decompiled_code:
int __fastcall show_opcode(char *a1, unsigned __int8 a2)
{
int result; // eax

result = a2;
switch ( a2 )
{
case 0u:
*(_DWORD *)a1 = 4936258;
break;
case 1u:
case 5u:
case 9u:
case 0xDu:
case 0x11u:
case 0x15u:
case 0x19u:
case 0x1Du:
*(_DWORD *)a1 = 4280911;
break;
case 2u:
case 3u:
case 4u:
case 7u:
case 0xBu:
case 0xCu:
case 0xFu:
case 0x12u:
case 0x13u:
case 0x14u:
case 0x17u:
case 0x1Au:
case 0x1Bu:
case 0x1Cu:
case 0x1Fu:
case 0x22u:
case 0x23u:
case 0x27u:
case 0x2Bu:
case 0x2Fu:
case 0x32u:
case 0x33u:
case 0x34u:
case 0x37u:
case 0x3Au:
case 0x3Bu:
case 0x3Cu:
case 0x3Fu:
case 0x42u:
case 0x43u:
case 0x44u:
case 0x47u:
case 0x4Bu:
case 0x4Fu:
case 0x52u:
case 0x53u:
case 0x54u:
case 0x57u:
case 0x5Au:
case 0x5Bu:
case 0x5Cu:
case 0x5Fu:
case 0x62u:
case 0x63u:
case 0x64u:
case 0x67u:
case 0x6Bu:
case 0x6Fu:
case 0x72u:
case 0x73u:
case 0x74u:
case 0x77u:
case 0x7Au:
case 0x7Bu:
case 0x7Cu:
case 0x7Fu:
case 0x80u:
case 0x82u:
case 0x83u:
case 0x87u:
case 0x89u:
case 0x8Bu:
case 0x8Fu:
case 0x92u:
case 0x93u:
case 0x97u:
case 0x9Bu:
case 0x9Cu:
case 0x9Eu:
case 0x9Fu:
case 0xABu:
case 0xB2u:
case 0xBBu:
case 0xC2u:
case 0xC3u:
case 0xC7u:
case 0xCBu:
case 0xCFu:
case 0xD2u:
case 0xD3u:
case 0xD4u:
case 0xD7u:
case 0xDAu:
case 0xDBu:
case 0xDCu:
case 0xDFu:
case 0xE2u:
case 0xE3u:
case 0xE7u:
case 0xEBu:
case 0xEFu:
case 0xF2u:
case 0xF3u:
case 0xF4u:
case 0xF7u:
case 0xFAu:
case 0xFBu:
case 0xFCu:
result = sprintf(a1, "*** ILLEGAL INSTRUCTION (%x) ***", a2);
break;
case 6u:
case 0xEu:
case 0x16u:
case 0x1Eu:
*(_DWORD *)a1 = 5002049;
break;
case 8u:
*(_DWORD *)a1 = 5261392;
break;
case 0xAu:
strcpy(a1, "ASL A");
break;
case 0x10u:
*(_DWORD *)a1 = 5001282;
break;
case 0x18u:
*(_DWORD *)a1 = 4410435;
break;
case 0x20u:
*(_DWORD *)a1 = 5395274;
break;
case 0x21u:
case 0x25u:
case 0x29u:
case 0x2Du:
case 0x31u:
case 0x35u:
case 0x39u:
case 0x3Du:
*(_DWORD *)a1 = 4476481;
break;
case 0x24u:
case 0x2Cu:
*(_DWORD *)a1 = 5523778;
break;
case 0x26u:
case 0x2Eu:
case 0x36u:
case 0x3Eu:
*(_DWORD *)a1 = 5001042;
break;
case 0x28u:
*(_DWORD *)a1 = 5262416;
break;
case 0x2Au:
strcpy(a1, "ROL A");
break;
case 0x30u:
*(_DWORD *)a1 = 4803906;
break;
case 0x38u:
*(_DWORD *)a1 = 4408659;
break;
case 0x40u:
*(_DWORD *)a1 = 4805714;
break;
case 0x41u:
case 0x45u:
case 0x49u:
case 0x4Du:
case 0x51u:
case 0x55u:
case 0x59u:
case 0x5Du:
*(_DWORD *)a1 = 5394245;
break;
case 0x46u:
case 0x4Eu:
case 0x56u:
case 0x5Eu:
*(_DWORD *)a1 = 5395276;
break;
case 0x48u:
*(_DWORD *)a1 = 4278352;
break;
case 0x4Au:
strcpy(a1, "LSR A");
break;
case 0x4Cu:
case 0x6Cu:
*(_DWORD *)a1 = 5262666;
break;
case 0x50u:
*(_DWORD *)a1 = 4412994;
break;
case 0x58u:
*(_DWORD *)a1 = 4803651;
break;
case 0x60u:
*(_DWORD *)a1 = 5461074;
break;
case 0x61u:
case 0x65u:
case 0x69u:
case 0x6Du:
case 0x71u:
case 0x75u:
case 0x79u:
case 0x7Du:
*(_DWORD *)a1 = 4408385;
break;
case 0x66u:
case 0x6Eu:
case 0x76u:
case 0x7Eu:
*(_DWORD *)a1 = 5394258;
break;
case 0x68u:
*(_DWORD *)a1 = 4279376;
break;
case 0x6Au:
strcpy(a1, "ROR A");
break;
case 0x70u:
*(_DWORD *)a1 = 5461570;
break;
case 0x78u:
*(_DWORD *)a1 = 4801875;
break;
case 0x81u:
case 0x85u:
case 0x8Du:
case 0x91u:
case 0x95u:
case 0x99u:
case 0x9Du:
*(_DWORD *)a1 = 4281427;
break;
case 0x84u:
case 0x8Cu:
case 0x94u:
*(_DWORD *)a1 = 5854291;
break;
case 0x86u:
case 0x8Eu:
case 0x96u:
*(_DWORD *)a1 = 5788755;
break;
case 0x88u:
*(_DWORD *)a1 = 5850436;
break;
case 0x8Au:
*(_DWORD *)a1 = 4282452;
break;
case 0x90u:
*(_DWORD *)a1 = 4408130;
break;
case 0x98u:
*(_DWORD *)a1 = 4282708;
break;
case 0x9Au:
*(_DWORD *)a1 = 5462100;
break;
case 0xA0u:
case 0xA4u:
case 0xACu:
case 0xB4u:
case 0xBCu:
*(_DWORD *)a1 = 5850188;
break;
case 0xA1u:
case 0xA5u:
case 0xA9u:
case 0xADu:
case 0xB1u:
case 0xB5u:
case 0xB9u:
case 0xBDu:
*(_DWORD *)a1 = 4277324;
break;
case 0xA2u:
case 0xA6u:
case 0xAEu:
case 0xB6u:
case 0xBEu:
*(_DWORD *)a1 = 5784652;
break;
case 0xA3u:
case 0xA7u:
case 0xAFu:
case 0xB3u:
case 0xB7u:
case 0xBFu:
*(_DWORD *)a1 = 5783884;
break;
case 0xA8u:
*(_DWORD *)a1 = 5849428;
break;
case 0xAAu:
*(_DWORD *)a1 = 5783892;
break;
case 0xB0u:
*(_DWORD *)a1 = 5456706;
break;
case 0xB8u:
*(_DWORD *)a1 = 5655619;
break;
case 0xBAu:
*(_DWORD *)a1 = 5788500;
break;
case 0xC0u:
case 0xC4u:
case 0xCCu:
*(_DWORD *)a1 = 5853251;
break;
case 0xC1u:
case 0xC5u:
case 0xC9u:
case 0xCDu:
case 0xD1u:
case 0xD5u:
case 0xD9u:
case 0xDDu:
*(_DWORD *)a1 = 5262659;
break;
case 0xC6u:
case 0xCEu:
case 0xD6u:
case 0xDEu:
*(_DWORD *)a1 = 4408644;
break;
case 0xC8u:
*(_DWORD *)a1 = 5852745;
break;
case 0xCAu:
*(_DWORD *)a1 = 5784900;
break;
case 0xD0u:
*(_DWORD *)a1 = 4542018;
break;
case 0xD8u:
*(_DWORD *)a1 = 4475971;
break;
case 0xE0u:
case 0xE4u:
case 0xECu:
*(_DWORD *)a1 = 5787715;
break;
case 0xE1u:
case 0xE5u:
case 0xE9u:
case 0xEDu:
case 0xF1u:
case 0xF5u:
case 0xF9u:
case 0xFDu:
*(_DWORD *)a1 = 4407891;
break;
case 0xE6u:
case 0xEEu:
case 0xF6u:
case 0xFEu:
*(_DWORD *)a1 = 4410953;
break;
case 0xE8u:
*(_DWORD *)a1 = 5787209;
break;
case 0xEAu:
*(_DWORD *)a1 = 5263182;
break;
case 0xF0u:
*(_DWORD *)a1 = 5326146;
break;
case 0xF8u:
*(_DWORD *)a1 = 4474195;
break;
case 0xFFu:
*(_DWORD *)a1 = 4412229;
break;
}
return result;
}

canonical_decompiled_code:
int __fastcall func5(char *a1, unsigned __int8 a2)
{
int result; // eax

result = a2;
switch ( a2 )
{
case 0u:
*(_DWORD *)a1 = 4936258;
break;
case 1u:
case 5u:
case 9u:
case 0xDu:
case 0x11u:
case 0x15u:
case 0x19u:
case 0x1Du:
*(_DWORD *)a1 = 4280911;
break;
case 2u:
case 3u:
case 4u:
case 7u:
case 0xBu:
case 0xCu:
case 0xFu:
case 0x12u:
case 0x13u:
case 0x14u:
case 0x17u:
case 0x1Au:
case 0x1Bu:
case 0x1Cu:
case 0x1Fu:
case 0x22u:
case 0x23u:
case 0x27u:
case 0x2Bu:
case 0x2Fu:
case 0x32u:
case 0x33u:
case 0x34u:
case 0x37u:
case 0x3Au:
case 0x3Bu:
case 0x3Cu:
case 0x3Fu:
case 0x42u:
case 0x43u:
case 0x44u:
case 0x47u:
case 0x4Bu:
case 0x4Fu:
case 0x52u:
case 0x53u:
case 0x54u:
case 0x57u:
case 0x5Au:
case 0x5Bu:
case 0x5Cu:
case 0x5Fu:
case 0x62u:
case 0x63u:
case 0x64u:
case 0x67u:
case 0x6Bu:
case 0x6Fu:
case 0x72u:
case 0x73u:
case 0x74u:
case 0x77u:
case 0x7Au:
case 0x7Bu:
case 0x7Cu:
case 0x7Fu:
case 0x80u:
case 0x82u:
case 0x83u:
case 0x87u:
case 0x89u:
case 0x8Bu:
case 0x8Fu:
case 0x92u:
case 0x93u:
case 0x97u:
case 0x9Bu:
case 0x9Cu:
case 0x9Eu:
case 0x9Fu:
case 0xABu:
case 0xB2u:
case 0xBBu:
case 0xC2u:
case 0xC3u:
case 0xC7u:
case 0xCBu:
case 0xCFu:
case 0xD2u:
case 0xD3u:
case 0xD4u:
case 0xD7u:
case 0xDAu:
case 0xDBu:
case 0xDCu:
case 0xDFu:
case 0xE2u:
case 0xE3u:
case 0xE7u:
case 0xEBu:
case 0xEFu:
case 0xF2u:
case 0xF3u:
case 0xF4u:
case 0xF7u:
case 0xFAu:
case 0xFBu:
case 0xFCu:
result = sprintf(a1, "*** ILLEGAL INSTRUCTION (%x) ***", a2);
break;
case 6u:
case 0xEu:
case 0x16u:
case 0x1Eu:
*(_DWORD *)a1 = 5002049;
break;
case 8u:
*(_DWORD *)a1 = 5261392;
break;
case 0xAu:
strcpy(a1, "ASL A");
break;
case 0x10u:
*(_DWORD *)a1 = 5001282;
break;
case 0x18u:
*(_DWORD *)a1 = 4410435;
break;
case 0x20u:
*(_DWORD *)a1 = 5395274;
break;
case 0x21u:
case 0x25u:
case 0x29u:
case 0x2Du:
case 0x31u:
case 0x35u:
case 0x39u:
case 0x3Du:
*(_DWORD *)a1 = 4476481;
break;
case 0x24u:
case 0x2Cu:
*(_DWORD *)a1 = 5523778;
break;
case 0x26u:
case 0x2Eu:
case 0x36u:
case 0x3Eu:
*(_DWORD *)a1 = 5001042;
break;
case 0x28u:
*(_DWORD *)a1 = 5262416;
break;
case 0x2Au:
strcpy(a1, "ROL A");
break;
case 0x30u:
*(_DWORD *)a1 = 4803906;
break;
case 0x38u:
*(_DWORD *)a1 = 4408659;
break;
case 0x40u:
*(_DWORD *)a1 = 4805714;
break;
case 0x41u:
case 0x45u:
case 0x49u:
case 0x4Du:
case 0x51u:
case 0x55u:
case 0x59u:
case 0x5Du:
*(_DWORD *)a1 = 5394245;
break;
case 0x46u:
case 0x4Eu:
case 0x56u:
case 0x5Eu:
*(_DWORD *)a1 = 5395276;
break;
case 0x48u:
*(_DWORD *)a1 = 4278352;
break;
case 0x4Au:
strcpy(a1, "LSR A");
break;
case 0x4Cu:
case 0x6Cu:
*(_DWORD *)a1 = 5262666;
break;
case 0x50u:
*(_DWORD *)a1 = 4412994;
break;
case 0x58u:
*(_DWORD *)a1 = 4803651;
break;
case 0x60u:
*(_DWORD *)a1 = 5461074;
break;
case 0x61u:
case 0x65u:
case 0x69u:
case 0x6Du:
case 0x71u:
case 0x75u:
case 0x79u:
case 0x7Du:
*(_DWORD *)a1 = 4408385;
break;
case 0x66u:
case 0x6Eu:
case 0x76u:
case 0x7Eu:
*(_DWORD *)a1 = 5394258;
break;
case 0x68u:
*(_DWORD *)a1 = 4279376;
break;
case 0x6Au:
strcpy(a1, "ROR A");
break;
case 0x70u:
*(_DWORD *)a1 = 5461570;
break;
case 0x78u:
*(_DWORD *)a1 = 4801875;
break;
case 0x81u:
case 0x85u:
case 0x8Du:
case 0x91u:
case 0x95u:
case 0x99u:
case 0x9Du:
*(_DWORD *)a1 = 4281427;
break;
case 0x84u:
case 0x8Cu:
case 0x94u:
*(_DWORD *)a1 = 5854291;
break;
case 0x86u:
case 0x8Eu:
case 0x96u:
*(_DWORD *)a1 = 5788755;
break;
case 0x88u:
*(_DWORD *)a1 = 5850436;
break;
case 0x8Au:
*(_DWORD *)a1 = 4282452;
break;
case 0x90u:
*(_DWORD *)a1 = 4408130;
break;
case 0x98u:
*(_DWORD *)a1 = 4282708;
break;
case 0x9Au:
*(_DWORD *)a1 = 5462100;
break;
case 0xA0u:
case 0xA4u:
case 0xACu:
case 0xB4u:
case 0xBCu:
*(_DWORD *)a1 = 5850188;
break;
case 0xA1u:
case 0xA5u:
case 0xA9u:
case 0xADu:
case 0xB1u:
case 0xB5u:
case 0xB9u:
case 0xBDu:
*(_DWORD *)a1 = 4277324;
break;
case 0xA2u:
case 0xA6u:
case 0xAEu:
case 0xB6u:
case 0xBEu:
*(_DWORD *)a1 = 5784652;
break;
case 0xA3u:
case 0xA7u:
case 0xAFu:
case 0xB3u:
case 0xB7u:
case 0xBFu:
*(_DWORD *)a1 = 5783884;
break;
case 0xA8u:
*(_DWORD *)a1 = 5849428;
break;
case 0xAAu:
*(_DWORD *)a1 = 5783892;
break;
case 0xB0u:
*(_DWORD *)a1 = 5456706;
break;
case 0xB8u:
*(_DWORD *)a1 = 5655619;
break;
case 0xBAu:
*(_DWORD *)a1 = 5788500;
break;
case 0xC0u:
case 0xC4u:
case 0xCCu:
*(_DWORD *)a1 = 5853251;
break;
case 0xC1u:
case 0xC5u:
case 0xC9u:
case 0xCDu:
case 0xD1u:
case 0xD5u:
case 0xD9u:
case 0xDDu:
*(_DWORD *)a1 = 5262659;
break;
case 0xC6u:
case 0xCEu:
case 0xD6u:
case 0xDEu:
*(_DWORD *)a1 = 4408644;
break;
case 0xC8u:
*(_DWORD *)a1 = 5852745;
break;
case 0xCAu:
*(_DWORD *)a1 = 5784900;
break;
case 0xD0u:
*(_DWORD *)a1 = 4542018;
break;
case 0xD8u:
*(_DWORD *)a1 = 4475971;
break;
case 0xE0u:
case 0xE4u:
case 0xECu:
*(_DWORD *)a1 = 5787715;
break;
case 0xE1u:
case 0xE5u:
case 0xE9u:
case 0xEDu:
case 0xF1u:
case 0xF5u:
case 0xF9u:
case 0xFDu:
*(_DWORD *)a1 = 4407891;
break;
case 0xE6u:
case 0xEEu:
case 0xF6u:
case 0xFEu:
*(_DWORD *)a1 = 4410953;
break;
case 0xE8u:
*(_DWORD *)a1 = 5787209;
break;
case 0xEAu:
*(_DWORD *)a1 = 5263182;
break;
case 0xF0u:
*(_DWORD *)a1 = 5326146;
break;
case 0xF8u:
*(_DWORD *)a1 = 4474195;
break;
case 0xFFu:
*(_DWORD *)a1 = 4412229;
break;
}
return result;
}

original_code:
void show_opcode(char *mystring, uint8 instr)
{
 switch (instr) {
 case 0x6d:
 case 0x65:
 case 0x69:
 case 0x79:
 case 0x7d:
 case 0x61:
 case 0x71:
 case 0x75:
  sprintf(mystring, "ADC");
  break;
 case 0x2d:
 case 0x25:
 case 0x29:
 case 0x39:
 case 0x3d:
 case 0x21:
 case 0x31:
 case 0x35:
  sprintf(mystring, "AND");
  break;
 case 0x0e:
 case 0x06:
 case 0x1e:
 case 0x16:
  sprintf(mystring, "ASL");
  break;
 case 0x0a:
  sprintf(mystring, "ASL A");
  break;
 case 0x90:
  sprintf(mystring, "BCC");
  break;
 case 0xb0:
  sprintf(mystring, "BCS");
  break;
 case 0xf0:
  sprintf(mystring, "BEQ");
  break;
 case 0x2c:
 case 0x24:
  sprintf(mystring, "BIT");
  break;
 case 0x30:
  sprintf(mystring, "BMI");
  break;
 case 0xd0:
  sprintf(mystring, "BNE");
  break;
 case 0x10:
  sprintf(mystring, "BPL");
  break;
 case 0x00:
  sprintf(mystring, "BRK");
  break;
 case 0x50:
  sprintf(mystring, "BVC");
  break;
 case 0x70:
  sprintf(mystring, "BVS");
  break;
 case 0x18:
  sprintf(mystring, "CLC");
  break;
 case 0xd8:
  sprintf(mystring, "CLD");
  break;
 case 0x58:
  sprintf(mystring, "CLI");
  break;
 case 0xb8:
  sprintf(mystring, "CLV");
  break;
 case 0xcd:
 case 0xc5:
 case 0xc9:
 case 0xdd:
 case 0xd9:
 case 0xc1:
 case 0xd1:
 case 0xd5:
  sprintf(mystring, "CMP");
  break;
 case 0xec:
 case 0xe4:
 case 0xe0:
  sprintf(mystring, "CPX");
  break;
 case 0xcc:
 case 0xc4:
 case 0xc0:
  sprintf(mystring, "CPY");
  break;
 case 0xce:
 case 0xc6:
 case 0xde:
 case 0xd6:
  sprintf(mystring, "DEC");
  break;
 case 0xca:
  sprintf(mystring, "DEX");
  break;
 case 0x88:
  sprintf(mystring, "DEY");
  break;
 case 0x4d:
 case 0x45:
 case 0x49:
 case 0x5d:
 case 0x59:
 case 0x41:
 case 0x51:
 case 0x55:
  sprintf(mystring, "EOR");
  break;
 case 0xff:
  sprintf(mystring, "ESC");
  break;
 case 0xee:
 case 0xe6:
 case 0xfe:
 case 0xf6:
  sprintf(mystring, "INC");
  break;
 case 0xe8:
  sprintf(mystring, "INX");
  break;
 case 0xc8:
  sprintf(mystring, "INY");
  break;
 case 0x4c:
 case 0x6c:
  sprintf(mystring, "JMP");
  break;
 case 0x20:
  sprintf(mystring, "JSR");
  break;
 case 0xa3:
 case 0xa7:
 case 0xaf:
 case 0xb3:
 case 0xb7:
 case 0xbf:
  sprintf(mystring, "LAX");
  break;
 case 0xad:
 case 0xa5:
 case 0xa9:
 case 0xbd:
 case 0xb9:
 case 0xa1:
 case 0xb1:
 case 0xb5:
  sprintf(mystring, "LDA");
  break;
 case 0xae:
 case 0xa6:
 case 0xa2:
 case 0xbe:
 case 0xb6:
  sprintf(mystring, "LDX");
  break;
 case 0xac:
 case 0xa4:
 case 0xa0:
 case 0xbc:
 case 0xb4:
  sprintf(mystring, "LDY");
  break;
 case 0x4e:
 case 0x46:
 case 0x5e:
 case 0x56:
  sprintf(mystring, "LSR");
  break;
 case 0x4a:
  sprintf(mystring, "LSR A");
  break;
 case 0xea:
  sprintf(mystring, "NOP");
  break;
 case 0x0d:
 case 0x05:
 case 0x09:
 case 0x1d:
 case 0x19:
 case 0x01:
 case 0x11:
 case 0x15:
  sprintf(mystring, "ORA");
  break;
 case 0x48:
  sprintf(mystring, "PHA");
  break;
 case 0x08:
  sprintf(mystring, "PHP");
  break;
 case 0x68:
  sprintf(mystring, "PLA");
  break;
 case 0x28:
  sprintf(mystring, "PLP");
  break;
 case 0x2e:
 case 0x26:
 case 0x3e:
 case 0x36:
  sprintf(mystring, "ROL");
  break;
 case 0x2a:
  sprintf(mystring, "ROL A");
  break;
 case 0x6e:
 case 0x66:
 case 0x7e:
 case 0x76:
  sprintf(mystring, "ROR");
  break;
 case 0x6a:
  sprintf(mystring, "ROR A");
  break;
 case 0x40:
  sprintf(mystring, "RTI");
  break;
 case 0x60:
  sprintf(mystring, "RTS");
  break;
 case 0xed:
 case 0xe5:
 case 0xe9:
 case 0xfd:
 case 0xf9:
 case 0xe1:
 case 0xf1:
 case 0xf5:
  sprintf(mystring, "SBC");
  break;
 case 0x38:
  sprintf(mystring, "SEC");
  break;
 case 0xf8:
  sprintf(mystring, "SED");
  break;
 case 0x78:
  sprintf(mystring, "SEI");
  break;
 case 0x8d:
 case 0x85:
 case 0x9d:
 case 0x99:
 case 0x81:
 case 0x91:
 case 0x95:
  sprintf(mystring, "STA");
  break;
 case 0x8e:
 case 0x86:
 case 0x96:
  sprintf(mystring, "STX");
  break;
 case 0x8c:
 case 0x84:
 case 0x94:
  sprintf(mystring, "STY");
  break;
 case 0xaa:
  sprintf(mystring, "TAX");
  break;
 case 0xa8:
  sprintf(mystring, "TAY");
  break;
 case 0xba:
  sprintf(mystring, "TSX");
  break;
 case 0x8a:
  sprintf(mystring, "TXA");
  break;
 case 0x9a:
  sprintf(mystring, "TXS");
  break;
 case 0x98:
  sprintf(mystring, "TYA");
  break;
 default:
  sprintf(mystring, "*** ILLEGAL INSTRUCTION (%x) ***", instr);
  break;
 }
}

canonical_original_code:
void show_opcode(char *mystring, unsigned char instr)
{
 switch (instr) {
 case 0x6d:
 case 0x65:
 case 0x69:
 case 0x79:
 case 0x7d:
 case 0x61:
 case 0x71:
 case 0x75:
  sprintf(mystring, "ADC");
  break;
 case 0x2d:
 case 0x25:
 case 0x29:
 case 0x39:
 case 0x3d:
 case 0x21:
 case 0x31:
 case 0x35:
  sprintf(mystring, "AND");
  break;
 case 0x0e:
 case 0x06:
 case 0x1e:
 case 0x16:
  sprintf(mystring, "ASL");
  break;
 case 0x0a:
  sprintf(mystring, "ASL A");
  break;
 case 0x90:
  sprintf(mystring, "BCC");
  break;
 case 0xb0:
  sprintf(mystring, "BCS");
  break;
 case 0xf0:
  sprintf(mystring, "BEQ");
  break;
 case 0x2c:
 case 0x24:
  sprintf(mystring, "BIT");
  break;
 case 0x30:
  sprintf(mystring, "BMI");
  break;
 case 0xd0:
  sprintf(mystring, "BNE");
  break;
 case 0x10:
  sprintf(mystring, "BPL");
  break;
 case 0x00:
  sprintf(mystring, "BRK");
  break;
 case 0x50:
  sprintf(mystring, "BVC");
  break;
 case 0x70:
  sprintf(mystring, "BVS");
  break;
 case 0x18:
  sprintf(mystring, "CLC");
  break;
 case 0xd8:
  sprintf(mystring, "CLD");
  break;
 case 0x58:
  sprintf(mystring, "CLI");
  break;
 case 0xb8:
  sprintf(mystring, "CLV");
  break;
 case 0xcd:
 case 0xc5:
 case 0xc9:
 case 0xdd:
 case 0xd9:
 case 0xc1:
 case 0xd1:
 case 0xd5:
  sprintf(mystring, "CMP");
  break;
 case 0xec:
 case 0xe4:
 case 0xe0:
  sprintf(mystring, "CPX");
  break;
 case 0xcc:
 case 0xc4:
 case 0xc0:
  sprintf(mystring, "CPY");
  break;
 case 0xce:
 case 0xc6:
 case 0xde:
 case 0xd6:
  sprintf(mystring, "DEC");
  break;
 case 0xca:
  sprintf(mystring, "DEX");
  break;
 case 0x88:
  sprintf(mystring, "DEY");
  break;
 case 0x4d:
 case 0x45:
 case 0x49:
 case 0x5d:
 case 0x59:
 case 0x41:
 case 0x51:
 case 0x55:
  sprintf(mystring, "EOR");
  break;
 case 0xff:
  sprintf(mystring, "ESC");
  break;
 case 0xee:
 case 0xe6:
 case 0xfe:
 case 0xf6:
  sprintf(mystring, "INC");
  break;
 case 0xe8:
  sprintf(mystring, "INX");
  break;
 case 0xc8:
  sprintf(mystring, "INY");
  break;
 case 0x4c:
 case 0x6c:
  sprintf(mystring, "JMP");
  break;
 case 0x20:
  sprintf(mystring, "JSR");
  break;
 case 0xa3:
 case 0xa7:
 case 0xaf:
 case 0xb3:
 case 0xb7:
 case 0xbf:
  sprintf(mystring, "LAX");
  break;
 case 0xad:
 case 0xa5:
 case 0xa9:
 case 0xbd:
 case 0xb9:
 case 0xa1:
 case 0xb1:
 case 0xb5:
  sprintf(mystring, "LDA");
  break;
 case 0xae:
 case 0xa6:
 case 0xa2:
 case 0xbe:
 case 0xb6:
  sprintf(mystring, "LDX");
  break;
 case 0xac:
 case 0xa4:
 case 0xa0:
 case 0xbc:
 case 0xb4:
  sprintf(mystring, "LDY");
  break;
 case 0x4e:
 case 0x46:
 case 0x5e:
 case 0x56:
  sprintf(mystring, "LSR");
  break;
 case 0x4a:
  sprintf(mystring, "LSR A");
  break;
 case 0xea:
  sprintf(mystring, "NOP");
  break;
 case 0x0d:
 case 0x05:
 case 0x09:
 case 0x1d:
 case 0x19:
 case 0x01:
 case 0x11:
 case 0x15:
  sprintf(mystring, "ORA");
  break;
 case 0x48:
  sprintf(mystring, "PHA");
  break;
 case 0x08:
  sprintf(mystring, "PHP");
  break;
 case 0x68:
  sprintf(mystring, "PLA");
  break;
 case 0x28:
  sprintf(mystring, "PLP");
  break;
 case 0x2e:
 case 0x26:
 case 0x3e:
 case 0x36:
  sprintf(mystring, "ROL");
  break;
 case 0x2a:
  sprintf(mystring, "ROL A");
  break;
 case 0x6e:
 case 0x66:
 case 0x7e:
 case 0x76:
  sprintf(mystring, "ROR");
  break;
 case 0x6a:
  sprintf(mystring, "ROR A");
  break;
 case 0x40:
  sprintf(mystring, "RTI");
  break;
 case 0x60:
  sprintf(mystring, "RTS");
  break;
 case 0xed:
 case 0xe5:
 case 0xe9:
 case 0xfd:
 case 0xf9:
 case 0xe1:
 case 0xf1:
 case 0xf5:
  sprintf(mystring, "SBC");
  break;
 case 0x38:
  sprintf(mystring, "SEC");
  break;
 case 0xf8:
  sprintf(mystring, "SED");
  break;
 case 0x78:
  sprintf(mystring, "SEI");
  break;
 case 0x8d:
 case 0x85:
 case 0x9d:
 case 0x99:
 case 0x81:
 case 0x91:
 case 0x95:
  sprintf(mystring, "STA");
  break;
 case 0x8e:
 case 0x86:
 case 0x96:
  sprintf(mystring, "STX");
  break;
 case 0x8c:
 case 0x84:
 case 0x94:
  sprintf(mystring, "STY");
  break;
 case 0xaa:
  sprintf(mystring, "TAX");
  break;
 case 0xa8:
  sprintf(mystring, "TAY");
  break;
 case 0xba:
  sprintf(mystring, "TSX");
  break;
 case 0x8a:
  sprintf(mystring, "TXA");
  break;
 case 0x9a:
  sprintf(mystring, "TXS");
  break;
 case 0x98:
  sprintf(mystring, "TYA");
  break;
 default:
  sprintf(mystring, "*** ILLEGAL INSTRUCTION (%x) ***", instr);
  break;
 }
}

variable_types:
mystring
char *

variable_types:
instr
unsigned char


decompiled_code:
int __fastcall show_operand(char *dest, char a2)
{
unsigned __int16 v2; // bp
int result; // eax
__int16 v4; // bp
__int64 v5; // rax
__int64 v6; // rdx
unsigned __int16 v7; // bp
unsigned __int16 v8; // bp
__int64 v9; // rdx
__int64 v10; // rdx
__int64 v11; // rdx
__int16 v12; // bp
__int64 v13; // rdx
__int16 v14; // bp
unsigned __int16 v15; // bp

switch ( a2 )
{
case 0:
case 2:
case 3:
case 4:
case 7:
case 8:
case 10:
case 11:
case 12:
case 15:
case 18:
case 19:
case 20:
case 23:
case 24:
case 26:
case 27:
case 28:
case 31:
case 34:
case 35:
case 39:
case 40:
case 42:
case 43:
case 47:
case 50:
case 51:
case 52:
case 55:
case 56:
case 58:
case 59:
case 60:
case 63:
case 64:
case 66:
case 67:
case 68:
case 71:
case 72:
case 74:
case 75:
case 79:
case 82:
case 83:
case 84:
case 87:
case 88:
case 90:
case 91:
case 92:
case 95:
case 96:
case 98:
case 99:
case 100:
case 103:
case 104:
case 106:
case 107:
case 111:
case 114:
case 115:
case 116:
case 119:
case 120:
case 122:
case 123:
case 124:
case 127:
case -128:
case -126:
case -125:
case -121:
case -120:
case -119:
case -118:
case -117:
case -113:
case -110:
case -109:
case -105:
case -104:
case -102:
case -101:
case -100:
case -98:
case -97:
case -88:
case -86:
case -85:
case -78:
case -72:
case -70:
case -69:
case -62:
case -61:
case -57:
case -56:
case -54:
case -53:
case -49:
case -46:
case -45:
case -44:
case -41:
case -40:
case -38:
case -37:
case -36:
case -33:
case -30:
case -29:
case -25:
case -24:
case -22:
case -21:
case -17:
case -14:
case -13:
case -12:
case -9:
case -8:
case -6:
case -5:
case -4:
return result;
case 1:
case 33:
case 65:
case 97:
case -127:
case -95:
case -93:
case -63:
case -31:
v9 = (unsigned __int16)addr++;
result = sprintf(dest, "($%x,X)", *(unsigned __int8 *)(memory + v9));
break;
case 5:
case 6:
case 36:
case 37:
case 38:
case 69:
case 70:
case 101:
case 102:
case -124:
case -123:
case -122:
case -92:
case -91:
case -90:
case -89:
case -60:
case -59:
case -58:
case -28:
case -27:
case -26:
v4 = *(unsigned __int8 *)(memory + (unsigned __int16)addr);
sprintf(dest, "$%x", *(unsigned __int8 *)(memory + (unsigned __int16)addr));
result = (unsigned int)add_hw_tag(dest, v4);
++addr;
break;
case 9:
case 41:
case 73:
case 105:
case -96:
case -94:
case -87:
case -64:
case -55:
case -32:
case -23:
case -1:
v6 = (unsigned __int16)addr++;
result = sprintf(dest, "#$%x", *(unsigned __int8 *)(memory + v6));
break;
case 13:
case 14:
case 32:
case 44:
case 45:
case 46:
case 76:
case 77:
case 78:
case 109:
case 110:
case -116:
case -115:
case -114:
case -84:
case -83:
case -82:
case -81:
case -52:
case -51:
case -50:
case -20:
case -19:
case -18:
v2 = *(_WORD *)(memory + (unsigned __int16)addr);
sprintf(dest, "$%x", v2);
result = (unsigned int)add_hw_tag(dest, v2);
addr += 2;
break;
case 16:
case 48:
case 80:
case 112:
case -112:
case -80:
case -48:
case -16:
v5 = (unsigned __int16)addr++;
result = sprintf(dest, "$%x", *(char *)(memory + v5) + (unsigned int)(unsigned __int16)addr);
break;
case 17:
case 49:
case 81:
case 113:
case -111:
case -79:
case -77:
case -47:
case -15:
v10 = (unsigned __int16)addr++;
result = sprintf(dest, "($%x),Y", *(unsigned __int8 *)(memory + v10));
break;
case 21:
case 22:
case 53:
case 54:
case 85:
case 86:
case 117:
case 118:
case -108:
case -107:
case -76:
case -75:
case -43:
case -42:
case -11:
case -10:
v11 = (unsigned __int16)addr++;
v12 = *(unsigned __int8 *)(memory + v11);
sprintf(dest, "$%x, X", *(unsigned __int8 *)(memory + v11));
result = (unsigned int)add_hw_tag(dest, v12);
break;
case 25:
case 57:
case 89:
case 121:
case -103:
case -71:
case -66:
case -65:
case -39:
case -7:
v8 = *(_WORD *)(memory + (unsigned __int16)addr);
sprintf(dest, "$%x, Y", v8);
result = (unsigned int)add_hw_tag(dest, v8);
addr += 2;
break;
case 29:
case 30:
case 61:
case 62:
case 93:
case 94:
case 125:
case 126:
case -99:
case -68:
case -67:
case -35:
case -34:
case -3:
case -2:
v7 = *(_WORD *)(memory + (unsigned __int16)addr);
sprintf(dest, "$%x, X", v7);
result = (unsigned int)add_hw_tag(dest, v7);
addr += 2;
break;
case 108:
v15 = *(_WORD *)(memory + (unsigned __int16)addr);
sprintf(dest, "($%x)", v15);
result = (unsigned int)add_hw_tag(dest, v15);
addr += 2;
break;
case -106:
case -74:
case -73:
v13 = (unsigned __int16)addr++;
v14 = *(unsigned __int8 *)(memory + v13);
sprintf(dest, "$%x, Y", *(unsigned __int8 *)(memory + v13));
result = (unsigned int)add_hw_tag(dest, v14);
break;
}
return result;
}

canonical_decompiled_code:
int __fastcall func6(char *dest, char a2)
{
unsigned __int16 v2; // bp
int result; // eax
__int16 v4; // bp
__int64 v5; // rax
__int64 v6; // rdx
unsigned __int16 v7; // bp
unsigned __int16 v8; // bp
__int64 v9; // rdx
__int64 v10; // rdx
__int64 v11; // rdx
__int16 v12; // bp
__int64 v13; // rdx
__int16 v14; // bp
unsigned __int16 v15; // bp

switch ( a2 )
{
case 0:
case 2:
case 3:
case 4:
case 7:
case 8:
case 10:
case 11:
case 12:
case 15:
case 18:
case 19:
case 20:
case 23:
case 24:
case 26:
case 27:
case 28:
case 31:
case 34:
case 35:
case 39:
case 40:
case 42:
case 43:
case 47:
case 50:
case 51:
case 52:
case 55:
case 56:
case 58:
case 59:
case 60:
case 63:
case 64:
case 66:
case 67:
case 68:
case 71:
case 72:
case 74:
case 75:
case 79:
case 82:
case 83:
case 84:
case 87:
case 88:
case 90:
case 91:
case 92:
case 95:
case 96:
case 98:
case 99:
case 100:
case 103:
case 104:
case 106:
case 107:
case 111:
case 114:
case 115:
case 116:
case 119:
case 120:
case 122:
case 123:
case 124:
case 127:
case -128:
case -126:
case -125:
case -121:
case -120:
case -119:
case -118:
case -117:
case -113:
case -110:
case -109:
case -105:
case -104:
case -102:
case -101:
case -100:
case -98:
case -97:
case -88:
case -86:
case -85:
case -78:
case -72:
case -70:
case -69:
case -62:
case -61:
case -57:
case -56:
case -54:
case -53:
case -49:
case -46:
case -45:
case -44:
case -41:
case -40:
case -38:
case -37:
case -36:
case -33:
case -30:
case -29:
case -25:
case -24:
case -22:
case -21:
case -17:
case -14:
case -13:
case -12:
case -9:
case -8:
case -6:
case -5:
case -4:
return result;
case 1:
case 33:
case 65:
case 97:
case -127:
case -95:
case -93:
case -63:
case -31:
v9 = (unsigned __int16)addr++;
result = sprintf(dest, "($%x,X)", *(unsigned __int8 *)(memory + v9));
break;
case 5:
case 6:
case 36:
case 37:
case 38:
case 69:
case 70:
case 101:
case 102:
case -124:
case -123:
case -122:
case -92:
case -91:
case -90:
case -89:
case -60:
case -59:
case -58:
case -28:
case -27:
case -26:
v4 = *(unsigned __int8 *)(memory + (unsigned __int16)addr);
sprintf(dest, "$%x", *(unsigned __int8 *)(memory + (unsigned __int16)addr));
result = (unsigned int)func1(dest, v4);
++addr;
break;
case 9:
case 41:
case 73:
case 105:
case -96:
case -94:
case -87:
case -64:
case -55:
case -32:
case -23:
case -1:
v6 = (unsigned __int16)addr++;
result = sprintf(dest, "#$%x", *(unsigned __int8 *)(memory + v6));
break;
case 13:
case 14:
case 32:
case 44:
case 45:
case 46:
case 76:
case 77:
case 78:
case 109:
case 110:
case -116:
case -115:
case -114:
case -84:
case -83:
case -82:
case -81:
case -52:
case -51:
case -50:
case -20:
case -19:
case -18:
v2 = *(_WORD *)(memory + (unsigned __int16)addr);
sprintf(dest, "$%x", v2);
result = (unsigned int)func1(dest, v2);
addr += 2;
break;
case 16:
case 48:
case 80:
case 112:
case -112:
case -80:
case -48:
case -16:
v5 = (unsigned __int16)addr++;
result = sprintf(dest, "$%x", *(char *)(memory + v5) + (unsigned int)(unsigned __int16)addr);
break;
case 17:
case 49:
case 81:
case 113:
case -111:
case -79:
case -77:
case -47:
case -15:
v10 = (unsigned __int16)addr++;
result = sprintf(dest, "($%x),Y", *(unsigned __int8 *)(memory + v10));
break;
case 21:
case 22:
case 53:
case 54:
case 85:
case 86:
case 117:
case 118:
case -108:
case -107:
case -76:
case -75:
case -43:
case -42:
case -11:
case -10:
v11 = (unsigned __int16)addr++;
v12 = *(unsigned __int8 *)(memory + v11);
sprintf(dest, "$%x, X", *(unsigned __int8 *)(memory + v11));
result = (unsigned int)func1(dest, v12);
break;
case 25:
case 57:
case 89:
case 121:
case -103:
case -71:
case -66:
case -65:
case -39:
case -7:
v8 = *(_WORD *)(memory + (unsigned __int16)addr);
sprintf(dest, "$%x, Y", v8);
result = (unsigned int)func1(dest, v8);
addr += 2;
break;
case 29:
case 30:
case 61:
case 62:
case 93:
case 94:
case 125:
case 126:
case -99:
case -68:
case -67:
case -35:
case -34:
case -3:
case -2:
v7 = *(_WORD *)(memory + (unsigned __int16)addr);
sprintf(dest, "$%x, X", v7);
result = (unsigned int)func1(dest, v7);
addr += 2;
break;
case 108:
v15 = *(_WORD *)(memory + (unsigned __int16)addr);
sprintf(dest, "($%x)", v15);
result = (unsigned int)func1(dest, v15);
addr += 2;
break;
case -106:
case -74:
case -73:
v13 = (unsigned __int16)addr++;
v14 = *(unsigned __int8 *)(memory + v13);
sprintf(dest, "$%x, Y", *(unsigned __int8 *)(memory + v13));
result = (unsigned int)func1(dest, v14);
break;
}
return result;
}

original_code:
void show_operand(char *mystring, uint8 instr)
{
 uint8 byte;
 uint16 word;
 switch (instr) {
 case 0x6d:
 case 0x2d:
 case 0x0e:
 case 0x2c:
 case 0xcd:
 case 0xec:
 case 0xcc:
 case 0xce:
 case 0x4d:
 case 0xee:
 case 0x4c:
 case 0x20:
 case 0xaf:
 case 0xad:
 case 0xae:
 case 0xac:
 case 0x4e:
 case 0x0d:
 case 0x2e:
 case 0x6e:
 case 0xed:
 case 0x8d:
 case 0x8e:
 case 0x8c:
  word = (memory[addr + 1] << 8) | memory[addr];
  sprintf(mystring, "$%x", word);
  add_hw_tag(mystring, word);
  addr += 2;
  break;
 case 0x65:
 case 0x25:
 case 0x06:
 case 0x24:
 case 0xc5:
 case 0xe4:
 case 0xc4:
 case 0xc6:
 case 0x45:
 case 0xe6:
 case 0xa7:
 case 0xa5:
 case 0xa6:
 case 0xa4:
 case 0x46:
 case 0x05:
 case 0x26:
 case 0x66:
 case 0xe5:
 case 0x85:
 case 0x86:
 case 0x84:
  byte = memory[addr];
  sprintf(mystring, "$%x", byte);
  add_hw_tag(mystring, (uint16)byte);
  addr++;
  break;
 case 0x90:
 case 0xb0:
 case 0xf0:
 case 0x30:
 case 0xd0:
 case 0x10:
 case 0x50:
 case 0x70:
  byte = memory[addr];
  addr++;
  sprintf(mystring, "$%x", addr + (char) byte);
  break;
 case 0x69:
 case 0x29:
 case 0xc9:
 case 0xe0:
 case 0xc0:
 case 0x49:
 case 0xa9:
 case 0xa2:
 case 0xa0:
 case 0x09:
 case 0xe9:
 case 0xff:
  byte = memory[addr];
  addr++;
  sprintf(mystring, "#$%x", byte);
  break;
 case 0x7d:
 case 0x3d:
 case 0x1e:
 case 0xdd:
 case 0xde:
 case 0x5d:
 case 0xfe:
 case 0xbd:
 case 0xbc:
 case 0x5e:
 case 0x1d:
 case 0x3e:
 case 0x7e:
 case 0xfd:
 case 0x9d:
  word = (memory[addr + 1] << 8) | memory[addr];
  sprintf(mystring, "$%x, X", word);
  add_hw_tag(mystring, word);
  addr += 2;
  break;
 case 0x79:
 case 0x39:
 case 0xd9:
 case 0x59:
 case 0xbf:
 case 0xb9:
 case 0xbe:
 case 0x19:
 case 0xf9:
 case 0x99:
  word = (memory[addr + 1] << 8) | memory[addr];
  sprintf(mystring, "$%x, Y", word);
  add_hw_tag(mystring, word);
  addr += 2;
  break;
 case 0x61:
 case 0x21:
 case 0xc1:
 case 0x41:
 case 0xa3:
 case 0xa1:
 case 0x01:
 case 0xe1:
 case 0x81:
  byte = memory[addr];
  addr++;
  sprintf(mystring, "($%x,X)", byte);
  break;
 case 0x71:
 case 0x31:
 case 0xd1:
 case 0x51:
 case 0xb3:
 case 0xb1:
 case 0x11:
 case 0xf1:
 case 0x91:
  byte = memory[addr];
  addr++;
  sprintf(mystring, "($%x),Y", byte);
  break;
 case 0x75:
 case 0x35:
 case 0x16:
 case 0xd5:
 case 0xd6:
 case 0x55:
 case 0xf6:
 case 0xb5:
 case 0xb4:
 case 0x56:
 case 0x15:
 case 0x36:
 case 0x76:
 case 0xf5:
 case 0x95:
 case 0x94:
  byte = memory[addr];
  addr++;
  sprintf(mystring, "$%x, X", byte);
  add_hw_tag(mystring, (uint16)byte);
  break;
 case 0xb7:
 case 0xb6:
 case 0x96:
  byte = memory[addr];
  addr++;
  sprintf(mystring, "$%x, Y", byte);
  add_hw_tag(mystring, (uint16)byte);
  break;
 case 0x6c:
  word = (memory[addr + 1] << 8) | memory[addr];
  sprintf(mystring, "($%x)", word);
  add_hw_tag(mystring, word);
  addr += 2;
  break;
 }
}

canonical_original_code:
void show_operand(char *mystring, unsigned char instr)
{
 unsigned char byte;
 unsigned short word;
 switch (instr) {
 case 0x6d:
 case 0x2d:
 case 0x0e:
 case 0x2c:
 case 0xcd:
 case 0xec:
 case 0xcc:
 case 0xce:
 case 0x4d:
 case 0xee:
 case 0x4c:
 case 0x20:
 case 0xaf:
 case 0xad:
 case 0xae:
 case 0xac:
 case 0x4e:
 case 0x0d:
 case 0x2e:
 case 0x6e:
 case 0xed:
 case 0x8d:
 case 0x8e:
 case 0x8c:
  word = (memory[addr + 1] << 8) | memory[addr];
  sprintf(mystring, "$%x", word);
  add_hw_tag(mystring, word);
  addr += 2;
  break;
 case 0x65:
 case 0x25:
 case 0x06:
 case 0x24:
 case 0xc5:
 case 0xe4:
 case 0xc4:
 case 0xc6:
 case 0x45:
 case 0xe6:
 case 0xa7:
 case 0xa5:
 case 0xa6:
 case 0xa4:
 case 0x46:
 case 0x05:
 case 0x26:
 case 0x66:
 case 0xe5:
 case 0x85:
 case 0x86:
 case 0x84:
  byte = memory[addr];
  sprintf(mystring, "$%x", byte);
  add_hw_tag(mystring, (unsigned short)byte);
  addr++;
  break;
 case 0x90:
 case 0xb0:
 case 0xf0:
 case 0x30:
 case 0xd0:
 case 0x10:
 case 0x50:
 case 0x70:
  byte = memory[addr];
  addr++;
  sprintf(mystring, "$%x", addr + (char) byte);
  break;
 case 0x69:
 case 0x29:
 case 0xc9:
 case 0xe0:
 case 0xc0:
 case 0x49:
 case 0xa9:
 case 0xa2:
 case 0xa0:
 case 0x09:
 case 0xe9:
 case 0xff:
  byte = memory[addr];
  addr++;
  sprintf(mystring, "#$%x", byte);
  break;
 case 0x7d:
 case 0x3d:
 case 0x1e:
 case 0xdd:
 case 0xde:
 case 0x5d:
 case 0xfe:
 case 0xbd:
 case 0xbc:
 case 0x5e:
 case 0x1d:
 case 0x3e:
 case 0x7e:
 case 0xfd:
 case 0x9d:
  word = (memory[addr + 1] << 8) | memory[addr];
  sprintf(mystring, "$%x, X", word);
  add_hw_tag(mystring, word);
  addr += 2;
  break;
 case 0x79:
 case 0x39:
 case 0xd9:
 case 0x59:
 case 0xbf:
 case 0xb9:
 case 0xbe:
 case 0x19:
 case 0xf9:
 case 0x99:
  word = (memory[addr + 1] << 8) | memory[addr];
  sprintf(mystring, "$%x, Y", word);
  add_hw_tag(mystring, word);
  addr += 2;
  break;
 case 0x61:
 case 0x21:
 case 0xc1:
 case 0x41:
 case 0xa3:
 case 0xa1:
 case 0x01:
 case 0xe1:
 case 0x81:
  byte = memory[addr];
  addr++;
  sprintf(mystring, "($%x,X)", byte);
  break;
 case 0x71:
 case 0x31:
 case 0xd1:
 case 0x51:
 case 0xb3:
 case 0xb1:
 case 0x11:
 case 0xf1:
 case 0x91:
  byte = memory[addr];
  addr++;
  sprintf(mystring, "($%x),Y", byte);
  break;
 case 0x75:
 case 0x35:
 case 0x16:
 case 0xd5:
 case 0xd6:
 case 0x55:
 case 0xf6:
 case 0xb5:
 case 0xb4:
 case 0x56:
 case 0x15:
 case 0x36:
 case 0x76:
 case 0xf5:
 case 0x95:
 case 0x94:
  byte = memory[addr];
  addr++;
  sprintf(mystring, "$%x, X", byte);
  add_hw_tag(mystring, (unsigned short)byte);
  break;
 case 0xb7:
 case 0xb6:
 case 0x96:
  byte = memory[addr];
  addr++;
  sprintf(mystring, "$%x, Y", byte);
  add_hw_tag(mystring, (unsigned short)byte);
  break;
 case 0x6c:
  word = (memory[addr + 1] << 8) | memory[addr];
  sprintf(mystring, "($%x)", word);
  add_hw_tag(mystring, word);
  addr += 2;
  break;
 }
}

variable_types:
byte
unsigned char

variable_types:
word
unsigned short

return_type: void


disassemble

decompiled_code:
__int64 __fastcall disassemble(__int16 a1, unsigned __int16 a2)
{
unsigned __int16 v2; // dx
int v3; // ebp
unsigned int v4; // er12
char v5; // bl
char v7[128]; // [rsp+0h] [rbp-128h] BYREF
char v8[168]; // [rsp+80h] [rbp-A8h] BYREF

addr = a1;
if ( a2 )
{
memory = memory5200;
clrEmuScreen(0LL);
v2 = addr;
v3 = 0;
if ( a2 <= (unsigned __int16)addr )
goto LABEL_9;
}
else
{
memory = memory5200;
clrEmuScreen(0LL);
v2 = addr;
v3 = 24;
}
v4 = 0;
while ( v2 <= 0xFFFBu )
{
sprintf(msg, "%x: ", v2);
printXY(msg, 0LL, v4, 11LL);
v5 = *(_BYTE *)(memory + (unsigned __int16)addr++);
strcpy(v7, " ");
show_opcode(v8, v5);
show_operand(v7, v5);
sprintf(msg, "%s %s", v8, v7);
printXY(msg, 48LL, v4, 12LL);
v3 -= v3 > 0;
v2 = addr;
v4 += 8;
if ( v3 <= 0 && (unsigned __int16)addr >= a2 )
break;
}
LABEL_9:
BlitBuffer(0LL, 240LL);
return (unsigned __int16)addr;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int16 a1, unsigned __int16 a2)
{
unsigned __int16 v2; // dx
int v3; // ebp
unsigned int v4; // er12
char v5; // bl
char v7[128]; // [rsp+0h] [rbp-128h] BYREF
char v8[168]; // [rsp+80h] [rbp-A8h] BYREF

addr = a1;
if ( a2 )
{
memory = memory5200;
clrEmuScreen(0LL);
v2 = addr;
v3 = 0;
if ( a2 <= (unsigned __int16)addr )
goto LABEL_9;
}
else
{
memory = memory5200;
clrEmuScreen(0LL);
v2 = addr;
v3 = 24;
}
v4 = 0;
while ( v2 <= 0xFFFBu )
{
sprintf(msg, "%x: ", v2);
printXY(msg, 0LL, v4, 11LL);
v5 = *(_BYTE *)(memory + (unsigned __int16)addr++);
strcpy(v7, " ");
func5(v8, v5);
func6(v7, v5);
sprintf(msg, "%s %s", v8, v7);
printXY(msg, 48LL, v4, 12LL);
v3 -= v3 > 0;
v2 = addr;
v4 += 8;
if ( v3 <= 0 && (unsigned __int16)addr >= a2 )
break;
}
LABEL_9:
BlitBuffer(0LL, 240LL);
return (unsigned __int16)addr;
}

original_code:
unsigned int disassemble(uint16 addr1, uint16 addr2)
{
 uint8 instr;
 int count, line;
    char string1[128];
    char string2[128];
 addr = addr1;
 count = (addr2 == 0) ? 24 : 0;
    line = 0;
    memory = memory5200;
    clrEmuScreen(0x00);
 while ((addr < addr2 || count > 0) && (addr < 0xFFFC)) {
  sprintf(msg, "%x: ", addr);
  printXY(msg, 0, line * 8, 11);
  instr = memory[addr];
  addr++;
        sprintf(string2, "  ");
  show_opcode(string1, instr);
  show_operand(string2, instr);
  sprintf(msg, "%s    %s", string1, string2);
  printXY(msg, 48, line * 8, 12);
  line++;
  if (count > 0)
   count--;
 }
 BlitBuffer(0, 240);
 return addr;
}

canonical_original_code:
unsigned int disassemble(unsigned short addr1, unsigned short addr2)
{
 unsigned char instr;
 int count; int line;
    char string1[128];
    char string2[128];
 addr = addr1;
 count = (addr2 == 0) ? 24 : 0;
    line = 0;
    memory = memory5200;
    clrEmuScreen(0x00);
 while ((addr < addr2 || count > 0) && (addr < 0xFFFC)) {
  sprintf(msg, "%x: ", addr);
  printXY(msg, 0, line * 8, 11);
  instr = memory[addr];
  addr++;
        sprintf(string2, "  ");
  show_opcode(string1, instr);
  show_operand(string2, instr);
  sprintf(msg, "%s    %s", string1, string2);
  printXY(msg, 48, line * 8, 12);
  line++;
  if (count > 0)
   count--;
 }
 BlitBuffer(0, 240);
 return addr;
}

variable_types: count int

variable_types: line int

return_type: unsigned int


repo: jamesabanks/Pod

decompiled_code:
__int64 __fastcall run_test(char *path)
{
unsigned int v1; // ebx
int *v2; // rbx
char *v3; // rax
int *v4; // rax
char *v5; // rax
_DWORD stat_loc[3]; // [rsp+4h] [rbp-24h] BYREF
char *argv[3]; // [rsp+10h] [rbp-18h] BYREF

argv[0] = 0LL;
argv[1] = 0LL;
*(_QWORD *)&stat_loc[1] = 0LL;
fprintf(stdout, "Running test '%s'\n", path);
fflush(stdout);
if ( !fork() )
{
argv[0] = path;
execve(path, argv, (char *const *)&stat_loc[1]);
v2 = __errno_location();
v3 = strerror(*v2);
fprintf(stdout, " Execve failure: %s (%d)\n", v3, (unsigned int)*v2);
fflush(stdout);
exit(*v2);
}
v1 = 0;
if ( wait((__WAIT_STATUS)stat_loc) < 0 )
{
v4 = __errno_location();
v5 = strerror(*v4);
fprintf(stdout, " Wait failure: %s\n", v5);
v1 = 1;
}
if ( stat_loc[0] )
{
if ( (stat_loc[0] & 0x7F) != 0 )
{
fwrite(" FAILED (and/or didn't exit)\n", 1uLL, 0x20uLL, stdout);
}
else if ( BYTE1(stat_loc[0]) == 1 )
{
fwrite(" FAILED (1 error)\n", 1uLL, 0x15uLL, stdout);
}
else
{
fprintf(stdout, " FAILED (%d errors)\n", BYTE1(stat_loc[0]));
}
}
else
{
fwrite(" SUCCESS\n", 1uLL, 0xCuLL, stdout);
}
fflush(stdout);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func7(char *path)
{
unsigned int v1; // ebx
int *v2; // rbx
char *v3; // rax
int *v4; // rax
char *v5; // rax
_DWORD stat_loc[3]; // [rsp+4h] [rbp-24h] BYREF
char *argv[3]; // [rsp+10h] [rbp-18h] BYREF

argv[0] = 0LL;
argv[1] = 0LL;
*(_QWORD *)&stat_loc[1] = 0LL;
fprintf(stdout, "Running test '%s'\n", path);
fflush(stdout);
if ( !fork() )
{
argv[0] = path;
execve(path, argv, (char *const *)&stat_loc[1]);
v2 = __errno_location();
v3 = strerror(*v2);
fprintf(stdout, " Execve failure: %s (%d)\n", v3, (unsigned int)*v2);
fflush(stdout);
exit(*v2);
}
v1 = 0;
if ( wait((__WAIT_STATUS)stat_loc) < 0 )
{
v4 = __errno_location();
v5 = strerror(*v4);
fprintf(stdout, " Wait failure: %s\n", v5);
v1 = 1;
}
if ( stat_loc[0] )
{
if ( (stat_loc[0] & 0x7F) != 0 )
{
fwrite(" FAILED (and/or didn't exit)\n", 1uLL, 0x20uLL, stdout);
}
else if ( BYTE1(stat_loc[0]) == 1 )
{
fwrite(" FAILED (1 error)\n", 1uLL, 0x15uLL, stdout);
}
else
{
fprintf(stdout, " FAILED (%d errors)\n", BYTE1(stat_loc[0]));
}
}
else
{
fwrite(" SUCCESS\n", 1uLL, 0xCuLL, stdout);
}
fflush(stdout);
return v1;
}

original_code:
static int run_test(char *name)
{
    char *argv[] = { ((void *)0), ((void *)0) };
    char *env[] = { ((void *)0) };
    pid_t pid;
    int retval;
    int status;
    char *estr;
    int temp;
    retval = 0;
    fprintf(stdout, "Running test '%s'\n", name);
    fflush(stdout);
    pid = fork();
    if (pid == 0) {
        argv[0] = name;
        execve(name, argv, env);
        estr = strerror((*__errno_location ()));
        fprintf(stdout, "    Execve failure: %s (%d)\n", estr, (*__errno_location ()));
        fflush(stdout);
        exit((*__errno_location ()));
    } else {
        pid = wait(&status);
        if (pid < 0) {
            fprintf(stdout, "    Wait failure: %s\n", strerror((*__errno_location ())));
            retval = 1;
        }
    }
    if (status == 0) {
        fprintf(stdout, "    SUCCESS\n");
    } else {
        if ((((status) & 0x7f) == 0)) {
            temp = (((status) & 0xff00) >> 8);
            if (temp == 1) {
                fprintf(stdout, "    FAILED (1 error)\n");
            } else {
                fprintf(stdout, "    FAILED (%d errors)\n", temp);
            }
        } else {
            fprintf(stdout, "    FAILED (and/or didn't exit)\n");
        }
    }
    fflush(stdout);
    return retval;
}

canonical_original_code:
static int run_test(char *name)
{
    char *argv[] = { ((void *)0), ((void *)0) };
    char *env[] = { ((void *)0) };
    int pid;
    int retval;
    int status;
    char *estr;
    int temp;
    retval = 0;
    fprintf(stdout, "Running test '%s'\n", name);
    fflush(stdout);
    pid = fork();
    if (pid == 0) {
        argv[0] = name;
        execve(name, argv, env);
        estr = strerror((*__errno_location ()));
        fprintf(stdout, "    Execve failure: %s (%d)\n", estr, (*__errno_location ()));
        fflush(stdout);
        exit((*__errno_location ()));
    } else {
        pid = wait(&status);
        if (pid < 0) {
            fprintf(stdout, "    Wait failure: %s\n", strerror((*__errno_location ())));
            retval = 1;
        }
    }
    if (status == 0) {
        fprintf(stdout, "    SUCCESS\n");
    } else {
        if ((((status) & 0x7f) == 0)) {
            temp = (((status) & 0xff00) >> 8);
            if (temp == 1) {
                fprintf(stdout, "    FAILED (1 error)\n");
            } else {
                fprintf(stdout, "    FAILED (%d errors)\n", temp);
            }
        } else {
            fprintf(stdout, "    FAILED (and/or didn't exit)\n");
        }
    }
    fflush(stdout);
    return retval;
}

variable_types:
name
char *

variable_types:
argv
char *[]

variable_types:
env
char *[]

variable_types: pid int

variable_types: retval int

variable_types: status int

variable_types:
estr
char *

variable_types: temp int

return_type: int


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // rdi
char **v4; // rbp
int v5; // ebx

if ( argc > 2 )
{
fwrite("Too many arguments\n", 1uLL, 0x13uLL, stderr);
v5 = 1;
}
else if ( argc == 2 )
{
v5 = run_test((char *)argv[1]);
}
else
{
v3 = test_files[0];
v4 = off_4040A8;
v5 = 0;
if ( test_files[0] )
{
while ( 1 )
{
v5 = run_test(v3);
if ( v5 )
break;
if ( *v4 )
{
fputc(10, stdout);
v3 = *v4++;
if ( v3 )
continue;
}
return v5;
}
fputc(10, stdout);
}
}
return v5;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // rdi
char **v4; // rbp
int v5; // ebx

if ( argc > 2 )
{
fwrite("Too many arguments\n", 1uLL, 0x13uLL, stderr);
v5 = 1;
}
else if ( argc == 2 )
{
v5 = func7((char *)argv[1]);
}
else
{
v3 = test_files[0];
v4 = off_4040A8;
v5 = 0;
if ( test_files[0] )
{
while ( 1 )
{
v5 = func7(v3);
if ( v5 )
break;
if ( *v4 )
{
fputc(10, stdout);
v3 = *v4++;
if ( v3 )
continue;
}
return v5;
}
fputc(10, stdout);
}
}
return v5;
}

original_code:
int main(int argc, char *argv[])
{
    int i;
    int retval;
    retval = 0;
    if (argc > 2) {
        fprintf(stderr, "Too many arguments\n");
        retval = 1;
    } else if (argc == 2) {
        retval = run_test(argv[1]);
    } else {
        i = 0;
        while (test_files[i] != ((void *)0)) {
            retval = run_test(test_files[i]);
            if (retval != 0) {
                fprintf(stdout, "\n");
                break;
            }
            i++;
            if (test_files[i] != ((void *)0)) {
                fprintf(stdout, "\n");
            }
        }
    }
    return retval;
}

variable_types: argc int

variable_types: i int


repo: jamesfowkes/Code-Library

original_code:
int integer_value(char *c1, int pos, int len)
{
 int d = 0;
 register int i;
 for (i=0;(i<len);i++)
 {
  switch (c1[i+pos]) {
  case ' ' :
   break;
  case '0' :
   d *= 10;
   break;
  case '1' :
   d *= 10;
   d++;
   break;
  case '2' :
   d *= 10;
   d += 2;
   break;
  case '3' :
   d *= 10;
   d += 3;
   break;
  case '4' :
   d *= 10;
   d += 4;
   break;
  case '5' :
   d *= 10;
   d += 5;
   break;
  case '6' :
   d *= 10;
   d += 6;
   break;
  case '7' :
   d *= 10;
   d += 7;
   break;
  case '8' :
   d *= 10;
   d += 8;
   break;
  case '9' :
   d *= 10;
   d += 9;
   break;
  default :
   break;
  }
 }
 return d;
}

variable_types: pos int

variable_types: len int

variable_types: d int


original_code:
void Convert_Satellite_Data (struct tle_ascii tle, struct sgp_data *data)
{
 int iexp, ibexp;
 double a1,ao,del1,delo,xnodp,temp, xke;
 data->epoch = double_value(tle.l[1], 18, 14);
 data->julian_epoch = Julian_Date_of_Epoch(data->epoch);
 data->xndt2o = double_value(tle.l[1], 33, 10);
 data->xndd6o = double_value(tle.l[1], 44, 6) * 1.0E-5;
 iexp = integer_value(tle.l[1], 50, 2);
 data->bstar = double_value(tle.l[1], 53, 6) * 1.0E-5;
 ibexp = integer_value(tle.l[1], 59, 2);
 data->xincl = double_value(tle.l[2], 8, 8);
 data->xnodeo = double_value(tle.l[2], 17, 8);
 data->eo = double_value(tle.l[2], 26, 7) * 1E-7;
 data->omegao = double_value(tle.l[2], 34, 8);
 data->xmo = double_value(tle.l[2], 43, 8);
 data->xno = double_value(tle.l[2], 52, 11);
 data->xndd6o = (data->xndd6o) * pow (10.0, -iexp);
 data->bstar = (data->bstar) * pow (10.0, -ibexp) / 1.0;
 data->xnodeo = radians(data->xnodeo);
 data->omegao = radians(data->omegao);
 data->xmo = radians(data->xmo);
 data->xincl = radians(data->xincl);
 data->xno = (data->xno) * 2.0 * 3.1415926535897932384626433279 / 1440.0;
 data->xndt2o = (data->xndt2o) * 2.0 * 3.1415926535897932384626433279 / sqr (1440.0);
 data->xndd6o = (data->xndd6o) * 2.0 * 3.1415926535897932384626433279 / cube (1440.0);
 xke = sqrt((3600.0 * 398600.8) / cube(6378.135));
 a1 = pow ((xke/(data->xno)),(2.0/3.0));
 temp = 1.5 * (1.0826158E-3 / 2.0) * ( 3 * sqr ( cos (data->xincl)) - 1.0 ) / pow ( ( 1.0 - sqr (data->eo) ), 1.5);
 del1 = temp / (sqr (a1));
 ao = a1 * ( 1 - del1 * (0.5 * (2.0/3.0) + del1 * (1.0 + (134.0/81.0)* del1 )));
 delo = temp / (sqr (ao));
 xnodp = (data->xno) / (1 + delo);
 if (((2 * 3.1415926535897932384626433279) / xnodp) >= 225)
     data->ideep = 1;
 else
     data->ideep = 0;
}

canonical_original_code:
void Convert_Satellite_Data(struct tle_ascii tle, struct sgp_data *data)
{
 int iexp; int ibexp;
 double a1; double ao; double del1; double delo; double xnodp; double temp; double xke;
 data->epoch = double_value(tle.l[1], 18, 14);
 data->julian_epoch = Julian_Date_of_Epoch(data->epoch);
 data->xndt2o = double_value(tle.l[1], 33, 10);
 data->xndd6o = double_value(tle.l[1], 44, 6) * 1.0E-5;
 iexp = integer_value(tle.l[1], 50, 2);
 data->bstar = double_value(tle.l[1], 53, 6) * 1.0E-5;
 ibexp = integer_value(tle.l[1], 59, 2);
 data->xincl = double_value(tle.l[2], 8, 8);
 data->xnodeo = double_value(tle.l[2], 17, 8);
 data->eo = double_value(tle.l[2], 26, 7) * 1E-7;
 data->omegao = double_value(tle.l[2], 34, 8);
 data->xmo = double_value(tle.l[2], 43, 8);
 data->xno = double_value(tle.l[2], 52, 11);
 data->xndd6o = (data->xndd6o) * pow (10.0, -iexp);
 data->bstar = (data->bstar) * pow (10.0, -ibexp) / 1.0;
 data->xnodeo = radians(data->xnodeo);
 data->omegao = radians(data->omegao);
 data->xmo = radians(data->xmo);
 data->xincl = radians(data->xincl);
 data->xno = (data->xno) * 2.0 * 3.1415926535897932384626433279 / 1440.0;
 data->xndt2o = (data->xndt2o) * 2.0 * 3.1415926535897932384626433279 / sqr (1440.0);
 data->xndd6o = (data->xndd6o) * 2.0 * 3.1415926535897932384626433279 / cube (1440.0);
 xke = sqrt((3600.0 * 398600.8) / cube(6378.135));
 a1 = pow ((xke/(data->xno)),(2.0/3.0));
 temp = 1.5 * (1.0826158E-3 / 2.0) * ( 3 * sqr ( cos (data->xincl)) - 1.0 ) / pow ( ( 1.0 - sqr (data->eo) ), 1.5);
 del1 = temp / (sqr (a1));
 ao = a1 * ( 1 - del1 * (0.5 * (2.0/3.0) + del1 * (1.0 + (134.0/81.0)* del1 )));
 delo = temp / (sqr (ao));
 xnodp = (data->xno) / (1 + delo);
 if (((2 * 3.1415926535897932384626433279) / xnodp) >= 225)
     data->ideep = 1;
 else
     data->ideep = 0;
}

variable_types:
tle
struct tle_ascii { char *l[3]; }

variable_types: struct sgp_data { double epoch; double julian_epoch; double xno; double bstar; double xincl; double eo; double xmo; double omegao; double xnodeo; double xndt2o; double xndd6o; char catnr[5]; char elset[3]; int ideep; } *

variable_types: iexp int

variable_types: ibexp int

variable_types: ao double

variable_types: delo double

variable_types: xnodp double

variable_types: temp double

variable_types: xke double


original_code:
void Convert_Sat_State (struct vector *p, struct vector *v)
{
 register int i;
 for (i=0;(i<3);i++)
 {
  p->v[i] = p->v[i] * 6378.135;
  if (v)
  {
   v->v[i] = v->v[i] * 6378.135 / 60;
  }
 }
 Magnitude (p);
 if (v)
 {
  Magnitude (v);
 }
}

canonical_original_code:
void Convert_Sat_State(struct vector *p, struct vector *v)
{
 register int i;
 for (i=0;(i<3);i++)
 {
  p->v[i] = p->v[i] * 6378.135;
  if (v)
  {
   v->v[i] = v->v[i] * 6378.135 / 60;
  }
 }
 Magnitude (p);
 if (v)
 {
  Magnitude (v);
 }
}

variable_types:
p
struct vector { double v[4]; } *

variable_types:
v
struct vector *


sgp

decompiled_code:
__int64 __fastcall sgp(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8, __int64 a9)
{
char v11[136]; // [rsp+8h] [rbp-88h] BYREF

Convert_Satellite_Data((__int64)v11, a2, a3, a4, a5, a6, a7, a8, a9);
Convert_Sat_State(a2, a3);
return 0LL;
}

original_code:
int sgp (int mode, double time, struct tle_ascii tle, struct vector *pos, struct vector *vel)
{
 (void)mode;
 struct sgp_data satdata;
 Convert_Satellite_Data (tle, &satdata);
 Convert_Sat_State (pos, vel);
 return 0;
}

canonical_original_code:
int sgp(int mode, double time, struct tle_ascii tle, struct vector *pos, struct vector *vel)
{
 (void)mode;
 struct sgp_data satdata;
 Convert_Satellite_Data (tle, &satdata);
 Convert_Sat_State (pos, vel);
 return 0;
}

variable_types: mode int

variable_types: time double

variable_types:
pos
struct vector { double v[4]; } *

variable_types:
vel
struct vector *

variable_types: struct sgp_data { double epoch; double julian_epoch; double xno; double bstar; double xincl; double eo; double xmo; double omegao; double xnodeo; double xndt2o; double xndd6o; char catnr[5]; char elset[3]; int ideep; }


decompiled_code:
__int64 __fastcall sgp0(__int64 a1, __int64 a2, double *a3, double a4)
{
double v5; // xmm0_8
double v6; // r15
double v7; // r13
double v8; // r14
double v9; // xmm0_8
double v10; // r13
double v11; // r14
double v12; // r13
double v13; // r15
double v14; // r13
double v15; // xmm0_8
double v16; // xmm5_8
double v17; // xmm0_8
double v18; // r13
double v19; // r14
double v20; // r15
double v21; // r15
double v22; // xmm3_8
double v23; // xmm0_8
double v24; // xmm0_8
double v25; // r14
double v26; // xmm1_8
int v27; // er13
double v28; // xmm4_8
double v29; // xmm0_8
double v30; // r13
double v31; // r14
double v32; // r15
double v33; // xmm0_8
double v34; // xmm0_8
double v35; // xmm4_8
double v36; // r14
double v37; // xmm0_8
double v38; // r14
double v39; // r13
double v40; // r13
double v41; // r15
double v42; // r14
double v43; // r13
double v44; // xmm0_8
double v45; // r14
__int64 v46; // r13
double v47; // rbx
double v48; // xmm0_8
double v49; // xmm4_8
double v50; // xmm3_8
__int64 i; // rax
double v52; // xmm0_8
double v53; // xmm1_8
__int64 result; // rax
double v55; // xmm0_8
double xa; // [rsp+0h] [rbp-128h]
double xb; // [rsp+0h] [rbp-128h]
double v59; // [rsp+8h] [rbp-120h]
double v60; // [rsp+8h] [rbp-120h]
double v61; // [rsp+8h] [rbp-120h]
double v62; // [rsp+8h] [rbp-120h]
double v63; // [rsp+8h] [rbp-120h]
double v64; // [rsp+10h] [rbp-118h]
double v65; // [rsp+10h] [rbp-118h]
double v66; // [rsp+10h] [rbp-118h]
double v67; // [rsp+10h] [rbp-118h]
double v68; // [rsp+10h] [rbp-118h]
double v69; // [rsp+10h] [rbp-118h]
double v70; // [rsp+10h] [rbp-118h]
double v71; // [rsp+18h] [rbp-110h]
double v72; // [rsp+20h] [rbp-108h]
double v73; // [rsp+20h] [rbp-108h]
double v74; // [rsp+28h] [rbp-100h]
double v75; // [rsp+28h] [rbp-100h]
double v76; // [rsp+28h] [rbp-100h]
double v77; // [rsp+30h] [rbp-F8h]
double v78; // [rsp+30h] [rbp-F8h]
double v79; // [rsp+30h] [rbp-F8h]
double v80; // [rsp+38h] [rbp-F0h]
double v81; // [rsp+38h] [rbp-F0h]
double v82; // [rsp+38h] [rbp-F0h]
double v83; // [rsp+40h] [rbp-E8h]
double v84; // [rsp+48h] [rbp-E0h]
double v85; // [rsp+48h] [rbp-E0h]
double v86; // [rsp+50h] [rbp-D8h]
double v87; // [rsp+58h] [rbp-D0h]
double v88; // [rsp+58h] [rbp-D0h]
double cosx; // [rsp+60h] [rbp-C8h] BYREF
double sinx[9]; // [rsp+68h] [rbp-C0h] BYREF
__int64 v91[4]; // [rsp+B0h] [rbp-78h]
__int64 v92[11]; // [rsp+D0h] [rbp-58h]

v5 = 1434962880.0 / cube(6378.135);
if ( v5 < 0.0 )
v72 = sqrt(v5);
else
v72 = sqrt(v5);
v6 = pow(v72 / a3[2], 0.6666666666666666);
sincos(a3[4], sinx, &cosx);
v71 = cosx;
v83 = sinx[0];
v7 = ((double (*)(void))sqr)();
v8 = sqr(v6);
v9 = sqr(a3[5]);
v59 = (v7 * 3.0 - 1.0) * 0.00081196185 / (v8 * pow(1.0 - v9, 1.5));
v10 = 1.0 - v59 * 0.3333333333333333 - sqr(v59);
v60 = v6 * (v10 - sqr(v59) * 1.654320987654321 * v59);
v11 = (1.0 - sqr(a3[5])) * v60;
v84 = (1.0 - a3[5]) * v60;
v87 = a3[6] + a3[7] + a3[8];
v12 = v71 * a3[2] * -0.0016239237;
v64 = v12 / sqr(v11);
v13 = a3[2];
v14 = sqr(v71);
v77 = (v14 * 5.0 - 1.0) * v13 * 0.00081196185 / sqr(v11);
v74 = (a3[9] + a3[9]) * a4 + a3[2];
v80 = 3.0 * a3[10];
v15 = sqr(a4);
v16 = pow(a3[2] / (v15 * v80 + v74), 0.6666666666666666) * v60;
v75 = v16;
if ( v16 <= v84 )
{
v61 = *(double *)&LC0;
v17 = sqr(0.000001);
}
else
{
v61 = 1.0 - v84 / v16;
v17 = sqr(v61);
}
v81 = (1.0 - v17) * v75;
v86 = v64 * a4 + a3[8];
sincos(v77 * a4 + a3[7], sinx, &cosx);
v18 = cosx;
v19 = sinx[0];
v65 = (v77 + a3[2] + v64) * a4 + v87;
v20 = a3[9];
v66 = v20 * sqr(a4) + v65;
v21 = a3[10];
v22 = v61;
v62 = v83 * 0.00000253881 / (v81 * 0.0021652316) + v19 * v61;
v23 = v21 * sqr(a4) * a4 + v66;
v67 = v18 * v22;
v24 = fmod2p(v23 - (v71 * 5.0 + 3.0) * (v18 * v22 * -0.00000253881 * v83) / (v81 * 0.0043304632 * (v71 + 1.0)));
v25 = fmod2p(v24 - v86);
sincos(v25, sinx, &cosx);
xa = (v25 - v62 * cosx + v67 * sinx[0] - v25) / (1.0 - sinx[0] * v62 - cosx * v67) + v25;
v26 = v25;
v27 = 9;
while ( COERCE_DOUBLE(COERCE_UNSIGNED_INT64(xa - v26) & LC17) > 0.000001 )
{
sincos(xa, sinx, &cosx);
v28 = v25 - v62 * cosx;
v29 = (v28 + v67 * sinx[0] - xa) / (1.0 - sinx[0] * v62 - cosx * v67) + xa;
v26 = xa;
if ( !--v27 )
goto LABEL_12;
xa = (v28 + v67 * sinx[0] - xa) / (1.0 - sinx[0] * v62 - cosx * v67) + xa;
}
v29 = xa;
LABEL_12:
sincos(v29, sinx, &cosx);
v30 = cosx;
v31 = sinx[0];
v78 = cosx * v67 + sinx[0] * v62;
v85 = sinx[0] * v67 - cosx * v62;
v32 = sqr(v67);
v88 = 1.0 - (v32 + sqr(v62));
xb = v88 * v75;
v82 = (1.0 - v78) * v75;
if ( v75 < 0.0 )
v33 = sqrt(v75);
else
v33 = sqrt(v75);
v79 = v33 * v72 * v85 / v82;
if ( xb < 0.0 )
v34 = sqrt(xb);
else
v34 = sqrt(xb);
v73 = v34 * v72 / v82;
v35 = v75 / v82;
v76 = v75 / v82;
v36 = v31 - v62;
if ( v88 < 0.0 )
{
v38 = (v36 - v67 * v85 / (sqrt(v88) + 1.0)) * v76;
v68 = v30 - v67;
v39 = v62 * v85;
v37 = sqrt(v88);
}
else
{
v37 = sqrt(v88);
v38 = (v36 - v67 * v85 / (v37 + 1.0)) * v35;
v68 = v30 - v67;
v39 = v62 * v85;
}
v69 = actan(v38, (v39 / (v37 + 1.0) + v68) * v76);
v40 = sqr(v83);
sincos(v69 + v69, sinx, &cosx);
v41 = cosx;
v42 = sinx[0];
v63 = v40 / xb * 0.00027065395 * cosx + v82;
v43 = sqr(v71);
v70 = v69 - (v43 * 7.0 - 1.0) * v42 * 0.000135326975 / sqr(xb);
v44 = sqr(xb);
sincos(v42 * v71 * 0.00081196185 / v44 + v86, sinx, &cosx);
v45 = cosx;
v46 = *(_QWORD *)&sinx[0];
v47 = a3[4];
v48 = sqr(xb);
sincos(v71 * v83 * v41 * 0.00081196185 / v48 + v47, sinx, &cosx);
*(double *)v92 = COERCE_DOUBLE(v46 ^ LC21) * cosx;
*(double *)&v92[1] = cosx * v45;
*(double *)&v92[2] = sinx[0];
*(double *)v91 = v45;
v91[1] = v46;
v91[2] = 0LL;
sincos(v70, sinx, &cosx);
v49 = cosx;
v50 = sinx[0];
for ( i = 0LL; i != 3; ++i )
{
v52 = *(double *)&v92[i];
v53 = *(double *)&v91[i];
sinx[i + 5] = v52 * v50 + v53 * v49;
sinx[i + 1] = v52 * v49 - v53 * v50;
}
for ( result = 0LL; result != 3; ++result )
{
v55 = sinx[result + 5];
*(double *)(a1 + result * 8) = v63 * v55;
*(double *)(a2 + result * 8) = v55 * v79 + v73 * sinx[result + 1];
}
return result * 8;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, double *a3, double a4)
{
double v5; // xmm0_8
double v6; // r15
double v7; // r13
double v8; // r14
double v9; // xmm0_8
double v10; // r13
double v11; // r14
double v12; // r13
double v13; // r15
double v14; // r13
double v15; // xmm0_8
double v16; // xmm5_8
double v17; // xmm0_8
double v18; // r13
double v19; // r14
double v20; // r15
double v21; // r15
double v22; // xmm3_8
double v23; // xmm0_8
double v24; // xmm0_8
double v25; // r14
double v26; // xmm1_8
int v27; // er13
double v28; // xmm4_8
double v29; // xmm0_8
double v30; // r13
double v31; // r14
double v32; // r15
double v33; // xmm0_8
double v34; // xmm0_8
double v35; // xmm4_8
double v36; // r14
double v37; // xmm0_8
double v38; // r14
double v39; // r13
double v40; // r13
double v41; // r15
double v42; // r14
double v43; // r13
double v44; // xmm0_8
double v45; // r14
__int64 v46; // r13
double v47; // rbx
double v48; // xmm0_8
double v49; // xmm4_8
double v50; // xmm3_8
__int64 i; // rax
double v52; // xmm0_8
double v53; // xmm1_8
__int64 result; // rax
double v55; // xmm0_8
double xa; // [rsp+0h] [rbp-128h]
double xb; // [rsp+0h] [rbp-128h]
double v59; // [rsp+8h] [rbp-120h]
double v60; // [rsp+8h] [rbp-120h]
double v61; // [rsp+8h] [rbp-120h]
double v62; // [rsp+8h] [rbp-120h]
double v63; // [rsp+8h] [rbp-120h]
double v64; // [rsp+10h] [rbp-118h]
double v65; // [rsp+10h] [rbp-118h]
double v66; // [rsp+10h] [rbp-118h]
double v67; // [rsp+10h] [rbp-118h]
double v68; // [rsp+10h] [rbp-118h]
double v69; // [rsp+10h] [rbp-118h]
double v70; // [rsp+10h] [rbp-118h]
double v71; // [rsp+18h] [rbp-110h]
double v72; // [rsp+20h] [rbp-108h]
double v73; // [rsp+20h] [rbp-108h]
double v74; // [rsp+28h] [rbp-100h]
double v75; // [rsp+28h] [rbp-100h]
double v76; // [rsp+28h] [rbp-100h]
double v77; // [rsp+30h] [rbp-F8h]
double v78; // [rsp+30h] [rbp-F8h]
double v79; // [rsp+30h] [rbp-F8h]
double v80; // [rsp+38h] [rbp-F0h]
double v81; // [rsp+38h] [rbp-F0h]
double v82; // [rsp+38h] [rbp-F0h]
double v83; // [rsp+40h] [rbp-E8h]
double v84; // [rsp+48h] [rbp-E0h]
double v85; // [rsp+48h] [rbp-E0h]
double v86; // [rsp+50h] [rbp-D8h]
double v87; // [rsp+58h] [rbp-D0h]
double v88; // [rsp+58h] [rbp-D0h]
double cosx; // [rsp+60h] [rbp-C8h] BYREF
double sinx[9]; // [rsp+68h] [rbp-C0h] BYREF
__int64 v91[4]; // [rsp+B0h] [rbp-78h]
__int64 v92[11]; // [rsp+D0h] [rbp-58h]

v5 = 1434962880.0 / cube(6378.135);
if ( v5 < 0.0 )
v72 = sqrt(v5);
else
v72 = sqrt(v5);
v6 = pow(v72 / a3[2], 0.6666666666666666);
sincos(a3[4], sinx, &cosx);
v71 = cosx;
v83 = sinx[0];
v7 = ((double (*)(void))sqr)();
v8 = sqr(v6);
v9 = sqr(a3[5]);
v59 = (v7 * 3.0 - 1.0) * 0.00081196185 / (v8 * pow(1.0 - v9, 1.5));
v10 = 1.0 - v59 * 0.3333333333333333 - sqr(v59);
v60 = v6 * (v10 - sqr(v59) * 1.654320987654321 * v59);
v11 = (1.0 - sqr(a3[5])) * v60;
v84 = (1.0 - a3[5]) * v60;
v87 = a3[6] + a3[7] + a3[8];
v12 = v71 * a3[2] * -0.0016239237;
v64 = v12 / sqr(v11);
v13 = a3[2];
v14 = sqr(v71);
v77 = (v14 * 5.0 - 1.0) * v13 * 0.00081196185 / sqr(v11);
v74 = (a3[9] + a3[9]) * a4 + a3[2];
v80 = 3.0 * a3[10];
v15 = sqr(a4);
v16 = pow(a3[2] / (v15 * v80 + v74), 0.6666666666666666) * v60;
v75 = v16;
if ( v16 <= v84 )
{
v61 = *(double *)&LC0;
v17 = sqr(0.000001);
}
else
{
v61 = 1.0 - v84 / v16;
v17 = sqr(v61);
}
v81 = (1.0 - v17) * v75;
v86 = v64 * a4 + a3[8];
sincos(v77 * a4 + a3[7], sinx, &cosx);
v18 = cosx;
v19 = sinx[0];
v65 = (v77 + a3[2] + v64) * a4 + v87;
v20 = a3[9];
v66 = v20 * sqr(a4) + v65;
v21 = a3[10];
v22 = v61;
v62 = v83 * 0.00000253881 / (v81 * 0.0021652316) + v19 * v61;
v23 = v21 * sqr(a4) * a4 + v66;
v67 = v18 * v22;
v24 = fmod2p(v23 - (v71 * 5.0 + 3.0) * (v18 * v22 * -0.00000253881 * v83) / (v81 * 0.0043304632 * (v71 + 1.0)));
v25 = fmod2p(v24 - v86);
sincos(v25, sinx, &cosx);
xa = (v25 - v62 * cosx + v67 * sinx[0] - v25) / (1.0 - sinx[0] * v62 - cosx * v67) + v25;
v26 = v25;
v27 = 9;
while ( COERCE_DOUBLE(COERCE_UNSIGNED_INT64(xa - v26) & LC17) > 0.000001 )
{
sincos(xa, sinx, &cosx);
v28 = v25 - v62 * cosx;
v29 = (v28 + v67 * sinx[0] - xa) / (1.0 - sinx[0] * v62 - cosx * v67) + xa;
v26 = xa;
if ( !--v27 )
goto LABEL_12;
xa = (v28 + v67 * sinx[0] - xa) / (1.0 - sinx[0] * v62 - cosx * v67) + xa;
}
v29 = xa;
LABEL_12:
sincos(v29, sinx, &cosx);
v30 = cosx;
v31 = sinx[0];
v78 = cosx * v67 + sinx[0] * v62;
v85 = sinx[0] * v67 - cosx * v62;
v32 = sqr(v67);
v88 = 1.0 - (v32 + sqr(v62));
xb = v88 * v75;
v82 = (1.0 - v78) * v75;
if ( v75 < 0.0 )
v33 = sqrt(v75);
else
v33 = sqrt(v75);
v79 = v33 * v72 * v85 / v82;
if ( xb < 0.0 )
v34 = sqrt(xb);
else
v34 = sqrt(xb);
v73 = v34 * v72 / v82;
v35 = v75 / v82;
v76 = v75 / v82;
v36 = v31 - v62;
if ( v88 < 0.0 )
{
v38 = (v36 - v67 * v85 / (sqrt(v88) + 1.0)) * v76;
v68 = v30 - v67;
v39 = v62 * v85;
v37 = sqrt(v88);
}
else
{
v37 = sqrt(v88);
v38 = (v36 - v67 * v85 / (v37 + 1.0)) * v35;
v68 = v30 - v67;
v39 = v62 * v85;
}
v69 = actan(v38, (v39 / (v37 + 1.0) + v68) * v76);
v40 = sqr(v83);
sincos(v69 + v69, sinx, &cosx);
v41 = cosx;
v42 = sinx[0];
v63 = v40 / xb * 0.00027065395 * cosx + v82;
v43 = sqr(v71);
v70 = v69 - (v43 * 7.0 - 1.0) * v42 * 0.000135326975 / sqr(xb);
v44 = sqr(xb);
sincos(v42 * v71 * 0.00081196185 / v44 + v86, sinx, &cosx);
v45 = cosx;
v46 = *(_QWORD *)&sinx[0];
v47 = a3[4];
v48 = sqr(xb);
sincos(v71 * v83 * v41 * 0.00081196185 / v48 + v47, sinx, &cosx);
*(double *)v92 = COERCE_DOUBLE(v46 ^ LC21) * cosx;
*(double *)&v92[1] = cosx * v45;
*(double *)&v92[2] = sinx[0];
*(double *)v91 = v45;
v91[1] = v46;
v91[2] = 0LL;
sincos(v70, sinx, &cosx);
v49 = cosx;
v50 = sinx[0];
for ( i = 0LL; i != 3; ++i )
{
v52 = *(double *)&v92[i];
v53 = *(double *)&v91[i];
sinx[i + 5] = v52 * v50 + v53 * v49;
sinx[i + 1] = v52 * v49 - v53 * v50;
}
for ( result = 0LL; result != 3; ++result )
{
v55 = sinx[result + 5];
*(double *)(a1 + result * 8) = v63 * v55;
*(double *)(a2 + result * 8) = v55 * v79 + v73 * sinx[result + 1];
}
return result * 8;
}

original_code:
void sgp0 (double tsince, struct vector *pos, struct vector *vel, struct sgp_data *satdata)
{
 double a1=0, cosio=0, sinio=0, sigma1=0, a0=0, p0=0;
 double q0=0, L0=0, xnodedt=0, domegadt=0, temp=0, a=0;
 double e=0, p=0, xnodeso=0, omegaso=0, Ls=0, Aynsl=0;
 double Axnsl=0, L=0, u=0, deltaEw=0, temp2=0, temp3=0;
 double Ew=0, ecose=0, esine=0, elsqr=0, pl=0, r=0;
 double rdot=0, rvdot=0, sinu=0, cosu=0, ik=0, rk=0;
 double uk=0, xnodek=0, xke=0;
 int i;
 struct vector MV, NV, UV, VV;
 xke = sqrt(((3600.0 * 398600.8) / cube(6378.135)));
 temp2 = xke / (satdata->xno);
 a1 = pow (temp2 , (2.0/3.0));
 cosio = cos (satdata->xincl);
 sinio = sin (satdata->xincl);
 sigma1 = 1.5 * (1.0826158E-3 / 2.0) * ( 3.0 * (sqr(cosio) ) - 1.0 ) / (sqr(a1) * pow( 1.0 - sqr(satdata->eo) , 1.5));
 a0 = a1 * (1.0 - (1.0 / 3.0) * sigma1 - sqr( sigma1 )- ( 134.0 / 81.0 ) * sqr(sigma1) * sigma1);
 p0 = a0 * (1.0 - sqr(satdata->eo));
 q0 = a0 * (1.0 - (satdata->eo));
 L0 = (satdata->xmo) + (satdata->omegao) + (satdata->xnodeo);
 xnodedt = -3.0 * ((1.0826158E-3 / 2.0)) * ((satdata->xno) * cosio ) / (sqr(p0));
 domegadt = 1.5 * (1.0826158E-3 / 2.0) * ( (satdata->xno) * (5.0 * sqr(cosio) - 1.0)) / (sqr(p0));
 temp = (satdata->xno) + 2.0 * (satdata->xndt2o) * tsince + 3.0 * (satdata->xndd6o) * sqr(tsince);
 temp = (satdata->xno)/temp;
 a = a0 * pow(temp , (2.0/3.0));
 if (a > q0)
  e = (1.0 - (q0 / a));
 else
  e = 1.0E-6;
 p = a * ( 1.0 - sqr(e) );
 xnodeso = (satdata->xnodeo) + xnodedt * tsince;
 omegaso = (satdata->omegao) + domegadt * tsince;
 Ls = L0 + ((satdata->xno) + domegadt + xnodedt) * tsince + (satdata->xndt2o) * sqr(tsince) + (satdata->xndd6o) * sqr(tsince) * tsince;
 Aynsl = e * sin(omegaso) - (-2.53881E-6 * sinio) / (4.0 * (1.0826158E-3 / 2.0) * p);
 Axnsl = e * cos(omegaso);
 temp2 = (-2.53881E-6 * Axnsl * sinio * (3.0 + 5.0 * cosio));
 temp3 = 8.0 * (1.0826158E-3 / 2.0) * p * (1.0 + cosio);
 temp = Ls - temp2 / temp3;
 L = fmod2p( temp );
 u = fmod2p(L - xnodeso);
 temp = u;
 i = 1;
 do {
  temp2 = u - Aynsl * cos(temp) + Axnsl * sin(temp) - temp;
  temp3 = 1.0 - Aynsl * sin(temp) - Axnsl * cos(temp);
  deltaEw = temp2 / temp3;
  Ew = deltaEw + temp;
  temp2 = temp;
  temp = Ew;
  i++;
        } while ((i<=10) && (fabs(Ew-temp2) > 1.0E-6));
 ecose = Axnsl * cos(Ew) + Aynsl * sin(Ew);
 esine = Axnsl * sin(Ew) - Aynsl * cos(Ew);
 elsqr = sqr(Axnsl) + sqr(Aynsl);
 pl = a * (1.0 - elsqr);
 r = a * (1.0 - ecose);
 rdot = xke * sqrt(a)* esine/r;
 rvdot = xke * sqrt(pl)/r;
 sinu = (a / r) * (sin(Ew) - Aynsl - ( (Axnsl*esine) / (1.0 + sqrt(1.0 - elsqr))));
 cosu = (a / r) * (cos(Ew) - Axnsl + ( (Aynsl*esine) / (1.0 + sqrt(1.0 - elsqr))));
 u = actan (sinu, cosu);
 rk = r + (1.0/2.0) * (1.0826158E-3 / 2.0) * (sqr(sinio)/pl) * cos(2.0 * u);
 uk = u - (1.0/4.0) * (1.0826158E-3 / 2.0) * (sin(2.0*u) * (7.0 * sqr(cosio) - 1.0)) / sqr(pl);
 xnodek = xnodeso + 1.5 * (1.0826158E-3 / 2.0) * (cosio * sin(2.0 * u)) / sqr(pl);
 ik = (satdata->xincl) + 1.5 * (1.0826158E-3 / 2.0) * (sinio * cosio * cos(2.0 * u)) / sqr(pl);
 MV.v[0] = -sin( xnodek ) * cos(ik);
 MV.v[1] = cos( xnodek ) * cos(ik);
 MV.v[2] = sin( ik );
 NV.v[0] = cos( xnodek );
 NV.v[1] = sin( xnodek );
 NV.v[2] = 0;
 for (i=0;(i<3);i++)
 {
  UV.v[i] = MV.v[i] * sin(uk) + NV.v[i] * cos(uk);
  VV.v[i] = MV.v[i] * cos(uk) - NV.v[i] * sin(uk);
        }
 for (i=0;(i<3);i++)
 {
  pos->v[i] = rk * UV.v[i];
  vel->v[i] = rdot * UV.v[i] + rvdot * VV.v[i];
        }
}

canonical_original_code:
void sgp0(double tsince, struct vector *pos, struct vector *vel, struct sgp_data *satdata)
{
 double a1 = 0; double cosio = 0; double sinio = 0; double sigma1 = 0; double a0 = 0; double p0 = 0;
 double q0 = 0; double L0 = 0; double xnodedt = 0; double domegadt = 0; double temp = 0; double a = 0;
 double e = 0; double p = 0; double xnodeso = 0; double omegaso = 0; double Ls = 0; double Aynsl = 0;
 double Axnsl = 0; double L = 0; double u = 0; double deltaEw = 0; double temp2 = 0; double temp3 = 0;
 double Ew = 0; double ecose = 0; double esine = 0; double elsqr = 0; double pl = 0; double r = 0;
 double rdot = 0; double rvdot = 0; double sinu = 0; double cosu = 0; double ik = 0; double rk = 0;
 double uk = 0; double xnodek = 0; double xke = 0;
 int i;
 struct vector MV; struct vector NV; struct vector UV; struct vector VV;
 xke = sqrt(((3600.0 * 398600.8) / cube(6378.135)));
 temp2 = xke / (satdata->xno);
 a1 = pow (temp2 , (2.0/3.0));
 cosio = cos (satdata->xincl);
 sinio = sin (satdata->xincl);
 sigma1 = 1.5 * (1.0826158E-3 / 2.0) * ( 3.0 * (sqr(cosio) ) - 1.0 ) / (sqr(a1) * pow( 1.0 - sqr(satdata->eo) , 1.5));
 a0 = a1 * (1.0 - (1.0 / 3.0) * sigma1 - sqr( sigma1 )- ( 134.0 / 81.0 ) * sqr(sigma1) * sigma1);
 p0 = a0 * (1.0 - sqr(satdata->eo));
 q0 = a0 * (1.0 - (satdata->eo));
 L0 = (satdata->xmo) + (satdata->omegao) + (satdata->xnodeo);
 xnodedt = -3.0 * ((1.0826158E-3 / 2.0)) * ((satdata->xno) * cosio ) / (sqr(p0));
 domegadt = 1.5 * (1.0826158E-3 / 2.0) * ( (satdata->xno) * (5.0 * sqr(cosio) - 1.0)) / (sqr(p0));
 temp = (satdata->xno) + 2.0 * (satdata->xndt2o) * tsince + 3.0 * (satdata->xndd6o) * sqr(tsince);
 temp = (satdata->xno)/temp;
 a = a0 * pow(temp , (2.0/3.0));
 if (a > q0)
  e = (1.0 - (q0 / a));
 else
  e = 1.0E-6;
 p = a * ( 1.0 - sqr(e) );
 xnodeso = (satdata->xnodeo) + xnodedt * tsince;
 omegaso = (satdata->omegao) + domegadt * tsince;
 Ls = L0 + ((satdata->xno) + domegadt + xnodedt) * tsince + (satdata->xndt2o) * sqr(tsince) + (satdata->xndd6o) * sqr(tsince) * tsince;
 Aynsl = e * sin(omegaso) - (-2.53881E-6 * sinio) / (4.0 * (1.0826158E-3 / 2.0) * p);
 Axnsl = e * cos(omegaso);
 temp2 = (-2.53881E-6 * Axnsl * sinio * (3.0 + 5.0 * cosio));
 temp3 = 8.0 * (1.0826158E-3 / 2.0) * p * (1.0 + cosio);
 temp = Ls - temp2 / temp3;
 L = fmod2p( temp );
 u = fmod2p(L - xnodeso);
 temp = u;
 i = 1;
 do {
  temp2 = u - Aynsl * cos(temp) + Axnsl * sin(temp) - temp;
  temp3 = 1.0 - Aynsl * sin(temp) - Axnsl * cos(temp);
  deltaEw = temp2 / temp3;
  Ew = deltaEw + temp;
  temp2 = temp;
  temp = Ew;
  i++;
        } while ((i<=10) && (fabs(Ew-temp2) > 1.0E-6));
 ecose = Axnsl * cos(Ew) + Aynsl * sin(Ew);
 esine = Axnsl * sin(Ew) - Aynsl * cos(Ew);
 elsqr = sqr(Axnsl) + sqr(Aynsl);
 pl = a * (1.0 - elsqr);
 r = a * (1.0 - ecose);
 rdot = xke * sqrt(a)* esine/r;
 rvdot = xke * sqrt(pl)/r;
 sinu = (a / r) * (sin(Ew) - Aynsl - ( (Axnsl*esine) / (1.0 + sqrt(1.0 - elsqr))));
 cosu = (a / r) * (cos(Ew) - Axnsl + ( (Aynsl*esine) / (1.0 + sqrt(1.0 - elsqr))));
 u = actan (sinu, cosu);
 rk = r + (1.0/2.0) * (1.0826158E-3 / 2.0) * (sqr(sinio)/pl) * cos(2.0 * u);
 uk = u - (1.0/4.0) * (1.0826158E-3 / 2.0) * (sin(2.0*u) * (7.0 * sqr(cosio) - 1.0)) / sqr(pl);
 xnodek = xnodeso + 1.5 * (1.0826158E-3 / 2.0) * (cosio * sin(2.0 * u)) / sqr(pl);
 ik = (satdata->xincl) + 1.5 * (1.0826158E-3 / 2.0) * (sinio * cosio * cos(2.0 * u)) / sqr(pl);
 MV.v[0] = -sin( xnodek ) * cos(ik);
 MV.v[1] = cos( xnodek ) * cos(ik);
 MV.v[2] = sin( ik );
 NV.v[0] = cos( xnodek );
 NV.v[1] = sin( xnodek );
 NV.v[2] = 0;
 for (i=0;(i<3);i++)
 {
  UV.v[i] = MV.v[i] * sin(uk) + NV.v[i] * cos(uk);
  VV.v[i] = MV.v[i] * cos(uk) - NV.v[i] * sin(uk);
        }
 for (i=0;(i<3);i++)
 {
  pos->v[i] = rk * UV.v[i];
  vel->v[i] = rdot * UV.v[i] + rvdot * VV.v[i];
        }
}

variable_types: tsince double

variable_types: cosio double

variable_types: sinio double

variable_types: xnodedt double

variable_types: domegadt double

variable_types: a double

variable_types: e double

variable_types: p double

variable_types: xnodeso double

variable_types: omegaso double

variable_types: Ls double

variable_types: Aynsl double

variable_types: Axnsl double

variable_types: L double

variable_types: u double

variable_types: deltaEw double

variable_types: Ew double

variable_types: ecose double

variable_types: esine double

variable_types: elsqr double

variable_types: pl double

variable_types: r double

variable_types: rdot double

variable_types: rvdot double

variable_types: sinu double

variable_types: cosu double

variable_types: ik double

variable_types: rk double

variable_types: uk double

variable_types: xnodek double

variable_types: i int

variable_types:
MV
struct vector { double v[4]; }

variable_types:
NV
struct vector { double v[4]; }

variable_types:
UV
struct vector { double v[4]; }

variable_types:
VV
struct vector { double v[4]; }

user_defined_types: struct sgp_data { double epoch; double julian_epoch; double xno; double bstar; double xincl; double eo; double xmo; double omegao; double xnodeo; double xndt2o; double xndd6o; char catnr[5]; char elset[3]; int ideep; }


decompiled_code:
__int64 __fastcall sgp0call(__int64 a1, __int64 a2, double *a3, double a4)
{
return sgp0(a1, a2, a3, (a4 - a3[1]) * 1440.0);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, double *a3, double a4)
{
return func0(a1, a2, a3, (a4 - a3[1]) * 1440.0);
}

original_code:
void sgp0call (double time, struct vector *pos, struct vector *vel, struct sgp_data *satdata)
{
 double tsince;
 tsince = ( time - (satdata->julian_epoch) ) * 1440.0;
 sgp0 (tsince, pos, vel, satdata);
}

canonical_original_code:
void sgp0call(double time, struct vector *pos, struct vector *vel, struct sgp_data *satdata)
{
 double tsince;
 tsince = ( time - (satdata->julian_epoch) ) * 1440.0;
 sgp0 (tsince, pos, vel, satdata);
}

variable_types: time double

variable_types:
pos
struct vector { double v[4]; } *

variable_types:
vel
struct vector *

variable_types: struct sgp_data { double epoch; double julian_epoch; double xno; double bstar; double xincl; double eo; double xmo; double omegao; double xnodeo; double xndt2o; double xndd6o; char catnr[5]; char elset[3]; int ideep; } *

variable_types: tsince double


original_code:
double Julian_Date_of_Year(double year)
{
 double A, B, JDoY;
 year = year - 1.0;
 A = floor(year / 100.0);
 B = 2.0 - A + floor(A / 4.0);
 JDoY = floor(365.25 * year) + floor(30.6001 * 14.0) + 1720994.5 + B;
 return JDoY;
}

canonical_original_code:
double Julian_Date_of_Year(double year)
{
 double A; double B; double JDoY;
 year = year - 1.0;
 A = floor(year / 100.0);
 B = 2.0 - A + floor(A / 4.0);
 JDoY = floor(365.25 * year) + floor(30.6001 * 14.0) + 1720994.5 + B;
 return JDoY;
}

variable_types: year double

variable_types: A double

variable_types: B double

variable_types: JDoY double

return_type: double


original_code:
double Julian_Date_of_Epoch(double epoch)
{
 double year, day, JDoE;
 year = floor(epoch*1.0E-3);
 if (year < 57)
  year += 2000;
 else
  year += 1900;
 day = epoch - (floor(epoch*1.0E-3))*1.0E3;
 JDoE = Julian_Date_of_Year(year) + day;
 return JDoE;
}

canonical_original_code:
double Julian_Date_of_Epoch(double epoch)
{
 double year; double day; double JDoE;
 year = floor(epoch*1.0E-3);
 if (year < 57)
  year += 2000;
 else
  year += 1900;
 day = epoch - (floor(epoch*1.0E-3))*1.0E3;
 JDoE = Julian_Date_of_Year(year) + day;
 return JDoE;
}

variable_types: epoch double

variable_types: day double

variable_types: JDoE double


ThetaG

canonical_original_code:
double ThetaG(double epoch, double *ds50)
{
 double year; double day; double UT; double jd; double TU; double GMST; double TG;
 year = floor(epoch*1.0E-3);
 if (year < 57)
  year = year + 2000;
 else
  year = year + 1900;
 day = epoch - (floor(epoch*1.0E-3))*1.0E3;
 UT = day - floor(day);
 day = floor(day);
 jd = Julian_Date_of_Year(year) + day;
 TU = (jd - 2451545.0)/36525;
 GMST = 24110.54841 + TU * (8640184.812866 + TU * (0.093104 - TU * 6.2E-6));
 GMST = modulus(GMST + 86400.0 * 1.00273790934 * UT , 86400.0);
 TG = 2.0 * 3.1415926535897932384626433279 * GMST / 86400.0;
 *ds50 = jd - 2433281.5 + UT;
 return TG;
}

variable_types: UT double

variable_types: jd double

variable_types: TU double

variable_types: GMST double

variable_types: TG double


original_code:
void sgp_test (void)
{
 struct vector pos[5], vel[5];
 struct sgp_data satdata;
 char l1[2][24];
 char l2[2][70];
 char l3[2][70];
 int satnumber=0, interval, j;
 double delta, tsince;
 struct tle_ascii sat_data[2];
 char c;
 sat_data[0].l[0] = l1[0];
 sat_data[0].l[1] = l2[0];
 sat_data[0].l[2] = l3[0];
 sat_data[1].l[0] = l1[1];
 sat_data[1].l[1] = l2[2];
 sat_data[1].l[2] = l3[3];
 gettestdata(&sat_data[0],&sat_data[1]);
 delta = 360.0;
 for (j=0;(j<5);j++)
 {
  int model=0;
  printf("\n\n\n");
  switch (j)
  {
  case 0 :
   model = 0;
   printf("*** SGP0 ***\n\n");
   satnumber = 0;
   break;
  case 1 :
   model = 1;
   printf("*** SGP4 ***\n\n");
   satnumber = 0;
   break;
  case 2 :
   model = 2;
   printf("*** SDP4 ***\n\n");
   satnumber = 1;
   break;
  case 3 :
   model = 3;
   printf("*** SGP8 ***\n\n");
   satnumber = 0;
   break;
  case 4 :
   model = 4;
   printf("*** SDP8 ***\n\n");
   satnumber = 1;
   break;
  }
  printf("%s",sat_data[satnumber].l[1]);
  printf("%s",sat_data[satnumber].l[2]);
  printf("\n");
  printf("\n");
  Convert_Satellite_Data(sat_data[satnumber],&satdata);
  for (interval=0;(interval<=4);interval++)
  {
   tsince = interval * delta;
   switch (model)
   {
   case 0:
    sgp0(tsince,&pos[interval],&vel[interval],&satdata);
    break;
   case 1:
    sgp4(tsince,&pos[interval],&vel[interval],&satdata);
    break;
   case 2:
    sdp4(tsince,&pos[interval],&vel[interval],&satdata);
    break;
   case 3:
    sgp8(tsince,&pos[interval],&vel[interval],&satdata);
    break;
   case 4:
    sdp8(tsince,&pos[interval],&vel[interval],&satdata);
    break;
   }
   Convert_Sat_State(&pos[interval],&vel[interval]);
   pos[interval].v[3]=tsince;
  }
  printf("  TSINCE           X                  Y                  Z \n");
  for (interval=0;(interval<=4);interval++)
   printf(" % 7.1f    % 15.8f    % 15.8f    % 15.8f \n", pos[interval].v[3], pos[interval].v[0],pos[interval].v[1],pos[interval].v[2]);
  printf("\n\n\n                   XDOT               YDOT             ZDOT \n");
  for (interval=0;(interval<=4);interval++)
   printf("             % 13.8f      % 13.8f     % 13.8f \n",vel[interval].v[0],vel[interval].v[1],vel[interval].v[2]);
  printf("\n");
  fflush(stdin);
  c=getchar();
 }
}

canonical_original_code:
void sgp_test()
{
 struct vector pos[5]; struct vector vel[5];
 struct sgp_data satdata;
 char l1[2][24];
 char l2[2][70];
 char l3[2][70];
 int satnumber = 0; int interval; int j;
 double delta; double tsince;
 struct tle_ascii sat_data[2];
 char c;
 sat_data[0].l[0] = l1[0];
 sat_data[0].l[1] = l2[0];
 sat_data[0].l[2] = l3[0];
 sat_data[1].l[0] = l1[1];
 sat_data[1].l[1] = l2[2];
 sat_data[1].l[2] = l3[3];
 gettestdata(&sat_data[0],&sat_data[1]);
 delta = 360.0;
 for (j=0;(j<5);j++)
 {
  int model = 0;
  printf("\n\n\n");
  switch (j)
  {
  case 0 :
   model = 0;
   printf("*** SGP0 ***\n\n");
   satnumber = 0;
   break;
  case 1 :
   model = 1;
   printf("*** SGP4 ***\n\n");
   satnumber = 0;
   break;
  case 2 :
   model = 2;
   printf("*** SDP4 ***\n\n");
   satnumber = 1;
   break;
  case 3 :
   model = 3;
   printf("*** SGP8 ***\n\n");
   satnumber = 0;
   break;
  case 4 :
   model = 4;
   printf("*** SDP8 ***\n\n");
   satnumber = 1;
   break;
  }
  printf("%s",sat_data[satnumber].l[1]);
  printf("%s",sat_data[satnumber].l[2]);
  printf("\n");
  printf("\n");
  Convert_Satellite_Data(sat_data[satnumber],&satdata);
  for (interval=0;(interval<=4);interval++)
  {
   tsince = interval * delta;
   switch (model)
   {
   case 0:
    sgp0(tsince,&pos[interval],&vel[interval],&satdata);
    break;
   case 1:
    sgp4(tsince,&pos[interval],&vel[interval],&satdata);
    break;
   case 2:
    sdp4(tsince,&pos[interval],&vel[interval],&satdata);
    break;
   case 3:
    sgp8(tsince,&pos[interval],&vel[interval],&satdata);
    break;
   case 4:
    sdp8(tsince,&pos[interval],&vel[interval],&satdata);
    break;
   }
   Convert_Sat_State(&pos[interval],&vel[interval]);
   pos[interval].v[3]=tsince;
  }
  printf("  TSINCE           X                  Y                  Z \n");
  for (interval=0;(interval<=4);interval++)
   printf(" % 7.1f    % 15.8f    % 15.8f    % 15.8f \n", pos[interval].v[3], pos[interval].v[0],pos[interval].v[1],pos[interval].v[2]);
  printf("\n\n\n                   XDOT               YDOT             ZDOT \n");
  for (interval=0;(interval<=4);interval++)
   printf("             % 13.8f      % 13.8f     % 13.8f \n",vel[interval].v[0],vel[interval].v[1],vel[interval].v[2]);
  printf("\n");
  fflush(stdin);
  c=getchar();
 }
}

variable_types:
pos
struct vector { double v[4]; } [5]

variable_types:
vel
struct vector { double v[4]; } [5]

variable_types: struct sgp_data { double epoch; double julian_epoch; double xno; double bstar; double xincl; double eo; double xmo; double omegao; double xnodeo; double xndt2o; double xndd6o; char catnr[5]; char elset[3]; int ideep; }

variable_types: satnumber int

variable_types: interval int

variable_types: j int

variable_types: delta double

variable_types: c char

variable_types: model int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
sgp_test(argc, argv, envp);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
func1(argc, argv, envp);
return 0;
}

original_code:
int main (void)
{
 sgp_test();
        return 0;
}

canonical_original_code:
int main()
{
 sgp_test();
        return 0;
}


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int i; // ebx
unsigned __int8 v4; // al

for ( i = 0; i != 16; ++i )
{
v4 = SSEG_CreateDigit(i, &map, 1);
printDigit(i, v4);
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int i; // ebx
unsigned __int8 v4; // al

for ( i = 0; i != 16; ++i )
{
v4 = func15(i, &map, 1);
func16(i, v4);
}
return 0;
}


decompiled_code:
__int64 __fastcall enter_coin(_QWORD *a1, int a2)
{
_DWORD *v3; // rbp
int v4; // er15
int v5; // er14
int v6; // er13
int v7; // er12
int v8; // eax
int v10; // [rsp+8h] [rbp-50h]
int v11; // [rsp+Ch] [rbp-4Ch]
char v12; // [rsp+1Ch] [rbp-3Ch]
char nptr[59]; // [rsp+1Dh] [rbp-3Bh] BYREF

v3 = (_DWORD *)*a1;
v11 = 0;
v10 = 0;
v4 = 0;
v5 = 0;
v6 = 0;
v7 = 0;
do
{
printf("Enter a coin ($%.2f remaining): ", (float)((float)a2 / 100.0));
fgets(nptr, 5, stdin);
if ( *(&v12 + strlen(nptr)) == 10 )
{
if ( !strcmp(nptr, "\n") )
return 0xFFFFFFFFLL;
}
else
{
puts("Error: Input was too long! Try again.");
}
v8 = atoi(nptr);
switch ( v8 )
{
case 5:
++v7;
goto LABEL_11;
case 10:
++v6;
goto LABEL_11;
case 20:
++v5;
++v3[5];
goto LABEL_11;
case 50:
++v4;
goto LABEL_11;
case 100:
++v10;
goto LABEL_11;
case 200:
++v11;
LABEL_11:
a2 -= v8;
continue;
}
puts("Error: Invalid coin entered! Please try again.");
}
while ( a2 > 0 );
v3[1] += v7;
v3[3] += v6;
v3[5] += v5;
v3[7] += v4;
v3[9] += v10;
v3[11] += v11;
return (unsigned int)a2;
}

canonical_decompiled_code:
__int64 __fastcall func0(_QWORD *a1, int a2)
{
_DWORD *v3; // rbp
int v4; // er15
int v5; // er14
int v6; // er13
int v7; // er12
int v8; // eax
int v10; // [rsp+8h] [rbp-50h]
int v11; // [rsp+Ch] [rbp-4Ch]
char v12; // [rsp+1Ch] [rbp-3Ch]
char nptr[59]; // [rsp+1Dh] [rbp-3Bh] BYREF

v3 = (_DWORD *)*a1;
v11 = 0;
v10 = 0;
v4 = 0;
v5 = 0;
v6 = 0;
v7 = 0;
do
{
printf("Enter a coin ($%.2f remaining): ", (float)((float)a2 / 100.0));
fgets(nptr, 5, stdin);
if ( *(&v12 + strlen(nptr)) == 10 )
{
if ( !strcmp(nptr, "\n") )
return 0xFFFFFFFFLL;
}
else
{
puts("Error: Input was too long! Try again.");
}
v8 = atoi(nptr);
switch ( v8 )
{
case 5:
++v7;
goto LABEL_11;
case 10:
++v6;
goto LABEL_11;
case 20:
++v5;
++v3[5];
goto LABEL_11;
case 50:
++v4;
goto LABEL_11;
case 100:
++v10;
goto LABEL_11;
case 200:
++v11;
LABEL_11:
a2 -= v8;
continue;
}
puts("Error: Invalid coin entered! Please try again.");
}
while ( a2 > 0 );
v3[1] += v7;
v3[3] += v6;
v3[5] += v5;
v3[7] += v4;
v3[9] += v10;
v3[11] += v11;
return (unsigned int)a2;
}

original_code:
int enter_coin(tm_type_ptr tm, int price){
 char charinput[3];
 int input = 0;
 BOOLEAN success = FALSE;
 struct coin *listptr;
 int fivecent = 0, tencent = 0, twentycent = 0, fiftycent = 0, one = 0, two = 0, negprice = 0;
 listptr = tm->coins;
 do{
  printf("Enter a coin ($%.2f remaining): ",(float)price / 100);
  fgets(charinput, 3 + 2, stdin);
   if(charinput[strlen(charinput) -1] !='\n'){
                printf("Error: Input was too long! Try again.\n");
            }
    else if (strcmp(charinput, "\n") == 0){
     fivecent = 0;
     tencent = 0;
     twentycent = 0;
     fiftycent = 0;
     one = 0;
     two = 0;
                    return -1;
            }
   input = atoi(charinput);
   if (input == 5){
    fivecent++;
    success = TRUE;
   }
   else if (input == 10){
    tencent++;
    success = TRUE;
   }
   else if (input == 20){
    twentycent++;
    listptr[2].count++;
    success = TRUE;
   }
   else if (input == 50){
    fiftycent++;
    success = TRUE;
   }
   else if (input == 100){
    one++;
    success = TRUE;
   }
   else if (input == 200){
    two++;
    success = TRUE;
   }
   else{
    printf("Error: Invalid coin entered! Please try again.\n");
   }
   if (success == TRUE){
   price -= input;
   success = FALSE;
   }
 }
 while(price > 0);
 listptr[0].count += fivecent;
 listptr[1].count += tencent;
 listptr[2].count += twentycent;
 listptr[3].count += fiftycent;
 listptr[4].count += one;
 listptr[5].count += two;
 negprice = price;
 return negprice;
}

canonical_original_code:
int enter_coin(struct tm *tm, int price){
 char charinput[3];
 int input = 0;
 enum truefalse success = FALSE;
 struct coin *listptr;
 int fivecent = 0; int tencent = 0; int twentycent = 0; int fiftycent = 0; int one = 0; int two = 0; int negprice = 0;
 listptr = tm->coins;
 do{
  printf("Enter a coin ($%.2f remaining): ",(float)price / 100);
  fgets(charinput, 3 + 2, stdin);
   if(charinput[strlen(charinput) -1] !='\n'){
                printf("Error: Input was too long! Try again.\n");
            }
    else if (strcmp(charinput, "\n") == 0){
     fivecent = 0;
     tencent = 0;
     twentycent = 0;
     fiftycent = 0;
     one = 0;
     two = 0;
                    return -1;
            }
   input = atoi(charinput);
   if (input == 5){
    fivecent++;
    success = TRUE;
   }
   else if (input == 10){
    tencent++;
    success = TRUE;
   }
   else if (input == 20){
    twentycent++;
    listptr[2].count++;
    success = TRUE;
   }
   else if (input == 50){
    fiftycent++;
    success = TRUE;
   }
   else if (input == 100){
    one++;
    success = TRUE;
   }
   else if (input == 200){
    two++;
    success = TRUE;
   }
   else{
    printf("Error: Invalid coin entered! Please try again.\n");
   }
   if (success == TRUE){
   price -= input;
   success = FALSE;
   }
 }
 while(price > 0);
 listptr[0].count += fivecent;
 listptr[1].count += tencent;
 listptr[2].count += twentycent;
 listptr[3].count += fiftycent;
 listptr[4].count += one;
 listptr[5].count += two;
 negprice = price;
 return negprice;
}

variable_types: struct tm { struct coin { enum coin_types { FIVE_CENTS=5, TEN_CENTS=10, TWENTY_CENTS=20, FIFTY_CENTS=50, ONE_DOLLAR=100, TWO_DOLLARS=200 } denomination; unsigned int count; } *coins; struct stock_list { struct stock_node { struct stock_data { char ticket_name[-1]; char ticket_type; char ticket_zone[-1]; unsigned int ticket_price; unsigned int stock_level; } *data; struct stock_node *next_node; } *head_stock; unsigned int num_stock_items; } *stock; } *

variable_types: price int

variable_types:
charinput
char [3]

variable_types: input int

variable_types:
success
enum truefalse { FALSE=0, TRUE=1 }

variable_types: fivecent int

variable_types: tencent int

variable_types: twentycent int

variable_types: fiftycent int

variable_types: one int

variable_types: two int

variable_types: negprice int

user_defined_types: struct tm { struct coin *coins; struct stock_list *stock; }

user_defined_types: struct coin { enum coin_types denomination; unsigned int count; }

user_defined_types: struct stock_list { struct stock_node *head_stock; unsigned int num_stock_items; }

user_defined_types: struct stock_node { struct stock_data *data; struct stock_node *next_node; }


decompiled_code:
void read_rest_of_line()
{
int v0; // eax

do
v0 = getc(stdin);
while ( v0 != -1 && v0 != 10 );
clearerr(stdin);
}

canonical_decompiled_code:
void func1()
{
int v0; // eax

do
v0 = getc(stdin);
while ( v0 != -1 && v0 != 10 );
clearerr(stdin);
}

original_code:
void read_rest_of_line(void)
{
    int ch;
    while(ch=getc(stdin), ch!=(-1) && ch!='\n')
        ;
    clearerr(stdin);
}

canonical_original_code:
void read_rest_of_line()
{
    int ch;
    while(ch=getc(stdin), ch!=(-1) && ch!='\n')
        ;
    clearerr(stdin);
}

variable_types: ch int


stringinput

decompiled_code:
char *__fastcall stringinput(const char *a1, char *a2, int a3)
{
char *result; // rax
char *v5; // rax

while ( 1 )
{
printf("%s", a1);
result = fgets(a2, a3, stdin);
if ( !result )
break;
v5 = &a2[strlen(a2) - 1];
if ( *v5 == 10 )
{
if ( !strcmp(a2, "\n") )
return 0LL;
*v5 = 0;
return a2;
}
puts("Error: Input was too long! Try again.");
read_rest_of_line();
}
return result;
}

canonical_decompiled_code:
char *__fastcall func2(const char *a1, char *a2, int a3)
{
char *result; // rax
char *v5; // rax

while ( 1 )
{
printf("%s", a1);
result = fgets(a2, a3, stdin);
if ( !result )
break;
v5 = &a2[strlen(a2) - 1];
if ( *v5 == 10 )
{
if ( !strcmp(a2, "\n") )
return 0LL;
*v5 = 0;
return a2;
}
puts("Error: Input was too long! Try again.");
func1();
}
return result;
}

original_code:
char * stringinput(char * prompt, char * storage, int size){
 BOOLEAN finished = FALSE;
 do{
        printf("%s", prompt);
        if(fgets(storage, size, stdin) == ((void *)0)){
   return FALSE;
  }
            if(storage[strlen(storage) -1] !='\n'){
                printf("Error: Input was too long! Try again.\n");
                read_rest_of_line();
            }
            else if (strcmp(storage, "\n") == 0){
                    return FALSE;
            }
            else{
                storage[strlen(storage) -1] = '\0';
                finished = TRUE;
            }
        }while(!finished);
 return storage;
}

canonical_original_code:
char *stringinput(char *prompt, char *storage, int size){
 enum truefalse finished = FALSE;
 do{
        printf("%s", prompt);
        if(fgets(storage, size, stdin) == ((void *)0)){
   return FALSE;
  }
            if(storage[strlen(storage) -1] !='\n'){
                printf("Error: Input was too long! Try again.\n");
                read_rest_of_line();
            }
            else if (strcmp(storage, "\n") == 0){
                    return FALSE;
            }
            else{
                storage[strlen(storage) -1] = '\0';
                finished = TRUE;
            }
        }while(!finished);
 return storage;
}

variable_types:
prompt
char *

variable_types:
storage
char *

variable_types: size int

variable_types:
finished
enum truefalse { FALSE=0, TRUE=1 }

return_type: char *


charinput

decompiled_code:
char *__fastcall charinput(const char *a1, char *a2, int a3)
{
char *result; // rax
char *v5; // rdx

while ( 1 )
{
printf("%s", a1);
result = fgets(a2, a3, stdin);
if ( !result )
break;
v5 = &a2[strlen(a2) - 1];
if ( *v5 == 10 )
{
if ( !strcmp(a2, "\n") )
return 0LL;
if ( *a2 == 70 )
{
*v5 = 0;
return a2;
}
if ( *a2 == 67 )
{
*v5 = 0;
return a2;
}
puts("Error: not a valid input! Please try again.");
}
else
{
puts("Error: Input was too long! Try again.");
read_rest_of_line();
}
}
return result;
}

canonical_decompiled_code:
char *__fastcall func3(const char *a1, char *a2, int a3)
{
char *result; // rax
char *v5; // rdx

while ( 1 )
{
printf("%s", a1);
result = fgets(a2, a3, stdin);
if ( !result )
break;
v5 = &a2[strlen(a2) - 1];
if ( *v5 == 10 )
{
if ( !strcmp(a2, "\n") )
return 0LL;
if ( *a2 == 70 )
{
*v5 = 0;
return a2;
}
if ( *a2 == 67 )
{
*v5 = 0;
return a2;
}
puts("Error: not a valid input! Please try again.");
}
else
{
puts("Error: Input was too long! Try again.");
func1();
}
}
return result;
}

original_code:
char * charinput(char * prompt, char * storage, int size){
 BOOLEAN finished = FALSE;
 do{
        printf("%s", prompt);
        if(fgets(storage, size, stdin) == ((void *)0)){
   return FALSE;
  }
            if(storage[strlen(storage) -1] !='\n'){
                printf("Error: Input was too long! Try again.\n");
                read_rest_of_line();
            }
            else if (strcmp(storage, "\n") == 0){
                    return FALSE;
            }
   else if (storage[0] == 'F'){
    storage[strlen(storage) -1] = '\0';
                finished = TRUE;
   }
   else if (storage[0] == 'C'){
    storage[strlen(storage) -1] = '\0';
                finished = TRUE;
   }
            else{
                printf("Error: not a valid input! Please try again.\n");
            }
        }while(!finished);
 return storage;
}

canonical_original_code:
char *charinput(char *prompt, char *storage, int size){
 enum truefalse finished = FALSE;
 do{
        printf("%s", prompt);
        if(fgets(storage, size, stdin) == ((void *)0)){
   return FALSE;
  }
            if(storage[strlen(storage) -1] !='\n'){
                printf("Error: Input was too long! Try again.\n");
                read_rest_of_line();
            }
            else if (strcmp(storage, "\n") == 0){
                    return FALSE;
            }
   else if (storage[0] == 'F'){
    storage[strlen(storage) -1] = '\0';
                finished = TRUE;
   }
   else if (storage[0] == 'C'){
    storage[strlen(storage) -1] = '\0';
                finished = TRUE;
   }
            else{
                printf("Error: not a valid input! Please try again.\n");
            }
        }while(!finished);
 return storage;
}


zoneinput

decompiled_code:
char *__fastcall zoneinput(const char *a1, char *a2, int a3)
{
char *result; // rax
char *v7; // rdx

while ( 1 )
{
printf("%s", a1);
result = fgets(a2, a3, stdin);
if ( !result )
break;
v7 = &a2[strlen(a2) - 1];
if ( *v7 == 10 )
{
if ( !strcmp(a2, "\n") )
return 0LL;
if ( *a2 == 49 )
{
*v7 = 0;
return a2;
}
if ( *a2 == 50 )
{
*v7 = 0;
return a2;
}
if ( !memcmp(a2, "1+2", 2uLL) )
{
*v7 = 0;
return a2;
}
puts("Error: not a valid input! Please try again.");
}
else
{
puts("Error: Input was too long! Try again.");
read_rest_of_line();
}
}
return result;
}

canonical_decompiled_code:
char *__fastcall func4(const char *a1, char *a2, int a3)
{
char *result; // rax
char *v7; // rdx

while ( 1 )
{
printf("%s", a1);
result = fgets(a2, a3, stdin);
if ( !result )
break;
v7 = &a2[strlen(a2) - 1];
if ( *v7 == 10 )
{
if ( !strcmp(a2, "\n") )
return 0LL;
if ( *a2 == 49 )
{
*v7 = 0;
return a2;
}
if ( *a2 == 50 )
{
*v7 = 0;
return a2;
}
if ( !memcmp(a2, "1+2", 2uLL) )
{
*v7 = 0;
return a2;
}
puts("Error: not a valid input! Please try again.");
}
else
{
puts("Error: Input was too long! Try again.");
func1();
}
}
return result;
}

original_code:
char * zoneinput(char * prompt, char * storage, int size){
 BOOLEAN finished = FALSE;
 do{
        printf("%s", prompt);
        if(fgets(storage, size, stdin) == ((void *)0)){
   return FALSE;
  }
            if(storage[strlen(storage) -1] !='\n'){
                printf("Error: Input was too long! Try again.\n");
                read_rest_of_line();
            }
            else if (strcmp(storage, "\n") == 0){
                    return FALSE;
            }
   else if (storage[0] == '1'){
    storage[strlen(storage) -1] = '\0';
                finished = TRUE;
   }
   else if (storage[0] == '2'){
    storage[strlen(storage) -1] = '\0';
                finished = TRUE;
   }
   else if (strncmp(storage, "1+2", 2) == 0){
    storage[strlen(storage) -1] = '\0';
                finished = TRUE;
   }
            else{
                printf("Error: not a valid input! Please try again.\n");
            }
        }while(!finished);
 return storage;
}

canonical_original_code:
char *zoneinput(char *prompt, char *storage, int size){
 enum truefalse finished = FALSE;
 do{
        printf("%s", prompt);
        if(fgets(storage, size, stdin) == ((void *)0)){
   return FALSE;
  }
            if(storage[strlen(storage) -1] !='\n'){
                printf("Error: Input was too long! Try again.\n");
                read_rest_of_line();
            }
            else if (strcmp(storage, "\n") == 0){
                    return FALSE;
            }
   else if (storage[0] == '1'){
    storage[strlen(storage) -1] = '\0';
                finished = TRUE;
   }
   else if (storage[0] == '2'){
    storage[strlen(storage) -1] = '\0';
                finished = TRUE;
   }
   else if (strncmp(storage, "1+2", 2) == 0){
    storage[strlen(storage) -1] = '\0';
                finished = TRUE;
   }
            else{
                printf("Error: not a valid input! Please try again.\n");
            }
        }while(!finished);
 return storage;
}


decompiled_code:
__int64 __fastcall system_init(_QWORD *a1)
{
_DWORD *v1; // rax
_DWORD *v2; // rbx
_DWORD *v3; // rax

v1 = malloc(0x10uLL);
a1[1] = v1;
if ( v1 )
{
v2 = v1;
v3 = malloc(0x30uLL);
*a1 = v3;
*v3 = 0;
v3[1] = 0;
*(_QWORD *)v2 = 0LL;
v2[2] = 0;
}
else
{
perror("Error: Memory allocation failed! Exiting...\n");
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(_QWORD *a1)
{
_DWORD *v1; // rax
_DWORD *v2; // rbx
_DWORD *v3; // rax

v1 = malloc(0x10uLL);
a1[1] = v1;
if ( v1 )
{
v2 = v1;
v3 = malloc(0x30uLL);
*a1 = v3;
*v3 = 0;
v3[1] = 0;
*(_QWORD *)v2 = 0LL;
v2[2] = 0;
}
else
{
perror("Error: Memory allocation failed! Exiting...\n");
}
return 1LL;
}

original_code:
BOOLEAN system_init(tm_type * tm)
{
 tm->stock = (struct stock_list *)malloc(sizeof(struct stock_list));
 if (!tm->stock){
  perror("Error: Memory allocation failed! Exiting...\n");
  return 1;
 }
 tm->coins = (struct coin *)malloc((6) * sizeof(struct coin));
 tm->coins->denomination = 0;
 tm->coins->count = 0;
 if (!tm->coins){
  perror("Error: Memory allocation failed! Exiting...\n");
  return 1;
 }
 tm->stock->head_stock = ((void *)0);
 tm->stock->num_stock_items = 0;
    return TRUE;
}

canonical_original_code:
enum truefalse system_init(struct tm *tm)
{
 tm->stock = (struct stock_list *)malloc(sizeof(struct stock_list));
 if (!tm->stock){
  perror("Error: Memory allocation failed! Exiting...\n");
  return 1;
 }
 tm->coins = (struct coin *)malloc((6) * sizeof(struct coin));
 tm->coins->denomination = 0;
 tm->coins->count = 0;
 if (!tm->coins){
  perror("Error: Memory allocation failed! Exiting...\n");
  return 1;
 }
 tm->stock->head_stock = ((void *)0);
 tm->stock->num_stock_items = 0;
    return TRUE;
}

variable_types: struct tm { struct coin { enum coin_types { FIVE_CENTS=5, TEN_CENTS=10, TWENTY_CENTS=20, FIFTY_CENTS=50, ONE_DOLLAR=100, TWO_DOLLARS=200 } denomination; unsigned int count; } *coins; struct stock_list { struct stock_node { struct stock_data { char ticket_name[-1]; char ticket_type; char ticket_zone[-1]; unsigned int ticket_price; unsigned int stock_level; } *data; struct stock_node *next_node; } *head_stock; unsigned int num_stock_items; } *stock; } *

return_type: enum truefalse { FALSE=0, TRUE=1 }


decompiled_code:
void __fastcall system_free(void **a1)
{
__int64 v1; // rbx
void **v2; // rbp

v1 = *(_QWORD *)a1[1];
while ( v1 )
{
v2 = (void **)v1;
v1 = *(_QWORD *)(v1 + 8);
free(*v2);
free(v2);
}
free(a1[1]);
free(*a1);
}

original_code:
void system_free(tm_type_ptr tm)
{
 stock_node *currentItem = ((void *)0), *nextItem = ((void *)0);
 currentItem = tm->stock->head_stock;
 while (currentItem != ((void *)0)){
  nextItem = currentItem->next_node;
  free(currentItem->data);
  free(currentItem);
  currentItem = nextItem;
 }
 free(tm->stock);
 free(tm->coins);
}

canonical_original_code:
void system_free(struct tm *tm)
{
 struct stock_node *currentItem = ((void *)0); struct stock_node *nextItem = ((void *)0);
 currentItem = tm->stock->head_stock;
 while (currentItem != ((void *)0)){
  nextItem = currentItem->next_node;
  free(currentItem->data);
  free(currentItem);
  currentItem = nextItem;
 }
 free(tm->stock);
 free(tm->coins);
}

variable_types: struct stock_node { struct stock_data { char ticket_name[-1]; char ticket_type; char ticket_zone[-1]; unsigned int ticket_price; unsigned int stock_level; } *data; struct stock_node *next_node; } *

user_defined_types: enum coin_types { FIVE_CENTS=5, TEN_CENTS=10, TWENTY_CENTS=20, FIFTY_CENTS=50, ONE_DOLLAR=100, TWO_DOLLARS=200 }