decompiled_code:
__int64 __fastcall ts4800PinUnlock(__int64 a1, int a2, char a3)
{
__int64 v3; // rdi
__int64 result; // rax

v3 = (unsigned int)(*(_DWORD *)(a1 + 60) + a2);
if ( (a3 & 2) != 0 )
result = ThreadUnlockR(v3);
else
result = ThreadUnlockW(v3);
return result;
}

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

v3 = (unsigned int)(*(_DWORD *)(a1 + 60) + a2);
if ( (a3 & 2) != 0 )
result = ThreadUnlockR(v3);
else
result = ThreadUnlockW(v3);
return result;
}

original_code:
int ts4800PinUnlock(ts4800Pin *ob, unsigned num, int flags) {
  if (flags & SHARED) {
    return ThreadUnlockR(ob->LockBase+num);
  } else {
    return ThreadUnlockW(ob->LockBase+num);
  }
}

canonical_original_code:
int ts4800PinUnlock(struct ts4800Pin *ob, unsigned int num, int flags) {
  if (flags & SHARED) {
    return ThreadUnlockR(ob->LockBase+num);
  } else {
    return ThreadUnlockW(ob->LockBase+num);
  }
}


repo: embeddedarm/libtsctl

decompiled_code:
__int64 tsdio24ArchNextSubArch()
{
return tsdio24Next;
}

canonical_decompiled_code:
__int64 func0()
{
return tsdio24Next;
}

canonical_original_code:
struct Arch *tsdio24ArchNextSubArch() {
  return tsdio24Next;
}

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 tsdio24NextSubArchSet(__int64 a1)
{
tsdio24Next = a1;
}

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

original_code:
void tsdio24NextSubArchSet(Arch *arch) {
  tsdio24Next = arch;
}

canonical_original_code:
void tsdio24NextSubArchSet(struct Arch *arch) {
  tsdio24Next = 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); } *

return_type: void


decompiled_code:
__int64 tsdio24ArchInit()
{
__int64 v0; // r12
__int64 v2; // rbx
__int64 v3; // rbp

v0 = tsdio24_0;
if ( tsdio24_0 )
return v0;
v2 = 0LL;
v3 = BusInit(2LL);
(*(void (__fastcall **)(__int64, _QWORD, __int64))(v3 + 16))(v3, 0LL, 2LL);
do
{
if ( (*(unsigned __int8 (__fastcall **)(__int64, _QWORD))(v3 + 40))(v3, (unsigned int)(8 * v2 + 256)) == 84 )
dio24present[v2] = 1;
++v2;
}
while ( v2 != 4 );
(*(void (__fastcall **)(__int64, _QWORD, __int64))(v3 + 24))(v3, 0LL, 2LL);
if ( !dio24present[0] )
return v0;
tsdio24_0 = (__int64)tsdio24Arch;
dioctl_config_add2(
&Xtsdio24_dioctl_config,
(unsigned int)Xtsdio24_dioctl_config_len,
(unsigned int)Ytsdio24_dioctl_config_len);
return tsdio24_0;
}

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

v0 = tsdio24_0;
if ( tsdio24_0 )
return v0;
v2 = 0LL;
v3 = BusInit(2LL);
(*(void (__fastcall **)(__int64, _QWORD, __int64))(v3 + 16))(v3, 0LL, 2LL);
do
{
if ( (*(unsigned __int8 (__fastcall **)(__int64, _QWORD))(v3 + 40))(v3, (unsigned int)(8 * v2 + 256)) == 84 )
dio24present[v2] = 1;
++v2;
}
while ( v2 != 4 );
(*(void (__fastcall **)(__int64, _QWORD, __int64))(v3 + 24))(v3, 0LL, 2LL);
if ( !dio24present[0] )
return v0;
tsdio24_0 = (__int64)tsdio24Arch;
dioctl_config_add2(
&Xtsdio24_dioctl_config,
(unsigned int)Xtsdio24_dioctl_config_len,
(unsigned int)Ytsdio24_dioctl_config_len);
return tsdio24_0;
}

original_code:
Arch *tsdio24ArchInit(int model) {
  static Arch *tsdio24;
  Bus *pc104;
  int i,val;
  if (tsdio24) return tsdio24;
  pc104 = BusInit(2);
  pc104->Lock(pc104,0,SHARED);
  for (i=0;i<4;i++) {
    val = pc104->Peek8(pc104,0x100+8*i);
    if (val == 0x54) dio24present[i] = 1;
  }
  pc104->Unlock(pc104,0,SHARED);
  if (dio24present[0] == 0 && dio24present[0] == 0 && dio24present[0] == 0 && dio24present[0] == 0) {
    return 0;
  }
  tsdio24 = &tsdio24Arch;
  dioctl_config_add2(Xtsdio24_dioctl_config,Xtsdio24_dioctl_config_len,Ytsdio24_dioctl_config_len);
  return tsdio24;
}

canonical_original_code:
struct Arch *tsdio24ArchInit(int model) {
  static struct Arch *tsdio24;
  struct Bus *pc104;
  int i; int val;
  if (tsdio24) return tsdio24;
  pc104 = BusInit(2);
  pc104->Lock(pc104,0,SHARED);
  for (i=0;i<4;i++) {
    val = pc104->Peek8(pc104,0x100+8*i);
    if (val == 0x54) dio24present[i] = 1;
  }
  pc104->Unlock(pc104,0,SHARED);
  if (dio24present[0] == 0 && dio24present[0] == 0 && dio24present[0] == 0 && dio24present[0] == 0) {
    return 0;
  }
  tsdio24 = &tsdio24Arch;
  dioctl_config_add2(Xtsdio24_dioctl_config,Xtsdio24_dioctl_config_len,Ytsdio24_dioctl_config_len);
  return tsdio24;
}

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: i int

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 tsdio24__BusInit0()
{
__int64 v0; // rax

*((_QWORD *)&tsDIO24DIOCacheBus_IBit + 1) = 0xFF000000FFLL;
*(&tsDIO24DIOCacheBus_OBit + 1) = 0xFF000000FFLL;
*((_DWORD *)&tsDIO24DIOCacheBus_IBit + 1) = 255;
tsDIO24DIOCacheBus_OBit = 0xFF00000003LL;
*((_QWORD *)&tsDIO24DIOCacheBus + 39) = 0x800000004LL;
*((_DWORD *)&tsDIO24DIOCacheBus + 80) = 4;
*((_QWORD *)&tsDIO24DIOCacheBus + 44) = &tsDIO24DIOCacheBus_WO;
*((_QWORD *)&tsDIO24DIOCacheBus + 45) = &tsDIO24DIOCacheBus_IBit;
*((_QWORD *)&tsDIO24DIOCacheBus + 46) = &tsDIO24DIOCacheBus_OBit;
*((_QWORD *)&tsDIO24DIOCacheBus + 41) = &tsDIO24DIOCacheBus_icache;
*((_QWORD *)&tsDIO24DIOCacheBus + 42) = &tsDIO24DIOCacheBus_ocache;
*((_QWORD *)&tsDIO24DIOCacheBus + 43) = &tsDIO24DIOCacheBus_ocache0;
v0 = BusInit(2LL);
return CacheBusInit(&tsDIO24DIOCacheBus, v0);
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v0; // rax

*((_QWORD *)&tsDIO24DIOCacheBus_IBit + 1) = 0xFF000000FFLL;
*(&tsDIO24DIOCacheBus_OBit + 1) = 0xFF000000FFLL;
*((_DWORD *)&tsDIO24DIOCacheBus_IBit + 1) = 255;
tsDIO24DIOCacheBus_OBit = 0xFF00000003LL;
*((_QWORD *)&tsDIO24DIOCacheBus + 39) = 0x800000004LL;
*((_DWORD *)&tsDIO24DIOCacheBus + 80) = 4;
*((_QWORD *)&tsDIO24DIOCacheBus + 44) = &tsDIO24DIOCacheBus_WO;
*((_QWORD *)&tsDIO24DIOCacheBus + 45) = &tsDIO24DIOCacheBus_IBit;
*((_QWORD *)&tsDIO24DIOCacheBus + 46) = &tsDIO24DIOCacheBus_OBit;
*((_QWORD *)&tsDIO24DIOCacheBus + 41) = &tsDIO24DIOCacheBus_icache;
*((_QWORD *)&tsDIO24DIOCacheBus + 42) = &tsDIO24DIOCacheBus_ocache;
*((_QWORD *)&tsDIO24DIOCacheBus + 43) = &tsDIO24DIOCacheBus_ocache0;
v0 = BusInit(2LL);
return CacheBusInit(&tsDIO24DIOCacheBus, v0);
}

original_code:
Bus *tsdio24__BusInit0(Bus *bus,int inst) {
  tsDIO24DIOCacheBus_IBit[1] = 0xFF;
  tsDIO24DIOCacheBus_IBit[2] = 0xFF;
  tsDIO24DIOCacheBus_IBit[3] = 0xFF;
  tsDIO24DIOCacheBus_OBit[0] = 3;
  tsDIO24DIOCacheBus_OBit[1] = 0xFF;
  tsDIO24DIOCacheBus_OBit[2] = 0xFF;
  tsDIO24DIOCacheBus_OBit[3] = 0xFF;
  tsDIO24DIOCacheBus.Length = 4;
  tsDIO24DIOCacheBus.Width = 8;
  tsDIO24DIOCacheBus.Offset = 4;
  tsDIO24DIOCacheBus.WO = tsDIO24DIOCacheBus_WO;
  tsDIO24DIOCacheBus.IBit = tsDIO24DIOCacheBus_IBit;
  tsDIO24DIOCacheBus.OBit = tsDIO24DIOCacheBus_OBit;
  tsDIO24DIOCacheBus.icache = tsDIO24DIOCacheBus_icache;
  tsDIO24DIOCacheBus.ocache = tsDIO24DIOCacheBus_ocache;
  tsDIO24DIOCacheBus.ocache0 = tsDIO24DIOCacheBus_ocache0;
  return CacheBusInit(&tsDIO24DIOCacheBus,BusInit(2));
}

canonical_original_code:
struct Bus *tsdio24__BusInit0(struct Bus *bus, int inst) {
  tsDIO24DIOCacheBus_IBit[1] = 0xFF;
  tsDIO24DIOCacheBus_IBit[2] = 0xFF;
  tsDIO24DIOCacheBus_IBit[3] = 0xFF;
  tsDIO24DIOCacheBus_OBit[0] = 3;
  tsDIO24DIOCacheBus_OBit[1] = 0xFF;
  tsDIO24DIOCacheBus_OBit[2] = 0xFF;
  tsDIO24DIOCacheBus_OBit[3] = 0xFF;
  tsDIO24DIOCacheBus.Length = 4;
  tsDIO24DIOCacheBus.Width = 8;
  tsDIO24DIOCacheBus.Offset = 4;
  tsDIO24DIOCacheBus.WO = tsDIO24DIOCacheBus_WO;
  tsDIO24DIOCacheBus.IBit = tsDIO24DIOCacheBus_IBit;
  tsDIO24DIOCacheBus.OBit = tsDIO24DIOCacheBus_OBit;
  tsDIO24DIOCacheBus.icache = tsDIO24DIOCacheBus_icache;
  tsDIO24DIOCacheBus.ocache = tsDIO24DIOCacheBus_ocache;
  tsDIO24DIOCacheBus.ocache0 = tsDIO24DIOCacheBus_ocache0;
  return CacheBusInit(&tsDIO24DIOCacheBus,BusInit(2));
}

variable_types:
bus
struct Bus *

variable_types: inst int

return_type: 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 tsdio24__DIORawInit1(__int64 a1, unsigned int a2)
{
__int64 v2; // rax

if ( !dio24present[1] )
return tsdio24__DIORawInit0(a1, a2);
v2 = tsdio24__BusInit0(0LL, 0LL);
return tsDIO24DIORawInit((char *)&dio24 + 112 * (int)a2, v2, 8 * a2 + 256);
}

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

if ( !dio24present[1] )
return func7(a1, a2);
v2 = func3(0LL, 0LL);
return tsDIO24DIORawInit((char *)&dio24 + 112 * (int)a2, v2, 8 * a2 + 256);
}

original_code:
DIORaw *tsdio24__DIORawInit1(DIORaw *dioraw0,int inst) {
  if (!dio24present[1]) {
    return tsdio24__DIORawInit0(dioraw0,inst);
  }
  return tsDIO24DIORawInit(&dio24[inst],tsdio24__BusInit0(0,0),0x100+inst*8);
}

canonical_original_code:
struct DIORaw *tsdio24__DIORawInit1(struct DIORaw *dioraw0, int inst) {
  if (!dio24present[1]) {
    return tsdio24__DIORawInit0(dioraw0,inst);
  }
  return tsDIO24DIORawInit(&dio24[inst],tsdio24__BusInit0(0,0),0x100+inst*8);
}

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 tsdio24__DIORawInit2(__int64 a1, unsigned int a2)
{
__int64 v2; // rax

if ( !dio24present[2] )
return tsdio24__DIORawInit1(a1, a2);
v2 = tsdio24__BusInit0(0LL, 0LL);
return tsDIO24DIORawInit((char *)&dio24 + 112 * (int)a2, v2, 8 * a2 + 256);
}

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

if ( !dio24present[2] )
return func4(a1, a2);
v2 = func3(0LL, 0LL);
return tsDIO24DIORawInit((char *)&dio24 + 112 * (int)a2, v2, 8 * a2 + 256);
}

original_code:
DIORaw *tsdio24__DIORawInit2(DIORaw *dioraw0,int inst) {
  if (!dio24present[2]) {
    return tsdio24__DIORawInit1(dioraw0,inst);
  }
  return tsDIO24DIORawInit(&dio24[inst],tsdio24__BusInit0(0,0),0x100+inst*8);
}

canonical_original_code:
struct DIORaw *tsdio24__DIORawInit2(struct DIORaw *dioraw0, int inst) {
  if (!dio24present[2]) {
    return tsdio24__DIORawInit1(dioraw0,inst);
  }
  return tsDIO24DIORawInit(&dio24[inst],tsdio24__BusInit0(0,0),0x100+inst*8);
}

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 tsdio24__DIORawInit3(__int64 a1, unsigned int a2)
{
__int64 v2; // rax

if ( !dio24present[3] )
return tsdio24__DIORawInit2(a1, a2);
v2 = tsdio24__BusInit0(0LL, 0LL);
return tsDIO24DIORawInit((char *)&dio24 + 112 * (int)a2, v2, 8 * a2 + 256);
}

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

if ( !dio24present[3] )
return func5(a1, a2);
v2 = func3(0LL, 0LL);
return tsDIO24DIORawInit((char *)&dio24 + 112 * (int)a2, v2, 8 * a2 + 256);
}

original_code:
DIORaw *tsdio24__DIORawInit3(DIORaw *dioraw0,int inst) {
  if (!dio24present[3]) {
    return tsdio24__DIORawInit2(dioraw0,inst);
  }
  return tsDIO24DIORawInit(&dio24[inst],tsdio24__BusInit0(0,0),0x100+inst*8);
}

canonical_original_code:
struct DIORaw *tsdio24__DIORawInit3(struct DIORaw *dioraw0, int inst) {
  if (!dio24present[3]) {
    return tsdio24__DIORawInit2(dioraw0,inst);
  }
  return tsDIO24DIORawInit(&dio24[inst],tsdio24__BusInit0(0,0),0x100+inst*8);
}


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

if ( !dio24present[0] )
return tsdio24__DIORawInit3(a1, a2);
v2 = tsdio24__BusInit0(0LL, 0LL);
return tsDIO24DIORawInit((char *)&dio24 + 112 * (int)a2, v2, 8 * a2 + 256);
}

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

if ( !dio24present[0] )
return func6(a1, a2);
v2 = func3(0LL, 0LL);
return tsDIO24DIORawInit((char *)&dio24 + 112 * (int)a2, v2, 8 * a2 + 256);
}

original_code:
DIORaw *tsdio24__DIORawInit0(DIORaw *dioraw0,int inst) {
  if (!dio24present[0]) {
    return tsdio24__DIORawInit3(dioraw0,inst);
  }
  return tsDIO24DIORawInit(&dio24[inst],tsdio24__BusInit0(0,0),0x100+inst*8);
}

canonical_original_code:
struct DIORaw *tsdio24__DIORawInit0(struct DIORaw *dioraw0, int inst) {
  if (!dio24present[0]) {
    return tsdio24__DIORawInit3(dioraw0,inst);
  }
  return tsDIO24DIORawInit(&dio24[inst],tsdio24__BusInit0(0,0),0x100+inst*8);
}


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

v2 = tsdio24__DIORawInit0(0LL, a2);
if ( a2 > 3 || !dio24present[a2] )
return DummyDIOInit((char *)&r8dummyDIO + 128 * (__int64)(int)a2, 8LL);
v3 = v2;
DIO24DIOCapabilities = 0x404040406060606LL;
*(__m128i *)(&DIO24DIOCapabilities + 1) = _mm_load_si128((const __m128i *)&LC0);
pdio24[21 * (int)a2 + 19] = &DIO24DIOCapabilities;
v4 = tsdio24__BusInit0(0LL, 0LL);
return PhysicalDIOInit(&pdio24[21 * (int)a2], v4, v3);
}

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

v2 = func7(0LL, a2);
if ( a2 > 3 || !dio24present[a2] )
return DummyDIOInit((char *)&r8dummyDIO + 128 * (__int64)(int)a2, 8LL);
v3 = v2;
DIO24DIOCapabilities = 0x404040406060606LL;
*(__m128i *)(&DIO24DIOCapabilities + 1) = _mm_load_si128((const __m128i *)&LC0);
pdio24[21 * (int)a2 + 19] = &DIO24DIOCapabilities;
v4 = func3(0LL, 0LL);
return PhysicalDIOInit(&pdio24[21 * (int)a2], v4, v3);
}

original_code:
DIO *tsdio24__DIOInit0(DIO *dio,int inst) {
  int i;
  DIORaw *dioraw = tsdio24__DIORawInit0(0,inst);
  if (inst >= 0 && inst <= 3 && dio24present[inst]) {
    for (i=0;i<4;i++) {
      DIO24DIOCapabilities[i] = DIO_OUTPUT_ONLY;
    }
    for (i=4;i<8;i++) {
      DIO24DIOCapabilities[i] = DIO_CAN_DRIVE_LOW;
    }
    for (i=8;i<24;i++) {
      DIO24DIOCapabilities[i] = DIO_NORMAL;
    }
    pdio24[inst].Caps = DIO24DIOCapabilities;
    return PhysicalDIOInit(&pdio24[inst],tsdio24__BusInit0(0,0),dioraw);
  } else {
    return DummyDIOInit(&r8dummyDIO[inst],8);
  }
}

canonical_original_code:
struct DIO *tsdio24__DIOInit0(struct DIO *dio, int inst) {
  int i;
  struct DIORaw *dioraw = tsdio24__DIORawInit0(0,inst);
  if (inst >= 0 && inst <= 3 && dio24present[inst]) {
    for (i=0;i<4;i++) {
      DIO24DIOCapabilities[i] = DIO_OUTPUT_ONLY;
    }
    for (i=4;i<8;i++) {
      DIO24DIOCapabilities[i] = DIO_CAN_DRIVE_LOW;
    }
    for (i=8;i<24;i++) {
      DIO24DIOCapabilities[i] = DIO_NORMAL;
    }
    pdio24[inst].Caps = DIO24DIOCapabilities;
    return PhysicalDIOInit(&pdio24[inst],tsdio24__BusInit0(0,0),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:
// attributes: thunk
__int64 __fastcall tsdio24__DIOInit1(__int64 a1, unsigned int a2)
{
return tsdio24__DIOInit0(a1, a2);
}

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

original_code:
DIO *tsdio24__DIOInit1(DIO *dio,int inst) {
  return tsdio24__DIOInit0(dio,inst);
}

canonical_original_code:
struct DIO *tsdio24__DIOInit1(struct DIO *dio, int inst) {
  return tsdio24__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:
// attributes: thunk
__int64 __fastcall tsdio24__DIOInit2(__int64 a1, unsigned int a2)
{
return tsdio24__DIOInit1(a1, a2);
}

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

original_code:
DIO *tsdio24__DIOInit2(DIO *dio,int inst) {
  return tsdio24__DIOInit0(dio,inst);
}

canonical_original_code:
struct DIO *tsdio24__DIOInit2(struct DIO *dio, int inst) {
  return tsdio24__DIOInit0(dio,inst);
}


decompiled_code:
// attributes: thunk
__int64 __fastcall tsdio24__DIOInit3(__int64 a1, unsigned int a2)
{
return tsdio24__DIOInit1(a1, a2);
}

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

original_code:
DIO *tsdio24__DIOInit3(DIO *dio,int inst) {
  return tsdio24__DIOInit0(dio,inst);
}

canonical_original_code:
struct DIO *tsdio24__DIOInit3(struct DIO *dio, int inst) {
  return tsdio24__DIOInit0(dio,inst);
}


ArrayFree

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

canonical_decompiled_code:
void __fastcall func12(__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

return_type: char *


ArraySizeAuto

decompiled_code:
__int64 __fastcall ArraySizeAuto(__int64 a1, int a2)
{
*(_DWORD *)(a1 - 4) = a2;
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1, int a2)
{
*(_DWORD *)(a1 - 4) = a2;
return a1;
}

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

return_type: void *


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 *

return_type: unsigned int


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


ArrayFreeFreeFree

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

if ( *(_DWORD *)(a1 - 4) )
{
v2 = 0LL;
do
{
while ( 1 )
{
v3 = *(_QWORD *)(a1 + 8 * v2);
if ( v3 )
break;
if ( *(_DWORD *)(a1 - 4) <= (unsigned int)++v2 )
goto LABEL_11;
}
if ( *(_DWORD *)(v3 - 4) )
{
v4 = 0LL;
do
{
if ( *(_QWORD *)(v3 + 8 * v4) )
{
ArrayFree(*(_QWORD *)(v3 + 8 * v4));
v3 = *(_QWORD *)(a1 + 8 * v2);
}
++v4;
}
while ( *(_DWORD *)(v3 - 4) > (unsigned int)v4 );
}
ArrayFree(v3);
++v2;
}
while ( *(_DWORD *)(a1 - 4) > (unsigned int)v2 );
}
LABEL_11:
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:
// attributes: thunk
void __noreturn ArrayCompareFunction()
{
while ( 1 )
;
}

canonical_decompiled_code:
void __noreturn func19()
{
while ( 1 )
;
}

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

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


SystemTimeFini

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

result = *(unsigned int *)(a1 + 72);
if ( (int)result > 0 )
*(_DWORD *)(a1 + 72) = 0;
return result;
}

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

result = *(unsigned int *)(a1 + 72);
if ( (int)result > 0 )
*(_DWORD *)(a1 + 72) = 0;
return result;
}

original_code:
void SystemTimeFini(SystemTime *me) {
  if (me->InitStatus > 0) me->InitStatus = 0;
}

canonical_original_code:
void SystemTimeFini(struct SystemTime *me) {
  if (me->InitStatus > 0) me->InitStatus = 0;
}

variable_types: struct SystemTime { void *(*Init)(struct SystemTime *me, ...); void (*Fini)(struct SystemTime *me); unsigned int (*Wait)(struct SystemTime *me, unsigned int microseconds); void (*Delay)(struct SystemTime *me, unsigned int microseconds); unsigned int (*Tick)(struct SystemTime *me); unsigned int (*usElapsed)(struct SystemTime *me, unsigned int start); unsigned int (*usFuture)(struct SystemTime *me, unsigned int start, unsigned int microseconds); enum TimeResult { TimeoutOccurred=1, TimeoutDidNotOccur=0 } (*TimeoutQ)(struct SystemTime *me, unsigned int start, unsigned int end); unsigned int (*TPS)(struct SystemTime *me); int InitStatus; } *

user_defined_types: struct SystemTime { void *(*Init)(struct SystemTime *me, ...); void (*Fini)(struct SystemTime *me); unsigned int (*Wait)(struct SystemTime *me, unsigned int microseconds); void (*Delay)(struct SystemTime *me, unsigned int microseconds); unsigned int (*Tick)(struct SystemTime *me); unsigned int (*usElapsed)(struct SystemTime *me, unsigned int start); unsigned int (*usFuture)(struct SystemTime *me, unsigned int start, unsigned int microseconds); enum TimeResult (*TimeoutQ)(struct SystemTime *me, unsigned int start, unsigned int end); unsigned int (*TPS)(struct SystemTime *me); int InitStatus; }


SystemTimeusFuture

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

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

original_code:
unsigned SystemTimeusFuture(SystemTime *time,unsigned start,unsigned us) {
  return start + us;
}

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

variable_types:
start
unsigned int

variable_types:
us
unsigned int

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


SystemTimeTPS

decompiled_code:
__int64 SystemTimeTPS()
{
return 1000000LL;
}

original_code:
unsigned SystemTimeTPS(SystemTime *me) {
  return 1000000;
}

canonical_original_code:
unsigned int SystemTimeTPS(struct SystemTime *me) {
  return 1000000;
}


SystemTimeTick

decompiled_code:
__int64 SystemTimeTick()
{
struct timeval v1; // [rsp+0h] [rbp-18h] BYREF

gettimeofday(&v1, 0LL);
return (unsigned int)(LODWORD(v1.tv_usec) + 1000000 * LODWORD(v1.tv_sec));
}

canonical_decompiled_code:
__int64 func4()
{
struct timeval v1; // [rsp+0h] [rbp-18h] BYREF

gettimeofday(&v1, 0LL);
return (unsigned int)(LODWORD(v1.tv_usec) + 1000000 * LODWORD(v1.tv_sec));
}

original_code:
unsigned SystemTimeTick(SystemTime *me) {
  struct timeval tv;
  gettimeofday(&tv,0);
  return (unsigned)((unsigned long long)tv.tv_sec * 1000000 + tv.tv_usec);
}

canonical_original_code:
unsigned int SystemTimeTick(struct SystemTime *me) {
  struct timeval tv;
  gettimeofday(&tv,0);
  return (unsigned int)((unsigned long long)tv.tv_sec * 1000000 + tv.tv_usec);
}

variable_types: struct timeval { long tv_sec; long tv_usec; }


SystemTimeusElapsed

decompiled_code:
__int64 __fastcall SystemTimeusElapsed(__int64 a1, int a2)
{
return (unsigned int)SystemTimeTick() - a2;
}

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

original_code:
unsigned SystemTimeusElapsed(SystemTime *time,unsigned start) {
  unsigned ret,now = SystemTimeTick(time);
  if (now < start) {
    ret = ((unsigned)(-start)+now);
    if (ret > 1000000000) {
    }
    return ret;
  } else {
    return now - start;
  }
}

canonical_original_code:
unsigned int SystemTimeusElapsed(struct SystemTime *time, unsigned int start) {
  unsigned int ret; unsigned int now = SystemTimeTick(time);
  if (now < start) {
    ret = ((unsigned int)(-start)+now);
    if (ret > 1000000000) {
    }
    return ret;
  } else {
    return now - start;
  }
}

variable_types:
ret
unsigned int

variable_types:
now
unsigned int


SystemTimeTimeoutQ

decompiled_code:
__int64 __fastcall SystemTimeTimeoutQ(__int64 a1, unsigned int a2, unsigned int a3)
{
unsigned int v4; // eax
unsigned int v5; // edx
__int64 result; // rax

v4 = SystemTimeTick();
v5 = v4;
if ( a3 > a2 )
return (v4 < a2) | (unsigned __int8)(v4 >= a3);
result = 1LL;
if ( a3 != a2 )
result = (v5 < a2) & (unsigned __int8)(v5 >= a3);
return result;
}

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

v4 = func4();
v5 = v4;
if ( a3 > a2 )
return (v4 < a2) | (unsigned __int8)(v4 >= a3);
result = 1LL;
if ( a3 != a2 )
result = (v5 < a2) & (unsigned __int8)(v5 >= a3);
return result;
}

original_code:
TimeResult SystemTimeTimeoutQ(SystemTime *time,unsigned start,unsigned end) {
  unsigned now = SystemTimeTick(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 SystemTimeTimeoutQ(struct SystemTime *time, unsigned int start, unsigned int end) {
  unsigned int now = SystemTimeTick(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 }


SystemTimeWait

decompiled_code:
// attributes: thunk
__int64 __fastcall SystemTimeWait(__int64 a1, unsigned int a2)
{
return SystemMicroSecondWait(a1, a2);
}

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

original_code:
unsigned SystemTimeWait(SystemTime *me,unsigned microseconds) {
  return SystemMicroSecondWait(me,microseconds);
}

canonical_original_code:
unsigned int SystemTimeWait(struct SystemTime *me, unsigned int microseconds) {
  return SystemMicroSecondWait(me,microseconds);
}

variable_types:
microseconds
unsigned int


SystemTimeDelay

decompiled_code:
// attributes: thunk
__int64 __fastcall SystemTimeDelay(__int64 a1, unsigned int a2)
{
return SystemMicroSecondWait(a1, a2);
}

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

original_code:
void SystemTimeDelay(SystemTime *me,unsigned microseconds) {
  SystemMicroSecondWait(me,microseconds);
}

canonical_original_code:
void SystemTimeDelay(struct SystemTime *me, unsigned int microseconds) {
  SystemMicroSecondWait(me,microseconds);
}


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

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

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

variable_types: struct tsDIO24DIORaw { void *(*Init)(struct tsDIO24DIORaw *me, void *bus, int adrs); void (*Fini)(struct tsDIO24DIORaw *me); int (*Lock)(struct tsDIO24DIORaw *me, unsigned int num, int flags); int (*Unlock)(struct tsDIO24DIORaw *me, unsigned int num, int flags); int (*Preempt)(struct tsDIO24DIORaw *me); void (*DirSet)(struct tsDIO24DIORaw *me, int num, int asOutput); void (*DataSet)(struct tsDIO24DIORaw *me, int num, int asHigh); int (*DirGet)(struct tsDIO24DIORaw *me, int num); int (*DataGet)(struct tsDIO24DIORaw *me, int num); unsigned int (*Count)(struct tsDIO24DIORaw *me); int InitStatus; int deferlockW; int deferlockR; 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; int adrs; } *

variable_types:
num
unsigned int

variable_types: flags int

return_type: int

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


decompiled_code:
__int64 __fastcall tsDIO24DIORawUnlock(__int64 a1, __int64 a2, char a3)
{
int v3; // eax
__int64 result; // rax
int v5; // eax

if ( (a3 & 2) != 0 )
{
v3 = *(_DWORD *)(a1 + 88);
if ( !v3 )
{
LABEL_3:
(*(void (__fastcall **)(_QWORD))(*(_QWORD *)(a1 + 96) + 24LL))(*(_QWORD *)(a1 + 96));
return 1LL;
}
*(_DWORD *)(a1 + 88) = v3 - 1;
result = 1LL;
}
else
{
v5 = *(_DWORD *)(a1 + 84);
if ( !v5 )
goto LABEL_3;
*(_DWORD *)(a1 + 84) = v5 - 1;
result = 1LL;
}
return result;
}

original_code:
int tsDIO24DIORawUnlock(tsDIO24DIORaw *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 tsDIO24DIORawUnlock(struct tsDIO24DIORaw *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 tsDIO24DIORawPreempt()
{
return 0xFFFFFFFFLL;
}

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

original_code:
int tsDIO24DIORawPreempt(tsDIO24DIORaw *ob) {
  return -1;
}

canonical_original_code:
int tsDIO24DIORawPreempt(struct tsDIO24DIORaw *ob) {
  return -1;
}


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

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

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

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

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

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


original_code:
void tsDIO24DIORawDirSet(tsDIO24DIORaw *dio,int Num,int asOutput) {
  if (( Num<0 ? ~(Num) : (Num)) > 23) return;
  tsDIO24DIORawLockReal(dio,0);
  if (( Num<0 ? ~(Num) : (Num)) < 8) {
    if (!asOutput) {
      dio->sub->BitAssign8(dio->sub,dio->adrs+5,( Num<0 ? ~(Num) : (Num)),1);
    }
  } else if (( Num<0 ? ~(Num) : (Num)) < 16) {
    dio->sub->BitAssign8(dio->sub,dio->adrs+4,1,asOutput);
  } else {
    dio->sub->BitAssign8(dio->sub,dio->adrs+4,0,asOutput);
  }
}

canonical_original_code:
void tsDIO24DIORawDirSet(struct tsDIO24DIORaw *dio, int Num, int asOutput) {
  if (( Num<0 ? ~(Num) : (Num)) > 23) return;
  tsDIO24DIORawLockReal(dio,0);
  if (( Num<0 ? ~(Num) : (Num)) < 8) {
    if (!asOutput) {
      dio->sub->BitAssign8(dio->sub,dio->adrs+5,( Num<0 ? ~(Num) : (Num)),1);
    }
  } else if (( Num<0 ? ~(Num) : (Num)) < 16) {
    dio->sub->BitAssign8(dio->sub,dio->adrs+4,1,asOutput);
  } else {
    dio->sub->BitAssign8(dio->sub,dio->adrs+4,0,asOutput);
  }
}

variable_types: Num int

variable_types: asOutput int


original_code:
void tsDIO24DIORawDataSet(tsDIO24DIORaw *dio,int Num,int asHigh) {
  if (( Num<0 ? ~(Num) : (Num)) > 23) return;
  tsDIO24DIORawLockReal(dio,0);
  if (( Num<0 ? ~(Num) : (Num)) < 8) {
    dio->sub->BitAssign8(dio->sub,dio->adrs+5,( Num<0 ? ~(Num) : (Num)),asHigh);
  } else if (( Num<0 ? ~(Num) : (Num)) < 16) {
    dio->sub->BitAssign8(dio->sub,dio->adrs+6,( Num<0 ? ~(Num) : (Num))-8,asHigh);
  } else {
    dio->sub->BitAssign8(dio->sub,dio->adrs+7,( Num<0 ? ~(Num) : (Num))-16,asHigh);
  }
}

canonical_original_code:
void tsDIO24DIORawDataSet(struct tsDIO24DIORaw *dio, int Num, int asHigh) {
  if (( Num<0 ? ~(Num) : (Num)) > 23) return;
  tsDIO24DIORawLockReal(dio,0);
  if (( Num<0 ? ~(Num) : (Num)) < 8) {
    dio->sub->BitAssign8(dio->sub,dio->adrs+5,( Num<0 ? ~(Num) : (Num)),asHigh);
  } else if (( Num<0 ? ~(Num) : (Num)) < 16) {
    dio->sub->BitAssign8(dio->sub,dio->adrs+6,( Num<0 ? ~(Num) : (Num))-8,asHigh);
  } else {
    dio->sub->BitAssign8(dio->sub,dio->adrs+7,( Num<0 ? ~(Num) : (Num))-16,asHigh);
  }
}

variable_types: asHigh int


original_code:
int tsDIO24DIORawDirGet(tsDIO24DIORaw *dio,int Num) {
  if (( Num<0 ? ~(Num) : (Num)) > 3 && ( Num<0 ? ~(Num) : (Num)) < 8) return 1;
  if (( Num<0 ? ~(Num) : (Num)) > 23) return 0;
  tsDIO24DIORawLockReal(dio,SHARED);
  if (( Num<0 ? ~(Num) : (Num)) < 8) {
    return dio->sub->BitGet8(dio->sub,dio->adrs+5,( Num<0 ? ~(Num) : (Num)));
  } else if (( Num<0 ? ~(Num) : (Num)) < 16) {
    return dio->sub->BitGet8(dio->sub,dio->adrs+4,1);
  } else {
    return dio->sub->BitGet8(dio->sub,dio->adrs+4,0);
  }
}

canonical_original_code:
int tsDIO24DIORawDirGet(struct tsDIO24DIORaw *dio, int Num) {
  if (( Num<0 ? ~(Num) : (Num)) > 3 && ( Num<0 ? ~(Num) : (Num)) < 8) return 1;
  if (( Num<0 ? ~(Num) : (Num)) > 23) return 0;
  tsDIO24DIORawLockReal(dio,SHARED);
  if (( Num<0 ? ~(Num) : (Num)) < 8) {
    return dio->sub->BitGet8(dio->sub,dio->adrs+5,( Num<0 ? ~(Num) : (Num)));
  } else if (( Num<0 ? ~(Num) : (Num)) < 16) {
    return dio->sub->BitGet8(dio->sub,dio->adrs+4,1);
  } else {
    return dio->sub->BitGet8(dio->sub,dio->adrs+4,0);
  }
}


original_code:
int tsDIO24DIORawDataGet(tsDIO24DIORaw *dio,int Num) {
  if (( Num<0 ? ~(Num) : (Num)) > 23) return;
  tsDIO24DIORawLockReal(dio,SHARED);
  if (( Num<0 ? ~(Num) : (Num)) < 8) {
    return dio->sub->BitGet8(dio->sub,dio->adrs+5,( Num<0 ? ~(Num) : (Num)));
  } else if (( Num<0 ? ~(Num) : (Num)) < 16) {
    return dio->sub->BitGet8(dio->sub,dio->adrs+6,( Num<0 ? ~(Num) : (Num))-8);
  } else {
    return dio->sub->BitGet8(dio->sub,dio->adrs+7,( Num<0 ? ~(Num) : (Num))-16);
  }
}

canonical_original_code:
int tsDIO24DIORawDataGet(struct tsDIO24DIORaw *dio, int Num) {
  if (( Num<0 ? ~(Num) : (Num)) > 23) return;
  tsDIO24DIORawLockReal(dio,SHARED);
  if (( Num<0 ? ~(Num) : (Num)) < 8) {
    return dio->sub->BitGet8(dio->sub,dio->adrs+5,( Num<0 ? ~(Num) : (Num)));
  } else if (( Num<0 ? ~(Num) : (Num)) < 16) {
    return dio->sub->BitGet8(dio->sub,dio->adrs+6,( Num<0 ? ~(Num) : (Num))-8);
  } else {
    return dio->sub->BitGet8(dio->sub,dio->adrs+7,( Num<0 ? ~(Num) : (Num))-16);
  }
}


decompiled_code:
__int64 tsDIO24DIORawCount()
{
return 24LL;
}

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

original_code:
unsigned tsDIO24DIORawCount(tsDIO24DIORaw *dio) {
  return 24;
}

canonical_original_code:
unsigned int tsDIO24DIORawCount(struct tsDIO24DIORaw *dio) {
  return 24;
}


original_code:
__attribute__((always_inline))
int tsDIO24DIORawLockReal(tsDIO24DIORaw *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 tsDIO24DIORawLockReal(struct tsDIO24DIORaw *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--;
    }
  }
}


DummyBusFini

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

result = *(unsigned int *)(a1 + 288);
if ( (int)result > 0 )
*(_DWORD *)(a1 + 288) = 0;
return result;
}

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

result = *(unsigned int *)(a1 + 288);
if ( (int)result > 0 )
*(_DWORD *)(a1 + 288) = 0;
return result;
}

original_code:
void DummyBusFini(DummyBus *bus) {
  if (bus->InitStatus > 0) bus->InitStatus = 0;
}

canonical_original_code:
void DummyBusFini(struct DummyBus *bus) {
  if (bus->InitStatus > 0) bus->InitStatus = 0;
}

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


DummyBusLock

decompiled_code:
__int64 DummyBusLock()
{
return 1LL;
}

canonical_decompiled_code:
__int64 func2()
{
return 1LL;
}

original_code:
int DummyBusLock(DummyBus *me,unsigned num,int flags) {
  return 1;
}

canonical_original_code:
int DummyBusLock(struct DummyBus *me, unsigned int num, int flags) {
  return 1;
}

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


DummyBusPreempt

decompiled_code:
__int64 DummyBusPreempt()
{
return 1LL;
}

canonical_decompiled_code:
__int64 func3()
{
return 1LL;
}

original_code:
int DummyBusPreempt(DummyBus *me) {
  return 1;
}

canonical_original_code:
int DummyBusPreempt(struct DummyBus *me) {
  return 1;
}


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

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

original_code:
unsigned char DummyBusPeek8(DummyBus *me,int adrs) {
  return 0;
}

canonical_original_code:
unsigned char DummyBusPeek8(struct DummyBus *me, int adrs) {
  return 0;
}

variable_types: adrs int

return_type: unsigned char


decompiled_code:
void DummyBusPoke8()
{
;
}

canonical_decompiled_code:
void func5()
{
;
}

original_code:
void DummyBusPoke8(DummyBus *me,int adrs,unsigned char val) {
}

canonical_original_code:
void DummyBusPoke8(struct DummyBus *me, int adrs, unsigned char val) {
}

variable_types:
val
unsigned char


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

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

original_code:
unsigned short DummyBusPeek16(DummyBus *me,int adrs) {
  return 0;
}

canonical_original_code:
unsigned short DummyBusPeek16(struct DummyBus *me, int adrs) {
  return 0;
}

return_type: unsigned short


decompiled_code:
void DummyBusPoke16()
{
;
}

canonical_decompiled_code:
void func7()
{
;
}

original_code:
void DummyBusPoke16(DummyBus *me,int adrs,unsigned short val) {
}

canonical_original_code:
void DummyBusPoke16(struct DummyBus *me, int adrs, unsigned short val) {
}

variable_types:
val
unsigned short


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

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

original_code:
unsigned DummyBusPeek32(DummyBus *me,int adrs) {
  return 0;
}

canonical_original_code:
unsigned int DummyBusPeek32(struct DummyBus *me, int adrs) {
  return 0;
}


decompiled_code:
void DummyBusPoke32()
{
;
}

canonical_decompiled_code:
void func9()
{
;
}

original_code:
void DummyBusPoke32(DummyBus *me,int adrs,unsigned val) {
}

canonical_original_code:
void DummyBusPoke32(struct DummyBus *me, int adrs, unsigned int val) {
}

variable_types:
val
unsigned int


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

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

original_code:
int DummyBusBitGet8(DummyBus *bus,int adrs,int bit) {
  return 0;
}

canonical_original_code:
int DummyBusBitGet8(struct DummyBus *bus, int adrs, int bit) {
  return 0;
}

variable_types: bit int


decompiled_code:
void DummyBusBitAssign8()
{
;
}

canonical_decompiled_code:
void func11()
{
;
}

original_code:
void DummyBusBitAssign8(DummyBus *bus,int adrs,int bit,int val) {
}

canonical_original_code:
void DummyBusBitAssign8(struct DummyBus *bus, int adrs, int bit, int val) {
}

variable_types: val int


decompiled_code:
void DummyBusBitSet8()
{
;
}

canonical_decompiled_code:
void func12()
{
;
}

original_code:
void DummyBusBitSet8(DummyBus *bus,int adrs,int bit) {
}

canonical_original_code:
void DummyBusBitSet8(struct DummyBus *bus, int adrs, int bit) {
}


DummyBusPeekStream

decompiled_code:
void DummyBusPeekStream()
{
;
}

canonical_decompiled_code:
void func13()
{
;
}

original_code:
void DummyBusPeekStream(DummyBus *bus,int adr,int dir,char* buf) {
}

canonical_original_code:
void DummyBusPeekStream(struct DummyBus *bus, int adr, int dir, char *buf) {
}

variable_types: adr int

variable_types: dir int

variable_types:
buf
char *


DummyBusRefresh

decompiled_code:
void DummyBusRefresh()
{
;
}

canonical_decompiled_code:
void func14()
{
;
}

original_code:
void DummyBusRefresh(DummyBus *me) {
}

canonical_original_code:
void DummyBusRefresh(struct DummyBus *me) {
}


DummyBusCommit

decompiled_code:
void DummyBusCommit()
{
;
}

canonical_decompiled_code:
void func15()
{
;
}

original_code:
void DummyBusCommit(DummyBus *me,int forceall) {
}

canonical_original_code:
void DummyBusCommit(struct DummyBus *me, int forceall) {
}

variable_types: forceall int


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

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

original_code:
unsigned char DummyBusAssign8X(DummyBus *me,int adrs,int bit1,int bit0,int val) {
  return 0;
}

canonical_original_code:
unsigned char DummyBusAssign8X(struct DummyBus *me, int adrs, int bit1, int bit0, int val) {
  return 0;
}


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

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

original_code:
unsigned short DummyBusAssign16X(DummyBus *me,int adrs,int bit1,int bit0,int val) {
  return 0;
}

canonical_original_code:
unsigned short DummyBusAssign16X(struct DummyBus *me, int adrs, int bit1, int bit0, int val) {
  return 0;
}


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

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

original_code:
unsigned DummyBusAssign32X(DummyBus *me,int adrs,int bit1,int bit0,int val) {
  return 0;
}

canonical_original_code:
unsigned int DummyBusAssign32X(struct DummyBus *me, int adrs, int bit1, int bit0, int val) {
  return 0;
}


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

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

original_code:
unsigned char DummyBusBitsGet8(DummyBus *me,int adrs,int bit1,int bit0) {
  return 0;
}

canonical_original_code:
unsigned char DummyBusBitsGet8(struct DummyBus *me, int adrs, int bit1, int bit0) {
  return 0;
}


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

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

original_code:
unsigned short DummyBusBitsGet16(DummyBus *me,int adrs,int bit1,int bit0) {
  return 0;
}

canonical_original_code:
unsigned short DummyBusBitsGet16(struct DummyBus *me, int adrs, int bit1, int bit0) {
  return 0;
}


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

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

original_code:
unsigned DummyBusBitsGet32(DummyBus *me,int adrs,int bit1,int bit0) {
  return 0;
}

canonical_original_code:
unsigned int DummyBusBitsGet32(struct DummyBus *me, int adrs, int bit1, int bit0) {
  return 0;
}


DummyBusPokeStream

decompiled_code:
void DummyBusPokeStream()
{
;
}

canonical_decompiled_code:
void func23()
{
;
}

original_code:
void DummyBusPokeStream(DummyBus *bus,int adr,int dir,const char* buf) {
}

canonical_original_code:
void DummyBusPokeStream(struct DummyBus *bus, int adr, int dir, char *buf) {
}


decompiled_code:
void DummyBusBitClear32()
{
;
}

canonical_decompiled_code:
void func25()
{
;
}

original_code:
void DummyBusBitClear32(DummyBus *bus,int adrs,int bit) {
}

canonical_original_code:
void DummyBusBitClear32(struct DummyBus *bus, int adrs, int bit) {
}


decompiled_code:
void DummyBusBitSet32()
{
;
}

canonical_decompiled_code:
void func26()
{
;
}

original_code:
void DummyBusBitSet32(DummyBus *bus,int adrs,int bit) {
}

canonical_original_code:
void DummyBusBitSet32(struct DummyBus *bus, int adrs, int bit) {
}


decompiled_code:
void DummyBusBitClear16()
{
;
}

canonical_decompiled_code:
void func27()
{
;
}

original_code:
void DummyBusBitClear16(DummyBus *bus,int adrs,int bit) {
}

canonical_original_code:
void DummyBusBitClear16(struct DummyBus *bus, int adrs, int bit) {
}


decompiled_code:
void DummyBusBitSet16()
{
;
}

canonical_decompiled_code:
void func28()
{
;
}

original_code:
void DummyBusBitSet16(DummyBus *bus,int adrs,int bit) {
}

canonical_original_code:
void DummyBusBitSet16(struct DummyBus *bus, int adrs, int bit) {
}


decompiled_code:
void DummyBusBitClear8()
{
;
}

canonical_decompiled_code:
void func29()
{
;
}

original_code:
void DummyBusBitClear8(DummyBus *bus,int adrs,int bit) {
}

canonical_original_code:
void DummyBusBitClear8(struct DummyBus *bus, int adrs, int bit) {
}


decompiled_code:
void DummyBusBitAssign32()
{
;
}

canonical_decompiled_code:
void func31()
{
;
}

original_code:
void DummyBusBitAssign32(DummyBus *bus,int adrs,int bit,int val) {
}

canonical_original_code:
void DummyBusBitAssign32(struct DummyBus *bus, int adrs, int bit, int val) {
}


decompiled_code:
void DummyBusBitAssign16()
{
;
}

canonical_decompiled_code:
void func32()
{
;
}

original_code:
void DummyBusBitAssign16(DummyBus *bus,int adrs,int bit,int val) {
}

canonical_original_code:
void DummyBusBitAssign16(struct DummyBus *bus, int adrs, int bit, int val) {
}


decompiled_code:
// attributes: thunk
__int64 __fastcall DummyBusBitToggle32()
{
return DummyBusBitGet8_constprop_0();
}

canonical_decompiled_code:
__int64 __fastcall func34()
{
return func33();
}

original_code:
int DummyBusBitToggle32(DummyBus *bus,int adrs,int bit) {
  return 0;
}

canonical_original_code:
int DummyBusBitToggle32(struct DummyBus *bus, int adrs, int bit) {
  return 0;
}


decompiled_code:
// attributes: thunk
__int64 __fastcall DummyBusBitToggle16()
{
return DummyBusBitGet8_constprop_0();
}

canonical_decompiled_code:
__int64 __fastcall func35()
{
return func33();
}

original_code:
int DummyBusBitToggle16(DummyBus *bus,int adrs,int bit) {
  return 0;
}

canonical_original_code:
int DummyBusBitToggle16(struct DummyBus *bus, int adrs, int bit) {
  return 0;
}


decompiled_code:
// attributes: thunk
__int64 __fastcall DummyBusBitToggle8()
{
return DummyBusBitGet8_constprop_0();
}

canonical_decompiled_code:
__int64 __fastcall func36()
{
return func33();
}

original_code:
int DummyBusBitToggle8(DummyBus *bus,int adrs,int bit) {
  return 0;
}

canonical_original_code:
int DummyBusBitToggle8(struct DummyBus *bus, int adrs, int bit) {
  return 0;
}


decompiled_code:
// attributes: thunk
__int64 __fastcall DummyBusBitGet32()
{
return DummyBusBitGet8_constprop_0();
}

canonical_decompiled_code:
__int64 __fastcall func37()
{
return func33();
}

original_code:
int DummyBusBitGet32(DummyBus *bus,int adrs,int bit) {
  return 0;
}

canonical_original_code:
int DummyBusBitGet32(struct DummyBus *bus, int adrs, int bit) {
  return 0;
}


decompiled_code:
// attributes: thunk
__int64 __fastcall DummyBusBitGet16()
{
return DummyBusBitGet8_constprop_0();
}

canonical_decompiled_code:
__int64 __fastcall func38()
{
return func33();
}

original_code:
int DummyBusBitGet16(DummyBus *bus,int adrs,int bit) {
  return 0;
}

canonical_original_code:
int DummyBusBitGet16(struct DummyBus *bus, int adrs, int bit) {
  return 0;
}


DummyBusUnlock

decompiled_code:
// attributes: thunk
__int64 __fastcall DummyBusUnlock()
{
return DummyBusLock_constprop_0();
}

canonical_decompiled_code:
__int64 __fastcall func40()
{
return func39();
}

original_code:
int DummyBusUnlock(DummyBus *me,unsigned num,int flags) {
  return 1;
}

canonical_original_code:
int DummyBusUnlock(struct DummyBus *me, unsigned int num, int flags) {
  return 1;
}


DummyDIOFini

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

result = *(unsigned int *)(a1 + 120);
if ( (int)result > 0 )
*(_DWORD *)(a1 + 120) = 0;
return result;
}

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

result = *(unsigned int *)(a1 + 120);
if ( (int)result > 0 )
*(_DWORD *)(a1 + 120) = 0;
return result;
}

original_code:
void DummyDIOFini(DummyDIO *dio) {
  if (dio->InitStatus > 0) dio->InitStatus = 0;
}

canonical_original_code:
void DummyDIOFini(struct DummyDIO *dio) {
  if (dio->InitStatus > 0) dio->InitStatus = 0;
}

variable_types: struct DummyDIO { void *(*Init)(struct DummyDIO *me, int count); void (*Fini)(struct DummyDIO *me); int (*Lock)(struct DummyDIO *me, unsigned int num, int flags); int (*Unlock)(struct DummyDIO *me, unsigned int num, int flags); int (*Preempt)(struct DummyDIO *me); void (*Refresh)(struct DummyDIO *me); void (*Commit)(struct DummyDIO *me, int ForceAll); void (*Set)(struct DummyDIO *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)(struct DummyDIO *me, int DIONum); void (*SetAsync)(struct DummyDIO *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)(struct DummyDIO *me, int DIONum); void (*Wait)(struct DummyDIO *me, int *match, int min, int max, int *nh, int *nl); unsigned int (*Count)(struct DummyDIO *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)(struct DummyDIO *me, unsigned int num); int (*GetMulti)(struct DummyDIO *me, char *state, int offset); int InitStatus; unsigned int NumLocks; } *

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


DummyDIORefresh

decompiled_code:
void DummyDIORefresh()
{
;
}

canonical_decompiled_code:
void func2()
{
;
}

original_code:
void DummyDIORefresh(DummyDIO *dio) {
}

canonical_original_code:
void DummyDIORefresh(struct DummyDIO *dio) {
}


DummyDIOCommit

decompiled_code:
void DummyDIOCommit()
{
;
}

canonical_decompiled_code:
void func3()
{
;
}

original_code:
void DummyDIOCommit(DummyDIO *dio,int forceall) {
}

canonical_original_code:
void DummyDIOCommit(struct DummyDIO *dio, int forceall) {
}


DummyDIOSet

decompiled_code:
void DummyDIOSet()
{
;
}

canonical_decompiled_code:
void func4()
{
;
}

original_code:
void DummyDIOSet(DummyDIO *dio,int DIONum,DIOState State) {
}

canonical_original_code:
void DummyDIOSet(struct DummyDIO *dio, int DIONum, enum DIOState State) {
}

variable_types: DIONum int

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


DummyDIOGet

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

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

original_code:
DIOState DummyDIOGet(DummyDIO *dio,int DIONum) {
  return INPUT;
}

canonical_original_code:
enum DIOState DummyDIOGet(struct DummyDIO *dio, int DIONum) {
  return INPUT;
}

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


DummyDIOGetAsync

decompiled_code:
// attributes: thunk
__int64 __fastcall DummyDIOGetAsync()
{
return DummyDIOGet();
}

canonical_decompiled_code:
__int64 __fastcall func6()
{
return func5();
}

original_code:
DIOState DummyDIOGetAsync(DummyDIO *dio,int DIONum) {
  return INPUT;
}

canonical_original_code:
enum DIOState DummyDIOGetAsync(struct DummyDIO *dio, int DIONum) {
  return INPUT;
}


DummyDIOLock

decompiled_code:
__int64 DummyDIOLock()
{
return 1LL;
}

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

original_code:
int DummyDIOLock(DummyDIO *dio,unsigned num,int flags) {
  return 1;
}

canonical_original_code:
int DummyDIOLock(struct DummyDIO *dio, unsigned int num, int flags) {
  return 1;
}

variable_types:
num
unsigned int

variable_types: flags int


DummyDIOPreempt

decompiled_code:
void DummyDIOPreempt()
{
;
}

canonical_decompiled_code:
void func8()
{
;
}

original_code:
int DummyDIOPreempt(DummyDIO *dio) {
}

canonical_original_code:
int DummyDIOPreempt(struct DummyDIO *dio) {
}


DummyDIOCount

decompiled_code:
__int64 __fastcall DummyDIOCount(__int64 a1)
{
return *(unsigned int *)(a1 + 124);
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
return *(unsigned int *)(a1 + 124);
}

original_code:
unsigned DummyDIOCount(DummyDIO *dio) {
  return dio->NumLocks;
}

canonical_original_code:
unsigned int DummyDIOCount(struct DummyDIO *dio) {
  return dio->NumLocks;
}


DummyDIOCapabilities

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

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

original_code:
DIOCaps DummyDIOCapabilities(DummyDIO *dio,unsigned num) {
  return DIO_NOT_PRESENT;
}

canonical_original_code:
enum DIOCaps DummyDIOCapabilities(struct DummyDIO *dio, unsigned int num) {
  return DIO_NOT_PRESENT;
}

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


DummyDIOGetMulti

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

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

original_code:
int DummyDIOGetMulti(DummyDIO *dio,char* bits,int offset) {
  return 0;
}

canonical_original_code:
int DummyDIOGetMulti(struct DummyDIO *dio, char *bits, int offset) {
  return 0;
}

variable_types:
bits
char *

variable_types: offset int


DummyDIOUnlock

decompiled_code:
// attributes: thunk
__int64 __fastcall DummyDIOUnlock()
{
return DummyDIOLock_constprop_0();
}

canonical_decompiled_code:
__int64 __fastcall func13()
{
return func12();
}

original_code:
int DummyDIOUnlock(DummyDIO *dio,unsigned num,int flags) {
  return 1;
}

canonical_original_code:
int DummyDIOUnlock(struct DummyDIO *dio, unsigned int num, int flags) {
  return 1;
}


DummyDIOSetAsync

decompiled_code:
void DummyDIOSetAsync()
{
;
}

canonical_decompiled_code:
void func15()
{
;
}

original_code:
void DummyDIOSetAsync(DummyDIO *dio,int DIONum,DIOState State) {
}

canonical_original_code:
void DummyDIOSetAsync(struct DummyDIO *dio, int DIONum, enum DIOState State) {
}


ArrayFree

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

canonical_decompiled_code:
void __fastcall func16(__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 func17(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)
{
*(_DWORD *)(a1 - 4) = a2;
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func18(__int64 a1, int a2)
{
*(_DWORD *)(a1 - 4) = a2;
return a1;
}

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 func19(__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 func20(__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

if ( *(_DWORD *)(a1 - 4) )
{
v2 = 0LL;
do
{
while ( 1 )
{
v3 = *(_QWORD *)(a1 + 8 * v2);
if ( v3 )
break;
if ( *(_DWORD *)(a1 - 4) <= (unsigned int)++v2 )
goto LABEL_11;
}
if ( *(_DWORD *)(v3 - 4) )
{
v4 = 0LL;
do
{
if ( *(_QWORD *)(v3 + 8 * v4) )
{
ArrayFree(*(_QWORD *)(v3 + 8 * v4));
v3 = *(_QWORD *)(a1 + 8 * v2);
}
++v4;
}
while ( *(_DWORD *)(v3 - 4) > (unsigned int)v4 );
}
ArrayFree(v3);
++v2;
}
while ( *(_DWORD *)(a1 - 4) > (unsigned int)v2 );
}
LABEL_11:
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:
// attributes: thunk
void __noreturn ArrayCompareFunction()
{
while ( 1 )
;
}

canonical_decompiled_code:
void __noreturn func23()
{
while ( 1 )
;
}

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

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


DummyDIOWait

decompiled_code:
__int64 __fastcall DummyDIOWait(__int64 a1, __int64 a2)
{
return ArraySizeAuto(a2, 0);
}

canonical_decompiled_code:
__int64 __fastcall func24(__int64 a1, __int64 a2)
{
return func18(a2, 0);
}

original_code:
void DummyDIOWait(DummyDIO *dio,int* match,int min,int max,
      const int* h,const int* l) {
  ArraySizeAuto(match,0);
}

canonical_original_code:
void DummyDIOWait(struct DummyDIO *dio, int *match, int min, int max, int *h, int *l) {
  ArraySizeAuto(match,0);
}

variable_types: struct DummyDIO { void *(*Init)(struct DummyDIO *me, int count); void (*Fini)(struct DummyDIO *me); int (*Lock)(struct DummyDIO *me, unsigned int num, int flags); int (*Unlock)(struct DummyDIO *me, unsigned int num, int flags); int (*Preempt)(struct DummyDIO *me); void (*Refresh)(struct DummyDIO *me); void (*Commit)(struct DummyDIO *me, int ForceAll); void (*Set)(struct DummyDIO *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)(struct DummyDIO *me, int DIONum); void (*SetAsync)(struct DummyDIO *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)(struct DummyDIO *me, int DIONum); void (*Wait)(struct DummyDIO *me, int *match, int min, int max, int *nh, int *nl); unsigned int (*Count)(struct DummyDIO *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)(struct DummyDIO *me, unsigned int num); int (*GetMulti)(struct DummyDIO *me, char *state, int offset); int InitStatus; unsigned int NumLocks; } *

variable_types:
match
int *

variable_types: min int

variable_types: max int

variable_types:
h
int *

variable_types:
l
int *


NetTimeFini

decompiled_code:
void __fastcall NetTimeFini(__int64 a1)
{
*(_DWORD *)(a1 + 72) = 0;
}

canonical_decompiled_code:
void __fastcall func0(__int64 a1)
{
*(_DWORD *)(a1 + 72) = 0;
}

original_code:
void *NetTimeFini(NetTime *ob) {
  ob->InitStatus = 0;
}

canonical_original_code:
void *NetTimeFini(struct NetTime *ob) {
  ob->InitStatus = 0;
}

variable_types: struct NetTime { void *(*Init)(void *me, ...); void (*Fini)(void *me); unsigned int (*Wait)(void *me, unsigned int microseconds); void (*Delay)(void *me, unsigned int microseconds); unsigned int (*Tick)(void *me); unsigned int (*usElapsed)(void *me, unsigned int start); unsigned int (*usFuture)(void *me, unsigned int start, unsigned int microseconds); enum TimeResult { TimeoutOccurred=1, TimeoutDidNotOccur=0 } (*TimeoutQ)(void *me, unsigned int start, unsigned int end); unsigned int (*TPS)(void *me); int InitStatus; struct tsctl { struct __jmp_buf_tag { long __jmpbuf[8]; int __mask_was_saved; struct __sigset_t { unsigned long __val[-1]; } __saved_mask; } exception[1]; struct Stream { void (*Fini)(struct Stream *); int (*Read)(struct Stream *, char *bytes, int len); int (*Unread)(struct Stream *st, int ch); int (*ReadChar)(struct Stream *st); unsigned int (*InputReady)(struct Stream *st); int (*Write)(struct Stream *, char *bytes, int len); int (*WriteChar)(struct Stream *st, char byte); int (*isEOF)(struct Stream *st); void (*Flush)(struct Stream *st); int outputOffset; } *st; int mode; } *conn; int instance; struct Stream *in; } *

user_defined_types: struct NetTime { void *(*Init)(void *me, ...); void (*Fini)(void *me); unsigned int (*Wait)(void *me, unsigned int microseconds); void (*Delay)(void *me, unsigned int microseconds); unsigned int (*Tick)(void *me); unsigned int (*usElapsed)(void *me, unsigned int start); unsigned int (*usFuture)(void *me, unsigned int start, unsigned int microseconds); enum TimeResult (*TimeoutQ)(void *me, unsigned int start, unsigned int end); unsigned int (*TPS)(void *me); int InitStatus; struct tsctl *conn; int instance; struct Stream *in; }

user_defined_types: struct tsctl { struct __jmp_buf_tag exception[1]; struct Stream *st; int mode; }

user_defined_types: struct __jmp_buf_tag { long __jmpbuf[8]; int __mask_was_saved; struct __sigset_t __saved_mask; }


NetTimeDelay

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

WriteInt16LE(*(_QWORD *)(a1 + 104), 2LL);
WriteInt8LE(*(_QWORD *)(a1 + 104), (unsigned int)*(char *)(a1 + 88));
WriteInt8LE(*(_QWORD *)(a1 + 104), 1LL);
WriteUInt32LE(*(_QWORD *)(a1 + 104), a2);
result = *(_QWORD *)(a1 + 80);
v3 = *(_DWORD *)(result + 208);
if ( v3 <= 0 || (++*(_DWORD *)(result + 212), v3 == 1) )
{
(*(void (__fastcall **)(_QWORD))(*(_QWORD *)(a1 + 104) + 64LL))(*(_QWORD *)(a1 + 104));
result = *(unsigned int *)(*(_QWORD *)(a1 + 80) + 208LL);
if ( (int)result <= 0 )
{
if ( (unsigned __int16)ReadInt16LE(*(_QWORD *)(a1 + 96)) != 2 )
longjmp(*(struct __jmp_buf_tag **)(a1 + 80), 1);
if ( (unsigned __int8)ReadUInt8LE(*(_QWORD *)(a1 + 96)) != 1
|| (result = ReadUInt8LE(*(_QWORD *)(a1 + 96)), (_BYTE)result != 0x80) )
{
longjmp(*(struct __jmp_buf_tag **)(a1 + 80), 2);
}
}
}
return result;
}

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

WriteInt16LE(*(_QWORD *)(a1 + 104), 2LL);
WriteInt8LE(*(_QWORD *)(a1 + 104), (unsigned int)*(char *)(a1 + 88));
WriteInt8LE(*(_QWORD *)(a1 + 104), 1LL);
WriteUInt32LE(*(_QWORD *)(a1 + 104), a2);
result = *(_QWORD *)(a1 + 80);
v3 = *(_DWORD *)(result + 208);
if ( v3 <= 0 || (++*(_DWORD *)(result + 212), v3 == 1) )
{
(*(void (__fastcall **)(_QWORD))(*(_QWORD *)(a1 + 104) + 64LL))(*(_QWORD *)(a1 + 104));
result = *(unsigned int *)(*(_QWORD *)(a1 + 80) + 208LL);
if ( (int)result <= 0 )
{
if ( (unsigned __int16)ReadInt16LE(*(_QWORD *)(a1 + 96)) != 2 )
longjmp(*(struct __jmp_buf_tag **)(a1 + 80), 1);
if ( (unsigned __int8)ReadUInt8LE(*(_QWORD *)(a1 + 96)) != 1
|| (result = ReadUInt8LE(*(_QWORD *)(a1 + 96)), (_BYTE)result != 0x80) )
{
longjmp(*(struct __jmp_buf_tag **)(a1 + 80), 2);
}
}
}
return result;
}

original_code:
void NetTimeDelay(NetTime *ob,uint32 microseconds) {
  Stream *out = ob->out;
  int ret_len;
  WriteInt16LE(ob->out,0x0002);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x01);
  WriteUInt32LE(ob->out,microseconds);
  if (ob->conn->mode > 0) ob->conn->count++;
  if (ob->conn->mode < 2) ob->out->Flush(ob->out);
  if (ob->conn->mode > 0) return;
  if (ReadInt16LE(ob->in) != 0x0002) longjmp(ob->conn->exception,1);
  if (ReadUInt8LE(ob->in) != 0x01) longjmp(ob->conn->exception,2);
  if (ReadUInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2);
}

canonical_original_code:
void NetTimeDelay(struct NetTime *ob, unsigned int microseconds) {
  struct Stream *out = ob->out;
  int ret_len;
  WriteInt16LE(ob->out,0x0002);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x01);
  WriteUInt32LE(ob->out,microseconds);
  if (ob->conn->mode > 0) ob->conn->count++;
  if (ob->conn->mode < 2) ob->out->Flush(ob->out);
  if (ob->conn->mode > 0) return;
  if (ReadInt16LE(ob->in) != 0x0002) longjmp(ob->conn->exception,1);
  if (ReadUInt8LE(ob->in) != 0x01) longjmp(ob->conn->exception,2);
  if (ReadUInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2);
}

variable_types:
microseconds
unsigned int

variable_types: struct Stream { void (*Fini)(struct Stream *); int (*Read)(struct Stream *, char *bytes, int len); int (*Unread)(struct Stream *st, int ch); int (*ReadChar)(struct Stream *st); unsigned int (*InputReady)(struct Stream *st); int (*Write)(struct Stream *, char *bytes, int len); int (*WriteChar)(struct Stream *st, char byte); int (*isEOF)(struct Stream *st); void (*Flush)(struct Stream *st); int outputOffset; } *

user_defined_types: struct __sigset_t { unsigned long __val[-1]; }


NetTimeTimeoutQ

decompiled_code:
__int64 __fastcall NetTimeTimeoutQ(__int64 a1, unsigned int a2, unsigned int a3)
{
__int64 v5; // r12
__int64 v6; // rdx
__int64 v7; // rdi
int v8; // eax
unsigned int v9; // er12

v5 = *(_QWORD *)(a1 + 104);
WriteInt16LE(v5, 2LL);
WriteInt8LE(*(_QWORD *)(a1 + 104), (unsigned int)*(char *)(a1 + 88));
WriteInt8LE(*(_QWORD *)(a1 + 104), 5LL);
WriteUInt32LE(*(_QWORD *)(a1 + 104), a2);
WriteUInt32LE(*(_QWORD *)(a1 + 104), a3);
(*(void (__fastcall **)(_QWORD))(*(_QWORD *)(a1 + 104) + 64LL))(*(_QWORD *)(a1 + 104));
v6 = *(_QWORD *)(a1 + 80);
if ( *(int *)(v6 + 208) > 0 )
{
while ( 1 )
{
v8 = *(_DWORD *)(v6 + 212);
if ( !v8 )
break;
v7 = *(_QWORD *)(a1 + 96);
*(_DWORD *)(v6 + 212) = v8 - 1;
ReadInt32LE(v7);
v6 = *(_QWORD *)(a1 + 80);
}
}
if ( (unsigned __int16)ReadInt16LE(*(_QWORD *)(a1 + 96)) != 2 )
longjmp(*(struct __jmp_buf_tag **)(a1 + 80), 1);
if ( (unsigned __int8)ReadUInt8LE(*(_QWORD *)(a1 + 96)) != 5 )
goto LABEL_12;
if ( (unsigned __int8)ReadUInt8LE(*(_QWORD *)(a1 + 96)) != 0xC1 )
longjmp(*(struct __jmp_buf_tag **)(a1 + 80), 3);
v9 = ReadInt32LE(v5);
if ( (unsigned __int8)ReadUInt8LE(*(_QWORD *)(a1 + 96)) != 0x80 )
LABEL_12:
longjmp(*(struct __jmp_buf_tag **)(a1 + 80), 2);
return v9;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, unsigned int a2, unsigned int a3)
{
__int64 v5; // r12
__int64 v6; // rdx
__int64 v7; // rdi
int v8; // eax
unsigned int v9; // er12

v5 = *(_QWORD *)(a1 + 104);
WriteInt16LE(v5, 2LL);
WriteInt8LE(*(_QWORD *)(a1 + 104), (unsigned int)*(char *)(a1 + 88));
WriteInt8LE(*(_QWORD *)(a1 + 104), 5LL);
WriteUInt32LE(*(_QWORD *)(a1 + 104), a2);
WriteUInt32LE(*(_QWORD *)(a1 + 104), a3);
(*(void (__fastcall **)(_QWORD))(*(_QWORD *)(a1 + 104) + 64LL))(*(_QWORD *)(a1 + 104));
v6 = *(_QWORD *)(a1 + 80);
if ( *(int *)(v6 + 208) > 0 )
{
while ( 1 )
{
v8 = *(_DWORD *)(v6 + 212);
if ( !v8 )
break;
v7 = *(_QWORD *)(a1 + 96);
*(_DWORD *)(v6 + 212) = v8 - 1;
ReadInt32LE(v7);
v6 = *(_QWORD *)(a1 + 80);
}
}
if ( (unsigned __int16)ReadInt16LE(*(_QWORD *)(a1 + 96)) != 2 )
longjmp(*(struct __jmp_buf_tag **)(a1 + 80), 1);
if ( (unsigned __int8)ReadUInt8LE(*(_QWORD *)(a1 + 96)) != 5 )
goto LABEL_12;
if ( (unsigned __int8)ReadUInt8LE(*(_QWORD *)(a1 + 96)) != 0xC1 )
longjmp(*(struct __jmp_buf_tag **)(a1 + 80), 3);
v9 = ReadInt32LE(v5);
if ( (unsigned __int8)ReadUInt8LE(*(_QWORD *)(a1 + 96)) != 0x80 )
LABEL_12:
longjmp(*(struct __jmp_buf_tag **)(a1 + 80), 2);
return v9;
}

original_code:
TimeResult NetTimeTimeoutQ(NetTime *ob,uint32 start,uint32 end) {
  Stream *out = ob->out;
  int ret_len;
  TimeResult ret;
  WriteInt16LE(ob->out,0x0002);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x05);
  WriteUInt32LE(ob->out,start);
  WriteUInt32LE(ob->out,end);
  ob->out->Flush(ob->out);
  if (ob->conn->mode > 0) {
    while (ob->conn->count) {
      ob->conn->count--;
      ReadInt32LE(ob->in);
    }
  }
  if (ReadInt16LE(ob->in) != 0x0002) longjmp(ob->conn->exception,1);
  if (ReadUInt8LE(ob->in) != 0x05) longjmp(ob->conn->exception,2);
  if (ReadUInt8LE(ob->in) != 0xC1) longjmp(ob->conn->exception,3);
  ret = ReadInt32LE(out);
  if (ReadUInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2);
  return ret;
}

canonical_original_code:
enum TimeResult NetTimeTimeoutQ(struct NetTime *ob, unsigned int start, unsigned int end) {
  struct Stream *out = ob->out;
  int ret_len;
  enum TimeResult ret;
  WriteInt16LE(ob->out,0x0002);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x05);
  WriteUInt32LE(ob->out,start);
  WriteUInt32LE(ob->out,end);
  ob->out->Flush(ob->out);
  if (ob->conn->mode > 0) {
    while (ob->conn->count) {
      ob->conn->count--;
      ReadInt32LE(ob->in);
    }
  }
  if (ReadInt16LE(ob->in) != 0x0002) longjmp(ob->conn->exception,1);
  if (ReadUInt8LE(ob->in) != 0x05) longjmp(ob->conn->exception,2);
  if (ReadUInt8LE(ob->in) != 0xC1) longjmp(ob->conn->exception,3);
  ret = ReadInt32LE(out);
  if (ReadUInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2);
  return ret;
}

variable_types:
start
unsigned int

variable_types:
end
unsigned int

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

user_defined_types: struct Stream { void (*Fini)(struct Stream *); int (*Read)(struct Stream *, char *bytes, int len); int (*Unread)(struct Stream *st, int ch); int (*ReadChar)(struct Stream *st); unsigned int (*InputReady)(struct Stream *st); int (*Write)(struct Stream *, char *bytes, int len); int (*WriteChar)(struct Stream *st, char byte); int (*isEOF)(struct Stream *st); void (*Flush)(struct Stream *st); int outputOffset; }


NetTimeWait

decompiled_code:
__int64 __fastcall NetTimeWait(__int64 a1, unsigned int a2)
{
__int64 v2; // r12
__int64 v4; // rdx
__int64 v5; // rdi
int v6; // eax
unsigned int v7; // er12

v2 = *(_QWORD *)(a1 + 104);
WriteInt16LE(v2, 2LL);
WriteInt8LE(*(_QWORD *)(a1 + 104), (unsigned int)*(char *)(a1 + 88));
WriteInt8LE(*(_QWORD *)(a1 + 104), 0LL);
WriteUInt32LE(*(_QWORD *)(a1 + 104), a2);
(*(void (__fastcall **)(_QWORD))(*(_QWORD *)(a1 + 104) + 64LL))(*(_QWORD *)(a1 + 104));
v4 = *(_QWORD *)(a1 + 80);
if ( *(int *)(v4 + 208) > 0 )
{
while ( 1 )
{
v6 = *(_DWORD *)(v4 + 212);
if ( !v6 )
break;
v5 = *(_QWORD *)(a1 + 96);
*(_DWORD *)(v4 + 212) = v6 - 1;
ReadInt32LE(v5);
v4 = *(_QWORD *)(a1 + 80);
}
}
if ( (unsigned __int16)ReadInt16LE(*(_QWORD *)(a1 + 96)) != 2 )
longjmp(*(struct __jmp_buf_tag **)(a1 + 80), 1);
if ( (unsigned __int8)ReadUInt8LE(*(_QWORD *)(a1 + 96)) )
goto LABEL_12;
if ( (unsigned __int8)ReadUInt8LE(*(_QWORD *)(a1 + 96)) != 3 )
longjmp(*(struct __jmp_buf_tag **)(a1 + 80), 3);
v7 = ReadUInt32LE(v2);
if ( (unsigned __int8)ReadUInt8LE(*(_QWORD *)(a1 + 96)) != 0x80 )
LABEL_12:
longjmp(*(struct __jmp_buf_tag **)(a1 + 80), 2);
return v7;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, unsigned int a2)
{
__int64 v2; // r12
__int64 v4; // rdx
__int64 v5; // rdi
int v6; // eax
unsigned int v7; // er12

v2 = *(_QWORD *)(a1 + 104);
WriteInt16LE(v2, 2LL);
WriteInt8LE(*(_QWORD *)(a1 + 104), (unsigned int)*(char *)(a1 + 88));
WriteInt8LE(*(_QWORD *)(a1 + 104), 0LL);
WriteUInt32LE(*(_QWORD *)(a1 + 104), a2);
(*(void (__fastcall **)(_QWORD))(*(_QWORD *)(a1 + 104) + 64LL))(*(_QWORD *)(a1 + 104));
v4 = *(_QWORD *)(a1 + 80);
if ( *(int *)(v4 + 208) > 0 )
{
while ( 1 )
{
v6 = *(_DWORD *)(v4 + 212);
if ( !v6 )
break;
v5 = *(_QWORD *)(a1 + 96);
*(_DWORD *)(v4 + 212) = v6 - 1;
ReadInt32LE(v5);
v4 = *(_QWORD *)(a1 + 80);
}
}
if ( (unsigned __int16)ReadInt16LE(*(_QWORD *)(a1 + 96)) != 2 )
longjmp(*(struct __jmp_buf_tag **)(a1 + 80), 1);
if ( (unsigned __int8)ReadUInt8LE(*(_QWORD *)(a1 + 96)) )
goto LABEL_12;
if ( (unsigned __int8)ReadUInt8LE(*(_QWORD *)(a1 + 96)) != 3 )
longjmp(*(struct __jmp_buf_tag **)(a1 + 80), 3);
v7 = ReadUInt32LE(v2);
if ( (unsigned __int8)ReadUInt8LE(*(_QWORD *)(a1 + 96)) != 0x80 )
LABEL_12:
longjmp(*(struct __jmp_buf_tag **)(a1 + 80), 2);
return v7;
}

original_code:
uint32 NetTimeWait(NetTime *ob,uint32 microseconds) {
  Stream *out = ob->out;
  int ret_len;
  uint32 ret;
  WriteInt16LE(ob->out,0x0002);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x00);
  WriteUInt32LE(ob->out,microseconds);
  ob->out->Flush(ob->out);
  if (ob->conn->mode > 0) {
    while (ob->conn->count) {
      ob->conn->count--;
      ReadInt32LE(ob->in);
    }
  }
  if (ReadInt16LE(ob->in) != 0x0002) longjmp(ob->conn->exception,1);
  if (ReadUInt8LE(ob->in) != 0x00) longjmp(ob->conn->exception,2);
  if (ReadUInt8LE(ob->in) != 0x03) longjmp(ob->conn->exception,3);
  ret = ReadUInt32LE(out);
  if (ReadUInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2);
  return ret;
}

canonical_original_code:
unsigned int NetTimeWait(struct NetTime *ob, unsigned int microseconds) {
  struct Stream *out = ob->out;
  int ret_len;
  unsigned int ret;
  WriteInt16LE(ob->out,0x0002);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x00);
  WriteUInt32LE(ob->out,microseconds);
  ob->out->Flush(ob->out);
  if (ob->conn->mode > 0) {
    while (ob->conn->count) {
      ob->conn->count--;
      ReadInt32LE(ob->in);
    }
  }
  if (ReadInt16LE(ob->in) != 0x0002) longjmp(ob->conn->exception,1);
  if (ReadUInt8LE(ob->in) != 0x00) longjmp(ob->conn->exception,2);
  if (ReadUInt8LE(ob->in) != 0x03) longjmp(ob->conn->exception,3);
  ret = ReadUInt32LE(out);
  if (ReadUInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2);
  return ret;
}

variable_types:
ret
unsigned int


NetTimeTick

original_code:
uint32 NetTimeTick(NetTime *ob) {
  Stream *out = ob->out;
  int ret_len;
  uint32 ret;
  WriteInt16LE(ob->out,0x0002);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x02);
  ob->out->Flush(ob->out);
  if (ob->conn->mode > 0) {
    while (ob->conn->count) {
      ob->conn->count--;
      ReadInt32LE(ob->in);
    }
  }
  if (ReadInt16LE(ob->in) != 0x0002) longjmp(ob->conn->exception,1);
  if (ReadUInt8LE(ob->in) != 0x02) longjmp(ob->conn->exception,2);
  if (ReadUInt8LE(ob->in) != 0x03) longjmp(ob->conn->exception,3);
  ret = ReadUInt32LE(out);
  if (ReadUInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2);
  return ret;
}

canonical_original_code:
unsigned int NetTimeTick(struct NetTime *ob) {
  struct Stream *out = ob->out;
  int ret_len;
  unsigned int ret;
  WriteInt16LE(ob->out,0x0002);
  WriteInt8LE(ob->out,ob->instance);
  WriteInt8LE(ob->out,0x02);
  ob->out->Flush(ob->out);
  if (ob->conn->mode > 0) {
    while (ob->conn->count) {
      ob->conn->count--;
      ReadInt32LE(ob->in);
    }
  }
  if (ReadInt16LE(ob->in) != 0x0002) longjmp(ob->conn->exception,1);
  if (ReadUInt8LE(ob->in) != 0x02) longjmp(ob->conn->exception,2);
  if (ReadUInt8LE(ob->in) != 0x03) longjmp(ob->conn->exception,3);
  ret = ReadUInt32LE(out);
  if (ReadUInt8LE(ob->in) != 0x80) longjmp(ob->conn->exception,2);
  return ret;
}