avoid-loop-based-search
Use when code uses a loop to search for a value that satisfies an equation or constraint
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Use when code uses a loop to search for a value that satisfies an equation or constraint
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
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-search |
| description | Use when code uses a loop to search for a value that satisfies an equation or constraint |
A KLEE-coverage code transformation. Applying it rewrites C source so symbolic execution explores more of the program's behavior.
When code uses a loop to search for a value that satisfies an equation or constraint
Replace the loop with a direct mathematical calculation to find the solution, using inverse operations or algebraic manipulation
Loops create many path constraints that KLEE must explore sequentially, while direct calculations produce simpler constraints that can be solved more efficiently by the constraint solver
Before:
#include <stdio.h>
int n;
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
if (i * 108 / 100 == n) {
printf("%d\n", i);
return 0;
}
}
printf(":(\n");
}
After:
#include <stdio.h>
#include <math.h>
int main(int argc, char const *argv[])
{
int n,m;
scanf("%d",&n);
m=ceil(n/1.08);
if(n==(int)(m*1.08)) printf("%d",m);
else printf(":(");
return 0;
}
ef425e7f