setTimer

decompiled_code:
int __fastcall setTimer(unsigned int a1)
{
struct itimerspec v2; // [rsp+0h] [rbp-28h] BYREF

v2.it_interval.tv_sec = 0LL;
v2.it_interval.tv_nsec = 0LL;
v2.it_value.tv_sec = a1 / 0xF4240;
if ( !a1 )
a1 = 1;
v2.it_value.tv_nsec = 1000 * (a1 % 0xF4240);
return timer_settime(timer, 0, &v2, 0LL);
}

canonical_decompiled_code:
int __fastcall func11(unsigned int a1)
{
struct itimerspec v2; // [rsp+0h] [rbp-28h] BYREF

v2.it_interval.tv_sec = 0LL;
v2.it_interval.tv_nsec = 0LL;
v2.it_value.tv_sec = a1 / 0xF4240;
if ( !a1 )
a1 = 1;
v2.it_value.tv_nsec = 1000 * (a1 % 0xF4240);
return timer_settime(timer, 0, &v2, 0LL);
}

original_code:
void setTimer(uint32_t value)
{
 long tv_nsec = 1000 * (((value>1)?value:1)%1000000);
 time_t tv_sec = value/1000000;
 struct itimerspec timerValues;
 timerValues.it_value.tv_sec = tv_sec;
 timerValues.it_value.tv_nsec = tv_nsec;
 timerValues.it_interval.tv_sec = 0;
 timerValues.it_interval.tv_nsec = 0;
  timer_settime (timer, 0, &timerValues, ((void *)0));
}

canonical_original_code:
void setTimer(unsigned int value)
{
 long tv_nsec = 1000 * (((value>1)?value:1)%1000000);
 long tv_sec = value/1000000;
 struct itimerspec timerValues;
 timerValues.it_value.tv_sec = tv_sec;
 timerValues.it_value.tv_nsec = tv_nsec;
 timerValues.it_interval.tv_sec = 0;
 timerValues.it_interval.tv_nsec = 0;
  timer_settime (timer, 0, &timerValues, ((void *)0));
}

variable_types:
value
unsigned int

variable_types: struct itimerspec { struct timespec { long tv_sec; long tv_nsec; } it_interval; struct timespec it_value; }

user_defined_types: struct itimerspec { struct timespec it_interval; struct timespec it_value; }


getElapsedTime

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

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

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

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

original_code:
uint32_t getElapsedTime(void)
{
 struct timeval p;
 if(gettimeofday(&p,((void *)0))) {
  perror("gettimeofday()");
 }
 return (p.tv_sec - last_sig.tv_sec)* 1000000 + p.tv_usec - last_sig.tv_usec;
}

canonical_original_code:
unsigned int getElapsedTime()
{
 struct timeval p;
 if(gettimeofday(&p,((void *)0))) {
  perror("gettimeofday()");
 }
 return (p.tv_sec - last_sig.tv_sec)* 1000000 + p.tv_usec - last_sig.tv_usec;
}

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

return_type: unsigned int


decompiled_code:
__int64 __fastcall TestSlaveB_valueRangeTest(char a1, _BYTE *a2)
{
__int64 result; // rax

result = 0LL;
if ( a1 == -97 )
result = *a2 != 0 ? 0x6090030 : 0;
return result;
}

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

result = 0LL;
if ( a1 == -97 )
result = *a2 != 0 ? 0x6090030 : 0;
return result;
}

original_code:
unsigned long int TestSlaveB_valueRangeTest (unsigned char typeValue, void * value)
{
  switch (typeValue) {
    case 0x9F:
      if (*(unsigned char*)value != (unsigned char)0) return 0x06090030;
      break;
  }
  return 0;
}

canonical_original_code:
unsigned long TestSlaveB_valueRangeTest(unsigned char typeValue, void *value)
{
  switch (typeValue) {
    case 0x9F:
      if (*(unsigned char *)value != (unsigned char)0) return 0x06090030;
      break;
  }
  return 0;
}

variable_types:
typeValue
unsigned char

variable_types:
value
void *

return_type: unsigned long


decompiled_code:
void ***__fastcall TestSlaveB_scanIndexOD(unsigned __int16 a1, _QWORD *a2, _QWORD *a3)
{
void ***result; // rax

*a3 = 0LL;
if ( a1 <= 0x1018u )
{
if ( a1 > 0xFFFu )
{
switch ( a1 )
{
case 0x1000u:
result = &TestSlaveB_objdict;
goto LABEL_8;
case 0x1001u:
result = &TestSlaveB_objdict + 2;
goto LABEL_8;
case 0x1003u:
*a3 = &TestSlaveB_Index1003_callbacks;
result = &TestSlaveB_objdict + 4;
goto LABEL_8;
case 0x1005u:
*a3 = &TestSlaveB_Index1005_callbacks;
result = &TestSlaveB_objdict + 6;
goto LABEL_8;
case 0x1006u:
*a3 = &TestSlaveB_Index1006_callbacks;
result = &TestSlaveB_objdict + 8;
goto LABEL_8;
case 0x1010u:
*a3 = &TestSlaveB_Index1010_callbacks;
result = &TestSlaveB_objdict + 10;
goto LABEL_8;
case 0x1011u:
*a3 = &TestSlaveB_Index1011_callbacks;
result = &TestSlaveB_objdict + 12;
goto LABEL_8;
case 0x1014u:
result = &TestSlaveB_objdict + 14;
goto LABEL_8;
case 0x1017u:
*a3 = &TestSlaveB_Index1017_callbacks;
result = &TestSlaveB_objdict + 16;
goto LABEL_8;
case 0x1018u:
result = &TestSlaveB_objdict + 18;
goto LABEL_8;
default:
goto LABEL_14;
}
}
goto LABEL_14;
}
if ( a1 == 6656 )
{
*a2 = 0LL;
return &TestSlaveB_objdict + 24;
}
if ( a1 <= 0x1A00u )
{
if ( a1 == 4608 )
{
*a2 = 0LL;
return &TestSlaveB_objdict + 20;
}
if ( a1 != 6144 )
goto LABEL_14;
*a3 = &TestSlaveB_Index1800_callbacks;
result = &TestSlaveB_objdict + 22;
LABEL_8:
*a2 = 0LL;
return result;
}
if ( a1 == 0x2000 )
{
result = &TestSlaveB_objdict + 26;
goto LABEL_8;
}
LABEL_14:
*a2 = 100794368LL;
return 0LL;
}

canonical_decompiled_code:
void ***__fastcall func1(unsigned __int16 a1, _QWORD *a2, _QWORD *a3)
{
void ***result; // rax

*a3 = 0LL;
if ( a1 <= 0x1018u )
{
if ( a1 > 0xFFFu )
{
switch ( a1 )
{
case 0x1000u:
result = &TestSlaveB_objdict;
goto LABEL_8;
case 0x1001u:
result = &TestSlaveB_objdict + 2;
goto LABEL_8;
case 0x1003u:
*a3 = &TestSlaveB_Index1003_callbacks;
result = &TestSlaveB_objdict + 4;
goto LABEL_8;
case 0x1005u:
*a3 = &TestSlaveB_Index1005_callbacks;
result = &TestSlaveB_objdict + 6;
goto LABEL_8;
case 0x1006u:
*a3 = &TestSlaveB_Index1006_callbacks;
result = &TestSlaveB_objdict + 8;
goto LABEL_8;
case 0x1010u:
*a3 = &TestSlaveB_Index1010_callbacks;
result = &TestSlaveB_objdict + 10;
goto LABEL_8;
case 0x1011u:
*a3 = &TestSlaveB_Index1011_callbacks;
result = &TestSlaveB_objdict + 12;
goto LABEL_8;
case 0x1014u:
result = &TestSlaveB_objdict + 14;
goto LABEL_8;
case 0x1017u:
*a3 = &TestSlaveB_Index1017_callbacks;
result = &TestSlaveB_objdict + 16;
goto LABEL_8;
case 0x1018u:
result = &TestSlaveB_objdict + 18;
goto LABEL_8;
default:
goto LABEL_14;
}
}
goto LABEL_14;
}
if ( a1 == 6656 )
{
*a2 = 0LL;
return &TestSlaveB_objdict + 24;
}
if ( a1 <= 0x1A00u )
{
if ( a1 == 4608 )
{
*a2 = 0LL;
return &TestSlaveB_objdict + 20;
}
if ( a1 != 6144 )
goto LABEL_14;
*a3 = &TestSlaveB_Index1800_callbacks;
result = &TestSlaveB_objdict + 22;
LABEL_8:
*a2 = 0LL;
return result;
}
if ( a1 == 0x2000 )
{
result = &TestSlaveB_objdict + 26;
goto LABEL_8;
}
LABEL_14:
*a2 = 100794368LL;
return 0LL;
}

original_code:
const indextable * TestSlaveB_scanIndexOD (unsigned short wIndex, unsigned long int * errorCode, ODCallback_t **callbacks)
{
 int i;
 *callbacks = ((void *)0);
 switch(wIndex){
  case 0x1000: i = 0;break;
  case 0x1001: i = 1;break;
  case 0x1003: i = 2;*callbacks = TestSlaveB_Index1003_callbacks; break;
  case 0x1005: i = 3;*callbacks = TestSlaveB_Index1005_callbacks; break;
  case 0x1006: i = 4;*callbacks = TestSlaveB_Index1006_callbacks; break;
  case 0x1010: i = 5;*callbacks = TestSlaveB_Index1010_callbacks; break;
  case 0x1011: i = 6;*callbacks = TestSlaveB_Index1011_callbacks; break;
  case 0x1014: i = 7;break;
  case 0x1017: i = 8;*callbacks = TestSlaveB_Index1017_callbacks; break;
  case 0x1018: i = 9;break;
  case 0x1200: i = 10;break;
  case 0x1800: i = 11;*callbacks = TestSlaveB_Index1800_callbacks; break;
  case 0x1A00: i = 12;break;
  case 0x2000: i = 13;break;
  default:
   *errorCode = 0x06020000;
   return ((void *)0);
 }
 *errorCode = 0x00000000;
 return &TestSlaveB_objdict[i];
}

canonical_original_code:
struct td_indextable *TestSlaveB_scanIndexOD(unsigned short wIndex, unsigned long *errorCode, unsigned long (***callbacks)(struct struct_CO_Data *d, struct td_indextable *, unsigned char bSubindex))
{
 int i;
 *callbacks = ((void *)0);
 switch(wIndex){
  case 0x1000: i = 0;break;
  case 0x1001: i = 1;break;
  case 0x1003: i = 2;*callbacks = TestSlaveB_Index1003_callbacks; break;
  case 0x1005: i = 3;*callbacks = TestSlaveB_Index1005_callbacks; break;
  case 0x1006: i = 4;*callbacks = TestSlaveB_Index1006_callbacks; break;
  case 0x1010: i = 5;*callbacks = TestSlaveB_Index1010_callbacks; break;
  case 0x1011: i = 6;*callbacks = TestSlaveB_Index1011_callbacks; break;
  case 0x1014: i = 7;break;
  case 0x1017: i = 8;*callbacks = TestSlaveB_Index1017_callbacks; break;
  case 0x1018: i = 9;break;
  case 0x1200: i = 10;break;
  case 0x1800: i = 11;*callbacks = TestSlaveB_Index1800_callbacks; break;
  case 0x1A00: i = 12;break;
  case 0x2000: i = 13;break;
  default:
   *errorCode = 0x06020000;
   return ((void *)0);
 }
 *errorCode = 0x00000000;
 return &TestSlaveB_objdict[i];
}

variable_types:
wIndex
unsigned short

variable_types:
errorCode
unsigned long *

variable_types: unsigned long (***)(struct struct_CO_Data { unsigned char *bDeviceNodeId; struct td_indextable *objdict; struct struct_s_PDO_status { unsigned char transmit_type_parameter; short event_timer; short inhibit_timer; struct Message { unsigned short cob_id; unsigned char rtr; unsigned char len; unsigned char data[8]; } last_message; } *PDO_status; short *RxPDO_EventTimers; void (*RxPDO_EventTimers_Handler)(struct struct_CO_Data *, unsigned long); struct s_quick_index { unsigned short SDO_SVR; unsigned short SDO_CLT; unsigned short PDO_RCV; unsigned short PDO_RCV_MAP; unsigned short PDO_TRS; unsigned short PDO_TRS_MAP; } *firstIndex; struct s_quick_index *lastIndex; unsigned short *ObjdictSize; unsigned char *iam_a_slave; unsigned long (*valueRangeTest)(unsigned char typeValue, void *Value); struct struct_s_transfer { unsigned char CliServNbr; unsigned char whoami; unsigned char state; unsigned char toggle; unsigned long abortCode; unsigned short index; unsigned char subIndex; unsigned long count; unsigned long offset; unsigned char data[32]; unsigned char peerCRCsupport; unsigned char blksize; unsigned char ackseq; unsigned long objsize; unsigned char lastblockoffset; unsigned char seqno; unsigned char endfield; enum rxStep_t { RXSTEP_INIT=0, RXSTEP_STARTED=1, RXSTEP_END=2 } rxstep; unsigned char tmpData[8]; unsigned char dataType; short timer; void (*Callback)(struct struct_CO_Data *d, unsigned char nodeId); } transfers[4]; enum enum_nodeState { Initialisation=0, Disconnected=1, Connecting=2, Preparing=2, Stopped=4, Operational=5, Pre_operational=127, Unknown_state=15 } nodeState; struct s_state_communication { char csBoot_Up; char csSDO; char csEmergency; char csSYNC; char csLifeGuard; char csPDO; char csLSS; } CurrentCommunicationState; void (*initialisation)(struct struct_CO_Data *); void (*preOperational)(struct struct_CO_Data *); void (*operational)(struct struct_CO_Data *); void (*stopped)(struct struct_CO_Data *); void (*NMT_Slave_Node_Reset_Callback)(struct struct_CO_Data *); void (*NMT_Slave_Communications_Reset_Callback)(struct struct_CO_Data *); unsigned char *ConsumerHeartbeatCount; unsigned long *ConsumerHeartbeatEntries; short *ConsumerHeartBeatTimers; unsigned short *ProducerHeartBeatTime; short ProducerHeartBeatTimer; void (*heartbeatError)(struct struct_CO_Data *, unsigned char); enum enum_nodeState { Initialisation=0, Disconnected=1, Connecting=2, Preparing=2, Stopped=4, Operational=5, Pre_operational=127, Unknown_state=15 } NMTable[128]; short GuardTimeTimer; short LifeTimeTimer; void (*nodeguardError)(struct struct_CO_Data *, unsigned char); unsigned short *GuardTime; unsigned char *LifeTimeFactor; unsigned char nodeGuardStatus[128]; short syncTimer; unsigned long *COB_ID_Sync; unsigned long *Sync_Cycle_Period; void (*post_sync)(struct struct_CO_Data *); void (*post_TPDO)(struct struct_CO_Data *); void (*post_SlaveBootup)(struct struct_CO_Data *, unsigned char); void (*post_SlaveStateChange)(struct struct_CO_Data *, unsigned char, enum enum_nodeState { Initialisation=0, Disconnected=1, Connecting=2, Preparing=2, Stopped=4, Operational=5, Pre_operational=127, Unknown_state=15 }); unsigned char toggle; void *canHandle; struct td_indextable *(*scanIndexOD)(unsigned short wIndex, unsigned long *errorCode, unsigned long (***Callback)(struct struct_CO_Data *d, struct td_indextable *, unsigned char bSubindex)); void (*storeODSubIndex)(struct struct_CO_Data *d, unsigned short wIndex, unsigned char bSubindex); struct td_indextable *dcf_odentry; unsigned char *dcf_cursor; unsigned long dcf_entries_count; unsigned char dcf_status; unsigned long dcf_size; unsigned char *dcf_data; enum enum_errorState { Error_free=0, Error_occurred=1 } error_state; unsigned char error_history_size; unsigned char *error_number; unsigned long *error_first_element; unsigned char *error_register; unsigned long *error_cobid; struct s_errors { unsigned short errCode; unsigned char errRegMask; unsigned char active; } error_data[8]; void (*post_emcy)(struct struct_CO_Data *d, unsigned char nodeID, unsigned short errCode, unsigned char errReg); } *d, struct td_indextable *, unsigned char bSubindex)

variable_types: i int

return_type: struct td_indextable { struct td_subindex { unsigned char bAccessType; unsigned char bDataType; unsigned long size; void *pObject; } *pSubindex; unsigned char bSubCount; unsigned short index; } *

user_defined_types: struct td_indextable { struct td_subindex *pSubindex; unsigned char bSubCount; unsigned short index; }

user_defined_types: struct struct_CO_Data { unsigned char *bDeviceNodeId; struct td_indextable *objdict; struct struct_s_PDO_status *PDO_status; short *RxPDO_EventTimers; void (*RxPDO_EventTimers_Handler)(struct struct_CO_Data *, unsigned long); struct s_quick_index *firstIndex; struct s_quick_index *lastIndex; unsigned short *ObjdictSize; unsigned char *iam_a_slave; unsigned long (*valueRangeTest)(unsigned char typeValue, void *Value); struct struct_s_transfer transfers[4]; enum enum_nodeState nodeState; struct s_state_communication CurrentCommunicationState; void (*initialisation)(struct struct_CO_Data *); void (*preOperational)(struct struct_CO_Data *); void (*operational)(struct struct_CO_Data *); void (*stopped)(struct struct_CO_Data *); void (*NMT_Slave_Node_Reset_Callback)(struct struct_CO_Data *); void (*NMT_Slave_Communications_Reset_Callback)(struct struct_CO_Data *); unsigned char *ConsumerHeartbeatCount; unsigned long *ConsumerHeartbeatEntries; short *ConsumerHeartBeatTimers; unsigned short *ProducerHeartBeatTime; short ProducerHeartBeatTimer; void (*heartbeatError)(struct struct_CO_Data *, unsigned char); enum enum_nodeState NMTable[128]; short GuardTimeTimer; short LifeTimeTimer; void (*nodeguardError)(struct struct_CO_Data *, unsigned char); unsigned short *GuardTime; unsigned char *LifeTimeFactor; unsigned char nodeGuardStatus[128]; short syncTimer; unsigned long *COB_ID_Sync; unsigned long *Sync_Cycle_Period; void (*post_sync)(struct struct_CO_Data *); void (*post_TPDO)(struct struct_CO_Data *); void (*post_SlaveBootup)(struct struct_CO_Data *, unsigned char); void (*post_SlaveStateChange)(struct struct_CO_Data *, unsigned char, enum enum_nodeState); unsigned char toggle; void *canHandle; struct td_indextable *(*scanIndexOD)(unsigned short wIndex, unsigned long *errorCode, unsigned long (***Callback)(struct struct_CO_Data *d, struct td_indextable *, unsigned char bSubindex)); void (*storeODSubIndex)(struct struct_CO_Data *d, unsigned short wIndex, unsigned char bSubindex); struct td_indextable *dcf_odentry; unsigned char *dcf_cursor; unsigned long dcf_entries_count; unsigned char dcf_status; unsigned long dcf_size; unsigned char *dcf_data; enum enum_errorState error_state; unsigned char error_history_size; unsigned char *error_number; unsigned long *error_first_element; unsigned char *error_register; unsigned long *error_cobid; struct s_errors error_data[8]; void (*post_emcy)(struct struct_CO_Data *d, unsigned char nodeID, unsigned short errCode, unsigned char errReg); }

user_defined_types: struct struct_s_PDO_status { unsigned char transmit_type_parameter; short event_timer; short inhibit_timer; struct Message last_message; }

user_defined_types: struct struct_s_transfer { unsigned char CliServNbr; unsigned char whoami; unsigned char state; unsigned char toggle; unsigned long abortCode; unsigned short index; unsigned char subIndex; unsigned long count; unsigned long offset; unsigned char data[32]; unsigned char peerCRCsupport; unsigned char blksize; unsigned char ackseq; unsigned long objsize; unsigned char lastblockoffset; unsigned char seqno; unsigned char endfield; enum rxStep_t rxstep; unsigned char tmpData[8]; unsigned char dataType; short timer; void (*Callback)(struct struct_CO_Data *d, unsigned char nodeId); }


decompiled_code:
int __fastcall TestSlaveA_heartbeatError(__int64 a1, unsigned __int8 a2)
{
return printf("TestSlaveA_heartbeatError %d\n", a2);
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1, unsigned __int8 a2)
{
return printf("TestSlaveA_heartbeatError %d\n", a2);
}

original_code:
void TestSlaveA_heartbeatError(CO_Data* d, unsigned char heartbeatID)
{
 printf ("TestSlaveA_heartbeatError %d\n", heartbeatID);
}

canonical_original_code:
void TestSlaveA_heartbeatError(struct struct_CO_Data *d, unsigned char heartbeatID)
{
 printf ("TestSlaveA_heartbeatError %d\n", heartbeatID);
}

variable_types: struct struct_CO_Data { unsigned char *bDeviceNodeId; struct td_indextable { struct td_subindex { unsigned char bAccessType; unsigned char bDataType; unsigned long size; void *pObject; } *pSubindex; unsigned char bSubCount; unsigned short index; } *objdict; struct struct_s_PDO_status { unsigned char transmit_type_parameter; short event_timer; short inhibit_timer; struct Message { unsigned short cob_id; unsigned char rtr; unsigned char len; unsigned char data[8]; } last_message; } *PDO_status; short *RxPDO_EventTimers; void (*RxPDO_EventTimers_Handler)(struct struct_CO_Data *, unsigned long); struct s_quick_index { unsigned short SDO_SVR; unsigned short SDO_CLT; unsigned short PDO_RCV; unsigned short PDO_RCV_MAP; unsigned short PDO_TRS; unsigned short PDO_TRS_MAP; } *firstIndex; struct s_quick_index *lastIndex; unsigned short *ObjdictSize; unsigned char *iam_a_slave; unsigned long (*valueRangeTest)(unsigned char typeValue, void *Value); struct struct_s_transfer { unsigned char CliServNbr; unsigned char whoami; unsigned char state; unsigned char toggle; unsigned long abortCode; unsigned short index; unsigned char subIndex; unsigned long count; unsigned long offset; unsigned char data[32]; unsigned char peerCRCsupport; unsigned char blksize; unsigned char ackseq; unsigned long objsize; unsigned char lastblockoffset; unsigned char seqno; unsigned char endfield; enum rxStep_t { RXSTEP_INIT=0, RXSTEP_STARTED=1, RXSTEP_END=2 } rxstep; unsigned char tmpData[8]; unsigned char dataType; short timer; void (*Callback)(struct struct_CO_Data *d, unsigned char nodeId); } transfers[4]; enum enum_nodeState { Initialisation=0, Disconnected=1, Connecting=2, Preparing=2, Stopped=4, Operational=5, Pre_operational=127, Unknown_state=15 } nodeState; struct s_state_communication { char csBoot_Up; char csSDO; char csEmergency; char csSYNC; char csLifeGuard; char csPDO; char csLSS; } CurrentCommunicationState; void (*initialisation)(struct struct_CO_Data *); void (*preOperational)(struct struct_CO_Data *); void (*operational)(struct struct_CO_Data *); void (*stopped)(struct struct_CO_Data *); void (*NMT_Slave_Node_Reset_Callback)(struct struct_CO_Data *); void (*NMT_Slave_Communications_Reset_Callback)(struct struct_CO_Data *); unsigned char *ConsumerHeartbeatCount; unsigned long *ConsumerHeartbeatEntries; short *ConsumerHeartBeatTimers; unsigned short *ProducerHeartBeatTime; short ProducerHeartBeatTimer; void (*heartbeatError)(struct struct_CO_Data *, unsigned char); enum enum_nodeState { Initialisation=0, Disconnected=1, Connecting=2, Preparing=2, Stopped=4, Operational=5, Pre_operational=127, Unknown_state=15 } NMTable[128]; short GuardTimeTimer; short LifeTimeTimer; void (*nodeguardError)(struct struct_CO_Data *, unsigned char); unsigned short *GuardTime; unsigned char *LifeTimeFactor; unsigned char nodeGuardStatus[128]; short syncTimer; unsigned long *COB_ID_Sync; unsigned long *Sync_Cycle_Period; void (*post_sync)(struct struct_CO_Data *); void (*post_TPDO)(struct struct_CO_Data *); void (*post_SlaveBootup)(struct struct_CO_Data *, unsigned char); void (*post_SlaveStateChange)(struct struct_CO_Data *, unsigned char, enum enum_nodeState { Initialisation=0, Disconnected=1, Connecting=2, Preparing=2, Stopped=4, Operational=5, Pre_operational=127, Unknown_state=15 }); unsigned char toggle; void *canHandle; struct td_indextable *(*scanIndexOD)(unsigned short wIndex, unsigned long *errorCode, unsigned long (***Callback)(struct struct_CO_Data *d, struct td_indextable *, unsigned char bSubindex)); void (*storeODSubIndex)(struct struct_CO_Data *d, unsigned short wIndex, unsigned char bSubindex); struct td_indextable *dcf_odentry; unsigned char *dcf_cursor; unsigned long dcf_entries_count; unsigned char dcf_status; unsigned long dcf_size; unsigned char *dcf_data; enum enum_errorState { Error_free=0, Error_occurred=1 } error_state; unsigned char error_history_size; unsigned char *error_number; unsigned long *error_first_element; unsigned char *error_register; unsigned long *error_cobid; struct s_errors { unsigned short errCode; unsigned char errRegMask; unsigned char active; } error_data[8]; void (*post_emcy)(struct struct_CO_Data *d, unsigned char nodeID, unsigned short errCode, unsigned char errReg); } *

variable_types:
heartbeatID
unsigned char

return_type: void


decompiled_code:
int TestSlaveA_initialisation()
{
return puts("TestSlaveA_initialisation");
}

canonical_decompiled_code:
int func1()
{
return puts("TestSlaveA_initialisation");
}

original_code:
void TestSlaveA_initialisation(CO_Data* d)
{
 printf ("TestSlaveA_initialisation\n");
}

canonical_original_code:
void TestSlaveA_initialisation(struct struct_CO_Data *d)
{
 printf ("TestSlaveA_initialisation\n");
}

user_defined_types: enum enum_nodeState { Initialisation=0, Disconnected=1, Connecting=2, Preparing=2, Stopped=4, Operational=5, Pre_operational=127, Unknown_state=15 }

user_defined_types: struct s_state_communication { char csBoot_Up; char csSDO; char csEmergency; char csSYNC; char csLifeGuard; char csPDO; char csLSS; }

user_defined_types: enum enum_errorState { Error_free=0, Error_occurred=1 }

user_defined_types: struct s_quick_index { unsigned short SDO_SVR; unsigned short SDO_CLT; unsigned short PDO_RCV; unsigned short PDO_RCV_MAP; unsigned short PDO_TRS; unsigned short PDO_TRS_MAP; }

user_defined_types: struct s_errors { unsigned short errCode; unsigned char errRegMask; unsigned char active; }

user_defined_types: struct Message { unsigned short cob_id; unsigned char rtr; unsigned char len; unsigned char data[8]; }

user_defined_types: enum rxStep_t { RXSTEP_INIT=0, RXSTEP_STARTED=1, RXSTEP_END=2 }

user_defined_types: struct td_subindex { unsigned char bAccessType; unsigned char bDataType; unsigned long size; void *pObject; }


decompiled_code:
int TestSlaveA_preOperational()
{
return puts("TestSlaveA_preOperational");
}

canonical_decompiled_code:
int func2()
{
return puts("TestSlaveA_preOperational");
}

original_code:
void TestSlaveA_preOperational(CO_Data* d)
{
 printf ("TestSlaveA_preOperational\n");
}

canonical_original_code:
void TestSlaveA_preOperational(struct struct_CO_Data *d)
{
 printf ("TestSlaveA_preOperational\n");
}


decompiled_code:
int TestSlaveA_operational()
{
return puts("TestSlaveA_operational");
}

canonical_decompiled_code:
int func3()
{
return puts("TestSlaveA_operational");
}

original_code:
void TestSlaveA_operational(CO_Data* d)
{
 printf ("TestSlaveA_operational\n");
}

canonical_original_code:
void TestSlaveA_operational(struct struct_CO_Data *d)
{
 printf ("TestSlaveA_operational\n");
}


decompiled_code:
int TestSlaveA_stopped()
{
return puts("TestSlaveA_stopped");
}

canonical_decompiled_code:
int func4()
{
return puts("TestSlaveA_stopped");
}

original_code:
void TestSlaveA_stopped(CO_Data* d)
{
 printf ("TestSlaveA_stopped\n");
}

canonical_original_code:
void TestSlaveA_stopped(struct struct_CO_Data *d)
{
 printf ("TestSlaveA_stopped\n");
}


decompiled_code:
int TestSlaveA_post_sync()
{
return puts("TestSlaveA_post_sync");
}

canonical_decompiled_code:
int func5()
{
return puts("TestSlaveA_post_sync");
}

original_code:
void TestSlaveA_post_sync(CO_Data* d)
{
      printf ("TestSlaveA_post_sync\n");
}

canonical_original_code:
void TestSlaveA_post_sync(struct struct_CO_Data *d)
{
      printf ("TestSlaveA_post_sync\n");
}


decompiled_code:
void *TestSlaveA_post_TPDO()
{
void *result; // rax

puts("TestSlaveA_post_TPDO");
++SlaveAMap1;
result = &SlaveAMap2;
SlaveAMap2 += 2;
return result;
}

canonical_decompiled_code:
void *func6()
{
void *result; // rax

puts("TestSlaveA_post_TPDO");
++SlaveAMap1;
result = &SlaveAMap2;
SlaveAMap2 += 2;
return result;
}

original_code:
void TestSlaveA_post_TPDO(CO_Data* d)
{
 printf ("TestSlaveA_post_TPDO\n");
 SlaveAMap1++;
 SlaveAMap2+=2;
}

canonical_original_code:
void TestSlaveA_post_TPDO(struct struct_CO_Data *d)
{
 printf ("TestSlaveA_post_TPDO\n");
 SlaveAMap1++;
 SlaveAMap2+=2;
}


decompiled_code:
int __fastcall TestSlaveA_storeODSubIndex(__int64 a1, unsigned __int16 a2, unsigned __int8 a3)
{
return printf("TestSlaveA_storeODSubIndex : %4.4x %2.2x\n", a2, a3);
}

canonical_decompiled_code:
int __fastcall func7(__int64 a1, unsigned __int16 a2, unsigned __int8 a3)
{
return printf("TestSlaveA_storeODSubIndex : %4.4x %2.2x\n", a2, a3);
}

original_code:
void TestSlaveA_storeODSubIndex(CO_Data* d, unsigned short wIndex, unsigned char bSubindex)
{
 printf ("TestSlaveA_storeODSubIndex : %4.4x %2.2x\n", wIndex, bSubindex);
}

canonical_original_code:
void TestSlaveA_storeODSubIndex(struct struct_CO_Data *d, unsigned short wIndex, unsigned char bSubindex)
{
 printf ("TestSlaveA_storeODSubIndex : %4.4x %2.2x\n", wIndex, bSubindex);
}

variable_types:
bSubindex
unsigned char


decompiled_code:
int __fastcall TestSlaveA_post_emcy(__int64 a1, unsigned __int8 a2, unsigned __int16 a3, unsigned __int8 a4)
{
return printf("SlaveA received EMCY message. Node: %2.2x ErrorCode: %4.4x ErrorRegister: %2.2x\n", a2, a3, a4);
}

canonical_decompiled_code:
int __fastcall func8(__int64 a1, unsigned __int8 a2, unsigned __int16 a3, unsigned __int8 a4)
{
return printf("SlaveA received EMCY message. Node: %2.2x ErrorCode: %4.4x ErrorRegister: %2.2x\n", a2, a3, a4);
}

original_code:
void TestSlaveA_post_emcy(CO_Data* d, unsigned char nodeID, unsigned short errCode, unsigned char errReg)
{
 printf ("SlaveA received EMCY message. Node: %2.2x  ErrorCode: %4.4x  ErrorRegister: %2.2x\n", nodeID, errCode, errReg);
}

canonical_original_code:
void TestSlaveA_post_emcy(struct struct_CO_Data *d, unsigned char nodeID, unsigned short errCode, unsigned char errReg)
{
 printf ("SlaveA received EMCY message. Node: %2.2x  ErrorCode: %4.4x  ErrorRegister: %2.2x\n", nodeID, errCode, errReg);
}

variable_types:
nodeID
unsigned char

variable_types:
errCode
unsigned short

variable_types:
errReg
unsigned char


decompiled_code:
int TestSlaveA_NMT_Slave_Communications_Reset_Callback()
{
return puts("TestSlaveA_NMT_Slave_Communications_Reset_Callback");
}

canonical_decompiled_code:
int func9()
{
return puts("TestSlaveA_NMT_Slave_Communications_Reset_Callback");
}

original_code:
void TestSlaveA_NMT_Slave_Communications_Reset_Callback(CO_Data* d)
{
 printf ("TestSlaveA_NMT_Slave_Communications_Reset_Callback\n");
}

canonical_original_code:
void TestSlaveA_NMT_Slave_Communications_Reset_Callback(struct struct_CO_Data *d)
{
 printf ("TestSlaveA_NMT_Slave_Communications_Reset_Callback\n");
}


decompiled_code:
int TestSlaveA_StoreConfiguration()
{
return puts("TestSlaveA_StoreConfiguration");
}

canonical_decompiled_code:
int func10()
{
return puts("TestSlaveA_StoreConfiguration");
}

original_code:
void TestSlaveA_StoreConfiguration(CO_Data* d, unsigned char *error, unsigned char *spec_error)
{
 printf ("TestSlaveA_StoreConfiguration\n");
}

canonical_original_code:
void TestSlaveA_StoreConfiguration(struct struct_CO_Data *d, unsigned char *error, unsigned char *spec_error)
{
 printf ("TestSlaveA_StoreConfiguration\n");
}

variable_types:
error
unsigned char *


decompiled_code:
__int64 __fastcall TestMaster_valueRangeTest(char a1, _BYTE *a2)
{
__int64 result; // rax

result = 0LL;
if ( a1 == -97 )
result = *a2 != 0 ? 0x6090030 : 0;
return result;
}

original_code:
unsigned long int TestMaster_valueRangeTest (unsigned char typeValue, void * value)
{
  switch (typeValue) {
    case 0x9F:
      if (*(unsigned char*)value != (unsigned char)0) return 0x06090030;
      break;
  }
  return 0;
}

canonical_original_code:
unsigned long TestMaster_valueRangeTest(unsigned char typeValue, void *value)
{
  switch (typeValue) {
    case 0x9F:
      if (*(unsigned char *)value != (unsigned char)0) return 0x06090030;
      break;
  }
  return 0;
}


original_code:
unsigned char init_consise_dcf(CO_Data* d,unsigned char nodeId)
{
    unsigned long int errorCode;
    ODCallback_t *Callback;
    unsigned char* dcf;
    d->dcf_odentry = (*d->scanIndexOD)(0x1F22, &errorCode, &Callback);
    if (errorCode != 0x00000000) goto DCF_finish;
    if(nodeId > d->dcf_odentry->bSubCount) goto DCF_finish;
    if(! d->dcf_odentry->pSubindex[nodeId].size) goto DCF_finish;
    dcf = *(unsigned char**)d->dcf_odentry->pSubindex[nodeId].pObject;
    d->dcf_cursor = dcf + 4;
    d->dcf_entries_count = 0;
    d->dcf_status = 0;
    return 1;
    DCF_finish:
    return 0;
}

canonical_original_code:
unsigned char init_consise_dcf(struct struct_CO_Data *d, unsigned char nodeId)
{
    unsigned long errorCode;
    unsigned long (**Callback)(struct struct_CO_Data *d, struct td_indextable *, unsigned char bSubindex);
    unsigned char *dcf;
    d->dcf_odentry = (*d->scanIndexOD)(0x1F22, &errorCode, &Callback);
    if (errorCode != 0x00000000) goto DCF_finish;
    if(nodeId > d->dcf_odentry->bSubCount) goto DCF_finish;
    if(! d->dcf_odentry->pSubindex[nodeId].size) goto DCF_finish;
    dcf = *(unsigned char **)d->dcf_odentry->pSubindex[nodeId].pObject;
    d->dcf_cursor = dcf + 4;
    d->dcf_entries_count = 0;
    d->dcf_status = 0;
    return 1;
    DCF_finish:
    return 0;
}

variable_types:
nodeId
unsigned char

variable_types:
errorCode
unsigned long

variable_types: unsigned long (**)(struct struct_CO_Data { unsigned char *bDeviceNodeId; struct td_indextable { struct td_subindex { unsigned char bAccessType; unsigned char bDataType; unsigned long size; void *pObject; } *pSubindex; unsigned char bSubCount; unsigned short index; } *objdict; struct struct_s_PDO_status { unsigned char transmit_type_parameter; short event_timer; short inhibit_timer; struct Message { unsigned short cob_id; unsigned char rtr; unsigned char len; unsigned char data[8]; } last_message; } *PDO_status; short *RxPDO_EventTimers; void (*RxPDO_EventTimers_Handler)(struct struct_CO_Data *, unsigned long); struct s_quick_index { unsigned short SDO_SVR; unsigned short SDO_CLT; unsigned short PDO_RCV; unsigned short PDO_RCV_MAP; unsigned short PDO_TRS; unsigned short PDO_TRS_MAP; } *firstIndex; struct s_quick_index *lastIndex; unsigned short *ObjdictSize; unsigned char *iam_a_slave; unsigned long (*valueRangeTest)(unsigned char typeValue, void *Value); struct struct_s_transfer { unsigned char CliServNbr; unsigned char whoami; unsigned char state; unsigned char toggle; unsigned long abortCode; unsigned short index; unsigned char subIndex; unsigned long count; unsigned long offset; unsigned char data[32]; unsigned char peerCRCsupport; unsigned char blksize; unsigned char ackseq; unsigned long objsize; unsigned char lastblockoffset; unsigned char seqno; unsigned char endfield; enum rxStep_t { RXSTEP_INIT=0, RXSTEP_STARTED=1, RXSTEP_END=2 } rxstep; unsigned char tmpData[8]; unsigned char dataType; short timer; void (*Callback)(struct struct_CO_Data *d, unsigned char nodeId); } transfers[4]; enum enum_nodeState { Initialisation=0, Disconnected=1, Connecting=2, Preparing=2, Stopped=4, Operational=5, Pre_operational=127, Unknown_state=15 } nodeState; struct s_state_communication { char csBoot_Up; char csSDO; char csEmergency; char csSYNC; char csLifeGuard; char csPDO; char csLSS; } CurrentCommunicationState; void (*initialisation)(struct struct_CO_Data *); void (*preOperational)(struct struct_CO_Data *); void (*operational)(struct struct_CO_Data *); void (*stopped)(struct struct_CO_Data *); void (*NMT_Slave_Node_Reset_Callback)(struct struct_CO_Data *); void (*NMT_Slave_Communications_Reset_Callback)(struct struct_CO_Data *); unsigned char *ConsumerHeartbeatCount; unsigned long *ConsumerHeartbeatEntries; short *ConsumerHeartBeatTimers; unsigned short *ProducerHeartBeatTime; short ProducerHeartBeatTimer; void (*heartbeatError)(struct struct_CO_Data *, unsigned char); enum enum_nodeState { Initialisation=0, Disconnected=1, Connecting=2, Preparing=2, Stopped=4, Operational=5, Pre_operational=127, Unknown_state=15 } NMTable[128]; short GuardTimeTimer; short LifeTimeTimer; void (*nodeguardError)(struct struct_CO_Data *, unsigned char); unsigned short *GuardTime; unsigned char *LifeTimeFactor; unsigned char nodeGuardStatus[128]; short syncTimer; unsigned long *COB_ID_Sync; unsigned long *Sync_Cycle_Period; void (*post_sync)(struct struct_CO_Data *); void (*post_TPDO)(struct struct_CO_Data *); void (*post_SlaveBootup)(struct struct_CO_Data *, unsigned char); void (*post_SlaveStateChange)(struct struct_CO_Data *, unsigned char, enum enum_nodeState { Initialisation=0, Disconnected=1, Connecting=2, Preparing=2, Stopped=4, Operational=5, Pre_operational=127, Unknown_state=15 }); unsigned char toggle; void *canHandle; struct td_indextable *(*scanIndexOD)(unsigned short wIndex, unsigned long *errorCode, unsigned long (***Callback)(struct struct_CO_Data *d, struct td_indextable *, unsigned char bSubindex)); void (*storeODSubIndex)(struct struct_CO_Data *d, unsigned short wIndex, unsigned char bSubindex); struct td_indextable *dcf_odentry; unsigned char *dcf_cursor; unsigned long dcf_entries_count; unsigned char dcf_status; unsigned long dcf_size; unsigned char *dcf_data; enum enum_errorState { Error_free=0, Error_occurred=1 } error_state; unsigned char error_history_size; unsigned char *error_number; unsigned long *error_first_element; unsigned char *error_register; unsigned long *error_cobid; struct s_errors { unsigned short errCode; unsigned char errRegMask; unsigned char active; } error_data[8]; void (*post_emcy)(struct struct_CO_Data *d, unsigned char nodeID, unsigned short errCode, unsigned char errReg); } *d, struct td_indextable *, unsigned char bSubindex)

variable_types:
dcf
unsigned char *

return_type: unsigned char


original_code:
unsigned char get_next_DCF_data(CO_Data* d, dcf_entry_t *dcf_entry, unsigned char nodeId)
{
  unsigned char* dcfend;
  unsigned long int nb_entries;
  unsigned long int szData;
  unsigned char* dcf;
  if(!d->dcf_odentry)
     return 0;
  if(nodeId > d->dcf_odentry->bSubCount)
     return 0;
  szData = d->dcf_odentry->pSubindex[nodeId].size;
  dcf = *(unsigned char**)d->dcf_odentry->pSubindex[nodeId].pObject;
  nb_entries = (*((unsigned long int*)dcf));
  dcfend = dcf + szData;
  if((unsigned char*)d->dcf_cursor + 7 < (unsigned char*)dcfend && d->dcf_entries_count < nb_entries){
    memcpy(&dcf_entry->Index, d->dcf_cursor,2);
        d->dcf_cursor+=2;
    dcf_entry->Subindex = *(d->dcf_cursor++);
    memcpy(&dcf_entry->Size, d->dcf_cursor,4);
    d->dcf_cursor+=4;
    d->dcf_data = dcf_entry->Data = d->dcf_cursor;
    d->dcf_size = dcf_entry->Size;
    d->dcf_cursor += dcf_entry->Size;
    d->dcf_entries_count++;
    return 1;
  }
  return 0;
}

canonical_original_code:
unsigned char get_next_DCF_data(struct struct_CO_Data *d, struct dcf_entry_t *dcf_entry, unsigned char nodeId)
{
  unsigned char *dcfend;
  unsigned long nb_entries;
  unsigned long szData;
  unsigned char *dcf;
  if(!d->dcf_odentry)
     return 0;
  if(nodeId > d->dcf_odentry->bSubCount)
     return 0;
  szData = d->dcf_odentry->pSubindex[nodeId].size;
  dcf = *(unsigned char **)d->dcf_odentry->pSubindex[nodeId].pObject;
  nb_entries = (*((unsigned long *)dcf));
  dcfend = dcf + szData;
  if((unsigned char *)d->dcf_cursor + 7 < (unsigned char *)dcfend && d->dcf_entries_count < nb_entries){
    memcpy(&dcf_entry->Index, d->dcf_cursor,2);
        d->dcf_cursor+=2;
    dcf_entry->Subindex = *(d->dcf_cursor++);
    memcpy(&dcf_entry->Size, d->dcf_cursor,4);
    d->dcf_cursor+=4;
    d->dcf_data = dcf_entry->Data = d->dcf_cursor;
    d->dcf_size = dcf_entry->Size;
    d->dcf_cursor += dcf_entry->Size;
    d->dcf_entries_count++;
    return 1;
  }
  return 0;
}

variable_types: struct dcf_entry_t { unsigned short Index; unsigned char Subindex; unsigned long Size; unsigned char *Data; } *

variable_types:
dcfend
unsigned char *

variable_types:
szData
unsigned long


decompiled_code:
__int64 __fastcall read_consise_dcf_next_entry(_QWORD *a1, unsigned __int8 a2)
{
__int64 result; // rax
unsigned __int16 v3; // [rsp+0h] [rbp-38h] BYREF
unsigned __int8 v4; // [rsp+2h] [rbp-36h]

result = get_next_DCF_data(a1, (__int64)&v3, a2);
if ( (_BYTE)result )
{
readNetworkDictCallbackAI(a1, a2, v3, v4, 0LL, CheckSDOAndContinue, 0LL);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(_QWORD *a1, unsigned __int8 a2)
{
__int64 result; // rax
unsigned __int16 v3; // [rsp+0h] [rbp-38h] BYREF
unsigned __int8 v4; // [rsp+2h] [rbp-36h]

result = func1(a1, (__int64)&v3, a2);
if ( (_BYTE)result )
{
readNetworkDictCallbackAI(a1, a2, v3, v4, 0LL, CheckSDOAndContinue, 0LL);
result = 1LL;
}
return result;
}

original_code:
static unsigned char read_consise_dcf_next_entry(CO_Data* d, unsigned char nodeId)
{
    unsigned char Ret;
    dcf_entry_t dcf_entry;
    if(!get_next_DCF_data(d, &dcf_entry, nodeId))
        return 0;
    Ret = readNetworkDictCallbackAI(d,
                   nodeId,
                   dcf_entry.Index,
                   dcf_entry.Subindex,
                   0,
                   CheckSDOAndContinue,
                   0);
    if(Ret)
        ;
    return 1;
}

canonical_original_code:
static unsigned char read_consise_dcf_next_entry(struct struct_CO_Data *d, unsigned char nodeId)
{
    unsigned char Ret;
    struct dcf_entry_t dcf_entry;
    if(!get_next_DCF_data(d, &dcf_entry, nodeId))
        return 0;
    Ret = readNetworkDictCallbackAI(d,
                   nodeId,
                   dcf_entry.Index,
                   dcf_entry.Subindex,
                   0,
                   CheckSDOAndContinue,
                   0);
    if(Ret)
        ;
    return 1;
}

variable_types:
Ret
unsigned char

variable_types: struct dcf_entry_t { unsigned short Index; unsigned char Subindex; unsigned long Size; unsigned char *Data; }


decompiled_code:
__int64 __fastcall check_and_start_node(__int64 a1, unsigned __int8 a2)
{
__int64 result; // rax

result = 0LL;
if ( !*(_BYTE *)(a1 + 1456) )
{
if ( (unsigned __int8)init_consise_dcf(a1, a2) && (unsigned __int8)read_consise_dcf_next_entry((_QWORD *)a1, a2) )
{
*(_BYTE *)(a1 + 1456) = 1;
result = 2LL;
}
else
{
start_node(a1, a2);
result = 1LL;
}
}
return result;
}

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

result = 0LL;
if ( !*(_BYTE *)(a1 + 1456) )
{
if ( (unsigned __int8)func0(a1, a2) && (unsigned __int8)func2((_QWORD *)a1, a2) )
{
*(_BYTE *)(a1 + 1456) = 1;
result = 2LL;
}
else
{
start_node(a1, a2);
result = 1LL;
}
}
return result;
}

original_code:
unsigned char check_and_start_node(CO_Data* d, unsigned char nodeId)
{
    if(d->dcf_status != 0)
        return 0;
    if((init_consise_dcf(d, nodeId) == 0) || (read_consise_dcf_next_entry(d, nodeId) == 0)){
        start_node(d, nodeId);
        return 1;
    }
    d->dcf_status = 1;
    return 2;
}

canonical_original_code:
unsigned char check_and_start_node(struct struct_CO_Data *d, unsigned char nodeId)
{
    if(d->dcf_status != 0)
        return 0;
    if((init_consise_dcf(d, nodeId) == 0) || (read_consise_dcf_next_entry(d, nodeId) == 0)){
        start_node(d, nodeId);
        return 1;
    }
    d->dcf_status = 1;
    return 2;
}


decompiled_code:
__int64 __fastcall write_consise_dcf_next_entry(_QWORD *a1, unsigned __int8 a2)
{
__int64 result; // rax
unsigned __int16 v3; // [rsp+0h] [rbp-38h] BYREF
unsigned __int8 v4; // [rsp+2h] [rbp-36h]
unsigned __int8 v5; // [rsp+8h] [rbp-30h]
__int64 v6; // [rsp+10h] [rbp-28h]

result = get_next_DCF_data(a1, (__int64)&v3, a2);
if ( (_BYTE)result )
{
writeNetworkDictCallBackAI(a1, a2, v3, v4, v5, 0LL, v6, CheckSDOAndContinue, 0LL, 0LL);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(_QWORD *a1, unsigned __int8 a2)
{
__int64 result; // rax
unsigned __int16 v3; // [rsp+0h] [rbp-38h] BYREF
unsigned __int8 v4; // [rsp+2h] [rbp-36h]
unsigned __int8 v5; // [rsp+8h] [rbp-30h]
__int64 v6; // [rsp+10h] [rbp-28h]

result = func1(a1, (__int64)&v3, a2);
if ( (_BYTE)result )
{
writeNetworkDictCallBackAI(a1, a2, v3, v4, v5, 0LL, v6, CheckSDOAndContinue, 0LL, 0LL);
result = 1LL;
}
return result;
}

original_code:
static unsigned char write_consise_dcf_next_entry(CO_Data* d, unsigned char nodeId)
{
    unsigned char Ret;
    dcf_entry_t dcf_entry;
    if(!get_next_DCF_data(d, &dcf_entry, nodeId))
        return 0;
    Ret = writeNetworkDictCallBackAI(d,
                    nodeId,
                    dcf_entry.Index,
                    dcf_entry.Subindex,
                    (unsigned char)dcf_entry.Size,
                    0,
                    dcf_entry.Data,
                    CheckSDOAndContinue,
                    0,
                    0);
    if(Ret)
        ;
    return 1;
}

canonical_original_code:
static unsigned char write_consise_dcf_next_entry(struct struct_CO_Data *d, unsigned char nodeId)
{
    unsigned char Ret;
    struct dcf_entry_t dcf_entry;
    if(!get_next_DCF_data(d, &dcf_entry, nodeId))
        return 0;
    Ret = writeNetworkDictCallBackAI(d,
                    nodeId,
                    dcf_entry.Index,
                    dcf_entry.Subindex,
                    (unsigned char)dcf_entry.Size,
                    0,
                    dcf_entry.Data,
                    CheckSDOAndContinue,
                    0,
                    0);
    if(Ret)
        ;
    return 1;
}

user_defined_types: struct dcf_entry_t { unsigned short Index; unsigned char Subindex; unsigned long Size; unsigned char *Data; }


SaveNode

decompiled_code:
__int64 __fastcall SaveNode(__int64 a1, unsigned __int8 a2)
{
__int64 v3; // [rsp+8h] [rbp-10h] BYREF

v3 = 1702257011LL;
return writeNetworkDictCallBackAI(a1, a2, 4112LL, 1LL, 4LL, 0LL, &v3, CheckSDOAndContinue, 0LL, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, unsigned __int8 a2)
{
__int64 v3; // [rsp+8h] [rbp-10h] BYREF

v3 = 1702257011LL;
return writeNetworkDictCallBackAI(a1, a2, 4112LL, 1LL, 4LL, 0LL, &v3, CheckSDOAndContinue, 0LL, 0LL);
}

original_code:
void SaveNode(CO_Data* d, unsigned char nodeId)
{
    unsigned char Ret;
    unsigned long int data=0x65766173;
    Ret = writeNetworkDictCallBackAI(d,
                    nodeId,
                    0x1010,
                    1,
                    4,
                    0,
                    (void *)&data,
                    CheckSDOAndContinue,
                    0,
                    0);
    if(Ret)
        ;
}

canonical_original_code:
void SaveNode(struct struct_CO_Data *d, unsigned char nodeId)
{
    unsigned char Ret;
    unsigned long data = 0x65766173;
    Ret = writeNetworkDictCallBackAI(d,
                    nodeId,
                    0x1010,
                    1,
                    4,
                    0,
                    (void *)&data,
                    CheckSDOAndContinue,
                    0,
                    0);
    if(Ret)
        ;
}

variable_types:
data
unsigned long


CheckSDOAndContinue

decompiled_code:
__int64 __fastcall CheckSDOAndContinue(__int64 a1, unsigned __int8 a2)
{
__int64 result; // rax
__int64 v3; // rbp
char v4; // dl
__int64 v5; // rcx
__int64 v6; // rax
__int64 v7; // rsi
char v8[4]; // [rsp+Ch] [rbp-2Ch] BYREF
__int64 v9; // [rsp+10h] [rbp-28h] BYREF
__int64 v10[4]; // [rsp+18h] [rbp-20h] BYREF

result = *(unsigned __int8 *)(a1 + 1456);
v9 = 0LL;
v10[0] = 4LL;
switch ( (_BYTE)result )
{
case 1:
v3 = a2;
result = getReadResultNetworkDict(a1, a2, v8, v10, &v9);
v4 = result;
if ( (_BYTE)result != 1 )
goto LABEL_16;
v5 = v10[0];
if ( *(_QWORD *)(a1 + 1464) != v10[0] )
goto LABEL_20;
v6 = --v10[0];
if ( v5 )
{
v7 = *(_QWORD *)(a1 + 1472);
do
{
if ( v8[v6] != *(_BYTE *)(v7 + v6) )
v4 = 0;
v10[0] = --v6;
}
while ( v6 != -1 );
if ( !v4 )
{
LABEL_20:
result = init_consise_dcf(a1, v3);
if ( (_BYTE)result )
{
result = write_consise_dcf_next_entry((_QWORD *)a1, v3);
if ( (_BYTE)result )
{
*(_BYTE *)(a1 + 1456) = 2;
return result;
}
}
goto LABEL_16;
}
}
result = read_consise_dcf_next_entry((_QWORD *)a1, v3);
if ( !(_BYTE)result )
return start_and_seek_node(a1, (unsigned int)v3);
break;
case 2:
v3 = a2;
result = getWriteResultNetworkDict(a1, a2, &v9);
if ( (_BYTE)result != 1 )
goto LABEL_16;
result = write_consise_dcf_next_entry((_QWORD *)a1, a2);
if ( !(_BYTE)result )
{
*(_BYTE *)(a1 + 1456) = 0;
return start_and_seek_node(a1, (unsigned int)v3);
}
break;
case 3:
v3 = a2;
result = getWriteResultNetworkDict(a1, a2, &v9);
if ( (_BYTE)result == 1 )
{
result = masterSendNMTstateChange(a1, a2, 129LL);
*(_BYTE *)(a1 + 1456) = 0;
*(_DWORD *)(a1 + 4LL * a2 + 672) = 15;
return result;
}
LABEL_16:
*(_DWORD *)(a1 + 4 * v3 + 672) = 15;
return result;
default:
return result;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, unsigned __int8 a2)
{
__int64 result; // rax
__int64 v3; // rbp
char v4; // dl
__int64 v5; // rcx
__int64 v6; // rax
__int64 v7; // rsi
char v8[4]; // [rsp+Ch] [rbp-2Ch] BYREF
__int64 v9; // [rsp+10h] [rbp-28h] BYREF
__int64 v10[4]; // [rsp+18h] [rbp-20h] BYREF

result = *(unsigned __int8 *)(a1 + 1456);
v9 = 0LL;
v10[0] = 4LL;
switch ( (_BYTE)result )
{
case 1:
v3 = a2;
result = getReadResultNetworkDict(a1, a2, v8, v10, &v9);
v4 = result;
if ( (_BYTE)result != 1 )
goto LABEL_16;
v5 = v10[0];
if ( *(_QWORD *)(a1 + 1464) != v10[0] )
goto LABEL_20;
v6 = --v10[0];
if ( v5 )
{
v7 = *(_QWORD *)(a1 + 1472);
do
{
if ( v8[v6] != *(_BYTE *)(v7 + v6) )
v4 = 0;
v10[0] = --v6;
}
while ( v6 != -1 );
if ( !v4 )
{
LABEL_20:
result = func0(a1, v3);
if ( (_BYTE)result )
{
result = func4((_QWORD *)a1, v3);
if ( (_BYTE)result )
{
*(_BYTE *)(a1 + 1456) = 2;
return result;
}
}
goto LABEL_16;
}
}
result = func2((_QWORD *)a1, v3);
if ( !(_BYTE)result )
return start_and_seek_node(a1, (unsigned int)v3);
break;
case 2:
v3 = a2;
result = getWriteResultNetworkDict(a1, a2, &v9);
if ( (_BYTE)result != 1 )
goto LABEL_16;
result = func4((_QWORD *)a1, a2);
if ( !(_BYTE)result )
{
*(_BYTE *)(a1 + 1456) = 0;
return start_and_seek_node(a1, (unsigned int)v3);
}
break;
case 3:
v3 = a2;
result = getWriteResultNetworkDict(a1, a2, &v9);
if ( (_BYTE)result == 1 )
{
result = masterSendNMTstateChange(a1, a2, 129LL);
*(_BYTE *)(a1 + 1456) = 0;
*(_DWORD *)(a1 + 4LL * a2 + 672) = 15;
return result;
}
LABEL_16:
*(_DWORD *)(a1 + 4 * v3 + 672) = 15;
return result;
default:
return result;
}
return result;
}

original_code:
static void CheckSDOAndContinue(CO_Data* d, unsigned char nodeId)
{
    unsigned long int abortCode = 0;
    unsigned char buf[4], match = 0, node;
    unsigned long int size=4;
    if(d->dcf_status == 1){
        if(getReadResultNetworkDict (d, nodeId, buf, &size, &abortCode) != 0x1)
            goto dcferror;
        if(size == d->dcf_size){
            match = 1;
            while(size--)
                if(buf[size] != d->dcf_data[size])
                    match = 0;
        }
        if(match) {
            if(read_consise_dcf_next_entry(d, nodeId) == 0){
                start_and_seek_node(d, nodeId);
            }
        }
        else {
            if((init_consise_dcf(d, nodeId) == 0) || (write_consise_dcf_next_entry(d, nodeId) == 0))
                goto dcferror;
            d->dcf_status = 2;
        }
    }
    else if(d->dcf_status == 2){
        if(getWriteResultNetworkDict (d, nodeId, &abortCode) != 0x1)
            goto dcferror;
        if(write_consise_dcf_next_entry(d, nodeId) == 0){
            d->dcf_status = 0;
           start_and_seek_node(d,nodeId);
        }
    }
    else if(d->dcf_status == 3){
        if(getWriteResultNetworkDict (d, nodeId, &abortCode) != 0x1)
            goto dcferror;
        masterSendNMTstateChange (d, nodeId, 0x81);
        d->dcf_status = 0;
        d->NMTable[nodeId] = Unknown_state;
    }
    return;
dcferror:
    ;
    ;
    d->NMTable[nodeId] = Unknown_state;
}

canonical_original_code:
static void CheckSDOAndContinue(struct struct_CO_Data *d, unsigned char nodeId)
{
    unsigned long abortCode = 0;
    unsigned char buf[4]; unsigned char match = 0; unsigned char node;
    unsigned long size = 4;
    if(d->dcf_status == 1){
        if(getReadResultNetworkDict (d, nodeId, buf, &size, &abortCode) != 0x1)
            goto dcferror;
        if(size == d->dcf_size){
            match = 1;
            while(size--)
                if(buf[size] != d->dcf_data[size])
                    match = 0;
        }
        if(match) {
            if(read_consise_dcf_next_entry(d, nodeId) == 0){
                start_and_seek_node(d, nodeId);
            }
        }
        else {
            if((init_consise_dcf(d, nodeId) == 0) || (write_consise_dcf_next_entry(d, nodeId) == 0))
                goto dcferror;
            d->dcf_status = 2;
        }
    }
    else if(d->dcf_status == 2){
        if(getWriteResultNetworkDict (d, nodeId, &abortCode) != 0x1)
            goto dcferror;
        if(write_consise_dcf_next_entry(d, nodeId) == 0){
            d->dcf_status = 0;
           start_and_seek_node(d,nodeId);
        }
    }
    else if(d->dcf_status == 3){
        if(getWriteResultNetworkDict (d, nodeId, &abortCode) != 0x1)
            goto dcferror;
        masterSendNMTstateChange (d, nodeId, 0x81);
        d->dcf_status = 0;
        d->NMTable[nodeId] = Unknown_state;
    }
    return;
dcferror:
    ;
    ;
    d->NMTable[nodeId] = Unknown_state;
}

variable_types: struct struct_CO_Data { unsigned char *bDeviceNodeId; struct td_indextable { struct td_subindex { unsigned char bAccessType; unsigned char bDataType; unsigned long size; void *pObject; } *pSubindex; unsigned char bSubCount; unsigned short index; } *objdict; struct struct_s_PDO_status { unsigned char transmit_type_parameter; short event_timer; short inhibit_timer; struct Message { unsigned short cob_id; unsigned char rtr; unsigned char len; unsigned char data[8]; } last_message; } *PDO_status; short *RxPDO_EventTimers; void (*RxPDO_EventTimers_Handler)(struct struct_CO_Data *, unsigned long); struct s_quick_index { unsigned short SDO_SVR; unsigned short SDO_CLT; unsigned short PDO_RCV; unsigned short PDO_RCV_MAP; unsigned short PDO_TRS; unsigned short PDO_TRS_MAP; } *firstIndex; struct s_quick_index *lastIndex; unsigned short *ObjdictSize; unsigned char *iam_a_slave; unsigned long (*valueRangeTest)(unsigned char typeValue, void *Value); struct struct_s_transfer { unsigned char CliServNbr; unsigned char whoami; unsigned char state; unsigned char toggle; unsigned long abortCode; unsigned short index; unsigned char subIndex; unsigned long count; unsigned long offset; unsigned char data[32]; unsigned char peerCRCsupport; unsigned char blksize; unsigned char ackseq; unsigned long objsize; unsigned char lastblockoffset; unsigned char seqno; unsigned char endfield; enum rxStep_t { RXSTEP_INIT=0, RXSTEP_STARTED=1, RXSTEP_END=2 } rxstep; unsigned char tmpData[8]; unsigned char dataType; short timer; void (*Callback)(struct struct_CO_Data *d, unsigned char nodeId); } transfers[4]; enum enum_nodeState { Initialisation=0, Disconnected=1, Connecting=2, Preparing=2, Stopped=4, Operational=5, Pre_operational=127, Unknown_state=15 } nodeState; struct s_state_communication { char csBoot_Up; char csSDO; char csEmergency; char csSYNC; char csLifeGuard; char csPDO; char csLSS; } CurrentCommunicationState; void (*initialisation)(struct struct_CO_Data *); void (*preOperational)(struct struct_CO_Data *); void (*operational)(struct struct_CO_Data *); void (*stopped)(struct struct_CO_Data *); void (*NMT_Slave_Node_Reset_Callback)(struct struct_CO_Data *); void (*NMT_Slave_Communications_Reset_Callback)(struct struct_CO_Data *); unsigned char *ConsumerHeartbeatCount; unsigned long *ConsumerHeartbeatEntries; short *ConsumerHeartBeatTimers; unsigned short *ProducerHeartBeatTime; short ProducerHeartBeatTimer; void (*heartbeatError)(struct struct_CO_Data *, unsigned char); enum enum_nodeState { Initialisation=0, Disconnected=1, Connecting=2, Preparing=2, Stopped=4, Operational=5, Pre_operational=127, Unknown_state=15 } NMTable[128]; short GuardTimeTimer; short LifeTimeTimer; void (*nodeguardError)(struct struct_CO_Data *, unsigned char); unsigned short *GuardTime; unsigned char *LifeTimeFactor; unsigned char nodeGuardStatus[128]; short syncTimer; unsigned long *COB_ID_Sync; unsigned long *Sync_Cycle_Period; void (*post_sync)(struct struct_CO_Data *); void (*post_TPDO)(struct struct_CO_Data *); void (*post_SlaveBootup)(struct struct_CO_Data *, unsigned char); void (*post_SlaveStateChange)(struct struct_CO_Data *, unsigned char, enum enum_nodeState { Initialisation=0, Disconnected=1, Connecting=2, Preparing=2, Stopped=4, Operational=5, Pre_operational=127, Unknown_state=15 }); unsigned char toggle; void *canHandle; struct td_indextable *(*scanIndexOD)(unsigned short wIndex, unsigned long *errorCode, unsigned long (***Callback)(struct struct_CO_Data *d, struct td_indextable *, unsigned char bSubindex)); void (*storeODSubIndex)(struct struct_CO_Data *d, unsigned short wIndex, unsigned char bSubindex); struct td_indextable *dcf_odentry; unsigned char *dcf_cursor; unsigned long dcf_entries_count; unsigned char dcf_status; unsigned long dcf_size; unsigned char *dcf_data; enum enum_errorState { Error_free=0, Error_occurred=1 } error_state; unsigned char error_history_size; unsigned char *error_number; unsigned long *error_first_element; unsigned char *error_register; unsigned long *error_cobid; struct s_errors { unsigned short errCode; unsigned char errRegMask; unsigned char active; } error_data[8]; void (*post_emcy)(struct struct_CO_Data *d, unsigned char nodeID, unsigned short errCode, unsigned char errReg); } *

variable_types:
abortCode
unsigned long

variable_types:
buf
unsigned char [4]

variable_types:
match
unsigned char

variable_types:
node
unsigned char

variable_types:
size
unsigned long


accessDictionaryError

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

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

original_code:
unsigned char accessDictionaryError(unsigned short index, unsigned char subIndex,
                           unsigned long int sizeDataDict, unsigned long int sizeDataGiven, unsigned long int code)
{
  return 0;
}

canonical_original_code:
unsigned char accessDictionaryError(unsigned short index, unsigned char subIndex, unsigned long sizeDataDict, unsigned long sizeDataGiven, unsigned long code)
{
  return 0;
}

variable_types:
index
unsigned short

variable_types:
subIndex
unsigned char

variable_types:
sizeDataDict
unsigned long

variable_types:
sizeDataGiven
unsigned long

variable_types:
code
unsigned long


scanIndexOD

decompiled_code:
__int64 __fastcall scanIndexOD(__int64 a1, unsigned __int16 a2, __int64 a3, __int64 a4)
{
return (*(__int64 (__fastcall **)(_QWORD, __int64, __int64))(a1 + 1416))(a2, a3, a4);
}

original_code:
const indextable * scanIndexOD (CO_Data* d, unsigned short wIndex, unsigned long int *errorCode, ODCallback_t **Callback)
{
  return (*d->scanIndexOD)(wIndex, errorCode, Callback);
}

canonical_original_code:
struct td_indextable *scanIndexOD(struct struct_CO_Data *d, unsigned short wIndex, unsigned long *errorCode, unsigned long (***Callback)(struct struct_CO_Data *d, struct td_indextable *, unsigned char bSubindex))
{
  return (*d->scanIndexOD)(wIndex, errorCode, Callback);
}

variable_types: struct struct_CO_Data { unsigned char *bDeviceNodeId; struct td_indextable *objdict; struct struct_s_PDO_status { unsigned char transmit_type_parameter; short event_timer; short inhibit_timer; struct Message { unsigned short cob_id; unsigned char rtr; unsigned char len; unsigned char data[8]; } last_message; } *PDO_status; short *RxPDO_EventTimers; void (*RxPDO_EventTimers_Handler)(struct struct_CO_Data *, unsigned long); struct s_quick_index { unsigned short SDO_SVR; unsigned short SDO_CLT; unsigned short PDO_RCV; unsigned short PDO_RCV_MAP; unsigned short PDO_TRS; unsigned short PDO_TRS_MAP; } *firstIndex; struct s_quick_index *lastIndex; unsigned short *ObjdictSize; unsigned char *iam_a_slave; unsigned long (*valueRangeTest)(unsigned char typeValue, void *Value); struct struct_s_transfer { unsigned char CliServNbr; unsigned char whoami; unsigned char state; unsigned char toggle; unsigned long abortCode; unsigned short index; unsigned char subIndex; unsigned long count; unsigned long offset; unsigned char data[32]; unsigned char peerCRCsupport; unsigned char blksize; unsigned char ackseq; unsigned long objsize; unsigned char lastblockoffset; unsigned char seqno; unsigned char endfield; enum rxStep_t { RXSTEP_INIT=0, RXSTEP_STARTED=1, RXSTEP_END=2 } rxstep; unsigned char tmpData[8]; unsigned char dataType; short timer; void (*Callback)(struct struct_CO_Data *d, unsigned char nodeId); } transfers[4]; enum enum_nodeState { Initialisation=0, Disconnected=1, Connecting=2, Preparing=2, Stopped=4, Operational=5, Pre_operational=127, Unknown_state=15 } nodeState; struct s_state_communication { char csBoot_Up; char csSDO; char csEmergency; char csSYNC; char csLifeGuard; char csPDO; char csLSS; } CurrentCommunicationState; void (*initialisation)(struct struct_CO_Data *); void (*preOperational)(struct struct_CO_Data *); void (*operational)(struct struct_CO_Data *); void (*stopped)(struct struct_CO_Data *); void (*NMT_Slave_Node_Reset_Callback)(struct struct_CO_Data *); void (*NMT_Slave_Communications_Reset_Callback)(struct struct_CO_Data *); unsigned char *ConsumerHeartbeatCount; unsigned long *ConsumerHeartbeatEntries; short *ConsumerHeartBeatTimers; unsigned short *ProducerHeartBeatTime; short ProducerHeartBeatTimer; void (*heartbeatError)(struct struct_CO_Data *, unsigned char); enum enum_nodeState { Initialisation=0, Disconnected=1, Connecting=2, Preparing=2, Stopped=4, Operational=5, Pre_operational=127, Unknown_state=15 } NMTable[128]; short GuardTimeTimer; short LifeTimeTimer; void (*nodeguardError)(struct struct_CO_Data *, unsigned char); unsigned short *GuardTime; unsigned char *LifeTimeFactor; unsigned char nodeGuardStatus[128]; short syncTimer; unsigned long *COB_ID_Sync; unsigned long *Sync_Cycle_Period; void (*post_sync)(struct struct_CO_Data *); void (*post_TPDO)(struct struct_CO_Data *); void (*post_SlaveBootup)(struct struct_CO_Data *, unsigned char); void (*post_SlaveStateChange)(struct struct_CO_Data *, unsigned char, enum enum_nodeState { Initialisation=0, Disconnected=1, Connecting=2, Preparing=2, Stopped=4, Operational=5, Pre_operational=127, Unknown_state=15 }); unsigned char toggle; void *canHandle; struct td_indextable *(*scanIndexOD)(unsigned short wIndex, unsigned long *errorCode, unsigned long (***Callback)(struct struct_CO_Data *d, struct td_indextable *, unsigned char bSubindex)); void (*storeODSubIndex)(struct struct_CO_Data *d, unsigned short wIndex, unsigned char bSubindex); struct td_indextable *dcf_odentry; unsigned char *dcf_cursor; unsigned long dcf_entries_count; unsigned char dcf_status; unsigned long dcf_size; unsigned char *dcf_data; enum enum_errorState { Error_free=0, Error_occurred=1 } error_state; unsigned char error_history_size; unsigned char *error_number; unsigned long *error_first_element; unsigned char *error_register; unsigned long *error_cobid; struct s_errors { unsigned short errCode; unsigned char errRegMask; unsigned char active; } error_data[8]; void (*post_emcy)(struct struct_CO_Data *d, unsigned char nodeID, unsigned short errCode, unsigned char errReg); } *

variable_types:
wIndex
unsigned short

variable_types:
errorCode
unsigned long *

variable_types: unsigned long (***)(struct struct_CO_Data *d, struct td_indextable *, unsigned char bSubindex)


RegisterSetODentryCallBack

decompiled_code:
__int64 __fastcall RegisterSetODentryCallBack(__int64 a1, unsigned __int16 a2, unsigned __int8 a3, __int64 a4)
{
__int64 v6; // rax
__int64 v7; // r8
__int64 v9; // [rsp+0h] [rbp-28h] BYREF
__int64 v10[4]; // [rsp+8h] [rbp-20h] BYREF

v6 = scanIndexOD(a1, a2, (__int64)&v9, (__int64)v10);
v7 = v9;
if ( !v9 && v10[0] && *(_BYTE *)(v6 + 8) > a3 )
*(_QWORD *)(v10[0] + 8LL * a3) = a4;
return v7;
}

original_code:
unsigned long int RegisterSetODentryCallBack(CO_Data* d, unsigned short wIndex, unsigned char bSubindex, ODCallback_t Callback)
{
unsigned long int errorCode;
ODCallback_t *CallbackList;
const indextable *odentry;
  odentry = scanIndexOD (d, wIndex, &errorCode, &CallbackList);
  if(errorCode == 0x00000000 && CallbackList && bSubindex < odentry->bSubCount)
    CallbackList[bSubindex] = Callback;
  return errorCode;
}

canonical_original_code:
unsigned long RegisterSetODentryCallBack(struct struct_CO_Data *d, unsigned short wIndex, unsigned char bSubindex, unsigned long (*Callback)(struct struct_CO_Data *d, struct td_indextable *, unsigned char bSubindex))
{
unsigned long errorCode;
unsigned long (**CallbackList)(struct struct_CO_Data *d, struct td_indextable *, unsigned char bSubindex);
struct td_indextable *odentry;
  odentry = scanIndexOD (d, wIndex, &errorCode, &CallbackList);
  if(errorCode == 0x00000000 && CallbackList && bSubindex < odentry->bSubCount)
    CallbackList[bSubindex] = Callback;
  return errorCode;
}

variable_types:
bSubindex
unsigned char

variable_types: unsigned long (*)(struct struct_CO_Data *d, struct td_indextable *, unsigned char bSubindex)

variable_types:
errorCode
unsigned long

variable_types: unsigned long (**)(struct struct_CO_Data { unsigned char *bDeviceNodeId; struct td_indextable { struct td_subindex { unsigned char bAccessType; unsigned char bDataType; unsigned long size; void *pObject; } *pSubindex; unsigned char bSubCount; unsigned short index; } *objdict; struct struct_s_PDO_status { unsigned char transmit_type_parameter; short event_timer; short inhibit_timer; struct Message { unsigned short cob_id; unsigned char rtr; unsigned char len; unsigned char data[8]; } last_message; } *PDO_status; short *RxPDO_EventTimers; void (*RxPDO_EventTimers_Handler)(struct struct_CO_Data *, unsigned long); struct s_quick_index { unsigned short SDO_SVR; unsigned short SDO_CLT; unsigned short PDO_RCV; unsigned short PDO_RCV_MAP; unsigned short PDO_TRS; unsigned short PDO_TRS_MAP; } *firstIndex; struct s_quick_index *lastIndex; unsigned short *ObjdictSize; unsigned char *iam_a_slave; unsigned long (*valueRangeTest)(unsigned char typeValue, void *Value); struct struct_s_transfer { unsigned char CliServNbr; unsigned char whoami; unsigned char state; unsigned char toggle; unsigned long abortCode; unsigned short index; unsigned char subIndex; unsigned long count; unsigned long offset; unsigned char data[32]; unsigned char peerCRCsupport; unsigned char blksize; unsigned char ackseq; unsigned long objsize; unsigned char lastblockoffset; unsigned char seqno; unsigned char endfield; enum rxStep_t { RXSTEP_INIT=0, RXSTEP_STARTED=1, RXSTEP_END=2 } rxstep; unsigned char tmpData[8]; unsigned char dataType; short timer; void (*Callback)(struct struct_CO_Data *d, unsigned char nodeId); } transfers[4]; enum enum_nodeState { Initialisation=0, Disconnected=1, Connecting=2, Preparing=2, Stopped=4, Operational=5, Pre_operational=127, Unknown_state=15 } nodeState; struct s_state_communication { char csBoot_Up; char csSDO; char csEmergency; char csSYNC; char csLifeGuard; char csPDO; char csLSS; } CurrentCommunicationState; void (*initialisation)(struct struct_CO_Data *); void (*preOperational)(struct struct_CO_Data *); void (*operational)(struct struct_CO_Data *); void (*stopped)(struct struct_CO_Data *); void (*NMT_Slave_Node_Reset_Callback)(struct struct_CO_Data *); void (*NMT_Slave_Communications_Reset_Callback)(struct struct_CO_Data *); unsigned char *ConsumerHeartbeatCount; unsigned long *ConsumerHeartbeatEntries; short *ConsumerHeartBeatTimers; unsigned short *ProducerHeartBeatTime; short ProducerHeartBeatTimer; void (*heartbeatError)(struct struct_CO_Data *, unsigned char); enum enum_nodeState { Initialisation=0, Disconnected=1, Connecting=2, Preparing=2, Stopped=4, Operational=5, Pre_operational=127, Unknown_state=15 } NMTable[128]; short GuardTimeTimer; short LifeTimeTimer; void (*nodeguardError)(struct struct_CO_Data *, unsigned char); unsigned short *GuardTime; unsigned char *LifeTimeFactor; unsigned char nodeGuardStatus[128]; short syncTimer; unsigned long *COB_ID_Sync; unsigned long *Sync_Cycle_Period; void (*post_sync)(struct struct_CO_Data *); void (*post_TPDO)(struct struct_CO_Data *); void (*post_SlaveBootup)(struct struct_CO_Data *, unsigned char); void (*post_SlaveStateChange)(struct struct_CO_Data *, unsigned char, enum enum_nodeState { Initialisation=0, Disconnected=1, Connecting=2, Preparing=2, Stopped=4, Operational=5, Pre_operational=127, Unknown_state=15 }); unsigned char toggle; void *canHandle; struct td_indextable *(*scanIndexOD)(unsigned short wIndex, unsigned long *errorCode, unsigned long (***Callback)(struct struct_CO_Data *d, struct td_indextable *, unsigned char bSubindex)); void (*storeODSubIndex)(struct struct_CO_Data *d, unsigned short wIndex, unsigned char bSubindex); struct td_indextable *dcf_odentry; unsigned char *dcf_cursor; unsigned long dcf_entries_count; unsigned char dcf_status; unsigned long dcf_size; unsigned char *dcf_data; enum enum_errorState { Error_free=0, Error_occurred=1 } error_state; unsigned char error_history_size; unsigned char *error_number; unsigned long *error_first_element; unsigned char *error_register; unsigned long *error_cobid; struct s_errors { unsigned short errCode; unsigned char errRegMask; unsigned char active; } error_data[8]; void (*post_emcy)(struct struct_CO_Data *d, unsigned char nodeID, unsigned short errCode, unsigned char errReg); } *d, struct td_indextable *, unsigned char bSubindex)


decompiled_code:
__int64 __fastcall ObjDict_valueRangeTest(char a1, _BYTE *a2)
{
__int64 result; // rax

result = 0LL;
if ( a1 == -97 )
result = *a2 != 0 ? 0x6090030 : 0;
return result;
}

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

result = 0LL;
if ( a1 == -97 )
result = *a2 != 0 ? 0x6090030 : 0;
return result;
}

original_code:
unsigned long int ObjDict_valueRangeTest (unsigned char typeValue, void * value)
{
  switch (typeValue) {
    case 0x9F:
      if (*(unsigned char*)value != (unsigned char)0) return 0x06090030;
      break;
  }
  return 0;
}

canonical_original_code:
unsigned long ObjDict_valueRangeTest(unsigned char typeValue, void *value)
{
  switch (typeValue) {
    case 0x9F:
      if (*(unsigned char *)value != (unsigned char)0) return 0x06090030;
      break;
  }
  return 0;
}

variable_types:
typeValue
unsigned char

variable_types:
value
void *


decompiled_code:
void ***__fastcall ObjDict_scanIndexOD(unsigned __int16 a1, _QWORD *a2, _QWORD *a3)
{
void ***result; // rax

*a3 = 0LL;
if ( a1 == 5633 )
{
result = &ObjDict_objdict + 38;
goto LABEL_13;
}
if ( a1 > 0x1601u )
{
if ( a1 == 25090 )
{
result = &ObjDict_objdict + 58;
goto LABEL_13;
}
if ( a1 <= 0x6202u )
{
if ( a1 == 6657 )
{
result = &ObjDict_objdict + 48;
goto LABEL_13;
}
if ( a1 <= 0x1A01u )
{
if ( a1 == 6146 )
{
*a3 = &ObjDict_Index1802_callbacks;
result = &ObjDict_objdict + 44;
goto LABEL_13;
}
if ( a1 <= 0x1802u )
{
if ( a1 == 6144 )
{
*a3 = &ObjDict_Index1800_callbacks;
result = &ObjDict_objdict + 40;
goto LABEL_13;
}
if ( a1 == 6145 )
{
*a3 = &ObjDict_Index1801_callbacks;
result = &ObjDict_objdict + 42;
goto LABEL_13;
}
}
else if ( a1 == 6656 )
{
result = &ObjDict_objdict + 46;
goto LABEL_13;
}
}
else
{
if ( a1 == 24578 )
{
result = &ObjDict_objdict + 54;
goto LABEL_13;
}
if ( a1 <= 0x6002u )
{
if ( a1 == 6658 )
{
result = &ObjDict_objdict + 50;
goto LABEL_13;
}
if ( a1 == 24576 )
{
result = &ObjDict_objdict + 52;
goto LABEL_13;
}
}
else if ( a1 == 25088 )
{
result = &ObjDict_objdict + 56;
goto LABEL_13;
}
}
}
else
{
if ( a1 == 25635 )
{
result = &ObjDict_objdict + 68;
goto LABEL_13;
}
if ( a1 <= 0x6423u )
{
if ( a1 == 25601 )
{
result = &ObjDict_objdict + 64;
goto LABEL_13;
}
if ( a1 <= 0x6401u )
{
if ( a1 == 25094 )
{
result = &ObjDict_objdict + 60;
goto LABEL_13;
}
if ( a1 == 25095 )
{
result = &ObjDict_objdict + 62;
goto LABEL_13;
}
}
else if ( a1 == 25617 )
{
result = &ObjDict_objdict + 66;
goto LABEL_13;
}
}
else
{
switch ( a1 )
{
case 0x6443u:
result = &ObjDict_objdict + 72;
goto LABEL_13;
case 0x6444u:
result = &ObjDict_objdict + 74;
LABEL_13:
*a2 = 0LL;
return result;
case 0x6426u:
*a2 = 0LL;
return &ObjDict_objdict + 70;
}
}
}
}
else
{
if ( a1 <= 0x1020u )
{
if ( a1 > 0xFFFu )
{
switch ( a1 )
{
case 0x1000u:
result = &ObjDict_objdict;
goto LABEL_13;
case 0x1001u:
result = &ObjDict_objdict + 2;
goto LABEL_13;
case 0x1002u:
result = &ObjDict_objdict + 4;
goto LABEL_13;
case 0x1005u:
*a3 = &ObjDict_Index1005_callbacks;
result = &ObjDict_objdict + 6;
goto LABEL_13;
case 0x1008u:
result = &ObjDict_objdict + 8;
goto LABEL_13;
case 0x1009u:
result = &ObjDict_objdict + 10;
goto LABEL_13;
case 0x100Au:
result = &ObjDict_objdict + 12;
goto LABEL_13;
case 0x100Cu:
result = &ObjDict_objdict + 14;
goto LABEL_13;
case 0x100Du:
result = &ObjDict_objdict + 16;
goto LABEL_13;
case 0x1010u:
result = &ObjDict_objdict + 18;
goto LABEL_13;
case 0x1011u:
result = &ObjDict_objdict + 20;
goto LABEL_13;
case 0x1016u:
result = &ObjDict_objdict + 22;
goto LABEL_13;
case 0x1017u:
*a3 = &ObjDict_Index1017_callbacks;
result = &ObjDict_objdict + 24;
goto LABEL_13;
case 0x1018u:
result = &ObjDict_objdict + 26;
goto LABEL_13;
case 0x1020u:
result = &ObjDict_objdict + 28;
goto LABEL_13;
default:
goto LABEL_56;
}
}
goto LABEL_56;
}
if ( a1 == 5121 )
{
result = &ObjDict_objdict + 34;
goto LABEL_13;
}
if ( a1 > 0x1401u )
{
if ( a1 == 5632 )
{
*a2 = 0LL;
return &ObjDict_objdict + 36;
}
goto LABEL_56;
}
if ( a1 == 4608 )
{
result = &ObjDict_objdict + 30;
goto LABEL_13;
}
if ( a1 == 5120 )
{
result = &ObjDict_objdict + 32;
goto LABEL_13;
}
}
LABEL_56:
*a2 = 100794368LL;
return 0LL;
}

canonical_decompiled_code:
void ***__fastcall func1(unsigned __int16 a1, _QWORD *a2, _QWORD *a3)
{
void ***result; // rax

*a3 = 0LL;
if ( a1 == 5633 )
{
result = &ObjDict_objdict + 38;
goto LABEL_13;
}
if ( a1 > 0x1601u )
{
if ( a1 == 25090 )
{
result = &ObjDict_objdict + 58;
goto LABEL_13;
}
if ( a1 <= 0x6202u )
{
if ( a1 == 6657 )
{
result = &ObjDict_objdict + 48;
goto LABEL_13;
}
if ( a1 <= 0x1A01u )
{
if ( a1 == 6146 )
{
*a3 = &ObjDict_Index1802_callbacks;
result = &ObjDict_objdict + 44;
goto LABEL_13;
}
if ( a1 <= 0x1802u )
{
if ( a1 == 6144 )
{
*a3 = &ObjDict_Index1800_callbacks;
result = &ObjDict_objdict + 40;
goto LABEL_13;
}
if ( a1 == 6145 )
{
*a3 = &ObjDict_Index1801_callbacks;
result = &ObjDict_objdict + 42;
goto LABEL_13;
}
}
else if ( a1 == 6656 )
{
result = &ObjDict_objdict + 46;
goto LABEL_13;
}
}
else
{
if ( a1 == 24578 )
{
result = &ObjDict_objdict + 54;
goto LABEL_13;
}
if ( a1 <= 0x6002u )
{
if ( a1 == 6658 )
{
result = &ObjDict_objdict + 50;
goto LABEL_13;
}
if ( a1 == 24576 )
{
result = &ObjDict_objdict + 52;
goto LABEL_13;
}
}
else if ( a1 == 25088 )
{
result = &ObjDict_objdict + 56;
goto LABEL_13;
}
}
}
else
{
if ( a1 == 25635 )
{
result = &ObjDict_objdict + 68;
goto LABEL_13;
}
if ( a1 <= 0x6423u )
{
if ( a1 == 25601 )
{
result = &ObjDict_objdict + 64;
goto LABEL_13;
}
if ( a1 <= 0x6401u )
{
if ( a1 == 25094 )
{
result = &ObjDict_objdict + 60;
goto LABEL_13;
}
if ( a1 == 25095 )
{
result = &ObjDict_objdict + 62;
goto LABEL_13;
}
}
else if ( a1 == 25617 )
{
result = &ObjDict_objdict + 66;
goto LABEL_13;
}
}
else
{
switch ( a1 )
{
case 0x6443u:
result = &ObjDict_objdict + 72;
goto LABEL_13;
case 0x6444u:
result = &ObjDict_objdict + 74;
LABEL_13:
*a2 = 0LL;
return result;
case 0x6426u:
*a2 = 0LL;
return &ObjDict_objdict + 70;
}
}
}
}
else
{
if ( a1 <= 0x1020u )
{
if ( a1 > 0xFFFu )
{
switch ( a1 )
{
case 0x1000u:
result = &ObjDict_objdict;
goto LABEL_13;
case 0x1001u:
result = &ObjDict_objdict + 2;
goto LABEL_13;
case 0x1002u:
result = &ObjDict_objdict + 4;
goto LABEL_13;
case 0x1005u:
*a3 = &ObjDict_Index1005_callbacks;
result = &ObjDict_objdict + 6;
goto LABEL_13;
case 0x1008u:
result = &ObjDict_objdict + 8;
goto LABEL_13;
case 0x1009u:
result = &ObjDict_objdict + 10;
goto LABEL_13;
case 0x100Au:
result = &ObjDict_objdict + 12;
goto LABEL_13;
case 0x100Cu:
result = &ObjDict_objdict + 14;
goto LABEL_13;
case 0x100Du:
result = &ObjDict_objdict + 16;
goto LABEL_13;
case 0x1010u:
result = &ObjDict_objdict + 18;
goto LABEL_13;
case 0x1011u:
result = &ObjDict_objdict + 20;
goto LABEL_13;
case 0x1016u:
result = &ObjDict_objdict + 22;
goto LABEL_13;
case 0x1017u:
*a3 = &ObjDict_Index1017_callbacks;
result = &ObjDict_objdict + 24;
goto LABEL_13;
case 0x1018u:
result = &ObjDict_objdict + 26;
goto LABEL_13;
case 0x1020u:
result = &ObjDict_objdict + 28;
goto LABEL_13;
default:
goto LABEL_56;
}
}
goto LABEL_56;
}
if ( a1 == 5121 )
{
result = &ObjDict_objdict + 34;
goto LABEL_13;
}
if ( a1 > 0x1401u )
{
if ( a1 == 5632 )
{
*a2 = 0LL;
return &ObjDict_objdict + 36;
}
goto LABEL_56;
}
if ( a1 == 4608 )
{
result = &ObjDict_objdict + 30;
goto LABEL_13;
}
if ( a1 == 5120 )
{
result = &ObjDict_objdict + 32;
goto LABEL_13;
}
}
LABEL_56:
*a2 = 100794368LL;
return 0LL;
}

original_code:
const indextable * ObjDict_scanIndexOD (unsigned short wIndex, unsigned long int * errorCode, ODCallback_t **callbacks)
{
 int i;
 *callbacks = ((void *)0);
 switch(wIndex){
  case 0x1000: i = 0;break;
  case 0x1001: i = 1;break;
  case 0x1002: i = 2;break;
  case 0x1005: i = 3;*callbacks = ObjDict_Index1005_callbacks; break;
  case 0x1008: i = 4;break;
  case 0x1009: i = 5;break;
  case 0x100A: i = 6;break;
  case 0x100C: i = 7;break;
  case 0x100D: i = 8;break;
  case 0x1010: i = 9;break;
  case 0x1011: i = 10;break;
  case 0x1016: i = 11;break;
  case 0x1017: i = 12;*callbacks = ObjDict_Index1017_callbacks; break;
  case 0x1018: i = 13;break;
  case 0x1020: i = 14;break;
  case 0x1200: i = 15;break;
  case 0x1400: i = 16;break;
  case 0x1401: i = 17;break;
  case 0x1600: i = 18;break;
  case 0x1601: i = 19;break;
  case 0x1800: i = 20;*callbacks = ObjDict_Index1800_callbacks; break;
  case 0x1801: i = 21;*callbacks = ObjDict_Index1801_callbacks; break;
  case 0x1802: i = 22;*callbacks = ObjDict_Index1802_callbacks; break;
  case 0x1A00: i = 23;break;
  case 0x1A01: i = 24;break;
  case 0x1A02: i = 25;break;
  case 0x6000: i = 26;break;
  case 0x6002: i = 27;break;
  case 0x6200: i = 28;break;
  case 0x6202: i = 29;break;
  case 0x6206: i = 30;break;
  case 0x6207: i = 31;break;
  case 0x6401: i = 32;break;
  case 0x6411: i = 33;break;
  case 0x6423: i = 34;break;
  case 0x6426: i = 35;break;
  case 0x6443: i = 36;break;
  case 0x6444: i = 37;break;
  default:
   *errorCode = 0x06020000;
   return ((void *)0);
 }
 *errorCode = 0x00000000;
 return &ObjDict_objdict[i];
}

canonical_original_code:
struct td_indextable *ObjDict_scanIndexOD(unsigned short wIndex, unsigned long *errorCode, unsigned long (***callbacks)(struct struct_CO_Data *d, struct td_indextable *, unsigned char bSubindex))
{
 int i;
 *callbacks = ((void *)0);
 switch(wIndex){
  case 0x1000: i = 0;break;
  case 0x1001: i = 1;break;
  case 0x1002: i = 2;break;
  case 0x1005: i = 3;*callbacks = ObjDict_Index1005_callbacks; break;
  case 0x1008: i = 4;break;
  case 0x1009: i = 5;break;
  case 0x100A: i = 6;break;
  case 0x100C: i = 7;break;
  case 0x100D: i = 8;break;
  case 0x1010: i = 9;break;
  case 0x1011: i = 10;break;
  case 0x1016: i = 11;break;
  case 0x1017: i = 12;*callbacks = ObjDict_Index1017_callbacks; break;
  case 0x1018: i = 13;break;
  case 0x1020: i = 14;break;
  case 0x1200: i = 15;break;
  case 0x1400: i = 16;break;
  case 0x1401: i = 17;break;
  case 0x1600: i = 18;break;
  case 0x1601: i = 19;break;
  case 0x1800: i = 20;*callbacks = ObjDict_Index1800_callbacks; break;
  case 0x1801: i = 21;*callbacks = ObjDict_Index1801_callbacks; break;
  case 0x1802: i = 22;*callbacks = ObjDict_Index1802_callbacks; break;
  case 0x1A00: i = 23;break;
  case 0x1A01: i = 24;break;
  case 0x1A02: i = 25;break;
  case 0x6000: i = 26;break;
  case 0x6002: i = 27;break;
  case 0x6200: i = 28;break;
  case 0x6202: i = 29;break;
  case 0x6206: i = 30;break;
  case 0x6207: i = 31;break;
  case 0x6401: i = 32;break;
  case 0x6411: i = 33;break;
  case 0x6423: i = 34;break;
  case 0x6426: i = 35;break;
  case 0x6443: i = 36;break;
  case 0x6444: i = 37;break;
  default:
   *errorCode = 0x06020000;
   return ((void *)0);
 }
 *errorCode = 0x00000000;
 return &ObjDict_objdict[i];
}

variable_types: unsigned long (***)(struct struct_CO_Data { unsigned char *bDeviceNodeId; struct td_indextable *objdict; struct struct_s_PDO_status { unsigned char transmit_type_parameter; short event_timer; short inhibit_timer; struct Message { unsigned short cob_id; unsigned char rtr; unsigned char len; unsigned char data[8]; } last_message; } *PDO_status; short *RxPDO_EventTimers; void (*RxPDO_EventTimers_Handler)(struct struct_CO_Data *, unsigned long); struct s_quick_index { unsigned short SDO_SVR; unsigned short SDO_CLT; unsigned short PDO_RCV; unsigned short PDO_RCV_MAP; unsigned short PDO_TRS; unsigned short PDO_TRS_MAP; } *firstIndex; struct s_quick_index *lastIndex; unsigned short *ObjdictSize; unsigned char *iam_a_slave; unsigned long (*valueRangeTest)(unsigned char typeValue, void *Value); struct struct_s_transfer { unsigned char CliServNbr; unsigned char whoami; unsigned char state; unsigned char toggle; unsigned long abortCode; unsigned short index; unsigned char subIndex; unsigned long count; unsigned long offset; unsigned char data[32]; unsigned char peerCRCsupport; unsigned char blksize; unsigned char ackseq; unsigned long objsize; unsigned char lastblockoffset; unsigned char seqno; unsigned char endfield; enum rxStep_t { RXSTEP_INIT=0, RXSTEP_STARTED=1, RXSTEP_END=2 } rxstep; unsigned char tmpData[8]; unsigned char dataType; short timer; void (*Callback)(struct struct_CO_Data *d, unsigned char nodeId); } transfers[4]; enum enum_nodeState { Initialisation=0, Disconnected=1, Connecting=2, Preparing=2, Stopped=4, Operational=5, Pre_operational=127, Unknown_state=15 } nodeState; struct s_state_communication { char csBoot_Up; char csSDO; char csEmergency; char csSYNC; char csLifeGuard; char csPDO; char csLSS; } CurrentCommunicationState; void (*initialisation)(struct struct_CO_Data *); void (*preOperational)(struct struct_CO_Data *); void (*operational)(struct struct_CO_Data *); void (*stopped)(struct struct_CO_Data *); void (*NMT_Slave_Node_Reset_Callback)(struct struct_CO_Data *); void (*NMT_Slave_Communications_Reset_Callback)(struct struct_CO_Data *); unsigned char *ConsumerHeartbeatCount; unsigned long *ConsumerHeartbeatEntries; short *ConsumerHeartBeatTimers; unsigned short *ProducerHeartBeatTime; short ProducerHeartBeatTimer; void (*heartbeatError)(struct struct_CO_Data *, unsigned char); enum enum_nodeState { Initialisation=0, Disconnected=1, Connecting=2, Preparing=2, Stopped=4, Operational=5, Pre_operational=127, Unknown_state=15 } NMTable[128]; short GuardTimeTimer; short LifeTimeTimer; void (*nodeguardError)(struct struct_CO_Data *, unsigned char); unsigned short *GuardTime; unsigned char *LifeTimeFactor; unsigned char nodeGuardStatus[128]; short syncTimer; unsigned long *COB_ID_Sync; unsigned long *Sync_Cycle_Period; void (*post_sync)(struct struct_CO_Data *); void (*post_TPDO)(struct struct_CO_Data *); void (*post_SlaveBootup)(struct struct_CO_Data *, unsigned char); void (*post_SlaveStateChange)(struct struct_CO_Data *, unsigned char, enum enum_nodeState { Initialisation=0, Disconnected=1, Connecting=2, Preparing=2, Stopped=4, Operational=5, Pre_operational=127, Unknown_state=15 }); unsigned char toggle; void *canHandle; struct td_indextable *(*scanIndexOD)(unsigned short wIndex, unsigned long *errorCode, unsigned long (***Callback)(struct struct_CO_Data *d, struct td_indextable *, unsigned char bSubindex)); void (*storeODSubIndex)(struct struct_CO_Data *d, unsigned short wIndex, unsigned char bSubindex); struct td_indextable *dcf_odentry; unsigned char *dcf_cursor; unsigned long dcf_entries_count; unsigned char dcf_status; unsigned long dcf_size; unsigned char *dcf_data; enum enum_errorState { Error_free=0, Error_occurred=1 } error_state; unsigned char error_history_size; unsigned char *error_number; unsigned long *error_first_element; unsigned char *error_register; unsigned long *error_cobid; struct s_errors { unsigned short errCode; unsigned char errRegMask; unsigned char active; } error_data[8]; void (*post_emcy)(struct struct_CO_Data *d, unsigned char nodeID, unsigned short errCode, unsigned char errReg); } *d, struct td_indextable *, unsigned char bSubindex)

variable_types: i int


decompiled_code:
__int64 OnMasterMap1Update()
{
printf("OnMasterMap1Update:%d\n", MasterMap1);
return 0LL;
}

canonical_decompiled_code:
__int64 func0()
{
printf("OnMasterMap1Update:%d\n", MasterMap1);
return 0LL;
}

original_code:
unsigned long int OnMasterMap1Update(CO_Data* d, const indextable * unsused_indextable, unsigned char unsused_bSubindex)
{
 printf ("OnMasterMap1Update:%d\n", MasterMap1);
 return 0;
}

canonical_original_code:
unsigned long OnMasterMap1Update(struct struct_CO_Data *d, struct td_indextable *unsused_indextable, unsigned char unsused_bSubindex)
{
 printf ("OnMasterMap1Update:%d\n", MasterMap1);
 return 0;
}

variable_types: struct struct_CO_Data { unsigned char *bDeviceNodeId; struct td_indextable { struct td_subindex { unsigned char bAccessType; unsigned char bDataType; unsigned long size; void *pObject; } *pSubindex; unsigned char bSubCount; unsigned short index; } *objdict; struct struct_s_PDO_status { unsigned char transmit_type_parameter; short event_timer; short inhibit_timer; struct Message { unsigned short cob_id; unsigned char rtr; unsigned char len; unsigned char data[8]; } last_message; } *PDO_status; short *RxPDO_EventTimers; void (*RxPDO_EventTimers_Handler)(struct struct_CO_Data *, unsigned long); struct s_quick_index { unsigned short SDO_SVR; unsigned short SDO_CLT; unsigned short PDO_RCV; unsigned short PDO_RCV_MAP; unsigned short PDO_TRS; unsigned short PDO_TRS_MAP; } *firstIndex; struct s_quick_index *lastIndex; unsigned short *ObjdictSize; unsigned char *iam_a_slave; unsigned long (*valueRangeTest)(unsigned char typeValue, void *Value); struct struct_s_transfer { unsigned char CliServNbr; unsigned char whoami; unsigned char state; unsigned char toggle; unsigned long abortCode; unsigned short index; unsigned char subIndex; unsigned long count; unsigned long offset; unsigned char data[32]; unsigned char peerCRCsupport; unsigned char blksize; unsigned char ackseq; unsigned long objsize; unsigned char lastblockoffset; unsigned char seqno; unsigned char endfield; enum rxStep_t { RXSTEP_INIT=0, RXSTEP_STARTED=1, RXSTEP_END=2 } rxstep; unsigned char tmpData[8]; unsigned char dataType; short timer; void (*Callback)(struct struct_CO_Data *d, unsigned char nodeId); } transfers[4]; enum enum_nodeState { Initialisation=0, Disconnected=1, Connecting=2, Preparing=2, Stopped=4, Operational=5, Pre_operational=127, Unknown_state=15 } nodeState; struct s_state_communication { char csBoot_Up; char csSDO; char csEmergency; char csSYNC; char csLifeGuard; char csPDO; char csLSS; } CurrentCommunicationState; void (*initialisation)(struct struct_CO_Data *); void (*preOperational)(struct struct_CO_Data *); void (*operational)(struct struct_CO_Data *); void (*stopped)(struct struct_CO_Data *); void (*NMT_Slave_Node_Reset_Callback)(struct struct_CO_Data *); void (*NMT_Slave_Communications_Reset_Callback)(struct struct_CO_Data *); unsigned char *ConsumerHeartbeatCount; unsigned long *ConsumerHeartbeatEntries; short *ConsumerHeartBeatTimers; unsigned short *ProducerHeartBeatTime; short ProducerHeartBeatTimer; void (*heartbeatError)(struct struct_CO_Data *, unsigned char); enum enum_nodeState { Initialisation=0, Disconnected=1, Connecting=2, Preparing=2, Stopped=4, Operational=5, Pre_operational=127, Unknown_state=15 } NMTable[128]; short GuardTimeTimer; short LifeTimeTimer; void (*nodeguardError)(struct struct_CO_Data *, unsigned char); unsigned short *GuardTime; unsigned char *LifeTimeFactor; unsigned char nodeGuardStatus[128]; short syncTimer; unsigned long *COB_ID_Sync; unsigned long *Sync_Cycle_Period; void (*post_sync)(struct struct_CO_Data *); void (*post_TPDO)(struct struct_CO_Data *); void (*post_SlaveBootup)(struct struct_CO_Data *, unsigned char); void (*post_SlaveStateChange)(struct struct_CO_Data *, unsigned char, enum enum_nodeState { Initialisation=0, Disconnected=1, Connecting=2, Preparing=2, Stopped=4, Operational=5, Pre_operational=127, Unknown_state=15 }); unsigned char toggle; void *canHandle; struct td_indextable *(*scanIndexOD)(unsigned short wIndex, unsigned long *errorCode, unsigned long (***Callback)(struct struct_CO_Data *d, struct td_indextable *, unsigned char bSubindex)); void (*storeODSubIndex)(struct struct_CO_Data *d, unsigned short wIndex, unsigned char bSubindex); struct td_indextable *dcf_odentry; unsigned char *dcf_cursor; unsigned long dcf_entries_count; unsigned char dcf_status; unsigned long dcf_size; unsigned char *dcf_data; enum enum_errorState { Error_free=0, Error_occurred=1 } error_state; unsigned char error_history_size; unsigned char *error_number; unsigned long *error_first_element; unsigned char *error_register; unsigned long *error_cobid; struct s_errors { unsigned short errCode; unsigned char errRegMask; unsigned char active; } error_data[8]; void (*post_emcy)(struct struct_CO_Data *d, unsigned char nodeID, unsigned short errCode, unsigned char errReg); } *


decompiled_code:
void __fastcall catch_signal(unsigned int a1)
{
signal(15, catch_signal);
signal(2, catch_signal);
printf("Got Signal %d\n", a1);
}

canonical_decompiled_code:
void __fastcall func1(unsigned int a1)
{
signal(15, catch_signal);
signal(2, catch_signal);
printf("Got Signal %d\n", a1);
}

original_code:
void catch_signal(int sig)
{
  signal(15, catch_signal);
  signal(2, catch_signal);
  printf ("Got Signal %d\n",sig);
}

variable_types: sig int


InitNodes

decompiled_code:
char InitNodes()
{
bool v0; // zf
char result; // al

if ( strcmp(SlaveBoard[1], "none") )
{
setNodeId(&TestSlave_Data, 2LL);
setState(&TestSlave_Data, 0LL);
}
v0 = strcmp(MasterBoard[1], "none") == 0;
result = !v0;
if ( !v0 )
{
RegisterSetODentryCallBack(&TestMaster_Data, 0x2000LL, 0LL, OnMasterMap1Update);
setNodeId(&TestMaster_Data, 1LL);
result = setState(&TestMaster_Data, 0LL);
}
return result;
}

canonical_decompiled_code:
char func2()
{
bool v0; // zf
char result; // al

if ( strcmp(SlaveBoard[1], "none") )
{
setNodeId(&TestSlave_Data, 2LL);
setState(&TestSlave_Data, 0LL);
}
v0 = strcmp(MasterBoard[1], "none") == 0;
result = !v0;
if ( !v0 )
{
RegisterSetODentryCallBack(&TestMaster_Data, 0x2000LL, 0LL, OnMasterMap1Update);
setNodeId(&TestMaster_Data, 1LL);
result = setState(&TestMaster_Data, 0LL);
}
return result;
}

original_code:
void InitNodes(CO_Data* d, unsigned long int id)
{
 if(strcmp(SlaveBoard.baudrate, "none")) {
  setNodeId(&TestSlave_Data, 0x02);
  setState(&TestSlave_Data, Initialisation);
 }
 if(strcmp(MasterBoard.baudrate, "none")){
   RegisterSetODentryCallBack(&TestMaster_Data, 0x2000, 0, &OnMasterMap1Update);
  setNodeId(&TestMaster_Data, 0x01);
  setState(&TestMaster_Data, Initialisation);
 }
}

canonical_original_code:
void InitNodes(struct struct_CO_Data *d, unsigned long id)
{
 if(strcmp(SlaveBoard.baudrate, "none")) {
  setNodeId(&TestSlave_Data, 0x02);
  setState(&TestSlave_Data, Initialisation);
 }
 if(strcmp(MasterBoard.baudrate, "none")){
   RegisterSetODentryCallBack(&TestMaster_Data, 0x2000, 0, &OnMasterMap1Update);
  setNodeId(&TestMaster_Data, 0x01);
  setState(&TestMaster_Data, Initialisation);
 }
}

variable_types:
id
unsigned long


Exit

decompiled_code:
char Exit()
{
bool v0; // zf
char result; // al

v0 = strcmp(MasterBoard[1], "none") == 0;
result = !v0;
if ( !v0 )
{
masterSendNMTstateChange(&TestMaster_Data, 2LL, 129LL);
result = setState(&TestMaster_Data, 4LL);
}
return result;
}

canonical_decompiled_code:
char func3()
{
bool v0; // zf
char result; // al

v0 = strcmp(MasterBoard[1], "none") == 0;
result = !v0;
if ( !v0 )
{
masterSendNMTstateChange(&TestMaster_Data, 2LL, 129LL);
result = setState(&TestMaster_Data, 4LL);
}
return result;
}

original_code:
void Exit(CO_Data* d, unsigned long int id)
{
 if(strcmp(MasterBoard.baudrate, "none")){
  masterSendNMTstateChange(&TestMaster_Data, 0x02, 0x81);
  setState(&TestMaster_Data, Stopped);
 }
}

canonical_original_code:
void Exit(struct struct_CO_Data *d, unsigned long id)
{
 if(strcmp(MasterBoard.baudrate, "none")){
  masterSendNMTstateChange(&TestMaster_Data, 0x02, 0x81);
  setState(&TestMaster_Data, Stopped);
 }
}


help

decompiled_code:
int help()
{
puts("**************************************************************");
puts("* TestMasterSlave *");
puts("* *");
puts("* A simple example for PC. It does implement 2 CanOpen *");
puts("* nodes in the same process. A master and a slave. Both *");
puts("* communicate together, exchanging periodically NMT, SYNC, *");
puts("* SDO and PDO. Master configure heartbeat producer time *");
puts("* at 1000 ms for slave node-id 0x02 by concise DCF. *");
puts("* *");
puts("* Usage: *");
puts("* ./TestMasterSlave [OPTIONS] *");
puts("* *");
puts("* OPTIONS: *");
puts("* -l : Can library [\"libcanfestival_can_virtual.so\"] *");
puts("* *");
puts("* Slave: *");
puts("* -s : bus name [\"0\"] *");
puts("* -S : 1M,500K,250K,125K,100K,50K,20K,10K,none(disable) *");
puts("* *");
puts("* Master: *");
puts("* -m : bus name [\"1\"] *");
puts("* -M : 1M,500K,250K,125K,100K,50K,20K,10K,none(disable) *");
puts("* *");
return puts("**************************************************************");
}

canonical_decompiled_code:
int func4()
{
puts("**************************************************************");
puts("* TestMasterSlave *");
puts("* *");
puts("* A simple example for PC. It does implement 2 CanOpen *");
puts("* nodes in the same process. A master and a slave. Both *");
puts("* communicate together, exchanging periodically NMT, SYNC, *");
puts("* SDO and PDO. Master configure heartbeat producer time *");
puts("* at 1000 ms for slave node-id 0x02 by concise DCF. *");
puts("* *");
puts("* Usage: *");
puts("* ./TestMasterSlave [OPTIONS] *");
puts("* *");
puts("* OPTIONS: *");
puts("* -l : Can library [\"libcanfestival_can_virtual.so\"] *");
puts("* *");
puts("* Slave: *");
puts("* -s : bus name [\"0\"] *");
puts("* -S : 1M,500K,250K,125K,100K,50K,20K,10K,none(disable) *");
puts("* *");
puts("* Master: *");
puts("* -m : bus name [\"1\"] *");
puts("* -M : 1M,500K,250K,125K,100K,50K,20K,10K,none(disable) *");
puts("* *");
return puts("**************************************************************");
}

original_code:
void help(void)
{
  printf("**************************************************************\n");
  printf("*  TestMasterSlave                                           *\n");
  printf("*                                                            *\n");
  printf("*  A simple example for PC. It does implement 2 CanOpen      *\n");
  printf("*  nodes in the same process. A master and a slave. Both     *\n");
  printf("*  communicate together, exchanging periodically NMT, SYNC,  *\n");
  printf("*  SDO and PDO. Master configure heartbeat producer time     *\n");
  printf("*  at 1000 ms for slave node-id 0x02 by concise DCF.         *\n");
  printf("*                                                            *\n");
  printf("*   Usage:                                                   *\n");
  printf("*   ./TestMasterSlave  [OPTIONS]                             *\n");
  printf("*                                                            *\n");
  printf("*   OPTIONS:                                                 *\n");
  printf("*     -l : Can library [\"libcanfestival_can_virtual.so\"]     *\n");
  printf("*                                                            *\n");
  printf("*    Slave:                                                  *\n");
  printf("*     -s : bus name [\"0\"]                                    *\n");
  printf("*     -S : 1M,500K,250K,125K,100K,50K,20K,10K,none(disable)  *\n");
  printf("*                                                            *\n");
  printf("*    Master:                                                 *\n");
  printf("*     -m : bus name [\"1\"]                                    *\n");
  printf("*     -M : 1M,500K,250K,125K,100K,50K,20K,10K,none(disable)  *\n");
  printf("*                                                            *\n");
  printf("**************************************************************\n");
}

canonical_original_code:
void help()
{
  printf("**************************************************************\n");
  printf("*  TestMasterSlave                                           *\n");
  printf("*                                                            *\n");
  printf("*  A simple example for PC. It does implement 2 CanOpen      *\n");
  printf("*  nodes in the same process. A master and a slave. Both     *\n");
  printf("*  communicate together, exchanging periodically NMT, SYNC,  *\n");
  printf("*  SDO and PDO. Master configure heartbeat producer time     *\n");
  printf("*  at 1000 ms for slave node-id 0x02 by concise DCF.         *\n");
  printf("*                                                            *\n");
  printf("*   Usage:                                                   *\n");
  printf("*   ./TestMasterSlave  [OPTIONS]                             *\n");
  printf("*                                                            *\n");
  printf("*   OPTIONS:                                                 *\n");
  printf("*     -l : Can library [\"libcanfestival_can_virtual.so\"]     *\n");
  printf("*                                                            *\n");
  printf("*    Slave:                                                  *\n");
  printf("*     -s : bus name [\"0\"]                                    *\n");
  printf("*     -S : 1M,500K,250K,125K,100K,50K,20K,10K,none(disable)  *\n");
  printf("*                                                            *\n");
  printf("*    Master:                                                 *\n");
  printf("*     -m : bus name [\"1\"]                                    *\n");
  printf("*     -M : 1M,500K,250K,125K,100K,50K,20K,10K,none(disable)  *\n");
  printf("*                                                            *\n");
  printf("**************************************************************\n");
}