decompiled_code:
void ***__fastcall CANOpenShellSlaveOD_scanIndexOD(__int16 a1, _QWORD *a2, _QWORD *a3)
{
int v3; // eax
void ***result; // rax

*a3 = 0LL;
switch ( a1 )
{
case 4096:
v3 = 0;
goto LABEL_4;
case 4097:
v3 = 1;
goto LABEL_4;
case 4119:
*a3 = &CANOpenShellSlaveOD_Index1017_callbacks;
v3 = 2;
goto LABEL_4;
case 4120:
v3 = 3;
goto LABEL_4;
case 4736:
v3 = 4;
goto LABEL_4;
case 4737:
v3 = 5;
goto LABEL_4;
case 4738:
v3 = 6;
goto LABEL_4;
case 4739:
v3 = 7;
goto LABEL_4;
case 4740:
v3 = 8;
goto LABEL_4;
case 4741:
v3 = 9;
goto LABEL_4;
case 4742:
v3 = 10;
goto LABEL_4;
case 4743:
v3 = 11;
goto LABEL_4;
case 4744:
v3 = 12;
goto LABEL_4;
case 4745:
v3 = 13;
goto LABEL_4;
case 4746:
v3 = 14;
goto LABEL_4;
case 4747:
v3 = 15;
goto LABEL_4;
case 4748:
v3 = 16;
goto LABEL_4;
case 4749:
v3 = 17;
goto LABEL_4;
case 4750:
v3 = 18;
goto LABEL_4;
case 4751:
v3 = 19;
goto LABEL_4;
case 4752:
v3 = 20;
goto LABEL_4;
case 4753:
v3 = 21;
goto LABEL_4;
case 4754:
v3 = 22;
goto LABEL_4;
case 4755:
v3 = 23;
goto LABEL_4;
case 4756:
v3 = 24;
goto LABEL_4;
case 4757:
v3 = 25;
goto LABEL_4;
case 4758:
v3 = 26;
goto LABEL_4;
case 4759:
v3 = 27;
goto LABEL_4;
case 4760:
v3 = 28;
goto LABEL_4;
case 4761:
v3 = 29;
goto LABEL_4;
case 4762:
v3 = 30;
goto LABEL_4;
case 4763:
v3 = 31;
goto LABEL_4;
case 4764:
v3 = 32;
goto LABEL_4;
case 4765:
v3 = 33;
goto LABEL_4;
case 4766:
v3 = 34;
goto LABEL_4;
case 4767:
v3 = 35;
goto LABEL_4;
case 4768:
v3 = 36;
goto LABEL_4;
case 4769:
v3 = 37;
goto LABEL_4;
case 4770:
v3 = 38;
goto LABEL_4;
case 4771:
v3 = 39;
goto LABEL_4;
case 4772:
v3 = 40;
goto LABEL_4;
case 4773:
v3 = 41;
goto LABEL_4;
case 4774:
v3 = 42;
goto LABEL_4;
case 4775:
v3 = 43;
goto LABEL_4;
case 4776:
v3 = 44;
goto LABEL_4;
case 4777:
v3 = 45;
goto LABEL_4;
case 4778:
v3 = 46;
goto LABEL_4;
case 4779:
v3 = 47;
goto LABEL_4;
case 4780:
v3 = 48;
goto LABEL_4;
case 4781:
v3 = 49;
goto LABEL_4;
case 4782:
v3 = 50;
goto LABEL_4;
case 4783:
v3 = 51;
goto LABEL_4;
case 4784:
v3 = 52;
goto LABEL_4;
case 4785:
v3 = 53;
goto LABEL_4;
case 4786:
v3 = 54;
goto LABEL_4;
case 4787:
v3 = 55;
goto LABEL_4;
case 4788:
v3 = 56;
goto LABEL_4;
case 4789:
v3 = 57;
goto LABEL_4;
case 4790:
v3 = 58;
goto LABEL_4;
case 4791:
v3 = 59;
goto LABEL_4;
case 4792:
v3 = 60;
goto LABEL_4;
case 4793:
v3 = 61;
goto LABEL_4;
case 4794:
v3 = 62;
goto LABEL_4;
case 4795:
v3 = 63;
goto LABEL_4;
case 4796:
v3 = 64;
goto LABEL_4;
case 4797:
v3 = 65;
goto LABEL_4;
case 4798:
v3 = 66;
goto LABEL_4;
case 4799:
v3 = 67;
goto LABEL_4;
case 4800:
v3 = 68;
goto LABEL_4;
case 4801:
v3 = 69;
goto LABEL_4;
case 4802:
v3 = 70;
goto LABEL_4;
case 4803:
v3 = 71;
goto LABEL_4;
case 4804:
v3 = 72;
goto LABEL_4;
case 4805:
v3 = 73;
goto LABEL_4;
case 4806:
v3 = 74;
goto LABEL_4;
case 4807:
v3 = 75;
goto LABEL_4;
case 4808:
v3 = 76;
goto LABEL_4;
case 4809:
v3 = 77;
goto LABEL_4;
case 4810:
v3 = 78;
goto LABEL_4;
case 4811:
v3 = 79;
goto LABEL_4;
case 4812:
v3 = 80;
goto LABEL_4;
case 4813:
v3 = 81;
goto LABEL_4;
case 4814:
v3 = 82;
goto LABEL_4;
case 4815:
v3 = 83;
goto LABEL_4;
case 4816:
v3 = 84;
goto LABEL_4;
case 4817:
v3 = 85;
goto LABEL_4;
case 4818:
v3 = 86;
goto LABEL_4;
case 4819:
v3 = 87;
goto LABEL_4;
case 4820:
v3 = 88;
goto LABEL_4;
case 4821:
v3 = 89;
goto LABEL_4;
case 4822:
v3 = 90;
goto LABEL_4;
case 4823:
v3 = 91;
goto LABEL_4;
case 4824:
v3 = 92;
goto LABEL_4;
case 4825:
v3 = 93;
goto LABEL_4;
case 4826:
v3 = 94;
goto LABEL_4;
case 4827:
v3 = 95;
goto LABEL_4;
case 4828:
v3 = 96;
goto LABEL_4;
case 4829:
v3 = 97;
goto LABEL_4;
case 4830:
v3 = 98;
goto LABEL_4;
case 4831:
v3 = 99;
goto LABEL_4;
case 4832:
v3 = 100;
goto LABEL_4;
case 4833:
v3 = 101;
goto LABEL_4;
case 4834:
v3 = 102;
goto LABEL_4;
case 4835:
v3 = 103;
goto LABEL_4;
case 4836:
v3 = 104;
goto LABEL_4;
case 4837:
v3 = 105;
goto LABEL_4;
case 4838:
v3 = 106;
goto LABEL_4;
case 4839:
v3 = 107;
goto LABEL_4;
case 4840:
v3 = 108;
goto LABEL_4;
case 4841:
v3 = 109;
goto LABEL_4;
case 4842:
v3 = 110;
goto LABEL_4;
case 4843:
v3 = 111;
goto LABEL_4;
case 4844:
v3 = 112;
goto LABEL_4;
case 4845:
v3 = 113;
goto LABEL_4;
case 4846:
v3 = 114;
goto LABEL_4;
case 4847:
v3 = 115;
goto LABEL_4;
case 4848:
v3 = 116;
goto LABEL_4;
case 4849:
v3 = 117;
goto LABEL_4;
case 4850:
v3 = 118;
goto LABEL_4;
case 4851:
v3 = 119;
goto LABEL_4;
case 4852:
v3 = 120;
goto LABEL_4;
case 4853:
v3 = 121;
goto LABEL_4;
case 4854:
v3 = 122;
goto LABEL_4;
case 4855:
v3 = 123;
goto LABEL_4;
case 4856:
v3 = 124;
goto LABEL_4;
case 4857:
v3 = 125;
goto LABEL_4;
case 4858:
v3 = 126;
goto LABEL_4;
case 4859:
v3 = 127;
goto LABEL_4;
case 4860:
v3 = 128;
goto LABEL_4;
case 4861:
v3 = 129;
goto LABEL_4;
case 4862:
v3 = 130;
LABEL_4:
*a2 = 0LL;
result = &(&CANOpenShellSlaveOD_objdict)[2 * v3];
break;
default:
*a2 = 100794368LL;
result = 0LL;
break;
}
return result;
}

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

*a3 = 0LL;
switch ( a1 )
{
case 4096:
v3 = 0;
goto LABEL_4;
case 4097:
v3 = 1;
goto LABEL_4;
case 4119:
*a3 = &CANOpenShellSlaveOD_Index1017_callbacks;
v3 = 2;
goto LABEL_4;
case 4120:
v3 = 3;
goto LABEL_4;
case 4736:
v3 = 4;
goto LABEL_4;
case 4737:
v3 = 5;
goto LABEL_4;
case 4738:
v3 = 6;
goto LABEL_4;
case 4739:
v3 = 7;
goto LABEL_4;
case 4740:
v3 = 8;
goto LABEL_4;
case 4741:
v3 = 9;
goto LABEL_4;
case 4742:
v3 = 10;
goto LABEL_4;
case 4743:
v3 = 11;
goto LABEL_4;
case 4744:
v3 = 12;
goto LABEL_4;
case 4745:
v3 = 13;
goto LABEL_4;
case 4746:
v3 = 14;
goto LABEL_4;
case 4747:
v3 = 15;
goto LABEL_4;
case 4748:
v3 = 16;
goto LABEL_4;
case 4749:
v3 = 17;
goto LABEL_4;
case 4750:
v3 = 18;
goto LABEL_4;
case 4751:
v3 = 19;
goto LABEL_4;
case 4752:
v3 = 20;
goto LABEL_4;
case 4753:
v3 = 21;
goto LABEL_4;
case 4754:
v3 = 22;
goto LABEL_4;
case 4755:
v3 = 23;
goto LABEL_4;
case 4756:
v3 = 24;
goto LABEL_4;
case 4757:
v3 = 25;
goto LABEL_4;
case 4758:
v3 = 26;
goto LABEL_4;
case 4759:
v3 = 27;
goto LABEL_4;
case 4760:
v3 = 28;
goto LABEL_4;
case 4761:
v3 = 29;
goto LABEL_4;
case 4762:
v3 = 30;
goto LABEL_4;
case 4763:
v3 = 31;
goto LABEL_4;
case 4764:
v3 = 32;
goto LABEL_4;
case 4765:
v3 = 33;
goto LABEL_4;
case 4766:
v3 = 34;
goto LABEL_4;
case 4767:
v3 = 35;
goto LABEL_4;
case 4768:
v3 = 36;
goto LABEL_4;
case 4769:
v3 = 37;
goto LABEL_4;
case 4770:
v3 = 38;
goto LABEL_4;
case 4771:
v3 = 39;
goto LABEL_4;
case 4772:
v3 = 40;
goto LABEL_4;
case 4773:
v3 = 41;
goto LABEL_4;
case 4774:
v3 = 42;
goto LABEL_4;
case 4775:
v3 = 43;
goto LABEL_4;
case 4776:
v3 = 44;
goto LABEL_4;
case 4777:
v3 = 45;
goto LABEL_4;
case 4778:
v3 = 46;
goto LABEL_4;
case 4779:
v3 = 47;
goto LABEL_4;
case 4780:
v3 = 48;
goto LABEL_4;
case 4781:
v3 = 49;
goto LABEL_4;
case 4782:
v3 = 50;
goto LABEL_4;
case 4783:
v3 = 51;
goto LABEL_4;
case 4784:
v3 = 52;
goto LABEL_4;
case 4785:
v3 = 53;
goto LABEL_4;
case 4786:
v3 = 54;
goto LABEL_4;
case 4787:
v3 = 55;
goto LABEL_4;
case 4788:
v3 = 56;
goto LABEL_4;
case 4789:
v3 = 57;
goto LABEL_4;
case 4790:
v3 = 58;
goto LABEL_4;
case 4791:
v3 = 59;
goto LABEL_4;
case 4792:
v3 = 60;
goto LABEL_4;
case 4793:
v3 = 61;
goto LABEL_4;
case 4794:
v3 = 62;
goto LABEL_4;
case 4795:
v3 = 63;
goto LABEL_4;
case 4796:
v3 = 64;
goto LABEL_4;
case 4797:
v3 = 65;
goto LABEL_4;
case 4798:
v3 = 66;
goto LABEL_4;
case 4799:
v3 = 67;
goto LABEL_4;
case 4800:
v3 = 68;
goto LABEL_4;
case 4801:
v3 = 69;
goto LABEL_4;
case 4802:
v3 = 70;
goto LABEL_4;
case 4803:
v3 = 71;
goto LABEL_4;
case 4804:
v3 = 72;
goto LABEL_4;
case 4805:
v3 = 73;
goto LABEL_4;
case 4806:
v3 = 74;
goto LABEL_4;
case 4807:
v3 = 75;
goto LABEL_4;
case 4808:
v3 = 76;
goto LABEL_4;
case 4809:
v3 = 77;
goto LABEL_4;
case 4810:
v3 = 78;
goto LABEL_4;
case 4811:
v3 = 79;
goto LABEL_4;
case 4812:
v3 = 80;
goto LABEL_4;
case 4813:
v3 = 81;
goto LABEL_4;
case 4814:
v3 = 82;
goto LABEL_4;
case 4815:
v3 = 83;
goto LABEL_4;
case 4816:
v3 = 84;
goto LABEL_4;
case 4817:
v3 = 85;
goto LABEL_4;
case 4818:
v3 = 86;
goto LABEL_4;
case 4819:
v3 = 87;
goto LABEL_4;
case 4820:
v3 = 88;
goto LABEL_4;
case 4821:
v3 = 89;
goto LABEL_4;
case 4822:
v3 = 90;
goto LABEL_4;
case 4823:
v3 = 91;
goto LABEL_4;
case 4824:
v3 = 92;
goto LABEL_4;
case 4825:
v3 = 93;
goto LABEL_4;
case 4826:
v3 = 94;
goto LABEL_4;
case 4827:
v3 = 95;
goto LABEL_4;
case 4828:
v3 = 96;
goto LABEL_4;
case 4829:
v3 = 97;
goto LABEL_4;
case 4830:
v3 = 98;
goto LABEL_4;
case 4831:
v3 = 99;
goto LABEL_4;
case 4832:
v3 = 100;
goto LABEL_4;
case 4833:
v3 = 101;
goto LABEL_4;
case 4834:
v3 = 102;
goto LABEL_4;
case 4835:
v3 = 103;
goto LABEL_4;
case 4836:
v3 = 104;
goto LABEL_4;
case 4837:
v3 = 105;
goto LABEL_4;
case 4838:
v3 = 106;
goto LABEL_4;
case 4839:
v3 = 107;
goto LABEL_4;
case 4840:
v3 = 108;
goto LABEL_4;
case 4841:
v3 = 109;
goto LABEL_4;
case 4842:
v3 = 110;
goto LABEL_4;
case 4843:
v3 = 111;
goto LABEL_4;
case 4844:
v3 = 112;
goto LABEL_4;
case 4845:
v3 = 113;
goto LABEL_4;
case 4846:
v3 = 114;
goto LABEL_4;
case 4847:
v3 = 115;
goto LABEL_4;
case 4848:
v3 = 116;
goto LABEL_4;
case 4849:
v3 = 117;
goto LABEL_4;
case 4850:
v3 = 118;
goto LABEL_4;
case 4851:
v3 = 119;
goto LABEL_4;
case 4852:
v3 = 120;
goto LABEL_4;
case 4853:
v3 = 121;
goto LABEL_4;
case 4854:
v3 = 122;
goto LABEL_4;
case 4855:
v3 = 123;
goto LABEL_4;
case 4856:
v3 = 124;
goto LABEL_4;
case 4857:
v3 = 125;
goto LABEL_4;
case 4858:
v3 = 126;
goto LABEL_4;
case 4859:
v3 = 127;
goto LABEL_4;
case 4860:
v3 = 128;
goto LABEL_4;
case 4861:
v3 = 129;
goto LABEL_4;
case 4862:
v3 = 130;
LABEL_4:
*a2 = 0LL;
result = &(&CANOpenShellSlaveOD_objdict)[2 * v3];
break;
default:
*a2 = 100794368LL;
result = 0LL;
break;
}
return result;
}

original_code:
const indextable * CANOpenShellSlaveOD_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 0x1017: i = 2;*callbacks = CANOpenShellSlaveOD_Index1017_callbacks; break;
  case 0x1018: i = 3;break;
  case 0x1280: i = 4;break;
  case 0x1281: i = 5;break;
  case 0x1282: i = 6;break;
  case 0x1283: i = 7;break;
  case 0x1284: i = 8;break;
  case 0x1285: i = 9;break;
  case 0x1286: i = 10;break;
  case 0x1287: i = 11;break;
  case 0x1288: i = 12;break;
  case 0x1289: i = 13;break;
  case 0x128A: i = 14;break;
  case 0x128B: i = 15;break;
  case 0x128C: i = 16;break;
  case 0x128D: i = 17;break;
  case 0x128E: i = 18;break;
  case 0x128F: i = 19;break;
  case 0x1290: i = 20;break;
  case 0x1291: i = 21;break;
  case 0x1292: i = 22;break;
  case 0x1293: i = 23;break;
  case 0x1294: i = 24;break;
  case 0x1295: i = 25;break;
  case 0x1296: i = 26;break;
  case 0x1297: i = 27;break;
  case 0x1298: i = 28;break;
  case 0x1299: i = 29;break;
  case 0x129A: i = 30;break;
  case 0x129B: i = 31;break;
  case 0x129C: i = 32;break;
  case 0x129D: i = 33;break;
  case 0x129E: i = 34;break;
  case 0x129F: i = 35;break;
  case 0x12A0: i = 36;break;
  case 0x12A1: i = 37;break;
  case 0x12A2: i = 38;break;
  case 0x12A3: i = 39;break;
  case 0x12A4: i = 40;break;
  case 0x12A5: i = 41;break;
  case 0x12A6: i = 42;break;
  case 0x12A7: i = 43;break;
  case 0x12A8: i = 44;break;
  case 0x12A9: i = 45;break;
  case 0x12AA: i = 46;break;
  case 0x12AB: i = 47;break;
  case 0x12AC: i = 48;break;
  case 0x12AD: i = 49;break;
  case 0x12AE: i = 50;break;
  case 0x12AF: i = 51;break;
  case 0x12B0: i = 52;break;
  case 0x12B1: i = 53;break;
  case 0x12B2: i = 54;break;
  case 0x12B3: i = 55;break;
  case 0x12B4: i = 56;break;
  case 0x12B5: i = 57;break;
  case 0x12B6: i = 58;break;
  case 0x12B7: i = 59;break;
  case 0x12B8: i = 60;break;
  case 0x12B9: i = 61;break;
  case 0x12BA: i = 62;break;
  case 0x12BB: i = 63;break;
  case 0x12BC: i = 64;break;
  case 0x12BD: i = 65;break;
  case 0x12BE: i = 66;break;
  case 0x12BF: i = 67;break;
  case 0x12C0: i = 68;break;
  case 0x12C1: i = 69;break;
  case 0x12C2: i = 70;break;
  case 0x12C3: i = 71;break;
  case 0x12C4: i = 72;break;
  case 0x12C5: i = 73;break;
  case 0x12C6: i = 74;break;
  case 0x12C7: i = 75;break;
  case 0x12C8: i = 76;break;
  case 0x12C9: i = 77;break;
  case 0x12CA: i = 78;break;
  case 0x12CB: i = 79;break;
  case 0x12CC: i = 80;break;
  case 0x12CD: i = 81;break;
  case 0x12CE: i = 82;break;
  case 0x12CF: i = 83;break;
  case 0x12D0: i = 84;break;
  case 0x12D1: i = 85;break;
  case 0x12D2: i = 86;break;
  case 0x12D3: i = 87;break;
  case 0x12D4: i = 88;break;
  case 0x12D5: i = 89;break;
  case 0x12D6: i = 90;break;
  case 0x12D7: i = 91;break;
  case 0x12D8: i = 92;break;
  case 0x12D9: i = 93;break;
  case 0x12DA: i = 94;break;
  case 0x12DB: i = 95;break;
  case 0x12DC: i = 96;break;
  case 0x12DD: i = 97;break;
  case 0x12DE: i = 98;break;
  case 0x12DF: i = 99;break;
  case 0x12E0: i = 100;break;
  case 0x12E1: i = 101;break;
  case 0x12E2: i = 102;break;
  case 0x12E3: i = 103;break;
  case 0x12E4: i = 104;break;
  case 0x12E5: i = 105;break;
  case 0x12E6: i = 106;break;
  case 0x12E7: i = 107;break;
  case 0x12E8: i = 108;break;
  case 0x12E9: i = 109;break;
  case 0x12EA: i = 110;break;
  case 0x12EB: i = 111;break;
  case 0x12EC: i = 112;break;
  case 0x12ED: i = 113;break;
  case 0x12EE: i = 114;break;
  case 0x12EF: i = 115;break;
  case 0x12F0: i = 116;break;
  case 0x12F1: i = 117;break;
  case 0x12F2: i = 118;break;
  case 0x12F3: i = 119;break;
  case 0x12F4: i = 120;break;
  case 0x12F5: i = 121;break;
  case 0x12F6: i = 122;break;
  case 0x12F7: i = 123;break;
  case 0x12F8: i = 124;break;
  case 0x12F9: i = 125;break;
  case 0x12FA: i = 126;break;
  case 0x12FB: i = 127;break;
  case 0x12FC: i = 128;break;
  case 0x12FD: i = 129;break;
  case 0x12FE: i = 130;break;
  default:
   *errorCode = 0x06020000;
   return ((void *)0);
 }
 *errorCode = 0x00000000;
 return &CANOpenShellSlaveOD_objdict[i];
}

canonical_original_code:
struct td_indextable *CANOpenShellSlaveOD_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 0x1017: i = 2;*callbacks = CANOpenShellSlaveOD_Index1017_callbacks; break;
  case 0x1018: i = 3;break;
  case 0x1280: i = 4;break;
  case 0x1281: i = 5;break;
  case 0x1282: i = 6;break;
  case 0x1283: i = 7;break;
  case 0x1284: i = 8;break;
  case 0x1285: i = 9;break;
  case 0x1286: i = 10;break;
  case 0x1287: i = 11;break;
  case 0x1288: i = 12;break;
  case 0x1289: i = 13;break;
  case 0x128A: i = 14;break;
  case 0x128B: i = 15;break;
  case 0x128C: i = 16;break;
  case 0x128D: i = 17;break;
  case 0x128E: i = 18;break;
  case 0x128F: i = 19;break;
  case 0x1290: i = 20;break;
  case 0x1291: i = 21;break;
  case 0x1292: i = 22;break;
  case 0x1293: i = 23;break;
  case 0x1294: i = 24;break;
  case 0x1295: i = 25;break;
  case 0x1296: i = 26;break;
  case 0x1297: i = 27;break;
  case 0x1298: i = 28;break;
  case 0x1299: i = 29;break;
  case 0x129A: i = 30;break;
  case 0x129B: i = 31;break;
  case 0x129C: i = 32;break;
  case 0x129D: i = 33;break;
  case 0x129E: i = 34;break;
  case 0x129F: i = 35;break;
  case 0x12A0: i = 36;break;
  case 0x12A1: i = 37;break;
  case 0x12A2: i = 38;break;
  case 0x12A3: i = 39;break;
  case 0x12A4: i = 40;break;
  case 0x12A5: i = 41;break;
  case 0x12A6: i = 42;break;
  case 0x12A7: i = 43;break;
  case 0x12A8: i = 44;break;
  case 0x12A9: i = 45;break;
  case 0x12AA: i = 46;break;
  case 0x12AB: i = 47;break;
  case 0x12AC: i = 48;break;
  case 0x12AD: i = 49;break;
  case 0x12AE: i = 50;break;
  case 0x12AF: i = 51;break;
  case 0x12B0: i = 52;break;
  case 0x12B1: i = 53;break;
  case 0x12B2: i = 54;break;
  case 0x12B3: i = 55;break;
  case 0x12B4: i = 56;break;
  case 0x12B5: i = 57;break;
  case 0x12B6: i = 58;break;
  case 0x12B7: i = 59;break;
  case 0x12B8: i = 60;break;
  case 0x12B9: i = 61;break;
  case 0x12BA: i = 62;break;
  case 0x12BB: i = 63;break;
  case 0x12BC: i = 64;break;
  case 0x12BD: i = 65;break;
  case 0x12BE: i = 66;break;
  case 0x12BF: i = 67;break;
  case 0x12C0: i = 68;break;
  case 0x12C1: i = 69;break;
  case 0x12C2: i = 70;break;
  case 0x12C3: i = 71;break;
  case 0x12C4: i = 72;break;
  case 0x12C5: i = 73;break;
  case 0x12C6: i = 74;break;
  case 0x12C7: i = 75;break;
  case 0x12C8: i = 76;break;
  case 0x12C9: i = 77;break;
  case 0x12CA: i = 78;break;
  case 0x12CB: i = 79;break;
  case 0x12CC: i = 80;break;
  case 0x12CD: i = 81;break;
  case 0x12CE: i = 82;break;
  case 0x12CF: i = 83;break;
  case 0x12D0: i = 84;break;
  case 0x12D1: i = 85;break;
  case 0x12D2: i = 86;break;
  case 0x12D3: i = 87;break;
  case 0x12D4: i = 88;break;
  case 0x12D5: i = 89;break;
  case 0x12D6: i = 90;break;
  case 0x12D7: i = 91;break;
  case 0x12D8: i = 92;break;
  case 0x12D9: i = 93;break;
  case 0x12DA: i = 94;break;
  case 0x12DB: i = 95;break;
  case 0x12DC: i = 96;break;
  case 0x12DD: i = 97;break;
  case 0x12DE: i = 98;break;
  case 0x12DF: i = 99;break;
  case 0x12E0: i = 100;break;
  case 0x12E1: i = 101;break;
  case 0x12E2: i = 102;break;
  case 0x12E3: i = 103;break;
  case 0x12E4: i = 104;break;
  case 0x12E5: i = 105;break;
  case 0x12E6: i = 106;break;
  case 0x12E7: i = 107;break;
  case 0x12E8: i = 108;break;
  case 0x12E9: i = 109;break;
  case 0x12EA: i = 110;break;
  case 0x12EB: i = 111;break;
  case 0x12EC: i = 112;break;
  case 0x12ED: i = 113;break;
  case 0x12EE: i = 114;break;
  case 0x12EF: i = 115;break;
  case 0x12F0: i = 116;break;
  case 0x12F1: i = 117;break;
  case 0x12F2: i = 118;break;
  case 0x12F3: i = 119;break;
  case 0x12F4: i = 120;break;
  case 0x12F5: i = 121;break;
  case 0x12F6: i = 122;break;
  case 0x12F7: i = 123;break;
  case 0x12F8: i = 124;break;
  case 0x12F9: i = 125;break;
  case 0x12FA: i = 126;break;
  case 0x12FB: i = 127;break;
  case 0x12FC: i = 128;break;
  case 0x12FD: i = 129;break;
  case 0x12FE: i = 130;break;
  default:
   *errorCode = 0x06020000;
   return ((void *)0);
 }
 *errorCode = 0x00000000;
 return &CANOpenShellSlaveOD_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)

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


TranslateBaudRate

original_code:
int TranslateBaudRate(char* optarg){
 if(!strcmp( optarg, "1M")) return (int)1000;
 if(!strcmp( optarg, "500K")) return (int)500;
 if(!strcmp( optarg, "250K")) return (int)250;
 if(!strcmp( optarg, "125K")) return (int)125;
 if(!strcmp( optarg, "100K")) return (int)100;
 if(!strcmp( optarg, "50K")) return (int)50;
 if(!strcmp( optarg, "20K")) return (int)20;
 if(!strcmp( optarg, "10K")) return (int)10;
 if(!strcmp( optarg, "5K")) return (int)5;
 if(!strcmp( optarg, "none")) return 0;
 return 0x0000;
}

canonical_original_code:
int TranslateBaudRate(char *optarg){
 if(!strcmp( optarg, "1M")) return (int)1000;
 if(!strcmp( optarg, "500K")) return (int)500;
 if(!strcmp( optarg, "250K")) return (int)250;
 if(!strcmp( optarg, "125K")) return (int)125;
 if(!strcmp( optarg, "100K")) return (int)100;
 if(!strcmp( optarg, "50K")) return (int)50;
 if(!strcmp( optarg, "20K")) return (int)20;
 if(!strcmp( optarg, "10K")) return (int)10;
 if(!strcmp( optarg, "5K")) return (int)5;
 if(!strcmp( optarg, "none")) return 0;
 return 0x0000;
}

variable_types:
optarg
char *

return_type: int


decompiled_code:
bool __fastcall canReceive_driver(__int64 a1, void *a2)
{
return read(*(_DWORD *)(a1 + 4), a2, 0xCuLL) != 12;
}

canonical_decompiled_code:
bool __fastcall func0(__int64 a1, void *a2)
{
return read(*(_DWORD *)(a1 + 4), a2, 0xCuLL) != 12;
}

original_code:
unsigned char canReceive_driver(CAN_HANDLE fd0, Message *m)
{
 if(read(((CANPipe*)fd0)->pipe[0], m, sizeof(Message)) != (ssize_t)sizeof(Message))
 {
  return 1;
 }
 return 0;
}

canonical_original_code:
unsigned char canReceive_driver(void *fd0, struct Message *m)
{
 if(read(((struct CANPipe *)fd0)->pipe[0], m, sizeof(Message)) != (long)sizeof(Message))
 {
  return 1;
 }
 return 0;
}

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

return_type: unsigned char

user_defined_types: struct CANPipe { char used; int pipe[2]; }


decompiled_code:
__int64 __fastcall canSend_driver(_BYTE *a1, const void *a2)
{
_DWORD *v2; // rbx
_BYTE *v3; // rbp
unsigned int i; // er12

printf("%lx->[ ", 0xAAAAAAAAAAAAAAABLL * ((a1 - (_BYTE *)&canpipes) >> 2));
v2 = &canpipes;
v3 = &canpipes;
for ( i = 0; i != 16; ++i )
{
if ( *v3 && a1 != v3 )
printf("%x ", i);
v3 += 12;
}
printf(" ]");
do
{
if ( *(_BYTE *)v2 && a1 != (_BYTE *)v2 )
write(v2[2], a2, 0xCuLL);
v2 += 3;
}
while ( v2 != (_DWORD *)((char *)&canpipes + 192) );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(_BYTE *a1, const void *a2)
{
_DWORD *v2; // rbx
_BYTE *v3; // rbp
unsigned int i; // er12

printf("%lx->[ ", 0xAAAAAAAAAAAAAAABLL * ((a1 - (_BYTE *)&canpipes) >> 2));
v2 = &canpipes;
v3 = &canpipes;
for ( i = 0; i != 16; ++i )
{
if ( *v3 && a1 != v3 )
printf("%x ", i);
v3 += 12;
}
printf(" ]");
do
{
if ( *(_BYTE *)v2 && a1 != (_BYTE *)v2 )
write(v2[2], a2, 0xCuLL);
v2 += 3;
}
while ( v2 != (_DWORD *)((char *)&canpipes + 192) );
return 0LL;
}

original_code:
unsigned char canSend_driver(CAN_HANDLE fd0, Message const *m)
{
  int i;
  printf("%lx->[ ", (CANPipe*)fd0 - &canpipes[0]);
  for(i=0; i < 16; i++)
  {
   if(canpipes[i].used && &canpipes[i] != (CANPipe*)fd0)
   {
  printf("%x ",i);
   }
  }
  printf(" ]");
  print_message(m);
  for(i=0; i < 16; i++)
  {
   if(canpipes[i].used && &canpipes[i] != (CANPipe*)fd0)
   {
  write(canpipes[i].pipe[1], m, sizeof(Message));
   }
  }
  return 0;
}

canonical_original_code:
unsigned char canSend_driver(void *fd0, struct Message *m)
{
  int i;
  printf("%lx->[ ", (struct CANPipe *)fd0 - &canpipes[0]);
  for(i=0; i < 16; i++)
  {
   if(canpipes[i].used && &canpipes[i] != (struct CANPipe *)fd0)
   {
  printf("%x ",i);
   }
  }
  printf(" ]");
  print_message(m);
  for(i=0; i < 16; i++)
  {
   if(canpipes[i].used && &canpipes[i] != (struct CANPipe *)fd0)
   {
  write(canpipes[i].pipe[1], m, sizeof(Message));
   }
  }
  return 0;
}

variable_types: i int

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


decompiled_code:
__int64 __fastcall canChangeBaudRate_driver(__int64 a1, const char *a2)
{
unsigned int v2; // eax

v2 = TranslateBaudRate(a2);
printf("%lx-> changing to baud rate %s[%d]\n", 0xAAAAAAAAAAAAAAABLL * ((a1 - (__int64)&canpipes) >> 2), a2, v2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, const char *a2)
{
unsigned int v2; // eax

v2 = func2(a2);
printf("%lx-> changing to baud rate %s[%d]\n", 0xAAAAAAAAAAAAAAABLL * ((a1 - (__int64)&canpipes) >> 2), a2, v2);
return 0LL;
}

original_code:
unsigned char canChangeBaudRate_driver( CAN_HANDLE fd0, char* baud)
{
    printf("%lx-> changing to baud rate %s[%d]\n", (CANPipe*)fd0 - &canpipes[0],baud,TranslateBaudRate(baud));
    return 0;
}

canonical_original_code:
unsigned char canChangeBaudRate_driver(void *fd0, char *baud)
{
    printf("%lx-> changing to baud rate %s[%d]\n", (struct CANPipe *)fd0 - &canpipes[0],baud,TranslateBaudRate(baud));
    return 0;
}

variable_types:
baud
char *


decompiled_code:
char *canOpen_driver()
{
_BYTE *v0; // rax
int v1; // ebx
__int64 v3; // rbp

v0 = canpipes;
v1 = 0;
while ( *v0 )
{
++v1;
v0 += 12;
if ( v1 == 16 )
goto LABEL_4;
}
v3 = 12LL * v1;
if ( pipe((int *)&canpipes[v3 + 4]) )
{
LABEL_4:
fwrite("Open failed.\n", 1uLL, 0xDuLL, stderr);
return 0LL;
}
canpipes[12 * v1] = 1;
return &canpipes[v3];
}

canonical_decompiled_code:
char *func4()
{
_BYTE *v0; // rax
int v1; // ebx
__int64 v3; // rbp

v0 = canpipes;
v1 = 0;
while ( *v0 )
{
++v1;
v0 += 12;
if ( v1 == 16 )
goto LABEL_4;
}
v3 = 12LL * v1;
if ( pipe((int *)&canpipes[v3 + 4]) )
{
LABEL_4:
fwrite("Open failed.\n", 1uLL, 0xDuLL, stderr);
return 0LL;
}
canpipes[12 * v1] = 1;
return &canpipes[v3];
}

original_code:
CAN_HANDLE canOpen_driver(s_BOARD *board)
{
  int i;
  for(i=0; i < 16; i++)
  {
   if(!canpipes[i].used)
    break;
  }
  if (i==16 || pipe(canpipes[i].pipe))
    {
      fprintf (stderr, "Open failed.\n");
      return (CAN_HANDLE)((void *)0);
    }
   canpipes[i].used = 1;
   return (CAN_HANDLE) &canpipes[i];
}

canonical_original_code:
void *canOpen_driver(struct struct_s_BOARD *board)
{
  int i;
  for(i=0; i < 16; i++)
  {
   if(!canpipes[i].used)
    break;
  }
  if (i==16 || pipe(canpipes[i].pipe))
    {
      fprintf (stderr, "Open failed.\n");
      return (CAN_HANDLE)((void *)0);
    }
   canpipes[i].used = 1;
   return (CAN_HANDLE) &canpipes[i];
}

variable_types: struct struct_s_BOARD { char *busname; char *baudrate; } *

return_type: void *


decompiled_code:
__int64 __fastcall canClose_driver(__int64 a1)
{
close(*(_DWORD *)(a1 + 4));
close(*(_DWORD *)(a1 + 8));
*(_BYTE *)a1 = 0;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
close(*(_DWORD *)(a1 + 4));
close(*(_DWORD *)(a1 + 8));
*(_BYTE *)a1 = 0;
return 0LL;
}

original_code:
int canClose_driver(CAN_HANDLE fd0)
{
  close(((CANPipe*)fd0)->pipe[0]);
  close(((CANPipe*)fd0)->pipe[1]);
  ((CANPipe*)fd0)->used = 0;
  return 0;
}

canonical_original_code:
int canClose_driver(void *fd0)
{
  close(((struct CANPipe *)fd0)->pipe[0]);
  close(((struct CANPipe *)fd0)->pipe[1]);
  ((struct CANPipe *)fd0)->used = 0;
  return 0;
}


decompiled_code:
__int64 __fastcall TestSlave_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 TestSlave_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 TestSlave_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 TestSlave_scanIndexOD(unsigned __int16 a1, _QWORD *a2, _QWORD *a3)
{
int v3; // eax

*a3 = 0LL;
if ( a1 > 0x1A04u )
{
if ( (unsigned __int16)(a1 - 0x2000) <= 0xCu )
{
switch ( a1 )
{
case 0x2000u:
v3 = 21;
goto LABEL_9;
case 0x2001u:
v3 = 22;
goto LABEL_9;
case 0x2002u:
v3 = 23;
goto LABEL_9;
case 0x2003u:
v3 = 24;
goto LABEL_9;
case 0x2004u:
v3 = 25;
goto LABEL_9;
case 0x2005u:
v3 = 26;
goto LABEL_9;
case 0x2006u:
v3 = 27;
goto LABEL_9;
case 0x2007u:
v3 = 28;
goto LABEL_9;
case 0x2008u:
v3 = 29;
goto LABEL_9;
case 0x2009u:
v3 = 30;
goto LABEL_9;
case 0x200Au:
v3 = 31;
goto LABEL_9;
case 0x200Bu:
v3 = 32;
goto LABEL_9;
case 0x200Cu:
v3 = 33;
goto LABEL_9;
default:
goto LABEL_42;
}
}
goto LABEL_42;
}
if ( a1 > 0x19FFu )
{
switch ( a1 )
{
case 0x1A00u:
v3 = 16;
goto LABEL_9;
case 0x1A01u:
v3 = 17;
goto LABEL_9;
case 0x1A02u:
v3 = 18;
goto LABEL_9;
case 0x1A03u:
v3 = 19;
goto LABEL_9;
case 0x1A04u:
v3 = 20;
goto LABEL_9;
default:
goto LABEL_42;
}
}
if ( a1 <= 0x1018u )
{
if ( a1 > 0xFFFu )
{
switch ( a1 )
{
case 0x1000u:
v3 = 0;
goto LABEL_9;
case 0x1001u:
v3 = 1;
goto LABEL_9;
case 0x1003u:
*a3 = &TestSlave_Index1003_callbacks;
v3 = 2;
goto LABEL_9;
case 0x1005u:
*a3 = &TestSlave_Index1005_callbacks;
v3 = 3;
goto LABEL_9;
case 0x1006u:
*a3 = &TestSlave_Index1006_callbacks;
v3 = 4;
goto LABEL_9;
case 0x1010u:
*a3 = &TestSlave_Index1010_callbacks;
v3 = 5;
goto LABEL_9;
case 0x1011u:
*a3 = &TestSlave_Index1011_callbacks;
v3 = 6;
goto LABEL_9;
case 0x1014u:
v3 = 7;
goto LABEL_9;
case 0x1017u:
*a3 = &TestSlave_Index1017_callbacks;
v3 = 8;
goto LABEL_9;
case 0x1018u:
v3 = 9;
goto LABEL_9;
default:
break;
}
}
LABEL_42:
*a2 = 100794368LL;
return 0LL;
}
if ( a1 != 4608 )
{
if ( (unsigned __int16)(a1 - 6144) <= 4u )
{
switch ( a1 )
{
case 0x1800u:
*a3 = &TestSlave_Index1800_callbacks;
v3 = 11;
goto LABEL_9;
case 0x1801u:
*a3 = &TestSlave_Index1801_callbacks;
v3 = 12;
goto LABEL_9;
case 0x1802u:
*a3 = &TestSlave_Index1802_callbacks;
v3 = 13;
goto LABEL_9;
case 0x1803u:
*a3 = &TestSlave_Index1803_callbacks;
v3 = 14;
goto LABEL_9;
case 0x1804u:
*a3 = &TestSlave_Index1804_callbacks;
v3 = 15;
goto LABEL_9;
default:
goto LABEL_42;
}
}
goto LABEL_42;
}
v3 = 10;
LABEL_9:
*a2 = 0LL;
return &(&TestSlave_objdict)[2 * v3];
}

canonical_decompiled_code:
void ***__fastcall func1(unsigned __int16 a1, _QWORD *a2, _QWORD *a3)
{
int v3; // eax

*a3 = 0LL;
if ( a1 > 0x1A04u )
{
if ( (unsigned __int16)(a1 - 0x2000) <= 0xCu )
{
switch ( a1 )
{
case 0x2000u:
v3 = 21;
goto LABEL_9;
case 0x2001u:
v3 = 22;
goto LABEL_9;
case 0x2002u:
v3 = 23;
goto LABEL_9;
case 0x2003u:
v3 = 24;
goto LABEL_9;
case 0x2004u:
v3 = 25;
goto LABEL_9;
case 0x2005u:
v3 = 26;
goto LABEL_9;
case 0x2006u:
v3 = 27;
goto LABEL_9;
case 0x2007u:
v3 = 28;
goto LABEL_9;
case 0x2008u:
v3 = 29;
goto LABEL_9;
case 0x2009u:
v3 = 30;
goto LABEL_9;
case 0x200Au:
v3 = 31;
goto LABEL_9;
case 0x200Bu:
v3 = 32;
goto LABEL_9;
case 0x200Cu:
v3 = 33;
goto LABEL_9;
default:
goto LABEL_42;
}
}
goto LABEL_42;
}
if ( a1 > 0x19FFu )
{
switch ( a1 )
{
case 0x1A00u:
v3 = 16;
goto LABEL_9;
case 0x1A01u:
v3 = 17;
goto LABEL_9;
case 0x1A02u:
v3 = 18;
goto LABEL_9;
case 0x1A03u:
v3 = 19;
goto LABEL_9;
case 0x1A04u:
v3 = 20;
goto LABEL_9;
default:
goto LABEL_42;
}
}
if ( a1 <= 0x1018u )
{
if ( a1 > 0xFFFu )
{
switch ( a1 )
{
case 0x1000u:
v3 = 0;
goto LABEL_9;
case 0x1001u:
v3 = 1;
goto LABEL_9;
case 0x1003u:
*a3 = &TestSlave_Index1003_callbacks;
v3 = 2;
goto LABEL_9;
case 0x1005u:
*a3 = &TestSlave_Index1005_callbacks;
v3 = 3;
goto LABEL_9;
case 0x1006u:
*a3 = &TestSlave_Index1006_callbacks;
v3 = 4;
goto LABEL_9;
case 0x1010u:
*a3 = &TestSlave_Index1010_callbacks;
v3 = 5;
goto LABEL_9;
case 0x1011u:
*a3 = &TestSlave_Index1011_callbacks;
v3 = 6;
goto LABEL_9;
case 0x1014u:
v3 = 7;
goto LABEL_9;
case 0x1017u:
*a3 = &TestSlave_Index1017_callbacks;
v3 = 8;
goto LABEL_9;
case 0x1018u:
v3 = 9;
goto LABEL_9;
default:
break;
}
}
LABEL_42:
*a2 = 100794368LL;
return 0LL;
}
if ( a1 != 4608 )
{
if ( (unsigned __int16)(a1 - 6144) <= 4u )
{
switch ( a1 )
{
case 0x1800u:
*a3 = &TestSlave_Index1800_callbacks;
v3 = 11;
goto LABEL_9;
case 0x1801u:
*a3 = &TestSlave_Index1801_callbacks;
v3 = 12;
goto LABEL_9;
case 0x1802u:
*a3 = &TestSlave_Index1802_callbacks;
v3 = 13;
goto LABEL_9;
case 0x1803u:
*a3 = &TestSlave_Index1803_callbacks;
v3 = 14;
goto LABEL_9;
case 0x1804u:
*a3 = &TestSlave_Index1804_callbacks;
v3 = 15;
goto LABEL_9;
default:
goto LABEL_42;
}
}
goto LABEL_42;
}
v3 = 10;
LABEL_9:
*a2 = 0LL;
return &(&TestSlave_objdict)[2 * v3];
}

original_code:
const indextable * TestSlave_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 = TestSlave_Index1003_callbacks; break;
  case 0x1005: i = 3;*callbacks = TestSlave_Index1005_callbacks; break;
  case 0x1006: i = 4;*callbacks = TestSlave_Index1006_callbacks; break;
  case 0x1010: i = 5;*callbacks = TestSlave_Index1010_callbacks; break;
  case 0x1011: i = 6;*callbacks = TestSlave_Index1011_callbacks; break;
  case 0x1014: i = 7;break;
  case 0x1017: i = 8;*callbacks = TestSlave_Index1017_callbacks; break;
  case 0x1018: i = 9;break;
  case 0x1200: i = 10;break;
  case 0x1800: i = 11;*callbacks = TestSlave_Index1800_callbacks; break;
  case 0x1801: i = 12;*callbacks = TestSlave_Index1801_callbacks; break;
  case 0x1802: i = 13;*callbacks = TestSlave_Index1802_callbacks; break;
  case 0x1803: i = 14;*callbacks = TestSlave_Index1803_callbacks; break;
  case 0x1804: i = 15;*callbacks = TestSlave_Index1804_callbacks; break;
  case 0x1A00: i = 16;break;
  case 0x1A01: i = 17;break;
  case 0x1A02: i = 18;break;
  case 0x1A03: i = 19;break;
  case 0x1A04: i = 20;break;
  case 0x2000: i = 21;break;
  case 0x2001: i = 22;break;
  case 0x2002: i = 23;break;
  case 0x2003: i = 24;break;
  case 0x2004: i = 25;break;
  case 0x2005: i = 26;break;
  case 0x2006: i = 27;break;
  case 0x2007: i = 28;break;
  case 0x2008: i = 29;break;
  case 0x2009: i = 30;break;
  case 0x200A: i = 31;break;
  case 0x200B: i = 32;break;
  case 0x200C: i = 33;break;
  default:
   *errorCode = 0x06020000;
   return ((void *)0);
 }
 *errorCode = 0x00000000;
 return &TestSlave_objdict[i];
}

canonical_original_code:
struct td_indextable *TestSlave_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 = TestSlave_Index1003_callbacks; break;
  case 0x1005: i = 3;*callbacks = TestSlave_Index1005_callbacks; break;
  case 0x1006: i = 4;*callbacks = TestSlave_Index1006_callbacks; break;
  case 0x1010: i = 5;*callbacks = TestSlave_Index1010_callbacks; break;
  case 0x1011: i = 6;*callbacks = TestSlave_Index1011_callbacks; break;
  case 0x1014: i = 7;break;
  case 0x1017: i = 8;*callbacks = TestSlave_Index1017_callbacks; break;
  case 0x1018: i = 9;break;
  case 0x1200: i = 10;break;
  case 0x1800: i = 11;*callbacks = TestSlave_Index1800_callbacks; break;
  case 0x1801: i = 12;*callbacks = TestSlave_Index1801_callbacks; break;
  case 0x1802: i = 13;*callbacks = TestSlave_Index1802_callbacks; break;
  case 0x1803: i = 14;*callbacks = TestSlave_Index1803_callbacks; break;
  case 0x1804: i = 15;*callbacks = TestSlave_Index1804_callbacks; break;
  case 0x1A00: i = 16;break;
  case 0x1A01: i = 17;break;
  case 0x1A02: i = 18;break;
  case 0x1A03: i = 19;break;
  case 0x1A04: i = 20;break;
  case 0x2000: i = 21;break;
  case 0x2001: i = 22;break;
  case 0x2002: i = 23;break;
  case 0x2003: i = 24;break;
  case 0x2004: i = 25;break;
  case 0x2005: i = 26;break;
  case 0x2006: i = 27;break;
  case 0x2007: i = 28;break;
  case 0x2008: i = 29;break;
  case 0x2009: i = 30;break;
  case 0x200A: i = 31;break;
  case 0x200B: i = 32;break;
  case 0x200C: i = 33;break;
  default:
   *errorCode = 0x06020000;
   return ((void *)0);
 }
 *errorCode = 0x00000000;
 return &TestSlave_objdict[i];
}

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

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

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: 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 struct_s_PDO_status { unsigned char transmit_type_parameter; short event_timer; short inhibit_timer; struct Message last_message; }

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

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

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


decompiled_code:
__int64 __fastcall CANOpenShellMasterOD_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 CANOpenShellMasterOD_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 CANOpenShellMasterOD_valueRangeTest(unsigned char typeValue, void *value)
{
  switch (typeValue) {
    case 0x9F:
      if (*(unsigned char *)value != (unsigned char)0) return 0x06090030;
      break;
  }
  return 0;
}


decompiled_code:
void ***__fastcall CANOpenShellMasterOD_scanIndexOD(__int16 a1, _QWORD *a2, _QWORD *a3)
{
int v3; // eax
void ***result; // rax

*a3 = 0LL;
switch ( a1 )
{
case 4096:
v3 = 0;
goto LABEL_4;
case 4097:
v3 = 1;
goto LABEL_4;
case 4101:
*a3 = &CANOpenShellMasterOD_Index1005_callbacks;
v3 = 2;
goto LABEL_4;
case 4102:
*a3 = &CANOpenShellMasterOD_Index1006_callbacks;
v3 = 3;
goto LABEL_4;
case 4119:
*a3 = &CANOpenShellMasterOD_Index1017_callbacks;
v3 = 4;
goto LABEL_4;
case 4120:
v3 = 5;
goto LABEL_4;
case 4736:
v3 = 6;
goto LABEL_4;
case 4737:
v3 = 7;
goto LABEL_4;
case 4738:
v3 = 8;
goto LABEL_4;
case 4739:
v3 = 9;
goto LABEL_4;
case 4740:
v3 = 10;
goto LABEL_4;
case 4741:
v3 = 11;
goto LABEL_4;
case 4742:
v3 = 12;
goto LABEL_4;
case 4743:
v3 = 13;
goto LABEL_4;
case 4744:
v3 = 14;
goto LABEL_4;
case 4745:
v3 = 15;
goto LABEL_4;
case 4746:
v3 = 16;
goto LABEL_4;
case 4747:
v3 = 17;
goto LABEL_4;
case 4748:
v3 = 18;
goto LABEL_4;
case 4749:
v3 = 19;
goto LABEL_4;
case 4750:
v3 = 20;
goto LABEL_4;
case 4751:
v3 = 21;
goto LABEL_4;
case 4752:
v3 = 22;
goto LABEL_4;
case 4753:
v3 = 23;
goto LABEL_4;
case 4754:
v3 = 24;
goto LABEL_4;
case 4755:
v3 = 25;
goto LABEL_4;
case 4756:
v3 = 26;
goto LABEL_4;
case 4757:
v3 = 27;
goto LABEL_4;
case 4758:
v3 = 28;
goto LABEL_4;
case 4759:
v3 = 29;
goto LABEL_4;
case 4760:
v3 = 30;
goto LABEL_4;
case 4761:
v3 = 31;
goto LABEL_4;
case 4762:
v3 = 32;
goto LABEL_4;
case 4763:
v3 = 33;
goto LABEL_4;
case 4764:
v3 = 34;
goto LABEL_4;
case 4765:
v3 = 35;
goto LABEL_4;
case 4766:
v3 = 36;
goto LABEL_4;
case 4767:
v3 = 37;
goto LABEL_4;
case 4768:
v3 = 38;
goto LABEL_4;
case 4769:
v3 = 39;
goto LABEL_4;
case 4770:
v3 = 40;
goto LABEL_4;
case 4771:
v3 = 41;
goto LABEL_4;
case 4772:
v3 = 42;
goto LABEL_4;
case 4773:
v3 = 43;
goto LABEL_4;
case 4774:
v3 = 44;
goto LABEL_4;
case 4775:
v3 = 45;
goto LABEL_4;
case 4776:
v3 = 46;
goto LABEL_4;
case 4777:
v3 = 47;
goto LABEL_4;
case 4778:
v3 = 48;
goto LABEL_4;
case 4779:
v3 = 49;
goto LABEL_4;
case 4780:
v3 = 50;
goto LABEL_4;
case 4781:
v3 = 51;
goto LABEL_4;
case 4782:
v3 = 52;
goto LABEL_4;
case 4783:
v3 = 53;
goto LABEL_4;
case 4784:
v3 = 54;
goto LABEL_4;
case 4785:
v3 = 55;
goto LABEL_4;
case 4786:
v3 = 56;
goto LABEL_4;
case 4787:
v3 = 57;
goto LABEL_4;
case 4788:
v3 = 58;
goto LABEL_4;
case 4789:
v3 = 59;
goto LABEL_4;
case 4790:
v3 = 60;
goto LABEL_4;
case 4791:
v3 = 61;
goto LABEL_4;
case 4792:
v3 = 62;
goto LABEL_4;
case 4793:
v3 = 63;
goto LABEL_4;
case 4794:
v3 = 64;
goto LABEL_4;
case 4795:
v3 = 65;
goto LABEL_4;
case 4796:
v3 = 66;
goto LABEL_4;
case 4797:
v3 = 67;
goto LABEL_4;
case 4798:
v3 = 68;
goto LABEL_4;
case 4799:
v3 = 69;
goto LABEL_4;
case 4800:
v3 = 70;
goto LABEL_4;
case 4801:
v3 = 71;
goto LABEL_4;
case 4802:
v3 = 72;
goto LABEL_4;
case 4803:
v3 = 73;
goto LABEL_4;
case 4804:
v3 = 74;
goto LABEL_4;
case 4805:
v3 = 75;
goto LABEL_4;
case 4806:
v3 = 76;
goto LABEL_4;
case 4807:
v3 = 77;
goto LABEL_4;
case 4808:
v3 = 78;
goto LABEL_4;
case 4809:
v3 = 79;
goto LABEL_4;
case 4810:
v3 = 80;
goto LABEL_4;
case 4811:
v3 = 81;
goto LABEL_4;
case 4812:
v3 = 82;
goto LABEL_4;
case 4813:
v3 = 83;
goto LABEL_4;
case 4814:
v3 = 84;
goto LABEL_4;
case 4815:
v3 = 85;
goto LABEL_4;
case 4816:
v3 = 86;
goto LABEL_4;
case 4817:
v3 = 87;
goto LABEL_4;
case 4818:
v3 = 88;
goto LABEL_4;
case 4819:
v3 = 89;
goto LABEL_4;
case 4820:
v3 = 90;
goto LABEL_4;
case 4821:
v3 = 91;
goto LABEL_4;
case 4822:
v3 = 92;
goto LABEL_4;
case 4823:
v3 = 93;
goto LABEL_4;
case 4824:
v3 = 94;
goto LABEL_4;
case 4825:
v3 = 95;
goto LABEL_4;
case 4826:
v3 = 96;
goto LABEL_4;
case 4827:
v3 = 97;
goto LABEL_4;
case 4828:
v3 = 98;
goto LABEL_4;
case 4829:
v3 = 99;
goto LABEL_4;
case 4830:
v3 = 100;
goto LABEL_4;
case 4831:
v3 = 101;
goto LABEL_4;
case 4832:
v3 = 102;
goto LABEL_4;
case 4833:
v3 = 103;
goto LABEL_4;
case 4834:
v3 = 104;
goto LABEL_4;
case 4835:
v3 = 105;
goto LABEL_4;
case 4836:
v3 = 106;
goto LABEL_4;
case 4837:
v3 = 107;
goto LABEL_4;
case 4838:
v3 = 108;
goto LABEL_4;
case 4839:
v3 = 109;
goto LABEL_4;
case 4840:
v3 = 110;
goto LABEL_4;
case 4841:
v3 = 111;
goto LABEL_4;
case 4842:
v3 = 112;
goto LABEL_4;
case 4843:
v3 = 113;
goto LABEL_4;
case 4844:
v3 = 114;
goto LABEL_4;
case 4845:
v3 = 115;
goto LABEL_4;
case 4846:
v3 = 116;
goto LABEL_4;
case 4847:
v3 = 117;
goto LABEL_4;
case 4848:
v3 = 118;
goto LABEL_4;
case 4849:
v3 = 119;
goto LABEL_4;
case 4850:
v3 = 120;
goto LABEL_4;
case 4851:
v3 = 121;
goto LABEL_4;
case 4852:
v3 = 122;
goto LABEL_4;
case 4853:
v3 = 123;
goto LABEL_4;
case 4854:
v3 = 124;
goto LABEL_4;
case 4855:
v3 = 125;
goto LABEL_4;
case 4856:
v3 = 126;
goto LABEL_4;
case 4857:
v3 = 127;
goto LABEL_4;
case 4858:
v3 = 128;
goto LABEL_4;
case 4859:
v3 = 129;
goto LABEL_4;
case 4860:
v3 = 130;
goto LABEL_4;
case 4861:
v3 = 131;
goto LABEL_4;
case 4862:
v3 = 132;
LABEL_4:
*a2 = 0LL;
result = &(&CANOpenShellMasterOD_objdict)[2 * v3];
break;
default:
*a2 = 100794368LL;
result = 0LL;
break;
}
return result;
}

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

*a3 = 0LL;
switch ( a1 )
{
case 4096:
v3 = 0;
goto LABEL_4;
case 4097:
v3 = 1;
goto LABEL_4;
case 4101:
*a3 = &CANOpenShellMasterOD_Index1005_callbacks;
v3 = 2;
goto LABEL_4;
case 4102:
*a3 = &CANOpenShellMasterOD_Index1006_callbacks;
v3 = 3;
goto LABEL_4;
case 4119:
*a3 = &CANOpenShellMasterOD_Index1017_callbacks;
v3 = 4;
goto LABEL_4;
case 4120:
v3 = 5;
goto LABEL_4;
case 4736:
v3 = 6;
goto LABEL_4;
case 4737:
v3 = 7;
goto LABEL_4;
case 4738:
v3 = 8;
goto LABEL_4;
case 4739:
v3 = 9;
goto LABEL_4;
case 4740:
v3 = 10;
goto LABEL_4;
case 4741:
v3 = 11;
goto LABEL_4;
case 4742:
v3 = 12;
goto LABEL_4;
case 4743:
v3 = 13;
goto LABEL_4;
case 4744:
v3 = 14;
goto LABEL_4;
case 4745:
v3 = 15;
goto LABEL_4;
case 4746:
v3 = 16;
goto LABEL_4;
case 4747:
v3 = 17;
goto LABEL_4;
case 4748:
v3 = 18;
goto LABEL_4;
case 4749:
v3 = 19;
goto LABEL_4;
case 4750:
v3 = 20;
goto LABEL_4;
case 4751:
v3 = 21;
goto LABEL_4;
case 4752:
v3 = 22;
goto LABEL_4;
case 4753:
v3 = 23;
goto LABEL_4;
case 4754:
v3 = 24;
goto LABEL_4;
case 4755:
v3 = 25;
goto LABEL_4;
case 4756:
v3 = 26;
goto LABEL_4;
case 4757:
v3 = 27;
goto LABEL_4;
case 4758:
v3 = 28;
goto LABEL_4;
case 4759:
v3 = 29;
goto LABEL_4;
case 4760:
v3 = 30;
goto LABEL_4;
case 4761:
v3 = 31;
goto LABEL_4;
case 4762:
v3 = 32;
goto LABEL_4;
case 4763:
v3 = 33;
goto LABEL_4;
case 4764:
v3 = 34;
goto LABEL_4;
case 4765:
v3 = 35;
goto LABEL_4;
case 4766:
v3 = 36;
goto LABEL_4;
case 4767:
v3 = 37;
goto LABEL_4;
case 4768:
v3 = 38;
goto LABEL_4;
case 4769:
v3 = 39;
goto LABEL_4;
case 4770:
v3 = 40;
goto LABEL_4;
case 4771:
v3 = 41;
goto LABEL_4;
case 4772:
v3 = 42;
goto LABEL_4;
case 4773:
v3 = 43;
goto LABEL_4;
case 4774:
v3 = 44;
goto LABEL_4;
case 4775:
v3 = 45;
goto LABEL_4;
case 4776:
v3 = 46;
goto LABEL_4;
case 4777:
v3 = 47;
goto LABEL_4;
case 4778:
v3 = 48;
goto LABEL_4;
case 4779:
v3 = 49;
goto LABEL_4;
case 4780:
v3 = 50;
goto LABEL_4;
case 4781:
v3 = 51;
goto LABEL_4;
case 4782:
v3 = 52;
goto LABEL_4;
case 4783:
v3 = 53;
goto LABEL_4;
case 4784:
v3 = 54;
goto LABEL_4;
case 4785:
v3 = 55;
goto LABEL_4;
case 4786:
v3 = 56;
goto LABEL_4;
case 4787:
v3 = 57;
goto LABEL_4;
case 4788:
v3 = 58;
goto LABEL_4;
case 4789:
v3 = 59;
goto LABEL_4;
case 4790:
v3 = 60;
goto LABEL_4;
case 4791:
v3 = 61;
goto LABEL_4;
case 4792:
v3 = 62;
goto LABEL_4;
case 4793:
v3 = 63;
goto LABEL_4;
case 4794:
v3 = 64;
goto LABEL_4;
case 4795:
v3 = 65;
goto LABEL_4;
case 4796:
v3 = 66;
goto LABEL_4;
case 4797:
v3 = 67;
goto LABEL_4;
case 4798:
v3 = 68;
goto LABEL_4;
case 4799:
v3 = 69;
goto LABEL_4;
case 4800:
v3 = 70;
goto LABEL_4;
case 4801:
v3 = 71;
goto LABEL_4;
case 4802:
v3 = 72;
goto LABEL_4;
case 4803:
v3 = 73;
goto LABEL_4;
case 4804:
v3 = 74;
goto LABEL_4;
case 4805:
v3 = 75;
goto LABEL_4;
case 4806:
v3 = 76;
goto LABEL_4;
case 4807:
v3 = 77;
goto LABEL_4;
case 4808:
v3 = 78;
goto LABEL_4;
case 4809:
v3 = 79;
goto LABEL_4;
case 4810:
v3 = 80;
goto LABEL_4;
case 4811:
v3 = 81;
goto LABEL_4;
case 4812:
v3 = 82;
goto LABEL_4;
case 4813:
v3 = 83;
goto LABEL_4;
case 4814:
v3 = 84;
goto LABEL_4;
case 4815:
v3 = 85;
goto LABEL_4;
case 4816:
v3 = 86;
goto LABEL_4;
case 4817:
v3 = 87;
goto LABEL_4;
case 4818:
v3 = 88;
goto LABEL_4;
case 4819:
v3 = 89;
goto LABEL_4;
case 4820:
v3 = 90;
goto LABEL_4;
case 4821:
v3 = 91;
goto LABEL_4;
case 4822:
v3 = 92;
goto LABEL_4;
case 4823:
v3 = 93;
goto LABEL_4;
case 4824:
v3 = 94;
goto LABEL_4;
case 4825:
v3 = 95;
goto LABEL_4;
case 4826:
v3 = 96;
goto LABEL_4;
case 4827:
v3 = 97;
goto LABEL_4;
case 4828:
v3 = 98;
goto LABEL_4;
case 4829:
v3 = 99;
goto LABEL_4;
case 4830:
v3 = 100;
goto LABEL_4;
case 4831:
v3 = 101;
goto LABEL_4;
case 4832:
v3 = 102;
goto LABEL_4;
case 4833:
v3 = 103;
goto LABEL_4;
case 4834:
v3 = 104;
goto LABEL_4;
case 4835:
v3 = 105;
goto LABEL_4;
case 4836:
v3 = 106;
goto LABEL_4;
case 4837:
v3 = 107;
goto LABEL_4;
case 4838:
v3 = 108;
goto LABEL_4;
case 4839:
v3 = 109;
goto LABEL_4;
case 4840:
v3 = 110;
goto LABEL_4;
case 4841:
v3 = 111;
goto LABEL_4;
case 4842:
v3 = 112;
goto LABEL_4;
case 4843:
v3 = 113;
goto LABEL_4;
case 4844:
v3 = 114;
goto LABEL_4;
case 4845:
v3 = 115;
goto LABEL_4;
case 4846:
v3 = 116;
goto LABEL_4;
case 4847:
v3 = 117;
goto LABEL_4;
case 4848:
v3 = 118;
goto LABEL_4;
case 4849:
v3 = 119;
goto LABEL_4;
case 4850:
v3 = 120;
goto LABEL_4;
case 4851:
v3 = 121;
goto LABEL_4;
case 4852:
v3 = 122;
goto LABEL_4;
case 4853:
v3 = 123;
goto LABEL_4;
case 4854:
v3 = 124;
goto LABEL_4;
case 4855:
v3 = 125;
goto LABEL_4;
case 4856:
v3 = 126;
goto LABEL_4;
case 4857:
v3 = 127;
goto LABEL_4;
case 4858:
v3 = 128;
goto LABEL_4;
case 4859:
v3 = 129;
goto LABEL_4;
case 4860:
v3 = 130;
goto LABEL_4;
case 4861:
v3 = 131;
goto LABEL_4;
case 4862:
v3 = 132;
LABEL_4:
*a2 = 0LL;
result = &(&CANOpenShellMasterOD_objdict)[2 * v3];
break;
default:
*a2 = 100794368LL;
result = 0LL;
break;
}
return result;
}

original_code:
const indextable * CANOpenShellMasterOD_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 0x1005: i = 2;*callbacks = CANOpenShellMasterOD_Index1005_callbacks; break;
  case 0x1006: i = 3;*callbacks = CANOpenShellMasterOD_Index1006_callbacks; break;
  case 0x1017: i = 4;*callbacks = CANOpenShellMasterOD_Index1017_callbacks; break;
  case 0x1018: i = 5;break;
  case 0x1280: i = 6;break;
  case 0x1281: i = 7;break;
  case 0x1282: i = 8;break;
  case 0x1283: i = 9;break;
  case 0x1284: i = 10;break;
  case 0x1285: i = 11;break;
  case 0x1286: i = 12;break;
  case 0x1287: i = 13;break;
  case 0x1288: i = 14;break;
  case 0x1289: i = 15;break;
  case 0x128A: i = 16;break;
  case 0x128B: i = 17;break;
  case 0x128C: i = 18;break;
  case 0x128D: i = 19;break;
  case 0x128E: i = 20;break;
  case 0x128F: i = 21;break;
  case 0x1290: i = 22;break;
  case 0x1291: i = 23;break;
  case 0x1292: i = 24;break;
  case 0x1293: i = 25;break;
  case 0x1294: i = 26;break;
  case 0x1295: i = 27;break;
  case 0x1296: i = 28;break;
  case 0x1297: i = 29;break;
  case 0x1298: i = 30;break;
  case 0x1299: i = 31;break;
  case 0x129A: i = 32;break;
  case 0x129B: i = 33;break;
  case 0x129C: i = 34;break;
  case 0x129D: i = 35;break;
  case 0x129E: i = 36;break;
  case 0x129F: i = 37;break;
  case 0x12A0: i = 38;break;
  case 0x12A1: i = 39;break;
  case 0x12A2: i = 40;break;
  case 0x12A3: i = 41;break;
  case 0x12A4: i = 42;break;
  case 0x12A5: i = 43;break;
  case 0x12A6: i = 44;break;
  case 0x12A7: i = 45;break;
  case 0x12A8: i = 46;break;
  case 0x12A9: i = 47;break;
  case 0x12AA: i = 48;break;
  case 0x12AB: i = 49;break;
  case 0x12AC: i = 50;break;
  case 0x12AD: i = 51;break;
  case 0x12AE: i = 52;break;
  case 0x12AF: i = 53;break;
  case 0x12B0: i = 54;break;
  case 0x12B1: i = 55;break;
  case 0x12B2: i = 56;break;
  case 0x12B3: i = 57;break;
  case 0x12B4: i = 58;break;
  case 0x12B5: i = 59;break;
  case 0x12B6: i = 60;break;
  case 0x12B7: i = 61;break;
  case 0x12B8: i = 62;break;
  case 0x12B9: i = 63;break;
  case 0x12BA: i = 64;break;
  case 0x12BB: i = 65;break;
  case 0x12BC: i = 66;break;
  case 0x12BD: i = 67;break;
  case 0x12BE: i = 68;break;
  case 0x12BF: i = 69;break;
  case 0x12C0: i = 70;break;
  case 0x12C1: i = 71;break;
  case 0x12C2: i = 72;break;
  case 0x12C3: i = 73;break;
  case 0x12C4: i = 74;break;
  case 0x12C5: i = 75;break;
  case 0x12C6: i = 76;break;
  case 0x12C7: i = 77;break;
  case 0x12C8: i = 78;break;
  case 0x12C9: i = 79;break;
  case 0x12CA: i = 80;break;
  case 0x12CB: i = 81;break;
  case 0x12CC: i = 82;break;
  case 0x12CD: i = 83;break;
  case 0x12CE: i = 84;break;
  case 0x12CF: i = 85;break;
  case 0x12D0: i = 86;break;
  case 0x12D1: i = 87;break;
  case 0x12D2: i = 88;break;
  case 0x12D3: i = 89;break;
  case 0x12D4: i = 90;break;
  case 0x12D5: i = 91;break;
  case 0x12D6: i = 92;break;
  case 0x12D7: i = 93;break;
  case 0x12D8: i = 94;break;
  case 0x12D9: i = 95;break;
  case 0x12DA: i = 96;break;
  case 0x12DB: i = 97;break;
  case 0x12DC: i = 98;break;
  case 0x12DD: i = 99;break;
  case 0x12DE: i = 100;break;
  case 0x12DF: i = 101;break;
  case 0x12E0: i = 102;break;
  case 0x12E1: i = 103;break;
  case 0x12E2: i = 104;break;
  case 0x12E3: i = 105;break;
  case 0x12E4: i = 106;break;
  case 0x12E5: i = 107;break;
  case 0x12E6: i = 108;break;
  case 0x12E7: i = 109;break;
  case 0x12E8: i = 110;break;
  case 0x12E9: i = 111;break;
  case 0x12EA: i = 112;break;
  case 0x12EB: i = 113;break;
  case 0x12EC: i = 114;break;
  case 0x12ED: i = 115;break;
  case 0x12EE: i = 116;break;
  case 0x12EF: i = 117;break;
  case 0x12F0: i = 118;break;
  case 0x12F1: i = 119;break;
  case 0x12F2: i = 120;break;
  case 0x12F3: i = 121;break;
  case 0x12F4: i = 122;break;
  case 0x12F5: i = 123;break;
  case 0x12F6: i = 124;break;
  case 0x12F7: i = 125;break;
  case 0x12F8: i = 126;break;
  case 0x12F9: i = 127;break;
  case 0x12FA: i = 128;break;
  case 0x12FB: i = 129;break;
  case 0x12FC: i = 130;break;
  case 0x12FD: i = 131;break;
  case 0x12FE: i = 132;break;
  default:
   *errorCode = 0x06020000;
   return ((void *)0);
 }
 *errorCode = 0x00000000;
 return &CANOpenShellMasterOD_objdict[i];
}

canonical_original_code:
struct td_indextable *CANOpenShellMasterOD_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 0x1005: i = 2;*callbacks = CANOpenShellMasterOD_Index1005_callbacks; break;
  case 0x1006: i = 3;*callbacks = CANOpenShellMasterOD_Index1006_callbacks; break;
  case 0x1017: i = 4;*callbacks = CANOpenShellMasterOD_Index1017_callbacks; break;
  case 0x1018: i = 5;break;
  case 0x1280: i = 6;break;
  case 0x1281: i = 7;break;
  case 0x1282: i = 8;break;
  case 0x1283: i = 9;break;
  case 0x1284: i = 10;break;
  case 0x1285: i = 11;break;
  case 0x1286: i = 12;break;
  case 0x1287: i = 13;break;
  case 0x1288: i = 14;break;
  case 0x1289: i = 15;break;
  case 0x128A: i = 16;break;
  case 0x128B: i = 17;break;
  case 0x128C: i = 18;break;
  case 0x128D: i = 19;break;
  case 0x128E: i = 20;break;
  case 0x128F: i = 21;break;
  case 0x1290: i = 22;break;
  case 0x1291: i = 23;break;
  case 0x1292: i = 24;break;
  case 0x1293: i = 25;break;
  case 0x1294: i = 26;break;
  case 0x1295: i = 27;break;
  case 0x1296: i = 28;break;
  case 0x1297: i = 29;break;
  case 0x1298: i = 30;break;
  case 0x1299: i = 31;break;
  case 0x129A: i = 32;break;
  case 0x129B: i = 33;break;
  case 0x129C: i = 34;break;
  case 0x129D: i = 35;break;
  case 0x129E: i = 36;break;
  case 0x129F: i = 37;break;
  case 0x12A0: i = 38;break;
  case 0x12A1: i = 39;break;
  case 0x12A2: i = 40;break;
  case 0x12A3: i = 41;break;
  case 0x12A4: i = 42;break;
  case 0x12A5: i = 43;break;
  case 0x12A6: i = 44;break;
  case 0x12A7: i = 45;break;
  case 0x12A8: i = 46;break;
  case 0x12A9: i = 47;break;
  case 0x12AA: i = 48;break;
  case 0x12AB: i = 49;break;
  case 0x12AC: i = 50;break;
  case 0x12AD: i = 51;break;
  case 0x12AE: i = 52;break;
  case 0x12AF: i = 53;break;
  case 0x12B0: i = 54;break;
  case 0x12B1: i = 55;break;
  case 0x12B2: i = 56;break;
  case 0x12B3: i = 57;break;
  case 0x12B4: i = 58;break;
  case 0x12B5: i = 59;break;
  case 0x12B6: i = 60;break;
  case 0x12B7: i = 61;break;
  case 0x12B8: i = 62;break;
  case 0x12B9: i = 63;break;
  case 0x12BA: i = 64;break;
  case 0x12BB: i = 65;break;
  case 0x12BC: i = 66;break;
  case 0x12BD: i = 67;break;
  case 0x12BE: i = 68;break;
  case 0x12BF: i = 69;break;
  case 0x12C0: i = 70;break;
  case 0x12C1: i = 71;break;
  case 0x12C2: i = 72;break;
  case 0x12C3: i = 73;break;
  case 0x12C4: i = 74;break;
  case 0x12C5: i = 75;break;
  case 0x12C6: i = 76;break;
  case 0x12C7: i = 77;break;
  case 0x12C8: i = 78;break;
  case 0x12C9: i = 79;break;
  case 0x12CA: i = 80;break;
  case 0x12CB: i = 81;break;
  case 0x12CC: i = 82;break;
  case 0x12CD: i = 83;break;
  case 0x12CE: i = 84;break;
  case 0x12CF: i = 85;break;
  case 0x12D0: i = 86;break;
  case 0x12D1: i = 87;break;
  case 0x12D2: i = 88;break;
  case 0x12D3: i = 89;break;
  case 0x12D4: i = 90;break;
  case 0x12D5: i = 91;break;
  case 0x12D6: i = 92;break;
  case 0x12D7: i = 93;break;
  case 0x12D8: i = 94;break;
  case 0x12D9: i = 95;break;
  case 0x12DA: i = 96;break;
  case 0x12DB: i = 97;break;
  case 0x12DC: i = 98;break;
  case 0x12DD: i = 99;break;
  case 0x12DE: i = 100;break;
  case 0x12DF: i = 101;break;
  case 0x12E0: i = 102;break;
  case 0x12E1: i = 103;break;
  case 0x12E2: i = 104;break;
  case 0x12E3: i = 105;break;
  case 0x12E4: i = 106;break;
  case 0x12E5: i = 107;break;
  case 0x12E6: i = 108;break;
  case 0x12E7: i = 109;break;
  case 0x12E8: i = 110;break;
  case 0x12E9: i = 111;break;
  case 0x12EA: i = 112;break;
  case 0x12EB: i = 113;break;
  case 0x12EC: i = 114;break;
  case 0x12ED: i = 115;break;
  case 0x12EE: i = 116;break;
  case 0x12EF: i = 117;break;
  case 0x12F0: i = 118;break;
  case 0x12F1: i = 119;break;
  case 0x12F2: i = 120;break;
  case 0x12F3: i = 121;break;
  case 0x12F4: i = 122;break;
  case 0x12F5: i = 123;break;
  case 0x12F6: i = 124;break;
  case 0x12F7: i = 125;break;
  case 0x12F8: i = 126;break;
  case 0x12F9: i = 127;break;
  case 0x12FA: i = 128;break;
  case 0x12FB: i = 129;break;
  case 0x12FC: i = 130;break;
  case 0x12FD: i = 131;break;
  case 0x12FE: i = 132;break;
  default:
   *errorCode = 0x06020000;
   return ((void *)0);
 }
 *errorCode = 0x00000000;
 return &CANOpenShellMasterOD_objdict[i];
}


decompiled_code:
__int64 __fastcall TestSlaveA_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 TestSlaveA_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 TestSlaveA_valueRangeTest(unsigned char typeValue, void *value)
{
  switch (typeValue) {
    case 0x9F:
      if (*(unsigned char *)value != (unsigned char)0) return 0x06090030;
      break;
  }
  return 0;
}


decompiled_code:
void ***__fastcall TestSlaveA_scanIndexOD(unsigned __int16 a1, _QWORD *a2, _QWORD *a3)
{
int v3; // eax

*a3 = 0LL;
if ( a1 <= 0x1018u )
{
if ( a1 > 0xFFFu )
{
switch ( a1 )
{
case 0x1000u:
v3 = 0;
goto LABEL_10;
case 0x1001u:
v3 = 1;
goto LABEL_10;
case 0x1003u:
*a3 = &TestSlaveA_Index1003_callbacks;
v3 = 2;
goto LABEL_10;
case 0x1005u:
*a3 = &TestSlaveA_Index1005_callbacks;
v3 = 3;
goto LABEL_10;
case 0x1006u:
*a3 = &TestSlaveA_Index1006_callbacks;
v3 = 4;
goto LABEL_10;
case 0x1010u:
*a3 = &TestSlaveA_Index1010_callbacks;
v3 = 5;
goto LABEL_10;
case 0x1011u:
*a3 = &TestSlaveA_Index1011_callbacks;
v3 = 6;
goto LABEL_10;
case 0x1014u:
v3 = 7;
goto LABEL_10;
case 0x1017u:
*a3 = &TestSlaveA_Index1017_callbacks;
v3 = 8;
goto LABEL_10;
case 0x1018u:
v3 = 9;
goto LABEL_10;
default:
goto LABEL_21;
}
}
goto LABEL_21;
}
if ( a1 == 6656 )
{
v3 = 12;
goto LABEL_10;
}
if ( a1 <= 0x1A00u )
{
if ( a1 == 4608 )
{
v3 = 10;
goto LABEL_10;
}
if ( a1 == 6144 )
{
*a3 = &TestSlaveA_Index1800_callbacks;
v3 = 11;
goto LABEL_10;
}
}
else
{
if ( a1 == 0x2000 )
{
v3 = 13;
goto LABEL_10;
}
if ( a1 == 8193 )
{
v3 = 14;
LABEL_10:
*a2 = 0LL;
return &(&TestSlaveA_objdict)[2 * v3];
}
}
LABEL_21:
*a2 = 100794368LL;
return 0LL;
}

canonical_decompiled_code:
void ***__fastcall func1(unsigned __int16 a1, _QWORD *a2, _QWORD *a3)
{
int v3; // eax

*a3 = 0LL;
if ( a1 <= 0x1018u )
{
if ( a1 > 0xFFFu )
{
switch ( a1 )
{
case 0x1000u:
v3 = 0;
goto LABEL_10;
case 0x1001u:
v3 = 1;
goto LABEL_10;
case 0x1003u:
*a3 = &TestSlaveA_Index1003_callbacks;
v3 = 2;
goto LABEL_10;
case 0x1005u:
*a3 = &TestSlaveA_Index1005_callbacks;
v3 = 3;
goto LABEL_10;
case 0x1006u:
*a3 = &TestSlaveA_Index1006_callbacks;
v3 = 4;
goto LABEL_10;
case 0x1010u:
*a3 = &TestSlaveA_Index1010_callbacks;
v3 = 5;
goto LABEL_10;
case 0x1011u:
*a3 = &TestSlaveA_Index1011_callbacks;
v3 = 6;
goto LABEL_10;
case 0x1014u:
v3 = 7;
goto LABEL_10;
case 0x1017u:
*a3 = &TestSlaveA_Index1017_callbacks;
v3 = 8;
goto LABEL_10;
case 0x1018u:
v3 = 9;
goto LABEL_10;
default:
goto LABEL_21;
}
}
goto LABEL_21;
}
if ( a1 == 6656 )
{
v3 = 12;
goto LABEL_10;
}
if ( a1 <= 0x1A00u )
{
if ( a1 == 4608 )
{
v3 = 10;
goto LABEL_10;
}
if ( a1 == 6144 )
{
*a3 = &TestSlaveA_Index1800_callbacks;
v3 = 11;
goto LABEL_10;
}
}
else
{
if ( a1 == 0x2000 )
{
v3 = 13;
goto LABEL_10;
}
if ( a1 == 8193 )
{
v3 = 14;
LABEL_10:
*a2 = 0LL;
return &(&TestSlaveA_objdict)[2 * v3];
}
}
LABEL_21:
*a2 = 100794368LL;
return 0LL;
}

original_code:
const indextable * TestSlaveA_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 = TestSlaveA_Index1003_callbacks; break;
  case 0x1005: i = 3;*callbacks = TestSlaveA_Index1005_callbacks; break;
  case 0x1006: i = 4;*callbacks = TestSlaveA_Index1006_callbacks; break;
  case 0x1010: i = 5;*callbacks = TestSlaveA_Index1010_callbacks; break;
  case 0x1011: i = 6;*callbacks = TestSlaveA_Index1011_callbacks; break;
  case 0x1014: i = 7;break;
  case 0x1017: i = 8;*callbacks = TestSlaveA_Index1017_callbacks; break;
  case 0x1018: i = 9;break;
  case 0x1200: i = 10;break;
  case 0x1800: i = 11;*callbacks = TestSlaveA_Index1800_callbacks; break;
  case 0x1A00: i = 12;break;
  case 0x2000: i = 13;break;
  case 0x2001: i = 14;break;
  default:
   *errorCode = 0x06020000;
   return ((void *)0);
 }
 *errorCode = 0x00000000;
 return &TestSlaveA_objdict[i];
}

canonical_original_code:
struct td_indextable *TestSlaveA_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 = TestSlaveA_Index1003_callbacks; break;
  case 0x1005: i = 3;*callbacks = TestSlaveA_Index1005_callbacks; break;
  case 0x1006: i = 4;*callbacks = TestSlaveA_Index1006_callbacks; break;
  case 0x1010: i = 5;*callbacks = TestSlaveA_Index1010_callbacks; break;
  case 0x1011: i = 6;*callbacks = TestSlaveA_Index1011_callbacks; break;
  case 0x1014: i = 7;break;
  case 0x1017: i = 8;*callbacks = TestSlaveA_Index1017_callbacks; break;
  case 0x1018: i = 9;break;
  case 0x1200: i = 10;break;
  case 0x1800: i = 11;*callbacks = TestSlaveA_Index1800_callbacks; break;
  case 0x1A00: i = 12;break;
  case 0x2000: i = 13;break;
  case 0x2001: i = 14;break;
  default:
   *errorCode = 0x06020000;
   return ((void *)0);
 }
 *errorCode = 0x00000000;
 return &TestSlaveA_objdict[i];
}


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

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

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

canonical_original_code:
void TestMaster_heartbeatError(struct struct_CO_Data *d, unsigned char heartbeatID)
{
 printf ("TestMaster_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 TestMaster_operational()
{
return puts("TestMaster_operational");
}

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

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

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


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

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

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

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


repo: JFreegman/Colour-Keys

decompiled_code:
int __fastcall random_key(char *s)
{
char *v1; // rbx
int v2; // eax
int result; // eax

v1 = s;
do
{
v2 = rand();
result = snprintf(v1++, 8uLL, "%x", (unsigned int)(v2 % 16));
}
while ( v1 != s + 76 );
return result;
}

canonical_decompiled_code:
int __fastcall func9(char *s)
{
char *v1; // rbx
int v2; // eax
int result; // eax

v1 = s;
do
{
v2 = rand();
result = snprintf(v1++, 8uLL, "%x", (unsigned int)(v2 % 16));
}
while ( v1 != s + 76 );
return result;
}

original_code:
static void random_key(char *s)
{
    int i;
    for (i = 0; i < 76; ++i)
        snprintf(s+i, sizeof(s), "%x", rand() % 16);
}

variable_types:
s
char *


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
bool v3; // bp
int v4; // er12
unsigned int i; // ebx
int result; // eax
__int64 v7[10]; // [rsp+0h] [rbp-B8h] BYREF
char s2[8]; // [rsp+50h] [rbp-68h] BYREF
__int64 v9; // [rsp+58h] [rbp-60h]
__int64 v10; // [rsp+60h] [rbp-58h]
__int64 v11; // [rsp+68h] [rbp-50h]
__int64 v12; // [rsp+70h] [rbp-48h]
__int64 v13; // [rsp+78h] [rbp-40h]
__int64 v14; // [rsp+80h] [rbp-38h]
__int64 v15; // [rsp+88h] [rbp-30h]
__int64 v16; // [rsp+90h] [rbp-28h]
__int64 v17; // [rsp+98h] [rbp-20h]

if ( (unsigned int)(argc - 2) > 1 )
{
puts("Usage: [num tests] (-m to mute)");
result = -1;
}
else
{
v3 = 0;
if ( argc == 3 )
v3 = strcmp(argv[2], "-m") == 0;
v4 = atoi(argv[1]);
if ( v4 > 0 )
{
for ( i = 1; ; ++i )
{
if ( !v3 )
printf("* Test %d\n", i);
v7[0] = 0LL;
v7[1] = 0LL;
v7[2] = 0LL;
v7[3] = 0LL;
v7[4] = 0LL;
v7[5] = 0LL;
v7[6] = 0LL;
v7[7] = 0LL;
v7[8] = 0LL;
v7[9] = 0LL;
random_key((char *)v7);
if ( (unsigned int)make_keyimg((const char *)v7, "testkeyimg.tox") )
__assert_fail("make_keyimg(key_in, outpath) == 0", "keyimgtest.c", 0x2Fu, "main");
*(_QWORD *)s2 = 0LL;
v9 = 0LL;
v10 = 0LL;
v11 = 0LL;
v12 = 0LL;
v13 = 0LL;
v14 = 0LL;
v15 = 0LL;
v16 = 0LL;
v17 = 0LL;
if ( (unsigned int)extract_keyimg((__int64)s2, "testkeyimg.tox") )
__assert_fail("extract_keyimg(key_out, outpath) == 0", "keyimgtest.c", 0x34u, "main");
if ( !v3 )
{
printf("IN :%s\n", (const char *)v7);
printf("OUT:%s\n\n", s2);
}
if ( strcmp((const char *)v7, s2) )
__assert_fail("strcmp(key_in, key_out) == 0", "keyimgtest.c", 0x3Cu, "main");
if ( i == v4 )
break;
}
}
puts("Tests passed!");
result = 0;
}
return result;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
bool v3; // bp
int v4; // er12
unsigned int i; // ebx
int result; // eax
__int64 v7[10]; // [rsp+0h] [rbp-B8h] BYREF
char s2[8]; // [rsp+50h] [rbp-68h] BYREF
__int64 v9; // [rsp+58h] [rbp-60h]
__int64 v10; // [rsp+60h] [rbp-58h]
__int64 v11; // [rsp+68h] [rbp-50h]
__int64 v12; // [rsp+70h] [rbp-48h]
__int64 v13; // [rsp+78h] [rbp-40h]
__int64 v14; // [rsp+80h] [rbp-38h]
__int64 v15; // [rsp+88h] [rbp-30h]
__int64 v16; // [rsp+90h] [rbp-28h]
__int64 v17; // [rsp+98h] [rbp-20h]

if ( (unsigned int)(argc - 2) > 1 )
{
puts("Usage: [num tests] (-m to mute)");
result = -1;
}
else
{
v3 = 0;
if ( argc == 3 )
v3 = strcmp(argv[2], "-m") == 0;
v4 = atoi(argv[1]);
if ( v4 > 0 )
{
for ( i = 1; ; ++i )
{
if ( !v3 )
printf("* Test %d\n", i);
v7[0] = 0LL;
v7[1] = 0LL;
v7[2] = 0LL;
v7[3] = 0LL;
v7[4] = 0LL;
v7[5] = 0LL;
v7[6] = 0LL;
v7[7] = 0LL;
v7[8] = 0LL;
v7[9] = 0LL;
func9((char *)v7);
if ( (unsigned int)func8((const char *)v7, "testkeyimg.tox") )
__assert_fail("make_keyimg(key_in, outpath) == 0", "keyimgtest.c", 0x2Fu, "main");
*(_QWORD *)s2 = 0LL;
v9 = 0LL;
v10 = 0LL;
v11 = 0LL;
v12 = 0LL;
v13 = 0LL;
v14 = 0LL;
v15 = 0LL;
v16 = 0LL;
v17 = 0LL;
if ( (unsigned int)func7((__int64)s2, "testkeyimg.tox") )
__assert_fail("extract_keyimg(key_out, outpath) == 0", "keyimgtest.c", 0x34u, "main");
if ( !v3 )
{
printf("IN :%s\n", (const char *)v7);
printf("OUT:%s\n\n", s2);
}
if ( strcmp((const char *)v7, s2) )
__assert_fail("strcmp(key_in, key_out) == 0", "keyimgtest.c", 0x3Cu, "main");
if ( i == v4 )
break;
}
}
puts("Tests passed!");
result = 0;
}
return result;
}

original_code:
int main(int argc, char *argv[])
{
    if (argc < 2 || argc > 3) {
        printf("Usage: [num tests] (-m to mute)\n");
        return -1;
    }
    _Bool mute = 0;
    if (argc == 3 && strcmp(argv[2], "-m") == 0)
        mute = 1;
    int n = atoi(argv[1]);
    int i;
    for (i = 0; i < n; ++i) {
        if (!mute)
            printf("* Test %d\n", i+1);
        const char *outpath = "testkeyimg.tox";
        char key_in[80] = {'\0'};
        random_key(key_in);
        ((void) sizeof ((make_keyimg(key_in, outpath) == 0) ? 1 : 0), __extension__ ({ if (make_keyimg(key_in, outpath) == 0) ; else __assert_fail ("make_keyimg(key_in, outpath) == 0", "keyimgtest.c", 47, __extension__ __PRETTY_FUNCTION__); }));
        char key_out[80] = {'\0'};
        ((void) sizeof ((extract_keyimg(key_out, outpath) == 0) ? 1 : 0), __extension__ ({ if (extract_keyimg(key_out, outpath) == 0) ; else __assert_fail ("extract_keyimg(key_out, outpath) == 0", "keyimgtest.c", 52, __extension__ __PRETTY_FUNCTION__); }));
        if (!mute) {
            printf("IN :%s\n", key_in);
            printf("OUT:%s\n\n", key_out);
        }
        ((void) sizeof ((strcmp(key_in, key_out) == 0) ? 1 : 0), __extension__ ({ if (strcmp(key_in, key_out) == 0) ; else __assert_fail ("strcmp(key_in, key_out) == 0", "keyimgtest.c", 60, __extension__ __PRETTY_FUNCTION__); }));
    }
    printf("Tests passed!\n");
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
    if (argc < 2 || argc > 3) {
        printf("Usage: [num tests] (-m to mute)\n");
        return -1;
    }
    _Bool mute = 0;
    if (argc == 3 && strcmp(argv[2], "-m") == 0)
        mute = 1;
    int n = atoi(argv[1]);
    int i;
    for (i = 0; i < n; ++i) {
        if (!mute)
            printf("* Test %d\n", i+1);
        char *outpath = "testkeyimg.tox";
        char key_in[80] = {'\0'};
        random_key(key_in);
        ((void) sizeof ((make_keyimg(key_in, outpath) == 0) ? 1 : 0), __extension__ ({ if (make_keyimg(key_in, outpath) == 0) ; else __assert_fail ("make_keyimg(key_in, outpath) == 0", "keyimgtest.c", 47, __extension__ __PRETTY_FUNCTION__); }));
        char key_out[80] = {'\0'};
        ((void) sizeof ((extract_keyimg(key_out, outpath) == 0) ? 1 : 0), __extension__ ({ if (extract_keyimg(key_out, outpath) == 0) ; else __assert_fail ("extract_keyimg(key_out, outpath) == 0", "keyimgtest.c", 52, __extension__ __PRETTY_FUNCTION__); }));
        if (!mute) {
            printf("IN :%s\n", key_in);
            printf("OUT:%s\n\n", key_out);
        }
        ((void) sizeof ((strcmp(key_in, key_out) == 0) ? 1 : 0), __extension__ ({ if (strcmp(key_in, key_out) == 0) ; else __assert_fail ("strcmp(key_in, key_out) == 0", "keyimgtest.c", 60, __extension__ __PRETTY_FUNCTION__); }));
    }
    printf("Tests passed!\n");
    return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: n int

variable_types:
outpath
char *


repo: JLLLinn/System-Programming

decompiled_code:
__int64 __fastcall compare1(_DWORD *a1, _DWORD *a2)
{
return (unsigned int)(*a1 - *a2);
}

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

original_code:
int compare1(const void * a, const void * b)
{
 return ( *(int*)a - *(int*)b );
}

canonical_original_code:
int compare1(void *a, void *b)
{
 return ( *(int *)a - *(int *)b );
}

variable_types:
a
void *

variable_types:
b
void *


decompiled_code:
__int64 __fastcall compare2(_DWORD *a1, _DWORD *a2)
{
return (unsigned int)(*a2 - *a1);
}

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

original_code:
int compare2(const void * a, const void * b)
{
 return ( *(int*)b - *(int*)a );
}

canonical_original_code:
int compare2(void *a, void *b)
{
 return ( *(int *)b - *(int *)a );
}


original_code:
int priqueue_offer(priqueue_t *q, void *ptr) {
 if (!q->headMin->data) {
  q->headMin->data = ptr;
  (q->size)++;
  return 0;
 } else {
  int index = 0;
  priqueue_entry_t* cur;
  if (q->comparer(ptr, q->headMin->data) < 0) {
   cur = malloc(sizeof(priqueue_entry_t));
   cur->next = q->headMin;
   q->headMin = cur;
   q->headMin->data = ptr;
   (q->size)++;
   return 0;
  }
  cur = q->headMin;
  priqueue_entry_t* temp;
  int i = 0;
  while (cur->next) {
   i++;
   if (q->comparer(ptr, cur->next->data) < 0) {
    temp = malloc(sizeof(priqueue_entry_t));
    temp->next = cur->next;
    cur->next = temp;
    temp->data = ptr;
    (q->size)++;
    return i;
   }
   cur = cur->next;
  }
  i++;
  cur->next = malloc(sizeof(priqueue_entry_t));
  cur = cur->next;
  cur->next = ((void *)0);
  cur->data = ptr;
  (q->size)++;
  return i;
 }
 return -1;
}

canonical_original_code:
int priqueue_offer(struct _priqueue_t *q, void *ptr) {
 if (!q->headMin->data) {
  q->headMin->data = ptr;
  (q->size)++;
  return 0;
 } else {
  int index = 0;
  struct _priqueue_entry_t *cur;
  if (q->comparer(ptr, q->headMin->data) < 0) {
   cur = malloc(sizeof(priqueue_entry_t));
   cur->next = q->headMin;
   q->headMin = cur;
   q->headMin->data = ptr;
   (q->size)++;
   return 0;
  }
  cur = q->headMin;
  struct _priqueue_entry_t *temp;
  int i = 0;
  while (cur->next) {
   i++;
   if (q->comparer(ptr, cur->next->data) < 0) {
    temp = malloc(sizeof(priqueue_entry_t));
    temp->next = cur->next;
    cur->next = temp;
    temp->data = ptr;
    (q->size)++;
    return i;
   }
   cur = cur->next;
  }
  i++;
  cur->next = malloc(sizeof(priqueue_entry_t));
  cur = cur->next;
  cur->next = ((void *)0);
  cur->data = ptr;
  (q->size)++;
  return i;
 }
 return -1;
}

variable_types: struct _priqueue_t { int (*comparer)(void *, void *); struct _priqueue_entry_t { struct _priqueue_entry_t *next; void *data; } *headMin; int size; } *

variable_types:
ptr
void *

variable_types: index int

user_defined_types: struct _priqueue_t { int (*comparer)(void *, void *); struct _priqueue_entry_t *headMin; int size; }


decompiled_code:
__int64 __fastcall priqueue_peek(__int64 a1)
{
return *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL);
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
return *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL);
}

original_code:
void *priqueue_peek(priqueue_t *q) {
 if (q->headMin->data) {
  return q->headMin->data;
 }
 return ((void *)0);
}

canonical_original_code:
void *priqueue_peek(struct _priqueue_t *q) {
 if (q->headMin->data) {
  return q->headMin->data;
 }
 return ((void *)0);
}

user_defined_types: struct _priqueue_entry_t { struct _priqueue_entry_t *next; void *data; }


original_code:
void *priqueue_poll(priqueue_t *q) {
 if (q->headMin->data) {
  void* ret = q->headMin->data;
  if (q->headMin->next) {
   priqueue_entry_t* temphead = q->headMin;
   q->headMin = q->headMin->next;
   free(temphead);
  } else {
   q->headMin->next = ((void *)0);
   q->headMin->data = ((void *)0);
  }
  (q->size)--;
  return ret;
 }
 return ((void *)0);
}

canonical_original_code:
void *priqueue_poll(struct _priqueue_t *q) {
 if (q->headMin->data) {
  void *ret = q->headMin->data;
  if (q->headMin->next) {
   struct _priqueue_entry_t *temphead = q->headMin;
   q->headMin = q->headMin->next;
   free(temphead);
  } else {
   q->headMin->next = ((void *)0);
   q->headMin->data = ((void *)0);
  }
  (q->size)--;
  return ret;
 }
 return ((void *)0);
}

variable_types:
ret
void *

variable_types: struct _priqueue_entry_t { struct _priqueue_entry_t *next; void *data; } *


decompiled_code:
__int64 __fastcall priqueue_size(__int64 a1)
{
return *(unsigned int *)(a1 + 16);
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1)
{
return *(unsigned int *)(a1 + 16);
}

original_code:
int priqueue_size(priqueue_t *q) {
 return q->size;
}

canonical_original_code:
int priqueue_size(struct _priqueue_t *q) {
 return q->size;
}


decompiled_code:
void __fastcall priqueue_destroy(__int64 a1)
{
_QWORD *v1; // rbx
void *v2; // rdi

v1 = *(_QWORD **)(a1 + 8);
while ( v1 )
{
v2 = v1;
v1 = (_QWORD *)*v1;
free(v2);
}
}

canonical_decompiled_code:
void __fastcall func13(__int64 a1)
{
_QWORD *v1; // rbx
void *v2; // rdi

v1 = *(_QWORD **)(a1 + 8);
while ( v1 )
{
v2 = v1;
v1 = (_QWORD *)*v1;
free(v2);
}
}

original_code:
void priqueue_destroy(priqueue_t *q) {
 priqueue_entry_t* cur = q->headMin;
 priqueue_entry_t* prev = q->headMin;
 while (cur) {
  prev = cur;
  cur = cur->next;
  free(prev);
 }
}

canonical_original_code:
void priqueue_destroy(struct _priqueue_t *q) {
 struct _priqueue_entry_t *cur = q->headMin;
 struct _priqueue_entry_t *prev = q->headMin;
 while (cur) {
  prev = cur;
  cur = cur->next;
  free(prev);
 }
}


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rdx
_DWORD *v4; // rbx
__int64 i; // rax
unsigned int v6; // eax
unsigned int v7; // ebp
unsigned int v8; // eax
unsigned int v9; // eax
unsigned int *v10; // rax
unsigned int v11; // eax
unsigned int *v12; // rax
unsigned int v13; // eax
unsigned int *v14; // rax
unsigned int *v15; // rax
_BYTE v17[32]; // [rsp+0h] [rbp-68h] BYREF
char v18[72]; // [rsp+20h] [rbp-48h] BYREF

priqueue_init(v18, compare1, envp);
priqueue_init(v17, compare2, v3);
v4 = malloc(0x190uLL);
for ( i = 0LL; i != 100; ++i )
v4[i] = i;
priqueue_offer(v18, v4 + 12);
priqueue_offer(v18, v4 + 13);
priqueue_offer(v18, v4 + 14);
priqueue_offer(v18, v4 + 12);
priqueue_offer(v18, v4 + 12);
v6 = priqueue_size(v18);
printf("Total elements: %d (expected 5).\n", v6);
v7 = *(_DWORD *)priqueue_poll(v18);
printf("Top element: %d (expected 12).\n", v7);
v8 = priqueue_size(v18);
printf("Total elements: %d (expected 4).\n", v8);
priqueue_peek(v18);
printf("Top element: %d (expected 12).\n", v7);
v9 = priqueue_size(v18);
printf("Total elements: %d (expected 4).\n", v9);
v10 = (unsigned int *)priqueue_poll(v18);
printf("Top element: %d (expected 12).\n", *v10);
v11 = priqueue_size(v18);
printf("Total elements: %d (expected 3).\n", v11);
v12 = (unsigned int *)priqueue_poll(v18);
printf("Top element: %d (expected 12).\n", *v12);
v13 = priqueue_size(v18);
printf("Total elements: %d (expected 2).\n", v13);
priqueue_offer(v18, v4 + 10);
priqueue_offer(v18, v4 + 30);
priqueue_offer(v18, v4 + 20);
priqueue_offer(v18, v4 + 25);
priqueue_offer(v17, v4 + 10);
priqueue_offer(v17, v4 + 30);
priqueue_offer(v17, v4 + 20);
printf("Elements in order queue (expected 10 13 14 20 25 30): ");
while ( (unsigned int)priqueue_size(v18) )
{
v14 = (unsigned int *)priqueue_poll(v18);
printf("%d ", *v14);
}
putchar(10);
printf("Elements in order queue (expected 30 20 10): ");
while ( (unsigned int)priqueue_size(v17) )
{
v15 = (unsigned int *)priqueue_poll(v17);
printf("%d ", *v15);
}
putchar(10);
priqueue_destroy(v17);
priqueue_destroy(v18);
free(v4);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rdx
_DWORD *v4; // rbx
__int64 i; // rax
unsigned int v6; // eax
unsigned int v7; // ebp
unsigned int v8; // eax
unsigned int v9; // eax
unsigned int *v10; // rax
unsigned int v11; // eax
unsigned int *v12; // rax
unsigned int v13; // eax
unsigned int *v14; // rax
unsigned int *v15; // rax
_BYTE v17[32]; // [rsp+0h] [rbp-68h] BYREF
char v18[72]; // [rsp+20h] [rbp-48h] BYREF

priqueue_init(v18, compare1, envp);
priqueue_init(v17, compare2, v3);
v4 = malloc(0x190uLL);
for ( i = 0LL; i != 100; ++i )
v4[i] = i;
func9(v18, v4 + 12);
func9(v18, v4 + 13);
func9(v18, v4 + 14);
func9(v18, v4 + 12);
func9(v18, v4 + 12);
v6 = func12(v18);
printf("Total elements: %d (expected 5).\n", v6);
v7 = *(_DWORD *)func11(v18);
printf("Top element: %d (expected 12).\n", v7);
v8 = func12(v18);
printf("Total elements: %d (expected 4).\n", v8);
func10(v18);
printf("Top element: %d (expected 12).\n", v7);
v9 = func12(v18);
printf("Total elements: %d (expected 4).\n", v9);
v10 = (unsigned int *)func11(v18);
printf("Top element: %d (expected 12).\n", *v10);
v11 = func12(v18);
printf("Total elements: %d (expected 3).\n", v11);
v12 = (unsigned int *)func11(v18);
printf("Top element: %d (expected 12).\n", *v12);
v13 = func12(v18);
printf("Total elements: %d (expected 2).\n", v13);
func9(v18, v4 + 10);
func9(v18, v4 + 30);
func9(v18, v4 + 20);
func9(v18, v4 + 25);
func9(v17, v4 + 10);
func9(v17, v4 + 30);
func9(v17, v4 + 20);
printf("Elements in order queue (expected 10 13 14 20 25 30): ");
while ( (unsigned int)func12(v18) )
{
v14 = (unsigned int *)func11(v18);
printf("%d ", *v14);
}
putchar(10);
printf("Elements in order queue (expected 30 20 10): ");
while ( (unsigned int)func12(v17) )
{
v15 = (unsigned int *)func11(v17);
printf("%d ", *v15);
}
putchar(10);
func13(v17);
func13(v18);
free(v4);
return 0;
}

original_code:
int main()
{
 priqueue_t q, q2;
 priqueue_init(&q, compare1);
 priqueue_init(&q2, compare2);
 int *values = malloc(100 * sizeof(int));
 int i;
 for (i = 0; i < 100; i++)
  values[i] = i;
 priqueue_offer(&q, &values[12]);
 priqueue_offer(&q, &values[13]);
 priqueue_offer(&q, &values[14]);
 priqueue_offer(&q, &values[12]);
 priqueue_offer(&q, &values[12]);
 printf("Total elements: %d (expected 5).\n", priqueue_size(&q));
 int val = *((int *)priqueue_poll(&q));
 printf("Top element: %d (expected 12).\n", val);
 printf("Total elements: %d (expected 4).\n", priqueue_size(&q));
 int val4 = *((int *)priqueue_peek(&q));
 printf("Top element: %d (expected 12).\n", val);
 printf("Total elements: %d (expected 4).\n", priqueue_size(&q));
 int val2 = *((int *)priqueue_poll(&q));
 printf("Top element: %d (expected 12).\n", val2);
 printf("Total elements: %d (expected 3).\n", priqueue_size(&q));
 int val3 = *((int *)priqueue_poll(&q));
 printf("Top element: %d (expected 12).\n", val3);
 printf("Total elements: %d (expected 2).\n", priqueue_size(&q));
 priqueue_offer(&q, &values[10]);
 priqueue_offer(&q, &values[30]);
 priqueue_offer(&q, &values[20]);
 priqueue_offer(&q, &values[25]);
 priqueue_offer(&q2, &values[10]);
 priqueue_offer(&q2, &values[30]);
 priqueue_offer(&q2, &values[20]);
 printf("Elements in order queue (expected 10 13 14 20 25 30): ");
 while ( priqueue_size(&q) )
  printf("%d ", *((int *)priqueue_poll(&q)) );
 printf("\n");
 printf("Elements in order queue (expected 30 20 10): ");
 while ( priqueue_size(&q2) )
  printf("%d ", *((int *)priqueue_poll(&q2)) );
 printf("\n");
 priqueue_destroy(&q2);
 priqueue_destroy(&q);
 free(values);
 return 0;
}

canonical_original_code:
int main()
{
 struct _priqueue_t q; struct _priqueue_t q2;
 priqueue_init(&q, compare1);
 priqueue_init(&q2, compare2);
 int *values = malloc(100 * sizeof(int));
 int i;
 for (i = 0; i < 100; i++)
  values[i] = i;
 priqueue_offer(&q, &values[12]);
 priqueue_offer(&q, &values[13]);
 priqueue_offer(&q, &values[14]);
 priqueue_offer(&q, &values[12]);
 priqueue_offer(&q, &values[12]);
 printf("Total elements: %d (expected 5).\n", priqueue_size(&q));
 int val = *((int *)priqueue_poll(&q));
 printf("Top element: %d (expected 12).\n", val);
 printf("Total elements: %d (expected 4).\n", priqueue_size(&q));
 int val4 = *((int *)priqueue_peek(&q));
 printf("Top element: %d (expected 12).\n", val);
 printf("Total elements: %d (expected 4).\n", priqueue_size(&q));
 int val2 = *((int *)priqueue_poll(&q));
 printf("Top element: %d (expected 12).\n", val2);
 printf("Total elements: %d (expected 3).\n", priqueue_size(&q));
 int val3 = *((int *)priqueue_poll(&q));
 printf("Top element: %d (expected 12).\n", val3);
 printf("Total elements: %d (expected 2).\n", priqueue_size(&q));
 priqueue_offer(&q, &values[10]);
 priqueue_offer(&q, &values[30]);
 priqueue_offer(&q, &values[20]);
 priqueue_offer(&q, &values[25]);
 priqueue_offer(&q2, &values[10]);
 priqueue_offer(&q2, &values[30]);
 priqueue_offer(&q2, &values[20]);
 printf("Elements in order queue (expected 10 13 14 20 25 30): ");
 while ( priqueue_size(&q) )
  printf("%d ", *((int *)priqueue_poll(&q)) );
 printf("\n");
 printf("Elements in order queue (expected 30 20 10): ");
 while ( priqueue_size(&q2) )
  printf("%d ", *((int *)priqueue_poll(&q2)) );
 printf("\n");
 priqueue_destroy(&q2);
 priqueue_destroy(&q);
 free(values);
 return 0;
}

variable_types: struct _priqueue_t { int (*comparer)(void *, void *); struct _priqueue_entry_t { struct _priqueue_entry_t *next; void *data; } *headMin; int size; }

variable_types:
values
int *

variable_types: i int

variable_types: val int


verify

decompiled_code:
void __fastcall verify(_BYTE *a1, char a2, __int64 a3)
{
_BYTE *v3; // rdx

v3 = &a1[a3];
while ( a1 != v3 )
{
if ( *a1++ != a2 )
{
puts("Memeory failed to contain correct value!");
exit(1);
}
}
}

canonical_decompiled_code:
void __fastcall func7(_BYTE *a1, char a2, __int64 a3)
{
_BYTE *v3; // rdx

v3 = &a1[a3];
while ( a1 != v3 )
{
if ( *a1++ != a2 )
{
puts("Memeory failed to contain correct value!");
exit(1);
}
}
}

original_code:
void verify(void *region, int c, size_t len)
{
  char *r = region;
  while (len--) if (*(r++) != (char)c) {
    printf("Memeory failed to contain correct value!\n");
    exit(1);
  }
}

canonical_original_code:
void verify(void *region, int c, unsigned long len)
{
  char *r = region;
  while (len--) if (*(r++) != (char)c) {
    printf("Memeory failed to contain correct value!\n");
    exit(1);
  }
}

variable_types:
region
void *

variable_types: c int

variable_types:
len
unsigned long

variable_types:
r
char *


overlap

decompiled_code:
_BOOL8 __fastcall overlap(unsigned __int64 a1, unsigned __int64 a2, __int64 a3)
{
_BOOL8 result; // rax

result = 0LL;
if ( a1 <= a2 )
result = a2 < a3 + a1;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func8(unsigned __int64 a1, unsigned __int64 a2, __int64 a3)
{
_BOOL8 result; // rax

result = 0LL;
if ( a1 <= a2 )
result = a2 < a3 + a1;
return result;
}

original_code:
int overlap(void *r1, void *r2, size_t len)
{
  return (size_t)r1 <= (size_t)r2 && (size_t)r2 < (size_t)(r1 + len);
}

canonical_original_code:
int overlap(void *r1, void *r2, unsigned long len)
{
  return (unsigned long)r1 <= (unsigned long)r2 && (unsigned long)r2 < (unsigned long)(r1 + len);
}


decompiled_code:
_BOOL8 __fastcall verify_overlap2(unsigned __int64 a1, unsigned __int64 a2, __int64 a3)
{
_BOOL8 result; // rax

result = overlap(a1, a2, a3);
if ( result )
{
puts("Memory regions overlap!");
exit(1);
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func9(unsigned __int64 a1, unsigned __int64 a2, __int64 a3)
{
_BOOL8 result; // rax

result = func8(a1, a2, a3);
if ( result )
{
puts("Memory regions overlap!");
exit(1);
}
return result;
}

original_code:
void verify_overlap2(void *r1, void *r2, size_t len)
{
  if (overlap(r1, r2, len)) {
    printf("Memory regions overlap!\n");
    exit(1);
  }
}

canonical_original_code:
void verify_overlap2(void *r1, void *r2, unsigned long len)
{
  if (overlap(r1, r2, len)) {
    printf("Memory regions overlap!\n");
    exit(1);
  }
}


decompiled_code:
_BOOL8 __fastcall verify_overlap3(unsigned __int64 a1, unsigned __int64 a2, unsigned __int64 a3, __int64 a4)
{
_BOOL8 result; // rax

if ( overlap(a1, a2, a4) || overlap(a1, a3, a4) || (result = overlap(a2, a3, a4)) )
{
puts("Memory regions overlap!");
exit(1);
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func10(unsigned __int64 a1, unsigned __int64 a2, unsigned __int64 a3, __int64 a4)
{
_BOOL8 result; // rax

if ( func8(a1, a2, a4) || func8(a1, a3, a4) || (result = func8(a2, a3, a4)) )
{
puts("Memory regions overlap!");
exit(1);
}
return result;
}

original_code:
void verify_overlap3(void *r1, void *r2, void *r3, size_t len)
{
  if (overlap(r1, r2, len) || overlap(r1, r3, len) || overlap(r2, r3, len)) {
    printf("Memory regions overlap!\n");
    exit(1);
  }
}

canonical_original_code:
void verify_overlap3(void *r1, void *r2, void *r3, unsigned long len)
{
  if (overlap(r1, r2, len) || overlap(r1, r3, len) || overlap(r2, r3, len)) {
    printf("Memory regions overlap!\n");
    exit(1);
  }
}


original_code:
void queue_init(queue_t *q) {
 q->head = ((void *)0);
 q->tail = ((void *)0);
 q->size = 0;
}

canonical_original_code:
void queue_init(struct queue_t *q) {
 q->head = ((void *)0);
 q->tail = ((void *)0);
 q->size = 0;
}

variable_types: struct queue_t { struct queue_node { void *item; struct queue_node *next; } *head; struct queue_node *tail; unsigned int size; } *

user_defined_types: struct queue_t { struct queue_node *head; struct queue_node *tail; unsigned int size; }


original_code:
void *queue_remove_at(queue_t *q, int pos){
 if( pos < 0 || q->size-1 < pos)
  return ((void *)0);
 q->size--;
 struct queue_node *cur = q->head;
 struct queue_node *prev = ((void *)0);
 while(pos--){
  prev = cur;
  cur = cur->next;
 }
 if(cur == q->head){
  q->head = cur->next;
  if(q->head == ((void *)0))
   q->tail = ((void *)0);
  void *item = cur->item;
  free(cur);
  return item;
 }else if(cur == q->tail){
  q->tail = prev;
  prev->next = ((void *)0);
  void *item = cur->item;
  free(cur);
  return item;
 }else{
  prev->next = cur->next;
  void *item = cur->item;
  free(cur);
  return item;
 }
}

canonical_original_code:
void *queue_remove_at(struct queue_t *q, int pos){
 if( pos < 0 || q->size-1 < pos)
  return ((void *)0);
 q->size--;
 struct queue_node *cur = q->head;
 struct queue_node *prev = ((void *)0);
 while(pos--){
  prev = cur;
  cur = cur->next;
 }
 if(cur == q->head){
  q->head = cur->next;
  if(q->head == ((void *)0))
   q->tail = ((void *)0);
  void *item = cur->item;
  free(cur);
  return item;
 }else if(cur == q->tail){
  q->tail = prev;
  prev->next = ((void *)0);
  void *item = cur->item;
  free(cur);
  return item;
 }else{
  prev->next = cur->next;
  void *item = cur->item;
  free(cur);
  return item;
 }
}

variable_types: pos int

variable_types: struct queue_node { void *item; struct queue_node *next; } *

variable_types:
item
void *