GetFieldType

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

if ( *(_DWORD *)(a1[2] + 80LL) <= a2 )
result = 0LL;
else
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

if ( *(_DWORD *)(a1[2] + 80LL) <= a2 )
result = 0LL;
else
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

repo: secmobi/android-utils

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

if ( *(_DWORD *)(a1[2] + 80LL) <= a2 )
result = 0LL;
else
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

if ( *(_DWORD *)(a1[2] + 80LL) <= a2 )
result = 0LL;
else
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);
}

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


GetMethodName

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

if ( *(_DWORD *)(a1[2] + 88LL) <= a2 )
result = 0LL;
else
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

if ( *(_DWORD *)(a1[2] + 88LL) <= a2 )
result = 0LL;
else
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; } *

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 DexProtoId_t { unsigned int shortyIdx; unsigned int returnTypeIdx; unsigned int parametersOff; }

user_defined_types: struct DexFieldId_t { unsigned short classIdx; unsigned short typeIdx; 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; }


GetMethodClass

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

if ( *(_DWORD *)(a1[2] + 88LL) <= a2 )
result = 0LL;
else
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

if ( *(_DWORD *)(a1[2] + 88LL) <= a2 )
result = 0LL;
else
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);
}

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


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

return_type: unsigned int


GetClassName

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

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

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

if ( *(_DWORD *)(a1[2] + 96LL) > a2 )
result = (void *)func1(a1, *(_DWORD *)(a1[8] + 32LL * a2));
else
result = &unk_643;
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:
// attributes: thunk
void DexClose(void *ptr)
{
free(ptr);
}

canonical_decompiled_code:
void func13(void *ptr)
{
free(ptr);
}

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 *

return_type: void


DexDumpAll

decompiled_code:
__int64 __fastcall DexDumpAll(_QWORD *a1)
{
_DWORD *v1; // rax
unsigned int v2; // ebx
const char *v3; // rax
__int64 v4; // rsi
unsigned int v5; // ebx
const char *v6; // rax
__int64 v7; // rsi
unsigned int v8; // er12
unsigned int v9; // ebx
const char *v10; // rax
const char *v11; // rcx
unsigned int v12; // edx
const char *v13; // rax
unsigned int v14; // ebx
const char *v15; // rax
__int64 v16; // rsi
const char *v17; // rcx
const char *v18; // r8
__int64 result; // rax
unsigned int v20; // ebx
unsigned int v21; // eax
const char *v22; // rax
__int64 v23; // rsi
const char *v24; // rcx
const char *v25; // r8

v1 = (_DWORD *)a1[2];
if ( v1[14] )
{
v2 = 0;
do
{
v3 = (const char *)GetString(a1, v2);
v4 = v2++;
printf("string[%u] = %s\n", v4, v3);
v1 = (_DWORD *)a1[2];
}
while ( v1[14] > v2 );
}
if ( v1[16] )
{
v5 = 0;
do
{
v6 = (const char *)GetType(a1, v5);
v7 = v5++;
printf("type[%u] = %s\n", v7, v6);
v1 = (_DWORD *)a1[2];
}
while ( v1[16] > v5 );
}
if ( v1[18] )
{
v8 = 0;
do
{
v9 = 0;
GetProtoReturnType(a1, v8);
v10 = (const char *)GetProtoShorty(a1, v8);
printf("proto[%u] = %s, ret = %s, ", v8, v10, v11);
while ( (unsigned int)GetProtoParameterCount(a1, v8) > v9 )
{
v12 = v9++;
v13 = (const char *)GetProtoParameter(a1, v8, v12);
printf("para[%u] = %s, ", v9, v13);
}
++v8;
putchar(10);
v1 = (_DWORD *)a1[2];
}
while ( v1[18] > v8 );
}
if ( v1[20] )
{
v14 = 0;
do
{
GetFieldType(a1, v14);
GetFieldName(a1, v14);
v15 = (const char *)GetFieldClass(a1, v14);
v16 = v14++;
printf("field[%u] = %s -> %s (%s)\n", v16, v15, v17, v18);
v1 = (_DWORD *)a1[2];
}
while ( v1[20] > v14 );
}
result = (unsigned int)v1[22];
v20 = 0;
if ( (_DWORD)result )
{
do
{
v21 = GetMethodProtoId((__int64)a1, v20);
GetProtoShorty(a1, v21);
GetMethodName(a1, v20);
v22 = (const char *)GetMethodClass(a1, v20);
v23 = v20++;
printf("method[%u] = %s -> %s (%s)\n", v23, v22, v24, v25);
result = a1[2];
}
while ( *(_DWORD *)(result + 88) > v20 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func14(_QWORD *a1)
{
_DWORD *v1; // rax
unsigned int v2; // ebx
const char *v3; // rax
__int64 v4; // rsi
unsigned int v5; // ebx
const char *v6; // rax
__int64 v7; // rsi
unsigned int v8; // er12
unsigned int v9; // ebx
const char *v10; // rax
const char *v11; // rcx
unsigned int v12; // edx
const char *v13; // rax
unsigned int v14; // ebx
const char *v15; // rax
__int64 v16; // rsi
const char *v17; // rcx
const char *v18; // r8
__int64 result; // rax
unsigned int v20; // ebx
unsigned int v21; // eax
const char *v22; // rax
__int64 v23; // rsi
const char *v24; // rcx
const char *v25; // r8

v1 = (_DWORD *)a1[2];
if ( v1[14] )
{
v2 = 0;
do
{
v3 = (const char *)func0(a1, v2);
v4 = v2++;
printf("string[%u] = %s\n", v4, v3);
v1 = (_DWORD *)a1[2];
}
while ( v1[14] > v2 );
}
if ( v1[16] )
{
v5 = 0;
do
{
v6 = (const char *)func1(a1, v5);
v7 = v5++;
printf("type[%u] = %s\n", v7, v6);
v1 = (_DWORD *)a1[2];
}
while ( v1[16] > v5 );
}
if ( v1[18] )
{
v8 = 0;
do
{
v9 = 0;
func3(a1, v8);
v10 = (const char *)func2(a1, v8);
printf("proto[%u] = %s, ret = %s, ", v8, v10, v11);
while ( (unsigned int)func4(a1, v8) > v9 )
{
v12 = v9++;
v13 = (const char *)func5(a1, v8, v12);
printf("para[%u] = %s, ", v9, v13);
}
++v8;
putchar(10);
v1 = (_DWORD *)a1[2];
}
while ( v1[18] > v8 );
}
if ( v1[20] )
{
v14 = 0;
do
{
func7(a1, v14);
func8(a1, v14);
v15 = (const char *)func6(a1, v14);
v16 = v14++;
printf("field[%u] = %s -> %s (%s)\n", v16, v15, v17, v18);
v1 = (_DWORD *)a1[2];
}
while ( v1[20] > v14 );
}
result = (unsigned int)v1[22];
v20 = 0;
if ( (_DWORD)result )
{
do
{
v21 = func11((__int64)a1, v20);
func2(a1, v21);
func9(a1, v20);
v22 = (const char *)func10(a1, v20);
v23 = v20++;
printf("method[%u] = %s -> %s (%s)\n", v23, v22, v24, v25);
result = a1[2];
}
while ( *(_DWORD *)(result + 88) > v20 );
}
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
unsigned int v3; // esi
const char *v4; // rax

result = *(unsigned int *)(a1[2] + 56LL);
if ( (_DWORD)result )
{
v2 = 0;
do
{
v3 = v2++;
v4 = (const char *)GetString(a1, v3);
puts(v4);
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
unsigned int v3; // esi
const char *v4; // rax

result = *(unsigned int *)(a1[2] + 56LL);
if ( (_DWORD)result )
{
v2 = 0;
do
{
v3 = v2++;
v4 = (const char *)func0(a1, v3);
puts(v4);
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
unsigned int v3; // esi
const char *v4; // rax

result = *(unsigned int *)(a1[2] + 96LL);
if ( (_DWORD)result )
{
v2 = 0;
do
{
v3 = v2++;
v4 = (const char *)GetClassName(a1, v3);
puts(v4);
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
unsigned int v3; // esi
const char *v4; // rax

result = *(unsigned int *)(a1[2] + 96LL);
if ( (_DWORD)result )
{
v2 = 0;
do
{
v3 = v2++;
v4 = (const char *)func12(a1, v3);
puts(v4);
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
unsigned int v4; // esi
const char *v5; // rax
const char *v6; // rdx
const char *v7; // rcx

result = *(unsigned int *)(a1[2] + 88LL);
if ( (_DWORD)result )
{
v2 = 0;
do
{
v3 = GetMethodProtoId((__int64)a1, v2);
GetProtoShorty(a1, v3);
GetMethodName(a1, v2);
v4 = v2++;
v5 = (const char *)GetMethodClass(a1, v4);
printf("%s %s (%s)\n", v5, v6, v7);
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
unsigned int v4; // esi
const char *v5; // rax
const char *v6; // rdx
const char *v7; // rcx

result = *(unsigned int *)(a1[2] + 88LL);
if ( (_DWORD)result )
{
v2 = 0;
do
{
v3 = func11((__int64)a1, v2);
func2(a1, v3);
func9(a1, v2);
v4 = v2++;
v5 = (const char *)func10(a1, v4);
printf("%s %s (%s)\n", v5, v6, v7);
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 __int8 *v2; // rcx
unsigned __int8 *v3; // rsi
unsigned int v4; // edx
unsigned int v5; // eax

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

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

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

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

variable_types:
i
unsigned long


decompiled_code:
__int64 __fastcall ReadULEB128(char **a1)
{
char *v1; // rdx
int v2; // ecx
unsigned int v3; // er8
char v4; // si

v1 = *a1;
v2 = 0;
v3 = 0;
do
{
v4 = *v1++;
v3 |= (v4 & 0x7F) << v2;
if ( v4 >= 0 )
break;
v2 += 7;
}
while ( v2 != 28 );
*a1 = v1;
return v3;
}

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)
{
struct cmsghdr *v1; // rsi
char v3; // [rsp+1h] [rbp-79h] BYREF
__int64 v4[2]; // [rsp+2h] [rbp-78h] BYREF
__int128 v5; // [rsp+12h] [rbp-68h] BYREF
__int64 v6; // [rsp+22h] [rbp-58h]
struct msghdr message; // [rsp+32h] [rbp-48h] BYREF

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

canonical_decompiled_code:
__int64 __fastcall func7(int a1)
{
struct cmsghdr *v1; // rsi
char v3; // [rsp+1h] [rbp-79h] BYREF
__int64 v4[2]; // [rsp+2h] [rbp-78h] BYREF
__int128 v5; // [rsp+12h] [rbp-68h] BYREF
__int64 v6; // [rsp+22h] [rbp-58h]
struct msghdr message; // [rsp+32h] [rbp-48h] BYREF

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

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

return_type: int

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
unsigned int v4; // ebp
int v5; // er12
__int64 v6; // r13
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 )
{
v5 = 1;
perror("socket() failed\n");
}
else
{
v4 = v3;
memset(v9, 0, sizeof(v9));
v8.sa_family = 1;
v11 = 0;
v10 = 0;
strcpy(v8.sa_data, "./demo_socket");
v5 = connect(v3, &v8, 0x6Eu);
if ( v5 )
{
v5 = 1;
perror("connect() failed\n");
}
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
unsigned int v4; // ebp
int v5; // er12
__int64 v6; // r13
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 )
{
v5 = 1;
perror("socket() failed\n");
}
else
{
v4 = v3;
memset(v9, 0, sizeof(v9));
v8.sa_family = 1;
v11 = 0;
v10 = 0;
strcpy(v8.sa_data, "./demo_socket");
v5 = connect(v3, &v8, 0x6Eu);
if ( v5 )
{
v5 = 1;
perror("connect() failed\n");
}
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)
{
unsigned int v2; // eax
__int64 v3; // rbp
char **v4; // rax
char **v5; // r13
const char **v6; // rbx
const char **v7; // rbp
const char *v8; // rdi
void *v10[37]; // [rsp+0h] [rbp-128h] BYREF

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

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

printf("signal revived [%d]\n", (unsigned int)sig);
v2 = backtrace(v10, 32);
v3 = v2;
if ( v2 )
{
v4 = backtrace_symbols(v10, v2);
v5 = v4;
if ( (int)v3 > 0 )
{
v6 = (const char **)v4;
v7 = (const char **)&v4[v3];
do
{
v8 = *v6++;
puts(v8);
}
while ( v6 != v7 );
}
}
else
{
puts("fail to get backtrace");
v5 = backtrace_symbols(v10, 0);
}
free(v5);
_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)
{
char v3; // [rsp+Fh] [rbp-79h] BYREF
__int64 v4[2]; // [rsp+10h] [rbp-78h] BYREF
__int64 v5[2]; // [rsp+20h] [rbp-68h] BYREF
int v6; // [rsp+30h] [rbp-58h]
int v7; // [rsp+34h] [rbp-54h]
struct msghdr message; // [rsp+40h] [rbp-48h] BYREF

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

canonical_decompiled_code:
ssize_t __fastcall func7(int a1, int a2)
{
char v3; // [rsp+Fh] [rbp-79h] BYREF
__int64 v4[2]; // [rsp+10h] [rbp-78h] BYREF
__int64 v5[2]; // [rsp+20h] [rbp-68h] BYREF
int v6; // [rsp+30h] [rbp-58h]
int v7; // [rsp+34h] [rbp-54h]
struct msghdr message; // [rsp+40h] [rbp-48h] BYREF

v6 = a2;
v4[0] = (__int64)&v3;
message.msg_iov = (iovec *)v4;
message.msg_control = v5;
v3 = 70;
v4[1] = 1LL;
*(_QWORD *)&message.msg_flags = 0LL;
message.msg_iovlen = 1LL;
v7 = 0;
message.msg_controllen = 24LL;
v5[0] = 20LL;
v5[1] = 0x100000001LL;
*(_OWORD *)&message.msg_name = 0LL;
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; // ebp
int v4; // er12
int v5; // er13
socklen_t addr_len; // [rsp+Ch] [rbp-FCh] BYREF
struct sockaddr v8; // [rsp+10h] [rbp-F8h] BYREF
struct sockaddr addr; // [rsp+80h] [rbp-88h] BYREF
char v10[88]; // [rsp+90h] [rbp-78h] BYREF
int v11; // [rsp+E8h] [rbp-20h]
__int16 v12; // [rsp+ECh] [rbp-1Ch]

addr_len = 0;
v3 = socket(1, 1, 0);
if ( v3 < 0 )
perror("socket() failed\n");
unlink("./demo_socket");
memset(v10, 0, sizeof(v10));
addr.sa_family = 1;
v12 = 0;
v11 = 0;
strcpy(addr.sa_data, "./demo_socket");
if ( bind(v3, &addr, 0x6Eu) )
{
v4 = 1;
perror("bind() failed\n");
}
else
{
v4 = listen(v3, 5);
if ( v4 )
{
v4 = 1;
perror("listen() failed\n");
}
else
{
v5 = accept(v3, &v8, &addr_len);
if ( v5 >= 0 )
{
puts("client connected");
if ( (int)send_fd((unsigned int)v5, 1LL) < 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; // ebp
int v4; // er12
int v5; // er13
socklen_t addr_len; // [rsp+Ch] [rbp-FCh] BYREF
struct sockaddr v8; // [rsp+10h] [rbp-F8h] BYREF
struct sockaddr addr; // [rsp+80h] [rbp-88h] BYREF
char v10[88]; // [rsp+90h] [rbp-78h] BYREF
int v11; // [rsp+E8h] [rbp-20h]
__int16 v12; // [rsp+ECh] [rbp-1Ch]

addr_len = 0;
v3 = socket(1, 1, 0);
if ( v3 < 0 )
perror("socket() failed\n");
unlink("./demo_socket");
memset(v10, 0, sizeof(v10));
addr.sa_family = 1;
v12 = 0;
v11 = 0;
strcpy(addr.sa_data, "./demo_socket");
if ( bind(v3, &addr, 0x6Eu) )
{
v4 = 1;
perror("bind() failed\n");
}
else
{
v4 = listen(v3, 5);
if ( v4 )
{
v4 = 1;
perror("listen() failed\n");
}
else
{
v5 = accept(v3, &v8, &addr_len);
if ( v5 >= 0 )
{
puts("client connected");
if ( (int)func7((unsigned int)v5, 1LL) < 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

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:
__int64 __fastcall display_object(_QWORD *a1)
{
__int64 result; // rax
__int64 *v3; // rdi
__int64 v4; // rbx

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

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

if ( a1 )
{
result = log_printf("display_object: object handle 0x%08x class 0x%08x\n", *a1, a1[1]);
v3 = (__int64 *)a1[3];
if ( v3[2] )
{
v4 = 24LL;
do
{
result = func0(v3);
v3 = (__int64 *)(v4 + a1[3]);
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
__m128i v1; // xmm0

log_printf("CKI_Info_New: entered\n");
result = (char *)malloc(0x58uLL);
if ( result )
{
v1 = _mm_load_si128((const __m128i *)&LC2);
*((_QWORD *)result + 5) = 0LL;
*(_WORD *)result = 0;
*((_WORD *)result + 40) = 0;
*(__m128i *)(result + 2) = v1;
*(__m128i *)(result + 18) = v1;
*((__m128i *)result + 3) = v1;
*((__m128i *)result + 4) = v1;
}
return result;
}

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

log_printf("CKI_Info_New: entered\n");
result = (char *)malloc(0x58uLL);
if ( result )
{
v1 = _mm_load_si128((const __m128i *)&LC2);
*((_QWORD *)result + 5) = 0LL;
*(_WORD *)result = 0;
*((_WORD *)result + 40) = 0;
*(__m128i *)(result + 2) = v1;
*(__m128i *)(result + 18) = v1;
*((__m128i *)result + 3) = v1;
*((__m128i *)result + 4) = v1;
}
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 )
{
result[1] = 0LL;
*(_WORD *)result = 0;
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 )
{
result[1] = 0LL;
*(_WORD *)result = 0;
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 *


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

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

original_code:
void CKI_FunctionList_Free(CK_FUNCTION_LIST_PTR pFunctionList) {
    log_printf("CKI_FunctionList_Free: entered\n");
    if (pFunctionList==((void *)0)) return;
    free(pFunctionList);
    return;
}

canonical_original_code:
void CKI_FunctionList_Free(struct CK_FUNCTION_LIST *pFunctionList) {
    log_printf("CKI_FunctionList_Free: entered\n");
    if (pFunctionList==((void *)0)) return;
    free(pFunctionList);
    return;
}

variable_types: struct CK_FUNCTION_LIST { struct CK_VERSION { unsigned char major; unsigned char minor; } version; unsigned long (*C_Initialize)(void *pReserved); unsigned long (*C_Finalize)(void *pReserved); unsigned long (*C_GetInfo)(struct CK_INFO { struct CK_VERSION cryptokiVersion; unsigned char manufacturerID[32]; unsigned long flags; unsigned char libraryDescription[32]; struct CK_VERSION libraryVersion; } *pInfo); unsigned long (*C_GetFunctionList)(struct CK_FUNCTION_LIST **ppFunctionList); unsigned long (*C_GetSlotList)(unsigned char tokenPresent, unsigned long *pSlotList, unsigned long *pulCount); unsigned long (*C_GetSlotInfo)(unsigned long slotID, struct CK_SLOT_INFO { unsigned char slotDescription[64]; unsigned char manufacturerID[32]; unsigned long flags; struct CK_VERSION hardwareVersion; struct CK_VERSION firmwareVersion; } *pInfo); unsigned long (*C_GetTokenInfo)(unsigned long slotID, 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]; } *pInfo); unsigned long (*C_GetMechanismList)(unsigned long slotID, unsigned short *pMechanismList, unsigned long *pulCount); unsigned long (*C_GetMechanismInfo)(unsigned long slotID, unsigned short type, struct CK_MECHANISM_INFO { unsigned long ulMinKeySize; unsigned long ulMaxKeySize; unsigned long flags; } *pInfo); unsigned long (*C_InitToken)(unsigned long slotID, unsigned char *pPin, unsigned long ulPinLen, unsigned char *pLabel); unsigned long (*C_InitPIN)(unsigned long hSession, unsigned char *pPin, unsigned long ulPinLen); unsigned long (*C_SetPIN)(unsigned long hSession, unsigned char *pOldPin, unsigned long ulOldLen, unsigned char *pNewPin, unsigned long ulNewLen); unsigned long (*C_OpenSession)(unsigned long slotID, unsigned long flags, void *pApplication, unsigned long *Notify, unsigned long *phSession); unsigned long (*C_CloseSession)(unsigned long hSession); unsigned long (*C_CloseAllSessions)(unsigned long slotID); unsigned long (*C_GetSessionInfo)(unsigned long hSession, struct CK_SESSION_INFO { unsigned long slotID; unsigned long state; unsigned long flags; unsigned long ulDeviceError; } *pInfo); unsigned long (*C_GetOperationState)(unsigned long hSession, unsigned char *pOperationState, unsigned long *pulOperationStateLen); unsigned long (*C_SetOperationState)(unsigned long hSession, unsigned char *pOperationState, unsigned long ulOperationStateLen, unsigned long hEncryptionKey, unsigned long hAuthenticationKey); unsigned long (*C_Login)(unsigned long hSession, unsigned long userType, unsigned char *pPin, unsigned long ulPinLen); unsigned long (*C_Logout)(unsigned long hSession); unsigned long (*C_CreateObject)(unsigned long hSession, struct CK_ATTRIBUTE { unsigned long type; void *value; unsigned long ulValueLen; } *pTemplate, unsigned long ulCount, unsigned long *pObject); unsigned long (*C_CopyObject)(unsigned long hSession, unsigned long hObject, struct CK_ATTRIBUTE *pTemplate, unsigned long ulCount, unsigned long *pNewObject); unsigned long (*C_DestroyObject)(unsigned long hSession, unsigned long hObject); unsigned long (*C_GetObjectSize)(unsigned long hSession, unsigned long hObject, unsigned long *pulSize); unsigned long (*C_GetAttributeValue)(unsigned long hSession, unsigned long hObject, struct CK_ATTRIBUTE *pTemplate, unsigned long ulCount); unsigned long (*C_SetAttributeValue)(unsigned long hSession, unsigned long hObject, struct CK_ATTRIBUTE *pTemplate, unsigned long ulCount); unsigned long (*C_FindObjectsInit)(unsigned long hSession, struct CK_ATTRIBUTE *pTemplate, unsigned long ulCount); unsigned long (*C_FindObjects)(unsigned long hSession, unsigned long *phObject, unsigned long ulMaxObjectCount, unsigned long *pulObjectCount); unsigned long (*C_FindObjectsFinal)(unsigned long hSession); unsigned long (*C_EncryptInit)(unsigned long hSession, struct CK_MECHANISM { unsigned short mechanism; void *pParameter; unsigned long ulParameterLen; } *pMechanism, unsigned long hKey); unsigned long (*C_Encrypt)(unsigned long hSession, unsigned char *pData, unsigned long ulDataLen, unsigned char *pEncryptedData, unsigned long *pulEncryptedDataLen); unsigned long (*C_EncryptUpdate)(unsigned long hSession, unsigned char *pPart, unsigned long ulPartLen, unsigned char *pEncryptedPart, unsigned long *pulEncryptedPartLen); unsigned long (*C_EncryptFinal)(unsigned long hSession, unsigned char *pLastEncryptedPart, unsigned long *pulLastEncyptedPartLen); unsigned long (*C_DecryptInit)(unsigned long hSession, struct CK_MECHANISM *pMechanism, unsigned long hKey); unsigned long (*C_Decrypt)(unsigned long hSession, unsigned char *pEncryptedData, unsigned long ulEncryptedDataLen, unsigned long *pulDataLen); unsigned long (*C_DecryptUpdate)(unsigned long hSession, unsigned char *pEncryptedPart, unsigned long ulEncryptedPartLen, unsigned char *pPart, unsigned long *pulPartLen); unsigned long (*C_DecryptFinal)(unsigned long hSession, unsigned char *pLastPart, unsigned long *pulLastPartLen); unsigned long (*C_DigestInit)(unsigned long hSession, struct CK_MECHANISM *pMechanism); unsigned long (*C_Digest)(unsigned long hSession, unsigned char *pData, unsigned long ulDataLen, unsigned char *pDigest, unsigned long *pulDigestLen); unsigned long (*C_DigestUpdate)(unsigned long hSession, unsigned char *pPart, unsigned long ulPartLen); unsigned long (*C_DigestKey)(unsigned long hSession, unsigned long hKey); unsigned long (*C_DigestFinal)(unsigned long hSession, unsigned char *pDigest, unsigned long *pulDigestLen); unsigned long (*C_SignInit)(unsigned long hSession, struct CK_MECHANISM *pMechanism, unsigned long hKey); unsigned long (*C_Sign)(unsigned long hSession, unsigned char *pData, unsigned long ulDataLen, unsigned char *pSignature, unsigned long *pulSignatureLen); unsigned long (*C_SignUpdate)(unsigned long hSession, unsigned char *pData, unsigned long ulPartLen); unsigned long (*C_SignFinal)(unsigned long hSession, unsigned char *pSignature, unsigned long *pulSignatureLen); unsigned long (*C_SignRecoverInit)(unsigned long hSession, struct CK_MECHANISM *pMechanism, unsigned long hKey); unsigned long (*C_SignRecover)(unsigned long hSession, unsigned char *pData, unsigned long ulDataLen, unsigned char *pSignature, unsigned long *pulSignature); unsigned long (*C_VerifyInit)(unsigned long hSession, struct CK_MECHANISM *pMechanism, unsigned long hKey); unsigned long (*C_Verify)(unsigned long hSession, unsigned char *pData, unsigned long ulDataLen, unsigned char *pSignature, unsigned long ulSignatureLen); unsigned long (*C_VerifyUpdate)(unsigned long hSession, unsigned char *pPart, unsigned long ulPartLen); unsigned long (*C_VerifyFinal)(unsigned long hSession, unsigned char *pSignature, unsigned long ulSignatureLen); unsigned long (*C_VerifyRecoverInit)(unsigned long hSession, struct CK_MECHANISM *pMechanism, unsigned long hKey); unsigned long (*C_VerifyRecover)(unsigned long hSession, unsigned char *pSignature, unsigned long ulSignatureLen, unsigned char *pData, unsigned long *pulDataLen); unsigned long (*C_DigestEncryptUpdate)(unsigned long hSession, unsigned char *pPart, unsigned long ulPartLen, unsigned char *pEncryptedPart, unsigned long *pulEncryptedPartLen); unsigned long (*C_DecryptDigestUpdate)(unsigned long hSession, unsigned char *pEncryptedPart, unsigned long pEncryptedPartLen, unsigned char *pPart, unsigned long *pulPartLen); unsigned long (*C_SignEncryptUpdate)(unsigned long hSession, unsigned char *pPart, unsigned long ulPartLen, unsigned char *pEncryptedPart, unsigned long *pulEncryptedPartLen); unsigned long (*C_DecryptVerifyUpdate)(unsigned long hSession, unsigned char *pEncryptedPart, unsigned long ulEncryptedPartLen, unsigned char *pPart, unsigned long *pulPartLen); unsigned long (*C_GenerateKey)(unsigned long hSession, struct CK_MECHANISM *pMechanism, struct CK_ATTRIBUTE *pTemplate, unsigned long ulCount, unsigned long *phKey); unsigned long (*C_GenerateKeyPair)(unsigned long hSession, struct CK_MECHANISM *pMechanism, struct CK_ATTRIBUTE *pPublicKeyTemplate, unsigned long ulPublicKeyAttributeCount, struct CK_ATTRIBUTE *pPrivateKeyTemplate, unsigned long ulPrivateKeyAttributeCount, unsigned long *phPublicKey, unsigned long *phPrivateKey); unsigned long (*C_WrapKey)(unsigned long hSession, struct CK_MECHANISM *pMechanism, unsigned long hWrappingKey, unsigned long hKey, unsigned char *pWrappedKey, unsigned long *pulWrappedKeyLen); unsigned long (*C_UnwrapKey)(unsigned long hSession, struct CK_MECHANISM *pMechanism, unsigned long hUnwrappingKey, unsigned char *pWrappedKey, unsigned long ulWrappedKeyLen, struct CK_ATTRIBUTE *pTemplate, unsigned long ulAttributeCount, unsigned long *phKey); unsigned long (*C_DeriveKey)(unsigned long hSession, struct CK_MECHANISM *pMechanism, unsigned long hBaseKey, struct CK_ATTRIBUTE *pTemplate, unsigned long ulAttributeCount, unsigned long *phKey); unsigned long (*C_SeedRandom)(unsigned long hSession, unsigned char *pSeed, unsigned long ulSeedLen); unsigned long (*C_GenerateRandom)(unsigned long hSession, unsigned char *pRandomData, unsigned long ulRandomLen); unsigned long (*C_GetFunctionStatus)(unsigned long hSession); unsigned long (*C_CancelFunction)(unsigned long hSession); } *

user_defined_types: struct CK_FUNCTION_LIST { struct CK_VERSION version; unsigned long (*C_Initialize)(void *pReserved); unsigned long (*C_Finalize)(void *pReserved); unsigned long (*C_GetInfo)(struct CK_INFO *pInfo); unsigned long (*C_GetFunctionList)(struct CK_FUNCTION_LIST **ppFunctionList); unsigned long (*C_GetSlotList)(unsigned char tokenPresent, unsigned long *pSlotList, unsigned long *pulCount); unsigned long (*C_GetSlotInfo)(unsigned long slotID, struct CK_SLOT_INFO *pInfo); unsigned long (*C_GetTokenInfo)(unsigned long slotID, struct CK_TOKEN_INFO *pInfo); unsigned long (*C_GetMechanismList)(unsigned long slotID, unsigned short *pMechanismList, unsigned long *pulCount); unsigned long (*C_GetMechanismInfo)(unsigned long slotID, unsigned short type, struct CK_MECHANISM_INFO *pInfo); unsigned long (*C_InitToken)(unsigned long slotID, unsigned char *pPin, unsigned long ulPinLen, unsigned char *pLabel); unsigned long (*C_InitPIN)(unsigned long hSession, unsigned char *pPin, unsigned long ulPinLen); unsigned long (*C_SetPIN)(unsigned long hSession, unsigned char *pOldPin, unsigned long ulOldLen, unsigned char *pNewPin, unsigned long ulNewLen); unsigned long (*C_OpenSession)(unsigned long slotID, unsigned long flags, void *pApplication, unsigned long *Notify, unsigned long *phSession); unsigned long (*C_CloseSession)(unsigned long hSession); unsigned long (*C_CloseAllSessions)(unsigned long slotID); unsigned long (*C_GetSessionInfo)(unsigned long hSession, struct CK_SESSION_INFO *pInfo); unsigned long (*C_GetOperationState)(unsigned long hSession, unsigned char *pOperationState, unsigned long *pulOperationStateLen); unsigned long (*C_SetOperationState)(unsigned long hSession, unsigned char *pOperationState, unsigned long ulOperationStateLen, unsigned long hEncryptionKey, unsigned long hAuthenticationKey); unsigned long (*C_Login)(unsigned long hSession, unsigned long userType, unsigned char *pPin, unsigned long ulPinLen); unsigned long (*C_Logout)(unsigned long hSession); unsigned long (*C_CreateObject)(unsigned long hSession, struct CK_ATTRIBUTE *pTemplate, unsigned long ulCount, unsigned long *pObject); unsigned long (*C_CopyObject)(unsigned long hSession, unsigned long hObject, struct CK_ATTRIBUTE *pTemplate, unsigned long ulCount, unsigned long *pNewObject); unsigned long (*C_DestroyObject)(unsigned long hSession, unsigned long hObject); unsigned long (*C_GetObjectSize)(unsigned long hSession, unsigned long hObject, unsigned long *pulSize); unsigned long (*C_GetAttributeValue)(unsigned long hSession, unsigned long hObject, struct CK_ATTRIBUTE *pTemplate, unsigned long ulCount); unsigned long (*C_SetAttributeValue)(unsigned long hSession, unsigned long hObject, struct CK_ATTRIBUTE *pTemplate, unsigned long ulCount); unsigned long (*C_FindObjectsInit)(unsigned long hSession, struct CK_ATTRIBUTE *pTemplate, unsigned long ulCount); unsigned long (*C_FindObjects)(unsigned long hSession, unsigned long *phObject, unsigned long ulMaxObjectCount, unsigned long *pulObjectCount); unsigned long (*C_FindObjectsFinal)(unsigned long hSession); unsigned long (*C_EncryptInit)(unsigned long hSession, struct CK_MECHANISM *pMechanism, unsigned long hKey); unsigned long (*C_Encrypt)(unsigned long hSession, unsigned char *pData, unsigned long ulDataLen, unsigned char *pEncryptedData, unsigned long *pulEncryptedDataLen); unsigned long (*C_EncryptUpdate)(unsigned long hSession, unsigned char *pPart, unsigned long ulPartLen, unsigned char *pEncryptedPart, unsigned long *pulEncryptedPartLen); unsigned long (*C_EncryptFinal)(unsigned long hSession, unsigned char *pLastEncryptedPart, unsigned long *pulLastEncyptedPartLen); unsigned long (*C_DecryptInit)(unsigned long hSession, struct CK_MECHANISM *pMechanism, unsigned long hKey); unsigned long (*C_Decrypt)(unsigned long hSession, unsigned char *pEncryptedData, unsigned long ulEncryptedDataLen, unsigned long *pulDataLen); unsigned long (*C_DecryptUpdate)(unsigned long hSession, unsigned char *pEncryptedPart, unsigned long ulEncryptedPartLen, unsigned char *pPart, unsigned long *pulPartLen); unsigned long (*C_DecryptFinal)(unsigned long hSession, unsigned char *pLastPart, unsigned long *pulLastPartLen); unsigned long (*C_DigestInit)(unsigned long hSession, struct CK_MECHANISM *pMechanism); unsigned long (*C_Digest)(unsigned long hSession, unsigned char *pData, unsigned long ulDataLen, unsigned char *pDigest, unsigned long *pulDigestLen); unsigned long (*C_DigestUpdate)(unsigned long hSession, unsigned char *pPart, unsigned long ulPartLen); unsigned long (*C_DigestKey)(unsigned long hSession, unsigned long hKey); unsigned long (*C_DigestFinal)(unsigned long hSession, unsigned char *pDigest, unsigned long *pulDigestLen); unsigned long (*C_SignInit)(unsigned long hSession, struct CK_MECHANISM *pMechanism, unsigned long hKey); unsigned long (*C_Sign)(unsigned long hSession, unsigned char *pData, unsigned long ulDataLen, unsigned char *pSignature, unsigned long *pulSignatureLen); unsigned long (*C_SignUpdate)(unsigned long hSession, unsigned char *pData, unsigned long ulPartLen); unsigned long (*C_SignFinal)(unsigned long hSession, unsigned char *pSignature, unsigned long *pulSignatureLen); unsigned long (*C_SignRecoverInit)(unsigned long hSession, struct CK_MECHANISM *pMechanism, unsigned long hKey); unsigned long (*C_SignRecover)(unsigned long hSession, unsigned char *pData, unsigned long ulDataLen, unsigned char *pSignature, unsigned long *pulSignature); unsigned long (*C_VerifyInit)(unsigned long hSession, struct CK_MECHANISM *pMechanism, unsigned long hKey); unsigned long (*C_Verify)(unsigned long hSession, unsigned char *pData, unsigned long ulDataLen, unsigned char *pSignature, unsigned long ulSignatureLen); unsigned long (*C_VerifyUpdate)(unsigned long hSession, unsigned char *pPart, unsigned long ulPartLen); unsigned long (*C_VerifyFinal)(unsigned long hSession, unsigned char *pSignature, unsigned long ulSignatureLen); unsigned long (*C_VerifyRecoverInit)(unsigned long hSession, struct CK_MECHANISM *pMechanism, unsigned long hKey); unsigned long (*C_VerifyRecover)(unsigned long hSession, unsigned char *pSignature, unsigned long ulSignatureLen, unsigned char *pData, unsigned long *pulDataLen); unsigned long (*C_DigestEncryptUpdate)(unsigned long hSession, unsigned char *pPart, unsigned long ulPartLen, unsigned char *pEncryptedPart, unsigned long *pulEncryptedPartLen); unsigned long (*C_DecryptDigestUpdate)(unsigned long hSession, unsigned char *pEncryptedPart, unsigned long pEncryptedPartLen, unsigned char *pPart, unsigned long *pulPartLen); unsigned long (*C_SignEncryptUpdate)(unsigned long hSession, unsigned char *pPart, unsigned long ulPartLen, unsigned char *pEncryptedPart, unsigned long *pulEncryptedPartLen); unsigned long (*C_DecryptVerifyUpdate)(unsigned long hSession, unsigned char *pEncryptedPart, unsigned long ulEncryptedPartLen, unsigned char *pPart, unsigned long *pulPartLen); unsigned long (*C_GenerateKey)(unsigned long hSession, struct CK_MECHANISM *pMechanism, struct CK_ATTRIBUTE *pTemplate, unsigned long ulCount, unsigned long *phKey); unsigned long (*C_GenerateKeyPair)(unsigned long hSession, struct CK_MECHANISM *pMechanism, struct CK_ATTRIBUTE *pPublicKeyTemplate, unsigned long ulPublicKeyAttributeCount, struct CK_ATTRIBUTE *pPrivateKeyTemplate, unsigned long ulPrivateKeyAttributeCount, unsigned long *phPublicKey, unsigned long *phPrivateKey); unsigned long (*C_WrapKey)(unsigned long hSession, struct CK_MECHANISM *pMechanism, unsigned long hWrappingKey, unsigned long hKey, unsigned char *pWrappedKey, unsigned long *pulWrappedKeyLen); unsigned long (*C_UnwrapKey)(unsigned long hSession, struct CK_MECHANISM *pMechanism, unsigned long hUnwrappingKey, unsigned char *pWrappedKey, unsigned long ulWrappedKeyLen, struct CK_ATTRIBUTE *pTemplate, unsigned long ulAttributeCount, unsigned long *phKey); unsigned long (*C_DeriveKey)(unsigned long hSession, struct CK_MECHANISM *pMechanism, unsigned long hBaseKey, struct CK_ATTRIBUTE *pTemplate, unsigned long ulAttributeCount, unsigned long *phKey); unsigned long (*C_SeedRandom)(unsigned long hSession, unsigned char *pSeed, unsigned long ulSeedLen); unsigned long (*C_GenerateRandom)(unsigned long hSession, unsigned char *pRandomData, unsigned long ulRandomLen); unsigned long (*C_GetFunctionStatus)(unsigned long hSession); unsigned long (*C_CancelFunction)(unsigned long hSession); }