avoid-loop-based-sqrt
Use when computing square root through iterative loop (while i*i < target)
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Menu
Use when computing square root through iterative loop (while i*i < target)
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Baseado na classificação ocupacional SOC
Use when printf statements output strings without trailing newlines
Use when array is accessed with direct user input as index (0-based indexing)
Use when the program accesses a precomputed table using an offset (e.g., arr[n-1]) that introduces an arithmetic operation between the symbolic input and the index
Use when loop variables iterate over character values (e.g., ASCII codes) to represent different operations or choices
Use when code uses a loop to search for an input value in an array and then uses the found index for further computation
Use when code reads a fixed number of characters into an array and only accesses individual elements
| name | avoid-loop-based-sqrt |
| description | Use when computing square root through iterative loop (while i*i < target) |
A KLEE-coverage code transformation. Applying it rewrites C source so symbolic execution explores more of the program's behavior.
When computing square root through iterative loop (while i*i < target)
Replace the loop with direct sqrt() function call and integer comparison
Loops create path explosion in symbolic execution as each iteration generates new constraints, while sqrt() is typically modeled as a single operation
Before:
#include <stdio.h>
int main(void){
int a,b,d,t,i=0;
scanf("%d%d",&a,&b);
if (b==100) d=1000;
else if (b<10) d=10;
else d=100;
t=a*d+b;
while (i*i<t) i++;
printf("%s\n",(i*i==t)? "Yes":"No");
return 0;
}
After:
#include<stdio.h>
#include<math.h>
int main(){
int a,b;
scanf("%d%d",&a,&b);
if(b>=100)a=a*1000+b;
else if(b>=10)a=a*100+b;
else a=a*10+b;
b=sqrt(a+0.1);
if(b*b==a)puts("Yes");
else puts("No");
return 0;
}
882d2ca0