ASCIIZ

canonical_decompiled_code:
char *__fastcall func10(char *src)
{
unsigned int v1; // ebx
char *v2; // rax

v1 = strlen(src);
v2 = (char *)ArrayAlloc(v1, 1u);
return strncpy(v2, src, v1);
}

original_code:
char *ASCIIZ(const char *str) {
  unsigned len = strlen(str);
  char *str2 = (char *)ArrayAlloc(len,1);
  strncpy(str2,str,len);
  return str2;
}

canonical_original_code:
char *ASCIIZ(char *str) {
  unsigned int len = strlen(str);
  char *str2 = (char *)ArrayAlloc(len,1);
  strncpy(str2,str,len);
  return str2;
}

variable_types:
str
char *

variable_types:
len
unsigned int


ArraySizeAuto

repo: embeddedarm/libtsctl

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

result = a1;
*(_DWORD *)(a1 - 4) = a2;
return result;
}

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

result = a1;
*(_DWORD *)(a1 - 4) = a2;
return result;
}

original_code:
void *ArraySizeAuto(void *arr,unsigned count) {
  unsigned *ptr = (unsigned *)arr;
  ptr -= 3;
  ptr[2] = count;
  return &ptr[3];
}

canonical_original_code:
void *ArraySizeAuto(void *arr, unsigned int count) {
  unsigned int *ptr = (unsigned *)arr;
  ptr -= 3;
  ptr[2] = count;
  return &ptr[3];
}

variable_types:
arr
void *

variable_types:
count
unsigned int

variable_types:
ptr
unsigned int *

return_type: void *


ArrayElementSize

decompiled_code:
__int64 __fastcall ArrayElementSize(__int64 a1)
{
return *(unsigned int *)(a1 - 8);
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1)
{
return *(unsigned int *)(a1 - 8);
}

original_code:
unsigned ArrayElementSize(const void *array) {
  return _ArrayElementSize(array);
}

canonical_original_code:
unsigned int ArrayElementSize(void *array) {
  return _ArrayElementSize(array);
}

variable_types:
array
void *

return_type: unsigned int


ArrayLength

decompiled_code:
__int64 __fastcall ArrayLength(__int64 a1)
{
return *(unsigned int *)(a1 - 4);
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1)
{
return *(unsigned int *)(a1 - 4);
}

original_code:
unsigned ArrayLength(const void *array) {
  return _ArrayLength(array);
}

canonical_original_code:
unsigned int ArrayLength(void *array) {
  return _ArrayLength(array);
}


ArrayFreeFree

decompiled_code:
void __fastcall ArrayFreeFree(__int64 a1)
{
__int64 v2; // rbx
__int64 v3; // rdi

if ( *(_DWORD *)(a1 - 4) )
{
v2 = 0LL;
do
{
v3 = *(_QWORD *)(a1 + 8 * v2);
if ( v3 )
ArrayFree(v3);
++v2;
}
while ( *(_DWORD *)(a1 - 4) > (unsigned int)v2 );
}
ArrayFree(a1);
}

original_code:
void ArrayFreeFree(const void *arr0) {
  const void * const *arr = (const void * const *)arr0;
  int i;
  for (i=0;i<_ArrayLength(arr);i++) {
    if (arr[i]) ArrayFree(arr[i]);
  }
  ArrayFree(arr);
}

canonical_original_code:
void ArrayFreeFree(void *arr0) {
  void **arr = (const void * const *)arr0;
  int i;
  for (i=0;i<_ArrayLength(arr);i++) {
    if (arr[i]) ArrayFree(arr[i]);
  }
  ArrayFree(arr);
}

variable_types:
arr
void **

variable_types: i int

return_type: void


ArrayFreeFreeFree

decompiled_code:
void __fastcall ArrayFreeFreeFree(__int64 a1)
{
__int64 v2; // rbp
__int64 v3; // rdi
__int64 v4; // rbx
__int64 v5; // rdi

if ( *(_DWORD *)(a1 - 4) )
{
v2 = 0LL;
do
{
v3 = *(_QWORD *)(a1 + 8 * v2);
if ( v3 )
{
if ( *(_DWORD *)(v3 - 4) )
{
v4 = 0LL;
do
{
v5 = *(_QWORD *)(v3 + 8 * v4);
if ( v5 )
ArrayFree(v5);
v3 = *(_QWORD *)(a1 + 8 * v2);
++v4;
}
while ( *(_DWORD *)(v3 - 4) > (unsigned int)v4 );
}
ArrayFree(v3);
}
++v2;
}
while ( *(_DWORD *)(a1 - 4) > (unsigned int)v2 );
}
ArrayFree(a1);
}

original_code:
void ArrayFreeFreeFree(const void *arr0) {
  const void ** const *arr = (const void ** const *)arr0;
  int i,j;
  for (i=0;i<_ArrayLength(arr);i++) {
    if (arr[i]) {
      for (j=0;j<_ArrayLength(arr[i]);j++) {
 if (arr[i][j]) ArrayFree(arr[i][j]);
      }
      ArrayFree(arr[i]);
    }
  }
  ArrayFree(arr);
}

canonical_original_code:
void ArrayFreeFreeFree(void *arr0) {
  void ***arr = (const void ** const *)arr0;
  int i; int j;
  for (i=0;i<_ArrayLength(arr);i++) {
    if (arr[i]) {
      for (j=0;j<_ArrayLength(arr[i]);j++) {
 if (arr[i][j]) ArrayFree(arr[i][j]);
      }
      ArrayFree(arr[i]);
    }
  }
  ArrayFree(arr);
}

variable_types:
arr
void ***

variable_types: j int


ArrayCompareFunction

decompiled_code:
__int64 ArrayCompareFunction()
{
return ArrayCompareFunction();
}

canonical_decompiled_code:
__int64 func16()
{
return func16();
}

original_code:
void *ArrayCompareFunction(const void *array) {
  return ArrayCompareFunction(array);
}

canonical_original_code:
void *ArrayCompareFunction(void *array) {
  return ArrayCompareFunction(array);
}


decompiled_code:
__int64 __fastcall MarvellPXA166DIORawLock(__int64 a1, __int64 a2, char a3)
{
if ( (a3 & 2) != 0 )
++*(_DWORD *)(a1 + 84);
else
++*(_DWORD *)(a1 + 88);
return 1LL;
}

original_code:
int MarvellPXA166DIORawLock(MarvellPXA166DIORaw *ob, unsigned num, int flags) {
  if (flags & SHARED) {
    ob->deferlockR++;
  } else {
    ob->deferlockW++;
  }
  return 1;
}

canonical_original_code:
int MarvellPXA166DIORawLock(struct MarvellPXA166DIORaw *ob, unsigned int num, int flags) {
  if (flags & SHARED) {
    ob->deferlockR++;
  } else {
    ob->deferlockW++;
  }
  return 1;
}

variable_types: struct MarvellPXA166DIORaw { void *(*Init)(struct MarvellPXA166DIORaw *me, void *bus); void (*Fini)(struct MarvellPXA166DIORaw *me); int (*Lock)(struct MarvellPXA166DIORaw *me, unsigned int num, int flags); int (*Unlock)(struct MarvellPXA166DIORaw *me, unsigned int num, int flags); int (*Preempt)(struct MarvellPXA166DIORaw *me); void (*DirSet)(struct MarvellPXA166DIORaw *me, int num, int asOutput); void (*DataSet)(struct MarvellPXA166DIORaw *me, int num, int asHigh); int (*DirGet)(struct MarvellPXA166DIORaw *me, int num); int (*DataGet)(struct MarvellPXA166DIORaw *me, int num); unsigned int (*Count)(struct MarvellPXA166DIORaw *me); int InitStatus; int deferlockR; int deferlockW; struct Bus { void *(*Init)(void *me, ...); void (*Fini)(void *me); int (*Lock)(void *me, unsigned int num, int flags); int (*Unlock)(void *me, unsigned int num, int flags); int (*Preempt)(void *me); unsigned char (*Peek8)(void *me, int Address); void (*Poke8)(void *me, int Address, unsigned char Value); unsigned short (*Peek16)(void *me, int Address); void (*Poke16)(void *me, int Address, unsigned short Value); unsigned int (*Peek32)(void *me, int Address); void (*Poke32)(void *me, int Address, unsigned int Value); int (*BitGet8)(void *me, int Address, int BitNumber); void (*BitAssign8)(void *me, int Address, int BitNumber, int Value); void (*BitSet8)(void *me, int Address, int BitNumber); void (*BitClear8)(void *me, int Address, int BitNumber); int (*BitGet16)(void *me, int Address, int BitNumber); void (*BitAssign16)(void *me, int Address, int BitNumber, int Value); void (*BitSet16)(void *me, int Address, int BitNumber); void (*BitClear16)(void *me, int Address, int BitNumber); int (*BitGet32)(void *me, int Address, int BitNumber); void (*BitAssign32)(void *me, int Address, int BitNumber, int Value); void (*BitSet32)(void *me, int Address, int BitNumber); void (*BitClear32)(void *me, int Address, int BitNumber); void (*PeekStream)(void *me, int address, int direction, char *dest); void (*PokeStream)(void *me, int address, int direction, char *data); void (*Refresh)(void *me); void (*Commit)(void *me, int ForceAll); int (*BitToggle8)(void *me, int Address, int BitNumber); int (*BitToggle16)(void *me, int Address, int BitNumber); int (*BitToggle32)(void *me, int Address, int BitNumber); unsigned char (*Assign8X)(void *me, int Address, int BitMSB, int BitLSB, int Value); unsigned short (*Assign16X)(void *me, int Address, int BitMSB, int BitLSB, int Value); unsigned int (*Assign32X)(void *me, int Address, int BitMSB, int BitLSB, int Value); unsigned char (*BitsGet8)(void *me, int Address, int BitMSB, int BitLSB); unsigned short (*BitsGet16)(void *me, int Address, int BitMSB, int BitLSB); unsigned int (*BitsGet32)(void *me, int Address, int BitMSB, int BitLSB); int InitStatus; unsigned int LockBase; int deferlockW; int deferlockR; } *sub; } *

variable_types:
num
unsigned int

variable_types: flags int

return_type: int

user_defined_types: struct MarvellPXA166DIORaw { void *(*Init)(struct MarvellPXA166DIORaw *me, void *bus); void (*Fini)(struct MarvellPXA166DIORaw *me); int (*Lock)(struct MarvellPXA166DIORaw *me, unsigned int num, int flags); int (*Unlock)(struct MarvellPXA166DIORaw *me, unsigned int num, int flags); int (*Preempt)(struct MarvellPXA166DIORaw *me); void (*DirSet)(struct MarvellPXA166DIORaw *me, int num, int asOutput); void (*DataSet)(struct MarvellPXA166DIORaw *me, int num, int asHigh); int (*DirGet)(struct MarvellPXA166DIORaw *me, int num); int (*DataGet)(struct MarvellPXA166DIORaw *me, int num); unsigned int (*Count)(struct MarvellPXA166DIORaw *me); int InitStatus; int deferlockR; int deferlockW; struct Bus *sub; }


original_code:
int MarvellPXA166DIORawUnlock(MarvellPXA166DIORaw *ob, unsigned num, int flags) {
  if (flags & SHARED) {
    if (ob->deferlockR) {
      ob->deferlockR--;
    } else {
      ob->sub->Unlock(ob->sub,num,flags);
    }
    return 1;
  } else {
    if (ob->deferlockW) {
      ob->deferlockW--;
    } else {
      ob->sub->Unlock(ob->sub,num,flags);
    }
    return 1;
  }
}

canonical_original_code:
int MarvellPXA166DIORawUnlock(struct MarvellPXA166DIORaw *ob, unsigned int num, int flags) {
  if (flags & SHARED) {
    if (ob->deferlockR) {
      ob->deferlockR--;
    } else {
      ob->sub->Unlock(ob->sub,num,flags);
    }
    return 1;
  } else {
    if (ob->deferlockW) {
      ob->deferlockW--;
    } else {
      ob->sub->Unlock(ob->sub,num,flags);
    }
    return 1;
  }
}

user_defined_types: struct Bus { void *(*Init)(void *me, ...); void (*Fini)(void *me); int (*Lock)(void *me, unsigned int num, int flags); int (*Unlock)(void *me, unsigned int num, int flags); int (*Preempt)(void *me); unsigned char (*Peek8)(void *me, int Address); void (*Poke8)(void *me, int Address, unsigned char Value); unsigned short (*Peek16)(void *me, int Address); void (*Poke16)(void *me, int Address, unsigned short Value); unsigned int (*Peek32)(void *me, int Address); void (*Poke32)(void *me, int Address, unsigned int Value); int (*BitGet8)(void *me, int Address, int BitNumber); void (*BitAssign8)(void *me, int Address, int BitNumber, int Value); void (*BitSet8)(void *me, int Address, int BitNumber); void (*BitClear8)(void *me, int Address, int BitNumber); int (*BitGet16)(void *me, int Address, int BitNumber); void (*BitAssign16)(void *me, int Address, int BitNumber, int Value); void (*BitSet16)(void *me, int Address, int BitNumber); void (*BitClear16)(void *me, int Address, int BitNumber); int (*BitGet32)(void *me, int Address, int BitNumber); void (*BitAssign32)(void *me, int Address, int BitNumber, int Value); void (*BitSet32)(void *me, int Address, int BitNumber); void (*BitClear32)(void *me, int Address, int BitNumber); void (*PeekStream)(void *me, int address, int direction, char *dest); void (*PokeStream)(void *me, int address, int direction, char *data); void (*Refresh)(void *me); void (*Commit)(void *me, int ForceAll); int (*BitToggle8)(void *me, int Address, int BitNumber); int (*BitToggle16)(void *me, int Address, int BitNumber); int (*BitToggle32)(void *me, int Address, int BitNumber); unsigned char (*Assign8X)(void *me, int Address, int BitMSB, int BitLSB, int Value); unsigned short (*Assign16X)(void *me, int Address, int BitMSB, int BitLSB, int Value); unsigned int (*Assign32X)(void *me, int Address, int BitMSB, int BitLSB, int Value); unsigned char (*BitsGet8)(void *me, int Address, int BitMSB, int BitLSB); unsigned short (*BitsGet16)(void *me, int Address, int BitMSB, int BitLSB); unsigned int (*BitsGet32)(void *me, int Address, int BitMSB, int BitLSB); int InitStatus; unsigned int LockBase; int deferlockW; int deferlockR; }


decompiled_code:
__int64 MarvellPXA166DIORawPreempt()
{
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func2()
{
return 0xFFFFFFFFLL;
}

original_code:
int MarvellPXA166DIORawPreempt(MarvellPXA166DIORaw *ob) {
  return -1;
}

canonical_original_code:
int MarvellPXA166DIORawPreempt(struct MarvellPXA166DIORaw *ob) {
  return -1;
}


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

result = a1;
if ( *(int *)(a1 + 80) <= 0 )
{
*(_QWORD *)a1 = MarvellPXA166DIORawInit;
*(_QWORD *)(a1 + 8) = MarvellPXA166DIORawFini;
*(_QWORD *)(a1 + 16) = MarvellPXA166DIORawLock;
*(_QWORD *)(a1 + 24) = MarvellPXA166DIORawUnlock;
*(_QWORD *)(a1 + 32) = MarvellPXA166DIORawPreempt;
*(_QWORD *)(a1 + 40) = MarvellPXA166DIORawDirSet;
*(_QWORD *)(a1 + 48) = MarvellPXA166DIORawDataSet;
*(_QWORD *)(a1 + 56) = MarvellPXA166DIORawDirGet;
*(_QWORD *)(a1 + 64) = MarvellPXA166DIORawDataGet;
*(_QWORD *)(a1 + 72) = MarvellPXA166DIORawCount;
*(_DWORD *)(a1 + 88) = 0;
*(_DWORD *)(a1 + 84) = 0;
*(_QWORD *)(a1 + 96) = a2;
if ( *(int *)(a2 + 288) <= 0 )
*(_DWORD *)(a1 + 80) = -1;
else
*(_DWORD *)(a1 + 80) = 1;
}
return result;
}

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

result = a1;
if ( *(int *)(a1 + 80) <= 0 )
{
*(_QWORD *)a1 = MarvellPXA166DIORawInit;
*(_QWORD *)(a1 + 8) = MarvellPXA166DIORawFini;
*(_QWORD *)(a1 + 16) = MarvellPXA166DIORawLock;
*(_QWORD *)(a1 + 24) = MarvellPXA166DIORawUnlock;
*(_QWORD *)(a1 + 32) = MarvellPXA166DIORawPreempt;
*(_QWORD *)(a1 + 40) = MarvellPXA166DIORawDirSet;
*(_QWORD *)(a1 + 48) = MarvellPXA166DIORawDataSet;
*(_QWORD *)(a1 + 56) = MarvellPXA166DIORawDirGet;
*(_QWORD *)(a1 + 64) = MarvellPXA166DIORawDataGet;
*(_QWORD *)(a1 + 72) = MarvellPXA166DIORawCount;
*(_DWORD *)(a1 + 88) = 0;
*(_DWORD *)(a1 + 84) = 0;
*(_QWORD *)(a1 + 96) = a2;
if ( *(int *)(a2 + 288) <= 0 )
*(_DWORD *)(a1 + 80) = -1;
else
*(_DWORD *)(a1 + 80) = 1;
}
return result;
}

original_code:
void *MarvellPXA166DIORawInit(MarvellPXA166DIORaw *dio,void *bus1) {
  Bus *bus = bus1;
  if (dio->InitStatus > 0) return dio;
  dio->Init = (void *)MarvellPXA166DIORawInit;
  dio->Fini = (void *)MarvellPXA166DIORawFini;
  dio->Lock = (void *)MarvellPXA166DIORawLock;
  dio->Unlock = (void *)MarvellPXA166DIORawUnlock;
  dio->Preempt = (void *)MarvellPXA166DIORawPreempt;
  dio->DirSet = (void *)MarvellPXA166DIORawDirSet;
  dio->DataSet = (void *)MarvellPXA166DIORawDataSet;
  dio->DirGet = (void *)MarvellPXA166DIORawDirGet;
  dio->DataGet = (void *)MarvellPXA166DIORawDataGet;
  dio->Count = (void *)MarvellPXA166DIORawCount;
  MarvellPXA166DIORawLockInit(dio);
  dio->sub = bus;
  if (dio->sub->InitStatus <= 0) {
    dio->InitStatus = -1;
    return dio;
  }
  dio->InitStatus = 1;
  return dio;
}

canonical_original_code:
void *MarvellPXA166DIORawInit(struct MarvellPXA166DIORaw *dio, void *bus1) {
  struct Bus *bus = bus1;
  if (dio->InitStatus > 0) return dio;
  dio->Init = (void *)MarvellPXA166DIORawInit;
  dio->Fini = (void *)MarvellPXA166DIORawFini;
  dio->Lock = (void *)MarvellPXA166DIORawLock;
  dio->Unlock = (void *)MarvellPXA166DIORawUnlock;
  dio->Preempt = (void *)MarvellPXA166DIORawPreempt;
  dio->DirSet = (void *)MarvellPXA166DIORawDirSet;
  dio->DataSet = (void *)MarvellPXA166DIORawDataSet;
  dio->DirGet = (void *)MarvellPXA166DIORawDirGet;
  dio->DataGet = (void *)MarvellPXA166DIORawDataGet;
  dio->Count = (void *)MarvellPXA166DIORawCount;
  MarvellPXA166DIORawLockInit(dio);
  dio->sub = bus;
  if (dio->sub->InitStatus <= 0) {
    dio->InitStatus = -1;
    return dio;
  }
  dio->InitStatus = 1;
  return dio;
}

variable_types: struct Bus { void *(*Init)(void *me, ...); void (*Fini)(void *me); int (*Lock)(void *me, unsigned int num, int flags); int (*Unlock)(void *me, unsigned int num, int flags); int (*Preempt)(void *me); unsigned char (*Peek8)(void *me, int Address); void (*Poke8)(void *me, int Address, unsigned char Value); unsigned short (*Peek16)(void *me, int Address); void (*Poke16)(void *me, int Address, unsigned short Value); unsigned int (*Peek32)(void *me, int Address); void (*Poke32)(void *me, int Address, unsigned int Value); int (*BitGet8)(void *me, int Address, int BitNumber); void (*BitAssign8)(void *me, int Address, int BitNumber, int Value); void (*BitSet8)(void *me, int Address, int BitNumber); void (*BitClear8)(void *me, int Address, int BitNumber); int (*BitGet16)(void *me, int Address, int BitNumber); void (*BitAssign16)(void *me, int Address, int BitNumber, int Value); void (*BitSet16)(void *me, int Address, int BitNumber); void (*BitClear16)(void *me, int Address, int BitNumber); int (*BitGet32)(void *me, int Address, int BitNumber); void (*BitAssign32)(void *me, int Address, int BitNumber, int Value); void (*BitSet32)(void *me, int Address, int BitNumber); void (*BitClear32)(void *me, int Address, int BitNumber); void (*PeekStream)(void *me, int address, int direction, char *dest); void (*PokeStream)(void *me, int address, int direction, char *data); void (*Refresh)(void *me); void (*Commit)(void *me, int ForceAll); int (*BitToggle8)(void *me, int Address, int BitNumber); int (*BitToggle16)(void *me, int Address, int BitNumber); int (*BitToggle32)(void *me, int Address, int BitNumber); unsigned char (*Assign8X)(void *me, int Address, int BitMSB, int BitLSB, int Value); unsigned short (*Assign16X)(void *me, int Address, int BitMSB, int BitLSB, int Value); unsigned int (*Assign32X)(void *me, int Address, int BitMSB, int BitLSB, int Value); unsigned char (*BitsGet8)(void *me, int Address, int BitMSB, int BitLSB); unsigned short (*BitsGet16)(void *me, int Address, int BitMSB, int BitLSB); unsigned int (*BitsGet32)(void *me, int Address, int BitMSB, int BitLSB); int InitStatus; unsigned int LockBase; int deferlockW; int deferlockR; } *


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

result = (*(__int64 (__fastcall **)(_QWORD))(*(_QWORD *)(a1 + 96) + 8LL))(*(_QWORD *)(a1 + 96));
if ( *(int *)(a1 + 80) > 0 )
*(_DWORD *)(a1 + 80) = 0;
return result;
}

original_code:
void MarvellPXA166DIORawFini(MarvellPXA166DIORaw *dio) {
  dio->sub->Fini(dio->sub);
  if (dio->InitStatus > 0) dio->InitStatus = 0;
}

canonical_original_code:
void MarvellPXA166DIORawFini(struct MarvellPXA166DIORaw *dio) {
  dio->sub->Fini(dio->sub);
  if (dio->InitStatus > 0) dio->InitStatus = 0;
}


original_code:
void MarvellPXA166DIORawDirSet(MarvellPXA166DIORaw *dio,int Num,int asOutput) {
  if (( Num<0 ? ~(Num) : (Num)) > 122) return;
  MarvellPXA166DIORawLockReal(dio,0);
  if (( Num<0 ? ~(Num) : (Num)) < 32) {
    dio->sub->BitAssign32(dio->sub,( Num<0 ? ~(0x0C) : (0x0C)),( Num<0 ? ~(Num) : (Num)),asOutput);
  } else if (( Num<0 ? ~(Num) : (Num)) <= 64) {
    dio->sub->BitAssign32(dio->sub,( Num<0 ? ~(0x10) : (0x10)),( Num<0 ? ~(Num) : (Num))-32,asOutput);
  } else if (( Num<0 ? ~(Num) : (Num)) <= 96) {
    dio->sub->BitAssign32(dio->sub,( Num<0 ? ~(0x14) : (0x14)),( Num<0 ? ~(Num) : (Num))-64,asOutput);
  } else {
    dio->sub->BitAssign32(dio->sub,( Num<0 ? ~(0x10C) : (0x10C)),( Num<0 ? ~(Num) : (Num))-96,asOutput);
  }
}

canonical_original_code:
void MarvellPXA166DIORawDirSet(struct MarvellPXA166DIORaw *dio, int Num, int asOutput) {
  if (( Num<0 ? ~(Num) : (Num)) > 122) return;
  MarvellPXA166DIORawLockReal(dio,0);
  if (( Num<0 ? ~(Num) : (Num)) < 32) {
    dio->sub->BitAssign32(dio->sub,( Num<0 ? ~(0x0C) : (0x0C)),( Num<0 ? ~(Num) : (Num)),asOutput);
  } else if (( Num<0 ? ~(Num) : (Num)) <= 64) {
    dio->sub->BitAssign32(dio->sub,( Num<0 ? ~(0x10) : (0x10)),( Num<0 ? ~(Num) : (Num))-32,asOutput);
  } else if (( Num<0 ? ~(Num) : (Num)) <= 96) {
    dio->sub->BitAssign32(dio->sub,( Num<0 ? ~(0x14) : (0x14)),( Num<0 ? ~(Num) : (Num))-64,asOutput);
  } else {
    dio->sub->BitAssign32(dio->sub,( Num<0 ? ~(0x10C) : (0x10C)),( Num<0 ? ~(Num) : (Num))-96,asOutput);
  }
}

variable_types: Num int

variable_types: asOutput int


variable_types: asHigh int


original_code:
int MarvellPXA166DIORawDirGet(MarvellPXA166DIORaw *dio,int Num) {
  if (( Num<0 ? ~(Num) : (Num)) > 122) return 0;
  if (( Num<0 ? ~(Num) : (Num)) == 60 || ( Num<0 ? ~(Num) : (Num)) == 61) return 1;
  MarvellPXA166DIORawLockReal(dio,SHARED);
  if (( Num<0 ? ~(Num) : (Num)) < 32) {
    return dio->sub->BitGet32(dio->sub,( Num<0 ? ~(0x0C) : (0x0C)),( Num<0 ? ~(Num) : (Num)));
  } else if (( Num<0 ? ~(Num) : (Num)) <= 64) {
    return dio->sub->BitGet32(dio->sub,( Num<0 ? ~(0x10) : (0x10)),( Num<0 ? ~(Num) : (Num))-32);
  } else if (( Num<0 ? ~(Num) : (Num)) <= 96) {
    return dio->sub->BitGet32(dio->sub,( Num<0 ? ~(0x14) : (0x14)),( Num<0 ? ~(Num) : (Num))-64);
  } else {
    return dio->sub->BitGet32(dio->sub,( Num<0 ? ~(0x10C) : (0x10C)),( Num<0 ? ~(Num) : (Num))-96);
  }
}

canonical_original_code:
int MarvellPXA166DIORawDirGet(struct MarvellPXA166DIORaw *dio, int Num) {
  if (( Num<0 ? ~(Num) : (Num)) > 122) return 0;
  if (( Num<0 ? ~(Num) : (Num)) == 60 || ( Num<0 ? ~(Num) : (Num)) == 61) return 1;
  MarvellPXA166DIORawLockReal(dio,SHARED);
  if (( Num<0 ? ~(Num) : (Num)) < 32) {
    return dio->sub->BitGet32(dio->sub,( Num<0 ? ~(0x0C) : (0x0C)),( Num<0 ? ~(Num) : (Num)));
  } else if (( Num<0 ? ~(Num) : (Num)) <= 64) {
    return dio->sub->BitGet32(dio->sub,( Num<0 ? ~(0x10) : (0x10)),( Num<0 ? ~(Num) : (Num))-32);
  } else if (( Num<0 ? ~(Num) : (Num)) <= 96) {
    return dio->sub->BitGet32(dio->sub,( Num<0 ? ~(0x14) : (0x14)),( Num<0 ? ~(Num) : (Num))-64);
  } else {
    return dio->sub->BitGet32(dio->sub,( Num<0 ? ~(0x10C) : (0x10C)),( Num<0 ? ~(Num) : (Num))-96);
  }
}


original_code:
int MarvellPXA166DIORawDataGet(MarvellPXA166DIORaw *dio,int Num) {
  if (( Num<0 ? ~(Num) : (Num)) > 122) return 0;
  MarvellPXA166DIORawLockReal(dio,SHARED);
  if (( Num<0 ? ~(Num) : (Num)) < 32) {
    return dio->sub->BitGet32(dio->sub,( Num<0 ? ~(0x00) : (0x00)),( Num<0 ? ~(Num) : (Num)));
  } else if (( Num<0 ? ~(Num) : (Num)) <= 64) {
    return dio->sub->BitGet32(dio->sub,( Num<0 ? ~(0x04) : (0x04)),( Num<0 ? ~(Num) : (Num))-32);
  } else if (( Num<0 ? ~(Num) : (Num)) <= 96) {
    return dio->sub->BitGet32(dio->sub,( Num<0 ? ~(0x08) : (0x08)),( Num<0 ? ~(Num) : (Num))-64);
  } else {
    return dio->sub->BitGet32(dio->sub,( Num<0 ? ~(0x100) : (0x100)),( Num<0 ? ~(Num) : (Num))-96);
  }
}

canonical_original_code:
int MarvellPXA166DIORawDataGet(struct MarvellPXA166DIORaw *dio, int Num) {
  if (( Num<0 ? ~(Num) : (Num)) > 122) return 0;
  MarvellPXA166DIORawLockReal(dio,SHARED);
  if (( Num<0 ? ~(Num) : (Num)) < 32) {
    return dio->sub->BitGet32(dio->sub,( Num<0 ? ~(0x00) : (0x00)),( Num<0 ? ~(Num) : (Num)));
  } else if (( Num<0 ? ~(Num) : (Num)) <= 64) {
    return dio->sub->BitGet32(dio->sub,( Num<0 ? ~(0x04) : (0x04)),( Num<0 ? ~(Num) : (Num))-32);
  } else if (( Num<0 ? ~(Num) : (Num)) <= 96) {
    return dio->sub->BitGet32(dio->sub,( Num<0 ? ~(0x08) : (0x08)),( Num<0 ? ~(Num) : (Num))-64);
  } else {
    return dio->sub->BitGet32(dio->sub,( Num<0 ? ~(0x100) : (0x100)),( Num<0 ? ~(Num) : (Num))-96);
  }
}


decompiled_code:
__int64 MarvellPXA166DIORawCount()
{
return 128LL;
}

canonical_decompiled_code:
__int64 func9()
{
return 128LL;
}

original_code:
unsigned MarvellPXA166DIORawCount(MarvellPXA166DIORaw *dio) {
  return 128;
}

canonical_original_code:
unsigned int MarvellPXA166DIORawCount(struct MarvellPXA166DIORaw *dio) {
  return 128;
}


decompiled_code:
__int64 __fastcall MarvellPXA166DIORawLockReal(__int64 a1, char a2)
{
__int64 result; // rax

if ( (a2 & 2) != 0 )
{
if ( *(_DWORD *)(a1 + 84) )
{
do
{
(*(void (__fastcall **)(_QWORD, _QWORD, __int64))(*(_QWORD *)(a1 + 96) + 16LL))(*(_QWORD *)(a1 + 96), 0LL, 2LL);
result = (unsigned int)(*(_DWORD *)(a1 + 84) - 1);
*(_DWORD *)(a1 + 84) = result;
}
while ( (_DWORD)result );
}
}
else if ( *(_DWORD *)(a1 + 88) )
{
do
{
(*(void (__fastcall **)(_QWORD, _QWORD, _QWORD))(*(_QWORD *)(a1 + 96) + 16LL))(*(_QWORD *)(a1 + 96), 0LL, 0LL);
result = (unsigned int)(*(_DWORD *)(a1 + 88) - 1);
*(_DWORD *)(a1 + 88) = result;
}
while ( (_DWORD)result );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, char a2)
{
__int64 result; // rax

if ( (a2 & 2) != 0 )
{
if ( *(_DWORD *)(a1 + 84) )
{
do
{
(*(void (__fastcall **)(_QWORD, _QWORD, __int64))(*(_QWORD *)(a1 + 96) + 16LL))(*(_QWORD *)(a1 + 96), 0LL, 2LL);
result = (unsigned int)(*(_DWORD *)(a1 + 84) - 1);
*(_DWORD *)(a1 + 84) = result;
}
while ( (_DWORD)result );
}
}
else if ( *(_DWORD *)(a1 + 88) )
{
do
{
(*(void (__fastcall **)(_QWORD, _QWORD, _QWORD))(*(_QWORD *)(a1 + 96) + 16LL))(*(_QWORD *)(a1 + 96), 0LL, 0LL);
result = (unsigned int)(*(_DWORD *)(a1 + 88) - 1);
*(_DWORD *)(a1 + 88) = result;
}
while ( (_DWORD)result );
}
return result;
}

original_code:
__attribute__((always_inline))
int MarvellPXA166DIORawLockReal(MarvellPXA166DIORaw *dio,int flags) {
  if (flags & SHARED) {
    while (dio->deferlockR) {
      dio->sub->Lock(dio->sub,0,SHARED);
      dio->deferlockR--;
    }
  } else {
    while (dio->deferlockW) {
      dio->sub->Lock(dio->sub,0,0);
      dio->deferlockW--;
    }
  }
}

canonical_original_code:
int MarvellPXA166DIORawLockReal(struct MarvellPXA166DIORaw *dio, int flags) {
  if (flags & SHARED) {
    while (dio->deferlockR) {
      dio->sub->Lock(dio->sub,0,SHARED);
      dio->deferlockR--;
    }
  } else {
    while (dio->deferlockW) {
      dio->sub->Lock(dio->sub,0,0);
      dio->deferlockW--;
    }
  }
}


accelerate

decompiled_code:
__int64 __fastcall accelerate(char *a1)
{
char i; // al

for ( i = *a1; *a1 && i != 60; i = *a1 )
++a1;
if ( i == 60 )
return (unsigned int)a1[1];
return (unsigned int)nonchar_0++;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *a1)
{
char i; // al

for ( i = *a1; *a1 && i != 60; i = *a1 )
++a1;
if ( i == 60 )
return (unsigned int)a1[1];
return (unsigned int)nonchar_0++;
}

original_code:
static int accelerate(const char *str) {
  static int nonchar = 0x1000;
  while (*str && *str != '<') {
    str++;
  }
  if (*str == '<') {
    return *(str+1);
  } else {
    return nonchar++;
  }
}

canonical_original_code:
static int accelerate(char *str) {
  static int nonchar = 0x1000;
  while (*str && *str != '<') {
    str++;
  }
  if (*str == '<') {
    return *(str+1);
  } else {
    return nonchar++;
  }
}

variable_types:
str
char *

variable_types: nonchar int


unaccelerate

decompiled_code:
char *__fastcall unaccelerate(const char *a1)
{
size_t v1; // rax
char *v2; // r8
char v3; // al
const char *v4; // rdi
char *v5; // rdx
int v6; // ecx
char *v7; // rsi

v1 = strlen(a1);
v2 = (char *)malloc(v1 + 1);
v3 = *a1;
if ( *a1 )
{
v4 = a1 + 1;
v5 = v2;
v6 = 0;
do
{
if ( v3 == 60 && !v6 )
{
v7 = (char *)v4;
v6 = 1;
}
else if ( v3 == 62 && v6 == 1 )
{
v7 = (char *)v4;
v6 = 2;
}
else
{
v7 = (char *)v4;
*v5++ = v3;
}
v3 = *v7;
++v4;
}
while ( *v7 );
}
return v2;
}

canonical_decompiled_code:
char *__fastcall func1(const char *a1)
{
size_t v1; // rax
char *v2; // r8
char v3; // al
const char *v4; // rdi
char *v5; // rdx
int v6; // ecx
char *v7; // rsi

v1 = strlen(a1);
v2 = (char *)malloc(v1 + 1);
v3 = *a1;
if ( *a1 )
{
v4 = a1 + 1;
v5 = v2;
v6 = 0;
do
{
if ( v3 == 60 && !v6 )
{
v7 = (char *)v4;
v6 = 1;
}
else if ( v3 == 62 && v6 == 1 )
{
v7 = (char *)v4;
v6 = 2;
}
else
{
v7 = (char *)v4;
*v5++ = v3;
}
v3 = *v7;
++v4;
}
while ( *v7 );
}
return v2;
}

original_code:
static char *unaccelerate(const char *str) {
  char *ret,*str2 = malloc(strlen(str)+1);
  int found = 0;
  int i;
  ret = str2;
  while (*str) {
    if (found == 0 && *str == '<') {
      found = 1;
      str++;
    } else if (found == 1 && *str == '>') {
      found = 2;
      str++;
    } else {
      if (found != 1) {
 *(str2++) = *(str++);
      } else {
 *(str2++) = *(str++);
      }
    }
  }
  return ret;
}

canonical_original_code:
static char *unaccelerate(char *str) {
  char *ret; char *str2 = malloc(strlen(str)+1);
  int found = 0;
  int i;
  ret = str2;
  while (*str) {
    if (found == 0 && *str == '<') {
      found = 1;
      str++;
    } else if (found == 1 && *str == '>') {
      found = 2;
      str++;
    } else {
      if (found != 1) {
 *(str2++) = *(str++);
      } else {
 *(str2++) = *(str++);
      }
    }
  }
  return ret;
}

variable_types:
ret
char *

variable_types: found int

return_type: char *


OptionHost

decompiled_code:
_BOOL8 __fastcall OptionHost(char *nptr, _DWORD *a2)
{
char *v3; // rbx
__int64 v4; // rsi
char *v6; // rax
unsigned int v7; // eax

if ( nptr && (v3 = nptr, *nptr) )
{
v6 = strchr(nptr, 58);
if ( v6 )
{
*v6 = 0;
v4 = (unsigned int)strtoul(v6 + 1, 0LL, 0);
}
else if ( strchr(nptr, 46) || (v7 = atoi(nptr), (v4 = v7) == 0) )
{
v4 = (unsigned int)OptionHostPortDefault;
}
else
{
v3 = "127.0.0.1";
}
}
else
{
v4 = (unsigned int)OptionHostPortDefault;
v3 = "127.0.0.1";
}
if ( OptionHostSocketCreate )
*a2 = OptionHostSocketCreate(v3, v4);
else
*a2 = -1;
return *a2 >= 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(char *nptr, _DWORD *a2)
{
char *v3; // rbx
__int64 v4; // rsi
char *v6; // rax
unsigned int v7; // eax

if ( nptr && (v3 = nptr, *nptr) )
{
v6 = strchr(nptr, 58);
if ( v6 )
{
*v6 = 0;
v4 = (unsigned int)strtoul(v6 + 1, 0LL, 0);
}
else if ( strchr(nptr, 46) || (v7 = atoi(nptr), (v4 = v7) == 0) )
{
v4 = (unsigned int)OptionHostPortDefault;
}
else
{
v3 = "127.0.0.1";
}
}
else
{
v4 = (unsigned int)OptionHostPortDefault;
v3 = "127.0.0.1";
}
if ( OptionHostSocketCreate )
*a2 = OptionHostSocketCreate(v3, v4);
else
*a2 = -1;
return *a2 >= 0;
}

original_code:
int OptionHost(char *arg,void *target0,int opt) {
  int *target = target0;
  char *sport, *host;
  int port;
  if (!arg || arg[0] == 0) {
    host = "127.0.0.1";
    port = OptionHostPortDefault;
  } else {
    sport = strchr(arg,':');
    if (sport) {
      *(sport++) = 0;
      host = arg;
      port = strtoul(sport, ((void *)0), 0);
    } else if (!strchr(arg,'.') && (port = atoi(arg))) {
      host = "127.0.0.1";
    } else {
      host = arg;
      port = OptionHostPortDefault;
    }
  }
  if (OptionHostSocketCreate) {
    *target = OptionHostSocketCreate(host,port);
  } else {
    *target = -1;
  }
  if (*target < 0) {
    return 0;
  }
  return 1;
}

canonical_original_code:
int OptionHost(char *arg, void *target0, int opt) {
  int *target = target0;
  char *sport; char *host;
  int port;
  if (!arg || arg[0] == 0) {
    host = "127.0.0.1";
    port = OptionHostPortDefault;
  } else {
    sport = strchr(arg,':');
    if (sport) {
      *(sport++) = 0;
      host = arg;
      port = strtoul(sport, ((void *)0), 0);
    } else if (!strchr(arg,'.') && (port = atoi(arg))) {
      host = "127.0.0.1";
    } else {
      host = arg;
      port = OptionHostPortDefault;
    }
  }
  if (OptionHostSocketCreate) {
    *target = OptionHostSocketCreate(host,port);
  } else {
    *target = -1;
  }
  if (*target < 0) {
    return 0;
  }
  return 1;
}

variable_types:
arg
char *

variable_types: opt int

variable_types:
target
int *

variable_types:
sport
char *

variable_types:
host
char *

variable_types: port int


OptionString

decompiled_code:
__int64 __fastcall OptionString(char *src, char **a2)
{
size_t v2; // rax
char *v3; // rax

v2 = strlen(src);
v3 = (char *)malloc(v2 + 1);
*a2 = v3;
strcpy(v3, src);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *src, char **a2)
{
size_t v2; // rax
char *v3; // rax

v2 = strlen(src);
v3 = (char *)malloc(v2 + 1);
*a2 = v3;
strcpy(v3, src);
return 1LL;
}

original_code:
int OptionString(char *arg,void *target0,int opt) {
  char **target = target0;
  *target = malloc(strlen(arg)+1);
  strcpy(*target,arg);
  return 1;
}

canonical_original_code:
int OptionString(char *arg, void *target0, int opt) {
  char **target = target0;
  *target = malloc(strlen(arg)+1);
  strcpy(*target,arg);
  return 1;
}

variable_types:
target
char **


OptionBoolean

decompiled_code:
__int64 __fastcall OptionBoolean(__int64 a1, _DWORD *a2)
{
*a2 = 1;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, _DWORD *a2)
{
*a2 = 1;
return 1LL;
}

original_code:
int OptionBoolean(char *arg,void *target0,int opt) {
  int *target = target0;
  *target = 1;
  return 1;
}

canonical_original_code:
int OptionBoolean(char *arg, void *target0, int opt) {
  int *target = target0;
  *target = 1;
  return 1;
}


decompiled_code:
__int64 __fastcall OptionBoolean0(__int64 a1, _DWORD *a2)
{
*a2 = 0;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, _DWORD *a2)
{
*a2 = 0;
return 1LL;
}

original_code:
int OptionBoolean0(char *arg,void *target0,int opt) {
  int *target = target0;
  *target = 0;
  return 1;
}

canonical_original_code:
int OptionBoolean0(char *arg, void *target0, int opt) {
  int *target = target0;
  *target = 0;
  return 1;
}


OptionUnsigned

decompiled_code:
__int64 __fastcall OptionUnsigned(const char *a1, _DWORD *a2)
{
if ( a1 )
*a2 = strtoul(a1, 0LL, 0);
else
*a2 = -1;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func6(const char *a1, _DWORD *a2)
{
if ( a1 )
*a2 = strtoul(a1, 0LL, 0);
else
*a2 = -1;
return 1LL;
}

original_code:
int OptionUnsigned(char *arg,void *target0,int opt) {
  unsigned *target = target0;
  if (arg) {
    *target = strtoul(arg,((void *)0),0);
  } else {
    *target = 0xFFFFFFFF;
  }
  return 1;
}

canonical_original_code:
int OptionUnsigned(char *arg, void *target0, int opt) {
  unsigned int *target = target0;
  if (arg) {
    *target = strtoul(arg,((void *)0),0);
  } else {
    *target = 0xFFFFFFFF;
  }
  return 1;
}

variable_types:
target
unsigned int *


OptionSigned

decompiled_code:
__int64 __fastcall OptionSigned(const char *a1, _DWORD *a2)
{
if ( a1 )
*a2 = strtol(a1, 0LL, 0);
else
*a2 = -559038737;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(const char *a1, _DWORD *a2)
{
if ( a1 )
*a2 = strtol(a1, 0LL, 0);
else
*a2 = -559038737;
return 1LL;
}

original_code:
int OptionSigned(char *arg,void *target0,int opt) {
  int *target = target0;
  if (arg) {
    *target = strtol(arg,((void *)0),0);
  } else {
    *target = 0xDEADBEEF;
  }
  return 1;
}

canonical_original_code:
int OptionSigned(char *arg, void *target0, int opt) {
  int *target = target0;
  if (arg) {
    *target = strtol(arg,((void *)0),0);
  } else {
    *target = 0xDEADBEEF;
  }
  return 1;
}


OptionsParse

original_code:
int OptionsParse(int argc,char **argv,struct option2 *opts) {
  struct option *long_options;
  char *optstr,*helpstr;
  const char *prolog="",*epilog="";
  int i,n,j,c,total=0,gothelp=0;
  for (n=0;
       opts[n].has_arg||opts[n].f||opts[n].target;
       n++);
  if (opts[n].name) {
    prolog = opts[n].name;
  }
  if (opts[n].help) {
    epilog = opts[n].help;
  }
  long_options = malloc(sizeof(struct option) * (n+2));
  optstr = malloc(2+3*n);
  j=0;
  optstr[j] = 0;
  for (i=0;i<n;i++) {
    long_options[i].name = unaccelerate(opts[i].name);
    long_options[i].has_arg = opts[i].has_arg;
    long_options[i].flag = 0;
    long_options[i].val = accelerate(opts[i].name);
    if (long_options[i].val && long_options[i].val < 0xFF) {
      optstr[j++] = long_options[i].val;
      if (long_options[i].has_arg > 0) {
 optstr[j++] = ':';
      }
      if (long_options[i].has_arg > 1) {
 optstr[j++] = ':';
      }
      optstr[j] = 0;
    }
  }
  long_options[i].name = "help";
  long_options[i].has_arg = 0;
  long_options[i].flag = 0;
  long_options[i].val = 0xFFF;
  long_options[i+1].name = 0;
  long_options[i+1].has_arg = 0;
  long_options[i+1].flag = 0;
  long_options[i+1].val = 0;
  optstr[j++] = 'h';
  optstr[j] = 0;
  while ((c = getopt_long(argc,argv,optstr,long_options,((void *)0))) != -1) {
    for (i=0;i<=n;i++) {
      if (c == long_options[i].val) {
 if (c == 0xFFF) {
   gothelp = 1;
   fprintf(stderr,"%s",prolog);
   for (j=0;j<n;j++) {
     if (opts[j].help) {
       if (long_options[j].val < 0x100) {
  fprintf(stderr,"-%c | --%s%s%s\n",long_options[j].val,
   long_options[j].name,
   (long_options[j].has_arg>0 ? "=" : " "),
   opts[j].help);
       } else {
  fprintf(stderr,"--%s  %s\n",long_options[j].name, opts[j].help);
       }
     }
   }
   fprintf(stderr,"%s",epilog);
 } else if (!++total || !opts[i].f(optarg,opts[i].target,c)) {
   goto OptionsParseDone;
 }
      }
    }
  }
 OptionsParseDone:
  free(long_options);
  free(optstr);
  return (gothelp && total == 0) ? -1 : total;
}

canonical_original_code:
int OptionsParse(int argc, char **argv, struct option2 *opts) {
  struct option *long_options;
  char *optstr; char *helpstr;
  char *prolog = ""; char *epilog = "";
  int i; int n; int j; int c; int total = 0; int gothelp = 0;
  for (n=0;
       opts[n].has_arg||opts[n].f||opts[n].target;
       n++);
  if (opts[n].name) {
    prolog = opts[n].name;
  }
  if (opts[n].help) {
    epilog = opts[n].help;
  }
  long_options = malloc(sizeof(struct option) * (n+2));
  optstr = malloc(2+3*n);
  j=0;
  optstr[j] = 0;
  for (i=0;i<n;i++) {
    long_options[i].name = unaccelerate(opts[i].name);
    long_options[i].has_arg = opts[i].has_arg;
    long_options[i].flag = 0;
    long_options[i].val = accelerate(opts[i].name);
    if (long_options[i].val && long_options[i].val < 0xFF) {
      optstr[j++] = long_options[i].val;
      if (long_options[i].has_arg > 0) {
 optstr[j++] = ':';
      }
      if (long_options[i].has_arg > 1) {
 optstr[j++] = ':';
      }
      optstr[j] = 0;
    }
  }
  long_options[i].name = "help";
  long_options[i].has_arg = 0;
  long_options[i].flag = 0;
  long_options[i].val = 0xFFF;
  long_options[i+1].name = 0;
  long_options[i+1].has_arg = 0;
  long_options[i+1].flag = 0;
  long_options[i+1].val = 0;
  optstr[j++] = 'h';
  optstr[j] = 0;
  while ((c = getopt_long(argc,argv,optstr,long_options,((void *)0))) != -1) {
    for (i=0;i<=n;i++) {
      if (c == long_options[i].val) {
 if (c == 0xFFF) {
   gothelp = 1;
   fprintf(stderr,"%s",prolog);
   for (j=0;j<n;j++) {
     if (opts[j].help) {
       if (long_options[j].val < 0x100) {
  fprintf(stderr,"-%c | --%s%s%s\n",long_options[j].val,
   long_options[j].name,
   (long_options[j].has_arg>0 ? "=" : " "),
   opts[j].help);
       } else {
  fprintf(stderr,"--%s  %s\n",long_options[j].name, opts[j].help);
       }
     }
   }
   fprintf(stderr,"%s",epilog);
 } else if (!++total || !opts[i].f(optarg,opts[i].target,c)) {
   goto OptionsParseDone;
 }
      }
    }
  }
 OptionsParseDone:
  free(long_options);
  free(optstr);
  return (gothelp && total == 0) ? -1 : total;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: struct option2 { int has_arg; int (*f)(char *arg, void *target, int opt); void *target; char *name; char *help; } *

variable_types: struct option { char *name; int has_arg; int *flag; int val; } *

variable_types:
optstr
char *

variable_types:
helpstr
char *

variable_types:
prolog
char *

variable_types:
epilog
char *

variable_types: i int

variable_types: n int

variable_types: j int

variable_types: c int

variable_types: total int

variable_types: gothelp int


TSTimeFini

original_code:
void TSTimeFini(TSTime *me) {
  if (me->InitStatus > 0) {
    me->bus->Fini(me->bus);
    me->InitStatus = 0;
  }
}

canonical_original_code:
void TSTimeFini(struct TSTime *me) {
  if (me->InitStatus > 0) {
    me->bus->Fini(me->bus);
    me->InitStatus = 0;
  }
}

variable_types: struct TSTime { void *(*Init)(struct TSTime *me, void *bus, int adrsMSB, int adrsLSB, int Hz); void (*Fini)(struct TSTime *me); unsigned int (*Wait)(struct TSTime *me, unsigned int microseconds); void (*Delay)(struct TSTime *me, unsigned int microseconds); unsigned int (*Tick)(struct TSTime *me); unsigned int (*usElapsed)(struct TSTime *me, unsigned int start); unsigned int (*usFuture)(struct TSTime *me, unsigned int start, unsigned int microseconds); enum TimeResult { TimeoutOccurred=1, TimeoutDidNotOccur=0 } (*TimeoutQ)(struct TSTime *me, unsigned int start, unsigned int end); unsigned int (*TPS)(struct TSTime *me); int InitStatus; struct Bus { void *(*Init)(void *me, ...); void (*Fini)(void *me); int (*Lock)(void *me, unsigned int num, int flags); int (*Unlock)(void *me, unsigned int num, int flags); int (*Preempt)(void *me); unsigned char (*Peek8)(void *me, int Address); void (*Poke8)(void *me, int Address, unsigned char Value); unsigned short (*Peek16)(void *me, int Address); void (*Poke16)(void *me, int Address, unsigned short Value); unsigned int (*Peek32)(void *me, int Address); void (*Poke32)(void *me, int Address, unsigned int Value); int (*BitGet8)(void *me, int Address, int BitNumber); void (*BitAssign8)(void *me, int Address, int BitNumber, int Value); void (*BitSet8)(void *me, int Address, int BitNumber); void (*BitClear8)(void *me, int Address, int BitNumber); int (*BitGet16)(void *me, int Address, int BitNumber); void (*BitAssign16)(void *me, int Address, int BitNumber, int Value); void (*BitSet16)(void *me, int Address, int BitNumber); void (*BitClear16)(void *me, int Address, int BitNumber); int (*BitGet32)(void *me, int Address, int BitNumber); void (*BitAssign32)(void *me, int Address, int BitNumber, int Value); void (*BitSet32)(void *me, int Address, int BitNumber); void (*BitClear32)(void *me, int Address, int BitNumber); void (*PeekStream)(void *me, int address, int direction, char *dest); void (*PokeStream)(void *me, int address, int direction, char *data); void (*Refresh)(void *me); void (*Commit)(void *me, int ForceAll); int (*BitToggle8)(void *me, int Address, int BitNumber); int (*BitToggle16)(void *me, int Address, int BitNumber); int (*BitToggle32)(void *me, int Address, int BitNumber); unsigned char (*Assign8X)(void *me, int Address, int BitMSB, int BitLSB, int Value); unsigned short (*Assign16X)(void *me, int Address, int BitMSB, int BitLSB, int Value); unsigned int (*Assign32X)(void *me, int Address, int BitMSB, int BitLSB, int Value); unsigned char (*BitsGet8)(void *me, int Address, int BitMSB, int BitLSB); unsigned short (*BitsGet16)(void *me, int Address, int BitMSB, int BitLSB); unsigned int (*BitsGet32)(void *me, int Address, int BitMSB, int BitLSB); int InitStatus; unsigned int LockBase; int deferlockW; int deferlockR; } *bus; int adrsMSB; int adrsLSB; int Hz; } *

user_defined_types: struct TSTime { void *(*Init)(struct TSTime *me, void *bus, int adrsMSB, int adrsLSB, int Hz); void (*Fini)(struct TSTime *me); unsigned int (*Wait)(struct TSTime *me, unsigned int microseconds); void (*Delay)(struct TSTime *me, unsigned int microseconds); unsigned int (*Tick)(struct TSTime *me); unsigned int (*usElapsed)(struct TSTime *me, unsigned int start); unsigned int (*usFuture)(struct TSTime *me, unsigned int start, unsigned int microseconds); enum TimeResult (*TimeoutQ)(struct TSTime *me, unsigned int start, unsigned int end); unsigned int (*TPS)(struct TSTime *me); int InitStatus; struct Bus *bus; int adrsMSB; int adrsLSB; int Hz; }


TSTimeTick

original_code:
unsigned TSTimeTick(TSTime *me) {
  return _TSTimeTick(me);
}

canonical_original_code:
unsigned int TSTimeTick(struct TSTime *me) {
  return _TSTimeTick(me);
}

user_defined_types: enum TimeResult { TimeoutOccurred=1, TimeoutDidNotOccur=0 }


TSTimeusElapsed

original_code:
unsigned TSTimeusElapsed(TSTime *time,unsigned start) {
  unsigned now = _TSTimeTick(time);
  if (now < start) {
    return 1 * ((unsigned)(-start) + now);
  } else {
    return 1 * (now - start);
  }
}

canonical_original_code:
unsigned int TSTimeusElapsed(struct TSTime *time, unsigned int start) {
  unsigned int now = _TSTimeTick(time);
  if (now < start) {
    return 1 * ((unsigned int)(-start) + now);
  } else {
    return 1 * (now - start);
  }
}

variable_types:
start
unsigned int

variable_types:
now
unsigned int


TSTimeusFuture

decompiled_code:
__int64 __fastcall TSTimeusFuture(__int64 a1, int a2, int a3)
{
return (unsigned int)(a2 + a3);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, int a2, int a3)
{
return (unsigned int)(a2 + a3);
}

original_code:
unsigned TSTimeusFuture(TSTime *time,unsigned start,unsigned us) {
  return start + us;
}

canonical_original_code:
unsigned int TSTimeusFuture(struct TSTime *time, unsigned int start, unsigned int us) {
  return start + us;
}

variable_types:
us
unsigned int


TSTimeTimeoutQ

decompiled_code:
__int64 __fastcall TSTimeTimeoutQ(__int64 a1, unsigned int a2, unsigned int a3)
{
int v5; // er14
unsigned __int16 v6; // r15
int v7; // eax
unsigned int v8; // ebp
__int64 result; // rax

v5 = (*(__int64 (__fastcall **)(_QWORD, _QWORD))(*(_QWORD *)(a1 + 80) + 56LL))(
*(_QWORD *)(a1 + 80),
*(unsigned int *)(a1 + 88));
v6 = (*(__int64 (__fastcall **)(_QWORD, _QWORD))(*(_QWORD *)(a1 + 80) + 56LL))(
*(_QWORD *)(a1 + 80),
*(unsigned int *)(a1 + 92));
v7 = (*(__int64 (__fastcall **)(_QWORD, _QWORD))(*(_QWORD *)(a1 + 80) + 56LL))(
*(_QWORD *)(a1 + 80),
*(unsigned int *)(a1 + 88));
if ( (_WORD)v5 == (_WORD)v7 )
v8 = (v5 << 16) + v6;
else
v8 = (*(unsigned __int16 (__fastcall **)(_QWORD, _QWORD))(*(_QWORD *)(a1 + 80) + 56LL))(
*(_QWORD *)(a1 + 80),
*(unsigned int *)(a1 + 92))
+ (v7 << 16);
if ( a3 > a2 )
return (a2 > v8) | (unsigned __int8)(a3 <= v8);
result = 1LL;
if ( a3 != a2 )
result = (a2 > v8) & (unsigned __int8)(a3 <= v8);
return result;
}

original_code:
TimeResult TSTimeTimeoutQ(TSTime *time,unsigned start,unsigned end) {
  unsigned now = _TSTimeTick(time);
  if (end > start) {
    return now >= end || now < start;
  } else if (end == start) {
    return 1;
  } else {
    return !(now >= start || now < end);
  }
}

canonical_original_code:
enum TimeResult TSTimeTimeoutQ(struct TSTime *time, unsigned int start, unsigned int end) {
  unsigned int now = _TSTimeTick(time);
  if (end > start) {
    return now >= end || now < start;
  } else if (end == start) {
    return 1;
  } else {
    return !(now >= start || now < end);
  }
}

variable_types:
end
unsigned int

return_type: enum TimeResult { TimeoutOccurred=1, TimeoutDidNotOccur=0 }


TSTimeTPS

decompiled_code:
__int64 __fastcall TSTimeTPS(__int64 a1)
{
return *(unsigned int *)(a1 + 96);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
return *(unsigned int *)(a1 + 96);
}

original_code:
unsigned TSTimeTPS(TSTime *me) {
  return me->Hz;
}

canonical_original_code:
unsigned int TSTimeTPS(struct TSTime *me) {
  return me->Hz;
}


TSTimeWait

decompiled_code:
__int64 TSTimeWait()
{
return SystemMicroSecondWait();
}

canonical_decompiled_code:
__int64 func7()
{
return SystemMicroSecondWait();
}

original_code:
unsigned TSTimeWait(TSTime *me,unsigned us) {
  return SystemMicroSecondWait(me,us);
}

canonical_original_code:
unsigned int TSTimeWait(struct TSTime *me, unsigned int us) {
  return SystemMicroSecondWait(me,us);
}


TSTimeDelay

decompiled_code:
__int64 TSTimeDelay()
{
return SystemMicroSecondWait();
}

canonical_decompiled_code:
__int64 func8()
{
return SystemMicroSecondWait();
}

original_code:
void TSTimeDelay(TSTime *me,unsigned us) {
  SystemMicroSecondWait(me,us);
}

canonical_original_code:
void TSTimeDelay(struct TSTime *me, unsigned int us) {
  SystemMicroSecondWait(me,us);
}


decompiled_code:
__int64 tsrelay8ArchNextSubArch()
{
return tsrelay8Next;
}

canonical_decompiled_code:
__int64 func0()
{
return tsrelay8Next;
}

canonical_original_code:
struct Arch *tsrelay8ArchNextSubArch() {
  return tsrelay8Next;
}

return_type: struct Arch { struct Arch *(*Init)(); void *(*Function)(int class, int inst); struct Arch *(*NextSubArch)(); void (*NextSubArchSet)(struct Arch *); int (*CANBusId)(int inst); } *


decompiled_code:
void __fastcall tsrelay8NextSubArchSet(__int64 a1)
{
tsrelay8Next = a1;
}

canonical_decompiled_code:
void __fastcall func1(__int64 a1)
{
tsrelay8Next = a1;
}

original_code:
void tsrelay8NextSubArchSet(Arch *arch) {
  tsrelay8Next = arch;
}

canonical_original_code:
void tsrelay8NextSubArchSet(struct Arch *arch) {
  tsrelay8Next = arch;
}

variable_types: struct Arch { struct Arch *(*Init)(); void *(*Function)(int class, int inst); struct Arch *(*NextSubArch)(); void (*NextSubArchSet)(struct Arch *); int (*CANBusId)(int inst); } *


decompiled_code:
__int64 tsrelay8ArchInit()
{
__int64 v0; // r12
__int64 v2; // rbp
__int64 i; // rbx

v0 = tsrelay8_0;
if ( !tsrelay8_0 )
{
v2 = BusInit(2LL);
(*(void (__fastcall **)(__int64, _QWORD, __int64))(v2 + 16))(v2, 0LL, 2LL);
for ( i = 0LL; i != 4; ++i )
{
if ( (*(unsigned __int8 (__fastcall **)(__int64, _QWORD))(v2 + 40))(v2, (unsigned int)(16 * i + 320)) == 0x9B )
r8present[i] = 1;
}
(*(void (__fastcall **)(__int64, _QWORD, __int64))(v2 + 24))(v2, 0LL, 2LL);
if ( r8present[0] )
{
tsrelay8_0 = (__int64)tsrelay8Arch;
dioctl_config_add2(
&Xtsrelay8_dioctl_config,
(unsigned int)Xtsrelay8_dioctl_config_len,
(unsigned int)Ytsrelay8_dioctl_config_len);
v0 = tsrelay8_0;
}
}
return v0;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 v0; // r12
__int64 v2; // rbp
__int64 i; // rbx

v0 = tsrelay8_0;
if ( !tsrelay8_0 )
{
v2 = BusInit(2LL);
(*(void (__fastcall **)(__int64, _QWORD, __int64))(v2 + 16))(v2, 0LL, 2LL);
for ( i = 0LL; i != 4; ++i )
{
if ( (*(unsigned __int8 (__fastcall **)(__int64, _QWORD))(v2 + 40))(v2, (unsigned int)(16 * i + 320)) == 0x9B )
r8present[i] = 1;
}
(*(void (__fastcall **)(__int64, _QWORD, __int64))(v2 + 24))(v2, 0LL, 2LL);
if ( r8present[0] )
{
tsrelay8_0 = (__int64)tsrelay8Arch;
dioctl_config_add2(
&Xtsrelay8_dioctl_config,
(unsigned int)Xtsrelay8_dioctl_config_len,
(unsigned int)Ytsrelay8_dioctl_config_len);
v0 = tsrelay8_0;
}
}
return v0;
}

original_code:
Arch *tsrelay8ArchInit(int model) {
  static Arch *tsrelay8;
  Bus *pc104;
  int i,val;
  if (tsrelay8) return tsrelay8;
  pc104 = BusInit(2);
  pc104->Lock(pc104,0,SHARED);
  for (i=0;i<4;i++) {
    val = pc104->Peek8(pc104,0x140+0x10*i);
    if (val == 0x9B) r8present[i] = 1;
  }
  pc104->Unlock(pc104,0,SHARED);
  if (r8present[0] == 0 && r8present[0] == 0 && r8present[0] == 0 && r8present[0] == 0){
    return 0;
  }
  tsrelay8 = &tsrelay8Arch;
  dioctl_config_add2(Xtsrelay8_dioctl_config,Xtsrelay8_dioctl_config_len,Ytsrelay8_dioctl_config_len);
  return tsrelay8;
}

canonical_original_code:
struct Arch *tsrelay8ArchInit(int model) {
  static struct Arch *tsrelay8;
  struct Bus *pc104;
  int i; int val;
  if (tsrelay8) return tsrelay8;
  pc104 = BusInit(2);
  pc104->Lock(pc104,0,SHARED);
  for (i=0;i<4;i++) {
    val = pc104->Peek8(pc104,0x140+0x10*i);
    if (val == 0x9B) r8present[i] = 1;
  }
  pc104->Unlock(pc104,0,SHARED);
  if (r8present[0] == 0 && r8present[0] == 0 && r8present[0] == 0 && r8present[0] == 0){
    return 0;
  }
  tsrelay8 = &tsrelay8Arch;
  dioctl_config_add2(Xtsrelay8_dioctl_config,Xtsrelay8_dioctl_config_len,Ytsrelay8_dioctl_config_len);
  return tsrelay8;
}

variable_types: model int

variable_types: struct Bus { void *(*Init)(void *me, ...); void (*Fini)(void *me); int (*Lock)(void *me, unsigned int num, int flags); int (*Unlock)(void *me, unsigned int num, int flags); int (*Preempt)(void *me); unsigned char (*Peek8)(void *me, int Address); void (*Poke8)(void *me, int Address, unsigned char Value); unsigned short (*Peek16)(void *me, int Address); void (*Poke16)(void *me, int Address, unsigned short Value); unsigned int (*Peek32)(void *me, int Address); void (*Poke32)(void *me, int Address, unsigned int Value); int (*BitGet8)(void *me, int Address, int BitNumber); void (*BitAssign8)(void *me, int Address, int BitNumber, int Value); void (*BitSet8)(void *me, int Address, int BitNumber); void (*BitClear8)(void *me, int Address, int BitNumber); int (*BitGet16)(void *me, int Address, int BitNumber); void (*BitAssign16)(void *me, int Address, int BitNumber, int Value); void (*BitSet16)(void *me, int Address, int BitNumber); void (*BitClear16)(void *me, int Address, int BitNumber); int (*BitGet32)(void *me, int Address, int BitNumber); void (*BitAssign32)(void *me, int Address, int BitNumber, int Value); void (*BitSet32)(void *me, int Address, int BitNumber); void (*BitClear32)(void *me, int Address, int BitNumber); void (*PeekStream)(void *me, int address, int direction, char *dest); void (*PokeStream)(void *me, int address, int direction, char *data); void (*Refresh)(void *me); void (*Commit)(void *me, int ForceAll); int (*BitToggle8)(void *me, int Address, int BitNumber); int (*BitToggle16)(void *me, int Address, int BitNumber); int (*BitToggle32)(void *me, int Address, int BitNumber); unsigned char (*Assign8X)(void *me, int Address, int BitMSB, int BitLSB, int Value); unsigned short (*Assign16X)(void *me, int Address, int BitMSB, int BitLSB, int Value); unsigned int (*Assign32X)(void *me, int Address, int BitMSB, int BitLSB, int Value); unsigned char (*BitsGet8)(void *me, int Address, int BitMSB, int BitLSB); unsigned short (*BitsGet16)(void *me, int Address, int BitMSB, int BitLSB); unsigned int (*BitsGet32)(void *me, int Address, int BitMSB, int BitLSB); int InitStatus; unsigned int LockBase; int deferlockW; int deferlockR; } *

variable_types: val int

user_defined_types: struct Arch { struct Arch *(*Init)(); void *(*Function)(int class, int inst); struct Arch *(*NextSubArch)(); void (*NextSubArchSet)(struct Arch *); int (*CANBusId)(int inst); }


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

if ( !r8present[1] )
return tsrelay8__DIORawInit0();
v2 = BusInit(2LL);
return tsRelay8DIORawInit((char *)&r8dio + 112 * a2, v2, (unsigned int)(16 * (a2 + 20)));
}

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

if ( !r8present[1] )
return func6();
v2 = BusInit(2LL);
return tsRelay8DIORawInit((char *)&r8dio + 112 * a2, v2, (unsigned int)(16 * (a2 + 20)));
}

original_code:
DIORaw *tsrelay8__DIORawInit1(DIORaw *dioraw0,int inst) {
  if (!r8present[1]) {
    return tsrelay8__DIORawInit0(dioraw0,inst);
  }
  return tsRelay8DIORawInit(&r8dio[inst],BusInit(2),0x140 + inst * 0x10);
}

canonical_original_code:
struct DIORaw *tsrelay8__DIORawInit1(struct DIORaw *dioraw0, int inst) {
  if (!r8present[1]) {
    return tsrelay8__DIORawInit0(dioraw0,inst);
  }
  return tsRelay8DIORawInit(&r8dio[inst],BusInit(2),0x140 + inst * 0x10);
}

variable_types: inst int

return_type: struct DIORaw { void *(*Init)(void *me, ...); void (*Fini)(void *me); int (*Lock)(void *me, unsigned int num, int flags); int (*Unlock)(void *me, unsigned int num, int flags); int (*Preempt)(void *me); void (*DirSet)(void *me, int num, int asOutput); void (*DataSet)(void *me, int num, int asHigh); int (*DirGet)(void *me, int num); int (*DataGet)(void *me, int num); unsigned int (*Count)(void *me); int InitStatus; } *


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

if ( !r8present[2] )
return tsrelay8__DIORawInit1(a1, a2);
v2 = BusInit(2LL);
return tsRelay8DIORawInit((char *)&r8dio + 112 * a2, v2, (unsigned int)(16 * (a2 + 20)));
}

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

if ( !r8present[2] )
return func3(a1, a2);
v2 = BusInit(2LL);
return tsRelay8DIORawInit((char *)&r8dio + 112 * a2, v2, (unsigned int)(16 * (a2 + 20)));
}

original_code:
DIORaw *tsrelay8__DIORawInit2(DIORaw *dioraw0,int inst) {
  if (!r8present[2]) {
    return tsrelay8__DIORawInit1(dioraw0,inst);
  }
  return tsRelay8DIORawInit(&r8dio[inst],BusInit(2),0x140 + inst * 0x10);
}

canonical_original_code:
struct DIORaw *tsrelay8__DIORawInit2(struct DIORaw *dioraw0, int inst) {
  if (!r8present[2]) {
    return tsrelay8__DIORawInit1(dioraw0,inst);
  }
  return tsRelay8DIORawInit(&r8dio[inst],BusInit(2),0x140 + inst * 0x10);
}

user_defined_types: struct DIORaw { void *(*Init)(void *me, ...); void (*Fini)(void *me); int (*Lock)(void *me, unsigned int num, int flags); int (*Unlock)(void *me, unsigned int num, int flags); int (*Preempt)(void *me); void (*DirSet)(void *me, int num, int asOutput); void (*DataSet)(void *me, int num, int asHigh); int (*DirGet)(void *me, int num); int (*DataGet)(void *me, int num); unsigned int (*Count)(void *me); int InitStatus; }


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

if ( !r8present[3] )
return tsrelay8__DIORawInit2(a1, a2);
v2 = BusInit(2LL);
return tsRelay8DIORawInit((char *)&r8dio + 112 * a2, v2, (unsigned int)(16 * (a2 + 20)));
}

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

if ( !r8present[3] )
return func4(a1, a2);
v2 = BusInit(2LL);
return tsRelay8DIORawInit((char *)&r8dio + 112 * a2, v2, (unsigned int)(16 * (a2 + 20)));
}

original_code:
DIORaw *tsrelay8__DIORawInit3(DIORaw *dioraw0,int inst) {
  if (!r8present[3]) {
    return tsrelay8__DIORawInit2(dioraw0,inst);
  }
  return tsRelay8DIORawInit(&r8dio[inst],BusInit(2),0x140 + inst * 0x10);
}

canonical_original_code:
struct DIORaw *tsrelay8__DIORawInit3(struct DIORaw *dioraw0, int inst) {
  if (!r8present[3]) {
    return tsrelay8__DIORawInit2(dioraw0,inst);
  }
  return tsRelay8DIORawInit(&r8dio[inst],BusInit(2),0x140 + inst * 0x10);
}


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

if ( !r8present[0] )
return tsrelay8__DIORawInit3(a1, a2);
v2 = BusInit(2LL);
return tsRelay8DIORawInit((char *)&r8dio + 112 * a2, v2, (unsigned int)(16 * (a2 + 20)));
}

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

if ( !r8present[0] )
return func5(a1, a2);
v2 = BusInit(2LL);
return tsRelay8DIORawInit((char *)&r8dio + 112 * a2, v2, (unsigned int)(16 * (a2 + 20)));
}

original_code:
DIORaw *tsrelay8__DIORawInit0(DIORaw *dioraw0,int inst) {
  if (!r8present[0]) {
    return tsrelay8__DIORawInit3(dioraw0,inst);
  }
  return tsRelay8DIORawInit(&r8dio[inst],BusInit(2),0x140 + inst * 0x10);
}

canonical_original_code:
struct DIORaw *tsrelay8__DIORawInit0(struct DIORaw *dioraw0, int inst) {
  if (!r8present[0]) {
    return tsrelay8__DIORawInit3(dioraw0,inst);
  }
  return tsRelay8DIORawInit(&r8dio[inst],BusInit(2),0x140 + inst * 0x10);
}


decompiled_code:
__int64 __fastcall tsrelay8__DIOInit0(__int64 a1, int a2)
{
__int64 v2; // rax
__int64 v3; // r12
__int64 v4; // rax

v2 = tsrelay8__DIORawInit0(0LL, a2);
if ( (unsigned int)a2 > 3 )
return DummyDIOInit((char *)&r8dummyDIO + 128 * (__int64)a2, 8LL);
v3 = v2;
if ( !r8present[a2] )
return DummyDIOInit((char *)&r8dummyDIO + 128 * (__int64)a2, 8LL);
Relay8DIOCapabilities = 6;
*(&Relay8DIOCapabilities + 1) = 6;
*(&Relay8DIOCapabilities + 2) = 6;
*(&Relay8DIOCapabilities + 3) = 6;
*(&Relay8DIOCapabilities + 4) = 6;
*(&Relay8DIOCapabilities + 5) = 6;
*(&Relay8DIOCapabilities + 6) = 6;
*(&Relay8DIOCapabilities + 7) = 6;
r8pdio[21 * a2 + 19] = (__int64)&Relay8DIOCapabilities;
v4 = BusInit(2LL);
return PhysicalDIOInit(&r8pdio[21 * a2], v4, v3);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, int a2)
{
__int64 v2; // rax
__int64 v3; // r12
__int64 v4; // rax

v2 = func6(0LL, a2);
if ( (unsigned int)a2 > 3 )
return DummyDIOInit((char *)&r8dummyDIO + 128 * (__int64)a2, 8LL);
v3 = v2;
if ( !r8present[a2] )
return DummyDIOInit((char *)&r8dummyDIO + 128 * (__int64)a2, 8LL);
Relay8DIOCapabilities = 6;
*(&Relay8DIOCapabilities + 1) = 6;
*(&Relay8DIOCapabilities + 2) = 6;
*(&Relay8DIOCapabilities + 3) = 6;
*(&Relay8DIOCapabilities + 4) = 6;
*(&Relay8DIOCapabilities + 5) = 6;
*(&Relay8DIOCapabilities + 6) = 6;
*(&Relay8DIOCapabilities + 7) = 6;
r8pdio[21 * a2 + 19] = (__int64)&Relay8DIOCapabilities;
v4 = BusInit(2LL);
return PhysicalDIOInit(&r8pdio[21 * a2], v4, v3);
}

original_code:
DIO *tsrelay8__DIOInit0(DIO *dio,int inst) {
  int i;
  DIORaw *dioraw = tsrelay8__DIORawInit0(0,inst);
  if (inst >= 0 && inst <= 3 && r8present[inst]) {
    for (i=0;i<8;i++) {
      Relay8DIOCapabilities[i] = DIO_OUTPUT_ONLY;
    }
    r8pdio[inst].Caps = Relay8DIOCapabilities;
    return PhysicalDIOInit(&r8pdio[inst],BusInit(2),dioraw);
  } else {
    return DummyDIOInit(&r8dummyDIO[inst],8);
  }
}

canonical_original_code:
struct DIO *tsrelay8__DIOInit0(struct DIO *dio, int inst) {
  int i;
  struct DIORaw *dioraw = tsrelay8__DIORawInit0(0,inst);
  if (inst >= 0 && inst <= 3 && r8present[inst]) {
    for (i=0;i<8;i++) {
      Relay8DIOCapabilities[i] = DIO_OUTPUT_ONLY;
    }
    r8pdio[inst].Caps = Relay8DIOCapabilities;
    return PhysicalDIOInit(&r8pdio[inst],BusInit(2),dioraw);
  } else {
    return DummyDIOInit(&r8dummyDIO[inst],8);
  }
}

variable_types:
dio
struct DIO *

variable_types: struct DIORaw { void *(*Init)(void *me, ...); void (*Fini)(void *me); int (*Lock)(void *me, unsigned int num, int flags); int (*Unlock)(void *me, unsigned int num, int flags); int (*Preempt)(void *me); void (*DirSet)(void *me, int num, int asOutput); void (*DataSet)(void *me, int num, int asHigh); int (*DirGet)(void *me, int num); int (*DataGet)(void *me, int num); unsigned int (*Count)(void *me); int InitStatus; } *

return_type: struct DIO { void *(*Init)(void *me, ...); void (*Fini)(void *me); int (*Lock)(void *me, unsigned int num, int flags); int (*Unlock)(void *me, unsigned int num, int flags); int (*Preempt)(void *me); void (*Refresh)(void *me); void (*Commit)(void *me, int ForceAll); void (*Set)(void *me, int DIONum, enum DIOState { INPUT_LOW=-3, INPUT_HIGH=-2, INPUT=-1, LOW=0, HIGH=1 } State); enum DIOState { INPUT_LOW=-3, INPUT_HIGH=-2, INPUT=-1, LOW=0, HIGH=1 } (*Get)(void *me, int DIONum); void (*SetAsync)(void *me, int DIONum, enum DIOState { INPUT_LOW=-3, INPUT_HIGH=-2, INPUT=-1, LOW=0, HIGH=1 } State); enum DIOState { INPUT_LOW=-3, INPUT_HIGH=-2, INPUT=-1, LOW=0, HIGH=1 } (*GetAsync)(void *me, int DIONum); void (*Wait)(void *me, int *match, int min, int max, int *nh, int *nl); unsigned int (*Count)(void *me); enum DIOCaps { DIO_NOT_PRESENT=0, DIO_CAN_INPUT=1, DIO_CAN_DRIVE_HIGH=2, DIO_HIGH_SIDE=3, DIO_CAN_DRIVE_LOW=4, DIO_LOW_SIDE=5, DIO_OUTPUT_ONLY=6, DIO_NORMAL=7 } (*Capabilities)(void *me, unsigned int num); int (*GetMulti)(void *me, char *state, int offset); int InitStatus; } *

user_defined_types: struct DIO { void *(*Init)(void *me, ...); void (*Fini)(void *me); int (*Lock)(void *me, unsigned int num, int flags); int (*Unlock)(void *me, unsigned int num, int flags); int (*Preempt)(void *me); void (*Refresh)(void *me); void (*Commit)(void *me, int ForceAll); void (*Set)(void *me, int DIONum, enum DIOState State); enum DIOState (*Get)(void *me, int DIONum); void (*SetAsync)(void *me, int DIONum, enum DIOState State); enum DIOState (*GetAsync)(void *me, int DIONum); void (*Wait)(void *me, int *match, int min, int max, int *nh, int *nl); unsigned int (*Count)(void *me); enum DIOCaps (*Capabilities)(void *me, unsigned int num); int (*GetMulti)(void *me, char *state, int offset); int InitStatus; }


decompiled_code:
__int64 __fastcall tsrelay8__DIOInit1(__int64 a1, int a2)
{
return tsrelay8__DIOInit0(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, int a2)
{
return func7(a1, a2);
}

original_code:
DIO *tsrelay8__DIOInit1(DIO *dio,int inst) {
  return tsrelay8__DIOInit0(dio,inst);
}

canonical_original_code:
struct DIO *tsrelay8__DIOInit1(struct DIO *dio, int inst) {
  return tsrelay8__DIOInit0(dio,inst);
}

user_defined_types: enum DIOState { INPUT_LOW=-3, INPUT_HIGH=-2, INPUT=-1, LOW=0, HIGH=1 }

user_defined_types: enum DIOCaps { DIO_NOT_PRESENT=0, DIO_CAN_INPUT=1, DIO_CAN_DRIVE_HIGH=2, DIO_HIGH_SIDE=3, DIO_CAN_DRIVE_LOW=4, DIO_LOW_SIDE=5, DIO_OUTPUT_ONLY=6, DIO_NORMAL=7 }


decompiled_code:
__int64 __fastcall tsrelay8__DIOInit2(__int64 a1, int a2)
{
return tsrelay8__DIOInit0(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, int a2)
{
return func7(a1, a2);
}

original_code:
DIO *tsrelay8__DIOInit2(DIO *dio,int inst) {
  return tsrelay8__DIOInit0(dio,inst);
}

canonical_original_code:
struct DIO *tsrelay8__DIOInit2(struct DIO *dio, int inst) {
  return tsrelay8__DIOInit0(dio,inst);
}


decompiled_code:
__int64 __fastcall tsrelay8__DIOInit3(__int64 a1, int a2)
{
return tsrelay8__DIOInit0(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, int a2)
{
return func7(a1, a2);
}

original_code:
DIO *tsrelay8__DIOInit3(DIO *dio,int inst) {
  return tsrelay8__DIOInit0(dio,inst);
}

canonical_original_code:
struct DIO *tsrelay8__DIOInit3(struct DIO *dio, int inst) {
  return tsrelay8__DIOInit0(dio,inst);
}


ArrayFree

decompiled_code:
void __fastcall ArrayFree(__int64 a1)
{
free((void *)(a1 - 12));
}

canonical_decompiled_code:
void __fastcall func11(__int64 a1)
{
free((void *)(a1 - 12));
}

original_code:
void ArrayFree(const void *arr) {
  unsigned *ptr = (unsigned *)arr;
  free(ptr-3);
}

canonical_original_code:
void ArrayFree(void *arr) {
  unsigned int *ptr = (unsigned *)arr;
  free(ptr-3);
}

variable_types:
arr
void *

variable_types:
ptr
unsigned int *


ASCIIZ

decompiled_code:
char *__fastcall ASCIIZ(char *src)
{
unsigned int v1; // ebx
char *v2; // rax

v1 = strlen(src);
v2 = (char *)ArrayAlloc(v1, 1u);
return strncpy(v2, src, v1);
}

canonical_decompiled_code:
char *__fastcall func13(char *src)
{
unsigned int v1; // ebx
char *v2; // rax

v1 = strlen(src);
v2 = (char *)ArrayAlloc(v1, 1u);
return strncpy(v2, src, v1);
}

original_code:
char *ASCIIZ(const char *str) {
  unsigned len = strlen(str);
  char *str2 = (char *)ArrayAlloc(len,1);
  strncpy(str2,str,len);
  return str2;
}

canonical_original_code:
char *ASCIIZ(char *str) {
  unsigned int len = strlen(str);
  char *str2 = (char *)ArrayAlloc(len,1);
  strncpy(str2,str,len);
  return str2;
}

variable_types:
str
char *

variable_types:
len
unsigned int


ArraySizeAuto

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

result = a1;
*(_DWORD *)(a1 - 4) = a2;
return result;
}

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

result = a1;
*(_DWORD *)(a1 - 4) = a2;
return result;
}

original_code:
void *ArraySizeAuto(void *arr,unsigned count) {
  unsigned *ptr = (unsigned *)arr;
  ptr -= 3;
  ptr[2] = count;
  return &ptr[3];
}

canonical_original_code:
void *ArraySizeAuto(void *arr, unsigned int count) {
  unsigned int *ptr = (unsigned *)arr;
  ptr -= 3;
  ptr[2] = count;
  return &ptr[3];
}

variable_types:
count
unsigned int


ArrayElementSize

decompiled_code:
__int64 __fastcall ArrayElementSize(__int64 a1)
{
return *(unsigned int *)(a1 - 8);
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1)
{
return *(unsigned int *)(a1 - 8);
}

original_code:
unsigned ArrayElementSize(const void *array) {
  return _ArrayElementSize(array);
}

canonical_original_code:
unsigned int ArrayElementSize(void *array) {
  return _ArrayElementSize(array);
}

variable_types:
array
void *


ArrayLength

decompiled_code:
__int64 __fastcall ArrayLength(__int64 a1)
{
return *(unsigned int *)(a1 - 4);
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 a1)
{
return *(unsigned int *)(a1 - 4);
}

original_code:
unsigned ArrayLength(const void *array) {
  return _ArrayLength(array);
}

canonical_original_code:
unsigned int ArrayLength(void *array) {
  return _ArrayLength(array);
}


ArrayFreeFree

decompiled_code:
void __fastcall ArrayFreeFree(__int64 a1)
{
__int64 v2; // rbx
__int64 v3; // rdi

if ( *(_DWORD *)(a1 - 4) )
{
v2 = 0LL;
do
{
v3 = *(_QWORD *)(a1 + 8 * v2);
if ( v3 )
ArrayFree(v3);
++v2;
}
while ( *(_DWORD *)(a1 - 4) > (unsigned int)v2 );
}
ArrayFree(a1);
}

original_code:
void ArrayFreeFree(const void *arr0) {
  const void * const *arr = (const void * const *)arr0;
  int i;
  for (i=0;i<_ArrayLength(arr);i++) {
    if (arr[i]) ArrayFree(arr[i]);
  }
  ArrayFree(arr);
}

canonical_original_code:
void ArrayFreeFree(void *arr0) {
  void **arr = (const void * const *)arr0;
  int i;
  for (i=0;i<_ArrayLength(arr);i++) {
    if (arr[i]) ArrayFree(arr[i]);
  }
  ArrayFree(arr);
}

variable_types:
arr
void **

variable_types: i int


ArrayFreeFreeFree

decompiled_code:
void __fastcall ArrayFreeFreeFree(__int64 a1)
{
__int64 v2; // rbp
__int64 v3; // rdi
__int64 v4; // rbx
__int64 v5; // rdi

if ( *(_DWORD *)(a1 - 4) )
{
v2 = 0LL;
do
{
v3 = *(_QWORD *)(a1 + 8 * v2);
if ( v3 )
{
if ( *(_DWORD *)(v3 - 4) )
{
v4 = 0LL;
do
{
v5 = *(_QWORD *)(v3 + 8 * v4);
if ( v5 )
ArrayFree(v5);
v3 = *(_QWORD *)(a1 + 8 * v2);
++v4;
}
while ( *(_DWORD *)(v3 - 4) > (unsigned int)v4 );
}
ArrayFree(v3);
}
++v2;
}
while ( *(_DWORD *)(a1 - 4) > (unsigned int)v2 );
}
ArrayFree(a1);
}

original_code:
void ArrayFreeFreeFree(const void *arr0) {
  const void ** const *arr = (const void ** const *)arr0;
  int i,j;
  for (i=0;i<_ArrayLength(arr);i++) {
    if (arr[i]) {
      for (j=0;j<_ArrayLength(arr[i]);j++) {
 if (arr[i][j]) ArrayFree(arr[i][j]);
      }
      ArrayFree(arr[i]);
    }
  }
  ArrayFree(arr);
}

canonical_original_code:
void ArrayFreeFreeFree(void *arr0) {
  void ***arr = (const void ** const *)arr0;
  int i; int j;
  for (i=0;i<_ArrayLength(arr);i++) {
    if (arr[i]) {
      for (j=0;j<_ArrayLength(arr[i]);j++) {
 if (arr[i][j]) ArrayFree(arr[i][j]);
      }
      ArrayFree(arr[i]);
    }
  }
  ArrayFree(arr);
}

variable_types:
arr
void ***

variable_types: j int


ArrayCompareFunction

decompiled_code:
__int64 ArrayCompareFunction()
{
return ArrayCompareFunction();
}

canonical_decompiled_code:
__int64 func19()
{
return func19();
}

original_code:
void *ArrayCompareFunction(const void *array) {
  return ArrayCompareFunction(array);
}

canonical_original_code:
void *ArrayCompareFunction(void *array) {
  return ArrayCompareFunction(array);
}


LinuxTWIFini

decompiled_code:
int __fastcall LinuxTWIFini(__int64 a1)
{
int result; // eax
int v3; // edi

result = (*(__int64 (__fastcall **)(_QWORD))(*(_QWORD *)(a1 + 64) + 8LL))(*(_QWORD *)(a1 + 64));
v3 = *(_DWORD *)(a1 + 88);
if ( v3 )
{
result = close(v3);
*(_DWORD *)(a1 + 88) = 0;
}
if ( *(int *)(a1 + 56) > 0 )
*(_DWORD *)(a1 + 56) = 0;
return result;
}

original_code:
void LinuxTWIFini(LinuxTWI *twi){
  twi->bus->Fini(twi->bus);
  if (twi->f) {
    close(twi->f);
    twi->f = 0;
  }
  if (twi->InitStatus > 0) twi->InitStatus = 0;
}

canonical_original_code:
void LinuxTWIFini(struct LinuxTWI *twi){
  twi->bus->Fini(twi->bus);
  if (twi->f) {
    close(twi->f);
    twi->f = 0;
  }
  if (twi->InitStatus > 0) twi->InitStatus = 0;
}

variable_types: struct LinuxTWI { void *(*Init)(struct LinuxTWI *me, char *devfile); void (*Fini)(struct LinuxTWI *me); int (*Lock)(struct LinuxTWI *me, unsigned int num, int flags); int (*Unlock)(struct LinuxTWI *me, unsigned int num, int flags); int (*Preempt)(struct LinuxTWI *me); enum TWIResult { TWISuccess=1, TWIErrorPortInvalid=-1, TWIErrorModeUnsupported=-2, TWIErrorBaudUnconstrained=-3, TWIErrorHardware=-4, TWIErrorHandle=-5, TWIErrorWriteNAck=-6, TWIErrorDataNAck=-7, TWIErrorReadNack=-8, TWIErrorSDALow=-9, TWIErrorSCLLow=-10, TWIErrorAdrsLen=-11, TWIErrorTimeout=-12, TWIErrorOverrun=-13, TWIErrorArbLost=-14, TWIErrorUnknown=-999, TWIErrorOpInvalid=-15 } (*Write)(struct LinuxTWI *me, int devadr, int adrslen, int adrs, char *bytes); enum TWIResult { TWISuccess=1, TWIErrorPortInvalid=-1, TWIErrorModeUnsupported=-2, TWIErrorBaudUnconstrained=-3, TWIErrorHardware=-4, TWIErrorHandle=-5, TWIErrorWriteNAck=-6, TWIErrorDataNAck=-7, TWIErrorReadNack=-8, TWIErrorSDALow=-9, TWIErrorSCLLow=-10, TWIErrorAdrsLen=-11, TWIErrorTimeout=-12, TWIErrorOverrun=-13, TWIErrorArbLost=-14, TWIErrorUnknown=-999, TWIErrorOpInvalid=-15 } (*Read)(struct LinuxTWI *me, int devadr, int adrslen, int adrs, char *bytes); int InitStatus; struct Bus { void *(*Init)(void *me, ...); void (*Fini)(void *me); int (*Lock)(void *me, unsigned int num, int flags); int (*Unlock)(void *me, unsigned int num, int flags); int (*Preempt)(void *me); unsigned char (*Peek8)(void *me, int Address); void (*Poke8)(void *me, int Address, unsigned char Value); unsigned short (*Peek16)(void *me, int Address); void (*Poke16)(void *me, int Address, unsigned short Value); unsigned int (*Peek32)(void *me, int Address); void (*Poke32)(void *me, int Address, unsigned int Value); int (*BitGet8)(void *me, int Address, int BitNumber); void (*BitAssign8)(void *me, int Address, int BitNumber, int Value); void (*BitSet8)(void *me, int Address, int BitNumber); void (*BitClear8)(void *me, int Address, int BitNumber); int (*BitGet16)(void *me, int Address, int BitNumber); void (*BitAssign16)(void *me, int Address, int BitNumber, int Value); void (*BitSet16)(void *me, int Address, int BitNumber); void (*BitClear16)(void *me, int Address, int BitNumber); int (*BitGet32)(void *me, int Address, int BitNumber); void (*BitAssign32)(void *me, int Address, int BitNumber, int Value); void (*BitSet32)(void *me, int Address, int BitNumber); void (*BitClear32)(void *me, int Address, int BitNumber); void (*PeekStream)(void *me, int address, int direction, char *dest); void (*PokeStream)(void *me, int address, int direction, char *data); void (*Refresh)(void *me); void (*Commit)(void *me, int ForceAll); int (*BitToggle8)(void *me, int Address, int BitNumber); int (*BitToggle16)(void *me, int Address, int BitNumber); int (*BitToggle32)(void *me, int Address, int BitNumber); unsigned char (*Assign8X)(void *me, int Address, int BitMSB, int BitLSB, int Value); unsigned short (*Assign16X)(void *me, int Address, int BitMSB, int BitLSB, int Value); unsigned int (*Assign32X)(void *me, int Address, int BitMSB, int BitLSB, int Value); unsigned char (*BitsGet8)(void *me, int Address, int BitMSB, int BitLSB); unsigned short (*BitsGet16)(void *me, int Address, int BitMSB, int BitLSB); unsigned int (*BitsGet32)(void *me, int Address, int BitMSB, int BitLSB); int InitStatus; unsigned int LockBase; int deferlockW; int deferlockR; } *bus; int LockNum; char *devfile; int f; } *

user_defined_types: struct LinuxTWI { void *(*Init)(struct LinuxTWI *me, char *devfile); void (*Fini)(struct LinuxTWI *me); int (*Lock)(struct LinuxTWI *me, unsigned int num, int flags); int (*Unlock)(struct LinuxTWI *me, unsigned int num, int flags); int (*Preempt)(struct LinuxTWI *me); enum TWIResult (*Write)(struct LinuxTWI *me, int devadr, int adrslen, int adrs, char *bytes); enum TWIResult (*Read)(struct LinuxTWI *me, int devadr, int adrslen, int adrs, char *bytes); int InitStatus; struct Bus *bus; int LockNum; char *devfile; int f; }


LinuxTWILock

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

if ( (a3 & 2) != 0 )
return 4294967285LL;
result = ThreadMutexLock(*(unsigned int *)(a1 + 72));
if ( (int)result >= 0 )
{
result = 1LL;
if ( !*(_DWORD *)(a1 + 88) )
{
*(_DWORD *)(a1 + 88) = open(*(const char **)(a1 + 80), 2);
result = 1LL;
}
}
return result;
}

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

if ( (a3 & 2) != 0 )
return 4294967285LL;
result = ThreadMutexLock(*(unsigned int *)(a1 + 72));
if ( (int)result >= 0 )
{
result = 1LL;
if ( !*(_DWORD *)(a1 + 88) )
{
*(_DWORD *)(a1 + 88) = open(*(const char **)(a1 + 80), 2);
result = 1LL;
}
}
return result;
}

original_code:
int LinuxTWILock(LinuxTWI *twi,unsigned num,int flags) {
  int ret,mode;
  if (flags & SHARED) return -11;
  mode = (flags & NONBLOCKING) ?
    LOCK_TRY :
    (flags & NOUNLOCK) ? LOCK_FOD : LOCK_SOD;
  if ((ret=ThreadMutexLock(twi->LockNum,mode)) < 0) return ret;
  if (!twi->f) {
    twi->f = open(twi->devfile,02);
  }
  return 1;
}

canonical_original_code:
int LinuxTWILock(struct LinuxTWI *twi, unsigned int num, int flags) {
  int ret; int mode;
  if (flags & SHARED) return -11;
  mode = (flags & NONBLOCKING) ?
    LOCK_TRY :
    (flags & NOUNLOCK) ? LOCK_FOD : LOCK_SOD;
  if ((ret=ThreadMutexLock(twi->LockNum,mode)) < 0) return ret;
  if (!twi->f) {
    twi->f = open(twi->devfile,02);
  }
  return 1;
}

variable_types:
num
unsigned int

variable_types: flags int

variable_types: ret int

variable_types: mode int

user_defined_types: enum TWIResult { TWISuccess=1, TWIErrorPortInvalid=-1, TWIErrorModeUnsupported=-2, TWIErrorBaudUnconstrained=-3, TWIErrorHardware=-4, TWIErrorHandle=-5, TWIErrorWriteNAck=-6, TWIErrorDataNAck=-7, TWIErrorReadNack=-8, TWIErrorSDALow=-9, TWIErrorSCLLow=-10, TWIErrorAdrsLen=-11, TWIErrorTimeout=-12, TWIErrorOverrun=-13, TWIErrorArbLost=-14, TWIErrorUnknown=-999, TWIErrorOpInvalid=-15 }


LinuxTWIUnlock

decompiled_code:
__int64 __fastcall LinuxTWIUnlock(__int64 a1)
{
close(*(_DWORD *)(a1 + 88));
*(_DWORD *)(a1 + 88) = 0;
return ThreadMutexUnlock(*(unsigned int *)(a1 + 72));
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
close(*(_DWORD *)(a1 + 88));
*(_DWORD *)(a1 + 88) = 0;
return ThreadMutexUnlock(*(unsigned int *)(a1 + 72));
}

original_code:
int LinuxTWIUnlock(LinuxTWI *twi,unsigned num,int flags) {
  close(twi->f);
  twi->f = 0;
  return ThreadMutexUnlock(twi->LockNum);
}

canonical_original_code:
int LinuxTWIUnlock(struct LinuxTWI *twi, unsigned int num, int flags) {
  close(twi->f);
  twi->f = 0;
  return ThreadMutexUnlock(twi->LockNum);
}


LinuxTWIPreempt

decompiled_code:
__int64 __fastcall LinuxTWIPreempt(__int64 a1)
{
LinuxTWILock(a1, *(unsigned int *)(a1 + 72), 0);
sched_yield();
return LinuxTWILock(a1, *(unsigned int *)(a1 + 72), 0);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
func2(a1, *(unsigned int *)(a1 + 72), 0);
sched_yield();
return func2(a1, *(unsigned int *)(a1 + 72), 0);
}

original_code:
int LinuxTWIPreempt(LinuxTWI *twi) {
  LinuxTWILock(twi,twi->LockNum,0);
  sched_yield();
  return LinuxTWILock(twi,twi->LockNum,0);
}

canonical_original_code:
int LinuxTWIPreempt(struct LinuxTWI *twi) {
  LinuxTWILock(twi,twi->LockNum,0);
  sched_yield();
  return LinuxTWILock(twi,twi->LockNum,0);
}


ArrayFree

canonical_decompiled_code:
void __fastcall func5(__int64 a1)
{
free((void *)(a1 - 12));
}


ASCIIZ

canonical_decompiled_code:
char *__fastcall func7(char *src)
{
unsigned int v1; // ebx
char *v2; // rax

v1 = strlen(src);
v2 = (char *)ArrayAlloc(v1, 1u);
return strncpy(v2, src, v1);
}


ArraySizeAuto

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

result = a1;
*(_DWORD *)(a1 - 4) = a2;
return result;
}


ArrayElementSize

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
return *(unsigned int *)(a1 - 8);
}


ArrayLength

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
return *(unsigned int *)(a1 - 4);
}


LinuxTWIWrite

decompiled_code:
__int64 __fastcall LinuxTWIWrite(__int64 a1, unsigned int a2, int a3, int a4, const void *a5)
{
int v7; // ebx
int buf[11]; // [rsp+Ch] [rbp-2Ch] BYREF

buf[0] = a4;
v7 = ArrayLength((__int64)a5);
ioctl(*(_DWORD *)(a1 + 88), 0x703uLL, a2);
write(*(_DWORD *)(a1 + 88), buf, a3);
write(*(_DWORD *)(a1 + 88), a5, v7);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, unsigned int a2, int a3, int a4, const void *a5)
{
int v7; // ebx
int buf[11]; // [rsp+Ch] [rbp-2Ch] BYREF

buf[0] = a4;
v7 = func10((__int64)a5);
ioctl(*(_DWORD *)(a1 + 88), 0x703uLL, a2);
write(*(_DWORD *)(a1 + 88), buf, a3);
write(*(_DWORD *)(a1 + 88), a5, v7);
return 1LL;
}

original_code:
int LinuxTWIWrite(LinuxTWI *twi,int devadrs,int adrslen,int adrs,const char* bytes){
  int len = ArrayLength(bytes);
  ioctl(twi->f,0x0703,devadrs);
  write(twi->f,&adrs,adrslen);
  write(twi->f,bytes,len);
  return 1;
}

canonical_original_code:
int LinuxTWIWrite(struct LinuxTWI *twi, int devadrs, int adrslen, int adrs, char *bytes){
  int len = ArrayLength(bytes);
  ioctl(twi->f,0x0703,devadrs);
  write(twi->f,&adrs,adrslen);
  write(twi->f,bytes,len);
  return 1;
}

variable_types: devadrs int

variable_types: adrslen int

variable_types: adrs int

variable_types:
bytes
char *

variable_types: len int


LinuxTWIRead

decompiled_code:
__int64 __fastcall LinuxTWIRead(__int64 a1, unsigned int a2, int a3, int a4, void *a5)
{
int v7; // ebx
int buf[11]; // [rsp+Ch] [rbp-2Ch] BYREF

buf[0] = a4;
v7 = ArrayLength((__int64)a5);
ioctl(*(_DWORD *)(a1 + 88), 0x703uLL, a2);
write(*(_DWORD *)(a1 + 88), buf, a3);
read(*(_DWORD *)(a1 + 88), a5, v7);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, unsigned int a2, int a3, int a4, void *a5)
{
int v7; // ebx
int buf[11]; // [rsp+Ch] [rbp-2Ch] BYREF

buf[0] = a4;
v7 = func10((__int64)a5);
ioctl(*(_DWORD *)(a1 + 88), 0x703uLL, a2);
write(*(_DWORD *)(a1 + 88), buf, a3);
read(*(_DWORD *)(a1 + 88), a5, v7);
return 1LL;
}

original_code:
int LinuxTWIRead(LinuxTWI *twi,int devadrs,int adrslen,int adrs,char* bytes){
  int len = ArrayLength(bytes);
  ioctl(twi->f,0x0703,devadrs);
  write(twi->f,&adrs,adrslen);
  read(twi->f,bytes,len);
  return 1;
}

canonical_original_code:
int LinuxTWIRead(struct LinuxTWI *twi, int devadrs, int adrslen, int adrs, char *bytes){
  int len = ArrayLength(bytes);
  ioctl(twi->f,0x0703,devadrs);
  write(twi->f,&adrs,adrslen);
  read(twi->f,bytes,len);
  return 1;
}


ArrayCompareFunction

canonical_decompiled_code:
__int64 func15()
{
return func15();
}


original_code:
void *ts8900PinInit(ts8900Pin *pin,void *parent,void *bus,int start) {
  if (pin->InitStatus > 0) return pin;
  pin->LockBase = ((Pin *)parent)->LockBase;
  pin->Init = (void *)ts8900PinInit;
  pin->Fini = (void *)ts8900PinFini;
  pin->Lock = ((ts8900Pin *)parent)->Lock;
  pin->Unlock = ((ts8900Pin *)parent)->Unlock;
  pin->Preempt = ((ts8900Pin *)parent)->Preempt;
  pin->ModeGet = (void *)ts8900PinModeGet;
  pin->ModeSet = (void *)ts8900PinModeSet;
  pin->parent = parent;
  pin->bus = bus;
  pin->InitStatus = 1;
  pin->start = start;
  return pin;
}

canonical_original_code:
void *ts8900PinInit(struct ts8900Pin *pin, void *parent, void *bus, int start) {
  if (pin->InitStatus > 0) return pin;
  pin->LockBase = ((struct Pin *)parent)->LockBase;
  pin->Init = (void *)ts8900PinInit;
  pin->Fini = (void *)ts8900PinFini;
  pin->Lock = ((struct ts8900Pin *)parent)->Lock;
  pin->Unlock = ((struct ts8900Pin *)parent)->Unlock;
  pin->Preempt = ((struct ts8900Pin *)parent)->Preempt;
  pin->ModeGet = (void *)ts8900PinModeGet;
  pin->ModeSet = (void *)ts8900PinModeSet;
  pin->parent = parent;
  pin->bus = bus;
  pin->InitStatus = 1;
  pin->start = start;
  return pin;
}

variable_types: struct ts8900Pin { void *(*Init)(struct ts8900Pin *me, void *parent, void *bus, int start); void (*Fini)(struct ts8900Pin *me); int (*Lock)(struct ts8900Pin *me, unsigned int num, int flags); int (*Unlock)(struct ts8900Pin *me, unsigned int num, int flags); int (*Preempt)(struct ts8900Pin *me); enum PinMode { MODE_DIO=0, MODE_CAN=1, MODE_SPI=2, MODE_ADC=3, MODE_TWI=4, MODE_UART=5, MODE_TS=6, MODE_BUS=7, MODE_PWM=8, MODE_CLK=9, MODE_UNKNOWN=-1 } (*ModeGet)(struct ts8900Pin *me, int PinNumber); enum PinResult { PinSuccess=1, PinErrorModeInvalid=-13 } (*ModeSet)(struct ts8900Pin *me, int PinNumber, enum PinMode { MODE_DIO=0, MODE_CAN=1, MODE_SPI=2, MODE_ADC=3, MODE_TWI=4, MODE_UART=5, MODE_TS=6, MODE_BUS=7, MODE_PWM=8, MODE_CLK=9, MODE_UNKNOWN=-1 } Mode); int InitStatus; unsigned int LockBase; int deferlock; int deferlockR; int deferlockW; struct Pin { void *(*Init)(void *me, ...); void (*Fini)(void *me); int (*Lock)(void *me, unsigned int num, int flags); int (*Unlock)(void *me, unsigned int num, int flags); int (*Preempt)(void *me); enum PinMode { MODE_DIO=0, MODE_CAN=1, MODE_SPI=2, MODE_ADC=3, MODE_TWI=4, MODE_UART=5, MODE_TS=6, MODE_BUS=7, MODE_PWM=8, MODE_CLK=9, MODE_UNKNOWN=-1 } (*ModeGet)(void *me, int PinNumber); enum PinResult { PinSuccess=1, PinErrorModeInvalid=-13 } (*ModeSet)(void *me, int PinNumber, enum PinMode { MODE_DIO=0, MODE_CAN=1, MODE_SPI=2, MODE_ADC=3, MODE_TWI=4, MODE_UART=5, MODE_TS=6, MODE_BUS=7, MODE_PWM=8, MODE_CLK=9, MODE_UNKNOWN=-1 } Mode); int InitStatus; unsigned int LockBase; int deferlock; } *parent; struct Bus { void *(*Init)(void *me, ...); void (*Fini)(void *me); int (*Lock)(void *me, unsigned int num, int flags); int (*Unlock)(void *me, unsigned int num, int flags); int (*Preempt)(void *me); unsigned char (*Peek8)(void *me, int Address); void (*Poke8)(void *me, int Address, unsigned char Value); unsigned short (*Peek16)(void *me, int Address); void (*Poke16)(void *me, int Address, unsigned short Value); unsigned int (*Peek32)(void *me, int Address); void (*Poke32)(void *me, int Address, unsigned int Value); int (*BitGet8)(void *me, int Address, int BitNumber); void (*BitAssign8)(void *me, int Address, int BitNumber, int Value); void (*BitSet8)(void *me, int Address, int BitNumber); void (*BitClear8)(void *me, int Address, int BitNumber); int (*BitGet16)(void *me, int Address, int BitNumber); void (*BitAssign16)(void *me, int Address, int BitNumber, int Value); void (*BitSet16)(void *me, int Address, int BitNumber); void (*BitClear16)(void *me, int Address, int BitNumber); int (*BitGet32)(void *me, int Address, int BitNumber); void (*BitAssign32)(void *me, int Address, int BitNumber, int Value); void (*BitSet32)(void *me, int Address, int BitNumber); void (*BitClear32)(void *me, int Address, int BitNumber); void (*PeekStream)(void *me, int address, int direction, char *dest); void (*PokeStream)(void *me, int address, int direction, char *data); void (*Refresh)(void *me); void (*Commit)(void *me, int ForceAll); int (*BitToggle8)(void *me, int Address, int BitNumber); int (*BitToggle16)(void *me, int Address, int BitNumber); int (*BitToggle32)(void *me, int Address, int BitNumber); unsigned char (*Assign8X)(void *me, int Address, int BitMSB, int BitLSB, int Value); unsigned short (*Assign16X)(void *me, int Address, int BitMSB, int BitLSB, int Value); unsigned int (*Assign32X)(void *me, int Address, int BitMSB, int BitLSB, int Value); unsigned char (*BitsGet8)(void *me, int Address, int BitMSB, int BitLSB); unsigned short (*BitsGet16)(void *me, int Address, int BitMSB, int BitLSB); unsigned int (*BitsGet32)(void *me, int Address, int BitMSB, int BitLSB); int InitStatus; unsigned int LockBase; int deferlockW; int deferlockR; } *bus; int start; } *

variable_types:
parent
void *

variable_types:
bus
void *

variable_types: start int

user_defined_types: struct ts8900Pin { void *(*Init)(struct ts8900Pin *me, void *parent, void *bus, int start); void (*Fini)(struct ts8900Pin *me); int (*Lock)(struct ts8900Pin *me, unsigned int num, int flags); int (*Unlock)(struct ts8900Pin *me, unsigned int num, int flags); int (*Preempt)(struct ts8900Pin *me); enum PinMode (*ModeGet)(struct ts8900Pin *me, int PinNumber); enum PinResult (*ModeSet)(struct ts8900Pin *me, int PinNumber, enum PinMode Mode); int InitStatus; unsigned int LockBase; int deferlock; int deferlockR; int deferlockW; struct Pin *parent; struct Bus *bus; int start; }

user_defined_types: struct Pin { void *(*Init)(void *me, ...); void (*Fini)(void *me); int (*Lock)(void *me, unsigned int num, int flags); int (*Unlock)(void *me, unsigned int num, int flags); int (*Preempt)(void *me); enum PinMode (*ModeGet)(void *me, int PinNumber); enum PinResult (*ModeSet)(void *me, int PinNumber, enum PinMode Mode); int InitStatus; unsigned int LockBase; int deferlock; }


original_code:
void ts8900PinFini(ts8900Pin *pin) {
  if (pin->InitStatus > 0) pin->InitStatus = 0;
}

canonical_original_code:
void ts8900PinFini(struct ts8900Pin *pin) {
  if (pin->InitStatus > 0) pin->InitStatus = 0;
}

user_defined_types: enum PinMode { MODE_DIO=0, MODE_CAN=1, MODE_SPI=2, MODE_ADC=3, MODE_TWI=4, MODE_UART=5, MODE_TS=6, MODE_BUS=7, MODE_PWM=8, MODE_CLK=9, MODE_UNKNOWN=-1 }

user_defined_types: enum PinResult { PinSuccess=1, PinErrorModeInvalid=-13 }


original_code:
PinMode ts8900PinModeGet(ts8900Pin *pin,int npin) {
  int ret;
  npin -= pin->start;
  if (npin >= 16 && npin <= 31) {
    pin->bus->Lock(pin->bus,0,SHARED);
    ret=pin->bus->BitGet16(pin->bus,0x08,npin-16) ? MODE_DIO:MODE_BUS;
    pin->bus->Unlock(pin->bus,0,SHARED);
    return ret;
  } else if (npin == 32) {
    pin->bus->Lock(pin->bus,0,SHARED);
    ret=pin->bus->BitGet16(pin->bus,0x0A,8) ? MODE_DIO:MODE_BUS;
    pin->bus->Unlock(pin->bus,0,SHARED);
    return ret;
  } else if (npin >= 33 && npin <= 41) {
    pin->bus->Lock(pin->bus,0,SHARED);
    ret=pin->bus->BitGet16(pin->bus,0x0A,npin-33) ? MODE_DIO:MODE_BUS;
    pin->bus->Unlock(pin->bus,0,SHARED);
    return ret;
  }
  npin += pin->start;
  return pin->parent->ModeGet(pin->parent,npin);
}

canonical_original_code:
enum PinMode ts8900PinModeGet(struct ts8900Pin *pin, int npin) {
  int ret;
  npin -= pin->start;
  if (npin >= 16 && npin <= 31) {
    pin->bus->Lock(pin->bus,0,SHARED);
    ret=pin->bus->BitGet16(pin->bus,0x08,npin-16) ? MODE_DIO:MODE_BUS;
    pin->bus->Unlock(pin->bus,0,SHARED);
    return ret;
  } else if (npin == 32) {
    pin->bus->Lock(pin->bus,0,SHARED);
    ret=pin->bus->BitGet16(pin->bus,0x0A,8) ? MODE_DIO:MODE_BUS;
    pin->bus->Unlock(pin->bus,0,SHARED);
    return ret;
  } else if (npin >= 33 && npin <= 41) {
    pin->bus->Lock(pin->bus,0,SHARED);
    ret=pin->bus->BitGet16(pin->bus,0x0A,npin-33) ? MODE_DIO:MODE_BUS;
    pin->bus->Unlock(pin->bus,0,SHARED);
    return ret;
  }
  npin += pin->start;
  return pin->parent->ModeGet(pin->parent,npin);
}

variable_types: npin int

return_type: enum PinMode { MODE_DIO=0, MODE_CAN=1, MODE_SPI=2, MODE_ADC=3, MODE_TWI=4, MODE_UART=5, MODE_TS=6, MODE_BUS=7, MODE_PWM=8, MODE_CLK=9, MODE_UNKNOWN=-1 }


original_code:
PinResult ts8900PinModeSet(ts8900Pin *pin,int npin,PinMode mode) {
  int ret;
  npin -= pin->start;
  if (npin >= 16 && npin <= 31) {
    pin->bus->Lock(pin->bus,0,0);
    if (mode == MODE_DIO) {
      pin->bus->BitSet16(pin->bus,0x08,npin-16);
      ret=PinSuccess;
    } else if (mode == MODE_BUS) {
      pin->bus->BitClear16(pin->bus,0x08,npin-16);
      ret=PinSuccess;
    } else {
      ret=PinErrorModeInvalid;
    }
    pin->bus->Unlock(pin->bus,0,0);
    return ret;
  } else if (npin == 32) {
    pin->bus->Lock(pin->bus,0,0);
    if (mode == MODE_DIO) {
      pin->bus->BitSet16(pin->bus,0x0A,8);
      ret=PinSuccess;
    } else if (mode == MODE_BUS) {
      pin->bus->BitClear16(pin->bus,0x0A,8);
      ret=PinSuccess;
    } else {
      ret=PinErrorModeInvalid;
    }
    pin->bus->Unlock(pin->bus,0,0);
    return ret;
  } else if (npin >= 33 && npin <= 41) {
    pin->bus->Lock(pin->bus,0,0);
    if (mode == MODE_DIO) {
      pin->bus->BitSet16(pin->bus,0x0A,npin-33);
      ret=PinSuccess;
    } else if (mode == MODE_BUS) {
      pin->bus->BitClear16(pin->bus,0x0A,npin-33);
      ret=PinSuccess;
    } else {
      ret=PinErrorModeInvalid;
    }
    pin->bus->Unlock(pin->bus,0,0);
    return ret;
  }
  npin += pin->start;
  return pin->parent->ModeSet(pin->parent,npin,mode);
}

canonical_original_code:
enum PinResult ts8900PinModeSet(struct ts8900Pin *pin, int npin, enum PinMode mode) {
  int ret;
  npin -= pin->start;
  if (npin >= 16 && npin <= 31) {
    pin->bus->Lock(pin->bus,0,0);
    if (mode == MODE_DIO) {
      pin->bus->BitSet16(pin->bus,0x08,npin-16);
      ret=PinSuccess;
    } else if (mode == MODE_BUS) {
      pin->bus->BitClear16(pin->bus,0x08,npin-16);
      ret=PinSuccess;
    } else {
      ret=PinErrorModeInvalid;
    }
    pin->bus->Unlock(pin->bus,0,0);
    return ret;
  } else if (npin == 32) {
    pin->bus->Lock(pin->bus,0,0);
    if (mode == MODE_DIO) {
      pin->bus->BitSet16(pin->bus,0x0A,8);
      ret=PinSuccess;
    } else if (mode == MODE_BUS) {
      pin->bus->BitClear16(pin->bus,0x0A,8);
      ret=PinSuccess;
    } else {
      ret=PinErrorModeInvalid;
    }
    pin->bus->Unlock(pin->bus,0,0);
    return ret;
  } else if (npin >= 33 && npin <= 41) {
    pin->bus->Lock(pin->bus,0,0);
    if (mode == MODE_DIO) {
      pin->bus->BitSet16(pin->bus,0x0A,npin-33);
      ret=PinSuccess;
    } else if (mode == MODE_BUS) {
      pin->bus->BitClear16(pin->bus,0x0A,npin-33);
      ret=PinSuccess;
    } else {
      ret=PinErrorModeInvalid;
    }
    pin->bus->Unlock(pin->bus,0,0);
    return ret;
  }
  npin += pin->start;
  return pin->parent->ModeSet(pin->parent,npin,mode);
}

variable_types: enum PinMode { MODE_DIO=0, MODE_CAN=1, MODE_SPI=2, MODE_ADC=3, MODE_TWI=4, MODE_UART=5, MODE_TS=6, MODE_BUS=7, MODE_PWM=8, MODE_CLK=9, MODE_UNKNOWN=-1 }

return_type: enum PinResult { PinSuccess=1, PinErrorModeInvalid=-13 }


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

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

canonical_original_code:
struct Arch *ts8200ArchNextSubArch() {
  return 0;
}


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

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

original_code:
void *ts8200Function(int class,int inst) {
  return 0;
}

canonical_original_code:
void *ts8200Function(int class, int inst) {
  return 0;
}

variable_types: class int

variable_types: inst int


decompiled_code:
__int64 ts8200ArchInit()
{
__int64 result; // rax

result = ts8200_0;
if ( !ts8200_0 )
{
ts8200_0 = (__int64)ts8200Arch;
dioctl_config_add2(
&Xts8200_dioctl_config,
(unsigned int)Xts8200_dioctl_config_len,
(unsigned int)Yts8200_dioctl_config_len);
result = ts8200_0;
}
return result;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 result; // rax

result = ts8200_0;
if ( !ts8200_0 )
{
ts8200_0 = (__int64)ts8200Arch;
dioctl_config_add2(
&Xts8200_dioctl_config,
(unsigned int)Xts8200_dioctl_config_len,
(unsigned int)Yts8200_dioctl_config_len);
result = ts8200_0;
}
return result;
}

original_code:
Arch *ts8200ArchInit() {
  static Arch *ts8200;
  if (ts8200) return ts8200;
  ts8200 = &ts8200Arch;
  dioctl_config_add2(Xts8200_dioctl_config,Xts8200_dioctl_config_len,Yts8200_dioctl_config_len);
  return ts8200;
}

canonical_original_code:
struct Arch *ts8200ArchInit() {
  static struct Arch *ts8200;
  if (ts8200) return ts8200;
  ts8200 = &ts8200Arch;
  dioctl_config_add2(Xts8200_dioctl_config,Xts8200_dioctl_config_len,Yts8200_dioctl_config_len);
  return ts8200;
}

variable_types: struct Arch { struct Arch *(*Init)(); void *(*Function)(int class, int inst); struct Arch *(*NextSubArch)(); void (*NextSubArchSet)(struct Arch *); int (*CANBusId)(int inst); } *


ArrayFree

decompiled_code:
void __fastcall ArrayFree(__int64 a1)
{
free((void *)(a1 - 12));
}

canonical_decompiled_code:
void __fastcall func3(__int64 a1)
{
free((void *)(a1 - 12));
}

original_code:
void ArrayFree(const void *arr) {
  unsigned *ptr = (unsigned *)arr;
  free(ptr-3);
}

canonical_original_code:
void ArrayFree(void *arr) {
  unsigned int *ptr = (unsigned *)arr;
  free(ptr-3);
}

variable_types:
arr
void *

variable_types:
ptr
unsigned int *


ASCIIZ

decompiled_code:
char *__fastcall ASCIIZ(char *src)
{
unsigned int v1; // ebx
char *v2; // rax

v1 = strlen(src);
v2 = (char *)ArrayAlloc(v1, 1u);
return strncpy(v2, src, v1);
}

canonical_decompiled_code:
char *__fastcall func5(char *src)
{
unsigned int v1; // ebx
char *v2; // rax

v1 = strlen(src);
v2 = (char *)ArrayAlloc(v1, 1u);
return strncpy(v2, src, v1);
}

original_code:
char *ASCIIZ(const char *str) {
  unsigned len = strlen(str);
  char *str2 = (char *)ArrayAlloc(len,1);
  strncpy(str2,str,len);
  return str2;
}

canonical_original_code:
char *ASCIIZ(char *str) {
  unsigned int len = strlen(str);
  char *str2 = (char *)ArrayAlloc(len,1);
  strncpy(str2,str,len);
  return str2;
}

variable_types:
str
char *

variable_types:
len
unsigned int


ArraySizeAuto

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

result = a1;
*(_DWORD *)(a1 - 4) = a2;
return result;
}

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

result = a1;
*(_DWORD *)(a1 - 4) = a2;
return result;
}

original_code:
void *ArraySizeAuto(void *arr,unsigned count) {
  unsigned *ptr = (unsigned *)arr;
  ptr -= 3;
  ptr[2] = count;
  return &ptr[3];
}

canonical_original_code:
void *ArraySizeAuto(void *arr, unsigned int count) {
  unsigned int *ptr = (unsigned *)arr;
  ptr -= 3;
  ptr[2] = count;
  return &ptr[3];
}

variable_types:
count
unsigned int


ArrayElementSize

decompiled_code:
__int64 __fastcall ArrayElementSize(__int64 a1)
{
return *(unsigned int *)(a1 - 8);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
return *(unsigned int *)(a1 - 8);
}

original_code:
unsigned ArrayElementSize(const void *array) {
  return _ArrayElementSize(array);
}

canonical_original_code:
unsigned int ArrayElementSize(void *array) {
  return _ArrayElementSize(array);
}

variable_types:
array
void *


ArrayLength

decompiled_code:
__int64 __fastcall ArrayLength(__int64 a1)
{
return *(unsigned int *)(a1 - 4);
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
return *(unsigned int *)(a1 - 4);
}

original_code:
unsigned ArrayLength(const void *array) {
  return _ArrayLength(array);
}

canonical_original_code:
unsigned int ArrayLength(void *array) {
  return _ArrayLength(array);
}


ArrayFreeFree

decompiled_code:
void __fastcall ArrayFreeFree(__int64 a1)
{
__int64 v2; // rbx
__int64 v3; // rdi

if ( *(_DWORD *)(a1 - 4) )
{
v2 = 0LL;
do
{
v3 = *(_QWORD *)(a1 + 8 * v2);
if ( v3 )
ArrayFree(v3);
++v2;
}
while ( *(_DWORD *)(a1 - 4) > (unsigned int)v2 );
}
ArrayFree(a1);
}

original_code:
void ArrayFreeFree(const void *arr0) {
  const void * const *arr = (const void * const *)arr0;
  int i;
  for (i=0;i<_ArrayLength(arr);i++) {
    if (arr[i]) ArrayFree(arr[i]);
  }
  ArrayFree(arr);
}

canonical_original_code:
void ArrayFreeFree(void *arr0) {
  void **arr = (const void * const *)arr0;
  int i;
  for (i=0;i<_ArrayLength(arr);i++) {
    if (arr[i]) ArrayFree(arr[i]);
  }
  ArrayFree(arr);
}

variable_types:
arr
void **

variable_types: i int


ArrayFreeFreeFree

decompiled_code:
void __fastcall ArrayFreeFreeFree(__int64 a1)
{
__int64 v2; // rbp
__int64 v3; // rdi
__int64 v4; // rbx
__int64 v5; // rdi

if ( *(_DWORD *)(a1 - 4) )
{
v2 = 0LL;
do
{
v3 = *(_QWORD *)(a1 + 8 * v2);
if ( v3 )
{
if ( *(_DWORD *)(v3 - 4) )
{
v4 = 0LL;
do
{
v5 = *(_QWORD *)(v3 + 8 * v4);
if ( v5 )
ArrayFree(v5);
v3 = *(_QWORD *)(a1 + 8 * v2);
++v4;
}
while ( *(_DWORD *)(v3 - 4) > (unsigned int)v4 );
}
ArrayFree(v3);
}
++v2;
}
while ( *(_DWORD *)(a1 - 4) > (unsigned int)v2 );
}
ArrayFree(a1);
}

original_code:
void ArrayFreeFreeFree(const void *arr0) {
  const void ** const *arr = (const void ** const *)arr0;
  int i,j;
  for (i=0;i<_ArrayLength(arr);i++) {
    if (arr[i]) {
      for (j=0;j<_ArrayLength(arr[i]);j++) {
 if (arr[i][j]) ArrayFree(arr[i][j]);
      }
      ArrayFree(arr[i]);
    }
  }
  ArrayFree(arr);
}

canonical_original_code:
void ArrayFreeFreeFree(void *arr0) {
  void ***arr = (const void ** const *)arr0;
  int i; int j;
  for (i=0;i<_ArrayLength(arr);i++) {
    if (arr[i]) {
      for (j=0;j<_ArrayLength(arr[i]);j++) {
 if (arr[i][j]) ArrayFree(arr[i][j]);
      }
      ArrayFree(arr[i]);
    }
  }
  ArrayFree(arr);
}

variable_types:
arr
void ***

variable_types: j int


ArrayCompareFunction

decompiled_code:
__int64 ArrayCompareFunction()
{
return ArrayCompareFunction();
}

canonical_decompiled_code:
__int64 func11()
{
return func11();
}

original_code:
void *ArrayCompareFunction(const void *array) {
  return ArrayCompareFunction(array);
}

canonical_original_code:
void *ArrayCompareFunction(void *array) {
  return ArrayCompareFunction(array);
}


ArrayFree

canonical_decompiled_code:
void __fastcall func0(__int64 a1)
{
free((void *)(a1 - 12));
}


ASCIIZ

canonical_decompiled_code:
char *__fastcall func2(char *src)
{
unsigned int v1; // ebx
char *v2; // rax

v1 = strlen(src);
v2 = (char *)ArrayAlloc(v1, 1u);
return strncpy(v2, src, v1);
}


ArraySizeAuto

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

result = a1;
*(_DWORD *)(a1 - 4) = a2;
return result;
}


ArrayElementSize

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
return *(unsigned int *)(a1 - 8);
}


ArrayLength

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
return *(unsigned int *)(a1 - 4);
}


ArrayCompareFunction

canonical_decompiled_code:
__int64 func8()
{
return func8();
}