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

if ( !a1 )
return 0xFFFFFFFFLL;
if ( *(_DWORD *)(a1 + 16) == 3 )
{
if ( *(_QWORD *)(a1 + 160) || (unsigned int)elf_cook() )
{
result = 0LL;
if ( a2 )
{
*a2 = *(_QWORD *)(a1 + 176);
result = 0LL;
}
}
else
{
result = 0xFFFFFFFFLL;
}
}
else
{
elf_errno = 13;
result = 0xFFFFFFFFLL;
}
return result;
}

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

if ( !a1 )
return 0xFFFFFFFFLL;
if ( *(_DWORD *)(a1 + 16) == 3 )
{
if ( *(_QWORD *)(a1 + 160) || (unsigned int)elf_cook() )
{
result = 0LL;
if ( a2 )
{
*a2 = *(_QWORD *)(a1 + 176);
result = 0LL;
}
}
else
{
result = 0xFFFFFFFFLL;
}
}
else
{
elf_errno = 13;
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int
elf_getphdrnum(Elf *elf, size_t *resultp) {
    if (!elf) {
 return -1;
    }
    do{}while(0);
    if (elf->e_kind != ELF_K_ELF) {
 (_elf_errno = (ERROR_NOTELF));
 return -1;
    }
    if (!elf->e_ehdr && !_elf_cook(elf)) {
 return -1;
    }
    if (resultp) {
 *resultp = elf->e_phnum;
    }
    return 0;
}

canonical_original_code:
int elf_getphdrnum(struct Elf *elf, unsigned long *resultp) {
    if (!elf) {
 return -1;
    }
    do{}while(0);
    if (elf->e_kind != ELF_K_ELF) {
 (_elf_errno = (ERROR_NOTELF));
 return -1;
    }
    if (!elf->e_ehdr && !_elf_cook(elf)) {
 return -1;
    }
    if (resultp) {
 *resultp = elf->e_phnum;
    }
    return 0;
}

variable_types: struct Elf { unsigned long e_size; unsigned long e_dsize; enum Elf_Kind { ELF_K_NONE=0, ELF_K_AR=1, ELF_K_COFF=2, ELF_K_ELF=3, ELF_K_NUM=4 } e_kind; char *e_data; char *e_rawdata; unsigned long e_idlen; int e_fd; unsigned int e_count; struct Elf *e_parent; unsigned long e_next; unsigned long e_base; struct Elf *e_link; struct Elf_Arhdr { char *ar_name; long ar_date; long ar_uid; long ar_gid; unsigned long ar_mode; long ar_size; char *ar_rawname; } *e_arhdr; unsigned long e_off; struct Elf *e_members; char *e_symtab; unsigned long e_symlen; char *e_strtab; unsigned long e_strlen; unsigned int e_class; unsigned int e_encoding; unsigned int e_version; char *e_ehdr; char *e_phdr; unsigned long e_phnum; struct Elf_Scn { struct Elf_Scn *s_link; struct Elf *s_elf; unsigned long s_index; unsigned int s_scn_flags; unsigned int s_shdr_flags; struct Scn_Data { struct Elf_Data { void *d_buf; enum Elf_Type { ELF_T_BYTE=0, ELF_T_ADDR=1, ELF_T_DYN=2, ELF_T_EHDR=3, ELF_T_HALF=4, ELF_T_OFF=5, ELF_T_PHDR=6, ELF_T_RELA=7, ELF_T_REL=8, ELF_T_SHDR=9, ELF_T_SWORD=10, ELF_T_SYM=11, ELF_T_WORD=12, ELF_T_SXWORD=13, ELF_T_XWORD=14, ELF_T_VDEF=15, ELF_T_VNEED=16, ELF_T_NUM=17 } d_type; unsigned long d_size; long d_off; unsigned long d_align; unsigned int d_version; } sd_data; struct Scn_Data *sd_link; struct Elf_Scn *sd_scn; char *sd_memdata; unsigned int sd_data_flags; unsigned int sd_freeme; unsigned int sd_free_data; long sd_magic; } *s_data_1; struct Scn_Data *s_data_n; struct Scn_Data *s_rawdata; unsigned int s_type; unsigned long s_offset; unsigned long s_size; unsigned int s_freeme; union { 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; } u_shdr64; struct Elf32_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned int sh_flags; unsigned int sh_addr; unsigned int sh_offset; unsigned int sh_size; unsigned int sh_link; unsigned int sh_info; unsigned int sh_addralign; unsigned int sh_entsize; } u_shdr32; } s_uhdr; long s_magic; } *e_scn_1; struct Elf_Scn *e_scn_n; unsigned int e_elf_flags; unsigned int e_ehdr_flags; unsigned int e_phdr_flags; unsigned int e_readable; unsigned int e_writable; unsigned int e_disabled; unsigned int e_cooked; unsigned int e_free_syms; unsigned int e_unmap_data; unsigned int e_memory; long e_magic; } *

variable_types:
resultp
unsigned long *


repo: aodinokov/expos

decompiled_code:
__int64 __fastcall elf_getshdrnum(__int64 a1, __int64 *a2)
{
__int64 v2; // rdx
__int64 v3; // rax
unsigned int v4; // edx

if ( !a1 )
return 0xFFFFFFFFLL;
if ( *(_DWORD *)(a1 + 16) == 3 )
{
if ( *(_QWORD *)(a1 + 160) || (unsigned int)elf_cook() )
{
v2 = *(_QWORD *)(a1 + 192);
v3 = 0LL;
if ( v2 )
v3 = *(_QWORD *)(v2 + 16) + 1LL;
v4 = 0;
if ( a2 )
*a2 = v3;
}
else
{
v4 = -1;
}
}
else
{
elf_errno = 13;
v4 = -1;
}
return v4;
}

original_code:
int
elf_getshdrnum(Elf *elf, size_t *resultp) {
    size_t num = 0;
    Elf_Scn *scn;
    if (!elf) {
 return -1;
    }
    do{}while(0);
    if (elf->e_kind != ELF_K_ELF) {
 (_elf_errno = (ERROR_NOTELF));
 return -1;
    }
    if (!elf->e_ehdr && !_elf_cook(elf)) {
 return -1;
    }
    if ((scn = elf->e_scn_n)) {
 num = scn->s_index + 1;
    }
    if (resultp) {
 *resultp = num;
    }
    return 0;
}

canonical_original_code:
int elf_getshdrnum(struct Elf *elf, unsigned long *resultp) {
    unsigned long num = 0;
    struct Elf_Scn *scn;
    if (!elf) {
 return -1;
    }
    do{}while(0);
    if (elf->e_kind != ELF_K_ELF) {
 (_elf_errno = (ERROR_NOTELF));
 return -1;
    }
    if (!elf->e_ehdr && !_elf_cook(elf)) {
 return -1;
    }
    if ((scn = elf->e_scn_n)) {
 num = scn->s_index + 1;
    }
    if (resultp) {
 *resultp = num;
    }
    return 0;
}

variable_types:
num
unsigned long

variable_types: struct Elf_Scn { struct Elf_Scn *s_link; struct Elf { unsigned long e_size; unsigned long e_dsize; enum Elf_Kind { ELF_K_NONE=0, ELF_K_AR=1, ELF_K_COFF=2, ELF_K_ELF=3, ELF_K_NUM=4 } e_kind; char *e_data; char *e_rawdata; unsigned long e_idlen; int e_fd; unsigned int e_count; struct Elf *e_parent; unsigned long e_next; unsigned long e_base; struct Elf *e_link; struct Elf_Arhdr { char *ar_name; long ar_date; long ar_uid; long ar_gid; unsigned long ar_mode; long ar_size; char *ar_rawname; } *e_arhdr; unsigned long e_off; struct Elf *e_members; char *e_symtab; unsigned long e_symlen; char *e_strtab; unsigned long e_strlen; unsigned int e_class; unsigned int e_encoding; unsigned int e_version; char *e_ehdr; char *e_phdr; unsigned long e_phnum; struct Elf_Scn *e_scn_1; struct Elf_Scn *e_scn_n; unsigned int e_elf_flags; unsigned int e_ehdr_flags; unsigned int e_phdr_flags; unsigned int e_readable; unsigned int e_writable; unsigned int e_disabled; unsigned int e_cooked; unsigned int e_free_syms; unsigned int e_unmap_data; unsigned int e_memory; long e_magic; } *s_elf; unsigned long s_index; unsigned int s_scn_flags; unsigned int s_shdr_flags; struct Scn_Data { struct Elf_Data { void *d_buf; enum Elf_Type { ELF_T_BYTE=0, ELF_T_ADDR=1, ELF_T_DYN=2, ELF_T_EHDR=3, ELF_T_HALF=4, ELF_T_OFF=5, ELF_T_PHDR=6, ELF_T_RELA=7, ELF_T_REL=8, ELF_T_SHDR=9, ELF_T_SWORD=10, ELF_T_SYM=11, ELF_T_WORD=12, ELF_T_SXWORD=13, ELF_T_XWORD=14, ELF_T_VDEF=15, ELF_T_VNEED=16, ELF_T_NUM=17 } d_type; unsigned long d_size; long d_off; unsigned long d_align; unsigned int d_version; } sd_data; struct Scn_Data *sd_link; struct Elf_Scn *sd_scn; char *sd_memdata; unsigned int sd_data_flags; unsigned int sd_freeme; unsigned int sd_free_data; long sd_magic; } *s_data_1; struct Scn_Data *s_data_n; struct Scn_Data *s_rawdata; unsigned int s_type; unsigned long s_offset; unsigned long s_size; unsigned int s_freeme; union { 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; } u_shdr64; struct Elf32_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned int sh_flags; unsigned int sh_addr; unsigned int sh_offset; unsigned int sh_size; unsigned int sh_link; unsigned int sh_info; unsigned int sh_addralign; unsigned int sh_entsize; } u_shdr32; } s_uhdr; long s_magic; } *

return_type: int

user_defined_types: struct Elf { unsigned long e_size; unsigned long e_dsize; enum Elf_Kind e_kind; char *e_data; char *e_rawdata; unsigned long e_idlen; int e_fd; unsigned int e_count; struct Elf *e_parent; unsigned long e_next; unsigned long e_base; struct Elf *e_link; struct Elf_Arhdr *e_arhdr; unsigned long e_off; struct Elf *e_members; char *e_symtab; unsigned long e_symlen; char *e_strtab; unsigned long e_strlen; unsigned int e_class; unsigned int e_encoding; unsigned int e_version; char *e_ehdr; char *e_phdr; unsigned long e_phnum; struct Elf_Scn *e_scn_1; struct Elf_Scn *e_scn_n; unsigned int e_elf_flags; unsigned int e_ehdr_flags; unsigned int e_phdr_flags; unsigned int e_readable; unsigned int e_writable; unsigned int e_disabled; unsigned int e_cooked; unsigned int e_free_syms; unsigned int e_unmap_data; unsigned int e_memory; long e_magic; }

user_defined_types: struct Elf_Scn { struct Elf_Scn *s_link; struct Elf *s_elf; unsigned long s_index; unsigned int s_scn_flags; unsigned int s_shdr_flags; struct Scn_Data *s_data_1; struct Scn_Data *s_data_n; struct Scn_Data *s_rawdata; unsigned int s_type; unsigned long s_offset; unsigned long s_size; unsigned int s_freeme; union { struct Elf64_Shdr u_shdr64; struct Elf32_Shdr u_shdr32; } s_uhdr; long s_magic; }

user_defined_types: struct Scn_Data { struct Elf_Data sd_data; struct Scn_Data *sd_link; struct Elf_Scn *sd_scn; char *sd_memdata; unsigned int sd_data_flags; unsigned int sd_freeme; unsigned int sd_free_data; long sd_magic; }

user_defined_types: struct Elf_Data { void *d_buf; enum Elf_Type d_type; unsigned long d_size; long d_off; unsigned long d_align; unsigned int d_version; }


decompiled_code:
__int64 __fastcall elf_getshdrstrndx(__int64 a1, char *a2)
{
char *v2; // rbp
int v3; // eax
__int64 v4; // rdx
__int64 result; // rax
__int64 v6; // rdx
char v7; // [rsp+0h] [rbp-20h] BYREF

if ( !a1 )
return 0xFFFFFFFFLL;
v2 = a2;
if ( !a2 )
v2 = &v7;
if ( *(_DWORD *)(a1 + 16) != 3 )
{
elf_errno = 13;
return 0xFFFFFFFFLL;
}
if ( !*(_QWORD *)(a1 + 160) && !(unsigned int)elf_cook() )
return 0xFFFFFFFFLL;
v3 = *(_DWORD *)(a1 + 144);
if ( v3 == 1 )
{
v4 = *(unsigned __int16 *)(*(_QWORD *)(a1 + 160) + 50LL);
}
else
{
if ( v3 != 2 )
{
elf_errno = 19;
return 0xFFFFFFFFLL;
}
v4 = *(unsigned __int16 *)(*(_QWORD *)(a1 + 160) + 62LL);
}
if ( v4 == 0xFFFF )
{
v6 = *(_QWORD *)(a1 + 184);
if ( v6 )
{
if ( v3 == 2 )
*(_QWORD *)v2 = *(unsigned int *)(v6 + 128);
else
*(_QWORD *)v2 = *(unsigned int *)(v6 + 112);
result = 0LL;
}
else
{
elf_errno = 21;
result = 0xFFFFFFFFLL;
}
}
else
{
*(_QWORD *)v2 = v4;
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, char *a2)
{
char *v2; // rbp
int v3; // eax
__int64 v4; // rdx
__int64 result; // rax
__int64 v6; // rdx
char v7; // [rsp+0h] [rbp-20h] BYREF

if ( !a1 )
return 0xFFFFFFFFLL;
v2 = a2;
if ( !a2 )
v2 = &v7;
if ( *(_DWORD *)(a1 + 16) != 3 )
{
elf_errno = 13;
return 0xFFFFFFFFLL;
}
if ( !*(_QWORD *)(a1 + 160) && !(unsigned int)elf_cook() )
return 0xFFFFFFFFLL;
v3 = *(_DWORD *)(a1 + 144);
if ( v3 == 1 )
{
v4 = *(unsigned __int16 *)(*(_QWORD *)(a1 + 160) + 50LL);
}
else
{
if ( v3 != 2 )
{
elf_errno = 19;
return 0xFFFFFFFFLL;
}
v4 = *(unsigned __int16 *)(*(_QWORD *)(a1 + 160) + 62LL);
}
if ( v4 == 0xFFFF )
{
v6 = *(_QWORD *)(a1 + 184);
if ( v6 )
{
if ( v3 == 2 )
*(_QWORD *)v2 = *(unsigned int *)(v6 + 128);
else
*(_QWORD *)v2 = *(unsigned int *)(v6 + 112);
result = 0LL;
}
else
{
elf_errno = 21;
result = 0xFFFFFFFFLL;
}
}
else
{
*(_QWORD *)v2 = v4;
result = 0LL;
}
return result;
}

original_code:
int
elf_getshdrstrndx(Elf *elf, size_t *resultp) {
    size_t num = 0;
    size_t dummy;
    Elf_Scn *scn;
    if (!elf) {
 return -1;
    }
    do{}while(0);
    if (resultp == ((void *)0)) {
 resultp = &dummy;
    }
    if (elf->e_kind != ELF_K_ELF) {
 (_elf_errno = (ERROR_NOTELF));
 return -1;
    }
    if (!elf->e_ehdr && !_elf_cook(elf)) {
 return -1;
    }
    if (elf->e_class == 1) {
 num = ((Elf32_Ehdr*)elf->e_ehdr)->e_shstrndx;
    }
    else if (elf->e_class == 2) {
 num = ((Elf64_Ehdr*)elf->e_ehdr)->e_shstrndx;
    }
    else {
 if (((elf->e_class) >= 1 && (elf->e_class) <= 2)) {
     (_elf_errno = (ERROR_UNIMPLEMENTED));
 }
 else {
     (_elf_errno = (ERROR_UNKNOWN_CLASS));
 }
 return -1;
    }
    if (num != 0xffff) {
 *resultp = num;
 return 0;
    }
    if (!(scn = elf->e_scn_1)) {
 (_elf_errno = (ERROR_NOSUCHSCN));
 return -1;
    }
    do{}while(0);
    if (elf->e_class == 2) {
 *resultp = scn->s_uhdr.u_shdr64.sh_link;
 return 0;
    }
    *resultp = scn->s_uhdr.u_shdr32.sh_link;
    return 0;
}

canonical_original_code:
int elf_getshdrstrndx(struct Elf *elf, unsigned long *resultp) {
    unsigned long num = 0;
    unsigned long dummy;
    struct Elf_Scn *scn;
    if (!elf) {
 return -1;
    }
    do{}while(0);
    if (resultp == ((void *)0)) {
 resultp = &dummy;
    }
    if (elf->e_kind != ELF_K_ELF) {
 (_elf_errno = (ERROR_NOTELF));
 return -1;
    }
    if (!elf->e_ehdr && !_elf_cook(elf)) {
 return -1;
    }
    if (elf->e_class == 1) {
 num = ((struct Elf32_Ehdr *)elf->e_ehdr)->e_shstrndx;
    }
    else if (elf->e_class == 2) {
 num = ((struct Elf64_Ehdr *)elf->e_ehdr)->e_shstrndx;
    }
    else {
 if (((elf->e_class) >= 1 && (elf->e_class) <= 2)) {
     (_elf_errno = (ERROR_UNIMPLEMENTED));
 }
 else {
     (_elf_errno = (ERROR_UNKNOWN_CLASS));
 }
 return -1;
    }
    if (num != 0xffff) {
 *resultp = num;
 return 0;
    }
    if (!(scn = elf->e_scn_1)) {
 (_elf_errno = (ERROR_NOSUCHSCN));
 return -1;
    }
    do{}while(0);
    if (elf->e_class == 2) {
 *resultp = scn->s_uhdr.u_shdr64.sh_link;
 return 0;
    }
    *resultp = scn->s_uhdr.u_shdr32.sh_link;
    return 0;
}

variable_types:
dummy
unsigned long

user_defined_types: struct Elf32_Ehdr { unsigned char e_ident[-1]; unsigned short e_type; unsigned short e_machine; unsigned int e_version; unsigned int e_entry; unsigned int e_phoff; unsigned int 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 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: enum Elf_Kind { ELF_K_NONE=0, ELF_K_AR=1, ELF_K_COFF=2, ELF_K_ELF=3, ELF_K_NUM=4 }

user_defined_types: struct Elf_Arhdr { char *ar_name; long ar_date; long ar_uid; long ar_gid; unsigned long ar_mode; long ar_size; char *ar_rawname; }

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 Elf32_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned int sh_flags; unsigned int sh_addr; unsigned int sh_offset; unsigned int sh_size; unsigned int sh_link; unsigned int sh_info; unsigned int sh_addralign; unsigned int sh_entsize; }

user_defined_types: enum Elf_Type { ELF_T_BYTE=0, ELF_T_ADDR=1, ELF_T_DYN=2, ELF_T_EHDR=3, ELF_T_HALF=4, ELF_T_OFF=5, ELF_T_PHDR=6, ELF_T_RELA=7, ELF_T_REL=8, ELF_T_SHDR=9, ELF_T_SWORD=10, ELF_T_SYM=11, ELF_T_WORD=12, ELF_T_SXWORD=13, ELF_T_XWORD=14, ELF_T_VDEF=15, ELF_T_VNEED=16, ELF_T_NUM=17 }


decompiled_code:
_BOOL8 __fastcall elf_getphnum(__int64 a1, _QWORD *a2)
{
return (unsigned int)elf_getphdrnum(a1, a2) == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(__int64 a1, _QWORD *a2)
{
return (unsigned int)func0(a1, a2) == 0;
}

original_code:
int
elf_getphnum(Elf *elf, size_t *resultp) {
    return elf_getphdrnum(elf, resultp) ? 0 : 1;
}

canonical_original_code:
int elf_getphnum(struct Elf *elf, unsigned long *resultp) {
    return elf_getphdrnum(elf, resultp) ? 0 : 1;
}


decompiled_code:
_BOOL8 __fastcall elf_getshnum(__int64 a1, __int64 *a2)
{
return (unsigned int)elf_getshdrnum(a1, a2) == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func4(__int64 a1, __int64 *a2)
{
return (unsigned int)func1(a1, a2) == 0;
}

original_code:
int
elf_getshnum(Elf *elf, size_t *resultp) {
    return elf_getshdrnum(elf, resultp) ? 0 : 1;
}

canonical_original_code:
int elf_getshnum(struct Elf *elf, unsigned long *resultp) {
    return elf_getshdrnum(elf, resultp) ? 0 : 1;
}


decompiled_code:
_BOOL8 __fastcall elf_getshstrndx(__int64 a1, char *a2)
{
return (unsigned int)elf_getshdrstrndx(a1, a2) == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func5(__int64 a1, char *a2)
{
return (unsigned int)func2(a1, a2) == 0;
}

original_code:
int
elf_getshstrndx(Elf *elf, size_t *resultp) {
    return elf_getshdrstrndx(elf, resultp) ? 0 : 1;
}

canonical_original_code:
int elf_getshstrndx(struct Elf *elf, unsigned long *resultp) {
    return elf_getshdrstrndx(elf, resultp) ? 0 : 1;
}


original_code:
int
elfx_update_shstrndx(Elf *elf, size_t value) {
    size_t extvalue = 0;
    Elf_Scn *scn;
    if (!elf) {
 return 0;
    }
    do{}while(0);
    if (value >= 0xff00) {
 extvalue = value;
 value = 0xffff;
    }
    if (elf->e_kind != ELF_K_ELF) {
 (_elf_errno = (ERROR_NOTELF));
 return 0;
    }
    if (!elf->e_ehdr && !_elf_cook(elf)) {
 return 0;
    }
    if (!(scn = _elf_first_scn(elf))) {
 return 0;
    }
    do{}while(0);
    if (elf->e_class == 1) {
 ((Elf32_Ehdr*)elf->e_ehdr)->e_shstrndx = value;
 scn->s_uhdr.u_shdr32.sh_link = extvalue;
    }
    else if (elf->e_class == 2) {
 ((Elf64_Ehdr*)elf->e_ehdr)->e_shstrndx = value;
 scn->s_uhdr.u_shdr64.sh_link = extvalue;
    }
    else {
 if (((elf->e_class) >= 1 && (elf->e_class) <= 2)) {
     (_elf_errno = (ERROR_UNIMPLEMENTED));
 }
 else {
     (_elf_errno = (ERROR_UNKNOWN_CLASS));
 }
 return 0;
    }
    elf->e_ehdr_flags |= 0x1;
    scn->s_shdr_flags |= 0x1;
    return 1;
}

canonical_original_code:
int elfx_update_shstrndx(struct Elf *elf, unsigned long value) {
    unsigned long extvalue = 0;
    struct Elf_Scn *scn;
    if (!elf) {
 return 0;
    }
    do{}while(0);
    if (value >= 0xff00) {
 extvalue = value;
 value = 0xffff;
    }
    if (elf->e_kind != ELF_K_ELF) {
 (_elf_errno = (ERROR_NOTELF));
 return 0;
    }
    if (!elf->e_ehdr && !_elf_cook(elf)) {
 return 0;
    }
    if (!(scn = _elf_first_scn(elf))) {
 return 0;
    }
    do{}while(0);
    if (elf->e_class == 1) {
 ((struct Elf32_Ehdr *)elf->e_ehdr)->e_shstrndx = value;
 scn->s_uhdr.u_shdr32.sh_link = extvalue;
    }
    else if (elf->e_class == 2) {
 ((struct Elf64_Ehdr *)elf->e_ehdr)->e_shstrndx = value;
 scn->s_uhdr.u_shdr64.sh_link = extvalue;
    }
    else {
 if (((elf->e_class) >= 1 && (elf->e_class) <= 2)) {
     (_elf_errno = (ERROR_UNIMPLEMENTED));
 }
 else {
     (_elf_errno = (ERROR_UNKNOWN_CLASS));
 }
 return 0;
    }
    elf->e_ehdr_flags |= 0x1;
    scn->s_shdr_flags |= 0x1;
    return 1;
}

variable_types:
value
unsigned long

variable_types:
extvalue
unsigned long


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

if ( a1 )
result = *(_QWORD *)(a1 + 72);
else
result = -1LL;
return result;
}

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

if ( a1 )
result = *(_QWORD *)(a1 + 72);
else
result = -1LL;
return result;
}

original_code:
off_t
elf_getbase(Elf *elf) {
    if (!elf) {
 return -1;
    }
    do{}while(0);
    return (off_t)elf->e_base;
}

canonical_original_code:
long elf_getbase(struct Elf *elf) {
    if (!elf) {
 return -1;
    }
    do{}while(0);
    return (long)elf->e_base;
}

return_type: long


decompiled_code:
__int64 __fastcall elf32_getshdr(__int64 a1)
{
if ( !a1 )
return 0LL;
if ( *(_DWORD *)(*(_QWORD *)(a1 + 8) + 144LL) == 1 )
return a1 + 88;
elf_errno = 14;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
if ( !a1 )
return 0LL;
if ( *(_DWORD *)(*(_QWORD *)(a1 + 8) + 144LL) == 1 )
return a1 + 88;
elf_errno = 14;
return 0LL;
}

original_code:
Elf32_Shdr*
elf32_getshdr(Elf_Scn *scn) {
    if (!scn) {
 return ((void *)0);
    }
    do{}while(0);
    do{}while(0);
    do{}while(0);
    if (scn->s_elf->e_class == 1) {
 return &scn->s_uhdr.u_shdr32;
    }
    (_elf_errno = (ERROR_CLASSMISMATCH));
    return ((void *)0);
}

canonical_original_code:
struct Elf32_Shdr *elf32_getshdr(struct Elf_Scn *scn) {
    if (!scn) {
 return ((void *)0);
    }
    do{}while(0);
    do{}while(0);
    do{}while(0);
    if (scn->s_elf->e_class == 1) {
 return &scn->s_uhdr.u_shdr32;
    }
    (_elf_errno = (ERROR_CLASSMISMATCH));
    return ((void *)0);
}

variable_types: struct Elf_Scn { struct Elf_Scn *s_link; struct Elf { unsigned long e_size; unsigned long e_dsize; enum Elf_Kind { ELF_K_NONE=0, ELF_K_AR=1, ELF_K_COFF=2, ELF_K_ELF=3, ELF_K_NUM=4 } e_kind; char *e_data; char *e_rawdata; unsigned long e_idlen; int e_fd; unsigned int e_count; struct Elf *e_parent; unsigned long e_next; unsigned long e_base; struct Elf *e_link; struct Elf_Arhdr { char *ar_name; long ar_date; long ar_uid; long ar_gid; unsigned long ar_mode; long ar_size; char *ar_rawname; } *e_arhdr; unsigned long e_off; struct Elf *e_members; char *e_symtab; unsigned long e_symlen; char *e_strtab; unsigned long e_strlen; unsigned int e_class; unsigned int e_encoding; unsigned int e_version; char *e_ehdr; char *e_phdr; unsigned long e_phnum; struct Elf_Scn *e_scn_1; struct Elf_Scn *e_scn_n; unsigned int e_elf_flags; unsigned int e_ehdr_flags; unsigned int e_phdr_flags; unsigned int e_readable; unsigned int e_writable; unsigned int e_disabled; unsigned int e_cooked; unsigned int e_free_syms; unsigned int e_unmap_data; unsigned int e_memory; long e_magic; } *s_elf; unsigned long s_index; unsigned int s_scn_flags; unsigned int s_shdr_flags; struct Scn_Data { struct Elf_Data { void *d_buf; enum Elf_Type { ELF_T_BYTE=0, ELF_T_ADDR=1, ELF_T_DYN=2, ELF_T_EHDR=3, ELF_T_HALF=4, ELF_T_OFF=5, ELF_T_PHDR=6, ELF_T_RELA=7, ELF_T_REL=8, ELF_T_SHDR=9, ELF_T_SWORD=10, ELF_T_SYM=11, ELF_T_WORD=12, ELF_T_SXWORD=13, ELF_T_XWORD=14, ELF_T_VDEF=15, ELF_T_VNEED=16, ELF_T_NUM=17 } d_type; unsigned long d_size; long d_off; unsigned long d_align; unsigned int d_version; } sd_data; struct Scn_Data *sd_link; struct Elf_Scn *sd_scn; char *sd_memdata; unsigned int sd_data_flags; unsigned int sd_freeme; unsigned int sd_free_data; long sd_magic; } *s_data_1; struct Scn_Data *s_data_n; struct Scn_Data *s_rawdata; unsigned int s_type; unsigned long s_offset; unsigned long s_size; unsigned int s_freeme; union { 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; } u_shdr64; struct Elf32_Shdr u_shdr32; } s_uhdr; long s_magic; } *

return_type: struct Elf32_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned int sh_flags; unsigned int sh_addr; unsigned int sh_offset; unsigned int sh_size; unsigned int sh_link; unsigned int sh_info; unsigned int sh_addralign; unsigned int sh_entsize; } *


decompiled_code:
__int64 __fastcall elf64_getshdr(__int64 a1)
{
if ( !a1 )
return 0LL;
if ( *(_DWORD *)(*(_QWORD *)(a1 + 8) + 144LL) == 2 )
return a1 + 88;
elf_errno = 14;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
if ( !a1 )
return 0LL;
if ( *(_DWORD *)(*(_QWORD *)(a1 + 8) + 144LL) == 2 )
return a1 + 88;
elf_errno = 14;
return 0LL;
}

original_code:
Elf64_Shdr*
elf64_getshdr(Elf_Scn *scn) {
    if (!scn) {
 return ((void *)0);
    }
    do{}while(0);
    do{}while(0);
    do{}while(0);
    if (scn->s_elf->e_class == 2) {
 return &scn->s_uhdr.u_shdr64;
    }
    (_elf_errno = (ERROR_CLASSMISMATCH));
    return ((void *)0);
}

canonical_original_code:
struct Elf64_Shdr *elf64_getshdr(struct Elf_Scn *scn) {
    if (!scn) {
 return ((void *)0);
    }
    do{}while(0);
    do{}while(0);
    do{}while(0);
    if (scn->s_elf->e_class == 2) {
 return &scn->s_uhdr.u_shdr64;
    }
    (_elf_errno = (ERROR_CLASSMISMATCH));
    return ((void *)0);
}

variable_types: struct Elf_Scn { struct Elf_Scn *s_link; struct Elf { unsigned long e_size; unsigned long e_dsize; enum Elf_Kind { ELF_K_NONE=0, ELF_K_AR=1, ELF_K_COFF=2, ELF_K_ELF=3, ELF_K_NUM=4 } e_kind; char *e_data; char *e_rawdata; unsigned long e_idlen; int e_fd; unsigned int e_count; struct Elf *e_parent; unsigned long e_next; unsigned long e_base; struct Elf *e_link; struct Elf_Arhdr { char *ar_name; long ar_date; long ar_uid; long ar_gid; unsigned long ar_mode; long ar_size; char *ar_rawname; } *e_arhdr; unsigned long e_off; struct Elf *e_members; char *e_symtab; unsigned long e_symlen; char *e_strtab; unsigned long e_strlen; unsigned int e_class; unsigned int e_encoding; unsigned int e_version; char *e_ehdr; char *e_phdr; unsigned long e_phnum; struct Elf_Scn *e_scn_1; struct Elf_Scn *e_scn_n; unsigned int e_elf_flags; unsigned int e_ehdr_flags; unsigned int e_phdr_flags; unsigned int e_readable; unsigned int e_writable; unsigned int e_disabled; unsigned int e_cooked; unsigned int e_free_syms; unsigned int e_unmap_data; unsigned int e_memory; long e_magic; } *s_elf; unsigned long s_index; unsigned int s_scn_flags; unsigned int s_shdr_flags; struct Scn_Data { struct Elf_Data { void *d_buf; enum Elf_Type { ELF_T_BYTE=0, ELF_T_ADDR=1, ELF_T_DYN=2, ELF_T_EHDR=3, ELF_T_HALF=4, ELF_T_OFF=5, ELF_T_PHDR=6, ELF_T_RELA=7, ELF_T_REL=8, ELF_T_SHDR=9, ELF_T_SWORD=10, ELF_T_SYM=11, ELF_T_WORD=12, ELF_T_SXWORD=13, ELF_T_XWORD=14, ELF_T_VDEF=15, ELF_T_VNEED=16, ELF_T_NUM=17 } d_type; unsigned long d_size; long d_off; unsigned long d_align; unsigned int d_version; } sd_data; struct Scn_Data *sd_link; struct Elf_Scn *sd_scn; char *sd_memdata; unsigned int sd_data_flags; unsigned int sd_freeme; unsigned int sd_free_data; long sd_magic; } *s_data_1; struct Scn_Data *s_data_n; struct Scn_Data *s_rawdata; unsigned int s_type; unsigned long s_offset; unsigned long s_size; unsigned int s_freeme; union { struct Elf64_Shdr u_shdr64; struct Elf32_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned int sh_flags; unsigned int sh_addr; unsigned int sh_offset; unsigned int sh_size; unsigned int sh_link; unsigned int sh_info; unsigned int sh_addralign; unsigned int sh_entsize; } u_shdr32; } s_uhdr; long s_magic; } *

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


original_code:
static inline void CMN_list_del(struct CMN_list_head *entry)
{
 __CMN_list_del(entry->prev, entry->next);
 entry->next = (pCMN_list_head_t)((void *) 0x00100100);
 entry->prev = (pCMN_list_head_t)((void *) 0x00200200);
}

variable_types: struct CMN_list_head { struct CMN_list_head *next; } *

return_type: void


decompiled_code:
__int64 __fastcall esyslog_unregisterBackend(void *ptr)
{
if ( !ptr )
return 0xFFFFFFFFLL;
ESyslogEngine_RemBacked((__int64)&st_ESyslogEngine, (__int64)ptr);
free(ptr);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func19(void *ptr)
{
if ( !ptr )
return 0xFFFFFFFFLL;
func12((__int64)&st_ESyslogEngine, (__int64)ptr);
free(ptr);
return 0LL;
}

original_code:
int esyslog_unregisterBackend (void *pBackendHandle) {
 ESyslogEngine_Backend_t *pEngine_Backend = (ESyslogEngine_Backend_t *)pBackendHandle;
 if (!pBackendHandle)
  return -1;
 _ESyslogEngine_RemBacked(&st_ESyslogEngine, pEngine_Backend);
 free(pEngine_Backend);
 return 0;
}

canonical_original_code:
int esyslog_unregisterBackend(void *pBackendHandle) {
 struct tagESyslogEngine_Backend *pEngine_Backend = (ESyslogEngine_Backend_t *)pBackendHandle;
 if (!pBackendHandle)
  return -1;
 _ESyslogEngine_RemBacked(&st_ESyslogEngine, pEngine_Backend);
 free(pEngine_Backend);
 return 0;
}

variable_types:
pBackendHandle
void *

variable_types: struct tagESyslogEngine_Backend { struct tagESyslog_Backend { void (*onSyslog)(struct tagESyslog_Backend *pBackend, char *moduleName, struct tagESyslog_Group { char name[40]; struct tagESyslog_GroupConfig { unsigned int mask; } config; } *pGroup, enum enumESyslog_MsgImportance { esgiEmerg=0, esgiAlert=1, esgiCrit=2, esgiErr=3, esgiWarn=4, esgiNotice=5, esgiInfo=6, esgiDebug=7 } importance, char *format, __builtin_va_list ap); void (*onDestroy)(struct tagESyslog_Backend *pBackend); } *pBackend; struct CMN_list_head { struct CMN_list_head *next; } list; } *

user_defined_types: struct tagESyslogEngine_Backend { struct tagESyslog_Backend *pBackend; struct CMN_list_head list; }

user_defined_types: struct tagESyslog_Backend { void (*onSyslog)(struct tagESyslog_Backend *pBackend, char *moduleName, struct tagESyslog_Group *pGroup, enum enumESyslog_MsgImportance importance, char *format, __builtin_va_list ap); void (*onDestroy)(struct tagESyslog_Backend *pBackend); }

user_defined_types: struct tagESyslog_Group { char name[40]; struct tagESyslog_GroupConfig config; }


decompiled_code:
__int64 esyslog_getModuleCount()
{
return (unsigned int)st_ESyslogEngine;
}

canonical_decompiled_code:
__int64 func22()
{
return (unsigned int)st_ESyslogEngine;
}

original_code:
ESyslog_ModuleId_t esyslog_getModuleCount(void) {
 return st_ESyslogEngine.moduleCnt;
}

canonical_original_code:
int esyslog_getModuleCount() {
 return st_ESyslogEngine.moduleCnt;
}


decompiled_code:
__int64 __fastcall esyslog_getModuleName(int a1, __m128i *a2)
{
const __m128i *v2; // rax

if ( !a2 )
return 0xFFFFFFFFLL;
v2 = (const __m128i *)ESyslogEngine_GetModuleImpl((__int64)&st_ESyslogEngine, a1);
if ( !v2 )
return 0xFFFFFFFFLL;
*a2 = _mm_loadu_si128(v2);
a2[1] = _mm_loadu_si128(v2 + 1);
a2[2].m128i_i64[0] = v2[2].m128i_i64[0];
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func23(int a1, __m128i *a2)
{
const __m128i *v2; // rax

if ( !a2 )
return 0xFFFFFFFFLL;
v2 = (const __m128i *)ESyslogEngine_GetModuleImpl((__int64)&st_ESyslogEngine, a1);
if ( !v2 )
return 0xFFFFFFFFLL;
*a2 = _mm_loadu_si128(v2);
a2[1] = _mm_loadu_si128(v2 + 1);
a2[2].m128i_i64[0] = v2[2].m128i_i64[0];
return 0LL;
}

original_code:
int esyslog_getModuleName(ESyslog_ModuleId_t moduleId, ESyslog_ModuleName_t *pName) {
 ESyslog_ModuleImpl_t * pModuleImpl;
 if (!pName)
  return -1;
 if (!(pModuleImpl = _ESyslogEngine_GetModuleImpl(&st_ESyslogEngine, moduleId)))
  return -1;
 memcpy(&((*pName)[0]), &(pModuleImpl->name[0]), sizeof(ESyslog_ModuleName_t));
 return 0;
}

canonical_original_code:
int esyslog_getModuleName(int moduleId, char (*pName)[40]) {
 struct tagESyslog_ModuleImpl *pModuleImpl;
 if (!pName)
  return -1;
 if (!(pModuleImpl = _ESyslogEngine_GetModuleImpl(&st_ESyslogEngine, moduleId)))
  return -1;
 memcpy(&((*pName)[0]), &(pModuleImpl->name[0]), sizeof(ESyslog_ModuleName_t));
 return 0;
}

variable_types: moduleId int

variable_types:
pName
char (*)[40]

variable_types: struct tagESyslog_ModuleImpl { char name[40]; int usageCounter; int grpCount; struct CMN_list_head { struct CMN_list_head *next; } grpList; struct CMN_list_head list; } *

user_defined_types: struct tagESyslog_ModuleImpl { char name[40]; int usageCounter; int grpCount; struct CMN_list_head grpList; struct CMN_list_head list; }


decompiled_code:
__int64 __fastcall esyslog_getGroupCount(int a1)
{
_QWORD *v1; // rax
__int64 result; // rax

v1 = ESyslogEngine_GetModuleImpl((__int64)&st_ESyslogEngine, a1);
if ( v1 )
result = *((unsigned int *)v1 + 11);
else
result = 0xFFFFFFFFLL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func24(int a1)
{
_QWORD *v1; // rax
__int64 result; // rax

v1 = ESyslogEngine_GetModuleImpl((__int64)&st_ESyslogEngine, a1);
if ( v1 )
result = *((unsigned int *)v1 + 11);
else
result = 0xFFFFFFFFLL;
return result;
}

original_code:
ESyslog_GroupId_t esyslog_getGroupCount(ESyslog_ModuleId_t moduleId) {
 ESyslog_ModuleImpl_t * pModuleImpl;
 if (!(pModuleImpl = _ESyslogEngine_GetModuleImpl(&st_ESyslogEngine, moduleId)))
  return -1;
 return pModuleImpl->grpCount;
}

canonical_original_code:
int esyslog_getGroupCount(int moduleId) {
 struct tagESyslog_ModuleImpl *pModuleImpl;
 if (!(pModuleImpl = _ESyslogEngine_GetModuleImpl(&st_ESyslogEngine, moduleId)))
  return -1;
 return pModuleImpl->grpCount;
}

user_defined_types: struct CMN_list_head { struct CMN_list_head *next; }


decompiled_code:
__int64 __fastcall esyslog_getGroup(int a1, int a2, __m128i *a3)
{
_QWORD *v4; // rdi
const __m128i *v5; // rax

if ( !a3 )
return 0xFFFFFFFFLL;
v4 = ESyslogEngine_GetModuleImpl((__int64)&st_ESyslogEngine, a1);
if ( !v4 )
return 0xFFFFFFFFLL;
v5 = (const __m128i *)ESyslogModuleImpl_GetGroupImpl((__int64)v4, a2);
if ( !v5 )
return 0xFFFFFFFFLL;
*a3 = _mm_loadu_si128(v5);
a3[1] = _mm_loadu_si128(v5 + 1);
a3[2].m128i_i64[0] = v5[2].m128i_i64[0];
a3[2].m128i_i32[2] = v5[2].m128i_i32[2];
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func25(int a1, int a2, __m128i *a3)
{
_QWORD *v4; // rdi
const __m128i *v5; // rax

if ( !a3 )
return 0xFFFFFFFFLL;
v4 = ESyslogEngine_GetModuleImpl((__int64)&st_ESyslogEngine, a1);
if ( !v4 )
return 0xFFFFFFFFLL;
v5 = (const __m128i *)ESyslogModuleImpl_GetGroupImpl((__int64)v4, a2);
if ( !v5 )
return 0xFFFFFFFFLL;
*a3 = _mm_loadu_si128(v5);
a3[1] = _mm_loadu_si128(v5 + 1);
a3[2].m128i_i64[0] = v5[2].m128i_i64[0];
a3[2].m128i_i32[2] = v5[2].m128i_i32[2];
return 0LL;
}

original_code:
int esyslog_getGroup(ESyslog_ModuleId_t moduleId, ESyslog_GroupId_t groupId, ESyslog_Group_t *pGroup) {
 ESyslog_ModuleImpl_t * pModuleImpl;
 ESyslog_GroupImpl_t * pGroupImpl;
 if (!pGroup) {
  return -1;
 }
 if (!(pModuleImpl = _ESyslogEngine_GetModuleImpl(&st_ESyslogEngine, moduleId))) {
  return -1;
 }
 if (!(pGroupImpl = _ESyslogModuleImpl_GetGroupImpl(pModuleImpl, groupId))) {
  return -1;
 }
 memcpy(pGroup, &pGroupImpl->group, sizeof(ESyslog_Group_t));
 return 0;
}

canonical_original_code:
int esyslog_getGroup(int moduleId, int groupId, struct tagESyslog_Group *pGroup) {
 struct tagESyslog_ModuleImpl *pModuleImpl;
 struct tagESyslog_GroupImpl *pGroupImpl;
 if (!pGroup) {
  return -1;
 }
 if (!(pModuleImpl = _ESyslogEngine_GetModuleImpl(&st_ESyslogEngine, moduleId))) {
  return -1;
 }
 if (!(pGroupImpl = _ESyslogModuleImpl_GetGroupImpl(pModuleImpl, groupId))) {
  return -1;
 }
 memcpy(pGroup, &pGroupImpl->group, sizeof(ESyslog_Group_t));
 return 0;
}

variable_types: groupId int

variable_types: struct tagESyslog_Group { char name[40]; struct tagESyslog_GroupConfig { unsigned int mask; } config; } *

variable_types: struct tagESyslog_GroupImpl { struct tagESyslog_Group { char name[40]; struct tagESyslog_GroupConfig { unsigned int mask; } config; } group; struct tagESyslog_ModuleImpl { char name[40]; int usageCounter; int grpCount; struct CMN_list_head { struct CMN_list_head *next; } grpList; struct CMN_list_head list; } *pModule; struct CMN_list_head list; } *

user_defined_types: struct tagESyslog_GroupImpl { struct tagESyslog_Group group; struct tagESyslog_ModuleImpl *pModule; struct CMN_list_head list; }


decompiled_code:
__int64 __fastcall esyslog_setGroupConfig(int a1, int a2, _DWORD *a3)
{
_QWORD *v4; // rdi
_QWORD *v5; // rax

if ( !a3 )
return 0xFFFFFFFFLL;
v4 = ESyslogEngine_GetModuleImpl((__int64)&st_ESyslogEngine, a1);
if ( !v4 )
return 0xFFFFFFFFLL;
v5 = ESyslogModuleImpl_GetGroupImpl((__int64)v4, a2);
if ( !v5 )
return 0xFFFFFFFFLL;
*((_DWORD *)v5 + 10) = *a3;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func26(int a1, int a2, _DWORD *a3)
{
_QWORD *v4; // rdi
_QWORD *v5; // rax

if ( !a3 )
return 0xFFFFFFFFLL;
v4 = ESyslogEngine_GetModuleImpl((__int64)&st_ESyslogEngine, a1);
if ( !v4 )
return 0xFFFFFFFFLL;
v5 = ESyslogModuleImpl_GetGroupImpl((__int64)v4, a2);
if ( !v5 )
return 0xFFFFFFFFLL;
*((_DWORD *)v5 + 10) = *a3;
return 0LL;
}

original_code:
int esyslog_setGroupConfig(ESyslog_ModuleId_t moduleId, ESyslog_GroupId_t groupId, ESyslog_GroupConfig_t *pGroupConfig) {
 ESyslog_ModuleImpl_t * pModuleImpl;
 ESyslog_GroupImpl_t * pGroupImpl;
 if (!pGroupConfig) {
  return -1;
 }
 if (!(pModuleImpl = _ESyslogEngine_GetModuleImpl(&st_ESyslogEngine, moduleId))) {
  return -1;
 }
 if (!(pGroupImpl = _ESyslogModuleImpl_GetGroupImpl(pModuleImpl, groupId))) {
  return -1;
 }
 memcpy(&pGroupImpl->group.config, pGroupConfig, sizeof(ESyslog_GroupConfig_t));
 return 0;
}

canonical_original_code:
int esyslog_setGroupConfig(int moduleId, int groupId, struct tagESyslog_GroupConfig *pGroupConfig) {
 struct tagESyslog_ModuleImpl *pModuleImpl;
 struct tagESyslog_GroupImpl *pGroupImpl;
 if (!pGroupConfig) {
  return -1;
 }
 if (!(pModuleImpl = _ESyslogEngine_GetModuleImpl(&st_ESyslogEngine, moduleId))) {
  return -1;
 }
 if (!(pGroupImpl = _ESyslogModuleImpl_GetGroupImpl(pModuleImpl, groupId))) {
  return -1;
 }
 memcpy(&pGroupImpl->group.config, pGroupConfig, sizeof(ESyslog_GroupConfig_t));
 return 0;
}

variable_types: struct tagESyslog_GroupConfig { unsigned int mask; } *


decompiled_code:
__int64 __fastcall add_bytes(unsigned __int8 *a1, __int64 a2)
{
unsigned __int8 *v2; // rsi
__int64 result; // rax

if ( !a2 )
return 0LL;
v2 = &a1[a2];
result = 0LL;
do
result += *a1++;
while ( v2 != a1 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned __int8 *a1, __int64 a2)
{
unsigned __int8 *v2; // rsi
__int64 result; // rax

if ( !a2 )
return 0LL;
v2 = &a1[a2];
result = 0LL;
do
result += *a1++;
while ( v2 != a1 );
return result;
}

original_code:
static long
add_bytes(unsigned char *ptr, size_t len) {
    long csum = 0;
    while (len--) {
 csum += *ptr++;
    }
    return csum;
}

canonical_original_code:
static long add_bytes(unsigned char *ptr, unsigned long len) {
    long csum = 0;
    while (len--) {
 csum += *ptr++;
    }
    return csum;
}

variable_types:
ptr
unsigned char *

variable_types:
len
unsigned long

variable_types: csum long


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

result = 0LL;
if ( a1 )
{
if ( *(_DWORD *)(a1 + 16) == 3 )
{
if ( *(_DWORD *)(a1 + 144) == 1 )
{
result = elf_csum(a1);
}
else
{
elf_errno = 14;
result = 0LL;
}
}
else
{
elf_errno = 13;
result = 0LL;
}
}
return result;
}

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

result = 0LL;
if ( a1 )
{
if ( *(_DWORD *)(a1 + 16) == 3 )
{
if ( *(_DWORD *)(a1 + 144) == 1 )
{
result = func2(a1);
}
else
{
elf_errno = 14;
result = 0LL;
}
}
else
{
elf_errno = 13;
result = 0LL;
}
}
return result;
}

original_code:
long
elf32_checksum(Elf *elf) {
    if (elf) {
 if (elf->e_kind != ELF_K_ELF) {
     (_elf_errno = (ERROR_NOTELF));
 }
 else if (elf->e_class != 1) {
     (_elf_errno = (ERROR_CLASSMISMATCH));
 }
 else {
     return _elf_csum(elf);
 }
    }
    return 0L;
}

canonical_original_code:
long elf32_checksum(struct Elf *elf) {
    if (elf) {
 if (elf->e_kind != ELF_K_ELF) {
     (_elf_errno = (ERROR_NOTELF));
 }
 else if (elf->e_class != 1) {
     (_elf_errno = (ERROR_CLASSMISMATCH));
 }
 else {
     return _elf_csum(elf);
 }
    }
    return 0L;
}

variable_types: struct Elf { unsigned long e_size; unsigned long e_dsize; enum Elf_Kind { ELF_K_NONE=0, ELF_K_AR=1, ELF_K_COFF=2, ELF_K_ELF=3, ELF_K_NUM=4 } e_kind; char *e_data; char *e_rawdata; unsigned long e_idlen; int e_fd; unsigned int e_count; struct Elf *e_parent; unsigned long e_next; unsigned long e_base; struct Elf *e_link; struct Elf_Arhdr { char *ar_name; long ar_date; long ar_uid; long ar_gid; unsigned long ar_mode; long ar_size; char *ar_rawname; } *e_arhdr; unsigned long e_off; struct Elf *e_members; char *e_symtab; unsigned long e_symlen; char *e_strtab; unsigned long e_strlen; unsigned int e_class; unsigned int e_encoding; unsigned int e_version; char *e_ehdr; char *e_phdr; unsigned long e_phnum; struct Elf_Scn { struct Elf_Scn *s_link; struct Elf *s_elf; unsigned long s_index; unsigned int s_scn_flags; unsigned int s_shdr_flags; struct Scn_Data { struct Elf_Data { void *d_buf; enum Elf_Type { ELF_T_BYTE=0, ELF_T_ADDR=1, ELF_T_DYN=2, ELF_T_EHDR=3, ELF_T_HALF=4, ELF_T_OFF=5, ELF_T_PHDR=6, ELF_T_RELA=7, ELF_T_REL=8, ELF_T_SHDR=9, ELF_T_SWORD=10, ELF_T_SYM=11, ELF_T_WORD=12, ELF_T_SXWORD=13, ELF_T_XWORD=14, ELF_T_VDEF=15, ELF_T_VNEED=16, ELF_T_NUM=17 } d_type; unsigned long d_size; long d_off; unsigned long d_align; unsigned int d_version; } sd_data; struct Scn_Data *sd_link; struct Elf_Scn *sd_scn; char *sd_memdata; unsigned int sd_data_flags; unsigned int sd_freeme; unsigned int sd_free_data; long sd_magic; } *s_data_1; struct Scn_Data *s_data_n; struct Scn_Data *s_rawdata; unsigned int s_type; unsigned long s_offset; unsigned long s_size; unsigned int s_freeme; union { 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; } u_shdr64; struct Elf32_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned int sh_flags; unsigned int sh_addr; unsigned int sh_offset; unsigned int sh_size; unsigned int sh_link; unsigned int sh_info; unsigned int sh_addralign; unsigned int sh_entsize; } u_shdr32; } s_uhdr; long s_magic; } *e_scn_1; struct Elf_Scn *e_scn_n; unsigned int e_elf_flags; unsigned int e_ehdr_flags; unsigned int e_phdr_flags; unsigned int e_readable; unsigned int e_writable; unsigned int e_disabled; unsigned int e_cooked; unsigned int e_free_syms; unsigned int e_unmap_data; unsigned int e_memory; long e_magic; } *

user_defined_types: struct Elf { unsigned long e_size; unsigned long e_dsize; enum Elf_Kind e_kind; char *e_data; char *e_rawdata; unsigned long e_idlen; int e_fd; unsigned int e_count; struct Elf *e_parent; unsigned long e_next; unsigned long e_base; struct Elf *e_link; struct Elf_Arhdr *e_arhdr; unsigned long e_off; struct Elf *e_members; char *e_symtab; unsigned long e_symlen; char *e_strtab; unsigned long e_strlen; unsigned int e_class; unsigned int e_encoding; unsigned int e_version; char *e_ehdr; char *e_phdr; unsigned long e_phnum; struct Elf_Scn *e_scn_1; struct Elf_Scn *e_scn_n; unsigned int e_elf_flags; unsigned int e_ehdr_flags; unsigned int e_phdr_flags; unsigned int e_readable; unsigned int e_writable; unsigned int e_disabled; unsigned int e_cooked; unsigned int e_free_syms; unsigned int e_unmap_data; unsigned int e_memory; long e_magic; }


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

result = 0LL;
if ( a1 )
{
if ( *(_DWORD *)(a1 + 16) == 3 )
{
if ( *(_DWORD *)(a1 + 144) == 2 )
{
result = elf_csum(a1);
}
else
{
elf_errno = 14;
result = 0LL;
}
}
else
{
elf_errno = 13;
result = 0LL;
}
}
return result;
}

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

result = 0LL;
if ( a1 )
{
if ( *(_DWORD *)(a1 + 16) == 3 )
{
if ( *(_DWORD *)(a1 + 144) == 2 )
{
result = func2(a1);
}
else
{
elf_errno = 14;
result = 0LL;
}
}
else
{
elf_errno = 13;
result = 0LL;
}
}
return result;
}

original_code:
long
elf64_checksum(Elf *elf) {
    if (elf) {
 if (elf->e_kind != ELF_K_ELF) {
     (_elf_errno = (ERROR_NOTELF));
 }
 else if (elf->e_class != 2) {
     (_elf_errno = (ERROR_CLASSMISMATCH));
 }
 else {
     return _elf_csum(elf);
 }
    }
    return 0L;
}

canonical_original_code:
long elf64_checksum(struct Elf *elf) {
    if (elf) {
 if (elf->e_kind != ELF_K_ELF) {
     (_elf_errno = (ERROR_NOTELF));
 }
 else if (elf->e_class != 2) {
     (_elf_errno = (ERROR_CLASSMISMATCH));
 }
 else {
     return _elf_csum(elf);
 }
    }
    return 0L;
}

user_defined_types: struct Elf_Scn { struct Elf_Scn *s_link; struct Elf *s_elf; unsigned long s_index; unsigned int s_scn_flags; unsigned int s_shdr_flags; struct Scn_Data *s_data_1; struct Scn_Data *s_data_n; struct Scn_Data *s_rawdata; unsigned int s_type; unsigned long s_offset; unsigned long s_size; unsigned int s_freeme; union { struct Elf64_Shdr u_shdr64; struct Elf32_Shdr u_shdr32; } s_uhdr; long s_magic; }


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

result = 0LL;
if ( a1 )
{
if ( *(_DWORD *)(a1 + 16) == 3 )
{
if ( (unsigned int)(*(_DWORD *)(a1 + 144) - 1) <= 1 )
{
result = elf_csum(a1);
}
else
{
elf_errno = 19;
result = 0LL;
}
}
else
{
elf_errno = 13;
result = 0LL;
}
}
return result;
}

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

result = 0LL;
if ( a1 )
{
if ( *(_DWORD *)(a1 + 16) == 3 )
{
if ( (unsigned int)(*(_DWORD *)(a1 + 144) - 1) <= 1 )
{
result = func2(a1);
}
else
{
elf_errno = 19;
result = 0LL;
}
}
else
{
elf_errno = 13;
result = 0LL;
}
}
return result;
}

original_code:
long
gelf_checksum(Elf *elf) {
    if (elf) {
 if (elf->e_kind != ELF_K_ELF) {
     (_elf_errno = (ERROR_NOTELF));
 }
 else if (!((elf->e_class) >= 1 && (elf->e_class) <= 2)) {
     (_elf_errno = (ERROR_UNKNOWN_CLASS));
 }
 else {
     return _elf_csum(elf);
 }
    }
    return 0L;
}

canonical_original_code:
long gelf_checksum(struct Elf *elf) {
    if (elf) {
 if (elf->e_kind != ELF_K_ELF) {
     (_elf_errno = (ERROR_NOTELF));
 }
 else if (!((elf->e_class) >= 1 && (elf->e_class) <= 2)) {
     (_elf_errno = (ERROR_UNKNOWN_CLASS));
 }
 else {
     return _elf_csum(elf);
 }
    }
    return 0L;
}

user_defined_types: struct Scn_Data { struct Elf_Data sd_data; struct Scn_Data *sd_link; struct Elf_Scn *sd_scn; char *sd_memdata; unsigned int sd_data_flags; unsigned int sd_freeme; unsigned int sd_free_data; long sd_magic; }


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

if ( !a1 )
return 0LL;
result = *(_QWORD *)(a1 + 88);
if ( !result )
elf_errno = 7;
return result;
}

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

if ( !a1 )
return 0LL;
result = *(_QWORD *)(a1 + 88);
if ( !result )
elf_errno = 7;
return result;
}

original_code:
Elf_Arhdr*
elf_getarhdr(Elf *elf) {
    if (!elf) {
 return ((void *)0);
    }
    do{}while(0);
    if (elf->e_arhdr) {
 return elf->e_arhdr;
    }
    (_elf_errno = (ERROR_NOTARCHIVE));
    return ((void *)0);
}

canonical_original_code:
struct Elf_Arhdr *elf_getarhdr(struct Elf *elf) {
    if (!elf) {
 return ((void *)0);
    }
    do{}while(0);
    if (elf->e_arhdr) {
 return elf->e_arhdr;
    }
    (_elf_errno = (ERROR_NOTARCHIVE));
    return ((void *)0);
}

variable_types: struct Elf { unsigned long e_size; unsigned long e_dsize; enum Elf_Kind { ELF_K_NONE=0, ELF_K_AR=1, ELF_K_COFF=2, ELF_K_ELF=3, ELF_K_NUM=4 } e_kind; char *e_data; char *e_rawdata; unsigned long e_idlen; int e_fd; unsigned int e_count; struct Elf *e_parent; unsigned long e_next; unsigned long e_base; struct Elf *e_link; struct Elf_Arhdr *e_arhdr; unsigned long e_off; struct Elf *e_members; char *e_symtab; unsigned long e_symlen; char *e_strtab; unsigned long e_strlen; unsigned int e_class; unsigned int e_encoding; unsigned int e_version; char *e_ehdr; char *e_phdr; unsigned long e_phnum; struct Elf_Scn { struct Elf_Scn *s_link; struct Elf *s_elf; unsigned long s_index; unsigned int s_scn_flags; unsigned int s_shdr_flags; struct Scn_Data { struct Elf_Data { void *d_buf; enum Elf_Type { ELF_T_BYTE=0, ELF_T_ADDR=1, ELF_T_DYN=2, ELF_T_EHDR=3, ELF_T_HALF=4, ELF_T_OFF=5, ELF_T_PHDR=6, ELF_T_RELA=7, ELF_T_REL=8, ELF_T_SHDR=9, ELF_T_SWORD=10, ELF_T_SYM=11, ELF_T_WORD=12, ELF_T_SXWORD=13, ELF_T_XWORD=14, ELF_T_VDEF=15, ELF_T_VNEED=16, ELF_T_NUM=17 } d_type; unsigned long d_size; long d_off; unsigned long d_align; unsigned int d_version; } sd_data; struct Scn_Data *sd_link; struct Elf_Scn *sd_scn; char *sd_memdata; unsigned int sd_data_flags; unsigned int sd_freeme; unsigned int sd_free_data; long sd_magic; } *s_data_1; struct Scn_Data *s_data_n; struct Scn_Data *s_rawdata; unsigned int s_type; unsigned long s_offset; unsigned long s_size; unsigned int s_freeme; union { 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; } u_shdr64; struct Elf32_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned int sh_flags; unsigned int sh_addr; unsigned int sh_offset; unsigned int sh_size; unsigned int sh_link; unsigned int sh_info; unsigned int sh_addralign; unsigned int sh_entsize; } u_shdr32; } s_uhdr; long s_magic; } *e_scn_1; struct Elf_Scn *e_scn_n; unsigned int e_elf_flags; unsigned int e_ehdr_flags; unsigned int e_phdr_flags; unsigned int e_readable; unsigned int e_writable; unsigned int e_disabled; unsigned int e_cooked; unsigned int e_free_syms; unsigned int e_unmap_data; unsigned int e_memory; long e_magic; } *

return_type: struct Elf_Arhdr { char *ar_name; long ar_date; long ar_uid; long ar_gid; unsigned long ar_mode; long ar_size; char *ar_rawname; } *

user_defined_types: struct Elf_Data { void *d_buf; enum Elf_Type d_type; unsigned long d_size; long d_off; unsigned long d_align; unsigned int d_version; }


decompiled_code:
char *__fastcall elf_errmsg(unsigned int a1)
{
if ( a1 )
{
if ( a1 == -1 )
a1 = elf_errno;
}
else
{
a1 = elf_errno;
if ( !elf_errno )
return 0LL;
}
if ( a1 > 0x4B )
{
a1 = 1;
}
else if ( !messages[a1] )
{
a1 = 1;
}
return messages[a1];
}

canonical_decompiled_code:
char *__fastcall func0(unsigned int a1)
{
if ( a1 )
{
if ( a1 == -1 )
a1 = elf_errno;
}
else
{
a1 = elf_errno;
if ( !elf_errno )
return 0LL;
}
if ( a1 > 0x4B )
{
a1 = 1;
}
else if ( !messages[a1] )
{
a1 = 1;
}
return messages[a1];
}

original_code:
const char*
elf_errmsg(int err) {
    if (err == 0) {
 err = _elf_errno;
 if (err == 0) {
     return ((void *)0);
 }
    }
    else if (err == -1) {
 err = _elf_errno;
    }
    if (err < 0 || err >= ERROR_NUM || _messages[err] == ((void *)0)) {
 err = ERROR_UNKNOWN;
    }
    return _messages[err];
}

canonical_original_code:
char *elf_errmsg(int err) {
    if (err == 0) {
 err = _elf_errno;
 if (err == 0) {
     return ((void *)0);
 }
    }
    else if (err == -1) {
 err = _elf_errno;
    }
    if (err < 0 || err >= ERROR_NUM || _messages[err] == ((void *)0)) {
 err = ERROR_UNKNOWN;
    }
    return _messages[err];
}

variable_types: err int

return_type: char *


original_code:
Elf_Cmd
elf_next(Elf *elf) {
    if (!elf) {
 return ELF_C_NULL;
    }
    do{}while(0);
    if (!elf->e_parent) {
 return ELF_C_NULL;
    }
    do{}while(0);
    do{}while(0);
    elf->e_parent->e_off = elf->e_next;
    if (elf->e_next == elf->e_parent->e_size) {
 return ELF_C_NULL;
    }
    return ELF_C_READ;
}

canonical_original_code:
enum Elf_Cmd elf_next(struct Elf *elf) {
    if (!elf) {
 return ELF_C_NULL;
    }
    do{}while(0);
    if (!elf->e_parent) {
 return ELF_C_NULL;
    }
    do{}while(0);
    do{}while(0);
    elf->e_parent->e_off = elf->e_next;
    if (elf->e_next == elf->e_parent->e_size) {
 return ELF_C_NULL;
    }
    return ELF_C_READ;
}

return_type: enum Elf_Cmd { ELF_C_NULL=0, ELF_C_READ=1, ELF_C_WRITE=2, ELF_C_CLR=3, ELF_C_SET=4, ELF_C_FDDONE=5, ELF_C_FDREAD=6, ELF_C_RDWR=7, ELF_C_NUM=8 }


decompiled_code:
__int64 __fastcall elf32_getphdr(__int64 a1)
{
return elf_getphdr(a1, 1);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
return func0(a1, 1);
}

original_code:
Elf32_Phdr*
elf32_getphdr(Elf *elf) {
    return (Elf32_Phdr*)_elf_getphdr(elf, 1);
}

canonical_original_code:
struct Elf32_Phdr *elf32_getphdr(struct Elf *elf) {
    return (struct Elf32_Phdr *)_elf_getphdr(elf, 1);
}

return_type: struct Elf32_Phdr { unsigned int p_type; unsigned int p_offset; unsigned int p_vaddr; unsigned int p_paddr; unsigned int p_filesz; unsigned int p_memsz; unsigned int p_flags; unsigned int p_align; } *


decompiled_code:
__int64 __fastcall elf64_getphdr(__int64 a1)
{
return elf_getphdr(a1, 2);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
return func0(a1, 2);
}

original_code:
Elf64_Phdr*
elf64_getphdr(Elf *elf) {
    return (Elf64_Phdr*)_elf_getphdr(elf, 2);
}

canonical_original_code:
struct Elf64_Phdr *elf64_getphdr(struct Elf *elf) {
    return (struct Elf64_Phdr *)_elf_getphdr(elf, 2);
}

return_type: 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:
int
gelf_update_ehdr(Elf *elf, GElf_Ehdr *src) {
    char *tmp;
    if (!elf || !src) {
 return 0;
    }
    do{}while(0);
    tmp = _elf_getehdr(elf, elf->e_class);
    if (!tmp) {
 return 0;
    }
    if (elf->e_class == 2) {
 *(Elf64_Ehdr*)tmp = *src;
    }
    else if (elf->e_class == 1) {
 Elf32_Ehdr *dst = (Elf32_Ehdr*)tmp;
 bcopy(src->e_ident,dst->e_ident,(16));
 do { if (sizeof((dst)->e_type) < sizeof((src)->e_type) && (Elf32_Half)(src)->e_type != (src)->e_type) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_type = (Elf32_Half)(src)->e_type; } while (0);
 do { if (sizeof((dst)->e_machine) < sizeof((src)->e_machine) && (Elf32_Half)(src)->e_machine != (src)->e_machine) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_machine = (Elf32_Half)(src)->e_machine; } while (0);
 do { if (sizeof((dst)->e_version) < sizeof((src)->e_version) && (Elf32_Word)(src)->e_version != (src)->e_version) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_version = (Elf32_Word)(src)->e_version; } while (0);
 do { if (sizeof((dst)->e_entry) < sizeof((src)->e_entry) && (Elf32_Addr)(src)->e_entry != (src)->e_entry) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_entry = (Elf32_Addr)(src)->e_entry; } while (0);
 do { if (sizeof((dst)->e_phoff) < sizeof((src)->e_phoff) && (Elf32_Off)(src)->e_phoff != (src)->e_phoff) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_phoff = (Elf32_Off)(src)->e_phoff; } while (0);
 do { if (sizeof((dst)->e_shoff) < sizeof((src)->e_shoff) && (Elf32_Off)(src)->e_shoff != (src)->e_shoff) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_shoff = (Elf32_Off)(src)->e_shoff; } while (0);
 do { if (sizeof((dst)->e_flags) < sizeof((src)->e_flags) && (Elf32_Word)(src)->e_flags != (src)->e_flags) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_flags = (Elf32_Word)(src)->e_flags; } while (0);
 do { if (sizeof((dst)->e_ehsize) < sizeof((src)->e_ehsize) && (Elf32_Half)(src)->e_ehsize != (src)->e_ehsize) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_ehsize = (Elf32_Half)(src)->e_ehsize; } while (0);
 do { if (sizeof((dst)->e_phentsize) < sizeof((src)->e_phentsize) && (Elf32_Half)(src)->e_phentsize != (src)->e_phentsize) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_phentsize = (Elf32_Half)(src)->e_phentsize; } while (0);
 do { if (sizeof((dst)->e_phnum) < sizeof((src)->e_phnum) && (Elf32_Half)(src)->e_phnum != (src)->e_phnum) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_phnum = (Elf32_Half)(src)->e_phnum; } while (0);
 do { if (sizeof((dst)->e_shentsize) < sizeof((src)->e_shentsize) && (Elf32_Half)(src)->e_shentsize != (src)->e_shentsize) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_shentsize = (Elf32_Half)(src)->e_shentsize; } while (0);
 do { if (sizeof((dst)->e_shnum) < sizeof((src)->e_shnum) && (Elf32_Half)(src)->e_shnum != (src)->e_shnum) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_shnum = (Elf32_Half)(src)->e_shnum; } while (0);
 do { if (sizeof((dst)->e_shstrndx) < sizeof((src)->e_shstrndx) && (Elf32_Half)(src)->e_shstrndx != (src)->e_shstrndx) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_shstrndx = (Elf32_Half)(src)->e_shstrndx; } while (0);
    }
    else {
 if (((elf->e_class) >= 1 && (elf->e_class) <= 2)) {
     (_elf_errno = (ERROR_UNIMPLEMENTED));
 }
 else {
     (_elf_errno = (ERROR_UNKNOWN_CLASS));
 }
 return 0;
    }
    return 1;
}

canonical_original_code:
int gelf_update_ehdr(struct Elf *elf, struct Elf64_Ehdr *src) {
    char *tmp;
    if (!elf || !src) {
 return 0;
    }
    do{}while(0);
    tmp = _elf_getehdr(elf, elf->e_class);
    if (!tmp) {
 return 0;
    }
    if (elf->e_class == 2) {
 *(struct Elf64_Ehdr *)tmp = *src;
    }
    else if (elf->e_class == 1) {
 struct Elf32_Ehdr *dst = (Elf32_Ehdr*)tmp;
 bcopy(src->e_ident,dst->e_ident,(16));
 do { if (sizeof((dst)->e_type) < sizeof((src)->e_type) && (Elf32_Half)(src)->e_type != (src)->e_type) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_type = (Elf32_Half)(src)->e_type; } while (0);
 do { if (sizeof((dst)->e_machine) < sizeof((src)->e_machine) && (Elf32_Half)(src)->e_machine != (src)->e_machine) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_machine = (Elf32_Half)(src)->e_machine; } while (0);
 do { if (sizeof((dst)->e_version) < sizeof((src)->e_version) && (Elf32_Word)(src)->e_version != (src)->e_version) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_version = (Elf32_Word)(src)->e_version; } while (0);
 do { if (sizeof((dst)->e_entry) < sizeof((src)->e_entry) && (Elf32_Addr)(src)->e_entry != (src)->e_entry) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_entry = (Elf32_Addr)(src)->e_entry; } while (0);
 do { if (sizeof((dst)->e_phoff) < sizeof((src)->e_phoff) && (Elf32_Off)(src)->e_phoff != (src)->e_phoff) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_phoff = (Elf32_Off)(src)->e_phoff; } while (0);
 do { if (sizeof((dst)->e_shoff) < sizeof((src)->e_shoff) && (Elf32_Off)(src)->e_shoff != (src)->e_shoff) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_shoff = (Elf32_Off)(src)->e_shoff; } while (0);
 do { if (sizeof((dst)->e_flags) < sizeof((src)->e_flags) && (Elf32_Word)(src)->e_flags != (src)->e_flags) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_flags = (Elf32_Word)(src)->e_flags; } while (0);
 do { if (sizeof((dst)->e_ehsize) < sizeof((src)->e_ehsize) && (Elf32_Half)(src)->e_ehsize != (src)->e_ehsize) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_ehsize = (Elf32_Half)(src)->e_ehsize; } while (0);
 do { if (sizeof((dst)->e_phentsize) < sizeof((src)->e_phentsize) && (Elf32_Half)(src)->e_phentsize != (src)->e_phentsize) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_phentsize = (Elf32_Half)(src)->e_phentsize; } while (0);
 do { if (sizeof((dst)->e_phnum) < sizeof((src)->e_phnum) && (Elf32_Half)(src)->e_phnum != (src)->e_phnum) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_phnum = (Elf32_Half)(src)->e_phnum; } while (0);
 do { if (sizeof((dst)->e_shentsize) < sizeof((src)->e_shentsize) && (Elf32_Half)(src)->e_shentsize != (src)->e_shentsize) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_shentsize = (Elf32_Half)(src)->e_shentsize; } while (0);
 do { if (sizeof((dst)->e_shnum) < sizeof((src)->e_shnum) && (Elf32_Half)(src)->e_shnum != (src)->e_shnum) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_shnum = (Elf32_Half)(src)->e_shnum; } while (0);
 do { if (sizeof((dst)->e_shstrndx) < sizeof((src)->e_shstrndx) && (Elf32_Half)(src)->e_shstrndx != (src)->e_shstrndx) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_shstrndx = (Elf32_Half)(src)->e_shstrndx; } while (0);
    }
    else {
 if (((elf->e_class) >= 1 && (elf->e_class) <= 2)) {
     (_elf_errno = (ERROR_UNIMPLEMENTED));
 }
 else {
     (_elf_errno = (ERROR_UNKNOWN_CLASS));
 }
 return 0;
    }
    return 1;
}

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

variable_types:
tmp
char *

variable_types: struct Elf32_Ehdr { unsigned char e_ident[-1]; unsigned short e_type; unsigned short e_machine; unsigned int e_version; unsigned int e_entry; unsigned int e_phoff; unsigned int 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; } *


original_code:
size_t
elf_delscn(Elf *elf, Elf_Scn *scn) {
    Elf_Scn *pscn;
    Scn_Data *sd;
    Scn_Data *tmp;
    size_t index;
    if (!elf || !scn) {
 return 0;
    }
    do{}while(0);
    do{}while(0);
    do{}while(0);
    if (scn->s_elf != elf) {
 (_elf_errno = (ERROR_ELFSCNMISMATCH));
 return 0;
    }
    do{}while(0);
    if (scn == elf->e_scn_1) {
 (_elf_errno = (ERROR_NULLSCN));
 return 0;
    }
    for (pscn = elf->e_scn_1; pscn->s_link; pscn = pscn->s_link) {
 if (pscn->s_link == scn) {
     break;
 }
    }
    if (pscn->s_link != scn) {
 (_elf_errno = (ERROR_ELFSCNMISMATCH));
 return 0;
    }
    if (elf->e_scn_n == scn) {
 elf->e_scn_n = pscn;
    }
    pscn->s_link = scn->s_link;
    index = scn->s_index;
    for (sd = scn->s_data_1; sd; sd = tmp) {
 do{}while(0);
 do{}while(0);
 tmp = sd->sd_link;
 if (sd->sd_free_data && sd->sd_memdata) {
     free(sd->sd_memdata);
 }
 if (sd->sd_freeme) {
     free(sd);
 }
    }
    if ((sd = scn->s_rawdata)) {
 do{}while(0);
 do{}while(0);
 if (sd->sd_free_data && sd->sd_memdata) {
     free(sd->sd_memdata);
 }
 if (sd->sd_freeme) {
     free(sd);
 }
    }
    if (scn->s_freeme) {
 do{}while(0);
 free(scn);
    }
    for (scn = pscn->s_link; scn; scn = scn->s_link) {
 do{}while(0);
 scn->s_index--;
    }
    if (elf->e_class == 1) {
 _elf32_update_shdr(elf, index);
 return index;
    }
    else if (elf->e_class == 2) {
 _elf64_update_shdr(elf, index);
 return index;
    }
    else if (((elf->e_class) >= 1 && (elf->e_class) <= 2)) {
 (_elf_errno = (ERROR_UNIMPLEMENTED));
    }
    else {
 (_elf_errno = (ERROR_UNKNOWN_CLASS));
    }
    return 0;
}

canonical_original_code:
unsigned long elf_delscn(struct Elf *elf, struct Elf_Scn *scn) {
    struct Elf_Scn *pscn;
    struct Scn_Data *sd;
    struct Scn_Data *tmp;
    unsigned long index;
    if (!elf || !scn) {
 return 0;
    }
    do{}while(0);
    do{}while(0);
    do{}while(0);
    if (scn->s_elf != elf) {
 (_elf_errno = (ERROR_ELFSCNMISMATCH));
 return 0;
    }
    do{}while(0);
    if (scn == elf->e_scn_1) {
 (_elf_errno = (ERROR_NULLSCN));
 return 0;
    }
    for (pscn = elf->e_scn_1; pscn->s_link; pscn = pscn->s_link) {
 if (pscn->s_link == scn) {
     break;
 }
    }
    if (pscn->s_link != scn) {
 (_elf_errno = (ERROR_ELFSCNMISMATCH));
 return 0;
    }
    if (elf->e_scn_n == scn) {
 elf->e_scn_n = pscn;
    }
    pscn->s_link = scn->s_link;
    index = scn->s_index;
    for (sd = scn->s_data_1; sd; sd = tmp) {
 do{}while(0);
 do{}while(0);
 tmp = sd->sd_link;
 if (sd->sd_free_data && sd->sd_memdata) {
     free(sd->sd_memdata);
 }
 if (sd->sd_freeme) {
     free(sd);
 }
    }
    if ((sd = scn->s_rawdata)) {
 do{}while(0);
 do{}while(0);
 if (sd->sd_free_data && sd->sd_memdata) {
     free(sd->sd_memdata);
 }
 if (sd->sd_freeme) {
     free(sd);
 }
    }
    if (scn->s_freeme) {
 do{}while(0);
 free(scn);
    }
    for (scn = pscn->s_link; scn; scn = scn->s_link) {
 do{}while(0);
 scn->s_index--;
    }
    if (elf->e_class == 1) {
 _elf32_update_shdr(elf, index);
 return index;
    }
    else if (elf->e_class == 2) {
 _elf64_update_shdr(elf, index);
 return index;
    }
    else if (((elf->e_class) >= 1 && (elf->e_class) <= 2)) {
 (_elf_errno = (ERROR_UNIMPLEMENTED));
    }
    else {
 (_elf_errno = (ERROR_UNKNOWN_CLASS));
    }
    return 0;
}

variable_types:
scn
struct Elf_Scn *

variable_types: struct Elf_Scn { struct Elf_Scn *s_link; struct Elf { unsigned long e_size; unsigned long e_dsize; enum Elf_Kind { ELF_K_NONE=0, ELF_K_AR=1, ELF_K_COFF=2, ELF_K_ELF=3, ELF_K_NUM=4 } e_kind; char *e_data; char *e_rawdata; unsigned long e_idlen; int e_fd; unsigned int e_count; struct Elf *e_parent; unsigned long e_next; unsigned long e_base; struct Elf *e_link; struct Elf_Arhdr { char *ar_name; long ar_date; long ar_uid; long ar_gid; unsigned long ar_mode; long ar_size; char *ar_rawname; } *e_arhdr; unsigned long e_off; struct Elf *e_members; char *e_symtab; unsigned long e_symlen; char *e_strtab; unsigned long e_strlen; unsigned int e_class; unsigned int e_encoding; unsigned int e_version; char *e_ehdr; char *e_phdr; unsigned long e_phnum; struct Elf_Scn *e_scn_1; struct Elf_Scn *e_scn_n; unsigned int e_elf_flags; unsigned int e_ehdr_flags; unsigned int e_phdr_flags; unsigned int e_readable; unsigned int e_writable; unsigned int e_disabled; unsigned int e_cooked; unsigned int e_free_syms; unsigned int e_unmap_data; unsigned int e_memory; long e_magic; } *s_elf; unsigned long s_index; unsigned int s_scn_flags; unsigned int s_shdr_flags; struct Scn_Data { struct Elf_Data { void *d_buf; enum Elf_Type { ELF_T_BYTE=0, ELF_T_ADDR=1, ELF_T_DYN=2, ELF_T_EHDR=3, ELF_T_HALF=4, ELF_T_OFF=5, ELF_T_PHDR=6, ELF_T_RELA=7, ELF_T_REL=8, ELF_T_SHDR=9, ELF_T_SWORD=10, ELF_T_SYM=11, ELF_T_WORD=12, ELF_T_SXWORD=13, ELF_T_XWORD=14, ELF_T_VDEF=15, ELF_T_VNEED=16, ELF_T_NUM=17 } d_type; unsigned long d_size; long d_off; unsigned long d_align; unsigned int d_version; } sd_data; struct Scn_Data *sd_link; struct Elf_Scn *sd_scn; char *sd_memdata; unsigned int sd_data_flags; unsigned int sd_freeme; unsigned int sd_free_data; long sd_magic; } *s_data_1; struct Scn_Data *s_data_n; struct Scn_Data *s_rawdata; unsigned int s_type; unsigned long s_offset; unsigned long s_size; unsigned int s_freeme; union { 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; } u_shdr64; struct Elf32_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned int sh_flags; unsigned int sh_addr; unsigned int sh_offset; unsigned int sh_size; unsigned int sh_link; unsigned int sh_info; unsigned int sh_addralign; unsigned int sh_entsize; } u_shdr32; } s_uhdr; long s_magic; } *

variable_types: struct Scn_Data { struct Elf_Data { void *d_buf; enum Elf_Type { ELF_T_BYTE=0, ELF_T_ADDR=1, ELF_T_DYN=2, ELF_T_EHDR=3, ELF_T_HALF=4, ELF_T_OFF=5, ELF_T_PHDR=6, ELF_T_RELA=7, ELF_T_REL=8, ELF_T_SHDR=9, ELF_T_SWORD=10, ELF_T_SYM=11, ELF_T_WORD=12, ELF_T_SXWORD=13, ELF_T_XWORD=14, ELF_T_VDEF=15, ELF_T_VNEED=16, ELF_T_NUM=17 } d_type; unsigned long d_size; long d_off; unsigned long d_align; unsigned int d_version; } sd_data; struct Scn_Data *sd_link; struct Elf_Scn { struct Elf_Scn *s_link; struct Elf { unsigned long e_size; unsigned long e_dsize; enum Elf_Kind { ELF_K_NONE=0, ELF_K_AR=1, ELF_K_COFF=2, ELF_K_ELF=3, ELF_K_NUM=4 } e_kind; char *e_data; char *e_rawdata; unsigned long e_idlen; int e_fd; unsigned int e_count; struct Elf *e_parent; unsigned long e_next; unsigned long e_base; struct Elf *e_link; struct Elf_Arhdr { char *ar_name; long ar_date; long ar_uid; long ar_gid; unsigned long ar_mode; long ar_size; char *ar_rawname; } *e_arhdr; unsigned long e_off; struct Elf *e_members; char *e_symtab; unsigned long e_symlen; char *e_strtab; unsigned long e_strlen; unsigned int e_class; unsigned int e_encoding; unsigned int e_version; char *e_ehdr; char *e_phdr; unsigned long e_phnum; struct Elf_Scn *e_scn_1; struct Elf_Scn *e_scn_n; unsigned int e_elf_flags; unsigned int e_ehdr_flags; unsigned int e_phdr_flags; unsigned int e_readable; unsigned int e_writable; unsigned int e_disabled; unsigned int e_cooked; unsigned int e_free_syms; unsigned int e_unmap_data; unsigned int e_memory; long e_magic; } *s_elf; unsigned long s_index; unsigned int s_scn_flags; unsigned int s_shdr_flags; struct Scn_Data *s_data_1; struct Scn_Data *s_data_n; struct Scn_Data *s_rawdata; unsigned int s_type; unsigned long s_offset; unsigned long s_size; unsigned int s_freeme; union { 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; } u_shdr64; struct Elf32_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned int sh_flags; unsigned int sh_addr; unsigned int sh_offset; unsigned int sh_size; unsigned int sh_link; unsigned int sh_info; unsigned int sh_addralign; unsigned int sh_entsize; } u_shdr32; } s_uhdr; long s_magic; } *sd_scn; char *sd_memdata; unsigned int sd_data_flags; unsigned int sd_freeme; unsigned int sd_free_data; long sd_magic; } *

variable_types:
index
unsigned long

return_type: unsigned long


decompiled_code:
__int64 elf_errno()
{
unsigned int v0; // edx

v0 = elf_errno;
elf_errno = 0;
return v0;
}

canonical_decompiled_code:
__int64 func0()
{
unsigned int v0; // edx

v0 = elf_errno;
elf_errno = 0;
return v0;
}

original_code:
int
elf_errno(void) {
    int tmp = _elf_errno;
    _elf_errno = 0;
    return tmp;
}

canonical_original_code:
int elf_errno() {
    int tmp = _elf_errno;
    _elf_errno = 0;
    return tmp;
}

variable_types: tmp int


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

if ( !a1 )
return -1LL;
v1 = *(_QWORD *)(a1 + 56);
if ( v1 )
result = *(_QWORD *)(a1 + 72) - 60LL - *(_QWORD *)(v1 + 72);
else
result = -1LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
__int64 v1; // rdx
__int64 result; // rax

if ( !a1 )
return -1LL;
v1 = *(_QWORD *)(a1 + 56);
if ( v1 )
result = *(_QWORD *)(a1 + 72) - 60LL - *(_QWORD *)(v1 + 72);
else
result = -1LL;
return result;
}

original_code:
off_t
elf_getaroff(Elf *elf) {
    Elf *ref;
    if (!elf) {
 return (off_t)-1;
    }
    do{}while(0);
    if (!(ref = elf->e_parent)) {
 return (off_t)-1;
    }
    do{}while(0);
    do{}while(0);
    return (off_t)(elf->e_base - ref->e_base - sizeof(struct ar_hdr));
}

canonical_original_code:
long elf_getaroff(struct Elf *elf) {
    struct Elf *ref;
    if (!elf) {
 return (off_t)-1;
    }
    do{}while(0);
    if (!(ref = elf->e_parent)) {
 return (off_t)-1;
    }
    do{}while(0);
    do{}while(0);
    return (off_t)(elf->e_base - ref->e_base - sizeof(struct ar_hdr));
}

user_defined_types: struct ar_hdr { char ar_name[16]; char ar_date[12]; char ar_uid[6]; char ar_gid[6]; char ar_mode[8]; char ar_size[10]; char ar_fmag[2]; }


decompiled_code:
__int64 __fastcall elf_rawfile(__int64 a1, char *a2)
{
char *v2; // rbp
char v3; // al
__int64 result; // rax
char v5; // [rsp+8h] [rbp-20h] BYREF

v2 = a2;
if ( !a2 )
v2 = &v5;
*(_QWORD *)v2 = 0LL;
if ( !a1 )
return 0LL;
v3 = *(_BYTE *)(a1 + 212);
if ( (v3 & 1) == 0 )
return 0LL;
if ( !*(_QWORD *)a1 )
return *(_QWORD *)(a1 + 32);
if ( *(_QWORD *)(a1 + 32) )
{
LABEL_7:
*(_QWORD *)v2 = *(_QWORD *)a1;
return *(_QWORD *)(a1 + 32);
}
if ( (v3 & 8) == 0 )
{
*(_QWORD *)(a1 + 32) = *(_QWORD *)(a1 + 24);
goto LABEL_7;
}
result = elf_read(a1, 0LL, 0LL);
*(_QWORD *)(a1 + 32) = result;
if ( result )
goto LABEL_7;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, char *a2)
{
char *v2; // rbp
char v3; // al
__int64 result; // rax
char v5; // [rsp+8h] [rbp-20h] BYREF

v2 = a2;
if ( !a2 )
v2 = &v5;
*(_QWORD *)v2 = 0LL;
if ( !a1 )
return 0LL;
v3 = *(_BYTE *)(a1 + 212);
if ( (v3 & 1) == 0 )
return 0LL;
if ( !*(_QWORD *)a1 )
return *(_QWORD *)(a1 + 32);
if ( *(_QWORD *)(a1 + 32) )
{
LABEL_7:
*(_QWORD *)v2 = *(_QWORD *)a1;
return *(_QWORD *)(a1 + 32);
}
if ( (v3 & 8) == 0 )
{
*(_QWORD *)(a1 + 32) = *(_QWORD *)(a1 + 24);
goto LABEL_7;
}
result = elf_read(a1, 0LL, 0LL);
*(_QWORD *)(a1 + 32) = result;
if ( result )
goto LABEL_7;
return result;
}

original_code:
char*
elf_rawfile(Elf *elf, size_t *ptr) {
    size_t tmp;
    if (!ptr) {
 ptr = &tmp;
    }
    *ptr = 0;
    if (!elf) {
 return ((void *)0);
    }
    do{}while(0);
    if (!elf->e_readable) {
 return ((void *)0);
    }
    else if (elf->e_size) {
 if (!elf->e_rawdata) {
     do{}while(0);
     if (!elf->e_cooked) {
  elf->e_rawdata = elf->e_data;
     }
     else if (!(elf->e_rawdata = _elf_read(elf, ((void *)0), 0, elf->e_size))) {
  return ((void *)0);
     }
 }
 *ptr = elf->e_size;
    }
    return elf->e_rawdata;
}

canonical_original_code:
char *elf_rawfile(struct Elf *elf, unsigned long *ptr) {
    unsigned long tmp;
    if (!ptr) {
 ptr = &tmp;
    }
    *ptr = 0;
    if (!elf) {
 return ((void *)0);
    }
    do{}while(0);
    if (!elf->e_readable) {
 return ((void *)0);
    }
    else if (elf->e_size) {
 if (!elf->e_rawdata) {
     do{}while(0);
     if (!elf->e_cooked) {
  elf->e_rawdata = elf->e_data;
     }
     else if (!(elf->e_rawdata = _elf_read(elf, ((void *)0), 0, elf->e_size))) {
  return ((void *)0);
     }
 }
 *ptr = elf->e_size;
    }
    return elf->e_rawdata;
}

variable_types:
ptr
unsigned long *

variable_types:
tmp
unsigned long


original_code:
int
gelf_update_phdr(Elf *elf, int ndx, GElf_Phdr *src) {
    char *tmp;
    size_t n;
    if (!elf || !src) {
 return 0;
    }
    do{}while(0);
    tmp = _elf_getphdr(elf, elf->e_class);
    if (!tmp) {
 return 0;
    }
    if (ndx < 0 || ndx >= elf->e_phnum) {
 (_elf_errno = (ERROR_BADINDEX));
 return 0;
    }
    n = (_elf_fmsize[((elf->e_class))-1][((_elf_version))-0 -1][((ELF_T_PHDR))-ELF_T_BYTE][(0)]);
    if (n == 0) {
 (_elf_errno = (ERROR_UNIMPLEMENTED));
 return 0;
    }
    if (elf->e_class == 2) {
 *(Elf64_Phdr*)(tmp + ndx * n) = *src;
    }
    else if (elf->e_class == 1) {
 Elf32_Phdr *dst = (Elf32_Phdr*)(tmp + ndx * n);
 do { if (sizeof((dst)->p_type) < sizeof((src)->p_type) && (Elf32_Word)(src)->p_type != (src)->p_type) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->p_type = (Elf32_Word)(src)->p_type; } while (0);
 do { if (sizeof((dst)->p_offset) < sizeof((src)->p_offset) && (Elf32_Off)(src)->p_offset != (src)->p_offset) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->p_offset = (Elf32_Off)(src)->p_offset; } while (0);
 do { if (sizeof((dst)->p_vaddr) < sizeof((src)->p_vaddr) && (Elf32_Addr)(src)->p_vaddr != (src)->p_vaddr) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->p_vaddr = (Elf32_Addr)(src)->p_vaddr; } while (0);
 do { if (sizeof((dst)->p_paddr) < sizeof((src)->p_paddr) && (Elf32_Addr)(src)->p_paddr != (src)->p_paddr) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->p_paddr = (Elf32_Addr)(src)->p_paddr; } while (0);
 do { if (sizeof((dst)->p_filesz) < sizeof((src)->p_filesz) && (Elf32_Word)(src)->p_filesz != (src)->p_filesz) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->p_filesz = (Elf32_Word)(src)->p_filesz; } while (0);
 do { if (sizeof((dst)->p_memsz) < sizeof((src)->p_memsz) && (Elf32_Word)(src)->p_memsz != (src)->p_memsz) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->p_memsz = (Elf32_Word)(src)->p_memsz; } while (0);
 do { if (sizeof((dst)->p_flags) < sizeof((src)->p_flags) && (Elf32_Word)(src)->p_flags != (src)->p_flags) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->p_flags = (Elf32_Word)(src)->p_flags; } while (0);
 do { if (sizeof((dst)->p_align) < sizeof((src)->p_align) && (Elf32_Word)(src)->p_align != (src)->p_align) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->p_align = (Elf32_Word)(src)->p_align; } while (0);
    }
    else {
 if (((elf->e_class) >= 1 && (elf->e_class) <= 2)) {
     (_elf_errno = (ERROR_UNIMPLEMENTED));
 }
 else {
     (_elf_errno = (ERROR_UNKNOWN_CLASS));
 }
 return 0;
    }
    return 1;
}

canonical_original_code:
int gelf_update_phdr(struct Elf *elf, int ndx, struct Elf64_Phdr *src) {
    char *tmp;
    unsigned long n;
    if (!elf || !src) {
 return 0;
    }
    do{}while(0);
    tmp = _elf_getphdr(elf, elf->e_class);
    if (!tmp) {
 return 0;
    }
    if (ndx < 0 || ndx >= elf->e_phnum) {
 (_elf_errno = (ERROR_BADINDEX));
 return 0;
    }
    n = (_elf_fmsize[((elf->e_class))-1][((_elf_version))-0 -1][((ELF_T_PHDR))-ELF_T_BYTE][(0)]);
    if (n == 0) {
 (_elf_errno = (ERROR_UNIMPLEMENTED));
 return 0;
    }
    if (elf->e_class == 2) {
 *(struct Elf64_Phdr *)(tmp + ndx * n) = *src;
    }
    else if (elf->e_class == 1) {
 struct Elf32_Phdr *dst = (Elf32_Phdr*)(tmp + ndx * n);
 do { if (sizeof((dst)->p_type) < sizeof((src)->p_type) && (Elf32_Word)(src)->p_type != (src)->p_type) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->p_type = (Elf32_Word)(src)->p_type; } while (0);
 do { if (sizeof((dst)->p_offset) < sizeof((src)->p_offset) && (Elf32_Off)(src)->p_offset != (src)->p_offset) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->p_offset = (Elf32_Off)(src)->p_offset; } while (0);
 do { if (sizeof((dst)->p_vaddr) < sizeof((src)->p_vaddr) && (Elf32_Addr)(src)->p_vaddr != (src)->p_vaddr) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->p_vaddr = (Elf32_Addr)(src)->p_vaddr; } while (0);
 do { if (sizeof((dst)->p_paddr) < sizeof((src)->p_paddr) && (Elf32_Addr)(src)->p_paddr != (src)->p_paddr) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->p_paddr = (Elf32_Addr)(src)->p_paddr; } while (0);
 do { if (sizeof((dst)->p_filesz) < sizeof((src)->p_filesz) && (Elf32_Word)(src)->p_filesz != (src)->p_filesz) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->p_filesz = (Elf32_Word)(src)->p_filesz; } while (0);
 do { if (sizeof((dst)->p_memsz) < sizeof((src)->p_memsz) && (Elf32_Word)(src)->p_memsz != (src)->p_memsz) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->p_memsz = (Elf32_Word)(src)->p_memsz; } while (0);
 do { if (sizeof((dst)->p_flags) < sizeof((src)->p_flags) && (Elf32_Word)(src)->p_flags != (src)->p_flags) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->p_flags = (Elf32_Word)(src)->p_flags; } while (0);
 do { if (sizeof((dst)->p_align) < sizeof((src)->p_align) && (Elf32_Word)(src)->p_align != (src)->p_align) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->p_align = (Elf32_Word)(src)->p_align; } while (0);
    }
    else {
 if (((elf->e_class) >= 1 && (elf->e_class) <= 2)) {
     (_elf_errno = (ERROR_UNIMPLEMENTED));
 }
 else {
     (_elf_errno = (ERROR_UNKNOWN_CLASS));
 }
 return 0;
    }
    return 1;
}

variable_types: ndx int

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

variable_types:
n
unsigned long

variable_types: struct Elf32_Phdr { unsigned int p_type; unsigned int p_offset; unsigned int p_vaddr; unsigned int p_paddr; unsigned int p_filesz; unsigned int p_memsz; unsigned int p_flags; unsigned int p_align; } *


decompiled_code:
void *__fastcall elf32_newphdr(__int64 a1, unsigned __int64 a2)
{
return elf_newphdr(a1, a2, 1);
}

canonical_decompiled_code:
void *__fastcall func1(__int64 a1, unsigned __int64 a2)
{
return func0(a1, a2, 1);
}

original_code:
Elf32_Phdr*
elf32_newphdr(Elf *elf, size_t count) {
    return (Elf32_Phdr*)_elf_newphdr(elf, count, 1);
}

canonical_original_code:
struct Elf32_Phdr *elf32_newphdr(struct Elf *elf, unsigned long count) {
    return (struct Elf32_Phdr *)_elf_newphdr(elf, count, 1);
}

variable_types: struct Elf { unsigned long e_size; unsigned long e_dsize; enum Elf_Kind { ELF_K_NONE=0, ELF_K_AR=1, ELF_K_COFF=2, ELF_K_ELF=3, ELF_K_NUM=4 } e_kind; char *e_data; char *e_rawdata; unsigned long e_idlen; int e_fd; unsigned int e_count; struct Elf *e_parent; unsigned long e_next; unsigned long e_base; struct Elf *e_link; struct Elf_Arhdr { char *ar_name; long ar_date; long ar_uid; long ar_gid; unsigned long ar_mode; long ar_size; char *ar_rawname; } *e_arhdr; unsigned long e_off; struct Elf *e_members; char *e_symtab; unsigned long e_symlen; char *e_strtab; unsigned long e_strlen; unsigned int e_class; unsigned int e_encoding; unsigned int e_version; char *e_ehdr; char *e_phdr; unsigned long e_phnum; struct Elf_Scn { struct Elf_Scn *s_link; struct Elf *s_elf; unsigned long s_index; unsigned int s_scn_flags; unsigned int s_shdr_flags; struct Scn_Data { struct Elf_Data { void *d_buf; enum Elf_Type { ELF_T_BYTE=0, ELF_T_ADDR=1, ELF_T_DYN=2, ELF_T_EHDR=3, ELF_T_HALF=4, ELF_T_OFF=5, ELF_T_PHDR=6, ELF_T_RELA=7, ELF_T_REL=8, ELF_T_SHDR=9, ELF_T_SWORD=10, ELF_T_SYM=11, ELF_T_WORD=12, ELF_T_SXWORD=13, ELF_T_XWORD=14, ELF_T_VDEF=15, ELF_T_VNEED=16, ELF_T_NUM=17 } d_type; unsigned long d_size; long d_off; unsigned long d_align; unsigned int d_version; } sd_data; struct Scn_Data *sd_link; struct Elf_Scn *sd_scn; char *sd_memdata; unsigned int sd_data_flags; unsigned int sd_freeme; unsigned int sd_free_data; long sd_magic; } *s_data_1; struct Scn_Data *s_data_n; struct Scn_Data *s_rawdata; unsigned int s_type; unsigned long s_offset; unsigned long s_size; unsigned int s_freeme; union { 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; } u_shdr64; struct Elf32_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned int sh_flags; unsigned int sh_addr; unsigned int sh_offset; unsigned int sh_size; unsigned int sh_link; unsigned int sh_info; unsigned int sh_addralign; unsigned int sh_entsize; } u_shdr32; } s_uhdr; long s_magic; } *e_scn_1; struct Elf_Scn *e_scn_n; unsigned int e_elf_flags; unsigned int e_ehdr_flags; unsigned int e_phdr_flags; unsigned int e_readable; unsigned int e_writable; unsigned int e_disabled; unsigned int e_cooked; unsigned int e_free_syms; unsigned int e_unmap_data; unsigned int e_memory; long e_magic; } *

variable_types:
count
unsigned long

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


decompiled_code:
void *__fastcall elf64_newphdr(__int64 a1, unsigned __int64 a2)
{
return elf_newphdr(a1, a2, 2);
}

canonical_decompiled_code:
void *__fastcall func2(__int64 a1, unsigned __int64 a2)
{
return func0(a1, a2, 2);
}

original_code:
Elf64_Phdr*
elf64_newphdr(Elf *elf, size_t count) {
    return (Elf64_Phdr*)_elf_newphdr(elf, count, 2);
}

canonical_original_code:
struct Elf64_Phdr *elf64_newphdr(struct Elf *elf, unsigned long count) {
    return (struct Elf64_Phdr *)_elf_newphdr(elf, count, 2);
}

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: enum Elf_Kind { ELF_K_NONE=0, ELF_K_AR=1, ELF_K_COFF=2, ELF_K_ELF=3, ELF_K_NUM=4 }


decompiled_code:
void *__fastcall gelf_newphdr(__int64 a1, unsigned __int64 a2)
{
int v2; // edx

v2 = *(_DWORD *)(a1 + 144);
if ( (unsigned int)(v2 - 1) <= 1 )
return elf_newphdr(a1, a2, v2);
elf_errno = 19;
return 0LL;
}

canonical_decompiled_code:
void *__fastcall func3(__int64 a1, unsigned __int64 a2)
{
int v2; // edx

v2 = *(_DWORD *)(a1 + 144);
if ( (unsigned int)(v2 - 1) <= 1 )
return func0(a1, a2, v2);
elf_errno = 19;
return 0LL;
}

original_code:
unsigned long
gelf_newphdr(Elf *elf, size_t phnum) {
    if (!((elf->e_class) >= 1 && (elf->e_class) <= 2)) {
 (_elf_errno = (ERROR_UNKNOWN_CLASS));
 return 0;
    }
    return (unsigned long)_elf_newphdr(elf, phnum, elf->e_class);
}

canonical_original_code:
unsigned long gelf_newphdr(struct Elf *elf, unsigned long phnum) {
    if (!((elf->e_class) >= 1 && (elf->e_class) <= 2)) {
 (_elf_errno = (ERROR_UNKNOWN_CLASS));
 return 0;
    }
    return (unsigned long)_elf_newphdr(elf, phnum, elf->e_class);
}

variable_types:
phnum
unsigned long

user_defined_types: struct Elf_Arhdr { char *ar_name; long ar_date; long ar_uid; long ar_gid; unsigned long ar_mode; long ar_size; char *ar_rawname; }

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


original_code:
size_t
elfx_remscn(Elf *elf, Elf_Scn *scn) {
    Elf_Scn *pscn;
    Scn_Data *sd;
    Scn_Data *tmp;
    size_t index;
    if (!elf || !scn) {
 return 0;
    }
    do{}while(0);
    if (elf->e_kind != ELF_K_ELF) {
 (_elf_errno = (ERROR_NOTELF));
 return 0;
    }
    do{}while(0);
    do{}while(0);
    if (scn->s_elf != elf) {
 (_elf_errno = (ERROR_ELFSCNMISMATCH));
 return 0;
    }
    do{}while(0);
    if (scn == elf->e_scn_1) {
 (_elf_errno = (ERROR_NULLSCN));
 return 0;
    }
    for (pscn = elf->e_scn_1; pscn->s_link; pscn = pscn->s_link) {
 if (pscn->s_link == scn) {
     break;
 }
    }
    if (pscn->s_link != scn) {
 (_elf_errno = (ERROR_ELFSCNMISMATCH));
 return 0;
    }
    if (elf->e_scn_n == scn) {
 elf->e_scn_n = pscn;
    }
    pscn->s_link = scn->s_link;
    index = scn->s_index;
    for (sd = scn->s_data_1; sd; sd = tmp) {
 do{}while(0);
 do{}while(0);
 tmp = sd->sd_link;
 if (sd->sd_free_data && sd->sd_memdata) {
     free(sd->sd_memdata);
 }
 if (sd->sd_freeme) {
     free(sd);
 }
    }
    if ((sd = scn->s_rawdata)) {
 do{}while(0);
 do{}while(0);
 if (sd->sd_free_data && sd->sd_memdata) {
     free(sd->sd_memdata);
 }
 if (sd->sd_freeme) {
     free(sd);
 }
    }
    if (scn->s_freeme) {
 do{}while(0);
 free(scn);
    }
    for (scn = pscn->s_link; scn; scn = scn->s_link) {
 do{}while(0);
 scn->s_index--;
    }
    if (_elf_update_shnum(elf, elf->e_scn_n->s_index + 1)) {
 return 0;
    }
    return index;
}

canonical_original_code:
unsigned long elfx_remscn(struct Elf *elf, struct Elf_Scn *scn) {
    struct Elf_Scn *pscn;
    struct Scn_Data *sd;
    struct Scn_Data *tmp;
    unsigned long index;
    if (!elf || !scn) {
 return 0;
    }
    do{}while(0);
    if (elf->e_kind != ELF_K_ELF) {
 (_elf_errno = (ERROR_NOTELF));
 return 0;
    }
    do{}while(0);
    do{}while(0);
    if (scn->s_elf != elf) {
 (_elf_errno = (ERROR_ELFSCNMISMATCH));
 return 0;
    }
    do{}while(0);
    if (scn == elf->e_scn_1) {
 (_elf_errno = (ERROR_NULLSCN));
 return 0;
    }
    for (pscn = elf->e_scn_1; pscn->s_link; pscn = pscn->s_link) {
 if (pscn->s_link == scn) {
     break;
 }
    }
    if (pscn->s_link != scn) {
 (_elf_errno = (ERROR_ELFSCNMISMATCH));
 return 0;
    }
    if (elf->e_scn_n == scn) {
 elf->e_scn_n = pscn;
    }
    pscn->s_link = scn->s_link;
    index = scn->s_index;
    for (sd = scn->s_data_1; sd; sd = tmp) {
 do{}while(0);
 do{}while(0);
 tmp = sd->sd_link;
 if (sd->sd_free_data && sd->sd_memdata) {
     free(sd->sd_memdata);
 }
 if (sd->sd_freeme) {
     free(sd);
 }
    }
    if ((sd = scn->s_rawdata)) {
 do{}while(0);
 do{}while(0);
 if (sd->sd_free_data && sd->sd_memdata) {
     free(sd->sd_memdata);
 }
 if (sd->sd_freeme) {
     free(sd);
 }
    }
    if (scn->s_freeme) {
 do{}while(0);
 free(scn);
    }
    for (scn = pscn->s_link; scn; scn = scn->s_link) {
 do{}while(0);
 scn->s_index--;
    }
    if (_elf_update_shnum(elf, elf->e_scn_n->s_index + 1)) {
 return 0;
    }
    return index;
}

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

user_defined_types: enum Elf_Type { ELF_T_BYTE=0, ELF_T_ADDR=1, ELF_T_DYN=2, ELF_T_EHDR=3, ELF_T_HALF=4, ELF_T_OFF=5, ELF_T_PHDR=6, ELF_T_RELA=7, ELF_T_REL=8, ELF_T_SHDR=9, ELF_T_SWORD=10, ELF_T_SYM=11, ELF_T_WORD=12, ELF_T_SXWORD=13, ELF_T_XWORD=14, ELF_T_VDEF=15, ELF_T_VNEED=16, ELF_T_NUM=17 }


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

result = 0LL;
if ( a1 )
result = elf_flag((_DWORD *)(a1 + 72), a2, a3);
return result;
}

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

result = 0LL;
if ( a1 )
result = func0((_DWORD *)(a1 + 72), a2, a3);
return result;
}

original_code:
unsigned
elf_flagdata(Elf_Data *data, Elf_Cmd cmd, unsigned flags) {
    Scn_Data *sd = (Scn_Data*)data;
    if (!sd) {
 return 0;
    }
    do{}while(0);
    return _elf_flag(&sd->sd_data_flags, cmd, flags);
}

canonical_original_code:
unsigned int elf_flagdata(struct Elf_Data *data, enum Elf_Cmd cmd, unsigned int flags) {
    struct Scn_Data *sd = (Scn_Data*)data;
    if (!sd) {
 return 0;
    }
    do{}while(0);
    return _elf_flag(&sd->sd_data_flags, cmd, flags);
}

variable_types: struct Elf_Data { void *d_buf; enum Elf_Type { ELF_T_BYTE=0, ELF_T_ADDR=1, ELF_T_DYN=2, ELF_T_EHDR=3, ELF_T_HALF=4, ELF_T_OFF=5, ELF_T_PHDR=6, ELF_T_RELA=7, ELF_T_REL=8, ELF_T_SHDR=9, ELF_T_SWORD=10, ELF_T_SYM=11, ELF_T_WORD=12, ELF_T_SXWORD=13, ELF_T_XWORD=14, ELF_T_VDEF=15, ELF_T_VNEED=16, ELF_T_NUM=17 } d_type; unsigned long d_size; long d_off; unsigned long d_align; unsigned int d_version; } *

variable_types: enum Elf_Cmd { ELF_C_NULL=0, ELF_C_READ=1, ELF_C_WRITE=2, ELF_C_CLR=3, ELF_C_SET=4, ELF_C_FDDONE=5, ELF_C_FDREAD=6, ELF_C_RDWR=7, ELF_C_NUM=8 }

variable_types:
flags
unsigned int

return_type: unsigned int


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

result = 0LL;
if ( a1 )
result = elf_flag((_DWORD *)(a1 + 204), a2, a3);
return result;
}

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

result = 0LL;
if ( a1 )
result = func0((_DWORD *)(a1 + 204), a2, a3);
return result;
}

original_code:
unsigned
elf_flagehdr(Elf *elf, Elf_Cmd cmd, unsigned flags) {
    if (!elf) {
 return 0;
    }
    do{}while(0);
    return _elf_flag(&elf->e_ehdr_flags, cmd, flags);
}

canonical_original_code:
unsigned int elf_flagehdr(struct Elf *elf, enum Elf_Cmd cmd, unsigned int flags) {
    if (!elf) {
 return 0;
    }
    do{}while(0);
    return _elf_flag(&elf->e_ehdr_flags, cmd, flags);
}

user_defined_types: enum Elf_Cmd { ELF_C_NULL=0, ELF_C_READ=1, ELF_C_WRITE=2, ELF_C_CLR=3, ELF_C_SET=4, ELF_C_FDDONE=5, ELF_C_FDREAD=6, ELF_C_RDWR=7, ELF_C_NUM=8 }


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

result = 0LL;
if ( a1 )
result = elf_flag((_DWORD *)(a1 + 200), a2, a3);
return result;
}

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

result = 0LL;
if ( a1 )
result = func0((_DWORD *)(a1 + 200), a2, a3);
return result;
}

original_code:
unsigned
elf_flagelf(Elf *elf, Elf_Cmd cmd, unsigned flags) {
    if (!elf) {
 return 0;
    }
    do{}while(0);
    return _elf_flag(&elf->e_elf_flags, cmd, flags);
}

canonical_original_code:
unsigned int elf_flagelf(struct Elf *elf, enum Elf_Cmd cmd, unsigned int flags) {
    if (!elf) {
 return 0;
    }
    do{}while(0);
    return _elf_flag(&elf->e_elf_flags, cmd, flags);
}


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

result = 0LL;
if ( a1 )
result = elf_flag((_DWORD *)(a1 + 208), a2, a3);
return result;
}

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

result = 0LL;
if ( a1 )
result = func0((_DWORD *)(a1 + 208), a2, a3);
return result;
}

original_code:
unsigned
elf_flagphdr(Elf *elf, Elf_Cmd cmd, unsigned flags) {
    if (!elf) {
 return 0;
    }
    do{}while(0);
    return _elf_flag(&elf->e_phdr_flags, cmd, flags);
}

canonical_original_code:
unsigned int elf_flagphdr(struct Elf *elf, enum Elf_Cmd cmd, unsigned int flags) {
    if (!elf) {
 return 0;
    }
    do{}while(0);
    return _elf_flag(&elf->e_phdr_flags, cmd, flags);
}


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

result = 0LL;
if ( a1 )
result = elf_flag((_DWORD *)(a1 + 24), a2, a3);
return result;
}

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

result = 0LL;
if ( a1 )
result = func0((_DWORD *)(a1 + 24), a2, a3);
return result;
}

original_code:
unsigned
elf_flagscn(Elf_Scn *scn, Elf_Cmd cmd, unsigned flags) {
    if (!scn) {
 return 0;
    }
    do{}while(0);
    return _elf_flag(&scn->s_scn_flags, cmd, flags);
}

canonical_original_code:
unsigned int elf_flagscn(struct Elf_Scn *scn, enum Elf_Cmd cmd, unsigned int flags) {
    if (!scn) {
 return 0;
    }
    do{}while(0);
    return _elf_flag(&scn->s_scn_flags, cmd, flags);
}


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

result = 0LL;
if ( a1 )
result = elf_flag((_DWORD *)(a1 + 28), a2, a3);
return result;
}

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

result = 0LL;
if ( a1 )
result = func0((_DWORD *)(a1 + 28), a2, a3);
return result;
}

original_code:
unsigned
elf_flagshdr(Elf_Scn *scn, Elf_Cmd cmd, unsigned flags) {
    if (!scn) {
 return 0;
    }
    do{}while(0);
    return _elf_flag(&scn->s_shdr_flags, cmd, flags);
}

canonical_original_code:
unsigned int elf_flagshdr(struct Elf_Scn *scn, enum Elf_Cmd cmd, unsigned int flags) {
    if (!scn) {
 return 0;
    }
    do{}while(0);
    return _elf_flag(&scn->s_shdr_flags, cmd, flags);
}


original_code:
char*
elf_getident(Elf *elf, size_t *ptr) {
    size_t tmp;
    if (!ptr) {
 ptr = &tmp;
    }
    if (!elf) {
 *ptr = 0;
 return ((void *)0);
    }
    do{}while(0);
    if (elf->e_kind != ELF_K_ELF) {
 *ptr = elf->e_idlen;
 return elf->e_data;
    }
    if (elf->e_ehdr || _elf_cook(elf)) {
 *ptr = elf->e_idlen;
 return elf->e_ehdr;
    }
    *ptr = 0;
    return ((void *)0);
}

canonical_original_code:
char *elf_getident(struct Elf *elf, unsigned long *ptr) {
    unsigned long tmp;
    if (!ptr) {
 ptr = &tmp;
    }
    if (!elf) {
 *ptr = 0;
 return ((void *)0);
    }
    do{}while(0);
    if (elf->e_kind != ELF_K_ELF) {
 *ptr = elf->e_idlen;
 return elf->e_data;
    }
    if (elf->e_ehdr || _elf_cook(elf)) {
 *ptr = elf->e_idlen;
 return elf->e_ehdr;
    }
    *ptr = 0;
    return ((void *)0);
}


decompiled_code:
__int64 vfs_open()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func6()
{
return 0LL;
}

original_code:
int vfs_open(const char *pathname, int flags, mode_t mode) {
 return 0;
}

canonical_original_code:
int vfs_open(char *pathname, int flags, unsigned int mode) {
 return 0;
}

variable_types:
pathname
char *

variable_types: flags int

variable_types:
mode
unsigned int


decompiled_code:
__int64 vfs_close()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func7()
{
return 0LL;
}

original_code:
int vfs_close(int fd) {
 return 0;
}

canonical_original_code:
int vfs_close(int fd) {
 return 0;
}

variable_types: fd int