igamf

decompiled_code:
__m64 __fastcall igamf(double a1, double a2)
{
__m64 result; // xmm0_8
float v4; // xmm1_4
__int64 v5; // xmm0_8
__int64 v6; // xmm4_8
float v7; // xmm2_4
float v8; // xmm0_4
float v9; // xmm1_4
double v10; // xmm0_8
float v11; // xmm1_4
float x; // [rsp+4h] [rbp-14h]
float v13; // [rsp+8h] [rbp-10h]
float v14; // [rsp+Ch] [rbp-Ch]

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

canonical_decompiled_code:
__m64 __fastcall func0(double a1, double a2)
{
__m64 result; // xmm0_8
float v4; // xmm1_4
__int64 v5; // xmm0_8
__int64 v6; // xmm4_8
float v7; // xmm2_4
float v8; // xmm0_4
float v9; // xmm1_4
double v10; // xmm0_8
float v11; // xmm1_4
float x; // [rsp+4h] [rbp-14h]
float v13; // [rsp+8h] [rbp-10h]
float v14; // [rsp+Ch] [rbp-Ch]

v13 = *(float *)&a1;
x = *(float *)&a2;
result = 0LL;
if ( *(float *)&a2 <= 0.0 )
return 0LL;
if ( *(float *)&a1 > 0.0 )
{
if ( *(float *)&a2 > 1.0 && *(float *)&a2 > *(float *)&a1 )
{
v10 = func1(a1, a2);
v11 = *(float *)&v10;
result = (__m64)(unsigned int)LC0;
*(float *)&result.m64_u64 = 1.0 - v11;
}
else
{
v14 = (float)(logf(*(float *)&a2) * v13) - *(float *)&a2;
v4 = lgamf(v13);
v5 = LODWORD(v14);
if ( COERCE_FLOAT(MAXLOGF ^ LC2) > (float)(v14 - v4) )
{
mtherr("igamf", 4LL);
result = 0LL;
}
else
{
*(float *)&v5 = expf(v14 - v4);
v6 = v5;
v7 = v13;
v8 = *(float *)&LC0;
v9 = *(float *)&LC0;
do
{
v7 = v7 + 1.0;
v8 = v8 * (float)(x / v7);
v9 = v9 + v8;
}
while ( (float)(v8 / v9) > MACHEPF );
*((_DWORD *)&result + 1) = HIDWORD(v6);
*(float *)&result.m64_u64 = (float)(*(float *)&v6 * v9) / v13;
}
}
}
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


repo: jeremybarnes/cephes

variable_types: xx float

variable_types: x float

variable_types: y float

variable_types: z float

variable_types: e int

return_type: float


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 result; // rax

v4 = 0;
do
result = a2(*(_QWORD *)(a1 + 96) + 4LL * v4++, 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 result; // rax

v4 = 0;
do
result = a2(*(_QWORD *)(a1 + 96) + 4LL * v4++, 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
__int64 result; // rax
void *v5; // r13
void *v6; // rdi

v2 = *(_DWORD *)(a1 + 108);
result = 0LL;
if ( v2 < a2 )
{
v5 = *(void **)(a1 + 96);
v6 = malloc(4LL * a2);
*(_QWORD *)(a1 + 96) = v6;
if ( v6 )
{
memcpy(v6, v5, 4LL * v2);
*(_DWORD *)(a1 + 108) = a2;
free(v5);
result = 1LL;
}
else
{
result = 0LL;
}
}
return result;
}

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

v2 = *(_DWORD *)(a1 + 108);
result = 0LL;
if ( v2 < a2 )
{
v5 = *(void **)(a1 + 96);
v6 = malloc(4LL * a2);
*(_QWORD *)(a1 + 96) = v6;
if ( v6 )
{
memcpy(v6, v5, 4LL * v2);
*(_DWORD *)(a1 + 108) = a2;
free(v5);
result = 1LL;
}
else
{
result = 0LL;
}
}
return result;
}

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)
{
int v3; // esi
__int64 result; // rax

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

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

v3 = *(_DWORD *)(a1 + 108);
if ( *(_DWORD *)(a1 + 104) != v3 || (result = func17(a1, 2 * v3), (_BYTE)result) )
{
*(_DWORD *)(*(_QWORD *)(a1 + 96) + 4LL * (unsigned int)(*(_DWORD *)(a1 + 104))++) = a2;
result = 1LL;
}
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 )
{
*(_QWORD *)(a1 + 88) = vector_int_t_delete_heap;
result = a3;
}
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 )
{
*(_QWORD *)(a1 + 88) = vector_int_t_delete_heap;
result = a3;
}
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); // rbx
unsigned int v4; // ebp
unsigned int v5; // eax
unsigned int v6; // ebp
unsigned int v7; // eax
unsigned int v8; // ebp
unsigned int *v9; // rax
unsigned int v10; // ebp
unsigned int *v11; // rax
unsigned int v12; // ebp
unsigned int v13; // eax
unsigned int v14; // er12
unsigned int v15; // ebp
unsigned int *v16; // rax
unsigned int v17; // ebp
unsigned int *v18; // rax
unsigned int v19; // ebp
unsigned int v20; // eax
unsigned int *v21; // rax
__m128i v23[3]; // [rsp+0h] [rbp-88h] BYREF
__int64 (__fastcall *v24)(__m128i *); // [rsp+30h] [rbp-58h]
__int64 (__fastcall *v25)(__m128i *); // [rsp+38h] [rbp-50h]
unsigned __int8 (__fastcall *v26)(__m128i *); // [rsp+58h] [rbp-30h]

v3 = (unsigned __int8 (__fastcall **)(_QWORD))new_vector_int_t(2);
stacked_vector_int_t(v23, 20);
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 = v25(v23);
v7 = v24(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), void (__fastcall *)(_DWORD *), _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 ( v26(v23) )
free(v23);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned __int8 (__fastcall **v3)(_QWORD); // rbx
unsigned int v4; // ebp
unsigned int v5; // eax
unsigned int v6; // ebp
unsigned int v7; // eax
unsigned int v8; // ebp
unsigned int *v9; // rax
unsigned int v10; // ebp
unsigned int *v11; // rax
unsigned int v12; // ebp
unsigned int v13; // eax
unsigned int v14; // er12
unsigned int v15; // ebp
unsigned int *v16; // rax
unsigned int v17; // ebp
unsigned int *v18; // rax
unsigned int v19; // ebp
unsigned int v20; // eax
unsigned int *v21; // rax
__m128i v23[3]; // [rsp+0h] [rbp-88h] BYREF
__int64 (__fastcall *v24)(__m128i *); // [rsp+30h] [rbp-58h]
__int64 (__fastcall *v25)(__m128i *); // [rsp+38h] [rbp-50h]
unsigned __int8 (__fastcall *v26)(__m128i *); // [rsp+58h] [rbp-30h]

v3 = (unsigned __int8 (__fastcall **)(_QWORD))func20(2);
stacked_vector_int_t(v23, 20);
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 = v25(v23);
v7 = v24(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), void (__fastcall *)(_DWORD *), _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 ( v26(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;}


decompiled_code:
__int64 __fastcall stack_int_t_push(__int64 a1, int a2)
{
_QWORD *v2; // rax

v2 = malloc(0x10uLL);
if ( !v2 )
return 0LL;
*(_DWORD *)v2 = a2;
v2[1] = *(_QWORD *)(a1 + 48);
*(_QWORD *)(a1 + 48) = v2;
++*(_DWORD *)(a1 + 56);
return 1LL;
}

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; // rbx

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; // rbx

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 func14(__int64 a1)
{
func13(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 func15(__int64 a1)
{
func13(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); // rbx
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
__m128i v14; // [rsp+0h] [rbp-48h] BYREF
void (__fastcall *v15)(__m128i *, __int64); // [rsp+10h] [rbp-38h]
__int64 (__fastcall *v16)(__m128i *); // [rsp+20h] [rbp-28h]
unsigned __int8 (__fastcall *v17)(__m128i *); // [rsp+28h] [rbp-20h]

v3 = (unsigned __int8 (__fastcall **)(_QWORD))new_stack_int_t();
stacked_stack_int_t(&v14);
v4 = ((__int64 (__fastcall *)(unsigned __int8 (__fastcall **)(_QWORD), const char **))v3[4])(v3, argv);
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 = v16(&v14);
printf("Stacked Stack size: %d\n", v10);
v15(&v14, 21LL);
v11 = v16(&v14);
printf("Stacked Stack size after a push: %d\n", v11);
v12 = (unsigned int *)((__int64 (__fastcall *)(__m128i *))v14.m128i_i64[0])(&v14);
printf("Stacked Stack top value after a push: %d\n", *v12);
if ( v3[5](v3) )
free(v3);
if ( v17(&v14) )
free(&v14);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned __int8 (__fastcall **v3)(_QWORD); // rbx
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
__m128i v14; // [rsp+0h] [rbp-48h] BYREF
void (__fastcall *v15)(__m128i *, __int64); // [rsp+10h] [rbp-38h]
__int64 (__fastcall *v16)(__m128i *); // [rsp+20h] [rbp-28h]
unsigned __int8 (__fastcall *v17)(__m128i *); // [rsp+28h] [rbp-20h]

v3 = (unsigned __int8 (__fastcall **)(_QWORD))func12();
stacked_stack_int_t(&v14);
v4 = ((__int64 (__fastcall *)(unsigned __int8 (__fastcall **)(_QWORD), const char **))v3[4])(v3, argv);
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 = v16(&v14);
printf("Stacked Stack size: %d\n", v10);
v15(&v14, 21LL);
v11 = v16(&v14);
printf("Stacked Stack size after a push: %d\n", v11);
v12 = (unsigned int *)((__int64 (__fastcall *)(__m128i *))v14.m128i_i64[0])(&v14);
printf("Stacked Stack top value after a push: %d\n", *v12);
if ( v3[5](v3) )
free(v3);
if ( v17(&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; // rbx

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; // rbx

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 func15(__int64 a1)
{
func14(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 func16(__int64 a1)
{
func14(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)
{
void *v3; // rbx
__m128i v5[3]; // [rsp+0h] [rbp-58h] BYREF
unsigned __int8 (__fastcall *v6)(__m128i *, const char **); // [rsp+30h] [rbp-28h]

v3 = new_queue_int_t();
stacked_queue_int_t(v5);
if ( v3 && (*((unsigned __int8 (__fastcall **)(void *, const char **))v3 + 6))(v3, argv) )
free(v3);
if ( v6(v5, argv) )
free(v5);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
void *v3; // rbx
__m128i v5[3]; // [rsp+0h] [rbp-58h] BYREF
unsigned __int8 (__fastcall *v6)(__m128i *, const char **); // [rsp+30h] [rbp-28h]

v3 = func13();
stacked_queue_int_t(v5);
if ( v3 && (*((unsigned __int8 (__fastcall **)(void *, const char **))v3 + 6))(v3, argv) )
free(v3);
if ( v6(v5, argv) )
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; // rbx

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; // rbx

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; // rbp

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

canonical_decompiled_code:
__int64 __fastcall func6(int a1)
{
__int64 v1; // rbp

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

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, unsigned int (__fastcall *a4)(__int64, _QWORD))
{
__int64 v6; // r15
_QWORD *v7; // rbx
_QWORD *v8; // r13

v6 = (int)(a2 % *(_DWORD *)a3);
v7 = *(_QWORD **)(*(_QWORD *)(a3 + 8) + 8 * v6);
v8 = 0LL;
if ( v7 )
{
while ( !a4(a1, *v7) )
{
v8 = v7;
if ( !v7[1] )
goto LABEL_6;
v7 = (_QWORD *)v7[1];
}
}
else
{
LABEL_6:
fatal_error("hash_delete, object not found");
v8 = v7;
v7 = 0LL;
}
if ( v8 )
v8[1] = v7[1];
else
*(_QWORD *)(*(_QWORD *)(a3 + 8) + 8 * v6) = v7[1];
return free_hashnode((__int64)v7);
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, unsigned int a2, __int64 a3, unsigned int (__fastcall *a4)(__int64, _QWORD))
{
__int64 v6; // r15
_QWORD *v7; // rbx
_QWORD *v8; // r13

v6 = (int)(a2 % *(_DWORD *)a3);
v7 = *(_QWORD **)(*(_QWORD *)(a3 + 8) + 8 * v6);
v8 = 0LL;
if ( v7 )
{
while ( !a4(a1, *v7) )
{
v8 = v7;
if ( !v7[1] )
goto LABEL_6;
v7 = (_QWORD *)v7[1];
}
}
else
{
LABEL_6:
fatal_error("hash_delete, object not found");
v8 = v7;
v7 = 0LL;
}
if ( v8 )
v8[1] = v7[1];
else
*(_QWORD *)(*(_QWORD *)(a3 + 8) + 8 * v6) = v7[1];
return func2((__int64)v7);
}

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


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
{
v3 = (unsigned int)(v3 + 1);
v2 = *(_QWORD *)(v2 + 8);
}
while ( v2 );
if ( (int)v3 > 0 )
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
{
v3 = (unsigned int)(v3 + 1);
v2 = *(_QWORD *)(v2 + 8);
}
while ( v2 );
if ( (int)v3 > 0 )
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

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

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

++Estack_frees;
++Estack_avails;
result = Estack_avail;
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

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

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

++Estack_gets;
result = Estack_avail;
if ( !Estack_avail )
return malloc(0x1910uLL);
--Estack_avails;
Estack_avail = (void *)*((_QWORD *)Estack_avail + 801);
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:
int p_estack_mem()
{
return fprint_estack_mem(stdout, 1);
}

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

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


decompiled_code:
void free_estack_memory()
{
void *i; // rbx
void *v1; // rdi

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

canonical_decompiled_code:
void func4()
{
void *i; // rbx
void *v1; // rdi

for ( i = Estack_avail; i; --Estack_avails )
{
v1 = i;
i = (void *)*((_QWORD *)i + 801);
free(v1);
}
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)
{
_QWORD *i; // rbx
_QWORD *v2; // rdi
void *result; // rax

for ( i = a1; i; result = free_estack(v2) )
{
v2 = i;
i = (_QWORD *)i[801];
}
return result;
}

canonical_decompiled_code:
void *__fastcall func7(_QWORD *a1)
{
_QWORD *i; // rbx
_QWORD *v2; // rdi
void *result; // rax

for ( i = a1; i; result = func0(v2) )
{
v2 = i;
i = (_QWORD *)i[801];
}
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 func1()
{
__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 func2(__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 func4()
{
return func3(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 func5(__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 func7(__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; // r13
int v2; // ebp
__int64 v3; // r12
int v4; // eax
int v5; // edx
bool v6; // cc
int v7; // eax
int v8; // ebp
__int64 result; // rax

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

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
__int64 v1; // r13
int v2; // ebp
__int64 v3; // r12
int v4; // eax
int v5; // edx
bool v6; // cc
int v7; // eax
int v8; // ebp
__int64 result; // rax

v1 = *(_QWORD *)(a1 + 16);
v2 = func5(v1);
v3 = *(_QWORD *)(a1 + 24);
v4 = func5(v3);
v5 = v4 + 1;
v6 = v2 <= v4;
v7 = v2 + 1;
if ( v6 )
v7 = v5;
*(_DWORD *)(a1 + 12) = v7;
v8 = func7(v1);
result = v8 + (unsigned int)func7(v3) + 1;
*(_DWORD *)(a1 + 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;
}


decompiled_code:
__int64 __fastcall rotate_left(__int64 a1)
{
__int64 v1; // rbp

v1 = *(_QWORD *)(a1 + 24);
*(_QWORD *)(a1 + 24) = *(_QWORD *)(v1 + 16);
set_height_and_size(a1);
*(_QWORD *)(v1 + 16) = a1;
set_height_and_size(v1);
return v1;
}

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; } *


decompiled_code:
__int64 __fastcall rotate_right(__int64 a1)
{
__int64 v1; // rbp

v1 = *(_QWORD *)(a1 + 16);
*(_QWORD *)(a1 + 16) = *(_QWORD *)(v1 + 24);
set_height_and_size(a1);
*(_QWORD *)(v1 + 24) = a1;
set_height_and_size(v1);
return v1;
}

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; // r12
int v2; // ebp
__int64 v3; // r13
int v4; // ebp
__int64 result; // rax
int v6; // ebp

if ( balance_ok(a1) )
{
set_height_and_size(a1);
result = a1;
}
else
{
v1 = *(_QWORD *)(a1 + 16);
v2 = avl_height(v1);
v3 = *(_QWORD *)(a1 + 24);
if ( v2 >= (int)avl_height(v3) )
{
v6 = avl_height(*(_QWORD *)(v1 + 24));
if ( v6 > (int)avl_height(*(_QWORD *)(v1 + 16)) )
*(_QWORD *)(a1 + 16) = rotate_left(v1);
result = rotate_right(a1);
}
else
{
v4 = avl_height(*(_QWORD *)(v3 + 16));
if ( v4 > (int)avl_height(*(_QWORD *)(v3 + 24)) )
*(_QWORD *)(a1 + 24) = rotate_right(v3);
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 result; // rax
__int64 v6; // rbp
__int64 v7; // rbx
int v8; // er12
__int64 v9; // rax
__int64 v10[4]; // [rsp+8h] [rbp-20h] BYREF

v10[0] = (__int64)a1;
if ( !a1 )
{
fatal_error("avl_delete, item not found");
return v10[0];
}
v4 = a3(a2, *a1);
if ( v4 == 2 )
{
*(_QWORD *)(v10[0] + 16) = avl_delete(*(_QWORD *)(v10[0] + 16), a2, a3);
goto LABEL_6;
}
if ( v4 == 3 )
{
*(_QWORD *)(v10[0] + 24) = avl_delete(*(_QWORD *)(v10[0] + 24), a2, a3);
goto LABEL_6;
}
if ( v4 != 1 )
{
fatal_error("avl_find: not comparable");
LABEL_6:
v10[0] = avl_fix(v10[0]);
return v10[0];
}
v6 = *(_QWORD *)(v10[0] + 16);
v7 = *(_QWORD *)(v10[0] + 24);
free_avl_node(v10[0]);
v10[0] = 0LL;
result = v7 | v6;
if ( v7 | v6 )
{
v8 = avl_height(v6);
if ( v8 >= (int)avl_height(v7) )
v6 = remove_and_return_largest(v6, v10);
else
v7 = remove_and_return_smallest(v7, v10);
v9 = v10[0];
*(_QWORD *)(v10[0] + 16) = v6;
*(_QWORD *)(v9 + 24) = v7;
goto LABEL_6;
}
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 v4; // eax
__int64 result; // rax
int v6; // er13

if ( !a1 )
return 1LL;
v4 = a3(a2, *a1);
switch ( v4 )
{
case 2:
return avl_place(a1[2], a2, a3);
case 3:
v6 = avl_size(a1[2]);
result = v6 + (unsigned int)avl_place(a1[3], a2, a3) + 1;
break;
case 1:
result = (unsigned int)avl_size(a1[2]) + 1;
break;
default:
fatal_error("avl_place, not comparable");
result = 0x7FFFFFFFLL;
break;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func18(_QWORD *a1, __int64 a2, __int64 (__fastcall *a3)(__int64, _QWORD))
{
int v4; // eax
__int64 result; // rax
int v6; // er13

if ( !a1 )
return 1LL;
v4 = a3(a2, *a1);
switch ( v4 )
{
case 2:
return func18(a1[2], a2, a3);
case 3:
v6 = func7(a1[2]);
result = v6 + (unsigned int)func18(a1[3], a2, a3) + 1;
break;
case 1:
result = (unsigned int)func7(a1[2]) + 1;
break;
default:
fatal_error("avl_place, not comparable");
result = 0x7FFFFFFFLL;
break;
}
return result;
}

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; // ebp

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

canonical_decompiled_code:
double __fastcall func19(_QWORD *a1, __int64 a2, __int64 (__fastcall *a3)(__int64, _QWORD))
{
int v3; // ebp

v3 = func18(a1, a2, a3);
return (double)v3 / (double)(int)func7((__int64)a1);
}

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)
{
__int64 v2; // r12
int v3; // eax
int v4; // eax
__int64 result; // rax

if ( !a1 )
return 0LL;
if ( a2 <= 0 )
return 0LL;
if ( *(_DWORD *)(a1 + 8) < a2 )
return 0LL;
v2 = *(_QWORD *)(a1 + 16);
v3 = avl_size(v2);
if ( v3 >= a2 )
return avl_nth_item(v2, (unsigned int)a2);
v4 = v3 + 1;
if ( v4 == a2 )
result = *(_QWORD *)a1;
else
result = avl_nth_item(*(_QWORD *)(a1 + 24), (unsigned int)(a2 - v4));
return result;
}

canonical_decompiled_code:
__int64 __fastcall func20(__int64 a1, int a2)
{
__int64 v2; // r12
int v3; // eax
int v4; // eax
__int64 result; // rax

if ( !a1 )
return 0LL;
if ( a2 <= 0 )
return 0LL;
if ( *(_DWORD *)(a1 + 8) < a2 )
return 0LL;
v2 = *(_QWORD *)(a1 + 16);
v3 = func7(v2);
if ( v3 >= a2 )
return func20(v2, (unsigned int)a2);
v4 = v3 + 1;
if ( v4 == a2 )
result = *(_QWORD *)a1;
else
result = func20(*(_QWORD *)(a1 + 24), (unsigned int)(a2 - v4));
return result;
}

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));
}


original_code:
void *avl_item_at_position(Avl_node p, double pos)
{
  if (p == ((void *)0) || pos <= 0.0 || pos > 1.0)
    return ((void *)0);
  else {
    int n = (int) ceil(pos * p->size);
    n = (n < 1 ? 1 : (n > p->size ? p->size : n));
    return avl_nth_item(p, n);
  }
}

canonical_original_code:
void *avl_item_at_position(struct avl_node *p, double pos)
{
  if (p == ((void *)0) || pos <= 0.0 || pos > 1.0)
    return ((void *)0);
  else {
    int n = (int) ceil(pos * p->size);
    n = (n < 1 ? 1 : (n > p->size ? p->size : n));
    return avl_nth_item(p, n);
  }
}

variable_types: pos double


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

if ( a1 )
{
avl_zap(*(_QWORD *)(a1 + 16));
avl_zap(*(_QWORD *)(a1 + 24));
result = free_avl_node(a1);
}
return result;
}

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

if ( a1 )
{
func22(*(_QWORD *)(a1 + 16));
func22(*(_QWORD *)(a1 + 24));
result = func2(a1);
}
return result;
}

original_code:
void avl_zap(Avl_node p)
{
  if (p != ((void *)0)) {
    avl_zap(p->left);
    avl_zap(p->right);
    free_avl_node(p);
  }
}

canonical_original_code:
void avl_zap(struct avl_node *p)
{
  if (p != ((void *)0)) {
    avl_zap(p->left);
    avl_zap(p->right);
    free_avl_node(p);
  }
}


decompiled_code:
void __fastcall avl_check(const void **a1, unsigned int (__fastcall *a2)(_QWORD, const void *))
{
_QWORD *v2; // rax
_QWORD *v3; // rax
int v4; // er12
int v5; // ebp
int v6; // eax
int v7; // edx
bool v8; // cc
int v9; // eax
int v10; // ebp

if ( a1 )
{
avl_check(a1[2]);
avl_check(a1[3]);
v2 = a1[2];
if ( v2 && a2(*v2, *a1) != 2 )
{
printf("error: left not smaller: %p\n", *a1);
fprintf(stderr, "error: left not smaller: %p\n", *a1);
}
v3 = a1[3];
if ( v3 && a2(*v3, *a1) != 3 )
{
printf("error: right not greater: %p\n", *a1);
fprintf(stderr, "error: right not greater: %p\n", *a1);
}
v4 = *((_DWORD *)a1 + 3);
v5 = avl_height((__int64)a1[2]);
v6 = avl_height((__int64)a1[3]);
v7 = v6 + 1;
v8 = v5 <= v6;
v9 = v5 + 1;
if ( v8 )
v9 = v7;
if ( v4 != v9 )
{
printf("error: height wrong: %p\n", *a1);
fprintf(stderr, "error: height wrong: %p\n", *a1);
}
v10 = avl_size((__int64)a1[2]);
if ( *((_DWORD *)a1 + 2) != v10 + (unsigned int)avl_size((__int64)a1[3]) + 1 )
{
printf("error: size wrong: %p\n", *a1);
fprintf(stderr, "error: size wrong: %p\n", *a1);
}
if ( !balance_ok((__int64)a1) )
{
printf("error: unbalanced: %p\n", *a1);
fprintf(stderr, "error: unbalanced: %p\n", *a1);
}
}
}

canonical_decompiled_code:
void __fastcall func23(const void **a1, unsigned int (__fastcall *a2)(_QWORD, const void *))
{
_QWORD *v2; // rax
_QWORD *v3; // rax
int v4; // er12
int v5; // ebp
int v6; // eax
int v7; // edx
bool v8; // cc
int v9; // eax
int v10; // ebp

if ( a1 )
{
func23(a1[2]);
func23(a1[3]);
v2 = a1[2];
if ( v2 && a2(*v2, *a1) != 2 )
{
printf("error: left not smaller: %p\n", *a1);
fprintf(stderr, "error: left not smaller: %p\n", *a1);
}
v3 = a1[3];
if ( v3 && a2(*v3, *a1) != 3 )
{
printf("error: right not greater: %p\n", *a1);
fprintf(stderr, "error: right not greater: %p\n", *a1);
}
v4 = *((_DWORD *)a1 + 3);
v5 = func5((__int64)a1[2]);
v6 = func5((__int64)a1[3]);
v7 = v6 + 1;
v8 = v5 <= v6;
v9 = v5 + 1;
if ( v8 )
v9 = v7;
if ( v4 != v9 )
{
printf("error: height wrong: %p\n", *a1);
fprintf(stderr, "error: height wrong: %p\n", *a1);
}
v10 = func7((__int64)a1[2]);
if ( *((_DWORD *)a1 + 2) != v10 + (unsigned int)func7((__int64)a1[3]) + 1 )
{
printf("error: size wrong: %p\n", *a1);
fprintf(stderr, "error: size wrong: %p\n", *a1);
}
if ( !func6((__int64)a1) )
{
printf("error: unbalanced: %p\n", *a1);
fprintf(stderr, "error: unbalanced: %p\n", *a1);
}
}
}

original_code:
void avl_check(Avl_node p,
        Ordertype (*compare) (void *, void *))
{
  if (p != ((void *)0)) {
    avl_check(p->left, compare);
    avl_check(p->right, compare);
    if (p->left && (*compare)(p->left->item, p->item) != LESS_THAN) {
      printf("error: left not smaller: %p\n", p->item);
      fprintf(stderr, "error: left not smaller: %p\n", p->item);
    }
    if (p->right && (*compare)(p->right->item, p->item) != GREATER_THAN) {
      printf("error: right not greater: %p\n", p->item);
      fprintf(stderr, "error: right not greater: %p\n", p->item);
    }
    if (p->height != ((avl_height(p->left)) > (avl_height(p->right)) ? (avl_height(p->left)) : (avl_height(p->right))) + 1) {
      printf("error: height wrong: %p\n", p->item);
      fprintf(stderr, "error: height wrong: %p\n", p->item);
    }
    if (p->size != (avl_size(p->left) + avl_size(p->right)) + 1) {
      printf("error: size wrong: %p\n", p->item);
      fprintf(stderr, "error: size wrong: %p\n", p->item);
    }
    if (!balance_ok(p)) {
      printf("error: unbalanced: %p\n", p->item);
      fprintf(stderr, "error: unbalanced: %p\n", p->item);
    }
  }
}

canonical_original_code:
void avl_check(struct avl_node *p, enum Ordertype (*compare)(void *, void *))
{
  if (p != ((void *)0)) {
    avl_check(p->left, compare);
    avl_check(p->right, compare);
    if (p->left && (*compare)(p->left->item, p->item) != LESS_THAN) {
      printf("error: left not smaller: %p\n", p->item);
      fprintf(stderr, "error: left not smaller: %p\n", p->item);
    }
    if (p->right && (*compare)(p->right->item, p->item) != GREATER_THAN) {
      printf("error: right not greater: %p\n", p->item);
      fprintf(stderr, "error: right not greater: %p\n", p->item);
    }
    if (p->height != ((avl_height(p->left)) > (avl_height(p->right)) ? (avl_height(p->left)) : (avl_height(p->right))) + 1) {
      printf("error: height wrong: %p\n", p->item);
      fprintf(stderr, "error: height wrong: %p\n", p->item);
    }
    if (p->size != (avl_size(p->left) + avl_size(p->right)) + 1) {
      printf("error: size wrong: %p\n", p->item);
      fprintf(stderr, "error: size wrong: %p\n", p->item);
    }
    if (!balance_ok(p)) {
      printf("error: unbalanced: %p\n", p->item);
      fprintf(stderr, "error: unbalanced: %p\n", p->item);
    }
  }
}


decompiled_code:
int __fastcall p_avl(unsigned int *a1, int a2)
{
int i; // ebx
int result; // eax
int j; // ebx

if ( a1 )
{
p_avl(*((_QWORD *)a1 + 3), (unsigned int)(a2 + 1));
if ( a2 > 0 )
{
for ( i = 0; i != a2; ++i )
printf(" ");
}
printf("%4d\n", *a1);
result = p_avl(*((_QWORD *)a1 + 2), (unsigned int)(a2 + 1));
}
else
{
if ( a2 > 0 )
{
for ( j = 0; j != a2; ++j )
printf(" ");
}
result = puts("----");
}
return result;
}

canonical_decompiled_code:
int __fastcall func24(unsigned int *a1, int a2)
{
int i; // ebx
int result; // eax
int j; // ebx

if ( a1 )
{
func24(*((_QWORD *)a1 + 3), (unsigned int)(a2 + 1));
if ( a2 > 0 )
{
for ( i = 0; i != a2; ++i )
printf(" ");
}
printf("%4d\n", *a1);
result = func24(*((_QWORD *)a1 + 2), (unsigned int)(a2 + 1));
}
else
{
if ( a2 > 0 )
{
for ( j = 0; j != a2; ++j )
printf(" ");
}
result = puts("----");
}
return result;
}

original_code:
void p_avl(Avl_node p, int level)
{
  int i;
  if (p == ((void *)0)) {
    for (i = 0; i < level; i++)
      printf("    ");
    printf("----\n");
  }
  else {
    p_avl(p->right, level+1);
    for (i = 0; i < level; i++)
      printf("    ");
    printf("%4d\n", (int) p->item);
    p_avl(p->left, level+1);
  }
}

canonical_original_code:
void p_avl(struct avl_node *p, int level)
{
  int i;
  if (p == ((void *)0)) {
    for (i = 0; i < level; i++)
      printf("    ");
    printf("----\n");
  }
  else {
    p_avl(p->right, level+1);
    for (i = 0; i < level; i++)
      printf("    ");
    printf("%4d\n", (int) p->item);
    p_avl(p->left, level+1);
  }
}

variable_types: level int


original_code:
Flatterm fapply_demod(Term t, Context c)
{
  Flatterm f;
  if (((t)->private_symbol >= 0)) {
    f = copy_flatterm((Flatterm) c->terms[((t)->private_symbol)]);
    f->reduced_flag = TRUE;
  }
  else {
    int n = 1;
    int i;
    Flatterm end;
    f = get_flatterm();
    f->private_symbol = t->private_symbol;
    ((f)->arity) = ((t)->arity);
    end = f;
    for (i = 0; i < ((t)->arity); i++) {
      Flatterm a = fapply_demod(((t)->args[i]), c);
      n += a->size;
      end->next = a;
      a->prev = end;
      end = a->end;
    }
    f->size = n;
    f->end = end;
  }
  return f;
}

canonical_original_code:
struct flatterm *fapply_demod(struct term *t, struct context *c)
{
  struct flatterm *f;
  if (((t)->private_symbol >= 0)) {
    f = copy_flatterm((struct flatterm *) c->terms[((t)->private_symbol)]);
    f->reduced_flag = TRUE;
  }
  else {
    int n = 1;
    int i;
    struct flatterm *end;
    f = get_flatterm();
    f->private_symbol = t->private_symbol;
    ((f)->arity) = ((t)->arity);
    end = f;
    for (i = 0; i < ((t)->arity); i++) {
      struct flatterm *a = fapply_demod(((t)->args[i]), c);
      n += a->size;
      end->next = a;
      a->prev = end;
      end = a->end;
    }
    f->size = n;
    f->end = end;
  }
  return f;
}

variable_types: struct term { int private_symbol; unsigned char arity; unsigned char private_flags; struct term **args; void *container; union { unsigned int id; void *vp; } u; } *

variable_types: struct context { struct term *terms[100]; struct context *contexts[100]; int multiplier; struct term *partial_term; } *

variable_types: struct flatterm { short private_symbol; unsigned char arity; struct flatterm *prev; int size; struct discrim { struct discrim *next; union { struct discrim *kids; struct plist { void *v; struct plist *next; } *data; } u; short symbol; char type; } *alternative; int varnum_bound_to; enum BOOL { FALSE=0, TRUE=1 } reduced_flag; } *

user_defined_types: struct flatterm { short private_symbol; unsigned char arity; struct flatterm *prev; int size; struct discrim *alternative; int varnum_bound_to; enum BOOL reduced_flag; }

user_defined_types: struct discrim { struct discrim *next; union { struct discrim *kids; struct plist *data; } u; short symbol; char type; }


original_code:
void discrim_flat_cancel(Discrim_pos pos)
{
  Flatterm f = pos->backtrack;
  Flatterm query = (Flatterm) pos->query;
  while (f != query->prev) {
    if (f->varnum_bound_to >= 0) {
      pos->subst->terms[f->varnum_bound_to] = ((void *)0);
      f->varnum_bound_to = -1;
    }
    f->alternative = ((void *)0);
    f = f->prev;
  }
  free_discrim_pos(pos);
}

canonical_original_code:
void discrim_flat_cancel(struct discrim_pos *pos)
{
  struct flatterm *f = pos->backtrack;
  struct flatterm *query = (Flatterm) pos->query;
  while (f != query->prev) {
    if (f->varnum_bound_to >= 0) {
      pos->subst->terms[f->varnum_bound_to] = ((void *)0);
      f->varnum_bound_to = -1;
    }
    f->alternative = ((void *)0);
    f = f->prev;
  }
  free_discrim_pos(pos);
}

variable_types: struct discrim_pos { void *query; struct context { struct term { int private_symbol; unsigned char arity; unsigned char private_flags; struct term **args; void *container; union { unsigned int id; void *vp; } u; } *terms[100]; struct context *contexts[100]; int multiplier; struct term *partial_term; } *subst; struct plist { void *v; struct plist *next; } *data; void *backtrack; } *

user_defined_types: struct discrim_pos { void *query; struct context *subst; struct plist *data; void *backtrack; }

user_defined_types: struct context { struct term *terms[100]; struct context *contexts[100]; int multiplier; struct term *partial_term; }


fdemodulate

decompiled_code:
__int64 __fastcall fdemodulate(__int64 a1, __int64 *a2, _DWORD *a3, _DWORD *a4, int *a5, _QWORD *a6, unsigned int a7)
{
__int64 v9; // rbp
__int64 v10; // rbx
int v11; // er14
int v12; // er14
__int64 v13; // rbp
__int64 v14; // rbx
int v18[15]; // [rsp+2Ch] [rbp-3Ch] BYREF

v9 = term_to_flatterm();
v10 = get_context();
v11 = *(_DWORD *)(v9 + 32);
v18[0] = v11;
if ( *a4 == 0x7FFFFFFF )
{
v13 = fdemod(v9, a2, v10, a3, 0x7FFFFFFF, v18, a5, a6, a7);
free_context(v10);
}
else
{
v12 = *a4 + v11;
v13 = fdemod(v9, a2, v10, a3, v12, v18, a5, a6, a7);
free_context(v10);
if ( v18[0] > v12 )
*a4 = -1;
}
if ( *a6 )
{
v14 = flatterm_to_term(v13);
zap_flatterm(v13);
zap_term(a1);
}
else
{
zap_flatterm(v13);
v14 = a1;
}
return v14;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 *a2, _DWORD *a3, _DWORD *a4, int *a5, _QWORD *a6, unsigned int a7)
{
__int64 v9; // rbp
__int64 v10; // rbx
int v11; // er14
int v12; // er14
__int64 v13; // rbp
__int64 v14; // rbx
int v18[15]; // [rsp+2Ch] [rbp-3Ch] BYREF

v9 = term_to_flatterm();
v10 = get_context();
v11 = *(_DWORD *)(v9 + 32);
v18[0] = v11;
if ( *a4 == 0x7FFFFFFF )
{
v13 = func3(v9, a2, v10, a3, 0x7FFFFFFF, v18, a5, a6, a7);
free_context(v10);
}
else
{
v12 = *a4 + v11;
v13 = func3(v9, a2, v10, a3, v12, v18, a5, a6, a7);
free_context(v10);
if ( v18[0] > v12 )
*a4 = -1;
}
if ( *a6 )
{
v14 = flatterm_to_term(v13);
zap_flatterm(v13);
zap_term(a1);
}
else
{
zap_flatterm(v13);
v14 = a1;
}
return v14;
}

original_code:
Term fdemodulate(Term t, Discrim root,
   int *step_limit, int *increase_limit, int *sequence,
   I3list *just_head, BOOL lex_order_vars)
{
  Flatterm f = term_to_flatterm(t);
  Context subst = get_context();
  int current_size = f->size;
  int size_limit = (*increase_limit==0x7fffffff) ? 0x7fffffff : current_size + *increase_limit;
  Flatterm f2 = fdemod(f, root, subst, step_limit,
         size_limit, &current_size,
         sequence, just_head, lex_order_vars);
  free_context(subst);
  if (current_size > size_limit)
    *increase_limit = -1;
  if (*just_head == ((void *)0)) {
    zap_flatterm(f2);
    return t;
  }
  else {
    Term t2 = flatterm_to_term(f2);
    zap_flatterm(f2);
    zap_term(t);
    return t2;
  }
}

canonical_original_code:
struct term *fdemodulate(struct term *t, struct discrim *root, int *step_limit, int *increase_limit, int *sequence, struct i3list **just_head, enum BOOL lex_order_vars)
{
  struct flatterm *f = term_to_flatterm(t);
  struct context *subst = get_context();
  int current_size = f->size;
  int size_limit = (*increase_limit==0x7fffffff) ? 0x7fffffff : current_size + *increase_limit;
  struct flatterm *f2 = fdemod(f, root, subst, step_limit,
         size_limit, &current_size,
         sequence, just_head, lex_order_vars);
  free_context(subst);
  if (current_size > size_limit)
    *increase_limit = -1;
  if (*just_head == ((void *)0)) {
    zap_flatterm(f2);
    return t;
  }
  else {
    struct term *t2 = flatterm_to_term(f2);
    zap_flatterm(f2);
    zap_term(t);
    return t2;
  }
}

variable_types:
t
struct term *

variable_types: struct discrim { struct discrim *next; union { struct discrim *kids; struct plist { void *v; struct plist *next; } *data; } u; short symbol; char type; } *

variable_types:
sequence
int *

variable_types: struct i3list { int i; int j; int k; struct i3list *next; } **

variable_types: struct context { struct term { int private_symbol; unsigned char arity; unsigned char private_flags; struct term **args; void *container; union { unsigned int id; void *vp; } u; } *terms[100]; struct context *contexts[100]; int multiplier; struct term *partial_term; } *


decompiled_code:
__int64 fdemod_attempts()
{
return (unsigned int)Fdemod_attempts;
}

canonical_decompiled_code:
__int64 func5()
{
return (unsigned int)Fdemod_attempts;
}

original_code:
int fdemod_attempts()
{
  return Fdemod_attempts;
}


decompiled_code:
__int64 fdemod_rewrites()
{
return (unsigned int)Fdemod_rewrites;
}

canonical_decompiled_code:
__int64 func6()
{
return (unsigned int)Fdemod_rewrites;
}

original_code:
int fdemod_rewrites()
{
  return Fdemod_rewrites;
}


original_code:
static
double complexity2(int *s, int n)
{
  int c = 1;
  int b = 1;
  int a, k, kmax;
  a = k = kmax = 0;
  while (b+k < n) {
    if (s[a+k] == s[b+k]) {
      k++;
    }
    else {
      kmax = ((k) > (kmax) ? (k) : (kmax));
      a++;
      if (a != b)
 k = 0;
      else {
 c++;
 b += (kmax+1);
 a = k = kmax = 0;
      }
    }
  }
  return ((double) c) / n;
}

canonical_original_code:
static double complexity2(int *s, int n)
{
  int c = 1;
  int b = 1;
  int a; int k; int kmax;
  a = k = kmax = 0;
  while (b+k < n) {
    if (s[a+k] == s[b+k]) {
      k++;
    }
    else {
      kmax = ((k) > (kmax) ? (k) : (kmax));
      a++;
      if (a != b)
 k = 0;
      else {
 c++;
 b += (kmax+1);
 a = k = kmax = 0;
      }
    }
  }
  return ((double) c) / n;
}

variable_types:
s
int *

variable_types: n int

variable_types: c int

variable_types: b int

variable_types: a int

variable_types: k int

variable_types: kmax int


decompiled_code:
__int64 __fastcall complex4_compare(__int64 a1, unsigned int *a2, _DWORD *a3)
{
__int64 result; // rax
__int64 v5; // rbp

result = *a2;
if ( *(_DWORD *)a1 == (_DWORD)result )
{
++*a3;
if ( *(_BYTE *)(a1 + 4) )
{
v5 = 0LL;
do
{
complex4_compare(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8 * v5), *(_QWORD *)(*((_QWORD *)a2 + 1) + 8 * v5), a3);
++v5;
result = *(unsigned __int8 *)(a1 + 4);
}
while ( (int)result > (int)v5 );
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, unsigned int *a2, _DWORD *a3)
{
__int64 result; // rax
__int64 v5; // rbp

result = *a2;
if ( *(_DWORD *)a1 == (_DWORD)result )
{
++*a3;
if ( *(_BYTE *)(a1 + 4) )
{
v5 = 0LL;
do
{
func2(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8 * v5), *(_QWORD *)(*((_QWORD *)a2 + 1) + 8 * v5), a3);
++v5;
result = *(unsigned __int8 *)(a1 + 4);
}
while ( (int)result > (int)v5 );
}
}
return result;
}

original_code:
static
void complex4_compare(Term a, Term b, int *n)
{
  if ((-((a)->private_symbol)) == (-((b)->private_symbol))) {
    int i;
    (*n)++;
    for (i = 0; i < ((a)->arity); i++)
      complex4_compare(((a)->args[i]), ((b)->args[i]), n);
  }
}

canonical_original_code:
static void complex4_compare(struct term *a, struct term *b, int *n)
{
  if ((-((a)->private_symbol)) == (-((b)->private_symbol))) {
    int i;
    (*n)++;
    for (i = 0; i < ((a)->arity); i++)
      complex4_compare(((a)->args[i]), ((b)->args[i]), n);
  }
}

variable_types:
b
struct term *

variable_types:
n
int *

variable_types: i int

user_defined_types: struct term { int private_symbol; unsigned char arity; unsigned char private_flags; struct term **args; void *container; union { unsigned int id; void *vp; } u; }