decompiled_code:
__int64 __fastcall yar_port_from_str(_DWORD *a1, const char *a2)
{
unsigned __int64 v2; // rbx
__int64 result; // rax
char *endptr; // [rsp+8h] [rbp-20h] BYREF

if ( !a1 )
_assert_fail("port != NULL", "port.c", 0x3Au, "yar_port_from_str");
if ( !a2 )
_assert_fail("str != NULL", "port.c", 0x3Bu, "yar_port_from_str");
if ( !*a2 )
return 0xFFFFFFFFLL;
v2 = strtoul(a2, &endptr, 10);
if ( *endptr )
return 0xFFFFFFFFLL;
if ( v2 )
{
if ( v2 <= 0xFFFF )
goto LABEL_7;
result = 0xFFFFFFFFLL;
}
else
{
if ( *_errno_location() != 22 )
{
LABEL_7:
*a1 = v2;
return 0LL;
}
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(_DWORD *a1, const char *a2)
{
unsigned __int64 v2; // rbx
__int64 result; // rax
char *endptr; // [rsp+8h] [rbp-20h] BYREF

if ( !a1 )
_assert_fail("port != NULL", "port.c", 0x3Au, "yar_port_from_str");
if ( !a2 )
_assert_fail("str != NULL", "port.c", 0x3Bu, "yar_port_from_str");
if ( !*a2 )
return 0xFFFFFFFFLL;
v2 = strtoul(a2, &endptr, 10);
if ( *endptr )
return 0xFFFFFFFFLL;
if ( v2 )
{
if ( v2 <= 0xFFFF )
goto LABEL_7;
result = 0xFFFFFFFFLL;
}
else
{
if ( *_errno_location() != 22 )
{
LABEL_7:
*a1 = v2;
return 0LL;
}
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int yar_port_from_str(yar_port_t *port, const char *str)
{
    unsigned long tmp;
    char *cptr;
    ((void) sizeof ((port != ((void *)0)) ? 1 : 0), __extension__ ({ if (port != ((void *)0)) ; else __assert_fail ("port != NULL", "port.c", 58, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((str != ((void *)0)) ? 1 : 0), __extension__ ({ if (str != ((void *)0)) ; else __assert_fail ("str != NULL", "port.c", 59, __extension__ __PRETTY_FUNCTION__); }));
    if (str == ((void *)0) || *str == '\0') {
        return -1;
    }
    tmp = strtoul(str, &cptr, 10);
    if (*cptr != '\0') {
        return -1;
    }
    if ((tmp == 0 && (*__errno_location ()) == 22) || tmp > 65535) {
        return -1;
    }
    *port = (yar_port_t)tmp;
    return 0;
}

canonical_original_code:
int yar_port_from_str(unsigned int *port, char *str)
{
    unsigned long tmp;
    char *cptr;
    ((void) sizeof ((port != ((void *)0)) ? 1 : 0), __extension__ ({ if (port != ((void *)0)) ; else __assert_fail ("port != NULL", "port.c", 58, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((str != ((void *)0)) ? 1 : 0), __extension__ ({ if (str != ((void *)0)) ; else __assert_fail ("str != NULL", "port.c", 59, __extension__ __PRETTY_FUNCTION__); }));
    if (str == ((void *)0) || *str == '\0') {
        return -1;
    }
    tmp = strtoul(str, &cptr, 10);
    if (*cptr != '\0') {
        return -1;
    }
    if ((tmp == 0 && (*__errno_location ()) == 22) || tmp > 65535) {
        return -1;
    }
    *port = (unsigned int)tmp;
    return 0;
}

variable_types:
port
unsigned int *

variable_types:
str
char *

variable_types:
tmp
unsigned long

variable_types:
cptr
char *


repo: sebcat/yarlib

decompiled_code:
__int64 __fastcall port_range_init_from_str(_DWORD *a1, const char *a2)
{
char *v2; // rax
const char *v3; // rbp
__int64 result; // rax
int v5; // [rsp+8h] [rbp-120h] BYREF
int v6; // [rsp+Ch] [rbp-11Ch] BYREF
char dest[280]; // [rsp+10h] [rbp-118h] BYREF

strncpy(dest, a2, 0xFFuLL);
dest[255] = 0;
v2 = strchr(dest, 45);
if ( v2 )
{
v3 = v2 + 1;
*v2 = 0;
if ( (unsigned int)yar_port_from_str(&v6, dest) )
{
result = 0xFFFFFFFFLL;
}
else
{
if ( !(unsigned int)yar_port_from_str(&v5, v3) )
{
LABEL_4:
*a1 = v6;
a1[2] = 0;
a1[1] = v5;
return 0LL;
}
result = 0xFFFFFFFFLL;
}
}
else if ( (unsigned int)yar_port_from_str(&v6, dest) )
{
result = 0xFFFFFFFFLL;
}
else
{
if ( !(unsigned int)yar_port_from_str(&v5, dest) )
goto LABEL_4;
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(_DWORD *a1, const char *a2)
{
char *v2; // rax
const char *v3; // rbp
__int64 result; // rax
int v5; // [rsp+8h] [rbp-120h] BYREF
int v6; // [rsp+Ch] [rbp-11Ch] BYREF
char dest[280]; // [rsp+10h] [rbp-118h] BYREF

strncpy(dest, a2, 0xFFuLL);
dest[255] = 0;
v2 = strchr(dest, 45);
if ( v2 )
{
v3 = v2 + 1;
*v2 = 0;
if ( (unsigned int)func1(&v6, dest) )
{
result = 0xFFFFFFFFLL;
}
else
{
if ( !(unsigned int)func1(&v5, v3) )
{
LABEL_4:
*a1 = v6;
a1[2] = 0;
a1[1] = v5;
return 0LL;
}
result = 0xFFFFFFFFLL;
}
}
else if ( (unsigned int)func1(&v6, dest) )
{
result = 0xFFFFFFFFLL;
}
else
{
if ( !(unsigned int)func1(&v5, dest) )
goto LABEL_4;
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
static int port_range_init_from_str(port_range_t *range, const char *rangestr)
{
    char buf[256], *cptr;
    yar_port_t startport, endport;
    strncpy(buf, rangestr, sizeof(buf));
    buf[sizeof(buf)-1] = '\0';
    cptr = strchr(buf, '-');
    if (cptr != ((void *)0)) {
        *cptr++ = '\0';
        if (yar_port_from_str(&startport, buf) != 0 ||
                yar_port_from_str(&endport, cptr) != 0) {
            return -1;
        }
    } else {
        if (yar_port_from_str(&startport, buf) != 0 ||
                yar_port_from_str(&endport, buf) != 0) {
            return -1;
        }
    }
    do { (range)->start = (startport); (range)->offset = 0; (range)->end = (endport); } while(0);;
    return 0;
}

canonical_original_code:
static int port_range_init_from_str(struct port_range_t *range, char *rangestr)
{
    char buf[256]; char *cptr;
    unsigned int startport; unsigned int endport;
    strncpy(buf, rangestr, sizeof(buf));
    buf[sizeof(buf)-1] = '\0';
    cptr = strchr(buf, '-');
    if (cptr != ((void *)0)) {
        *cptr++ = '\0';
        if (yar_port_from_str(&startport, buf) != 0 ||
                yar_port_from_str(&endport, cptr) != 0) {
            return -1;
        }
    } else {
        if (yar_port_from_str(&startport, buf) != 0 ||
                yar_port_from_str(&endport, buf) != 0) {
            return -1;
        }
    }
    do { (range)->start = (startport); (range)->offset = 0; (range)->end = (endport); } while(0);;
    return 0;
}

variable_types: struct port_range_t { unsigned int start; unsigned int offset; } *

variable_types:
rangestr
char *

variable_types:
buf
char [256]

variable_types:
startport
unsigned int

variable_types:
endport
unsigned int

return_type: int


decompiled_code:
int __fastcall yar_port_to_str(unsigned int a1, char *a2, size_t a3)
{
int result; // eax

if ( !a2 )
_assert_fail("dst != NULL", "port.c", 0x50u, "yar_port_to_str");
if ( !a3 )
_assert_fail("dstlen > 0", "port.c", 0x51u, "yar_port_to_str");
result = snprintf(a2, a3, "%u", a1);
a2[a3 - 1] = 0;
return result;
}

canonical_decompiled_code:
int __fastcall func3(unsigned int a1, char *a2, size_t a3)
{
int result; // eax

if ( !a2 )
_assert_fail("dst != NULL", "port.c", 0x50u, "yar_port_to_str");
if ( !a3 )
_assert_fail("dstlen > 0", "port.c", 0x51u, "yar_port_to_str");
result = snprintf(a2, a3, "%u", a1);
a2[a3 - 1] = 0;
return result;
}

original_code:
void yar_port_to_str(const yar_port_t port, char *dst, size_t dstlen)
{
    ((void) sizeof ((dst != ((void *)0)) ? 1 : 0), __extension__ ({ if (dst != ((void *)0)) ; else __assert_fail ("dst != NULL", "port.c", 80, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((dstlen > 0) ? 1 : 0), __extension__ ({ if (dstlen > 0) ; else __assert_fail ("dstlen > 0", "port.c", 81, __extension__ __PRETTY_FUNCTION__); }));
    snprintf(dst, dstlen, "%u", port);
    dst[dstlen-1] = '\0';
}

canonical_original_code:
void yar_port_to_str(unsigned int port, char *dst, unsigned long dstlen)
{
    ((void) sizeof ((dst != ((void *)0)) ? 1 : 0), __extension__ ({ if (dst != ((void *)0)) ; else __assert_fail ("dst != NULL", "port.c", 80, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((dstlen > 0) ? 1 : 0), __extension__ ({ if (dstlen > 0) ; else __assert_fail ("dstlen > 0", "port.c", 81, __extension__ __PRETTY_FUNCTION__); }));
    snprintf(dst, dstlen, "%u", port);
    dst[dstlen-1] = '\0';
}

variable_types:
port
unsigned int

variable_types:
dst
char *

variable_types:
dstlen
unsigned long

return_type: void


decompiled_code:
__int64 __fastcall yar_portspec_next(unsigned __int64 *a1, unsigned int *a2)
{
unsigned __int64 v2; // rax
unsigned int v3; // ebp
unsigned __int64 v4; // rax
unsigned int v6; // eax

if ( !a1 )
_assert_fail("spec != NULL", "port.c", 0xD2u, "yar_portspec_next");
v2 = a1[2];
if ( !v2 )
_assert_fail("spec->ranges != NULL", "port.c", 0xD3u, "yar_portspec_next");
v3 = port_range_next((unsigned int *)(v2 + 12 * a1[1]), a2);
if ( !(_BYTE)v3 )
{
v4 = a1[1] + 1;
a1[1] = v4;
if ( v4 < *a1 && (v6 = port_range_next((unsigned int *)(a1[2] + 12 * v4), a2), (_BYTE)v6) )
v3 = v6;
else
a1[1] = *a1;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned __int64 *a1, unsigned int *a2)
{
unsigned __int64 v2; // rax
unsigned int v3; // ebp
unsigned __int64 v4; // rax
unsigned int v6; // eax

if ( !a1 )
_assert_fail("spec != NULL", "port.c", 0xD2u, "yar_portspec_next");
v2 = a1[2];
if ( !v2 )
_assert_fail("spec->ranges != NULL", "port.c", 0xD3u, "yar_portspec_next");
v3 = func0((unsigned int *)(v2 + 12 * a1[1]), a2);
if ( !(_BYTE)v3 )
{
v4 = a1[1] + 1;
a1[1] = v4;
if ( v4 < *a1 && (v6 = func0((unsigned int *)(a1[2] + 12 * v4), a2), (_BYTE)v6) )
v3 = v6;
else
a1[1] = *a1;
}
return v3;
}

original_code:
_Bool yar_portspec_next(struct portspec_t *spec, yar_port_t *port)
{
    ((void) sizeof ((spec != ((void *)0)) ? 1 : 0), __extension__ ({ if (spec != ((void *)0)) ; else __assert_fail ("spec != NULL", "port.c", 210, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((spec->ranges != ((void *)0)) ? 1 : 0), __extension__ ({ if (spec->ranges != ((void *)0)) ; else __assert_fail ("spec->ranges != NULL", "port.c", 211, __extension__ __PRETTY_FUNCTION__); }));
    if (!port_range_next(&spec->ranges[spec->rangeix], port)) {
        spec->rangeix++;
        if (spec->rangeix >= spec->nranges
                || !port_range_next(&spec->ranges[spec->rangeix], port)) {
            spec->rangeix = spec->nranges;
            return 0;
        }
    }
    return 1;
}

canonical_original_code:
_Bool yar_portspec_next(struct portspec_t *spec, unsigned int *port)
{
    ((void) sizeof ((spec != ((void *)0)) ? 1 : 0), __extension__ ({ if (spec != ((void *)0)) ; else __assert_fail ("spec != NULL", "port.c", 210, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((spec->ranges != ((void *)0)) ? 1 : 0), __extension__ ({ if (spec->ranges != ((void *)0)) ; else __assert_fail ("spec->ranges != NULL", "port.c", 211, __extension__ __PRETTY_FUNCTION__); }));
    if (!port_range_next(&spec->ranges[spec->rangeix], port)) {
        spec->rangeix++;
        if (spec->rangeix >= spec->nranges
                || !port_range_next(&spec->ranges[spec->rangeix], port)) {
            spec->rangeix = spec->nranges;
            return 0;
        }
    }
    return 1;
}

variable_types: struct portspec_t { unsigned long nranges; struct port_range_t { unsigned int start; unsigned int offset; } *ranges; } *

user_defined_types: struct portspec_t { unsigned long nranges; struct port_range_t *ranges; }


decompiled_code:
void __fastcall yar_portspec_reset(unsigned __int64 *a1)
{
__int64 v1; // rdx
unsigned __int64 v2; // rax

if ( !a1 )
_assert_fail("spec != NULL", "port.c", 0xE3u, "yar_portspec_reset");
if ( !a1[2] )
_assert_fail("spec->ranges != NULL", "port.c", 0xE4u, "yar_portspec_reset");
a1[1] = 0LL;
if ( *a1 )
{
v1 = 0LL;
v2 = 0LL;
do
{
*(_DWORD *)(a1[2] + v1 + 8) = 0;
++v2;
v1 += 12LL;
}
while ( *a1 > v2 );
}
}

canonical_decompiled_code:
void __fastcall func5(unsigned __int64 *a1)
{
__int64 v1; // rdx
unsigned __int64 v2; // rax

if ( !a1 )
_assert_fail("spec != NULL", "port.c", 0xE3u, "yar_portspec_reset");
if ( !a1[2] )
_assert_fail("spec->ranges != NULL", "port.c", 0xE4u, "yar_portspec_reset");
a1[1] = 0LL;
if ( *a1 )
{
v1 = 0LL;
v2 = 0LL;
do
{
*(_DWORD *)(a1[2] + v1 + 8) = 0;
++v2;
v1 += 12LL;
}
while ( *a1 > v2 );
}
}

original_code:
void yar_portspec_reset(struct portspec_t *spec)
{
    size_t i;
    ((void) sizeof ((spec != ((void *)0)) ? 1 : 0), __extension__ ({ if (spec != ((void *)0)) ; else __assert_fail ("spec != NULL", "port.c", 227, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((spec->ranges != ((void *)0)) ? 1 : 0), __extension__ ({ if (spec->ranges != ((void *)0)) ; else __assert_fail ("spec->ranges != NULL", "port.c", 228, __extension__ __PRETTY_FUNCTION__); }));
    spec->rangeix = 0;
    for(i=0; i<spec->nranges; i++) {
        spec->ranges[i].offset = 0;
    }
}

canonical_original_code:
void yar_portspec_reset(struct portspec_t *spec)
{
    unsigned long i;
    ((void) sizeof ((spec != ((void *)0)) ? 1 : 0), __extension__ ({ if (spec != ((void *)0)) ; else __assert_fail ("spec != NULL", "port.c", 227, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((spec->ranges != ((void *)0)) ? 1 : 0), __extension__ ({ if (spec->ranges != ((void *)0)) ; else __assert_fail ("spec->ranges != NULL", "port.c", 228, __extension__ __PRETTY_FUNCTION__); }));
    spec->rangeix = 0;
    for(i=0; i<spec->nranges; i++) {
        spec->ranges[i].offset = 0;
    }
}

variable_types:
i
unsigned long

user_defined_types: struct port_range_t { unsigned int start; unsigned int offset; }


decompiled_code:
void __fastcall yar_portspec_free(void *ptr)
{
void *v2; // rdi

if ( ptr )
{
v2 = (void *)*((_QWORD *)ptr + 2);
if ( v2 )
free(v2);
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func6(void *ptr)
{
void *v2; // rdi

if ( ptr )
{
v2 = (void *)*((_QWORD *)ptr + 2);
if ( v2 )
free(v2);
free(ptr);
}
}

original_code:
void yar_portspec_free(struct portspec_t *spec)
{
    if (spec != ((void *)0)) {
        if (spec->ranges != ((void *)0)) {
            free(spec->ranges);
        }
        free(spec);
    }
}


decompiled_code:
bool __fastcall yar_portspec_is_expired(_QWORD *a1)
{
return a1[1] >= *a1;
}

canonical_decompiled_code:
bool __fastcall func7(_QWORD *a1)
{
return a1[1] >= *a1;
}

original_code:
_Bool yar_portspec_is_expired(struct portspec_t *spec)
{
    return (spec->rangeix < spec->nranges) ? 0 : 1;
}


GetType

repo: secmobi/android-utils

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

result = 0LL;
if ( *(_DWORD *)(a1[2] + 64LL) > a2 )
result = GetString(a1, *(_DWORD *)(a1[4] + 4LL * a2));
return result;
}

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

result = 0LL;
if ( *(_DWORD *)(a1[2] + 64LL) > a2 )
result = func0(a1, *(_DWORD *)(a1[4] + 4LL * a2));
return result;
}

original_code:
static char *
GetType(DexFile_t *dex, uint32_t idx)
{
 DexTypeId_t *id;
 if(idx >= dex->header->typeIdsSize)
  return ((void *)0);
 id = dex->typeIds + idx;
 return GetString(dex, id->descriptorIdx);
}

canonical_original_code:
static char *GetType(struct DexFile_t *dex, unsigned int idx)
{
 struct DexTypeId_t *id;
 if(idx >= dex->header->typeIdsSize)
  return ((void *)0);
 id = dex->typeIds + idx;
 return GetString(dex, id->descriptorIdx);
}

variable_types: struct DexFile_t { unsigned char *data; unsigned long len; struct DexHeader_t { unsigned char magic[8]; unsigned int checksum; unsigned char signature[20]; unsigned int fileSize; unsigned int headerSize; unsigned int endianTag; unsigned int linkSize; unsigned int linkOff; unsigned int mapOff; unsigned int stringIdsSize; unsigned int stringIdsOff; unsigned int typeIdsSize; unsigned int typeIdsOff; unsigned int protoIdsSize; unsigned int protoIdsOff; unsigned int fieldIdsSize; unsigned int fieldIdsOff; unsigned int methodIdsSize; unsigned int methodIdsOff; unsigned int classDefsSize; unsigned int classDefsOff; unsigned int dataSize; unsigned int dataOff; } *header; struct DexStringId_t { unsigned int stringDataOff; } *stringIds; struct DexTypeId_t { unsigned int descriptorIdx; } *typeIds; struct DexProtoId_t { unsigned int shortyIdx; unsigned int returnTypeIdx; unsigned int parametersOff; } *protoIds; struct DexFieldId_t { unsigned short classIdx; unsigned short typeIdx; unsigned int nameIdx; } *fieldIds; struct DexMethodId_t { unsigned short classIdx; unsigned short protoIdx; unsigned int nameIdx; } *methodIds; struct DexClassDef_t { unsigned int classIdx; unsigned int accessFlags; unsigned int superclassIdx; unsigned int interfacesOff; unsigned int sourceFileIdx; unsigned int annotationsOff; unsigned int classDataOff; unsigned int staticValuesOff; } *classDefs; struct DexLink_t { unsigned char bleargh; } *linkData; } *

variable_types:
idx
unsigned int

return_type: char *

user_defined_types: struct DexFile_t { unsigned char *data; unsigned long len; struct DexHeader_t *header; struct DexStringId_t *stringIds; struct DexTypeId_t *typeIds; struct DexProtoId_t *protoIds; struct DexFieldId_t *fieldIds; struct DexMethodId_t *methodIds; struct DexClassDef_t *classDefs; struct DexLink_t *linkData; }


GetProtoShorty

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

result = 0LL;
if ( *(_DWORD *)(a1[2] + 72LL) > a2 )
result = GetString(a1, *(_DWORD *)(a1[5] + 12LL * a2));
return result;
}

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

result = 0LL;
if ( *(_DWORD *)(a1[2] + 72LL) > a2 )
result = func0(a1, *(_DWORD *)(a1[5] + 12LL * a2));
return result;
}

original_code:
static char *
GetProtoShorty(DexFile_t *dex, uint32_t idx)
{
 DexProtoId_t *id;
 if(idx >= dex->header->protoIdsSize)
  return ((void *)0);
 id = dex->protoIds + idx;
 return GetString(dex, id->shortyIdx);
}

canonical_original_code:
static char *GetProtoShorty(struct DexFile_t *dex, unsigned int idx)
{
 struct DexProtoId_t *id;
 if(idx >= dex->header->protoIdsSize)
  return ((void *)0);
 id = dex->protoIds + idx;
 return GetString(dex, id->shortyIdx);
}

variable_types: struct DexProtoId_t { unsigned int shortyIdx; unsigned int returnTypeIdx; unsigned int parametersOff; } *

user_defined_types: struct DexHeader_t { unsigned char magic[8]; unsigned int checksum; unsigned char signature[20]; unsigned int fileSize; unsigned int headerSize; unsigned int endianTag; unsigned int linkSize; unsigned int linkOff; unsigned int mapOff; unsigned int stringIdsSize; unsigned int stringIdsOff; unsigned int typeIdsSize; unsigned int typeIdsOff; unsigned int protoIdsSize; unsigned int protoIdsOff; unsigned int fieldIdsSize; unsigned int fieldIdsOff; unsigned int methodIdsSize; unsigned int methodIdsOff; unsigned int classDefsSize; unsigned int classDefsOff; unsigned int dataSize; unsigned int dataOff; }

user_defined_types: struct DexStringId_t { unsigned int stringDataOff; }

user_defined_types: struct DexTypeId_t { unsigned int descriptorIdx; }

user_defined_types: struct DexFieldId_t { unsigned short classIdx; unsigned short typeIdx; unsigned int nameIdx; }

user_defined_types: struct DexMethodId_t { unsigned short classIdx; unsigned short protoIdx; unsigned int nameIdx; }

user_defined_types: struct DexClassDef_t { unsigned int classIdx; unsigned int accessFlags; unsigned int superclassIdx; unsigned int interfacesOff; unsigned int sourceFileIdx; unsigned int annotationsOff; unsigned int classDataOff; unsigned int staticValuesOff; }

user_defined_types: struct DexLink_t { unsigned char bleargh; }


GetProtoReturnType

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

result = 0LL;
if ( *(_DWORD *)(a1[2] + 72LL) > a2 )
result = GetType(a1, *(_DWORD *)(a1[5] + 12LL * a2 + 4));
return result;
}

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

result = 0LL;
if ( *(_DWORD *)(a1[2] + 72LL) > a2 )
result = func1(a1, *(_DWORD *)(a1[5] + 12LL * a2 + 4));
return result;
}

original_code:
static char *
GetProtoReturnType(DexFile_t *dex, uint32_t idx)
{
 DexProtoId_t *id;
 if(idx >= dex->header->protoIdsSize)
  return ((void *)0);
 id = dex->protoIds + idx;
 return GetType(dex, id->returnTypeIdx);
}

canonical_original_code:
static char *GetProtoReturnType(struct DexFile_t *dex, unsigned int idx)
{
 struct DexProtoId_t *id;
 if(idx >= dex->header->protoIdsSize)
  return ((void *)0);
 id = dex->protoIds + idx;
 return GetType(dex, id->returnTypeIdx);
}

user_defined_types: struct DexProtoId_t { unsigned int shortyIdx; unsigned int returnTypeIdx; unsigned int parametersOff; }


GetProtoParameterCount

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

result = 0xFFFFFFFFLL;
if ( *(_DWORD *)(a1[2] + 72LL) > a2 )
{
result = *(unsigned int *)(a1[5] + 12LL * a2 + 8);
if ( result >= a1[1] )
{
result = 0xFFFFFFFFLL;
}
else if ( (_DWORD)result )
{
result = *(unsigned int *)(*a1 + result);
}
}
return result;
}

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

result = 0xFFFFFFFFLL;
if ( *(_DWORD *)(a1[2] + 72LL) > a2 )
{
result = *(unsigned int *)(a1[5] + 12LL * a2 + 8);
if ( result >= a1[1] )
{
result = 0xFFFFFFFFLL;
}
else if ( (_DWORD)result )
{
result = *(unsigned int *)(*a1 + result);
}
}
return result;
}

original_code:
static uint32_t
GetProtoParameterCount(DexFile_t *dex, uint32_t idx)
{
 DexProtoId_t *id;
 DexTypeList_t *para;
 if(idx >= dex->header->protoIdsSize)
  return -1;
 id = dex->protoIds + idx;
 if(id->parametersOff >= dex->len)
  return -1;
 if(id->parametersOff == 0)
  return 0;
 para = (DexTypeList_t *)(dex->data + id->parametersOff);
 return para->size;
}

canonical_original_code:
static unsigned int GetProtoParameterCount(struct DexFile_t *dex, unsigned int idx)
{
 struct DexProtoId_t *id;
 struct DexTypeList_t *para;
 if(idx >= dex->header->protoIdsSize)
  return -1;
 id = dex->protoIds + idx;
 if(id->parametersOff >= dex->len)
  return -1;
 if(id->parametersOff == 0)
  return 0;
 para = (struct DexTypeList_t *)(dex->data + id->parametersOff);
 return para->size;
}

variable_types: struct DexTypeList_t { unsigned int size; struct DexTypeItem_t { unsigned short typeIdx; } list[1]; } *

return_type: unsigned int

user_defined_types: struct DexTypeList_t { unsigned int size; struct DexTypeItem_t list[1]; }


GetProtoParameter

decompiled_code:
unsigned __int64 __fastcall GetProtoParameter(_QWORD *a1, unsigned int a2, unsigned int a3)
{
unsigned __int64 v3; // rax
unsigned int *v4; // rax
unsigned __int64 v5; // rcx

if ( *(_DWORD *)(a1[2] + 72LL) <= a2 )
return 0LL;
v3 = *(unsigned int *)(a1[5] + 12LL * a2 + 8);
if ( v3 >= a1[1] || !*(_DWORD *)(a1[5] + 12LL * a2 + 8) )
return 0LL;
v4 = (unsigned int *)(*a1 + v3);
v5 = 0LL;
if ( *v4 > a3 )
v5 = GetType(a1, *((unsigned __int16 *)v4 + a3 + 2));
return v5;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func5(_QWORD *a1, unsigned int a2, unsigned int a3)
{
unsigned __int64 v3; // rax
unsigned int *v4; // rax
unsigned __int64 v5; // rcx

if ( *(_DWORD *)(a1[2] + 72LL) <= a2 )
return 0LL;
v3 = *(unsigned int *)(a1[5] + 12LL * a2 + 8);
if ( v3 >= a1[1] || !*(_DWORD *)(a1[5] + 12LL * a2 + 8) )
return 0LL;
v4 = (unsigned int *)(*a1 + v3);
v5 = 0LL;
if ( *v4 > a3 )
v5 = func1(a1, *((unsigned __int16 *)v4 + a3 + 2));
return v5;
}

original_code:
static char *
GetProtoParameter(DexFile_t *dex, uint32_t idx, uint32_t n)
{
 DexProtoId_t *id;
 DexTypeList_t *para;
 if(idx >= dex->header->protoIdsSize)
  return ((void *)0);
 id = dex->protoIds + idx;
 if(id->parametersOff >= dex->len)
  return ((void *)0);
 if(id->parametersOff == 0)
  return ((void *)0);
 para = (DexTypeList_t *)(dex->data + id->parametersOff);
 if(n >= para->size)
  return ((void *)0);
 return GetType(dex, para->list[n].typeIdx);
}

canonical_original_code:
static char *GetProtoParameter(struct DexFile_t *dex, unsigned int idx, unsigned int n)
{
 struct DexProtoId_t *id;
 struct DexTypeList_t *para;
 if(idx >= dex->header->protoIdsSize)
  return ((void *)0);
 id = dex->protoIds + idx;
 if(id->parametersOff >= dex->len)
  return ((void *)0);
 if(id->parametersOff == 0)
  return ((void *)0);
 para = (struct DexTypeList_t *)(dex->data + id->parametersOff);
 if(n >= para->size)
  return ((void *)0);
 return GetType(dex, para->list[n].typeIdx);
}

variable_types:
n
unsigned int

user_defined_types: struct DexTypeItem_t { unsigned short typeIdx; }


GetFieldClass

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

result = 0LL;
if ( *(_DWORD *)(a1[2] + 80LL) > a2 )
result = GetType(a1, *(unsigned __int16 *)(a1[6] + 8LL * a2));
return result;
}

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

result = 0LL;
if ( *(_DWORD *)(a1[2] + 80LL) > a2 )
result = func1(a1, *(unsigned __int16 *)(a1[6] + 8LL * a2));
return result;
}

original_code:
static char *
GetFieldClass(DexFile_t *dex, uint32_t idx)
{
 DexFieldId_t *id;
 if(idx >= dex->header->fieldIdsSize)
  return ((void *)0);
 id = dex->fieldIds + idx;
 return GetType(dex, id->classIdx);
}

canonical_original_code:
static char *GetFieldClass(struct DexFile_t *dex, unsigned int idx)
{
 struct DexFieldId_t *id;
 if(idx >= dex->header->fieldIdsSize)
  return ((void *)0);
 id = dex->fieldIds + idx;
 return GetType(dex, id->classIdx);
}

variable_types: struct DexFieldId_t { unsigned short classIdx; unsigned short typeIdx; unsigned int nameIdx; } *


GetFieldType

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

result = 0LL;
if ( *(_DWORD *)(a1[2] + 80LL) > a2 )
result = GetType(a1, *(unsigned __int16 *)(a1[6] + 8LL * a2 + 2));
return result;
}

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

result = 0LL;
if ( *(_DWORD *)(a1[2] + 80LL) > a2 )
result = func1(a1, *(unsigned __int16 *)(a1[6] + 8LL * a2 + 2));
return result;
}

original_code:
static char *
GetFieldType(DexFile_t *dex, uint32_t idx)
{
 DexFieldId_t *id;
 if(idx >= dex->header->fieldIdsSize)
  return ((void *)0);
 id = dex->fieldIds + idx;
 return GetType(dex, id->typeIdx);
}

canonical_original_code:
static char *GetFieldType(struct DexFile_t *dex, unsigned int idx)
{
 struct DexFieldId_t *id;
 if(idx >= dex->header->fieldIdsSize)
  return ((void *)0);
 id = dex->fieldIds + idx;
 return GetType(dex, id->typeIdx);
}


GetFieldName

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

result = 0LL;
if ( *(_DWORD *)(a1[2] + 80LL) > a2 )
result = GetString(a1, *(_DWORD *)(a1[6] + 8LL * a2 + 4));
return result;
}

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

result = 0LL;
if ( *(_DWORD *)(a1[2] + 80LL) > a2 )
result = func0(a1, *(_DWORD *)(a1[6] + 8LL * a2 + 4));
return result;
}

original_code:
static char *
GetFieldName(DexFile_t *dex, uint32_t idx)
{
 DexFieldId_t *id;
 if(idx >= dex->header->fieldIdsSize)
  return ((void *)0);
 id = dex->fieldIds + idx;
 return GetString(dex, id->nameIdx);
}

canonical_original_code:
static char *GetFieldName(struct DexFile_t *dex, unsigned int idx)
{
 struct DexFieldId_t *id;
 if(idx >= dex->header->fieldIdsSize)
  return ((void *)0);
 id = dex->fieldIds + idx;
 return GetString(dex, id->nameIdx);
}


GetMethodName

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

result = 0LL;
if ( *(_DWORD *)(a1[2] + 88LL) > a2 )
result = GetString(a1, *(_DWORD *)(a1[7] + 8LL * a2 + 4));
return result;
}

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

result = 0LL;
if ( *(_DWORD *)(a1[2] + 88LL) > a2 )
result = func0(a1, *(_DWORD *)(a1[7] + 8LL * a2 + 4));
return result;
}

original_code:
static char *
GetMethodName(DexFile_t *dex, uint32_t idx)
{
 DexMethodId_t *id;
 if(idx >= dex->header->methodIdsSize)
  return ((void *)0);
 id = dex->methodIds + idx;
 return GetString(dex, id->nameIdx);
}

canonical_original_code:
static char *GetMethodName(struct DexFile_t *dex, unsigned int idx)
{
 struct DexMethodId_t *id;
 if(idx >= dex->header->methodIdsSize)
  return ((void *)0);
 id = dex->methodIds + idx;
 return GetString(dex, id->nameIdx);
}

variable_types: struct DexMethodId_t { unsigned short classIdx; unsigned short protoIdx; unsigned int nameIdx; } *


GetMethodClass

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

result = 0LL;
if ( *(_DWORD *)(a1[2] + 88LL) > a2 )
result = GetType(a1, *(unsigned __int16 *)(a1[7] + 8LL * a2));
return result;
}

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

result = 0LL;
if ( *(_DWORD *)(a1[2] + 88LL) > a2 )
result = func1(a1, *(unsigned __int16 *)(a1[7] + 8LL * a2));
return result;
}

original_code:
static char *
GetMethodClass(DexFile_t *dex, uint32_t idx)
{
 DexMethodId_t *id;
 if(idx >= dex->header->methodIdsSize)
  return ((void *)0);
 id = dex->methodIds + idx;
 return GetType(dex, id->classIdx);
}

canonical_original_code:
static char *GetMethodClass(struct DexFile_t *dex, unsigned int idx)
{
 struct DexMethodId_t *id;
 if(idx >= dex->header->methodIdsSize)
  return ((void *)0);
 id = dex->methodIds + idx;
 return GetType(dex, id->classIdx);
}


GetMethodProtoId

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

result = 0xFFFFFFFFLL;
if ( *(_DWORD *)(*(_QWORD *)(a1 + 16) + 88LL) > a2 )
result = *(unsigned __int16 *)(*(_QWORD *)(a1 + 56) + 8LL * a2 + 2);
return result;
}

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

result = 0xFFFFFFFFLL;
if ( *(_DWORD *)(*(_QWORD *)(a1 + 16) + 88LL) > a2 )
result = *(unsigned __int16 *)(*(_QWORD *)(a1 + 56) + 8LL * a2 + 2);
return result;
}

original_code:
static uint32_t
GetMethodProtoId(DexFile_t *dex, uint32_t idx)
{
 DexMethodId_t *id;
 if(idx >= dex->header->methodIdsSize)
  return -1;
 id = dex->methodIds + idx;
 return id->protoIdx;
}

canonical_original_code:
static unsigned int GetMethodProtoId(struct DexFile_t *dex, unsigned int idx)
{
 struct DexMethodId_t *id;
 if(idx >= dex->header->methodIdsSize)
  return -1;
 id = dex->methodIds + idx;
 return id->protoIdx;
}


GetClassName

decompiled_code:
void *__fastcall GetClassName(_QWORD *a1, unsigned int a2)
{
void *result; // rax

result = &unk_5DC;
if ( *(_DWORD *)(a1[2] + 96LL) > a2 )
result = (void *)GetType(a1, *(_DWORD *)(a1[8] + 32LL * a2));
return result;
}

canonical_decompiled_code:
void *__fastcall func12(_QWORD *a1, unsigned int a2)
{
void *result; // rax

result = &unk_5DC;
if ( *(_DWORD *)(a1[2] + 96LL) > a2 )
result = (void *)func1(a1, *(_DWORD *)(a1[8] + 32LL * a2));
return result;
}

original_code:
static char *
GetClassName(DexFile_t *dex, uint32_t idx)
{
 DexClassDef_t *def;
 if(idx >= dex->header->classDefsSize)
  return "";
 def = dex->classDefs + idx;
 return GetType(dex, def->classIdx);
}

canonical_original_code:
static char *GetClassName(struct DexFile_t *dex, unsigned int idx)
{
 struct DexClassDef_t *def;
 if(idx >= dex->header->classDefsSize)
  return "";
 def = dex->classDefs + idx;
 return GetType(dex, def->classIdx);
}

variable_types: struct DexClassDef_t { unsigned int classIdx; unsigned int accessFlags; unsigned int superclassIdx; unsigned int interfacesOff; unsigned int sourceFileIdx; unsigned int annotationsOff; unsigned int classDataOff; unsigned int staticValuesOff; } *


DexClose

decompiled_code:
void __fastcall DexClose(void *a1)
{
free(a1);
}

canonical_decompiled_code:
void __fastcall func13(void *a1)
{
free(a1);
}

original_code:
void
DexClose(void *dexFile)
{
 DexFile_t *dex = (DexFile_t *)dexFile;
 free(dex);
}

canonical_original_code:
void DexClose(void *dexFile)
{
 struct DexFile_t *dex = (DexFile_t *)dexFile;
 free(dex);
}

variable_types:
dexFile
void *


DexDumpAll

decompiled_code:
__int64 __fastcall DexDumpAll(_QWORD *a1)
{
unsigned int v1; // ebx
const char *v2; // rax
unsigned int v3; // ebx
const char *v4; // rax
unsigned int v5; // er12
const char *v6; // rax
unsigned int i; // ebx
const char *v8; // rbx
const char *v9; // rax
unsigned int v10; // ebx
const char *v11; // r13
const char *v12; // r12
const char *v13; // rax
__int64 result; // rax
unsigned int v15; // ebx
unsigned int v16; // eax
const char *v17; // r13
const char *v18; // r12
const char *v19; // rax

if ( *(_DWORD *)(a1[2] + 56LL) )
{
v1 = 0;
do
{
v2 = (const char *)GetString(a1, v1);
printf("string[%u] = %s\n", v1++, v2);
}
while ( *(_DWORD *)(a1[2] + 56LL) > v1 );
}
if ( *(_DWORD *)(a1[2] + 64LL) )
{
v3 = 0;
do
{
v4 = (const char *)GetType(a1, v3);
printf("type[%u] = %s\n", v3++, v4);
}
while ( *(_DWORD *)(a1[2] + 64LL) > v3 );
}
if ( *(_DWORD *)(a1[2] + 72LL) )
{
v5 = 0;
do
{
v8 = (const char *)GetProtoReturnType(a1, v5);
v9 = (const char *)GetProtoShorty(a1, v5);
printf("proto[%u] = %s, ret = %s, ", v5, v9, v8);
for ( i = 0; (unsigned int)GetProtoParameterCount(a1, v5) > i; printf("para[%u] = %s, ", i, v6) )
v6 = (const char *)GetProtoParameter(a1, v5, i++);
putchar(10);
++v5;
}
while ( *(_DWORD *)(a1[2] + 72LL) > v5 );
}
if ( *(_DWORD *)(a1[2] + 80LL) )
{
v10 = 0;
do
{
v11 = (const char *)GetFieldType(a1, v10);
v12 = (const char *)GetFieldName(a1, v10);
v13 = (const char *)GetFieldClass(a1, v10);
printf("field[%u] = %s -> %s (%s)\n", v10++, v13, v12, v11);
}
while ( *(_DWORD *)(a1[2] + 80LL) > v10 );
}
result = a1[2];
if ( *(_DWORD *)(result + 88) )
{
v15 = 0;
do
{
v16 = GetMethodProtoId((__int64)a1, v15);
v17 = (const char *)GetProtoShorty(a1, v16);
v18 = (const char *)GetMethodName(a1, v15);
v19 = (const char *)GetMethodClass(a1, v15);
printf("method[%u] = %s -> %s (%s)\n", v15++, v19, v18, v17);
result = a1[2];
}
while ( *(_DWORD *)(result + 88) > v15 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func14(_QWORD *a1)
{
unsigned int v1; // ebx
const char *v2; // rax
unsigned int v3; // ebx
const char *v4; // rax
unsigned int v5; // er12
const char *v6; // rax
unsigned int i; // ebx
const char *v8; // rbx
const char *v9; // rax
unsigned int v10; // ebx
const char *v11; // r13
const char *v12; // r12
const char *v13; // rax
__int64 result; // rax
unsigned int v15; // ebx
unsigned int v16; // eax
const char *v17; // r13
const char *v18; // r12
const char *v19; // rax

if ( *(_DWORD *)(a1[2] + 56LL) )
{
v1 = 0;
do
{
v2 = (const char *)func0(a1, v1);
printf("string[%u] = %s\n", v1++, v2);
}
while ( *(_DWORD *)(a1[2] + 56LL) > v1 );
}
if ( *(_DWORD *)(a1[2] + 64LL) )
{
v3 = 0;
do
{
v4 = (const char *)func1(a1, v3);
printf("type[%u] = %s\n", v3++, v4);
}
while ( *(_DWORD *)(a1[2] + 64LL) > v3 );
}
if ( *(_DWORD *)(a1[2] + 72LL) )
{
v5 = 0;
do
{
v8 = (const char *)func3(a1, v5);
v9 = (const char *)func2(a1, v5);
printf("proto[%u] = %s, ret = %s, ", v5, v9, v8);
for ( i = 0; (unsigned int)func4(a1, v5) > i; printf("para[%u] = %s, ", i, v6) )
v6 = (const char *)func5(a1, v5, i++);
putchar(10);
++v5;
}
while ( *(_DWORD *)(a1[2] + 72LL) > v5 );
}
if ( *(_DWORD *)(a1[2] + 80LL) )
{
v10 = 0;
do
{
v11 = (const char *)func7(a1, v10);
v12 = (const char *)func8(a1, v10);
v13 = (const char *)func6(a1, v10);
printf("field[%u] = %s -> %s (%s)\n", v10++, v13, v12, v11);
}
while ( *(_DWORD *)(a1[2] + 80LL) > v10 );
}
result = a1[2];
if ( *(_DWORD *)(result + 88) )
{
v15 = 0;
do
{
v16 = func11((__int64)a1, v15);
v17 = (const char *)func2(a1, v16);
v18 = (const char *)func9(a1, v15);
v19 = (const char *)func10(a1, v15);
printf("method[%u] = %s -> %s (%s)\n", v15++, v19, v18, v17);
result = a1[2];
}
while ( *(_DWORD *)(result + 88) > v15 );
}
return result;
}

original_code:
void
DexDumpAll(void *dexFile)
{
 DexFile_t *dex = (DexFile_t *)dexFile;
 uint32_t i;
 for(i = 0; i < dex->header->stringIdsSize; i++)
  printf("string[%u] = %s\n", i, GetString(dex, i));
 for(i = 0; i < dex->header->typeIdsSize; i++)
  printf("type[%u] = %s\n", i, GetType(dex, i));
 for(i = 0; i < dex->header->protoIdsSize; i++)
 {
  uint32_t j;
  printf("proto[%u] = %s, ret = %s, ",
    i,
    GetProtoShorty(dex, i),
    GetProtoReturnType(dex, i));
  for(j = 0; j < GetProtoParameterCount(dex, i); j++)
   printf("para[%u] = %s, ", j+1, GetProtoParameter(dex, i, j));
  printf("\n");
 }
 for(i = 0; i < dex->header->fieldIdsSize; i++)
  printf("field[%u] = %s -> %s (%s)\n",
    i,
    GetFieldClass(dex, i),
    GetFieldName(dex, i),
    GetFieldType(dex, i));
 for(i = 0; i < dex->header->methodIdsSize; i++)
  printf("method[%u] = %s -> %s (%s)\n",
    i,
    GetMethodClass(dex, i),
    GetMethodName(dex, i),
    GetProtoShorty(dex, GetMethodProtoId(dex, i)));
}

canonical_original_code:
void DexDumpAll(void *dexFile)
{
 struct DexFile_t *dex = (DexFile_t *)dexFile;
 unsigned int i;
 for(i = 0; i < dex->header->stringIdsSize; i++)
  printf("string[%u] = %s\n", i, GetString(dex, i));
 for(i = 0; i < dex->header->typeIdsSize; i++)
  printf("type[%u] = %s\n", i, GetType(dex, i));
 for(i = 0; i < dex->header->protoIdsSize; i++)
 {
  unsigned int j;
  printf("proto[%u] = %s, ret = %s, ",
    i,
    GetProtoShorty(dex, i),
    GetProtoReturnType(dex, i));
  for(j = 0; j < GetProtoParameterCount(dex, i); j++)
   printf("para[%u] = %s, ", j+1, GetProtoParameter(dex, i, j));
  printf("\n");
 }
 for(i = 0; i < dex->header->fieldIdsSize; i++)
  printf("field[%u] = %s -> %s (%s)\n",
    i,
    GetFieldClass(dex, i),
    GetFieldName(dex, i),
    GetFieldType(dex, i));
 for(i = 0; i < dex->header->methodIdsSize; i++)
  printf("method[%u] = %s -> %s (%s)\n",
    i,
    GetMethodClass(dex, i),
    GetMethodName(dex, i),
    GetProtoShorty(dex, GetMethodProtoId(dex, i)));
}

variable_types:
i
unsigned int

variable_types:
j
unsigned int


DexDumpString

decompiled_code:
__int64 __fastcall DexDumpString(_QWORD *a1)
{
__int64 result; // rax
unsigned int v2; // ebx
const char *v3; // rax

result = a1[2];
if ( *(_DWORD *)(result + 56) )
{
v2 = 0;
do
{
v3 = (const char *)GetString(a1, v2);
puts(v3);
++v2;
result = a1[2];
}
while ( *(_DWORD *)(result + 56) > v2 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func15(_QWORD *a1)
{
__int64 result; // rax
unsigned int v2; // ebx
const char *v3; // rax

result = a1[2];
if ( *(_DWORD *)(result + 56) )
{
v2 = 0;
do
{
v3 = (const char *)func0(a1, v2);
puts(v3);
++v2;
result = a1[2];
}
while ( *(_DWORD *)(result + 56) > v2 );
}
return result;
}

original_code:
void
DexDumpString(void *dexFile)
{
 DexFile_t *dex = (DexFile_t *)dexFile;
 uint32_t i;
 for(i = 0; i < dex->header->stringIdsSize; i++)
  printf("%s\n", GetString(dex, i));
}

canonical_original_code:
void DexDumpString(void *dexFile)
{
 struct DexFile_t *dex = (DexFile_t *)dexFile;
 unsigned int i;
 for(i = 0; i < dex->header->stringIdsSize; i++)
  printf("%s\n", GetString(dex, i));
}


DexDumpClass

decompiled_code:
__int64 __fastcall DexDumpClass(_QWORD *a1)
{
__int64 result; // rax
unsigned int v2; // ebx
const char *v3; // rax

result = a1[2];
if ( *(_DWORD *)(result + 96) )
{
v2 = 0;
do
{
v3 = (const char *)GetClassName(a1, v2);
puts(v3);
++v2;
result = a1[2];
}
while ( *(_DWORD *)(result + 96) > v2 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func16(_QWORD *a1)
{
__int64 result; // rax
unsigned int v2; // ebx
const char *v3; // rax

result = a1[2];
if ( *(_DWORD *)(result + 96) )
{
v2 = 0;
do
{
v3 = (const char *)func12(a1, v2);
puts(v3);
++v2;
result = a1[2];
}
while ( *(_DWORD *)(result + 96) > v2 );
}
return result;
}

original_code:
void
DexDumpClass(void *dexFile)
{
 DexFile_t *dex = (DexFile_t *)dexFile;
 uint32_t i;
 for(i = 0; i < dex->header->classDefsSize; i++)
  printf("%s\n", GetClassName(dex, i));
}

canonical_original_code:
void DexDumpClass(void *dexFile)
{
 struct DexFile_t *dex = (DexFile_t *)dexFile;
 unsigned int i;
 for(i = 0; i < dex->header->classDefsSize; i++)
  printf("%s\n", GetClassName(dex, i));
}


DexDumpMethod

decompiled_code:
__int64 __fastcall DexDumpMethod(_QWORD *a1)
{
__int64 result; // rax
unsigned int v2; // ebx
unsigned int v3; // eax
const char *v4; // r13
const char *v5; // r12
const char *v6; // rax

result = a1[2];
if ( *(_DWORD *)(result + 88) )
{
v2 = 0;
do
{
v3 = GetMethodProtoId((__int64)a1, v2);
v4 = (const char *)GetProtoShorty(a1, v3);
v5 = (const char *)GetMethodName(a1, v2);
v6 = (const char *)GetMethodClass(a1, v2);
printf("%s %s (%s)\n", v6, v5, v4);
++v2;
result = a1[2];
}
while ( *(_DWORD *)(result + 88) > v2 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func17(_QWORD *a1)
{
__int64 result; // rax
unsigned int v2; // ebx
unsigned int v3; // eax
const char *v4; // r13
const char *v5; // r12
const char *v6; // rax

result = a1[2];
if ( *(_DWORD *)(result + 88) )
{
v2 = 0;
do
{
v3 = func11((__int64)a1, v2);
v4 = (const char *)func2(a1, v3);
v5 = (const char *)func9(a1, v2);
v6 = (const char *)func10(a1, v2);
printf("%s %s (%s)\n", v6, v5, v4);
++v2;
result = a1[2];
}
while ( *(_DWORD *)(result + 88) > v2 );
}
return result;
}

original_code:
void
DexDumpMethod(void *dexFile)
{
 DexFile_t *dex = (DexFile_t *)dexFile;
 uint32_t i;
 for(i = 0; i < dex->header->methodIdsSize; i++)
  printf("%s %s (%s)\n",
    GetMethodClass(dex, i),
    GetMethodName(dex, i),
    GetProtoShorty(dex, GetMethodProtoId(dex, i)));
}

canonical_original_code:
void DexDumpMethod(void *dexFile)
{
 struct DexFile_t *dex = (DexFile_t *)dexFile;
 unsigned int i;
 for(i = 0; i < dex->header->methodIdsSize; i++)
  printf("%s %s (%s)\n",
    GetMethodClass(dex, i),
    GetMethodName(dex, i),
    GetProtoShorty(dex, GetMethodProtoId(dex, i)));
}


GetString

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

if ( *(_DWORD *)(a1[2] + 56LL) <= a2 )
return 0LL;
v2 = *(unsigned int *)(a1[3] + 4LL * a2);
if ( v2 >= a1[1] )
return 0LL;
result = *a1 + v2;
do
++result;
while ( *(char *)(result - 1) < 0 );
return result;
}

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

if ( *(_DWORD *)(a1[2] + 56LL) <= a2 )
return 0LL;
v2 = *(unsigned int *)(a1[3] + 4LL * a2);
if ( v2 >= a1[1] )
return 0LL;
result = *a1 + v2;
do
++result;
while ( *(char *)(result - 1) < 0 );
return result;
}

original_code:
static char *
GetString(DexFile_t *dex, uint32_t idx)
{
 DexStringId_t *id;
 unsigned char *p;
 if(idx >= dex->header->stringIdsSize)
  return ((void *)0);
 id = dex->stringIds + idx;
 if(id->stringDataOff >= dex->len)
  return ((void *)0);
 p = dex->data + id->stringDataOff;
 while (*(p++) > 0x7f)
  ;
 return (char *)p;
}

canonical_original_code:
static char *GetString(struct DexFile_t *dex, unsigned int idx)
{
 struct DexStringId_t *id;
 unsigned char *p;
 if(idx >= dex->header->stringIdsSize)
  return ((void *)0);
 id = dex->stringIds + idx;
 if(id->stringDataOff >= dex->len)
  return ((void *)0);
 p = dex->data + id->stringDataOff;
 while (*(p++) > 0x7f)
  ;
 return (char *)p;
}

variable_types: struct DexStringId_t { unsigned int stringDataOff; } *

variable_types:
p
unsigned char *


decompiled_code:
__int64 __fastcall Adler32Checksum(unsigned __int8 *a1, __int64 a2)
{
unsigned int v2; // edx
unsigned int v3; // eax
unsigned __int8 *v4; // rcx
unsigned __int8 *v5; // rsi

v2 = 0;
v3 = 1;
if ( a2 )
{
v3 = *a1 + 1;
v4 = a1 + 1;
v5 = &a1[a2];
v2 = 0;
while ( 1 )
{
for ( v2 += v3; v2 > 0xFFF0; v2 -= 65521 )
;
if ( v4 == v5 )
break;
for ( v3 += *v4; v3 > 0xFFF0; v3 -= 65521 )
;
++v4;
}
}
return (v2 << 16) | v3;
}

original_code:
uint32_t
Adler32Checksum(unsigned char *data, size_t len)
{
 uint32_t a = 1, b = 0;
 size_t i;
 for(i = 0; i < len; i++)
 {
  a += data[i];
  while(a >= 65521) a -= 65521;
  b += a;
  while(b >= 65521) b -= 65521;
 }
 return (b<<16)|a;
}

canonical_original_code:
unsigned int Adler32Checksum(unsigned char *data, unsigned long len)
{
 unsigned int a = 1; unsigned int b = 0;
 unsigned long i;
 for(i = 0; i < len; i++)
 {
  a += data[i];
  while(a >= 65521) a -= 65521;
  b += a;
  while(b >= 65521) b -= 65521;
 }
 return (b<<16)|a;
}

variable_types:
data
unsigned char *

variable_types:
len
unsigned long

variable_types:
a
unsigned int

variable_types:
b
unsigned int


original_code:
uint32_t
ReadULEB128(unsigned char **data)
{
 uint32_t result = 0;
 unsigned char *ptr = *data;
 int i;
 for(i = 0; i < 4; i++)
 {
  int cur = *(ptr++);
  result |= (cur & 0x7f) << (i*7);
  if(cur < 0x80)
   break;
 }
 *data = ptr;
 return result;
}

canonical_original_code:
unsigned int ReadULEB128(unsigned char **data)
{
 unsigned int result = 0;
 unsigned char *ptr = *data;
 int i;
 for(i = 0; i < 4; i++)
 {
  int cur = *(ptr++);
  result |= (cur & 0x7f) << (i*7);
  if(cur < 0x80)
   break;
 }
 *data = ptr;
 return result;
}

variable_types:
data
unsigned char **

variable_types:
result
unsigned int

variable_types:
ptr
unsigned char *

variable_types: i int

variable_types: cur int


repo: secularbird/blogcnsrc

decompiled_code:
__int64 __fastcall recv_fd(int a1)
{
__int64 result; // rax
struct cmsghdr *v2; // rsi
__int64 v3[3]; // [rsp+0h] [rbp-78h] BYREF
char v4; // [rsp+1Fh] [rbp-59h] BYREF
__int64 v5[2]; // [rsp+20h] [rbp-58h] BYREF
struct msghdr message; // [rsp+30h] [rbp-48h] BYREF

message.msg_name = 0LL;
*(_QWORD *)&message.msg_namelen = 0LL;
*(_QWORD *)&message.msg_flags = 0LL;
v3[0] = 0LL;
v3[1] = 0LL;
v3[2] = 0LL;
v5[0] = (__int64)&v4;
v5[1] = 1LL;
message.msg_iov = (iovec *)v5;
message.msg_iovlen = 1LL;
message.msg_control = v3;
message.msg_controllen = 24LL;
if ( recvmsg(a1, &message, 0) < 0 )
return 0xFFFFFFFFLL;
if ( v4 != 70 )
return 0xFFFFFFFFLL;
if ( (message.msg_flags & 8) != 0 )
return 0xFFFFFFFFLL;
result = 0xFFFFFFFFLL;
if ( message.msg_controllen > 0xF )
{
v2 = (struct cmsghdr *)message.msg_control;
if ( message.msg_control )
{
while ( *(_QWORD *)&v2->cmsg_level != 0x100000001LL )
{
v2 = __cmsg_nxthdr(&message, v2);
if ( !v2 )
return 0xFFFFFFFFLL;
}
result = *(unsigned int *)v2->__cmsg_data;
}
else
{
result = 0xFFFFFFFFLL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(int a1)
{
__int64 result; // rax
struct cmsghdr *v2; // rsi
__int64 v3[3]; // [rsp+0h] [rbp-78h] BYREF
char v4; // [rsp+1Fh] [rbp-59h] BYREF
__int64 v5[2]; // [rsp+20h] [rbp-58h] BYREF
struct msghdr message; // [rsp+30h] [rbp-48h] BYREF

message.msg_name = 0LL;
*(_QWORD *)&message.msg_namelen = 0LL;
*(_QWORD *)&message.msg_flags = 0LL;
v3[0] = 0LL;
v3[1] = 0LL;
v3[2] = 0LL;
v5[0] = (__int64)&v4;
v5[1] = 1LL;
message.msg_iov = (iovec *)v5;
message.msg_iovlen = 1LL;
message.msg_control = v3;
message.msg_controllen = 24LL;
if ( recvmsg(a1, &message, 0) < 0 )
return 0xFFFFFFFFLL;
if ( v4 != 70 )
return 0xFFFFFFFFLL;
if ( (message.msg_flags & 8) != 0 )
return 0xFFFFFFFFLL;
result = 0xFFFFFFFFLL;
if ( message.msg_controllen > 0xF )
{
v2 = (struct cmsghdr *)message.msg_control;
if ( message.msg_control )
{
while ( *(_QWORD *)&v2->cmsg_level != 0x100000001LL )
{
v2 = __cmsg_nxthdr(&message, v2);
if ( !v2 )
return 0xFFFFFFFFLL;
}
result = *(unsigned int *)v2->__cmsg_data;
}
else
{
result = 0xFFFFFFFFLL;
}
}
return result;
}

original_code:
int recv_fd(int socket)
{
 int sent_fd, available_ancillary_element_buffer_space;
 struct msghdr socket_message;
 struct iovec io_vector[1];
 struct cmsghdr *control_message = ((void *)0);
 char message_buffer[1];
 char ancillary_element_buffer[((((sizeof(int)) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1)) + (((sizeof (struct cmsghdr)) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1)))];
 memset(&socket_message, 0, sizeof(struct msghdr));
 memset(ancillary_element_buffer, 0, ((((sizeof(int)) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1)) + (((sizeof (struct cmsghdr)) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1))));
 io_vector[0].iov_base = message_buffer;
 io_vector[0].iov_len = 1;
 socket_message.msg_iov = io_vector;
 socket_message.msg_iovlen = 1;
 socket_message.msg_control = ancillary_element_buffer;
 socket_message.msg_controllen = ((((sizeof(int)) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1)) + (((sizeof (struct cmsghdr)) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1)));
 if(recvmsg(socket, &socket_message, 0) < 0)
  return -1;
 if(message_buffer[0] != 'F')
 {
  return -1;
 }
 if((socket_message.msg_flags & MSG_CTRUNC) == MSG_CTRUNC)
 {
  return -1;
 }
 for(control_message = ((size_t) (&socket_message)->msg_controllen >= sizeof (struct cmsghdr) ? (struct cmsghdr *) (&socket_message)->msg_control : (struct cmsghdr *) 0);
 control_message != ((void *)0);
 control_message = __cmsg_nxthdr (&socket_message, control_message))
 {
  if( (control_message->cmsg_level == 1) &&
   (control_message->cmsg_type == SCM_RIGHTS) )
  {
   sent_fd = *((int *) ((control_message)->__cmsg_data));
   return sent_fd;
  }
 }
 return -1;
}

canonical_original_code:
int recv_fd(int socket)
{
 int sent_fd; int available_ancillary_element_buffer_space;
 struct msghdr socket_message;
 struct iovec io_vector[1];
 struct cmsghdr *control_message = ((void *)0);
 char message_buffer[1];
 char ancillary_element_buffer[-1];
 memset(&socket_message, 0, sizeof(struct msghdr));
 memset(ancillary_element_buffer, 0, ((((sizeof(int)) + sizeof (unsigned long) - 1) & (unsigned long) ~(sizeof (unsigned long) - 1)) + (((sizeof (struct cmsghdr)) + sizeof (unsigned long) - 1) & (unsigned long) ~(sizeof (unsigned long) - 1))));
 io_vector[0].iov_base = message_buffer;
 io_vector[0].iov_len = 1;
 socket_message.msg_iov = io_vector;
 socket_message.msg_iovlen = 1;
 socket_message.msg_control = ancillary_element_buffer;
 socket_message.msg_controllen = ((((sizeof(int)) + sizeof (unsigned long) - 1) & (unsigned long) ~(sizeof (unsigned long) - 1)) + (((sizeof (struct cmsghdr)) + sizeof (unsigned long) - 1) & (unsigned long) ~(sizeof (unsigned long) - 1)));
 if(recvmsg(socket, &socket_message, 0) < 0)
  return -1;
 if(message_buffer[0] != 'F')
 {
  return -1;
 }
 if((socket_message.msg_flags & MSG_CTRUNC) == MSG_CTRUNC)
 {
  return -1;
 }
 for(control_message = ((unsigned long) (&socket_message)->msg_controllen >= sizeof (struct cmsghdr) ? (struct cmsghdr *) (&socket_message)->msg_control : (struct cmsghdr *) 0);
 control_message != ((void *)0);
 control_message = __cmsg_nxthdr (&socket_message, control_message))
 {
  if( (control_message->cmsg_level == 1) &&
   (control_message->cmsg_type == SCM_RIGHTS) )
  {
   sent_fd = *((int *) ((control_message)->__cmsg_data));
   return sent_fd;
  }
 }
 return -1;
}

variable_types: socket int

variable_types: struct msghdr { void *msg_name; unsigned int msg_namelen; struct iovec { void *iov_base; unsigned long iov_len; } *msg_iov; unsigned long msg_iovlen; void *msg_control; unsigned long msg_controllen; int msg_flags; }

variable_types: struct iovec { void *iov_base; unsigned long iov_len; } [1]

variable_types: struct cmsghdr { unsigned long cmsg_len; int cmsg_level; int cmsg_type; unsigned char __cmsg_data[]; } *

user_defined_types: struct msghdr { void *msg_name; unsigned int msg_namelen; struct iovec *msg_iov; unsigned long msg_iovlen; void *msg_control; unsigned long msg_controllen; int msg_flags; }


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax
int v4; // ebx
int v5; // ebp
__int64 v6; // r12
struct sockaddr v8; // [rsp+0h] [rbp-88h] BYREF
_BYTE v9[88]; // [rsp+10h] [rbp-78h] BYREF
int v10; // [rsp+68h] [rbp-20h]
__int16 v11; // [rsp+6Ch] [rbp-1Ch]

v3 = socket(1, 1, 0);
if ( v3 < 0 )
{
perror("socket() failed\n");
v5 = 1;
}
else
{
v4 = v3;
memset(v9, 0, sizeof(v9));
v10 = 0;
v11 = 0;
v8.sa_family = 1;
strcpy(v8.sa_data, "./demo_socket");
v5 = connect(v3, &v8, 0x6Eu);
if ( v5 )
{
perror("connect() failed\n");
v5 = 1;
}
else
{
v6 = (unsigned int)recv_fd(v4);
printf("recevied fd is %d\n", v6);
sleep(0xAu);
write(v6, "This is from client", 0x14uLL);
close(v4);
}
}
return v5;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax
int v4; // ebx
int v5; // ebp
__int64 v6; // r12
struct sockaddr v8; // [rsp+0h] [rbp-88h] BYREF
_BYTE v9[88]; // [rsp+10h] [rbp-78h] BYREF
int v10; // [rsp+68h] [rbp-20h]
__int16 v11; // [rsp+6Ch] [rbp-1Ch]

v3 = socket(1, 1, 0);
if ( v3 < 0 )
{
perror("socket() failed\n");
v5 = 1;
}
else
{
v4 = v3;
memset(v9, 0, sizeof(v9));
v10 = 0;
v11 = 0;
v8.sa_family = 1;
strcpy(v8.sa_data, "./demo_socket");
v5 = connect(v3, &v8, 0x6Eu);
if ( v5 )
{
perror("connect() failed\n");
v5 = 1;
}
else
{
v6 = (unsigned int)func7(v4);
printf("recevied fd is %d\n", v6);
sleep(0xAu);
write(v6, "This is from client", 0x14uLL);
close(v4);
}
}
return v5;
}

original_code:
int main (int argc, char const *argv[])
{
 struct sockaddr_un server_address;
 int socket_fd;
 int rev_fd = -1;
 char *buffer = "This is from client";
 socket_fd = socket(1, SOCK_STREAM, 0);
 if(socket_fd < 0)
 {
  perror("socket() failed\n");
  return 1;
 }
 memset(&server_address, 0, sizeof(struct sockaddr_un));
 server_address.sun_family = 1;
 snprintf(server_address.sun_path, sizeof(server_address.sun_path), "./demo_socket");
 if(connect(socket_fd, (struct sockaddr *) &server_address, sizeof(struct sockaddr_un)) != 0)
 {
  perror("connect() failed\n");
  return 1;
 }
 rev_fd = recv_fd(socket_fd);
 printf("recevied fd is %d\n",rev_fd);
 sleep(10);
 write(rev_fd, buffer, strlen(buffer)+1);
 close(socket_fd);
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
 struct sockaddr_un server_address;
 int socket_fd;
 int rev_fd = -1;
 char *buffer = "This is from client";
 socket_fd = socket(1, SOCK_STREAM, 0);
 if(socket_fd < 0)
 {
  perror("socket() failed\n");
  return 1;
 }
 memset(&server_address, 0, sizeof(struct sockaddr_un));
 server_address.sun_family = 1;
 snprintf(server_address.sun_path, sizeof(server_address.sun_path), "./demo_socket");
 if(connect(socket_fd, (struct sockaddr *) &server_address, sizeof(struct sockaddr_un)) != 0)
 {
  perror("connect() failed\n");
  return 1;
 }
 rev_fd = recv_fd(socket_fd);
 printf("recevied fd is %d\n",rev_fd);
 sleep(10);
 write(rev_fd, buffer, strlen(buffer)+1);
 close(socket_fd);
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: struct sockaddr_un { unsigned short sun_family; char sun_path[108]; }

variable_types:
buffer
char *

user_defined_types: struct sockaddr { unsigned short sa_family; char sa_data[14]; }


signalhandler

decompiled_code:
__sighandler_t __fastcall signalhandler(int sig)
{
int v1; // eax
int v2; // ebp
char **v3; // rax
char **v4; // r13
const char **v5; // rbx
const char **v6; // rbp
void *v8[37]; // [rsp+0h] [rbp-128h] BYREF

printf("signal revived [%d]\n", (unsigned int)sig);
v1 = backtrace(v8, 32);
if ( v1 )
{
v2 = v1;
v3 = backtrace_symbols(v8, v1);
v4 = v3;
if ( v2 > 0 )
{
v5 = (const char **)v3;
v6 = (const char **)&v3[v2];
do
puts(*v5++);
while ( v5 != v6 );
}
}
else
{
puts("fail to get backtrace");
v4 = backtrace_symbols(v8, 0);
}
free(v4);
_Unwind_Backtrace((_Unwind_Trace_Fn)handler, 0LL);
return signal(sig, 0LL);
}

canonical_decompiled_code:
__sighandler_t __fastcall func8(int sig)
{
int v1; // eax
int v2; // ebp
char **v3; // rax
char **v4; // r13
const char **v5; // rbx
const char **v6; // rbp
void *v8[37]; // [rsp+0h] [rbp-128h] BYREF

printf("signal revived [%d]\n", (unsigned int)sig);
v1 = backtrace(v8, 32);
if ( v1 )
{
v2 = v1;
v3 = backtrace_symbols(v8, v1);
v4 = v3;
if ( v2 > 0 )
{
v5 = (const char **)v3;
v6 = (const char **)&v3[v2];
do
puts(*v5++);
while ( v5 != v6 );
}
}
else
{
puts("fail to get backtrace");
v4 = backtrace_symbols(v8, 0);
}
free(v4);
_Unwind_Backtrace((_Unwind_Trace_Fn)handler, 0LL);
return signal(sig, 0LL);
}

original_code:
void signalhandler(int sig)
{
    printf("signal revived [%d]\n", sig);
    enum {
        MAX_STACK = 32,
    };
    void *stack[MAX_STACK];
    int size = backtrace(stack, MAX_STACK);
    if(size == 0) {
        printf("fail to get backtrace\n");
    }
    char** strs = backtrace_symbols(stack, size);
    int i = 0;
    for (i = 0; i < size; ++i) {
        printf("%s\n", strs[i]);
    }
    free(strs);
 _Unwind_Backtrace(&handler, ((void *)0));
    signal(sig, ((__sighandler_t) 0));
}

canonical_original_code:
void signalhandler(int sig)
{
    printf("signal revived [%d]\n", sig);
    enum {
        MAX_STACK = 32,
    };
    void *stack[-1];
    int size = backtrace(stack, MAX_STACK);
    if(size == 0) {
        printf("fail to get backtrace\n");
    }
    char **strs = backtrace_symbols(stack, size);
    int i = 0;
    for (i = 0; i < size; ++i) {
        printf("%s\n", strs[i]);
    }
    free(strs);
 _Unwind_Backtrace(&handler, ((void *)0));
    signal(sig, ((void (*)(int)) 0));
}

variable_types: sig int

variable_types:
stack
void *[-1]

variable_types: size int

variable_types:
strs
char **


addsignalstack

decompiled_code:
void __fastcall addsignalstack(void *a1)
{
struct sigaltstack v1; // [rsp+0h] [rbp-28h] BYREF

if ( !a1 )
__assert_fail("stack!=NULL", "mybacktrace.h", 0x39u, "addsignalstack");
v1.ss_sp = a1;
v1.ss_size = 0x2000LL;
v1.ss_flags = 0;
if ( sigaltstack(&v1, 0LL) < 0 )
perror("sig stack setting failed");
}

canonical_decompiled_code:
void __fastcall func9(void *a1)
{
struct sigaltstack v1; // [rsp+0h] [rbp-28h] BYREF

if ( !a1 )
__assert_fail("stack!=NULL", "mybacktrace.h", 0x39u, "addsignalstack");
v1.ss_sp = a1;
v1.ss_size = 0x2000LL;
v1.ss_flags = 0;
if ( sigaltstack(&v1, 0LL) < 0 )
perror("sig stack setting failed");
}

original_code:
void addsignalstack(char *stack, int size)
{
 ((void) sizeof ((stack!=((void *)0)) ? 1 : 0), __extension__ ({ if (stack!=((void *)0)) ; else __assert_fail ("stack!=NULL", "mybacktrace.h", 57, __extension__ __PRETTY_FUNCTION__); }));
    stack_t sigstack;
    sigstack.ss_sp = stack;
    sigstack.ss_size = 8192;
    sigstack.ss_flags = 0;
    if (sigaltstack(&sigstack, 0) < 0) {
        perror("sig stack setting failed");
    }
}

canonical_original_code:
void addsignalstack(char *stack, int size)
{
 ((void) sizeof ((stack!=((void *)0)) ? 1 : 0), __extension__ ({ if (stack!=((void *)0)) ; else __assert_fail ("stack!=NULL", "mybacktrace.h", 57, __extension__ __PRETTY_FUNCTION__); }));
    struct stack_t sigstack;
    sigstack.ss_sp = stack;
    sigstack.ss_size = 8192;
    sigstack.ss_flags = 0;
    if (sigaltstack(&sigstack, 0) < 0) {
        perror("sig stack setting failed");
    }
}

variable_types:
stack
char *

variable_types: struct stack_t { void *ss_sp; int ss_flags; unsigned long ss_size; }


registersignal

decompiled_code:
void registersignal()
{
struct sigaction v0; // [rsp+0h] [rbp-A8h] BYREF

v0.sa_handler = (__sighandler_t)signalhandler;
v0.sa_flags = 402653184;
if ( sigaction(11, &v0, 0LL) < 0 )
perror("sigaction failed\n");
if ( sigaction(7, &v0, 0LL) < 0 )
perror("sigaction failed\n");
if ( sigaction(4, &v0, 0LL) < 0 )
perror("sigaction failed\n");
if ( sigaction(6, &v0, 0LL) < 0 )
perror("sigaction failed\n");
}

canonical_decompiled_code:
void func10()
{
struct sigaction v0; // [rsp+0h] [rbp-A8h] BYREF

v0.sa_handler = (__sighandler_t)signalhandler;
v0.sa_flags = 402653184;
if ( sigaction(11, &v0, 0LL) < 0 )
perror("sigaction failed\n");
if ( sigaction(7, &v0, 0LL) < 0 )
perror("sigaction failed\n");
if ( sigaction(4, &v0, 0LL) < 0 )
perror("sigaction failed\n");
if ( sigaction(6, &v0, 0LL) < 0 )
perror("sigaction failed\n");
}

original_code:
void registersignal()
{
    struct sigaction act;
    act.__sigaction_handler.sa_handler = signalhandler;
    act.sa_flags = 0x08000000|0x10000000;
    int ret = sigaction(11, &act, ((void *)0));
    if (ret < 0) {
        perror("sigaction failed\n");
    }
    ret = sigaction(7, &act, ((void *)0));
    if (ret < 0) {
        perror("sigaction failed\n");
    }
    ret = sigaction(4, &act, ((void *)0));
    if (ret < 0) {
        perror("sigaction failed\n");
    }
    ret = sigaction(6, &act, ((void *)0));
    if (ret < 0) {
        perror("sigaction failed\n");
    }
}

variable_types: struct sigaction { union { void (*sa_handler)(int); void (*sa_sigaction)(int, struct siginfo_t { int si_signo; int si_errno; int si_code; int __pad0; union { int _pad[-1]; struct { int si_pid; unsigned int si_uid; } _kill; struct { int si_tid; int si_overrun; union sigval { int sival_int; void *sival_ptr; } si_sigval; } _timer; struct { int si_pid; unsigned int si_uid; union sigval si_sigval; } _rt; struct { int si_pid; unsigned int si_uid; int si_status; long si_utime; long si_stime; } _sigchld; struct { void *si_addr; short si_addr_lsb; union { struct { void *_lower; void *_upper; } _addr_bnd; unsigned int _pkey; } _bounds; } _sigfault; struct { long si_band; int si_fd; } _sigpoll; struct { void *_call_addr; int _syscall; unsigned int _arch; } _sigsys; } _sifields; } *, void *); } __sigaction_handler; struct __sigset_t { unsigned long __val[-1]; } sa_mask; int sa_flags; void (*sa_restorer)(); }

variable_types: ret int

user_defined_types: struct sigaction { union { void (*sa_handler)(int); void (*sa_sigaction)(int, struct siginfo_t *, void *); } __sigaction_handler; struct __sigset_t sa_mask; int sa_flags; void (*sa_restorer)(); }

user_defined_types: struct siginfo_t { int si_signo; int si_errno; int si_code; int __pad0; union { int _pad[-1]; struct { int si_pid; unsigned int si_uid; } _kill; struct { int si_tid; int si_overrun; union sigval si_sigval; } _timer; struct { int si_pid; unsigned int si_uid; union sigval si_sigval; } _rt; struct { int si_pid; unsigned int si_uid; int si_status; long si_utime; long si_stime; } _sigchld; struct { void *si_addr; short si_addr_lsb; union { struct { void *_lower; void *_upper; } _addr_bnd; unsigned int _pkey; } _bounds; } _sigfault; struct { long si_band; int si_fd; } _sigpoll; struct { void *_call_addr; int _syscall; unsigned int _arch; } _sigsys; } _sifields; }


recursiondeath

decompiled_code:
int recursiondeath()
{
recursiondeath();
return printf("%d", 4294967275LL);
}

original_code:
void recursiondeath()
{
    char buffer[1024];
    recursiondeath();
    memset(buffer, 0xeb, sizeof(buffer));
    printf("%d", buffer[0]);
}

variable_types:
buffer
char [1024]


threadloop

decompiled_code:
void *__fastcall threadloop(void *a1)
{
__int64 v2; // [rsp+0h] [rbp-2008h] BYREF

addsignalstack(&v2);
recursiondeath();
return 0LL;
}

canonical_decompiled_code:
void *__fastcall func12(void *a1)
{
__int64 v2; // [rsp+0h] [rbp-2008h] BYREF

func9(&v2);
func11();
return 0LL;
}

original_code:
void* threadloop(void* args)
{
    char altstack[8192];
    addsignalstack(altstack, 8192);
    recursiondeath();
    return ((void *)0);
}

canonical_original_code:
void *threadloop(void *args)
{
    char altstack[8192];
    addsignalstack(altstack, 8192);
    recursiondeath();
    return ((void *)0);
}

variable_types:
args
void *

variable_types:
altstack
char [8192]

return_type: void *


decompiled_code:
ssize_t __fastcall send_fd(int a1, int a2)
{
__int64 v3; // [rsp+0h] [rbp-78h] BYREF
int v4; // [rsp+8h] [rbp-70h]
int v5; // [rsp+Ch] [rbp-6Ch]
int v6; // [rsp+10h] [rbp-68h]
int v7; // [rsp+14h] [rbp-64h]
char v8; // [rsp+1Fh] [rbp-59h] BYREF
__int64 v9[2]; // [rsp+20h] [rbp-58h] BYREF
struct msghdr message; // [rsp+30h] [rbp-48h] BYREF

v8 = 70;
v9[0] = (__int64)&v8;
v9[1] = 1LL;
message.msg_name = 0LL;
*(_QWORD *)&message.msg_namelen = 0LL;
*(_QWORD *)&message.msg_flags = 0LL;
message.msg_iov = (iovec *)v9;
message.msg_iovlen = 1LL;
v7 = 0;
message.msg_control = &v3;
message.msg_controllen = 24LL;
v4 = 1;
v5 = 1;
v3 = 20LL;
v6 = a2;
return sendmsg(a1, &message, 0);
}

canonical_decompiled_code:
ssize_t __fastcall func7(int a1, int a2)
{
__int64 v3; // [rsp+0h] [rbp-78h] BYREF
int v4; // [rsp+8h] [rbp-70h]
int v5; // [rsp+Ch] [rbp-6Ch]
int v6; // [rsp+10h] [rbp-68h]
int v7; // [rsp+14h] [rbp-64h]
char v8; // [rsp+1Fh] [rbp-59h] BYREF
__int64 v9[2]; // [rsp+20h] [rbp-58h] BYREF
struct msghdr message; // [rsp+30h] [rbp-48h] BYREF

v8 = 70;
v9[0] = (__int64)&v8;
v9[1] = 1LL;
message.msg_name = 0LL;
*(_QWORD *)&message.msg_namelen = 0LL;
*(_QWORD *)&message.msg_flags = 0LL;
message.msg_iov = (iovec *)v9;
message.msg_iovlen = 1LL;
v7 = 0;
message.msg_control = &v3;
message.msg_controllen = 24LL;
v4 = 1;
v5 = 1;
v3 = 20LL;
v6 = a2;
return sendmsg(a1, &message, 0);
}

original_code:
int send_fd(int socket, int fd_to_send)
{
 struct msghdr socket_message;
 struct iovec io_vector[1];
 struct cmsghdr *control_message = ((void *)0);
 char message_buffer[1];
 char ancillary_element_buffer[((((sizeof(int)) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1)) + (((sizeof (struct cmsghdr)) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1)))];
 int available_ancillary_element_buffer_space;
 message_buffer[0] = 'F';
 io_vector[0].iov_base = message_buffer;
 io_vector[0].iov_len = 1;
 memset(&socket_message, 0, sizeof(struct msghdr));
 socket_message.msg_iov = io_vector;
 socket_message.msg_iovlen = 1;
 available_ancillary_element_buffer_space = ((((sizeof(int)) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1)) + (((sizeof (struct cmsghdr)) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1)));
 memset(ancillary_element_buffer, 0, available_ancillary_element_buffer_space);
 socket_message.msg_control = ancillary_element_buffer;
 socket_message.msg_controllen = available_ancillary_element_buffer_space;
 control_message = ((size_t) (&socket_message)->msg_controllen >= sizeof (struct cmsghdr) ? (struct cmsghdr *) (&socket_message)->msg_control : (struct cmsghdr *) 0);
 control_message->cmsg_level = 1;
 control_message->cmsg_type = SCM_RIGHTS;
 control_message->cmsg_len = ((((sizeof (struct cmsghdr)) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1)) + (sizeof(int)));
 *((int *) ((control_message)->__cmsg_data)) = fd_to_send;
 return sendmsg(socket, &socket_message, 0);
}

canonical_original_code:
int send_fd(int socket, int fd_to_send)
{
 struct msghdr socket_message;
 struct iovec io_vector[1];
 struct cmsghdr *control_message = ((void *)0);
 char message_buffer[1];
 char ancillary_element_buffer[-1];
 int available_ancillary_element_buffer_space;
 message_buffer[0] = 'F';
 io_vector[0].iov_base = message_buffer;
 io_vector[0].iov_len = 1;
 memset(&socket_message, 0, sizeof(struct msghdr));
 socket_message.msg_iov = io_vector;
 socket_message.msg_iovlen = 1;
 available_ancillary_element_buffer_space = ((((sizeof(int)) + sizeof (unsigned long) - 1) & (unsigned long) ~(sizeof (unsigned long) - 1)) + (((sizeof (struct cmsghdr)) + sizeof (unsigned long) - 1) & (unsigned long) ~(sizeof (unsigned long) - 1)));
 memset(ancillary_element_buffer, 0, available_ancillary_element_buffer_space);
 socket_message.msg_control = ancillary_element_buffer;
 socket_message.msg_controllen = available_ancillary_element_buffer_space;
 control_message = ((unsigned long) (&socket_message)->msg_controllen >= sizeof (struct cmsghdr) ? (struct cmsghdr *) (&socket_message)->msg_control : (struct cmsghdr *) 0);
 control_message->cmsg_level = 1;
 control_message->cmsg_type = SCM_RIGHTS;
 control_message->cmsg_len = ((((sizeof (struct cmsghdr)) + sizeof (unsigned long) - 1) & (unsigned long) ~(sizeof (unsigned long) - 1)) + (sizeof(int)));
 *((int *) ((control_message)->__cmsg_data)) = fd_to_send;
 return sendmsg(socket, &socket_message, 0);
}

variable_types: socket int

variable_types: struct msghdr { void *msg_name; unsigned int msg_namelen; struct iovec { void *iov_base; unsigned long iov_len; } *msg_iov; unsigned long msg_iovlen; void *msg_control; unsigned long msg_controllen; int msg_flags; }

variable_types: struct iovec { void *iov_base; unsigned long iov_len; } [1]

user_defined_types: struct cmsghdr { unsigned long cmsg_len; int cmsg_level; int cmsg_type; unsigned char __cmsg_data[]; }


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebx
int v4; // ebp
int v5; // er12
socklen_t addr_len; // [rsp+Ch] [rbp-FCh] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-F8h] BYREF
char v9[88]; // [rsp+20h] [rbp-E8h] BYREF
int v10; // [rsp+78h] [rbp-90h]
__int16 v11; // [rsp+7Ch] [rbp-8Ch]
struct sockaddr v12; // [rsp+80h] [rbp-88h] BYREF

addr_len = 0;
v3 = socket(1, 1, 0);
if ( v3 < 0 )
perror("socket() failed\n");
unlink("./demo_socket");
memset(v9, 0, sizeof(v9));
v10 = 0;
v11 = 0;
addr.sa_family = 1;
strcpy(addr.sa_data, "./demo_socket");
if ( bind(v3, &addr, 0x6Eu) )
{
perror("bind() failed\n");
v4 = 1;
}
else
{
v4 = listen(v3, 5);
if ( v4 )
{
perror("listen() failed\n");
v4 = 1;
}
else
{
v5 = accept(v3, &v12, &addr_len);
if ( v5 >= 0 )
{
puts("client connected");
if ( (int)send_fd(v5, 1) < 0 )
perror("send_fd()");
else
puts("fd sended");
}
close(v3);
}
}
return v4;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebx
int v4; // ebp
int v5; // er12
socklen_t addr_len; // [rsp+Ch] [rbp-FCh] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-F8h] BYREF
char v9[88]; // [rsp+20h] [rbp-E8h] BYREF
int v10; // [rsp+78h] [rbp-90h]
__int16 v11; // [rsp+7Ch] [rbp-8Ch]
struct sockaddr v12; // [rsp+80h] [rbp-88h] BYREF

addr_len = 0;
v3 = socket(1, 1, 0);
if ( v3 < 0 )
perror("socket() failed\n");
unlink("./demo_socket");
memset(v9, 0, sizeof(v9));
v10 = 0;
v11 = 0;
addr.sa_family = 1;
strcpy(addr.sa_data, "./demo_socket");
if ( bind(v3, &addr, 0x6Eu) )
{
perror("bind() failed\n");
v4 = 1;
}
else
{
v4 = listen(v3, 5);
if ( v4 )
{
perror("listen() failed\n");
v4 = 1;
}
else
{
v5 = accept(v3, &v12, &addr_len);
if ( v5 >= 0 )
{
puts("client connected");
if ( (int)func7(v5, 1) < 0 )
perror("send_fd()");
else
puts("fd sended");
}
close(v3);
}
}
return v4;
}

original_code:
int main (int argc, char const *argv[])
{
 struct sockaddr_un client_address;
 struct sockaddr_un server_address;
 int socket_fd = 0;
 int client_fd = 0;
 int address_length = 0;
 socket_fd = socket(1, SOCK_STREAM, 0);
 if(socket_fd < 0) {
  perror("socket() failed\n");
 }
 unlink("./demo_socket");
    memset(&server_address, 0, sizeof(struct sockaddr_un));
    server_address.sun_family = 1;
    snprintf(server_address.sun_path, sizeof(server_address.sun_path), "./demo_socket");
    if(bind(socket_fd,
            (struct sockaddr *) &server_address,
            sizeof(struct sockaddr_un)) != 0)
    {
     perror("bind() failed\n");
     return 1;
    }
    if(listen(socket_fd, 5) != 0)
    {
     perror("listen() failed\n");
     return 1;
    }
 if((client_fd = accept(socket_fd, (struct sockaddr *) &client_address, &address_length)) > -1 )
 {
  printf("client connected\n");
  if(send_fd(client_fd, 1) < 0) {
   perror("send_fd()");
  } else {
   printf("fd sended\n");
  }
 }
 close(socket_fd);
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
 struct sockaddr_un client_address;
 struct sockaddr_un server_address;
 int socket_fd = 0;
 int client_fd = 0;
 int address_length = 0;
 socket_fd = socket(1, SOCK_STREAM, 0);
 if(socket_fd < 0) {
  perror("socket() failed\n");
 }
 unlink("./demo_socket");
    memset(&server_address, 0, sizeof(struct sockaddr_un));
    server_address.sun_family = 1;
    snprintf(server_address.sun_path, sizeof(server_address.sun_path), "./demo_socket");
    if(bind(socket_fd,
            (struct sockaddr *) &server_address,
            sizeof(struct sockaddr_un)) != 0)
    {
     perror("bind() failed\n");
     return 1;
    }
    if(listen(socket_fd, 5) != 0)
    {
     perror("listen() failed\n");
     return 1;
    }
 if((client_fd = accept(socket_fd, (struct sockaddr *) &client_address, &address_length)) > -1 )
 {
  printf("client connected\n");
  if(send_fd(client_fd, 1) < 0) {
   perror("send_fd()");
  } else {
   printf("fd sended\n");
  }
 }
 close(socket_fd);
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

user_defined_types: struct sockaddr_un { unsigned short sun_family; char sun_path[108]; }


repo: secure-endpoints/kcacred

decompiled_code:
unsigned __int64 __fastcall display_attribute(_QWORD *a1)
{
__int64 v1; // rdx
unsigned __int64 result; // rax
__int64 v3; // r14
unsigned int v4; // ebx
unsigned __int8 v5; // bp
const unsigned __int16 **v6; // rax
__int64 v7; // rdx
unsigned int v8; // [rsp+8h] [rbp-A0h]
unsigned int v9; // [rsp+Ch] [rbp-9Ch]
char v10[32]; // [rsp+10h] [rbp-98h] BYREF
char v11[120]; // [rsp+30h] [rbp-78h] BYREF

v1 = a1[2];
v11[0] = 0;
v10[0] = 0;
log_printf("display_attribute: type: 0x%08x, length %03ld value:\n", *a1, v1);
result = a1[2];
if ( result )
{
v9 = 0;
v3 = 0LL;
do
{
v8 = result - v9;
if ( (_DWORD)result == v9 )
{
v4 = 0;
}
else
{
v4 = 0;
do
{
v5 = *(_BYTE *)(a1[1] + v4 + v3);
sprintf(&v11[2 * v4], "%02x", v5);
v6 = _ctype_b_loc();
v7 = 46LL;
if ( ((*v6)[v5] & 0x4000) != 0 )
v7 = v5;
sprintf(&v10[v4++], "%c", v7);
}
while ( v4 <= 0xF && v8 > v4 );
if ( v4 > 0xF )
goto LABEL_5;
}
do
{
strcat(v11, "..");
*(_WORD *)&v10[strlen(v10)] = 46;
++v4;
}
while ( v4 <= 0xF );
LABEL_5:
log_printf("%s |%s|\n", v11, v10);
v9 += 16;
v3 = v9;
result = a1[2];
}
while ( v9 < result );
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func0(_QWORD *a1)
{
__int64 v1; // rdx
unsigned __int64 result; // rax
__int64 v3; // r14
unsigned int v4; // ebx
unsigned __int8 v5; // bp
const unsigned __int16 **v6; // rax
__int64 v7; // rdx
unsigned int v8; // [rsp+8h] [rbp-A0h]
unsigned int v9; // [rsp+Ch] [rbp-9Ch]
char v10[32]; // [rsp+10h] [rbp-98h] BYREF
char v11[120]; // [rsp+30h] [rbp-78h] BYREF

v1 = a1[2];
v11[0] = 0;
v10[0] = 0;
log_printf("display_attribute: type: 0x%08x, length %03ld value:\n", *a1, v1);
result = a1[2];
if ( result )
{
v9 = 0;
v3 = 0LL;
do
{
v8 = result - v9;
if ( (_DWORD)result == v9 )
{
v4 = 0;
}
else
{
v4 = 0;
do
{
v5 = *(_BYTE *)(a1[1] + v4 + v3);
sprintf(&v11[2 * v4], "%02x", v5);
v6 = _ctype_b_loc();
v7 = 46LL;
if ( ((*v6)[v5] & 0x4000) != 0 )
v7 = v5;
sprintf(&v10[v4++], "%c", v7);
}
while ( v4 <= 0xF && v8 > v4 );
if ( v4 > 0xF )
goto LABEL_5;
}
do
{
strcat(v11, "..");
*(_WORD *)&v10[strlen(v10)] = 46;
++v4;
}
while ( v4 <= 0xF );
LABEL_5:
log_printf("%s |%s|\n", v11, v10);
v9 += 16;
v3 = v9;
result = a1[2];
}
while ( v9 < result );
}
return result;
}

original_code:
void display_attribute(CK_ATTRIBUTE_PTR attr) {
    unsigned int i, j;
    int totalLength = attr->ulValueLen;
    char temphex[64];
    char tempascii[32];
    unsigned char c;
    unsigned int remain;
    temphex[0] = '\0';
    tempascii[0] = '\0';
    log_printf("display_attribute: type: 0x%08x, length %03ld value:\n", attr->type, attr->ulValueLen);
    for (j = 0; j < attr->ulValueLen; j += 16) {
 remain = attr->ulValueLen - j;
 for (i = 0; i < 16 && i < remain; i++) {
     c = *((char *)(attr->value)+i+j);
     sprintf(&(temphex[i*2]), "%02x", c);
     sprintf(&(tempascii[i]), "%c", ((*__ctype_b_loc ())[(int) ((c))] & (unsigned short int) _ISprint) ? c : '.');
 }
 for (; i < 16; i++) {
     strcat(temphex, "..");
     strcat(tempascii, ".");
 }
 log_printf("%s  |%s|\n", temphex, tempascii);
    }
    return;
}

canonical_original_code:
void display_attribute(struct CK_ATTRIBUTE *attr) {
    unsigned int i; unsigned int j;
    int totalLength = attr->ulValueLen;
    char temphex[64];
    char tempascii[32];
    unsigned char c;
    unsigned int remain;
    temphex[0] = '\0';
    tempascii[0] = '\0';
    log_printf("display_attribute: type: 0x%08x, length %03ld value:\n", attr->type, attr->ulValueLen);
    for (j = 0; j < attr->ulValueLen; j += 16) {
 remain = attr->ulValueLen - j;
 for (i = 0; i < 16 && i < remain; i++) {
     c = *((char *)(attr->value)+i+j);
     sprintf(&(temphex[i*2]), "%02x", c);
     sprintf(&(tempascii[i]), "%c", ((*__ctype_b_loc ())[(int) ((c))] & (unsigned short) _ISprint) ? c : '.');
 }
 for (; i < 16; i++) {
     strcat(temphex, "..");
     strcat(tempascii, ".");
 }
 log_printf("%s  |%s|\n", temphex, tempascii);
    }
    return;
}

variable_types: struct CK_ATTRIBUTE { unsigned long type; void *value; unsigned long ulValueLen; } *

variable_types:
i
unsigned int

variable_types:
j
unsigned int

variable_types: totalLength int

variable_types:
temphex
char [64]

variable_types:
tempascii
char [32]

variable_types:
c
unsigned char

variable_types:
remain
unsigned int


decompiled_code:
unsigned __int64 __fastcall display_object(_QWORD *a1)
{
unsigned __int64 result; // rax
_QWORD *v3; // rdi
__int64 v4; // rbx

if ( a1 )
{
result = log_printf("display_object: object handle 0x%08x class 0x%08x\n", *a1, a1[1]);
v3 = (_QWORD *)a1[3];
if ( v3[2] )
{
v4 = 24LL;
do
{
result = display_attribute(v3);
v3 = (_QWORD *)(a1[3] + v4);
v4 += 24LL;
}
while ( v3[2] );
}
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func1(_QWORD *a1)
{
unsigned __int64 result; // rax
_QWORD *v3; // rdi
__int64 v4; // rbx

if ( a1 )
{
result = log_printf("display_object: object handle 0x%08x class 0x%08x\n", *a1, a1[1]);
v3 = (_QWORD *)a1[3];
if ( v3[2] )
{
v4 = 24LL;
do
{
result = func0(v3);
v3 = (_QWORD *)(a1[3] + v4);
v4 += 24LL;
}
while ( v3[2] );
}
}
return result;
}

original_code:
void display_object(PKCS11_OBJECT *object) {
    int i;
    if (!object)
 return;
    log_printf("display_object: object handle 0x%08x class 0x%08x\n",
  object->ulObjectHandle, object->ulObjectClass);
    for (i=0; object->pAttribute[i].ulValueLen!=0; i++) {
 display_attribute(&(object->pAttribute[i]));
    }
    return;
}

canonical_original_code:
void display_object(struct PKCS11_OBJECT *object) {
    int i;
    if (!object)
 return;
    log_printf("display_object: object handle 0x%08x class 0x%08x\n",
  object->ulObjectHandle, object->ulObjectClass);
    for (i=0; object->pAttribute[i].ulValueLen!=0; i++) {
 display_attribute(&(object->pAttribute[i]));
    }
    return;
}

variable_types: struct PKCS11_OBJECT { unsigned long ulObjectHandle; unsigned long ulObjectClass; unsigned long ulSessionHandle; struct CK_ATTRIBUTE { unsigned long type; void *value; unsigned long ulValueLen; } *pAttribute; } *

variable_types: i int

user_defined_types: struct PKCS11_OBJECT { unsigned long ulObjectHandle; unsigned long ulObjectClass; unsigned long ulSessionHandle; struct CK_ATTRIBUTE *pAttribute; }


decompiled_code:
void __fastcall CKI_Info_Free(void *ptr)
{
log_printf("CKI_Info_Free: entered\n");
if ( ptr )
free(ptr);
}

canonical_decompiled_code:
void __fastcall func0(void *ptr)
{
log_printf("CKI_Info_Free: entered\n");
if ( ptr )
free(ptr);
}

original_code:
void CKI_Info_Free(CK_INFO_PTR pInfo) {
    log_printf("CKI_Info_Free: entered\n");
    if (pInfo==((void *)0))
 return;
    free(pInfo);
    return;
}

canonical_original_code:
void CKI_Info_Free(struct CK_INFO *pInfo) {
    log_printf("CKI_Info_Free: entered\n");
    if (pInfo==((void *)0))
 return;
    free(pInfo);
    return;
}

variable_types: struct CK_INFO { struct CK_VERSION { unsigned char major; unsigned char minor; } cryptokiVersion; unsigned char manufacturerID[32]; unsigned long flags; unsigned char libraryDescription[32]; struct CK_VERSION libraryVersion; } *

user_defined_types: struct CK_INFO { struct CK_VERSION cryptokiVersion; unsigned char manufacturerID[32]; unsigned long flags; unsigned char libraryDescription[32]; struct CK_VERSION libraryVersion; }


decompiled_code:
char *CKI_Info_New()
{
char *result; // rax

log_printf("CKI_Info_New: entered\n");
result = (char *)malloc(0x58uLL);
if ( result )
{
*result = 0;
result[1] = 0;
memset(result + 2, 32, 32);
*((_QWORD *)result + 5) = 0LL;
strcpy(result + 48, " ");
result[81] = 0;
}
return result;
}

canonical_decompiled_code:
char *func1()
{
char *result; // rax

log_printf("CKI_Info_New: entered\n");
result = (char *)malloc(0x58uLL);
if ( result )
{
*result = 0;
result[1] = 0;
memset(result + 2, 32, 32);
*((_QWORD *)result + 5) = 0LL;
strcpy(result + 48, " ");
result[81] = 0;
}
return result;
}

original_code:
CK_INFO_PTR CKI_Info_New() {
    CK_INFO_PTR pInfo;
    log_printf("CKI_Info_New: entered\n");
    pInfo=(CK_INFO_PTR)malloc(sizeof(CK_INFO));
    if (pInfo==((void *)0)) {
 return(((void *)0));
    }
    pInfo->cryptokiVersion.major=0;
    pInfo->cryptokiVersion.minor=0;
    memset(pInfo->manufacturerID,' ',sizeof(pInfo->manufacturerID));
    pInfo->flags=0L;
    memset(pInfo->libraryDescription,' ',sizeof(pInfo->libraryDescription));
    pInfo->libraryVersion.major=0;
    pInfo->libraryVersion.minor=0;
    return(pInfo);
}

canonical_original_code:
struct CK_INFO *CKI_Info_New() {
    struct CK_INFO *pInfo;
    log_printf("CKI_Info_New: entered\n");
    pInfo=(struct CK_INFO *)malloc(sizeof(CK_INFO));
    if (pInfo==((void *)0)) {
 return(((void *)0));
    }
    pInfo->cryptokiVersion.major=0;
    pInfo->cryptokiVersion.minor=0;
    memset(pInfo->manufacturerID,' ',sizeof(pInfo->manufacturerID));
    pInfo->flags=0L;
    memset(pInfo->libraryDescription,' ',sizeof(pInfo->libraryDescription));
    pInfo->libraryVersion.major=0;
    pInfo->libraryVersion.minor=0;
    return(pInfo);
}

return_type: struct CK_INFO { struct CK_VERSION { unsigned char major; unsigned char minor; } cryptokiVersion; unsigned char manufacturerID[32]; unsigned long flags; unsigned char libraryDescription[32]; struct CK_VERSION libraryVersion; } *


decompiled_code:
void __fastcall CKI_SlotInfo_Free(void *ptr)
{
log_printf("CKI_SlotInfo_Free: entered\n");
if ( ptr )
free(ptr);
}

canonical_decompiled_code:
void __fastcall func2(void *ptr)
{
log_printf("CKI_SlotInfo_Free: entered\n");
if ( ptr )
free(ptr);
}

original_code:
void CKI_SlotInfo_Free(CK_SLOT_INFO_PTR pInfo) {
    log_printf("CKI_SlotInfo_Free: entered\n");
    if (pInfo==((void *)0)) return;
    free(pInfo);
    return;
}

canonical_original_code:
void CKI_SlotInfo_Free(struct CK_SLOT_INFO *pInfo) {
    log_printf("CKI_SlotInfo_Free: entered\n");
    if (pInfo==((void *)0)) return;
    free(pInfo);
    return;
}

variable_types: struct CK_SLOT_INFO { unsigned char slotDescription[64]; unsigned char manufacturerID[32]; unsigned long flags; struct CK_VERSION { unsigned char major; unsigned char minor; } hardwareVersion; struct CK_VERSION firmwareVersion; } *

user_defined_types: struct CK_SLOT_INFO { unsigned char slotDescription[64]; unsigned char manufacturerID[32]; unsigned long flags; struct CK_VERSION hardwareVersion; struct CK_VERSION firmwareVersion; }


original_code:
CK_SLOT_INFO_PTR CKI_SlotInfo_New() {
    CK_SLOT_INFO_PTR pSlotInfo;
    log_printf("CKI_SlotInfo_New: entered\n");
    pSlotInfo=(CK_SLOT_INFO_PTR)malloc(sizeof(CK_SLOT_INFO));
    if (pSlotInfo==((void *)0)) {
 return(((void *)0));
    }
    memset(pSlotInfo->slotDescription,' ',sizeof(pSlotInfo->slotDescription));
    memset(pSlotInfo->manufacturerID,' ',sizeof(pSlotInfo->manufacturerID));
    pSlotInfo->flags=(CK_FLAGS)0x00000002;
    log_printf("CKI_SlotInfo_New: pSlotInfo->flags = 0x%08lX\n",
  pSlotInfo->flags);
    pSlotInfo->hardwareVersion.major=0;
    pSlotInfo->hardwareVersion.minor=0;
    pSlotInfo->firmwareVersion.major=0;
    pSlotInfo->firmwareVersion.minor=0;
    return(pSlotInfo);
}

canonical_original_code:
struct CK_SLOT_INFO *CKI_SlotInfo_New() {
    struct CK_SLOT_INFO *pSlotInfo;
    log_printf("CKI_SlotInfo_New: entered\n");
    pSlotInfo=(struct CK_SLOT_INFO *)malloc(sizeof(CK_SLOT_INFO));
    if (pSlotInfo==((void *)0)) {
 return(((void *)0));
    }
    memset(pSlotInfo->slotDescription,' ',sizeof(pSlotInfo->slotDescription));
    memset(pSlotInfo->manufacturerID,' ',sizeof(pSlotInfo->manufacturerID));
    pSlotInfo->flags=(unsigned long)0x00000002;
    log_printf("CKI_SlotInfo_New: pSlotInfo->flags = 0x%08lX\n",
  pSlotInfo->flags);
    pSlotInfo->hardwareVersion.major=0;
    pSlotInfo->hardwareVersion.minor=0;
    pSlotInfo->firmwareVersion.major=0;
    pSlotInfo->firmwareVersion.minor=0;
    return(pSlotInfo);
}

return_type: struct CK_SLOT_INFO { unsigned char slotDescription[64]; unsigned char manufacturerID[32]; unsigned long flags; struct CK_VERSION { unsigned char major; unsigned char minor; } hardwareVersion; struct CK_VERSION firmwareVersion; } *


decompiled_code:
void __fastcall CKI_TokenInfo_Free(void *ptr)
{
log_printf("CKI_TokenInfo_Free: entered\n");
if ( ptr )
free(ptr);
}

canonical_decompiled_code:
void __fastcall func4(void *ptr)
{
log_printf("CKI_TokenInfo_Free: entered\n");
if ( ptr )
free(ptr);
}

original_code:
void CKI_TokenInfo_Free(CK_TOKEN_INFO_PTR pInfo) {
    log_printf("CKI_TokenInfo_Free: entered\n");
    if (pInfo==((void *)0)) return;
    free(pInfo);
    return;
}

canonical_original_code:
void CKI_TokenInfo_Free(struct CK_TOKEN_INFO *pInfo) {
    log_printf("CKI_TokenInfo_Free: entered\n");
    if (pInfo==((void *)0)) return;
    free(pInfo);
    return;
}

variable_types: struct CK_TOKEN_INFO { unsigned char label[32]; unsigned char manufacturerID[32]; unsigned char model[16]; unsigned char serialNumber[16]; unsigned long flags; unsigned long ulMaxSessionCount; unsigned long ulSessionCount; unsigned long ulMaxRwSessionCount; unsigned long ulRwSessionCount; unsigned long ulMaxPinLen; unsigned long ulMinPinLen; unsigned long ulTotalPublicMemory; unsigned long ulFreePublicMemory; unsigned long ulTotalPrivateMemory; unsigned long ulFreePrivateMemory; struct CK_VERSION { unsigned char major; unsigned char minor; } hardwareVersion; struct CK_VERSION firmwareVersion; unsigned char utcTime[16]; } *

user_defined_types: struct CK_TOKEN_INFO { unsigned char label[32]; unsigned char manufacturerID[32]; unsigned char model[16]; unsigned char serialNumber[16]; unsigned long flags; unsigned long ulMaxSessionCount; unsigned long ulSessionCount; unsigned long ulMaxRwSessionCount; unsigned long ulRwSessionCount; unsigned long ulMaxPinLen; unsigned long ulMinPinLen; unsigned long ulTotalPublicMemory; unsigned long ulFreePublicMemory; unsigned long ulTotalPrivateMemory; unsigned long ulFreePrivateMemory; struct CK_VERSION hardwareVersion; struct CK_VERSION firmwareVersion; unsigned char utcTime[16]; }


original_code:
CK_TOKEN_INFO_PTR CKI_TokenInfo_New() {
    CK_TOKEN_INFO_PTR pInfo;
    log_printf("CKI_TokenInfo_New: entered\n");
    pInfo=(CK_TOKEN_INFO_PTR)malloc(sizeof(CK_TOKEN_INFO));
    if (pInfo==((void *)0)) {
 return(((void *)0));
    }
    memset(pInfo->label,' ',sizeof(pInfo->label));
    memset(pInfo->manufacturerID,' ',sizeof(pInfo->manufacturerID));
    memset(pInfo->model,' ',sizeof(pInfo->model));
    memset(pInfo->serialNumber,' ',sizeof(pInfo->serialNumber));
    pInfo->flags=0L;
    pInfo->flags=(CK_FLAGS)(0x00000100
        | 0x00000008) ;
    log_printf("CKI_TokenInfo_New: pInfo->flags = 0x%08lX (CKF_PROTECTED_AUTHENTICATION_PATH | CKF_USER_PIN_INITIALIZED)\n", (CK_FLAGS)pInfo->flags);
    pInfo->ulMaxSessionCount=0L;
    pInfo->ulSessionCount=0L;
    pInfo->ulMaxRwSessionCount=0L;
    pInfo->ulRwSessionCount=0L;
    pInfo->ulMaxPinLen=0L;
    pInfo->ulMinPinLen=0L;
    pInfo->ulTotalPublicMemory=0L;
    pInfo->ulFreePublicMemory=0L;
    pInfo->ulTotalPrivateMemory=0L;
    pInfo->ulFreePrivateMemory=0L;
    pInfo->hardwareVersion.major=0;
    pInfo->hardwareVersion.minor=0;
    pInfo->firmwareVersion.major=0;
    pInfo->firmwareVersion.minor=0;
    memset(pInfo->utcTime,' ',sizeof(pInfo->utcTime));
    return(pInfo);
}

canonical_original_code:
struct CK_TOKEN_INFO *CKI_TokenInfo_New() {
    struct CK_TOKEN_INFO *pInfo;
    log_printf("CKI_TokenInfo_New: entered\n");
    pInfo=(struct CK_TOKEN_INFO *)malloc(sizeof(CK_TOKEN_INFO));
    if (pInfo==((void *)0)) {
 return(((void *)0));
    }
    memset(pInfo->label,' ',sizeof(pInfo->label));
    memset(pInfo->manufacturerID,' ',sizeof(pInfo->manufacturerID));
    memset(pInfo->model,' ',sizeof(pInfo->model));
    memset(pInfo->serialNumber,' ',sizeof(pInfo->serialNumber));
    pInfo->flags=0L;
    pInfo->flags=(CK_FLAGS)(0x00000100
        | 0x00000008) ;
    log_printf("CKI_TokenInfo_New: pInfo->flags = 0x%08lX (CKF_PROTECTED_AUTHENTICATION_PATH | CKF_USER_PIN_INITIALIZED)\n", (unsigned long)pInfo->flags);
    pInfo->ulMaxSessionCount=0L;
    pInfo->ulSessionCount=0L;
    pInfo->ulMaxRwSessionCount=0L;
    pInfo->ulRwSessionCount=0L;
    pInfo->ulMaxPinLen=0L;
    pInfo->ulMinPinLen=0L;
    pInfo->ulTotalPublicMemory=0L;
    pInfo->ulFreePublicMemory=0L;
    pInfo->ulTotalPrivateMemory=0L;
    pInfo->ulFreePrivateMemory=0L;
    pInfo->hardwareVersion.major=0;
    pInfo->hardwareVersion.minor=0;
    pInfo->firmwareVersion.major=0;
    pInfo->firmwareVersion.minor=0;
    memset(pInfo->utcTime,' ',sizeof(pInfo->utcTime));
    return(pInfo);
}

return_type: struct CK_TOKEN_INFO { unsigned char label[32]; unsigned char manufacturerID[32]; unsigned char model[16]; unsigned char serialNumber[16]; unsigned long flags; unsigned long ulMaxSessionCount; unsigned long ulSessionCount; unsigned long ulMaxRwSessionCount; unsigned long ulRwSessionCount; unsigned long ulMaxPinLen; unsigned long ulMinPinLen; unsigned long ulTotalPublicMemory; unsigned long ulFreePublicMemory; unsigned long ulTotalPrivateMemory; unsigned long ulFreePrivateMemory; struct CK_VERSION { unsigned char major; unsigned char minor; } hardwareVersion; struct CK_VERSION firmwareVersion; unsigned char utcTime[16]; } *


decompiled_code:
void __fastcall CKI_SessionInfo_Free(void *ptr)
{
log_printf("CKI_SessionInfo_Free: entered\n");
if ( ptr )
free(ptr);
}

canonical_decompiled_code:
void __fastcall func6(void *ptr)
{
log_printf("CKI_SessionInfo_Free: entered\n");
if ( ptr )
free(ptr);
}

original_code:
void CKI_SessionInfo_Free(CK_SESSION_INFO_PTR pInfo) {
    log_printf("CKI_SessionInfo_Free: entered\n");
    if (pInfo==((void *)0)) return;
    free(pInfo);
    return;
}

canonical_original_code:
void CKI_SessionInfo_Free(struct CK_SESSION_INFO *pInfo) {
    log_printf("CKI_SessionInfo_Free: entered\n");
    if (pInfo==((void *)0)) return;
    free(pInfo);
    return;
}

variable_types: struct CK_SESSION_INFO { unsigned long slotID; unsigned long state; unsigned long flags; unsigned long ulDeviceError; } *


decompiled_code:
_QWORD *CKI_SessionInfo_New()
{
_QWORD *result; // rax

log_printf("CKI_SessionInfo_New: entered\n");
result = malloc(0x20uLL);
if ( result )
{
*result = 0LL;
result[1] = 0LL;
result[2] = 0LL;
result[3] = 0LL;
}
return result;
}

canonical_decompiled_code:
_QWORD *func7()
{
_QWORD *result; // rax

log_printf("CKI_SessionInfo_New: entered\n");
result = malloc(0x20uLL);
if ( result )
{
*result = 0LL;
result[1] = 0LL;
result[2] = 0LL;
result[3] = 0LL;
}
return result;
}

original_code:
CK_SESSION_INFO_PTR CKI_SessionInfo_New() {
    CK_SESSION_INFO_PTR pInfo;
    log_printf("CKI_SessionInfo_New: entered\n");
    pInfo=(CK_SESSION_INFO_PTR)malloc(sizeof(CK_SESSION_INFO));
    if (pInfo==((void *)0)) {
 return(((void *)0));
    }
    pInfo->slotID=0L;
    pInfo->state=0L;
    pInfo->flags=0L;
    pInfo->ulDeviceError=0L;
    return(pInfo);
}

canonical_original_code:
struct CK_SESSION_INFO *CKI_SessionInfo_New() {
    struct CK_SESSION_INFO *pInfo;
    log_printf("CKI_SessionInfo_New: entered\n");
    pInfo=(struct CK_SESSION_INFO *)malloc(sizeof(CK_SESSION_INFO));
    if (pInfo==((void *)0)) {
 return(((void *)0));
    }
    pInfo->slotID=0L;
    pInfo->state=0L;
    pInfo->flags=0L;
    pInfo->ulDeviceError=0L;
    return(pInfo);
}

return_type: struct CK_SESSION_INFO { unsigned long slotID; unsigned long state; unsigned long flags; unsigned long ulDeviceError; } *


decompiled_code:
void __fastcall CKI_Attribute_Free(void *ptr)
{
log_printf("CKI_Attribute_Free: entered\n");
if ( ptr )
free(ptr);
}

canonical_decompiled_code:
void __fastcall func8(void *ptr)
{
log_printf("CKI_Attribute_Free: entered\n");
if ( ptr )
free(ptr);
}

original_code:
void CKI_Attribute_Free(CK_ATTRIBUTE_PTR pAttribute) {
    log_printf("CKI_Attribute_Free: entered\n");
    if (pAttribute==((void *)0)) return;
    if (pAttribute->value==((void *)0))
 free(pAttribute->value);
    free(pAttribute);
    return;
}

canonical_original_code:
void CKI_Attribute_Free(struct CK_ATTRIBUTE *pAttribute) {
    log_printf("CKI_Attribute_Free: entered\n");
    if (pAttribute==((void *)0)) return;
    if (pAttribute->value==((void *)0))
 free(pAttribute->value);
    free(pAttribute);
    return;
}

user_defined_types: struct CK_ATTRIBUTE { unsigned long type; void *value; unsigned long ulValueLen; }


decompiled_code:
_QWORD *CKI_Attribute_New()
{
_QWORD *result; // rax

log_printf("CKI_Attribute_New: entered\n");
result = malloc(0x18uLL);
if ( result )
{
result[1] = 0LL;
result[2] = 0LL;
}
return result;
}

canonical_decompiled_code:
_QWORD *func9()
{
_QWORD *result; // rax

log_printf("CKI_Attribute_New: entered\n");
result = malloc(0x18uLL);
if ( result )
{
result[1] = 0LL;
result[2] = 0LL;
}
return result;
}

original_code:
CK_ATTRIBUTE_PTR CKI_Attribute_New() {
    CK_ATTRIBUTE_PTR pAttribute;
    log_printf("CKI_Attribute_New: entered\n");
    pAttribute=(CK_ATTRIBUTE_PTR)malloc(sizeof(CK_ATTRIBUTE));
    if (pAttribute==((void *)0)) {
 return(((void *)0));
    }
    pAttribute->value=((void *)0);
    pAttribute->ulValueLen=0L;
    return(pAttribute);
}

canonical_original_code:
struct CK_ATTRIBUTE *CKI_Attribute_New() {
    struct CK_ATTRIBUTE *pAttribute;
    log_printf("CKI_Attribute_New: entered\n");
    pAttribute=(struct CK_ATTRIBUTE *)malloc(sizeof(CK_ATTRIBUTE));
    if (pAttribute==((void *)0)) {
 return(((void *)0));
    }
    pAttribute->value=((void *)0);
    pAttribute->ulValueLen=0L;
    return(pAttribute);
}

return_type: struct CK_ATTRIBUTE { unsigned long type; void *value; unsigned long ulValueLen; } *


decompiled_code:
void __fastcall CKI_Mechanism_Free(void *ptr)
{
void *v2; // rdi

log_printf("CKI_Mechanism_Free: entered\n");
if ( ptr )
{
v2 = (void *)*((_QWORD *)ptr + 1);
if ( v2 )
free(v2);
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func10(void *ptr)
{
void *v2; // rdi

log_printf("CKI_Mechanism_Free: entered\n");
if ( ptr )
{
v2 = (void *)*((_QWORD *)ptr + 1);
if ( v2 )
free(v2);
free(ptr);
}
}

original_code:
void CKI_Mechanism_Free(CK_MECHANISM_PTR pMechanism) {
    log_printf("CKI_Mechanism_Free: entered\n");
    if (pMechanism==((void *)0)) return;
    if (pMechanism->pParameter!=((void *)0))
 free(pMechanism->pParameter);
    free(pMechanism);
    return;
}

canonical_original_code:
void CKI_Mechanism_Free(struct CK_MECHANISM *pMechanism) {
    log_printf("CKI_Mechanism_Free: entered\n");
    if (pMechanism==((void *)0)) return;
    if (pMechanism->pParameter!=((void *)0))
 free(pMechanism->pParameter);
    free(pMechanism);
    return;
}

variable_types: struct CK_MECHANISM { unsigned short mechanism; void *pParameter; unsigned long ulParameterLen; } *


decompiled_code:
_QWORD *CKI_Mechanism_New()
{
_QWORD *result; // rax

log_printf("CKI_Mechanism_New: entered\n");
result = malloc(0x18uLL);
if ( result )
{
*(_WORD *)result = 0;
result[1] = 0LL;
result[2] = 0LL;
}
return result;
}

canonical_decompiled_code:
_QWORD *func11()
{
_QWORD *result; // rax

log_printf("CKI_Mechanism_New: entered\n");
result = malloc(0x18uLL);
if ( result )
{
*(_WORD *)result = 0;
result[1] = 0LL;
result[2] = 0LL;
}
return result;
}

original_code:
CK_MECHANISM_PTR CKI_Mechanism_New() {
    CK_MECHANISM_PTR pMechanism;
    log_printf("CKI_Mechanism_New: entered\n");
    pMechanism=(CK_MECHANISM_PTR)malloc(sizeof(CK_MECHANISM));
    if (pMechanism==((void *)0)) {
 return(((void *)0));
    }
    pMechanism->mechanism=0L;
    pMechanism->pParameter=((void *)0);
    pMechanism->ulParameterLen=0L;
    return(pMechanism);
}

canonical_original_code:
struct CK_MECHANISM *CKI_Mechanism_New() {
    struct CK_MECHANISM *pMechanism;
    log_printf("CKI_Mechanism_New: entered\n");
    pMechanism=(struct CK_MECHANISM *)malloc(sizeof(CK_MECHANISM));
    if (pMechanism==((void *)0)) {
 return(((void *)0));
    }
    pMechanism->mechanism=0L;
    pMechanism->pParameter=((void *)0);
    pMechanism->ulParameterLen=0L;
    return(pMechanism);
}

return_type: struct CK_MECHANISM { unsigned short mechanism; void *pParameter; unsigned long ulParameterLen; } *


decompiled_code:
void __fastcall CKI_MechanismInfo_Free(void *ptr)
{
log_printf("CKI_MechanismInfo_Free: entered\n");
if ( ptr )
free(ptr);
}

canonical_decompiled_code:
void __fastcall func12(void *ptr)
{
log_printf("CKI_MechanismInfo_Free: entered\n");
if ( ptr )
free(ptr);
}

original_code:
void CKI_MechanismInfo_Free(CK_MECHANISM_INFO_PTR pInfo) {
    log_printf("CKI_MechanismInfo_Free: entered\n");
    if (pInfo==((void *)0)) return;
    free(pInfo);
    return;
}

canonical_original_code:
void CKI_MechanismInfo_Free(struct CK_MECHANISM_INFO *pInfo) {
    log_printf("CKI_MechanismInfo_Free: entered\n");
    if (pInfo==((void *)0)) return;
    free(pInfo);
    return;
}

variable_types: struct CK_MECHANISM_INFO { unsigned long ulMinKeySize; unsigned long ulMaxKeySize; unsigned long flags; } *


decompiled_code:
_QWORD *CKI_MechanismInfo_New()
{
_QWORD *result; // rax

log_printf("CKI_MechanismInfo_New: entered\n");
result = malloc(0x18uLL);
if ( result )
{
*result = 0LL;
result[1] = 0LL;
result[2] = 0LL;
}
return result;
}

canonical_decompiled_code:
_QWORD *func13()
{
_QWORD *result; // rax

log_printf("CKI_MechanismInfo_New: entered\n");
result = malloc(0x18uLL);
if ( result )
{
*result = 0LL;
result[1] = 0LL;
result[2] = 0LL;
}
return result;
}

original_code:
CK_MECHANISM_INFO_PTR CKI_MechanismInfo_New() {
    CK_MECHANISM_INFO_PTR pInfo;
    log_printf("CKI_MechanismInfo_New: entered\n");
    pInfo=(CK_MECHANISM_INFO_PTR)malloc(sizeof(CK_MECHANISM_INFO));
    if (pInfo==((void *)0)) {
 return(((void *)0));
    }
    pInfo->ulMinKeySize=0L;
    pInfo->ulMaxKeySize=0L;
    pInfo->flags=0L;
    return(pInfo);
}

canonical_original_code:
struct CK_MECHANISM_INFO *CKI_MechanismInfo_New() {
    struct CK_MECHANISM_INFO *pInfo;
    log_printf("CKI_MechanismInfo_New: entered\n");
    pInfo=(struct CK_MECHANISM_INFO *)malloc(sizeof(CK_MECHANISM_INFO));
    if (pInfo==((void *)0)) {
 return(((void *)0));
    }
    pInfo->ulMinKeySize=0L;
    pInfo->ulMaxKeySize=0L;
    pInfo->flags=0L;
    return(pInfo);
}

return_type: struct CK_MECHANISM_INFO { unsigned long ulMinKeySize; unsigned long ulMaxKeySize; unsigned long flags; } *


decompiled_code:
void __fastcall CKI_Pin_Free(void *ptr)
{
log_printf("CKI_Pin_Free: entered\n");
if ( ptr )
free(ptr);
}

canonical_decompiled_code:
void __fastcall func14(void *ptr)
{
log_printf("CKI_Pin_Free: entered\n");
if ( ptr )
free(ptr);
}

original_code:
void CKI_Pin_Free(CK_CHAR_PTR pPin) {
    log_printf("CKI_Pin_Free: entered\n");
    if (pPin==((void *)0)) return;
    free(pPin);
    return;
}

canonical_original_code:
void CKI_Pin_Free(unsigned char *pPin) {
    log_printf("CKI_Pin_Free: entered\n");
    if (pPin==((void *)0)) return;
    free(pPin);
    return;
}

variable_types:
pPin
unsigned char *