cleanup

original_code:
int cleanup(struct reroutetab *rrt,struct kludges *kl) {
struct rrlist *wlk;
struct kludgelist *walkto,*wlkto;
 while(rrt->orgroot!=((void *)0)) {
  wlk=rrt->orgroot;
  rrt->orgroot=rrt->orgroot->next;
  free((void *)wlk);
 }
 while(rrt->dstroot!=((void *)0)) {
  wlk=rrt->dstroot;
  rrt->dstroot=rrt->dstroot->next;
  free((void *)wlk);
 }
 walkto=kl->root;
 while(walkto!=((void *)0)) {
  wlkto=walkto;
  walkto=walkto->next;
  free((void *)wlkto->klg.kludge);
  if (wlkto->klg.spec!=((void *)0)) {
   free((void *)wlkto->klg.spec);
  }
  if (wlkto->klg.repl!=((void *)0) && wlkto->klg.repl!=NIL) {
   free((void *)wlkto->klg.repl);
  }
  free((void *)wlkto);
 }
 return(0);
}

canonical_original_code:
int cleanup(struct reroutetab *rrt, struct kludges *kl) {
struct rrlist *wlk;
struct kludgelist *walkto; struct kludgelist *wlkto;
 while(rrt->orgroot!=((void *)0)) {
  wlk=rrt->orgroot;
  rrt->orgroot=rrt->orgroot->next;
  free((void *)wlk);
 }
 while(rrt->dstroot!=((void *)0)) {
  wlk=rrt->dstroot;
  rrt->dstroot=rrt->dstroot->next;
  free((void *)wlk);
 }
 walkto=kl->root;
 while(walkto!=((void *)0)) {
  wlkto=walkto;
  walkto=walkto->next;
  free((void *)wlkto->klg.kludge);
  if (wlkto->klg.spec!=((void *)0)) {
   free((void *)wlkto->klg.spec);
  }
  if (wlkto->klg.repl!=((void *)0) && wlkto->klg.repl!=NIL) {
   free((void *)wlkto->klg.repl);
  }
  free((void *)wlkto);
 }
 return(0);
}

variable_types: struct reroutetab { struct rrlist { struct rrlist *next; struct fidaddr { int Zone; int Net; int Node; int Point; } in; } *orgroot; struct rrlist *dstroot; } *

variable_types: struct kludges { struct kludgelist { struct kludgelist *next; struct kludge { char *kludge; char *spec; char *repl; } klg; } *root; } *


cleanuppacket

repo: ricojansen/packman

original_code:
int cleanuppacket(struct packet *pakt) {
struct msglist *walk,*ttmp;
 walk=pakt->root;
 while(walk!=((void *)0)) {
  ttmp=walk;
  walk=walk->next;
  free((void *)ttmp->Text);
  free((void *)ttmp);
 }
 pakt->root=((void *)0);
 pakt->thread=((void *)0);
 return(0);
}

canonical_original_code:
int cleanuppacket(struct packet *pakt) {
struct msglist *walk; struct msglist *ttmp;
 walk=pakt->root;
 while(walk!=((void *)0)) {
  ttmp=walk;
  walk=walk->next;
  free((void *)ttmp->Text);
  free((void *)ttmp);
 }
 pakt->root=((void *)0);
 pakt->thread=((void *)0);
 return(0);
}

variable_types: struct packet { struct PacketHeader { unsigned char origNodeLO; unsigned char origNodeHI; unsigned char destNodeLO; unsigned char destNodeHI; unsigned char yearLO; unsigned char yearHI; unsigned char monthLO; unsigned char monthHI; unsigned char dayLO; unsigned char dayHI; unsigned char hourLO; unsigned char hourHI; unsigned char minuteLO; unsigned char minuteHI; unsigned char secondLO; unsigned char secondHI; unsigned char baudLO; unsigned char baudHI; unsigned char ID1; unsigned char ID2; unsigned char origNetLO; unsigned char origNetHI; unsigned char destNetLO; unsigned char destNetHI; unsigned char prodcode; unsigned char serialno; unsigned char password[8]; unsigned char origZoneLO; unsigned char origZoneHI; unsigned char destZoneLO; unsigned char destZoneHI; unsigned char fill[20]; } pkh; struct msglist { struct msglist *next; struct PackedMessage { unsigned char origNodeLO; unsigned char origNodeHI; unsigned char destNodeLO; unsigned char destNodeHI; unsigned char origNetLO; unsigned char origNetHI; unsigned char destNetLO; unsigned char destNetHI; unsigned char AttributeLO; unsigned char AttributeHI; unsigned char costLO; unsigned char costHI; unsigned char DateTime[20]; } pmsg; char FromUser[36]; char ToUser[36]; char Subject[72]; char *Text; } *root; } *

return_type: int

user_defined_types: struct packet { struct PacketHeader pkh; struct msglist *root; }

user_defined_types: struct msglist { struct msglist *next; struct PackedMessage pmsg; char FromUser[36]; char ToUser[36]; char Subject[72]; char *Text; }


cleanupnamelist

decompiled_code:
__int64 __fastcall cleanupnamelist(void *ptr)
{
void *v1; // rbx
void *v2; // rdi

v1 = ptr;
while ( v1 )
{
v2 = v1;
v1 = (void *)*((_QWORD *)v1 + 2);
free(v2);
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(void *ptr)
{
void *v1; // rbx
void *v2; // rdi

v1 = ptr;
while ( v1 )
{
v2 = v1;
v1 = (void *)*((_QWORD *)v1 + 2);
free(v2);
}
return 0LL;
}

original_code:
int cleanupnamelist(struct namelist *root) {
struct namelist *tmp;
 while(root!=((void *)0)) {
  tmp=root;
  root=root->next;
  free(tmp);
 }
 return(0);
}

variable_types: struct namelist { char name[13]; struct namelist *next; } *


parseaddress

original_code:
int parseaddress(char *line,struct fidaddr *fid,char wild) {
char symbol;
int transport,type;
 printmsg(3,"ParseAddress\n");
 fid->Zone=fid->Net=fid->Node=fid->Point=0;
 if (wild==(00) || *line!='*') {
  if (getnum(&transport,&line)==-1) {
   goto NUMERROR;
  }
 } else {
  transport=(-1);
  line++;
 }
 START: symbol=*line;line++; keepSTART:
     type=1;
     switch(symbol) {
      case ':' :
         fid->Zone=transport;
         if (*line!='*' || wild==(00)) {
          if (getnum(&transport,&line)==-1) {
           goto NUMERROR;
          }
         } else {
          transport=(-1);
          line++;
         }
         goto ADDR3OR4;
      case '/' :
         fid->Net=transport;
         if (*line!='*' || wild==(00)) {
          if (getnum(&transport,&line)==-1) {
           goto NUMERROR;
          }
         } else {
          transport=(-1);
          line++;
         }
         goto ADDR2OR3;
      case '.' :
         fid->Node=transport;
         if (*line!='*' || wild==(00)) {
          if (getnum(&transport,&line)==-1) {
           goto NUMERROR;
          }
         } else {
          transport=(-1);
          line++;
         }
         goto ADDR2;
      default:
         fid->Node=transport;
         goto END;
     }
 ADDR3OR4: symbol=*line;line++; keepADDR3OR4:type+=1;
     if (symbol=='/') {
      fid->Net=transport;
      if (*line!='*' || wild==(00)) {
       if (getnum(&transport,&line)==-1) {
        goto NUMERROR;
       }
      } else {
       transport=(-1);
       line++;
      }
      goto ADDR2OR3;
     } else {
      goto ERROR;
     }
 ADDR2OR3: symbol=*line;line++; keepADDR2OR3:type+=1;
     if (symbol=='.') {
      fid->Node=transport;
      if (*line!='*' || wild==(00)) {
       if (getnum(&transport,&line)==-1) {
        goto NUMERROR;
       }
      } else {
       transport=(-1);
       line++;
      }
      goto ADDR2;
     } else {
      fid->Node=transport;
      goto END;
     }
 ADDR2: symbol=*line;line++; keepADDR2: type+=1;
     type+=8;
     fid->Point=transport;
     goto END;
 ERROR: symbol=*line;line++; keepERROR: printmsg(0,"Parse error malformed address\n");
     type=-1;
     goto END;
 NUMERROR: symbol=*line;line++; keepNUMERROR:printmsg(0,"Parse error invalid address\n");
     type=-1;
     goto END;
 END: symbol=*line;line++; keepEND: return(type);
}

canonical_original_code:
int parseaddress(char *line, struct fidaddr *fid, char wild) {
char symbol;
int transport; int type;
 printmsg(3,"ParseAddress\n");
 fid->Zone=fid->Net=fid->Node=fid->Point=0;
 if (wild==(00) || *line!='*') {
  if (getnum(&transport,&line)==-1) {
   goto NUMERROR;
  }
 } else {
  transport=(-1);
  line++;
 }
 START: symbol=*line;line++; keepSTART:
     type=1;
     switch(symbol) {
      case ':' :
         fid->Zone=transport;
         if (*line!='*' || wild==(00)) {
          if (getnum(&transport,&line)==-1) {
           goto NUMERROR;
          }
         } else {
          transport=(-1);
          line++;
         }
         goto ADDR3OR4;
      case '/' :
         fid->Net=transport;
         if (*line!='*' || wild==(00)) {
          if (getnum(&transport,&line)==-1) {
           goto NUMERROR;
          }
         } else {
          transport=(-1);
          line++;
         }
         goto ADDR2OR3;
      case '.' :
         fid->Node=transport;
         if (*line!='*' || wild==(00)) {
          if (getnum(&transport,&line)==-1) {
           goto NUMERROR;
          }
         } else {
          transport=(-1);
          line++;
         }
         goto ADDR2;
      default:
         fid->Node=transport;
         goto END;
     }
 ADDR3OR4: symbol=*line;line++; keepADDR3OR4:type+=1;
     if (symbol=='/') {
      fid->Net=transport;
      if (*line!='*' || wild==(00)) {
       if (getnum(&transport,&line)==-1) {
        goto NUMERROR;
       }
      } else {
       transport=(-1);
       line++;
      }
      goto ADDR2OR3;
     } else {
      goto ERROR;
     }
 ADDR2OR3: symbol=*line;line++; keepADDR2OR3:type+=1;
     if (symbol=='.') {
      fid->Node=transport;
      if (*line!='*' || wild==(00)) {
       if (getnum(&transport,&line)==-1) {
        goto NUMERROR;
       }
      } else {
       transport=(-1);
       line++;
      }
      goto ADDR2;
     } else {
      fid->Node=transport;
      goto END;
     }
 ADDR2: symbol=*line;line++; keepADDR2: type+=1;
     type+=8;
     fid->Point=transport;
     goto END;
 ERROR: symbol=*line;line++; keepERROR: printmsg(0,"Parse error malformed address\n");
     type=-1;
     goto END;
 NUMERROR: symbol=*line;line++; keepNUMERROR:printmsg(0,"Parse error invalid address\n");
     type=-1;
     goto END;
 END: symbol=*line;line++; keepEND: return(type);
}

variable_types:
line
char *

variable_types: struct fidaddr { int Zone; int Net; int Node; int Point; } *

variable_types: wild char

variable_types: symbol char

variable_types: transport int

variable_types: type int


parsespec

original_code:
int parsespec(char **text,int *pos,struct kludge *klg,struct reroutetab *rrt) {
char symbol;
char *line;
char *rep;
int repeat,type=0,keep=0,len;
 printmsg(3,"ParseSpec\n");
 line=klg->spec;
 rep=klg->repl;
 LOOP: symbol=*line;line++; keepLOOP: switch(symbol) {
      case '%' : goto TOKEN;
      case '\0': goto keepEND;
      default : if ((*text)[*pos]!=symbol) {
         printmsg(0,"Kludge spefication doesn't match\n");
         type=-1;
         goto keepEND;
           } else {
         rep++;
         (*pos)++;
         goto LOOP;
           }
     }
 TOKEN: symbol=*line;line++; keepTOKEN: if ((((*__ctype_b_loc ())[(int) ((symbol))] & (unsigned short int) _ISalnum) && !((*__ctype_b_loc ())[(int) ((symbol))] & (unsigned short int) _ISalpha))) {
      line--;
      getnum(&repeat,&line);
      goto TYPE;
     } else {
      switch(symbol) {
       case '%' : if ((*text)[*pos]!=symbol) {
          printmsg(0,"Kludge specification doesn't match\n");
          type=-1;
          goto keepEND;
            } else {
          rep++;
          (*pos)++;
          keep=0;
          goto LOOP;
            }
       case 's' : if (!keep) {
             len=0;
             while((*text)[*pos+len]!=(0x0D)) len++;
             replacestring(text,len,*pos,rep);
            }
            keep=0;
            goto keepEND;
       case 'k' : keep=1;
            goto TOKEN;
       default: printmsg(0,"Invalid kludge specification\n");
            type=-1;
            goto keepEND;
      }
     }
 TYPE: symbol=*line;line++; keepTYPE: switch(symbol) {
      case 'a' : if (repeat==0) { char *oldrep;
          oldrep=rep;
          while((*text)[*pos]!=(0x0D)) {
           doaddress(text,pos,&rep,rrt,keep);
           rep=oldrep;
           if ((*text)[*pos]!=(0x0D)) {
            while(!(((*__ctype_b_loc ())[(int) (((*text)[*pos]))] & (unsigned short int) _ISalnum) && !((*__ctype_b_loc ())[(int) (((*text)[*pos]))] & (unsigned short int) _ISalpha))) (*pos)++;
           }
          }
           } else {
          while(repeat--) {
           doaddress(text,pos,&rep,rrt,keep);
          }
           }
           keep=0;
           goto LOOP;
      case 'w' : if (repeat==0) { char *oldrep;
          oldrep=rep;
          while(*rep!='\0') {
           doword(text,pos,&rep,keep);
           rep=oldrep;
          }
           } else {
          while(repeat--) {
           doword(text,pos,&rep,keep);
          }
           }
           keep=0;
           goto LOOP;
      case 'n' : if (repeat==0) { char *oldrep;
          oldrep=rep;
          while(*rep!='\0') {
           donum(text,pos,&rep,keep);
           rep=oldrep;
          }
           } else {
          while(repeat--) {
           donum(text,pos,&rep,keep);
          }
           }
           keep=0;
           goto LOOP;
      default: keep=0;
           printmsg(0,"Unknown token in kludge specification\n");
           goto LOOP;
     }
 END: symbol=*line;line++; keepEND: return(type);
}

canonical_original_code:
int parsespec(char **text, int *pos, struct kludge *klg, struct reroutetab *rrt) {
char symbol;
char *line;
char *rep;
int repeat; int type = 0; int keep = 0; int len;
 printmsg(3,"ParseSpec\n");
 line=klg->spec;
 rep=klg->repl;
 LOOP: symbol=*line;line++; keepLOOP: switch(symbol) {
      case '%' : goto TOKEN;
      case '\0': goto keepEND;
      default : if ((*text)[*pos]!=symbol) {
         printmsg(0,"Kludge spefication doesn't match\n");
         type=-1;
         goto keepEND;
           } else {
         rep++;
         (*pos)++;
         goto LOOP;
           }
     }
 TOKEN: symbol=*line;line++; keepTOKEN: if ((((*__ctype_b_loc ())[(int) ((symbol))] & (unsigned short) _ISalnum) && !((*__ctype_b_loc ())[(int) ((symbol))] & (unsigned short) _ISalpha))) {
      line--;
      getnum(&repeat,&line);
      goto TYPE;
     } else {
      switch(symbol) {
       case '%' : if ((*text)[*pos]!=symbol) {
          printmsg(0,"Kludge specification doesn't match\n");
          type=-1;
          goto keepEND;
            } else {
          rep++;
          (*pos)++;
          keep=0;
          goto LOOP;
            }
       case 's' : if (!keep) {
             len=0;
             while((*text)[*pos+len]!=(0x0D)) len++;
             replacestring(text,len,*pos,rep);
            }
            keep=0;
            goto keepEND;
       case 'k' : keep=1;
            goto TOKEN;
       default: printmsg(0,"Invalid kludge specification\n");
            type=-1;
            goto keepEND;
      }
     }
 TYPE: symbol=*line;line++; keepTYPE: switch(symbol) {
      case 'a' : if (repeat==0) { char *oldrep;
          oldrep=rep;
          while((*text)[*pos]!=(0x0D)) {
           doaddress(text,pos,&rep,rrt,keep);
           rep=oldrep;
           if ((*text)[*pos]!=(0x0D)) {
            while(!(((*__ctype_b_loc ())[(int) (((*text)[*pos]))] & (unsigned short) _ISalnum) && !((*__ctype_b_loc ())[(int) (((*text)[*pos]))] & (unsigned short) _ISalpha))) (*pos)++;
           }
          }
           } else {
          while(repeat--) {
           doaddress(text,pos,&rep,rrt,keep);
          }
           }
           keep=0;
           goto LOOP;
      case 'w' : if (repeat==0) { char *oldrep;
          oldrep=rep;
          while(*rep!='\0') {
           doword(text,pos,&rep,keep);
           rep=oldrep;
          }
           } else {
          while(repeat--) {
           doword(text,pos,&rep,keep);
          }
           }
           keep=0;
           goto LOOP;
      case 'n' : if (repeat==0) { char *oldrep;
          oldrep=rep;
          while(*rep!='\0') {
           donum(text,pos,&rep,keep);
           rep=oldrep;
          }
           } else {
          while(repeat--) {
           donum(text,pos,&rep,keep);
          }
           }
           keep=0;
           goto LOOP;
      default: keep=0;
           printmsg(0,"Unknown token in kludge specification\n");
           goto LOOP;
     }
 END: symbol=*line;line++; keepEND: return(type);
}

variable_types:
text
char **

variable_types:
pos
int *

variable_types: struct kludge { char *kludge; char *spec; char *repl; } *

variable_types:
rep
char *

variable_types: repeat int

variable_types: keep int

variable_types: len int

variable_types:
oldrep
char *

user_defined_types: struct reroutetab { struct rrlist *orgroot; struct rrlist *dstroot; }

user_defined_types: struct rrlist { struct rrlist *next; struct fidaddr in; }

user_defined_types: struct fidaddr { int Zone; int Net; int Node; int Point; }


kludgereplace

decompiled_code:
__int64 __fastcall kludgereplace(_QWORD *a1, unsigned int *a2, __int64 **a3, __int64 a4)
{
char *v7; // rcx
char v8; // dl
__int64 v9; // rax
int v10; // esi
const char *v11; // r15
const char *v12; // rbp
size_t v13; // rax
unsigned int v14; // ebp
__int64 *v16; // rax
_BYTE *v17; // rdx
__int64 v18; // rax
int v19; // ecx
__int64 v20; // rdx
char v21; // [rsp+1h] [rbp-139h]
char v22[312]; // [rsp+2h] [rbp-138h] BYREF

printmsg(3LL, "KludgeReplace\n");
printmsg(1LL, "Kludge : ");
v7 = (char *)(*a1 + (int)*a2);
v8 = *v7;
if ( *v7 == 13 )
{
v10 = 0;
}
else
{
v9 = 1LL;
do
{
*(&v21 + v9) = v8;
v10 = v9++;
v8 = v7[v9 - 1];
}
while ( v8 != 13 );
}
v22[v10] = 0;
strcat(v22, " -> ");
printmsg(1LL, v22);
v11 = (const char *)(*a1 + (int)*a2);
while ( 1 )
{
v12 = (const char *)a3[1];
v13 = strlen(v12);
v14 = strncmp(v12, v11, v13);
if ( !v14 )
break;
a3 = (__int64 **)*a3;
if ( !a3 )
{
printmsg(1LL, "Not found\n");
return (unsigned int)-1;
}
}
v16 = a3[3];
if ( v16 )
{
if ( v16 == (__int64 *)NIL )
{
printmsg(1LL, "Remove\n");
v17 = (_BYTE *)(*a1 + (int)*a2);
if ( *v17 == 13 )
{
v19 = 0;
}
else
{
v18 = 1LL;
do
v19 = v18++;
while ( v17[v18 - 1] != 13 );
}
v20 = *a2 - 1;
*a2 = v20;
replacestring(a1, (unsigned int)(v19 + 2), v20, &unk_604);
}
else
{
printmsg(1LL, "Modify\n");
*a2 += strlen((const char *)a3[1]);
parsespec(a1, a2, (__int64)(a3 + 1), a4);
}
}
else
{
printmsg(1LL, "No Action\n");
}
return v14;
}

canonical_decompiled_code:
__int64 __fastcall func1(_QWORD *a1, unsigned int *a2, __int64 **a3, __int64 a4)
{
char *v7; // rcx
char v8; // dl
__int64 v9; // rax
int v10; // esi
const char *v11; // r15
const char *v12; // rbp
size_t v13; // rax
unsigned int v14; // ebp
__int64 *v16; // rax
_BYTE *v17; // rdx
__int64 v18; // rax
int v19; // ecx
__int64 v20; // rdx
char v21; // [rsp+1h] [rbp-139h]
char v22[312]; // [rsp+2h] [rbp-138h] BYREF

printmsg(3LL, "KludgeReplace\n");
printmsg(1LL, "Kludge : ");
v7 = (char *)(*a1 + (int)*a2);
v8 = *v7;
if ( *v7 == 13 )
{
v10 = 0;
}
else
{
v9 = 1LL;
do
{
*(&v21 + v9) = v8;
v10 = v9++;
v8 = v7[v9 - 1];
}
while ( v8 != 13 );
}
v22[v10] = 0;
strcat(v22, " -> ");
printmsg(1LL, v22);
v11 = (const char *)(*a1 + (int)*a2);
while ( 1 )
{
v12 = (const char *)a3[1];
v13 = strlen(v12);
v14 = strncmp(v12, v11, v13);
if ( !v14 )
break;
a3 = (__int64 **)*a3;
if ( !a3 )
{
printmsg(1LL, "Not found\n");
return (unsigned int)-1;
}
}
v16 = a3[3];
if ( v16 )
{
if ( v16 == (__int64 *)NIL )
{
printmsg(1LL, "Remove\n");
v17 = (_BYTE *)(*a1 + (int)*a2);
if ( *v17 == 13 )
{
v19 = 0;
}
else
{
v18 = 1LL;
do
v19 = v18++;
while ( v17[v18 - 1] != 13 );
}
v20 = *a2 - 1;
*a2 = v20;
replacestring(a1, (unsigned int)(v19 + 2), v20, &unk_604);
}
else
{
printmsg(1LL, "Modify\n");
*a2 += strlen((const char *)a3[1]);
func0(a1, a2, (__int64)(a3 + 1), a4);
}
}
else
{
printmsg(1LL, "No Action\n");
}
return v14;
}

original_code:
int kludgereplace(char **text,int *pos,struct kludgelist *klq,struct reroutetab *rrt) {
struct kludgelist *wlk;
int qq;
char txt[255];
 printmsg(3,"KludgeReplace\n");
 printmsg(1,"Kludge  : ");
 qq=0;
 while((*text)[*pos+qq]!=(0x0D)) {
  txt[qq]=(*text)[*pos+qq];
  qq++;
 }
 txt[qq]='\0';
 strcat(txt," -> ");
 printmsg(1,txt);
 wlk=klq;
 while(strncmp(wlk->klg.kludge,(*text)+*pos,strlen(wlk->klg.kludge))!=0) {
  wlk=wlk->next;
  if (wlk==((void *)0)) {
   printmsg(1,"Not found\n");
   return(-1);
  }
 }
 if (wlk->klg.repl==((void *)0)) {
   printmsg(1,"No Action\n");
   return(0);
 }
 if (wlk->klg.repl==NIL) {
  int len=0;
  printmsg(1,"Remove\n");
  while((*text)[*pos+len]!=(0x0D)) len++;
  len++;
  (*pos)--;
  replacestring(text,len+1,*pos,"");
        return(0);
 } else {
  printmsg(1,"Modify\n");
        (*pos)+=strlen(wlk->klg.kludge);
        parsespec(text,pos,&(wlk->klg),rrt);
        return(0);
    }
}

canonical_original_code:
int kludgereplace(char **text, int *pos, struct kludgelist *klq, struct reroutetab *rrt) {
struct kludgelist *wlk;
int qq;
char txt[255];
 printmsg(3,"KludgeReplace\n");
 printmsg(1,"Kludge  : ");
 qq=0;
 while((*text)[*pos+qq]!=(0x0D)) {
  txt[qq]=(*text)[*pos+qq];
  qq++;
 }
 txt[qq]='\0';
 strcat(txt," -> ");
 printmsg(1,txt);
 wlk=klq;
 while(strncmp(wlk->klg.kludge,(*text)+*pos,strlen(wlk->klg.kludge))!=0) {
  wlk=wlk->next;
  if (wlk==((void *)0)) {
   printmsg(1,"Not found\n");
   return(-1);
  }
 }
 if (wlk->klg.repl==((void *)0)) {
   printmsg(1,"No Action\n");
   return(0);
 }
 if (wlk->klg.repl==NIL) {
  int len = 0;
  printmsg(1,"Remove\n");
  while((*text)[*pos+len]!=(0x0D)) len++;
  len++;
  (*pos)--;
  replacestring(text,len+1,*pos,"");
        return(0);
 } else {
  printmsg(1,"Modify\n");
        (*pos)+=strlen(wlk->klg.kludge);
        parsespec(text,pos,&(wlk->klg),rrt);
        return(0);
    }
}

variable_types: struct kludgelist { struct kludgelist *next; struct kludge { char *kludge; char *spec; char *repl; } klg; } *

variable_types: struct reroutetab { struct rrlist { struct rrlist *next; struct fidaddr { int Zone; int Net; int Node; int Point; } in; } *orgroot; struct rrlist *dstroot; } *

variable_types: qq int

variable_types:
txt
char [255]

user_defined_types: struct kludgelist { struct kludgelist *next; struct kludge klg; }


parserepl

decompiled_code:
__int64 __fastcall parserepl(_QWORD *a1)
{
_BYTE *v1; // rax
char v2; // dl
_BYTE *v3; // rbx
__int64 result; // rax

printmsg(3LL, "ParseRepl\n");
v1 = (_BYTE *)*a1;
if ( *(_BYTE *)*a1 == 37 )
{
v2 = v1[1];
v3 = v1 + 2;
result = 2LL;
if ( v2 != 100 )
{
result = 1LL;
if ( v2 != 111 )
{
printmsg(0LL, "Unknown token in replacement specification\n");
result = 0xFFFFFFFFLL;
}
}
}
else
{
v3 = v1 + 1;
printmsg(0LL, "Replacement specification doesn't match\n");
result = 0xFFFFFFFFLL;
}
*a1 = v3;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(_QWORD *a1)
{
_BYTE *v1; // rax
char v2; // dl
_BYTE *v3; // rbx
__int64 result; // rax

printmsg(3LL, "ParseRepl\n");
v1 = (_BYTE *)*a1;
if ( *(_BYTE *)*a1 == 37 )
{
v2 = v1[1];
v3 = v1 + 2;
result = 2LL;
if ( v2 != 100 )
{
result = 1LL;
if ( v2 != 111 )
{
printmsg(0LL, "Unknown token in replacement specification\n");
result = 0xFFFFFFFFLL;
}
}
}
else
{
v3 = v1 + 1;
printmsg(0LL, "Replacement specification doesn't match\n");
result = 0xFFFFFFFFLL;
}
*a1 = v3;
return result;
}

original_code:
int parserepl(char **rep) {
char *line;
char symbol;
int type=0;
 printmsg(3,"ParseRepl\n");
 line=*rep;
 BEGIN: symbol=*line;line++; keepBEGIN: switch(symbol) {
      case '%' : goto TYPE;
      default: printmsg(0,"Replacement specification doesn't match\n");
           type=-1;
           goto keepEND;
     }
 TYPE: symbol=*line;line++; keepTYPE: switch(symbol) {
      case 'o' : type=1;
           goto keepEND;
      case 'd' : type=2;
           goto keepEND;
      default: printmsg(0,"Unknown token in replacement specification\n");
           type=-1;
           goto keepEND;
     }
 END: symbol=*line;line++; keepEND: *rep=line;
     return(type);
}

canonical_original_code:
int parserepl(char **rep) {
char *line;
char symbol;
int type = 0;
 printmsg(3,"ParseRepl\n");
 line=*rep;
 BEGIN: symbol=*line;line++; keepBEGIN: switch(symbol) {
      case '%' : goto TYPE;
      default: printmsg(0,"Replacement specification doesn't match\n");
           type=-1;
           goto keepEND;
     }
 TYPE: symbol=*line;line++; keepTYPE: switch(symbol) {
      case 'o' : type=1;
           goto keepEND;
      case 'd' : type=2;
           goto keepEND;
      default: printmsg(0,"Unknown token in replacement specification\n");
           type=-1;
           goto keepEND;
     }
 END: symbol=*line;line++; keepEND: *rep=line;
     return(type);
}

variable_types:
rep
char **

variable_types:
line
char *


repo: ricpelo/elcirculo

decompiled_code:
const void *__fastcall deduce_magic(void *s2, int a2)
{
int *v3; // rbx
int v4; // ebp
const void *v5; // rdi

v3 = (int *)&unk_370;
v4 = 0;
v5 = &unk_312;
while ( *v3 > a2 || memcmp(v5, s2, *v3) )
{
++v4;
v3 += 6;
v5 = (const void *)*((_QWORD *)v3 - 2);
if ( !v5 )
return v5;
}
return *(&off_368 + 3 * v4);
}

canonical_decompiled_code:
const void *__fastcall func0(void *s2, int a2)
{
int *v3; // rbx
int v4; // ebp
const void *v5; // rdi

v3 = (int *)&unk_370;
v4 = 0;
v5 = &unk_312;
while ( *v3 > a2 || memcmp(v5, s2, *v3) )
{
++v4;
v3 += 6;
v5 = (const void *)*((_QWORD *)v3 - 2);
if ( !v5 )
return v5;
}
return *(&off_368 + 3 * v4);
}

original_code:
static char *deduce_magic(void *sf, int32 extent)
{
 int i;
 for(i=0;magic[i].magic;i++)
 if (extent >= magic[i].len && memcmp(magic[i].magic,sf,magic[i].len)==0)
  return magic[i].name;
 return ((void *)0);
}

canonical_original_code:
static char *deduce_magic(void *sf, int extent)
{
 int i;
 for(i=0;magic[i].magic;i++)
 if (extent >= magic[i].len && memcmp(magic[i].magic,sf,magic[i].len)==0)
  return magic[i].name;
 return ((void *)0);
}

variable_types:
sf
void *

variable_types: extent int

variable_types: i int

return_type: char *


decompiled_code:
void __fastcall executable_treaty(int a1, void *a2, int a3, char *a4, int a5)
{
if ( ((a1 & 0x100) == 0 || (int)claim_story_file(a2, a3) >= 0) && ((a1 & 0x200) == 0 || a5 && a4) )
{
if ( a1 == 515 )
{
if ( a5 > 4 )
strncpy(a4, byte_315, a5);
}
else if ( a1 > 515 )
{
if ( a1 > 778 )
{
if ( a1 == 779 )
get_story_file_extension((__int64)a2, a3, a4, a5);
}
else if ( a1 <= 776 && a1 == 776 )
{
get_story_file_IFID(a2, a3, a4, a5);
}
}
else if ( a1 == 513 )
{
if ( a5 > 46 )
strcpy(a4, "http://http://en.wikipedia.org/wiki/Executable");
}
else if ( a1 > 513 && a5 > 511 )
{
strncpy(a4, "executable", a5 - 1);
}
}
}

original_code:
int32 executable_treaty(int32 selector,
                   void *story_file, int32 extent,
                   void *output, int32 output_extent)
{
 int32 ll, csf;
 if ((0x100 & selector) &&
     (csf=claim_story_file(story_file, extent))<0)
         return -1;
 if ((0x200 & selector) &&
     (output_extent ==0 ||
     output==((void *)0)))
        return -3;
 switch(selector)
 {
  case 0x201:
                do { if (output_extent < ((signed) strlen("http://http://en.wikipedia.org/wiki/Executable")+1)) return -3; } while (0);
                strcpy((char *) output,"http://http://en.wikipedia.org/wiki/Executable");
                return 0;
  case 0x202:
                do { if (output_extent < (512)) return -3; } while (0);
                strncpy((char *) output,"executable",output_extent-1);
                return 0;
  case 0x203:
                ll=(strlen(".exe")+1) < 512 ? (strlen(".exe")+1):512;
                do { if (output_extent < (ll)) return -3; } while (0);
                strncpy((char *) output, ".exe", output_extent);
                return 0;
  case 0x104:
                return csf;
  case 0x105:
  case 0x309:
                return 0;
  case 0x106:
  case 0x107:
  case 0x30A:
                return 0;
  case 0x308:
                return get_story_file_IFID(story_file, extent, (char *)output, output_extent);
  case 0x30B:
                return get_story_file_extension(story_file, extent, (char *)output, output_extent);
 }
 return -2;
}

canonical_original_code:
int executable_treaty(int selector, void *story_file, int extent, void *output, int output_extent)
{
 int ll; int csf;
 if ((0x100 & selector) &&
     (csf=claim_story_file(story_file, extent))<0)
         return -1;
 if ((0x200 & selector) &&
     (output_extent ==0 ||
     output==((void *)0)))
        return -3;
 switch(selector)
 {
  case 0x201:
                do { if (output_extent < ((int) strlen("http://http://en.wikipedia.org/wiki/Executable")+1)) return -3; } while (0);
                strcpy((char *) output,"http://http://en.wikipedia.org/wiki/Executable");
                return 0;
  case 0x202:
                do { if (output_extent < (512)) return -3; } while (0);
                strncpy((char *) output,"executable",output_extent-1);
                return 0;
  case 0x203:
                ll=(strlen(".exe")+1) < 512 ? (strlen(".exe")+1):512;
                do { if (output_extent < (ll)) return -3; } while (0);
                strncpy((char *) output, ".exe", output_extent);
                return 0;
  case 0x104:
                return csf;
  case 0x105:
  case 0x309:
                return 0;
  case 0x106:
  case 0x107:
  case 0x30A:
                return 0;
  case 0x308:
                return get_story_file_IFID(story_file, extent, (char *)output, output_extent);
  case 0x30B:
                return get_story_file_extension(story_file, extent, (char *)output, output_extent);
 }
 return -2;
}

variable_types: selector int

variable_types:
output
void *

variable_types: ll int

variable_types: csf int


decompiled_code:
_BOOL8 __fastcall claim_story_file(void *a1, int a2)
{
return deduce_magic(a1, a2) != 0LL;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(void *a1, int a2)
{
return func0(a1, a2) != 0LL;
}

original_code:
static int32 claim_story_file(void *sf, int32 extent)
{
 if (deduce_magic(sf,extent)) return 1;
 return 0;
}

canonical_original_code:
static int claim_story_file(void *sf, int extent)
{
 if (deduce_magic(sf,extent)) return 1;
 return 0;
}


decompiled_code:
__int64 __fastcall get_story_file_IFID(void *a1, int a2, char *a3, int a4)
{
const char *v6; // rax
const char *v7; // rbx
int v8; // eax
unsigned int v9; // edx

v6 = (const char *)deduce_magic(a1, a2);
if ( !v6 )
return 0;
v7 = v6;
v8 = strlen(v6);
v9 = -3;
if ( v8 + 1 < a4 )
{
strcpy(a3, v7);
*(_WORD *)&a3[strlen(a3)] = 45;
v9 = -4;
}
return v9;
}

canonical_decompiled_code:
__int64 __fastcall func2(void *a1, int a2, char *a3, int a4)
{
const char *v6; // rax
const char *v7; // rbx
int v8; // eax
unsigned int v9; // edx

v6 = (const char *)func0(a1, a2);
if ( !v6 )
return 0;
v7 = v6;
v8 = strlen(v6);
v9 = -3;
if ( v8 + 1 < a4 )
{
strcpy(a3, v7);
*(_WORD *)&a3[strlen(a3)] = 45;
v9 = -4;
}
return v9;
}

original_code:
static int32 get_story_file_IFID(void *sf, int32 extent, char *output, int32 output_extent)
{
 char *o;
 o=deduce_magic(sf,extent);
 if (!o) return 0;
 do { if (output_extent < ((signed) strlen(o)+2)) return -3; } while (0);
 strcpy(output,o);
 strcat(output,"-");
 return -4;
}

canonical_original_code:
static int get_story_file_IFID(void *sf, int extent, char *output, int output_extent)
{
 char *o;
 o=deduce_magic(sf,extent);
 if (!o) return 0;
 do { if (output_extent < ((int) strlen(o)+2)) return -3; } while (0);
 strcpy(output,o);
 strcat(output,"-");
 return -4;
}

variable_types:
output
char *

variable_types:
o
char *


decompiled_code:
size_t __fastcall get_story_file_extension(__int64 a1, int a2, void *a3, int a4)
{
__int64 v6; // rax
int v7; // ecx
char v8; // dl
__int64 v9; // rbx

if ( !a1 )
return 0xFFFFFFFFLL;
if ( !a2 )
return 0xFFFFFFFFLL;
v6 = 1LL;
do
{
v7 = v6;
v8 = byte_315[v6++];
}
while ( v8 && v8 != 44 );
if ( a4 <= v7 )
return 4294967293LL;
v9 = v7;
memcpy(a3, byte_315, v7);
*((_BYTE *)a3 + v9) = 0;
return strlen((const char *)a3);
}

canonical_decompiled_code:
size_t __fastcall func3(__int64 a1, int a2, void *a3, int a4)
{
__int64 v6; // rax
int v7; // ecx
char v8; // dl
__int64 v9; // rbx

if ( !a1 )
return 0xFFFFFFFFLL;
if ( !a2 )
return 0xFFFFFFFFLL;
v6 = 1LL;
do
{
v7 = v6;
v8 = byte_315[v6++];
}
while ( v8 && v8 != 44 );
if ( a4 <= v7 )
return 4294967293LL;
v9 = v7;
memcpy(a3, byte_315, v7);
*((_BYTE *)a3 + v9) = 0;
return strlen((const char *)a3);
}

original_code:
static int32 get_story_file_extension(void *sf, int32 extent, char *out, int32 output_extent)
{
 int i;
 if (!sf || !extent) return -1;
 for(i=0;".exe"[i] && ".exe"[i]!=',';i++);
 do { if (output_extent < (i+1)) return -3; } while (0);
 memcpy(out,".exe",i);
 out[i]=0;
 return strlen(out);
}

canonical_original_code:
static int get_story_file_extension(void *sf, int extent, char *out, int output_extent)
{
 int i;
 if (!sf || !extent) return -1;
 for(i=0;".exe"[i] && ".exe"[i]!=',';i++);
 do { if (output_extent < (i+1)) return -3; } while (0);
 memcpy(out,".exe",i);
 out[i]=0;
 return strlen(out);
}

variable_types:
out
char *


decompiled_code:
__int64 __fastcall read_l9_int(unsigned __int16 *a1)
{
return *a1;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int16 *a1)
{
return *a1;
}

original_code:
static int32 read_l9_int(unsigned char *sf)
{
 return ((int32) sf[1]) << 8 | sf[0];
}

canonical_original_code:
static int read_l9_int(unsigned char *sf)
{
 return ((int) sf[1]) << 8 | sf[0];
}

variable_types:
sf
unsigned char *


decompiled_code:
__int64 __fastcall v2_recognition(__int64 a1, int a2, int *a3, _BYTE *a4)
{
unsigned __int16 *v5; // rbx
int v6; // ebp
int v7; // er13
int v8; // eax
__int64 v9; // rax
__int64 v10; // rbp

if ( a2 <= 20 )
return 0LL;
v5 = (unsigned __int16 *)(a1 + 4);
v6 = 0;
while ( 1 )
{
if ( (unsigned int)read_l9_int(v5) == 32 && (unsigned int)read_l9_int(v5 + 3) == 0x8000 )
{
v7 = read_l9_int(v5 + 8);
if ( v7 == (unsigned int)read_l9_int(v5 + 9) )
{
v8 = read_l9_int(v5 + 12);
*a3 = v8;
if ( v8 )
{
if ( v6 + v8 <= a2 )
break;
}
}
}
++v6;
v5 = (unsigned __int16 *)((char *)v5 + 1);
if ( v6 == a2 - 20 )
return 0LL;
}
*a4 = 0;
if ( *a3 < 0 )
return 2LL;
v9 = 0LL;
v10 = a1 + v6;
do
*a4 += *(_BYTE *)(v10 + v9++);
while ( *a3 >= (int)v9 );
return 2LL;
}

original_code:
static int v2_recognition (unsigned char *sf, int32 extent, int32 *l, unsigned char *c)
{
  int32 i, j;
  for (i=0;i<extent-20;i++)
    if ((read_l9_int(sf+i+4) == 0x0020) &&
        (read_l9_int(sf+i+0x0a) == 0x8000) &&
        (read_l9_int(sf+i+0x14) == read_l9_int(sf+i+0x16)))
    {
      *l=read_l9_int(sf+i+0x1c);
      if (*l && *l+i <=extent)
       {
         *c=0;
         for(j=0;j<=*l;j++)
          *c+=sf[i+j];
         return 2;
       }
    }
 return 0;
}

canonical_original_code:
static int v2_recognition(unsigned char *sf, int extent, int *l, unsigned char *c)
{
  int i; int j;
  for (i=0;i<extent-20;i++)
    if ((read_l9_int(sf+i+4) == 0x0020) &&
        (read_l9_int(sf+i+0x0a) == 0x8000) &&
        (read_l9_int(sf+i+0x14) == read_l9_int(sf+i+0x16)))
    {
      *l=read_l9_int(sf+i+0x1c);
      if (*l && *l+i <=extent)
       {
         *c=0;
         for(j=0;j<=*l;j++)
          *c+=sf[i+j];
         return 2;
       }
    }
 return 0;
}

variable_types:
l
int *

variable_types:
c
unsigned char *

variable_types: j int


variable_types: phase int

variable_types: end int

variable_types: checksum char


original_code:
static char *get_l9_ifid(int32 length, unsigned char chk)
{
 int i;
 for(i=0;l9_registry[i].length;i++)
  if (length==l9_registry[i].length && chk==l9_registry[i].chk) return l9_registry[i].ifid;
 return ((void *)0);
}

canonical_original_code:
static char *get_l9_ifid(int length, unsigned char chk)
{
 int i;
 for(i=0;l9_registry[i].length;i++)
  if (length==l9_registry[i].length && chk==l9_registry[i].chk) return l9_registry[i].ifid;
 return ((void *)0);
}

variable_types: length int

variable_types:
chk
unsigned char


original_code:
static int v1_recognition(unsigned char *sf, int32 extent, char **ifid)
{
  int32 i;
  unsigned char a = 0xff, b = 0xff;
  for (i=0;i<extent-20;i++)
   if (memcmp(sf+i,"ATTAC",5)==0 && sf[i+5]==0xcb)
   {
    a = sf[i+6];
    break;
   }
  for (;i<(extent-20);i++)
   if (memcmp(sf+i,"BUNC",4)==0 && sf[i+4]==0xc8)
   {
    b = sf[i + 5];
    break;
   }
  if (a == 0xff && b == 0xff)
   return 0;
  if (a == 0x14 && b == 0xff) *ifid="LEVEL9-006";
  else if (a == 0x15 && b == 0x5d) *ifid="LEVEL9-013";
  else if (a == 0x1a && b == 0x24) *ifid="LEVEL9-005";
  else if (a == 0x20 && b == 0x3b) *ifid="LEVEL9-003";
  else *ifid=((void *)0);
  return 1;
}

canonical_original_code:
static int v1_recognition(unsigned char *sf, int extent, char **ifid)
{
  int i;
  unsigned char a = 0xff; unsigned char b = 0xff;
  for (i=0;i<extent-20;i++)
   if (memcmp(sf+i,"ATTAC",5)==0 && sf[i+5]==0xcb)
   {
    a = sf[i+6];
    break;
   }
  for (;i<(extent-20);i++)
   if (memcmp(sf+i,"BUNC",4)==0 && sf[i+4]==0xc8)
   {
    b = sf[i + 5];
    break;
   }
  if (a == 0xff && b == 0xff)
   return 0;
  if (a == 0x14 && b == 0xff) *ifid="LEVEL9-006";
  else if (a == 0x15 && b == 0x5d) *ifid="LEVEL9-013";
  else if (a == 0x1a && b == 0x24) *ifid="LEVEL9-005";
  else if (a == 0x20 && b == 0x3b) *ifid="LEVEL9-003";
  else *ifid=((void *)0);
  return 1;
}

variable_types: extent int

variable_types:
ifid
char **

variable_types: i int

variable_types:
a
unsigned char

variable_types:
b
unsigned char


decompiled_code:
void __fastcall level9_treaty(int a1, unsigned __int16 *a2, int a3, char *a4, int a5)
{
if ( ((a1 & 0x100) == 0 || (int)claim_story_file(a2, a3) >= 0) && ((a1 & 0x200) == 0 || a5 && a4) )
{
if ( a1 == 515 )
{
if ( a5 > 8 )
strncpy(a4, ".l9,.sna", a5);
}
else if ( a1 > 515 )
{
if ( a1 > 778 )
{
if ( a1 == 779 )
get_story_file_extension((__int64)a2, a3, a4, a5);
}
else if ( a1 <= 776 && a1 == 776 )
{
get_story_file_IFID(a2, a3, a4, a5);
}
}
else if ( a1 == 513 )
{
if ( a5 > 52 )
strcpy(a4, "http://www.if-legends.org/~l9memorial/html/home.html");
}
else if ( a1 > 513 && a5 > 511 )
{
strncpy(a4, "level9", a5 - 1);
}
}
}

original_code:
int32 level9_treaty(int32 selector,
                   void *story_file, int32 extent,
                   void *output, int32 output_extent)
{
 int32 ll, csf;
 if ((0x100 & selector) &&
     (csf=claim_story_file(story_file, extent))<0)
         return -1;
 if ((0x200 & selector) &&
     (output_extent ==0 ||
     output==((void *)0)))
        return -3;
 switch(selector)
 {
  case 0x201:
                do { if (output_extent < ((signed) strlen("http://www.if-legends.org/~l9memorial/html/home.html")+1)) return -3; } while (0);
                strcpy((char *) output,"http://www.if-legends.org/~l9memorial/html/home.html");
                return 0;
  case 0x202:
                do { if (output_extent < (512)) return -3; } while (0);
                strncpy((char *) output,"level9",output_extent-1);
                return 0;
  case 0x203:
                ll=(strlen(".l9,.sna")+1) < 512 ? (strlen(".l9,.sna")+1):512;
                do { if (output_extent < (ll)) return -3; } while (0);
                strncpy((char *) output, ".l9,.sna", output_extent);
                return 0;
  case 0x104:
                return csf;
  case 0x105:
  case 0x309:
                return 0;
  case 0x106:
  case 0x107:
  case 0x30A:
                return 0;
  case 0x308:
                return get_story_file_IFID(story_file, extent, (char *)output, output_extent);
  case 0x30B:
                return get_story_file_extension(story_file, extent, (char *)output, output_extent);
 }
 return -2;
}

canonical_original_code:
int level9_treaty(int selector, void *story_file, int extent, void *output, int output_extent)
{
 int ll; int csf;
 if ((0x100 & selector) &&
     (csf=claim_story_file(story_file, extent))<0)
         return -1;
 if ((0x200 & selector) &&
     (output_extent ==0 ||
     output==((void *)0)))
        return -3;
 switch(selector)
 {
  case 0x201:
                do { if (output_extent < ((int) strlen("http://www.if-legends.org/~l9memorial/html/home.html")+1)) return -3; } while (0);
                strcpy((char *) output,"http://www.if-legends.org/~l9memorial/html/home.html");
                return 0;
  case 0x202:
                do { if (output_extent < (512)) return -3; } while (0);
                strncpy((char *) output,"level9",output_extent-1);
                return 0;
  case 0x203:
                ll=(strlen(".l9,.sna")+1) < 512 ? (strlen(".l9,.sna")+1):512;
                do { if (output_extent < (ll)) return -3; } while (0);
                strncpy((char *) output, ".l9,.sna", output_extent);
                return 0;
  case 0x104:
                return csf;
  case 0x105:
  case 0x309:
                return 0;
  case 0x106:
  case 0x107:
  case 0x30A:
                return 0;
  case 0x308:
                return get_story_file_IFID(story_file, extent, (char *)output, output_extent);
  case 0x30B:
                return get_story_file_extension(story_file, extent, (char *)output, output_extent);
 }
 return -2;
}

variable_types: selector int

variable_types:
output
void *

variable_types: ll int

variable_types: csf int


decompiled_code:
__int64 __fastcall claim_story_file(unsigned __int16 *a1, int a2)
{
int v2; // edx
__int64 result; // rax
char *v4; // [rsp+8h] [rbp-10h] BYREF

v4 = 0LL;
v2 = get_l9_version(a1, a2, &v4);
result = 0xFFFFFFFFLL;
if ( v2 )
result = v4 != 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned __int16 *a1, int a2)
{
int v2; // edx
__int64 result; // rax
char *v4; // [rsp+8h] [rbp-10h] BYREF

v4 = 0LL;
v2 = func5(a1, a2, &v4);
result = 0xFFFFFFFFLL;
if ( v2 )
result = v4 != 0LL;
return result;
}

original_code:
static int32 claim_story_file(void *story, int32 extent)
{
 char *ifid=((void *)0);
 if (get_l9_version((unsigned char *) story,extent, &ifid))
  if (ifid) return 1;
  else return 0;
 return -1;
}

canonical_original_code:
static int claim_story_file(void *story, int extent)
{
 char *ifid = ((void *)0);
 if (get_l9_version((unsigned char *) story,extent, &ifid))
  if (ifid) return 1;
  else return 0;
 return -1;
}

variable_types:
story
void *

variable_types:
ifid
char *


decompiled_code:
__int64 __fastcall get_story_file_IFID(unsigned __int16 *a1, int a2, char *a3, int a4)
{
unsigned int v6; // eax
char *v7; // r12
unsigned int v8; // edx
char *s; // [rsp+8h] [rbp-20h] BYREF

s = 0LL;
v6 = get_l9_version(a1, a2, &s);
if ( !v6 )
return (unsigned int)-1;
v7 = s;
if ( s )
{
if ( a4 <= (int)strlen(s) )
{
v8 = -3;
}
else
{
strcpy(a3, v7);
v8 = 1;
}
}
else
{
v8 = -3;
if ( a4 > 9 )
{
sprintf(a3, "LEVEL9-%d-", v6);
v8 = -4;
}
}
return v8;
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned __int16 *a1, int a2, char *a3, int a4)
{
unsigned int v6; // eax
char *v7; // r12
unsigned int v8; // edx
char *s; // [rsp+8h] [rbp-20h] BYREF

s = 0LL;
v6 = func5(a1, a2, &s);
if ( !v6 )
return (unsigned int)-1;
v7 = s;
if ( s )
{
if ( a4 <= (int)strlen(s) )
{
v8 = -3;
}
else
{
strcpy(a3, v7);
v8 = 1;
}
}
else
{
v8 = -3;
if ( a4 > 9 )
{
sprintf(a3, "LEVEL9-%d-", v6);
v8 = -4;
}
}
return v8;
}

original_code:
static int32 get_story_file_IFID(void *story_file, int32 extent, char *output, int32 output_extent)
{
 char *ifid=((void *)0);
 int i=get_l9_version((unsigned char *)story_file, extent, &ifid);
 if (!i) return -1;
 if (ifid)
 {
   do { if (output_extent < ((signed) strlen(ifid)+1)) return -3; } while (0);
   strcpy(output,ifid);
   return 1;
 }
 do { if (output_extent < (10)) return -3; } while (0);
 sprintf(output,"LEVEL9-%d-",i);
 return -4;
}

canonical_original_code:
static int get_story_file_IFID(void *story_file, int extent, char *output, int output_extent)
{
 char *ifid = ((void *)0);
 int i = get_l9_version((unsigned char *)story_file, extent, &ifid);
 if (!i) return -1;
 if (ifid)
 {
   do { if (output_extent < ((int) strlen(ifid)+1)) return -3; } while (0);
   strcpy(output,ifid);
   return 1;
 }
 do { if (output_extent < (10)) return -3; } while (0);
 sprintf(output,"LEVEL9-%d-",i);
 return -4;
}

variable_types:
output
char *


decompiled_code:
size_t __fastcall get_story_file_extension(__int64 a1, int a2, void *a3, int a4)
{
__int64 v7; // rax
int v8; // ecx
char v9; // dl
__int64 v10; // rbx

if ( !a1 )
return 0xFFFFFFFFLL;
if ( !a2 )
return 0xFFFFFFFFLL;
v7 = 1LL;
do
{
v8 = v7;
v9 = *(&byte_9C6 + v7++);
}
while ( v9 && v9 != 44 );
if ( a4 <= v8 )
return 4294967293LL;
v10 = v8;
memcpy(a3, &byte_9C6, v8);
*((_BYTE *)a3 + v10) = 0;
return strlen((const char *)a3);
}

canonical_decompiled_code:
size_t __fastcall func8(__int64 a1, int a2, void *a3, int a4)
{
__int64 v7; // rax
int v8; // ecx
char v9; // dl
__int64 v10; // rbx

if ( !a1 )
return 0xFFFFFFFFLL;
if ( !a2 )
return 0xFFFFFFFFLL;
v7 = 1LL;
do
{
v8 = v7;
v9 = *(&byte_9C6 + v7++);
}
while ( v9 && v9 != 44 );
if ( a4 <= v8 )
return 4294967293LL;
v10 = v8;
memcpy(a3, &byte_9C6, v8);
*((_BYTE *)a3 + v10) = 0;
return strlen((const char *)a3);
}

original_code:
static int32 get_story_file_extension(void *sf, int32 extent, char *out, int32 output_extent)
{
 int i;
 if (!sf || !extent) return -1;
 for(i=0;".l9,.sna"[i] && ".l9,.sna"[i]!=',';i++);
 do { if (output_extent < (i+1)) return -3; } while (0);
 memcpy(out,".l9,.sna",i);
 out[i]=0;
 return strlen(out);
}

canonical_original_code:
static int get_story_file_extension(void *sf, int extent, char *out, int output_extent)
{
 int i;
 if (!sf || !extent) return -1;
 for(i=0;".l9,.sna"[i] && ".l9,.sna"[i]!=',';i++);
 do { if (output_extent < (i+1)) return -3; } while (0);
 memcpy(out,".l9,.sna",i);
 out[i]=0;
 return strlen(out);
}

variable_types:
sf
void *

variable_types:
out
char *


decompiled_code:
int print_preamble()
{
const char *v0; // rsi
int result; // eax
char v2; // al
char *v3; // rdx
int v4; // ebx

if ( ErrorReport > 0 && input_file >= ErrorReport )
v0 = *(const char **)(InputFiles + 16LL * ErrorReport - 16);
else
v0 = (const char *)*((_QWORD *)&ErrorReport + 1);
if ( v0 )
{
result = error_format;
if ( error_format != 1 )
goto LABEL_6;
v2 = *v0;
if ( *v0 )
{
v3 = (char *)(v0 + 1);
v4 = 0;
do
{
if ( v2 == 47 )
{
v4 = -1;
}
else if ( v2 == 46 )
{
v4 = 0;
}
v2 = *v3++;
}
while ( v2 );
printf("%s", v0);
if ( v4 )
printf("%s", ".inf");
return printf("(%d): ", (unsigned int)*(&ErrorReport + 4));
}
LABEL_26:
printf("%s", v0);
return printf("(%d): ", (unsigned int)*(&ErrorReport + 4));
}
result = error_format;
if ( error_format == 1 )
{
v0 = (const char *)&unk_D44;
goto LABEL_26;
}
v0 = (const char *)&unk_D44;
LABEL_6:
if ( result == 2 )
return printf("File \"%s\"; Line %d\t# ", v0, (unsigned int)*(&ErrorReport + 4));
if ( !result )
{
if ( !*(&ErrorReport + 5) )
printf("\"%s\", ", v0);
result = printf("line %d: ", (unsigned int)*(&ErrorReport + 4));
}
return result;
}

canonical_decompiled_code:
int func0()
{
const char *v0; // rsi
int result; // eax
char v2; // al
char *v3; // rdx
int v4; // ebx

if ( ErrorReport > 0 && input_file >= ErrorReport )
v0 = *(const char **)(InputFiles + 16LL * ErrorReport - 16);
else
v0 = (const char *)*((_QWORD *)&ErrorReport + 1);
if ( v0 )
{
result = error_format;
if ( error_format != 1 )
goto LABEL_6;
v2 = *v0;
if ( *v0 )
{
v3 = (char *)(v0 + 1);
v4 = 0;
do
{
if ( v2 == 47 )
{
v4 = -1;
}
else if ( v2 == 46 )
{
v4 = 0;
}
v2 = *v3++;
}
while ( v2 );
printf("%s", v0);
if ( v4 )
printf("%s", ".inf");
return printf("(%d): ", (unsigned int)*(&ErrorReport + 4));
}
LABEL_26:
printf("%s", v0);
return printf("(%d): ", (unsigned int)*(&ErrorReport + 4));
}
result = error_format;
if ( error_format == 1 )
{
v0 = (const char *)&unk_D44;
goto LABEL_26;
}
v0 = (const char *)&unk_D44;
LABEL_6:
if ( result == 2 )
return printf("File \"%s\"; Line %d\t# ", v0, (unsigned int)*(&ErrorReport + 4));
if ( !result )
{
if ( !*(&ErrorReport + 5) )
printf("\"%s\", ", v0);
result = printf("line %d: ", (unsigned int)*(&ErrorReport + 4));
}
return result;
}

original_code:
static void print_preamble(void)
{
    int j, with_extension_flag = 0; char *p;
    j = ErrorReport.file_number;
    if (j <= 0 || j > input_file) p = ErrorReport.source;
    else p = InputFiles[j-1].filename;
    if (!p) p = "";
    switch(error_format)
    {
        case 0:
            if (!(ErrorReport.main_flag)) printf("\"%s\", ", p);
            printf("line %d: ", ErrorReport.line_number);
            break;
        case 1:
            for (j=0; p[j]!=0; j++)
            { if (p[j] == '/') with_extension_flag = -1;
                if (p[j] == '.') with_extension_flag = 0;
            }
            printf("%s", p);
            if (with_extension_flag) printf("%s", ".inf");
            printf("(%d): ", ErrorReport.line_number);
            break;
        case 2:
            printf("File \"%s\"; Line %d\t# ", p, ErrorReport.line_number);
            break;
    }
}

canonical_original_code:
static void print_preamble()
{
    int j; int with_extension_flag = 0; char *p;
    j = ErrorReport.file_number;
    if (j <= 0 || j > input_file) p = ErrorReport.source;
    else p = InputFiles[j-1].filename;
    if (!p) p = "";
    switch(error_format)
    {
        case 0:
            if (!(ErrorReport.main_flag)) printf("\"%s\", ", p);
            printf("line %d: ", ErrorReport.line_number);
            break;
        case 1:
            for (j=0; p[j]!=0; j++)
            { if (p[j] == '/') with_extension_flag = -1;
                if (p[j] == '.') with_extension_flag = 0;
            }
            printf("%s", p);
            if (with_extension_flag) printf("%s", ".inf");
            printf("(%d): ", ErrorReport.line_number);
            break;
        case 2:
            printf("File \"%s\"; Line %d\t# ", p, ErrorReport.line_number);
            break;
    }
}

variable_types: j int

variable_types:
p
char *

return_type: void


decompiled_code:
size_t ellipsize_error_message_buff()
{
size_t result; // rax

result = strlen(error_message_buff);
if ( result == 255 )
dword_D3F = 3026478;
return result;
}

canonical_decompiled_code:
size_t func1()
{
size_t result; // rax

result = strlen(error_message_buff);
if ( result == 255 )
dword_D3F = 3026478;
return result;
}

original_code:
static void ellipsize_error_message_buff(void)
{
    if (strlen(error_message_buff) == (256)-1)
        strcat(error_message_buff, "...");
}

canonical_original_code:
static void ellipsize_error_message_buff()
{
    if (strlen(error_message_buff) == (256)-1)
        strcat(error_message_buff, "...");
}


warning

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

if ( !nowarnings_switch )
return message(2, a1);
++no_suppressed_warnings;
return result;
}

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

if ( !nowarnings_switch )
return func2(2, a1);
++no_suppressed_warnings;
return result;
}

original_code:
extern void warning(char *s1)
{ if (nowarnings_switch) { no_suppressed_warnings++; return; }
    message(2,s1);
}


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

if ( nowarnings_switch )
{
++no_suppressed_warnings;
}
else
{
snprintf(error_message_buff, 0x100uLL, "%s %d.", a1, a2);
ellipsize_error_message_buff();
result = message(2, error_message_buff);
}
return result;
}

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

if ( nowarnings_switch )
{
++no_suppressed_warnings;
}
else
{
snprintf(error_message_buff, 0x100uLL, "%s %d.", a1, a2);
func1();
result = func2(2, error_message_buff);
}
return result;
}

original_code:
extern void warning_numbered(char *s1, int val)
{ if (nowarnings_switch) { no_suppressed_warnings++; return; }
    snprintf(error_message_buff, (256),"%s %d.", s1, val);
    ellipsize_error_message_buff();
    message(2,error_message_buff);
}

variable_types: val int


decompiled_code:
int __fastcall warning_named(const char *a1, const char *a2)
{
int result; // eax

if ( nowarnings_switch )
{
++no_suppressed_warnings;
}
else
{
snprintf(error_message_buff, 0x100uLL, "%s \"%s\"", a1, a2);
ellipsize_error_message_buff();
result = message(2, error_message_buff);
}
return result;
}

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

if ( nowarnings_switch )
{
++no_suppressed_warnings;
}
else
{
snprintf(error_message_buff, 0x100uLL, "%s \"%s\"", a1, a2);
func1();
result = func2(2, error_message_buff);
}
return result;
}

original_code:
extern void warning_named(char *s1, char *s2)
{
    if (nowarnings_switch) { no_suppressed_warnings++; return; }
    snprintf(error_message_buff, (256),"%s \"%s\"", s1, s2);
    ellipsize_error_message_buff();
    message(2,error_message_buff);
}


decompiled_code:
void __fastcall dbnu_warning(const char *a1, const char *a2, int a3)
{
int v3; // er13
__int64 v4; // r12
int v5; // ebp
int v6; // ebx
int v7; // er14

if ( nowarnings_switch )
{
++no_suppressed_warnings;
}
else
{
v3 = ErrorReport;
v4 = *((_QWORD *)&ErrorReport + 1);
v5 = *(&ErrorReport + 4);
v6 = *(&ErrorReport + 5);
if ( a3 != -1 )
{
ErrorReport = a3 / 0x800000;
*(&ErrorReport + 4) = a3 % 0x800000;
*(&ErrorReport + 5) = a3 / 0x800000 == 1;
}
snprintf(error_message_buff, 0x100uLL, "%s \"%s\" declared but not used", a1, a2);
ellipsize_error_message_buff();
v7 = concise_switch;
concise_switch = -1;
message(2, error_message_buff);
concise_switch = v7;
ErrorReport = v3;
*((_QWORD *)&ErrorReport + 1) = v4;
*(&ErrorReport + 4) = v5;
*(&ErrorReport + 5) = v6;
}
}

canonical_decompiled_code:
void __fastcall func6(const char *a1, const char *a2, int a3)
{
int v3; // er13
__int64 v4; // r12
int v5; // ebp
int v6; // ebx
int v7; // er14

if ( nowarnings_switch )
{
++no_suppressed_warnings;
}
else
{
v3 = ErrorReport;
v4 = *((_QWORD *)&ErrorReport + 1);
v5 = *(&ErrorReport + 4);
v6 = *(&ErrorReport + 5);
if ( a3 != -1 )
{
ErrorReport = a3 / 0x800000;
*(&ErrorReport + 4) = a3 % 0x800000;
*(&ErrorReport + 5) = a3 / 0x800000 == 1;
}
snprintf(error_message_buff, 0x100uLL, "%s \"%s\" declared but not used", a1, a2);
func1();
v7 = concise_switch;
concise_switch = -1;
func2(2, error_message_buff);
concise_switch = v7;
ErrorReport = v3;
*((_QWORD *)&ErrorReport + 1) = v4;
*(&ErrorReport + 4) = v5;
*(&ErrorReport + 5) = v6;
}
}

original_code:
extern void dbnu_warning(char *type, char *name, int32 report_line)
{ int i;
    ErrorPosition E = ErrorReport;
    if (nowarnings_switch) { no_suppressed_warnings++; return; }
    if (report_line != -1)
    { ErrorReport.file_number = report_line/(0x800000L);
        ErrorReport.line_number = report_line%(0x800000L);
        ErrorReport.main_flag = (ErrorReport.file_number == 1);
    }
    snprintf(error_message_buff, (256), "%s \"%s\" declared but not used", type, name);
    ellipsize_error_message_buff();
    i = concise_switch; concise_switch = -1;
    message(2,error_message_buff);
    concise_switch = i;
    ErrorReport = E;
}

canonical_original_code:
extern void dbnu_warning(char *type, char *name, int report_line)
{ int i;
    struct ErrorPosition_s E = ErrorReport;
    if (nowarnings_switch) { no_suppressed_warnings++; return; }
    if (report_line != -1)
    { ErrorReport.file_number = report_line/(0x800000L);
        ErrorReport.line_number = report_line%(0x800000L);
        ErrorReport.main_flag = (ErrorReport.file_number == 1);
    }
    snprintf(error_message_buff, (256), "%s \"%s\" declared but not used", type, name);
    ellipsize_error_message_buff();
    i = concise_switch; concise_switch = -1;
    message(2,error_message_buff);
    concise_switch = i;
    ErrorReport = E;
}

variable_types:
type
char *

variable_types:
name
char *

variable_types: struct ErrorPosition_s { int file_number; char *source; int line_number; int main_flag; }


decompiled_code:
void __fastcall uncalled_routine_warning(const char *a1, const char *a2, int a3)
{
int v3; // er13
__int64 v4; // r12
int v5; // ebp
int v6; // ebx
int v7; // er14

if ( nowarnings_switch )
{
++no_suppressed_warnings;
}
else
{
v3 = ErrorReport;
v4 = *((_QWORD *)&ErrorReport + 1);
v5 = *(&ErrorReport + 4);
v6 = *(&ErrorReport + 5);
if ( a3 != -1 )
{
ErrorReport = a3 / 0x800000;
*(&ErrorReport + 4) = a3 % 0x800000;
*(&ErrorReport + 5) = a3 / 0x800000 == 1;
}
if ( OMIT_UNUSED_ROUTINES )
snprintf(error_message_buff, 0x100uLL, "%s \"%s\" unused and omitted", a1, a2);
else
snprintf(error_message_buff, 0x100uLL, "%s \"%s\" unused (not omitted)", a1, a2);
ellipsize_error_message_buff();
v7 = concise_switch;
concise_switch = -1;
message(2, error_message_buff);
concise_switch = v7;
ErrorReport = v3;
*((_QWORD *)&ErrorReport + 1) = v4;
*(&ErrorReport + 4) = v5;
*(&ErrorReport + 5) = v6;
}
}

canonical_decompiled_code:
void __fastcall func7(const char *a1, const char *a2, int a3)
{
int v3; // er13
__int64 v4; // r12
int v5; // ebp
int v6; // ebx
int v7; // er14

if ( nowarnings_switch )
{
++no_suppressed_warnings;
}
else
{
v3 = ErrorReport;
v4 = *((_QWORD *)&ErrorReport + 1);
v5 = *(&ErrorReport + 4);
v6 = *(&ErrorReport + 5);
if ( a3 != -1 )
{
ErrorReport = a3 / 0x800000;
*(&ErrorReport + 4) = a3 % 0x800000;
*(&ErrorReport + 5) = a3 / 0x800000 == 1;
}
if ( OMIT_UNUSED_ROUTINES )
snprintf(error_message_buff, 0x100uLL, "%s \"%s\" unused and omitted", a1, a2);
else
snprintf(error_message_buff, 0x100uLL, "%s \"%s\" unused (not omitted)", a1, a2);
func1();
v7 = concise_switch;
concise_switch = -1;
func2(2, error_message_buff);
concise_switch = v7;
ErrorReport = v3;
*((_QWORD *)&ErrorReport + 1) = v4;
*(&ErrorReport + 4) = v5;
*(&ErrorReport + 5) = v6;
}
}

original_code:
extern void uncalled_routine_warning(char *type, char *name, int32 report_line)
{ int i;
    ErrorPosition E = ErrorReport;
    if (nowarnings_switch) { no_suppressed_warnings++; return; }
    if (report_line != -1)
    { ErrorReport.file_number = report_line/(0x800000L);
        ErrorReport.line_number = report_line%(0x800000L);
        ErrorReport.main_flag = (ErrorReport.file_number == 1);
    }
    if (OMIT_UNUSED_ROUTINES)
        snprintf(error_message_buff, (256), "%s \"%s\" unused and omitted", type, name);
    else
        snprintf(error_message_buff, (256), "%s \"%s\" unused (not omitted)", type, name);
    ellipsize_error_message_buff();
    i = concise_switch; concise_switch = -1;
    message(2,error_message_buff);
    concise_switch = i;
    ErrorReport = E;
}

canonical_original_code:
extern void uncalled_routine_warning(char *type, char *name, int report_line)
{ int i;
    struct ErrorPosition_s E = ErrorReport;
    if (nowarnings_switch) { no_suppressed_warnings++; return; }
    if (report_line != -1)
    { ErrorReport.file_number = report_line/(0x800000L);
        ErrorReport.line_number = report_line%(0x800000L);
        ErrorReport.main_flag = (ErrorReport.file_number == 1);
    }
    if (OMIT_UNUSED_ROUTINES)
        snprintf(error_message_buff, (256), "%s \"%s\" unused and omitted", type, name);
    else
        snprintf(error_message_buff, (256), "%s \"%s\" unused (not omitted)", type, name);
    ellipsize_error_message_buff();
    i = concise_switch; concise_switch = -1;
    message(2,error_message_buff);
    concise_switch = i;
    ErrorReport = E;
}

variable_types: i int

user_defined_types: struct ErrorPosition_s { int file_number; char *source; int line_number; int main_flag; }


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

result = is_systemfile();
if ( result != 1 )
{
result = nowarnings_switch | obsolete_switch;
if ( nowarnings_switch | obsolete_switch )
{
++no_suppressed_warnings;
}
else
{
snprintf(error_message_buff, 0x100uLL, "Obsolete usage: %s", a1);
ellipsize_error_message_buff();
result = message(2, error_message_buff);
}
}
return result;
}

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

result = is_systemfile();
if ( result != 1 )
{
result = nowarnings_switch | obsolete_switch;
if ( nowarnings_switch | obsolete_switch )
{
++no_suppressed_warnings;
}
else
{
snprintf(error_message_buff, 0x100uLL, "Obsolete usage: %s", a1);
func1();
result = func2(2, error_message_buff);
}
}
return result;
}

original_code:
extern void obsolete_warning(char *s1)
{ if (is_systemfile()==1) return;
    if (obsolete_switch || nowarnings_switch)
    { no_suppressed_warnings++; return; }
    snprintf(error_message_buff, (256), "Obsolete usage: %s",s1);
    ellipsize_error_message_buff();
    message(2,error_message_buff);
}


decompiled_code:
int print_sorry_message()
{
return printf(
"***********************************************************************\n"
"* 'Compiler errors' should never occur if Inform is working properly. *\n"
"* This is version %d.%02d of Inform, dated %20s: so *\n"
"* if that was more than six months ago, there may be a more recent *\n"
"* version available, from which the problem may have been removed. *\n"
"* If not, please report this fault to: graham@gnelson.demon.co.uk *\n"
"* and if at all possible, please include your source code, as faults *\n"
"* such as these are rare and often difficult to reproduce. Sorry. *\n"
"***********************************************************************\n",
6LL,
32LL,
"14th October 2012");
}

canonical_decompiled_code:
int func9()
{
return printf(
"***********************************************************************\n"
"* 'Compiler errors' should never occur if Inform is working properly. *\n"
"* This is version %d.%02d of Inform, dated %20s: so *\n"
"* if that was more than six months ago, there may be a more recent *\n"
"* version available, from which the problem may have been removed. *\n"
"* If not, please report this fault to: graham@gnelson.demon.co.uk *\n"
"* and if at all possible, please include your source code, as faults *\n"
"* such as these are rare and often difficult to reproduce. Sorry. *\n"
"***********************************************************************\n",
6LL,
32LL,
"14th October 2012");
}

original_code:
extern void print_sorry_message(void)
{ printf(
"***********************************************************************\n* 'Compiler errors' should never occur if Inform is working properly. *\n* This is version %d.%02d of Inform, dated %20s: so      *\n* if that was more than six months ago, there may be a more recent    *\n* version available, from which the problem may have been removed.    *\n* If not, please report this fault to:   graham@gnelson.demon.co.uk   *\n* and if at all possible, please include your source code, as faults  *\n* such as these are rare and often difficult to reproduce.  Sorry.    *\n***********************************************************************\n",
    (1632/100)%10, 1632%100, "14th October 2012");
}

canonical_original_code:
extern void print_sorry_message()
{ printf(
"***********************************************************************\n* 'Compiler errors' should never occur if Inform is working properly. *\n* This is version %d.%02d of Inform, dated %20s: so      *\n* if that was more than six months ago, there may be a more recent    *\n* version available, from which the problem may have been removed.    *\n* If not, please report this fault to:   graham@gnelson.demon.co.uk   *\n* and if at all possible, please include your source code, as faults  *\n* such as these are rare and often difficult to reproduce.  Sorry.    *\n***********************************************************************\n",
    (1632/100)%10, 1632%100, "14th October 2012");
}


fatalerror

decompiled_code:
void __fastcall __noreturn fatalerror(const char *a1)
{
print_preamble();
printf("Fatal error: %s\n", a1);
if ( no_compiler_errors > 0 )
print_sorry_message();
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func10(const char *a1)
{
func0();
printf("Fatal error: %s\n", a1);
if ( no_compiler_errors > 0 )
func9();
exit(1);
}

original_code:
extern void fatalerror(char *s)
{ print_preamble();
    printf("Fatal error: %s\n",s);
    if (no_compiler_errors > 0) print_sorry_message();
    exit(1);
}

variable_types:
s
char *


decompiled_code:
void __fastcall __noreturn fatalerror_named(const char *a1, const char *a2)
{
snprintf(error_message_buff, 0x100uLL, "%s \"%s\"", a1, a2);
ellipsize_error_message_buff();
fatalerror(error_message_buff);
}

canonical_decompiled_code:
void __fastcall __noreturn func11(const char *a1, const char *a2)
{
snprintf(error_message_buff, 0x100uLL, "%s \"%s\"", a1, a2);
func1();
func10(error_message_buff);
}

original_code:
extern void fatalerror_named(char *m, char *fn)
{ snprintf(error_message_buff, (256), "%s \"%s\"", m, fn);
    ellipsize_error_message_buff();
    fatalerror(error_message_buff);
}

variable_types:
m
char *

variable_types:
fn
char *


decompiled_code:
void __fastcall __noreturn memory_out_error(unsigned int a1, unsigned int a2, const char *a3)
{
if ( a2 == 1 )
snprintf(error_message_buff, 0x100uLL, "Run out of memory allocating %d bytes for %s", a1, a3);
else
snprintf(error_message_buff, 0x100uLL, "Run out of memory allocating array of %dx%d bytes for %s", a2, a1, a3);
ellipsize_error_message_buff();
fatalerror(error_message_buff);
}

canonical_decompiled_code:
void __fastcall __noreturn func12(unsigned int a1, unsigned int a2, const char *a3)
{
if ( a2 == 1 )
snprintf(error_message_buff, 0x100uLL, "Run out of memory allocating %d bytes for %s", a1, a3);
else
snprintf(error_message_buff, 0x100uLL, "Run out of memory allocating array of %dx%d bytes for %s", a2, a1, a3);
func1();
func10(error_message_buff);
}

original_code:
extern void memory_out_error(int32 size, int32 howmany, char *name)
{ if (howmany == 1)
        snprintf(error_message_buff, (256),
            "Run out of memory allocating %d bytes for %s", size, name);
    else
        snprintf(error_message_buff, (256),
            "Run out of memory allocating array of %dx%d bytes for %s",
                howmany, size, name);
    ellipsize_error_message_buff();
    fatalerror(error_message_buff);
}

canonical_original_code:
extern void memory_out_error(int size, int howmany, char *name)
{ if (howmany == 1)
        snprintf(error_message_buff, (256),
            "Run out of memory allocating %d bytes for %s", size, name);
    else
        snprintf(error_message_buff, (256),
            "Run out of memory allocating array of %dx%d bytes for %s",
                howmany, size, name);
    ellipsize_error_message_buff();
    fatalerror(error_message_buff);
}

variable_types: size int

variable_types: howmany int


memoryerror

decompiled_code:
void __fastcall __noreturn memoryerror(const char *a1, int a2)
{
snprintf(
error_message_buff,
0x100uLL,
"The memory setting %s (which is %ld at present) has been exceeded. Try running Inform again with $%s=<some-larger-n"
"umber> on the command line.",
a1,
a2,
a1);
ellipsize_error_message_buff();
fatalerror(error_message_buff);
}

canonical_decompiled_code:
void __fastcall __noreturn func13(const char *a1, int a2)
{
snprintf(
error_message_buff,
0x100uLL,
"The memory setting %s (which is %ld at present) has been exceeded. Try running Inform again with $%s=<some-larger-n"
"umber> on the command line.",
a1,
a2,
a1);
func1();
func10(error_message_buff);
}

original_code:
extern void memoryerror(char *s, int32 size)
{
    snprintf(error_message_buff, (256),
        "The memory setting %s (which is %ld at present) has been exceeded.  Try running Inform again with $%s=<some-larger-number> on the command line.",s,(long int) size,s);
    ellipsize_error_message_buff();
    fatalerror(error_message_buff);
}

canonical_original_code:
extern void memoryerror(char *s, int size)
{
    snprintf(error_message_buff, (256),
        "The memory setting %s (which is %ld at present) has been exceeded.  Try running Inform again with $%s=<some-larger-number> on the command line.",s,(long) size,s);
    ellipsize_error_message_buff();
    fatalerror(error_message_buff);
}


error

decompiled_code:
int __fastcall error(const char *a1)
{
if ( no_errors == 100 )
fatalerror("Too many errors: giving up");
return message(1, a1);
}

canonical_decompiled_code:
int __fastcall func14(const char *a1)
{
if ( no_errors == 100 )
func10("Too many errors: giving up");
return func2(1, a1);
}

original_code:
extern void error(char *s)
{ if (no_errors == 100)
        fatalerror("Too many errors: giving up");
    errors[no_errors] = no_syntax_lines;
    message(1,s);
}


decompiled_code:
int __fastcall error_named(const char *a1, const char *a2)
{
snprintf(error_message_buff, 0x100uLL, "%s \"%s\"", a1, a2);
ellipsize_error_message_buff();
return error(error_message_buff);
}

canonical_decompiled_code:
int __fastcall func15(const char *a1, const char *a2)
{
snprintf(error_message_buff, 0x100uLL, "%s \"%s\"", a1, a2);
func1();
return func14(error_message_buff);
}

original_code:
extern void error_named(char *s1, char *s2)
{ snprintf(error_message_buff, (256),"%s \"%s\"",s1,s2);
    ellipsize_error_message_buff();
    error(error_message_buff);
}


decompiled_code:
int __fastcall no_such_label(const char *a1)
{
return error_named("No such label as", a1);
}

canonical_decompiled_code:
int __fastcall func16(const char *a1)
{
return func15("No such label as", a1);
}

original_code:
extern void no_such_label(char *lname)
{ error_named("No such label as",lname);
}

variable_types:
lname
char *


decompiled_code:
int __fastcall error_numbered(const char *a1, unsigned int a2)
{
snprintf(error_message_buff, 0x100uLL, "%s %d.", a1, a2);
ellipsize_error_message_buff();
return error(error_message_buff);
}

canonical_decompiled_code:
int __fastcall func17(const char *a1, unsigned int a2)
{
snprintf(error_message_buff, 0x100uLL, "%s %d.", a1, a2);
func1();
return func14(error_message_buff);
}

original_code:
extern void error_numbered(char *s1, int val)
{
    snprintf(error_message_buff, (256),"%s %d.",s1,val);
    ellipsize_error_message_buff();
    error(error_message_buff);
}


decompiled_code:
int __fastcall error_named_at(const char *a1, const char *a2, int a3)
{
int v3; // er13
__int64 v4; // r12
int v5; // ebp
int v6; // ebx
int v7; // er14
int result; // eax

v3 = ErrorReport;
v4 = *((_QWORD *)&ErrorReport + 1);
v5 = *(&ErrorReport + 4);
v6 = *(&ErrorReport + 5);
if ( a3 != -1 )
{
ErrorReport = a3 / 0x800000;
*(&ErrorReport + 4) = a3 % 0x800000;
*(&ErrorReport + 5) = a3 / 0x800000 == 1;
}
snprintf(error_message_buff, 0x100uLL, "%s \"%s\"", a1, a2);
ellipsize_error_message_buff();
v7 = concise_switch;
concise_switch = -1;
result = error(error_message_buff);
ErrorReport = v3;
*((_QWORD *)&ErrorReport + 1) = v4;
*(&ErrorReport + 4) = v5;
*(&ErrorReport + 5) = v6;
concise_switch = v7;
return result;
}

canonical_decompiled_code:
int __fastcall func18(const char *a1, const char *a2, int a3)
{
int v3; // er13
__int64 v4; // r12
int v5; // ebp
int v6; // ebx
int v7; // er14
int result; // eax

v3 = ErrorReport;
v4 = *((_QWORD *)&ErrorReport + 1);
v5 = *(&ErrorReport + 4);
v6 = *(&ErrorReport + 5);
if ( a3 != -1 )
{
ErrorReport = a3 / 0x800000;
*(&ErrorReport + 4) = a3 % 0x800000;
*(&ErrorReport + 5) = a3 / 0x800000 == 1;
}
snprintf(error_message_buff, 0x100uLL, "%s \"%s\"", a1, a2);
func1();
v7 = concise_switch;
concise_switch = -1;
result = func14(error_message_buff);
ErrorReport = v3;
*((_QWORD *)&ErrorReport + 1) = v4;
*(&ErrorReport + 4) = v5;
*(&ErrorReport + 5) = v6;
concise_switch = v7;
return result;
}

original_code:
extern void error_named_at(char *s1, char *s2, int32 report_line)
{ int i;
    ErrorPosition E = ErrorReport;
    if (report_line != -1)
    { ErrorReport.file_number = report_line/(0x800000L);
        ErrorReport.line_number = report_line%(0x800000L);
        ErrorReport.main_flag = (ErrorReport.file_number == 1);
    }
    snprintf(error_message_buff, (256),"%s \"%s\"",s1,s2);
    ellipsize_error_message_buff();
    i = concise_switch; concise_switch = -1;
    error(error_message_buff);
    ErrorReport = E; concise_switch = i;
}

canonical_original_code:
extern void error_named_at(char *s1, char *s2, int report_line)
{ int i;
    struct ErrorPosition_s E = ErrorReport;
    if (report_line != -1)
    { ErrorReport.file_number = report_line/(0x800000L);
        ErrorReport.line_number = report_line%(0x800000L);
        ErrorReport.main_flag = (ErrorReport.file_number == 1);
    }
    snprintf(error_message_buff, (256),"%s \"%s\"",s1,s2);
    ellipsize_error_message_buff();
    i = concise_switch; concise_switch = -1;
    error(error_message_buff);
    ErrorReport = E; concise_switch = i;
}


decompiled_code:
int __fastcall ebf_error(const char *a1, const char *a2)
{
snprintf(error_message_buff, 0x100uLL, "Expected %s but found %s", a1, a2);
ellipsize_error_message_buff();
return error(error_message_buff);
}

canonical_decompiled_code:
int __fastcall func19(const char *a1, const char *a2)
{
snprintf(error_message_buff, 0x100uLL, "Expected %s but found %s", a1, a2);
func1();
return func14(error_message_buff);
}

original_code:
extern void ebf_error(char *s1, char *s2)
{ snprintf(error_message_buff, (256), "Expected %s but found %s", s1, s2);
    ellipsize_error_message_buff();
    error(error_message_buff);
}


decompiled_code:
int __fastcall char_error(const char *a1, unsigned int a2)
{
int v2; // eax
unsigned int v3; // ebx
const char *v4; // rax
int v5; // eax

v2 = iso_to_unicode(a2);
v3 = v2;
if ( character_set_unicode )
{
snprintf(error_message_buff, 0x100uLL, "%s (unicode) $%04x", a1, (unsigned int)v2);
}
else
{
if ( v2 > 255 )
{
v4 = (const char *)name_of_iso_set(character_set_setting);
snprintf(error_message_buff, 0x100uLL, "%s (unicode) $%04x = (ISO %s) $%02x", a1, v3, v4, a2);
goto LABEL_11;
}
snprintf(error_message_buff, 0x100uLL, "%s (ISO Latin1) $%02x", a1, (unsigned int)v2);
}
if ( v3 - 32 <= 0x5E || v3 - 161 <= 0x5E && character_set_setting == 1 && !character_set_unicode )
{
v5 = strlen(error_message_buff);
snprintf(&error_message_buff[v5], 256 - v5, ", i.e., '%c'", v3);
}
LABEL_11:
ellipsize_error_message_buff();
return error(error_message_buff);
}

canonical_decompiled_code:
int __fastcall func20(const char *a1, unsigned int a2)
{
int v2; // eax
unsigned int v3; // ebx
const char *v4; // rax
int v5; // eax

v2 = iso_to_unicode(a2);
v3 = v2;
if ( character_set_unicode )
{
snprintf(error_message_buff, 0x100uLL, "%s (unicode) $%04x", a1, (unsigned int)v2);
}
else
{
if ( v2 > 255 )
{
v4 = (const char *)name_of_iso_set(character_set_setting);
snprintf(error_message_buff, 0x100uLL, "%s (unicode) $%04x = (ISO %s) $%02x", a1, v3, v4, a2);
goto LABEL_11;
}
snprintf(error_message_buff, 0x100uLL, "%s (ISO Latin1) $%02x", a1, (unsigned int)v2);
}
if ( v3 - 32 <= 0x5E || v3 - 161 <= 0x5E && character_set_setting == 1 && !character_set_unicode )
{
v5 = strlen(error_message_buff);
snprintf(&error_message_buff[v5], 256 - v5, ", i.e., '%c'", v3);
}
LABEL_11:
func1();
return func14(error_message_buff);
}

original_code:
extern void char_error(char *s, int ch)
{ int32 uni;
    uni = iso_to_unicode(ch);
    if (character_set_unicode)
        snprintf(error_message_buff, (256), "%s (unicode) $%04x", s, uni);
    else if (uni >= 0x100)
    { snprintf(error_message_buff, (256),
            "%s (unicode) $%04x = (ISO %s) $%02x", s, uni,
            name_of_iso_set(character_set_setting), ch);
    }
    else
        snprintf(error_message_buff, (256), "%s (ISO Latin1) $%02x", s, uni);
    if (((uni>=32) && (uni<127))
        || (((uni >= 0xa1) && (uni <= 0xff))
        && (character_set_setting==1) && (!character_set_unicode)))
    { int curlen = strlen(error_message_buff);
        snprintf(error_message_buff+curlen, (256)-curlen,
            ", i.e., '%c'", uni);
    }
    ellipsize_error_message_buff();
    error(error_message_buff);
}

canonical_original_code:
extern void char_error(char *s, int ch)
{ int uni;
    uni = iso_to_unicode(ch);
    if (character_set_unicode)
        snprintf(error_message_buff, (256), "%s (unicode) $%04x", s, uni);
    else if (uni >= 0x100)
    { snprintf(error_message_buff, (256),
            "%s (unicode) $%04x = (ISO %s) $%02x", s, uni,
            name_of_iso_set(character_set_setting), ch);
    }
    else
        snprintf(error_message_buff, (256), "%s (ISO Latin1) $%02x", s, uni);
    if (((uni>=32) && (uni<127))
        || (((uni >= 0xa1) && (uni <= 0xff))
        && (character_set_setting==1) && (!character_set_unicode)))
    { int curlen = strlen(error_message_buff);
        snprintf(error_message_buff+curlen, (256)-curlen,
            ", i.e., '%c'", uni);
    }
    ellipsize_error_message_buff();
    error(error_message_buff);
}

variable_types: ch int

variable_types: uni int

variable_types: curlen int


decompiled_code:
int __fastcall unicode_char_error(const char *a1, unsigned int a2)
{
int v3; // eax

if ( (int)a2 <= 255 )
{
snprintf(error_message_buff, 0x100uLL, "%s (ISO Latin1) $%02x", a1, a2);
if ( a2 - 32 <= 0x5E || a2 - 161 <= 0x5E && character_set_setting == 1 && !character_set_unicode )
{
v3 = strlen(error_message_buff);
snprintf(&error_message_buff[v3], 256 - v3, ", i.e., '%c'", a2);
}
}
else
{
snprintf(error_message_buff, 0x100uLL, "%s (unicode) $%04x", a1, a2);
}
ellipsize_error_message_buff();
return error(error_message_buff);
}

canonical_decompiled_code:
int __fastcall func21(const char *a1, unsigned int a2)
{
int v3; // eax

if ( (int)a2 <= 255 )
{
snprintf(error_message_buff, 0x100uLL, "%s (ISO Latin1) $%02x", a1, a2);
if ( a2 - 32 <= 0x5E || a2 - 161 <= 0x5E && character_set_setting == 1 && !character_set_unicode )
{
v3 = strlen(error_message_buff);
snprintf(&error_message_buff[v3], 256 - v3, ", i.e., '%c'", a2);
}
}
else
{
snprintf(error_message_buff, 0x100uLL, "%s (unicode) $%04x", a1, a2);
}
func1();
return func14(error_message_buff);
}

original_code:
extern void unicode_char_error(char *s, int32 uni)
{
    if (uni >= 0x100)
        snprintf(error_message_buff, (256), "%s (unicode) $%04x", s, uni);
    else
        snprintf(error_message_buff, (256), "%s (ISO Latin1) $%02x", s, uni);
    if (((uni>=32) && (uni<127))
        || (((uni >= 0xa1) && (uni <= 0xff))
        && (character_set_setting==1) && (!character_set_unicode)))
    { int curlen = strlen(error_message_buff);
        snprintf(error_message_buff+curlen, (256)-curlen,
            ", i.e., '%c'", uni);
    }
    ellipsize_error_message_buff();
    error(error_message_buff);
}

canonical_original_code:
extern void unicode_char_error(char *s, int uni)
{
    if (uni >= 0x100)
        snprintf(error_message_buff, (256), "%s (unicode) $%04x", s, uni);
    else
        snprintf(error_message_buff, (256), "%s (ISO Latin1) $%02x", s, uni);
    if (((uni>=32) && (uni<127))
        || (((uni >= 0xa1) && (uni <= 0xff))
        && (character_set_setting==1) && (!character_set_unicode)))
    { int curlen = strlen(error_message_buff);
        snprintf(error_message_buff+curlen, (256)-curlen,
            ", i.e., '%c'", uni);
    }
    ellipsize_error_message_buff();
    error(error_message_buff);
}


decompiled_code:
int __fastcall link_error(const char *a1)
{
if ( no_errors == 100 )
fatalerror("Too many errors: giving up");
return message(3, a1);
}

canonical_decompiled_code:
int __fastcall func22(const char *a1)
{
if ( no_errors == 100 )
func10("Too many errors: giving up");
return func2(3, a1);
}

original_code:
extern void link_error(char *s)
{ if (no_errors==100) fatalerror("Too many errors: giving up");
    errors[no_errors] = no_syntax_lines;
    message(3,s);
}


decompiled_code:
int __fastcall link_error_named(const char *a1, const char *a2)
{
snprintf(error_message_buff, 0x100uLL, "%s \"%s\"", a1, a2);
ellipsize_error_message_buff();
return link_error(error_message_buff);
}

canonical_decompiled_code:
int __fastcall func23(const char *a1, const char *a2)
{
snprintf(error_message_buff, 0x100uLL, "%s \"%s\"", a1, a2);
func1();
return func22(error_message_buff);
}

original_code:
extern void link_error_named(char *s1, char *s2)
{ snprintf(error_message_buff, (256),"%s \"%s\"",s1,s2);
    ellipsize_error_message_buff();
    link_error(error_message_buff);
}


decompiled_code:
__int64 __fastcall compiler_error(const char *a1)
{
if ( no_link_errors > 0 )
return 0LL;
if ( no_errors > 0 )
return 0LL;
if ( no_compiler_errors == 100 )
fatalerror("Too many compiler errors: giving up");
message(4, a1);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func24(const char *a1)
{
if ( no_link_errors > 0 )
return 0LL;
if ( no_errors > 0 )
return 0LL;
if ( no_compiler_errors == 100 )
func10("Too many compiler errors: giving up");
func2(4, a1);
return 0xFFFFFFFFLL;
}

original_code:
extern int compiler_error(char *s)
{ if (no_link_errors > 0) return 0;
    if (no_errors > 0) return 0;
    if (no_compiler_errors==100)
        fatalerror("Too many compiler errors: giving up");
    message(4,s);
    return -1;
}


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

result = 0LL;
if ( no_link_errors <= 0 )
{
if ( no_errors <= 0 )
{
snprintf(error_message_buff, 0x100uLL, "%s \"%s\"", a1, a2);
ellipsize_error_message_buff();
compiler_error(error_message_buff);
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
}
return result;
}

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

result = 0LL;
if ( no_link_errors <= 0 )
{
if ( no_errors <= 0 )
{
snprintf(error_message_buff, 0x100uLL, "%s \"%s\"", a1, a2);
func1();
func24(error_message_buff);
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
}
return result;
}

original_code:
extern int compiler_error_named(char *s1, char *s2)
{ if (no_link_errors > 0) return 0;
    if (no_errors > 0) return 0;
    snprintf(error_message_buff, (256), "%s \"%s\"",s1,s2);
    ellipsize_error_message_buff();
    compiler_error(error_message_buff);
    return -1;
}


decompiled_code:
void init_errors_vars()
{
forerrors_buff = 0LL;
no_errors = 0;
no_warnings = 0;
no_suppressed_warnings = 0;
no_compiler_errors = 0;
}

canonical_decompiled_code:
void func26()
{
forerrors_buff = 0LL;
no_errors = 0;
no_warnings = 0;
no_suppressed_warnings = 0;
no_compiler_errors = 0;
}

original_code:
extern void init_errors_vars(void)
{ forerrors_buff = ((void *)0);
    no_errors = 0; no_warnings = 0; no_suppressed_warnings = 0;
    no_compiler_errors = 0;
}

canonical_original_code:
extern void init_errors_vars()
{ forerrors_buff = ((void *)0);
    no_errors = 0; no_warnings = 0; no_suppressed_warnings = 0;
    no_compiler_errors = 0;
}


decompiled_code:
void errors_begin_pass()
{
*(&ErrorReport + 4) = 0;
ErrorReport = -1;
*((_QWORD *)&ErrorReport + 1) = "<no text read yet>";
*(&ErrorReport + 5) = 0;
}

canonical_decompiled_code:
void func27()
{
*(&ErrorReport + 4) = 0;
ErrorReport = -1;
*((_QWORD *)&ErrorReport + 1) = "<no text read yet>";
*(&ErrorReport + 5) = 0;
}

original_code:
extern void errors_begin_pass(void)
{ ErrorReport.line_number = 0;
    ErrorReport.file_number = -1;
    ErrorReport.source = "<no text read yet>";
    ErrorReport.main_flag = 0;
}

canonical_original_code:
extern void errors_begin_pass()
{ ErrorReport.line_number = 0;
    ErrorReport.file_number = -1;
    ErrorReport.source = "<no text read yet>";
    ErrorReport.main_flag = 0;
}


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

result = my_malloc(512LL, "errors buffer");
forerrors_buff = result;
return result;
}

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

result = my_malloc(512LL, "errors buffer");
forerrors_buff = result;
return result;
}

original_code:
extern void errors_allocate_arrays(void)
{ forerrors_buff = my_malloc(512, "errors buffer");
}

canonical_original_code:
extern void errors_allocate_arrays()
{ forerrors_buff = my_malloc(512, "errors buffer");
}


decompiled_code:
__int64 errors_free_arrays()
{
return my_free(&forerrors_buff, "errors buffer");
}

canonical_decompiled_code:
__int64 func29()
{
return my_free(&forerrors_buff, "errors buffer");
}

original_code:
extern void errors_free_arrays(void)
{ my_free(&forerrors_buff, "errors buffer");
}

canonical_original_code:
extern void errors_free_arrays()
{ my_free(&forerrors_buff, "errors buffer");
}


message

decompiled_code:
int __fastcall message(int a1, const char *a2)
{
int result; // eax
__int64 v3; // rax

if ( hash_printed_since_newline )
putchar(10);
hash_printed_since_newline = 0;
print_preamble();
if ( a1 == 3 )
{
printf("Error: [linking '%s'] ", (const char *)&current_module_filename);
++no_link_errors;
++no_errors;
return printf(" %s\n", a2);
}
if ( a1 > 3 )
{
if ( a1 != 4 )
return printf(" %s\n", a2);
printf("*** Compiler error: ");
++no_compiler_errors;
return printf(" %s\n", a2);
}
if ( a1 == 1 )
{
printf("Error: ");
++no_errors;
}
else if ( a1 == 2 )
{
printf("Warning: ");
++no_warnings;
}
result = printf(" %s\n", a2);
if ( !concise_switch )
{
result = forerrors_pointer;
if ( forerrors_pointer > 0 )
{
*(_BYTE *)(forerrors_buff + forerrors_pointer) = 0;
v3 = forerrors_buff;
*(_QWORD *)(forerrors_buff + 68) = 0x6374652E2E2E2020LL;
*(_BYTE *)(v3 + 76) = 0;
result = printf("> %s\n", (const char *)forerrors_buff);
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(int a1, const char *a2)
{
int result; // eax
__int64 v3; // rax

if ( hash_printed_since_newline )
putchar(10);
hash_printed_since_newline = 0;
func0();
if ( a1 == 3 )
{
printf("Error: [linking '%s'] ", (const char *)&current_module_filename);
++no_link_errors;
++no_errors;
return printf(" %s\n", a2);
}
if ( a1 > 3 )
{
if ( a1 != 4 )
return printf(" %s\n", a2);
printf("*** Compiler error: ");
++no_compiler_errors;
return printf(" %s\n", a2);
}
if ( a1 == 1 )
{
printf("Error: ");
++no_errors;
}
else if ( a1 == 2 )
{
printf("Warning: ");
++no_warnings;
}
result = printf(" %s\n", a2);
if ( !concise_switch )
{
result = forerrors_pointer;
if ( forerrors_pointer > 0 )
{
*(_BYTE *)(forerrors_buff + forerrors_pointer) = 0;
v3 = forerrors_buff;
*(_QWORD *)(forerrors_buff + 68) = 0x6374652E2E2E2020LL;
*(_BYTE *)(v3 + 76) = 0;
result = printf("> %s\n", (const char *)forerrors_buff);
}
}
return result;
}

original_code:
static void message(int style, char *s)
{ int throw_style = style;
    if (hash_printed_since_newline) printf("\n");
    hash_printed_since_newline = 0;
    print_preamble();
    switch(style)
    { case 1: printf("Error: "); no_errors++; break;
        case 2: printf("Warning: "); no_warnings++; break;
        case 3: printf("Error:  [linking '%s']  ", current_module_filename);
                no_link_errors++; no_errors++; throw_style=1; break;
        case 4: printf("*** Compiler error: ");
                no_compiler_errors++; throw_style=1; break;
    }
    printf(" %s\n", s);
    if ((!concise_switch) && (forerrors_pointer > 0) && (style <= 2))
    { forerrors_buff[forerrors_pointer] = 0;
        sprintf(forerrors_buff+68,"  ...etc");
        printf("> %s\n",forerrors_buff);
    }
}

variable_types: style int