decompiled_code:
__int64 IRC_filter_register_cvars()
{
Cvar_Register(irc_filter_join_part_messages);
Cvar_Register(irc_filter_quit_messages);
Cvar_Register(irc_filter_private_messages);
return Cvar_Register(irc_filter_notice_messages);
}

canonical_decompiled_code:
__int64 func0()
{
Cvar_Register(irc_filter_join_part_messages);
Cvar_Register(irc_filter_quit_messages);
Cvar_Register(irc_filter_private_messages);
return Cvar_Register(irc_filter_notice_messages);
}

original_code:
void IRC_filter_register_cvars() {
  Cvar_Register(&irc_filter_join_part_messages);
  Cvar_Register(&irc_filter_quit_messages);
  Cvar_Register(&irc_filter_private_messages);
  Cvar_Register(&irc_filter_notice_messages);
}


repo: jite/jquake

decompiled_code:
_BOOL8 IRC_filter_show_chanop_messages()
{
return LODWORD(irc_filter_join_part_messages[8]) == 0;
}

canonical_decompiled_code:
_BOOL8 func1()
{
return LODWORD(irc_filter_join_part_messages[8]) == 0;
}

original_code:
int IRC_filter_show_chanop_messages() {
  return (irc_filter_join_part_messages.integer == 0);
}

return_type: int


decompiled_code:
_BOOL8 IRC_filter_show_connection_messages()
{
return LODWORD(irc_filter_quit_messages[8]) == 0;
}

canonical_decompiled_code:
_BOOL8 func2()
{
return LODWORD(irc_filter_quit_messages[8]) == 0;
}

original_code:
int IRC_filter_show_connection_messages() {
  return (irc_filter_quit_messages.integer == 0);
}


decompiled_code:
_BOOL8 IRC_filter_show_private_messages()
{
return LODWORD(irc_filter_private_messages[8]) == 0;
}

canonical_decompiled_code:
_BOOL8 func3()
{
return LODWORD(irc_filter_private_messages[8]) == 0;
}

original_code:
int IRC_filter_show_private_messages() {
  return (irc_filter_private_messages.integer == 0);
}


decompiled_code:
_BOOL8 IRC_filter_show_notice_messages()
{
return LODWORD(irc_filter_notice_messages[8]) == 0;
}

canonical_decompiled_code:
_BOOL8 func4()
{
return LODWORD(irc_filter_notice_messages[8]) == 0;
}

original_code:
int IRC_filter_show_notice_messages() {
  return (irc_filter_notice_messages.integer == 0);
}


original_code:
static void XSD_Variable_Init(xml_variable_t *document)
{
    memset(document, 0, sizeof(xml_variable_t));
}

canonical_original_code:
static void XSD_Variable_Init(struct xml_variable_s *document)
{
    memset(document, 0, sizeof(xml_variable_t));
}

variable_types: struct xml_variable_s { char *document_type; char *name; char *description; enum cvartype_t { t_boolean=0, t_enum=1, t_integer=2, t_float=3, t_string=4 } value_type; union { char *string_description; char *integer_description; char *float_description; struct { char *true_description; char *false_description; } boolean_value; struct variable_enum_value_s { char *name; char *description; struct variable_enum_value_s *next; } *enum_value; } value; char *remarks; } *

return_type: void

user_defined_types: struct xml_variable_s { char *document_type; char *name; char *description; enum cvartype_t value_type; union { char *string_description; char *integer_description; char *float_description; struct { char *true_description; char *false_description; } boolean_value; struct variable_enum_value_s *enum_value; } value; char *remarks; }


decompiled_code:
void __fastcall XSD_Variable_Free(void *ptr)
{
void *v2; // rdi
void *v3; // rdi
void *v4; // rdi
void *v5; // rdi
_QWORD *i; // rbx
void *v7; // rdi
void *v8; // rdi

v2 = (void *)*((_QWORD *)ptr + 1);
if ( v2 )
{
free(v2);
*((_QWORD *)ptr + 1) = 0LL;
}
v3 = (void *)*((_QWORD *)ptr + 2);
if ( v3 )
{
free(v3);
*((_QWORD *)ptr + 2) = 0LL;
}
v4 = (void *)*((_QWORD *)ptr + 6);
if ( v4 )
{
free(v4);
*((_QWORD *)ptr + 6) = 0LL;
}
switch ( *((_DWORD *)ptr + 6) )
{
case 0:
v8 = (void *)*((_QWORD *)ptr + 4);
if ( v8 )
{
free(v8);
*((_QWORD *)ptr + 4) = 0LL;
}
v5 = (void *)*((_QWORD *)ptr + 5);
if ( v5 )
goto LABEL_9;
break;
case 1:
for ( i = (_QWORD *)*((_QWORD *)ptr + 4); i; *((_QWORD *)ptr + 4) = i )
{
v7 = i;
i = (_QWORD *)i[2];
free(v7);
}
break;
case 2:
case 3:
case 4:
v5 = (void *)*((_QWORD *)ptr + 4);
if ( v5 )
LABEL_9:
free(v5);
break;
default:
break;
}
if ( *(_QWORD *)ptr )
free(*(void **)ptr);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func4(void *ptr)
{
void *v2; // rdi
void *v3; // rdi
void *v4; // rdi
void *v5; // rdi
_QWORD *i; // rbx
void *v7; // rdi
void *v8; // rdi

v2 = (void *)*((_QWORD *)ptr + 1);
if ( v2 )
{
free(v2);
*((_QWORD *)ptr + 1) = 0LL;
}
v3 = (void *)*((_QWORD *)ptr + 2);
if ( v3 )
{
free(v3);
*((_QWORD *)ptr + 2) = 0LL;
}
v4 = (void *)*((_QWORD *)ptr + 6);
if ( v4 )
{
free(v4);
*((_QWORD *)ptr + 6) = 0LL;
}
switch ( *((_DWORD *)ptr + 6) )
{
case 0:
v8 = (void *)*((_QWORD *)ptr + 4);
if ( v8 )
{
free(v8);
*((_QWORD *)ptr + 4) = 0LL;
}
v5 = (void *)*((_QWORD *)ptr + 5);
if ( v5 )
goto LABEL_9;
break;
case 1:
for ( i = (_QWORD *)*((_QWORD *)ptr + 4); i; *((_QWORD *)ptr + 4) = i )
{
v7 = i;
i = (_QWORD *)i[2];
free(v7);
}
break;
case 2:
case 3:
case 4:
v5 = (void *)*((_QWORD *)ptr + 4);
if ( v5 )
LABEL_9:
free(v5);
break;
default:
break;
}
if ( *(_QWORD *)ptr )
free(*(void **)ptr);
free(ptr);
}

original_code:
void XSD_Variable_Free(xml_t *doc)
{
    xml_variable_t *document = (xml_variable_t *) doc;
    if (document->name)
        if(document->name) { free(document->name); document->name = ((void *)0); };
    if (document->description)
        if(document->description) { free(document->description); document->description = ((void *)0); };
    if (document->remarks)
        if(document->remarks) { free(document->remarks); document->remarks = ((void *)0); };
    switch (document->value_type)
    {
    case t_boolean:
        if (document->value.boolean_value.true_description)
            if(document->value.boolean_value.true_description) { free(document->value.boolean_value.true_description); document->value.boolean_value.true_description = ((void *)0); };
        if (document->value.boolean_value.false_description)
            if(document->value.boolean_value.false_description) { free(document->value.boolean_value.false_description); document->value.boolean_value.false_description = ((void *)0); };
        break;
    case t_integer:
        if (document->value.integer_description)
            if(document->value.integer_description) { free(document->value.integer_description); document->value.integer_description = ((void *)0); };
        break;
    case t_float:
        if (document->value.float_description)
            if(document->value.float_description) { free(document->value.float_description); document->value.float_description = ((void *)0); };
        break;
    case t_string:
        if (document->value.string_description)
            if(document->value.string_description) { free(document->value.string_description); document->value.string_description = ((void *)0); };
        break;
    case t_enum:
        while (document->value.enum_value)
        {
            variable_enum_value_t *next = document->value.enum_value->next;
            if(document->value.enum_value) { free(document->value.enum_value); document->value.enum_value = ((void *)0); };
            document->value.enum_value = next;
        }
        break;
    }
    if (document->document_type)
        if(document->document_type) { free(document->document_type); document->document_type = ((void *)0); };
    if(document) { free(document); document = ((void *)0); };
}

canonical_original_code:
void XSD_Variable_Free(struct xml_s *doc)
{
    struct xml_variable_s *document = (xml_variable_t *) doc;
    if (document->name)
        if(document->name) { free(document->name); document->name = ((void *)0); };
    if (document->description)
        if(document->description) { free(document->description); document->description = ((void *)0); };
    if (document->remarks)
        if(document->remarks) { free(document->remarks); document->remarks = ((void *)0); };
    switch (document->value_type)
    {
    case t_boolean:
        if (document->value.boolean_value.true_description)
            if(document->value.boolean_value.true_description) { free(document->value.boolean_value.true_description); document->value.boolean_value.true_description = ((void *)0); };
        if (document->value.boolean_value.false_description)
            if(document->value.boolean_value.false_description) { free(document->value.boolean_value.false_description); document->value.boolean_value.false_description = ((void *)0); };
        break;
    case t_integer:
        if (document->value.integer_description)
            if(document->value.integer_description) { free(document->value.integer_description); document->value.integer_description = ((void *)0); };
        break;
    case t_float:
        if (document->value.float_description)
            if(document->value.float_description) { free(document->value.float_description); document->value.float_description = ((void *)0); };
        break;
    case t_string:
        if (document->value.string_description)
            if(document->value.string_description) { free(document->value.string_description); document->value.string_description = ((void *)0); };
        break;
    case t_enum:
        while (document->value.enum_value)
        {
            struct variable_enum_value_s *next = document->value.enum_value->next;
            if(document->value.enum_value) { free(document->value.enum_value); document->value.enum_value = ((void *)0); };
            document->value.enum_value = next;
        }
        break;
    }
    if (document->document_type)
        if(document->document_type) { free(document->document_type); document->document_type = ((void *)0); };
    if(document) { free(document); document = ((void *)0); };
}

variable_types:
doc
struct xml_s { char *document_type; } *

variable_types: struct variable_enum_value_s { char *name; char *description; struct variable_enum_value_s *next; } *

user_defined_types: enum cvartype_t { t_boolean=0, t_enum=1, t_integer=2, t_float=3, t_string=4 }


decompiled_code:
__int64 __fastcall XSD_Variable_Convert(__int64 a1, __int64 a2)
{
__int64 v2; // r12
__int64 v3; // rax
__int64 v4; // rbx
__int64 result; // rax

v2 = XSD_Document_New();
*(_QWORD *)(v2 + 8) = Q_strdup(*(_QWORD *)(a1 + 8));
v3 = Q_malloc(24LL, a2);
*(_QWORD *)(v3 + 16) = 0LL;
v4 = v3;
*(_OWORD *)v3 = 0LL;
*(_QWORD *)(v3 + 16) = Q_strdup(*(_QWORD *)(a1 + 16));
result = v2;
*(_QWORD *)(v2 + 32) = v4;
return result;
}

original_code:
xml_document_t * XSD_Variable_Convert(xml_t *doc)
{
    xml_document_t *ret;
    xml_variable_t *var = (xml_variable_t *) doc;
    ret = XSD_Document_New();
    ret->title = Q_strdup(var->name);
    {
        document_tag_text_t *text;
        text = (document_tag_text_t *) Q_malloc(sizeof(document_tag_text_t));
        memset(text, 0, sizeof(document_tag_text_t));
        text->type = tag_text;
        text->text = Q_strdup(var->description);
        ret->content = (document_tag_t *) text;
    }
    return ret;
}

canonical_original_code:
struct xml_document_s *XSD_Variable_Convert(struct xml_s *doc)
{
    struct xml_document_s *ret;
    struct xml_variable_s *var = (xml_variable_t *) doc;
    ret = XSD_Document_New();
    ret->title = Q_strdup(var->name);
    {
        struct document_tag_text_s *text;
        text = (struct document_tag_text_s *) Q_malloc(sizeof(document_tag_text_t));
        memset(text, 0, sizeof(document_tag_text_t));
        text->type = tag_text;
        text->text = Q_strdup(var->description);
        ret->content = (struct document_tag_s *) text;
    }
    return ret;
}

variable_types: struct xml_document_s { char *document_type; char *title; char *date; struct xml_document_author_s { enum document_tag_type_t { tag_text=0, tag_section=1, tag_p=2, tag_list=3, tag_dict=4, tag_hr=5, tag_h=6, tag_pre=7, tag_em=8, tag_a=9, tag_img=10, tag_color=11, tag_br=12, tag_sp=13, tag_li=14, tag_di=15 } type; struct xml_document_author_s *next; char *name; char *email; char *im; } *authors; struct document_tag_s { enum document_tag_type_t { tag_text=0, tag_section=1, tag_p=2, tag_list=3, tag_dict=4, tag_hr=5, tag_h=6, tag_pre=7, tag_em=8, tag_a=9, tag_img=10, tag_color=11, tag_br=12, tag_sp=13, tag_li=14, tag_di=15 } type; struct document_tag_s *next; } *content; } *

variable_types: struct document_tag_text_s { enum document_tag_type_t { tag_text=0, tag_section=1, tag_p=2, tag_list=3, tag_dict=4, tag_hr=5, tag_h=6, tag_pre=7, tag_em=8, tag_a=9, tag_img=10, tag_color=11, tag_br=12, tag_sp=13, tag_li=14, tag_di=15 } type; struct document_tag_s { enum document_tag_type_t { tag_text=0, tag_section=1, tag_p=2, tag_list=3, tag_dict=4, tag_hr=5, tag_h=6, tag_pre=7, tag_em=8, tag_a=9, tag_img=10, tag_color=11, tag_br=12, tag_sp=13, tag_li=14, tag_di=15 } type; struct document_tag_s *next; } *next; char *text; } *

user_defined_types: struct xml_document_s { char *document_type; char *title; char *date; struct xml_document_author_s *authors; struct document_tag_s *content; }

user_defined_types: struct document_tag_text_s { enum document_tag_type_t type; struct document_tag_s *next; char *text; }

user_defined_types: struct document_tag_s { enum document_tag_type_t type; struct document_tag_s *next; }

user_defined_types: struct xml_document_author_s { enum document_tag_type_t type; struct xml_document_author_s *next; char *name; char *email; char *im; }

user_defined_types: struct variable_enum_value_s { char *name; char *description; struct variable_enum_value_s *next; }


decompiled_code:
__int64 __fastcall R_MQW_NetGraph(char a1, __int64 a2, __int64 a3, int a4, __int64 a5, int a6, int a7, int a8, int a9, int a10, int a11, int a12, int a13, int a14)
{
int v16; // er13
int v17; // ebx
__int64 result; // rax
float v19; // xmm7_4
unsigned int v20; // er12
__int64 v21; // r8
size_t v22; // r14
size_t v23; // rax
int v24; // eax
char v25; // bp
int v26; // er13
int v27; // edx
int v28; // ebp
int v29; // ebp
int v30; // er14
int v32; // eax
__int64 v33; // rdx
int v34; // er15
float v35; // xmm1_4
float v36; // [rsp+Ch] [rbp-13Ch]
int v37; // [rsp+20h] [rbp-128h]
float v38; // [rsp+24h] [rbp-124h]
int v39; // [rsp+2Ch] [rbp-11Ch]
int v41; // [rsp+3Ch] [rbp-10Ch]
char v42[80]; // [rsp+40h] [rbp-108h] BYREF
char s[184]; // [rsp+90h] [rbp-B8h] BYREF

v16 = a11;
v17 = a12;
if ( !hud_5 )
{
hud_5 = HUD_Find("netgraph");
par_alpha_4 = HUD_FindVar(hud_5, "alpha");
par_full_3 = HUD_FindVar(hud_5, "full");
par_inframes_2 = HUD_FindVar(hud_5, "inframes");
par_maxping_1 = HUD_FindVar(hud_5, "scale");
par_dropheight_0 = HUD_FindVar(hud_5, "lostscale");
}
result = CL_CalcNet();
if ( v16 < 0 )
{
v16 = 256;
}
else
{
if ( v16 <= 15 )
return result;
result = 256LL;
if ( v16 > 256 )
v16 = 256;
}
if ( v17 < 0 )
{
v17 = 32;
}
else if ( v17 > 256 )
{
v17 = 256;
}
else if ( !v17 )
{
return result;
}
v19 = *(float *)(par_alpha_4 + 32);
if ( v19 < 0.0 )
v38 = *(float *)&LC0;
else
v38 = fminf(1.0, v19);
v20 = a10;
v39 = a9;
if ( a9 >= 0 && a10 >= 0 )
{
v37 = v16 - 1;
if ( a4 < 0 )
{
LABEL_22:
if ( v38 < 1.0 )
{
glDisable(3008LL);
glEnable(3042LL);
}
glTexEnvf(8960LL, 8704LL, 8448.0);
if ( *(float *)(par_full_3 + 32) == 0.0 )
GL_Bind((unsigned int)netgraphtexture);
else
GL_Bind(whitetexture);
v24 = v20 + v17;
if ( a14 )
v24 = v20;
v25 = a1 - v16;
v26 = v37;
LOBYTE(v41) = v25;
v36 = (float)v24;
while ( 1 )
{
v28 = v37 - v26;
v32 = *(_DWORD *)(a3 + 4LL * (unsigned __int8)(v26 + v41));
switch ( v32 )
{
case 10000:
v33 = 444LL;
break;
case 9999:
v33 = 316LL;
break;
case 9998:
v33 = 832LL;
break;
case 10001:
v33 = 16LL;
break;
default:
if ( v32 <= 8999 )
{
v33 = 1016LL;
if ( *(float *)(par_inframes_2 + 32) == 0.0 )
v32 = (int)(float)((float)(v17 * v32) / *(float *)(par_maxping_1 + 32));
goto LABEL_42;
}
v33 = 1016LL;
break;
}
v35 = *(float *)(par_dropheight_0 + 32) * (float)v17;
if ( v35 <= (float)v17 )
v32 = (int)v35;
else
v32 = (int)(float)v17;
LABEL_42:
if ( v32 < 0 )
v32 = 0;
if ( v32 > v17 )
v32 = v17;
v34 = v32;
if ( v38 >= 1.0 )
glColor4ubv();
else
glColor4ub(
*((unsigned __int8 *)&d_8to24table + v33),
*((unsigned __int8 *)&d_8to24table + v33 + 1),
*((unsigned __int8 *)&d_8to24table + v33 + 2),
(unsigned __int8)(int)(float)(v38 * 255.0));
v27 = v20 + v34;
if ( !a13 )
v28 = v26;
v29 = v39 + v28;
if ( !a14 )
v27 = v20 + v17 - v34;
v30 = v27;
glBegin(7LL);
glTexCoord2f(0.0);
glVertex2f(COERCE_DOUBLE((unsigned __int64)COERCE_UNSIGNED_INT((float)v29)), v36);
glTexCoord2f(COERCE_DOUBLE((unsigned __int64)LC0));
glVertex2f(COERCE_DOUBLE((unsigned __int64)COERCE_UNSIGNED_INT((float)(v29 + 1))), v36);
glTexCoord2f(COERCE_DOUBLE((unsigned __int64)LC0));
glVertex2f(COERCE_DOUBLE((unsigned __int64)COERCE_UNSIGNED_INT((float)(v29 + 1))), (float)v30);
glTexCoord2f(0.0);
glVertex2f(COERCE_DOUBLE((unsigned __int64)COERCE_UNSIGNED_INT((float)v29)), (float)v30);
glEnd();
if ( v26-- == 0 )
{
glColor3f(1.0, 1.0);
glTexEnvf(8960LL, 8704LL, 7681.0);
glEnable(3008LL);
glDisable(3042LL);
return glEnable(3553LL);
}
}
}
if ( a6 >= 0 )
goto LABEL_18;
goto LABEL_67;
}
if ( a4 < 0 )
{
result = HUD_PrepareDraw(hud_5, (unsigned int)v16, (unsigned int)v17, &a9, &a10);
if ( (_DWORD)result )
{
v20 = a10;
v39 = a9;
v37 = v16 - 1;
goto LABEL_22;
}
}
else
{
result = HUD_PrepareDraw(hud_5, (unsigned int)v16, (unsigned int)(v17 + 8), &a9, &a10);
if ( (_DWORD)result )
{
v20 = a10;
v39 = a9;
if ( a6 >= 0 )
{
LABEL_18:
strlcpy(v42, &unk_A28, 80LL);
v21 = 99LL;
if ( a4 <= 99 )
v21 = (unsigned int)a4;
snprintf(s, 0x80uLL, format, (unsigned int)a6, v21);
v22 = strlen(s);
v23 = strlen(v42);
strlcpy(&v42[v23 - v22 - 3], s, v22 + 83 - v23);
Draw_String((unsigned int)(v39 + 4), v20, v42);
v37 = v16 - 1;
goto LABEL_21;
}
LABEL_67:
snprintf(v42, 0x50uLL, " %3i%% packet loss", (unsigned int)a4);
v37 = v16 - 1;
v42[(v16 - 1) >> 3] = 0;
Draw_String((unsigned int)(v39 + 3), v20, v42);
LABEL_21:
v20 += 8;
goto LABEL_22;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(char a1, __int64 a2, __int64 a3, int a4, __int64 a5, int a6, int a7, int a8, int a9, int a10, int a11, int a12, int a13, int a14)
{
int v16; // er13
int v17; // ebx
__int64 result; // rax
float v19; // xmm7_4
unsigned int v20; // er12
__int64 v21; // r8
size_t v22; // r14
size_t v23; // rax
int v24; // eax
char v25; // bp
int v26; // er13
int v27; // edx
int v28; // ebp
int v29; // ebp
int v30; // er14
int v32; // eax
__int64 v33; // rdx
int v34; // er15
float v35; // xmm1_4
float v36; // [rsp+Ch] [rbp-13Ch]
int v37; // [rsp+20h] [rbp-128h]
float v38; // [rsp+24h] [rbp-124h]
int v39; // [rsp+2Ch] [rbp-11Ch]
int v41; // [rsp+3Ch] [rbp-10Ch]
char v42[80]; // [rsp+40h] [rbp-108h] BYREF
char s[184]; // [rsp+90h] [rbp-B8h] BYREF

v16 = a11;
v17 = a12;
if ( !hud_5 )
{
hud_5 = HUD_Find("netgraph");
par_alpha_4 = HUD_FindVar(hud_5, "alpha");
par_full_3 = HUD_FindVar(hud_5, "full");
par_inframes_2 = HUD_FindVar(hud_5, "inframes");
par_maxping_1 = HUD_FindVar(hud_5, "scale");
par_dropheight_0 = HUD_FindVar(hud_5, "lostscale");
}
result = CL_CalcNet();
if ( v16 < 0 )
{
v16 = 256;
}
else
{
if ( v16 <= 15 )
return result;
result = 256LL;
if ( v16 > 256 )
v16 = 256;
}
if ( v17 < 0 )
{
v17 = 32;
}
else if ( v17 > 256 )
{
v17 = 256;
}
else if ( !v17 )
{
return result;
}
v19 = *(float *)(par_alpha_4 + 32);
if ( v19 < 0.0 )
v38 = *(float *)&LC0;
else
v38 = fminf(1.0, v19);
v20 = a10;
v39 = a9;
if ( a9 >= 0 && a10 >= 0 )
{
v37 = v16 - 1;
if ( a4 < 0 )
{
LABEL_22:
if ( v38 < 1.0 )
{
glDisable(3008LL);
glEnable(3042LL);
}
glTexEnvf(8960LL, 8704LL, 8448.0);
if ( *(float *)(par_full_3 + 32) == 0.0 )
GL_Bind((unsigned int)netgraphtexture);
else
GL_Bind(whitetexture);
v24 = v20 + v17;
if ( a14 )
v24 = v20;
v25 = a1 - v16;
v26 = v37;
LOBYTE(v41) = v25;
v36 = (float)v24;
while ( 1 )
{
v28 = v37 - v26;
v32 = *(_DWORD *)(a3 + 4LL * (unsigned __int8)(v26 + v41));
switch ( v32 )
{
case 10000:
v33 = 444LL;
break;
case 9999:
v33 = 316LL;
break;
case 9998:
v33 = 832LL;
break;
case 10001:
v33 = 16LL;
break;
default:
if ( v32 <= 8999 )
{
v33 = 1016LL;
if ( *(float *)(par_inframes_2 + 32) == 0.0 )
v32 = (int)(float)((float)(v17 * v32) / *(float *)(par_maxping_1 + 32));
goto LABEL_42;
}
v33 = 1016LL;
break;
}
v35 = *(float *)(par_dropheight_0 + 32) * (float)v17;
if ( v35 <= (float)v17 )
v32 = (int)v35;
else
v32 = (int)(float)v17;
LABEL_42:
if ( v32 < 0 )
v32 = 0;
if ( v32 > v17 )
v32 = v17;
v34 = v32;
if ( v38 >= 1.0 )
glColor4ubv();
else
glColor4ub(
*((unsigned __int8 *)&d_8to24table + v33),
*((unsigned __int8 *)&d_8to24table + v33 + 1),
*((unsigned __int8 *)&d_8to24table + v33 + 2),
(unsigned __int8)(int)(float)(v38 * 255.0));
v27 = v20 + v34;
if ( !a13 )
v28 = v26;
v29 = v39 + v28;
if ( !a14 )
v27 = v20 + v17 - v34;
v30 = v27;
glBegin(7LL);
glTexCoord2f(0.0);
glVertex2f(COERCE_DOUBLE((unsigned __int64)COERCE_UNSIGNED_INT((float)v29)), v36);
glTexCoord2f(COERCE_DOUBLE((unsigned __int64)LC0));
glVertex2f(COERCE_DOUBLE((unsigned __int64)COERCE_UNSIGNED_INT((float)(v29 + 1))), v36);
glTexCoord2f(COERCE_DOUBLE((unsigned __int64)LC0));
glVertex2f(COERCE_DOUBLE((unsigned __int64)COERCE_UNSIGNED_INT((float)(v29 + 1))), (float)v30);
glTexCoord2f(0.0);
glVertex2f(COERCE_DOUBLE((unsigned __int64)COERCE_UNSIGNED_INT((float)v29)), (float)v30);
glEnd();
if ( v26-- == 0 )
{
glColor3f(1.0, 1.0);
glTexEnvf(8960LL, 8704LL, 7681.0);
glEnable(3008LL);
glDisable(3042LL);
return glEnable(3553LL);
}
}
}
if ( a6 >= 0 )
goto LABEL_18;
goto LABEL_67;
}
if ( a4 < 0 )
{
result = HUD_PrepareDraw(hud_5, (unsigned int)v16, (unsigned int)v17, &a9, &a10);
if ( (_DWORD)result )
{
v20 = a10;
v39 = a9;
v37 = v16 - 1;
goto LABEL_22;
}
}
else
{
result = HUD_PrepareDraw(hud_5, (unsigned int)v16, (unsigned int)(v17 + 8), &a9, &a10);
if ( (_DWORD)result )
{
v20 = a10;
v39 = a9;
if ( a6 >= 0 )
{
LABEL_18:
strlcpy(v42, &unk_A28, 80LL);
v21 = 99LL;
if ( a4 <= 99 )
v21 = (unsigned int)a4;
snprintf(s, 0x80uLL, format, (unsigned int)a6, v21);
v22 = strlen(s);
v23 = strlen(v42);
strlcpy(&v42[v23 - v22 - 3], s, v22 + 83 - v23);
Draw_String((unsigned int)(v39 + 4), v20, v42);
v37 = v16 - 1;
goto LABEL_21;
}
LABEL_67:
snprintf(v42, 0x50uLL, " %3i%% packet loss", (unsigned int)a4);
v37 = v16 - 1;
v42[(v16 - 1) >> 3] = 0;
Draw_String((unsigned int)(v39 + 3), v20, v42);
LABEL_21:
v20 += 8;
goto LABEL_22;
}
}
return result;
}

original_code:
void R_MQW_NetGraph(int outgoing_sequence, int incoming_sequence, int *packet_latency,
                int lost, int minping, int avgping, int maxping, int devping,
                int posx, int posy, int width, int height, int revx, int revy)
{
    int a, x, i, y;
    char st[80];
    float alpha;
    static hud_t *hud = ((void *)0);
    static cvar_t
        *par_alpha, *par_full, *par_inframes, *par_maxping, *par_dropheight;
    if (hud == ((void *)0))
    {
        hud = HUD_Find("netgraph");
        par_alpha = HUD_FindVar(hud, "alpha");
        par_full = HUD_FindVar(hud, "full");
        par_inframes = HUD_FindVar(hud, "inframes");
        par_maxping = HUD_FindVar(hud, "scale");
        par_dropheight = HUD_FindVar(hud, "lostscale");
    }
    CL_CalcNet();
    alpha = par_alpha->value;
    if (width < 0)
        width = 256;
    width = ((width) < (256) ? (width) : (256));
    if (width < 16)
        return;
    if (height < 0)
        height = 32;
    if (height > 256)
        height = 256;
    if (height < 1)
        return;
    if (alpha < 0 || alpha > 1)
        alpha = 1;
    if (posx < 0 || posy < 0)
    {
        int w, h;
        w = width;
        h = height;
        if (lost >= 0)
            h += 8;
        if (!HUD_PrepareDraw(hud, w, h, &posx, &posy))
            return;
    }
    x = posx;
    y = posy;
    if (lost >= 0)
    {
        if (avgping < 0)
        {
            snprintf(st, sizeof (st)," %3i%% packet loss", lost);
            st[(width-1)/8] = 0;
            Draw_String(x+3, y, st);
        }
        else
        {
            char buf[128];
            if (lost > 99)
                lost = 99;
            strlcpy(st, "\x1D\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1F", sizeof (st));
            snprintf (buf, sizeof (buf), " %i \xf %i%% ", avgping, lost);
            strlcpy (st + strlen(st) - strlen(buf) - 3, buf, sizeof (st) - strlen (st) + strlen (buf) + 3);
            Draw_String(x+4, y, st);
        }
        y += 8;
    }
    if (alpha < 1)
    {
        glDisable(0x0BC0);
        glEnable (0x0BE2);
    }
    glTexEnvf(0x2300, 0x2200, 0x2100);
    if (par_full->value)
        GL_Bind(whitetexture);
    else
        GL_Bind(netgraphtexture);
    for (a=0; a < width; a++)
    {
        int px, py1, py2;
        unsigned char *pColor;
        int h, color;
        i = (outgoing_sequence-a-1) & 255;
        h = packet_latency[i];
        if (h == 10000)
            color = 0x6f;
        else if (h == 9999)
            color = 0x4f;
        else if (h == 9998)
            color = 0xd0;
        else if (h == 10001)
            color = 4;
        else
            color = 0xfe;
        if (h < 9000)
        {
            if (!par_inframes->value)
                h = h*height/par_maxping->value;
        }
        else
            h = ((height) < (height*par_dropheight->value) ? (height) : (height*par_dropheight->value));
        (h = ((((h) > (0) ? (h) : (0))) < (height) ? (((h) > (0) ? (h) : (0))) : (height)));
        pColor = (unsigned char *) &d_8to24table[(byte) color];
        if (alpha < 1)
            glColor4ub (pColor[0], pColor[1], pColor[2], (byte)(alpha*255));
        else
            glColor4ubv ( pColor );
        px = x + (revx ? a : width-a-1);
        if (revy)
        {
            py1 = y + 0;
            py2 = y + h;
        }
        else
        {
            py1 = y + height;
            py2 = y + height-h;
        }
        glBegin (0x0007);
        glTexCoord2f (0, 0);
        glVertex2f (px, py1);
        glTexCoord2f (1, 0);
        glVertex2f (px+1, py1);
        glTexCoord2f (1, h/2.0);
        glVertex2f (px+1, py2);
        glTexCoord2f (0, h/2.0);
        glVertex2f (px, py2);
        glEnd ();
    }
    glColor3f(1,1,1);
    glTexEnvf ( 0x2300, 0x2200, 0x1E01 );
    glEnable(0x0BC0);
    glDisable(0x0BE2);
    glEnable(0x0DE1);
}

canonical_original_code:
void R_MQW_NetGraph(int outgoing_sequence, int incoming_sequence, int *packet_latency, int lost, int minping, int avgping, int maxping, int devping, int posx, int posy, int width, int height, int revx, int revy)
{
    int a; int x; int i; int y;
    char st[80];
    float alpha;
    static struct hud_s *hud = ((void *)0);
    static struct cvar_s *par_alpha; static struct cvar_s *par_full; static struct cvar_s *par_inframes; static struct cvar_s *par_maxping; static struct cvar_s *par_dropheight;
    if (hud == ((void *)0))
    {
        hud = HUD_Find("netgraph");
        par_alpha = HUD_FindVar(hud, "alpha");
        par_full = HUD_FindVar(hud, "full");
        par_inframes = HUD_FindVar(hud, "inframes");
        par_maxping = HUD_FindVar(hud, "scale");
        par_dropheight = HUD_FindVar(hud, "lostscale");
    }
    CL_CalcNet();
    alpha = par_alpha->value;
    if (width < 0)
        width = 256;
    width = ((width) < (256) ? (width) : (256));
    if (width < 16)
        return;
    if (height < 0)
        height = 32;
    if (height > 256)
        height = 256;
    if (height < 1)
        return;
    if (alpha < 0 || alpha > 1)
        alpha = 1;
    if (posx < 0 || posy < 0)
    {
        int w; int h;
        w = width;
        h = height;
        if (lost >= 0)
            h += 8;
        if (!HUD_PrepareDraw(hud, w, h, &posx, &posy))
            return;
    }
    x = posx;
    y = posy;
    if (lost >= 0)
    {
        if (avgping < 0)
        {
            snprintf(st, sizeof (st)," %3i%% packet loss", lost);
            st[(width-1)/8] = 0;
            Draw_String(x+3, y, st);
        }
        else
        {
            char buf[128];
            if (lost > 99)
                lost = 99;
            strlcpy(st, "\x1D\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1F", sizeof (st));
            snprintf (buf, sizeof (buf), " %i \xf %i%% ", avgping, lost);
            strlcpy (st + strlen(st) - strlen(buf) - 3, buf, sizeof (st) - strlen (st) + strlen (buf) + 3);
            Draw_String(x+4, y, st);
        }
        y += 8;
    }
    if (alpha < 1)
    {
        glDisable(0x0BC0);
        glEnable (0x0BE2);
    }
    glTexEnvf(0x2300, 0x2200, 0x2100);
    if (par_full->value)
        GL_Bind(whitetexture);
    else
        GL_Bind(netgraphtexture);
    for (a=0; a < width; a++)
    {
        int px; int py1; int py2;
        unsigned char *pColor;
        int h; int color;
        i = (outgoing_sequence-a-1) & 255;
        h = packet_latency[i];
        if (h == 10000)
            color = 0x6f;
        else if (h == 9999)
            color = 0x4f;
        else if (h == 9998)
            color = 0xd0;
        else if (h == 10001)
            color = 4;
        else
            color = 0xfe;
        if (h < 9000)
        {
            if (!par_inframes->value)
                h = h*height/par_maxping->value;
        }
        else
            h = ((height) < (height*par_dropheight->value) ? (height) : (height*par_dropheight->value));
        (h = ((((h) > (0) ? (h) : (0))) < (height) ? (((h) > (0) ? (h) : (0))) : (height)));
        pColor = (unsigned char *) &d_8to24table[(unsigned char) color];
        if (alpha < 1)
            glColor4ub (pColor[0], pColor[1], pColor[2], (byte)(alpha*255));
        else
            glColor4ubv ( pColor );
        px = x + (revx ? a : width-a-1);
        if (revy)
        {
            py1 = y + 0;
            py2 = y + h;
        }
        else
        {
            py1 = y + height;
            py2 = y + height-h;
        }
        glBegin (0x0007);
        glTexCoord2f (0, 0);
        glVertex2f (px, py1);
        glTexCoord2f (1, 0);
        glVertex2f (px+1, py1);
        glTexCoord2f (1, h/2.0);
        glVertex2f (px+1, py2);
        glTexCoord2f (0, h/2.0);
        glVertex2f (px, py2);
        glEnd ();
    }
    glColor3f(1,1,1);
    glTexEnvf ( 0x2300, 0x2200, 0x1E01 );
    glEnable(0x0BC0);
    glDisable(0x0BE2);
    glEnable(0x0DE1);
}

variable_types: lost int

variable_types: minping int

variable_types: avgping int

variable_types: maxping int

variable_types: devping int

variable_types: posx int

variable_types: posy int

variable_types: width int

variable_types: height int

variable_types: revx int

variable_types: revy int

variable_types: a int

variable_types: x int

variable_types: i int

variable_types: y int

variable_types:
st
char [80]

variable_types: alpha float

variable_types: struct hud_s { char *name; char *description; void (*draw_func)(struct hud_s *); struct cvar_s { char *name; char *string; int flags; void (*OnChange)(struct cvar_s *var, char *value, enum qbool { false=0, true=1 } *cancel); float value; float maxrulesetvalue; float minrulesetvalue; char *defaultvalue; char *latchedString; int integer; unsigned char color[4]; enum qbool { false=0, true=1 } modified; enum qbool { false=0, true=1 } teamplay; struct cvar_group_s { char name[65]; int count; struct cvar_s *head; struct cvar_group_s *next; } *group; struct cvar_s *next_in_group; struct cvar_s *hash_next; struct cvar_s *next; } *order; struct cvar_s *show; struct cvar_s *frame; struct cvar_s *frame_color; unsigned char frame_color_cache[4]; struct cvar_s *opacity; struct cvar_s *place; struct hud_s *place_hud; enum qbool { false=0, true=1 } place_outside; int place_num; struct cvar_s *align_x; struct cvar_s *align_y; int align_x_num; int align_y_num; struct cvar_s *pos_x; struct cvar_s *pos_y; struct cvar_s **params; int num_params; enum cactive_t { ca_disconnected=0, ca_demostart=1, ca_connected=2, ca_onserver=3, ca_active=4 } min_state; unsigned int flags; int lx; int al; int last_try_sequence; int last_draw_sequence; struct hud_s *next; } *

variable_types: w int

variable_types: h int

variable_types:
buf
char [128]

variable_types: px int

variable_types:
pColor
unsigned char *

variable_types: color int

user_defined_types: struct hud_s { char *name; char *description; void (*draw_func)(struct hud_s *); struct cvar_s *order; struct cvar_s *show; struct cvar_s *frame; struct cvar_s *frame_color; unsigned char frame_color_cache[4]; struct cvar_s *opacity; struct cvar_s *place; struct hud_s *place_hud; enum qbool place_outside; int place_num; struct cvar_s *align_x; struct cvar_s *align_y; int align_x_num; int align_y_num; struct cvar_s *pos_x; struct cvar_s *pos_y; struct cvar_s **params; int num_params; enum cactive_t min_state; unsigned int flags; int lx; int al; int last_try_sequence; int last_draw_sequence; struct hud_s *next; }

user_defined_types: struct cvar_s { char *name; char *string; int flags; void (*OnChange)(struct cvar_s *var, char *value, enum qbool *cancel); float value; float maxrulesetvalue; float minrulesetvalue; char *defaultvalue; char *latchedString; int integer; unsigned char color[4]; enum qbool modified; enum qbool teamplay; struct cvar_group_s *group; struct cvar_s *next_in_group; struct cvar_s *hash_next; struct cvar_s *next; }


decompiled_code:
__int64 __fastcall thread_func(_DWORD *a1)
{
int v1; // eax
size_t v2; // rax
int v3; // eax
size_t v4; // rax

*a1 += 50;
_mythread_debug_futex_init();
futex_down_constprop_0_isra_0();
v1 = mythread_self();
sprintf(&debug_msg, "Thread %ld: Incremented count by 50 and will now yield\n", v1);
v2 = strlen(&debug_msg);
write(1, &debug_msg, v2);
futex_up_constprop_0_isra_0();
mythread_yield();
*a1 += 50;
_mythread_debug_futex_init();
futex_down_constprop_0_isra_0();
v3 = mythread_self();
sprintf(&debug_msg, "Thread %ld: Incremented count by 50 and will now exit\n", v3);
v4 = strlen(&debug_msg);
write(1, &debug_msg, v4);
futex_up_constprop_0_isra_0();
mythread_exit(0LL);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(_DWORD *a1)
{
int v1; // eax
size_t v2; // rax
int v3; // eax
size_t v4; // rax

*a1 += 50;
_mythread_debug_futex_init();
func3();
v1 = mythread_self();
sprintf(&debug_msg, "Thread %ld: Incremented count by 50 and will now yield\n", v1);
v2 = strlen(&debug_msg);
write(1, &debug_msg, v2);
func4();
mythread_yield();
*a1 += 50;
_mythread_debug_futex_init();
func3();
v3 = mythread_self();
sprintf(&debug_msg, "Thread %ld: Incremented count by 50 and will now exit\n", v3);
v4 = strlen(&debug_msg);
write(1, &debug_msg, v4);
func4();
mythread_exit(0LL);
return 0LL;
}

original_code:
void *thread_func(void *arg)
{
 int *count = (int *)arg;
 *count = *count + 50;
 __mythread_debug_futex_init(); futex_down(&debug_futex); sprintf(debug_msg, "Thread %ld: Incremented count by 50 and will now yield\n", (unsigned long)mythread_self().tid); write(1, debug_msg, strlen(debug_msg)); futex_up(&debug_futex);;
 mythread_yield();
 *count = *count + 50;
 __mythread_debug_futex_init(); futex_down(&debug_futex); sprintf(debug_msg, "Thread %ld: Incremented count by 50 and will now exit\n", (unsigned long)mythread_self().tid); write(1, debug_msg, strlen(debug_msg)); futex_up(&debug_futex);;
 mythread_exit(((void *)0));
 return ((void *)0);
}

variable_types:
arg
void *

variable_types:
count
int *

return_type: void *


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebp
__int64 v4; // rbx
char *v5; // rcx
char *v6; // rdi
__int64 v7; // rbx
size_t v8; // rax
__int64 v9; // rcx
__int64 v10; // rdx
size_t v11; // rax
__m128i v12; // xmm0
size_t v13; // rax
char v15[96]; // [rsp+8h] [rbp-60h] BYREF

v3 = 0;
v4 = 0LL;
do
{
*(_DWORD *)&v15[v4 + 40] = v3;
v5 = &v15[v4 + 40];
++v3;
v6 = &v15[v4 + 8];
v4 += 4LL;
mythread_create(v6, 0LL, thread_func, v5);
}
while ( v3 != 8 );
v7 = 0LL;
do
{
_mythread_debug_futex_init();
futex_down_constprop_0_isra_0();
sprintf(&debug_msg, "Main: Will now wait for thread %ld. Yielding..\n", *(int *)&v15[4 * v7 + 8]);
v8 = strlen(&debug_msg);
write(1, &debug_msg, v8);
futex_up_constprop_0_isra_0();
mythread_join(*(unsigned int *)&v15[4 * (int)v7 + 8], v15);
_mythread_debug_futex_init();
futex_down_constprop_0_isra_0();
v9 = *(unsigned int *)&v15[4 * v7 + 40];
v10 = *(int *)&v15[4 * v7++ + 8];
sprintf(&debug_msg, "Main: Thread %ld exited and increment count to %d\n", v10, v9);
v11 = strlen(&debug_msg);
write(1, &debug_msg, v11);
futex_up_constprop_0_isra_0();
}
while ( v7 != 8 );
_mythread_debug_futex_init();
futex_down_constprop_0_isra_0();
v12 = _mm_load_si128((const __m128i *)&LC4);
*((_QWORD *)&debug_msg + 6) = 0xA2E2E74697865LL;
*(__m128i *)&debug_msg = v12;
*((__m128i *)&debug_msg + 1) = _mm_load_si128((const __m128i *)&LC5);
*((__m128i *)&debug_msg + 2) = _mm_load_si128((const __m128i *)&LC6);
v13 = strlen(&debug_msg);
write(1, &debug_msg, v13);
futex_up_constprop_0_isra_0();
mythread_exit(0LL);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebp
__int64 v4; // rbx
char *v5; // rcx
char *v6; // rdi
__int64 v7; // rbx
size_t v8; // rax
__int64 v9; // rcx
__int64 v10; // rdx
size_t v11; // rax
__m128i v12; // xmm0
size_t v13; // rax
char v15[96]; // [rsp+8h] [rbp-60h] BYREF

v3 = 0;
v4 = 0LL;
do
{
*(_DWORD *)&v15[v4 + 40] = v3;
v5 = &v15[v4 + 40];
++v3;
v6 = &v15[v4 + 8];
v4 += 4LL;
mythread_create(v6, 0LL, thread_func, v5);
}
while ( v3 != 8 );
v7 = 0LL;
do
{
_mythread_debug_futex_init();
func3();
sprintf(&debug_msg, "Main: Will now wait for thread %ld. Yielding..\n", *(int *)&v15[4 * v7 + 8]);
v8 = strlen(&debug_msg);
write(1, &debug_msg, v8);
func4();
mythread_join(*(unsigned int *)&v15[4 * (int)v7 + 8], v15);
_mythread_debug_futex_init();
func3();
v9 = *(unsigned int *)&v15[4 * v7 + 40];
v10 = *(int *)&v15[4 * v7++ + 8];
sprintf(&debug_msg, "Main: Thread %ld exited and increment count to %d\n", v10, v9);
v11 = strlen(&debug_msg);
write(1, &debug_msg, v11);
func4();
}
while ( v7 != 8 );
_mythread_debug_futex_init();
func3();
v12 = _mm_load_si128((const __m128i *)&LC4);
*((_QWORD *)&debug_msg + 6) = 0xA2E2E74697865LL;
*(__m128i *)&debug_msg = v12;
*((__m128i *)&debug_msg + 1) = _mm_load_si128((const __m128i *)&LC5);
*((__m128i *)&debug_msg + 2) = _mm_load_si128((const __m128i *)&LC6);
v13 = strlen(&debug_msg);
write(1, &debug_msg, v13);
func4();
mythread_exit(0LL);
return 0;
}

original_code:
int main()
{
 mythread_t threads[8];
 int count[8];
 int i;
 char *status;
 for (i = 0; i < 8; i++) {
  count[i] = i;
  mythread_create(&threads[i], ((void *)0), thread_func, &count[i]);
 }
 for (i = 0; i < 8; i++) {
  __mythread_debug_futex_init(); futex_down(&debug_futex); sprintf(debug_msg, "Main: Will now wait for thread %ld. Yielding..\n", (unsigned long)threads[i].tid); write(1, debug_msg, strlen(debug_msg)); futex_up(&debug_futex);;
  mythread_join(threads[i], (void **)&status);
  __mythread_debug_futex_init(); futex_down(&debug_futex); sprintf(debug_msg, "Main: Thread %ld exited and increment count to %d\n", (unsigned long)threads[i].tid, count[i]); write(1, debug_msg, strlen(debug_msg)); futex_up(&debug_futex);;
 }
 __mythread_debug_futex_init(); futex_down(&debug_futex); sprintf(debug_msg, "Main: All threads completed execution. Will now exit..\n"); write(1, debug_msg, strlen(debug_msg)); futex_up(&debug_futex);;
 mythread_exit(((void *)0));
 return 0;
}

canonical_original_code:
int main()
{
 struct mythread threads[8];
 int count[8];
 int i;
 char *status;
 for (i = 0; i < 8; i++) {
  count[i] = i;
  mythread_create(&threads[i], ((void *)0), thread_func, &count[i]);
 }
 for (i = 0; i < 8; i++) {
  __mythread_debug_futex_init(); futex_down(&debug_futex); sprintf(debug_msg, "Main: Will now wait for thread %ld. Yielding..\n", (unsigned long)threads[i].tid); write(1, debug_msg, strlen(debug_msg)); futex_up(&debug_futex);;
  mythread_join(threads[i], (void **)&status);
  __mythread_debug_futex_init(); futex_down(&debug_futex); sprintf(debug_msg, "Main: Thread %ld exited and increment count to %d\n", (unsigned long)threads[i].tid, count[i]); write(1, debug_msg, strlen(debug_msg)); futex_up(&debug_futex);;
 }
 __mythread_debug_futex_init(); futex_down(&debug_futex); sprintf(debug_msg, "Main: All threads completed execution. Will now exit..\n"); write(1, debug_msg, strlen(debug_msg)); futex_up(&debug_futex);;
 mythread_exit(((void *)0));
 return 0;
}

variable_types:
threads
struct mythread { int tid; } [8]

variable_types:
count
int [8]

variable_types:
status
char *


decompiled_code:
__int64 __fastcall sys_futex(__int64 a1, unsigned int a2, unsigned int a3, __int64 a4)
{
return syscall(202LL, a1, a2, a3, a4, 0LL, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, unsigned int a2, unsigned int a3, __int64 a4)
{
return syscall(202LL, a1, a2, a3, a4, 0LL, 0LL);
}

original_code:
int sys_futex(int *uaddr, int op, int val, const struct timespec *timeout)
{
  return syscall(202, uaddr, op, val, timeout, ((void *)0), 0);
}

canonical_original_code:
int sys_futex(int *uaddr, int op, int val, struct timespec *timeout)
{
  return syscall(202, uaddr, op, val, timeout, ((void *)0), 0);
}

variable_types:
uaddr
int *

variable_types: op int

variable_types: val int

variable_types: struct timespec { long tv_sec; long tv_nsec; } *


decompiled_code:
__int64 __fastcall futex_await(__int64 a1, unsigned int a2)
{
return sys_futex(a1, 2u, a2, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, unsigned int a2)
{
return func0(a1, 2u, a2, 0LL);
}

original_code:
int futex_await(struct futex *futx, int signal)
{
 return sys_futex(&futx->count, 2, signal, ((void *)0));
}

variable_types:
futx
struct futex { int count; } *

variable_types: signal int


decompiled_code:
void __fastcall futex_init(_DWORD *a1, int a2)
{
*a1 = a2;
}

canonical_decompiled_code:
void __fastcall func4(_DWORD *a1, int a2)
{
*a1 = a2;
}

original_code:
void futex_init(struct futex *futx, int val)
{
 futx->count = val;
 __futex_commit();
}


decompiled_code:
__int64 mythread_self()
{
return _mythread_gettid();
}

canonical_decompiled_code:
__int64 func0()
{
return _mythread_gettid();
}

original_code:
mythread_t mythread_self()
{
 pid_t tid;
 mythread_t self_tcb;
 tid = __mythread_gettid();
 self_tcb.tid = tid;
 return (self_tcb);
}

canonical_original_code:
struct mythread mythread_self()
{
 int tid;
 struct mythread self_tcb;
 tid = __mythread_gettid();
 self_tcb.tid = tid;
 return (self_tcb);
}

variable_types: tid int

return_type: struct mythread { int tid; }


decompiled_code:
__int64 __fastcall mythread_exit(__int64 a1)
{
__int64 v2; // rax
__int64 v3; // rdi
__int64 v4; // rax

v2 = _mythread_selfptr();
*(_DWORD *)(v2 + 4) = 3;
v3 = v2;
*(_QWORD *)(v2 + 24) = a1;
v4 = *(_QWORD *)(v2 + 32);
if ( v4 )
*(_DWORD *)(v4 + 4) = 1;
_mythread_dispatcher(v3);
return _mythread_do_exit();
}

original_code:
void mythread_exit(void *return_val)
{
 mythread_private_t *self_ptr;
 self_ptr = __mythread_selfptr();
 self_ptr->state = 3;
 self_ptr->returnValue = return_val;
 if (self_ptr->blockedForJoin != ((void *)0))
  self_ptr->blockedForJoin->state = 1;
 __mythread_dispatcher(self_ptr);
 __mythread_do_exit();
}

canonical_original_code:
void mythread_exit(void *return_val)
{
 struct mythread_private *self_ptr;
 self_ptr = __mythread_selfptr();
 self_ptr->state = 3;
 self_ptr->returnValue = return_val;
 if (self_ptr->blockedForJoin != ((void *)0))
  self_ptr->blockedForJoin->state = 1;
 __mythread_dispatcher(self_ptr);
 __mythread_do_exit();
}

variable_types: struct mythread_private { int tid; int state; void *(*start_func)(void *); void *args; void *returnValue; struct mythread_private *blockedForJoin; struct futex { int count; } sched_futex; struct mythread_private *prev; } *

user_defined_types: struct mythread_private { int tid; int state; void *(*start_func)(void *); void *args; void *returnValue; struct mythread_private *blockedForJoin; struct futex sched_futex; struct mythread_private *prev; }


decompiled_code:
void __fastcall mythread_q_init(__int64 a1)
{
*(_QWORD *)(a1 + 48) = a1;
*(_QWORD *)(a1 + 56) = a1;
mythread_q_head = a1;
}

canonical_decompiled_code:
void __fastcall func0(__int64 a1)
{
*(_QWORD *)(a1 + 48) = a1;
*(_QWORD *)(a1 + 56) = a1;
mythread_q_head = a1;
}

original_code:
void mythread_q_init(mythread_private_t * node)
{
 node->prev = node;
 node->next = node;
 mythread_q_head = node;
}

canonical_original_code:
void mythread_q_init(struct mythread_private *node)
{
 node->prev = node;
 node->next = node;
 mythread_q_head = node;
}


decompiled_code:
void __fastcall mythread_q_add(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rdx

v1 = mythread_q_head;
if ( mythread_q_head )
{
v2 = *(_QWORD *)(mythread_q_head + 48);
*(_QWORD *)(a1 + 56) = mythread_q_head;
*(_QWORD *)(a1 + 48) = v2;
*(_QWORD *)(*(_QWORD *)(v1 + 48) + 56LL) = a1;
*(_QWORD *)(v1 + 48) = a1;
}
else
{
mythread_q_init(a1);
}
}

canonical_decompiled_code:
void __fastcall func1(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rdx

v1 = mythread_q_head;
if ( mythread_q_head )
{
v2 = *(_QWORD *)(mythread_q_head + 48);
*(_QWORD *)(a1 + 56) = mythread_q_head;
*(_QWORD *)(a1 + 48) = v2;
*(_QWORD *)(*(_QWORD *)(v1 + 48) + 56LL) = a1;
*(_QWORD *)(v1 + 48) = a1;
}
else
{
func0(a1);
}
}

original_code:
void mythread_q_add(mythread_private_t * node)
{
 if (mythread_q_head == ((void *)0)) {
  mythread_q_init(node);
  return;
 }
 node->next = mythread_q_head;
 node->prev = mythread_q_head->prev;
 mythread_q_head->prev->next = node;
 mythread_q_head->prev = node;
 return;
}

canonical_original_code:
void mythread_q_add(struct mythread_private *node)
{
 if (mythread_q_head == ((void *)0)) {
  mythread_q_init(node);
  return;
 }
 node->next = mythread_q_head;
 node->prev = mythread_q_head->prev;
 mythread_q_head->prev->next = node;
 mythread_q_head->prev = node;
 return;
}


decompiled_code:
__int64 __fastcall mythread_q_delete(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rdx
__int64 v3; // rdx

if ( mythread_q_head != a1 )
goto LABEL_2;
result = *(_QWORD *)(a1 + 56);
if ( a1 == result )
{
puts("The Q is now Empty!");
mythread_q_head = 0LL;
LABEL_2:
result = *(_QWORD *)(a1 + 56);
v2 = *(_QWORD *)(a1 + 48);
*(_QWORD *)(v2 + 56) = result;
*(_QWORD *)(result + 48) = v2;
return result;
}
v3 = *(_QWORD *)(a1 + 48);
mythread_q_head = *(_QWORD *)(a1 + 56);
*(_QWORD *)(v3 + 56) = result;
*(_QWORD *)(result + 48) = v3;
return result;
}

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

if ( mythread_q_head != a1 )
goto LABEL_2;
result = *(_QWORD *)(a1 + 56);
if ( a1 == result )
{
puts("The Q is now Empty!");
mythread_q_head = 0LL;
LABEL_2:
result = *(_QWORD *)(a1 + 56);
v2 = *(_QWORD *)(a1 + 48);
*(_QWORD *)(v2 + 56) = result;
*(_QWORD *)(result + 48) = v2;
return result;
}
v3 = *(_QWORD *)(a1 + 48);
mythread_q_head = *(_QWORD *)(a1 + 56);
*(_QWORD *)(v3 + 56) = result;
*(_QWORD *)(result + 48) = v3;
return result;
}

original_code:
void mythread_q_delete(mythread_private_t * node)
{
 mythread_private_t *p;
 if (node == mythread_q_head && node->next == mythread_q_head) {
  printf("The Q is now Empty!\n");
  mythread_q_head = ((void *)0);
 }
 if (node == mythread_q_head)
  mythread_q_head = node->next;
 p = node->prev;
 p->next = node->next;
 node->next->prev = p;
 return;
}

canonical_original_code:
void mythread_q_delete(struct mythread_private *node)
{
 struct mythread_private *p;
 if (node == mythread_q_head && node->next == mythread_q_head) {
  printf("The Q is now Empty!\n");
  mythread_q_head = ((void *)0);
 }
 if (node == mythread_q_head)
  mythread_q_head = node->next;
 p = node->prev;
 p->next = node->next;
 node->next->prev = p;
 return;
}


decompiled_code:
int mythread_q_state_display()
{
__int64 v0; // rbx
int result; // eax

if ( mythread_q_head )
{
puts("\n The Q contents are -> ");
v0 = mythread_q_head;
do
{
result = printf(" %d\n", *(unsigned int *)(v0 + 4));
v0 = *(_QWORD *)(v0 + 56);
}
while ( mythread_q_head != v0 );
}
return result;
}

canonical_decompiled_code:
int func3()
{
__int64 v0; // rbx
int result; // eax

if ( mythread_q_head )
{
puts("\n The Q contents are -> ");
v0 = mythread_q_head;
do
{
result = printf(" %d\n", *(unsigned int *)(v0 + 4));
v0 = *(_QWORD *)(v0 + 56);
}
while ( mythread_q_head != v0 );
}
return result;
}

original_code:
void mythread_q_state_display()
{
 if (mythread_q_head != ((void *)0)) {
  printf("\n The Q contents are -> \n");
  mythread_private_t *p;
  p = mythread_q_head;
  do {
   printf(" %d\n", p->state);
   p = p->next;
  } while (p != mythread_q_head);
 }
}

canonical_original_code:
void mythread_q_state_display()
{
 if (mythread_q_head != ((void *)0)) {
  printf("\n The Q contents are -> \n");
  struct mythread_private *p;
  p = mythread_q_head;
  do {
   printf(" %d\n", p->state);
   p = p->next;
  } while (p != mythread_q_head);
 }
}


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

if ( !mythread_q_head )
return 0LL;
result = mythread_q_head;
while ( *(_DWORD *)result != a1 )
{
result = *(_QWORD *)(result + 56);
if ( mythread_q_head == result )
return 0LL;
}
return result;
}

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

if ( !mythread_q_head )
return 0LL;
result = mythread_q_head;
while ( *(_DWORD *)result != a1 )
{
result = *(_QWORD *)(result + 56);
if ( mythread_q_head == result )
return 0LL;
}
return result;
}

original_code:
mythread_private_t *mythread_q_search(unsigned long new_tid)
{
 mythread_private_t *p;
 if (mythread_q_head != ((void *)0)) {
  p = mythread_q_head;
  do {
   if (p->tid == new_tid)
    return p;
   p = p->next;
  } while (p != mythread_q_head);
 }
 return ((void *)0);
}

canonical_original_code:
struct mythread_private *mythread_q_search(unsigned long new_tid)
{
 struct mythread_private *p;
 if (mythread_q_head != ((void *)0)) {
  p = mythread_q_head;
  do {
   if (p->tid == new_tid)
    return p;
   p = p->next;
  } while (p != mythread_q_head);
 }
 return ((void *)0);
}

return_type: struct mythread_private { int tid; int state; void *(*start_func)(void *); void *args; void *returnValue; struct mythread_private *blockedForJoin; struct futex { int count; } sched_futex; struct mythread_private *prev; } *


decompiled_code:
__int64 __fastcall mythread_wrapper(__int64 a1)
{
futex_down_isra_0((volatile signed __int64 *)(a1 + 40));
(*(void (__fastcall **)(_QWORD))(a1 + 8))(*(_QWORD *)(a1 + 16));
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
func2((volatile signed __int64 *)(a1 + 40));
(*(void (__fastcall **)(_QWORD))(a1 + 8))(*(_QWORD *)(a1 + 16));
return 0LL;
}

original_code:
int mythread_wrapper(void *thread_tcb)
{
 mythread_private_t *new_tcb;
 new_tcb = (mythread_private_t *) thread_tcb;
 do {} while(0);;
 futex_down(&new_tcb->sched_futex);
 do {} while(0);;
 new_tcb->start_func(new_tcb->args);
 return 0;
}

canonical_original_code:
int mythread_wrapper(void *thread_tcb)
{
 struct mythread_private *new_tcb;
 new_tcb = (struct mythread_private *) thread_tcb;
 do {} while(0);;
 futex_down(&new_tcb->sched_futex);
 do {} while(0);;
 new_tcb->start_func(new_tcb->args);
 return 0;
}


decompiled_code:
void __noreturn mythread_idle()
{
__int64 v0; // rax
int v1; // edx
__int64 v2; // rax

while ( 1 )
{
v0 = _mythread_selfptr();
v1 = *(_DWORD *)v0;
v2 = *(_QWORD *)(v0 + 56);
if ( v1 == *(_DWORD *)v2 )
break;
while ( *(_DWORD *)(v2 + 4) == 3 )
{
v2 = *(_QWORD *)(v2 + 56);
if ( *(_DWORD *)v2 == v1 )
goto LABEL_6;
}
mythread_yield();
}
LABEL_6:
exit(0);
}

canonical_decompiled_code:
void __noreturn func0()
{
__int64 v0; // rax
int v1; // edx
__int64 v2; // rax

while ( 1 )
{
v0 = _mythread_selfptr();
v1 = *(_DWORD *)v0;
v2 = *(_QWORD *)(v0 + 56);
if ( v1 == *(_DWORD *)v2 )
break;
while ( *(_DWORD *)(v2 + 4) == 3 )
{
v2 = *(_QWORD *)(v2 + 56);
if ( *(_DWORD *)v2 == v1 )
goto LABEL_6;
}
mythread_yield();
}
LABEL_6:
exit(0);
}

original_code:
void *mythread_idle(void *phony)
{
 mythread_private_t *traverse_tcb;
 pid_t idle_tcb_tid;
 while (1) {
  do {} while(0);;
  traverse_tcb = __mythread_selfptr();
  idle_tcb_tid = traverse_tcb->tid;
  traverse_tcb = traverse_tcb->next;
  while (traverse_tcb->tid != idle_tcb_tid) {
   if (traverse_tcb->state != 3) {
    break;
   }
   traverse_tcb = traverse_tcb->next;
  }
  if (traverse_tcb->tid == idle_tcb_tid)
   exit(0);
  mythread_yield();
 }
}

canonical_original_code:
void *mythread_idle(void *phony)
{
 struct mythread_private *traverse_tcb;
 int idle_tcb_tid;
 while (1) {
  do {} while(0);;
  traverse_tcb = __mythread_selfptr();
  idle_tcb_tid = traverse_tcb->tid;
  traverse_tcb = traverse_tcb->next;
  while (traverse_tcb->tid != idle_tcb_tid) {
   if (traverse_tcb->state != 3) {
    break;
   }
   traverse_tcb = traverse_tcb->next;
  }
  if (traverse_tcb->tid == idle_tcb_tid)
   exit(0);
  mythread_yield();
 }
}

variable_types:
phony
void *


decompiled_code:
__int64 mythread_yield()
{
__int64 v0; // rbx
__int64 result; // rax

v0 = _mythread_selfptr();
futex_down_isra_0((volatile signed __int64 *)&gfutex);
if ( (unsigned int)_mythread_dispatcher(v0) == -1 )
{
futex_up_isra_0((volatile signed __int64 *)&gfutex);
result = 0LL;
}
else
{
if ( *(int *)(v0 + 40) > 0 )
futex_down_isra_0((volatile signed __int64 *)(v0 + 40));
futex_up_isra_0((volatile signed __int64 *)&gfutex);
futex_down_isra_0((volatile signed __int64 *)(v0 + 40));
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 func6()
{
__int64 v0; // rbx
__int64 result; // rax

v0 = _mythread_selfptr();
func4((volatile signed __int64 *)&gfutex);
if ( (unsigned int)func5(v0) == -1 )
{
func3((volatile signed __int64 *)&gfutex);
result = 0LL;
}
else
{
if ( *(int *)(v0 + 40) > 0 )
func4((volatile signed __int64 *)(v0 + 40));
func3((volatile signed __int64 *)&gfutex);
func4((volatile signed __int64 *)(v0 + 40));
result = 0LL;
}
return result;
}

original_code:
int mythread_yield()
{
 mythread_private_t *self;
 int retval;
 self = __mythread_selfptr();
 futex_down(&gfutex);
 retval = __mythread_dispatcher(self);
 if (retval == -1) {
  futex_up(&gfutex);
  return 0;
 }
 do {} while(0);;
 if (self->sched_futex.count > 0)
  futex_down(&self->sched_futex);
 futex_up(&gfutex);
 do {} while(0);;
 futex_down(&self->sched_futex);
 return 0;
}

canonical_original_code:
int mythread_yield()
{
 struct mythread_private *self;
 int retval;
 self = __mythread_selfptr();
 futex_down(&gfutex);
 retval = __mythread_dispatcher(self);
 if (retval == -1) {
  futex_up(&gfutex);
  return 0;
 }
 do {} while(0);;
 if (self->sched_futex.count > 0)
  futex_down(&self->sched_futex);
 futex_up(&gfutex);
 do {} while(0);;
 futex_down(&self->sched_futex);
 return 0;
}

variable_types: retval int


decompiled_code:
__int64 __fastcall mythread_join(int a1, _QWORD *a2)
{
__int64 v2; // rbp
__int64 v3; // rax
__int64 v4; // rbx

v2 = _mythread_selfptr();
v3 = mythread_q_search(a1);
v4 = v3;
if ( *(_DWORD *)(v3 + 4) == 3 )
goto LABEL_4;
if ( !*(_QWORD *)(v3 + 32) )
{
*(_QWORD *)(v3 + 32) = v2;
*(_DWORD *)(v2 + 4) = 2;
mythread_yield();
LABEL_4:
*a2 = *(_QWORD *)(v4 + 24);
return 0LL;
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, _QWORD *a2)
{
__int64 v2; // rbp
__int64 v3; // rax
__int64 v4; // rbx

v2 = _mythread_selfptr();
v3 = mythread_q_search(a1);
v4 = v3;
if ( *(_DWORD *)(v3 + 4) == 3 )
goto LABEL_4;
if ( !*(_QWORD *)(v3 + 32) )
{
*(_QWORD *)(v3 + 32) = v2;
*(_DWORD *)(v2 + 4) = 2;
mythread_yield();
LABEL_4:
*a2 = *(_QWORD *)(v4 + 24);
return 0LL;
}
return 0xFFFFFFFFLL;
}

original_code:
int mythread_join(mythread_t target_thread, void **status)
{
 mythread_private_t *target, *self_ptr;
 self_ptr = __mythread_selfptr();
 do {} while(0);;
 target = mythread_q_search(target_thread.tid);
 if (target->state == 3) {
  *status = target->returnValue;
  return 0;
 }
 do {} while(0);;
 if (target->blockedForJoin != ((void *)0))
  return -1;
 target->blockedForJoin = self_ptr;
 do {} while(0);;
 self_ptr->state = 2;
 mythread_yield();
 *status = target->returnValue;
 return 0;
}

canonical_original_code:
int mythread_join(struct mythread target_thread, void **status)
{
 struct mythread_private *target; struct mythread_private *self_ptr;
 self_ptr = __mythread_selfptr();
 do {} while(0);;
 target = mythread_q_search(target_thread.tid);
 if (target->state == 3) {
  *status = target->returnValue;
  return 0;
 }
 do {} while(0);;
 if (target->blockedForJoin != ((void *)0))
  return -1;
 target->blockedForJoin = self_ptr;
 do {} while(0);;
 self_ptr->state = 2;
 mythread_yield();
 *status = target->returnValue;
 return 0;
}

variable_types:
status
void **


sigHandler

repo: jitrc/eklavya-ros-pkg

decompiled_code:
__int64 __fastcall sigHandler(int a1)
{
signal(a1, (__sighandler_t)((char *)sigHandler + 1));
return vn200_disconnect(&vn200);
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
signal(a1, (__sighandler_t)((char *)sigHandler + 1));
return vn200_disconnect(&vn200);
}

original_code:
void sigHandler(int sig) {
  signal(sig, ((__sighandler_t) 1));
  vn200_disconnect(&vn200);
}

canonical_original_code:
void sigHandler(int sig) {
  signal(sig, ((void (*)(int)) 1));
  vn200_disconnect(&vn200);
}

variable_types: sig int


main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
double v3; // xmm1_8
__int64 i; // rsi
double v5; // xmm0_8
double v6; // xmm0_8
double v7; // xmm3_8
double v8; // xmm0_8
double v9; // [rsp+38h] [rbp-E0h]
double v10; // [rsp+38h] [rbp-E0h]
double x; // [rsp+40h] [rbp-D8h]
double v12; // [rsp+48h] [rbp-D0h]
double v13; // [rsp+58h] [rbp-C0h]
double v14; // [rsp+60h] [rbp-B8h]
double v15; // [rsp+68h] [rbp-B0h]
unsigned __int16 v16; // [rsp+78h] [rbp-A0h] BYREF
unsigned __int16 v17; // [rsp+7Ah] [rbp-9Eh] BYREF
float v18; // [rsp+7Ch] [rbp-9Ch] BYREF
float v19; // [rsp+80h] [rbp-98h] BYREF
float v20; // [rsp+84h] [rbp-94h] BYREF
double v21; // [rsp+88h] [rbp-90h] BYREF
__int64 v22[4]; // [rsp+90h] [rbp-88h] BYREF
double v23; // [rsp+B0h] [rbp-68h] BYREF
double v24; // [rsp+B8h] [rbp-60h]
double v25; // [rsp+C0h] [rbp-58h]
__int64 v26[9]; // [rsp+D0h] [rbp-48h] BYREF

vn200_connect(&vn200, "/dev/serial/by-id/usb-FTDI_USB-RS232_Cable_FTUTUVO5-if00-port0", 115200LL);
for ( i = 0LL; ; i = (unsigned int)(i + 1) )
{
printf("Iter: %d\n", i);
vn200_getInsSolution(&vn200, &v21, &v16, &v17, v22, &v23, v26, &v18, &v19, &v20);
v12 = v25;
v10 = 3.141592653589793 * v23 / 180.0;
x = 3.141592653589793 * v24 / 180.0;
v7 = 1.0 - pow(0.9966471893352525, v3);
v14 = sin(v10);
v8 = 1.0 - pow(v14 * v7, v3);
if ( v8 >= 0.0 )
v5 = sqrt(v8);
else
v5 = sqrt(v8);
v13 = 6378137.0 / v5;
v15 = (v12 + 6378137.0 / v5) * sin(v10 + 1.570796326794897);
v9 = sin(x + 1.570796326794897);
v6 = sin(x);
v3 = *(double *)v22;
printf(
"INS Solution:\n"
" GPS Time: %f\n"
" GPS Week: %u\n"
" INS Status: %.4X\n"
" YPR.Yaw: %+#7.2f\n"
" YPR.Pitch: %+#7.2f\n"
" YPR.Roll: %+#7.2f\n"
" LLA.Lattitude: %+#7.8f\n"
" LLA.Longitude: %+#7.8f\n"
" LLA.Altitude: %+#7.8f\n"
" Velocity.North: %+#7.2f\n"
" Velocity.East: %+#7.2f\n"
" Velocity.Down: %+#7.2f\n"
" Attitude Uncertainty: %+#7.2f\n"
" Position Uncertainty: %+#7.2f\n"
" Velocity Uncertainty: %+#7.2f\n"
" Cartesian X: %+#lf\n"
" Cartesian Y: %+#lf\n"
" Cartesian Z: %+#lf\n",
v16,
v17,
v21,
*(double *)v22,
*(double *)&v22[1],
*(double *)&v22[2],
v23,
v24,
v25,
*(double *)v26,
v26[1],
v26[2],
v18,
v19,
v20,
v15 * v9,
v6 * v15,
(v13 * (1.0 - v7) + v12) * v14);
puts("\n");
sleep(1u);
}
}

original_code:
int main()
{
 double gpsTime;
 unsigned short gpsWeek, status;
 VnVector3 ypr, latitudeLognitudeAltitude, nedVelocity;
 float attitudeUncertainty, positionUncertainty, velocityUncertainty;
  double x,y,z,a,f,b,e2,Nphi,latitude,longitude,altitude;
 int i = 0;
 vn200_connect(&vn200, COM_PORT, BAUD_RATE);
  while(1) {
    printf("Iter: %d\n", i++);
  vn200_getInsSolution(
   &vn200,
   &gpsTime,
      &gpsWeek,
   &status,
   &ypr,
   &latitudeLognitudeAltitude,
   &nedVelocity,
   &attitudeUncertainty,
   &positionUncertainty,
   &velocityUncertainty);
    latitude = latitudeLognitudeAltitude.c0*3.141592653589793238462643/180;
    longitude =latitudeLognitudeAltitude.c1*3.141592653589793238462643/180;
    altitude = latitudeLognitudeAltitude.c2;
    a = 6378137; f = 1/298.257223563;
    b = a*(1 - f);
    e2 = 1 - pow((b/a),2);
    Nphi = a/sqrt(1 - pow(e2*sin(latitude),2));
    x = (Nphi + altitude)*(sin(latitude+1.57079632679489661923))*(sin(longitude+1.57079632679489661923));
    y = (Nphi + altitude)*(sin(latitude+1.57079632679489661923))*sin(longitude);
    z = (Nphi*(1 - e2) + altitude)*sin(latitude);
  printf("INS Solution:\n"
   "  GPS Time:               %f\n"
   "  GPS Week:               %u\n"
   "  INS Status:             %.4X\n"
   "  YPR.Yaw:                %+#7.2f\n"
   "  YPR.Pitch:              %+#7.2f\n"
   "  YPR.Roll:               %+#7.2f\n"
   "  LLA.Lattitude:          %+#7.8f\n"
   "  LLA.Longitude:          %+#7.8f\n"
   "  LLA.Altitude:           %+#7.8f\n"
   "  Velocity.North:         %+#7.2f\n"
   "  Velocity.East:          %+#7.2f\n"
   "  Velocity.Down:          %+#7.2f\n"
   "  Attitude Uncertainty:   %+#7.2f\n"
   "  Position Uncertainty:   %+#7.2f\n"
   "  Velocity Uncertainty:   %+#7.2f\n"
      "  Cartesian X:            %+#lf\n"
      "  Cartesian Y:            %+#lf\n"
      "  Cartesian Z:            %+#lf\n",
   gpsTime,
   gpsWeek,
   status,
   ypr.c0,
   ypr.c1,
   ypr.c2,
   latitudeLognitudeAltitude.c0,
   latitudeLognitudeAltitude.c1,
   latitudeLognitudeAltitude.c2,
   nedVelocity.c0,
   nedVelocity.c1,
   nedVelocity.c2,
   attitudeUncertainty,
   positionUncertainty,
   velocityUncertainty,
      x,
      y,
      z);
  printf("\n\n");
  sleep(1);
 }
 vn200_disconnect(&vn200);
 return 0;
}

canonical_original_code:
int main()
{
 double gpsTime;
 unsigned short gpsWeek; unsigned short status;
 struct VnVector3 ypr; struct VnVector3 latitudeLognitudeAltitude; struct VnVector3 nedVelocity;
 float attitudeUncertainty; float positionUncertainty; float velocityUncertainty;
  double x; double y; double z; double a; double f; double b; double e2; double Nphi; double latitude; double longitude; double altitude;
 int i = 0;
 vn200_connect(&vn200, COM_PORT, BAUD_RATE);
  while(1) {
    printf("Iter: %d\n", i++);
  vn200_getInsSolution(
   &vn200,
   &gpsTime,
      &gpsWeek,
   &status,
   &ypr,
   &latitudeLognitudeAltitude,
   &nedVelocity,
   &attitudeUncertainty,
   &positionUncertainty,
   &velocityUncertainty);
    latitude = latitudeLognitudeAltitude.c0*3.141592653589793238462643/180;
    longitude =latitudeLognitudeAltitude.c1*3.141592653589793238462643/180;
    altitude = latitudeLognitudeAltitude.c2;
    a = 6378137; f = 1/298.257223563;
    b = a*(1 - f);
    e2 = 1 - pow((b/a),2);
    Nphi = a/sqrt(1 - pow(e2*sin(latitude),2));
    x = (Nphi + altitude)*(sin(latitude+1.57079632679489661923))*(sin(longitude+1.57079632679489661923));
    y = (Nphi + altitude)*(sin(latitude+1.57079632679489661923))*sin(longitude);
    z = (Nphi*(1 - e2) + altitude)*sin(latitude);
  printf("INS Solution:\n"
   "  GPS Time:               %f\n"
   "  GPS Week:               %u\n"
   "  INS Status:             %.4X\n"
   "  YPR.Yaw:                %+#7.2f\n"
   "  YPR.Pitch:              %+#7.2f\n"
   "  YPR.Roll:               %+#7.2f\n"
   "  LLA.Lattitude:          %+#7.8f\n"
   "  LLA.Longitude:          %+#7.8f\n"
   "  LLA.Altitude:           %+#7.8f\n"
   "  Velocity.North:         %+#7.2f\n"
   "  Velocity.East:          %+#7.2f\n"
   "  Velocity.Down:          %+#7.2f\n"
   "  Attitude Uncertainty:   %+#7.2f\n"
   "  Position Uncertainty:   %+#7.2f\n"
   "  Velocity Uncertainty:   %+#7.2f\n"
      "  Cartesian X:            %+#lf\n"
      "  Cartesian Y:            %+#lf\n"
      "  Cartesian Z:            %+#lf\n",
   gpsTime,
   gpsWeek,
   status,
   ypr.c0,
   ypr.c1,
   ypr.c2,
   latitudeLognitudeAltitude.c0,
   latitudeLognitudeAltitude.c1,
   latitudeLognitudeAltitude.c2,
   nedVelocity.c0,
   nedVelocity.c1,
   nedVelocity.c2,
   attitudeUncertainty,
   positionUncertainty,
   velocityUncertainty,
      x,
      y,
      z);
  printf("\n\n");
  sleep(1);
 }
 vn200_disconnect(&vn200);
 return 0;
}

variable_types: gpsTime double

variable_types:
gpsWeek
unsigned short

variable_types:
status
unsigned short

variable_types: struct VnVector3 { double c0; double c1; double c2; }

variable_types: attitudeUncertainty float

variable_types: positionUncertainty float

variable_types: velocityUncertainty float

variable_types: x double

variable_types: y double

variable_types: z double

variable_types: a double

variable_types: f double

variable_types: b double

variable_types: Nphi double

variable_types: latitude double

variable_types: longitude double

variable_types: altitude double

variable_types: i int


getEnvPairMine

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

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

original_code:
char* getEnvPairMine(int i) {
    return ((void *)0);
}

canonical_original_code:
char *getEnvPairMine(int i) {
    return ((void *)0);
}

return_type: char *


main

repo: jjlin/edln

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // rbp
const char *v4; // r12
char *v5; // rsi
int v7; // eax
__int64 v8; // rax
__int64 v9; // rdx

if ( argc != 2 )
{
if ( argc != 3 )
{
fprintf(stderr, "usage: %s symlink_to_edit [new_target]\n", *argv);
return 0;
}
v3 = (char *)argv[1];
v4 = argv[2];
remove_trailing_slashes(v3, argv, envp);
v5 = orig_target;
if ( readlink(v3, orig_target, 0xFFFuLL) >= 0 )
{
if ( v4 )
goto LABEL_5;
goto LABEL_16;
}
LABEL_11:
v7 = *__errno_location();
if ( v7 == 2 )
fatal_error("'%s' does not exist.", (char)v3);
if ( v7 == 22 )
fatal_error("'%s' is not a symlink.", (char)v3);
LABEL_15:
fatal_error(0LL, (char)v5);
}
v3 = (char *)argv[1];
remove_trailing_slashes(v3, argv, envp);
v5 = orig_target;
if ( readlink(v3, orig_target, 0xFFFuLL) < 0 )
goto LABEL_11;
LABEL_16:
if ( !getcwd(orig_wd, 0x1000uLL) )
fatal_error("getcwd() failed (buffer too small).", 0);
change_to_symlink_dir(v3);
customize_rl_completion_behavior(4097LL);
rl_extend_line_buffer();
rl_pre_input_hook = (__int64)init_rl_line_buffer;
v8 = readline();
v4 = (const char *)v8;
if ( !v8 )
fatal_error("No input received, aborting.", 0);
remove_trailing_slashes(v8, 4096LL, v9);
v5 = orig_target;
if ( !strcmp(v4, orig_target) )
exit(0);
if ( !*v4 )
fatal_error("Can't symlink to an empty target.", (char)orig_target);
LABEL_5:
if ( chdir(orig_wd) < 0 )
{
v5 = "Warning: Couldn't chdir() back to '%s': ";
fprintf(stderr, "Warning: Couldn't chdir() back to '%s': ", orig_wd);
perror(0LL);
}
if ( unlink(v3) < 0 )
goto LABEL_15;
LOBYTE(v5) = (_BYTE)v3;
if ( symlink(v4, v3) < 0 )
goto LABEL_15;
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // rbp
const char *v4; // r12
char *v5; // rsi
int v7; // eax
__int64 v8; // rax
__int64 v9; // rdx

if ( argc != 2 )
{
if ( argc != 3 )
{
fprintf(stderr, "usage: %s symlink_to_edit [new_target]\n", *argv);
return 0;
}
v3 = (char *)argv[1];
v4 = argv[2];
func11(v3, argv, envp);
v5 = orig_target;
if ( readlink(v3, orig_target, 0xFFFuLL) >= 0 )
{
if ( v4 )
goto LABEL_5;
goto LABEL_16;
}
LABEL_11:
v7 = *__errno_location();
if ( v7 == 2 )
func12("'%s' does not exist.", (char)v3);
if ( v7 == 22 )
func12("'%s' is not a symlink.", (char)v3);
LABEL_15:
func12(0LL, (char)v5);
}
v3 = (char *)argv[1];
func11(v3, argv, envp);
v5 = orig_target;
if ( readlink(v3, orig_target, 0xFFFuLL) < 0 )
goto LABEL_11;
LABEL_16:
if ( !getcwd(orig_wd, 0x1000uLL) )
func12("getcwd() failed (buffer too small).", 0);
func10(v3);
func9(4097LL);
rl_extend_line_buffer();
rl_pre_input_hook = (__int64)init_rl_line_buffer;
v8 = readline();
v4 = (const char *)v8;
if ( !v8 )
func12("No input received, aborting.", 0);
func11(v8, 4096LL, v9);
v5 = orig_target;
if ( !strcmp(v4, orig_target) )
exit(0);
if ( !*v4 )
func12("Can't symlink to an empty target.", (char)orig_target);
LABEL_5:
if ( chdir(orig_wd) < 0 )
{
v5 = "Warning: Couldn't chdir() back to '%s': ";
fprintf(stderr, "Warning: Couldn't chdir() back to '%s': ", orig_wd);
perror(0LL);
}
if ( unlink(v3) < 0 )
goto LABEL_15;
LOBYTE(v5) = (_BYTE)v3;
if ( symlink(v4, v3) < 0 )
goto LABEL_15;
return 0;
}

original_code:
int main(int argc, char** argv)
{
    char* link_path = ((void *)0);
    char* new_target = ((void *)0);
    switch (argc) {
    case 3:
        new_target = argv[2];
    case 2:
        link_path = argv[1];
        break;
    default:
        fprintf(stderr, "usage: %s symlink_to_edit [new_target]\n", argv[0]);
        return 0;
    }
    remove_trailing_slashes(link_path);
    if (readlink(link_path, orig_target, sizeof(orig_target)-1) < 0) {
        switch ((*__errno_location ())) {
        case 2:
            fatal_error("'%s' does not exist.", link_path);
            break;
        case 22:
            fatal_error("'%s' is not a symlink.", link_path);
            break;
        default:
            fatal_error(((void *)0));
            break;
        }
    }
    if (new_target == ((void *)0)) {
        if (!getcwd(orig_wd, sizeof(orig_wd))) {
            fatal_error("getcwd() failed (buffer too small).");
        }
        change_to_symlink_dir(link_path);
        customize_rl_completion_behavior();
        rl_extend_line_buffer(4096 +1);
        rl_pre_input_hook = &init_rl_line_buffer;
        new_target = readline("New target: ");
        if (new_target == ((void *)0))
            fatal_error("No input received, aborting.");
        remove_trailing_slashes(new_target);
        if (!strcmp(new_target, orig_target)) {
            exit(0);
        } else if (*new_target == '\0') {
            fatal_error("Can't symlink to an empty target.");
        }
    }
    if (chdir(orig_wd) < 0) {
        fprintf(stderr, "Warning: Couldn't chdir() back to '%s': ", orig_wd);
        perror(((void *)0));
    }
    if (unlink(link_path) < 0)
        fatal_error(((void *)0));
    if (symlink(new_target, link_path) < 0)
        fatal_error(((void *)0));
    return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
    char *link_path = ((void *)0);
    char *new_target = ((void *)0);
    switch (argc) {
    case 3:
        new_target = argv[2];
    case 2:
        link_path = argv[1];
        break;
    default:
        fprintf(stderr, "usage: %s symlink_to_edit [new_target]\n", argv[0]);
        return 0;
    }
    remove_trailing_slashes(link_path);
    if (readlink(link_path, orig_target, sizeof(orig_target)-1) < 0) {
        switch ((*__errno_location ())) {
        case 2:
            fatal_error("'%s' does not exist.", link_path);
            break;
        case 22:
            fatal_error("'%s' is not a symlink.", link_path);
            break;
        default:
            fatal_error(((void *)0));
            break;
        }
    }
    if (new_target == ((void *)0)) {
        if (!getcwd(orig_wd, sizeof(orig_wd))) {
            fatal_error("getcwd() failed (buffer too small).");
        }
        change_to_symlink_dir(link_path);
        customize_rl_completion_behavior();
        rl_extend_line_buffer(4096 +1);
        rl_pre_input_hook = &init_rl_line_buffer;
        new_target = readline("New target: ");
        if (new_target == ((void *)0))
            fatal_error("No input received, aborting.");
        remove_trailing_slashes(new_target);
        if (!strcmp(new_target, orig_target)) {
            exit(0);
        } else if (*new_target == '\0') {
            fatal_error("Can't symlink to an empty target.");
        }
    }
    if (chdir(orig_wd) < 0) {
        fprintf(stderr, "Warning: Couldn't chdir() back to '%s': ", orig_wd);
        perror(((void *)0));
    }
    if (unlink(link_path) < 0)
        fatal_error(((void *)0));
    if (symlink(new_target, link_path) < 0)
        fatal_error(((void *)0));
    return 0;
}

variable_types: argc int

variable_types:
argv
char **


decompiled_code:
__int64 init_rl_line_buffer()
{
rl_replace_line();
rl_point = rl_end;
rl_redisplay();
return 0LL;
}

canonical_decompiled_code:
__int64 func7()
{
rl_replace_line();
rl_point = rl_end;
rl_redisplay();
return 0LL;
}

original_code:
int init_rl_line_buffer(void)
{
    rl_replace_line(orig_target, 0);
    rl_point = rl_end;
    rl_redisplay();
    return 0;
}

canonical_original_code:
int init_rl_line_buffer()
{
    rl_replace_line(orig_target, 0);
    rl_point = rl_end;
    rl_redisplay();
    return 0;
}


decompiled_code:
__int64 edln_rl_filename_completion_function()
{
rl_completion_append_character = 0;
return rl_filename_completion_function();
}

canonical_decompiled_code:
__int64 func8()
{
rl_completion_append_character = 0;
return rl_filename_completion_function();
}

original_code:
char* edln_rl_filename_completion_function(const char* text, int state)
{
    rl_completion_append_character = '\0';
    return rl_filename_completion_function(text, state);
}

canonical_original_code:
char *edln_rl_filename_completion_function(char *text, int state)
{
    rl_completion_append_character = '\0';
    return rl_filename_completion_function(text, state);
}

variable_types:
text
char *

variable_types: state int


decompiled_code:
void customize_rl_completion_behavior()
{
rl_completer_word_break_characters = (__int64)"";
rl_completion_entry_function = (__int64)edln_rl_filename_completion_function;
}

canonical_decompiled_code:
void func9()
{
rl_completer_word_break_characters = (__int64)"";
rl_completion_entry_function = (__int64)edln_rl_filename_completion_function;
}

original_code:
void customize_rl_completion_behavior(void)
{
    rl_completer_word_break_characters = "";
    rl_completion_entry_function = &edln_rl_filename_completion_function;
}

canonical_original_code:
void customize_rl_completion_behavior()
{
    rl_completer_word_break_characters = "";
    rl_completion_entry_function = &edln_rl_filename_completion_function;
}


decompiled_code:
void __fastcall change_to_symlink_dir(char *path)
{
int v1; // edx
char *v2; // rbx
__int64 v3; // rax

v1 = strlen(path);
if ( v1 - 1 > 0 )
{
v2 = &path[v1 - 1];
v3 = (__int64)&v2[-(v1 - 2) - 1];
while ( *v2 != 47 )
{
if ( --v2 == (char *)v3 )
return;
}
*v2 = 0;
if ( chdir(path) < 0 )
{
fprintf(stderr, "Warning: Couldn't chdir() to '%s': ", path);
perror(0LL);
}
*v2 = 47;
}
}

canonical_decompiled_code:
void __fastcall func10(char *path)
{
int v1; // edx
char *v2; // rbx
__int64 v3; // rax

v1 = strlen(path);
if ( v1 - 1 > 0 )
{
v2 = &path[v1 - 1];
v3 = (__int64)&v2[-(v1 - 2) - 1];
while ( *v2 != 47 )
{
if ( --v2 == (char *)v3 )
return;
}
*v2 = 0;
if ( chdir(path) < 0 )
{
fprintf(stderr, "Warning: Couldn't chdir() to '%s': ", path);
perror(0LL);
}
*v2 = 47;
}
}

original_code:
void change_to_symlink_dir(char* link_path)
{
    int i;
    for (i = strlen(link_path) - 1; i > 0; --i) {
        if (link_path[i] == '/') {
            link_path[i] = '\0';
            if (chdir(link_path) < 0) {
                fprintf(stderr, "Warning: Couldn't chdir() to '%s': ", link_path);
                perror(((void *)0));
            }
            link_path[i] = '/';
            break;
        }
    }
}

canonical_original_code:
void change_to_symlink_dir(char *link_path)
{
    int i;
    for (i = strlen(link_path) - 1; i > 0; --i) {
        if (link_path[i] == '/') {
            link_path[i] = '\0';
            if (chdir(link_path) < 0) {
                fprintf(stderr, "Warning: Couldn't chdir() to '%s': ", link_path);
                perror(((void *)0));
            }
            link_path[i] = '/';
            break;
        }
    }
}


decompiled_code:
const char *__fastcall remove_trailing_slashes(const char *a1)
{
const char *result; // rax

result = &a1[strlen(a1) - 1];
if ( a1 < result )
{
do
{
if ( *result != 47 )
break;
*result-- = 0;
}
while ( a1 != result );
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func11(const char *a1)
{
const char *result; // rax

result = &a1[strlen(a1) - 1];
if ( a1 < result )
{
do
{
if ( *result != 47 )
break;
*result-- = 0;
}
while ( a1 != result );
}
return result;
}

original_code:
void remove_trailing_slashes(char* path)
{
    char* last_char = path + strlen(path) - 1;
    while (last_char > path && *last_char == '/') {
        *last_char-- = '\0';
    }
}

canonical_original_code:
void remove_trailing_slashes(char *path)
{
    char *last_char = path + strlen(path) - 1;
    while (last_char > path && *last_char == '/') {
        *last_char-- = '\0';
    }
}

variable_types:
path
char *


decompiled_code:
void __noreturn fatal_error(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-10D0h] BYREF
char s[4096]; // [rsp+20h] [rbp-10B8h] BYREF

if ( format )
{
va_start(arg, format);
vsnprintf(s, 0x1000uLL, format, arg);
fprintf(stderr, "%s\n", s);
}
else
{
perror(0LL);
}
exit(1);
}

canonical_decompiled_code:
void __noreturn func12(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-10D0h] BYREF
char s[4096]; // [rsp+20h] [rbp-10B8h] BYREF

if ( format )
{
va_start(arg, format);
vsnprintf(s, 0x1000uLL, format, arg);
fprintf(stderr, "%s\n", s);
}
else
{
perror(0LL);
}
exit(1);
}

original_code:
void fatal_error(const char* fmt, ...)
{
    char msg[4096];
    va_list ap;
    if (fmt) {
        __builtin_va_start(ap,fmt);
        vsnprintf(msg, sizeof(msg), fmt, ap);
        __builtin_va_end(ap);
        fprintf(stderr, "%s\n", msg);
    } else {
        perror(((void *)0));
    }
    exit(1);
}

canonical_original_code:
void fatal_error(char *fmt, ...)
{
    char msg[4096];
    __builtin_va_list ap;
    if (fmt) {
        __builtin_va_start(ap,fmt);
        vsnprintf(msg, sizeof(msg), fmt, ap);
        __builtin_va_end(ap);
        fprintf(stderr, "%s\n", msg);
    } else {
        perror(((void *)0));
    }
    exit(1);
}

variable_types:
fmt
char *

variable_types:
msg
char [4096]


repo: jjolly/anagram

original_code:
int main(int argc, char *argv[])
{
  char *srch, match[(64)], word[(64)];
  int count[26], ci, wild = 0, finding = 1, pos = 0;
  if ( argc < 2 )
    error_usage(argv[0], 1);
  for(ci = 0; ci < 26; ci++) count[ci] = 0;
  srch = argv[1];
  while(*srch != '\0')
  {
    ci = 1;
    if ( *srch >= '0' && *srch <= '9' )
    {
      ci = 0;
      while(*srch >= '0' && *srch <= '9')
        ci = ci * 10 + *(srch++) - '0';
    }
    if ( *srch >= 'a' && *srch <= 'z' ) count[*srch - 'a'] += ci;
    else if ( *srch >= 'A' && *srch <= 'Z' ) count[*srch - 'A'] += ci;
    else if ( *srch == '.' || *srch == '_' ) wild += ci;
    else error_usage(argv[0], 1);
    srch++;
  }
  match[0] = '\0';
  word[0] = '\0';
  while((ci = fgetc(stdin)) != (-1))
  {
    if ( ci & 0x80 )
      while ( (ci<<=1) & 0x80 ) fgetc(stdin);
    else if ( ci == '\n' || ci == '\r' )
    {
      if ( *word != '\0' && finding == 1 )
        fprintf(stdout, "%s\n", word);
      srch = match;
      while(*srch != '\0')
      {
        if ( *srch == '.' ) wild++;
        else count[*srch - 'a']++;
        srch++;
      }
      match[0] = '\0';
      word[0] = '\0';
      pos = 0;
      finding = 1;
    }
    else if ( finding == 1 )
    {
      if ( ci >= 'A' && ci <= 'Z' ) ci += 'a' - 'A';
      if ( ci >= 'a' && ci <= 'z' )
      {
        if ( count[ci - 'a'] > 0 )
        {
          count[ci - 'a']--;
          match[pos] = ci;
        }
        else if ( wild > 0 )
        {
          wild--;
          match[pos] = '.';
        }
        else finding = 0;
        if ( finding == 1 )
        {
          if ( pos < (64) - 1 )
          {
            word[pos++] = ci;
            word[pos] = '\0';
            match[pos] = '\0';
          }
          else finding = 0;
        }
      }
      else finding = 0;
    }
  }
  return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
  char *srch; char match[-1]; char word[-1];
  int count[26]; int ci; int wild = 0; int finding = 1; int pos = 0;
  if ( argc < 2 )
    error_usage(argv[0], 1);
  for(ci = 0; ci < 26; ci++) count[ci] = 0;
  srch = argv[1];
  while(*srch != '\0')
  {
    ci = 1;
    if ( *srch >= '0' && *srch <= '9' )
    {
      ci = 0;
      while(*srch >= '0' && *srch <= '9')
        ci = ci * 10 + *(srch++) - '0';
    }
    if ( *srch >= 'a' && *srch <= 'z' ) count[*srch - 'a'] += ci;
    else if ( *srch >= 'A' && *srch <= 'Z' ) count[*srch - 'A'] += ci;
    else if ( *srch == '.' || *srch == '_' ) wild += ci;
    else error_usage(argv[0], 1);
    srch++;
  }
  match[0] = '\0';
  word[0] = '\0';
  while((ci = fgetc(stdin)) != (-1))
  {
    if ( ci & 0x80 )
      while ( (ci<<=1) & 0x80 ) fgetc(stdin);
    else if ( ci == '\n' || ci == '\r' )
    {
      if ( *word != '\0' && finding == 1 )
        fprintf(stdout, "%s\n", word);
      srch = match;
      while(*srch != '\0')
      {
        if ( *srch == '.' ) wild++;
        else count[*srch - 'a']++;
        srch++;
      }
      match[0] = '\0';
      word[0] = '\0';
      pos = 0;
      finding = 1;
    }
    else if ( finding == 1 )
    {
      if ( ci >= 'A' && ci <= 'Z' ) ci += 'a' - 'A';
      if ( ci >= 'a' && ci <= 'z' )
      {
        if ( count[ci - 'a'] > 0 )
        {
          count[ci - 'a']--;
          match[pos] = ci;
        }
        else if ( wild > 0 )
        {
          wild--;
          match[pos] = '.';
        }
        else finding = 0;
        if ( finding == 1 )
        {
          if ( pos < (64) - 1 )
          {
            word[pos++] = ci;
            word[pos] = '\0';
            match[pos] = '\0';
          }
          else finding = 0;
        }
      }
      else finding = 0;
    }
  }
  return 0;
}

variable_types:
argv
char *[]

variable_types:
srch
char *

variable_types:
match
char [-1]

variable_types:
word
char [-1]

variable_types:
count
int [26]

variable_types: ci int

variable_types: wild int

variable_types: finding int

variable_types: pos int


usage

decompiled_code:
int __fastcall usage(const char *a1)
{
return fprintf(stderr, "%s: Anagrammer\n", a1);
}

canonical_decompiled_code:
int __fastcall func7(const char *a1)
{
return fprintf(stderr, "%s: Anagrammer\n", a1);
}

original_code:
void usage(const char *name)
{
  fprintf(stderr, "%s: Anagrammer\n", name);
}

canonical_original_code:
void usage(char *name)
{
  fprintf(stderr, "%s: Anagrammer\n", name);
}

variable_types:
name
char *


decompiled_code:
void __fastcall __noreturn error_usage(const char *a1, int a2)
{
usage(a1);
exit(a2);
}

canonical_decompiled_code:
void __fastcall __noreturn func8(const char *a1, int a2)
{
func7(a1);
exit(a2);
}

original_code:
void error_usage(const char *name, int err)
{
  usage(name);
  exit(err);
}

canonical_original_code:
void error_usage(char *name, int err)
{
  usage(name);
  exit(err);
}

variable_types: err int


decompiled_code:
__int64 __fastcall r_wait(__WAIT_STATUS stat_loc)
{
unsigned int v1; // er12

do
v1 = wait(stat_loc);
while ( v1 == -1 && *__errno_location() == 4 );
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func7(__WAIT_STATUS stat_loc)
{
unsigned int v1; // er12

do
v1 = wait(stat_loc);
while ( v1 == -1 && *__errno_location() == 4 );
return v1;
}

original_code:
pid_t r_wait (int* status_loc)
{
   int retval;
   while ( (retval = wait(status_loc) ) == -1 && ((*__errno_location ()) == 4) );
   return retval;
}

canonical_original_code:
int r_wait(int *status_loc)
{
   int retval;
   while ( (retval = wait(status_loc) ) == -1 && ((*__errno_location ()) == 4) );
   return retval;
}

variable_types: retval int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax
int v4; // ebp
unsigned int i; // er12
__pid_t v6; // ebx
__pid_t v7; // ebp
__pid_t v8; // eax

v3 = atoi(argv[1]);
if ( v3 <= 1 )
{
i = 1;
v6 = 0;
}
else
{
v4 = v3;
for ( i = 1; i != v4; ++i )
{
v6 = fork();
if ( v6 <= 0 )
break;
}
}
while ( (int)r_wait(0LL) > 0 )
;
v7 = getppid();
v8 = getpid();
fprintf(_bss_start, "i:%d process ID:%ld parent ID: %ld child ID %ld\n", i, v8, v7, v6);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax
int v4; // ebp
unsigned int i; // er12
__pid_t v6; // ebx
__pid_t v7; // ebp
__pid_t v8; // eax

v3 = atoi(argv[1]);
if ( v3 <= 1 )
{
i = 1;
v6 = 0;
}
else
{
v4 = v3;
for ( i = 1; i != v4; ++i )
{
v6 = fork();
if ( v6 <= 0 )
break;
}
}
while ( (int)func7(0LL) > 0 )
;
v7 = getppid();
v8 = getpid();
fprintf(_bss_start, "i:%d process ID:%ld parent ID: %ld child ID %ld\n", i, v8, v7, v6);
return 0;
}

original_code:
int main(int argc, char *argv[ ] )
{
   pid_t childpid = 0;
   int i, n;
   n = atoi ( argv[1] );
   for ( i = 1; i < n; i++)
        if ((childpid = fork( )) <= 0 )
             break;
   while (r_wait(((void *)0)) > 0);
   fprintf(stderr, "i:%d process ID:%ld  parent ID: %ld child ID %ld\n",
        i, (long)getpid( ), (long)getppid( ), (long)childpid );
   return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
   int childpid = 0;
   int i; int n;
   n = atoi ( argv[1] );
   for ( i = 1; i < n; i++)
        if ((childpid = fork( )) <= 0 )
             break;
   while (r_wait(((void *)0)) > 0);
   fprintf(stderr, "i:%d process ID:%ld  parent ID: %ld child ID %ld\n",
        i, (long)getpid( ), (long)getppid( ), (long)childpid );
   return 0;
}

variable_types: argc int

variable_types: childpid int

variable_types: i int

variable_types: n int


isPrime

decompiled_code:
__int64 __fastcall isPrime(int a1)
{
unsigned int v1; // edx
int v2; // ecx

v1 = 0;
v2 = 2;
if ( a1 <= 1 )
return v1;
while ( v2 * v2 <= a1 )
{
v1 = a1 % v2;
v2 += (v2 != 2) + 1;
if ( !v1 )
return v1;
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(int a1)
{
unsigned int v1; // edx
int v2; // ecx

v1 = 0;
v2 = 2;
if ( a1 <= 1 )
return v1;
while ( v2 * v2 <= a1 )
{
v1 = a1 % v2;
v2 += (v2 != 2) + 1;
if ( !v1 )
return v1;
}
return 1LL;
}

original_code:
int isPrime(int number) {
 int i, result = (1);
 if ( number < 2 ) result = (0);
 else
  for ( i = 2; result == (1) && i * i <= number; i += (i == 2) ? 1 : 2 )
   if ( number % i == 0 ) result = (0);
 return result;
}

canonical_original_code:
int isPrime(int number) {
 int i; int result = (1);
 if ( number < 2 ) result = (0);
 else
  for ( i = 2; result == (1) && i * i <= number; i += (i == 2) ? 1 : 2 )
   if ( number % i == 0 ) result = (0);
 return result;
}

variable_types: number int

variable_types: result int


printIsPrime

decompiled_code:
size_t __fastcall printIsPrime(unsigned int a1)
{
fprintf(stdout, "%d is ", a1);
if ( !(unsigned int)isPrime(a1) )
fwrite("not ", 1uLL, 4uLL, stdout);
return fwrite("prime\n", 1uLL, 6uLL, stdout);
}

canonical_decompiled_code:
size_t __fastcall func8(unsigned int a1)
{
fprintf(stdout, "%d is ", a1);
if ( !(unsigned int)func7(a1) )
fwrite("not ", 1uLL, 4uLL, stdout);
return fwrite("prime\n", 1uLL, 6uLL, stdout);
}

original_code:
void printIsPrime(int number) {
 fprintf(stdout, "%d is ", number);
 if ( isPrime(number) == (0) ) fprintf(stdout, "not ");
 fprintf(stdout, "prime\n");
}


isPrimeConsumer

decompiled_code:
void *__fastcall isPrimeConsumer(void *a1)
{
unsigned int v1; // er13
int v3; // eax
signed int v4; // ebx
FILE *v5; // rdi
unsigned int v6; // er14

v1 = 0;
v3 = *((_DWORD *)a1 + 20);
v4 = 0;
if ( !*((_DWORD *)a1 + 21) )
goto LABEL_4;
while ( v3 > 0 )
{
while ( 1 )
{
v5 = stdout;
v6 = *((_DWORD *)a1 + v4);
*((_DWORD *)a1 + 20) = v3 - 1;
++v1;
v4 = (v4 + 1) % 0x14u;
fprintf(v5, "%d :", v1);
printIsPrime(v6);
v3 = *((_DWORD *)a1 + 20);
if ( *((_DWORD *)a1 + 21) )
break;
LABEL_4:
while ( v3 <= 0 )
;
}
}
return 0LL;
}

canonical_decompiled_code:
void *__fastcall func9(void *a1)
{
unsigned int v1; // er13
int v3; // eax
signed int v4; // ebx
FILE *v5; // rdi
unsigned int v6; // er14

v1 = 0;
v3 = *((_DWORD *)a1 + 20);
v4 = 0;
if ( !*((_DWORD *)a1 + 21) )
goto LABEL_4;
while ( v3 > 0 )
{
while ( 1 )
{
v5 = stdout;
v6 = *((_DWORD *)a1 + v4);
*((_DWORD *)a1 + 20) = v3 - 1;
++v1;
v4 = (v4 + 1) % 0x14u;
fprintf(v5, "%d :", v1);
func8(v6);
v3 = *((_DWORD *)a1 + 20);
if ( *((_DWORD *)a1 + 21) )
break;
LABEL_4:
while ( v3 <= 0 )
;
}
}
return 0LL;
}

original_code:
void *isPrimeConsumer(void *ptr) {
 int count = 0, number, next_out = 0;
 struct primecheck_data *data = (struct primecheck_data *)ptr;
 while(data->done == (0) || data->count > 0) {
  if ( data->count > 0 ) {
   number = data->buffer[next_out];
   next_out = (next_out + 1) % (20);
   data->count--;
   fprintf(stdout, "%d :", ++count);
   printIsPrime(number);
  }
 }
 return ((void *)0);
}

canonical_original_code:
void *isPrimeConsumer(void *ptr) {
 int count = 0; int number; int next_out = 0;
 struct primecheck_data *data = (struct primecheck_data *)ptr;
 while(data->done == (0) || data->count > 0) {
  if ( data->count > 0 ) {
   number = data->buffer[next_out];
   next_out = (next_out + 1) % (20);
   data->count--;
   fprintf(stdout, "%d :", ++count);
   printIsPrime(number);
  }
 }
 return ((void *)0);
}

variable_types:
ptr
void *

variable_types: count int

variable_types: struct primecheck_data { int buffer[-1]; int count; int done; } *


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
_QWORD *v3; // rax
_DWORD *v4; // r13
signed int v5; // ebx
int v6; // er12
int v7; // eax
int v9; // [rsp+4h] [rbp-34h]
pthread_t newthread[6]; // [rsp+8h] [rbp-30h] BYREF

v3 = malloc(0x58uLL);
if ( v3 )
{
v3[10] = 0LL;
v4 = v3;
v5 = 0;
v6 = pthread_create(newthread, 0LL, isPrimeConsumer, v3);
if ( v6 )
{
v6 = 1;
fwrite("Failure to create consumer thread\n", 1uLL, 0x22uLL, stderr);
}
else
{
while ( (unsigned int)__isoc99_fscanf() == 1 )
{
v7 = v4[20];
if ( v7 == 20 )
{
while ( 1 )
;
}
v4[v5] = v9;
v4[20] = v7 + 1;
v5 = (v5 + 1) % 0x14u;
}
v4[21] = 1;
pthread_join(newthread[0], 0LL);
free(v4);
}
}
else
{
v6 = 1;
perror("Unable to allocate shared data structure");
}
return v6;
}

original_code:
int main() {
 pthread_t consumer;
 int number, next_in = 0;
 struct primecheck_data *data = malloc(sizeof(struct primecheck_data));
 if ( data == ((void *)0) ) {
  perror("Unable to allocate shared data structure");
  return(1);
 }
 data->count = 0;
 data->done = (0);
 if ( pthread_create(&consumer, ((void *)0), isPrimeConsumer, data) != 0 ) {
  fprintf(stderr, "Failure to create consumer thread\n");
  return(1);
 }
 while ( fscanf(stdin, "%d", &number) == 1 ) {
  while ( data->count == (20) );
  data->buffer[next_in] = number;
  next_in = (next_in + 1) % (20);
  data->count++;
 }
 data->done = (1);
 pthread_join(consumer, ((void *)0));
 free(data);
 return 0;
}

canonical_original_code:
int main() {
 unsigned long consumer;
 int number; int next_in = 0;
 struct primecheck_data *data = malloc(sizeof(struct primecheck_data));
 if ( data == ((void *)0) ) {
  perror("Unable to allocate shared data structure");
  return(1);
 }
 data->count = 0;
 data->done = (0);
 if ( pthread_create(&consumer, ((void *)0), isPrimeConsumer, data) != 0 ) {
  fprintf(stderr, "Failure to create consumer thread\n");
  return(1);
 }
 while ( fscanf(stdin, "%d", &number) == 1 ) {
  while ( data->count == (20) );
  data->buffer[next_in] = number;
  next_in = (next_in + 1) % (20);
  data->count++;
 }
 data->done = (1);
 pthread_join(consumer, ((void *)0));
 free(data);
 return 0;
}

variable_types:
consumer
unsigned long

user_defined_types: struct primecheck_data { int buffer[-1]; int count; int done; }


decompiled_code:
size_t p1sig()
{
return fwrite("Ping...\n", 1uLL, 8uLL, stderr);
}

canonical_decompiled_code:
size_t func7()
{
return fwrite("Ping...\n", 1uLL, 8uLL, stderr);
}

original_code:
void p1sig(int signo)
{
 fprintf(stderr, "Ping...\n");
}

variable_types: signo int


decompiled_code:
size_t p2sig()
{
return fwrite("Pong...\n", 1uLL, 8uLL, stderr);
}

canonical_decompiled_code:
size_t func8()
{
return fwrite("Pong...\n", 1uLL, 8uLL, stderr);
}

original_code:
void p2sig(int signo)
{
 fprintf(stderr, "Pong...\n");
}


parent

decompiled_code:
void __fastcall __noreturn parent(__pid_t pid)
{
sigset_t v1; // [rsp+0h] [rbp-128h] BYREF
struct sigaction v2; // [rsp+80h] [rbp-A8h] BYREF

v2.sa_handler = (__sighandler_t)p1sig;
sigemptyset(&v2.sa_mask);
v2.sa_flags = 0;
sigaction(10, &v2, 0LL);
while ( 1 )
{
sigfillset(&v1);
sigdelset(&v1, 10);
sigdelset(&v1, 2);
sigsuspend(&v1);
sleep(1u);
kill(pid, 10);
}
}

canonical_decompiled_code:
void __fastcall __noreturn func9(__pid_t pid)
{
sigset_t v1; // [rsp+0h] [rbp-128h] BYREF
struct sigaction v2; // [rsp+80h] [rbp-A8h] BYREF

v2.sa_handler = (__sighandler_t)p1sig;
sigemptyset(&v2.sa_mask);
v2.sa_flags = 0;
sigaction(10, &v2, 0LL);
while ( 1 )
{
sigfillset(&v1);
sigdelset(&v1, 10);
sigdelset(&v1, 2);
sigsuspend(&v1);
sleep(1u);
kill(pid, 10);
}
}

original_code:
void parent(int childpid)
{
 struct sigaction sa;
 sigset_t sigmask;
 sa.__sigaction_handler.sa_handler = p1sig;
 sigemptyset(&sa.sa_mask);
 sa.sa_flags = 0;
 sigaction(10, &sa, ((void *)0));
 while(1)
 {
  sigfillset(&sigmask);
  sigdelset(&sigmask,10);
  sigdelset(&sigmask,2);
  sigsuspend(&sigmask);
  sleep(1);
  kill(childpid, 10);
 }
}

canonical_original_code:
void parent(int childpid)
{
 struct sigaction sa;
 struct __sigset_t sigmask;
 sa.__sigaction_handler.sa_handler = p1sig;
 sigemptyset(&sa.sa_mask);
 sa.sa_flags = 0;
 sigaction(10, &sa, ((void *)0));
 while(1)
 {
  sigfillset(&sigmask);
  sigdelset(&sigmask,10);
  sigdelset(&sigmask,2);
  sigsuspend(&sigmask);
  sleep(1);
  kill(childpid, 10);
 }
}

variable_types: struct sigaction { union { void (*sa_handler)(int); void (*sa_sigaction)(int, struct siginfo_t { int si_signo; int si_errno; int si_code; int __pad0; union { int _pad[-1]; struct { int si_pid; unsigned int si_uid; } _kill; struct { int si_tid; int si_overrun; union sigval { int sival_int; void *sival_ptr; } si_sigval; } _timer; struct { int si_pid; unsigned int si_uid; union sigval si_sigval; } _rt; struct { int si_pid; unsigned int si_uid; int si_status; long si_utime; long si_stime; } _sigchld; struct { void *si_addr; short si_addr_lsb; union { struct { void *_lower; void *_upper; } _addr_bnd; unsigned int _pkey; } _bounds; } _sigfault; struct { long si_band; int si_fd; } _sigpoll; struct { void *_call_addr; int _syscall; unsigned int _arch; } _sigsys; } _sifields; } *, void *); } __sigaction_handler; struct __sigset_t { unsigned long __val[-1]; } sa_mask; int sa_flags; void (*sa_restorer)(); }

user_defined_types: struct sigaction { union { void (*sa_handler)(int); void (*sa_sigaction)(int, struct siginfo_t *, void *); } __sigaction_handler; struct __sigset_t sa_mask; int sa_flags; void (*sa_restorer)(); }

user_defined_types: struct siginfo_t { int si_signo; int si_errno; int si_code; int __pad0; union { int _pad[-1]; struct { int si_pid; unsigned int si_uid; } _kill; struct { int si_tid; int si_overrun; union sigval si_sigval; } _timer; struct { int si_pid; unsigned int si_uid; union sigval si_sigval; } _rt; struct { int si_pid; unsigned int si_uid; int si_status; long si_utime; long si_stime; } _sigchld; struct { void *si_addr; short si_addr_lsb; union { struct { void *_lower; void *_upper; } _addr_bnd; unsigned int _pkey; } _bounds; } _sigfault; struct { long si_band; int si_fd; } _sigpoll; struct { void *_call_addr; int _syscall; unsigned int _arch; } _sigsys; } _sifields; }


child

decompiled_code:
void __noreturn child()
{
__pid_t v0; // eax
sigset_t v1; // [rsp+0h] [rbp-128h] BYREF
struct sigaction v2; // [rsp+80h] [rbp-A8h] BYREF

v2.sa_handler = (__sighandler_t)p2sig;
sigemptyset(&v2.sa_mask);
v2.sa_flags = 0;
sigaction(10, &v2, 0LL);
while ( 1 )
{
sleep(1u);
v0 = getppid();
kill(v0, 10);
sigfillset(&v1);
sigdelset(&v1, 10);
sigdelset(&v1, 2);
sigsuspend(&v1);
}
}

canonical_decompiled_code:
void __noreturn func10()
{
__pid_t v0; // eax
sigset_t v1; // [rsp+0h] [rbp-128h] BYREF
struct sigaction v2; // [rsp+80h] [rbp-A8h] BYREF

v2.sa_handler = (__sighandler_t)p2sig;
sigemptyset(&v2.sa_mask);
v2.sa_flags = 0;
sigaction(10, &v2, 0LL);
while ( 1 )
{
sleep(1u);
v0 = getppid();
kill(v0, 10);
sigfillset(&v1);
sigdelset(&v1, 10);
sigdelset(&v1, 2);
sigsuspend(&v1);
}
}

original_code:
void child()
{
 struct sigaction sa;
 sigset_t sigmask;
 sa.__sigaction_handler.sa_handler = p2sig;
 sigemptyset(&sa.sa_mask);
 sa.sa_flags = 0;
 sigaction(10, &sa, ((void *)0));
 while(1)
 {
  sleep(1);
  kill(getppid(), 10);
  sigfillset(&sigmask);
  sigdelset(&sigmask,10);
  sigdelset(&sigmask,2);
  sigsuspend(&sigmask);
 }
}

canonical_original_code:
void child()
{
 struct sigaction sa;
 struct __sigset_t sigmask;
 sa.__sigaction_handler.sa_handler = p2sig;
 sigemptyset(&sa.sa_mask);
 sa.sa_flags = 0;
 sigaction(10, &sa, ((void *)0));
 while(1)
 {
  sleep(1);
  kill(getppid(), 10);
  sigfillset(&sigmask);
  sigdelset(&sigmask,10);
  sigdelset(&sigmask,2);
  sigsuspend(&sigmask);
 }
}

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

user_defined_types: union sigval { int sival_int; void *sival_ptr; }


main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
__pid_t v3; // eax

v3 = fork();
if ( !v3 )
child(argc, argv);
parent(v3);
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
__pid_t v3; // eax

v3 = fork();
if ( !v3 )
func10(argc, argv);
func9(v3);
}

original_code:
int main()
{
 int childpid = fork();
 if ( childpid == 0 )
 {
  child();
 }
 else
 {
  parent(childpid);
 }
 return 0;
}


producer

decompiled_code:
void __fastcall __noreturn producer(void *a1)
{
__int64 v1; // rdi
int i; // ecx

v1 = buffer;
for ( i = 1; counter != 20; ++counter )
{
*(_DWORD *)(v1 + 4LL * in) = i++;
in = (in + 1) % 20;
}
while ( 1 )
;
}

canonical_decompiled_code:
void __fastcall __noreturn func7(void *a1)
{
__int64 v1; // rdi
int i; // ecx

v1 = buffer;
for ( i = 1; counter != 20; ++counter )
{
*(_DWORD *)(v1 + 4LL * in) = i++;
in = (in + 1) % 20;
}
while ( 1 )
;
}

original_code:
void *producer(void *ptr) {
 int value = 1;
 while(1) {
  while(counter == (20))
   ;
  buffer[in] = value++;
  in = (in + 1) % (20);
  counter++;
 }
}

variable_types: value int


consumer

decompiled_code:
__int64 consumer()
{
int v0; // edx
unsigned int v1; // er8
__int64 result; // rax
__int64 v3; // rsi

v0 = counter;
v1 = 0;
LODWORD(result) = out;
do
{
if ( !v0 )
{
while ( 1 )
;
}
++v1;
v3 = *(unsigned int *)(buffer + 4LL * (int)result);
if ( (_DWORD)v3 != v1 )
{
printf("Error at value %d! I was expecting %d\n", v3, v1);
exit(-1);
}
counter = --v0;
result = (unsigned int)(((int)result + 1) % 20);
out = result;
}
while ( v1 != 0x10000 );
return result;
}

canonical_decompiled_code:
__int64 func8()
{
int v0; // edx
unsigned int v1; // er8
__int64 result; // rax
__int64 v3; // rsi

v0 = counter;
v1 = 0;
LODWORD(result) = out;
do
{
if ( !v0 )
{
while ( 1 )
;
}
++v1;
v3 = *(unsigned int *)(buffer + 4LL * (int)result);
if ( (_DWORD)v3 != v1 )
{
printf("Error at value %d! I was expecting %d\n", v3, v1);
exit(-1);
}
counter = --v0;
result = (unsigned int)(((int)result + 1) % 20);
out = result;
}
while ( v1 != 0x10000 );
return result;
}

original_code:
void consumer() {
 int last = 0;
 while(last < 65536) {
  while(counter == 0)
   ;
  last++;
  if ( last != buffer[out] ) {
   printf("Error at value %d! I was expecting %d\n", buffer[out], last);
   exit(-1);
  }
  out = (out + 1) % (20);
  counter--;
 }
}

variable_types: last int