PFDecListV

decompiled_code:
__int64 __fastcall PFDecListV(__int64 a1)
{
__int64 v1; // rbx

v1 = a1;
headPr("PFDecList");
if ( a1 )
{
while ( *(_DWORD *)v1 )
{
if ( *(_DWORD *)v1 == 1 )
{
ProcDecV(*(_QWORD *)(v1 + 8));
LABEL_4:
v1 = *(_QWORD *)(v1 + 24);
if ( !v1 )
return tailPr("PFDecList");
}
else
{
fwrite("ANALYSER BUG:104\n", 1uLL, 0x11uLL, errlist);
v1 = *(_QWORD *)(v1 + 24);
if ( !v1 )
return tailPr("PFDecList");
}
}
FunDecV(*(_QWORD *)(v1 + 16));
goto LABEL_4;
}
return tailPr("PFDecList");
}

canonical_decompiled_code:
__int64 __fastcall func24(__int64 a1)
{
__int64 v1; // rbx

v1 = a1;
headPr("PFDecList");
if ( a1 )
{
while ( *(_DWORD *)v1 )
{
if ( *(_DWORD *)v1 == 1 )
{
func28(*(_QWORD *)(v1 + 8));
LABEL_4:
v1 = *(_QWORD *)(v1 + 24);
if ( !v1 )
return tailPr("PFDecList");
}
else
{
fwrite("ANALYSER BUG:104\n", 1uLL, 0x11uLL, errlist);
v1 = *(_QWORD *)(v1 + 24);
if ( !v1 )
return tailPr("PFDecList");
}
}
func30(*(_QWORD *)(v1 + 16));
goto LABEL_4;
}
return tailPr("PFDecList");
}

original_code:
void PFDecListV(PFDecListSP t)
{
  headPr("PFDecList");
  for (; t != ((void *)0); t = t->next) {
    switch (t->type) {
    case Proc_PFDec_t:
      ProcDecV(t->pdp);
      break;
    case Fun_PFDec_t:
      FunDecV(t->fdp);
      break;
    default:
      fprintf(errlist, "ANALYSER BUG:104\n");
    }
  }
  tailPr("PFDecList");
}

canonical_original_code:
void PFDecListV(struct _PFDecListS *t)
{
  headPr("PFDecList");
  for (; t != ((void *)0); t = t->next) {
    switch (t->type) {
    case Proc_PFDec_t:
      ProcDecV(t->pdp);
      break;
    case Fun_PFDec_t:
      FunDecV(t->fdp);
      break;
    default:
      fprintf(errlist, "ANALYSER BUG:104\n");
    }
  }
  tailPr("PFDecList");
}

variable_types: struct _PFDecListS { enum PFDec_t { Fun_PFDec_t=0, Proc_PFDec_t=1 } type; struct _ProcDecS { struct _ProcDefS { struct _ProcHeadS { struct _IdentS { enum Ident_t { Init_Ident_t=0, Proc_Ident_t=1, Int_Fun_Ident_t=2, Char_Fun_Ident_t=3, Int_Const_Ident_t=4, Char_Const_Ident_t=5, Int_Var_Ident_t=6, Char_Var_Ident_t=7, IntArr_Var_Ident_t=8, CharArr_Var_Ident_t=9, Int_Para_Val_Ident_t=10, Char_Para_Val_Ident_t=11, Int_Para_Ref_Ident_t=12, Char_Para_Ref_Ident_t=13 } type; char *name; int val; int length; int line; } *idp; struct _ParaListS { struct _ParaDefS { struct _IdentS *idp; struct _ParaDefS *next; } *pdp; struct _ParaListS *next; } *plp; } *php; struct _BlockS { struct _ConstDecS { struct _ConstDefS { struct _IdentS *idp; } *cdp; struct _ConstDecS *next; } *cdp; struct _VarDecS { struct _VarDefS { struct _IdentS *idp; struct _VarDefS *next; } *vdp; struct _VarDecS *next; } *vdp; struct _PFDecListS *pfdlp; struct _CompStmtS { struct _StmtS { enum Stmt_t { Assgin_Stmt_t=0, IF_Stmt_t=1, Repeat_Stmt_t=2, Pcall_Stmt_t=3, Comp_Stmt_t=4, Read_Stmt_t=5, Write_Stmt_t=6, For_Stmt_t=7, Null_Stmt_t=8 } type; struct _AssignStmtS { enum Assgin_t { Norm_Assgin_t=0, Fun_Assgin_t=1, Array_Assgin_t=2 } type; struct _IdentS *idp; struct _ExprS { enum Addop_t { Nop_Addop_t=0, Add_Addop_t=1, Neg_Addop_t=2, Minus_Addop_t=3 } op; struct _TermS { enum Multop_t { Nop_Multop_t=0, Mult_Multop_t=1, Div_Multop_t=2 } op; struct _FactorS { enum Factor_t { Id_Factor_t=0, Array_Factor_t=1, Unsign_Factor_t=2, Expr_Factor_t=3, Funcall_Factor_t=4 } type; struct _IdentS *idp; struct _ExprS *ep; int usi; struct _FcallStmtS { struct _IdentS *idp; struct _ArgListS { struct _ExprS *ep; struct _ArgListS *next; } *alp; } *fcsp; } *fp; struct _TermS *next; } *tp; struct _ExprS *next; } *lep; struct _ExprS *rep; } *asp; struct _IfStmtS { struct _CondS { struct _ExprS *lep; enum Rela_t { Equ_Rela_t=0, Neq_Rela_t=1, Gtt_Rela_t=2, Geq_Rela_t=3, Lst_Rela_t=4, Leq_Rela_t=5 } op; struct _ExprS *rep; } *cp; struct _StmtS *tp; struct _StmtS *ep; } *ifp; struct _RepeStmtS { struct _StmtS *sp; struct _CondS *cp; } *rpp; struct _ForStmtS { enum For_t { To_For_t=0, Downto_For_t=1 } type; struct _IdentS *idp; struct _ExprS *lep; struct _ExprS *rep; struct _StmtS *sp; } *frp; struct _PcallStmtS { struct _IdentS *idp; struct _ArgListS *alp; } *pcp; struct _CompStmtS *cpp; struct _ReadStmtS { struct _IdentS *idp; struct _ReadStmtS *next; } *rdp; struct _WriteStmtS { enum Write_t { StrId_Write_t=0, Str_Write_t=1, Id_Write_t=2 } type; char *sp; struct _ExprS *ep; } *wtp; } *sp; struct _CompStmtS *next; } *csp; } *bp; } *pdp; struct _ProcDecS *next; } *pdp; struct _FunDecS { struct _FunDefS { struct _FunHeadS { struct _IdentS *idp; struct _ParaListS *plp; } *fhp; struct _BlockS *bp; } *fdp; struct _FunDecS *next; } *fdp; struct _PFDecListS *next; } *

user_defined_types: struct _PFDecListS { enum PFDec_t type; struct _ProcDecS *pdp; struct _FunDecS *fdp; struct _PFDecListS *next; }

user_defined_types: struct _ProcDecS { struct _ProcDefS *pdp; struct _ProcDecS *next; }

user_defined_types: struct _FunDecS { struct _FunDefS *fdp; struct _FunDecS *next; }

user_defined_types: struct _ProcDefS { struct _ProcHeadS *php; struct _BlockS *bp; }

user_defined_types: struct _FunDefS { struct _FunHeadS *fhp; struct _BlockS *bp; }

user_defined_types: struct _ProcHeadS { struct _IdentS *idp; struct _ParaListS *plp; }

user_defined_types: struct _BlockS { struct _ConstDecS *cdp; struct _VarDecS *vdp; struct _PFDecListS *pfdlp; struct _CompStmtS *csp; }

user_defined_types: struct _ParaListS { struct _ParaDefS *pdp; struct _ParaListS *next; }

user_defined_types: struct _ConstDecS { struct _ConstDefS *cdp; struct _ConstDecS *next; }

user_defined_types: struct _VarDecS { struct _VarDefS *vdp; struct _VarDecS *next; }


BlockV

repo: Jeanhwea/Compiler

decompiled_code:
__int64 __fastcall BlockV(__int64 a1)
{
headPr("Block");
if ( a1 )
{
ConstDecV(*(_QWORD *)a1);
VarDecV(*(_QWORD *)(a1 + 8));
PFDecListV(*(_QWORD *)(a1 + 16));
CompStmtV(*(__int64 **)(a1 + 24));
}
return tailPr("Block");
}

original_code:
void BlockV(BlockSP t)
{
  headPr("Block");
  if (t != ((void *)0)) {
    ConstDecV(t->cdp);
    VarDecV(t->vdp);
    PFDecListV(t->pfdlp);
    CompStmtV(t->csp);
  }
  tailPr("Block");
}

canonical_original_code:
void BlockV(struct _BlockS *t)
{
  headPr("Block");
  if (t != ((void *)0)) {
    ConstDecV(t->cdp);
    VarDecV(t->vdp);
    PFDecListV(t->pfdlp);
    CompStmtV(t->csp);
  }
  tailPr("Block");
}

variable_types: struct _BlockS { struct _ConstDecS { struct _ConstDefS { struct _IdentS { enum Ident_t { Init_Ident_t=0, Proc_Ident_t=1, Int_Fun_Ident_t=2, Char_Fun_Ident_t=3, Int_Const_Ident_t=4, Char_Const_Ident_t=5, Int_Var_Ident_t=6, Char_Var_Ident_t=7, IntArr_Var_Ident_t=8, CharArr_Var_Ident_t=9, Int_Para_Val_Ident_t=10, Char_Para_Val_Ident_t=11, Int_Para_Ref_Ident_t=12, Char_Para_Ref_Ident_t=13 } type; char *name; int val; int length; int line; } *idp; } *cdp; struct _ConstDecS *next; } *cdp; struct _VarDecS { struct _VarDefS { struct _IdentS *idp; struct _VarDefS *next; } *vdp; struct _VarDecS *next; } *vdp; struct _PFDecListS { enum PFDec_t { Fun_PFDec_t=0, Proc_PFDec_t=1 } type; struct _ProcDecS { struct _ProcDefS { struct _ProcHeadS { struct _IdentS *idp; struct _ParaListS { struct _ParaDefS { struct _IdentS *idp; struct _ParaDefS *next; } *pdp; struct _ParaListS *next; } *plp; } *php; struct _BlockS *bp; } *pdp; struct _ProcDecS *next; } *pdp; struct _FunDecS { struct _FunDefS { struct _FunHeadS { struct _IdentS *idp; struct _ParaListS *plp; } *fhp; struct _BlockS *bp; } *fdp; struct _FunDecS *next; } *fdp; struct _PFDecListS *next; } *pfdlp; struct _CompStmtS { struct _StmtS { enum Stmt_t { Assgin_Stmt_t=0, IF_Stmt_t=1, Repeat_Stmt_t=2, Pcall_Stmt_t=3, Comp_Stmt_t=4, Read_Stmt_t=5, Write_Stmt_t=6, For_Stmt_t=7, Null_Stmt_t=8 } type; struct _AssignStmtS { enum Assgin_t { Norm_Assgin_t=0, Fun_Assgin_t=1, Array_Assgin_t=2 } type; struct _IdentS *idp; struct _ExprS { enum Addop_t { Nop_Addop_t=0, Add_Addop_t=1, Neg_Addop_t=2, Minus_Addop_t=3 } op; struct _TermS { enum Multop_t { Nop_Multop_t=0, Mult_Multop_t=1, Div_Multop_t=2 } op; struct _FactorS { enum Factor_t { Id_Factor_t=0, Array_Factor_t=1, Unsign_Factor_t=2, Expr_Factor_t=3, Funcall_Factor_t=4 } type; struct _IdentS *idp; struct _ExprS *ep; int usi; struct _FcallStmtS { struct _IdentS *idp; struct _ArgListS { struct _ExprS *ep; struct _ArgListS *next; } *alp; } *fcsp; } *fp; struct _TermS *next; } *tp; struct _ExprS *next; } *lep; struct _ExprS *rep; } *asp; struct _IfStmtS { struct _CondS { struct _ExprS *lep; enum Rela_t { Equ_Rela_t=0, Neq_Rela_t=1, Gtt_Rela_t=2, Geq_Rela_t=3, Lst_Rela_t=4, Leq_Rela_t=5 } op; struct _ExprS *rep; } *cp; struct _StmtS *tp; struct _StmtS *ep; } *ifp; struct _RepeStmtS { struct _StmtS *sp; struct _CondS *cp; } *rpp; struct _ForStmtS { enum For_t { To_For_t=0, Downto_For_t=1 } type; struct _IdentS *idp; struct _ExprS *lep; struct _ExprS *rep; struct _StmtS *sp; } *frp; struct _PcallStmtS { struct _IdentS *idp; struct _ArgListS *alp; } *pcp; struct _CompStmtS *cpp; struct _ReadStmtS { struct _IdentS *idp; struct _ReadStmtS *next; } *rdp; struct _WriteStmtS { enum Write_t { StrId_Write_t=0, Str_Write_t=1, Id_Write_t=2 } type; char *sp; struct _ExprS *ep; } *wtp; } *sp; struct _CompStmtS *next; } *csp; } *

return_type: void

user_defined_types: struct _CompStmtS { struct _StmtS *sp; struct _CompStmtS *next; }

user_defined_types: struct _ConstDefS { struct _IdentS *idp; }

user_defined_types: struct _StmtS { enum Stmt_t type; struct _AssignStmtS *asp; struct _IfStmtS *ifp; struct _RepeStmtS *rpp; struct _ForStmtS *frp; struct _PcallStmtS *pcp; struct _CompStmtS *cpp; struct _ReadStmtS *rdp; struct _WriteStmtS *wtp; }

user_defined_types: struct _IdentS { enum Ident_t type; char *name; int val; int length; int line; }

user_defined_types: struct _AssignStmtS { enum Assgin_t type; struct _IdentS *idp; struct _ExprS *lep; struct _ExprS *rep; }

user_defined_types: struct _IfStmtS { struct _CondS *cp; struct _StmtS *tp; struct _StmtS *ep; }

user_defined_types: struct _ForStmtS { enum For_t type; struct _IdentS *idp; struct _ExprS *lep; struct _ExprS *rep; struct _StmtS *sp; }

user_defined_types: struct _WriteStmtS { enum Write_t type; char *sp; struct _ExprS *ep; }

user_defined_types: struct _ExprS { enum Addop_t op; struct _TermS *tp; struct _ExprS *next; }

user_defined_types: struct _CondS { struct _ExprS *lep; enum Rela_t op; struct _ExprS *rep; }

user_defined_types: struct _TermS { enum Multop_t op; struct _FactorS *fp; struct _TermS *next; }

user_defined_types: struct _FactorS { enum Factor_t type; struct _IdentS *idp; struct _ExprS *ep; int usi; struct _FcallStmtS *fcsp; }

user_defined_types: struct _FcallStmtS { struct _IdentS *idp; struct _ArgListS *alp; }


PgmV

decompiled_code:
__int64 __fastcall PgmV(__int64 *a1)
{
headPr("Pgm");
if ( a1 )
BlockV(*a1);
return tailPr("Pgm");
}

canonical_decompiled_code:
__int64 __fastcall func26(__int64 *a1)
{
headPr("Pgm");
if ( a1 )
func25(*a1);
return tailPr("Pgm");
}

original_code:
void PgmV(PgmSP t)
{
  headPr("Pgm");
  if (t != ((void *)0)) {
    BlockV(t->bp);
  }
  tailPr("Pgm");
}

canonical_original_code:
void PgmV(struct _PgmS *t)
{
  headPr("Pgm");
  if (t != ((void *)0)) {
    BlockV(t->bp);
  }
  tailPr("Pgm");
}

variable_types: struct _PgmS { struct _BlockS { struct _ConstDecS { struct _ConstDefS { struct _IdentS { enum Ident_t { Init_Ident_t=0, Proc_Ident_t=1, Int_Fun_Ident_t=2, Char_Fun_Ident_t=3, Int_Const_Ident_t=4, Char_Const_Ident_t=5, Int_Var_Ident_t=6, Char_Var_Ident_t=7, IntArr_Var_Ident_t=8, CharArr_Var_Ident_t=9, Int_Para_Val_Ident_t=10, Char_Para_Val_Ident_t=11, Int_Para_Ref_Ident_t=12, Char_Para_Ref_Ident_t=13 } type; char *name; int val; int length; int line; } *idp; } *cdp; struct _ConstDecS *next; } *cdp; struct _VarDecS { struct _VarDefS { struct _IdentS *idp; struct _VarDefS *next; } *vdp; struct _VarDecS *next; } *vdp; struct _PFDecListS { enum PFDec_t { Fun_PFDec_t=0, Proc_PFDec_t=1 } type; struct _ProcDecS { struct _ProcDefS { struct _ProcHeadS { struct _IdentS *idp; struct _ParaListS { struct _ParaDefS { struct _IdentS *idp; struct _ParaDefS *next; } *pdp; struct _ParaListS *next; } *plp; } *php; struct _BlockS *bp; } *pdp; struct _ProcDecS *next; } *pdp; struct _FunDecS { struct _FunDefS { struct _FunHeadS { struct _IdentS *idp; struct _ParaListS *plp; } *fhp; struct _BlockS *bp; } *fdp; struct _FunDecS *next; } *fdp; struct _PFDecListS *next; } *pfdlp; struct _CompStmtS { struct _StmtS { enum Stmt_t { Assgin_Stmt_t=0, IF_Stmt_t=1, Repeat_Stmt_t=2, Pcall_Stmt_t=3, Comp_Stmt_t=4, Read_Stmt_t=5, Write_Stmt_t=6, For_Stmt_t=7, Null_Stmt_t=8 } type; struct _AssignStmtS { enum Assgin_t { Norm_Assgin_t=0, Fun_Assgin_t=1, Array_Assgin_t=2 } type; struct _IdentS *idp; struct _ExprS { enum Addop_t { Nop_Addop_t=0, Add_Addop_t=1, Neg_Addop_t=2, Minus_Addop_t=3 } op; struct _TermS { enum Multop_t { Nop_Multop_t=0, Mult_Multop_t=1, Div_Multop_t=2 } op; struct _FactorS { enum Factor_t { Id_Factor_t=0, Array_Factor_t=1, Unsign_Factor_t=2, Expr_Factor_t=3, Funcall_Factor_t=4 } type; struct _IdentS *idp; struct _ExprS *ep; int usi; struct _FcallStmtS { struct _IdentS *idp; struct _ArgListS { struct _ExprS *ep; struct _ArgListS *next; } *alp; } *fcsp; } *fp; struct _TermS *next; } *tp; struct _ExprS *next; } *lep; struct _ExprS *rep; } *asp; struct _IfStmtS { struct _CondS { struct _ExprS *lep; enum Rela_t { Equ_Rela_t=0, Neq_Rela_t=1, Gtt_Rela_t=2, Geq_Rela_t=3, Lst_Rela_t=4, Leq_Rela_t=5 } op; struct _ExprS *rep; } *cp; struct _StmtS *tp; struct _StmtS *ep; } *ifp; struct _RepeStmtS { struct _StmtS *sp; struct _CondS *cp; } *rpp; struct _ForStmtS { enum For_t { To_For_t=0, Downto_For_t=1 } type; struct _IdentS *idp; struct _ExprS *lep; struct _ExprS *rep; struct _StmtS *sp; } *frp; struct _PcallStmtS { struct _IdentS *idp; struct _ArgListS *alp; } *pcp; struct _CompStmtS *cpp; struct _ReadStmtS { struct _IdentS *idp; struct _ReadStmtS *next; } *rdp; struct _WriteStmtS { enum Write_t { StrId_Write_t=0, Str_Write_t=1, Id_Write_t=2 } type; char *sp; struct _ExprS *ep; } *wtp; } *sp; struct _CompStmtS *next; } *csp; } *bp; } *

user_defined_types: struct _BlockS { struct _ConstDecS *cdp; struct _VarDecS *vdp; struct _PFDecListS *pfdlp; struct _CompStmtS *csp; }

user_defined_types: struct _PFDecListS { enum PFDec_t type; struct _ProcDecS *pdp; struct _FunDecS *fdp; struct _PFDecListS *next; }

user_defined_types: struct _ProcDecS { struct _ProcDefS *pdp; struct _ProcDecS *next; }

user_defined_types: struct _FunDecS { struct _FunDefS *fdp; struct _FunDecS *next; }

user_defined_types: struct _ProcDefS { struct _ProcHeadS *php; struct _BlockS *bp; }

user_defined_types: struct _FunDefS { struct _FunHeadS *fhp; struct _BlockS *bp; }

user_defined_types: struct _ProcHeadS { struct _IdentS *idp; struct _ParaListS *plp; }


ProcDefV

decompiled_code:
__int64 __fastcall ProcDefV(__int64 a1)
{
headPr("ProcDef");
if ( a1 )
{
ProcHeadV(*(__int64 **)a1);
BlockV(*(_QWORD *)(a1 + 8));
}
return tailPr("ProcDef");
}

canonical_decompiled_code:
__int64 __fastcall func27(__int64 a1)
{
headPr("ProcDef");
if ( a1 )
{
func7(*(__int64 **)a1);
func25(*(_QWORD *)(a1 + 8));
}
return tailPr("ProcDef");
}

original_code:
void ProcDefV(ProcDefSP t)
{
  headPr("ProcDef");
  if (t != ((void *)0)) {
    ProcHeadV(t->php);
    BlockV(t->bp);
  }
  tailPr("ProcDef");
}

canonical_original_code:
void ProcDefV(struct _ProcDefS *t)
{
  headPr("ProcDef");
  if (t != ((void *)0)) {
    ProcHeadV(t->php);
    BlockV(t->bp);
  }
  tailPr("ProcDef");
}

variable_types: struct _ProcDefS { struct _ProcHeadS { struct _IdentS { enum Ident_t { Init_Ident_t=0, Proc_Ident_t=1, Int_Fun_Ident_t=2, Char_Fun_Ident_t=3, Int_Const_Ident_t=4, Char_Const_Ident_t=5, Int_Var_Ident_t=6, Char_Var_Ident_t=7, IntArr_Var_Ident_t=8, CharArr_Var_Ident_t=9, Int_Para_Val_Ident_t=10, Char_Para_Val_Ident_t=11, Int_Para_Ref_Ident_t=12, Char_Para_Ref_Ident_t=13 } type; char *name; int val; int length; int line; } *idp; struct _ParaListS { struct _ParaDefS { struct _IdentS *idp; struct _ParaDefS *next; } *pdp; struct _ParaListS *next; } *plp; } *php; struct _BlockS { struct _ConstDecS { struct _ConstDefS { struct _IdentS *idp; } *cdp; struct _ConstDecS *next; } *cdp; struct _VarDecS { struct _VarDefS { struct _IdentS *idp; struct _VarDefS *next; } *vdp; struct _VarDecS *next; } *vdp; struct _PFDecListS { enum PFDec_t { Fun_PFDec_t=0, Proc_PFDec_t=1 } type; struct _ProcDecS { struct _ProcDefS *pdp; struct _ProcDecS *next; } *pdp; struct _FunDecS { struct _FunDefS { struct _FunHeadS { struct _IdentS *idp; struct _ParaListS *plp; } *fhp; struct _BlockS *bp; } *fdp; struct _FunDecS *next; } *fdp; struct _PFDecListS *next; } *pfdlp; struct _CompStmtS { struct _StmtS { enum Stmt_t { Assgin_Stmt_t=0, IF_Stmt_t=1, Repeat_Stmt_t=2, Pcall_Stmt_t=3, Comp_Stmt_t=4, Read_Stmt_t=5, Write_Stmt_t=6, For_Stmt_t=7, Null_Stmt_t=8 } type; struct _AssignStmtS { enum Assgin_t { Norm_Assgin_t=0, Fun_Assgin_t=1, Array_Assgin_t=2 } type; struct _IdentS *idp; struct _ExprS { enum Addop_t { Nop_Addop_t=0, Add_Addop_t=1, Neg_Addop_t=2, Minus_Addop_t=3 } op; struct _TermS { enum Multop_t { Nop_Multop_t=0, Mult_Multop_t=1, Div_Multop_t=2 } op; struct _FactorS { enum Factor_t { Id_Factor_t=0, Array_Factor_t=1, Unsign_Factor_t=2, Expr_Factor_t=3, Funcall_Factor_t=4 } type; struct _IdentS *idp; struct _ExprS *ep; int usi; struct _FcallStmtS { struct _IdentS *idp; struct _ArgListS { struct _ExprS *ep; struct _ArgListS *next; } *alp; } *fcsp; } *fp; struct _TermS *next; } *tp; struct _ExprS *next; } *lep; struct _ExprS *rep; } *asp; struct _IfStmtS { struct _CondS { struct _ExprS *lep; enum Rela_t { Equ_Rela_t=0, Neq_Rela_t=1, Gtt_Rela_t=2, Geq_Rela_t=3, Lst_Rela_t=4, Leq_Rela_t=5 } op; struct _ExprS *rep; } *cp; struct _StmtS *tp; struct _StmtS *ep; } *ifp; struct _RepeStmtS { struct _StmtS *sp; struct _CondS *cp; } *rpp; struct _ForStmtS { enum For_t { To_For_t=0, Downto_For_t=1 } type; struct _IdentS *idp; struct _ExprS *lep; struct _ExprS *rep; struct _StmtS *sp; } *frp; struct _PcallStmtS { struct _IdentS *idp; struct _ArgListS *alp; } *pcp; struct _CompStmtS *cpp; struct _ReadStmtS { struct _IdentS *idp; struct _ReadStmtS *next; } *rdp; struct _WriteStmtS { enum Write_t { StrId_Write_t=0, Str_Write_t=1, Id_Write_t=2 } type; char *sp; struct _ExprS *ep; } *wtp; } *sp; struct _CompStmtS *next; } *csp; } *bp; } *

user_defined_types: struct _IdentS { enum Ident_t type; char *name; int val; int length; int line; }

user_defined_types: struct _ParaListS { struct _ParaDefS *pdp; struct _ParaListS *next; }

user_defined_types: struct _ConstDecS { struct _ConstDefS *cdp; struct _ConstDecS *next; }

user_defined_types: struct _VarDecS { struct _VarDefS *vdp; struct _VarDecS *next; }

user_defined_types: struct _CompStmtS { struct _StmtS *sp; struct _CompStmtS *next; }

user_defined_types: struct _StmtS { enum Stmt_t type; struct _AssignStmtS *asp; struct _IfStmtS *ifp; struct _RepeStmtS *rpp; struct _ForStmtS *frp; struct _PcallStmtS *pcp; struct _CompStmtS *cpp; struct _ReadStmtS *rdp; struct _WriteStmtS *wtp; }


ProcDecV

decompiled_code:
__int64 __fastcall ProcDecV(__int64 *a1)
{
__int64 *v1; // rbx

v1 = a1;
headPr("ProcDec");
if ( a1 )
{
do
{
ProcDefV(*v1);
v1 = (__int64 *)v1[1];
}
while ( v1 );
}
return tailPr("ProcDec");
}

canonical_decompiled_code:
__int64 __fastcall func28(__int64 *a1)
{
__int64 *v1; // rbx

v1 = a1;
headPr("ProcDec");
if ( a1 )
{
do
{
func27(*v1);
v1 = (__int64 *)v1[1];
}
while ( v1 );
}
return tailPr("ProcDec");
}

original_code:
void ProcDecV(ProcDecSP t)
{
  headPr("ProcDec");
  for (; t != ((void *)0); t = t->next) {
    ProcDefV(t->pdp);
  }
  tailPr("ProcDec");
}

canonical_original_code:
void ProcDecV(struct _ProcDecS *t)
{
  headPr("ProcDec");
  for (; t != ((void *)0); t = t->next) {
    ProcDefV(t->pdp);
  }
  tailPr("ProcDec");
}

variable_types: struct _ProcDecS { struct _ProcDefS { struct _ProcHeadS { struct _IdentS { enum Ident_t { Init_Ident_t=0, Proc_Ident_t=1, Int_Fun_Ident_t=2, Char_Fun_Ident_t=3, Int_Const_Ident_t=4, Char_Const_Ident_t=5, Int_Var_Ident_t=6, Char_Var_Ident_t=7, IntArr_Var_Ident_t=8, CharArr_Var_Ident_t=9, Int_Para_Val_Ident_t=10, Char_Para_Val_Ident_t=11, Int_Para_Ref_Ident_t=12, Char_Para_Ref_Ident_t=13 } type; char *name; int val; int length; int line; } *idp; struct _ParaListS { struct _ParaDefS { struct _IdentS *idp; struct _ParaDefS *next; } *pdp; struct _ParaListS *next; } *plp; } *php; struct _BlockS { struct _ConstDecS { struct _ConstDefS { struct _IdentS *idp; } *cdp; struct _ConstDecS *next; } *cdp; struct _VarDecS { struct _VarDefS { struct _IdentS *idp; struct _VarDefS *next; } *vdp; struct _VarDecS *next; } *vdp; struct _PFDecListS { enum PFDec_t { Fun_PFDec_t=0, Proc_PFDec_t=1 } type; struct _ProcDecS *pdp; struct _FunDecS { struct _FunDefS { struct _FunHeadS { struct _IdentS *idp; struct _ParaListS *plp; } *fhp; struct _BlockS *bp; } *fdp; struct _FunDecS *next; } *fdp; struct _PFDecListS *next; } *pfdlp; struct _CompStmtS { struct _StmtS { enum Stmt_t { Assgin_Stmt_t=0, IF_Stmt_t=1, Repeat_Stmt_t=2, Pcall_Stmt_t=3, Comp_Stmt_t=4, Read_Stmt_t=5, Write_Stmt_t=6, For_Stmt_t=7, Null_Stmt_t=8 } type; struct _AssignStmtS { enum Assgin_t { Norm_Assgin_t=0, Fun_Assgin_t=1, Array_Assgin_t=2 } type; struct _IdentS *idp; struct _ExprS { enum Addop_t { Nop_Addop_t=0, Add_Addop_t=1, Neg_Addop_t=2, Minus_Addop_t=3 } op; struct _TermS { enum Multop_t { Nop_Multop_t=0, Mult_Multop_t=1, Div_Multop_t=2 } op; struct _FactorS { enum Factor_t { Id_Factor_t=0, Array_Factor_t=1, Unsign_Factor_t=2, Expr_Factor_t=3, Funcall_Factor_t=4 } type; struct _IdentS *idp; struct _ExprS *ep; int usi; struct _FcallStmtS { struct _IdentS *idp; struct _ArgListS { struct _ExprS *ep; struct _ArgListS *next; } *alp; } *fcsp; } *fp; struct _TermS *next; } *tp; struct _ExprS *next; } *lep; struct _ExprS *rep; } *asp; struct _IfStmtS { struct _CondS { struct _ExprS *lep; enum Rela_t { Equ_Rela_t=0, Neq_Rela_t=1, Gtt_Rela_t=2, Geq_Rela_t=3, Lst_Rela_t=4, Leq_Rela_t=5 } op; struct _ExprS *rep; } *cp; struct _StmtS *tp; struct _StmtS *ep; } *ifp; struct _RepeStmtS { struct _StmtS *sp; struct _CondS *cp; } *rpp; struct _ForStmtS { enum For_t { To_For_t=0, Downto_For_t=1 } type; struct _IdentS *idp; struct _ExprS *lep; struct _ExprS *rep; struct _StmtS *sp; } *frp; struct _PcallStmtS { struct _IdentS *idp; struct _ArgListS *alp; } *pcp; struct _CompStmtS *cpp; struct _ReadStmtS { struct _IdentS *idp; struct _ReadStmtS *next; } *rdp; struct _WriteStmtS { enum Write_t { StrId_Write_t=0, Str_Write_t=1, Id_Write_t=2 } type; char *sp; struct _ExprS *ep; } *wtp; } *sp; struct _CompStmtS *next; } *csp; } *bp; } *pdp; struct _ProcDecS *next; } *

user_defined_types: struct _AssignStmtS { enum Assgin_t type; struct _IdentS *idp; struct _ExprS *lep; struct _ExprS *rep; }

user_defined_types: struct _IfStmtS { struct _CondS *cp; struct _StmtS *tp; struct _StmtS *ep; }

user_defined_types: struct _ForStmtS { enum For_t type; struct _IdentS *idp; struct _ExprS *lep; struct _ExprS *rep; struct _StmtS *sp; }

user_defined_types: struct _WriteStmtS { enum Write_t type; char *sp; struct _ExprS *ep; }

user_defined_types: struct _ExprS { enum Addop_t op; struct _TermS *tp; struct _ExprS *next; }

user_defined_types: struct _CondS { struct _ExprS *lep; enum Rela_t op; struct _ExprS *rep; }


FunDefV

decompiled_code:
__int64 __fastcall FunDefV(__int64 a1)
{
headPr("FunDef");
if ( a1 )
{
FunHeadV(*(__int64 **)a1);
BlockV(*(_QWORD *)(a1 + 8));
}
return tailPr("FunDef");
}

canonical_decompiled_code:
__int64 __fastcall func29(__int64 a1)
{
headPr("FunDef");
if ( a1 )
{
func8(*(__int64 **)a1);
func25(*(_QWORD *)(a1 + 8));
}
return tailPr("FunDef");
}

original_code:
void FunDefV(FunDefSP t)
{
  headPr("FunDef");
  if (t != ((void *)0)) {
    FunHeadV(t->fhp);
    BlockV(t->bp);
  }
  tailPr("FunDef");
}

canonical_original_code:
void FunDefV(struct _FunDefS *t)
{
  headPr("FunDef");
  if (t != ((void *)0)) {
    FunHeadV(t->fhp);
    BlockV(t->bp);
  }
  tailPr("FunDef");
}

variable_types: struct _FunDefS { struct _FunHeadS { struct _IdentS { enum Ident_t { Init_Ident_t=0, Proc_Ident_t=1, Int_Fun_Ident_t=2, Char_Fun_Ident_t=3, Int_Const_Ident_t=4, Char_Const_Ident_t=5, Int_Var_Ident_t=6, Char_Var_Ident_t=7, IntArr_Var_Ident_t=8, CharArr_Var_Ident_t=9, Int_Para_Val_Ident_t=10, Char_Para_Val_Ident_t=11, Int_Para_Ref_Ident_t=12, Char_Para_Ref_Ident_t=13 } type; char *name; int val; int length; int line; } *idp; struct _ParaListS { struct _ParaDefS { struct _IdentS *idp; struct _ParaDefS *next; } *pdp; struct _ParaListS *next; } *plp; } *fhp; struct _BlockS { struct _ConstDecS { struct _ConstDefS { struct _IdentS *idp; } *cdp; struct _ConstDecS *next; } *cdp; struct _VarDecS { struct _VarDefS { struct _IdentS *idp; struct _VarDefS *next; } *vdp; struct _VarDecS *next; } *vdp; struct _PFDecListS { enum PFDec_t { Fun_PFDec_t=0, Proc_PFDec_t=1 } type; struct _ProcDecS { struct _ProcDefS { struct _ProcHeadS { struct _IdentS *idp; struct _ParaListS *plp; } *php; struct _BlockS *bp; } *pdp; struct _ProcDecS *next; } *pdp; struct _FunDecS { struct _FunDefS *fdp; struct _FunDecS *next; } *fdp; struct _PFDecListS *next; } *pfdlp; struct _CompStmtS { struct _StmtS { enum Stmt_t { Assgin_Stmt_t=0, IF_Stmt_t=1, Repeat_Stmt_t=2, Pcall_Stmt_t=3, Comp_Stmt_t=4, Read_Stmt_t=5, Write_Stmt_t=6, For_Stmt_t=7, Null_Stmt_t=8 } type; struct _AssignStmtS { enum Assgin_t { Norm_Assgin_t=0, Fun_Assgin_t=1, Array_Assgin_t=2 } type; struct _IdentS *idp; struct _ExprS { enum Addop_t { Nop_Addop_t=0, Add_Addop_t=1, Neg_Addop_t=2, Minus_Addop_t=3 } op; struct _TermS { enum Multop_t { Nop_Multop_t=0, Mult_Multop_t=1, Div_Multop_t=2 } op; struct _FactorS { enum Factor_t { Id_Factor_t=0, Array_Factor_t=1, Unsign_Factor_t=2, Expr_Factor_t=3, Funcall_Factor_t=4 } type; struct _IdentS *idp; struct _ExprS *ep; int usi; struct _FcallStmtS { struct _IdentS *idp; struct _ArgListS { struct _ExprS *ep; struct _ArgListS *next; } *alp; } *fcsp; } *fp; struct _TermS *next; } *tp; struct _ExprS *next; } *lep; struct _ExprS *rep; } *asp; struct _IfStmtS { struct _CondS { struct _ExprS *lep; enum Rela_t { Equ_Rela_t=0, Neq_Rela_t=1, Gtt_Rela_t=2, Geq_Rela_t=3, Lst_Rela_t=4, Leq_Rela_t=5 } op; struct _ExprS *rep; } *cp; struct _StmtS *tp; struct _StmtS *ep; } *ifp; struct _RepeStmtS { struct _StmtS *sp; struct _CondS *cp; } *rpp; struct _ForStmtS { enum For_t { To_For_t=0, Downto_For_t=1 } type; struct _IdentS *idp; struct _ExprS *lep; struct _ExprS *rep; struct _StmtS *sp; } *frp; struct _PcallStmtS { struct _IdentS *idp; struct _ArgListS *alp; } *pcp; struct _CompStmtS *cpp; struct _ReadStmtS { struct _IdentS *idp; struct _ReadStmtS *next; } *rdp; struct _WriteStmtS { enum Write_t { StrId_Write_t=0, Str_Write_t=1, Id_Write_t=2 } type; char *sp; struct _ExprS *ep; } *wtp; } *sp; struct _CompStmtS *next; } *csp; } *bp; } *

user_defined_types: struct _FunHeadS { struct _IdentS *idp; struct _ParaListS *plp; }

user_defined_types: struct _BlockS { struct _ConstDecS *cdp; struct _VarDecS *vdp; struct _PFDecListS *pfdlp; struct _CompStmtS *csp; }

user_defined_types: struct _PFDecListS { enum PFDec_t type; struct _ProcDecS *pdp; struct _FunDecS *fdp; struct _PFDecListS *next; }

user_defined_types: struct _ProcDecS { struct _ProcDefS *pdp; struct _ProcDecS *next; }

user_defined_types: struct _TermS { enum Multop_t op; struct _FactorS *fp; struct _TermS *next; }

user_defined_types: struct _FactorS { enum Factor_t type; struct _IdentS *idp; struct _ExprS *ep; int usi; struct _FcallStmtS *fcsp; }

user_defined_types: struct _FcallStmtS { struct _IdentS *idp; struct _ArgListS *alp; }


FunDecV

decompiled_code:
__int64 __fastcall FunDecV(__int64 *a1)
{
__int64 *v1; // rbx

v1 = a1;
headPr("FunDec");
if ( a1 )
{
do
{
FunDefV(*v1);
v1 = (__int64 *)v1[1];
}
while ( v1 );
}
return tailPr("FunDec");
}

canonical_decompiled_code:
__int64 __fastcall func30(__int64 *a1)
{
__int64 *v1; // rbx

v1 = a1;
headPr("FunDec");
if ( a1 )
{
do
{
func29(*v1);
v1 = (__int64 *)v1[1];
}
while ( v1 );
}
return tailPr("FunDec");
}

original_code:
void FunDecV(FunDecSP t)
{
  headPr("FunDec");
  for (; t != ((void *)0); t = t->next) {
    FunDefV(t->fdp);
  }
  tailPr("FunDec");
}

canonical_original_code:
void FunDecV(struct _FunDecS *t)
{
  headPr("FunDec");
  for (; t != ((void *)0); t = t->next) {
    FunDefV(t->fdp);
  }
  tailPr("FunDec");
}

variable_types: struct _FunDecS { struct _FunDefS { struct _FunHeadS { struct _IdentS { enum Ident_t { Init_Ident_t=0, Proc_Ident_t=1, Int_Fun_Ident_t=2, Char_Fun_Ident_t=3, Int_Const_Ident_t=4, Char_Const_Ident_t=5, Int_Var_Ident_t=6, Char_Var_Ident_t=7, IntArr_Var_Ident_t=8, CharArr_Var_Ident_t=9, Int_Para_Val_Ident_t=10, Char_Para_Val_Ident_t=11, Int_Para_Ref_Ident_t=12, Char_Para_Ref_Ident_t=13 } type; char *name; int val; int length; int line; } *idp; struct _ParaListS { struct _ParaDefS { struct _IdentS *idp; struct _ParaDefS *next; } *pdp; struct _ParaListS *next; } *plp; } *fhp; struct _BlockS { struct _ConstDecS { struct _ConstDefS { struct _IdentS *idp; } *cdp; struct _ConstDecS *next; } *cdp; struct _VarDecS { struct _VarDefS { struct _IdentS *idp; struct _VarDefS *next; } *vdp; struct _VarDecS *next; } *vdp; struct _PFDecListS { enum PFDec_t { Fun_PFDec_t=0, Proc_PFDec_t=1 } type; struct _ProcDecS { struct _ProcDefS { struct _ProcHeadS { struct _IdentS *idp; struct _ParaListS *plp; } *php; struct _BlockS *bp; } *pdp; struct _ProcDecS *next; } *pdp; struct _FunDecS *fdp; struct _PFDecListS *next; } *pfdlp; struct _CompStmtS { struct _StmtS { enum Stmt_t { Assgin_Stmt_t=0, IF_Stmt_t=1, Repeat_Stmt_t=2, Pcall_Stmt_t=3, Comp_Stmt_t=4, Read_Stmt_t=5, Write_Stmt_t=6, For_Stmt_t=7, Null_Stmt_t=8 } type; struct _AssignStmtS { enum Assgin_t { Norm_Assgin_t=0, Fun_Assgin_t=1, Array_Assgin_t=2 } type; struct _IdentS *idp; struct _ExprS { enum Addop_t { Nop_Addop_t=0, Add_Addop_t=1, Neg_Addop_t=2, Minus_Addop_t=3 } op; struct _TermS { enum Multop_t { Nop_Multop_t=0, Mult_Multop_t=1, Div_Multop_t=2 } op; struct _FactorS { enum Factor_t { Id_Factor_t=0, Array_Factor_t=1, Unsign_Factor_t=2, Expr_Factor_t=3, Funcall_Factor_t=4 } type; struct _IdentS *idp; struct _ExprS *ep; int usi; struct _FcallStmtS { struct _IdentS *idp; struct _ArgListS { struct _ExprS *ep; struct _ArgListS *next; } *alp; } *fcsp; } *fp; struct _TermS *next; } *tp; struct _ExprS *next; } *lep; struct _ExprS *rep; } *asp; struct _IfStmtS { struct _CondS { struct _ExprS *lep; enum Rela_t { Equ_Rela_t=0, Neq_Rela_t=1, Gtt_Rela_t=2, Geq_Rela_t=3, Lst_Rela_t=4, Leq_Rela_t=5 } op; struct _ExprS *rep; } *cp; struct _StmtS *tp; struct _StmtS *ep; } *ifp; struct _RepeStmtS { struct _StmtS *sp; struct _CondS *cp; } *rpp; struct _ForStmtS { enum For_t { To_For_t=0, Downto_For_t=1 } type; struct _IdentS *idp; struct _ExprS *lep; struct _ExprS *rep; struct _StmtS *sp; } *frp; struct _PcallStmtS { struct _IdentS *idp; struct _ArgListS *alp; } *pcp; struct _CompStmtS *cpp; struct _ReadStmtS { struct _IdentS *idp; struct _ReadStmtS *next; } *rdp; struct _WriteStmtS { enum Write_t { StrId_Write_t=0, Str_Write_t=1, Id_Write_t=2 } type; char *sp; struct _ExprS *ep; } *wtp; } *sp; struct _CompStmtS *next; } *csp; } *bp; } *fdp; struct _FunDecS *next; } *

user_defined_types: struct _FunDecS { struct _FunDefS *fdp; struct _FunDecS *next; }

user_defined_types: struct _FunDefS { struct _FunHeadS *fhp; struct _BlockS *bp; }

user_defined_types: struct _IdentS { enum Ident_t type; char *name; int val; int length; int line; }

user_defined_types: struct _ParaListS { struct _ParaDefS *pdp; struct _ParaListS *next; }

user_defined_types: struct _ConstDecS { struct _ConstDefS *cdp; struct _ConstDecS *next; }

user_defined_types: struct _ProcDefS { struct _ProcHeadS *php; struct _BlockS *bp; }


analyse

decompiled_code:
__int64 __fastcall analyse(__int64 *a1)
{
__int64 result; // rax

if ( a1 )
result = PgmV(a1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func31(__int64 *a1)
{
__int64 result; // rax

if ( a1 )
result = func26(a1);
return result;
}

original_code:
void analyse(PgmSP t)
{
  if (t != ((void *)0))
    PgmV(t);
}

canonical_original_code:
void analyse(struct _PgmS *t)
{
  if (t != ((void *)0))
    PgmV(t);
}

user_defined_types: struct _VarDecS { struct _VarDefS *vdp; struct _VarDecS *next; }

user_defined_types: struct _CompStmtS { struct _StmtS *sp; struct _CompStmtS *next; }

user_defined_types: enum PFDec_t { Fun_PFDec_t=0, Proc_PFDec_t=1 }

user_defined_types: struct _ConstDefS { struct _IdentS *idp; }

user_defined_types: struct _VarDefS { struct _IdentS *idp; struct _VarDefS *next; }

user_defined_types: struct _StmtS { enum Stmt_t type; struct _AssignStmtS *asp; struct _IfStmtS *ifp; struct _RepeStmtS *rpp; struct _ForStmtS *frp; struct _PcallStmtS *pcp; struct _CompStmtS *cpp; struct _ReadStmtS *rdp; struct _WriteStmtS *wtp; }

user_defined_types: enum Stmt_t { Assgin_Stmt_t=0, IF_Stmt_t=1, Repeat_Stmt_t=2, Pcall_Stmt_t=3, Comp_Stmt_t=4, Read_Stmt_t=5, Write_Stmt_t=6, For_Stmt_t=7, Null_Stmt_t=8 }

user_defined_types: struct _AssignStmtS { enum Assgin_t type; struct _IdentS *idp; struct _ExprS *lep; struct _ExprS *rep; }

user_defined_types: struct _IfStmtS { struct _CondS *cp; struct _StmtS *tp; struct _StmtS *ep; }

user_defined_types: struct _RepeStmtS { struct _StmtS *sp; struct _CondS *cp; }

user_defined_types: struct _ForStmtS { enum For_t type; struct _IdentS *idp; struct _ExprS *lep; struct _ExprS *rep; struct _StmtS *sp; }

user_defined_types: struct _PcallStmtS { struct _IdentS *idp; struct _ArgListS *alp; }

user_defined_types: struct _ReadStmtS { struct _IdentS *idp; struct _ReadStmtS *next; }

user_defined_types: enum Ident_t { Init_Ident_t=0, Proc_Ident_t=1, Int_Fun_Ident_t=2, Char_Fun_Ident_t=3, Int_Const_Ident_t=4, Char_Const_Ident_t=5, Int_Var_Ident_t=6, Char_Var_Ident_t=7, IntArr_Var_Ident_t=8, CharArr_Var_Ident_t=9, Int_Para_Val_Ident_t=10, Char_Para_Val_Ident_t=11, Int_Para_Ref_Ident_t=12, Char_Para_Ref_Ident_t=13 }

user_defined_types: enum Assgin_t { Norm_Assgin_t=0, Fun_Assgin_t=1, Array_Assgin_t=2 }

user_defined_types: enum For_t { To_For_t=0, Downto_For_t=1 }

user_defined_types: enum Write_t { StrId_Write_t=0, Str_Write_t=1, Id_Write_t=2 }

user_defined_types: struct _ProcHeadS { struct _IdentS *idp; struct _ParaListS *plp; }

user_defined_types: enum Addop_t { Nop_Addop_t=0, Add_Addop_t=1, Neg_Addop_t=2, Minus_Addop_t=3 }

user_defined_types: enum Rela_t { Equ_Rela_t=0, Neq_Rela_t=1, Gtt_Rela_t=2, Geq_Rela_t=3, Lst_Rela_t=4, Leq_Rela_t=5 }

user_defined_types: enum Multop_t { Nop_Multop_t=0, Mult_Multop_t=1, Div_Multop_t=2 }

user_defined_types: struct _ParaDefS { struct _IdentS *idp; struct _ParaDefS *next; }

user_defined_types: enum Factor_t { Id_Factor_t=0, Array_Factor_t=1, Unsign_Factor_t=2, Expr_Factor_t=3, Funcall_Factor_t=4 }

user_defined_types: struct _ArgListS { struct _ExprS *ep; struct _ArgListS *next; }


decompiled_code:
__pid_t do_compile()
{
__pid_t v0; // eax
int v2; // [rsp-10h] [rbp-28h]
__WAIT_STATUS stat_loc; // [rsp+Ch] [rbp-Ch] BYREF

v0 = fork();
if ( v0 < 0 )
{
fwrite("can not fork", 1uLL, 0xCuLL, stderr);
exit(1);
}
if ( v0 )
return wait((__WAIT_STATUS)&stat_loc);
execl("/usr/bin/nasm", "nasm", "-g", "-f", "elf", asmlistf, 0LL);
return v2;
}

canonical_decompiled_code:
__pid_t func0()
{
__pid_t v0; // eax
int v2; // [rsp-10h] [rbp-28h]
__WAIT_STATUS stat_loc; // [rsp+Ch] [rbp-Ch] BYREF

v0 = fork();
if ( v0 < 0 )
{
fwrite("can not fork", 1uLL, 0xCuLL, stderr);
exit(1);
}
if ( v0 )
return wait((__WAIT_STATUS)&stat_loc);
execl("/usr/bin/nasm", "nasm", "-g", "-f", "elf", asmlistf, 0LL);
return v2;
}

original_code:
void do_compile(void)
{
 int state;
 pid_t pid;
 if ((pid = fork()) < 0) {
  fprintf(stderr, "can not fork");
  exit(1);
 }
 if (pid == 0) {
  execl("/usr/bin/nasm", "nasm", "-g", "-f", "elf", asmlistf, (char *)0);
 } else {
  wait(&state);
 }
}

canonical_original_code:
void do_compile()
{
 int state;
 int pid;
 if ((pid = fork()) < 0) {
  fprintf(stderr, "can not fork");
  exit(1);
 }
 if (pid == 0) {
  execl("/usr/bin/nasm", "nasm", "-g", "-f", "elf", asmlistf, (char *)0);
 } else {
  wait(&state);
 }
}

variable_types: state int

variable_types: pid int


decompiled_code:
__pid_t do_link()
{
size_t v0; // r12
char *v1; // r13
char *v2; // rbp
__pid_t v3; // eax
int v5; // [rsp-10h] [rbp-38h]
__WAIT_STATUS stat_loc; // [rsp+Ch] [rbp-1Ch] BYREF

v0 = fnlen;
v1 = (char *)calloc(fnlen + 1, 1uLL);
v2 = (char *)calloc((int)v0 + 3, 1uLL);
strncpy(v1, pgm, v0);
strncpy(v2, pgm, v0);
strcat(v2, ".o");
v3 = fork();
if ( v3 < 0 )
{
fwrite("can not fork", 1uLL, 0xCuLL, stderr);
exit(1);
}
if ( v3 )
return wait((__WAIT_STATUS)&stat_loc);
execl("/usr/bin/gcc", "gcc", "-g", "-o", v1, v2, 0LL);
return v5;
}

canonical_decompiled_code:
__pid_t func1()
{
size_t v0; // r12
char *v1; // r13
char *v2; // rbp
__pid_t v3; // eax
int v5; // [rsp-10h] [rbp-38h]
__WAIT_STATUS stat_loc; // [rsp+Ch] [rbp-1Ch] BYREF

v0 = fnlen;
v1 = (char *)calloc(fnlen + 1, 1uLL);
v2 = (char *)calloc((int)v0 + 3, 1uLL);
strncpy(v1, pgm, v0);
strncpy(v2, pgm, v0);
strcat(v2, ".o");
v3 = fork();
if ( v3 < 0 )
{
fwrite("can not fork", 1uLL, 0xCuLL, stderr);
exit(1);
}
if ( v3 )
return wait((__WAIT_STATUS)&stat_loc);
execl("/usr/bin/gcc", "gcc", "-g", "-o", v1, v2, 0LL);
return v5;
}

original_code:
void do_link(void)
{
 int state;
 pid_t pid;
 char *objfile;
 char *outputfile;
 outputfile = (char *)calloc(fnlen + 1, sizeof(char));
 objfile = (char *)calloc(fnlen + 3, sizeof(char));
 strncpy(outputfile, pgm, fnlen);
 strncpy(objfile, pgm, fnlen);
 strcat(objfile, ".o");
 if ((pid = fork()) < 0) {
  fprintf(stderr, "can not fork");
  exit(1);
 }
 if (pid == 0) {
  execl("/usr/bin/gcc", "gcc","-g", "-o", outputfile, objfile, (char *)0);
 } else {
  wait(&state);
 }
}

canonical_original_code:
void do_link()
{
 int state;
 int pid;
 char *objfile;
 char *outputfile;
 outputfile = (char *)calloc(fnlen + 1, sizeof(char));
 objfile = (char *)calloc(fnlen + 3, sizeof(char));
 strncpy(outputfile, pgm, fnlen);
 strncpy(objfile, pgm, fnlen);
 strcat(objfile, ".o");
 if ((pid = fork()) < 0) {
  fprintf(stderr, "can not fork");
  exit(1);
 }
 if (pid == 0) {
  execl("/usr/bin/gcc", "gcc","-g", "-o", outputfile, objfile, (char *)0);
 } else {
  wait(&state);
 }
}

variable_types:
objfile
char *

variable_types:
outputfile
char *


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbx
int v4; // eax
int v5; // er14
char v6; // dl
int v7; // er13
int v8; // ebx
int v9; // er12
char *v10; // rbp
int v11; // er14
char *v12; // rbp
int v13; // er14
char *v14; // rbp
const char *v15; // rbp
__int64 v16; // rax
__int64 v17; // rbp
int v19; // er14
char *v20; // rbp
FILE *v21; // rax
const char *v22; // rdx
int v23; // er14
char *v24; // rbp
FILE *v25; // rax
int v26; // er14
char *v27; // rbp
const char *v28; // rbp
FILE *v29; // rax
size_t v30; // rax

fwrite("compiler version 0.9.9 starting ...\n", 1uLL, 0x24uLL, stdout);
if ( argc <= 1 )
{
fwrite("usage: ./compiler <filename>\n", 1uLL, 0x1DuLL, stdout);
exit(1);
}
v3 = argc;
strcpy(pgm, argv[v3 - 1]);
source = fopen(pgm, "r");
if ( !source )
{
fprintf(stderr, "File `%s` not found\n", pgm);
exit(1);
}
if ( !strchr(pgm, 46) )
{
v30 = strlen(pgm);
*(_DWORD *)&pgm[v30] = 1935765550;
pgm[v30 + 4] = 0;
}
v4 = strcspn(pgm, ".");
fnlen = v4;
v5 = v4;
v6 = *argv[v3 - 2];
switch ( v6 )
{
case 'd':
listing = stdout;
v7 = 0;
v8 = 0;
v9 = 1;
code = stdout;
stablist = stdout;
break;
case 'o':
listing = stdout;
v7 = 0;
v8 = 1;
v9 = 1;
code = stdout;
stablist = stdout;
break;
case 's':
listing = stdout;
v7 = 0;
v8 = 1;
v9 = 0;
code = stdout;
stablist = stdout;
break;
case 'c':
listing = stdout;
v7 = 1;
v8 = 0;
v9 = 0;
code = stdout;
stablist = stdout;
break;
default:
v7 = 0;
v8 = 0;
v9 = 0;
break;
}
daglist = (__int64)stdout;
errlist = (__int64)stderr;
tiplist = (__int64)stderr;
v10 = (char *)calloc(v4 + 5, 1uLL);
asmlistf = (__int64)v10;
strncpy(v10, pgm, v5);
strcat(v10, ".asm");
asmlist = fopen(v10, "w");
if ( !asmlist )
{
v22 = (const char *)asmlistf;
LABEL_32:
fprintf(stderr, "Unable to open %s\n", v22);
goto LABEL_33;
}
if ( v8 )
{
v11 = fnlen;
v12 = (char *)calloc(fnlen + 16, 1uLL);
asmoptimf = (__int64)v12;
strncpy(v12, pgm, v11);
strcat(v12, ".optim.asm");
asmoptim = fopen(v12, "w");
if ( !asmoptim )
{
v22 = (const char *)asmoptimf;
goto LABEL_32;
}
}
v13 = fnlen;
v14 = (char *)calloc(fnlen + 5, 1uLL);
astlistf = (__int64)v14;
strncpy(v14, pgm, v13);
strcat(v14, ".xml");
astlist = fopen(v15, "w");
if ( !astlist )
{
v22 = (const char *)astlistf;
goto LABEL_32;
}
if ( !v9 )
{
v19 = fnlen;
v20 = (char *)calloc(fnlen + 6, 1uLL);
codef = (__int64)v20;
strncpy(v20, pgm, v19);
strcat(v20, ".qaud");
v21 = fopen(v20, "w");
v22 = (const char *)codef;
code = v21;
if ( !v21 )
goto LABEL_32;
v23 = fnlen;
v24 = (char *)calloc(fnlen + 5, 1uLL);
listingf = (__int64)v24;
strncpy(v24, pgm, v23);
strcat(v24, ".lst");
v25 = fopen(v24, "w");
v22 = (const char *)listingf;
listing = v25;
if ( !v25 )
goto LABEL_32;
v26 = fnlen;
v27 = (char *)calloc(fnlen + 5, 1uLL);
stablistf = (__int64)v27;
strncpy(v27, pgm, v26);
strcat(v27, ".stb");
v29 = fopen(v28, "w");
v22 = (const char *)stablistf;
stablist = v29;
if ( !v29 )
goto LABEL_32;
}
if ( runlevel <= 2 || (v16 = parse(), v17 = v16, runlevel <= 1) || (analyse(v16), coder(v17), runlevel <= 0) )
LABEL_33:
exit(1);
elf();
if ( v8 )
{
print_all_variables();
fclose(asmlist);
asmlist = asmoptim;
make_fgraph();
dataflow();
global_reg_alocate();
fclose(source);
fclose(astlist);
if ( !v9 )
{
fclose(code);
fclose(listing);
fclose(stablist);
}
fclose(asmoptim);
}
else
{
fclose(source);
fclose(asmlist);
fclose(astlist);
if ( !v9 )
{
fclose(code);
fclose(listing);
fclose(stablist);
}
}
if ( v7 )
{
do_compile();
do_link();
}
fwrite("__ done __\n", 1uLL, 0xBuLL, stdout);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbx
int v4; // eax
int v5; // er14
char v6; // dl
int v7; // er13
int v8; // ebx
int v9; // er12
char *v10; // rbp
int v11; // er14
char *v12; // rbp
int v13; // er14
char *v14; // rbp
const char *v15; // rbp
__int64 v16; // rax
__int64 v17; // rbp
int v19; // er14
char *v20; // rbp
FILE *v21; // rax
const char *v22; // rdx
int v23; // er14
char *v24; // rbp
FILE *v25; // rax
int v26; // er14
char *v27; // rbp
const char *v28; // rbp
FILE *v29; // rax
size_t v30; // rax

fwrite("compiler version 0.9.9 starting ...\n", 1uLL, 0x24uLL, stdout);
if ( argc <= 1 )
{
fwrite("usage: ./compiler <filename>\n", 1uLL, 0x1DuLL, stdout);
exit(1);
}
v3 = argc;
strcpy(pgm, argv[v3 - 1]);
source = fopen(pgm, "r");
if ( !source )
{
fprintf(stderr, "File `%s` not found\n", pgm);
exit(1);
}
if ( !strchr(pgm, 46) )
{
v30 = strlen(pgm);
*(_DWORD *)&pgm[v30] = 1935765550;
pgm[v30 + 4] = 0;
}
v4 = strcspn(pgm, ".");
fnlen = v4;
v5 = v4;
v6 = *argv[v3 - 2];
switch ( v6 )
{
case 'd':
listing = stdout;
v7 = 0;
v8 = 0;
v9 = 1;
code = stdout;
stablist = stdout;
break;
case 'o':
listing = stdout;
v7 = 0;
v8 = 1;
v9 = 1;
code = stdout;
stablist = stdout;
break;
case 's':
listing = stdout;
v7 = 0;
v8 = 1;
v9 = 0;
code = stdout;
stablist = stdout;
break;
case 'c':
listing = stdout;
v7 = 1;
v8 = 0;
v9 = 0;
code = stdout;
stablist = stdout;
break;
default:
v7 = 0;
v8 = 0;
v9 = 0;
break;
}
daglist = (__int64)stdout;
errlist = (__int64)stderr;
tiplist = (__int64)stderr;
v10 = (char *)calloc(v4 + 5, 1uLL);
asmlistf = (__int64)v10;
strncpy(v10, pgm, v5);
strcat(v10, ".asm");
asmlist = fopen(v10, "w");
if ( !asmlist )
{
v22 = (const char *)asmlistf;
LABEL_32:
fprintf(stderr, "Unable to open %s\n", v22);
goto LABEL_33;
}
if ( v8 )
{
v11 = fnlen;
v12 = (char *)calloc(fnlen + 16, 1uLL);
asmoptimf = (__int64)v12;
strncpy(v12, pgm, v11);
strcat(v12, ".optim.asm");
asmoptim = fopen(v12, "w");
if ( !asmoptim )
{
v22 = (const char *)asmoptimf;
goto LABEL_32;
}
}
v13 = fnlen;
v14 = (char *)calloc(fnlen + 5, 1uLL);
astlistf = (__int64)v14;
strncpy(v14, pgm, v13);
strcat(v14, ".xml");
astlist = fopen(v15, "w");
if ( !astlist )
{
v22 = (const char *)astlistf;
goto LABEL_32;
}
if ( !v9 )
{
v19 = fnlen;
v20 = (char *)calloc(fnlen + 6, 1uLL);
codef = (__int64)v20;
strncpy(v20, pgm, v19);
strcat(v20, ".qaud");
v21 = fopen(v20, "w");
v22 = (const char *)codef;
code = v21;
if ( !v21 )
goto LABEL_32;
v23 = fnlen;
v24 = (char *)calloc(fnlen + 5, 1uLL);
listingf = (__int64)v24;
strncpy(v24, pgm, v23);
strcat(v24, ".lst");
v25 = fopen(v24, "w");
v22 = (const char *)listingf;
listing = v25;
if ( !v25 )
goto LABEL_32;
v26 = fnlen;
v27 = (char *)calloc(fnlen + 5, 1uLL);
stablistf = (__int64)v27;
strncpy(v27, pgm, v26);
strcat(v27, ".stb");
v29 = fopen(v28, "w");
v22 = (const char *)stablistf;
stablist = v29;
if ( !v29 )
goto LABEL_32;
}
if ( runlevel <= 2 || (v16 = parse(), v17 = v16, runlevel <= 1) || (analyse(v16), coder(v17), runlevel <= 0) )
LABEL_33:
exit(1);
elf();
if ( v8 )
{
print_all_variables();
fclose(asmlist);
asmlist = asmoptim;
make_fgraph();
dataflow();
global_reg_alocate();
fclose(source);
fclose(astlist);
if ( !v9 )
{
fclose(code);
fclose(listing);
fclose(stablist);
}
fclose(asmoptim);
}
else
{
fclose(source);
fclose(asmlist);
fclose(astlist);
if ( !v9 )
{
fclose(code);
fclose(listing);
fclose(stablist);
}
}
if ( v7 )
{
func0();
func1();
}
fwrite("__ done __\n", 1uLL, 0xBuLL, stdout);
return 0;
}

original_code:
int main(int argc, const char *argv[])
{
 PgmSP ast;
 BOOL debug = 0;
 BOOL optim = 0;
 BOOL compile_and_link = 0;
 fprintf(stdout, "compiler version 0.9.9 starting ...\n");
 if (argc < 2) {
  fprintf(stdout, "usage: ./compiler <filename>\n");
  exit(1);
 }
 strcpy(pgm,argv[argc-1]);
 source = fopen(pgm, "r");
 if (source == ((void *)0)) {
  fprintf(stderr, "File `%s` not found\n", pgm);
  exit(1);
 }
 if (strchr(pgm, '.') == ((void *)0)) {
  strcat(pgm, ".pas");
 }
 fnlen = strcspn(pgm, ".");
 if (argv[argc-2][0] == 'd') {
  debug = 1;
  listing = stdout;
  code = stdout;
  stablist = stdout;
 } else if (argv[argc-2][0] == 'o') {
  debug = 1;
  optim = 1;
  listing = stdout;
  code = stdout;
  stablist = stdout;
 } else if (argv[argc-2][0] == 's') {
  optim = 1;
  listing = stdout;
  code = stdout;
  stablist = stdout;
 } else if (argv[argc-2][0] == 'c') {
  compile_and_link = 1;
  listing = stdout;
  code = stdout;
  stablist = stdout;
 }
 daglist = stdout;
 errlist = stderr;
 tiplist = stderr;
 asmlistf = (char *)calloc(fnlen + 5, sizeof(char));
 strncpy(asmlistf, pgm, fnlen);
 strcat(asmlistf, ".asm");
 asmlist = fopen(asmlistf, "w");
 if (asmlist == ((void *)0)) {
  fprintf(stderr, "Unable to open %s\n", asmlistf);
  exit(1);
 }
 if (optim) {
  asmoptimf = (char *)calloc(fnlen + 16, sizeof(char));
  strncpy(asmoptimf, pgm, fnlen);
  strcat(asmoptimf, ".optim.asm");
  asmoptim = fopen(asmoptimf, "w");
  if (asmoptim == ((void *)0)) {
   fprintf(stderr, "Unable to open %s\n", asmoptimf);
   exit(1);
  }
 }
 astlistf = (char *)calloc(fnlen + 5, sizeof(char));
 strncpy(astlistf, pgm, fnlen);
 strcat(astlistf, ".xml");
 astlist = fopen(astlistf, "w");
 if (astlist == ((void *)0)) {
  fprintf(stderr, "Unable to open %s\n", astlistf);
  exit(1);
 }
 if (!debug) {
  codef = (char *)calloc(fnlen + 6, sizeof(char));
  strncpy(codef, pgm, fnlen);
  strcat(codef, ".qaud");
  code = fopen(codef, "w");
  if (code == ((void *)0)) {
   fprintf(stderr, "Unable to open %s\n", codef);
   exit(1);
  }
  listingf = (char *)calloc(fnlen + 5, sizeof(char));
  strncpy(listingf, pgm, fnlen);
  strcat(listingf, ".lst");
  listing = fopen(listingf, "w");
  if (listing == ((void *)0)) {
   fprintf(stderr, "Unable to open %s\n", listingf);
   exit(1);
  }
  stablistf = (char *)calloc(fnlen + 5, sizeof(char));
  strncpy(stablistf, pgm, fnlen);
  strcat(stablistf, ".stb");
  stablist = fopen(stablistf, "w");
  if (stablist == ((void *)0)) {
   fprintf(stderr, "Unable to open %s\n", stablistf);
   exit(1);
  }
 }
 if (runlevel > 2) {
  ast = parse();
 } else {
  exit(1);
 }
 if (runlevel > 1) {
  analyse(ast);
  coder(ast);
 } else {
  exit(1);
 }
 if (runlevel > 0) {
  elf();
 } else {
  exit(1);
 }
 if (optim) {
  print_all_variables();
  fclose(asmlist);
  asmlist = asmoptim;
  make_fgraph();
  dataflow();
  global_reg_alocate();
 }
 fclose(source);
 if(!optim) fclose(asmlist);
 fclose(astlist);
 if (!debug) {
  fclose(code);
  fclose(listing);
  fclose(stablist);
 }
 if (optim) {
  fclose(asmoptim);
 }
 if (compile_and_link) {
  do_compile();
  do_link();
 }
 fprintf(stdout, "__ done __\n");
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
 struct _PgmS *ast;
 int debug = 0;
 int optim = 0;
 int compile_and_link = 0;
 fprintf(stdout, "compiler version 0.9.9 starting ...\n");
 if (argc < 2) {
  fprintf(stdout, "usage: ./compiler <filename>\n");
  exit(1);
 }
 strcpy(pgm,argv[argc-1]);
 source = fopen(pgm, "r");
 if (source == ((void *)0)) {
  fprintf(stderr, "File `%s` not found\n", pgm);
  exit(1);
 }
 if (strchr(pgm, '.') == ((void *)0)) {
  strcat(pgm, ".pas");
 }
 fnlen = strcspn(pgm, ".");
 if (argv[argc-2][0] == 'd') {
  debug = 1;
  listing = stdout;
  code = stdout;
  stablist = stdout;
 } else if (argv[argc-2][0] == 'o') {
  debug = 1;
  optim = 1;
  listing = stdout;
  code = stdout;
  stablist = stdout;
 } else if (argv[argc-2][0] == 's') {
  optim = 1;
  listing = stdout;
  code = stdout;
  stablist = stdout;
 } else if (argv[argc-2][0] == 'c') {
  compile_and_link = 1;
  listing = stdout;
  code = stdout;
  stablist = stdout;
 }
 daglist = stdout;
 errlist = stderr;
 tiplist = stderr;
 asmlistf = (char *)calloc(fnlen + 5, sizeof(char));
 strncpy(asmlistf, pgm, fnlen);
 strcat(asmlistf, ".asm");
 asmlist = fopen(asmlistf, "w");
 if (asmlist == ((void *)0)) {
  fprintf(stderr, "Unable to open %s\n", asmlistf);
  exit(1);
 }
 if (optim) {
  asmoptimf = (char *)calloc(fnlen + 16, sizeof(char));
  strncpy(asmoptimf, pgm, fnlen);
  strcat(asmoptimf, ".optim.asm");
  asmoptim = fopen(asmoptimf, "w");
  if (asmoptim == ((void *)0)) {
   fprintf(stderr, "Unable to open %s\n", asmoptimf);
   exit(1);
  }
 }
 astlistf = (char *)calloc(fnlen + 5, sizeof(char));
 strncpy(astlistf, pgm, fnlen);
 strcat(astlistf, ".xml");
 astlist = fopen(astlistf, "w");
 if (astlist == ((void *)0)) {
  fprintf(stderr, "Unable to open %s\n", astlistf);
  exit(1);
 }
 if (!debug) {
  codef = (char *)calloc(fnlen + 6, sizeof(char));
  strncpy(codef, pgm, fnlen);
  strcat(codef, ".qaud");
  code = fopen(codef, "w");
  if (code == ((void *)0)) {
   fprintf(stderr, "Unable to open %s\n", codef);
   exit(1);
  }
  listingf = (char *)calloc(fnlen + 5, sizeof(char));
  strncpy(listingf, pgm, fnlen);
  strcat(listingf, ".lst");
  listing = fopen(listingf, "w");
  if (listing == ((void *)0)) {
   fprintf(stderr, "Unable to open %s\n", listingf);
   exit(1);
  }
  stablistf = (char *)calloc(fnlen + 5, sizeof(char));
  strncpy(stablistf, pgm, fnlen);
  strcat(stablistf, ".stb");
  stablist = fopen(stablistf, "w");
  if (stablist == ((void *)0)) {
   fprintf(stderr, "Unable to open %s\n", stablistf);
   exit(1);
  }
 }
 if (runlevel > 2) {
  ast = parse();
 } else {
  exit(1);
 }
 if (runlevel > 1) {
  analyse(ast);
  coder(ast);
 } else {
  exit(1);
 }
 if (runlevel > 0) {
  elf();
 } else {
  exit(1);
 }
 if (optim) {
  print_all_variables();
  fclose(asmlist);
  asmlist = asmoptim;
  make_fgraph();
  dataflow();
  global_reg_alocate();
 }
 fclose(source);
 if(!optim) fclose(asmlist);
 fclose(astlist);
 if (!debug) {
  fclose(code);
  fclose(listing);
  fclose(stablist);
 }
 if (optim) {
  fclose(asmoptim);
 }
 if (compile_and_link) {
  do_compile();
  do_link();
 }
 fprintf(stdout, "__ done __\n");
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: debug int

variable_types: optim int

return_type: int

user_defined_types: struct _BlockS { struct _ConstDecS *cdp; struct _VarDecS *vdp; struct _PFDecListS *pfdlp; struct _CompStmtS *csp; }

user_defined_types: struct _ConstDecS { struct _ConstDefS *cdp; struct _ConstDecS *next; }

user_defined_types: struct _VarDecS { struct _VarDefS *vdp; struct _VarDecS *next; }

user_defined_types: struct _PFDecListS { enum PFDec_t type; struct _ProcDecS *pdp; struct _FunDecS *fdp; struct _PFDecListS *next; }

user_defined_types: struct _CompStmtS { struct _StmtS *sp; struct _CompStmtS *next; }

user_defined_types: enum PFDec_t { Fun_PFDec_t=0, Proc_PFDec_t=1 }

user_defined_types: struct _ConstDefS { struct _IdentS *idp; }

user_defined_types: struct _VarDefS { struct _IdentS *idp; struct _VarDefS *next; }

user_defined_types: struct _ProcDecS { struct _ProcDefS *pdp; struct _ProcDecS *next; }

user_defined_types: struct _FunDecS { struct _FunDefS *fdp; struct _FunDecS *next; }

user_defined_types: struct _StmtS { enum Stmt_t type; struct _AssignStmtS *asp; struct _IfStmtS *ifp; struct _RepeStmtS *rpp; struct _ForStmtS *frp; struct _PcallStmtS *pcp; struct _CompStmtS *cpp; struct _ReadStmtS *rdp; struct _WriteStmtS *wtp; }

user_defined_types: enum Stmt_t { Assgin_Stmt_t=0, IF_Stmt_t=1, Repeat_Stmt_t=2, Pcall_Stmt_t=3, Comp_Stmt_t=4, Read_Stmt_t=5, Write_Stmt_t=6, For_Stmt_t=7, Null_Stmt_t=8 }

user_defined_types: struct _IdentS { enum Ident_t type; char *name; int val; int length; int line; }

user_defined_types: struct _ProcDefS { struct _ProcHeadS *php; struct _BlockS *bp; }

user_defined_types: struct _FunDefS { struct _FunHeadS *fhp; struct _BlockS *bp; }

user_defined_types: struct _AssignStmtS { enum Assgin_t type; struct _IdentS *idp; struct _ExprS *lep; struct _ExprS *rep; }

user_defined_types: struct _WriteStmtS { enum Write_t type; char *sp; struct _ExprS *ep; }

user_defined_types: struct _FunHeadS { struct _IdentS *idp; struct _ParaListS *plp; }

user_defined_types: struct _ExprS { enum Addop_t op; struct _TermS *tp; struct _ExprS *next; }

user_defined_types: struct _CondS { struct _ExprS *lep; enum Rela_t op; struct _ExprS *rep; }

user_defined_types: struct _ParaListS { struct _ParaDefS *pdp; struct _ParaListS *next; }

user_defined_types: struct _TermS { enum Multop_t op; struct _FactorS *fp; struct _TermS *next; }

user_defined_types: struct _FactorS { enum Factor_t type; struct _IdentS *idp; struct _ExprS *ep; int usi; struct _FcallStmtS *fcsp; }

user_defined_types: struct _FcallStmtS { struct _IdentS *idp; struct _ArgListS *alp; }


decompiled_code:
__int64 __fastcall dagable_bblock(__int64 a1)
{
unsigned int *v1; // rax
__int64 v2; // rcx
unsigned __int64 v3; // rdx

v1 = *(unsigned int **)(a1 + 32);
if ( !v1 )
return 1LL;
v2 = 1058536959LL;
while ( 1 )
{
v3 = *v1;
if ( (unsigned int)v3 > 0x1D || !_bittest64(&v2, v3) )
break;
if ( *(unsigned int **)(a1 + 40) != v1 )
{
v1 = (unsigned int *)*((_QWORD *)v1 + 5);
if ( v1 )
continue;
}
return 1LL;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
unsigned int *v1; // rax
__int64 v2; // rcx
unsigned __int64 v3; // rdx

v1 = *(unsigned int **)(a1 + 32);
if ( !v1 )
return 1LL;
v2 = 1058536959LL;
while ( 1 )
{
v3 = *v1;
if ( (unsigned int)v3 > 0x1D || !_bittest64(&v2, v3) )
break;
if ( *(unsigned int **)(a1 + 40) != v1 )
{
v1 = (unsigned int *)*((_QWORD *)v1 + 5);
if ( v1 )
continue;
}
return 1LL;
}
return 0LL;
}

original_code:
BOOL dagable_bblock(BBSP b)
{
 QuadSP p;
 for (p = b->first; p != ((void *)0); p = p->next) {
  if (!((p->op==ADD_op)||(p->op==SUB_op)||(p->op==MUL_op)||(p->op==DIV_op)||(p->op==NEG_op)||(p->op==ASS_op)||(p->op==INC_op)||(p->op==DEC_op)||(p->op==EQU_op)||(p->op==NEQ_op)||(p->op==GTT_op)||(p->op==GEQ_op)||(p->op==LST_op)||(p->op==LEQ_op)||(p->op==READ_op)||(p->op==READC_op)||(p->op==WRI_op)||(p->op==WRC_op)||(p->op==WRS_op)||(p->op==LOAD_op)||(p->op==JMP_op)||(p->op==CALL_op)||(p->op==PUSH_op)||(p->op==PUSHA_op)||(p->op==LABEL_op))) return 0;
  if (p == b->last) break;
 }
 return 1;
}

canonical_original_code:
int dagable_bblock(struct _BBS *b)
{
 struct _QuadS *p;
 for (p = b->first; p != ((void *)0); p = p->next) {
  if (!((p->op==ADD_op)||(p->op==SUB_op)||(p->op==MUL_op)||(p->op==DIV_op)||(p->op==NEG_op)||(p->op==ASS_op)||(p->op==INC_op)||(p->op==DEC_op)||(p->op==EQU_op)||(p->op==NEQ_op)||(p->op==GTT_op)||(p->op==GEQ_op)||(p->op==LST_op)||(p->op==LEQ_op)||(p->op==READ_op)||(p->op==READC_op)||(p->op==WRI_op)||(p->op==WRC_op)||(p->op==WRS_op)||(p->op==LOAD_op)||(p->op==JMP_op)||(p->op==CALL_op)||(p->op==PUSH_op)||(p->op==PUSHA_op)||(p->op==LABEL_op))) return 0;
  if (p == b->last) break;
 }
 return 1;
}

variable_types: struct _BBS { int id; struct _QuadS { enum Quad_t { ADD_op=0, SUB_op=1, MUL_op=2, DIV_op=3, INC_op=4, DEC_op=5, NEG_op=6, LOAD_op=7, ASS_op=8, AARR_op=9, EQU_op=10, NEQ_op=11, GTT_op=12, GEQ_op=13, LST_op=14, LEQ_op=15, JMP_op=16, PUSH_op=17, PUSHA_op=18, POP_op=19, CALL_op=20, SRET_op=21, ENTER_op=22, FIN_op=23, READ_op=24, READC_op=25, WRS_op=26, WRI_op=27, WRC_op=28, LABEL_op=29 } op; struct _SymTabES { char *name; char *label; int val; int lineno; int level; int posi; enum Obj_t { Nop_Obj_t=0, Const_Obj_t=1, Var_Obj_t=2, Proc_Obj_t=3, Fun_Obj_t=4, Array_Obj_t=5, Para_Val_Obj_t=6, Para_Ref_Obj_t=7, Tmp_Obj_t=8, Label_Obj_t=9, Num_Obj_t=10, String_Obj_t=11 } obj; enum Type_t { Int_Type_t=0, Char_Type_t=1, Nop_Type_t=2 } type; struct _SymTabS { struct _SymBucketS { struct _SymTabES *ep; struct _SymBucketS *next; } **sbp; int posi_var; int posi_para; int posi_tmp; int level; struct _SymBucketS *headinfo; struct _SymBucketS *tailinfo; struct _SymTabS *prev; struct _SymTabS *next; } *stp; } *r; struct _SymTabES *s; struct _SymTabES *d; struct _QuadS *prev; struct _QuadS *next; int rm_flag; } *qhead; struct _QuadS *qtail; struct _QuadS *scope; struct _QuadS *first; struct _QuadS *last; struct _BBListS { struct _BBS *bbp; struct _BBListS *next; } *pres; struct _BBListS *posts; int use[8]; int def[8]; int in_old[8]; int out_old[8]; int in[8]; int out[8]; } *

user_defined_types: struct _BBS { int id; struct _QuadS *qhead; struct _QuadS *qtail; struct _QuadS *scope; struct _QuadS *first; struct _QuadS *last; struct _BBListS *pres; struct _BBListS *posts; int use[8]; int def[8]; int in_old[8]; int out_old[8]; int in[8]; int out[8]; }

user_defined_types: struct _QuadS { enum Quad_t op; struct _SymTabES *r; struct _SymTabES *s; struct _SymTabES *d; struct _QuadS *prev; struct _QuadS *next; int rm_flag; }

user_defined_types: struct _SymTabES { char *name; char *label; int val; int lineno; int level; int posi; enum Obj_t obj; enum Type_t type; struct _SymTabS *stp; }

user_defined_types: struct _SymTabS { struct _SymBucketS **sbp; int posi_var; int posi_para; int posi_tmp; int level; struct _SymBucketS *headinfo; struct _SymBucketS *tailinfo; struct _SymTabS *prev; struct _SymTabS *next; }


decompiled_code:
__int64 make_fgraph()
{
__int64 v0; // rbx

initLeader();
elf_header();
do
{
v0 = newBblock();
addBblock(v0);
if ( (unsigned int)dagable_bblock(v0) )
make_dag_for_bblock();
else
copy_quad_for_bblock();
printAllQuads(*(_QWORD *)(v0 + 8));
}
while ( !(unsigned int)quad_end() );
return link_bblock();
}

canonical_decompiled_code:
__int64 func1()
{
__int64 v0; // rbx

initLeader();
elf_header();
do
{
v0 = newBblock();
addBblock(v0);
if ( (unsigned int)func0(v0) )
make_dag_for_bblock();
else
copy_quad_for_bblock();
printAllQuads(*(_QWORD *)(v0 + 8));
}
while ( !(unsigned int)quad_end() );
return link_bblock();
}

original_code:
void make_fgraph(void)
{
 BBSP b;
 initLeader();
 elf_header();
 do {
  b = newBblock();
  addBblock(b);
  if (dagable_bblock(b)) {
   make_dag_for_bblock(b);
  } else {
   copy_quad_for_bblock(b);
  }
  printAllQuads(b->qhead);
 } while (!quad_end());
 link_bblock();
}

canonical_original_code:
void make_fgraph()
{
 struct _BBS *b;
 initLeader();
 elf_header();
 do {
  b = newBblock();
  addBblock(b);
  if (dagable_bblock(b)) {
   make_dag_for_bblock(b);
  } else {
   copy_quad_for_bblock(b);
  }
  printAllQuads(b->qhead);
 } while (!quad_end());
 link_bblock();
}

user_defined_types: struct _BBListS { struct _BBS *bbp; struct _BBListS *next; }

user_defined_types: enum Quad_t { ADD_op=0, SUB_op=1, MUL_op=2, DIV_op=3, INC_op=4, DEC_op=5, NEG_op=6, LOAD_op=7, ASS_op=8, AARR_op=9, EQU_op=10, NEQ_op=11, GTT_op=12, GEQ_op=13, LST_op=14, LEQ_op=15, JMP_op=16, PUSH_op=17, PUSHA_op=18, POP_op=19, CALL_op=20, SRET_op=21, ENTER_op=22, FIN_op=23, READ_op=24, READC_op=25, WRS_op=26, WRI_op=27, WRC_op=28, LABEL_op=29 }

user_defined_types: enum Obj_t { Nop_Obj_t=0, Const_Obj_t=1, Var_Obj_t=2, Proc_Obj_t=3, Fun_Obj_t=4, Array_Obj_t=5, Para_Val_Obj_t=6, Para_Ref_Obj_t=7, Tmp_Obj_t=8, Label_Obj_t=9, Num_Obj_t=10, String_Obj_t=11 }

user_defined_types: enum Type_t { Int_Type_t=0, Char_Type_t=1, Nop_Type_t=2 }

user_defined_types: struct _SymBucketS { struct _SymTabES *ep; struct _SymBucketS *next; }


dataflow

decompiled_code:
__int64 dataflow()
{
__int64 result; // rax
_QWORD *v1; // rbx

cal_use_def();
do_dataflow();
printAllBblock();
rm_useless_assign();
result = printAllBblock();
v1 = (_QWORD *)bblst;
if ( bblst )
{
do
{
result = elf_for_block(*v1);
v1 = (_QWORD *)v1[1];
}
while ( v1 );
}
return result;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 result; // rax
_QWORD *v1; // rbx

cal_use_def();
do_dataflow();
printAllBblock();
rm_useless_assign();
result = printAllBblock();
v1 = (_QWORD *)bblst;
if ( bblst )
{
do
{
result = elf_for_block(*v1);
v1 = (_QWORD *)v1[1];
}
while ( v1 );
}
return result;
}

original_code:
void dataflow(void)
{
 BBListSP bl;
 cal_use_def();
 do_dataflow();
 _printAllBblock();
 rm_useless_assign();
 _printAllBblock();
 for (bl = bblst; bl; bl = bl->next)
  elf_for_block(bl->bbp);
}

canonical_original_code:
void dataflow()
{
 struct _BBListS *bl;
 cal_use_def();
 do_dataflow();
 _printAllBblock();
 rm_useless_assign();
 _printAllBblock();
 for (bl = bblst; bl; bl = bl->next)
  elf_for_block(bl->bbp);
}

variable_types: struct _BBListS { struct _BBS { int id; struct _QuadS { enum Quad_t { ADD_op=0, SUB_op=1, MUL_op=2, DIV_op=3, INC_op=4, DEC_op=5, NEG_op=6, LOAD_op=7, ASS_op=8, AARR_op=9, EQU_op=10, NEQ_op=11, GTT_op=12, GEQ_op=13, LST_op=14, LEQ_op=15, JMP_op=16, PUSH_op=17, PUSHA_op=18, POP_op=19, CALL_op=20, SRET_op=21, ENTER_op=22, FIN_op=23, READ_op=24, READC_op=25, WRS_op=26, WRI_op=27, WRC_op=28, LABEL_op=29 } op; struct _SymTabES { char *name; char *label; int val; int lineno; int level; int posi; enum Obj_t { Nop_Obj_t=0, Const_Obj_t=1, Var_Obj_t=2, Proc_Obj_t=3, Fun_Obj_t=4, Array_Obj_t=5, Para_Val_Obj_t=6, Para_Ref_Obj_t=7, Tmp_Obj_t=8, Label_Obj_t=9, Num_Obj_t=10, String_Obj_t=11 } obj; enum Type_t { Int_Type_t=0, Char_Type_t=1, Nop_Type_t=2 } type; struct _SymTabS { struct _SymBucketS { struct _SymTabES *ep; struct _SymBucketS *next; } **sbp; int posi_var; int posi_para; int posi_tmp; int level; struct _SymBucketS *headinfo; struct _SymBucketS *tailinfo; struct _SymTabS *prev; struct _SymTabS *next; } *stp; } *r; struct _SymTabES *s; struct _SymTabES *d; struct _QuadS *prev; struct _QuadS *next; int rm_flag; } *qhead; struct _QuadS *qtail; struct _QuadS *scope; struct _QuadS *first; struct _QuadS *last; struct _BBListS *pres; struct _BBListS *posts; int use[8]; int def[8]; int in_old[8]; int out_old[8]; int in[8]; int out[8]; } *bbp; struct _BBListS *next; } *


decompiled_code:
// attributes: thunk
__int64 global_reg_alocate()
{
return do_use_count();
}

canonical_decompiled_code:
__int64 func3()
{
return do_use_count();
}

original_code:
void global_reg_alocate(void)
{
 do_use_count();
}

canonical_original_code:
void global_reg_alocate()
{
 do_use_count();
}


emit

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

result = qtail;
if ( qtail )
{
*(_QWORD *)(a1 + 32) = qtail;
*(_QWORD *)(a1 + 40) = 0LL;
qtail = a1;
*(_QWORD *)(result + 40) = a1;
}
else
{
*(_QWORD *)(a1 + 32) = 0LL;
*(_QWORD *)(a1 + 40) = 0LL;
qtail = a1;
qhead = a1;
}
return result;
}

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

result = qtail;
if ( qtail )
{
*(_QWORD *)(a1 + 32) = qtail;
*(_QWORD *)(a1 + 40) = 0LL;
qtail = a1;
*(_QWORD *)(result + 40) = a1;
}
else
{
*(_QWORD *)(a1 + 32) = 0LL;
*(_QWORD *)(a1 + 40) = 0LL;
qtail = a1;
qhead = a1;
}
return result;
}

original_code:
void emit(QuadSP q)
{
 if (qtail == ((void *)0)) {
  q->prev = qtail;
  q->next = ((void *)0);
  qhead = qtail = q;
 } else {
  q->prev = qtail;
  q->next = ((void *)0);
  qtail->next = q;
  qtail = q;
 }
 if (ShowQuad) {
  if (runlevel > 0) {
  }
 }
}

canonical_original_code:
void emit(struct _QuadS *q)
{
 if (qtail == ((void *)0)) {
  q->prev = qtail;
  q->next = ((void *)0);
  qhead = qtail = q;
 } else {
  q->prev = qtail;
  q->next = ((void *)0);
  qtail->next = q;
  qtail = q;
 }
 if (ShowQuad) {
  if (runlevel > 0) {
  }
 }
}

variable_types: struct _QuadS { enum Quad_t { ADD_op=0, SUB_op=1, MUL_op=2, DIV_op=3, INC_op=4, DEC_op=5, NEG_op=6, LOAD_op=7, ASS_op=8, AARR_op=9, EQU_op=10, NEQ_op=11, GTT_op=12, GEQ_op=13, LST_op=14, LEQ_op=15, JMP_op=16, PUSH_op=17, PUSHA_op=18, POP_op=19, CALL_op=20, SRET_op=21, ENTER_op=22, FIN_op=23, READ_op=24, READC_op=25, WRS_op=26, WRI_op=27, WRC_op=28, LABEL_op=29 } op; struct _SymTabES { char *name; char *label; int val; int lineno; int level; int posi; enum Obj_t { Nop_Obj_t=0, Const_Obj_t=1, Var_Obj_t=2, Proc_Obj_t=3, Fun_Obj_t=4, Array_Obj_t=5, Para_Val_Obj_t=6, Para_Ref_Obj_t=7, Tmp_Obj_t=8, Label_Obj_t=9, Num_Obj_t=10, String_Obj_t=11 } obj; enum Type_t { Int_Type_t=0, Char_Type_t=1, Nop_Type_t=2 } type; struct _SymTabS { struct _SymBucketS { struct _SymTabES *ep; struct _SymBucketS *next; } **sbp; int posi_var; int posi_para; int posi_tmp; int level; struct _SymBucketS *headinfo; struct _SymBucketS *tailinfo; struct _SymTabS *prev; struct _SymTabS *next; } *stp; } *r; struct _SymTabES *s; struct _SymTabES *d; struct _QuadS *prev; struct _QuadS *next; int rm_flag; } *


printAllQuads

decompiled_code:
int __fastcall printAllQuads(__int64 a1)
{
__int64 v1; // rbx
int result; // eax

if ( a1 )
{
v1 = a1;
do
{
result = printQuad(v1);
v1 = *(_QWORD *)(v1 + 40);
}
while ( v1 );
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(__int64 a1)
{
__int64 v1; // rbx
int result; // eax

if ( a1 )
{
v1 = a1;
do
{
result = func1(v1);
v1 = *(_QWORD *)(v1 + 40);
}
while ( v1 );
}
return result;
}

original_code:
void printAllQuads(QuadSP q)
{
 for (; q != ((void *)0); q = q->next) {
  printQuad(q);
 }
}

canonical_original_code:
void printAllQuads(struct _QuadS *q)
{
 for (; q != ((void *)0); q = q->next) {
  printQuad(q);
 }
}


printAllQuad

decompiled_code:
int printAllQuad()
{
return printAllQuads(qhead);
}

canonical_decompiled_code:
int func3()
{
return func2(qhead);
}

original_code:
void printAllQuad()
{
 printAllQuads(qhead);
}


decompiled_code:
_BOOL8 __fastcall et_carls_function(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v5; // [rsp+0h] [rbp-48h] BYREF
int v6[10]; // [rsp+20h] [rbp-28h] BYREF

et_station_getselectwords(a1, a2, &v5);
et_event_getcontrol(a3, v6);
return v6[0] == 17;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v5; // [rsp+0h] [rbp-48h] BYREF
int v6[10]; // [rsp+20h] [rbp-28h] BYREF

et_station_getselectwords(a1, a2, &v5);
et_event_getcontrol(a3, v6);
return v6[0] == 17;
}

original_code:
int
et_carls_function(et_sys_id id, et_stat_id stat_id, et_event *pe)
{
  int select[6];
  int control[6];
  et_station_getselectwords(id, stat_id, select);
  et_event_getcontrol(pe, control);
  if(control[0] == 17)
  {
    return(1);
  }
  return(0);
}

canonical_original_code:
int et_carls_function(void *id, int stat_id, struct et_event_t *pe)
{
  int select[6];
  int control[6];
  et_station_getselectwords(id, stat_id, select);
  et_event_getcontrol(pe, control);
  if(control[0] == 17)
  {
    return(1);
  }
  return(0);
}

variable_types:
id
void *

variable_types: struct et_event_t { struct et_event_t *next; void *tempdata; void *pdata; char *data; unsigned long length; unsigned long memsize; unsigned long pointer; int modify; int priority; int owner; int temp; int age; int datastatus; int byteorder; int group; int place; int control[6]; char filename[-1]; } *

variable_types:
select
int [6]

variable_types:
control
int [6]


decompiled_code:
// attributes: thunk
_BOOL8 __fastcall et_mon_function(__int64 a1, unsigned int a2, __int64 a3)
{
return et2et_function_localalias(a1, a2, a3);
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(__int64 a1, unsigned int a2, __int64 a3)
{
return func1(a1, a2, a3);
}

original_code:
int
et_mon_function(et_sys_id id, et_stat_id stat_id, et_event *pe)
{
  int control[6];
  int cue, cnt;
  et_event_getcontrol(pe, control);
  if(control[0]==0) return(1);
  if(control[0]>15) return(1);
  et_station_getcue(id,stat_id,&cue);
  et_station_getinputcount(id,stat_id,&cnt);
  if(cnt<cue)
  {
    return(1);
  }
  else
  {
    return(0);
  }
}

canonical_original_code:
int et_mon_function(void *id, int stat_id, struct et_event_t *pe)
{
  int control[6];
  int cue; int cnt;
  et_event_getcontrol(pe, control);
  if(control[0]==0) return(1);
  if(control[0]>15) return(1);
  et_station_getcue(id,stat_id,&cue);
  et_station_getinputcount(id,stat_id,&cnt);
  if(cnt<cue)
  {
    return(1);
  }
  else
  {
    return(0);
  }
}

variable_types: cue int

variable_types: cnt int

user_defined_types: struct et_event_t { struct et_event_t *next; void *tempdata; void *pdata; char *data; unsigned long length; unsigned long memsize; unsigned long pointer; int modify; int priority; int owner; int temp; int age; int datastatus; int byteorder; int group; int place; int control[6]; char filename[-1]; }


decompiled_code:
_BOOL8 __fastcall et_ced_function(__int64 a1, __int64 a2, __int64 a3)
{
int v4[10]; // [rsp+0h] [rbp-28h] BYREF

et_event_getcontrol(a3, v4);
return (unsigned int)(v4[0] - 1) <= 0xD;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(__int64 a1, __int64 a2, __int64 a3)
{
int v4[10]; // [rsp+0h] [rbp-28h] BYREF

et_event_getcontrol(a3, v4);
return (unsigned int)(v4[0] - 1) <= 0xD;
}

original_code:
int
et_ced_function(et_sys_id id, et_stat_id stat_id, et_event *pe)
{
  int control[6];
  et_event_getcontrol(pe, control);
  if(control[0]>0&&control[0]<15)
  {
    return(1);
  }
  else
  {
    return(0);
  }
}

canonical_original_code:
int et_ced_function(void *id, int stat_id, struct et_event_t *pe)
{
  int control[6];
  et_event_getcontrol(pe, control);
  if(control[0]>0&&control[0]<15)
  {
    return(1);
  }
  else
  {
    return(0);
  }
}


decompiled_code:
_BOOL8 __fastcall et_scaler_function(__int64 a1, __int64 a2, __int64 a3)
{
int v4[10]; // [rsp+0h] [rbp-28h] BYREF

et_event_getcontrol(a3, v4);
return v4[0] == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func4(__int64 a1, __int64 a2, __int64 a3)
{
int v4[10]; // [rsp+0h] [rbp-28h] BYREF

et_event_getcontrol(a3, v4);
return v4[0] == 0;
}

original_code:
int
et_scaler_function(et_sys_id id, et_stat_id stat_id, et_event *pe)
{
  int control[6];
  et_event_getcontrol(pe, control);
  if(control[0]==0)
  {
    return(1);
  }
  else
  {
    return(0);
  }
}

canonical_original_code:
int et_scaler_function(void *id, int stat_id, struct et_event_t *pe)
{
  int control[6];
  et_event_getcontrol(pe, control);
  if(control[0]==0)
  {
    return(1);
  }
  else
  {
    return(0);
  }
}


repo: Jegp/OpenWrt-transfer

decompiled_code:
__int64 __fastcall write_to_socket(int fd, void *buf, int a3)
{
int v4; // ebx
int v5; // eax

if ( a3 <= 0 )
return 0LL;
v4 = a3;
do
{
v5 = write(fd, buf, v4);
if ( v5 < 0 )
{
fwrite("Failed to write to server\n", 1uLL, 0x1AuLL, stderr);
return 0xFFFFFFFFLL;
}
v4 -= v5;
buf = (char *)buf + v5;
}
while ( v4 > 0 );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(int fd, void *buf, int a3)
{
int v4; // ebx
int v5; // eax

if ( a3 <= 0 )
return 0LL;
v4 = a3;
do
{
v5 = write(fd, buf, v4);
if ( v5 < 0 )
{
fwrite("Failed to write to server\n", 1uLL, 0x1AuLL, stderr);
return 0xFFFFFFFFLL;
}
v4 -= v5;
buf = (char *)buf + v5;
}
while ( v4 > 0 );
return 0LL;
}

original_code:
int write_to_socket(int socketfd, void * buffer, int bytes_read) {
    int bytes_written;
    while (bytes_read > 0) {
        bytes_written = write(socketfd, buffer, bytes_read);
        if (bytes_written < 0) {
            fprintf(stderr, "Failed to write to server\n");
            return -1;
        }
        bytes_read -= bytes_written;
        buffer += bytes_written;
    }
    return 0;
}

canonical_original_code:
int write_to_socket(int socketfd, void *buffer, int bytes_read) {
    int bytes_written;
    while (bytes_read > 0) {
        bytes_written = write(socketfd, buffer, bytes_read);
        if (bytes_written < 0) {
            fprintf(stderr, "Failed to write to server\n");
            return -1;
        }
        bytes_read -= bytes_written;
        buffer += bytes_written;
    }
    return 0;
}

variable_types: socketfd int

variable_types:
buffer
void *


sendFile

decompiled_code:
__int64 __fastcall sendFile(const char *a1, int a2)
{
int v2; // eax
int v3; // ebp
int v4; // eax
unsigned int v5; // er12
__int64 result; // rax
_BYTE v7[1032]; // [rsp+0h] [rbp-408h] BYREF

v2 = open(a1, 0);
if ( v2 < 0 )
{
v5 = -1;
fprintf(stderr, "Could not open file '%s'\n", a1);
LABEL_7:
result = v5;
}
else
{
v3 = v2;
do
{
v4 = read(v3, v7, 0x3E8uLL);
v5 = v4;
if ( !v4 )
{
close(v3);
goto LABEL_7;
}
if ( v4 < 0 )
{
fwrite("Failed to read from file\n", 1uLL, 0x19uLL, stderr);
return 0xFFFFFFFFLL;
}
}
while ( !(unsigned int)write_to_socket(a2, v7, v4) );
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(const char *a1, int a2)
{
int v2; // eax
int v3; // ebp
int v4; // eax
unsigned int v5; // er12
__int64 result; // rax
_BYTE v7[1032]; // [rsp+0h] [rbp-408h] BYREF

v2 = open(a1, 0);
if ( v2 < 0 )
{
v5 = -1;
fprintf(stderr, "Could not open file '%s'\n", a1);
LABEL_7:
result = v5;
}
else
{
v3 = v2;
do
{
v4 = read(v3, v7, 0x3E8uLL);
v5 = v4;
if ( !v4 )
{
close(v3);
goto LABEL_7;
}
if ( v4 < 0 )
{
fwrite("Failed to read from file\n", 1uLL, 0x19uLL, stderr);
return 0xFFFFFFFFLL;
}
}
while ( !(unsigned int)func7(a2, v7, v4) );
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int sendFile(char * file, int socketfd) {
    int filefd, bytes_read;
    char buffer[1000];
    if ((filefd = open(file, 00)) < 0) {
        fprintf(stderr, "Could not open file '%s'\n", file);
        return -1;
    }
    while (1) {
        bytes_read = read(filefd, buffer, sizeof(buffer));
        if (bytes_read == 0) break;
        if (bytes_read < 0) {
            fprintf(stderr, "Failed to read from file\n");
            return -1;
        }
        if (write_to_socket(socketfd, (void *) buffer, bytes_read) != 0) {
            return -1;
        }
    }
    close(filefd);
    return 0;
}

canonical_original_code:
int sendFile(char *file, int socketfd) {
    int filefd; int bytes_read;
    char buffer[1000];
    if ((filefd = open(file, 00)) < 0) {
        fprintf(stderr, "Could not open file '%s'\n", file);
        return -1;
    }
    while (1) {
        bytes_read = read(filefd, buffer, sizeof(buffer));
        if (bytes_read == 0) break;
        if (bytes_read < 0) {
            fprintf(stderr, "Failed to read from file\n");
            return -1;
        }
        if (write_to_socket(socketfd, (void *) buffer, bytes_read) != 0) {
            return -1;
        }
    }
    close(filefd);
    return 0;
}

variable_types:
file
char *

variable_types: filefd int

variable_types:
buffer
char [1000]


decompiled_code:
__int64 __fastcall send_std_in(int fd)
{
int v1; // eax
void *buf; // [rsp+0h] [rbp-18h] BYREF
size_t n[2]; // [rsp+8h] [rbp-10h] BYREF

buf = 0LL;
do
{
v1 = getline((char **)&buf, n, stdin);
if ( v1 == -1 )
{
puts("Input ended");
return 0LL;
}
}
while ( !(unsigned int)write_to_socket(fd, buf, v1) );
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func9(int fd)
{
int v1; // eax
void *buf; // [rsp+0h] [rbp-18h] BYREF
size_t n[2]; // [rsp+8h] [rbp-10h] BYREF

buf = 0LL;
do
{
v1 = getline((char **)&buf, n, stdin);
if ( v1 == -1 )
{
puts("Input ended");
return 0LL;
}
}
while ( !(unsigned int)func7(fd, buf, v1) );
return 0xFFFFFFFFLL;
}

original_code:
int send_std_in(int socketfd) {
    int bytes_read;
    char * line = ((void *)0);
    size_t size;
    while (1) {
        if ((bytes_read = getline(&line, &size, stdin)) == -1) {
            printf("Input ended\n");
            return 0;
        }
        if (write_to_socket(socketfd, (void *) line, bytes_read) != 0) {
            return -1;
        }
    }
    return 0;
}

canonical_original_code:
int send_std_in(int socketfd) {
    int bytes_read;
    char *line = ((void *)0);
    unsigned long size;
    while (1) {
        if ((bytes_read = getline(&line, &size, stdin)) == -1) {
            printf("Input ended\n");
            return 0;
        }
        if (write_to_socket(socketfd, (void *) line, bytes_read) != 0) {
            return -1;
        }
    }
    return 0;
}

variable_types:
line
char *

variable_types:
size
unsigned long


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // r13
const char *v4; // rbp
const char *v5; // rsi
int v6; // eax
int v7; // er12
struct addrinfo *v8; // rbx
int v9; // eax
unsigned int v10; // ebp
const char *v12; // rax
struct addrinfo *pai; // [rsp+8h] [rbp-60h] BYREF
struct addrinfo req; // [rsp+10h] [rbp-58h] BYREF

if ( (unsigned int)(argc - 2) > 1 )
{
puts("Usage: client server-address [filename]");
exit(1);
}
v3 = argv[2];
v4 = argv[1];
v5 = "";
if ( v3 )
v5 = v3;
printf("Sending %s to server at '%s'\n", v5, v4);
*(_OWORD *)&req.ai_flags = 0LL;
*(_OWORD *)&req.ai_addrlen = 0LL;
req.ai_socktype = 1;
req.ai_flags = 1;
*(_OWORD *)&req.ai_canonname = 0LL;
v6 = getaddrinfo(v4, "3490", &req, &pai);
v7 = v6;
if ( v6 )
{
v12 = gai_strerror(v6);
fprintf(stderr, "Server error at getaddrinfo: %s\n", v12);
exit(1);
}
v8 = pai;
if ( !pai )
{
LABEL_16:
v7 = 2;
fwrite("Client: Failed to bind\n", 1uLL, 0x17uLL, stderr);
return v7;
}
while ( 1 )
{
v9 = socket(v8->ai_family, v8->ai_socktype, v8->ai_protocol);
v10 = v9;
if ( v9 != -1 )
break;
perror("Client: Failed to create socket");
LABEL_15:
v8 = v8->ai_next;
if ( !v8 )
goto LABEL_16;
}
if ( connect(v9, v8->ai_addr, v8->ai_addrlen) == -1 )
{
close(v10);
goto LABEL_15;
}
freeaddrinfo(pai);
if ( v3 )
{
if ( !(unsigned int)sendFile(v3, v10) )
goto LABEL_10;
v7 = -1;
fwrite("Client: Error while sending file\n", 1uLL, 0x21uLL, stderr);
}
else
{
if ( (unsigned int)send_std_in(v10) )
fwrite("Client: Error while sending data\n", 1uLL, 0x21uLL, stderr);
LABEL_10:
close(v10);
}
return v7;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // r13
const char *v4; // rbp
const char *v5; // rsi
int v6; // eax
int v7; // er12
struct addrinfo *v8; // rbx
int v9; // eax
unsigned int v10; // ebp
const char *v12; // rax
struct addrinfo *pai; // [rsp+8h] [rbp-60h] BYREF
struct addrinfo req; // [rsp+10h] [rbp-58h] BYREF

if ( (unsigned int)(argc - 2) > 1 )
{
puts("Usage: client server-address [filename]");
exit(1);
}
v3 = argv[2];
v4 = argv[1];
v5 = "";
if ( v3 )
v5 = v3;
printf("Sending %s to server at '%s'\n", v5, v4);
*(_OWORD *)&req.ai_flags = 0LL;
*(_OWORD *)&req.ai_addrlen = 0LL;
req.ai_socktype = 1;
req.ai_flags = 1;
*(_OWORD *)&req.ai_canonname = 0LL;
v6 = getaddrinfo(v4, "3490", &req, &pai);
v7 = v6;
if ( v6 )
{
v12 = gai_strerror(v6);
fprintf(stderr, "Server error at getaddrinfo: %s\n", v12);
exit(1);
}
v8 = pai;
if ( !pai )
{
LABEL_16:
v7 = 2;
fwrite("Client: Failed to bind\n", 1uLL, 0x17uLL, stderr);
return v7;
}
while ( 1 )
{
v9 = socket(v8->ai_family, v8->ai_socktype, v8->ai_protocol);
v10 = v9;
if ( v9 != -1 )
break;
perror("Client: Failed to create socket");
LABEL_15:
v8 = v8->ai_next;
if ( !v8 )
goto LABEL_16;
}
if ( connect(v9, v8->ai_addr, v8->ai_addrlen) == -1 )
{
close(v10);
goto LABEL_15;
}
freeaddrinfo(pai);
if ( v3 )
{
if ( !(unsigned int)func8(v3, v10) )
goto LABEL_10;
v7 = -1;
fwrite("Client: Error while sending file\n", 1uLL, 0x21uLL, stderr);
}
else
{
if ( (unsigned int)func9(v10) )
fwrite("Client: Error while sending data\n", 1uLL, 0x21uLL, stderr);
LABEL_10:
close(v10);
}
return v7;
}

original_code:
int main(int argc, char * args[]) {
    int socketfd, status;
    struct addrinfo hints, *servinfo, *current;
    struct sockaddr_storage remote_addr;
    char ipstr[46];
    socklen_t remote_addr_size;
    if (argc != 2 && argc != 3) {
        printf("Usage: client server-address [filename]\n");
        exit(1);
    }
    char * server = args[1];
    char * filename = args[2];
    printf("Sending %s to server at '%s'\n",
        (filename == ((void *)0)) ? "" : filename, server);
    memset(&hints, 0, sizeof hints);
    hints.ai_family = 0;
    hints.ai_socktype = SOCK_STREAM;
    hints.ai_flags = 0x0001;
    if ((status = getaddrinfo(server, "3490", &hints, &servinfo)) != 0) {
        fprintf(stderr, "Server error at getaddrinfo: %s\n", gai_strerror(status));
        exit(1);
    }
    for (current = servinfo; current != ((void *)0); current = current->ai_next) {
        void * address;
        char * ip_version;
        if (current->ai_family == 2) {
            address = &(((struct sockaddr_in *) current->ai_addr)->sin_addr);
        } else {
            address = &(((struct sockaddr_in6 *) current->ai_addr)->sin6_addr);
        }
        if ((socketfd = socket(current->ai_family,
                             current->ai_socktype,
                             current->ai_protocol)) == -1) {
            perror("Client: Failed to create socket");
            continue;
        }
        if (connect(socketfd, current->ai_addr, current->ai_addrlen) == -1) {
            close(socketfd);
            continue;
        }
        break;
    }
    if (current == ((void *)0)) {
        fprintf(stderr, "Client: Failed to bind\n");
        return 2;
    }
    freeaddrinfo(servinfo);
    if (filename == ((void *)0)) {
      if (send_std_in(socketfd) != 0) {
        fprintf(stderr, "Client: Error while sending data\n");
      }
    } else if (sendFile(filename, socketfd) != 0) {
        fprintf(stderr, "Client: Error while sending file\n");
        return -1;
    }
    close(socketfd);
    return 0;
}

canonical_original_code:
int main(int argc, char *args[]) {
    int socketfd; int status;
    struct addrinfo hints; struct addrinfo *servinfo; struct addrinfo *current;
    struct sockaddr_storage remote_addr;
    char ipstr[46];
    unsigned int remote_addr_size;
    if (argc != 2 && argc != 3) {
        printf("Usage: client server-address [filename]\n");
        exit(1);
    }
    char *server = args[1];
    char *filename = args[2];
    printf("Sending %s to server at '%s'\n",
        (filename == ((void *)0)) ? "" : filename, server);
    memset(&hints, 0, sizeof hints);
    hints.ai_family = 0;
    hints.ai_socktype = SOCK_STREAM;
    hints.ai_flags = 0x0001;
    if ((status = getaddrinfo(server, "3490", &hints, &servinfo)) != 0) {
        fprintf(stderr, "Server error at getaddrinfo: %s\n", gai_strerror(status));
        exit(1);
    }
    for (current = servinfo; current != ((void *)0); current = current->ai_next) {
        void *address;
        char *ip_version;
        if (current->ai_family == 2) {
            address = &(((struct sockaddr_in *) current->ai_addr)->sin_addr);
        } else {
            address = &(((struct sockaddr_in6 *) current->ai_addr)->sin6_addr);
        }
        if ((socketfd = socket(current->ai_family,
                             current->ai_socktype,
                             current->ai_protocol)) == -1) {
            perror("Client: Failed to create socket");
            continue;
        }
        if (connect(socketfd, current->ai_addr, current->ai_addrlen) == -1) {
            close(socketfd);
            continue;
        }
        break;
    }
    if (current == ((void *)0)) {
        fprintf(stderr, "Client: Failed to bind\n");
        return 2;
    }
    freeaddrinfo(servinfo);
    if (filename == ((void *)0)) {
      if (send_std_in(socketfd) != 0) {
        fprintf(stderr, "Client: Error while sending data\n");
      }
    } else if (sendFile(filename, socketfd) != 0) {
        fprintf(stderr, "Client: Error while sending file\n");
        return -1;
    }
    close(socketfd);
    return 0;
}

variable_types: argc int

variable_types:
args
char *[]

variable_types: status int

variable_types: struct addrinfo { int ai_flags; int ai_family; int ai_socktype; int ai_protocol; unsigned int ai_addrlen; struct sockaddr { unsigned short sa_family; char sa_data[14]; } *ai_addr; char *ai_canonname; struct addrinfo *ai_next; } *

variable_types: struct sockaddr_storage { unsigned short ss_family; char __ss_padding[-1]; unsigned long __ss_align; }

variable_types:
ipstr
char [46]

variable_types:
server
char *

variable_types:
filename
char *

variable_types:
address
void *

user_defined_types: struct addrinfo { int ai_flags; int ai_family; int ai_socktype; int ai_protocol; unsigned int ai_addrlen; struct sockaddr *ai_addr; char *ai_canonname; struct addrinfo *ai_next; }

user_defined_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr sin_addr; unsigned char sin_zero[-1]; }

user_defined_types: struct sockaddr_in6 { unsigned short sin6_family; unsigned short sin6_port; unsigned int sin6_flowinfo; struct in6_addr sin6_addr; unsigned int sin6_scope_id; }

user_defined_types: struct in6_addr { union { unsigned char __u6_addr8[16]; unsigned short __u6_addr16[8]; unsigned int __u6_addr32[4]; } __in6_u; }


decompiled_code:
__int64 __fastcall write_file(const char *a1, int a2)
{
int v2; // eax
int v3; // ebx
int v4; // eax
int v5; // er13
_BYTE *v6; // r14
int v7; // eax
_BYTE v9[152]; // [rsp+0h] [rbp-98h] BYREF

v2 = open(a1, 65, 420LL);
if ( v2 < 0 )
{
v5 = -1;
fprintf(stderr, "Failed to create file '%s'\n", a1);
}
else
{
v3 = v2;
LABEL_3:
v4 = recv(a2, v9, 0x64uLL, 0);
v5 = v4;
if ( v4 )
{
if ( v4 < 0 )
{
v5 = -1;
perror("Failure when receiving data");
}
else
{
v6 = v9;
while ( 1 )
{
v7 = write(v3, v6, (unsigned int)v5);
if ( v7 < 0 )
break;
v5 -= v7;
v6 += v7;
if ( v5 <= 0 )
goto LABEL_3;
}
v5 = -1;
fprintf(stderr, "Failed to write to file '%s'", a1);
}
}
}
return (unsigned int)v5;
}

canonical_decompiled_code:
__int64 __fastcall func7(const char *a1, int a2)
{
int v2; // eax
int v3; // ebx
int v4; // eax
int v5; // er13
_BYTE *v6; // r14
int v7; // eax
_BYTE v9[152]; // [rsp+0h] [rbp-98h] BYREF

v2 = open(a1, 65, 420LL);
if ( v2 < 0 )
{
v5 = -1;
fprintf(stderr, "Failed to create file '%s'\n", a1);
}
else
{
v3 = v2;
LABEL_3:
v4 = recv(a2, v9, 0x64uLL, 0);
v5 = v4;
if ( v4 )
{
if ( v4 < 0 )
{
v5 = -1;
perror("Failure when receiving data");
}
else
{
v6 = v9;
while ( 1 )
{
v7 = write(v3, v6, (unsigned int)v5);
if ( v7 < 0 )
break;
v5 -= v7;
v6 += v7;
if ( v5 <= 0 )
goto LABEL_3;
}
v5 = -1;
fprintf(stderr, "Failed to write to file '%s'", a1);
}
}
}
return (unsigned int)v5;
}

original_code:
int write_file(char * filename, int connection_fd) {
    char buffer[100];
    int filefd, bytes_read, bytes_written;
    if ((filefd = open(filename, 0100 | 01, 0644)) < 0) {
        fprintf(stderr, "Failed to create file '%s'\n", filename);
        return -1;
    }
    while (1) {
        bytes_read = recv(connection_fd, buffer, sizeof(buffer), 0);
        if (bytes_read == 0) break;
        if (bytes_read < 0) {
            perror("Failure when receiving data");
            return -1;
        }
        void * p = buffer;
        while (bytes_read > 0) {
            bytes_written = write(filefd, p, bytes_read);
            if (bytes_written < 0) {
                fprintf(stderr, "Failed to write to file '%s'", filename);
                return -1;
            }
            bytes_read -= bytes_written;
            p += bytes_written;
        }
    }
    return 0;
}

canonical_original_code:
int write_file(char *filename, int connection_fd) {
    char buffer[100];
    int filefd; int bytes_read; int bytes_written;
    if ((filefd = open(filename, 0100 | 01, 0644)) < 0) {
        fprintf(stderr, "Failed to create file '%s'\n", filename);
        return -1;
    }
    while (1) {
        bytes_read = recv(connection_fd, buffer, sizeof(buffer), 0);
        if (bytes_read == 0) break;
        if (bytes_read < 0) {
            perror("Failure when receiving data");
            return -1;
        }
        void *p = buffer;
        while (bytes_read > 0) {
            bytes_written = write(filefd, p, bytes_read);
            if (bytes_written < 0) {
                fprintf(stderr, "Failed to write to file '%s'", filename);
                return -1;
            }
            bytes_read -= bytes_written;
            p += bytes_written;
        }
    }
    return 0;
}

variable_types:
buffer
char [100]

variable_types:
p
void *