decompiled_code:
__int64 __fastcall id_expr(struct __jmp_buf_tag env[1])
{
__int64 v1; // rdx
__int64 result; // rax
__m128d v3; // xmm0
int v4; // ebx
int v5; // eax
double v6; // xmm0_8
__m128d v7; // xmm3
__m128d v8; // xmm1
__m128d v9; // xmm3
double v10; // xmm0_8
double v11; // xmm0_8
double v12; // xmm0_8
double v13; // xmm0_8
double v14; // xmm0_8
double v15; // xmm0_8
double v16; // xmm1_8
double v17; // xmm0_8
double v18; // xmm0_8
double v19; // xmm0_8
double v20; // xmm0_8
double v21; // xmm0_8
double v22; // xmm0_8
double v23; // xmm0_8
double v24; // xmm0_8
double v25; // xmm0_8
double v26; // xmm0_8
double v27; // xmm1_8
double v28; // xmm0_8
double v29; // xmm1_8
double v30; // xmm0_8
char dest[35]; // [rsp+5h] [rbp-23h] BYREF

v1 = 4LL * SLODWORD(env[1].__saved_mask.__val[2]);
if ( LODWORD(env[1].__jmpbuf[v1 + 3]) != 2 )
return num_expr(env);
strcpy(dest, (const char *)&env[1].__jmpbuf[v1 + 5]);
lex(env);
if ( LODWORD(env[1].__jmpbuf[4 * SLODWORD(env[1].__saved_mask.__val[2]) + 3]) != 40 )
{
*(_QWORD *)&v3.m128d_f64[0] = LC22;
if ( (unsigned int)istrcmp((__int64)dest, (__int64)"pi") )
{
if ( (unsigned int)istrcmp((__int64)dest, (__int64)"e") )
longjmp(env, 8);
*(_QWORD *)&v3.m128d_f64[0] = LC29;
}
return push(env, v3.m128d_f64[0]);
}
lex(env);
if ( LODWORD(env[1].__jmpbuf[4 * SLODWORD(env[1].__saved_mask.__val[2]) + 3]) == 41 )
{
lex(env);
if ( !(unsigned int)istrcmp((__int64)dest, (__int64)"abs")
|| !(unsigned int)istrcmp((__int64)dest, (__int64)"ceil")
|| !(unsigned int)istrcmp((__int64)dest, (__int64)"floor")
|| !(unsigned int)istrcmp((__int64)dest, (__int64)"sin") )
{
goto LABEL_26;
}
v4 = 0;
}
else
{
v4 = 0;
do
{
++v4;
add_expr(env);
v5 = env[1].__jmpbuf[4 * SLODWORD(env[1].__saved_mask.__val[2]) + 3];
if ( v5 == 41 )
break;
if ( v5 != 44 )
longjmp(env, 5);
lex(env);
}
while ( LODWORD(env[1].__jmpbuf[4 * SLODWORD(env[1].__saved_mask.__val[2]) + 3]) != 41 );
lex(env);
if ( !(unsigned int)istrcmp((__int64)dest, (__int64)"abs") )
{
if ( v4 == 1 )
{
v6 = pop((__int64)env);
return push(env, COERCE_DOUBLE(*(_QWORD *)&v6 & LC2));
}
LABEL_26:
longjmp(env, 7);
}
if ( !(unsigned int)istrcmp((__int64)dest, (__int64)"ceil") )
{
if ( v4 == 1 )
{
v3.m128d_f64[0] = pop((__int64)env);
if ( COERCE_DOUBLE(*(_QWORD *)&v3.m128d_f64[0] & LC2) < 4.503599627370496e15 )
{
v7.m128d_f64[0] = v3.m128d_f64[0];
v8.m128d_f64[0] = (double)(int)v3.m128d_f64[0];
*(_QWORD *)&v3.m128d_f64[0] = COERCE_UNSIGNED_INT64(v8.m128d_f64[0] + COERCE_DOUBLE(*(_OWORD *)&_mm_cmpgt_sd(v7, v8) & LC5)) | ~(_QWORD)LC2 & *(_QWORD *)&v3.m128d_f64[0];
}
return push(env, v3.m128d_f64[0]);
}
goto LABEL_26;
}
if ( !(unsigned int)istrcmp((__int64)dest, (__int64)"floor") )
{
if ( v4 == 1 )
{
v3.m128d_f64[0] = pop((__int64)env);
if ( COERCE_DOUBLE(*(_QWORD *)&v3.m128d_f64[0] & LC2) < 4.503599627370496e15 )
{
v9.m128d_f64[0] = (double)(int)v3.m128d_f64[0];
*(_QWORD *)&v3.m128d_f64[0] = COERCE_UNSIGNED_INT64(v9.m128d_f64[0] - COERCE_DOUBLE(*(_OWORD *)&_mm_cmpgt_sd(v9, v3) & LC5)) | ~(_QWORD)LC2 & *(_QWORD *)&v3.m128d_f64[0];
}
return push(env, v3.m128d_f64[0]);
}
goto LABEL_26;
}
if ( !(unsigned int)istrcmp((__int64)dest, (__int64)"sin") )
{
if ( v4 != 1 )
goto LABEL_26;
v10 = pop((__int64)env);
v3.m128d_f64[0] = sin(v10);
return push(env, v3.m128d_f64[0]);
}
}
if ( !(unsigned int)istrcmp((__int64)dest, (__int64)"asin") )
{
if ( v4 != 1 )
goto LABEL_26;
v11 = pop((__int64)env);
v3.m128d_f64[0] = asin(v11);
return push(env, v3.m128d_f64[0]);
}
if ( !(unsigned int)istrcmp((__int64)dest, (__int64)"cos") )
{
if ( v4 != 1 )
goto LABEL_26;
v12 = pop((__int64)env);
v3.m128d_f64[0] = cos(v12);
return push(env, v3.m128d_f64[0]);
}
if ( !(unsigned int)istrcmp((__int64)dest, (__int64)"acos") )
{
if ( v4 != 1 )
goto LABEL_26;
v13 = pop((__int64)env);
v3.m128d_f64[0] = acos(v13);
return push(env, v3.m128d_f64[0]);
}
if ( !(unsigned int)istrcmp((__int64)dest, (__int64)"tan") )
{
if ( v4 != 1 )
goto LABEL_26;
v14 = pop((__int64)env);
v3.m128d_f64[0] = tan(v14);
return push(env, v3.m128d_f64[0]);
}
if ( !(unsigned int)istrcmp((__int64)dest, (__int64)"atan") )
{
if ( v4 != 1 )
goto LABEL_26;
v15 = pop((__int64)env);
v3.m128d_f64[0] = atan(v15);
return push(env, v3.m128d_f64[0]);
}
if ( !(unsigned int)istrcmp((__int64)dest, (__int64)"atan2") )
{
if ( v4 != 2 )
goto LABEL_26;
v16 = pop((__int64)env);
v17 = pop((__int64)env);
v3.m128d_f64[0] = atan2(v17, v16);
return push(env, v3.m128d_f64[0]);
}
if ( !(unsigned int)istrcmp((__int64)dest, (__int64)"sinh") )
{
if ( v4 != 1 )
goto LABEL_26;
v18 = pop((__int64)env);
v3.m128d_f64[0] = sinh(v18);
return push(env, v3.m128d_f64[0]);
}
if ( !(unsigned int)istrcmp((__int64)dest, (__int64)"cosh") )
{
if ( v4 != 1 )
goto LABEL_26;
v19 = pop((__int64)env);
v3.m128d_f64[0] = cosh(v19);
return push(env, v3.m128d_f64[0]);
}
if ( !(unsigned int)istrcmp((__int64)dest, (__int64)"tanh") )
{
if ( v4 != 1 )
goto LABEL_26;
v20 = pop((__int64)env);
v3.m128d_f64[0] = tanh(v20);
return push(env, v3.m128d_f64[0]);
}
if ( !(unsigned int)istrcmp((__int64)dest, (__int64)"log") )
{
if ( v4 != 1 )
goto LABEL_26;
v21 = pop((__int64)env);
v3.m128d_f64[0] = log(v21);
return push(env, v3.m128d_f64[0]);
}
if ( !(unsigned int)istrcmp((__int64)dest, (__int64)"log10") )
{
if ( v4 != 1 )
goto LABEL_26;
v22 = pop((__int64)env);
v3.m128d_f64[0] = log10(v22);
return push(env, v3.m128d_f64[0]);
}
if ( !(unsigned int)istrcmp((__int64)dest, (__int64)"exp") )
{
if ( v4 != 1 )
goto LABEL_26;
v23 = pop((__int64)env);
v3.m128d_f64[0] = exp(v23);
return push(env, v3.m128d_f64[0]);
}
if ( !(unsigned int)istrcmp((__int64)dest, (__int64)"sqrt") )
{
if ( v4 != 1 )
goto LABEL_26;
v24 = pop((__int64)env);
v3.m128d_f64[0] = sqrt(v24);
return push(env, v3.m128d_f64[0]);
}
if ( (unsigned int)istrcmp((__int64)dest, (__int64)"rad") )
{
if ( (unsigned int)istrcmp((__int64)dest, (__int64)"deg") )
{
if ( (unsigned int)istrcmp((__int64)dest, (__int64)"pow") )
{
if ( (unsigned int)istrcmp((__int64)dest, (__int64)"hypot") )
longjmp(env, 6);
if ( v4 != 2 )
goto LABEL_26;
v29 = pop((__int64)env);
v30 = pop((__int64)env);
v3.m128d_f64[0] = sqrt(v30 * v30 + v29 * v29);
}
else
{
if ( v4 != 2 )
goto LABEL_26;
v27 = pop((__int64)env);
v28 = pop((__int64)env);
v3.m128d_f64[0] = pow(v28, v27);
}
return push(env, v3.m128d_f64[0]);
}
if ( v4 != 1 )
goto LABEL_26;
v26 = pop((__int64)env);
result = push(env, v26 * 180.0 / 3.141592654);
}
else
{
if ( v4 != 1 )
goto LABEL_26;
v25 = pop((__int64)env);
result = push(env, v25 * 3.141592654 / 180.0);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(struct __jmp_buf_tag env[1])
{
__int64 v1; // rdx
__int64 result; // rax
__m128d v3; // xmm0
int v4; // ebx
int v5; // eax
double v6; // xmm0_8
__m128d v7; // xmm3
__m128d v8; // xmm1
__m128d v9; // xmm3
double v10; // xmm0_8
double v11; // xmm0_8
double v12; // xmm0_8
double v13; // xmm0_8
double v14; // xmm0_8
double v15; // xmm0_8
double v16; // xmm1_8
double v17; // xmm0_8
double v18; // xmm0_8
double v19; // xmm0_8
double v20; // xmm0_8
double v21; // xmm0_8
double v22; // xmm0_8
double v23; // xmm0_8
double v24; // xmm0_8
double v25; // xmm0_8
double v26; // xmm0_8
double v27; // xmm1_8
double v28; // xmm0_8
double v29; // xmm1_8
double v30; // xmm0_8
char dest[35]; // [rsp+5h] [rbp-23h] BYREF

v1 = 4LL * SLODWORD(env[1].__saved_mask.__val[2]);
if ( LODWORD(env[1].__jmpbuf[v1 + 3]) != 2 )
return func4(env);
strcpy(dest, (const char *)&env[1].__jmpbuf[v1 + 5]);
func1(env);
if ( LODWORD(env[1].__jmpbuf[4 * SLODWORD(env[1].__saved_mask.__val[2]) + 3]) != 40 )
{
*(_QWORD *)&v3.m128d_f64[0] = LC22;
if ( (unsigned int)func2((__int64)dest, (__int64)"pi") )
{
if ( (unsigned int)func2((__int64)dest, (__int64)"e") )
longjmp(env, 8);
*(_QWORD *)&v3.m128d_f64[0] = LC29;
}
return func3(env, v3.m128d_f64[0]);
}
func1(env);
if ( LODWORD(env[1].__jmpbuf[4 * SLODWORD(env[1].__saved_mask.__val[2]) + 3]) == 41 )
{
func1(env);
if ( !(unsigned int)func2((__int64)dest, (__int64)"abs")
|| !(unsigned int)func2((__int64)dest, (__int64)"ceil")
|| !(unsigned int)func2((__int64)dest, (__int64)"floor")
|| !(unsigned int)func2((__int64)dest, (__int64)"sin") )
{
goto LABEL_26;
}
v4 = 0;
}
else
{
v4 = 0;
do
{
++v4;
func6(env);
v5 = env[1].__jmpbuf[4 * SLODWORD(env[1].__saved_mask.__val[2]) + 3];
if ( v5 == 41 )
break;
if ( v5 != 44 )
longjmp(env, 5);
func1(env);
}
while ( LODWORD(env[1].__jmpbuf[4 * SLODWORD(env[1].__saved_mask.__val[2]) + 3]) != 41 );
func1(env);
if ( !(unsigned int)func2((__int64)dest, (__int64)"abs") )
{
if ( v4 == 1 )
{
v6 = func0((__int64)env);
return func3(env, COERCE_DOUBLE(*(_QWORD *)&v6 & LC2));
}
LABEL_26:
longjmp(env, 7);
}
if ( !(unsigned int)func2((__int64)dest, (__int64)"ceil") )
{
if ( v4 == 1 )
{
v3.m128d_f64[0] = func0((__int64)env);
if ( COERCE_DOUBLE(*(_QWORD *)&v3.m128d_f64[0] & LC2) < 4.503599627370496e15 )
{
v7.m128d_f64[0] = v3.m128d_f64[0];
v8.m128d_f64[0] = (double)(int)v3.m128d_f64[0];
*(_QWORD *)&v3.m128d_f64[0] = COERCE_UNSIGNED_INT64(v8.m128d_f64[0] + COERCE_DOUBLE(*(_OWORD *)&_mm_cmpgt_sd(v7, v8) & LC5)) | ~(_QWORD)LC2 & *(_QWORD *)&v3.m128d_f64[0];
}
return func3(env, v3.m128d_f64[0]);
}
goto LABEL_26;
}
if ( !(unsigned int)func2((__int64)dest, (__int64)"floor") )
{
if ( v4 == 1 )
{
v3.m128d_f64[0] = func0((__int64)env);
if ( COERCE_DOUBLE(*(_QWORD *)&v3.m128d_f64[0] & LC2) < 4.503599627370496e15 )
{
v9.m128d_f64[0] = (double)(int)v3.m128d_f64[0];
*(_QWORD *)&v3.m128d_f64[0] = COERCE_UNSIGNED_INT64(v9.m128d_f64[0] - COERCE_DOUBLE(*(_OWORD *)&_mm_cmpgt_sd(v9, v3) & LC5)) | ~(_QWORD)LC2 & *(_QWORD *)&v3.m128d_f64[0];
}
return func3(env, v3.m128d_f64[0]);
}
goto LABEL_26;
}
if ( !(unsigned int)func2((__int64)dest, (__int64)"sin") )
{
if ( v4 != 1 )
goto LABEL_26;
v10 = func0((__int64)env);
v3.m128d_f64[0] = sin(v10);
return func3(env, v3.m128d_f64[0]);
}
}
if ( !(unsigned int)func2((__int64)dest, (__int64)"asin") )
{
if ( v4 != 1 )
goto LABEL_26;
v11 = func0((__int64)env);
v3.m128d_f64[0] = asin(v11);
return func3(env, v3.m128d_f64[0]);
}
if ( !(unsigned int)func2((__int64)dest, (__int64)"cos") )
{
if ( v4 != 1 )
goto LABEL_26;
v12 = func0((__int64)env);
v3.m128d_f64[0] = cos(v12);
return func3(env, v3.m128d_f64[0]);
}
if ( !(unsigned int)func2((__int64)dest, (__int64)"acos") )
{
if ( v4 != 1 )
goto LABEL_26;
v13 = func0((__int64)env);
v3.m128d_f64[0] = acos(v13);
return func3(env, v3.m128d_f64[0]);
}
if ( !(unsigned int)func2((__int64)dest, (__int64)"tan") )
{
if ( v4 != 1 )
goto LABEL_26;
v14 = func0((__int64)env);
v3.m128d_f64[0] = tan(v14);
return func3(env, v3.m128d_f64[0]);
}
if ( !(unsigned int)func2((__int64)dest, (__int64)"atan") )
{
if ( v4 != 1 )
goto LABEL_26;
v15 = func0((__int64)env);
v3.m128d_f64[0] = atan(v15);
return func3(env, v3.m128d_f64[0]);
}
if ( !(unsigned int)func2((__int64)dest, (__int64)"atan2") )
{
if ( v4 != 2 )
goto LABEL_26;
v16 = func0((__int64)env);
v17 = func0((__int64)env);
v3.m128d_f64[0] = atan2(v17, v16);
return func3(env, v3.m128d_f64[0]);
}
if ( !(unsigned int)func2((__int64)dest, (__int64)"sinh") )
{
if ( v4 != 1 )
goto LABEL_26;
v18 = func0((__int64)env);
v3.m128d_f64[0] = sinh(v18);
return func3(env, v3.m128d_f64[0]);
}
if ( !(unsigned int)func2((__int64)dest, (__int64)"cosh") )
{
if ( v4 != 1 )
goto LABEL_26;
v19 = func0((__int64)env);
v3.m128d_f64[0] = cosh(v19);
return func3(env, v3.m128d_f64[0]);
}
if ( !(unsigned int)func2((__int64)dest, (__int64)"tanh") )
{
if ( v4 != 1 )
goto LABEL_26;
v20 = func0((__int64)env);
v3.m128d_f64[0] = tanh(v20);
return func3(env, v3.m128d_f64[0]);
}
if ( !(unsigned int)func2((__int64)dest, (__int64)"log") )
{
if ( v4 != 1 )
goto LABEL_26;
v21 = func0((__int64)env);
v3.m128d_f64[0] = log(v21);
return func3(env, v3.m128d_f64[0]);
}
if ( !(unsigned int)func2((__int64)dest, (__int64)"log10") )
{
if ( v4 != 1 )
goto LABEL_26;
v22 = func0((__int64)env);
v3.m128d_f64[0] = log10(v22);
return func3(env, v3.m128d_f64[0]);
}
if ( !(unsigned int)func2((__int64)dest, (__int64)"exp") )
{
if ( v4 != 1 )
goto LABEL_26;
v23 = func0((__int64)env);
v3.m128d_f64[0] = exp(v23);
return func3(env, v3.m128d_f64[0]);
}
if ( !(unsigned int)func2((__int64)dest, (__int64)"sqrt") )
{
if ( v4 != 1 )
goto LABEL_26;
v24 = func0((__int64)env);
v3.m128d_f64[0] = sqrt(v24);
return func3(env, v3.m128d_f64[0]);
}
if ( (unsigned int)func2((__int64)dest, (__int64)"rad") )
{
if ( (unsigned int)func2((__int64)dest, (__int64)"deg") )
{
if ( (unsigned int)func2((__int64)dest, (__int64)"pow") )
{
if ( (unsigned int)func2((__int64)dest, (__int64)"hypot") )
longjmp(env, 6);
if ( v4 != 2 )
goto LABEL_26;
v29 = func0((__int64)env);
v30 = func0((__int64)env);
v3.m128d_f64[0] = sqrt(v30 * v30 + v29 * v29);
}
else
{
if ( v4 != 2 )
goto LABEL_26;
v27 = func0((__int64)env);
v28 = func0((__int64)env);
v3.m128d_f64[0] = pow(v28, v27);
}
return func3(env, v3.m128d_f64[0]);
}
if ( v4 != 1 )
goto LABEL_26;
v26 = func0((__int64)env);
result = func3(env, v26 * 180.0 / 3.141592654);
}
else
{
if ( v4 != 1 )
goto LABEL_26;
v25 = func0((__int64)env);
result = func3(env, v25 * 3.141592654 / 180.0);
}
return result;
}

original_code:
static void id_expr(struct eval *ev)
{
 if((ev->token[ev->cur_tok].type) == 2)
 {
  char id[11];
  strcpy(id, ev->token[ev->cur_tok].s_val);
  lex(ev);
  if((ev->token[ev->cur_tok].type) == '(')
  {
   int nargs = 0;
   lex(ev);
   while((ev->token[ev->cur_tok].type) != ')')
   {
    add_expr(ev);
    nargs++;
    if((ev->token[ev->cur_tok].type) == ')') break;
    if((ev->token[ev->cur_tok].type) != ',')
     longjmp(ev->j, (5));
    lex(ev);
   }
   lex(ev);
   if(!istrcmp(id, "abs"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, fabs(pop(ev)));
   }
   else if(!istrcmp(id, "ceil"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, ceil(pop(ev)));
   }
   else if(!istrcmp(id, "floor"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, floor(pop(ev)));
   }
   else if(!istrcmp(id, "sin"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, sin(pop(ev)));
   }
   else if(!istrcmp(id, "asin"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, asin(pop(ev)));
   }
   else if(!istrcmp(id, "cos"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, cos(pop(ev)));
   }
   else if(!istrcmp(id, "acos"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, acos(pop(ev)));
   }
   else if(!istrcmp(id, "tan"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, tan(pop(ev)));
   }
   else if(!istrcmp(id, "atan"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, atan(pop(ev)));
   }
   else if(!istrcmp(id, "atan2"))
   {
    double a, b;
    if(nargs != 2) longjmp(ev->j, (7));
    b = pop(ev);
    a = pop(ev);
    push(ev, atan2(a,b));
   }
   else if(!istrcmp(id, "sinh"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, sinh(pop(ev)));
   }
   else if(!istrcmp(id, "cosh"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, cosh(pop(ev)));
   }
   else if(!istrcmp(id, "tanh"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, tanh(pop(ev)));
   }
   else if(!istrcmp(id, "log"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, log(pop(ev)));
   }
   else if(!istrcmp(id, "log10"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, log10(pop(ev)));
   }
   else if(!istrcmp(id, "exp"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, exp(pop(ev)));
   }
   else if(!istrcmp(id, "sqrt"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, sqrt(pop(ev)));
   }
   else if(!istrcmp(id, "rad"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, pop(ev)*3.141592654/180);
   }
   else if(!istrcmp(id, "deg"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, pop(ev)*180/3.141592654);
   }
   else if(!istrcmp(id, "pow"))
   {
    double a, b;
    if(nargs != 2) longjmp(ev->j, (7));
    b = pop(ev);
    a = pop(ev);
    push(ev, pow(a,b));
   }
   else if(!istrcmp(id, "hypot"))
   {
    double a, b;
    if(nargs != 2) longjmp(ev->j, (7));
    b = pop(ev);
    a = pop(ev);
    push(ev, sqrt(a*a + b*b));
   }
   else
    longjmp(ev->j, (6));
  }
  else
  {
   if(!istrcmp(id, "pi"))
    push(ev, 3.141592654);
   else if(!istrcmp(id, "e"))
    push(ev, 2.718281828);
   else
    longjmp(ev->j, (8));
  }
 }
 else
  num_expr(ev);
}

canonical_original_code:
static void id_expr(struct eval *ev)
{
 if((ev->token[ev->cur_tok].type) == 2)
 {
  char id[11];
  strcpy(id, ev->token[ev->cur_tok].s_val);
  lex(ev);
  if((ev->token[ev->cur_tok].type) == '(')
  {
   int nargs = 0;
   lex(ev);
   while((ev->token[ev->cur_tok].type) != ')')
   {
    add_expr(ev);
    nargs++;
    if((ev->token[ev->cur_tok].type) == ')') break;
    if((ev->token[ev->cur_tok].type) != ',')
     longjmp(ev->j, (5));
    lex(ev);
   }
   lex(ev);
   if(!istrcmp(id, "abs"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, fabs(pop(ev)));
   }
   else if(!istrcmp(id, "ceil"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, ceil(pop(ev)));
   }
   else if(!istrcmp(id, "floor"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, floor(pop(ev)));
   }
   else if(!istrcmp(id, "sin"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, sin(pop(ev)));
   }
   else if(!istrcmp(id, "asin"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, asin(pop(ev)));
   }
   else if(!istrcmp(id, "cos"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, cos(pop(ev)));
   }
   else if(!istrcmp(id, "acos"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, acos(pop(ev)));
   }
   else if(!istrcmp(id, "tan"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, tan(pop(ev)));
   }
   else if(!istrcmp(id, "atan"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, atan(pop(ev)));
   }
   else if(!istrcmp(id, "atan2"))
   {
    double a; double b;
    if(nargs != 2) longjmp(ev->j, (7));
    b = pop(ev);
    a = pop(ev);
    push(ev, atan2(a,b));
   }
   else if(!istrcmp(id, "sinh"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, sinh(pop(ev)));
   }
   else if(!istrcmp(id, "cosh"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, cosh(pop(ev)));
   }
   else if(!istrcmp(id, "tanh"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, tanh(pop(ev)));
   }
   else if(!istrcmp(id, "log"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, log(pop(ev)));
   }
   else if(!istrcmp(id, "log10"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, log10(pop(ev)));
   }
   else if(!istrcmp(id, "exp"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, exp(pop(ev)));
   }
   else if(!istrcmp(id, "sqrt"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, sqrt(pop(ev)));
   }
   else if(!istrcmp(id, "rad"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, pop(ev)*3.141592654/180);
   }
   else if(!istrcmp(id, "deg"))
   {
    if(nargs != 1) longjmp(ev->j, (7));
    push(ev, pop(ev)*180/3.141592654);
   }
   else if(!istrcmp(id, "pow"))
   {
    double a; double b;
    if(nargs != 2) longjmp(ev->j, (7));
    b = pop(ev);
    a = pop(ev);
    push(ev, pow(a,b));
   }
   else if(!istrcmp(id, "hypot"))
   {
    double a; double b;
    if(nargs != 2) longjmp(ev->j, (7));
    b = pop(ev);
    a = pop(ev);
    push(ev, sqrt(a*a + b*b));
   }
   else
    longjmp(ev->j, (6));
  }
  else
  {
   if(!istrcmp(id, "pi"))
    push(ev, 3.141592654);
   else if(!istrcmp(id, "e"))
    push(ev, 2.718281828);
   else
    longjmp(ev->j, (8));
  }
 }
 else
  num_expr(ev);
}

variable_types:
id
char [11]

variable_types: nargs int


repo: wernsey/miscsrc

decompiled_code:
__int64 __fastcall bra_expr(struct __jmp_buf_tag env[1])
{
if ( LODWORD(env[1].__jmpbuf[4 * SLODWORD(env[1].__saved_mask.__val[2]) + 3]) != 40 )
return id_expr(env);
lex(env);
add_expr(env);
if ( LODWORD(env[1].__jmpbuf[4 * SLODWORD(env[1].__saved_mask.__val[2]) + 3]) != 41 )
longjmp(env, 5);
return lex(env);
}

canonical_decompiled_code:
__int64 __fastcall func8(struct __jmp_buf_tag env[1])
{
if ( LODWORD(env[1].__jmpbuf[4 * SLODWORD(env[1].__saved_mask.__val[2]) + 3]) != 40 )
return func7(env);
func1(env);
func6(env);
if ( LODWORD(env[1].__jmpbuf[4 * SLODWORD(env[1].__saved_mask.__val[2]) + 3]) != 41 )
longjmp(env, 5);
return func1(env);
}

original_code:
static void bra_expr(struct eval *ev)
{
 if((ev->token[ev->cur_tok].type) == '(')
 {
  lex(ev);
  add_expr(ev);
  if((ev->token[ev->cur_tok].type) != ')')
   longjmp(ev->j, (5));
  lex(ev);
 }
 else
   id_expr(ev);
}

variable_types: struct eval { struct __jmp_buf_tag { long __jmpbuf[8]; int __mask_was_saved; struct __sigset_t { unsigned long __val[-1]; } __saved_mask; } j[1]; char *p; double *st; int st_size; int sp; struct { int type; double n_val; char s_val[11]; } token[2]; int cur_tok; } *

return_type: void

user_defined_types: struct eval { struct __jmp_buf_tag j[1]; char *p; double *st; int st_size; int sp; struct { int type; double n_val; char s_val[11]; } token[2]; int cur_tok; }

user_defined_types: struct __jmp_buf_tag { long __jmpbuf[8]; int __mask_was_saved; struct __sigset_t __saved_mask; }


decompiled_code:
__int64 __fastcall uni_expr(struct __jmp_buf_tag env[1])
{
int v1; // ebx
__int64 result; // rax
double v3; // xmm0_8

v1 = env[1].__jmpbuf[4 * SLODWORD(env[1].__saved_mask.__val[2]) + 3];
if ( ((v1 - 43) & 0xFFFFFFFD) != 0 )
return bra_expr(env);
lex(env);
result = bra_expr(env);
if ( v1 == 45 )
{
v3 = pop((__int64)env);
result = push(env, COERCE_DOUBLE(*(_QWORD *)&v3 ^ LC30));
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(struct __jmp_buf_tag env[1])
{
int v1; // ebx
__int64 result; // rax
double v3; // xmm0_8

v1 = env[1].__jmpbuf[4 * SLODWORD(env[1].__saved_mask.__val[2]) + 3];
if ( ((v1 - 43) & 0xFFFFFFFD) != 0 )
return func8(env);
func1(env);
result = func8(env);
if ( v1 == 45 )
{
v3 = func0((__int64)env);
result = func3(env, COERCE_DOUBLE(*(_QWORD *)&v3 ^ LC30));
}
return result;
}

original_code:
static void uni_expr(struct eval *ev)
{
 int t = '+';
 if((ev->token[ev->cur_tok].type) == '-' || (ev->token[ev->cur_tok].type) == '+')
 {
  t = (ev->token[ev->cur_tok].type);
  lex(ev);
 }
 bra_expr(ev);
 if(t == '-')
 {
  double a = pop(ev);
  push(ev, -a);
 }
}

variable_types: t int

variable_types: a double

user_defined_types: struct __sigset_t { unsigned long __val[-1]; }


decompiled_code:
__int64 __fastcall pow_expr(struct __jmp_buf_tag env[1])
{
__int64 result; // rax
double v2; // xmm1_8
double v3; // xmm0_8
double v4; // xmm0_8

uni_expr(env);
result = 32LL * SLODWORD(env[1].__saved_mask.__val[2]);
if ( *(_DWORD *)((char *)&env[1].__jmpbuf[3] + result) == 94 )
{
lex(env);
pow_expr(env);
v2 = pop((__int64)env);
v3 = pop((__int64)env);
v4 = pow(v3, v2);
result = push(env, v4);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(struct __jmp_buf_tag env[1])
{
__int64 result; // rax
double v2; // xmm1_8
double v3; // xmm0_8
double v4; // xmm0_8

func9(env);
result = 32LL * SLODWORD(env[1].__saved_mask.__val[2]);
if ( *(_DWORD *)((char *)&env[1].__jmpbuf[3] + result) == 94 )
{
func1(env);
func10(env);
v2 = func0((__int64)env);
v3 = func0((__int64)env);
v4 = pow(v3, v2);
result = func3(env, v4);
}
return result;
}

original_code:
static void pow_expr(struct eval *ev)
{
 uni_expr(ev);
 if((ev->token[ev->cur_tok].type) == '^')
 {
  double a,b;
  lex(ev);
  pow_expr(ev);
  b = pop(ev);
  a = pop(ev);
  push(ev, pow(a,b));
 }
}

canonical_original_code:
static void pow_expr(struct eval *ev)
{
 uni_expr(ev);
 if((ev->token[ev->cur_tok].type) == '^')
 {
  double a; double b;
  lex(ev);
  pow_expr(ev);
  b = pop(ev);
  a = pop(ev);
  push(ev, pow(a,b));
 }
}

variable_types: b double


eval

decompiled_code:
void __fastcall eval(__int64 a1, int *a2)
{
int v2; // eax
jmp_buf env; // [rsp+20h] [rbp-138h] BYREF
__int64 v4; // [rsp+E8h] [rbp-70h]
void *ptr; // [rsp+F0h] [rbp-68h]
int v6; // [rsp+F8h] [rbp-60h]
int v7; // [rsp+FCh] [rbp-5Ch]
int v8; // [rsp+100h] [rbp-58h]
char v9; // [rsp+110h] [rbp-48h]
int v10; // [rsp+120h] [rbp-38h]
char v11; // [rsp+130h] [rbp-28h]
int v12; // [rsp+140h] [rbp-18h]

v6 = 10;
ptr = calloc(0xAuLL, 8uLL);
if ( ptr )
{
v7 = 0;
v2 = setjmp(env);
*a2 = v2;
if ( !v2 )
{
v8 = 1;
v9 = 0;
v10 = 1;
v11 = 0;
v12 = 0;
v4 = a1;
if ( (unsigned int)lex(env) )
{
expr(env);
pop((__int64)env);
}
}
free(ptr);
}
else
{
*a2 = 1;
}
}

canonical_decompiled_code:
void __fastcall func12(__int64 a1, int *a2)
{
int v2; // eax
jmp_buf env; // [rsp+20h] [rbp-138h] BYREF
__int64 v4; // [rsp+E8h] [rbp-70h]
void *ptr; // [rsp+F0h] [rbp-68h]
int v6; // [rsp+F8h] [rbp-60h]
int v7; // [rsp+FCh] [rbp-5Ch]
int v8; // [rsp+100h] [rbp-58h]
char v9; // [rsp+110h] [rbp-48h]
int v10; // [rsp+120h] [rbp-38h]
char v11; // [rsp+130h] [rbp-28h]
int v12; // [rsp+140h] [rbp-18h]

v6 = 10;
ptr = calloc(0xAuLL, 8uLL);
if ( ptr )
{
v7 = 0;
v2 = setjmp(env);
*a2 = v2;
if ( !v2 )
{
v8 = 1;
v9 = 0;
v10 = 1;
v11 = 0;
v12 = 0;
v4 = a1;
if ( (unsigned int)func1(env) )
{
func11(env);
func0((__int64)env);
}
}
free(ptr);
}
else
{
*a2 = 1;
}
}

original_code:
double eval(const char *exp, int *ep)
{
 struct eval ev;
 double ans = 0.0;
 ((void) (0));
 ev.st_size = 10;
 ev.st = calloc(ev.st_size, sizeof *ev.st);
 if(!ev.st)
 {
  *ep = 1;
  return 0.0;
 }
 ev.sp = 0;
 *ep = _setjmp (ev.j);
 if(*ep != 0)
 {
  free(ev.st);
  return 0.0;
 }
 ev.token[0].type = 1;
 ev.token[0].s_val[0] = '\0';
 ev.token[1].type = 1;
 ev.token[1].s_val[0] = '\0';
 ev.cur_tok = 0;
 ev.p = exp;
 if(lex(&ev) != 0)
 {
  expr(&ev);
  ans = pop(&ev);
 }
 free(ev.st);
 return ans;
}

canonical_original_code:
double eval(char *exp, int *ep)
{
 struct eval ev;
 double ans = 0.0;
 ((void) (0));
 ev.st_size = 10;
 ev.st = calloc(ev.st_size, sizeof *ev.st);
 if(!ev.st)
 {
  *ep = 1;
  return 0.0;
 }
 ev.sp = 0;
 *ep = _setjmp (ev.j);
 if(*ep != 0)
 {
  free(ev.st);
  return 0.0;
 }
 ev.token[0].type = 1;
 ev.token[0].s_val[0] = '\0';
 ev.token[1].type = 1;
 ev.token[1].s_val[0] = '\0';
 ev.cur_tok = 0;
 ev.p = exp;
 if(lex(&ev) != 0)
 {
  expr(&ev);
  ans = pop(&ev);
 }
 free(ev.st);
 return ans;
}

variable_types:
exp
char *

variable_types:
ep
int *

variable_types: struct eval { struct __jmp_buf_tag { long __jmpbuf[8]; int __mask_was_saved; struct __sigset_t { unsigned long __val[-1]; } __saved_mask; } j[1]; char *p; double *st; int st_size; int sp; struct { int type; double n_val; char s_val[11]; } token[2]; int cur_tok; }

variable_types: ans double

return_type: double


decompiled_code:
const char *__fastcall eval_error(unsigned int a1)
{
const char *result; // rax

result = "unknown error";
if ( a1 <= 8 )
result = (&CSWTCH_23)[a1];
return result;
}

canonical_decompiled_code:
const char *__fastcall func13(unsigned int a1)
{
const char *result; // rax

result = "unknown error";
if ( a1 <= 8 )
result = (&CSWTCH_23)[a1];
return result;
}

original_code:
const char *eval_error(int err)
{
 switch(err)
 {
 case 0: return "no error";
 case 1: return "out of memory";
 case 2: return "unknown token";
 case 3: return "identifier too long";
 case 4: return "value expected";
 case 5: return "missing ')'";
 case 6: return "unknown function";
 case 7: return "wrong number of arguments";
 case 8: return "unknown constant";
 }
 return "unknown error";
}

variable_types: err int

return_type: char *


expr

decompiled_code:
// attributes: thunk
__int64 __fastcall expr(struct __jmp_buf_tag *a1)
{
return add_expr(a1);
}

canonical_decompiled_code:
__int64 __fastcall func11(struct __jmp_buf_tag *a1)
{
return func6(a1);
}

original_code:
static void expr(struct eval *ev)
{
 add_expr(ev);
}


original_code:
int
ht_rehash (struct hash_tbl *ht, int new_size)
{
  struct hash_el **buckets, *j, *e, *k;
  int i, h;
  if (new_size >= 100000)
    {
      if (ht->size < 100000)
        new_size = 100000;
      else
        return 0;
    }
  buckets = calloc (new_size, sizeof *buckets);
  if (!buckets)
    return 0;
  for (i = 0; i < ht->size; i++)
    for (j = ht->buckets[i]; j;)
      {
        h = hash (j->key, new_size);
        e = j;
        j = j->next;
        e->next = ((void *)0);
        if (buckets[h])
          {
            for (k = buckets[h]; k->next; k = k->next);
            k->next = e;
          }
        else
          buckets[h] = e;
      }
  free (ht->buckets);
  ht->buckets = buckets;
  ht->size = new_size;
  return 1;
}

canonical_original_code:
int ht_rehash(struct hash_tbl *ht, int new_size)
{
  struct hash_el **buckets; struct hash_el *j; struct hash_el *e; struct hash_el *k;
  int i; int h;
  if (new_size >= 100000)
    {
      if (ht->size < 100000)
        new_size = 100000;
      else
        return 0;
    }
  buckets = calloc (new_size, sizeof *buckets);
  if (!buckets)
    return 0;
  for (i = 0; i < ht->size; i++)
    for (j = ht->buckets[i]; j;)
      {
        h = hash (j->key, new_size);
        e = j;
        j = j->next;
        e->next = ((void *)0);
        if (buckets[h])
          {
            for (k = buckets[h]; k->next; k = k->next);
            k->next = e;
          }
        else
          buckets[h] = e;
      }
  free (ht->buckets);
  ht->buckets = buckets;
  ht->size = new_size;
  return 1;
}

variable_types: struct hash_tbl { struct hash_el { char *key; void *value; struct hash_el *next; } **buckets; int size; int cnt; } *

variable_types: i int

variable_types: h int

return_type: int

user_defined_types: struct hash_tbl { struct hash_el **buckets; int size; int cnt; }


decompiled_code:
__int64 __fastcall ht_find(__int64 a1, char *a2)
{
__int64 result; // rax

result = search_isra_0(*(_QWORD *)a1, *(_DWORD *)(a1 + 8), a2);
if ( result )
result = *(_QWORD *)(result + 8);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, char *a2)
{
__int64 result; // rax

result = func1(*(_QWORD *)a1, *(_DWORD *)(a1 + 8), a2);
if ( result )
result = *(_QWORD *)(result + 8);
return result;
}

original_code:
void *
ht_find (struct hash_tbl *h, const char *key)
{
  int f;
  struct hash_el *i = search (h, key, &f);
  if (i)
    return i->value;
  return ((void *)0);
}

canonical_original_code:
void *ht_find(struct hash_tbl *h, char *key)
{
  int f;
  struct hash_el *i = search (h, key, &f);
  if (i)
    return i->value;
  return ((void *)0);
}

variable_types:
key
char *

variable_types: f int

variable_types: struct hash_el { char *key; void *value; struct hash_el *next; } *

return_type: void *


original_code:
void *
ht_delete (struct hash_tbl *h, const char *key)
{
  struct hash_el *i, *p = ((void *)0);
  void *d = ((void *)0);
  int f;
  f = hash (key, h->size);
  if (h->buckets[f])
    {
      for (i = h->buckets[f]; i; i = i->next)
        {
          if (!strcmp (i->key, key))
            {
              if (p)
                p->next = i->next;
              else
                h->buckets[f] = i->next;
              d = i->value;
              free (i->key);
              free (i);
              h->cnt--;
              break;
            }
          p = i;
        }
    }
  return d;
}

canonical_original_code:
void *ht_delete(struct hash_tbl *h, char *key)
{
  struct hash_el *i; struct hash_el *p = ((void *)0);
  void *d = ((void *)0);
  int f;
  f = hash (key, h->size);
  if (h->buckets[f])
    {
      for (i = h->buckets[f]; i; i = i->next)
        {
          if (!strcmp (i->key, key))
            {
              if (p)
                p->next = i->next;
              else
                h->buckets[f] = i->next;
              d = i->value;
              free (i->key);
              free (i);
              h->cnt--;
              break;
            }
          p = i;
        }
    }
  return d;
}

variable_types:
d
void *

user_defined_types: struct hash_el { char *key; void *value; struct hash_el *next; }


decompiled_code:
void __fastcall ht_free(void *ptr, void (__fastcall *a2)(void *, void *))
{
int v3; // eax
_QWORD *v4; // rdi
__int64 v5; // r14
void **v6; // rbp

v3 = *((_DWORD *)ptr + 2);
v4 = *(_QWORD **)ptr;
if ( v3 > 0 )
{
v5 = 0LL;
do
{
while ( 1 )
{
v6 = (void **)v4[v5];
if ( v6 )
break;
if ( *((_DWORD *)ptr + 2) <= (int)++v5 )
goto LABEL_9;
}
do
{
v4[v5] = v6[2];
if ( a2 )
a2(*v6, v6[1]);
free(*v6);
free(v6);
v4 = *(_QWORD **)ptr;
v6 = *(void ***)(*(_QWORD *)ptr + 8 * v5);
}
while ( v6 );
++v5;
}
while ( *((_DWORD *)ptr + 2) > (int)v5 );
}
LABEL_9:
free(v4);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func6(void *ptr, void (__fastcall *a2)(void *, void *))
{
int v3; // eax
_QWORD *v4; // rdi
__int64 v5; // r14
void **v6; // rbp

v3 = *((_DWORD *)ptr + 2);
v4 = *(_QWORD **)ptr;
if ( v3 > 0 )
{
v5 = 0LL;
do
{
while ( 1 )
{
v6 = (void **)v4[v5];
if ( v6 )
break;
if ( *((_DWORD *)ptr + 2) <= (int)++v5 )
goto LABEL_9;
}
do
{
v4[v5] = v6[2];
if ( a2 )
a2(*v6, v6[1]);
free(*v6);
free(v6);
v4 = *(_QWORD **)ptr;
v6 = *(void ***)(*(_QWORD *)ptr + 8 * v5);
}
while ( v6 );
++v5;
}
while ( *((_DWORD *)ptr + 2) > (int)v5 );
}
LABEL_9:
free(v4);
free(ptr);
}

original_code:
void
ht_free (struct hash_tbl *h, clear_all_dtor dtor)
{
  struct hash_el *e;
  int i;
  for (i = 0; i < h->size; i++)
    if (h->buckets[i])
      {
        e = h->buckets[i];
        while (e)
          {
            h->buckets[i] = e->next;
            if (dtor)
              dtor (e->key, e->value);
            free (e->key);
            free (e);
            e = h->buckets[i];
          }
      }
  free (h->buckets);
  free (h);
}

canonical_original_code:
void ht_free(struct hash_tbl *h, void (*dtor)(char *key, void *val))
{
  struct hash_el *e;
  int i;
  for (i = 0; i < h->size; i++)
    if (h->buckets[i])
      {
        e = h->buckets[i];
        while (e)
          {
            h->buckets[i] = e->next;
            if (dtor)
              dtor (e->key, e->value);
            free (e->key);
            free (e);
            e = h->buckets[i];
          }
      }
  free (h->buckets);
  free (h);
}

variable_types:
dtor
void (*)(char *key, void *val)


decompiled_code:
__int64 __fastcall ht_foreach(__int64 a1, __int64 (__fastcall *a2)(_QWORD, _QWORD, __int64), __int64 a3)
{
__int64 result; // rax
__int64 v4; // r13
_QWORD *v6; // rbx

result = *(unsigned int *)(a1 + 8);
if ( (int)result > 0 )
{
v4 = 0LL;
while ( 1 )
{
result = *(_QWORD *)a1;
v6 = *(_QWORD **)(*(_QWORD *)a1 + 8 * v4);
if ( v6 )
break;
LABEL_4:
if ( *(_DWORD *)(a1 + 8) <= (int)++v4 )
return result;
}
while ( 1 )
{
result = a2(*v6, v6[1], a3);
if ( !(_DWORD)result )
break;
v6 = (_QWORD *)v6[2];
if ( !v6 )
goto LABEL_4;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 (__fastcall *a2)(_QWORD, _QWORD, __int64), __int64 a3)
{
__int64 result; // rax
__int64 v4; // r13
_QWORD *v6; // rbx

result = *(unsigned int *)(a1 + 8);
if ( (int)result > 0 )
{
v4 = 0LL;
while ( 1 )
{
result = *(_QWORD *)a1;
v6 = *(_QWORD **)(*(_QWORD *)a1 + 8 * v4);
if ( v6 )
break;
LABEL_4:
if ( *(_DWORD *)(a1 + 8) <= (int)++v4 )
return result;
}
while ( 1 )
{
result = a2(*v6, v6[1], a3);
if ( !(_DWORD)result )
break;
v6 = (_QWORD *)v6[2];
if ( !v6 )
goto LABEL_4;
}
}
return result;
}

original_code:
void
ht_foreach (struct hash_tbl *h,
            int (*f) (const char *key, void *value, void *data), void *data)
{
  struct hash_el *e;
  int i;
  for (i = 0; i < h->size; i++)
    if (h->buckets[i])
      {
        e = h->buckets[i];
        while (e)
          {
            if (!f (e->key, e->value, data))
              return;
            e = e->next;
          }
      }
}

canonical_original_code:
void ht_foreach(struct hash_tbl *h, int (*f)(char *key, void *value, void *data), void *data)
{
  struct hash_el *e;
  int i;
  for (i = 0; i < h->size; i++)
    if (h->buckets[i])
      {
        e = h->buckets[i];
        while (e)
          {
            if (!f (e->key, e->value, data))
              return;
            e = e->next;
          }
      }
}

variable_types: int (*)(char *key, void *value, void *data)

variable_types:
data
void *


hash

decompiled_code:
__int64 __fastcall hash(_BYTE *a1, int a2)
{
int v2; // eax
int v3; // edx
unsigned int v4; // esi

v2 = (char)*a1;
v3 = a2 - 1;
if ( !*a1 )
return 0LL;
v4 = 0;
do
{
++a1;
v4 = v2 + 65599 * v4;
v2 = (char)*a1;
}
while ( *a1 );
return v3 & v4;
}

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1, int a2)
{
int v2; // eax
int v3; // edx
unsigned int v4; // esi

v2 = (char)*a1;
v3 = a2 - 1;
if ( !*a1 )
return 0LL;
v4 = 0;
do
{
++a1;
v4 = v2 + 65599 * v4;
v2 = (char)*a1;
}
while ( *a1 );
return v3 & v4;
}

original_code:
static int
hash (const char *str, int size)
{
  int x = 0;
  ((void) (0));
  while (str[0])
    {
      x = (x * 65599) + str[0];
      str++;
    }
  return x & (size - 1);
}

canonical_original_code:
static int hash(char *str, int size)
{
  int x = 0;
  ((void) (0));
  while (str[0])
    {
      x = (x * 65599) + str[0];
      str++;
    }
  return x & (size - 1);
}

variable_types:
str
char *

variable_types: size int

variable_types: x int


original_code:
const char *
ht_next (struct hash_tbl *h, const char *key)
{
  int f;
  struct hash_el *i;
  if (key == ((void *)0))
    {
      for (f = 0; f < h->size && !h->buckets[f]; f++);
      if (f >= h->size)
        return ((void *)0);
      ((void) (0));
      return h->buckets[f]->key;
    }
  i = search (h, key, &f);
  if (!i)
    return ((void *)0);
  if (i->next)
    return i->next->key;
  else
    {
      f++;
      while (f < h->size && !h->buckets[f])
        f++;
      if (f >= h->size)
        return ((void *)0);
      ((void) (0));
      return h->buckets[f]->key;
    }
}

canonical_original_code:
char *ht_next(struct hash_tbl *h, char *key)
{
  int f;
  struct hash_el *i;
  if (key == ((void *)0))
    {
      for (f = 0; f < h->size && !h->buckets[f]; f++);
      if (f >= h->size)
        return ((void *)0);
      ((void) (0));
      return h->buckets[f]->key;
    }
  i = search (h, key, &f);
  if (!i)
    return ((void *)0);
  if (i->next)
    return i->next->key;
  else
    {
      f++;
      while (f < h->size && !h->buckets[f])
        f++;
      if (f >= h->size)
        return ((void *)0);
      ((void) (0));
      return h->buckets[f]->key;
    }
}


decompiled_code:
void gc_sweep()
{
_QWORD *v0; // rbx
int v1; // eax
_QWORD *v2; // rbp
__int64 v3; // rax
void (__fastcall *v4)(_QWORD *); // rax

v0 = gc_objs;
while ( v0 )
{
while ( 1 )
{
v1 = *(_DWORD *)v0;
v2 = v0;
v0 = (_QWORD *)v0[4];
if ( v1 )
break;
if ( v0 )
v0[5] = v2[5];
v3 = v2[5];
if ( v3 )
*(_QWORD *)(v3 + 32) = v0;
if ( gc_objs == v2 )
gc_objs = (void *)v2[4];
v4 = (void (__fastcall *)(_QWORD *))v2[2];
if ( v4 )
v4(v2 + 8);
free(v2);
if ( !v0 )
return;
}
*(_DWORD *)v2 = 0;
}
}

canonical_decompiled_code:
void func0()
{
_QWORD *v0; // rbx
int v1; // eax
_QWORD *v2; // rbp
__int64 v3; // rax
void (__fastcall *v4)(_QWORD *); // rax

v0 = gc_objs;
while ( v0 )
{
while ( 1 )
{
v1 = *(_DWORD *)v0;
v2 = v0;
v0 = (_QWORD *)v0[4];
if ( v1 )
break;
if ( v0 )
v0[5] = v2[5];
v3 = v2[5];
if ( v3 )
*(_QWORD *)(v3 + 32) = v0;
if ( gc_objs == v2 )
gc_objs = (void *)v2[4];
v4 = (void (__fastcall *)(_QWORD *))v2[2];
if ( v4 )
v4(v2 + 8);
free(v2);
if ( !v0 )
return;
}
*(_DWORD *)v2 = 0;
}
}

original_code:
static void gc_sweep() {
 GcObj *gc = gc_objs;
 int collected = 0;
 while(gc) {
  if(gc->mark == 0) {
   GcObj *col = gc;
   gc = gc->next;
   if(col->next) col->next->prev = col->prev;
   if(col->prev) col->prev->next = col->next;
   if(gc_objs == col)
    gc_objs = col->next;
   if(col->dtor) {
    void *data = (char*)col + sizeof *col;
    col->dtor(data);
   }
   free(col);
   collected++;
  } else {
   gc->mark = 0;
   gc = gc->next;
  }
 }
}

canonical_original_code:
static void gc_sweep() {
 struct gc_object *gc = gc_objs;
 int collected = 0;
 while(gc) {
  if(gc->mark == 0) {
   struct gc_object *col = gc;
   gc = gc->next;
   if(col->next) col->next->prev = col->prev;
   if(col->prev) col->prev->next = col->next;
   if(gc_objs == col)
    gc_objs = col->next;
   if(col->dtor) {
    void *data = (char*)col + sizeof *col;
    col->dtor(data);
   }
   free(col);
   collected++;
  } else {
   gc->mark = 0;
   gc = gc->next;
  }
 }
}

variable_types: struct gc_object { int mark; void (*marker)(void *); void (*dtor)(void *); int retcount; struct gc_object *next; struct gc_object *rnext; } *

variable_types: collected int


original_code:
void *gc_retain(void *p) {
 GcObj *r;
 ((void) (0));
 r = (GcObj *)((char *)p - sizeof *r);
 ((void) (0));
 if(r->retcount == 0) {
  r->rnext = gc_roots;
  gc_roots = r;
  if(r->rnext) r->rnext->rprev = r;
  r->rprev = ((void *)0);
 }
 r->retcount++;
 return p;
}

canonical_original_code:
void *gc_retain(void *p) {
 struct gc_object *r;
 ((void) (0));
 r = (struct gc_object *)((char *)p - sizeof *r);
 ((void) (0));
 if(r->retcount == 0) {
  r->rnext = gc_roots;
  gc_roots = r;
  if(r->rnext) r->rnext->rprev = r;
  r->rprev = ((void *)0);
 }
 r->retcount++;
 return p;
}

variable_types:
p
void *

user_defined_types: struct gc_object { int mark; void (*marker)(void *); void (*dtor)(void *); int retcount; struct gc_object *next; struct gc_object *rnext; }


original_code:
void gc_release(void *p) {
 GcObj *r;
 ((void) (0));
 r = (GcObj *)((char *)p - sizeof *r);
 ((void) (0));
 r->retcount--;
 if(r->retcount == 0) {
  if(r->rnext) r->rnext->rprev = r->rprev;
  if(r->rprev) r->rprev->rnext = r->rnext;
  if(gc_roots == r)
   gc_roots = r->rnext;
  r->rnext = ((void *)0);
  r->rprev = ((void *)0);
 }
}

canonical_original_code:
void gc_release(void *p) {
 struct gc_object *r;
 ((void) (0));
 r = (struct gc_object *)((char *)p - sizeof *r);
 ((void) (0));
 r->retcount--;
 if(r->retcount == 0) {
  if(r->rnext) r->rnext->rprev = r->rprev;
  if(r->rprev) r->rprev->rnext = r->rnext;
  if(gc_roots == r)
   gc_roots = r->rnext;
  r->rnext = ((void *)0);
  r->rprev = ((void *)0);
 }
}


decompiled_code:
void gc_collect()
{
gc_mark_all();
gc_sweep();
}

canonical_decompiled_code:
void func3()
{
gc_mark_all();
func0();
}


decompiled_code:
void __fastcall gc_set_dtor(__int64 a1, __int64 a2)
{
*(_QWORD *)(a1 - 48) = a2;
}

original_code:
void gc_set_dtor(void *p, gc_function dtor) {
 GcObj *r;
 ((void) (0));
 r = (GcObj *)((char *)p - sizeof *r);
 r->dtor = dtor;
}

canonical_original_code:
void gc_set_dtor(void *p, void (*dtor)(void *)) {
 struct gc_object *r;
 ((void) (0));
 r = (struct gc_object *)((char *)p - sizeof *r);
 r->dtor = dtor;
}

variable_types:
dtor
void (*)(void *)


decompiled_code:
void __fastcall gc_set_marker(__int64 a1, __int64 a2)
{
*(_QWORD *)(a1 - 56) = a2;
}

original_code:
void gc_set_marker(void *p, gc_function marker) {
 GcObj *r;
 ((void) (0));
 r = (GcObj *)((char *)p - sizeof *r);
 r->marker = marker;
}

canonical_original_code:
void gc_set_marker(void *p, void (*marker)(void *)) {
 struct gc_object *r;
 ((void) (0));
 r = (struct gc_object *)((char *)p - sizeof *r);
 r->marker = marker;
}

variable_types:
marker
void (*)(void *)


decompiled_code:
int gc_dump()
{
__int64 v0; // rbx
int result; // eax
unsigned int *v2; // rbx

v0 = gc_roots;
if ( gc_roots )
{
puts("Roots:");
do
{
result = printf(" - %p (%d)\n", (const void *)(v0 + 64), *(unsigned int *)(v0 + 24));
v0 = *(_QWORD *)(v0 + 48);
}
while ( v0 );
}
v2 = (unsigned int *)gc_objs;
if ( gc_objs )
{
puts("Garbage:");
do
{
result = printf(" - %p (%d)\n", v2 + 16, *v2);
v2 = (unsigned int *)*((_QWORD *)v2 + 4);
}
while ( v2 );
}
return result;
}

canonical_decompiled_code:
int func6()
{
__int64 v0; // rbx
int result; // eax
unsigned int *v2; // rbx

v0 = gc_roots;
if ( gc_roots )
{
puts("Roots:");
do
{
result = printf(" - %p (%d)\n", (const void *)(v0 + 64), *(unsigned int *)(v0 + 24));
v0 = *(_QWORD *)(v0 + 48);
}
while ( v0 );
}
v2 = (unsigned int *)gc_objs;
if ( gc_objs )
{
puts("Garbage:");
do
{
result = printf(" - %p (%d)\n", v2 + 16, *v2);
v2 = (unsigned int *)*((_QWORD *)v2 + 4);
}
while ( v2 );
}
return result;
}

original_code:
void gc_dump() {
 GcObj *gc = gc_roots;
 if(gc) {
  printf("Roots:\n");
  while(gc) {
   void *data = (char*)gc + sizeof *gc;
   printf("    - %p (%d)\n", data, gc->retcount);
   gc = gc->rnext;
  }
 }
 gc = gc_objs;
 if(gc) {
  printf("Garbage:\n");
  while(gc) {
   void *data = (char*)gc + sizeof *gc;
   printf("    - %p (%d)\n", data, gc->mark);
   gc = gc->next;
  }
 }
}

canonical_original_code:
void gc_dump() {
 struct gc_object *gc = gc_roots;
 if(gc) {
  printf("Roots:\n");
  while(gc) {
   void *data = (char*)gc + sizeof *gc;
   printf("    - %p (%d)\n", data, gc->retcount);
   gc = gc->rnext;
  }
 }
 gc = gc_objs;
 if(gc) {
  printf("Garbage:\n");
  while(gc) {
   void *data = (char*)gc + sizeof *gc;
   printf("    - %p (%d)\n", data, gc->mark);
   gc = gc->next;
  }
 }
}


decompiled_code:
void gc_init()
{
;
}

canonical_decompiled_code:
void func7()
{
;
}

original_code:
void gc_init() {
}

canonical_original_code:
void gc_init() {
}


atom

original_code:
static int
atom (const char *text, const char *re, struct mstruct *m)
{
  const char *set;
  if (re[0] == '[')
    {
      int f = 0;
      if (re[1] == '!')
        re++;
      for (set = re + 1; set[0] != ']'; set++)
        {
          if (set[0] == '\0')
            return 0;
          if (set[0] == '\\')
            set++;
          else if (set[1] == '-')
            {
              if (set[2] == '\0')
                return 0;
     else if(set[2] == ']')
      goto check1;
              if (m->flags & 1)
                {
                  if (tolower (text[0]) >= tolower (set[0]) &&
                      tolower (text[0]) <= tolower (set[2]))
                    f = 1;
                }
              else if (text[0] >= set[0] && text[0] <= set[2])
                f = 1;
              set += 2;
              continue;
            }
check1:
          if (m->flags & 1)
            {
              if (tolower (set[0]) == tolower (text[0]))
                f = 1;
            }
          else if (set[0] == text[0])
            f = 1;
        }
      return (re[0] == '!') ? (!f) : (f);
    }
  else if (re[0] == '\\')
    {
      switch (re[1])
        {
        case 'a':
          return ((*__ctype_b_loc ())[(int) ((text[0]))] & (unsigned short int) _ISalpha);
        case 'w':
          return ((*__ctype_b_loc ())[(int) ((text[0]))] & (unsigned short int) _ISalnum);
        case 'd':
          return ((*__ctype_b_loc ())[(int) ((text[0]))] & (unsigned short int) _ISdigit);
        case 'u':
          return ((*__ctype_b_loc ())[(int) ((text[0]))] & (unsigned short int) _ISupper);
        case 'l':
          return ((*__ctype_b_loc ())[(int) ((text[0]))] & (unsigned short int) _ISlower);
        case 'x':
          return ((*__ctype_b_loc ())[(int) ((text[0]))] & (unsigned short int) _ISxdigit);
        case 's':
          return ((*__ctype_b_loc ())[(int) ((text[0]))] & (unsigned short int) _ISspace);
        case 'A':
          return !((*__ctype_b_loc ())[(int) ((text[0]))] & (unsigned short int) _ISalpha);
        case 'W':
          return !((*__ctype_b_loc ())[(int) ((text[0]))] & (unsigned short int) _ISalnum);
        case 'D':
          return !((*__ctype_b_loc ())[(int) ((text[0]))] & (unsigned short int) _ISdigit);
        case 'U':
          return !((*__ctype_b_loc ())[(int) ((text[0]))] & (unsigned short int) _ISupper);
        case 'L':
          return !((*__ctype_b_loc ())[(int) ((text[0]))] & (unsigned short int) _ISlower);
        case 'X':
          return !((*__ctype_b_loc ())[(int) ((text[0]))] & (unsigned short int) _ISxdigit);
        case 'S':
          return !((*__ctype_b_loc ())[(int) ((text[0]))] & (unsigned short int) _ISspace);
        default:
          re++;
          break;
        }
    }
  if (m->flags & 1)
    return tolower (re[0]) == tolower (text[0]) || re[0] == '.';
  return re[0] == text[0] || re[0] == '.';
}

canonical_original_code:
static int atom(char *text, char *re, struct mstruct *m)
{
  char *set;
  if (re[0] == '[')
    {
      int f = 0;
      if (re[1] == '!')
        re++;
      for (set = re + 1; set[0] != ']'; set++)
        {
          if (set[0] == '\0')
            return 0;
          if (set[0] == '\\')
            set++;
          else if (set[1] == '-')
            {
              if (set[2] == '\0')
                return 0;
     else if(set[2] == ']')
      goto check1;
              if (m->flags & 1)
                {
                  if (tolower (text[0]) >= tolower (set[0]) &&
                      tolower (text[0]) <= tolower (set[2]))
                    f = 1;
                }
              else if (text[0] >= set[0] && text[0] <= set[2])
                f = 1;
              set += 2;
              continue;
            }
check1:
          if (m->flags & 1)
            {
              if (tolower (set[0]) == tolower (text[0]))
                f = 1;
            }
          else if (set[0] == text[0])
            f = 1;
        }
      return (re[0] == '!') ? (!f) : (f);
    }
  else if (re[0] == '\\')
    {
      switch (re[1])
        {
        case 'a':
          return ((*__ctype_b_loc ())[(int) ((text[0]))] & (unsigned short) _ISalpha);
        case 'w':
          return ((*__ctype_b_loc ())[(int) ((text[0]))] & (unsigned short) _ISalnum);
        case 'd':
          return ((*__ctype_b_loc ())[(int) ((text[0]))] & (unsigned short) _ISdigit);
        case 'u':
          return ((*__ctype_b_loc ())[(int) ((text[0]))] & (unsigned short) _ISupper);
        case 'l':
          return ((*__ctype_b_loc ())[(int) ((text[0]))] & (unsigned short) _ISlower);
        case 'x':
          return ((*__ctype_b_loc ())[(int) ((text[0]))] & (unsigned short) _ISxdigit);
        case 's':
          return ((*__ctype_b_loc ())[(int) ((text[0]))] & (unsigned short) _ISspace);
        case 'A':
          return !((*__ctype_b_loc ())[(int) ((text[0]))] & (unsigned short) _ISalpha);
        case 'W':
          return !((*__ctype_b_loc ())[(int) ((text[0]))] & (unsigned short) _ISalnum);
        case 'D':
          return !((*__ctype_b_loc ())[(int) ((text[0]))] & (unsigned short) _ISdigit);
        case 'U':
          return !((*__ctype_b_loc ())[(int) ((text[0]))] & (unsigned short) _ISupper);
        case 'L':
          return !((*__ctype_b_loc ())[(int) ((text[0]))] & (unsigned short) _ISlower);
        case 'X':
          return !((*__ctype_b_loc ())[(int) ((text[0]))] & (unsigned short) _ISxdigit);
        case 'S':
          return !((*__ctype_b_loc ())[(int) ((text[0]))] & (unsigned short) _ISspace);
        default:
          re++;
          break;
        }
    }
  if (m->flags & 1)
    return tolower (re[0]) == tolower (text[0]) || re[0] == '.';
  return re[0] == text[0] || re[0] == '.';
}

variable_types:
text
char *

variable_types:
re
char *

variable_types: struct mstruct { char flags; char *start; char *end; } *

variable_types:
set
char *


star

decompiled_code:
__int64 __fastcall star(unsigned __int64 a1, char *a2, __int64 a3, _BYTE *a4)
{
char *v6; // rbp
char *i; // rbx

v6 = (char *)a1;
if ( (*a4 & 2) != 0 )
{
for ( i = (char *)a1; *i; ++i )
{
if ( !(unsigned int)atom(i, a2, a4) )
break;
}
while ( !(unsigned int)expr(i, a3, a4) )
{
if ( a1 >= (unsigned __int64)i-- )
return 0LL;
}
}
else
{
while ( !(unsigned int)expr(v6, a3, a4) )
{
if ( !*v6 || !(unsigned int)atom(v6, a2, a4) )
return 0LL;
++v6;
}
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned __int64 a1, char *a2, __int64 a3, _BYTE *a4)
{
char *v6; // rbp
char *i; // rbx

v6 = (char *)a1;
if ( (*a4 & 2) != 0 )
{
for ( i = (char *)a1; *i; ++i )
{
if ( !(unsigned int)func0(i, a2, a4) )
break;
}
while ( !(unsigned int)func2(i, a3, a4) )
{
if ( a1 >= (unsigned __int64)i-- )
return 0LL;
}
}
else
{
while ( !(unsigned int)func2(v6, a3, a4) )
{
if ( !*v6 || !(unsigned int)func0(v6, a2, a4) )
return 0LL;
++v6;
}
}
return 1LL;
}

original_code:
static int
star (const char *text, const char *s, const char *re, struct mstruct *m)
{
  if (m->flags & 2)
    {
      const char *t;
      for (t = text; t[0] && atom (t, s, m); t++);
      do
        {
          if (expr (t, re, m))
            return 1;
        }
      while (t-- > text);
    }
  else
    {
      do
        {
          if (expr (text, re, m))
            return 1;
        }
      while (text[0] != '\0' && atom (text++, s, m));
    }
  return 0;
}

canonical_original_code:
static int star(char *text, char *s, char *re, struct mstruct *m)
{
  if (m->flags & 2)
    {
      char *t;
      for (t = text; t[0] && atom (t, s, m); t++);
      do
        {
          if (expr (t, re, m))
            return 1;
        }
      while (t-- > text);
    }
  else
    {
      do
        {
          if (expr (text, re, m))
            return 1;
        }
      while (text[0] != '\0' && atom (text++, s, m));
    }
  return 0;
}

variable_types:
s
char *

variable_types:
t
char *

user_defined_types: struct mstruct { char flags; char *start; char *end; }


plus

decompiled_code:
__int64 __fastcall plus(char *a1, char *a2, char *a3, _BYTE *a4)
{
char *v6; // rbp
char *v7; // rbx

v6 = a1;
if ( (*a4 & 2) == 0 )
{
while ( *v6 && (unsigned int)atom(v6, a2, a4) )
{
if ( (unsigned int)expr(v6 + 1, a3, (__int64)a4) )
return 1LL;
++v6;
}
return 0LL;
}
v7 = a1;
if ( !*a1 )
return 0LL;
do
{
if ( !(unsigned int)atom(v7, a2, a4) )
break;
++v7;
}
while ( *v7 );
if ( v7 <= a1 )
return 0LL;
while ( !(unsigned int)expr(v7, a3, (__int64)a4) )
{
if ( a1 == --v7 )
return 0LL;
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *a1, char *a2, char *a3, _BYTE *a4)
{
char *v6; // rbp
char *v7; // rbx

v6 = a1;
if ( (*a4 & 2) == 0 )
{
while ( *v6 && (unsigned int)func0(v6, a2, a4) )
{
if ( (unsigned int)func2(v6 + 1, a3, (__int64)a4) )
return 1LL;
++v6;
}
return 0LL;
}
v7 = a1;
if ( !*a1 )
return 0LL;
do
{
if ( !(unsigned int)func0(v7, a2, a4) )
break;
++v7;
}
while ( *v7 );
if ( v7 <= a1 )
return 0LL;
while ( !(unsigned int)func2(v7, a3, (__int64)a4) )
{
if ( a1 == --v7 )
return 0LL;
}
return 1LL;
}

original_code:
static int
plus (const char *text, const char *s, const char *re, struct mstruct *m)
{
  if (m->flags & 2)
    {
      const char *t;
      for (t = text; t[0] && atom (t, s, m); t++);
      while (t > text)
        {
          if (expr (t, re, m))
            return 1;
          t--;
        }
    }
  else
    {
      while (text[0] != '\0' && atom (text++, s, m))
        if (expr (text, re, m))
          return 1;
    }
  return 0;
}

canonical_original_code:
static int plus(char *text, char *s, char *re, struct mstruct *m)
{
  if (m->flags & 2)
    {
      char *t;
      for (t = text; t[0] && atom (t, s, m); t++);
      while (t > text)
        {
          if (expr (t, re, m))
            return 1;
          t--;
        }
    }
  else
    {
      while (text[0] != '\0' && atom (text++, s, m))
        if (expr (text, re, m))
          return 1;
    }
  return 0;
}


ques

decompiled_code:
__int64 __fastcall ques(char *a1, char *a2, char *a3, _BYTE *a4)
{
__int64 result; // rax

if ( (*a4 & 2) != 0 )
{
if ( *a1 && (unsigned int)atom(a1, a2, a4) && (unsigned int)expr(a1 + 1, a3, (__int64)a4) )
return 1LL;
result = (unsigned int)expr(a1, a3, (__int64)a4) != 0;
}
else
{
result = expr(a1, a3, (__int64)a4);
if ( (_DWORD)result )
return 1LL;
if ( *a1 )
{
result = atom(a1, a2, a4);
if ( (_DWORD)result )
result = (unsigned int)expr(a1 + 1, a3, (__int64)a4) != 0;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(char *a1, char *a2, char *a3, _BYTE *a4)
{
__int64 result; // rax

if ( (*a4 & 2) != 0 )
{
if ( *a1 && (unsigned int)func0(a1, a2, a4) && (unsigned int)func2(a1 + 1, a3, (__int64)a4) )
return 1LL;
result = (unsigned int)func2(a1, a3, (__int64)a4) != 0;
}
else
{
result = func2(a1, a3, (__int64)a4);
if ( (_DWORD)result )
return 1LL;
if ( *a1 )
{
result = func0(a1, a2, a4);
if ( (_DWORD)result )
result = (unsigned int)func2(a1 + 1, a3, (__int64)a4) != 0;
}
}
return result;
}

original_code:
static int
ques (const char *text, const char *s, const char *re, struct mstruct *m)
{
  if (m->flags & 2)
    {
      if (text[0] != '\0' && atom (text, s, m))
        if (expr (text + 1, re, m))
          return 1;
      if (expr (text, re, m))
        return 1;
    }
  else
    {
      if (expr (text, re, m))
        return 1;
      if (text[0] != '\0' && atom (text++, s, m))
        if (expr (text, re, m))
          return 1;
    }
  return 0;
}

canonical_original_code:
static int ques(char *text, char *s, char *re, struct mstruct *m)
{
  if (m->flags & 2)
    {
      if (text[0] != '\0' && atom (text, s, m))
        if (expr (text + 1, re, m))
          return 1;
      if (expr (text, re, m))
        return 1;
    }
  else
    {
      if (expr (text, re, m))
        return 1;
      if (text[0] != '\0' && atom (text++, s, m))
        if (expr (text, re, m))
          return 1;
    }
  return 0;
}


decompiled_code:
__int64 __fastcall re_match(char *a1, char *a2, __int64 a3)
{
char *v4; // rbp
__int64 result; // rax

v4 = a1;
if ( *a2 == 94 )
{
*(_QWORD *)(a3 + 8) = a1;
result = expr(a1, a2 + 1, a3);
}
else
{
while ( 1 )
{
*(_QWORD *)(a3 + 8) = v4;
result = expr(v4, a2, a3);
if ( (_DWORD)result )
break;
if ( !*v4++ )
return result;
}
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(char *a1, char *a2, __int64 a3)
{
char *v4; // rbp
__int64 result; // rax

v4 = a1;
if ( *a2 == 94 )
{
*(_QWORD *)(a3 + 8) = a1;
result = func2(a1, a2 + 1, a3);
}
else
{
while ( 1 )
{
*(_QWORD *)(a3 + 8) = v4;
result = func2(v4, a2, a3);
if ( (_DWORD)result )
break;
if ( !*v4++ )
return result;
}
result = 1LL;
}
return result;
}

original_code:
static int
re_match (const char *text, const char *re, struct mstruct *m)
{
  if (re[0] == '^')
    {
      m->start = text;
      return expr (text, re + 1, m);
    }
  else
    do
      {
        m->start = text;
        if (expr (text, re, m))
          return 1;
      }
    while ((text++)[0] != '\0');
  return 0;
}

canonical_original_code:
static int re_match(char *text, char *re, struct mstruct *m)
{
  if (re[0] == '^')
    {
      m->start = text;
      return expr (text, re + 1, m);
    }
  else
    do
      {
        m->start = text;
        if (expr (text, re, m))
          return 1;
      }
    while ((text++)[0] != '\0');
  return 0;
}


decompiled_code:
__int64 __fastcall rx_match(char *a1, char *a2)
{
char v3[40]; // [rsp+0h] [rbp-28h] BYREF

v3[0] = 0;
return re_match(a1, a2, (__int64)v3);
}

canonical_decompiled_code:
__int64 __fastcall func6(char *a1, char *a2)
{
char v3[40]; // [rsp+0h] [rbp-28h] BYREF

v3[0] = 0;
return func5(a1, a2, (__int64)v3);
}

original_code:
int
rx_match (const char *text, const char *re)
{
  struct mstruct m;
  m.flags = 0;
  return re_match (text, re, &m);
}

canonical_original_code:
int rx_match(char *text, char *re)
{
  struct mstruct m;
  m.flags = 0;
  return re_match (text, re, &m);
}

variable_types: struct mstruct { char flags; char *start; char *end; }


decompiled_code:
__int64 __fastcall rx_search(char *a1, char *a2, _QWORD *a3, _QWORD *a4)
{
__int64 result; // rax
char v7[8]; // [rsp+0h] [rbp-38h] BYREF
__int64 v8; // [rsp+8h] [rbp-30h]
__int64 v9; // [rsp+10h] [rbp-28h]

v7[0] = 2;
v8 = 0LL;
v9 = 0LL;
result = re_match(a1, a2, (__int64)v7);
if ( (_DWORD)result )
{
if ( a3 )
*a3 = v8;
result = 1LL;
if ( a4 )
*a4 = v9;
}
else
{
if ( a3 )
*a3 = 0LL;
if ( a4 )
*a4 = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(char *a1, char *a2, _QWORD *a3, _QWORD *a4)
{
__int64 result; // rax
char v7[8]; // [rsp+0h] [rbp-38h] BYREF
__int64 v8; // [rsp+8h] [rbp-30h]
__int64 v9; // [rsp+10h] [rbp-28h]

v7[0] = 2;
v8 = 0LL;
v9 = 0LL;
result = func5(a1, a2, (__int64)v7);
if ( (_DWORD)result )
{
if ( a3 )
*a3 = v8;
result = 1LL;
if ( a4 )
*a4 = v9;
}
else
{
if ( a3 )
*a3 = 0LL;
if ( a4 )
*a4 = 0LL;
}
return result;
}

original_code:
int
rx_search (const char *text, const char *re, const char **beg,
           const char **end)
{
  struct mstruct m;
  m.flags = 2;
  m.start = 0;
  m.end = 0;
  if (re_match (text, re, &m))
    {
      if (beg)
        *beg = m.start;
      if (end)
        *end = m.end;
      return 1;
    }
  if (beg)
    *beg = 0;
  if (end)
    *end = 0;
  return 0;
}

canonical_original_code:
int rx_search(char *text, char *re, char **beg, char **end)
{
  struct mstruct m;
  m.flags = 2;
  m.start = 0;
  m.end = 0;
  if (re_match (text, re, &m))
    {
      if (beg)
        *beg = m.start;
      if (end)
        *end = m.end;
      return 1;
    }
  if (beg)
    *beg = 0;
  if (end)
    *end = 0;
  return 0;
}

variable_types:
beg
char **

variable_types:
end
char **


original_code:
static char *
int_match_sub (const char *text, const char *re, const char *sub, char once)
{
  const char *beg, *end, *p = text, *r, *u;
  char *o, *q;
  size_t len;
  if (!rx_search (text, re, &beg, &end))
    {
      char *a;
      size_t len = strlen (text);
      a = malloc (len + 1);
      if (!a)
        return ((void *)0);
      memcpy (a, text, len + 1);
      return a;
    }
  ((void) (0));
  len = strlen (text);
  o = malloc (len + 1);
  if (!o)
    return ((void *)0);
  q = o;
  do
    {
      for (; p < beg && p[0]; p++, q++)
        {
          do{ if(q - o >= (int)len) { char *t; len += (len>2)?len >> 1:2; t = realloc(o, len + 1); if(!t) { free(o); return ((void *)0); } q = t + (q - o); o = t; } } while(0);
          q[0] = p[0];
        }
      for (r = sub; r[0]; r++, q++)
        {
          do{ if(q - o >= (int)len) { char *t; len += (len>2)?len >> 1:2; t = realloc(o, len + 1); if(!t) { free(o); return ((void *)0); } q = t + (q - o); o = t; } } while(0);
          if (r[0] == '/')
            {
              r++;
              q[0] = r[0];
            }
          else if (r[0] == '&')
            {
              for (u = beg; u < end; u++, q++)
                {
                  do{ if(q - o >= (int)len) { char *t; len += (len>2)?len >> 1:2; t = realloc(o, len + 1); if(!t) { free(o); return ((void *)0); } q = t + (q - o); o = t; } } while(0);
                  q[0] = u[0];
                }
              q--;
            }
          else
            q[0] = r[0];
        }
      p = end;
    }
  while (rx_search (end, re, &beg, &end) && !once);
  for (; p[0]; p++, q++)
    {
      do{ if(q - o >= (int)len) { char *t; len += (len>2)?len >> 1:2; t = realloc(o, len + 1); if(!t) { free(o); return ((void *)0); } q = t + (q - o); o = t; } } while(0);
      q[0] = p[0];
    }
  q[0] = '\0';
  ((void) (0));
  return o;
}

canonical_original_code:
static char *int_match_sub(char *text, char *re, char *sub, char once)
{
  char *beg; char *end; char *p = text; char *r; char *u;
  char *o; char *q;
  unsigned long len;
  if (!rx_search (text, re, &beg, &end))
    {
      char *a;
      unsigned long len = strlen (text);
      a = malloc (len + 1);
      if (!a)
        return ((void *)0);
      memcpy (a, text, len + 1);
      return a;
    }
  ((void) (0));
  len = strlen (text);
  o = malloc (len + 1);
  if (!o)
    return ((void *)0);
  q = o;
  do
    {
      for (; p < beg && p[0]; p++, q++)
        {
          do{ if(q - o >= (int)len) { char *t; len += (len>2)?len >> 1:2; t = realloc(o, len + 1); if(!t) { free(o); return ((void *)0); } q = t + (q - o); o = t; } } while(0);
          q[0] = p[0];
        }
      for (r = sub; r[0]; r++, q++)
        {
          do{ if(q - o >= (int)len) { char *t; len += (len>2)?len >> 1:2; t = realloc(o, len + 1); if(!t) { free(o); return ((void *)0); } q = t + (q - o); o = t; } } while(0);
          if (r[0] == '/')
            {
              r++;
              q[0] = r[0];
            }
          else if (r[0] == '&')
            {
              for (u = beg; u < end; u++, q++)
                {
                  do{ if(q - o >= (int)len) { char *t; len += (len>2)?len >> 1:2; t = realloc(o, len + 1); if(!t) { free(o); return ((void *)0); } q = t + (q - o); o = t; } } while(0);
                  q[0] = u[0];
                }
              q--;
            }
          else
            q[0] = r[0];
        }
      p = end;
    }
  while (rx_search (end, re, &beg, &end) && !once);
  for (; p[0]; p++, q++)
    {
      do{ if(q - o >= (int)len) { char *t; len += (len>2)?len >> 1:2; t = realloc(o, len + 1); if(!t) { free(o); return ((void *)0); } q = t + (q - o); o = t; } } while(0);
      q[0] = p[0];
    }
  q[0] = '\0';
  ((void) (0));
  return o;
}

variable_types:
sub
char *

variable_types: once char

variable_types:
beg
char *

variable_types:
end
char *

variable_types:
p
char *

variable_types:
r
char *

variable_types:
u
char *

variable_types:
o
char *

variable_types:
q
char *

variable_types:
len
unsigned long

variable_types:
a
char *


decompiled_code:
char *__fastcall rx_sub(void *a1, char *a2, _BYTE *a3)
{
return int_match_sub(a1, a2, a3, 1);
}

canonical_decompiled_code:
char *__fastcall func9(void *a1, char *a2, _BYTE *a3)
{
return func8(a1, a2, a3, 1);
}

original_code:
char *
rx_sub (const char *text, const char *re, const char *sub)
{
  return int_match_sub (text, re, sub, 1);
}

canonical_original_code:
char *rx_sub(char *text, char *re, char *sub)
{
  return int_match_sub (text, re, sub, 1);
}

variable_types:
text
char *

variable_types:
re
char *


decompiled_code:
char *__fastcall rx_gsub(void *a1, char *a2, _BYTE *a3)
{
return int_match_sub(a1, a2, a3, 0);
}

canonical_decompiled_code:
char *__fastcall func10(void *a1, char *a2, _BYTE *a3)
{
return func8(a1, a2, a3, 0);
}

original_code:
char *
rx_gsub (const char *text, const char *re, const char *sub)
{
  return int_match_sub (text, re, sub, 0);
}

canonical_original_code:
char *rx_gsub(char *text, char *re, char *sub)
{
  return int_match_sub (text, re, sub, 0);
}


expr

original_code:
static int
expr (const char *text, const char *re, struct mstruct *m)
{
  int i = 0;
  if (re[0] == '\0')
    {
      m->end = text;
      return 1;
    }
  if (re[0] == '$' && re[1] == '\0')
    {
      m->end = text;
      return text[0] == '\0';
    }
  if (re[0] == '\\')
    {
      if (re[1] == 'i')
        {
          m->flags |= 1;
          return expr (text, re + 2, m);
        }
      else if (re[1] == 'I')
        {
          m->flags &= ~1;
          return expr (text, re + 2, m);
        }
      i++;
    }
  else if (re[0] == '[' && ++i)
    while (re[i] != ']')
      {
        if (re[i] == '\0')
          return 0;
        if (re[i] == '\\')
          i++;
        i++;
      }
  if (re[i + 1] == '*')
    return star (text, re, re + i + 2, m);
  if (re[i + 1] == '+')
    return plus (text, re, re + i + 2, m);
  if (re[i + 1] == '?')
    return ques (text, re, re + i + 2, m);
  if (text[0] && atom (text, re, m))
    return expr (text + 1, re + i + 1, m);
  return 0;
}

canonical_original_code:
static int expr(char *text, char *re, struct mstruct *m)
{
  int i = 0;
  if (re[0] == '\0')
    {
      m->end = text;
      return 1;
    }
  if (re[0] == '$' && re[1] == '\0')
    {
      m->end = text;
      return text[0] == '\0';
    }
  if (re[0] == '\\')
    {
      if (re[1] == 'i')
        {
          m->flags |= 1;
          return expr (text, re + 2, m);
        }
      else if (re[1] == 'I')
        {
          m->flags &= ~1;
          return expr (text, re + 2, m);
        }
      i++;
    }
  else if (re[0] == '[' && ++i)
    while (re[i] != ']')
      {
        if (re[i] == '\0')
          return 0;
        if (re[i] == '\\')
          i++;
        i++;
      }
  if (re[i + 1] == '*')
    return star (text, re, re + i + 2, m);
  if (re[i + 1] == '+')
    return plus (text, re, re + i + 2, m);
  if (re[i + 1] == '?')
    return ques (text, re, re + i + 2, m);
  if (text[0] && atom (text, re, m))
    return expr (text + 1, re + i + 1, m);
  return 0;
}

variable_types: struct mstruct { char flags; char *start; char *end; } *

variable_types: i int


printfun

decompiled_code:
__int64 __fastcall printfun(const char *a1, const char *a2)
{
printf("%s -> %s\n", a1, a2);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1, const char *a2)
{
printf("%s -> %s\n", a1, a2);
return 1LL;
}

original_code:
static int printfun (const char *key, void *value, void *data) {
  printf ("%s -> %s\n", key, (char *) value);
  return 1;
}

canonical_original_code:
static int printfun(char *key, void *value, void *data) {
  printf ("%s -> %s\n", key, (char *) value);
  return 1;
}

variable_types:
key
char *

variable_types:
value
void *

variable_types:
data
void *


iterate

decompiled_code:
__int64 __fastcall iterate(__int64 a1)
{
const char *i; // rbp
const char *v2; // rax
__int64 result; // rax

for ( i = 0LL; ; printf("%s %s\n", i, v2) )
{
result = ht_next(a1, i);
i = (const char *)result;
if ( !result )
break;
v2 = (const char *)ht_find(a1, result);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
const char *i; // rbp
const char *v2; // rax
__int64 result; // rax

for ( i = 0LL; ; printf("%s %s\n", i, v2) )
{
result = ht_next(a1, i);
i = (const char *)result;
if ( !result )
break;
v2 = (const char *)ht_find(a1, result);
}
return result;
}

original_code:
static void iterate (struct hash_tbl *h) {
  const char *key = ((void *)0);
  while ((key = ht_next (h, key)) != ((void *)0))
    printf ("%s %s\n", key, (char *) ht_find (h, key));
}

canonical_original_code:
static void iterate(struct hash_tbl *h) {
  char *key = ((void *)0);
  while ((key = ht_next (h, key)) != ((void *)0))
    printf ("%s %s\n", key, (char *) ht_find (h, key));
}

variable_types: struct hash_tbl { struct hash_el { char *key; void *value; struct hash_el *next; } **buckets; int size; int cnt; } *


dtor

decompiled_code:
void __fastcall dtor(__int64 a1, void *a2)
{
free(a2);
}

canonical_decompiled_code:
void __fastcall func2(__int64 a1, void *a2)
{
free(a2);
}

original_code:
static void dtor(const char *key, void *val) {
  free(val);
}

canonical_original_code:
static void dtor(char *key, void *val) {
  free(val);
}

variable_types:
val
void *


show

original_code:
void
show (struct hash_tbl *h)
{
  struct hash_el *e;
  int i;
  for (i = 0; i < h->size; i++)
    if (h->buckets[i])
      for (e = h->buckets[i]; e; e = e->next)
        printf ("%s %s\n", e->key, (char *) e->value);
}

canonical_original_code:
void show(struct hash_tbl *h)
{
  struct hash_el *e;
  int i;
  for (i = 0; i < h->size; i++)
    if (h->buckets[i])
      for (e = h->buckets[i]; e; e = e->next)
        printf ("%s %s\n", e->key, (char *) e->value);
}

variable_types: struct hash_el { char *key; void *value; struct hash_el *next; } *


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 *v3; // rbp
size_t v5; // rbx
_DWORD *v6; // rax
_DWORD *v7; // rdx
__int64 v8; // rax
unsigned int v9; // ebx
unsigned int v10; // ebx
unsigned int v11; // eax
__int64 v12; // rcx
const char *v13; // rdx
__int64 v14; // rax
const char *v15; // r14
const char *v16; // rax
void *v17; // rdi
int *v18; // rax
char *v19; // rax
__int64 v20; // [rsp+0h] [rbp-88h] BYREF
char v21[32]; // [rsp+20h] [rbp-68h] BYREF
char s[8]; // [rsp+40h] [rbp-48h] BYREF

v3 = (__int64 *)ht_create(8LL, argv, envp);
if ( v3 )
{
while ( 1 )
{
do
{
putchar(62);
fflush(stdout);
}
while ( (unsigned int)_isoc99_scanf("%s", &v20) != 1 );
if ( (_DWORD)v20 == 6581861 || (_DWORD)v20 == 1953068401 && !BYTE4(v20) )
{
LABEL_16:
ht_free(v3, dtor);
return 0;
}
if ( (_DWORD)v20 == 1953069157 )
break;
if ( (_DWORD)v20 == 6579297 )
{
if ( (unsigned int)_isoc99_scanf("%s %s", v21, s) == 2 )
{
v5 = strlen(s) + 1;
v6 = malloc(v5);
v7 = v6;
if ( v6 )
{
if ( (unsigned int)v5 < 8 )
{
if ( (v5 & 4) != 0 )
{
*v6 = *(_DWORD *)s;
*(_DWORD *)((char *)v6 + (unsigned int)v5 - 4) = *(_DWORD *)&v21[(unsigned int)v5 + 28];
}
else if ( (_DWORD)v5 )
{
*(_BYTE *)v6 = s[0];
if ( (v5 & 2) != 0 )
*(_WORD *)((char *)v6 + (unsigned int)v5 - 2) = *(_WORD *)&v21[(unsigned int)v5 + 30];
}
}
else
{
v8 = (unsigned int)v5;
v9 = v5 - 1;
*(_QWORD *)((char *)v7 + v8 - 8) = *(_QWORD *)&v21[v8 + 24];
if ( v9 >= 8 )
{
v10 = v9 & 0xFFFFFFF8;
v11 = 0;
do
{
v12 = v11;
v11 += 8;
*(_QWORD *)((char *)v7 + v12) = *(_QWORD *)&s[v12];
}
while ( v11 < v10 );
}
}
ht_insert(v3, v21);
}
else
{
v18 = _errno_location();
v19 = strerror(*v18);
fprintf(stderr, "error: %s\n", v19);
}
LABEL_14:
fflush(stdout);
}
}
else
{
LABEL_7:
if ( (_DWORD)v20 != 1684957542 || BYTE4(v20) )
{
if ( (_DWORD)v20 != 1954047342 || BYTE4(v20) )
{
if ( (_DWORD)v20 != 1701602660 || WORD2(v20) != 25972 || BYTE6(v20) )
{
if ( v20 == 0x68636165726F66LL )
{
ht_foreach(v3, printfun, 0LL);
}
else if ( (_DWORD)v20 != 2003789939 || BYTE4(v20) )
{
if ( v20 == 0x65746172657469LL )
iterate((__int64)v3);
else
fwrite("error: unknown command\n", 1uLL, 0x17uLL, stderr);
}
else
{
show(v3);
}
goto LABEL_14;
}
if ( !(unsigned int)_isoc99_scanf("%s", v21) )
{
v17 = (void *)ht_delete(v3, v21);
if ( v17 )
{
free(v17);
printf("%s deleted\n", v21);
goto LABEL_14;
}
goto LABEL_44;
}
}
else if ( (unsigned int)_isoc99_scanf("%s", v21) == 1 )
{
v14 = ht_next(v3, v21);
v15 = (const char *)v14;
if ( v14 )
{
v16 = (const char *)ht_find(v3, v14);
printf("%s => %s %s\n", v21, v15, v16);
}
else
{
printf("%s does not have a next element\n", v21);
}
goto LABEL_14;
}
}
else if ( (unsigned int)_isoc99_scanf("%s", v21) == 1 )
{
v13 = (const char *)ht_find(v3, v21);
if ( v13 )
{
printf("%s ~> %s\n", v21, v13);
goto LABEL_14;
}
LABEL_44:
printf("%s not found\n", v21);
goto LABEL_14;
}
}
}
if ( !BYTE4(v20) )
goto LABEL_16;
goto LABEL_7;
}
fwrite("error: ht_create() failed\n", 1uLL, 0x1AuLL, stderr);
return 1;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 *v3; // rbp
size_t v5; // rbx
_DWORD *v6; // rax
_DWORD *v7; // rdx
__int64 v8; // rax
unsigned int v9; // ebx
unsigned int v10; // ebx
unsigned int v11; // eax
__int64 v12; // rcx
const char *v13; // rdx
__int64 v14; // rax
const char *v15; // r14
const char *v16; // rax
void *v17; // rdi
int *v18; // rax
char *v19; // rax
__int64 v20; // [rsp+0h] [rbp-88h] BYREF
char v21[32]; // [rsp+20h] [rbp-68h] BYREF
char s[8]; // [rsp+40h] [rbp-48h] BYREF

v3 = (__int64 *)ht_create(8LL, argv, envp);
if ( v3 )
{
while ( 1 )
{
do
{
putchar(62);
fflush(stdout);
}
while ( (unsigned int)_isoc99_scanf("%s", &v20) != 1 );
if ( (_DWORD)v20 == 6581861 || (_DWORD)v20 == 1953068401 && !BYTE4(v20) )
{
LABEL_16:
ht_free(v3, dtor);
return 0;
}
if ( (_DWORD)v20 == 1953069157 )
break;
if ( (_DWORD)v20 == 6579297 )
{
if ( (unsigned int)_isoc99_scanf("%s %s", v21, s) == 2 )
{
v5 = strlen(s) + 1;
v6 = malloc(v5);
v7 = v6;
if ( v6 )
{
if ( (unsigned int)v5 < 8 )
{
if ( (v5 & 4) != 0 )
{
*v6 = *(_DWORD *)s;
*(_DWORD *)((char *)v6 + (unsigned int)v5 - 4) = *(_DWORD *)&v21[(unsigned int)v5 + 28];
}
else if ( (_DWORD)v5 )
{
*(_BYTE *)v6 = s[0];
if ( (v5 & 2) != 0 )
*(_WORD *)((char *)v6 + (unsigned int)v5 - 2) = *(_WORD *)&v21[(unsigned int)v5 + 30];
}
}
else
{
v8 = (unsigned int)v5;
v9 = v5 - 1;
*(_QWORD *)((char *)v7 + v8 - 8) = *(_QWORD *)&v21[v8 + 24];
if ( v9 >= 8 )
{
v10 = v9 & 0xFFFFFFF8;
v11 = 0;
do
{
v12 = v11;
v11 += 8;
*(_QWORD *)((char *)v7 + v12) = *(_QWORD *)&s[v12];
}
while ( v11 < v10 );
}
}
ht_insert(v3, v21);
}
else
{
v18 = _errno_location();
v19 = strerror(*v18);
fprintf(stderr, "error: %s\n", v19);
}
LABEL_14:
fflush(stdout);
}
}
else
{
LABEL_7:
if ( (_DWORD)v20 != 1684957542 || BYTE4(v20) )
{
if ( (_DWORD)v20 != 1954047342 || BYTE4(v20) )
{
if ( (_DWORD)v20 != 1701602660 || WORD2(v20) != 25972 || BYTE6(v20) )
{
if ( v20 == 0x68636165726F66LL )
{
ht_foreach(v3, printfun, 0LL);
}
else if ( (_DWORD)v20 != 2003789939 || BYTE4(v20) )
{
if ( v20 == 0x65746172657469LL )
func1((__int64)v3);
else
fwrite("error: unknown command\n", 1uLL, 0x17uLL, stderr);
}
else
{
func3(v3);
}
goto LABEL_14;
}
if ( !(unsigned int)_isoc99_scanf("%s", v21) )
{
v17 = (void *)ht_delete(v3, v21);
if ( v17 )
{
free(v17);
printf("%s deleted\n", v21);
goto LABEL_14;
}
goto LABEL_44;
}
}
else if ( (unsigned int)_isoc99_scanf("%s", v21) == 1 )
{
v14 = ht_next(v3, v21);
v15 = (const char *)v14;
if ( v14 )
{
v16 = (const char *)ht_find(v3, v14);
printf("%s => %s %s\n", v21, v15, v16);
}
else
{
printf("%s does not have a next element\n", v21);
}
goto LABEL_14;
}
}
else if ( (unsigned int)_isoc99_scanf("%s", v21) == 1 )
{
v13 = (const char *)ht_find(v3, v21);
if ( v13 )
{
printf("%s ~> %s\n", v21, v13);
goto LABEL_14;
}
LABEL_44:
printf("%s not found\n", v21);
goto LABEL_14;
}
}
}
if ( !BYTE4(v20) )
goto LABEL_16;
goto LABEL_7;
}
fwrite("error: ht_create() failed\n", 1uLL, 0x1AuLL, stderr);
return 1;
}

original_code:
int main (int argc, char *argv[]) {
  struct hash_tbl *h;
  char cmd[20], key[20], data[20], *res;
  h = ht_create (8);
  if (!h) {
    fprintf(stderr, "error: ht_create() failed\n");
    return 1;
  }
  while (1) {
      printf (">");
      fflush (stdout);
      if(scanf ("%s", cmd) != 1) continue;
      if (!strcmp (cmd, "end") || !strcmp (cmd, "quit") || !strcmp (cmd, "exit"))
        break;
      else if (!strcmp (cmd, "add"))
        {
          char *d;
          size_t len;
          if(scanf ("%s %s", key, data) != 2) continue;
          len = strlen (data);
          d = malloc (len + 1);
          if (d)
            {
              memcpy (d, data, len + 1);
              ht_insert (h, key, d);
            }
          else
            fprintf (stderr, "error: %s\n", strerror ((*__errno_location ())));
        }
      else if (!strcmp (cmd, "find"))
        {
          if(scanf ("%s", key) != 1) continue;
          res = ht_find (h, key);
          if (res)
            printf ("%s ~> %s\n", key, res);
          else
            printf ("%s not found\n", key);
        }
      else if (!strcmp (cmd, "next"))
        {
          const char *next;
          if(scanf ("%s", key) != 1) continue;
          next = ht_next (h, key);
          if (next)
            printf ("%s => %s %s\n", key, next, (char *) ht_find (h, next));
          else
            printf ("%s does not have a next element\n", key);
        }
      else if (!strcmp (cmd, "delete"))
        {
          if(scanf ("%s", key)) continue;
          res = ht_delete (h, key);
          if (res)
            {
              free (res);
              printf ("%s deleted\n", key);
            }
          else
            printf ("%s not found\n", key);
        }
      else if (!strcmp (cmd, "foreach"))
        {
          ht_foreach (h, printfun, ((void *)0));
        }
      else if (!strcmp (cmd, "show"))
        show (h);
      else if (!strcmp (cmd, "iterate"))
        iterate (h);
      else
        fprintf (stderr, "error: unknown command\n");
      fflush (stdout);
    }
  ht_free (h, dtor);
  return 0;
}

canonical_original_code:
int main(int argc, char *argv[]) {
  struct hash_tbl *h;
  char cmd[20]; char key[20]; char data[20]; char *res;
  h = ht_create (8);
  if (!h) {
    fprintf(stderr, "error: ht_create() failed\n");
    return 1;
  }
  while (1) {
      printf (">");
      fflush (stdout);
      if(scanf ("%s", cmd) != 1) continue;
      if (!strcmp (cmd, "end") || !strcmp (cmd, "quit") || !strcmp (cmd, "exit"))
        break;
      else if (!strcmp (cmd, "add"))
        {
          char *d;
          unsigned long len;
          if(scanf ("%s %s", key, data) != 2) continue;
          len = strlen (data);
          d = malloc (len + 1);
          if (d)
            {
              memcpy (d, data, len + 1);
              ht_insert (h, key, d);
            }
          else
            fprintf (stderr, "error: %s\n", strerror ((*__errno_location ())));
        }
      else if (!strcmp (cmd, "find"))
        {
          if(scanf ("%s", key) != 1) continue;
          res = ht_find (h, key);
          if (res)
            printf ("%s ~> %s\n", key, res);
          else
            printf ("%s not found\n", key);
        }
      else if (!strcmp (cmd, "next"))
        {
          char *next;
          if(scanf ("%s", key) != 1) continue;
          next = ht_next (h, key);
          if (next)
            printf ("%s => %s %s\n", key, next, (char *) ht_find (h, next));
          else
            printf ("%s does not have a next element\n", key);
        }
      else if (!strcmp (cmd, "delete"))
        {
          if(scanf ("%s", key)) continue;
          res = ht_delete (h, key);
          if (res)
            {
              free (res);
              printf ("%s deleted\n", key);
            }
          else
            printf ("%s not found\n", key);
        }
      else if (!strcmp (cmd, "foreach"))
        {
          ht_foreach (h, printfun, ((void *)0));
        }
      else if (!strcmp (cmd, "show"))
        show (h);
      else if (!strcmp (cmd, "iterate"))
        iterate (h);
      else
        fprintf (stderr, "error: unknown command\n");
      fflush (stdout);
    }
  ht_free (h, dtor);
  return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types:
cmd
char [20]

variable_types:
key
char [20]

variable_types:
data
char [20]

variable_types:
res
char *

variable_types:
d
char *

variable_types:
next
char *


decompiled_code:
void rc_init()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
void rc_init() {
}

canonical_original_code:
void rc_init() {
}


decompiled_code:
char *__fastcall rc_alloc(__int64 a1)
{
_QWORD *v1; // rax
char *v2; // r8

v1 = malloc(a1 + 16);
if ( !v1 )
return 0LL;
*(_DWORD *)v1 = 1;
v2 = (char *)(v1 + 2);
v1[1] = 0LL;
return v2;
}

canonical_decompiled_code:
char *__fastcall func1(__int64 a1)
{
_QWORD *v1; // rax
char *v2; // r8

v1 = malloc(a1 + 16);
if ( !v1 )
return 0LL;
*(_DWORD *)v1 = 1;
v2 = (char *)(v1 + 2);
v1[1] = 0LL;
return v2;
}

original_code:
void *rc_alloc(size_t size) {
    void *data;
    RefObj *r = malloc((sizeof *r) + size);
    if(!r)
        return ((void *)0);
    data = (char*)r + sizeof *r;
    r->refcnt = 1;
    r->dtor = ((void *)0);
    return data;
}

canonical_original_code:
void *rc_alloc(unsigned long size) {
    void *data;
    struct refobj *r = malloc((sizeof *r) + size);
    if(!r)
        return ((void *)0);
    data = (char *)r + sizeof *r;
    r->refcnt = 1;
    r->dtor = ((void *)0);
    return data;
}

variable_types:
size
unsigned long

variable_types: struct refobj { unsigned int refcnt; void (*dtor)(void *); } *


decompiled_code:
char *__fastcall rc_realloc(__int64 a1, __int64 a2)
{
char *result; // rax

if ( a1 )
result = (char *)realloc((void *)(a1 - 16), a2 + 16) + 16;
else
result = 0LL;
return result;
}

canonical_decompiled_code:
char *__fastcall func2(__int64 a1, __int64 a2)
{
char *result; // rax

if ( a1 )
result = (char *)realloc((void *)(a1 - 16), a2 + 16) + 16;
else
result = 0LL;
return result;
}

original_code:
void *rc_realloc(void *p, size_t size) {
    RefObj *r;
    if(!p)
        return ((void *)0);
    r = (RefObj *)((char *)p - sizeof *r);
    ((void) (0));
    r = realloc(r, (sizeof *r) + size);
    return (char*)r + sizeof *r;
}

canonical_original_code:
void *rc_realloc(void *p, unsigned long size) {
    struct refobj *r;
    if(!p)
        return ((void *)0);
    r = (struct refobj *)((char *)p - sizeof *r);
    ((void) (0));
    r = realloc(r, (sizeof *r) + size);
    return (char *)r + sizeof *r;
}

variable_types:
p
void *

user_defined_types: struct refobj { unsigned int refcnt; void (*dtor)(void *); }


decompiled_code:
void *__fastcall rc_strdup(void *src)
{
size_t v1; // r12
char *v2; // rax
void *v3; // r8

v1 = strlen((const char *)src) + 1;
v2 = rc_alloc(v1);
v3 = v2;
if ( v2 )
v3 = memcpy(v2, src, v1);
return v3;
}

canonical_decompiled_code:
void *__fastcall func3(void *src)
{
size_t v1; // r12
char *v2; // rax
void *v3; // r8

v1 = strlen((const char *)src) + 1;
v2 = func1(v1);
v3 = v2;
if ( v2 )
v3 = memcpy(v2, src, v1);
return v3;
}

original_code:
char *rc_strdup(const char *s) {
    size_t len = strlen(s);
    char *n = rc_alloc(len + 1);
    if(!n)
        return ((void *)0);
    memcpy(n, s, len + 1);
    return n;
}

canonical_original_code:
char *rc_strdup(char *s) {
    unsigned long len = strlen(s);
    char *n = rc_alloc(len + 1);
    if(!n)
        return ((void *)0);
    memcpy(n, s, len + 1);
    return n;
}

variable_types:
s
char *

variable_types:
len
unsigned long

variable_types:
n
char *


decompiled_code:
void *__fastcall rc_memdup(void *src, size_t n)
{
char *v2; // rax
void *v3; // r8

v2 = rc_alloc(n);
v3 = v2;
if ( v2 )
v3 = memcpy(v2, src, n);
return v3;
}

canonical_decompiled_code:
void *__fastcall func4(void *src, size_t n)
{
char *v2; // rax
void *v3; // r8

v2 = func1(n);
v3 = v2;
if ( v2 )
v3 = memcpy(v2, src, n);
return v3;
}

original_code:
void *rc_memdup(const void *p, size_t size) {
    char *n = rc_alloc(size);
    if(!n)
        return ((void *)0);
    memcpy(n, p, size);
    return n;
}

canonical_original_code:
void *rc_memdup(void *p, unsigned long size) {
    char *n = rc_alloc(size);
    if(!n)
        return ((void *)0);
    memcpy(n, p, size);
    return n;
}


decompiled_code:
__int64 __fastcall rc_retain(__int64 a1)
{
__int64 result; // rax

result = a1;
if ( a1 )
++*(_DWORD *)(a1 - 16);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
__int64 result; // rax

result = a1;
if ( a1 )
++*(_DWORD *)(a1 - 16);
return result;
}

original_code:
void *rc_retain(void *p) {
    RefObj *r;
    if(!p)
        return ((void *)0);
    r = (RefObj *)((char *)p - sizeof *r);
    r->refcnt++;
    return p;
}

canonical_original_code:
void *rc_retain(void *p) {
    struct refobj *r;
    if(!p)
        return ((void *)0);
    r = (struct refobj *)((char *)p - sizeof *r);
    r->refcnt++;
    return p;
}


original_code:
void rc_release(void *p) {
    RefObj *r;
    if(!p)
        return;
    r = (RefObj *)((char *)p - sizeof *r);
    r->refcnt--;
    if(r->refcnt == 0) {
        if(r->dtor != ((void *)0)) {
            r->dtor(p);
        }
        free(r);
    }
}

canonical_original_code:
void rc_release(void *p) {
    struct refobj *r;
    if(!p)
        return;
    r = (struct refobj *)((char *)p - sizeof *r);
    r->refcnt--;
    if(r->refcnt == 0) {
        if(r->dtor != ((void *)0)) {
            r->dtor(p);
        }
        free(r);
    }
}


decompiled_code:
void __fastcall rc_set_dtor(__int64 a1, __int64 a2)
{
if ( a1 )
*(_QWORD *)(a1 - 8) = a2;
}

canonical_decompiled_code:
void __fastcall func7(__int64 a1, __int64 a2)
{
if ( a1 )
*(_QWORD *)(a1 - 8) = a2;
}

original_code:
void rc_set_dtor(void *p, ref_dtor dtor) {
    RefObj *r;
    if(!p) return;
    r = (RefObj *)((char *)p - sizeof *r);
    r->dtor = dtor;
}

canonical_original_code:
void rc_set_dtor(void *p, void (*dtor)(void *)) {
    struct refobj *r;
    if(!p) return;
    r = (struct refobj *)((char *)p - sizeof *r);
    r->dtor = dtor;
}

variable_types:
dtor
void (*)(void *)


decompiled_code:
__int64 __fastcall rc_assign(__int64 *a1, __int64 a2)
{
__int64 v3; // rdi

v3 = *a1;
if ( v3 )
rc_release(v3);
*a1 = a2;
return a2;
}

original_code:
void *rc_assign(void **p, void *val) {
    if(*p) {
        rc_release(*p);
    }
    *p = val;
    return val;
}

variable_types:
p
void **

variable_types:
val
void *


simil

decompiled_code:
__int64 __fastcall simil(const char *a1, const char *a2)
{
int v2; // ebp
int v3; // eax
__int64 result; // rax

v2 = strlen(a1);
v3 = strlen(a2);
if ( v2 && v3 )
result = (unsigned int)((int)(200 * rsimil((__int64)a1, v2, (__int64)a2, v3, 1)) / (v2 + v3));
else
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(const char *a1, const char *a2)
{
int v2; // ebp
int v3; // eax
__int64 result; // rax

v2 = strlen(a1);
v3 = strlen(a2);
if ( v2 && v3 )
result = (unsigned int)((int)(200 * func0((__int64)a1, v2, (__int64)a2, v3, 1)) / (v2 + v3));
else
result = 0LL;
return result;
}

original_code:
int
simil (const char *a, const char *b)
{
  int alen, blen;
  alen = strlen (a);
  blen = strlen (b);
  if (alen == 0 || blen == 0)
    return 0;
  return (rsimil (a, alen, b, blen, 1) * 200) / (alen + blen);
}

canonical_original_code:
int simil(char *a, char *b)
{
  int alen; int blen;
  alen = strlen (a);
  blen = strlen (b);
  if (alen == 0 || blen == 0)
    return 0;
  return (rsimil (a, alen, b, blen, 1) * 200) / (alen + blen);
}

variable_types:
a
char *

variable_types:
b
char *

variable_types: alen int

variable_types: blen int


isimil

decompiled_code:
__int64 __fastcall isimil(const char *a1, const char *a2)
{
int v2; // ebp
int v3; // eax
__int64 result; // rax

v2 = strlen(a1);
v3 = strlen(a2);
if ( v2 && v3 )
result = (unsigned int)((int)(200 * rsimil((__int64)a1, v2, (__int64)a2, v3, 0)) / (v2 + v3));
else
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(const char *a1, const char *a2)
{
int v2; // ebp
int v3; // eax
__int64 result; // rax

v2 = strlen(a1);
v3 = strlen(a2);
if ( v2 && v3 )
result = (unsigned int)((int)(200 * func0((__int64)a1, v2, (__int64)a2, v3, 0)) / (v2 + v3));
else
result = 0LL;
return result;
}

original_code:
int
isimil (const char *a, const char *b)
{
  int alen, blen;
  alen = strlen (a);
  blen = strlen (b);
  if (alen == 0 || blen == 0)
    return 0;
  return (rsimil (a, alen, b, blen, 0) * 200) / (alen + blen);
}

canonical_original_code:
int isimil(char *a, char *b)
{
  int alen; int blen;
  alen = strlen (a);
  blen = strlen (b);
  if (alen == 0 || blen == 0)
    return 0;
  return (rsimil (a, alen, b, blen, 0) * 200) / (alen + blen);
}


decompiled_code:
__int64 __fastcall print_node(const char *a1)
{
printf("- %s\n", a1);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1)
{
printf("- %s\n", a1);
return 1LL;
}

original_code:
static int print_node(void *data)
{
 char *s = data;
 printf("- %s\n", s);
 return 1;
}

variable_types:
data
void *


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbp
unsigned int v4; // eax
__int64 v6; // rax
__int64 v7; // rax
void *v8; // rdx
int v9; // eax
void *v10; // rdx
void *v11; // rax
const char *v12; // rax
char *v13; // r12
const char *v14; // rsi
int v15; // [rsp+0h] [rbp-68h] BYREF
__int16 v16; // [rsp+4h] [rbp-64h]
char v17[72]; // [rsp+20h] [rbp-48h] BYREF

puts("Type 'help' for help");
v3 = list_create("Type 'help' for help", argv);
while ( 1 )
{
do
{
printf(">>");
fflush(stdout);
}
while ( (unsigned int)_isoc99_scanf("%10s", &v15) != 1 );
if ( v15 == 1953068401 && !(_BYTE)v16 )
break;
if ( v15 != 1886152040 || (_BYTE)v16 )
{
if ( v15 == 6579297 )
{
if ( (unsigned int)_isoc99_scanf("%40s", v17) == 1 )
{
v6 = my_strdup(v17);
list_append(v3, v6);
}
}
else if ( v15 != 1717855329 || (_BYTE)v16 )
{
if ( v15 != 2003789939 || (_BYTE)v16 )
{
if ( v15 == 2003789939 && v16 == 114 )
{
list_iterate_reverse(v3, print_node);
}
else if ( v15 != 1684957542 || (_BYTE)v16 )
{
if ( v15 == 1684957542 && v16 == 105 )
{
if ( (unsigned int)_isoc99_scanf("%40s", v17) == 1 )
{
v8 = &list_stricmp;
goto LABEL_34;
}
}
else if ( !strcmp((const char *)&v15, "rem") )
{
v9 = _isoc99_scanf("%40s", v17);
v10 = &list_strcmp;
if ( v9 == 1 )
goto LABEL_40;
}
else if ( !strcmp((const char *)&v15, "remi") )
{
if ( (unsigned int)_isoc99_scanf("%40s", v17) == 1 )
{
v10 = &list_stricmp;
LABEL_40:
v11 = (void *)list_remove(v3, v17, v10);
free(v11);
}
}
else
{
if ( !strcmp((const char *)&v15, "popf") )
{
v12 = (const char *)list_pop_front(v3);
goto LABEL_42;
}
if ( !strcmp((const char *)&v15, "popb") )
{
v12 = (const char *)list_pop_back(v3);
LABEL_42:
v13 = (char *)v12;
printf("Popped %s\n", v12);
free(v13);
}
else if ( !strcmp((const char *)&v15, "empty") )
{
v14 = "empty";
if ( !(unsigned int)list_isempty(v3) )
v14 = "not empty";
printf("List is %s\n", v14);
}
else if ( !strcmp((const char *)&v15, "count") )
{
v4 = list_count(v3);
printf("List has %d items\n", v4);
}
else
{
fprintf(stderr, "Unknown command %s\n", (const char *)&v15);
fflush(stdout);
}
}
}
else if ( (unsigned int)_isoc99_scanf("%40s", v17) == 1 )
{
v8 = &list_strcmp;
LABEL_34:
if ( list_find(v3, v17, v8) )
printf("%s is in the list\n", v17);
else
printf("%s is not in the list\n", v17);
}
}
else
{
list_iterate(v3, print_node);
}
}
else if ( (unsigned int)_isoc99_scanf("%40s", v17) == 1 )
{
v7 = my_strdup(v17);
list_prepend(v3, v7);
}
}
else
{
puts("help - Shows this message");
puts("quit - exits the test program");
puts("add <item> - Add item (at the end)");
puts("addf <item> - Add item to the front.");
puts("show - shows all items.");
puts("showr - shows items in revers order.");
puts("find <item> - Searches for an item in the list.");
puts("findi <item> - Case insensitive find.");
puts("rem <item> - removes an item in the list.");
puts("remi <item> - Case insensitive remove.");
puts("popf - Pops the front of the list.");
puts("popb - Pops the back of the list.");
puts("empty - Determines whether the list is empty");
puts("count - Counts the number of elements in the list");
}
}
list_destroy(v3, &free);
return 0;
}

original_code:
int main(int argc, char *argv[])
{
 link_list *list;
 char cmd[21], arg[41];
 printf("Type 'help' for help\n");
 list = list_create();
 for(;;)
 {
  printf(">>");
  fflush(stdout);
  if(scanf("%10s", cmd) != 1) continue;
  if(!strcmp(cmd, "quit")) break;
  else if(!strcmp(cmd, "help"))
  {
   printf("help - Shows this message\n");
   printf("quit - exits the test program\n");
   printf("add <item> - Add item (at the end)\n");
   printf("addf <item> - Add item to the front.\n");
   printf("show - shows all items.\n");
   printf("showr - shows items in revers order.\n");
   printf("find <item> - Searches for an item in the list.\n");
   printf("findi <item> - Case insensitive find.\n");
   printf("rem <item> - removes an item in the list.\n");
   printf("remi <item> - Case insensitive remove.\n");
   printf("popf - Pops the front of the list.\n");
   printf("popb - Pops the back of the list.\n");
   printf("empty - Determines whether the list is empty\n");
   printf("count - Counts the number of elements in the list\n");
  }
  else if(!strcmp(cmd, "add"))
  {
   if(scanf("%40s", arg) != 1) continue;
   list_append(list, my_strdup(arg));
  }
  else if(!strcmp(cmd, "addf"))
  {
   if(scanf("%40s", arg) != 1) continue;
   list_prepend(list, my_strdup(arg));
  }
  else if(!strcmp(cmd, "show"))
  {
   list_iterate(list, print_node);
  }
  else if(!strcmp(cmd, "showr"))
  {
   list_iterate_reverse(list, print_node);
  }
  else if(!strcmp(cmd, "find"))
  {
   if(scanf("%40s", arg) != 1) continue;
   if(list_find(list, arg, list_strcmp))
    printf("%s is in the list\n", arg);
   else
    printf("%s is not in the list\n", arg);
  }
  else if(!strcmp(cmd, "findi"))
  {
   if(scanf("%40s", arg) != 1) continue;
   if(list_find(list, arg, list_stricmp))
    printf("%s is in the list\n", arg);
   else
    printf("%s is not in the list\n", arg);
  }
  else if(!strcmp(cmd, "rem"))
  {
   char *c;
   if(scanf("%40s", arg) != 1) continue;
   c = list_remove(list, arg, list_strcmp);
   free(c);
  }
  else if(!strcmp(cmd, "remi"))
  {
   char *c;
   if(scanf("%40s", arg) != 1) continue;
   c = list_remove(list, arg, list_stricmp);
   free(c);
  }
  else if(!strcmp(cmd, "popf"))
  {
   char *c;
   c = list_pop_front(list);
   printf("Popped %s\n", c);
   free(c);
  }
  else if(!strcmp(cmd, "popb"))
  {
   char *c;
   c = list_pop_back(list);
   printf("Popped %s\n", c);
   free(c);
  }
  else if(!strcmp(cmd, "empty"))
  {
   printf("List is %s\n", list_isempty(list)?"empty":"not empty");
  }
  else if(!strcmp(cmd, "count"))
  {
   printf("List has %d items\n", list_count(list));
  }
  else
  {
   fprintf(stderr, "Unknown command %s\n", cmd);
   fflush(stdout);
  }
 }
 list_destroy(list, free);
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
 struct link_list *list;
 char cmd[21]; char arg[41];
 printf("Type 'help' for help\n");
 list = list_create();
 for(;;)
 {
  printf(">>");
  fflush(stdout);
  if(scanf("%10s", cmd) != 1) continue;
  if(!strcmp(cmd, "quit")) break;
  else if(!strcmp(cmd, "help"))
  {
   printf("help - Shows this message\n");
   printf("quit - exits the test program\n");
   printf("add <item> - Add item (at the end)\n");
   printf("addf <item> - Add item to the front.\n");
   printf("show - shows all items.\n");
   printf("showr - shows items in revers order.\n");
   printf("find <item> - Searches for an item in the list.\n");
   printf("findi <item> - Case insensitive find.\n");
   printf("rem <item> - removes an item in the list.\n");
   printf("remi <item> - Case insensitive remove.\n");
   printf("popf - Pops the front of the list.\n");
   printf("popb - Pops the back of the list.\n");
   printf("empty - Determines whether the list is empty\n");
   printf("count - Counts the number of elements in the list\n");
  }
  else if(!strcmp(cmd, "add"))
  {
   if(scanf("%40s", arg) != 1) continue;
   list_append(list, my_strdup(arg));
  }
  else if(!strcmp(cmd, "addf"))
  {
   if(scanf("%40s", arg) != 1) continue;
   list_prepend(list, my_strdup(arg));
  }
  else if(!strcmp(cmd, "show"))
  {
   list_iterate(list, print_node);
  }
  else if(!strcmp(cmd, "showr"))
  {
   list_iterate_reverse(list, print_node);
  }
  else if(!strcmp(cmd, "find"))
  {
   if(scanf("%40s", arg) != 1) continue;
   if(list_find(list, arg, list_strcmp))
    printf("%s is in the list\n", arg);
   else
    printf("%s is not in the list\n", arg);
  }
  else if(!strcmp(cmd, "findi"))
  {
   if(scanf("%40s", arg) != 1) continue;
   if(list_find(list, arg, list_stricmp))
    printf("%s is in the list\n", arg);
   else
    printf("%s is not in the list\n", arg);
  }
  else if(!strcmp(cmd, "rem"))
  {
   char *c;
   if(scanf("%40s", arg) != 1) continue;
   c = list_remove(list, arg, list_strcmp);
   free(c);
  }
  else if(!strcmp(cmd, "remi"))
  {
   char *c;
   if(scanf("%40s", arg) != 1) continue;
   c = list_remove(list, arg, list_stricmp);
   free(c);
  }
  else if(!strcmp(cmd, "popf"))
  {
   char *c;
   c = list_pop_front(list);
   printf("Popped %s\n", c);
   free(c);
  }
  else if(!strcmp(cmd, "popb"))
  {
   char *c;
   c = list_pop_back(list);
   printf("Popped %s\n", c);
   free(c);
  }
  else if(!strcmp(cmd, "empty"))
  {
   printf("List is %s\n", list_isempty(list)?"empty":"not empty");
  }
  else if(!strcmp(cmd, "count"))
  {
   printf("List has %d items\n", list_count(list));
  }
  else
  {
   fprintf(stderr, "Unknown command %s\n", cmd);
   fflush(stdout);
  }
 }
 list_destroy(list, free);
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: struct link_list { struct list_element { struct list_element *next; void *data; } *first; } *

variable_types:
cmd
char [21]

variable_types:
arg
char [41]

variable_types:
c
char *

user_defined_types: struct link_list { struct list_element *first; }


decompiled_code:
void __fastcall wav_free(void *ptr)
{
free(*((void **)ptr + 3));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func0(void *ptr)
{
free(*((void **)ptr + 3));
free(ptr);
}

original_code:
void wav_free(wav_t *w) {
 free(w->bytes);
 free(w);
}

canonical_original_code:
void wav_free(struct wav_t *w) {
 free(w->bytes);
 free(w);
}

variable_types: struct wav_t { unsigned short num_channels; unsigned int sample_rate; unsigned short bits_per_sample; unsigned int abytes; unsigned int nbytes; char *bytes; } *