qanfgp

decompiled_code:
__int64 qanfgp()
{
int v0; // er14
char v1; // r13
unsigned int v2; // er12
int v3; // ebp
void *v4; // rsi
int v5; // ebx
__int64 v7; // [rsp+8h] [rbp-70h] BYREF
char v8[4]; // [rsp+10h] [rbp-68h] BYREF
unsigned int v9; // [rsp+14h] [rbp-64h]

v0 = 5;
v1 = 1;
v2 = 0x10000;
v3 = 9;
qmov(qone, &qk);
qmov(qone, &qden);
qclear(&uf);
qclear(&ug);
v7 = 216LL;
ltoq(&v7, &q216);
qmov(&qk, v8);
++v9;
qadd(qone, v8);
qmov(v8, &qnum);
while ( 1 )
{
qadd(&qtwo, v8);
qadd(&qtwo, v8);
qmuli(v8, &qnum);
qnum = -(qnum == 0);
qmuli(&q216, &qden);
qmuli(&qk, &qden);
qmul(&zeta, &qden);
qdiv(&qden, &qnum, v8);
if ( (v1 & 1) == 0 )
break;
v4 = &ug;
if ( (v1 & 2) == 0 )
goto LABEL_12;
LABEL_4:
qsub(v8, v4);
if ( v2 > v9 )
v2 = v9;
if ( v9 > v2 )
return 0LL;
LABEL_7:
++v1;
qadd(qone, &qk);
if ( (int)(qone[1] - v9) > 175 )
return 0LL;
v5 = v0;
qmov(&qk, v8);
++v9;
qadd(qone, v8);
qmov(v8, &qnum);
if ( v0 < v3 )
{
do
{
v5 += 2;
qadd(&qtwo, v8);
qmuli(v8, &qnum);
}
while ( v5 < v3 );
}
v0 += 2;
v3 += 6;
}
v4 = &uf;
if ( (v1 & 2) != 0 )
goto LABEL_4;
LABEL_12:
qadd(v8, v4);
if ( v2 > v9 )
v2 = v9;
if ( v9 <= v2 )
goto LABEL_7;
return 0LL;
}

canonical_decompiled_code:
__int64 func1()
{
int v0; // er14
char v1; // r13
unsigned int v2; // er12
int v3; // ebp
void *v4; // rsi
int v5; // ebx
__int64 v7; // [rsp+8h] [rbp-70h] BYREF
char v8[4]; // [rsp+10h] [rbp-68h] BYREF
unsigned int v9; // [rsp+14h] [rbp-64h]

v0 = 5;
v1 = 1;
v2 = 0x10000;
v3 = 9;
qmov(qone, &qk);
qmov(qone, &qden);
qclear(&uf);
qclear(&ug);
v7 = 216LL;
ltoq(&v7, &q216);
qmov(&qk, v8);
++v9;
qadd(qone, v8);
qmov(v8, &qnum);
while ( 1 )
{
qadd(&qtwo, v8);
qadd(&qtwo, v8);
qmuli(v8, &qnum);
qnum = -(qnum == 0);
qmuli(&q216, &qden);
qmuli(&qk, &qden);
qmul(&zeta, &qden);
qdiv(&qden, &qnum, v8);
if ( (v1 & 1) == 0 )
break;
v4 = &ug;
if ( (v1 & 2) == 0 )
goto LABEL_12;
LABEL_4:
qsub(v8, v4);
if ( v2 > v9 )
v2 = v9;
if ( v9 > v2 )
return 0LL;
LABEL_7:
++v1;
qadd(qone, &qk);
if ( (int)(qone[1] - v9) > 175 )
return 0LL;
v5 = v0;
qmov(&qk, v8);
++v9;
qadd(qone, v8);
qmov(v8, &qnum);
if ( v0 < v3 )
{
do
{
v5 += 2;
qadd(&qtwo, v8);
qmuli(v8, &qnum);
}
while ( v5 < v3 );
}
v0 += 2;
v3 += 6;
}
v4 = &uf;
if ( (v1 & 2) != 0 )
goto LABEL_4;
LABEL_12:
qadd(v8, v4);
if ( v2 > v9 )
v2 = v9;
if ( v9 <= v2 )
goto LABEL_7;
return 0LL;
}

original_code:
int qanfgp()
{
QELT temp[14];
QELT maxf;
int k, i;
long ll;
maxf = 65536;
k = 1;
qmov( qone, qk );
qmov( qone, qden );
qclear( uf );
qclear( ug );
ll = 216;
ltoq( &ll, q216);
do
 {
 i = 2*k + 1;
 qmov( qk, temp );
 temp[1] += 1;
 qadd( qone, temp, temp );
 qmov( temp, qnum );
 while( i < (6*k-3) )
  {
  i += 2;
  qadd( qtwo, temp, temp );
  qmuli( temp, qnum, qnum );
  }
 qadd( qtwo, temp, temp );
 qadd( qtwo, temp, temp );
 qmuli( temp, qnum, qnum );
 if( qnum[0] != 0 )
  qnum[0] = 0;
 else
  qnum[0] = -1;
 qmuli( q216, qden, qden );
 qmuli( qk, qden, qden );
 qmul( zeta, qden, qden );
 qdiv( qden, qnum, temp );
 if( k & 1 )
  {
  if( k & 2 )
   qsub( temp, ug, ug );
  else
   qadd( temp, ug, ug );
  }
 else
  {
  if( k & 2 )
   qsub( temp, uf, uf );
  else
   qadd( temp, uf, uf );
  }
 if( temp[1] < maxf )
  maxf = temp[1];
 if( temp[1] > maxf )
  break;
 k += 1;
 qadd( qone, qk, qk );
 }
while( ((int) qone[1] - (int) temp[1]) < (((14 -2)-1)*32)/2 );
return 0;
}

canonical_original_code:
int qanfgp()
{
unsigned int temp[14];
unsigned int maxf;
int k; int i;
long ll;
maxf = 65536;
k = 1;
qmov( qone, qk );
qmov( qone, qden );
qclear( uf );
qclear( ug );
ll = 216;
ltoq( &ll, q216);
do
 {
 i = 2*k + 1;
 qmov( qk, temp );
 temp[1] += 1;
 qadd( qone, temp, temp );
 qmov( temp, qnum );
 while( i < (6*k-3) )
  {
  i += 2;
  qadd( qtwo, temp, temp );
  qmuli( temp, qnum, qnum );
  }
 qadd( qtwo, temp, temp );
 qadd( qtwo, temp, temp );
 qmuli( temp, qnum, qnum );
 if( qnum[0] != 0 )
  qnum[0] = 0;
 else
  qnum[0] = -1;
 qmuli( q216, qden, qden );
 qmuli( qk, qden, qden );
 qmul( zeta, qden, qden );
 qdiv( qden, qnum, temp );
 if( k & 1 )
  {
  if( k & 2 )
   qsub( temp, ug, ug );
  else
   qadd( temp, ug, ug );
  }
 else
  {
  if( k & 2 )
   qsub( temp, uf, uf );
  else
   qadd( temp, uf, uf );
  }
 if( temp[1] < maxf )
  maxf = temp[1];
 if( temp[1] > maxf )
  break;
 k += 1;
 qadd( qone, qk, qk );
 }
while( ((int) qone[1] - (int) temp[1]) < (((14 -2)-1)*32)/2 );
return 0;
}


nbdtrcf

repo: jeremybarnes/cephes

decompiled_code:
__m64 __fastcall nbdtrcf(int a1, int a2, float a3)
{
__m64 result; // xmm0_8

if ( a3 < 0.0 || a3 > 1.0 || a1 < 0 )
{
mtherr("nbdtrf", 1LL);
result = 0LL;
}
else
{
*((_DWORD *)&result + 1) = 0;
*(float *)&result.m64_u64 = (float)(a1 + 1);
incbetf(result.m64_f32[0], (float)a2, 1.0 - a3);
}
return result;
}

canonical_decompiled_code:
__m64 __fastcall func0(int a1, int a2, float a3)
{
__m64 result; // xmm0_8

if ( a3 < 0.0 || a3 > 1.0 || a1 < 0 )
{
mtherr("nbdtrf", 1LL);
result = 0LL;
}
else
{
*((_DWORD *)&result + 1) = 0;
*(float *)&result.m64_u64 = (float)(a1 + 1);
incbetf(result.m64_f32[0], (float)a2, 1.0 - a3);
}
return result;
}

original_code:
float nbdtrcf( int k, int n, float pp )
{
float dk, dn, p;
p = pp;
if( (p < 0.0) || (p > 1.0) )
 goto domerr;
if( k < 0 )
 {
domerr:
 mtherr( "nbdtrf", 1 );
 return( 0.0 );
 }
dk = k+1;
dn = n;
return( incbetf( dk, dn, 1.0 - p ) );
}

canonical_original_code:
float nbdtrcf(int k, int n, float pp)
{
float dk; float dn; float p;
p = pp;
if( (p < 0.0) || (p > 1.0) )
 goto domerr;
if( k < 0 )
 {
domerr:
 mtherr( "nbdtrf", 1 );
 return( 0.0 );
 }
dk = k+1;
dn = n;
return( incbetf( dk, dn, 1.0 - p ) );
}

variable_types: k int

variable_types: n int

variable_types: pp float

variable_types: dk float

variable_types: dn float

variable_types: p float

return_type: float


nbdtrf

decompiled_code:
__m64 __fastcall nbdtrf(int a1, int a2, float a3)
{
__m64 result; // xmm0_8

if ( a3 < 0.0 || a3 > 1.0 || a1 < 0 )
{
mtherr("nbdtrf", 1LL);
result = 0LL;
}
else
{
*((_DWORD *)&result + 1) = 0;
*(float *)&result.m64_u64 = (float)a2;
incbetf((float)a2, (float)(a1 + 1), a3);
}
return result;
}

canonical_decompiled_code:
__m64 __fastcall func1(int a1, int a2, float a3)
{
__m64 result; // xmm0_8

if ( a3 < 0.0 || a3 > 1.0 || a1 < 0 )
{
mtherr("nbdtrf", 1LL);
result = 0LL;
}
else
{
*((_DWORD *)&result + 1) = 0;
*(float *)&result.m64_u64 = (float)a2;
incbetf((float)a2, (float)(a1 + 1), a3);
}
return result;
}

original_code:
float nbdtrf( int k, int n, float pp )
{
float dk, dn, p;
p = pp;
if( (p < 0.0) || (p > 1.0) )
 goto domerr;
if( k < 0 )
 {
domerr:
 mtherr( "nbdtrf", 1 );
 return( 0.0 );
 }
dk = k+1;
dn = n;
return( incbetf( dn, dk, p ) );
}

canonical_original_code:
float nbdtrf(int k, int n, float pp)
{
float dk; float dn; float p;
p = pp;
if( (p < 0.0) || (p > 1.0) )
 goto domerr;
if( k < 0 )
 {
domerr:
 mtherr( "nbdtrf", 1 );
 return( 0.0 );
 }
dk = k+1;
dn = n;
return( incbetf( dn, dk, p ) );
}


decompiled_code:
float __fastcall k1f(double a1)
{
double v2; // xmm0_8
float v3; // xmm0_4
float result; // xmm0_4
float v5; // xmm0_4
float v6; // [rsp+8h] [rbp-10h]
float v7; // [rsp+8h] [rbp-10h]

v2 = *(float *)&a1;
if ( v2 <= 6.000000000000001e-39 )
{
mtherr(&unk_2AD, 1LL, v2, a1);
result = MAXNUMF;
}
else if ( *(float *)&a1 <= 2.0 )
{
v5 = logf(*(float *)&a1 * 0.5);
v7 = v5 * i1f(COERCE_DOUBLE((unsigned __int64)LODWORD(a1)));
result = (float)(chbevlf(&A, 7LL, (float)(*(float *)&a1 * *(float *)&a1) - 2.0) / *(float *)&a1) + v7;
}
else
{
v3 = expf(COERCE_FLOAT(LODWORD(a1) ^ LC4));
v6 = v3 * chbevlf(&B, 10LL, (float)(8.0 / *(float *)&a1) - 2.0);
result = v6 / sqrtf(*(float *)&a1);
}
return result;
}

canonical_decompiled_code:
float __fastcall func0(double a1)
{
double v2; // xmm0_8
float v3; // xmm0_4
float result; // xmm0_4
float v5; // xmm0_4
float v6; // [rsp+8h] [rbp-10h]
float v7; // [rsp+8h] [rbp-10h]

v2 = *(float *)&a1;
if ( v2 <= 6.000000000000001e-39 )
{
mtherr(&unk_2AD, 1LL, v2, a1);
result = MAXNUMF;
}
else if ( *(float *)&a1 <= 2.0 )
{
v5 = logf(*(float *)&a1 * 0.5);
v7 = v5 * i1f(COERCE_DOUBLE((unsigned __int64)LODWORD(a1)));
result = (float)(chbevlf(&A, 7LL, (float)(*(float *)&a1 * *(float *)&a1) - 2.0) / *(float *)&a1) + v7;
}
else
{
v3 = expf(COERCE_FLOAT(LODWORD(a1) ^ LC4));
v6 = v3 * chbevlf(&B, 10LL, (float)(8.0 / *(float *)&a1) - 2.0);
result = v6 / sqrtf(*(float *)&a1);
}
return result;
}

original_code:
float k1f(float xx)
{
float x, y;
x = xx;
if( x <= 6.0e-39 )
 {
 mtherr( "k1f", 1 );
 return( MAXNUMF );
 }
if( x <= 2.0f )
 {
 y = x * x - 2.0f;
 y = logf( 0.5f * x ) * i1f(x) + chbevlf( y, A, 7 ) / x;
 return( y );
 }
return( expf(-x) * chbevlf( 8.0f/x - 2.0f, B, 10 ) / sqrtf(x) );
}

canonical_original_code:
float k1f(float xx)
{
float x; float y;
x = xx;
if( x <= 6.0e-39 )
 {
 mtherr( "k1f", 1 );
 return( MAXNUMF );
 }
if( x <= 2.0f )
 {
 y = x * x - 2.0f;
 y = logf( 0.5f * x ) * i1f(x) + chbevlf( y, A, 7 ) / x;
 return( y );
 }
return( expf(-x) * chbevlf( 8.0f/x - 2.0f, B, 10 ) / sqrtf(x) );
}

variable_types: xx float

variable_types: x float

variable_types: y float


decompiled_code:
float __fastcall k1ef(double a1)
{
float v1; // xmm1_4
float result; // xmm0_4
float v3; // [rsp+0h] [rbp-10h]
float v4; // [rsp+0h] [rbp-10h]
float v5; // [rsp+0h] [rbp-10h]
float v6; // [rsp+0h] [rbp-10h]

v1 = *(float *)&a1;
if ( *(float *)&a1 <= 0.0 )
{
mtherr("k1ef", 1LL, 0.0, a1);
result = MAXNUMF;
}
else if ( *(float *)&a1 <= 2.0 )
{
v4 = logf(*(float *)&a1 * 0.5);
v5 = v4 * i1f(COERCE_DOUBLE((unsigned __int64)LODWORD(v1)));
v6 = (float)(chbevlf(&A, 7LL, (float)(v1 * v1) - 2.0) / v1) + v5;
result = expf(v1) * v6;
}
else
{
v3 = chbevlf(&B, 10LL, (float)(8.0 / *(float *)&a1) - 2.0);
result = v3 / sqrtf(v1);
}
return result;
}

canonical_decompiled_code:
float __fastcall func1(double a1)
{
float v1; // xmm1_4
float result; // xmm0_4
float v3; // [rsp+0h] [rbp-10h]
float v4; // [rsp+0h] [rbp-10h]
float v5; // [rsp+0h] [rbp-10h]
float v6; // [rsp+0h] [rbp-10h]

v1 = *(float *)&a1;
if ( *(float *)&a1 <= 0.0 )
{
mtherr("k1ef", 1LL, 0.0, a1);
result = MAXNUMF;
}
else if ( *(float *)&a1 <= 2.0 )
{
v4 = logf(*(float *)&a1 * 0.5);
v5 = v4 * i1f(COERCE_DOUBLE((unsigned __int64)LODWORD(v1)));
v6 = (float)(chbevlf(&A, 7LL, (float)(v1 * v1) - 2.0) / v1) + v5;
result = expf(v1) * v6;
}
else
{
v3 = chbevlf(&B, 10LL, (float)(8.0 / *(float *)&a1) - 2.0);
result = v3 / sqrtf(v1);
}
return result;
}

original_code:
float k1ef( float xx )
{
float x, y;
x = xx;
if( x <= 0.0f )
 {
 mtherr( "k1ef", 1 );
 return( MAXNUMF );
 }
if( x <= 2.0f )
 {
 y = x * x - 2.0f;
 y = logf( 0.5f * x ) * i1f(x) + chbevlf( y, A, 7 ) / x;
 return( y * expf(x) );
 }
return( chbevlf( 8.0f/x - 2.0f, B, 10 ) / sqrtf(x) );
}

canonical_original_code:
float k1ef(float xx)
{
float x; float y;
x = xx;
if( x <= 0.0f )
 {
 mtherr( "k1ef", 1 );
 return( MAXNUMF );
 }
if( x <= 2.0f )
 {
 y = x * x - 2.0f;
 y = logf( 0.5f * x ) * i1f(x) + chbevlf( y, A, 7 ) / x;
 return( y * expf(x) );
 }
return( chbevlf( 8.0f/x - 2.0f, B, 10 ) / sqrtf(x) );
}


original_code:
float exp10f(float xx)
{
float x, px, qx;
short n;
x = xx;
if( x > MAXL10 )
 {
 mtherr( "exp10f", 3 );
 return( MAXNUMF );
 }
if( x < -MAXL10 )
 {
 mtherr( "exp10f", 4 );
 return(0.0);
 }
if( x == 0 )
 return(1.0);
px = x * LOG210;
qx = floorf( px + 0.5 );
n = qx;
x -= qx * LG102A;
x -= qx * LG102B;
px = 1.0 + x * polevlf( x, P, 5 );
x = ldexpf( px, n );
return(x);
}

canonical_original_code:
float exp10f(float xx)
{
float x; float px; float qx;
short n;
x = xx;
if( x > MAXL10 )
 {
 mtherr( "exp10f", 3 );
 return( MAXNUMF );
 }
if( x < -MAXL10 )
 {
 mtherr( "exp10f", 4 );
 return(0.0);
 }
if( x == 0 )
 return(1.0);
px = x * LOG210;
qx = floorf( px + 0.5 );
n = qx;
x -= qx * LG102A;
x -= qx * LG102B;
px = 1.0 + x * polevlf( x, P, 5 );
x = ldexpf( px, n );
return(x);
}

variable_types: px float

variable_types: qx float

variable_types: n short


stdtrf

canonical_original_code:
float stdtrf(int k, float tt)
{
float t; float x; float rk; float z; float f; float tz; float p; float xsqk;
int j;
t = tt;
if( k <= 0 )
 {
 mtherr( "stdtrf", 1 );
 return(0.0);
 }
if( t == 0 )
 return( 0.5 );
if( t < -1.0 )
 {
 rk = k;
 z = rk / (rk + t * t);
 p = 0.5 * incbetf( 0.5*rk, 0.5, z );
 return( p );
 }
if( t < 0 )
 x = -t;
else
 x = t;
rk = k;
z = 1.0 + ( x * x )/rk;
if( (k & 1) != 0)
 {
 xsqk = x/sqrtf(rk);
 p = atanf( xsqk );
 if( k > 1 )
  {
  f = 1.0;
  tz = 1.0;
  j = 3;
  while( (j<=(k-2)) && ( (tz/f) > MACHEPF ) )
   {
   tz *= (j-1)/( z * j );
   f += tz;
   j += 2;
   }
  p += f * xsqk/z;
  }
 p *= 2.0/PIF;
 }
else
 {
 f = 1.0;
 tz = 1.0;
 j = 2;
 while( ( j <= (k-2) ) && ( (tz/f) > MACHEPF ) )
  {
  tz *= (j - 1)/( z * j );
  f += tz;
  j += 2;
  }
 p = f * x/sqrtf(z*rk);
 }
if( t < 0 )
 p = -p;
 p = 0.5 + 0.5 * p;
return(p);
}

variable_types: tt float

variable_types: t float

variable_types: rk float

variable_types: z float

variable_types: f float

variable_types: tz float

variable_types: xsqk float

variable_types: j int


psif

canonical_original_code:
float psif(float xx)
{
float p; float q; float nz; float x; float s; float w; float y; float z;
int i; int n; int negative;
x = xx;
nz = 0.0;
negative = 0;
if( x <= 0.0 )
 {
 negative = 1;
 q = x;
 p = floorf(q);
 if( p == q )
  {
  mtherr( "psif", 2 );
  return( MAXNUMF );
  }
 nz = q - p;
 if( nz != 0.5 )
  {
  if( nz > 0.5 )
   {
   p += 1.0;
   nz = q - p;
   }
  nz = PIF/tanf(PIF*nz);
  }
 else
  {
  nz = 0.0;
  }
 x = 1.0 - x;
 }
if( (x <= 10.0) && (x == floorf(x)) )
 {
 y = 0.0;
 n = x;
 for( i=1; i<n; i++ )
  {
  w = i;
  y += 1.0/w;
  }
 y -= 0.57721566490153286061;
 goto done;
 }
s = x;
w = 0.0;
while( s < 10.0 )
 {
 w += 1.0/s;
 s += 1.0;
 }
if( s < 1.0e8 )
 {
 z = 1.0/(s * s);
 y = z * polevlf( z, A, 3 );
 }
else
 y = 0.0;
y = logf(s) - (0.5/s) - y - w;
done:
if( negative )
 {
 y -= nz;
 }
return(y);
}

variable_types: q float

variable_types: nz float

variable_types: s float

variable_types: w float

variable_types: i int

variable_types: n int

variable_types: negative int


sinhf

original_code:
float sinhf( float xx )
{
register float z;
float x;
x = xx;
if( xx < 0 )
 z = -x;
else
 z = x;
if( z > MAXLOGF )
 {
 mtherr( "sinhf", 1 );
 if( x > 0 )
  return( MAXNUMF );
 else
  return( -MAXNUMF );
 }
if( z > 1.0 )
 {
 z = expf(z);
 z = 0.5*z - (0.5/z);
 if( x < 0 )
  z = -z;
 }
else
 {
 z = x * x;
 z =
 (( 2.03721912945E-4 * z
   + 8.33028376239E-3) * z
   + 1.66667160211E-1) * z * x
   + x;
 }
return( z );
}

canonical_original_code:
float sinhf(float xx)
{
register float z;
float x;
x = xx;
if( xx < 0 )
 z = -x;
else
 z = x;
if( z > MAXLOGF )
 {
 mtherr( "sinhf", 1 );
 if( x > 0 )
  return( MAXNUMF );
 else
  return( -MAXNUMF );
 }
if( z > 1.0 )
 {
 z = expf(z);
 z = 0.5*z - (0.5/z);
 if( x < 0 )
  z = -z;
 }
else
 {
 z = x * x;
 z =
 (( 2.03721912945E-4 * z
   + 8.33028376239E-3) * z
   + 1.66667160211E-1) * z * x
   + x;
 }
return( z );
}

variable_types: xx float

variable_types: x float


ellpkf

decompiled_code:
float __fastcall ellpkf(double a1)
{
float result; // xmm0_4
float x; // [rsp+0h] [rbp-14h]
float xa; // [rsp+0h] [rbp-14h]
float v4; // [rsp+4h] [rbp-10h]
float v5; // [rsp+8h] [rbp-Ch]

if ( *(float *)&a1 < 0.0 || *(float *)&a1 > 1.0 )
{
mtherr("ellpkf", 1LL);
result = 0.0;
}
else if ( *(float *)&a1 > MACHEPF )
{
x = *(float *)&a1;
v5 = polevlf(&P, 10LL, a1, a1);
v4 = x;
xa = logf(x);
result = v5
- (float)(xa
* polevlf(
&Q,
10LL,
COERCE_DOUBLE((unsigned __int64)LODWORD(v4)),
COERCE_DOUBLE((unsigned __int64)LODWORD(v4))));
}
else if ( *(float *)&a1 == 0.0 )
{
mtherr("ellpkf", 2LL);
result = MAXNUMF;
}
else
{
result = 1.386294364929199 - logf(*(float *)&a1) * 0.5;
}
return result;
}

canonical_decompiled_code:
float __fastcall func0(double a1)
{
float result; // xmm0_4
float x; // [rsp+0h] [rbp-14h]
float xa; // [rsp+0h] [rbp-14h]
float v4; // [rsp+4h] [rbp-10h]
float v5; // [rsp+8h] [rbp-Ch]

if ( *(float *)&a1 < 0.0 || *(float *)&a1 > 1.0 )
{
mtherr("ellpkf", 1LL);
result = 0.0;
}
else if ( *(float *)&a1 > MACHEPF )
{
x = *(float *)&a1;
v5 = polevlf(&P, 10LL, a1, a1);
v4 = x;
xa = logf(x);
result = v5
- (float)(xa
* polevlf(
&Q,
10LL,
COERCE_DOUBLE((unsigned __int64)LODWORD(v4)),
COERCE_DOUBLE((unsigned __int64)LODWORD(v4))));
}
else if ( *(float *)&a1 == 0.0 )
{
mtherr("ellpkf", 2LL);
result = MAXNUMF;
}
else
{
result = 1.386294364929199 - logf(*(float *)&a1) * 0.5;
}
return result;
}

original_code:
float ellpkf(float xx)
{
float x;
x = xx;
if( (x < 0.0) || (x > 1.0) )
 {
 mtherr( "ellpkf", 1 );
 return( 0.0 );
 }
if( x > MACHEPF )
 {
 return( polevlf(x,P,10) - logf(x) * polevlf(x,Q,10) );
 }
else
 {
 if( x == 0.0 )
  {
  mtherr( "ellpkf", 2 );
  return( MAXNUMF );
  }
 else
  {
  return( C1 - 0.5 * logf(x) );
  }
 }
}


jnf

original_code:
float jnf( int n, float xx )
{
float x, pkm2, pkm1, pk, xk, r, ans, xinv, sign;
int k;
x = xx;
sign = 1.0;
if( n < 0 )
 {
 n = -n;
 if( (n & 1) != 0 )
  sign = -1.0;
 }
if( n == 0 )
 return( sign * j0f(x) );
if( n == 1 )
 return( sign * j1f(x) );
if( n == 2 )
 return( sign * (2.0 * j1f(x) / x - j0f(x)) );
k = 24;
pk = 2 * (n + k);
ans = pk;
xk = x * x;
do
 {
 pk -= 2.0;
 ans = pk - (xk/ans);
 }
while( --k > 0 );
pk = 1.0;
xinv = 1.0/x;
pkm1 = ans * xinv;
k = n-1;
r = (float )(2 * k);
do
 {
 pkm2 = (pkm1 * r - pk * x) * xinv;
 pk = pkm1;
 pkm1 = pkm2;
 r -= 2.0;
 }
while( --k > 0 );
r = pk;
if( r < 0 )
 r = -r;
ans = pkm1;
if( ans < 0 )
 ans = -ans;
if( r > ans )
 ans = sign * j1f(x)/pk;
else
 ans = sign * j0f(x)/pkm1;
return( ans );
}

canonical_original_code:
float jnf(int n, float xx)
{
float x; float pkm2; float pkm1; float pk; float xk; float r; float ans; float xinv; float sign;
int k;
x = xx;
sign = 1.0;
if( n < 0 )
 {
 n = -n;
 if( (n & 1) != 0 )
  sign = -1.0;
 }
if( n == 0 )
 return( sign * j0f(x) );
if( n == 1 )
 return( sign * j1f(x) );
if( n == 2 )
 return( sign * (2.0 * j1f(x) / x - j0f(x)) );
k = 24;
pk = 2 * (n + k);
ans = pk;
xk = x * x;
do
 {
 pk -= 2.0;
 ans = pk - (xk/ans);
 }
while( --k > 0 );
pk = 1.0;
xinv = 1.0/x;
pkm1 = ans * xinv;
k = n-1;
r = (float )(2 * k);
do
 {
 pkm2 = (pkm1 * r - pk * x) * xinv;
 pk = pkm1;
 pkm1 = pkm2;
 r -= 2.0;
 }
while( --k > 0 );
r = pk;
if( r < 0 )
 r = -r;
ans = pkm1;
if( ans < 0 )
 ans = -ans;
if( r > ans )
 ans = sign * j1f(x)/pk;
else
 ans = sign * j0f(x)/pkm1;
return( ans );
}

variable_types: pk float

variable_types: xk float

variable_types: r float

variable_types: ans float

variable_types: xinv float

variable_types: sign float

variable_types: k int


facf

decompiled_code:
float __fastcall facf(int a1)
{
float result; // xmm0_4

if ( a1 < 0 )
{
mtherr("facf", 2LL);
result = MAXNUMF;
}
else if ( a1 > 33 )
{
mtherr("facf", 3LL);
result = MAXNUMF;
}
else
{
result = factbl[a1];
}
return result;
}

canonical_decompiled_code:
float __fastcall func0(int a1)
{
float result; // xmm0_4

if ( a1 < 0 )
{
mtherr("facf", 2LL);
result = MAXNUMF;
}
else if ( a1 > 33 )
{
mtherr("facf", 3LL);
result = MAXNUMF;
}
else
{
result = factbl[a1];
}
return result;
}

original_code:
float facf( int i )
{
if( i < 0 )
 {
 mtherr( "facf", 2 );
 return( MAXNUMF );
 }
if( i > 33 )
 {
 mtherr( "facf", 3 );
 return( MAXNUMF );
 }
return( factbl[i] );
}

canonical_original_code:
float facf(int i)
{
if( i < 0 )
 {
 mtherr( "facf", 2 );
 return( MAXNUMF );
 }
if( i > 33 )
 {
 mtherr( "facf", 3 );
 return( MAXNUMF );
 }
return( factbl[i] );
}


igamf

decompiled_code:
__m64 __fastcall igamf(double a1, float a2, double a3, double a4)
{
__m64 result; // xmm0_8
double v6; // xmm2_8
double v7; // xmm0_8
double v8; // xmm2_8
double v9; // xmm6_8
float v10; // xmm3_4
float v11; // xmm0_4
float v12; // xmm2_4
__m64 v13; // xmm7_8
float v14; // [rsp+0h] [rbp-14h]
unsigned int v15; // [rsp+4h] [rbp-10h]

if ( a2 <= 0.0 )
return 0LL;
result = 0LL;
if ( *(float *)&a1 > 0.0 )
{
if ( a2 > 1.0 && a2 > *(float *)&a1 )
{
v13 = (__m64)(unsigned int)LC0;
*(float *)&v13.m64_u64 = 1.0 - igamcf(a1);
result = v13;
}
else
{
v14 = *(float *)&a1;
*(float *)&v15 = (float)(logf(a2) * *(float *)&a1) - a2;
*(_QWORD *)&v6 = v15;
*(float *)&v6 = *(float *)&v15 - lgamf(v14);
v7 = v6;
*(_QWORD *)&v8 = MAXLOGF ^ (unsigned __int64)LC2;
if ( *(float *)&v8 > *(float *)&v7 )
{
mtherr("igamf", 4LL, v7, a2, v8, a4, v14);
result = 0LL;
}
else
{
*(float *)&v7 = expf(*(float *)&v7);
v9 = v7;
v10 = v14;
v11 = *(float *)&LC0;
v12 = *(float *)&LC0;
do
{
v10 = v10 + 1.0;
v11 = v11 * (float)(a2 / v10);
v12 = v12 + v11;
}
while ( (float)(v11 / v12) > MACHEPF );
*((_DWORD *)&result + 1) = HIDWORD(v9);
*(float *)&result.m64_u64 = (float)(*(float *)&v9 * v12) / v14;
}
}
}
return result;
}

canonical_decompiled_code:
__m64 __fastcall func0(double a1, float a2, double a3, double a4)
{
__m64 result; // xmm0_8
double v6; // xmm2_8
double v7; // xmm0_8
double v8; // xmm2_8
double v9; // xmm6_8
float v10; // xmm3_4
float v11; // xmm0_4
float v12; // xmm2_4
__m64 v13; // xmm7_8
float v14; // [rsp+0h] [rbp-14h]
unsigned int v15; // [rsp+4h] [rbp-10h]

if ( a2 <= 0.0 )
return 0LL;
result = 0LL;
if ( *(float *)&a1 > 0.0 )
{
if ( a2 > 1.0 && a2 > *(float *)&a1 )
{
v13 = (__m64)(unsigned int)LC0;
*(float *)&v13.m64_u64 = 1.0 - igamcf(a1);
result = v13;
}
else
{
v14 = *(float *)&a1;
*(float *)&v15 = (float)(logf(a2) * *(float *)&a1) - a2;
*(_QWORD *)&v6 = v15;
*(float *)&v6 = *(float *)&v15 - lgamf(v14);
v7 = v6;
*(_QWORD *)&v8 = MAXLOGF ^ (unsigned __int64)LC2;
if ( *(float *)&v8 > *(float *)&v7 )
{
mtherr("igamf", 4LL, v7, a2, v8, a4, v14);
result = 0LL;
}
else
{
*(float *)&v7 = expf(*(float *)&v7);
v9 = v7;
v10 = v14;
v11 = *(float *)&LC0;
v12 = *(float *)&LC0;
do
{
v10 = v10 + 1.0;
v11 = v11 * (float)(a2 / v10);
v12 = v12 + v11;
}
while ( (float)(v11 / v12) > MACHEPF );
*((_DWORD *)&result + 1) = HIDWORD(v9);
*(float *)&result.m64_u64 = (float)(*(float *)&v9 * v12) / v14;
}
}
}
return result;
}

original_code:
float igamf( float aa, float xx )
{
float a, x, ans, ax, c, r;
a = aa;
x = xx;
if( (x <= 0) || ( a <= 0) )
 return( 0.0 );
if( (x > 1.0) && (x > a ) )
 return( 1.0 - igamcf(a,x) );
ax = a * logf(x) - x - lgamf(a);
if( ax < -MAXLOGF )
 {
 mtherr( "igamf", 4 );
 return( 0.0 );
 }
ax = expf(ax);
r = a;
c = 1.0;
ans = 1.0;
do
 {
 r += 1.0;
 c *= x/r;
 ans += c;
 }
while( c/ans > MACHEPF );
return( ans * ax/a );
}

canonical_original_code:
float igamf(float aa, float xx)
{
float a; float x; float ans; float ax; float c; float r;
a = aa;
x = xx;
if( (x <= 0) || ( a <= 0) )
 return( 0.0 );
if( (x > 1.0) && (x > a ) )
 return( 1.0 - igamcf(a,x) );
ax = a * logf(x) - x - lgamf(a);
if( ax < -MAXLOGF )
 {
 mtherr( "igamf", 4 );
 return( 0.0 );
 }
ax = expf(ax);
r = a;
c = 1.0;
ans = 1.0;
do
 {
 r += 1.0;
 c *= x/r;
 ans += c;
 }
while( c/ans > MACHEPF );
return( ans * ax/a );
}

variable_types: aa float

variable_types: a float

variable_types: ax float

variable_types: c float


variable_types: y float

variable_types: z float

variable_types: e int


stirf

original_code:
static float stirf( float xx )
{
float x, y, w, v;
x = xx;
w = 1.0/x;
w = 1.0 + w * polevlf( w, STIR, 2 );
y = expf( -x );
if( x > MAXSTIR )
 {
 v = powf( x, 0.5 * x - 0.25 );
 y *= v;
 y *= v;
 }
else
 {
 y = powf( x, x - 0.5 ) * y;
 }
y = SQTPIF * y * w;
return( y );
}

canonical_original_code:
static float stirf(float xx)
{
float x; float y; float w; float v;
x = xx;
w = 1.0/x;
w = 1.0 + w * polevlf( w, STIR, 2 );
y = expf( -x );
if( x > MAXSTIR )
 {
 v = powf( x, 0.5 * x - 0.25 );
 y *= v;
 y *= v;
 }
else
 {
 y = powf( x, x - 0.5 ) * y;
 }
y = SQTPIF * y * w;
return( y );
}

variable_types: w float

variable_types: v float


repo: jeremyletang/csml

decompiled_code:
__int64 __fastcall vector_int_t_front(__int64 a1)
{
return *(_QWORD *)(a1 + 96);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
return *(_QWORD *)(a1 + 96);
}

original_code: int *vector_int_t_front(struct vector_int_t *self) { return &self->stored_data[0];}

variable_types: struct vector_int_t { int *(*front)(struct vector_int_t *self); int *(*back)(struct vector_int_t *self); int *(*at)(struct vector_int_t *self, unsigned int index); _Bool (*push_back)(struct vector_int_t *self, int item); void (*pop_back)(struct vector_int_t *self); _Bool (*is_empty)(struct vector_int_t *self); unsigned int (*len)(struct vector_int_t *self); unsigned int (*capacity)(struct vector_int_t *self); _Bool (*resize)(struct vector_int_t *self, unsigned int new_capacity); void (*clear)(struct vector_int_t *self); void (*for_each)(struct vector_int_t *self, void (*func)(int *item, void *data), void *data); _Bool (*free)(struct vector_int_t *self); int *stored_data; unsigned int size; unsigned int cap; } *

return_type: int *


decompiled_code:
__int64 __fastcall vector_int_t_back(__int64 a1)
{
return *(_QWORD *)(a1 + 96) + 4LL * (unsigned int)(*(_DWORD *)(a1 + 104) - 1);
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
return *(_QWORD *)(a1 + 96) + 4LL * (unsigned int)(*(_DWORD *)(a1 + 104) - 1);
}

original_code: int *vector_int_t_back(struct vector_int_t *self) { return &self->stored_data[self->size - 1];}

user_defined_types: struct vector_int_t { int *(*front)(struct vector_int_t *self); int *(*back)(struct vector_int_t *self); int *(*at)(struct vector_int_t *self, unsigned int index); _Bool (*push_back)(struct vector_int_t *self, int item); void (*pop_back)(struct vector_int_t *self); _Bool (*is_empty)(struct vector_int_t *self); unsigned int (*len)(struct vector_int_t *self); unsigned int (*capacity)(struct vector_int_t *self); _Bool (*resize)(struct vector_int_t *self, unsigned int new_capacity); void (*clear)(struct vector_int_t *self); void (*for_each)(struct vector_int_t *self, void (*func)(int *item, void *data), void *data); _Bool (*free)(struct vector_int_t *self); int *stored_data; unsigned int size; unsigned int cap; }


decompiled_code:
__int64 __fastcall vector_int_t_at(__int64 a1, unsigned int a2)
{
__int64 result; // rax

result = 0LL;
if ( *(_DWORD *)(a1 + 104) > a2 )
result = *(_QWORD *)(a1 + 96) + 4LL * a2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, unsigned int a2)
{
__int64 result; // rax

result = 0LL;
if ( *(_DWORD *)(a1 + 104) > a2 )
result = *(_QWORD *)(a1 + 96) + 4LL * a2;
return result;
}

original_code: int *vector_int_t_at(struct vector_int_t *self, unsigned int index) { int *return_value = 0; if (index < self->size) { return_value = &self->stored_data[index]; } return return_value;}

variable_types:
index
unsigned int


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

result = *(unsigned int *)(a1 + 104);
if ( (_DWORD)result )
{
result = (unsigned int)(result - 1);
*(_DWORD *)(a1 + 104) = result;
}
return result;
}

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

result = *(unsigned int *)(a1 + 104);
if ( (_DWORD)result )
{
result = (unsigned int)(result - 1);
*(_DWORD *)(a1 + 104) = result;
}
return result;
}

original_code: void vector_int_t_pop_back(struct vector_int_t *self) { if (self->size > 0) { self->size -= 1; }}

return_type: void


decompiled_code:
bool __fastcall vector_int_t_is_empty(__int64 a1)
{
return *(_DWORD *)(a1 + 104) == 0;
}

canonical_decompiled_code:
bool __fastcall func11(__int64 a1)
{
return *(_DWORD *)(a1 + 104) == 0;
}

original_code: _Bool vector_int_t_is_empty(struct vector_int_t *self) { return self->size == 0;}


decompiled_code:
__int64 __fastcall vector_int_t_len(__int64 a1)
{
return *(unsigned int *)(a1 + 104);
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1)
{
return *(unsigned int *)(a1 + 104);
}

original_code: unsigned int vector_int_t_len(struct vector_int_t *self) { return self->size;}

return_type: unsigned int


decompiled_code:
__int64 __fastcall vector_int_t_capacity(__int64 a1)
{
return *(unsigned int *)(a1 + 108);
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1)
{
return *(unsigned int *)(a1 + 108);
}

original_code: unsigned int vector_int_t_capacity(struct vector_int_t *self) { return self->cap;}


decompiled_code:
void __fastcall vector_int_t_clear(__int64 a1)
{
*(_DWORD *)(a1 + 104) = 0;
}

original_code: void vector_int_t_clear(struct vector_int_t *self) { self->size = 0;}


decompiled_code:
__int64 __fastcall vector_int_t_for_each(__int64 a1, __int64 (__fastcall *a2)(__int64, __int64), __int64 a3)
{
unsigned int v4; // ebx
__int64 v5; // rdx
__int64 result; // rax

v4 = 0;
do
{
v5 = v4++;
result = a2(*(_QWORD *)(a1 + 96) + 4 * v5, a3);
}
while ( *(_DWORD *)(a1 + 104) >= v4 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1, __int64 (__fastcall *a2)(__int64, __int64), __int64 a3)
{
unsigned int v4; // ebx
__int64 v5; // rdx
__int64 result; // rax

v4 = 0;
do
{
v5 = v4++;
result = a2(*(_QWORD *)(a1 + 96) + 4 * v5, a3);
}
while ( *(_DWORD *)(a1 + 104) >= v4 );
return result;
}

original_code: void vector_int_t_for_each(struct vector_int_t *self, void (*func)(int *item, void *data), void *data) { unsigned int iter = 0; while (iter <= self->size) { func(&self->stored_data[iter], data); iter += 1; }}

variable_types:
func
void (*)(int *item, void *data)

variable_types:
data
void *

variable_types:
iter
unsigned int


decompiled_code:
__int64 __fastcall vector_int_t_resize(__int64 a1, unsigned int a2)
{
unsigned int v2; // er12
void *v4; // r13
void *v5; // rax

v2 = *(_DWORD *)(a1 + 108);
if ( v2 >= a2 )
return 0LL;
v4 = *(void **)(a1 + 96);
v5 = malloc(4LL * a2);
*(_QWORD *)(a1 + 96) = v5;
if ( !v5 )
return 0LL;
memcpy(v5, v4, 4LL * v2);
*(_DWORD *)(a1 + 108) = a2;
free(v4);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func17(__int64 a1, unsigned int a2)
{
unsigned int v2; // er12
void *v4; // r13
void *v5; // rax

v2 = *(_DWORD *)(a1 + 108);
if ( v2 >= a2 )
return 0LL;
v4 = *(void **)(a1 + 96);
v5 = malloc(4LL * a2);
*(_QWORD *)(a1 + 96) = v5;
if ( !v5 )
return 0LL;
memcpy(v5, v4, 4LL * v2);
*(_DWORD *)(a1 + 108) = a2;
free(v4);
return 1LL;
}

original_code: _Bool vector_int_t_resize(struct vector_int_t *self, unsigned int new_capacity) { int *tmp_data = self->stored_data; _Bool return_value = 0; if (new_capacity > self->cap) { self->stored_data = malloc(sizeof(int) * (new_capacity)); if (self->stored_data) { memcpy(self->stored_data, tmp_data, sizeof(int) * self->cap); self->cap = new_capacity; free(tmp_data); return_value = 1; } } return return_value;}


decompiled_code:
__int64 __fastcall vector_int_t_push_back(__int64 a1, int a2)
{
__int64 v3; // rsi
__int64 result; // rax

v3 = *(unsigned int *)(a1 + 104);
if ( (_DWORD)v3 != *(_DWORD *)(a1 + 108) )
goto LABEL_2;
result = vector_int_t_resize(a1, 2 * (int)v3);
if ( (_BYTE)result )
{
v3 = *(unsigned int *)(a1 + 104);
LABEL_2:
*(_DWORD *)(*(_QWORD *)(a1 + 96) + 4 * v3) = a2;
result = 1LL;
++*(_DWORD *)(a1 + 104);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func18(__int64 a1, int a2)
{
__int64 v3; // rsi
__int64 result; // rax

v3 = *(unsigned int *)(a1 + 104);
if ( (_DWORD)v3 != *(_DWORD *)(a1 + 108) )
goto LABEL_2;
result = func17(a1, 2 * (int)v3);
if ( (_BYTE)result )
{
v3 = *(unsigned int *)(a1 + 104);
LABEL_2:
*(_DWORD *)(*(_QWORD *)(a1 + 96) + 4 * v3) = a2;
result = 1LL;
++*(_DWORD *)(a1 + 104);
}
return result;
}

original_code: _Bool vector_int_t_push_back(struct vector_int_t *self, int item) { _Bool return_value = 1; if (self->size == self->cap) { return_value = vector_int_t_resize(self, self->cap * 2); } if (return_value) { self->stored_data[self->size] = item; self->size += 1; } return return_value;}

variable_types: item int


decompiled_code:
__int64 __fastcall vector_int_t_initialize(__int64 a1, int a2, unsigned int a3)
{
void *v4; // rax
__int64 result; // rax

v4 = malloc(4LL * (unsigned int)(a2 + 1));
*(_QWORD *)(a1 + 96) = v4;
if ( !v4 )
return 0LL;
*(_DWORD *)(a1 + 108) = a2;
*(_DWORD *)(a1 + 104) = 0;
*(_QWORD *)a1 = vector_int_t_front;
*(_QWORD *)(a1 + 8) = vector_int_t_back;
*(_QWORD *)(a1 + 16) = vector_int_t_at;
*(_QWORD *)(a1 + 24) = vector_int_t_push_back;
*(_QWORD *)(a1 + 32) = vector_int_t_pop_back;
*(_QWORD *)(a1 + 40) = vector_int_t_is_empty;
*(_QWORD *)(a1 + 48) = vector_int_t_len;
*(_QWORD *)(a1 + 56) = vector_int_t_capacity;
*(_QWORD *)(a1 + 64) = vector_int_t_resize;
*(_QWORD *)(a1 + 72) = vector_int_t_clear;
*(_QWORD *)(a1 + 80) = vector_int_t_for_each;
if ( (_BYTE)a3 )
{
result = a3;
*(_QWORD *)(a1 + 88) = vector_int_t_delete_heap;
}
else
{
*(_QWORD *)(a1 + 88) = vector_int_t_delete_stacked;
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func19(__int64 a1, int a2, unsigned int a3)
{
void *v4; // rax
__int64 result; // rax

v4 = malloc(4LL * (unsigned int)(a2 + 1));
*(_QWORD *)(a1 + 96) = v4;
if ( !v4 )
return 0LL;
*(_DWORD *)(a1 + 108) = a2;
*(_DWORD *)(a1 + 104) = 0;
*(_QWORD *)a1 = vector_int_t_front;
*(_QWORD *)(a1 + 8) = vector_int_t_back;
*(_QWORD *)(a1 + 16) = vector_int_t_at;
*(_QWORD *)(a1 + 24) = vector_int_t_push_back;
*(_QWORD *)(a1 + 32) = vector_int_t_pop_back;
*(_QWORD *)(a1 + 40) = vector_int_t_is_empty;
*(_QWORD *)(a1 + 48) = vector_int_t_len;
*(_QWORD *)(a1 + 56) = vector_int_t_capacity;
*(_QWORD *)(a1 + 64) = vector_int_t_resize;
*(_QWORD *)(a1 + 72) = vector_int_t_clear;
*(_QWORD *)(a1 + 80) = vector_int_t_for_each;
if ( (_BYTE)a3 )
{
result = a3;
*(_QWORD *)(a1 + 88) = vector_int_t_delete_heap;
}
else
{
*(_QWORD *)(a1 + 88) = vector_int_t_delete_stacked;
result = 1LL;
}
return result;
}

original_code: _Bool vector_int_t_initialize(struct vector_int_t *self, unsigned int capacity, _Bool type) { _Bool return_value = 0; self->stored_data = malloc(sizeof(int) * (capacity + 1 )); if (self->stored_data) { self->cap = capacity; self->size = 0; self->front = vector_int_t_front; self->back = vector_int_t_back; self->at = vector_int_t_at; self->push_back = vector_int_t_push_back; self->pop_back = vector_int_t_pop_back; self->is_empty = vector_int_t_is_empty; self->len = vector_int_t_len; self->capacity = vector_int_t_capacity; self->resize = vector_int_t_resize; self->clear = vector_int_t_clear; self->for_each = vector_int_t_for_each; if (type) { self->free = vector_int_t_delete_heap; } else { self->free = vector_int_t_delete_stacked; } return_value = 1; } return return_value;}

variable_types:
capacity
unsigned int


decompiled_code:
void __fastcall vector_int_t_delete_in(__int64 a1)
{
void *v1; // rdi

v1 = *(void **)(a1 + 96);
if ( v1 )
free(v1);
}

canonical_decompiled_code:
void __fastcall func21(__int64 a1)
{
void *v1; // rdi

v1 = *(void **)(a1 + 96);
if ( v1 )
free(v1);
}

original_code: void vector_int_t_delete_in(struct vector_int_t *self) { if (self->stored_data) { free(self->stored_data); }}


decompiled_code:
__int64 __fastcall vector_int_t_delete_heap(__int64 a1)
{
vector_int_t_delete_in(a1);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func22(__int64 a1)
{
func21(a1);
return 1LL;
}

original_code: _Bool vector_int_t_delete_heap(struct vector_int_t *self) { vector_int_t_delete_in(self); return 1;}


decompiled_code:
__int64 __fastcall vector_int_t_delete_stacked(__int64 a1)
{
vector_int_t_delete_in(a1);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func23(__int64 a1)
{
func21(a1);
return 0LL;
}

original_code: _Bool vector_int_t_delete_stacked(struct vector_int_t *self) { vector_int_t_delete_in(self); return 0;}


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned __int8 (__fastcall **v3)(_QWORD); // rbp
unsigned int v4; // er12
unsigned int v5; // eax
unsigned int v6; // er12
unsigned int v7; // eax
unsigned int v8; // er12
unsigned int *v9; // rax
unsigned int v10; // er12
unsigned int *v11; // rax
unsigned int v12; // er12
unsigned int v13; // eax
unsigned int v14; // er13
unsigned int v15; // er12
unsigned int *v16; // rax
unsigned int v17; // er12
unsigned int *v18; // rax
unsigned int v19; // er12
unsigned int v20; // eax
unsigned int *v21; // rax
_QWORD v23[17]; // [rsp+0h] [rbp-88h] BYREF

v3 = (unsigned __int8 (__fastcall **)(_QWORD))new_vector_int_t(2LL, argv, envp);
stacked_vector_int_t(v23, 20LL);
v4 = ((__int64 (__fastcall *)(_QWORD))v3[7])(v3);
v5 = ((__int64 (__fastcall *)(_QWORD))v3[6])(v3);
printf("Heap vector len / capacity: %d / %d\n", v5, v4);
v6 = ((__int64 (__fastcall *)(_QWORD *))v23[7])(v23);
v7 = ((__int64 (__fastcall *)(_QWORD *))v23[6])(v23);
printf("Stacked vector len / capacity: %d / %d\n", v7, v6);
((void (__fastcall *)(unsigned __int8 (__fastcall **)(_QWORD), __int64))v3[3])(v3, 42LL);
v8 = *(_DWORD *)((__int64 (__fastcall *)(_QWORD))v3[1])(v3);
v9 = (unsigned int *)((__int64 (__fastcall *)(_QWORD))*v3)(v3);
printf("Heap vector front / back: %d / %d\n", *v9, v8);
((void (__fastcall *)(unsigned __int8 (__fastcall **)(_QWORD), __int64))v3[3])(v3, 21LL);
v10 = *(_DWORD *)((__int64 (__fastcall *)(_QWORD))v3[1])(v3);
v11 = (unsigned int *)((__int64 (__fastcall *)(_QWORD))*v3)(v3);
printf("Heap vector front / back: %d / %d\n", *v11, v10);
v12 = ((__int64 (__fastcall *)(_QWORD))v3[7])(v3);
v13 = ((__int64 (__fastcall *)(_QWORD))v3[6])(v3);
printf("Heap vector len / capacity: %d / %d\n", v13, v12);
((void (__fastcall *)(unsigned __int8 (__fastcall **)(_QWORD), __int64))v3[3])(v3, 84LL);
((void (__fastcall *)(unsigned __int8 (__fastcall **)(_QWORD), __int64 (__fastcall *)(), _QWORD))v3[10])(
v3,
increment_of_ten,
0LL);
v14 = *(_DWORD *)((__int64 (__fastcall *)(unsigned __int8 (__fastcall **)(_QWORD), __int64))v3[2])(v3, 2LL);
v15 = *(_DWORD *)((__int64 (__fastcall *)(unsigned __int8 (__fastcall **)(_QWORD), __int64))v3[2])(v3, 1LL);
v16 = (unsigned int *)((__int64 (__fastcall *)(unsigned __int8 (__fastcall **)(_QWORD), _QWORD))v3[2])(v3, 0LL);
printf("After call to for_each, item1: %d, item2: %d, item3: %d\n", *v16, v15, v14);
v3[4](v3);
v17 = *(_DWORD *)((__int64 (__fastcall *)(_QWORD))v3[1])(v3);
v18 = (unsigned int *)((__int64 (__fastcall *)(_QWORD))*v3)(v3);
printf("Heap vector front / back: %d / %d\n", *v18, v17);
v19 = ((__int64 (__fastcall *)(_QWORD))v3[7])(v3);
v20 = ((__int64 (__fastcall *)(_QWORD))v3[6])(v3);
printf("Heap vector len / capacity: %d / %d\n", v20, v19);
v21 = (unsigned int *)((__int64 (__fastcall *)(unsigned __int8 (__fastcall **)(_QWORD), __int64))v3[2])(v3, 1LL);
printf("Heap vector at index 1: %d\n", *v21);
if ( v3[11](v3) )
free(v3);
if ( ((unsigned __int8 (__fastcall *)(_QWORD *))v23[11])(v23) )
free(v23);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned __int8 (__fastcall **v3)(_QWORD); // rbp
unsigned int v4; // er12
unsigned int v5; // eax
unsigned int v6; // er12
unsigned int v7; // eax
unsigned int v8; // er12
unsigned int *v9; // rax
unsigned int v10; // er12
unsigned int *v11; // rax
unsigned int v12; // er12
unsigned int v13; // eax
unsigned int v14; // er13
unsigned int v15; // er12
unsigned int *v16; // rax
unsigned int v17; // er12
unsigned int *v18; // rax
unsigned int v19; // er12
unsigned int v20; // eax
unsigned int *v21; // rax
_QWORD v23[17]; // [rsp+0h] [rbp-88h] BYREF

v3 = (unsigned __int8 (__fastcall **)(_QWORD))func20(2LL, argv, envp);
stacked_vector_int_t(v23, 20LL);
v4 = ((__int64 (__fastcall *)(_QWORD))v3[7])(v3);
v5 = ((__int64 (__fastcall *)(_QWORD))v3[6])(v3);
printf("Heap vector len / capacity: %d / %d\n", v5, v4);
v6 = ((__int64 (__fastcall *)(_QWORD *))v23[7])(v23);
v7 = ((__int64 (__fastcall *)(_QWORD *))v23[6])(v23);
printf("Stacked vector len / capacity: %d / %d\n", v7, v6);
((void (__fastcall *)(unsigned __int8 (__fastcall **)(_QWORD), __int64))v3[3])(v3, 42LL);
v8 = *(_DWORD *)((__int64 (__fastcall *)(_QWORD))v3[1])(v3);
v9 = (unsigned int *)((__int64 (__fastcall *)(_QWORD))*v3)(v3);
printf("Heap vector front / back: %d / %d\n", *v9, v8);
((void (__fastcall *)(unsigned __int8 (__fastcall **)(_QWORD), __int64))v3[3])(v3, 21LL);
v10 = *(_DWORD *)((__int64 (__fastcall *)(_QWORD))v3[1])(v3);
v11 = (unsigned int *)((__int64 (__fastcall *)(_QWORD))*v3)(v3);
printf("Heap vector front / back: %d / %d\n", *v11, v10);
v12 = ((__int64 (__fastcall *)(_QWORD))v3[7])(v3);
v13 = ((__int64 (__fastcall *)(_QWORD))v3[6])(v3);
printf("Heap vector len / capacity: %d / %d\n", v13, v12);
((void (__fastcall *)(unsigned __int8 (__fastcall **)(_QWORD), __int64))v3[3])(v3, 84LL);
((void (__fastcall *)(unsigned __int8 (__fastcall **)(_QWORD), __int64 (__fastcall *)(), _QWORD))v3[10])(
v3,
increment_of_ten,
0LL);
v14 = *(_DWORD *)((__int64 (__fastcall *)(unsigned __int8 (__fastcall **)(_QWORD), __int64))v3[2])(v3, 2LL);
v15 = *(_DWORD *)((__int64 (__fastcall *)(unsigned __int8 (__fastcall **)(_QWORD), __int64))v3[2])(v3, 1LL);
v16 = (unsigned int *)((__int64 (__fastcall *)(unsigned __int8 (__fastcall **)(_QWORD), _QWORD))v3[2])(v3, 0LL);
printf("After call to for_each, item1: %d, item2: %d, item3: %d\n", *v16, v15, v14);
v3[4](v3);
v17 = *(_DWORD *)((__int64 (__fastcall *)(_QWORD))v3[1])(v3);
v18 = (unsigned int *)((__int64 (__fastcall *)(_QWORD))*v3)(v3);
printf("Heap vector front / back: %d / %d\n", *v18, v17);
v19 = ((__int64 (__fastcall *)(_QWORD))v3[7])(v3);
v20 = ((__int64 (__fastcall *)(_QWORD))v3[6])(v3);
printf("Heap vector len / capacity: %d / %d\n", v20, v19);
v21 = (unsigned int *)((__int64 (__fastcall *)(unsigned __int8 (__fastcall **)(_QWORD), __int64))v3[2])(v3, 1LL);
printf("Heap vector at index 1: %d\n", *v21);
if ( v3[11](v3) )
free(v3);
if ( ((unsigned __int8 (__fastcall *)(_QWORD *))v23[11])(v23) )
free(v23);
return 0;
}

original_code:
int main() {
    vector_int_t *heap_vector = new_vector_int_t(2);
    vector_int_t stacked_vector = stacked_vector_int_t(20);
    printf("Heap vector len / capacity: %d / %d\n",
        (heap_vector)->len(heap_vector),
        (heap_vector)->capacity(heap_vector));
    printf("Stacked vector len / capacity: %d / %d\n",
        (&stacked_vector)->len(&stacked_vector),
        (&stacked_vector)->capacity(&stacked_vector));
    (heap_vector)->push_back(heap_vector, 42);
    printf("Heap vector front / back: %d / %d\n",
        *(heap_vector)->front(heap_vector),
        *(heap_vector)->back(heap_vector));
    (heap_vector)->push_back(heap_vector, 21);
    printf("Heap vector front / back: %d / %d\n",
        *(heap_vector)->front(heap_vector),
        *(heap_vector)->back(heap_vector));
    printf("Heap vector len / capacity: %d / %d\n",
        (heap_vector)->len(heap_vector),
        (heap_vector)->capacity(heap_vector));
    (heap_vector)->push_back(heap_vector, 84);
    (heap_vector)->for_each(heap_vector, increment_of_ten, 0);
    printf("After call to for_each, item1: %d, item2: %d, item3: %d\n",
        *(heap_vector)->at(heap_vector, 0),
        *(heap_vector)->at(heap_vector, 1),
        *(heap_vector)->at(heap_vector, 2));
    (heap_vector)->pop_back(heap_vector);
    printf("Heap vector front / back: %d / %d\n",
        *(heap_vector)->front(heap_vector),
        *(heap_vector)->back(heap_vector));
    printf("Heap vector len / capacity: %d / %d\n",
        (heap_vector)->len(heap_vector),
        (heap_vector)->capacity(heap_vector));
    printf("Heap vector at index 1: %d\n", *(heap_vector)->at(heap_vector, 1));
    if ((heap_vector) != 0) { if ((heap_vector)->free(heap_vector) == 1) free(heap_vector);};
    if ((&stacked_vector) != 0) { if ((&stacked_vector)->free(&stacked_vector) == 1) free(&stacked_vector);};
    return 0;
}

canonical_original_code:
int main() {
    struct vector_int_t *heap_vector = new_vector_int_t(2);
    struct vector_int_t stacked_vector = stacked_vector_int_t(20);
    printf("Heap vector len / capacity: %d / %d\n",
        (heap_vector)->len(heap_vector),
        (heap_vector)->capacity(heap_vector));
    printf("Stacked vector len / capacity: %d / %d\n",
        (&stacked_vector)->len(&stacked_vector),
        (&stacked_vector)->capacity(&stacked_vector));
    (heap_vector)->push_back(heap_vector, 42);
    printf("Heap vector front / back: %d / %d\n",
        *(heap_vector)->front(heap_vector),
        *(heap_vector)->back(heap_vector));
    (heap_vector)->push_back(heap_vector, 21);
    printf("Heap vector front / back: %d / %d\n",
        *(heap_vector)->front(heap_vector),
        *(heap_vector)->back(heap_vector));
    printf("Heap vector len / capacity: %d / %d\n",
        (heap_vector)->len(heap_vector),
        (heap_vector)->capacity(heap_vector));
    (heap_vector)->push_back(heap_vector, 84);
    (heap_vector)->for_each(heap_vector, increment_of_ten, 0);
    printf("After call to for_each, item1: %d, item2: %d, item3: %d\n",
        *(heap_vector)->at(heap_vector, 0),
        *(heap_vector)->at(heap_vector, 1),
        *(heap_vector)->at(heap_vector, 2));
    (heap_vector)->pop_back(heap_vector);
    printf("Heap vector front / back: %d / %d\n",
        *(heap_vector)->front(heap_vector),
        *(heap_vector)->back(heap_vector));
    printf("Heap vector len / capacity: %d / %d\n",
        (heap_vector)->len(heap_vector),
        (heap_vector)->capacity(heap_vector));
    printf("Heap vector at index 1: %d\n", *(heap_vector)->at(heap_vector, 1));
    if ((heap_vector) != 0) { if ((heap_vector)->free(heap_vector) == 1) free(heap_vector);};
    if ((&stacked_vector) != 0) { if ((&stacked_vector)->free(&stacked_vector) == 1) free(&stacked_vector);};
    return 0;
}

variable_types: struct vector_int_t { int *(*front)(struct vector_int_t *self); int *(*back)(struct vector_int_t *self); int *(*at)(struct vector_int_t *self, unsigned int index); _Bool (*push_back)(struct vector_int_t *self, int item); void (*pop_back)(struct vector_int_t *self); _Bool (*is_empty)(struct vector_int_t *self); unsigned int (*len)(struct vector_int_t *self); unsigned int (*capacity)(struct vector_int_t *self); _Bool (*resize)(struct vector_int_t *self, unsigned int new_capacity); void (*clear)(struct vector_int_t *self); void (*for_each)(struct vector_int_t *self, void (*func)(int *item, void *data), void *data); _Bool (*free)(struct vector_int_t *self); int *stored_data; unsigned int size; unsigned int cap; }

return_type: int


decompiled_code:
__int64 __fastcall stack_int_t_top(__int64 a1)
{
return *(_QWORD *)(a1 + 48);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
return *(_QWORD *)(a1 + 48);
}

original_code: int *stack_int_t_top(struct stack_int_t *self) { return &self->top_item->item;}

variable_types: struct stack_int_t { int *(*top)(struct stack_int_t *self); void (*pop)(struct stack_int_t *self); _Bool (*push)(struct stack_int_t *self, int item); _Bool (*is_empty)(struct stack_int_t *self); unsigned int (*len)(struct stack_int_t *self); _Bool (*free)(struct stack_int_t *self); struct item_stack_int_t { int item; struct item_stack_int_t *next; } *top_item; int size; } *

user_defined_types: struct stack_int_t { int *(*top)(struct stack_int_t *self); void (*pop)(struct stack_int_t *self); _Bool (*push)(struct stack_int_t *self, int item); _Bool (*is_empty)(struct stack_int_t *self); unsigned int (*len)(struct stack_int_t *self); _Bool (*free)(struct stack_int_t *self); struct item_stack_int_t *top_item; int size; }


decompiled_code:
bool __fastcall stack_int_t_is_empty(__int64 a1)
{
return *(_DWORD *)(a1 + 56) == 0;
}

canonical_decompiled_code:
bool __fastcall func8(__int64 a1)
{
return *(_DWORD *)(a1 + 56) == 0;
}

original_code: _Bool stack_int_t_is_empty(struct stack_int_t *self) { return self->size == 0;}

user_defined_types: struct item_stack_int_t { int item; struct item_stack_int_t *next; }


decompiled_code:
__int64 __fastcall stack_int_t_len(__int64 a1)
{
return *(unsigned int *)(a1 + 56);
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
return *(unsigned int *)(a1 + 56);
}

original_code: unsigned int stack_int_t_len(struct stack_int_t *self) { return self->size;}


original_code: _Bool stack_int_t_push(struct stack_int_t *self, int item) { _Bool return_value = 0; struct item_stack_int_t *tmp = malloc(sizeof(item_stack_int_t)); if (tmp) { tmp->item = item; tmp->next = self->top_item; self->top_item = tmp; self->size += 1; return_value = 1; } return return_value;}

variable_types: struct item_stack_int_t { int item; struct item_stack_int_t *next; } *


original_code: void stack_int_t_pop(struct stack_int_t *self) { if (self->top_item) { struct item_stack_int_t *tmp = self->top_item; self->top_item = self->top_item->next; free(tmp); self->size -= 1; }}


decompiled_code:
void *new_stack_int_t()
{
void *v0; // rax
void *v1; // r8

v0 = malloc(0x40uLL);
v1 = v0;
if ( v0 )
stack_int_t_initialize((__int64)v0, 1);
return v1;
}

canonical_decompiled_code:
void *func12()
{
void *v0; // rax
void *v1; // r8

v0 = malloc(0x40uLL);
v1 = v0;
if ( v0 )
stack_int_t_initialize((__int64)v0, 1);
return v1;
}

original_code: stack_int_t *new_stack_int_t() { stack_int_t *self = malloc(sizeof(stack_int_t)); if (self) { stack_int_t_initialize(self, 1); } return self;}

canonical_original_code: struct stack_int_t *new_stack_int_t() { struct stack_int_t *self = malloc(sizeof(stack_int_t)); if (self) { stack_int_t_initialize(self, 1); } return self;}

return_type: struct stack_int_t { int *(*top)(struct stack_int_t *self); void (*pop)(struct stack_int_t *self); _Bool (*push)(struct stack_int_t *self, int item); _Bool (*is_empty)(struct stack_int_t *self); unsigned int (*len)(struct stack_int_t *self); _Bool (*free)(struct stack_int_t *self); struct item_stack_int_t { int item; struct item_stack_int_t *next; } *top_item; int size; } *


decompiled_code:
void __fastcall stack_int_t_delete_in(__int64 a1)
{
_QWORD *i; // rbx
void *v3; // rdi

for ( i = *(_QWORD **)(a1 + 48); i; *(_QWORD *)(a1 + 48) = i )
{
v3 = i;
i = (_QWORD *)i[1];
free(v3);
}
}

original_code: void stack_int_t_delete_in(struct stack_int_t *self) { struct item_stack_int_t *tmp; while (self->top_item) { tmp = self->top_item->next; free(self->top_item); self->top_item = tmp; }}


decompiled_code:
__int64 __fastcall stack_int_t_delete_heap(__int64 a1)
{
stack_int_t_delete_in(a1);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1)
{
func14(a1);
return 1LL;
}

original_code: _Bool stack_int_t_delete_heap(struct stack_int_t *self) { stack_int_t_delete_in(self); return 1;}


decompiled_code:
__int64 __fastcall stack_int_t_delete_stacked(__int64 a1)
{
stack_int_t_delete_in(a1);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 a1)
{
func14(a1);
return 0LL;
}

original_code: _Bool stack_int_t_delete_stacked(struct stack_int_t *self) { stack_int_t_delete_in(self); return 0;}


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned __int8 (__fastcall **v3)(_QWORD); // rbp
unsigned int v4; // eax
unsigned int v5; // eax
unsigned int *v6; // rax
unsigned int v7; // eax
_DWORD *v8; // rax
unsigned int *v9; // rax
unsigned int v10; // eax
unsigned int v11; // eax
unsigned int *v12; // rax
__int64 v14[4]; // [rsp+0h] [rbp-48h] BYREF
__int64 (__fastcall *v15)(__int64 *); // [rsp+20h] [rbp-28h]
unsigned __int8 (__fastcall *v16)(__int64 *); // [rsp+28h] [rbp-20h]

v3 = (unsigned __int8 (__fastcall **)(_QWORD))new_stack_int_t(argc, argv, envp);
stacked_stack_int_t(v14);
v4 = ((__int64 (__fastcall *)(_QWORD))v3[4])(v3);
printf("Heap Stack size: %d\n", v4);
((void (__fastcall *)(unsigned __int8 (__fastcall **)(_QWORD), __int64))v3[2])(v3, 21LL);
((void (__fastcall *)(unsigned __int8 (__fastcall **)(_QWORD), __int64))v3[2])(v3, 42LL);
((void (__fastcall *)(unsigned __int8 (__fastcall **)(_QWORD), __int64))v3[2])(v3, 84LL);
v5 = ((__int64 (__fastcall *)(_QWORD))v3[4])(v3);
printf("Heap Stack size after a push: %d\n", v5);
v6 = (unsigned int *)((__int64 (__fastcall *)(_QWORD))*v3)(v3);
printf("Heap Stack top value after a push: %d\n", *v6);
v3[1](v3);
v7 = ((__int64 (__fastcall *)(_QWORD))v3[4])(v3);
printf("Heap Stack size after a pop: %d\n", v7);
v8 = (_DWORD *)((__int64 (__fastcall *)(_QWORD))*v3)(v3);
*v8 += 10;
v9 = (unsigned int *)((__int64 (__fastcall *)(_QWORD))*v3)(v3);
printf("Heap Stack top after a top update: %d\n", *v9);
v10 = v15(v14);
printf("Stacked Stack size: %d\n", v10);
((void (__fastcall *)(__int64 *, __int64))v14[2])(v14, 21LL);
v11 = v15(v14);
printf("Stacked Stack size after a push: %d\n", v11);
v12 = (unsigned int *)((__int64 (__fastcall *)(__int64 *))v14[0])(v14);
printf("Stacked Stack top value after a push: %d\n", *v12);
if ( v3[5](v3) )
free(v3);
if ( v16(v14) )
free(v14);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned __int8 (__fastcall **v3)(_QWORD); // rbp
unsigned int v4; // eax
unsigned int v5; // eax
unsigned int *v6; // rax
unsigned int v7; // eax
_DWORD *v8; // rax
unsigned int *v9; // rax
unsigned int v10; // eax
unsigned int v11; // eax
unsigned int *v12; // rax
__int64 v14[4]; // [rsp+0h] [rbp-48h] BYREF
__int64 (__fastcall *v15)(__int64 *); // [rsp+20h] [rbp-28h]
unsigned __int8 (__fastcall *v16)(__int64 *); // [rsp+28h] [rbp-20h]

v3 = (unsigned __int8 (__fastcall **)(_QWORD))func12(argc, argv, envp);
func13(v14);
v4 = ((__int64 (__fastcall *)(_QWORD))v3[4])(v3);
printf("Heap Stack size: %d\n", v4);
((void (__fastcall *)(unsigned __int8 (__fastcall **)(_QWORD), __int64))v3[2])(v3, 21LL);
((void (__fastcall *)(unsigned __int8 (__fastcall **)(_QWORD), __int64))v3[2])(v3, 42LL);
((void (__fastcall *)(unsigned __int8 (__fastcall **)(_QWORD), __int64))v3[2])(v3, 84LL);
v5 = ((__int64 (__fastcall *)(_QWORD))v3[4])(v3);
printf("Heap Stack size after a push: %d\n", v5);
v6 = (unsigned int *)((__int64 (__fastcall *)(_QWORD))*v3)(v3);
printf("Heap Stack top value after a push: %d\n", *v6);
v3[1](v3);
v7 = ((__int64 (__fastcall *)(_QWORD))v3[4])(v3);
printf("Heap Stack size after a pop: %d\n", v7);
v8 = (_DWORD *)((__int64 (__fastcall *)(_QWORD))*v3)(v3);
*v8 += 10;
v9 = (unsigned int *)((__int64 (__fastcall *)(_QWORD))*v3)(v3);
printf("Heap Stack top after a top update: %d\n", *v9);
v10 = v15(v14);
printf("Stacked Stack size: %d\n", v10);
((void (__fastcall *)(__int64 *, __int64))v14[2])(v14, 21LL);
v11 = v15(v14);
printf("Stacked Stack size after a push: %d\n", v11);
v12 = (unsigned int *)((__int64 (__fastcall *)(__int64 *))v14[0])(v14);
printf("Stacked Stack top value after a push: %d\n", *v12);
if ( v3[5](v3) )
free(v3);
if ( v16(v14) )
free(v14);
return 0;
}

original_code:
int main() {
    stack_int_t *heap_stack = new_stack_int_t();
    stack_int_t stacked_stack = stacked_stack_int_t();
    printf("Heap Stack size: %d\n",(heap_stack)->len(heap_stack));
    (heap_stack)->push(heap_stack, 21);
    (heap_stack)->push(heap_stack, 42);
    (heap_stack)->push(heap_stack, 84);
    printf("Heap Stack size after a push: %d\n", (heap_stack)->len(heap_stack));
    printf("Heap Stack top value after a push: %d\n", *(heap_stack)->top(heap_stack));
    (heap_stack)->pop(heap_stack);
    printf("Heap Stack size after a pop: %d\n", (heap_stack)->len(heap_stack));
    *((heap_stack)->top(heap_stack)) += 10;
    printf("Heap Stack top after a top update: %d\n", *(heap_stack)->top(heap_stack));
    printf("Stacked Stack size: %d\n", (&stacked_stack)->len(&stacked_stack));
    (&stacked_stack)->push(&stacked_stack, 21);
    printf("Stacked Stack size after a push: %d\n", (&stacked_stack)->len(&stacked_stack));
    printf("Stacked Stack top value after a push: %d\n", *(&stacked_stack)->top(&stacked_stack));
    if ((heap_stack) != 0) { if ((heap_stack)->free(heap_stack) == 1) free(heap_stack);};
    if ((&stacked_stack) != 0) { if ((&stacked_stack)->free(&stacked_stack) == 1) free(&stacked_stack);};
    return 0;
}

canonical_original_code:
int main() {
    struct stack_int_t *heap_stack = new_stack_int_t();
    struct stack_int_t stacked_stack = stacked_stack_int_t();
    printf("Heap Stack size: %d\n",(heap_stack)->len(heap_stack));
    (heap_stack)->push(heap_stack, 21);
    (heap_stack)->push(heap_stack, 42);
    (heap_stack)->push(heap_stack, 84);
    printf("Heap Stack size after a push: %d\n", (heap_stack)->len(heap_stack));
    printf("Heap Stack top value after a push: %d\n", *(heap_stack)->top(heap_stack));
    (heap_stack)->pop(heap_stack);
    printf("Heap Stack size after a pop: %d\n", (heap_stack)->len(heap_stack));
    *((heap_stack)->top(heap_stack)) += 10;
    printf("Heap Stack top after a top update: %d\n", *(heap_stack)->top(heap_stack));
    printf("Stacked Stack size: %d\n", (&stacked_stack)->len(&stacked_stack));
    (&stacked_stack)->push(&stacked_stack, 21);
    printf("Stacked Stack size after a push: %d\n", (&stacked_stack)->len(&stacked_stack));
    printf("Stacked Stack top value after a push: %d\n", *(&stacked_stack)->top(&stacked_stack));
    if ((heap_stack) != 0) { if ((heap_stack)->free(heap_stack) == 1) free(heap_stack);};
    if ((&stacked_stack) != 0) { if ((&stacked_stack)->free(&stacked_stack) == 1) free(&stacked_stack);};
    return 0;
}

variable_types: struct stack_int_t { int *(*top)(struct stack_int_t *self); void (*pop)(struct stack_int_t *self); _Bool (*push)(struct stack_int_t *self, int item); _Bool (*is_empty)(struct stack_int_t *self); unsigned int (*len)(struct stack_int_t *self); _Bool (*free)(struct stack_int_t *self); struct item_stack_int_t { int item; struct item_stack_int_t *next; } *top_item; int size; }


decompiled_code:
__int64 __fastcall queue_int_t_front(__int64 a1)
{
return *(_QWORD *)(a1 + 56);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
return *(_QWORD *)(a1 + 56);
}

original_code: int *queue_int_t_front(struct queue_int_t *self) { return &self->front_item->item;}

variable_types: struct queue_int_t { int *(*front)(struct queue_int_t *self); int *(*back)(struct queue_int_t *self); void (*pop)(struct queue_int_t *self); _Bool (*push)(struct queue_int_t *self, int item); _Bool (*is_empty)(struct queue_int_t *self); unsigned int (*len)(struct queue_int_t *self); _Bool (*free)(struct queue_int_t *self); struct item_queue_int_t { int item; struct item_queue_int_t *next; } *front_item; struct item_queue_int_t *back_item; unsigned int size; } *

user_defined_types: struct queue_int_t { int *(*front)(struct queue_int_t *self); int *(*back)(struct queue_int_t *self); void (*pop)(struct queue_int_t *self); _Bool (*push)(struct queue_int_t *self, int item); _Bool (*is_empty)(struct queue_int_t *self); unsigned int (*len)(struct queue_int_t *self); _Bool (*free)(struct queue_int_t *self); struct item_queue_int_t *front_item; struct item_queue_int_t *back_item; unsigned int size; }


decompiled_code:
__int64 __fastcall queue_int_t_back(__int64 a1)
{
return *(_QWORD *)(a1 + 64);
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
return *(_QWORD *)(a1 + 64);
}

original_code: int *queue_int_t_back(struct queue_int_t *self) { return &self->back_item->item;}

user_defined_types: struct item_queue_int_t { int item; struct item_queue_int_t *next; }


decompiled_code:
bool __fastcall queue_int_t_is_empty(__int64 a1)
{
return *(_DWORD *)(a1 + 72) == 0;
}

canonical_decompiled_code:
bool __fastcall func9(__int64 a1)
{
return *(_DWORD *)(a1 + 72) == 0;
}

original_code: _Bool queue_int_t_is_empty(struct queue_int_t *self) { return self->size == 0;}


decompiled_code:
__int64 __fastcall queue_int_t_len(__int64 a1)
{
return *(unsigned int *)(a1 + 72);
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
return *(unsigned int *)(a1 + 72);
}

original_code: unsigned int queue_int_t_len(struct queue_int_t *self) { return self->size;}


original_code: _Bool queue_int_t_push(struct queue_int_t *self, int item) { _Bool return_value = 0; struct item_queue_int_t *tmp = malloc(sizeof(item_queue_int_t)); if (tmp) { tmp->item = item; if (!self->front_item && !self->back_item) { self->back_item->next = tmp; } self->back_item->next = tmp; self->back_item = tmp; self->size += 1; return_value = 1; } return return_value;}

variable_types: struct item_queue_int_t { int item; struct item_queue_int_t *next; } *


original_code: void queue_int_t_pop(struct queue_int_t *self) { if (self->front_item) { struct item_queue_int_t *tmp = self->front_item; self->front_item = tmp->next; free(tmp); self->size -= 1; }}


decompiled_code:
void *new_queue_int_t()
{
void *v0; // rax
void *v1; // r8

v0 = malloc(0x50uLL);
v1 = v0;
if ( v0 )
queue_int_t_initialize((__int64)v0, 1);
return v1;
}

canonical_decompiled_code:
void *func13()
{
void *v0; // rax
void *v1; // r8

v0 = malloc(0x50uLL);
v1 = v0;
if ( v0 )
queue_int_t_initialize((__int64)v0, 1);
return v1;
}

original_code: queue_int_t *new_queue_int_t() { queue_int_t *self = malloc(sizeof(queue_int_t)); if (self != 0) { queue_int_t_initialize(self, 1); } return self;}

canonical_original_code: struct queue_int_t *new_queue_int_t() { struct queue_int_t *self = malloc(sizeof(queue_int_t)); if (self != 0) { queue_int_t_initialize(self, 1); } return self;}

return_type: struct queue_int_t { int *(*front)(struct queue_int_t *self); int *(*back)(struct queue_int_t *self); void (*pop)(struct queue_int_t *self); _Bool (*push)(struct queue_int_t *self, int item); _Bool (*is_empty)(struct queue_int_t *self); unsigned int (*len)(struct queue_int_t *self); _Bool (*free)(struct queue_int_t *self); struct item_queue_int_t { int item; struct item_queue_int_t *next; } *front_item; struct item_queue_int_t *back_item; unsigned int size; } *


decompiled_code:
void __fastcall queue_int_t_delete_in(__int64 a1)
{
_QWORD *i; // rbx
void *v3; // rdi

for ( i = *(_QWORD **)(a1 + 56); i; *(_QWORD *)(a1 + 56) = i )
{
v3 = i;
i = (_QWORD *)i[1];
free(v3);
}
}

original_code: void queue_int_t_delete_in(struct queue_int_t *self) { struct item_queue_int_t *tmp; while (self->front_item) { tmp = self->front_item->next; free(self->front_item); self->front_item = tmp; }}


decompiled_code:
__int64 __fastcall queue_int_t_delete_heap(__int64 a1)
{
queue_int_t_delete_in(a1);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 a1)
{
func15(a1);
return 1LL;
}

original_code: _Bool queue_int_t_delete_heap(struct queue_int_t *self) { queue_int_t_delete_in(self); return 1;}


decompiled_code:
__int64 __fastcall queue_int_t_delete_stacked(__int64 a1)
{
queue_int_t_delete_in(a1);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func17(__int64 a1)
{
func15(a1);
return 0LL;
}

original_code: _Bool queue_int_t_delete_stacked(struct queue_int_t *self) { queue_int_t_delete_in(self); return 0;}


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned __int8 (__fastcall **v3)(_QWORD); // rbp
_QWORD v5[11]; // [rsp+0h] [rbp-58h] BYREF

v3 = (unsigned __int8 (__fastcall **)(_QWORD))new_queue_int_t(argc, argv, envp);
stacked_queue_int_t(v5);
if ( v3 && v3[6](v3) )
free(v3);
if ( ((unsigned __int8 (__fastcall *)(_QWORD *))v5[6])(v5) )
free(v5);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned __int8 (__fastcall **v3)(_QWORD); // rbp
_QWORD v5[11]; // [rsp+0h] [rbp-58h] BYREF

v3 = (unsigned __int8 (__fastcall **)(_QWORD))func13(argc, argv, envp);
func14(v5);
if ( v3 && v3[6](v3) )
free(v3);
if ( ((unsigned __int8 (__fastcall *)(_QWORD *))v5[6])(v5) )
free(v5);
return 0;
}

original_code:
int main() {
    queue_int_t *heap_queue = new_queue_int_t();
    queue_int_t stacked_queue = stacked_queue_int_t();
    if ((heap_queue) != 0) { if ((heap_queue)->free(heap_queue) == 1) free(heap_queue);};
    if ((&stacked_queue) != 0) { if ((&stacked_queue)->free(&stacked_queue) == 1) free(&stacked_queue);};
    return 0;
}

canonical_original_code:
int main() {
    struct queue_int_t *heap_queue = new_queue_int_t();
    struct queue_int_t stacked_queue = stacked_queue_int_t();
    if ((heap_queue) != 0) { if ((heap_queue)->free(heap_queue) == 1) free(heap_queue);};
    if ((&stacked_queue) != 0) { if ((&stacked_queue)->free(&stacked_queue) == 1) free(&stacked_queue);};
    return 0;
}

variable_types: struct queue_int_t { int *(*front)(struct queue_int_t *self); int *(*back)(struct queue_int_t *self); void (*pop)(struct queue_int_t *self); _Bool (*push)(struct queue_int_t *self, int item); _Bool (*is_empty)(struct queue_int_t *self); unsigned int (*len)(struct queue_int_t *self); _Bool (*free)(struct queue_int_t *self); struct item_queue_int_t { int item; struct item_queue_int_t *next; } *front_item; struct item_queue_int_t *back_item; unsigned int size; }


decompiled_code:
__int64 pair_int_char_t_delete_heap()
{
return 1LL;
}

canonical_decompiled_code:
__int64 func7()
{
return 1LL;
}

original_code: _Bool pair_int_char_t_delete_heap( struct pair_int_char_t *self __attribute__((unused))) { return 1;}

canonical_original_code: _Bool pair_int_char_t_delete_heap(struct pair_int_char_t *self) { return 1;}

variable_types: struct pair_int_char_t { int first; char second; void (*swap)(struct pair_int_char_t *self, struct pair_int_char_t *other); _Bool (*free)(struct pair_int_char_t *self); } *


decompiled_code:
__int64 pair_int_char_t_delete_stacked()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func8()
{
return 0LL;
}

original_code: _Bool pair_int_char_t_delete_stacked( struct pair_int_char_t *self __attribute__((unused))) { return 0;}

canonical_original_code: _Bool pair_int_char_t_delete_stacked(struct pair_int_char_t *self) { return 0;}

user_defined_types: struct pair_int_char_t { int first; char second; void (*swap)(struct pair_int_char_t *self, struct pair_int_char_t *other); _Bool (*free)(struct pair_int_char_t *self); }


decompiled_code:
__int64 __fastcall pair_int_char_t_swap(int *a1, int *a2)
{
int v2; // edx
__int64 result; // rax

v2 = *a1;
result = *((unsigned __int8 *)a1 + 4);
*a1 = *a2;
*((_BYTE *)a1 + 4) = *((_BYTE *)a2 + 4);
*a2 = v2;
*((_BYTE *)a2 + 4) = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(int *a1, int *a2)
{
int v2; // edx
__int64 result; // rax

v2 = *a1;
result = *((unsigned __int8 *)a1 + 4);
*a1 = *a2;
*((_BYTE *)a1 + 4) = *((_BYTE *)a2 + 4);
*a2 = v2;
*((_BYTE *)a2 + 4) = result;
return result;
}

original_code: void pair_int_char_t_swap(struct pair_int_char_t *self, struct pair_int_char_t *other) { int tmp_first = self->first; char tmp_secomd = self->second; self->first = other->first; self->second = other->second; other->first = tmp_first; other->second = tmp_secomd;}

variable_types:
other
struct pair_int_char_t *


decompiled_code:
void *__fastcall new_pair_int_char_t(int a1, char a2)
{
void *v2; // rax
void *v3; // r8

v2 = malloc(0x18uLL);
v3 = v2;
if ( v2 )
pair_int_char_t_initialize((__int64)v2, a1, a2, 1);
return v3;
}

canonical_decompiled_code:
void *__fastcall func10(int a1, char a2)
{
void *v2; // rax
void *v3; // r8

v2 = malloc(0x18uLL);
v3 = v2;
if ( v2 )
pair_int_char_t_initialize((__int64)v2, a1, a2, 1);
return v3;
}

original_code: pair_int_char_t *new_pair_int_char_t(int first_item, char second_item) { pair_int_char_t *self = malloc(sizeof(pair_int_char_t)); if (self) { pair_int_char_t_initialize(self, first_item, second_item, 1); } return self;}

canonical_original_code: struct pair_int_char_t *new_pair_int_char_t(int first_item, char second_item) { struct pair_int_char_t *self = malloc(sizeof(pair_int_char_t)); if (self) { pair_int_char_t_initialize(self, first_item, second_item, 1); } return self;}

return_type: struct pair_int_char_t { int first; char second; void (*swap)(struct pair_int_char_t *self, struct pair_int_char_t *other); _Bool (*free)(struct pair_int_char_t *self); } *


decompiled_code:
void __fastcall set_vct_print_length(int a1)
{
vct_print_length = a1;
}

canonical_decompiled_code:
void __fastcall func1(int a1)
{
vct_print_length = a1;
}

original_code: void set_vct_print_length(int len) {vct_print_length = len;}

variable_types: len int


msg

repo: jerome-labidurie/avr

decompiled_code:
int msg(int a1, const char *a2, ...)
{
int result; // eax
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

if ( verbosity >= a1 )
{
va_start(arg, a2);
vfprintf(stderr, a2, arg);
result = fputc(10, stderr);
}
return result;
}

canonical_decompiled_code:
int func8(int a1, const char *a2, ...)
{
int result; // eax
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

if ( verbosity >= a1 )
{
va_start(arg, a2);
vfprintf(stderr, a2, arg);
result = fputc(10, stderr);
}
return result;
}

original_code:
void msg (int level, const char *message, ...)
{
   va_list args;
   if (verbosity >= level) {
      __builtin_va_start(args,message);
      vfprintf (stderr, message, args);
      fputc ('\n', stderr);
      __builtin_va_end(args);
   }
}

canonical_original_code:
void msg(int level, char *message, ...)
{
   __builtin_va_list args;
   if (verbosity >= level) {
      __builtin_va_start(args,message);
      vfprintf (stderr, message, args);
      fputc ('\n', stderr);
      __builtin_va_end(args);
   }
}

variable_types: level int

variable_types:
message
char *


repo: jessealama/ladr

decompiled_code:
__int64 get_hashtab()
{
__int64 result; // rax

result = get_cmem(2LL);
++Hashtab_gets;
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 result; // rax

result = get_cmem(2LL);
++Hashtab_gets;
return result;
}

original_code:
static
Hashtab get_hashtab(void)
{
  Hashtab p = get_cmem(((sizeof(struct hashtab))%(sizeof(void *)) == 0 ? (sizeof(struct hashtab))/(sizeof(void *)) : (sizeof(struct hashtab))/(sizeof(void *)) + 1));
  Hashtab_gets++;
  return(p);
}

canonical_original_code:
static struct hashtab *get_hashtab()
{
  struct hashtab *p = get_cmem(((sizeof(struct hashtab))%(sizeof(void *)) == 0 ? (sizeof(struct hashtab))/(sizeof(void *)) : (sizeof(struct hashtab))/(sizeof(void *)) + 1));
  Hashtab_gets++;
  return(p);
}

variable_types: struct hashtab { int size; struct hashnode { void *v; struct hashnode *next; } **table; } *

user_defined_types: struct hashtab { int size; struct hashnode **table; }


decompiled_code:
__int64 get_hashnode()
{
__int64 result; // rax

result = get_cmem(2LL);
++Hashnode_gets;
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 result; // rax

result = get_cmem(2LL);
++Hashnode_gets;
return result;
}

original_code:
static
Hashnode get_hashnode(void)
{
  Hashnode p = get_cmem(((sizeof(struct hashnode))%(sizeof(void *)) == 0 ? (sizeof(struct hashnode))/(sizeof(void *)) : (sizeof(struct hashnode))/(sizeof(void *)) + 1));
  Hashnode_gets++;
  return(p);
}

canonical_original_code:
static struct hashnode *get_hashnode()
{
  struct hashnode *p = get_cmem(((sizeof(struct hashnode))%(sizeof(void *)) == 0 ? (sizeof(struct hashnode))/(sizeof(void *)) : (sizeof(struct hashnode))/(sizeof(void *)) + 1));
  Hashnode_gets++;
  return(p);
}

variable_types: struct hashnode { void *v; struct hashnode *next; } *


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

result = free_mem(a1, 2LL);
++Hashnode_frees;
return result;
}

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

result = free_mem(a1, 2LL);
++Hashnode_frees;
return result;
}

original_code:
static
void free_hashnode(Hashnode p)
{
  free_mem(p, ((sizeof(struct hashnode))%(sizeof(void *)) == 0 ? (sizeof(struct hashnode))/(sizeof(void *)) : (sizeof(struct hashnode))/(sizeof(void *)) + 1));
  Hashnode_frees++;
}

canonical_original_code:
static void free_hashnode(struct hashnode *p)
{
  free_mem(p, ((sizeof(struct hashnode))%(sizeof(void *)) == 0 ? (sizeof(struct hashnode))/(sizeof(void *)) : (sizeof(struct hashnode))/(sizeof(void *)) + 1));
  Hashnode_frees++;
}

user_defined_types: struct hashnode { void *v; struct hashnode *next; }


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

result = free_mem(a1, 2LL);
++Hashtab_frees;
return result;
}

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

result = free_mem(a1, 2LL);
++Hashtab_frees;
return result;
}

original_code:
static
void free_hashtab(Hashtab p)
{
  free_mem(p, ((sizeof(struct hashtab))%(sizeof(void *)) == 0 ? (sizeof(struct hashtab))/(sizeof(void *)) : (sizeof(struct hashtab))/(sizeof(void *)) + 1));
  Hashtab_frees++;
}

canonical_original_code:
static void free_hashtab(struct hashtab *p)
{
  free_mem(p, ((sizeof(struct hashtab))%(sizeof(void *)) == 0 ? (sizeof(struct hashtab))/(sizeof(void *)) : (sizeof(struct hashtab))/(sizeof(void *)) + 1));
  Hashtab_frees++;
}


decompiled_code:
int p_hash_mem()
{
return fprint_hash_mem(stdout, 1);
}

canonical_decompiled_code:
int func5()
{
return func4(stdout, 1);
}

original_code:
void p_hash_mem()
{
  fprint_hash_mem(stdout, TRUE);
}


decompiled_code:
__int64 __fastcall hash_init(int a1)
{
__int64 v1; // rax
__int64 v2; // r12

v1 = get_hashtab();
*(_DWORD *)v1 = a1;
v2 = v1;
*(_QWORD *)(v1 + 8) = calloc(a1, 8uLL);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func6(int a1)
{
__int64 v1; // rax
__int64 v2; // r12

v1 = func0();
*(_DWORD *)v1 = a1;
v2 = v1;
*(_QWORD *)(v1 + 8) = calloc(a1, 8uLL);
return v2;
}

original_code:
Hashtab hash_init(int size)
{
  Hashtab p = get_hashtab();
  p->size = size;
  p->table = calloc(size, sizeof(Hashnode));
  return p;
}

canonical_original_code:
struct hashtab *hash_init(int size)
{
  struct hashtab *p = get_hashtab();
  p->size = size;
  p->table = calloc(size, sizeof(Hashnode));
  return p;
}

variable_types: size int

return_type: struct hashtab { int size; struct hashnode { void *v; struct hashnode *next; } **table; } *


decompiled_code:
__int64 __fastcall hash_lookup(__int64 a1, unsigned int a2, __int64 a3, unsigned int (__fastcall *a4)(__int64, _QWORD))
{
_QWORD *v5; // rbx

v5 = *(_QWORD **)(*(_QWORD *)(a3 + 8) + 8LL * (a2 % *(_DWORD *)a3));
if ( !v5 )
return 0LL;
while ( !a4(a1, *v5) )
{
v5 = (_QWORD *)v5[1];
if ( !v5 )
return 0LL;
}
return *v5;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, unsigned int a2, __int64 a3, unsigned int (__fastcall *a4)(__int64, _QWORD))
{
_QWORD *v5; // rbx

v5 = *(_QWORD **)(*(_QWORD *)(a3 + 8) + 8LL * (a2 % *(_DWORD *)a3));
if ( !v5 )
return 0LL;
while ( !a4(a1, *v5) )
{
v5 = (_QWORD *)v5[1];
if ( !v5 )
return 0LL;
}
return *v5;
}

original_code:
void *hash_lookup(void *v, unsigned hashval, Hashtab h,
    BOOL (*id_func) (void *, void *))
{
  Hashnode p = h->table[hashval % h->size];
  while (p && !(*id_func)(v, p->v))
    p = p->next;
  return (p ? p->v : ((void *)0));
}

canonical_original_code:
void *hash_lookup(void *v, unsigned int hashval, struct hashtab *h, enum BOOL (*id_func)(void *, void *))
{
  struct hashnode *p = h->table[hashval % h->size];
  while (p && !(*id_func)(v, p->v))
    p = p->next;
  return (p ? p->v : ((void *)0));
}

variable_types:
v
void *

variable_types:
hashval
unsigned int

variable_types: enum BOOL { FALSE=0, TRUE=1 } (*)(void *, void *)

return_type: void *


decompiled_code:
__int64 __fastcall hash_delete(__int64 a1, unsigned int a2, __int64 a3, __int64 (__fastcall *a4)(__int64, _QWORD))
{
__int64 v5; // r15
_QWORD *v6; // rbp
_QWORD *v8; // r13
int i; // eax
bool v10; // zf
__int64 v11; // rax

v5 = (int)(a2 % *(_DWORD *)a3);
v6 = *(_QWORD **)(*(_QWORD *)(a3 + 8) + 8 * v5);
if ( !v6 )
{
fatal_error("hash_delete, object not found");
BUG();
}
v8 = 0LL;
for ( i = a4(a1, *v6); ; i = a4(a1, *v6) )
{
v10 = i == 0;
v11 = v6[1];
if ( !v10 )
break;
v8 = v6;
if ( !v11 )
hash_delete_cold();
v6 = (_QWORD *)v6[1];
}
if ( v8 )
v8[1] = v11;
else
*(_QWORD *)(*(_QWORD *)(a3 + 8) + 8 * v5) = v11;
return free_hashnode((__int64)v6);
}

original_code:
void hash_delete(void *v, unsigned hashval, Hashtab h,
   BOOL (*id_func) (void *, void *))
{
  int i = hashval % h->size;
  Hashnode p = h->table[i];
  Hashnode prev = ((void *)0);
  while (p && !(*id_func)(v, p->v)) {
    prev = p;
    p = p->next;
  }
  if (!p)
    fatal_error("hash_delete, object not found");
  if (prev)
    prev->next = p->next;
  else
    h->table[i] = p->next;
  free_hashnode(p);
}

canonical_original_code:
void hash_delete(void *v, unsigned int hashval, struct hashtab *h, enum BOOL (*id_func)(void *, void *))
{
  int i = hashval % h->size;
  struct hashnode *p = h->table[i];
  struct hashnode *prev = ((void *)0);
  while (p && !(*id_func)(v, p->v)) {
    prev = p;
    p = p->next;
  }
  if (!p)
    fatal_error("hash_delete, object not found");
  if (prev)
    prev->next = p->next;
  else
    h->table[i] = p->next;
  free_hashnode(p);
}

variable_types: i int


decompiled_code:
__int64 __fastcall hash_destroy(__int64 a1)
{
int v2; // eax
_QWORD *v3; // rdi
__int64 v4; // rbp
__int64 v5; // rbx
__int64 v6; // rdi

v2 = *(_DWORD *)a1;
v3 = *(_QWORD **)(a1 + 8);
if ( v2 > 0 )
{
v4 = 0LL;
do
{
v5 = v3[v4];
if ( v5 )
{
do
{
v6 = v5;
v5 = *(_QWORD *)(v5 + 8);
free_hashnode(v6);
}
while ( v5 );
v3 = *(_QWORD **)(a1 + 8);
}
++v4;
}
while ( *(_DWORD *)a1 > (int)v4 );
}
free(v3);
return free_hashtab(a1);
}

original_code:
void hash_destroy(Hashtab h)
{
  int i;
  for (i = 0; i < h->size; i++) {
    Hashnode p = h->table[i];
    while (p != ((void *)0)) {
      Hashnode p2 = p;
      p = p->next;
      free_hashnode(p2);
    }
  }
  free(h->table);
  free_hashtab(h);
}

canonical_original_code:
void hash_destroy(struct hashtab *h)
{
  int i;
  for (i = 0; i < h->size; i++) {
    struct hashnode *p = h->table[i];
    while (p != ((void *)0)) {
      struct hashnode *p2 = p;
      p = p->next;
      free_hashnode(p2);
    }
  }
  free(h->table);
  free_hashtab(h);
}


decompiled_code:
int __fastcall hash_info(unsigned int *a1)
{
__int64 v1; // rbx
__int64 v2; // rax
__int64 v3; // rdx

printf("\nHash info, size=%d\n", *a1);
if ( (int)*a1 > 0 )
{
v1 = 0LL;
do
{
v2 = *(_QWORD *)(*((_QWORD *)a1 + 1) + 8 * v1);
if ( v2 )
{
LODWORD(v3) = 0;
do
{
v2 = *(_QWORD *)(v2 + 8);
v3 = (unsigned int)(v3 + 1);
}
while ( v2 );
printf(" bucket %d has %d objects\n", (unsigned int)v1, v3);
}
++v1;
}
while ( (int)*a1 > (int)v1 );
}
return fflush(stdout);
}

canonical_decompiled_code:
int __fastcall func10(unsigned int *a1)
{
__int64 v1; // rbx
__int64 v2; // rax
__int64 v3; // rdx

printf("\nHash info, size=%d\n", *a1);
if ( (int)*a1 > 0 )
{
v1 = 0LL;
do
{
v2 = *(_QWORD *)(*((_QWORD *)a1 + 1) + 8 * v1);
if ( v2 )
{
LODWORD(v3) = 0;
do
{
v2 = *(_QWORD *)(v2 + 8);
v3 = (unsigned int)(v3 + 1);
}
while ( v2 );
printf(" bucket %d has %d objects\n", (unsigned int)v1, v3);
}
++v1;
}
while ( (int)*a1 > (int)v1 );
}
return fflush(stdout);
}

original_code:
void hash_info(Hashtab h)
{
  int i;
  printf("\nHash info, size=%d\n", h->size);
  for (i = 0; i < h->size; i++) {
    Hashnode p;
    int n = 0;
    for (p = h->table[i]; p; p = p->next)
      n++;
    if (n > 0)
      printf("    bucket %d has %d objects\n", i, n);
  }
  fflush(stdout);
}

canonical_original_code:
void hash_info(struct hashtab *h)
{
  int i;
  printf("\nHash info, size=%d\n", h->size);
  for (i = 0; i < h->size; i++) {
    struct hashnode *p;
    int n = 0;
    for (p = h->table[i]; p; p = p->next)
      n++;
    if (n > 0)
      printf("    bucket %d has %d objects\n", i, n);
  }
  fflush(stdout);
}

variable_types: n int


decompiled_code:
void *__fastcall free_estack(_QWORD *a1)
{
void *result; // rax

result = Estack_avail;
++Estack_frees;
++Estack_avails;
a1[801] = Estack_avail;
Estack_avail = a1;
return result;
}

canonical_decompiled_code:
void *__fastcall func0(_QWORD *a1)
{
void *result; // rax

result = Estack_avail;
++Estack_frees;
++Estack_avails;
a1[801] = Estack_avail;
Estack_avail = a1;
return result;
}

original_code:
static
void free_estack(Estack p)
{
  Estack_frees++;
  Estack_avails++;
  p->next = Estack_avail;
  Estack_avail = p;
}

canonical_original_code:
static void free_estack(struct estack *p)
{
  Estack_frees++;
  Estack_avails++;
  p->next = Estack_avail;
  Estack_avail = p;
}

variable_types: struct estack { void **p[400]; void *v[400]; int n; struct estack *next; } *


decompiled_code:
void *get_estack()
{
void *result; // rax
void *v1; // rdx

result = Estack_avail;
++Estack_gets;
if ( !Estack_avail )
return malloc(0x1910uLL);
v1 = (void *)*((_QWORD *)Estack_avail + 801);
--Estack_avails;
Estack_avail = v1;
return result;
}

canonical_decompiled_code:
void *func1()
{
void *result; // rax
void *v1; // rdx

result = Estack_avail;
++Estack_gets;
if ( !Estack_avail )
return malloc(0x1910uLL);
v1 = (void *)*((_QWORD *)Estack_avail + 801);
--Estack_avails;
Estack_avail = v1;
return result;
}

original_code:
static
Estack get_estack(void)
{
  Estack p;
  Estack_gets++;
  if (Estack_avail == ((void *)0))
    p = malloc(sizeof(struct estack));
  else {
    Estack_avails--;
    p = Estack_avail;
    Estack_avail = Estack_avail->next;
  }
  return(p);
}

canonical_original_code:
static struct estack *get_estack()
{
  struct estack *p;
  Estack_gets++;
  if (Estack_avail == ((void *)0))
    p = malloc(sizeof(struct estack));
  else {
    Estack_avails--;
    p = Estack_avail;
    Estack_avail = Estack_avail->next;
  }
  return(p);
}

return_type: struct estack { void **p[400]; void *v[400]; int n; struct estack *next; } *


decompiled_code:
__int64 p_estack_mem()
{
return fprint_estack_mem(stdout, 1);
}

canonical_decompiled_code:
__int64 func3()
{
return func2(stdout, 1);
}

original_code:
void p_estack_mem()
{
  fprint_estack_mem(stdout, 1);
}


decompiled_code:
void free_estack_memory()
{
void *v0; // rbx
int i; // ebp
void *v2; // rdi

v0 = Estack_avail;
for ( i = Estack_avails - 1; v0; --i )
{
v2 = v0;
v0 = (void *)*((_QWORD *)v0 + 801);
free(v2);
Estack_avails = i;
}
Estack_avail = 0LL;
}

canonical_decompiled_code:
void func4()
{
void *v0; // rbx
int i; // ebp
void *v2; // rdi

v0 = Estack_avail;
for ( i = Estack_avails - 1; v0; --i )
{
v2 = v0;
v0 = (void *)*((_QWORD *)v0 + 801);
free(v2);
Estack_avails = i;
}
Estack_avail = 0LL;
}

original_code:
void free_estack_memory(void)
{
  Estack a = Estack_avail;
  while (a) {
    Estack b = a;
    a = a->next;
    free(b);
    Estack_avails--;
  }
  Estack_avail = ((void *)0);
}

canonical_original_code:
void free_estack_memory()
{
  struct estack *a = Estack_avail;
  while (a) {
    struct estack *b = a;
    a = a->next;
    free(b);
    Estack_avails--;
  }
  Estack_avail = ((void *)0);
}

user_defined_types: struct estack { void **p[400]; void *v[400]; int n; struct estack *next; }


decompiled_code:
__int64 estack_bytes()
{
return (unsigned int)(6416 * (Estack_gets + Estack_avails - Estack_frees));
}

canonical_decompiled_code:
__int64 func5()
{
return (unsigned int)(6416 * (Estack_gets + Estack_avails - Estack_frees));
}

original_code:
int estack_bytes(void)
{
  return ((Estack_gets - Estack_frees) + Estack_avails) * sizeof(struct estack);
}

canonical_original_code:
int estack_bytes()
{
  return ((Estack_gets - Estack_frees) + Estack_avails) * sizeof(struct estack);
}


original_code:
void restore_from_stack(Estack stack)
{
  while (stack != ((void *)0)) {
    int i;
    Estack s = stack;
    stack = stack->next;
    for (i = s->n-1; i >= 0; i--) {
      *(s->p[i]) = s->v[i];
    }
    free_estack(s);
  }
}

canonical_original_code:
void restore_from_stack(struct estack *stack)
{
  while (stack != ((void *)0)) {
    int i;
    struct estack *s = stack;
    stack = stack->next;
    for (i = s->n-1; i >= 0; i--) {
      *(s->p[i]) = s->v[i];
    }
    free_estack(s);
  }
}


decompiled_code:
void *__fastcall zap_estack(_QWORD *a1)
{
void *result; // rax

for ( ; a1; result = free_estack(a1) )
;
return result;
}

canonical_decompiled_code:
void *__fastcall func7(_QWORD *a1)
{
void *result; // rax

for ( ; a1; result = func0(a1) )
;
return result;
}

original_code:
void zap_estack(Estack stack)
{
  while (stack != ((void *)0)) {
    Estack s = stack;
    stack = stack->next;
    free_estack(s);
  }
}

canonical_original_code:
void zap_estack(struct estack *stack)
{
  while (stack != ((void *)0)) {
    struct estack *s = stack;
    stack = stack->next;
    free_estack(s);
  }
}


decompiled_code:
__int64 get_avl_node()
{
__int64 result; // rax

result = get_mem(4LL);
++Avl_node_gets;
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 result; // rax

result = get_mem(4LL);
++Avl_node_gets;
return result;
}

original_code:
static
Avl_node get_avl_node(void)
{
  Avl_node p = get_mem(((sizeof(struct avl_node))%(sizeof(void *)) == 0 ? (sizeof(struct avl_node))/(sizeof(void *)) : (sizeof(struct avl_node))/(sizeof(void *)) + 1));
  Avl_node_gets++;
  return(p);
}

canonical_original_code:
static struct avl_node *get_avl_node()
{
  struct avl_node *p = get_mem(((sizeof(struct avl_node))%(sizeof(void *)) == 0 ? (sizeof(struct avl_node))/(sizeof(void *)) : (sizeof(struct avl_node))/(sizeof(void *)) + 1));
  Avl_node_gets++;
  return(p);
}

variable_types: struct avl_node { void *item; int size; int height; struct avl_node *left; } *


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

result = free_mem(a1, 4LL);
++Avl_node_frees;
return result;
}

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

result = free_mem(a1, 4LL);
++Avl_node_frees;
return result;
}

original_code:
static
void free_avl_node(Avl_node p)
{
  free_mem(p, ((sizeof(struct avl_node))%(sizeof(void *)) == 0 ? (sizeof(struct avl_node))/(sizeof(void *)) : (sizeof(struct avl_node))/(sizeof(void *)) + 1));
  Avl_node_frees++;
}

canonical_original_code:
static void free_avl_node(struct avl_node *p)
{
  free_mem(p, ((sizeof(struct avl_node))%(sizeof(void *)) == 0 ? (sizeof(struct avl_node))/(sizeof(void *)) : (sizeof(struct avl_node))/(sizeof(void *)) + 1));
  Avl_node_frees++;
}

user_defined_types: struct avl_node { void *item; int size; int height; struct avl_node *left; }


decompiled_code:
int p_avltree_mem()
{
return fprint_avltree_mem(stdout, 1);
}

canonical_decompiled_code:
int func3()
{
return func2(stdout, 1);
}

original_code:
void p_avltree_mem()
{
  fprint_avltree_mem(stdout, TRUE);
}


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

result = 0LL;
if ( a1 )
result = *(unsigned int *)(a1 + 12);
return result;
}

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

result = 0LL;
if ( a1 )
result = *(unsigned int *)(a1 + 12);
return result;
}

original_code:
int avl_height(Avl_node p)
{
  return (p == ((void *)0) ? 0 : p->height);
}

canonical_original_code:
int avl_height(struct avl_node *p)
{
  return (p == ((void *)0) ? 0 : p->height);
}


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

result = 0LL;
if ( a1 )
result = *(unsigned int *)(a1 + 8);
return result;
}

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

result = 0LL;
if ( a1 )
result = *(unsigned int *)(a1 + 8);
return result;
}

original_code:
int avl_size(Avl_node p)
{
  return (p == ((void *)0) ? 0 : p->size);
}

canonical_original_code:
int avl_size(struct avl_node *p)
{
  return (p == ((void *)0) ? 0 : p->size);
}


decompiled_code:
__int64 __fastcall set_height_and_size(__int64 a1)
{
__int64 v1; // rdx
int v2; // eax
__int64 v3; // rdx
__int64 v4; // r9
int v5; // ecx
bool v6; // cc
int v7; // esi
int v8; // eax
__int64 v9; // r8
int v10; // eax
int v11; // ecx
__int64 result; // rax
__int64 v13; // rdx

avl_height(*(_QWORD *)(a1 + 16));
v2 = avl_height(*(_QWORD *)(v1 + 24));
v6 = v5 <= v2;
v7 = v2 + 1;
v8 = v5 + 1;
if ( v6 )
v8 = v7;
*(_DWORD *)(v3 + 12) = v8;
avl_size(v4);
v10 = avl_size(v9);
result = (unsigned int)(v11 + v10 + 1);
*(_DWORD *)(v13 + 8) = result;
return result;
}

original_code:
static
void set_height_and_size(Avl_node p)
{
  p->height = ((avl_height(p->left)) > (avl_height(p->right)) ? (avl_height(p->left)) : (avl_height(p->right))) + 1;
  p->size = (avl_size(p->left) + avl_size(p->right)) + 1;
}

canonical_original_code:
static void set_height_and_size(struct avl_node *p)
{
  p->height = ((avl_height(p->left)) > (avl_height(p->right)) ? (avl_height(p->left)) : (avl_height(p->right))) + 1;
  p->size = (avl_size(p->left) + avl_size(p->right)) + 1;
}


original_code:
static
Avl_node rotate_left(Avl_node p)
{
  Avl_node b = p;
  Avl_node c = p->right->left;
  Avl_node d = p->right;
  if (Debug)
    printf("rotate left\n");
  b->right = c; set_height_and_size(b);
  d->left = b; set_height_and_size(d);
  return d;
}

canonical_original_code:
static struct avl_node *rotate_left(struct avl_node *p)
{
  struct avl_node *b = p;
  struct avl_node *c = p->right->left;
  struct avl_node *d = p->right;
  if (Debug)
    printf("rotate left\n");
  b->right = c; set_height_and_size(b);
  d->left = b; set_height_and_size(d);
  return d;
}

variable_types:
p
struct avl_node *

return_type: struct avl_node { void *item; int size; int height; struct avl_node *left; } *


original_code:
static
Avl_node rotate_right(Avl_node p)
{
  Avl_node b = p->left;
  Avl_node c = p->left->right;
  Avl_node d = p;
  if (Debug)
    printf("rotate right\n");
  d->left = c; set_height_and_size(d);
  b->right = d; set_height_and_size(b);
  return b;
}

canonical_original_code:
static struct avl_node *rotate_right(struct avl_node *p)
{
  struct avl_node *b = p->left;
  struct avl_node *c = p->left->right;
  struct avl_node *d = p;
  if (Debug)
    printf("rotate right\n");
  d->left = c; set_height_and_size(d);
  b->right = d; set_height_and_size(b);
  return b;
}


decompiled_code:
__int64 __fastcall avl_fix(__int64 a1)
{
__int64 v1; // r9
__int64 v2; // r10
int v3; // eax
__int64 v4; // r9
__int64 v5; // r10
int v6; // edx
__int64 v7; // r10
int v8; // eax
__int64 v9; // r10
int v10; // edx
__int64 result; // rax
__int64 v12; // r9
int v13; // eax
__int64 v14; // r9
int v15; // edx

if ( balance_ok_isra_0(*(_QWORD *)(a1 + 16), *(_QWORD *)(a1 + 24)) )
{
set_height_and_size(a1);
result = a1;
}
else
{
avl_height(v1);
v3 = avl_height(v2);
if ( v6 >= v3 )
{
avl_height(*(_QWORD *)(v4 + 24));
v13 = avl_height(*(_QWORD *)(v12 + 16));
if ( v15 > v13 )
*(_QWORD *)(a1 + 16) = rotate_left(v14);
result = rotate_right(a1);
}
else
{
avl_height(*(_QWORD *)(v5 + 16));
v8 = avl_height(*(_QWORD *)(v7 + 24));
if ( v10 > v8 )
*(_QWORD *)(a1 + 24) = rotate_right(v9);
result = rotate_left(a1);
}
}
return result;
}

original_code:
static
Avl_node avl_fix(Avl_node p)
{
  if (balance_ok(p)) {
    set_height_and_size(p);
    return p;
  }
  else {
    if (avl_height(p->left) < avl_height(p->right)) {
      if (avl_height(p->right->left) <= avl_height(p->right->right))
 return rotate_left(p);
      else {
 p->right = rotate_right(p->right);
 return rotate_left(p);
      }
    }
    else {
      if (avl_height(p->left->right) <= avl_height(p->left->left))
 return rotate_right(p);
      else {
 p->left = rotate_left(p->left);
 return rotate_right(p);
      }
    }
  }
}

canonical_original_code:
static struct avl_node *avl_fix(struct avl_node *p)
{
  if (balance_ok(p)) {
    set_height_and_size(p);
    return p;
  }
  else {
    if (avl_height(p->left) < avl_height(p->right)) {
      if (avl_height(p->right->left) <= avl_height(p->right->right))
 return rotate_left(p);
      else {
 p->right = rotate_right(p->right);
 return rotate_left(p);
      }
    }
    else {
      if (avl_height(p->left->right) <= avl_height(p->left->left))
 return rotate_right(p);
      else {
 p->left = rotate_left(p->left);
 return rotate_right(p);
      }
    }
  }
}


decompiled_code:
__int64 __fastcall avl_delete(_QWORD *a1, __int64 a2, __int64 (__fastcall *a3)(__int64, _QWORD))
{
int v4; // eax
__int64 v5; // rdi
__int64 result; // rax
__int64 v7; // r12
__int64 v8; // rbp
int v9; // eax
int v10; // edx
__int64 v11[4]; // [rsp+8h] [rbp-20h] BYREF

v11[0] = (__int64)a1;
if ( !a1 )
{
fatal_error("avl_delete, item not found");
return 0LL;
}
v4 = a3(a2, *a1);
if ( v4 == 2 )
{
v5 = v11[0];
*(_QWORD *)(v11[0] + 16) = avl_delete(*(_QWORD *)(v11[0] + 16), a2, a3);
return avl_fix(v5);
}
if ( v4 == 3 )
{
v5 = v11[0];
*(_QWORD *)(v11[0] + 24) = avl_delete(*(_QWORD *)(v11[0] + 24), a2, a3);
return avl_fix(v5);
}
if ( v4 != 1 )
{
fatal_error("avl_find: not comparable");
v5 = v11[0];
return avl_fix(v5);
}
v7 = *(_QWORD *)(v11[0] + 16);
v8 = *(_QWORD *)(v11[0] + 24);
free_avl_node(v11[0]);
v11[0] = 0LL;
result = v8 | v7;
if ( v8 | v7 )
{
avl_height(v7);
v9 = avl_height(v8);
if ( v10 >= v9 )
v7 = remove_and_return_largest_constprop_0(v7, v11);
else
v8 = remove_and_return_smallest_constprop_0(v8, v11);
v5 = v11[0];
*(_QWORD *)(v11[0] + 16) = v7;
*(_QWORD *)(v5 + 24) = v8;
return avl_fix(v5);
}
return result;
}

original_code:
Avl_node avl_delete(Avl_node p, void *item,
      Ordertype (*compare) (void *, void *))
{
  if (p == ((void *)0))
    fatal_error("avl_delete, item not found");
  else {
    Ordertype relation = (*compare)(item, p->item);
    if (relation == LESS_THAN)
      p->left = avl_delete(p->left, item, compare);
    else if (relation == GREATER_THAN)
      p->right = avl_delete(p->right, item, compare);
    else if (relation != SAME_AS)
      fatal_error("avl_find: not comparable");
    else {
      Avl_node left = p->left;
      Avl_node right = p->right;
      free_avl_node(p);
      p = ((void *)0);
      if (left == ((void *)0) && right == ((void *)0)) {
 return ((void *)0);
      }
      else if (avl_height(left) < avl_height(right))
 right = remove_and_return_smallest(right, &p);
      else
 left = remove_and_return_largest(left, &p);
      p->left = left;
      p->right = right;
    }
    p = avl_fix(p);
  }
  return p;
}

canonical_original_code:
struct avl_node *avl_delete(struct avl_node *p, void *item, enum Ordertype (*compare)(void *, void *))
{
  if (p == ((void *)0))
    fatal_error("avl_delete, item not found");
  else {
    enum Ordertype relation = (*compare)(item, p->item);
    if (relation == LESS_THAN)
      p->left = avl_delete(p->left, item, compare);
    else if (relation == GREATER_THAN)
      p->right = avl_delete(p->right, item, compare);
    else if (relation != SAME_AS)
      fatal_error("avl_find: not comparable");
    else {
      struct avl_node *left = p->left;
      struct avl_node *right = p->right;
      free_avl_node(p);
      p = ((void *)0);
      if (left == ((void *)0) && right == ((void *)0)) {
 return ((void *)0);
      }
      else if (avl_height(left) < avl_height(right))
 right = remove_and_return_smallest(right, &p);
      else
 left = remove_and_return_largest(left, &p);
      p->left = left;
      p->right = right;
    }
    p = avl_fix(p);
  }
  return p;
}

variable_types:
item
void *

variable_types: enum Ordertype { NOT_COMPARABLE=0, SAME_AS=1, LESS_THAN=2, GREATER_THAN=3, LESS_THAN_OR_SAME_AS=4, GREATER_THAN_OR_SAME_AS=5, NOT_LESS_THAN=6, NOT_GREATER_THAN=7 } (*)(void *, void *)


decompiled_code:
__int64 __fastcall avl_place(_QWORD *a1, __int64 a2, __int64 (__fastcall *a3)(__int64, _QWORD))
{
int v3; // er13
_QWORD *v5; // rbx
int v6; // eax
int v8; // eax

if ( !a1 )
return 1LL;
v3 = 0;
v5 = a1;
while ( 1 )
{
v6 = a3(a2, *v5);
if ( v6 != 2 )
break;
v5 = (_QWORD *)v5[2];
LABEL_9:
if ( !v5 )
return (unsigned int)(v3 + 1);
}
if ( v6 == 3 )
{
v8 = avl_size(v5[2]);
v5 = (_QWORD *)v5[3];
v3 += v8 + 1;
goto LABEL_9;
}
if ( v6 == 1 )
return v3 + (unsigned int)avl_size(v5[2]) + 1;
fatal_error("avl_place, not comparable");
return (unsigned int)(v3 + 0x7FFFFFFF);
}

canonical_decompiled_code:
__int64 __fastcall func14(_QWORD *a1, __int64 a2, __int64 (__fastcall *a3)(__int64, _QWORD))
{
int v3; // er13
_QWORD *v5; // rbx
int v6; // eax
int v8; // eax

if ( !a1 )
return 1LL;
v3 = 0;
v5 = a1;
while ( 1 )
{
v6 = a3(a2, *v5);
if ( v6 != 2 )
break;
v5 = (_QWORD *)v5[2];
LABEL_9:
if ( !v5 )
return (unsigned int)(v3 + 1);
}
if ( v6 == 3 )
{
v8 = func6(v5[2]);
v5 = (_QWORD *)v5[3];
v3 += v8 + 1;
goto LABEL_9;
}
if ( v6 == 1 )
return v3 + (unsigned int)func6(v5[2]) + 1;
fatal_error("avl_place, not comparable");
return (unsigned int)(v3 + 0x7FFFFFFF);
}

original_code:
int avl_place(Avl_node p, void *item,
       Ordertype (*compare) (void *, void *))
{
  if (p == ((void *)0))
    return 1;
  else {
    Ordertype relation = (*compare)(item, p->item);
    switch (relation) {
    case LESS_THAN:
      return avl_place(p->left, item, compare);
    case SAME_AS:
      return avl_size(p->left) + 1;
    case GREATER_THAN:
      return avl_size(p->left) + 1 + avl_place(p->right, item, compare);
    default: fatal_error("avl_place, not comparable");
    }
    return 0x7fffffff;
  }
}

canonical_original_code:
int avl_place(struct avl_node *p, void *item, enum Ordertype (*compare)(void *, void *))
{
  if (p == ((void *)0))
    return 1;
  else {
    enum Ordertype relation = (*compare)(item, p->item);
    switch (relation) {
    case LESS_THAN:
      return avl_place(p->left, item, compare);
    case SAME_AS:
      return avl_size(p->left) + 1;
    case GREATER_THAN:
      return avl_size(p->left) + 1 + avl_place(p->right, item, compare);
    default: fatal_error("avl_place, not comparable");
    }
    return 0x7fffffff;
  }
}

variable_types: enum Ordertype { NOT_COMPARABLE=0, SAME_AS=1, LESS_THAN=2, GREATER_THAN=3, LESS_THAN_OR_SAME_AS=4, GREATER_THAN_OR_SAME_AS=5, NOT_LESS_THAN=6, NOT_GREATER_THAN=7 }


decompiled_code:
double __fastcall avl_position(_QWORD *a1, __int64 a2, __int64 (__fastcall *a3)(__int64, _QWORD))
{
int v3; // eax
int v4; // edx

avl_place(a1, a2, a3);
v3 = avl_size((__int64)a1);
return (double)v4 / (double)v3;
}

canonical_decompiled_code:
double __fastcall func15(_QWORD *a1, __int64 a2, __int64 (__fastcall *a3)(__int64, _QWORD))
{
int v3; // eax
int v4; // edx

func14(a1, a2, a3);
v3 = func6((__int64)a1);
return (double)v4 / (double)v3;
}

original_code:
double avl_position(Avl_node p, void *item,
      Ordertype (*compare) (void *, void *))
{
  int place = avl_place(p, item, compare);
  return place / (double) avl_size(p);
}

canonical_original_code:
double avl_position(struct avl_node *p, void *item, enum Ordertype (*compare)(void *, void *))
{
  int place = avl_place(p, item, compare);
  return place / (double) avl_size(p);
}

variable_types: place int

return_type: double

user_defined_types: enum Ordertype { NOT_COMPARABLE=0, SAME_AS=1, LESS_THAN=2, GREATER_THAN=3, LESS_THAN_OR_SAME_AS=4, GREATER_THAN_OR_SAME_AS=5, NOT_LESS_THAN=6, NOT_GREATER_THAN=7 }


decompiled_code:
__int64 __fastcall avl_nth_item(__int64 a1, int a2)
{
bool v3; // r8
int v4; // eax
_QWORD *v5; // rdx
__int64 v6; // rcx
int v8; // eax

while ( 1 )
{
v3 = a2 <= 0;
while ( 1 )
{
if ( !a1 || v3 || *(_DWORD *)(a1 + 8) < a2 )
return 0LL;
v4 = avl_size(*(_QWORD *)(a1 + 16));
if ( v4 < a2 )
break;
a1 = v6;
}
v8 = v4 + 1;
if ( v8 == a2 )
break;
a1 = v5[3];
a2 -= v8;
}
return *v5;
}

original_code:
void *avl_nth_item(Avl_node p, int n)
{
  if (p == ((void *)0) || n < 1 || n > p->size)
    return ((void *)0);
  else if (n <= avl_size(p->left))
    return avl_nth_item(p->left, n);
  else if (n == avl_size(p->left)+1)
    return p->item;
  else
    return avl_nth_item(p->right, n - (avl_size(p->left)+1));
}

canonical_original_code:
void *avl_nth_item(struct avl_node *p, int n)
{
  if (p == ((void *)0) || n < 1 || n > p->size)
    return ((void *)0);
  else if (n <= avl_size(p->left))
    return avl_nth_item(p->left, n);
  else if (n == avl_size(p->left)+1)
    return p->item;
  else
    return avl_nth_item(p->right, n - (avl_size(p->left)+1));
}