decompiled_code:
void classical_e()
{
double *v0; // rsi
double *v1; // rsi
double *v2; // rsi
double *v3; // rsi
double *v4; // rsi
__int64 v5; // rdi
double *v6; // r10
__int64 v7; // r8
double *v8; // rsi
double *v9; // rsi
double *v10; // rsi
__int64 v11; // rdi
double *v12; // rsi
double *v13; // rsi
double *v14; // r11
__int64 v15; // r8
double *v16; // rsi
double *v17; // r10
__int64 v18; // r8
double *v19; // rsi
double *v20; // rsi
double *v21; // rsi
double *v22; // rsi
double *v23; // rsi
double *v24; // rsi
double *v25; // r11
__int64 v26; // r8
double *v27; // rsi
double *v28; // rsi
double *v29; // rsi
double *v30; // r10
__int64 v31; // r8
double *v32; // rsi
double *v33; // rsi
double *v34; // rsi
double *v35; // rsi
double *v36; // rsi

for ( z = 0; (unsigned int)z < total_z; ++z )
{
for ( y = 0; (unsigned int)y < total_y; ++y )
{
x = 0;
if ( total_x )
{
v11 = 0LL;
do
{
if ( (unsigned int)in_partition_main(v11, (unsigned int)y, (unsigned int)z) )
{
switch ( mode )
{
case 0:
v0 = (double *)(*(_QWORD *)(*(_QWORD *)(ex + 8LL * x) + 8LL * y) + 8LL * z);
*v0 = *(double *)(*(_QWORD *)(*(_QWORD *)(ca + 8LL * x) + 8LL * y) + 8LL * z) * *v0
- *(double *)(*(_QWORD *)(*(_QWORD *)(dipole_ex + 8LL * x) + 8LL * y) + 8LL * z)
* d_t
/ *(double *)(*(_QWORD *)(*(_QWORD *)(epsilon + 8LL * x) + 8LL * y) + 8LL * z);
v1 = (double *)(*(_QWORD *)(*(_QWORD *)(ey + 8LL * x) + 8LL * y) + 8LL * z);
*v1 = *(double *)(*(_QWORD *)(*(_QWORD *)(ca + 8LL * x) + 8LL * y) + 8LL * z) * *v1
- *(double *)(*(_QWORD *)(*(_QWORD *)(dipole_ey + 8LL * x) + 8LL * y) + 8LL * z)
* d_t
/ *(double *)(*(_QWORD *)(*(_QWORD *)(epsilon + 8LL * x) + 8LL * y) + 8LL * z);
v2 = (double *)(*(_QWORD *)(*(_QWORD *)(ez + 8LL * x) + 8LL * y) + 8LL * z);
*v2 = *(double *)(*(_QWORD *)(*(_QWORD *)(ca + 8LL * x) + 8LL * y) + 8LL * z) * *v2
- *(double *)(*(_QWORD *)(*(_QWORD *)(dipole_ez + 8LL * x) + 8LL * y) + 8LL * z)
* d_t
/ *(double *)(*(_QWORD *)(*(_QWORD *)(epsilon + 8LL * x) + 8LL * y) + 8LL * z);
if ( y )
{
v3 = (double *)(*(_QWORD *)(*(_QWORD *)(ex + 8LL * x) + 8LL * y) + 8LL * z);
*v3 = (*(double *)(*(_QWORD *)(*(_QWORD *)(hz + 8LL * x) + 8LL * y) + 8LL * z)
- *(double *)(*(_QWORD *)(*(_QWORD *)(hz + 8LL * x) + 8LL * y - 8) + 8LL * z))
* *(double *)(*(_QWORD *)(*(_QWORD *)(cb_y + 8LL * x) + 8LL * y) + 8LL * z)
+ *v3;
}
if ( z )
{
v4 = (double *)(*(_QWORD *)(*(_QWORD *)(ex + 8LL * x) + 8LL * y) + 8LL * z);
v5 = *(_QWORD *)(*(_QWORD *)(hy + 8LL * x) + 8LL * y);
*v4 = (*(double *)(v5 + 8LL * z - 8) - *(double *)(v5 + 8LL * z))
* *(double *)(*(_QWORD *)(*(_QWORD *)(cb_z + 8LL * x) + 8LL * y) + 8LL * z)
+ *v4;
if ( z )
{
v6 = (double *)(*(_QWORD *)(*(_QWORD *)(ey + 8LL * x) + 8LL * y) + 8LL * z);
v7 = *(_QWORD *)(*(_QWORD *)(hx + 8LL * x) + 8LL * y);
*v6 = (*(double *)(v7 + 8LL * z) - *(double *)(v7 + 8LL * z - 8))
* *(double *)(*(_QWORD *)(*(_QWORD *)(cb_z + 8LL * x) + 8LL * y) + 8LL * z)
+ *v6;
}
}
if ( x )
{
v8 = (double *)(*(_QWORD *)(*(_QWORD *)(ey + 8LL * x) + 8LL * y) + 8LL * z);
*v8 = *v8
- (*(double *)(*(_QWORD *)(*(_QWORD *)(hz + 8LL * x) + 8LL * y) + 8LL * z)
- *(double *)(*(_QWORD *)(*(_QWORD *)(hz + 8LL * x - 8) + 8LL * y) + 8LL * z))
* *(double *)(*(_QWORD *)(*(_QWORD *)(cb_x + 8LL * x) + 8LL * y) + 8LL * z);
if ( x )
{
v9 = (double *)(*(_QWORD *)(*(_QWORD *)(ez + 8LL * x) + 8LL * y) + 8LL * z);
*v9 = (*(double *)(*(_QWORD *)(*(_QWORD *)(hy + 8LL * x) + 8LL * y) + 8LL * z)
- *(double *)(*(_QWORD *)(*(_QWORD *)(hy + 8LL * x - 8) + 8LL * y) + 8LL * z))
* *(double *)(*(_QWORD *)(*(_QWORD *)(cb_x + 8LL * x) + 8LL * y) + 8LL * z)
+ *v9;
}
}
if ( y )
{
v10 = (double *)(*(_QWORD *)(*(_QWORD *)(ez + 8LL * x) + 8LL * y) + 8LL * z);
*v10 = *v10
- (*(double *)(*(_QWORD *)(*(_QWORD *)(hx + 8LL * x) + 8LL * y) + 8LL * z)
- *(double *)(*(_QWORD *)(*(_QWORD *)(hx + 8LL * x) + 8LL * y - 8) + 8LL * z))
* *(double *)(*(_QWORD *)(*(_QWORD *)(cb_y + 8LL * x) + 8LL * y) + 8LL * z);
}
break;
case 1:
v12 = (double *)(*(_QWORD *)(*(_QWORD *)(ex + 8LL * x) + 8LL * y) + 8LL * z);
*v12 = *(double *)(*(_QWORD *)(*(_QWORD *)(ca + 8LL * x) + 8LL * y) + 8LL * z) * *v12
- *(double *)(*(_QWORD *)(*(_QWORD *)(dipole_ex + 8LL * x) + 8LL * y) + 8LL * z)
* d_t
/ *(double *)(*(_QWORD *)(*(_QWORD *)(epsilon + 8LL * x) + 8LL * y) + 8LL * z);
if ( y )
{
v13 = (double *)(*(_QWORD *)(*(_QWORD *)(ex + 8LL * x) + 8LL * y) + 8LL * z);
*v13 = (*(double *)(*(_QWORD *)(*(_QWORD *)(hz + 8LL * x) + 8LL * y) + 8LL * z)
- *(double *)(*(_QWORD *)(*(_QWORD *)(hz + 8LL * x) + 8LL * y - 8) + 8LL * z))
* *(double *)(*(_QWORD *)(*(_QWORD *)(cb_y + 8LL * x) + 8LL * y) + 8LL * z)
+ *v13;
}
if ( z )
{
v14 = (double *)(*(_QWORD *)(*(_QWORD *)(ex + 8LL * x) + 8LL * y) + 8LL * z);
v15 = *(_QWORD *)(*(_QWORD *)(hy + 8LL * x) + 8LL * y);
*v14 = (*(double *)(v15 + 8LL * z) - *(double *)(v15 + 8LL * z - 8))
* *(double *)(*(_QWORD *)(*(_QWORD *)(cb_z + 8LL * x) + 8LL * y) + 8LL * z)
+ *v14;
}
break;
case 2:
v16 = (double *)(*(_QWORD *)(*(_QWORD *)(ey + 8LL * x) + 8LL * y) + 8LL * z);
*v16 = *(double *)(*(_QWORD *)(*(_QWORD *)(ca + 8LL * x) + 8LL * y) + 8LL * z) * *v16
- *(double *)(*(_QWORD *)(*(_QWORD *)(dipole_ey + 8LL * x) + 8LL * y) + 8LL * z)
* d_t
/ *(double *)(*(_QWORD *)(*(_QWORD *)(epsilon + 8LL * x) + 8LL * y) + 8LL * z);
if ( z )
{
v17 = (double *)(*(_QWORD *)(*(_QWORD *)(ey + 8LL * x) + 8LL * y) + 8LL * z);
v18 = *(_QWORD *)(*(_QWORD *)(hx + 8LL * x) + 8LL * y);
*v17 = (*(double *)(v18 + 8LL * z) - *(double *)(v18 + 8LL * z - 8))
* *(double *)(*(_QWORD *)(*(_QWORD *)(cb_z + 8LL * x) + 8LL * y) + 8LL * z)
+ *v17;
}
if ( x )
{
v19 = (double *)(*(_QWORD *)(*(_QWORD *)(ey + 8LL * x) + 8LL * y) + 8LL * z);
*v19 = *v19
- (*(double *)(*(_QWORD *)(*(_QWORD *)(hz + 8LL * x) + 8LL * y) + 8LL * z)
- *(double *)(*(_QWORD *)(*(_QWORD *)(hz + 8LL * x - 8) + 8LL * y) + 8LL * z))
* *(double *)(*(_QWORD *)(*(_QWORD *)(cb_x + 8LL * x) + 8LL * y) + 8LL * z);
}
break;
case 3:
v20 = (double *)(*(_QWORD *)(*(_QWORD *)(ez + 8LL * x) + 8LL * y) + 8LL * z);
*v20 = *(double *)(*(_QWORD *)(*(_QWORD *)(ca + 8LL * x) + 8LL * y) + 8LL * z) * *v20
- *(double *)(*(_QWORD *)(*(_QWORD *)(dipole_ez + 8LL * x) + 8LL * y) + 8LL * z)
* d_t
/ *(double *)(*(_QWORD *)(*(_QWORD *)(epsilon + 8LL * x) + 8LL * y) + 8LL * z);
if ( x )
{
v21 = (double *)(*(_QWORD *)(*(_QWORD *)(ez + 8LL * x) + 8LL * y) + 8LL * z);
*v21 = (*(double *)(*(_QWORD *)(*(_QWORD *)(hy + 8LL * x) + 8LL * y) + 8LL * z)
- *(double *)(*(_QWORD *)(*(_QWORD *)(hy + 8LL * x - 8) + 8LL * y) + 8LL * z))
* *(double *)(*(_QWORD *)(*(_QWORD *)(cb_x + 8LL * x) + 8LL * y) + 8LL * z)
+ *v21;
}
if ( y )
{
v22 = (double *)(*(_QWORD *)(*(_QWORD *)(ez + 8LL * x) + 8LL * y) + 8LL * z);
*v22 = *v22
- (*(double *)(*(_QWORD *)(*(_QWORD *)(hx + 8LL * x) + 8LL * y) + 8LL * z)
- *(double *)(*(_QWORD *)(*(_QWORD *)(hx + 8LL * x) + 8LL * y - 8) + 8LL * z))
* *(double *)(*(_QWORD *)(*(_QWORD *)(cb_y + 8LL * x) + 8LL * y) + 8LL * z);
}
break;
case 4:
v23 = (double *)(*(_QWORD *)(*(_QWORD *)(ey + 8LL * x) + 8LL * y) + 8LL * z);
*v23 = *(double *)(*(_QWORD *)(*(_QWORD *)(ca + 8LL * x) + 8LL * y) + 8LL * z) * *v23
- *(double *)(*(_QWORD *)(*(_QWORD *)(dipole_ey + 8LL * x) + 8LL * y) + 8LL * z)
* d_t
/ *(double *)(*(_QWORD *)(*(_QWORD *)(epsilon + 8LL * x) + 8LL * y) + 8LL * z);
v24 = (double *)(*(_QWORD *)(*(_QWORD *)(ez + 8LL * x) + 8LL * y) + 8LL * z);
*v24 = *(double *)(*(_QWORD *)(*(_QWORD *)(ca + 8LL * x) + 8LL * y) + 8LL * z) * *v24
- *(double *)(*(_QWORD *)(*(_QWORD *)(dipole_ez + 8LL * x) + 8LL * y) + 8LL * z)
* d_t
/ *(double *)(*(_QWORD *)(*(_QWORD *)(epsilon + 8LL * x) + 8LL * y) + 8LL * z);
if ( z )
{
v25 = (double *)(*(_QWORD *)(*(_QWORD *)(ey + 8LL * x) + 8LL * y) + 8LL * z);
v26 = *(_QWORD *)(*(_QWORD *)(hx + 8LL * x) + 8LL * y);
*v25 = (*(double *)(v26 + 8LL * z) - *(double *)(v26 + 8LL * z - 8))
* *(double *)(*(_QWORD *)(*(_QWORD *)(cb_z + 8LL * x) + 8LL * y) + 8LL * z)
+ *v25;
}
if ( y )
{
v27 = (double *)(*(_QWORD *)(*(_QWORD *)(ez + 8LL * x) + 8LL * y) + 8LL * z);
*v27 = *v27
- (*(double *)(*(_QWORD *)(*(_QWORD *)(hx + 8LL * x) + 8LL * y) + 8LL * z)
- *(double *)(*(_QWORD *)(*(_QWORD *)(hx + 8LL * x) + 8LL * y - 8) + 8LL * z))
* *(double *)(*(_QWORD *)(*(_QWORD *)(cb_y + 8LL * x) + 8LL * y) + 8LL * z);
}
break;
case 5:
v28 = (double *)(*(_QWORD *)(*(_QWORD *)(ex + 8LL * x) + 8LL * y) + 8LL * z);
*v28 = *(double *)(*(_QWORD *)(*(_QWORD *)(ca + 8LL * x) + 8LL * y) + 8LL * z) * *v28
- *(double *)(*(_QWORD *)(*(_QWORD *)(dipole_ex + 8LL * x) + 8LL * y) + 8LL * z)
* d_t
/ *(double *)(*(_QWORD *)(*(_QWORD *)(epsilon + 8LL * x) + 8LL * y) + 8LL * z);
v29 = (double *)(*(_QWORD *)(*(_QWORD *)(ez + 8LL * x) + 8LL * y) + 8LL * z);
*v29 = *(double *)(*(_QWORD *)(*(_QWORD *)(ca + 8LL * x) + 8LL * y) + 8LL * z) * *v29
- *(double *)(*(_QWORD *)(*(_QWORD *)(dipole_ez + 8LL * x) + 8LL * y) + 8LL * z)
* d_t
/ *(double *)(*(_QWORD *)(*(_QWORD *)(epsilon + 8LL * x) + 8LL * y) + 8LL * z);
if ( z )
{
v30 = (double *)(*(_QWORD *)(*(_QWORD *)(ex + 8LL * x) + 8LL * y) + 8LL * z);
v31 = *(_QWORD *)(*(_QWORD *)(hy + 8LL * x) + 8LL * y);
*v30 = *v30
- (*(double *)(v31 + 8LL * z) - *(double *)(v31 + 8LL * z - 8))
* *(double *)(*(_QWORD *)(*(_QWORD *)(cb_z + 8LL * x) + 8LL * y) + 8LL * z);
}
if ( x )
{
v32 = (double *)(*(_QWORD *)(*(_QWORD *)(ez + 8LL * x) + 8LL * y) + 8LL * z);
*v32 = (*(double *)(*(_QWORD *)(*(_QWORD *)(hy + 8LL * x) + 8LL * y) + 8LL * z)
- *(double *)(*(_QWORD *)(*(_QWORD *)(hy + 8LL * x - 8) + 8LL * y) + 8LL * z))
* *(double *)(*(_QWORD *)(*(_QWORD *)(cb_x + 8LL * x) + 8LL * y) + 8LL * z)
+ *v32;
}
break;
case 6:
v33 = (double *)(*(_QWORD *)(*(_QWORD *)(ex + 8LL * x) + 8LL * y) + 8LL * z);
*v33 = *(double *)(*(_QWORD *)(*(_QWORD *)(ca + 8LL * x) + 8LL * y) + 8LL * z) * *v33
- *(double *)(*(_QWORD *)(*(_QWORD *)(dipole_ex + 8LL * x) + 8LL * y) + 8LL * z)
* d_t
/ *(double *)(*(_QWORD *)(*(_QWORD *)(epsilon + 8LL * x) + 8LL * y) + 8LL * z);
v34 = (double *)(*(_QWORD *)(*(_QWORD *)(ey + 8LL * x) + 8LL * y) + 8LL * z);
*v34 = *(double *)(*(_QWORD *)(*(_QWORD *)(ca + 8LL * x) + 8LL * y) + 8LL * z) * *v34
- *(double *)(*(_QWORD *)(*(_QWORD *)(dipole_ey + 8LL * x) + 8LL * y) + 8LL * z)
* d_t
/ *(double *)(*(_QWORD *)(*(_QWORD *)(epsilon + 8LL * x) + 8LL * y) + 8LL * z);
if ( y )
{
v35 = (double *)(*(_QWORD *)(*(_QWORD *)(ex + 8LL * x) + 8LL * y) + 8LL * z);
*v35 = (*(double *)(*(_QWORD *)(*(_QWORD *)(hz + 8LL * x) + 8LL * y) + 8LL * z)
- *(double *)(*(_QWORD *)(*(_QWORD *)(hz + 8LL * x) + 8LL * y - 8) + 8LL * z))
* *(double *)(*(_QWORD *)(*(_QWORD *)(cb_y + 8LL * x) + 8LL * y) + 8LL * z)
+ *v35;
}
if ( x )
{
v36 = (double *)(*(_QWORD *)(*(_QWORD *)(ey + 8LL * x) + 8LL * y) + 8LL * z);
*v36 = *v36
- (*(double *)(*(_QWORD *)(*(_QWORD *)(hz + 8LL * x) + 8LL * y) + 8LL * z)
- *(double *)(*(_QWORD *)(*(_QWORD *)(hz + 8LL * x - 8) + 8LL * y) + 8LL * z))
* *(double *)(*(_QWORD *)(*(_QWORD *)(cb_x + 8LL * x) + 8LL * y) + 8LL * z);
}
break;
default:
break;
}
}
v11 = (unsigned int)(x + 1);
x = v11;
}
while ( (unsigned int)v11 < total_x );
}
}
}
}

canonical_decompiled_code:
void func1()
{
double *v0; // rsi
double *v1; // rsi
double *v2; // rsi
double *v3; // rsi
double *v4; // rsi
__int64 v5; // rdi
double *v6; // r10
__int64 v7; // r8
double *v8; // rsi
double *v9; // rsi
double *v10; // rsi
__int64 v11; // rdi
double *v12; // rsi
double *v13; // rsi
double *v14; // r11
__int64 v15; // r8
double *v16; // rsi
double *v17; // r10
__int64 v18; // r8
double *v19; // rsi
double *v20; // rsi
double *v21; // rsi
double *v22; // rsi
double *v23; // rsi
double *v24; // rsi
double *v25; // r11
__int64 v26; // r8
double *v27; // rsi
double *v28; // rsi
double *v29; // rsi
double *v30; // r10
__int64 v31; // r8
double *v32; // rsi
double *v33; // rsi
double *v34; // rsi
double *v35; // rsi
double *v36; // rsi

for ( z = 0; (unsigned int)z < total_z; ++z )
{
for ( y = 0; (unsigned int)y < total_y; ++y )
{
x = 0;
if ( total_x )
{
v11 = 0LL;
do
{
if ( (unsigned int)in_partition_main(v11, (unsigned int)y, (unsigned int)z) )
{
switch ( mode )
{
case 0:
v0 = (double *)(*(_QWORD *)(*(_QWORD *)(ex + 8LL * x) + 8LL * y) + 8LL * z);
*v0 = *(double *)(*(_QWORD *)(*(_QWORD *)(ca + 8LL * x) + 8LL * y) + 8LL * z) * *v0
- *(double *)(*(_QWORD *)(*(_QWORD *)(dipole_ex + 8LL * x) + 8LL * y) + 8LL * z)
* d_t
/ *(double *)(*(_QWORD *)(*(_QWORD *)(epsilon + 8LL * x) + 8LL * y) + 8LL * z);
v1 = (double *)(*(_QWORD *)(*(_QWORD *)(ey + 8LL * x) + 8LL * y) + 8LL * z);
*v1 = *(double *)(*(_QWORD *)(*(_QWORD *)(ca + 8LL * x) + 8LL * y) + 8LL * z) * *v1
- *(double *)(*(_QWORD *)(*(_QWORD *)(dipole_ey + 8LL * x) + 8LL * y) + 8LL * z)
* d_t
/ *(double *)(*(_QWORD *)(*(_QWORD *)(epsilon + 8LL * x) + 8LL * y) + 8LL * z);
v2 = (double *)(*(_QWORD *)(*(_QWORD *)(ez + 8LL * x) + 8LL * y) + 8LL * z);
*v2 = *(double *)(*(_QWORD *)(*(_QWORD *)(ca + 8LL * x) + 8LL * y) + 8LL * z) * *v2
- *(double *)(*(_QWORD *)(*(_QWORD *)(dipole_ez + 8LL * x) + 8LL * y) + 8LL * z)
* d_t
/ *(double *)(*(_QWORD *)(*(_QWORD *)(epsilon + 8LL * x) + 8LL * y) + 8LL * z);
if ( y )
{
v3 = (double *)(*(_QWORD *)(*(_QWORD *)(ex + 8LL * x) + 8LL * y) + 8LL * z);
*v3 = (*(double *)(*(_QWORD *)(*(_QWORD *)(hz + 8LL * x) + 8LL * y) + 8LL * z)
- *(double *)(*(_QWORD *)(*(_QWORD *)(hz + 8LL * x) + 8LL * y - 8) + 8LL * z))
* *(double *)(*(_QWORD *)(*(_QWORD *)(cb_y + 8LL * x) + 8LL * y) + 8LL * z)
+ *v3;
}
if ( z )
{
v4 = (double *)(*(_QWORD *)(*(_QWORD *)(ex + 8LL * x) + 8LL * y) + 8LL * z);
v5 = *(_QWORD *)(*(_QWORD *)(hy + 8LL * x) + 8LL * y);
*v4 = (*(double *)(v5 + 8LL * z - 8) - *(double *)(v5 + 8LL * z))
* *(double *)(*(_QWORD *)(*(_QWORD *)(cb_z + 8LL * x) + 8LL * y) + 8LL * z)
+ *v4;
if ( z )
{
v6 = (double *)(*(_QWORD *)(*(_QWORD *)(ey + 8LL * x) + 8LL * y) + 8LL * z);
v7 = *(_QWORD *)(*(_QWORD *)(hx + 8LL * x) + 8LL * y);
*v6 = (*(double *)(v7 + 8LL * z) - *(double *)(v7 + 8LL * z - 8))
* *(double *)(*(_QWORD *)(*(_QWORD *)(cb_z + 8LL * x) + 8LL * y) + 8LL * z)
+ *v6;
}
}
if ( x )
{
v8 = (double *)(*(_QWORD *)(*(_QWORD *)(ey + 8LL * x) + 8LL * y) + 8LL * z);
*v8 = *v8
- (*(double *)(*(_QWORD *)(*(_QWORD *)(hz + 8LL * x) + 8LL * y) + 8LL * z)
- *(double *)(*(_QWORD *)(*(_QWORD *)(hz + 8LL * x - 8) + 8LL * y) + 8LL * z))
* *(double *)(*(_QWORD *)(*(_QWORD *)(cb_x + 8LL * x) + 8LL * y) + 8LL * z);
if ( x )
{
v9 = (double *)(*(_QWORD *)(*(_QWORD *)(ez + 8LL * x) + 8LL * y) + 8LL * z);
*v9 = (*(double *)(*(_QWORD *)(*(_QWORD *)(hy + 8LL * x) + 8LL * y) + 8LL * z)
- *(double *)(*(_QWORD *)(*(_QWORD *)(hy + 8LL * x - 8) + 8LL * y) + 8LL * z))
* *(double *)(*(_QWORD *)(*(_QWORD *)(cb_x + 8LL * x) + 8LL * y) + 8LL * z)
+ *v9;
}
}
if ( y )
{
v10 = (double *)(*(_QWORD *)(*(_QWORD *)(ez + 8LL * x) + 8LL * y) + 8LL * z);
*v10 = *v10
- (*(double *)(*(_QWORD *)(*(_QWORD *)(hx + 8LL * x) + 8LL * y) + 8LL * z)
- *(double *)(*(_QWORD *)(*(_QWORD *)(hx + 8LL * x) + 8LL * y - 8) + 8LL * z))
* *(double *)(*(_QWORD *)(*(_QWORD *)(cb_y + 8LL * x) + 8LL * y) + 8LL * z);
}
break;
case 1:
v12 = (double *)(*(_QWORD *)(*(_QWORD *)(ex + 8LL * x) + 8LL * y) + 8LL * z);
*v12 = *(double *)(*(_QWORD *)(*(_QWORD *)(ca + 8LL * x) + 8LL * y) + 8LL * z) * *v12
- *(double *)(*(_QWORD *)(*(_QWORD *)(dipole_ex + 8LL * x) + 8LL * y) + 8LL * z)
* d_t
/ *(double *)(*(_QWORD *)(*(_QWORD *)(epsilon + 8LL * x) + 8LL * y) + 8LL * z);
if ( y )
{
v13 = (double *)(*(_QWORD *)(*(_QWORD *)(ex + 8LL * x) + 8LL * y) + 8LL * z);
*v13 = (*(double *)(*(_QWORD *)(*(_QWORD *)(hz + 8LL * x) + 8LL * y) + 8LL * z)
- *(double *)(*(_QWORD *)(*(_QWORD *)(hz + 8LL * x) + 8LL * y - 8) + 8LL * z))
* *(double *)(*(_QWORD *)(*(_QWORD *)(cb_y + 8LL * x) + 8LL * y) + 8LL * z)
+ *v13;
}
if ( z )
{
v14 = (double *)(*(_QWORD *)(*(_QWORD *)(ex + 8LL * x) + 8LL * y) + 8LL * z);
v15 = *(_QWORD *)(*(_QWORD *)(hy + 8LL * x) + 8LL * y);
*v14 = (*(double *)(v15 + 8LL * z) - *(double *)(v15 + 8LL * z - 8))
* *(double *)(*(_QWORD *)(*(_QWORD *)(cb_z + 8LL * x) + 8LL * y) + 8LL * z)
+ *v14;
}
break;
case 2:
v16 = (double *)(*(_QWORD *)(*(_QWORD *)(ey + 8LL * x) + 8LL * y) + 8LL * z);
*v16 = *(double *)(*(_QWORD *)(*(_QWORD *)(ca + 8LL * x) + 8LL * y) + 8LL * z) * *v16
- *(double *)(*(_QWORD *)(*(_QWORD *)(dipole_ey + 8LL * x) + 8LL * y) + 8LL * z)
* d_t
/ *(double *)(*(_QWORD *)(*(_QWORD *)(epsilon + 8LL * x) + 8LL * y) + 8LL * z);
if ( z )
{
v17 = (double *)(*(_QWORD *)(*(_QWORD *)(ey + 8LL * x) + 8LL * y) + 8LL * z);
v18 = *(_QWORD *)(*(_QWORD *)(hx + 8LL * x) + 8LL * y);
*v17 = (*(double *)(v18 + 8LL * z) - *(double *)(v18 + 8LL * z - 8))
* *(double *)(*(_QWORD *)(*(_QWORD *)(cb_z + 8LL * x) + 8LL * y) + 8LL * z)
+ *v17;
}
if ( x )
{
v19 = (double *)(*(_QWORD *)(*(_QWORD *)(ey + 8LL * x) + 8LL * y) + 8LL * z);
*v19 = *v19
- (*(double *)(*(_QWORD *)(*(_QWORD *)(hz + 8LL * x) + 8LL * y) + 8LL * z)
- *(double *)(*(_QWORD *)(*(_QWORD *)(hz + 8LL * x - 8) + 8LL * y) + 8LL * z))
* *(double *)(*(_QWORD *)(*(_QWORD *)(cb_x + 8LL * x) + 8LL * y) + 8LL * z);
}
break;
case 3:
v20 = (double *)(*(_QWORD *)(*(_QWORD *)(ez + 8LL * x) + 8LL * y) + 8LL * z);
*v20 = *(double *)(*(_QWORD *)(*(_QWORD *)(ca + 8LL * x) + 8LL * y) + 8LL * z) * *v20
- *(double *)(*(_QWORD *)(*(_QWORD *)(dipole_ez + 8LL * x) + 8LL * y) + 8LL * z)
* d_t
/ *(double *)(*(_QWORD *)(*(_QWORD *)(epsilon + 8LL * x) + 8LL * y) + 8LL * z);
if ( x )
{
v21 = (double *)(*(_QWORD *)(*(_QWORD *)(ez + 8LL * x) + 8LL * y) + 8LL * z);
*v21 = (*(double *)(*(_QWORD *)(*(_QWORD *)(hy + 8LL * x) + 8LL * y) + 8LL * z)
- *(double *)(*(_QWORD *)(*(_QWORD *)(hy + 8LL * x - 8) + 8LL * y) + 8LL * z))
* *(double *)(*(_QWORD *)(*(_QWORD *)(cb_x + 8LL * x) + 8LL * y) + 8LL * z)
+ *v21;
}
if ( y )
{
v22 = (double *)(*(_QWORD *)(*(_QWORD *)(ez + 8LL * x) + 8LL * y) + 8LL * z);
*v22 = *v22
- (*(double *)(*(_QWORD *)(*(_QWORD *)(hx + 8LL * x) + 8LL * y) + 8LL * z)
- *(double *)(*(_QWORD *)(*(_QWORD *)(hx + 8LL * x) + 8LL * y - 8) + 8LL * z))
* *(double *)(*(_QWORD *)(*(_QWORD *)(cb_y + 8LL * x) + 8LL * y) + 8LL * z);
}
break;
case 4:
v23 = (double *)(*(_QWORD *)(*(_QWORD *)(ey + 8LL * x) + 8LL * y) + 8LL * z);
*v23 = *(double *)(*(_QWORD *)(*(_QWORD *)(ca + 8LL * x) + 8LL * y) + 8LL * z) * *v23
- *(double *)(*(_QWORD *)(*(_QWORD *)(dipole_ey + 8LL * x) + 8LL * y) + 8LL * z)
* d_t
/ *(double *)(*(_QWORD *)(*(_QWORD *)(epsilon + 8LL * x) + 8LL * y) + 8LL * z);
v24 = (double *)(*(_QWORD *)(*(_QWORD *)(ez + 8LL * x) + 8LL * y) + 8LL * z);
*v24 = *(double *)(*(_QWORD *)(*(_QWORD *)(ca + 8LL * x) + 8LL * y) + 8LL * z) * *v24
- *(double *)(*(_QWORD *)(*(_QWORD *)(dipole_ez + 8LL * x) + 8LL * y) + 8LL * z)
* d_t
/ *(double *)(*(_QWORD *)(*(_QWORD *)(epsilon + 8LL * x) + 8LL * y) + 8LL * z);
if ( z )
{
v25 = (double *)(*(_QWORD *)(*(_QWORD *)(ey + 8LL * x) + 8LL * y) + 8LL * z);
v26 = *(_QWORD *)(*(_QWORD *)(hx + 8LL * x) + 8LL * y);
*v25 = (*(double *)(v26 + 8LL * z) - *(double *)(v26 + 8LL * z - 8))
* *(double *)(*(_QWORD *)(*(_QWORD *)(cb_z + 8LL * x) + 8LL * y) + 8LL * z)
+ *v25;
}
if ( y )
{
v27 = (double *)(*(_QWORD *)(*(_QWORD *)(ez + 8LL * x) + 8LL * y) + 8LL * z);
*v27 = *v27
- (*(double *)(*(_QWORD *)(*(_QWORD *)(hx + 8LL * x) + 8LL * y) + 8LL * z)
- *(double *)(*(_QWORD *)(*(_QWORD *)(hx + 8LL * x) + 8LL * y - 8) + 8LL * z))
* *(double *)(*(_QWORD *)(*(_QWORD *)(cb_y + 8LL * x) + 8LL * y) + 8LL * z);
}
break;
case 5:
v28 = (double *)(*(_QWORD *)(*(_QWORD *)(ex + 8LL * x) + 8LL * y) + 8LL * z);
*v28 = *(double *)(*(_QWORD *)(*(_QWORD *)(ca + 8LL * x) + 8LL * y) + 8LL * z) * *v28
- *(double *)(*(_QWORD *)(*(_QWORD *)(dipole_ex + 8LL * x) + 8LL * y) + 8LL * z)
* d_t
/ *(double *)(*(_QWORD *)(*(_QWORD *)(epsilon + 8LL * x) + 8LL * y) + 8LL * z);
v29 = (double *)(*(_QWORD *)(*(_QWORD *)(ez + 8LL * x) + 8LL * y) + 8LL * z);
*v29 = *(double *)(*(_QWORD *)(*(_QWORD *)(ca + 8LL * x) + 8LL * y) + 8LL * z) * *v29
- *(double *)(*(_QWORD *)(*(_QWORD *)(dipole_ez + 8LL * x) + 8LL * y) + 8LL * z)
* d_t
/ *(double *)(*(_QWORD *)(*(_QWORD *)(epsilon + 8LL * x) + 8LL * y) + 8LL * z);
if ( z )
{
v30 = (double *)(*(_QWORD *)(*(_QWORD *)(ex + 8LL * x) + 8LL * y) + 8LL * z);
v31 = *(_QWORD *)(*(_QWORD *)(hy + 8LL * x) + 8LL * y);
*v30 = *v30
- (*(double *)(v31 + 8LL * z) - *(double *)(v31 + 8LL * z - 8))
* *(double *)(*(_QWORD *)(*(_QWORD *)(cb_z + 8LL * x) + 8LL * y) + 8LL * z);
}
if ( x )
{
v32 = (double *)(*(_QWORD *)(*(_QWORD *)(ez + 8LL * x) + 8LL * y) + 8LL * z);
*v32 = (*(double *)(*(_QWORD *)(*(_QWORD *)(hy + 8LL * x) + 8LL * y) + 8LL * z)
- *(double *)(*(_QWORD *)(*(_QWORD *)(hy + 8LL * x - 8) + 8LL * y) + 8LL * z))
* *(double *)(*(_QWORD *)(*(_QWORD *)(cb_x + 8LL * x) + 8LL * y) + 8LL * z)
+ *v32;
}
break;
case 6:
v33 = (double *)(*(_QWORD *)(*(_QWORD *)(ex + 8LL * x) + 8LL * y) + 8LL * z);
*v33 = *(double *)(*(_QWORD *)(*(_QWORD *)(ca + 8LL * x) + 8LL * y) + 8LL * z) * *v33
- *(double *)(*(_QWORD *)(*(_QWORD *)(dipole_ex + 8LL * x) + 8LL * y) + 8LL * z)
* d_t
/ *(double *)(*(_QWORD *)(*(_QWORD *)(epsilon + 8LL * x) + 8LL * y) + 8LL * z);
v34 = (double *)(*(_QWORD *)(*(_QWORD *)(ey + 8LL * x) + 8LL * y) + 8LL * z);
*v34 = *(double *)(*(_QWORD *)(*(_QWORD *)(ca + 8LL * x) + 8LL * y) + 8LL * z) * *v34
- *(double *)(*(_QWORD *)(*(_QWORD *)(dipole_ey + 8LL * x) + 8LL * y) + 8LL * z)
* d_t
/ *(double *)(*(_QWORD *)(*(_QWORD *)(epsilon + 8LL * x) + 8LL * y) + 8LL * z);
if ( y )
{
v35 = (double *)(*(_QWORD *)(*(_QWORD *)(ex + 8LL * x) + 8LL * y) + 8LL * z);
*v35 = (*(double *)(*(_QWORD *)(*(_QWORD *)(hz + 8LL * x) + 8LL * y) + 8LL * z)
- *(double *)(*(_QWORD *)(*(_QWORD *)(hz + 8LL * x) + 8LL * y - 8) + 8LL * z))
* *(double *)(*(_QWORD *)(*(_QWORD *)(cb_y + 8LL * x) + 8LL * y) + 8LL * z)
+ *v35;
}
if ( x )
{
v36 = (double *)(*(_QWORD *)(*(_QWORD *)(ey + 8LL * x) + 8LL * y) + 8LL * z);
*v36 = *v36
- (*(double *)(*(_QWORD *)(*(_QWORD *)(hz + 8LL * x) + 8LL * y) + 8LL * z)
- *(double *)(*(_QWORD *)(*(_QWORD *)(hz + 8LL * x - 8) + 8LL * y) + 8LL * z))
* *(double *)(*(_QWORD *)(*(_QWORD *)(cb_x + 8LL * x) + 8LL * y) + 8LL * z);
}
break;
default:
break;
}
}
v11 = (unsigned int)(x + 1);
x = v11;
}
while ( (unsigned int)v11 < total_x );
}
}
}
}


repo: emguy/ezfdtd

decompiled_code:
__int64 __fastcall setup_input_ports(__int64 a1)
{
unsigned int v1; // er14
unsigned __int64 v3; // r13
unsigned int v4; // ebp
__int64 v5; // rax
__int64 i; // rax
_DWORD *v7; // rdx
__int64 v8; // rdx
int v9; // ecx
__int64 v10; // rdx
__int64 v11; // rax
__int64 v12; // rax
char v13[88]; // [rsp+0h] [rbp-58h] BYREF

if ( (unsigned int)h5_get_attr(a1, "excitations", "number_of_ports", &total_input_ports) )
{
v1 = 1;
if ( total_input_ports )
{
v1 = h5_get_attr(a1, "settings", "starting_index", &starting_index);
if ( v1 )
{
if ( total_input_ports <= 0 )
{
v1 = 1;
}
else
{
v3 = (unsigned int)((_DWORD)&input_ports + 40);
v4 = 1;
do
{
sprintf(v13, "port_%02d_number_of_points", v4);
v1 = h5_get_attr(a1, "excitations", v13, v3);
if ( !v1 )
{
notice("excitation.c", 55LL, "setup_input_ports", "fail to get h5 attributes");
return v1;
}
sprintf(v13, "port_%02d_polarization", v4);
v1 = h5_get_attr(a1, "excitations", v13, v3 + 16);
if ( !v1 )
{
notice("excitation.c", 58LL, "setup_input_ports", "fail to get h5 attributes");
return v1;
}
if ( mode && mode != *(_DWORD *)(v3 + 16) )
{
notice(
"excitation.c",
59LL,
"setup_input_ports",
"polarization does not match with current simulation mode");
return 0;
}
sprintf(v13, "/excitations/port_%02d_points", v4);
v5 = h5_load2(a1, v13, *(int *)v3, 3LL);
*(_QWORD *)(v3 + 8) = v5;
if ( !v5 )
{
notice("excitation.c", 63LL, "setup_input_ports", "fail to load hdf5 dataset");
return 0;
}
for ( i = 0LL; *(_DWORD *)v3 > (int)i; ++i )
{
v7 = *(_DWORD **)(*(_QWORD *)(v3 + 8) + 8 * i);
*v7 -= starting_index;
v8 = *(_QWORD *)(*(_QWORD *)(v3 + 8) + 8 * i);
v9 = starting_index;
*(_DWORD *)(v8 + 4) -= starting_index;
v10 = *(_QWORD *)(*(_QWORD *)(v3 + 8) + 8 * i);
*(_DWORD *)(v10 + 8) -= v9;
}
sprintf(v13, "/excitations/port_%02d_signal", v4);
v11 = h5_load1(a1, v13, total_timesteps);
*(_QWORD *)(v3 + 32) = v11;
if ( !v11 )
{
notice("excitation.c", 74LL, "setup_input_ports", "fail to load hdf5 dataset");
return 0;
}
sprintf(v13, "/excitations/port_%02d_distribution", v4);
v12 = h5_load1(a1, v13, *(int *)v3);
*(_QWORD *)(v3 + 24) = v12;
if ( !v12 )
{
notice("excitation.c", 77LL, "setup_input_ports", "fail to load hdf5 dataset");
return 0;
}
++v4;
v3 += 40LL;
}
while ( total_input_ports >= (int)v4 );
v1 = 1;
}
}
else
{
notice("excitation.c", 49LL, "setup_input_ports", "fail to get h5 attributes");
}
}
}
else
{
v1 = 0;
notice("excitation.c", 46LL, "setup_input_ports", "fail to get h5 attributes");
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
unsigned int v1; // er14
unsigned __int64 v3; // r13
unsigned int v4; // ebp
__int64 v5; // rax
__int64 i; // rax
_DWORD *v7; // rdx
__int64 v8; // rdx
int v9; // ecx
__int64 v10; // rdx
__int64 v11; // rax
__int64 v12; // rax
char v13[88]; // [rsp+0h] [rbp-58h] BYREF

if ( (unsigned int)h5_get_attr(a1, "excitations", "number_of_ports", &total_input_ports) )
{
v1 = 1;
if ( total_input_ports )
{
v1 = h5_get_attr(a1, "settings", "starting_index", &starting_index);
if ( v1 )
{
if ( total_input_ports <= 0 )
{
v1 = 1;
}
else
{
v3 = (unsigned int)((_DWORD)&input_ports + 40);
v4 = 1;
do
{
sprintf(v13, "port_%02d_number_of_points", v4);
v1 = h5_get_attr(a1, "excitations", v13, v3);
if ( !v1 )
{
notice("excitation.c", 55LL, "setup_input_ports", "fail to get h5 attributes");
return v1;
}
sprintf(v13, "port_%02d_polarization", v4);
v1 = h5_get_attr(a1, "excitations", v13, v3 + 16);
if ( !v1 )
{
notice("excitation.c", 58LL, "setup_input_ports", "fail to get h5 attributes");
return v1;
}
if ( mode && mode != *(_DWORD *)(v3 + 16) )
{
notice(
"excitation.c",
59LL,
"setup_input_ports",
"polarization does not match with current simulation mode");
return 0;
}
sprintf(v13, "/excitations/port_%02d_points", v4);
v5 = h5_load2(a1, v13, *(int *)v3, 3LL);
*(_QWORD *)(v3 + 8) = v5;
if ( !v5 )
{
notice("excitation.c", 63LL, "setup_input_ports", "fail to load hdf5 dataset");
return 0;
}
for ( i = 0LL; *(_DWORD *)v3 > (int)i; ++i )
{
v7 = *(_DWORD **)(*(_QWORD *)(v3 + 8) + 8 * i);
*v7 -= starting_index;
v8 = *(_QWORD *)(*(_QWORD *)(v3 + 8) + 8 * i);
v9 = starting_index;
*(_DWORD *)(v8 + 4) -= starting_index;
v10 = *(_QWORD *)(*(_QWORD *)(v3 + 8) + 8 * i);
*(_DWORD *)(v10 + 8) -= v9;
}
sprintf(v13, "/excitations/port_%02d_signal", v4);
v11 = h5_load1(a1, v13, total_timesteps);
*(_QWORD *)(v3 + 32) = v11;
if ( !v11 )
{
notice("excitation.c", 74LL, "setup_input_ports", "fail to load hdf5 dataset");
return 0;
}
sprintf(v13, "/excitations/port_%02d_distribution", v4);
v12 = h5_load1(a1, v13, *(int *)v3);
*(_QWORD *)(v3 + 24) = v12;
if ( !v12 )
{
notice("excitation.c", 77LL, "setup_input_ports", "fail to load hdf5 dataset");
return 0;
}
++v4;
v3 += 40LL;
}
while ( total_input_ports >= (int)v4 );
v1 = 1;
}
}
else
{
notice("excitation.c", 49LL, "setup_input_ports", "fail to get h5 attributes");
}
}
}
else
{
v1 = 0;
notice("excitation.c", 46LL, "setup_input_ports", "fail to get h5 attributes");
}
return v1;
}

original_code:
int setup_input_ports(char* file_name)
{
    int port_index;
    char attr_name[45];
    int status;
    int point_index;
    status = h5_get_attr(file_name, "excitations", "number_of_ports", &total_input_ports);
    if (!(status)) {notice("excitation.c",46,__func__,"fail to get h5 attributes"); return(0);};
    if (total_input_ports == 0) return 1;
    status = h5_get_attr(file_name, "settings", "starting_index", &starting_index);
    if (!(status)) {notice("excitation.c",49,__func__,"fail to get h5 attributes"); return(0);};
    for (port_index = 1; port_index <= total_input_ports; port_index++)
    {
        sprintf(attr_name, "port_%02d_number_of_points", port_index);
        status = h5_get_attr(file_name, "excitations", attr_name, &(input_ports[port_index].total_points));
        if (!(status)) {notice("excitation.c",55,__func__,"fail to get h5 attributes"); return(0);};
        sprintf(attr_name, "port_%02d_polarization", port_index);
        status = h5_get_attr(file_name, "excitations", attr_name, &(input_ports[port_index].polarization));
        if (!(status)) {notice("excitation.c",58,__func__,"fail to get h5 attributes"); return(0);};
        if (!(mode == 0 || input_ports[port_index].polarization == mode)) {notice("excitation.c",59,__func__,"polarization does not match with current simulation mode"); return(0);};
        sprintf(attr_name, "/excitations/port_%02d_points", port_index);
        input_ports[port_index].source_points = (int **)h5_load2(file_name, attr_name, input_ports[port_index].total_points, 3);
        if (!(input_ports[port_index].source_points)) {notice("excitation.c",63,__func__,"fail to load hdf5 dataset"); return(0);};
        for (point_index = 0; point_index < input_ports[port_index].total_points; point_index ++)
        {
            input_ports[port_index].source_points[point_index][0] = input_ports[port_index].source_points[point_index][0] - starting_index;
            input_ports[port_index].source_points[point_index][1] = input_ports[port_index].source_points[point_index][1] - starting_index;
            input_ports[port_index].source_points[point_index][2] = input_ports[port_index].source_points[point_index][2] - starting_index;
        }
        sprintf(attr_name, "/excitations/port_%02d_signal", port_index);
        input_ports[port_index].source_signal = (double *)h5_load1(file_name, attr_name, total_timesteps);
        if (!(input_ports[port_index].source_signal)) {notice("excitation.c",74,__func__,"fail to load hdf5 dataset"); return(0);};
        sprintf(attr_name, "/excitations/port_%02d_distribution", port_index);
        input_ports[port_index].source_distribution = (double *)h5_load1(file_name, attr_name, input_ports[port_index].total_points);
        if (!(input_ports[port_index].source_distribution)) {notice("excitation.c",77,__func__,"fail to load hdf5 dataset"); return(0);};
    }
    return 1;
}

canonical_original_code:
int setup_input_ports(char *file_name)
{
    int port_index;
    char attr_name[45];
    int status;
    int point_index;
    status = h5_get_attr(file_name, "excitations", "number_of_ports", &total_input_ports);
    if (!(status)) {notice("excitation.c",46,__func__,"fail to get h5 attributes"); return(0);};
    if (total_input_ports == 0) return 1;
    status = h5_get_attr(file_name, "settings", "starting_index", &starting_index);
    if (!(status)) {notice("excitation.c",49,__func__,"fail to get h5 attributes"); return(0);};
    for (port_index = 1; port_index <= total_input_ports; port_index++)
    {
        sprintf(attr_name, "port_%02d_number_of_points", port_index);
        status = h5_get_attr(file_name, "excitations", attr_name, &(input_ports[port_index].total_points));
        if (!(status)) {notice("excitation.c",55,__func__,"fail to get h5 attributes"); return(0);};
        sprintf(attr_name, "port_%02d_polarization", port_index);
        status = h5_get_attr(file_name, "excitations", attr_name, &(input_ports[port_index].polarization));
        if (!(status)) {notice("excitation.c",58,__func__,"fail to get h5 attributes"); return(0);};
        if (!(mode == 0 || input_ports[port_index].polarization == mode)) {notice("excitation.c",59,__func__,"polarization does not match with current simulation mode"); return(0);};
        sprintf(attr_name, "/excitations/port_%02d_points", port_index);
        input_ports[port_index].source_points = (int **)h5_load2(file_name, attr_name, input_ports[port_index].total_points, 3);
        if (!(input_ports[port_index].source_points)) {notice("excitation.c",63,__func__,"fail to load hdf5 dataset"); return(0);};
        for (point_index = 0; point_index < input_ports[port_index].total_points; point_index ++)
        {
            input_ports[port_index].source_points[point_index][0] = input_ports[port_index].source_points[point_index][0] - starting_index;
            input_ports[port_index].source_points[point_index][1] = input_ports[port_index].source_points[point_index][1] - starting_index;
            input_ports[port_index].source_points[point_index][2] = input_ports[port_index].source_points[point_index][2] - starting_index;
        }
        sprintf(attr_name, "/excitations/port_%02d_signal", port_index);
        input_ports[port_index].source_signal = (double *)h5_load1(file_name, attr_name, total_timesteps);
        if (!(input_ports[port_index].source_signal)) {notice("excitation.c",74,__func__,"fail to load hdf5 dataset"); return(0);};
        sprintf(attr_name, "/excitations/port_%02d_distribution", port_index);
        input_ports[port_index].source_distribution = (double *)h5_load1(file_name, attr_name, input_ports[port_index].total_points);
        if (!(input_ports[port_index].source_distribution)) {notice("excitation.c",77,__func__,"fail to load hdf5 dataset"); return(0);};
    }
    return 1;
}

variable_types: status int

return_type: int


decompiled_code:
__int64 __fastcall setup_point_sources(__int64 a1)
{
unsigned int v1; // ebx
int v3; // edx
__int64 i; // rax
int v5; // ecx

if ( (unsigned int)h5_get_attr(a1, "excitations", "number_of_point_sources", &total_point_sources) )
{
v1 = 1;
if ( total_point_sources )
{
v1 = h5_get_attr(a1, "settings", "starting_index", &starting_index);
if ( v1 )
{
source_points = h5_load2(a1, "/excitations/source_points", total_point_sources, 3LL);
if ( source_points )
{
v3 = total_point_sources;
for ( i = 0LL; total_point_sources > (int)i; ++i )
{
**(_DWORD **)(source_points + 8 * i) -= starting_index;
v5 = starting_index;
*(_DWORD *)(*(_QWORD *)(source_points + 8 * i) + 4LL) -= starting_index;
*(_DWORD *)(*(_QWORD *)(source_points + 8 * i) + 8LL) -= v5;
v3 = total_point_sources;
}
source_polarizations = h5_load1(a1, "/excitations/source_polarizations", v3);
if ( source_polarizations )
{
source_signals = h5_load2(a1, "/excitations/source_signals", total_timesteps, total_point_sources);
v1 = 1;
if ( !source_signals )
{
notice("excitation.c", 106LL, "setup_point_sources", "fail to load hdf5 dataset");
v1 = 0;
}
}
else
{
notice("excitation.c", 104LL, "setup_point_sources", "fail to load hdf5 dataset");
v1 = 0;
}
}
else
{
notice("excitation.c", 95LL, "setup_point_sources", "fail to load hdf5 dataset");
v1 = 0;
}
}
else
{
notice("excitation.c", 92LL, "setup_point_sources", "fail to get h5 attributes");
}
}
}
else
{
v1 = 0;
notice("excitation.c", 88LL, "setup_point_sources", "fail to load hdf5 dataset");
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
unsigned int v1; // ebx
int v3; // edx
__int64 i; // rax
int v5; // ecx

if ( (unsigned int)h5_get_attr(a1, "excitations", "number_of_point_sources", &total_point_sources) )
{
v1 = 1;
if ( total_point_sources )
{
v1 = h5_get_attr(a1, "settings", "starting_index", &starting_index);
if ( v1 )
{
source_points = h5_load2(a1, "/excitations/source_points", total_point_sources, 3LL);
if ( source_points )
{
v3 = total_point_sources;
for ( i = 0LL; total_point_sources > (int)i; ++i )
{
**(_DWORD **)(source_points + 8 * i) -= starting_index;
v5 = starting_index;
*(_DWORD *)(*(_QWORD *)(source_points + 8 * i) + 4LL) -= starting_index;
*(_DWORD *)(*(_QWORD *)(source_points + 8 * i) + 8LL) -= v5;
v3 = total_point_sources;
}
source_polarizations = h5_load1(a1, "/excitations/source_polarizations", v3);
if ( source_polarizations )
{
source_signals = h5_load2(a1, "/excitations/source_signals", total_timesteps, total_point_sources);
v1 = 1;
if ( !source_signals )
{
notice("excitation.c", 106LL, "setup_point_sources", "fail to load hdf5 dataset");
v1 = 0;
}
}
else
{
notice("excitation.c", 104LL, "setup_point_sources", "fail to load hdf5 dataset");
v1 = 0;
}
}
else
{
notice("excitation.c", 95LL, "setup_point_sources", "fail to load hdf5 dataset");
v1 = 0;
}
}
else
{
notice("excitation.c", 92LL, "setup_point_sources", "fail to get h5 attributes");
}
}
}
else
{
v1 = 0;
notice("excitation.c", 88LL, "setup_point_sources", "fail to load hdf5 dataset");
}
return v1;
}

original_code:
int setup_point_sources(char* file_name)
{
    int status;
    int point_index;
    status = h5_get_attr(file_name, "excitations", "number_of_point_sources", &total_point_sources);
    if (!(status)) {notice("excitation.c",88,__func__,"fail to load hdf5 dataset"); return(0);};
    if (total_point_sources == 0) return 1;
    status = h5_get_attr(file_name, "settings", "starting_index", &starting_index);
    if (!(status)) {notice("excitation.c",92,__func__,"fail to get h5 attributes"); return(0);};
    source_points = (int **)h5_load2(file_name, "/excitations/source_points", total_point_sources, 3);
    if (!(source_points)) {notice("excitation.c",95,__func__,"fail to load hdf5 dataset"); return(0);};
    for (point_index = 0; point_index < total_point_sources; point_index ++)
    {
        source_points[point_index][0] = source_points[point_index][0] - starting_index;
        source_points[point_index][1] = source_points[point_index][1] - starting_index;
        source_points[point_index][2] = source_points[point_index][2] - starting_index;
    }
    source_polarizations = (int *)h5_load1(file_name, "/excitations/source_polarizations", total_point_sources);
    if (!(source_polarizations)) {notice("excitation.c",104,__func__,"fail to load hdf5 dataset"); return(0);};
    source_signals = (double **)h5_load2(file_name, "/excitations/source_signals", total_timesteps, total_point_sources);
    if (!(source_signals)) {notice("excitation.c",106,__func__,"fail to load hdf5 dataset"); return(0);};
    return 1;
}

canonical_original_code:
int setup_point_sources(char *file_name)
{
    int status;
    int point_index;
    status = h5_get_attr(file_name, "excitations", "number_of_point_sources", &total_point_sources);
    if (!(status)) {notice("excitation.c",88,__func__,"fail to load hdf5 dataset"); return(0);};
    if (total_point_sources == 0) return 1;
    status = h5_get_attr(file_name, "settings", "starting_index", &starting_index);
    if (!(status)) {notice("excitation.c",92,__func__,"fail to get h5 attributes"); return(0);};
    source_points = (int **)h5_load2(file_name, "/excitations/source_points", total_point_sources, 3);
    if (!(source_points)) {notice("excitation.c",95,__func__,"fail to load hdf5 dataset"); return(0);};
    for (point_index = 0; point_index < total_point_sources; point_index ++)
    {
        source_points[point_index][0] = source_points[point_index][0] - starting_index;
        source_points[point_index][1] = source_points[point_index][1] - starting_index;
        source_points[point_index][2] = source_points[point_index][2] - starting_index;
    }
    source_polarizations = (int *)h5_load1(file_name, "/excitations/source_polarizations", total_point_sources);
    if (!(source_polarizations)) {notice("excitation.c",104,__func__,"fail to load hdf5 dataset"); return(0);};
    source_signals = (double **)h5_load2(file_name, "/excitations/source_signals", total_timesteps, total_point_sources);
    if (!(source_signals)) {notice("excitation.c",106,__func__,"fail to load hdf5 dataset"); return(0);};
    return 1;
}


decompiled_code:
__int64 __fastcall setup_hards(__int64 a1)
{
unsigned int v1; // ebx
int v3; // edx
__int64 i; // rax
int v5; // ecx

if ( (unsigned int)h5_get_attr(a1, "excitations", "number_of_hards", &total_hards) )
{
v1 = 1;
if ( total_hards )
{
v1 = h5_get_attr(a1, "settings", "starting_index", &starting_index);
if ( v1 )
{
hard_points = h5_load2(a1, "/excitations/hard_points", total_hards, 3LL);
if ( hard_points )
{
v3 = total_hards;
for ( i = 0LL; total_hards > (int)i; ++i )
{
**(_DWORD **)(hard_points + 8 * i) -= starting_index;
v5 = starting_index;
*(_DWORD *)(*(_QWORD *)(hard_points + 8 * i) + 4LL) -= starting_index;
*(_DWORD *)(*(_QWORD *)(hard_points + 8 * i) + 8LL) -= v5;
v3 = total_hards;
}
hard_polarizations = h5_load1(a1, "/excitations/hard_polarizations", v3);
if ( hard_polarizations )
{
hard_signals = h5_load2(a1, "/excitations/hard_signals", total_timesteps, total_hards);
v1 = 1;
if ( !hard_signals )
{
notice("excitation.c", 133LL, "setup_hards", "fail to load hdf5 dataset");
v1 = 0;
}
}
else
{
notice("excitation.c", 131LL, "setup_hards", "fail to load hdf5 dataset");
v1 = 0;
}
}
else
{
notice("excitation.c", 123LL, "setup_hards", "fail to load hdf5 dataset");
v1 = 0;
}
}
else
{
notice("excitation.c", 120LL, "setup_hards", "fail to get h5 attributes");
}
}
}
else
{
v1 = 0;
notice("excitation.c", 117LL, "setup_hards", "fail to load hdf5 dataset");
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
unsigned int v1; // ebx
int v3; // edx
__int64 i; // rax
int v5; // ecx

if ( (unsigned int)h5_get_attr(a1, "excitations", "number_of_hards", &total_hards) )
{
v1 = 1;
if ( total_hards )
{
v1 = h5_get_attr(a1, "settings", "starting_index", &starting_index);
if ( v1 )
{
hard_points = h5_load2(a1, "/excitations/hard_points", total_hards, 3LL);
if ( hard_points )
{
v3 = total_hards;
for ( i = 0LL; total_hards > (int)i; ++i )
{
**(_DWORD **)(hard_points + 8 * i) -= starting_index;
v5 = starting_index;
*(_DWORD *)(*(_QWORD *)(hard_points + 8 * i) + 4LL) -= starting_index;
*(_DWORD *)(*(_QWORD *)(hard_points + 8 * i) + 8LL) -= v5;
v3 = total_hards;
}
hard_polarizations = h5_load1(a1, "/excitations/hard_polarizations", v3);
if ( hard_polarizations )
{
hard_signals = h5_load2(a1, "/excitations/hard_signals", total_timesteps, total_hards);
v1 = 1;
if ( !hard_signals )
{
notice("excitation.c", 133LL, "setup_hards", "fail to load hdf5 dataset");
v1 = 0;
}
}
else
{
notice("excitation.c", 131LL, "setup_hards", "fail to load hdf5 dataset");
v1 = 0;
}
}
else
{
notice("excitation.c", 123LL, "setup_hards", "fail to load hdf5 dataset");
v1 = 0;
}
}
else
{
notice("excitation.c", 120LL, "setup_hards", "fail to get h5 attributes");
}
}
}
else
{
v1 = 0;
notice("excitation.c", 117LL, "setup_hards", "fail to load hdf5 dataset");
}
return v1;
}

original_code:
int setup_hards(char* file_name)
{
    int status;
    int point_index;
    status = h5_get_attr(file_name, "excitations", "number_of_hards", &total_hards);
    if (!(status)) {notice("excitation.c",117,__func__,"fail to load hdf5 dataset"); return(0);};
    if (total_hards == 0) return 1;
    status = h5_get_attr(file_name, "settings", "starting_index", &starting_index);
    if (!(status)) {notice("excitation.c",120,__func__,"fail to get h5 attributes"); return(0);};
    hard_points = (int **)h5_load2(file_name, "/excitations/hard_points", total_hards, 3);
    if (!(hard_points)) {notice("excitation.c",123,__func__,"fail to load hdf5 dataset"); return(0);};
    for (point_index = 0; point_index < total_hards; point_index ++)
    {
        hard_points[point_index][0] = hard_points[point_index][0] - starting_index;
        hard_points[point_index][1] = hard_points[point_index][1] - starting_index;
        hard_points[point_index][2] = hard_points[point_index][2] - starting_index;
    }
    hard_polarizations = (int *)h5_load1(file_name, "/excitations/hard_polarizations", total_hards);
    if (!(hard_polarizations)) {notice("excitation.c",131,__func__,"fail to load hdf5 dataset"); return(0);};
    hard_signals = (double **)h5_load2(file_name, "/excitations/hard_signals", total_timesteps, total_hards);
    if (!(hard_signals)) {notice("excitation.c",133,__func__,"fail to load hdf5 dataset"); return(0);};
    return 1;
}

canonical_original_code:
int setup_hards(char *file_name)
{
    int status;
    int point_index;
    status = h5_get_attr(file_name, "excitations", "number_of_hards", &total_hards);
    if (!(status)) {notice("excitation.c",117,__func__,"fail to load hdf5 dataset"); return(0);};
    if (total_hards == 0) return 1;
    status = h5_get_attr(file_name, "settings", "starting_index", &starting_index);
    if (!(status)) {notice("excitation.c",120,__func__,"fail to get h5 attributes"); return(0);};
    hard_points = (int **)h5_load2(file_name, "/excitations/hard_points", total_hards, 3);
    if (!(hard_points)) {notice("excitation.c",123,__func__,"fail to load hdf5 dataset"); return(0);};
    for (point_index = 0; point_index < total_hards; point_index ++)
    {
        hard_points[point_index][0] = hard_points[point_index][0] - starting_index;
        hard_points[point_index][1] = hard_points[point_index][1] - starting_index;
        hard_points[point_index][2] = hard_points[point_index][2] - starting_index;
    }
    hard_polarizations = (int *)h5_load1(file_name, "/excitations/hard_polarizations", total_hards);
    if (!(hard_polarizations)) {notice("excitation.c",131,__func__,"fail to load hdf5 dataset"); return(0);};
    hard_signals = (double **)h5_load2(file_name, "/excitations/hard_signals", total_timesteps, total_hards);
    if (!(hard_signals)) {notice("excitation.c",133,__func__,"fail to load hdf5 dataset"); return(0);};
    return 1;
}


excite

original_code:
int excite(int time_index)
{
    int source_index;
    int port_index;
    for (port_index = 1; port_index <= total_input_ports; port_index++)
    {
        for (source_index = 0; source_index < input_ports[port_index].total_points; source_index++)
        {
            x = input_ports[port_index].source_points[source_index][0];
            y = input_ports[port_index].source_points[source_index][1];
            z = input_ports[port_index].source_points[source_index][2];
            if (input_ports[port_index].polarization == p_ex)
                dipole_ex[x][y][z] = input_ports[port_index].source_signal[time_index]
                    * input_ports[port_index].source_distribution[source_index];
            else if (input_ports[port_index].polarization == p_ey)
                dipole_ey[x][y][z] = input_ports[port_index].source_signal[time_index]
                    * input_ports[port_index].source_distribution[source_index];
            else if (input_ports[port_index].polarization == p_ez)
                dipole_ez[x][y][z] = input_ports[port_index].source_signal[time_index]
                    * input_ports[port_index].source_distribution[source_index];
            else if (input_ports[port_index].polarization == p_hx)
                dipole_hx[x][y][z] = input_ports[port_index].source_signal[time_index]
                    * input_ports[port_index].source_distribution[source_index];
            else if (input_ports[port_index].polarization == p_hy)
                dipole_hy[x][y][z] = input_ports[port_index].source_signal[time_index]
                    * input_ports[port_index].source_distribution[source_index];
            else if (input_ports[port_index].polarization == p_hz)
                dipole_hz[x][y][z] = input_ports[port_index].source_signal[time_index]
                    * input_ports[port_index].source_distribution[source_index];
        }
    }
    for (source_index = 0; source_index < total_point_sources; source_index++)
    {
        x = source_points[source_index][0];
        y = source_points[source_index][1];
        z = source_points[source_index][2];
        switch (source_polarizations[source_index])
        {
            case (p_ex):
                dipole_ex[x][y][z] = source_signals[time_index][source_index];
                break;
            case (p_ey):
                dipole_ey[x][y][z] = source_signals[time_index][source_index];
                break;
            case (p_ez):
                dipole_ez[x][y][z] = source_signals[time_index][source_index];
                break;
            case (p_hx):
                dipole_hx[x][y][z] = source_signals[time_index][source_index];
                break;
            case (p_hy):
                dipole_hy[x][y][z] = source_signals[time_index][source_index];
                break;
            case (p_hz):
                dipole_hz[x][y][z] = source_signals[time_index][source_index];
                break;
        }
    }
    return 1;
}


decompiled_code:
__int64 __fastcall apply_ehards(int a1)
{
__int64 v1; // r9
__int64 v2; // rax
int **v3; // rdx
int v4; // esi
int v5; // ecx
int v6; // edx
int v7; // edi

if ( total_hards > 0 )
{
v1 = 8LL * a1;
v2 = 0LL;
do
{
v3 = (int **)(hard_points + 8 * v2);
v4 = **v3;
x = v4;
v5 = (*v3)[1];
y = v5;
v6 = (*v3)[2];
z = v6;
v7 = *(_DWORD *)(hard_polarizations + 4 * v2);
switch ( v7 )
{
case 1:
*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(ex + 8LL * v4) + 8LL * v5) + 8LL * v6) = *(_QWORD *)(*(_QWORD *)(hard_signals + v1)
+ 8 * v2);
break;
case 2:
*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(ey + 8LL * v4) + 8LL * v5) + 8LL * v6) = *(_QWORD *)(*(_QWORD *)(hard_signals + v1)
+ 8 * v2);
break;
case 3:
*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(ez + 8LL * v4) + 8LL * v5) + 8LL * v6) = *(_QWORD *)(*(_QWORD *)(hard_signals + v1)
+ 8 * v2);
break;
}
++v2;
}
while ( total_hards > (int)v2 );
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1)
{
__int64 v1; // r9
__int64 v2; // rax
int **v3; // rdx
int v4; // esi
int v5; // ecx
int v6; // edx
int v7; // edi

if ( total_hards > 0 )
{
v1 = 8LL * a1;
v2 = 0LL;
do
{
v3 = (int **)(hard_points + 8 * v2);
v4 = **v3;
x = v4;
v5 = (*v3)[1];
y = v5;
v6 = (*v3)[2];
z = v6;
v7 = *(_DWORD *)(hard_polarizations + 4 * v2);
switch ( v7 )
{
case 1:
*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(ex + 8LL * v4) + 8LL * v5) + 8LL * v6) = *(_QWORD *)(*(_QWORD *)(hard_signals + v1)
+ 8 * v2);
break;
case 2:
*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(ey + 8LL * v4) + 8LL * v5) + 8LL * v6) = *(_QWORD *)(*(_QWORD *)(hard_signals + v1)
+ 8 * v2);
break;
case 3:
*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(ez + 8LL * v4) + 8LL * v5) + 8LL * v6) = *(_QWORD *)(*(_QWORD *)(hard_signals + v1)
+ 8 * v2);
break;
}
++v2;
}
while ( total_hards > (int)v2 );
}
return 1LL;
}

original_code:
int apply_ehards(int time_index)
{
    int hard_index;
    for (hard_index = 0; hard_index < total_hards; hard_index++)
    {
        x = hard_points[hard_index][0];
        y = hard_points[hard_index][1];
        z = hard_points[hard_index][2];
        if (hard_polarizations[hard_index] == p_ex)
            ex[x][y][z] = hard_signals[time_index][hard_index];
        else if (hard_polarizations[hard_index] == p_ey)
            ey[x][y][z] = hard_signals[time_index][hard_index];
        else if (hard_polarizations[hard_index] == p_ez)
            ez[x][y][z] = hard_signals[time_index][hard_index];
    }
    return 1;
}


decompiled_code:
__int64 __fastcall apply_hhards(int a1)
{
__int64 v1; // r9
__int64 v2; // rax
int **v3; // rdx
int v4; // esi
int v5; // ecx
int v6; // edx
int v7; // edi

if ( total_hards > 0 )
{
v1 = 8LL * a1;
v2 = 0LL;
do
{
v3 = (int **)(hard_points + 8 * v2);
v4 = **v3;
x = v4;
v5 = (*v3)[1];
y = v5;
v6 = (*v3)[2];
z = v6;
v7 = *(_DWORD *)(hard_polarizations + 4 * v2);
switch ( v7 )
{
case 4:
*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(hx + 8LL * v4) + 8LL * v5) + 8LL * v6) = *(_QWORD *)(*(_QWORD *)(hard_signals + v1)
+ 8 * v2);
break;
case 5:
*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(hy + 8LL * v4) + 8LL * v5) + 8LL * v6) = *(_QWORD *)(*(_QWORD *)(hard_signals + v1)
+ 8 * v2);
break;
case 6:
*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(hz + 8LL * v4) + 8LL * v5) + 8LL * v6) = *(_QWORD *)(*(_QWORD *)(hard_signals + v1)
+ 8 * v2);
break;
}
++v2;
}
while ( total_hards > (int)v2 );
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(int a1)
{
__int64 v1; // r9
__int64 v2; // rax
int **v3; // rdx
int v4; // esi
int v5; // ecx
int v6; // edx
int v7; // edi

if ( total_hards > 0 )
{
v1 = 8LL * a1;
v2 = 0LL;
do
{
v3 = (int **)(hard_points + 8 * v2);
v4 = **v3;
x = v4;
v5 = (*v3)[1];
y = v5;
v6 = (*v3)[2];
z = v6;
v7 = *(_DWORD *)(hard_polarizations + 4 * v2);
switch ( v7 )
{
case 4:
*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(hx + 8LL * v4) + 8LL * v5) + 8LL * v6) = *(_QWORD *)(*(_QWORD *)(hard_signals + v1)
+ 8 * v2);
break;
case 5:
*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(hy + 8LL * v4) + 8LL * v5) + 8LL * v6) = *(_QWORD *)(*(_QWORD *)(hard_signals + v1)
+ 8 * v2);
break;
case 6:
*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(hz + 8LL * v4) + 8LL * v5) + 8LL * v6) = *(_QWORD *)(*(_QWORD *)(hard_signals + v1)
+ 8 * v2);
break;
}
++v2;
}
while ( total_hards > (int)v2 );
}
return 1LL;
}

original_code:
int apply_hhards(int time_index)
{
    int hard_index;
    for (hard_index = 0; hard_index < total_hards; hard_index++)
    {
        x = hard_points[hard_index][0];
        y = hard_points[hard_index][1];
        z = hard_points[hard_index][2];
        if (hard_polarizations[hard_index] == p_hx)
            hx[x][y][z] = hard_signals[time_index][hard_index];
        else if (hard_polarizations[hard_index] == p_hy)
            hy[x][y][z] = hard_signals[time_index][hard_index];
        else if (hard_polarizations[hard_index] == p_hz)
            hz[x][y][z] = hard_signals[time_index][hard_index];
    }
    return 1;
}


original_code:
void clist_init(
                CList *list,
                void (*destroy)(void *))
{
    list->size = 0;
    list->destroy = destroy;
    list->head = ((void *)0);
}

canonical_original_code:
void clist_init(struct CList_ *list, void (*destroy)(void *))
{
    list->size = 0;
    list->destroy = destroy;
    list->head = ((void *)0);
}

variable_types: struct CList_ { int size; int (*cmp)(void *, void *); void (*destroy)(void *); struct CListElmt_ { void *data; struct CListElmt_ *next; } *head; } *

variable_types:
destroy
void (*)(void *)

return_type: void

user_defined_types: struct CList_ { int size; int (*cmp)(void *, void *); void (*destroy)(void *); struct CListElmt_ *head; }


original_code:
int clist_ins_next(
                CList *list,
                CListElmt *iter,
                const void *data)
{
    CListElmt *new_element ;
    if((new_element = (CListElmt*)malloc(sizeof(CListElmt))) == ((void *)0))
        return -1;
    new_element->data = (void *)data;
    if(((list)->size) == 0)
    {
        new_element->next = new_element;
        list->head = new_element;
    } else {
        new_element->next = iter->next;
        iter->next = new_element;
    }
    list->size++;
    return 0;
}

canonical_original_code:
int clist_ins_next(struct CList_ *list, struct CListElmt_ *iter, void *data)
{
    struct CListElmt_ *new_element;
    if((new_element = (struct CListElmt_ *)malloc(sizeof(CListElmt))) == ((void *)0))
        return -1;
    new_element->data = (void *)data;
    if(((list)->size) == 0)
    {
        new_element->next = new_element;
        list->head = new_element;
    } else {
        new_element->next = iter->next;
        iter->next = new_element;
    }
    list->size++;
    return 0;
}

variable_types:
iter
struct CListElmt_ *

variable_types:
data
void *

variable_types: struct CListElmt_ { void *data; struct CListElmt_ *next; } *


original_code:
int clist_rem_next(
                CList *list,
                CListElmt * iter,
                void **data)
{
    CListElmt *old_element;
    if(((list)->size) == 0)
        return -1;
    *data = iter->next->data;
    if(iter == iter->next){
        old_element = iter;
        list->head = ((void *)0);
    } else {
        old_element = iter->next;
        iter->next = old_element->next;
        if (old_element == ((list)->head))
            list->head = old_element->next;
    }
    free(old_element);
    list->size--;
    return 0;
}

canonical_original_code:
int clist_rem_next(struct CList_ *list, struct CListElmt_ *iter, void **data)
{
    struct CListElmt_ *old_element;
    if(((list)->size) == 0)
        return -1;
    *data = iter->next->data;
    if(iter == iter->next){
        old_element = iter;
        list->head = ((void *)0);
    } else {
        old_element = iter->next;
        iter->next = old_element->next;
        if (old_element == ((list)->head))
            list->head = old_element->next;
    }
    free(old_element);
    list->size--;
    return 0;
}

variable_types:
data
void **

user_defined_types: struct CListElmt_ { void *data; struct CListElmt_ *next; }


decompiled_code:
int __fastcall print_email_list(unsigned int *a1)
{
int result; // eax
int v2; // er12
const char **v3; // rbp
int v4; // er13
int i; // ebx
__int64 v6; // rdx

result = fprintf(_bss_start, "Email_list size is %d (circling twice)\n\n", *a1);
v2 = *a1;
v3 = (const char **)*((_QWORD *)a1 + 3);
v4 = 2 * *a1;
if ( v4 > 0 )
{
for ( i = 0; i != v4; ++i )
{
v6 = (unsigned int)(i >> 31);
LODWORD(v6) = i % v2;
result = fprintf(
_bss_start,
"email_list[%03d] =\nEmail {\nsubjet: %s,\nfrom: %s,\ntime_date: %d }\n\n",
v6,
*v3,
*v3 + 1032,
*((unsigned int *)*v3 + 256));
v3 = (const char **)v3[1];
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func11(unsigned int *a1)
{
int result; // eax
int v2; // er12
const char **v3; // rbp
int v4; // er13
int i; // ebx
__int64 v6; // rdx

result = fprintf(_bss_start, "Email_list size is %d (circling twice)\n\n", *a1);
v2 = *a1;
v3 = (const char **)*((_QWORD *)a1 + 3);
v4 = 2 * *a1;
if ( v4 > 0 )
{
for ( i = 0; i != v4; ++i )
{
v6 = (unsigned int)(i >> 31);
LODWORD(v6) = i % v2;
result = fprintf(
_bss_start,
"email_list[%03d] =\nEmail {\nsubjet: %s,\nfrom: %s,\ntime_date: %d }\n\n",
v6,
*v3,
*v3 + 1032,
*((unsigned int *)*v3 + 256));
v3 = (const char **)v3[1];
}
}
return result;
}

original_code:
void print_email_list(const CList *list) {
    CListElmt *iter;
    int size,
                        i;
    fprintf(stdout, "Email_list size is %d (circling twice)\n\n", ((list)->size));
    size = ((list)->size);
    iter = ((list)->head);
    i = 0;
    Email *email;
    while (i < size * 2) {
        email = ((iter)->data);
        fprintf(stdout, "email_list[%03d] =\nEmail {\nsubjet: %s,\nfrom: %s,\ntime_date: %d }\n\n", (i % size), email->subject, email->from, (int) email->time_date);
        iter = ((iter)->next);
        i++;
    }
    return;
}

canonical_original_code:
void print_email_list(struct CList_ *list) {
    struct CListElmt_ *iter;
    int size; int i;
    fprintf(stdout, "Email_list size is %d (circling twice)\n\n", ((list)->size));
    size = ((list)->size);
    iter = ((list)->head);
    i = 0;
    struct Email_ *email;
    while (i < size * 2) {
        email = ((iter)->data);
        fprintf(stdout, "email_list[%03d] =\nEmail {\nsubjet: %s,\nfrom: %s,\ntime_date: %d }\n\n", (i % size), email->subject, email->from, (int) email->time_date);
        iter = ((iter)->next);
        i++;
    }
    return;
}

variable_types: size int

variable_types: i int

variable_types: struct Email_ { char subject[1024]; long time_date; char from[64]; } *


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbx
unsigned int i; // er12
char *v5; // rbp
int v6; // eax
int v7; // ebx
unsigned int v9[6]; // [rsp+0h] [rbp-498h] BYREF
__int64 v10; // [rsp+18h] [rbp-480h]
char *dest; // [rsp+28h] [rbp-470h] BYREF
char src[1128]; // [rsp+30h] [rbp-468h] BYREF

memset(src, 0, 0x448uLL);
strcpy(src, "this is a test demo");
*(_QWORD *)&src[24] = 0LL;
strcpy(&src[1032], "Thomas<youremail@domain>");
clist_init((__int64)v9, (__int64)free);
v3 = v10;
fwrite("...Insert ten emial objects\n", 1uLL, 0x1CuLL, _bss_start);
for ( i = 0; i != 10; ++i )
{
v5 = (char *)malloc(0x448uLL);
dest = v5;
if ( !v5 )
return 1;
*((_QWORD *)v5 + 128) = time(0LL);
strncpy(dest, src, 0x3FFuLL);
strncpy(dest + 1032, &src[1032], 0x3FuLL);
fprintf(_bss_start, "insert [%03d] item...\n", i);
if ( (unsigned int)clist_ins_next((__int64)v9, v3, (__int64)dest) )
return 1;
if ( v3 )
v3 = *(_QWORD *)(v3 + 8);
else
v3 = *(_QWORD *)(v10 + 8);
}
print_email_list(v9);
v6 = 15;
do
{
v3 = *(_QWORD *)(v3 + 8);
--v6;
}
while ( v6 );
dest = *(char **)v3;
fprintf(
_bss_start,
"remove after Email {\nsubjet: %s,\nfrom: %s,\ntime_date: %d }\n\n",
dest,
dest + 1032,
*((unsigned int *)dest + 256));
v7 = clist_rem_next((__int64)v9, v3, &dest);
if ( v7 )
return 1;
free(dest);
print_email_list(v9);
fwrite("Destory Email circular list\n", 1uLL, 0x1CuLL, _bss_start);
clist_dealloc((__int64)v9);
return v7;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbx
unsigned int i; // er12
char *v5; // rbp
int v6; // eax
int v7; // ebx
unsigned int v9[6]; // [rsp+0h] [rbp-498h] BYREF
__int64 v10; // [rsp+18h] [rbp-480h]
char *dest; // [rsp+28h] [rbp-470h] BYREF
char src[1128]; // [rsp+30h] [rbp-468h] BYREF

memset(src, 0, 0x448uLL);
strcpy(src, "this is a test demo");
*(_QWORD *)&src[24] = 0LL;
strcpy(&src[1032], "Thomas<youremail@domain>");
func7((__int64)v9, (__int64)free);
v3 = v10;
fwrite("...Insert ten emial objects\n", 1uLL, 0x1CuLL, _bss_start);
for ( i = 0; i != 10; ++i )
{
v5 = (char *)malloc(0x448uLL);
dest = v5;
if ( !v5 )
return 1;
*((_QWORD *)v5 + 128) = time(0LL);
strncpy(dest, src, 0x3FFuLL);
strncpy(dest + 1032, &src[1032], 0x3FuLL);
fprintf(_bss_start, "insert [%03d] item...\n", i);
if ( (unsigned int)func8((__int64)v9, v3, (__int64)dest) )
return 1;
if ( v3 )
v3 = *(_QWORD *)(v3 + 8);
else
v3 = *(_QWORD *)(v10 + 8);
}
func11(v9);
v6 = 15;
do
{
v3 = *(_QWORD *)(v3 + 8);
--v6;
}
while ( v6 );
dest = *(char **)v3;
fprintf(
_bss_start,
"remove after Email {\nsubjet: %s,\nfrom: %s,\ntime_date: %d }\n\n",
dest,
dest + 1032,
*((unsigned int *)dest + 256));
v7 = func9((__int64)v9, v3, &dest);
if ( v7 )
return 1;
free(dest);
func11(v9);
fwrite("Destory Email circular list\n", 1uLL, 0x1CuLL, _bss_start);
func10((__int64)v9);
return v7;
}

original_code:
int main()
{
    Email eemail = {.subject = "this is a test demo", .from = "Thomas<youremail@domain>"};
    Email *email;
    CList email_list;
    clist_init(&email_list, free);
    CListElmt *iter;
    iter = ((&email_list)->head);
    int i = 0;
    fprintf(stdout, "...Insert ten emial objects\n");
    while(i < 10){
        if((email = (Email*)malloc(sizeof(Email))) == ((void *)0) )
            return 1;
        email->time_date = time(((void *)0));
        strncpy(email->subject, eemail.subject, 1023);
        strncpy(email->from, eemail.from, 63);
        fprintf(stdout, "insert [%03d] item...\n", i);
        if(clist_ins_next(&email_list, iter, (void *)email ) != 0)
            return 1;
        if (iter == ((void *)0))
            iter = ((((&email_list)->head))->next);
        else
            iter = ((iter)->next);
        i++;
    }
    print_email_list(&email_list);
    for (i = 0; i < 15; i++)
      iter = ((iter)->next);
    email = ((iter)->data);
     fprintf(stdout, "remove after Email {\nsubjet: %s,\nfrom: %s,\ntime_date: %d }\n\n", email->subject, email->from, (int)email->time_date);
    if (clist_rem_next(&email_list, iter, (void **)&email) != 0)
        return 1;
    free(email);
    print_email_list(&email_list);
    fprintf(stdout, "Destory Email circular list\n");
    clist_dealloc(&email_list);
    return 0;
}

canonical_original_code:
int main()
{
    struct Email_ eemail = {.subject = "this is a test demo", .from = "Thomas<youremail@domain>"};
    struct Email_ *email;
    struct CList_ email_list;
    clist_init(&email_list, free);
    struct CListElmt_ *iter;
    iter = ((&email_list)->head);
    int i = 0;
    fprintf(stdout, "...Insert ten emial objects\n");
    while(i < 10){
        if((email = (struct Email_ *)malloc(sizeof(Email))) == ((void *)0) )
            return 1;
        email->time_date = time(((void *)0));
        strncpy(email->subject, eemail.subject, 1023);
        strncpy(email->from, eemail.from, 63);
        fprintf(stdout, "insert [%03d] item...\n", i);
        if(clist_ins_next(&email_list, iter, (void *)email ) != 0)
            return 1;
        if (iter == ((void *)0))
            iter = ((((&email_list)->head))->next);
        else
            iter = ((iter)->next);
        i++;
    }
    print_email_list(&email_list);
    for (i = 0; i < 15; i++)
      iter = ((iter)->next);
    email = ((iter)->data);
     fprintf(stdout, "remove after Email {\nsubjet: %s,\nfrom: %s,\ntime_date: %d }\n\n", email->subject, email->from, (int)email->time_date);
    if (clist_rem_next(&email_list, iter, (void **)&email) != 0)
        return 1;
    free(email);
    print_email_list(&email_list);
    fprintf(stdout, "Destory Email circular list\n");
    clist_dealloc(&email_list);
    return 0;
}

variable_types: struct Email_ { char subject[1024]; long time_date; char from[64]; }

variable_types: struct CList_ { int size; int (*cmp)(void *, void *); void (*destroy)(void *); struct CListElmt_ { void *data; struct CListElmt_ *next; } *head; }


decompiled_code:
unsigned __int64 COUNTING_SORT()
{
int *v0; // rax
int v1; // esi
__int64 v2; // rax
unsigned __int64 result; // rax
__int64 v4; // rdx
int v5; // esi
int v6; // eax

v0 = count;
do
*v0++ = 0;
while ( v0 != (int *)&unk_4043A4 );
v1 = lenth;
if ( lenth > 0 )
{
v2 = 1LL;
do
++count[num[v2++]];
while ( v2 != v1 + 1 );
}
result = (unsigned __int64)&unk_404084;
do
{
*(_DWORD *)result += *(_DWORD *)(result - 4);
result += 4LL;
}
while ( (_UNKNOWN *)result != &unk_4043A4 );
if ( v1 > 0 )
{
v4 = v1;
do
{
v5 = num[v4];
v6 = count[v5];
::result[v6] = v5;
result = (unsigned int)(v6 - 1);
count[v5] = result;
--v4;
}
while ( (int)v4 > 0 );
}
return result;
}

canonical_decompiled_code:
unsigned __int64 func7()
{
int *v0; // rax
int v1; // esi
__int64 v2; // rax
unsigned __int64 result; // rax
__int64 v4; // rdx
int v5; // esi
int v6; // eax

v0 = count;
do
*v0++ = 0;
while ( v0 != (int *)&unk_4043A4 );
v1 = lenth;
if ( lenth > 0 )
{
v2 = 1LL;
do
++count[num[v2++]];
while ( v2 != v1 + 1 );
}
result = (unsigned __int64)&unk_404084;
do
{
*(_DWORD *)result += *(_DWORD *)(result - 4);
result += 4LL;
}
while ( (_UNKNOWN *)result != &unk_4043A4 );
if ( v1 > 0 )
{
v4 = v1;
do
{
v5 = num[v4];
v6 = count[v5];
::result[v6] = v5;
result = (unsigned int)(v6 - 1);
count[v5] = result;
--v4;
}
while ( (int)v4 > 0 );
}
return result;
}

original_code:
void COUNTING_SORT()
{
    int i;
    for(i=0;i<=200;i++)
        count[i]=0;
    for(i=1;i<=lenth;i++)
        count[num[i]]=count[num[i]]+1;
    for(i=1;i<=200;i++)
        count[i]=count[i]+count[i-1];
    for(i=lenth;i>=1;i--)
    {
        result[count[num[i]]]=num[i];
        count[num[i]]=count[num[i]]-1;
    }
}


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // rbp
int v4; // ebx
__int64 v5; // rbx

freopen("in.txt", "r", _bss_start);
__isoc99_scanf();
if ( lenth > 0 )
{
v3 = (char *)&unk_4043C4;
v4 = 1;
do
{
__isoc99_scanf();
++v4;
v3 += 4;
}
while ( lenth >= v4 );
}
COUNTING_SORT();
if ( lenth > 0 )
{
v5 = 1LL;
do
printf(" %d", (unsigned int)result[v5++]);
while ( lenth >= (int)v5 );
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // rbp
int v4; // ebx
__int64 v5; // rbx

freopen("in.txt", "r", _bss_start);
__isoc99_scanf();
if ( lenth > 0 )
{
v3 = (char *)&unk_4043C4;
v4 = 1;
do
{
__isoc99_scanf();
++v4;
v3 += 4;
}
while ( lenth >= v4 );
}
func7();
if ( lenth > 0 )
{
v5 = 1LL;
do
printf(" %d", (unsigned int)result[v5++]);
while ( lenth >= (int)v5 );
}
return 0;
}

original_code:
int main()
{
    int i;
    freopen("in.txt","r",stdin);
    scanf("%d",&lenth);
    for(i=1;i<=lenth;i++)
    {
        scanf("%d",&num[i]);
    }
    COUNTING_SORT();
    for(i=1;i<=lenth;i++)
        printf(" %d",result[i]);
    return 0;
}


delete

original_code:
statusEnum delete(keyType key) {
    int i;
    nodeType *update[15 +1], *x;
    x = list.hdr;
    for (i = list.listLevel; i >= 0; i--) {
        while (x->forward[i] != list.hdr
          && (x->forward[i]->key < key))
            x = x->forward[i];
        update[i] = x;
    }
    x = x->forward[0];
    if (x == list.hdr || !(x->key == key))
        return STATUS_KEY_NOT_FOUND;
    for (i = 0; i <= list.listLevel; i++) {
        if (update[i]->forward[i] != x)
            break;
        update[i]->forward[i] = x->forward[i];
    }
    free (x);
    while ((list.listLevel > 0)
    && (list.hdr->forward[list.listLevel] == list.hdr))
        list.listLevel--;
    return STATUS_OK;
}

canonical_original_code:
enum statusEnum delete(int key) {
    int i;
    struct nodeTag *update[-1]; struct nodeTag *x;
    x = list.hdr;
    for (i = list.listLevel; i >= 0; i--) {
        while (x->forward[i] != list.hdr
          && (x->forward[i]->key < key))
            x = x->forward[i];
        update[i] = x;
    }
    x = x->forward[0];
    if (x == list.hdr || !(x->key == key))
        return STATUS_KEY_NOT_FOUND;
    for (i = 0; i <= list.listLevel; i++) {
        if (update[i]->forward[i] != x)
            break;
        update[i]->forward[i] = x->forward[i];
    }
    free (x);
    while ((list.listLevel > 0)
    && (list.hdr->forward[list.listLevel] == list.hdr))
        list.listLevel--;
    return STATUS_OK;
}

variable_types: key int

variable_types: struct nodeTag { int key; struct recType { int stuff; } rec; struct nodeTag *forward[1]; } *[-1]

return_type: enum statusEnum { STATUS_OK=0, STATUS_MEM_EXHAUSTED=1, STATUS_DUPLICATE_KEY=2, STATUS_KEY_NOT_FOUND=3 }

user_defined_types: struct nodeTag { int key; struct recType rec; struct nodeTag *forward[1]; }


find

original_code:
statusEnum find(keyType key, recType *rec) {
    int i;
    nodeType *x = list.hdr;
    for (i = list.listLevel; i >= 0; i--) {
        while (x->forward[i] != list.hdr && (x->forward[i]->key < key))
            x = x->forward[i];
    }
    x = x->forward[0];
    if (x != list.hdr && (x->key == key)) {
        *rec = x->rec;
        return STATUS_OK;
    }
    return STATUS_KEY_NOT_FOUND;
}

canonical_original_code:
enum statusEnum find(int key, struct recType *rec) {
    int i;
    struct nodeTag *x = list.hdr;
    for (i = list.listLevel; i >= 0; i--) {
        while (x->forward[i] != list.hdr && (x->forward[i]->key < key))
            x = x->forward[i];
    }
    x = x->forward[0];
    if (x != list.hdr && (x->key == key)) {
        *rec = x->rec;
        return STATUS_OK;
    }
    return STATUS_KEY_NOT_FOUND;
}

variable_types:
rec
struct recType { int stuff; } *

variable_types: struct nodeTag { int key; struct recType { int stuff; } rec; struct nodeTag *forward[1]; } *

user_defined_types: enum statusEnum { STATUS_OK=0, STATUS_MEM_EXHAUSTED=1, STATUS_DUPLICATE_KEY=2, STATUS_KEY_NOT_FOUND=3 }


initList

decompiled_code:
char *initList()
{
char *v0; // rax
char *v1; // rdx
char *result; // rax

v0 = (char *)malloc(0x88uLL);
list = (__int64)v0;
if ( !v0 )
{
puts("insufficient memory (initList)");
exit(1);
}
v1 = v0;
result = v0 + 8;
do
{
*(_QWORD *)result = v1;
result += 8;
}
while ( result != v1 + 136 );
dword_404098 = 0;
return result;
}

canonical_decompiled_code:
char *func11()
{
char *v0; // rax
char *v1; // rdx
char *result; // rax

v0 = (char *)malloc(0x88uLL);
list = (__int64)v0;
if ( !v0 )
{
puts("insufficient memory (initList)");
exit(1);
}
v1 = v0;
result = v0 + 8;
do
{
*(_QWORD *)result = v1;
result += 8;
}
while ( result != v1 + 136 );
dword_404098 = 0;
return result;
}

original_code:
void initList() {
    int i;
    if ((list.hdr = malloc(sizeof(nodeType) + 15*sizeof(nodeType *))) == 0) {
        printf ("insufficient memory (initList)\n");
        exit(1);
    }
    for (i = 0; i <= 15; i++)
        list.hdr->forward[i] = list.hdr;
    list.listLevel = 0;
}

canonical_original_code:
void initList() {
    int i;
    if ((list.hdr = malloc(sizeof(nodeType) + 15*sizeof(struct nodeTag *))) == 0) {
        printf ("insufficient memory (initList)\n");
        exit(1);
    }
    for (i = 0; i <= 15; i++)
        list.hdr->forward[i] = list.hdr;
    list.listLevel = 0;
}


decompiled_code:
int print_skip_list()
{
int v0; // er12
unsigned int *v1; // rbx

if ( dword_404098 >= 0 )
{
v0 = 0;
do
{
v1 = *(unsigned int **)(list + 8LL * v0 + 8);
printf("\nlevel[%d]", (unsigned int)v0);
for ( ; *(_QWORD *)&v1[2 * v0 + 2] != list; v1 = *(unsigned int **)&v1[2 * v0 + 2] )
printf("-->%d", *v1);
printf("-->%d", *v1);
++v0;
}
while ( dword_404098 >= v0 );
}
return putchar(10);
}

canonical_decompiled_code:
int func7()
{
int v0; // er12
unsigned int *v1; // rbx

if ( dword_404098 >= 0 )
{
v0 = 0;
do
{
v1 = *(unsigned int **)(list + 8LL * v0 + 8);
printf("\nlevel[%d]", (unsigned int)v0);
for ( ; *(_QWORD *)&v1[2 * v0 + 2] != list; v1 = *(unsigned int **)&v1[2 * v0 + 2] )
printf("-->%d", *v1);
printf("-->%d", *v1);
++v0;
}
while ( dword_404098 >= v0 );
}
return putchar(10);
}

original_code:
void print_skip_list()
{
    int i;
    nodeType *x;
    for (i = 0; i <= list.listLevel; i++) {
        x = list.hdr->forward[i];
        printf("\nlevel[%d]",i);
        while (x->forward[i] != list.hdr){
            printf("-->%d",x->key);
            x = x->forward[i];
        }
        printf("-->%d",x->key);
    }
    printf("\n");
}

canonical_original_code:
void print_skip_list()
{
    int i;
    struct nodeTag *x;
    for (i = 0; i <= list.listLevel; i++) {
        x = list.hdr->forward[i];
        printf("\nlevel[%d]",i);
        while (x->forward[i] != list.hdr){
            printf("-->%d",x->key);
            x = x->forward[i];
        }
        printf("-->%d",x->key);
    }
    printf("\n");
}


insert

original_code:
statusEnum insert(keyType key, recType *rec) {
    int i, newLevel;
    nodeType *update[15 +1];
    nodeType *x;
    count++;
    printf("-insert-%d-\n",key);
    x = list.hdr;
    for (i = list.listLevel; i >= 0; i--) {
        while (x->forward[i] != list.hdr && (x->forward[i]->key < key))
            x = x->forward[i];
        update[i] = x;
    }
    x = x->forward[0];
    if (x != list.hdr && (x->key == key))
        return STATUS_DUPLICATE_KEY;
    for (newLevel = 0;rand() < 2147483647/2 && newLevel < 15;newLevel++);
        if (newLevel > list.listLevel) {
            for (i = list.listLevel + 1; i <= newLevel; i++)
                update[i] = list.hdr;
            list.listLevel = newLevel;
        }
    if ((x = malloc(sizeof(nodeType) + newLevel*sizeof(nodeType *))) == 0)
        return STATUS_MEM_EXHAUSTED;
    x->key = key;
    x->rec = *rec;
    for (i = 0; i <= newLevel; i++) {
        x->forward[i] = update[i]->forward[i];
        update[i]->forward[i] = x;
    }
    return STATUS_OK;
}

canonical_original_code:
enum statusEnum insert(int key, struct recType *rec) {
    int i; int newLevel;
    struct nodeTag *update[-1];
    struct nodeTag *x;
    count++;
    printf("-insert-%d-\n",key);
    x = list.hdr;
    for (i = list.listLevel; i >= 0; i--) {
        while (x->forward[i] != list.hdr && (x->forward[i]->key < key))
            x = x->forward[i];
        update[i] = x;
    }
    x = x->forward[0];
    if (x != list.hdr && (x->key == key))
        return STATUS_DUPLICATE_KEY;
    for (newLevel = 0;rand() < 2147483647/2 && newLevel < 15;newLevel++);
        if (newLevel > list.listLevel) {
            for (i = list.listLevel + 1; i <= newLevel; i++)
                update[i] = list.hdr;
            list.listLevel = newLevel;
        }
    if ((x = malloc(sizeof(nodeType) + newLevel*sizeof(struct nodeTag *))) == 0)
        return STATUS_MEM_EXHAUSTED;
    x->key = key;
    x->rec = *rec;
    for (i = 0; i <= newLevel; i++) {
        x->forward[i] = update[i]->forward[i];
        update[i]->forward[i] = x;
    }
    return STATUS_OK;
}

variable_types: newLevel int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // rax
char *v4; // r12
int *v5; // rax
int *v6; // rbp
int *v7; // rbx
int *v8; // r13
__int64 j; // rbx
__int64 i; // rax
unsigned int v11; // eax
__int64 k; // rbx
unsigned int v13; // eax
int *l; // rbx
unsigned int v15; // eax

initList();
v3 = (char *)malloc(0x50uLL);
if ( !v3 )
{
fwrite("insufficient memory (rec)\n", 1uLL, 0x1AuLL, stderr);
exit(1);
}
v4 = v3;
v5 = (int *)malloc(0x50uLL);
v6 = v5;
if ( !v5 )
{
fwrite("insufficient memory (key)\n", 1uLL, 0x1AuLL, stderr);
exit(1);
}
if ( argc <= 2 )
{
for ( i = 0LL; i != 20; ++i )
v6[i] = i;
printf("seq, %d items\n", 20LL);
}
else
{
v7 = v5;
v8 = v5 + 20;
do
*v7++ = rand();
while ( v7 != v8 );
printf("ran, %d items\n", 20LL);
}
for ( j = 0LL; j != 20; ++j )
{
v11 = insert(v6[j], &v4[j * 4]);
if ( v11 )
printf("pt1: error = %d\n", v11);
}
printf("the number of insert node is %d!\n", (unsigned int)count);
print_skip_list();
for ( k = 19LL; k != -1; --k )
{
v13 = find(v6[k], &v4[k * 4]);
if ( v13 )
printf("pt2: error = %d\n", v13);
}
for ( l = v6 + 19; ; --l )
{
v15 = delete(*l);
if ( v15 )
printf("pt3: error = %d\n", v15);
if ( l == v6 )
break;
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // rax
char *v4; // r12
int *v5; // rax
int *v6; // rbp
int *v7; // rbx
int *v8; // r13
__int64 j; // rbx
__int64 i; // rax
unsigned int v11; // eax
__int64 k; // rbx
unsigned int v13; // eax
int *l; // rbx
unsigned int v15; // eax

func11();
v3 = (char *)malloc(0x50uLL);
if ( !v3 )
{
fwrite("insufficient memory (rec)\n", 1uLL, 0x1AuLL, stderr);
exit(1);
}
v4 = v3;
v5 = (int *)malloc(0x50uLL);
v6 = v5;
if ( !v5 )
{
fwrite("insufficient memory (key)\n", 1uLL, 0x1AuLL, stderr);
exit(1);
}
if ( argc <= 2 )
{
for ( i = 0LL; i != 20; ++i )
v6[i] = i;
printf("seq, %d items\n", 20LL);
}
else
{
v7 = v5;
v8 = v5 + 20;
do
*v7++ = rand();
while ( v7 != v8 );
printf("ran, %d items\n", 20LL);
}
for ( j = 0LL; j != 20; ++j )
{
v11 = func8(v6[j], &v4[j * 4]);
if ( v11 )
printf("pt1: error = %d\n", v11);
}
printf("the number of insert node is %d!\n", (unsigned int)count);
func7();
for ( k = 19LL; k != -1; --k )
{
v13 = func10(v6[k], &v4[k * 4]);
if ( v13 )
printf("pt2: error = %d\n", v13);
}
for ( l = v6 + 19; ; --l )
{
v15 = func9(*l);
if ( v15 )
printf("pt3: error = %d\n", v15);
if ( l == v6 )
break;
}
return 0;
}

original_code:
int main(int argc, char **argv) {
    int i, maxnum, random;
    recType *rec;
    keyType *key;
    statusEnum status;
    maxnum = 20;
    random = argc > 2;
    initList();
    if ((rec = malloc(maxnum * sizeof(recType))) == 0) {
        fprintf (stderr, "insufficient memory (rec)\n");
        exit(1);
    }
    if ((key = malloc(maxnum * sizeof(keyType))) == 0) {
        fprintf (stderr, "insufficient memory (key)\n");
        exit(1);
    }
    if (random) {
        for (i = 0; i < maxnum; i++) key[i] = rand();
        printf ("ran, %d items\n", maxnum);
    } else {
        for (i = 0; i < maxnum; i++) key[i] = i;
        printf ("seq, %d items\n", maxnum);
    }
    for (i = 0; i < maxnum; i++) {
        status = insert(key[i], &rec[i]);
        if (status)
            printf("pt1: error = %d\n", status);
    }
    printf("the number of insert node is %d!\n",count);
    print_skip_list();
    for (i = maxnum-1; i >= 0; i--) {
        status = find(key[i], &rec[i]);
        if (status) printf("pt2: error = %d\n", status);
    }
    for (i = maxnum-1; i >= 0; i--) {
        status = delete(key[i]);
        if (status) printf("pt3: error = %d\n", status);
    }
    return 0;
}

canonical_original_code:
int main(int argc, char **argv) {
    int i; int maxnum; int random;
    struct recType *rec;
    int *key;
    enum statusEnum status;
    maxnum = 20;
    random = argc > 2;
    initList();
    if ((rec = malloc(maxnum * sizeof(recType))) == 0) {
        fprintf (stderr, "insufficient memory (rec)\n");
        exit(1);
    }
    if ((key = malloc(maxnum * sizeof(keyType))) == 0) {
        fprintf (stderr, "insufficient memory (key)\n");
        exit(1);
    }
    if (random) {
        for (i = 0; i < maxnum; i++) key[i] = rand();
        printf ("ran, %d items\n", maxnum);
    } else {
        for (i = 0; i < maxnum; i++) key[i] = i;
        printf ("seq, %d items\n", maxnum);
    }
    for (i = 0; i < maxnum; i++) {
        status = insert(key[i], &rec[i]);
        if (status)
            printf("pt1: error = %d\n", status);
    }
    printf("the number of insert node is %d!\n",count);
    print_skip_list();
    for (i = maxnum-1; i >= 0; i--) {
        status = find(key[i], &rec[i]);
        if (status) printf("pt2: error = %d\n", status);
    }
    for (i = maxnum-1; i >= 0; i--) {
        status = delete(key[i]);
        if (status) printf("pt3: error = %d\n", status);
    }
    return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: maxnum int

variable_types: random int

variable_types:
key
int *

variable_types: enum statusEnum { STATUS_OK=0, STATUS_MEM_EXHAUSTED=1, STATUS_DUPLICATE_KEY=2, STATUS_KEY_NOT_FOUND=3 }


invert

decompiled_code:
char *__fastcall invert(char *a1, char *a2)
{
char *v2; // rax
char v3; // dl

if ( a1 < a2 && a1 != 0LL && a2 )
{
v2 = a1;
do
{
v3 = *v2;
*v2 = *a2;
*a2 = v3;
++v2;
--a2;
}
while ( v2 < a2 );
}
return a1;
}

original_code:
char *invert(char *start, char *end)
{
    char tmp, *ptmp = start;
    while (start != ((void *)0) && end != ((void *)0) && start < end)
    {
        tmp = *start;
        *start = *end;
        *end = tmp;
        start ++;
        end --;
    }
    return ptmp;
}

canonical_original_code:
char *invert(char *start, char *end)
{
    char tmp; char *ptmp = start;
    while (start != ((void *)0) && end != ((void *)0) && start < end)
    {
        tmp = *start;
        *start = *end;
        *end = tmp;
        start ++;
        end --;
    }
    return ptmp;
}

variable_types:
start
char *

variable_types:
end
char *

variable_types: tmp char

variable_types:
ptmp
char *

return_type: char *


left

decompiled_code:
char *__fastcall left(char *a1, int a2)
{
int v2; // er12
char *v3; // r12

v2 = strlen(a1);
invert(a1, &a1[a2 - 1]);
v3 = &a1[v2 - 1];
invert(&a1[a2], v3);
invert(a1, v3);
return a1;
}

canonical_decompiled_code:
char *__fastcall func8(char *a1, int a2)
{
int v2; // er12
char *v3; // r12

v2 = strlen(a1);
func7(a1, &a1[a2 - 1]);
v3 = &a1[v2 - 1];
func7(&a1[a2], v3);
func7(a1, v3);
return a1;
}

original_code:
char *left(char *s, int pos)
{
    int len = strlen(s);
    invert(s, s + (pos - 1));
    invert(s + pos, s + (len - 1));
    invert(s, s + (len - 1));
    return s;
}

variable_types:
s
char *

variable_types: pos int

variable_types: len int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // rax
char v5[19]; // [rsp+5h] [rbp-13h] BYREF

strcpy(v5, "abcdefghij");
v3 = left(v5, 3);
puts(v3);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // rax
char v5[19]; // [rsp+5h] [rbp-13h] BYREF

strcpy(v5, "abcdefghij");
v3 = func8(v5, 3);
puts(v3);
return 0;
}

original_code:
int main()
{
    char s[] = "abcdefghij";
    puts(left(s, 3));
    return 0;
}

variable_types:
s
char []


Exchange

decompiled_code:
__int64 __fastcall Exchange(_DWORD *a1, _DWORD *a2)
{
__int64 result; // rax

result = (unsigned int)*a1;
*a1 = *a2;
*a2 = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(_DWORD *a1, _DWORD *a2)
{
__int64 result; // rax

result = (unsigned int)*a1;
*a1 = *a2;
*a2 = result;
return result;
}

original_code:
void Exchange(int *a,int *b)
{
    int temp=*a;
        *a=*b;
        *b=temp;
}

canonical_original_code:
void Exchange(int *a, int *b)
{
    int temp = *a;
        *a=*b;
        *b=temp;
}

variable_types:
a
int *

variable_types:
b
int *

variable_types: temp int


decompiled_code:
__int64 __fastcall Max_HEAPIFY(__int64 a1, int a2)
{
__int64 result; // rax
int v3; // ebp

result = (unsigned int)(2 * a2);
v3 = result + 1;
if ( lenth >= (int)result && *(_DWORD *)(a1 + 4LL * (int)result) > *(_DWORD *)(a1 + 4LL * a2) )
{
if ( lenth < v3 )
{
v3 = 2 * a2;
}
else if ( *(_DWORD *)(a1 + 4LL * (int)result) >= *(_DWORD *)(a1 + 4LL * v3) )
{
v3 = 2 * a2;
}
goto LABEL_10;
}
if ( lenth >= v3 )
{
result = a2;
if ( *(_DWORD *)(a1 + 4LL * a2) < *(_DWORD *)(a1 + 4LL * v3) )
{
LABEL_10:
if ( v3 != a2 )
{
Exchange((_DWORD *)(a1 + 4LL * a2), (_DWORD *)(a1 + 4LL * v3));
result = Max_HEAPIFY(a1, (unsigned int)v3);
}
return result;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, int a2)
{
__int64 result; // rax
int v3; // ebp

result = (unsigned int)(2 * a2);
v3 = result + 1;
if ( lenth >= (int)result && *(_DWORD *)(a1 + 4LL * (int)result) > *(_DWORD *)(a1 + 4LL * a2) )
{
if ( lenth < v3 )
{
v3 = 2 * a2;
}
else if ( *(_DWORD *)(a1 + 4LL * (int)result) >= *(_DWORD *)(a1 + 4LL * v3) )
{
v3 = 2 * a2;
}
goto LABEL_10;
}
if ( lenth >= v3 )
{
result = a2;
if ( *(_DWORD *)(a1 + 4LL * a2) < *(_DWORD *)(a1 + 4LL * v3) )
{
LABEL_10:
if ( v3 != a2 )
{
func7((_DWORD *)(a1 + 4LL * a2), (_DWORD *)(a1 + 4LL * v3));
result = func8(a1, (unsigned int)v3);
}
return result;
}
}
return result;
}

original_code:
void Max_HEAPIFY(int *a,int i)
{
    int l=i*2,r=i*2+1,large;
    if(l<=lenth&&a[l]>a[i])
        large=l;
    else
        large=i;
    if(r<=lenth&&a[large]<a[r])
    {
        large=r;
    }
    if(large!=i)
    {
        Exchange(&a[i],&a[large]);
        Max_HEAPIFY(a,large);
    }
}

canonical_original_code:
void Max_HEAPIFY(int *a, int i)
{
    int l = i*2; int r = i*2+1; int large;
    if(l<=lenth&&a[l]>a[i])
        large=l;
    else
        large=i;
    if(r<=lenth&&a[large]<a[r])
    {
        large=r;
    }
    if(large!=i)
    {
        Exchange(&a[i],&a[large]);
        Max_HEAPIFY(a,large);
    }
}

variable_types: i int

variable_types: l int

variable_types: r int

variable_types: large int


decompiled_code:
__int64 __fastcall BUILD_MAX_HEAP(__int64 a1)
{
__int64 result; // rax
int v2; // ebx

result = (unsigned int)lenth;
v2 = lenth / 2;
if ( lenth > 1 )
{
do
result = Max_HEAPIFY(a1, v2--);
while ( v2 > 0 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
__int64 result; // rax
int v2; // ebx

result = (unsigned int)lenth;
v2 = lenth / 2;
if ( lenth > 1 )
{
do
result = func8(a1, v2--);
while ( v2 > 0 );
}
return result;
}

original_code:
void BUILD_MAX_HEAP(int *a)
{
  int i;
  for(i=lenth/2;i>=1;i--)
  {
      Max_HEAPIFY(a,i);
  }
}


HEAPSORT

decompiled_code:
__int64 __fastcall HEAPSORT(__int64 a1)
{
int v1; // ebx
__int64 result; // rax

BUILD_MAX_HEAP(a1);
v1 = 9;
do
{
Exchange((_DWORD *)(a1 + 4), (_DWORD *)(a1 + 4LL * lenth));
--lenth;
result = Max_HEAPIFY(a1, 1);
--v1;
}
while ( v1 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
int v1; // ebx
__int64 result; // rax

func9(a1);
v1 = 9;
do
{
func7((_DWORD *)(a1 + 4), (_DWORD *)(a1 + 4LL * lenth));
--lenth;
result = func8(a1, 1);
--v1;
}
while ( v1 );
return result;
}

original_code:
void HEAPSORT(int *a)
{
   int i;
   BUILD_MAX_HEAP(a);
   for(i=10;i>=2;i--)
   {
       Exchange(&a[1],&a[lenth]);
       lenth=lenth-1;
       Max_HEAPIFY(a,1);
   }
}


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int *v3; // rbx
char *v4; // rbp

freopen("in.txt", "r", _bss_start);
v3 = (unsigned int *)&unk_4040A4;
v4 = (char *)&unk_4040A4;
do
{
__isoc99_scanf();
v4 += 4;
}
while ( v4 != (char *)&unk_4040CC );
lenth = 10;
HEAPSORT((__int64)&num);
do
printf("%d ", *v3++);
while ( v3 != (unsigned int *)&unk_4040CC );
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int *v3; // rbx
char *v4; // rbp

freopen("in.txt", "r", _bss_start);
v3 = (unsigned int *)&unk_4040A4;
v4 = (char *)&unk_4040A4;
do
{
__isoc99_scanf();
v4 += 4;
}
while ( v4 != (char *)&unk_4040CC );
lenth = 10;
func10((__int64)&num);
do
printf("%d ", *v3++);
while ( v3 != (unsigned int *)&unk_4040CC );
return 0;
}

original_code:
int main()
{
    int i,j;
    freopen("in.txt","r",stdin);
    for(i=1;i<=10;i++)
    {
        scanf("%d",&num[i]);
    }
    lenth=10;
    HEAPSORT(num);
    for(i=1;i<=10;i++)
        printf("%d ",num[i]);
    return 0;
}

canonical_original_code:
int main()
{
    int i; int j;
    freopen("in.txt","r",stdin);
    for(i=1;i<=10;i++)
    {
        scanf("%d",&num[i]);
    }
    lenth=10;
    HEAPSORT(num);
    for(i=1;i<=10;i++)
        printf("%d ",num[i]);
    return 0;
}

variable_types: j int


decompiled_code:
size_t __fastcall get_next(const char *a1, _DWORD *a2)
{
size_t result; // rax
int v4; // edi
int v5; // edx

result = strlen(a1);
*a2 = -1;
if ( (int)result > 0 )
{
v4 = result;
LODWORD(result) = -1;
v5 = 0;
do
{
if ( (_DWORD)result == -1 || a1[v5] == a1[(int)result] )
{
++v5;
result = (unsigned int)(result + 1);
a2[v5] = result;
}
else
{
result = (unsigned int)a2[(int)result];
}
}
while ( v5 < v4 );
}
return result;
}

canonical_decompiled_code:
size_t __fastcall func7(const char *a1, _DWORD *a2)
{
size_t result; // rax
int v4; // edi
int v5; // edx

result = strlen(a1);
*a2 = -1;
if ( (int)result > 0 )
{
v4 = result;
LODWORD(result) = -1;
v5 = 0;
do
{
if ( (_DWORD)result == -1 || a1[v5] == a1[(int)result] )
{
++v5;
result = (unsigned int)(result + 1);
a2[v5] = result;
}
else
{
result = (unsigned int)a2[(int)result];
}
}
while ( v5 < v4 );
}
return result;
}

original_code:
int get_next(char* p, int* next)
{
    int len = strlen(p);
    int i = 0, k = -1;
    next[0] = -1;
    while(i<len)
    {
        if(k==-1 || p[i]==p[k])
        {
            i++;
            k++;
            next[i] = k;
        }else
        {
            k = next[k];
        }
    }
}

canonical_original_code:
int get_next(char *p, int *next)
{
    int len = strlen(p);
    int i = 0; int k = -1;
    next[0] = -1;
    while(i<len)
    {
        if(k==-1 || p[i]==p[k])
        {
            i++;
            k++;
            next[i] = k;
        }else
        {
            k = next[k];
        }
    }
}

variable_types:
p
char *

variable_types:
next
int *

variable_types: k int


decompiled_code:
__int64 __fastcall kmp_index(const char *a1, const char *a2, __int64 a3, int a4)
{
int v8; // er13
int v9; // eax
int v10; // edi
int v11; // esi
int v12; // eax
__int64 result; // rax

v8 = strlen(a1);
v9 = strlen(a2);
v10 = v9;
if ( a4 >= v8 || (v11 = v9, v9 <= 0) )
{
v12 = 0;
}
else
{
v12 = 0;
do
{
if ( v12 == -1 || a1[a4] == a2[v12] )
{
++a4;
++v12;
}
else
{
v12 = *(_DWORD *)(a3 + 4LL * v12);
}
}
while ( a4 < v8 && v12 < v11 );
}
if ( v10 > v12 )
result = 0xFFFFFFFFLL;
else
result = (unsigned int)(a4 - v10);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(const char *a1, const char *a2, __int64 a3, int a4)
{
int v8; // er13
int v9; // eax
int v10; // edi
int v11; // esi
int v12; // eax
__int64 result; // rax

v8 = strlen(a1);
v9 = strlen(a2);
v10 = v9;
if ( a4 >= v8 || (v11 = v9, v9 <= 0) )
{
v12 = 0;
}
else
{
v12 = 0;
do
{
if ( v12 == -1 || a1[a4] == a2[v12] )
{
++a4;
++v12;
}
else
{
v12 = *(_DWORD *)(a3 + 4LL * v12);
}
}
while ( a4 < v8 && v12 < v11 );
}
if ( v10 > v12 )
result = 0xFFFFFFFFLL;
else
result = (unsigned int)(a4 - v10);
return result;
}

original_code:
int kmp_index(char* s, char* p, int* next, int start)
{
    int i=start,j=0;
    int slen = strlen(s);
    int plen = strlen(p);
    while(i<slen && j<plen)
    {
        if(j==-1 || s[i]==p[j])
        {
            i++;
            j++;
        }else
        {
            j = next[j];
        }
    }
    if(j>=plen)
    {
        return i-plen;
    }else
    {
        return -1;
    }
}

canonical_original_code:
int kmp_index(char *s, char *p, int *next, int start)
{
    int i = start; int j = 0;
    int slen = strlen(s);
    int plen = strlen(p);
    while(i<slen && j<plen)
    {
        if(j==-1 || s[i]==p[j])
        {
            i++;
            j++;
        }else
        {
            j = next[j];
        }
    }
    if(j>=plen)
    {
        return i-plen;
    }else
    {
        return -1;
    }
}

variable_types: start int

variable_types: slen int

variable_types: plen int


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // rbx
int v4; // ebx
unsigned int v5; // eax
_DWORD v7[8]; // [rsp+0h] [rbp-418h] BYREF
char v8; // [rsp+20h] [rbp-3F8h] BYREF

get_next("abaabcac", v7);
v3 = (char *)v7;
do
{
printf("%d ", *(unsigned int *)v3);
v3 += 4;
}
while ( v3 != &v8 );
putchar(10);
v4 = 0;
while ( v4 != -1 )
{
v5 = kmp_index("xxabaabcacxxabaabcacdabaabcac99", "abaabcac", (__int64)v7, v4);
v4 = v5;
if ( v5 != -1 )
{
printf("'%s' @ %dth of '%s'\n", "abaabcac", v5, "xxabaabcacxxabaabcacdabaabcac99");
++v4;
}
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // rbx
int v4; // ebx
unsigned int v5; // eax
_DWORD v7[8]; // [rsp+0h] [rbp-418h] BYREF
char v8; // [rsp+20h] [rbp-3F8h] BYREF

func7("abaabcac", v7);
v3 = (char *)v7;
do
{
printf("%d ", *(unsigned int *)v3);
v3 += 4;
}
while ( v3 != &v8 );
putchar(10);
v4 = 0;
while ( v4 != -1 )
{
v5 = func8("xxabaabcacxxabaabcacdabaabcac99", "abaabcac", (__int64)v7, v4);
v4 = v5;
if ( v5 != -1 )
{
printf("'%s' @ %dth of '%s'\n", "abaabcac", v5, "xxabaabcacxxabaabcacdabaabcac99");
++v4;
}
}
return 0;
}

original_code:
int main()
{
    char* str = "xxabaabcacxxabaabcacdabaabcac99";
    char* pattern = "abaabcac";
    int next[256];
    int plen = strlen(pattern);
    int i;
    get_next(pattern, next);
    for(i=0;i<plen;i++)
    {
        printf("%d ", next[i]);
    }
    printf("\n");
    i=0;
    while(i!=-1)
    {
        i = kmp_index(str, pattern, next, i);
        if(i!=-1)
        {
            printf("'%s' @ %dth of '%s'\n", pattern, i, str);
            i++;
        }
    }
    return 0;
}

canonical_original_code:
int main()
{
    char *str = "xxabaabcacxxabaabcacdabaabcac99";
    char *pattern = "abaabcac";
    int next[256];
    int plen = strlen(pattern);
    int i;
    get_next(pattern, next);
    for(i=0;i<plen;i++)
    {
        printf("%d ", next[i]);
    }
    printf("\n");
    i=0;
    while(i!=-1)
    {
        i = kmp_index(str, pattern, next, i);
        if(i!=-1)
        {
            printf("'%s' @ %dth of '%s'\n", pattern, i, str);
            i++;
        }
    }
    return 0;
}

variable_types:
str
char *

variable_types:
pattern
char *

variable_types:
next
int [256]


Initiate

decompiled_code:
__int64 __fastcall Initiate(__int64 a1, int a2)
{
void *v2; // rax

*(_DWORD *)(a1 + 8) = a2;
v2 = malloc(8LL * a2);
*(_QWORD *)a1 = v2;
if ( !v2 )
return 0LL;
*(_DWORD *)(a1 + 12) = 0;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, int a2)
{
void *v2; // rax

*(_DWORD *)(a1 + 8) = a2;
v2 = malloc(8LL * a2);
*(_QWORD *)a1 = v2;
if ( !v2 )
return 0LL;
*(_DWORD *)(a1 + 12) = 0;
return 1LL;
}

original_code:
int Initiate(HashTable *hash,int mSize)
{
    hash->tableSize=mSize;
    hash->ht=(HashItem *)malloc(sizeof(HashItem)*mSize);
    if(hash->ht==((void *)0))
        return 0;
    else
    {
        hash->currentSize=0;
        return 1;
    }
}

canonical_original_code:
int Initiate(struct HashTable *hash, int mSize)
{
    hash->tableSize=mSize;
    hash->ht=(struct HashItem *)malloc(sizeof(HashItem)*mSize);
    if(hash->ht==((void *)0))
        return 0;
    else
    {
        hash->currentSize=0;
        return 1;
    }
}

variable_types: struct HashTable { struct HashItem { struct DataType { int key; } data; enum KindOfItem { Empty=0, Active=1, Deleted=2 } info; } *ht; int tableSize; int currentSize; } *

variable_types: mSize int

user_defined_types: struct HashTable { struct HashItem *ht; int tableSize; int currentSize; }

user_defined_types: struct HashItem { struct DataType data; enum KindOfItem info; }


Find

decompiled_code:
__int64 __fastcall Find(__int64 a1, int a2)
{
int v2; // ecx
__int64 result; // rax
_DWORD *v4; // rdx
unsigned int v5; // edx

v2 = *(_DWORD *)(a1 + 8);
result = (unsigned int)(a2 % v2);
while ( 1 )
{
v4 = (_DWORD *)(*(_QWORD *)a1 + 8LL * (int)result);
if ( v4[1] != 1 )
break;
if ( *v4 == a2 )
return result;
v5 = ((int)result + 1) % v2;
result = v5;
if ( a2 % v2 == v5 )
return (unsigned int)-v2;
}
return (unsigned int)-(int)result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, int a2)
{
int v2; // ecx
__int64 result; // rax
_DWORD *v4; // rdx
unsigned int v5; // edx

v2 = *(_DWORD *)(a1 + 8);
result = (unsigned int)(a2 % v2);
while ( 1 )
{
v4 = (_DWORD *)(*(_QWORD *)a1 + 8LL * (int)result);
if ( v4[1] != 1 )
break;
if ( *v4 == a2 )
return result;
v5 = ((int)result + 1) % v2;
result = v5;
if ( a2 % v2 == v5 )
return (unsigned int)-v2;
}
return (unsigned int)-(int)result;
}

original_code:
int Find(HashTable *hash,DataType x)
{
    int i=x.key%hash->tableSize;
    int j=i;
    while(hash->ht[j].info==Active && hash->ht[j].data.key!=x.key)
    {
        j=(j+1)%hash->tableSize;
        if(j==i)
            return -hash->tableSize;
    }
    if(hash->ht[j].info==Active)
        return j;
    else
        return -j;
}

canonical_original_code:
int Find(struct HashTable *hash, struct DataType x)
{
    int i = x.key%hash->tableSize;
    int j = i;
    while(hash->ht[j].info==Active && hash->ht[j].data.key!=x.key)
    {
        j=(j+1)%hash->tableSize;
        if(j==i)
            return -hash->tableSize;
    }
    if(hash->ht[j].info==Active)
        return j;
    else
        return -j;
}

variable_types:
x
struct DataType

user_defined_types: enum KindOfItem { Empty=0, Active=1, Deleted=2 }


Insert

original_code:
int Insert(HashTable *hash,DataType x)
{
    int i=Find(hash,x);
    if(i>0)
        return 0;
    else if(i!=-hash->tableSize)
    {
        hash->ht[-i].data=x;
        hash->ht[-i].info=Active;
        hash->currentSize++;
        return 1;
    }
    else
        return 0;
}

canonical_original_code:
int Insert(struct HashTable *hash, struct DataType x)
{
    int i = Find(hash,x);
    if(i>0)
        return 0;
    else if(i!=-hash->tableSize)
    {
        hash->ht[-i].data=x;
        hash->ht[-i].info=Active;
        hash->currentSize++;
        return 1;
    }
    else
        return 0;
}

variable_types: i int


Delete

original_code:
int Delete(HashTable *hash,DataType x)
{
    int i=Find(hash,x);
    if(i>=0)
    {
        hash->ht[i].info=Deleted;
        hash->currentSize--;
        return 1;
    }
    else
        return 0;
}

canonical_original_code:
int Delete(struct HashTable *hash, struct DataType x)
{
    int i = Find(hash,x);
    if(i>=0)
    {
        hash->ht[i].info=Deleted;
        hash->currentSize--;
        return 1;
    }
    else
        return 0;
}


Destroy

decompiled_code:
void __fastcall Destroy(void **a1)
{
free(*a1);
}

canonical_decompiled_code:
void __fastcall func11(void **a1)
{
free(*a1);
}

original_code:
void Destroy(HashTable *hash)
{
    free(hash->ht);
}

canonical_original_code:
void Destroy(struct HashTable *hash)
{
    free(hash->ht);
}