avoid-large-fixed-arrays
Use when code uses large fixed-size arrays (e.g., box[55555]) for sieve-based algorithms or marking/filtering operations
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Use when code uses large fixed-size arrays (e.g., box[55555]) for sieve-based algorithms or marking/filtering operations
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-large-fixed-arrays |
| description | Use when code uses large fixed-size arrays (e.g., box[55555]) for sieve-based algorithms or marking/filtering operations |
A KLEE-coverage code transformation. Applying it rewrites C source so symbolic execution explores more of the program's behavior.
When code uses large fixed-size arrays (e.g., box[55555]) for sieve-based algorithms or marking/filtering operations
Replace the large array-based sieve with direct primality testing using trial division up to sqrt(n), eliminating the need for pre-allocated marking arrays
Large arrays create complex memory constraints for KLEE, making it harder to reason about array accesses and increasing the symbolic execution state space, while direct computation with simple arithmetic operations produces simpler constraints
Before:
#include<stdio.h>
int main(){
int box[55555]={},a[55],i,j,n,cnt=0;
scanf("%d",&n);
for(i=2;i<55555;i++)box[i]=1;
for(i=2;i<55555;i++){
if(box[i]){
if(i%10==1) a[cnt++]=i;
for(j=i;j<55555;j+=i) box[j]=0;
}
if(cnt==n) break;
}
for(i=0;i<n;i++){
printf("%d ",a[i]);
}
printf("\n");
}
After:
#include <stdio.h>
#include <math.h>
int main()
{
int i, j, k,n,l;
scanf("%d", &n);
printf("2 ");
l = 1;
for (i = 3;;i += 2)
{
k = 0;
for (j = 3;j <= sqrt(i);j += 2)
{
if (i%j == 0)
{
k = 1;
break;
}
}
if (k == 0&&i%5==1) { printf("%d ", i); ++l;if (l == n) break; }
}
printf("\n");
return 0;
}
9bb5f880