decompiled_code:
__int64 __fastcall recfast_dx_He_dz(__int64 a1, __int64 a2, double *a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10, double a11)
{
double v13; // xmm0_8
double v14; // xmm0_8
double v15; // r14
double v16; // r14
int v17; // er15
double v18; // r14
double v20; // xmm0_8
double v21; // xmm0_8
double v22; // r14
double v23; // xmm0_8
double v24; // xmm0_8
double v25; // r14
double v26; // r15
double v27; // xmm0_8
double v28; // xmm1_8
double v29; // r14
double v30; // r14
double v31; // xmm0_8
double v32; // xmm0_8
double v33; // r14
double v34; // xmm0_8
double v35; // xmm0_8
double v36; // r14
double v37; // xmm1_8
double v38; // xmm2_8
double v39; // xmm0_8
double v40; // xmm1_8
double v41; // rbp
double v42; // xmm0_8
double v43; // xmm1_8
double v44; // xmm2_8
double v45; // xmm0_8
double v46; // rbp
double v47; // xmm1_8
double v48; // [rsp+0h] [rbp-B8h]
double v49; // [rsp+8h] [rbp-B0h]
double v50; // [rsp+8h] [rbp-B0h]
double v52; // [rsp+10h] [rbp-A8h]
double v53; // [rsp+18h] [rbp-A0h]
double v54; // [rsp+18h] [rbp-A0h]
double v55; // [rsp+20h] [rbp-98h]
double v56; // [rsp+20h] [rbp-98h]
double v58; // [rsp+28h] [rbp-90h]
double v59; // [rsp+30h] [rbp-88h]
double x; // [rsp+38h] [rbp-80h]
double xa; // [rsp+38h] [rbp-80h]
double xb; // [rsp+38h] [rbp-80h]
double v63; // [rsp+40h] [rbp-78h]
double v65; // [rsp+50h] [rbp-68h]
double v66; // [rsp+50h] [rbp-68h]
double v68; // [rsp+60h] [rbp-58h]
double v69; // [rsp+60h] [rbp-58h]
double v70; // [rsp+60h] [rbp-58h]
double v71; // [rsp+60h] [rbp-58h]
double v72; // [rsp+68h] [rbp-50h]
double v73; // [rsp+68h] [rbp-50h]
double v74; // [rsp+70h] [rbp-48h]
double v75; // [rsp+78h] [rbp-40h]

v48 = a10;
v49 = a11;
if ( *(_WORD *)(a1 + 3704) == 1 )
{
v20 = *(double *)(a2 + 288) * *(double *)(a2 + 288) * *(double *)(a2 + 296);
v48 = a10 / v20;
v49 = a11 / v20;
}
v63 = a7 * *(double *)(a2 + 32);
v13 = v48 / 2.999998240459423;
if ( v48 / 2.999998240459423 < 0.0 )
v53 = sqrt(v13);
else
v53 = sqrt(v13);
v14 = v48 / 130016.957803329;
if ( v48 / 130016.957803329 < 0.0 )
v55 = sqrt(v14);
else
v55 = sqrt(v14);
v15 = pow(v53 + 1.0, 0.289);
v72 = v55 + 1.0;
v56 = 1.80301774085957e-17 / (v15 * v53 * pow(v55 + 1.0, 1.711));
if ( *(_DWORD *)(a2 + 304) )
{
xa = v49 / 2.999998240459423;
if ( v49 / 2.999998240459423 < 0.0 )
{
v22 = sqrt(xa);
v21 = sqrt(xa);
}
else
{
v21 = sqrt(v49 / 2.999998240459423);
v22 = v21;
}
xb = v22 * pow(v21 + 1.0, 0.289);
v23 = v49 / 130016.957803329;
if ( v49 / 130016.957803329 < 0.0 )
v24 = sqrt(v23);
else
v24 = sqrt(v23);
v25 = pow(v24 + 1.0, 1.711);
v26 = pow(v49 * *(double *)(a2 + 8), 1.5);
x = 7.21207096343828e-17 / (v25 * xb) * v26 * exp(COERCE_DOUBLE(*(_QWORD *)(a2 + 48) ^ LC30) / v49);
}
else
{
v16 = pow(v48 * *(double *)(a2 + 8), 1.5);
x = v56 * 4.0 * v16 * exp(COERCE_DOUBLE(*(_QWORD *)(a2 + 48) ^ LC30) / v48);
}
if ( *(double *)(a2 + 224) > a4 || a4 > *(double *)(a2 + 208) )
goto LABEL_13;
if ( *(double *)(a2 + 216) > a8 )
{
v17 = 2;
}
else
{
v17 = *(_DWORD *)(a2 + 192);
if ( !v17 )
{
LABEL_13:
v65 = *(double *)(a2 + 56) / a9;
v17 = 0;
v18 = *(double *)&LC36;
v50 = *(double *)&LC36;
v54 = *(double *)&LC36;
goto LABEL_14;
}
}
v74 = 1.0 - a4;
v66 = 1798287000.0 * *(double *)(a2 + 56) * 3.0 * v63 * (1.0 - a4) / a9;
v75 = (1.0
- exp(COERCE_DOUBLE(COERCE_UNSIGNED_INT64(1798287000.0 * *(double *)(a2 + 56) * 3.0 * v63 * (1.0 - a4) / a9) ^ LC30)))
/ v66
* 1798287000.0;
v65 = 1.0 / (3.0 * v75 * v63 * (1.0 - a4));
if ( (v17 == 2 || v17 > 4) && *(double *)(a2 + 248) > a6 )
{
v27 = v48 * 2.7613008e-23 / 5.973668968367626e-10;
if ( v27 < 0.0 )
v28 = sqrt(v27);
else
v28 = sqrt(v27);
v65 = 1.0
/ ((1798287000.0
/ (pow(
5394861000.0
* *(double *)(a2 + 32)
* v74
* 299792458.0
* 299792458.0
/ (v28
* 5.130494962245208e15
* 6.398182600193133e-21
* (1.0 - a6))
/ 2.632197855762346e31,
*(double *)(a2 + 232))
* 0.36
+ 1.0)
+ v75)
* 3.0
* v63
* v74);
}
if ( v17 > 2 )
{
v29 = pow(v53 + 1.0, 0.239);
v54 = 4.943106869868343e-17 / (v29 * v53 * pow(v72, 1.761));
if ( *(_DWORD *)(a2 + 304) )
{
v69 = v49 / 2.999998240459423;
if ( v49 / 2.999998240459423 < 0.0 )
{
v33 = sqrt(v69);
v32 = sqrt(v69);
}
else
{
v32 = sqrt(v49 / 2.999998240459423);
v33 = v32;
}
v70 = v33 * pow(v32 + 1.0, 0.239);
v34 = v49 / 130016.957803329;
if ( v49 / 130016.957803329 < 0.0 )
v35 = sqrt(v34);
else
v35 = sqrt(v34);
v36 = pow(v35 + 1.0, 1.761);
v73 = exp(-7.638815355750231e-19 / (v49 * 1.3806504e-23));
v50 = 4.943106869868343e-17 / (v36 * v70) * v73 * pow(v49 * *(double *)(a2 + 8), 1.5) * 4.0 / 3.0;
}
else
{
v30 = exp(-7.638815355750231e-19 / (v48 * 1.3806504e-23));
v50 = v30 * v54 * pow(v48 * *(double *)(a2 + 8), 1.5) * 4.0 / 3.0;
}
if ( *(_WORD *)(a1 + 3704) == 1 )
{
v37 = *(double *)(a2 + 288);
v38 = *(double *)(a2 + 296);
v54 = v37 * v37 / v38 / v38 * v54;
v50 = v37 * v37 * v37 * v37 * v37 * v38 * v50;
}
v68 = (1.0
- exp(COERCE_DOUBLE(COERCE_UNSIGNED_INT64(v63 * 177.58 * v74 * 3.0 / (a9
* 25.13274122871834
* 4.834279833216292e21)) ^ LC30)))
/ (v63
* 177.58
* v74
* 3.0
/ (a9
* 25.13274122871834
* 4.834279833216292e21));
if ( ((v17 - 3) & 0xFFFFFFFD) != 0 && a6 < *(double *)(a2 + 256) )
{
v39 = v48 * 2.7613008e-23 / 5.973668968367626e-10;
if ( v39 < 0.0 )
v40 = sqrt(v39);
else
v40 = sqrt(v39);
v41 = pow(
532.74
* *(double *)(a2 + 32)
* v74
* 299792458.0
* 299792458.0
/ (v40
* 5.069105129542034e15
* 6.614603463449192e-21
* (1.0 - a6))
/ 2.569582681434936e31,
0.9);
v42 = (v68 * 177.58 + 177.58 / (v41 * 0.66 + 1.0) / 3.0) * exp(-13281.58002324601 / v48);
v18 = v42 / (v50 + v42);
}
else
{
v31 = exp(-13281.58002324601 / v48);
v18 = v68 * 177.58 * v31 / (v50 + v68 * 177.58 * v31);
}
}
else
{
v18 = *(double *)&LC36;
v50 = *(double *)&LC36;
v54 = *(double *)&LC36;
}
LABEL_14:
if ( *(_WORD *)(a1 + 3704) == 1 )
{
v43 = *(double *)(a2 + 288);
v44 = *(double *)(a2 + 296);
v56 = v43 * v43 / v44 / v44 * v56;
x = v43 * v43 * v43 * v43 * v43 * v44 * x;
}
if ( a4 >= 1.0e-15 )
{
v45 = *(double *)(a2 + 104) / v48;
if ( *(double *)(a2 + 264) <= v45 )
v71 = exp(*(double *)(a2 + 264));
else
v71 = exp(v45);
v46 = *(double *)&LC37;
if ( *(_WORD *)(a1 + 3704) == 1 )
{
v65 = v65 / pow(*(double *)(a2 + 288) * *(double *)(a2 + 288) * *(double *)(a2 + 296), 3.0);
v46 = pow(*(double *)(a2 + 288), 8.0) * *(double *)(a2 + 296) * 51.3;
}
v47 = a4;
v52 = 1.0 - a4;
v59 = v47 * a5 * a7;
v58 = (a8 + 1.0) * a9;
*a3 = (v46 * v65 * v63 * v52 * v71 + 1.0)
/ ((v46 + x) * v65 * v63 * v52 * v71 + 1.0)
* (v56 * v59 - x * v52 * exp(COERCE_DOUBLE(*(_QWORD *)(a2 + 64) ^ LC30) / v48))
/ v58;
if ( v17 > 2 )
*a3 = (v59 * v54 - v52 * 3.0 * v50 * exp(COERCE_DOUBLE(*(_QWORD *)(a2 + 72) ^ LC30) / v48)) * v18 / v58 + *a3;
}
else
{
*a3 = 0.0;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2, double *a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10, double a11)
{
double v13; // xmm0_8
double v14; // xmm0_8
double v15; // r14
double v16; // r14
int v17; // er15
double v18; // r14
double v20; // xmm0_8
double v21; // xmm0_8
double v22; // r14
double v23; // xmm0_8
double v24; // xmm0_8
double v25; // r14
double v26; // r15
double v27; // xmm0_8
double v28; // xmm1_8
double v29; // r14
double v30; // r14
double v31; // xmm0_8
double v32; // xmm0_8
double v33; // r14
double v34; // xmm0_8
double v35; // xmm0_8
double v36; // r14
double v37; // xmm1_8
double v38; // xmm2_8
double v39; // xmm0_8
double v40; // xmm1_8
double v41; // rbp
double v42; // xmm0_8
double v43; // xmm1_8
double v44; // xmm2_8
double v45; // xmm0_8
double v46; // rbp
double v47; // xmm1_8
double v48; // [rsp+0h] [rbp-B8h]
double v49; // [rsp+8h] [rbp-B0h]
double v50; // [rsp+8h] [rbp-B0h]
double v52; // [rsp+10h] [rbp-A8h]
double v53; // [rsp+18h] [rbp-A0h]
double v54; // [rsp+18h] [rbp-A0h]
double v55; // [rsp+20h] [rbp-98h]
double v56; // [rsp+20h] [rbp-98h]
double v58; // [rsp+28h] [rbp-90h]
double v59; // [rsp+30h] [rbp-88h]
double x; // [rsp+38h] [rbp-80h]
double xa; // [rsp+38h] [rbp-80h]
double xb; // [rsp+38h] [rbp-80h]
double v63; // [rsp+40h] [rbp-78h]
double v65; // [rsp+50h] [rbp-68h]
double v66; // [rsp+50h] [rbp-68h]
double v68; // [rsp+60h] [rbp-58h]
double v69; // [rsp+60h] [rbp-58h]
double v70; // [rsp+60h] [rbp-58h]
double v71; // [rsp+60h] [rbp-58h]
double v72; // [rsp+68h] [rbp-50h]
double v73; // [rsp+68h] [rbp-50h]
double v74; // [rsp+70h] [rbp-48h]
double v75; // [rsp+78h] [rbp-40h]

v48 = a10;
v49 = a11;
if ( *(_WORD *)(a1 + 3704) == 1 )
{
v20 = *(double *)(a2 + 288) * *(double *)(a2 + 288) * *(double *)(a2 + 296);
v48 = a10 / v20;
v49 = a11 / v20;
}
v63 = a7 * *(double *)(a2 + 32);
v13 = v48 / 2.999998240459423;
if ( v48 / 2.999998240459423 < 0.0 )
v53 = sqrt(v13);
else
v53 = sqrt(v13);
v14 = v48 / 130016.957803329;
if ( v48 / 130016.957803329 < 0.0 )
v55 = sqrt(v14);
else
v55 = sqrt(v14);
v15 = pow(v53 + 1.0, 0.289);
v72 = v55 + 1.0;
v56 = 1.80301774085957e-17 / (v15 * v53 * pow(v55 + 1.0, 1.711));
if ( *(_DWORD *)(a2 + 304) )
{
xa = v49 / 2.999998240459423;
if ( v49 / 2.999998240459423 < 0.0 )
{
v22 = sqrt(xa);
v21 = sqrt(xa);
}
else
{
v21 = sqrt(v49 / 2.999998240459423);
v22 = v21;
}
xb = v22 * pow(v21 + 1.0, 0.289);
v23 = v49 / 130016.957803329;
if ( v49 / 130016.957803329 < 0.0 )
v24 = sqrt(v23);
else
v24 = sqrt(v23);
v25 = pow(v24 + 1.0, 1.711);
v26 = pow(v49 * *(double *)(a2 + 8), 1.5);
x = 7.21207096343828e-17 / (v25 * xb) * v26 * exp(COERCE_DOUBLE(*(_QWORD *)(a2 + 48) ^ LC30) / v49);
}
else
{
v16 = pow(v48 * *(double *)(a2 + 8), 1.5);
x = v56 * 4.0 * v16 * exp(COERCE_DOUBLE(*(_QWORD *)(a2 + 48) ^ LC30) / v48);
}
if ( *(double *)(a2 + 224) > a4 || a4 > *(double *)(a2 + 208) )
goto LABEL_13;
if ( *(double *)(a2 + 216) > a8 )
{
v17 = 2;
}
else
{
v17 = *(_DWORD *)(a2 + 192);
if ( !v17 )
{
LABEL_13:
v65 = *(double *)(a2 + 56) / a9;
v17 = 0;
v18 = *(double *)&LC36;
v50 = *(double *)&LC36;
v54 = *(double *)&LC36;
goto LABEL_14;
}
}
v74 = 1.0 - a4;
v66 = 1798287000.0 * *(double *)(a2 + 56) * 3.0 * v63 * (1.0 - a4) / a9;
v75 = (1.0
- exp(COERCE_DOUBLE(COERCE_UNSIGNED_INT64(1798287000.0 * *(double *)(a2 + 56) * 3.0 * v63 * (1.0 - a4) / a9) ^ LC30)))
/ v66
* 1798287000.0;
v65 = 1.0 / (3.0 * v75 * v63 * (1.0 - a4));
if ( (v17 == 2 || v17 > 4) && *(double *)(a2 + 248) > a6 )
{
v27 = v48 * 2.7613008e-23 / 5.973668968367626e-10;
if ( v27 < 0.0 )
v28 = sqrt(v27);
else
v28 = sqrt(v27);
v65 = 1.0
/ ((1798287000.0
/ (pow(
5394861000.0
* *(double *)(a2 + 32)
* v74
* 299792458.0
* 299792458.0
/ (v28
* 5.130494962245208e15
* 6.398182600193133e-21
* (1.0 - a6))
/ 2.632197855762346e31,
*(double *)(a2 + 232))
* 0.36
+ 1.0)
+ v75)
* 3.0
* v63
* v74);
}
if ( v17 > 2 )
{
v29 = pow(v53 + 1.0, 0.239);
v54 = 4.943106869868343e-17 / (v29 * v53 * pow(v72, 1.761));
if ( *(_DWORD *)(a2 + 304) )
{
v69 = v49 / 2.999998240459423;
if ( v49 / 2.999998240459423 < 0.0 )
{
v33 = sqrt(v69);
v32 = sqrt(v69);
}
else
{
v32 = sqrt(v49 / 2.999998240459423);
v33 = v32;
}
v70 = v33 * pow(v32 + 1.0, 0.239);
v34 = v49 / 130016.957803329;
if ( v49 / 130016.957803329 < 0.0 )
v35 = sqrt(v34);
else
v35 = sqrt(v34);
v36 = pow(v35 + 1.0, 1.761);
v73 = exp(-7.638815355750231e-19 / (v49 * 1.3806504e-23));
v50 = 4.943106869868343e-17 / (v36 * v70) * v73 * pow(v49 * *(double *)(a2 + 8), 1.5) * 4.0 / 3.0;
}
else
{
v30 = exp(-7.638815355750231e-19 / (v48 * 1.3806504e-23));
v50 = v30 * v54 * pow(v48 * *(double *)(a2 + 8), 1.5) * 4.0 / 3.0;
}
if ( *(_WORD *)(a1 + 3704) == 1 )
{
v37 = *(double *)(a2 + 288);
v38 = *(double *)(a2 + 296);
v54 = v37 * v37 / v38 / v38 * v54;
v50 = v37 * v37 * v37 * v37 * v37 * v38 * v50;
}
v68 = (1.0
- exp(COERCE_DOUBLE(COERCE_UNSIGNED_INT64(v63 * 177.58 * v74 * 3.0 / (a9
* 25.13274122871834
* 4.834279833216292e21)) ^ LC30)))
/ (v63
* 177.58
* v74
* 3.0
/ (a9
* 25.13274122871834
* 4.834279833216292e21));
if ( ((v17 - 3) & 0xFFFFFFFD) != 0 && a6 < *(double *)(a2 + 256) )
{
v39 = v48 * 2.7613008e-23 / 5.973668968367626e-10;
if ( v39 < 0.0 )
v40 = sqrt(v39);
else
v40 = sqrt(v39);
v41 = pow(
532.74
* *(double *)(a2 + 32)
* v74
* 299792458.0
* 299792458.0
/ (v40
* 5.069105129542034e15
* 6.614603463449192e-21
* (1.0 - a6))
/ 2.569582681434936e31,
0.9);
v42 = (v68 * 177.58 + 177.58 / (v41 * 0.66 + 1.0) / 3.0) * exp(-13281.58002324601 / v48);
v18 = v42 / (v50 + v42);
}
else
{
v31 = exp(-13281.58002324601 / v48);
v18 = v68 * 177.58 * v31 / (v50 + v68 * 177.58 * v31);
}
}
else
{
v18 = *(double *)&LC36;
v50 = *(double *)&LC36;
v54 = *(double *)&LC36;
}
LABEL_14:
if ( *(_WORD *)(a1 + 3704) == 1 )
{
v43 = *(double *)(a2 + 288);
v44 = *(double *)(a2 + 296);
v56 = v43 * v43 / v44 / v44 * v56;
x = v43 * v43 * v43 * v43 * v43 * v44 * x;
}
if ( a4 >= 1.0e-15 )
{
v45 = *(double *)(a2 + 104) / v48;
if ( *(double *)(a2 + 264) <= v45 )
v71 = exp(*(double *)(a2 + 264));
else
v71 = exp(v45);
v46 = *(double *)&LC37;
if ( *(_WORD *)(a1 + 3704) == 1 )
{
v65 = v65 / pow(*(double *)(a2 + 288) * *(double *)(a2 + 288) * *(double *)(a2 + 296), 3.0);
v46 = pow(*(double *)(a2 + 288), 8.0) * *(double *)(a2 + 296) * 51.3;
}
v47 = a4;
v52 = 1.0 - a4;
v59 = v47 * a5 * a7;
v58 = (a8 + 1.0) * a9;
*a3 = (v46 * v65 * v63 * v52 * v71 + 1.0)
/ ((v46 + x) * v65 * v63 * v52 * v71 + 1.0)
* (v56 * v59 - x * v52 * exp(COERCE_DOUBLE(*(_QWORD *)(a2 + 64) ^ LC30) / v48))
/ v58;
if ( v17 > 2 )
*a3 = (v59 * v54 - v52 * 3.0 * v50 * exp(COERCE_DOUBLE(*(_QWORD *)(a2 + 72) ^ LC30) / v48)) * v18 / v58 + *a3;
}
else
{
*a3 = 0.0;
}
return 0LL;
}

original_code:
int recfast_dx_He_dz(struct thermodynamics* pth, struct thermorecfast * pre, double x_He, double x, double x_H, double nH,
                     double z, double Hz, double Tmat, double Trad,
                     double* dxHe_dz) {
  double Rdown_trip,Rup_trip,tauHe_s,pHe_s,tauHe_t,pHe_t,CL_PSt;
  double Doppler,gamma_2Ps,gamma_2Pt,pb,qb,AHcon;
  double sq_0,sq_1;
  double K_He,Rup_He,Rdown_He,He_Boltz;
  double CfHe_t=0.;
  double C_He;
  double n_He;
  int Heflag;
  double A2s1sHe = 51.3;
  Rdown_trip = 0.; Rup_trip = 0.;
  if (pth->has_varconst == 1) {
    Tmat /= pre->fsR*pre->fsR*pre->meR;
    Trad /= pre->fsR*pre->fsR*pre->meR;
  }
  n_He = pre->fHe * nH;
  sq_0 = sqrt(Tmat/pow(10.,0.477121));
  sq_1 = sqrt(Tmat/pow(10.,5.114));
  Rdown_He = pow(10.,-16.744)/(sq_0 * pow((1.+sq_0),(1.-0.711)) * pow((1. + sq_1),(1. + 0.711)));
  switch (pre->photoion_mode){
    case recfast_photoion_Tmat:
      Rup_He = 4.*Rdown_He*pow((pre->CR*Tmat),1.5)*exp(-pre->CDB_He/Tmat);
      break;
    case recfast_photoion_Trad:
    default:
      Rup_He = 4.*pow(10.,-16.744)/(sqrt(Trad/pow(10.,0.477121)) * pow((1.+sqrt(Trad/pow(10.,0.477121))),(1.-0.711)) * pow((1. + sqrt(Trad/pow(10.,5.114))),(1. + 0.711))) * pow((pre->CR*Trad),1.5)*exp(-pre->CDB_He/Trad);
      break;
  }
  if ((x_He < pre->x_He_trigger_small) || (x_He > pre->x_He0_trigger2)){
    Heflag = 0;
  }
  else if(z<pre->z_switch_late){
    Heflag = 2;
  }
  else{
    Heflag = pre->Heswitch;
  }
  if (Heflag == 0){
    K_He = pre->CK_He/Hz;
  }
  else {
    tauHe_s = 1.798287e9*pre->CK_He*3.*n_He*(1.-x_He)/Hz;
    pHe_s = (1.-exp(-tauHe_s))/tauHe_s;
    K_He = 1./(1.798287e9*pHe_s*3.*n_He*(1.-x_He));
    if (((Heflag == 2) || (Heflag >= 5)) && (x_H < pre->x_H_limit_KHe)) {
      Doppler = 2.*1.3806504e-23*Tmat/(1.673575e-27*3.9715*2.99792458e8*2.99792458e8);
      Doppler = 2.99792458e8*1.71134891e7*sqrt(Doppler);
      gamma_2Ps = 3.*1.798287e9*pre->fHe*(1.-x_He)*2.99792458e8*2.99792458e8
          /(sqrt(3.1415926535897932384626433832795e0)*1.436289e-22*8.*3.1415926535897932384626433832795e0*Doppler*(1.-x_H))
          /pow(2.99792458e8*1.71134891e7,2);
      pb = 0.36;
      qb = pre->fudge_He;
      AHcon = 1.798287e9/(1.+pb*pow(gamma_2Ps,qb));
      K_He=1./((1.798287e9*pHe_s+AHcon)*3.*n_He*(1.-x_He));
    }
    if (Heflag >= 3) {
      Rdown_trip = pow(10.,-16.306)/(sq_0*pow((1.+sq_0),(1.-0.761)) * pow((1.+sq_1),(1.+0.761)));
      switch (pre->photoion_mode){
        case recfast_photoion_Tmat:
          Rup_trip = Rdown_trip*exp(-6.62606896e-34*2.99792458e8*3.8454693845e6/(1.3806504e-23*Tmat))*pow(pre->CR*Tmat,1.5)*4./3.;
          break;
        case recfast_photoion_Trad:
        default:
          Rup_trip = pow(10.,-16.306)/(sqrt(Trad/pow(10.,0.477121))*pow((1.+sqrt(Trad/pow(10.,0.477121))),(1.-0.761)) * pow((1.+sqrt(Trad/pow(10.,5.114))),(1.+0.761))) *exp(-6.62606896e-34*2.99792458e8*3.8454693845e6/(1.3806504e-23*Trad))*pow(pre->CR*Trad,1.5)*4./3.;
          break;
      }
      if (pth->has_varconst == 1) {
        Rdown_trip *= pre->fsR*pre->fsR/pre->meR/pre->meR;
        Rup_trip *= pre->fsR*pre->fsR*pre->fsR*pre->fsR*pre->fsR*pre->meR;
      }
      tauHe_t = 177.58e0*n_He*(1.-x_He)*3./(8.*3.1415926535897932384626433832795e0*Hz*pow(1.690871466e7,3));
      pHe_t = (1. - exp(-tauHe_t))/tauHe_t;
      CL_PSt = 6.62606896e-34*2.99792458e8*(1.690871466e7 - 1.5985597526e7)/1.3806504e-23;
      if ((Heflag == 3) || (Heflag == 5) || (x_H >= pre->x_H_limit_CfHe_t)) {
        CfHe_t = 177.58e0*pHe_t*exp(-CL_PSt/Tmat);
        CfHe_t = CfHe_t/(Rup_trip+CfHe_t);
      }
      else {
        Doppler = 2.*1.3806504e-23*Tmat/(1.673575e-27*3.9715*2.99792458e8*2.99792458e8);
        Doppler = 2.99792458e8*1.690871466e7*sqrt(Doppler);
        gamma_2Pt = 3.*177.58e0*pre->fHe*(1.-x_He)*2.99792458e8*2.99792458e8
          /(sqrt(3.1415926535897932384626433832795e0)*1.484872e-22*8.*3.1415926535897932384626433832795e0*Doppler*(1.-x_H))
          /pow(2.99792458e8*1.690871466e7,2);
        pb = 0.66;
        qb = 0.9;
        AHcon = 177.58e0/(1.+pb*pow(gamma_2Pt,qb))/3.;
        CfHe_t = (177.58e0*pHe_t+AHcon)*exp(-CL_PSt/Tmat);
        CfHe_t = CfHe_t/(Rup_trip+CfHe_t);
      }
    }
  }
  if (pth->has_varconst == 1) {
    Rdown_He *= pre->fsR*pre->fsR/pre->meR/pre->meR;
    Rup_He *= pre->fsR*pre->fsR*pre->fsR*pre->fsR*pre->fsR*pre->meR;
  }
  if (x_He < 1.e-15){
    *dxHe_dz=0.;
  }
  else {
    if (pre->CDB_He2s2p/Tmat < pre->max_exp_boltz){
      He_Boltz=exp(pre->CDB_He2s2p/Tmat);
    }
    else{
      He_Boltz=exp(pre->max_exp_boltz);
    }
    if (pth->has_varconst == 1) {
      K_He /= pow(pre->fsR*pre->fsR*pre->meR,3);
      A2s1sHe *= pow(pre->fsR, 8)*pre->meR;
    }
    C_He = (1. + K_He*A2s1sHe*n_He*(1.-x_He)*He_Boltz)/(1. + K_He*(A2s1sHe+Rup_He)*n_He*(1.-x_He)*He_Boltz);
    *dxHe_dz = (x*x_He*nH*Rdown_He - Rup_He*(1.-x_He)*exp(-pre->CL_He/Tmat)) * C_He / (Hz*(1+z));
    if (Heflag >= 3){
      *dxHe_dz += (x*x_He*nH*Rdown_trip - (1.-x_He)*3.*Rup_trip*exp(-pre->CL_Het/Tmat)) *CfHe_t/(Hz*(1.+z));
    }
  }
  return 0;
}

canonical_original_code:
int recfast_dx_He_dz(struct thermodynamics *pth, struct thermorecfast *pre, double x_He, double x, double x_H, double nH, double z, double Hz, double Tmat, double Trad, double *dxHe_dz) {
  double Rdown_trip; double Rup_trip; double tauHe_s; double pHe_s; double tauHe_t; double pHe_t; double CL_PSt;
  double Doppler; double gamma_2Ps; double gamma_2Pt; double pb; double qb; double AHcon;
  double sq_0; double sq_1;
  double K_He; double Rup_He; double Rdown_He; double He_Boltz;
  double CfHe_t = 0.;
  double C_He;
  double n_He;
  int Heflag;
  double A2s1sHe = 51.3;
  Rdown_trip = 0.; Rup_trip = 0.;
  if (pth->has_varconst == 1) {
    Tmat /= pre->fsR*pre->fsR*pre->meR;
    Trad /= pre->fsR*pre->fsR*pre->meR;
  }
  n_He = pre->fHe * nH;
  sq_0 = sqrt(Tmat/pow(10.,0.477121));
  sq_1 = sqrt(Tmat/pow(10.,5.114));
  Rdown_He = pow(10.,-16.744)/(sq_0 * pow((1.+sq_0),(1.-0.711)) * pow((1. + sq_1),(1. + 0.711)));
  switch (pre->photoion_mode){
    case recfast_photoion_Tmat:
      Rup_He = 4.*Rdown_He*pow((pre->CR*Tmat),1.5)*exp(-pre->CDB_He/Tmat);
      break;
    case recfast_photoion_Trad:
    default:
      Rup_He = 4.*pow(10.,-16.744)/(sqrt(Trad/pow(10.,0.477121)) * pow((1.+sqrt(Trad/pow(10.,0.477121))),(1.-0.711)) * pow((1. + sqrt(Trad/pow(10.,5.114))),(1. + 0.711))) * pow((pre->CR*Trad),1.5)*exp(-pre->CDB_He/Trad);
      break;
  }
  if ((x_He < pre->x_He_trigger_small) || (x_He > pre->x_He0_trigger2)){
    Heflag = 0;
  }
  else if(z<pre->z_switch_late){
    Heflag = 2;
  }
  else{
    Heflag = pre->Heswitch;
  }
  if (Heflag == 0){
    K_He = pre->CK_He/Hz;
  }
  else {
    tauHe_s = 1.798287e9*pre->CK_He*3.*n_He*(1.-x_He)/Hz;
    pHe_s = (1.-exp(-tauHe_s))/tauHe_s;
    K_He = 1./(1.798287e9*pHe_s*3.*n_He*(1.-x_He));
    if (((Heflag == 2) || (Heflag >= 5)) && (x_H < pre->x_H_limit_KHe)) {
      Doppler = 2.*1.3806504e-23*Tmat/(1.673575e-27*3.9715*2.99792458e8*2.99792458e8);
      Doppler = 2.99792458e8*1.71134891e7*sqrt(Doppler);
      gamma_2Ps = 3.*1.798287e9*pre->fHe*(1.-x_He)*2.99792458e8*2.99792458e8
          /(sqrt(3.1415926535897932384626433832795e0)*1.436289e-22*8.*3.1415926535897932384626433832795e0*Doppler*(1.-x_H))
          /pow(2.99792458e8*1.71134891e7,2);
      pb = 0.36;
      qb = pre->fudge_He;
      AHcon = 1.798287e9/(1.+pb*pow(gamma_2Ps,qb));
      K_He=1./((1.798287e9*pHe_s+AHcon)*3.*n_He*(1.-x_He));
    }
    if (Heflag >= 3) {
      Rdown_trip = pow(10.,-16.306)/(sq_0*pow((1.+sq_0),(1.-0.761)) * pow((1.+sq_1),(1.+0.761)));
      switch (pre->photoion_mode){
        case recfast_photoion_Tmat:
          Rup_trip = Rdown_trip*exp(-6.62606896e-34*2.99792458e8*3.8454693845e6/(1.3806504e-23*Tmat))*pow(pre->CR*Tmat,1.5)*4./3.;
          break;
        case recfast_photoion_Trad:
        default:
          Rup_trip = pow(10.,-16.306)/(sqrt(Trad/pow(10.,0.477121))*pow((1.+sqrt(Trad/pow(10.,0.477121))),(1.-0.761)) * pow((1.+sqrt(Trad/pow(10.,5.114))),(1.+0.761))) *exp(-6.62606896e-34*2.99792458e8*3.8454693845e6/(1.3806504e-23*Trad))*pow(pre->CR*Trad,1.5)*4./3.;
          break;
      }
      if (pth->has_varconst == 1) {
        Rdown_trip *= pre->fsR*pre->fsR/pre->meR/pre->meR;
        Rup_trip *= pre->fsR*pre->fsR*pre->fsR*pre->fsR*pre->fsR*pre->meR;
      }
      tauHe_t = 177.58e0*n_He*(1.-x_He)*3./(8.*3.1415926535897932384626433832795e0*Hz*pow(1.690871466e7,3));
      pHe_t = (1. - exp(-tauHe_t))/tauHe_t;
      CL_PSt = 6.62606896e-34*2.99792458e8*(1.690871466e7 - 1.5985597526e7)/1.3806504e-23;
      if ((Heflag == 3) || (Heflag == 5) || (x_H >= pre->x_H_limit_CfHe_t)) {
        CfHe_t = 177.58e0*pHe_t*exp(-CL_PSt/Tmat);
        CfHe_t = CfHe_t/(Rup_trip+CfHe_t);
      }
      else {
        Doppler = 2.*1.3806504e-23*Tmat/(1.673575e-27*3.9715*2.99792458e8*2.99792458e8);
        Doppler = 2.99792458e8*1.690871466e7*sqrt(Doppler);
        gamma_2Pt = 3.*177.58e0*pre->fHe*(1.-x_He)*2.99792458e8*2.99792458e8
          /(sqrt(3.1415926535897932384626433832795e0)*1.484872e-22*8.*3.1415926535897932384626433832795e0*Doppler*(1.-x_H))
          /pow(2.99792458e8*1.690871466e7,2);
        pb = 0.66;
        qb = 0.9;
        AHcon = 177.58e0/(1.+pb*pow(gamma_2Pt,qb))/3.;
        CfHe_t = (177.58e0*pHe_t+AHcon)*exp(-CL_PSt/Tmat);
        CfHe_t = CfHe_t/(Rup_trip+CfHe_t);
      }
    }
  }
  if (pth->has_varconst == 1) {
    Rdown_He *= pre->fsR*pre->fsR/pre->meR/pre->meR;
    Rup_He *= pre->fsR*pre->fsR*pre->fsR*pre->fsR*pre->fsR*pre->meR;
  }
  if (x_He < 1.e-15){
    *dxHe_dz=0.;
  }
  else {
    if (pre->CDB_He2s2p/Tmat < pre->max_exp_boltz){
      He_Boltz=exp(pre->CDB_He2s2p/Tmat);
    }
    else{
      He_Boltz=exp(pre->max_exp_boltz);
    }
    if (pth->has_varconst == 1) {
      K_He /= pow(pre->fsR*pre->fsR*pre->meR,3);
      A2s1sHe *= pow(pre->fsR, 8)*pre->meR;
    }
    C_He = (1. + K_He*A2s1sHe*n_He*(1.-x_He)*He_Boltz)/(1. + K_He*(A2s1sHe+Rup_He)*n_He*(1.-x_He)*He_Boltz);
    *dxHe_dz = (x*x_He*nH*Rdown_He - Rup_He*(1.-x_He)*exp(-pre->CL_He/Tmat)) * C_He / (Hz*(1+z));
    if (Heflag >= 3){
      *dxHe_dz += (x*x_He*nH*Rdown_trip - (1.-x_He)*3.*Rup_trip*exp(-pre->CL_Het/Tmat)) *CfHe_t/(Hz*(1.+z));
    }
  }
  return 0;
}

variable_types: Doppler double

variable_types: pb double

variable_types: qb double

variable_types: AHcon double

variable_types: Heflag int

user_defined_types: enum recombination_algorithm { recfast=0, hyrec=1 }

user_defined_types: enum recfast_photoion_modes { recfast_photoion_Tmat=0, recfast_photoion_Trad=1 }

user_defined_types: enum reionization_parametrization { reio_none=0, reio_camb=1, reio_bins_tanh=2, reio_half_tanh=3, reio_many_tanh=4, reio_inter=5 }

user_defined_types: enum reionization_z_or_tau { reio_z=0, reio_tau=1 }

user_defined_types: enum PBH_accretion_approx { spherical_accretion=0, disk_accretion=1 }


decompiled_code:
__int64 __fastcall thermodynamics_hyrec_free(void **a1)
{
hyrec_free(*a1);
free(*a1);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(void **a1)
{
hyrec_free(*a1);
free(*a1);
return 0LL;
}

original_code:
int thermodynamics_hyrec_free(struct thermohyrec* phy){
  hyrec_free(phy->data);
  free(phy->data);
  return 0;
}

canonical_original_code:
int thermodynamics_hyrec_free(struct thermohyrec *phy){
  hyrec_free(phy->data);
  free(phy->data);
  return 0;
}

variable_types: struct thermohyrec { struct HYREC_DATA { struct HYREC_ATOMIC { double logTR_tab[100]; double T_RATIO_tab[40]; double **logAlpha_tab[4]; double logR2p2s_tab[100]; double DlogTR; double Eb_tab[311]; double A1s_tab[311]; double A2s_tab[311]; double A3s3d_tab[311]; double A4s4d_tab[311]; } *atomic; struct REC_COSMOPARAMS { double h; double T0; double obh2; double w0; double Neff; double Nur; double Nmnu; double mnu[3]; double fHe; double nH0; double YHe; double fsR; double dlna; struct INJ_PARAMS { double odmh2; double pann; double ann_z; double ann_z_halo; double decay; double Mpbh; int on_the_spot; double ion; } *inj_params; } *cosmo; double zmax; double zmin; long Nz; double *xe_output; double *Tm_output; int error; int quasi_eq; int loop_after_quasi; int Tm_evolve_implicit; char *error_message; char *path_to_hyrec; struct RADIATION { double z0; long iz_rad_0; double **Dfminus_hist; double **Dfnu_hist; double **Dfminus_Ly_hist; } *rad; struct FIT_FUNC { double *swift_func[5]; } *fit; } *data; double zstart; double zend; double xHeII_limit; char error_message[2048]; int thermohyrec_verbose; } *

return_type: int

user_defined_types: struct thermohyrec { struct HYREC_DATA *data; double zstart; double zend; double xHeII_limit; char error_message[2048]; int thermohyrec_verbose; }

user_defined_types: struct HYREC_DATA { struct HYREC_ATOMIC *atomic; struct REC_COSMOPARAMS *cosmo; double zmax; double zmin; long Nz; double *xe_output; double *Tm_output; int error; int quasi_eq; int loop_after_quasi; int Tm_evolve_implicit; char *error_message; char *path_to_hyrec; struct RADIATION *rad; struct FIT_FUNC *fit; }

user_defined_types: struct REC_COSMOPARAMS { double h; double T0; double obh2; double w0; double Neff; double Nur; double Nmnu; double mnu[3]; double fHe; double nH0; double YHe; double fsR; double dlna; struct INJ_PARAMS *inj_params; }


original_code:
int hyrec_dx_H_dz(struct thermodynamics* pth, struct thermohyrec* phy, double x_H, double x_He, double xe, double nH, double z, double Hz, double Tmat, double Trad, double alpha, double me, double *dx_H_dz) {
  struct injection* pin = &(pth->in);
  long iz = 0;
  int model;
  double Trad_phys;
  { if (4 == 3) { { ErrorMsg Optional_arguments; class_protect_sprintf(Optional_arguments,"FULL mode is currently not allowed for HyRec-2"); { ErrorMsg FMsg; class_protect_sprintf(FMsg,"condition (%s) is true; %s","MODEL == FULL",Optional_arguments); class_protect_sprintf(phy->error_message,"%s(L:%d) :%s",__func__,114,FMsg); }; }; return 1; } };
  if (pth->has_exotic_injection == 1) {
    phy->data->cosmo->inj_params->ion = pin->pvecdeposition[pin->index_dep_ionH]/nH/(13.5984336478*1.602176487e-19);
    phy->data->cosmo->inj_params->exclya = pin->pvecdeposition[pin->index_dep_lya]/nH/(10.1988356821*1.602176487e-19);
  }
  else{
    phy->data->cosmo->inj_params->ion = 0.;
    phy->data->cosmo->inj_params->exclya = 0.;
  }
  if (pth->has_varconst == 1) {
    phy->data->cosmo->fsR = alpha;
    phy->data->cosmo->meR = me;
  }
  Trad_phys = Trad*8.617343e-5;
  if (pth->has_varconst == 1) {
    Trad_phys /= phy->data->cosmo->fsR*phy->data->cosmo->fsR*phy->data->cosmo->meR;
  }
  if (Trad_phys <= 0.004 || Tmat/Trad <= 0.1) { model = 0; }
  else { model = 4; }
  *dx_H_dz = -1./(1.+z)* rec_dxHIIdlna(phy->data, model, xe, x_H, nH*1e-6, Hz, Tmat*8.617343e-5, Trad*8.617343e-5, iz, z);
  if(phy->data->error != 0){
    { ErrorMsg FMsg; class_protect_sprintf(FMsg,"error in %s;\n=>%s","rec_dxHIIdlna",phy->data->error_message); class_protect_sprintf(phy->error_message,"%s(L:%d) :%s",__func__,143,FMsg); };;
    return 1;
  }
  return 0;
}

canonical_original_code:
int hyrec_dx_H_dz(struct thermodynamics *pth, struct thermohyrec *phy, double x_H, double x_He, double xe, double nH, double z, double Hz, double Tmat, double Trad, double alpha, double me, double *dx_H_dz) {
  struct injection *pin = &(pth->in);
  long iz = 0;
  int model;
  double Trad_phys;
  { if (4 == 3) { { char Optional_arguments[2048]; class_protect_sprintf(Optional_arguments,"FULL mode is currently not allowed for HyRec-2"); { char FMsg[2048]; class_protect_sprintf(FMsg,"condition (%s) is true; %s","MODEL == FULL",Optional_arguments); class_protect_sprintf(phy->error_message,"%s(L:%d) :%s",__func__,114,FMsg); }; }; return 1; } };
  if (pth->has_exotic_injection == 1) {
    phy->data->cosmo->inj_params->ion = pin->pvecdeposition[pin->index_dep_ionH]/nH/(13.5984336478*1.602176487e-19);
    phy->data->cosmo->inj_params->exclya = pin->pvecdeposition[pin->index_dep_lya]/nH/(10.1988356821*1.602176487e-19);
  }
  else{
    phy->data->cosmo->inj_params->ion = 0.;
    phy->data->cosmo->inj_params->exclya = 0.;
  }
  if (pth->has_varconst == 1) {
    phy->data->cosmo->fsR = alpha;
    phy->data->cosmo->meR = me;
  }
  Trad_phys = Trad*8.617343e-5;
  if (pth->has_varconst == 1) {
    Trad_phys /= phy->data->cosmo->fsR*phy->data->cosmo->fsR*phy->data->cosmo->meR;
  }
  if (Trad_phys <= 0.004 || Tmat/Trad <= 0.1) { model = 0; }
  else { model = 4; }
  *dx_H_dz = -1./(1.+z)* rec_dxHIIdlna(phy->data, model, xe, x_H, nH*1e-6, Hz, Tmat*8.617343e-5, Trad*8.617343e-5, iz, z);
  if(phy->data->error != 0){
    { char FMsg[2048]; class_protect_sprintf(FMsg,"error in %s;\n=>%s","rec_dxHIIdlna",phy->data->error_message); class_protect_sprintf(phy->error_message,"%s(L:%d) :%s",__func__,143,FMsg); };;
    return 1;
  }
  return 0;
}

variable_types: struct thermodynamics { double YHe; double bbn_alpha_sensitivity; enum recombination_algorithm { recfast=0, hyrec=1 } recombination; enum recfast_photoion_modes { recfast_photoion_Tmat=0, recfast_photoion_Trad=1 } recfast_photoion_mode; enum reionization_parametrization { reio_none=0, reio_camb=1, reio_bins_tanh=2, reio_half_tanh=3, reio_many_tanh=4, reio_inter=5 } reio_parametrization; enum reionization_z_or_tau { reio_z=0, reio_tau=1 } reio_z_or_tau; double tau_reio; double z_reio; short compute_cb2_derivatives; short compute_damping_scale; short has_idm_b; short has_idm_g; short has_idm_dr; double reionization_width; double reionization_exponent; double helium_fullreio_redshift; double helium_fullreio_width; int binned_reio_num; double *binned_reio_z; double *binned_reio_xe; double binned_reio_step_sharpness; int many_tanh_num; double *many_tanh_z; double *many_tanh_xe; double many_tanh_width; int reio_inter_num; double *reio_inter_z; double *reio_inter_xe; short has_exotic_injection; struct injection { double DM_annihilation_efficiency; double DM_annihilation_cross_section; double DM_annihilation_mass; double DM_annihilation_fraction; double DM_annihilation_variation; double DM_annihilation_z; double DM_annihilation_zmax; double DM_annihilation_zmin; double DM_annihilation_f_halo; double DM_annihilation_z_halo; double DM_decay_fraction; double DM_decay_Gamma; double PBH_evaporation_fraction; double PBH_evaporation_mass; double PBH_accretion_fraction; double PBH_accretion_mass; enum PBH_accretion_approx { spherical_accretion=0, disk_accretion=1 } PBH_accretion_recipe; double PBH_accretion_relative_velocities; double PBH_accretion_ADAF_delta; double PBH_accretion_eigenvalue; int f_eff_type; char f_eff_file[256]; int chi_type; char chi_z_file[256]; char chi_x_file[256]; int Nz_size; double z_initial; double z_start_chi_approx; double H0; double T_g0; double Omega0_b; double Omega0_cdm; double rho0_cdm; double H; double a; double t; double rho_g; double rho_b; double rho_cdm; double fHe; double N_e0; double heat_capacity; double T_b; double x_e; double nH; double *z_table; int z_size; double tol_z_table; int filled_until_index_z; double filled_until_z; int last_index_z_feff; int last_index_z_chi; int last_index_z_inj; int last_index_z; int index_z_store; int last_index_x_chi; double PBH_z_evaporation; double PBH_QCD_activation; double *PBH_table_z; double *PBH_table_mass; double *PBH_table_mass_dd; double *PBH_table_F; double *PBH_table_F_dd; int Nz_PBH; double **injection_table; int index_inj_cool; int index_inj_diss; int index_inj_DM_ann; int index_inj_DM_dec; int index_inj_PBH_eva; int index_inj_PBH_acc; int index_inj_tot; int inj_size; double f_eff; int feff_z_size; double *feff_table; double *chiz_table; int chiz_size; double *chix_table; int chix_size; double **deposition_table; double *chi; int index_dep_heat; int index_dep_ionH; int index_dep_ionHe; int index_dep_lya; int index_dep_lowE; int dep_size; double *pvecdeposition; int has_exotic_injection; int has_DM_ann; int has_DM_dec; int has_PBH_eva; int has_PBH_acc; int to_store; char error_message[2048]; } in; double annihilation; short has_on_the_spot; double decay; double annihilation_variation; double annihilation_z; double annihilation_zmax; double annihilation_zmin; double annihilation_f_halo; double annihilation_z_halo; short has_varconst; int index_th_xe; int index_th_dkappa; int index_th_tau_d; int index_th_ddkappa; int index_th_dddkappa; int index_th_exp_m_kappa; int index_th_g; int index_th_dg; int index_th_ddg; int index_th_T_idm; int index_th_c2_idm; int index_th_T_idr; int index_th_dmu_idm_dr; int index_th_ddmu_idm_dr; int index_th_dddmu_idm_dr; int index_th_dmu_idr; int index_th_tau_idm_dr; int index_th_tau_idr; int index_th_g_idm_dr; int index_th_dmu_idm_g; int index_th_ddmu_idm_g; int index_th_dddmu_idm_g; int index_th_exp_mu_idm_g; int index_th_R_idm_b; int index_th_dR_idm_b; int index_th_ddR_idm_b; int index_th_Tb; int index_th_dTb; int index_th_wb; int index_th_cb2; int index_th_dcb2; int index_th_ddcb2; int index_th_rate; int index_th_r_d; int th_size; int tt_size; double *z_table; double *tau_table; double *thermodynamics_table; double *d2thermodynamics_dz2_table; double z_rec; double tau_rec; double rs_rec; double ds_rec; double ra_rec; double da_rec; double rd_rec; double z_star; double tau_star; double rs_star; double ds_star; double ra_star; double da_star; double rd_star; double z_d; double tau_d; double ds_d; double rs_d; double tau_cut; double angular_rescaling; double tau_free_streaming; double tau_idr_free_streaming; double tau_idr; double tau_idm_dr; double tau_ini; double fHe; double n_e; double m_idm; double a_idm_dr; double b_idr; double n_index_idm_dr; double cross_idm_b; int n_index_idm_b; double n_coeff_idm_b; double cross_idm_g; double u_idm_g; int n_index_idm_g; short inter_normal; short inter_closeby; short thermodynamics_verbose; short hyrec_verbose; char error_message[2048]; } *

variable_types: xe double

variable_types: nH double

variable_types: z double

variable_types: Hz double

variable_types: Tmat double

variable_types: Trad double

variable_types: alpha double

variable_types: me double

variable_types: struct injection { double DM_annihilation_efficiency; double DM_annihilation_cross_section; double DM_annihilation_mass; double DM_annihilation_fraction; double DM_annihilation_variation; double DM_annihilation_z; double DM_annihilation_zmax; double DM_annihilation_zmin; double DM_annihilation_f_halo; double DM_annihilation_z_halo; double DM_decay_fraction; double DM_decay_Gamma; double PBH_evaporation_fraction; double PBH_evaporation_mass; double PBH_accretion_fraction; double PBH_accretion_mass; enum PBH_accretion_approx { spherical_accretion=0, disk_accretion=1 } PBH_accretion_recipe; double PBH_accretion_relative_velocities; double PBH_accretion_ADAF_delta; double PBH_accretion_eigenvalue; int f_eff_type; char f_eff_file[256]; int chi_type; char chi_z_file[256]; char chi_x_file[256]; int Nz_size; double z_initial; double z_start_chi_approx; double H0; double T_g0; double Omega0_b; double Omega0_cdm; double rho0_cdm; double H; double a; double t; double rho_g; double rho_b; double rho_cdm; double fHe; double N_e0; double heat_capacity; double T_b; double x_e; double nH; double *z_table; int z_size; double tol_z_table; int filled_until_index_z; double filled_until_z; int last_index_z_feff; int last_index_z_chi; int last_index_z_inj; int last_index_z; int index_z_store; int last_index_x_chi; double PBH_z_evaporation; double PBH_QCD_activation; double *PBH_table_z; double *PBH_table_mass; double *PBH_table_mass_dd; double *PBH_table_F; double *PBH_table_F_dd; int Nz_PBH; double **injection_table; int index_inj_cool; int index_inj_diss; int index_inj_DM_ann; int index_inj_DM_dec; int index_inj_PBH_eva; int index_inj_PBH_acc; int index_inj_tot; int inj_size; double f_eff; int feff_z_size; double *feff_table; double *chiz_table; int chiz_size; double *chix_table; int chix_size; double **deposition_table; double *chi; int index_dep_heat; int index_dep_ionH; int index_dep_ionHe; int index_dep_lya; int index_dep_lowE; int dep_size; double *pvecdeposition; int has_exotic_injection; int has_DM_ann; int has_DM_dec; int has_PBH_eva; int has_PBH_acc; int to_store; char error_message[2048]; } *

variable_types: iz long

variable_types: model int

variable_types:
FMsg
char [2048]

user_defined_types: struct thermodynamics { double YHe; double bbn_alpha_sensitivity; enum recombination_algorithm recombination; enum recfast_photoion_modes recfast_photoion_mode; enum reionization_parametrization reio_parametrization; enum reionization_z_or_tau reio_z_or_tau; double tau_reio; double z_reio; short compute_cb2_derivatives; short compute_damping_scale; short has_idm_b; short has_idm_g; short has_idm_dr; double reionization_width; double reionization_exponent; double helium_fullreio_redshift; double helium_fullreio_width; int binned_reio_num; double *binned_reio_z; double *binned_reio_xe; double binned_reio_step_sharpness; int many_tanh_num; double *many_tanh_z; double *many_tanh_xe; double many_tanh_width; int reio_inter_num; double *reio_inter_z; double *reio_inter_xe; short has_exotic_injection; struct injection in; double annihilation; short has_on_the_spot; double decay; double annihilation_variation; double annihilation_z; double annihilation_zmax; double annihilation_zmin; double annihilation_f_halo; double annihilation_z_halo; short has_varconst; int index_th_xe; int index_th_dkappa; int index_th_tau_d; int index_th_ddkappa; int index_th_dddkappa; int index_th_exp_m_kappa; int index_th_g; int index_th_dg; int index_th_ddg; int index_th_T_idm; int index_th_c2_idm; int index_th_T_idr; int index_th_dmu_idm_dr; int index_th_ddmu_idm_dr; int index_th_dddmu_idm_dr; int index_th_dmu_idr; int index_th_tau_idm_dr; int index_th_tau_idr; int index_th_g_idm_dr; int index_th_dmu_idm_g; int index_th_ddmu_idm_g; int index_th_dddmu_idm_g; int index_th_exp_mu_idm_g; int index_th_R_idm_b; int index_th_dR_idm_b; int index_th_ddR_idm_b; int index_th_Tb; int index_th_dTb; int index_th_wb; int index_th_cb2; int index_th_dcb2; int index_th_ddcb2; int index_th_rate; int index_th_r_d; int th_size; int tt_size; double *z_table; double *tau_table; double *thermodynamics_table; double *d2thermodynamics_dz2_table; double z_rec; double tau_rec; double rs_rec; double ds_rec; double ra_rec; double da_rec; double rd_rec; double z_star; double tau_star; double rs_star; double ds_star; double ra_star; double da_star; double rd_star; double z_d; double tau_d; double ds_d; double rs_d; double tau_cut; double angular_rescaling; double tau_free_streaming; double tau_idr_free_streaming; double tau_idr; double tau_idm_dr; double tau_ini; double fHe; double n_e; double m_idm; double a_idm_dr; double b_idr; double n_index_idm_dr; double cross_idm_b; int n_index_idm_b; double n_coeff_idm_b; double cross_idm_g; double u_idm_g; int n_index_idm_g; short inter_normal; short inter_closeby; short thermodynamics_verbose; short hyrec_verbose; char error_message[2048]; }

user_defined_types: struct injection { double DM_annihilation_efficiency; double DM_annihilation_cross_section; double DM_annihilation_mass; double DM_annihilation_fraction; double DM_annihilation_variation; double DM_annihilation_z; double DM_annihilation_zmax; double DM_annihilation_zmin; double DM_annihilation_f_halo; double DM_annihilation_z_halo; double DM_decay_fraction; double DM_decay_Gamma; double PBH_evaporation_fraction; double PBH_evaporation_mass; double PBH_accretion_fraction; double PBH_accretion_mass; enum PBH_accretion_approx PBH_accretion_recipe; double PBH_accretion_relative_velocities; double PBH_accretion_ADAF_delta; double PBH_accretion_eigenvalue; int f_eff_type; char f_eff_file[256]; int chi_type; char chi_z_file[256]; char chi_x_file[256]; int Nz_size; double z_initial; double z_start_chi_approx; double H0; double T_g0; double Omega0_b; double Omega0_cdm; double rho0_cdm; double H; double a; double t; double rho_g; double rho_b; double rho_cdm; double fHe; double N_e0; double heat_capacity; double T_b; double x_e; double nH; double *z_table; int z_size; double tol_z_table; int filled_until_index_z; double filled_until_z; int last_index_z_feff; int last_index_z_chi; int last_index_z_inj; int last_index_z; int index_z_store; int last_index_x_chi; double PBH_z_evaporation; double PBH_QCD_activation; double *PBH_table_z; double *PBH_table_mass; double *PBH_table_mass_dd; double *PBH_table_F; double *PBH_table_F_dd; int Nz_PBH; double **injection_table; int index_inj_cool; int index_inj_diss; int index_inj_DM_ann; int index_inj_DM_dec; int index_inj_PBH_eva; int index_inj_PBH_acc; int index_inj_tot; int inj_size; double f_eff; int feff_z_size; double *feff_table; double *chiz_table; int chiz_size; double *chix_table; int chix_size; double **deposition_table; double *chi; int index_dep_heat; int index_dep_ionH; int index_dep_ionHe; int index_dep_lya; int index_dep_lowE; int dep_size; double *pvecdeposition; int has_exotic_injection; int has_DM_ann; int has_DM_dec; int has_PBH_eva; int has_PBH_acc; int to_store; char error_message[2048]; }

user_defined_types: struct HYREC_ATOMIC { double logTR_tab[100]; double T_RATIO_tab[40]; double **logAlpha_tab[4]; double logR2p2s_tab[100]; double DlogTR; double Eb_tab[311]; double A1s_tab[311]; double A2s_tab[311]; double A3s3d_tab[311]; double A4s4d_tab[311]; }

user_defined_types: struct RADIATION { double z0; long iz_rad_0; double **Dfminus_hist; double **Dfnu_hist; double **Dfminus_Ly_hist; }

user_defined_types: struct FIT_FUNC { double *swift_func[5]; }

user_defined_types: struct INJ_PARAMS { double odmh2; double pann; double ann_z; double ann_z_halo; double decay; double Mpbh; int on_the_spot; double ion; }


original_code:
int hyrec_dx_He_dz(struct thermodynamics* pth, struct thermohyrec* phy, double x_H, double x_He, double xe, double nH, double z, double Hz, double Tmat, double Trad, double alpha, double me, double *dx_He_dz) {
  struct injection* pin = &(pth->in);
  double xHeII = x_He*phy->data->cosmo->fHe;
  { if (4 == 3) { { ErrorMsg Optional_arguments; class_protect_sprintf(Optional_arguments,"FULL mode is currently not allowed for HyRec-2"); { ErrorMsg FMsg; class_protect_sprintf(FMsg,"condition (%s) is true; %s","MODEL == FULL",Optional_arguments); class_protect_sprintf(phy->error_message,"%s(L:%d) :%s",__func__,177,FMsg); }; }; return 1; } };
  if (pth->has_exotic_injection == 1) {
    phy->data->cosmo->inj_params->ion = pin->pvecdeposition[pin->index_dep_ionHe]/nH/(13.5984336478*1.602176487e-19);
    phy->data->cosmo->inj_params->exclya = pin->pvecdeposition[pin->index_dep_lya]/nH/(10.1988356821*1.602176487e-19);
  }
  else{
    phy->data->cosmo->inj_params->ion = 0.;
    phy->data->cosmo->inj_params->exclya = 0.;
  }
  if (pth->has_varconst == 1) {
    phy->data->cosmo->fsR = alpha;
    phy->data->cosmo->meR = me;
  }
  if (xHeII<phy->xHeII_limit) {
    *dx_He_dz=0;
  }
  else {
    *dx_He_dz = -1./(1.+z)* rec_helium_dxHeIIdlna(phy->data, z, 1.-x_H, xHeII, Hz) / phy->data->cosmo->fHe;
    if(phy->data->error != 0){
      { ErrorMsg FMsg; class_protect_sprintf(FMsg,"error in %s;\n=>%s","rec_helium_dxHeIIdlna",phy->data->error_message); class_protect_sprintf(phy->error_message,"%s(L:%d) :%s",__func__,204,FMsg); };;
      return 1;
    }
  }
  return 0;
}

canonical_original_code:
int hyrec_dx_He_dz(struct thermodynamics *pth, struct thermohyrec *phy, double x_H, double x_He, double xe, double nH, double z, double Hz, double Tmat, double Trad, double alpha, double me, double *dx_He_dz) {
  struct injection *pin = &(pth->in);
  double xHeII = x_He*phy->data->cosmo->fHe;
  { if (4 == 3) { { char Optional_arguments[2048]; class_protect_sprintf(Optional_arguments,"FULL mode is currently not allowed for HyRec-2"); { char FMsg[2048]; class_protect_sprintf(FMsg,"condition (%s) is true; %s","MODEL == FULL",Optional_arguments); class_protect_sprintf(phy->error_message,"%s(L:%d) :%s",__func__,177,FMsg); }; }; return 1; } };
  if (pth->has_exotic_injection == 1) {
    phy->data->cosmo->inj_params->ion = pin->pvecdeposition[pin->index_dep_ionHe]/nH/(13.5984336478*1.602176487e-19);
    phy->data->cosmo->inj_params->exclya = pin->pvecdeposition[pin->index_dep_lya]/nH/(10.1988356821*1.602176487e-19);
  }
  else{
    phy->data->cosmo->inj_params->ion = 0.;
    phy->data->cosmo->inj_params->exclya = 0.;
  }
  if (pth->has_varconst == 1) {
    phy->data->cosmo->fsR = alpha;
    phy->data->cosmo->meR = me;
  }
  if (xHeII<phy->xHeII_limit) {
    *dx_He_dz=0;
  }
  else {
    *dx_He_dz = -1./(1.+z)* rec_helium_dxHeIIdlna(phy->data, z, 1.-x_H, xHeII, Hz) / phy->data->cosmo->fHe;
    if(phy->data->error != 0){
      { char FMsg[2048]; class_protect_sprintf(FMsg,"error in %s;\n=>%s","rec_helium_dxHeIIdlna",phy->data->error_message); class_protect_sprintf(phy->error_message,"%s(L:%d) :%s",__func__,204,FMsg); };;
      return 1;
    }
  }
  return 0;
}

variable_types: xHeII double


decompiled_code:
__int64 __fastcall gt_init(__int64 a1)
{
void *v1; // rax
__int64 result; // rax
char v3[2072]; // [rsp+0h] [rbp-818h] BYREF

v1 = malloc(0x1000uLL);
*(_QWORD *)a1 = v1;
if ( v1 )
{
*(_QWORD *)(a1 + 8) = 4096LL;
*(_QWORD *)(a1 + 16) = 0LL;
*(_DWORD *)(a1 + 24) = 0;
result = 0LL;
}
else
{
class_protect_sprintf(v3, "could not allocate %s with size %d", "self->buffer", 4096LL);
class_protect_sprintf(a1 + 28, "%s(L:%d) :%s", "gt_init", 17LL, v3);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
void *v1; // rax
__int64 result; // rax
char v3[2072]; // [rsp+0h] [rbp-818h] BYREF

v1 = malloc(0x1000uLL);
*(_QWORD *)a1 = v1;
if ( v1 )
{
*(_QWORD *)(a1 + 8) = 4096LL;
*(_QWORD *)(a1 + 16) = 0LL;
*(_DWORD *)(a1 + 24) = 0;
result = 0LL;
}
else
{
class_protect_sprintf(v3, "could not allocate %s with size %d", "self->buffer", 4096LL);
class_protect_sprintf(a1 + 28, "%s(L:%d) :%s", "gt_init", 17LL, v3);
result = 1LL;
}
return result;
}

original_code:
int gt_init(
  growTable* self
  ) {
  { self->buffer=malloc(4096); if (self->buffer == ((void *)0)) { int size_int; size_int = 4096; { ErrorMsg FMsg; class_protect_sprintf(FMsg,"could not allocate %s with size %d","self->buffer",size_int); class_protect_sprintf(self->error_message,"%s(L:%d) :%s",__func__,17,FMsg); };; return 1; } };
  self->sz=4096;
  self->csz=0;
  self->freeze=0;
  return 0;
}

canonical_original_code:
int gt_init(struct growTable *self) {
  { self->buffer=malloc(4096); if (self->buffer == ((void *)0)) { int size_int; size_int = 4096; { char FMsg[2048]; class_protect_sprintf(FMsg,"could not allocate %s with size %d","self->buffer",size_int); class_protect_sprintf(self->error_message,"%s(L:%d) :%s",__func__,17,FMsg); };; return 1; } };
  self->sz=4096;
  self->csz=0;
  self->freeze=0;
  return 0;
}

variable_types: struct growTable { void *buffer; long sz; long csz; int freeze; char error_message[2048]; } *


decompiled_code:
__int64 __fastcall gt_add(__int64 a1, __int64 a2, const void *a3, size_t a4)
{
unsigned int v4; // er13
__int64 v5; // rbp
size_t v8; // r13
signed __int64 v9; // rsi
void *v10; // rax
char v12[2048]; // [rsp+0h] [rbp-1028h] BYREF
char v13[2088]; // [rsp+800h] [rbp-828h] BYREF

v4 = *(_DWORD *)(a1 + 24);
if ( v4 == 1 )
{
class_protect_sprintf(v12, "cannot add any more data in the growTable (freeze is on)");
class_protect_sprintf(v13, "condition (%s) is true; %s", "self->freeze == _TRUE_", v12);
class_protect_sprintf(a1 + 28, "%s(L:%d) :%s", "gt_add", 41LL, v13);
}
else
{
v5 = a2;
if ( a2 == -1 )
v5 = *(_QWORD *)(a1 + 16);
if ( v5 < 0 )
{
class_protect_sprintf(v12, "Don't know what to do with idx=%ld", v5);
class_protect_sprintf(v13, "condition (%s) is true; %s", "ridx<0", v12);
class_protect_sprintf(a1 + 28, "%s(L:%d) :%s", "gt_add", 51LL, v13);
v4 = 1;
}
else
{
v8 = v5 + a4;
v9 = *(_QWORD *)(a1 + 8);
if ( (__int64)(v5 + a4) > v9 )
{
v10 = realloc(*(void **)a1, 2 * v9);
if ( !v10 )
{
class_protect_sprintf(v12, "Cannot grow growTable");
class_protect_sprintf(v13, "condition (%s) is true; %s", "nbuffer==NULL", v12);
class_protect_sprintf(a1 + 28, "%s(L:%d) :%s", "gt_add", 58LL, v13);
return 1;
}
*(_QWORD *)a1 = v10;
*(_QWORD *)(a1 + 8) *= 2LL;
}
if ( memcpy((void *)(*(_QWORD *)a1 + v5), a3, a4) == (void *)(*(_QWORD *)a1 + v5) )
{
*(_QWORD *)(a1 + 16) = v8;
v4 = 0;
}
else
{
class_protect_sprintf(v12, "Cannot add data to growTable");
class_protect_sprintf(v13, "condition (%s) is true; %s", "res!=self->buffer+ridx", v12);
class_protect_sprintf(a1 + 28, "%s(L:%d) :%s", "gt_add", 66LL, v13);
v4 = 1;
}
}
}
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, const void *a3, size_t a4)
{
unsigned int v4; // er13
__int64 v5; // rbp
size_t v8; // r13
signed __int64 v9; // rsi
void *v10; // rax
char v12[2048]; // [rsp+0h] [rbp-1028h] BYREF
char v13[2088]; // [rsp+800h] [rbp-828h] BYREF

v4 = *(_DWORD *)(a1 + 24);
if ( v4 == 1 )
{
class_protect_sprintf(v12, "cannot add any more data in the growTable (freeze is on)");
class_protect_sprintf(v13, "condition (%s) is true; %s", "self->freeze == _TRUE_", v12);
class_protect_sprintf(a1 + 28, "%s(L:%d) :%s", "gt_add", 41LL, v13);
}
else
{
v5 = a2;
if ( a2 == -1 )
v5 = *(_QWORD *)(a1 + 16);
if ( v5 < 0 )
{
class_protect_sprintf(v12, "Don't know what to do with idx=%ld", v5);
class_protect_sprintf(v13, "condition (%s) is true; %s", "ridx<0", v12);
class_protect_sprintf(a1 + 28, "%s(L:%d) :%s", "gt_add", 51LL, v13);
v4 = 1;
}
else
{
v8 = v5 + a4;
v9 = *(_QWORD *)(a1 + 8);
if ( (__int64)(v5 + a4) > v9 )
{
v10 = realloc(*(void **)a1, 2 * v9);
if ( !v10 )
{
class_protect_sprintf(v12, "Cannot grow growTable");
class_protect_sprintf(v13, "condition (%s) is true; %s", "nbuffer==NULL", v12);
class_protect_sprintf(a1 + 28, "%s(L:%d) :%s", "gt_add", 58LL, v13);
return 1;
}
*(_QWORD *)a1 = v10;
*(_QWORD *)(a1 + 8) *= 2LL;
}
if ( memcpy((void *)(*(_QWORD *)a1 + v5), a3, a4) == (void *)(*(_QWORD *)a1 + v5) )
{
*(_QWORD *)(a1 + 16) = v8;
v4 = 0;
}
else
{
class_protect_sprintf(v12, "Cannot add data to growTable");
class_protect_sprintf(v13, "condition (%s) is true; %s", "res!=self->buffer+ridx", v12);
class_protect_sprintf(a1 + 28, "%s(L:%d) :%s", "gt_add", 66LL, v13);
v4 = 1;
}
}
}
return v4;
}

original_code:
int gt_add(
  growTable* self,
  long idx,
  void* data,
  long sz
  ) {
  long ridx;
  void *res;
  void *nbuffer;
  { if (self->freeze == 1) { { ErrorMsg Optional_arguments; class_protect_sprintf(Optional_arguments,"cannot add any more data in the growTable (freeze is on)"); { ErrorMsg FMsg; class_protect_sprintf(FMsg,"condition (%s) is true; %s","self->freeze == _TRUE_",Optional_arguments); class_protect_sprintf(self->error_message,"%s(L:%d) :%s",__func__,41,FMsg); }; }; return 1; } };
  if (idx==-1) {
    ridx=self->csz;
  }
  else {
    ridx=idx;
  }
  { if (ridx<0) { { ErrorMsg Optional_arguments; class_protect_sprintf(Optional_arguments,"Don't know what to do with idx=%ld",ridx); { ErrorMsg FMsg; class_protect_sprintf(FMsg,"condition (%s) is true; %s","ridx<0",Optional_arguments); class_protect_sprintf(self->error_message,"%s(L:%d) :%s",__func__,51,FMsg); }; }; return 1; } };
  if (ridx+sz>self->sz) {
    nbuffer=realloc(self->buffer,self->sz*2);
    { if (nbuffer==((void *)0)) { { ErrorMsg Optional_arguments; class_protect_sprintf(Optional_arguments,"Cannot grow growTable"); { ErrorMsg FMsg; class_protect_sprintf(FMsg,"condition (%s) is true; %s","nbuffer==NULL",Optional_arguments); class_protect_sprintf(self->error_message,"%s(L:%d) :%s",__func__,58,FMsg); }; }; return 1; } };
    self->buffer=nbuffer;
    self->sz=self->sz*2;
  }
  res=memcpy((void*) (self->buffer+ridx),(void*) data,(size_t) sz);
  { if (res!=self->buffer+ridx) { { ErrorMsg Optional_arguments; class_protect_sprintf(Optional_arguments,"Cannot add data to growTable"); { ErrorMsg FMsg; class_protect_sprintf(FMsg,"condition (%s) is true; %s","res!=self->buffer+ridx",Optional_arguments); class_protect_sprintf(self->error_message,"%s(L:%d) :%s",__func__,66,FMsg); }; }; return 1; } };
  self->csz=ridx+sz;
  return 0;
}

canonical_original_code:
int gt_add(struct growTable *self, long idx, void *data, long sz) {
  long ridx;
  void *res;
  void *nbuffer;
  { if (self->freeze == 1) { { char Optional_arguments[2048]; class_protect_sprintf(Optional_arguments,"cannot add any more data in the growTable (freeze is on)"); { char FMsg[2048]; class_protect_sprintf(FMsg,"condition (%s) is true; %s","self->freeze == _TRUE_",Optional_arguments); class_protect_sprintf(self->error_message,"%s(L:%d) :%s",__func__,41,FMsg); }; }; return 1; } };
  if (idx==-1) {
    ridx=self->csz;
  }
  else {
    ridx=idx;
  }
  { if (ridx<0) { { char Optional_arguments[2048]; class_protect_sprintf(Optional_arguments,"Don't know what to do with idx=%ld",ridx); { char FMsg[2048]; class_protect_sprintf(FMsg,"condition (%s) is true; %s","ridx<0",Optional_arguments); class_protect_sprintf(self->error_message,"%s(L:%d) :%s",__func__,51,FMsg); }; }; return 1; } };
  if (ridx+sz>self->sz) {
    nbuffer=realloc(self->buffer,self->sz*2);
    { if (nbuffer==((void *)0)) { { char Optional_arguments[2048]; class_protect_sprintf(Optional_arguments,"Cannot grow growTable"); { char FMsg[2048]; class_protect_sprintf(FMsg,"condition (%s) is true; %s","nbuffer==NULL",Optional_arguments); class_protect_sprintf(self->error_message,"%s(L:%d) :%s",__func__,58,FMsg); }; }; return 1; } };
    self->buffer=nbuffer;
    self->sz=self->sz*2;
  }
  res=memcpy((void *) (self->buffer+ridx),(void *) data,(unsigned long) sz);
  { if (res!=self->buffer+ridx) { { char Optional_arguments[2048]; class_protect_sprintf(Optional_arguments,"Cannot add data to growTable"); { char FMsg[2048]; class_protect_sprintf(FMsg,"condition (%s) is true; %s","res!=self->buffer+ridx",Optional_arguments); class_protect_sprintf(self->error_message,"%s(L:%d) :%s",__func__,66,FMsg); }; }; return 1; } };
  self->csz=ridx+sz;
  return 0;
}

variable_types: idx long

variable_types:
data
void *

variable_types: sz long

variable_types: ridx long

variable_types:
res
void *

variable_types:
nbuffer
void *

user_defined_types: struct growTable { void *buffer; long sz; long csz; int freeze; char error_message[2048]; }


decompiled_code:
__int64 __fastcall gt_retrieve(_QWORD *a1, __int64 a2, size_t a3, void *a4)
{
__int64 v4; // rax
__int64 result; // rax
void *v6; // rdx
char v7[2048]; // [rsp+0h] [rbp-1018h] BYREF
char v8[2072]; // [rsp+800h] [rbp-818h] BYREF

if ( a2 < 0 )
{
class_protect_sprintf(v7, "don't know what to do with idx=%ld", a2);
class_protect_sprintf(v8, "condition (%s) is true; %s", "idx<0", v7);
class_protect_sprintf((char *)a1 + 28, "%s(L:%d) :%s", "gt_retrieve", 87LL, v8);
result = 1LL;
}
else
{
v4 = a1[2];
if ( v4 >= a2 && v4 >= (__int64)(a3 + a2) )
{
v6 = memcpy(a4, (const void *)(*a1 + a2), a3);
result = 0LL;
if ( v6 != (void *)(*a1 + a2) )
{
class_protect_sprintf(v7, "cannot retrieve data from the growTable");
class_protect_sprintf(v8, "condition (%s) is true; %s", "res!=self->buffer+idx", v7);
class_protect_sprintf((char *)a1 + 28, "%s(L:%d) :%s", "gt_retrieve", 96LL, v8);
result = 1LL;
}
}
else
{
class_protect_sprintf(v7, "not enough data in growTable");
class_protect_sprintf(v8, "condition (%s) is true; %s", "(idx>self->csz) || (idx+sz>self->csz)", v7);
class_protect_sprintf((char *)a1 + 28, "%s(L:%d) :%s", "gt_retrieve", 91LL, v8);
result = 1LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(_QWORD *a1, __int64 a2, size_t a3, void *a4)
{
__int64 v4; // rax
__int64 result; // rax
void *v6; // rdx
char v7[2048]; // [rsp+0h] [rbp-1018h] BYREF
char v8[2072]; // [rsp+800h] [rbp-818h] BYREF

if ( a2 < 0 )
{
class_protect_sprintf(v7, "don't know what to do with idx=%ld", a2);
class_protect_sprintf(v8, "condition (%s) is true; %s", "idx<0", v7);
class_protect_sprintf((char *)a1 + 28, "%s(L:%d) :%s", "gt_retrieve", 87LL, v8);
result = 1LL;
}
else
{
v4 = a1[2];
if ( v4 >= a2 && v4 >= (__int64)(a3 + a2) )
{
v6 = memcpy(a4, (const void *)(*a1 + a2), a3);
result = 0LL;
if ( v6 != (void *)(*a1 + a2) )
{
class_protect_sprintf(v7, "cannot retrieve data from the growTable");
class_protect_sprintf(v8, "condition (%s) is true; %s", "res!=self->buffer+idx", v7);
class_protect_sprintf((char *)a1 + 28, "%s(L:%d) :%s", "gt_retrieve", 96LL, v8);
result = 1LL;
}
}
else
{
class_protect_sprintf(v7, "not enough data in growTable");
class_protect_sprintf(v8, "condition (%s) is true; %s", "(idx>self->csz) || (idx+sz>self->csz)", v7);
class_protect_sprintf((char *)a1 + 28, "%s(L:%d) :%s", "gt_retrieve", 91LL, v8);
result = 1LL;
}
}
return result;
}

original_code:
int gt_retrieve(
  growTable *self,
  long idx,
  long sz,
  void* data
  ) {
  void *res;
  { if (idx<0) { { ErrorMsg Optional_arguments; class_protect_sprintf(Optional_arguments,"don't know what to do with idx=%ld",idx); { ErrorMsg FMsg; class_protect_sprintf(FMsg,"condition (%s) is true; %s","idx<0",Optional_arguments); class_protect_sprintf(self->error_message,"%s(L:%d) :%s",__func__,87,FMsg); }; }; return 1; } };
  { if ((idx>self->csz) || (idx+sz>self->csz)) { { ErrorMsg Optional_arguments; class_protect_sprintf(Optional_arguments,"not enough data in growTable"); { ErrorMsg FMsg; class_protect_sprintf(FMsg,"condition (%s) is true; %s","(idx>self->csz) || (idx+sz>self->csz)",Optional_arguments); class_protect_sprintf(self->error_message,"%s(L:%d) :%s",__func__,91,FMsg); }; }; return 1; } };
  res=memcpy(data,self->buffer+idx,sz);
  { if (res!=self->buffer+idx) { { ErrorMsg Optional_arguments; class_protect_sprintf(Optional_arguments,"cannot retrieve data from the growTable"); { ErrorMsg FMsg; class_protect_sprintf(FMsg,"condition (%s) is true; %s","res!=self->buffer+idx",Optional_arguments); class_protect_sprintf(self->error_message,"%s(L:%d) :%s",__func__,96,FMsg); }; }; return 1; } };
  return 0;
}

canonical_original_code:
int gt_retrieve(struct growTable *self, long idx, long sz, void *data) {
  void *res;
  { if (idx<0) { { char Optional_arguments[2048]; class_protect_sprintf(Optional_arguments,"don't know what to do with idx=%ld",idx); { char FMsg[2048]; class_protect_sprintf(FMsg,"condition (%s) is true; %s","idx<0",Optional_arguments); class_protect_sprintf(self->error_message,"%s(L:%d) :%s",__func__,87,FMsg); }; }; return 1; } };
  { if ((idx>self->csz) || (idx+sz>self->csz)) { { char Optional_arguments[2048]; class_protect_sprintf(Optional_arguments,"not enough data in growTable"); { char FMsg[2048]; class_protect_sprintf(FMsg,"condition (%s) is true; %s","(idx>self->csz) || (idx+sz>self->csz)",Optional_arguments); class_protect_sprintf(self->error_message,"%s(L:%d) :%s",__func__,91,FMsg); }; }; return 1; } };
  res=memcpy(data,self->buffer+idx,sz);
  { if (res!=self->buffer+idx) { { char Optional_arguments[2048]; class_protect_sprintf(Optional_arguments,"cannot retrieve data from the growTable"); { char FMsg[2048]; class_protect_sprintf(FMsg,"condition (%s) is true; %s","res!=self->buffer+idx",Optional_arguments); class_protect_sprintf(self->error_message,"%s(L:%d) :%s",__func__,96,FMsg); }; }; return 1; } };
  return 0;
}


decompiled_code:
__int64 __fastcall gt_retrieveAll(_QWORD *a1, void *a2)
{
return gt_retrieve(a1, 0LL, a1[2], a2);
}

canonical_decompiled_code:
__int64 __fastcall func3(_QWORD *a1, void *a2)
{
return func2(a1, 0LL, a1[2], a2);
}

original_code:
int gt_retrieveAll(
  growTable *self,
  void* data
  ) {
  return gt_retrieve(self,0,self->csz,data);
}

canonical_original_code:
int gt_retrieveAll(struct growTable *self, void *data) {
  return gt_retrieve(self,0,self->csz,data);
}


decompiled_code:
__int64 __fastcall gt_getSize(__int64 a1, __int64 *a2)
{
__int64 v2; // rax
__int64 result; // rax
char v4[2048]; // [rsp-800h] [rbp-1018h] BYREF
char v5[2072]; // [rsp+0h] [rbp-818h] BYREF

v2 = *(_QWORD *)(a1 + 16);
if ( v2 < 0 )
{
class_protect_sprintf(v4, "growTable does not make sense");
class_protect_sprintf(v5, "condition (%s) is true; %s", "self->csz<0", v4);
class_protect_sprintf(a1 + 28, "%s(L:%d) :%s", "gt_getSize", 124LL, v5);
result = 1LL;
}
else
{
*a2 = v2;
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 *a2)
{
__int64 v2; // rax
__int64 result; // rax
char v4[2048]; // [rsp-800h] [rbp-1018h] BYREF
char v5[2072]; // [rsp+0h] [rbp-818h] BYREF

v2 = *(_QWORD *)(a1 + 16);
if ( v2 < 0 )
{
class_protect_sprintf(v4, "growTable does not make sense");
class_protect_sprintf(v5, "condition (%s) is true; %s", "self->csz<0", v4);
class_protect_sprintf(a1 + 28, "%s(L:%d) :%s", "gt_getSize", 124LL, v5);
result = 1LL;
}
else
{
*a2 = v2;
result = 0LL;
}
return result;
}

original_code:
int gt_getSize(
  growTable* self,
  long *idx
  ) {
  { if (self->csz<0) { { ErrorMsg Optional_arguments; class_protect_sprintf(Optional_arguments,"growTable does not make sense"); { ErrorMsg FMsg; class_protect_sprintf(FMsg,"condition (%s) is true; %s","self->csz<0",Optional_arguments); class_protect_sprintf(self->error_message,"%s(L:%d) :%s",__func__,124,FMsg); }; }; return 1; } };
  *idx=self->csz;
  return 0;
}

canonical_original_code:
int gt_getSize(struct growTable *self, long *idx) {
  { if (self->csz<0) { { char Optional_arguments[2048]; class_protect_sprintf(Optional_arguments,"growTable does not make sense"); { char FMsg[2048]; class_protect_sprintf(FMsg,"condition (%s) is true; %s","self->csz<0",Optional_arguments); class_protect_sprintf(self->error_message,"%s(L:%d) :%s",__func__,124,FMsg); }; }; return 1; } };
  *idx=self->csz;
  return 0;
}

variable_types:
idx
long *


decompiled_code:
__int64 __fastcall gt_getPtr(__int64 a1, _QWORD *a2)
{
*(_DWORD *)(a1 + 24) = 1;
*a2 = *(_QWORD *)a1;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, _QWORD *a2)
{
*(_DWORD *)(a1 + 24) = 1;
*a2 = *(_QWORD *)a1;
return 0LL;
}

original_code:
int gt_getPtr(
  growTable* self,
  void** ptr
  ) {
  self->freeze=1;
  *ptr=self->buffer;
  return 0;
}

canonical_original_code:
int gt_getPtr(struct growTable *self, void **ptr) {
  self->freeze=1;
  *ptr=self->buffer;
  return 0;
}

variable_types:
ptr
void **


original_code:
int gt_free(growTable* self) {
  free(self->buffer);
  self->csz=-1;
  self->sz=-1;
  self->freeze=0;
  return 0;
}

canonical_original_code:
int gt_free(struct growTable *self) {
  free(self->buffer);
  self->csz=-1;
  self->sz=-1;
  self->freeze=0;
  return 0;
}


variable_types: x double

variable_types:
Ci
double *

variable_types: y double

variable_types: f double

variable_types: g double


variable_types:
Si
double *


original_code:
double rec_saha_xH1s(REC_COSMOPARAMS *cosmo, double z, double xHeII) {
  double s, Tr, nH, ainv;
  double nH0 = cosmo->nH0, T0 = cosmo->T0;
  double fsR = cosmo->fsR, meR = cosmo->meR;
  Tr = T0 * (ainv=1.+z) /fsR/fsR/meR;
  nH = nH0*ainv*ainv*ainv;
  s = fsR*fsR*fsR*meR*meR*meR *2.4127161187130e15*Tr*sqrt(Tr)*exp(-157801.37882/Tr)/nH;
  if (s == 0.) return 1.;
  else if (s > 1e5) return (1.+xHeII)/s - (xHeII*xHeII + 3.*xHeII + 2.)/s/s;
  else return 1.-2./(1.+ xHeII/s + sqrt((1.+ xHeII/s)*(1.+ xHeII/s) +4./s));
}

canonical_original_code:
double rec_saha_xH1s(struct REC_COSMOPARAMS *cosmo, double z, double xHeII) {
  double s; double Tr; double nH; double ainv;
  double nH0 = cosmo->nH0; double T0 = cosmo->T0;
  double fsR = cosmo->fsR; double meR = cosmo->meR;
  Tr = T0 * (ainv=1.+z) /fsR/fsR/meR;
  nH = nH0*ainv*ainv*ainv;
  s = fsR*fsR*fsR*meR*meR*meR *2.4127161187130e15*Tr*sqrt(Tr)*exp(-157801.37882/Tr)/nH;
  if (s == 0.) return 1.;
  else if (s > 1e5) return (1.+xHeII)/s - (xHeII*xHeII + 3.*xHeII + 2.)/s/s;
  else return 1.-2./(1.+ xHeII/s + sqrt((1.+ xHeII/s)*(1.+ xHeII/s) +4./s));
}

variable_types: struct REC_COSMOPARAMS { double h; double T0; double obh2; double w0; double Neff; double Nur; double Nmnu; double mnu[3]; double fHe; double nH0; double YHe; double fsR; double dlna; struct INJ_PARAMS { double odmh2; double pann; double ann_z; double ann_z_halo; double decay; double Mpbh; int on_the_spot; double ion; } *inj_params; } *

variable_types: z double

variable_types: s double

variable_types: Tr double

variable_types: nH double

variable_types: ainv double

variable_types: fsR double

variable_types: meR double

return_type: double


original_code:
double rec_helium_dxHeIIdlna(HYREC_DATA *data, double z, double xH1, double xHeII, double H) {
  double nH0 = data->cosmo->nH0, Tr0 = data->cosmo->T0, fHe = data->cosmo->fHe;
  double fsR = data->cosmo->fsR, meR = data->cosmo->meR;
  int *error = &data->error;
  double Tr, nH, ainv, s, s0;
  double xe, xHeI, y2s, y2p, ydown;
  double etacinv, g2pinc, dnuline, tau2p, pesc, tauc, enh;
  char sub_message[256];
  if (*error == 1) return 0.;
  xe = xHeII + (1.-xH1);
  xHeI = fHe - xHeII;
  if (xHeI < 0.){
    sprintf(sub_message, "xHeI = %E < 0 at z = %f in rec_helium_dxHeIIdlna.\nYou should try and extend the hydrogen post-saha phase by increasing DXHII_MAX in history.h\n", xHeI, z);
    strcat(data->error_message, sub_message);
    *error = 1;
  }
  Tr = Tr0*(ainv=1+z) /fsR/fsR/meR;
  nH = nH0*ainv*ainv*ainv;
  s0 = fsR*fsR*fsR*meR*meR*meR *2.414194e15*Tr*sqrt(Tr)/nH * 4.;
  s = s0 * exp(-285325./Tr);
  y2s = exp(46090./Tr)/s0;
  y2p = exp(39101./Tr)/s0 * 3.;
  etacinv = fsR*fsR*fsR *meR*meR*meR* 9.15776e22 * H/nH/xH1;
  g2pinc = 1.976e6 / (1.-exp(-6989./Tr))
          + 6.03e6 / (exp(19754./Tr)-1.)
          + 1.06e8 / (exp(21539./Tr)-1.)
          + 2.18e6 / (exp(28496./Tr)-1.)
          + 3.37e7 / (exp(29224./Tr)-1.)
          + 1.04e6 / (exp(32414./Tr)-1.)
          + 1.51e7 / (exp(32781./Tr)-1.);
  g2pinc *= fsR*fsR*fsR*fsR*fsR*meR ;
  tau2p = 4.277e-8 * nH/H * xHeI /(fsR*meR*meR);
  dnuline = g2pinc * tau2p / (4.*3.14159265358979323846*3.14159265358979323846);
  tauc = dnuline/etacinv;
  enh = sqrt(1.+3.14159265358979323846*3.14159265358979323846*tauc) + 7.74*tauc/(1.+70.*tauc);
  pesc = enh / tau2p;
  pesc = pesc + (1.-exp(-1.023e-7*tau2p))*(0.964525*exp(2947./Tr)-enh*exp(-6.14e13*fsR*fsR*meR/etacinv))/tau2p;
  ydown = fsR*fsR*fsR*fsR*fsR*fsR*fsR*fsR*meR *50.94*y2s
        + fsR*fsR*fsR*fsR*fsR*meR* 1.7989e9*y2p*pesc;
  return ydown*(xHeI*s - xHeII*xe)/H;
}

canonical_original_code:
double rec_helium_dxHeIIdlna(struct HYREC_DATA *data, double z, double xH1, double xHeII, double H) {
  double nH0 = data->cosmo->nH0; double Tr0 = data->cosmo->T0; double fHe = data->cosmo->fHe;
  double fsR = data->cosmo->fsR; double meR = data->cosmo->meR;
  int *error = &data->error;
  double Tr; double nH; double ainv; double s; double s0;
  double xe; double xHeI; double y2s; double y2p; double ydown;
  double etacinv; double g2pinc; double dnuline; double tau2p; double pesc; double tauc; double enh;
  char sub_message[256];
  if (*error == 1) return 0.;
  xe = xHeII + (1.-xH1);
  xHeI = fHe - xHeII;
  if (xHeI < 0.){
    sprintf(sub_message, "xHeI = %E < 0 at z = %f in rec_helium_dxHeIIdlna.\nYou should try and extend the hydrogen post-saha phase by increasing DXHII_MAX in history.h\n", xHeI, z);
    strcat(data->error_message, sub_message);
    *error = 1;
  }
  Tr = Tr0*(ainv=1+z) /fsR/fsR/meR;
  nH = nH0*ainv*ainv*ainv;
  s0 = fsR*fsR*fsR*meR*meR*meR *2.414194e15*Tr*sqrt(Tr)/nH * 4.;
  s = s0 * exp(-285325./Tr);
  y2s = exp(46090./Tr)/s0;
  y2p = exp(39101./Tr)/s0 * 3.;
  etacinv = fsR*fsR*fsR *meR*meR*meR* 9.15776e22 * H/nH/xH1;
  g2pinc = 1.976e6 / (1.-exp(-6989./Tr))
          + 6.03e6 / (exp(19754./Tr)-1.)
          + 1.06e8 / (exp(21539./Tr)-1.)
          + 2.18e6 / (exp(28496./Tr)-1.)
          + 3.37e7 / (exp(29224./Tr)-1.)
          + 1.04e6 / (exp(32414./Tr)-1.)
          + 1.51e7 / (exp(32781./Tr)-1.);
  g2pinc *= fsR*fsR*fsR*fsR*fsR*meR ;
  tau2p = 4.277e-8 * nH/H * xHeI /(fsR*meR*meR);
  dnuline = g2pinc * tau2p / (4.*3.14159265358979323846*3.14159265358979323846);
  tauc = dnuline/etacinv;
  enh = sqrt(1.+3.14159265358979323846*3.14159265358979323846*tauc) + 7.74*tauc/(1.+70.*tauc);
  pesc = enh / tau2p;
  pesc = pesc + (1.-exp(-1.023e-7*tau2p))*(0.964525*exp(2947./Tr)-enh*exp(-6.14e13*fsR*fsR*meR/etacinv))/tau2p;
  ydown = fsR*fsR*fsR*fsR*fsR*fsR*fsR*fsR*meR *50.94*y2s
        + fsR*fsR*fsR*fsR*fsR*meR* 1.7989e9*y2p*pesc;
  return ydown*(xHeI*s - xHeII*xe)/H;
}

variable_types: struct HYREC_DATA { struct HYREC_ATOMIC { double logTR_tab[100]; double T_RATIO_tab[40]; double **logAlpha_tab[4]; double logR2p2s_tab[100]; double DlogTR; double Eb_tab[311]; double A1s_tab[311]; double A2s_tab[311]; double A3s3d_tab[311]; double A4s4d_tab[311]; } *atomic; struct REC_COSMOPARAMS { double h; double T0; double obh2; double w0; double Neff; double Nur; double Nmnu; double mnu[3]; double fHe; double nH0; double YHe; double fsR; double dlna; struct INJ_PARAMS { double odmh2; double pann; double ann_z; double ann_z_halo; double decay; double Mpbh; int on_the_spot; double ion; } *inj_params; } *cosmo; double zmax; double zmin; long Nz; double *xe_output; double *Tm_output; int error; int quasi_eq; int loop_after_quasi; int Tm_evolve_implicit; char *error_message; char *path_to_hyrec; struct RADIATION { double z0; long iz_rad_0; double **Dfminus_hist; double **Dfnu_hist; double **Dfminus_Ly_hist; } *rad; struct FIT_FUNC { double *swift_func[5]; } *fit; } *

variable_types: xHeII double

variable_types: H double

variable_types: fHe double

variable_types:
error
int *

variable_types: xe double

variable_types: xHeI double

variable_types: ydown double

variable_types: etacinv double

variable_types: dnuline double

variable_types: pesc double

variable_types: tauc double

variable_types: enh double


repo: lessandro/redismq

decompiled_code:
void __fastcall rmq_message_free(void *ptr)
{
free(*(void **)ptr);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func17(void *ptr)
{
free(*(void **)ptr);
free(ptr);
}

original_code:
void rmq_message_free(struct rmq_message *msg)
{
    free(msg->message);
    free(msg);
}

variable_types: struct rmq_message { char *message; struct { struct rmq_message *stqe_next; } entries; } *

return_type: void


decompiled_code:
__int64 __fastcall rmq_blpop(__int64 a1, __int64 a2)
{
if ( *(_DWORD *)a1 )
_assert_fail("ctx->type == RMQ_NONE", "redismq.c", 0xC4u, "rmq_blpop");
*(_DWORD *)a1 = 1;
*(_QWORD *)(a1 + 48) = a2;
return rmq_connect(a1);
}

canonical_decompiled_code:
__int64 __fastcall func19(__int64 a1, __int64 a2)
{
if ( *(_DWORD *)a1 )
_assert_fail("ctx->type == RMQ_NONE", "redismq.c", 0xC4u, "rmq_blpop");
*(_DWORD *)a1 = 1;
*(_QWORD *)(a1 + 48) = a2;
return func6(a1);
}

original_code:
void rmq_blpop(struct rmq_context *ctx, rmq_callback *blpop_cb)
{
    ((ctx->type == 0) ? (void) (0) : __assert_fail ("ctx->type == RMQ_NONE", "redismq.c", 196, __extension__ __PRETTY_FUNCTION__));
    ctx->type = 1;
    ctx->blpop_cb = blpop_cb;
    rmq_connect(ctx);
}

canonical_original_code:
void rmq_blpop(struct rmq_context *ctx, void (*blpop_cb)(char *message))
{
    ((ctx->type == 0) ? (void) (0) : __assert_fail ("ctx->type == RMQ_NONE", "redismq.c", 196, __extension__ __PRETTY_FUNCTION__));
    ctx->type = 1;
    ctx->blpop_cb = blpop_cb;
    rmq_connect(ctx);
}

variable_types: struct rmq_context { int type; char *redis_host; int redis_port; int redis_db; char *key; void *redis_ctx; int connected; void (*blpop_cb)(char *message); struct rmq_message_head { struct rmq_message { char *message; struct { struct rmq_message *stqe_next; } entries; } *stqh_first; struct rmq_message **stqh_last; } head; } *

user_defined_types: struct rmq_context { int type; char *redis_host; int redis_port; int redis_db; char *key; void *redis_ctx; int connected; void (*blpop_cb)(char *message); struct rmq_message_head head; }

user_defined_types: struct rmq_message_head { struct rmq_message *stqh_first; struct rmq_message **stqh_last; }


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

if ( !*(_DWORD *)a1 )
{
*(_DWORD *)a1 = 2;
*(_QWORD *)(a1 + 56) = 0LL;
*(_QWORD *)(a1 + 64) = a1 + 56;
rmq_connect(a1);
}
if ( *(_DWORD *)a1 != 2 )
_assert_fail("ctx->type == RMQ_RPUSH", "redismq.c", 0xD5u, "rmq_rpush");
v2 = (const char **)rmq_message_new(a2);
v2[1] = 0LL;
**(_QWORD **)(a1 + 64) = v2;
result = (__int64)(v2 + 1);
*(_QWORD *)(a1 + 64) = v2 + 1;
if ( *(_DWORD *)(a1 + 40) )
result = rmq_rpush_message(a1, v2);
return result;
}

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

if ( !*(_DWORD *)a1 )
{
*(_DWORD *)a1 = 2;
*(_QWORD *)(a1 + 56) = 0LL;
*(_QWORD *)(a1 + 64) = a1 + 56;
func6(a1);
}
if ( *(_DWORD *)a1 != 2 )
_assert_fail("ctx->type == RMQ_RPUSH", "redismq.c", 0xD5u, "rmq_rpush");
v2 = (const char **)rmq_message_new(a2);
v2[1] = 0LL;
**(_QWORD **)(a1 + 64) = v2;
result = (__int64)(v2 + 1);
*(_QWORD *)(a1 + 64) = v2 + 1;
if ( *(_DWORD *)(a1 + 40) )
result = func3(a1, v2);
return result;
}

original_code:
void rmq_rpush(struct rmq_context *ctx, const char *message)
{
    if (ctx->type == 0) {
        ctx->type = 2;
        do { (&ctx->head)->stqh_first = ((void *)0); (&ctx->head)->stqh_last = &(&ctx->head)->stqh_first; } while ( 0);
        rmq_connect(ctx);
    }
    ((ctx->type == 2) ? (void) (0) : __assert_fail ("ctx->type == RMQ_RPUSH", "redismq.c", 213, __extension__ __PRETTY_FUNCTION__));
    struct rmq_message *msg = rmq_message_new(message);
    do { (msg)->entries.stqe_next = ((void *)0); *(&ctx->head)->stqh_last = (msg); (&ctx->head)->stqh_last = &(msg)->entries.stqe_next; } while ( 0);
    if (ctx->connected)
        rmq_rpush_message(ctx, msg);
}

canonical_original_code:
void rmq_rpush(struct rmq_context *ctx, char *message)
{
    if (ctx->type == 0) {
        ctx->type = 2;
        do { (&ctx->head)->stqh_first = ((void *)0); (&ctx->head)->stqh_last = &(&ctx->head)->stqh_first; } while ( 0);
        rmq_connect(ctx);
    }
    ((ctx->type == 2) ? (void) (0) : __assert_fail ("ctx->type == RMQ_RPUSH", "redismq.c", 213, __extension__ __PRETTY_FUNCTION__));
    struct rmq_message *msg = rmq_message_new(message);
    do { (msg)->entries.stqe_next = ((void *)0); *(&ctx->head)->stqh_last = (msg); (&ctx->head)->stqh_last = &(msg)->entries.stqe_next; } while ( 0);
    if (ctx->connected)
        rmq_rpush_message(ctx, msg);
}

variable_types:
message
char *

user_defined_types: struct rmq_message { char *message; struct { struct rmq_message *stqe_next; } entries; }


decompiled_code:
void rmq_rpushf(__int64 a1, const char *a2, ...)
{
void *ptr; // [rsp+0h] [rbp-D8h] BYREF
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, a2);
vasprintf((char **)&ptr, a2, arg);
rmq_rpush(a1, (char *)ptr);
free(ptr);
}

canonical_decompiled_code:
void func21(__int64 a1, const char *a2, ...)
{
void *ptr; // [rsp+0h] [rbp-D8h] BYREF
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, a2);
vasprintf((char **)&ptr, a2, arg);
func20(a1, (char *)ptr);
free(ptr);
}

original_code:
void rmq_rpushf(struct rmq_context *ctx, const char *format, ...)
{
    va_list args;
    __builtin_va_start(args,format);
    char *buf;
    vasprintf(&buf, format, args);
    rmq_rpush(ctx, buf);
    free(buf);
    __builtin_va_end(args);
}

canonical_original_code:
void rmq_rpushf(struct rmq_context *ctx, char *format, ...)
{
    __builtin_va_list args;
    __builtin_va_start(args,format);
    char *buf;
    vasprintf(&buf, format, args);
    rmq_rpush(ctx, buf);
    free(buf);
    __builtin_va_end(args);
}

variable_types:
format
char *

variable_types:
buf
char *


decompiled_code:
char *__fastcall rmq_init(__int64 a1, const char *a2, int a3, int a4, const char *a5)
{
char *result; // rax

*(_DWORD *)a1 = 0;
*(_QWORD *)(a1 + 8) = strdup(a2);
*(_DWORD *)(a1 + 16) = a3;
*(_DWORD *)(a1 + 20) = a4;
result = strdup(a5);
*(_QWORD *)(a1 + 24) = result;
*(_QWORD *)(a1 + 32) = 0LL;
*(_DWORD *)(a1 + 40) = 0;
return result;
}

canonical_decompiled_code:
char *__fastcall func22(__int64 a1, const char *a2, int a3, int a4, const char *a5)
{
char *result; // rax

*(_DWORD *)a1 = 0;
*(_QWORD *)(a1 + 8) = strdup(a2);
*(_DWORD *)(a1 + 16) = a3;
*(_DWORD *)(a1 + 20) = a4;
result = strdup(a5);
*(_QWORD *)(a1 + 24) = result;
*(_QWORD *)(a1 + 32) = 0LL;
*(_DWORD *)(a1 + 40) = 0;
return result;
}

original_code:
void rmq_init(struct rmq_context *ctx, const char *redis_host, int redis_port,
    int redis_db, const char *key)
{
    ctx->type = 0;
    ctx->redis_host = strdup(redis_host);
    ctx->redis_port = redis_port;
    ctx->redis_db = redis_db;
    ctx->key = strdup(key);
    ctx->redis_ctx = ((void *)0);
    ctx->connected = 0;
}

canonical_original_code:
void rmq_init(struct rmq_context *ctx, char *redis_host, int redis_port, int redis_db, char *key)
{
    ctx->type = 0;
    ctx->redis_host = strdup(redis_host);
    ctx->redis_port = redis_port;
    ctx->redis_db = redis_db;
    ctx->key = strdup(key);
    ctx->redis_ctx = ((void *)0);
    ctx->connected = 0;
}

variable_types:
key
char *


decompiled_code:
__int64 __fastcall read_search(__int64 a1, __int64 a2)
{
__int64 v2; // rax
__int64 result; // rax
__int64 v4; // [rsp+8h] [rbp-10h] BYREF

v4 = a2;
while ( 1 )
{
result = get_next_line(0LL, &v4);
if ( (int)result <= 0 )
break;
if ( find_value(a1, v4) )
{
v2 = find_value(a1, v4);
ft_putstr(v2);
}
else
{
ft_putstr(v4);
ft_putstr(": Not found.");
}
ft_putstr("\n");
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
__int64 v2; // rax
__int64 result; // rax
__int64 v4; // [rsp+8h] [rbp-10h] BYREF

v4 = a2;
while ( 1 )
{
result = get_next_line(0LL, &v4);
if ( (int)result <= 0 )
break;
if ( find_value(a1, v4) )
{
v2 = find_value(a1, v4);
ft_putstr(v2);
}
else
{
ft_putstr(v4);
ft_putstr(": Not found.");
}
ft_putstr("\n");
}
return result;
}

original_code:
void read_search(t_search *head, char *line)
{
 while (get_next_line(0, &line) > 0)
 {
  if (find_value(head, line) == ((void *)0))
  {
   ft_putstr(line);
   ft_putstr(": Not found.");
  }
  else
   ft_putstr(find_value(head, line));
  ft_putstr("\n");
 }
}

canonical_original_code:
void read_search(struct s_search *head, char *line)
{
 while (get_next_line(0, &line) > 0)
 {
  if (find_value(head, line) == ((void *)0))
  {
   ft_putstr(line);
   ft_putstr(": Not found.");
  }
  else
   ft_putstr(find_value(head, line));
  ft_putstr("\n");
 }
}

variable_types: struct s_search { char *keyword; char *value; int nb_next; short is_leef; struct s_search *before; struct s_search **next; } *

variable_types:
line
char *


decompiled_code:
__int64 __fastcall define_thehead(__int64 a1, __int64 a2, void *a3)
{
char i; // bl
__int64 result; // rax
__int64 v6; // rax
__int64 v7[4]; // [rsp+8h] [rbp-20h] BYREF

v7[0] = a2;
for ( i = 0; ; ++i )
{
result = get_next_line(0LL, v7);
if ( (int)result <= 0 )
break;
if ( (unsigned int)ft_strcmp(v7[0], &unk_24F) )
{
if ( (i & 1) != 0 )
{
v6 = new_t_search(a3, v7[0]);
insert_new(a1, v6);
free(a3);
}
else
{
a3 = (void *)ft_strdup(v7[0]);
}
}
else
{
read_search(a1, v7[0]);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, void *a3)
{
char i; // bl
__int64 result; // rax
__int64 v6; // rax
__int64 v7[4]; // [rsp+8h] [rbp-20h] BYREF

v7[0] = a2;
for ( i = 0; ; ++i )
{
result = get_next_line(0LL, v7);
if ( (int)result <= 0 )
break;
if ( (unsigned int)ft_strcmp(v7[0], &unk_24F) )
{
if ( (i & 1) != 0 )
{
v6 = new_t_search(a3, v7[0]);
insert_new(a1, v6);
free(a3);
}
else
{
a3 = (void *)ft_strdup(v7[0]);
}
}
else
{
func0(a1, v7[0]);
}
}
return result;
}

original_code:
void define_thehead(t_search *head, char *line, char *key)
{
 int i;
 i = 0;
 while (get_next_line(0, &line) > 0)
 {
  if (ft_strcmp(line, "") == 0)
   read_search(head, line);
  else if ((i % 2) != 0)
  {
   insert_new(head , new_t_search(key, line));
   free(key);
  }
  else
   key = ft_strdup(line);
  i++;
 }
}

canonical_original_code:
void define_thehead(struct s_search *head, char *line, char *key)
{
 int i;
 i = 0;
 while (get_next_line(0, &line) > 0)
 {
  if (ft_strcmp(line, "") == 0)
   read_search(head, line);
  else if ((i % 2) != 0)
  {
   insert_new(head , new_t_search(key, line));
   free(key);
  }
  else
   key = ft_strdup(line);
  i++;
 }
}

variable_types: i int

user_defined_types: struct s_search { char *keyword; char *value; int nb_next; short is_leef; struct s_search *before; struct s_search **next; }


decompiled_code:
__int64 read_standard()
{
void *v0; // rbx
__int64 v1; // rbp
__int64 v2; // rdi
__int64 v4[4]; // [rsp+8h] [rbp-20h] BYREF

the_head = new_t_search(0LL, 0LL);
*(_WORD *)(the_head + 20) = 1;
get_next_line(0LL, v4);
v0 = (void *)ft_strdup(v4[0]);
get_next_line(0LL, v4);
v1 = new_t_search(v0, v4[0]);
insert_new(the_head, v1);
v2 = the_head;
*(_WORD *)(the_head + 20) = 0;
*(_WORD *)(v1 + 20) = 1;
return define_thehead(v2, v4[0], v0);
}

canonical_decompiled_code:
__int64 func2()
{
void *v0; // rbx
__int64 v1; // rbp
__int64 v2; // rdi
__int64 v4[4]; // [rsp+8h] [rbp-20h] BYREF

the_head = new_t_search(0LL, 0LL);
*(_WORD *)(the_head + 20) = 1;
get_next_line(0LL, v4);
v0 = (void *)ft_strdup(v4[0]);
get_next_line(0LL, v4);
v1 = new_t_search(v0, v4[0]);
insert_new(the_head, v1);
v2 = the_head;
*(_WORD *)(the_head + 20) = 0;
*(_WORD *)(v1 + 20) = 1;
return func1(v2, v4[0], v0);
}

original_code:
void read_standard()
{
 char *line;
 char *key;
 t_search *head;
 head = new_t_search(((void *)0), ((void *)0));
 the_head = head;
 the_head->is_leef = 1;
 get_next_line(0, &line);
 key = ft_strdup(line);
 get_next_line(0, &line);
 head = new_t_search(key, line);
 insert_new(the_head, head);
 the_head->is_leef = 0;
 head->is_leef = 1;
 define_thehead(the_head, line, key);
}

canonical_original_code:
void read_standard()
{
 char *line;
 char *key;
 struct s_search *head;
 head = new_t_search(((void *)0), ((void *)0));
 the_head = head;
 the_head->is_leef = 1;
 get_next_line(0, &line);
 key = ft_strdup(line);
 get_next_line(0, &line);
 head = new_t_search(key, line);
 insert_new(the_head, head);
 the_head->is_leef = 0;
 head->is_leef = 1;
 define_thehead(the_head, line, key);
}


decompiled_code:
__int64 __fastcall print_t_search(__int64 a1)
{
__int64 v1; // rbx
__int64 result; // rax
__int64 v3; // rbx

ft_putstr(*(_QWORD *)a1);
ft_putstr(" ");
ft_putstr(*(_QWORD *)(a1 + 8));
ft_putchar(10LL);
if ( *(int *)(a1 + 16) > 0 )
{
v1 = 0LL;
do
{
ft_putstr(**(_QWORD **)(*(_QWORD *)(a1 + 32) + 8 * v1));
ft_putchar(32LL);
++v1;
}
while ( *(_DWORD *)(a1 + 16) > (int)v1 );
}
result = ft_putstr("\n\n\n");
if ( *(int *)(a1 + 16) > 0 )
{
v3 = 0LL;
do
result = print_t_search(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 8 * v3++));
while ( *(_DWORD *)(a1 + 16) > (int)v3 );
}
return result;
}

original_code:
void print_t_search(t_search *head)
{
 int i;
 ft_putstr(head->keyword);
 ft_putstr("    ");
 ft_putstr(head->value);
 ft_putchar('\n');
 i = 0;
 while (i < head->nb_next)
 {
  ft_putstr((head->next[i])->keyword);
  ft_putchar(' ');
  i++;
 }
 ft_putstr("\n\n\n");
 i = 0;
 while (i < head->nb_next)
 {
  print_t_search(head->next[i]);
  i++;
 }
}

canonical_original_code:
void print_t_search(struct s_search *head)
{
 int i;
 ft_putstr(head->keyword);
 ft_putstr("    ");
 ft_putstr(head->value);
 ft_putchar('\n');
 i = 0;
 while (i < head->nb_next)
 {
  ft_putstr((head->next[i])->keyword);
  ft_putchar(' ');
  i++;
 }
 ft_putstr("\n\n\n");
 i = 0;
 while (i < head->nb_next)
 {
  print_t_search(head->next[i]);
  i++;
 }
}


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
read_standard(argc, argv, envp);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
func2(argc, argv, envp);
return 0;
}

original_code:
int main()
{
 read_standard();
 return (0);
}


original_code:
int ft_strcmp(const char *s1, const char *s2)
{
 int count;
 count = 0;
 if (s1 == ((void *)0) || s2 == ((void *)0))
  return (1);
 while (s1[count] == s2[count] && s1[count] != 0 && s2[count] != 0)
  count++;
 return (s1[count] - s2[count]);
}

canonical_original_code:
int ft_strcmp(char *s1, char *s2)
{
 int count;
 count = 0;
 if (s1 == ((void *)0) || s2 == ((void *)0))
  return (1);
 while (s1[count] == s2[count] && s1[count] != 0 && s2[count] != 0)
  count++;
 return (s1[count] - s2[count]);
}

variable_types: count int


original_code:
void move_elem(t_search **tab, int i, int nb)
{
 while (nb > i)
 {
  tab[nb] = tab[nb - 1];
  nb--;
 }
}

canonical_original_code:
void move_elem(struct s_search **tab, int i, int nb)
{
 while (nb > i)
 {
  tab[nb] = tab[nb - 1];
  nb--;
 }
}

variable_types: struct s_search { char *keyword; char *value; int nb_next; short is_leef; struct s_search *before; struct s_search **next; } **

variable_types: nb int


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

for ( result = 1208LL; result != 2408; result += 8LL )
*(_QWORD *)(*(_QWORD *)(a1 + 32) + result - 1208) = *(_QWORD *)(*(_QWORD *)(a1 + 32) + result);
*(_DWORD *)(a1 + 16) = 150;
return result;
}

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

for ( result = 1208LL; result != 2408; result += 8LL )
*(_QWORD *)(*(_QWORD *)(a1 + 32) + result - 1208) = *(_QWORD *)(*(_QWORD *)(a1 + 32) + result);
*(_DWORD *)(a1 + 16) = 150;
return result;
}

original_code:
void reduce_t_search(t_search *head)
{
 int i;
 i = 0;
 while (i < 301 / 2)
 {
  head->next[i] = head->next[i + 301 / 2 + 1];
  i++;
 }
 head->nb_next = 301 / 2;
}

canonical_original_code:
void reduce_t_search(struct s_search *head)
{
 int i;
 i = 0;
 while (i < 301 / 2)
 {
  head->next[i] = head->next[i + 301 / 2 + 1];
  i++;
 }
 head->nb_next = 301 / 2;
}


decompiled_code:
__int64 __fastcall split_t_search(__int64 a1)
{
__int64 v2; // [rsp+8h] [rbp-10h] BYREF

sub_t_search(a1, &v2);
reduce_t_search(a1);
return insert_tab(*(_QWORD *)(a1 + 24), v2);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
__int64 v2; // [rsp+8h] [rbp-10h] BYREF

sub_t_search(a1, &v2);
func2(a1);
return insert_tab(*(_QWORD *)(a1 + 24), v2);
}

original_code:
void split_t_search(t_search *head)
{
 t_search *t1;
 sub_t_search(head, &t1);
 reduce_t_search(head);
 insert_tab(head->before, t1);
}

canonical_original_code:
void split_t_search(struct s_search *head)
{
 struct s_search *t1;
 sub_t_search(head, &t1);
 reduce_t_search(head);
 insert_tab(head->before, t1);
}


decompiled_code:
__int64 __fastcall insert_tab(__int64 a1, _QWORD *a2)
{
__int64 result; // rax
__int64 i; // rbx
int v4[11]; // [rsp+Ch] [rbp-2Ch] BYREF

v4[0] = 1;
if ( *(_DWORD *)(a1 + 16) == 301 )
{
split_t_search();
insert_new(the_head, a2);
v4[0] = 0;
}
result = *(unsigned int *)(a1 + 16);
for ( i = 0LL; (int)result >= (int)i; ++i )
{
if ( !v4[0] )
break;
if ( (_DWORD)result == (_DWORD)i || (int)ft_strcmp(*a2, **(_QWORD **)(*(_QWORD *)(a1 + 32) + 8 * i)) < 0 )
{
sub_insert(a1, a2, (unsigned int)i, v4);
}
else if ( !(unsigned int)ft_strcmp(*a2, **(_QWORD **)(*(_QWORD *)(a1 + 32) + 8 * i)) )
{
*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 8 * i) + 8LL) = a2[1];
}
result = *(unsigned int *)(a1 + 16);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, _QWORD *a2)
{
__int64 result; // rax
__int64 i; // rbx
int v4[11]; // [rsp+Ch] [rbp-2Ch] BYREF

v4[0] = 1;
if ( *(_DWORD *)(a1 + 16) == 301 )
{
split_t_search();
func1(the_head, a2);
v4[0] = 0;
}
result = *(unsigned int *)(a1 + 16);
for ( i = 0LL; (int)result >= (int)i; ++i )
{
if ( !v4[0] )
break;
if ( (_DWORD)result == (_DWORD)i || (int)ft_strcmp(*a2, **(_QWORD **)(*(_QWORD *)(a1 + 32) + 8 * i)) < 0 )
{
sub_insert(a1, a2, (unsigned int)i, v4);
}
else if ( !(unsigned int)ft_strcmp(*a2, **(_QWORD **)(*(_QWORD *)(a1 + 32) + 8 * i)) )
{
*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 8 * i) + 8LL) = a2[1];
}
result = *(unsigned int *)(a1 + 16);
}
return result;
}

original_code:
void insert_tab(t_search *head, t_search *new)
{
 int i;
 int out;
 i = 0;
 out = 1;
 if (head->nb_next == 301 && out)
 {
  split_t_search(head);
  insert_new(the_head, new);
  out = 0;
 }
 while (i <= head->nb_next && out)
 {
  if (i == head->nb_next
   || ft_strcmp(new->keyword, (head->next[i])->keyword) < 0)
   sub_insert(head, new, i, &out);
  else if (ft_strcmp(new->keyword, (head->next[i])->keyword) == 0)
   (head->next[i])->value = new->value;
  i++;
 }
}

canonical_original_code:
void insert_tab(struct s_search *head, struct s_search *new)
{
 int i;
 int out;
 i = 0;
 out = 1;
 if (head->nb_next == 301 && out)
 {
  split_t_search(head);
  insert_new(the_head, new);
  out = 0;
 }
 while (i <= head->nb_next && out)
 {
  if (i == head->nb_next
   || ft_strcmp(new->keyword, (head->next[i])->keyword) < 0)
   sub_insert(head, new, i, &out);
  else if (ft_strcmp(new->keyword, (head->next[i])->keyword) == 0)
   (head->next[i])->value = new->value;
  i++;
 }
}

variable_types:
new
struct s_search *

variable_types: out int


decompiled_code:
void __fastcall insert_new(_QWORD *a1, _QWORD *a2)
{
if ( (unsigned int)ft_strcmp(*a1, *a2) )
{
if ( *((_WORD *)a1 + 10) == 1 )
{
insert_tab((__int64)a1, a2);
}
else if ( (int)ft_strcmp(*a1, *a2) < 0 )
{
swap_t_search(a1, a2);
insert_new(a1, a2);
}
else
{
what_branch(a1, a2);
}
}
else
{
free((void *)a1[1]);
a1[1] = a2[1];
free(a2);
}
}

canonical_decompiled_code:
void __fastcall func1(_QWORD *a1, _QWORD *a2)
{
if ( (unsigned int)ft_strcmp(*a1, *a2) )
{
if ( *((_WORD *)a1 + 10) == 1 )
{
func0((__int64)a1, a2);
}
else if ( (int)ft_strcmp(*a1, *a2) < 0 )
{
swap_t_search(a1, a2);
func1(a1, a2);
}
else
{
func2(a1, a2);
}
}
else
{
free((void *)a1[1]);
a1[1] = a2[1];
free(a2);
}
}

original_code:
void insert_new(t_search *head, t_search *new)
{
 if (ft_strcmp(head->keyword, new->keyword) == 0)
 {
  free(head->value);
  head->value = new->value;
  free(new);
 }
 else if (head->is_leef == 1)
  insert_tab(head, new);
 else if (ft_strcmp(head->keyword, new->keyword) < 0)
 {
  swap_t_search(head, new);
  insert_new(head, new);
 }
 else
 {
  what_branch(head, new);
 }
}

canonical_original_code:
void insert_new(struct s_search *head, struct s_search *new)
{
 if (ft_strcmp(head->keyword, new->keyword) == 0)
 {
  free(head->value);
  head->value = new->value;
  free(new);
 }
 else if (head->is_leef == 1)
  insert_tab(head, new);
 else if (ft_strcmp(head->keyword, new->keyword) < 0)
 {
  swap_t_search(head, new);
  insert_new(head, new);
 }
 else
 {
  what_branch(head, new);
 }
}


original_code:
void what_branch(t_search *head, t_search *new)
{
 int i;
 i = 0;
 while (i < head->nb_next)
 {
  if (ft_strcmp(((head->next)[i])->keyword,
     new->keyword) >= 0)
  {
   insert_new(head->next[i], new);
   i = head->nb_next + 1;
  }
  i++;
 }
 if (i == head->nb_next)
 {
  swap_t_search(head->next[i - 1], new);
  insert_new(head, new);
 }
}

canonical_original_code:
void what_branch(struct s_search *head, struct s_search *new)
{
 int i;
 i = 0;
 while (i < head->nb_next)
 {
  if (ft_strcmp(((head->next)[i])->keyword,
     new->keyword) >= 0)
  {
   insert_new(head->next[i], new);
   i = head->nb_next + 1;
  }
  i++;
 }
 if (i == head->nb_next)
 {
  swap_t_search(head->next[i - 1], new);
  insert_new(head, new);
 }
}


original_code:
void sub_t_search(t_search *head, t_search **t1)
{
 int i;
 i = 0;
 *t1 = new_t_search(head->next[head->nb_next / 2]->keyword,
  head->next[head->nb_next / 2]->value);
 (*t1)->before = head->before;
 (*t1)->is_leef = 1;
 while (i < head->nb_next / 2)
 {
  (*t1)->next[i] = head->next[i];
  (*t1)->nb_next++;
  i++;
 }
}

canonical_original_code:
void sub_t_search(struct s_search *head, struct s_search **t1)
{
 int i;
 i = 0;
 *t1 = new_t_search(head->next[head->nb_next / 2]->keyword,
  head->next[head->nb_next / 2]->value);
 (*t1)->before = head->before;
 (*t1)->is_leef = 1;
 while (i < head->nb_next / 2)
 {
  (*t1)->next[i] = head->next[i];
  (*t1)->nb_next++;
  i++;
 }
}


decompiled_code:
__int64 __fastcall ft_putstr(char *a1)
{
char v2; // di
_BYTE *i; // rbx
__int64 result; // rax

if ( !a1 )
return ft_putstr("NULL");
v2 = *a1;
for ( i = a1 + 1; v2; v2 = *(i - 1) )
{
result = ft_putchar((unsigned int)v2);
++i;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *a1)
{
char v2; // di
_BYTE *i; // rbx
__int64 result; // rax

if ( !a1 )
return func0("NULL");
v2 = *a1;
for ( i = a1 + 1; v2; v2 = *(i - 1) )
{
result = ft_putchar((unsigned int)v2);
++i;
}
return result;
}

original_code:
void ft_putstr(const char *s)
{
 int count;
 count = 0;
 if (s == ((void *)0))
  ft_putstr("NULL");
 else
 {
  while (s[count])
  {
   ft_putchar(s[count]);
   count++;
  }
 }
}

canonical_original_code:
void ft_putstr(char *s)
{
 int count;
 count = 0;
 if (s == ((void *)0))
  ft_putstr("NULL");
 else
 {
  while (s[count])
  {
   ft_putchar(s[count]);
   count++;
  }
 }
}

variable_types:
s
char *


decompiled_code:
__int64 __fastcall find_next(char *a1)
{
char *v1; // rax
char v2; // dl

if ( !a1 )
return 0xFFFFFFFFLL;
v1 = a1;
while ( 1 )
{
v2 = *v1;
if ( !*v1 )
break;
++v1;
if ( v2 == 10 )
return (unsigned int)((_DWORD)v1 - (_DWORD)a1 - 1);
}
return 0xFFFFFFFFLL;
}

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

if ( !a1 )
return 0xFFFFFFFFLL;
v1 = a1;
while ( 1 )
{
v2 = *v1;
if ( !*v1 )
break;
++v1;
if ( v2 == 10 )
return (unsigned int)((_DWORD)v1 - (_DWORD)a1 - 1);
}
return 0xFFFFFFFFLL;
}

original_code:
static int find_next(char *str)
{
 char *stock;
 stock = str;
 if (str)
 while (*str)
  if (*str++ == '\n')
  return (str - stock - 1);
 return (-1);
}

variable_types:
str
char *

variable_types:
stock
char *


len

decompiled_code:
__int64 __fastcall len(_BYTE *a1)
{
__int64 result; // rax
_BYTE *v2; // rax

if ( !a1 )
return 0LL;
result = 0LL;
if ( *a1 )
{
v2 = a1;
do
++v2;
while ( *v2 );
result = (unsigned int)((_DWORD)v2 - (_DWORD)a1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(_BYTE *a1)
{
__int64 result; // rax
_BYTE *v2; // rax

if ( !a1 )
return 0LL;
result = 0LL;
if ( *a1 )
{
v2 = a1;
do
++v2;
while ( *v2 );
result = (unsigned int)((_DWORD)v2 - (_DWORD)a1);
}
return result;
}

original_code:
static int len(char *str)
{
 char *stock;
 if (!str || !*str)
 return (0);
 stock = str;
 while (*str)
 str++;
 return (str - stock);
}


decompiled_code:
ssize_t __fastcall get_next_line(int fd, char **a2)
{
char *v2; // rax
ssize_t result; // rax
_BYTE v4[1048]; // [rsp+0h] [rbp-418h] BYREF

while ( 1 )
{
v2 = get_next_next((char **)&old_1);
if ( v2 )
break;
result = read(fd, v4, 0x400uLL);
if ( !(_DWORD)result )
return result;
old_1 = (__int64)concat((char *)old_1, (__int64)v4, result);
if ( !old_1 )
return 0xFFFFFFFFLL;
}
*a2 = v2;
return 1LL;
}

canonical_decompiled_code:
ssize_t __fastcall func3(int fd, char **a2)
{
char *v2; // rax
ssize_t result; // rax
_BYTE v4[1048]; // [rsp+0h] [rbp-418h] BYREF

while ( 1 )
{
v2 = func2((char **)&old_1);
if ( v2 )
break;
result = read(fd, v4, 0x400uLL);
if ( !(_DWORD)result )
return result;
old_1 = (__int64)concat((char *)old_1, (__int64)v4, result);
if ( !old_1 )
return 0xFFFFFFFFLL;
}
*a2 = v2;
return 1LL;
}

original_code:
int get_next_line(int fd, char **line)
{
 char *ret;
 int n_read;
 static char *old;
 static int i;
 char buf[1024];
 while (!(ret = get_next_next(&old)))
 {
  n_read = read(fd, buf, 1024);
  if (!n_read)
   return (0);
  old = concat(old, buf, n_read);
  if (old == ((void *)0))
   return (-1);
 }
 line[i] = ret;
 return (1);
}

variable_types: fd int

variable_types:
line
char **

variable_types:
ret
char *

variable_types:
old
char *

variable_types:
buf
char [1024]


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

if ( !*a1 )
return 0LL;
result = 0LL;
do
++result;
while ( a1[result] );
return result;
}

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

if ( !*a1 )
return 0LL;
result = 0LL;
do
++result;
while ( a1[result] );
return result;
}

original_code:
size_t ft_strlen(const char *s)
{
 size_t count;
 count = 0;
 while (s[count])
 {
  count++;
 }
 return (count);
}

canonical_original_code:
unsigned long ft_strlen(char *s)
{
 unsigned long count;
 count = 0;
 while (s[count])
 {
  count++;
 }
 return (count);
}

variable_types:
count
unsigned long

return_type: unsigned long


decompiled_code:
__int64 __fastcall find_value(__int64 a1, __int64 a2)
{
__int64 v2; // rbx

if ( !(unsigned int)ft_strcmp(*(_QWORD *)a1) )
return *(_QWORD *)(a1 + 8);
if ( *(int *)(a1 + 16) <= 0 )
return 0LL;
v2 = 0LL;
while ( (int)ft_strcmp(**(_QWORD **)(*(_QWORD *)(a1 + 32) + 8 * v2)) < 0 )
{
if ( *(_DWORD *)(a1 + 16) <= (int)++v2 )
return 0LL;
}
return find_value(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 8 * v2), a2);
}

original_code:
char *find_value(t_search *head, char *keyword)
{
 int i;
 i = 0;
 if (ft_strcmp(head->keyword, keyword) != 0)
 {
  while (i < head->nb_next)
  {
   if (ft_strcmp(head->next[i]->keyword, keyword) >= 0)
    return (find_value(head->next[i], keyword));
   i++;
  }
 }
 else
  return (head->value);
 return (((void *)0));
}

canonical_original_code:
char *find_value(struct s_search *head, char *keyword)
{
 int i;
 i = 0;
 if (ft_strcmp(head->keyword, keyword) != 0)
 {
  while (i < head->nb_next)
  {
   if (ft_strcmp(head->next[i]->keyword, keyword) >= 0)
    return (find_value(head->next[i], keyword));
   i++;
  }
 }
 else
  return (head->value);
 return (((void *)0));
}

variable_types: struct s_search { char *keyword; char *value; int nb_next; short is_leef; struct s_search *before; struct s_search **next; } *

variable_types:
keyword
char *

return_type: char *


original_code:
void *ft_memcpy(void *s1, const void *s2, size_t n)
{
 size_t count;
 unsigned char *str1;
 unsigned char *str2;
 count = 0;
 str1 = (unsigned char *) s1;
 str2 = (unsigned char *) s2;
 while (count < n)
 {
  str1[count] = str2[count];
  count++;
 }
 return (s1);
}

canonical_original_code:
void *ft_memcpy(void *s1, void *s2, unsigned long n)
{
 unsigned long count;
 unsigned char *str1;
 unsigned char *str2;
 count = 0;
 str1 = (unsigned char *) s1;
 str2 = (unsigned char *) s2;
 while (count < n)
 {
  str1[count] = str2[count];
  count++;
 }
 return (s1);
}

variable_types:
n
unsigned long

return_type: void *


decompiled_code:
ssize_t __fastcall ft_putchar(char a1)
{
char buf[12]; // [rsp+Ch] [rbp-Ch] BYREF

buf[0] = a1;
return write(1, buf, 1uLL);
}

canonical_decompiled_code:
ssize_t __fastcall func0(char a1)
{
char buf[12]; // [rsp+Ch] [rbp-Ch] BYREF

buf[0] = a1;
return write(1, buf, 1uLL);
}

original_code:
void ft_putchar(char c)
{
 write(1, &c, 1);
}

variable_types: c char