outgnuhash

decompiled_code:
__int64 __fastcall outgnuhash(int *a1, unsigned __int64 a2)
{
signed __int64 v2; // r13
int *v3; // rbp
int v4; // er12
int v5; // er15
signed __int64 v6; // rbx
unsigned int *v7; // r14
__int64 v8; // rdi
__int64 v9; // rdi
__int64 v11; // r12
__int64 v12; // rsi
unsigned int *v13; // r12
__int64 v14; // rdi
__int64 v15; // rdi
__int64 v16; // rsi

v2 = a2 >> 2;
v3 = a1;
if ( a2 > 0xF )
{
v4 = a1[2];
v5 = *a1;
if ( (unsigned int)iself64() )
v4 *= 2;
LODWORD(v6) = v4 + 4;
if ( v4 + 4 + v5 <= v2 )
{
v7 = (unsigned int *)a1;
beginblock(1LL);
do
{
v8 = *v7++;
v9 = strdec(v8);
out(v9);
}
while ( v7 != (unsigned int *)(v3 + 4) );
if ( v4 && (linebreak(), v4 > 0) )
{
v11 = (__int64)&v3[v4 - 1 + 5];
do
{
v12 = *v7++;
outf("0x%08lX", v12);
}
while ( (unsigned int *)v11 != v7 );
if ( !v5 )
goto LABEL_9;
}
else
{
LODWORD(v6) = 4;
if ( !v5 )
goto LABEL_9;
}
linebreak();
if ( v5 > 0 )
{
v13 = (unsigned int *)&v3[(int)v6];
do
{
v14 = *v13++;
v15 = strdec(v14);
out(v15);
}
while ( &v3[(int)v6 + 1 + (unsigned __int64)(unsigned int)(v5 - 1)] != (int *)v13 );
v6 = v5 + (int)v6;
if ( v6 >= v2 )
return endblock();
goto LABEL_20;
}
LABEL_9:
v6 = (int)v6;
if ( (int)v6 >= v2 )
return endblock();
LABEL_20:
linebreak();
do
{
v16 = (unsigned int)v3[v6++];
outf("0x%08lX", v16);
}
while ( v2 != v6 );
return endblock();
}
}
return outwords((__int64)a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func5(int *a1, unsigned __int64 a2)
{
signed __int64 v2; // r13
int *v3; // rbp
int v4; // er12
int v5; // er15
signed __int64 v6; // rbx
unsigned int *v7; // r14
__int64 v8; // rdi
__int64 v9; // rdi
__int64 v11; // r12
__int64 v12; // rsi
unsigned int *v13; // r12
__int64 v14; // rdi
__int64 v15; // rdi
__int64 v16; // rsi

v2 = a2 >> 2;
v3 = a1;
if ( a2 > 0xF )
{
v4 = a1[2];
v5 = *a1;
if ( (unsigned int)iself64() )
v4 *= 2;
LODWORD(v6) = v4 + 4;
if ( v4 + 4 + v5 <= v2 )
{
v7 = (unsigned int *)a1;
beginblock(1LL);
do
{
v8 = *v7++;
v9 = strdec(v8);
out(v9);
}
while ( v7 != (unsigned int *)(v3 + 4) );
if ( v4 && (linebreak(), v4 > 0) )
{
v11 = (__int64)&v3[v4 - 1 + 5];
do
{
v12 = *v7++;
outf("0x%08lX", v12);
}
while ( (unsigned int *)v11 != v7 );
if ( !v5 )
goto LABEL_9;
}
else
{
LODWORD(v6) = 4;
if ( !v5 )
goto LABEL_9;
}
linebreak();
if ( v5 > 0 )
{
v13 = (unsigned int *)&v3[(int)v6];
do
{
v14 = *v13++;
v15 = strdec(v14);
out(v15);
}
while ( &v3[(int)v6 + 1 + (unsigned __int64)(unsigned int)(v5 - 1)] != (int *)v13 );
v6 = v5 + (int)v6;
if ( v6 >= v2 )
return endblock();
goto LABEL_20;
}
LABEL_9:
v6 = (int)v6;
if ( (int)v6 >= v2 )
return endblock();
LABEL_20:
linebreak();
do
{
v16 = (unsigned int)v3[v6++];
outf("0x%08lX", v16);
}
while ( v2 != v6 );
return endblock();
}
}
return func4((__int64)a1, a2);
}

original_code:
static void outgnuhash(void const *ptr, long size, int ndx)
{
    Elf64_Word const *entries = ptr;
    long count = size / sizeof *entries;
    int buckets, masks;
    int i, n;
    (void)ndx;
    if (count < 4) {
 outwords(ptr, size, ndx);
 return;
    }
    buckets = entries[0];
    masks = entries[2];
    if (iself64())
 masks *= 2;
    if (4 + masks + buckets > count) {
 outwords(ptr, size, ndx);
 return;
    }
    beginblock(1);
    for (i = 0 ; i < 4 ; ++i)
 (out(strdec(entries[i])));
    n = i;
    if (masks) {
 linebreak();
 for (i = 0 ; i < masks ; ++i)
     outf("0x%08lX", entries[n + i]);
 n += i;
    }
    if (buckets) {
 linebreak();
 for (i = 0 ; i < buckets ; ++i)
     (out(strdec(entries[n + i])));
 n += i;
    }
    if (n < count) {
 linebreak();
 for (i = n ; i < count ; ++i)
     outf("0x%08lX", entries[i]);
    }
    endblock();
}

canonical_original_code:
static void outgnuhash(void *ptr, long size, int ndx)
{
    unsigned int *entries = ptr;
    long count = size / sizeof *entries;
    int buckets; int masks;
    int i; int n;
    (void)ndx;
    if (count < 4) {
 outwords(ptr, size, ndx);
 return;
    }
    buckets = entries[0];
    masks = entries[2];
    if (iself64())
 masks *= 2;
    if (4 + masks + buckets > count) {
 outwords(ptr, size, ndx);
 return;
    }
    beginblock(1);
    for (i = 0 ; i < 4 ; ++i)
 (out(strdec(entries[i])));
    n = i;
    if (masks) {
 linebreak();
 for (i = 0 ; i < masks ; ++i)
     outf("0x%08lX", entries[n + i]);
 n += i;
    }
    if (buckets) {
 linebreak();
 for (i = 0 ; i < buckets ; ++i)
     (out(strdec(entries[n + i])));
 n += i;
    }
    if (n < count) {
 linebreak();
 for (i = n ; i < count ; ++i)
     outf("0x%08lX", entries[i]);
    }
    endblock();
}

variable_types: buckets int

variable_types: masks int

variable_types: i int

variable_types: n int


outhalves

decompiled_code:
__int64 __fastcall outhalves(__int64 a1, unsigned __int64 a2)
{
__int64 v2; // rsi
_WORD *v3; // rdx
__int64 v4; // rax
__int64 v5; // rbp
unsigned __int64 v6; // r12
const char *v7; // r14
__int64 v8; // rdi
__int64 v9; // rax
unsigned int v10; // edx
__int64 v11; // rbx
__int64 v12; // rsi
char v14[56]; // [rsp-38h] [rbp-38h] BYREF

v2 = a2 >> 1;
if ( v2 )
{
v3 = (_WORD *)(a1 + 2 * v2 - 2);
v4 = 0LL;
v5 = v2;
while ( !*v3 )
{
++v4;
--v3;
if ( v2 == v4 )
return out("{ 0 }");
}
if ( v4 <= 254 || 4 * v4 < v2 )
{
v6 = 0LL;
}
else
{
v6 = v4 & 0xFFFFFFFFFFFFFFFCLL;
v5 = v2 - (v4 & 0xFFFFFFFFFFFFFFFCLL);
if ( v5 <= 0 )
{
v7 = "%u";
beginblock(1LL);
LABEL_9:
sprintf(v14, "%s x %%ld", v7);
v8 = strf(v14, 0LL, v6);
outcomment(v8);
return endblock();
}
}
v9 = 0LL;
v10 = 0;
do
{
if ( v10 < *(unsigned __int16 *)(a1 + 2 * v9) )
v10 = *(unsigned __int16 *)(a1 + 2 * v9);
++v9;
}
while ( v9 < v5 );
if ( v10 <= 0xFF )
{
v7 = "0x%02X";
if ( v10 <= 0x63 )
{
v7 = "%u";
beginblock(1LL);
goto LABEL_18;
}
}
else
{
v7 = "0x%04X";
}
beginblock(1LL);
LABEL_18:
v11 = 0LL;
do
{
v12 = *(unsigned __int16 *)(a1 + 2 * v11++);
outf(v7, v12);
}
while ( v11 < v5 );
if ( !v6 )
return endblock();
goto LABEL_9;
}
return out("{ 0 }");
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, unsigned __int64 a2)
{
__int64 v2; // rsi
_WORD *v3; // rdx
__int64 v4; // rax
__int64 v5; // rbp
unsigned __int64 v6; // r12
const char *v7; // r14
__int64 v8; // rdi
__int64 v9; // rax
unsigned int v10; // edx
__int64 v11; // rbx
__int64 v12; // rsi
char v14[56]; // [rsp-38h] [rbp-38h] BYREF

v2 = a2 >> 1;
if ( v2 )
{
v3 = (_WORD *)(a1 + 2 * v2 - 2);
v4 = 0LL;
v5 = v2;
while ( !*v3 )
{
++v4;
--v3;
if ( v2 == v4 )
return out("{ 0 }");
}
if ( v4 <= 254 || 4 * v4 < v2 )
{
v6 = 0LL;
}
else
{
v6 = v4 & 0xFFFFFFFFFFFFFFFCLL;
v5 = v2 - (v4 & 0xFFFFFFFFFFFFFFFCLL);
if ( v5 <= 0 )
{
v7 = "%u";
beginblock(1LL);
LABEL_9:
sprintf(v14, "%s x %%ld", v7);
v8 = strf(v14, 0LL, v6);
outcomment(v8);
return endblock();
}
}
v9 = 0LL;
v10 = 0;
do
{
if ( v10 < *(unsigned __int16 *)(a1 + 2 * v9) )
v10 = *(unsigned __int16 *)(a1 + 2 * v9);
++v9;
}
while ( v9 < v5 );
if ( v10 <= 0xFF )
{
v7 = "0x%02X";
if ( v10 <= 0x63 )
{
v7 = "%u";
beginblock(1LL);
goto LABEL_18;
}
}
else
{
v7 = "0x%04X";
}
beginblock(1LL);
LABEL_18:
v11 = 0LL;
do
{
v12 = *(unsigned __int16 *)(a1 + 2 * v11++);
outf(v7, v12);
}
while ( v11 < v5 );
if ( !v6 )
return endblock();
goto LABEL_9;
}
return out("{ 0 }");
}

original_code:
static void outhalves(void const *ptr, long size, int ndx)
{
    Elf64_Half const *halves = ptr;
    long count = size / sizeof *halves;
    char fmtbuf[16];
    char const *fmt = ((void *)0);
    unsigned int max;
    long zeroes, i;
    (void)ndx;
    for (zeroes = 0 ; zeroes < count ; ++zeroes)
 if (halves[count - zeroes - 1])
     break;
    if (zeroes == count) {
 out("{ 0 }");
 return;
    }
    if (zeroes < 255 || zeroes * 4 < count)
 zeroes = 0;
    zeroes &= ~3;
    count -= zeroes;
    max = 0;
    for (i = 0 ; i < count ; ++i) {
 if (max < halves[i])
     max = halves[i];
    }
    fmt = max > 0xFF ? "0x%04X" : max > 99 ? "0x%02X" : "%u";
    beginblock(1);
    for (i = 0 ; i < count ; ++i)
 outf(fmt, halves[i]);
    if (zeroes) {
 sprintf(fmtbuf, "%s x %%ld", fmt);
 outcomment(strf(fmtbuf, 0, zeroes));
    }
    endblock();
}

canonical_original_code:
static void outhalves(void *ptr, long size, int ndx)
{
    unsigned short *halves = ptr;
    long count = size / sizeof *halves;
    char fmtbuf[16];
    char *fmt = ((void *)0);
    unsigned int max;
    long zeroes; long i;
    (void)ndx;
    for (zeroes = 0 ; zeroes < count ; ++zeroes)
 if (halves[count - zeroes - 1])
     break;
    if (zeroes == count) {
 out("{ 0 }");
 return;
    }
    if (zeroes < 255 || zeroes * 4 < count)
 zeroes = 0;
    zeroes &= ~3;
    count -= zeroes;
    max = 0;
    for (i = 0 ; i < count ; ++i) {
 if (max < halves[i])
     max = halves[i];
    }
    fmt = max > 0xFF ? "0x%04X" : max > 99 ? "0x%02X" : "%u";
    beginblock(1);
    for (i = 0 ; i < count ; ++i)
 outf(fmt, halves[i]);
    if (zeroes) {
 sprintf(fmtbuf, "%s x %%ld", fmt);
 outcomment(strf(fmtbuf, 0, zeroes));
    }
    endblock();
}

variable_types:
ptr
void *

variable_types: size long

variable_types: ndx int

variable_types:
halves
unsigned short *

variable_types: count long

variable_types:
fmtbuf
char [16]

variable_types:
fmt
char *

variable_types:
max
unsigned int

variable_types: zeroes long

variable_types: i long

return_type: void


outbytes

decompiled_code:
__int64 __fastcall outbytes(__int64 a1, __int64 a2)
{
__int64 v3; // rbx
__int64 v4; // rbp
__int64 v5; // rax
_BYTE *i; // rdx
unsigned __int64 v7; // rbp
__int64 v8; // rax
__int64 v9; // r12
__int64 v10; // rdi
__int64 v11; // rdi
__int64 v12; // rdi
__int64 v13; // rax
__int64 v14; // r12
__int64 v15; // rsi
__int64 v17; // rdi
__int64 v18; // rax

v3 = a2;
if ( a2 > 0 )
{
v4 = a2 - 1;
v5 = 0LL;
for ( i = (_BYTE *)(a1 + a2 - 1); !*i; --i )
{
if ( a2 == ++v5 )
return out("{ 0 }");
}
if ( v5 > 254 && 4 * v5 >= a2 )
{
v7 = v5 & 0xFFFFFFFFFFFFFFF8LL;
v8 = outstringsize(a1, a2);
if ( !forcehex && 2 * v8 <= 3 * a2 )
{
v3 = a2 - v7;
beginblock(1LL);
if ( (__int64)(a2 - v7) <= 0 )
{
LABEL_13:
v12 = strf("0x00 x %ld", v7);
outcomment(v12);
return endblock();
}
LABEL_10:
v9 = 0LL;
do
{
v10 = *(unsigned __int8 *)(a1 + v9++);
v11 = strchar(v10);
out(v11);
}
while ( v9 < v3 );
if ( !v7 )
return endblock();
goto LABEL_13;
}
v3 = a2 - v7;
beginblock(1LL);
if ( (__int64)(a2 - v7) <= 0 )
{
LABEL_24:
v17 = strf("0x00 x %d", v7);
outcomment(v17);
return endblock();
}
LABEL_19:
v14 = 0LL;
do
{
v15 = *(unsigned __int8 *)(a1 + v14++);
outf("0x%02X", v15);
}
while ( v14 < v3 );
if ( !v7 )
return endblock();
goto LABEL_24;
}
v13 = outstringsize(a1, a2);
if ( forcehex || 2 * v13 > 3 * a2 )
{
v7 = 0LL;
beginblock(1LL);
goto LABEL_19;
}
if ( *(_BYTE *)(a1 + a2 - 1) )
{
v7 = 0LL;
beginblock(1LL);
goto LABEL_10;
}
return outstring(a1, v4);
}
if ( a2 )
{
v18 = ((__int64 (*)(void))outstringsize)();
if ( forcehex || 3 * a2 < 2 * v18 || (v4 = a2 - 1, *(_BYTE *)(a1 + a2 - 1)) )
{
beginblock(1LL);
return endblock();
}
return outstring(a1, v4);
}
return out("{ 0 }");
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2)
{
__int64 v3; // rbx
__int64 v4; // rbp
__int64 v5; // rax
_BYTE *i; // rdx
unsigned __int64 v7; // rbp
__int64 v8; // rax
__int64 v9; // r12
__int64 v10; // rdi
__int64 v11; // rdi
__int64 v12; // rdi
__int64 v13; // rax
__int64 v14; // r12
__int64 v15; // rsi
__int64 v17; // rdi
__int64 v18; // rax

v3 = a2;
if ( a2 > 0 )
{
v4 = a2 - 1;
v5 = 0LL;
for ( i = (_BYTE *)(a1 + a2 - 1); !*i; --i )
{
if ( a2 == ++v5 )
return out("{ 0 }");
}
if ( v5 > 254 && 4 * v5 >= a2 )
{
v7 = v5 & 0xFFFFFFFFFFFFFFF8LL;
v8 = outstringsize(a1, a2);
if ( !forcehex && 2 * v8 <= 3 * a2 )
{
v3 = a2 - v7;
beginblock(1LL);
if ( (__int64)(a2 - v7) <= 0 )
{
LABEL_13:
v12 = strf("0x00 x %ld", v7);
outcomment(v12);
return endblock();
}
LABEL_10:
v9 = 0LL;
do
{
v10 = *(unsigned __int8 *)(a1 + v9++);
v11 = strchar(v10);
out(v11);
}
while ( v9 < v3 );
if ( !v7 )
return endblock();
goto LABEL_13;
}
v3 = a2 - v7;
beginblock(1LL);
if ( (__int64)(a2 - v7) <= 0 )
{
LABEL_24:
v17 = strf("0x00 x %d", v7);
outcomment(v17);
return endblock();
}
LABEL_19:
v14 = 0LL;
do
{
v15 = *(unsigned __int8 *)(a1 + v14++);
outf("0x%02X", v15);
}
while ( v14 < v3 );
if ( !v7 )
return endblock();
goto LABEL_24;
}
v13 = outstringsize(a1, a2);
if ( forcehex || 2 * v13 > 3 * a2 )
{
v7 = 0LL;
beginblock(1LL);
goto LABEL_19;
}
if ( *(_BYTE *)(a1 + a2 - 1) )
{
v7 = 0LL;
beginblock(1LL);
goto LABEL_10;
}
return outstring(a1, v4);
}
if ( a2 )
{
v18 = ((__int64 (*)(void))outstringsize)();
if ( forcehex || 3 * a2 < 2 * v18 || (v4 = a2 - 1, *(_BYTE *)(a1 + a2 - 1)) )
{
beginblock(1LL);
return endblock();
}
return outstring(a1, v4);
}
return out("{ 0 }");
}

original_code:
static void outbytes(void const *ptr, long size, int ndx)
{
    unsigned char const *bytes = ptr;
    long zeroes, n;
    long i;
    (void)ndx;
    for (zeroes = 0 ; zeroes < size && !bytes[size - zeroes - 1] ; ++zeroes) ;
    if (zeroes == size) {
 out("{ 0 }");
 return;
    }
    if (zeroes < 255 || zeroes * 4 < size)
 zeroes = 0;
    zeroes &= ~7;
    n = outstringsize((char const*)bytes, size);
    if (forcehex || n * 2 > size * 3) {
 beginblock(1);
 for (i = 0 ; i < size - zeroes ; ++i)
     outf("0x%02X", bytes[i]);
 if (zeroes)
     outcomment(strf("0x00 x %d", zeroes));
 endblock();
    } else if (zeroes || bytes[size - 1]) {
 beginblock(1);
 for (i = 0 ; i < size - zeroes ; ++i)
     (out(strchar(bytes[i])));
 if (zeroes)
     outcomment(strf("0x00 x %ld", zeroes));
 endblock();
    } else {
 outstring((char const*)bytes, size - 1);
    }
}

canonical_original_code:
static void outbytes(void *ptr, long size, int ndx)
{
    unsigned char *bytes = ptr;
    long zeroes; long n;
    long i;
    (void)ndx;
    for (zeroes = 0 ; zeroes < size && !bytes[size - zeroes - 1] ; ++zeroes) ;
    if (zeroes == size) {
 out("{ 0 }");
 return;
    }
    if (zeroes < 255 || zeroes * 4 < size)
 zeroes = 0;
    zeroes &= ~7;
    n = outstringsize((char *)bytes, size);
    if (forcehex || n * 2 > size * 3) {
 beginblock(1);
 for (i = 0 ; i < size - zeroes ; ++i)
     outf("0x%02X", bytes[i]);
 if (zeroes)
     outcomment(strf("0x00 x %d", zeroes));
 endblock();
    } else if (zeroes || bytes[size - 1]) {
 beginblock(1);
 for (i = 0 ; i < size - zeroes ; ++i)
     (out(strchar(bytes[i])));
 if (zeroes)
     outcomment(strf("0x00 x %ld", zeroes));
 endblock();
    } else {
 outstring((char *)bytes, size - 1);
    }
}

variable_types:
bytes
unsigned char *

variable_types: n long


forcehexbytes

decompiled_code:
void forcehexbytes()
{
forcehex = 1;
}

canonical_decompiled_code:
void func8()
{
forcehex = 1;
}

original_code:
void forcehexbytes(void)
{
    forcehex = 1;
}

canonical_original_code:
void forcehexbytes()
{
    forcehex = 1;
}


outtypedblock

decompiled_code:
__int64 __fastcall outtypedblock(int a1, __int64 a2, unsigned __int64 a3, unsigned int a4)
{
__int64 v5; // rbp
__int64 result; // rax
unsigned __int64 v7[4]; // [rsp+8h] [rbp-20h] BYREF

v7[0] = a3;
v5 = getptrto(a2, v7);
if ( (unsigned int)iself64() )
result = ((__int64 (__fastcall *)(__int64, unsigned __int64, unsigned int))outputfunctions64[a1])(v5, v7[0], a4);
else
result = ((__int64 (__fastcall *)(__int64, unsigned __int64, unsigned int))outputfunctions32[a1])(v5, v7[0], a4);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(int a1, __int64 a2, unsigned __int64 a3, unsigned int a4)
{
__int64 v5; // rbp
__int64 result; // rax
unsigned __int64 v7[4]; // [rsp+8h] [rbp-20h] BYREF

v7[0] = a3;
v5 = getptrto(a2, v7);
if ( (unsigned int)iself64() )
result = ((__int64 (__fastcall *)(__int64, unsigned __int64, unsigned int))outputfunctions64[a1])(v5, v7[0], a4);
else
result = ((__int64 (__fastcall *)(__int64, unsigned __int64, unsigned int))outputfunctions32[a1])(v5, v7[0], a4);
return result;
}

original_code:
void outtypedblock(int type, long offset, long size, int ndx)
{
    void const *ptr;
    ptr = getptrto(offset, &size);
    if (iself64())
 outputfunctions64[type](ptr, size, ndx);
    else
 outputfunctions32[type](ptr, size, ndx);
}

canonical_original_code:
void outtypedblock(int type, long offset, long size, int ndx)
{
    void *ptr;
    ptr = getptrto(offset, &size);
    if (iself64())
 outputfunctions64[type](ptr, size, ndx);
    else
 outputfunctions32[type](ptr, size, ndx);
}

variable_types: type int

variable_types: offset long


output

decompiled_code:
__int64 output()
{
out("#include <stddef.h>\n");
out("#include <elf.h>\n");
out("\n");
outputaddresses();
outputenum();
outputstruct();
return outputpieces();
}

canonical_decompiled_code:
__int64 func10()
{
out("#include <stddef.h>\n");
out("#include <elf.h>\n");
out("\n");
outputaddresses();
outputenum();
outputstruct();
return outputpieces();
}

original_code:
void output(void)
{
    out("#include <stddef.h>\n");
    out("#include <elf.h>\n");
    out("\n");
    outputaddresses();
    outputenum();
    outputstruct();
    outputpieces();
}

canonical_original_code:
void output()
{
    out("#include <stddef.h>\n");
    out("#include <elf.h>\n");
    out("\n");
    outputaddresses();
    outputenum();
    outputstruct();
    outputpieces();
}


prognew

decompiled_code:
__int64 __fastcall prognew(__int64 a1)
{
*(_DWORD *)(a1 + 32) = 1;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
*(_DWORD *)(a1 + 32) = 1;
return 1LL;
}

original_code:
static _Bool prognew(elfpart *part)
{
    part->shtype = 1;
    return 1;
}

canonical_original_code:
static _Bool prognew(struct elfpart *part)
{
    part->shtype = 1;
    return 1;
}

variable_types: struct elfpart { _Bool (*new)(struct elfpart *); _Bool (*init)(struct elfpart *, struct blueprint { int filetype; int partcount; struct elfpart *parts; } *); _Bool (*fill)(struct elfpart *, struct blueprint *); _Bool (*complete)(struct elfpart *, struct blueprint *); int shtype; int entsize; int count; int size; void *part; char *shname; unsigned long offset; long addr; struct elfpart *link; int info; short flags; _Bool done; } *

user_defined_types: struct elfpart { _Bool (*new)(struct elfpart *); _Bool (*init)(struct elfpart *, struct blueprint *); _Bool (*fill)(struct elfpart *, struct blueprint *); _Bool (*complete)(struct elfpart *, struct blueprint *); int shtype; int entsize; int count; int size; void *part; char *shname; unsigned long offset; long addr; struct elfpart *link; int info; short flags; _Bool done; }


textnew

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

*(_DWORD *)(a1 + 32) = 1;
*(_WORD *)(a1 + 92) = 5;
result = 1LL;
*(_QWORD *)(a1 + 56) = ".text";
return result;
}

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

*(_DWORD *)(a1 + 32) = 1;
*(_WORD *)(a1 + 92) = 5;
result = 1LL;
*(_QWORD *)(a1 + 56) = ".text";
return result;
}

original_code:
static _Bool textnew(elfpart *part)
{
    part->shtype = 1;
    part->flags = (1 << 2) | (1 << 0);
    part->shname = ".text";
    return 1;
}

canonical_original_code:
static _Bool textnew(struct elfpart *part)
{
    part->shtype = 1;
    part->flags = (1 << 2) | (1 << 0);
    part->shname = ".text";
    return 1;
}

user_defined_types: struct blueprint { int filetype; int partcount; struct elfpart *parts; }


datanew

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

*(_DWORD *)(a1 + 32) = 1;
*(_WORD *)(a1 + 92) = 6;
result = 1LL;
*(_QWORD *)(a1 + 56) = ".data";
return result;
}

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

*(_DWORD *)(a1 + 32) = 1;
*(_WORD *)(a1 + 92) = 6;
result = 1LL;
*(_QWORD *)(a1 + 56) = ".data";
return result;
}

original_code:
static _Bool datanew(elfpart *part)
{
    part->shtype = 1;
    part->flags = (1 << 2) | (1 << 1);
    part->shname = ".data";
    return 1;
}

canonical_original_code:
static _Bool datanew(struct elfpart *part)
{
    part->shtype = 1;
    part->flags = (1 << 2) | (1 << 1);
    part->shname = ".data";
    return 1;
}


rodatanew

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

*(_DWORD *)(a1 + 32) = 1;
*(_WORD *)(a1 + 92) = 4;
result = 1LL;
*(_QWORD *)(a1 + 56) = ".rodata";
return result;
}

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

*(_DWORD *)(a1 + 32) = 1;
*(_WORD *)(a1 + 92) = 4;
result = 1LL;
*(_QWORD *)(a1 + 56) = ".rodata";
return result;
}

original_code:
static _Bool rodatanew(elfpart *part)
{
    part->shtype = 1;
    part->flags = (1 << 2);
    part->shname = ".rodata";
    return 1;
}

canonical_original_code:
static _Bool rodatanew(struct elfpart *part)
{
    part->shtype = 1;
    part->flags = (1 << 2);
    part->shname = ".rodata";
    return 1;
}


enforcevalidation

decompiled_code:
void __fastcall enforcevalidation(char a1)
{
dieoninvalid = a1;
}

canonical_decompiled_code:
void __fastcall func1(char a1)
{
dieoninvalid = a1;
}

original_code:
void enforcevalidation(_Bool flag)
{
    dieoninvalid = flag;
}


getlasterror

decompiled_code:
__int64 getlasterror()
{
return errormessage;
}

canonical_decompiled_code:
__int64 func2()
{
return errormessage;
}

original_code:
char const *getlasterror(void)
{
    return errormessage;
}

canonical_original_code:
char *getlasterror()
{
    return errormessage;
}

return_type: char *


newparts

decompiled_code:
__int64 __fastcall newparts(__int64 a1)
{
int v2; // edx
bool v3; // di
_QWORD *v4; // rbx

v2 = *(_DWORD *)(a1 + 4);
v3 = 0;
if ( v2 > 0 )
v3 = *(_QWORD *)(a1 + 8) != 0LL;
if ( (unsigned int)validate(v3, "empty blueprint") )
{
v4 = *(_QWORD **)(a1 + 8);
if ( *(int *)(a1 + 4) <= 0 )
return 1LL;
while ( !*v4 || ((unsigned __int8 (__fastcall *)(_QWORD *))*v4)(v4) )
{
v4 += 12;
if ( (__int64)(0xAAAAAAAAAAAAAAABLL * (((__int64)v4 - *(_QWORD *)(a1 + 8)) >> 5)) >= *(int *)(a1 + 4) )
return 1LL;
}
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
int v2; // edx
bool v3; // di
_QWORD *v4; // rbx

v2 = *(_DWORD *)(a1 + 4);
v3 = 0;
if ( v2 > 0 )
v3 = *(_QWORD *)(a1 + 8) != 0LL;
if ( (unsigned int)func3(v3, "empty blueprint") )
{
v4 = *(_QWORD **)(a1 + 8);
if ( *(int *)(a1 + 4) <= 0 )
return 1LL;
while ( !*v4 || ((unsigned __int8 (__fastcall *)(_QWORD *))*v4)(v4) )
{
v4 += 12;
if ( (__int64)(0xAAAAAAAAAAAAAAABLL * (((__int64)v4 - *(_QWORD *)(a1 + 8)) >> 5)) >= *(int *)(a1 + 4) )
return 1LL;
}
}
return 0LL;
}

original_code:
_Bool newparts(blueprint *bp)
{
    if (!_validate(bp->partcount > 0 && bp->parts, "empty blueprint"))
        return 0;
    for (elfpart *(part) = (bp)->parts ; (part) - (bp)->parts < (bp)->partcount ; ++(part)) {
        if (part->new)
            if (!(*part->new)(part))
                return 0;
    }
    return 1;
}

canonical_original_code:
_Bool newparts(struct blueprint *bp)
{
    if (!_validate(bp->partcount > 0 && bp->parts, "empty blueprint"))
        return 0;
    for (elfpart *(part) = (bp)->parts ; (part) - (bp)->parts < (bp)->partcount ; ++(part)) {
        if (part->new)
            if (!(*part->new)(part))
                return 0;
    }
    return 1;
}

variable_types: struct blueprint { int filetype; int partcount; struct elfpart { _Bool (*new)(struct elfpart *); _Bool (*init)(struct elfpart *, struct blueprint *); _Bool (*fill)(struct elfpart *, struct blueprint *); _Bool (*complete)(struct elfpart *, struct blueprint *); int shtype; int entsize; int count; int size; void *part; char *shname; unsigned long offset; long addr; struct elfpart *link; int info; short flags; _Bool done; } *parts; } *


initparts

decompiled_code:
bool __fastcall initparts(__int64 a1)
{
signed __int64 v1; // rsi
__int64 v2; // rcx
signed __int64 v3; // rdx
int v4; // er12
bool v5; // al
__int64 v6; // r13
int v7; // ebx

v1 = *(_QWORD *)(a1 + 8);
v2 = *(int *)(a1 + 4);
v3 = v1;
v4 = *(_DWORD *)(a1 + 4);
if ( v2 > 0 )
{
do
{
v5 = 1;
if ( *(_DWORD *)(v3 + 32) )
v5 = *(_QWORD *)(v3 + 8) == 0LL;
*(_BYTE *)(v3 + 94) = v5;
v3 += 96LL;
}
while ( (__int64)(0xAAAAAAAAAAAAAAABLL * ((v3 - v1) >> 5)) < v2 );
}
while ( 2 )
{
if ( !v4 )
return 1;
v6 = *(_QWORD *)(a1 + 8);
if ( *(int *)(a1 + 4) <= 0 )
return (unsigned int)validate(v4 > 0, "mutually dependent ELF parts in initparts()") != 0;
v7 = 0;
do
{
if ( !*(_BYTE *)(v6 + 94) )
{
if ( !(*(unsigned __int8 (__fastcall **)(__int64, __int64, signed __int64))(v6 + 8))(v6, a1, v3) )
return 0;
v7 += *(_BYTE *)(v6 + 94) == 0;
}
v6 += 96LL;
v3 = *(int *)(a1 + 4);
}
while ( (__int64)(0xAAAAAAAAAAAAAAABLL * ((v6 - *(_QWORD *)(a1 + 8)) >> 5)) < v3 );
if ( (unsigned int)validate(v7 < v4, "mutually dependent ELF parts in initparts()") )
{
v4 = v7;
continue;
}
break;
}
return 0;
}

canonical_decompiled_code:
bool __fastcall func6(__int64 a1)
{
signed __int64 v1; // rsi
__int64 v2; // rcx
signed __int64 v3; // rdx
int v4; // er12
bool v5; // al
__int64 v6; // r13
int v7; // ebx

v1 = *(_QWORD *)(a1 + 8);
v2 = *(int *)(a1 + 4);
v3 = v1;
v4 = *(_DWORD *)(a1 + 4);
if ( v2 > 0 )
{
do
{
v5 = 1;
if ( *(_DWORD *)(v3 + 32) )
v5 = *(_QWORD *)(v3 + 8) == 0LL;
*(_BYTE *)(v3 + 94) = v5;
v3 += 96LL;
}
while ( (__int64)(0xAAAAAAAAAAAAAAABLL * ((v3 - v1) >> 5)) < v2 );
}
while ( 2 )
{
if ( !v4 )
return 1;
v6 = *(_QWORD *)(a1 + 8);
if ( *(int *)(a1 + 4) <= 0 )
return (unsigned int)func3(v4 > 0, "mutually dependent ELF parts in initparts()") != 0;
v7 = 0;
do
{
if ( !*(_BYTE *)(v6 + 94) )
{
if ( !(*(unsigned __int8 (__fastcall **)(__int64, __int64, signed __int64))(v6 + 8))(v6, a1, v3) )
return 0;
v7 += *(_BYTE *)(v6 + 94) == 0;
}
v6 += 96LL;
v3 = *(int *)(a1 + 4);
}
while ( (__int64)(0xAAAAAAAAAAAAAAABLL * ((v6 - *(_QWORD *)(a1 + 8)) >> 5)) < v3 );
if ( (unsigned int)func3(v7 < v4, "mutually dependent ELF parts in initparts()") )
{
v4 = v7;
continue;
}
break;
}
return 0;
}

original_code:
_Bool initparts(blueprint *bp)
{
    int notdone, notdoneprev;
    for (elfpart *(part) = (bp)->parts ; (part) - (bp)->parts < (bp)->partcount ; ++(part))
        part->done = !((part)->shtype != 0) || !part->init;
    notdone = bp->partcount;
    while (notdone) {
        notdoneprev = notdone;
        notdone = 0;
        for (elfpart *(part) = (bp)->parts ; (part) - (bp)->parts < (bp)->partcount ; ++(part)) {
            if (!part->done) {
                if (!(*part->init)(part, bp))
                    return 0;
                if (!part->done)
                    ++notdone;
            }
        }
        if (!_validate(notdone < notdoneprev,
                       "mutually dependent ELF parts in initparts()"))
            return 0;
    }
    return 1;
}

canonical_original_code:
_Bool initparts(struct blueprint *bp)
{
    int notdone; int notdoneprev;
    for (elfpart *(part) = (bp)->parts ; (part) - (bp)->parts < (bp)->partcount ; ++(part))
        part->done = !((part)->shtype != 0) || !part->init;
    notdone = bp->partcount;
    while (notdone) {
        notdoneprev = notdone;
        notdone = 0;
        for (elfpart *(part) = (bp)->parts ; (part) - (bp)->parts < (bp)->partcount ; ++(part)) {
            if (!part->done) {
                if (!(*part->init)(part, bp))
                    return 0;
                if (!part->done)
                    ++notdone;
            }
        }
        if (!_validate(notdone < notdoneprev,
                       "mutually dependent ELF parts in initparts()"))
            return 0;
    }
    return 1;
}

variable_types: notdone int

variable_types: notdoneprev int


fillparts

decompiled_code:
bool __fastcall fillparts(__int64 a1)
{
signed __int64 v1; // rsi
__int64 v2; // rcx
signed __int64 v3; // rdx
int v4; // er12
bool v5; // al
__int64 v6; // r13
int v7; // ebx

v1 = *(_QWORD *)(a1 + 8);
v2 = *(int *)(a1 + 4);
v3 = v1;
v4 = *(_DWORD *)(a1 + 4);
if ( v2 > 0 )
{
do
{
v5 = 1;
if ( *(_DWORD *)(v3 + 32) )
v5 = *(_QWORD *)(v3 + 16) == 0LL;
*(_BYTE *)(v3 + 94) = v5;
v3 += 96LL;
}
while ( (__int64)(0xAAAAAAAAAAAAAAABLL * ((v3 - v1) >> 5)) < v2 );
}
while ( 2 )
{
if ( !v4 )
return 1;
v6 = *(_QWORD *)(a1 + 8);
if ( *(int *)(a1 + 4) <= 0 )
return (unsigned int)validate(v4 > 0, "mutually dependent ELF parts in fillparts()") != 0;
v7 = 0;
do
{
if ( !*(_BYTE *)(v6 + 94) )
{
if ( !(*(unsigned __int8 (__fastcall **)(__int64, __int64, signed __int64))(v6 + 16))(v6, a1, v3) )
return 0;
v7 += *(_BYTE *)(v6 + 94) == 0;
}
v6 += 96LL;
v3 = *(int *)(a1 + 4);
}
while ( (__int64)(0xAAAAAAAAAAAAAAABLL * ((v6 - *(_QWORD *)(a1 + 8)) >> 5)) < v3 );
if ( (unsigned int)validate(v7 < v4, "mutually dependent ELF parts in fillparts()") )
{
v4 = v7;
continue;
}
break;
}
return 0;
}

canonical_decompiled_code:
bool __fastcall func7(__int64 a1)
{
signed __int64 v1; // rsi
__int64 v2; // rcx
signed __int64 v3; // rdx
int v4; // er12
bool v5; // al
__int64 v6; // r13
int v7; // ebx

v1 = *(_QWORD *)(a1 + 8);
v2 = *(int *)(a1 + 4);
v3 = v1;
v4 = *(_DWORD *)(a1 + 4);
if ( v2 > 0 )
{
do
{
v5 = 1;
if ( *(_DWORD *)(v3 + 32) )
v5 = *(_QWORD *)(v3 + 16) == 0LL;
*(_BYTE *)(v3 + 94) = v5;
v3 += 96LL;
}
while ( (__int64)(0xAAAAAAAAAAAAAAABLL * ((v3 - v1) >> 5)) < v2 );
}
while ( 2 )
{
if ( !v4 )
return 1;
v6 = *(_QWORD *)(a1 + 8);
if ( *(int *)(a1 + 4) <= 0 )
return (unsigned int)func3(v4 > 0, "mutually dependent ELF parts in fillparts()") != 0;
v7 = 0;
do
{
if ( !*(_BYTE *)(v6 + 94) )
{
if ( !(*(unsigned __int8 (__fastcall **)(__int64, __int64, signed __int64))(v6 + 16))(v6, a1, v3) )
return 0;
v7 += *(_BYTE *)(v6 + 94) == 0;
}
v6 += 96LL;
v3 = *(int *)(a1 + 4);
}
while ( (__int64)(0xAAAAAAAAAAAAAAABLL * ((v6 - *(_QWORD *)(a1 + 8)) >> 5)) < v3 );
if ( (unsigned int)func3(v7 < v4, "mutually dependent ELF parts in fillparts()") )
{
v4 = v7;
continue;
}
break;
}
return 0;
}

original_code:
_Bool fillparts(blueprint *bp)
{
    int notdone, notdoneprev;
    for (elfpart *(part) = (bp)->parts ; (part) - (bp)->parts < (bp)->partcount ; ++(part))
        part->done = !((part)->shtype != 0) || !part->fill;
    notdone = bp->partcount;
    while (notdone) {
        notdoneprev = notdone;
        notdone = 0;
        for (elfpart *(part) = (bp)->parts ; (part) - (bp)->parts < (bp)->partcount ; ++(part)) {
            if (!part->done) {
                if (!(*part->fill)(part, bp))
                    return 0;
                if (!part->done)
                    ++notdone;
            }
        }
        if (!_validate(notdone < notdoneprev,
                       "mutually dependent ELF parts in fillparts()"))
            return 0;
    }
    return 1;
}

canonical_original_code:
_Bool fillparts(struct blueprint *bp)
{
    int notdone; int notdoneprev;
    for (elfpart *(part) = (bp)->parts ; (part) - (bp)->parts < (bp)->partcount ; ++(part))
        part->done = !((part)->shtype != 0) || !part->fill;
    notdone = bp->partcount;
    while (notdone) {
        notdoneprev = notdone;
        notdone = 0;
        for (elfpart *(part) = (bp)->parts ; (part) - (bp)->parts < (bp)->partcount ; ++(part)) {
            if (!part->done) {
                if (!(*part->fill)(part, bp))
                    return 0;
                if (!part->done)
                    ++notdone;
            }
        }
        if (!_validate(notdone < notdoneprev,
                       "mutually dependent ELF parts in fillparts()"))
            return 0;
    }
    return 1;
}


measureparts

original_code:
void measureparts(blueprint *bp)
{
    intptr_t off;
    off = 0;
    for (elfpart *(part) = (bp)->parts ; (part) - (bp)->parts < (bp)->partcount ; ++(part)) {
 if (((part)->shtype != 0)) {
     if (part->entsize)
  part->size = part->count * part->entsize;
     part->offset = off;
     off = (((off + part->size) + (sizeof(Elf64_Addr) - 1)) & ~(sizeof(Elf64_Addr) - 1));
        }
    }
    if (bp->filetype != 1) {
 off = 0;
        for (elfpart *(part) = (bp)->parts ; (part) - (bp)->parts < (bp)->partcount ; ++(part)) {
     if (part->flags) {
  part->addr = part->offset;
  if (!(part->flags & (1 << 1))) {
      if (off < part->addr + part->size)
   off = part->addr + part->size;
  }
            }
 }
 off = (((off) + (0x1000 - 1)) & ~(0x1000 - 1));
        for (elfpart *(part) = (bp)->parts ; (part) - (bp)->parts < (bp)->partcount ; ++(part))
     if (part->flags & (1 << 1))
  part->addr += off;
 if (bp->filetype == 2) {
            for (elfpart *(part) = (bp)->parts ; (part) - (bp)->parts < (bp)->partcount ; ++(part))
  if (part->flags)
      part->addr += loadaddr;
 }
    }
}

canonical_original_code:
void measureparts(struct blueprint *bp)
{
    long off;
    off = 0;
    for (elfpart *(part) = (bp)->parts ; (part) - (bp)->parts < (bp)->partcount ; ++(part)) {
 if (((part)->shtype != 0)) {
     if (part->entsize)
  part->size = part->count * part->entsize;
     part->offset = off;
     off = (((off + part->size) + (sizeof(Elf64_Addr) - 1)) & ~(sizeof(Elf64_Addr) - 1));
        }
    }
    if (bp->filetype != 1) {
 off = 0;
        for (elfpart *(part) = (bp)->parts ; (part) - (bp)->parts < (bp)->partcount ; ++(part)) {
     if (part->flags) {
  part->addr = part->offset;
  if (!(part->flags & (1 << 1))) {
      if (off < part->addr + part->size)
   off = part->addr + part->size;
  }
            }
 }
 off = (((off) + (0x1000 - 1)) & ~(0x1000 - 1));
        for (elfpart *(part) = (bp)->parts ; (part) - (bp)->parts < (bp)->partcount ; ++(part))
     if (part->flags & (1 << 1))
  part->addr += off;
 if (bp->filetype == 2) {
            for (elfpart *(part) = (bp)->parts ; (part) - (bp)->parts < (bp)->partcount ; ++(part))
  if (part->flags)
      part->addr += loadaddr;
 }
    }
}

variable_types: off long


completeparts

decompiled_code:
bool __fastcall completeparts(__int64 a1)
{
signed __int64 v1; // rsi
__int64 v2; // rcx
signed __int64 v3; // rdx
int v4; // er12
bool v5; // al
__int64 v6; // r13
int v7; // ebx

v1 = *(_QWORD *)(a1 + 8);
v2 = *(int *)(a1 + 4);
v3 = v1;
v4 = *(_DWORD *)(a1 + 4);
if ( v2 > 0 )
{
do
{
v5 = 1;
if ( *(_DWORD *)(v3 + 32) )
v5 = *(_QWORD *)(v3 + 24) == 0LL;
*(_BYTE *)(v3 + 94) = v5;
v3 += 96LL;
}
while ( (__int64)(0xAAAAAAAAAAAAAAABLL * ((v3 - v1) >> 5)) < v2 );
}
while ( 2 )
{
if ( !v4 )
return 1;
v6 = *(_QWORD *)(a1 + 8);
if ( *(int *)(a1 + 4) <= 0 )
return (unsigned int)validate(v4 > 0, "mutually dependent ELF parts in completeparts()") != 0;
v7 = 0;
do
{
if ( !*(_BYTE *)(v6 + 94) )
{
if ( !(*(unsigned __int8 (__fastcall **)(__int64, __int64, signed __int64))(v6 + 24))(v6, a1, v3) )
return 0;
v7 += *(_BYTE *)(v6 + 94) == 0;
}
v6 += 96LL;
v3 = *(int *)(a1 + 4);
}
while ( (__int64)(0xAAAAAAAAAAAAAAABLL * ((v6 - *(_QWORD *)(a1 + 8)) >> 5)) < v3 );
if ( (unsigned int)validate(v7 < v4, "mutually dependent ELF parts in completeparts()") )
{
v4 = v7;
continue;
}
break;
}
return 0;
}

canonical_decompiled_code:
bool __fastcall func9(__int64 a1)
{
signed __int64 v1; // rsi
__int64 v2; // rcx
signed __int64 v3; // rdx
int v4; // er12
bool v5; // al
__int64 v6; // r13
int v7; // ebx

v1 = *(_QWORD *)(a1 + 8);
v2 = *(int *)(a1 + 4);
v3 = v1;
v4 = *(_DWORD *)(a1 + 4);
if ( v2 > 0 )
{
do
{
v5 = 1;
if ( *(_DWORD *)(v3 + 32) )
v5 = *(_QWORD *)(v3 + 24) == 0LL;
*(_BYTE *)(v3 + 94) = v5;
v3 += 96LL;
}
while ( (__int64)(0xAAAAAAAAAAAAAAABLL * ((v3 - v1) >> 5)) < v2 );
}
while ( 2 )
{
if ( !v4 )
return 1;
v6 = *(_QWORD *)(a1 + 8);
if ( *(int *)(a1 + 4) <= 0 )
return (unsigned int)func3(v4 > 0, "mutually dependent ELF parts in completeparts()") != 0;
v7 = 0;
do
{
if ( !*(_BYTE *)(v6 + 94) )
{
if ( !(*(unsigned __int8 (__fastcall **)(__int64, __int64, signed __int64))(v6 + 24))(v6, a1, v3) )
return 0;
v7 += *(_BYTE *)(v6 + 94) == 0;
}
v6 += 96LL;
v3 = *(int *)(a1 + 4);
}
while ( (__int64)(0xAAAAAAAAAAAAAAABLL * ((v6 - *(_QWORD *)(a1 + 8)) >> 5)) < v3 );
if ( (unsigned int)func3(v7 < v4, "mutually dependent ELF parts in completeparts()") )
{
v4 = v7;
continue;
}
break;
}
return 0;
}

original_code:
_Bool completeparts(blueprint *bp)
{
    int notdone, notdoneprev;
    for (elfpart *(part) = (bp)->parts ; (part) - (bp)->parts < (bp)->partcount ; ++(part))
        part->done = !((part)->shtype != 0) || !part->complete;
    notdone = bp->partcount;
    while (notdone) {
        notdoneprev = notdone;
        notdone = 0;
        for (elfpart *(part) = (bp)->parts ; (part) - (bp)->parts < (bp)->partcount ; ++(part)) {
            if (!part->done) {
                if (!(*part->complete)(part, bp))
                    return 0;
                if (!part->done)
                    ++notdone;
            }
        }
        if (!_validate(notdone < notdoneprev,
                       "mutually dependent ELF parts in completeparts()"))
            return 0;
    }
    return 1;
}

canonical_original_code:
_Bool completeparts(struct blueprint *bp)
{
    int notdone; int notdoneprev;
    for (elfpart *(part) = (bp)->parts ; (part) - (bp)->parts < (bp)->partcount ; ++(part))
        part->done = !((part)->shtype != 0) || !part->complete;
    notdone = bp->partcount;
    while (notdone) {
        notdoneprev = notdone;
        notdone = 0;
        for (elfpart *(part) = (bp)->parts ; (part) - (bp)->parts < (bp)->partcount ; ++(part)) {
            if (!part->done) {
                if (!(*part->complete)(part, bp))
                    return 0;
                if (!part->done)
                    ++notdone;
            }
        }
        if (!_validate(notdone < notdoneprev,
                       "mutually dependent ELF parts in completeparts()"))
            return 0;
    }
    return 1;
}


setshdrstrs

decompiled_code:
__int64 __fastcall setshdrstrs(__int64 a1, int a2, int a3)
{
__int64 v3; // rbx
int v4; // eax
int v5; // er8
__int64 result; // rax

v3 = a3;
v4 = a3;
if ( a2 >= a3 )
v4 = a2;
v5 = validate(*(_DWORD *)(a1 + 4) > v4, "invalid index in setshdrstrs()");
result = 0LL;
if ( v5 )
{
*(_QWORD *)(*(_QWORD *)(a1 + 8) + 96LL * a2 + 80) = *(_QWORD *)(a1 + 8) + 96 * v3;
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, int a2, int a3)
{
__int64 v3; // rbx
int v4; // eax
int v5; // er8
__int64 result; // rax

v3 = a3;
v4 = a3;
if ( a2 >= a3 )
v4 = a2;
v5 = func3(*(_DWORD *)(a1 + 4) > v4, "invalid index in setshdrstrs()");
result = 0LL;
if ( v5 )
{
*(_QWORD *)(*(_QWORD *)(a1 + 8) + 96LL * a2 + 80) = *(_QWORD *)(a1 + 8) + 96 * v3;
result = 1LL;
}
return result;
}

original_code:
_Bool setshdrstrs(blueprint *bp, int shdrsindex, int strsindex)
{
    if (!_validate(shdrsindex < bp->partcount && strsindex < bp->partcount,
                   "invalid index in setshdrstrs()"))
        return 0;
    bp->parts[shdrsindex].link = &bp->parts[strsindex];
    return 1;
}

canonical_original_code:
_Bool setshdrstrs(struct blueprint *bp, int shdrsindex, int strsindex)
{
    if (!_validate(shdrsindex < bp->partcount && strsindex < bp->partcount,
                   "invalid index in setshdrstrs()"))
        return 0;
    bp->parts[shdrsindex].link = &bp->parts[strsindex];
    return 1;
}

variable_types: shdrsindex int

variable_types: strsindex int


sethashsyms

decompiled_code:
__int64 __fastcall sethashsyms(__int64 a1, int a2, int a3)
{
__int64 v3; // rbx
int v4; // eax
int v5; // er8
__int64 result; // rax

v3 = a3;
v4 = a3;
if ( a2 >= a3 )
v4 = a2;
v5 = validate(*(_DWORD *)(a1 + 4) > v4, "invalid index in sethashsyms()");
result = 0LL;
if ( v5 )
{
*(_QWORD *)(*(_QWORD *)(a1 + 8) + 96LL * a2 + 80) = *(_QWORD *)(a1 + 8) + 96 * v3;
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, int a2, int a3)
{
__int64 v3; // rbx
int v4; // eax
int v5; // er8
__int64 result; // rax

v3 = a3;
v4 = a3;
if ( a2 >= a3 )
v4 = a2;
v5 = func3(*(_DWORD *)(a1 + 4) > v4, "invalid index in sethashsyms()");
result = 0LL;
if ( v5 )
{
*(_QWORD *)(*(_QWORD *)(a1 + 8) + 96LL * a2 + 80) = *(_QWORD *)(a1 + 8) + 96 * v3;
result = 1LL;
}
return result;
}

original_code:
_Bool sethashsyms(blueprint *bp, int hashindex, int symsindex)
{
    if (!_validate(hashindex < bp->partcount && symsindex < bp->partcount,
                   "invalid index in sethashsyms()"))
        return 0;
    bp->parts[hashindex].link = &bp->parts[symsindex];
    return 1;
}

canonical_original_code:
_Bool sethashsyms(struct blueprint *bp, int hashindex, int symsindex)
{
    if (!_validate(hashindex < bp->partcount && symsindex < bp->partcount,
                   "invalid index in sethashsyms()"))
        return 0;
    bp->parts[hashindex].link = &bp->parts[symsindex];
    return 1;
}

variable_types: hashindex int

variable_types: symsindex int


setsymstrings

decompiled_code:
__int64 __fastcall setsymstrings(__int64 a1, int a2, int a3)
{
__int64 v3; // rbx
int v4; // eax
int v5; // er8
__int64 result; // rax

v3 = a3;
v4 = a3;
if ( a2 >= a3 )
v4 = a2;
v5 = validate(*(_DWORD *)(a1 + 4) > v4, "invalid index in setsymstrings()");
result = 0LL;
if ( v5 )
{
*(_QWORD *)(*(_QWORD *)(a1 + 8) + 96LL * a2 + 80) = *(_QWORD *)(a1 + 8) + 96 * v3;
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, int a2, int a3)
{
__int64 v3; // rbx
int v4; // eax
int v5; // er8
__int64 result; // rax

v3 = a3;
v4 = a3;
if ( a2 >= a3 )
v4 = a2;
v5 = func3(*(_DWORD *)(a1 + 4) > v4, "invalid index in setsymstrings()");
result = 0LL;
if ( v5 )
{
*(_QWORD *)(*(_QWORD *)(a1 + 8) + 96LL * a2 + 80) = *(_QWORD *)(a1 + 8) + 96 * v3;
result = 1LL;
}
return result;
}

original_code:
_Bool setsymstrings(blueprint *bp, int symsindex, int strsindex)
{
    if (!_validate(symsindex < bp->partcount && strsindex < bp->partcount,
                   "invalid index in setsymstrings()"))
        return 0;
    bp->parts[symsindex].link = &bp->parts[strsindex];
    return 1;
}

canonical_original_code:
_Bool setsymstrings(struct blueprint *bp, int symsindex, int strsindex)
{
    if (!_validate(symsindex < bp->partcount && strsindex < bp->partcount,
                   "invalid index in setsymstrings()"))
        return 0;
    bp->parts[symsindex].link = &bp->parts[strsindex];
    return 1;
}


setrelsyms

decompiled_code:
__int64 __fastcall setrelsyms(__int64 a1, int a2, int a3)
{
__int64 v3; // rbx
int v4; // eax
int v5; // er8
__int64 result; // rax

v3 = a3;
v4 = a3;
if ( a2 >= a3 )
v4 = a2;
v5 = validate(*(_DWORD *)(a1 + 4) > v4, "invalid index in setrelsyms()");
result = 0LL;
if ( v5 )
{
*(_QWORD *)(*(_QWORD *)(a1 + 8) + 96LL * a2 + 80) = *(_QWORD *)(a1 + 8) + 96 * v3;
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, int a2, int a3)
{
__int64 v3; // rbx
int v4; // eax
int v5; // er8
__int64 result; // rax

v3 = a3;
v4 = a3;
if ( a2 >= a3 )
v4 = a2;
v5 = func3(*(_DWORD *)(a1 + 4) > v4, "invalid index in setrelsyms()");
result = 0LL;
if ( v5 )
{
*(_QWORD *)(*(_QWORD *)(a1 + 8) + 96LL * a2 + 80) = *(_QWORD *)(a1 + 8) + 96 * v3;
result = 1LL;
}
return result;
}

original_code:
_Bool setrelsyms(blueprint *bp, int relindex, int symsindex)
{
    if (!_validate(relindex < bp->partcount && symsindex < bp->partcount,
                   "invalid index in setrelsyms()"))
        return 0;
    bp->parts[relindex].link = &bp->parts[symsindex];
    return 1;
}

canonical_original_code:
_Bool setrelsyms(struct blueprint *bp, int relindex, int symsindex)
{
    if (!_validate(relindex < bp->partcount && symsindex < bp->partcount,
                   "invalid index in setrelsyms()"))
        return 0;
    bp->parts[relindex].link = &bp->parts[symsindex];
    return 1;
}

variable_types: relindex int


setrelsection

decompiled_code:
__int64 __fastcall setrelsection(__int64 a1, int a2, int a3)
{
int v3; // eax
int v5; // er8
__int64 result; // rax

v3 = a3;
if ( a2 >= a3 )
v3 = a2;
v5 = validate(*(_DWORD *)(a1 + 4) > v3, "invalid index in setrelsection()");
result = 0LL;
if ( v5 )
{
*(_DWORD *)(*(_QWORD *)(a1 + 8) + 96LL * a2 + 88) = a3;
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1, int a2, int a3)
{
int v3; // eax
int v5; // er8
__int64 result; // rax

v3 = a3;
if ( a2 >= a3 )
v3 = a2;
v5 = func3(*(_DWORD *)(a1 + 4) > v3, "invalid index in setrelsection()");
result = 0LL;
if ( v5 )
{
*(_DWORD *)(*(_QWORD *)(a1 + 8) + 96LL * a2 + 88) = a3;
result = 1LL;
}
return result;
}

original_code:
_Bool setrelsection(blueprint *bp, int relindex, int sectindex)
{
    if (!_validate(relindex < bp->partcount && sectindex < bp->partcount,
                   "invalid index in setrelsection()"))
        return 0;
    bp->parts[relindex].info = sectindex;
    return 1;
}

canonical_original_code:
_Bool setrelsection(struct blueprint *bp, int relindex, int sectindex)
{
    if (!_validate(relindex < bp->partcount && sectindex < bp->partcount,
                   "invalid index in setrelsection()"))
        return 0;
    bp->parts[relindex].info = sectindex;
    return 1;
}

variable_types: sectindex int


setexecentry

decompiled_code:
__int64 __fastcall setexecentry(__int64 a1, __int64 a2)
{
__int64 result; // rax

result = *(_QWORD *)(*(_QWORD *)(a1 + 8) + 48LL);
*(_QWORD *)(result + 24) = a2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1, __int64 a2)
{
__int64 result; // rax

result = *(_QWORD *)(*(_QWORD *)(a1 + 8) + 48LL);
*(_QWORD *)(result + 24) = a2;
return result;
}

original_code:
void setexecentry(blueprint *bp, intptr_t addr)
{
    ((Elf64_Ehdr*)((bp)->parts[0].part))->e_entry = addr;
}

canonical_original_code:
void setexecentry(struct blueprint *bp, long addr)
{
    ((struct Elf64_Ehdr *)((bp)->parts[0].part))->e_entry = addr;
}

variable_types: addr long

user_defined_types: struct Elf64_Ehdr { unsigned char e_ident[-1]; unsigned short e_type; unsigned short e_machine; unsigned int e_version; unsigned long e_entry; unsigned long e_phoff; unsigned long e_shoff; unsigned int e_flags; unsigned short e_ehsize; unsigned short e_phentsize; unsigned short e_phnum; unsigned short e_shentsize; unsigned short e_shnum; unsigned short e_shstrndx; }


outputelf

original_code:
static void outputelf(void)
{
    long pos;
    int i;
    destfile = fopen(outputfile, "wb");
    if (!destfile)
 ferr();
    pos = 0;
    for (i = 0 ; i < piececount ; ++i) {
 for ( ; pos < pieces[i].offset ; ++pos)
     fputc(0, destfile);
 pieces[i].output();
 pos += pieces[i].size;
    }
    if (fclose(destfile))
 ferr();
    destfile = ((void *)0);
}

canonical_original_code:
static void outputelf()
{
    long pos;
    int i;
    destfile = fopen(outputfile, "wb");
    if (!destfile)
 ferr();
    pos = 0;
    for (i = 0 ; i < piececount ; ++i) {
 for ( ; pos < pieces[i].offset ; ++pos)
     fputc(0, destfile);
 pieces[i].output();
 pos += pieces[i].size;
    }
    if (fclose(destfile))
 ferr();
    destfile = ((void *)0);
}

variable_types: pos long

variable_types: i int


dyncmp

decompiled_code:
__int64 __fastcall dyncmp(const void *a1, const void *a2)
{
return (unsigned int)*(_QWORD *)a1 - *(_DWORD *)a2;
}

canonical_decompiled_code:
__int64 __fastcall func0(const void *a1, const void *a2)
{
return (unsigned int)*(_QWORD *)a1 - *(_DWORD *)a2;
}

original_code:
static int dyncmp(void const *e1, void const *e2)
{
    return ((Elf64_Dyn const*)e1)->d_tag - ((Elf64_Dyn const*)e2)->d_tag;
}

canonical_original_code:
static int dyncmp(void *e1, void *e2)
{
    return ((struct Elf64_Dyn *)e1)->d_tag - ((struct Elf64_Dyn *)e2)->d_tag;
}

return_type: int

user_defined_types: struct Elf64_Dyn { long d_tag; union { unsigned long d_val; unsigned long d_ptr; } d_un; }


dynget

decompiled_code:
__int64 __fastcall dynget(__int64 a1)
{
void *v1; // rax
__int64 v2; // r8
__int64 v4[3]; // [rsp+0h] [rbp-18h] BYREF

v4[0] = a1;
v1 = tfind(v4, &dynvalues, (__compar_fn_t)dyncmp);
v2 = 0LL;
if ( v1 )
v2 = *(_QWORD *)(*(_QWORD *)v1 + 8LL);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
void *v1; // rax
__int64 v2; // r8
__int64 v4[3]; // [rsp+0h] [rbp-18h] BYREF

v4[0] = a1;
v1 = tfind(v4, &dynvalues, (__compar_fn_t)dyncmp);
v2 = 0LL;
if ( v1 )
v2 = *(_QWORD *)(*(_QWORD *)v1 + 8LL);
return v2;
}

original_code:
static unsigned long dynget(long tag)
{
    Elf64_Dyn key;
    Elf64_Dyn const **dyn;
    key.d_tag = tag;
    dyn = tfind(&key, &dynvalues, dyncmp);
    return dyn ? (*dyn)->d_un.d_val : 0;
}

canonical_original_code:
static unsigned long dynget(long tag)
{
    struct Elf64_Dyn key;
    struct Elf64_Dyn **dyn;
    key.d_tag = tag;
    dyn = tfind(&key, &dynvalues, dyncmp);
    return dyn ? (*dyn)->d_un.d_val : 0;
}

variable_types: tag long

variable_types: struct Elf64_Dyn { long d_tag; union { unsigned long d_val; unsigned long d_ptr; } d_un; } **

return_type: unsigned long


warnpartial

decompiled_code:
void __fastcall warnpartial(const char *a1, const char *a2)
{
warn("Dynamic section contains %s but no %s.", a1, a2);
}

canonical_decompiled_code:
void __fastcall func2(const char *a1, const char *a2)
{
warn("Dynamic section contains %s but no %s.", a1, a2);
}

original_code:
static void warnpartial(char const *present, char const *absent)
{
    warn("Dynamic section contains %s but no %s.", present, absent);
}

canonical_original_code:
static void warnpartial(char *present, char *absent)
{
    warn("Dynamic section contains %s but no %s.", present, absent);
}

variable_types:
present
char *

variable_types:
absent
char *


hashdynamicsection

original_code:
void hashdynamicsection(long offset, long size, int ndx)
{
    long i;
    if (!offset || !size)
 return;
    if (iself64()) {
 Elf64_Dyn const *dyns = getptrto(offset, &size);
 for (i = 0 ; (dyns + i) - dyns < size ; ++i) {
     if (dyns[i].d_tag == 0)
  break;
     tsearch(dyns + i, &dynvalues, dyncmp);
 }
    } else {
 Elf32_Dyn const *dyn32s = getptrto(offset, &size);
 Elf64_Dyn *dyns;
 dyns = allocate(size * sizeof(Elf64_Dyn) / sizeof(Elf32_Dyn));
 for (i = 0 ; (dyn32s + i) - dyn32s < size ; ++i) {
     if (dyn32s[i].d_tag == 0)
  break;
     dyns[i].d_tag = dyn32s[i].d_tag;
     dyns[i].d_un.d_val = dyn32s[i].d_un.d_val;
     tsearch(dyns + i, &dynvalues, dyncmp);
 }
    }
    offset = dynget(5);
    size = dynget(10);
    if (offset && size)
 setpiecestrtable(ndx, getaddressoffset(offset), size);
}

canonical_original_code:
void hashdynamicsection(long offset, long size, int ndx)
{
    long i;
    if (!offset || !size)
 return;
    if (iself64()) {
 struct Elf64_Dyn *dyns = getptrto(offset, &size);
 for (i = 0 ; (dyns + i) - dyns < size ; ++i) {
     if (dyns[i].d_tag == 0)
  break;
     tsearch(dyns + i, &dynvalues, dyncmp);
 }
    } else {
 struct Elf32_Dyn *dyn32s = getptrto(offset, &size);
 struct Elf64_Dyn *dyns;
 dyns = allocate(size * sizeof(Elf64_Dyn) / sizeof(Elf32_Dyn));
 for (i = 0 ; (dyn32s + i) - dyn32s < size ; ++i) {
     if (dyn32s[i].d_tag == 0)
  break;
     dyns[i].d_tag = dyn32s[i].d_tag;
     dyns[i].d_un.d_val = dyn32s[i].d_un.d_val;
     tsearch(dyns + i, &dynvalues, dyncmp);
 }
    }
    offset = dynget(5);
    size = dynget(10);
    if (offset && size)
 setpiecestrtable(ndx, getaddressoffset(offset), size);
}

variable_types: offset long

variable_types: size long

variable_types: ndx int

variable_types: i long

variable_types: struct Elf64_Dyn { long d_tag; union { unsigned long d_val; unsigned long d_ptr; } d_un; } *

variable_types: struct Elf32_Dyn { int d_tag; union { unsigned int d_val; unsigned int d_ptr; } d_un; } *


dividedynsegments

decompiled_code:
void dividedynsegments()
{
__int64 v0; // r14
__int64 v1; // r12
__int64 v2; // r15
__int64 v3; // rax
__int64 v4; // rbp
__int64 v5; // r13
__int64 v6; // r13
__int64 v7; // r13
__int64 v8; // r13
__int64 v9; // r13
__int64 v10; // r13
__int64 v11; // r13
__int64 v12; // r13
__int64 v13; // r13
__int64 v14; // rax
int v15; // eax
int v16; // er13
__int64 v17; // r13
int v18; // eax
__int64 v19; // r13
int v20; // eax
__int64 v21; // r13
int v22; // eax
unsigned int v23; // ebx
int v24; // eax
__int64 v25; // r13
int v26; // eax
unsigned int v27; // ebx
__int64 v28; // r13
int v29; // eax
unsigned int v30; // eax
__int64 v31; // rbx
__int64 v32; // r13
int v33; // eax
unsigned int v34; // eax
unsigned int v35; // er13
__int64 v36; // rbx
__int64 v37; // r13
int v38; // eax
unsigned int v39; // eax
unsigned int v40; // er13
__int64 v41; // r13
_DWORD *v42; // rax
__int64 v43; // rax
__int64 v44; // rax
__int64 v45; // rsi
__int64 v46; // rax
int v47; // eax
unsigned int v48; // eax
int v49; // eax
int v50; // eax
int v51; // eax
int v52; // eax
int v53; // eax
__int64 v54[8]; // [rsp+8h] [rbp-40h] BYREF

v0 = 0LL;
v1 = dynget(5LL);
if ( v1 )
{
v0 = dynget(10LL);
if ( v0 )
{
v1 = getaddressoffset(v1);
recordpiece(v1, v0, 7LL, "~dynstr", 1LL);
}
else
{
v1 = 0LL;
warnpartial("DT_STRTAB", "DT_STRSZ");
}
}
v2 = 0LL;
v3 = dynget(4LL);
v4 = v3;
if ( v3 )
{
v54[0] = 8LL;
v41 = getaddressoffset(v3);
v42 = (_DWORD *)getptrto(v41, v54);
if ( v54[0] <= 7 )
{
v45 = v4;
v4 = 0LL;
warn("invalid hash table offset: %ld.", v45);
}
else
{
symcount = v42[1];
recordpiece(v41, 4LL * (unsigned int)(*v42 + symcount + 2), 9LL, "~hash", 4LL);
v4 = dynget(6LL);
if ( v4 )
{
v54[0] = dynget(11LL);
if ( v54[0] != (-(__int64)((unsigned int)((__int64 (*)(void))iself64)() == 0) & 0xFFFFFFFFFFFFFFF8LL) + 24 )
{
v51 = ((__int64 (*)(void))iself64)();
warn("unexepected value for DT_SYMENT: %ld instead of %d.", v54[0], v51 == 0 ? 16 : 24);
}
v46 = getaddressoffset(v4);
v2 = v54[0] * symcount;
v4 = v46;
v47 = ((__int64 (*)(void))iself64)();
v48 = recordpiece(v4, v2, 11LL, "~dynsym", v47 == 0 ? 4 : 8);
if ( v0 )
setpiecestrtable(v48, v1, v0);
}
v43 = dynget(1879048176LL);
if ( v43 )
{
v44 = getaddressoffset(v43);
recordpiece(v44, 2 * symcount, 3LL, "~versym", 2LL);
}
}
}
v5 = dynget(17LL);
if ( v5 )
{
v54[0] = dynget(18LL);
v36 = v54[0];
if ( v54[0] )
{
if ( v36 % (__int64)((-(__int64)((unsigned int)((__int64 (*)(void))iself64)() == 0) & 0xFFFFFFFFFFFFFFF8LL) + 16) )
{
v49 = ((__int64 (*)(void))iself64)();
warn("unexpected value for DT_RELSZ: %ld instead of %d.", v54[0], v49 == 0 ? 8 : 16);
}
v37 = getaddressoffset(v5);
v38 = ((__int64 (*)(void))iself64)();
v39 = recordpiece(v37, v54[0], 13LL, "~rel_got", v38 == 0 ? 4 : 8);
v40 = v39;
if ( v4 )
{
setpiecemisctable(v39, v4, v2);
setpiecestrtable(v40, v1, v0);
}
}
else
{
warnpartial("DT_REL", "DT_RELSZ");
}
}
v6 = dynget(7LL);
if ( v6 )
{
v54[0] = dynget(8LL);
v31 = v54[0];
if ( v54[0] )
{
if ( v31 % (__int64)((-(__int64)((unsigned int)((__int64 (*)(void))iself64)() == 0) & 0xFFFFFFFFFFFFFFF4LL) + 24) )
{
v50 = ((__int64 (*)(void))iself64)();
warn("unexpected value for DT_RELASZ: %ld instead of %d.", v54[0], v50 == 0 ? 12 : 24);
}
v32 = getaddressoffset(v6);
v33 = ((__int64 (*)(void))iself64)();
v34 = recordpiece(v32, v54[0], 14LL, "~rela_got", v33 == 0 ? 4 : 8);
v35 = v34;
if ( v4 )
{
setpiecemisctable(v34, v4, v2);
setpiecestrtable(v35, v1, v0);
}
}
else
{
warnpartial("DT_RELA", "DT_RELASZ");
}
}
v7 = dynget(1879047935LL);
if ( v7 )
{
v54[0] = dynget(1879047678LL);
if ( v54[0] )
{
v27 = dynget(1879047679LL);
((void (*)(void))iself64)();
if ( v27 != 4 )
{
((void (*)(void))iself64)();
warn("unexpected value for DT_SYMINENT: %ld instead of %d.", v27, 4LL);
}
if ( v54[0] % (int)v27 )
warn("unexpected value for DT_SYMINSZ: %ld is not an even multiple of %ld.", v54[0], v27);
v28 = getaddressoffset(v7);
v29 = ((__int64 (*)(void))iself64)();
v30 = recordpiece(v28, v54[0], 12LL, "~syminfo", v29 == 0 ? 4 : 8);
if ( v0 )
setpiecestrtable(v30, v1, v0);
}
else
{
warnpartial("DT_SYMINFO", "DT_SYMINSZ");
}
}
v8 = dynget(1879047934LL);
if ( v8 )
{
v54[0] = dynget(1879047675LL);
if ( v54[0] )
{
v23 = dynget(1879047674LL);
if ( ((unsigned int)((__int64 (*)(void))iself64)() == 0 ? 24 : 32) != v23 )
{
v24 = ((__int64 (*)(void))iself64)();
warn("unexpected value for DT_MOVEENT: %ld instead of %d.", v23, v24 == 0 ? 24 : 32);
}
if ( v54[0] % (int)v23 )
warn("unexpected value for DT_MOVESZ: %ld is not an even multiple of %ld.", v54[0], v23);
v25 = getaddressoffset(v8);
v26 = ((__int64 (*)(void))iself64)();
recordpiece(v25, v54[0], 15LL, "~move", v26 == 0 ? 4 : 8);
}
else
{
warnpartial("DT_MOVETAB", "DT_MOVESZ");
}
}
v9 = dynget(25LL);
if ( v9 )
{
v54[0] = dynget(27LL);
if ( v54[0] )
{
v21 = getaddressoffset(v9);
v22 = ((__int64 (*)(void))iself64)();
recordpiece(v21, v54[0], 6LL, "~init_array", v22 == 0 ? 4 : 8);
}
else
{
warnpartial("DT_INIT_ARRAY", "DT_INIT_ARRAYSZ");
}
}
v10 = dynget(26LL);
if ( v10 )
{
v54[0] = dynget(28LL);
if ( v54[0] )
{
v19 = getaddressoffset(v10);
v20 = ((__int64 (*)(void))iself64)();
recordpiece(v19, v54[0], 6LL, "~fini_array", v20 == 0 ? 4 : 8);
}
else
{
warnpartial("DT_FINI_ARRAY", "DT_FINI_ARRAYSZ");
}
}
v11 = dynget(32LL);
if ( v11 )
{
v54[0] = dynget(33LL);
if ( v54[0] )
{
v17 = getaddressoffset(v11);
v18 = ((__int64 (*)(void))iself64)();
recordpiece(v17, v54[0], 6LL, "~preinit_array", v18 == 0 ? 4 : 8);
}
else
{
warnpartial("DT_PREINIT_ARRAY", "DT_PREINIT_ARRAYSZ");
}
}
v12 = dynget(23LL);
if ( v12 )
{
v54[0] = dynget(2LL);
if ( v54[0] )
{
v13 = getaddressoffset(v12);
v14 = dynget(20LL);
if ( v14 == 17 )
{
v53 = ((__int64 (*)(void))iself64)();
v16 = recordpiece(v13, v54[0], 13LL, "~plt_rel", v53 == 0 ? 4 : 8);
}
else if ( v14 == 7 )
{
v52 = iself64(20LL, 7LL);
v16 = recordpiece(v13, v54[0], 14LL, "~plt_rela", v52 == 0 ? 4 : 8);
}
else
{
warn("unrecognized value for DT_PLTREL: %ld.", v14);
v16 = v15;
}
if ( v16 > 0 )
{
if ( v4 )
{
setpiecemisctable((unsigned int)v16, v4, v2);
setpiecestrtable((unsigned int)v16, v1, v0);
}
}
}
else
{
warnpartial("DT_JMPREL", "DT_PLTRELSZ");
}
}
}

canonical_decompiled_code:
void func4()
{
__int64 v0; // r14
__int64 v1; // r12
__int64 v2; // r15
__int64 v3; // rax
__int64 v4; // rbp
__int64 v5; // r13
__int64 v6; // r13
__int64 v7; // r13
__int64 v8; // r13
__int64 v9; // r13
__int64 v10; // r13
__int64 v11; // r13
__int64 v12; // r13
__int64 v13; // r13
__int64 v14; // rax
int v15; // eax
int v16; // er13
__int64 v17; // r13
int v18; // eax
__int64 v19; // r13
int v20; // eax
__int64 v21; // r13
int v22; // eax
unsigned int v23; // ebx
int v24; // eax
__int64 v25; // r13
int v26; // eax
unsigned int v27; // ebx
__int64 v28; // r13
int v29; // eax
unsigned int v30; // eax
__int64 v31; // rbx
__int64 v32; // r13
int v33; // eax
unsigned int v34; // eax
unsigned int v35; // er13
__int64 v36; // rbx
__int64 v37; // r13
int v38; // eax
unsigned int v39; // eax
unsigned int v40; // er13
__int64 v41; // r13
_DWORD *v42; // rax
__int64 v43; // rax
__int64 v44; // rax
__int64 v45; // rsi
__int64 v46; // rax
int v47; // eax
unsigned int v48; // eax
int v49; // eax
int v50; // eax
int v51; // eax
int v52; // eax
int v53; // eax
__int64 v54[8]; // [rsp+8h] [rbp-40h] BYREF

v0 = 0LL;
v1 = func1(5LL);
if ( v1 )
{
v0 = func1(10LL);
if ( v0 )
{
v1 = getaddressoffset(v1);
recordpiece(v1, v0, 7LL, "~dynstr", 1LL);
}
else
{
v1 = 0LL;
func2("DT_STRTAB", "DT_STRSZ");
}
}
v2 = 0LL;
v3 = func1(4LL);
v4 = v3;
if ( v3 )
{
v54[0] = 8LL;
v41 = getaddressoffset(v3);
v42 = (_DWORD *)getptrto(v41, v54);
if ( v54[0] <= 7 )
{
v45 = v4;
v4 = 0LL;
warn("invalid hash table offset: %ld.", v45);
}
else
{
symcount = v42[1];
recordpiece(v41, 4LL * (unsigned int)(*v42 + symcount + 2), 9LL, "~hash", 4LL);
v4 = func1(6LL);
if ( v4 )
{
v54[0] = func1(11LL);
if ( v54[0] != (-(__int64)((unsigned int)((__int64 (*)(void))iself64)() == 0) & 0xFFFFFFFFFFFFFFF8LL) + 24 )
{
v51 = ((__int64 (*)(void))iself64)();
warn("unexepected value for DT_SYMENT: %ld instead of %d.", v54[0], v51 == 0 ? 16 : 24);
}
v46 = getaddressoffset(v4);
v2 = v54[0] * symcount;
v4 = v46;
v47 = ((__int64 (*)(void))iself64)();
v48 = recordpiece(v4, v2, 11LL, "~dynsym", v47 == 0 ? 4 : 8);
if ( v0 )
setpiecestrtable(v48, v1, v0);
}
v43 = func1(1879048176LL);
if ( v43 )
{
v44 = getaddressoffset(v43);
recordpiece(v44, 2 * symcount, 3LL, "~versym", 2LL);
}
}
}
v5 = func1(17LL);
if ( v5 )
{
v54[0] = func1(18LL);
v36 = v54[0];
if ( v54[0] )
{
if ( v36 % (__int64)((-(__int64)((unsigned int)((__int64 (*)(void))iself64)() == 0) & 0xFFFFFFFFFFFFFFF8LL) + 16) )
{
v49 = ((__int64 (*)(void))iself64)();
warn("unexpected value for DT_RELSZ: %ld instead of %d.", v54[0], v49 == 0 ? 8 : 16);
}
v37 = getaddressoffset(v5);
v38 = ((__int64 (*)(void))iself64)();
v39 = recordpiece(v37, v54[0], 13LL, "~rel_got", v38 == 0 ? 4 : 8);
v40 = v39;
if ( v4 )
{
setpiecemisctable(v39, v4, v2);
setpiecestrtable(v40, v1, v0);
}
}
else
{
func2("DT_REL", "DT_RELSZ");
}
}
v6 = func1(7LL);
if ( v6 )
{
v54[0] = func1(8LL);
v31 = v54[0];
if ( v54[0] )
{
if ( v31 % (__int64)((-(__int64)((unsigned int)((__int64 (*)(void))iself64)() == 0) & 0xFFFFFFFFFFFFFFF4LL) + 24) )
{
v50 = ((__int64 (*)(void))iself64)();
warn("unexpected value for DT_RELASZ: %ld instead of %d.", v54[0], v50 == 0 ? 12 : 24);
}
v32 = getaddressoffset(v6);
v33 = ((__int64 (*)(void))iself64)();
v34 = recordpiece(v32, v54[0], 14LL, "~rela_got", v33 == 0 ? 4 : 8);
v35 = v34;
if ( v4 )
{
setpiecemisctable(v34, v4, v2);
setpiecestrtable(v35, v1, v0);
}
}
else
{
func2("DT_RELA", "DT_RELASZ");
}
}
v7 = func1(1879047935LL);
if ( v7 )
{
v54[0] = func1(1879047678LL);
if ( v54[0] )
{
v27 = func1(1879047679LL);
((void (*)(void))iself64)();
if ( v27 != 4 )
{
((void (*)(void))iself64)();
warn("unexpected value for DT_SYMINENT: %ld instead of %d.", v27, 4LL);
}
if ( v54[0] % (int)v27 )
warn("unexpected value for DT_SYMINSZ: %ld is not an even multiple of %ld.", v54[0], v27);
v28 = getaddressoffset(v7);
v29 = ((__int64 (*)(void))iself64)();
v30 = recordpiece(v28, v54[0], 12LL, "~syminfo", v29 == 0 ? 4 : 8);
if ( v0 )
setpiecestrtable(v30, v1, v0);
}
else
{
func2("DT_SYMINFO", "DT_SYMINSZ");
}
}
v8 = func1(1879047934LL);
if ( v8 )
{
v54[0] = func1(1879047675LL);
if ( v54[0] )
{
v23 = func1(1879047674LL);
if ( ((unsigned int)((__int64 (*)(void))iself64)() == 0 ? 24 : 32) != v23 )
{
v24 = ((__int64 (*)(void))iself64)();
warn("unexpected value for DT_MOVEENT: %ld instead of %d.", v23, v24 == 0 ? 24 : 32);
}
if ( v54[0] % (int)v23 )
warn("unexpected value for DT_MOVESZ: %ld is not an even multiple of %ld.", v54[0], v23);
v25 = getaddressoffset(v8);
v26 = ((__int64 (*)(void))iself64)();
recordpiece(v25, v54[0], 15LL, "~move", v26 == 0 ? 4 : 8);
}
else
{
func2("DT_MOVETAB", "DT_MOVESZ");
}
}
v9 = func1(25LL);
if ( v9 )
{
v54[0] = func1(27LL);
if ( v54[0] )
{
v21 = getaddressoffset(v9);
v22 = ((__int64 (*)(void))iself64)();
recordpiece(v21, v54[0], 6LL, "~init_array", v22 == 0 ? 4 : 8);
}
else
{
func2("DT_INIT_ARRAY", "DT_INIT_ARRAYSZ");
}
}
v10 = func1(26LL);
if ( v10 )
{
v54[0] = func1(28LL);
if ( v54[0] )
{
v19 = getaddressoffset(v10);
v20 = ((__int64 (*)(void))iself64)();
recordpiece(v19, v54[0], 6LL, "~fini_array", v20 == 0 ? 4 : 8);
}
else
{
func2("DT_FINI_ARRAY", "DT_FINI_ARRAYSZ");
}
}
v11 = func1(32LL);
if ( v11 )
{
v54[0] = func1(33LL);
if ( v54[0] )
{
v17 = getaddressoffset(v11);
v18 = ((__int64 (*)(void))iself64)();
recordpiece(v17, v54[0], 6LL, "~preinit_array", v18 == 0 ? 4 : 8);
}
else
{
func2("DT_PREINIT_ARRAY", "DT_PREINIT_ARRAYSZ");
}
}
v12 = func1(23LL);
if ( v12 )
{
v54[0] = func1(2LL);
if ( v54[0] )
{
v13 = getaddressoffset(v12);
v14 = func1(20LL);
if ( v14 == 17 )
{
v53 = ((__int64 (*)(void))iself64)();
v16 = recordpiece(v13, v54[0], 13LL, "~plt_rel", v53 == 0 ? 4 : 8);
}
else if ( v14 == 7 )
{
v52 = iself64(20LL, 7LL);
v16 = recordpiece(v13, v54[0], 14LL, "~plt_rela", v52 == 0 ? 4 : 8);
}
else
{
warn("unrecognized value for DT_PLTREL: %ld.", v14);
v16 = v15;
}
if ( v16 > 0 )
{
if ( v4 )
{
setpiecemisctable((unsigned int)v16, v4, v2);
setpiecestrtable((unsigned int)v16, v1, v0);
}
}
}
else
{
func2("DT_JMPREL", "DT_PLTRELSZ");
}
}
}

original_code:
void dividedynsegments(void)
{
    long strtab = 0, strsize = 0;
    long symtab = 0, symsize = 0;
    long offset, size, value;
    int entsize, n;
    value = dynget(5);
    if (value) {
 strsize = dynget(10);
 if (strsize) {
     strtab = getaddressoffset(value);
     recordpiece(strtab, strsize, P_STRINGS, "~dynstr", 1);
 } else {
     warnpartial("DT_STRTAB", "DT_STRSZ");
 }
    }
    value = dynget(4);
    if (value) {
 Elf64_Word const *table;
 offset = getaddressoffset(value);
 size = 2 * sizeof(Elf64_Word);
 table = getptrto(offset, &size);
 if (size < 2 * (int)sizeof(Elf64_Word)) {
     warn("invalid hash table offset: %ld.", value);
 } else {
     symcount = table[1];
     recordpiece(offset, (2 + table[0] + symcount) * sizeof *table,
   P_HASH, "~hash", 4);
     value = dynget(6);
     if (value) {
  size = dynget(11);
  if (size != ((int)(iself64() ? sizeof(Elf64_Sym) : sizeof(Elf32_Sym))))
      warn("unexepected value for DT_SYMENT: %ld instead of %d.",
    size, ((int)(iself64() ? sizeof(Elf64_Sym) : sizeof(Elf32_Sym))));
  symtab = getaddressoffset(value);
  symsize = symcount * size;
  n = recordpiece(symtab, symsize, P_SYMTAB, "~dynsym",
    ((int)(iself64() ? sizeof(Elf64_Addr) : sizeof(Elf32_Addr))));
  if (strsize)
      setpiecestrtable(n, strtab, strsize);
     }
     value = dynget(0x6ffffff0);
     if (value) {
  offset = getaddressoffset(value);
  recordpiece(offset, symcount * 2, P_HALVES, "~versym", 2);
     }
 }
    }
    value = dynget(17);
    if (value) {
 size = dynget(18);
 if (size) {
     if (size % ((int)(iself64() ? sizeof(Elf64_Rel) : sizeof(Elf32_Rel))) != 0)
  warn("unexpected value for DT_RELSZ: %ld instead of %d.",
       size, ((int)(iself64() ? sizeof(Elf64_Rel) : sizeof(Elf32_Rel))));
     offset = getaddressoffset(value);
     n = recordpiece(offset, size, P_REL, "~rel_got", ((int)(iself64() ? sizeof(Elf64_Addr) : sizeof(Elf32_Addr))));
     if (symtab) {
  setpiecemisctable(n, symtab, symsize);
  setpiecestrtable(n, strtab, strsize);
     }
 } else {
     warnpartial("DT_REL", "DT_RELSZ");
 }
    }
    value = dynget(7);
    if (value) {
 size = dynget(8);
 if (size) {
     if (size % ((int)(iself64() ? sizeof(Elf64_Rela) : sizeof(Elf32_Rela))) != 0)
  warn("unexpected value for DT_RELASZ: %ld instead of %d.",
       size, ((int)(iself64() ? sizeof(Elf64_Rela) : sizeof(Elf32_Rela))));
     offset = getaddressoffset(value);
     n = recordpiece(offset, size, P_RELA, "~rela_got",
       ((int)(iself64() ? sizeof(Elf64_Addr) : sizeof(Elf32_Addr))));
     if (symtab) {
  setpiecemisctable(n, symtab, symsize);
  setpiecestrtable(n, strtab, strsize);
     }
 } else {
     warnpartial("DT_RELA", "DT_RELASZ");
 }
    }
    value = dynget(0x6ffffeff);
    if (value) {
 size = dynget(0x6ffffdfe);
 if (size) {
     entsize = dynget(0x6ffffdff);
     if (entsize != ((int)(iself64() ? sizeof(Elf64_Syminfo) : sizeof(Elf32_Syminfo))))
  warn("unexpected value for DT_SYMINENT: %ld instead of %d.",
       entsize, ((int)(iself64() ? sizeof(Elf64_Syminfo) : sizeof(Elf32_Syminfo))));
     if (size % entsize != 0)
  warn("unexpected value for DT_SYMINSZ:"
       " %ld is not an even multiple of %ld.", size, entsize);
     offset = getaddressoffset(value);
     n = recordpiece(offset, size, P_SYMINFO, "~syminfo",
       ((int)(iself64() ? sizeof(Elf64_Addr) : sizeof(Elf32_Addr))));
     if (strsize)
  setpiecestrtable(n, strtab, strsize);
 } else {
     warnpartial("DT_SYMINFO", "DT_SYMINSZ");
 }
    }
    value = dynget(0x6ffffefe);
    if (value) {
 size = dynget(0x6ffffdfb);
 if (size) {
     entsize = dynget(0x6ffffdfa);
     if (entsize != ((int)(iself64() ? sizeof(Elf64_Move) : sizeof(Elf32_Move))))
  warn("unexpected value for DT_MOVEENT: %ld instead of %d.",
       entsize, ((int)(iself64() ? sizeof(Elf64_Move) : sizeof(Elf32_Move))));
     if (size % entsize != 0)
  warn("unexpected value for DT_MOVESZ:"
       " %ld is not an even multiple of %ld.", size, entsize);
     offset = getaddressoffset(value);
     recordpiece(offset, size, P_MOVE, "~move", ((int)(iself64() ? sizeof(Elf64_Addr) : sizeof(Elf32_Addr))));
 } else {
     warnpartial("DT_MOVETAB", "DT_MOVESZ");
 }
    }
    value = dynget(25);
    if (value) {
 size = dynget(27);
 if (size) {
     offset = getaddressoffset(value);
     recordpiece(offset, size, P_ADDRS, "~init_array",
   ((int)(iself64() ? sizeof(Elf64_Addr) : sizeof(Elf32_Addr))));
 } else {
     warnpartial("DT_INIT_ARRAY","DT_INIT_ARRAYSZ");
 }
    }
    value = dynget(26);
    if (value) {
 size = dynget(28);
 if (size) {
     offset = getaddressoffset(value);
     recordpiece(offset, size, P_ADDRS, "~fini_array",
   ((int)(iself64() ? sizeof(Elf64_Addr) : sizeof(Elf32_Addr))));
 } else {
     warnpartial("DT_FINI_ARRAY", "DT_FINI_ARRAYSZ");
 }
    }
    value = dynget(32);
    if (value) {
 size = dynget(33);
 if (size) {
     offset = getaddressoffset(value);
     recordpiece(offset, size, P_ADDRS, "~preinit_array",
   ((int)(iself64() ? sizeof(Elf64_Addr) : sizeof(Elf32_Addr))));
 } else {
     warnpartial("DT_PREINIT_ARRAY", "DT_PREINIT_ARRAYSZ");
 }
    }
    value = dynget(23);
    if (value) {
 size = dynget(2);
 if (size) {
     offset = getaddressoffset(value);
     value = dynget(20);
     if (value == 17)
  n = recordpiece(offset, size, P_REL, "~plt_rel",
    ((int)(iself64() ? sizeof(Elf64_Addr) : sizeof(Elf32_Addr))));
     else if (value == 7)
  n = recordpiece(offset, size, P_RELA, "~plt_rela",
    ((int)(iself64() ? sizeof(Elf64_Addr) : sizeof(Elf32_Addr))));
     else
  n = warn("unrecognized value for DT_PLTREL: %ld.", value);
     if (n > 0 && symtab) {
  setpiecemisctable(n, symtab, symsize);
  setpiecestrtable(n, strtab, strsize);
     }
 } else {
     warnpartial("DT_JMPREL", "DT_PLTRELSZ");
 }
    }
}

canonical_original_code:
void dividedynsegments()
{
    long strtab = 0; long strsize = 0;
    long symtab = 0; long symsize = 0;
    long offset; long size; long value;
    int entsize; int n;
    value = dynget(5);
    if (value) {
 strsize = dynget(10);
 if (strsize) {
     strtab = getaddressoffset(value);
     recordpiece(strtab, strsize, P_STRINGS, "~dynstr", 1);
 } else {
     warnpartial("DT_STRTAB", "DT_STRSZ");
 }
    }
    value = dynget(4);
    if (value) {
 unsigned int *table;
 offset = getaddressoffset(value);
 size = 2 * sizeof(Elf64_Word);
 table = getptrto(offset, &size);
 if (size < 2 * (int)sizeof(Elf64_Word)) {
     warn("invalid hash table offset: %ld.", value);
 } else {
     symcount = table[1];
     recordpiece(offset, (2 + table[0] + symcount) * sizeof *table,
   P_HASH, "~hash", 4);
     value = dynget(6);
     if (value) {
  size = dynget(11);
  if (size != ((int)(iself64() ? sizeof(Elf64_Sym) : sizeof(Elf32_Sym))))
      warn("unexepected value for DT_SYMENT: %ld instead of %d.",
    size, ((int)(iself64() ? sizeof(Elf64_Sym) : sizeof(Elf32_Sym))));
  symtab = getaddressoffset(value);
  symsize = symcount * size;
  n = recordpiece(symtab, symsize, P_SYMTAB, "~dynsym",
    ((int)(iself64() ? sizeof(Elf64_Addr) : sizeof(Elf32_Addr))));
  if (strsize)
      setpiecestrtable(n, strtab, strsize);
     }
     value = dynget(0x6ffffff0);
     if (value) {
  offset = getaddressoffset(value);
  recordpiece(offset, symcount * 2, P_HALVES, "~versym", 2);
     }
 }
    }
    value = dynget(17);
    if (value) {
 size = dynget(18);
 if (size) {
     if (size % ((int)(iself64() ? sizeof(Elf64_Rel) : sizeof(Elf32_Rel))) != 0)
  warn("unexpected value for DT_RELSZ: %ld instead of %d.",
       size, ((int)(iself64() ? sizeof(Elf64_Rel) : sizeof(Elf32_Rel))));
     offset = getaddressoffset(value);
     n = recordpiece(offset, size, P_REL, "~rel_got", ((int)(iself64() ? sizeof(Elf64_Addr) : sizeof(Elf32_Addr))));
     if (symtab) {
  setpiecemisctable(n, symtab, symsize);
  setpiecestrtable(n, strtab, strsize);
     }
 } else {
     warnpartial("DT_REL", "DT_RELSZ");
 }
    }
    value = dynget(7);
    if (value) {
 size = dynget(8);
 if (size) {
     if (size % ((int)(iself64() ? sizeof(Elf64_Rela) : sizeof(Elf32_Rela))) != 0)
  warn("unexpected value for DT_RELASZ: %ld instead of %d.",
       size, ((int)(iself64() ? sizeof(Elf64_Rela) : sizeof(Elf32_Rela))));
     offset = getaddressoffset(value);
     n = recordpiece(offset, size, P_RELA, "~rela_got",
       ((int)(iself64() ? sizeof(Elf64_Addr) : sizeof(Elf32_Addr))));
     if (symtab) {
  setpiecemisctable(n, symtab, symsize);
  setpiecestrtable(n, strtab, strsize);
     }
 } else {
     warnpartial("DT_RELA", "DT_RELASZ");
 }
    }
    value = dynget(0x6ffffeff);
    if (value) {
 size = dynget(0x6ffffdfe);
 if (size) {
     entsize = dynget(0x6ffffdff);
     if (entsize != ((int)(iself64() ? sizeof(Elf64_Syminfo) : sizeof(Elf32_Syminfo))))
  warn("unexpected value for DT_SYMINENT: %ld instead of %d.",
       entsize, ((int)(iself64() ? sizeof(Elf64_Syminfo) : sizeof(Elf32_Syminfo))));
     if (size % entsize != 0)
  warn("unexpected value for DT_SYMINSZ:"
       " %ld is not an even multiple of %ld.", size, entsize);
     offset = getaddressoffset(value);
     n = recordpiece(offset, size, P_SYMINFO, "~syminfo",
       ((int)(iself64() ? sizeof(Elf64_Addr) : sizeof(Elf32_Addr))));
     if (strsize)
  setpiecestrtable(n, strtab, strsize);
 } else {
     warnpartial("DT_SYMINFO", "DT_SYMINSZ");
 }
    }
    value = dynget(0x6ffffefe);
    if (value) {
 size = dynget(0x6ffffdfb);
 if (size) {
     entsize = dynget(0x6ffffdfa);
     if (entsize != ((int)(iself64() ? sizeof(Elf64_Move) : sizeof(Elf32_Move))))
  warn("unexpected value for DT_MOVEENT: %ld instead of %d.",
       entsize, ((int)(iself64() ? sizeof(Elf64_Move) : sizeof(Elf32_Move))));
     if (size % entsize != 0)
  warn("unexpected value for DT_MOVESZ:"
       " %ld is not an even multiple of %ld.", size, entsize);
     offset = getaddressoffset(value);
     recordpiece(offset, size, P_MOVE, "~move", ((int)(iself64() ? sizeof(Elf64_Addr) : sizeof(Elf32_Addr))));
 } else {
     warnpartial("DT_MOVETAB", "DT_MOVESZ");
 }
    }
    value = dynget(25);
    if (value) {
 size = dynget(27);
 if (size) {
     offset = getaddressoffset(value);
     recordpiece(offset, size, P_ADDRS, "~init_array",
   ((int)(iself64() ? sizeof(Elf64_Addr) : sizeof(Elf32_Addr))));
 } else {
     warnpartial("DT_INIT_ARRAY","DT_INIT_ARRAYSZ");
 }
    }
    value = dynget(26);
    if (value) {
 size = dynget(28);
 if (size) {
     offset = getaddressoffset(value);
     recordpiece(offset, size, P_ADDRS, "~fini_array",
   ((int)(iself64() ? sizeof(Elf64_Addr) : sizeof(Elf32_Addr))));
 } else {
     warnpartial("DT_FINI_ARRAY", "DT_FINI_ARRAYSZ");
 }
    }
    value = dynget(32);
    if (value) {
 size = dynget(33);
 if (size) {
     offset = getaddressoffset(value);
     recordpiece(offset, size, P_ADDRS, "~preinit_array",
   ((int)(iself64() ? sizeof(Elf64_Addr) : sizeof(Elf32_Addr))));
 } else {
     warnpartial("DT_PREINIT_ARRAY", "DT_PREINIT_ARRAYSZ");
 }
    }
    value = dynget(23);
    if (value) {
 size = dynget(2);
 if (size) {
     offset = getaddressoffset(value);
     value = dynget(20);
     if (value == 17)
  n = recordpiece(offset, size, P_REL, "~plt_rel",
    ((int)(iself64() ? sizeof(Elf64_Addr) : sizeof(Elf32_Addr))));
     else if (value == 7)
  n = recordpiece(offset, size, P_RELA, "~plt_rela",
    ((int)(iself64() ? sizeof(Elf64_Addr) : sizeof(Elf32_Addr))));
     else
  n = warn("unrecognized value for DT_PLTREL: %ld.", value);
     if (n > 0 && symtab) {
  setpiecemisctable(n, symtab, symsize);
  setpiecestrtable(n, strtab, strsize);
     }
 } else {
     warnpartial("DT_JMPREL", "DT_PLTRELSZ");
 }
    }
}

variable_types: strtab long

variable_types: strsize long

variable_types: symtab long

variable_types: symsize long

variable_types: value long

variable_types: entsize int

variable_types: n int

variable_types:
table
unsigned int *


strdynamicvalue

decompiled_code:
const char *__fastcall strdynamicvalue(__int64 a1, __int64 a2)
{
__int64 v2; // rdi
const char *result; // rax
__int64 v4; // rax
int v5; // eax
bool v6; // zf

if ( a1 <= 33 )
{
if ( a1 > 1 )
{
switch ( a1 )
{
case 2LL:
v2 = dynget(23LL);
if ( v2 )
goto LABEL_13;
return 0LL;
case 8LL:
goto LABEL_16;
case 9LL:
if ( (-(__int64)((unsigned int)iself64(a1, a2) == 0) & 0xFFFFFFFFFFFFFFF4LL) + 24 == a2 )
{
v6 = (unsigned int)iself64(a1, a2) == 0;
result = "sizeof(Elf64_Rela)";
if ( v6 )
result = "sizeof(Elf32_Rela)";
}
else
{
LABEL_16:
v2 = dynget(7LL);
if ( v2 )
goto LABEL_13;
result = 0LL;
}
return result;
case 10LL:
v2 = dynget(5LL);
if ( v2 )
goto LABEL_13;
return 0LL;
case 11LL:
if ( (-(__int64)((unsigned int)iself64(a1, a2) == 0) & 0xFFFFFFFFFFFFFFF8LL) + 24 == a2 )
{
v6 = (unsigned int)iself64(a1, a2) == 0;
result = "sizeof(Elf64_Sym)";
if ( v6 )
result = "sizeof(Elf32_Sym)";
}
else
{
v2 = dynget(6LL);
if ( v2 )
goto LABEL_13;
result = 0LL;
}
return result;
case 18LL:
goto LABEL_19;
case 19LL:
if ( (-(__int64)((unsigned int)iself64(a1, a2) == 0) & 0xFFFFFFFFFFFFFFF8LL) + 16 == a2 )
{
v6 = (unsigned int)iself64(a1, a2) == 0;
result = "sizeof(Elf64_Rel)";
if ( v6 )
result = "sizeof(Elf32_Rel)";
}
else
{
LABEL_19:
v2 = dynget(17LL);
if ( v2 )
goto LABEL_13;
result = 0LL;
}
break;
case 27LL:
v2 = dynget(25LL);
if ( v2 )
goto LABEL_13;
return 0LL;
case 28LL:
v2 = dynget(26LL);
if ( v2 )
goto LABEL_13;
return 0LL;
case 33LL:
v2 = dynget(32LL);
if ( v2 )
goto LABEL_13;
return 0LL;
default:
return 0LL;
}
return result;
}
return 0LL;
}
if ( a1 == 1879047678 )
goto LABEL_12;
if ( a1 <= 1879047678 )
{
if ( a1 == 1879047674 )
{
if ( (-(__int64)((unsigned int)iself64(1879047674LL, a2) == 0) & 0xFFFFFFFFFFFFFFF8LL) + 32 == a2 )
{
v6 = (unsigned int)iself64(1879047674LL, a2) == 0;
result = "sizeof(Elf64_Move)";
if ( v6 )
result = "sizeof(Elf32_Move)";
return result;
}
}
else if ( a1 != 1879047675 )
{
return 0LL;
}
v2 = dynget(1879047934LL);
if ( !v2 )
return 0LL;
goto LABEL_13;
}
if ( a1 != 1879047679 )
return 0LL;
iself64(1879047679LL, a2);
if ( a2 != 4 )
{
LABEL_12:
v2 = dynget(1879047935LL);
if ( !v2 )
return 0LL;
LABEL_13:
v4 = getaddressoffset(v2);
v5 = getindexfromoffset(v4);
if ( v5 >= 0 )
return (const char *)getsizestr(a2, (unsigned int)v5);
return 0LL;
}
v6 = (unsigned int)iself64(1879047679LL, 4LL) == 0;
result = "sizeof(Elf64_Syminfo)";
if ( v6 )
result = "sizeof(Elf32_Syminfo)";
return result;
}

canonical_decompiled_code:
const char *__fastcall func5(__int64 a1, __int64 a2)
{
__int64 v2; // rdi
const char *result; // rax
__int64 v4; // rax
int v5; // eax
bool v6; // zf

if ( a1 <= 33 )
{
if ( a1 > 1 )
{
switch ( a1 )
{
case 2LL:
v2 = func1(23LL);
if ( v2 )
goto LABEL_13;
return 0LL;
case 8LL:
goto LABEL_16;
case 9LL:
if ( (-(__int64)((unsigned int)iself64(a1, a2) == 0) & 0xFFFFFFFFFFFFFFF4LL) + 24 == a2 )
{
v6 = (unsigned int)iself64(a1, a2) == 0;
result = "sizeof(Elf64_Rela)";
if ( v6 )
result = "sizeof(Elf32_Rela)";
}
else
{
LABEL_16:
v2 = func1(7LL);
if ( v2 )
goto LABEL_13;
result = 0LL;
}
return result;
case 10LL:
v2 = func1(5LL);
if ( v2 )
goto LABEL_13;
return 0LL;
case 11LL:
if ( (-(__int64)((unsigned int)iself64(a1, a2) == 0) & 0xFFFFFFFFFFFFFFF8LL) + 24 == a2 )
{
v6 = (unsigned int)iself64(a1, a2) == 0;
result = "sizeof(Elf64_Sym)";
if ( v6 )
result = "sizeof(Elf32_Sym)";
}
else
{
v2 = func1(6LL);
if ( v2 )
goto LABEL_13;
result = 0LL;
}
return result;
case 18LL:
goto LABEL_19;
case 19LL:
if ( (-(__int64)((unsigned int)iself64(a1, a2) == 0) & 0xFFFFFFFFFFFFFFF8LL) + 16 == a2 )
{
v6 = (unsigned int)iself64(a1, a2) == 0;
result = "sizeof(Elf64_Rel)";
if ( v6 )
result = "sizeof(Elf32_Rel)";
}
else
{
LABEL_19:
v2 = func1(17LL);
if ( v2 )
goto LABEL_13;
result = 0LL;
}
break;
case 27LL:
v2 = func1(25LL);
if ( v2 )
goto LABEL_13;
return 0LL;
case 28LL:
v2 = func1(26LL);
if ( v2 )
goto LABEL_13;
return 0LL;
case 33LL:
v2 = func1(32LL);
if ( v2 )
goto LABEL_13;
return 0LL;
default:
return 0LL;
}
return result;
}
return 0LL;
}
if ( a1 == 1879047678 )
goto LABEL_12;
if ( a1 <= 1879047678 )
{
if ( a1 == 1879047674 )
{
if ( (-(__int64)((unsigned int)iself64(1879047674LL, a2) == 0) & 0xFFFFFFFFFFFFFFF8LL) + 32 == a2 )
{
v6 = (unsigned int)iself64(1879047674LL, a2) == 0;
result = "sizeof(Elf64_Move)";
if ( v6 )
result = "sizeof(Elf32_Move)";
return result;
}
}
else if ( a1 != 1879047675 )
{
return 0LL;
}
v2 = func1(1879047934LL);
if ( !v2 )
return 0LL;
goto LABEL_13;
}
if ( a1 != 1879047679 )
return 0LL;
iself64(1879047679LL, a2);
if ( a2 != 4 )
{
LABEL_12:
v2 = func1(1879047935LL);
if ( !v2 )
return 0LL;
LABEL_13:
v4 = getaddressoffset(v2);
v5 = getindexfromoffset(v4);
if ( v5 >= 0 )
return (const char *)getsizestr(a2, (unsigned int)v5);
return 0LL;
}
v6 = (unsigned int)iself64(1879047679LL, 4LL) == 0;
result = "sizeof(Elf64_Syminfo)";
if ( v6 )
result = "sizeof(Elf32_Syminfo)";
return result;
}

original_code:
char const *strdynamicvalue(long tag, long value)
{
    long offset;
    int ndx;
    switch (tag) {
      case 10:
 if ((offset = dynget(5)) != 0)
     if ((ndx = getindexfromoffset(getaddressoffset(offset))) >= 0)
  return getsizestr(value, ndx);
 break;
      case 18:
 if ((offset = dynget(17)) != 0)
     if ((ndx = getindexfromoffset(getaddressoffset(offset))) >= 0)
  return getsizestr(value, ndx);
 break;
      case 8:
 if ((offset = dynget(7)) != 0)
     if ((ndx = getindexfromoffset(getaddressoffset(offset))) >= 0)
  return getsizestr(value, ndx);
 break;
      case 2:
 if ((offset = dynget(23)) != 0)
     if ((ndx = getindexfromoffset(getaddressoffset(offset))) >= 0)
  return getsizestr(value, ndx);
 break;
      case 0x6ffffdfe:
 if ((offset = dynget(0x6ffffeff)) != 0)
     if ((ndx = getindexfromoffset(getaddressoffset(offset))) >= 0)
  return getsizestr(value, ndx);
 break;
      case 27:
 if ((offset = dynget(25)) != 0)
     if ((ndx = getindexfromoffset(getaddressoffset(offset))) >= 0)
  return getsizestr(value, ndx);
 break;
      case 28:
 if ((offset = dynget(26)) != 0)
     if ((ndx = getindexfromoffset(getaddressoffset(offset))) >= 0)
  return getsizestr(value, ndx);
 break;
      case 33:
 if ((offset = dynget(32)) != 0)
     if ((ndx = getindexfromoffset(getaddressoffset(offset))) >= 0)
  return getsizestr(value, ndx);
 break;
      case 19:
 if (value == ((int)(iself64() ? sizeof(Elf64_Rel) : sizeof(Elf32_Rel))))
     return (iself64() ? "sizeof(Elf64_" "Rel" ")" : "sizeof(Elf32_" "Rel" ")");
 if ((offset = dynget(17)) != 0)
     if ((ndx = getindexfromoffset(getaddressoffset(offset))) >= 0)
  return getsizestr(value, ndx);
 break;
      case 9:
 if (value == ((int)(iself64() ? sizeof(Elf64_Rela) : sizeof(Elf32_Rela))))
     return (iself64() ? "sizeof(Elf64_" "Rela" ")" : "sizeof(Elf32_" "Rela" ")");
 if ((offset = dynget(7)) != 0)
     if ((ndx = getindexfromoffset(getaddressoffset(offset))) >= 0)
  return getsizestr(value, ndx);
 break;
      case 11:
 if (value == ((int)(iself64() ? sizeof(Elf64_Sym) : sizeof(Elf32_Sym))))
     return (iself64() ? "sizeof(Elf64_" "Sym" ")" : "sizeof(Elf32_" "Sym" ")");
 if ((offset = dynget(6)) != 0)
     if ((ndx = getindexfromoffset(getaddressoffset(offset))) >= 0)
  return getsizestr(value, ndx);
 break;
      case 0x6ffffdff:
 if (value == ((int)(iself64() ? sizeof(Elf64_Syminfo) : sizeof(Elf32_Syminfo))))
     return (iself64() ? "sizeof(Elf64_" "Syminfo" ")" : "sizeof(Elf32_" "Syminfo" ")");
 if ((offset = dynget(0x6ffffeff)) != 0)
     if ((ndx = getindexfromoffset(getaddressoffset(offset))) >= 0)
  return getsizestr(value, ndx);
 break;
      case 0x6ffffdfb:
 if ((offset = dynget(0x6ffffefe)) != 0)
     if ((ndx = getindexfromoffset(getaddressoffset(offset))) >= 0)
  return getsizestr(value, ndx);
 break;
      case 0x6ffffdfa:
 if (value == ((int)(iself64() ? sizeof(Elf64_Move) : sizeof(Elf32_Move))))
     return (iself64() ? "sizeof(Elf64_" "Move" ")" : "sizeof(Elf32_" "Move" ")");
 if ((offset = dynget(0x6ffffefe)) != 0)
     if ((ndx = getindexfromoffset(getaddressoffset(offset))) >= 0)
  return getsizestr(value, ndx);
 break;
    }
    return ((void *)0);
}

canonical_original_code:
char *strdynamicvalue(long tag, long value)
{
    long offset;
    int ndx;
    switch (tag) {
      case 10:
 if ((offset = dynget(5)) != 0)
     if ((ndx = getindexfromoffset(getaddressoffset(offset))) >= 0)
  return getsizestr(value, ndx);
 break;
      case 18:
 if ((offset = dynget(17)) != 0)
     if ((ndx = getindexfromoffset(getaddressoffset(offset))) >= 0)
  return getsizestr(value, ndx);
 break;
      case 8:
 if ((offset = dynget(7)) != 0)
     if ((ndx = getindexfromoffset(getaddressoffset(offset))) >= 0)
  return getsizestr(value, ndx);
 break;
      case 2:
 if ((offset = dynget(23)) != 0)
     if ((ndx = getindexfromoffset(getaddressoffset(offset))) >= 0)
  return getsizestr(value, ndx);
 break;
      case 0x6ffffdfe:
 if ((offset = dynget(0x6ffffeff)) != 0)
     if ((ndx = getindexfromoffset(getaddressoffset(offset))) >= 0)
  return getsizestr(value, ndx);
 break;
      case 27:
 if ((offset = dynget(25)) != 0)
     if ((ndx = getindexfromoffset(getaddressoffset(offset))) >= 0)
  return getsizestr(value, ndx);
 break;
      case 28:
 if ((offset = dynget(26)) != 0)
     if ((ndx = getindexfromoffset(getaddressoffset(offset))) >= 0)
  return getsizestr(value, ndx);
 break;
      case 33:
 if ((offset = dynget(32)) != 0)
     if ((ndx = getindexfromoffset(getaddressoffset(offset))) >= 0)
  return getsizestr(value, ndx);
 break;
      case 19:
 if (value == ((int)(iself64() ? sizeof(Elf64_Rel) : sizeof(Elf32_Rel))))
     return (iself64() ? "sizeof(Elf64_" "Rel" ")" : "sizeof(Elf32_" "Rel" ")");
 if ((offset = dynget(17)) != 0)
     if ((ndx = getindexfromoffset(getaddressoffset(offset))) >= 0)
  return getsizestr(value, ndx);
 break;
      case 9:
 if (value == ((int)(iself64() ? sizeof(Elf64_Rela) : sizeof(Elf32_Rela))))
     return (iself64() ? "sizeof(Elf64_" "Rela" ")" : "sizeof(Elf32_" "Rela" ")");
 if ((offset = dynget(7)) != 0)
     if ((ndx = getindexfromoffset(getaddressoffset(offset))) >= 0)
  return getsizestr(value, ndx);
 break;
      case 11:
 if (value == ((int)(iself64() ? sizeof(Elf64_Sym) : sizeof(Elf32_Sym))))
     return (iself64() ? "sizeof(Elf64_" "Sym" ")" : "sizeof(Elf32_" "Sym" ")");
 if ((offset = dynget(6)) != 0)
     if ((ndx = getindexfromoffset(getaddressoffset(offset))) >= 0)
  return getsizestr(value, ndx);
 break;
      case 0x6ffffdff:
 if (value == ((int)(iself64() ? sizeof(Elf64_Syminfo) : sizeof(Elf32_Syminfo))))
     return (iself64() ? "sizeof(Elf64_" "Syminfo" ")" : "sizeof(Elf32_" "Syminfo" ")");
 if ((offset = dynget(0x6ffffeff)) != 0)
     if ((ndx = getindexfromoffset(getaddressoffset(offset))) >= 0)
  return getsizestr(value, ndx);
 break;
      case 0x6ffffdfb:
 if ((offset = dynget(0x6ffffefe)) != 0)
     if ((ndx = getindexfromoffset(getaddressoffset(offset))) >= 0)
  return getsizestr(value, ndx);
 break;
      case 0x6ffffdfa:
 if (value == ((int)(iself64() ? sizeof(Elf64_Move) : sizeof(Elf32_Move))))
     return (iself64() ? "sizeof(Elf64_" "Move" ")" : "sizeof(Elf32_" "Move" ")");
 if ((offset = dynget(0x6ffffefe)) != 0)
     if ((ndx = getindexfromoffset(getaddressoffset(offset))) >= 0)
  return getsizestr(value, ndx);
 break;
    }
    return ((void *)0);
}

variable_types: tag long


textout

decompiled_code:
__int64 __fastcall textout(char *s)
{
int v1; // ebx
__int64 result; // rax

v1 = strlen(s);
if ( fputs(s, outfile) == -1 )
fail(0LL);
xpos += v1;
result = (__int64)strrchr(s, 10);
if ( result )
{
result = strlen((const char *)(result + 1));
xpos = result;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *s)
{
int v1; // ebx
__int64 result; // rax

v1 = strlen(s);
if ( fputs(s, outfile) == -1 )
fail(0LL);
xpos += v1;
result = (__int64)strrchr(s, 10);
if ( result )
{
result = strlen((const char *)(result + 1));
xpos = result;
}
return result;
}

original_code:
static void textout(char const *str)
{
    int n;
    n = strlen(str);
    if (fputs(str, outfile) == (-1))
 fail(((void *)0));
    xpos += n;
    str = strrchr(str, '\n');
    if (str)
 xpos = strlen(str + 1);
}

canonical_original_code:
static void textout(char *str)
{
    int n;
    n = strlen(str);
    if (fputs(str, outfile) == (-1))
 fail(((void *)0));
    xpos += n;
    str = strrchr(str, '\n');
    if (str)
 xpos = strlen(str + 1);
}

variable_types:
str
char *


stringchar

decompiled_code:
char *__fastcall stringchar(char *a1)
{
char v1; // bl
char *result; // rax
char v3; // al

v1 = *a1;
if ( *a1 > 34 )
{
result = (char *)&unk_74C;
if ( v1 == 92 )
return result;
LABEL_8:
if ( ((*_ctype_b_loc())[v1] & 0x4000) != 0 || v1 == 32 )
{
buf_0 = v1;
result = &buf_0;
byte_729 = 0;
}
else
{
buf_0 = 92;
byte_729 = ((unsigned __int8)*a1 >> 6) + 48;
byte_72A = (((unsigned __int8)*a1 >> 3) & 7) + 48;
v3 = *a1;
byte_72C = 0;
byte_72B = (v3 & 7) + 48;
result = &buf_0;
}
return result;
}
if ( v1 <= 6 )
{
LABEL_6:
if ( !v1 )
{
result = (char *)&unk_767;
if ( (unsigned __int8)(a1[1] - 48) > 7u )
return result;
}
goto LABEL_8;
}
switch ( v1 )
{
case 7:
result = (char *)&unk_764;
break;
case 8:
result = (char *)&unk_74F;
break;
case 9:
result = (char *)&unk_752;
break;
case 10:
result = (char *)&unk_75B;
break;
case 11:
result = (char *)&unk_758;
break;
case 12:
result = (char *)&unk_755;
break;
case 13:
result = (char *)&unk_75E;
break;
case 34:
result = (char *)&unk_761;
break;
default:
goto LABEL_6;
}
return result;
}

canonical_decompiled_code:
char *__fastcall func1(char *a1)
{
char v1; // bl
char *result; // rax
char v3; // al

v1 = *a1;
if ( *a1 > 34 )
{
result = (char *)&unk_74C;
if ( v1 == 92 )
return result;
LABEL_8:
if ( ((*_ctype_b_loc())[v1] & 0x4000) != 0 || v1 == 32 )
{
buf_0 = v1;
result = &buf_0;
byte_729 = 0;
}
else
{
buf_0 = 92;
byte_729 = ((unsigned __int8)*a1 >> 6) + 48;
byte_72A = (((unsigned __int8)*a1 >> 3) & 7) + 48;
v3 = *a1;
byte_72C = 0;
byte_72B = (v3 & 7) + 48;
result = &buf_0;
}
return result;
}
if ( v1 <= 6 )
{
LABEL_6:
if ( !v1 )
{
result = (char *)&unk_767;
if ( (unsigned __int8)(a1[1] - 48) > 7u )
return result;
}
goto LABEL_8;
}
switch ( v1 )
{
case 7:
result = (char *)&unk_764;
break;
case 8:
result = (char *)&unk_74F;
break;
case 9:
result = (char *)&unk_752;
break;
case 10:
result = (char *)&unk_75B;
break;
case 11:
result = (char *)&unk_758;
break;
case 12:
result = (char *)&unk_755;
break;
case 13:
result = (char *)&unk_75E;
break;
case 34:
result = (char *)&unk_761;
break;
default:
goto LABEL_6;
}
return result;
}

original_code:
static char const *stringchar(char const *ptr)
{
    static char buf[8];
    switch (*ptr) {
      case '\a': return "\\a"; case '\r': return "\\r";
      case '\b': return "\\b"; case '\t': return "\\t";
      case '\f': return "\\f"; case '\v': return "\\v";
      case '\n': return "\\n"; case '\\': return "\\\\";
      case '"': return "\\\"";
    }
    if (!*ptr && !(ptr[1] >= '0' && ptr[1] <= '7'))
 return "\\0";
    else if (((*__ctype_b_loc ())[(int) ((*ptr))] & (unsigned short int) _ISprint) || *ptr == ' ') {
 buf[0] = *ptr;
 buf[1] = '\0';
    } else {
 buf[0] = '\\';
 buf[1] = '0' + ((unsigned char)*ptr / 64);
 buf[2] = '0' + (((unsigned char)*ptr / 8) % 8);
 buf[3] = '0' + ((unsigned char)*ptr % 8);
 buf[4] = '\0';
    }
    return buf;
}

canonical_original_code:
static char *stringchar(char *ptr)
{
    static char buf[8];
    switch (*ptr) {
      case '\a': return "\\a"; case '\r': return "\\r";
      case '\b': return "\\b"; case '\t': return "\\t";
      case '\f': return "\\f"; case '\v': return "\\v";
      case '\n': return "\\n"; case '\\': return "\\\\";
      case '"': return "\\\"";
    }
    if (!*ptr && !(ptr[1] >= '0' && ptr[1] <= '7'))
 return "\\0";
    else if (((*__ctype_b_loc ())[(int) ((*ptr))] & (unsigned short) _ISprint) || *ptr == ' ') {
 buf[0] = *ptr;
 buf[1] = '\0';
    } else {
 buf[0] = '\\';
 buf[1] = '0' + ((unsigned char)*ptr / 64);
 buf[2] = '0' + (((unsigned char)*ptr / 8) % 8);
 buf[3] = '0' + ((unsigned char)*ptr % 8);
 buf[4] = '\0';
    }
    return buf;
}

variable_types:
ptr
char *

variable_types:
buf
char [8]


setoutputwidth

decompiled_code:
void __fastcall setoutputwidth(int a1)
{
if ( a1 )
rmargin = a1 - 4;
}

canonical_decompiled_code:
void __fastcall func3(int a1)
{
if ( a1 )
rmargin = a1 - 4;
}

original_code:
void setoutputwidth(int width)
{
    if (width)
 rmargin = width - 4;
}

variable_types: width int


setoutputindent

decompiled_code:
void __fastcall setoutputindent(int a1)
{
if ( a1 )
indent = a1;
}

canonical_decompiled_code:
void __fastcall func4(int a1)
{
if ( a1 )
indent = a1;
}

original_code:
void setoutputindent(int width)
{
    if (width)
 indent = width;
}


linebreak

decompiled_code:
int linebreak()
{
int v0; // ebx
int result; // eax

if ( pendingcomma )
{
fputc(44, outfile);
pendingcomma = 0;
}
v0 = indent * level;
result = xpos;
if ( xpos > indent * level )
{
fputc(10, outfile);
result = 0;
xpos = 0;
}
if ( v0 > result )
{
result = fprintf(outfile, "%*s", v0 - result, (const char *)&unk_76A);
xpos = v0;
}
return result;
}

canonical_decompiled_code:
int func5()
{
int v0; // ebx
int result; // eax

if ( pendingcomma )
{
fputc(44, outfile);
pendingcomma = 0;
}
v0 = indent * level;
result = xpos;
if ( xpos > indent * level )
{
fputc(10, outfile);
result = 0;
xpos = 0;
}
if ( v0 > result )
{
result = fprintf(outfile, "%*s", v0 - result, (const char *)&unk_76A);
xpos = v0;
}
return result;
}

original_code:
void linebreak(void)
{
    int n;
    if (pendingcomma) {
 fputc(',', outfile);
 pendingcomma = 0;
    }
    n = level * indent;
    if (xpos > n) {
 fputc('\n', outfile);
 xpos = 0;
    }
    if (xpos < n) {
 fprintf(outfile, "%*s", n - xpos, "");
 xpos = n;
    }
}

canonical_original_code:
void linebreak()
{
    int n;
    if (pendingcomma) {
 fputc(',', outfile);
 pendingcomma = 0;
    }
    n = level * indent;
    if (xpos > n) {
 fputc('\n', outfile);
 xpos = 0;
    }
    if (xpos < n) {
 fprintf(outfile, "%*s", n - xpos, "");
 xpos = n;
    }
}


beginblock

decompiled_code:
int __fastcall beginblock(int a1)
{
int v1; // eax

linebreak();
pendingcomma = 0;
v1 = level;
blockstack[level] = a1;
level = v1 + 1;
if ( !a1 )
return textout("{ ");
textout("{\n");
return linebreak();
}

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

func5();
pendingcomma = 0;
v1 = level;
blockstack[level] = a1;
level = v1 + 1;
if ( !a1 )
return func0("{ ");
func0("{\n");
return func5();
}

original_code:
void beginblock(int brk)
{
    linebreak();
    blockstack[level] = brk;
    ++level;
    pendingcomma = 0;
    if (brk) {
 textout("{\n");
 linebreak();
    } else {
 textout("{ ");
    }
}

variable_types: brk int


endblock

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

pendingcomma = 0;
if ( blockstack[--level] )
{
linebreak();
if ( level )
{
LABEL_3:
result = textout("}");
pendingcomma = -1;
return result;
}
}
else
{
textout(" ");
if ( level )
goto LABEL_3;
}
return textout("};\n");
}

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

pendingcomma = 0;
if ( blockstack[--level] )
{
func5();
if ( level )
{
LABEL_3:
result = func0("}");
pendingcomma = -1;
return result;
}
}
else
{
func0(" ");
if ( level )
goto LABEL_3;
}
return func0("};\n");
}

original_code:
void endblock(void)
{
    pendingcomma = 0;
    --level;
    if (blockstack[level])
 linebreak();
    else
 textout(" ");
    if (level) {
 textout("}");
 pendingcomma = -1;
    } else {
 textout("};\n");
    }
}

canonical_original_code:
void endblock()
{
    pendingcomma = 0;
    --level;
    if (blockstack[level])
 linebreak();
    else
 textout(" ");
    if (level) {
 textout("}");
 pendingcomma = -1;
    } else {
 textout("};\n");
    }
}


out

decompiled_code:
_BOOL8 __fastcall out(char *s)
{
_BOOL8 result; // rax

if ( (int)(xpos + strlen(s)) >= rmargin )
linebreak();
if ( pendingcomma )
{
if ( pendingcomma > 0 && xpos + 2 < rmargin )
textout(", ");
else
linebreak();
}
textout(s);
result = level > 0;
pendingcomma = level > 0;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func8(char *s)
{
_BOOL8 result; // rax

if ( (int)(xpos + strlen(s)) >= rmargin )
func5();
if ( pendingcomma )
{
if ( pendingcomma > 0 && xpos + 2 < rmargin )
func0(", ");
else
func5();
}
func0(s);
result = level > 0;
pendingcomma = level > 0;
return result;
}

original_code:
void out(char const *str)
{
    int n;
    n = strlen(str);
    if (xpos + n >= rmargin)
 linebreak();
    if (pendingcomma) {
 if (pendingcomma > 0 && xpos + 2 < rmargin)
     textout(", ");
 else
     linebreak();
    }
    textout(str);
    pendingcomma = level > 0;
}

canonical_original_code:
void out(char *str)
{
    int n;
    n = strlen(str);
    if (xpos + n >= rmargin)
 linebreak();
    if (pendingcomma) {
 if (pendingcomma > 0 && xpos + 2 < rmargin)
     textout(", ");
 else
     linebreak();
    }
    textout(str);
    pendingcomma = level > 0;
}


outcomment

decompiled_code:
int __fastcall outcomment(char *a1)
{
int v1; // eax
int result; // eax
int v3; // ebx
__int64 v4; // rbp
const char *v5; // rdi
char *v6; // rax
int v7; // [rsp+0h] [rbp-18h]

if ( strstr(a1, "*/") )
{
v4 = strallocate();
v5 = (const char *)v4;
while ( 1 )
{
v6 = strstr(v5, "*/");
v5 = v6;
if ( !v6 )
break;
*v6 = 43;
}
outcomment(v4);
result = deallocate(v4);
}
else
{
v1 = xpos + strlen(a1);
if ( !pendingcomma )
{
if ( v1 + 7 >= rmargin )
linebreak();
goto LABEL_5;
}
if ( v1 + 9 >= rmargin )
{
linebreak();
pendingcomma = 0;
LABEL_5:
textout("/* ");
textout(a1);
return textout(" */");
}
textout(", ");
v3 = pendingcomma;
pendingcomma = 0;
textout("/* ");
textout(a1);
textout(" */");
if ( v3 >= 0 )
result = v7;
else
result = linebreak();
}
return result;
}

canonical_decompiled_code:
int __fastcall func9(char *a1)
{
int v1; // eax
int result; // eax
int v3; // ebx
__int64 v4; // rbp
const char *v5; // rdi
char *v6; // rax
int v7; // [rsp+0h] [rbp-18h]

if ( strstr(a1, "*/") )
{
v4 = strallocate();
v5 = (const char *)v4;
while ( 1 )
{
v6 = strstr(v5, "*/");
v5 = v6;
if ( !v6 )
break;
*v6 = 43;
}
func9(v4);
result = deallocate(v4);
}
else
{
v1 = xpos + strlen(a1);
if ( !pendingcomma )
{
if ( v1 + 7 >= rmargin )
func5();
goto LABEL_5;
}
if ( v1 + 9 >= rmargin )
{
func5();
pendingcomma = 0;
LABEL_5:
func0("/* ");
func0(a1);
return func0(" */");
}
func0(", ");
v3 = pendingcomma;
pendingcomma = 0;
func0("/* ");
func0(a1);
func0(" */");
if ( v3 >= 0 )
result = v7;
else
result = func5();
}
return result;
}

original_code:
void outcomment(char const *text)
{
    int pendingbreak = 0;
    int length;
    if (strstr(text, "*/")) {
 char *copy = strallocate(text);
 char *p = copy;
 while ((p = strstr(p, "*/")) != ((void *)0))
     *p = '+';
 outcomment(copy);
 deallocate(copy);
 return;
    }
    length = strlen(text);
    if (pendingcomma) {
 if (xpos + length + 9 >= rmargin) {
     linebreak();
 } else {
     textout(", ");
     pendingbreak = (pendingcomma < 0);
 }
 pendingcomma = 0;
    } else {
 if (xpos + length + 7 >= rmargin)
     linebreak();
    }
    textout("/* ");
    textout(text);
    textout(" */");
    if (pendingbreak)
 linebreak();
}

canonical_original_code:
void outcomment(char *text)
{
    int pendingbreak = 0;
    int length;
    if (strstr(text, "*/")) {
 char *copy = strallocate(text);
 char *p = copy;
 while ((p = strstr(p, "*/")) != ((void *)0))
     *p = '+';
 outcomment(copy);
 deallocate(copy);
 return;
    }
    length = strlen(text);
    if (pendingcomma) {
 if (xpos + length + 9 >= rmargin) {
     linebreak();
 } else {
     textout(", ");
     pendingbreak = (pendingcomma < 0);
 }
 pendingcomma = 0;
    } else {
 if (xpos + length + 7 >= rmargin)
     linebreak();
    }
    textout("/* ");
    textout(text);
    textout(" */");
    if (pendingbreak)
 linebreak();
}

variable_types:
text
char *

variable_types: pendingbreak int

variable_types: length int

variable_types:
copy
char *

variable_types:
p
char *