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

ID_current = -1;
result = staff_partID;
MultiN = 0;
if ( staff_partID == -1 )
{
part_current = 0LL;
voice_current = &voice_unparted;
}
partID_current = staff_partID;
return result;
}

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

ID_current = -1;
result = staff_partID;
MultiN = 0;
if ( staff_partID == -1 )
{
part_current = 0LL;
voice_current = &voice_unparted;
}
partID_current = staff_partID;
return result;
}

original_code:
void
tags_reset(void)
{
    ID_current = -1;
    MultiN = 0;
    if (staff_partID == -1) {
        part_current = ((void *)0);
        voice_current = &voice_unparted;
    }
    partID_current = staff_partID;
}

canonical_original_code:
void tags_reset()
{
    ID_current = -1;
    MultiN = 0;
    if (staff_partID == -1) {
        part_current = ((void *)0);
        voice_current = &voice_unparted;
    }
    partID_current = staff_partID;
}


repo: rfhh/lily-contribs

decompiled_code:
__int64 __fastcall slur_dupl_lookup(int a1)
{
return *((unsigned int *)slurs_duplicate + a1);
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
return *((unsigned int *)slurs_duplicate + a1);
}

original_code:
static int
slur_dupl_lookup(int ID)
{
    return slurs_duplicate[ID];
}

variable_types: ID int

return_type: int


decompiled_code:
__int64 __fastcall slur_dupl_create(int a1)
{
unsigned int v1; // er12

v1 = n_slurs;
slurs_increase(n_slurs);
*((_DWORD *)slurs_duplicate + a1) = v1;
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
unsigned int v1; // er12

v1 = n_slurs;
slurs_increase(n_slurs);
*((_DWORD *)slurs_duplicate + a1) = v1;
return v1;
}

original_code:
static int
slur_dupl_create(int ID)
{
    int new_ID = n_slurs;
    slurs_increase(new_ID);
    slurs_duplicate[ID] = new_ID;
    return new_ID;
}


decompiled_code:
void __fastcall xly_chord(int a1)
{
void *v2; // rax
FILE *v3; // r12
__int64 v4; // r14
__int64 v5; // rax
__int64 v6; // rbx
unsigned int v7; // er15
__int64 v8; // rcx
__int64 v9; // rdi
__int64 v10; // r14
__int64 v11; // rax
__int64 v12; // rbp
unsigned int v13; // ebx
__int64 v14; // rcx
__int64 v15; // rdi
__int64 v16; // r14
__int64 v17; // rax
__int64 v18; // rbp
unsigned int v19; // ebx
__int64 v20; // rcx
__int64 v21; // rdi
__int64 v22; // rcx
__int64 v23; // r8

v2 = malloc(4LL * n_ties);
v3 = stderr;
ties_duplicate = v2;
if ( !v2 )
{
v22 = 281LL;
v23 = 4LL * n_ties;
LABEL_21:
fprintf(v3, "%s:%d malloc(%zd) fails\n", "xly_chord.c", v22, v23);
return;
}
if ( n_ties > 0 )
memset(v2, 255, 4LL * n_ties);
slurs_duplicate = malloc(4LL * n_slurs);
if ( !slurs_duplicate )
{
v22 = 290LL;
v23 = 4LL * n_slurs;
goto LABEL_21;
}
if ( n_slurs > 0 )
memset(slurs_duplicate, 255, 4LL * n_slurs);
v4 = 0LL;
fwrite("Chord analysis...\n", 1uLL, 0x12uLL, v3);
v5 = part;
if ( n_part > 0 )
{
do
{
v6 = 0LL;
v7 = 0;
if ( *(int *)(v5 + 16 * v4) > 0 )
{
do
{
v8 = v7++;
fprintf(stderr, " ........ part %d, staff %d\n", (unsigned int)v4, v8);
v9 = v6 + *(_QWORD *)(part + 16 * v4 + 8);
v6 += 72LL;
do_staff_chording(v9, a1);
v5 = part;
}
while ( *(_DWORD *)(part + 16 * v4) > (signed int)v7 );
}
++v4;
}
while ( n_part > (int)v4 );
}
v10 = 0LL;
fwrite("Pending slur analysis...\n", 1uLL, 0x19uLL, stderr);
v11 = part;
if ( n_part > 0 )
{
do
{
v12 = 0LL;
v13 = 0;
if ( *(int *)(v11 + 16 * v10) > 0 )
{
do
{
v14 = v13++;
fprintf(stderr, " ........ part %d, staff %d\n", (unsigned int)v10, v14);
v15 = *(_QWORD *)(*(_QWORD *)(part + 16 * v10 + 8) + v12 + 32);
v12 += 72LL;
do_staff_slur_pending_isra_0(v15);
v11 = part;
}
while ( *(_DWORD *)(part + 16 * v10) > (signed int)v13 );
}
++v10;
}
while ( n_part > (int)v10 );
}
v16 = 0LL;
fwrite("Multibar rest aggregation...\n", 1uLL, 0x1DuLL, stderr);
v17 = part;
if ( n_part > 0 )
{
do
{
v18 = 0LL;
v19 = 0;
if ( *(int *)(v17 + 16 * v16) > 0 )
{
do
{
v20 = v19++;
fprintf(stderr, " ........ part %d, staff %d\n", (unsigned int)v16, v20);
v21 = v18 + *(_QWORD *)(part + 16 * v16 + 8);
v18 += 72LL;
do_staff_multibar_aggregate(v21);
v17 = part;
}
while ( *(_DWORD *)(part + 16 * v16) > (signed int)v19 );
}
++v16;
}
while ( n_part > (int)v16 );
}
free(ties_duplicate);
free(slurs_duplicate);
}

canonical_decompiled_code:
void __fastcall func5(int a1)
{
void *v2; // rax
FILE *v3; // r12
__int64 v4; // r14
__int64 v5; // rax
__int64 v6; // rbx
unsigned int v7; // er15
__int64 v8; // rcx
__int64 v9; // rdi
__int64 v10; // r14
__int64 v11; // rax
__int64 v12; // rbp
unsigned int v13; // ebx
__int64 v14; // rcx
__int64 v15; // rdi
__int64 v16; // r14
__int64 v17; // rax
__int64 v18; // rbp
unsigned int v19; // ebx
__int64 v20; // rcx
__int64 v21; // rdi
__int64 v22; // rcx
__int64 v23; // r8

v2 = malloc(4LL * n_ties);
v3 = stderr;
ties_duplicate = v2;
if ( !v2 )
{
v22 = 281LL;
v23 = 4LL * n_ties;
LABEL_21:
fprintf(v3, "%s:%d malloc(%zd) fails\n", "xly_chord.c", v22, v23);
return;
}
if ( n_ties > 0 )
memset(v2, 255, 4LL * n_ties);
slurs_duplicate = malloc(4LL * n_slurs);
if ( !slurs_duplicate )
{
v22 = 290LL;
v23 = 4LL * n_slurs;
goto LABEL_21;
}
if ( n_slurs > 0 )
memset(slurs_duplicate, 255, 4LL * n_slurs);
v4 = 0LL;
fwrite("Chord analysis...\n", 1uLL, 0x12uLL, v3);
v5 = part;
if ( n_part > 0 )
{
do
{
v6 = 0LL;
v7 = 0;
if ( *(int *)(v5 + 16 * v4) > 0 )
{
do
{
v8 = v7++;
fprintf(stderr, " ........ part %d, staff %d\n", (unsigned int)v4, v8);
v9 = v6 + *(_QWORD *)(part + 16 * v4 + 8);
v6 += 72LL;
func2(v9, a1);
v5 = part;
}
while ( *(_DWORD *)(part + 16 * v4) > (signed int)v7 );
}
++v4;
}
while ( n_part > (int)v4 );
}
v10 = 0LL;
fwrite("Pending slur analysis...\n", 1uLL, 0x19uLL, stderr);
v11 = part;
if ( n_part > 0 )
{
do
{
v12 = 0LL;
v13 = 0;
if ( *(int *)(v11 + 16 * v10) > 0 )
{
do
{
v14 = v13++;
fprintf(stderr, " ........ part %d, staff %d\n", (unsigned int)v10, v14);
v15 = *(_QWORD *)(*(_QWORD *)(part + 16 * v10 + 8) + v12 + 32);
v12 += 72LL;
func4(v15);
v11 = part;
}
while ( *(_DWORD *)(part + 16 * v10) > (signed int)v13 );
}
++v10;
}
while ( n_part > (int)v10 );
}
v16 = 0LL;
fwrite("Multibar rest aggregation...\n", 1uLL, 0x1DuLL, stderr);
v17 = part;
if ( n_part > 0 )
{
do
{
v18 = 0LL;
v19 = 0;
if ( *(int *)(v17 + 16 * v16) > 0 )
{
do
{
v20 = v19++;
fprintf(stderr, " ........ part %d, staff %d\n", (unsigned int)v16, v20);
v21 = v18 + *(_QWORD *)(part + 16 * v16 + 8);
v18 += 72LL;
func3(v21);
v17 = part;
}
while ( *(_DWORD *)(part + 16 * v16) > (signed int)v19 );
}
++v16;
}
while ( n_part > (int)v16 );
}
free(ties_duplicate);
free(slurs_duplicate);
}

original_code:
void
xly_chord(int do_chording)
{
    int p;
    int f;
    int i;
    ties_duplicate = malloc(n_ties * sizeof *ties_duplicate);
    if (ties_duplicate == ((void *)0)) {
        fprintf(stderr, "%s:%d malloc(%zd) fails\n", "xly_chord.c", 281,
                n_ties * sizeof *ties_duplicate);
        return;
    }
    for (i = 0; i < n_ties; i++) {
        ties_duplicate[i] = -1;
    }
    slurs_duplicate = malloc(n_slurs * sizeof *slurs_duplicate);
    if (slurs_duplicate == ((void *)0)) {
        fprintf(stderr, "%s:%d malloc(%zd) fails\n", "xly_chord.c", 290,
                n_slurs * sizeof *slurs_duplicate);
        return;
    }
    for (i = 0; i < n_slurs; i++) {
        slurs_duplicate[i] = -1;
    }
    fprintf(stderr, "Chord analysis...\n");
    for (p = 0; p < n_part; p++) {
        for (f = 0; f < part[p].n_staff; f++) {
            fprintf(stderr, "      ........ part %d, staff %d\n", p, f);
            do_staff_chording(&part[p].staff[f], do_chording);
        }
    }
    fprintf(stderr, "Pending slur analysis...\n");
    for (p = 0; p < n_part; p++) {
        for (f = 0; f < part[p].n_staff; f++) {
            fprintf(stderr, "      ........ part %d, staff %d\n", p, f);
            do_staff_slur_pending(&part[p].staff[f]);
        }
    }
    fprintf(stderr, "Multibar rest aggregation...\n");
    for (p = 0; p < n_part; p++) {
        for (f = 0; f < part[p].n_staff; f++) {
            fprintf(stderr, "      ........ part %d, staff %d\n", p, f);
            do_staff_multibar_aggregate(&part[p].staff[f]);
        }
    }
    free(ties_duplicate);
    free(slurs_duplicate);
}

variable_types: p int

variable_types: f int

variable_types: i int

return_type: void


decompiled_code:
void xly_chord_init()
{
;
}

canonical_decompiled_code:
void func6()
{
;
}

original_code:
void
xly_chord_init(void)
{
}

canonical_original_code:
void xly_chord_init()
{
}


decompiled_code:
void xly_chord_end()
{
;
}

canonical_decompiled_code:
void func7()
{
;
}

original_code:
void
xly_chord_end(void)
{
}

canonical_original_code:
void xly_chord_end()
{
}


doindent

decompiled_code:
int __fastcall doindent(int a1)
{
int v1; // edi
int v2; // ebx
int result; // eax

v1 = a1 - 1;
if ( v1 && 4 * v1 )
{
v2 = 0;
do
{
++v2;
result = putchar(32);
}
while ( 4 * v1 != v2 );
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(int a1)
{
int v1; // edi
int v2; // ebx
int result; // eax

v1 = a1 - 1;
if ( v1 && 4 * v1 )
{
v2 = 0;
do
{
++v2;
result = putchar(32);
}
while ( 4 * v1 != v2 );
}
return result;
}

original_code:
void
doindent(unsigned indent)
{
    int i;
    if ((--indent) <= 0 )
        return;
    indent *= 4;
    for (i = 0; i < indent; i++)
        printf(" ");
}

canonical_original_code:
void doindent(unsigned int indent)
{
    int i;
    if ((--indent) <= 0 )
        return;
    indent *= 4;
    for (i = 0; i < indent; i++)
        printf(" ");
}

variable_types:
indent
unsigned int


printSHORT

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

result = xly_verbose;
if ( xly_verbose )
result = verbose_printf(" %s=%d", a2, (unsigned int)a1);
return result;
}

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

result = xly_verbose;
if ( xly_verbose )
result = verbose_printf(" %s=%d", a2, (unsigned int)a1);
return result;
}

original_code:
void
printSHORT(SHORT h, const char *strComment)
{
    ((xly_verbose) ? verbose_printf(" %s=%d", strComment, h) : RIFFIO_OK);
}

canonical_original_code:
void printSHORT(short h, char *strComment)
{
    ((xly_verbose) ? verbose_printf(" %s=%d", strComment, h) : RIFFIO_OK);
}

variable_types: h short

variable_types:
strComment
char *


printSTROFFSET

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

result = xly_verbose;
if ( xly_verbose )
result = verbose_printf(" // %s\n", a2);
return result;
}

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

result = xly_verbose;
if ( xly_verbose )
result = verbose_printf(" // %s\n", a2);
return result;
}

original_code:
void
printSTROFFSET(STROFFSET offset, const char *strComment)
{
    ((xly_verbose) ? verbose_printf(" // %s\n", strComment) : RIFFIO_OK);
}

canonical_original_code:
void printSTROFFSET(long offset, char *strComment)
{
    ((xly_verbose) ? verbose_printf(" // %s\n", strComment) : RIFFIO_OK);
}

variable_types: offset long


printRATIONAL

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

result = xly_verbose;
if ( xly_verbose )
result = verbose_printf(" %s=%d/%d", a2, (unsigned int)(__int16)a1, (unsigned int)(a1 >> 16));
return result;
}

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

result = xly_verbose;
if ( xly_verbose )
result = verbose_printf(" %s=%d/%d", a2, (unsigned int)(__int16)a1, (unsigned int)(a1 >> 16));
return result;
}

original_code:
void
printRATIONAL(RATIONAL r, const char *strComment)
{
    ((xly_verbose) ? verbose_printf(" %s=%d/%d", strComment, r.numerator, r.denominator) : RIFFIO_OK);
}

canonical_original_code:
void printRATIONAL(struct RATIONAL r, char *strComment)
{
    ((xly_verbose) ? verbose_printf(" %s=%d/%d", strComment, r.numerator, r.denominator) : RIFFIO_OK);
}

variable_types: struct RATIONAL { short numerator; short denominator; }


printBYTE

decompiled_code:
__int64 __fastcall printBYTE(unsigned __int8 a1, const char *a2)
{
__int64 result; // rax

result = xly_verbose;
if ( xly_verbose )
result = verbose_printf(" %s=%u", a2, a1);
return result;
}

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

result = xly_verbose;
if ( xly_verbose )
result = verbose_printf(" %s=%u", a2, a1);
return result;
}

original_code:
void
printBYTE(BYTE b, const char *strComment)
{
    ((xly_verbose) ? verbose_printf(" %s=%u", strComment, b) : RIFFIO_OK);
}

canonical_original_code:
void printBYTE(unsigned char b, char *strComment)
{
    ((xly_verbose) ? verbose_printf(" %s=%u", strComment, b) : RIFFIO_OK);
}

variable_types:
b
unsigned char


printSIGNEDBYTE

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

result = xly_verbose;
if ( xly_verbose )
result = verbose_printf(" %s=%d", a2, (unsigned int)a1);
return result;
}

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

result = xly_verbose;
if ( xly_verbose )
result = verbose_printf(" %s=%d", a2, (unsigned int)a1);
return result;
}

original_code:
void
printSIGNEDBYTE(SIGNEDBYTE sb, const char *strComment)
{
    ((xly_verbose) ? verbose_printf(" %s=%d", strComment, sb) : RIFFIO_OK);
}

canonical_original_code:
void printSIGNEDBYTE(char sb, char *strComment)
{
    ((xly_verbose) ? verbose_printf(" %s=%d", strComment, sb) : RIFFIO_OK);
}

variable_types: sb char


decompiled_code:
__int64 xly_init()
{
xly_partial_init();
xly_chord_init();
xly_repeat_init();
xly_voice_init();
return xly_dump_init();
}

canonical_decompiled_code:
__int64 func1()
{
xly_partial_init();
xly_chord_init();
xly_repeat_init();
xly_voice_init();
return xly_dump_init();
}

original_code:
void
xly_init(void)
{
    xly_partial_init();
    xly_chord_init();
    xly_repeat_init();
    xly_voice_init();
    xly_dump_init();
}

canonical_original_code:
void xly_init()
{
    xly_partial_init();
    xly_chord_init();
    xly_repeat_init();
    xly_voice_init();
    xly_dump_init();
}


decompiled_code:
__int64 xly_end()
{
xly_dump_end();
xly_partial_end();
xly_repeat_end();
xly_chord_end();
return xly_voice_end();
}

canonical_decompiled_code:
__int64 func2()
{
xly_dump_end();
xly_partial_end();
xly_repeat_end();
xly_chord_end();
return xly_voice_end();
}

original_code:
void
xly_end(void)
{
    xly_dump_end();
    xly_partial_end();
    xly_repeat_end();
    xly_chord_end();
    xly_voice_end();
}

canonical_original_code:
void xly_end()
{
    xly_dump_end();
    xly_partial_end();
    xly_repeat_end();
    xly_chord_end();
    xly_voice_end();
}


decompiled_code:
__int64 xly_partial()
{
__int64 v0; // r13
__int64 v1; // rax
__int64 v2; // rbx
__int64 v3; // rdx
__int64 result; // rax
_BYTE v5[72]; // [rsp+0h] [rbp-48h] BYREF

v0 = 0LL;
fwrite("Find partial start...\n", 1uLL, 0x16uLL, stderr);
_gmpq_init(v5);
v1 = part;
if ( n_part > 0 )
{
do
{
v2 = 0LL;
v3 = v1 + 16 * v0;
if ( *(int *)v3 > 0 )
{
do
{
do_staff_partial((__int64)v5, *(_QWORD *)(v3 + 8) + 72 * v2);
if ( (unsigned int)v2 | (unsigned int)v0 )
{
if ( !(unsigned int)_gmpq_equal(v5, &xly_t_partial) )
{
fprintf(stderr, "Uh oh -- partial part %d staff %d = ", (unsigned int)v0, (unsigned int)v2);
_gmpq_out_str(stderr, 10LL, v5);
fwrite(" global = ", 1uLL, 0xAuLL, stderr);
_gmpq_out_str(stderr, 10LL, &xly_t_partial);
fputc(10, stderr);
}
}
else
{
_gmpq_set(&xly_t_partial, v5);
}
v1 = part;
++v2;
v3 = part + 16 * v0;
}
while ( *(_DWORD *)v3 > (int)v2 );
}
++v0;
}
while ( n_part > (int)v0 );
}
result = _gmpq_clear(v5);
if ( xly_verbose )
{
result = verbose_printf("Partial = ");
if ( xly_verbose )
{
_gmpq_out_str(stderr, 10LL, &xly_t_partial);
result = xly_verbose;
if ( xly_verbose )
result = verbose_printf("\n");
}
}
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 v0; // r13
__int64 v1; // rax
__int64 v2; // rbx
__int64 v3; // rdx
__int64 result; // rax
_BYTE v5[72]; // [rsp+0h] [rbp-48h] BYREF

v0 = 0LL;
fwrite("Find partial start...\n", 1uLL, 0x16uLL, stderr);
_gmpq_init(v5);
v1 = part;
if ( n_part > 0 )
{
do
{
v2 = 0LL;
v3 = v1 + 16 * v0;
if ( *(int *)v3 > 0 )
{
do
{
func0((__int64)v5, *(_QWORD *)(v3 + 8) + 72 * v2);
if ( (unsigned int)v2 | (unsigned int)v0 )
{
if ( !(unsigned int)_gmpq_equal(v5, &xly_t_partial) )
{
fprintf(stderr, "Uh oh -- partial part %d staff %d = ", (unsigned int)v0, (unsigned int)v2);
_gmpq_out_str(stderr, 10LL, v5);
fwrite(" global = ", 1uLL, 0xAuLL, stderr);
_gmpq_out_str(stderr, 10LL, &xly_t_partial);
fputc(10, stderr);
}
}
else
{
_gmpq_set(&xly_t_partial, v5);
}
v1 = part;
++v2;
v3 = part + 16 * v0;
}
while ( *(_DWORD *)v3 > (int)v2 );
}
++v0;
}
while ( n_part > (int)v0 );
}
result = _gmpq_clear(v5);
if ( xly_verbose )
{
result = verbose_printf("Partial = ");
if ( xly_verbose )
{
_gmpq_out_str(stderr, 10LL, &xly_t_partial);
result = xly_verbose;
if ( xly_verbose )
result = verbose_printf("\n");
}
}
return result;
}

original_code:
void
xly_partial(void)
{
    int p;
    int f;
    mpq_t t;
    fprintf(stderr, "Find partial start...\n");
    __gmpq_init(t);
    for (p = 0; p < n_part; p++) {
        for (f = 0; f < part[p].n_staff; f++) {
            do_staff_partial(&t, &part[p].staff[f]);
            if (p == 0 && f == 0) {
                __gmpq_set(xly_t_partial, t);
            } else if (! __gmpq_equal(t, xly_t_partial)) {
                fprintf(stderr, "Uh oh -- partial part %d staff %d = ", p, f);
                __gmpq_out_str(stderr, 10, t);
                fprintf(stderr, " global = ");
                __gmpq_out_str(stderr, 10, xly_t_partial);
                fprintf(stderr, "\n");
            }
        }
    }
    __gmpq_clear(t);
    ((xly_verbose) ? verbose_printf("Partial = ") : RIFFIO_OK);
    ((xly_verbose) ? __gmpq_out_str(stderr, 10, xly_t_partial) : RIFFIO_OK);
    ((xly_verbose) ? verbose_printf("\n") : RIFFIO_OK);
}

canonical_original_code:
void xly_partial()
{
    int p;
    int f;
    struct __mpq_struct t[1];
    fprintf(stderr, "Find partial start...\n");
    __gmpq_init(t);
    for (p = 0; p < n_part; p++) {
        for (f = 0; f < part[p].n_staff; f++) {
            do_staff_partial(&t, &part[p].staff[f]);
            if (p == 0 && f == 0) {
                __gmpq_set(xly_t_partial, t);
            } else if (! __gmpq_equal(t, xly_t_partial)) {
                fprintf(stderr, "Uh oh -- partial part %d staff %d = ", p, f);
                __gmpq_out_str(stderr, 10, t);
                fprintf(stderr, " global = ");
                __gmpq_out_str(stderr, 10, xly_t_partial);
                fprintf(stderr, "\n");
            }
        }
    }
    __gmpq_clear(t);
    ((xly_verbose) ? verbose_printf("Partial = ") : RIFFIO_OK);
    ((xly_verbose) ? __gmpq_out_str(stderr, 10, xly_t_partial) : RIFFIO_OK);
    ((xly_verbose) ? verbose_printf("\n") : RIFFIO_OK);
}

variable_types: struct __mpq_struct { struct __mpz_struct { int _mp_alloc; int _mp_size; unsigned long *_mp_d; } _mp_num; struct __mpz_struct _mp_den; } [1]

user_defined_types: struct __mpq_struct { struct __mpz_struct _mp_num; struct __mpz_struct _mp_den; }


decompiled_code:
__int64 xly_partial_init()
{
return _gmpq_init(&xly_t_partial);
}

canonical_decompiled_code:
__int64 func2()
{
return _gmpq_init(&xly_t_partial);
}

original_code:
void
xly_partial_init(void)
{
    __gmpq_init(xly_t_partial);
}

canonical_original_code:
void xly_partial_init()
{
    __gmpq_init(xly_t_partial);
}


decompiled_code:
void xly_partial_end()
{
;
}

canonical_decompiled_code:
void func3()
{
;
}

original_code:
void
xly_partial_end(void)
{
}

canonical_original_code:
void xly_partial_end()
{
}


decompiled_code:
void __fastcall increase_tuplets(int a1)
{
if ( n_tuplet <= a1 )
{
n_tuplet = a1 + 1;
global_tuplet = realloc(global_tuplet, 56LL * (a1 + 1));
}
}

canonical_decompiled_code:
void __fastcall func1(int a1)
{
if ( n_tuplet <= a1 )
{
n_tuplet = a1 + 1;
global_tuplet = realloc(global_tuplet, 56LL * (a1 + 1));
}
}

original_code:
static void
increase_tuplets(int ID)
{
    if (ID < n_tuplet) {
        return;
    }
    n_tuplet = ID + 1;
    global_tuplet = realloc(global_tuplet, n_tuplet * sizeof(*global_tuplet));
}


main

canonical_name: main

repo: rfjakob/earlyoom

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
__int64 v3; // r15
__int64 v4; // rax
__int64 v5; // rbx
__int64 v6; // r14
size_t v7; // rbx
_BYTE *v8; // rax
int v9; // edx
__int64 v10; // r8
__int64 v11; // r13
__int64 i; // [rsp+8h] [rbp-70h]
struct timeval tv; // [rsp+10h] [rbp-68h] BYREF
struct timeval v14; // [rsp+20h] [rbp-58h] BYREF
unsigned __int64 v15; // [rsp+38h] [rbp-40h]

v3 = 0LL;
v15 = __readfsqword(0x28u);
v4 = sysconf(30);
v5 = 5 * v4;
v6 = v4;
signal(15, handle_sigterm);
v7 = 2 * v5;
gettimeofday(&tv, 0LL);
for ( i = 0LL; ; i = v11 )
{
do
{
while ( 1 )
{
v8 = malloc(v7);
if ( v8 )
break;
puts("malloc failed");
}
v9 = 10;
do
{
*v8 = -85;
v8 += v6;
--v9;
}
while ( v9 );
++v3;
}
while ( __ROR8__(0x1CAC083126E978D5LL * v3, 3) > 0x4189374BC6A7EFuLL );
v10 = v3 * v7 + 0xFFFFF;
if ( ((v3 * v7) & 0x8000000000000000LL) == 0LL )
v10 = v3 * v7;
v11 = v10 >> 20;
gettimeofday(&v14, 0LL);
printf(
"%4ld MiB (%4ld MiB/s)\n",
v11,
1000000 * (v11 - i) / (v14.tv_usec + 1000000 * (v14.tv_sec - tv.tv_sec) - tv.tv_usec));
gettimeofday(&tv, 0LL);
}
}

original_code:
int main()
{
    long page_size = sysconf(_SC_PAGESIZE);
    long bs = page_size * 10;
    long cnt = 0, last_sum = 0;
    struct timeval tv1;
    signal(15, handle_sigterm);
    gettimeofday(&tv1, ((void *)0));
    while (1) {
        char* p = malloc(bs);
        if (!p) {
            printf("malloc failed\n");
            continue;
        }
        for (int i = 0; i < 10; i++) {
            p[i * page_size] = 0xab;
        }
        cnt++;
        if (cnt % 1000 == 0) {
            long sum = bs * cnt / 1024 / 1024;
            struct timeval tv2;
            gettimeofday(&tv2, ((void *)0));
            long delta = tv2.tv_sec - tv1.tv_sec;
            delta *= 1000000;
            delta = delta + tv2.tv_usec - tv1.tv_usec;
            long mbps = (sum - last_sum) * 1000000 / delta;
            printf("%4ld MiB (%4ld MiB/s)\n", sum, mbps);
            last_sum = sum;
            gettimeofday(&tv1, ((void *)0));
        }
    }
}

canonical_original_code:
int main()
{
    long page_size = sysconf(_SC_PAGESIZE);
    long bs = page_size * 10;
    long cnt = 0; long last_sum = 0;
    struct timeval tv1;
    signal(15, handle_sigterm);
    gettimeofday(&tv1, ((void *)0));
    while (1) {
        char *p = malloc(bs);
        if (!p) {
            printf("malloc failed\n");
            continue;
        }
        for (int i = 0; i < 10; i++) {
            p[i * page_size] = 0xab;
        }
        cnt++;
        if (cnt % 1000 == 0) {
            long sum = bs * cnt / 1024 / 1024;
            struct timeval tv2;
            gettimeofday(&tv2, ((void *)0));
            long delta = tv2.tv_sec - tv1.tv_sec;
            delta *= 1000000;
            delta = delta + tv2.tv_usec - tv1.tv_usec;
            long mbps = (sum - last_sum) * 1000000 / delta;
            printf("%4ld MiB (%4ld MiB/s)\n", sum, mbps);
            last_sum = sum;
            gettimeofday(&tv1, ((void *)0));
        }
    }
}

variable_types: bs long

variable_types: cnt long

variable_types: struct timeval { long tv_sec; long tv_usec; }

variable_types:
p
char *

variable_types: sum long

variable_types: delta long

variable_types: mbps long


decompiled_code:
void __fastcall handle_sigterm(unsigned int a1)
{
printf("blocking SIGTERM %d\n", a1);
}

canonical_decompiled_code:
void __fastcall func7(unsigned int a1)
{
printf("blocking SIGTERM %d\n", a1);
}

original_code:
void handle_sigterm(int sig)
{
    printf("blocking SIGTERM %d\n", sig);
}

variable_types: sig int


randf

repo: rgharpuray/VoIP-opt

decompiled_code:
float randf()
{
return (float)rand() * 4.6566129e-10;
}

canonical_decompiled_code:
float func0()
{
return (float)rand() * 4.6566129e-10;
}

original_code:
float randf()
{
  return ((float)rand())/(float)2147483647;
}

return_type: float


randgaussian

decompiled_code:
float randgaussian()
{
float v0; // xmm0_4
double v1; // xmm0_8
float v2; // xmm0_4
double v4; // [rsp+8h] [rbp-10h]

v0 = randf();
v1 = (float)(logf(v0) * -2.0);
if ( v1 < 0.0 )
v4 = sqrt(v1);
else
v4 = sqrt(v1);
v2 = randf();
return cosf(v2 * 6.283185) * v4;
}

canonical_decompiled_code:
float func1()
{
float v0; // xmm0_4
double v1; // xmm0_8
float v2; // xmm0_4
double v4; // [rsp+8h] [rbp-10h]

v0 = func0();
v1 = (float)(logf(v0) * -2.0);
if ( v1 < 0.0 )
v4 = sqrt(v1);
else
v4 = sqrt(v1);
v2 = func0();
return cosf(v2 * 6.283185) * v4;
}

original_code:
float randgaussian()
{
  return sqrt(-2*logf(randf()))*cosf(2*pi*randf());
}


decompiled_code:
__int64 markov_transition()
{
float v0; // xmm0_4
__int64 result; // rax

v0 = randf();
if ( !nstates )
LABEL_6:
_assert_fail("0", "src/markov.c", 0x29u, "markov_transition");
result = 0LL;
while ( 1 )
{
v0 = v0 - *(float *)(transition_rates + 4LL * (unsigned int)(state * nstates) + 4 * result);
if ( v0 <= 0.0 )
break;
if ( ++result == nstates )
goto LABEL_6;
}
state = result;
return result;
}

canonical_decompiled_code:
__int64 func2()
{
float v0; // xmm0_4
__int64 result; // rax

v0 = func0();
if ( !nstates )
LABEL_6:
_assert_fail("0", "src/markov.c", 0x29u, "markov_transition");
result = 0LL;
while ( 1 )
{
v0 = v0 - *(float *)(transition_rates + 4LL * (unsigned int)(state * nstates) + 4 * result);
if ( v0 <= 0.0 )
break;
if ( ++result == nstates )
goto LABEL_6;
}
state = result;
return result;
}

original_code:
void markov_transition()
{
  float random = randf();
  float* ptr = &(transition_rates[nstates*state]);
  for(int i = 0; i < nstates; i++) {
    random -= ptr[i];
    if(random <= 0.0f) {
      state = i;
      return;
    }
  }
  ((void) sizeof ((0) ? 1 : 0), __extension__ ({ if (0) ; else __assert_fail ("0", "src/markov.c", 41, __extension__ __PRETTY_FUNCTION__); }));
}

canonical_original_code:
void markov_transition()
{
  float random = randf();
  float *ptr = &(transition_rates[nstates*state]);
  for(int i = 0; i < nstates; i++) {
    random -= ptr[i];
    if(random <= 0.0f) {
      state = i;
      return;
    }
  }
  ((void) sizeof ((0) ? 1 : 0), __extension__ ({ if (0) ; else __assert_fail ("0", "src/markov.c", 41, __extension__ __PRETTY_FUNCTION__); }));
}

variable_types: random float

variable_types:
ptr
float *

variable_types: i int


decompiled_code:
_BOOL8 markov_emission()
{
__int64 v0; // rbx

v0 = state;
if ( state < 0 || state >= (unsigned int)nstates )
_assert_fail("(state >= 0)&&(state < nstates)", "src/markov.c", 0x31u, "markov_emission");
return *(float *)(drop_rates + 4 * v0) > randf();
}

canonical_decompiled_code:
_BOOL8 func3()
{
__int64 v0; // rbx

v0 = state;
if ( state < 0 || state >= (unsigned int)nstates )
_assert_fail("(state >= 0)&&(state < nstates)", "src/markov.c", 0x31u, "markov_emission");
return *(float *)(drop_rates + 4 * v0) > func0();
}

canonical_original_code:
enum mmvalue markov_emission()
{
  ((void) sizeof (((state >= 0)&&(state < nstates)) ? 1 : 0), __extension__ ({ if ((state >= 0)&&(state < nstates)) ; else __assert_fail ("(state >= 0)&&(state < nstates)", "src/markov.c", 49, __extension__ __PRETTY_FUNCTION__); }));
  float random = randf();
  return (random < drop_rates[state]) ? MM_DROP : MM_ACCEPT;
}

return_type: enum mmvalue { MM_ACCEPT=0, MM_DROP=1 }


decompiled_code:
float *__fastcall markov_initmodel_lowhigh(float a1, float a2, float a3, float a4)
{
float *v4; // rax
float *result; // rax

nstates = 2;
v4 = (float *)malloc(8uLL);
drop_rates = (__int64)v4;
*v4 = a1;
v4[1] = a2;
result = (float *)malloc(0x10uLL);
state = 0;
transition_rates = (__int64)result;
result[1] = 1.0 / a3;
result[2] = 1.0 / a4;
*result = 1.0 - (float)(1.0 / a3);
result[3] = 1.0 - (float)(1.0 / a4);
return result;
}

canonical_decompiled_code:
float *__fastcall func4(float a1, float a2, float a3, float a4)
{
float *v4; // rax
float *result; // rax

nstates = 2;
v4 = (float *)malloc(8uLL);
drop_rates = (__int64)v4;
*v4 = a1;
v4[1] = a2;
result = (float *)malloc(0x10uLL);
state = 0;
transition_rates = (__int64)result;
result[1] = 1.0 / a3;
result[2] = 1.0 / a4;
*result = 1.0 - (float)(1.0 / a3);
result[3] = 1.0 - (float)(1.0 / a4);
return result;
}

original_code:
void markov_initmodel_lowhigh(float low_lr, float high_lr, float low_meanlength, float high_meanlength)
{
  nstates = 2;
  drop_rates = malloc(2*sizeof(float));
  drop_rates[0] = low_lr;
  drop_rates[1] = high_lr;
  transition_rates = malloc(4*sizeof(float));
  transition_rates[0] = 1.0f - 1.0f/low_meanlength;
  transition_rates[1] = 1.0f/low_meanlength;
  transition_rates[2] = 1.0f/high_meanlength;
  transition_rates[3] = 1.0f - 1.0f/high_meanlength;
  state = 0;
}


original_code:
static void skip_string(void)
{
  while (*p)
    p++;
  p++;
}

canonical_original_code:
static void skip_string()
{
  while (*p)
    p++;
  p++;
}


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

result = "WEAK";
if ( (a1 & 0x40) == 0 )
{
result = "GLOB";
if ( (a1 & 8) == 0 )
{
result = "LOCL";
if ( (a1 & 0x20) != 0 )
result = "COMM";
}
}
return result;
}

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

result = "WEAK";
if ( (a1 & 0x40) == 0 )
{
result = "GLOB";
if ( (a1 & 8) == 0 )
{
result = "LOCL";
if ( (a1 & 0x20) != 0 )
result = "COMM";
}
}
return result;
}

original_code:
static const char *bind_name(int flags)
{
  if (flags & 64)
    return "WEAK";
  if (flags & 8)
    return "GLOB";
  if (flags & 32)
    return "COMM";
  return "LOCL";
}

canonical_original_code:
static char *bind_name(int flags)
{
  if (flags & 64)
    return "WEAK";
  if (flags & 8)
    return "GLOB";
  if (flags & 32)
    return "COMM";
  return "LOCL";
}

variable_types: flags int

return_type: char *


decompiled_code:
const char *__fastcall def_name(__int64 a1, __int64 a2, int a3)
{
int v4; // edx
const char *result; // rax
__int64 v6; // rax

v4 = *(_DWORD *)(a1 + 16);
result = "*UND*";
if ( v4 != 2 )
{
result = "*ABS*";
if ( v4 != 3 )
{
result = "???";
if ( v4 == 1 )
{
v6 = *(int *)(a1 + 24);
if ( (int)v6 > 0 && (int)v6 <= a3 )
result = *(const char **)(a2 + 32 * v6 - 24);
else
result = "???";
}
}
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func2(__int64 a1, __int64 a2, int a3)
{
int v4; // edx
const char *result; // rax
__int64 v6; // rax

v4 = *(_DWORD *)(a1 + 16);
result = "*UND*";
if ( v4 != 2 )
{
result = "*ABS*";
if ( v4 != 3 )
{
result = "???";
if ( v4 == 1 )
{
v6 = *(int *)(a1 + 24);
if ( (int)v6 > 0 && (int)v6 <= a3 )
result = *(const char **)(a2 + 32 * v6 - 24);
else
result = "???";
}
}
}
return result;
}

original_code:
static const char *def_name(struct vobj_symbol *vs,
                            struct vobj_section *sec,int nsecs)
{
  switch (vs->type) {
    case 3:
      return "*ABS*";
    case 2:
      return "*UND*";
    case 1:
      if (vs->sec>0 && vs->sec<=nsecs)
        return sec[vs->sec-1].name;
  }
  return "???";
}

canonical_original_code:
static char *def_name(struct vobj_symbol *vs, struct vobj_section *sec, int nsecs)
{
  switch (vs->type) {
    case 3:
      return "*ABS*";
    case 2:
      return "*UND*";
    case 1:
      if (vs->sec>0 && vs->sec<=nsecs)
        return sec[vs->sec-1].name;
  }
  return "???";
}

variable_types: struct vobj_symbol { unsigned long offs; char *name; int type; long val; } *

variable_types: struct vobj_section { unsigned long offs; char *name; long dsize; } *

variable_types: nsecs int


decompiled_code:
__int64 __fastcall read_number(int a1)
{
__int64 v1; // rax
char v2; // dl
__int64 v3; // r8
unsigned __int8 v4; // si
__int64 v5; // rax
unsigned __int64 v6; // rdx
__int64 v7; // rcx
int v8; // ecx

if ( p >= (unsigned __int64)vobj + vlen )
{
fwrite("\nObject file is corrupt! Aborting.\n", 1uLL, 0x23uLL, stderr);
exit(1);
}
v1 = p + 1;
v2 = *(_BYTE *)p++;
v3 = (unsigned __int8)v2;
if ( v2 < 0 )
{
v3 = 0LL;
v4 = v2 + 0x80;
if ( v2 != (char)0x80 )
{
v5 = v4 + v1;
p = v5;
v6 = v5 + ~(unsigned __int64)(unsigned __int8)(v2 + 127);
do
{
v7 = *(unsigned __int8 *)--v5;
v3 = v7 | (v3 << 8);
}
while ( v6 != v5 );
if ( a1 )
{
v8 = 8 * v4;
if ( _bittest64(&v3, (unsigned int)(v8 - 1)) )
v3 |= -1LL << v8;
}
}
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func5(int a1)
{
__int64 v1; // rax
char v2; // dl
__int64 v3; // r8
unsigned __int8 v4; // si
__int64 v5; // rax
unsigned __int64 v6; // rdx
__int64 v7; // rcx
int v8; // ecx

if ( p >= (unsigned __int64)vobj + vlen )
{
fwrite("\nObject file is corrupt! Aborting.\n", 1uLL, 0x23uLL, stderr);
exit(1);
}
v1 = p + 1;
v2 = *(_BYTE *)p++;
v3 = (unsigned __int8)v2;
if ( v2 < 0 )
{
v3 = 0LL;
v4 = v2 + 0x80;
if ( v2 != (char)0x80 )
{
v5 = v4 + v1;
p = v5;
v6 = v5 + ~(unsigned __int64)(unsigned __int8)(v2 + 127);
do
{
v7 = *(unsigned __int8 *)--v5;
v3 = v7 | (v3 << 8);
}
while ( v6 != v5 );
if ( a1 )
{
v8 = 8 * v4;
if ( _bittest64(&v3, (unsigned int)(v8 - 1)) )
v3 |= -1LL << v8;
}
}
}
return v3;
}

original_code:
static taddr read_number(int is_signed)
{
  taddr val;
  ubyte n,*q;
  int size;
  if (p >= vobj+vlen) {
    fprintf(stderr,"\nObject file is corrupt! Aborting.\n");
    exit(1);
  }
  if ((n = *p++) <= 0x7f)
    return (taddr)n;
  val = 0;
  if (n -= 0x80) {
    size = n << 3;
    p += n;
    q = p;
    while (n--)
      val = (val<<8) | *(--q);
    if (is_signed && (val & (1LL<<(size-1))))
      val |= ~((taddr)(1LL<<(size))-1);
  }
  return val;
}

canonical_original_code:
static long read_number(int is_signed)
{
  long val;
  unsigned char n; unsigned char *q;
  int size;
  if (p >= vobj+vlen) {
    fprintf(stderr,"\nObject file is corrupt! Aborting.\n");
    exit(1);
  }
  if ((n = *p++) <= 0x7f)
    return (long)n;
  val = 0;
  if (n -= 0x80) {
    size = n << 3;
    p += n;
    q = p;
    while (n--)
      val = (val<<8) | *(--q);
    if (is_signed && (val & (1LL<<(size-1))))
      val |= ~((taddr)(1LL<<(size))-1);
  }
  return val;
}

variable_types: val long

variable_types:
n
unsigned char

variable_types:
q
unsigned char *

variable_types: size int

return_type: long


decompiled_code:
__int64 __fastcall read_symbol(__int64 a1)
{
__int64 v1; // rdx
__int64 result; // rax

v1 = p - (_QWORD)vobj;
*(_QWORD *)(a1 + 8) = p;
*(_QWORD *)a1 = v1;
skip_string();
*(_DWORD *)(a1 + 16) = read_number(0);
*(_DWORD *)(a1 + 20) = read_number(0);
*(_DWORD *)(a1 + 24) = read_number(0);
*(_QWORD *)(a1 + 32) = read_number(1);
result = read_number(0);
*(_DWORD *)(a1 + 28) = result;
return result;
}

original_code:
static void read_symbol(struct vobj_symbol *vsym)
{
  vsym->offs = p - vobj;
  vsym->name = (const char *)p;
  skip_string();
  vsym->type = (int)read_number(0);
  vsym->flags = (int)read_number(0);
  vsym->sec = (int)read_number(0);
  vsym->val = read_number(1);
  vsym->size = (int)read_number(0);
}

canonical_original_code:
static void read_symbol(struct vobj_symbol *vsym)
{
  vsym->offs = p - vobj;
  vsym->name = (char *)p;
  skip_string();
  vsym->type = (int)read_number(0);
  vsym->flags = (int)read_number(0);
  vsym->sec = (int)read_number(0);
  vsym->val = read_number(1);
  vsym->size = (int)read_number(0);
}

user_defined_types: struct vobj_symbol { unsigned long offs; char *name; int type; long val; }


decompiled_code:
int __fastcall read_section(__int64 *a1, __int64 a2, int a3)
{
__int64 v4; // rdx
__int64 v5; // r13
unsigned int v6; // er12
__int64 v7; // rax
int v8; // ebx
unsigned __int8 v9; // r15
__int64 v10; // r14
int v11; // er12
int v12; // er13
__int64 v13; // rsi
__int64 v14; // rax
int v15; // eax
__int64 v16; // rcx
const void *v17; // r11
__int64 v18; // rax
int v20; // [rsp-10h] [rbp-68h]
const char *v21; // [rsp+0h] [rbp-58h]
__int64 v22; // [rsp+0h] [rbp-58h]
__int64 v23; // [rsp+8h] [rbp-50h]
int v24; // [rsp+10h] [rbp-48h]

v4 = p - (_QWORD)vobj;
a1[1] = p;
*a1 = v4;
skip_string();
v21 = (const char *)p;
skip_string();
v5 = read_number(0);
v6 = read_number(0);
a1[2] = read_number(0);
v24 = read_number(0);
a1[3] = read_number(0);
print_sep();
printf(
"%08llx: SECTION \"%s\" (attributes=\"%s\")\nFlags: %-8lx Alignment: %-6d Total size: %-9lld File size: %-9lld\n",
bptmask & *a1,
(const char *)a1[1],
v21,
v5,
v6,
a1[2],
a1[3]);
if ( v24 )
{
if ( v24 == 1 )
{
printf("%d Relocation%s present.\n", 1LL, emptystr);
p += a1[3];
}
else
{
printf("%d Relocation%s present.\n", (unsigned int)v24, "s");
v7 = a1[3];
p += v7;
if ( v24 <= 0 )
return v7;
}
v8 = 0;
LABEL_21:
puts("\nfile offs sectoffs pos sz mask type symbol+addend");
while ( 1 )
{
printf("%08llx: ", bptmask & (p - (_QWORD)vobj));
v9 = read_number(0);
if ( v9 > 0x11u )
{
v18 = read_number(0);
p += v18;
LODWORD(v7) = printf("special relocation type %-3d with a size of %d bytes\n", v9, v18);
}
else
{
v10 = read_number(0);
v11 = read_number(0);
v12 = read_number(0);
v22 = read_number(1);
v23 = read_number(1);
v13 = read_number(0);
v14 = v10 + (v11 >> 3);
if ( v10 < 0 || v14 >= a1[2] )
{
LODWORD(v7) = printf("offset 0x%llx is outside of section!\n", bptmask & v14);
}
else
{
v15 = v13 - 1;
if ( (int)v13 - 1 < 0 || v15 >= a3 )
{
LODWORD(v7) = printf("symbol index %d is illegal!\n", v13);
}
else if ( v12 < 0 || (v16 = (unsigned int)(bpb * bpt), (int)v16 < v12) )
{
LODWORD(v7) = printf("size of %d bits is illegal!\n", (unsigned int)v12);
}
else if ( v11 < 0 || (int)v16 < v12 + v11 )
{
LODWORD(v7) = printf(
"bit field start=%d, size=%d doesn't fit into target address type (%d bits)!\n",
(unsigned int)v11,
(unsigned int)v12,
v16);
}
else
{
v17 = *(const void **)(a2 + 40LL * v15 + 8);
if ( !memcmp(v17, " *current pc", 0xCuLL) )
v17 = (const void *)a1[1];
printf(
"%08llx %02d %02d %8llx %-8s %s%+lld\n",
v10 & bptmask,
(unsigned int)v11,
(unsigned int)v12,
bptmask & v22,
reloc_name[v9],
(const char *)v17,
v23);
LODWORD(v7) = v20;
}
}
}
if ( v24 == ++v8 )
break;
if ( !v8 )
goto LABEL_21;
}
}
else
{
v7 = a1[3];
p += v7;
}
return v7;
}

canonical_decompiled_code:
int __fastcall func7(__int64 *a1, __int64 a2, int a3)
{
__int64 v4; // rdx
__int64 v5; // r13
unsigned int v6; // er12
__int64 v7; // rax
int v8; // ebx
unsigned __int8 v9; // r15
__int64 v10; // r14
int v11; // er12
int v12; // er13
__int64 v13; // rsi
__int64 v14; // rax
int v15; // eax
__int64 v16; // rcx
const void *v17; // r11
__int64 v18; // rax
int v20; // [rsp-10h] [rbp-68h]
const char *v21; // [rsp+0h] [rbp-58h]
__int64 v22; // [rsp+0h] [rbp-58h]
__int64 v23; // [rsp+8h] [rbp-50h]
int v24; // [rsp+10h] [rbp-48h]

v4 = p - (_QWORD)vobj;
a1[1] = p;
*a1 = v4;
func0();
v21 = (const char *)p;
func0();
v5 = func5(0);
v6 = func5(0);
a1[2] = func5(0);
v24 = func5(0);
a1[3] = func5(0);
func4();
printf(
"%08llx: SECTION \"%s\" (attributes=\"%s\")\nFlags: %-8lx Alignment: %-6d Total size: %-9lld File size: %-9lld\n",
bptmask & *a1,
(const char *)a1[1],
v21,
v5,
v6,
a1[2],
a1[3]);
if ( v24 )
{
if ( v24 == 1 )
{
printf("%d Relocation%s present.\n", 1LL, emptystr);
p += a1[3];
}
else
{
printf("%d Relocation%s present.\n", (unsigned int)v24, "s");
v7 = a1[3];
p += v7;
if ( v24 <= 0 )
return v7;
}
v8 = 0;
LABEL_21:
puts("\nfile offs sectoffs pos sz mask type symbol+addend");
while ( 1 )
{
printf("%08llx: ", bptmask & (p - (_QWORD)vobj));
v9 = func5(0);
if ( v9 > 0x11u )
{
v18 = func5(0);
p += v18;
LODWORD(v7) = printf("special relocation type %-3d with a size of %d bytes\n", v9, v18);
}
else
{
v10 = func5(0);
v11 = func5(0);
v12 = func5(0);
v22 = func5(1);
v23 = func5(1);
v13 = func5(0);
v14 = v10 + (v11 >> 3);
if ( v10 < 0 || v14 >= a1[2] )
{
LODWORD(v7) = printf("offset 0x%llx is outside of section!\n", bptmask & v14);
}
else
{
v15 = v13 - 1;
if ( (int)v13 - 1 < 0 || v15 >= a3 )
{
LODWORD(v7) = printf("symbol index %d is illegal!\n", v13);
}
else if ( v12 < 0 || (v16 = (unsigned int)(bpb * bpt), (int)v16 < v12) )
{
LODWORD(v7) = printf("size of %d bits is illegal!\n", (unsigned int)v12);
}
else if ( v11 < 0 || (int)v16 < v12 + v11 )
{
LODWORD(v7) = printf(
"bit field start=%d, size=%d doesn't fit into target address type (%d bits)!\n",
(unsigned int)v11,
(unsigned int)v12,
v16);
}
else
{
v17 = *(const void **)(a2 + 40LL * v15 + 8);
if ( !memcmp(v17, " *current pc", 0xCuLL) )
v17 = (const void *)a1[1];
printf(
"%08llx %02d %02d %8llx %-8s %s%+lld\n",
v10 & bptmask,
(unsigned int)v11,
(unsigned int)v12,
bptmask & v22,
reloc_name[v9],
(const char *)v17,
v23);
LODWORD(v7) = v20;
}
}
}
if ( v24 == ++v8 )
break;
if ( !v8 )
goto LABEL_21;
}
}
else
{
v7 = a1[3];
p += v7;
}
return v7;
}

original_code:
static void read_section(struct vobj_section *vsect,
                         struct vobj_symbol *vsym,int nsyms)
{
  const char *attr;
  unsigned long flags;
  int align,nrelocs,i;
  vsect->offs = p - vobj;
  vsect->name = p;
  skip_string();
  attr = p;
  skip_string();
  flags = (unsigned long)read_number(0);
  align = (int)read_number(0);
  vsect->dsize = read_number(0);
  nrelocs = (int)read_number(0);
  vsect->fsize = read_number(0);
  print_sep();
  printf("%08llx: SECTION \"%s\" (attributes=\"%s\")\n"
         "Flags: %-8lx  Alignment: %-6d "
         "Total size: %-9lld File size: %-9lld\n",
         (unsigned long long)((vsect->offs)&bptmask),vsect->name,attr,flags,align,
         vsect->dsize,vsect->fsize);
  if (nrelocs)
    printf("%d Relocation%s present.\n",nrelocs,nrelocs==1?emptystr:sstr);
  p += vsect->fsize;
  for (i=0; i<nrelocs; i++) {
    ubyte type;
    if (i == 0) {
      printf("\nfile offs sectoffs pos sz mask     type     symbol+addend\n");
    }
    printf("%08llx: ",(unsigned long long)((p-vobj)&bptmask));
    type = (ubyte)read_number(0);
    if (type<sizeof(reloc_name)/sizeof(reloc_name[0])) {
      taddr offs,mask,addend;
      int bpos,bsiz,sym;
      const char *basesym;
      offs = read_number(0);
      bpos = (int)read_number(0);
      bsiz = (int)read_number(0);
      mask = read_number(1);
      addend = read_number(1);
      sym = (int)read_number(0) - 1;
      if (offs<0 || offs+(bpos>>3)>=vsect->dsize) {
        printf("offset 0x%llx is outside of section!\n",
               (unsigned long long)((offs+(bpos>>3))&bptmask));
        continue;
      }
      if (sym<0 || sym>=nsyms) {
        printf("symbol index %d is illegal!\n",sym+1);
        continue;
      }
      if (bsiz<0 || bsiz>bpt*bpb) {
        printf("size of %d bits is illegal!\n",bsiz);
        continue;
      }
      if (bpos<0 || bpos+bsiz>bpt*bpb) {
        printf("bit field start=%d, size=%d doesn't fit into target address "
               "type (%d bits)!\n",bpos,bsiz,bpt*bpb);
        continue;
      }
      basesym = vsym[sym].name;
      if (!strncmp(basesym," *current pc",12)) {
        basesym = vsect->name;
      }
      printf("%08llx  %02d %02d %8llx %-8s %s%+lld\n",
             (unsigned long long)((offs)&bptmask),bpos,bsiz,(unsigned long long)((mask)&bptmask),
             reloc_name[type],basesym,addend);
    }
    else {
      taddr rsize;
      rsize = read_number(0);
      p += rsize;
      printf("special relocation type %-3d with a size of %d bytes\n",
             (int)type,(int)rsize);
    }
  }
}

canonical_original_code:
static void read_section(struct vobj_section *vsect, struct vobj_symbol *vsym, int nsyms)
{
  char *attr;
  unsigned long flags;
  int align; int nrelocs; int i;
  vsect->offs = p - vobj;
  vsect->name = p;
  skip_string();
  attr = p;
  skip_string();
  flags = (unsigned long)read_number(0);
  align = (int)read_number(0);
  vsect->dsize = read_number(0);
  nrelocs = (int)read_number(0);
  vsect->fsize = read_number(0);
  print_sep();
  printf("%08llx: SECTION \"%s\" (attributes=\"%s\")\n"
         "Flags: %-8lx  Alignment: %-6d "
         "Total size: %-9lld File size: %-9lld\n",
         (unsigned long long)((vsect->offs)&bptmask),vsect->name,attr,flags,align,
         vsect->dsize,vsect->fsize);
  if (nrelocs)
    printf("%d Relocation%s present.\n",nrelocs,nrelocs==1?emptystr:sstr);
  p += vsect->fsize;
  for (i=0; i<nrelocs; i++) {
    unsigned char type;
    if (i == 0) {
      printf("\nfile offs sectoffs pos sz mask     type     symbol+addend\n");
    }
    printf("%08llx: ",(unsigned long long)((p-vobj)&bptmask));
    type = (unsigned char)read_number(0);
    if (type<sizeof(reloc_name)/sizeof(reloc_name[0])) {
      long offs; long mask; long addend;
      int bpos; int bsiz; int sym;
      char *basesym;
      offs = read_number(0);
      bpos = (int)read_number(0);
      bsiz = (int)read_number(0);
      mask = read_number(1);
      addend = read_number(1);
      sym = (int)read_number(0) - 1;
      if (offs<0 || offs+(bpos>>3)>=vsect->dsize) {
        printf("offset 0x%llx is outside of section!\n",
               (unsigned long long)((offs+(bpos>>3))&bptmask));
        continue;
      }
      if (sym<0 || sym>=nsyms) {
        printf("symbol index %d is illegal!\n",sym+1);
        continue;
      }
      if (bsiz<0 || bsiz>bpt*bpb) {
        printf("size of %d bits is illegal!\n",bsiz);
        continue;
      }
      if (bpos<0 || bpos+bsiz>bpt*bpb) {
        printf("bit field start=%d, size=%d doesn't fit into target address "
               "type (%d bits)!\n",bpos,bsiz,bpt*bpb);
        continue;
      }
      basesym = vsym[sym].name;
      if (!strncmp(basesym," *current pc",12)) {
        basesym = vsect->name;
      }
      printf("%08llx  %02d %02d %8llx %-8s %s%+lld\n",
             (unsigned long long)((offs)&bptmask),bpos,bsiz,(unsigned long long)((mask)&bptmask),
             reloc_name[type],basesym,addend);
    }
    else {
      long rsize;
      rsize = read_number(0);
      p += rsize;
      printf("special relocation type %-3d with a size of %d bytes\n",
             (int)type,(int)rsize);
    }
  }
}

variable_types: nsyms int

variable_types:
attr
char *

variable_types:
flags
unsigned long

variable_types: align int

variable_types: nrelocs int

variable_types:
type
unsigned char

variable_types: offs long

variable_types: mask long

variable_types: addend long

variable_types: bpos int

variable_types: bsiz int

variable_types: sym int

variable_types:
basesym
char *

variable_types: rsize long

user_defined_types: struct vobj_section { unsigned long offs; char *name; long dsize; }


vobjdump

decompiled_code:
__int64 vobjdump()
{
__int64 result; // rax
__int64 v1; // rdx
int v2; // ebx
unsigned int v3; // eax
const char *v4; // r15
__int64 v5; // rbp
int v6; // er14
int v7; // er13
int v8; // er12
const char *v9; // rax
const char *v10; // rdx
__int64 v11; // rbx
__int64 v12; // r15
__int64 v13; // rbp
size_t v14; // r15
__int64 *v15; // r13
__int64 v16; // rdi
int j; // ebp
const char *v18; // r15
const char *v19; // rax
__int64 v20; // r8
__int64 v21; // rcx
const char *v22; // r9
size_t v23; // r13
char *v24; // rax
char *v25; // r15
int i; // er13
__int64 v27; // rdi

p = (__int64)vobj;
if ( (unsigned __int64)vlen <= 4
|| *(_BYTE *)vobj != 86
|| *((_BYTE *)vobj + 1) != 79
|| *((_BYTE *)vobj + 2) != 66
|| *((_BYTE *)vobj + 3) != 74 )
{
fwrite("Not a VOBJ file!\n", 1uLL, 0x11uLL, stderr);
return 1LL;
}
p = (__int64)vobj + 5;
v1 = *((unsigned __int8 *)vobj + 4);
v2 = v1 - 1;
if ( (unsigned int)(v1 - 1) > 1 )
{
fprintf(stderr, "Wrong endianess: %d\n", v1);
return 1LL;
}
v3 = read_number(0);
bpb = v3;
if ( v3 != 8 )
{
fprintf(stderr, "%d bits per byte not supported!\n", v3);
return 1LL;
}
bpt = read_number(0);
if ( (unsigned int)bpt > 8 )
{
fprintf(stderr, "%d bytes per taddr not supported!\n", (unsigned int)bpt);
return 1LL;
}
v4 = (const char *)p;
bptmask = (1LL << ((unsigned __int8)bpb * (unsigned __int8)bpt)) - 1;
skip_string();
v5 = read_number(0);
v6 = v5;
v7 = read_number(0);
v8 = v7;
print_sep();
v9 = emptystr;
if ( (_DWORD)v5 != 1 )
v9 = "s";
v10 = endian_name[v2];
if ( v7 == 1 )
{
printf(
"VOBJ %s (%s endian), %d bits per byte, %d bytes per word.\n%d symbol%s.\n%d section%s.\n",
v4,
v10,
(unsigned int)bpb,
(unsigned int)bpt,
1LL,
emptystr,
v5,
v9);
}
else
{
v11 = 0LL;
printf(
"VOBJ %s (%s endian), %d bits per byte, %d bytes per word.\n%d symbol%s.\n%d section%s.\n",
v4,
v10,
(unsigned int)bpb,
(unsigned int)bpt,
(unsigned int)v7,
"s",
v5,
v9);
if ( !v7 )
goto LABEL_16;
}
v23 = 40LL * v7;
v24 = (char *)malloc(v23);
v11 = (__int64)v24;
if ( !v24 )
{
fprintf(stderr, "Cannot allocate %ld bytes for symbols!\n", v23);
return 1LL;
}
v25 = v24;
for ( i = 0; i < v8; ++i )
{
v27 = (__int64)v25;
v25 += 40;
read_symbol(v27);
}
LABEL_16:
v12 = (int)v5;
v13 = 0LL;
v14 = 32 * v12;
v15 = (__int64 *)malloc(v14);
if ( v15 )
{
while ( v6 > (int)v13 )
{
v16 = v13++;
read_section(&v15[4 * v16], v11, v8);
}
for ( j = 0; j < v8; ++j )
{
if ( !j )
{
putchar(10);
print_sep();
puts("SYMBOL TABLE\nfile offs bind size type def value name");
}
v18 = *(const char **)(v11 + 8);
if ( strncmp(v18, " *current pc", 0xCuLL) )
{
def_name(v11, (__int64)v15, v6);
v19 = bind_name(*(_DWORD *)(v11 + 20));
printf(
"%08llx: %-4s %08x %-4s %8.8s %8llx %s\n",
v20 & *(_QWORD *)v11,
v19,
*(unsigned int *)(v11 + 28),
(const char *)*(&type_name + v21),
v22,
*(_QWORD *)(v11 + 32) & v20,
v18);
}
v11 += 40LL;
}
result = 0LL;
}
else
{
fprintf(stderr, "Cannot allocate %ld bytes for sections!\n", v14);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 func8()
{
__int64 result; // rax
__int64 v1; // rdx
int v2; // ebx
unsigned int v3; // eax
const char *v4; // r15
__int64 v5; // rbp
int v6; // er14
int v7; // er13
int v8; // er12
const char *v9; // rax
const char *v10; // rdx
__int64 v11; // rbx
__int64 v12; // r15
__int64 v13; // rbp
size_t v14; // r15
__int64 *v15; // r13
__int64 v16; // rdi
int j; // ebp
const char *v18; // r15
const char *v19; // rax
__int64 v20; // r8
__int64 v21; // rcx
const char *v22; // r9
size_t v23; // r13
char *v24; // rax
char *v25; // r15
int i; // er13
__int64 v27; // rdi

p = (__int64)vobj;
if ( (unsigned __int64)vlen <= 4
|| *(_BYTE *)vobj != 86
|| *((_BYTE *)vobj + 1) != 79
|| *((_BYTE *)vobj + 2) != 66
|| *((_BYTE *)vobj + 3) != 74 )
{
fwrite("Not a VOBJ file!\n", 1uLL, 0x11uLL, stderr);
return 1LL;
}
p = (__int64)vobj + 5;
v1 = *((unsigned __int8 *)vobj + 4);
v2 = v1 - 1;
if ( (unsigned int)(v1 - 1) > 1 )
{
fprintf(stderr, "Wrong endianess: %d\n", v1);
return 1LL;
}
v3 = func5(0);
bpb = v3;
if ( v3 != 8 )
{
fprintf(stderr, "%d bits per byte not supported!\n", v3);
return 1LL;
}
bpt = func5(0);
if ( (unsigned int)bpt > 8 )
{
fprintf(stderr, "%d bytes per taddr not supported!\n", (unsigned int)bpt);
return 1LL;
}
v4 = (const char *)p;
bptmask = (1LL << ((unsigned __int8)bpb * (unsigned __int8)bpt)) - 1;
func0();
v5 = func5(0);
v6 = v5;
v7 = func5(0);
v8 = v7;
func4();
v9 = emptystr;
if ( (_DWORD)v5 != 1 )
v9 = "s";
v10 = endian_name[v2];
if ( v7 == 1 )
{
printf(
"VOBJ %s (%s endian), %d bits per byte, %d bytes per word.\n%d symbol%s.\n%d section%s.\n",
v4,
v10,
(unsigned int)bpb,
(unsigned int)bpt,
1LL,
emptystr,
v5,
v9);
}
else
{
v11 = 0LL;
printf(
"VOBJ %s (%s endian), %d bits per byte, %d bytes per word.\n%d symbol%s.\n%d section%s.\n",
v4,
v10,
(unsigned int)bpb,
(unsigned int)bpt,
(unsigned int)v7,
"s",
v5,
v9);
if ( !v7 )
goto LABEL_16;
}
v23 = 40LL * v7;
v24 = (char *)malloc(v23);
v11 = (__int64)v24;
if ( !v24 )
{
fprintf(stderr, "Cannot allocate %ld bytes for symbols!\n", v23);
return 1LL;
}
v25 = v24;
for ( i = 0; i < v8; ++i )
{
v27 = (__int64)v25;
v25 += 40;
func6(v27);
}
LABEL_16:
v12 = (int)v5;
v13 = 0LL;
v14 = 32 * v12;
v15 = (__int64 *)malloc(v14);
if ( v15 )
{
while ( v6 > (int)v13 )
{
v16 = v13++;
func7(&v15[4 * v16], v11, v8);
}
for ( j = 0; j < v8; ++j )
{
if ( !j )
{
putchar(10);
func4();
puts("SYMBOL TABLE\nfile offs bind size type def value name");
}
v18 = *(const char **)(v11 + 8);
if ( strncmp(v18, " *current pc", 0xCuLL) )
{
func2(v11, (__int64)v15, v6);
v19 = func1(*(_DWORD *)(v11 + 20));
printf(
"%08llx: %-4s %08x %-4s %8.8s %8llx %s\n",
v20 & *(_QWORD *)v11,
v19,
*(unsigned int *)(v11 + 28),
(const char *)*(&type_name + v21),
v22,
*(_QWORD *)(v11 + 32) & v20,
v18);
}
v11 += 40LL;
}
result = 0LL;
}
else
{
fprintf(stderr, "Cannot allocate %ld bytes for sections!\n", v14);
result = 1LL;
}
return result;
}

original_code:
static int vobjdump(void)
{
  p = vobj;
  if (vlen>4 && p[0]==0x56 && p[1]==0x4f && p[2]==0x42 && p[3]==0x4a) {
    int endian,nsecs,nsyms,i;
    const char *cpu_name;
    struct vobj_symbol *vsymbols = ((void *)0);
    struct vobj_section *vsect = ((void *)0);
    p += 4;
    endian = (int)*p++;
    if (endian<1 || endian>2) {
      fprintf(stderr,"Wrong endianess: %d\n",endian);
      return 1;
    }
    bpb = (int)read_number(0);
    if (bpb != 8) {
      fprintf(stderr,"%d bits per byte not supported!\n",bpb);
      return 1;
    }
    bpt = (int)read_number(0);
    if (bpt > sizeof(taddr)) {
      fprintf(stderr,"%d bytes per taddr not supported!\n",bpt);
      return 1;
    }
    bptmask = ((taddr)(1LL<<(bpt*bpb))-1);
    cpu_name = p;
    skip_string();
    nsecs = (int)read_number(0);
    nsyms = (int)read_number(0);
    print_sep();
    printf("VOBJ %s (%s endian), %d bits per byte, %d bytes per word.\n"
           "%d symbol%s.\n%d section%s.\n",
           cpu_name,endian_name[endian-1],bpb,bpt,
           nsyms,nsyms==1?emptystr:sstr,nsecs,nsecs==1?emptystr:sstr);
    if (nsyms) {
      if (vsymbols = malloc(nsyms * sizeof(struct vobj_symbol))) {
        for (i=0; i<nsyms; i++)
          read_symbol(&vsymbols[i]);
      }
      else {
        fprintf(stderr,"Cannot allocate %ld bytes for symbols!\n",
                (long)(nsyms * sizeof(struct vobj_symbol)));
        return 1;
      }
    }
    if (vsect = malloc(nsecs * sizeof(struct vobj_section))) {
      for (i=0; i<nsecs; i++)
        read_section(&vsect[i],vsymbols,nsyms);
    }
    else {
      fprintf(stderr,"Cannot allocate %ld bytes for sections!\n",
              (long)(nsecs * sizeof(struct vobj_section)));
      return 1;
    }
    for (i=0; i<nsyms; i++) {
      struct vobj_symbol *vs = &vsymbols[i];
      if (i == 0) {
        printf("\n");
        print_sep();
        printf("SYMBOL TABLE\n"
               "file offs bind size     type def      value    name\n");
      }
      if (!strncmp(vs->name," *current pc",12))
        continue;
      printf("%08llx: %-4s %08x %-4s %8.8s %8llx %s\n",
             (unsigned long long)((vs->offs)&bptmask),bind_name(vs->flags),(unsigned)vs->size,
             type_name[((vs)->flags&7)],def_name(vs,vsect,nsecs),
             (unsigned long long)((vs->val)&bptmask),vs->name);
    }
  }
  else {
    fprintf(stderr,"Not a VOBJ file!\n");
    return 1;
  }
  return 0;
}

canonical_original_code:
static int vobjdump()
{
  p = vobj;
  if (vlen>4 && p[0]==0x56 && p[1]==0x4f && p[2]==0x42 && p[3]==0x4a) {
    int endian; int nsecs; int nsyms; int i;
    char *cpu_name;
    struct vobj_symbol *vsymbols = ((void *)0);
    struct vobj_section *vsect = ((void *)0);
    p += 4;
    endian = (int)*p++;
    if (endian<1 || endian>2) {
      fprintf(stderr,"Wrong endianess: %d\n",endian);
      return 1;
    }
    bpb = (int)read_number(0);
    if (bpb != 8) {
      fprintf(stderr,"%d bits per byte not supported!\n",bpb);
      return 1;
    }
    bpt = (int)read_number(0);
    if (bpt > sizeof(taddr)) {
      fprintf(stderr,"%d bytes per taddr not supported!\n",bpt);
      return 1;
    }
    bptmask = ((taddr)(1LL<<(bpt*bpb))-1);
    cpu_name = p;
    skip_string();
    nsecs = (int)read_number(0);
    nsyms = (int)read_number(0);
    print_sep();
    printf("VOBJ %s (%s endian), %d bits per byte, %d bytes per word.\n"
           "%d symbol%s.\n%d section%s.\n",
           cpu_name,endian_name[endian-1],bpb,bpt,
           nsyms,nsyms==1?emptystr:sstr,nsecs,nsecs==1?emptystr:sstr);
    if (nsyms) {
      if (vsymbols = malloc(nsyms * sizeof(struct vobj_symbol))) {
        for (i=0; i<nsyms; i++)
          read_symbol(&vsymbols[i]);
      }
      else {
        fprintf(stderr,"Cannot allocate %ld bytes for symbols!\n",
                (long)(nsyms * sizeof(struct vobj_symbol)));
        return 1;
      }
    }
    if (vsect = malloc(nsecs * sizeof(struct vobj_section))) {
      for (i=0; i<nsecs; i++)
        read_section(&vsect[i],vsymbols,nsyms);
    }
    else {
      fprintf(stderr,"Cannot allocate %ld bytes for sections!\n",
              (long)(nsecs * sizeof(struct vobj_section)));
      return 1;
    }
    for (i=0; i<nsyms; i++) {
      struct vobj_symbol *vs = &vsymbols[i];
      if (i == 0) {
        printf("\n");
        print_sep();
        printf("SYMBOL TABLE\n"
               "file offs bind size     type def      value    name\n");
      }
      if (!strncmp(vs->name," *current pc",12))
        continue;
      printf("%08llx: %-4s %08x %-4s %8.8s %8llx %s\n",
             (unsigned long long)((vs->offs)&bptmask),bind_name(vs->flags),(unsigned int)vs->size,
             type_name[((vs)->flags&7)],def_name(vs,vsect,nsecs),
             (unsigned long long)((vs->val)&bptmask),vs->name);
    }
  }
  else {
    fprintf(stderr,"Not a VOBJ file!\n");
    return 1;
  }
  return 0;
}

variable_types: endian int

variable_types: nsecs int

variable_types: i int

variable_types: struct vobj_symbol { unsigned long offs; char *name; int type; long val; } *

variable_types: struct vobj_section { unsigned long offs; char *name; long dsize; } *


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebp
unsigned int v4; // eax
unsigned int v5; // ebx

v3 = 0;
initscr();
raw();
cbreak();
noecho();
do
{
while ( 1 )
{
v4 = wgetch(stdscr__NCURSES6_TINFO_5_0_19991023);
v5 = v4;
if ( v4 != 42 )
break;
if ( v3 )
wattr_off(stdscr__NCURSES6_TINFO_5_0_19991023, 0x200000uLL, 0LL);
else
wattr_on(stdscr__NCURSES6_TINFO_5_0_19991023, 0x200000uLL, 0LL);
v3 ^= 1u;
wrefresh(stdscr__NCURSES6_TINFO_5_0_19991023);
}
waddch(stdscr__NCURSES6_TINFO_5_0_19991023, v4);
wrefresh(stdscr__NCURSES6_TINFO_5_0_19991023);
}
while ( v5 != 113 );
endwin();
return 0;
}

original_code:
int main(char* argvs[], int argc) {
  int ch, bold = 0;
  initscr();
  raw();
  cbreak();
  noecho();
  do {
    ch = wgetch(stdscr);
    if (ch == '*') {
      bold = !bold;
      if (bold) {
        wattr_on(stdscr, (attr_t)((((chtype)((1U)) << ((13) + 8)))), ((void *)0));
      } else {
        wattr_off(stdscr, (attr_t)((((chtype)((1U)) << ((13) + 8)))), ((void *)0));
      }
    } else {
      waddch(stdscr,(ch));
    }
    wrefresh(stdscr);
  } while (ch != 'q');
  endwin();
  return 0;
}

canonical_original_code:
int main(char *argvs[], int argc) {
  int ch; int bold = 0;
  initscr();
  raw();
  cbreak();
  noecho();
  do {
    ch = wgetch(stdscr);
    if (ch == '*') {
      bold = !bold;
      if (bold) {
        wattr_on(stdscr, (attr_t)((((chtype)((1U)) << ((13) + 8)))), ((void *)0));
      } else {
        wattr_off(stdscr, (attr_t)((((chtype)((1U)) << ((13) + 8)))), ((void *)0));
      }
    } else {
      waddch(stdscr,(ch));
    }
    wrefresh(stdscr);
  } while (ch != 'q');
  endwin();
  return 0;
}

variable_types:
argvs
char *[]

variable_types: argc int

variable_types: ch int

variable_types: bold int


repo: rhilenova/mamewm

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
const char *v3; // r8
const char **v4; // rax
__int16 v5; // cx
const char **v6; // rdi
int v7; // ebx
__int64 v8; // rbp
const xcb_setup_t *v9; // rax
xcb_window_t v10; // er12
const char *v11; // r13
__int64 v12; // r14
uint16_t v13; // ax
xcb_intern_atom_reply_t *v14; // rax
xcb_void_cookie_t v15; // eax
uint32_t value_list[5]; // [rsp+Ch] [rbp-5Ch] BYREF
char *s[9]; // [rsp+20h] [rbp-48h]

v3 = *argv;
s[0] = "_NET_WM_DESKTOP";
s[1] = "WM_DELETE_WINDOW";
s[2] = "WM_PROTOCOLS";
if ( argc <= 1 )
{
program_name = (__int64)v3;
}
else
{
v4 = argv + 1;
v5 = 0;
v6 = &argv[(unsigned int)(argc - 2) + 2];
do
{
if ( **v4 == 45 )
{
if ( (*v4)[1] != 118 )
{
program_name = (__int64)v3;
LABEL_21:
fprintf(stderr, "usage: %s [-v]\n", v3);
exit(-1);
}
Verbose = 1;
}
else
{
v5 = 1;
}
++v4;
}
while ( v4 != v6 );
program_name = (__int64)v3;
if ( v5 == 1 )
goto LABEL_21;
}
printf("Starting %s...\n", *argv);
if ( signal(2, sigcatch) != (__sighandler_t)-1LL )
{
if ( signal(15, sigcatch) != (__sighandler_t)-1LL )
{
if ( signal(17, (__sighandler_t)1) != (__sighandler_t)-1LL )
{
connection = xcb_connect(0LL, 0LL);
v7 = xcb_connection_has_error(connection);
if ( !v7 )
{
v8 = 0LL;
v9 = xcb_get_setup(connection);
v10 = xcb_setup_roots_iterator(v9).data->root;
do
{
v11 = s[v8];
v12 = (int)v8++;
v13 = strlen(v11);
value_list[v12 + 2] = xcb_intern_atom(connection, 0, v13, v11).sequence;
}
while ( v8 != 3 );
while ( 1 )
{
v14 = xcb_intern_atom_reply(connection, (xcb_intern_atom_cookie_t)value_list[v7 + 2], &xcb_error);
if ( !xcb_error )
free(v14);
if ( ++v7 == 3 )
{
value_list[0] = 1703936;
v15.sequence = xcb_change_window_attributes_checked(connection, v10, 0x800u, value_list).sequence;
xcb_error = xcb_request_check(connection, v15);
xcb_flush(connection);
if ( xcb_error )
fprintf(
stderr,
"MAMEwm: Can't subscribe to events - error code %d. Another window manager already running?\n",
xcb_error->error_code);
cleanup(sigcode);
}
}
}
perror("xcb_connect");
exit(-1);
}
perror("setting SIGCHLD handler");
exit(-1);
}
perror("setting SIGTERM handler");
exit(-1);
}
perror("setting SIGINT handler");
exit(-1);
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
const char *v3; // r8
const char **v4; // rax
__int16 v5; // cx
const char **v6; // rdi
int v7; // ebx
__int64 v8; // rbp
const xcb_setup_t *v9; // rax
xcb_window_t v10; // er12
const char *v11; // r13
__int64 v12; // r14
uint16_t v13; // ax
xcb_intern_atom_reply_t *v14; // rax
xcb_void_cookie_t v15; // eax
uint32_t value_list[5]; // [rsp+Ch] [rbp-5Ch] BYREF
char *s[9]; // [rsp+20h] [rbp-48h]

v3 = *argv;
s[0] = "_NET_WM_DESKTOP";
s[1] = "WM_DELETE_WINDOW";
s[2] = "WM_PROTOCOLS";
if ( argc <= 1 )
{
program_name = (__int64)v3;
}
else
{
v4 = argv + 1;
v5 = 0;
v6 = &argv[(unsigned int)(argc - 2) + 2];
do
{
if ( **v4 == 45 )
{
if ( (*v4)[1] != 118 )
{
program_name = (__int64)v3;
LABEL_21:
fprintf(stderr, "usage: %s [-v]\n", v3);
exit(-1);
}
Verbose = 1;
}
else
{
v5 = 1;
}
++v4;
}
while ( v4 != v6 );
program_name = (__int64)v3;
if ( v5 == 1 )
goto LABEL_21;
}
printf("Starting %s...\n", *argv);
if ( signal(2, sigcatch) != (__sighandler_t)-1LL )
{
if ( signal(15, sigcatch) != (__sighandler_t)-1LL )
{
if ( signal(17, (__sighandler_t)1) != (__sighandler_t)-1LL )
{
connection = xcb_connect(0LL, 0LL);
v7 = xcb_connection_has_error(connection);
if ( !v7 )
{
v8 = 0LL;
v9 = xcb_get_setup(connection);
v10 = xcb_setup_roots_iterator(v9).data->root;
do
{
v11 = s[v8];
v12 = (int)v8++;
v13 = strlen(v11);
value_list[v12 + 2] = xcb_intern_atom(connection, 0, v13, v11).sequence;
}
while ( v8 != 3 );
while ( 1 )
{
v14 = xcb_intern_atom_reply(connection, (xcb_intern_atom_cookie_t)value_list[v7 + 2], &xcb_error);
if ( !xcb_error )
free(v14);
if ( ++v7 == 3 )
{
value_list[0] = 1703936;
v15.sequence = xcb_change_window_attributes_checked(connection, v10, 0x800u, value_list).sequence;
xcb_error = xcb_request_check(connection, v15);
xcb_flush(connection);
if ( xcb_error )
fprintf(
stderr,
"MAMEwm: Can't subscribe to events - error code %d. Another window manager already running?\n",
xcb_error->error_code);
func8(sigcode);
}
}
}
perror("xcb_connect");
exit(-1);
}
perror("setting SIGCHLD handler");
exit(-1);
}
perror("setting SIGTERM handler");
exit(-1);
}
perror("setting SIGINT handler");
exit(-1);
}

original_code:
int main(int argc, char* argv[])
{
    xcb_screen_t *screen;
    xcb_window_t root;
    const short ATOM_NUMBER = 3;
    char *atom_names[] = {"_NET_WM_DESKTOP",
                          "WM_DELETE_WINDOW",
                          "WM_PROTOCOLS"};
    xcb_intern_atom_cookie_t cookies[ATOM_NUMBER];
    xcb_atom_t atoms[ATOM_NUMBER];
    int counter;
    short error = 0;
    uint32_t mask = 0;
    uint32_t values[2];
    xcb_void_cookie_t cookie;
    for(counter = 1; counter < argc; ++counter)
    {
        if(argv[counter][0] == '-')
        {
            switch (argv[counter][1])
            {
                case 'v':
                    Verbose = 1;
                    continue;
            }
            error = 1;
            break;
        } else
        {
            error = 1;
        }
    }
    program_name = argv[0];
    if(error == 1)
    {
        fprintf(stderr, "usage:  %s [-v]\n", program_name);
        exit(-1);
    }
    printf("Starting %s...\n", argv[0]);
    if(signal(2, sigcatch) == ((__sighandler_t) -1))
    {
        perror("setting SIGINT handler");
        exit(-1);
    }
    if(signal(15, sigcatch) == ((__sighandler_t) -1))
    {
        perror("setting SIGTERM handler");
        exit(-1);
    }
    if(signal(17, ((__sighandler_t) 1)) == ((__sighandler_t) -1))
    {
        perror("setting SIGCHLD handler");
        exit(-1);
    }
    connection = xcb_connect(((void *)0), ((void *)0));
    if(xcb_connection_has_error(connection))
    {
        perror("xcb_connect");
        exit(-1);
    }
    screen = xcb_setup_roots_iterator(xcb_get_setup(connection)).data;
    root = screen->root;
    for(counter = 0; counter < ATOM_NUMBER; ++counter)
    {
        cookies[counter] = xcb_intern_atom(connection, 0,
                                           strlen(atom_names[counter]),
                                           atom_names[counter]);
    }
    for(counter = 0; counter < ATOM_NUMBER; ++counter)
    {
        xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(connection,
                                                               cookies[counter],
                                                               &xcb_error);
        if(xcb_error == ((void *)0))
        {
            atoms[counter] = reply->atom;
            free(reply);
        }
    }
    mask = XCB_CW_EVENT_MASK;
    values[0] = XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT |
                XCB_EVENT_MASK_STRUCTURE_NOTIFY |
                XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY;
    cookie = xcb_change_window_attributes_checked(connection, root, mask,
                                                  values);
    xcb_error = xcb_request_check(connection, cookie);
    xcb_flush(connection);
    if (xcb_error != ((void *)0))
    {
        fprintf(stderr, "MAMEwm: Can't subscribe to events - error code %d."
                " Another window manager already running?\n",
                xcb_error->error_code);
    }
    cleanup(sigcode);
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
    struct xcb_screen_t *screen;
    unsigned int root;
    short ATOM_NUMBER = 3;
    char *atom_names[] = {"_NET_WM_DESKTOP",
                          "WM_DELETE_WINDOW",
                          "WM_PROTOCOLS"};
    struct xcb_intern_atom_cookie_t cookies[-1];
    unsigned int atoms[-1];
    int counter;
    short error = 0;
    unsigned int mask = 0;
    unsigned int values[2];
    struct xcb_void_cookie_t cookie;
    for(counter = 1; counter < argc; ++counter)
    {
        if(argv[counter][0] == '-')
        {
            switch (argv[counter][1])
            {
                case 'v':
                    Verbose = 1;
                    continue;
            }
            error = 1;
            break;
        } else
        {
            error = 1;
        }
    }
    program_name = argv[0];
    if(error == 1)
    {
        fprintf(stderr, "usage:  %s [-v]\n", program_name);
        exit(-1);
    }
    printf("Starting %s...\n", argv[0]);
    if(signal(2, sigcatch) == ((__sighandler_t) -1))
    {
        perror("setting SIGINT handler");
        exit(-1);
    }
    if(signal(15, sigcatch) == ((__sighandler_t) -1))
    {
        perror("setting SIGTERM handler");
        exit(-1);
    }
    if(signal(17, ((void (*)(int)) 1)) == ((__sighandler_t) -1))
    {
        perror("setting SIGCHLD handler");
        exit(-1);
    }
    connection = xcb_connect(((void *)0), ((void *)0));
    if(xcb_connection_has_error(connection))
    {
        perror("xcb_connect");
        exit(-1);
    }
    screen = xcb_setup_roots_iterator(xcb_get_setup(connection)).data;
    root = screen->root;
    for(counter = 0; counter < ATOM_NUMBER; ++counter)
    {
        cookies[counter] = xcb_intern_atom(connection, 0,
                                           strlen(atom_names[counter]),
                                           atom_names[counter]);
    }
    for(counter = 0; counter < ATOM_NUMBER; ++counter)
    {
        struct xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(connection,
                                                               cookies[counter],
                                                               &xcb_error);
        if(xcb_error == ((void *)0))
        {
            atoms[counter] = reply->atom;
            free(reply);
        }
    }
    mask = XCB_CW_EVENT_MASK;
    values[0] = XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT |
                XCB_EVENT_MASK_STRUCTURE_NOTIFY |
                XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY;
    cookie = xcb_change_window_attributes_checked(connection, root, mask,
                                                  values);
    xcb_error = xcb_request_check(connection, cookie);
    xcb_flush(connection);
    if (xcb_error != ((void *)0))
    {
        fprintf(stderr, "MAMEwm: Can't subscribe to events - error code %d."
                " Another window manager already running?\n",
                xcb_error->error_code);
    }
    cleanup(sigcode);
    return 0;
}

variable_types:
argv
char *[]

variable_types: struct xcb_screen_t { unsigned int root; unsigned int default_colormap; unsigned int white_pixel; unsigned int black_pixel; unsigned int current_input_masks; unsigned short width_in_pixels; unsigned short height_in_pixels; unsigned short width_in_millimeters; unsigned short height_in_millimeters; unsigned short min_installed_maps; unsigned short max_installed_maps; unsigned int root_visual; unsigned char backing_stores; unsigned char save_unders; unsigned char root_depth; unsigned char allowed_depths_len; } *

variable_types:
root
unsigned int

variable_types: struct xcb_intern_atom_cookie_t { unsigned int sequence; } [-1]

variable_types:
atoms
unsigned int [-1]

variable_types: counter int

variable_types: error short

variable_types:
mask
unsigned int

variable_types:
values
unsigned int [2]

variable_types: struct xcb_void_cookie_t { unsigned int sequence; }

variable_types: struct xcb_intern_atom_reply_t { unsigned char response_type; unsigned char pad0; unsigned short sequence; unsigned int length; unsigned int atom; } *


sigcatch

decompiled_code:
void __fastcall sigcatch(int a1)
{
sigcode = a1;
}

canonical_decompiled_code:
void __fastcall func7(int a1)
{
sigcode = a1;
}

original_code:
void sigcatch(int sig)
{
    sigcode = sig;
}

variable_types: sig int


cleanup

decompiled_code:
void __fastcall __noreturn cleanup(int status)
{
xcb_set_input_focus(connection, 0, 1u, 0);
xcb_flush(connection);
xcb_disconnect(connection);
printf("Shutting down %s...\n", (const char *)program_name);
exit(status);
}

canonical_decompiled_code:
void __fastcall __noreturn func8(int status)
{
xcb_set_input_focus(connection, 0, 1u, 0);
xcb_flush(connection);
xcb_disconnect(connection);
printf("Shutting down %s...\n", (const char *)program_name);
exit(status);
}

original_code:
void cleanup(int code)
{
    xcb_set_input_focus(connection, 0L, XCB_INPUT_FOCUS_POINTER_ROOT,
                        0L);
    xcb_flush(connection);
    xcb_disconnect(connection);
    printf("Shutting down %s...\n", program_name);
    exit(code);
}

variable_types: code int


decompiled_code:
__int64 __fastcall update_pri(int a1, int a2)
{
__int64 v2; // rax
double v4; // xmm1_8
double v5; // xmm0_8

if ( *(_DWORD *)(heap_A + 16LL * a1) != a2 )
return fwrite("Error update_pri!\n", 1uLL, 0x12uLL, DFILE);
v2 = adjlist + 72LL * a2;
if ( *(_DWORD *)(v2 + 32) != a1 )
return fwrite("Error update_pri!\n", 1uLL, 0x12uLL, DFILE);
v4 = *(double *)(v2 + 16);
v5 = *(double *)(v2 + 24);
if ( v4 == 0.0 )
return update(v5);
if ( v5 == 0.0 )
return update(*(double *)(v2 + 16));
if ( v4 <= v5 )
return update(v5 - v4 - 1.0);
return update(v4 - v5 - 1.0);
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, int a2)
{
__int64 v2; // rax
double v4; // xmm1_8
double v5; // xmm0_8

if ( *(_DWORD *)(heap_A + 16LL * a1) != a2 )
return fwrite("Error update_pri!\n", 1uLL, 0x12uLL, DFILE);
v2 = adjlist + 72LL * a2;
if ( *(_DWORD *)(v2 + 32) != a1 )
return fwrite("Error update_pri!\n", 1uLL, 0x12uLL, DFILE);
v4 = *(double *)(v2 + 16);
v5 = *(double *)(v2 + 24);
if ( v4 == 0.0 )
return update(v5);
if ( v5 == 0.0 )
return update(*(double *)(v2 + 16));
if ( v4 <= v5 )
return update(v5 - v4 - 1.0);
return update(v4 - v5 - 1.0);
}

original_code:
void update_pri(int hi, int pi)
{
    double pr;
    if ((heap_A[hi].pid != pi)||(adjlist[pi].hid != hi)) {
        fprintf(DFILE,"Error update_pri!\n");
        return;
    }
    if (adjlist[pi].in==0.0) {
        pr = adjlist[pi].out;
    }
    else if (adjlist[pi].out == 0.0) {
        pr = adjlist[pi].in;
    }
    else {
        if (adjlist[pi].in > adjlist[pi].out) {
            pr = adjlist[pi].in - adjlist[pi].out - 1;
        }
        else {
            pr = adjlist[pi].out - adjlist[pi].in - 1;
        }
    }
    update(hi,pr);
}

variable_types: hi int

variable_types: pi int

variable_types: pr double


decompiled_code:
__int64 __fastcall opp_update(int a1)
{
__int64 v1; // rbp
__int64 result; // rax
double *v3; // rbx
double v4; // xmm2_8
double v5; // rdi
__int64 v6; // rdx
int v7; // er8
double v8; // xmm0_8
double v9; // xmm1_8
double v10; // xmm0_8
double v11; // xmm1_8
double v12; // xmm0_8
double v13; // xmm1_8
double v14; // xmm0_8

v1 = 72LL * a1;
result = opplist;
v3 = *(double **)(opplist + 8LL * a1);
if ( v3 )
{
v4 = *(double *)&LC3;
while ( 1 )
{
v5 = *v3;
result = adjlist;
v6 = adjlist + 72LL * (int)*(_QWORD *)v3;
if ( defer && *(_WORD *)(v6 + 8) == 0xFFFF || *(_WORD *)(v6 + 10) )
goto LABEL_6;
v7 = *(_DWORD *)(v6 + 32);
result = v1 + adjlist;
v8 = *(double *)(v1 + adjlist + 16);
v9 = *(double *)(v1 + adjlist + 24);
if ( !v7 )
{
if ( v8 > v9 )
{
v12 = COERCE_DOUBLE(*(_QWORD *)&v8 ^ LC3) * v3[1];
*(double *)(v6 + 24) = v12;
result = insert_heap(v12, v9, v4);
v4 = *(double *)&LC3;
}
else if ( v9 > v8 )
{
*(_QWORD *)&v13 = *(_QWORD *)&v9 ^ LC3;
v14 = v3[1] * v13;
*(double *)(v6 + 16) = v14;
result = insert_heap(v14, v13, v4);
v4 = *(double *)&LC3;
}
goto LABEL_6;
}
if ( v8 <= v9 )
break;
v10 = COERCE_DOUBLE(*(_QWORD *)&v8 ^ LC3) * v3[1];
if ( v10 <= *(double *)(v6 + 24) )
{
LABEL_6:
v3 = (double *)*((_QWORD *)v3 + 2);
if ( !v3 )
return result;
}
else
{
*(double *)(v6 + 24) = v10;
result = update_pri(v7, SLODWORD(v5));
v3 = (double *)*((_QWORD *)v3 + 2);
v4 = *(double *)&LC3;
if ( !v3 )
return result;
}
}
if ( v9 > v8 )
{
v11 = COERCE_DOUBLE(*(_QWORD *)&v9 ^ *(_QWORD *)&v4) * v3[1];
if ( v11 > *(double *)(v6 + 16) )
{
*(double *)(v6 + 16) = v11;
result = update_pri(v7, SLODWORD(v5));
v4 = *(double *)&LC3;
}
}
goto LABEL_6;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
__int64 v1; // rbp
__int64 result; // rax
double *v3; // rbx
double v4; // xmm2_8
double v5; // rdi
__int64 v6; // rdx
int v7; // er8
double v8; // xmm0_8
double v9; // xmm1_8
double v10; // xmm0_8
double v11; // xmm1_8
double v12; // xmm0_8
double v13; // xmm1_8
double v14; // xmm0_8

v1 = 72LL * a1;
result = opplist;
v3 = *(double **)(opplist + 8LL * a1);
if ( v3 )
{
v4 = *(double *)&LC3;
while ( 1 )
{
v5 = *v3;
result = adjlist;
v6 = adjlist + 72LL * (int)*(_QWORD *)v3;
if ( defer && *(_WORD *)(v6 + 8) == 0xFFFF || *(_WORD *)(v6 + 10) )
goto LABEL_6;
v7 = *(_DWORD *)(v6 + 32);
result = v1 + adjlist;
v8 = *(double *)(v1 + adjlist + 16);
v9 = *(double *)(v1 + adjlist + 24);
if ( !v7 )
{
if ( v8 > v9 )
{
v12 = COERCE_DOUBLE(*(_QWORD *)&v8 ^ LC3) * v3[1];
*(double *)(v6 + 24) = v12;
result = insert_heap(v12, v9, v4);
v4 = *(double *)&LC3;
}
else if ( v9 > v8 )
{
*(_QWORD *)&v13 = *(_QWORD *)&v9 ^ LC3;
v14 = v3[1] * v13;
*(double *)(v6 + 16) = v14;
result = insert_heap(v14, v13, v4);
v4 = *(double *)&LC3;
}
goto LABEL_6;
}
if ( v8 <= v9 )
break;
v10 = COERCE_DOUBLE(*(_QWORD *)&v8 ^ LC3) * v3[1];
if ( v10 <= *(double *)(v6 + 24) )
{
LABEL_6:
v3 = (double *)*((_QWORD *)v3 + 2);
if ( !v3 )
return result;
}
else
{
*(double *)(v6 + 24) = v10;
result = func0(v7, SLODWORD(v5));
v3 = (double *)*((_QWORD *)v3 + 2);
v4 = *(double *)&LC3;
if ( !v3 )
return result;
}
}
if ( v9 > v8 )
{
v11 = COERCE_DOUBLE(*(_QWORD *)&v9 ^ *(_QWORD *)&v4) * v3[1];
if ( v11 > *(double *)(v6 + 16) )
{
*(double *)(v6 + 16) = v11;
result = func0(v7, SLODWORD(v5));
v4 = *(double *)&LC3;
}
}
goto LABEL_6;
}
return result;
}

original_code:
void opp_update(int pi)
{
    struct plist *pindex;
    int npi, nhi;
    double temp;
    pindex = opplist[pi];
    while (pindex!=((void *)0)) {
        npi = pindex->pid;
        if (defer) {
            if (adjlist[npi].bad == -1) {
                pindex = pindex->next;
                continue;
            }
        }
        if (adjlist[npi].label == 0) {
            if (adjlist[npi].hid == 0) {
                if (adjlist[pi].in > adjlist[pi].out) {
                    adjlist[npi].out = (-1.0) * adjlist[pi].in * pindex->angle;
                    insert_heap(npi,adjlist[npi].out);
                }
                else if (adjlist[pi].in < adjlist[pi].out) {
                    adjlist[npi].in = (-1.0) * adjlist[pi].out * pindex->angle;
                    insert_heap(npi,adjlist[npi].in);
                }
            }
            else {
                nhi = adjlist[npi].hid;
                if (adjlist[pi].in > adjlist[pi].out) {
                    temp = (-1.0) * adjlist[pi].in * pindex->angle;
                    if (temp > adjlist[npi].out) {
                        adjlist[npi].out = temp;
                        update_pri(nhi,npi);
                    }
                }
                else if (adjlist[pi].in < adjlist[pi].out) {
                    temp = (-1.0) * adjlist[pi].out * pindex->angle;
                    if (temp > adjlist[npi].in) {
                        adjlist[npi].in = temp;
                        update_pri(nhi,npi);
                    }
                }
            }
        }
        pindex = pindex->next;
    }
}

canonical_original_code:
void opp_update(int pi)
{
    struct plist *pindex;
    int npi; int nhi;
    double temp;
    pindex = opplist[pi];
    while (pindex!=((void *)0)) {
        npi = pindex->pid;
        if (defer) {
            if (adjlist[npi].bad == -1) {
                pindex = pindex->next;
                continue;
            }
        }
        if (adjlist[npi].label == 0) {
            if (adjlist[npi].hid == 0) {
                if (adjlist[pi].in > adjlist[pi].out) {
                    adjlist[npi].out = (-1.0) * adjlist[pi].in * pindex->angle;
                    insert_heap(npi,adjlist[npi].out);
                }
                else if (adjlist[pi].in < adjlist[pi].out) {
                    adjlist[npi].in = (-1.0) * adjlist[pi].out * pindex->angle;
                    insert_heap(npi,adjlist[npi].in);
                }
            }
            else {
                nhi = adjlist[npi].hid;
                if (adjlist[pi].in > adjlist[pi].out) {
                    temp = (-1.0) * adjlist[pi].in * pindex->angle;
                    if (temp > adjlist[npi].out) {
                        adjlist[npi].out = temp;
                        update_pri(nhi,npi);
                    }
                }
                else if (adjlist[pi].in < adjlist[pi].out) {
                    temp = (-1.0) * adjlist[pi].out * pindex->angle;
                    if (temp > adjlist[npi].in) {
                        adjlist[npi].in = temp;
                        update_pri(nhi,npi);
                    }
                }
            }
        }
        pindex = pindex->next;
    }
}

variable_types: struct plist { long pid; double angle; struct plist *next; } *

variable_types: npi int

variable_types: nhi int

variable_types: temp double


decompiled_code:
__int64 __fastcall sym_update(int a1)
{
__int64 v1; // r13
__int64 result; // rax
__int64 v3; // rbx
__int64 v4; // r12
__int64 v5; // rbp
__int64 v6; // rdx
double v7; // xmm0_8
int v8; // edi
double v9; // xmm1_8
double v10; // xmm2_8
double v11; // xmm0_8
double v12; // xmm1_8
double v13; // xmm1_8
double v14; // xmm0_8
double v15; // xmm0_8
double v16; // xmm0_8

v1 = 72LL * a1;
result = adjlist;
v3 = *(_QWORD *)(adjlist + v1);
if ( v3 )
{
while ( 1 )
{
v4 = *(_QWORD *)(v3 + 24);
v5 = 72LL * (int)v4;
v6 = result + v5;
if ( (!defer || *(_WORD *)(v6 + 8) != 0xFFFF) && !*(_WORD *)(v6 + 10) )
{
v7 = *(double *)(v3 + 8);
if ( v7 > theta )
{
v8 = *(_DWORD *)(v6 + 32);
if ( v8 )
{
if ( *(_DWORD *)(heap_A + 16LL * v8) != (_DWORD)v4 )
{
fwrite("ERROR\n", 1uLL, 6uLL, DFILE);
result = adjlist;
v6 = adjlist + v5;
v8 = *(_DWORD *)(adjlist + v5 + 32);
}
result += v1;
v11 = *(double *)(result + 16);
v12 = *(double *)(result + 24);
if ( v11 > v12 )
{
v14 = v11 * *(double *)(v3 + 8);
if ( v14 > *(double *)(v6 + 16) )
{
*(double *)(v6 + 16) = v14;
result = update_pri(v8, v4);
}
}
else if ( v12 > v11 )
{
v13 = v12 * *(double *)(v3 + 8);
if ( v13 > *(double *)(v6 + 24) )
{
*(double *)(v6 + 24) = v13;
result = update_pri(v8, v4);
}
}
}
else
{
result += v1;
v9 = *(double *)(result + 16);
v10 = *(double *)(result + 24);
if ( v9 > v10 )
{
v16 = v7 * v9;
*(double *)(v6 + 16) = v16;
result = insert_heap(v16, v9, v10);
}
else if ( v10 > v9 )
{
v15 = v7 * v10;
*(double *)(v6 + 24) = v15;
result = insert_heap(v15, v9, v10);
}
}
}
}
v3 = *(_QWORD *)(v3 + 32);
if ( !v3 )
break;
result = adjlist;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1)
{
__int64 v1; // r13
__int64 result; // rax
__int64 v3; // rbx
__int64 v4; // r12
__int64 v5; // rbp
__int64 v6; // rdx
double v7; // xmm0_8
int v8; // edi
double v9; // xmm1_8
double v10; // xmm2_8
double v11; // xmm0_8
double v12; // xmm1_8
double v13; // xmm1_8
double v14; // xmm0_8
double v15; // xmm0_8
double v16; // xmm0_8

v1 = 72LL * a1;
result = adjlist;
v3 = *(_QWORD *)(adjlist + v1);
if ( v3 )
{
while ( 1 )
{
v4 = *(_QWORD *)(v3 + 24);
v5 = 72LL * (int)v4;
v6 = result + v5;
if ( (!defer || *(_WORD *)(v6 + 8) != 0xFFFF) && !*(_WORD *)(v6 + 10) )
{
v7 = *(double *)(v3 + 8);
if ( v7 > theta )
{
v8 = *(_DWORD *)(v6 + 32);
if ( v8 )
{
if ( *(_DWORD *)(heap_A + 16LL * v8) != (_DWORD)v4 )
{
fwrite("ERROR\n", 1uLL, 6uLL, DFILE);
result = adjlist;
v6 = adjlist + v5;
v8 = *(_DWORD *)(adjlist + v5 + 32);
}
result += v1;
v11 = *(double *)(result + 16);
v12 = *(double *)(result + 24);
if ( v11 > v12 )
{
v14 = v11 * *(double *)(v3 + 8);
if ( v14 > *(double *)(v6 + 16) )
{
*(double *)(v6 + 16) = v14;
result = func0(v8, v4);
}
}
else if ( v12 > v11 )
{
v13 = v12 * *(double *)(v3 + 8);
if ( v13 > *(double *)(v6 + 24) )
{
*(double *)(v6 + 24) = v13;
result = func0(v8, v4);
}
}
}
else
{
result += v1;
v9 = *(double *)(result + 16);
v10 = *(double *)(result + 24);
if ( v9 > v10 )
{
v16 = v7 * v9;
*(double *)(v6 + 16) = v16;
result = insert_heap(v16, v9, v10);
}
else if ( v10 > v9 )
{
v15 = v7 * v10;
*(double *)(v6 + 24) = v15;
result = insert_heap(v15, v9, v10);
}
}
}
}
v3 = *(_QWORD *)(v3 + 32);
if ( !v3 )
break;
result = adjlist;
}
}
return result;
}

original_code:
void sym_update(int pi)
{
    struct edgesimp *eindex;
    int npi, nhi;
    double temp;
    eindex = adjlist[pi].eptr;
    while (eindex!=((void *)0)) {
        npi = eindex->pid;
        if (defer) {
            if (adjlist[npi].bad == -1) {
                eindex = eindex->next;
                continue;
            }
        }
        if ((adjlist[npi].label==0) && (eindex->angle > theta)) {
            if (adjlist[npi].hid == 0) {
                if (adjlist[pi].in > adjlist[pi].out) {
                    adjlist[npi].in = adjlist[pi].in * eindex->angle;
                    insert_heap(npi,adjlist[npi].in);
                }
                else if (adjlist[pi].in < adjlist[pi].out) {
                    adjlist[npi].out = adjlist[pi].out * eindex->angle;
                    insert_heap(npi,adjlist[npi].out);
                }
            }
            else {
                if (heap_A[adjlist[npi].hid].pid != npi) fprintf(DFILE,"ERROR\n");
                nhi = adjlist[npi].hid;
                if (adjlist[pi].in > adjlist[pi].out) {
                    temp = adjlist[pi].in * eindex->angle;
                    if (temp > adjlist[npi].in) {
                        adjlist[npi].in = temp;
                        update_pri(nhi,npi);
                    }
                }
                else if (adjlist[pi].in < adjlist[pi].out) {
                    temp = adjlist[pi].out * eindex->angle;
                    if (temp > adjlist[npi].out) {
                        adjlist[npi].out = temp;
                        update_pri(nhi,npi);
                    }
                }
            }
        }
        eindex = eindex->next;
    }
}

canonical_original_code:
void sym_update(int pi)
{
    struct edgesimp *eindex;
    int npi; int nhi;
    double temp;
    eindex = adjlist[pi].eptr;
    while (eindex!=((void *)0)) {
        npi = eindex->pid;
        if (defer) {
            if (adjlist[npi].bad == -1) {
                eindex = eindex->next;
                continue;
            }
        }
        if ((adjlist[npi].label==0) && (eindex->angle > theta)) {
            if (adjlist[npi].hid == 0) {
                if (adjlist[pi].in > adjlist[pi].out) {
                    adjlist[npi].in = adjlist[pi].in * eindex->angle;
                    insert_heap(npi,adjlist[npi].in);
                }
                else if (adjlist[pi].in < adjlist[pi].out) {
                    adjlist[npi].out = adjlist[pi].out * eindex->angle;
                    insert_heap(npi,adjlist[npi].out);
                }
            }
            else {
                if (heap_A[adjlist[npi].hid].pid != npi) fprintf(DFILE,"ERROR\n");
                nhi = adjlist[npi].hid;
                if (adjlist[pi].in > adjlist[pi].out) {
                    temp = adjlist[pi].in * eindex->angle;
                    if (temp > adjlist[npi].in) {
                        adjlist[npi].in = temp;
                        update_pri(nhi,npi);
                    }
                }
                else if (adjlist[pi].in < adjlist[pi].out) {
                    temp = adjlist[pi].out * eindex->angle;
                    if (temp > adjlist[npi].out) {
                        adjlist[npi].out = temp;
                        update_pri(nhi,npi);
                    }
                }
            }
        }
        eindex = eindex->next;
    }
}

variable_types: struct edgesimp { short kth; double angle; struct simplex { struct simplex *next; short mark; double *vv; double sqradius; short status; long poleindex; short edgestatus[6]; long visit; struct basis_s { struct basis_s *next; int ref_count; int lscale; double sqa; double vecs[1]; } *normal; struct neighbor { double *vert; struct simplex *simp; struct basis_s *basis; } peak; struct neighbor neigh[1]; } *simp; long pid; struct edgesimp *next; } *

user_defined_types: struct edgesimp { short kth; double angle; struct simplex *simp; long pid; struct edgesimp *next; }

user_defined_types: struct simplex { struct simplex *next; short mark; double *vv; double sqradius; short status; long poleindex; short edgestatus[6]; long visit; struct basis_s *normal; struct neighbor peak; struct neighbor neigh[1]; }


propagate

decompiled_code:
__int64 propagate()
{
int v0; // er12

v0 = extract_max();
*(_WORD *)(adjlist + 72LL * v0 + 10) = (*(double *)(adjlist + 72LL * v0 + 16) > *(double *)(adjlist + 72LL * v0 + 24))
+ 1;
if ( v0 != -1 )
{
opp_update(v0);
sym_update(v0);
}
return (unsigned int)v0;
}

canonical_decompiled_code:
__int64 func3()
{
int v0; // er12

v0 = extract_max();
*(_WORD *)(adjlist + 72LL * v0 + 10) = (*(double *)(adjlist + 72LL * v0 + 16) > *(double *)(adjlist + 72LL * v0 + 24))
+ 1;
if ( v0 != -1 )
{
func1(v0);
func2(v0);
}
return (unsigned int)v0;
}

original_code:
int propagate()
{
    int pid;
    pid = extract_max();
    if (adjlist[pid].in > adjlist[pid].out)
        adjlist[pid].label = 2;
    else adjlist[pid].label = 1;
    if (pid != -1) {
        opp_update(pid);
        sym_update(pid);
    }
    return pid;
}

variable_types: pid int