decompiled_code:
__int64 __fastcall elfu_mSymtabLookupSymToAddr(__int64 a1, __int64 a2, unsigned int *a3, _QWORD *a4)
{
__int64 v6; // rdx
unsigned int v7; // eax
__int64 v8; // rsi
__int64 v9; // rax
__int64 v10; // rdx
__int64 result; // rax

v6 = *((unsigned __int8 *)a3 + 21);
if ( (_BYTE)v6 == 3 )
{
if ( !*((_QWORD *)a3 + 3) )
_assert_fail("sym->scnptr", "src/libelfu/model/symtab.c", 0x30u, "elfu_mSymtabLookupSymToAddr");
if ( !((__int64 (*)(void))elfu_mScnByOldscn)() )
_assert_fail(
"elfu_mScnByOldscn(me, sym->scnptr)",
"src/libelfu/model/symtab.c",
0x31u,
"elfu_mSymtabLookupSymToAddr");
*a4 = *(_QWORD *)(elfu_mScnByOldscn(a1, *((_QWORD *)a3 + 3)) + 16);
result = 0LL;
}
else if ( (unsigned __int8)v6 > 3u )
{
if ( (_BYTE)v6 == 4 )
fwrite("elfu_mSymtabLookupSymToAddr: Symbol type FILE is not supported.\n", 1uLL, 0x40uLL, stderr);
else
fprintf(
stderr,
"elfu_mSymtabLookupSymToAddr: Unknown symbol type %d for %s.\n",
v6,
(const char *)(*(_QWORD *)(*(_QWORD *)(a2 + 72) + 64LL) + *a3));
result = 0xFFFFFFFFLL;
}
else
{
v7 = a3[8];
switch ( v7 )
{
case 0u:
goto LABEL_17;
case 0xFFF1u:
*a4 = *((_QWORD *)a3 + 1);
return 0LL;
case 0xFFF2u:
LABEL_17:
result = 0xFFFFFFFFLL;
break;
default:
v8 = *((_QWORD *)a3 + 3);
if ( !v8 )
_assert_fail("sym->scnptr", "src/libelfu/model/symtab.c", 0x28u, "elfu_mSymtabLookupSymToAddr");
v9 = elfu_mScnByOldscn(a1, v8);
if ( !v9 )
_assert_fail("newscn", "src/libelfu/model/symtab.c", 0x2Au, "elfu_mSymtabLookupSymToAddr");
v10 = *(_QWORD *)(v9 + 16) + *((_QWORD *)a3 + 1);
result = 0LL;
*a4 = v10;
break;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, unsigned int *a3, _QWORD *a4)
{
__int64 v6; // rdx
unsigned int v7; // eax
__int64 v8; // rsi
__int64 v9; // rax
__int64 v10; // rdx
__int64 result; // rax

v6 = *((unsigned __int8 *)a3 + 21);
if ( (_BYTE)v6 == 3 )
{
if ( !*((_QWORD *)a3 + 3) )
_assert_fail("sym->scnptr", "src/libelfu/model/symtab.c", 0x30u, "elfu_mSymtabLookupSymToAddr");
if ( !((__int64 (*)(void))elfu_mScnByOldscn)() )
_assert_fail(
"elfu_mScnByOldscn(me, sym->scnptr)",
"src/libelfu/model/symtab.c",
0x31u,
"elfu_mSymtabLookupSymToAddr");
*a4 = *(_QWORD *)(elfu_mScnByOldscn(a1, *((_QWORD *)a3 + 3)) + 16);
result = 0LL;
}
else if ( (unsigned __int8)v6 > 3u )
{
if ( (_BYTE)v6 == 4 )
fwrite("elfu_mSymtabLookupSymToAddr: Symbol type FILE is not supported.\n", 1uLL, 0x40uLL, stderr);
else
fprintf(
stderr,
"elfu_mSymtabLookupSymToAddr: Unknown symbol type %d for %s.\n",
v6,
(const char *)(*(_QWORD *)(*(_QWORD *)(a2 + 72) + 64LL) + *a3));
result = 0xFFFFFFFFLL;
}
else
{
v7 = a3[8];
switch ( v7 )
{
case 0u:
goto LABEL_17;
case 0xFFF1u:
*a4 = *((_QWORD *)a3 + 1);
return 0LL;
case 0xFFF2u:
LABEL_17:
result = 0xFFFFFFFFLL;
break;
default:
v8 = *((_QWORD *)a3 + 3);
if ( !v8 )
_assert_fail("sym->scnptr", "src/libelfu/model/symtab.c", 0x28u, "elfu_mSymtabLookupSymToAddr");
v9 = elfu_mScnByOldscn(a1, v8);
if ( !v9 )
_assert_fail("newscn", "src/libelfu/model/symtab.c", 0x2Au, "elfu_mSymtabLookupSymToAddr");
v10 = *(_QWORD *)(v9 + 16) + *((_QWORD *)a3 + 1);
result = 0LL;
*a4 = v10;
break;
}
}
return result;
}

original_code:
int elfu_mSymtabLookupSymToAddr(ElfuElf *me, ElfuScn *msst, ElfuSym *sym, GElf_Addr *result)
{
  char *symname = ((msst)->linkptr->databuf + (sym->name));
  switch (sym->type) {
    case 0:
    case 1:
    case 2:
      if (sym->shndx == 0) {
        return -1;
      } else if (sym->shndx == 0xfff1) {
        *result = sym->value;
        return 0;
      } else if (sym->shndx == 0xfff2) {
        return -1;
      } else {
        ElfuScn *newscn;
        ((void) sizeof ((sym->scnptr) ? 1 : 0), __extension__ ({ if (sym->scnptr) ; else __assert_fail ("sym->scnptr", "src/libelfu/model/symtab.c", 40, __extension__ __PRETTY_FUNCTION__); }));
        newscn = elfu_mScnByOldscn(me, sym->scnptr);
        ((void) sizeof ((newscn) ? 1 : 0), __extension__ ({ if (newscn) ; else __assert_fail ("newscn", "src/libelfu/model/symtab.c", 42, __extension__ __PRETTY_FUNCTION__); }));
        *result = newscn->shdr.sh_addr + sym->value;
        return 0;
      }
      break;
    case 3:
      ((void) sizeof ((sym->scnptr) ? 1 : 0), __extension__ ({ if (sym->scnptr) ; else __assert_fail ("sym->scnptr", "src/libelfu/model/symtab.c", 48, __extension__ __PRETTY_FUNCTION__); }));
      ((void) sizeof ((elfu_mScnByOldscn(me, sym->scnptr)) ? 1 : 0), __extension__ ({ if (elfu_mScnByOldscn(me, sym->scnptr)) ; else __assert_fail ("elfu_mScnByOldscn(me, sym->scnptr)", "src/libelfu/model/symtab.c", 49, __extension__ __PRETTY_FUNCTION__); }));
      *result = elfu_mScnByOldscn(me, sym->scnptr)->shdr.sh_addr;
      return 0;
    case 4:
      do { fprintf(stderr, "elfu_mSymtabLookupSymToAddr: Symbol type FILE is not supported.\n"); } while(0);
      return -1;
    default:
      do { fprintf(stderr, "elfu_mSymtabLookupSymToAddr: Unknown symbol type %d for %s.\n", sym->type, symname); } while(0);
      return -1;
  }
}

canonical_original_code:
int elfu_mSymtabLookupSymToAddr(struct ElfuElf *me, struct ElfuScn *msst, struct ElfuSym *sym, unsigned long *result)
{
  char *symname = ((msst)->linkptr->databuf + (sym->name));
  switch (sym->type) {
    case 0:
    case 1:
    case 2:
      if (sym->shndx == 0) {
        return -1;
      } else if (sym->shndx == 0xfff1) {
        *result = sym->value;
        return 0;
      } else if (sym->shndx == 0xfff2) {
        return -1;
      } else {
        struct ElfuScn *newscn;
        ((void) sizeof ((sym->scnptr) ? 1 : 0), __extension__ ({ if (sym->scnptr) ; else __assert_fail ("sym->scnptr", "src/libelfu/model/symtab.c", 40, __extension__ __PRETTY_FUNCTION__); }));
        newscn = elfu_mScnByOldscn(me, sym->scnptr);
        ((void) sizeof ((newscn) ? 1 : 0), __extension__ ({ if (newscn) ; else __assert_fail ("newscn", "src/libelfu/model/symtab.c", 42, __extension__ __PRETTY_FUNCTION__); }));
        *result = newscn->shdr.sh_addr + sym->value;
        return 0;
      }
      break;
    case 3:
      ((void) sizeof ((sym->scnptr) ? 1 : 0), __extension__ ({ if (sym->scnptr) ; else __assert_fail ("sym->scnptr", "src/libelfu/model/symtab.c", 48, __extension__ __PRETTY_FUNCTION__); }));
      ((void) sizeof ((elfu_mScnByOldscn(me, sym->scnptr)) ? 1 : 0), __extension__ ({ if (elfu_mScnByOldscn(me, sym->scnptr)) ; else __assert_fail ("elfu_mScnByOldscn(me, sym->scnptr)", "src/libelfu/model/symtab.c", 49, __extension__ __PRETTY_FUNCTION__); }));
      *result = elfu_mScnByOldscn(me, sym->scnptr)->shdr.sh_addr;
      return 0;
    case 4:
      do { fprintf(stderr, "elfu_mSymtabLookupSymToAddr: Symbol type FILE is not supported.\n"); } while(0);
      return -1;
    default:
      do { fprintf(stderr, "elfu_mSymtabLookupSymToAddr: Unknown symbol type %d for %s.\n", sym->type, symname); } while(0);
      return -1;
  }
}

variable_types:
msst
struct ElfuScn *

variable_types:
sym
struct ElfuSym *

user_defined_types: struct ElfuRel { unsigned long offset; unsigned int sym; unsigned char type; int addendUsed; int addend; struct { struct ElfuRel *cqe_next; struct ElfuRel *cqe_prev; } elem; }


repo: norly/centaur

decompiled_code:
__int64 __fastcall elfu_mSymtabSymToName(__int64 a1, unsigned int *a2)
{
if ( !a1 )
_assert_fail("msst", "src/libelfu/model/symtab.c", 0x41u, "elfu_mSymtabSymToName");
if ( !a2 )
_assert_fail("sym", "src/libelfu/model/symtab.c", 0x42u, "elfu_mSymtabSymToName");
return *(_QWORD *)(*(_QWORD *)(a1 + 72) + 64LL) + *a2;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, unsigned int *a2)
{
if ( !a1 )
_assert_fail("msst", "src/libelfu/model/symtab.c", 0x41u, "elfu_mSymtabSymToName");
if ( !a2 )
_assert_fail("sym", "src/libelfu/model/symtab.c", 0x42u, "elfu_mSymtabSymToName");
return *(_QWORD *)(*(_QWORD *)(a1 + 72) + 64LL) + *a2;
}

original_code:
char* elfu_mSymtabSymToName(ElfuScn *msst, ElfuSym *sym)
{
  ((void) sizeof ((msst) ? 1 : 0), __extension__ ({ if (msst) ; else __assert_fail ("msst", "src/libelfu/model/symtab.c", 65, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((sym) ? 1 : 0), __extension__ ({ if (sym) ; else __assert_fail ("sym", "src/libelfu/model/symtab.c", 66, __extension__ __PRETTY_FUNCTION__); }));
  return ((msst)->linkptr->databuf + (sym->name));
}

canonical_original_code:
char *elfu_mSymtabSymToName(struct ElfuScn *msst, struct ElfuSym *sym)
{
  ((void) sizeof ((msst) ? 1 : 0), __extension__ ({ if (msst) ; else __assert_fail ("msst", "src/libelfu/model/symtab.c", 65, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((sym) ? 1 : 0), __extension__ ({ if (sym) ; else __assert_fail ("sym", "src/libelfu/model/symtab.c", 66, __extension__ __PRETTY_FUNCTION__); }));
  return ((msst)->linkptr->databuf + (sym->name));
}

variable_types: struct ElfuScn { struct Elf64_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned long sh_flags; unsigned long sh_addr; unsigned long sh_offset; unsigned long sh_size; unsigned int sh_link; unsigned int sh_info; unsigned long sh_addralign; unsigned long sh_entsize; } shdr; char *databuf; struct ElfuScn *linkptr; struct ElfuScn *infoptr; struct ElfuScn *oldptr; struct ElfuSymtab { struct Syms { struct ElfuSym { unsigned int name; unsigned long value; unsigned int size; unsigned char bind; unsigned char type; unsigned char other; struct ElfuScn *scnptr; int shndx; struct { struct ElfuSym *cqe_next; struct ElfuSym *cqe_prev; } elem; } *cqh_first; struct ElfuSym *cqh_last; } syms; } symtab; struct ElfuReltab { struct Rels { struct ElfuRel { unsigned long offset; unsigned int sym; unsigned char type; int addendUsed; int addend; struct { struct ElfuRel *cqe_next; struct ElfuRel *cqe_prev; } elem; } *cqh_first; struct ElfuRel *cqh_last; } rels; } reltab; struct { struct ElfuScn *cqe_next; struct ElfuScn *cqe_prev; } elemChildScn; } *

return_type: char *

user_defined_types: struct ElfuScn { struct Elf64_Shdr shdr; char *databuf; struct ElfuScn *linkptr; struct ElfuScn *infoptr; struct ElfuScn *oldptr; struct ElfuSymtab symtab; struct ElfuReltab reltab; struct { struct ElfuScn *cqe_next; struct ElfuScn *cqe_prev; } elemChildScn; }

user_defined_types: struct Syms { struct ElfuSym *cqh_first; struct ElfuSym *cqh_last; }

user_defined_types: struct Rels { struct ElfuRel *cqh_first; struct ElfuRel *cqh_last; }


decompiled_code:
__int64 __fastcall elfu_mSymtabIndexToSym(__int64 a1, int a2)
{
__int64 v2; // r8
int i; // eax

if ( !a1 )
_assert_fail("msst", "src/libelfu/model/symtab.c", 0x4Eu, "elfu_mSymtabIndexToSym");
if ( !a2 )
_assert_fail("entry > 0", "src/libelfu/model/symtab.c", 0x4Fu, "elfu_mSymtabIndexToSym");
v2 = *(_QWORD *)(a1 + 96);
if ( v2 == a1 + 96 )
_assert_fail("!CIRCLEQ_EMPTY(&msst->symtab.syms)", "src/libelfu/model/symtab.c", 0x50u, "elfu_mSymtabIndexToSym");
for ( i = 1; a2 != i; v2 = *(_QWORD *)(v2 + 40) )
++i;
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, int a2)
{
__int64 v2; // r8
int i; // eax

if ( !a1 )
_assert_fail("msst", "src/libelfu/model/symtab.c", 0x4Eu, "elfu_mSymtabIndexToSym");
if ( !a2 )
_assert_fail("entry > 0", "src/libelfu/model/symtab.c", 0x4Fu, "elfu_mSymtabIndexToSym");
v2 = *(_QWORD *)(a1 + 96);
if ( v2 == a1 + 96 )
_assert_fail("!CIRCLEQ_EMPTY(&msst->symtab.syms)", "src/libelfu/model/symtab.c", 0x50u, "elfu_mSymtabIndexToSym");
for ( i = 1; a2 != i; v2 = *(_QWORD *)(v2 + 40) )
++i;
return v2;
}

original_code:
ElfuSym* elfu_mSymtabIndexToSym(ElfuScn *msst, GElf_Word entry)
{
  GElf_Word i;
  ElfuSym *sym;
  ((void) sizeof ((msst) ? 1 : 0), __extension__ ({ if (msst) ; else __assert_fail ("msst", "src/libelfu/model/symtab.c", 78, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((entry > 0) ? 1 : 0), __extension__ ({ if (entry > 0) ; else __assert_fail ("entry > 0", "src/libelfu/model/symtab.c", 79, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((!((&msst->symtab.syms)->cqh_first == (void *)(&msst->symtab.syms))) ? 1 : 0), __extension__ ({ if (!((&msst->symtab.syms)->cqh_first == (void *)(&msst->symtab.syms))) ; else __assert_fail ("!CIRCLEQ_EMPTY(&msst->symtab.syms)", "src/libelfu/model/symtab.c", 80, __extension__ __PRETTY_FUNCTION__); }));
  sym = ((&msst->symtab.syms)->cqh_first);
  for (i = 1; i < entry; i++) {
    sym = ((sym)->elem.cqe_next);
  }
  return sym;
}

canonical_original_code:
struct ElfuSym *elfu_mSymtabIndexToSym(struct ElfuScn *msst, unsigned int entry)
{
  unsigned int i;
  struct ElfuSym *sym;
  ((void) sizeof ((msst) ? 1 : 0), __extension__ ({ if (msst) ; else __assert_fail ("msst", "src/libelfu/model/symtab.c", 78, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((entry > 0) ? 1 : 0), __extension__ ({ if (entry > 0) ; else __assert_fail ("entry > 0", "src/libelfu/model/symtab.c", 79, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((!((&msst->symtab.syms)->cqh_first == (void *)(&msst->symtab.syms))) ? 1 : 0), __extension__ ({ if (!((&msst->symtab.syms)->cqh_first == (void *)(&msst->symtab.syms))) ; else __assert_fail ("!CIRCLEQ_EMPTY(&msst->symtab.syms)", "src/libelfu/model/symtab.c", 80, __extension__ __PRETTY_FUNCTION__); }));
  sym = ((&msst->symtab.syms)->cqh_first);
  for (i = 1; i < entry; i++) {
    sym = ((sym)->elem.cqe_next);
  }
  return sym;
}

variable_types:
entry
unsigned int

variable_types:
i
unsigned int

variable_types: struct ElfuSym { unsigned int name; unsigned long value; unsigned int size; unsigned char bind; unsigned char type; unsigned char other; struct ElfuScn { struct Elf64_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned long sh_flags; unsigned long sh_addr; unsigned long sh_offset; unsigned long sh_size; unsigned int sh_link; unsigned int sh_info; unsigned long sh_addralign; unsigned long sh_entsize; } shdr; char *databuf; struct ElfuScn *linkptr; struct ElfuScn *infoptr; struct ElfuScn *oldptr; struct ElfuSymtab { struct Syms { struct ElfuSym *cqh_first; struct ElfuSym *cqh_last; } syms; } symtab; struct ElfuReltab { struct Rels { struct ElfuRel { unsigned long offset; unsigned int sym; unsigned char type; int addendUsed; int addend; struct { struct ElfuRel *cqe_next; struct ElfuRel *cqe_prev; } elem; } *cqh_first; struct ElfuRel *cqh_last; } rels; } reltab; struct { struct ElfuScn *cqe_next; struct ElfuScn *cqe_prev; } elemChildScn; } *scnptr; int shndx; struct { struct ElfuSym *cqe_next; struct ElfuSym *cqe_prev; } elem; } *

user_defined_types: struct ElfuSym { unsigned int name; unsigned long value; unsigned int size; unsigned char bind; unsigned char type; unsigned char other; struct ElfuScn *scnptr; int shndx; struct { struct ElfuSym *cqe_next; struct ElfuSym *cqe_prev; } elem; }


decompiled_code:
__int64 __fastcall elfu_mSymtabLookupAddrByName(__int64 a1, __int64 a2, const char *a3)
{
unsigned int *v4; // rbx
__int64 v5; // r12
__int64 v6; // r12
__int64 v8; // rax
unsigned int v9; // eax

if ( !a1 )
_assert_fail("me", "src/libelfu/model/symtab.c", 0x61u, "elfu_mSymtabLookupAddrByName");
if ( !a2 )
_assert_fail("msst", "src/libelfu/model/symtab.c", 0x62u, "elfu_mSymtabLookupAddrByName");
if ( !a3 )
_assert_fail("name", "src/libelfu/model/symtab.c", 0x63u, "elfu_mSymtabLookupAddrByName");
if ( !*a3 )
_assert_fail("strlen(name) > 0", "src/libelfu/model/symtab.c", 0x64u, "elfu_mSymtabLookupAddrByName");
v4 = *(unsigned int **)(a2 + 96);
if ( v4 == (unsigned int *)(a2 + 96) )
_assert_fail(
"!CIRCLEQ_EMPTY(&msst->symtab.syms)",
"src/libelfu/model/symtab.c",
0x65u,
"elfu_mSymtabLookupAddrByName");
v5 = *(_QWORD *)(*(_QWORD *)(a2 + 72) + 64LL);
while ( strcmp((const char *)(v5 + *v4), a3) )
{
v4 = (unsigned int *)*((_QWORD *)v4 + 5);
if ( (unsigned int *)(a2 + 96) == v4 )
return 0LL;
}
if ( *((_BYTE *)v4 + 21) > 2u )
return 0LL;
v8 = *((_QWORD *)v4 + 3);
if ( v8 )
{
v6 = *((_QWORD *)v4 + 1);
if ( *(_WORD *)(a1 + 24) == 1 )
v6 += *(_QWORD *)(v8 + 16);
}
else
{
v9 = v4[8];
v6 = 0LL;
if ( v9 )
{
if ( v9 == 65521 )
v6 = *((_QWORD *)v4 + 1);
else
fwrite(
"elfu_mSymtabLookupAddrByName: Symbol binding COMMON is not supported, using 0.\n",
1uLL,
0x4FuLL,
stderr);
}
}
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, const char *a3)
{
unsigned int *v4; // rbx
__int64 v5; // r12
__int64 v6; // r12
__int64 v8; // rax
unsigned int v9; // eax

if ( !a1 )
_assert_fail("me", "src/libelfu/model/symtab.c", 0x61u, "elfu_mSymtabLookupAddrByName");
if ( !a2 )
_assert_fail("msst", "src/libelfu/model/symtab.c", 0x62u, "elfu_mSymtabLookupAddrByName");
if ( !a3 )
_assert_fail("name", "src/libelfu/model/symtab.c", 0x63u, "elfu_mSymtabLookupAddrByName");
if ( !*a3 )
_assert_fail("strlen(name) > 0", "src/libelfu/model/symtab.c", 0x64u, "elfu_mSymtabLookupAddrByName");
v4 = *(unsigned int **)(a2 + 96);
if ( v4 == (unsigned int *)(a2 + 96) )
_assert_fail(
"!CIRCLEQ_EMPTY(&msst->symtab.syms)",
"src/libelfu/model/symtab.c",
0x65u,
"elfu_mSymtabLookupAddrByName");
v5 = *(_QWORD *)(*(_QWORD *)(a2 + 72) + 64LL);
while ( strcmp((const char *)(v5 + *v4), a3) )
{
v4 = (unsigned int *)*((_QWORD *)v4 + 5);
if ( (unsigned int *)(a2 + 96) == v4 )
return 0LL;
}
if ( *((_BYTE *)v4 + 21) > 2u )
return 0LL;
v8 = *((_QWORD *)v4 + 3);
if ( v8 )
{
v6 = *((_QWORD *)v4 + 1);
if ( *(_WORD *)(a1 + 24) == 1 )
v6 += *(_QWORD *)(v8 + 16);
}
else
{
v9 = v4[8];
v6 = 0LL;
if ( v9 )
{
if ( v9 == 65521 )
v6 = *((_QWORD *)v4 + 1);
else
fwrite(
"elfu_mSymtabLookupAddrByName: Symbol binding COMMON is not supported, using 0.\n",
1uLL,
0x4FuLL,
stderr);
}
}
return v6;
}

original_code:
GElf_Addr elfu_mSymtabLookupAddrByName(ElfuElf *me, ElfuScn *msst, char *name)
{
  ElfuSym *sym;
  ((void) sizeof ((me) ? 1 : 0), __extension__ ({ if (me) ; else __assert_fail ("me", "src/libelfu/model/symtab.c", 97, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((msst) ? 1 : 0), __extension__ ({ if (msst) ; else __assert_fail ("msst", "src/libelfu/model/symtab.c", 98, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((name) ? 1 : 0), __extension__ ({ if (name) ; else __assert_fail ("name", "src/libelfu/model/symtab.c", 99, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((strlen(name) > 0) ? 1 : 0), __extension__ ({ if (strlen(name) > 0) ; else __assert_fail ("strlen(name) > 0", "src/libelfu/model/symtab.c", 100, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((!((&msst->symtab.syms)->cqh_first == (void *)(&msst->symtab.syms))) ? 1 : 0), __extension__ ({ if (!((&msst->symtab.syms)->cqh_first == (void *)(&msst->symtab.syms))) ; else __assert_fail ("!CIRCLEQ_EMPTY(&msst->symtab.syms)", "src/libelfu/model/symtab.c", 101, __extension__ __PRETTY_FUNCTION__); }));
  for ((sym) = ((&msst->symtab.syms)->cqh_first); (sym) != (const void *)(&msst->symtab.syms); (sym) = ((sym)->elem.cqe_next)) {
    char *symname = ((msst)->linkptr->databuf + (sym->name));
    if (!strcmp(symname, name)) {
      goto SYMBOL_FOUND;
    }
  }
  return 0;
  SYMBOL_FOUND:
  switch (sym->type) {
    case 0:
    case 1:
    case 2:
      if (sym->scnptr) {
        GElf_Addr a = sym->value;
        a += me->ehdr.e_type == 1 ? sym->scnptr->shdr.sh_addr : 0;
        return a;
      } else if (sym->shndx == 0) {
        return 0;
      } else if (sym->shndx == 0xfff1) {
        return sym->value;
      } else {
        do { fprintf(stderr, "elfu_mSymtabLookupAddrByName: Symbol binding COMMON is not supported, using 0.\n"); } while(0);
        return 0;
      }
      break;
    default:
      return 0;
  }
}

canonical_original_code:
unsigned long elfu_mSymtabLookupAddrByName(struct ElfuElf *me, struct ElfuScn *msst, char *name)
{
  struct ElfuSym *sym;
  ((void) sizeof ((me) ? 1 : 0), __extension__ ({ if (me) ; else __assert_fail ("me", "src/libelfu/model/symtab.c", 97, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((msst) ? 1 : 0), __extension__ ({ if (msst) ; else __assert_fail ("msst", "src/libelfu/model/symtab.c", 98, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((name) ? 1 : 0), __extension__ ({ if (name) ; else __assert_fail ("name", "src/libelfu/model/symtab.c", 99, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((strlen(name) > 0) ? 1 : 0), __extension__ ({ if (strlen(name) > 0) ; else __assert_fail ("strlen(name) > 0", "src/libelfu/model/symtab.c", 100, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((!((&msst->symtab.syms)->cqh_first == (void *)(&msst->symtab.syms))) ? 1 : 0), __extension__ ({ if (!((&msst->symtab.syms)->cqh_first == (void *)(&msst->symtab.syms))) ; else __assert_fail ("!CIRCLEQ_EMPTY(&msst->symtab.syms)", "src/libelfu/model/symtab.c", 101, __extension__ __PRETTY_FUNCTION__); }));
  for ((sym) = ((&msst->symtab.syms)->cqh_first); (sym) != (void *)(&msst->symtab.syms); (sym) = ((sym)->elem.cqe_next)) {
    char *symname = ((msst)->linkptr->databuf + (sym->name));
    if (!strcmp(symname, name)) {
      goto SYMBOL_FOUND;
    }
  }
  return 0;
  SYMBOL_FOUND:
  switch (sym->type) {
    case 0:
    case 1:
    case 2:
      if (sym->scnptr) {
        unsigned long a = sym->value;
        a += me->ehdr.e_type == 1 ? sym->scnptr->shdr.sh_addr : 0;
        return a;
      } else if (sym->shndx == 0) {
        return 0;
      } else if (sym->shndx == 0xfff1) {
        return sym->value;
      } else {
        do { fprintf(stderr, "elfu_mSymtabLookupAddrByName: Symbol binding COMMON is not supported, using 0.\n"); } while(0);
        return 0;
      }
      break;
    default:
      return 0;
  }
}

variable_types: struct ElfuElf { int elfclass; 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; } ehdr; struct PhdrList { struct ElfuPhdr { struct Elf64_Phdr { unsigned int p_type; unsigned int p_flags; unsigned long p_offset; unsigned long p_vaddr; unsigned long p_paddr; unsigned long p_filesz; unsigned long p_memsz; unsigned long p_align; } phdr; struct ChildScnList { struct ElfuScn { struct Elf64_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned long sh_flags; unsigned long sh_addr; unsigned long sh_offset; unsigned long sh_size; unsigned int sh_link; unsigned int sh_info; unsigned long sh_addralign; unsigned long sh_entsize; } shdr; char *databuf; struct ElfuScn *linkptr; struct ElfuScn *infoptr; struct ElfuScn *oldptr; struct ElfuSymtab { struct Syms { struct ElfuSym { unsigned int name; unsigned long value; unsigned int size; unsigned char bind; unsigned char type; unsigned char other; struct ElfuScn *scnptr; int shndx; struct { struct ElfuSym *cqe_next; struct ElfuSym *cqe_prev; } elem; } *cqh_first; struct ElfuSym *cqh_last; } syms; } symtab; struct ElfuReltab { struct Rels { struct ElfuRel { unsigned long offset; unsigned int sym; unsigned char type; int addendUsed; int addend; struct { struct ElfuRel *cqe_next; struct ElfuRel *cqe_prev; } elem; } *cqh_first; struct ElfuRel *cqh_last; } rels; } reltab; struct { struct ElfuScn *cqe_next; struct ElfuScn *cqe_prev; } elemChildScn; } *cqh_first; struct ElfuScn *cqh_last; } childScnList; struct ChildPhdrList { struct ElfuPhdr *cqh_first; struct ElfuPhdr *cqh_last; } childPhdrList; struct { struct ElfuPhdr *cqe_next; struct ElfuPhdr *cqe_prev; } elemChildPhdr; struct { struct ElfuPhdr *cqe_next; struct ElfuPhdr *cqe_prev; } elem; } *cqh_first; struct ElfuPhdr *cqh_last; } phdrList; struct OrphanScnList { struct ElfuScn *cqh_first; struct ElfuScn *cqh_last; } orphanScnList; struct ElfuScn *shstrtab; struct ElfuScn *symtab; } *

variable_types:
name
char *

variable_types:
symname
char *

variable_types:
a
unsigned long

return_type: unsigned long

user_defined_types: struct ElfuElf { int elfclass; struct Elf64_Ehdr ehdr; struct PhdrList phdrList; struct OrphanScnList orphanScnList; struct ElfuScn *shstrtab; struct ElfuScn *symtab; }

user_defined_types: struct PhdrList { struct ElfuPhdr *cqh_first; struct ElfuPhdr *cqh_last; }

user_defined_types: struct ElfuPhdr { struct Elf64_Phdr phdr; struct ChildScnList childScnList; struct ChildPhdrList childPhdrList; struct { struct ElfuPhdr *cqe_next; struct ElfuPhdr *cqe_prev; } elemChildPhdr; struct { struct ElfuPhdr *cqe_next; struct ElfuPhdr *cqe_prev; } elem; }

user_defined_types: struct ChildScnList { struct ElfuScn *cqh_first; struct ElfuScn *cqh_last; }


decompiled_code:
void __fastcall elfu_mSymtabAddGlobalDymtabIfNotPresent(__int64 a1)
{
__int64 v2; // rbp
__int64 v3; // rax
__int64 v4; // r12
_BOOL8 v5; // rax
_BYTE *v6; // rax
__int64 v7; // rdx
__int64 v8; // rax
__int64 v9; // rdi
__int64 v10; // rdi

if ( !a1 )
_assert_fail("me", "src/libelfu/model/symtab.c", 0xDDu, "elfu_mSymtabAddGlobalDymtabIfNotPresent");
if ( !*(_QWORD *)(a1 + 112) )
{
v2 = elfu_mScnAlloc();
if ( !v2 )
_assert_fail("symtab", "src/libelfu/model/symtab.c", 0xE4u, "elfu_mSymtabAddGlobalDymtabIfNotPresent");
v3 = elfu_mScnAlloc();
v4 = v3;
if ( !v3 )
_assert_fail("strtab", "src/libelfu/model/symtab.c", 0xE6u, "elfu_mSymtabAddGlobalDymtabIfNotPresent");
*(_QWORD *)(v2 + 72) = v3;
v5 = *(_DWORD *)a1 != 1;
*(_QWORD *)(v2 + 48) = 4LL;
*(_QWORD *)(v2 + 56) = 8 * v5 + 16;
*(_QWORD *)(v4 + 48) = 1LL;
*(_DWORD *)(v2 + 4) = 2;
*(_DWORD *)(v4 + 4) = 3;
v6 = malloc(1uLL);
*(_QWORD *)(v4 + 64) = v6;
if ( !v6 )
_assert_fail("strtab->databuf", "src/libelfu/model/symtab.c", 0xF0u, "elfu_mSymtabAddGlobalDymtabIfNotPresent");
v7 = *(_QWORD *)(a1 + 96);
*v6 = 0;
v8 = a1 + 88;
*(_QWORD *)(v2 + 128) = a1 + 88;
*(_QWORD *)(v2 + 136) = v7;
if ( a1 + 88 == *(_QWORD *)(a1 + 88) )
{
*(_QWORD *)(a1 + 88) = v2;
*(_QWORD *)(a1 + 96) = v2;
*(_QWORD *)(v4 + 128) = v8;
*(_QWORD *)(v4 + 136) = v2;
if ( v8 == v2 )
{
*(_QWORD *)(a1 + 88) = v4;
LABEL_10:
v9 = *(_QWORD *)(a1 + 104);
*(_QWORD *)(a1 + 96) = v4;
*(_QWORD *)(a1 + 112) = v2;
if ( v9 )
{
*(_DWORD *)v2 = *(_QWORD *)(v9 + 32);
if ( (unsigned int)elfu_mScnAppendData(v9, ".symtab", 8LL) )
*(_DWORD *)v2 = 0;
v10 = *(_QWORD *)(a1 + 104);
*(_DWORD *)v4 = *(_QWORD *)(v10 + 32);
if ( (unsigned int)elfu_mScnAppendData(v10, ".strtab", 8LL) )
*(_DWORD *)v4 = 0;
}
return;
}
}
else
{
*(_QWORD *)(v7 + 128) = v2;
*(_QWORD *)(v4 + 128) = v8;
*(_QWORD *)(v4 + 136) = v2;
}
*(_QWORD *)(v2 + 128) = v4;
goto LABEL_10;
}
}

canonical_decompiled_code:
void __fastcall func5(__int64 a1)
{
__int64 v2; // rbp
__int64 v3; // rax
__int64 v4; // r12
_BOOL8 v5; // rax
_BYTE *v6; // rax
__int64 v7; // rdx
__int64 v8; // rax
__int64 v9; // rdi
__int64 v10; // rdi

if ( !a1 )
_assert_fail("me", "src/libelfu/model/symtab.c", 0xDDu, "elfu_mSymtabAddGlobalDymtabIfNotPresent");
if ( !*(_QWORD *)(a1 + 112) )
{
v2 = elfu_mScnAlloc();
if ( !v2 )
_assert_fail("symtab", "src/libelfu/model/symtab.c", 0xE4u, "elfu_mSymtabAddGlobalDymtabIfNotPresent");
v3 = elfu_mScnAlloc();
v4 = v3;
if ( !v3 )
_assert_fail("strtab", "src/libelfu/model/symtab.c", 0xE6u, "elfu_mSymtabAddGlobalDymtabIfNotPresent");
*(_QWORD *)(v2 + 72) = v3;
v5 = *(_DWORD *)a1 != 1;
*(_QWORD *)(v2 + 48) = 4LL;
*(_QWORD *)(v2 + 56) = 8 * v5 + 16;
*(_QWORD *)(v4 + 48) = 1LL;
*(_DWORD *)(v2 + 4) = 2;
*(_DWORD *)(v4 + 4) = 3;
v6 = malloc(1uLL);
*(_QWORD *)(v4 + 64) = v6;
if ( !v6 )
_assert_fail("strtab->databuf", "src/libelfu/model/symtab.c", 0xF0u, "elfu_mSymtabAddGlobalDymtabIfNotPresent");
v7 = *(_QWORD *)(a1 + 96);
*v6 = 0;
v8 = a1 + 88;
*(_QWORD *)(v2 + 128) = a1 + 88;
*(_QWORD *)(v2 + 136) = v7;
if ( a1 + 88 == *(_QWORD *)(a1 + 88) )
{
*(_QWORD *)(a1 + 88) = v2;
*(_QWORD *)(a1 + 96) = v2;
*(_QWORD *)(v4 + 128) = v8;
*(_QWORD *)(v4 + 136) = v2;
if ( v8 == v2 )
{
*(_QWORD *)(a1 + 88) = v4;
LABEL_10:
v9 = *(_QWORD *)(a1 + 104);
*(_QWORD *)(a1 + 96) = v4;
*(_QWORD *)(a1 + 112) = v2;
if ( v9 )
{
*(_DWORD *)v2 = *(_QWORD *)(v9 + 32);
if ( (unsigned int)elfu_mScnAppendData(v9, ".symtab", 8LL) )
*(_DWORD *)v2 = 0;
v10 = *(_QWORD *)(a1 + 104);
*(_DWORD *)v4 = *(_QWORD *)(v10 + 32);
if ( (unsigned int)elfu_mScnAppendData(v10, ".strtab", 8LL) )
*(_DWORD *)v4 = 0;
}
return;
}
}
else
{
*(_QWORD *)(v7 + 128) = v2;
*(_QWORD *)(v4 + 128) = v8;
*(_QWORD *)(v4 + 136) = v2;
}
*(_QWORD *)(v2 + 128) = v4;
goto LABEL_10;
}
}

original_code:
void elfu_mSymtabAddGlobalDymtabIfNotPresent(ElfuElf *me)
{
  ((void) sizeof ((me) ? 1 : 0), __extension__ ({ if (me) ; else __assert_fail ("me", "src/libelfu/model/symtab.c", 221, __extension__ __PRETTY_FUNCTION__); }));
  if (!me->symtab) {
    ElfuScn *symtab;
    ElfuScn *strtab;
    symtab = elfu_mScnAlloc();
    ((void) sizeof ((symtab) ? 1 : 0), __extension__ ({ if (symtab) ; else __assert_fail ("symtab", "src/libelfu/model/symtab.c", 228, __extension__ __PRETTY_FUNCTION__); }));
    strtab = elfu_mScnAlloc();
    ((void) sizeof ((strtab) ? 1 : 0), __extension__ ({ if (strtab) ; else __assert_fail ("strtab", "src/libelfu/model/symtab.c", 230, __extension__ __PRETTY_FUNCTION__); }));
    symtab->linkptr = strtab;
    symtab->shdr.sh_entsize = me->elfclass == 1 ? sizeof(Elf32_Sym) : sizeof(Elf64_Sym);
    symtab->shdr.sh_addralign = 4;
    strtab->shdr.sh_addralign = 1;
    symtab->shdr.sh_type = 2;
    strtab->shdr.sh_type = 3;
    strtab->databuf = malloc(1);
    ((void) sizeof ((strtab->databuf) ? 1 : 0), __extension__ ({ if (strtab->databuf) ; else __assert_fail ("strtab->databuf", "src/libelfu/model/symtab.c", 240, __extension__ __PRETTY_FUNCTION__); }));
    strtab->databuf[0] = 0;
    do { (symtab)->elemChildScn.cqe_next = (void *)(&me->orphanScnList); (symtab)->elemChildScn.cqe_prev = (&me->orphanScnList)->cqh_last; if ((&me->orphanScnList)->cqh_first == (void *)(&me->orphanScnList)) (&me->orphanScnList)->cqh_first = (symtab); else (&me->orphanScnList)->cqh_last->elemChildScn.cqe_next = (symtab); (&me->orphanScnList)->cqh_last = (symtab); } while ( 0);
    do { (strtab)->elemChildScn.cqe_next = (void *)(&me->orphanScnList); (strtab)->elemChildScn.cqe_prev = (&me->orphanScnList)->cqh_last; if ((&me->orphanScnList)->cqh_first == (void *)(&me->orphanScnList)) (&me->orphanScnList)->cqh_first = (strtab); else (&me->orphanScnList)->cqh_last->elemChildScn.cqe_next = (strtab); (&me->orphanScnList)->cqh_last = (strtab); } while ( 0);
    me->symtab = symtab;
    if (me->shstrtab) {
      symtab->shdr.sh_name = me->shstrtab->shdr.sh_size;
      if (elfu_mScnAppendData(me->shstrtab, ".symtab", 8)) {
        symtab->shdr.sh_name = 0;
      }
      strtab->shdr.sh_name = me->shstrtab->shdr.sh_size;
      if (elfu_mScnAppendData(me->shstrtab, ".strtab", 8)) {
        strtab->shdr.sh_name = 0;
      }
    }
  }
}

canonical_original_code:
void elfu_mSymtabAddGlobalDymtabIfNotPresent(struct ElfuElf *me)
{
  ((void) sizeof ((me) ? 1 : 0), __extension__ ({ if (me) ; else __assert_fail ("me", "src/libelfu/model/symtab.c", 221, __extension__ __PRETTY_FUNCTION__); }));
  if (!me->symtab) {
    struct ElfuScn *symtab;
    struct ElfuScn *strtab;
    symtab = elfu_mScnAlloc();
    ((void) sizeof ((symtab) ? 1 : 0), __extension__ ({ if (symtab) ; else __assert_fail ("symtab", "src/libelfu/model/symtab.c", 228, __extension__ __PRETTY_FUNCTION__); }));
    strtab = elfu_mScnAlloc();
    ((void) sizeof ((strtab) ? 1 : 0), __extension__ ({ if (strtab) ; else __assert_fail ("strtab", "src/libelfu/model/symtab.c", 230, __extension__ __PRETTY_FUNCTION__); }));
    symtab->linkptr = strtab;
    symtab->shdr.sh_entsize = me->elfclass == 1 ? sizeof(Elf32_Sym) : sizeof(Elf64_Sym);
    symtab->shdr.sh_addralign = 4;
    strtab->shdr.sh_addralign = 1;
    symtab->shdr.sh_type = 2;
    strtab->shdr.sh_type = 3;
    strtab->databuf = malloc(1);
    ((void) sizeof ((strtab->databuf) ? 1 : 0), __extension__ ({ if (strtab->databuf) ; else __assert_fail ("strtab->databuf", "src/libelfu/model/symtab.c", 240, __extension__ __PRETTY_FUNCTION__); }));
    strtab->databuf[0] = 0;
    do { (symtab)->elemChildScn.cqe_next = (void *)(&me->orphanScnList); (symtab)->elemChildScn.cqe_prev = (&me->orphanScnList)->cqh_last; if ((&me->orphanScnList)->cqh_first == (void *)(&me->orphanScnList)) (&me->orphanScnList)->cqh_first = (symtab); else (&me->orphanScnList)->cqh_last->elemChildScn.cqe_next = (symtab); (&me->orphanScnList)->cqh_last = (symtab); } while ( 0);
    do { (strtab)->elemChildScn.cqe_next = (void *)(&me->orphanScnList); (strtab)->elemChildScn.cqe_prev = (&me->orphanScnList)->cqh_last; if ((&me->orphanScnList)->cqh_first == (void *)(&me->orphanScnList)) (&me->orphanScnList)->cqh_first = (strtab); else (&me->orphanScnList)->cqh_last->elemChildScn.cqe_next = (strtab); (&me->orphanScnList)->cqh_last = (strtab); } while ( 0);
    me->symtab = symtab;
    if (me->shstrtab) {
      symtab->shdr.sh_name = me->shstrtab->shdr.sh_size;
      if (elfu_mScnAppendData(me->shstrtab, ".symtab", 8)) {
        symtab->shdr.sh_name = 0;
      }
      strtab->shdr.sh_name = me->shstrtab->shdr.sh_size;
      if (elfu_mScnAppendData(me->shstrtab, ".strtab", 8)) {
        strtab->shdr.sh_name = 0;
      }
    }
  }
}

return_type: void

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

user_defined_types: struct OrphanScnList { struct ElfuScn *cqh_first; struct ElfuScn *cqh_last; }

user_defined_types: struct Elf64_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned long sh_flags; unsigned long sh_addr; unsigned long sh_offset; unsigned long sh_size; unsigned int sh_link; unsigned int sh_info; unsigned long sh_addralign; unsigned long sh_entsize; }

user_defined_types: struct Elf64_Phdr { unsigned int p_type; unsigned int p_flags; unsigned long p_offset; unsigned long p_vaddr; unsigned long p_paddr; unsigned long p_filesz; unsigned long p_memsz; unsigned long p_align; }

user_defined_types: struct ChildPhdrList { struct ElfuPhdr *cqh_first; struct ElfuPhdr *cqh_last; }


subOldscn

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

result = 0LL;
if ( *(_QWORD *)(a2 + 88) == a3 )
result = a2;
return result;
}

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

result = 0LL;
if ( *(_QWORD *)(a2 + 88) == a3 )
result = a2;
return result;
}

original_code:
static void* subOldscn(ElfuElf *me, ElfuScn *ms, void *aux1, void *aux2)
{
  ElfuScn *otherScn = (ElfuScn*)aux1;
  (void)aux2;
  if (ms->oldptr == otherScn) {
    return ms;
  }
  return ((void *)0);
}

canonical_original_code:
static void *subOldscn(struct ElfuElf *me, struct ElfuScn *ms, void *aux1, void *aux2)
{
  struct ElfuScn *otherScn = (ElfuScn*)aux1;
  (void)aux2;
  if (ms->oldptr == otherScn) {
    return ms;
  }
  return ((void *)0);
}

variable_types:
ms
struct ElfuScn *

return_type: void *


subScnsToArray

original_code:
static void* subScnsToArray(ElfuElf *me, ElfuScn *ms, void *aux1, void *aux2)
{
  ElfuScn **arr = (ElfuScn**)aux1;
  size_t *i = (size_t*)aux2;
  arr[(*i)] = ms;
  *i += 1;
  return ((void *)0);
}

canonical_original_code:
static void *subScnsToArray(struct ElfuElf *me, struct ElfuScn *ms, void *aux1, void *aux2)
{
  struct ElfuScn **arr = (ElfuScn**)aux1;
  unsigned long *i = (size_t*)aux2;
  arr[(*i)] = ms;
  *i += 1;
  return ((void *)0);
}

variable_types: struct ElfuScn { struct Elf64_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned long sh_flags; unsigned long sh_addr; unsigned long sh_offset; unsigned long sh_size; unsigned int sh_link; unsigned int sh_info; unsigned long sh_addralign; unsigned long sh_entsize; } shdr; char *databuf; struct ElfuScn *linkptr; struct ElfuScn *infoptr; struct ElfuScn *oldptr; struct ElfuSymtab { struct Syms { struct ElfuSym { unsigned int name; unsigned long value; unsigned int size; unsigned char bind; unsigned char type; unsigned char other; struct ElfuScn *scnptr; int shndx; struct { struct ElfuSym *cqe_next; struct ElfuSym *cqe_prev; } elem; } *cqh_first; struct ElfuSym *cqh_last; } syms; } symtab; struct ElfuReltab { struct Rels { struct ElfuRel { unsigned long offset; unsigned int sym; unsigned char type; int addendUsed; int addend; struct { struct ElfuRel *cqe_next; struct ElfuRel *cqe_prev; } elem; } *cqh_first; struct ElfuRel *cqh_last; } rels; } reltab; struct { struct ElfuScn *cqe_next; struct ElfuScn *cqe_prev; } elemChildScn; } **

variable_types:
i
unsigned long *


original_code:
void* elfu_mScnForall(ElfuElf *me, SectionHandlerFunc f, void *aux1, void *aux2)
{
  ElfuPhdr *mp;
  ElfuScn *ms;
  for ((mp) = ((&me->phdrList)->cqh_first); (mp) != (const void *)(&me->phdrList); (mp) = ((mp)->elem.cqe_next)) {
    if (mp->phdr.p_type != 1) {
      continue;
    }
    for ((ms) = ((&mp->childScnList)->cqh_first); (ms) != (const void *)(&mp->childScnList); (ms) = ((ms)->elemChildScn.cqe_next)) {
      void *rv = f(me, ms, aux1, aux2);
      if (rv) {
        return rv;
      }
    }
  }
  for ((ms) = ((&me->orphanScnList)->cqh_first); (ms) != (const void *)(&me->orphanScnList); (ms) = ((ms)->elemChildScn.cqe_next)) {
    void *rv = f(me, ms, aux1, aux2);
    if (rv) {
      return rv;
    }
  }
  return ((void *)0);
}

canonical_original_code:
void *elfu_mScnForall(struct ElfuElf *me, void *f(struct ElfuElf *me, struct ElfuScn *ms, void *aux1, void *aux2), void *aux1, void *aux2)
{
  struct ElfuPhdr *mp;
  struct ElfuScn *ms;
  for ((mp) = ((&me->phdrList)->cqh_first); (mp) != (void *)(&me->phdrList); (mp) = ((mp)->elem.cqe_next)) {
    if (mp->phdr.p_type != 1) {
      continue;
    }
    for ((ms) = ((&mp->childScnList)->cqh_first); (ms) != (void *)(&mp->childScnList); (ms) = ((ms)->elemChildScn.cqe_next)) {
      void *rv = f(me, ms, aux1, aux2);
      if (rv) {
        return rv;
      }
    }
  }
  for ((ms) = ((&me->orphanScnList)->cqh_first); (ms) != (void *)(&me->orphanScnList); (ms) = ((ms)->elemChildScn.cqe_next)) {
    void *rv = f(me, ms, aux1, aux2);
    if (rv) {
      return rv;
    }
  }
  return ((void *)0);
}

variable_types: void *(struct ElfuElf *me, struct ElfuScn *ms, void *aux1, void *aux2)

variable_types: struct ElfuPhdr { struct Elf64_Phdr { unsigned int p_type; unsigned int p_flags; unsigned long p_offset; unsigned long p_vaddr; unsigned long p_paddr; unsigned long p_filesz; unsigned long p_memsz; unsigned long p_align; } phdr; struct ChildScnList { struct ElfuScn { struct Elf64_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned long sh_flags; unsigned long sh_addr; unsigned long sh_offset; unsigned long sh_size; unsigned int sh_link; unsigned int sh_info; unsigned long sh_addralign; unsigned long sh_entsize; } shdr; char *databuf; struct ElfuScn *linkptr; struct ElfuScn *infoptr; struct ElfuScn *oldptr; struct ElfuSymtab { struct Syms { struct ElfuSym { unsigned int name; unsigned long value; unsigned int size; unsigned char bind; unsigned char type; unsigned char other; struct ElfuScn *scnptr; int shndx; struct { struct ElfuSym *cqe_next; struct ElfuSym *cqe_prev; } elem; } *cqh_first; struct ElfuSym *cqh_last; } syms; } symtab; struct ElfuReltab { struct Rels { struct ElfuRel { unsigned long offset; unsigned int sym; unsigned char type; int addendUsed; int addend; struct { struct ElfuRel *cqe_next; struct ElfuRel *cqe_prev; } elem; } *cqh_first; struct ElfuRel *cqh_last; } rels; } reltab; struct { struct ElfuScn *cqe_next; struct ElfuScn *cqe_prev; } elemChildScn; } *cqh_first; struct ElfuScn *cqh_last; } childScnList; struct ChildPhdrList { struct ElfuPhdr *cqh_first; struct ElfuPhdr *cqh_last; } childPhdrList; struct { struct ElfuPhdr *cqe_next; struct ElfuPhdr *cqe_prev; } elemChildPhdr; struct { struct ElfuPhdr *cqe_next; struct ElfuPhdr *cqe_prev; } elem; } *

variable_types:
rv
void *


decompiled_code:
__int64 __fastcall elfu_mScnCount(__int64 a1)
{
__int64 v2; // [rsp+8h] [rbp-10h] BYREF

v2 = 0LL;
if ( !a1 )
_assert_fail("me", "src/libelfu/model/section.c", 0x50u, "elfu_mScnCount");
elfu_mScnForall(a1, (__int64 (__fastcall *)(__int64, __int64, __int64, __int64))subCounter, (__int64)&v2, 0LL);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
__int64 v2; // [rsp+8h] [rbp-10h] BYREF

v2 = 0LL;
if ( !a1 )
_assert_fail("me", "src/libelfu/model/section.c", 0x50u, "elfu_mScnCount");
func4(a1, (__int64 (__fastcall *)(__int64, __int64, __int64, __int64))subCounter, (__int64)&v2, 0LL);
return v2;
}

original_code:
size_t elfu_mScnCount(ElfuElf *me)
{
  size_t i = 0;
  ((void) sizeof ((me) ? 1 : 0), __extension__ ({ if (me) ; else __assert_fail ("me", "src/libelfu/model/section.c", 80, __extension__ __PRETTY_FUNCTION__); }));
  elfu_mScnForall(me, subCounter, &i, ((void *)0));
  return i;
}

canonical_original_code:
unsigned long elfu_mScnCount(struct ElfuElf *me)
{
  unsigned long i = 0;
  ((void) sizeof ((me) ? 1 : 0), __extension__ ({ if (me) ; else __assert_fail ("me", "src/libelfu/model/section.c", 80, __extension__ __PRETTY_FUNCTION__); }));
  elfu_mScnForall(me, subCounter, &i, ((void *)0));
  return i;
}

variable_types:
i
unsigned long


decompiled_code:
unsigned __int64 __fastcall elfu_mScnIndex(__int64 a1, __int64 a2)
{
unsigned __int64 v2; // r8
unsigned __int64 result; // rax
unsigned __int64 v4; // [rsp+8h] [rbp-10h] BYREF

v4 = 1LL;
if ( !a1 )
_assert_fail("me", "src/libelfu/model/section.c", 0x5Eu, "elfu_mScnIndex");
if ( !a2 )
_assert_fail("ms", "src/libelfu/model/section.c", 0x5Fu, "elfu_mScnIndex");
elfu_mScnForall(a1, (__int64 (__fastcall *)(__int64, __int64, __int64, __int64))subCounter, (__int64)&v4, a2);
v2 = elfu_mScnCount(a1);
result = v4;
if ( v2 < v4 )
_assert_fail("i <= elfu_mScnCount(me)", "src/libelfu/model/section.c", 0x64u, "elfu_mScnIndex");
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func6(__int64 a1, __int64 a2)
{
unsigned __int64 v2; // r8
unsigned __int64 result; // rax
unsigned __int64 v4; // [rsp+8h] [rbp-10h] BYREF

v4 = 1LL;
if ( !a1 )
_assert_fail("me", "src/libelfu/model/section.c", 0x5Eu, "elfu_mScnIndex");
if ( !a2 )
_assert_fail("ms", "src/libelfu/model/section.c", 0x5Fu, "elfu_mScnIndex");
func4(a1, (__int64 (__fastcall *)(__int64, __int64, __int64, __int64))subCounter, (__int64)&v4, a2);
v2 = func5(a1);
result = v4;
if ( v2 < v4 )
_assert_fail("i <= elfu_mScnCount(me)", "src/libelfu/model/section.c", 0x64u, "elfu_mScnIndex");
return result;
}

original_code:
size_t elfu_mScnIndex(ElfuElf *me, ElfuScn *ms)
{
  size_t i = 1;
  ((void) sizeof ((me) ? 1 : 0), __extension__ ({ if (me) ; else __assert_fail ("me", "src/libelfu/model/section.c", 94, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((ms) ? 1 : 0), __extension__ ({ if (ms) ; else __assert_fail ("ms", "src/libelfu/model/section.c", 95, __extension__ __PRETTY_FUNCTION__); }));
  elfu_mScnForall(me, subCounter, &i, ms);
  ((void) sizeof ((i <= elfu_mScnCount(me)) ? 1 : 0), __extension__ ({ if (i <= elfu_mScnCount(me)) ; else __assert_fail ("i <= elfu_mScnCount(me)", "src/libelfu/model/section.c", 100, __extension__ __PRETTY_FUNCTION__); }));
  return i;
}

canonical_original_code:
unsigned long elfu_mScnIndex(struct ElfuElf *me, struct ElfuScn *ms)
{
  unsigned long i = 1;
  ((void) sizeof ((me) ? 1 : 0), __extension__ ({ if (me) ; else __assert_fail ("me", "src/libelfu/model/section.c", 94, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((ms) ? 1 : 0), __extension__ ({ if (ms) ; else __assert_fail ("ms", "src/libelfu/model/section.c", 95, __extension__ __PRETTY_FUNCTION__); }));
  elfu_mScnForall(me, subCounter, &i, ms);
  ((void) sizeof ((i <= elfu_mScnCount(me)) ? 1 : 0), __extension__ ({ if (i <= elfu_mScnCount(me)) ; else __assert_fail ("i <= elfu_mScnCount(me)", "src/libelfu/model/section.c", 100, __extension__ __PRETTY_FUNCTION__); }));
  return i;
}


decompiled_code:
__int64 __fastcall elfu_mScnByOldscn(__int64 a1, __int64 a2)
{
if ( !a1 )
_assert_fail("me", "src/libelfu/model/section.c", 0x79u, "elfu_mScnByOldscn");
if ( !a2 )
_assert_fail("oldscn", "src/libelfu/model/section.c", 0x7Au, "elfu_mScnByOldscn");
return elfu_mScnForall(a1, (__int64 (__fastcall *)(__int64, __int64, __int64, __int64))subOldscn, a2, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2)
{
if ( !a1 )
_assert_fail("me", "src/libelfu/model/section.c", 0x79u, "elfu_mScnByOldscn");
if ( !a2 )
_assert_fail("oldscn", "src/libelfu/model/section.c", 0x7Au, "elfu_mScnByOldscn");
return func4(a1, (__int64 (__fastcall *)(__int64, __int64, __int64, __int64))subOldscn, a2, 0LL);
}

original_code:
ElfuScn* elfu_mScnByOldscn(ElfuElf *me, ElfuScn *oldscn)
{
  ((void) sizeof ((me) ? 1 : 0), __extension__ ({ if (me) ; else __assert_fail ("me", "src/libelfu/model/section.c", 121, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((oldscn) ? 1 : 0), __extension__ ({ if (oldscn) ; else __assert_fail ("oldscn", "src/libelfu/model/section.c", 122, __extension__ __PRETTY_FUNCTION__); }));
  return elfu_mScnForall(me, subOldscn, oldscn, ((void *)0));
}

canonical_original_code:
struct ElfuScn *elfu_mScnByOldscn(struct ElfuElf *me, struct ElfuScn *oldscn)
{
  ((void) sizeof ((me) ? 1 : 0), __extension__ ({ if (me) ; else __assert_fail ("me", "src/libelfu/model/section.c", 121, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((oldscn) ? 1 : 0), __extension__ ({ if (oldscn) ; else __assert_fail ("oldscn", "src/libelfu/model/section.c", 122, __extension__ __PRETTY_FUNCTION__); }));
  return elfu_mScnForall(me, subOldscn, oldscn, ((void *)0));
}

variable_types: struct ElfuElf { int elfclass; 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; } ehdr; struct PhdrList { struct ElfuPhdr { struct Elf64_Phdr { unsigned int p_type; unsigned int p_flags; unsigned long p_offset; unsigned long p_vaddr; unsigned long p_paddr; unsigned long p_filesz; unsigned long p_memsz; unsigned long p_align; } phdr; struct ChildScnList { struct ElfuScn *cqh_first; struct ElfuScn *cqh_last; } childScnList; struct ChildPhdrList { struct ElfuPhdr *cqh_first; struct ElfuPhdr *cqh_last; } childPhdrList; struct { struct ElfuPhdr *cqe_next; struct ElfuPhdr *cqe_prev; } elemChildPhdr; struct { struct ElfuPhdr *cqe_next; struct ElfuPhdr *cqe_prev; } elem; } *cqh_first; struct ElfuPhdr *cqh_last; } phdrList; struct OrphanScnList { struct ElfuScn *cqh_first; struct ElfuScn *cqh_last; } orphanScnList; struct ElfuScn *shstrtab; struct ElfuScn *symtab; } *

variable_types:
oldscn
struct ElfuScn *

return_type: struct ElfuScn { struct Elf64_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned long sh_flags; unsigned long sh_addr; unsigned long sh_offset; unsigned long sh_size; unsigned int sh_link; unsigned int sh_info; unsigned long sh_addralign; unsigned long sh_entsize; } shdr; char *databuf; struct ElfuScn *linkptr; struct ElfuScn *infoptr; struct ElfuScn *oldptr; struct ElfuSymtab { struct Syms { struct ElfuSym { unsigned int name; unsigned long value; unsigned int size; unsigned char bind; unsigned char type; unsigned char other; struct ElfuScn *scnptr; int shndx; struct { struct ElfuSym *cqe_next; struct ElfuSym *cqe_prev; } elem; } *cqh_first; struct ElfuSym *cqh_last; } syms; } symtab; struct ElfuReltab { struct Rels { struct ElfuRel { unsigned long offset; unsigned int sym; unsigned char type; int addendUsed; int addend; struct { struct ElfuRel *cqe_next; struct ElfuRel *cqe_prev; } elem; } *cqh_first; struct ElfuRel *cqh_last; } rels; } reltab; struct { struct ElfuScn *cqe_next; struct ElfuScn *cqe_prev; } elemChildScn; } *


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

if ( !a1 )
_assert_fail("me", "src/libelfu/model/section.c", 0x86u, "elfu_mScnName");
if ( !a2 )
_assert_fail("ms", "src/libelfu/model/section.c", 0x87u, "elfu_mScnName");
result = *(_QWORD *)(a1 + 104);
if ( result )
{
result = *(_QWORD *)(result + 64);
if ( result )
result += *a2;
}
return result;
}

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

if ( !a1 )
_assert_fail("me", "src/libelfu/model/section.c", 0x86u, "elfu_mScnName");
if ( !a2 )
_assert_fail("ms", "src/libelfu/model/section.c", 0x87u, "elfu_mScnName");
result = *(_QWORD *)(a1 + 104);
if ( result )
{
result = *(_QWORD *)(result + 64);
if ( result )
result += *a2;
}
return result;
}

original_code:
char* elfu_mScnName(ElfuElf *me, ElfuScn *ms)
{
  ((void) sizeof ((me) ? 1 : 0), __extension__ ({ if (me) ; else __assert_fail ("me", "src/libelfu/model/section.c", 134, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((ms) ? 1 : 0), __extension__ ({ if (ms) ; else __assert_fail ("ms", "src/libelfu/model/section.c", 135, __extension__ __PRETTY_FUNCTION__); }));
  if (!me->shstrtab) {
    return ((void *)0);
  }
  if (!me->shstrtab->databuf) {
    return ((void *)0);
  }
  return &me->shstrtab->databuf[ms->shdr.sh_name];
}

canonical_original_code:
char *elfu_mScnName(struct ElfuElf *me, struct ElfuScn *ms)
{
  ((void) sizeof ((me) ? 1 : 0), __extension__ ({ if (me) ; else __assert_fail ("me", "src/libelfu/model/section.c", 134, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((ms) ? 1 : 0), __extension__ ({ if (ms) ; else __assert_fail ("ms", "src/libelfu/model/section.c", 135, __extension__ __PRETTY_FUNCTION__); }));
  if (!me->shstrtab) {
    return ((void *)0);
  }
  if (!me->shstrtab->databuf) {
    return ((void *)0);
  }
  return &me->shstrtab->databuf[ms->shdr.sh_name];
}


decompiled_code:
void *__fastcall elfu_mScnSortedByOffset(__int64 a1, __int64 *a2)
{
__int64 v2; // rbx
void *v3; // rax
void *v4; // r12
__int64 v6[6]; // [rsp+8h] [rbp-30h] BYREF

if ( !a1 )
_assert_fail("me", "src/libelfu/model/section.c", 0xBFu, "elfu_mScnSortedByOffset");
v2 = elfu_mScnCount(a1);
v3 = malloc(8 * v2);
v4 = v3;
if ( v3 )
{
v6[0] = 0LL;
elfu_mScnForall(
a1,
(__int64 (__fastcall *)(__int64, __int64, __int64, __int64))subScnsToArray,
(__int64)v3,
(__int64)v6);
if ( v6[0] != v2 )
_assert_fail("i == numSecs", "src/libelfu/model/section.c", 0xCBu, "elfu_mScnSortedByOffset");
qsort(v4, v2, 8uLL, (__compar_fn_t)cmpScnOffs);
*a2 = v2;
}
else
{
fwrite("elfu_mScnSortedByOffset: Failed to allocate memory.\n", 1uLL, 0x34uLL, stderr);
}
return v4;
}

canonical_decompiled_code:
void *__fastcall func9(__int64 a1, __int64 *a2)
{
__int64 v2; // rbx
void *v3; // rax
void *v4; // r12
__int64 v6[6]; // [rsp+8h] [rbp-30h] BYREF

if ( !a1 )
_assert_fail("me", "src/libelfu/model/section.c", 0xBFu, "elfu_mScnSortedByOffset");
v2 = func5(a1);
v3 = malloc(8 * v2);
v4 = v3;
if ( v3 )
{
v6[0] = 0LL;
func4(
a1,
(__int64 (__fastcall *)(__int64, __int64, __int64, __int64))subScnsToArray,
(__int64)v3,
(__int64)v6);
if ( v6[0] != v2 )
_assert_fail("i == numSecs", "src/libelfu/model/section.c", 0xCBu, "elfu_mScnSortedByOffset");
qsort(v4, v2, 8uLL, (__compar_fn_t)cmpScnOffs);
*a2 = v2;
}
else
{
fwrite("elfu_mScnSortedByOffset: Failed to allocate memory.\n", 1uLL, 0x34uLL, stderr);
}
return v4;
}

original_code:
ElfuScn** elfu_mScnSortedByOffset(ElfuElf *me, size_t *count)
{
  size_t numSecs;
  ElfuScn **sortedSecs;
  size_t i;
  ((void) sizeof ((me) ? 1 : 0), __extension__ ({ if (me) ; else __assert_fail ("me", "src/libelfu/model/section.c", 191, __extension__ __PRETTY_FUNCTION__); }));
  numSecs = elfu_mScnCount(me);
  sortedSecs = malloc(numSecs * sizeof(*sortedSecs));
  if (!sortedSecs) {
    do { fprintf(stderr, "elfu_mScnSortedByOffset: Failed to allocate memory.\n"); } while(0);
    return ((void *)0);
  }
  i = 0;
  elfu_mScnForall(me, subScnsToArray, sortedSecs, &i);
  ((void) sizeof ((i == numSecs) ? 1 : 0), __extension__ ({ if (i == numSecs) ; else __assert_fail ("i == numSecs", "src/libelfu/model/section.c", 203, __extension__ __PRETTY_FUNCTION__); }));
  qsort(sortedSecs, numSecs, sizeof(*sortedSecs), cmpScnOffs);
  *count = numSecs;
  return sortedSecs;
}

canonical_original_code:
struct ElfuScn **elfu_mScnSortedByOffset(struct ElfuElf *me, unsigned long *count)
{
  unsigned long numSecs;
  struct ElfuScn **sortedSecs;
  unsigned long i;
  ((void) sizeof ((me) ? 1 : 0), __extension__ ({ if (me) ; else __assert_fail ("me", "src/libelfu/model/section.c", 191, __extension__ __PRETTY_FUNCTION__); }));
  numSecs = elfu_mScnCount(me);
  sortedSecs = malloc(numSecs * sizeof(*sortedSecs));
  if (!sortedSecs) {
    do { fprintf(stderr, "elfu_mScnSortedByOffset: Failed to allocate memory.\n"); } while(0);
    return ((void *)0);
  }
  i = 0;
  elfu_mScnForall(me, subScnsToArray, sortedSecs, &i);
  ((void) sizeof ((i == numSecs) ? 1 : 0), __extension__ ({ if (i == numSecs) ; else __assert_fail ("i == numSecs", "src/libelfu/model/section.c", 203, __extension__ __PRETTY_FUNCTION__); }));
  qsort(sortedSecs, numSecs, sizeof(*sortedSecs), cmpScnOffs);
  *count = numSecs;
  return sortedSecs;
}

variable_types:
count
unsigned long *

variable_types:
numSecs
unsigned long

return_type: struct ElfuScn { struct Elf64_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned long sh_flags; unsigned long sh_addr; unsigned long sh_offset; unsigned long sh_size; unsigned int sh_link; unsigned int sh_info; unsigned long sh_addralign; unsigned long sh_entsize; } shdr; char *databuf; struct ElfuScn *linkptr; struct ElfuScn *infoptr; struct ElfuScn *oldptr; struct ElfuSymtab { struct Syms { struct ElfuSym { unsigned int name; unsigned long value; unsigned int size; unsigned char bind; unsigned char type; unsigned char other; struct ElfuScn *scnptr; int shndx; struct { struct ElfuSym *cqe_next; struct ElfuSym *cqe_prev; } elem; } *cqh_first; struct ElfuSym *cqh_last; } syms; } symtab; struct ElfuReltab { struct Rels { struct ElfuRel { unsigned long offset; unsigned int sym; unsigned char type; int addendUsed; int addend; struct { struct ElfuRel *cqe_next; struct ElfuRel *cqe_prev; } elem; } *cqh_first; struct ElfuRel *cqh_last; } rels; } reltab; struct { struct ElfuScn *cqe_next; struct ElfuScn *cqe_prev; } elemChildScn; } **


decompiled_code:
__int64 __fastcall elfu_mScnAppendData(__int64 a1, const void *a2, size_t a3)
{
void *v4; // rdi
char *v6; // rax
__int64 result; // rax

if ( !a1 )
_assert_fail("ms", "src/libelfu/model/section.c", 0xDAu, "elfu_mScnAppendData");
if ( *(_DWORD *)(a1 + 4) == 8 )
_assert_fail("ms->shdr.sh_type != SHT_NOBITS", "src/libelfu/model/section.c", 0xDBu, "elfu_mScnAppendData");
v4 = *(void **)(a1 + 64);
if ( !v4 )
_assert_fail("ms->databuf", "src/libelfu/model/section.c", 0xDCu, "elfu_mScnAppendData");
v6 = (char *)realloc(v4, a3 + *(_QWORD *)(a1 + 32));
if ( v6 )
{
*(_QWORD *)(a1 + 64) = v6;
memcpy(&v6[*(_QWORD *)(a1 + 32)], a2, a3);
*(_QWORD *)(a1 + 32) += a3;
result = 0LL;
}
else
{
fwrite("elfu_mScnAppendData: malloc() failed for newbuf.\n", 1uLL, 0x31uLL, stderr);
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, const void *a2, size_t a3)
{
void *v4; // rdi
char *v6; // rax
__int64 result; // rax

if ( !a1 )
_assert_fail("ms", "src/libelfu/model/section.c", 0xDAu, "elfu_mScnAppendData");
if ( *(_DWORD *)(a1 + 4) == 8 )
_assert_fail("ms->shdr.sh_type != SHT_NOBITS", "src/libelfu/model/section.c", 0xDBu, "elfu_mScnAppendData");
v4 = *(void **)(a1 + 64);
if ( !v4 )
_assert_fail("ms->databuf", "src/libelfu/model/section.c", 0xDCu, "elfu_mScnAppendData");
v6 = (char *)realloc(v4, a3 + *(_QWORD *)(a1 + 32));
if ( v6 )
{
*(_QWORD *)(a1 + 64) = v6;
memcpy(&v6[*(_QWORD *)(a1 + 32)], a2, a3);
*(_QWORD *)(a1 + 32) += a3;
result = 0LL;
}
else
{
fwrite("elfu_mScnAppendData: malloc() failed for newbuf.\n", 1uLL, 0x31uLL, stderr);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int elfu_mScnAppendData(ElfuScn *ms, void *buf, size_t len)
{
  char *newbuf;
  ((void) sizeof ((ms) ? 1 : 0), __extension__ ({ if (ms) ; else __assert_fail ("ms", "src/libelfu/model/section.c", 218, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((ms->shdr.sh_type != 8) ? 1 : 0), __extension__ ({ if (ms->shdr.sh_type != 8) ; else __assert_fail ("ms->shdr.sh_type != SHT_NOBITS", "src/libelfu/model/section.c", 219, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((ms->databuf) ? 1 : 0), __extension__ ({ if (ms->databuf) ; else __assert_fail ("ms->databuf", "src/libelfu/model/section.c", 220, __extension__ __PRETTY_FUNCTION__); }));
  newbuf = realloc(ms->databuf, ms->shdr.sh_size + len);
  if (!newbuf) {
    do { fprintf(stderr, "elfu_mScnAppendData: malloc() failed for newbuf.\n"); } while(0);
    return -1;
  }
  ms->databuf = newbuf;
  memcpy(newbuf + ms->shdr.sh_size, buf, len);
  ms->shdr.sh_size += len;
  ((void) sizeof ((ms->shdr.sh_size == ms->shdr.sh_size) ? 1 : 0), __extension__ ({ if (ms->shdr.sh_size == ms->shdr.sh_size) ; else __assert_fail ("ms->shdr.sh_size == ms->shdr.sh_size", "src/libelfu/model/section.c", 231, __extension__ __PRETTY_FUNCTION__); }));
  return 0;
}

canonical_original_code:
int elfu_mScnAppendData(struct ElfuScn *ms, void *buf, unsigned long len)
{
  char *newbuf;
  ((void) sizeof ((ms) ? 1 : 0), __extension__ ({ if (ms) ; else __assert_fail ("ms", "src/libelfu/model/section.c", 218, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((ms->shdr.sh_type != 8) ? 1 : 0), __extension__ ({ if (ms->shdr.sh_type != 8) ; else __assert_fail ("ms->shdr.sh_type != SHT_NOBITS", "src/libelfu/model/section.c", 219, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((ms->databuf) ? 1 : 0), __extension__ ({ if (ms->databuf) ; else __assert_fail ("ms->databuf", "src/libelfu/model/section.c", 220, __extension__ __PRETTY_FUNCTION__); }));
  newbuf = realloc(ms->databuf, ms->shdr.sh_size + len);
  if (!newbuf) {
    do { fprintf(stderr, "elfu_mScnAppendData: malloc() failed for newbuf.\n"); } while(0);
    return -1;
  }
  ms->databuf = newbuf;
  memcpy(newbuf + ms->shdr.sh_size, buf, len);
  ms->shdr.sh_size += len;
  ((void) sizeof ((ms->shdr.sh_size == ms->shdr.sh_size) ? 1 : 0), __extension__ ({ if (ms->shdr.sh_size == ms->shdr.sh_size) ; else __assert_fail ("ms->shdr.sh_size == ms->shdr.sh_size", "src/libelfu/model/section.c", 231, __extension__ __PRETTY_FUNCTION__); }));
  return 0;
}

variable_types: struct ElfuScn { struct Elf64_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned long sh_flags; unsigned long sh_addr; unsigned long sh_offset; unsigned long sh_size; unsigned int sh_link; unsigned int sh_info; unsigned long sh_addralign; unsigned long sh_entsize; } shdr; char *databuf; struct ElfuScn *linkptr; struct ElfuScn *infoptr; struct ElfuScn *oldptr; struct ElfuSymtab { struct Syms { struct ElfuSym { unsigned int name; unsigned long value; unsigned int size; unsigned char bind; unsigned char type; unsigned char other; struct ElfuScn *scnptr; int shndx; struct { struct ElfuSym *cqe_next; struct ElfuSym *cqe_prev; } elem; } *cqh_first; struct ElfuSym *cqh_last; } syms; } symtab; struct ElfuReltab { struct Rels { struct ElfuRel { unsigned long offset; unsigned int sym; unsigned char type; int addendUsed; int addend; struct { struct ElfuRel *cqe_next; struct ElfuRel *cqe_prev; } elem; } *cqh_first; struct ElfuRel *cqh_last; } rels; } reltab; struct { struct ElfuScn *cqe_next; struct ElfuScn *cqe_prev; } elemChildScn; } *

variable_types:
buf
void *

variable_types:
len
unsigned long

variable_types:
newbuf
char *

return_type: int


decompiled_code:
_QWORD *elfu_mScnAlloc()
{
_QWORD *v0; // rax
_QWORD *v1; // r12
char *v2; // rax

v0 = calloc(0x90uLL, 1uLL);
v1 = v0;
if ( v0 )
{
v2 = (char *)(v0 + 12);
v1[12] = v2;
v1[13] = v2;
v1[14] = v1 + 14;
v1[15] = v1 + 14;
}
else
{
fwrite("mScnCreate: malloc() failed for ElfuScn.\n", 1uLL, 0x29uLL, stderr);
}
return v1;
}

canonical_decompiled_code:
_QWORD *func11()
{
_QWORD *v0; // rax
_QWORD *v1; // r12
char *v2; // rax

v0 = calloc(0x90uLL, 1uLL);
v1 = v0;
if ( v0 )
{
v2 = (char *)(v0 + 12);
v1[12] = v2;
v1[13] = v2;
v1[14] = v1 + 14;
v1[15] = v1 + 14;
}
else
{
fwrite("mScnCreate: malloc() failed for ElfuScn.\n", 1uLL, 0x29uLL, stderr);
}
return v1;
}

original_code:
ElfuScn* elfu_mScnAlloc()
{
  ElfuScn *ms;
  ms = malloc(sizeof(ElfuScn));
  if (!ms) {
    do { fprintf(stderr, "mScnCreate: malloc() failed for ElfuScn.\n"); } while(0);
    return ((void *)0);
  }
  memset(ms, 0, sizeof(*ms));
  do { (&ms->symtab.syms)->cqh_first = (void *)(&ms->symtab.syms); (&ms->symtab.syms)->cqh_last = (void *)(&ms->symtab.syms); } while ( 0);
  do { (&ms->reltab.rels)->cqh_first = (void *)(&ms->reltab.rels); (&ms->reltab.rels)->cqh_last = (void *)(&ms->reltab.rels); } while ( 0);
  return ms;
}

canonical_original_code:
struct ElfuScn *elfu_mScnAlloc()
{
  struct ElfuScn *ms;
  ms = malloc(sizeof(ElfuScn));
  if (!ms) {
    do { fprintf(stderr, "mScnCreate: malloc() failed for ElfuScn.\n"); } while(0);
    return ((void *)0);
  }
  memset(ms, 0, sizeof(*ms));
  do { (&ms->symtab.syms)->cqh_first = (void *)(&ms->symtab.syms); (&ms->symtab.syms)->cqh_last = (void *)(&ms->symtab.syms); } while ( 0);
  do { (&ms->reltab.rels)->cqh_first = (void *)(&ms->reltab.rels); (&ms->reltab.rels)->cqh_last = (void *)(&ms->reltab.rels); } while ( 0);
  return ms;
}


decompiled_code:
void __fastcall elfu_mScnDestroy(void *ptr)
{
char *v1; // rbx
char *v2; // rbp
char *v4; // rdi
__int64 v5; // rax
char *v6; // rbx
char *v7; // rbp
char *v8; // rdi
__int64 v9; // rax
void *v10; // rdi

if ( !ptr )
_assert_fail("ms", "src/libelfu/model/section.c", 0x106u, "elfu_mScnDestroy");
v1 = (char *)*((_QWORD *)ptr + 12);
v2 = (char *)ptr + 96;
if ( v1 != (char *)ptr + 96 )
{
while ( 1 )
{
v4 = v1;
v1 = (char *)*((_QWORD *)v1 + 5);
v5 = *((_QWORD *)v4 + 6);
if ( v2 == v1 )
{
*((_QWORD *)ptr + 13) = v5;
if ( v2 == (char *)v5 )
goto LABEL_8;
LABEL_5:
*(_QWORD *)(v5 + 40) = v1;
free(v4);
if ( v2 == v1 )
break;
}
else
{
*((_QWORD *)v1 + 6) = v5;
if ( v2 != (char *)v5 )
goto LABEL_5;
LABEL_8:
*((_QWORD *)ptr + 12) = v1;
free(v4);
if ( v2 == v1 )
break;
}
}
}
v6 = (char *)*((_QWORD *)ptr + 14);
v7 = (char *)ptr + 112;
if ( v6 != (char *)ptr + 112 )
{
while ( 1 )
{
v8 = v6;
v6 = (char *)*((_QWORD *)v6 + 3);
v9 = *((_QWORD *)v8 + 4);
if ( v7 == v6 )
{
*((_QWORD *)ptr + 15) = v9;
if ( v7 == (char *)v9 )
goto LABEL_15;
LABEL_12:
*(_QWORD *)(v9 + 24) = v6;
free(v8);
if ( v7 == v6 )
break;
}
else
{
*((_QWORD *)v6 + 4) = v9;
if ( v7 != (char *)v9 )
goto LABEL_12;
LABEL_15:
*((_QWORD *)ptr + 14) = v6;
free(v8);
if ( v7 == v6 )
break;
}
}
}
v10 = (void *)*((_QWORD *)ptr + 8);
if ( v10 )
free(v10);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func12(void *ptr)
{
char *v1; // rbx
char *v2; // rbp
char *v4; // rdi
__int64 v5; // rax
char *v6; // rbx
char *v7; // rbp
char *v8; // rdi
__int64 v9; // rax
void *v10; // rdi

if ( !ptr )
_assert_fail("ms", "src/libelfu/model/section.c", 0x106u, "elfu_mScnDestroy");
v1 = (char *)*((_QWORD *)ptr + 12);
v2 = (char *)ptr + 96;
if ( v1 != (char *)ptr + 96 )
{
while ( 1 )
{
v4 = v1;
v1 = (char *)*((_QWORD *)v1 + 5);
v5 = *((_QWORD *)v4 + 6);
if ( v2 == v1 )
{
*((_QWORD *)ptr + 13) = v5;
if ( v2 == (char *)v5 )
goto LABEL_8;
LABEL_5:
*(_QWORD *)(v5 + 40) = v1;
free(v4);
if ( v2 == v1 )
break;
}
else
{
*((_QWORD *)v1 + 6) = v5;
if ( v2 != (char *)v5 )
goto LABEL_5;
LABEL_8:
*((_QWORD *)ptr + 12) = v1;
free(v4);
if ( v2 == v1 )
break;
}
}
}
v6 = (char *)*((_QWORD *)ptr + 14);
v7 = (char *)ptr + 112;
if ( v6 != (char *)ptr + 112 )
{
while ( 1 )
{
v8 = v6;
v6 = (char *)*((_QWORD *)v6 + 3);
v9 = *((_QWORD *)v8 + 4);
if ( v7 == v6 )
{
*((_QWORD *)ptr + 15) = v9;
if ( v7 == (char *)v9 )
goto LABEL_15;
LABEL_12:
*(_QWORD *)(v9 + 24) = v6;
free(v8);
if ( v7 == v6 )
break;
}
else
{
*((_QWORD *)v6 + 4) = v9;
if ( v7 != (char *)v9 )
goto LABEL_12;
LABEL_15:
*((_QWORD *)ptr + 14) = v6;
free(v8);
if ( v7 == v6 )
break;
}
}
}
v10 = (void *)*((_QWORD *)ptr + 8);
if ( v10 )
free(v10);
free(ptr);
}

original_code:
void elfu_mScnDestroy(ElfuScn* ms)
{
  ((void) sizeof ((ms) ? 1 : 0), __extension__ ({ if (ms) ; else __assert_fail ("ms", "src/libelfu/model/section.c", 262, __extension__ __PRETTY_FUNCTION__); }));
  if (!((&ms->symtab.syms)->cqh_first == (void *)(&ms->symtab.syms))) {
    ElfuSym *nextsym;
    nextsym = ((&ms->symtab.syms)->cqh_first);
    while ((void*)nextsym != (void*)&ms->symtab.syms) {
      ElfuSym *cursym = nextsym;
      nextsym = ((cursym)->elem.cqe_next);
      do { if ((cursym)->elem.cqe_next == (void *)(&ms->symtab.syms)) (&ms->symtab.syms)->cqh_last = (cursym)->elem.cqe_prev; else (cursym)->elem.cqe_next->elem.cqe_prev = (cursym)->elem.cqe_prev; if ((cursym)->elem.cqe_prev == (void *)(&ms->symtab.syms)) (&ms->symtab.syms)->cqh_first = (cursym)->elem.cqe_next; else (cursym)->elem.cqe_prev->elem.cqe_next = (cursym)->elem.cqe_next; } while ( 0);
      free(cursym);
    }
  }
  if (!((&ms->reltab.rels)->cqh_first == (void *)(&ms->reltab.rels))) {
    ElfuRel *nextrel;
    nextrel = ((&ms->reltab.rels)->cqh_first);
    while ((void*)nextrel != (void*)&ms->reltab.rels) {
      ElfuRel *currel = nextrel;
      nextrel = ((currel)->elem.cqe_next);
      do { if ((currel)->elem.cqe_next == (void *)(&ms->reltab.rels)) (&ms->reltab.rels)->cqh_last = (currel)->elem.cqe_prev; else (currel)->elem.cqe_next->elem.cqe_prev = (currel)->elem.cqe_prev; if ((currel)->elem.cqe_prev == (void *)(&ms->reltab.rels)) (&ms->reltab.rels)->cqh_first = (currel)->elem.cqe_next; else (currel)->elem.cqe_prev->elem.cqe_next = (currel)->elem.cqe_next; } while ( 0);
      free(currel);
    }
  }
  if (ms->databuf) {
    free(ms->databuf);
  }
  free(ms);
}

canonical_original_code:
void elfu_mScnDestroy(struct ElfuScn *ms)
{
  ((void) sizeof ((ms) ? 1 : 0), __extension__ ({ if (ms) ; else __assert_fail ("ms", "src/libelfu/model/section.c", 262, __extension__ __PRETTY_FUNCTION__); }));
  if (!((&ms->symtab.syms)->cqh_first == (void *)(&ms->symtab.syms))) {
    struct ElfuSym *nextsym;
    nextsym = ((&ms->symtab.syms)->cqh_first);
    while ((void *)nextsym != (void *)&ms->symtab.syms) {
      struct ElfuSym *cursym = nextsym;
      nextsym = ((cursym)->elem.cqe_next);
      do { if ((cursym)->elem.cqe_next == (void *)(&ms->symtab.syms)) (&ms->symtab.syms)->cqh_last = (cursym)->elem.cqe_prev; else (cursym)->elem.cqe_next->elem.cqe_prev = (cursym)->elem.cqe_prev; if ((cursym)->elem.cqe_prev == (void *)(&ms->symtab.syms)) (&ms->symtab.syms)->cqh_first = (cursym)->elem.cqe_next; else (cursym)->elem.cqe_prev->elem.cqe_next = (cursym)->elem.cqe_next; } while ( 0);
      free(cursym);
    }
  }
  if (!((&ms->reltab.rels)->cqh_first == (void *)(&ms->reltab.rels))) {
    struct ElfuRel *nextrel;
    nextrel = ((&ms->reltab.rels)->cqh_first);
    while ((void *)nextrel != (void *)&ms->reltab.rels) {
      struct ElfuRel *currel = nextrel;
      nextrel = ((currel)->elem.cqe_next);
      do { if ((currel)->elem.cqe_next == (void *)(&ms->reltab.rels)) (&ms->reltab.rels)->cqh_last = (currel)->elem.cqe_prev; else (currel)->elem.cqe_next->elem.cqe_prev = (currel)->elem.cqe_prev; if ((currel)->elem.cqe_prev == (void *)(&ms->reltab.rels)) (&ms->reltab.rels)->cqh_first = (currel)->elem.cqe_next; else (currel)->elem.cqe_prev->elem.cqe_next = (currel)->elem.cqe_next; } while ( 0);
      free(currel);
    }
  }
  if (ms->databuf) {
    free(ms->databuf);
  }
  free(ms);
}

variable_types: struct ElfuSym { unsigned int name; unsigned long value; unsigned int size; unsigned char bind; unsigned char type; unsigned char other; struct ElfuScn { struct Elf64_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned long sh_flags; unsigned long sh_addr; unsigned long sh_offset; unsigned long sh_size; unsigned int sh_link; unsigned int sh_info; unsigned long sh_addralign; unsigned long sh_entsize; } shdr; char *databuf; struct ElfuScn *linkptr; struct ElfuScn *infoptr; struct ElfuScn *oldptr; struct ElfuSymtab { struct Syms { struct ElfuSym *cqh_first; struct ElfuSym *cqh_last; } syms; } symtab; struct ElfuReltab { struct Rels { struct ElfuRel { unsigned long offset; unsigned int sym; unsigned char type; int addendUsed; int addend; struct { struct ElfuRel *cqe_next; struct ElfuRel *cqe_prev; } elem; } *cqh_first; struct ElfuRel *cqh_last; } rels; } reltab; struct { struct ElfuScn *cqe_next; struct ElfuScn *cqe_prev; } elemChildScn; } *scnptr; int shndx; struct { struct ElfuSym *cqe_next; struct ElfuSym *cqe_prev; } elem; } *


subCounter

decompiled_code:
__int64 __fastcall subCounter(__int64 a1, __int64 a2, _QWORD *a3, __int64 a4)
{
__int64 result; // rax

result = a4;
if ( a4 != a2 )
{
++*a3;
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, _QWORD *a3, __int64 a4)
{
__int64 result; // rax

result = a4;
if ( a4 != a2 )
{
++*a3;
result = 0LL;
}
return result;
}

original_code:
static void* subCounter(ElfuElf *me, ElfuScn *ms, void *aux1, void *aux2)
{
  size_t *i = (size_t*)aux1;
  ElfuScn *otherScn = (ElfuScn*)aux2;
  if (ms == otherScn) {
    return ms;
  }
  *i += 1;
  return ((void *)0);
}

canonical_original_code:
static void *subCounter(struct ElfuElf *me, struct ElfuScn *ms, void *aux1, void *aux2)
{
  unsigned long *i = (size_t*)aux1;
  struct ElfuScn *otherScn = (ElfuScn*)aux2;
  if (ms == otherScn) {
    return ms;
  }
  *i += 1;
  return ((void *)0);
}

variable_types: struct ElfuElf { int elfclass; 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; } ehdr; struct PhdrList { struct ElfuPhdr { struct Elf64_Phdr { unsigned int p_type; unsigned int p_flags; unsigned long p_offset; unsigned long p_vaddr; unsigned long p_paddr; unsigned long p_filesz; unsigned long p_memsz; unsigned long p_align; } phdr; struct ChildScnList { struct ElfuScn { struct Elf64_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned long sh_flags; unsigned long sh_addr; unsigned long sh_offset; unsigned long sh_size; unsigned int sh_link; unsigned int sh_info; unsigned long sh_addralign; unsigned long sh_entsize; } shdr; char *databuf; struct ElfuScn *linkptr; struct ElfuScn *infoptr; struct ElfuScn *oldptr; struct ElfuSymtab { struct Syms { struct ElfuSym { unsigned int name; unsigned long value; unsigned int size; unsigned char bind; unsigned char type; unsigned char other; struct ElfuScn *scnptr; int shndx; struct { struct ElfuSym *cqe_next; struct ElfuSym *cqe_prev; } elem; } *cqh_first; struct ElfuSym *cqh_last; } syms; } symtab; struct ElfuReltab { struct Rels { struct ElfuRel { unsigned long offset; unsigned int sym; unsigned char type; int addendUsed; int addend; struct { struct ElfuRel *cqe_next; struct ElfuRel *cqe_prev; } elem; } *cqh_first; struct ElfuRel *cqh_last; } rels; } reltab; struct { struct ElfuScn *cqe_next; struct ElfuScn *cqe_prev; } elemChildScn; } *cqh_first; struct ElfuScn *cqh_last; } childScnList; struct ChildPhdrList { struct ElfuPhdr *cqh_first; struct ElfuPhdr *cqh_last; } childPhdrList; struct { struct ElfuPhdr *cqe_next; struct ElfuPhdr *cqe_prev; } elemChildPhdr; struct { struct ElfuPhdr *cqe_next; struct ElfuPhdr *cqe_prev; } elem; } *cqh_first; struct ElfuPhdr *cqh_last; } phdrList; struct OrphanScnList { struct ElfuScn *cqh_first; struct ElfuScn *cqh_last; } orphanScnList; struct ElfuScn *shstrtab; struct ElfuScn *symtab; } *


cmpScnOffs

decompiled_code:
__int64 __fastcall cmpScnOffs(const void *a1, const void *a2)
{
__int64 v2; // rax
__int64 v3; // rdx
unsigned __int64 v4; // rcx
unsigned int v5; // er8

if ( !a1 )
_assert_fail("ms1", "src/libelfu/model/section.c", 0xA6u, "cmpScnOffs");
if ( !a2 )
_assert_fail("ms2", "src/libelfu/model/section.c", 0xA7u, "cmpScnOffs");
v2 = *(_QWORD *)a1;
v3 = *(_QWORD *)a2;
if ( !*(_QWORD *)a1 )
_assert_fail("s1", "src/libelfu/model/section.c", 0xACu, "cmpScnOffs");
if ( !v3 )
_assert_fail("s2", "src/libelfu/model/section.c", 0xADu, "cmpScnOffs");
v4 = *(_QWORD *)(v3 + 24);
v5 = -1;
if ( *(_QWORD *)(v2 + 24) >= v4 )
v5 = *(_QWORD *)(v2 + 24) != v4;
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func3(const void *a1, const void *a2)
{
__int64 v2; // rax
__int64 v3; // rdx
unsigned __int64 v4; // rcx
unsigned int v5; // er8

if ( !a1 )
_assert_fail("ms1", "src/libelfu/model/section.c", 0xA6u, "cmpScnOffs");
if ( !a2 )
_assert_fail("ms2", "src/libelfu/model/section.c", 0xA7u, "cmpScnOffs");
v2 = *(_QWORD *)a1;
v3 = *(_QWORD *)a2;
if ( !*(_QWORD *)a1 )
_assert_fail("s1", "src/libelfu/model/section.c", 0xACu, "cmpScnOffs");
if ( !v3 )
_assert_fail("s2", "src/libelfu/model/section.c", 0xADu, "cmpScnOffs");
v4 = *(_QWORD *)(v3 + 24);
v5 = -1;
if ( *(_QWORD *)(v2 + 24) >= v4 )
v5 = *(_QWORD *)(v2 + 24) != v4;
return v5;
}

original_code:
static int cmpScnOffs(const void *ms1, const void *ms2)
{
  ElfuScn *s1;
  ElfuScn *s2;
  ((void) sizeof ((ms1) ? 1 : 0), __extension__ ({ if (ms1) ; else __assert_fail ("ms1", "src/libelfu/model/section.c", 166, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((ms2) ? 1 : 0), __extension__ ({ if (ms2) ; else __assert_fail ("ms2", "src/libelfu/model/section.c", 167, __extension__ __PRETTY_FUNCTION__); }));
  s1 = *(ElfuScn**)ms1;
  s2 = *(ElfuScn**)ms2;
  ((void) sizeof ((s1) ? 1 : 0), __extension__ ({ if (s1) ; else __assert_fail ("s1", "src/libelfu/model/section.c", 172, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((s2) ? 1 : 0), __extension__ ({ if (s2) ; else __assert_fail ("s2", "src/libelfu/model/section.c", 173, __extension__ __PRETTY_FUNCTION__); }));
  if (s1->shdr.sh_offset < s2->shdr.sh_offset) {
    return -1;
  } else if (s1->shdr.sh_offset == s2->shdr.sh_offset) {
    return 0;
  } else {
    return 1;
  }
}

canonical_original_code:
static int cmpScnOffs(void *ms1, void *ms2)
{
  struct ElfuScn *s1;
  struct ElfuScn *s2;
  ((void) sizeof ((ms1) ? 1 : 0), __extension__ ({ if (ms1) ; else __assert_fail ("ms1", "src/libelfu/model/section.c", 166, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((ms2) ? 1 : 0), __extension__ ({ if (ms2) ; else __assert_fail ("ms2", "src/libelfu/model/section.c", 167, __extension__ __PRETTY_FUNCTION__); }));
  s1 = *(struct ElfuScn **)ms1;
  s2 = *(struct ElfuScn **)ms2;
  ((void) sizeof ((s1) ? 1 : 0), __extension__ ({ if (s1) ; else __assert_fail ("s1", "src/libelfu/model/section.c", 172, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((s2) ? 1 : 0), __extension__ ({ if (s2) ; else __assert_fail ("s2", "src/libelfu/model/section.c", 173, __extension__ __PRETTY_FUNCTION__); }));
  if (s1->shdr.sh_offset < s2->shdr.sh_offset) {
    return -1;
  } else if (s1->shdr.sh_offset == s2->shdr.sh_offset) {
    return 0;
  } else {
    return 1;
  }
}


segmentTypeStr

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

switch ( a1 )
{
case 0:
result = "NULL";
break;
case 1:
result = "LOAD";
break;
case 2:
result = "DYNAMIC";
break;
case 3:
result = "INTERP";
break;
case 4:
result = "NOTE";
break;
case 5:
result = "SHLIB";
break;
case 6:
result = "PHDR";
break;
case 7:
result = "TLS";
break;
case 8:
result = "NUM";
break;
default:
result = "GNU_STACK";
if ( a1 != 1685382481 )
{
if ( a1 == 1685382482 )
{
result = "GNU_RELRO";
}
else
{
result = (const char *)&unk_8B3;
if ( a1 == 1685382480 )
result = "GNU_EH_FRAME";
}
}
break;
}
return result;
}

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

switch ( a1 )
{
case 0:
result = "NULL";
break;
case 1:
result = "LOAD";
break;
case 2:
result = "DYNAMIC";
break;
case 3:
result = "INTERP";
break;
case 4:
result = "NOTE";
break;
case 5:
result = "SHLIB";
break;
case 6:
result = "PHDR";
break;
case 7:
result = "TLS";
break;
case 8:
result = "NUM";
break;
default:
result = "GNU_STACK";
if ( a1 != 1685382481 )
{
if ( a1 == 1685382482 )
{
result = "GNU_RELRO";
}
else
{
result = (const char *)&unk_8B3;
if ( a1 == 1685382480 )
result = "GNU_EH_FRAME";
}
}
break;
}
return result;
}

original_code:
static char* segmentTypeStr(Elf32_Word p_type)
{
  switch(p_type) {
    case 0:
      return "NULL";
    case 1:
      return "LOAD";
    case 2:
      return "DYNAMIC";
    case 3:
      return "INTERP";
    case 4:
      return "NOTE";
    case 5:
      return "SHLIB";
    case 6:
      return "PHDR";
    case 7:
      return "TLS";
    case 8:
      return "NUM";
    case 0x6474e550:
      return "GNU_EH_FRAME";
    case 0x6474e551:
      return "GNU_STACK";
    case 0x6474e552:
      return "GNU_RELRO";
  }
  return "-?-";
}

canonical_original_code:
static char *segmentTypeStr(unsigned int p_type)
{
  switch(p_type) {
    case 0:
      return "NULL";
    case 1:
      return "LOAD";
    case 2:
      return "DYNAMIC";
    case 3:
      return "INTERP";
    case 4:
      return "NOTE";
    case 5:
      return "SHLIB";
    case 6:
      return "PHDR";
    case 7:
      return "TLS";
    case 8:
      return "NUM";
    case 0x6474e550:
      return "GNU_EH_FRAME";
    case 0x6474e551:
      return "GNU_STACK";
    case 0x6474e552:
      return "GNU_RELRO";
  }
  return "-?-";
}


sectionTypeStr

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

switch ( a1 )
{
case 0:
result = "NULL";
break;
case 1:
result = "PROGBITS";
break;
case 2:
result = "SYMTAB";
break;
case 3:
result = "STRTAB";
break;
case 4:
result = "RELA";
break;
case 5:
result = "HASH";
break;
case 6:
result = "DYNAMIC";
break;
case 7:
result = "NOTE";
break;
case 8:
result = "NOBITS";
break;
case 9:
result = "REL";
break;
case 10:
result = "SHLIB";
break;
case 11:
result = "DYNSYM";
break;
case 12:
case 13:
LABEL_2:
result = (const char *)&unk_8B3;
break;
case 14:
result = "INIT_ARRAY";
break;
case 15:
result = "FINI_ARRAY";
break;
case 16:
result = "PREINIT_ARRAY";
break;
case 17:
result = "SHT_GROUP";
break;
case 18:
result = "SYMTAB_SHNDX";
break;
case 19:
result = "NUM";
break;
default:
switch ( a1 )
{
case 1879048181:
result = "GNU_ATTRIBUTES";
break;
case 1879048182:
result = "GNU_HASH";
break;
case 1879048183:
result = "GNU_LIBLIST";
break;
case 1879048189:
result = "GNU_verdef";
break;
case 1879048190:
result = "GNU_verneed";
break;
case 1879048191:
result = "GNU_versym";
break;
default:
goto LABEL_2;
}
break;
}
return result;
}

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

switch ( a1 )
{
case 0:
result = "NULL";
break;
case 1:
result = "PROGBITS";
break;
case 2:
result = "SYMTAB";
break;
case 3:
result = "STRTAB";
break;
case 4:
result = "RELA";
break;
case 5:
result = "HASH";
break;
case 6:
result = "DYNAMIC";
break;
case 7:
result = "NOTE";
break;
case 8:
result = "NOBITS";
break;
case 9:
result = "REL";
break;
case 10:
result = "SHLIB";
break;
case 11:
result = "DYNSYM";
break;
case 12:
case 13:
LABEL_2:
result = (const char *)&unk_8B3;
break;
case 14:
result = "INIT_ARRAY";
break;
case 15:
result = "FINI_ARRAY";
break;
case 16:
result = "PREINIT_ARRAY";
break;
case 17:
result = "SHT_GROUP";
break;
case 18:
result = "SYMTAB_SHNDX";
break;
case 19:
result = "NUM";
break;
default:
switch ( a1 )
{
case 1879048181:
result = "GNU_ATTRIBUTES";
break;
case 1879048182:
result = "GNU_HASH";
break;
case 1879048183:
result = "GNU_LIBLIST";
break;
case 1879048189:
result = "GNU_verdef";
break;
case 1879048190:
result = "GNU_verneed";
break;
case 1879048191:
result = "GNU_versym";
break;
default:
goto LABEL_2;
}
break;
}
return result;
}

original_code:
static char* sectionTypeStr(Elf32_Word sh_type)
{
  switch(sh_type) {
    case 0:
      return "NULL";
    case 1:
      return "PROGBITS";
    case 2:
      return "SYMTAB";
    case 3:
      return "STRTAB";
    case 4:
      return "RELA";
    case 5:
      return "HASH";
    case 6:
      return "DYNAMIC";
    case 7:
      return "NOTE";
    case 8:
      return "NOBITS";
    case 9:
      return "REL";
    case 10:
      return "SHLIB";
    case 11:
      return "DYNSYM";
    case 14:
      return "INIT_ARRAY";
    case 15:
      return "FINI_ARRAY";
    case 16:
      return "PREINIT_ARRAY";
    case 17:
      return "SHT_GROUP";
    case 18:
      return "SYMTAB_SHNDX";
    case 19:
      return "NUM";
    case 0x6ffffff5:
      return "GNU_ATTRIBUTES";
    case 0x6ffffff6:
      return "GNU_HASH";
    case 0x6ffffff7:
      return "GNU_LIBLIST";
    case 0x6ffffffd:
      return "GNU_verdef";
    case 0x6ffffffe:
      return "GNU_verneed";
    case 0x6fffffff:
      return "GNU_versym";
  }
  return "-?-";
}

canonical_original_code:
static char *sectionTypeStr(unsigned int sh_type)
{
  switch(sh_type) {
    case 0:
      return "NULL";
    case 1:
      return "PROGBITS";
    case 2:
      return "SYMTAB";
    case 3:
      return "STRTAB";
    case 4:
      return "RELA";
    case 5:
      return "HASH";
    case 6:
      return "DYNAMIC";
    case 7:
      return "NOTE";
    case 8:
      return "NOBITS";
    case 9:
      return "REL";
    case 10:
      return "SHLIB";
    case 11:
      return "DYNSYM";
    case 14:
      return "INIT_ARRAY";
    case 15:
      return "FINI_ARRAY";
    case 16:
      return "PREINIT_ARRAY";
    case 17:
      return "SHT_GROUP";
    case 18:
      return "SYMTAB_SHNDX";
    case 19:
      return "NUM";
    case 0x6ffffff5:
      return "GNU_ATTRIBUTES";
    case 0x6ffffff6:
      return "GNU_HASH";
    case 0x6ffffff7:
      return "GNU_LIBLIST";
    case 0x6ffffffd:
      return "GNU_verdef";
    case 0x6ffffffe:
      return "GNU_verneed";
    case 0x6fffffff:
      return "GNU_versym";
  }
  return "-?-";
}


decompiled_code:
int __fastcall elfu_mDumpPhdr(__int64 a1, __int64 a2)
{
__int64 v2; // r13
const char *v3; // rax
__int64 v4; // rcx
int result; // eax
__int64 i; // rbx
const char *v7; // rax
__int64 v8; // r13
__int64 j; // rbx
__int64 v10; // r12
const char *v11; // rax

if ( !a1 )
_assert_fail("me", "src/libelfu/modelops/dump.c", 0x72u, "elfu_mDumpPhdr");
if ( !a2 )
_assert_fail("mp", "src/libelfu/modelops/dump.c", 0x73u, "elfu_mDumpPhdr");
v2 = a2 + 72;
v3 = segmentTypeStr(*(_DWORD *)a2);
result = fprintf(
stdout,
"%12s %8x %8x %8x %8x %8x %8x %8x %8x\n",
v3,
v4,
*(unsigned int *)(a2 + 8),
*(unsigned int *)(a2 + 16),
*(_QWORD *)(a2 + 24),
*(_QWORD *)(a2 + 32),
*(_QWORD *)(a2 + 40),
*(unsigned int *)(a2 + 4),
*(_QWORD *)(a2 + 48));
if ( *(_QWORD *)(a2 + 72) != a2 + 72 )
{
result = fwrite(" -> Child PHDRs:\n", 1uLL, 0x16uLL, stdout);
for ( i = *(_QWORD *)(a2 + 72); v2 != i; i = *(_QWORD *)(i + 88) )
{
v7 = segmentTypeStr(*(_DWORD *)i);
result = fprintf(stdout, " * %-8s @ %8x\n", v7, *(unsigned int *)(i + 16));
}
}
v8 = a2 + 56;
if ( *(_QWORD *)(a2 + 56) != a2 + 56 )
{
result = fwrite(" -> Child sections:\n", 1uLL, 0x19uLL, stdout);
for ( j = *(_QWORD *)(a2 + 56); v8 != j; j = *(_QWORD *)(j + 128) )
{
v10 = *(_QWORD *)(j + 16);
v11 = (const char *)elfu_mScnName(a1, j);
result = fprintf(stdout, " * %-17s @ %8x\n", v11, (unsigned int)v10);
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(__int64 a1, __int64 a2)
{
__int64 v2; // r13
const char *v3; // rax
__int64 v4; // rcx
int result; // eax
__int64 i; // rbx
const char *v7; // rax
__int64 v8; // r13
__int64 j; // rbx
__int64 v10; // r12
const char *v11; // rax

if ( !a1 )
_assert_fail("me", "src/libelfu/modelops/dump.c", 0x72u, "elfu_mDumpPhdr");
if ( !a2 )
_assert_fail("mp", "src/libelfu/modelops/dump.c", 0x73u, "elfu_mDumpPhdr");
v2 = a2 + 72;
v3 = func0(*(_DWORD *)a2);
result = fprintf(
stdout,
"%12s %8x %8x %8x %8x %8x %8x %8x %8x\n",
v3,
v4,
*(unsigned int *)(a2 + 8),
*(unsigned int *)(a2 + 16),
*(_QWORD *)(a2 + 24),
*(_QWORD *)(a2 + 32),
*(_QWORD *)(a2 + 40),
*(unsigned int *)(a2 + 4),
*(_QWORD *)(a2 + 48));
if ( *(_QWORD *)(a2 + 72) != a2 + 72 )
{
result = fwrite(" -> Child PHDRs:\n", 1uLL, 0x16uLL, stdout);
for ( i = *(_QWORD *)(a2 + 72); v2 != i; i = *(_QWORD *)(i + 88) )
{
v7 = func0(*(_DWORD *)i);
result = fprintf(stdout, " * %-8s @ %8x\n", v7, *(unsigned int *)(i + 16));
}
}
v8 = a2 + 56;
if ( *(_QWORD *)(a2 + 56) != a2 + 56 )
{
result = fwrite(" -> Child sections:\n", 1uLL, 0x19uLL, stdout);
for ( j = *(_QWORD *)(a2 + 56); v8 != j; j = *(_QWORD *)(j + 128) )
{
v10 = *(_QWORD *)(j + 16);
v11 = (const char *)elfu_mScnName(a1, j);
result = fprintf(stdout, " * %-17s @ %8x\n", v11, (unsigned int)v10);
}
}
return result;
}

original_code:
void elfu_mDumpPhdr(ElfuElf *me, ElfuPhdr *mp)
{
  ((void) sizeof ((me) ? 1 : 0), __extension__ ({ if (me) ; else __assert_fail ("me", "src/libelfu/modelops/dump.c", 114, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((mp) ? 1 : 0), __extension__ ({ if (mp) ; else __assert_fail ("mp", "src/libelfu/modelops/dump.c", 115, __extension__ __PRETTY_FUNCTION__); }));
  do { fprintf(stdout, "%12s %8x %8x %8x %8x %8x %8x %8x %8x\n", segmentTypeStr(mp->phdr.p_type), (unsigned)mp->phdr.p_type, (unsigned)mp->phdr.p_offset, (unsigned)mp->phdr.p_vaddr, (unsigned)mp->phdr.p_paddr, (unsigned)mp->phdr.p_filesz, (unsigned)mp->phdr.p_memsz, (unsigned)mp->phdr.p_flags, (unsigned)mp->phdr.p_align); } while(0);
  if (!((&mp->childPhdrList)->cqh_first == (void *)(&mp->childPhdrList))) {
    ElfuPhdr *mpc;
    do { fprintf(stdout, "      -> Child PHDRs:\n"); } while(0);
    for ((mpc) = ((&mp->childPhdrList)->cqh_first); (mpc) != (const void *)(&mp->childPhdrList); (mpc) = ((mpc)->elemChildPhdr.cqe_next)) {
      do { fprintf(stdout, "        * %-8s @ %8x\n", segmentTypeStr(mpc->phdr.p_type), (unsigned)mpc->phdr.p_vaddr); } while(0);
    }
  }
  if (!((&mp->childScnList)->cqh_first == (void *)(&mp->childScnList))) {
    ElfuScn *msc;
    do { fprintf(stdout, "      -> Child sections:\n"); } while(0);
    for ((msc) = ((&mp->childScnList)->cqh_first); (msc) != (const void *)(&mp->childScnList); (msc) = ((msc)->elemChildScn.cqe_next)) {
      do { fprintf(stdout, "        * %-17s @ %8x\n", elfu_mScnName(me, msc), (unsigned)msc->shdr.sh_addr); } while(0);
    }
  }
}

canonical_original_code:
void elfu_mDumpPhdr(struct ElfuElf *me, struct ElfuPhdr *mp)
{
  ((void) sizeof ((me) ? 1 : 0), __extension__ ({ if (me) ; else __assert_fail ("me", "src/libelfu/modelops/dump.c", 114, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((mp) ? 1 : 0), __extension__ ({ if (mp) ; else __assert_fail ("mp", "src/libelfu/modelops/dump.c", 115, __extension__ __PRETTY_FUNCTION__); }));
  do { fprintf(stdout, "%12s %8x %8x %8x %8x %8x %8x %8x %8x\n", segmentTypeStr(mp->phdr.p_type), (unsigned int)mp->phdr.p_type, (unsigned int)mp->phdr.p_offset, (unsigned int)mp->phdr.p_vaddr, (unsigned int)mp->phdr.p_paddr, (unsigned int)mp->phdr.p_filesz, (unsigned int)mp->phdr.p_memsz, (unsigned int)mp->phdr.p_flags, (unsigned int)mp->phdr.p_align); } while(0);
  if (!((&mp->childPhdrList)->cqh_first == (void *)(&mp->childPhdrList))) {
    struct ElfuPhdr *mpc;
    do { fprintf(stdout, "      -> Child PHDRs:\n"); } while(0);
    for ((mpc) = ((&mp->childPhdrList)->cqh_first); (mpc) != (void *)(&mp->childPhdrList); (mpc) = ((mpc)->elemChildPhdr.cqe_next)) {
      do { fprintf(stdout, "        * %-8s @ %8x\n", segmentTypeStr(mpc->phdr.p_type), (unsigned int)mpc->phdr.p_vaddr); } while(0);
    }
  }
  if (!((&mp->childScnList)->cqh_first == (void *)(&mp->childScnList))) {
    struct ElfuScn *msc;
    do { fprintf(stdout, "      -> Child sections:\n"); } while(0);
    for ((msc) = ((&mp->childScnList)->cqh_first); (msc) != (void *)(&mp->childScnList); (msc) = ((msc)->elemChildScn.cqe_next)) {
      do { fprintf(stdout, "        * %-17s @ %8x\n", elfu_mScnName(me, msc), (unsigned int)msc->shdr.sh_addr); } while(0);
    }
  }
}

variable_types:
mp
struct ElfuPhdr *


decompiled_code:
int __fastcall elfu_mDumpScn(__int64 a1, __int64 a2)
{
const char *v3; // r13
const char *v4; // r12
const char *v5; // rax
__int64 v6; // rsi
const char *v7; // r14
__int64 v8; // rsi
const char *v9; // rax

if ( !a1 )
_assert_fail("me", "src/libelfu/modelops/dump.c", 0x9Cu, "elfu_mDumpScn");
if ( !a2 )
_assert_fail("ms", "src/libelfu/modelops/dump.c", 0x9Du, "elfu_mDumpScn");
v3 = (const char *)&unk_A3D;
v4 = (const char *)elfu_mScnName(a1, a2);
v5 = sectionTypeStr(*(_DWORD *)(a2 + 4));
v6 = *(_QWORD *)(a2 + 72);
v7 = v5;
if ( v6 )
v3 = (const char *)elfu_mScnName(a1, v6);
v8 = *(_QWORD *)(a2 + 80);
v9 = (const char *)&unk_A3D;
if ( v8 )
v9 = (const char *)elfu_mScnName(a1, v8);
return fprintf(
stdout,
"%-17s %-15s %8x %9x %8x %2x %2x %2d %-17s %-17s\n",
v4,
v7,
*(unsigned int *)(a2 + 16),
*(unsigned int *)(a2 + 24),
*(_QWORD *)(a2 + 32),
*(_QWORD *)(a2 + 56),
*(_QWORD *)(a2 + 8),
*(_QWORD *)(a2 + 48),
v3,
v9);
}

canonical_decompiled_code:
int __fastcall func3(__int64 a1, __int64 a2)
{
const char *v3; // r13
const char *v4; // r12
const char *v5; // rax
__int64 v6; // rsi
const char *v7; // r14
__int64 v8; // rsi
const char *v9; // rax

if ( !a1 )
_assert_fail("me", "src/libelfu/modelops/dump.c", 0x9Cu, "elfu_mDumpScn");
if ( !a2 )
_assert_fail("ms", "src/libelfu/modelops/dump.c", 0x9Du, "elfu_mDumpScn");
v3 = (const char *)&unk_A3D;
v4 = (const char *)elfu_mScnName(a1, a2);
v5 = func1(*(_DWORD *)(a2 + 4));
v6 = *(_QWORD *)(a2 + 72);
v7 = v5;
if ( v6 )
v3 = (const char *)elfu_mScnName(a1, v6);
v8 = *(_QWORD *)(a2 + 80);
v9 = (const char *)&unk_A3D;
if ( v8 )
v9 = (const char *)elfu_mScnName(a1, v8);
return fprintf(
stdout,
"%-17s %-15s %8x %9x %8x %2x %2x %2d %-17s %-17s\n",
v4,
v7,
*(unsigned int *)(a2 + 16),
*(unsigned int *)(a2 + 24),
*(_QWORD *)(a2 + 32),
*(_QWORD *)(a2 + 56),
*(_QWORD *)(a2 + 8),
*(_QWORD *)(a2 + 48),
v3,
v9);
}

original_code:
void elfu_mDumpScn(ElfuElf *me, ElfuScn *ms)
{
  char *namestr, *typestr, *linkstr, *infostr;
  ((void) sizeof ((me) ? 1 : 0), __extension__ ({ if (me) ; else __assert_fail ("me", "src/libelfu/modelops/dump.c", 156, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((ms) ? 1 : 0), __extension__ ({ if (ms) ; else __assert_fail ("ms", "src/libelfu/modelops/dump.c", 157, __extension__ __PRETTY_FUNCTION__); }));
  namestr = elfu_mScnName(me, ms);
  typestr = sectionTypeStr(ms->shdr.sh_type);
  linkstr = ms->linkptr ? elfu_mScnName(me, ms->linkptr) : "";
  infostr = ms->infoptr ? elfu_mScnName(me, ms->infoptr) : "";
  do { fprintf(stdout, "%-17s %-15s %8x %9x %8x %2x %2x %2d %-17s %-17s\n", namestr, typestr, (unsigned)ms->shdr.sh_addr, (unsigned)ms->shdr.sh_offset, (unsigned)ms->shdr.sh_size, (unsigned)ms->shdr.sh_entsize, (unsigned)ms->shdr.sh_flags, (unsigned)ms->shdr.sh_addralign, linkstr, infostr); } while(0);
}

canonical_original_code:
void elfu_mDumpScn(struct ElfuElf *me, struct ElfuScn *ms)
{
  char *namestr; char *typestr; char *linkstr; char *infostr;
  ((void) sizeof ((me) ? 1 : 0), __extension__ ({ if (me) ; else __assert_fail ("me", "src/libelfu/modelops/dump.c", 156, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((ms) ? 1 : 0), __extension__ ({ if (ms) ; else __assert_fail ("ms", "src/libelfu/modelops/dump.c", 157, __extension__ __PRETTY_FUNCTION__); }));
  namestr = elfu_mScnName(me, ms);
  typestr = sectionTypeStr(ms->shdr.sh_type);
  linkstr = ms->linkptr ? elfu_mScnName(me, ms->linkptr) : "";
  infostr = ms->infoptr ? elfu_mScnName(me, ms->infoptr) : "";
  do { fprintf(stdout, "%-17s %-15s %8x %9x %8x %2x %2x %2d %-17s %-17s\n", namestr, typestr, (unsigned int)ms->shdr.sh_addr, (unsigned int)ms->shdr.sh_offset, (unsigned int)ms->shdr.sh_size, (unsigned int)ms->shdr.sh_entsize, (unsigned int)ms->shdr.sh_flags, (unsigned int)ms->shdr.sh_addralign, linkstr, infostr); } while(0);
}

variable_types:
ms
struct ElfuScn *

variable_types:
namestr
char *

variable_types:
typestr
char *

variable_types:
linkstr
char *

variable_types:
infostr
char *


subScnDump

decompiled_code:
__int64 __fastcall subScnDump(__int64 a1, __int64 a2)
{
__int64 v2; // rax

v2 = elfu_mScnIndex();
printf(" [%4d] ", v2);
elfu_mDumpScn(a1, a2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2)
{
__int64 v2; // rax

v2 = elfu_mScnIndex();
printf(" [%4d] ", v2);
func3(a1, a2);
return 0LL;
}

original_code:
static void* subScnDump(ElfuElf *me, ElfuScn *ms, void *aux1, void *aux2)
{
  (void) aux1;
  (void) aux2;
  printf(" [%4d] ", elfu_mScnIndex(me, ms));
  elfu_mDumpScn(me, ms);
  return ((void *)0);
}

canonical_original_code:
static void *subScnDump(struct ElfuElf *me, struct ElfuScn *ms, void *aux1, void *aux2)
{
  (void) aux1;
  (void) aux2;
  printf(" [%4d] ", elfu_mScnIndex(me, ms));
  elfu_mDumpScn(me, ms);
  return ((void *)0);
}


decompiled_code:
int __fastcall elfu_mDumpEhdr(__int64 a1)
{
__int64 v1; // rdx
__int64 v2; // rsi
const char *v3; // rdx

if ( !a1 )
_assert_fail("me", "src/libelfu/modelops/dump.c", 0xB4u, "elfu_mDumpEhdr");
fwrite("ELF header:\n", 1uLL, 0xCuLL, stdout);
v1 = 32LL;
if ( *(_DWORD *)a1 != 1 )
v1 = 64LL;
fprintf(stdout, " %d-bit ELF object\n", v1);
fwrite(" EHDR:\n", 1uLL, 9uLL, stdout);
fprintf(stdout, " e_type %8x\n", *(unsigned __int16 *)(a1 + 24));
fprintf(stdout, " e_machine %8x\n", *(unsigned __int16 *)(a1 + 26));
fprintf(stdout, " e_version %8x\n", *(unsigned int *)(a1 + 28));
fprintf(stdout, " e_entry %8x\n", *(unsigned int *)(a1 + 32));
fprintf(stdout, " e_phoff %8x\n", *(unsigned int *)(a1 + 40));
fprintf(stdout, " e_shoff %8x\n", *(unsigned int *)(a1 + 48));
fprintf(stdout, " e_flags %8x\n", *(unsigned int *)(a1 + 56));
fprintf(stdout, " e_ehsize %8x\n", *(unsigned __int16 *)(a1 + 60));
fprintf(stdout, " e_phentsize %8x\n", *(unsigned __int16 *)(a1 + 62));
fprintf(stdout, " e_shentsize %8x\n", *(unsigned __int16 *)(a1 + 66));
v2 = *(_QWORD *)(a1 + 104);
v3 = "(none)";
if ( v2 )
v3 = (const char *)elfu_mScnName(a1, v2);
return fprintf(stdout, " shstrtab: %s\n", v3);
}

canonical_decompiled_code:
int __fastcall func5(__int64 a1)
{
__int64 v1; // rdx
__int64 v2; // rsi
const char *v3; // rdx

if ( !a1 )
_assert_fail("me", "src/libelfu/modelops/dump.c", 0xB4u, "elfu_mDumpEhdr");
fwrite("ELF header:\n", 1uLL, 0xCuLL, stdout);
v1 = 32LL;
if ( *(_DWORD *)a1 != 1 )
v1 = 64LL;
fprintf(stdout, " %d-bit ELF object\n", v1);
fwrite(" EHDR:\n", 1uLL, 9uLL, stdout);
fprintf(stdout, " e_type %8x\n", *(unsigned __int16 *)(a1 + 24));
fprintf(stdout, " e_machine %8x\n", *(unsigned __int16 *)(a1 + 26));
fprintf(stdout, " e_version %8x\n", *(unsigned int *)(a1 + 28));
fprintf(stdout, " e_entry %8x\n", *(unsigned int *)(a1 + 32));
fprintf(stdout, " e_phoff %8x\n", *(unsigned int *)(a1 + 40));
fprintf(stdout, " e_shoff %8x\n", *(unsigned int *)(a1 + 48));
fprintf(stdout, " e_flags %8x\n", *(unsigned int *)(a1 + 56));
fprintf(stdout, " e_ehsize %8x\n", *(unsigned __int16 *)(a1 + 60));
fprintf(stdout, " e_phentsize %8x\n", *(unsigned __int16 *)(a1 + 62));
fprintf(stdout, " e_shentsize %8x\n", *(unsigned __int16 *)(a1 + 66));
v2 = *(_QWORD *)(a1 + 104);
v3 = "(none)";
if ( v2 )
v3 = (const char *)elfu_mScnName(a1, v2);
return fprintf(stdout, " shstrtab: %s\n", v3);
}

original_code:
void elfu_mDumpEhdr(ElfuElf *me)
{
  ((void) sizeof ((me) ? 1 : 0), __extension__ ({ if (me) ; else __assert_fail ("me", "src/libelfu/modelops/dump.c", 180, __extension__ __PRETTY_FUNCTION__); }));
  do { fprintf(stdout, "ELF header:\n"); } while(0);
  do { fprintf(stdout, "   %d-bit ELF object\n", me->elfclass == 1 ? 32 : 64); } while(0);
  do { fprintf(stdout, "   EHDR:\n"); } while(0);
  do { fprintf(stdout, "     e_type       %8x\n", me->ehdr.e_type); } while(0);
  do { fprintf(stdout, "     e_machine    %8x\n", me->ehdr.e_machine); } while(0);
  do { fprintf(stdout, "     e_version    %8x\n", me->ehdr.e_version); } while(0);
  do { fprintf(stdout, "     e_entry      %8x\n", (unsigned)me->ehdr.e_entry); } while(0);
  do { fprintf(stdout, "     e_phoff      %8x\n", (unsigned)me->ehdr.e_phoff); } while(0);
  do { fprintf(stdout, "     e_shoff      %8x\n", (unsigned)me->ehdr.e_shoff); } while(0);
  do { fprintf(stdout, "     e_flags      %8x\n", me->ehdr.e_flags); } while(0);
  do { fprintf(stdout, "     e_ehsize     %8x\n", me->ehdr.e_ehsize); } while(0);
  do { fprintf(stdout, "     e_phentsize  %8x\n", me->ehdr.e_phentsize); } while(0);
  do { fprintf(stdout, "     e_shentsize  %8x\n", me->ehdr.e_shentsize); } while(0);
  do { fprintf(stdout, "   shstrtab: %s\n", me->shstrtab ? elfu_mScnName(me, me->shstrtab) : "(none)"); } while(0);
}

canonical_original_code:
void elfu_mDumpEhdr(struct ElfuElf *me)
{
  ((void) sizeof ((me) ? 1 : 0), __extension__ ({ if (me) ; else __assert_fail ("me", "src/libelfu/modelops/dump.c", 180, __extension__ __PRETTY_FUNCTION__); }));
  do { fprintf(stdout, "ELF header:\n"); } while(0);
  do { fprintf(stdout, "   %d-bit ELF object\n", me->elfclass == 1 ? 32 : 64); } while(0);
  do { fprintf(stdout, "   EHDR:\n"); } while(0);
  do { fprintf(stdout, "     e_type       %8x\n", me->ehdr.e_type); } while(0);
  do { fprintf(stdout, "     e_machine    %8x\n", me->ehdr.e_machine); } while(0);
  do { fprintf(stdout, "     e_version    %8x\n", me->ehdr.e_version); } while(0);
  do { fprintf(stdout, "     e_entry      %8x\n", (unsigned int)me->ehdr.e_entry); } while(0);
  do { fprintf(stdout, "     e_phoff      %8x\n", (unsigned int)me->ehdr.e_phoff); } while(0);
  do { fprintf(stdout, "     e_shoff      %8x\n", (unsigned int)me->ehdr.e_shoff); } while(0);
  do { fprintf(stdout, "     e_flags      %8x\n", me->ehdr.e_flags); } while(0);
  do { fprintf(stdout, "     e_ehsize     %8x\n", me->ehdr.e_ehsize); } while(0);
  do { fprintf(stdout, "     e_phentsize  %8x\n", me->ehdr.e_phentsize); } while(0);
  do { fprintf(stdout, "     e_shentsize  %8x\n", me->ehdr.e_shentsize); } while(0);
  do { fprintf(stdout, "   shstrtab: %s\n", me->shstrtab ? elfu_mScnName(me, me->shstrtab) : "(none)"); } while(0);
}