decompiled_code:
__int64 __fastcall box_project(__int64 a1, __m128i a2)
{
unsigned int v2; // er14
__int64 v3; // rbp
__int64 v4; // rbx
__int64 v5; // rdi
__int64 result; // rax

v2 = _mm_cvtsi128_si32(a2);
v3 = a1 + 552;
v4 = a1;
do
{
v5 = v4;
v4 += 92LL;
result = surface_project(v5, *(double *)_mm_cvtsi32_si128(v2).m128i_i64);
}
while ( v4 != v3 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, __m128i a2)
{
unsigned int v2; // er14
__int64 v3; // rbp
__int64 v4; // rbx
__int64 v5; // rdi
__int64 result; // rax

v2 = _mm_cvtsi128_si32(a2);
v3 = a1 + 552;
v4 = a1;
do
{
v5 = v4;
v4 += 92LL;
result = surface_project(v5, *(double *)_mm_cvtsi32_si128(v2).m128i_i64);
}
while ( v4 != v3 );
return result;
}

original_code:
void
box_project(box_t *b, float d)
{
 int i;
 for (i = 0; i < 6; i++)
  surface_project(&b->surfaces[i], d);
}

canonical_original_code:
void box_project(struct box_t *b, float d)
{
 int i;
 for (i = 0; i < 6; i++)
  surface_project(&b->surfaces[i], d);
}

variable_types: d float


repo: oshogbo/warnock

decompiled_code:
__int64 __fastcall box_draw(__int64 a1)
{
__int64 v1; // rbp
__int64 v2; // rbx
__int64 v3; // rdi
__int64 result; // rax

v1 = a1 + 552;
v2 = a1;
do
{
v3 = v2;
v2 += 92LL;
result = surface_draw(v3);
}
while ( v2 != v1 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
__int64 v1; // rbp
__int64 v2; // rbx
__int64 v3; // rdi
__int64 result; // rax

v1 = a1 + 552;
v2 = a1;
do
{
v3 = v2;
v2 += 92LL;
result = surface_draw(v3);
}
while ( v2 != v1 );
return result;
}

original_code:
void
box_draw(box_t *box)
{
 int i;
 for (i = 0; i < 6; i++)
  surface_draw(&box->surfaces[i]);
}

canonical_original_code:
void box_draw(struct box_t *box)
{
 int i;
 for (i = 0; i < 6; i++)
  surface_draw(&box->surfaces[i]);
}

variable_types: struct box_t { struct surface_t { struct coord_t { float x; float y; float z; float xp; float yp; } coords[4]; float r; float g; float b; } surfaces[6]; int color_schame; } *

variable_types: i int

return_type: void

user_defined_types: struct box_t { struct surface_t surfaces[6]; int color_schame; }

user_defined_types: struct surface_t { struct coord_t coords[4]; float r; float g; float b; }


decompiled_code:
__int64 __fastcall box_set_color(__int64 a1, __m128i a2)
{
unsigned int v2; // er14
__int64 v3; // rbp
__int64 v4; // rbx
__int64 v5; // rdi
__int64 result; // rax

v2 = _mm_cvtsi128_si32(a2);
v3 = a1 + 552;
v4 = a1;
do
{
v5 = v4;
v4 += 92LL;
result = surface_set_color(v5, *(double *)_mm_cvtsi32_si128(v2).m128i_i64);
}
while ( v4 != v3 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, __m128i a2)
{
unsigned int v2; // er14
__int64 v3; // rbp
__int64 v4; // rbx
__int64 v5; // rdi
__int64 result; // rax

v2 = _mm_cvtsi128_si32(a2);
v3 = a1 + 552;
v4 = a1;
do
{
v5 = v4;
v4 += 92LL;
result = surface_set_color(v5, *(double *)_mm_cvtsi32_si128(v2).m128i_i64);
}
while ( v4 != v3 );
return result;
}

original_code:
void
box_set_color(box_t *box, float r, float g, float b)
{
 int i;
 for (i = 0; i < 6; i++)
  surface_set_color(&box->surfaces[i], r, g, b);
}

canonical_original_code:
void box_set_color(struct box_t *box, float r, float g, float b)
{
 int i;
 for (i = 0; i < 6; i++)
  surface_set_color(&box->surfaces[i], r, g, b);
}

variable_types: r float

variable_types: g float

variable_types: b float

user_defined_types: struct coord_t { float x; float y; float z; float xp; float yp; }


decompiled_code:
void __fastcall coord_project(float *a1, float a2)
{
float v2; // xmm2_4
float v3; // xmm1_4
float v4; // xmm0_4

v2 = a1[2];
v3 = (float)(*a1 * a2) / v2;
v4 = (float)(a2 * a1[1]) / v2;
a1[3] = v3;
a1[4] = v4;
}

original_code:
void
coord_project(coord_t *c, float d)
{
 c->xp = c->x * d / c->z;
 c->yp = c->y * d / c->z;
}

canonical_original_code:
void coord_project(struct coord_t *c, float d)
{
 c->xp = c->x * d / c->z;
 c->yp = c->y * d / c->z;
}

variable_types: struct coord_t { float x; float y; float z; float xp; float yp; } *


decompiled_code:
void __fastcall coord_translation(float *a1, float a2, float a3, float a4)
{
float v4; // xmm1_4
float v5; // xmm2_4

v4 = a3 + a1[1];
v5 = a4 + a1[2];
*a1 = a2 + *a1;
a1[1] = v4;
a1[2] = v5;
}

canonical_decompiled_code:
void __fastcall func1(float *a1, float a2, float a3, float a4)
{
float v4; // xmm1_4
float v5; // xmm2_4

v4 = a3 + a1[1];
v5 = a4 + a1[2];
*a1 = a2 + *a1;
a1[1] = v4;
a1[2] = v5;
}

original_code:
void
coord_translation(coord_t *c, float x, float y, float z)
{
 c->x += x;
 c->y += y;
 c->z += z;
}

canonical_original_code:
void coord_translation(struct coord_t *c, float x, float y, float z)
{
 c->x += x;
 c->y += y;
 c->z += z;
}

variable_types: x float

variable_types: y float

variable_types: z float


decompiled_code:
void __fastcall coord_set(float *a1, float a2, float a3, float a4)
{
*a1 = a2;
a1[1] = a3;
a1[2] = a4;
}

canonical_decompiled_code:
void __fastcall func2(float *a1, float a2, float a3, float a4)
{
*a1 = a2;
a1[1] = a3;
a1[2] = a4;
}

original_code:
void
coord_set(coord_t *p, float x, float y, float z)
{
 p->x = x;
 p->y = y;
 p->z = z;
}

canonical_original_code:
void coord_set(struct coord_t *p, float x, float y, float z)
{
 p->x = x;
 p->y = y;
 p->z = z;
}


decompiled_code:
void __fastcall coord_rotate_x(__int64 a1, float a2)
{
float v2; // xmm0_4
float v3; // xmm1_4
float v4; // xmm2_4
float v5; // xmm0_4
float cosx; // [rsp+0h] [rbp-10h] BYREF
float sinx[3]; // [rsp+4h] [rbp-Ch] BYREF

v2 = a2 * 3.141592653589793 / 180.0;
sincosf(v2, sinx, &cosx);
v3 = cosx * *(float *)(a1 + 8);
v4 = (float)(*(float *)(a1 + 4) * cosx) - (float)(*(float *)(a1 + 8) * sinx[0]);
v5 = sinx[0] * v4;
*(float *)(a1 + 4) = v4;
*(float *)(a1 + 8) = v5 + v3;
}

canonical_decompiled_code:
void __fastcall func3(__int64 a1, float a2)
{
float v2; // xmm0_4
float v3; // xmm1_4
float v4; // xmm2_4
float v5; // xmm0_4
float cosx; // [rsp+0h] [rbp-10h] BYREF
float sinx[3]; // [rsp+4h] [rbp-Ch] BYREF

v2 = a2 * 3.141592653589793 / 180.0;
sincosf(v2, sinx, &cosx);
v3 = cosx * *(float *)(a1 + 8);
v4 = (float)(*(float *)(a1 + 4) * cosx) - (float)(*(float *)(a1 + 8) * sinx[0]);
v5 = sinx[0] * v4;
*(float *)(a1 + 4) = v4;
*(float *)(a1 + 8) = v5 + v3;
}

original_code:
void
coord_rotate_x(coord_t *c, float alphax)
{
 float radians;
 radians = alphax * 3.14159265358979323846 / 180;
 c->y = c->y * cosf(radians) - c->z * sinf(radians);
 c->z = c->y * sinf(radians) + c->z * cosf(radians);
}

canonical_original_code:
void coord_rotate_x(struct coord_t *c, float alphax)
{
 float radians;
 radians = alphax * 3.14159265358979323846 / 180;
 c->y = c->y * cosf(radians) - c->z * sinf(radians);
 c->z = c->y * sinf(radians) + c->z * cosf(radians);
}

variable_types: alphax float

variable_types: radians float


decompiled_code:
void __fastcall coord_rotate_y(float *a1, float a2)
{
float v2; // xmm0_4
float v3; // xmm3_4
float v4; // xmm0_4
float v5; // xmm1_4
float cosx; // [rsp+0h] [rbp-10h] BYREF
float sinx[3]; // [rsp+4h] [rbp-Ch] BYREF

v2 = a2 * 3.141592653589793 / 180.0;
sincosf(v2, sinx, &cosx);
v3 = sinx[0];
v4 = cosx * a1[2];
v5 = (float)(*a1 * cosx) + (float)(a1[2] * sinx[0]);
*a1 = v5;
a1[2] = v4 - (float)(v5 * v3);
}

canonical_decompiled_code:
void __fastcall func4(float *a1, float a2)
{
float v2; // xmm0_4
float v3; // xmm3_4
float v4; // xmm0_4
float v5; // xmm1_4
float cosx; // [rsp+0h] [rbp-10h] BYREF
float sinx[3]; // [rsp+4h] [rbp-Ch] BYREF

v2 = a2 * 3.141592653589793 / 180.0;
sincosf(v2, sinx, &cosx);
v3 = sinx[0];
v4 = cosx * a1[2];
v5 = (float)(*a1 * cosx) + (float)(a1[2] * sinx[0]);
*a1 = v5;
a1[2] = v4 - (float)(v5 * v3);
}

original_code:
void
coord_rotate_y(coord_t *c, float alphax)
{
 float radians;
 radians = alphax * 3.14159265358979323846 / 180;
 c->x = c->x * cosf(radians) + c->z * sinf(radians);
 c->z = - c->x * sinf(radians) + c->z * cosf(radians);
}

canonical_original_code:
void coord_rotate_y(struct coord_t *c, float alphax)
{
 float radians;
 radians = alphax * 3.14159265358979323846 / 180;
 c->x = c->x * cosf(radians) + c->z * sinf(radians);
 c->z = - c->x * sinf(radians) + c->z * cosf(radians);
}


decompiled_code:
void __fastcall coord_rotate_z(float *a1, float a2)
{
float v2; // xmm0_4
float v3; // xmm1_4
float v4; // xmm2_4
float v5; // xmm0_4
float cosx; // [rsp+0h] [rbp-10h] BYREF
float sinx[3]; // [rsp+4h] [rbp-Ch] BYREF

v2 = a2 * 3.141592653589793 / 180.0;
sincosf(v2, sinx, &cosx);
v3 = cosx * a1[1];
v4 = (float)(*a1 * cosx) - (float)(a1[1] * sinx[0]);
v5 = sinx[0] * v4;
*a1 = v4;
a1[1] = v5 + v3;
}

canonical_decompiled_code:
void __fastcall func5(float *a1, float a2)
{
float v2; // xmm0_4
float v3; // xmm1_4
float v4; // xmm2_4
float v5; // xmm0_4
float cosx; // [rsp+0h] [rbp-10h] BYREF
float sinx[3]; // [rsp+4h] [rbp-Ch] BYREF

v2 = a2 * 3.141592653589793 / 180.0;
sincosf(v2, sinx, &cosx);
v3 = cosx * a1[1];
v4 = (float)(*a1 * cosx) - (float)(a1[1] * sinx[0]);
v5 = sinx[0] * v4;
*a1 = v4;
a1[1] = v5 + v3;
}

original_code:
void
coord_rotate_z(coord_t *c, float alphax)
{
 float radians;
 radians = alphax * 3.14159265358979323846 / 180;
 c->x = c->x * cosf(radians) - c->y * sinf(radians);
 c->y = c->x * sinf(radians) + c->y * cosf(radians);
}

canonical_original_code:
void coord_rotate_z(struct coord_t *c, float alphax)
{
 float radians;
 radians = alphax * 3.14159265358979323846 / 180;
 c->x = c->x * cosf(radians) - c->y * sinf(radians);
 c->y = c->x * sinf(radians) + c->y * cosf(radians);
}


logLevel

repo: oskarirauta/populatefs

decompiled_code:
__int64 logLevel()
{
return (unsigned int)logging_level;
}

canonical_decompiled_code:
__int64 func0()
{
return (unsigned int)logging_level;
}

original_code:
int logLevel(void)
{
 return logging_level;
}

canonical_original_code:
int logLevel()
{
 return logging_level;
}

return_type: int


setLoggingLevel

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

if ( a1 <= 0 )
{
logging_level = 0;
}
else
{
result = 2LL;
if ( a1 != 1 )
a1 = 2;
logging_level = a1;
}
return result;
}

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

if ( a1 <= 0 )
{
logging_level = 0;
}
else
{
result = 2LL;
if ( a1 != 1 )
a1 = 2;
logging_level = a1;
}
return result;
}

original_code:
void setLoggingLevel(int state)
{
 logging_level = state < 1 ? 0 : ( state == 1 ? 1 : 2 );
}

variable_types: state int


decompiled_code:
char *log_cwd()
{
char *result; // rax

result = logPath;
if ( !logPath )
result = (char *)&logPathRoot;
return result;
}

canonical_decompiled_code:
char *func2()
{
char *result; // rax

result = logPath;
if ( !logPath )
result = (char *)&logPathRoot;
return result;
}

original_code:
char *log_cwd(void)
{
 return logPath ? logPath : logPathRoot;
}

canonical_original_code:
char *log_cwd()
{
 return logPath ? logPath : logPathRoot;
}

return_type: char *


decompiled_code:
_BOOL8 log_inRoot()
{
return logPath != 0LL;
}

canonical_decompiled_code:
_BOOL8 func3()
{
return logPath != 0LL;
}

original_code:
int log_inRoot(void)
{
 return logPath ? 1 : 0;
}

canonical_original_code:
int log_inRoot()
{
 return logPath ? 1 : 0;
}


decompiled_code:
_QWORD *get_single_warning()
{
_QWORD *result; // rax

result = warning_list;
if ( warning_list )
result = (_QWORD *)*warning_list;
return result;
}

canonical_decompiled_code:
_QWORD *func4()
{
_QWORD *result; // rax

result = warning_list;
if ( warning_list )
result = (_QWORD *)*warning_list;
return result;
}

original_code:
char *get_single_warning(void)
{
 if ( !warning_list )
  return ((void *)0);
 return warning_list->str;
}

canonical_original_code:
char *get_single_warning()
{
 if ( !warning_list )
  return ((void *)0);
 return warning_list->str;
}


decompiled_code:
void clear_single_warning()
{
_QWORD *v0; // rbp
void *v1; // rdi

v0 = warning_list;
if ( warning_list )
{
v1 = (void *)*warning_list;
warning_list = (_QWORD *)warning_list[1];
free(v1);
free(v0);
}
}

canonical_decompiled_code:
void func5()
{
_QWORD *v0; // rbp
void *v1; // rdi

v0 = warning_list;
if ( warning_list )
{
v1 = (void *)*warning_list;
warning_list = (_QWORD *)warning_list[1];
free(v1);
free(v0);
}
}

original_code:
void clear_single_warning(void)
{
 if ( !warning_list )
  return;
 warning_nodeT *node = warning_list;
 if ( node->next == ((void *)0) )
  warning_list = ((void *)0);
 else
  warning_list = node->next;
 node->next = ((void *)0);
 free( node->str );
 node->str = ((void *)0);
 free( node );
}

canonical_original_code:
void clear_single_warning()
{
 if ( !warning_list )
  return;
 struct warning_node *node = warning_list;
 if ( node->next == ((void *)0) )
  warning_list = ((void *)0);
 else
  warning_list = node->next;
 node->next = ((void *)0);
 free( node->str );
 node->str = ((void *)0);
 free( node );
}

variable_types: struct warning_node { char *str; struct warning_node *next; } *


decompiled_code:
void purge_warnings()
{
const char **i; // rbp
const char *v1; // rsi

for ( i = (const char **)warning_list; warning_list; i = (const char **)warning_list )
{
v1 = *i;
warning_list = i[1];
printf("Warning: %s\r\n", v1);
free((void *)*i);
free(i);
}
warning_list = 0LL;
}

canonical_decompiled_code:
void func6()
{
const char **i; // rbp
const char *v1; // rsi

for ( i = (const char **)warning_list; warning_list; i = (const char **)warning_list )
{
v1 = *i;
warning_list = i[1];
printf("Warning: %s\r\n", v1);
free((void *)*i);
free(i);
}
warning_list = 0LL;
}

original_code:
void purge_warnings(void)
{
 while ( warning_list ) {
  warning_nodeT *node = warning_list;
  warning_list = node->next;
  printf("Warning: %s\r\n", node->str);
  node->next = ((void *)0);
  free( node->str );
  node->str = ((void *)0);
  free( node );
  node = ((void *)0);
 }
 warning_list = ((void *)0);
}

canonical_original_code:
void purge_warnings()
{
 while ( warning_list ) {
  struct warning_node *node = warning_list;
  warning_list = node->next;
  printf("Warning: %s\r\n", node->str);
  node->next = ((void *)0);
  free( node->str );
  node->str = ((void *)0);
  free( node );
  node = ((void *)0);
 }
 warning_list = ((void *)0);
}

user_defined_types: struct warning_node { char *str; struct warning_node *next; }


decompiled_code:
void __noreturn log_error(const char *a1, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, a1);
if ( warning_list )
{
puts("\r\n");
purge_warnings();
puts("\r");
}
printf("Error: ");
vprintf(a1, arg);
puts("\r");
fflush(stdout);
exit(-1);
}

canonical_decompiled_code:
void __noreturn func7(const char *a1, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, a1);
if ( warning_list )
{
puts("\r\n");
func6();
puts("\r");
}
printf("Error: ");
vprintf(a1, arg);
puts("\r");
fflush(stdout);
exit(-1);
}

original_code:
void log_error(const char *s, ...)
{
 va_list p;
 __builtin_va_start(p,s);
 if ( warning_list ) {
  printf("\r\n\n");
  purge_warnings();
  printf("\r\n");
 }
 printf("Error: ");
 vprintf(s, p);
 printf("\r\n");
 fflush(stdout);
 exit(-1);
}

canonical_original_code:
void log_error(char *s, ...)
{
 __builtin_va_list p;
 __builtin_va_start(p,s);
 if ( warning_list ) {
  printf("\r\n\n");
  purge_warnings();
  printf("\r\n");
 }
 printf("Error: ");
 vprintf(s, p);
 printf("\r\n");
 fflush(stdout);
 exit(-1);
}

variable_types:
s
char *


decompiled_code:
int __fastcall log_action(int a1, char *a2, const char *a3, unsigned int a4, __int64 a5, __int64 a6, unsigned int a7, __int64 a8, __int64 a9, int a10)
{
__int64 v12; // rcx
unsigned int v14; // er14
__int64 v15; // r10
__int64 v16; // r11
int result; // eax
__int64 v18; // rsi
char *v19; // rdx
char *v20; // rax
__int64 v21; // rsi
char *v22; // rdx
char *v23; // rax
__int64 v24; // rsi
char *v25; // rdx
char *v26; // rax
char *v27; // rax
__int64 v28; // r10
__int64 v29; // r11
__int64 v30; // rsi
const char *v31; // rdx
char *v32; // rax
char *v33; // rax
__int64 v34; // rsi
char *v35; // rdx
char *v36; // rax
char *v37; // rax
char *v38; // rax
unsigned int v39; // eax
char *v40; // rax
char *v41; // rax
char *v42; // rax
const char *v43; // rsi
char *v44; // rax
char *v45; // rax
char *v46; // rax
int v47; // [rsp-10h] [rbp-68h]
__int64 v49; // [rsp+0h] [rbp-58h]
__int64 v50; // [rsp+0h] [rbp-58h]
__int64 v51; // [rsp+0h] [rbp-58h]
__int64 v52; // [rsp+0h] [rbp-58h]
__int64 v53; // [rsp+0h] [rbp-58h]
__int64 v54; // [rsp+0h] [rbp-58h]
__int64 v55; // [rsp+8h] [rbp-50h]
__int64 v56; // [rsp+8h] [rbp-50h]
__int64 v57; // [rsp+8h] [rbp-50h]
__int64 v58; // [rsp+8h] [rbp-50h]
__int64 v59; // [rsp+8h] [rbp-50h]
__int64 v60; // [rsp+8h] [rbp-50h]
__int64 v61; // [rsp+8h] [rbp-50h]

v12 = a5;
v14 = a7;
v15 = a8;
v16 = a9;
if ( a1 == 8 )
{
v55 = a6;
internal_log_chdir(a2);
v16 = a9;
v15 = a8;
a6 = v55;
v12 = a5;
}
result = logging_level;
if ( logging_level > 0 )
{
switch ( a7 )
{
case 1u:
v14 = 102;
break;
case 3u:
v14 = 99;
break;
case 4u:
v14 = 98;
break;
case 5u:
v14 = 112;
break;
case 6u:
v14 = 115;
break;
default:
break;
}
switch ( a1 )
{
case 1:
if ( logging_level == 1 )
{
v25 = log_cwd();
v24 = a10 == 0 ? 120 : 33;
}
else
{
if ( a10 )
{
LABEL_35:
v26 = log_cwd();
return printf("[x][write] %s/%s\r\n", v26, a2);
}
v24 = 120LL;
v25 = log_cwd();
}
result = printf("[%c][write] %s/%s\r\n", v24, v25, a2);
if ( logging_level > 1 && a10 )
goto LABEL_35;
return result;
case 2:
if ( logging_level == 1 )
{
if ( v14 != 102 )
{
v60 = v16;
v53 = v15;
v45 = log_cwd();
v29 = v60;
v28 = v53;
v31 = v45;
v30 = a10 == 0 ? 120 : 33;
goto LABEL_40;
}
}
else
{
if ( a10 )
goto LABEL_43;
if ( v14 != 102 )
{
v56 = v16;
v49 = v15;
v27 = log_cwd();
v28 = v49;
v29 = v56;
v30 = 120LL;
v31 = v27;
LABEL_40:
v57 = v29;
v50 = v28;
printf("[%c][mknod] %s/%s %c:%ld,%ld\r\n", v30, v31, a2, v14, v28, v29);
result = v47;
v15 = v50;
v16 = v57;
goto LABEL_41;
}
}
v61 = v16;
v54 = v15;
v46 = log_cwd();
result = printf("[x][touch] %s/%s\r\n", v46, a2);
v15 = v54;
v16 = v61;
LABEL_41:
if ( logging_level <= 1 || !a10 )
return result;
LABEL_43:
if ( v14 == 102 )
goto LABEL_51;
v58 = v16;
v51 = v15;
v32 = log_cwd();
return printf("[x][mknod] %s/%s %c:%ld,%ld\r\n", v32, a2, v14, v51, v58);
case 3:
v33 = log_cwd();
return printf("[%c][mkdir] %s/%s\r\n", a10 == 0 ? 100 : 45, v33, a2);
case 4:
if ( logging_level == 1 )
{
v35 = log_cwd();
v34 = a10 == 0 ? 120 : 33;
}
else
{
if ( a10 )
{
LABEL_51:
v36 = log_cwd();
return printf("[x][touch] %s/%s\r\n", v36, a2);
}
v34 = 120LL;
v35 = log_cwd();
}
result = printf("[%c][touch] %s/%s\r\n", v34, v35, a2);
if ( logging_level > 1 && a10 )
goto LABEL_51;
return result;
case 9:
if ( !a10 && logging_level == 1 )
{
v44 = log_cwd();
printf("[x][rm] %s/%s\r\n", v44, a2);
result = logging_level;
}
if ( result > 1 )
{
LABEL_52:
v37 = log_cwd();
result = printf("[x][rm] %s/%s\r\n", v37, a2);
}
return result;
case 10:
if ( logging_level == 1 )
{
v22 = log_cwd();
v21 = a10 == 0 ? 120 : 33;
}
else
{
if ( a10 )
{
LABEL_29:
v23 = log_cwd();
return printf("[x][symlink] %s/%s --> %s\r\n", v23, a2, a3);
}
v21 = 120LL;
v22 = log_cwd();
}
result = printf("[%c][symlink] %s/%s --> %s\r\n", v21, v22, a2, a3);
if ( logging_level <= 1 )
return result;
LABEL_28:
if ( a10 )
goto LABEL_29;
return result;
case 11:
if ( logging_level == 1 )
{
v19 = log_cwd();
v18 = a10 == 0 ? 120 : 33;
}
else
{
if ( a10 )
{
LABEL_23:
v20 = log_cwd();
return printf("[x][hardlink] %s/%s --> %s\r\n", v20, a2, a3);
}
v18 = 120LL;
v19 = log_cwd();
}
result = printf("[%c][hardlink] %s/%s --> %s\r\n", v18, v19, a2, a3);
if ( logging_level > 1 )
{
LABEL_22:
if ( a10 )
goto LABEL_23;
}
break;
default:
if ( logging_level != 1 )
{
switch ( a1 )
{
case 5:
v42 = log_cwd();
return printf("[p][chmod] %s/%s %d\r\n", v42, a2, a4);
case 6:
v59 = a6;
v52 = v12;
v41 = log_cwd();
return printf("[o][chown] %s/%s %ld:%ld\r\n", v41, a2, v52, v59);
case 7:
v38 = log_cwd();
printf("[t][filetype] %s/%s: ", v38, a2);
v39 = a4 & 0xF000;
if ( v39 == 24576 )
{
puts("BLOCK DEVICE NODE\r");
}
else
{
if ( v39 > 0x6000 )
{
switch ( v39 )
{
case 0xA000u:
puts("SYMBOLIC LINK\r");
goto LABEL_58;
case 0xC000u:
puts("SOCKET\r");
goto LABEL_58;
case 0x8000u:
puts("REGULAR FILE\r");
goto LABEL_58;
}
}
else
{
switch ( v39 )
{
case 0x2000u:
puts("CHARACTER DEVICE NODE\r");
goto LABEL_58;
case 0x4000u:
puts("DIRECTORY\r");
goto LABEL_58;
case 0x1000u:
puts("FIFO\r");
goto LABEL_58;
}
}
puts("UNKNOWN FILETYPE\r");
}
LABEL_58:
v40 = log_cwd();
result = printf("[p][chmod] %s/%s %04o\r\n", v40, a2, a4 & 0x1FF);
break;
case 8:
v43 = logPath;
if ( !logPath )
v43 = "[fs root]";
return printf("[-][chdir] %s\r\n", v43, a3, v12);
case 9:
goto LABEL_52;
case 10:
goto LABEL_28;
case 11:
goto LABEL_22;
default:
return result;
}
}
return result;
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func9(int a1, char *a2, const char *a3, unsigned int a4, __int64 a5, __int64 a6, unsigned int a7, __int64 a8, __int64 a9, int a10)
{
__int64 v12; // rcx
unsigned int v14; // er14
__int64 v15; // r10
__int64 v16; // r11
int result; // eax
__int64 v18; // rsi
char *v19; // rdx
char *v20; // rax
__int64 v21; // rsi
char *v22; // rdx
char *v23; // rax
__int64 v24; // rsi
char *v25; // rdx
char *v26; // rax
char *v27; // rax
__int64 v28; // r10
__int64 v29; // r11
__int64 v30; // rsi
const char *v31; // rdx
char *v32; // rax
char *v33; // rax
__int64 v34; // rsi
char *v35; // rdx
char *v36; // rax
char *v37; // rax
char *v38; // rax
unsigned int v39; // eax
char *v40; // rax
char *v41; // rax
char *v42; // rax
const char *v43; // rsi
char *v44; // rax
char *v45; // rax
char *v46; // rax
int v47; // [rsp-10h] [rbp-68h]
__int64 v49; // [rsp+0h] [rbp-58h]
__int64 v50; // [rsp+0h] [rbp-58h]
__int64 v51; // [rsp+0h] [rbp-58h]
__int64 v52; // [rsp+0h] [rbp-58h]
__int64 v53; // [rsp+0h] [rbp-58h]
__int64 v54; // [rsp+0h] [rbp-58h]
__int64 v55; // [rsp+8h] [rbp-50h]
__int64 v56; // [rsp+8h] [rbp-50h]
__int64 v57; // [rsp+8h] [rbp-50h]
__int64 v58; // [rsp+8h] [rbp-50h]
__int64 v59; // [rsp+8h] [rbp-50h]
__int64 v60; // [rsp+8h] [rbp-50h]
__int64 v61; // [rsp+8h] [rbp-50h]

v12 = a5;
v14 = a7;
v15 = a8;
v16 = a9;
if ( a1 == 8 )
{
v55 = a6;
func8(a2);
v16 = a9;
v15 = a8;
a6 = v55;
v12 = a5;
}
result = logging_level;
if ( logging_level > 0 )
{
switch ( a7 )
{
case 1u:
v14 = 102;
break;
case 3u:
v14 = 99;
break;
case 4u:
v14 = 98;
break;
case 5u:
v14 = 112;
break;
case 6u:
v14 = 115;
break;
default:
break;
}
switch ( a1 )
{
case 1:
if ( logging_level == 1 )
{
v25 = func2();
v24 = a10 == 0 ? 120 : 33;
}
else
{
if ( a10 )
{
LABEL_35:
v26 = func2();
return printf("[x][write] %s/%s\r\n", v26, a2);
}
v24 = 120LL;
v25 = func2();
}
result = printf("[%c][write] %s/%s\r\n", v24, v25, a2);
if ( logging_level > 1 && a10 )
goto LABEL_35;
return result;
case 2:
if ( logging_level == 1 )
{
if ( v14 != 102 )
{
v60 = v16;
v53 = v15;
v45 = func2();
v29 = v60;
v28 = v53;
v31 = v45;
v30 = a10 == 0 ? 120 : 33;
goto LABEL_40;
}
}
else
{
if ( a10 )
goto LABEL_43;
if ( v14 != 102 )
{
v56 = v16;
v49 = v15;
v27 = func2();
v28 = v49;
v29 = v56;
v30 = 120LL;
v31 = v27;
LABEL_40:
v57 = v29;
v50 = v28;
printf("[%c][mknod] %s/%s %c:%ld,%ld\r\n", v30, v31, a2, v14, v28, v29);
result = v47;
v15 = v50;
v16 = v57;
goto LABEL_41;
}
}
v61 = v16;
v54 = v15;
v46 = func2();
result = printf("[x][touch] %s/%s\r\n", v46, a2);
v15 = v54;
v16 = v61;
LABEL_41:
if ( logging_level <= 1 || !a10 )
return result;
LABEL_43:
if ( v14 == 102 )
goto LABEL_51;
v58 = v16;
v51 = v15;
v32 = func2();
return printf("[x][mknod] %s/%s %c:%ld,%ld\r\n", v32, a2, v14, v51, v58);
case 3:
v33 = func2();
return printf("[%c][mkdir] %s/%s\r\n", a10 == 0 ? 100 : 45, v33, a2);
case 4:
if ( logging_level == 1 )
{
v35 = func2();
v34 = a10 == 0 ? 120 : 33;
}
else
{
if ( a10 )
{
LABEL_51:
v36 = func2();
return printf("[x][touch] %s/%s\r\n", v36, a2);
}
v34 = 120LL;
v35 = func2();
}
result = printf("[%c][touch] %s/%s\r\n", v34, v35, a2);
if ( logging_level > 1 && a10 )
goto LABEL_51;
return result;
case 9:
if ( !a10 && logging_level == 1 )
{
v44 = func2();
printf("[x][rm] %s/%s\r\n", v44, a2);
result = logging_level;
}
if ( result > 1 )
{
LABEL_52:
v37 = func2();
result = printf("[x][rm] %s/%s\r\n", v37, a2);
}
return result;
case 10:
if ( logging_level == 1 )
{
v22 = func2();
v21 = a10 == 0 ? 120 : 33;
}
else
{
if ( a10 )
{
LABEL_29:
v23 = func2();
return printf("[x][symlink] %s/%s --> %s\r\n", v23, a2, a3);
}
v21 = 120LL;
v22 = func2();
}
result = printf("[%c][symlink] %s/%s --> %s\r\n", v21, v22, a2, a3);
if ( logging_level <= 1 )
return result;
LABEL_28:
if ( a10 )
goto LABEL_29;
return result;
case 11:
if ( logging_level == 1 )
{
v19 = func2();
v18 = a10 == 0 ? 120 : 33;
}
else
{
if ( a10 )
{
LABEL_23:
v20 = func2();
return printf("[x][hardlink] %s/%s --> %s\r\n", v20, a2, a3);
}
v18 = 120LL;
v19 = func2();
}
result = printf("[%c][hardlink] %s/%s --> %s\r\n", v18, v19, a2, a3);
if ( logging_level > 1 )
{
LABEL_22:
if ( a10 )
goto LABEL_23;
}
break;
default:
if ( logging_level != 1 )
{
switch ( a1 )
{
case 5:
v42 = func2();
return printf("[p][chmod] %s/%s %d\r\n", v42, a2, a4);
case 6:
v59 = a6;
v52 = v12;
v41 = func2();
return printf("[o][chown] %s/%s %ld:%ld\r\n", v41, a2, v52, v59);
case 7:
v38 = func2();
printf("[t][filetype] %s/%s: ", v38, a2);
v39 = a4 & 0xF000;
if ( v39 == 24576 )
{
puts("BLOCK DEVICE NODE\r");
}
else
{
if ( v39 > 0x6000 )
{
switch ( v39 )
{
case 0xA000u:
puts("SYMBOLIC LINK\r");
goto LABEL_58;
case 0xC000u:
puts("SOCKET\r");
goto LABEL_58;
case 0x8000u:
puts("REGULAR FILE\r");
goto LABEL_58;
}
}
else
{
switch ( v39 )
{
case 0x2000u:
puts("CHARACTER DEVICE NODE\r");
goto LABEL_58;
case 0x4000u:
puts("DIRECTORY\r");
goto LABEL_58;
case 0x1000u:
puts("FIFO\r");
goto LABEL_58;
}
}
puts("UNKNOWN FILETYPE\r");
}
LABEL_58:
v40 = func2();
result = printf("[p][chmod] %s/%s %04o\r\n", v40, a2, a4 & 0x1FF);
break;
case 8:
v43 = logPath;
if ( !logPath )
v43 = "[fs root]";
return printf("[-][chdir] %s\r\n", v43, a3, v12);
case 9:
goto LABEL_52;
case 10:
goto LABEL_28;
case 11:
goto LABEL_22;
default:
return result;
}
}
return result;
}
}
return result;
}

original_code:
void log_action(int actiontype, char *fname, char *target,
  mode_t mode, unsigned long uid, unsigned long gid,
  int type, unsigned long major, unsigned long minor,
  int overwrite )
{
 if ( actiontype == 8 )
  internal_log_chdir(fname);
 if ( logging_level < 1 )
  return;
 int type2;
 switch (type) {
 case 1: type2 = 'f'; break;
 case 5: type2 = 'p'; break;
 case 6: type2 = 's'; break;
 case 3: type2 = 'c'; break;
 case 4: type2 = 'b'; break;
 default: type2 = type;
 }
 switch ( actiontype ) {
 case 1:
  if ((( logging_level == 1 ) && ( overwrite )) || ( !overwrite ))
   printf("[%c][write]     %s/%s\r\n", overwrite ? '!' : 'x', log_cwd(), fname);
  break;
 case 2:
  if ((( logging_level == 1 ) && ( overwrite )) || ( !overwrite )) {
   if ( type2 == 'f' )
    printf("[x][touch]    %s/%s\r\n", log_cwd(), fname);
   else
    printf("[%c][mknod]    %s/%s %c:%ld,%ld\r\n", overwrite ? '!' : 'x', log_cwd(), fname, type2, major, minor);
  }
  break;
 case 3:
  printf("[%c][mkdir]    %s/%s\r\n", overwrite ? '-' : 'd', log_cwd(), fname);
  break;
 case 4:
  if ((( logging_level == 1 ) && ( overwrite )) || ( !overwrite ))
   printf("[%c][touch]    %s/%s\r\n", overwrite ? '!' : 'x', log_cwd(), fname);
  break;
 case 9:
  if (( logging_level == 1 ) && ( !overwrite ))
   printf("[x][rm]       %s/%s\r\n", log_cwd(), fname);
  break;
 case 10:
  if ((( logging_level == 1 ) && ( overwrite )) || ( !overwrite ))
   printf("[%c][symlink]  %s/%s --> %s\r\n", overwrite ? '!' : 'x', log_cwd(), fname, target);
  break;
 case 11:
  if ((( logging_level == 1 ) && ( overwrite )) || ( !overwrite ))
   printf("[%c][hardlink] %s/%s --> %s\r\n", overwrite ? '!' : 'x', log_cwd(), fname, target);
  break;
 }
 if ( logging_level < 2 )
  return;
 switch ( actiontype ) {
 case 1:
  if ( overwrite )
   printf("[x][write]     %s/%s\r\n", log_cwd(), fname);
  break;
 case 2:
  if ( overwrite ) {
   if ( type2 == 'f' )
    printf("[x][touch]    %s/%s\r\n", log_cwd(), fname);
   else
    printf("[x][mknod]    %s/%s %c:%ld,%ld\r\n", log_cwd(), fname, type2, major, minor);
  }
  break;
 case 4:
  if ( overwrite )
   printf("[x][touch]    %s/%s\r\n", log_cwd(), fname);
  break;
 case 5:
  printf("[p][chmod]    %s/%s %d\r\n", log_cwd(), fname, mode);
  break;
 case 6:
  printf("[o][chown]    %s/%s %ld:%ld\r\n", log_cwd(), fname, uid, gid);
  break;
 case 7:
  printf("[t][filetype] %s/%s: ", log_cwd(), fname);
  switch (( mode ) & 00170000 ) {
  case 0120000: printf("SYMBOLIC LINK\r\n"); break;
  case 0100000: printf("REGULAR FILE\r\n"); break;
  case 0040000: printf("DIRECTORY\r\n"); break;
  case 0020000: printf("CHARACTER DEVICE NODE\r\n"); break;
  case 0060000: printf("BLOCK DEVICE NODE\r\n"); break;
  case 0010000: printf("FIFO\r\n"); break;
  case 0140000: printf("SOCKET\r\n"); break;
  default: printf("UNKNOWN FILETYPE\r\n");
  }
  printf("[p][chmod]    %s/%s %04o\r\n", log_cwd(), fname, mode & 0777);
  break;
 case 8:
  printf("[-][chdir]    %s\r\n", logPath ? logPath : "[fs root]");
  break;
 case 9:
  printf("[x][rm]       %s/%s\r\n", log_cwd(), fname);
  break;
 case 10:
  if ( overwrite )
   printf("[x][symlink]  %s/%s --> %s\r\n", log_cwd(), fname, target);
  break;
 case 11:
  if ( overwrite )
   printf("[x][hardlink]  %s/%s --> %s\r\n", log_cwd(), fname, target);
  break;
 }
}

canonical_original_code:
void log_action(int actiontype, char *fname, char *target, unsigned int mode, unsigned long uid, unsigned long gid, int type, unsigned long major, unsigned long minor, int overwrite)
{
 if ( actiontype == 8 )
  internal_log_chdir(fname);
 if ( logging_level < 1 )
  return;
 int type2;
 switch (type) {
 case 1: type2 = 'f'; break;
 case 5: type2 = 'p'; break;
 case 6: type2 = 's'; break;
 case 3: type2 = 'c'; break;
 case 4: type2 = 'b'; break;
 default: type2 = type;
 }
 switch ( actiontype ) {
 case 1:
  if ((( logging_level == 1 ) && ( overwrite )) || ( !overwrite ))
   printf("[%c][write]     %s/%s\r\n", overwrite ? '!' : 'x', log_cwd(), fname);
  break;
 case 2:
  if ((( logging_level == 1 ) && ( overwrite )) || ( !overwrite )) {
   if ( type2 == 'f' )
    printf("[x][touch]    %s/%s\r\n", log_cwd(), fname);
   else
    printf("[%c][mknod]    %s/%s %c:%ld,%ld\r\n", overwrite ? '!' : 'x', log_cwd(), fname, type2, major, minor);
  }
  break;
 case 3:
  printf("[%c][mkdir]    %s/%s\r\n", overwrite ? '-' : 'd', log_cwd(), fname);
  break;
 case 4:
  if ((( logging_level == 1 ) && ( overwrite )) || ( !overwrite ))
   printf("[%c][touch]    %s/%s\r\n", overwrite ? '!' : 'x', log_cwd(), fname);
  break;
 case 9:
  if (( logging_level == 1 ) && ( !overwrite ))
   printf("[x][rm]       %s/%s\r\n", log_cwd(), fname);
  break;
 case 10:
  if ((( logging_level == 1 ) && ( overwrite )) || ( !overwrite ))
   printf("[%c][symlink]  %s/%s --> %s\r\n", overwrite ? '!' : 'x', log_cwd(), fname, target);
  break;
 case 11:
  if ((( logging_level == 1 ) && ( overwrite )) || ( !overwrite ))
   printf("[%c][hardlink] %s/%s --> %s\r\n", overwrite ? '!' : 'x', log_cwd(), fname, target);
  break;
 }
 if ( logging_level < 2 )
  return;
 switch ( actiontype ) {
 case 1:
  if ( overwrite )
   printf("[x][write]     %s/%s\r\n", log_cwd(), fname);
  break;
 case 2:
  if ( overwrite ) {
   if ( type2 == 'f' )
    printf("[x][touch]    %s/%s\r\n", log_cwd(), fname);
   else
    printf("[x][mknod]    %s/%s %c:%ld,%ld\r\n", log_cwd(), fname, type2, major, minor);
  }
  break;
 case 4:
  if ( overwrite )
   printf("[x][touch]    %s/%s\r\n", log_cwd(), fname);
  break;
 case 5:
  printf("[p][chmod]    %s/%s %d\r\n", log_cwd(), fname, mode);
  break;
 case 6:
  printf("[o][chown]    %s/%s %ld:%ld\r\n", log_cwd(), fname, uid, gid);
  break;
 case 7:
  printf("[t][filetype] %s/%s: ", log_cwd(), fname);
  switch (( mode ) & 00170000 ) {
  case 0120000: printf("SYMBOLIC LINK\r\n"); break;
  case 0100000: printf("REGULAR FILE\r\n"); break;
  case 0040000: printf("DIRECTORY\r\n"); break;
  case 0020000: printf("CHARACTER DEVICE NODE\r\n"); break;
  case 0060000: printf("BLOCK DEVICE NODE\r\n"); break;
  case 0010000: printf("FIFO\r\n"); break;
  case 0140000: printf("SOCKET\r\n"); break;
  default: printf("UNKNOWN FILETYPE\r\n");
  }
  printf("[p][chmod]    %s/%s %04o\r\n", log_cwd(), fname, mode & 0777);
  break;
 case 8:
  printf("[-][chdir]    %s\r\n", logPath ? logPath : "[fs root]");
  break;
 case 9:
  printf("[x][rm]       %s/%s\r\n", log_cwd(), fname);
  break;
 case 10:
  if ( overwrite )
   printf("[x][symlink]  %s/%s --> %s\r\n", log_cwd(), fname, target);
  break;
 case 11:
  if ( overwrite )
   printf("[x][hardlink]  %s/%s --> %s\r\n", log_cwd(), fname, target);
  break;
 }
}

variable_types: actiontype int

variable_types:
fname
char *

variable_types:
target
char *

variable_types:
mode
unsigned int

variable_types:
uid
unsigned long

variable_types:
gid
unsigned long

variable_types: type int

variable_types:
major
unsigned long

variable_types:
minor
unsigned long

variable_types: overwrite int


decompiled_code:
void log_warning(char *format, ...)
{
char *v1; // rax
char *v2; // rbp
_QWORD *v3; // rax
_QWORD *v4; // rbx
char **v5; // rax
char **v6; // r12
size_t v7; // r13
char *v8; // rax
gcc_va_list arg; // [rsp+8h] [rbp-F0h] BYREF

v1 = (char *)malloc(0x202uLL);
v2 = v1;
if ( !v1 )
log_error("[log/log_warning] Memory allocation error (tmpS)");
va_start(arg, format);
vsnprintf(v1, 0x200uLL, format, arg);
v3 = warning_list;
if ( warning_list )
{
do
{
v4 = v3;
v3 = (_QWORD *)v3[1];
}
while ( v3 );
v5 = (char **)malloc(0x10uLL);
v4[1] = v5;
v6 = v5;
}
else
{
warning_list = malloc(0x10uLL);
v6 = (char **)warning_list;
}
v7 = strlen(v2) + 1;
v8 = (char *)calloc(v7, 1uLL);
*v6 = v8;
snprintf(v8, v7, "%s", v2);
v6[1] = 0LL;
free(v2);
}

canonical_decompiled_code:
void func10(char *format, ...)
{
char *v1; // rax
char *v2; // rbp
_QWORD *v3; // rax
_QWORD *v4; // rbx
char **v5; // rax
char **v6; // r12
size_t v7; // r13
char *v8; // rax
gcc_va_list arg; // [rsp+8h] [rbp-F0h] BYREF

v1 = (char *)malloc(0x202uLL);
v2 = v1;
if ( !v1 )
func7("[log/log_warning] Memory allocation error (tmpS)");
va_start(arg, format);
vsnprintf(v1, 0x200uLL, format, arg);
v3 = warning_list;
if ( warning_list )
{
do
{
v4 = v3;
v3 = (_QWORD *)v3[1];
}
while ( v3 );
v5 = (char **)malloc(0x10uLL);
v4[1] = v5;
v6 = v5;
}
else
{
warning_list = malloc(0x10uLL);
v6 = (char **)warning_list;
}
v7 = strlen(v2) + 1;
v8 = (char *)calloc(v7, 1uLL);
*v6 = v8;
snprintf(v8, v7, "%s", v2);
v6[1] = 0LL;
free(v2);
}

original_code:
void log_warning(const char *s, ...)
{
 char *tmpS = ((void *)0);
 va_list p;
 warning_nodeT *node;
 size_t len;
 tmpS = (char*)malloc(512 + 2);
 if ( !tmpS )
  log_error("[log/log_warning] Memory allocation error (tmpS)");
 __builtin_va_start(p,s);
 vsnprintf(tmpS, 512, s, p);
 if ( !warning_list ) {
  warning_list = (warning_nodeT*)malloc(sizeof(warning_nodeT));
  node = warning_list;
 } else {
  node = warning_list;
  while ( node->next != ((void *)0) )
   node = node->next;
  node->next = (warning_nodeT*)malloc(sizeof(warning_nodeT));
  node = node->next;
 }
 len = strlen(tmpS);
 node->str = (char*)malloc(len + 1);
 memset(node->str, 0, len + 1);
 snprintf(node->str, len + 1, "%s", tmpS);
 node->next = ((void *)0);
 free( tmpS );
 tmpS = ((void *)0);
}

canonical_original_code:
void log_warning(char *s, ...)
{
 char *tmpS = ((void *)0);
 __builtin_va_list p;
 struct warning_node *node;
 unsigned long len;
 tmpS = (char *)malloc(512 + 2);
 if ( !tmpS )
  log_error("[log/log_warning] Memory allocation error (tmpS)");
 __builtin_va_start(p,s);
 vsnprintf(tmpS, 512, s, p);
 if ( !warning_list ) {
  warning_list = (struct warning_node *)malloc(sizeof(warning_nodeT));
  node = warning_list;
 } else {
  node = warning_list;
  while ( node->next != ((void *)0) )
   node = node->next;
  node->next = (struct warning_node *)malloc(sizeof(warning_nodeT));
  node = node->next;
 }
 len = strlen(tmpS);
 node->str = (char *)malloc(len + 1);
 memset(node->str, 0, len + 1);
 snprintf(node->str, len + 1, "%s", tmpS);
 node->next = ((void *)0);
 free( tmpS );
 tmpS = ((void *)0);
}

variable_types:
tmpS
char *

variable_types:
len
unsigned long


decompiled_code:
void clear_warnings()
{
void **i; // rbp
void *v1; // rdi

for ( i = (void **)warning_list; warning_list; i = (void **)warning_list )
{
v1 = *i;
warning_list = i[1];
free(v1);
free(i);
}
warning_list = 0LL;
}

canonical_decompiled_code:
void func11()
{
void **i; // rbp
void *v1; // rdi

for ( i = (void **)warning_list; warning_list; i = (void **)warning_list )
{
v1 = *i;
warning_list = i[1];
free(v1);
free(i);
}
warning_list = 0LL;
}

original_code:
void clear_warnings(void)
{
 while ( warning_list ) {
  warning_nodeT *node = warning_list;
  warning_list = node->next;
  node->next = ((void *)0);
  free( node->str );
  node->str = ((void *)0);
  free( node );
  node = ((void *)0);
 }
 warning_list = ((void *)0);
}

canonical_original_code:
void clear_warnings()
{
 while ( warning_list ) {
  struct warning_node *node = warning_list;
  warning_list = node->next;
  node->next = ((void *)0);
  free( node->str );
  node->str = ((void *)0);
  free( node );
  node = ((void *)0);
 }
 warning_list = ((void *)0);
}


decompiled_code:
void release_log()
{
if ( logPath )
{
free(logPath);
logPath = 0LL;
}
clear_warnings();
}

canonical_decompiled_code:
void func12()
{
if ( logPath )
{
free(logPath);
logPath = 0LL;
}
func11();
}

original_code:
void release_log(void)
{
 if ( logPath ) {
  free(logPath);
  logPath = ((void *)0);
 }
 clear_warnings();
}

canonical_original_code:
void release_log()
{
 if ( logPath ) {
  free(logPath);
  logPath = ((void *)0);
 }
 clear_warnings();
}


decompiled_code:
__int64 __fastcall linklist_add(__int64 a1, __int64 a2, const char *a3)
{
_QWORD *v4; // rdx
_QWORD *v5; // rbx
_QWORD *v7; // rax
_QWORD *v8; // r13
char *v9; // rax

v4 = linklist;
if ( !linklist )
{
linklist = malloc(0x20uLL);
v8 = linklist;
LABEL_10:
*v8 = a1;
v8[1] = a2;
v9 = strdup(a3);
v8[3] = 0LL;
v8[2] = v9;
return 0LL;
}
v5 = (_QWORD *)*((_QWORD *)linklist + 3);
if ( !v5 )
{
v5 = linklist;
LABEL_9:
v7 = malloc(0x20uLL);
v5[3] = v7;
v8 = v7;
goto LABEL_10;
}
while ( v4[1] != a2 || *v4 != a1 )
{
v4 = v5;
if ( !v5[3] )
goto LABEL_9;
v5 = (_QWORD *)v5[3];
}
return v4[2];
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, const char *a3)
{
_QWORD *v4; // rdx
_QWORD *v5; // rbx
_QWORD *v7; // rax
_QWORD *v8; // r13
char *v9; // rax

v4 = linklist;
if ( !linklist )
{
linklist = malloc(0x20uLL);
v8 = linklist;
LABEL_10:
*v8 = a1;
v8[1] = a2;
v9 = strdup(a3);
v8[3] = 0LL;
v8[2] = v9;
return 0LL;
}
v5 = (_QWORD *)*((_QWORD *)linklist + 3);
if ( !v5 )
{
v5 = linklist;
LABEL_9:
v7 = malloc(0x20uLL);
v5[3] = v7;
v8 = v7;
goto LABEL_10;
}
while ( v4[1] != a2 || *v4 != a1 )
{
v4 = v5;
if ( !v5[3] )
goto LABEL_9;
v5 = (_QWORD *)v5[3];
}
return v4[2];
}

original_code:
char *linklist_add(dev_t dev_id, ino_t inode_num, char *name)
{
 linklistT *node;
 if ( linklist != ((void *)0) ) {
  node = linklist;
  while ( node->next != ((void *)0) )
   if (( node->inode_num == inode_num ) && ( node->dev_id == dev_id ))
    return node->name;
   else node = node->next;
  node->next = (linklistT*)malloc(sizeof(linklistT));
  node = node->next;
 } else {
  linklist = (linklistT*)malloc(sizeof(linklistT));
  node = linklist;
 }
 node->dev_id = dev_id;
 node->inode_num = inode_num;
 node->name = strdup(name);
 node->next = ((void *)0);
 return ((void *)0);
}

canonical_original_code:
char *linklist_add(unsigned long dev_id, unsigned long inode_num, char *name)
{
 struct linklist_node *node;
 if ( linklist != ((void *)0) ) {
  node = linklist;
  while ( node->next != ((void *)0) )
   if (( node->inode_num == inode_num ) && ( node->dev_id == dev_id ))
    return node->name;
   else node = node->next;
  node->next = (struct linklist_node *)malloc(sizeof(linklistT));
  node = node->next;
 } else {
  linklist = (struct linklist_node *)malloc(sizeof(linklistT));
  node = linklist;
 }
 node->dev_id = dev_id;
 node->inode_num = inode_num;
 node->name = strdup(name);
 node->next = ((void *)0);
 return ((void *)0);
}

variable_types:
name
char *

variable_types: struct linklist_node { unsigned long dev_id; unsigned long inode_num; char *name; struct linklist_node *next; } *


decompiled_code:
void linklist_release()
{
_QWORD *v0; // rbx
_QWORD *v1; // rbp
void *v2; // rdi

v0 = linklist;
if ( linklist )
{
do
{
v1 = v0;
v0 = (_QWORD *)v0[3];
v2 = (void *)v1[2];
linklist = v0;
free(v2);
free(v1);
}
while ( v0 );
}
}

canonical_decompiled_code:
void func1()
{
_QWORD *v0; // rbx
_QWORD *v1; // rbp
void *v2; // rdi

v0 = linklist;
if ( linklist )
{
do
{
v1 = v0;
v0 = (_QWORD *)v0[3];
v2 = (void *)v1[2];
linklist = v0;
free(v2);
free(v1);
}
while ( v0 );
}
}

original_code:
void linklist_release(void)
{
 while ( linklist != ((void *)0) ) {
  linklistT *node = linklist;
  linklist = node->next;
  node->next = ((void *)0);
  free( node->name);
  node->name = ((void *)0);
  free( node );
  node = ((void *)0);
 }
}

canonical_original_code:
void linklist_release()
{
 while ( linklist != ((void *)0) ) {
  struct linklist_node *node = linklist;
  linklist = node->next;
  node->next = ((void *)0);
  free( node->name);
  node->name = ((void *)0);
  free( node );
  node = ((void *)0);
 }
}

user_defined_types: struct linklist_node { unsigned long dev_id; unsigned long inode_num; char *name; struct linklist_node *next; }


original_code:
unsigned long oct2dec(unsigned long int value)
{
 unsigned long int oct, dec = 0;
 int i = 0;
 oct = value;
 while ( oct != 0 ) {
  dec = dec + (oct % 10) * pow(8, i++);
  oct = oct / 10;
 }
 return dec;
}

canonical_original_code:
unsigned long oct2dec(unsigned long value)
{
 unsigned long oct; unsigned long dec = 0;
 int i = 0;
 oct = value;
 while ( oct != 0 ) {
  dec = dec + (oct % 10) * pow(8, i++);
  oct = oct / 10;
 }
 return dec;
}

variable_types:
value
unsigned long

variable_types:
oct
unsigned long

variable_types:
dec
unsigned long

variable_types: i int

return_type: unsigned long


repo: osmanbaskaya/tr-text-normalization

decompiled_code:
__int64 __fastcall ngram_hash_function(int *a1)
{
int v1; // eax
__int64 v2; // rdx
unsigned int v3; // er8
int v4; // eax

v1 = *a1;
if ( !*a1 )
return 0LL;
v2 = 0LL;
v3 = 0;
do
{
v4 = ngram_hash_rnd[v2++] * v1;
v3 += v4;
v1 = a1[v2];
}
while ( v1 );
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func0(int *a1)
{
int v1; // eax
__int64 v2; // rdx
unsigned int v3; // er8
int v4; // eax

v1 = *a1;
if ( !*a1 )
return 0LL;
v2 = 0LL;
v3 = 0;
do
{
v4 = ngram_hash_rnd[v2++] * v1;
v3 += v4;
v1 = a1[v2];
}
while ( v1 );
return v3;
}

original_code:
guint ngram_hash_function(Ngram ng) {
  guint hash = 0;
  for (int i = 0; ng[i] != 0; i++) {
    hash += ng[i] * ngram_hash_rnd[i];
  }
  return hash;
}

canonical_original_code:
unsigned int ngram_hash_function(unsigned int *ng) {
  unsigned int hash = 0;
  for (int i = 0; ng[i] != 0; i++) {
    hash += ng[i] * ngram_hash_rnd[i];
  }
  return hash;
}

variable_types:
ng
unsigned int *

variable_types:
hash
unsigned int

return_type: unsigned int


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

if ( a1 )
result = g_free();
return result;
}

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

if ( a1 )
result = g_free();
return result;
}

original_code: void ngram_free(gpointer p) { if (p != ((void *)0)) g_free(p); }

canonical_original_code: void ngram_free(void *p) { if (p != ((void *)0)) g_free(p); }

variable_types:
p
void *


decompiled_code:
// attributes: thunk
__int64 __fastcall logprob_free(__int64 a1)
{
return ngram_free(a1);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
return func2(a1);
}

original_code: void logprob_free(gpointer p) { if (p != ((void *)0)) g_free(p); }

canonical_original_code: void logprob_free(void *p) { if (p != ((void *)0)) g_free(p); }


decompiled_code:
__int64 g_message_init()
{
return g_log_set_handler(0LL, 32LL, my_log_func, 0LL);
}

canonical_decompiled_code:
__int64 func4()
{
return g_log_set_handler(0LL, 32LL, my_log_func, 0LL);
}

original_code:
static void g_message_init()
{
  g_log_set_handler(((void *)0), G_LOG_LEVEL_MESSAGE, my_log_func, ((void *)0));
}


runtime

decompiled_code:
time_t runtime()
{
time_t v0; // rax

v0 = time(0LL);
if ( t0_0 )
return v0 - t0_0;
t0_0 = v0;
return 0LL;
}

canonical_decompiled_code:
time_t func6()
{
time_t v0; // rax

v0 = time(0LL);
if ( t0_0 )
return v0 - t0_0;
t0_0 = v0;
return 0LL;
}

original_code:
static unsigned long runtime() {
  static time_t t0 = 0;
  time_t t1 = time(((void *)0));
  if (t0 == 0) t0 = t1;
  return t1-t0;
}

canonical_original_code:
static unsigned long runtime() {
  static long t0 = 0;
  long t1 = time(((void *)0));
  if (t0 == 0) t0 = t1;
  return t1-t0;
}


decompiled_code:
int __fastcall my_log_func(__int64 a1, __int64 a2, const char *a3)
{
__int64 v4; // r12
time_t v5; // rax

v4 = memory();
v5 = runtime();
return fprintf(stderr, "[t=%lu m=%llu] %s\n", v5, v4, a3);
}

canonical_decompiled_code:
int __fastcall func7(__int64 a1, __int64 a2, const char *a3)
{
__int64 v4; // r12
time_t v5; // rax

v4 = func5();
v5 = func6();
return fprintf(stderr, "[t=%lu m=%llu] %s\n", v5, v4, a3);
}

original_code:
static void my_log_func(const gchar *log_domain,
   GLogLevelFlags log_level,
   const gchar *message,
   gpointer user_data) {
  fprintf(stderr, "[t=%lu m=%llu] %s\n",
   runtime(), memory(), message);
}

canonical_original_code:
static void my_log_func(char *log_domain, enum GLogLevelFlags log_level, char *message, void *user_data) {
  fprintf(stderr, "[t=%lu m=%llu] %s\n",
   runtime(), memory(), message);
}

variable_types: enum GLogLevelFlags { G_LOG_FLAG_RECURSION=expr, G_LOG_FLAG_FATAL=expr, G_LOG_LEVEL_ERROR=expr, G_LOG_LEVEL_CRITICAL=expr, G_LOG_LEVEL_WARNING=expr, G_LOG_LEVEL_MESSAGE=expr, G_LOG_LEVEL_INFO=expr, G_LOG_LEVEL_DEBUG=expr, G_LOG_LEVEL_MASK=expr }

variable_types:
message
char *


decompiled_code:
__int64 __fastcall ngram_size(_DWORD *a1)
{
__int64 v1; // rax
unsigned int v2; // er8

if ( !*a1 )
return 0LL;
v1 = 1LL;
do
v2 = v1++;
while ( a1[v1 - 1] );
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func11(_DWORD *a1)
{
__int64 v1; // rax
unsigned int v2; // er8

if ( !*a1 )
return 0LL;
v1 = 1LL;
do
v2 = v1++;
while ( a1[v1 - 1] );
return v2;
}

original_code:
int ngram_size(Ngram ng) {
  int n = 0;
  while (ng[n] != 0) n++;
  return n;
}

canonical_original_code:
int ngram_size(unsigned int *ng) {
  int n = 0;
  while (ng[n] != 0) n++;
  return n;
}

variable_types: n int


decompiled_code:
__int64 __fastcall ngram_to_gstring(__int64 *a1, unsigned int *a2)
{
_DWORD *v3; // rbx
__int64 v4; // rdi
__int64 v5; // rax

v3 = a2;
g_string_truncate(a1, 0LL);
v4 = *a2;
if ( (_DWORD)v4 )
{
while ( 1 )
{
v5 = g_quark_to_string(v4);
++v3;
g_string_append(a1, v5);
if ( !*v3 )
break;
g_string_append_c_inline_constprop_0_isra_0(a1);
v4 = (unsigned int)*v3;
}
}
return *a1;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 *a1, unsigned int *a2)
{
_DWORD *v3; // rbx
__int64 v4; // rdi
__int64 v5; // rax

v3 = a2;
g_string_truncate(a1, 0LL);
v4 = *a2;
if ( (_DWORD)v4 )
{
while ( 1 )
{
v5 = g_quark_to_string(v4);
++v3;
g_string_append(a1, v5);
if ( !*v3 )
break;
func8(a1);
v4 = (unsigned int)*v3;
}
}
return *a1;
}

original_code:
char *ngram_to_gstring(GString *g, Ngram ng) {
  g_string_truncate(g, 0);
  for (int n = 0; ng[n] != 0; n++) {
    if (n > 0) g_string_append_c_inline (g, ' ');
    g_string_append(g, g_quark_to_string(ng[n]));
  }
  return g->str;
}

canonical_original_code:
char *ngram_to_gstring(struct _GString *g, unsigned int *ng) {
  g_string_truncate(g, 0);
  for (int n = 0; ng[n] != 0; n++) {
    if (n > 0) g_string_append_c_inline (g, ' ');
    g_string_append(g, g_quark_to_string(ng[n]));
  }
  return g->str;
}

variable_types: struct _GString { char *str; unsigned long len; unsigned long allocated_len; } *


decompiled_code:
void *__fastcall ngram_dup(void *src)
{
size_t v1; // r12
void *v2; // rax

v1 = 4LL * (unsigned int)(*(_DWORD *)src + 1);
v2 = (void *)minialloc(v1);
return memcpy(v2, src, v1);
}

canonical_decompiled_code:
void *__fastcall func1(void *src)
{
size_t v1; // r12
void *v2; // rax

v1 = 4LL * (unsigned int)(*(_DWORD *)src + 1);
v2 = (void *)minialloc(v1);
return memcpy(v2, src, v1);
}

original_code:
Ngram ngram_dup(Ngram ng) {
  gsize size = (sizeof(Token) * (((ng)[0])+1));
  Ngram ngcopy = minialloc(size);
  memcpy(ngcopy, ng, size);
  return ngcopy;
}

canonical_original_code:
unsigned int *ngram_dup(unsigned int *ng) {
  unsigned long size = (sizeof(Token) * (((ng)[0])+1));
  unsigned int *ngcopy = minialloc(size);
  memcpy(ngcopy, ng, size);
  return ngcopy;
}

variable_types:
size
unsigned long

variable_types:
ngcopy
unsigned int *

return_type: unsigned int *


decompiled_code:
void *__fastcall ngram_cpy(void *a1, _DWORD *a2)
{
return memcpy(a1, a2, 4LL * (unsigned int)(*a2 + 1));
}

canonical_decompiled_code:
void *__fastcall func3(void *a1, _DWORD *a2)
{
return memcpy(a1, a2, 4LL * (unsigned int)(*a2 + 1));
}

original_code:
Ngram ngram_cpy(Ngram ngcopy, Ngram ng) {
  gsize size = (sizeof(Token) * (((ng)[0])+1));
  memcpy(ngcopy, ng, size);
  return ngcopy;
}

canonical_original_code:
unsigned int *ngram_cpy(unsigned int *ngcopy, unsigned int *ng) {
  unsigned long size = (sizeof(Token) * (((ng)[0])+1));
  memcpy(ngcopy, ng, size);
  return ngcopy;
}


decompiled_code:
__int64 __fastcall ngram_hash(int *a1)
{
__int64 v1; // rax
unsigned int i; // er8
int v3; // edx

if ( !ngram_hash_rnd[0] )
init_ngram_hash_rnd();
v1 = *a1;
for ( i = 0; (int)v1 > 0; i += v3 )
{
v3 = ngram_hash_rnd[v1] * a1[v1];
--v1;
}
return i;
}

canonical_decompiled_code:
__int64 __fastcall func4(int *a1)
{
__int64 v1; // rax
unsigned int i; // er8
int v3; // edx

if ( !ngram_hash_rnd[0] )
func0();
v1 = *a1;
for ( i = 0; (int)v1 > 0; i += v3 )
{
v3 = ngram_hash_rnd[v1] * a1[v1];
--v1;
}
return i;
}

original_code:
guint ngram_hash(gconstpointer p) {
  if (*ngram_hash_rnd == 0) init_ngram_hash_rnd();
  const Token *ng = p;
  guint hash = 0;
  for (int i = ((ng)[0]); i > 0; i--) {
    hash += ng[i] * ngram_hash_rnd[i];
  }
  return hash;
}

canonical_original_code:
unsigned int ngram_hash(void *p) {
  if (*ngram_hash_rnd == 0) init_ngram_hash_rnd();
  unsigned int *ng = p;
  unsigned int hash = 0;
  for (int i = ((ng)[0]); i > 0; i--) {
    hash += ng[i] * ngram_hash_rnd[i];
  }
  return hash;
}


decompiled_code:
int *init_ngram_hash_rnd()
{
int *result; // rax
int *i; // rbx
int v2; // eax

result = (int *)(unsigned int)ngram_hash_rnd;
if ( !ngram_hash_rnd )
{
for ( i = (int *)&unk_11BC; ; --i )
{
do
v2 = g_random_int();
while ( !v2 );
*i = v2;
result = i - 1;
if ( i == &ngram_hash_rnd )
break;
}
}
return result;
}

canonical_decompiled_code:
int *func0()
{
int *result; // rax
int *i; // rbx
int v2; // eax

result = (int *)(unsigned int)ngram_hash_rnd;
if ( !ngram_hash_rnd )
{
for ( i = (int *)&unk_11BC; ; --i )
{
do
v2 = g_random_int();
while ( !v2 );
*i = v2;
result = i - 1;
if ( i == &ngram_hash_rnd )
break;
}
}
return result;
}

original_code:
static void init_ngram_hash_rnd() {
  guint32 r;
  if (*ngram_hash_rnd == 0) {
    for (int i = 1023; i >= 0; i--) {
      do {
 r = g_random_int();
      } while (r == 0);
      ngram_hash_rnd[i] = r;
    }
  }
}

canonical_original_code:
static void init_ngram_hash_rnd() {
  unsigned int r;
  if (*ngram_hash_rnd == 0) {
    for (int i = 1023; i >= 0; i--) {
      do {
 r = g_random_int();
      } while (r == 0);
      ngram_hash_rnd[i] = r;
    }
  }
}

variable_types:
r
unsigned int


decompiled_code:
void *__fastcall ngram_from_string(char *a1)
{
int v1; // ebp
char *v2; // rax
char *v3; // rdi
__int64 v4; // rbx
char *save_ptr; // [rsp+8h] [rbp-1020h] BYREF
int src[1030]; // [rsp+10h] [rbp-1018h] BYREF

v1 = 0;
save_ptr = 0LL;
v2 = strtok_r(a1, delim, &save_ptr);
if ( v2 )
{
v3 = v2;
v4 = 1LL;
while ( 1 )
{
v1 = v4;
src[v4] = g_quark_from_string(v3);
v3 = strtok_r(0LL, delim, &save_ptr);
if ( !v3 )
break;
if ( ++v4 == 1024 )
{
g_assertion_message_expr(0LL, "ngram.c", 10LL, "ngram_from_string", "ntok < MAX_NGRAM_ORDER");
break;
}
}
}
src[0] = v1;
return ngram_dup(src);
}

canonical_decompiled_code:
void *__fastcall func2(char *a1)
{
int v1; // ebp
char *v2; // rax
char *v3; // rdi
__int64 v4; // rbx
char *save_ptr; // [rsp+8h] [rbp-1020h] BYREF
int src[1030]; // [rsp+10h] [rbp-1018h] BYREF

v1 = 0;
save_ptr = 0LL;
v2 = strtok_r(a1, delim, &save_ptr);
if ( v2 )
{
v3 = v2;
v4 = 1LL;
while ( 1 )
{
v1 = v4;
src[v4] = g_quark_from_string(v3);
v3 = strtok_r(0LL, delim, &save_ptr);
if ( !v3 )
break;
if ( ++v4 == 1024 )
{
g_assertion_message_expr(0LL, "ngram.c", 10LL, "ngram_from_string", "ntok < MAX_NGRAM_ORDER");
break;
}
}
}
src[0] = v1;
return func1(src);
}

original_code:
Ngram ngram_from_string(char *str) {
  Token ng[1 + 1023];
  int ntok = 0;
  for (char *_ptr = ((void *)0), *(word) = strtok_r((str), " \t\n\r\f\v", &_ptr); (word) != ((void *)0); (word) = strtok_r(((void *)0)," \t\n\r\f\v", &_ptr)) {
    do { if (ntok < 1023) ; else g_assertion_message_expr (((gchar*) 0), "ngram.c", 10, ((const char*) (__func__)), "ntok < MAX_NGRAM_ORDER"); } while (0);
    ng[++ntok] = g_quark_from_string(word);
  }
  ng[0] = ntok;
  return ngram_dup(ng);
}

canonical_original_code:
unsigned int *ngram_from_string(char *str) {
  unsigned int ng[-1];
  int ntok = 0;
  for (char *_ptr = ((void *)0); char *word = strtok_r((str), " \t\n\r\f\v", &_ptr); (word) != ((void *)0); (word) = strtok_r(((void *)0)," \t\n\r\f\v", &_ptr)) {
    do { if (ntok < 1023) ; else g_assertion_message_expr (((char *) 0), "ngram.c", 10, ((char *) (__func__)), "ntok < MAX_NGRAM_ORDER"); } while (0);
    ng[++ntok] = g_quark_from_string(word);
  }
  ng[0] = ntok;
  return ngram_dup(ng);
}

variable_types:
str
char *

variable_types:
ng
unsigned int [-1]

variable_types: ntok int

variable_types:
word
char *


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

v2 = *a1;
if ( (_DWORD)v2 != *a2 )
return 0LL;
while ( 1 )
{
if ( (int)v2 <= 0 )
return 1LL;
if ( a1[v2] != a2[v2] )
break;
--v2;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(int *a1, _DWORD *a2)
{
__int64 v2; // rax

v2 = *a1;
if ( (_DWORD)v2 != *a2 )
return 0LL;
while ( 1 )
{
if ( (int)v2 <= 0 )
return 1LL;
if ( a1[v2] != a2[v2] )
break;
--v2;
}
return 0LL;
}

original_code:
gboolean ngram_equal(gconstpointer pa, gconstpointer pb) {
  const Token *a = pa;
  const Token *b = pb;
  if (((a)[0]) != ((b)[0])) return 0;
  for (int i = ((a)[0]); i > 0; i--) {
    if (a[i] != b[i]) return 0;
  }
  return 1;
}

canonical_original_code:
int ngram_equal(void *pa, void *pb) {
  unsigned int *a = pa;
  unsigned int *b = pb;
  if (((a)[0]) != ((b)[0])) return 0;
  for (int i = ((a)[0]); i > 0; i--) {
    if (a[i] != b[i]) return 0;
  }
  return 1;
}

variable_types:
pa
void *

variable_types:
pb
void *

variable_types:
a
unsigned int *

variable_types:
b
unsigned int *


decompiled_code:
int __fastcall sentence_print(_DWORD *a1)
{
__int64 v2; // rbx
__int64 v3; // rdi
const char *v4; // rax

if ( *a1 )
{
v2 = 1LL;
do
{
v3 = (unsigned int)a1[v2++];
v4 = (const char *)g_quark_to_string(v3);
printf("%s ", v4);
}
while ( *a1 >= (unsigned int)v2 );
}
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func3(_DWORD *a1)
{
__int64 v2; // rbx
__int64 v3; // rdi
const char *v4; // rax

if ( *a1 )
{
v2 = 1LL;
do
{
v3 = (unsigned int)a1[v2++];
v4 = (const char *)g_quark_to_string(v3);
printf("%s ", v4);
}
while ( *a1 >= (unsigned int)v2 );
}
return putchar(10);
}

original_code:
void sentence_print(Sentence s) {
  for (int i = 1; i <= ((guint32)(*s)); i++) {
    printf("%s ", g_quark_to_string(s[i]));
  }
  printf("\n");
}

canonical_original_code:
void sentence_print(unsigned int *s) {
  for (int i = 1; i <= ((guint32)(*s)); i++) {
    printf("%s ", g_quark_to_string(s[i]));
  }
  printf("\n");
}

variable_types:
s
unsigned int *

variable_types: i int


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

SOS = g_quark_from_string(&unk_378);
EOS = g_quark_from_string("</s>");
result = g_quark_from_string("<unk>");
UNK = result;
return result;
}

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

SOS = g_quark_from_string(&unk_378);
EOS = g_quark_from_string("</s>");
result = g_quark_from_string("<unk>");
UNK = result;
return result;
}

original_code:
static void init_special_tokens() {
  SOS = g_quark_from_string("<s>");
  EOS = g_quark_from_string("</s>");
  UNK = g_quark_from_string("<unk>");
}


decompiled_code:
__int64 __fastcall sentence_from_string(_DWORD *a1, char *a2, unsigned int a3, __int64 a4)
{
unsigned int v6; // ebx
char *i; // r14
int v8; // eax
__int64 v9; // rdx
__int64 result; // rax
char *save_ptr[6]; // [rsp+8h] [rbp-30h] BYREF

if ( !SOS )
init_special_tokens();
if ( !a3 )
g_assertion_message_expr(0LL, "sentence.c", 20LL, "sentence_from_string", "ntok < nmax");
a1[1] = SOS;
if ( a4 )
*(_QWORD *)(a4 + 8) = &unk_378;
save_ptr[0] = 0LL;
v6 = 1;
for ( i = strtok_r(a2, delim, save_ptr); i; i = strtok_r(0LL, delim, save_ptr) )
{
v8 = g_quark_try_string(i);
if ( SOS != v8 && EOS != v8 )
{
if ( a3 <= v6 )
v8 = g_assertion_message_expr(0LL, "sentence.c", 26LL, "sentence_from_string", "ntok < nmax");
if ( !v8 )
v8 = UNK;
a1[++v6] = v8;
if ( a4 )
*(_QWORD *)(a4 + 8LL * v6) = i;
}
}
if ( a3 <= v6 )
g_assertion_message_expr(0LL, "sentence.c", 30LL, "sentence_from_string", "ntok < nmax");
v9 = v6 + 1;
result = v9;
a1[v9] = EOS;
if ( a4 )
*(_QWORD *)(a4 + 8 * v9) = "</s>";
*a1 = v9;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(_DWORD *a1, char *a2, unsigned int a3, __int64 a4)
{
unsigned int v6; // ebx
char *i; // r14
int v8; // eax
__int64 v9; // rdx
__int64 result; // rax
char *save_ptr[6]; // [rsp+8h] [rbp-30h] BYREF

if ( !SOS )
func0();
if ( !a3 )
g_assertion_message_expr(0LL, "sentence.c", 20LL, "sentence_from_string", "ntok < nmax");
a1[1] = SOS;
if ( a4 )
*(_QWORD *)(a4 + 8) = &unk_378;
save_ptr[0] = 0LL;
v6 = 1;
for ( i = strtok_r(a2, delim, save_ptr); i; i = strtok_r(0LL, delim, save_ptr) )
{
v8 = g_quark_try_string(i);
if ( SOS != v8 && EOS != v8 )
{
if ( a3 <= v6 )
v8 = g_assertion_message_expr(0LL, "sentence.c", 26LL, "sentence_from_string", "ntok < nmax");
if ( !v8 )
v8 = UNK;
a1[++v6] = v8;
if ( a4 )
*(_QWORD *)(a4 + 8LL * v6) = i;
}
}
if ( a3 <= v6 )
g_assertion_message_expr(0LL, "sentence.c", 30LL, "sentence_from_string", "ntok < nmax");
v9 = v6 + 1;
result = v9;
a1[v9] = EOS;
if ( a4 )
*(_QWORD *)(a4 + 8 * v9) = "</s>";
*a1 = v9;
return result;
}

original_code:
guint32 sentence_from_string(Sentence st, char *str, int nmax, char **w) {
  if (SOS == 0) init_special_tokens();
  guint32 ntok = 0;
  do { if (ntok < nmax) ; else g_assertion_message_expr (((gchar*) 0), "sentence.c", 20, ((const char*) (__func__)), "ntok < nmax"); } while (0);
  st[++ntok] = SOS;
  if (w != ((void *)0)) w[ntok] = "<s>";
  for (char *_ptr = ((void *)0), *(word) = strtok_r((str), " \t\n\r\f\v", &_ptr); (word) != ((void *)0); (word) = strtok_r(((void *)0)," \t\n\r\f\v", &_ptr)) {
    Token wtok = g_quark_try_string(word);
    if ((wtok == SOS) || (wtok == EOS)) continue;
    do { if (ntok < nmax) ; else g_assertion_message_expr (((gchar*) 0), "sentence.c", 26, ((const char*) (__func__)), "ntok < nmax"); } while (0);
    st[++ntok] = (wtok == 0 ? UNK : wtok);
    if (w != ((void *)0)) w[ntok] = word;
  }
  do { if (ntok < nmax) ; else g_assertion_message_expr (((gchar*) 0), "sentence.c", 30, ((const char*) (__func__)), "ntok < nmax"); } while (0);
  st[++ntok] = EOS;
  if (w != ((void *)0)) w[ntok] = "</s>";
  st[0] = ntok;
  return ntok;
}

canonical_original_code:
unsigned int sentence_from_string(unsigned int *st, char *str, int nmax, char **w) {
  if (SOS == 0) init_special_tokens();
  unsigned int ntok = 0;
  do { if (ntok < nmax) ; else g_assertion_message_expr (((char *) 0), "sentence.c", 20, ((char *) (__func__)), "ntok < nmax"); } while (0);
  st[++ntok] = SOS;
  if (w != ((void *)0)) w[ntok] = "<s>";
  for (char *_ptr = ((void *)0); char *word = strtok_r((str), " \t\n\r\f\v", &_ptr); (word) != ((void *)0); (word) = strtok_r(((void *)0)," \t\n\r\f\v", &_ptr)) {
    unsigned int wtok = g_quark_try_string(word);
    if ((wtok == SOS) || (wtok == EOS)) continue;
    do { if (ntok < nmax) ; else g_assertion_message_expr (((char *) 0), "sentence.c", 26, ((char *) (__func__)), "ntok < nmax"); } while (0);
    st[++ntok] = (wtok == 0 ? UNK : wtok);
    if (w != ((void *)0)) w[ntok] = word;
  }
  do { if (ntok < nmax) ; else g_assertion_message_expr (((char *) 0), "sentence.c", 30, ((char *) (__func__)), "ntok < nmax"); } while (0);
  st[++ntok] = EOS;
  if (w != ((void *)0)) w[ntok] = "</s>";
  st[0] = ntok;
  return ntok;
}

variable_types:
st
unsigned int *

variable_types: nmax int

variable_types:
w
char **

variable_types:
ntok
unsigned int

variable_types:
wtok
unsigned int


canonical_decompiled_code:
__int64 func0()
{
return g_log_set_handler(0LL, 32LL, my_log_func, 0LL);
}

canonical_original_code:
static void g_message_init()
{
  g_log_set_handler(((void *)0), G_LOG_LEVEL_MESSAGE, my_log_func, ((void *)0));
}


canonical_decompiled_code:
time_t func2()
{
time_t v0; // rax

v0 = time(0LL);
if ( t0_0 )
return v0 - t0_0;
t0_0 = v0;
return 0LL;
}


canonical_decompiled_code:
int __fastcall func3(__int64 a1, __int64 a2, const char *a3)
{
__int64 v4; // r12
time_t v5; // rax

v4 = func1();
v5 = func2();
return fprintf(stderr, "[t=%lu m=%llu] %s\n", v5, v4, a3);
}

variable_types: enum GLogLevelFlags { G_LOG_FLAG_RECURSION=expr, G_LOG_FLAG_FATAL=expr, G_LOG_LEVEL_ERROR=expr, G_LOG_LEVEL_CRITICAL=expr, G_LOG_LEVEL_WARNING=expr, G_LOG_LEVEL_MESSAGE=expr, G_LOG_LEVEL_INFO=expr, G_LOG_LEVEL_DEBUG=expr, G_LOG_LEVEL_MASK=expr }

variable_types:
message
char *


repo: osmocom/osmo-tetra

original_code:
uint16_t get_nth_bit(const uint8_t *input, int _bit)
{
 uint16_t val;
 int byte = _bit / 8;
 int bit = 7 - _bit % 8;
 val = (input[byte] & (1 << bit)) >> bit;
 return val;
}

canonical_original_code:
unsigned short get_nth_bit(unsigned char *input, int _bit)
{
 unsigned short val;
 int byte = _bit / 8;
 int bit = 7 - _bit % 8;
 val = (input[byte] & (1 << bit)) >> bit;
 return val;
}

variable_types:
input
unsigned char *

variable_types:
val
unsigned short

variable_types: byte int

variable_types: bit int

return_type: unsigned short


original_code:
uint16_t crc16_itut_bytes(uint16_t crc, const uint8_t *input, int number_bits)
{
 int i;
 for (i = 0; i < number_bits; ++i) {
  uint16_t bit = get_nth_bit(input, i);
  crc ^= bit << 15;
  if ((crc & 0x8000)) {
   crc <<= 1;
   crc ^= 0x1021;
  } else {
   crc <<= 1;
  }
 }
 return crc;
}

canonical_original_code:
unsigned short crc16_itut_bytes(unsigned short crc, unsigned char *input, int number_bits)
{
 int i;
 for (i = 0; i < number_bits; ++i) {
  unsigned short bit = get_nth_bit(input, i);
  crc ^= bit << 15;
  if ((crc & 0x8000)) {
   crc <<= 1;
   crc ^= 0x1021;
  } else {
   crc <<= 1;
  }
 }
 return crc;
}

variable_types:
crc
unsigned short

variable_types:
bit
unsigned short


original_code:
uint16_t crc16_itut_bits(uint16_t crc, const uint8_t *input, int number_bits)
{
 int i;
 for (i = 0; i < number_bits; ++i) {
  uint16_t bit = input[i] & 0x1;
  crc ^= bit << 15;
  if ((crc & 0x8000)) {
   crc <<= 1;
   crc ^= 0x1021;
  } else {
   crc <<= 1;
  }
 }
 return crc;
}

canonical_original_code:
unsigned short crc16_itut_bits(unsigned short crc, unsigned char *input, int number_bits)
{
 int i;
 for (i = 0; i < number_bits; ++i) {
  unsigned short bit = input[i] & 0x1;
  crc ^= bit << 15;
  if ((crc & 0x8000)) {
   crc <<= 1;
   crc ^= 0x1021;
  } else {
   crc <<= 1;
  }
 }
 return crc;
}


decompiled_code:
__int64 __fastcall crc16_itut_poly(unsigned int a1, int a2, unsigned __int8 *a3, int a4)
{
unsigned int v4; // er8
__int64 v5; // r9
int v6; // eax

if ( a4 <= 0 )
return a1;
v4 = a1;
v5 = (__int64)&a3[a4 - 1 + 1];
do
{
v6 = v4 ^ (*a3 << 15);
v4 = 2 * v6;
if ( (v6 & 0x8000u) != 0 )
v4 = a2 ^ (2 * v6);
++a3;
}
while ( (unsigned __int8 *)v5 != a3 );
return v4;
}

original_code:
uint16_t crc16_itut_poly(uint16_t crc, uint32_t poly, const uint8_t *input, int number_bits)
{
 int i;
 for (i = 0; i < number_bits; ++i) {
  uint16_t bit = input[i] & 0x1;
  crc ^= bit << 15;
  if ((crc & 0x8000)) {
   crc <<= 1;
   crc ^= poly;
  } else {
   crc <<= 1;
  }
 }
 return crc;
}

canonical_original_code:
unsigned short crc16_itut_poly(unsigned short crc, unsigned int poly, unsigned char *input, int number_bits)
{
 int i;
 for (i = 0; i < number_bits; ++i) {
  unsigned short bit = input[i] & 0x1;
  crc ^= bit << 15;
  if ((crc & 0x8000)) {
   crc <<= 1;
   crc ^= poly;
  } else {
   crc <<= 1;
  }
 }
 return crc;
}

variable_types:
poly
unsigned int


decompiled_code:
__int64 __fastcall crc16_ccitt_bits(unsigned __int8 *a1, int a2)
{
return crc16_itut_bits(0xFFFFu, a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned __int8 *a1, int a2)
{
return func2(0xFFFFu, a1, a2);
}

original_code:
uint16_t crc16_ccitt_bits(uint8_t *bits, unsigned int len)
{
 return crc16_itut_bits(0xffff, bits, len);
}

canonical_original_code:
unsigned short crc16_ccitt_bits(unsigned char *bits, unsigned int len)
{
 return crc16_itut_bits(0xffff, bits, len);
}

variable_types:
bits
unsigned char *

variable_types:
len
unsigned int


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

result = *(unsigned int *)(a1 + 16);
if ( (unsigned int)result > 0x3C )
{
result = (unsigned int)result % 0x3C;
*(_DWORD *)(a1 + 16) = result;
}
return result;
}

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

result = *(unsigned int *)(a1 + 16);
if ( (unsigned int)result > 0x3C )
{
result = (unsigned int)result % 0x3C;
*(_DWORD *)(a1 + 16) = result;
}
return result;
}

original_code:
static void normalize_mn(struct tetra_tdma_time *tm)
{
 if (tm->mn > 60)
  tm->mn = (tm->mn%60);
}

variable_types: struct tetra_tdma_time { unsigned short hn; unsigned int sn; unsigned int tn; unsigned int fn; unsigned int mn; } *


decompiled_code:
__int64 __fastcall normalize_fn(__int64 a1)
{
unsigned int v1; // edx

v1 = *(_DWORD *)(a1 + 12);
if ( v1 > 0x12 )
{
*(_DWORD *)(a1 + 16) += v1 / 0x12;
*(_DWORD *)(a1 + 12) = v1 % 0x12;
}
return normalize_mn(a1);
}

original_code:
static void normalize_fn(struct tetra_tdma_time *tm)
{
 uint32_t mn_delta;
 if (tm->fn > 18) {
  mn_delta = tm->fn/18;
  tm->fn = (tm->fn%18);
  tm->mn += mn_delta;
 }
 normalize_mn(tm);
}

canonical_original_code:
static void normalize_fn(struct tetra_tdma_time *tm)
{
 unsigned int mn_delta;
 if (tm->fn > 18) {
  mn_delta = tm->fn/18;
  tm->fn = (tm->fn%18);
  tm->mn += mn_delta;
 }
 normalize_mn(tm);
}

user_defined_types: struct tetra_tdma_time { unsigned short hn; unsigned int sn; unsigned int tn; unsigned int fn; unsigned int mn; }


decompiled_code:
__int64 __fastcall normalize_tn(__int64 a1)
{
unsigned int v1; // eax

v1 = *(_DWORD *)(a1 + 8);
if ( v1 > 4 )
{
*(_DWORD *)(a1 + 12) += v1 >> 2;
*(_DWORD *)(a1 + 8) = v1 & 3;
}
return normalize_fn(a1);
}

original_code:
static void normalize_tn(struct tetra_tdma_time *tm)
{
 uint32_t fn_delta;
 if (tm->tn > 4) {
  fn_delta = tm->tn/4;
  tm->tn = (tm->tn%4);
  tm->fn += fn_delta;
 }
 normalize_fn(tm);
}

canonical_original_code:
static void normalize_tn(struct tetra_tdma_time *tm)
{
 unsigned int fn_delta;
 if (tm->tn > 4) {
  fn_delta = tm->tn/4;
  tm->tn = (tm->tn%4);
  tm->fn += fn_delta;
 }
 normalize_fn(tm);
}


decompiled_code:
__int64 __fastcall normalize_sn(__int64 a1)
{
unsigned int v1; // eax

v1 = *(_DWORD *)(a1 + 4);
if ( v1 > 0xFF )
{
*(_DWORD *)(a1 + 8) += v1 / 0xFF;
*(_DWORD *)(a1 + 4) = v1 % 0xFF + 1;
}
return normalize_tn(a1);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
unsigned int v1; // eax

v1 = *(_DWORD *)(a1 + 4);
if ( v1 > 0xFF )
{
*(_DWORD *)(a1 + 8) += v1 / 0xFF;
*(_DWORD *)(a1 + 4) = v1 % 0xFF + 1;
}
return func2(a1);
}

original_code:
static void normalize_sn(struct tetra_tdma_time *tm)
{
 uint32_t tn_delta;
 if (tm->sn > 255) {
  tn_delta = (tm->sn/255);
  tm->sn = (tm->sn % 255) + 1;
  tm->tn += tn_delta;
 }
 normalize_tn(tm);
}

canonical_original_code:
static void normalize_sn(struct tetra_tdma_time *tm)
{
 unsigned int tn_delta;
 if (tm->sn > 255) {
  tn_delta = (tm->sn/255);
  tm->sn = (tm->sn % 255) + 1;
  tm->tn += tn_delta;
 }
 normalize_tn(tm);
}


decompiled_code:
__int64 __fastcall tetra_tdma_time_add_sym(__int64 a1, int a2)
{
*(_DWORD *)(a1 + 4) += a2;
return normalize_sn(a1);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, int a2)
{
*(_DWORD *)(a1 + 4) += a2;
return func3(a1);
}

original_code:
void tetra_tdma_time_add_sym(struct tetra_tdma_time *tm, uint32_t sym_count)
{
 tm->sn += sym_count;
 normalize_sn(tm);
}

canonical_original_code:
void tetra_tdma_time_add_sym(struct tetra_tdma_time *tm, unsigned int sym_count)
{
 tm->sn += sym_count;
 normalize_sn(tm);
}


decompiled_code:
__int64 __fastcall tetra_tdma_time_add_tn(__int64 a1, int a2)
{
*(_DWORD *)(a1 + 8) += a2;
return normalize_tn(a1);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, int a2)
{
*(_DWORD *)(a1 + 8) += a2;
return func2(a1);
}

original_code:
void tetra_tdma_time_add_tn(struct tetra_tdma_time *tm, uint32_t tn_count)
{
 tm->tn += tn_count;
 normalize_tn(tm);
}

canonical_original_code:
void tetra_tdma_time_add_tn(struct tetra_tdma_time *tm, unsigned int tn_count)
{
 tm->tn += tn_count;
 normalize_tn(tm);
}


decompiled_code:
__int64 __fastcall tetra_tdma_time_add_fn(__int64 a1, int a2)
{
*(_DWORD *)(a1 + 12) += a2;
return normalize_fn(a1);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, int a2)
{
*(_DWORD *)(a1 + 12) += a2;
return func1(a1);
}

original_code:
void tetra_tdma_time_add_fn(struct tetra_tdma_time *tm, uint32_t fn_count)
{
 tm->fn += fn_count;
 normalize_fn(tm);
}

canonical_original_code:
void tetra_tdma_time_add_fn(struct tetra_tdma_time *tm, unsigned int fn_count)
{
 tm->fn += fn_count;
 normalize_fn(tm);
}


decompiled_code:
char *__fastcall tetra_tdma_time_dump(unsigned int *a1)
{
snprintf(buf_0, 0x100uLL, "%02u/%02u/%u/%03u", a1[4], a1[3], a1[2], a1[1]);
return buf_0;
}

canonical_decompiled_code:
char *__fastcall func7(unsigned int *a1)
{
snprintf(buf_0, 0x100uLL, "%02u/%02u/%u/%03u", a1[4], a1[3], a1[2], a1[1]);
return buf_0;
}

original_code:
char *tetra_tdma_time_dump(const struct tetra_tdma_time *tm)
{
 static char buf[256];
 snprintf(buf, sizeof(buf), "%02u/%02u/%u/%03u", tm->mn, tm->fn, tm->tn, tm->sn);
 return buf;
}

canonical_original_code:
char *tetra_tdma_time_dump(struct tetra_tdma_time *tm)
{
 static char buf[256];
 snprintf(buf, sizeof(buf), "%02u/%02u/%u/%03u", tm->mn, tm->fn, tm->tn, tm->sn);
 return buf;
}

variable_types:
buf
char [256]


decompiled_code:
__int64 __fastcall tetra_tdma_time2fn(unsigned __int16 *a1)
{
return *((_DWORD *)a1 + 3) + 18 * (*((_DWORD *)a1 + 4) + 60 * (unsigned int)*a1);
}

canonical_decompiled_code:
__int64 __fastcall func8(unsigned __int16 *a1)
{
return *((_DWORD *)a1 + 3) + 18 * (*((_DWORD *)a1 + 4) + 60 * (unsigned int)*a1);
}

original_code:
uint32_t tetra_tdma_time2fn(struct tetra_tdma_time *tm)
{
 return (((tm->hn * 60) + tm->mn) * 18) + tm->fn;
}

canonical_original_code:
unsigned int tetra_tdma_time2fn(struct tetra_tdma_time *tm)
{
 return (((tm->hn * 60) + tm->mn) * 18) + tm->fn;
}


decompiled_code:
int tetra_rm3014_init()
{
char *v0; // rbp
__int64 i; // rbx
__int64 v2; // rdi
int v3; // eax
__int64 v4; // rsi
unsigned int v5; // er9
__int64 v6; // rdx
int result; // eax

v0 = (char *)&rm_30_14_gen;
for ( i = 0LL; i != 14; ++i )
{
v2 = (__int64)v0;
v0 += 16;
v3 = shift_bits_together_constprop_0(v2);
v4 = (unsigned int)i;
v6 = v3 | v5;
rm_30_14_rows[i] = v6;
result = printf("rm_30_14_rows[%u] = 0x%08x\n", v4, v6);
}
return result;
}

canonical_decompiled_code:
int func1()
{
char *v0; // rbp
__int64 i; // rbx
__int64 v2; // rdi
int v3; // eax
__int64 v4; // rsi
unsigned int v5; // er9
__int64 v6; // rdx
int result; // eax

v0 = (char *)&rm_30_14_gen;
for ( i = 0LL; i != 14; ++i )
{
v2 = (__int64)v0;
v0 += 16;
v3 = func0(v2);
v4 = (unsigned int)i;
v6 = v3 | v5;
rm_30_14_rows[i] = v6;
result = printf("rm_30_14_rows[%u] = 0x%08x\n", v4, v6);
}
return result;
}

original_code:
void tetra_rm3014_init(void)
{
 int i;
 uint32_t val;
 for (i = 0; i < 14; i++) {
  val = (1 << (16+13 - i));
  val |= shift_bits_together(rm_30_14_gen[i], 16);
  rm_30_14_rows[i] = val;
  printf("rm_30_14_rows[%u] = 0x%08x\n", i, val);
 }
}

canonical_original_code:
void tetra_rm3014_init()
{
 int i;
 unsigned int val;
 for (i = 0; i < 14; i++) {
  val = (1 << (16+13 - i));
  val |= shift_bits_together(rm_30_14_gen[i], 16);
  rm_30_14_rows[i] = val;
  printf("rm_30_14_rows[%u] = 0x%08x\n", i, val);
 }
}

variable_types: i int

variable_types:
val
unsigned int


decompiled_code:
__int64 __fastcall tetra_rm3014_compute(int a1)
{
__int64 v1; // rax
unsigned int v2; // er8

a1 = (unsigned __int16)a1;
v1 = 0LL;
v2 = 0;
do
{
if ( _bittest(&a1, 13 - v1) )
v2 ^= rm_30_14_rows[v1];
++v1;
}
while ( v1 != 14 );
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1)
{
__int64 v1; // rax
unsigned int v2; // er8

a1 = (unsigned __int16)a1;
v1 = 0LL;
v2 = 0;
do
{
if ( _bittest(&a1, 13 - v1) )
v2 ^= rm_30_14_rows[v1];
++v1;
}
while ( v1 != 14 );
return v2;
}

original_code:
uint32_t tetra_rm3014_compute(const uint16_t in)
{
 int i;
 uint32_t val = 0;
 for (i = 0; i < 14; i++) {
  uint32_t bit = (in >> (14-1-i)) & 1;
  if (bit)
   val ^= rm_30_14_rows[i];
 }
 return val;
}

canonical_original_code:
unsigned int tetra_rm3014_compute(unsigned short in)
{
 int i;
 unsigned int val = 0;
 for (i = 0; i < 14; i++) {
  unsigned int bit = (in >> (14-1-i)) & 1;
  if (bit)
   val ^= rm_30_14_rows[i];
 }
 return val;
}

variable_types:
in
unsigned short

variable_types:
bit
unsigned int


decompiled_code:
__int64 __fastcall tetra_rm3014_decode(int a1, _WORD *a2)
{
__int64 result; // rax

result = 0LL;
*a2 = HIWORD(a1);
return result;
}

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

result = 0LL;
*a2 = HIWORD(a1);
return result;
}

original_code:
int tetra_rm3014_decode(const uint32_t inp, uint16_t *out)
{
 *out = inp >> 16;
 return 0;
}

canonical_original_code:
int tetra_rm3014_decode(unsigned int inp, unsigned short *out)
{
 *out = inp >> 16;
 return 0;
}

variable_types:
inp
unsigned int

variable_types:
out
unsigned short *


original_code:
void viterbi_dec_sb1_wrapper(const uint8_t *in, uint8_t *out, unsigned int sym_count)
{
 int8_t vit_inp[864*4] = {0};
 int i;
 for (i = 0; i < sym_count*4; i++) {
  switch (in[i]) {
  case 0:
   vit_inp[i] = 127;
   break;
  case 0xff:
   vit_inp[i] = 0;
   break;
  default:
   vit_inp[i] = -127;
   break;
  }
 }
 conv_cch_decode(vit_inp, out, sym_count);
}

canonical_original_code:
void viterbi_dec_sb1_wrapper(unsigned char *in, unsigned char *out, unsigned int sym_count)
{
 char vit_inp[-1] = {0};
 int i;
 for (i = 0; i < sym_count*4; i++) {
  switch (in[i]) {
  case 0:
   vit_inp[i] = 127;
   break;
  case 0xff:
   vit_inp[i] = 0;
   break;
  default:
   vit_inp[i] = -127;
   break;
  }
 }
 conv_cch_decode(vit_inp, out, sym_count);
}

variable_types:
in
unsigned char *

variable_types:
out
unsigned char *


original_code:
void tetra_acelp_type2_to_codec(const uint8_t *in, uint8_t *out)
{
 int bit, frame;
 const uint8_t *in_cur = in;
 for (bit = 0; bit < 51; bit++) {
  for (frame = 0; frame < 2; frame++)
   out[frame*(51 +56 +30) + class0_positions[bit] - 1] = in_cur[2*bit + frame];
 }
 in_cur += 2*51;
 for (bit = 0; bit < 56; bit++) {
  for (frame = 0; frame < 2; frame++)
   out[frame*(51 +56 +30) + class1_positions[bit] - 1] = in_cur[2*bit + frame];
 }
 in_cur += 2*56;
 for (bit = 0; bit < 30; bit++) {
  for (frame = 0; frame < 2; frame++)
   out[frame*(51 +56 +30) + class2_positions[bit] - 1] = in_cur[2*bit + frame];
 }
}

canonical_original_code:
void tetra_acelp_type2_to_codec(unsigned char *in, unsigned char *out)
{
 int bit; int frame;
 unsigned char *in_cur = in;
 for (bit = 0; bit < 51; bit++) {
  for (frame = 0; frame < 2; frame++)
   out[frame*(51 +56 +30) + class0_positions[bit] - 1] = in_cur[2*bit + frame];
 }
 in_cur += 2*51;
 for (bit = 0; bit < 56; bit++) {
  for (frame = 0; frame < 2; frame++)
   out[frame*(51 +56 +30) + class1_positions[bit] - 1] = in_cur[2*bit + frame];
 }
 in_cur += 2*56;
 for (bit = 0; bit < 30; bit++) {
  for (frame = 0; frame < 2; frame++)
   out[frame*(51 +56 +30) + class2_positions[bit] - 1] = in_cur[2*bit + frame];
 }
}

variable_types: frame int


original_code:
void tetra_acelp_codec_to_acelp(const uint8_t *in, uint8_t *out)
{
 int bit, frame;
 uint8_t *out_cur = out;
 for (bit = 0; bit < 51; bit++) {
  for (frame = 0; frame < 2; frame++)
   out_cur[2*bit + frame] = in[frame*(51 +56 +30) + class0_positions[bit] - 1];
 }
 out_cur += 2*51;
 for (bit = 0; bit < 56; bit++) {
  for (frame = 0; frame < 2; frame++)
   out_cur[2*bit + frame] = in[frame*(51 +56 +30) + class1_positions[bit] - 1];
 }
 out_cur += 2*56;
 for (bit = 0; bit < 30; bit++) {
  for (frame = 0; frame < 2; frame++)
   out_cur[2*bit + frame] = in[frame*(51 +56 +30) + class2_positions[bit] - 1];
 }
}

canonical_original_code:
void tetra_acelp_codec_to_acelp(unsigned char *in, unsigned char *out)
{
 int bit; int frame;
 unsigned char *out_cur = out;
 for (bit = 0; bit < 51; bit++) {
  for (frame = 0; frame < 2; frame++)
   out_cur[2*bit + frame] = in[frame*(51 +56 +30) + class0_positions[bit] - 1];
 }
 out_cur += 2*51;
 for (bit = 0; bit < 56; bit++) {
  for (frame = 0; frame < 2; frame++)
   out_cur[2*bit + frame] = in[frame*(51 +56 +30) + class1_positions[bit] - 1];
 }
 out_cur += 2*56;
 for (bit = 0; bit < 30; bit++) {
  for (frame = 0; frame < 2; frame++)
   out_cur[2*bit + frame] = in[frame*(51 +56 +30) + class2_positions[bit] - 1];
 }
}

variable_types: bit int


decompiled_code:
__int64 __fastcall tun_alloc(const char *a1)
{
int v1; // er12
bool v2; // zf
int v3; // eax
int v5; // edi
__int128 v6; // [rsp+0h] [rbp-48h] BYREF
__int128 v7; // [rsp+10h] [rbp-38h]
__int64 v8; // [rsp+20h] [rbp-28h]

v1 = open("/dev/net/tun", 2);
if ( v1 >= 0 )
{
v2 = *a1 == 0;
v8 = 0LL;
v7 = 0LL;
v6 = 0LL;
LOWORD(v7) = 4097;
if ( !v2 )
snprintf((char *)&v6, 0x10uLL, "%s", a1);
v3 = ioctl(v1, 0x400454CAuLL, &v6);
if ( v3 < 0 )
{
v5 = v1;
v1 = v3;
close(v5);
}
}
return (unsigned int)v1;
}

original_code:
int tun_alloc(char *dev)
  {
      struct ifreq ifr;
      int fd, err;
      fd = open("/dev/net/tun", 02);
 if (fd < 0)
  return fd;
      memset(&ifr, 0, sizeof(ifr));
      ifr.ifr_ifru.ifru_flags = 0x0001|0x1000;
      if( *dev )
         snprintf(ifr.ifr_ifrn.ifrn_name, 16, "%s", dev);
      if( (err = ioctl(fd, (((1U) << (((0 +8)+8)+14)) | ((('T')) << (0 +8)) | (((202)) << 0) | ((((sizeof(int)))) << ((0 +8)+8))), (void *) &ifr)) < 0 ){
         close(fd);
         return err;
      }
      return fd;
  }

canonical_original_code:
int tun_alloc(char *dev)
  {
      struct ifreq ifr;
      int fd; int err;
      fd = open("/dev/net/tun", 02);
 if (fd < 0)
  return fd;
      memset(&ifr, 0, sizeof(ifr));
      ifr.ifr_ifru.ifru_flags = 0x0001|0x1000;
      if( *dev )
         snprintf(ifr.ifr_ifrn.ifrn_name, 16, "%s", dev);
      if( (err = ioctl(fd, (((1U) << (((0 +8)+8)+14)) | ((('T')) << (0 +8)) | (((202)) << 0) | ((((sizeof(int)))) << ((0 +8)+8))), (void *) &ifr)) < 0 ){
         close(fd);
         return err;
      }
      return fd;
  }

variable_types:
dev
char *

variable_types: struct ifreq { union { char ifrn_name[16]; } ifr_ifrn; union { struct sockaddr { unsigned short sa_family; char sa_data[14]; } ifru_addr; struct sockaddr ifru_dstaddr; struct sockaddr ifru_broadaddr; struct sockaddr ifru_netmask; struct sockaddr ifru_hwaddr; short ifru_flags; int ifru_ivalue; int ifru_mtu; struct ifmap { unsigned long mem_start; unsigned long mem_end; unsigned short base_addr; unsigned char irq; unsigned char dma; unsigned char port; } ifru_map; char ifru_slave[16]; char ifru_newname[16]; void *ifru_data; struct if_settings { unsigned int type; unsigned int size; union { struct raw_hdlc_proto { unsigned short encoding; unsigned short parity; } *raw_hdlc; struct cisco_proto { unsigned int interval; unsigned int timeout; } *cisco; struct fr_proto { unsigned int t391; unsigned int t392; unsigned int n391; unsigned int n392; unsigned int n393; unsigned short lmi; unsigned short dce; } *fr; struct fr_proto_pvc { unsigned int dlci; } *fr_pvc; struct fr_proto_pvc_info { unsigned int dlci; char master[16]; } *fr_pvc_info; struct sync_serial_settings { unsigned int clock_rate; unsigned int clock_type; unsigned short loopback; } *sync; struct te1_settings { unsigned int clock_rate; unsigned int clock_type; unsigned short loopback; unsigned int slot_map; } *te1; } ifs_ifsu; } ifru_settings; } ifr_ifru; }

variable_types: fd int

variable_types: err int

user_defined_types: struct ifreq { union { char ifrn_name[16]; } ifr_ifrn; union { struct sockaddr ifru_addr; struct sockaddr ifru_dstaddr; struct sockaddr ifru_broadaddr; struct sockaddr ifru_netmask; struct sockaddr ifru_hwaddr; short ifru_flags; int ifru_ivalue; int ifru_mtu; struct ifmap ifru_map; char ifru_slave[16]; char ifru_newname[16]; void *ifru_data; struct if_settings ifru_settings; } ifr_ifru; }

user_defined_types: struct if_settings { unsigned int type; unsigned int size; union { struct raw_hdlc_proto *raw_hdlc; struct cisco_proto *cisco; struct fr_proto *fr; struct fr_proto_pvc *fr_pvc; struct fr_proto_pvc_info *fr_pvc_info; struct sync_serial_settings *sync; struct te1_settings *te1; } ifs_ifsu; }


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

result = 3LL;
if ( a1 <= 2.0 )
{
result = 1LL;
if ( a1 <= 0.0 )
{
result = 4294967293LL;
if ( a1 >= -2.0 )
result = 0xFFFFFFFFLL;
}
}
return result;
}

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

result = 3LL;
if ( a1 <= 2.0 )
{
result = 1LL;
if ( a1 <= 0.0 )
{
result = 4294967293LL;
if ( a1 >= -2.0 )
result = 0xFFFFFFFFLL;
}
}
return result;
}

original_code:
static int process_sym_fl(float fl)
{
 int ret;
 if (fl > 2)
  ret = 3;
 else if (fl > 0)
  ret = 1;
 else if (fl < -2)
  ret = -3;
 else
  ret = -1;
 return ret;
}

variable_types: fl float

variable_types: ret int


main

canonical_name: main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // er12
int v4; // ebp
int v5; // eax
float v6; // xmm7_4
float v7; // xmm6_4
int v8; // eax
unsigned __int64 v9; // r13
float *v10; // rbx
char *v11; // r15
char *v12; // r14
float v13; // xmm5_4
int v14; // eax
float v15; // xmm0_4
int v16; // eax
__int64 v17; // rdx
__int64 v18; // rsi
int v19; // eax
float v20; // [rsp+Ch] [rbp-184Ch]
float v21; // [rsp+10h] [rbp-1848h]
float v22; // [rsp+14h] [rbp-1844h]
int fd; // [rsp+18h] [rbp-1840h]
int v24; // [rsp+1Ch] [rbp-183Ch]
char v25[2048]; // [rsp+20h] [rbp-1838h] BYREF
char buf[4152]; // [rsp+820h] [rbp-1038h] BYREF

v3 = 0;
v4 = 0;
v21 = 0.0;
v22 = *(float *)&LC3;
while ( 1 )
{
v5 = getopt(argc, (char *const *)argv, "vaf:F:");
if ( v5 == -1 )
break;
if ( v5 == 102 )
{
v7 = atof(optarg);
v22 = v7;
}
else if ( v5 > 102 )
{
if ( v5 != 118 )
goto LABEL_13;
v3 = 1;
}
else if ( v5 == 70 )
{
v6 = atof(optarg);
v21 = v6;
}
else
{
if ( v5 != 97 )
goto LABEL_13;
v4 = 1;
}
}
if ( optind + 1 >= argc )
{
fprintf(stderr, "Usage: %s [-v] [-a] [-f filter_val] [-F filter_goal] <infile> <outfile>\n", *argv);
fwrite("-v verbose, print bits to stdout\n", 1uLL, 0x21uLL, stderr);
fwrite("-a turn on pseudo-afc (automatic frequency correction)\n", 1uLL, 0x37uLL, stderr);
fwrite("-f pseudo-afc averaging filter constant (default 0.0001)\n", 1uLL, 0x39uLL, stderr);
fwrite("-F pseudo-afc filter goal (default: 0)\n", 1uLL, 0x27uLL, stderr);
LABEL_13:
exit(2);
}
fd = open(argv[optind], 0);
if ( fd < 0 )
{
perror("open infile");
exit(1);
}
v24 = creat(argv[optind + 1], 0x1B0u);
if ( v24 < 0 )
{
perror("open outfile");
exit(1);
}
v20 = 0.0;
while ( 1 )
{
v8 = read(fd, buf, 0x1000uLL);
if ( v8 < 0 )
{
perror("read");
exit(1);
}
if ( !v8 )
LABEL_32:
exit(0);
v9 = (unsigned __int64)v8 >> 2;
if ( v9 )
break;
LABEL_30:
v19 = write(v24, v25, 2 * (int)v9);
if ( v19 < 0 )
{
perror("write");
exit(1);
}
if ( !v19 )
goto LABEL_32;
}
v10 = (float *)buf;
v11 = v25;
v12 = &v25[2 * (unsigned int)(v9 - 1) + 2];
while ( 1 )
{
while ( 1 )
{
v15 = *v10;
if ( !v4 )
break;
if ( v15 > -5.0 && v15 < 5.0 )
{
v13 = (1.0 - v22) * v20 + (float)((float)(v15 - v21) * v22);
v20 = v13;
}
v14 = process_sym_fl(v15 - v20);
sym_int2bits(v14, v11);
if ( v3 )
goto LABEL_29;
LABEL_26:
v11 += 2;
++v10;
if ( v11 == v12 )
goto LABEL_30;
}
v16 = process_sym_fl(v15);
sym_int2bits(v16, v11);
if ( !v3 )
goto LABEL_26;
LABEL_29:
v17 = (unsigned __int8)v11[1];
v18 = (unsigned __int8)*v11;
v11 += 2;
++v10;
printf("%1u%1u", v18, v17);
if ( v11 == v12 )
goto LABEL_30;
}
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // er12
int v4; // ebp
int v5; // eax
float v6; // xmm7_4
float v7; // xmm6_4
int v8; // eax
unsigned __int64 v9; // r13
float *v10; // rbx
char *v11; // r15
char *v12; // r14
float v13; // xmm5_4
int v14; // eax
float v15; // xmm0_4
int v16; // eax
__int64 v17; // rdx
__int64 v18; // rsi
int v19; // eax
float v20; // [rsp+Ch] [rbp-184Ch]
float v21; // [rsp+10h] [rbp-1848h]
float v22; // [rsp+14h] [rbp-1844h]
int fd; // [rsp+18h] [rbp-1840h]
int v24; // [rsp+1Ch] [rbp-183Ch]
char v25[2048]; // [rsp+20h] [rbp-1838h] BYREF
char buf[4152]; // [rsp+820h] [rbp-1038h] BYREF

v3 = 0;
v4 = 0;
v21 = 0.0;
v22 = *(float *)&LC3;
while ( 1 )
{
v5 = getopt(argc, (char *const *)argv, "vaf:F:");
if ( v5 == -1 )
break;
if ( v5 == 102 )
{
v7 = atof(optarg);
v22 = v7;
}
else if ( v5 > 102 )
{
if ( v5 != 118 )
goto LABEL_13;
v3 = 1;
}
else if ( v5 == 70 )
{
v6 = atof(optarg);
v21 = v6;
}
else
{
if ( v5 != 97 )
goto LABEL_13;
v4 = 1;
}
}
if ( optind + 1 >= argc )
{
fprintf(stderr, "Usage: %s [-v] [-a] [-f filter_val] [-F filter_goal] <infile> <outfile>\n", *argv);
fwrite("-v verbose, print bits to stdout\n", 1uLL, 0x21uLL, stderr);
fwrite("-a turn on pseudo-afc (automatic frequency correction)\n", 1uLL, 0x37uLL, stderr);
fwrite("-f pseudo-afc averaging filter constant (default 0.0001)\n", 1uLL, 0x39uLL, stderr);
fwrite("-F pseudo-afc filter goal (default: 0)\n", 1uLL, 0x27uLL, stderr);
LABEL_13:
exit(2);
}
fd = open(argv[optind], 0);
if ( fd < 0 )
{
perror("open infile");
exit(1);
}
v24 = creat(argv[optind + 1], 0x1B0u);
if ( v24 < 0 )
{
perror("open outfile");
exit(1);
}
v20 = 0.0;
while ( 1 )
{
v8 = read(fd, buf, 0x1000uLL);
if ( v8 < 0 )
{
perror("read");
exit(1);
}
if ( !v8 )
LABEL_32:
exit(0);
v9 = (unsigned __int64)v8 >> 2;
if ( v9 )
break;
LABEL_30:
v19 = write(v24, v25, 2 * (int)v9);
if ( v19 < 0 )
{
perror("write");
exit(1);
}
if ( !v19 )
goto LABEL_32;
}
v10 = (float *)buf;
v11 = v25;
v12 = &v25[2 * (unsigned int)(v9 - 1) + 2];
while ( 1 )
{
while ( 1 )
{
v15 = *v10;
if ( !v4 )
break;
if ( v15 > -5.0 && v15 < 5.0 )
{
v13 = (1.0 - v22) * v20 + (float)((float)(v15 - v21) * v22);
v20 = v13;
}
v14 = func0(v15 - v20);
func1(v14, v11);
if ( v3 )
goto LABEL_29;
LABEL_26:
v11 += 2;
++v10;
if ( v11 == v12 )
goto LABEL_30;
}
v16 = func0(v15);
func1(v16, v11);
if ( !v3 )
goto LABEL_26;
LABEL_29:
v17 = (unsigned __int8)v11[1];
v18 = (unsigned __int8)*v11;
v11 += 2;
++v10;
printf("%1u%1u", v18, v17);
if ( v11 == v12 )
goto LABEL_30;
}
}

original_code:
int main(int argc, char **argv)
{
 int fd, fd_out, opt;
 int opt_verbose = 0;
 int opt_afc = 0;
 float filter = 0;
 float filter_val = 0.0001;
 float filter_goal = 0;
 int sym;
 while ((opt = getopt(argc, argv, "vaf:F:")) != -1) {
  switch (opt) {
  case 'v':
   opt_verbose = 1;
   break;
  case 'a':
   opt_afc = 1;
   break;
  case 'f':
   filter_val = atof(optarg);
   break;
  case 'F':
   filter_goal = atof(optarg);
   break;
  default:
   exit(2);
  }
 }
 if (argc <= optind+1) {
  fprintf(stderr, "Usage: %s [-v] [-a] [-f filter_val] [-F filter_goal] <infile> <outfile>\n", argv[0]);
  fprintf(stderr, "-v verbose, print bits to stdout\n");
  fprintf(stderr, "-a turn on pseudo-afc (automatic frequency correction)\n");
  fprintf(stderr, "-f pseudo-afc averaging filter constant (default 0.0001)\n");
  fprintf(stderr, "-F pseudo-afc filter goal (default: 0)\n");
  exit(2);
 }
 fd = open(argv[optind], 00);
 if (fd < 0) {
  perror("open infile");
  exit(1);
 }
 fd_out = creat(argv[optind+1], 0660);
 if (fd_out < 0) {
  perror("open outfile");
  exit(1);
 }
 while (1) {
  int rc;
  float fl[1024];
  uint8_t bits[2*1024];
  rc = read(fd, fl, sizeof(*fl) * 1024);
  if (rc < 0) {
   perror("read");
   exit(1);
  } else if (rc == 0) {
   break;
  }
  rc /= sizeof(*fl);
  int i;
  for (i = 0; i < rc; ++i) {
   if (opt_afc) {
    if ((fl[i] > -5.0) && (fl[i] < 5.0)) {
     filter = filter * (1.0 - filter_val) + (fl[i] - filter_goal) * filter_val;
    }
    sym = process_sym_fl(fl[i]-filter);
   } else {
    sym = process_sym_fl(fl[i]);
   }
   sym_int2bits(sym, bits + i*2);
   if (opt_verbose) {
    printf("%1u%1u", bits[2*i + 0], bits[2*i + 1]);
   }
  }
  rc = write(fd_out, bits, rc * 2);
  if (rc < 0) {
   perror("write");
   exit(1);
  } else if (rc == 0)
   break;
 }
 exit(0);
}

canonical_original_code:
int main(int argc, char **argv)
{
 int fd; int fd_out; int opt;
 int opt_verbose = 0;
 int opt_afc = 0;
 float filter = 0;
 float filter_val = 0.0001;
 float filter_goal = 0;
 int sym;
 while ((opt = getopt(argc, argv, "vaf:F:")) != -1) {
  switch (opt) {
  case 'v':
   opt_verbose = 1;
   break;
  case 'a':
   opt_afc = 1;
   break;
  case 'f':
   filter_val = atof(optarg);
   break;
  case 'F':
   filter_goal = atof(optarg);
   break;
  default:
   exit(2);
  }
 }
 if (argc <= optind+1) {
  fprintf(stderr, "Usage: %s [-v] [-a] [-f filter_val] [-F filter_goal] <infile> <outfile>\n", argv[0]);
  fprintf(stderr, "-v verbose, print bits to stdout\n");
  fprintf(stderr, "-a turn on pseudo-afc (automatic frequency correction)\n");
  fprintf(stderr, "-f pseudo-afc averaging filter constant (default 0.0001)\n");
  fprintf(stderr, "-F pseudo-afc filter goal (default: 0)\n");
  exit(2);
 }
 fd = open(argv[optind], 00);
 if (fd < 0) {
  perror("open infile");
  exit(1);
 }
 fd_out = creat(argv[optind+1], 0660);
 if (fd_out < 0) {
  perror("open outfile");
  exit(1);
 }
 while (1) {
  int rc;
  float fl[1024];
  unsigned char bits[-1];
  rc = read(fd, fl, sizeof(*fl) * 1024);
  if (rc < 0) {
   perror("read");
   exit(1);
  } else if (rc == 0) {
   break;
  }
  rc /= sizeof(*fl);
  int i;
  for (i = 0; i < rc; ++i) {
   if (opt_afc) {
    if ((fl[i] > -5.0) && (fl[i] < 5.0)) {
     filter = filter * (1.0 - filter_val) + (fl[i] - filter_goal) * filter_val;
    }
    sym = process_sym_fl(fl[i]-filter);
   } else {
    sym = process_sym_fl(fl[i]);
   }
   sym_int2bits(sym, bits + i*2);
   if (opt_verbose) {
    printf("%1u%1u", bits[2*i + 0], bits[2*i + 1]);
   }
  }
  rc = write(fd_out, bits, rc * 2);
  if (rc < 0) {
   perror("write");
   exit(1);
  } else if (rc == 0)
   break;
 }
 exit(0);
}

variable_types: argc int

variable_types:
argv
char **

variable_types: opt int

variable_types: filter float

variable_types: sym int

variable_types: rc int

variable_types:
fl
float [1024]

variable_types:
bits
unsigned char [-1]


Usage

decompiled_code:
void __fastcall __noreturn Usage(const char *a1)
{
fprintf(stderr, "Create: %s [-b] [-u owner] [-g group] [-t device-name] [-f tun-clone-device] [ -U ]\n", a1);
fprintf(stderr, "Delete: %s -d device-name [-f tun-clone-device]\n\n", a1);
fwrite(
"The default tun clone device is /dev/net/tun - some systems use\n/dev/misc/net/tun instead\n\n",
1uLL,
0x5BuLL,
stderr);
fwrite("-b will result in brief output (just the device name)\n", 1uLL, 0x36uLL, stderr);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func0(const char *a1)
{
fprintf(stderr, "Create: %s [-b] [-u owner] [-g group] [-t device-name] [-f tun-clone-device] [ -U ]\n", a1);
fprintf(stderr, "Delete: %s -d device-name [-f tun-clone-device]\n\n", a1);
fwrite(
"The default tun clone device is /dev/net/tun - some systems use\n/dev/misc/net/tun instead\n\n",
1uLL,
0x5BuLL,
stderr);
fwrite("-b will result in brief output (just the device name)\n", 1uLL, 0x36uLL, stderr);
exit(1);
}

original_code:
static void Usage(char *name)
{
  fprintf(stderr, "Create: %s [-b] [-u owner] [-g group] [-t device-name] "
   "[-f tun-clone-device] [ -U ]\n", name);
  fprintf(stderr, "Delete: %s -d device-name [-f tun-clone-device]\n\n",
   name);
  fprintf(stderr, "The default tun clone device is /dev/net/tun - some systems"
   " use\n/dev/misc/net/tun instead\n\n");
  fprintf(stderr, "-b will result in brief output (just the device name)\n");
  exit(1);
}

variable_types:
name
char *