original_code:
void coulomb_full(ENERGY *ener,PARAM *param,PBC *box,double *x,double *y,
    double *z,double *fx, double *fy, double *fz,double *q,
    int **exclList,int *exclPair)
{
  int i,j,k,exclude;
  double elec=0.,pelec,delec;
  double r,r2,rt,fxi,fyi,fzi,fxj,fyj,fzj;
  double delta[3];
  for(i=0;i<param->nAtom-1;i++)
  {
    fxi=0.;
    fyi=0.;
    fzi=0.;
    for(j=i+1;j<param->nAtom;j++)
    {
      exclude=0;
      for (k=0;k<exclPair[i];k++)
      {
 if(exclList[i][k]==j)
 {
   exclude=1;
   break;
 }
      }
      if(!exclude)
      {
 delta[0]=x[j]-x[i];
 delta[1]=y[j]-y[i];
 delta[2]=z[j]-z[i];
 r2=dist(box,delta);
 r=sqrt(r2);
 rt=1./r;
 pelec=param->chargeConst*q[i]*q[j]*rt;
 elec+=pelec;
 delec=-pelec*rt;
 fxj=delec*delta[0]*rt;
 fyj=delec*delta[1]*rt;
 fzj=delec*delta[2]*rt;
 fxi+=fxj;
 fyi+=fyj;
 fzi+=fzj;
 fx[j]+=-fxj;
 fy[j]+=-fyj;
 fz[j]+=-fzj;
      }
    }
    fx[i]+=fxi;
    fy[i]+=fyi;
    fz[i]+=fzi;
  }
  ener->elec+=elec;
}

canonical_original_code:
void coulomb_full(struct ENERGY *ener, struct PARAM *param, struct PBC *box, double *x, double *y, double *z, double *fx, double *fy, double *fz, double *q, int **exclList, int *exclPair)
{
  int i; int j; int k; int exclude;
  double elec = 0.; double pelec; double delec;
  double r; double r2; double rt; double fxi; double fyi; double fzi; double fxj; double fyj; double fzj;
  double delta[3];
  for(i=0;i<param->nAtom-1;i++)
  {
    fxi=0.;
    fyi=0.;
    fzi=0.;
    for(j=i+1;j<param->nAtom;j++)
    {
      exclude=0;
      for (k=0;k<exclPair[i];k++)
      {
 if(exclList[i][k]==j)
 {
   exclude=1;
   break;
 }
      }
      if(!exclude)
      {
 delta[0]=x[j]-x[i];
 delta[1]=y[j]-y[i];
 delta[2]=z[j]-z[i];
 r2=dist(box,delta);
 r=sqrt(r2);
 rt=1./r;
 pelec=param->chargeConst*q[i]*q[j]*rt;
 elec+=pelec;
 delec=-pelec*rt;
 fxj=delec*delta[0]*rt;
 fyj=delec*delta[1]*rt;
 fzj=delec*delta[2]*rt;
 fxi+=fxj;
 fyi+=fyj;
 fzi+=fzj;
 fx[j]+=-fxj;
 fy[j]+=-fyj;
 fz[j]+=-fzj;
      }
    }
    fx[i]+=fxi;
    fy[i]+=fyi;
    fz[i]+=fzi;
  }
  ener->elec+=elec;
}

variable_types: struct ENERGY { double tot; double elec; double bond; double conint; double virelec; double virshake; } *

variable_types: struct PBC { enum BOX_TYPE { NOBOX=0, CUBIC=1, ORBIC=2, TCLIN=3 } type; double a; double u; double pa; double stress1; double stress4; double stress7; } *

variable_types:
x
double *

variable_types:
y
double *

variable_types:
z
double *

variable_types:
fx
double *

variable_types:
fy
double *

variable_types:
fz
double *

variable_types:
q
double *

variable_types:
exclList
int **

variable_types:
exclPair
int *

variable_types: j int

variable_types: k int

variable_types: exclude int

variable_types: elec double

variable_types: pelec double

variable_types: delec double

variable_types: r double

variable_types: fxi double

variable_types: fyi double

variable_types: fzi double

variable_types: fxj double

variable_types: fyj double

variable_types: fzj double

variable_types:
delta
double [3]

user_defined_types: struct PARAM { int step; double timeStep; int nAtom; int nBond; int nConst; double tolShake; double chargeConst; double cutOff; double cutOn; double temp0; double tolMinim; }

user_defined_types: struct PBC { enum BOX_TYPE type; double a; double u; double pa; double stress1; double stress4; double stress7; }


repo: pcazade/MDBas

decompiled_code:
double __fastcall coulomb_shift1(double *a1, double *a2, double a3, double a4, double a5)
{
double v6; // xmm4_8
double v7; // xmm1_8
double v8; // xmm0_8
double v9; // xmm3_8

v6 = a5 * a4 * a1[13];
v7 = a4 * a1[15];
v8 = 1.0 - (v6 + v6) + v7;
v9 = a3 * a1[9] * a5;
*a2 = (v7 - v6 + v7 - v6 - v8) * (a5 * v9);
return v8 * v9;
}

canonical_decompiled_code:
double __fastcall func2(double *a1, double *a2, double a3, double a4, double a5)
{
double v6; // xmm4_8
double v7; // xmm1_8
double v8; // xmm0_8
double v9; // xmm3_8

v6 = a5 * a4 * a1[13];
v7 = a4 * a1[15];
v8 = 1.0 - (v6 + v6) + v7;
v9 = a3 * a1[9] * a5;
*a2 = (v7 - v6 + v7 - v6 - v8) * (a5 * v9);
return v8 * v9;
}

original_code:
double coulomb_shift1(const PARAM *param,double *delec,const double qel,
        const double r2,const double rt)
{
  double elec=0.,pelec,shift1,shift2,shiftFunc,dshiftFunc;
  shift1=rt*r2*param->rcutOff;
  shift2=r2*param->rcutOff2;
  shiftFunc=1.-2.*shift1+shift2;
  dshiftFunc=2.*(shift2-shift1);
  pelec=param->chargeConst*qel*rt;
  elec=pelec*shiftFunc;
  *delec=pelec*rt*(dshiftFunc-shiftFunc);
  return elec;
}

canonical_original_code:
double coulomb_shift1(struct PARAM *param, double *delec, double qel, double r2, double rt)
{
  double elec = 0.; double pelec; double shift1; double shift2; double shiftFunc; double dshiftFunc;
  shift1=rt*r2*param->rcutOff;
  shift2=r2*param->rcutOff2;
  shiftFunc=1.-2.*shift1+shift2;
  dshiftFunc=2.*(shift2-shift1);
  pelec=param->chargeConst*qel*rt;
  elec=pelec*shiftFunc;
  *delec=pelec*rt*(dshiftFunc-shiftFunc);
  return elec;
}

variable_types: struct PARAM { int step; double timeStep; int nAtom; int nBond; int nConst; double tolShake; double chargeConst; double cutOff; double cutOn; double temp0; double tolMinim; } *

variable_types:
delec
double *

variable_types: qel double

variable_types: rt double

variable_types: shiftFunc double

variable_types: dshiftFunc double

return_type: double


original_code:
double coulomb_switch(const PARAM *param,double *delec,const double qel,
        const double r2,const double rt)
{
  double elec=0.,pelec,switch1,switchFunc,dswitchFunc;
  if(r2<=param->cutOn2)
  {
    pelec=param->chargeConst*qel*rt;
    elec=pelec;
    *delec=-pelec*rt;
  }
  else
  {
    switch1=param->cutOff2-r2;
    switchFunc=((switch1)*(switch1))*(param->cutOff2+2.*r2-3.*param->cutOn2)*param->switch2;
    dswitchFunc=12.*r2*switch1*(param->cutOn2-r2)*param->switch2;
    pelec=param->chargeConst*qel*rt;
    elec=pelec*switchFunc;
    *delec=pelec*rt*(dswitchFunc-switchFunc);
  }
  return elec;
}

canonical_original_code:
double coulomb_switch(struct PARAM *param, double *delec, double qel, double r2, double rt)
{
  double elec = 0.; double pelec; double switch1; double switchFunc; double dswitchFunc;
  if(r2<=param->cutOn2)
  {
    pelec=param->chargeConst*qel*rt;
    elec=pelec;
    *delec=-pelec*rt;
  }
  else
  {
    switch1=param->cutOff2-r2;
    switchFunc=((switch1)*(switch1))*(param->cutOff2+2.*r2-3.*param->cutOn2)*param->switch2;
    dswitchFunc=12.*r2*switch1*(param->cutOn2-r2)*param->switch2;
    pelec=param->chargeConst*qel*rt;
    elec=pelec*switchFunc;
    *delec=pelec*rt*(dswitchFunc-switchFunc);
  }
  return elec;
}

variable_types: elec double

variable_types: switchFunc double

variable_types: dswitchFunc double


decompiled_code:
double __fastcall coulomb14_none(__int64 a1, _QWORD *a2)
{
*a2 = 0LL;
return 0.0;
}

canonical_decompiled_code:
double __fastcall func4(__int64 a1, _QWORD *a2)
{
*a2 = 0LL;
return 0.0;
}

original_code:
double coulomb14_none(const PARAM *param,double *delec,const double qel,
        const double r2,const double rt)
{
  *delec=0.;
  return 0.;
}

canonical_original_code:
double coulomb14_none(struct PARAM *param, double *delec, double qel, double r2, double rt)
{
  *delec=0.;
  return 0.;
}


decompiled_code:
void __fastcall coulomb14_full(__int64 a1, double *a2, double a3, double a4, double a5)
{
*a2 = a5 * COERCE_DOUBLE(COERCE_UNSIGNED_INT64(*(double *)(a1 + 88) * *(double *)(a1 + 72) * a3 * a5) ^ LC2);
}

canonical_decompiled_code:
void __fastcall func5(__int64 a1, double *a2, double a3, double a4, double a5)
{
*a2 = a5 * COERCE_DOUBLE(COERCE_UNSIGNED_INT64(*(double *)(a1 + 88) * *(double *)(a1 + 72) * a3 * a5) ^ LC2);
}

original_code:
double coulomb14_full(const PARAM *param,double *delec,const double qel,
        const double r2,const double rt)
{
  double elec=0.;
  elec=param->scal14*param->chargeConst*qel*rt;
  *delec=-elec*rt;
  return elec;
}

canonical_original_code:
double coulomb14_full(struct PARAM *param, double *delec, double qel, double r2, double rt)
{
  double elec = 0.;
  elec=param->scal14*param->chargeConst*qel*rt;
  *delec=-elec*rt;
  return elec;
}


decompiled_code:
double __fastcall coulomb14_switch(double *a1, double *a2, double a3, double a4, double a5)
{
double v5; // xmm6_8
double result; // xmm0_8
double v7; // xmm7_8
double v8; // xmm9_8
double v9; // xmm3_8
double v10; // xmm8_8
double v11; // xmm7_8

v5 = a1[17];
if ( v5 < a4 )
{
v7 = a1[14];
if ( v7 < a4 )
{
result = 0.0;
}
else
{
v8 = v7 - a4;
v9 = a1[18];
v10 = (v7 + a4 + a4 - v5 * 3.0) * (v8 * v8) * v9;
v11 = a1[11] * a1[9] * a3 * a5;
result = v10 * v11;
*a2 = (v9 * (a4 * 12.0 * v8 * (v5 - a4)) - v10) * (a5 * v11);
}
}
else
{
result = a3 * (a1[11] * a1[9]) * a5;
*a2 = a5 * COERCE_DOUBLE(*(_QWORD *)&result ^ LC2);
}
return result;
}

original_code:
double coulomb14_switch(const PARAM *param,double *delec,const double qel,
   const double r2,const double rt)
{
  double elec=0.,pelec,switch1,switchFunc,dswitchFunc;
  if(r2<=param->cutOn2)
  {
    pelec=param->scal14*param->chargeConst*qel*rt;
    elec=pelec;
    *delec=-pelec*rt;
  }
  else if(r2<=param->cutOff2)
  {
    switch1=param->cutOff2-r2;
    switchFunc=((switch1)*(switch1))*(param->cutOff2+2.*r2-3.*param->cutOn2)*param->switch2;
    dswitchFunc=12.*r2*switch1*(param->cutOn2-r2)*param->switch2;
    pelec=param->scal14*param->chargeConst*qel*rt;
    elec=pelec*switchFunc;
    *delec=pelec*rt*(dswitchFunc-switchFunc);
  }
  return elec;
}

canonical_original_code:
double coulomb14_switch(struct PARAM *param, double *delec, double qel, double r2, double rt)
{
  double elec = 0.; double pelec; double switch1; double switchFunc; double dswitchFunc;
  if(r2<=param->cutOn2)
  {
    pelec=param->scal14*param->chargeConst*qel*rt;
    elec=pelec;
    *delec=-pelec*rt;
  }
  else if(r2<=param->cutOff2)
  {
    switch1=param->cutOff2-r2;
    switchFunc=((switch1)*(switch1))*(param->cutOff2+2.*r2-3.*param->cutOn2)*param->switch2;
    dswitchFunc=12.*r2*switch1*(param->cutOn2-r2)*param->switch2;
    pelec=param->scal14*param->chargeConst*qel*rt;
    elec=pelec*switchFunc;
    *delec=pelec*rt*(dswitchFunc-switchFunc);
  }
  return elec;
}

variable_types: pelec double


decompiled_code:
double __fastcall vdw_none(__int64 a1, _QWORD *a2)
{
*a2 = 0LL;
return 0.0;
}

canonical_decompiled_code:
double __fastcall func0(__int64 a1, _QWORD *a2)
{
*a2 = 0LL;
return 0.0;
}

original_code:
double vdw_none(const PARAM *param, double *dvdw, const double veps,
        const double vsig, const double r2, const double rt)
{
    *dvdw = 0.;
    return 0.;
}

canonical_original_code:
double vdw_none(struct PARAM *param, double *dvdw, double veps, double vsig, double r2, double rt)
{
    *dvdw = 0.;
    return 0.;
}

variable_types:
dvdw
double *

variable_types: veps double

variable_types: vsig double


original_code:
void vdw_full(const PARAM *param, ENERGY *ener, const PBC *box, double *x,
        double *y, double *z, double *fx, double *fy, double *fz, double *eps, double *sig,
        int **exclList, int *exclPair)
{
    int i, j, k, exclude;
    ;
    double evdw = 0., pvdw, dvdw;
    double r, r2, rt, fxj, fyj, fzj, fxi, fyi, fzi;
    double delta[3];
    for (i = 0; i < param->nAtom - 1; i++)
    {
        fxi = 0.;
        fyi = 0.;
        fzi = 0.;
        for (j = i + 1; j < param->nAtom; j++)
        {
            exclude = 0;
            for (k = 0; k < exclPair[i]; k++)
            {
                if (exclList[i][k] == j)
                {
                    exclude = 1;
                    break;
                }
            }
            if (!exclude)
            {
                delta[0] = x[j] - x[i];
                delta[1] = y[j] - y[i];
                delta[2] = z[j] - z[i];
                r2 = dist(box, delta);
                r = sqrt(r2);
                rt = 1. / r;
                pvdw = 4. * eps[i] * eps[j]*(((((((sig[i] + sig[j]) / r)*((sig[i] + sig[j]) / r))*((sig[i] + sig[j]) / r))*((((sig[i] + sig[j]) / r)*((sig[i] + sig[j]) / r))*((sig[i] + sig[j]) / r)))*(((((sig[i] + sig[j]) / r)*((sig[i] + sig[j]) / r))*((sig[i] + sig[j]) / r))*((((sig[i] + sig[j]) / r)*((sig[i] + sig[j]) / r))*((sig[i] + sig[j]) / r)))) - (((((sig[i] + sig[j]) / r)*((sig[i] + sig[j]) / r))*((sig[i] + sig[j]) / r))*((((sig[i] + sig[j]) / r)*((sig[i] + sig[j]) / r))*((sig[i] + sig[j]) / r))));
                dvdw = 24. * eps[i] * eps[j] / r * ((((((sig[i] + sig[j]) / r)*((sig[i] + sig[j]) / r))*((sig[i] + sig[j]) / r))*((((sig[i] + sig[j]) / r)*((sig[i] + sig[j]) / r))*((sig[i] + sig[j]) / r))) - 2. * ((((((sig[i] + sig[j]) / r)*((sig[i] + sig[j]) / r))*((sig[i] + sig[j]) / r))*((((sig[i] + sig[j]) / r)*((sig[i] + sig[j]) / r))*((sig[i] + sig[j]) / r)))*(((((sig[i] + sig[j]) / r)*((sig[i] + sig[j]) / r))*((sig[i] + sig[j]) / r))*((((sig[i] + sig[j]) / r)*((sig[i] + sig[j]) / r))*((sig[i] + sig[j]) / r)))));
                evdw += pvdw;
                fxj = dvdw * delta[0] / r;
                fyj = dvdw * delta[1] / r;
                fzj = dvdw * delta[2] / r;
                fxi += fxj;
                fyi += fyj;
                fzi += fzj;
                fx[j] += -fxj;
                fy[j] += -fyj;
                fz[j] += -fzj;
            }
        }
        fx[i] += fxi;
        fy[i] += fyi;
        fz[i] += fzi;
    }
    ener->vdw += evdw;
}

canonical_original_code:
void vdw_full(struct PARAM *param, struct ENERGY *ener, struct PBC *box, double *x, double *y, double *z, double *fx, double *fy, double *fz, double *eps, double *sig, int **exclList, int *exclPair)
{
    int i; int j; int k; int exclude;
    ;
    double evdw = 0.; double pvdw; double dvdw;
    double r; double r2; double rt; double fxj; double fyj; double fzj; double fxi; double fyi; double fzi;
    double delta[3];
    for (i = 0; i < param->nAtom - 1; i++)
    {
        fxi = 0.;
        fyi = 0.;
        fzi = 0.;
        for (j = i + 1; j < param->nAtom; j++)
        {
            exclude = 0;
            for (k = 0; k < exclPair[i]; k++)
            {
                if (exclList[i][k] == j)
                {
                    exclude = 1;
                    break;
                }
            }
            if (!exclude)
            {
                delta[0] = x[j] - x[i];
                delta[1] = y[j] - y[i];
                delta[2] = z[j] - z[i];
                r2 = dist(box, delta);
                r = sqrt(r2);
                rt = 1. / r;
                pvdw = 4. * eps[i] * eps[j]*(((((((sig[i] + sig[j]) / r)*((sig[i] + sig[j]) / r))*((sig[i] + sig[j]) / r))*((((sig[i] + sig[j]) / r)*((sig[i] + sig[j]) / r))*((sig[i] + sig[j]) / r)))*(((((sig[i] + sig[j]) / r)*((sig[i] + sig[j]) / r))*((sig[i] + sig[j]) / r))*((((sig[i] + sig[j]) / r)*((sig[i] + sig[j]) / r))*((sig[i] + sig[j]) / r)))) - (((((sig[i] + sig[j]) / r)*((sig[i] + sig[j]) / r))*((sig[i] + sig[j]) / r))*((((sig[i] + sig[j]) / r)*((sig[i] + sig[j]) / r))*((sig[i] + sig[j]) / r))));
                dvdw = 24. * eps[i] * eps[j] / r * ((((((sig[i] + sig[j]) / r)*((sig[i] + sig[j]) / r))*((sig[i] + sig[j]) / r))*((((sig[i] + sig[j]) / r)*((sig[i] + sig[j]) / r))*((sig[i] + sig[j]) / r))) - 2. * ((((((sig[i] + sig[j]) / r)*((sig[i] + sig[j]) / r))*((sig[i] + sig[j]) / r))*((((sig[i] + sig[j]) / r)*((sig[i] + sig[j]) / r))*((sig[i] + sig[j]) / r)))*(((((sig[i] + sig[j]) / r)*((sig[i] + sig[j]) / r))*((sig[i] + sig[j]) / r))*((((sig[i] + sig[j]) / r)*((sig[i] + sig[j]) / r))*((sig[i] + sig[j]) / r)))));
                evdw += pvdw;
                fxj = dvdw * delta[0] / r;
                fyj = dvdw * delta[1] / r;
                fzj = dvdw * delta[2] / r;
                fxi += fxj;
                fyi += fyj;
                fzi += fzj;
                fx[j] += -fxj;
                fy[j] += -fyj;
                fz[j] += -fzj;
            }
        }
        fx[i] += fxi;
        fy[i] += fyi;
        fz[i] += fzi;
    }
    ener->vdw += evdw;
}

variable_types: struct ENERGY { double tot; double elec; double bond; double conint; double virelec; double virshake; } *

variable_types: struct PBC { enum BOX_TYPE { NOBOX=0, CUBIC=1, ORBIC=2, TCLIN=3 } type; double a; double u; double pa; double stress1; double stress4; double stress7; } *

variable_types:
x
double *

variable_types:
y
double *

variable_types:
z
double *

variable_types:
fx
double *

variable_types:
fy
double *

variable_types:
fz
double *

variable_types:
eps
double *

variable_types:
sig
double *

variable_types:
exclList
int **

variable_types:
exclPair
int *

variable_types: i int

variable_types: j int

variable_types: k int

variable_types: exclude int

variable_types: evdw double

variable_types: pvdw double

variable_types: dvdw double

variable_types: r double

variable_types: fxj double

variable_types: fxi double

variable_types: fyi double

variable_types: fzi double

return_type: void


decompiled_code:
double __fastcall vdw14_none(__int64 a1, _QWORD *a2)
{
*a2 = 0LL;
return 0.0;
}

canonical_decompiled_code:
double __fastcall func2(__int64 a1, _QWORD *a2)
{
*a2 = 0LL;
return 0.0;
}

original_code:
double vdw14_none(const PARAM *param, double *dvdw, const double veps,
        const double vsig, const double r2, const double rt)
{
    *dvdw = 0;
    return 0.;
}

canonical_original_code:
double vdw14_none(struct PARAM *param, double *dvdw, double veps, double vsig, double r2, double rt)
{
    *dvdw = 0;
    return 0.;
}

variable_types: struct PARAM { int step; double timeStep; int nAtom; int nBond; int nConst; double tolShake; double chargeConst; double cutOff; double cutOn; double temp0; double tolMinim; } *

variable_types:
dvdw
double *

variable_types: veps double

variable_types: vsig double

variable_types: rt double


original_code:
double vdw14_full(const PARAM *param, double *dvdw, const double veps,
        const double vsig, const double r2, const double rt)
{
    double evdw = 0.;
    double vsig6, vsig12;
    vsig6 = vsig*rt;
    vsig6 = ((((vsig6)*(vsig6))*(vsig6))*(((vsig6)*(vsig6))*(vsig6)));
    vsig12 = ((vsig6)*(vsig6));
    evdw = 4. * param->scal14 * veps * (vsig12 - vsig6);
    *dvdw = 24. * param->scal14 * veps * rt * (vsig6 - 2. * vsig12);
    return evdw;
}

canonical_original_code:
double vdw14_full(struct PARAM *param, double *dvdw, double veps, double vsig, double r2, double rt)
{
    double evdw = 0.;
    double vsig6; double vsig12;
    vsig6 = vsig*rt;
    vsig6 = ((((vsig6)*(vsig6))*(vsig6))*(((vsig6)*(vsig6))*(vsig6)));
    vsig12 = ((vsig6)*(vsig6));
    evdw = 4. * param->scal14 * veps * (vsig12 - vsig6);
    *dvdw = 24. * param->scal14 * veps * rt * (vsig6 - 2. * vsig12);
    return evdw;
}


minimise

decompiled_code:
void minimise()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
void minimise(CTRL *ctrl,PARAM *param,ENERGY *ener,PBC *box,NEIGH *neigh,
       ATOM atom[],BOND bond[],BOND ub[],ANGLE angle[],DIHE dihe[],
       DIHE impr[])
{
}

canonical_original_code:
void minimise(struct CTRL *ctrl, struct PARAM *param, struct ENERGY *ener, struct PBC *box, struct NEIGH *neigh, struct ATOM atom[], struct BOND bond[], struct BOND ub[], struct ANGLE angle[], struct DIHE dihe[], struct DIHE impr[])
{
}

variable_types: struct CTRL { int newjob; int keyRand; int printOut; int keyMd; int seed; int keyMinim; int keyLink; int keyConstH; int keyNb14; int keyEwald; enum ELEC_TYPE { NOELEC=0, FULL=1, SHIFT1=2, SHIFT2=3, SWITCH=4 } elecType; enum VDW_TYPE { NOVDW=0, VFULL=1, VSWITCH=2 } vdwType; enum INTEGRATOR_TYPE { LEAPFROG=0, VELOCITY=1 } integrator; enum ENSEMBLE_TYPE { NVE=0, NVT_B=1, NPT_B=2, NVT_H=3, NPT_H=4 } ens; } *

variable_types: struct ENERGY { double tot; double elec; double bond; double conint; double virelec; double virshake; } *

variable_types: struct PBC { enum BOX_TYPE { NOBOX=0, CUBIC=1, ORBIC=2, TCLIN=3 } type; double a; double u; double pa; double stress1; double stress4; double stress7; } *

variable_types: struct NEIGH { int update; int linkRatio; int nCells; int sizeList; int nPair14; } *

variable_types: struct ATOM { char label[5]; int type; } []

variable_types: struct BOND { enum BOND_TYPE { BHARM=0, BMORSE=1 } type; int a; double k; } []

variable_types:
ub
struct BOND []

variable_types: struct ANGLE { enum ANGLE_TYPE { AHARM=0 } type; int a; double k; } []

variable_types: struct DIHE { enum DIHE_TYPE { DCOS=1, DHARM=2 } type; int order; int a; double k; } []

variable_types:
impr
struct DIHE []

user_defined_types: struct CTRL { int newjob; int keyRand; int printOut; int keyMd; int seed; int keyMinim; int keyLink; int keyConstH; int keyNb14; int keyEwald; enum ELEC_TYPE elecType; enum VDW_TYPE vdwType; enum INTEGRATOR_TYPE integrator; enum ENSEMBLE_TYPE ens; }

user_defined_types: struct BOND { enum BOND_TYPE type; int a; double k; }

user_defined_types: struct ANGLE { enum ANGLE_TYPE type; int a; double k; }

user_defined_types: struct DIHE { enum DIHE_TYPE type; int order; int a; double k; }


steepestDescent

original_code:
void steepestDescent(CTRL *ctrl,PARAM *param,ENERGY *ener,PBC *box,NEIGH *neigh,
       ATOM atom[],BOND bond[],BOND ub[],ANGLE angle[],DIHE dihe[],
       DIHE impr[],double x[],double y[],double z[],double fx[],
       double fy[],double fz[])
{
  double step = 1.0e-7 ;
  double prec = 1.0e-3 ;
  int maxSteps = 10000 ;
  double diff;
  double eprev = 0. , enow = 0. ;
  int i, currSt=0 ;
  eprev = ener->pot;
  do
  {
    for (i=0 ; i < param->nAtom ; i++)
    {
      x[i] += step * fx[i] ;
      y[i] += step * fy[i] ;
      z[i] += step * fz[i] ;
    }
    enow = ener->pot;
    diff = fabs(enow-eprev);
    eprev=enow;
    currSt++;
  } while ( (diff >= prec) && (currSt<=maxSteps) ) ;
}

canonical_original_code:
void steepestDescent(struct CTRL *ctrl, struct PARAM *param, struct ENERGY *ener, struct PBC *box, struct NEIGH *neigh, struct ATOM atom[], struct BOND bond[], struct BOND ub[], struct ANGLE angle[], struct DIHE dihe[], struct DIHE impr[], double x[], double y[], double z[], double fx[], double fy[], double fz[])
{
  double step = 1.0e-7;
  double prec = 1.0e-3;
  int maxSteps = 10000;
  double diff;
  double eprev = 0.; double enow = 0.;
  int i; int currSt = 0;
  eprev = ener->pot;
  do
  {
    for (i=0 ; i < param->nAtom ; i++)
    {
      x[i] += step * fx[i] ;
      y[i] += step * fy[i] ;
      z[i] += step * fz[i] ;
    }
    enow = ener->pot;
    diff = fabs(enow-eprev);
    eprev=enow;
    currSt++;
  } while ( (diff >= prec) && (currSt<=maxSteps) ) ;
}

variable_types:
x
double []

variable_types:
y
double []

variable_types:
z
double []

variable_types:
fx
double []

variable_types:
fy
double []

variable_types:
fz
double []

variable_types: step double

variable_types: prec double

variable_types: maxSteps int

variable_types: diff double

variable_types: eprev double

variable_types: enow double

variable_types: i int

variable_types: currSt int

user_defined_types: struct ENERGY { double tot; double elec; double bond; double conint; double virelec; double virshake; }

user_defined_types: struct NEIGH { int update; int linkRatio; int nCells; int sizeList; int nPair14; }

user_defined_types: struct ATOM { char label[5]; int type; }

user_defined_types: enum ELEC_TYPE { NOELEC=0, FULL=1, SHIFT1=2, SHIFT2=3, SWITCH=4 }

user_defined_types: enum VDW_TYPE { NOVDW=0, VFULL=1, VSWITCH=2 }

user_defined_types: enum INTEGRATOR_TYPE { LEAPFROG=0, VELOCITY=1 }

user_defined_types: enum ENSEMBLE_TYPE { NVE=0, NVT_B=1, NPT_B=2, NVT_H=3, NPT_H=4 }

user_defined_types: enum BOX_TYPE { NOBOX=0, CUBIC=1, ORBIC=2, TCLIN=3 }


conjugateGradients

decompiled_code:
void conjugateGradients()
{
;
}

canonical_decompiled_code:
void func2()
{
;
}

original_code:
void conjugateGradients(CTRL *ctrl,PARAM *param,ENERGY *ener,PBC *box,NEIGH *neigh,
   ATOM atom[],BOND bond[],BOND ub[],ANGLE angle[],DIHE dihe[],
   DIHE impr[])
{
}

canonical_original_code:
void conjugateGradients(struct CTRL *ctrl, struct PARAM *param, struct ENERGY *ener, struct PBC *box, struct NEIGH *neigh, struct ATOM atom[], struct BOND bond[], struct BOND ub[], struct ANGLE angle[], struct DIHE dihe[], struct DIHE impr[])
{
}

variable_types: struct CTRL { int newjob; int keyRand; int printOut; int keyMd; int seed; int keyMinim; int keyLink; int keyConstH; int keyNb14; int keyEwald; enum ELEC_TYPE { NOELEC=0, FULL=1, SHIFT1=2, SHIFT2=3, SWITCH=4 } elecType; enum VDW_TYPE { NOVDW=0, VFULL=1, VSWITCH=2 } vdwType; enum INTEGRATOR_TYPE { LEAPFROG=0, VELOCITY=1 } integrator; enum ENSEMBLE_TYPE { NVE=0, NVT_B=1, NPT_B=2, NVT_H=3, NPT_H=4 } ens; } *

variable_types: struct PARAM { int step; double timeStep; int nAtom; int nBond; int nConst; double tolShake; double chargeConst; double cutOff; double cutOn; double temp0; double tolMinim; } *

variable_types: struct ENERGY { double tot; double elec; double bond; double conint; double virelec; double virshake; } *

variable_types: struct PBC { enum BOX_TYPE { NOBOX=0, CUBIC=1, ORBIC=2, TCLIN=3 } type; double a; double u; double pa; double stress1; double stress4; double stress7; } *

variable_types: struct NEIGH { int update; int linkRatio; int nCells; int sizeList; int nPair14; } *

variable_types: struct ATOM { char label[5]; int type; } []

variable_types: struct BOND { enum BOND_TYPE { BHARM=0, BMORSE=1 } type; int a; double k; } []

variable_types:
ub
struct BOND []

variable_types: struct ANGLE { enum ANGLE_TYPE { AHARM=0 } type; int a; double k; } []


decompiled_code:
void *__fastcall my_malloc(size_t a1)
{
void *v1; // rbx

v1 = malloc(a1);
if ( !v1 )
my_error(1LL, "src/memory.c", 27LL, 0LL);
return v1;
}

canonical_decompiled_code:
void *__fastcall func0(size_t a1)
{
void *v1; // rbx

v1 = malloc(a1);
if ( !v1 )
my_error(1LL, "src/memory.c", 27LL, 0LL);
return v1;
}

original_code:
void* my_malloc(size_t size)
{
  void *ptr = ((void *)0);
  ptr=(void*)malloc(size);
  if(ptr==((void *)0))
    my_error(MEM_ALLOC_ERROR,"src/memory.c",27,0);
  return ptr;
}

canonical_original_code:
void *my_malloc(unsigned long size)
{
  void *ptr = ((void *)0);
  ptr=(void *)malloc(size);
  if(ptr==((void *)0))
    my_error(MEM_ALLOC_ERROR,"src/memory.c",27,0);
  return ptr;
}

variable_types:
size
unsigned long

variable_types:
ptr
void *

return_type: void *


decompiled_code:
void *__fastcall my_realloc(void *a1, size_t a2)
{
void *v2; // rbx

v2 = realloc(a1, a2);
if ( !v2 )
my_error(1LL, "src/memory.c", 40LL, 0LL);
return v2;
}

canonical_decompiled_code:
void *__fastcall func1(void *a1, size_t a2)
{
void *v2; // rbx

v2 = realloc(a1, a2);
if ( !v2 )
my_error(1LL, "src/memory.c", 40LL, 0LL);
return v2;
}

original_code:
void* my_realloc(void *ptr1,size_t size)
{
  void *ptr2 = ((void *)0);
  ptr2=(void*)realloc(ptr1,size);
  if(ptr2==((void *)0))
    my_error(MEM_ALLOC_ERROR,"src/memory.c",40,0);
  return ptr2;
}

canonical_original_code:
void *my_realloc(void *ptr1, unsigned long size)
{
  void *ptr2 = ((void *)0);
  ptr2=(void *)realloc(ptr1,size);
  if(ptr2==((void *)0))
    my_error(MEM_ALLOC_ERROR,"src/memory.c",40,0);
  return ptr2;
}


decompiled_code:
void *__fastcall my_calloc(int a1, size_t a2)
{
void *v2; // rbx

v2 = calloc(a1, a2);
if ( !v2 )
my_error(1LL, "src/memory.c", 53LL, 0LL);
return v2;
}

canonical_decompiled_code:
void *__fastcall func2(int a1, size_t a2)
{
void *v2; // rbx

v2 = calloc(a1, a2);
if ( !v2 )
my_error(1LL, "src/memory.c", 53LL, 0LL);
return v2;
}

original_code:
void* my_calloc(int dim, size_t size)
{
  void *ptr = ((void *)0);
  ptr=(void*)calloc(dim,size);
  if(ptr==((void *)0))
    my_error(MEM_ALLOC_ERROR,"src/memory.c",53,0);
  return ptr;
}

canonical_original_code:
void *my_calloc(int dim, unsigned long size)
{
  void *ptr = ((void *)0);
  ptr=(void *)calloc(dim,size);
  if(ptr==((void *)0))
    my_error(MEM_ALLOC_ERROR,"src/memory.c",53,0);
  return ptr;
}

variable_types: dim int


decompiled_code:
char *free_2D(int a1, __int64 a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10, ...)
{
char *result; // rax
void **v11; // r12
void **v12; // rdx
void **v13; // rbx
gcc_va_list va; // [rsp+8h] [rbp-70h] BYREF
__int64 v15; // [rsp+28h] [rbp-50h]

va_start(va, a10);
v15 = a2;
result = (char *)va[0].reg_save_area;
if ( a2 )
{
v11 = (void **)a2;
do
{
v13 = v11;
if ( a1 > 0 )
{
do
free(*v13++);
while ( v13 != &v11[(unsigned int)(a1 - 1) + 1] );
}
free(v11);
if ( va[0].gp_offset > 0x2F )
{
v12 = (void **)va[0].overflow_arg_area;
result = (char *)va[0].overflow_arg_area + 8;
va[0].overflow_arg_area = (char *)va[0].overflow_arg_area + 8;
}
else
{
v12 = (void **)((char *)va[0].reg_save_area + va[0].gp_offset);
result = (char *)(va[0].gp_offset + 8);
va[0].gp_offset += 8;
}
v11 = (void **)*v12;
}
while ( *v12 );
}
return result;
}

canonical_decompiled_code:
char *func3(int a1, __int64 a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10, ...)
{
char *result; // rax
void **v11; // r12
void **v12; // rdx
void **v13; // rbx
gcc_va_list va; // [rsp+8h] [rbp-70h] BYREF
__int64 v15; // [rsp+28h] [rbp-50h]

va_start(va, a10);
v15 = a2;
result = (char *)va[0].reg_save_area;
if ( a2 )
{
v11 = (void **)a2;
do
{
v13 = v11;
if ( a1 > 0 )
{
do
free(*v13++);
while ( v13 != &v11[(unsigned int)(a1 - 1) + 1] );
}
free(v11);
if ( va[0].gp_offset > 0x2F )
{
v12 = (void **)va[0].overflow_arg_area;
result = (char *)va[0].overflow_arg_area + 8;
va[0].overflow_arg_area = (char *)va[0].overflow_arg_area + 8;
}
else
{
v12 = (void **)((char *)va[0].reg_save_area + va[0].gp_offset);
result = (char *)(va[0].gp_offset + 8);
va[0].gp_offset += 8;
}
v11 = (void **)*v12;
}
while ( *v12 );
}
return result;
}

original_code:
void free_2D(int dim1, ...)
{
    int i;
    void **array=((void *)0);
    va_list ap;
    __builtin_va_start(ap,dim1);
    array=__builtin_va_arg(ap,void**);
    while(array!=((void *)0))
    {
        for(i=0; i<dim1; i++)
            free(array[i]);
        free(array);
        array=((void *)0);
        array=__builtin_va_arg(ap,void**);
    }
    __builtin_va_end(ap);
}

canonical_original_code:
void free_2D(int dim1, ...)
{
    int i;
    void **array = ((void *)0);
    __builtin_va_list ap;
    __builtin_va_start(ap,dim1);
    array=__builtin_va_arg(ap,void**);
    while(array!=((void *)0))
    {
        for(i=0; i<dim1; i++)
            free(array[i]);
        free(array);
        array=((void *)0);
        array=__builtin_va_arg(ap,void**);
    }
    __builtin_va_end(ap);
}

variable_types:
array
void **


decompiled_code:
char *free_3D(int a1, int a2, __int64 a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10, double a11, ...)
{
char *result; // rax
void **v12; // r15
__int64 v13; // rbx
void **v14; // rbp
void **v15; // rdx
gcc_va_list va; // [rsp+18h] [rbp-80h] BYREF
__int64 v17; // [rsp+40h] [rbp-58h]

va_start(va, a11);
v17 = a3;
result = (char *)va[0].reg_save_area;
if ( a3 )
{
v12 = (void **)a3;
do
{
if ( a1 > 0 )
{
v14 = v12;
do
{
v13 = 0LL;
if ( a2 > 0 )
{
do
{
free(*(void **)((char *)*v14 + v13));
v13 += 8LL;
}
while ( 8LL * (unsigned int)(a2 - 1) + 8 != v13 );
}
free(*v14++);
}
while ( v14 != &v12[(unsigned int)(a1 - 1) + 1] );
}
free(v12);
if ( va[0].gp_offset > 0x2F )
{
v15 = (void **)va[0].overflow_arg_area;
result = (char *)va[0].overflow_arg_area + 8;
va[0].overflow_arg_area = (char *)va[0].overflow_arg_area + 8;
}
else
{
v15 = (void **)((char *)va[0].reg_save_area + va[0].gp_offset);
result = (char *)(va[0].gp_offset + 8);
va[0].gp_offset += 8;
}
v12 = (void **)*v15;
}
while ( *v15 );
}
return result;
}

canonical_decompiled_code:
char *func4(int a1, int a2, __int64 a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10, double a11, ...)
{
char *result; // rax
void **v12; // r15
__int64 v13; // rbx
void **v14; // rbp
void **v15; // rdx
gcc_va_list va; // [rsp+18h] [rbp-80h] BYREF
__int64 v17; // [rsp+40h] [rbp-58h]

va_start(va, a11);
v17 = a3;
result = (char *)va[0].reg_save_area;
if ( a3 )
{
v12 = (void **)a3;
do
{
if ( a1 > 0 )
{
v14 = v12;
do
{
v13 = 0LL;
if ( a2 > 0 )
{
do
{
free(*(void **)((char *)*v14 + v13));
v13 += 8LL;
}
while ( 8LL * (unsigned int)(a2 - 1) + 8 != v13 );
}
free(*v14++);
}
while ( v14 != &v12[(unsigned int)(a1 - 1) + 1] );
}
free(v12);
if ( va[0].gp_offset > 0x2F )
{
v15 = (void **)va[0].overflow_arg_area;
result = (char *)va[0].overflow_arg_area + 8;
va[0].overflow_arg_area = (char *)va[0].overflow_arg_area + 8;
}
else
{
v15 = (void **)((char *)va[0].reg_save_area + va[0].gp_offset);
result = (char *)(va[0].gp_offset + 8);
va[0].gp_offset += 8;
}
v12 = (void **)*v15;
}
while ( *v15 );
}
return result;
}

original_code:
void free_3D(int dim1, int dim2, ...)
{
    int i,j;
    void ***array=((void *)0);
    va_list ap;
    __builtin_va_start(ap,dim2);
    array=__builtin_va_arg(ap,void***);
    while(array!=((void *)0))
    {
        for(i=0; i<dim1; i++)
        {
            for(j=0; j<dim2; j++)
                free(array[i][j]);
            free(array[i]);
        }
        free(array);
        array=((void *)0);
        array=__builtin_va_arg(ap,void***);
    }
    __builtin_va_end(ap);
}

canonical_original_code:
void free_3D(int dim1, int dim2, ...)
{
    int i; int j;
    void ***array = ((void *)0);
    __builtin_va_list ap;
    __builtin_va_start(ap,dim2);
    array=__builtin_va_arg(ap,void***);
    while(array!=((void *)0))
    {
        for(i=0; i<dim1; i++)
        {
            for(j=0; j<dim2; j++)
                free(array[i][j]);
            free(array[i]);
        }
        free(array);
        array=((void *)0);
        array=__builtin_va_arg(ap,void***);
    }
    __builtin_va_end(ap);
}

variable_types: j int

variable_types:
array
void ***


numforce

decompiled_code:
unsigned __int64 __fastcall numforce(double a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, int a8, int a9, int a10, int a11, double *a12, double *a13, double *a14, double *a15, unsigned int a16)
{
double *v17; // rdi
double *v18; // rsi
double *v19; // rcx
unsigned __int64 result; // rax
double v21; // xmm4_8
double *v22; // r8
double v23; // xmm2_8
double v24; // xmm5_8
double v25; // xmm2_8
double v26; // xmm5_8
double v27; // xmm2_8
double v28; // xmm5_8
double v29; // xmm2_8
double v30; // xmm5_8
int v31; // er8
double v32; // xmm6_8
double v33; // xmm8_8
double v34; // xmm7_8
double v35; // xmm1_8
double v36; // xmm6_8
double v37; // xmm8_8
double v38; // xmm7_8
double v39; // xmm1_8
double v40; // xmm6_8
double v41; // xmm8_8
double v42; // xmm7_8
double v43; // xmm1_8
double v44; // xmm3_8
double v45; // xmm2_8
double v46; // xmm7_8
int v47; // er8
double v48; // xmm8_8
double v49; // xmm10_8
double v50; // xmm11_8
double v51; // xmm12_8
double v52; // xmm1_8
double v53; // xmm9_8
double v54; // xmm8_8
double v55; // xmm10_8
double v56; // xmm11_8
double v57; // xmm12_8
double v58; // xmm1_8
double v59; // xmm9_8
double v60; // xmm8_8
double v61; // xmm10_8
double v62; // xmm11_8
double v63; // xmm12_8
double v64; // xmm1_8
double v65; // xmm9_8

v17 = a13;
v18 = a14;
v19 = a15;
result = a16;
if ( a16 == 2 )
{
if ( *(int *)(a3 + 24) > 0 )
{
v21 = a1 + a1;
v22 = a12;
result = 0LL;
do
{
v23 = a13[result];
a13[result] = v23 - a1;
v24 = *(double *)(a4 + 8);
a13[result] = a1 + v23;
*v22 = COERCE_DOUBLE(COERCE_UNSIGNED_INT64(*(double *)(a4 + 8) - v24) ^ LC0) / v21;
a13[result] = v23;
v25 = a14[result];
a14[result] = v25 - a1;
v26 = *(double *)(a4 + 8);
a14[result] = a1 + v25;
v22[1] = COERCE_DOUBLE(COERCE_UNSIGNED_INT64(*(double *)(a4 + 8) - v26) ^ LC0) / v21;
a14[result] = v25;
v27 = a15[result];
a15[result] = v27 - a1;
v28 = *(double *)(a4 + 8);
a15[result] = a1 + v27;
v22[2] = COERCE_DOUBLE(COERCE_UNSIGNED_INT64(*(double *)(a4 + 8) - v28) ^ LC0) / v21;
a15[result++] = v27;
v22 += 3;
}
while ( *(_DWORD *)(a3 + 24) > (int)result );
}
}
else if ( a16 == 4 )
{
if ( *(int *)(a3 + 24) > 0 )
{
v29 = a1 + a1;
v30 = a1 * 12.0;
result = (unsigned __int64)a12;
v31 = 0;
do
{
v32 = *v17;
*v17 = *v17 - v29;
v33 = *(double *)(a4 + 8);
*v17 = v32 - a1;
v34 = *(double *)(a4 + 8);
*v17 = a1 + v32;
v35 = *(double *)(a4 + 8);
*v17 = v29 + v32;
*(double *)result = COERCE_DOUBLE(COERCE_UNSIGNED_INT64((v35 - v34) * 8.0 - (*(double *)(a4 + 8) - v33)) ^ LC0)
/ v30;
*v17 = v32;
v36 = *v18;
*v18 = *v18 - v29;
v37 = *(double *)(a4 + 8);
*v18 = v36 - a1;
v38 = *(double *)(a4 + 8);
*v18 = a1 + v36;
v39 = *(double *)(a4 + 8);
*v18 = v29 + v36;
*(double *)(result + 8) = COERCE_DOUBLE(COERCE_UNSIGNED_INT64((v39 - v38) * 8.0 - (*(double *)(a4 + 8) - v37)) ^ LC0)
/ v30;
*v18 = v36;
v40 = *v19;
*v19 = *v19 - v29;
v41 = *(double *)(a4 + 8);
*v19 = v40 - a1;
v42 = *(double *)(a4 + 8);
*v19 = a1 + v40;
v43 = *(double *)(a4 + 8);
*v19 = v29 + v40;
*(double *)(result + 16) = COERCE_DOUBLE(COERCE_UNSIGNED_INT64((v43 - v42) * 8.0 - (*(double *)(a4 + 8) - v41)) ^ LC0)
/ v30;
*v19 = v40;
++v31;
++v17;
result += 24LL;
++v18;
++v19;
}
while ( *(_DWORD *)(a3 + 24) > v31 );
}
}
else if ( a16 == 6 && *(int *)(a3 + 24) > 0 )
{
v44 = a1 * 3.0;
v45 = a1 + a1;
v46 = a1 * 60.0;
result = (unsigned __int64)a12;
v47 = 0;
do
{
v48 = *v17;
*v17 = *v17 - v44;
v49 = *(double *)(a4 + 8);
*v17 = v48 - v45;
v50 = *(double *)(a4 + 8);
*v17 = v48 - a1;
v51 = *(double *)(a4 + 8);
*v17 = v48 + a1;
v52 = *(double *)(a4 + 8);
*v17 = v45 + v48;
v53 = *(double *)(a4 + 8);
*v17 = v44 + v48;
*(double *)result = COERCE_DOUBLE(COERCE_UNSIGNED_INT64((v52 - v51) * 45.0 - (v53 - v50) * 9.0 + *(double *)(a4 + 8) - v49) ^ LC0)
/ v46;
*v17 = v48;
v54 = *v18;
*v18 = *v18 - v44;
v55 = *(double *)(a4 + 8);
*v18 = v54 - v45;
v56 = *(double *)(a4 + 8);
*v18 = v54 - a1;
v57 = *(double *)(a4 + 8);
*v18 = a1 + v54;
v58 = *(double *)(a4 + 8);
*v18 = v45 + v54;
v59 = *(double *)(a4 + 8);
*v18 = v44 + v54;
*(double *)(result + 8) = COERCE_DOUBLE(COERCE_UNSIGNED_INT64((v58 - v57) * 45.0 - (v59 - v56) * 9.0 + *(double *)(a4 + 8) - v55) ^ LC0)
/ v46;
*v18 = v54;
v60 = *v19;
*v19 = *v19 - v44;
v61 = *(double *)(a4 + 8);
*v19 = v60 - v45;
v62 = *(double *)(a4 + 8);
*v19 = v60 - a1;
v63 = *(double *)(a4 + 8);
*v19 = a1 + v60;
v64 = *(double *)(a4 + 8);
*v19 = v45 + v60;
v65 = *(double *)(a4 + 8);
*v19 = v44 + v60;
*(double *)(result + 16) = COERCE_DOUBLE(COERCE_UNSIGNED_INT64((v64 - v63) * 45.0 - (v65 - v62) * 9.0 + *(double *)(a4 + 8) - v61) ^ LC0)
/ v46;
*v19 = v60;
++v47;
++v17;
result += 24LL;
++v18;
++v19;
}
while ( *(_DWORD *)(a3 + 24) > v47 );
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func0(double a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, int a8, int a9, int a10, int a11, double *a12, double *a13, double *a14, double *a15, unsigned int a16)
{
double *v17; // rdi
double *v18; // rsi
double *v19; // rcx
unsigned __int64 result; // rax
double v21; // xmm4_8
double *v22; // r8
double v23; // xmm2_8
double v24; // xmm5_8
double v25; // xmm2_8
double v26; // xmm5_8
double v27; // xmm2_8
double v28; // xmm5_8
double v29; // xmm2_8
double v30; // xmm5_8
int v31; // er8
double v32; // xmm6_8
double v33; // xmm8_8
double v34; // xmm7_8
double v35; // xmm1_8
double v36; // xmm6_8
double v37; // xmm8_8
double v38; // xmm7_8
double v39; // xmm1_8
double v40; // xmm6_8
double v41; // xmm8_8
double v42; // xmm7_8
double v43; // xmm1_8
double v44; // xmm3_8
double v45; // xmm2_8
double v46; // xmm7_8
int v47; // er8
double v48; // xmm8_8
double v49; // xmm10_8
double v50; // xmm11_8
double v51; // xmm12_8
double v52; // xmm1_8
double v53; // xmm9_8
double v54; // xmm8_8
double v55; // xmm10_8
double v56; // xmm11_8
double v57; // xmm12_8
double v58; // xmm1_8
double v59; // xmm9_8
double v60; // xmm8_8
double v61; // xmm10_8
double v62; // xmm11_8
double v63; // xmm12_8
double v64; // xmm1_8
double v65; // xmm9_8

v17 = a13;
v18 = a14;
v19 = a15;
result = a16;
if ( a16 == 2 )
{
if ( *(int *)(a3 + 24) > 0 )
{
v21 = a1 + a1;
v22 = a12;
result = 0LL;
do
{
v23 = a13[result];
a13[result] = v23 - a1;
v24 = *(double *)(a4 + 8);
a13[result] = a1 + v23;
*v22 = COERCE_DOUBLE(COERCE_UNSIGNED_INT64(*(double *)(a4 + 8) - v24) ^ LC0) / v21;
a13[result] = v23;
v25 = a14[result];
a14[result] = v25 - a1;
v26 = *(double *)(a4 + 8);
a14[result] = a1 + v25;
v22[1] = COERCE_DOUBLE(COERCE_UNSIGNED_INT64(*(double *)(a4 + 8) - v26) ^ LC0) / v21;
a14[result] = v25;
v27 = a15[result];
a15[result] = v27 - a1;
v28 = *(double *)(a4 + 8);
a15[result] = a1 + v27;
v22[2] = COERCE_DOUBLE(COERCE_UNSIGNED_INT64(*(double *)(a4 + 8) - v28) ^ LC0) / v21;
a15[result++] = v27;
v22 += 3;
}
while ( *(_DWORD *)(a3 + 24) > (int)result );
}
}
else if ( a16 == 4 )
{
if ( *(int *)(a3 + 24) > 0 )
{
v29 = a1 + a1;
v30 = a1 * 12.0;
result = (unsigned __int64)a12;
v31 = 0;
do
{
v32 = *v17;
*v17 = *v17 - v29;
v33 = *(double *)(a4 + 8);
*v17 = v32 - a1;
v34 = *(double *)(a4 + 8);
*v17 = a1 + v32;
v35 = *(double *)(a4 + 8);
*v17 = v29 + v32;
*(double *)result = COERCE_DOUBLE(COERCE_UNSIGNED_INT64((v35 - v34) * 8.0 - (*(double *)(a4 + 8) - v33)) ^ LC0)
/ v30;
*v17 = v32;
v36 = *v18;
*v18 = *v18 - v29;
v37 = *(double *)(a4 + 8);
*v18 = v36 - a1;
v38 = *(double *)(a4 + 8);
*v18 = a1 + v36;
v39 = *(double *)(a4 + 8);
*v18 = v29 + v36;
*(double *)(result + 8) = COERCE_DOUBLE(COERCE_UNSIGNED_INT64((v39 - v38) * 8.0 - (*(double *)(a4 + 8) - v37)) ^ LC0)
/ v30;
*v18 = v36;
v40 = *v19;
*v19 = *v19 - v29;
v41 = *(double *)(a4 + 8);
*v19 = v40 - a1;
v42 = *(double *)(a4 + 8);
*v19 = a1 + v40;
v43 = *(double *)(a4 + 8);
*v19 = v29 + v40;
*(double *)(result + 16) = COERCE_DOUBLE(COERCE_UNSIGNED_INT64((v43 - v42) * 8.0 - (*(double *)(a4 + 8) - v41)) ^ LC0)
/ v30;
*v19 = v40;
++v31;
++v17;
result += 24LL;
++v18;
++v19;
}
while ( *(_DWORD *)(a3 + 24) > v31 );
}
}
else if ( a16 == 6 && *(int *)(a3 + 24) > 0 )
{
v44 = a1 * 3.0;
v45 = a1 + a1;
v46 = a1 * 60.0;
result = (unsigned __int64)a12;
v47 = 0;
do
{
v48 = *v17;
*v17 = *v17 - v44;
v49 = *(double *)(a4 + 8);
*v17 = v48 - v45;
v50 = *(double *)(a4 + 8);
*v17 = v48 - a1;
v51 = *(double *)(a4 + 8);
*v17 = v48 + a1;
v52 = *(double *)(a4 + 8);
*v17 = v45 + v48;
v53 = *(double *)(a4 + 8);
*v17 = v44 + v48;
*(double *)result = COERCE_DOUBLE(COERCE_UNSIGNED_INT64((v52 - v51) * 45.0 - (v53 - v50) * 9.0 + *(double *)(a4 + 8) - v49) ^ LC0)
/ v46;
*v17 = v48;
v54 = *v18;
*v18 = *v18 - v44;
v55 = *(double *)(a4 + 8);
*v18 = v54 - v45;
v56 = *(double *)(a4 + 8);
*v18 = v54 - a1;
v57 = *(double *)(a4 + 8);
*v18 = a1 + v54;
v58 = *(double *)(a4 + 8);
*v18 = v45 + v54;
v59 = *(double *)(a4 + 8);
*v18 = v44 + v54;
*(double *)(result + 8) = COERCE_DOUBLE(COERCE_UNSIGNED_INT64((v58 - v57) * 45.0 - (v59 - v56) * 9.0 + *(double *)(a4 + 8) - v55) ^ LC0)
/ v46;
*v18 = v54;
v60 = *v19;
*v19 = *v19 - v44;
v61 = *(double *)(a4 + 8);
*v19 = v60 - v45;
v62 = *(double *)(a4 + 8);
*v19 = v60 - a1;
v63 = *(double *)(a4 + 8);
*v19 = a1 + v60;
v64 = *(double *)(a4 + 8);
*v19 = v45 + v60;
v65 = *(double *)(a4 + 8);
*v19 = v44 + v60;
*(double *)(result + 16) = COERCE_DOUBLE(COERCE_UNSIGNED_INT64((v64 - v63) * 45.0 - (v65 - v62) * 9.0 + *(double *)(a4 + 8) - v61) ^ LC0)
/ v46;
*v19 = v60;
++v47;
++v17;
result += 24LL;
++v18;
++v19;
}
while ( *(_DWORD *)(a3 + 24) > v47 );
}
return result;
}

original_code:
void numforce(CTRL *ctrl,PARAM *param,ENERGY *ener,PBC *box,NEIGH *neigh,
       BOND bond[],BOND ub[],ANGLE angle[],DIHE dihe[],DIHE impr[],
       DELTA nForce[],double x[],double y[],double z[],int npoints,double h)
{
  int i;
  double coord;
  if(npoints==2)
  {
    double a,b;
    for(i=0;i<param->nAtom;i++)
    {
      coord=x[i];
      x[i]=coord-h;
      a=ener->pot;
      x[i]=coord+h;
      b=ener->pot;
      nForce[i].x=-(b-a)/(2.*h);
      x[i]=coord;
      coord=y[i];
      y[i]=coord-h;
      a=ener->pot;
      y[i]=coord+h;
      b=ener->pot;
      nForce[i].y=-(b-a)/(2.*h);
      y[i]=coord;
      coord=z[i];
      z[i]=coord-h;
      a=ener->pot;
      z[i]=coord+h;
      b=ener->pot;
      nForce[i].z=-(b-a)/(2.*h);
      z[i]=coord;
    }
  }
  else if(npoints==4)
  {
    double a,b,c,d;
    for(i=0;i<param->nAtom;i++)
    {
      coord=x[i];
      x[i]=coord-(2.*h);
      a=ener->pot;
      x[i]=coord-h;
      b=ener->pot;
      x[i]=coord+h;
      c=ener->pot;
      x[i]=coord+(2.*h);
      d=ener->pot;
      nForce[i].x=-(8.*(c-b)-(d-a))/(12.*h);
      x[i]=coord;
      coord=y[i];
      y[i]=coord-(2.*h);
      a=ener->pot;
      y[i]=coord-h;
      b=ener->pot;
      y[i]=coord+h;
      c=ener->pot;
      y[i]=coord+(2.*h);
      d=ener->pot;
      nForce[i].y=-(8.*(c-b)-(d-a))/(12.*h);
      y[i]=coord;
      coord=z[i];
      z[i]=coord-(2.*h);
      a=ener->pot;
      z[i]=coord-h;
      b=ener->pot;
      z[i]=coord+h;
      c=ener->pot;
      z[i]=coord+(2.*h);
      d=ener->pot;
      nForce[i].z=-(8.*(c-b)-(d-a))/(12.*h);
      z[i]=coord;
    }
  }
  else if(npoints==6)
  {
    double a,b,c,d,e,f;
    for(i=0;i<param->nAtom;i++)
    {
      coord=x[i];
      x[i]=coord-(3.*h);
      a=ener->pot;
      x[i]=coord-(2.*h);
      b=ener->pot;
      x[i]=coord-h;
      c=ener->pot;
      x[i]=coord+h;
      d=ener->pot;
      x[i]=coord+(2.*h);
      e=ener->pot;
      x[i]=coord+(3.*h);
      f=ener->pot;
      nForce[i].x=-(45.*(d-c)-9.*(e-b)+(f-a))/(60.*h);
      x[i]=coord;
      coord=y[i];
      y[i]=coord-(3.*h);
      a=ener->pot;
      y[i]=coord-(2.*h);
      b=ener->pot;
      y[i]=coord-h;
      c=ener->pot;
      y[i]=coord+h;
      d=ener->pot;
      y[i]=coord+(2.*h);
      e=ener->pot;
      y[i]=coord+(3.*h);
      f=ener->pot;
      nForce[i].y=-(45.*(d-c)-9.*(e-b)+(f-a))/(60.*h);
      y[i]=coord;
      coord=z[i];
      z[i]=coord-(3.*h);
      a=ener->pot;
      z[i]=coord-(2.*h);
      b=ener->pot;
      z[i]=coord-h;
      c=ener->pot;
      z[i]=coord+h;
      d=ener->pot;
      z[i]=coord+(2.*h);
      e=ener->pot;
      z[i]=coord+(3.*h);
      f=ener->pot;
      nForce[i].z=-(45.*(d-c)-9.*(e-b)+(f-a))/(60.*h);
      z[i]=coord;
    }
  }
}

canonical_original_code:
void numforce(struct CTRL *ctrl, struct PARAM *param, struct ENERGY *ener, struct PBC *box, struct NEIGH *neigh, struct BOND bond[], struct BOND ub[], struct ANGLE angle[], struct DIHE dihe[], struct DIHE impr[], struct DELTA nForce[], double x[], double y[], double z[], int npoints, double h)
{
  int i;
  double coord;
  if(npoints==2)
  {
    double a; double b;
    for(i=0;i<param->nAtom;i++)
    {
      coord=x[i];
      x[i]=coord-h;
      a=ener->pot;
      x[i]=coord+h;
      b=ener->pot;
      nForce[i].x=-(b-a)/(2.*h);
      x[i]=coord;
      coord=y[i];
      y[i]=coord-h;
      a=ener->pot;
      y[i]=coord+h;
      b=ener->pot;
      nForce[i].y=-(b-a)/(2.*h);
      y[i]=coord;
      coord=z[i];
      z[i]=coord-h;
      a=ener->pot;
      z[i]=coord+h;
      b=ener->pot;
      nForce[i].z=-(b-a)/(2.*h);
      z[i]=coord;
    }
  }
  else if(npoints==4)
  {
    double a; double b; double c; double d;
    for(i=0;i<param->nAtom;i++)
    {
      coord=x[i];
      x[i]=coord-(2.*h);
      a=ener->pot;
      x[i]=coord-h;
      b=ener->pot;
      x[i]=coord+h;
      c=ener->pot;
      x[i]=coord+(2.*h);
      d=ener->pot;
      nForce[i].x=-(8.*(c-b)-(d-a))/(12.*h);
      x[i]=coord;
      coord=y[i];
      y[i]=coord-(2.*h);
      a=ener->pot;
      y[i]=coord-h;
      b=ener->pot;
      y[i]=coord+h;
      c=ener->pot;
      y[i]=coord+(2.*h);
      d=ener->pot;
      nForce[i].y=-(8.*(c-b)-(d-a))/(12.*h);
      y[i]=coord;
      coord=z[i];
      z[i]=coord-(2.*h);
      a=ener->pot;
      z[i]=coord-h;
      b=ener->pot;
      z[i]=coord+h;
      c=ener->pot;
      z[i]=coord+(2.*h);
      d=ener->pot;
      nForce[i].z=-(8.*(c-b)-(d-a))/(12.*h);
      z[i]=coord;
    }
  }
  else if(npoints==6)
  {
    double a; double b; double c; double d; double e; double f;
    for(i=0;i<param->nAtom;i++)
    {
      coord=x[i];
      x[i]=coord-(3.*h);
      a=ener->pot;
      x[i]=coord-(2.*h);
      b=ener->pot;
      x[i]=coord-h;
      c=ener->pot;
      x[i]=coord+h;
      d=ener->pot;
      x[i]=coord+(2.*h);
      e=ener->pot;
      x[i]=coord+(3.*h);
      f=ener->pot;
      nForce[i].x=-(45.*(d-c)-9.*(e-b)+(f-a))/(60.*h);
      x[i]=coord;
      coord=y[i];
      y[i]=coord-(3.*h);
      a=ener->pot;
      y[i]=coord-(2.*h);
      b=ener->pot;
      y[i]=coord-h;
      c=ener->pot;
      y[i]=coord+h;
      d=ener->pot;
      y[i]=coord+(2.*h);
      e=ener->pot;
      y[i]=coord+(3.*h);
      f=ener->pot;
      nForce[i].y=-(45.*(d-c)-9.*(e-b)+(f-a))/(60.*h);
      y[i]=coord;
      coord=z[i];
      z[i]=coord-(3.*h);
      a=ener->pot;
      z[i]=coord-(2.*h);
      b=ener->pot;
      z[i]=coord-h;
      c=ener->pot;
      z[i]=coord+h;
      d=ener->pot;
      z[i]=coord+(2.*h);
      e=ener->pot;
      z[i]=coord+(3.*h);
      f=ener->pot;
      nForce[i].z=-(45.*(d-c)-9.*(e-b)+(f-a))/(60.*h);
      z[i]=coord;
    }
  }
}

variable_types: struct DIHE { enum DIHE_TYPE { DCOS=1, DHARM=2 } type; int order; int a; double k; } []

variable_types:
impr
struct DIHE []

variable_types:
nForce
struct DELTA { double x; } []

variable_types:
x
double []

variable_types:
y
double []

variable_types:
z
double []

variable_types: npoints int

variable_types: h double

variable_types: i int

variable_types: coord double

variable_types: a double

variable_types: b double

variable_types: c double

variable_types: d double

variable_types: e double

variable_types: f double


decompiled_code:
__int64 __fastcall init_rand(unsigned int a1)
{
return dsfmt_chk_init_gen_rand(&dsfmt, a1, 19937LL);
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1)
{
return dsfmt_chk_init_gen_rand(&dsfmt, a1, 19937LL);
}

original_code:
void init_rand(unsigned int seed)
{
  dsfmt_init_gen_rand(&dsfmt,seed);
}

variable_types:
seed
unsigned int


decompiled_code:
double get_rand()
{
int v0; // eax

if ( dword_D60 > 381 )
{
dsfmt_gen_rand_all(dsfmt);
dword_D60 = 0;
}
v0 = dword_D60++;
return COERCE_DOUBLE(dsfmt[v0] | 1) - 1.0;
}

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

if ( dword_D60 > 381 )
{
dsfmt_gen_rand_all(dsfmt);
dword_D60 = 0;
}
v0 = dword_D60++;
return COERCE_DOUBLE(dsfmt[v0] | 1) - 1.0;
}

original_code:
double get_rand()
{
  return dsfmt_genrand_open_open(&dsfmt);
}


decompiled_code:
void __fastcall get_BoxMuller(double *a1, double *a2)
{
double v2; // xmm0_8
double v3; // xmm0_8
double v4; // xmm1_8
double v5; // xmm0_8
double v6; // xmm0_8
double v7; // xmm0_8
double v8; // xmm0_8
double v9; // [rsp+8h] [rbp-30h]
double v10; // [rsp+18h] [rbp-20h]

do
{
v2 = get_rand();
v9 = v2 + v2 - 1.0;
v3 = get_rand();
v10 = v3 + v3 - 1.0;
v4 = v9 * v9 + v10 * v10;
}
while ( v4 >= 1.0 );
v5 = log(v4) * -2.0 / v4;
if ( v5 < 0.0 )
v6 = sqrt(v5);
else
v6 = sqrt(v5);
*a1 = v6 * v9;
v7 = log(v4) * -2.0 / v4;
if ( v7 < 0.0 )
v8 = sqrt(v7);
else
v8 = sqrt(v7);
*a2 = v8 * v10;
}

original_code:
void get_BoxMuller(double *u, double *v)
{
  double a,b,s;
  do
  {
      a = 2. * get_rand() - 1.;
      b = 2. * get_rand() - 1.;
      s = a*a + b*b;
  }while (s >= 1.);
  *u= a*sqrt(-2.*log(s)/s);
  *v= b*sqrt(-2.*log(s)/s);
}

canonical_original_code:
void get_BoxMuller(double *u, double *v)
{
  double a; double b; double s;
  do
  {
      a = 2. * get_rand() - 1.;
      b = 2. * get_rand() - 1.;
      s = a*a + b*b;
  }while (s >= 1.);
  *u= a*sqrt(-2.*log(s)/s);
  *v= b*sqrt(-2.*log(s)/s);
}

variable_types:
u
double *

variable_types:
v
double *

variable_types: s double


loadUserPlugin

decompiled_code:
__int64 __fastcall loadUserPlugin(const char *a1, const char *a2)
{
plugin = 0LL;
fnc = 0LL;
plugin = dlopen(a1, 1);
if ( !plugin )
my_error(414LL, "src/user.c", 27LL, 2LL, "loadUserPlugin", a1);
fnc = (__int64)dlsym(plugin, a2);
if ( !fnc )
my_error(415LL, "src/user.c", 32LL, 3LL, "loadUserPlugin", a1);
return fnc;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1, const char *a2)
{
plugin = 0LL;
fnc = 0LL;
plugin = dlopen(a1, 1);
if ( !plugin )
my_error(414LL, "src/user.c", 27LL, 2LL, "loadUserPlugin", a1);
fnc = (__int64)dlsym(plugin, a2);
if ( !fnc )
my_error(415LL, "src/user.c", 32LL, 3LL, "loadUserPlugin", a1);
return fnc;
}

original_code:
UserEnergyPtr loadUserPlugin(const char pluginName[], const char funcName[])
{
    plugin = ((void *)0);
    fnc = ((void *)0);
    plugin = dlopen(pluginName, 0x00001);
    if(plugin==((void *)0))
        my_error(PLUGINS_DLOPEN_ERROR,"src/user.c",27,2,__func__,pluginName);
    fnc = dlsym(plugin,funcName);
    if(fnc==((void *)0))
        my_error(PLUGINS_DLSYM_ERROR,"src/user.c",32,3,__func__,pluginName,funcName);
    UserEnergyPtr eneCustom = (UserEnergyPtr) fnc;
    return eneCustom;
}

canonical_original_code:
double (*loadUserPlugin(char pluginName[], char funcName[]))(struct PARAM *param, struct PBC *box, double x[], double y[], double z[], double fx[], double fy[], double fz[], int neighList[], int neighPair[], int neighOrder[], int neighList14[])
{
    plugin = ((void *)0);
    fnc = ((void *)0);
    plugin = dlopen(pluginName, 0x00001);
    if(plugin==((void *)0))
        my_error(PLUGINS_DLOPEN_ERROR,"src/user.c",27,2,__func__,pluginName);
    fnc = dlsym(plugin,funcName);
    if(fnc==((void *)0))
        my_error(PLUGINS_DLSYM_ERROR,"src/user.c",32,3,__func__,pluginName,funcName);
    double (*eneCustom)(struct PARAM *param, struct PBC *box, double x[], double y[], double z[], double fx[], double fy[], double fz[], int neighList[], int neighPair[], int neighOrder[], int neighList14[]) = (UserEnergyPtr) fnc;
    return eneCustom;
}

variable_types:
pluginName
char []

variable_types:
funcName
char []

variable_types: double (*)(struct PARAM { int step; double timeStep; int nAtom; int nBond; int nConst; double tolShake; double chargeConst; double cutOff; double cutOn; double temp0; double tolMinim; } *param, struct PBC { enum BOX_TYPE { NOBOX=0, CUBIC=1, ORBIC=2, TCLIN=3 } type; double a; double u; double pa; double stress1; double stress4; double stress7; } *box, double x[], double y[], double z[], double fx[], double fy[], double fz[], int neighList[], int neighPair[], int neighOrder[], int neighList14[])


closeUserPlugin

decompiled_code:
int closeUserPlugin()
{
return dlclose(plugin);
}

canonical_decompiled_code:
int func1()
{
return dlclose(plugin);
}

original_code:
void closeUserPlugin(void)
{
    int err = dlclose(plugin);
}

canonical_original_code:
void closeUserPlugin()
{
    int err = dlclose(plugin);
}

variable_types: err int


MyEnergyFunction

decompiled_code:
double MyEnergyFunction()
{
puts("Hello from my Plugin !");
return 0.0;
}

canonical_decompiled_code:
double func6()
{
puts("Hello from my Plugin !");
return 0.0;
}

original_code:
double MyEnergyFunction (const PARAM *param, const PBC *box,
                const double x[], const double y[], const double z[],
                double fx[], double fy[], double fz[],
                const int neighList[], const int neighPair[], const int neighOrder[],
                const int neighList14[])
{
    puts("Hello from my Plugin !");
    return 0.0;
}

canonical_original_code:
double MyEnergyFunction(struct PARAM *param, struct PBC *box, double x[], double y[], double z[], double fx[], double fy[], double fz[], int neighList[], int neighPair[], int neighOrder[], int neighList14[])
{
    puts("Hello from my Plugin !");
    return 0.0;
}

variable_types: struct PARAM { int step; double timeStep; int nAtom; int nBond; int nConst; double tolShake; double chargeConst; double cutOff; double cutOn; double temp0; double tolMinim; } *

variable_types: struct PBC { enum BOX_TYPE { NOBOX=0, CUBIC=1, ORBIC=2, TCLIN=3 } type; double a; double u; double pa; double stress1; double stress4; double stress7; } *

variable_types:
x
double []

variable_types:
y
double []

variable_types:
z
double []

variable_types:
fx
double []

variable_types:
fy
double []

variable_types:
fz
double []

variable_types:
neighList
int []

variable_types:
neighPair
int []

variable_types:
neighOrder
int []


repo: pcercuei/glfrontier

decompiled_code:
__int64 __fastcall parent_side(__int64 *a1)
{
__int64 v1; // rax

v1 = *a1;
if ( !*a1 )
return 0xFFFFFFFFLL;
if ( *(__int64 **)(v1 + 8) == a1 )
return 0LL;
return (unsigned int)(*(_QWORD *)(v1 + 16) != (_QWORD)a1) + 1;
}

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

v1 = *a1;
if ( !*a1 )
return 0xFFFFFFFFLL;
if ( *(__int64 **)(v1 + 8) == a1 )
return 0LL;
return (unsigned int)(*(_QWORD *)(v1 + 16) != (_QWORD)a1) + 1;
}

original_code:
static int parent_side (const struct Node *node)
{
 if (node->parent == ((void *)0))
  return -1;
 else if (node->parent->child[0] == node)
  return 0;
 else if (node->parent->child[1] == node)
  return 1;
 else
  return 2;
}

canonical_original_code:
static int parent_side(struct Node *node)
{
 if (node->parent == ((void *)0))
  return -1;
 else if (node->parent->child[0] == node)
  return 0;
 else if (node->parent->child[1] == node)
  return 1;
 else
  return 2;
}

variable_types: struct Node { struct Node *parent; struct Node *child[2]; char balance; char *key; void *obj; } *

return_type: int


original_code:
static struct Node *balance_node (struct Dict *tree, struct Node *high)
{
 struct Node *mid = ((void *)0);
 struct Node *low = ((void *)0);
 if ((high->balance == +2) && (high->child[1]->balance >= 0)) {
  mid = high->child[1];
  low = mid->child[1];
  mid->parent = high->parent;
  switch (parent_side (high)) {
   case -1: tree->root = mid; break;
   case 0: mid->parent->child[0] = mid; break;
   case 1: mid->parent->child[1] = mid; break;
  }
  high->child[1] = mid->child[0];
  if (mid->child[0]) mid->child[0]->parent = high;
  mid->child[0] = high;
  high->parent = mid;
  high->balance = high->balance - 1 - ((mid->balance)>(0) ? (mid->balance) : (0));
  mid->balance = mid->balance - 1 + ((high->balance)<(0) ? (high->balance) : (0));
  return mid;
 }
 else if ((high->balance == -2) && (high->child[0]->balance <= 0)) {
  mid = high->child[0];
  low = mid->child[0];
  mid->parent = high->parent;
  switch (parent_side (high)) {
   case -1: tree->root = mid; break;
   case 0: mid->parent->child[0] = mid; break;
   case 1: mid->parent->child[1] = mid; break;
  }
  high->child[0] = mid->child[1];
  if (mid->child[1]) mid->child[1]->parent = high;
  mid->child[1] = high;
  high->parent = mid;
  high->balance = high->balance + 1 - ((mid->balance)<(0) ? (mid->balance) : (0));
  mid->balance = mid->balance + 1 + ((high->balance)>(0) ? (high->balance) : (0));
  return mid;
 }
 else if ((high->balance == +2) && (high->child[1]->balance == -1)) {
  mid = high->child[1];
  low = mid->child[0];
  low->parent = high->parent;
  switch (parent_side (high)) {
   case -1: tree->root = low; break;
   case 0: low->parent->child[0] = low; break;
   case 1: low->parent->child[1] = low; break;
  }
  high->child[1] = low->child[0];
  if (low->child[0]) low->child[0]->parent = high;
  mid->child[0] = low->child[1];
  if (low->child[1]) low->child[1]->parent = mid;
  low->child[0] = high;
  high->parent = low;
  low->child[1] = mid;
  mid->parent = low;
  high->balance = -((low->balance)>(0) ? (low->balance) : (0));
  mid->balance = -((low->balance)<(0) ? (low->balance) : (0));
  low->balance = 0;
  return low;
 }
 else if ((high->balance == -2) && (high->child[0]->balance == +1)) {
  mid = high->child[0];
  low = mid->child[1];
  low->parent = high->parent;
  switch (parent_side (high)) {
   case -1: tree->root = low; break;
   case 0: low->parent->child[0] = low; break;
   case 1: low->parent->child[1] = low; break;
  }
  high->child[0] = low->child[1];
  if (low->child[1]) low->child[1]->parent = high;
  mid->child[1] = low->child[0];
  if (low->child[0]) low->child[0]->parent = mid;
  low->child[1] = high;
  high->parent = low;
  low->child[0] = mid;
  mid->parent = low;
  high->balance = -((low->balance)<(0) ? (low->balance) : (0));
  mid->balance = -((low->balance)>(0) ? (low->balance) : (0));
  low->balance = 0;
  return low;
 } else {
  ((void) sizeof (("This shouldn't happen in balance_node()") ? 1 : 0), __extension__ ({ if ("This shouldn't happen in balance_node()") ; else __assert_fail ("\"This shouldn't happen in balance_node()\"", "dict.c", 194, __extension__ __PRETTY_FUNCTION__); }));
  return ((void *)0);
 }
}

canonical_original_code:
static struct Node *balance_node(struct Dict *tree, struct Node *high)
{
 struct Node *mid = ((void *)0);
 struct Node *low = ((void *)0);
 if ((high->balance == +2) && (high->child[1]->balance >= 0)) {
  mid = high->child[1];
  low = mid->child[1];
  mid->parent = high->parent;
  switch (parent_side (high)) {
   case -1: tree->root = mid; break;
   case 0: mid->parent->child[0] = mid; break;
   case 1: mid->parent->child[1] = mid; break;
  }
  high->child[1] = mid->child[0];
  if (mid->child[0]) mid->child[0]->parent = high;
  mid->child[0] = high;
  high->parent = mid;
  high->balance = high->balance - 1 - ((mid->balance)>(0) ? (mid->balance) : (0));
  mid->balance = mid->balance - 1 + ((high->balance)<(0) ? (high->balance) : (0));
  return mid;
 }
 else if ((high->balance == -2) && (high->child[0]->balance <= 0)) {
  mid = high->child[0];
  low = mid->child[0];
  mid->parent = high->parent;
  switch (parent_side (high)) {
   case -1: tree->root = mid; break;
   case 0: mid->parent->child[0] = mid; break;
   case 1: mid->parent->child[1] = mid; break;
  }
  high->child[0] = mid->child[1];
  if (mid->child[1]) mid->child[1]->parent = high;
  mid->child[1] = high;
  high->parent = mid;
  high->balance = high->balance + 1 - ((mid->balance)<(0) ? (mid->balance) : (0));
  mid->balance = mid->balance + 1 + ((high->balance)>(0) ? (high->balance) : (0));
  return mid;
 }
 else if ((high->balance == +2) && (high->child[1]->balance == -1)) {
  mid = high->child[1];
  low = mid->child[0];
  low->parent = high->parent;
  switch (parent_side (high)) {
   case -1: tree->root = low; break;
   case 0: low->parent->child[0] = low; break;
   case 1: low->parent->child[1] = low; break;
  }
  high->child[1] = low->child[0];
  if (low->child[0]) low->child[0]->parent = high;
  mid->child[0] = low->child[1];
  if (low->child[1]) low->child[1]->parent = mid;
  low->child[0] = high;
  high->parent = low;
  low->child[1] = mid;
  mid->parent = low;
  high->balance = -((low->balance)>(0) ? (low->balance) : (0));
  mid->balance = -((low->balance)<(0) ? (low->balance) : (0));
  low->balance = 0;
  return low;
 }
 else if ((high->balance == -2) && (high->child[0]->balance == +1)) {
  mid = high->child[0];
  low = mid->child[1];
  low->parent = high->parent;
  switch (parent_side (high)) {
   case -1: tree->root = low; break;
   case 0: low->parent->child[0] = low; break;
   case 1: low->parent->child[1] = low; break;
  }
  high->child[0] = low->child[1];
  if (low->child[1]) low->child[1]->parent = high;
  mid->child[1] = low->child[0];
  if (low->child[0]) low->child[0]->parent = mid;
  low->child[1] = high;
  high->parent = low;
  low->child[0] = mid;
  mid->parent = low;
  high->balance = -((low->balance)<(0) ? (low->balance) : (0));
  mid->balance = -((low->balance)>(0) ? (low->balance) : (0));
  low->balance = 0;
  return low;
 } else {
  ((void) sizeof (("This shouldn't happen in balance_node()") ? 1 : 0), __extension__ ({ if ("This shouldn't happen in balance_node()") ; else __assert_fail ("\"This shouldn't happen in balance_node()\"", "dict.c", 194, __extension__ __PRETTY_FUNCTION__); }));
  return ((void *)0);
 }
}

variable_types: struct Dict { struct Node *root; int len; } *

variable_types:
high
struct Node *

return_type: struct Node { struct Node *parent; struct Node *child[2]; char balance; char *key; void *obj; } *


decompiled_code:
void __fastcall free_node(void *ptr)
{
void *v2; // rdi

v2 = (void *)*((_QWORD *)ptr + 4);
if ( v2 )
free(v2);
free(ptr);
}

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

v2 = (void *)*((_QWORD *)ptr + 4);
if ( v2 )
free(v2);
free(ptr);
}

original_code:
static void free_node (struct Node *node)
{
 if (node->key) free (node->key);
 free (node);
}

canonical_original_code:
static void free_node(struct Node *node)
{
 if (node->key) free (node->key);
 free (node);
}

user_defined_types: struct Node { struct Node *parent; struct Node *child[2]; char balance; char *key; void *obj; }


decompiled_code:
void __fastcall node_recurse_free(_QWORD *a1)
{
if ( a1[1] )
node_recurse_free();
if ( a1[2] )
node_recurse_free();
free_node(a1);
}

canonical_decompiled_code:
void __fastcall func3(_QWORD *a1)
{
if ( a1[1] )
func3();
if ( a1[2] )
func3();
func2(a1);
}

original_code:
static void node_recurse_free (struct Node *node)
{
 if (node->child[0]) {
  node_recurse_free (node->child[0]);
 }
 if (node->child[1]) {
  node_recurse_free (node->child[1]);
 }
 free_node (node);
}

canonical_original_code:
static void node_recurse_free(struct Node *node)
{
 if (node->child[0]) {
  node_recurse_free (node->child[0]);
 }
 if (node->child[1]) {
  node_recurse_free (node->child[1]);
 }
 free_node (node);
}


decompiled_code:
_QWORD *alloc_node()
{
_QWORD *result; // rax

result = malloc(0x30uLL);
*result = 0LL;
result[1] = 0LL;
result[2] = 0LL;
result[3] = 0LL;
result[4] = 0LL;
result[5] = 0LL;
return result;
}

canonical_decompiled_code:
_QWORD *func4()
{
_QWORD *result; // rax

result = malloc(0x30uLL);
*result = 0LL;
result[1] = 0LL;
result[2] = 0LL;
result[3] = 0LL;
result[4] = 0LL;
result[5] = 0LL;
return result;
}

original_code:
static struct Node *alloc_node ()
{
 struct Node *node = (struct Node *) malloc (sizeof (struct Node));
 memset (node, 0, sizeof (struct Node));
 return node;
}

canonical_original_code:
static struct Node *alloc_node()
{
 struct Node *node = (struct Node *) malloc (sizeof (struct Node));
 memset (node, 0, sizeof (struct Node));
 return node;
}


decompiled_code:
char *__fastcall set_node(__int64 a1, const char *a2, __int64 a3)
{
size_t v4; // rax
char *v5; // rax
char *result; // rax

v4 = strlen(a2);
v5 = (char *)malloc(v4 + 1);
*(_QWORD *)(a1 + 32) = v5;
result = strcpy(v5, a2);
*(_QWORD *)(a1 + 40) = a3;
return result;
}

canonical_decompiled_code:
char *__fastcall func5(__int64 a1, const char *a2, __int64 a3)
{
size_t v4; // rax
char *v5; // rax
char *result; // rax

v4 = strlen(a2);
v5 = (char *)malloc(v4 + 1);
*(_QWORD *)(a1 + 32) = v5;
result = strcpy(v5, a2);
*(_QWORD *)(a1 + 40) = a3;
return result;
}

original_code:
static void set_node (struct Node *node, const char *key, void *obj)
{
 node->key = (char *) malloc (strlen(key)+1);
 strcpy (node->key, key);
 node->obj = obj;
}

canonical_original_code:
static void set_node(struct Node *node, char *key, void *obj)
{
 node->key = (char *) malloc (strlen(key)+1);
 strcpy (node->key, key);
 node->obj = obj;
}

variable_types:
key
char *

variable_types:
obj
void *


decompiled_code:
void __fastcall dict_init(__int64 a1)
{
*(_QWORD *)a1 = 0LL;
*(_DWORD *)(a1 + 8) = 0;
}

canonical_decompiled_code:
void __fastcall func6(__int64 a1)
{
*(_QWORD *)a1 = 0LL;
*(_DWORD *)(a1 + 8) = 0;
}

original_code:
void dict_init (struct Dict *tree)
{
 tree->root = ((void *)0);
 tree->len = 0;
}

canonical_original_code:
void dict_init(struct Dict *tree)
{
 tree->root = ((void *)0);
 tree->len = 0;
}

variable_types: struct Dict { struct Node { struct Node *parent; struct Node *child[2]; char balance; char *key; void *obj; } *root; int len; } *

user_defined_types: struct Dict { struct Node *root; int len; }


decompiled_code:
void __fastcall dict_free(_QWORD **a1)
{
node_recurse_free(*a1);
}

canonical_decompiled_code:
void __fastcall func7(_QWORD **a1)
{
func3(*a1);
}

original_code:
void dict_free (struct Dict *tree)
{
 node_recurse_free (tree->root);
}

canonical_original_code:
void dict_free(struct Dict *tree)
{
 node_recurse_free (tree->root);
}


decompiled_code:
__int64 __fastcall dict_get(__int64 *a1, const char *a2)
{
__int64 v2; // rbx
int v4; // eax

v2 = *a1;
while ( v2 )
{
v4 = strcmp(*(const char **)(v2 + 32), a2);
if ( v4 < 0 )
{
v2 = *(_QWORD *)(v2 + 8);
}
else
{
if ( v4 <= 0 )
return v2;
v2 = *(_QWORD *)(v2 + 16);
}
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 *a1, const char *a2)
{
__int64 v2; // rbx
int v4; // eax

v2 = *a1;
while ( v2 )
{
v4 = strcmp(*(const char **)(v2 + 32), a2);
if ( v4 < 0 )
{
v2 = *(_QWORD *)(v2 + 8);
}
else
{
if ( v4 <= 0 )
return v2;
v2 = *(_QWORD *)(v2 + 16);
}
}
return v2;
}

original_code:
struct Node *dict_get (struct Dict *tree, const char *key)
{
 int cmp;
 struct Node *parent = ((void *)0);
 struct Node *node;
 if (tree->root == ((void *)0)) {
  return ((void *)0);
 }
 node = tree->root;
 while (1) {
  if ((parent) && (node == ((void *)0)))
   return ((void *)0);
  cmp = strcmp (node->key, key);
  if (cmp < 0) {
   parent = node;
   node = node->child[0];
  } else if (cmp > 0) {
   parent = node;
   node = node->child[1];
  } else {
   return node;
  }
 }
}

canonical_original_code:
struct Node *dict_get(struct Dict *tree, char *key)
{
 int cmp;
 struct Node *parent = ((void *)0);
 struct Node *node;
 if (tree->root == ((void *)0)) {
  return ((void *)0);
 }
 node = tree->root;
 while (1) {
  if ((parent) && (node == ((void *)0)))
   return ((void *)0);
  cmp = strcmp (node->key, key);
  if (cmp < 0) {
   parent = node;
   node = node->child[0];
  } else if (cmp > 0) {
   parent = node;
   node = node->child[1];
  } else {
   return node;
  }
 }
}

variable_types: cmp int


original_code:
void dict_remove (struct Dict *tree, const char *key)
{
 int side;
 struct Node *to_remove;
 struct Node *iter;
 struct Node *rem_pos;
 int rem_dir;
 to_remove = dict_get (tree, key);
 if (to_remove == ((void *)0)) return;
 side = parent_side (to_remove);
 if ((to_remove->child[0] == ((void *)0)) && (to_remove->child[1] == ((void *)0))) {
  if (side == -1) {
   tree->root = ((void *)0);
  } else {
   to_remove->parent->child[side] = ((void *)0);
  }
  rem_pos = to_remove->parent;
  rem_dir = side;
 } else if (to_remove->child[0] == ((void *)0)) {
  if (side == -1) {
   tree->root = to_remove->child[1];
  } else {
   to_remove->parent->child[side] = to_remove->child[1];
  }
  to_remove->child[1]->parent = to_remove->parent;
  rem_pos = to_remove->parent;
  rem_dir = side;
 } else if (to_remove->child[1] == ((void *)0)) {
  if (side == -1) {
   tree->root = to_remove->child[0];
  } else {
   to_remove->parent->child[side] = to_remove->child[0];
  }
  to_remove->child[0]->parent = to_remove->parent;
  rem_pos = to_remove->parent;
  rem_dir = side;
 } else {
  iter = to_remove->child[0];
  while (iter->child[1]) {
   iter = iter->child[1];
  }
  if (iter->child[0]) {
   iter->child[0]->parent = iter->parent;
   iter->parent->child[parent_side (iter)] = iter->child[0];
   iter->child[0] = ((void *)0);
  } else {
   iter->parent->child[parent_side (iter)] = ((void *)0);
  }
  rem_pos = iter->parent;
  rem_dir = 1;
  if (rem_pos == to_remove) {
   rem_pos = iter;
   rem_dir = 0;
  }
  switch (parent_side (to_remove)) {
   case -1:
    tree->root = iter;
    iter->parent = ((void *)0);
    break;
   case 0:
    iter->parent = to_remove->parent;
    iter->parent->child[0] = iter;
    break;
   case 1:
    iter->parent = to_remove->parent;
    iter->parent->child[1] = iter;
    break;
  }
  if ((to_remove->child[0] != ((void *)0)) &&
      (to_remove->child[0] != iter)) {
   iter->child[0] = to_remove->child[0];
   iter->child[0]->parent = iter;
  } else {
   iter->child[0] = ((void *)0);
  }
  if ((to_remove->child[1] != ((void *)0)) &&
      (to_remove->child[1] != iter)) {
   iter->child[1] = to_remove->child[1];
   iter->child[1]->parent = iter;
  } else {
   iter->child[1] = ((void *)0);
  }
  iter->balance = to_remove->balance;
 }
 iter = rem_pos;
 ((void) sizeof ((iter != to_remove) ? 1 : 0), __extension__ ({ if (iter != to_remove) ; else __assert_fail ("iter != to_remove", "dict.c", 323, __extension__ __PRETTY_FUNCTION__); }));
 while (iter) {
  switch (rem_dir) {
   case 0: side = -1; break;
   case 1: side = 1; break;
  }
  iter->balance -= side;
  if (abs (iter->balance) >= 2) {
   iter = balance_node (tree, iter);
   if (iter->balance != 0) return;
  } else if (abs (iter->balance) == 1) {
   break;
  }
  rem_dir = parent_side (iter);
  iter = iter->parent;
 }
 free_node (to_remove);
}

canonical_original_code:
void dict_remove(struct Dict *tree, char *key)
{
 int side;
 struct Node *to_remove;
 struct Node *iter;
 struct Node *rem_pos;
 int rem_dir;
 to_remove = dict_get (tree, key);
 if (to_remove == ((void *)0)) return;
 side = parent_side (to_remove);
 if ((to_remove->child[0] == ((void *)0)) && (to_remove->child[1] == ((void *)0))) {
  if (side == -1) {
   tree->root = ((void *)0);
  } else {
   to_remove->parent->child[side] = ((void *)0);
  }
  rem_pos = to_remove->parent;
  rem_dir = side;
 } else if (to_remove->child[0] == ((void *)0)) {
  if (side == -1) {
   tree->root = to_remove->child[1];
  } else {
   to_remove->parent->child[side] = to_remove->child[1];
  }
  to_remove->child[1]->parent = to_remove->parent;
  rem_pos = to_remove->parent;
  rem_dir = side;
 } else if (to_remove->child[1] == ((void *)0)) {
  if (side == -1) {
   tree->root = to_remove->child[0];
  } else {
   to_remove->parent->child[side] = to_remove->child[0];
  }
  to_remove->child[0]->parent = to_remove->parent;
  rem_pos = to_remove->parent;
  rem_dir = side;
 } else {
  iter = to_remove->child[0];
  while (iter->child[1]) {
   iter = iter->child[1];
  }
  if (iter->child[0]) {
   iter->child[0]->parent = iter->parent;
   iter->parent->child[parent_side (iter)] = iter->child[0];
   iter->child[0] = ((void *)0);
  } else {
   iter->parent->child[parent_side (iter)] = ((void *)0);
  }
  rem_pos = iter->parent;
  rem_dir = 1;
  if (rem_pos == to_remove) {
   rem_pos = iter;
   rem_dir = 0;
  }
  switch (parent_side (to_remove)) {
   case -1:
    tree->root = iter;
    iter->parent = ((void *)0);
    break;
   case 0:
    iter->parent = to_remove->parent;
    iter->parent->child[0] = iter;
    break;
   case 1:
    iter->parent = to_remove->parent;
    iter->parent->child[1] = iter;
    break;
  }
  if ((to_remove->child[0] != ((void *)0)) &&
      (to_remove->child[0] != iter)) {
   iter->child[0] = to_remove->child[0];
   iter->child[0]->parent = iter;
  } else {
   iter->child[0] = ((void *)0);
  }
  if ((to_remove->child[1] != ((void *)0)) &&
      (to_remove->child[1] != iter)) {
   iter->child[1] = to_remove->child[1];
   iter->child[1]->parent = iter;
  } else {
   iter->child[1] = ((void *)0);
  }
  iter->balance = to_remove->balance;
 }
 iter = rem_pos;
 ((void) sizeof ((iter != to_remove) ? 1 : 0), __extension__ ({ if (iter != to_remove) ; else __assert_fail ("iter != to_remove", "dict.c", 323, __extension__ __PRETTY_FUNCTION__); }));
 while (iter) {
  switch (rem_dir) {
   case 0: side = -1; break;
   case 1: side = 1; break;
  }
  iter->balance -= side;
  if (abs (iter->balance) >= 2) {
   iter = balance_node (tree, iter);
   if (iter->balance != 0) return;
  } else if (abs (iter->balance) == 1) {
   break;
  }
  rem_dir = parent_side (iter);
  iter = iter->parent;
 }
 free_node (to_remove);
}

variable_types: side int


original_code:
int dict_set (struct Dict *tree, const char *key, void *obj)
{
 int cmp = 0;
 int side;
 struct Node *parent = ((void *)0);
 struct Node *node;
 if (tree->root == ((void *)0)) {
  tree->root = alloc_node ();
  set_node (tree->root, key, obj);
  tree->len++;
  return 1;
 }
 node = tree->root;
 while (1) {
  if ((parent) && (node == ((void *)0)))
   break;
  cmp = strcmp (node->key, key);
  if (cmp < 0) {
   parent = node;
   node = node->child[0];
  } else if (cmp > 0) {
   parent = node;
   node = node->child[1];
  } else {
   node->obj = obj;
   return 0;
  }
 }
 node = alloc_node ();
 set_node (node, key, obj);
 tree->len++;
 if (cmp < 0) {
  parent->child[0] = node;
 } else {
  parent->child[1] = node;
 }
 node->parent = parent;
 while (parent) {
  if (parent->child[0] == node) {
   side = -1;
  } else {
   side = +1;
  }
  parent->balance += side;
  if (abs (parent->balance) >= 2) {
   parent = balance_node (tree, parent);
   if (parent->balance == 0) return 1;
  } else if (parent->balance == 0) {
   break;
  }
  node = parent;
  parent = node->parent;
 }
 return 1;
}

canonical_original_code:
int dict_set(struct Dict *tree, char *key, void *obj)
{
 int cmp = 0;
 int side;
 struct Node *parent = ((void *)0);
 struct Node *node;
 if (tree->root == ((void *)0)) {
  tree->root = alloc_node ();
  set_node (tree->root, key, obj);
  tree->len++;
  return 1;
 }
 node = tree->root;
 while (1) {
  if ((parent) && (node == ((void *)0)))
   break;
  cmp = strcmp (node->key, key);
  if (cmp < 0) {
   parent = node;
   node = node->child[0];
  } else if (cmp > 0) {
   parent = node;
   node = node->child[1];
  } else {
   node->obj = obj;
   return 0;
  }
 }
 node = alloc_node ();
 set_node (node, key, obj);
 tree->len++;
 if (cmp < 0) {
  parent->child[0] = node;
 } else {
  parent->child[1] = node;
 }
 node->parent = parent;
 while (parent) {
  if (parent->child[0] == node) {
   side = -1;
  } else {
   side = +1;
  }
  parent->balance += side;
  if (abs (parent->balance) >= 2) {
   parent = balance_node (tree, parent);
   if (parent->balance == 0) return 1;
  } else if (parent->balance == 0) {
   break;
  }
  node = parent;
  parent = node->parent;
 }
 return 1;
}


repo: pcercuei/libxdgmime

decompiled_code:
int __fastcall icon_entry_cmp(const void *a1, const void *a2)
{
return strcmp(*(const char **)a1, *(const char **)a2);
}

canonical_decompiled_code:
int __fastcall func0(const void *a1, const void *a2)
{
return strcmp(*(const char **)a1, *(const char **)a2);
}

original_code:
static int
icon_entry_cmp (const void *v1, const void *v2)
{
  return strcmp (((XdgIcon *)v1)->mime_type, ((XdgIcon *)v2)->mime_type);
}

canonical_original_code:
static int icon_entry_cmp(void *v1, void *v2)
{
  return strcmp (((struct XdgIcon *)v1)->mime_type, ((struct XdgIcon *)v2)->mime_type);
}

user_defined_types: struct XdgIcon { char *mime_type; char *icon_name; }


decompiled_code:
int __fastcall alias_entry_cmp(const void *a1, const void *a2)
{
return strcmp(*(const char **)a1, *(const char **)a2);
}

original_code:
static int
alias_entry_cmp (const void *v1, const void *v2)
{
  return strcmp (((XdgAlias *)v1)->alias, ((XdgAlias *)v2)->alias);
}

canonical_original_code:
static int alias_entry_cmp(void *v1, void *v2)
{
  return strcmp (((struct XdgAlias *)v1)->alias, ((struct XdgAlias *)v2)->alias);
}

user_defined_types: struct XdgAlias { char *alias; char *mime_type; }


decompiled_code:
int __fastcall parent_entry_cmp(const void *a1, const void *a2)
{
return strcmp(*(const char **)a1, *(const char **)a2);
}

original_code:
static int
parent_entry_cmp (const void *v1, const void *v2)
{
  return strcmp (((XdgMimeParents *)v1)->mime, ((XdgMimeParents *)v2)->mime);
}

canonical_original_code:
static int parent_entry_cmp(void *v1, void *v2)
{
  return strcmp (((struct XdgMimeParents *)v1)->mime, ((struct XdgMimeParents *)v2)->mime);
}

user_defined_types: struct XdgMimeParents { char *mime; char **parents; int n_parents; }


reverseBits

repo: pclewis/dc

original_code:
static inline uint8_t reverseBits(uint8_t b) {
 return ((b * 0x0802LU & 0x22110LU) | (b * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16;
}

canonical_original_code:
static inline unsigned char reverseBits(unsigned char b) {
 return ((b * 0x0802LU & 0x22110LU) | (b * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16;
}

variable_types:
b
unsigned char

return_type: unsigned char


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int result; // eax
FILE *v4; // rbx
unsigned __int8 v5; // al
int v6; // eax

if ( argc == 2 )
{
v4 = (FILE *)fopen_safe((char)argv[1]);
if ( v4 )
{
while ( 1 )
{
v6 = fgetc(v4);
if ( v6 == -1 )
break;
v5 = reverseBits(v6);
fputc(v5, stdout);
}
fclose(v4);
result = 0;
}
else
{
result = 1;
}
}
else
{
fprintf(stderr, "Usage: %s [f1]\n", *argv);
result = 1;
}
return result;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int result; // eax
FILE *v4; // rbx
unsigned __int8 v5; // al
int v6; // eax

if ( argc == 2 )
{
v4 = (FILE *)fopen_safe((char)argv[1]);
if ( v4 )
{
while ( 1 )
{
v6 = fgetc(v4);
if ( v6 == -1 )
break;
v5 = func7(v6);
fputc(v5, stdout);
}
fclose(v4);
result = 0;
}
else
{
result = 1;
}
}
else
{
fprintf(stderr, "Usage: %s [f1]\n", *argv);
result = 1;
}
return result;
}

original_code:
int main(int argc, char *argv[]) {
 int status = 1;
 if(argc < 3) {
  printf("Usage: %s keyfile...\n", argv[0]);
  goto done;
 }
 Relation *relation = calloc(1, sizeof(Relation));
 for(int i = 1; i < argc; ++i) {
  relate(relation, argv[i]);
 }
 for(size_t ki = 0; ki < 240; ++ki) {
  for(int bi = 0; bi < 8; ++bi) {
   for(int bv = 0; bv < 2; ++bv) {
    if( relation->cnt[ki][bi][bv] < 2) {
     printf("Didn't see enough key index %zu bit %d with value %d\n", ki, bi, bv);
     continue;
    }
    for(size_t si = 0; si < 240; ++si) {
     for(int sb = 0; sb < 8; ++sb) {
      if(((relation->related[ki][bi][bv][si]&(1<<(sb)))!=0))
       printf("key %zu bit %d = %d, scr %zu bit %d = %d, cnt=%d\n", ki, bi, bv, si, sb, ((relation->value[ki][bi][bv][si]&(1<<(sb)))!=0) ? 1 : 0, relation->cnt[ki][bi][bv]);
     }
    }
   }
  }
 }
 printf("Welp.\n");
 status = 0;
 done:
 return status;
}

canonical_original_code:
int main(int argc, char *argv[]) {
 int status = 1;
 if(argc < 3) {
  printf("Usage: %s keyfile...\n", argv[0]);
  goto done;
 }
 struct Relation *relation = calloc(1, sizeof(Relation));
 for(int i = 1; i < argc; ++i) {
  relate(relation, argv[i]);
 }
 for(unsigned long ki = 0; ki < 240; ++ki) {
  for(int bi = 0; bi < 8; ++bi) {
   for(int bv = 0; bv < 2; ++bv) {
    if( relation->cnt[ki][bi][bv] < 2) {
     printf("Didn't see enough key index %zu bit %d with value %d\n", ki, bi, bv);
     continue;
    }
    for(unsigned long si = 0; si < 240; ++si) {
     for(int sb = 0; sb < 8; ++sb) {
      if(((relation->related[ki][bi][bv][si]&(1<<(sb)))!=0))
       printf("key %zu bit %d = %d, scr %zu bit %d = %d, cnt=%d\n", ki, bi, bv, si, sb, ((relation->value[ki][bi][bv][si]&(1<<(sb)))!=0) ? 1 : 0, relation->cnt[ki][bi][bv]);
     }
    }
   }
  }
 }
 printf("Welp.\n");
 status = 0;
 done:
 return status;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: status int

variable_types: struct Relation { int cnt[240][8][2]; unsigned char value[240][8][2][240]; unsigned char related[240][8][2][240]; } *

variable_types: i int

variable_types:
ki
unsigned long

variable_types: bi int

variable_types: bv int

variable_types:
si
unsigned long

variable_types: sb int


die

decompiled_code:
void __noreturn die(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
vfprintf(stderr, format, arg);
fputc(10, stderr);
exit(1);
}

canonical_decompiled_code:
void __noreturn func8(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
vfprintf(stderr, format, arg);
fputc(10, stderr);
exit(1);
}

original_code:
void die(const char *fmt, ...) {
 va_list args;
 __builtin_va_start(args,fmt);
 vfprintf(stderr, fmt, args);
 __builtin_va_end(args);
 fprintf(stderr, "\n");
 exit(1);
}

canonical_original_code:
void die(char *fmt, ...) {
 __builtin_va_list args;
 __builtin_va_start(args,fmt);
 vfprintf(stderr, fmt, args);
 __builtin_va_end(args);
 fprintf(stderr, "\n");
 exit(1);
}

variable_types:
fmt
char *


decompiled_code:
void *__fastcall realloc_safe(void *a1, size_t a2)
{
void *result; // rax

result = realloc(a1, a2);
if ( !result )
die("Realloc failed. Requested size: %zu", a2);
return result;
}

canonical_decompiled_code:
void *__fastcall func15(void *a1, size_t a2)
{
void *result; // rax

result = realloc(a1, a2);
if ( !result )
func8("Realloc failed. Requested size: %zu", a2);
return result;
}

original_code:
void *realloc_safe(void *ptr, size_t size) {
 void *result = realloc(ptr, size);
 if(result == ((void *)0)) die("Realloc failed. Requested size: %zu", size);
 return result;
}

canonical_original_code:
void *realloc_safe(void *ptr, unsigned long size) {
 void *result = realloc(ptr, size);
 if(result == ((void *)0)) die("Realloc failed. Requested size: %zu", size);
 return result;
}

variable_types:
ptr
void *

variable_types:
size
unsigned long

variable_types:
result
void *


decompiled_code:
void *__fastcall calloc_safe(size_t a1, size_t a2)
{
void *result; // rax

result = calloc(a1, a2);
if ( !result )
die("Calloc failed. Requested size: %zu", a2 * a1);
return result;
}

canonical_decompiled_code:
void *__fastcall func16(size_t a1, size_t a2)
{
void *result; // rax

result = calloc(a1, a2);
if ( !result )
func8("Calloc failed. Requested size: %zu", a2 * a1);
return result;
}

original_code:
void *calloc_safe(size_t nmemb, size_t size) {
 void *result = calloc(nmemb, size);
 if(result == ((void *)0)) die("Calloc failed. Requested size: %zu", nmemb*size);
 return result;
}

canonical_original_code:
void *calloc_safe(unsigned long nmemb, unsigned long size) {
 void *result = calloc(nmemb, size);
 if(result == ((void *)0)) die("Calloc failed. Requested size: %zu", nmemb*size);
 return result;
}

variable_types:
nmemb
unsigned long


repo: pcx/misc

decompiled_code:
_QWORD *Stack_create()
{
_QWORD *v0; // rbx
_BYTE *v1; // rax
int *v3; // rbp
char *v4; // r8
int *v5; // r12
char *v6; // r8

v0 = malloc(0x28uLL);
if ( v0 )
{
v1 = malloc(0x18uLL);
*v0 = v1;
if ( v1 )
{
*(_DWORD *)v1 = 0;
v1[4] = 0;
*((_QWORD *)v1 + 1) = 0LL;
*((_QWORD *)v1 + 2) = 0LL;
v0[1] = head;
v0[2] = push;
v0[3] = pop;
v0[4] = size;
}
else
{
v5 = __errno_location();
v6 = "None";
if ( *v5 )
v6 = strerror(*v5);
fprintf(stderr, "[ERROR] (%s:%d: errno: %s) Out of memory.\n", "src/stack.c", 15LL, v6);
*v5 = 0;
free(v0);
v0 = 0LL;
}
}
else
{
v3 = __errno_location();
v4 = "None";
if ( *v3 )
v4 = strerror(*v3);
fprintf(stderr, "[ERROR] (%s:%d: errno: %s) Out of memory.\n", "src/stack.c", 12LL, v4);
*v3 = 0;
}
return v0;
}

canonical_decompiled_code:
_QWORD *func7()
{
_QWORD *v0; // rbx
_BYTE *v1; // rax
int *v3; // rbp
char *v4; // r8
int *v5; // r12
char *v6; // r8

v0 = malloc(0x28uLL);
if ( v0 )
{
v1 = malloc(0x18uLL);
*v0 = v1;
if ( v1 )
{
*(_DWORD *)v1 = 0;
v1[4] = 0;
*((_QWORD *)v1 + 1) = 0LL;
*((_QWORD *)v1 + 2) = 0LL;
v0[1] = head;
v0[2] = push;
v0[3] = pop;
v0[4] = size;
}
else
{
v5 = __errno_location();
v6 = "None";
if ( *v5 )
v6 = strerror(*v5);
fprintf(stderr, "[ERROR] (%s:%d: errno: %s) Out of memory.\n", "src/stack.c", 15LL, v6);
*v5 = 0;
free(v0);
v0 = 0LL;
}
}
else
{
v3 = __errno_location();
v4 = "None";
if ( *v3 )
v4 = strerror(*v3);
fprintf(stderr, "[ERROR] (%s:%d: errno: %s) Out of memory.\n", "src/stack.c", 12LL, v4);
*v3 = 0;
}
return v0;
}

original_code:
LinkedStack *Stack_create()
{
     LinkedStack *st = (LinkedStack *) malloc(sizeof(LinkedStack));
     if(!((st))) { fprintf(stderr, "[ERROR] (%s:%d: errno: %s) " "Out of memory." "\n", "src/stack.c", 12, ((*__errno_location ()) == 0 ? "None" : strerror((*__errno_location ())))); (*__errno_location ())=0; goto error; };
     st->_head = (linked_element *) malloc(sizeof(linked_element));
     if(!((st->_head))) { fprintf(stderr, "[ERROR] (%s:%d: errno: %s) " "Out of memory." "\n", "src/stack.c", 15, ((*__errno_location ()) == 0 ? "None" : strerror((*__errno_location ())))); (*__errno_location ())=0; goto error; };
     st->_head->val = 0;
     st->_head->set = 0;
     st->_head->next = ((void *)0);
     st->_head->prev = ((void *)0);
     st->head = head;
     st->push = push;
     st->pop = pop;
     st->size = size;
     return st;
error:
     if(st) free(st);
     return ((void *)0);
}

canonical_original_code:
struct LinkedStack *Stack_create()
{
     struct LinkedStack *st = (LinkedStack *) malloc(sizeof(LinkedStack));
     if(!((st))) { fprintf(stderr, "[ERROR] (%s:%d: errno: %s) " "Out of memory." "\n", "src/stack.c", 12, ((*__errno_location ()) == 0 ? "None" : strerror((*__errno_location ())))); (*__errno_location ())=0; goto error; };
     st->_head = (struct linked_element *) malloc(sizeof(linked_element));
     if(!((st->_head))) { fprintf(stderr, "[ERROR] (%s:%d: errno: %s) " "Out of memory." "\n", "src/stack.c", 15, ((*__errno_location ()) == 0 ? "None" : strerror((*__errno_location ())))); (*__errno_location ())=0; goto error; };
     st->_head->val = 0;
     st->_head->set = 0;
     st->_head->next = ((void *)0);
     st->_head->prev = ((void *)0);
     st->head = head;
     st->push = push;
     st->pop = pop;
     st->size = size;
     return st;
error:
     if(st) free(st);
     return ((void *)0);
}

variable_types: struct LinkedStack { struct linked_element { int val; _Bool set; struct linked_element *next; } *_head; int (*head)(struct linked_element *el); int (*push)(struct linked_element **el, int i); int (*pop)(struct linked_element **el); int (*size)(struct linked_element *el); } *

user_defined_types: struct LinkedStack { struct linked_element *_head; int (*head)(struct linked_element *el); int (*push)(struct linked_element **el, int i); int (*pop)(struct linked_element **el); int (*size)(struct linked_element *el); }


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
_QWORD *v3; // rax
_QWORD *v4; // rbx
unsigned int i; // ebp
int v6; // er12
unsigned int v7; // eax
int *v8; // rbx
char *v9; // r8
int *v10; // rbp
char *v11; // r8
unsigned int v12; // eax
unsigned int v13; // er13
int *v14; // rbp
char *v15; // r8

v3 = Stack_create();
if ( v3 )
{
v4 = v3;
fprintf(stderr, "[INFO] (%s:%d) Created an empty stack data structure.\n", "src/stack_example.c", 13LL);
for ( i = 1; i != 7; ++i )
{
v6 = ((__int64 (__fastcall *)(_QWORD *, _QWORD))v4[2])(v4, i);
if ( v6 )
{
v10 = __errno_location();
v11 = "None";
if ( *v10 )
v11 = strerror(*v10);
fprintf(stderr, "[ERROR] (%s:%d: errno: %s) Failed to push onto stack.\n", "src/stack_example.c", 17LL, v11);
*v10 = 0;
goto LABEL_12;
}
}
v7 = ((__int64 (__fastcall *)(_QWORD))v4[4])(*v4);
fprintf(
stderr,
"[INFO] (%s:%d) Pushed numbers 1-6 onto the stack. Stack size is now %d.\n",
"src/stack_example.c",
19LL,
v7);
fprintf(stderr, "[INFO] (%s:%d) Now emptying stack by poping all its elements:\n", "src/stack_example.c", 21LL);
while ( 1 )
{
v13 = ((__int64 (__fastcall *)(_QWORD *))v4[3])(v4);
v14 = __errno_location();
if ( *v14 )
{
if ( !strerror(*v14) )
break;
}
v12 = ((__int64 (__fastcall *)(_QWORD))v4[4])(*v4);
fprintf(stderr, "[INFO] (%s:%d) Popped %d. Stack size is now %d.\n", "src/stack_example.c", 29LL, v13, v12);
if ( !*v4 )
{
fprintf(stderr, "[INFO] (%s:%d) Stack is now empty. Bye bye.\n", "src/stack_example.c", 31LL);
free(v4);
return v6;
}
}
v15 = "None";
if ( *v14 )
v15 = strerror(*v14);
fprintf(
stderr,
"[ERROR] (%s:%d: errno: %s) Failed to pop off the stack. Something's wrong.\n",
"src/stack_example.c",
26LL,
v15);
*v14 = 0;
LABEL_12:
free(v4);
v6 = -1;
}
else
{
v8 = __errno_location();
v9 = "None";
if ( *v8 )
v9 = strerror(*v8);
fprintf(stderr, "[ERROR] (%s:%d: errno: %s) Out of memory.\n", "src/stack_example.c", 12LL, v9);
*v8 = 0;
v6 = -1;
}
return v6;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
_QWORD *v3; // rax
_QWORD *v4; // rbx
unsigned int i; // ebp
int v6; // er12
unsigned int v7; // eax
int *v8; // rbx
char *v9; // r8
int *v10; // rbp
char *v11; // r8
unsigned int v12; // eax
unsigned int v13; // er13
int *v14; // rbp
char *v15; // r8

v3 = func7();
if ( v3 )
{
v4 = v3;
fprintf(stderr, "[INFO] (%s:%d) Created an empty stack data structure.\n", "src/stack_example.c", 13LL);
for ( i = 1; i != 7; ++i )
{
v6 = ((__int64 (__fastcall *)(_QWORD *, _QWORD))v4[2])(v4, i);
if ( v6 )
{
v10 = __errno_location();
v11 = "None";
if ( *v10 )
v11 = strerror(*v10);
fprintf(stderr, "[ERROR] (%s:%d: errno: %s) Failed to push onto stack.\n", "src/stack_example.c", 17LL, v11);
*v10 = 0;
goto LABEL_12;
}
}
v7 = ((__int64 (__fastcall *)(_QWORD))v4[4])(*v4);
fprintf(
stderr,
"[INFO] (%s:%d) Pushed numbers 1-6 onto the stack. Stack size is now %d.\n",
"src/stack_example.c",
19LL,
v7);
fprintf(stderr, "[INFO] (%s:%d) Now emptying stack by poping all its elements:\n", "src/stack_example.c", 21LL);
while ( 1 )
{
v13 = ((__int64 (__fastcall *)(_QWORD *))v4[3])(v4);
v14 = __errno_location();
if ( *v14 )
{
if ( !strerror(*v14) )
break;
}
v12 = ((__int64 (__fastcall *)(_QWORD))v4[4])(*v4);
fprintf(stderr, "[INFO] (%s:%d) Popped %d. Stack size is now %d.\n", "src/stack_example.c", 29LL, v13, v12);
if ( !*v4 )
{
fprintf(stderr, "[INFO] (%s:%d) Stack is now empty. Bye bye.\n", "src/stack_example.c", 31LL);
free(v4);
return v6;
}
}
v15 = "None";
if ( *v14 )
v15 = strerror(*v14);
fprintf(
stderr,
"[ERROR] (%s:%d: errno: %s) Failed to pop off the stack. Something's wrong.\n",
"src/stack_example.c",
26LL,
v15);
*v14 = 0;
LABEL_12:
free(v4);
v6 = -1;
}
else
{
v8 = __errno_location();
v9 = "None";
if ( *v8 )
v9 = strerror(*v8);
fprintf(stderr, "[ERROR] (%s:%d: errno: %s) Out of memory.\n", "src/stack_example.c", 12LL, v9);
*v8 = 0;
v6 = -1;
}
return v6;
}

original_code:
int main(int argc, char **argv)
{
     LinkedStack *st = Stack_create();
     if(!((st))) { fprintf(stderr, "[ERROR] (%s:%d: errno: %s) " "Out of memory." "\n", "src/stack_example.c", 12, ((*__errno_location ()) == 0 ? "None" : strerror((*__errno_location ())))); (*__errno_location ())=0; goto error; };
     fprintf(stderr, "[INFO] (%s:%d) " "Created an empty stack data structure." "\n", "src/stack_example.c", 13);
     for(int i = 1; i <= 6; i++) {
   if(st->push(&(st->_head), i) != 0)
        { fprintf(stderr, "[ERROR] (%s:%d: errno: %s) " "Failed to push onto stack." "\n", "src/stack_example.c", 17, ((*__errno_location ()) == 0 ? "None" : strerror((*__errno_location ())))); (*__errno_location ())=0; goto error; };
     }
     fprintf(stderr, "[INFO] (%s:%d) " "Pushed numbers 1-6 onto the stack. Stack size is now %d." "\n", "src/stack_example.c", 19, st->size(st->_head));
     fprintf(stderr, "[INFO] (%s:%d) " "Now emptying stack by poping all its elements:" "\n", "src/stack_example.c", 21);
     int i, v = 0;
     for(i = 1; ; i++) {
   v = st->pop(&(st->_head));
   if(!((*__errno_location ()) == 0 ? "None" : strerror((*__errno_location ())))) {
        { fprintf(stderr, "[ERROR] (%s:%d: errno: %s) " "Failed to pop off the stack. Something's wrong." "\n", "src/stack_example.c", 26, ((*__errno_location ()) == 0 ? "None" : strerror((*__errno_location ())))); (*__errno_location ())=0; goto error; };
   }
   fprintf(stderr, "[INFO] (%s:%d) " "Popped %d. Stack size is now %d." "\n", "src/stack_example.c", 29, v, st->size(st->_head));
   if(!st->_head) {
        fprintf(stderr, "[INFO] (%s:%d) " "Stack is now empty. Bye bye." "\n", "src/stack_example.c", 31);
        break;
   }
     }
     if(st) free(st);
     return 0;
error:
     if(st) free(st);
     return -1;
}

canonical_original_code:
int main(int argc, char **argv)
{
     struct LinkedStack *st = Stack_create();
     if(!((st))) { fprintf(stderr, "[ERROR] (%s:%d: errno: %s) " "Out of memory." "\n", "src/stack_example.c", 12, ((*__errno_location ()) == 0 ? "None" : strerror((*__errno_location ())))); (*__errno_location ())=0; goto error; };
     fprintf(stderr, "[INFO] (%s:%d) " "Created an empty stack data structure." "\n", "src/stack_example.c", 13);
     for(int i = 1; i <= 6; i++) {
   if(st->push(&(st->_head), i) != 0)
        { fprintf(stderr, "[ERROR] (%s:%d: errno: %s) " "Failed to push onto stack." "\n", "src/stack_example.c", 17, ((*__errno_location ()) == 0 ? "None" : strerror((*__errno_location ())))); (*__errno_location ())=0; goto error; };
     }
     fprintf(stderr, "[INFO] (%s:%d) " "Pushed numbers 1-6 onto the stack. Stack size is now %d." "\n", "src/stack_example.c", 19, st->size(st->_head));
     fprintf(stderr, "[INFO] (%s:%d) " "Now emptying stack by poping all its elements:" "\n", "src/stack_example.c", 21);
     int i; int v = 0;
     for(i = 1; ; i++) {
   v = st->pop(&(st->_head));
   if(!((*__errno_location ()) == 0 ? "None" : strerror((*__errno_location ())))) {
        { fprintf(stderr, "[ERROR] (%s:%d: errno: %s) " "Failed to pop off the stack. Something's wrong." "\n", "src/stack_example.c", 26, ((*__errno_location ()) == 0 ? "None" : strerror((*__errno_location ())))); (*__errno_location ())=0; goto error; };
   }
   fprintf(stderr, "[INFO] (%s:%d) " "Popped %d. Stack size is now %d." "\n", "src/stack_example.c", 29, v, st->size(st->_head));
   if(!st->_head) {
        fprintf(stderr, "[INFO] (%s:%d) " "Stack is now empty. Bye bye." "\n", "src/stack_example.c", 31);
        break;
   }
     }
     if(st) free(st);
     return 0;
error:
     if(st) free(st);
     return -1;
}

variable_types:
argv
char **

variable_types: v int

user_defined_types: struct linked_element { int val; _Bool set; struct linked_element *next; }


head

decompiled_code:
__int64 __fastcall head(unsigned int *a1)
{
int *v2; // rbx
char *v3; // r8

if ( a1 )
return *a1;
v2 = __errno_location();
v3 = "None";
if ( *v2 )
v3 = strerror(*v2);
fprintf(
stderr,
"[ERROR] (%s:%d: errno: %s) Cannot access property of a null pointer.\n",
"src/linked_list.c",
14LL,
v3);
*v2 = 0;
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func8(unsigned int *a1)
{
int *v2; // rbx
char *v3; // r8

if ( a1 )
return *a1;
v2 = __errno_location();
v3 = "None";
if ( *v2 )
v3 = strerror(*v2);
fprintf(
stderr,
"[ERROR] (%s:%d: errno: %s) Cannot access property of a null pointer.\n",
"src/linked_list.c",
14LL,
v3);
*v2 = 0;
return 0xFFFFFFFFLL;
}

original_code:
int head(linked_element *el)
{
     if(!(el)) { fprintf(stderr, "[ERROR] (%s:%d: errno: %s) " "Cannot access property of a null pointer." "\n", "src/linked_list.c", 14, ((*__errno_location ()) == 0 ? "None" : strerror((*__errno_location ())))); (*__errno_location ())=0; goto error; };
     return el->val;
error:
     return -1;
}

canonical_original_code:
int head(struct linked_element *el)
{
     if(!(el)) { fprintf(stderr, "[ERROR] (%s:%d: errno: %s) " "Cannot access property of a null pointer." "\n", "src/linked_list.c", 14, ((*__errno_location ()) == 0 ? "None" : strerror((*__errno_location ())))); (*__errno_location ())=0; goto error; };
     return el->val;
error:
     return -1;
}

variable_types: struct linked_element { int val; _Bool set; struct linked_element *next; } *


size

original_code:
int size(linked_element *el)
{
     if(!el) {
   return 0;
     } else {
   int i = 1;
   while(1) {
        if(el->next) {
      i++;
      el = el->next;
        } else {
      break;
        }
   }
   return i;
     }
}

canonical_original_code:
int size(struct linked_element *el)
{
     if(!el) {
   return 0;
     } else {
   int i = 1;
   while(1) {
        if(el->next) {
      i++;
      el = el->next;
        } else {
      break;
        }
   }
   return i;
     }
}