original_code:
void GBROM_AssignSections(void)
{
 SLONG i;
 struct sSection *pSection;
 MaxBankUsed = 0;
 for (i = 0; i < 259; i += 1) {
  BankFree[i] = malloc(sizeof *BankFree[i]);
  if (!BankFree[i])
   fatalerror("Out of memory!");
  if (i == 0) {
   BankFree[i]->nOrg = 0x0000;
   if (options & 0x01) {
    BankFree[i]->nSize = 0x8000;
    MaxAvail[i] = 0x8000;
   } else {
    BankFree[i]->nSize = 0x4000;
    MaxAvail[i] = 0x4000;
   }
  } else if (i >= 1 && i <= 255) {
   BankFree[i]->nOrg = 0x4000;
   if (options & 0x01) {
    BankFree[i]->nSize = 0;
    MaxAvail[i] = 0;
   } else {
    BankFree[i]->nSize = 0x4000;
    MaxAvail[i] = 0x4000;
   }
  } else if (i == BANK_BSS) {
   BankFree[i]->nOrg = 0xC000;
   BankFree[i]->nSize = 0x2000;
   MaxAvail[i] = 0x2000;
  } else if (i == BANK_VRAM) {
   BankFree[i]->nOrg = 0x8000;
   BankFree[i]->nSize = 0x2000;
   MaxAvail[i] = 0x2000;
  } else if (i == BANK_HRAM) {
   BankFree[i]->nOrg = 0xFF80;
   BankFree[i]->nSize = 0x007F;
   MaxAvail[i] = 0x007F;
  }
  BankFree[i]->pPrev = ((void *)0);
  BankFree[i]->pNext = ((void *)0);
 }
 pSection = pSections;
 while (pSection) {
  if ((pSection->nOrg != -1 || pSection->nBank != -1)
      && pSection->oAssigned == 0) {
   switch (pSection->Type) {
   case SECT_BSS:
    if (area_AllocAbs
        (&BankFree[BANK_BSS], pSection->nOrg,
         pSection->nByteSize) != pSection->nOrg) {
     sprintf(temptext,
      "Unable to load fixed BSS section at $%lX",
      pSection->nOrg);
     fatalerror(temptext);
    }
    pSection->oAssigned = 1;
    pSection->nBank = BANK_BSS;
    break;
   case SECT_HRAM:
    if (area_AllocAbs
        (&BankFree[BANK_HRAM], pSection->nOrg,
         pSection->nByteSize) != pSection->nOrg) {
     sprintf(temptext,
      "Unable to load fixed HRAM section at $%lX",
      pSection->nOrg);
     fatalerror(temptext);
    }
    pSection->oAssigned = 1;
    pSection->nBank = BANK_HRAM;
    break;
   case SECT_VRAM:
    if (area_AllocAbs
        (&BankFree[BANK_VRAM], pSection->nOrg,
         pSection->nByteSize) != pSection->nOrg) {
     sprintf(temptext,
      "Unable to load fixed VRAM section at $%lX",
      pSection->nOrg);
     fatalerror(temptext);
    }
    pSection->oAssigned = 1;
    pSection->nBank = BANK_VRAM;
    break;
   case SECT_HOME:
    if (area_AllocAbs
        (&BankFree[BANK_HOME], pSection->nOrg,
         pSection->nByteSize) != pSection->nOrg) {
     sprintf(temptext,
      "Unable to load fixed HOME section at $%lX",
      pSection->nOrg);
     fatalerror(temptext);
    }
    pSection->oAssigned = 1;
    pSection->nBank = BANK_HOME;
    break;
   case SECT_CODE:
    if (pSection->nBank == -1) {
    } else {
     if (pSection->nOrg == -1) {
     } else {
      if (pSection->nBank >= 1
          && pSection->nBank <= 255) {
       if (area_AllocAbs
           (&BankFree
            [pSection->nBank],
            pSection->nOrg,
            pSection->
            nByteSize) !=
           pSection->nOrg) {
        sprintf
            (temptext,
             "Unable to load fixed CODE/DATA section at $%lX in bank $%02lX",
             pSection->
             nOrg,
             pSection->
             nBank);
        fatalerror
            (temptext);
       }
       {if( (pSection-> nBank)>MaxBankUsed ) MaxBankUsed=(pSection-> nBank);};
       pSection->oAssigned = 1;
      } else {
       sprintf(temptext,
        "Unable to load fixed CODE/DATA section at $%lX in bank $%02lX",
        pSection->nOrg,
        pSection->
        nBank);
       fatalerror(temptext);
      }
     }
    }
    break;
   }
  }
  pSection = pSection->pNext;
 }
 pSection = pSections;
 while (pSection) {
  if (pSection->oAssigned == 0
      && pSection->Type == SECT_CODE
      && pSection->nOrg == -1 && pSection->nBank != -1) {
   if (pSection->nBank >= 1 && pSection->nBank <= 255) {
    if ((pSection->nOrg =
         area_Alloc(&BankFree[pSection->nBank],
      pSection->nByteSize)) == -1) {
     sprintf(temptext,
      "Unable to load fixed CODE/DATA section into bank $%02lX",
      pSection->nBank);
     fatalerror(temptext);
    }
    pSection->oAssigned = 1;
    {if( (pSection->nBank)>MaxBankUsed ) MaxBankUsed=(pSection->nBank);};
   } else {
    sprintf(temptext,
     "Unable to load fixed CODE/DATA section into bank $%02lX",
     pSection->nBank);
    fatalerror(temptext);
   }
  }
  pSection = pSection->pNext;
 }
 pSection = pSections;
 while (pSection) {
  if (pSection->oAssigned == 0
      && pSection->Type == SECT_CODE
      && pSection->nOrg != -1 && pSection->nBank == -1) {
   if ((pSection->nBank =
        area_AllocAbsCODEAnyBank(pSection->nOrg,
            pSection->nByteSize)) ==
       -1) {
    sprintf(temptext,
     "Unable to load fixed CODE/DATA section at $%lX into any bank",
     pSection->nOrg);
    fatalerror(temptext);
   }
   pSection->oAssigned = 1;
   {if( (pSection->nBank)>MaxBankUsed ) MaxBankUsed=(pSection->nBank);};
  }
  pSection = pSection->pNext;
 }
 pSection = pSections;
 while (pSection) {
  if (pSection->oAssigned == 0) {
   switch (pSection->Type) {
   case SECT_BSS:
    if ((pSection->nOrg =
         area_Alloc(&BankFree[BANK_BSS],
      pSection->nByteSize)) == -1) {
     fatalerror("BSS section too large\n");
    }
    pSection->nBank = BANK_BSS;
    pSection->oAssigned = 1;
    break;
   case SECT_HRAM:
    if ((pSection->nOrg =
         area_Alloc(&BankFree[BANK_HRAM],
      pSection->nByteSize)) == -1) {
     fatalerror("HRAM section too large");
    }
    pSection->nBank = BANK_HRAM;
    pSection->oAssigned = 1;
    break;
   case SECT_VRAM:
    if ((pSection->nOrg =
         area_Alloc(&BankFree[BANK_VRAM],
      pSection->nByteSize)) == -1) {
     fatalerror("VRAM section too large");
    }
    pSection->nBank = BANK_VRAM;
    pSection->oAssigned = 1;
    break;
   case SECT_HOME:
    if ((pSection->nOrg =
         area_Alloc(&BankFree[BANK_HOME],
      pSection->nByteSize)) == -1) {
     fatalerror("HOME section too large");
    }
    pSection->nBank = BANK_HOME;
    pSection->oAssigned = 1;
    break;
   case SECT_CODE:
    break;
   default:
    fatalerror("(INTERNAL) Unknown section type!");
    break;
   }
  }
  pSection = pSection->pNext;
 }
 AssignCodeSections();
}

canonical_original_code:
void GBROM_AssignSections()
{
 long i;
 struct sSection *pSection;
 MaxBankUsed = 0;
 for (i = 0; i < 259; i += 1) {
  BankFree[i] = malloc(sizeof *BankFree[i]);
  if (!BankFree[i])
   fatalerror("Out of memory!");
  if (i == 0) {
   BankFree[i]->nOrg = 0x0000;
   if (options & 0x01) {
    BankFree[i]->nSize = 0x8000;
    MaxAvail[i] = 0x8000;
   } else {
    BankFree[i]->nSize = 0x4000;
    MaxAvail[i] = 0x4000;
   }
  } else if (i >= 1 && i <= 255) {
   BankFree[i]->nOrg = 0x4000;
   if (options & 0x01) {
    BankFree[i]->nSize = 0;
    MaxAvail[i] = 0;
   } else {
    BankFree[i]->nSize = 0x4000;
    MaxAvail[i] = 0x4000;
   }
  } else if (i == BANK_BSS) {
   BankFree[i]->nOrg = 0xC000;
   BankFree[i]->nSize = 0x2000;
   MaxAvail[i] = 0x2000;
  } else if (i == BANK_VRAM) {
   BankFree[i]->nOrg = 0x8000;
   BankFree[i]->nSize = 0x2000;
   MaxAvail[i] = 0x2000;
  } else if (i == BANK_HRAM) {
   BankFree[i]->nOrg = 0xFF80;
   BankFree[i]->nSize = 0x007F;
   MaxAvail[i] = 0x007F;
  }
  BankFree[i]->pPrev = ((void *)0);
  BankFree[i]->pNext = ((void *)0);
 }
 pSection = pSections;
 while (pSection) {
  if ((pSection->nOrg != -1 || pSection->nBank != -1)
      && pSection->oAssigned == 0) {
   switch (pSection->Type) {
   case SECT_BSS:
    if (area_AllocAbs
        (&BankFree[BANK_BSS], pSection->nOrg,
         pSection->nByteSize) != pSection->nOrg) {
     sprintf(temptext,
      "Unable to load fixed BSS section at $%lX",
      pSection->nOrg);
     fatalerror(temptext);
    }
    pSection->oAssigned = 1;
    pSection->nBank = BANK_BSS;
    break;
   case SECT_HRAM:
    if (area_AllocAbs
        (&BankFree[BANK_HRAM], pSection->nOrg,
         pSection->nByteSize) != pSection->nOrg) {
     sprintf(temptext,
      "Unable to load fixed HRAM section at $%lX",
      pSection->nOrg);
     fatalerror(temptext);
    }
    pSection->oAssigned = 1;
    pSection->nBank = BANK_HRAM;
    break;
   case SECT_VRAM:
    if (area_AllocAbs
        (&BankFree[BANK_VRAM], pSection->nOrg,
         pSection->nByteSize) != pSection->nOrg) {
     sprintf(temptext,
      "Unable to load fixed VRAM section at $%lX",
      pSection->nOrg);
     fatalerror(temptext);
    }
    pSection->oAssigned = 1;
    pSection->nBank = BANK_VRAM;
    break;
   case SECT_HOME:
    if (area_AllocAbs
        (&BankFree[BANK_HOME], pSection->nOrg,
         pSection->nByteSize) != pSection->nOrg) {
     sprintf(temptext,
      "Unable to load fixed HOME section at $%lX",
      pSection->nOrg);
     fatalerror(temptext);
    }
    pSection->oAssigned = 1;
    pSection->nBank = BANK_HOME;
    break;
   case SECT_CODE:
    if (pSection->nBank == -1) {
    } else {
     if (pSection->nOrg == -1) {
     } else {
      if (pSection->nBank >= 1
          && pSection->nBank <= 255) {
       if (area_AllocAbs
           (&BankFree
            [pSection->nBank],
            pSection->nOrg,
            pSection->
            nByteSize) !=
           pSection->nOrg) {
        sprintf
            (temptext,
             "Unable to load fixed CODE/DATA section at $%lX in bank $%02lX",
             pSection->
             nOrg,
             pSection->
             nBank);
        fatalerror
            (temptext);
       }
       {if( (pSection-> nBank)>MaxBankUsed ) MaxBankUsed=(pSection-> nBank);};
       pSection->oAssigned = 1;
      } else {
       sprintf(temptext,
        "Unable to load fixed CODE/DATA section at $%lX in bank $%02lX",
        pSection->nOrg,
        pSection->
        nBank);
       fatalerror(temptext);
      }
     }
    }
    break;
   }
  }
  pSection = pSection->pNext;
 }
 pSection = pSections;
 while (pSection) {
  if (pSection->oAssigned == 0
      && pSection->Type == SECT_CODE
      && pSection->nOrg == -1 && pSection->nBank != -1) {
   if (pSection->nBank >= 1 && pSection->nBank <= 255) {
    if ((pSection->nOrg =
         area_Alloc(&BankFree[pSection->nBank],
      pSection->nByteSize)) == -1) {
     sprintf(temptext,
      "Unable to load fixed CODE/DATA section into bank $%02lX",
      pSection->nBank);
     fatalerror(temptext);
    }
    pSection->oAssigned = 1;
    {if( (pSection->nBank)>MaxBankUsed ) MaxBankUsed=(pSection->nBank);};
   } else {
    sprintf(temptext,
     "Unable to load fixed CODE/DATA section into bank $%02lX",
     pSection->nBank);
    fatalerror(temptext);
   }
  }
  pSection = pSection->pNext;
 }
 pSection = pSections;
 while (pSection) {
  if (pSection->oAssigned == 0
      && pSection->Type == SECT_CODE
      && pSection->nOrg != -1 && pSection->nBank == -1) {
   if ((pSection->nBank =
        area_AllocAbsCODEAnyBank(pSection->nOrg,
            pSection->nByteSize)) ==
       -1) {
    sprintf(temptext,
     "Unable to load fixed CODE/DATA section at $%lX into any bank",
     pSection->nOrg);
    fatalerror(temptext);
   }
   pSection->oAssigned = 1;
   {if( (pSection->nBank)>MaxBankUsed ) MaxBankUsed=(pSection->nBank);};
  }
  pSection = pSection->pNext;
 }
 pSection = pSections;
 while (pSection) {
  if (pSection->oAssigned == 0) {
   switch (pSection->Type) {
   case SECT_BSS:
    if ((pSection->nOrg =
         area_Alloc(&BankFree[BANK_BSS],
      pSection->nByteSize)) == -1) {
     fatalerror("BSS section too large\n");
    }
    pSection->nBank = BANK_BSS;
    pSection->oAssigned = 1;
    break;
   case SECT_HRAM:
    if ((pSection->nOrg =
         area_Alloc(&BankFree[BANK_HRAM],
      pSection->nByteSize)) == -1) {
     fatalerror("HRAM section too large");
    }
    pSection->nBank = BANK_HRAM;
    pSection->oAssigned = 1;
    break;
   case SECT_VRAM:
    if ((pSection->nOrg =
         area_Alloc(&BankFree[BANK_VRAM],
      pSection->nByteSize)) == -1) {
     fatalerror("VRAM section too large");
    }
    pSection->nBank = BANK_VRAM;
    pSection->oAssigned = 1;
    break;
   case SECT_HOME:
    if ((pSection->nOrg =
         area_Alloc(&BankFree[BANK_HOME],
      pSection->nByteSize)) == -1) {
     fatalerror("HOME section too large");
    }
    pSection->nBank = BANK_HOME;
    pSection->oAssigned = 1;
    break;
   case SECT_CODE:
    break;
   default:
    fatalerror("(INTERNAL) Unknown section type!");
    break;
   }
  }
  pSection = pSection->pNext;
 }
 AssignCodeSections();
}


repo: vegard/rgbds-linux

original_code:
void PSION2_AssignSections(void)
{
 struct sSection *pSection;
 BankFree[0] = malloc(sizeof *BankFree[0]);
 if (!BankFree[0])
  fatalerror("Out of memory!");
 BankFree[0]->nOrg = 0x0000;
 BankFree[0]->nSize = 0x10000;
 MaxAvail[0] = 0x10000;
 BankFree[0]->pPrev = ((void *)0);
 BankFree[0]->pNext = ((void *)0);
 pSection = pSections;
 while (pSection) {
  if (pSection->oAssigned == 0
    && pSection->Type == SECT_CODE) {
   pSection->oAssigned = 1;
   pSection->nBank = 0;
   pSection->nOrg = BankFree[0]->nOrg;
   BankFree[0]->nOrg += pSection->nByteSize;
   BankFree[0]->nSize -= pSection->nByteSize;
  }
  pSection = pSection->pNext;
 }
 pSection = pSections;
 while (pSection) {
  if (pSection->oAssigned == 0
    && pSection->Type == SECT_BSS) {
   pSection->oAssigned = 1;
   pSection->nBank = 0;
   pSection->nOrg = BankFree[0]->nOrg;
   BankFree[0]->nOrg += pSection->nByteSize;
   BankFree[0]->nSize -= pSection->nByteSize;
  }
  pSection = pSection->pNext;
 }
}

canonical_original_code:
void PSION2_AssignSections()
{
 struct sSection *pSection;
 BankFree[0] = malloc(sizeof *BankFree[0]);
 if (!BankFree[0])
  fatalerror("Out of memory!");
 BankFree[0]->nOrg = 0x0000;
 BankFree[0]->nSize = 0x10000;
 MaxAvail[0] = 0x10000;
 BankFree[0]->pPrev = ((void *)0);
 BankFree[0]->pNext = ((void *)0);
 pSection = pSections;
 while (pSection) {
  if (pSection->oAssigned == 0
    && pSection->Type == SECT_CODE) {
   pSection->oAssigned = 1;
   pSection->nBank = 0;
   pSection->nOrg = BankFree[0]->nOrg;
   BankFree[0]->nOrg += pSection->nByteSize;
   BankFree[0]->nSize -= pSection->nByteSize;
  }
  pSection = pSection->pNext;
 }
 pSection = pSections;
 while (pSection) {
  if (pSection->oAssigned == 0
    && pSection->Type == SECT_BSS) {
   pSection->oAssigned = 1;
   pSection->nBank = 0;
   pSection->nOrg = BankFree[0]->nOrg;
   BankFree[0]->nOrg += pSection->nByteSize;
   BankFree[0]->nSize -= pSection->nByteSize;
  }
  pSection = pSection->pNext;
 }
}

variable_types: struct sSection { long nBank; long nOrg; char oAssigned; long nByteSize; enum eSectionType { SECT_BSS=0, SECT_VRAM=1, SECT_CODE=2, SECT_HOME=3, SECT_HRAM=4 } Type; unsigned char *pData; long nNumberOfSymbols; struct sSymbol { char *pzName; enum eSymbolType { SYM_LOCAL=0, SYM_IMPORT=1, SYM_EXPORT=2 } Type; long nSectionID; struct sSection *pSection; long nOffset; } **tSymbols; struct sPatch { char *pzFilename; long nLineNo; long nOffset; enum ePatchType { PATCH_BYTE=0, PATCH_WORD_L=1, PATCH_LONG_L=2, PATCH_WORD_B=3, PATCH_LONG_B=4 } Type; long nRPNSize; unsigned char *pRPN; struct sPatch *pNext; char oRelocPatch; } *pPatches; struct sSection *pNext; } *

return_type: void

user_defined_types: struct sSection { long nBank; long nOrg; char oAssigned; long nByteSize; enum eSectionType Type; unsigned char *pData; long nNumberOfSymbols; struct sSymbol **tSymbols; struct sPatch *pPatches; struct sSection *pNext; }

user_defined_types: struct sPatch { char *pzFilename; long nLineNo; long nOffset; enum ePatchType Type; long nRPNSize; unsigned char *pRPN; struct sPatch *pNext; char oRelocPatch; }

user_defined_types: struct sSymbol { char *pzName; enum eSymbolType Type; long nSectionID; struct sSection *pSection; long nOffset; }


AssignSections

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

result = outputtype;
if ( !outputtype )
return GBROM_AssignSections();
if ( outputtype == 1 )
result = PSION2_AssignSections();
return result;
}

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

result = outputtype;
if ( !outputtype )
return func7();
if ( outputtype == 1 )
result = func8();
return result;
}

original_code:
void AssignSections(void)
{
 switch (outputtype) {
 case OUTPUT_GBROM:
  GBROM_AssignSections();
  break;
 case OUTPUT_PSION2:
  PSION2_AssignSections();
  break;
 }
}

canonical_original_code:
void AssignSections()
{
 switch (outputtype) {
 case OUTPUT_GBROM:
  GBROM_AssignSections();
  break;
 case OUTPUT_PSION2:
  PSION2_AssignSections();
  break;
 }
}


CreateSymbolTable

decompiled_code:
__int64 CreateSymbolTable()
{
__int64 result; // rax
_QWORD *v1; // rbp
__int64 v2; // rbx
_QWORD *v3; // rax
_QWORD *v4; // rdx

result = sym_Init();
v1 = (_QWORD *)pSections;
if ( pSections )
{
while ( 1 )
{
result = v1[6];
v2 = result - 1;
if ( result )
break;
LABEL_10:
v1 = (_QWORD *)v1[9];
if ( !v1 )
return result;
}
while ( 1 )
{
v3 = *(_QWORD **)(v1[7] + 8 * v2);
if ( *((_DWORD *)v3 + 2) != 2 )
goto LABEL_4;
v4 = (_QWORD *)v3[3];
if ( v4 == v1 )
break;
if ( v4 )
goto LABEL_4;
sym_CreateSymbol(*v3, v3[4], 0xFFFFFFFFLL);
result = v2 - 1;
if ( !v2 )
goto LABEL_10;
LABEL_5:
v2 = result;
}
sym_CreateSymbol(*v3, v1[1] + v3[4], (unsigned int)*(char *)v1);
LABEL_4:
result = v2 - 1;
if ( !v2 )
goto LABEL_10;
goto LABEL_5;
}
return result;
}

canonical_decompiled_code:
__int64 func10()
{
__int64 result; // rax
_QWORD *v1; // rbp
__int64 v2; // rbx
_QWORD *v3; // rax
_QWORD *v4; // rdx

result = sym_Init();
v1 = (_QWORD *)pSections;
if ( pSections )
{
while ( 1 )
{
result = v1[6];
v2 = result - 1;
if ( result )
break;
LABEL_10:
v1 = (_QWORD *)v1[9];
if ( !v1 )
return result;
}
while ( 1 )
{
v3 = *(_QWORD **)(v1[7] + 8 * v2);
if ( *((_DWORD *)v3 + 2) != 2 )
goto LABEL_4;
v4 = (_QWORD *)v3[3];
if ( v4 == v1 )
break;
if ( v4 )
goto LABEL_4;
sym_CreateSymbol(*v3, v3[4], 0xFFFFFFFFLL);
result = v2 - 1;
if ( !v2 )
goto LABEL_10;
LABEL_5:
v2 = result;
}
sym_CreateSymbol(*v3, v1[1] + v3[4], (unsigned int)*(char *)v1);
LABEL_4:
result = v2 - 1;
if ( !v2 )
goto LABEL_10;
goto LABEL_5;
}
return result;
}

original_code:
void CreateSymbolTable(void)
{
 struct sSection *pSect;
 sym_Init();
 pSect = pSections;
 while (pSect) {
  SLONG i;
  i = pSect->nNumberOfSymbols;
  while (i--) {
   if ((pSect->tSymbols[i]->Type == SYM_EXPORT) &&
       ((pSect->tSymbols[i]->pSection == pSect) ||
        (pSect->tSymbols[i]->pSection == ((void *)0)))) {
    if (pSect->tSymbols[i]->pSection == ((void *)0))
     sym_CreateSymbol(pSect->tSymbols[i]->
        pzName,
        pSect->tSymbols[i]->
        nOffset, -1);
    else
     sym_CreateSymbol(pSect->tSymbols[i]->
        pzName,
        pSect->nOrg +
        pSect->tSymbols[i]->
        nOffset, pSect->nBank);
   }
  }
  pSect = pSect->pNext;
 }
}

canonical_original_code:
void CreateSymbolTable()
{
 struct sSection *pSect;
 sym_Init();
 pSect = pSections;
 while (pSect) {
  long i;
  i = pSect->nNumberOfSymbols;
  while (i--) {
   if ((pSect->tSymbols[i]->Type == SYM_EXPORT) &&
       ((pSect->tSymbols[i]->pSection == pSect) ||
        (pSect->tSymbols[i]->pSection == ((void *)0)))) {
    if (pSect->tSymbols[i]->pSection == ((void *)0))
     sym_CreateSymbol(pSect->tSymbols[i]->
        pzName,
        pSect->tSymbols[i]->
        nOffset, -1);
    else
     sym_CreateSymbol(pSect->tSymbols[i]->
        pzName,
        pSect->nOrg +
        pSect->tSymbols[i]->
        nOffset, pSect->nBank);
   }
  }
  pSect = pSect->pNext;
 }
}

variable_types: i long

user_defined_types: enum eSectionType { SECT_BSS=0, SECT_VRAM=1, SECT_CODE=2, SECT_HOME=3, SECT_HRAM=4 }

user_defined_types: enum ePatchType { PATCH_BYTE=0, PATCH_WORD_L=1, PATCH_LONG_L=2, PATCH_WORD_B=3, PATCH_LONG_B=4 }

user_defined_types: enum eSymbolType { SYM_LOCAL=0, SYM_IMPORT=1, SYM_EXPORT=2 }


decompiled_code:
__int64 math_DefinePI()
{
return sym_AddEqu(&unk_376, 205887LL);
}

canonical_decompiled_code:
__int64 func0()
{
return sym_AddEqu(&unk_376, 205887LL);
}

original_code:
void math_DefinePI(void)
{
 sym_AddEqu("_PI", ((SLONG)((acos(-1))*65536.0)));
}

canonical_original_code:
void math_DefinePI()
{
 sym_AddEqu("_PI", ((SLONG)((acos(-1))*65536.0)));
}


rpnpush

decompiled_code:
__int64 __fastcall rpnpush(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rdx

result = rpnp;
v2 = rpnp + 1;
rpnstack[rpnp] = a1;
rpnp = v2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rdx

result = rpnp;
v2 = rpnp + 1;
rpnstack[rpnp] = a1;
rpnp = v2;
return result;
}

original_code:
void rpnpush(SLONG i)
{
 rpnstack[rpnp++] = i;
}

canonical_original_code:
void rpnpush(long i)
{
 rpnstack[rpnp++] = i;
}


rpnpop

decompiled_code:
__int64 rpnpop()
{
--rpnp;
return rpnstack[rpnp];
}

canonical_decompiled_code:
__int64 func1()
{
--rpnp;
return rpnstack[rpnp];
}

original_code:
SLONG rpnpop(void)
{
 return (rpnstack[--rpnp]);
}

canonical_original_code:
long rpnpop()
{
 return (rpnstack[--rpnp]);
}

return_type: long


getsymvalue

decompiled_code:
__int64 __fastcall getsymvalue(__int64 a1)
{
__int64 v1; // rdx
int v2; // eax
__int64 result; // rax

v1 = *(_QWORD *)(*(_QWORD *)(pCurrentSection + 56) + 8 * a1);
v2 = *(_DWORD *)(v1 + 8);
if ( v2 == 1 )
return sym_GetValue(*(_QWORD *)v1);
if ( (v2 & 0xFFFFFFFD) != 0 )
{
fatalerror("*INTERNAL* UNKNOWN SYMBOL TYPE");
result = 0LL;
}
else if ( **(_BYTE **)v1 != 64 || *(_BYTE *)(*(_QWORD *)v1 + 1LL) )
{
result = *(_QWORD *)(*(_QWORD *)(v1 + 24) + 8LL) + *(_QWORD *)(v1 + 32);
}
else
{
result = nPC;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
__int64 v1; // rdx
int v2; // eax
__int64 result; // rax

v1 = *(_QWORD *)(*(_QWORD *)(pCurrentSection + 56) + 8 * a1);
v2 = *(_DWORD *)(v1 + 8);
if ( v2 == 1 )
return sym_GetValue(*(_QWORD *)v1);
if ( (v2 & 0xFFFFFFFD) != 0 )
{
fatalerror("*INTERNAL* UNKNOWN SYMBOL TYPE");
result = 0LL;
}
else if ( **(_BYTE **)v1 != 64 || *(_BYTE *)(*(_QWORD *)v1 + 1LL) )
{
result = *(_QWORD *)(*(_QWORD *)(v1 + 24) + 8LL) + *(_QWORD *)(v1 + 32);
}
else
{
result = nPC;
}
return result;
}

original_code:
SLONG getsymvalue(SLONG symid)
{
 switch (pCurrentSection->tSymbols[symid]->Type) {
 case SYM_IMPORT:
  return (sym_GetValue(pCurrentSection->tSymbols[symid]->pzName));
  break;
 case SYM_EXPORT:
 case SYM_LOCAL:
  {
   if (strcmp
       (pCurrentSection->tSymbols[symid]->pzName,
        "@") == 0) {
    return (nPC);
   } else
    return (pCurrentSection->tSymbols[symid]->
     nOffset +
     pCurrentSection->tSymbols[symid]->
     pSection->nOrg);
  }
 default:
  break;
 }
 fatalerror("*INTERNAL* UNKNOWN SYMBOL TYPE");
 return (0);
}

canonical_original_code:
long getsymvalue(long symid)
{
 switch (pCurrentSection->tSymbols[symid]->Type) {
 case SYM_IMPORT:
  return (sym_GetValue(pCurrentSection->tSymbols[symid]->pzName));
  break;
 case SYM_EXPORT:
 case SYM_LOCAL:
  {
   if (strcmp
       (pCurrentSection->tSymbols[symid]->pzName,
        "@") == 0) {
    return (nPC);
   } else
    return (pCurrentSection->tSymbols[symid]->
     nOffset +
     pCurrentSection->tSymbols[symid]->
     pSection->nOrg);
  }
 default:
  break;
 }
 fatalerror("*INTERNAL* UNKNOWN SYMBOL TYPE");
 return (0);
}

variable_types: symid long


getsymbank

decompiled_code:
__int64 __fastcall getsymbank(__int64 a1)
{
__int64 v1; // rdx
int v2; // eax

v1 = *(_QWORD *)(*(_QWORD *)(pCurrentSection + 56) + 8 * a1);
v2 = *(_DWORD *)(v1 + 8);
if ( v2 == 1 )
return sym_GetBank(*(_QWORD *)v1);
if ( (v2 & 0xFFFFFFFD) == 0 )
return **(_QWORD **)(v1 + 24);
fatalerror("*INTERNAL* UNKNOWN SYMBOL TYPE");
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
__int64 v1; // rdx
int v2; // eax

v1 = *(_QWORD *)(*(_QWORD *)(pCurrentSection + 56) + 8 * a1);
v2 = *(_DWORD *)(v1 + 8);
if ( v2 == 1 )
return sym_GetBank(*(_QWORD *)v1);
if ( (v2 & 0xFFFFFFFD) == 0 )
return **(_QWORD **)(v1 + 24);
fatalerror("*INTERNAL* UNKNOWN SYMBOL TYPE");
return 0LL;
}

original_code:
SLONG getsymbank(SLONG symid)
{
 switch (pCurrentSection->tSymbols[symid]->Type) {
 case SYM_IMPORT:
  return (sym_GetBank(pCurrentSection->tSymbols[symid]->pzName));
  break;
 case SYM_EXPORT:
 case SYM_LOCAL:
  return (pCurrentSection->tSymbols[symid]->pSection->nBank);
 default:
  break;
 }
 fatalerror("*INTERNAL* UNKNOWN SYMBOL TYPE");
 return (0);
}

canonical_original_code:
long getsymbank(long symid)
{
 switch (pCurrentSection->tSymbols[symid]->Type) {
 case SYM_IMPORT:
  return (sym_GetBank(pCurrentSection->tSymbols[symid]->pzName));
  break;
 case SYM_EXPORT:
 case SYM_LOCAL:
  return (pCurrentSection->tSymbols[symid]->pSection->nBank);
 default:
  break;
 }
 fatalerror("*INTERNAL* UNKNOWN SYMBOL TYPE");
 return (0);
}


calcrpn

decompiled_code:
__int64 __fastcall calcrpn(__int64 a1)
{
const char **v1; // r13
__int64 v2; // rbp
_BYTE *v3; // rax
__int64 v4; // rbx
_BYTE *v5; // r12
__int64 v6; // rax
char v7; // cl
__int64 v9; // r15
__int64 v10; // rax
__int64 v11; // rax
__int64 v12; // r8
int v13; // er9
__int64 v14; // rdx
__int64 v15; // r9
__int64 v16; // r15
__int64 v17; // rcx
unsigned __int64 v18; // rcx
__int64 v19; // rax
char v20; // cl
__int64 v21; // rax
__int64 v22; // rdx
__int64 v23; // rax
__int64 v24; // rdx
__int64 v25; // rax
__int64 v26; // rdx
__int64 v27; // rax
__int64 v28; // rdx
__int64 v29; // rax
__int64 v30; // rdx
__int64 v31; // rax
__int64 v32; // rdx
__int64 v33; // rax
__int64 v34; // rdi
__int64 v35; // rdi
__int64 v36; // rdi
__int64 v37; // rax
__int64 v38; // rcx
__int64 v39; // rax
__int64 v40; // rcx
__int64 v41; // rdi
__int64 v42; // rax
__int64 v43; // rdx
__int64 v44; // rdi

v1 = (const char **)a1;
v2 = *(_QWORD *)(a1 + 32);
v3 = *(_BYTE **)(a1 + 40);
*(_BYTE *)(a1 + 56) = 0;
rpnp = 0LL;
if ( v2 > 0 )
{
while ( 1 )
{
v4 = v2 - 1;
v5 = v3 + 1;
switch ( *v3 )
{
case 0:
v44 = ((__int64 (*)(void))rpnpop)();
a1 = rpnpop(v44) + v44;
rpnpush(a1);
goto LABEL_5;
case 1:
rpnpop(a1);
v42 = rpnpop(a1);
a1 = v42 - v43;
rpnpush(v42 - v43);
goto LABEL_5;
case 2:
v41 = rpnpop(a1);
a1 = rpnpop(v41) * v41;
rpnpush(a1);
goto LABEL_5;
case 3:
rpnpop(a1);
v39 = rpnpop(a1);
a1 = v39 / v40;
rpnpush(v39 / v40);
goto LABEL_5;
case 4:
rpnpop(a1);
v37 = rpnpop(a1);
a1 = v37 % v38;
rpnpush(v37 % v38);
goto LABEL_5;
case 5:
a1 = -rpnpop(a1);
rpnpush(a1);
goto LABEL_5;
case 6:
v36 = rpnpop(a1);
a1 = rpnpop(v36) | v36;
rpnpush(a1);
goto LABEL_5;
case 7:
v35 = rpnpop(a1);
a1 = rpnpop(v35) & v35;
rpnpush(a1);
goto LABEL_5;
case 8:
v34 = rpnpop(a1);
a1 = rpnpop(v34) ^ v34;
rpnpush(a1);
goto LABEL_5;
case 9:
a1 = rpnpop(a1) ^ 0xFFFFFFFFLL;
rpnpush(a1);
goto LABEL_5;
case 0xA:
a1 = rpnpop(a1);
if ( !a1 )
goto LABEL_4;
goto LABEL_29;
case 0xB:
v33 = rpnpop(a1);
a1 = 1LL;
if ( !v33 )
LABEL_29:
a1 = rpnpop(a1) != 0;
goto LABEL_4;
case 0xC:
a1 = rpnpop(a1) == 0;
rpnpush(a1);
goto LABEL_5;
case 0xD:
rpnpop(a1);
v31 = rpnpop(0LL);
a1 = v32 == v31;
rpnpush(a1);
goto LABEL_5;
case 0xE:
rpnpop(a1);
v29 = rpnpop(0LL);
a1 = v30 != v29;
rpnpush(a1);
goto LABEL_5;
case 0xF:
rpnpop(a1);
v27 = rpnpop(0LL);
a1 = v27 > v28;
rpnpush(a1);
goto LABEL_5;
case 0x10:
rpnpop(a1);
v25 = rpnpop(0LL);
a1 = v25 < v26;
rpnpush(a1);
goto LABEL_5;
case 0x11:
rpnpop(a1);
v23 = rpnpop(0LL);
a1 = v23 >= v24;
rpnpush(a1);
goto LABEL_5;
case 0x12:
rpnpop(a1);
v21 = rpnpop(0LL);
a1 = v21 <= v22;
rpnpush(a1);
goto LABEL_5;
case 0x13:
rpnpop(a1);
v19 = rpnpop(a1);
a1 = v19 << v20;
rpnpush(v19 << v20);
goto LABEL_5;
case 0x14:
rpnpop(a1);
v6 = rpnpop(a1);
a1 = v6 >> v7;
LABEL_4:
rpnpush(a1);
goto LABEL_5;
case 0x15:
v5 = v3 + 5;
v4 = v2 - 5;
a1 = getsymbank(((unsigned __int8)v3[4] << 24) | (unsigned __int64)(unsigned __int8)v3[1] | ((unsigned __int8)v3[3] << 16) | ((unsigned __int8)v3[2] << 8));
rpnpush(a1);
goto LABEL_5;
case 0x16:
a1 = (unsigned __int8)rpnpop(a1);
rpnpush(a1);
if ( v18 - 256 > 0xFDFF && v18 <= 0xFFFF )
goto LABEL_5;
sprintf(&temptext, "%s(%ld) : Value must be in the HRAM area", *v1, v1[1]);
break;
case 0x17:
a1 = (unsigned __int8)rpnpop(a1);
rpnpush(a1);
if ( (unsigned __int64)(v17 - 0x2000) <= 0xFF )
goto LABEL_5;
sprintf(&temptext, "%s(%ld) : Value must be in the ZP area", *v1, v1[1]);
break;
case 0x18:
v5 = v3 + 9;
v11 = rpnpop(a1);
v15 = v14 | v13;
v16 = v11;
if ( v12 > v11 || v15 < v11 )
{
sprintf(&temptext, "%s(%ld) : Value must be in the range [%ld;%ld]", *v1, v1[1], v12, v15);
fatalerror(&temptext);
}
a1 = v16;
v4 = v2 - 9;
rpnpush(v16);
goto LABEL_5;
case 0x80:
v5 = v3 + 5;
v4 = v2 - 5;
a1 = ((unsigned __int8)v3[4] << 24) | (unsigned __int64)(unsigned __int8)v3[1] | ((unsigned __int8)v3[3] << 16) | ((unsigned __int8)v3[2] << 8);
rpnpush(a1);
goto LABEL_5;
case 0x81:
v5 = v3 + 5;
v4 = v2 - 5;
v9 = ((unsigned __int8)v3[4] << 24) | (unsigned __int64)(unsigned __int8)v3[1] | ((unsigned __int8)v3[3] << 16) | ((unsigned __int8)v3[2] << 8);
v10 = getsymvalue(v9);
rpnpush(v10);
a1 = v9;
*((_BYTE *)v1 + 56) |= getsymbank(v9) != -1;
goto LABEL_5;
default:
goto LABEL_5;
}
a1 = (__int64)&temptext;
fatalerror(&temptext);
LABEL_5:
if ( v4 <= 0 )
break;
v3 = v5;
v2 = v4;
}
}
return rpnpop(a1);
}

original_code:
SLONG calcrpn(struct sPatch * pPatch)
{
 SLONG t, size;
 UBYTE *rpn;
 rpnp = 0;
 size = pPatch->nRPNSize;
 rpn = pPatch->pRPN;
 pPatch->oRelocPatch = 0;
 while (size > 0) {
  size -= 1;
  switch (*rpn++) {
  case RPN_ADD:
   rpnpush(rpnpop() + rpnpop());
   break;
  case RPN_SUB:
   t = rpnpop();
   rpnpush(rpnpop() - t);
   break;
  case RPN_MUL:
   rpnpush(rpnpop() * rpnpop());
   break;
  case RPN_DIV:
   t = rpnpop();
   rpnpush(rpnpop() / t);
   break;
  case RPN_MOD:
   t = rpnpop();
   rpnpush(rpnpop() % t);
   break;
  case RPN_UNSUB:
   rpnpush(-rpnpop());
   break;
  case RPN_OR:
   rpnpush(rpnpop() | rpnpop());
   break;
  case RPN_AND:
   rpnpush(rpnpop() & rpnpop());
   break;
  case RPN_XOR:
   rpnpush(rpnpop() ^ rpnpop());
   break;
  case RPN_UNNOT:
   rpnpush(rpnpop() ^ 0xFFFFFFFF);
   break;
  case RPN_LOGAND:
   rpnpush(rpnpop() && rpnpop());
   break;
  case RPN_LOGOR:
   rpnpush(rpnpop() || rpnpop());
   break;
  case RPN_LOGUNNOT:
   rpnpush(!rpnpop());
   break;
  case RPN_LOGEQ:
   rpnpush(rpnpop() == rpnpop());
   break;
  case RPN_LOGNE:
   rpnpush(rpnpop() != rpnpop());
   break;
  case RPN_LOGGT:
   t = rpnpop();
   rpnpush(rpnpop() > t);
   break;
  case RPN_LOGLT:
   t = rpnpop();
   rpnpush(rpnpop() < t);
   break;
  case RPN_LOGGE:
   t = rpnpop();
   rpnpush(rpnpop() >= t);
   break;
  case RPN_LOGLE:
   t = rpnpop();
   rpnpush(rpnpop() <= t);
   break;
  case RPN_SHL:
   t = rpnpop();
   rpnpush(rpnpop() << t);
   break;
  case RPN_SHR:
   t = rpnpop();
   rpnpush(rpnpop() >> t);
   break;
  case RPN_HRAM:
   t = rpnpop();
   rpnpush(t & 0xFF);
   if (t < 0 || (t > 0xFF && t < 0xFF00) || t > 0xFFFF) {
    sprintf(temptext,
     "%s(%ld) : Value must be in the HRAM area",
     pPatch->pzFilename, pPatch->nLineNo);
    fatalerror(temptext);
   }
   break;
  case RPN_PCEZP:
   t = rpnpop();
   rpnpush(t & 0xFF);
   if (t < 0x2000 || t > 0x20FF) {
    sprintf(temptext,
     "%s(%ld) : Value must be in the ZP area",
     pPatch->pzFilename, pPatch->nLineNo);
    fatalerror(temptext);
   }
   break;
  case RPN_CONST:
   t = (*rpn++);
   t |= (*rpn++) << 8;
   t |= (*rpn++) << 16;
   t |= (*rpn++) << 24;
   rpnpush(t);
   size -= 4;
   break;
  case RPN_SYM:
   t = (*rpn++);
   t |= (*rpn++) << 8;
   t |= (*rpn++) << 16;
   t |= (*rpn++) << 24;
   rpnpush(getsymvalue(t));
   pPatch->oRelocPatch |= (getsymbank(t) != -1);
   size -= 4;
   break;
  case RPN_BANK:
   t = (*rpn++);
   t |= (*rpn++) << 8;
   t |= (*rpn++) << 16;
   t |= (*rpn++) << 24;
   rpnpush(getsymbank(t));
   size -= 4;
   break;
  case RPN_RANGECHECK:
   {
    SLONG low, high;
    low = (*rpn++);
    low |= (*rpn++) << 8;
    low |= (*rpn++) << 16;
    low |= (*rpn++) << 24;
    high = (*rpn++);
    high |= (*rpn++) << 8;
    high |= (*rpn++) << 16;
    high |= (*rpn++) << 24;
    t = rpnpop();
    if (t < low || t > high) {
     sprintf(temptext,
      "%s(%ld) : Value must be in the range [%ld;%ld]",
      pPatch->pzFilename,
      pPatch->nLineNo, low, high);
     fatalerror(temptext);
    }
    rpnpush(t);
    size -= 8;
    break;
   }
  }
 }
 return (rpnpop());
}

canonical_original_code:
long calcrpn(struct sPatch *pPatch)
{
 long t; long size;
 unsigned char *rpn;
 rpnp = 0;
 size = pPatch->nRPNSize;
 rpn = pPatch->pRPN;
 pPatch->oRelocPatch = 0;
 while (size > 0) {
  size -= 1;
  switch (*rpn++) {
  case RPN_ADD:
   rpnpush(rpnpop() + rpnpop());
   break;
  case RPN_SUB:
   t = rpnpop();
   rpnpush(rpnpop() - t);
   break;
  case RPN_MUL:
   rpnpush(rpnpop() * rpnpop());
   break;
  case RPN_DIV:
   t = rpnpop();
   rpnpush(rpnpop() / t);
   break;
  case RPN_MOD:
   t = rpnpop();
   rpnpush(rpnpop() % t);
   break;
  case RPN_UNSUB:
   rpnpush(-rpnpop());
   break;
  case RPN_OR:
   rpnpush(rpnpop() | rpnpop());
   break;
  case RPN_AND:
   rpnpush(rpnpop() & rpnpop());
   break;
  case RPN_XOR:
   rpnpush(rpnpop() ^ rpnpop());
   break;
  case RPN_UNNOT:
   rpnpush(rpnpop() ^ 0xFFFFFFFF);
   break;
  case RPN_LOGAND:
   rpnpush(rpnpop() && rpnpop());
   break;
  case RPN_LOGOR:
   rpnpush(rpnpop() || rpnpop());
   break;
  case RPN_LOGUNNOT:
   rpnpush(!rpnpop());
   break;
  case RPN_LOGEQ:
   rpnpush(rpnpop() == rpnpop());
   break;
  case RPN_LOGNE:
   rpnpush(rpnpop() != rpnpop());
   break;
  case RPN_LOGGT:
   t = rpnpop();
   rpnpush(rpnpop() > t);
   break;
  case RPN_LOGLT:
   t = rpnpop();
   rpnpush(rpnpop() < t);
   break;
  case RPN_LOGGE:
   t = rpnpop();
   rpnpush(rpnpop() >= t);
   break;
  case RPN_LOGLE:
   t = rpnpop();
   rpnpush(rpnpop() <= t);
   break;
  case RPN_SHL:
   t = rpnpop();
   rpnpush(rpnpop() << t);
   break;
  case RPN_SHR:
   t = rpnpop();
   rpnpush(rpnpop() >> t);
   break;
  case RPN_HRAM:
   t = rpnpop();
   rpnpush(t & 0xFF);
   if (t < 0 || (t > 0xFF && t < 0xFF00) || t > 0xFFFF) {
    sprintf(temptext,
     "%s(%ld) : Value must be in the HRAM area",
     pPatch->pzFilename, pPatch->nLineNo);
    fatalerror(temptext);
   }
   break;
  case RPN_PCEZP:
   t = rpnpop();
   rpnpush(t & 0xFF);
   if (t < 0x2000 || t > 0x20FF) {
    sprintf(temptext,
     "%s(%ld) : Value must be in the ZP area",
     pPatch->pzFilename, pPatch->nLineNo);
    fatalerror(temptext);
   }
   break;
  case RPN_CONST:
   t = (*rpn++);
   t |= (*rpn++) << 8;
   t |= (*rpn++) << 16;
   t |= (*rpn++) << 24;
   rpnpush(t);
   size -= 4;
   break;
  case RPN_SYM:
   t = (*rpn++);
   t |= (*rpn++) << 8;
   t |= (*rpn++) << 16;
   t |= (*rpn++) << 24;
   rpnpush(getsymvalue(t));
   pPatch->oRelocPatch |= (getsymbank(t) != -1);
   size -= 4;
   break;
  case RPN_BANK:
   t = (*rpn++);
   t |= (*rpn++) << 8;
   t |= (*rpn++) << 16;
   t |= (*rpn++) << 24;
   rpnpush(getsymbank(t));
   size -= 4;
   break;
  case RPN_RANGECHECK:
   {
    long low; long high;
    low = (*rpn++);
    low |= (*rpn++) << 8;
    low |= (*rpn++) << 16;
    low |= (*rpn++) << 24;
    high = (*rpn++);
    high |= (*rpn++) << 8;
    high |= (*rpn++) << 16;
    high |= (*rpn++) << 24;
    t = rpnpop();
    if (t < low || t > high) {
     sprintf(temptext,
      "%s(%ld) : Value must be in the range [%ld;%ld]",
      pPatch->pzFilename,
      pPatch->nLineNo, low, high);
     fatalerror(temptext);
    }
    rpnpush(t);
    size -= 8;
    break;
   }
  }
 }
 return (rpnpop());
}

variable_types: struct sPatch { char *pzFilename; long nLineNo; long nOffset; enum ePatchType { PATCH_BYTE=0, PATCH_WORD_L=1, PATCH_LONG_L=2, PATCH_WORD_B=3, PATCH_LONG_B=4 } Type; long nRPNSize; unsigned char *pRPN; struct sPatch *pNext; char oRelocPatch; } *

variable_types: t long

variable_types: size long

variable_types:
rpn
unsigned char *

variable_types: low long

variable_types: high long


Patch

original_code:
void Patch(void)
{
 struct sSection *pSect;
 pSect = pSections;
 while (pSect) {
  struct sPatch *pPatch;
  pCurrentSection = pSect;
  pPatch = pSect->pPatches;
  while (pPatch) {
   SLONG t;
   nPC = pSect->nOrg + pPatch->nOffset;
   t = calcrpn(pPatch);
   switch (pPatch->Type) {
   case PATCH_BYTE:
    if (t >= -128 && t <= 255) {
     t &= 0xFF;
     pSect->pData[pPatch->nOffset] =
         (UBYTE) t;
    } else {
     sprintf(temptext,
      "%s(%ld) : Value must be 8-bit\n",
      pPatch->pzFilename,
      pPatch->nLineNo);
     fatalerror(temptext);
    }
    break;
   case PATCH_WORD_L:
   case PATCH_WORD_B:
    if (t >= -32768 && t <= 65535) {
     t &= 0xFFFF;
     if (pPatch->Type == PATCH_WORD_L) {
      pSect->pData[pPatch->nOffset] =
          t & 0xFF;
      pSect->pData[pPatch->nOffset +
            1] =
          (t >> 8) & 0xFF;
     } else {
      pSect->pData[pPatch->nOffset] =
          (t >> 8) & 0xFF;
      pSect->pData[pPatch->nOffset +
            1] = t & 0xFF;
     }
    } else {
     sprintf(temptext,
      "%s(%ld) : Value must be 16-bit\n",
      pPatch->pzFilename,
      pPatch->nLineNo);
     fatalerror(temptext);
    }
    break;
   case PATCH_LONG_L:
    pSect->pData[pPatch->nOffset + 0] = t & 0xFF;
    pSect->pData[pPatch->nOffset + 1] =
        (t >> 8) & 0xFF;
    pSect->pData[pPatch->nOffset + 2] =
        (t >> 16) & 0xFF;
    pSect->pData[pPatch->nOffset + 3] =
        (t >> 24) & 0xFF;
    break;
   case PATCH_LONG_B:
    pSect->pData[pPatch->nOffset + 0] =
        (t >> 24) & 0xFF;
    pSect->pData[pPatch->nOffset + 1] =
        (t >> 16) & 0xFF;
    pSect->pData[pPatch->nOffset + 2] =
        (t >> 8) & 0xFF;
    pSect->pData[pPatch->nOffset + 3] = t & 0xFF;
    break;
   }
   pPatch = pPatch->pNext;
  }
  pSect = pSect->pNext;
 }
}

canonical_original_code:
void Patch()
{
 struct sSection *pSect;
 pSect = pSections;
 while (pSect) {
  struct sPatch *pPatch;
  pCurrentSection = pSect;
  pPatch = pSect->pPatches;
  while (pPatch) {
   long t;
   nPC = pSect->nOrg + pPatch->nOffset;
   t = calcrpn(pPatch);
   switch (pPatch->Type) {
   case PATCH_BYTE:
    if (t >= -128 && t <= 255) {
     t &= 0xFF;
     pSect->pData[pPatch->nOffset] =
         (unsigned char) t;
    } else {
     sprintf(temptext,
      "%s(%ld) : Value must be 8-bit\n",
      pPatch->pzFilename,
      pPatch->nLineNo);
     fatalerror(temptext);
    }
    break;
   case PATCH_WORD_L:
   case PATCH_WORD_B:
    if (t >= -32768 && t <= 65535) {
     t &= 0xFFFF;
     if (pPatch->Type == PATCH_WORD_L) {
      pSect->pData[pPatch->nOffset] =
          t & 0xFF;
      pSect->pData[pPatch->nOffset +
            1] =
          (t >> 8) & 0xFF;
     } else {
      pSect->pData[pPatch->nOffset] =
          (t >> 8) & 0xFF;
      pSect->pData[pPatch->nOffset +
            1] = t & 0xFF;
     }
    } else {
     sprintf(temptext,
      "%s(%ld) : Value must be 16-bit\n",
      pPatch->pzFilename,
      pPatch->nLineNo);
     fatalerror(temptext);
    }
    break;
   case PATCH_LONG_L:
    pSect->pData[pPatch->nOffset + 0] = t & 0xFF;
    pSect->pData[pPatch->nOffset + 1] =
        (t >> 8) & 0xFF;
    pSect->pData[pPatch->nOffset + 2] =
        (t >> 16) & 0xFF;
    pSect->pData[pPatch->nOffset + 3] =
        (t >> 24) & 0xFF;
    break;
   case PATCH_LONG_B:
    pSect->pData[pPatch->nOffset + 0] =
        (t >> 24) & 0xFF;
    pSect->pData[pPatch->nOffset + 1] =
        (t >> 16) & 0xFF;
    pSect->pData[pPatch->nOffset + 2] =
        (t >> 8) & 0xFF;
    pSect->pData[pPatch->nOffset + 3] = t & 0xFF;
    break;
   }
   pPatch = pPatch->pNext;
  }
  pSect = pSect->pNext;
 }
}


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

result = 0LL;
while ( CurrentOptions[result + 8] != a1 )
{
if ( ++result == 4 )
return 0LL;
}
return result;
}

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

result = 0LL;
while ( CurrentOptions[result + 8] != a1 )
{
if ( ++result == 4 )
return 0LL;
}
return result;
}

original_code:
SLONG gbgfx2bin(char ch)
{
 SLONG i;
 for (i = 0; i <= 3; i += 1) {
  if (CurrentOptions.gbgfx[i] == ch) {
   return (i);
  }
 }
 return (0);
}

canonical_original_code:
long gbgfx2bin(char ch)
{
 long i;
 for (i = 0; i <= 3; i += 1) {
  if (CurrentOptions.gbgfx[i] == ch) {
   return (i);
  }
 }
 return (0);
}

variable_types: ch char


decompiled_code:
_BOOL8 __fastcall binary2bin(unsigned __int8 a1)
{
_BOOL8 result; // rax

if ( a1 == CurrentOptions[12] )
result = 0LL;
else
result = CurrentOptions[13] == a1;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(unsigned __int8 a1)
{
_BOOL8 result; // rax

if ( a1 == CurrentOptions[12] )
result = 0LL;
else
result = CurrentOptions[13] == a1;
return result;
}

original_code:
SLONG binary2bin(char ch)
{
 SLONG i;
 for (i = 0; i <= 1; i += 1) {
  if (CurrentOptions.binary[i] == ch) {
   return (i);
  }
 }
 return (0);
}

canonical_original_code:
long binary2bin(char ch)
{
 long i;
 for (i = 0; i <= 1; i += 1) {
  if (CurrentOptions.binary[i] == ch) {
   return (i);
  }
 }
 return (0);
}


decompiled_code:
__int64 __fastcall char2bin(char a1)
{
unsigned __int8 v1; // di
__int64 result; // rax

if ( (unsigned __int8)(a1 - 97) <= 5u )
return (char)(a1 - 87);
if ( (unsigned __int8)(a1 - 65) <= 5u )
return (char)(a1 - 55);
v1 = a1 - 48;
result = (char)v1;
if ( v1 >= 0xAu )
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(char a1)
{
unsigned __int8 v1; // di
__int64 result; // rax

if ( (unsigned __int8)(a1 - 97) <= 5u )
return (char)(a1 - 87);
if ( (unsigned __int8)(a1 - 65) <= 5u )
return (char)(a1 - 55);
v1 = a1 - 48;
result = (char)v1;
if ( v1 >= 0xAu )
result = 0LL;
return result;
}

original_code:
SLONG char2bin(char ch)
{
 if (ch >= 'a' && ch <= 'f')
  return (ch - 'a' + 10);
 if (ch >= 'A' && ch <= 'F')
  return (ch - 'A' + 10);
 if (ch >= '0' && ch <= '9')
  return (ch - '0');
 return (0);
}


ParseFixedPoint

decompiled_code:
__int64 __fastcall ParseFixedPoint(char *nptr, __int64 a2)
{
__int64 v3; // rdi
__int64 v4; // rdx
__int64 v5; // rax

v3 = a2;
if ( a2 )
{
v4 = 0LL;
v5 = 0LL;
do
{
if ( nptr[v5] == 46 && ++v4 == 2 )
break;
++v5;
--v3;
}
while ( v3 );
}
yyunputbytes(v3);
*(_QWORD *)&yylval = (unsigned int)(int)(atof(nptr) * 65536.0);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *nptr, __int64 a2)
{
__int64 v3; // rdi
__int64 v4; // rdx
__int64 v5; // rax

v3 = a2;
if ( a2 )
{
v4 = 0LL;
v5 = 0LL;
do
{
if ( nptr[v5] == 46 && ++v4 == 2 )
break;
++v5;
--v3;
}
while ( v3 );
}
yyunputbytes(v3);
*(_QWORD *)&yylval = (unsigned int)(int)(atof(nptr) * 65536.0);
return 1LL;
}

original_code:
ULONG ParseFixedPoint(char *s, ULONG size)
{
 char dest[256];
 ULONG i = 0, dot = 0;
 while (size && dot != 2) {
  if (s[i] == '.')
   dot += 1;
  if (dot < 2) {
   dest[i] = s[i];
   size -= 1;
   i += 1;
  }
 }
 dest[i] = 0;
 yyunputbytes(size);
 yylval.nConstValue = (SLONG) (atof(s) * 65536);
 return (1);
}

canonical_original_code:
unsigned long ParseFixedPoint(char *s, unsigned long size)
{
 char dest[256];
 unsigned long i = 0; unsigned long dot = 0;
 while (size && dot != 2) {
  if (s[i] == '.')
   dot += 1;
  if (dot < 2) {
   dest[i] = s[i];
   size -= 1;
   i += 1;
  }
 }
 dest[i] = 0;
 yyunputbytes(size);
 yylval.nConstValue = (SLONG) (atof(s) * 65536);
 return (1);
}

variable_types:
s
char *

variable_types:
size
unsigned long

variable_types:
dest
char [256]

variable_types:
i
unsigned long

variable_types:
dot
unsigned long

return_type: unsigned long


PutUniqueArg

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

yyskipbytes(a2);
v2 = sym_FindMacroArg(-1LL);
yyunputstr(v2);
return 0LL;
}

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

yyskipbytes(a2);
v2 = sym_FindMacroArg(-1LL);
yyunputstr(v2);
return 0LL;
}

original_code:
ULONG PutUniqueArg(char *src, ULONG size)
{
 src = src;
 yyskipbytes(size);
 yyunputstr(sym_FindMacroArg(-1));
 return (0);
}

canonical_original_code:
unsigned long PutUniqueArg(char *src, unsigned long size)
{
 src = src;
 yyskipbytes(size);
 yyunputstr(sym_FindMacroArg(-1));
 return (0);
}

variable_types:
src
char *


ParseSymbol

decompiled_code:
__int64 __fastcall ParseSymbol(char *a1, __int64 a2)
{
__int64 v3; // r13
int v4; // ebx
__int64 v5; // rdx
char v6; // al
__int64 v7; // rdi
char *v8; // rcx
char v9; // dl
__int64 v10; // rax
char *v11; // rcx
bool v12; // zf
__int64 result; // rax
char *v14; // rbx
char v15; // al
char v16; // [rsp+1h] [rbp-139h]
char v17[312]; // [rsp+2h] [rbp-138h] BYREF

if ( !a2 )
{
v4 = 0;
goto LABEL_17;
}
v3 = a2;
v4 = 0;
do
{
v6 = *a1;
if ( *a1 != 92 )
{
v5 = v4;
++a1;
--v3;
++v4;
v17[v5] = v6;
LABEL_4:
if ( !v3 )
break;
continue;
}
v7 = a1[1];
if ( (_BYTE)v7 == 64 )
{
v8 = (char *)sym_FindMacroArg(-1LL);
}
else
{
if ( (unsigned __int8)(v7 - 48) > 9u )
{
fatalerror("Malformed ID");
return 0LL;
}
v8 = (char *)sym_FindMacroArg(v7);
}
a1 += 2;
v3 -= 2LL;
if ( !v8 )
goto LABEL_4;
v9 = *v8;
if ( !*v8 )
goto LABEL_4;
v10 = v4 + 1;
v11 = &v8[-v4];
do
{
*(&v16 + v10) = v9;
v4 = v10++;
v9 = v11[v10 - 1];
}
while ( v9 );
if ( !v3 )
break;
}
while ( v4 <= 255 );
if ( v4 > 256 )
fatalerror("Symbol too long");
LABEL_17:
v12 = oDontExpandStrings == 0;
v17[v4] = 0;
if ( v12 && sym_isString(v17) )
{
yyskipbytes((int)a2);
v14 = (char *)sym_GetStringValue(v17);
yyunputstr(v14);
while ( 1 )
{
v15 = *v14;
if ( !*v14 )
break;
while ( 1 )
{
++v14;
if ( v15 != 10 )
break;
--nLineNo;
v15 = *v14;
if ( !*v14 )
goto LABEL_26;
}
}
LABEL_26:
result = 0LL;
}
else
{
strcpy(&yylval, v17);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(char *a1, __int64 a2)
{
__int64 v3; // r13
int v4; // ebx
__int64 v5; // rdx
char v6; // al
__int64 v7; // rdi
char *v8; // rcx
char v9; // dl
__int64 v10; // rax
char *v11; // rcx
bool v12; // zf
__int64 result; // rax
char *v14; // rbx
char v15; // al
char v16; // [rsp+1h] [rbp-139h]
char v17[312]; // [rsp+2h] [rbp-138h] BYREF

if ( !a2 )
{
v4 = 0;
goto LABEL_17;
}
v3 = a2;
v4 = 0;
do
{
v6 = *a1;
if ( *a1 != 92 )
{
v5 = v4;
++a1;
--v3;
++v4;
v17[v5] = v6;
LABEL_4:
if ( !v3 )
break;
continue;
}
v7 = a1[1];
if ( (_BYTE)v7 == 64 )
{
v8 = (char *)sym_FindMacroArg(-1LL);
}
else
{
if ( (unsigned __int8)(v7 - 48) > 9u )
{
fatalerror("Malformed ID");
return 0LL;
}
v8 = (char *)sym_FindMacroArg(v7);
}
a1 += 2;
v3 -= 2LL;
if ( !v8 )
goto LABEL_4;
v9 = *v8;
if ( !*v8 )
goto LABEL_4;
v10 = v4 + 1;
v11 = &v8[-v4];
do
{
*(&v16 + v10) = v9;
v4 = v10++;
v9 = v11[v10 - 1];
}
while ( v9 );
if ( !v3 )
break;
}
while ( v4 <= 255 );
if ( v4 > 256 )
fatalerror("Symbol too long");
LABEL_17:
v12 = oDontExpandStrings == 0;
v17[v4] = 0;
if ( v12 && sym_isString(v17) )
{
yyskipbytes((int)a2);
v14 = (char *)sym_GetStringValue(v17);
yyunputstr(v14);
while ( 1 )
{
v15 = *v14;
if ( !*v14 )
break;
while ( 1 )
{
++v14;
if ( v15 != 10 )
break;
--nLineNo;
v15 = *v14;
if ( !*v14 )
goto LABEL_26;
}
}
LABEL_26:
result = 0LL;
}
else
{
strcpy(&yylval, v17);
result = 1LL;
}
return result;
}

original_code:
ULONG ParseSymbol(char *src, ULONG size)
{
 char dest[256 + 1];
 int copied = 0, size_backup = size;
 while (size && copied < 256) {
  if (*src == '\\') {
   char *marg;
   src += 1;
   size -= 1;
   if (*src == '@')
    marg = sym_FindMacroArg(-1);
   else if (*src >= '0' && *src <= '9')
    marg = sym_FindMacroArg(*src);
   else {
    fatalerror("Malformed ID");
    return (0);
   }
   src += 1;
   size -= 1;
   if (marg) {
    while (*marg)
     dest[copied++] = *marg++;
   }
  } else {
   dest[copied++] = *src++;
   size -= 1;
  }
 }
 if (copied > 256)
  fatalerror("Symbol too long");
 dest[copied] = 0;
 if (oDontExpandStrings == 0 && sym_isString(dest)) {
  char *s;
  yyskipbytes(size_backup);
  yyunputstr(s = sym_GetStringValue(dest));
  while (*s) {
   if (*s++ == '\n') {
    nLineNo -= 1;
   }
  }
  return (0);
 } else {
  strcpy(yylval.tzString, dest);
  return (1);
 }
}

canonical_original_code:
unsigned long ParseSymbol(char *src, unsigned long size)
{
 char dest[-1];
 int copied = 0; int size_backup = size;
 while (size && copied < 256) {
  if (*src == '\\') {
   char *marg;
   src += 1;
   size -= 1;
   if (*src == '@')
    marg = sym_FindMacroArg(-1);
   else if (*src >= '0' && *src <= '9')
    marg = sym_FindMacroArg(*src);
   else {
    fatalerror("Malformed ID");
    return (0);
   }
   src += 1;
   size -= 1;
   if (marg) {
    while (*marg)
     dest[copied++] = *marg++;
   }
  } else {
   dest[copied++] = *src++;
   size -= 1;
  }
 }
 if (copied > 256)
  fatalerror("Symbol too long");
 dest[copied] = 0;
 if (oDontExpandStrings == 0 && sym_isString(dest)) {
  char *s;
  yyskipbytes(size_backup);
  yyunputstr(s = sym_GetStringValue(dest));
  while (*s) {
   if (*s++ == '\n') {
    nLineNo -= 1;
   }
  }
  return (0);
 } else {
  strcpy(yylval.tzString, dest);
  return (1);
 }
}

variable_types:
dest
char [-1]

variable_types: copied int

variable_types:
marg
char *


PutMacroArg

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

yyskipbytes(a2);
v2 = sym_FindMacroArg(*(char *)(a1 + 1) - 48);
if ( v2 )
yyunputstr(v2);
else
yyerror("Macro argument not defined");
return 0LL;
}

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

yyskipbytes(a2);
v2 = sym_FindMacroArg(*(char *)(a1 + 1) - 48);
if ( v2 )
yyunputstr(v2);
else
yyerror("Macro argument not defined");
return 0LL;
}

original_code:
ULONG PutMacroArg(char *src, ULONG size)
{
 char *s;
 yyskipbytes(size);
 if ((s = sym_FindMacroArg(src[1] - '0')) != ((void *)0)) {
  yyunputstr(s);
 } else {
  yyerror("Macro argument not defined");
 }
 return (0);
}

canonical_original_code:
unsigned long PutMacroArg(char *src, unsigned long size)
{
 char *s;
 yyskipbytes(size);
 if ((s = sym_FindMacroArg(src[1] - '0')) != ((void *)0)) {
  yyunputstr(s);
 } else {
  yyerror("Macro argument not defined");
 }
 return (0);
}


decompiled_code:
__int64 __fastcall ascii2bin(char *a1)
{
char *v1; // r13
char v2; // di
_BOOL8 (__fastcall *v3)(unsigned __int8); // rbp
__int64 v4; // r12
__int64 i; // rbx
_BOOL8 v6; // rax
char v8; // di
__int64 v9; // rax
__int64 v10; // rcx

v1 = a1;
v2 = *a1;
if ( v2 == 38 )
{
v2 = v1[1];
v3 = (_BOOL8 (__fastcall *)(unsigned __int8))char2bin;
++v1;
i = 0LL;
v4 = 8LL;
if ( !v2 )
return i;
goto LABEL_7;
}
if ( v2 > 38 )
{
v3 = (_BOOL8 (__fastcall *)(unsigned __int8))char2bin;
v4 = 10LL;
if ( v2 != 96 )
goto LABEL_7;
v8 = v1[1];
for ( i = 0LL; v8; i = ((v9 >> 1) & 1) + (((_WORD)v9 << 8) & 0x100) + 2 * i )
{
v9 = gbgfx2bin(v8);
v8 = *(_BYTE *)(v10 + 1);
}
}
else
{
if ( v2 == 36 )
{
v2 = v1[1];
v3 = (_BOOL8 (__fastcall *)(unsigned __int8))char2bin;
++v1;
i = 0LL;
v4 = 16LL;
if ( !v2 )
return i;
goto LABEL_7;
}
if ( v2 == 37 )
{
v2 = v1[1];
v3 = binary2bin;
++v1;
v4 = 2LL;
}
else
{
v3 = (_BOOL8 (__fastcall *)(unsigned __int8))char2bin;
v4 = 10LL;
}
i = 0LL;
if ( v2 )
{
LABEL_7:
i = 0LL;
do
{
v6 = v3(v2);
v2 = *++v1;
i = v6 + v4 * i;
}
while ( v2 );
return i;
}
}
return i;
}

canonical_decompiled_code:
__int64 __fastcall func7(char *a1)
{
char *v1; // r13
char v2; // di
_BOOL8 (__fastcall *v3)(unsigned __int8); // rbp
__int64 v4; // r12
__int64 i; // rbx
_BOOL8 v6; // rax
char v8; // di
__int64 v9; // rax
__int64 v10; // rcx

v1 = a1;
v2 = *a1;
if ( v2 == 38 )
{
v2 = v1[1];
v3 = (_BOOL8 (__fastcall *)(unsigned __int8))char2bin;
++v1;
i = 0LL;
v4 = 8LL;
if ( !v2 )
return i;
goto LABEL_7;
}
if ( v2 > 38 )
{
v3 = (_BOOL8 (__fastcall *)(unsigned __int8))char2bin;
v4 = 10LL;
if ( v2 != 96 )
goto LABEL_7;
v8 = v1[1];
for ( i = 0LL; v8; i = ((v9 >> 1) & 1) + (((_WORD)v9 << 8) & 0x100) + 2 * i )
{
v9 = func0(v8);
v8 = *(_BYTE *)(v10 + 1);
}
}
else
{
if ( v2 == 36 )
{
v2 = v1[1];
v3 = (_BOOL8 (__fastcall *)(unsigned __int8))char2bin;
++v1;
i = 0LL;
v4 = 16LL;
if ( !v2 )
return i;
goto LABEL_7;
}
if ( v2 == 37 )
{
v2 = v1[1];
v3 = binary2bin;
++v1;
v4 = 2LL;
}
else
{
v3 = (_BOOL8 (__fastcall *)(unsigned __int8))char2bin;
v4 = 10LL;
}
i = 0LL;
if ( v2 )
{
LABEL_7:
i = 0LL;
do
{
v6 = v3(v2);
v2 = *++v1;
i = v6 + v4 * i;
}
while ( v2 );
return i;
}
}
return i;
}

original_code:
SLONG ascii2bin(char *s)
{
 SLONG radix = 10;
 SLONG result = 0;
 x2bin convertfunc = char2bin;
 switch (*s) {
 case '$':
  radix = 16;
  s += 1;
  convertfunc = char2bin;
  break;
 case '&':
  radix = 8;
  s += 1;
  convertfunc = char2bin;
  break;
 case '`':
  radix = 4;
  s += 1;
  convertfunc = gbgfx2bin;
  break;
 case '%':
  radix = 2;
  s += 1;
  convertfunc = binary2bin;
  break;
 }
 if (radix == 4) {
  SLONG c;
  while (*s != '\0') {
   c = convertfunc(*s++);
   result = result * 2 + ((c & 1) << 8) + ((c & 2) >> 1);
  }
 } else {
  while (*s != '\0')
   result = result * radix + convertfunc(*s++);
 }
 return (result);
}

canonical_original_code:
long ascii2bin(char *s)
{
 long radix = 10;
 long result = 0;
 long (*convertfunc)(char ch) = char2bin;
 switch (*s) {
 case '$':
  radix = 16;
  s += 1;
  convertfunc = char2bin;
  break;
 case '&':
  radix = 8;
  s += 1;
  convertfunc = char2bin;
  break;
 case '`':
  radix = 4;
  s += 1;
  convertfunc = gbgfx2bin;
  break;
 case '%':
  radix = 2;
  s += 1;
  convertfunc = binary2bin;
  break;
 }
 if (radix == 4) {
  long c;
  while (*s != '\0') {
   c = convertfunc(*s++);
   result = result * 2 + ((c & 1) << 8) + ((c & 2) >> 1);
  }
 } else {
  while (*s != '\0')
   result = result * radix + convertfunc(*s++);
 }
 return (result);
}

variable_types: radix long

variable_types: result long

variable_types:
convertfunc
long (*)(char ch)

variable_types: c long


ParseNumber

decompiled_code:
__int64 __fastcall ParseNumber(char *src, size_t n)
{
char v3[264]; // [rsp+0h] [rbp-108h] BYREF

strncpy(v3, src, n);
v3[n] = 0;
*(_QWORD *)&yylval = ascii2bin(v3);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(char *src, size_t n)
{
char v3[264]; // [rsp+0h] [rbp-108h] BYREF

strncpy(v3, src, n);
v3[n] = 0;
*(_QWORD *)&yylval = func7(v3);
return 1LL;
}

original_code:
ULONG ParseNumber(char *s, ULONG size)
{
 char dest[256];
 strncpy(dest, s, size);
 dest[size] = 0;
 yylval.nConstValue = ascii2bin(dest);
 return (1);
}

canonical_original_code:
unsigned long ParseNumber(char *s, unsigned long size)
{
 char dest[256];
 strncpy(dest, s, size);
 dest[size] = 0;
 yylval.nConstValue = ascii2bin(dest);
 return (1);
}


setuplex

decompiled_code:
__int64 setuplex()
{
__int64 v0; // rbp
__int64 v1; // rbp
__int64 v2; // rbp
__int64 v3; // rbp
__int64 v4; // rbp
__int64 v5; // rbp
__int64 v6; // rbp
__int64 v7; // rbp
__int64 v8; // rbp
__int64 v9; // rax
__int64 v10; // rbp

lex_Init();
lex_AddStrings(&staticstrings);
lex_AddStrings(&localstrings);
v0 = lex_FloatAlloc(&tMacroArgToken);
lex_FloatAddFirstRange(v0, 92LL, 92LL);
lex_FloatAddSecondRange(v0, 48LL, 57LL);
v1 = lex_FloatAlloc(&tMacroUniqueToken);
lex_FloatAddFirstRange(v1, 92LL, 92LL);
lex_FloatAddSecondRange(v1, 64LL, 64LL);
v2 = lex_FloatAlloc(&tNumberToken);
lex_FloatAddFirstRange(v2, 48LL, 57LL);
lex_FloatAddSecondRange(v2, 48LL, 57LL);
lex_FloatAddRange(v2, 48LL, 57LL);
v3 = lex_FloatAlloc(&tNumberToken);
nBinaryID = v3;
lex_FloatAddFirstRange(v3, 37LL, 37LL);
lex_FloatAddSecondRange(v3, (unsigned __int16)(char)CurrentOptions[12], (unsigned __int16)(char)CurrentOptions[12]);
lex_FloatAddSecondRange(v3, (unsigned __int16)(char)CurrentOptions[13], (unsigned __int16)(char)CurrentOptions[13]);
lex_FloatAddRange(v3, (unsigned __int16)(char)CurrentOptions[12], (unsigned __int16)(char)CurrentOptions[12]);
lex_FloatAddRange(v3, (unsigned __int16)(char)CurrentOptions[13], (unsigned __int16)(char)CurrentOptions[13]);
v4 = lex_FloatAlloc(&tNumberToken);
lex_FloatAddFirstRange(v4, 38LL, 38LL);
lex_FloatAddSecondRange(v4, 48LL, 55LL);
lex_FloatAddRange(v4, 48LL, 55LL);
v5 = lex_FloatAlloc(&tNumberToken);
nGBGfxID = v5;
lex_FloatAddFirstRange(v5, 96LL, 96LL);
lex_FloatAddSecondRange(v5, (unsigned __int16)(char)CurrentOptions[8], (unsigned __int16)(char)CurrentOptions[8]);
lex_FloatAddSecondRange(v5, (unsigned __int16)(char)CurrentOptions[9], (unsigned __int16)(char)CurrentOptions[9]);
lex_FloatAddSecondRange(v5, (unsigned __int16)(char)CurrentOptions[10], (unsigned __int16)(char)CurrentOptions[10]);
lex_FloatAddSecondRange(v5, (unsigned __int16)(char)CurrentOptions[11], (unsigned __int16)(char)CurrentOptions[11]);
lex_FloatAddRange(v5, (unsigned __int16)(char)CurrentOptions[8], (unsigned __int16)(char)CurrentOptions[8]);
lex_FloatAddRange(v5, (unsigned __int16)(char)CurrentOptions[9], (unsigned __int16)(char)CurrentOptions[9]);
lex_FloatAddRange(v5, (unsigned __int16)(char)CurrentOptions[10], (unsigned __int16)(char)CurrentOptions[10]);
lex_FloatAddRange(v5, (unsigned __int16)(char)CurrentOptions[11], (unsigned __int16)(char)CurrentOptions[11]);
v6 = lex_FloatAlloc(&tNumberToken);
lex_FloatAddFirstRange(v6, 36LL, 36LL);
lex_FloatAddSecondRange(v6, 48LL, 57LL);
lex_FloatAddSecondRange(v6, 65LL, 70LL);
lex_FloatAddSecondRange(v6, 97LL, 102LL);
lex_FloatAddRange(v6, 48LL, 57LL);
lex_FloatAddRange(v6, 65LL, 70LL);
lex_FloatAddRange(v6, 97LL, 102LL);
v7 = lex_FloatAlloc(&tIDToken);
lex_FloatAddFirstRange(v7, 97LL, 122LL);
lex_FloatAddFirstRange(v7, 65LL, 90LL);
lex_FloatAddFirstRange(v7, 95LL, 95LL);
lex_FloatAddSecondRange(v7, 97LL, 122LL);
lex_FloatAddSecondRange(v7, 65LL, 90LL);
lex_FloatAddSecondRange(v7, 48LL, 57LL);
lex_FloatAddSecondRange(v7, 95LL, 95LL);
lex_FloatAddSecondRange(v7, 92LL, 92LL);
lex_FloatAddSecondRange(v7, 64LL, 64LL);
lex_FloatAddSecondRange(v7, 35LL, 35LL);
lex_FloatAddRange(v7, 97LL, 122LL);
lex_FloatAddRange(v7, 65LL, 90LL);
lex_FloatAddRange(v7, 48LL, 57LL);
lex_FloatAddRange(v7, 95LL, 95LL);
lex_FloatAddRange(v7, 92LL, 92LL);
lex_FloatAddRange(v7, 64LL, 64LL);
lex_FloatAddRange(v7, 35LL, 35LL);
v8 = lex_FloatAlloc(&tIDToken);
lex_FloatAddFirstRange(v8, 46LL, 46LL);
lex_FloatAddSecondRange(v8, 97LL, 122LL);
lex_FloatAddSecondRange(v8, 65LL, 90LL);
lex_FloatAddSecondRange(v8, 95LL, 95LL);
lex_FloatAddRange(v8, 97LL, 122LL);
lex_FloatAddRange(v8, 65LL, 90LL);
lex_FloatAddRange(v8, 48LL, 57LL);
lex_FloatAddRange(v8, 95LL, 95LL);
lex_FloatAddRange(v8, 92LL, 92LL);
lex_FloatAddRange(v8, 64LL, 64LL);
lex_FloatAddRange(v8, 35LL, 35LL);
v9 = lex_FloatAlloc(&tIDToken);
lex_FloatAddFirstRange(v9, 64LL, 64LL);
v10 = lex_FloatAlloc(&tFixedPointToken);
lex_FloatAddFirstRange(v10, 46LL, 46LL);
lex_FloatAddFirstRange(v10, 48LL, 57LL);
lex_FloatAddSecondRange(v10, 46LL, 46LL);
lex_FloatAddSecondRange(v10, 48LL, 57LL);
lex_FloatAddRange(v10, 46LL, 46LL);
return lex_FloatAddRange(v10, 48LL, 57LL);
}

canonical_decompiled_code:
__int64 func9()
{
__int64 v0; // rbp
__int64 v1; // rbp
__int64 v2; // rbp
__int64 v3; // rbp
__int64 v4; // rbp
__int64 v5; // rbp
__int64 v6; // rbp
__int64 v7; // rbp
__int64 v8; // rbp
__int64 v9; // rax
__int64 v10; // rbp

lex_Init();
lex_AddStrings(&staticstrings);
lex_AddStrings(&localstrings);
v0 = lex_FloatAlloc(&tMacroArgToken);
lex_FloatAddFirstRange(v0, 92LL, 92LL);
lex_FloatAddSecondRange(v0, 48LL, 57LL);
v1 = lex_FloatAlloc(&tMacroUniqueToken);
lex_FloatAddFirstRange(v1, 92LL, 92LL);
lex_FloatAddSecondRange(v1, 64LL, 64LL);
v2 = lex_FloatAlloc(&tNumberToken);
lex_FloatAddFirstRange(v2, 48LL, 57LL);
lex_FloatAddSecondRange(v2, 48LL, 57LL);
lex_FloatAddRange(v2, 48LL, 57LL);
v3 = lex_FloatAlloc(&tNumberToken);
nBinaryID = v3;
lex_FloatAddFirstRange(v3, 37LL, 37LL);
lex_FloatAddSecondRange(v3, (unsigned __int16)(char)CurrentOptions[12], (unsigned __int16)(char)CurrentOptions[12]);
lex_FloatAddSecondRange(v3, (unsigned __int16)(char)CurrentOptions[13], (unsigned __int16)(char)CurrentOptions[13]);
lex_FloatAddRange(v3, (unsigned __int16)(char)CurrentOptions[12], (unsigned __int16)(char)CurrentOptions[12]);
lex_FloatAddRange(v3, (unsigned __int16)(char)CurrentOptions[13], (unsigned __int16)(char)CurrentOptions[13]);
v4 = lex_FloatAlloc(&tNumberToken);
lex_FloatAddFirstRange(v4, 38LL, 38LL);
lex_FloatAddSecondRange(v4, 48LL, 55LL);
lex_FloatAddRange(v4, 48LL, 55LL);
v5 = lex_FloatAlloc(&tNumberToken);
nGBGfxID = v5;
lex_FloatAddFirstRange(v5, 96LL, 96LL);
lex_FloatAddSecondRange(v5, (unsigned __int16)(char)CurrentOptions[8], (unsigned __int16)(char)CurrentOptions[8]);
lex_FloatAddSecondRange(v5, (unsigned __int16)(char)CurrentOptions[9], (unsigned __int16)(char)CurrentOptions[9]);
lex_FloatAddSecondRange(v5, (unsigned __int16)(char)CurrentOptions[10], (unsigned __int16)(char)CurrentOptions[10]);
lex_FloatAddSecondRange(v5, (unsigned __int16)(char)CurrentOptions[11], (unsigned __int16)(char)CurrentOptions[11]);
lex_FloatAddRange(v5, (unsigned __int16)(char)CurrentOptions[8], (unsigned __int16)(char)CurrentOptions[8]);
lex_FloatAddRange(v5, (unsigned __int16)(char)CurrentOptions[9], (unsigned __int16)(char)CurrentOptions[9]);
lex_FloatAddRange(v5, (unsigned __int16)(char)CurrentOptions[10], (unsigned __int16)(char)CurrentOptions[10]);
lex_FloatAddRange(v5, (unsigned __int16)(char)CurrentOptions[11], (unsigned __int16)(char)CurrentOptions[11]);
v6 = lex_FloatAlloc(&tNumberToken);
lex_FloatAddFirstRange(v6, 36LL, 36LL);
lex_FloatAddSecondRange(v6, 48LL, 57LL);
lex_FloatAddSecondRange(v6, 65LL, 70LL);
lex_FloatAddSecondRange(v6, 97LL, 102LL);
lex_FloatAddRange(v6, 48LL, 57LL);
lex_FloatAddRange(v6, 65LL, 70LL);
lex_FloatAddRange(v6, 97LL, 102LL);
v7 = lex_FloatAlloc(&tIDToken);
lex_FloatAddFirstRange(v7, 97LL, 122LL);
lex_FloatAddFirstRange(v7, 65LL, 90LL);
lex_FloatAddFirstRange(v7, 95LL, 95LL);
lex_FloatAddSecondRange(v7, 97LL, 122LL);
lex_FloatAddSecondRange(v7, 65LL, 90LL);
lex_FloatAddSecondRange(v7, 48LL, 57LL);
lex_FloatAddSecondRange(v7, 95LL, 95LL);
lex_FloatAddSecondRange(v7, 92LL, 92LL);
lex_FloatAddSecondRange(v7, 64LL, 64LL);
lex_FloatAddSecondRange(v7, 35LL, 35LL);
lex_FloatAddRange(v7, 97LL, 122LL);
lex_FloatAddRange(v7, 65LL, 90LL);
lex_FloatAddRange(v7, 48LL, 57LL);
lex_FloatAddRange(v7, 95LL, 95LL);
lex_FloatAddRange(v7, 92LL, 92LL);
lex_FloatAddRange(v7, 64LL, 64LL);
lex_FloatAddRange(v7, 35LL, 35LL);
v8 = lex_FloatAlloc(&tIDToken);
lex_FloatAddFirstRange(v8, 46LL, 46LL);
lex_FloatAddSecondRange(v8, 97LL, 122LL);
lex_FloatAddSecondRange(v8, 65LL, 90LL);
lex_FloatAddSecondRange(v8, 95LL, 95LL);
lex_FloatAddRange(v8, 97LL, 122LL);
lex_FloatAddRange(v8, 65LL, 90LL);
lex_FloatAddRange(v8, 48LL, 57LL);
lex_FloatAddRange(v8, 95LL, 95LL);
lex_FloatAddRange(v8, 92LL, 92LL);
lex_FloatAddRange(v8, 64LL, 64LL);
lex_FloatAddRange(v8, 35LL, 35LL);
v9 = lex_FloatAlloc(&tIDToken);
lex_FloatAddFirstRange(v9, 64LL, 64LL);
v10 = lex_FloatAlloc(&tFixedPointToken);
lex_FloatAddFirstRange(v10, 46LL, 46LL);
lex_FloatAddFirstRange(v10, 48LL, 57LL);
lex_FloatAddSecondRange(v10, 46LL, 46LL);
lex_FloatAddSecondRange(v10, 48LL, 57LL);
lex_FloatAddRange(v10, 46LL, 46LL);
return lex_FloatAddRange(v10, 48LL, 57LL);
}

original_code:
void setuplex(void)
{
 ULONG id;
 lex_Init();
 lex_AddStrings(staticstrings);
 lex_AddStrings(localstrings);
 id = lex_FloatAlloc(&tMacroArgToken);
 lex_FloatAddFirstRange(id, '\\', '\\');
 lex_FloatAddSecondRange(id, '0', '9');
 id = lex_FloatAlloc(&tMacroUniqueToken);
 lex_FloatAddFirstRange(id, '\\', '\\');
 lex_FloatAddSecondRange(id, '@', '@');
 id = lex_FloatAlloc(&tNumberToken);
 lex_FloatAddFirstRange(id, '0', '9');
 lex_FloatAddSecondRange(id, '0', '9');
 lex_FloatAddRange(id, '0', '9');
 nBinaryID = id = lex_FloatAlloc(&tNumberToken);
 lex_FloatAddFirstRange(id, '%', '%');
 lex_FloatAddSecondRange(id, CurrentOptions.binary[0],
    CurrentOptions.binary[0]);
 lex_FloatAddSecondRange(id, CurrentOptions.binary[1],
    CurrentOptions.binary[1]);
 lex_FloatAddRange(id, CurrentOptions.binary[0],
     CurrentOptions.binary[0]);
 lex_FloatAddRange(id, CurrentOptions.binary[1],
     CurrentOptions.binary[1]);
 id = lex_FloatAlloc(&tNumberToken);
 lex_FloatAddFirstRange(id, '&', '&');
 lex_FloatAddSecondRange(id, '0', '7');
 lex_FloatAddRange(id, '0', '7');
 nGBGfxID = id = lex_FloatAlloc(&tNumberToken);
 lex_FloatAddFirstRange(id, '`', '`');
 lex_FloatAddSecondRange(id, CurrentOptions.gbgfx[0],
    CurrentOptions.gbgfx[0]);
 lex_FloatAddSecondRange(id, CurrentOptions.gbgfx[1],
    CurrentOptions.gbgfx[1]);
 lex_FloatAddSecondRange(id, CurrentOptions.gbgfx[2],
    CurrentOptions.gbgfx[2]);
 lex_FloatAddSecondRange(id, CurrentOptions.gbgfx[3],
    CurrentOptions.gbgfx[3]);
 lex_FloatAddRange(id, CurrentOptions.gbgfx[0], CurrentOptions.gbgfx[0]);
 lex_FloatAddRange(id, CurrentOptions.gbgfx[1], CurrentOptions.gbgfx[1]);
 lex_FloatAddRange(id, CurrentOptions.gbgfx[2], CurrentOptions.gbgfx[2]);
 lex_FloatAddRange(id, CurrentOptions.gbgfx[3], CurrentOptions.gbgfx[3]);
 id = lex_FloatAlloc(&tNumberToken);
 lex_FloatAddFirstRange(id, '$', '$');
 lex_FloatAddSecondRange(id, '0', '9');
 lex_FloatAddSecondRange(id, 'A', 'F');
 lex_FloatAddSecondRange(id, 'a', 'f');
 lex_FloatAddRange(id, '0', '9');
 lex_FloatAddRange(id, 'A', 'F');
 lex_FloatAddRange(id, 'a', 'f');
 id = lex_FloatAlloc(&tIDToken);
 lex_FloatAddFirstRange(id, 'a', 'z');
 lex_FloatAddFirstRange(id, 'A', 'Z');
 lex_FloatAddFirstRange(id, '_', '_');
 lex_FloatAddSecondRange(id, 'a', 'z');
 lex_FloatAddSecondRange(id, 'A', 'Z');
 lex_FloatAddSecondRange(id, '0', '9');
 lex_FloatAddSecondRange(id, '_', '_');
 lex_FloatAddSecondRange(id, '\\', '\\');
 lex_FloatAddSecondRange(id, '@', '@');
 lex_FloatAddSecondRange(id, '#', '#');
 lex_FloatAddRange(id, 'a', 'z');
 lex_FloatAddRange(id, 'A', 'Z');
 lex_FloatAddRange(id, '0', '9');
 lex_FloatAddRange(id, '_', '_');
 lex_FloatAddRange(id, '\\', '\\');
 lex_FloatAddRange(id, '@', '@');
 lex_FloatAddRange(id, '#', '#');
 id = lex_FloatAlloc(&tIDToken);
 lex_FloatAddFirstRange(id, '.', '.');
 lex_FloatAddSecondRange(id, 'a', 'z');
 lex_FloatAddSecondRange(id, 'A', 'Z');
 lex_FloatAddSecondRange(id, '_', '_');
 lex_FloatAddRange(id, 'a', 'z');
 lex_FloatAddRange(id, 'A', 'Z');
 lex_FloatAddRange(id, '0', '9');
 lex_FloatAddRange(id, '_', '_');
 lex_FloatAddRange(id, '\\', '\\');
 lex_FloatAddRange(id, '@', '@');
 lex_FloatAddRange(id, '#', '#');
 id = lex_FloatAlloc(&tIDToken);
 lex_FloatAddFirstRange(id, '@', '@');
 id = lex_FloatAlloc(&tFixedPointToken);
 lex_FloatAddFirstRange(id, '.', '.');
 lex_FloatAddFirstRange(id, '0', '9');
 lex_FloatAddSecondRange(id, '.', '.');
 lex_FloatAddSecondRange(id, '0', '9');
 lex_FloatAddRange(id, '.', '.');
 lex_FloatAddRange(id, '0', '9');
}

canonical_original_code:
void setuplex()
{
 unsigned long id;
 lex_Init();
 lex_AddStrings(staticstrings);
 lex_AddStrings(localstrings);
 id = lex_FloatAlloc(&tMacroArgToken);
 lex_FloatAddFirstRange(id, '\\', '\\');
 lex_FloatAddSecondRange(id, '0', '9');
 id = lex_FloatAlloc(&tMacroUniqueToken);
 lex_FloatAddFirstRange(id, '\\', '\\');
 lex_FloatAddSecondRange(id, '@', '@');
 id = lex_FloatAlloc(&tNumberToken);
 lex_FloatAddFirstRange(id, '0', '9');
 lex_FloatAddSecondRange(id, '0', '9');
 lex_FloatAddRange(id, '0', '9');
 nBinaryID = id = lex_FloatAlloc(&tNumberToken);
 lex_FloatAddFirstRange(id, '%', '%');
 lex_FloatAddSecondRange(id, CurrentOptions.binary[0],
    CurrentOptions.binary[0]);
 lex_FloatAddSecondRange(id, CurrentOptions.binary[1],
    CurrentOptions.binary[1]);
 lex_FloatAddRange(id, CurrentOptions.binary[0],
     CurrentOptions.binary[0]);
 lex_FloatAddRange(id, CurrentOptions.binary[1],
     CurrentOptions.binary[1]);
 id = lex_FloatAlloc(&tNumberToken);
 lex_FloatAddFirstRange(id, '&', '&');
 lex_FloatAddSecondRange(id, '0', '7');
 lex_FloatAddRange(id, '0', '7');
 nGBGfxID = id = lex_FloatAlloc(&tNumberToken);
 lex_FloatAddFirstRange(id, '`', '`');
 lex_FloatAddSecondRange(id, CurrentOptions.gbgfx[0],
    CurrentOptions.gbgfx[0]);
 lex_FloatAddSecondRange(id, CurrentOptions.gbgfx[1],
    CurrentOptions.gbgfx[1]);
 lex_FloatAddSecondRange(id, CurrentOptions.gbgfx[2],
    CurrentOptions.gbgfx[2]);
 lex_FloatAddSecondRange(id, CurrentOptions.gbgfx[3],
    CurrentOptions.gbgfx[3]);
 lex_FloatAddRange(id, CurrentOptions.gbgfx[0], CurrentOptions.gbgfx[0]);
 lex_FloatAddRange(id, CurrentOptions.gbgfx[1], CurrentOptions.gbgfx[1]);
 lex_FloatAddRange(id, CurrentOptions.gbgfx[2], CurrentOptions.gbgfx[2]);
 lex_FloatAddRange(id, CurrentOptions.gbgfx[3], CurrentOptions.gbgfx[3]);
 id = lex_FloatAlloc(&tNumberToken);
 lex_FloatAddFirstRange(id, '$', '$');
 lex_FloatAddSecondRange(id, '0', '9');
 lex_FloatAddSecondRange(id, 'A', 'F');
 lex_FloatAddSecondRange(id, 'a', 'f');
 lex_FloatAddRange(id, '0', '9');
 lex_FloatAddRange(id, 'A', 'F');
 lex_FloatAddRange(id, 'a', 'f');
 id = lex_FloatAlloc(&tIDToken);
 lex_FloatAddFirstRange(id, 'a', 'z');
 lex_FloatAddFirstRange(id, 'A', 'Z');
 lex_FloatAddFirstRange(id, '_', '_');
 lex_FloatAddSecondRange(id, 'a', 'z');
 lex_FloatAddSecondRange(id, 'A', 'Z');
 lex_FloatAddSecondRange(id, '0', '9');
 lex_FloatAddSecondRange(id, '_', '_');
 lex_FloatAddSecondRange(id, '\\', '\\');
 lex_FloatAddSecondRange(id, '@', '@');
 lex_FloatAddSecondRange(id, '#', '#');
 lex_FloatAddRange(id, 'a', 'z');
 lex_FloatAddRange(id, 'A', 'Z');
 lex_FloatAddRange(id, '0', '9');
 lex_FloatAddRange(id, '_', '_');
 lex_FloatAddRange(id, '\\', '\\');
 lex_FloatAddRange(id, '@', '@');
 lex_FloatAddRange(id, '#', '#');
 id = lex_FloatAlloc(&tIDToken);
 lex_FloatAddFirstRange(id, '.', '.');
 lex_FloatAddSecondRange(id, 'a', 'z');
 lex_FloatAddSecondRange(id, 'A', 'Z');
 lex_FloatAddSecondRange(id, '_', '_');
 lex_FloatAddRange(id, 'a', 'z');
 lex_FloatAddRange(id, 'A', 'Z');
 lex_FloatAddRange(id, '0', '9');
 lex_FloatAddRange(id, '_', '_');
 lex_FloatAddRange(id, '\\', '\\');
 lex_FloatAddRange(id, '@', '@');
 lex_FloatAddRange(id, '#', '#');
 id = lex_FloatAlloc(&tIDToken);
 lex_FloatAddFirstRange(id, '@', '@');
 id = lex_FloatAlloc(&tFixedPointToken);
 lex_FloatAddFirstRange(id, '.', '.');
 lex_FloatAddFirstRange(id, '0', '9');
 lex_FloatAddSecondRange(id, '.', '.');
 lex_FloatAddSecondRange(id, '0', '9');
 lex_FloatAddRange(id, '.', '.');
 lex_FloatAddRange(id, '0', '9');
}

variable_types:
id
unsigned long


decompiled_code:
__int64 __fastcall opt_SetCurrentOptions(const __m128i *a1)
{
__int64 v2; // rdi
__int64 result; // rax

if ( nGBGfxID != -1LL )
{
lex_FloatDeleteRange(nGBGfxID, (unsigned __int16)SBYTE8(CurrentOptions), (unsigned __int16)SBYTE8(CurrentOptions));
lex_FloatDeleteRange(nGBGfxID, (unsigned __int16)SBYTE9(CurrentOptions), (unsigned __int16)SBYTE9(CurrentOptions));
lex_FloatDeleteRange(nGBGfxID, (unsigned __int16)SBYTE10(CurrentOptions), (unsigned __int16)SBYTE10(CurrentOptions));
lex_FloatDeleteRange(nGBGfxID, (unsigned __int16)SBYTE11(CurrentOptions), (unsigned __int16)SBYTE11(CurrentOptions));
lex_FloatDeleteSecondRange(
nGBGfxID,
(unsigned __int16)SBYTE8(CurrentOptions),
(unsigned __int16)SBYTE8(CurrentOptions));
lex_FloatDeleteSecondRange(
nGBGfxID,
(unsigned __int16)SBYTE9(CurrentOptions),
(unsigned __int16)SBYTE9(CurrentOptions));
lex_FloatDeleteSecondRange(
nGBGfxID,
(unsigned __int16)SBYTE10(CurrentOptions),
(unsigned __int16)SBYTE10(CurrentOptions));
lex_FloatDeleteSecondRange(
nGBGfxID,
(unsigned __int16)SBYTE11(CurrentOptions),
(unsigned __int16)SBYTE11(CurrentOptions));
}
if ( nBinaryID != -1LL )
{
lex_FloatDeleteRange(
nBinaryID,
(unsigned __int16)SBYTE12(CurrentOptions),
(unsigned __int16)SBYTE12(CurrentOptions));
lex_FloatDeleteRange(
nBinaryID,
(unsigned __int16)SBYTE13(CurrentOptions),
(unsigned __int16)SBYTE13(CurrentOptions));
lex_FloatDeleteSecondRange(
nBinaryID,
(unsigned __int16)SBYTE12(CurrentOptions),
(unsigned __int16)SBYTE12(CurrentOptions));
lex_FloatDeleteSecondRange(
nBinaryID,
(unsigned __int16)SBYTE13(CurrentOptions),
(unsigned __int16)SBYTE13(CurrentOptions));
}
v2 = nGBGfxID;
CurrentOptions = (__int128)_mm_loadu_si128(a1);
result = a1[1].m128i_i64[0];
*((_QWORD *)&CurrentOptions + 2) = result;
if ( v2 != -1 )
{
lex_FloatAddRange(v2, (unsigned __int16)SBYTE8(CurrentOptions), (unsigned __int16)SBYTE8(CurrentOptions));
lex_FloatAddRange(nGBGfxID, (unsigned __int16)SBYTE9(CurrentOptions), (unsigned __int16)SBYTE9(CurrentOptions));
lex_FloatAddRange(nGBGfxID, (unsigned __int16)SBYTE10(CurrentOptions), (unsigned __int16)SBYTE10(CurrentOptions));
lex_FloatAddRange(nGBGfxID, (unsigned __int16)SBYTE11(CurrentOptions), (unsigned __int16)SBYTE11(CurrentOptions));
lex_FloatAddSecondRange(
nGBGfxID,
(unsigned __int16)SBYTE8(CurrentOptions),
(unsigned __int16)SBYTE8(CurrentOptions));
lex_FloatAddSecondRange(
nGBGfxID,
(unsigned __int16)SBYTE9(CurrentOptions),
(unsigned __int16)SBYTE9(CurrentOptions));
lex_FloatAddSecondRange(
nGBGfxID,
(unsigned __int16)SBYTE10(CurrentOptions),
(unsigned __int16)SBYTE10(CurrentOptions));
result = lex_FloatAddSecondRange(
nGBGfxID,
(unsigned __int16)SBYTE11(CurrentOptions),
(unsigned __int16)SBYTE11(CurrentOptions));
}
if ( nBinaryID != -1LL )
{
lex_FloatAddRange(nBinaryID, (unsigned __int16)SBYTE12(CurrentOptions), (unsigned __int16)SBYTE12(CurrentOptions));
lex_FloatAddRange(nBinaryID, (unsigned __int16)SBYTE13(CurrentOptions), (unsigned __int16)SBYTE13(CurrentOptions));
lex_FloatAddSecondRange(
nBinaryID,
(unsigned __int16)SBYTE12(CurrentOptions),
(unsigned __int16)SBYTE12(CurrentOptions));
result = lex_FloatAddSecondRange(
nBinaryID,
(unsigned __int16)SBYTE13(CurrentOptions),
(unsigned __int16)SBYTE13(CurrentOptions));
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(const __m128i *a1)
{
__int64 v2; // rdi
__int64 result; // rax

if ( nGBGfxID != -1LL )
{
lex_FloatDeleteRange(nGBGfxID, (unsigned __int16)SBYTE8(CurrentOptions), (unsigned __int16)SBYTE8(CurrentOptions));
lex_FloatDeleteRange(nGBGfxID, (unsigned __int16)SBYTE9(CurrentOptions), (unsigned __int16)SBYTE9(CurrentOptions));
lex_FloatDeleteRange(nGBGfxID, (unsigned __int16)SBYTE10(CurrentOptions), (unsigned __int16)SBYTE10(CurrentOptions));
lex_FloatDeleteRange(nGBGfxID, (unsigned __int16)SBYTE11(CurrentOptions), (unsigned __int16)SBYTE11(CurrentOptions));
lex_FloatDeleteSecondRange(
nGBGfxID,
(unsigned __int16)SBYTE8(CurrentOptions),
(unsigned __int16)SBYTE8(CurrentOptions));
lex_FloatDeleteSecondRange(
nGBGfxID,
(unsigned __int16)SBYTE9(CurrentOptions),
(unsigned __int16)SBYTE9(CurrentOptions));
lex_FloatDeleteSecondRange(
nGBGfxID,
(unsigned __int16)SBYTE10(CurrentOptions),
(unsigned __int16)SBYTE10(CurrentOptions));
lex_FloatDeleteSecondRange(
nGBGfxID,
(unsigned __int16)SBYTE11(CurrentOptions),
(unsigned __int16)SBYTE11(CurrentOptions));
}
if ( nBinaryID != -1LL )
{
lex_FloatDeleteRange(
nBinaryID,
(unsigned __int16)SBYTE12(CurrentOptions),
(unsigned __int16)SBYTE12(CurrentOptions));
lex_FloatDeleteRange(
nBinaryID,
(unsigned __int16)SBYTE13(CurrentOptions),
(unsigned __int16)SBYTE13(CurrentOptions));
lex_FloatDeleteSecondRange(
nBinaryID,
(unsigned __int16)SBYTE12(CurrentOptions),
(unsigned __int16)SBYTE12(CurrentOptions));
lex_FloatDeleteSecondRange(
nBinaryID,
(unsigned __int16)SBYTE13(CurrentOptions),
(unsigned __int16)SBYTE13(CurrentOptions));
}
v2 = nGBGfxID;
CurrentOptions = (__int128)_mm_loadu_si128(a1);
result = a1[1].m128i_i64[0];
*((_QWORD *)&CurrentOptions + 2) = result;
if ( v2 != -1 )
{
lex_FloatAddRange(v2, (unsigned __int16)SBYTE8(CurrentOptions), (unsigned __int16)SBYTE8(CurrentOptions));
lex_FloatAddRange(nGBGfxID, (unsigned __int16)SBYTE9(CurrentOptions), (unsigned __int16)SBYTE9(CurrentOptions));
lex_FloatAddRange(nGBGfxID, (unsigned __int16)SBYTE10(CurrentOptions), (unsigned __int16)SBYTE10(CurrentOptions));
lex_FloatAddRange(nGBGfxID, (unsigned __int16)SBYTE11(CurrentOptions), (unsigned __int16)SBYTE11(CurrentOptions));
lex_FloatAddSecondRange(
nGBGfxID,
(unsigned __int16)SBYTE8(CurrentOptions),
(unsigned __int16)SBYTE8(CurrentOptions));
lex_FloatAddSecondRange(
nGBGfxID,
(unsigned __int16)SBYTE9(CurrentOptions),
(unsigned __int16)SBYTE9(CurrentOptions));
lex_FloatAddSecondRange(
nGBGfxID,
(unsigned __int16)SBYTE10(CurrentOptions),
(unsigned __int16)SBYTE10(CurrentOptions));
result = lex_FloatAddSecondRange(
nGBGfxID,
(unsigned __int16)SBYTE11(CurrentOptions),
(unsigned __int16)SBYTE11(CurrentOptions));
}
if ( nBinaryID != -1LL )
{
lex_FloatAddRange(nBinaryID, (unsigned __int16)SBYTE12(CurrentOptions), (unsigned __int16)SBYTE12(CurrentOptions));
lex_FloatAddRange(nBinaryID, (unsigned __int16)SBYTE13(CurrentOptions), (unsigned __int16)SBYTE13(CurrentOptions));
lex_FloatAddSecondRange(
nBinaryID,
(unsigned __int16)SBYTE12(CurrentOptions),
(unsigned __int16)SBYTE12(CurrentOptions));
result = lex_FloatAddSecondRange(
nBinaryID,
(unsigned __int16)SBYTE13(CurrentOptions),
(unsigned __int16)SBYTE13(CurrentOptions));
}
return result;
}

original_code:
void opt_SetCurrentOptions(struct sOptions *pOpt)
{
 if (nGBGfxID != -1) {
  lex_FloatDeleteRange(nGBGfxID, CurrentOptions.gbgfx[0],
         CurrentOptions.gbgfx[0]);
  lex_FloatDeleteRange(nGBGfxID, CurrentOptions.gbgfx[1],
         CurrentOptions.gbgfx[1]);
  lex_FloatDeleteRange(nGBGfxID, CurrentOptions.gbgfx[2],
         CurrentOptions.gbgfx[2]);
  lex_FloatDeleteRange(nGBGfxID, CurrentOptions.gbgfx[3],
         CurrentOptions.gbgfx[3]);
  lex_FloatDeleteSecondRange(nGBGfxID, CurrentOptions.gbgfx[0],
        CurrentOptions.gbgfx[0]);
  lex_FloatDeleteSecondRange(nGBGfxID, CurrentOptions.gbgfx[1],
        CurrentOptions.gbgfx[1]);
  lex_FloatDeleteSecondRange(nGBGfxID, CurrentOptions.gbgfx[2],
        CurrentOptions.gbgfx[2]);
  lex_FloatDeleteSecondRange(nGBGfxID, CurrentOptions.gbgfx[3],
        CurrentOptions.gbgfx[3]);
 }
 if (nBinaryID != -1) {
  lex_FloatDeleteRange(nBinaryID, CurrentOptions.binary[0],
         CurrentOptions.binary[0]);
  lex_FloatDeleteRange(nBinaryID, CurrentOptions.binary[1],
         CurrentOptions.binary[1]);
  lex_FloatDeleteSecondRange(nBinaryID, CurrentOptions.binary[0],
        CurrentOptions.binary[0]);
  lex_FloatDeleteSecondRange(nBinaryID, CurrentOptions.binary[1],
        CurrentOptions.binary[1]);
 }
 CurrentOptions = *pOpt;
 if (nGBGfxID != -1) {
  lex_FloatAddRange(nGBGfxID, CurrentOptions.gbgfx[0],
      CurrentOptions.gbgfx[0]);
  lex_FloatAddRange(nGBGfxID, CurrentOptions.gbgfx[1],
      CurrentOptions.gbgfx[1]);
  lex_FloatAddRange(nGBGfxID, CurrentOptions.gbgfx[2],
      CurrentOptions.gbgfx[2]);
  lex_FloatAddRange(nGBGfxID, CurrentOptions.gbgfx[3],
      CurrentOptions.gbgfx[3]);
  lex_FloatAddSecondRange(nGBGfxID, CurrentOptions.gbgfx[0],
     CurrentOptions.gbgfx[0]);
  lex_FloatAddSecondRange(nGBGfxID, CurrentOptions.gbgfx[1],
     CurrentOptions.gbgfx[1]);
  lex_FloatAddSecondRange(nGBGfxID, CurrentOptions.gbgfx[2],
     CurrentOptions.gbgfx[2]);
  lex_FloatAddSecondRange(nGBGfxID, CurrentOptions.gbgfx[3],
     CurrentOptions.gbgfx[3]);
 }
 if (nBinaryID != -1) {
  lex_FloatAddRange(nBinaryID, CurrentOptions.binary[0],
      CurrentOptions.binary[0]);
  lex_FloatAddRange(nBinaryID, CurrentOptions.binary[1],
      CurrentOptions.binary[1]);
  lex_FloatAddSecondRange(nBinaryID, CurrentOptions.binary[0],
     CurrentOptions.binary[0]);
  lex_FloatAddSecondRange(nBinaryID, CurrentOptions.binary[1],
     CurrentOptions.binary[1]);
 }
}

variable_types: struct sOptions { unsigned long endian; char gbgfx[4]; char binary[2]; long fillchar; } *


yyerror

decompiled_code:
int __fastcall yyerror(const char *a1)
{
int result; // eax

printf("*ERROR*\t");
fstk_Dump();
result = printf(" :\n\t%s\n", a1);
++nErrors;
return result;
}

canonical_decompiled_code:
int __fastcall func1(const char *a1)
{
int result; // eax

printf("*ERROR*\t");
fstk_Dump();
result = printf(" :\n\t%s\n", a1);
++nErrors;
return result;
}

original_code:
void yyerror(char *s)
{
 printf("*ERROR*\t");
 fstk_Dump();
 printf(" :\n\t%s\n", s);
 nErrors += 1;
}


decompiled_code:
__int64 __fastcall opt_Parse(__int64 a1)
{
char v1; // al
char v2; // al
__m128i v4; // [rsp+0h] [rbp-38h] BYREF
__int64 v5; // [rsp+10h] [rbp-28h] BYREF

v5 = *((_QWORD *)&CurrentOptions + 2);
v1 = *(_BYTE *)a1;
v4 = _mm_load_si128((const __m128i *)&CurrentOptions);
if ( v1 == 103 )
{
if ( strlen((const char *)(a1 + 1)) != 4 )
{
puts("*ERROR*\t :\n\tMust specify exactly 4 characters for option 'g'");
exit(5);
}
v4.m128i_i32[2] = *(_DWORD *)(a1 + 1);
return opt_SetCurrentOptions(&v4);
}
if ( v1 > 103 )
{
if ( v1 == 122 )
{
if ( strlen((const char *)(a1 + 1)) <= 2 )
{
if ( *(_BYTE *)(a1 + 1) == 63 && !*(_BYTE *)(a1 + 2) )
{
v5 = -1LL;
return opt_SetCurrentOptions(&v4);
}
if ( (((unsigned int)_isoc99_sscanf(a1 + 1, "%lx", &v5) + 1) & 0xFFFFFFFD) == 0 )
return opt_SetCurrentOptions(&v4);
}
puts("*ERROR*\t :\n\tInvalid argument for option 'z'");
exit(5);
}
goto LABEL_21;
}
if ( v1 == 98 )
{
if ( strlen((const char *)(a1 + 1)) != 2 )
{
puts("*ERROR*\t :\n\tMust specify exactly 2 characters for option 'b'");
exit(5);
}
v4.m128i_i16[6] = *(_WORD *)(a1 + 1);
return opt_SetCurrentOptions(&v4);
}
if ( v1 != 101 )
LABEL_21:
fatalerror("Unknown option");
v2 = *(_BYTE *)(a1 + 1);
if ( v2 != 98 )
{
if ( v2 != 108 )
{
puts("*ERROR*\t :\n\tArgument to option -e must be 'b' or 'l'");
exit(5);
}
v4.m128i_i64[0] = 0LL;
puts("*WARNING*\t :\n\tEndianness forced to LITTLE for destination CPU");
return opt_SetCurrentOptions(&v4);
}
v4.m128i_i64[0] = 1LL;
puts("*WARNING*\t :\n\tEndianness forced to BIG for destination CPU");
return opt_SetCurrentOptions(&v4);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
char v1; // al
char v2; // al
__m128i v4; // [rsp+0h] [rbp-38h] BYREF
__int64 v5; // [rsp+10h] [rbp-28h] BYREF

v5 = *((_QWORD *)&CurrentOptions + 2);
v1 = *(_BYTE *)a1;
v4 = _mm_load_si128((const __m128i *)&CurrentOptions);
if ( v1 == 103 )
{
if ( strlen((const char *)(a1 + 1)) != 4 )
{
puts("*ERROR*\t :\n\tMust specify exactly 4 characters for option 'g'");
exit(5);
}
v4.m128i_i32[2] = *(_DWORD *)(a1 + 1);
return func0(&v4);
}
if ( v1 > 103 )
{
if ( v1 == 122 )
{
if ( strlen((const char *)(a1 + 1)) <= 2 )
{
if ( *(_BYTE *)(a1 + 1) == 63 && !*(_BYTE *)(a1 + 2) )
{
v5 = -1LL;
return func0(&v4);
}
if ( (((unsigned int)_isoc99_sscanf(a1 + 1, "%lx", &v5) + 1) & 0xFFFFFFFD) == 0 )
return func0(&v4);
}
puts("*ERROR*\t :\n\tInvalid argument for option 'z'");
exit(5);
}
goto LABEL_21;
}
if ( v1 == 98 )
{
if ( strlen((const char *)(a1 + 1)) != 2 )
{
puts("*ERROR*\t :\n\tMust specify exactly 2 characters for option 'b'");
exit(5);
}
v4.m128i_i16[6] = *(_WORD *)(a1 + 1);
return func0(&v4);
}
if ( v1 != 101 )
LABEL_21:
func2("Unknown option");
v2 = *(_BYTE *)(a1 + 1);
if ( v2 != 98 )
{
if ( v2 != 108 )
{
puts("*ERROR*\t :\n\tArgument to option -e must be 'b' or 'l'");
exit(5);
}
v4.m128i_i64[0] = 0LL;
puts("*WARNING*\t :\n\tEndianness forced to LITTLE for destination CPU");
return func0(&v4);
}
v4.m128i_i64[0] = 1LL;
puts("*WARNING*\t :\n\tEndianness forced to BIG for destination CPU");
return func0(&v4);
}

original_code:
void opt_Parse(char *s)
{
 struct sOptions newopt;
 newopt = CurrentOptions;
 switch (s[0]) {
 case 'e':
  switch (s[1]) {
  case 'b':
   newopt.endian = 1;
   printf
       ("*WARNING*\t :\n\tEndianness forced to BIG for destination CPU\n");
   break;
  case 'l':
   newopt.endian = 0;
   printf
       ("*WARNING*\t :\n\tEndianness forced to LITTLE for destination CPU\n");
   break;
  default:
   printf
       ("*ERROR*\t :\n\tArgument to option -e must be 'b' or 'l'\n");
   exit(5);
  }
  break;
 case 'g':
  if (strlen(&s[1]) == 4) {
   newopt.gbgfx[0] = s[1];
   newopt.gbgfx[1] = s[2];
   newopt.gbgfx[2] = s[3];
   newopt.gbgfx[3] = s[4];
  } else {
   printf
       ("*ERROR*\t :\n\tMust specify exactly 4 characters for option 'g'\n");
   exit(5);
  }
  break;
 case 'b':
  if (strlen(&s[1]) == 2) {
   newopt.binary[0] = s[1];
   newopt.binary[1] = s[2];
  } else {
   printf
       ("*ERROR*\t :\n\tMust specify exactly 2 characters for option 'b'\n");
   exit(5);
  }
  break;
 case 'z':
  if (strlen(&s[1]) <= 2) {
   if (strcmp(&s[1], "?") == 0) {
    newopt.fillchar = -1;
   } else {
    int result;
    result = sscanf(&s[1], "%lx", &newopt.fillchar);
    if (!((result == (-1)) || (result == 1))) {
     printf
         ("*ERROR*\t :\n\tInvalid argument for option 'z'\n");
     exit(5);
    }
   }
  } else {
   printf
       ("*ERROR*\t :\n\tInvalid argument for option 'z'\n");
   exit(5);
  }
  break;
 default:
  fatalerror("Unknown option");
  break;
 }
 opt_SetCurrentOptions(&newopt);
}

variable_types: struct sOptions { unsigned long endian; char gbgfx[4]; char binary[2]; long fillchar; }

variable_types: result int


decompiled_code:
__m128i *opt_Push()
{
__m128i *result; // rax
__m128i v1; // xmm0
void *v2; // rdx

result = (__m128i *)malloc(0x20uLL);
if ( !result )
fatalerror("No memory for option stack");
v1 = _mm_load_si128((const __m128i *)&CurrentOptions);
result[1].m128i_i64[0] = *((_QWORD *)&CurrentOptions + 2);
v2 = pOptionStack;
*result = v1;
result[1].m128i_i64[1] = (__int64)v2;
pOptionStack = result;
return result;
}

canonical_decompiled_code:
__m128i *func4()
{
__m128i *result; // rax
__m128i v1; // xmm0
void *v2; // rdx

result = (__m128i *)malloc(0x20uLL);
if ( !result )
func2("No memory for option stack");
v1 = _mm_load_si128((const __m128i *)&CurrentOptions);
result[1].m128i_i64[0] = *((_QWORD *)&CurrentOptions + 2);
v2 = pOptionStack;
*result = v1;
result[1].m128i_i64[1] = (__int64)v2;
pOptionStack = result;
return result;
}

original_code:
void opt_Push(void)
{
 struct sOptionStackEntry *pOpt;
 if ((pOpt =
      (struct sOptionStackEntry *)
      malloc(sizeof(struct sOptionStackEntry))) != ((void *)0)) {
  pOpt->Options = CurrentOptions;
  pOpt->pNext = pOptionStack;
  pOptionStack = pOpt;
 } else
  fatalerror("No memory for option stack");
}

canonical_original_code:
void opt_Push()
{
 struct sOptionStackEntry *pOpt;
 if ((pOpt =
      (struct sOptionStackEntry *)
      malloc(sizeof(struct sOptionStackEntry))) != ((void *)0)) {
  pOpt->Options = CurrentOptions;
  pOpt->pNext = pOptionStack;
  pOptionStack = pOpt;
 } else
  fatalerror("No memory for option stack");
}

variable_types: struct sOptionStackEntry { struct sOptions { unsigned long endian; char gbgfx[4]; char binary[2]; long fillchar; } Options; struct sOptionStackEntry *pNext; } *

user_defined_types: struct sOptionStackEntry { struct sOptions Options; struct sOptionStackEntry *pNext; }


decompiled_code:
void opt_Pop()
{
_QWORD *v0; // rbp

v0 = pOptionStack;
if ( !pOptionStack )
fatalerror("No entries in the option stack");
opt_SetCurrentOptions((const __m128i *)pOptionStack);
pOptionStack = (void *)v0[3];
free(v0);
}

canonical_decompiled_code:
void func5()
{
_QWORD *v0; // rbp

v0 = pOptionStack;
if ( !pOptionStack )
func2("No entries in the option stack");
func0((const __m128i *)pOptionStack);
pOptionStack = (void *)v0[3];
free(v0);
}

original_code:
void opt_Pop(void)
{
 if (pOptionStack) {
  struct sOptionStackEntry *pOpt;
  pOpt = pOptionStack;
  opt_SetCurrentOptions(&(pOpt->Options));
  pOptionStack = pOpt->pNext;
  free(pOpt);
 } else
  fatalerror("No entries in the option stack");
}

canonical_original_code:
void opt_Pop()
{
 if (pOptionStack) {
  struct sOptionStackEntry *pOpt;
  pOpt = pOptionStack;
  opt_SetCurrentOptions(&(pOpt->Options));
  pOptionStack = pOpt->pNext;
  free(pOpt);
 } else
  fatalerror("No entries in the option stack");
}

user_defined_types: struct sOptions { unsigned long endian; char gbgfx[4]; char binary[2]; long fillchar; }


fatalerror

decompiled_code:
void __fastcall __noreturn fatalerror(const char *a1)
{
yyerror(a1);
exit(5);
}

canonical_decompiled_code:
void __fastcall __noreturn func2(const char *a1)
{
func1(a1);
exit(5);
}

original_code:
void fatalerror(char *s)
{
 yyerror(s);
 exit(5);
}

variable_types:
s
char *


PrintUsage

decompiled_code:
void __noreturn PrintUsage()
{
puts("RGBAsm v1.08c (part of ASMotor 1.10-linux-g74eea59)\n\nUsage: rgbasm [options] asmfile");
puts("Options:");
puts("\t-h\t\tThis text");
puts("\t-i<path>\tExtra include path");
puts("\t-o<file>\tWrite objectoutput to <file>");
puts("\t-e(l|b)\t\tChange endianness (CAUTION!)");
puts("\t-g<ASCI>\tChange the four characters used for Gameboy graphics\n\t\t\tconstants (default is 0123)");
puts("\t-b<AS>\t\tChange the two characters used for binary constants\n\t\t\t(default is 01)");
puts("\t-z<hx>\t\tSet the byte value (hex format) used for uninitialised\n\t\t\tdata (default is ? for random)");
exit(0);
}

canonical_decompiled_code:
void __noreturn func6()
{
puts("RGBAsm v1.08c (part of ASMotor 1.10-linux-g74eea59)\n\nUsage: rgbasm [options] asmfile");
puts("Options:");
puts("\t-h\t\tThis text");
puts("\t-i<path>\tExtra include path");
puts("\t-o<file>\tWrite objectoutput to <file>");
puts("\t-e(l|b)\t\tChange endianness (CAUTION!)");
puts("\t-g<ASCI>\tChange the four characters used for Gameboy graphics\n\t\t\tconstants (default is 0123)");
puts("\t-b<AS>\t\tChange the two characters used for binary constants\n\t\t\t(default is 01)");
puts("\t-z<hx>\t\tSet the byte value (hex format) used for uninitialised\n\t\t\tdata (default is ? for random)");
exit(0);
}

original_code:
void PrintUsage(void)
{
 printf("RGBAsm" " v" "1.08c" " (part of ASMotor " "1.10-linux" "-g74eea59"
        ")\n\nUsage: " "rgbasm" " [options] asmfile\n");
 printf("Options:\n");
 printf("\t-h\t\tThis text\n");
 printf("\t-i<path>\tExtra include path\n");
 printf("\t-o<file>\tWrite objectoutput to <file>\n");
 printf("\t-e(l|b)\t\tChange endianness (CAUTION!)\n");
 printf
     ("\t-g<ASCI>\tChange the four characters used for Gameboy graphics\n"
      "\t\t\tconstants (default is 0123)\n");
 printf
     ("\t-b<AS>\t\tChange the two characters used for binary constants\n"
      "\t\t\t(default is 01)\n");
 printf
     ("\t-z<hx>\t\tSet the byte value (hex format) used for uninitialised\n"
      "\t\t\tdata (default is ? for random)\n");
 exit(0);
}

canonical_original_code:
void PrintUsage()
{
 printf("RGBAsm" " v" "1.08c" " (part of ASMotor " "1.10-linux" "-g74eea59"
        ")\n\nUsage: " "rgbasm" " [options] asmfile\n");
 printf("Options:\n");
 printf("\t-h\t\tThis text\n");
 printf("\t-i<path>\tExtra include path\n");
 printf("\t-o<file>\tWrite objectoutput to <file>\n");
 printf("\t-e(l|b)\t\tChange endianness (CAUTION!)\n");
 printf
     ("\t-g<ASCI>\tChange the four characters used for Gameboy graphics\n"
      "\t\t\tconstants (default is 0123)\n");
 printf
     ("\t-b<AS>\t\tChange the two characters used for binary constants\n"
      "\t\t\t(default is 01)\n");
 printf
     ("\t-z<hx>\t\tSet the byte value (hex format) used for uninitialised\n"
      "\t\t\tdata (default is ? for random)\n");
 exit(0);
}