avoid-modulo-in-constraints
Use when code uses modulo operations (%) in conditional expressions that involve symbolic variables
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Use when code uses modulo operations (%) in conditional expressions that involve symbolic variables
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-modulo-in-constraints |
| description | Use when code uses modulo operations (%) in conditional expressions that involve symbolic variables |
A KLEE-coverage code transformation. Applying it rewrites C source so symbolic execution explores more of the program's behavior.
When code uses modulo operations (%) in conditional expressions that involve symbolic variables
Replace integer arithmetic with modulo checks by using floating-point arithmetic and checking if the result is an integer (e.g., checking if rounded value equals original value)
Modulo operations create complex non-linear constraints that are difficult for SMT solvers to reason about, while floating-point comparisons with rounding create simpler constraints that KLEE can explore more efficiently
Before:
#include <stdio.h>
int n;
int main()
{
scanf("%d",&n);
//printf("y");
for (long long i=1;i<=3500;i++)
for (long long j=i;j<=3500;j++)
{
//printf("%lld %lld %lld\n",i,j,(i*j*n) );
if ( (3*i*j>n*(i+j) ) && (i*j*n)%( 4*i*j-n*(i+j) )==0 )
{
printf("%lld %lld %lld\n",i,j,(i*j*n)/(4*i*j-n*(i+j) ) );
return 0;
}
}
}
After:
#include <stdio.h>
#include <math.h>
int main(void){
double n,i,j,k,ans,ap;
scanf("%lf",&n);
ans = 4/n;
for (i=1;i<5000;i++)
{
for (j=1;j<5000;j++)
{
ap = ans - 1/i - 1/j;
if (ap >0)
{
ap = 1.0/ap;
ap = roundl(ap * 10000000) / 10000000;
if ((int)(ap) == ap)
{
printf("%d %d %d",(int)(i),(int)(j),(int)(ap));
return 0;
}
}
}
}
return 0;
}
a6aff26e