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


repo: norly/centaur

decompiled_code:
void *__fastcall elfu_mScnSortedByOffset(__int64 a1, __int64 *a2)
{
__int64 v2; // rbp
void *v3; // rax
void *v4; // rbx
__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; // rbp
void *v3; // rax
void *v4; // rbx
__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: 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:
count
unsigned long *

variable_types:
numSecs
unsigned long

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

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 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 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 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_mScnAppendData(__int64 a1, const void *a2, size_t a3)
{
void *v5; // 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");
v5 = *(void **)(a1 + 64);
if ( !v5 )
_assert_fail("ms->databuf", "src/libelfu/model/section.c", 0xDCu, "elfu_mScnAppendData");
v6 = (char *)realloc(v5, *(_QWORD *)(a1 + 32) + a3);
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 *v5; // 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");
v5 = *(void **)(a1 + 64);
if ( !v5 )
_assert_fail("ms->databuf", "src/libelfu/model/section.c", 0xDCu, "elfu_mScnAppendData");
v6 = (char *)realloc(v5, *(_QWORD *)(a1 + 32) + a3);
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; // rbx

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

canonical_decompiled_code:
_QWORD *func11()
{
_QWORD *v0; // rbx

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

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

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


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

return_type: void

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


subCounter

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

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

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

result = a2;
if ( a2 != a4 )
{
++*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; } *

variable_types:
ms
struct ElfuScn *

variable_types:
i
unsigned long *

return_type: void *

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


cmpScnOffs

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

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 *)a2;
if ( !*(_QWORD *)a1 )
_assert_fail("s1", "src/libelfu/model/section.c", 0xACu, "cmpScnOffs");
if ( !v2 )
_assert_fail("s2", "src/libelfu/model/section.c", 0xADu, "cmpScnOffs");
v3 = *(_QWORD *)(*(_QWORD *)a1 + 24LL);
v4 = *(_QWORD *)(v2 + 24);
result = 0xFFFFFFFFLL;
if ( v3 >= v4 )
result = v3 != v4;
return result;
}

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

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 *)a2;
if ( !*(_QWORD *)a1 )
_assert_fail("s1", "src/libelfu/model/section.c", 0xACu, "cmpScnOffs");
if ( !v2 )
_assert_fail("s2", "src/libelfu/model/section.c", 0xADu, "cmpScnOffs");
v3 = *(_QWORD *)(*(_QWORD *)a1 + 24LL);
v4 = *(_QWORD *)(v2 + 24);
result = 0xFFFFFFFFLL;
if ( v3 >= v4 )
result = v3 != v4;
return result;
}

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

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 ElfuRel { unsigned long offset; unsigned int sym; unsigned char type; int addendUsed; int addend; struct { struct ElfuRel *cqe_next; struct ElfuRel *cqe_prev; } elem; }


segmentTypeStr

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

if ( !(v1 | v2) )
return (const char *)&unk_789;
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_789;
if ( a1 == 1685382480 )
result = "GNU_EH_FRAME";
}
}
break;
}
return result;
}

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

if ( !(v1 | v2) )
return (const char *)&unk_789;
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_789;
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 "-?-";
}

return_type: char *


sectionTypeStr

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

if ( !(v1 | v2) )
return (const char *)&unk_789;
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:
return (const char *)&unk_789;
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:
if ( (unsigned int)(a1 - 1879048181) > 0xA )
{
result = (const char *)&unk_789;
}
else
{
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:
result = (const char *)&unk_789;
break;
}
}
break;
}
return result;
}

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

if ( !(v1 | v2) )
return (const char *)&unk_789;
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:
return (const char *)&unk_789;
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:
if ( (unsigned int)(a1 - 1879048181) > 0xA )
{
result = (const char *)&unk_789;
}
else
{
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:
result = (const char *)&unk_789;
break;
}
}
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)
{
unsigned int v2; // ebx
const char *v3; // rax
int result; // eax
__int64 v5; // r13
__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 = *(_DWORD *)a2;
v3 = segmentTypeStr(*(_DWORD *)a2);
result = fprintf(
stdout,
"%12s %8x %8x %8x %8x %8x %8x %8x %8x\n",
v3,
v2,
*(unsigned int *)(a2 + 8),
*(unsigned int *)(a2 + 16),
*(_QWORD *)(a2 + 24),
*(_QWORD *)(a2 + 32),
*(_QWORD *)(a2 + 40),
*(unsigned int *)(a2 + 4),
*(_QWORD *)(a2 + 48));
v5 = a2 + 72;
if ( *(_QWORD *)(a2 + 72) != a2 + 72 )
{
result = fwrite(" -> Child PHDRs:\n", 1uLL, 0x16uLL, stdout);
for ( i = *(_QWORD *)(a2 + 72); v5 != 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)
{
unsigned int v2; // ebx
const char *v3; // rax
int result; // eax
__int64 v5; // r13
__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 = *(_DWORD *)a2;
v3 = func0(*(_DWORD *)a2);
result = fprintf(
stdout,
"%12s %8x %8x %8x %8x %8x %8x %8x %8x\n",
v3,
v2,
*(unsigned int *)(a2 + 8),
*(unsigned int *)(a2 + 16),
*(_QWORD *)(a2 + 24),
*(_QWORD *)(a2 + 32),
*(_QWORD *)(a2 + 40),
*(unsigned int *)(a2 + 4),
*(_QWORD *)(a2 + 48));
v5 = a2 + 72;
if ( *(_QWORD *)(a2 + 72) != a2 + 72 )
{
result = fwrite(" -> Child PHDRs:\n", 1uLL, 0x16uLL, stdout);
for ( i = *(_QWORD *)(a2 + 72); v5 != 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 *

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

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


decompiled_code:
int __fastcall elfu_mDumpScn(__int64 a1, __int64 a2)
{
const char *v3; // r12
const char *v4; // r13
__int64 v5; // rsi
const char *v6; // r14
__int64 v7; // rsi
const char *v8; // 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 *)elfu_mScnName(a1, a2);
v4 = sectionTypeStr(*(_DWORD *)(a2 + 4));
v5 = *(_QWORD *)(a2 + 72);
v6 = (const char *)&unk_913;
if ( v5 )
v6 = (const char *)elfu_mScnName(a1, v5);
v7 = *(_QWORD *)(a2 + 80);
v8 = (const char *)&unk_913;
if ( v7 )
v8 = (const char *)elfu_mScnName(a1, v7);
return fprintf(
stdout,
"%-17s %-15s %8x %9x %8x %2x %2x %2d %-17s %-17s\n",
v3,
v4,
*(unsigned int *)(a2 + 16),
*(unsigned int *)(a2 + 24),
*(_QWORD *)(a2 + 32),
*(_QWORD *)(a2 + 56),
*(_QWORD *)(a2 + 8),
*(_QWORD *)(a2 + 48),
v6,
v8);
}

canonical_decompiled_code:
int __fastcall func3(__int64 a1, __int64 a2)
{
const char *v3; // r12
const char *v4; // r13
__int64 v5; // rsi
const char *v6; // r14
__int64 v7; // rsi
const char *v8; // 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 *)elfu_mScnName(a1, a2);
v4 = func1(*(_DWORD *)(a2 + 4));
v5 = *(_QWORD *)(a2 + 72);
v6 = (const char *)&unk_913;
if ( v5 )
v6 = (const char *)elfu_mScnName(a1, v5);
v7 = *(_QWORD *)(a2 + 80);
v8 = (const char *)&unk_913;
if ( v7 )
v8 = (const char *)elfu_mScnName(a1, v7);
return fprintf(
stdout,
"%-17s %-15s %8x %9x %8x %2x %2x %2d %-17s %-17s\n",
v3,
v4,
*(unsigned int *)(a2 + 16),
*(unsigned int *)(a2 + 24),
*(_QWORD *)(a2 + 32),
*(_QWORD *)(a2 + 56),
*(_QWORD *)(a2 + 8),
*(_QWORD *)(a2 + 48),
v6,
v8);
}

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:
namestr
char *

variable_types:
typestr
char *

variable_types:
linkstr
char *

variable_types:
infostr
char *

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


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


decompiled_code:
int __fastcall elfu_mDumpElf(__int64 a1)
{
__int64 i; // rbx
_QWORD *j; // rbx
__int64 v3; // r14
__int64 v4; // r13
__int64 v5; // r12
const char *v6; // rax
__int64 v8[8]; // [rsp+8h] [rbp-40h] BYREF

if ( !a1 )
_assert_fail("me", "src/libelfu/modelops/dump.c", 0xDDu, "elfu_mDumpElf");
elfu_mDumpEhdr(a1);
fputc(10, stdout);
fwrite("Segments:\n", 1uLL, 0xAuLL, stdout);
fwrite(
" # (type) p_type p_offset p_vaddr p_paddr p_filesz p_memsz p_flags p_align\n",
1uLL,
0x5DuLL,
stdout);
fwrite(
" | | | | | | | | | \n",
1uLL,
0x5DuLL,
stdout);
v8[0] = 0LL;
for ( i = *(_QWORD *)(a1 + 72); i != a1 + 72; i = *(_QWORD *)(i + 104) )
{
printf(" [%4d] ", v8[0]);
elfu_mDumpPhdr(a1, i);
++v8[0];
}
fputc(10, stdout);
fwrite("Orphaned sections:\n", 1uLL, 0x13uLL, stdout);
for ( j = *(_QWORD **)(a1 + 88); j != (_QWORD *)(a1 + 88); j = (_QWORD *)j[16] )
{
v3 = j[4];
v4 = j[3];
v5 = j[2];
v6 = (const char *)elfu_mScnName(a1, j);
fprintf(
stdout,
" * %-17s @ %8x offset %8x size %8x\n",
v6,
(unsigned int)v5,
(unsigned int)v4,
(unsigned int)v3);
}
fputc(10, stdout);
fwrite("Sections:\n", 1uLL, 0xAuLL, stdout);
fwrite(
" # Name sh_type sh_addr sh_offset sh_size ES Fl Al sh_link sh_info \n",
1uLL,
0x73uLL,
stdout);
fwrite(
" | | | | | | | | | | \n",
1uLL,
0x73uLL,
stdout);
elfu_mScnForall(a1, subScnDump, v8, 0LL);
return fputc(10, stdout);
}

canonical_decompiled_code:
int __fastcall func6(__int64 a1)
{
__int64 i; // rbx
_QWORD *j; // rbx
__int64 v3; // r14
__int64 v4; // r13
__int64 v5; // r12
const char *v6; // rax
__int64 v8[8]; // [rsp+8h] [rbp-40h] BYREF

if ( !a1 )
_assert_fail("me", "src/libelfu/modelops/dump.c", 0xDDu, "elfu_mDumpElf");
func5(a1);
fputc(10, stdout);
fwrite("Segments:\n", 1uLL, 0xAuLL, stdout);
fwrite(
" # (type) p_type p_offset p_vaddr p_paddr p_filesz p_memsz p_flags p_align\n",
1uLL,
0x5DuLL,
stdout);
fwrite(
" | | | | | | | | | \n",
1uLL,
0x5DuLL,
stdout);
v8[0] = 0LL;
for ( i = *(_QWORD *)(a1 + 72); i != a1 + 72; i = *(_QWORD *)(i + 104) )
{
printf(" [%4d] ", v8[0]);
func2(a1, i);
++v8[0];
}
fputc(10, stdout);
fwrite("Orphaned sections:\n", 1uLL, 0x13uLL, stdout);
for ( j = *(_QWORD **)(a1 + 88); j != (_QWORD *)(a1 + 88); j = (_QWORD *)j[16] )
{
v3 = j[4];
v4 = j[3];
v5 = j[2];
v6 = (const char *)elfu_mScnName(a1, j);
fprintf(
stdout,
" * %-17s @ %8x offset %8x size %8x\n",
v6,
(unsigned int)v5,
(unsigned int)v4,
(unsigned int)v3);
}
fputc(10, stdout);
fwrite("Sections:\n", 1uLL, 0xAuLL, stdout);
fwrite(
" # Name sh_type sh_addr sh_offset sh_size ES Fl Al sh_link sh_info \n",
1uLL,
0x73uLL,
stdout);
fwrite(
" | | | | | | | | | | \n",
1uLL,
0x73uLL,
stdout);
elfu_mScnForall(a1, subScnDump, v8, 0LL);
return fputc(10, stdout);
}

original_code:
void elfu_mDumpElf(ElfuElf *me)
{
  ElfuPhdr *mp;
  ElfuScn *ms;
  size_t i;
  ((void) sizeof ((me) ? 1 : 0), __extension__ ({ if (me) ; else __assert_fail ("me", "src/libelfu/modelops/dump.c", 221, __extension__ __PRETTY_FUNCTION__); }));
  elfu_mDumpEhdr(me);
  do { fprintf(stdout, "\n"); } while(0);
  do { fprintf(stdout, "Segments:\n"); } while(0);
  do { fprintf(stdout, "     #        (type)   p_type p_offset  p_vaddr  p_paddr p_filesz  p_memsz  p_flags  p_align\n"); } while(0);
  do { fprintf(stdout, "       |            |        |        |        |        |        |        |        |        \n"); } while(0);
  i = 0;
  for ((mp) = ((&me->phdrList)->cqh_first); (mp) != (const void *)(&me->phdrList); (mp) = ((mp)->elem.cqe_next)) {
    printf(" [%4d] ", i);
    elfu_mDumpPhdr(me, mp);
    i++;
  }
  do { fprintf(stdout, "\n"); } while(0);
  do { fprintf(stdout, "Orphaned sections:\n"); } while(0);
  for ((ms) = ((&me->orphanScnList)->cqh_first); (ms) != (const void *)(&me->orphanScnList); (ms) = ((ms)->elemChildScn.cqe_next)) {
    do { fprintf(stdout, "        * %-17s @ %8x  offset %8x  size %8x\n", elfu_mScnName(me, ms), (unsigned)ms->shdr.sh_addr, (unsigned)ms->shdr.sh_offset, (unsigned)ms->shdr.sh_size); } while(0);
  }
  do { fprintf(stdout, "\n"); } while(0);
  do { fprintf(stdout, "Sections:\n"); } while(0);
  do { fprintf(stdout, "     #  Name              sh_type          sh_addr sh_offset  sh_size ES Fl Al sh_link           sh_info          \n"); } while(0);
  do { fprintf(stdout, "       |                 |               |        |         |        |  |  |  |                 |                 \n"); } while(0);
  elfu_mScnForall(me, subScnDump, &i, ((void *)0));
  do { fprintf(stdout, "\n"); } while(0);
}

canonical_original_code:
void elfu_mDumpElf(struct ElfuElf *me)
{
  struct ElfuPhdr *mp;
  struct ElfuScn *ms;
  unsigned long i;
  ((void) sizeof ((me) ? 1 : 0), __extension__ ({ if (me) ; else __assert_fail ("me", "src/libelfu/modelops/dump.c", 221, __extension__ __PRETTY_FUNCTION__); }));
  elfu_mDumpEhdr(me);
  do { fprintf(stdout, "\n"); } while(0);
  do { fprintf(stdout, "Segments:\n"); } while(0);
  do { fprintf(stdout, "     #        (type)   p_type p_offset  p_vaddr  p_paddr p_filesz  p_memsz  p_flags  p_align\n"); } while(0);
  do { fprintf(stdout, "       |            |        |        |        |        |        |        |        |        \n"); } while(0);
  i = 0;
  for ((mp) = ((&me->phdrList)->cqh_first); (mp) != (void *)(&me->phdrList); (mp) = ((mp)->elem.cqe_next)) {
    printf(" [%4d] ", i);
    elfu_mDumpPhdr(me, mp);
    i++;
  }
  do { fprintf(stdout, "\n"); } while(0);
  do { fprintf(stdout, "Orphaned sections:\n"); } while(0);
  for ((ms) = ((&me->orphanScnList)->cqh_first); (ms) != (void *)(&me->orphanScnList); (ms) = ((ms)->elemChildScn.cqe_next)) {
    do { fprintf(stdout, "        * %-17s @ %8x  offset %8x  size %8x\n", elfu_mScnName(me, ms), (unsigned int)ms->shdr.sh_addr, (unsigned int)ms->shdr.sh_offset, (unsigned int)ms->shdr.sh_size); } while(0);
  }
  do { fprintf(stdout, "\n"); } while(0);
  do { fprintf(stdout, "Sections:\n"); } while(0);
  do { fprintf(stdout, "     #  Name              sh_type          sh_addr sh_offset  sh_size ES Fl Al sh_link           sh_info          \n"); } while(0);
  do { fprintf(stdout, "       |                 |               |        |         |        |  |  |  |                 |                 \n"); } while(0);
  elfu_mScnForall(me, subScnDump, &i, ((void *)0));
  do { fprintf(stdout, "\n"); } while(0);
}


cmpPhdrType

decompiled_code:
__int64 __fastcall cmpPhdrType(const void *a1, const void *a2)
{
int v2; // edx
__int64 result; // rax
int v4; // ecx
unsigned __int64 v5; // rcx
unsigned __int64 v6; // rdx

v2 = *(_DWORD *)a1;
result = 0xFFFFFFFFLL;
if ( *(_DWORD *)a1 != 6 )
{
v4 = *(_DWORD *)a2;
result = 1LL;
if ( *(_DWORD *)a2 != 6 )
{
result = 0xFFFFFFFFLL;
if ( v2 != 3 )
{
if ( v2 == 1685382482 || v4 == 3 )
{
result = 1LL;
}
else if ( v4 != 1685382482 )
{
result = 1LL;
if ( v2 != 1685382481 )
{
result = 0xFFFFFFFFLL;
if ( v4 != 1685382481 )
{
result = 1LL;
if ( v2 != 1685382480 )
{
result = 0xFFFFFFFFLL;
if ( v4 != 1685382480 )
{
result = 1LL;
if ( v2 != 4 )
{
result = 0xFFFFFFFFLL;
if ( v4 != 4 )
{
result = 1LL;
if ( v2 != 2 )
{
result = 0xFFFFFFFFLL;
if ( v4 != 2 )
{
v5 = *((_QWORD *)a1 + 2);
v6 = *((_QWORD *)a2 + 2);
if ( v5 >= v6 )
result = v5 > v6;
}
}
}
}
}
}
}
}
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(const void *a1, const void *a2)
{
int v2; // edx
__int64 result; // rax
int v4; // ecx
unsigned __int64 v5; // rcx
unsigned __int64 v6; // rdx

v2 = *(_DWORD *)a1;
result = 0xFFFFFFFFLL;
if ( *(_DWORD *)a1 != 6 )
{
v4 = *(_DWORD *)a2;
result = 1LL;
if ( *(_DWORD *)a2 != 6 )
{
result = 0xFFFFFFFFLL;
if ( v2 != 3 )
{
if ( v2 == 1685382482 || v4 == 3 )
{
result = 1LL;
}
else if ( v4 != 1685382482 )
{
result = 1LL;
if ( v2 != 1685382481 )
{
result = 0xFFFFFFFFLL;
if ( v4 != 1685382481 )
{
result = 1LL;
if ( v2 != 1685382480 )
{
result = 0xFFFFFFFFLL;
if ( v4 != 1685382480 )
{
result = 1LL;
if ( v2 != 4 )
{
result = 0xFFFFFFFFLL;
if ( v4 != 4 )
{
result = 1LL;
if ( v2 != 2 )
{
result = 0xFFFFFFFFLL;
if ( v4 != 2 )
{
v5 = *((_QWORD *)a1 + 2);
v6 = *((_QWORD *)a2 + 2);
if ( v5 >= v6 )
result = v5 > v6;
}
}
}
}
}
}
}
}
}
}
}
}
return result;
}

original_code:
static int cmpPhdrType(const void *v1, const void *v2)
{
  const GElf_Phdr *p1 = (const GElf_Phdr*)v1;
  const GElf_Phdr *p2 = (const GElf_Phdr*)v2;
  if (p1->p_type == 6) {
    return -1;
  } else if (p2->p_type == 6) {
    return 1;
  } else if (p1->p_type == 3) {
    return -1;
  } else if (p2->p_type == 3) {
    return 1;
  }
  if (p1->p_type == 0x6474e552) {
    return 1;
  } else if (p2->p_type == 0x6474e552) {
    return -1;
  } else if (p1->p_type == 0x6474e551) {
    return 1;
  } else if (p2->p_type == 0x6474e551) {
    return -1;
  } else if (p1->p_type == 0x6474e550) {
    return 1;
  } else if (p2->p_type == 0x6474e550) {
    return -1;
  } else if (p1->p_type == 4) {
    return 1;
  } else if (p2->p_type == 4) {
    return -1;
  } else if (p1->p_type == 2) {
    return 1;
  } else if (p2->p_type == 2) {
    return -1;
  }
  if (p1->p_vaddr < p2->p_vaddr) {
    return -1;
  } else if (p1->p_vaddr > p2->p_vaddr) {
    return 1;
  }
  return 0;
}

canonical_original_code:
static int cmpPhdrType(void *v1, void *v2)
{
  struct Elf64_Phdr *p1 = (const GElf_Phdr*)v1;
  struct Elf64_Phdr *p2 = (const GElf_Phdr*)v2;
  if (p1->p_type == 6) {
    return -1;
  } else if (p2->p_type == 6) {
    return 1;
  } else if (p1->p_type == 3) {
    return -1;
  } else if (p2->p_type == 3) {
    return 1;
  }
  if (p1->p_type == 0x6474e552) {
    return 1;
  } else if (p2->p_type == 0x6474e552) {
    return -1;
  } else if (p1->p_type == 0x6474e551) {
    return 1;
  } else if (p2->p_type == 0x6474e551) {
    return -1;
  } else if (p1->p_type == 0x6474e550) {
    return 1;
  } else if (p2->p_type == 0x6474e550) {
    return -1;
  } else if (p1->p_type == 4) {
    return 1;
  } else if (p2->p_type == 4) {
    return -1;
  } else if (p1->p_type == 2) {
    return 1;
  } else if (p2->p_type == 2) {
    return -1;
  }
  if (p1->p_vaddr < p2->p_vaddr) {
    return -1;
  } else if (p1->p_vaddr > p2->p_vaddr) {
    return 1;
  }
  return 0;
}

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


original_code:
void* elfu_mPhdrForall(ElfuElf *me, PhdrHandlerFunc f, void *aux1, void *aux2)
{
  ElfuPhdr *mp;
  for ((mp) = ((&me->phdrList)->cqh_first); (mp) != (const void *)(&me->phdrList); (mp) = ((mp)->elem.cqe_next)) {
    ElfuPhdr *mp2;
    void *rv = f(me, mp, aux1, aux2);
    if (rv) {
      return rv;
    }
    for ((mp2) = ((&mp->childPhdrList)->cqh_first); (mp2) != (const void *)(&mp->childPhdrList); (mp2) = ((mp2)->elemChildPhdr.cqe_next)) {
      void *rv = f(me, mp2, aux1, aux2);
      if (rv) {
        return rv;
      }
    }
  }
  return ((void *)0);
}

canonical_original_code:
void *elfu_mPhdrForall(struct ElfuElf *me, void *f(struct ElfuElf *me, struct ElfuPhdr *mp, void *aux1, void *aux2), void *aux1, void *aux2)
{
  struct ElfuPhdr *mp;
  for ((mp) = ((&me->phdrList)->cqh_first); (mp) != (void *)(&me->phdrList); (mp) = ((mp)->elem.cqe_next)) {
    struct ElfuPhdr *mp2;
    void *rv = f(me, mp, aux1, aux2);
    if (rv) {
      return rv;
    }
    for ((mp2) = ((&mp->childPhdrList)->cqh_first); (mp2) != (void *)(&mp->childPhdrList); (mp2) = ((mp2)->elemChildPhdr.cqe_next)) {
      void *rv = f(me, mp2, aux1, aux2);
      if (rv) {
        return rv;
      }
    }
  }
  return ((void *)0);
}

variable_types: void *(struct ElfuElf *me, struct ElfuPhdr *mp, void *aux1, void *aux2)

variable_types:
rv
void *


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

v2 = 0LL;
if ( !a1 )
_assert_fail("me", "src/libelfu/model/phdr.c", 0x42u, "elfu_mPhdrCount");
elfu_mPhdrForall(a1, (__int64 (__fastcall *)(__int64, __int64, __int64, __int64))subCounter, (__int64)&v2, 0LL);
return v2;
}

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

v2 = 0LL;
if ( !a1 )
_assert_fail("me", "src/libelfu/model/phdr.c", 0x42u, "elfu_mPhdrCount");
func3(a1, (__int64 (__fastcall *)(__int64, __int64, __int64, __int64))subCounter, (__int64)&v2, 0LL);
return v2;
}

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

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

variable_types:
i
unsigned long

return_type: unsigned long


decompiled_code:
__int64 __fastcall elfu_mPhdrByAddr(__int64 a1, __int64 a2)
{
__int64 v3; // [rsp+8h] [rbp-10h] BYREF

v3 = a2;
return elfu_mPhdrForall(
a1,
(__int64 (__fastcall *)(__int64, __int64, __int64, __int64))subFindLoadByAddr,
(__int64)&v3,
0LL);
}

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

v3 = a2;
return func3(
a1,
(__int64 (__fastcall *)(__int64, __int64, __int64, __int64))subFindLoadByAddr,
(__int64)&v3,
0LL);
}

original_code:
ElfuPhdr* elfu_mPhdrByAddr(ElfuElf *me, GElf_Addr addr)
{
  return elfu_mPhdrForall(me, subFindLoadByAddr, &addr, ((void *)0));
}

canonical_original_code:
struct ElfuPhdr *elfu_mPhdrByAddr(struct ElfuElf *me, unsigned long addr)
{
  return elfu_mPhdrForall(me, subFindLoadByAddr, &addr, ((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 *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:
addr
unsigned long

return_type: 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; } *


decompiled_code:
__int64 __fastcall elfu_mPhdrByOffset(__int64 a1, __int64 a2)
{
__int64 v3; // [rsp+8h] [rbp-10h] BYREF

v3 = a2;
return elfu_mPhdrForall(
a1,
(__int64 (__fastcall *)(__int64, __int64, __int64, __int64))subFindLoadByOffset,
(__int64)&v3,
0LL);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2)
{
__int64 v3; // [rsp+8h] [rbp-10h] BYREF

v3 = a2;
return func3(
a1,
(__int64 (__fastcall *)(__int64, __int64, __int64, __int64))subFindLoadByOffset,
(__int64)&v3,
0LL);
}

original_code:
ElfuPhdr* elfu_mPhdrByOffset(ElfuElf *me, GElf_Off offset)
{
  return elfu_mPhdrForall(me, subFindLoadByOffset, &offset, ((void *)0));
}

canonical_original_code:
struct ElfuPhdr *elfu_mPhdrByOffset(struct ElfuElf *me, unsigned long offset)
{
  return elfu_mPhdrForall(me, subFindLoadByOffset, &offset, ((void *)0));
}

variable_types:
offset
unsigned long


decompiled_code:
_QWORD *elfu_mPhdrAlloc()
{
_QWORD *v0; // rbx

v0 = malloc(0x78uLL);
if ( v0 )
{
memset(v0, 0, 0x78uLL);
v0[7] = v0 + 7;
v0[8] = v0 + 7;
v0[9] = v0 + 9;
v0[10] = v0 + 9;
}
else
{
fwrite("mPhdrAlloc: malloc() failed for ElfuPhdr.\n", 1uLL, 0x2AuLL, stderr);
}
return v0;
}

canonical_decompiled_code:
_QWORD *func9()
{
_QWORD *v0; // rbx

v0 = malloc(0x78uLL);
if ( v0 )
{
memset(v0, 0, 0x78uLL);
v0[7] = v0 + 7;
v0[8] = v0 + 7;
v0[9] = v0 + 9;
v0[10] = v0 + 9;
}
else
{
fwrite("mPhdrAlloc: malloc() failed for ElfuPhdr.\n", 1uLL, 0x2AuLL, stderr);
}
return v0;
}

original_code:
ElfuPhdr* elfu_mPhdrAlloc()
{
  ElfuPhdr *mp;
  mp = malloc(sizeof(ElfuPhdr));
  if (!mp) {
    do { fprintf(stderr, "mPhdrAlloc: malloc() failed for ElfuPhdr.\n"); } while(0);
    return ((void *)0);
  }
  memset(mp, 0, sizeof(*mp));
  do { (&mp->childScnList)->cqh_first = (void *)(&mp->childScnList); (&mp->childScnList)->cqh_last = (void *)(&mp->childScnList); } while ( 0);
  do { (&mp->childPhdrList)->cqh_first = (void *)(&mp->childPhdrList); (&mp->childPhdrList)->cqh_last = (void *)(&mp->childPhdrList); } while ( 0);
  return mp;
}

canonical_original_code:
struct ElfuPhdr *elfu_mPhdrAlloc()
{
  struct ElfuPhdr *mp;
  mp = malloc(sizeof(ElfuPhdr));
  if (!mp) {
    do { fprintf(stderr, "mPhdrAlloc: malloc() failed for ElfuPhdr.\n"); } while(0);
    return ((void *)0);
  }
  memset(mp, 0, sizeof(*mp));
  do { (&mp->childScnList)->cqh_first = (void *)(&mp->childScnList); (&mp->childScnList)->cqh_last = (void *)(&mp->childScnList); } while ( 0);
  do { (&mp->childPhdrList)->cqh_first = (void *)(&mp->childPhdrList); (&mp->childPhdrList)->cqh_last = (void *)(&mp->childPhdrList); } while ( 0);
  return mp;
}


original_code:
void elfu_mPhdrDestroy(ElfuPhdr* mp)
{
  ((void) sizeof ((mp) ? 1 : 0), __extension__ ({ if (mp) ; else __assert_fail ("mp", "src/libelfu/model/phdr.c", 212, __extension__ __PRETTY_FUNCTION__); }));
  if (!((&mp->childPhdrList)->cqh_first == (void *)(&mp->childPhdrList))) {
    ElfuPhdr *nextmp;
    nextmp = ((&mp->childPhdrList)->cqh_first);
    while ((void*)nextmp != (void*)&mp->childPhdrList) {
      ElfuPhdr *curmp = nextmp;
      nextmp = ((curmp)->elemChildPhdr.cqe_next);
      do { if ((curmp)->elemChildPhdr.cqe_next == (void *)(&mp->childPhdrList)) (&mp->childPhdrList)->cqh_last = (curmp)->elemChildPhdr.cqe_prev; else (curmp)->elemChildPhdr.cqe_next->elemChildPhdr.cqe_prev = (curmp)->elemChildPhdr.cqe_prev; if ((curmp)->elemChildPhdr.cqe_prev == (void *)(&mp->childPhdrList)) (&mp->childPhdrList)->cqh_first = (curmp)->elemChildPhdr.cqe_next; else (curmp)->elemChildPhdr.cqe_prev->elemChildPhdr.cqe_next = (curmp)->elemChildPhdr.cqe_next; } while ( 0);
      elfu_mPhdrDestroy(curmp);
    }
  }
  if (!((&mp->childScnList)->cqh_first == (void *)(&mp->childScnList))) {
    ElfuScn *nextms;
    nextms = ((&mp->childScnList)->cqh_first);
    while ((void*)nextms != (void*)&mp->childScnList) {
      ElfuScn *curms = nextms;
      nextms = ((curms)->elemChildScn.cqe_next);
      do { if ((curms)->elemChildScn.cqe_next == (void *)(&mp->childScnList)) (&mp->childScnList)->cqh_last = (curms)->elemChildScn.cqe_prev; else (curms)->elemChildScn.cqe_next->elemChildScn.cqe_prev = (curms)->elemChildScn.cqe_prev; if ((curms)->elemChildScn.cqe_prev == (void *)(&mp->childScnList)) (&mp->childScnList)->cqh_first = (curms)->elemChildScn.cqe_next; else (curms)->elemChildScn.cqe_prev->elemChildScn.cqe_next = (curms)->elemChildScn.cqe_next; } while ( 0);
      elfu_mScnDestroy(curms);
    }
  }
  free(mp);
}

canonical_original_code:
void elfu_mPhdrDestroy(struct ElfuPhdr *mp)
{
  ((void) sizeof ((mp) ? 1 : 0), __extension__ ({ if (mp) ; else __assert_fail ("mp", "src/libelfu/model/phdr.c", 212, __extension__ __PRETTY_FUNCTION__); }));
  if (!((&mp->childPhdrList)->cqh_first == (void *)(&mp->childPhdrList))) {
    struct ElfuPhdr *nextmp;
    nextmp = ((&mp->childPhdrList)->cqh_first);
    while ((void *)nextmp != (void *)&mp->childPhdrList) {
      struct ElfuPhdr *curmp = nextmp;
      nextmp = ((curmp)->elemChildPhdr.cqe_next);
      do { if ((curmp)->elemChildPhdr.cqe_next == (void *)(&mp->childPhdrList)) (&mp->childPhdrList)->cqh_last = (curmp)->elemChildPhdr.cqe_prev; else (curmp)->elemChildPhdr.cqe_next->elemChildPhdr.cqe_prev = (curmp)->elemChildPhdr.cqe_prev; if ((curmp)->elemChildPhdr.cqe_prev == (void *)(&mp->childPhdrList)) (&mp->childPhdrList)->cqh_first = (curmp)->elemChildPhdr.cqe_next; else (curmp)->elemChildPhdr.cqe_prev->elemChildPhdr.cqe_next = (curmp)->elemChildPhdr.cqe_next; } while ( 0);
      elfu_mPhdrDestroy(curmp);
    }
  }
  if (!((&mp->childScnList)->cqh_first == (void *)(&mp->childScnList))) {
    struct ElfuScn *nextms;
    nextms = ((&mp->childScnList)->cqh_first);
    while ((void *)nextms != (void *)&mp->childScnList) {
      struct ElfuScn *curms = nextms;
      nextms = ((curms)->elemChildScn.cqe_next);
      do { if ((curms)->elemChildScn.cqe_next == (void *)(&mp->childScnList)) (&mp->childScnList)->cqh_last = (curms)->elemChildScn.cqe_prev; else (curms)->elemChildScn.cqe_next->elemChildScn.cqe_prev = (curms)->elemChildScn.cqe_prev; if ((curms)->elemChildScn.cqe_prev == (void *)(&mp->childScnList)) (&mp->childScnList)->cqh_first = (curms)->elemChildScn.cqe_next; else (curms)->elemChildScn.cqe_prev->elemChildScn.cqe_next = (curms)->elemChildScn.cqe_next; } while ( 0);
      elfu_mScnDestroy(curms);
    }
  }
  free(mp);
}

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


subCounter

decompiled_code:
__int64 __fastcall subCounter(__int64 a1, __int64 a2, _QWORD *a3)
{
++*a3;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, _QWORD *a3)
{
++*a3;
return 0LL;
}

original_code:
static void* subCounter(ElfuElf *me, ElfuPhdr *mp, void *aux1, void *aux2)
{
  size_t *i = (size_t*)aux1;
  (void)aux2;
  *i += 1;
  return ((void *)0);
}

canonical_original_code:
static void *subCounter(struct ElfuElf *me, struct ElfuPhdr *mp, void *aux1, void *aux2)
{
  unsigned long *i = (size_t*)aux1;
  (void)aux2;
  *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; } *


decompiled_code:
_QWORD *elfu_mElfAlloc()
{
_QWORD *v0; // rbx

v0 = malloc(0x78uLL);
if ( v0 )
{
memset(v0, 0, 0x78uLL);
v0[9] = v0 + 9;
v0[10] = v0 + 9;
v0[11] = v0 + 11;
v0[12] = v0 + 11;
}
else
{
fwrite("mElfAlloc: malloc() failed for ElfuElf.\n", 1uLL, 0x28uLL, stderr);
}
return v0;
}

canonical_decompiled_code:
_QWORD *func0()
{
_QWORD *v0; // rbx

v0 = malloc(0x78uLL);
if ( v0 )
{
memset(v0, 0, 0x78uLL);
v0[9] = v0 + 9;
v0[10] = v0 + 9;
v0[11] = v0 + 11;
v0[12] = v0 + 11;
}
else
{
fwrite("mElfAlloc: malloc() failed for ElfuElf.\n", 1uLL, 0x28uLL, stderr);
}
return v0;
}

original_code:
ElfuElf* elfu_mElfAlloc()
{
  ElfuElf *me;
  me = malloc(sizeof(ElfuElf));
  if (!me) {
    do { fprintf(stderr, "mElfAlloc: malloc() failed for ElfuElf.\n"); } while(0);
    return ((void *)0);
  }
  memset(me, 0, sizeof(*me));
  do { (&me->phdrList)->cqh_first = (void *)(&me->phdrList); (&me->phdrList)->cqh_last = (void *)(&me->phdrList); } while ( 0);
  do { (&me->orphanScnList)->cqh_first = (void *)(&me->orphanScnList); (&me->orphanScnList)->cqh_last = (void *)(&me->orphanScnList); } while ( 0);
  return me;
}

canonical_original_code:
struct ElfuElf *elfu_mElfAlloc()
{
  struct ElfuElf *me;
  me = malloc(sizeof(ElfuElf));
  if (!me) {
    do { fprintf(stderr, "mElfAlloc: malloc() failed for ElfuElf.\n"); } while(0);
    return ((void *)0);
  }
  memset(me, 0, sizeof(*me));
  do { (&me->phdrList)->cqh_first = (void *)(&me->phdrList); (&me->phdrList)->cqh_last = (void *)(&me->phdrList); } while ( 0);
  do { (&me->orphanScnList)->cqh_first = (void *)(&me->orphanScnList); (&me->orphanScnList)->cqh_last = (void *)(&me->orphanScnList); } while ( 0);
  return me;
}

return_type: 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; } *


original_code:
void elfu_mElfDestroy(ElfuElf* me)
{
  ((void) sizeof ((me) ? 1 : 0), __extension__ ({ if (me) ; else __assert_fail ("me", "src/libelfu/model/elf.c", 47, __extension__ __PRETTY_FUNCTION__); }));
  if (!((&me->phdrList)->cqh_first == (void *)(&me->phdrList))) {
    ElfuPhdr *nextmp;
    nextmp = ((&me->phdrList)->cqh_first);
    while ((void*)nextmp != (void*)&me->phdrList) {
      ElfuPhdr *curmp = nextmp;
      nextmp = ((curmp)->elem.cqe_next);
      do { if ((curmp)->elem.cqe_next == (void *)(&me->phdrList)) (&me->phdrList)->cqh_last = (curmp)->elem.cqe_prev; else (curmp)->elem.cqe_next->elem.cqe_prev = (curmp)->elem.cqe_prev; if ((curmp)->elem.cqe_prev == (void *)(&me->phdrList)) (&me->phdrList)->cqh_first = (curmp)->elem.cqe_next; else (curmp)->elem.cqe_prev->elem.cqe_next = (curmp)->elem.cqe_next; } while ( 0);
      elfu_mPhdrDestroy(curmp);
    }
  }
  if (!((&me->orphanScnList)->cqh_first == (void *)(&me->orphanScnList))) {
    ElfuScn *nextms;
    nextms = ((&me->orphanScnList)->cqh_first);
    while ((void*)nextms != (void*)&me->orphanScnList) {
      ElfuScn *curms = nextms;
      nextms = ((curms)->elemChildScn.cqe_next);
      do { if ((curms)->elemChildScn.cqe_next == (void *)(&me->orphanScnList)) (&me->orphanScnList)->cqh_last = (curms)->elemChildScn.cqe_prev; else (curms)->elemChildScn.cqe_next->elemChildScn.cqe_prev = (curms)->elemChildScn.cqe_prev; if ((curms)->elemChildScn.cqe_prev == (void *)(&me->orphanScnList)) (&me->orphanScnList)->cqh_first = (curms)->elemChildScn.cqe_next; else (curms)->elemChildScn.cqe_prev->elemChildScn.cqe_next = (curms)->elemChildScn.cqe_next; } while ( 0);
      elfu_mScnDestroy(curms);
    }
  }
  free(me);
}

canonical_original_code:
void elfu_mElfDestroy(struct ElfuElf *me)
{
  ((void) sizeof ((me) ? 1 : 0), __extension__ ({ if (me) ; else __assert_fail ("me", "src/libelfu/model/elf.c", 47, __extension__ __PRETTY_FUNCTION__); }));
  if (!((&me->phdrList)->cqh_first == (void *)(&me->phdrList))) {
    struct ElfuPhdr *nextmp;
    nextmp = ((&me->phdrList)->cqh_first);
    while ((void *)nextmp != (void *)&me->phdrList) {
      struct ElfuPhdr *curmp = nextmp;
      nextmp = ((curmp)->elem.cqe_next);
      do { if ((curmp)->elem.cqe_next == (void *)(&me->phdrList)) (&me->phdrList)->cqh_last = (curmp)->elem.cqe_prev; else (curmp)->elem.cqe_next->elem.cqe_prev = (curmp)->elem.cqe_prev; if ((curmp)->elem.cqe_prev == (void *)(&me->phdrList)) (&me->phdrList)->cqh_first = (curmp)->elem.cqe_next; else (curmp)->elem.cqe_prev->elem.cqe_next = (curmp)->elem.cqe_next; } while ( 0);
      elfu_mPhdrDestroy(curmp);
    }
  }
  if (!((&me->orphanScnList)->cqh_first == (void *)(&me->orphanScnList))) {
    struct ElfuScn *nextms;
    nextms = ((&me->orphanScnList)->cqh_first);
    while ((void *)nextms != (void *)&me->orphanScnList) {
      struct ElfuScn *curms = nextms;
      nextms = ((curms)->elemChildScn.cqe_next);
      do { if ((curms)->elemChildScn.cqe_next == (void *)(&me->orphanScnList)) (&me->orphanScnList)->cqh_last = (curms)->elemChildScn.cqe_prev; else (curms)->elemChildScn.cqe_next->elemChildScn.cqe_prev = (curms)->elemChildScn.cqe_prev; if ((curms)->elemChildScn.cqe_prev == (void *)(&me->orphanScnList)) (&me->orphanScnList)->cqh_first = (curms)->elemChildScn.cqe_next; else (curms)->elemChildScn.cqe_prev->elemChildScn.cqe_next = (curms)->elemChildScn.cqe_next; } while ( 0);
      elfu_mScnDestroy(curms);
    }
  }
  free(me);
}


decompiled_code:
__int64 __fastcall subScnAdd2(__int64 a1, __int64 a2, __int64 a3)
{
unsigned int v3; // ebx
__int64 result; // rax
__int64 v6; // rax
const char *v7; // rax

v3 = *(_DWORD *)(a2 + 4);
if ( v3 == 8 )
return 0LL;
if ( v3 > 8 )
{
if ( v3 == 9 )
goto LABEL_5;
LABEL_8:
v7 = (const char *)elfu_mScnName(a1, a2);
fprintf(stderr, "mReladd: Skipping section %s (type %d).\n", v7, v3);
return 0LL;
}
result = 0LL;
if ( v3 <= 3 )
return result;
if ( v3 != 4 )
goto LABEL_8;
LABEL_5:
v6 = elfu_mScnByOldscn(a3, *(_QWORD *)(a2 + 80));
return -(__int64)((unsigned int)elfu_mRelocate(a3, v6, a2) != 0);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3)
{
unsigned int v3; // ebx
__int64 result; // rax
__int64 v6; // rax
const char *v7; // rax

v3 = *(_DWORD *)(a2 + 4);
if ( v3 == 8 )
return 0LL;
if ( v3 > 8 )
{
if ( v3 == 9 )
goto LABEL_5;
LABEL_8:
v7 = (const char *)elfu_mScnName(a1, a2);
fprintf(stderr, "mReladd: Skipping section %s (type %d).\n", v7, v3);
return 0LL;
}
result = 0LL;
if ( v3 <= 3 )
return result;
if ( v3 != 4 )
goto LABEL_8;
LABEL_5:
v6 = elfu_mScnByOldscn(a3, *(_QWORD *)(a2 + 80));
return -(__int64)((unsigned int)elfu_mRelocate(a3, v6, a2) != 0);
}

original_code:
static void* subScnAdd2(ElfuElf *mrel, ElfuScn *ms, void *aux1, void *aux2)
{
  ElfuElf *me = (ElfuElf*)aux1;
  (void)aux2;
  switch(ms->shdr.sh_type) {
    case 0:
    case 1:
    case 2:
    case 3:
    case 8:
      break;
    case 4:
    case 9:
      if (elfu_mRelocate(me, elfu_mScnByOldscn(me, ms->infoptr), ms)) {
        return (void*)-1;
      }
      break;
    case 7:
    case 5:
    case 6:
    case 10:
    case 11:
    case 14:
    case 15:
    case 16:
    case 17:
    case 18:
    case 19:
    default:
      do { fprintf(stderr, "mReladd: Skipping section %s (type %d).\n", elfu_mScnName(mrel, ms), ms->shdr.sh_type); } while(0);
  }
  return ((void *)0);
}

canonical_original_code:
static void *subScnAdd2(struct ElfuElf *mrel, struct ElfuScn *ms, void *aux1, void *aux2)
{
  struct ElfuElf *me = (ElfuElf*)aux1;
  (void)aux2;
  switch(ms->shdr.sh_type) {
    case 0:
    case 1:
    case 2:
    case 3:
    case 8:
      break;
    case 4:
    case 9:
      if (elfu_mRelocate(me, elfu_mScnByOldscn(me, ms->infoptr), ms)) {
        return (void *)-1;
      }
      break;
    case 7:
    case 5:
    case 6:
    case 10:
    case 11:
    case 14:
    case 15:
    case 16:
    case 17:
    case 18:
    case 19:
    default:
      do { fprintf(stderr, "mReladd: Skipping section %s (type %d).\n", elfu_mScnName(mrel, ms), ms->shdr.sh_type); } while(0);
  }
  return ((void *)0);
}

variable_types:
ms
struct ElfuScn *


decompiled_code:
__int64 __fastcall subScnAdd1(__int64 a1, const __m128i *a2, __int64 a3)
{
__int32 v3; // eax
unsigned __int32 v5; // er12
const char *v6; // rax

v3 = a2->m128i_i32[1];
if ( (v3 == 1 || v3 == 8) && a2[2].m128i_i64[0] && !insertSection(a3, a1, a2) )
{
v5 = a2->m128i_u32[1];
v6 = (const char *)elfu_mScnName(a1, a2);
fprintf(stderr, "mReladd: Could not insert section %s (type %d), skipping.\n", v6, v5);
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, const __m128i *a2, __int64 a3)
{
__int32 v3; // eax
unsigned __int32 v5; // er12
const char *v6; // rax

v3 = a2->m128i_i32[1];
if ( (v3 == 1 || v3 == 8) && a2[2].m128i_i64[0] && !insertSection(a3, a1, a2) )
{
v5 = a2->m128i_u32[1];
v6 = (const char *)elfu_mScnName(a1, a2);
fprintf(stderr, "mReladd: Could not insert section %s (type %d), skipping.\n", v6, v5);
}
return 0LL;
}

original_code:
static void* subScnAdd1(ElfuElf *mrel, ElfuScn *ms, void *aux1, void *aux2)
{
  ElfuScn *newscn;
  ElfuElf *me = (ElfuElf*)aux1;
  (void)aux2;
  switch(ms->shdr.sh_type) {
    case 1:
    case 8:
      if (ms->shdr.sh_size == 0) {
        break;
      }
      newscn = insertSection(me, mrel, ms);
      if (!newscn) {
        do { fprintf(stderr, "mReladd: Could not insert section %s (type %d), skipping.\n", elfu_mScnName(mrel, ms), ms->shdr.sh_type); } while(0);
      }
      break;
  }
  return ((void *)0);
}

canonical_original_code:
static void *subScnAdd1(struct ElfuElf *mrel, struct ElfuScn *ms, void *aux1, void *aux2)
{
  struct ElfuScn *newscn;
  struct ElfuElf *me = (ElfuElf*)aux1;
  (void)aux2;
  switch(ms->shdr.sh_type) {
    case 1:
    case 8:
      if (ms->shdr.sh_size == 0) {
        break;
      }
      newscn = insertSection(me, mrel, ms);
      if (!newscn) {
        do { fprintf(stderr, "mReladd: Could not insert section %s (type %d), skipping.\n", elfu_mScnName(mrel, ms), ms->shdr.sh_type); } while(0);
      }
      break;
  }
  return ((void *)0);
}