cirrus-uchicago/symbolon/avoid-sprintf-for-digit-extraction

Claude Code and agent skill by cirrus-uchicago/symbolon

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Use when code converts integers to strings via sprintf and compares character codes to extract digits for symbolic constraints

Install

npx vskill@latest install cirrus-uchicago/symbolon/avoid-sprintf-for-digit-extraction

SKILL.md

The same SKILL.md was published earlier as cirrus-uchicago/symbolon/avoid-sprintf-for-digit-extraction.

avoid-sprintf-for-digit-extraction

Overview

A KLEE-coverage code transformation. Applying it rewrites C source so symbolic execution explores more of the program's behavior.

When to use

When code converts integers to strings via sprintf and compares character codes to extract digits for symbolic constraints

Transformation

Replace sprintf-based digit extraction with direct arithmetic decomposition (repeated modulo and division by 10) storing digits in an integer array, and compare integers directly instead of characters

Why it helps

KLEE handles integer arithmetic constraints natively and efficiently, but sprintf involves complex libc string formatting routines that bloat path conditions and obscure the relationship between symbolic inputs and digit values, hindering constraint solving and path exploration

Example

Before:

c
#include <stdio.h>
int main()
{
int N, M, s[6], c[6];
scanf ("%d %d", &N, &M);
for (int i = 0; i < M; i++) scanf ("%d %d", &s[i], &c[i]);
int p = 1;
for (int i = 1; i < N; i++) p *= 10;
for (int d = p - (N == 1); d < p * 10; d++){
char S[10];
sprintf(S, "%d", d);
int g = 0;
for (int k = 0; k < M; k++){
if (S[s[k] - 1] == c[k] + '0') g++;
}
if (g == M){
puts(S);
return 0;
}
}
puts("-1");
return 0;
}

After:

c
#include <stdio.h>
#include <math.h>
int s[11], c[11], d[11], n;
void digit(int N)
{
int cnt = n;
while (N)
{
d[cnt--] = N % 10;
N /= 10;
}
}
int main(void)
{
int m, i, j;
scanf("%d %d", &n, &m);
for (i = 1; i <= m; i++)
scanf("%d %d", &s[i], &c[i]);
for (i = n > 1 ? (int)pow(10.0, n - 1.0) : 0; i < (int)pow(10.0, n); i++)
{
digit(i);
for (j = 1; j <= m; j++)
if (d[s[j]] != c[j])
break;
if (j == m + 1)
{
printf("%d", i);
return 0;
}
}
puts("-1");
return 0;
}

Evidence

  • Average coverage delta: 0.694
  • Source problems: train_AtCoder_p02761
  • Rule id: 84be5166

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
11
7-day trend score
17

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/cirrus-uchicago/symbolon/avoid-sprintf-for-digit-extraction/badge)](https://verified-skill.com/skills/cirrus-uchicago/symbolon/avoid-sprintf-for-digit-extraction)

Something wrong with this skill or its page? Tell us.