Jianmin

decompiled_code:
__int64 Jianmin()
{
char *v0; // r12
char *v1; // rbx
char *v2; // rbp
char *v3; // rbx
char *v4; // rbx
char *v5; // r13
__int64 i; // r13
char *v7; // r15
int j; // er13
char *v9; // r15
int k; // er13
char *v11; // r15
int l; // er13
char v14[24]; // [rsp+180h] [rbp-2EE8h] BYREF
char v15[24]; // [rsp+8D0h] [rbp-2798h] BYREF
char v16[624]; // [rsp+1020h] [rbp-2048h] BYREF
char v17[624]; // [rsp+1290h] [rbp-1DD8h] BYREF
char v18[24]; // [rsp+1A40h] [rbp-1628h] BYREF
char v19[24]; // [rsp+2190h] [rbp-ED8h] BYREF
char v20[1872]; // [rsp+28E0h] [rbp-788h] BYREF
char v21[56]; // [rsp+3030h] [rbp-38h] BYREF

qmemcpy(v17, &unk_404120, sizeof(v17));
qmemcpy(v16, &unk_4043A0, sizeof(v16));
v0 = v20;
v1 = v20;
do
{
__gmpf_init();
v1 += 24;
}
while ( v1 != v21 );
v2 = v19;
v3 = v19;
do
{
__gmpf_init();
v3 += 24;
}
while ( v3 != v20 );
v4 = v18;
v5 = v18;
do
{
__gmpf_init();
v5 += 24;
}
while ( v5 != v19 );
initArray((__int64)v15, (__int64)v17, 78);
initArray((__int64)v14, (__int64)v16, 78);
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init();
__gmpf_init();
__gmpf_init();
__gmp_sscanf();
__gmpf_init_set_d();
__gmpf_init_set_d();
__gmpf_init_set_d();
__gmpf_init_set_d();
__gmpf_init_set_d();
__gmpf_init_set_d();
__gmpf_init_set_d();
__gmpf_init_set_d();
__gmpf_init_set_d();
__gmpf_init_set_d();
__gmpf_init_set_d();
__gmpf_init_set_d();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
for ( i = 0LL; i != 1872; i += 24LL )
__gmpf_sub();
puts("OVERALL REACTION RATES:");
v7 = v20;
for ( j = 0; j != 78; ++j )
{
__gmp_printf();
v7 += 24;
}
__gmp_printf();
puts("\nFORWARD REACTION RATES:");
v9 = v19;
for ( k = 0; k != 78; ++k )
{
__gmp_printf();
v9 += 24;
}
puts("\nREVERSE REACTION RATES:");
v11 = v18;
for ( l = 0; l != 78; ++l )
{
__gmp_printf();
v11 += 24;
}
do
{
__gmpf_clear();
v0 += 24;
}
while ( v0 != v21 );
do
{
__gmpf_clear();
v2 += 24;
}
while ( v2 != v20 );
do
{
__gmpf_clear();
v4 += 24;
}
while ( v4 != v19 );
clearArray((__int64)v15, 78);
clearArray((__int64)v14, 78);
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
return __gmpf_clear();
}

canonical_decompiled_code:
__int64 func11()
{
char *v0; // r12
char *v1; // rbx
char *v2; // rbp
char *v3; // rbx
char *v4; // rbx
char *v5; // r13
__int64 i; // r13
char *v7; // r15
int j; // er13
char *v9; // r15
int k; // er13
char *v11; // r15
int l; // er13
char v14[24]; // [rsp+180h] [rbp-2EE8h] BYREF
char v15[24]; // [rsp+8D0h] [rbp-2798h] BYREF
char v16[624]; // [rsp+1020h] [rbp-2048h] BYREF
char v17[624]; // [rsp+1290h] [rbp-1DD8h] BYREF
char v18[24]; // [rsp+1A40h] [rbp-1628h] BYREF
char v19[24]; // [rsp+2190h] [rbp-ED8h] BYREF
char v20[1872]; // [rsp+28E0h] [rbp-788h] BYREF
char v21[56]; // [rsp+3030h] [rbp-38h] BYREF

qmemcpy(v17, &unk_404120, sizeof(v17));
qmemcpy(v16, &unk_4043A0, sizeof(v16));
v0 = v20;
v1 = v20;
do
{
__gmpf_init();
v1 += 24;
}
while ( v1 != v21 );
v2 = v19;
v3 = v19;
do
{
__gmpf_init();
v3 += 24;
}
while ( v3 != v20 );
v4 = v18;
v5 = v18;
do
{
__gmpf_init();
v5 += 24;
}
while ( v5 != v19 );
func7((__int64)v15, (__int64)v17, 78);
func7((__int64)v14, (__int64)v16, 78);
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init_set();
__gmpf_init();
__gmpf_init();
__gmpf_init();
__gmp_sscanf();
__gmpf_init_set_d();
__gmpf_init_set_d();
__gmpf_init_set_d();
__gmpf_init_set_d();
__gmpf_init_set_d();
__gmpf_init_set_d();
__gmpf_init_set_d();
__gmpf_init_set_d();
__gmpf_init_set_d();
__gmpf_init_set_d();
__gmpf_init_set_d();
__gmpf_init_set_d();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
__gmpf_mul();
for ( i = 0LL; i != 1872; i += 24LL )
__gmpf_sub();
puts("OVERALL REACTION RATES:");
v7 = v20;
for ( j = 0; j != 78; ++j )
{
__gmp_printf();
v7 += 24;
}
__gmp_printf();
puts("\nFORWARD REACTION RATES:");
v9 = v19;
for ( k = 0; k != 78; ++k )
{
__gmp_printf();
v9 += 24;
}
puts("\nREVERSE REACTION RATES:");
v11 = v18;
for ( l = 0; l != 78; ++l )
{
__gmp_printf();
v11 += 24;
}
do
{
__gmpf_clear();
v0 += 24;
}
while ( v0 != v21 );
do
{
__gmpf_clear();
v2 += 24;
}
while ( v2 != v20 );
do
{
__gmpf_clear();
v4 += 24;
}
while ( v4 != v19 );
func10((__int64)v15, 78);
func10((__int64)v14, 78);
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
return __gmpf_clear();
}

canonical_original_code:
void Jianmin(struct NLSystemContext *ctx) {
    unsigned int i;
    unsigned long exponent;
    struct __mpf_struct r[78][1];
    struct __mpf_struct r_f[78][1];
    struct __mpf_struct r_b[78][1];
    struct __mpf_struct theta_A[1]; struct __mpf_struct theta_B[1]; struct __mpf_struct theta_C[1]; struct __mpf_struct theta_D[1]; struct __mpf_struct theta_E[1]; struct __mpf_struct theta_F[1]; struct __mpf_struct theta_G[1]; struct __mpf_struct theta_I[1]; struct __mpf_struct theta_J[1]; struct __mpf_struct theta_K[1]; struct __mpf_struct theta_L[1]; struct __mpf_struct theta_M[1]; struct __mpf_struct theta_N[1]; struct __mpf_struct theta_O[1]; struct __mpf_struct theta_P[1]; struct __mpf_struct theta_Q[1]; struct __mpf_struct theta_R[1]; struct __mpf_struct theta_S[1]; struct __mpf_struct theta_T[1]; struct __mpf_struct theta_U[1]; struct __mpf_struct theta_V[1]; struct __mpf_struct theta_W[1]; struct __mpf_struct theta_X[1]; struct __mpf_struct theta_Y[1]; struct __mpf_struct theta_Z[1]; struct __mpf_struct theta_Z1[1];
    struct __mpf_struct free[1]; struct __mpf_struct theta_H[1]; struct __mpf_struct theta_OH[1]; struct __mpf_struct theta_H2O[1]; struct __mpf_struct theta_CH[1]; struct __mpf_struct theta_CH2[1]; struct __mpf_struct theta_CH3[1]; struct __mpf_struct theta_CH4[1]; struct __mpf_struct theta_CO[1]; struct __mpf_struct theta_CHO[1]; struct __mpf_struct theta_CH2O[1]; struct __mpf_struct theta_CH3O[1]; struct __mpf_struct theta_CH3OH[1];
    struct __mpf_struct K_H[1];
    struct __mpf_struct temp[1];
    struct __mpf_struct e[1];
    double in_k_f[78] = {
        6.249e7, 1.831e3, 9.567e2, 8.447e3, 1.863e5, 5.509e8, 5.982, 2.106e10, 7.139e4, 2.243e8,
        2.418e7, 1.247e8, 1.100e2, 5.791e12, 1.114e9, 9.955e3, 5.396e2, 3.706e3, 2.705e8, 7.040e9,
        5.501e8, 2.335e4, 1.630e10, 6.622e2, 6.464e2, 2.109e8, 8.910, 3.268e5, 1.890e5, 9.014e11,
        7.631e3, 6.303e2, 1.075e2, 9.362e7, 9.540e4, 2.636e8, 3.368e8, 1.615e10, 3.290e-3, 1.004e3,
        1.457e5, 2.380e2, 3.845e7, 3.778e7, 9.432e3, 1.666e3, 3.094e8, 1.557e7, 6.575e1, 1.372e2,
          3.003, 3.044e13, 1.047e16, 2.092e12, 1.020e3, 0, 0, 0, 0, 0,
              0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
              0, 5.056e9, 1.396e9, 4.831e9, 9.712e6, 4.000, 2.403e6, 1.404e-1};
    double in_k_b[78] = {
         5.885e4, 3.070e6, 2.885e7, 8.560e1, 8.721, 3.131e5, 6.828e-12, 4.823e3, 1.020e4, 1.566,
         5.024e5, 3.056e6, 6.318e-1, 1.247e8, 8.518e-3, 6.388e10, 1.625e7, 1.514e5, 4.864e5, 1.941e2,
         1.750e6, 8.974e1, 5.505e-2, 1.555e1, 2.380e7, 1.986, 1.865e7, 1.668, 1.108e7, 1.962,
        1.902e11, 5.235e1, 1.311e7, 2.729, 2.606e8, 5.388e6, 4.689, 1.170e4, 2.457e-15, 1.833e-6,
        7.225e-5, 5.142e8, 4.046e12, 9.921e9, 3.620e7, 2.431e7, 1.802e13, 2.232e8, 7.117e7, 6.635e7,
         7.879e7, 1.230e8, 1.740e8, 1.640e8, 6.696e7, 0, 0, 0, 0, 0,
               0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
               0, 2.126e8, 1.611, 1.848e6, 1.828e2, 3.558e8, 1.593e5, 1.336e10};
    struct __mpf_struct k_f[78][1];
    struct __mpf_struct k_b[78][1];
    struct __mpf_struct p_A[1]; struct __mpf_struct p_H2[1]; struct __mpf_struct p_M[1]; struct __mpf_struct p_S[1]; struct __mpf_struct p_X[1]; struct __mpf_struct p_K[1]; struct __mpf_struct p_CO[1]; struct __mpf_struct p_H2O[1]; struct __mpf_struct p_CH4[1]; struct __mpf_struct p_CH3OH[1]; struct __mpf_struct KB[1]; struct __mpf_struct T[1];
    double partialPressures[12] = {1.0, 1.0, 1.0e-5, 1.0e-5, 1.0e-5, 1.0e-5,
                                1.0e-6, 0.0, 0.0, 0.0, 8.6173324e-5, 573};
    for(i = 0; i < 78; i++) {
        __gmpf_init(r[i]);
    }
    for(i = 0; i < 78; i++) {
        __gmpf_init(r_f[i]);
    }
    for(i = 0; i < 78; i++) {
        __gmpf_init(r_b[i]);
    }
    initArray(k_f, in_k_f, 78);
    initArray(k_b, in_k_b, 78);
    __gmpf_init_set(theta_A , ctx->state[0]);
    __gmpf_init_set(theta_E , ctx->state[1]);
    __gmpf_init_set(theta_F , ctx->state[2]);
    __gmpf_init_set(theta_G , ctx->state[3]);
    __gmpf_init_set(theta_I , ctx->state[4]);
    __gmpf_init_set(theta_L , ctx->state[5]);
    __gmpf_init_set(theta_M , ctx->state[6]);
    __gmpf_init_set(theta_N , ctx->state[7]);
    __gmpf_init_set(theta_O , ctx->state[8]);
    __gmpf_init_set(theta_R , ctx->state[9]);
    __gmpf_init_set(theta_S , ctx->state[10]);
    __gmpf_init_set(theta_U , ctx->state[11]);
    __gmpf_init_set(theta_V , ctx->state[12]);
    __gmpf_init_set(theta_X , ctx->state[13]);
    __gmpf_init_set(free , ctx->state[14]);
    __gmpf_init_set(theta_H , ctx->state[15]);
    __gmpf_init_set(theta_OH , ctx->state[16]);
    __gmpf_init_set(theta_H2O , ctx->state[17]);
    __gmpf_init_set(theta_CH , ctx->state[18]);
    __gmpf_init_set(theta_CH2 , ctx->state[19]);
    __gmpf_init_set(theta_CH3 , ctx->state[20]);
    __gmpf_init_set(theta_CH4 , ctx->state[21]);
    __gmpf_init_set(theta_CHO , ctx->state[22]);
    __gmpf_init_set(theta_CH2O , ctx->state[23]);
    __gmpf_init_set(theta_CH3O , ctx->state[24]);
    __gmpf_init_set(theta_CH3OH , ctx->state[25]);
    __gmpf_init_set(theta_W , ctx->state[26]);
    __gmpf_init_set(theta_T , ctx->state[27]);
    __gmpf_init_set(theta_B , ctx->state[28]);
    __gmpf_init_set(theta_J , ctx->state[29]);
    __gmpf_init_set(theta_P , ctx->state[30]);
    __gmpf_init_set(theta_C , ctx->state[31]);
    __gmpf_init_set(theta_D , ctx->state[32]);
    __gmpf_init_set(theta_K , ctx->state[33]);
    __gmpf_init_set(theta_Q , ctx->state[34]);
    __gmpf_init_set(theta_Y , ctx->state[35]);
    __gmpf_init_set(theta_Z , ctx->state[36]);
    __gmpf_init_set(theta_Z1 , ctx->state[37]);
    __gmpf_init_set(theta_CO , ctx->state[38]);
    __gmpf_init(K_H);
    __gmpf_init(temp);
    __gmpf_init(e);
    __gmp_sscanf("2.71828182845904523536028747135266249775724709369995", "%F", e);
    __gmpf_init_set_d(p_A , partialPressures[0]);
    __gmpf_init_set_d(p_H2 , partialPressures[1]);
    __gmpf_init_set_d(p_M , partialPressures[2]);
    __gmpf_init_set_d(p_S , partialPressures[3]);
    __gmpf_init_set_d(p_X , partialPressures[4]);
    __gmpf_init_set_d(p_K , partialPressures[5]);
    __gmpf_init_set_d(p_CO , partialPressures[6]);
    __gmpf_init_set_d(p_H2O , partialPressures[7]);
    __gmpf_init_set_d(p_CH4 , partialPressures[8]);
    __gmpf_init_set_d(p_CH3OH , partialPressures[9]);
    __gmpf_init_set_d(KB , partialPressures[10]);
    __gmpf_init_set_d(T , partialPressures[11]);
    __gmpf_mul( r_f[0], k_f[0], p_A);
    __gmpf_mul( r_f[0], r_f[0], free);
    __gmpf_mul( r_f[0], r_f[0], free);
    __gmpf_mul( r_f[0], r_f[0], free);
    __gmpf_mul( r_f[0], r_f[0], free);
    __gmpf_mul( r_f[1], k_f[1], theta_A);
    __gmpf_mul( r_f[1], r_f[1], theta_H);
    __gmpf_mul( r_f[4], k_f[4], theta_A);
    __gmpf_mul( r_f[4], r_f[4], free);
    __gmpf_mul( r_f[5], k_f[5], theta_A);
    __gmpf_mul( r_f[5], r_f[5], free);
    __gmpf_mul( r_f[6], k_f[6], theta_A);
    __gmpf_mul( r_f[6], r_f[6], free);
    __gmpf_mul( r_f[7], k_f[7], theta_A);
    __gmpf_mul( r_f[7], r_f[7], free);
    __gmpf_mul( r_f[8], k_f[8], theta_B);
    __gmpf_mul( r_f[8], r_f[8], free);
    __gmpf_mul( r_f[8], r_f[8], free);
    __gmpf_mul( r_f[11], k_f[11], theta_E);
    __gmpf_mul( r_f[11], r_f[11], theta_H);
    __gmpf_mul( r_f[12], k_f[12], theta_F);
    __gmpf_mul( r_f[12], r_f[12], free);
    __gmpf_mul( r_f[13], k_f[13], theta_F);
    __gmpf_mul( r_f[13], r_f[13], free);
    __gmpf_mul( r_f[14], k_f[14], theta_F);
    __gmpf_mul( r_f[15], k_f[15], theta_G);
    __gmpf_mul( r_f[15], r_f[15], theta_H);
    __gmpf_mul( r_f[16], k_f[16], theta_G);
    __gmpf_mul( r_f[16], r_f[16], free);
    __gmpf_mul( r_f[17], k_f[17], theta_I);
    __gmpf_mul( r_f[17], r_f[17], free);
    __gmpf_mul( r_f[18], k_f[18], theta_I);
    __gmpf_mul( r_f[18], r_f[18], free);
    __gmpf_mul( r_f[18], r_f[18], free);
    __gmpf_mul( r_f[19], k_f[19], theta_J);
    __gmpf_mul( r_f[21], k_f[21], theta_L);
    __gmpf_mul( r_f[21], r_f[21], free);
    __gmpf_mul( r_f[22], k_f[22], theta_L);
    __gmpf_mul( r_f[22], r_f[22], free);
    __gmpf_mul( r_f[23], k_f[23], theta_M);
    __gmpf_mul( r_f[23], r_f[23], free);
    __gmpf_mul( r_f[24], k_f[24], theta_M);
    __gmpf_mul( r_f[24], r_f[24], theta_H);
    __gmpf_mul( r_f[25], k_f[25], theta_N);
    __gmpf_mul( r_f[25], r_f[25], theta_H);
    __gmpf_mul( r_f[26], k_f[26], theta_O);
    __gmpf_mul( r_f[26], r_f[26], free);
    __gmpf_mul( r_f[27], k_f[27], theta_O);
    __gmpf_mul( r_f[27], r_f[27], free);
    __gmpf_mul( r_f[28], k_f[28], theta_P);
    __gmpf_mul( r_f[28], r_f[28], theta_H);
    __gmpf_mul( r_f[30], k_f[30], theta_R);
    __gmpf_mul( r_f[30], r_f[30], theta_H);
    __gmpf_mul( r_f[31], k_f[31], theta_S);
    __gmpf_mul( r_f[31], r_f[31], free);
    __gmpf_mul( r_f[32], k_f[32], theta_S);
    __gmpf_mul( r_f[32], r_f[32], theta_H);
    __gmpf_mul( r_f[33], k_f[33], theta_T);
    __gmpf_mul( r_f[33], r_f[33], free);
    __gmpf_mul( r_f[34], k_f[34], theta_U);
    __gmpf_mul( r_f[34], r_f[34], theta_H);
    __gmpf_mul( r_f[35], k_f[35], theta_V);
    __gmpf_mul( r_f[35], r_f[35], theta_H);
    __gmpf_mul( r_f[36], k_f[36], theta_W);
    __gmpf_mul( r_f[37], k_f[37], theta_F);
    __gmpf_mul( r_f[37], r_f[37], free);
    __gmpf_mul( r_f[39], k_f[39], theta_I);
    __gmpf_mul( r_f[39], r_f[39], free);
    __gmpf_mul( r_f[39], r_f[39], free);
    __gmpf_mul( r_f[40], k_f[40], theta_B);
    __gmpf_mul( r_f[40], r_f[40], free);
    __gmpf_mul( r_f[40], r_f[40], free);
    __gmpf_mul( r_f[41], k_f[41], theta_CH3O);
    __gmpf_mul( r_f[41], r_f[41], theta_H);
    __gmpf_mul( r_f[42], k_f[42], theta_CH);
    __gmpf_mul( r_f[42], r_f[42], theta_H);
    __gmpf_mul( r_f[43], k_f[43], theta_CH2);
    __gmpf_mul( r_f[43], r_f[43], theta_H);
    __gmpf_mul( r_f[44], k_f[44], theta_CH3);
    __gmpf_mul( r_f[44], r_f[44], theta_H);
    __gmpf_mul( r_f[45], k_f[45], theta_OH);
    __gmpf_mul( r_f[45], r_f[45], theta_H);
    __gmpf_mul( r_f[46], k_f[46], theta_CHO);
    __gmpf_mul( r_f[46], r_f[46], theta_H);
    __gmpf_mul( r_f[47], k_f[47], theta_CH2O);
    __gmpf_mul( r_f[47], r_f[47], theta_H);
    __gmpf_mul( r_f[48], k_f[48], theta_S);
    __gmpf_mul( r_f[49], k_f[49], theta_M);
    __gmpf_mul( r_f[50], k_f[50], theta_X);
    __gmpf_mul( r_f[51], k_f[51], theta_CH3OH);
    __gmpf_mul( r_f[52], k_f[52], theta_CH4);
    __gmpf_mul( r_f[53], k_f[53], theta_H2O);
    __gmpf_mul( r_f[54], k_f[54], theta_K);
    __gmpf_mul( r_f[71], k_f[71], theta_O);
    __gmpf_mul( r_f[71], r_f[71], free);
    __gmpf_mul( r_f[72], k_f[72], theta_Z);
    __gmpf_mul( r_f[72], r_f[72], free);
    __gmpf_mul( r_f[73], k_f[73], theta_Z);
    __gmpf_mul( r_f[73], r_f[73], free);
    __gmpf_mul( r_f[74], k_f[74], theta_Z1);
    __gmpf_mul( r_f[75], k_f[75], theta_G);
    __gmpf_mul( r_f[75], r_f[75], theta_H);
    __gmpf_mul( r_f[76], k_f[76], theta_Y);
    __gmpf_mul( r_f[76], r_f[76], free);
    __gmpf_mul( r_f[77], k_f[77], theta_CO);
    __gmpf_mul( r_f[77], r_f[77], theta_H);
    __gmpf_mul( r_f[2], k_f[2], theta_A);
    __gmpf_mul( r_f[2], r_f[2], theta_H);
    __gmpf_mul( r_f[3], k_f[3], theta_A);
    __gmpf_mul( r_f[3], r_f[3], free);
    __gmpf_mul( r_f[9], k_f[9], theta_C);
    __gmpf_mul( r_f[9], r_f[9], free);
    __gmpf_mul( r_f[10], k_f[10], theta_D);
    __gmpf_mul( r_f[10], r_f[10], theta_H);
    __gmpf_mul( r_f[20], k_f[20], theta_K);
    __gmpf_mul( r_f[20], r_f[20], free);
    __gmpf_mul( r_f[29], k_f[29], theta_Q);
    __gmpf_mul( r_f[29], r_f[29], free);
    __gmpf_mul( r_b[0], k_b[0], theta_A);
    __gmpf_mul( r_b[1], k_b[1], theta_B);
    __gmpf_mul( r_b[1], r_b[1], free);
    __gmpf_mul( r_b[4], k_b[4], theta_E);
    __gmpf_mul( r_b[4], r_b[4], theta_CH3O);
    __gmpf_mul( r_b[5], k_b[5], theta_F);
    __gmpf_mul( r_b[5], r_b[5], theta_H);
    __gmpf_mul( r_b[6], k_b[6], theta_G);
    __gmpf_mul( r_b[6], r_b[6], theta_CH3);
    __gmpf_mul( r_b[7], k_b[7], theta_I);
    __gmpf_mul( r_b[7], r_b[7], theta_H);
    __gmpf_mul( r_b[8], k_b[8], theta_J);
    __gmpf_mul( r_b[8], r_b[8], theta_H);
    __gmpf_mul( r_b[11], k_b[11], theta_S);
    __gmpf_mul( r_b[11], r_b[11], free);
    __gmpf_mul( r_b[12], k_b[12], theta_E);
    __gmpf_mul( r_b[12], r_b[12], theta_CH2O);
    __gmpf_mul( r_b[13], k_b[13], theta_L);
    __gmpf_mul( r_b[13], r_b[13], theta_H);
    __gmpf_mul( r_b[14], k_b[14], theta_G);
    __gmpf_mul( r_b[14], r_b[14], theta_CH2);
    __gmpf_mul( r_b[15], k_b[15], theta_M);
    __gmpf_mul( r_b[15], r_b[15], free);
    __gmpf_mul( r_b[16], k_b[16], theta_N);
    __gmpf_mul( r_b[16], r_b[16], theta_OH);
    __gmpf_mul( r_b[17], k_b[17], theta_N);
    __gmpf_mul( r_b[17], r_b[17], theta_CH3O);
    __gmpf_mul( r_b[18], k_b[18], theta_O);
    __gmpf_mul( r_b[18], r_b[18], theta_H);
    __gmpf_mul( r_b[19], k_b[19], theta_P);
    __gmpf_mul( r_b[19], r_b[19], theta_CH2);
    __gmpf_mul( r_b[21], k_b[21], theta_E);
    __gmpf_mul( r_b[21], r_b[21], theta_CHO);
    __gmpf_mul( r_b[22], k_b[22], theta_G);
    __gmpf_mul( r_b[22], r_b[22], theta_CH);
    __gmpf_mul( r_b[23], k_b[23], theta_E);
    __gmpf_mul( r_b[23], r_b[23], theta_OH);
    __gmpf_mul( r_b[24], k_b[24], theta_T);
    __gmpf_mul( r_b[25], k_b[25], theta_R);
    __gmpf_mul( r_b[25], r_b[25], free);
    __gmpf_mul( r_b[26], k_b[26], theta_N);
    __gmpf_mul( r_b[26], r_b[26], theta_CH2O);
    __gmpf_mul( r_b[27], k_b[27], theta_U);
    __gmpf_mul( r_b[27], r_b[27], theta_CH2);
    __gmpf_mul( r_b[28], k_b[28], theta_T);
    __gmpf_mul( r_b[28], r_b[28], free);
    __gmpf_mul( r_b[30], k_b[30], theta_S);
    __gmpf_mul( r_b[30], r_b[30], free);
    __gmpf_mul( r_b[31], k_b[31], theta_V);
    __gmpf_mul( r_b[31], r_b[31], theta_OH);
    __gmpf_mul( r_b[32], k_b[32], theta_W);
    __gmpf_mul( r_b[32], r_b[32], free);
    __gmpf_mul( r_b[33], k_b[33], theta_S);
    __gmpf_mul( r_b[33], r_b[33], theta_OH);
    __gmpf_mul( r_b[34], k_b[34], theta_G);
    __gmpf_mul( r_b[34], r_b[34], free);
    __gmpf_mul( r_b[34], r_b[34], free);
    __gmpf_mul( r_b[35], k_b[35], theta_X);
    __gmpf_mul( r_b[35], r_b[35], free);
    __gmpf_mul( r_b[35], r_b[35], free);
    __gmpf_mul( r_b[36], k_b[36], theta_X);
    __gmpf_mul( r_b[36], r_b[36], theta_OH);
    __gmpf_mul( r_b[37], k_b[37], theta_O);
    __gmpf_mul( r_b[37], r_b[37], theta_H);
    __gmpf_mul( r_b[39], k_b[39], theta_U);
    __gmpf_mul( r_b[39], r_b[39], theta_CH3);
    __gmpf_mul( r_b[40], k_b[40], theta_S);
    __gmpf_mul( r_b[40], r_b[40], theta_CH3O);
    __gmpf_mul( r_b[41], k_b[41], theta_CH3OH);
    __gmpf_mul( r_b[41], r_b[41], free);
    __gmpf_mul( r_b[42], k_b[42], theta_CH2);
    __gmpf_mul( r_b[42], r_b[42], free);
    __gmpf_mul( r_b[43], k_b[43], theta_CH3);
    __gmpf_mul( r_b[43], r_b[43], free);
    __gmpf_mul( r_b[44], k_b[44], theta_CH4);
    __gmpf_mul( r_b[44], r_b[44], free);
    __gmpf_mul( r_b[45], k_b[45], theta_H2O);
    __gmpf_mul( r_b[45], r_b[45], free);
    __gmpf_mul( r_b[46], k_b[46], theta_CH2O);
    __gmpf_mul( r_b[46], r_b[46], free);
    __gmpf_mul( r_b[47], k_b[47], theta_CH3O);
    __gmpf_mul( r_b[47], r_b[47], free);
    __gmpf_mul( r_b[47], r_b[47], free);
    __gmpf_mul( r_b[48], k_b[48], p_S);
    __gmpf_mul( r_b[48], r_b[48], free);
    __gmpf_mul( r_b[48], r_b[48], free);
    __gmpf_mul( r_b[48], r_b[48], free);
    __gmpf_mul( r_b[48], r_b[48], free);
    __gmpf_mul( r_b[49], k_b[49], p_M);
    __gmpf_mul( r_b[49], r_b[49], free);
    __gmpf_mul( r_b[49], r_b[49], free);
    __gmpf_mul( r_b[49], r_b[49], free);
    __gmpf_mul( r_b[49], r_b[49], free);
    __gmpf_mul( r_b[50], k_b[50], p_X);
    __gmpf_mul( r_b[50], r_b[50], free);
    __gmpf_mul( r_b[50], r_b[50], free);
    __gmpf_mul( r_b[50], r_b[50], free);
    __gmpf_mul( r_b[51], k_b[51], p_CH3OH);
    __gmpf_mul( r_b[51], r_b[51], free);
    __gmpf_mul( r_b[52], k_b[52], p_CH4);
    __gmpf_mul( r_b[52], r_b[52], free);
    __gmpf_mul( r_b[53], k_b[53], p_H2O);
    __gmpf_mul( r_b[53], r_b[53], free);
    __gmpf_mul( r_b[54], k_b[54], p_K);
    __gmpf_mul( r_b[54], r_b[54], free);
    __gmpf_mul( r_b[54], r_b[54], free);
    __gmpf_mul( r_b[54], r_b[54], free);
    __gmpf_mul( r_b[54], r_b[54], free);
    __gmpf_mul( r_b[71], k_b[71], theta_Z);
    __gmpf_mul( r_b[71], r_b[71], theta_H);
    __gmpf_mul( r_b[72], k_b[72], theta_U);
    __gmpf_mul( r_b[72], r_b[72], theta_CH);
    __gmpf_mul( r_b[73], k_b[73], theta_Z1);
    __gmpf_mul( r_b[73], r_b[73], theta_H);
    __gmpf_mul( r_b[74], k_b[74], theta_N);
    __gmpf_mul( r_b[74], r_b[74], theta_CO);
    __gmpf_mul( r_b[75], k_b[75], theta_Y);
    __gmpf_mul( r_b[75], r_b[75], free);
    __gmpf_mul( r_b[76], k_b[76], theta_R);
    __gmpf_mul( r_b[76], r_b[76], theta_OH);
    __gmpf_mul( r_b[77], k_b[77], theta_CHO);
    __gmpf_mul( r_b[2], k_b[2], theta_C);
    __gmpf_mul( r_b[2], r_b[2], free);
    __gmpf_mul( r_b[3], k_b[3], theta_D);
    __gmpf_mul( r_b[3], r_b[3], theta_OH);
    __gmpf_mul( r_b[9], k_b[9], theta_K);
    __gmpf_mul( r_b[9], r_b[9], theta_OH);
    __gmpf_mul( r_b[10], k_b[10], theta_K);
    __gmpf_mul( r_b[10], r_b[10], free);
    __gmpf_mul( r_b[20], k_b[20], theta_Q);
    __gmpf_mul( r_b[20], r_b[20], theta_H);
    __gmpf_mul( r_b[29], k_b[29], theta_R);
    __gmpf_mul( r_b[29], r_b[29], theta_CH2);
    for(i = 0; i < 78; i++) {
        __gmpf_sub( r[i], r_f[i], r_b[i]);
    }
    printf("OVERALL REACTION RATES:\n");
    for(i = 0; i < 78; i++) {
        __gmp_printf("r[%d] = %Fg\n", i, r[i]);
    }
    __gmp_printf("K_H = %Fg\n", K_H);
    printf("\nFORWARD REACTION RATES:\n");
    for(i = 0; i < 78; i++) {
        __gmp_printf("r_f[%d] = %Fg\n", i, r_f[i]);
    }
    printf("\nREVERSE REACTION RATES:\n");
    for(i = 0; i < 78; i++) {
        __gmp_printf("r_b[%d] = %Fg\n", i, r_b[i]);
    }
    for(i = 0; i < 78; i++) {
        __gmpf_clear(r[i]);
    }
    for(i = 0; i < 78; i++) {
        __gmpf_clear(r_f[i]);
    }
    for(i = 0; i < 78; i++) {
        __gmpf_clear(r_b[i]);
    }
    clearArray(k_f, 78);
    clearArray(k_b, 78);
    __gmpf_clear(theta_A);
    __gmpf_clear(theta_E);
    __gmpf_clear(theta_F);
    __gmpf_clear(theta_G);
    __gmpf_clear(theta_I);
    __gmpf_clear(theta_L);
    __gmpf_clear(theta_M);
    __gmpf_clear(theta_N);
    __gmpf_clear(theta_O);
    __gmpf_clear(theta_R);
    __gmpf_clear(theta_S);
    __gmpf_clear(theta_U);
    __gmpf_clear(theta_V);
    __gmpf_clear(theta_X);
    __gmpf_clear(free);
    __gmpf_clear(theta_H);
    __gmpf_clear(theta_OH);
    __gmpf_clear(theta_H2O);
    __gmpf_clear(theta_CH);
    __gmpf_clear(theta_CH2);
    __gmpf_clear(theta_CH3);
    __gmpf_clear(theta_CH4);
    __gmpf_clear(theta_CHO);
    __gmpf_clear(theta_CH2O);
    __gmpf_clear(theta_CH3O);
    __gmpf_clear(theta_CH3OH);
    __gmpf_clear(theta_W);
    __gmpf_clear(theta_T);
    __gmpf_clear(theta_B);
    __gmpf_clear(theta_J);
    __gmpf_clear(theta_P);
    __gmpf_clear(theta_C);
    __gmpf_clear(theta_D);
    __gmpf_clear(theta_K);
    __gmpf_clear(theta_Q);
    __gmpf_clear(theta_Y);
    __gmpf_clear(theta_Z);
    __gmpf_clear(theta_Z1);
    __gmpf_clear(theta_CO);
    __gmpf_clear(K_H);
    __gmpf_clear(temp);
    __gmpf_clear(e);
    __gmpf_clear(p_A);
    __gmpf_clear(p_H2);
    __gmpf_clear(p_M);
    __gmpf_clear(p_S);
    __gmpf_clear(p_X);
    __gmpf_clear(p_K);
    __gmpf_clear(p_CO);
    __gmpf_clear(p_H2O);
    __gmpf_clear(p_CH4);
    __gmpf_clear(p_CH3OH);
    __gmpf_clear(KB);
    __gmpf_clear(T);
}

variable_types:
exponent
unsigned long

variable_types: struct __mpf_struct { int _mp_prec; int _mp_size; long _mp_exp; unsigned long *_mp_d; } [78][1]

variable_types: struct __mpf_struct { int _mp_prec; int _mp_size; long _mp_exp; unsigned long *_mp_d; } [1]

variable_types:
partialPressures
double [12]


main

canonical_name: main

repo: philipaconrad/theta

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
_QWORD v4[5]; // [rsp+0h] [rbp-28h] BYREF

__gmpf_set_default_prec();
initArray((__int64)&state, (__int64)&in_systemVars, 39);
initArray((__int64)&minBounds, (__int64)&in_minBounds, 39);
initArray((__int64)&maxBounds, (__int64)&in_maxBounds, 39);
initNLSystemContext((__int64)v4, (__int64)&state, (__int64)&minBounds, (__int64)&maxBounds, 39);
Jianmin(v4);
if ( !(unsigned int)checkBounds(v4, 39) )
puts("\nThe system strayed outside of its constraints! Please check your math.");
clearArray((__int64)&state, 39);
clearArray((__int64)&minBounds, 39);
clearArray((__int64)&maxBounds, 39);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
_QWORD v4[5]; // [rsp+0h] [rbp-28h] BYREF

__gmpf_set_default_prec();
func7((__int64)&state, (__int64)&in_systemVars, 39);
func7((__int64)&minBounds, (__int64)&in_minBounds, 39);
func7((__int64)&maxBounds, (__int64)&in_maxBounds, 39);
func8((__int64)v4, (__int64)&state, (__int64)&minBounds, (__int64)&maxBounds, 39);
func11(v4);
if ( !(unsigned int)func9(v4, 39) )
puts("\nThe system strayed outside of its constraints! Please check your math.");
func10((__int64)&state, 39);
func10((__int64)&minBounds, 39);
func10((__int64)&maxBounds, 39);
return 0;
}

original_code:
int main(int argc, char** argv[]) {
    NLSystemContext ctx;
    bool inBounds;
    uint32 i;
    __gmpf_set_default_prec(256);
    initArray(state, in_systemVars, 39);
    initArray(minBounds, in_minBounds, 39);
    initArray(maxBounds, in_maxBounds, 39);
    initNLSystemContext(&ctx, state, minBounds, maxBounds, 39);
    Jianmin(&ctx);
    inBounds = checkBounds(&ctx, 39);
    if(inBounds == 0) {
        printf("\nThe system strayed outside of its constraints! Please check your math.\n");
    }
    clearArray(state, 39);
    clearArray(minBounds, 39);
    clearArray(maxBounds, 39);
    return 0;
}

canonical_original_code:
int main(int argc, char **argv[]) {
    struct NLSystemContext ctx;
    int inBounds;
    unsigned int i;
    __gmpf_set_default_prec(256);
    initArray(state, in_systemVars, 39);
    initArray(minBounds, in_minBounds, 39);
    initArray(maxBounds, in_maxBounds, 39);
    initNLSystemContext(&ctx, state, minBounds, maxBounds, 39);
    Jianmin(&ctx);
    inBounds = checkBounds(&ctx, 39);
    if(inBounds == 0) {
        printf("\nThe system strayed outside of its constraints! Please check your math.\n");
    }
    clearArray(state, 39);
    clearArray(minBounds, 39);
    clearArray(maxBounds, 39);
    return 0;
}

variable_types: argc int

variable_types:
argv
char **[]

variable_types: struct NLSystemContext { struct __mpf_struct { int _mp_prec; int _mp_size; long _mp_exp; unsigned long *_mp_d; } (*state)[1]; struct __mpf_struct (*minBounds)[1]; struct __mpf_struct (*maxBounds)[1]; unsigned int listSize; }

variable_types: inBounds int

variable_types:
i
unsigned int

return_type: int

user_defined_types: struct NLSystemContext { struct __mpf_struct (*state)[1]; struct __mpf_struct (*minBounds)[1]; struct __mpf_struct (*maxBounds)[1]; unsigned int listSize; }


repo: philippedeswert/sp-smaps

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

result = strdup(a2);
*(_QWORD *)a1 = result;
*(_DWORD *)(a1 + 8) = a3;
return result;
}

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

result = strdup(a2);
*(_QWORD *)a1 = result;
*(_DWORD *)(a1 + 8) = a3;
return result;
}

original_code:
void
symbol_ctor(symbol_t *self, const char *key, int val)
{
  self->symbol_key = strdup(key);
  self->symbol_val = val;
}

canonical_original_code:
void symbol_ctor(struct symbol_t *self, char *key, int val)
{
  self->symbol_key = strdup(key);
  self->symbol_val = val;
}

variable_types: struct symbol_t { char *symbol_key; int symbol_val; } *

variable_types:
key
char *

variable_types: val int

return_type: void


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

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

original_code:
void
symbol_dtor(symbol_t *self)
{
  free(self->symbol_key);
}

canonical_original_code:
void symbol_dtor(struct symbol_t *self)
{
  free(self->symbol_key);
}

user_defined_types: struct symbol_t { char *symbol_key; int symbol_val; }


decompiled_code:
void *__fastcall symbol_create(const char *a1, int a2)
{
void *v2; // rbx

v2 = calloc(1uLL, 0x10uLL);
symbol_ctor((__int64)v2, a1, a2);
return v2;
}

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

v2 = calloc(1uLL, 0x10uLL);
func0((__int64)v2, a1, a2);
return v2;
}

original_code:
symbol_t *
symbol_create(const char *key, int val)
{
  symbol_t *self = calloc(1, sizeof *self);
  symbol_ctor(self, key, val);
  return self;
}

canonical_original_code:
struct symbol_t *symbol_create(char *key, int val)
{
  struct symbol_t *self = calloc(1, sizeof *self);
  symbol_ctor(self, key, val);
  return self;
}

return_type: struct symbol_t { char *symbol_key; int symbol_val; } *


decompiled_code:
void __fastcall symbol_delete(void *ptr)
{
if ( ptr )
{
symbol_dtor((void **)ptr);
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func3(void *ptr)
{
if ( ptr )
{
func1((void **)ptr);
free(ptr);
}
}

original_code:
void
symbol_delete(symbol_t *self)
{
  if( self != 0 )
  {
    symbol_dtor(self);
    free(self);
  }
}

canonical_original_code:
void symbol_delete(struct symbol_t *self)
{
  if( self != 0 )
  {
    symbol_dtor(self);
    free(self);
  }
}


decompiled_code:
void __fastcall symbol_delete_cb(void *a1)
{
symbol_delete(a1);
}

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

original_code:
void
symbol_delete_cb(void *self)
{
  symbol_delete(self);
}

variable_types:
self
void *


decompiled_code:
void __fastcall symtab_dtor(__int64 a1)
{
unsigned __int64 v1; // rbx

if ( *(_QWORD *)(a1 + 8) )
{
v1 = 0LL;
do
symbol_dtor((void **)(*(_QWORD *)a1 + 16 * v1++));
while ( *(_QWORD *)(a1 + 8) > v1 );
}
free(*(void **)a1);
}

original_code:
void
symtab_dtor(symtab_t *self)
{
  for( size_t i = 0; i < self->symtab_count; ++i )
  {
    symbol_dtor(&self->symtab_entry[i]);
  }
  free(self->symtab_entry);
}

canonical_original_code:
void symtab_dtor(struct symtab_t *self)
{
  for( unsigned long i = 0; i < self->symtab_count; ++i )
  {
    symbol_dtor(&self->symtab_entry[i]);
  }
  free(self->symtab_entry);
}

variable_types: struct symtab_t { struct symbol_t { char *symbol_key; int symbol_val; } *symtab_entry; unsigned long symtab_count; unsigned long symtab_alloc; } *

variable_types:
i
unsigned long

user_defined_types: struct symtab_t { struct symbol_t *symtab_entry; unsigned long symtab_count; unsigned long symtab_alloc; }


decompiled_code:
_QWORD *symtab_create()
{
_QWORD *v0; // rbx

v0 = calloc(1uLL, 0x18uLL);
symtab_ctor(v0);
return v0;
}

canonical_decompiled_code:
_QWORD *func7()
{
_QWORD *v0; // rbx

v0 = calloc(1uLL, 0x18uLL);
func5(v0);
return v0;
}

original_code:
symtab_t *
symtab_create(void)
{
  symtab_t *self = calloc(1, sizeof *self);
  symtab_ctor(self);
  return self;
}

canonical_original_code:
struct symtab_t *symtab_create()
{
  struct symtab_t *self = calloc(1, sizeof *self);
  symtab_ctor(self);
  return self;
}

return_type: struct symtab_t { struct symbol_t { char *symbol_key; int symbol_val; } *symtab_entry; unsigned long symtab_count; unsigned long symtab_alloc; } *


decompiled_code:
void __fastcall symtab_delete(void *ptr)
{
if ( ptr )
{
symtab_dtor((__int64)ptr);
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func8(void *ptr)
{
if ( ptr )
{
func6((__int64)ptr);
free(ptr);
}
}

original_code:
void
symtab_delete(symtab_t *self)
{
  if( self != 0 )
  {
    symtab_dtor(self);
    free(self);
  }
}

canonical_original_code:
void symtab_delete(struct symtab_t *self)
{
  if( self != 0 )
  {
    symtab_dtor(self);
    free(self);
  }
}


decompiled_code:
void __fastcall symtab_delete_cb(void *a1)
{
symtab_delete(a1);
}

canonical_decompiled_code:
void __fastcall func9(void *a1)
{
func8(a1);
}

original_code:
void
symtab_delete_cb(void *self)
{
  symtab_delete(self);
}


decompiled_code:
__int64 __fastcall symtab_get(__int64 *a1, const char *a2, unsigned int a3)
{
unsigned __int64 v3; // r12
__int64 v4; // r15
unsigned __int64 v5; // r14
__int64 v6; // rbp
int v7; // eax

v3 = a1[1];
if ( !v3 )
return a3;
v4 = *a1;
v5 = 0LL;
do
{
v6 = v4 + 16 * ((v5 + v3) >> 1);
v7 = strcmp(*(const char **)v6, a2);
if ( v7 < 0 )
{
v5 = ((v5 + v3) >> 1) + 1;
}
else
{
if ( v7 <= 0 )
return *(unsigned int *)(v6 + 8);
v3 = (v5 + v3) >> 1;
}
}
while ( v5 < v3 );
return a3;
}

original_code:
int
symtab_get(symtab_t *self, const char *str, int def)
{
  size_t lo = 0;
  size_t hi = self->symtab_count;
  while( lo < hi )
  {
    size_t i = (lo + hi)/2;
    symbol_t *s = &self->symtab_entry[i];
    int r = strcmp(s->symbol_key, str);
    if( r < 0 ) { lo = i + 1; continue; }
    if( r > 0 ) { hi = i + 0; continue; }
    return s->symbol_val;
  }
  return def;
}

canonical_original_code:
int symtab_get(struct symtab_t *self, char *str, int def)
{
  unsigned long lo = 0;
  unsigned long hi = self->symtab_count;
  while( lo < hi )
  {
    unsigned long i = (lo + hi)/2;
    struct symbol_t *s = &self->symtab_entry[i];
    int r = strcmp(s->symbol_key, str);
    if( r < 0 ) { lo = i + 1; continue; }
    if( r > 0 ) { hi = i + 0; continue; }
    return s->symbol_val;
  }
  return def;
}

variable_types:
str
char *

variable_types: def int

variable_types:
lo
unsigned long

variable_types:
hi
unsigned long

variable_types: r int


original_code:
void
symtab_set(symtab_t *self, const char *str, int val)
{
  size_t lo = 0;
  size_t hi = self->symtab_count;
  symbol_t *s = 0;
  for( ;; )
  {
    if( lo == hi )
    {
      if( self->symtab_count == self->symtab_alloc )
      {
        self->symtab_alloc *= 2;
        self->symtab_entry = realloc(self->symtab_entry,
                                      self->symtab_alloc *
                                      sizeof *self->symtab_entry);
      }
      s = &self->symtab_entry[lo];
      memmove(s+1, s+0, (self->symtab_count - lo) * sizeof *s);
      self->symtab_count += 1;
      symbol_ctor(s, str, val);
      break;
    }
    else
    {
      size_t i = (lo + hi)/2;
      s = &self->symtab_entry[i];
      int r = strcmp(s->symbol_key, str);
      if( r < 0 ) { lo = i + 1; continue; }
      if( r > 0 ) { hi = i + 0; continue; }
      s->symbol_val = val;
      break;
    }
  }
}

canonical_original_code:
void symtab_set(struct symtab_t *self, char *str, int val)
{
  unsigned long lo = 0;
  unsigned long hi = self->symtab_count;
  struct symbol_t *s = 0;
  for( ;; )
  {
    if( lo == hi )
    {
      if( self->symtab_count == self->symtab_alloc )
      {
        self->symtab_alloc *= 2;
        self->symtab_entry = realloc(self->symtab_entry,
                                      self->symtab_alloc *
                                      sizeof *self->symtab_entry);
      }
      s = &self->symtab_entry[lo];
      memmove(s+1, s+0, (self->symtab_count - lo) * sizeof *s);
      self->symtab_count += 1;
      symbol_ctor(s, str, val);
      break;
    }
    else
    {
      unsigned long i = (lo + hi)/2;
      s = &self->symtab_entry[i];
      int r = strcmp(s->symbol_key, str);
      if( r < 0 ) { lo = i + 1; continue; }
      if( r > 0 ) { hi = i + 0; continue; }
      s->symbol_val = val;
      break;
    }
  }
}


original_code:
int
symtab_enumerate(symtab_t *self, const char *str)
{
  size_t lo = 0;
  size_t hi = self->symtab_count;
  symbol_t *s = 0;
  for( ;; )
  {
    if( lo == hi )
    {
      if( self->symtab_count == self->symtab_alloc )
      {
        self->symtab_alloc *= 2;
        self->symtab_entry = realloc(self->symtab_entry,
                                      self->symtab_alloc *
                                      sizeof *self->symtab_entry);
      }
      s = &self->symtab_entry[lo];
      memmove(s+1, s+0, (self->symtab_count - lo) * sizeof *s);
      symbol_ctor(s, str, (int)self->symtab_count++);
      break;
    }
    else
    {
      size_t i = (lo + hi)/2;
      s = &self->symtab_entry[i];
      int r = strcmp(s->symbol_key, str);
      if( r < 0 ) { lo = i + 1; continue; }
      if( r > 0 ) { hi = i + 0; continue; }
      break;
    }
  }
  return s->symbol_val;
}

canonical_original_code:
int symtab_enumerate(struct symtab_t *self, char *str)
{
  unsigned long lo = 0;
  unsigned long hi = self->symtab_count;
  struct symbol_t *s = 0;
  for( ;; )
  {
    if( lo == hi )
    {
      if( self->symtab_count == self->symtab_alloc )
      {
        self->symtab_alloc *= 2;
        self->symtab_entry = realloc(self->symtab_entry,
                                      self->symtab_alloc *
                                      sizeof *self->symtab_entry);
      }
      s = &self->symtab_entry[lo];
      memmove(s+1, s+0, (self->symtab_count - lo) * sizeof *s);
      symbol_ctor(s, str, (int)self->symtab_count++);
      break;
    }
    else
    {
      unsigned long i = (lo + hi)/2;
      s = &self->symtab_entry[i];
      int r = strcmp(s->symbol_key, str);
      if( r < 0 ) { lo = i + 1; continue; }
      if( r > 0 ) { hi = i + 0; continue; }
      break;
    }
  }
  return s->symbol_val;
}


decompiled_code:
void __fastcall symtab_renum(_QWORD *a1)
{
unsigned __int64 v1; // rax

if ( a1[1] )
{
v1 = 0LL;
do
{
*(_DWORD *)(*a1 + 16 * v1 + 8) = v1;
++v1;
}
while ( a1[1] > v1 );
}
}

original_code:
void symtab_renum(symtab_t *self)
{
  for( int i = 0; i < self->symtab_count; ++i )
  {
    symbol_t *s = &self->symtab_entry[i];
    s->symbol_val = i;
  }
}

canonical_original_code:
void symtab_renum(struct symtab_t *self)
{
  for( int i = 0; i < self->symtab_count; ++i )
  {
    struct symbol_t *s = &self->symtab_entry[i];
    s->symbol_val = i;
  }
}

variable_types: i int


decompiled_code:
const char *__fastcall color_to_markup(int a1)
{
const char *result; // rax

switch ( a1 )
{
case 0:
result = (const char *)&unk_205;
break;
case 1:
result = "WHITE";
break;
case 2:
result = "BLUE";
break;
case 3:
result = "YELLOW";
break;
case 4:
result = "GREEN";
break;
default:
result = (const char *)&unk_204;
break;
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func0(int a1)
{
const char *result; // rax

switch ( a1 )
{
case 0:
result = (const char *)&unk_205;
break;
case 1:
result = "WHITE";
break;
case 2:
result = "BLUE";
break;
case 3:
result = "YELLOW";
break;
case 4:
result = "GREEN";
break;
default:
result = (const char *)&unk_204;
break;
}
return result;
}

original_code:
static const char* color_to_markup(const color_t c)
{
    switch (c) {
        case RED: return "RED"; break;
        case WHITE: return "WHITE"; break;
        case BLUE: return "BLUE"; break;
        case YELLOW: return "YELLOW"; break;
        case GREEN: return "GREEN"; break;
        default: return ""; break;
    }
}

canonical_original_code:
static char *color_to_markup(enum color_t c)
{
    switch (c) {
        case RED: return "RED"; break;
        case WHITE: return "WHITE"; break;
        case BLUE: return "BLUE"; break;
        case YELLOW: return "YELLOW"; break;
        case GREEN: return "GREEN"; break;
        default: return ""; break;
    }
}

variable_types: enum color_t { RED=0, WHITE=1, BLUE=2, YELLOW=3, GREEN=4 }

return_type: char *


decompiled_code:
void __fastcall set_markup_style(int a1)
{
markup_style = a1;
}

canonical_decompiled_code:
void __fastcall func1(int a1)
{
markup_style = a1;
}

original_code:
void set_markup_style(const markup_style_t style)
{
    markup_style = style;
}

canonical_original_code:
void set_markup_style(enum markup_style_t style)
{
    markup_style = style;
}

variable_types: enum markup_style_t { NO_MARKUP=0, MIRC=1, XTERM=2 }


markup

decompiled_code:
char *__fastcall markup(int a1, const char *a2)
{
char *result; // rax
bool v3; // cc
const char *v4; // rax
unsigned int v5; // edx
void *v6; // rbx
int v7[10]; // [rsp+0h] [rbp-28h]

if ( markup_style == 1 )
{
v4 = color_to_markup(a1);
v5 = snprintf(buffer_0, 0x80uLL, "[COLOR=%s]%s[/COLOR]", v4, a2);
result = 0LL;
if ( v5 <= 0x7F )
{
v6 = (void *)irc_color_convert_to_mirc(buffer_0);
if ( (unsigned int)snprintf(buffer_0, 0x80uLL, "%s", (const char *)v6) > 0x7F )
{
free(v6);
result = 0LL;
}
else
{
free(v6);
result = buffer_0;
}
}
}
else if ( markup_style == 2 )
{
v7[0] = 31;
v7[1] = 37;
v7[2] = 34;
v7[3] = 33;
v7[4] = 32;
v3 = (unsigned int)snprintf(buffer_0, 0x80uLL, "\x1B[%d;1m%s\x1B[0m", (unsigned int)v7[a1], a2) <= 0x7F;
result = buffer_0;
if ( !v3 )
result = 0LL;
}
else
{
result = 0LL;
if ( !markup_style )
{
v3 = (unsigned int)snprintf(buffer_0, 0x80uLL, "%s", a2) <= 0x7F;
result = buffer_0;
if ( !v3 )
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
char *__fastcall func2(int a1, const char *a2)
{
char *result; // rax
bool v3; // cc
const char *v4; // rax
unsigned int v5; // edx
void *v6; // rbx
int v7[10]; // [rsp+0h] [rbp-28h]

if ( markup_style == 1 )
{
v4 = func0(a1);
v5 = snprintf(buffer_0, 0x80uLL, "[COLOR=%s]%s[/COLOR]", v4, a2);
result = 0LL;
if ( v5 <= 0x7F )
{
v6 = (void *)irc_color_convert_to_mirc(buffer_0);
if ( (unsigned int)snprintf(buffer_0, 0x80uLL, "%s", (const char *)v6) > 0x7F )
{
free(v6);
result = 0LL;
}
else
{
free(v6);
result = buffer_0;
}
}
}
else if ( markup_style == 2 )
{
v7[0] = 31;
v7[1] = 37;
v7[2] = 34;
v7[3] = 33;
v7[4] = 32;
v3 = (unsigned int)snprintf(buffer_0, 0x80uLL, "\x1B[%d;1m%s\x1B[0m", (unsigned int)v7[a1], a2) <= 0x7F;
result = buffer_0;
if ( !v3 )
result = 0LL;
}
else
{
result = 0LL;
if ( !markup_style )
{
v3 = (unsigned int)snprintf(buffer_0, 0x80uLL, "%s", a2) <= 0x7F;
result = buffer_0;
if ( !v3 )
result = 0LL;
}
}
return result;
}

original_code:
const char *markup(const color_t color, const char *str)
{
    static char buffer[128];
    if (markup_style == MIRC) {
        if (sizeof(buffer) <= snprintf(buffer, sizeof(buffer), "[COLOR=%s]%s[/COLOR]",
                    color_to_markup(color), str)) {
            return ((void *)0);
        }
        char *colored = irc_color_convert_to_mirc(buffer);
        if (sizeof(buffer) <= snprintf(buffer, sizeof(buffer), "%s", colored)) {
            free(colored);
            return ((void *)0);
        }
        free(colored);
    }
    else if (markup_style == XTERM) {
        unsigned int xterm_color_map[] = { 31, 37, 34, 33, 32 };
        if (sizeof(buffer) <= snprintf(buffer, sizeof(buffer), "\033[%d;1m%s\033[0m",
                    xterm_color_map[(int)color], str)) {
            return ((void *)0);
        }
    }
    else if (markup_style == NO_MARKUP) {
        if (sizeof(buffer) <= snprintf(buffer, sizeof(buffer), "%s", str)) {
            return ((void *)0);
        }
    }
    else
        return ((void *)0);
    return buffer;
}

canonical_original_code:
char *markup(enum color_t color, char *str)
{
    static char buffer[128];
    if (markup_style == MIRC) {
        if (sizeof(buffer) <= snprintf(buffer, sizeof(buffer), "[COLOR=%s]%s[/COLOR]",
                    color_to_markup(color), str)) {
            return ((void *)0);
        }
        char *colored = irc_color_convert_to_mirc(buffer);
        if (sizeof(buffer) <= snprintf(buffer, sizeof(buffer), "%s", colored)) {
            free(colored);
            return ((void *)0);
        }
        free(colored);
    }
    else if (markup_style == XTERM) {
        unsigned int xterm_color_map[] = { 31, 37, 34, 33, 32 };
        if (sizeof(buffer) <= snprintf(buffer, sizeof(buffer), "\033[%d;1m%s\033[0m",
                    xterm_color_map[(int)color], str)) {
            return ((void *)0);
        }
    }
    else if (markup_style == NO_MARKUP) {
        if (sizeof(buffer) <= snprintf(buffer, sizeof(buffer), "%s", str)) {
            return ((void *)0);
        }
    }
    else
        return ((void *)0);
    return buffer;
}

variable_types:
buffer
char [128]

variable_types:
colored
char *

user_defined_types: enum color_t { RED=0, WHITE=1, BLUE=2, YELLOW=3, GREEN=4 }


decompiled_code:
char *__fastcall card_to_markup_string(__int16 *a1)
{
__int16 v1; // bp
char *v2; // rax
char *result; // rax

v1 = *a1;
if ( *a1 )
{
v2 = color_to_string(*((_DWORD *)a1 + 1));
if ( v1 == 1 )
snprintf(buffer_3, 0x20uLL, "%s*", v2);
else
snprintf(buffer_3, 0x20uLL, "%s%d", v2, (unsigned int)v1);
}
else
{
strcpy(buffer_3, "--");
}
result = buffer_3;
if ( *a1 )
result = (char *)markup(*((unsigned int *)a1 + 1), buffer_3);
return result;
}

canonical_decompiled_code:
char *__fastcall func1(__int16 *a1)
{
__int16 v1; // bp
char *v2; // rax
char *result; // rax

v1 = *a1;
if ( *a1 )
{
v2 = func0(*((_DWORD *)a1 + 1));
if ( v1 == 1 )
snprintf(buffer_3, 0x20uLL, "%s*", v2);
else
snprintf(buffer_3, 0x20uLL, "%s%d", v2, (unsigned int)v1);
}
else
{
strcpy(buffer_3, "--");
}
result = buffer_3;
if ( *a1 )
result = (char *)markup(*((unsigned int *)a1 + 1), buffer_3);
return result;
}

original_code:
const char *card_to_markup_string(const card_t *card) {
    static char buffer[32];
    if (card->value == 0)
        snprintf(buffer, sizeof(buffer), "--");
    else if (card->value != 1)
        snprintf(buffer, sizeof(buffer), "%s%d", color_to_string(card->color), card->value);
    else
        snprintf(buffer, sizeof(buffer), "%s*", color_to_string(card->color));
    return card->value == 0 ? buffer : markup(card->color, buffer);
}

canonical_original_code:
char *card_to_markup_string(struct card_t *card) {
    static char buffer[32];
    if (card->value == 0)
        snprintf(buffer, sizeof(buffer), "--");
    else if (card->value != 1)
        snprintf(buffer, sizeof(buffer), "%s%d", color_to_string(card->color), card->value);
    else
        snprintf(buffer, sizeof(buffer), "%s*", color_to_string(card->color));
    return card->value == 0 ? buffer : markup(card->color, buffer);
}

variable_types: struct card_t { short value; enum color_t { RED=0, WHITE=1, BLUE=2, YELLOW=3, GREEN=4 } color; } *

variable_types:
buffer
char [32]

user_defined_types: struct card_t { short value; enum color_t color; }


decompiled_code:
char *__fastcall stack_to_string(__int64 a1)
{
__int64 v1; // r12
int v2; // er13
char *v3; // rbp

buffer_1[0] = 0;
if ( !*(_DWORD *)(a1 + 16) )
return buffer_1;
v1 = 0LL;
v2 = 0;
while ( 1 )
{
v3 = card_to_markup_string((__int16 *)(*(_QWORD *)a1 + 8 * v1));
if ( v2 + strnlen(v3, 0x100uLL) > 0xFF )
break;
v2 += snprintf(&buffer_1[v2], 256LL - v2, "%s ", v3);
if ( *(_DWORD *)(a1 + 16) <= (unsigned int)++v1 )
return buffer_1;
}
return 0LL;
}

canonical_decompiled_code:
char *__fastcall func2(__int64 a1)
{
__int64 v1; // r12
int v2; // er13
char *v3; // rbp

buffer_1[0] = 0;
if ( !*(_DWORD *)(a1 + 16) )
return buffer_1;
v1 = 0LL;
v2 = 0;
while ( 1 )
{
v3 = func1((__int16 *)(*(_QWORD *)a1 + 8 * v1));
if ( v2 + strnlen(v3, 0x100uLL) > 0xFF )
break;
v2 += snprintf(&buffer_1[v2], 256LL - v2, "%s ", v3);
if ( *(_DWORD *)(a1 + 16) <= (unsigned int)++v1 )
return buffer_1;
}
return 0LL;
}

original_code:
const char *stack_to_string(const card_stack_t *stack) {
    static char buffer[256];
    buffer[0] = 0;
    int count = 0;
    for (int i = 0; i < stack->index; i++) {
        const char *cardstr = card_to_markup_string(&stack->cards[i]);
        if (count + strnlen(cardstr, sizeof(buffer)) >= sizeof(buffer))
            return ((void *)0);
        count += snprintf(&buffer[count], sizeof(buffer)-count, "%s ", cardstr);
    }
    return (const char*)&buffer;
}

canonical_original_code:
char *stack_to_string(struct card_stack_t *stack) {
    static char buffer[256];
    buffer[0] = 0;
    int count = 0;
    for (int i = 0; i < stack->index; i++) {
        char *cardstr = card_to_markup_string(&stack->cards[i]);
        if (count + strnlen(cardstr, sizeof(buffer)) >= sizeof(buffer))
            return ((void *)0);
        count += snprintf(&buffer[count], sizeof(buffer)-count, "%s ", cardstr);
    }
    return (char *)&buffer;
}

variable_types: struct card_stack_t { struct card_t { short value; enum color_t { RED=0, WHITE=1, BLUE=2, YELLOW=3, GREEN=4 } color; } *cards; unsigned long max_size; unsigned int index; } *

variable_types:
buffer
char [256]

variable_types: count int

variable_types:
cardstr
char *

user_defined_types: struct card_stack_t { struct card_t *cards; unsigned long max_size; unsigned int index; }


decompiled_code:
void *__fastcall init_stack(__int64 a1, __int64 a2)
{
void *result; // rax

result = malloc(8 * a2);
*(_QWORD *)a1 = result;
*(_QWORD *)(a1 + 8) = a2;
*(_DWORD *)(a1 + 16) = 0;
return result;
}

canonical_decompiled_code:
void *__fastcall func3(__int64 a1, __int64 a2)
{
void *result; // rax

result = malloc(8 * a2);
*(_QWORD *)a1 = result;
*(_QWORD *)(a1 + 8) = a2;
*(_DWORD *)(a1 + 16) = 0;
return result;
}

original_code:
void init_stack(card_stack_t *stack, const size_t max_size) {
    stack->cards = (card_t*)malloc(max_size * sizeof(card_t));
    stack->max_size = max_size;
    stack->index = 0;
}

canonical_original_code:
void init_stack(struct card_stack_t *stack, unsigned long max_size) {
    stack->cards = (struct card_t *)malloc(max_size * sizeof(card_t));
    stack->max_size = max_size;
    stack->index = 0;
}


decompiled_code:
unsigned __int64 __fastcall push_stack(__int64 a1, _QWORD *a2)
{
unsigned __int64 result; // rax

result = *(unsigned int *)(a1 + 16);
if ( result >= *(_QWORD *)(a1 + 8) )
_assert_fail("stack->index < stack->max_size", "card_stack.c", 0x47u, "push_stack");
*(_QWORD *)(*(_QWORD *)a1 + 8 * result) = *a2;
++*(_DWORD *)(a1 + 16);
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func4(__int64 a1, _QWORD *a2)
{
unsigned __int64 result; // rax

result = *(unsigned int *)(a1 + 16);
if ( result >= *(_QWORD *)(a1 + 8) )
_assert_fail("stack->index < stack->max_size", "card_stack.c", 0x47u, "push_stack");
*(_QWORD *)(*(_QWORD *)a1 + 8 * result) = *a2;
++*(_DWORD *)(a1 + 16);
return result;
}

original_code:
void push_stack(card_stack_t *stack, const card_t *data) {
    ((stack->index < stack->max_size) ? (void) (0) : __assert_fail ("stack->index < stack->max_size", "card_stack.c", 71, __extension__ __PRETTY_FUNCTION__));
    memcpy(stack->cards + stack->index, data, sizeof(stack->cards[0]));
    stack->index++;
}

canonical_original_code:
void push_stack(struct card_stack_t *stack, struct card_t *data) {
    ((stack->index < stack->max_size) ? (void) (0) : __assert_fail ("stack->index < stack->max_size", "card_stack.c", 71, __extension__ __PRETTY_FUNCTION__));
    memcpy(stack->cards + stack->index, data, sizeof(stack->cards[0]));
    stack->index++;
}

variable_types:
data
struct card_t *


decompiled_code:
__int64 __fastcall pop_stack(__int64 a1)
{
int v1; // eax
unsigned int v2; // eax

v1 = *(_DWORD *)(a1 + 16);
if ( !v1 )
return 0LL;
v2 = v1 - 1;
*(_DWORD *)(a1 + 16) = v2;
return *(_QWORD *)a1 + 8LL * v2;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
int v1; // eax
unsigned int v2; // eax

v1 = *(_DWORD *)(a1 + 16);
if ( !v1 )
return 0LL;
v2 = v1 - 1;
*(_DWORD *)(a1 + 16) = v2;
return *(_QWORD *)a1 + 8LL * v2;
}

original_code:
card_t *pop_stack(card_stack_t *stack) {
    if (stack->index == 0)
        return ((void *)0);
    stack->index--;
    return stack->cards + stack->index;
}

canonical_original_code:
struct card_t *pop_stack(struct card_stack_t *stack) {
    if (stack->index == 0)
        return ((void *)0);
    stack->index--;
    return stack->cards + stack->index;
}

variable_types: struct card_stack_t { struct card_t *cards; unsigned long max_size; unsigned int index; } *

return_type: struct card_t { short value; enum color_t { RED=0, WHITE=1, BLUE=2, YELLOW=3, GREEN=4 } color; } *


decompiled_code:
__int64 __fastcall top_stack(__int64 a1)
{
unsigned int v1; // eax
__int64 result; // rax

v1 = *(_DWORD *)(a1 + 16);
if ( v1 )
result = *(_QWORD *)a1 + 8LL * v1 - 8;
else
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
unsigned int v1; // eax
__int64 result; // rax

v1 = *(_DWORD *)(a1 + 16);
if ( v1 )
result = *(_QWORD *)a1 + 8LL * v1 - 8;
else
result = 0LL;
return result;
}

original_code:
card_t *top_stack(const card_stack_t *stack) {
    if (stack->index == 0)
        return ((void *)0);
    return stack->cards + stack->index-1;
}

canonical_original_code:
struct card_t *top_stack(struct card_stack_t *stack) {
    if (stack->index == 0)
        return ((void *)0);
    return stack->cards + stack->index-1;
}


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

original_code:
void deinit_stack(card_stack_t *stack) {
    free(stack->cards);
    stack->max_size = 0;
    stack->index = 0;
}

canonical_original_code:
void deinit_stack(struct card_stack_t *stack) {
    free(stack->cards);
    stack->max_size = 0;
    stack->index = 0;
}


decompiled_code:
__int64 __fastcall num_cards(__int64 a1)
{
return *(unsigned int *)(a1 + 16);
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
return *(unsigned int *)(a1 + 16);
}

original_code:
unsigned int num_cards(const card_stack_t *stack)
{
    return stack->index;
}

canonical_original_code:
unsigned int num_cards(struct card_stack_t *stack)
{
    return stack->index;
}

return_type: unsigned int


repo: philwil/ssds

decompiled_code:
__int64 test_argc()
{
unsigned int v0; // eax
__int64 v1; // rbp
__int64 i; // rbx
char v4[144]; // [rsp+0h] [rbp-128h] BYREF
__int64 v5[19]; // [rsp+90h] [rbp-98h] BYREF

strcpy(&v4[53], ":");
strcpy(v4, "class:alarm:action:create_field:MaxAlarmValue:float:");
printf("test_argc lbuf was (%s) \n", v4);
v0 = get_argc(v4, (__int64)v5, 16);
if ( v0 )
{
v1 = v0;
for ( i = 0LL; i != v1; ++i )
printf(" %d (%s) \n", (unsigned int)i, (const char *)v5[i]);
}
return 0LL;
}

canonical_decompiled_code:
__int64 func2()
{
unsigned int v0; // eax
__int64 v1; // rbp
__int64 i; // rbx
char v4[144]; // [rsp+0h] [rbp-128h] BYREF
__int64 v5[19]; // [rsp+90h] [rbp-98h] BYREF

strcpy(&v4[53], ":");
strcpy(v4, "class:alarm:action:create_field:MaxAlarmValue:float:");
printf("test_argc lbuf was (%s) \n", v4);
v0 = func1(v4, (__int64)v5, 16);
if ( v0 )
{
v1 = v0;
for ( i = 0LL; i != v1; ++i )
printf(" %d (%s) \n", (unsigned int)i, (const char *)v5[i]);
}
return 0LL;
}

original_code:
int test_argc(void)
{
  char **argv;
  char *myargv[16];
  int argc;
  int idx;
  char lbuf[132];
  strcpy(lbuf, "class:alarm:action:create_class:");
  strcpy(lbuf, "class:alarm:action:create_field:InputAlarmValue:float:");
  strcpy(lbuf, "class:alarm:action:create_field:MaxAlarmValue:float:");
  argv = myargv;
  printf("test_argc lbuf was (%s) \n", lbuf);
  argc = get_argc(lbuf, argv, 16);
  idx = 0;
  while (argc--) {
    printf(" %d (%s) \n", idx, argv[idx]);
    idx++;
  }
  return 0;
}

canonical_original_code:
int test_argc()
{
  char **argv;
  char *myargv[16];
  int argc;
  int idx;
  char lbuf[132];
  strcpy(lbuf, "class:alarm:action:create_class:");
  strcpy(lbuf, "class:alarm:action:create_field:InputAlarmValue:float:");
  strcpy(lbuf, "class:alarm:action:create_field:MaxAlarmValue:float:");
  argv = myargv;
  printf("test_argc lbuf was (%s) \n", lbuf);
  argc = get_argc(lbuf, argv, 16);
  idx = 0;
  while (argc--) {
    printf(" %d (%s) \n", idx, argv[idx]);
    idx++;
  }
  return 0;
}

variable_types:
argv
char **

variable_types:
myargv
char *[16]

variable_types: argc int

variable_types: idx int

variable_types:
lbuf
char [132]


original_code:
int do_find_group(char *data, void *pcli, int group_act)
{
  int ret;
  int res;
  int i,j;
  int num;
  int len;
  char *dsp;
  char *tsp;
  int idx;
  char stmp[16];
  char ntmp[64];
  struct ssds_client *cli;
  struct ssds_client *cli_save;
  struct cli_group *gr;
  struct cli_group_entry *gr_ent;
  cli = pcli;
  ret = -1;
  switch(group_act) {
  case 2:
    gr = cli->curr_group;
    dsp = (char *)data;
    tsp = stmp;
    while(*dsp && (*dsp != ',') && (*dsp != ':')) {
      *tsp++ = *dsp++;
    }
    *tsp = 0;
    dsp++;
    num = atoi(stmp);
    if(0)
      printf("set_group (%s) num entries now %d num %d (%s)dsp (%s)\n"
      , gr->name, gr->num_entries, num, stmp,dsp);
    if(num<0) {
      num = -num;
      gr->num_entries=0;
    }
    if (gr->num_entries+num<gr->max_entries) {
      idx = gr->num_entries;
      while(num--) {
 gr_ent = &gr->entries[idx];
 tsp = gr_ent->name;
 len = 64-1;
 while(len-- && *dsp && (*dsp != ',') && (*dsp != ':')) {
   *tsp++ = *dsp++;
 }
 *tsp = 0;
 dsp++;
 idx++;
 gr->num_entries++;
      }
    }
    ret = gr->num_entries;
    break;
  case 5:
    gr = cli->curr_group;
    num = gr->num_entries;
    if(0)printf("show_group num entries %d\n",num);
    ret = 0;
    dsp = (char *)data;
    ret+=sprintf(dsp+ret,"%d",num);
    for(idx=0; idx<num; idx++) {
      gr_ent = &gr->entries[idx];
      if(0)
 printf("show_group num entry %d name (%s)\n",
      idx, gr_ent->name);
      ret+=sprintf(dsp+ret,",%s",gr_ent->name);
    }
    ret+=sprintf(dsp+ret,":");
    break;
  case 3:
    ret = 0;
    dsp = data;
    gr = cli->curr_group;
    num = gr->num_entries;
    ret += get_str_val(stmp, dsp+ret, ',', 32);
    sscanf(stmp,"%d",&num);
    for(i=0;i<num;i++) {
      gr_ent = &gr->entries[i];
      ret += get_str_val(stmp, dsp+ret, ',', 32);
      if(0)
 printf("set_items %d name (%s) val (%s) ret %d dsp(%s)\n"
      ,i,gr_ent->name,stmp,ret,dsp+ret);
      set_action_val_name(gr_ent->name, stmp, strlen(stmp));
    }
    break;
  case 4:
    ret = 0;
    dsp = data;
    gr = cli->curr_group;
    num=gr->num_entries;
    ret+=sprintf(dsp+ret,"%d",num);
    for(i=0;i<num;i++) {
      ret+=sprintf(dsp+ret,",");
      gr_ent = &gr->entries[i];
      ret+=get_action_val_name_gr(gr_ent->name, dsp+ret, 32);
    }
    ret+=sprintf(dsp+ret,":");
    break;
  case 9:
    printf("num groups = %d\n",cli->num_groups);
    for(i=0;i<cli->num_groups;i++) {
      gr = &cli->groups[i];
      printf("groups %d name (%s) entries %d \n",
      i, gr->name, gr->num_entries);
      for(j=0;j<gr->num_entries;j++) {
 gr_ent = &gr->entries[j];
 printf("   entry %d name (%s)\n",j, gr_ent->name);
      }
    }
    break;
  case 8:
    ret = 0;
    dsp = data;
    gr = cli->curr_group;
    num=gr->num_entries;
    if(0)printf("get_group (%s) num entries %d cli %p\n",
  gr->name,gr->num_entries, cli);
    for(i=0; i<num; i++) {
      gr_ent = &gr->entries[i];
      res=get_action_len_name_gr(gr_ent->name, 32);
      if(res>0) ret+=res;
      if(0)
 printf("get_group_len name (%s) ret %d res %d\n", gr->name, ret, res);
    }
    break;
  case 6:
    ret = 0;
    dsp = data;
    gr = cli->curr_group;
    num=gr->num_entries;
    for(i=0;i<num;i++) {
      gr_ent = &gr->entries[i];
      res=get_action_val_name_bin(gr_ent->name, dsp+ret, 32);
      if(res > 0) ret+=res;
      if(0)
 printf("get_group_bin name %d (%s) ret %d res %d\n"
        , i,gr_ent->name,ret,res);
    }
    break;
  case 7:
    ret = 0;
    dsp = data;
    gr = cli->curr_group;
    num=gr->num_entries;
    for(i=0;i<num;i++) {
      gr_ent = &gr->entries[i];
      res = set_action_val_name_bin(gr_ent->name, dsp+ret, 32);
      if(res > 0) ret += res;
    }
    break;
  case 1:
    cli_save = ((void *)0);
    if (data[0] == '0') {
      cli_save = cli;
      cli=get_ssds_client(0);
      strncpy(ntmp, &data[1], 63);
      ntmp[63]=0;
      data = &ntmp[0];
    }
    if(cli) {
      for (i = 0; i < cli->num_groups; i++) {
 gr = &cli->groups[i];
 if(strcmp(gr->name, data) == 0) {
   ret = i;
   if(cli_save) {
     cli_save->curr_group = gr;
   } else {
     cli->curr_group = gr;
   }
   break;
 }
      }
      i = cli->num_groups;
      if((ret==-1) && (i < cli->max_groups)) {
 gr = &cli->groups[i];
 strncpy(gr->name, data, 63);
 gr->name[63] = 0;
 gr->num_entries = 0;
 gr->max_entries = 32;
 if(cli_save) {
   cli_save->curr_group = gr;
 } else {
   cli->curr_group = gr;
 }
        ret = i;
 cli->num_groups++;
      }
    }
    break;
  default:
    break;
  }
  return ret;
}

canonical_original_code:
int do_find_group(char *data, void *pcli, int group_act)
{
  int ret;
  int res;
  int i; int j;
  int num;
  int len;
  char *dsp;
  char *tsp;
  int idx;
  char stmp[16];
  char ntmp[64];
  struct ssds_client *cli;
  struct ssds_client *cli_save;
  struct cli_group *gr;
  struct cli_group_entry *gr_ent;
  cli = pcli;
  ret = -1;
  switch(group_act) {
  case 2:
    gr = cli->curr_group;
    dsp = (char *)data;
    tsp = stmp;
    while(*dsp && (*dsp != ',') && (*dsp != ':')) {
      *tsp++ = *dsp++;
    }
    *tsp = 0;
    dsp++;
    num = atoi(stmp);
    if(0)
      printf("set_group (%s) num entries now %d num %d (%s)dsp (%s)\n"
      , gr->name, gr->num_entries, num, stmp,dsp);
    if(num<0) {
      num = -num;
      gr->num_entries=0;
    }
    if (gr->num_entries+num<gr->max_entries) {
      idx = gr->num_entries;
      while(num--) {
 gr_ent = &gr->entries[idx];
 tsp = gr_ent->name;
 len = 64-1;
 while(len-- && *dsp && (*dsp != ',') && (*dsp != ':')) {
   *tsp++ = *dsp++;
 }
 *tsp = 0;
 dsp++;
 idx++;
 gr->num_entries++;
      }
    }
    ret = gr->num_entries;
    break;
  case 5:
    gr = cli->curr_group;
    num = gr->num_entries;
    if(0)printf("show_group num entries %d\n",num);
    ret = 0;
    dsp = (char *)data;
    ret+=sprintf(dsp+ret,"%d",num);
    for(idx=0; idx<num; idx++) {
      gr_ent = &gr->entries[idx];
      if(0)
 printf("show_group num entry %d name (%s)\n",
      idx, gr_ent->name);
      ret+=sprintf(dsp+ret,",%s",gr_ent->name);
    }
    ret+=sprintf(dsp+ret,":");
    break;
  case 3:
    ret = 0;
    dsp = data;
    gr = cli->curr_group;
    num = gr->num_entries;
    ret += get_str_val(stmp, dsp+ret, ',', 32);
    sscanf(stmp,"%d",&num);
    for(i=0;i<num;i++) {
      gr_ent = &gr->entries[i];
      ret += get_str_val(stmp, dsp+ret, ',', 32);
      if(0)
 printf("set_items %d name (%s) val (%s) ret %d dsp(%s)\n"
      ,i,gr_ent->name,stmp,ret,dsp+ret);
      set_action_val_name(gr_ent->name, stmp, strlen(stmp));
    }
    break;
  case 4:
    ret = 0;
    dsp = data;
    gr = cli->curr_group;
    num=gr->num_entries;
    ret+=sprintf(dsp+ret,"%d",num);
    for(i=0;i<num;i++) {
      ret+=sprintf(dsp+ret,",");
      gr_ent = &gr->entries[i];
      ret+=get_action_val_name_gr(gr_ent->name, dsp+ret, 32);
    }
    ret+=sprintf(dsp+ret,":");
    break;
  case 9:
    printf("num groups = %d\n",cli->num_groups);
    for(i=0;i<cli->num_groups;i++) {
      gr = &cli->groups[i];
      printf("groups %d name (%s) entries %d \n",
      i, gr->name, gr->num_entries);
      for(j=0;j<gr->num_entries;j++) {
 gr_ent = &gr->entries[j];
 printf("   entry %d name (%s)\n",j, gr_ent->name);
      }
    }
    break;
  case 8:
    ret = 0;
    dsp = data;
    gr = cli->curr_group;
    num=gr->num_entries;
    if(0)printf("get_group (%s) num entries %d cli %p\n",
  gr->name,gr->num_entries, cli);
    for(i=0; i<num; i++) {
      gr_ent = &gr->entries[i];
      res=get_action_len_name_gr(gr_ent->name, 32);
      if(res>0) ret+=res;
      if(0)
 printf("get_group_len name (%s) ret %d res %d\n", gr->name, ret, res);
    }
    break;
  case 6:
    ret = 0;
    dsp = data;
    gr = cli->curr_group;
    num=gr->num_entries;
    for(i=0;i<num;i++) {
      gr_ent = &gr->entries[i];
      res=get_action_val_name_bin(gr_ent->name, dsp+ret, 32);
      if(res > 0) ret+=res;
      if(0)
 printf("get_group_bin name %d (%s) ret %d res %d\n"
        , i,gr_ent->name,ret,res);
    }
    break;
  case 7:
    ret = 0;
    dsp = data;
    gr = cli->curr_group;
    num=gr->num_entries;
    for(i=0;i<num;i++) {
      gr_ent = &gr->entries[i];
      res = set_action_val_name_bin(gr_ent->name, dsp+ret, 32);
      if(res > 0) ret += res;
    }
    break;
  case 1:
    cli_save = ((void *)0);
    if (data[0] == '0') {
      cli_save = cli;
      cli=get_ssds_client(0);
      strncpy(ntmp, &data[1], 63);
      ntmp[63]=0;
      data = &ntmp[0];
    }
    if(cli) {
      for (i = 0; i < cli->num_groups; i++) {
 gr = &cli->groups[i];
 if(strcmp(gr->name, data) == 0) {
   ret = i;
   if(cli_save) {
     cli_save->curr_group = gr;
   } else {
     cli->curr_group = gr;
   }
   break;
 }
      }
      i = cli->num_groups;
      if((ret==-1) && (i < cli->max_groups)) {
 gr = &cli->groups[i];
 strncpy(gr->name, data, 63);
 gr->name[63] = 0;
 gr->num_entries = 0;
 gr->max_entries = 32;
 if(cli_save) {
   cli_save->curr_group = gr;
 } else {
   cli->curr_group = gr;
 }
        ret = i;
 cli->num_groups++;
      }
    }
    break;
  default:
    break;
  }
  return ret;
}

variable_types:
data
char *

variable_types:
pcli
void *

variable_types: ret int

variable_types: res int

variable_types: i int

variable_types: j int

variable_types: num int

variable_types: len int

variable_types:
dsp
char *

variable_types:
tsp
char *

variable_types:
stmp
char [16]

variable_types:
ntmp
char [64]

variable_types: struct ssds_client { struct ssds_client *next; struct ssds_client *next_def; int type; int fd; int idx; int ix; int is_auto; char ipaddr[32]; int port; char rxbuf[512]; int rxbuf_len; char txbuf[512]; int txbuf_len; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } cli_addr; int num_groups; int max_groups; struct cli_group { char name[64]; int num_entries; int max_entries; struct cli_group_entry { char name[64]; short f_len; short f_type; char *data; } entries[32]; } *curr_group; struct cli_group groups[32]; } *

variable_types: struct cli_group_entry { char name[64]; short f_len; short f_type; char *data; } *

user_defined_types: struct ssds_client { struct ssds_client *next; struct ssds_client *next_def; int type; int fd; int idx; int ix; int is_auto; char ipaddr[32]; int port; char rxbuf[512]; int rxbuf_len; char txbuf[512]; int txbuf_len; struct sockaddr_in cli_addr; int num_groups; int max_groups; struct cli_group *curr_group; struct cli_group groups[32]; }

user_defined_types: struct cli_group { char name[64]; int num_entries; int max_entries; struct cli_group_entry entries[32]; }

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


decompiled_code:
__int64 test_get_field_bit()
{
get_field_bit("bit_0.0", 1LL, 1LL);
get_field_bit("bit_0FF00.0", 0LL, 1LL);
get_field_bit("bit_0.4", 1LL, 1LL);
get_field_bit("bit_30.4", 1LL, 1LL);
return 0LL;
}

canonical_decompiled_code:
__int64 func5()
{
get_field_bit("bit_0.0", 1LL, 1LL);
get_field_bit("bit_0FF00.0", 0LL, 1LL);
get_field_bit("bit_0.4", 1LL, 1LL);
get_field_bit("bit_30.4", 1LL, 1LL);
return 0LL;
}

original_code:
int test_get_field_bit(void)
{
   get_field_bit("bit_0.0", 1, 1);
   get_field_bit("bit_0FF00.0",0,1);
   get_field_bit("bit_0.4",1,1);
   get_field_bit("bit_30.4",1,1);
   return 0;
}

canonical_original_code:
int test_get_field_bit()
{
   get_field_bit("bit_0.0", 1, 1);
   get_field_bit("bit_0FF00.0",0,1);
   get_field_bit("bit_0.4",1,1);
   get_field_bit("bit_30.4",1,1);
   return 0;
}


usage

decompiled_code:
void __noreturn usage()
{
fprintf(stderr, "jpeg2ps %s: convert JPEG files to PostScript Level 2 or 3.\n", "V1.9");
fwrite("(C) Thomas Merz 1994-2002\n\n", 1uLL, 0x1BuLL, stderr);
fwrite("usage: jpeg2ps [options] jpegfile > epsfile\n", 1uLL, 0x2CuLL, stderr);
fwrite("-a auto rotate: produce landscape output if width > height\n", 1uLL, 0x42uLL, stderr);
fwrite("-b binary mode: output 8 bit data (default: 7 bit with ASCII85)\n", 1uLL, 0x47uLL, stderr);
fwrite("-h hex mode: output 7 bit data in ASCIIHex encoding\n", 1uLL, 0x3BuLL, stderr);
fwrite("-o <name> output file name\n", 1uLL, 0x1BuLL, stderr);
fwrite("-p <size> page size name. Known names are:\n", 1uLL, 0x2BuLL, stderr);
fwrite(" a0, a1, a2, a3, a4, a5, a6, b5, letter, legal, ledger, p11x17\n", 1uLL, 0x48uLL, stderr);
fwrite("-q quiet mode: suppress all informational messages\n", 1uLL, 0x3AuLL, stderr);
fwrite("-r <dpi> resolution value (dots per inch)\n", 1uLL, 0x2BuLL, stderr);
fwrite(" 0 means use value given in file, if any (disables autorotate)\n", 1uLL, 0x48uLL, stderr);
exit(1);
}

canonical_decompiled_code:
void __noreturn func0()
{
fprintf(stderr, "jpeg2ps %s: convert JPEG files to PostScript Level 2 or 3.\n", "V1.9");
fwrite("(C) Thomas Merz 1994-2002\n\n", 1uLL, 0x1BuLL, stderr);
fwrite("usage: jpeg2ps [options] jpegfile > epsfile\n", 1uLL, 0x2CuLL, stderr);
fwrite("-a auto rotate: produce landscape output if width > height\n", 1uLL, 0x42uLL, stderr);
fwrite("-b binary mode: output 8 bit data (default: 7 bit with ASCII85)\n", 1uLL, 0x47uLL, stderr);
fwrite("-h hex mode: output 7 bit data in ASCIIHex encoding\n", 1uLL, 0x3BuLL, stderr);
fwrite("-o <name> output file name\n", 1uLL, 0x1BuLL, stderr);
fwrite("-p <size> page size name. Known names are:\n", 1uLL, 0x2BuLL, stderr);
fwrite(" a0, a1, a2, a3, a4, a5, a6, b5, letter, legal, ledger, p11x17\n", 1uLL, 0x48uLL, stderr);
fwrite("-q quiet mode: suppress all informational messages\n", 1uLL, 0x3AuLL, stderr);
fwrite("-r <dpi> resolution value (dots per inch)\n", 1uLL, 0x2BuLL, stderr);
fwrite(" 0 means use value given in file, if any (disables autorotate)\n", 1uLL, 0x48uLL, stderr);
exit(1);
}

original_code:
static
void usage(void) {
  fprintf(stderr, "jpeg2ps %s: convert JPEG files to PostScript Level 2 or 3.\n",
     "V1.9");
  fprintf(stderr, "(C) Thomas Merz 1994-2002\n\n");
  fprintf(stderr, "usage: jpeg2ps [options] jpegfile > epsfile\n");
  fprintf(stderr, "-a        auto rotate: produce landscape output if width > height\n");
  fprintf(stderr, "-b        binary mode: output 8 bit data (default: 7 bit with ASCII85)\n");
  fprintf(stderr, "-h        hex mode: output 7 bit data in ASCIIHex encoding\n");
  fprintf(stderr, "-o <name> output file name\n");
  fprintf(stderr, "-p <size> page size name. Known names are:\n");
  fprintf(stderr, "          a0, a1, a2, a3, a4, a5, a6, b5, letter, legal, ledger, p11x17\n");
  fprintf(stderr, "-q        quiet mode: suppress all informational messages\n");
  fprintf(stderr, "-r <dpi>  resolution value (dots per inch)\n");
  fprintf(stderr, "          0 means use value given in file, if any (disables autorotate)\n");
  exit(1);
}

canonical_original_code:
static void usage() {
  fprintf(stderr, "jpeg2ps %s: convert JPEG files to PostScript Level 2 or 3.\n",
     "V1.9");
  fprintf(stderr, "(C) Thomas Merz 1994-2002\n\n");
  fprintf(stderr, "usage: jpeg2ps [options] jpegfile > epsfile\n");
  fprintf(stderr, "-a        auto rotate: produce landscape output if width > height\n");
  fprintf(stderr, "-b        binary mode: output 8 bit data (default: 7 bit with ASCII85)\n");
  fprintf(stderr, "-h        hex mode: output 7 bit data in ASCIIHex encoding\n");
  fprintf(stderr, "-o <name> output file name\n");
  fprintf(stderr, "-p <size> page size name. Known names are:\n");
  fprintf(stderr, "          a0, a1, a2, a3, a4, a5, a6, b5, letter, legal, ledger, p11x17\n");
  fprintf(stderr, "-q        quiet mode: suppress all informational messages\n");
  fprintf(stderr, "-r <dpi>  resolution value (dots per inch)\n");
  fprintf(stderr, "          0 means use value given in file, if any (disables autorotate)\n");
  exit(1);
}


repo: phuc/wpng

decompiled_code:
void wpng_cleanup()
{
if ( stream )
{
fclose(stream);
stream = 0LL;
}
if ( qword_8E0 )
{
fclose(qword_8E0);
qword_8E0 = 0LL;
}
if ( ptr )
{
free(ptr);
ptr = 0LL;
}
if ( qword_908 )
{
free(qword_908);
qword_908 = 0LL;
}
}

canonical_decompiled_code:
void func0()
{
if ( stream )
{
fclose(stream);
stream = 0LL;
}
if ( qword_8E0 )
{
fclose(qword_8E0);
qword_8E0 = 0LL;
}
if ( ptr )
{
free(ptr);
ptr = 0LL;
}
if ( qword_908 )
{
free(qword_908);
qword_908 = 0LL;
}
}

original_code:
static void wpng_cleanup(void)
{
    if (wpng_info.outfile) {
        fclose(wpng_info.outfile);
        wpng_info.outfile = ((void *)0);
    }
    if (wpng_info.infile) {
        fclose(wpng_info.infile);
        wpng_info.infile = ((void *)0);
    }
    if (wpng_info.image_data) {
        free(wpng_info.image_data);
        wpng_info.image_data = ((void *)0);
    }
    if (wpng_info.row_pointers) {
        free(wpng_info.row_pointers);
        wpng_info.row_pointers = ((void *)0);
    }
}

canonical_original_code:
static void wpng_cleanup()
{
    if (wpng_info.outfile) {
        fclose(wpng_info.outfile);
        wpng_info.outfile = ((void *)0);
    }
    if (wpng_info.infile) {
        fclose(wpng_info.infile);
        wpng_info.infile = ((void *)0);
    }
    if (wpng_info.image_data) {
        free(wpng_info.image_data);
        wpng_info.image_data = ((void *)0);
    }
    if (wpng_info.row_pointers) {
        free(wpng_info.row_pointers);
        wpng_info.row_pointers = ((void *)0);
    }
}


main

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

v3 = fopen(argv[2], "wb");
v4 = fopen(argv[1], "rb");
write_ppm2png(v4, v3);
return 0;
}

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

v3 = fopen(argv[2], "wb");
v4 = fopen(argv[1], "rb");
func9(v4, v3);
return 0;
}

original_code:
int main(int argc, char **argv) {
  write_ppm2png(fopen(argv[1], "rb"), fopen(argv[2], "wb"));
  return 0;
}

variable_types: argc int

variable_types:
argv
char **


modInverse

decompiled_code:
__int64 __fastcall modInverse(unsigned __int64 a1, unsigned __int64 a2)
{
unsigned __int64 v2; // rdx
unsigned __int64 v3; // r8
unsigned __int64 v4; // rcx
__int64 i; // rdi
unsigned __int64 v6; // rdx

v2 = a1 % a2;
v3 = a1 % a2;
if ( a2 <= 1 )
return 0LL;
if ( v2 == 1 )
return 1LL;
v4 = 2 * v2;
for ( i = 2LL; i != a2; ++i )
{
v6 = v4 % a2;
v4 += v3;
if ( v6 == 1 )
return i;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned __int64 a1, unsigned __int64 a2)
{
unsigned __int64 v2; // rdx
unsigned __int64 v3; // r8
unsigned __int64 v4; // rcx
__int64 i; // rdi
unsigned __int64 v6; // rdx

v2 = a1 % a2;
v3 = a1 % a2;
if ( a2 <= 1 )
return 0LL;
if ( v2 == 1 )
return 1LL;
v4 = 2 * v2;
for ( i = 2LL; i != a2; ++i )
{
v6 = v4 % a2;
v4 += v3;
if ( v6 == 1 )
return i;
}
return 0LL;
}

original_code:
unsigned long modInverse(unsigned long a, unsigned long m)
{
 int x;
 a %= m;
 for(x = 1; x < m; x++)
 {
  if((a*x) % m == 1)
   return x;
 }
 return 0;
}

variable_types:
a
unsigned long

variable_types:
m
unsigned long

variable_types: x int

return_type: unsigned long


totient

decompiled_code:
__int64 __fastcall totient(__int64 a1, __int64 a2)
{
return (a2 - 1) * (a1 - 1);
}

original_code:
unsigned long totient(unsigned long p, unsigned long q)
{
 return (p - 1)*(q - 1);
}

variable_types:
p
unsigned long

variable_types:
q
unsigned long


isprime

decompiled_code:
__int64 __fastcall isprime(unsigned __int64 a1)
{
unsigned __int64 v1; // rcx

if ( a1 <= 2 )
return 1LL;
if ( (a1 & 1) == 0 )
return 0LL;
v1 = 2LL;
while ( a1 != ++v1 )
{
if ( !(a1 % v1) )
return 0LL;
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func9(unsigned __int64 a1)
{
unsigned __int64 v1; // rcx

if ( a1 <= 2 )
return 1LL;
if ( (a1 & 1) == 0 )
return 0LL;
v1 = 2LL;
while ( a1 != ++v1 )
{
if ( !(a1 % v1) )
return 0LL;
}
return 1LL;
}

original_code:
bool isprime(unsigned long n)
{
 unsigned long i;
 for (i = 2; i < n; i++)
 {
  if (n % i == 0)
  {
   return 0;
  }
 }
 return 1;
}

canonical_original_code:
char isprime(unsigned long n)
{
 unsigned long i;
 for (i = 2; i < n; i++)
 {
  if (n % i == 0)
  {
   return 0;
  }
 }
 return 1;
}

variable_types:
n
unsigned long

variable_types:
i
unsigned long

return_type: char


encrypt

decompiled_code:
__int64 encrypt()
{
__gmpz_init();
__gmpz_init();
__gmpz_init();
__gmpz_init();
__gmpz_set_ui();
__gmpz_set_ui();
__gmpz_set_ui();
__gmpz_powm();
return __gmpz_get_ui();
}

canonical_decompiled_code:
__int64 func10()
{
__gmpz_init();
__gmpz_init();
__gmpz_init();
__gmpz_init();
__gmpz_set_ui();
__gmpz_set_ui();
__gmpz_set_ui();
__gmpz_powm();
return __gmpz_get_ui();
}

original_code:
unsigned long int encrypt(unsigned long long in, unsigned long long n, unsigned long long d)
{
 mpz_t tmp;
 mpz_t out;
 mpz_t exp;
 mpz_t mod;
 __gmpz_init(tmp);
 __gmpz_init(out);
 __gmpz_init(exp);
 __gmpz_init(mod);
 __gmpz_set_ui(tmp, in);
 __gmpz_set_ui(exp, d);
 __gmpz_set_ui(mod, n);
 __gmpz_powm(out, tmp, exp, mod);
 return __gmpz_get_ui(out);
}

canonical_original_code:
unsigned long encrypt(unsigned long long in, unsigned long long n, unsigned long long d)
{
 struct __mpz_struct tmp[1];
 struct __mpz_struct out[1];
 struct __mpz_struct exp[1];
 struct __mpz_struct mod[1];
 __gmpz_init(tmp);
 __gmpz_init(out);
 __gmpz_init(exp);
 __gmpz_init(mod);
 __gmpz_set_ui(tmp, in);
 __gmpz_set_ui(exp, d);
 __gmpz_set_ui(mod, n);
 __gmpz_powm(out, tmp, exp, mod);
 return __gmpz_get_ui(out);
}

variable_types:
in
unsigned long long

variable_types:
n
unsigned long long

variable_types:
d
unsigned long long

variable_types: struct __mpz_struct { int _mp_alloc; int _mp_size; unsigned long *_mp_d; } [1]


decrypt

decompiled_code:
__int64 decrypt()
{
return encrypt();
}

canonical_decompiled_code:
__int64 func11()
{
return func10();
}

original_code:
unsigned long int decrypt(unsigned long long in, unsigned long long n, unsigned long long d)
{
 return encrypt(in, n, d);
}

canonical_original_code:
unsigned long decrypt(unsigned long long in, unsigned long long n, unsigned long long d)
{
 return encrypt(in, n, d);
}


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // rbx
char *v4; // rax
char v6[536]; // [rsp+0h] [rbp-218h] BYREF

printf("HEX: ");
while ( fgets(v6, 513, stdin) )
{
v4 = strchr(v6, 10);
if ( v4 )
*v4 = 0;
if ( !v6[0] )
break;
v3 = (char *)hex2bin(v6);
printf("BIN: %s\n", v3);
free(v3);
printf("HEX: ");
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // rbx
char *v4; // rax
char v6[536]; // [rsp+0h] [rbp-218h] BYREF

printf("HEX: ");
while ( fgets(v6, 513, stdin) )
{
v4 = strchr(v6, 10);
if ( v4 )
*v4 = 0;
if ( !v6[0] )
break;
v3 = (char *)func7(v6);
printf("BIN: %s\n", v3);
free(v3);
printf("HEX: ");
}
return 0;
}

original_code:
int main(int argc, char *argv[]) {
 char input[512+1];
    printf("HEX: ");
    while(fgets(input, sizeof input, stdin)) {
        char *pos=input;
        if (((void *)0) != (pos = strchr(pos, '\n'))) *pos = '\0';
        if (strlen(input) == 0) break;
  char* ans = ((void *)0);
  ans = hex2bin(input);
  printf("BIN: %s\n", ans);
  free(ans);
        printf("HEX: ");
 }
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[]) {
 char input[-1];
    printf("HEX: ");
    while(fgets(input, sizeof input, stdin)) {
        char *pos = input;
        if (((void *)0) != (pos = strchr(pos, '\n'))) *pos = '\0';
        if (strlen(input) == 0) break;
  char *ans = ((void *)0);
  ans = hex2bin(input);
  printf("BIN: %s\n", ans);
  free(ans);
        printf("HEX: ");
 }
 return 0;
}

variable_types:
argv
char *[]

variable_types:
input
char [-1]

variable_types:
pos
char *

variable_types:
ans
char *


decompiled_code:
char *__fastcall hex2bin(const char *a1)
{
const char *v1; // rbx
int v2; // eax
char *v3; // rbp
char v4; // al

v1 = a1;
v2 = strlen(a1);
v3 = (char *)malloc(4 * v2);
*v3 = 0;
v4 = *a1;
if ( *a1 )
{
while ( 2 )
{
switch ( v4 )
{
case '0':
strcpy(&v3[strlen(v3)], "0000");
goto LABEL_4;
case '1':
strcpy(&v3[strlen(v3)], "0001");
goto LABEL_4;
case '2':
strcpy(&v3[strlen(v3)], "0010");
goto LABEL_4;
case '3':
strcpy(&v3[strlen(v3)], "0011");
goto LABEL_4;
case '4':
strcpy(&v3[strlen(v3)], "0100");
goto LABEL_4;
case '5':
strcpy(&v3[strlen(v3)], "0101");
goto LABEL_4;
case '6':
strcpy(&v3[strlen(v3)], "0110");
goto LABEL_4;
case '7':
strcpy(&v3[strlen(v3)], "0111");
goto LABEL_4;
case '8':
strcpy(&v3[strlen(v3)], "1000");
goto LABEL_4;
case '9':
strcpy(&v3[strlen(v3)], "1001");
goto LABEL_4;
case 'A':
case 'a':
strcpy(&v3[strlen(v3)], "1010");
goto LABEL_4;
case 'B':
case 'b':
strcpy(&v3[strlen(v3)], "1011");
goto LABEL_4;
case 'C':
case 'c':
strcpy(&v3[strlen(v3)], "1100");
goto LABEL_4;
case 'D':
case 'd':
strcpy(&v3[strlen(v3)], "1101");
goto LABEL_4;
case 'E':
case 'e':
strcpy(&v3[strlen(v3)], "1110");
goto LABEL_4;
case 'F':
case 'f':
strcpy(&v3[strlen(v3)], "1111");
LABEL_4:
v4 = *++v1;
if ( *v1 )
continue;
return v3;
default:
free(v3);
return 0LL;
}
}
}
return v3;
}

canonical_decompiled_code:
char *__fastcall func7(const char *a1)
{
const char *v1; // rbx
int v2; // eax
char *v3; // rbp
char v4; // al

v1 = a1;
v2 = strlen(a1);
v3 = (char *)malloc(4 * v2);
*v3 = 0;
v4 = *a1;
if ( *a1 )
{
while ( 2 )
{
switch ( v4 )
{
case '0':
strcpy(&v3[strlen(v3)], "0000");
goto LABEL_4;
case '1':
strcpy(&v3[strlen(v3)], "0001");
goto LABEL_4;
case '2':
strcpy(&v3[strlen(v3)], "0010");
goto LABEL_4;
case '3':
strcpy(&v3[strlen(v3)], "0011");
goto LABEL_4;
case '4':
strcpy(&v3[strlen(v3)], "0100");
goto LABEL_4;
case '5':
strcpy(&v3[strlen(v3)], "0101");
goto LABEL_4;
case '6':
strcpy(&v3[strlen(v3)], "0110");
goto LABEL_4;
case '7':
strcpy(&v3[strlen(v3)], "0111");
goto LABEL_4;
case '8':
strcpy(&v3[strlen(v3)], "1000");
goto LABEL_4;
case '9':
strcpy(&v3[strlen(v3)], "1001");
goto LABEL_4;
case 'A':
case 'a':
strcpy(&v3[strlen(v3)], "1010");
goto LABEL_4;
case 'B':
case 'b':
strcpy(&v3[strlen(v3)], "1011");
goto LABEL_4;
case 'C':
case 'c':
strcpy(&v3[strlen(v3)], "1100");
goto LABEL_4;
case 'D':
case 'd':
strcpy(&v3[strlen(v3)], "1101");
goto LABEL_4;
case 'E':
case 'e':
strcpy(&v3[strlen(v3)], "1110");
goto LABEL_4;
case 'F':
case 'f':
strcpy(&v3[strlen(v3)], "1111");
LABEL_4:
v4 = *++v1;
if ( *v1 )
continue;
return v3;
default:
free(v3);
return 0LL;
}
}
}
return v3;
}

original_code:
char* hex2bin(const char* hex)
{
 int len = strlen(hex);
 char* bin = malloc(4*len*sizeof(char));
 *bin = '\0';
 while(*hex) {
  switch(*hex) {
  case '0':
   strcat(bin, "0000");
   break;
  case '1':
   strcat(bin, "0001");
   break;
  case '2':
   strcat(bin, "0010");
   break;
  case '3':
   strcat(bin, "0011");
   break;
  case '4':
   strcat(bin, "0100");
   break;
  case '5':
   strcat(bin, "0101");
   break;
  case '6':
   strcat(bin, "0110");
   break;
  case '7':
   strcat(bin, "0111");
   break;
  case '8':
   strcat(bin, "1000");
   break;
  case '9':
   strcat(bin, "1001");
   break;
  case 'A': case 'a':
   strcat(bin, "1010");
   break;
  case 'B': case 'b':
   strcat(bin, "1011");
   break;
  case 'C': case 'c':
   strcat(bin, "1100");
   break;
  case 'D': case 'd':
   strcat(bin, "1101");
   break;
  case 'E': case 'e':
   strcat(bin, "1110");
   break;
  case 'F': case 'f':
   strcat(bin, "1111");
   break;
  default:
            free(bin);
            return ((void *)0);
  }
  ++hex;
 }
 return bin;
}

canonical_original_code:
char *hex2bin(char *hex)
{
 int len = strlen(hex);
 char *bin = malloc(4*len*sizeof(char));
 *bin = '\0';
 while(*hex) {
  switch(*hex) {
  case '0':
   strcat(bin, "0000");
   break;
  case '1':
   strcat(bin, "0001");
   break;
  case '2':
   strcat(bin, "0010");
   break;
  case '3':
   strcat(bin, "0011");
   break;
  case '4':
   strcat(bin, "0100");
   break;
  case '5':
   strcat(bin, "0101");
   break;
  case '6':
   strcat(bin, "0110");
   break;
  case '7':
   strcat(bin, "0111");
   break;
  case '8':
   strcat(bin, "1000");
   break;
  case '9':
   strcat(bin, "1001");
   break;
  case 'A': case 'a':
   strcat(bin, "1010");
   break;
  case 'B': case 'b':
   strcat(bin, "1011");
   break;
  case 'C': case 'c':
   strcat(bin, "1100");
   break;
  case 'D': case 'd':
   strcat(bin, "1101");
   break;
  case 'E': case 'e':
   strcat(bin, "1110");
   break;
  case 'F': case 'f':
   strcat(bin, "1111");
   break;
  default:
            free(bin);
            return ((void *)0);
  }
  ++hex;
 }
 return bin;
}

variable_types:
hex
char *

variable_types: len int

variable_types:
bin
char *


repo: phyw/tzdata

decompiled_code:
char *__fastcall asctime_r(struct tm *tp, char *dest)
{
unsigned int v3; // eax
unsigned int v4; // eax
char *v5; // r12
__int64 v6; // r15
__int64 v7; // r14
unsigned int v8; // er13
unsigned int v9; // ebx
const char *v10; // rsi
size_t v11; // rax
char *result; // rax
char *v13; // [rsp+8h] [rbp-A0h]
char src[83]; // [rsp+10h] [rbp-98h] BYREF
char s[69]; // [rsp+63h] [rbp-45h] BYREF

if ( tp )
{
v3 = tp->tm_wday;
v13 = (char *)&unk_1A8;
if ( v3 <= 6 )
v13 = (char *)&wday_name_1 + 3 * (int)v3;
v4 = tp->tm_mon;
v5 = (char *)&unk_1A8;
if ( v4 <= 0xB )
v5 = &mon_name_0[3 * v4];
strftime(s, 0xDuLL, "%Y", tp);
v6 = (unsigned int)tp->tm_sec;
v7 = (unsigned int)tp->tm_min;
v8 = tp->tm_hour;
v9 = tp->tm_mday;
v10 = "%.3s %.3s%3d %2.2d:%2.2d:%2.2d %-4s\n";
if ( strlen(s) > 4 )
v10 = "%.3s %.3s%3d %2.2d:%2.2d:%2.2d %s\n";
sprintf(src, v10, v13, v5, v9, v8, v7, v6, s);
v11 = strlen(src);
if ( dest == buf_asctime || v11 <= 0x19 )
{
result = strcpy(dest, src);
}
else
{
*_errno_location() = 75;
result = 0LL;
}
}
else
{
*_errno_location() = 22;
strcpy(dest, "??? ??? ?? ??:??:?? ????\n");
result = dest;
}
return result;
}

canonical_decompiled_code:
char *__fastcall func0(struct tm *tp, char *dest)
{
unsigned int v3; // eax
unsigned int v4; // eax
char *v5; // r12
__int64 v6; // r15
__int64 v7; // r14
unsigned int v8; // er13
unsigned int v9; // ebx
const char *v10; // rsi
size_t v11; // rax
char *result; // rax
char *v13; // [rsp+8h] [rbp-A0h]
char src[83]; // [rsp+10h] [rbp-98h] BYREF
char s[69]; // [rsp+63h] [rbp-45h] BYREF

if ( tp )
{
v3 = tp->tm_wday;
v13 = (char *)&unk_1A8;
if ( v3 <= 6 )
v13 = (char *)&wday_name_1 + 3 * (int)v3;
v4 = tp->tm_mon;
v5 = (char *)&unk_1A8;
if ( v4 <= 0xB )
v5 = &mon_name_0[3 * v4];
strftime(s, 0xDuLL, "%Y", tp);
v6 = (unsigned int)tp->tm_sec;
v7 = (unsigned int)tp->tm_min;
v8 = tp->tm_hour;
v9 = tp->tm_mday;
v10 = "%.3s %.3s%3d %2.2d:%2.2d:%2.2d %-4s\n";
if ( strlen(s) > 4 )
v10 = "%.3s %.3s%3d %2.2d:%2.2d:%2.2d %s\n";
sprintf(src, v10, v13, v5, v9, v8, v7, v6, s);
v11 = strlen(src);
if ( dest == buf_asctime || v11 <= 0x19 )
{
result = strcpy(dest, src);
}
else
{
*_errno_location() = 75;
result = 0LL;
}
}
else
{
*_errno_location() = 22;
strcpy(dest, "??? ??? ?? ??:??:?? ????\n");
result = dest;
}
return result;
}

original_code:
char *
asctime_r(register const struct tm *timeptr, char *buf)
{
 static const char wday_name[][3] = {
  "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
 };
 static const char mon_name[][3] = {
  "Jan", "Feb", "Mar", "Apr", "May", "Jun",
  "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
 };
 register const char * wn;
 register const char * mn;
 char year[(((sizeof (int) * 8) - (((int) -1) < 0)) * 302 / 1000 + 1 + (((int) -1) < 0)) + 2];
 char result[(2*3+5*(((sizeof (int) * 8) - (((int) -1) < 0)) * 302 / 1000 + 1 + (((int) -1) < 0))+7+2+1+1)];
 if (timeptr == ((void *)0)) {
  (*__errno_location ()) = 22;
  return strcpy(buf, "??? ??? ?? ??:??:?? ????\n");
 }
 if (timeptr->tm_wday < 0 || timeptr->tm_wday >= 7)
  wn = "???";
 else wn = wday_name[timeptr->tm_wday];
 if (timeptr->tm_mon < 0 || timeptr->tm_mon >= 12)
  mn = "???";
 else mn = mon_name[timeptr->tm_mon];
 (void) strftime(year, sizeof year, "%Y", timeptr);
 (void) sprintf(result,
  ((strlen(year) <= 4) ? "%.3s %.3s%3d %2.2d:%2.2d:%2.2d %-4s\n" : "%.3s %.3s%3d %2.2d:%2.2d:%2.2d     %s\n"),
  wn, mn,
  timeptr->tm_mday, timeptr->tm_hour,
  timeptr->tm_min, timeptr->tm_sec,
  year);
 if (strlen(result) < 26 || buf == buf_asctime)
  return strcpy(buf, result);
 else {
  (*__errno_location ()) = 75;
  return ((void *)0);
 }
}

canonical_original_code:
char *asctime_r(struct tm *timeptr, char *buf)
{
 static char wday_name[][3] = {
  "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
 };
 static char mon_name[][3] = {
  "Jan", "Feb", "Mar", "Apr", "May", "Jun",
  "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
 };
 register char *wn;
 register char *mn;
 char year[-1];
 char result[-1];
 if (timeptr == ((void *)0)) {
  (*__errno_location ()) = 22;
  return strcpy(buf, "??? ??? ?? ??:??:?? ????\n");
 }
 if (timeptr->tm_wday < 0 || timeptr->tm_wday >= 7)
  wn = "???";
 else wn = wday_name[timeptr->tm_wday];
 if (timeptr->tm_mon < 0 || timeptr->tm_mon >= 12)
  mn = "???";
 else mn = mon_name[timeptr->tm_mon];
 (void) strftime(year, sizeof year, "%Y", timeptr);
 (void) sprintf(result,
  ((strlen(year) <= 4) ? "%.3s %.3s%3d %2.2d:%2.2d:%2.2d %-4s\n" : "%.3s %.3s%3d %2.2d:%2.2d:%2.2d     %s\n"),
  wn, mn,
  timeptr->tm_mday, timeptr->tm_hour,
  timeptr->tm_min, timeptr->tm_sec,
  year);
 if (strlen(result) < 26 || buf == buf_asctime)
  return strcpy(buf, result);
 else {
  (*__errno_location ()) = 75;
  return ((void *)0);
 }
}

variable_types: struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; } *

variable_types:
buf
char *

variable_types:
wn
char *

variable_types:
mn
char *

variable_types:
year
char [-1]

variable_types:
result
char [-1]


asctime

decompiled_code:
char *__fastcall asctime(struct tm *a1)
{
return asctime_r(a1, buf_asctime);
}

canonical_decompiled_code:
char *__fastcall func1(struct tm *a1)
{
return func0(a1, buf_asctime);
}

original_code:
char *
asctime(register const struct tm *timeptr)
{
 return asctime_r(timeptr, buf_asctime);
}

canonical_original_code:
char *asctime(struct tm *timeptr)
{
 return asctime_r(timeptr, buf_asctime);
}

user_defined_types: struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; }