outxwords

decompiled_code:
__int64 __fastcall outxwords(unsigned __int64 *a1, unsigned __int64 a2)
{
__int64 v2; // r13
_QWORD *v3; // rdx
__int64 v4; // rax
unsigned __int64 v6; // rbx
__int64 v7; // r13
unsigned __int64 *v8; // rax
unsigned __int64 v9; // rdx
const char *v10; // r14
__int64 i; // rbp
__int64 v12; // rax
char v13[56]; // [rsp+0h] [rbp-38h] BYREF

v2 = a2 >> 3;
if ( !(a2 >> 3) )
return out("{ 0 }");
v3 = (unsigned __int64 *)((char *)a1 + (a2 & 0xFFFFFFFFFFFFFFF8LL) - 8);
v4 = 0LL;
while ( !*v3 )
{
++v4;
--v3;
if ( v2 == v4 )
return out("{ 0 }");
}
if ( v2 == v4 )
return out("{ 0 }");
if ( v4 <= 254 )
{
v4 = 0LL;
}
else if ( 4 * v4 < v2 )
{
v4 = 0LL;
}
v6 = v4 & 0xFFFFFFFFFFFFFFFCLL;
v7 = v2 - (v4 & 0xFFFFFFFFFFFFFFFCLL);
if ( v7 <= 0 )
{
beginblock(1LL);
v10 = "%lu";
}
else
{
v8 = a1;
v9 = 0LL;
do
{
if ( v9 < *v8 )
v9 = *v8;
++v8;
}
while ( v8 != &a1[v7] );
if ( v9 <= 0xFFFFFFFF )
{
v10 = "0x%08lX";
if ( v9 <= 0xFFFF )
{
v10 = "0x%04lX";
if ( v9 <= 0xFF )
{
v10 = "0x%02lX";
if ( v9 <= 0x63 )
v10 = "%lu";
}
}
beginblock(1LL);
}
else
{
beginblock(1LL);
v10 = "0x%016lX";
}
for ( i = 0LL; i < v7; ++i )
outf(v10, a1[i]);
}
if ( v6 )
{
sprintf(v13, "%s x %%ld", v10);
v12 = strf(v13, 0LL, v6);
outcomment(v12);
}
return endblock();
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned __int64 *a1, unsigned __int64 a2)
{
__int64 v2; // r13
_QWORD *v3; // rdx
__int64 v4; // rax
unsigned __int64 v6; // rbx
__int64 v7; // r13
unsigned __int64 *v8; // rax
unsigned __int64 v9; // rdx
const char *v10; // r14
__int64 i; // rbp
__int64 v12; // rax
char v13[56]; // [rsp+0h] [rbp-38h] BYREF

v2 = a2 >> 3;
if ( !(a2 >> 3) )
return out("{ 0 }");
v3 = (unsigned __int64 *)((char *)a1 + (a2 & 0xFFFFFFFFFFFFFFF8LL) - 8);
v4 = 0LL;
while ( !*v3 )
{
++v4;
--v3;
if ( v2 == v4 )
return out("{ 0 }");
}
if ( v2 == v4 )
return out("{ 0 }");
if ( v4 <= 254 )
{
v4 = 0LL;
}
else if ( 4 * v4 < v2 )
{
v4 = 0LL;
}
v6 = v4 & 0xFFFFFFFFFFFFFFFCLL;
v7 = v2 - (v4 & 0xFFFFFFFFFFFFFFFCLL);
if ( v7 <= 0 )
{
beginblock(1LL);
v10 = "%lu";
}
else
{
v8 = a1;
v9 = 0LL;
do
{
if ( v9 < *v8 )
v9 = *v8;
++v8;
}
while ( v8 != &a1[v7] );
if ( v9 <= 0xFFFFFFFF )
{
v10 = "0x%08lX";
if ( v9 <= 0xFFFF )
{
v10 = "0x%04lX";
if ( v9 <= 0xFF )
{
v10 = "0x%02lX";
if ( v9 <= 0x63 )
v10 = "%lu";
}
}
beginblock(1LL);
}
else
{
beginblock(1LL);
v10 = "0x%016lX";
}
for ( i = 0LL; i < v7; ++i )
outf(v10, a1[i]);
}
if ( v6 )
{
sprintf(v13, "%s x %%ld", v10);
v12 = strf(v13, 0LL, v6);
outcomment(v12);
}
return endblock();
}

original_code:
static void outxwords(void const *ptr, long size, int ndx)
{
    Elf64_Xword const *xwords = ptr;
    long count = size / sizeof *xwords;
    char fmtbuf[16];
    char const *fmt = ((void *)0);
    unsigned long max;
    long zeroes, i;
    (void)ndx;
    for (zeroes = 0 ; zeroes < count ; ++zeroes)
 if (xwords[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 < xwords[i])
     max = xwords[i];
    }
    fmt = max > 0xFFFFFFFF ? "0x%016lX" :
   max > 0x0000FFFF ? "0x%08lX" :
   max > 0x000000FF ? "0x%04lX" : max > 99 ? "0x%02lX" : "%lu";
    beginblock(1);
    for (i = 0 ; i < count ; ++i)
 outf(fmt, xwords[i]);
    if (zeroes) {
 sprintf(fmtbuf, "%s x %%ld", fmt);
 outcomment(strf(fmtbuf, 0, zeroes));
    }
    endblock();
}

canonical_original_code:
static void outxwords(void *ptr, long size, int ndx)
{
    unsigned long *xwords = ptr;
    long count = size / sizeof *xwords;
    char fmtbuf[16];
    char *fmt = ((void *)0);
    unsigned long max;
    long zeroes; long i;
    (void)ndx;
    for (zeroes = 0 ; zeroes < count ; ++zeroes)
 if (xwords[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 < xwords[i])
     max = xwords[i];
    }
    fmt = max > 0xFFFFFFFF ? "0x%016lX" :
   max > 0x0000FFFF ? "0x%08lX" :
   max > 0x000000FF ? "0x%04lX" : max > 99 ? "0x%02lX" : "%lu";
    beginblock(1);
    for (i = 0 ; i < count ; ++i)
 outf(fmt, xwords[i]);
    if (zeroes) {
 sprintf(fmtbuf, "%s x %%ld", fmt);
 outcomment(strf(fmtbuf, 0, zeroes));
    }
    endblock();
}

variable_types:
xwords
unsigned long *

variable_types:
fmtbuf
char [16]

variable_types:
fmt
char *

variable_types:
max
unsigned long

variable_types: zeroes long


outwords

decompiled_code:
__int64 __fastcall outwords(unsigned int *a1, unsigned __int64 a2)
{
__int64 v2; // r13
_DWORD *v3; // rdx
__int64 v4; // rax
unsigned __int64 v6; // rbx
__int64 v7; // r13
unsigned int *v8; // rax
unsigned __int64 v9; // rdx
const char *v10; // r14
__int64 i; // rbp
__int64 v12; // rdi
char v13[56]; // [rsp+0h] [rbp-38h] BYREF

v2 = a2 >> 2;
if ( !(a2 >> 2) )
return out("{ 0 }");
v3 = (unsigned int *)((char *)a1 + (a2 & 0xFFFFFFFFFFFFFFFCLL) - 4);
v4 = 0LL;
while ( !*v3 )
{
++v4;
--v3;
if ( v2 == v4 )
return out("{ 0 }");
}
if ( v2 == v4 )
return out("{ 0 }");
if ( v4 <= 254 )
{
v4 = 0LL;
}
else if ( 4 * v4 < v2 )
{
v4 = 0LL;
}
v6 = v4 & 0xFFFFFFFFFFFFFFFCLL;
v7 = v2 - (v4 & 0xFFFFFFFFFFFFFFFCLL);
if ( v7 <= 0 )
{
beginblock(1LL);
v10 = "%u";
}
else
{
v8 = a1;
v9 = 0LL;
do
{
if ( v9 < *v8 )
v9 = *v8;
++v8;
}
while ( v8 != &a1[v7] );
if ( v9 <= 0xFFFF )
{
v10 = "0x%04X";
if ( v9 <= 0xFF )
{
v10 = "0x%02X";
if ( v9 <= 0x63 )
v10 = "%u";
}
beginblock(1LL);
}
else
{
beginblock(1LL);
v10 = "0x%08X";
}
for ( i = 0LL; i < v7; ++i )
outf(v10, a1[i]);
}
if ( v6 )
{
sprintf(v13, "%s x %%ld", v10);
v12 = strf(v13, 0LL, v6);
outcomment(v12);
}
return endblock();
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned int *a1, unsigned __int64 a2)
{
__int64 v2; // r13
_DWORD *v3; // rdx
__int64 v4; // rax
unsigned __int64 v6; // rbx
__int64 v7; // r13
unsigned int *v8; // rax
unsigned __int64 v9; // rdx
const char *v10; // r14
__int64 i; // rbp
__int64 v12; // rdi
char v13[56]; // [rsp+0h] [rbp-38h] BYREF

v2 = a2 >> 2;
if ( !(a2 >> 2) )
return out("{ 0 }");
v3 = (unsigned int *)((char *)a1 + (a2 & 0xFFFFFFFFFFFFFFFCLL) - 4);
v4 = 0LL;
while ( !*v3 )
{
++v4;
--v3;
if ( v2 == v4 )
return out("{ 0 }");
}
if ( v2 == v4 )
return out("{ 0 }");
if ( v4 <= 254 )
{
v4 = 0LL;
}
else if ( 4 * v4 < v2 )
{
v4 = 0LL;
}
v6 = v4 & 0xFFFFFFFFFFFFFFFCLL;
v7 = v2 - (v4 & 0xFFFFFFFFFFFFFFFCLL);
if ( v7 <= 0 )
{
beginblock(1LL);
v10 = "%u";
}
else
{
v8 = a1;
v9 = 0LL;
do
{
if ( v9 < *v8 )
v9 = *v8;
++v8;
}
while ( v8 != &a1[v7] );
if ( v9 <= 0xFFFF )
{
v10 = "0x%04X";
if ( v9 <= 0xFF )
{
v10 = "0x%02X";
if ( v9 <= 0x63 )
v10 = "%u";
}
beginblock(1LL);
}
else
{
beginblock(1LL);
v10 = "0x%08X";
}
for ( i = 0LL; i < v7; ++i )
outf(v10, a1[i]);
}
if ( v6 )
{
sprintf(v13, "%s x %%ld", v10);
v12 = strf(v13, 0LL, v6);
outcomment(v12);
}
return endblock();
}

original_code:
static void outwords(void const *ptr, long size, int ndx)
{
    Elf64_Word const *words = ptr;
    long count = size / sizeof *words;
    char fmtbuf[16];
    char const *fmt = ((void *)0);
    unsigned long max;
    long zeroes, i;
    (void)ndx;
    for (zeroes = 0 ; zeroes < count ; ++zeroes)
 if (words[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 < words[i])
     max = words[i];
    }
    fmt = max > 0xFFFF ? "0x%08X" :
   max > 0x00FF ? "0x%04X" : max > 99 ? "0x%02X" : "%u";
    beginblock(1);
    for (i = 0 ; i < count ; ++i)
 outf(fmt, words[i]);
    if (zeroes) {
 sprintf(fmtbuf, "%s x %%ld", fmt);
 outcomment(strf(fmtbuf, 0, zeroes));
    }
    endblock();
}

canonical_original_code:
static void outwords(void *ptr, long size, int ndx)
{
    unsigned int *words = ptr;
    long count = size / sizeof *words;
    char fmtbuf[16];
    char *fmt = ((void *)0);
    unsigned long max;
    long zeroes; long i;
    (void)ndx;
    for (zeroes = 0 ; zeroes < count ; ++zeroes)
 if (words[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 < words[i])
     max = words[i];
    }
    fmt = max > 0xFFFF ? "0x%08X" :
   max > 0x00FF ? "0x%04X" : max > 99 ? "0x%02X" : "%u";
    beginblock(1);
    for (i = 0 ; i < count ; ++i)
 outf(fmt, words[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:
words
unsigned int *

variable_types: count long

variable_types: i long

return_type: void


outgnuhash

decompiled_code:
__int64 __fastcall outgnuhash(unsigned int *a1, unsigned __int64 a2)
{
unsigned int *v2; // rbx
signed __int64 v3; // r13
int v4; // er14
int v5; // er12
unsigned int *v6; // rbp
__int64 v7; // rdi
__int64 v8; // rbp
unsigned int *v10; // rbp
unsigned int *v11; // r12
unsigned __int64 v12; // r14
__int64 v13; // rdi
unsigned int v14; // [rsp+Ch] [rbp-3Ch]

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

canonical_decompiled_code:
__int64 __fastcall func5(unsigned int *a1, unsigned __int64 a2)
{
unsigned int *v2; // rbx
signed __int64 v3; // r13
int v4; // er14
int v5; // er12
unsigned int *v6; // rbp
__int64 v7; // rdi
__int64 v8; // rbp
unsigned int *v10; // rbp
unsigned int *v11; // r12
unsigned __int64 v12; // r14
__int64 v13; // rdi
unsigned int v14; // [rsp+Ch] [rbp-3Ch]

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

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:
entries
unsigned int *

variable_types: buckets int

variable_types: masks int

variable_types: i int

variable_types: n int


outhalves

decompiled_code:
__int64 __fastcall outhalves(unsigned __int16 *a1, unsigned __int64 a2)
{
__int64 v2; // r13
_WORD *v3; // rdx
__int64 v4; // rax
unsigned __int64 v6; // rbx
__int64 v7; // r13
unsigned __int16 *v8; // rax
unsigned int v9; // edx
const char *v10; // r14
__int64 i; // rbp
__int64 v12; // rdi
char v13[56]; // [rsp+0h] [rbp-38h] BYREF

v2 = a2 >> 1;
if ( !(a2 >> 1) )
return out("{ 0 }");
v3 = (unsigned __int16 *)((char *)a1 + (a2 & 0xFFFFFFFFFFFFFFFELL) - 2);
v4 = 0LL;
while ( !*v3 )
{
++v4;
--v3;
if ( v2 == v4 )
return out("{ 0 }");
}
if ( v2 == v4 )
return out("{ 0 }");
if ( v4 <= 254 )
{
v4 = 0LL;
}
else if ( 4 * v4 < v2 )
{
v4 = 0LL;
}
v6 = v4 & 0xFFFFFFFFFFFFFFFCLL;
v7 = v2 - (v4 & 0xFFFFFFFFFFFFFFFCLL);
if ( v7 <= 0 )
{
beginblock(1LL);
v10 = "%u";
}
else
{
v8 = a1;
v9 = 0;
do
{
if ( v9 < *v8 )
v9 = *v8;
++v8;
}
while ( v8 != &a1[v7] );
if ( v9 <= 0xFF )
{
v10 = "0x%02X";
if ( v9 <= 0x63 )
v10 = "%u";
beginblock(1LL);
}
else
{
beginblock(1LL);
v10 = "0x%04X";
}
for ( i = 0LL; i < v7; ++i )
outf(v10, a1[i]);
}
if ( v6 )
{
sprintf(v13, "%s x %%ld", v10);
v12 = strf(v13, 0LL, v6);
outcomment(v12);
}
return endblock();
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned __int16 *a1, unsigned __int64 a2)
{
__int64 v2; // r13
_WORD *v3; // rdx
__int64 v4; // rax
unsigned __int64 v6; // rbx
__int64 v7; // r13
unsigned __int16 *v8; // rax
unsigned int v9; // edx
const char *v10; // r14
__int64 i; // rbp
__int64 v12; // rdi
char v13[56]; // [rsp+0h] [rbp-38h] BYREF

v2 = a2 >> 1;
if ( !(a2 >> 1) )
return out("{ 0 }");
v3 = (unsigned __int16 *)((char *)a1 + (a2 & 0xFFFFFFFFFFFFFFFELL) - 2);
v4 = 0LL;
while ( !*v3 )
{
++v4;
--v3;
if ( v2 == v4 )
return out("{ 0 }");
}
if ( v2 == v4 )
return out("{ 0 }");
if ( v4 <= 254 )
{
v4 = 0LL;
}
else if ( 4 * v4 < v2 )
{
v4 = 0LL;
}
v6 = v4 & 0xFFFFFFFFFFFFFFFCLL;
v7 = v2 - (v4 & 0xFFFFFFFFFFFFFFFCLL);
if ( v7 <= 0 )
{
beginblock(1LL);
v10 = "%u";
}
else
{
v8 = a1;
v9 = 0;
do
{
if ( v9 < *v8 )
v9 = *v8;
++v8;
}
while ( v8 != &a1[v7] );
if ( v9 <= 0xFF )
{
v10 = "0x%02X";
if ( v9 <= 0x63 )
v10 = "%u";
beginblock(1LL);
}
else
{
beginblock(1LL);
v10 = "0x%04X";
}
for ( i = 0LL; i < v7; ++i )
outf(v10, a1[i]);
}
if ( v6 )
{
sprintf(v13, "%s x %%ld", v10);
v12 = strf(v13, 0LL, v6);
outcomment(v12);
}
return endblock();
}

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:
halves
unsigned short *

variable_types:
max
unsigned int


outbytes

decompiled_code:
__int64 __fastcall outbytes(unsigned __int8 *a1, __int64 a2)
{
unsigned __int8 *v2; // r13
__int64 v3; // rbp
unsigned __int8 *v4; // rdx
__int64 v5; // rax
unsigned __int64 v7; // rbx
__int64 v8; // rax
__int64 v9; // rdi
__int64 v10; // r12
__int64 v11; // rdi
__int64 v12; // rdi
unsigned __int8 *v13; // r12
unsigned __int8 *v14; // rbp

v2 = a1;
v3 = a2;
if ( a2 <= 0 )
{
if ( a2 )
{
v8 = ((__int64 (*)(void))outstringsize)();
v7 = 0LL;
if ( forcehex )
{
beginblock(1LL);
v7 = 0LL;
goto LABEL_30;
}
goto LABEL_26;
}
return out("{ 0 }");
}
v4 = &a1[a2 - 1];
v5 = 0LL;
while ( !*v4 )
{
++v5;
--v4;
if ( a2 == v5 )
return out("{ 0 }");
}
if ( a2 == v5 )
return out("{ 0 }");
if ( v5 <= 254 || 4 * v5 < a2 )
{
v8 = outstringsize(a1, a2);
v7 = 0LL;
if ( forcehex )
{
beginblock(1LL);
v7 = 0LL;
goto LABEL_28;
}
}
else
{
v7 = v5 & 0xFFFFFFFFFFFFFFF8LL;
v8 = outstringsize(a1, a2);
if ( forcehex )
{
LABEL_27:
beginblock(1LL);
v3 = a2 - v7;
if ( (__int64)(a2 - v7) > 0 )
{
LABEL_28:
v13 = a1;
v14 = &a1[v3];
do
outf("0x%02X", *v13++);
while ( v13 != v14 );
}
LABEL_30:
if ( v7 )
{
v9 = strf("0x00 x %d", v7);
outcomment(v9);
}
return endblock();
}
}
LABEL_26:
if ( 2 * v8 > 3 * a2 )
goto LABEL_27;
if ( v7 )
{
beginblock(1LL);
v3 = a2 - v7;
if ( (__int64)(a2 - v7) <= 0 )
{
LABEL_20:
v12 = strf("0x00 x %ld", v7);
outcomment(v12);
return endblock();
}
LABEL_14:
v10 = 0LL;
do
{
v11 = strchar(v2[v10]);
out(v11);
++v10;
}
while ( v10 < v3 );
if ( !v7 )
return endblock();
goto LABEL_20;
}
if ( !a1[a2 - 1] )
return outstring(a1, a2 - 1);
beginblock(1LL);
if ( a2 > 0 )
goto LABEL_14;
return endblock();
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned __int8 *a1, __int64 a2)
{
unsigned __int8 *v2; // r13
__int64 v3; // rbp
unsigned __int8 *v4; // rdx
__int64 v5; // rax
unsigned __int64 v7; // rbx
__int64 v8; // rax
__int64 v9; // rdi
__int64 v10; // r12
__int64 v11; // rdi
__int64 v12; // rdi
unsigned __int8 *v13; // r12
unsigned __int8 *v14; // rbp

v2 = a1;
v3 = a2;
if ( a2 <= 0 )
{
if ( a2 )
{
v8 = ((__int64 (*)(void))outstringsize)();
v7 = 0LL;
if ( forcehex )
{
beginblock(1LL);
v7 = 0LL;
goto LABEL_30;
}
goto LABEL_26;
}
return out("{ 0 }");
}
v4 = &a1[a2 - 1];
v5 = 0LL;
while ( !*v4 )
{
++v5;
--v4;
if ( a2 == v5 )
return out("{ 0 }");
}
if ( a2 == v5 )
return out("{ 0 }");
if ( v5 <= 254 || 4 * v5 < a2 )
{
v8 = outstringsize(a1, a2);
v7 = 0LL;
if ( forcehex )
{
beginblock(1LL);
v7 = 0LL;
goto LABEL_28;
}
}
else
{
v7 = v5 & 0xFFFFFFFFFFFFFFF8LL;
v8 = outstringsize(a1, a2);
if ( forcehex )
{
LABEL_27:
beginblock(1LL);
v3 = a2 - v7;
if ( (__int64)(a2 - v7) > 0 )
{
LABEL_28:
v13 = a1;
v14 = &a1[v3];
do
outf("0x%02X", *v13++);
while ( v13 != v14 );
}
LABEL_30:
if ( v7 )
{
v9 = strf("0x00 x %d", v7);
outcomment(v9);
}
return endblock();
}
}
LABEL_26:
if ( 2 * v8 > 3 * a2 )
goto LABEL_27;
if ( v7 )
{
beginblock(1LL);
v3 = a2 - v7;
if ( (__int64)(a2 - v7) <= 0 )
{
LABEL_20:
v12 = strf("0x00 x %ld", v7);
outcomment(v12);
return endblock();
}
LABEL_14:
v10 = 0LL;
do
{
v11 = strchar(v2[v10]);
out(v11);
++v10;
}
while ( v10 < v3 );
if ( !v7 )
return endblock();
goto LABEL_20;
}
if ( !a1[a2 - 1] )
return outstring(a1, a2 - 1);
beginblock(1LL);
if ( a2 > 0 )
goto LABEL_14;
return endblock();
}

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

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

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

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)
{
bool v2; // di
int v3; // edx
__int64 result; // rax
__int64 (__fastcall **v5)(_QWORD); // rbx

v2 = 0;
if ( *(int *)(a1 + 4) > 0 )
v2 = *(_QWORD *)(a1 + 8) != 0LL;
v3 = validate(v2, "empty blueprint");
result = 0LL;
if ( v3 )
{
v5 = *(__int64 (__fastcall ***)(_QWORD))(a1 + 8);
if ( *(int *)(a1 + 4) <= 0 )
{
result = 1LL;
}
else
{
while ( 1 )
{
if ( *v5 )
{
result = (*v5)(v5);
if ( !(_BYTE)result )
break;
}
v5 += 12;
if ( (__int64)(0xAAAAAAAAAAAAAAABLL * (((__int64)v5 - *(_QWORD *)(a1 + 8)) >> 5)) >= *(int *)(a1 + 4) )
return 1LL;
}
}
}
return result;
}

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

v2 = 0;
if ( *(int *)(a1 + 4) > 0 )
v2 = *(_QWORD *)(a1 + 8) != 0LL;
v3 = func3(v2, "empty blueprint");
result = 0LL;
if ( v3 )
{
v5 = *(__int64 (__fastcall ***)(_QWORD))(a1 + 8);
if ( *(int *)(a1 + 4) <= 0 )
{
result = 1LL;
}
else
{
while ( 1 )
{
if ( *v5 )
{
result = (*v5)(v5);
if ( !(_BYTE)result )
break;
}
v5 += 12;
if ( (__int64)(0xAAAAAAAAAAAAAAABLL * (((__int64)v5 - *(_QWORD *)(a1 + 8)) >> 5)) >= *(int *)(a1 + 4) )
return 1LL;
}
}
}
return result;
}

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

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

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

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)
{
int v3; // ebx
int v4; // eax
int v5; // edx
__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) + 96LL * v3;
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, int a2, int a3)
{
int v3; // ebx
int v4; // eax
int v5; // edx
__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) + 96LL * 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)
{
int v3; // ebx
int v4; // eax
int v5; // edx
__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) + 96LL * v3;
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, int a2, int a3)
{
int v3; // ebx
int v4; // eax
int v5; // edx
__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) + 96LL * 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)
{
int v3; // ebx
int v4; // eax
int v5; // edx
__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) + 96LL * v3;
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, int a2, int a3)
{
int v3; // ebx
int v4; // eax
int v5; // edx
__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) + 96LL * 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)
{
int v3; // ebx
int v4; // eax
int v5; // edx
__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) + 96LL * v3;
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, int a2, int a3)
{
int v3; // ebx
int v4; // eax
int v5; // edx
__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) + 96LL * 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; // ebp
int v4; // eax
int v5; // edx
__int64 result; // rax

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

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

v3 = a3;
v4 = a3;
if ( a2 >= a3 )
v4 = a2;
v5 = func3(*(_DWORD *)(a1 + 4) > v4, "invalid index in setrelsection()");
result = 0LL;
if ( v5 )
{
*(_DWORD *)(*(_QWORD *)(a1 + 8) + 96LL * a2 + 88) = v3;
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; // rdx
__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; // rdx
__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; // rbp
__int64 v1; // r13
__int64 v2; // rax
__int64 v3; // rbx
__int64 v4; // r14
__int64 v5; // r12
__int64 v6; // r12
__int64 v7; // r12
__int64 v8; // r12
__int64 v9; // r12
__int64 v10; // r12
__int64 v11; // r12
__int64 v12; // r12
__int64 v13; // r12
_DWORD *v14; // rax
__int64 v15; // rax
__int64 v16; // rax
int v17; // eax
unsigned int v18; // eax
int v19; // eax
__int64 v20; // r15
__int64 v21; // r12
int v22; // eax
unsigned int v23; // eax
unsigned int v24; // er12
int v25; // eax
__int64 v26; // r15
__int64 v27; // r12
int v28; // eax
unsigned int v29; // eax
unsigned int v30; // er12
int v31; // eax
unsigned int v32; // er15
__int64 v33; // r12
int v34; // eax
unsigned int v35; // eax
unsigned int v36; // er15
__int64 v37; // r12
int v38; // eax
int v39; // eax
__int64 v40; // r12
int v41; // eax
__int64 v42; // r12
int v43; // eax
__int64 v44; // r12
int v45; // eax
__int64 v46; // r12
__int64 v47; // rax
int v48; // eax
int v49; // er12
int v50; // eax
int v51; // eax
__int64 v52[8]; // [rsp+8h] [rbp-40h] BYREF

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

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

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

if ( a1 <= 33 )
{
result = 0LL;
if ( a1 > 1 )
{
switch ( a1 )
{
case 2LL:
v19 = dynget(23LL);
result = 0LL;
if ( v19 )
{
v20 = getaddressoffset(v19);
v21 = getindexfromoffset(v20);
result = 0LL;
if ( v21 >= 0 )
return (const char *)getsizestr(a2);
}
break;
case 8LL:
v16 = dynget(7LL);
result = 0LL;
if ( v16 )
{
v17 = getaddressoffset(v16);
v18 = getindexfromoffset(v17);
result = 0LL;
if ( v18 >= 0 )
return (const char *)getsizestr(a2);
}
break;
case 9LL:
if ( (-(__int64)((unsigned int)iself64() == 0) & 0xFFFFFFFFFFFFFFF4LL) + 24 == a2 )
{
v37 = (unsigned int)iself64() == 0;
result = "sizeof(Elf32_Rela)";
if ( !v37 )
result = "sizeof(Elf64_Rela)";
}
else
{
v38 = dynget(7LL);
result = 0LL;
if ( v38 )
{
v39 = getaddressoffset(v38);
v40 = getindexfromoffset(v39);
result = 0LL;
if ( v40 >= 0 )
return (const char *)getsizestr(a2);
}
}
break;
case 10LL:
v10 = dynget(5LL);
result = 0LL;
if ( v10 )
{
v11 = getaddressoffset(v10);
v12 = getindexfromoffset(v11);
result = 0LL;
if ( v12 >= 0 )
return (const char *)getsizestr(a2);
}
break;
case 11LL:
if ( (-(__int64)((unsigned int)iself64() == 0) & 0xFFFFFFFFFFFFFFF8LL) + 24 == a2 )
{
v37 = (unsigned int)iself64() == 0;
result = "sizeof(Elf32_Sym)";
if ( !v37 )
result = "sizeof(Elf64_Sym)";
}
else
{
v41 = dynget(6LL);
result = 0LL;
if ( v41 )
{
v42 = getaddressoffset(v41);
v43 = getindexfromoffset(v42);
result = 0LL;
if ( v43 >= 0 )
return (const char *)getsizestr(a2);
}
}
break;
case 18LL:
v13 = dynget(17LL);
result = 0LL;
if ( v13 )
{
v14 = getaddressoffset(v13);
v15 = getindexfromoffset(v14);
result = 0LL;
if ( v15 >= 0 )
return (const char *)getsizestr(a2);
}
break;
case 19LL:
if ( (-(__int64)((unsigned int)iself64() == 0) & 0xFFFFFFFFFFFFFFF8LL) + 16 == a2 )
{
v37 = (unsigned int)iself64() == 0;
result = "sizeof(Elf32_Rel)";
if ( !v37 )
result = "sizeof(Elf64_Rel)";
}
else
{
v34 = dynget(17LL);
result = 0LL;
if ( v34 )
{
v35 = getaddressoffset(v34);
v36 = getindexfromoffset(v35);
result = 0LL;
if ( v36 >= 0 )
return (const char *)getsizestr(a2);
}
}
break;
case 27LL:
v25 = dynget(25LL);
result = 0LL;
if ( v25 )
{
v26 = getaddressoffset(v25);
v27 = getindexfromoffset(v26);
result = 0LL;
if ( v27 >= 0 )
return (const char *)getsizestr(a2);
}
break;
case 28LL:
v28 = dynget(26LL);
result = 0LL;
if ( v28 )
{
v29 = getaddressoffset(v28);
v30 = getindexfromoffset(v29);
result = 0LL;
if ( v30 >= 0 )
return (const char *)getsizestr(a2);
}
break;
case 33LL:
v31 = dynget(32LL);
result = 0LL;
if ( v31 )
{
v32 = getaddressoffset(v31);
v33 = getindexfromoffset(v32);
result = 0LL;
if ( v33 >= 0 )
return (const char *)getsizestr(a2);
}
break;
default:
result = 0LL;
break;
}
}
return result;
}
if ( a1 == 1879047678 )
{
v22 = dynget(1879047935LL);
result = 0LL;
if ( !v22 )
return result;
v23 = getaddressoffset(v22);
v24 = getindexfromoffset(v23);
result = 0LL;
if ( v24 < 0 )
return result;
return (const char *)getsizestr(a2);
}
if ( a1 <= 1879047678 )
{
if ( a1 != 1879047674 )
{
if ( a1 != 1879047675 )
return 0LL;
v7 = dynget(1879047934LL);
result = 0LL;
if ( v7 )
{
v8 = getaddressoffset(v7);
v9 = getindexfromoffset(v8);
result = 0LL;
if ( v9 >= 0 )
return (const char *)getsizestr(a2);
}
return result;
}
if ( (-(__int64)((unsigned int)iself64() == 0) & 0xFFFFFFFFFFFFFFF8LL) + 32 == a2 )
{
v37 = (unsigned int)iself64() == 0;
result = "sizeof(Elf32_Move)";
if ( !v37 )
result = "sizeof(Elf64_Move)";
return result;
}
v44 = dynget(1879047934LL);
result = 0LL;
if ( !v44 )
return result;
v45 = getaddressoffset(v44);
v46 = getindexfromoffset(v45);
result = 0LL;
if ( v46 < 0 )
return result;
return (const char *)getsizestr(a2);
}
result = 0LL;
if ( a1 != 1879047679 )
return result;
iself64();
if ( a2 != 4 )
{
v4 = dynget(1879047935LL);
result = 0LL;
if ( !v4 )
return result;
v5 = getaddressoffset(v4);
v6 = getindexfromoffset(v5);
result = 0LL;
if ( v6 < 0 )
return result;
return (const char *)getsizestr(a2);
}
v37 = (unsigned int)iself64() == 0;
result = "sizeof(Elf32_Syminfo)";
if ( !v37 )
result = "sizeof(Elf64_Syminfo)";
return result;
}

canonical_decompiled_code:
const char *__fastcall func5(__int64 a1, __int64 a2)
{
const char *result; // rax
__int64 v4; // rdi
__int64 v5; // rax
int v6; // esi
__int64 v7; // rdi
__int64 v8; // rax
int v9; // esi
__int64 v10; // rdi
__int64 v11; // rax
int v12; // esi
__int64 v13; // rdi
__int64 v14; // rax
int v15; // esi
__int64 v16; // rdi
__int64 v17; // rax
int v18; // esi
__int64 v19; // rdi
__int64 v20; // rax
int v21; // esi
__int64 v22; // rdi
__int64 v23; // rax
int v24; // esi
__int64 v25; // rdi
__int64 v26; // rax
int v27; // esi
__int64 v28; // rdi
__int64 v29; // rax
int v30; // esi
__int64 v31; // rdi
__int64 v32; // rax
int v33; // esi
__int64 v34; // rdi
__int64 v35; // rax
int v36; // esi
bool v37; // zf
__int64 v38; // rdi
__int64 v39; // rax
int v40; // esi
__int64 v41; // rdi
__int64 v42; // rax
int v43; // esi
__int64 v44; // rdi
__int64 v45; // rax
int v46; // esi

if ( a1 <= 33 )
{
result = 0LL;
if ( a1 > 1 )
{
switch ( a1 )
{
case 2LL:
v19 = func1(23LL);
result = 0LL;
if ( v19 )
{
v20 = getaddressoffset(v19);
v21 = getindexfromoffset(v20);
result = 0LL;
if ( v21 >= 0 )
return (const char *)getsizestr(a2);
}
break;
case 8LL:
v16 = func1(7LL);
result = 0LL;
if ( v16 )
{
v17 = getaddressoffset(v16);
v18 = getindexfromoffset(v17);
result = 0LL;
if ( v18 >= 0 )
return (const char *)getsizestr(a2);
}
break;
case 9LL:
if ( (-(__int64)((unsigned int)iself64() == 0) & 0xFFFFFFFFFFFFFFF4LL) + 24 == a2 )
{
v37 = (unsigned int)iself64() == 0;
result = "sizeof(Elf32_Rela)";
if ( !v37 )
result = "sizeof(Elf64_Rela)";
}
else
{
v38 = func1(7LL);
result = 0LL;
if ( v38 )
{
v39 = getaddressoffset(v38);
v40 = getindexfromoffset(v39);
result = 0LL;
if ( v40 >= 0 )
return (const char *)getsizestr(a2);
}
}
break;
case 10LL:
v10 = func1(5LL);
result = 0LL;
if ( v10 )
{
v11 = getaddressoffset(v10);
v12 = getindexfromoffset(v11);
result = 0LL;
if ( v12 >= 0 )
return (const char *)getsizestr(a2);
}
break;
case 11LL:
if ( (-(__int64)((unsigned int)iself64() == 0) & 0xFFFFFFFFFFFFFFF8LL) + 24 == a2 )
{
v37 = (unsigned int)iself64() == 0;
result = "sizeof(Elf32_Sym)";
if ( !v37 )
result = "sizeof(Elf64_Sym)";
}
else
{
v41 = func1(6LL);
result = 0LL;
if ( v41 )
{
v42 = getaddressoffset(v41);
v43 = getindexfromoffset(v42);
result = 0LL;
if ( v43 >= 0 )
return (const char *)getsizestr(a2);
}
}
break;
case 18LL:
v13 = func1(17LL);
result = 0LL;
if ( v13 )
{
v14 = getaddressoffset(v13);
v15 = getindexfromoffset(v14);
result = 0LL;
if ( v15 >= 0 )
return (const char *)getsizestr(a2);
}
break;
case 19LL:
if ( (-(__int64)((unsigned int)iself64() == 0) & 0xFFFFFFFFFFFFFFF8LL) + 16 == a2 )
{
v37 = (unsigned int)iself64() == 0;
result = "sizeof(Elf32_Rel)";
if ( !v37 )
result = "sizeof(Elf64_Rel)";
}
else
{
v34 = func1(17LL);
result = 0LL;
if ( v34 )
{
v35 = getaddressoffset(v34);
v36 = getindexfromoffset(v35);
result = 0LL;
if ( v36 >= 0 )
return (const char *)getsizestr(a2);
}
}
break;
case 27LL:
v25 = func1(25LL);
result = 0LL;
if ( v25 )
{
v26 = getaddressoffset(v25);
v27 = getindexfromoffset(v26);
result = 0LL;
if ( v27 >= 0 )
return (const char *)getsizestr(a2);
}
break;
case 28LL:
v28 = func1(26LL);
result = 0LL;
if ( v28 )
{
v29 = getaddressoffset(v28);
v30 = getindexfromoffset(v29);
result = 0LL;
if ( v30 >= 0 )
return (const char *)getsizestr(a2);
}
break;
case 33LL:
v31 = func1(32LL);
result = 0LL;
if ( v31 )
{
v32 = getaddressoffset(v31);
v33 = getindexfromoffset(v32);
result = 0LL;
if ( v33 >= 0 )
return (const char *)getsizestr(a2);
}
break;
default:
result = 0LL;
break;
}
}
return result;
}
if ( a1 == 1879047678 )
{
v22 = func1(1879047935LL);
result = 0LL;
if ( !v22 )
return result;
v23 = getaddressoffset(v22);
v24 = getindexfromoffset(v23);
result = 0LL;
if ( v24 < 0 )
return result;
return (const char *)getsizestr(a2);
}
if ( a1 <= 1879047678 )
{
if ( a1 != 1879047674 )
{
if ( a1 != 1879047675 )
return 0LL;
v7 = func1(1879047934LL);
result = 0LL;
if ( v7 )
{
v8 = getaddressoffset(v7);
v9 = getindexfromoffset(v8);
result = 0LL;
if ( v9 >= 0 )
return (const char *)getsizestr(a2);
}
return result;
}
if ( (-(__int64)((unsigned int)iself64() == 0) & 0xFFFFFFFFFFFFFFF8LL) + 32 == a2 )
{
v37 = (unsigned int)iself64() == 0;
result = "sizeof(Elf32_Move)";
if ( !v37 )
result = "sizeof(Elf64_Move)";
return result;
}
v44 = func1(1879047934LL);
result = 0LL;
if ( !v44 )
return result;
v45 = getaddressoffset(v44);
v46 = getindexfromoffset(v45);
result = 0LL;
if ( v46 < 0 )
return result;
return (const char *)getsizestr(a2);
}
result = 0LL;
if ( a1 != 1879047679 )
return result;
iself64();
if ( a2 != 4 )
{
v4 = func1(1879047935LL);
result = 0LL;
if ( !v4 )
return result;
v5 = getaddressoffset(v4);
v6 = getindexfromoffset(v5);
result = 0LL;
if ( v6 < 0 )
return result;
return (const char *)getsizestr(a2);
}
v37 = (unsigned int)iself64() == 0;
result = "sizeof(Elf32_Syminfo)";
if ( !v37 )
result = "sizeof(Elf64_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; // ebp
__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; // ebp
__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

v1 = *a1;
if ( *a1 > 34 )
{
result = (char *)&unk_62C;
if ( v1 == 92 )
return result;
LABEL_15:
if ( ((*_ctype_b_loc())[v1] & 0x4000) != 0 || v1 == 32 )
{
buf_0 = v1;
byte_609 = 0;
result = &buf_0;
}
else
{
buf_0 = 92;
byte_609 = ((unsigned __int8)*a1 >> 6) + 48;
byte_60A = (((unsigned __int8)*a1 >> 3) & 7) + 48;
byte_60B = (*a1 & 7) + 48;
byte_60C = 0;
result = &buf_0;
}
return result;
}
if ( v1 <= 6 )
{
LABEL_13:
if ( !v1 )
{
result = (char *)&unk_647;
if ( (unsigned __int8)(a1[1] - 48) > 7u )
return result;
}
goto LABEL_15;
}
switch ( v1 )
{
case 7:
result = (char *)&unk_644;
break;
case 8:
result = (char *)&unk_62F;
break;
case 9:
result = (char *)&unk_632;
break;
case 10:
result = (char *)&unk_63B;
break;
case 11:
result = (char *)&unk_638;
break;
case 12:
result = (char *)&unk_635;
break;
case 13:
result = (char *)&unk_63E;
break;
case 34:
result = (char *)&unk_641;
break;
default:
goto LABEL_13;
}
return result;
}

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

v1 = *a1;
if ( *a1 > 34 )
{
result = (char *)&unk_62C;
if ( v1 == 92 )
return result;
LABEL_15:
if ( ((*_ctype_b_loc())[v1] & 0x4000) != 0 || v1 == 32 )
{
buf_0 = v1;
byte_609 = 0;
result = &buf_0;
}
else
{
buf_0 = 92;
byte_609 = ((unsigned __int8)*a1 >> 6) + 48;
byte_60A = (((unsigned __int8)*a1 >> 3) & 7) + 48;
byte_60B = (*a1 & 7) + 48;
byte_60C = 0;
result = &buf_0;
}
return result;
}
if ( v1 <= 6 )
{
LABEL_13:
if ( !v1 )
{
result = (char *)&unk_647;
if ( (unsigned __int8)(a1[1] - 48) > 7u )
return result;
}
goto LABEL_15;
}
switch ( v1 )
{
case 7:
result = (char *)&unk_644;
break;
case 8:
result = (char *)&unk_62F;
break;
case 9:
result = (char *)&unk_632;
break;
case 10:
result = (char *)&unk_63B;
break;
case 11:
result = (char *)&unk_638;
break;
case 12:
result = (char *)&unk_635;
break;
case 13:
result = (char *)&unk_63E;
break;
case 34:
result = (char *)&unk_641;
break;
default:
goto LABEL_13;
}
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;
if ( xpos > indent * level )
{
fputc(10, outfile);
xpos = 0;
}
result = xpos;
if ( xpos < v0 )
{
result = fprintf(outfile, "%*s", v0 - xpos, (const char *)&unk_64A);
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;
if ( xpos > indent * level )
{
fputc(10, outfile);
xpos = 0;
}
result = xpos;
if ( xpos < v0 )
{
result = fprintf(outfile, "%*s", v0 - xpos, (const char *)&unk_64A);
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();
v1 = level;
blockstack[level] = a1;
level = v1 + 1;
pendingcomma = 0;
if ( !a1 )
return textout("{ ");
textout("{\n");
return linebreak();
}

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

func5();
v1 = level;
blockstack[level] = a1;
level = v1 + 1;
pendingcomma = 0;
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();
else
textout(" ");
if ( !level )
return textout("};\n");
result = textout("}");
pendingcomma = -1;
return result;
}

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

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

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