decompiled_code:
float *__fastcall v3_normalize(float *a1, float *a2, float a3)
{
float *result; // rax
float v4; // xmm3_4
float v5; // xmm2_4

v3_norm(a2);
result = a1;
v4 = a2[2];
v5 = a2[1] / a3;
*a1 = *a2 / a3;
a1[1] = v5;
a1[2] = v4 / a3;
return result;
}

canonical_decompiled_code:
float *__fastcall func10(float *a1, float *a2, float a3)
{
float *result; // rax
float v4; // xmm3_4
float v5; // xmm2_4

func9(a2);
result = a1;
v4 = a2[2];
v5 = a2[1] / a3;
*a1 = *a2 / a3;
a1[1] = v5;
a1[2] = v4 / a3;
return result;
}

original_code:
v3_t *v3_normalize(v3_t *r, const v3_t *q) {
 fp_t normal = v3_norm(q);
 r->x = q->x / normal;
 r->y = q->y / normal;
 r->z = q->z / normal;
 return r;
}

canonical_original_code:
struct v3_t *v3_normalize(struct v3_t *r, struct v3_t *q) {
 float normal = v3_norm(q);
 r->x = q->x / normal;
 r->y = q->y / normal;
 r->z = q->z / normal;
 return r;
}

variable_types:
q
struct v3_t *

variable_types: normal float


decompiled_code:
__int64 __fastcall cels_convert_to_fahr(int a1)
{
return (unsigned int)(int)((double)a1 * 1.8 + 32.0);
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
return (unsigned int)(int)((double)a1 * 1.8 + 32.0);
}

original_code:
int cels_convert_to_fahr( int celsius )
{
    int fahr = 0;
    fahr = ( 9.0 / 5.0 ) * celsius + 32.0;
    return fahr;
}

canonical_original_code:
int cels_convert_to_fahr(int celsius)
{
    int fahr = 0;
    fahr = ( 9.0 / 5.0 ) * celsius + 32.0;
    return fahr;
}

variable_types: celsius int

variable_types: fahr int

return_type: int


main

canonical_name: main

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

v3 = 16;
printf("%3s\t%7s\n", "celsius", "fahr");
v4 = 0.0;
do
{
v5 = cels_convert_to_fahr((int)v4);
printf("%3.0f\t%6.1f\n", v4, (float)v5);
v4 = v4 + 20.0;
--v3;
}
while ( v3 );
return 0;
}

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

v3 = 16;
printf("%3s\t%7s\n", "celsius", "fahr");
v4 = 0.0;
do
{
v5 = func0((int)v4);
printf("%3.0f\t%6.1f\n", v4, (float)v5);
v4 = v4 + 20.0;
--v3;
}
while ( v3 );
return 0;
}

original_code:
int main( void )
{
    float celsius = 0;
    float fahr = 0;
    int upper = 300;
    int lower = 0;
    int step = 20;
    printf("%3s\t%7s\n", "celsius", "fahr" );
    for ( celsius = lower ; celsius <= upper ; celsius += step )
    {
        fahr = cels_convert_to_fahr(celsius);
        printf( "%3.0f\t%6.1f\n", celsius, fahr );
    }
    return 0;
}

canonical_original_code:
int main()
{
    float celsius = 0;
    float fahr = 0;
    int upper = 300;
    int lower = 0;
    int step = 20;
    printf("%3s\t%7s\n", "celsius", "fahr" );
    for ( celsius = lower ; celsius <= upper ; celsius += step )
    {
        fahr = cels_convert_to_fahr(celsius);
        printf( "%3.0f\t%6.1f\n", celsius, fahr );
    }
    return 0;
}

variable_types: celsius float

variable_types: fahr float

variable_types: upper int

variable_types: lower int

variable_types: step int


decompiled_code:
__int64 __fastcall horizontal_bars(int *a1, int a2)
{
int v3; // er12
int v4; // ebx

puts("\n=== horizontal_bars!!===");
if ( a2 > 0 )
{
v3 = 0;
do
{
printf("|%2d| ", (unsigned int)++v3);
if ( *a1 > 0 )
{
v4 = 0;
do
{
++v4;
putchar(42);
}
while ( *a1 > v4 );
}
++a1;
putchar(10);
}
while ( v3 != a2 );
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(int *a1, int a2)
{
int v3; // er12
int v4; // ebx

puts("\n=== horizontal_bars!!===");
if ( a2 > 0 )
{
v3 = 0;
do
{
printf("|%2d| ", (unsigned int)++v3);
if ( *a1 > 0 )
{
v4 = 0;
do
{
++v4;
putchar(42);
}
while ( *a1 > v4 );
}
++a1;
putchar(10);
}
while ( v3 != a2 );
}
return 0LL;
}

original_code:
int horizontal_bars ( int buffer[] ,int word_id )
{
    int i = 0;
    int j = 0;
    printf("\n=== horizontal_bars!!===\n");
    for ( i=0 ; i<word_id ; i++ ) {
        printf("|%2d| ",i+1);
        for ( j=0 ; j<buffer[i]; j++ ) {
            putchar('*');
        }
        putchar('\n');
    }
    return 0;
}

canonical_original_code:
int horizontal_bars(int buffer[], int word_id)
{
    int i = 0;
    int j = 0;
    printf("\n=== horizontal_bars!!===\n");
    for ( i=0 ; i<word_id ; i++ ) {
        printf("|%2d| ",i+1);
        for ( j=0 ; j<buffer[i]; j++ ) {
            putchar('*');
        }
        putchar('\n');
    }
    return 0;
}

variable_types:
buffer
int []

variable_types: i int

variable_types: j int


original_code:
int vertical_bars( int buffer[] ,int word_id )
{
    printf("\n===vertical_bars!!===\n");
    int i = 0;
    int j = 0;
    int max = 0;
    printf("|%2c|", ' ');
    for ( i=0 ; i<word_id ; i++ ) {
        printf("%2d|", i+1);
        max = (buffer[i]>max) ? buffer[i]:max;
    }
    putchar('\n');
    printf("|%2c|", ' ');
    for ( i=0 ; i<word_id ; i++ ) {
        printf("%2c|", '_');
    }
    putchar('\n');
    for ( i=max-1 ; i>=0; i-- ) {
        printf("|%2d|", i+1);
        for ( j=0 ; j<word_id ; j++ ) {
            printf("%2c|", i < buffer[j] ? '*' : ' ');
        }
        putchar('\n');
    }
    return 0;
}

canonical_original_code:
int vertical_bars(int buffer[], int word_id)
{
    printf("\n===vertical_bars!!===\n");
    int i = 0;
    int j = 0;
    int max = 0;
    printf("|%2c|", ' ');
    for ( i=0 ; i<word_id ; i++ ) {
        printf("%2d|", i+1);
        max = (buffer[i]>max) ? buffer[i]:max;
    }
    putchar('\n');
    printf("|%2c|", ' ');
    for ( i=0 ; i<word_id ; i++ ) {
        printf("%2c|", '_');
    }
    putchar('\n');
    for ( i=max-1 ; i>=0; i-- ) {
        printf("|%2d|", i+1);
        for ( j=0 ; j<word_id ; j++ ) {
            printf("%2c|", i < buffer[j] ? '*' : ' ');
        }
        putchar('\n');
    }
    return 0;
}

variable_types: max int


decompiled_code:
int __fastcall num_to_repeat_char(int a1, char a2)
{
int i; // ebx
int result; // eax

if ( a1 > 0 )
{
for ( i = 0; i != a1; ++i )
result = putchar(a2);
}
return result;
}

canonical_decompiled_code:
int __fastcall func0(int a1, char a2)
{
int i; // ebx
int result; // eax

if ( a1 > 0 )
{
for ( i = 0; i != a1; ++i )
result = putchar(a2);
}
return result;
}

original_code:
void num_to_repeat_char ( int num, char symbol )
{
    int i = 0;
    for( i=0 ; i<num ; i++ ) {
        printf("%c",symbol);
    }
}

canonical_original_code:
void num_to_repeat_char(int num, char symbol)
{
    int i = 0;
    for( i=0 ; i<num ; i++ ) {
        printf("%c",symbol);
    }
}

variable_types: num int

variable_types: symbol char

return_type: void


rateN

original_code:
void rateN(int g, int n, double R[n][g], double R_i[], double W[g][g], double gamma[], double tau[], double dt)
{
 int t,i,j,l;
 double s;
 for (i=0; i<g; i++){
  R[0][i] = R_i[i];
 }
 for (t=1; t<=n; t++){
  l = t-1;
  for (i=0; i<g; i++){
   s = 0;
   for (j=0; j<g; j++){
    s += W[j][i]*R[l][j];
   }
   R[t][i]=R[l][i]+dt/tau[i]*(-R[l][i]+(0 > s+gamma[i] ? 0 : s+gamma[i]));
  }
 }
}

canonical_original_code:
void rateN(int g, int n, double R[-1][-1], double R_i[], double W[-1][-1], double gamma[], double tau[], double dt)
{
 int t; int i; int j; int l;
 double s;
 for (i=0; i<g; i++){
  R[0][i] = R_i[i];
 }
 for (t=1; t<=n; t++){
  l = t-1;
  for (i=0; i<g; i++){
   s = 0;
   for (j=0; j<g; j++){
    s += W[j][i]*R[l][j];
   }
   R[t][i]=R[l][i]+dt/tau[i]*(-R[l][i]+(0 > s+gamma[i] ? 0 : s+gamma[i]));
  }
 }
}

variable_types: g int

variable_types: n int

variable_types:
gamma
double []

variable_types:
tau
double []

variable_types: dt double

variable_types: t int

variable_types: l int

variable_types: s double


assignPingW

original_code:
void
assignPingW(int no, double W[2*no][2*no],
            double wee, double wei, double wie, double wii,
            double xee, double xei, double xie, double xii)
{
    int i,j,g=2*no;
    double wW[2][2];
        wW[0][0]=wee; wW[0][1]=wei;
        wW[1][0]=wie; wW[1][1]=wii;
    double xW[2][2];
        xW[0][0]=xee; xW[0][1]=xei;
        xW[1][0]=xie; xW[1][1]=xii;
    for (i=0; i<g; i++){
        for (j=0; j<g; j++){
            if ( i/2 == j/2 ){
                W[i][j] = wW[i%2][j%2];
            } else {
                W[i][j] = xW[i%2][j%2];
            }
        }
    }
}

canonical_original_code:
void assignPingW(int no, double W[-1][-1], double wee, double wei, double wie, double wii, double xee, double xei, double xie, double xii)
{
    int i; int j; int g = 2*no;
    double wW[2][2];
        wW[0][0]=wee; wW[0][1]=wei;
        wW[1][0]=wie; wW[1][1]=wii;
    double xW[2][2];
        xW[0][0]=xee; xW[0][1]=xei;
        xW[1][0]=xie; xW[1][1]=xii;
    for (i=0; i<g; i++){
        for (j=0; j<g; j++){
            if ( i/2 == j/2 ){
                W[i][j] = wW[i%2][j%2];
            } else {
                W[i][j] = xW[i%2][j%2];
            }
        }
    }
}

variable_types: no int

variable_types: wee double

variable_types: wei double

variable_types: wie double

variable_types: wii double

variable_types: xee double

variable_types: xei double

variable_types: xie double

variable_types: xii double

variable_types:
wW
double [2][2]

variable_types:
xW
double [2][2]


rateSTDP

original_code:
void
rateSTDP(int n, int g, double dt, double R[n][g],
            double W[][g][g], double W_0[g][g], int W_c[g][g])
{
    int t,i,l;
    int tau, ga, gb;
    double sum;
    int wid = 100e-3/dt;
    int step = 10;
    double tau_w = 10;
    double A_n = -.51;
    double A_p = 1.03;
    double tau_n = 0.036;
    double tau_p = 0.014;
    double tau_d = 2e-3;
    double tau_pot = 1e-3;
    int ne_start = wid-tau_d/dt;
    int ne_end = wid + tau_pot/dt;
    int ne_diff = ne_end-ne_start;
    double kernel[2*wid+1];
    for (tau=0; tau<=wid; tau++){
        kernel[tau] = A_n*exp((-0.1+tau*dt)/tau_n);
    }
    for (tau=wid; tau<=2*wid; tau++){
        kernel[tau] = A_p*exp(-dt*(tau-wid)/tau_p);
    }
    for (tau=ne_start; tau<ne_end; tau++){
        kernel[tau] = kernel[ne_start]+(kernel[ne_end]-kernel[ne_start])*(tau-ne_start)/ne_diff;
    }
    for (ga=0; ga<g; ga++){
        for (gb=0; gb<g; gb++){
            W[0][ga][gb] = W_0[ga][gb];
        }
    }
    for (t=step; t<n; t+=step){
      i = t/step;
      l = i-1;
      for (ga=0; ga<g; ga++){ for (gb=0; gb<g; gb++){
        if ( t-wid < 0 || t+wid >= n ){
          W[i][ga][gb] = W[l][ga][gb];
        } else {
          if ( W_c[ga][gb] ){
            sum = 0;
            for (tau=0; tau<=wid; tau++){
                sum += kernel[tau]*R[t][ga]*R[t+tau-wid][gb]*dt;
            }
            for (tau=0; tau<=wid; tau++){
                sum += kernel[tau+wid]*R[t][gb]*R[t-tau][ga]*dt;
            }
            W[i][ga][gb] = W[l][ga][gb] + sum*dt/tau_w;
          } else {
            W[i][ga][gb] = W[l][ga][gb];
          }
        }
      }}
    }
}

canonical_original_code:
void rateSTDP(int n, int g, double dt, double R[-1][-1], double W[][-1][-1], double W_0[-1][-1], int W_c[-1][-1])
{
    int t; int i; int l;
    int tau; int ga; int gb;
    double sum;
    int wid = 100e-3/dt;
    int step = 10;
    double tau_w = 10;
    double A_n = -.51;
    double A_p = 1.03;
    double tau_n = 0.036;
    double tau_p = 0.014;
    double tau_d = 2e-3;
    double tau_pot = 1e-3;
    int ne_start = wid-tau_d/dt;
    int ne_end = wid + tau_pot/dt;
    int ne_diff = ne_end-ne_start;
    double kernel[-1];
    for (tau=0; tau<=wid; tau++){
        kernel[tau] = A_n*exp((-0.1+tau*dt)/tau_n);
    }
    for (tau=wid; tau<=2*wid; tau++){
        kernel[tau] = A_p*exp(-dt*(tau-wid)/tau_p);
    }
    for (tau=ne_start; tau<ne_end; tau++){
        kernel[tau] = kernel[ne_start]+(kernel[ne_end]-kernel[ne_start])*(tau-ne_start)/ne_diff;
    }
    for (ga=0; ga<g; ga++){
        for (gb=0; gb<g; gb++){
            W[0][ga][gb] = W_0[ga][gb];
        }
    }
    for (t=step; t<n; t+=step){
      i = t/step;
      l = i-1;
      for (ga=0; ga<g; ga++){ for (gb=0; gb<g; gb++){
        if ( t-wid < 0 || t+wid >= n ){
          W[i][ga][gb] = W[l][ga][gb];
        } else {
          if ( W_c[ga][gb] ){
            sum = 0;
            for (tau=0; tau<=wid; tau++){
                sum += kernel[tau]*R[t][ga]*R[t+tau-wid][gb]*dt;
            }
            for (tau=0; tau<=wid; tau++){
                sum += kernel[tau+wid]*R[t][gb]*R[t-tau][ga]*dt;
            }
            W[i][ga][gb] = W[l][ga][gb] + sum*dt/tau_w;
          } else {
            W[i][ga][gb] = W[l][ga][gb];
          }
        }
      }}
    }
}

variable_types: n int

variable_types: g int

variable_types: i int

variable_types: tau int

variable_types: ga int

variable_types: gb int

variable_types: sum double

variable_types: wid int

variable_types: step int

variable_types:
kernel
double [-1]


original_code:
void
*Learned_Synchrony_worker(void *arg)
{
    THREAD_DAT_1D * in = arg;
    printf("Starting thread %d...\n", in->id);
    int n=9999, no=2;
    double dt=0.0001;
    int i,j;
    int res = in->res;
    double wW[2][2];
        wW[0][0]=2; wW[0][1]=2.873;
        wW[1][0]=-2.873; wW[1][1]=-2;
    double ei=0.3, ie=-0.5, ii=0;
    double ee=in->DATA_IN[0];
    int p=1000;
    double lp_rates[p][2];
    get_last_period(&p, lp_rates, wW);
    double Re[n][no];
    double R_i[no][2];
    double pds[no][no];
    int numtrials = 300;
    double thesum;
    for (i=in->a; i<in->b; i++){
        R_i[0][0] = lp_rates[0][0];
        R_i[0][1] = lp_rates[0][1];
        R_i[1][0] = lp_rates[i*p/res][0];
        R_i[1][1] = lp_rates[i*p/res][1];
        thesum = 0;
        for (j=0; j<numtrials; j++){
            pingRateN(n,no,Re,R_i,ee,ei,ie,ii,wW,dt);
            phdiff2(n, no, Re, pds);
            thesum += pds[0][1];
        }
        in->DATA[i] = thesum/numtrials;
    }
}

canonical_original_code:
void *Learned_Synchrony_worker(void *arg)
{
    struct THREAD_DAT_1D *in = arg;
    printf("Starting thread %d...\n", in->id);
    int n = 9999; int no = 2;
    double dt = 0.0001;
    int i; int j;
    int res = in->res;
    double wW[2][2];
        wW[0][0]=2; wW[0][1]=2.873;
        wW[1][0]=-2.873; wW[1][1]=-2;
    double ei = 0.3; double ie = -0.5; double ii = 0;
    double ee = in->DATA_IN[0];
    int p = 1000;
    double lp_rates[-1][2];
    get_last_period(&p, lp_rates, wW);
    double Re[-1][-1];
    double R_i[-1][2];
    double pds[-1][-1];
    int numtrials = 300;
    double thesum;
    for (i=in->a; i<in->b; i++){
        R_i[0][0] = lp_rates[0][0];
        R_i[0][1] = lp_rates[0][1];
        R_i[1][0] = lp_rates[i*p/res][0];
        R_i[1][1] = lp_rates[i*p/res][1];
        thesum = 0;
        for (j=0; j<numtrials; j++){
            pingRateN(n,no,Re,R_i,ee,ei,ie,ii,wW,dt);
            phdiff2(n, no, Re, pds);
            thesum += pds[0][1];
        }
        in->DATA[i] = thesum/numtrials;
    }
}

variable_types:
arg
void *

variable_types: struct THREAD_DAT_1D { int id; int a; int b; int res; double *DATA; double *DATA_IN; } *

variable_types: no int

variable_types: dt double

variable_types: j int

variable_types: res int

variable_types: ei double

variable_types: ie double

variable_types: ii double

variable_types: ee double

variable_types: p int

variable_types:
Re
double [-1][-1]

variable_types:
pds
double [-1][-1]

variable_types: numtrials int

variable_types: thesum double

return_type: void *


decompiled_code:
unsigned __int64 __fastcall plasticPingRateN_recW(int a1, int a2, __int64 a3, __int64 a4, int a5, int a6, double a7, double a8, double a9, double a10, double a11, int a12, int a13, _QWORD *a14, __int64 a15)
{
int v15; // er15
__int64 v17; // rdx
void *v18; // rsp
double v19; // r13
signed __int64 v20; // rax
void *v21; // rsp
__int64 v22; // r12
__int64 v23; // r13
__int64 v24; // rbx
int v25; // eax
double v26; // xmm0_8
int v27; // eax
double v28; // xmm0_8
int v29; // eax
double v30; // xmm0_8
int v31; // eax
double v32; // xmm0_8
__int64 v33; // r13
void *v34; // rsp
__int64 v35; // rdx
_BYTE *v36; // rax
void *v37; // rsp
_QWORD *v38; // rax
_BYTE *v39; // rdx
void *v40; // rsp
char *v41; // rcx
int v42; // ebx
unsigned __int64 v43; // r14
size_t v44; // r12
signed __int64 v45; // rax
void *v46; // rsp
void *v47; // rsp
char *v48; // rcx
int v49; // ebx
size_t v50; // r14
unsigned __int64 v51; // r12
char *v52; // rdi
__int64 v53; // rdx
int v54; // ebx
size_t v55; // r14
__int64 v56; // r12
double v57; // r12
double v58; // rbx
double v59; // xmm5_8
double v60; // r8
__int64 v61; // xmm3_8
__int64 v62; // xmm4_8
int v63; // edi
double v64; // xmm6_8
int v65; // er14
int v66; // er13
double v67; // r11
int v68; // ecx
double *v69; // rsi
__int64 v70; // rdx
int *v71; // rax
int v72; // er15
double v73; // rdi
int v74; // edi
int v75; // ebx
unsigned __int64 result; // rax
int v77; // er10
__int64 v78; // rdx
int v79; // er11
unsigned __int64 v80; // r9
__int64 v81; // r8
_QWORD *v82; // rsi
int v83; // ecx
__int64 v84; // rax
unsigned __int64 v85; // rdi
void *v86; // rsp
void *v87; // rsp
void *v88; // rsp
void *v89; // rsp
void *v90; // rsp
_BYTE v91[8]; // [rsp+0h] [rbp-120h] BYREF
int v92; // [rsp+8h] [rbp-118h]
int v93; // [rsp+Ch] [rbp-114h]
double v94; // [rsp+10h] [rbp-110h]
double v95; // [rsp+18h] [rbp-108h]
__int64 v96; // [rsp+20h] [rbp-100h]
__int64 v97; // [rsp+28h] [rbp-F8h]
_BYTE *v98; // [rsp+30h] [rbp-F0h]
double v99; // [rsp+38h] [rbp-E8h]
unsigned int v100; // [rsp+40h] [rbp-E0h]
unsigned int v101; // [rsp+44h] [rbp-DCh]
_BYTE *v102; // [rsp+48h] [rbp-D8h]
_BYTE *v103; // [rsp+50h] [rbp-D0h]
_BYTE *v104; // [rsp+58h] [rbp-C8h]
_BYTE *v105; // [rsp+60h] [rbp-C0h]
_BYTE *v106; // [rsp+68h] [rbp-B8h]
_BYTE *v107; // [rsp+70h] [rbp-B0h]
unsigned __int64 v108; // [rsp+78h] [rbp-A8h]
unsigned __int64 v109; // [rsp+80h] [rbp-A0h]
unsigned __int64 v110; // [rsp+88h] [rbp-98h]
_BYTE *v111; // [rsp+90h] [rbp-90h]
__int64 v112; // [rsp+98h] [rbp-88h]
__int64 v113; // [rsp+A0h] [rbp-80h]
unsigned __int64 v114; // [rsp+A8h] [rbp-78h]
unsigned __int64 v115; // [rsp+B0h] [rbp-70h]
__int64 v116; // [rsp+B8h] [rbp-68h]
__int64 v117; // [rsp+C0h] [rbp-60h]
int *v118; // [rsp+C8h] [rbp-58h]
unsigned __int64 v119; // [rsp+D0h] [rbp-50h]
double v120; // [rsp+D8h] [rbp-48h]
double v121; // [rsp+E0h] [rbp-40h]
double v122; // [rsp+E8h] [rbp-38h]

v15 = 2 * a2;
v96 = a3;
v17 = v15 * (__int64)v15;
v97 = a2;
v100 = a2;
v101 = a1;
v116 = 2 * a2;
v118 = (int *)(8 * v17);
v93 = a5;
v92 = a6;
v108 = 8 * v116;
v117 = 4 * v17;
v18 = alloca(8 * v116 * a1);
v113 = *(_QWORD *)&a7;
v119 = 8 * v116 + 15;
v19 = COERCE_DOUBLE(v91);
v20 = 16 * (v119 >> 4);
v112 = *(_QWORD *)&a8;
v21 = alloca(v20);
v95 = a9;
v94 = a10;
v98 = v91;
v99 = a11;
if ( 2 * a2 <= 0 )
{
v86 = alloca(v20);
v102 = v91;
v87 = alloca(v20);
v104 = v91;
v88 = alloca((signed __int64)v118);
v103 = v91;
v89 = alloca((signed __int64)v118);
v106 = v91;
v90 = alloca((signed __int64)v118);
v105 = v91;
v107 = v91;
}
else
{
LODWORD(v114) = 2 * a2;
v22 = 0LL;
LODWORD(v115) = v15 - 1;
*(_QWORD *)&v120 = (unsigned int)v15;
v111 = v91;
do
{
while ( 1 )
{
v23 = v22 & 1;
v24 = a4 + 16LL * ((int)v22 >> 1);
v122 = *(double *)(v24 + 8 * v23);
v25 = rand();
v26 = log((double)v25 * 4.656612873077393e-10) * -2.0;
v121 = v26 < 0.0 ? sqrt(v26) : sqrt(v26);
v27 = rand();
v28 = sin((double)v27 * 4.656612873077393e-10 * 6.283185307179586);
if ( v28 * v121 + v122 >= 0.01 )
break;
*(_QWORD *)&v91[8 * v22++] = LC0;
if ( v22 == *(_QWORD *)&v120 )
goto LABEL_10;
}
v121 = *(double *)(v24 + 8 * v23);
v29 = rand();
v30 = log((double)v29 * 4.656612873077393e-10) * -2.0;
if ( v30 < 0.0 )
v122 = sqrt(v30);
else
v122 = sqrt(v30);
v31 = rand();
v32 = sin((double)v31 * 4.656612873077393e-10 * 6.283185307179586);
*(double *)&v91[8 * v22++] = v122 * v32 + v121;
}
while ( v22 != *(_QWORD *)&v120 );
LABEL_10:
v15 = v114;
v33 = (__int64)v111;
v34 = alloca(v119 & 0xFFFFFFFFFFFFFFF0LL);
v35 = 16LL * (((unsigned int)v115 >> 1) + 1);
v102 = v91;
v36 = v91;
do
{
*(_QWORD *)v36 = LC5;
v36 += 16;
*((_QWORD *)v36 - 1) = LC6;
}
while ( v36 != &v91[v35] );
v37 = alloca(v119 & 0xFFFFFFFFFFFFFFF0LL);
v104 = v91;
v38 = v91;
v39 = &v91[v35];
do
{
*v38 = LC7;
v38 += 2;
*(v38 - 1) = LC0;
}
while ( v38 != (_QWORD *)v39 );
v40 = alloca((signed __int64)v118);
v41 = v91;
*(_QWORD *)&v121 = (char *)v118 + 15;
v42 = 0;
v122 = COERCE_DOUBLE(v91);
v43 = v108;
v103 = v91;
v115 = v108 >> 3;
v44 = 8LL * *(_QWORD *)&v120;
do
{
++v42;
v41 = (char *)memset(v41, 0, v44) + v43;
}
while ( v15 != v42 );
v45 = 16LL * (*(_QWORD *)&v121 >> 4);
v46 = alloca(v45);
v47 = alloca(v45);
v106 = v91;
v105 = v91;
v48 = v91;
*(double *)&v119 = COERCE_DOUBLE(v91);
v121 = COERCE_DOUBLE(v91);
v49 = 0;
v50 = v44;
v51 = v108;
do
{
++v49;
v48 = (char *)memset(v48, 0, v50) + v51;
}
while ( v15 != v49 );
v52 = v91;
v107 = v91;
v118 = (int *)v91;
v53 = 4LL * *(_QWORD *)&v120;
v120 = v121;
v54 = 0;
v55 = v53;
*(_QWORD *)&v121 = (unsigned __int64)(4 * v116) >> 2;
v56 = 4 * v116;
do
{
++v54;
v52 = (char *)memset(v52, 0, v55) + v56;
}
while ( v15 != v54 );
v57 = v121;
v58 = v120;
LODWORD(v117) = 1;
v59 = v95;
v116 = 0LL;
v60 = *(double *)&v119;
v95 = *(double *)&v33;
v111 = (_BYTE *)(8LL * *(_QWORD *)&v121);
v109 = *(_QWORD *)&v120 + v108 + 8;
v61 = v113;
v114 = v115 + 1;
v62 = v112;
v110 = 16 * v115;
v63 = 0;
v64 = v94;
v65 = v92;
v66 = v93;
v67 = v122;
do
{
v68 = 0;
v69 = (double *)(v116 + v109);
*(_QWORD *)&v120 = (int)v117;
v112 = (int)v117 * v114;
v70 = v116;
v121 = v60;
v113 = v115 * (int)v117;
v71 = v118;
v122 = COERCE_DOUBLE(__PAIR64__(HIDWORD(v118), v15));
v72 = v63;
do
{
if ( v68 == v72 )
{
v119 = v68;
v85 = *(_QWORD *)&v120 + v115 * v68;
*(_QWORD *)(*(_QWORD *)&v58 + 8 * v68 * v114) = *a14;
*(_QWORD *)(*(_QWORD *)&v58 + 8 * v85) = a14[1];
*(_QWORD *)(*(_QWORD *)&v58 + 8 * (v113 + v119)) = a14[2];
*(_QWORD *)(*(_QWORD *)&v58 + 8 * v112) = a14[3];
}
else
{
*v71 = v66;
v73 = v121;
v71[1] = v65;
v71[*(_QWORD *)&v57] = a12;
v71[*(_QWORD *)&v57 + 1] = a13;
*(_QWORD *)(*(_QWORD *)&v58 + v70) = v61;
*(_QWORD *)(*(_QWORD *)&v58 + v70 + 8) = v62;
*(_QWORD *)(*(_QWORD *)&v73 + v70) = LC8;
*(_QWORD *)(*(_QWORD *)&v67 + v70) = LC9;
*(v69 - 1) = v59;
*v69 = v64;
}
v68 += 2;
v71 += 2;
v69 += 2;
v70 += 16LL;
}
while ( SLODWORD(v122) > v68 );
v74 = v72;
v15 = LODWORD(v122);
v63 = v74 + 2;
v118 = (int *)((char *)v118 + (_QWORD)v111);
v60 = v121;
LODWORD(v117) = v117 + 2;
v116 += v110;
}
while ( SLODWORD(v122) > v63 );
v19 = v95;
}
v75 = v101;
plasticRateN_recW(
(unsigned int)v15,
v101,
*(_QWORD *)&v19,
v98,
a15,
v107,
5000.0,
500.0,
v99,
v106,
v105,
v103,
v102,
v104);
result = v100;
if ( (int)v100 > 0 )
{
result = 2 * v100;
v77 = 0;
v78 = v96;
v79 = 2 * v100;
v80 = v108 >> 3;
v81 = 8 * v97;
do
{
v82 = (_QWORD *)v78;
v83 = 0;
if ( v75 > 0 )
{
do
{
v84 = v83++;
result = v77 + v80 * v84;
*v82 = *(_QWORD *)(*(_QWORD *)&v19 + 8 * result);
v82 = (_QWORD *)((char *)v82 + v81);
}
while ( v75 != v83 );
}
v77 += 2;
v78 += 8LL;
}
while ( v79 != v77 );
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func0(int a1, int a2, __int64 a3, __int64 a4, int a5, int a6, double a7, double a8, double a9, double a10, double a11, int a12, int a13, _QWORD *a14, __int64 a15)
{
int v15; // er15
__int64 v17; // rdx
void *v18; // rsp
double v19; // r13
signed __int64 v20; // rax
void *v21; // rsp
__int64 v22; // r12
__int64 v23; // r13
__int64 v24; // rbx
int v25; // eax
double v26; // xmm0_8
int v27; // eax
double v28; // xmm0_8
int v29; // eax
double v30; // xmm0_8
int v31; // eax
double v32; // xmm0_8
__int64 v33; // r13
void *v34; // rsp
__int64 v35; // rdx
_BYTE *v36; // rax
void *v37; // rsp
_QWORD *v38; // rax
_BYTE *v39; // rdx
void *v40; // rsp
char *v41; // rcx
int v42; // ebx
unsigned __int64 v43; // r14
size_t v44; // r12
signed __int64 v45; // rax
void *v46; // rsp
void *v47; // rsp
char *v48; // rcx
int v49; // ebx
size_t v50; // r14
unsigned __int64 v51; // r12
char *v52; // rdi
__int64 v53; // rdx
int v54; // ebx
size_t v55; // r14
__int64 v56; // r12
double v57; // r12
double v58; // rbx
double v59; // xmm5_8
double v60; // r8
__int64 v61; // xmm3_8
__int64 v62; // xmm4_8
int v63; // edi
double v64; // xmm6_8
int v65; // er14
int v66; // er13
double v67; // r11
int v68; // ecx
double *v69; // rsi
__int64 v70; // rdx
int *v71; // rax
int v72; // er15
double v73; // rdi
int v74; // edi
int v75; // ebx
unsigned __int64 result; // rax
int v77; // er10
__int64 v78; // rdx
int v79; // er11
unsigned __int64 v80; // r9
__int64 v81; // r8
_QWORD *v82; // rsi
int v83; // ecx
__int64 v84; // rax
unsigned __int64 v85; // rdi
void *v86; // rsp
void *v87; // rsp
void *v88; // rsp
void *v89; // rsp
void *v90; // rsp
_BYTE v91[8]; // [rsp+0h] [rbp-120h] BYREF
int v92; // [rsp+8h] [rbp-118h]
int v93; // [rsp+Ch] [rbp-114h]
double v94; // [rsp+10h] [rbp-110h]
double v95; // [rsp+18h] [rbp-108h]
__int64 v96; // [rsp+20h] [rbp-100h]
__int64 v97; // [rsp+28h] [rbp-F8h]
_BYTE *v98; // [rsp+30h] [rbp-F0h]
double v99; // [rsp+38h] [rbp-E8h]
unsigned int v100; // [rsp+40h] [rbp-E0h]
unsigned int v101; // [rsp+44h] [rbp-DCh]
_BYTE *v102; // [rsp+48h] [rbp-D8h]
_BYTE *v103; // [rsp+50h] [rbp-D0h]
_BYTE *v104; // [rsp+58h] [rbp-C8h]
_BYTE *v105; // [rsp+60h] [rbp-C0h]
_BYTE *v106; // [rsp+68h] [rbp-B8h]
_BYTE *v107; // [rsp+70h] [rbp-B0h]
unsigned __int64 v108; // [rsp+78h] [rbp-A8h]
unsigned __int64 v109; // [rsp+80h] [rbp-A0h]
unsigned __int64 v110; // [rsp+88h] [rbp-98h]
_BYTE *v111; // [rsp+90h] [rbp-90h]
__int64 v112; // [rsp+98h] [rbp-88h]
__int64 v113; // [rsp+A0h] [rbp-80h]
unsigned __int64 v114; // [rsp+A8h] [rbp-78h]
unsigned __int64 v115; // [rsp+B0h] [rbp-70h]
__int64 v116; // [rsp+B8h] [rbp-68h]
__int64 v117; // [rsp+C0h] [rbp-60h]
int *v118; // [rsp+C8h] [rbp-58h]
unsigned __int64 v119; // [rsp+D0h] [rbp-50h]
double v120; // [rsp+D8h] [rbp-48h]
double v121; // [rsp+E0h] [rbp-40h]
double v122; // [rsp+E8h] [rbp-38h]

v15 = 2 * a2;
v96 = a3;
v17 = v15 * (__int64)v15;
v97 = a2;
v100 = a2;
v101 = a1;
v116 = 2 * a2;
v118 = (int *)(8 * v17);
v93 = a5;
v92 = a6;
v108 = 8 * v116;
v117 = 4 * v17;
v18 = alloca(8 * v116 * a1);
v113 = *(_QWORD *)&a7;
v119 = 8 * v116 + 15;
v19 = COERCE_DOUBLE(v91);
v20 = 16 * (v119 >> 4);
v112 = *(_QWORD *)&a8;
v21 = alloca(v20);
v95 = a9;
v94 = a10;
v98 = v91;
v99 = a11;
if ( 2 * a2 <= 0 )
{
v86 = alloca(v20);
v102 = v91;
v87 = alloca(v20);
v104 = v91;
v88 = alloca((signed __int64)v118);
v103 = v91;
v89 = alloca((signed __int64)v118);
v106 = v91;
v90 = alloca((signed __int64)v118);
v105 = v91;
v107 = v91;
}
else
{
LODWORD(v114) = 2 * a2;
v22 = 0LL;
LODWORD(v115) = v15 - 1;
*(_QWORD *)&v120 = (unsigned int)v15;
v111 = v91;
do
{
while ( 1 )
{
v23 = v22 & 1;
v24 = a4 + 16LL * ((int)v22 >> 1);
v122 = *(double *)(v24 + 8 * v23);
v25 = rand();
v26 = log((double)v25 * 4.656612873077393e-10) * -2.0;
v121 = v26 < 0.0 ? sqrt(v26) : sqrt(v26);
v27 = rand();
v28 = sin((double)v27 * 4.656612873077393e-10 * 6.283185307179586);
if ( v28 * v121 + v122 >= 0.01 )
break;
*(_QWORD *)&v91[8 * v22++] = LC0;
if ( v22 == *(_QWORD *)&v120 )
goto LABEL_10;
}
v121 = *(double *)(v24 + 8 * v23);
v29 = rand();
v30 = log((double)v29 * 4.656612873077393e-10) * -2.0;
if ( v30 < 0.0 )
v122 = sqrt(v30);
else
v122 = sqrt(v30);
v31 = rand();
v32 = sin((double)v31 * 4.656612873077393e-10 * 6.283185307179586);
*(double *)&v91[8 * v22++] = v122 * v32 + v121;
}
while ( v22 != *(_QWORD *)&v120 );
LABEL_10:
v15 = v114;
v33 = (__int64)v111;
v34 = alloca(v119 & 0xFFFFFFFFFFFFFFF0LL);
v35 = 16LL * (((unsigned int)v115 >> 1) + 1);
v102 = v91;
v36 = v91;
do
{
*(_QWORD *)v36 = LC5;
v36 += 16;
*((_QWORD *)v36 - 1) = LC6;
}
while ( v36 != &v91[v35] );
v37 = alloca(v119 & 0xFFFFFFFFFFFFFFF0LL);
v104 = v91;
v38 = v91;
v39 = &v91[v35];
do
{
*v38 = LC7;
v38 += 2;
*(v38 - 1) = LC0;
}
while ( v38 != (_QWORD *)v39 );
v40 = alloca((signed __int64)v118);
v41 = v91;
*(_QWORD *)&v121 = (char *)v118 + 15;
v42 = 0;
v122 = COERCE_DOUBLE(v91);
v43 = v108;
v103 = v91;
v115 = v108 >> 3;
v44 = 8LL * *(_QWORD *)&v120;
do
{
++v42;
v41 = (char *)memset(v41, 0, v44) + v43;
}
while ( v15 != v42 );
v45 = 16LL * (*(_QWORD *)&v121 >> 4);
v46 = alloca(v45);
v47 = alloca(v45);
v106 = v91;
v105 = v91;
v48 = v91;
*(double *)&v119 = COERCE_DOUBLE(v91);
v121 = COERCE_DOUBLE(v91);
v49 = 0;
v50 = v44;
v51 = v108;
do
{
++v49;
v48 = (char *)memset(v48, 0, v50) + v51;
}
while ( v15 != v49 );
v52 = v91;
v107 = v91;
v118 = (int *)v91;
v53 = 4LL * *(_QWORD *)&v120;
v120 = v121;
v54 = 0;
v55 = v53;
*(_QWORD *)&v121 = (unsigned __int64)(4 * v116) >> 2;
v56 = 4 * v116;
do
{
++v54;
v52 = (char *)memset(v52, 0, v55) + v56;
}
while ( v15 != v54 );
v57 = v121;
v58 = v120;
LODWORD(v117) = 1;
v59 = v95;
v116 = 0LL;
v60 = *(double *)&v119;
v95 = *(double *)&v33;
v111 = (_BYTE *)(8LL * *(_QWORD *)&v121);
v109 = *(_QWORD *)&v120 + v108 + 8;
v61 = v113;
v114 = v115 + 1;
v62 = v112;
v110 = 16 * v115;
v63 = 0;
v64 = v94;
v65 = v92;
v66 = v93;
v67 = v122;
do
{
v68 = 0;
v69 = (double *)(v116 + v109);
*(_QWORD *)&v120 = (int)v117;
v112 = (int)v117 * v114;
v70 = v116;
v121 = v60;
v113 = v115 * (int)v117;
v71 = v118;
v122 = COERCE_DOUBLE(__PAIR64__(HIDWORD(v118), v15));
v72 = v63;
do
{
if ( v68 == v72 )
{
v119 = v68;
v85 = *(_QWORD *)&v120 + v115 * v68;
*(_QWORD *)(*(_QWORD *)&v58 + 8 * v68 * v114) = *a14;
*(_QWORD *)(*(_QWORD *)&v58 + 8 * v85) = a14[1];
*(_QWORD *)(*(_QWORD *)&v58 + 8 * (v113 + v119)) = a14[2];
*(_QWORD *)(*(_QWORD *)&v58 + 8 * v112) = a14[3];
}
else
{
*v71 = v66;
v73 = v121;
v71[1] = v65;
v71[*(_QWORD *)&v57] = a12;
v71[*(_QWORD *)&v57 + 1] = a13;
*(_QWORD *)(*(_QWORD *)&v58 + v70) = v61;
*(_QWORD *)(*(_QWORD *)&v58 + v70 + 8) = v62;
*(_QWORD *)(*(_QWORD *)&v73 + v70) = LC8;
*(_QWORD *)(*(_QWORD *)&v67 + v70) = LC9;
*(v69 - 1) = v59;
*v69 = v64;
}
v68 += 2;
v71 += 2;
v69 += 2;
v70 += 16LL;
}
while ( SLODWORD(v122) > v68 );
v74 = v72;
v15 = LODWORD(v122);
v63 = v74 + 2;
v118 = (int *)((char *)v118 + (_QWORD)v111);
v60 = v121;
LODWORD(v117) = v117 + 2;
v116 += v110;
}
while ( SLODWORD(v122) > v63 );
v19 = v95;
}
v75 = v101;
plasticRateN_recW(
(unsigned int)v15,
v101,
*(_QWORD *)&v19,
v98,
a15,
v107,
5000.0,
500.0,
v99,
v106,
v105,
v103,
v102,
v104);
result = v100;
if ( (int)v100 > 0 )
{
result = 2 * v100;
v77 = 0;
v78 = v96;
v79 = 2 * v100;
v80 = v108 >> 3;
v81 = 8 * v97;
do
{
v82 = (_QWORD *)v78;
v83 = 0;
if ( v75 > 0 )
{
do
{
v84 = v83++;
result = v77 + v80 * v84;
*v82 = *(_QWORD *)(*(_QWORD *)&v19 + 8 * result);
v82 = (_QWORD *)((char *)v82 + v81);
}
while ( v75 != v83 );
}
v77 += 2;
v78 += 8LL;
}
while ( v79 != v77 );
}
return result;
}

variable_types: n int

variable_types: xEE double

variable_types: xEI double

variable_types: xIE double

variable_types: xII double

variable_types:
wW
double [2][2]

variable_types: g int

variable_types: i int

variable_types: k int

variable_types: l int

variable_types:
gamma
double [-1]

variable_types:
tau
double [-1]

variable_types:
th
double [-1][-1]


plasticPingRateN

decompiled_code:
unsigned __int64 __fastcall plasticPingRateN(int a1, int a2, __int64 a3, __int64 a4, int a5, int a6, double a7, double a8, double a9, double a10, double a11, double a12, double a13, double a14, int a15, int a16, _QWORD *a17, double a18)
{
int v15; // er12
void *v16; // rsp
__int64 *v17; // r13
signed __int64 v18; // rax
void *v19; // rsp
__int64 v20; // r14
__int64 v22; // r12
__int64 v23; // rbx
int v24; // eax
double v25; // xmm0_8
int v26; // eax
double v27; // xmm0_8
int v28; // eax
double v29; // xmm0_8
int v30; // eax
double v31; // xmm0_8
unsigned __int64 v32; // r13
void *v33; // rsp
__int64 v34; // rdx
__int64 *v35; // rax
void *v36; // rsp
__int64 *v37; // rax
__int64 *v38; // rdx
int v39; // er13
void *v40; // rsp
__int64 v41; // r14
__int64 *v42; // rdi
unsigned __int64 v43; // r15
size_t v44; // rbx
unsigned __int64 v45; // r15
void *v46; // rsp
__int64 *v47; // rdi
int v48; // er13
unsigned __int64 v49; // r13
__int64 *v50; // rdi
__int64 v51; // r14
__int64 *v52; // r15
size_t v53; // r14
int v54; // er13
__int64 v55; // rbx
int v56; // er14
__int64 v57; // r9
__int64 v58; // rbx
double v59; // rcx
signed __int64 v60; // r8
__int64 v61; // rdx
__int64 v62; // xmm3_8
double v63; // xmm4_8
double v64; // xmm5_8
double v65; // xmm6_8
int v66; // edi
int v67; // er9
__int64 v69; // rbx
unsigned __int64 v70; // rsi
__int64 v71; // rax
double v72; // rcx
int v73; // er14
unsigned __int64 result; // rax
int v75; // er11
__int64 v76; // rdx
int v77; // ebx
unsigned __int64 v78; // r9
__int64 v79; // r8
_QWORD *v80; // rsi
int v81; // ecx
__int64 v82; // rax
__int64 v83; // r13
__int64 v84; // xmm2_8
void *v85; // rsp
void *v86; // rsp
void *v87; // rsp
void *v88; // rsp
unsigned __int64 v89; // [rsp+0h] [rbp-F0h] BYREF
int v90; // [rsp+8h] [rbp-E8h]
int v91; // [rsp+Ch] [rbp-E4h]
double v92; // [rsp+10h] [rbp-E0h]
double v93; // [rsp+18h] [rbp-D8h]
double v94; // [rsp+20h] [rbp-D0h]
__int64 v95; // [rsp+28h] [rbp-C8h]
__int64 v96; // [rsp+30h] [rbp-C0h]
__int64 v97; // [rsp+38h] [rbp-B8h]
__int64 *v98; // [rsp+40h] [rbp-B0h]
double v99; // [rsp+48h] [rbp-A8h]
unsigned int v100; // [rsp+50h] [rbp-A0h]
unsigned int v101; // [rsp+54h] [rbp-9Ch]
__int64 *v102; // [rsp+58h] [rbp-98h]
__int64 *v103; // [rsp+60h] [rbp-90h]
__int64 *v104; // [rsp+68h] [rbp-88h]
__int64 *v105; // [rsp+70h] [rbp-80h]
__int64 *v106; // [rsp+78h] [rbp-78h]
signed __int64 v107; // [rsp+80h] [rbp-70h]
__int64 v108; // [rsp+88h] [rbp-68h]
unsigned __int64 v109; // [rsp+90h] [rbp-60h]
double v110; // [rsp+98h] [rbp-58h]
double v111; // [rsp+A0h] [rbp-50h]
double v112; // [rsp+A8h] [rbp-48h]
unsigned __int64 v113; // [rsp+B0h] [rbp-40h]
double v114; // [rsp+B8h] [rbp-38h]
_QWORD *v115; // [rsp+110h] [rbp+20h]

v15 = 2 * a2;
v96 = a3;
v97 = a2;
*(_QWORD *)&v110 = 2 * a2;
v113 = 8LL * *(_QWORD *)&v110;
v101 = a1;
v100 = a2;
v16 = alloca(8 * *(_QWORD *)&v110 * a1);
v109 = 8LL * *(_QWORD *)&v110 + 15;
v17 = (__int64 *)&v89;
v18 = 16 * (v109 >> 4);
v91 = a5;
v19 = alloca(v18);
v90 = a6;
v108 = 4LL * *(_QWORD *)&v110 * *(_QWORD *)&v110;
v98 = (__int64 *)&v89;
v107 = 8LL * *(_QWORD *)&v110 * *(_QWORD *)&v110;
v95 = *(_QWORD *)&a7;
v94 = a8;
v93 = a9;
v92 = a10;
v99 = a11;
if ( 2 * a2 <= 0 )
{
v85 = alloca(v18);
v102 = (__int64 *)&v89;
v86 = alloca(v18);
v103 = (__int64 *)&v89;
v87 = alloca(v107);
v104 = (__int64 *)&v89;
v88 = alloca(v107);
v105 = (__int64 *)&v89;
v106 = (__int64 *)&v89;
}
else
{
v104 = (__int64 *)&v89;
v20 = 0LL;
LODWORD(v106) = v15 - 1;
*(_QWORD *)&v111 = (unsigned int)v15;
LODWORD(v105) = 2 * a2;
do
{
while ( 1 )
{
v22 = v20 & 1;
v23 = a4 + 16LL * ((int)v20 >> 1);
v114 = *(double *)(v23 + 8 * v22);
v24 = rand();
v25 = log((double)v24 * 4.656612873077393e-10) * -2.0;
v112 = v25 < 0.0 ? sqrt(v25) : sqrt(v25);
v26 = rand();
v27 = sin((double)v26 * 4.656612873077393e-10 * 6.283185307179586);
if ( v27 * v112 + v114 >= 0.0 )
break;
*(&v89 + v20++) = 0LL;
if ( v20 == *(_QWORD *)&v111 )
goto LABEL_10;
}
v112 = *(double *)(v23 + 8 * v22);
v28 = rand();
v29 = log((double)v28 * 4.656612873077393e-10) * -2.0;
if ( v29 < 0.0 )
v114 = sqrt(v29);
else
v114 = sqrt(v29);
v30 = rand();
v31 = sin((double)v30 * 4.656612873077393e-10 * 6.283185307179586);
*((double *)&v89 + v20++) = v114 * v31 + v112;
}
while ( v20 != *(_QWORD *)&v111 );
LABEL_10:
v15 = (int)v105;
v32 = (unsigned __int64)v104;
v33 = alloca(v109 & 0xFFFFFFFFFFFFFFF0LL);
v34 = 16LL * (((unsigned int)v106 >> 1) + 1);
v102 = (__int64 *)&v89;
v35 = (__int64 *)&v89;
do
{
*v35 = LC4;
v35 += 2;
*(v35 - 1) = LC5;
}
while ( v35 != (__int64 *)((char *)&v89 + v34) );
v36 = alloca(v109 & 0xFFFFFFFFFFFFFFF0LL);
v103 = (__int64 *)&v89;
v37 = (__int64 *)&v89;
v38 = (__int64 *)((char *)&v89 + v34);
do
{
*v37 = LC6;
v37 += 2;
*(v37 - 1) = LC7;
}
while ( v37 != v38 );
v109 = v32;
v39 = 0;
v40 = alloca(v107);
v41 = v107 + 15;
v42 = (__int64 *)&v89;
v104 = (__int64 *)&v89;
v43 = v113;
v112 = COERCE_DOUBLE(&v89);
*(_QWORD *)&v114 = v113 >> 3;
v44 = 8LL * *(_QWORD *)&v111;
do
{
++v39;
v42 = (__int64 *)((char *)memset(v42, 0, v44) + v43);
}
while ( v15 != v39 );
v45 = v113;
v46 = alloca(v41 & 0xFFFFFFFFFFFFFFF0LL);
v47 = (__int64 *)&v89;
v48 = 0;
v105 = (__int64 *)&v89;
do
{
++v48;
v47 = (__int64 *)((char *)memset(v47, 0, v44) + v45);
}
while ( v15 != v48 );
v49 = v109;
v107 = (signed __int64)&v89;
v50 = (__int64 *)&v89;
v51 = *(_QWORD *)&v111;
v111 = v112;
*(_QWORD *)&v112 = 4LL * *(_QWORD *)&v110;
v52 = (__int64 *)&v89;
v108 = (__int64)&v89;
v53 = 4 * v51;
v106 = (__int64 *)&v89;
v109 = (unsigned __int64)(4LL * *(_QWORD *)&v110) >> 2;
v89 = v49;
v54 = 0;
v55 = 4LL * *(_QWORD *)&v110;
do
{
++v54;
v50 = (__int64 *)((char *)memset(v50, 0, v53) + v55);
}
while ( v15 != v54 );
v56 = 0;
v57 = 8 * v109;
v58 = v108;
v59 = v111;
v111 = a18;
v60 = v107;
v109 = 16 * (*(_QWORD *)&v110 + 1LL);
v61 = *(_QWORD *)&a18;
v108 = v57;
v62 = v95;
v107 = 16LL * *(_QWORD *)&v114;
v95 = v89;
v63 = v94;
v64 = v93;
v65 = v92;
v66 = v91;
v67 = v90;
v69 = *(_QWORD *)&v112 + v58;
do
{
v114 = v59;
v115 = a17;
v70 = v113 + v61;
v71 = 0LL;
do
{
if ( v56 == (_DWORD)(v71 * 2) )
{
v83 = *(_QWORD *)&v111;
**(_QWORD **)&v111 = *v115;
*(_QWORD *)(v83 + 8) = v115[1];
v84 = v115[2];
v112 = v110;
*(_QWORD *)(v83 + 8LL * *(_QWORD *)&v110) = v84;
*(_QWORD *)(v83 + 8LL * *(_QWORD *)&v112 + 8) = v115[3];
}
else
{
LODWORD(v52[v71]) = v66;
v72 = v114;
HIDWORD(v52[v71]) = v67;
*(_DWORD *)(v69 + 2 * v71) = a15;
*(_DWORD *)(v69 + 2 * v71 + 4) = a16;
*(_QWORD *)(v61 + 4 * v71) = v62;
*(double *)(v61 + 4 * v71 + 8) = v63;
*(_QWORD *)(v60 + 4 * v71) = LC8;
*(_QWORD *)(*(_QWORD *)&v72 + 4 * v71) = LC9;
*(double *)(v70 + 4 * v71) = v64;
*(double *)(v70 + 4 * v71 + 8) = v65;
}
++v71;
}
while ( v15 > (int)(v71 * 2) );
v56 += 2;
a17 = v115;
v60 += v107;
*(_QWORD *)&v59 = v107 + *(_QWORD *)&v114;
*(_QWORD *)&v111 += v109;
v52 = (__int64 *)((char *)v52 + v108);
v69 += v108;
v61 = v113 + v70;
}
while ( v15 > v56 );
v17 = (__int64 *)v95;
}
v73 = v101;
plasticRateN((unsigned int)v15, v101, v17, v98, v106, *(_QWORD *)&a18, 100000.0, 1000.0, v99, v105, v104, v102, v103);
result = v100;
if ( (int)v100 > 0 )
{
result = 2 * v100;
v75 = 0;
v76 = v96;
v77 = 2 * v100;
v78 = v113 >> 3;
v79 = 8 * v97;
do
{
v80 = (_QWORD *)v76;
v81 = 0;
if ( v73 > 0 )
{
do
{
v82 = v81++;
result = v75 + v78 * v82;
*v80 = v17[result];
v80 = (_QWORD *)((char *)v80 + v79);
}
while ( v73 != v81 );
}
v75 += 2;
v76 += 8LL;
}
while ( v77 != v75 );
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func0(int a1, int a2, __int64 a3, __int64 a4, int a5, int a6, double a7, double a8, double a9, double a10, double a11, double a12, double a13, double a14, int a15, int a16, _QWORD *a17, double a18)
{
int v15; // er12
void *v16; // rsp
__int64 *v17; // r13
signed __int64 v18; // rax
void *v19; // rsp
__int64 v20; // r14
__int64 v22; // r12
__int64 v23; // rbx
int v24; // eax
double v25; // xmm0_8
int v26; // eax
double v27; // xmm0_8
int v28; // eax
double v29; // xmm0_8
int v30; // eax
double v31; // xmm0_8
unsigned __int64 v32; // r13
void *v33; // rsp
__int64 v34; // rdx
__int64 *v35; // rax
void *v36; // rsp
__int64 *v37; // rax
__int64 *v38; // rdx
int v39; // er13
void *v40; // rsp
__int64 v41; // r14
__int64 *v42; // rdi
unsigned __int64 v43; // r15
size_t v44; // rbx
unsigned __int64 v45; // r15
void *v46; // rsp
__int64 *v47; // rdi
int v48; // er13
unsigned __int64 v49; // r13
__int64 *v50; // rdi
__int64 v51; // r14
__int64 *v52; // r15
size_t v53; // r14
int v54; // er13
__int64 v55; // rbx
int v56; // er14
__int64 v57; // r9
__int64 v58; // rbx
double v59; // rcx
signed __int64 v60; // r8
__int64 v61; // rdx
__int64 v62; // xmm3_8
double v63; // xmm4_8
double v64; // xmm5_8
double v65; // xmm6_8
int v66; // edi
int v67; // er9
__int64 v69; // rbx
unsigned __int64 v70; // rsi
__int64 v71; // rax
double v72; // rcx
int v73; // er14
unsigned __int64 result; // rax
int v75; // er11
__int64 v76; // rdx
int v77; // ebx
unsigned __int64 v78; // r9
__int64 v79; // r8
_QWORD *v80; // rsi
int v81; // ecx
__int64 v82; // rax
__int64 v83; // r13
__int64 v84; // xmm2_8
void *v85; // rsp
void *v86; // rsp
void *v87; // rsp
void *v88; // rsp
unsigned __int64 v89; // [rsp+0h] [rbp-F0h] BYREF
int v90; // [rsp+8h] [rbp-E8h]
int v91; // [rsp+Ch] [rbp-E4h]
double v92; // [rsp+10h] [rbp-E0h]
double v93; // [rsp+18h] [rbp-D8h]
double v94; // [rsp+20h] [rbp-D0h]
__int64 v95; // [rsp+28h] [rbp-C8h]
__int64 v96; // [rsp+30h] [rbp-C0h]
__int64 v97; // [rsp+38h] [rbp-B8h]
__int64 *v98; // [rsp+40h] [rbp-B0h]
double v99; // [rsp+48h] [rbp-A8h]
unsigned int v100; // [rsp+50h] [rbp-A0h]
unsigned int v101; // [rsp+54h] [rbp-9Ch]
__int64 *v102; // [rsp+58h] [rbp-98h]
__int64 *v103; // [rsp+60h] [rbp-90h]
__int64 *v104; // [rsp+68h] [rbp-88h]
__int64 *v105; // [rsp+70h] [rbp-80h]
__int64 *v106; // [rsp+78h] [rbp-78h]
signed __int64 v107; // [rsp+80h] [rbp-70h]
__int64 v108; // [rsp+88h] [rbp-68h]
unsigned __int64 v109; // [rsp+90h] [rbp-60h]
double v110; // [rsp+98h] [rbp-58h]
double v111; // [rsp+A0h] [rbp-50h]
double v112; // [rsp+A8h] [rbp-48h]
unsigned __int64 v113; // [rsp+B0h] [rbp-40h]
double v114; // [rsp+B8h] [rbp-38h]
_QWORD *v115; // [rsp+110h] [rbp+20h]

v15 = 2 * a2;
v96 = a3;
v97 = a2;
*(_QWORD *)&v110 = 2 * a2;
v113 = 8LL * *(_QWORD *)&v110;
v101 = a1;
v100 = a2;
v16 = alloca(8 * *(_QWORD *)&v110 * a1);
v109 = 8LL * *(_QWORD *)&v110 + 15;
v17 = (__int64 *)&v89;
v18 = 16 * (v109 >> 4);
v91 = a5;
v19 = alloca(v18);
v90 = a6;
v108 = 4LL * *(_QWORD *)&v110 * *(_QWORD *)&v110;
v98 = (__int64 *)&v89;
v107 = 8LL * *(_QWORD *)&v110 * *(_QWORD *)&v110;
v95 = *(_QWORD *)&a7;
v94 = a8;
v93 = a9;
v92 = a10;
v99 = a11;
if ( 2 * a2 <= 0 )
{
v85 = alloca(v18);
v102 = (__int64 *)&v89;
v86 = alloca(v18);
v103 = (__int64 *)&v89;
v87 = alloca(v107);
v104 = (__int64 *)&v89;
v88 = alloca(v107);
v105 = (__int64 *)&v89;
v106 = (__int64 *)&v89;
}
else
{
v104 = (__int64 *)&v89;
v20 = 0LL;
LODWORD(v106) = v15 - 1;
*(_QWORD *)&v111 = (unsigned int)v15;
LODWORD(v105) = 2 * a2;
do
{
while ( 1 )
{
v22 = v20 & 1;
v23 = a4 + 16LL * ((int)v20 >> 1);
v114 = *(double *)(v23 + 8 * v22);
v24 = rand();
v25 = log((double)v24 * 4.656612873077393e-10) * -2.0;
v112 = v25 < 0.0 ? sqrt(v25) : sqrt(v25);
v26 = rand();
v27 = sin((double)v26 * 4.656612873077393e-10 * 6.283185307179586);
if ( v27 * v112 + v114 >= 0.0 )
break;
*(&v89 + v20++) = 0LL;
if ( v20 == *(_QWORD *)&v111 )
goto LABEL_10;
}
v112 = *(double *)(v23 + 8 * v22);
v28 = rand();
v29 = log((double)v28 * 4.656612873077393e-10) * -2.0;
if ( v29 < 0.0 )
v114 = sqrt(v29);
else
v114 = sqrt(v29);
v30 = rand();
v31 = sin((double)v30 * 4.656612873077393e-10 * 6.283185307179586);
*((double *)&v89 + v20++) = v114 * v31 + v112;
}
while ( v20 != *(_QWORD *)&v111 );
LABEL_10:
v15 = (int)v105;
v32 = (unsigned __int64)v104;
v33 = alloca(v109 & 0xFFFFFFFFFFFFFFF0LL);
v34 = 16LL * (((unsigned int)v106 >> 1) + 1);
v102 = (__int64 *)&v89;
v35 = (__int64 *)&v89;
do
{
*v35 = LC4;
v35 += 2;
*(v35 - 1) = LC5;
}
while ( v35 != (__int64 *)((char *)&v89 + v34) );
v36 = alloca(v109 & 0xFFFFFFFFFFFFFFF0LL);
v103 = (__int64 *)&v89;
v37 = (__int64 *)&v89;
v38 = (__int64 *)((char *)&v89 + v34);
do
{
*v37 = LC6;
v37 += 2;
*(v37 - 1) = LC7;
}
while ( v37 != v38 );
v109 = v32;
v39 = 0;
v40 = alloca(v107);
v41 = v107 + 15;
v42 = (__int64 *)&v89;
v104 = (__int64 *)&v89;
v43 = v113;
v112 = COERCE_DOUBLE(&v89);
*(_QWORD *)&v114 = v113 >> 3;
v44 = 8LL * *(_QWORD *)&v111;
do
{
++v39;
v42 = (__int64 *)((char *)memset(v42, 0, v44) + v43);
}
while ( v15 != v39 );
v45 = v113;
v46 = alloca(v41 & 0xFFFFFFFFFFFFFFF0LL);
v47 = (__int64 *)&v89;
v48 = 0;
v105 = (__int64 *)&v89;
do
{
++v48;
v47 = (__int64 *)((char *)memset(v47, 0, v44) + v45);
}
while ( v15 != v48 );
v49 = v109;
v107 = (signed __int64)&v89;
v50 = (__int64 *)&v89;
v51 = *(_QWORD *)&v111;
v111 = v112;
*(_QWORD *)&v112 = 4LL * *(_QWORD *)&v110;
v52 = (__int64 *)&v89;
v108 = (__int64)&v89;
v53 = 4 * v51;
v106 = (__int64 *)&v89;
v109 = (unsigned __int64)(4LL * *(_QWORD *)&v110) >> 2;
v89 = v49;
v54 = 0;
v55 = 4LL * *(_QWORD *)&v110;
do
{
++v54;
v50 = (__int64 *)((char *)memset(v50, 0, v53) + v55);
}
while ( v15 != v54 );
v56 = 0;
v57 = 8 * v109;
v58 = v108;
v59 = v111;
v111 = a18;
v60 = v107;
v109 = 16 * (*(_QWORD *)&v110 + 1LL);
v61 = *(_QWORD *)&a18;
v108 = v57;
v62 = v95;
v107 = 16LL * *(_QWORD *)&v114;
v95 = v89;
v63 = v94;
v64 = v93;
v65 = v92;
v66 = v91;
v67 = v90;
v69 = *(_QWORD *)&v112 + v58;
do
{
v114 = v59;
v115 = a17;
v70 = v113 + v61;
v71 = 0LL;
do
{
if ( v56 == (_DWORD)(v71 * 2) )
{
v83 = *(_QWORD *)&v111;
**(_QWORD **)&v111 = *v115;
*(_QWORD *)(v83 + 8) = v115[1];
v84 = v115[2];
v112 = v110;
*(_QWORD *)(v83 + 8LL * *(_QWORD *)&v110) = v84;
*(_QWORD *)(v83 + 8LL * *(_QWORD *)&v112 + 8) = v115[3];
}
else
{
LODWORD(v52[v71]) = v66;
v72 = v114;
HIDWORD(v52[v71]) = v67;
*(_DWORD *)(v69 + 2 * v71) = a15;
*(_DWORD *)(v69 + 2 * v71 + 4) = a16;
*(_QWORD *)(v61 + 4 * v71) = v62;
*(double *)(v61 + 4 * v71 + 8) = v63;
*(_QWORD *)(v60 + 4 * v71) = LC8;
*(_QWORD *)(*(_QWORD *)&v72 + 4 * v71) = LC9;
*(double *)(v70 + 4 * v71) = v64;
*(double *)(v70 + 4 * v71 + 8) = v65;
}
++v71;
}
while ( v15 > (int)(v71 * 2) );
v56 += 2;
a17 = v115;
v60 += v107;
*(_QWORD *)&v59 = v107 + *(_QWORD *)&v114;
*(_QWORD *)&v111 += v109;
v52 = (__int64 *)((char *)v52 + v108);
v69 += v108;
v61 = v113 + v70;
}
while ( v15 > v56 );
v17 = (__int64 *)v95;
}
v73 = v101;
plasticRateN((unsigned int)v15, v101, v17, v98, v106, *(_QWORD *)&a18, 100000.0, 1000.0, v99, v105, v104, v102, v103);
result = v100;
if ( (int)v100 > 0 )
{
result = 2 * v100;
v75 = 0;
v76 = v96;
v77 = 2 * v100;
v78 = v113 >> 3;
v79 = 8 * v97;
do
{
v80 = (_QWORD *)v76;
v81 = 0;
if ( v73 > 0 )
{
do
{
v82 = v81++;
result = v75 + v78 * v82;
*v80 = v17[result];
v80 = (_QWORD *)((char *)v80 + v79);
}
while ( v73 != v81 );
}
v75 += 2;
v76 += 8LL;
}
while ( v77 != v75 );
}
return result;
}

variable_types: no int

variable_types:
Re
double [-1][-1]

variable_types: dt double

variable_types: j int


pingRateN

decompiled_code:
unsigned __int64 __fastcall pingRateN(int a1, int a2, __int64 a3, __int64 a4, __int64 a5, double a6, double a7, double a8, double a9, double a10)
{
int v10; // er15
int v11; // er14
void *v12; // rsp
_BYTE *v13; // rbx
signed __int64 v14; // rdx
void *v15; // rsp
_BYTE *v16; // rax
__int64 v17; // rdx
void *v18; // rsp
_QWORD *v19; // rax
_BYTE *v20; // rdx
void *v22; // rsp
__int64 v23; // r12
__int64 v24; // r13
__int64 v25; // rbx
int v26; // eax
double v27; // xmm0_8
int v28; // eax
double v29; // xmm0_8
int v30; // eax
double v31; // xmm0_8
int v32; // eax
double v33; // xmm0_8
int v34; // esi
double v35; // xmm5_8
unsigned __int64 v36; // rcx
double v37; // xmm1_8
double *v38; // r11
double v39; // xmm2_8
double v40; // xmm3_8
_QWORD *v41; // r12
int v42; // ebx
double *v43; // rax
int v44; // edx
__int64 v45; // r13
__int64 v46; // rdi
unsigned __int64 result; // rax
int v48; // er10
__int64 v49; // rdx
int v50; // er11
unsigned __int64 v51; // r9
__int64 v52; // r8
_QWORD *v53; // rsi
int v54; // ecx
__int64 v55; // rax
void *v56; // rsp
void *v57; // rsp
_BYTE v58[8]; // [rsp+0h] [rbp-D0h] BYREF
_BYTE *v59; // [rsp+8h] [rbp-C8h]
_QWORD *v60; // [rsp+10h] [rbp-C0h]
double v61; // [rsp+18h] [rbp-B8h]
double v62; // [rsp+20h] [rbp-B0h]
double v63; // [rsp+28h] [rbp-A8h]
double v64; // [rsp+30h] [rbp-A0h]
_BYTE *v65; // [rsp+38h] [rbp-98h]
__int64 v66; // [rsp+40h] [rbp-90h]
__int64 v67; // [rsp+48h] [rbp-88h]
_BYTE *v68; // [rsp+50h] [rbp-80h]
double v69; // [rsp+58h] [rbp-78h]
int v70; // [rsp+60h] [rbp-70h]
unsigned int v71; // [rsp+64h] [rbp-6Ch]
_BYTE *v72; // [rsp+68h] [rbp-68h]
__int64 v73; // [rsp+70h] [rbp-60h]
_BYTE *v74; // [rsp+78h] [rbp-58h]
unsigned __int64 v75; // [rsp+80h] [rbp-50h]
__int64 v76; // [rsp+88h] [rbp-48h]
double v77; // [rsp+90h] [rbp-40h]
double v78; // [rsp+98h] [rbp-38h]

v10 = 2 * a2;
v11 = a1;
v66 = a3;
v67 = a2;
v71 = a2;
v75 = 16LL * a2;
v69 = a10;
v12 = alloca(8 * 2 * a2 * (__int64)a1);
v13 = v58;
v73 = 8 * v10 * (__int64)v10;
v14 = 16 * ((v75 + 15) >> 4);
v15 = alloca(v14);
v68 = v58;
if ( 2 * a2 <= 0 )
{
v56 = alloca(v14);
v72 = v58;
v57 = alloca(v14);
v74 = v58;
v76 = (__int64)v58;
}
else
{
v16 = v58;
v17 = 16LL * (((unsigned int)(v10 - 1) >> 1) + 1);
do
{
*(_QWORD *)v16 = LC1;
v16 += 16;
*((_QWORD *)v16 - 1) = LC2;
}
while ( v16 != &v58[v17] );
v18 = alloca(8LL * v10);
v72 = v58;
v19 = v58;
v20 = &v58[v17];
do
{
*v19 = LC3;
v19 += 2;
*(v19 - 1) = LC4;
}
while ( v19 != (_QWORD *)v20 );
v70 = a1;
v22 = alloca(8LL * v10);
v76 = (unsigned int)v10;
LODWORD(v65) = 2 * a2;
v60 = (_QWORD *)a5;
v23 = 0LL;
v74 = v58;
v59 = v58;
v64 = a6;
v63 = a7;
v62 = a8;
v61 = a9;
do
{
while ( 1 )
{
v24 = v23 & 1;
v25 = a4 + 16LL * ((int)v23 >> 1);
v78 = *(double *)(v25 + 8 * v24);
v26 = rand();
v27 = log((double)v26 * 4.656612873077393e-10) * -2.0;
v77 = v27 < 0.0 ? sqrt(v27) : sqrt(v27);
v28 = rand();
v29 = sin((double)v28 * 4.656612873077393e-10 * 6.283185307179586);
if ( v29 * v77 + v78 >= 0.0 )
break;
*(_QWORD *)&v58[8 * v23++] = 0LL;
if ( v23 == v76 )
goto LABEL_14;
}
v77 = *(double *)(v25 + 8 * v24);
v30 = rand();
v31 = log((double)v30 * 4.656612873077393e-10) * -2.0;
if ( v31 < 0.0 )
v78 = sqrt(v31);
else
v78 = sqrt(v31);
v32 = rand();
v33 = sin((double)v32 * 4.656612873077393e-10 * 6.283185307179586);
*(double *)&v58[8 * v23++] = v78 * v33 + v77;
}
while ( v23 != v76 );
LABEL_14:
v34 = 0;
v76 = (__int64)v58;
v35 = v64;
v36 = v75 >> 3;
*(_QWORD *)&v77 = 2 * v75;
v37 = v63;
v38 = (double *)v58;
LODWORD(v73) = v70;
v39 = v62;
*(_QWORD *)&v78 = (v75 >> 3) + 1;
v40 = v61;
v41 = v60;
v10 = (int)v65;
v65 = v59;
v42 = 1;
do
{
v43 = v38;
v44 = 0;
v45 = v42 * *(_QWORD *)&v78;
do
{
while ( v44 != v34 )
{
v44 += 2;
*v43 = v35;
v43[1] = v37;
v43[v36] = v39;
v43[v36 + 1] = v40;
v43 += 2;
if ( v10 <= v44 )
goto LABEL_19;
}
v46 = v44;
v44 += 2;
v43 += 2;
*(_QWORD *)&v58[8 * v46 * *(_QWORD *)&v78] = *v41;
*(_QWORD *)&v58[8 * v42 + 8 * v36 * v46] = v41[1];
*(_QWORD *)&v58[8 * v36 * v42 + 8 * v46] = v41[2];
*(_QWORD *)&v58[8 * v45] = v41[3];
}
while ( v10 > v44 );
LABEL_19:
v34 += 2;
v42 += 2;
v38 = (double *)((char *)v38 + *(_QWORD *)&v77);
}
while ( v10 > v34 );
v11 = v73;
v13 = v65;
}
rateN((unsigned int)v10, (unsigned int)v11, v13, v74, v76, v68, v69, v72);
result = v71;
if ( (int)v71 > 0 )
{
result = 2 * v71;
v48 = 0;
v49 = v66;
v50 = 2 * v71;
v51 = v75 >> 3;
v52 = 8 * v67;
do
{
v53 = (_QWORD *)v49;
v54 = 0;
if ( v11 > 0 )
{
do
{
v55 = v54++;
result = v48 + v51 * v55;
*v53 = *(_QWORD *)&v13[8 * result];
v53 = (_QWORD *)((char *)v53 + v52);
}
while ( v11 != v54 );
}
v48 += 2;
v49 += 8LL;
}
while ( v50 != v48 );
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func0(int a1, int a2, __int64 a3, __int64 a4, __int64 a5, double a6, double a7, double a8, double a9, double a10)
{
int v10; // er15
int v11; // er14
void *v12; // rsp
_BYTE *v13; // rbx
signed __int64 v14; // rdx
void *v15; // rsp
_BYTE *v16; // rax
__int64 v17; // rdx
void *v18; // rsp
_QWORD *v19; // rax
_BYTE *v20; // rdx
void *v22; // rsp
__int64 v23; // r12
__int64 v24; // r13
__int64 v25; // rbx
int v26; // eax
double v27; // xmm0_8
int v28; // eax
double v29; // xmm0_8
int v30; // eax
double v31; // xmm0_8
int v32; // eax
double v33; // xmm0_8
int v34; // esi
double v35; // xmm5_8
unsigned __int64 v36; // rcx
double v37; // xmm1_8
double *v38; // r11
double v39; // xmm2_8
double v40; // xmm3_8
_QWORD *v41; // r12
int v42; // ebx
double *v43; // rax
int v44; // edx
__int64 v45; // r13
__int64 v46; // rdi
unsigned __int64 result; // rax
int v48; // er10
__int64 v49; // rdx
int v50; // er11
unsigned __int64 v51; // r9
__int64 v52; // r8
_QWORD *v53; // rsi
int v54; // ecx
__int64 v55; // rax
void *v56; // rsp
void *v57; // rsp
_BYTE v58[8]; // [rsp+0h] [rbp-D0h] BYREF
_BYTE *v59; // [rsp+8h] [rbp-C8h]
_QWORD *v60; // [rsp+10h] [rbp-C0h]
double v61; // [rsp+18h] [rbp-B8h]
double v62; // [rsp+20h] [rbp-B0h]
double v63; // [rsp+28h] [rbp-A8h]
double v64; // [rsp+30h] [rbp-A0h]
_BYTE *v65; // [rsp+38h] [rbp-98h]
__int64 v66; // [rsp+40h] [rbp-90h]
__int64 v67; // [rsp+48h] [rbp-88h]
_BYTE *v68; // [rsp+50h] [rbp-80h]
double v69; // [rsp+58h] [rbp-78h]
int v70; // [rsp+60h] [rbp-70h]
unsigned int v71; // [rsp+64h] [rbp-6Ch]
_BYTE *v72; // [rsp+68h] [rbp-68h]
__int64 v73; // [rsp+70h] [rbp-60h]
_BYTE *v74; // [rsp+78h] [rbp-58h]
unsigned __int64 v75; // [rsp+80h] [rbp-50h]
__int64 v76; // [rsp+88h] [rbp-48h]
double v77; // [rsp+90h] [rbp-40h]
double v78; // [rsp+98h] [rbp-38h]

v10 = 2 * a2;
v11 = a1;
v66 = a3;
v67 = a2;
v71 = a2;
v75 = 16LL * a2;
v69 = a10;
v12 = alloca(8 * 2 * a2 * (__int64)a1);
v13 = v58;
v73 = 8 * v10 * (__int64)v10;
v14 = 16 * ((v75 + 15) >> 4);
v15 = alloca(v14);
v68 = v58;
if ( 2 * a2 <= 0 )
{
v56 = alloca(v14);
v72 = v58;
v57 = alloca(v14);
v74 = v58;
v76 = (__int64)v58;
}
else
{
v16 = v58;
v17 = 16LL * (((unsigned int)(v10 - 1) >> 1) + 1);
do
{
*(_QWORD *)v16 = LC1;
v16 += 16;
*((_QWORD *)v16 - 1) = LC2;
}
while ( v16 != &v58[v17] );
v18 = alloca(8LL * v10);
v72 = v58;
v19 = v58;
v20 = &v58[v17];
do
{
*v19 = LC3;
v19 += 2;
*(v19 - 1) = LC4;
}
while ( v19 != (_QWORD *)v20 );
v70 = a1;
v22 = alloca(8LL * v10);
v76 = (unsigned int)v10;
LODWORD(v65) = 2 * a2;
v60 = (_QWORD *)a5;
v23 = 0LL;
v74 = v58;
v59 = v58;
v64 = a6;
v63 = a7;
v62 = a8;
v61 = a9;
do
{
while ( 1 )
{
v24 = v23 & 1;
v25 = a4 + 16LL * ((int)v23 >> 1);
v78 = *(double *)(v25 + 8 * v24);
v26 = rand();
v27 = log((double)v26 * 4.656612873077393e-10) * -2.0;
v77 = v27 < 0.0 ? sqrt(v27) : sqrt(v27);
v28 = rand();
v29 = sin((double)v28 * 4.656612873077393e-10 * 6.283185307179586);
if ( v29 * v77 + v78 >= 0.0 )
break;
*(_QWORD *)&v58[8 * v23++] = 0LL;
if ( v23 == v76 )
goto LABEL_14;
}
v77 = *(double *)(v25 + 8 * v24);
v30 = rand();
v31 = log((double)v30 * 4.656612873077393e-10) * -2.0;
if ( v31 < 0.0 )
v78 = sqrt(v31);
else
v78 = sqrt(v31);
v32 = rand();
v33 = sin((double)v32 * 4.656612873077393e-10 * 6.283185307179586);
*(double *)&v58[8 * v23++] = v78 * v33 + v77;
}
while ( v23 != v76 );
LABEL_14:
v34 = 0;
v76 = (__int64)v58;
v35 = v64;
v36 = v75 >> 3;
*(_QWORD *)&v77 = 2 * v75;
v37 = v63;
v38 = (double *)v58;
LODWORD(v73) = v70;
v39 = v62;
*(_QWORD *)&v78 = (v75 >> 3) + 1;
v40 = v61;
v41 = v60;
v10 = (int)v65;
v65 = v59;
v42 = 1;
do
{
v43 = v38;
v44 = 0;
v45 = v42 * *(_QWORD *)&v78;
do
{
while ( v44 != v34 )
{
v44 += 2;
*v43 = v35;
v43[1] = v37;
v43[v36] = v39;
v43[v36 + 1] = v40;
v43 += 2;
if ( v10 <= v44 )
goto LABEL_19;
}
v46 = v44;
v44 += 2;
v43 += 2;
*(_QWORD *)&v58[8 * v46 * *(_QWORD *)&v78] = *v41;
*(_QWORD *)&v58[8 * v42 + 8 * v36 * v46] = v41[1];
*(_QWORD *)&v58[8 * v36 * v42 + 8 * v46] = v41[2];
*(_QWORD *)&v58[8 * v45] = v41[3];
}
while ( v10 > v44 );
LABEL_19:
v34 += 2;
v42 += 2;
v38 = (double *)((char *)v38 + *(_QWORD *)&v77);
}
while ( v10 > v34 );
v11 = v73;
v13 = v65;
}
rateN((unsigned int)v10, (unsigned int)v11, v13, v74, v76, v68, v69, v72);
result = v71;
if ( (int)v71 > 0 )
{
result = 2 * v71;
v48 = 0;
v49 = v66;
v50 = 2 * v71;
v51 = v75 >> 3;
v52 = 8 * v67;
do
{
v53 = (_QWORD *)v49;
v54 = 0;
if ( v11 > 0 )
{
do
{
v55 = v54++;
result = v48 + v51 * v55;
*v53 = *(_QWORD *)&v13[8 * result];
v53 = (_QWORD *)((char *)v53 + v52);
}
while ( v11 != v54 );
}
v48 += 2;
v49 += 8LL;
}
while ( v50 != v48 );
}
return result;
}

variable_types: n int


original_code:
void *EE_Attractor_worker(void *arg)
{
 printf("Inside string...");
 THREAD_DAT_1D * in = arg;
 printf("%d to %d\n", in->a, in->b);
 int n=9999, no=2;
 double dt=0.0001;
 int i, j, k;
 double ei=0.3;
 double ie=-0.5;
 double ii=0;
 double ee_a=0.1;
 double ee_b=0.3;
 int ee_res=in->res;
 double ee_vec[ee_res];
 linspace(ee_a, ee_b, ee_res, ee_vec);
 int ipd_res = 200;
 int trials = 100;
 double wW[2][2];
  wW[0][0]=2; wW[0][1]=2.873;
  wW[1][0]=-2.873; wW[1][1]=-2;
 int p=1000;
 double lp_rates[p][2];
 get_last_period(&p, lp_rates, wW);
 double Re[n][no];
 double R_i[no][no];
 double pds[no][no];
 double phdiffs[ee_res][ipd_res];
 for (i=in->a; i<in->b; i++){
  printf("T%d: %f percent done\n", in->id, 100*((double) i-in->a)/((double) ee_res-in->a));
  for (j=0; j<ipd_res; j++){
   R_i[0][0]=lp_rates[0][0];
   R_i[0][1]=lp_rates[0][1];
   R_i[1][0]=lp_rates[j*p/ipd_res][0];
   R_i[1][1]=lp_rates[j*p/ipd_res][1];
   in->DATA[i*ee_res+j]=0;
   for (k=0; k<trials; k++){
    pingRateN(n,no,Re,R_i,ee_vec[i],ei,ie,ii,wW,dt);
    phdiff2(n, no, Re, pds);
    in->DATA[i*ee_res+j]=in->DATA[i*ee_res+j]+pds[0][1];
   }
   in->DATA[i*ee_res+j]=in->DATA[i*ee_res+j]/trials;
  }
 }
 pthread_exit(((void *)0));
}

canonical_original_code:
void *EE_Attractor_worker(void *arg)
{
 printf("Inside string...");
 struct THREAD_DAT_1D *in = arg;
 printf("%d to %d\n", in->a, in->b);
 int n = 9999; int no = 2;
 double dt = 0.0001;
 int i; int j; int k;
 double ei = 0.3;
 double ie = -0.5;
 double ii = 0;
 double ee_a = 0.1;
 double ee_b = 0.3;
 int ee_res = in->res;
 double ee_vec[-1];
 linspace(ee_a, ee_b, ee_res, ee_vec);
 int ipd_res = 200;
 int trials = 100;
 double wW[2][2];
  wW[0][0]=2; wW[0][1]=2.873;
  wW[1][0]=-2.873; wW[1][1]=-2;
 int p = 1000;
 double lp_rates[-1][2];
 get_last_period(&p, lp_rates, wW);
 double Re[-1][-1];
 double R_i[-1][-1];
 double pds[-1][-1];
 double phdiffs[-1][-1];
 for (i=in->a; i<in->b; i++){
  printf("T%d: %f percent done\n", in->id, 100*((double) i-in->a)/((double) ee_res-in->a));
  for (j=0; j<ipd_res; j++){
   R_i[0][0]=lp_rates[0][0];
   R_i[0][1]=lp_rates[0][1];
   R_i[1][0]=lp_rates[j*p/ipd_res][0];
   R_i[1][1]=lp_rates[j*p/ipd_res][1];
   in->DATA[i*ee_res+j]=0;
   for (k=0; k<trials; k++){
    pingRateN(n,no,Re,R_i,ee_vec[i],ei,ie,ii,wW,dt);
    phdiff2(n, no, Re, pds);
    in->DATA[i*ee_res+j]=in->DATA[i*ee_res+j]+pds[0][1];
   }
   in->DATA[i*ee_res+j]=in->DATA[i*ee_res+j]/trials;
  }
 }
 pthread_exit(((void *)0));
}

variable_types:
arg
void *

variable_types: struct THREAD_DAT_1D { int id; int a; int b; int res; double *DATA; double *DATA_IN; } *

variable_types: ei double

variable_types: ie double

variable_types: ii double

variable_types: trials int

variable_types: p int

variable_types:
pds
double [-1][-1]

variable_types:
phdiffs
double [-1][-1]


bodyDiff

repo: wisdompilot/parallelComputing

decompiled_code:
double __fastcall bodyDiff(__int64 a1, __int64 a2, int a3)
{
__int64 v3; // rax
double v4; // xmm0_8
double v5; // xmm1_8
double result; // xmm0_8

v3 = a1 + 56LL * a3;
if ( a1 == v3 )
return 0.0;
v4 = *(double *)(a1 + 32) - *(double *)(a2 + 32);
v5 = (*(double *)(a1 + 24) - *(double *)(a2 + 24)) * (*(double *)(a1 + 24) - *(double *)(a2 + 24)) + v4 * v4;
result = 0.0;
do
{
a1 += 56LL;
result = result + v5;
}
while ( a1 != v3 );
return result;
}

canonical_decompiled_code:
double __fastcall func0(__int64 a1, __int64 a2, int a3)
{
__int64 v3; // rax
double v4; // xmm0_8
double v5; // xmm1_8
double result; // xmm0_8

v3 = a1 + 56LL * a3;
if ( a1 == v3 )
return 0.0;
v4 = *(double *)(a1 + 32) - *(double *)(a2 + 32);
v5 = (*(double *)(a1 + 24) - *(double *)(a2 + 24)) * (*(double *)(a1 + 24) - *(double *)(a2 + 24)) + v4 * v4;
result = 0.0;
do
{
a1 += 56LL;
result = result + v5;
}
while ( a1 != v3 );
return result;
}

original_code:
double bodyDiff(Body *a, Body *b, int size){
 Body *i = a, *j = b;
 double squareDiff = 0;
 double dvx, dvy;
 for (i = a; i != a + size; i++){
  dvx = a->velocity.x - b->velocity.x;
  dvy = a->velocity.y - b->velocity.y;
  squareDiff += dvx * dvx + dvy * dvy;
 }
 return squareDiff;
}

canonical_original_code:
double bodyDiff(struct Body *a, struct Body *b, int size){
 struct Body *i = a; struct Body *j = b;
 double squareDiff = 0;
 double dvx; double dvy;
 for (i = a; i != a + size; i++){
  dvx = a->velocity.x - b->velocity.x;
  dvy = a->velocity.y - b->velocity.y;
  squareDiff += dvx * dvx + dvy * dvy;
 }
 return squareDiff;
}

variable_types: struct Body { double mass; struct Vec2 { double x; } position; struct Vec2 velocity; struct Vec2 acceleration; } *

variable_types:
b
struct Body *

variable_types: size int

variable_types: squareDiff double

variable_types: dvx double

variable_types: dvy double

return_type: double

user_defined_types: struct Body { double mass; struct Vec2 position; struct Vec2 velocity; struct Vec2 acceleration; }


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
void *v3; // rbp
void *v4; // r12
double v5; // xmm0_8
__m128i v6; // xmm2
__m128i v8; // [rsp+0h] [rbp-78h] BYREF
__int64 v9; // [rsp+10h] [rbp-68h]
__m128i v10; // [rsp+20h] [rbp-58h] BYREF
__int64 v11; // [rsp+30h] [rbp-48h]
__m128i v12; // [rsp+40h] [rbp-38h] BYREF
__int64 v13; // [rsp+50h] [rbp-28h]

v3 = malloc((size_t)&unk_445C0);
v4 = malloc((size_t)&unk_445C0);
randInit(v3, 0LL, 5000LL);
bodyCopy(v4, v3, 0LL, 5000LL);
getState(&v8, v3, 5000LL);
v10 = _mm_loadu_si128(&v8);
v11 = v9;
nextPhase(v3, 4LL, &forceTable, 0.001);
nextPhaseHalf(v4, 4LL, &forceTable, 0.001);
v5 = bodyDiff((__int64)v3, (__int64)v4, 5000);
printf("diff=%f\n", v5);
getState(&v8, v3, 5000LL);
v6 = _mm_loadu_si128(&v8);
v13 = v9;
v12 = v6;
statePrint(&v10);
statePrint(&v12);
free(v3);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
void *v3; // rbp
void *v4; // r12
double v5; // xmm0_8
__m128i v6; // xmm2
__m128i v8; // [rsp+0h] [rbp-78h] BYREF
__int64 v9; // [rsp+10h] [rbp-68h]
__m128i v10; // [rsp+20h] [rbp-58h] BYREF
__int64 v11; // [rsp+30h] [rbp-48h]
__m128i v12; // [rsp+40h] [rbp-38h] BYREF
__int64 v13; // [rsp+50h] [rbp-28h]

v3 = malloc((size_t)&unk_445C0);
v4 = malloc((size_t)&unk_445C0);
randInit(v3, 0LL, 5000LL);
bodyCopy(v4, v3, 0LL, 5000LL);
getState(&v8, v3, 5000LL);
v10 = _mm_loadu_si128(&v8);
v11 = v9;
nextPhase(v3, 4LL, &forceTable, 0.001);
nextPhaseHalf(v4, 4LL, &forceTable, 0.001);
v5 = func0((__int64)v3, (__int64)v4, 5000);
printf("diff=%f\n", v5);
getState(&v8, v3, 5000LL);
v6 = _mm_loadu_si128(&v8);
v13 = v9;
v12 = v6;
statePrint(&v10);
statePrint(&v12);
free(v3);
return 0;
}

original_code:
int main(int argc, char *argv[]){
 double t0, t1, te;
 Body *bodies = (Body *) malloc (sizeof(Body ) * 5000);
 Body *bodies2 = (Body *) malloc (sizeof(Body ) * 5000);
 Body *bodies3 = (Body *) malloc (sizeof(Body ) * 5000);
 randInit (bodies, 0, 5000);
 bodyCopy(bodies2, bodies, 0, 5000);
 struct BodyState bs0, bsK;
 bs0 = getState(bodies, 5000);
 nextPhase(bodies, 0.001, 4, forceTable);
 nextPhaseHalf(bodies2, 0.001, 4, forceTable);
 double diff = bodyDiff(bodies, bodies2, 5000);
 printf("diff=%f\n", diff);
 bsK = getState(bodies, 5000);
 statePrint(&bs0);
 statePrint(&bsK);
 free(bodies);
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[]){
 double t0; double t1; double te;
 struct Body *bodies = (Body *) malloc (sizeof(Body ) * 5000);
 struct Body *bodies2 = (Body *) malloc (sizeof(Body ) * 5000);
 struct Body *bodies3 = (Body *) malloc (sizeof(Body ) * 5000);
 randInit (bodies, 0, 5000);
 bodyCopy(bodies2, bodies, 0, 5000);
 struct BodyState bs0; struct BodyState bsK;
 bs0 = getState(bodies, 5000);
 nextPhase(bodies, 0.001, 4, forceTable);
 nextPhaseHalf(bodies2, 0.001, 4, forceTable);
 double diff = bodyDiff(bodies, bodies2, 5000);
 printf("diff=%f\n", diff);
 bsK = getState(bodies, 5000);
 statePrint(&bs0);
 statePrint(&bsK);
 free(bodies);
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: te double

variable_types: struct BodyState { double mvx; double energy; }

variable_types: diff double


fastInvSqrtCube

decompiled_code:
double __fastcall fastInvSqrtCube(double a1)
{
return (1.5
- 0.5
* a1
* COERCE_DOUBLE(0x5FE6EB50C7B537A9LL - (*(_QWORD *)&a1 >> 1))
* COERCE_DOUBLE(0x5FE6EB50C7B537A9LL - (*(_QWORD *)&a1 >> 1)))
* COERCE_DOUBLE(0x5FE6EB50C7B537A9LL - (*(_QWORD *)&a1 >> 1))
/ a1;
}

canonical_decompiled_code:
double __fastcall func7(double a1)
{
return (1.5
- 0.5
* a1
* COERCE_DOUBLE(0x5FE6EB50C7B537A9LL - (*(_QWORD *)&a1 >> 1))
* COERCE_DOUBLE(0x5FE6EB50C7B537A9LL - (*(_QWORD *)&a1 >> 1)))
* COERCE_DOUBLE(0x5FE6EB50C7B537A9LL - (*(_QWORD *)&a1 >> 1))
/ a1;
}

original_code:
double fastInvSqrtCube(double number) {
 uint64_t i;
 double x2, y;
 x2 = number * 0.5;
 y = number;
 i = *(uint64_t *) &y;
 i = 0x5fe6eb50c7b537a9 - (i >> 1);
 y = *(double *) &i;
 y = y * (1.5 - (x2 * y * y));
 return y / number;
}

canonical_original_code:
double fastInvSqrtCube(double number) {
 unsigned long i;
 double x2; double y;
 x2 = number * 0.5;
 y = number;
 i = *(unsigned long *) &y;
 i = 0x5fe6eb50c7b537a9 - (i >> 1);
 y = *(double *) &i;
 y = y * (1.5 - (x2 * y * y));
 return y / number;
}

variable_types: number double

variable_types:
i
unsigned long

variable_types: y double


randTest

original_code:
void randTest(Body bodies[], int start, int end){
 int i;
 srand (time(((void *)0)));
 for (i = start; i < end; i++){
  bodies[i].mass = 1;
  bodies[i].position.x = 0.1 * i;
  bodies[i].position.y = 0.1 * i;
  bodies[i].velocity.x = 1;
  bodies[i].velocity.y = 1;
 }
}

canonical_original_code:
void randTest(struct Body bodies[], int start, int end){
 int i;
 srand (time(((void *)0)));
 for (i = start; i < end; i++){
  bodies[i].mass = 1;
  bodies[i].position.x = 0.1 * i;
  bodies[i].position.y = 0.1 * i;
  bodies[i].velocity.x = 1;
  bodies[i].velocity.y = 1;
 }
}

variable_types: struct Body { double mass; struct Vec2 { double x; } position; struct Vec2 velocity; struct Vec2 acceleration; } []

variable_types: start int

variable_types: end int

variable_types: i int


bodiesPrint

decompiled_code:
int __fastcall bodiesPrint(__int64 a1, int a2, int a3)
{
int v4; // ebx
double *v5; // rbp

v4 = a2;
putchar(123);
if ( a2 < a3 )
{
v5 = (double *)(a1 + 40LL * a2 + 16);
do
{
printf("{%f, %f}", *(v5 - 1), *v5);
if ( v4 == a3 - 1 )
break;
++v4;
v5 += 5;
printf(", ");
}
while ( a3 != v4 );
}
return puts("}, ");
}

original_code:
void bodiesPrint(Body bodies[], int start, int end){
 int i;
 printf("{");
 for (i = start; i < end; i++){
  printf("{%f, %f}", bodies[i].position.x, bodies[i].position.y);
  if (i == end - 1)
   break;
  else
   printf(", ");
 }
 printf("}, \n");
}

canonical_original_code:
void bodiesPrint(struct Body bodies[], int start, int end){
 int i;
 printf("{");
 for (i = start; i < end; i++){
  printf("{%f, %f}", bodies[i].position.x, bodies[i].position.y);
  if (i == end - 1)
   break;
  else
   printf(", ");
 }
 printf("}, \n");
}

variable_types: struct Body { double mass; struct Vec2 { double x; } position; struct Vec2 velocity; } []

user_defined_types: struct Body { double mass; struct Vec2 position; struct Vec2 velocity; }


wctime

decompiled_code:
int __fastcall wctime(double *a1)
{
int result; // eax
struct timeval v2; // [rsp+0h] [rbp-18h] BYREF

result = gettimeofday(&v2, 0LL);
*a1 = (double)SLODWORD(v2.tv_usec) * 0.000001 + (double)SLODWORD(v2.tv_sec);
return result;
}

canonical_decompiled_code:
int __fastcall func14(double *a1)
{
int result; // eax
struct timeval v2; // [rsp+0h] [rbp-18h] BYREF

result = gettimeofday(&v2, 0LL);
*a1 = (double)SLODWORD(v2.tv_usec) * 0.000001 + (double)SLODWORD(v2.tv_sec);
return result;
}

original_code:
void wctime(double *t) {
 struct timeval tv;
 gettimeofday(&tv, ((void *)0));
 *t = tv.tv_sec + (1E-6) * tv.tv_usec;
}

variable_types:
t
double *

variable_types: struct timeval { long tv_sec; long tv_usec; }


main

repo: witchnaga/filedlg

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int128 v4; // [rsp+0h] [rbp-38h] BYREF
__int128 v5; // [rsp+10h] [rbp-28h]
__int64 v6; // [rsp+20h] [rbp-18h]

v4 = 0LL;
v6 = 0LL;
v5 = 0LL;
if ( (unsigned int)command_parse(argc, argv, &v4) )
{
if ( (_WORD)v5 )
{
if ( (_WORD)v5 == 1 )
help_constprop_0_isra_0();
else
puts("main : cmd.mode is unexpected.");
}
else
{
exec_isra_0(&v4);
}
}
else
{
puts("main : parse_command is failed.");
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int128 v4; // [rsp+0h] [rbp-38h] BYREF
__int128 v5; // [rsp+10h] [rbp-28h]
__int64 v6; // [rsp+20h] [rbp-18h]

v4 = 0LL;
v6 = 0LL;
v5 = 0LL;
if ( (unsigned int)func16(argc, argv, &v4) )
{
if ( (_WORD)v5 )
{
if ( (_WORD)v5 == 1 )
func17();
else
puts("main : cmd.mode is unexpected.");
}
else
{
func18(&v4);
}
}
else
{
puts("main : parse_command is failed.");
}
return 0;
}

original_code:
int main(int argc, char** argv)
{
 Command cmd;
 memset(&cmd, 0, sizeof(cmd));
 if (command_parse(argc, argv, &cmd) != 0) {
  switch (cmd.mode) {
   case COMMAND_MODE_EXEC: exec(&cmd); break;
   case COMMAND_MODE_HELP: help(&cmd); break;
   default:
    printf("main : cmd.mode is unexpected.\n"); break;
  }
 } else {
  printf("main : parse_command is failed.\n");
 }
 return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
 struct Command cmd;
 memset(&cmd, 0, sizeof(cmd));
 if (command_parse(argc, argv, &cmd) != 0) {
  switch (cmd.mode) {
   case COMMAND_MODE_EXEC: exec(&cmd); break;
   case COMMAND_MODE_HELP: help(&cmd); break;
   default:
    printf("main : cmd.mode is unexpected.\n"); break;
  }
 } else {
  printf("main : parse_command is failed.\n");
 }
 return 0;
}

variable_types:
argv
char **

variable_types: struct Command { int argc; char **argv; unsigned short mode; unsigned int filter; unsigned short action; char *title; }


decompiled_code:
__int64 __fastcall file_dialog_get_action(__int64 a1)
{
__int64 result; // rax
__int16 v2; // dx

result = 0LL;
if ( a1 )
{
v2 = *(_WORD *)(a1 + 24);
if ( v2 )
{
if ( v2 == 1 )
{
result = 1LL;
}
else if ( v2 == 2 )
{
result = 2LL;
}
else
{
result = 3 * (unsigned int)(v2 == 3);
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
__int64 result; // rax
__int16 v2; // dx

result = 0LL;
if ( a1 )
{
v2 = *(_WORD *)(a1 + 24);
if ( v2 )
{
if ( v2 == 1 )
{
result = 1LL;
}
else if ( v2 == 2 )
{
result = 2LL;
}
else
{
result = 3 * (unsigned int)(v2 == 3);
}
}
}
return result;
}

original_code:
static GtkFileChooserAction file_dialog_get_action(Command* cmd_ptr)
{
 GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN;
 if (cmd_ptr != ((void *)0)) {
  int i;
  for (i = 0; i < (sizeof(actions)/sizeof((actions)[0])); ++i) {
   if (cmd_ptr->action == actions[i].action) {
    action = actions[i].gtk_action;
    break;
   }
  }
 }
 return action;
}

canonical_original_code:
static enum GtkFileChooserAction file_dialog_get_action(struct Command *cmd_ptr)
{
 enum GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN;
 if (cmd_ptr != ((void *)0)) {
  int i;
  for (i = 0; i < (sizeof(actions)/sizeof((actions)[0])); ++i) {
   if (cmd_ptr->action == actions[i].action) {
    action = actions[i].gtk_action;
    break;
   }
  }
 }
 return action;
}

variable_types: struct Command { int argc; char **argv; unsigned short mode; unsigned int filter; unsigned short action; char *title; } *

variable_types: enum GtkFileChooserAction { GTK_FILE_CHOOSER_ACTION_OPEN=0, GTK_FILE_CHOOSER_ACTION_SAVE=1, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER=2, GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER=3 }


original_code:
static void command_init(int argc, char** argv, Command* data_ptr)
{
 if (data_ptr != ((void *)0)) {
  data_ptr->argc = argc;
  data_ptr->argv = argv;
  data_ptr->mode = COMMAND_MODE_EXEC;
  data_ptr->filter = COMMAND_FILTER_DEFAULT;
  data_ptr->action = COMMAND_ACTION_DEFAULT;
  data_ptr->title = ((void *)0);
 }
}

canonical_original_code:
static void command_init(int argc, char **argv, struct Command *data_ptr)
{
 if (data_ptr != ((void *)0)) {
  data_ptr->argc = argc;
  data_ptr->argv = argv;
  data_ptr->mode = COMMAND_MODE_EXEC;
  data_ptr->filter = COMMAND_FILTER_DEFAULT;
  data_ptr->action = COMMAND_ACTION_DEFAULT;
  data_ptr->title = ((void *)0);
 }
}

variable_types: argc int

user_defined_types: struct Command { int argc; char **argv; unsigned short mode; unsigned int filter; unsigned short action; char *title; }


decompiled_code:
__int64 __fastcall command_parse_title(int a1, __int64 a2, __int64 a3, int a4)
{
__int64 result; // rax

result = 0LL;
if ( a4 < a1 )
{
*(_QWORD *)(a3 + 32) = *(_QWORD *)(a2 + 8LL * a4 + 8);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(int a1, __int64 a2, __int64 a3, int a4)
{
__int64 result; // rax

result = 0LL;
if ( a4 < a1 )
{
*(_QWORD *)(a3 + 32) = *(_QWORD *)(a2 + 8LL * a4 + 8);
result = 1LL;
}
return result;
}

original_code:
static int command_parse_title(int argc, char** argv, Command* data_ptr, int pos)
{
 int result = 0;
 if (pos < argc) {
  result = 1;
  data_ptr->title = argv[pos + 1];
 }
 return result;
}

canonical_original_code:
static int command_parse_title(int argc, char **argv, struct Command *data_ptr, int pos)
{
 int result = 0;
 if (pos < argc) {
  result = 1;
  data_ptr->title = argv[pos + 1];
 }
 return result;
}

variable_types: pos int

variable_types: result int


decompiled_code:
__int64 __fastcall command_parse_action(int a1, __int64 a2, __int64 a3, int a4)
{
unsigned int v4; // er12
const char *v5; // r13
__int64 v6; // rbx
__int64 v8; // r12
__int16 v9; // ax

v4 = 0;
if ( a4 >= a1 )
return v4;
v5 = *(const char **)(a2 + 8LL * a4 + 8);
if ( *v5 == 45 )
{
puts("command_parse_action : action parameter is invalid.");
return 0LL;
}
v6 = 0LL;
v8 = 0LL;
if ( !strcmp(v5, "open") )
{
LABEL_6:
v9 = word_402428[8 * v8];
v4 = 1;
*(_WORD *)(a3 + 24) = v9;
return v4;
}
while ( ++v6 != 4 )
{
v8 = (int)v6;
if ( !strcmp(v5, (const char *)action_parameter[2 * v6]) )
goto LABEL_6;
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func13(int a1, __int64 a2, __int64 a3, int a4)
{
unsigned int v4; // er12
const char *v5; // r13
__int64 v6; // rbx
__int64 v8; // r12
__int16 v9; // ax

v4 = 0;
if ( a4 >= a1 )
return v4;
v5 = *(const char **)(a2 + 8LL * a4 + 8);
if ( *v5 == 45 )
{
puts("command_parse_action : action parameter is invalid.");
return 0LL;
}
v6 = 0LL;
v8 = 0LL;
if ( !strcmp(v5, "open") )
{
LABEL_6:
v9 = word_402428[8 * v8];
v4 = 1;
*(_WORD *)(a3 + 24) = v9;
return v4;
}
while ( ++v6 != 4 )
{
v8 = (int)v6;
if ( !strcmp(v5, (const char *)action_parameter[2 * v6]) )
goto LABEL_6;
}
return 1LL;
}

original_code:
static int command_parse_action(int argc, char** argv, Command* data_ptr, int pos)
{
 int result = 0;
 if (pos < argc) {
  if (*argv[pos + 1] != '-') {
   int i;
   result = 1;
   for (i = 0; i < (sizeof(action_parameter)/sizeof((action_parameter)[0])); ++i) {
    if (strcmp(argv[pos + 1], action_parameter[i].command) == 0) {
     data_ptr->action = action_parameter[i].value;
     break;
    }
   }
  } else {
   printf("command_parse_action : action parameter is invalid.\n");
  }
 }
 return result;
}

canonical_original_code:
static int command_parse_action(int argc, char **argv, struct Command *data_ptr, int pos)
{
 int result = 0;
 if (pos < argc) {
  if (*argv[pos + 1] != '-') {
   int i;
   result = 1;
   for (i = 0; i < (sizeof(action_parameter)/sizeof((action_parameter)[0])); ++i) {
    if (strcmp(argv[pos + 1], action_parameter[i].command) == 0) {
     data_ptr->action = action_parameter[i].value;
     break;
    }
   }
  } else {
   printf("command_parse_action : action parameter is invalid.\n");
  }
 }
 return result;
}


decompiled_code:
__int64 __fastcall command_parse_filter(int a1, __int64 a2, __int64 a3, int a4)
{
unsigned int v4; // er13
const char *v5; // r15
int v6; // eax
int v7; // er13
char v8; // dl
const char *v9; // rsi
__int64 v10; // rbx
__int64 v11; // rbp
int v12; // eax
signed int v13; // eax
__int64 *v14; // r12
const char *v15; // rsi
unsigned int v16; // eax
char v19; // [rsp+Bh] [rbp-4Dh]
int v20; // [rsp+Ch] [rbp-4Ch]
char dest[16]; // [rsp+10h] [rbp-48h] BYREF

v4 = 0;
if ( a4 >= a1 )
return v4;
v5 = *(const char **)(a2 + 8LL * a4 + 8);
v19 = *v5;
if ( *v5 == 45 )
{
puts(aCommandParseFi);
return v4;
}
v6 = strlen(v5);
v7 = v6;
if ( v6 <= 0 )
return 1;
v8 = v19;
v9 = v5;
v10 = 1LL;
v20 = 0;
v11 = (unsigned int)(v6 - 1) + 1LL;
while ( 1 )
{
v12 = (_DWORD)v5 - 1 + v10;
if ( v8 == 43 )
{
v13 = v12 - (_DWORD)v9;
if ( (unsigned int)(v13 - 1) > 0xE )
goto LABEL_6;
goto LABEL_10;
}
if ( v7 != (_DWORD)v10 )
goto LABEL_6;
v16 = v12 - (_DWORD)v9;
if ( v16 > 0xE )
break;
v13 = v16 + 1;
LABEL_10:
v14 = (__int64 *)&off_4022D0;
*(_OWORD *)dest = 0LL;
strncpy(dest, v9, v13);
v15 = (const char *)&unk_4021E0;
while ( strcmp(dest, v15) )
{
if ( v14 == action_parameter )
goto LABEL_15;
v15 = (const char *)*v14;
v14 += 2;
}
v20 |= dword_4022B8[4 * v10];
LABEL_15:
v9 = &v5[v10];
LABEL_6:
if ( v10 == v11 )
break;
v8 = v5[v10++];
}
if ( v20 )
*(_DWORD *)(a3 + 20) = v20;
return 1;
}

canonical_decompiled_code:
__int64 __fastcall func14(int a1, __int64 a2, __int64 a3, int a4)
{
unsigned int v4; // er13
const char *v5; // r15
int v6; // eax
int v7; // er13
char v8; // dl
const char *v9; // rsi
__int64 v10; // rbx
__int64 v11; // rbp
int v12; // eax
signed int v13; // eax
__int64 *v14; // r12
const char *v15; // rsi
unsigned int v16; // eax
char v19; // [rsp+Bh] [rbp-4Dh]
int v20; // [rsp+Ch] [rbp-4Ch]
char dest[16]; // [rsp+10h] [rbp-48h] BYREF

v4 = 0;
if ( a4 >= a1 )
return v4;
v5 = *(const char **)(a2 + 8LL * a4 + 8);
v19 = *v5;
if ( *v5 == 45 )
{
puts(aCommandParseFi);
return v4;
}
v6 = strlen(v5);
v7 = v6;
if ( v6 <= 0 )
return 1;
v8 = v19;
v9 = v5;
v10 = 1LL;
v20 = 0;
v11 = (unsigned int)(v6 - 1) + 1LL;
while ( 1 )
{
v12 = (_DWORD)v5 - 1 + v10;
if ( v8 == 43 )
{
v13 = v12 - (_DWORD)v9;
if ( (unsigned int)(v13 - 1) > 0xE )
goto LABEL_6;
goto LABEL_10;
}
if ( v7 != (_DWORD)v10 )
goto LABEL_6;
v16 = v12 - (_DWORD)v9;
if ( v16 > 0xE )
break;
v13 = v16 + 1;
LABEL_10:
v14 = (__int64 *)&off_4022D0;
*(_OWORD *)dest = 0LL;
strncpy(dest, v9, v13);
v15 = (const char *)&unk_4021E0;
while ( strcmp(dest, v15) )
{
if ( v14 == action_parameter )
goto LABEL_15;
v15 = (const char *)*v14;
v14 += 2;
}
v20 |= dword_4022B8[4 * v10];
LABEL_15:
v9 = &v5[v10];
LABEL_6:
if ( v10 == v11 )
break;
v8 = v5[v10++];
}
if ( v20 )
*(_DWORD *)(a3 + 20) = v20;
return 1;
}

original_code:
static int command_parse_filter(int argc, char** argv, Command* data_ptr, int pos)
{
 int result = 0;
 if (pos < argc) {
  if (*argv[pos + 1] != '-') {
   int i, j;
   char buffer[16];
   unsigned int filter = 0;
   char* p_start = argv[pos + 1];
   int cch = strlen(argv[pos + 1]);
   result = 1;
   for (i = 0; i < cch; ++i) {
    char* p_temp = argv[pos + 1];
    char* p = &p_temp[i];
    int len = 0;
    if (*p == '+') {
     len = (p - p_start);
    } else if (cch == (i + 1)) {
     len = (p - p_start) + 1;
    }
    if (len > 0) {
     if ((sizeof(buffer) / sizeof(char)) > len) {
      memset(buffer, 0, sizeof(buffer));
      strncpy(buffer, p_start, len);
      for (j = 0; j < (sizeof(filter_parameter)/sizeof((filter_parameter)[0])); ++j) {
       if (strcmp(buffer, filter_parameter[j].command) == 0) {
        filter |= filter_parameter[i].value;
        break;
       }
      }
      p_start = &p_temp[i + 1];
     }
    }
   }
   if (filter != 0) {
    data_ptr->filter = filter;
   }
  } else {
   printf("command_parse_filter : filter parameter is nothing.\n");
  }
 }
 return result;
}

canonical_original_code:
static int command_parse_filter(int argc, char **argv, struct Command *data_ptr, int pos)
{
 int result = 0;
 if (pos < argc) {
  if (*argv[pos + 1] != '-') {
   int i; int j;
   char buffer[16];
   unsigned int filter = 0;
   char *p_start = argv[pos + 1];
   int cch = strlen(argv[pos + 1]);
   result = 1;
   for (i = 0; i < cch; ++i) {
    char *p_temp = argv[pos + 1];
    char *p = &p_temp[i];
    int len = 0;
    if (*p == '+') {
     len = (p - p_start);
    } else if (cch == (i + 1)) {
     len = (p - p_start) + 1;
    }
    if (len > 0) {
     if ((sizeof(buffer) / sizeof(char)) > len) {
      memset(buffer, 0, sizeof(buffer));
      strncpy(buffer, p_start, len);
      for (j = 0; j < (sizeof(filter_parameter)/sizeof((filter_parameter)[0])); ++j) {
       if (strcmp(buffer, filter_parameter[j].command) == 0) {
        filter |= filter_parameter[i].value;
        break;
       }
      }
      p_start = &p_temp[i + 1];
     }
    }
   }
   if (filter != 0) {
    data_ptr->filter = filter;
   }
  } else {
   printf("command_parse_filter : filter parameter is nothing.\n");
  }
 }
 return result;
}

variable_types: j int

variable_types:
buffer
char [16]

variable_types:
filter
unsigned int

variable_types: cch int

variable_types:
p
char *

variable_types: len int


decompiled_code:
__int64 __fastcall command_parse(int a1, __int64 a2, __int64 a3)
{
int v4; // ebx
unsigned __int8 *v5; // rax
int v6; // edx

if ( !a3 )
return 0LL;
v4 = 0;
command_init(a1, a2, a3);
if ( a1 > 0 )
{
while ( 1 )
{
while ( 1 )
{
v5 = *(unsigned __int8 **)(a2 + 8LL * v4);
if ( v5 )
break;
LABEL_14:
if ( a1 <= ++v4 )
return 1LL;
}
if ( !strcmp(*(const char **)(a2 + 8LL * v4), "--help") )
{
v4 += command_parse_help_constprop_0(a3) + 1;
if ( a1 <= v4 )
return 1LL;
}
else if ( !strcmp(*(const char **)(a2 + 8LL * v4), "--title") || (v6 = *v5, v6 == 45) && v5[1] == 116 && !v5[2] )
{
v4 += command_parse_title(a1, a2, a3, v4) + 1;
if ( a1 <= v4 )
return 1LL;
}
else if ( !strcmp(*(const char **)(a2 + 8LL * v4), "--action") || v6 == 45 && v5[1] == 97 && !v5[2] )
{
v4 += command_parse_action(a1, a2, a3, v4) + 1;
if ( a1 <= v4 )
return 1LL;
}
else
{
if ( strcmp(*(const char **)(a2 + 8LL * v4), "--filter") && (v6 != 45 || v5[1] != 102 || v5[2]) )
goto LABEL_14;
v4 += command_parse_filter(a1, a2, a3, v4) + 1;
if ( a1 <= v4 )
return 1LL;
}
}
}
return 1LL;
}

original_code:
int command_parse(int argc, char** argv, Command* data_ptr)
{
 int result = 0;
 if (data_ptr != ((void *)0)) {
  int i;
  command_init(argc, argv, data_ptr);
  result = 1;
  for (i = 0; i < argc; ++i) {
   char* p = argv[i];
   if (p != ((void *)0)) {
    if (strcmp(p, "--help") == 0) {
     i += command_parse_help(argc, argv, data_ptr, i);
    } else if (strcmp(p, "--title") == 0 || strcmp(p, "-t") == 0) {
     i += command_parse_title(argc, argv, data_ptr, i);
    } else if (strcmp(p, "--action") == 0 || strcmp(p, "-a") == 0) {
     i += command_parse_action(argc, argv, data_ptr, i);
    } else if (strcmp(p, "--filter") == 0 || strcmp(p, "-f") == 0) {
     i += command_parse_filter(argc, argv, data_ptr, i);
    }
   }
  }
 }
 return result;
}

canonical_original_code:
int command_parse(int argc, char **argv, struct Command *data_ptr)
{
 int result = 0;
 if (data_ptr != ((void *)0)) {
  int i;
  command_init(argc, argv, data_ptr);
  result = 1;
  for (i = 0; i < argc; ++i) {
   char *p = argv[i];
   if (p != ((void *)0)) {
    if (strcmp(p, "--help") == 0) {
     i += command_parse_help(argc, argv, data_ptr, i);
    } else if (strcmp(p, "--title") == 0 || strcmp(p, "-t") == 0) {
     i += command_parse_title(argc, argv, data_ptr, i);
    } else if (strcmp(p, "--action") == 0 || strcmp(p, "-a") == 0) {
     i += command_parse_action(argc, argv, data_ptr, i);
    } else if (strcmp(p, "--filter") == 0 || strcmp(p, "-f") == 0) {
     i += command_parse_filter(argc, argv, data_ptr, i);
    }
   }
  }
 }
 return result;
}

variable_types: i int


decompiled_code:
__int64 macs_map_free_index()
{
__int64 v0; // rdx
__int64 result; // rax
__int64 v2; // rcx

v0 = (unsigned int)((_DWORD)map + 24);
result = 0LL;
v2 = 0LL;
while ( !*(_DWORD *)(v0 + 8) )
{
if ( *(_QWORD *)v0 < map[5 * v2 + 3] )
v2 = result;
++result;
v0 += 40LL;
if ( result == 4096 )
return v2;
}
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v0; // rdx
__int64 result; // rax
__int64 v2; // rcx

v0 = (unsigned int)((_DWORD)map + 24);
result = 0LL;
v2 = 0LL;
while ( !*(_DWORD *)(v0 + 8) )
{
if ( *(_QWORD *)v0 < map[5 * v2 + 3] )
v2 = result;
++result;
v0 += 40LL;
if ( result == 4096 )
return v2;
}
return result;
}

original_code:
static size_t macs_map_free_index() {
 size_t min_index = 0;
 size_t i;
 for (i = 0; i < 4096; i++) {
  if (map[i].removed)
   return i;
  if (map[i].insert_time < map[min_index].insert_time) {
   min_index = i;
  }
 }
 return min_index;
}

canonical_original_code:
static unsigned long macs_map_free_index() {
 unsigned long min_index = 0;
 unsigned long i;
 for (i = 0; i < 4096; i++) {
  if (map[i].removed)
   return i;
  if (map[i].insert_time < map[min_index].insert_time) {
   min_index = i;
  }
 }
 return min_index;
}

variable_types:
i
unsigned long

return_type: unsigned long


decompiled_code:
_BOOL8 __fastcall macs_equal(__int64 a1, __int64 a2)
{
return (_DWORD)a1 == (_DWORD)a2 && WORD2(a1) == WORD2(a2);
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(__int64 a1, __int64 a2)
{
return (_DWORD)a1 == (_DWORD)a2 && WORD2(a1) == WORD2(a2);
}

original_code:
static int macs_equal(mac_t m1, mac_t m2) {
 return memcmp(&m1, &m2, sizeof (mac_t)) == 0;
}

canonical_original_code:
static int macs_equal(struct mac_addr_t m1, struct mac_addr_t m2) {
 return memcmp(&m1, &m2, sizeof (mac_t)) == 0;
}

variable_types: struct mac_addr_t { unsigned char a[6]; }


decompiled_code:
__int64 __fastcall macs_map_get_index(__int64 a1)
{
unsigned __int64 v1; // rdx
__int64 i; // r8
int v3; // ecx

v1 = (unsigned int)((_DWORD)map + 8);
for ( i = 0LL; i != 4096; ++i )
{
if ( !*(_DWORD *)(v1 + 24)
&& macs_equal(
((unsigned __int64)BYTE4(a1) << 32) | ((unsigned __int64)BYTE2(a1) << 16) | (unsigned __int16)a1 | ((unsigned __int64)BYTE3(a1) << 24) | ((unsigned __int64)BYTE5(a1) << 40),
map[5 * i])
&& *(_DWORD *)v1 == v3 )
{
return i;
}
v1 += 40LL;
}
return -1LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
unsigned __int64 v1; // rdx
__int64 i; // r8
int v3; // ecx

v1 = (unsigned int)((_DWORD)map + 8);
for ( i = 0LL; i != 4096; ++i )
{
if ( !*(_DWORD *)(v1 + 24)
&& func1(
((unsigned __int64)BYTE4(a1) << 32) | ((unsigned __int64)BYTE2(a1) << 16) | (unsigned __int16)a1 | ((unsigned __int64)BYTE3(a1) << 24) | ((unsigned __int64)BYTE5(a1) << 40),
map[5 * i])
&& *(_DWORD *)v1 == v3 )
{
return i;
}
v1 += 40LL;
}
return -1LL;
}

original_code:
static size_t macs_map_get_index(mac_t mac, int vlan) {
 size_t i;
 for (i = 0; i < 4096; i++)
  if (!map[i].removed && macs_equal(mac, map[i].mac) && vlan == map[i].vlan)
   return i;
 return -1;
}

canonical_original_code:
static unsigned long macs_map_get_index(struct mac_addr_t mac, int vlan) {
 unsigned long i;
 for (i = 0; i < 4096; i++)
  if (!map[i].removed && macs_equal(mac, map[i].mac) && vlan == map[i].vlan)
   return i;
 return -1;
}

variable_types: vlan int

user_defined_types: struct mac_addr_t { unsigned char a[6]; }


decompiled_code:
_BOOL8 __fastcall macs_map_exists(__int64 a1)
{
return macs_map_get_index(a1 & 0xFF00000000LL | ((unsigned __int64)BYTE3(a1) << 24) | (unsigned __int8)a1 | (unsigned __int64)((unsigned __int16)a1 & 0xFF00) | ((unsigned __int64)BYTE2(a1) << 16) | a1 & 0xFF0000000000LL) != -1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func4(__int64 a1)
{
return func2(a1 & 0xFF00000000LL | ((unsigned __int64)BYTE3(a1) << 24) | (unsigned __int8)a1 | (unsigned __int64)((unsigned __int16)a1 & 0xFF00) | ((unsigned __int64)BYTE2(a1) << 16) | a1 & 0xFF0000000000LL) != -1;
}

original_code:
int macs_map_exists(mac_t mac, int vlan) {
 return macs_map_get_index(mac, vlan) != -1;
}

canonical_original_code:
int macs_map_exists(struct mac_addr_t mac, int vlan) {
 return macs_map_get_index(mac, vlan) != -1;
}


decompiled_code:
__int64 __fastcall mac_is_multicast(char a1)
{
return a1 & 1;
}

canonical_decompiled_code:
__int64 __fastcall func7(char a1)
{
return a1 & 1;
}

original_code:
int mac_is_multicast(mac_t mac) {
 return mac.a[0] & 1;
}

canonical_original_code:
int mac_is_multicast(struct mac_addr_t mac) {
 return mac.a[0] & 1;
}


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char v3; // al
const char *v4; // rbp
int v5; // ebp
__int64 v6; // rcx
const char *v7; // rsi
struct addrinfo *v8; // rdi
sockaddr *v9; // rsi
int result; // eax
struct addrinfo *pai; // [rsp+8h] [rbp-80h] BYREF
char dest[16]; // [rsp+10h] [rbp-78h] BYREF
__int128 v13; // [rsp+20h] [rbp-68h]
__int64 v14; // [rsp+30h] [rbp-58h]
struct addrinfo req; // [rsp+40h] [rbp-48h] BYREF

strcpy(tap_name, "siktap");
while ( 1 )
{
v3 = getopt(argc, (char *const *)argv, "d:");
if ( v3 == -1 )
break;
if ( v3 != 100 )
fatal("Unknown option", (char)argv);
v4 = optarg;
if ( strlen(optarg) > 0x31 )
fatal("Too long interface name", (char)argv);
strcpy(tap_name, v4);
}
if ( optind >= argc )
fatal("Wrong configuration", (char)argv);
slicz_addr = strtok((char *)argv[optind], ":");
if ( !slicz_addr )
fatal("No address", (char)":");
slicz_port = strtok(0LL, ":");
if ( !slicz_port )
fatal("No port", (char)":");
tap_fd = open("/dev/net/tun", 2);
v5 = tap_fd;
if ( tap_fd < 0 )
{
perror("open(/dev/net/tun)");
result = 1;
}
else
{
v14 = 0LL;
v13 = 0LL;
strncpy(dest, tap_name, 0x10uLL);
LOWORD(v13) = 4098;
if ( ioctl(v5, 0x400454CAuLL, dest) < 0 )
{
perror("ioctl(TUNSETIFF)");
result = 1;
}
else
{
slicz_fd = socket(2, 2, 0);
if ( slicz_fd < 0 )
syserr("socket", 2);
v6 = 12LL;
v7 = slicz_port;
v8 = &req;
while ( v6 )
{
v8->ai_flags = 0;
v8 = (struct addrinfo *)((char *)v8 + 4);
--v6;
}
*(_QWORD *)&req.ai_family = 0x200000002LL;
if ( getaddrinfo(slicz_addr, v7, &req, &pai) )
syserr("getaddrinfo", (char)v7);
v9 = pai->ai_addr;
if ( connect(slicz_fd, v9, pai->ai_addrlen) < 0 )
syserr("connect", (char)v9);
freeaddrinfo(pai);
if ( !event_base_new() )
syserr("Error creating base", (char)v9);
event_new();
event_add();
event_new();
event_add();
event_base_dispatch();
result = 0;
}
}
return result;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char v3; // al
const char *v4; // rbp
int v5; // ebp
__int64 v6; // rcx
const char *v7; // rsi
struct addrinfo *v8; // rdi
sockaddr *v9; // rsi
int result; // eax
struct addrinfo *pai; // [rsp+8h] [rbp-80h] BYREF
char dest[16]; // [rsp+10h] [rbp-78h] BYREF
__int128 v13; // [rsp+20h] [rbp-68h]
__int64 v14; // [rsp+30h] [rbp-58h]
struct addrinfo req; // [rsp+40h] [rbp-48h] BYREF

strcpy(tap_name, "siktap");
while ( 1 )
{
v3 = getopt(argc, (char *const *)argv, "d:");
if ( v3 == -1 )
break;
if ( v3 != 100 )
func10("Unknown option", (char)argv);
v4 = optarg;
if ( strlen(optarg) > 0x31 )
func10("Too long interface name", (char)argv);
strcpy(tap_name, v4);
}
if ( optind >= argc )
func10("Wrong configuration", (char)argv);
slicz_addr = strtok((char *)argv[optind], ":");
if ( !slicz_addr )
func10("No address", (char)":");
slicz_port = strtok(0LL, ":");
if ( !slicz_port )
func10("No port", (char)":");
tap_fd = open("/dev/net/tun", 2);
v5 = tap_fd;
if ( tap_fd < 0 )
{
perror("open(/dev/net/tun)");
result = 1;
}
else
{
v14 = 0LL;
v13 = 0LL;
strncpy(dest, tap_name, 0x10uLL);
LOWORD(v13) = 4098;
if ( ioctl(v5, 0x400454CAuLL, dest) < 0 )
{
perror("ioctl(TUNSETIFF)");
result = 1;
}
else
{
slicz_fd = socket(2, 2, 0);
if ( slicz_fd < 0 )
func9("socket", 2);
v6 = 12LL;
v7 = slicz_port;
v8 = &req;
while ( v6 )
{
v8->ai_flags = 0;
v8 = (struct addrinfo *)((char *)v8 + 4);
--v6;
}
*(_QWORD *)&req.ai_family = 0x200000002LL;
if ( getaddrinfo(slicz_addr, v7, &req, &pai) )
func9("getaddrinfo", (char)v7);
v9 = pai->ai_addr;
if ( connect(slicz_fd, v9, pai->ai_addrlen) < 0 )
func9("connect", (char)v9);
freeaddrinfo(pai);
if ( !event_base_new() )
func9("Error creating base", (char)v9);
event_new();
event_add();
event_new();
event_add();
event_base_dispatch();
result = 0;
}
}
return result;
}

original_code:
int main(int argc, char** argv) {
 char opt;
 control_port = 42420;
 int was_c = 0;
 while ((opt = getopt(argc, argv, "c:p:")) != -1) {
  if (opt == 'c') {
   if (!was_c) {
    control_port = atoi(optarg);
    was_c = 1;
   } else {
    fatal("There should be one -c flag");
   }
  } else if (opt != 'p') {
   fatal("Wrong parameter");
  }
 }
 slicz_start();
 optind = 1;
 while ((opt = getopt(argc, argv, "c:p:")) != -1) {
  if (opt == 'p') {
   if (setconfig(optarg) != 0)
    fatal("Invalid configuration: %s", optarg);
  }
 }
 event_base_dispatch(base);
}

canonical_original_code:
int main(int argc, char **argv) {
 char opt;
 control_port = 42420;
 int was_c = 0;
 while ((opt = getopt(argc, argv, "c:p:")) != -1) {
  if (opt == 'c') {
   if (!was_c) {
    control_port = atoi(optarg);
    was_c = 1;
   } else {
    fatal("There should be one -c flag");
   }
  } else if (opt != 'p') {
   fatal("Wrong parameter");
  }
 }
 slicz_start();
 optind = 1;
 while ((opt = getopt(argc, argv, "c:p:")) != -1) {
  if (opt == 'p') {
   if (setconfig(optarg) != 0)
    fatal("Invalid configuration: %s", optarg);
  }
 }
 event_base_dispatch(base);
}

variable_types:
argv
char **

variable_types: opt char


decompiled_code:
ssize_t slicz_read_callback()
{
int v0; // eax
ssize_t result; // rax

puts("receiving");
v0 = recv(slicz_fd, &buf, 0x5EEuLL, 0);
if ( v0 < 0 )
syserr("Slicz socket read", (char)&buf);
result = write(tap_fd, &buf, v0);
if ( (int)result < 0 )
syserr("Tap socket write", (char)&buf);
return result;
}

canonical_decompiled_code:
ssize_t func7()
{
int v0; // eax
ssize_t result; // rax

puts("receiving");
v0 = recv(slicz_fd, &buf, 0x5EEuLL, 0);
if ( v0 < 0 )
func9("Slicz socket read", (char)&buf);
result = write(tap_fd, &buf, v0);
if ( (int)result < 0 )
func9("Tap socket write", (char)&buf);
return result;
}

original_code:
void slicz_read_callback(int sock, short ev, void* arg) {
 printf("receiving\n");
 int r = recv(slicz_fd, buf, sizeof (buf), 0);
 if (r < 0) syserr("Slicz socket read");
 int w = write(tap_fd, buf, r);
 if (w < 0) syserr("Tap socket write");
}

canonical_original_code:
void slicz_read_callback(int sock, short ev, void *arg) {
 printf("receiving\n");
 int r = recv(slicz_fd, buf, sizeof (buf), 0);
 if (r < 0) syserr("Slicz socket read");
 int w = write(tap_fd, buf, r);
 if (w < 0) syserr("Tap socket write");
}

variable_types: sock int

variable_types: ev short

variable_types:
arg
void *

variable_types: r int

variable_types: w int


decompiled_code:
ssize_t tap_read_callback()
{
int v0; // eax
ssize_t result; // rax

puts("sending");
v0 = read(tap_fd, &buf, 0x5EEuLL);
if ( v0 < 0 )
syserr("Tap socket read", (char)&buf);
result = send(slicz_fd, &buf, v0, 0);
if ( (int)result < 0 )
syserr("Slicz socket write", (char)&buf);
return result;
}

canonical_decompiled_code:
ssize_t func8()
{
int v0; // eax
ssize_t result; // rax

puts("sending");
v0 = read(tap_fd, &buf, 0x5EEuLL);
if ( v0 < 0 )
func9("Tap socket read", (char)&buf);
result = send(slicz_fd, &buf, v0, 0);
if ( (int)result < 0 )
func9("Slicz socket write", (char)&buf);
return result;
}

original_code:
void tap_read_callback(int sock, short ev, void* arg) {
 printf("sending\n");
 int r = read(tap_fd, buf, sizeof (buf));
 if (r < 0) syserr("Tap socket read");
 int w = send(slicz_fd, buf, r, 0);
 if (w < 0) syserr("Slicz socket write");
}

canonical_original_code:
void tap_read_callback(int sock, short ev, void *arg) {
 printf("sending\n");
 int r = read(tap_fd, buf, sizeof (buf));
 if (r < 0) syserr("Tap socket read");
 int w = send(slicz_fd, buf, r, 0);
 if (w < 0) syserr("Slicz socket write");
}


syserr

decompiled_code:
void __noreturn syserr(char *format, ...)
{
int *v1; // rbx
char *v2; // rax
gcc_va_list arg; // [rsp+8h] [rbp-E0h] BYREF

va_start(arg, format);
fwrite("ERROR: ", 1uLL, 7uLL, stderr);
vfprintf(stderr, format, arg);
v1 = __errno_location();
v2 = strerror(*v1);
fprintf(stderr, " (%d; %s)\n", (unsigned int)*v1, v2);
exit(1);
}

canonical_decompiled_code:
void __noreturn func9(char *format, ...)
{
int *v1; // rbx
char *v2; // rax
gcc_va_list arg; // [rsp+8h] [rbp-E0h] BYREF

va_start(arg, format);
fwrite("ERROR: ", 1uLL, 7uLL, stderr);
vfprintf(stderr, format, arg);
v1 = __errno_location();
v2 = strerror(*v1);
fprintf(stderr, " (%d; %s)\n", (unsigned int)*v1, v2);
exit(1);
}

original_code:
void syserr(const char *fmt, ...) {
 va_list fmt_args;
 fprintf(stderr, "ERROR: ");
 __builtin_va_start(fmt_args,fmt);
 vfprintf(stderr, fmt, fmt_args);
 __builtin_va_end(fmt_args);
 fprintf(stderr, " (%d; %s)\n", (*__errno_location ()), strerror((*__errno_location ())));
 exit(1);
}

canonical_original_code:
void syserr(char *fmt, ...) {
 __builtin_va_list fmt_args;
 fprintf(stderr, "ERROR: ");
 __builtin_va_start(fmt_args,fmt);
 vfprintf(stderr, fmt, fmt_args);
 __builtin_va_end(fmt_args);
 fprintf(stderr, " (%d; %s)\n", (*__errno_location ()), strerror((*__errno_location ())));
 exit(1);
}

variable_types:
fmt
char *


fatal

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

va_start(arg, format);
fwrite("ERROR: ", 1uLL, 7uLL, stderr);
vfprintf(stderr, format, arg);
fputc(10, stderr);
exit(1);
}

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

va_start(arg, format);
fwrite("ERROR: ", 1uLL, 7uLL, stderr);
vfprintf(stderr, format, arg);
fputc(10, stderr);
exit(1);
}

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

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


decompiled_code:
_BOOL8 frame_is_tagged()
{
__int16 v0; // ax
__int64 v1; // rdx

v0 = _bswap_16(33024);
return *(_WORD *)(v1 + 12) == (unsigned __int16)v0;
}

original_code:
int frame_is_tagged(frame_t* f) {
 return f->tpid == ntohs(0x8100);
}

canonical_original_code:
int frame_is_tagged(struct frame *f) {
 return f->tpid == ntohs(0x8100);
}

variable_types: struct frame { struct mac_addr_t { unsigned char a[6]; } dst_mac; struct mac_addr_t src_mac; unsigned short tpid; unsigned short tci; char content[1502]; unsigned long content_len; } *

user_defined_types: struct frame { struct mac_addr_t dst_mac; struct mac_addr_t src_mac; unsigned short tpid; unsigned short tci; char content[1502]; unsigned long content_len; }


decompiled_code:
__int64 __fastcall frame_vlan(__int64 a1)
{
return _bswap_16(*(_WORD *)(a1 + 14)) & 0xFFF;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
return func0(*(_WORD *)(a1 + 14)) & 0xFFF;
}

original_code:
int frame_vlan(frame_t* f) {
 return ntohs(f->tci) & 4095U;
}

canonical_original_code:
int frame_vlan(struct frame *f) {
 return ntohs(f->tci) & 4095U;
}


decompiled_code:
char *__fastcall frame_from_str(void *src, size_t n)
{
char *v2; // r12

v2 = (char *)malloc(0x5F6uLL);
memcpy(v2, src, n);
*(_QWORD *)(v2 + 1518) = n - 16;
if ( !frame_is_tagged() )
{
*(_QWORD *)(v2 + 1518) = n - 12;
memmove(v2 + 24416, v2 + 18312, n - 12);
}
return v2;
}

original_code:
frame_t* frame_from_str(char* buf, size_t len) {
 frame_t* f = malloc(sizeof (frame_t));
 memcpy(f, buf, len);
 f->content_len = len - 16;
 if (!frame_is_tagged(f)) {
  f->content_len = len - 12;
  memmove(f + 16, f + 12, f->content_len);
 }
 return f;
}

canonical_original_code:
struct frame *frame_from_str(char *buf, unsigned long len) {
 struct frame *f = malloc(sizeof (frame_t));
 memcpy(f, buf, len);
 f->content_len = len - 16;
 if (!frame_is_tagged(f)) {
  f->content_len = len - 12;
  memmove(f + 16, f + 12, f->content_len);
 }
 return f;
}

variable_types:
buf
char *

variable_types:
len
unsigned long

return_type: struct frame { struct mac_addr_t { unsigned char a[6]; } dst_mac; struct mac_addr_t src_mac; unsigned short tpid; unsigned short tci; char content[1502]; unsigned long content_len; } *