decompiled_code:
__int64 __fastcall ASN1_PRINTABLE_type(unsigned __int8 *a1, int a2)
{
unsigned __int64 v2; // rax
unsigned __int8 *v3; // rcx
int v4; // esi
int v5; // er9
unsigned __int64 v6; // r11
__int64 result; // rax

if ( a2 <= 0 )
a2 = -1;
if ( !a1 )
return 19LL;
v2 = *a1;
if ( !(_BYTE)v2 )
return 19LL;
v3 = &a1[a2];
v4 = 0;
v5 = 0;
v6 = 0xA7FFFB8100000000LL;
do
{
++a1;
if ( (unsigned __int8)v2 > 0x3Fu )
{
if ( (unsigned __int8)((v2 & 0xDF) - 65) >= 0x1Au )
v5 = 1;
}
else if ( !_bittest64((const __int64 *)&v6, v2) && (unsigned __int8)((v2 & 0xDF) - 65) > 0x19u )
{
v5 = 1;
goto LABEL_10;
}
if ( (v2 & 0x80u) != 0LL )
v4 = 1;
LABEL_10:
v2 = *a1;
}
while ( (_BYTE)v2 && v3 != a1 );
result = 20LL;
if ( !v4 )
result = v5 == 0 ? 19 : 22;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int8 *a1, int a2)
{
unsigned __int64 v2; // rax
unsigned __int8 *v3; // rcx
int v4; // esi
int v5; // er9
unsigned __int64 v6; // r11
__int64 result; // rax

if ( a2 <= 0 )
a2 = -1;
if ( !a1 )
return 19LL;
v2 = *a1;
if ( !(_BYTE)v2 )
return 19LL;
v3 = &a1[a2];
v4 = 0;
v5 = 0;
v6 = 0xA7FFFB8100000000LL;
do
{
++a1;
if ( (unsigned __int8)v2 > 0x3Fu )
{
if ( (unsigned __int8)((v2 & 0xDF) - 65) >= 0x1Au )
v5 = 1;
}
else if ( !_bittest64((const __int64 *)&v6, v2) && (unsigned __int8)((v2 & 0xDF) - 65) > 0x19u )
{
v5 = 1;
goto LABEL_10;
}
if ( (v2 & 0x80u) != 0LL )
v4 = 1;
LABEL_10:
v2 = *a1;
}
while ( (_BYTE)v2 && v3 != a1 );
result = 20LL;
if ( !v4 )
result = v5 == 0 ? 19 : 22;
return result;
}

variable_types:
s
unsigned char *

variable_types: c int


decompiled_code:
_QWORD *ecdh_data_new()
{
return ECDH_DATA_new_method(0LL);
}

canonical_decompiled_code:
_QWORD *func3()
{
return ECDH_DATA_new_method(0LL);
}

original_code:
static void *ecdh_data_new(void)
{
    return (void *)ECDH_DATA_new_method(NULL);
}

canonical_original_code:
static void *ecdh_data_new()
{
    return (void *)ECDH_DATA_new_method(NULL);
}

return_type: void *


decompiled_code:
__int64 engine_unregister_all_STORE()
{
return engine_table_cleanup(&store_table);
}

canonical_decompiled_code:
__int64 func0()
{
return engine_table_cleanup(&store_table);
}

original_code:
static void engine_unregister_all_STORE(void)
{
    engine_table_cleanup(&store_table);
}

canonical_original_code:
static void engine_unregister_all_STORE()
{
    engine_table_cleanup(&store_table);
}

return_type: void


decompiled_code:
__int64 OPENSSL_load_builtin_modules()
{
ASN1_add_oid_module();
ENGINE_add_conf_module();
return EVP_add_alg_module();
}

canonical_decompiled_code:
__int64 func0()
{
ASN1_add_oid_module();
ENGINE_add_conf_module();
return EVP_add_alg_module();
}

original_code:
void OPENSSL_load_builtin_modules(void)
{
    /* Add builtin modules here */
    ASN1_add_oid_module();
#ifndef OPENSSL_NO_ENGINE
    ENGINE_add_conf_module();
#endif
    EVP_add_alg_module();
}

canonical_original_code:
void OPENSSL_load_builtin_modules()
{
    /* Add builtin modules here */
    ASN1_add_oid_module();
#ifndef OPENSSL_NO_ENGINE
    ENGINE_add_conf_module();
#endif
    EVP_add_alg_module();
}


decompiled_code:
_QWORD *ecdsa_data_new()
{
return ECDSA_DATA_new_method(0LL);
}

canonical_decompiled_code:
_QWORD *func3()
{
return ECDSA_DATA_new_method(0LL);
}

original_code:
static void *ecdsa_data_new(void)
{
    return (void *)ECDSA_DATA_new_method(NULL);
}

canonical_original_code:
static void *ecdsa_data_new()
{
    return (void *)ECDSA_DATA_new_method(NULL);
}


decompiled_code:
__int64 ENGINE_get_table_flags()
{
return (unsigned int)table_flags;
}

canonical_decompiled_code:
__int64 func11()
{
return (unsigned int)table_flags;
}

original_code:
unsigned int ENGINE_get_table_flags(void)
{
    return table_flags;
}

canonical_original_code:
unsigned int ENGINE_get_table_flags()
{
    return table_flags;
}

return_type: unsigned int


decompiled_code:
void __fastcall ENGINE_set_table_flags(int a1)
{
table_flags = a1;
}

canonical_decompiled_code:
void __fastcall func12(int a1)
{
table_flags = a1;
}

original_code:
void ENGINE_set_table_flags(unsigned int flags)
{
    table_flags = flags;
}

variable_types:
flags
unsigned int


decompiled_code:
__int64 engine_unregister_all_DH()
{
return engine_table_cleanup(&dh_table);
}

canonical_decompiled_code:
__int64 func0()
{
return engine_table_cleanup(&dh_table);
}

original_code:
static void engine_unregister_all_DH(void)
{
    engine_table_cleanup(&dh_table);
}

canonical_original_code:
static void engine_unregister_all_DH()
{
    engine_table_cleanup(&dh_table);
}


decompiled_code:
__int64 ERR_load_crypto_strings()
{
ERR_load_ERR_strings();
ERR_load_BN_strings();
ERR_load_RSA_strings();
ERR_load_DH_strings();
ERR_load_EVP_strings();
ERR_load_BUF_strings();
ERR_load_OBJ_strings();
ERR_load_PEM_strings();
ERR_load_DSA_strings();
ERR_load_X509_strings();
ERR_load_ASN1_strings();
ERR_load_CONF_strings();
ERR_load_CRYPTO_strings();
ERR_load_COMP_strings();
ERR_load_EC_strings();
ERR_load_ECDSA_strings();
ERR_load_ECDH_strings();
ERR_load_BIO_strings();
ERR_load_PKCS7_strings();
ERR_load_X509V3_strings();
ERR_load_PKCS12_strings();
ERR_load_RAND_strings();
ERR_load_DSO_strings();
ERR_load_TS_strings();
ERR_load_ENGINE_strings();
ERR_load_OCSP_strings();
ERR_load_UI_strings();
return ERR_load_CMS_strings();
}

canonical_decompiled_code:
__int64 func0()
{
ERR_load_ERR_strings();
ERR_load_BN_strings();
ERR_load_RSA_strings();
ERR_load_DH_strings();
ERR_load_EVP_strings();
ERR_load_BUF_strings();
ERR_load_OBJ_strings();
ERR_load_PEM_strings();
ERR_load_DSA_strings();
ERR_load_X509_strings();
ERR_load_ASN1_strings();
ERR_load_CONF_strings();
ERR_load_CRYPTO_strings();
ERR_load_COMP_strings();
ERR_load_EC_strings();
ERR_load_ECDSA_strings();
ERR_load_ECDH_strings();
ERR_load_BIO_strings();
ERR_load_PKCS7_strings();
ERR_load_X509V3_strings();
ERR_load_PKCS12_strings();
ERR_load_RAND_strings();
ERR_load_DSO_strings();
ERR_load_TS_strings();
ERR_load_ENGINE_strings();
ERR_load_OCSP_strings();
ERR_load_UI_strings();
return ERR_load_CMS_strings();
}

original_code:
void ERR_load_crypto_strings(void)
{
#ifndef OPENSSL_NO_ERR
    ERR_load_ERR_strings();     /* include error strings for SYSerr */
    ERR_load_BN_strings();
# ifndef OPENSSL_NO_RSA
    ERR_load_RSA_strings();
# endif
# ifndef OPENSSL_NO_DH
    ERR_load_DH_strings();
# endif
    ERR_load_EVP_strings();
    ERR_load_BUF_strings();
    ERR_load_OBJ_strings();
    ERR_load_PEM_strings();
# ifndef OPENSSL_NO_DSA
    ERR_load_DSA_strings();
# endif
    ERR_load_X509_strings();
    ERR_load_ASN1_strings();
    ERR_load_CONF_strings();
    ERR_load_CRYPTO_strings();
# ifndef OPENSSL_NO_COMP
    ERR_load_COMP_strings();
# endif
# ifndef OPENSSL_NO_EC
    ERR_load_EC_strings();
# endif
# ifndef OPENSSL_NO_ECDSA
    ERR_load_ECDSA_strings();
# endif
# ifndef OPENSSL_NO_ECDH
    ERR_load_ECDH_strings();
# endif
    /* skip ERR_load_SSL_strings() because it is not in this library */
    ERR_load_BIO_strings();
    ERR_load_PKCS7_strings();
    ERR_load_X509V3_strings();
    ERR_load_PKCS12_strings();
    ERR_load_RAND_strings();
    ERR_load_DSO_strings();
    ERR_load_TS_strings();
# ifndef OPENSSL_NO_ENGINE
    ERR_load_ENGINE_strings();
# endif
    ERR_load_OCSP_strings();
    ERR_load_UI_strings();
# ifdef OPENSSL_FIPS
    ERR_load_FIPS_strings();
# endif
# ifndef OPENSSL_NO_CMS
    ERR_load_CMS_strings();
# endif
# ifndef OPENSSL_NO_JPAKE
    ERR_load_JPAKE_strings();
# endif
#endif
}

canonical_original_code:
void ERR_load_crypto_strings()
{
#ifndef OPENSSL_NO_ERR
    ERR_load_ERR_strings();     /* include error strings for SYSerr */
    ERR_load_BN_strings();
# ifndef OPENSSL_NO_RSA
    ERR_load_RSA_strings();
# endif
# ifndef OPENSSL_NO_DH
    ERR_load_DH_strings();
# endif
    ERR_load_EVP_strings();
    ERR_load_BUF_strings();
    ERR_load_OBJ_strings();
    ERR_load_PEM_strings();
# ifndef OPENSSL_NO_DSA
    ERR_load_DSA_strings();
# endif
    ERR_load_X509_strings();
    ERR_load_ASN1_strings();
    ERR_load_CONF_strings();
    ERR_load_CRYPTO_strings();
# ifndef OPENSSL_NO_COMP
    ERR_load_COMP_strings();
# endif
# ifndef OPENSSL_NO_EC
    ERR_load_EC_strings();
# endif
# ifndef OPENSSL_NO_ECDSA
    ERR_load_ECDSA_strings();
# endif
# ifndef OPENSSL_NO_ECDH
    ERR_load_ECDH_strings();
# endif
    /* skip ERR_load_SSL_strings() because it is not in this library */
    ERR_load_BIO_strings();
    ERR_load_PKCS7_strings();
    ERR_load_X509V3_strings();
    ERR_load_PKCS12_strings();
    ERR_load_RAND_strings();
    ERR_load_DSO_strings();
    ERR_load_TS_strings();
# ifndef OPENSSL_NO_ENGINE
    ERR_load_ENGINE_strings();
# endif
    ERR_load_OCSP_strings();
    ERR_load_UI_strings();
# ifdef OPENSSL_FIPS
    ERR_load_FIPS_strings();
# endif
# ifndef OPENSSL_NO_CMS
    ERR_load_CMS_strings();
# endif
# ifndef OPENSSL_NO_JPAKE
    ERR_load_JPAKE_strings();
# endif
#endif
}


decompiled_code:
__int64 ERR_load_CONF_strings()
{
__int64 result; // rax

result = ERR_func_error_string(CONF_str_functs);
if ( !result )
{
ERR_load_strings(0LL, &CONF_str_functs);
result = ERR_load_strings(0LL, &CONF_str_reasons);
}
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 result; // rax

result = ERR_func_error_string(CONF_str_functs);
if ( !result )
{
ERR_load_strings(0LL, &CONF_str_functs);
result = ERR_load_strings(0LL, &CONF_str_reasons);
}
return result;
}

original_code:
void ERR_load_CONF_strings(void)
{
#ifndef OPENSSL_NO_ERR

    if (ERR_func_error_string(CONF_str_functs[0].error) == NULL) {
        ERR_load_strings(0, CONF_str_functs);
        ERR_load_strings(0, CONF_str_reasons);
    }
#endif
}

canonical_original_code:
void ERR_load_CONF_strings()
{
#ifndef OPENSSL_NO_ERR

    if (ERR_func_error_string(CONF_str_functs[0].error) == NULL) {
        ERR_load_strings(0, CONF_str_functs);
        ERR_load_strings(0, CONF_str_reasons);
    }
#endif
}


decompiled_code:
__int64 engine_unregister_all_digests()
{
return engine_table_cleanup(&digest_table);
}

canonical_decompiled_code:
__int64 func0()
{
return engine_table_cleanup(&digest_table);
}

original_code:
static void engine_unregister_all_digests(void)
{
    engine_table_cleanup(&digest_table);
}

canonical_original_code:
static void engine_unregister_all_digests()
{
    engine_table_cleanup(&digest_table);
}


decompiled_code:
__int64 __fastcall ENGINE_init(__int64 a1)
{
unsigned int v1; // ebx

v1 = a1;
if ( a1 )
{
CRYPTO_lock(9LL, 30LL, "eng_init.c", 134LL);
v1 = engine_unlocked_init(a1);
CRYPTO_lock(10LL, 30LL, "eng_init.c", 136LL);
}
else
{
ERR_put_error(38LL, 119LL, 67LL, "eng_init.c", 131LL);
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
unsigned int v1; // ebx

v1 = a1;
if ( a1 )
{
CRYPTO_lock(9LL, 30LL, "eng_init.c", 134LL);
v1 = func0(a1);
CRYPTO_lock(10LL, 30LL, "eng_init.c", 136LL);
}
else
{
ERR_put_error(38LL, 119LL, 67LL, "eng_init.c", 131LL);
}
return v1;
}

original_code: char ENGINE_init(void) {return 0;}

canonical_original_code: char ENGINE_init() {return 0;}

return_type: char


decompiled_code:
_BOOL8 OPENSSL_issetugid()
{
__uid_t v0; // ebx
__uid_t v1; // edx
_BOOL8 result; // rax
__gid_t v3; // ebx

v0 = getuid();
v1 = geteuid();
result = 1LL;
if ( v0 == v1 )
{
v3 = getgid();
result = v3 != getegid();
}
return result;
}

canonical_decompiled_code:
_BOOL8 func0()
{
__uid_t v0; // ebx
__uid_t v1; // edx
_BOOL8 result; // rax
__gid_t v3; // ebx

v0 = getuid();
v1 = geteuid();
result = 1LL;
if ( v0 == v1 )
{
v3 = getgid();
result = v3 != getegid();
}
return result;
}

original_code:
int OPENSSL_issetugid(void)
{
    if (getuid() != geteuid())
        return 1;
    if (getgid() != getegid())
        return 1;
    return 0;
}

canonical_original_code:
int OPENSSL_issetugid()
{
    if (getuid() != geteuid())
        return 1;
    if (getgid() != getegid())
        return 1;
    return 0;
}

return_type: int


decompiled_code:
__int64 __fastcall parse_http_line1(char *nptr)
{
unsigned __int8 v1; // r12
char *v2; // rbx
const unsigned __int16 **v3; // rbp
const unsigned __int16 *v4; // rcx
unsigned __int8 v5; // al
__int64 result; // rax
unsigned __int8 v7; // al
char *v8; // r14
int v9; // er13
const char *v10; // r12
unsigned __int8 v11; // al
__int64 v12; // rcx
__int64 v13; // r8
char *endptr; // [rsp+8h] [rbp-30h] BYREF

v1 = *nptr;
if ( *nptr )
{
v2 = nptr;
v3 = _ctype_b_loc();
v4 = *v3;
while ( (v4[v1] & 0x2000) == 0 )
{
v1 = *++v2;
if ( !*v2 )
goto LABEL_9;
}
v5 = *v2;
if ( *v2 )
{
while ( (v4[v5] & 0x2000) != 0 )
{
v5 = *++v2;
if ( !*v2 )
goto LABEL_7;
}
v7 = *v2;
v8 = v2;
if ( *v2 )
{
while ( (v4[v7] & 0x2000) == 0 )
{
v7 = *++v8;
if ( !*v8 )
goto LABEL_18;
}
*v8 = 0;
v9 = strtoul(v2, &endptr, 10);
result = 0LL;
if ( !*endptr )
{
v10 = v8 + 1;
v11 = v8[1];
if ( v11 )
{
while ( ((*v3)[v11] & 0x2000) != 0 )
{
v11 = *++v10;
if ( !*v10 )
goto LABEL_24;
}
if ( v11 )
{
for ( endptr = (char *)&v10[strlen(v10) - 1]; ((*v3)[(unsigned __int8)*endptr] & 0x2000) != 0; --endptr )
*endptr = 0;
}
}
LABEL_24:
result = 1LL;
if ( v9 != 200 )
{
ERR_put_error(39LL, 118LL, 114LL, "ocsp_ht.c", 247LL);
if ( *v10 )
ERR_add_error_data(4LL, "Code=", v2, ",Reason=", v10);
else
ERR_add_error_data(2LL, "Code=", v2, v12, v13);
result = 0LL;
}
}
}
else
{
LABEL_18:
ERR_put_error(39LL, 118LL, 115LL, "ocsp_ht.c", 220LL);
result = 0LL;
}
}
else
{
LABEL_7:
ERR_put_error(39LL, 118LL, 115LL, "ocsp_ht.c", 211LL);
result = 0LL;
}
}
else
{
LABEL_9:
ERR_put_error(39LL, 118LL, 115LL, "ocsp_ht.c", 202LL);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *nptr)
{
unsigned __int8 v1; // r12
char *v2; // rbx
const unsigned __int16 **v3; // rbp
const unsigned __int16 *v4; // rcx
unsigned __int8 v5; // al
__int64 result; // rax
unsigned __int8 v7; // al
char *v8; // r14
int v9; // er13
const char *v10; // r12
unsigned __int8 v11; // al
__int64 v12; // rcx
__int64 v13; // r8
char *endptr; // [rsp+8h] [rbp-30h] BYREF

v1 = *nptr;
if ( *nptr )
{
v2 = nptr;
v3 = _ctype_b_loc();
v4 = *v3;
while ( (v4[v1] & 0x2000) == 0 )
{
v1 = *++v2;
if ( !*v2 )
goto LABEL_9;
}
v5 = *v2;
if ( *v2 )
{
while ( (v4[v5] & 0x2000) != 0 )
{
v5 = *++v2;
if ( !*v2 )
goto LABEL_7;
}
v7 = *v2;
v8 = v2;
if ( *v2 )
{
while ( (v4[v7] & 0x2000) == 0 )
{
v7 = *++v8;
if ( !*v8 )
goto LABEL_18;
}
*v8 = 0;
v9 = strtoul(v2, &endptr, 10);
result = 0LL;
if ( !*endptr )
{
v10 = v8 + 1;
v11 = v8[1];
if ( v11 )
{
while ( ((*v3)[v11] & 0x2000) != 0 )
{
v11 = *++v10;
if ( !*v10 )
goto LABEL_24;
}
if ( v11 )
{
for ( endptr = (char *)&v10[strlen(v10) - 1]; ((*v3)[(unsigned __int8)*endptr] & 0x2000) != 0; --endptr )
*endptr = 0;
}
}
LABEL_24:
result = 1LL;
if ( v9 != 200 )
{
ERR_put_error(39LL, 118LL, 114LL, "ocsp_ht.c", 247LL);
if ( *v10 )
ERR_add_error_data(4LL, "Code=", v2, ",Reason=", v10);
else
ERR_add_error_data(2LL, "Code=", v2, v12, v13);
result = 0LL;
}
}
}
else
{
LABEL_18:
ERR_put_error(39LL, 118LL, 115LL, "ocsp_ht.c", 220LL);
result = 0LL;
}
}
else
{
LABEL_7:
ERR_put_error(39LL, 118LL, 115LL, "ocsp_ht.c", 211LL);
result = 0LL;
}
}
else
{
LABEL_9:
ERR_put_error(39LL, 118LL, 115LL, "ocsp_ht.c", 202LL);
result = 0LL;
}
return result;
}

original_code:
static int parse_http_line1(char *line)
{
    int retcode;
    char *p, *q, *r;
    /* Skip to first white space (passed protocol info) */

    for (p = line; *p && !isspace((unsigned char)*p); p++)
        continue;
    if (!*p) {
        OCSPerr(OCSP_F_PARSE_HTTP_LINE1, OCSP_R_SERVER_RESPONSE_PARSE_ERROR);
        return 0;
    }

    /* Skip past white space to start of response code */
    while (*p && isspace((unsigned char)*p))
        p++;

    if (!*p) {
        OCSPerr(OCSP_F_PARSE_HTTP_LINE1, OCSP_R_SERVER_RESPONSE_PARSE_ERROR);
        return 0;
    }

    /* Find end of response code: first whitespace after start of code */
    for (q = p; *q && !isspace((unsigned char)*q); q++)
        continue;

    if (!*q) {
        OCSPerr(OCSP_F_PARSE_HTTP_LINE1, OCSP_R_SERVER_RESPONSE_PARSE_ERROR);
        return 0;
    }

    /* Set end of response code and start of message */
    *q++ = 0;

    /* Attempt to parse numeric code */
    retcode = strtoul(p, &r, 10);

    if (*r)
        return 0;

    /* Skip over any leading white space in message */
    while (*q && isspace((unsigned char)*q))
        q++;

    if (*q) {
        /*
         * Finally zap any trailing white space in message (include CRLF)
         */

        /* We know q has a non white space character so this is OK */
        for (r = q + strlen(q) - 1; isspace((unsigned char)*r); r--)
            *r = 0;
    }
    if (retcode != 200) {
        OCSPerr(OCSP_F_PARSE_HTTP_LINE1, OCSP_R_SERVER_RESPONSE_ERROR);
        if (!*q)
            ERR_add_error_data(2, "Code=", p);
        else
            ERR_add_error_data(4, "Code=", p, ",Reason=", q);
        return 0;
    }

    return 1;

}

canonical_original_code:
static int parse_http_line1(char *line)
{
    int retcode;
    char *p; char *q; char *r;
    /* Skip to first white space (passed protocol info) */

    for (p = line; *p && !isspace((unsigned char)*p); p++)
        continue;
    if (!*p) {
        OCSPerr(OCSP_F_PARSE_HTTP_LINE1, OCSP_R_SERVER_RESPONSE_PARSE_ERROR);
        return 0;
    }

    /* Skip past white space to start of response code */
    while (*p && isspace((unsigned char)*p))
        p++;

    if (!*p) {
        OCSPerr(OCSP_F_PARSE_HTTP_LINE1, OCSP_R_SERVER_RESPONSE_PARSE_ERROR);
        return 0;
    }

    /* Find end of response code: first whitespace after start of code */
    for (q = p; *q && !isspace((unsigned char)*q); q++)
        continue;

    if (!*q) {
        OCSPerr(OCSP_F_PARSE_HTTP_LINE1, OCSP_R_SERVER_RESPONSE_PARSE_ERROR);
        return 0;
    }

    /* Set end of response code and start of message */
    *q++ = 0;

    /* Attempt to parse numeric code */
    retcode = strtoul(p, &r, 10);

    if (*r)
        return 0;

    /* Skip over any leading white space in message */
    while (*q && isspace((unsigned char)*q))
        q++;

    if (*q) {
        /*
         * Finally zap any trailing white space in message (include CRLF)
         */

        /* We know q has a non white space character so this is OK */
        for (r = q + strlen(q) - 1; isspace((unsigned char)*r); r--)
            *r = 0;
    }
    if (retcode != 200) {
        OCSPerr(OCSP_F_PARSE_HTTP_LINE1, OCSP_R_SERVER_RESPONSE_ERROR);
        if (!*q)
            ERR_add_error_data(2, "Code=", p);
        else
            ERR_add_error_data(4, "Code=", p, ",Reason=", q);
        return 0;
    }

    return 1;

}

variable_types:
line
char *

variable_types: retcode int

variable_types:
p
char *

variable_types:
q
char *

variable_types:
r
char *


original_code:
int EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int dlen)
{
    int i, ret = 0;
    unsigned long l;

    for (i = dlen; i > 0; i -= 3) {
        if (i >= 3) {
            l = (((unsigned long)f[0]) << 16L) |
                (((unsigned long)f[1]) << 8L) | f[2];
            *(t++) = conv_bin2ascii(l >> 18L);
            *(t++) = conv_bin2ascii(l >> 12L);
            *(t++) = conv_bin2ascii(l >> 6L);
            *(t++) = conv_bin2ascii(l);
        } else {
            l = ((unsigned long)f[0]) << 16L;
            if (i == 2)
                l |= ((unsigned long)f[1] << 8L);

            *(t++) = conv_bin2ascii(l >> 18L);
            *(t++) = conv_bin2ascii(l >> 12L);
            *(t++) = (i == 1) ? '=' : conv_bin2ascii(l >> 6L);
            *(t++) = '=';
        }
        ret += 4;
        f += 3;
    }

    *t = '\0';
    return (ret);
}

canonical_original_code:
int EVP_EncodeBlock(unsigned char *t, unsigned char *f, int dlen)
{
    int i; int ret = 0;
    unsigned long l;

    for (i = dlen; i > 0; i -= 3) {
        if (i >= 3) {
            l = (((unsigned long)f[0]) << 16L) |
                (((unsigned long)f[1]) << 8L) | f[2];
            *(t++) = conv_bin2ascii(l >> 18L);
            *(t++) = conv_bin2ascii(l >> 12L);
            *(t++) = conv_bin2ascii(l >> 6L);
            *(t++) = conv_bin2ascii(l);
        } else {
            l = ((unsigned long)f[0]) << 16L;
            if (i == 2)
                l |= ((unsigned long)f[1] << 8L);

            *(t++) = conv_bin2ascii(l >> 18L);
            *(t++) = conv_bin2ascii(l >> 12L);
            *(t++) = (i == 1) ? '=' : conv_bin2ascii(l >> 6L);
            *(t++) = '=';
        }
        ret += 4;
        f += 3;
    }

    *t = '\0';
    return (ret);
}

variable_types:
t
unsigned char *

variable_types:
f
unsigned char *

variable_types: dlen int

variable_types: i int

variable_types: ret int

variable_types:
l
unsigned long


decompiled_code:
__int64 __fastcall EVP_DecodeBlock(_BYTE *a1, _BYTE *a2, int a3)
{
_BYTE *i; // rcx
unsigned int v5; // er9
_BYTE *v7; // r10
char v8; // dl
unsigned __int8 v9; // cl
unsigned __int8 v10; // di
char v11; // r11

for ( ; data_ascii2bin[*a2 & 0x7F] == -32 && a3 > 0; --a3 )
++a2;
if ( a3 > 3 )
{
for ( i = &a2[a3 - 1]; ((unsigned __int8)data_ascii2bin[*i & 0x7F] | 0x13) == 0xF3; --i )
{
if ( --a3 == 3 )
return (unsigned int)-1;
}
}
if ( (a3 & 3) != 0 )
return (unsigned int)-1;
if ( a3 <= 0 )
return 0;
v7 = &a2[4 * ((unsigned int)(a3 - 1) >> 2) + 4];
v5 = 0;
while ( 1 )
{
v8 = data_ascii2bin[*a2 & 0x7F];
v9 = data_ascii2bin[a2[1] & 0x7F];
v10 = data_ascii2bin[a2[2] & 0x7F];
a2 += 4;
v11 = data_ascii2bin[*(a2 - 1) & 0x7F];
if ( v8 < 0 )
return (unsigned int)-1;
if ( (v9 & 0x80u) != 0 )
return (unsigned int)-1;
if ( (v10 & 0x80u) != 0 )
return (unsigned int)-1;
if ( v11 < 0 )
break;
*a1 = (unsigned int)((v10 << 6) | (v9 << 12) | ((unsigned __int8)v8 << 18)) >> 16;
a1[1] = (unsigned __int16)((v10 << 6) | (v9 << 12)) >> 8;
a1 += 3;
*(a1 - 1) = (v10 << 6) | v11;
v5 += 3;
if ( v7 == a2 )
return v5;
}
return (unsigned int)-1;
}

canonical_decompiled_code:
__int64 __fastcall func5(_BYTE *a1, _BYTE *a2, int a3)
{
_BYTE *i; // rcx
unsigned int v5; // er9
_BYTE *v7; // r10
char v8; // dl
unsigned __int8 v9; // cl
unsigned __int8 v10; // di
char v11; // r11

for ( ; data_ascii2bin[*a2 & 0x7F] == -32 && a3 > 0; --a3 )
++a2;
if ( a3 > 3 )
{
for ( i = &a2[a3 - 1]; ((unsigned __int8)data_ascii2bin[*i & 0x7F] | 0x13) == 0xF3; --i )
{
if ( --a3 == 3 )
return (unsigned int)-1;
}
}
if ( (a3 & 3) != 0 )
return (unsigned int)-1;
if ( a3 <= 0 )
return 0;
v7 = &a2[4 * ((unsigned int)(a3 - 1) >> 2) + 4];
v5 = 0;
while ( 1 )
{
v8 = data_ascii2bin[*a2 & 0x7F];
v9 = data_ascii2bin[a2[1] & 0x7F];
v10 = data_ascii2bin[a2[2] & 0x7F];
a2 += 4;
v11 = data_ascii2bin[*(a2 - 1) & 0x7F];
if ( v8 < 0 )
return (unsigned int)-1;
if ( (v9 & 0x80u) != 0 )
return (unsigned int)-1;
if ( (v10 & 0x80u) != 0 )
return (unsigned int)-1;
if ( v11 < 0 )
break;
*a1 = (unsigned int)((v10 << 6) | (v9 << 12) | ((unsigned __int8)v8 << 18)) >> 16;
a1[1] = (unsigned __int16)((v10 << 6) | (v9 << 12)) >> 8;
a1 += 3;
*(a1 - 1) = (v10 << 6) | v11;
v5 += 3;
if ( v7 == a2 )
return v5;
}
return (unsigned int)-1;
}

original_code:
int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n)
{
    int i, ret = 0, a, b, c, d;
    unsigned long l;

    /* trim white space from the start of the line. */
    while ((conv_ascii2bin(*f) == B64_WS) && (n > 0)) {
        f++;
        n--;
    }

    /*
     * strip off stuff at the end of the line ascii2bin values B64_WS,
     * B64_EOLN, B64_EOLN and B64_EOF
     */
    while ((n > 3) && (B64_NOT_BASE64(conv_ascii2bin(f[n - 1]))))
        n--;

    if (n % 4 != 0)
        return (-1);

    for (i = 0; i < n; i += 4) {
        a = conv_ascii2bin(*(f++));
        b = conv_ascii2bin(*(f++));
        c = conv_ascii2bin(*(f++));
        d = conv_ascii2bin(*(f++));
        if ((a & 0x80) || (b & 0x80) || (c & 0x80) || (d & 0x80))
            return (-1);
        l = ((((unsigned long)a) << 18L) |
             (((unsigned long)b) << 12L) |
             (((unsigned long)c) << 6L) | (((unsigned long)d)));
        *(t++) = (unsigned char)(l >> 16L) & 0xff;
        *(t++) = (unsigned char)(l >> 8L) & 0xff;
        *(t++) = (unsigned char)(l) & 0xff;
        ret += 3;
    }
    return (ret);
}

canonical_original_code:
int EVP_DecodeBlock(unsigned char *t, unsigned char *f, int n)
{
    int i; int ret = 0; int a; int b; int c; int d;
    unsigned long l;

    /* trim white space from the start of the line. */
    while ((conv_ascii2bin(*f) == B64_WS) && (n > 0)) {
        f++;
        n--;
    }

    /*
     * strip off stuff at the end of the line ascii2bin values B64_WS,
     * B64_EOLN, B64_EOLN and B64_EOF
     */
    while ((n > 3) && (B64_NOT_BASE64(conv_ascii2bin(f[n - 1]))))
        n--;

    if (n % 4 != 0)
        return (-1);

    for (i = 0; i < n; i += 4) {
        a = conv_ascii2bin(*(f++));
        b = conv_ascii2bin(*(f++));
        c = conv_ascii2bin(*(f++));
        d = conv_ascii2bin(*(f++));
        if ((a & 0x80) || (b & 0x80) || (c & 0x80) || (d & 0x80))
            return (-1);
        l = ((((unsigned long)a) << 18L) |
             (((unsigned long)b) << 12L) |
             (((unsigned long)c) << 6L) | (((unsigned long)d)));
        *(t++) = (unsigned char)(l >> 16L) & 0xff;
        *(t++) = (unsigned char)(l >> 8L) & 0xff;
        *(t++) = (unsigned char)(l) & 0xff;
        ret += 3;
    }
    return (ret);
}

variable_types: n int

variable_types: a int

variable_types: b int

variable_types: d int


decompiled_code:
__int64 ERR_load_BN_strings()
{
__int64 result; // rax

result = ERR_func_error_string(BN_str_functs);
if ( !result )
{
ERR_load_strings(0LL, &BN_str_functs);
result = ERR_load_strings(0LL, &BN_str_reasons);
}
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 result; // rax

result = ERR_func_error_string(BN_str_functs);
if ( !result )
{
ERR_load_strings(0LL, &BN_str_functs);
result = ERR_load_strings(0LL, &BN_str_reasons);
}
return result;
}

original_code:
void ERR_load_BN_strings(void)
{
#ifndef OPENSSL_NO_ERR

    if (ERR_func_error_string(BN_str_functs[0].error) == NULL) {
        ERR_load_strings(0, BN_str_functs);
        ERR_load_strings(0, BN_str_reasons);
    }
#endif
}

canonical_original_code:
void ERR_load_BN_strings()
{
#ifndef OPENSSL_NO_ERR

    if (ERR_func_error_string(BN_str_functs[0].error) == NULL) {
        ERR_load_strings(0, BN_str_functs);
        ERR_load_strings(0, BN_str_reasons);
    }
#endif
}


decompiled_code:
__int64 ERR_load_TS_strings()
{
__int64 result; // rax

result = ERR_func_error_string(TS_str_functs);
if ( !result )
{
ERR_load_strings(0LL, &TS_str_functs);
result = ERR_load_strings(0LL, &TS_str_reasons);
}
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 result; // rax

result = ERR_func_error_string(TS_str_functs);
if ( !result )
{
ERR_load_strings(0LL, &TS_str_functs);
result = ERR_load_strings(0LL, &TS_str_reasons);
}
return result;
}

original_code:
void ERR_load_TS_strings(void)
{
#ifndef OPENSSL_NO_ERR

    if (ERR_func_error_string(TS_str_functs[0].error) == NULL) {
        ERR_load_strings(0, TS_str_functs);
        ERR_load_strings(0, TS_str_reasons);
    }
#endif
}

canonical_original_code:
void ERR_load_TS_strings()
{
#ifndef OPENSSL_NO_ERR

    if (ERR_func_error_string(TS_str_functs[0].error) == NULL) {
        ERR_load_strings(0, TS_str_functs);
        ERR_load_strings(0, TS_str_reasons);
    }
#endif
}


decompiled_code:
__int64 engine_unregister_all_ciphers()
{
return engine_table_cleanup(&cipher_table);
}

canonical_decompiled_code:
__int64 func0()
{
return engine_table_cleanup(&cipher_table);
}

original_code:
static void engine_unregister_all_ciphers(void)
{
    engine_table_cleanup(&cipher_table);
}

canonical_original_code:
static void engine_unregister_all_ciphers()
{
    engine_table_cleanup(&cipher_table);
}


decompiled_code:
__int64 ERR_load_UI_strings()
{
__int64 result; // rax

result = ERR_func_error_string(UI_str_functs);
if ( !result )
{
ERR_load_strings(0LL, &UI_str_functs);
result = ERR_load_strings(0LL, &UI_str_reasons);
}
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 result; // rax

result = ERR_func_error_string(UI_str_functs);
if ( !result )
{
ERR_load_strings(0LL, &UI_str_functs);
result = ERR_load_strings(0LL, &UI_str_reasons);
}
return result;
}

original_code:
void ERR_load_UI_strings(void)
{
#ifndef OPENSSL_NO_ERR

    if (ERR_func_error_string(UI_str_functs[0].error) == NULL) {
        ERR_load_strings(0, UI_str_functs);
        ERR_load_strings(0, UI_str_reasons);
    }
#endif
}

canonical_original_code:
void ERR_load_UI_strings()
{
#ifndef OPENSSL_NO_ERR

    if (ERR_func_error_string(UI_str_functs[0].error) == NULL) {
        ERR_load_strings(0, UI_str_functs);
        ERR_load_strings(0, UI_str_reasons);
    }
#endif
}


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

if ( (a1 & 0xFFFFFFF7) == 258 )
{
a1 &= 0xFFFFFEFF;
return tag2str_0[a1];
}
result = "(unknown)";
if ( a1 <= 0x1E )
return tag2str_0[a1];
return result;
}

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

if ( (a1 & 0xFFFFFFF7) == 258 )
{
a1 &= 0xFFFFFEFF;
return tag2str_0[a1];
}
result = "(unknown)";
if ( a1 <= 0x1E )
return tag2str_0[a1];
return result;
}

original_code:
const char *ASN1_tag2str(int tag)
{
    static const char *const tag2str[] = {
        /* 0-4 */
        "EOC", "BOOLEAN", "INTEGER", "BIT STRING", "OCTET STRING",
        /* 5-9 */
        "NULL", "OBJECT", "OBJECT DESCRIPTOR", "EXTERNAL", "REAL",
        /* 10-13 */
        "ENUMERATED", "<ASN1 11>", "UTF8STRING", "<ASN1 13>",
        /* 15-17 */
        "<ASN1 14>", "<ASN1 15>", "SEQUENCE", "SET",
        /* 18-20 */
        "NUMERICSTRING", "PRINTABLESTRING", "T61STRING",
        /* 21-24 */
        "VIDEOTEXSTRING", "IA5STRING", "UTCTIME", "GENERALIZEDTIME",
        /* 25-27 */
        "GRAPHICSTRING", "VISIBLESTRING", "GENERALSTRING",
        /* 28-30 */
        "UNIVERSALSTRING", "<ASN1 29>", "BMPSTRING"
    };

    if ((tag == V_ASN1_NEG_INTEGER) || (tag == V_ASN1_NEG_ENUMERATED))
        tag &= ~0x100;

    if (tag < 0 || tag > 30)
        return "(unknown)";
    return tag2str[tag];
}

canonical_original_code:
char *ASN1_tag2str(int tag)
{
    static char *tag2str[] = {
        /* 0-4 */
        "EOC", "BOOLEAN", "INTEGER", "BIT STRING", "OCTET STRING",
        /* 5-9 */
        "NULL", "OBJECT", "OBJECT DESCRIPTOR", "EXTERNAL", "REAL",
        /* 10-13 */
        "ENUMERATED", "<ASN1 11>", "UTF8STRING", "<ASN1 13>",
        /* 15-17 */
        "<ASN1 14>", "<ASN1 15>", "SEQUENCE", "SET",
        /* 18-20 */
        "NUMERICSTRING", "PRINTABLESTRING", "T61STRING",
        /* 21-24 */
        "VIDEOTEXSTRING", "IA5STRING", "UTCTIME", "GENERALIZEDTIME",
        /* 25-27 */
        "GRAPHICSTRING", "VISIBLESTRING", "GENERALSTRING",
        /* 28-30 */
        "UNIVERSALSTRING", "<ASN1 29>", "BMPSTRING"
    };

    if ((tag == V_ASN1_NEG_INTEGER) || (tag == V_ASN1_NEG_ENUMERATED))
        tag &= ~0x100;

    if (tag < 0 || tag > 30)
        return "(unknown)";
    return tag2str[tag];
}

variable_types: tag int

return_type: char *


decompiled_code:
__int64 ERR_load_PEM_strings()
{
__int64 result; // rax

result = ERR_func_error_string(PEM_str_functs);
if ( !result )
{
ERR_load_strings(0LL, &PEM_str_functs);
result = ERR_load_strings(0LL, &PEM_str_reasons);
}
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 result; // rax

result = ERR_func_error_string(PEM_str_functs);
if ( !result )
{
ERR_load_strings(0LL, &PEM_str_functs);
result = ERR_load_strings(0LL, &PEM_str_reasons);
}
return result;
}

original_code:
void ERR_load_PEM_strings(void)
{
#ifndef OPENSSL_NO_ERR

    if (ERR_func_error_string(PEM_str_functs[0].error) == NULL) {
        ERR_load_strings(0, PEM_str_functs);
        ERR_load_strings(0, PEM_str_reasons);
    }
#endif
}

canonical_original_code:
void ERR_load_PEM_strings()
{
#ifndef OPENSSL_NO_ERR

    if (ERR_func_error_string(PEM_str_functs[0].error) == NULL) {
        ERR_load_strings(0, PEM_str_functs);
        ERR_load_strings(0, PEM_str_reasons);
    }
#endif
}


decompiled_code:
__int64 ERR_load_PKCS12_strings()
{
__int64 result; // rax

result = ERR_func_error_string(PKCS12_str_functs);
if ( !result )
{
ERR_load_strings(0LL, &PKCS12_str_functs);
result = ERR_load_strings(0LL, &PKCS12_str_reasons);
}
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 result; // rax

result = ERR_func_error_string(PKCS12_str_functs);
if ( !result )
{
ERR_load_strings(0LL, &PKCS12_str_functs);
result = ERR_load_strings(0LL, &PKCS12_str_reasons);
}
return result;
}

original_code:
void ERR_load_PKCS12_strings(void)
{
#ifndef OPENSSL_NO_ERR

    if (ERR_func_error_string(PKCS12_str_functs[0].error) == NULL) {
        ERR_load_strings(0, PKCS12_str_functs);
        ERR_load_strings(0, PKCS12_str_reasons);
    }
#endif
}

canonical_original_code:
void ERR_load_PKCS12_strings()
{
#ifndef OPENSSL_NO_ERR

    if (ERR_func_error_string(PKCS12_str_functs[0].error) == NULL) {
        ERR_load_strings(0, PKCS12_str_functs);
        ERR_load_strings(0, PKCS12_str_reasons);
    }
#endif
}


decompiled_code:
__int64 __fastcall constant_time_msb(int a1)
{
return (unsigned int)(a1 >> 31);
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
return (unsigned int)(a1 >> 31);
}

original_code:
static inline unsigned int constant_time_msb(unsigned int a)
{
    return 0 - (a >> (sizeof(a) * 8 - 1));
}

variable_types:
a
unsigned int


decompiled_code:
__int64 __fastcall constant_time_is_zero(int a1)
{
return constant_time_msb(~a1 & (unsigned int)(a1 - 1));
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
return func0(~a1 & (unsigned int)(a1 - 1));
}

original_code:
static inline unsigned int constant_time_is_zero(unsigned int a)
{
    return constant_time_msb(~a & (a - 1));
}


decompiled_code:
__int64 __fastcall constant_time_select(int a1, int a2, unsigned int a3)
{
return a1 & (a3 ^ a2) ^ a3;
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, int a2, unsigned int a3)
{
return a1 & (a3 ^ a2) ^ a3;
}

original_code:
static inline unsigned int constant_time_select(unsigned int mask,
                                                unsigned int a,
                                                unsigned int b)
{
    return (mask & a) | (~mask & b);
}

variable_types:
mask
unsigned int

variable_types:
b
unsigned int


decompiled_code:
// attributes: thunk
__int64 __fastcall constant_time_select_int(int a1, int a2, unsigned int a3)
{
return constant_time_select(a1, a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1, int a2, unsigned int a3)
{
return func3(a1, a2, a3);
}

original_code:
static inline int constant_time_select_int(unsigned int mask, int a, int b)
{
    return (int)(constant_time_select(mask, (unsigned)(a), (unsigned)(b)));
}

canonical_original_code:
static inline int constant_time_select_int(unsigned int mask, int a, int b)
{
    return (int)(constant_time_select(mask, (unsigned int)(a), (unsigned int)(b)));
}


original_code:
static int dh_cb(int p, int n, BN_GENCB *cb)
{
    char c = '*';
    if (p == 0)
        c = '.';
    if (p == 1)
        c = '+';
    if (p == 2)
        c = '*';
    if (p == 3)
        c = '\n';
    BIO_write(cb->arg, &c, 1);
    (void)(int)BIO_ctrl(cb->arg,11,0,((void *)0));
    return 1;
}

canonical_original_code:
static int dh_cb(int p, int n, struct bn_gencb_st *cb)
{
    char c = '*';
    if (p == 0)
        c = '.';
    if (p == 1)
        c = '+';
    if (p == 2)
        c = '*';
    if (p == 3)
        c = '\n';
    BIO_write(cb->arg, &c, 1);
    (void)(int)BIO_ctrl(cb->arg,11,0,((void *)0));
    return 1;
}

variable_types: p int

variable_types: struct bn_gencb_st { unsigned int ver; void *arg; union { void (*cb_1)(int, int, void *); int (*cb_2)(int, int, struct bn_gencb_st *); } cb; } *

variable_types: c char


decompiled_code:
int __fastcall get_current_time(struct timeval *a1)
{
return gettimeofday(a1, 0LL);
}

canonical_decompiled_code:
int __fastcall func7(struct timeval *a1)
{
return gettimeofday(a1, 0LL);
}

original_code:
static void get_current_time(struct timeval *t)
{
    gettimeofday(t, ((void *)0));
}

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


user_defined_types: struct bn_gencb_st { unsigned int ver; void *arg; union { void (*cb_1)(int, int, void *); int (*cb_2)(int, int, struct bn_gencb_st *); } cb; }


decompiled_code:
__int64 __fastcall dh_cb(unsigned int a1, __int64 *a2)
{
__int64 result; // rax
__int64 v3; // rax
bool v4; // zf

if ( a1 )
{
result = 1LL;
if ( a1 == 2 )
{
DH_free(*a2);
*a2 = 0LL;
result = 2LL;
}
}
else
{
v3 = DH_new();
*a2 = v3;
v4 = v3 == 0;
result = 2LL;
if ( v4 )
result = a1;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1, __int64 *a2)
{
__int64 result; // rax
__int64 v3; // rax
bool v4; // zf

if ( a1 )
{
result = 1LL;
if ( a1 == 2 )
{
DH_free(*a2);
*a2 = 0LL;
result = 2LL;
}
}
else
{
v3 = DH_new();
*a2 = v3;
v4 = v3 == 0;
result = 2LL;
if ( v4 )
result = a1;
}
return result;
}


tone

decompiled_code:
__int64 __fastcall tone(int fd, int a2, const void *a3)
{
while ( a2 )
{
--a2;
if ( write(fd, a3, 0xAuLL) != 10 )
return 0xFFFFFFFFLL;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(int fd, int a2, const void *a3)
{
while ( a2 )
{
--a2;
if ( write(fd, a3, 0xAuLL) != 10 )
return 0xFFFFFFFFLL;
}
return 0LL;
}

original_code:
int tone(int fd, int cycles, const signed char *pattern)
{
 while (cycles--)
 {
  if (write(fd,pattern,10)!=10)
   return -1;
 }
 return 0;
}

canonical_original_code:
int tone(int fd, int cycles, char *pattern)
{
 while (cycles--)
 {
  if (write(fd,pattern,10)!=10)
   return -1;
 }
 return 0;
}

variable_types: fd int

variable_types: cycles int

variable_types:
pattern
char *


modulate

decompiled_code:
__int64 __fastcall modulate(int a1, int a2)
{
unsigned __int64 v2; // rax
unsigned int v3; // edx
int v5; // edx
char *v6; // rcx
char *v7; // rbx
int v8; // ebp
char v9[256]; // [rsp+0h] [rbp-118h] BYREF
char v10; // [rsp+100h] [rbp-18h] BYREF

v2 = read(a1, v9, 0x100uLL);
v3 = 0;
if ( v2 )
{
if ( v2 <= 0xFF )
{
v5 = 256 - v2;
v6 = &v9[v2];
if ( (unsigned int)(256 - v2) >= 8 )
{
*(_QWORD *)v6 = 0LL;
*(_QWORD *)&v6[v5 - 8] = 0LL;
memset(
(void *)((unsigned __int64)(v6 + 8) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * ((v5 + (unsigned int)v6 - (((_DWORD)v6 + 8) & 0xFFFFFFF8)) >> 3));
}
else if ( (-(char)v2 & 4) != 0 )
{
*(_DWORD *)v6 = 0;
*(_DWORD *)&v6[v5 - 4] = 0;
}
else if ( v5 )
{
*v6 = 0;
if ( (-(char)v2 & 2) != 0 )
*(_WORD *)&v6[v5 - 2] = 0;
}
}
if ( (unsigned int)tone(a2, 2000, &cycle_tone) || (v7 = v9, (unsigned int)tone(a2, 8, &cycle_silence)) )
{
LABEL_4:
perror("Unable to write output");
v3 = -1;
}
else
{
do
{
v8 = 9;
do
{
if ( (*v7 & 1) != 0 )
{
if ( (unsigned int)tone(a2, 16, &cycle_tone) || (unsigned int)tone(a2, 8, &cycle_silence) )
goto LABEL_4;
}
else if ( (unsigned int)tone(a2, 8, &cycle_tone) || (unsigned int)tone(a2, 16, &cycle_silence) )
{
goto LABEL_4;
}
*v7 = (unsigned __int8)*v7 >> 1;
--v8;
}
while ( v8 );
++v7;
}
while ( v7 != &v10 );
v3 = 1;
}
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func8(int a1, int a2)
{
unsigned __int64 v2; // rax
unsigned int v3; // edx
int v5; // edx
char *v6; // rcx
char *v7; // rbx
int v8; // ebp
char v9[256]; // [rsp+0h] [rbp-118h] BYREF
char v10; // [rsp+100h] [rbp-18h] BYREF

v2 = read(a1, v9, 0x100uLL);
v3 = 0;
if ( v2 )
{
if ( v2 <= 0xFF )
{
v5 = 256 - v2;
v6 = &v9[v2];
if ( (unsigned int)(256 - v2) >= 8 )
{
*(_QWORD *)v6 = 0LL;
*(_QWORD *)&v6[v5 - 8] = 0LL;
memset(
(void *)((unsigned __int64)(v6 + 8) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * ((v5 + (unsigned int)v6 - (((_DWORD)v6 + 8) & 0xFFFFFFF8)) >> 3));
}
else if ( (-(char)v2 & 4) != 0 )
{
*(_DWORD *)v6 = 0;
*(_DWORD *)&v6[v5 - 4] = 0;
}
else if ( v5 )
{
*v6 = 0;
if ( (-(char)v2 & 2) != 0 )
*(_WORD *)&v6[v5 - 2] = 0;
}
}
if ( (unsigned int)func7(a2, 2000, &cycle_tone) || (v7 = v9, (unsigned int)func7(a2, 8, &cycle_silence)) )
{
LABEL_4:
perror("Unable to write output");
v3 = -1;
}
else
{
do
{
v8 = 9;
do
{
if ( (*v7 & 1) != 0 )
{
if ( (unsigned int)func7(a2, 16, &cycle_tone) || (unsigned int)func7(a2, 8, &cycle_silence) )
goto LABEL_4;
}
else if ( (unsigned int)func7(a2, 8, &cycle_tone) || (unsigned int)func7(a2, 16, &cycle_silence) )
{
goto LABEL_4;
}
*v7 = (unsigned __int8)*v7 >> 1;
--v8;
}
while ( v8 );
++v7;
}
while ( v7 != &v10 );
v3 = 1;
}
}
return v3;
}

original_code:
int modulate(int fdin, int fdout)
{
 unsigned char buf[256];
 unsigned char *ptr=buf;
 int bitcount;
 ssize_t count;
 count=read(fdin,buf,sizeof(buf));
 if (count==0)
  return 0;
 if (count<sizeof(buf))
  memset(buf+count,0x00,sizeof(buf)-count);
 if (tone(fdout,((8)*250),cycle_tone))
  goto error;
 if (tone(fdout,8,cycle_silence))
  goto error;
 for (count=0;count<256;count++)
 {
  for (bitcount=0;bitcount<9;bitcount++)
  {
   if (*ptr&0x01)
   {
    if (tone(fdout,8*2,cycle_tone))
     goto error;
    if (tone(fdout,8,cycle_silence))
     goto error;
   }
   else
   {
    if (tone(fdout,8,cycle_tone))
     goto error;
    if (tone(fdout,8*2,cycle_silence))
     goto error;
   }
   *ptr>>=1;
  }
  ptr++;
 }
 return 1;
error:
 perror("Unable to write output");
 return -1;
}

canonical_original_code:
int modulate(int fdin, int fdout)
{
 unsigned char buf[256];
 unsigned char *ptr = buf;
 int bitcount;
 long count;
 count=read(fdin,buf,sizeof(buf));
 if (count==0)
  return 0;
 if (count<sizeof(buf))
  memset(buf+count,0x00,sizeof(buf)-count);
 if (tone(fdout,((8)*250),cycle_tone))
  goto error;
 if (tone(fdout,8,cycle_silence))
  goto error;
 for (count=0;count<256;count++)
 {
  for (bitcount=0;bitcount<9;bitcount++)
  {
   if (*ptr&0x01)
   {
    if (tone(fdout,8*2,cycle_tone))
     goto error;
    if (tone(fdout,8,cycle_silence))
     goto error;
   }
   else
   {
    if (tone(fdout,8,cycle_tone))
     goto error;
    if (tone(fdout,8*2,cycle_silence))
     goto error;
   }
   *ptr>>=1;
  }
  ptr++;
 }
 return 1;
error:
 perror("Unable to write output");
 return -1;
}

variable_types: fdin int

variable_types: fdout int

variable_types:
buf
unsigned char [256]

variable_types:
ptr
unsigned char *

variable_types: bitcount int

variable_types: count long


usage

decompiled_code:
int usage()
{
return puts(
"tam8085tape <input> <output>\n"
"\n"
"Converts input file to TAM8085-tape format\n"
"Input is a raw byte stream.\n"
"Output is signed 8 bit samples with 32000 sps.\n"
"Output consists of 256 byte pages. Input is padded to full page with zeros.\n");
}

canonical_decompiled_code:
int func9()
{
return puts(
"tam8085tape <input> <output>\n"
"\n"
"Converts input file to TAM8085-tape format\n"
"Input is a raw byte stream.\n"
"Output is signed 8 bit samples with 32000 sps.\n"
"Output consists of 256 byte pages. Input is padded to full page with zeros.\n");
}

original_code:
void usage(void)
{
 puts(
"tam8085tape <input> <output>\n\n"
"Converts input file to TAM8085-tape format\n"
"Input is a raw byte stream.\n"
"Output is signed 8 bit samples with 32000 sps.\n"
"Output consists of 256 byte pages. Input is padded to full page with zeros.\n"
 );
}

canonical_original_code:
void usage()
{
 puts(
"tam8085tape <input> <output>\n\n"
"Converts input file to TAM8085-tape format\n"
"Input is a raw byte stream.\n"
"Output is signed 8 bit samples with 32000 sps.\n"
"Output consists of 256 byte pages. Input is padded to full page with zeros.\n"
 );
}


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // rdx
bool v4; // zf
int v5; // ebp
int v6; // er12
int v7; // ebx

if ( argc <= 2 )
{
usage();
v7 = 0;
}
else
{
v3 = argv[1];
v4 = strcmp(v3, "-") == 0;
v5 = !v4;
if ( v4 || (v5 = open(v3, 0), v5 >= 0) )
{
v6 = 1;
if ( !strcmp(argv[2], "-") || (v6 = open(argv[2], 193, 511LL), v6 >= 0) )
{
do
v7 = modulate(v5, v6);
while ( v7 );
close(v6);
close(v5);
}
else
{
perror("Error opening output file");
v7 = -1;
}
}
else
{
perror("Error opening input file");
v7 = -1;
}
}
return v7;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // rdx
bool v4; // zf
int v5; // ebp
int v6; // er12
int v7; // ebx

if ( argc <= 2 )
{
func9();
v7 = 0;
}
else
{
v3 = argv[1];
v4 = strcmp(v3, "-") == 0;
v5 = !v4;
if ( v4 || (v5 = open(v3, 0), v5 >= 0) )
{
v6 = 1;
if ( !strcmp(argv[2], "-") || (v6 = open(argv[2], 193, 511LL), v6 >= 0) )
{
do
v7 = func8(v5, v6);
while ( v7 );
close(v6);
close(v5);
}
else
{
perror("Error opening output file");
v7 = -1;
}
}
else
{
perror("Error opening input file");
v7 = -1;
}
}
return v7;
}

original_code:
int main(int argc, char **argv)
{
 int infd=-1, outfd=-1;
 int retval;
 if (argc<3)
 {
  usage();
  return 0;
 }
 if (strcmp(argv[1],"-")==0)
 {
  infd=0;
 }
 else
 {
  infd=open(argv[1],00);
 }
 if (infd<0)
 {
  perror("Error opening input file");
  return -1;
 }
 if (strcmp(argv[2],"-")==0)
 {
  outfd=1;
 }
 else
 {
  outfd=open(argv[2],01|0100|0200,0777);
 }
 if (outfd<0)
 {
  perror("Error opening output file");
  return -1;
 }
 while ((retval=modulate(infd,outfd)))
  ;
 close(outfd);
 close(infd);
 return retval;
}

canonical_original_code:
int main(int argc, char **argv)
{
 int infd = -1; int outfd = -1;
 int retval;
 if (argc<3)
 {
  usage();
  return 0;
 }
 if (strcmp(argv[1],"-")==0)
 {
  infd=0;
 }
 else
 {
  infd=open(argv[1],00);
 }
 if (infd<0)
 {
  perror("Error opening input file");
  return -1;
 }
 if (strcmp(argv[2],"-")==0)
 {
  outfd=1;
 }
 else
 {
  outfd=open(argv[2],01|0100|0200,0777);
 }
 if (outfd<0)
 {
  perror("Error opening output file");
  return -1;
 }
 while ((retval=modulate(infd,outfd)))
  ;
 close(outfd);
 close(infd);
 return retval;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: infd int

variable_types: outfd int

variable_types: retval int


uiSetup

decompiled_code:
void uiSetup()
{
isKeyPad = 0;
shipLocation = 0x80;
isAutoFire = 0;
}

canonical_decompiled_code:
void func0()
{
isKeyPad = 0;
shipLocation = 0x80;
isAutoFire = 0;
}

original_code:
void uiSetup(void) {
  isKeyPad = 0;
  shipLocation = 128;
  isAutoFire = 0;
}

canonical_original_code:
void uiSetup() {
  isKeyPad = 0;
  shipLocation = 128;
  isAutoFire = 0;
}


uiStep

decompiled_code:
__int64 uiStep()
{
__int64 result; // rax

result = u8g_sdl_get_key();
isFire = 0;
if ( (_DWORD)result == 115 )
goto LABEL_13;
if ( (int)result <= 115 )
{
if ( (_DWORD)result == 32 )
{
isFire = 1;
}
else if ( (_DWORD)result == 113 )
{
exit(0);
}
return result;
}
if ( (_DWORD)result == 273 )
{
LABEL_13:
result = (unsigned __int8)~uiIncrement;
if ( (unsigned __int8)shipLocation <= (int)result )
shipLocation += uiIncrement;
}
else if ( (_DWORD)result == 274 || (_DWORD)result == 120 )
{
result = (unsigned __int8)shipLocation;
if ( (unsigned __int8)shipLocation >= (unsigned __int8)uiIncrement )
{
result = (unsigned __int8)shipLocation - (unsigned int)(unsigned __int8)uiIncrement;
shipLocation -= uiIncrement;
}
}
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 result; // rax

result = u8g_sdl_get_key();
isFire = 0;
if ( (_DWORD)result == 115 )
goto LABEL_13;
if ( (int)result <= 115 )
{
if ( (_DWORD)result == 32 )
{
isFire = 1;
}
else if ( (_DWORD)result == 113 )
{
exit(0);
}
return result;
}
if ( (_DWORD)result == 273 )
{
LABEL_13:
result = (unsigned __int8)~uiIncrement;
if ( (unsigned __int8)shipLocation <= (int)result )
shipLocation += uiIncrement;
}
else if ( (_DWORD)result == 274 || (_DWORD)result == 120 )
{
result = (unsigned __int8)shipLocation;
if ( (unsigned __int8)shipLocation >= (unsigned __int8)uiIncrement )
{
result = (unsigned __int8)shipLocation - (unsigned int)(unsigned __int8)uiIncrement;
shipLocation -= uiIncrement;
}
}
return result;
}

original_code:
void uiStep(void) {
  int key = u8g_sdl_get_key();
  isFire = 0;
  switch( key )
  {
    case ' ':
      isFire = 1;
      break;
    case 274:
    case 'x':
      if ( shipLocation >= 0+ uiIncrement )
 shipLocation -= uiIncrement;
      break;
    case 273:
    case 's':
      if ( shipLocation <= 255 - uiIncrement )
 shipLocation += uiIncrement;
      break;
    case 'q':
      exit(0);
  }
}

canonical_original_code:
void uiStep() {
  int key = u8g_sdl_get_key();
  isFire = 0;
  switch( key )
  {
    case ' ':
      isFire = 1;
      break;
    case 274:
    case 'x':
      if ( shipLocation >= 0+ uiIncrement )
 shipLocation -= uiIncrement;
      break;
    case 273:
    case 's':
      if ( shipLocation <= 255 - uiIncrement )
 shipLocation += uiIncrement;
      break;
    case 'q':
      exit(0);
  }
}

variable_types: key int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v4; // ebx

if ( (unsigned __int8)u8g_Init(&u8g, &u8g_dev_sdl_1bit, envp) )
{
st_Setup(&u8g);
uiSetup();
v4 = 4000;
do
{
u8g_FirstPage(&u8g);
do
st_Draw(0LL);
while ( (unsigned __int8)u8g_NextPage(&u8g) );
SDL_Delay(10LL);
uiStep();
st_Step((unsigned __int8)shipLocation, (unsigned __int8)isAutoFire, (unsigned __int8)isFire);
--v4;
}
while ( v4 );
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v4; // ebx

if ( (unsigned __int8)u8g_Init(&u8g, &u8g_dev_sdl_1bit, envp) )
{
st_Setup(&u8g);
func0();
v4 = 4000;
do
{
u8g_FirstPage(&u8g);
do
st_Draw(0LL);
while ( (unsigned __int8)u8g_NextPage(&u8g) );
SDL_Delay(10LL);
func1();
st_Step((unsigned __int8)shipLocation, (unsigned __int8)isAutoFire, (unsigned __int8)isFire);
--v4;
}
while ( v4 );
}
return 0;
}

original_code:
int main(void)
{
  uint32_t x;
  if ( u8g_Init(&u8g, &u8g_dev_sdl_1bit) == 0 )
    return 0;
  st_Setup(&u8g);
  uiSetup();
  for(x = 0; x < 4000; x++)
  {
    u8g_FirstPage(&u8g);
    do
    {
      st_Draw(0);
    } while( u8g_NextPage(&u8g) );
    SDL_Delay(10);
    uiStep();
    st_Step(shipLocation, isAutoFire, isFire);
  }
  return 0;
}

canonical_original_code:
int main()
{
  unsigned int x;
  if ( u8g_Init(&u8g, &u8g_dev_sdl_1bit) == 0 )
    return 0;
  st_Setup(&u8g);
  uiSetup();
  for(x = 0; x < 4000; x++)
  {
    u8g_FirstPage(&u8g);
    do
    {
      st_Draw(0);
    } while( u8g_NextPage(&u8g) );
    SDL_Delay(10);
    uiStep();
    st_Step(shipLocation, isAutoFire, isFire);
  }
  return 0;
}

variable_types:
x
unsigned int


decompiled_code:
__int64 __fastcall u8g_DrawWuPixel(__int64 a1, unsigned __int16 a2, unsigned __int16 a3, char a4)
{
u8g_SetColorIndex(a1, (unsigned __int8)(3 - a4));
return u8g_DrawPixel(a1, a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, unsigned __int16 a2, unsigned __int16 a3, char a4)
{
u8g_SetColorIndex(a1, (unsigned __int8)(3 - a4));
return u8g_DrawPixel(a1, a2, a3);
}

original_code:
void u8g_DrawWuPixel(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, uint8_t intensity)
{
  u8g_SetColorIndex(u8g, 4 -1-intensity);
  u8g_DrawPixel(u8g, x0, y0);
}

canonical_original_code:
void u8g_DrawWuPixel(struct _u8g_t *u8g, unsigned short x0, unsigned short y0, unsigned char intensity)
{
  u8g_SetColorIndex(u8g, 4 -1-intensity);
  u8g_DrawPixel(u8g, x0, y0);
}

variable_types: struct _u8g_t { unsigned short width; unsigned short height; struct _u8g_dev_t { unsigned char (*dev_fn)(struct _u8g_t *u8g, struct _u8g_dev_t *dev, unsigned char msg, void *arg); void *dev_mem; unsigned char (*com_fn)(struct _u8g_t *u8g, unsigned char msg, unsigned char arg_val, void *arg_ptr); } *dev; unsigned char *font; unsigned char *cursor_font; unsigned char cursor_fg_color; unsigned char cursor_encoding; unsigned char mode; unsigned short cursor_x; unsigned short cursor_y; void (*cursor_fn)(struct _u8g_t *u8g); char glyph_dx; char glyph_x; char glyph_y; unsigned char glyph_width; unsigned char glyph_height; unsigned short (*font_calc_vref)(struct _u8g_t *u8g); unsigned char font_height_mode; char font_ref_ascent; char font_ref_descent; unsigned char font_line_spacing_factor; unsigned char line_spacing; struct _u8g_dev_arg_pixel_t { unsigned short x; unsigned char pixel; unsigned char dir; unsigned char color; unsigned char hi_color; unsigned char blue; } arg_pixel; void (*state_cb)(unsigned char msg); struct _u8g_box_t { unsigned short x0; } current_page; } *

variable_types:
intensity
unsigned char

user_defined_types: struct _u8g_t { unsigned short width; unsigned short height; struct _u8g_dev_t *dev; unsigned char *font; unsigned char *cursor_font; unsigned char cursor_fg_color; unsigned char cursor_encoding; unsigned char mode; unsigned short cursor_x; unsigned short cursor_y; void (*cursor_fn)(struct _u8g_t *u8g); char glyph_dx; char glyph_x; char glyph_y; unsigned char glyph_width; unsigned char glyph_height; unsigned short (*font_calc_vref)(struct _u8g_t *u8g); unsigned char font_height_mode; char font_ref_ascent; char font_ref_descent; unsigned char font_line_spacing_factor; unsigned char line_spacing; struct _u8g_dev_arg_pixel_t arg_pixel; void (*state_cb)(unsigned char msg); struct _u8g_box_t current_page; }


decompiled_code:
__int64 __fastcall u8g_DrawWuLine2Bit(__int64 a1, unsigned __int16 a2, int a3, unsigned __int16 a4, int a5)
{
unsigned __int16 v5; // bx
int v6; // ebp
unsigned __int16 v7; // r14
unsigned __int16 v8; // ax
unsigned __int16 v9; // r13
unsigned __int16 v10; // r15
unsigned __int16 v11; // r13
unsigned __int16 v12; // dx
__int64 result; // rax
unsigned __int16 v14; // r13
unsigned __int16 v15; // ax
__int16 v16; // [rsp+Eh] [rbp-4Ah]
unsigned __int64 v17; // [rsp+10h] [rbp-48h]
unsigned __int64 v18; // [rsp+10h] [rbp-48h]
__int16 v19; // [rsp+1Ch] [rbp-3Ch]
unsigned __int16 v20; // [rsp+1Eh] [rbp-3Ah]

v5 = a2;
v6 = a3;
v7 = a5;
if ( (unsigned __int16)a3 > (unsigned __int16)a5 )
v6 = a5;
if ( (unsigned __int16)a3 > (unsigned __int16)a5 )
{
v7 = a3;
if ( (unsigned __int16)a3 > (unsigned __int16)a5 )
v5 = a4;
}
v8 = a2;
if ( (unsigned __int16)a3 <= (unsigned __int16)a5 )
v8 = a4;
v20 = v8;
v9 = v7 - v6;
if ( v5 > v8 )
{
v10 = v5 - v8;
v16 = -1;
}
else
{
v10 = v8 - v5;
if ( v8 == v5 )
{
u8g_SetColorIndex(a1, 3LL);
return u8g_DrawVLine(a1, v5, (unsigned __int16)v6, (unsigned __int16)(v7 - v6 + 1));
}
v16 = 1;
}
if ( v9 )
{
u8g_DrawWuPixel(a1, v5, v6, 0);
if ( v10 >= v9 )
{
v18 = ((unsigned __int64)v9 << 16) / v10;
v19 = v10 - 1;
if ( v10 != 1 )
{
v14 = 0;
do
{
v15 = v14;
v14 += v18;
LOWORD(v6) = v6 - ((v15 < v14) - 1);
v5 += v16;
u8g_DrawWuPixel(a1, v5, v6, v14 >> 14);
u8g_DrawWuPixel(a1, v5, v6 + 1, ((int)v14 >> 14) ^ 3);
--v19;
}
while ( v19 );
}
}
else
{
v17 = ((unsigned __int64)v10 << 16) / v9;
v11 = 0;
do
{
v12 = v11;
v11 += v17;
if ( v11 <= v12 )
v5 += v16;
u8g_DrawWuPixel(a1, v5, ++v6, v11 >> 14);
u8g_DrawWuPixel(a1, v5 + v16, v6, ((int)v11 >> 14) ^ 3);
}
while ( v7 + ~(_WORD)v6 );
}
result = u8g_DrawWuPixel(a1, v20, v7, 0);
}
else
{
u8g_SetColorIndex(a1, 3LL);
result = u8g_DrawHLine(a1, v5, (unsigned __int16)v6, (unsigned __int16)(v10 + 1));
}
return result;
}

original_code:
void u8g_DrawWuLine2Bit(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t x1, u8g_uint_t y1)
{
  uint16_t ErrorAdj, ErrorAcc, ErrorAccTemp;
  uint16_t IntensityShift;
  u8g_uint_t DeltaX, DeltaY;
  u8g_uint_t XDir;
  uint8_t Weighting, WeightingComplementMask;
  if ( y0 > y1 )
  {
    u8g_uint_t temp;
    temp = y0; y0 = y1; y1= temp;
    temp = x0; x0 = x1; x1= temp;
  }
  DeltaY = y1 - y0;
  if ( x1 >= x0 )
  {
    DeltaX = x1 - x0;
    XDir = 1;
  }
  else
  {
    DeltaX = x0 - x1;
    XDir = 0;
    XDir--;
  }
  if ( DeltaX == 0 )
  {
    u8g_SetColorIndex(u8g, 4 -1-0);
    u8g_DrawVLine(u8g, x0, y0, DeltaY+1 );
    return;
  }
  if ( DeltaY == 0 )
  {
    u8g_SetColorIndex(u8g, 4 -1-0);
    u8g_DrawHLine(u8g, x0, y0, DeltaX+1 );
    return;
  }
  u8g_DrawWuPixel(u8g, x0, y0, 0);
  ErrorAcc = 0;
  IntensityShift = 16 - 2;
  WeightingComplementMask = 4 - 1;
  if ( DeltaY > DeltaX )
  {
    ErrorAdj = ((unsigned long)DeltaX << 16) / (unsigned long)DeltaY;
    while( --DeltaY )
    {
      ErrorAccTemp = ErrorAcc;
      ErrorAcc += ErrorAdj;
      if ( ErrorAcc <= ErrorAccTemp )
      {
        x0 += XDir;
      }
      y0++;
      Weighting = ErrorAcc >> IntensityShift;
      u8g_DrawWuPixel(u8g, x0, y0, 0 +Weighting);
      Weighting ^= WeightingComplementMask;
      u8g_DrawWuPixel(u8g, x0+XDir, y0, 0 +Weighting);
    }
  }
  else
  {
    ErrorAdj = ((unsigned long)DeltaY << 16) / (unsigned long)DeltaX;
    while( --DeltaX )
    {
      ErrorAccTemp = ErrorAcc;
      ErrorAcc += ErrorAdj;
      if ( ErrorAcc <= ErrorAccTemp )
      {
        y0++;
      }
      x0 += XDir;
      Weighting = ErrorAcc >> IntensityShift;
      u8g_DrawWuPixel(u8g, x0, y0, 0 +Weighting);
      Weighting ^= WeightingComplementMask;
      u8g_DrawWuPixel(u8g, x0, y0+1, 0 +Weighting);
    }
  }
  u8g_DrawWuPixel(u8g, x1, y1, 0);
}

canonical_original_code:
void u8g_DrawWuLine2Bit(struct _u8g_t *u8g, unsigned short x0, unsigned short y0, unsigned short x1, unsigned short y1)
{
  unsigned short ErrorAdj; unsigned short ErrorAcc; unsigned short ErrorAccTemp;
  unsigned short IntensityShift;
  unsigned short DeltaX; unsigned short DeltaY;
  unsigned short XDir;
  unsigned char Weighting; unsigned char WeightingComplementMask;
  if ( y0 > y1 )
  {
    unsigned short temp;
    temp = y0; y0 = y1; y1= temp;
    temp = x0; x0 = x1; x1= temp;
  }
  DeltaY = y1 - y0;
  if ( x1 >= x0 )
  {
    DeltaX = x1 - x0;
    XDir = 1;
  }
  else
  {
    DeltaX = x0 - x1;
    XDir = 0;
    XDir--;
  }
  if ( DeltaX == 0 )
  {
    u8g_SetColorIndex(u8g, 4 -1-0);
    u8g_DrawVLine(u8g, x0, y0, DeltaY+1 );
    return;
  }
  if ( DeltaY == 0 )
  {
    u8g_SetColorIndex(u8g, 4 -1-0);
    u8g_DrawHLine(u8g, x0, y0, DeltaX+1 );
    return;
  }
  u8g_DrawWuPixel(u8g, x0, y0, 0);
  ErrorAcc = 0;
  IntensityShift = 16 - 2;
  WeightingComplementMask = 4 - 1;
  if ( DeltaY > DeltaX )
  {
    ErrorAdj = ((unsigned long)DeltaX << 16) / (unsigned long)DeltaY;
    while( --DeltaY )
    {
      ErrorAccTemp = ErrorAcc;
      ErrorAcc += ErrorAdj;
      if ( ErrorAcc <= ErrorAccTemp )
      {
        x0 += XDir;
      }
      y0++;
      Weighting = ErrorAcc >> IntensityShift;
      u8g_DrawWuPixel(u8g, x0, y0, 0 +Weighting);
      Weighting ^= WeightingComplementMask;
      u8g_DrawWuPixel(u8g, x0+XDir, y0, 0 +Weighting);
    }
  }
  else
  {
    ErrorAdj = ((unsigned long)DeltaY << 16) / (unsigned long)DeltaX;
    while( --DeltaX )
    {
      ErrorAccTemp = ErrorAcc;
      ErrorAcc += ErrorAdj;
      if ( ErrorAcc <= ErrorAccTemp )
      {
        y0++;
      }
      x0 += XDir;
      Weighting = ErrorAcc >> IntensityShift;
      u8g_DrawWuPixel(u8g, x0, y0, 0 +Weighting);
      Weighting ^= WeightingComplementMask;
      u8g_DrawWuPixel(u8g, x0, y0+1, 0 +Weighting);
    }
  }
  u8g_DrawWuPixel(u8g, x1, y1, 0);
}

variable_types:
ErrorAdj
unsigned short

variable_types:
ErrorAcc
unsigned short

variable_types:
ErrorAccTemp
unsigned short

variable_types:
IntensityShift
unsigned short

variable_types:
DeltaX
unsigned short

variable_types:
DeltaY
unsigned short

variable_types:
XDir
unsigned short

variable_types:
Weighting
unsigned char

variable_types:
WeightingComplementMask
unsigned char

variable_types:
temp
unsigned short

user_defined_types: struct _u8g_dev_arg_pixel_t { unsigned short x; unsigned char pixel; unsigned char dir; unsigned char color; unsigned char hi_color; unsigned char blue; }

user_defined_types: struct _u8g_box_t { unsigned short x0; }

user_defined_types: struct _u8g_dev_t { unsigned char (*dev_fn)(struct _u8g_t *u8g, struct _u8g_dev_t *dev, unsigned char msg, void *arg); void *dev_mem; unsigned char (*com_fn)(struct _u8g_t *u8g, unsigned char msg, unsigned char arg_val, void *arg_ptr); }


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

u8g_Init(v4, &u8g_dev_sdl_2bit, envp);
u8g_FirstPage(v4);
do
{
u8g_SetFont(v4, &u8g_font_10x20);
u8g_SetFont(v4, &u8g_font_fur25);
u8g_GetFontBBXWidth(v4);
u8g_GetFontBBXHeight(v4);
u8g_SetColorIndex(v4, 1LL);
u8g_DrawStr(v4, 30LL, 35LL, "gabc");
u8g_SetColorIndex(v4, 2LL);
u8g_DrawStr(v4, 31LL, 36LL, "gabc");
u8g_SetColorIndex(v4, 3LL);
u8g_DrawStr(v4, 32LL, 37LL, "gabc");
u8g_DrawWuLine2Bit((__int64)v4, 0, 63, 0x64u, 63);
u8g_DrawWuLine2Bit((__int64)v4, 0, 60, 0x64u, 58);
u8g_DrawWuLine2Bit((__int64)v4, 0, 57, 0x64u, 53);
}
while ( (unsigned __int8)u8g_NextPage(v4) );
while ( (int)u8g_sdl_get_key() < 0 )
;
return 0;
}

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

u8g_Init(v4, &u8g_dev_sdl_2bit, envp);
u8g_FirstPage(v4);
do
{
u8g_SetFont(v4, &u8g_font_10x20);
u8g_SetFont(v4, &u8g_font_fur25);
u8g_GetFontBBXWidth(v4);
u8g_GetFontBBXHeight(v4);
u8g_SetColorIndex(v4, 1LL);
u8g_DrawStr(v4, 30LL, 35LL, "gabc");
u8g_SetColorIndex(v4, 2LL);
u8g_DrawStr(v4, 31LL, 36LL, "gabc");
u8g_SetColorIndex(v4, 3LL);
u8g_DrawStr(v4, 32LL, 37LL, "gabc");
func1((__int64)v4, 0, 63, 0x64u, 63);
func1((__int64)v4, 0, 60, 0x64u, 58);
func1((__int64)v4, 0, 57, 0x64u, 53);
}
while ( (unsigned __int8)u8g_NextPage(v4) );
while ( (int)u8g_sdl_get_key() < 0 )
;
return 0;
}

original_code:
int main(void)
{
  u8g_uint_t w,h;
  u8g_t u8g;
  u8g_Init(&u8g, &u8g_dev_sdl_2bit);
  u8g_FirstPage(&u8g);
  do
  {
    u8g_SetFont(&u8g, u8g_font_10x20);
    u8g_SetFont(&u8g, u8g_font_fur25);
    w = u8g_GetFontBBXWidth(&u8g);
    h = u8g_GetFontBBXHeight(&u8g);
    u8g_SetColorIndex(&u8g, 1);
    u8g_DrawStr(&u8g, 30, 35, "gabc");
    u8g_SetColorIndex(&u8g, 2);
    u8g_DrawStr(&u8g, 30+1, 35+1, "gabc");
    u8g_SetColorIndex(&u8g, 3);
    u8g_DrawStr(&u8g, 30+2, 35+2, "gabc");
    u8g_DrawWuLine2Bit(&u8g, 0, 63, 100, 63);
    u8g_DrawWuLine2Bit(&u8g, 0, 63-3, 100, 63-5);
    u8g_DrawWuLine2Bit(&u8g, 0, 63-2*3, 100, 63-2*5);
  }while( u8g_NextPage(&u8g) );
  while( u8g_sdl_get_key() < 0 )
    ;
  return 0;
}

canonical_original_code:
int main()
{
  unsigned short w; unsigned short h;
  struct _u8g_t u8g;
  u8g_Init(&u8g, &u8g_dev_sdl_2bit);
  u8g_FirstPage(&u8g);
  do
  {
    u8g_SetFont(&u8g, u8g_font_10x20);
    u8g_SetFont(&u8g, u8g_font_fur25);
    w = u8g_GetFontBBXWidth(&u8g);
    h = u8g_GetFontBBXHeight(&u8g);
    u8g_SetColorIndex(&u8g, 1);
    u8g_DrawStr(&u8g, 30, 35, "gabc");
    u8g_SetColorIndex(&u8g, 2);
    u8g_DrawStr(&u8g, 30+1, 35+1, "gabc");
    u8g_SetColorIndex(&u8g, 3);
    u8g_DrawStr(&u8g, 30+2, 35+2, "gabc");
    u8g_DrawWuLine2Bit(&u8g, 0, 63, 100, 63);
    u8g_DrawWuLine2Bit(&u8g, 0, 63-3, 100, 63-5);
    u8g_DrawWuLine2Bit(&u8g, 0, 63-2*3, 100, 63-2*5);
  }while( u8g_NextPage(&u8g) );
  while( u8g_sdl_get_key() < 0 )
    ;
  return 0;
}

variable_types:
w
unsigned short

variable_types:
h
unsigned short

variable_types: struct _u8g_t { unsigned short width; unsigned short height; struct _u8g_dev_t { unsigned char (*dev_fn)(struct _u8g_t *u8g, struct _u8g_dev_t *dev, unsigned char msg, void *arg); void *dev_mem; unsigned char (*com_fn)(struct _u8g_t *u8g, unsigned char msg, unsigned char arg_val, void *arg_ptr); } *dev; unsigned char *font; unsigned char *cursor_font; unsigned char cursor_fg_color; unsigned char cursor_encoding; unsigned char mode; unsigned short cursor_x; unsigned short cursor_y; void (*cursor_fn)(struct _u8g_t *u8g); char glyph_dx; char glyph_x; char glyph_y; unsigned char glyph_width; unsigned char glyph_height; unsigned short (*font_calc_vref)(struct _u8g_t *u8g); unsigned char font_height_mode; char font_ref_ascent; char font_ref_descent; unsigned char font_line_spacing_factor; unsigned char line_spacing; struct _u8g_dev_arg_pixel_t { unsigned short x; unsigned char pixel; unsigned char dir; unsigned char color; unsigned char hi_color; unsigned char blue; } arg_pixel; void (*state_cb)(unsigned char msg); struct _u8g_box_t { unsigned short x0; } current_page; }


decompiled_code:
int __fastcall pic_gen_short_desc(__int64 a1, const char *a2)
{
char v3[256]; // [rsp+0h] [rbp-278h] BYREF
char v4[96]; // [rsp+100h] [rbp-178h] BYREF
char s[280]; // [rsp+160h] [rbp-118h] BYREF

u8g_Init(v4, &u8g_dev_pbm);
u8g_SetFont(v4, a1);
if ( (unsigned __int8)u8g_IsGlyph(v4, 97LL) )
sprintf(s, "%s: 123 ABC abcdefg", a2);
else
strcpy(s, "0123456789");
u8g_FirstPage(v4);
do
{
u8g_SetFont(v4, a1);
u8g_DrawStr(v4, 0LL, 100LL, s);
}
while ( (unsigned __int8)u8g_NextPage(v4) );
u8g_SetFont(v4, a1);
sprintf(v3, "convert u8g.pbm -trim %s_short.png", a2);
return system(v3);
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1, const char *a2)
{
char v3[256]; // [rsp+0h] [rbp-278h] BYREF
char v4[96]; // [rsp+100h] [rbp-178h] BYREF
char s[280]; // [rsp+160h] [rbp-118h] BYREF

u8g_Init(v4, &u8g_dev_pbm);
u8g_SetFont(v4, a1);
if ( (unsigned __int8)u8g_IsGlyph(v4, 97LL) )
sprintf(s, "%s: 123 ABC abcdefg", a2);
else
strcpy(s, "0123456789");
u8g_FirstPage(v4);
do
{
u8g_SetFont(v4, a1);
u8g_DrawStr(v4, 0LL, 100LL, s);
}
while ( (unsigned __int8)u8g_NextPage(v4) );
u8g_SetFont(v4, a1);
sprintf(v3, "convert u8g.pbm -trim %s_short.png", a2);
return system(v3);
}

original_code:
void pic_gen_short_desc(const u8g_pgm_uint8_t *font, const char *name, u8g_uint_t width, const char *real_name)
{
  char s[256];
  u8g_t u8g;
  u8g_Init(&u8g, &u8g_dev_pbm);
    u8g_SetFont(&u8g, font);
  if ( u8g_IsGlyph(&u8g, 'a') != 0 )
    sprintf(s, "%s: 123 ABC abcdefg", name);
  else
    sprintf(s, "0123456789");
  u8g_FirstPage(&u8g);
  do
  {
    u8g_SetFont(&u8g, font);
    u8g_DrawStr(&u8g, 0, 100, s);
  }while( u8g_NextPage(&u8g) );
  {
    char cmd[256];
    u8g_SetFont(&u8g, font);
    sprintf(cmd, "convert u8g.pbm -trim %s_short.png", name );
    system(cmd);
  }
}

canonical_original_code:
void pic_gen_short_desc(unsigned char *font, char *name, unsigned short width, char *real_name)
{
  char s[256];
  struct _u8g_t u8g;
  u8g_Init(&u8g, &u8g_dev_pbm);
    u8g_SetFont(&u8g, font);
  if ( u8g_IsGlyph(&u8g, 'a') != 0 )
    sprintf(s, "%s: 123 ABC abcdefg", name);
  else
    sprintf(s, "0123456789");
  u8g_FirstPage(&u8g);
  do
  {
    u8g_SetFont(&u8g, font);
    u8g_DrawStr(&u8g, 0, 100, s);
  }while( u8g_NextPage(&u8g) );
  {
    char cmd[256];
    u8g_SetFont(&u8g, font);
    sprintf(cmd, "convert u8g.pbm -trim %s_short.png", name );
    system(cmd);
  }
}

variable_types:
font
unsigned char *

variable_types:
name
char *

variable_types:
width
unsigned short

variable_types:
s
char [256]

variable_types:
cmd
char [256]


decompiled_code:
int __fastcall pic_gen_font(__int64 a1, const char *a2, __int16 a3, const char *a4)
{
unsigned __int16 v4; // bp
__int16 v5; // bx
unsigned __int16 v6; // r12
unsigned __int8 v7; // al
__int16 v8; // dx
__int16 v9; // r14
unsigned __int8 v10; // bp
unsigned __int8 v11; // bl
unsigned __int8 v12; // al
__int64 v13; // rax
unsigned __int16 v16; // [rsp+6h] [rbp-2B2h]
__int16 v18; // [rsp+18h] [rbp-2A0h]
__int16 v19; // [rsp+1Ah] [rbp-29Eh]
unsigned __int8 v20; // [rsp+1Ch] [rbp-29Ch]
unsigned __int8 v21; // [rsp+1Dh] [rbp-29Bh]
char command[256]; // [rsp+20h] [rbp-298h] BYREF
char v23[96]; // [rsp+120h] [rbp-198h] BYREF
char s[312]; // [rsp+180h] [rbp-138h] BYREF

pic_gen_short_desc(a1, a2);
u8g_Init(v23, &u8g_dev_pbm);
v21 = u8g_font_GetFontStartEncoding(a1);
v20 = u8g_font_GetFontEndEncoding(a1);
u8g_FirstPage(v23);
do
{
u8g_SetFont(v23, a1);
u8g_GetFontBBXWidth(v23);
u8g_GetFontBBXWidth(v23);
v7 = u8g_GetFontBBXHeight(v23);
v8 = v7;
if ( v7 <= 0xDu )
v8 = 14;
v9 = v8;
v18 = v8;
sprintf(s, "%s, %s", a2, a4);
u8g_SetFont(v23, &u8g_font_7x13);
u8g_DrawStrFontBBX(v23, 0LL, 14LL, 0LL, s);
u8g_SetFont(v23, a1);
v10 = u8g_GetFontCapitalAHeight(v23);
v11 = u8g_GetFontBBXHeight(v23);
v12 = u8g_GetFontBBXWidth(v23);
sprintf(s, "BBX Width %d, Height %d, Capital A %d", v12, v11, v10);
u8g_SetFont(v23, &u8g_font_7x13);
u8g_DrawStrFontBBX(v23, 0LL, 28LL, 0LL, s);
v13 = u8g_font_GetSize(a1);
sprintf(s, "Font data size: %d", v13);
u8g_DrawStrFontBBX(v23, 0LL, 42LL, 0LL, s);
v6 = v21 - (v21 & 0xF);
v16 = v9 + 42;
v19 = 16;
do
{
u8g_SetFont(v23, &u8g_font_7x13);
if ( v20 >= v6 )
{
sprintf(s, "%3d/0x%02x", v6, v6);
u8g_DrawStrFontBBX(v23, 0LL, v16, 0LL, s);
}
v4 = 75;
v5 = 16;
do
{
if ( v20 >= v6 )
{
u8g_SetFont(v23, a1);
u8g_DrawGlyphFontBBX(v23, v4, v16, 0LL, (unsigned __int8)v6++);
}
v4 += a3;
--v5;
}
while ( v5 );
v16 += v18;
--v19;
}
while ( v19 );
}
while ( (unsigned __int8)u8g_NextPage(v23) );
u8g_SetFont(v23, a1);
sprintf(command, "convert u8g.pbm -trim %s.png", a2);
return system(command);
}

canonical_decompiled_code:
int __fastcall func1(__int64 a1, const char *a2, __int16 a3, const char *a4)
{
unsigned __int16 v4; // bp
__int16 v5; // bx
unsigned __int16 v6; // r12
unsigned __int8 v7; // al
__int16 v8; // dx
__int16 v9; // r14
unsigned __int8 v10; // bp
unsigned __int8 v11; // bl
unsigned __int8 v12; // al
__int64 v13; // rax
unsigned __int16 v16; // [rsp+6h] [rbp-2B2h]
__int16 v18; // [rsp+18h] [rbp-2A0h]
__int16 v19; // [rsp+1Ah] [rbp-29Eh]
unsigned __int8 v20; // [rsp+1Ch] [rbp-29Ch]
unsigned __int8 v21; // [rsp+1Dh] [rbp-29Bh]
char command[256]; // [rsp+20h] [rbp-298h] BYREF
char v23[96]; // [rsp+120h] [rbp-198h] BYREF
char s[312]; // [rsp+180h] [rbp-138h] BYREF

func0(a1, a2);
u8g_Init(v23, &u8g_dev_pbm);
v21 = u8g_font_GetFontStartEncoding(a1);
v20 = u8g_font_GetFontEndEncoding(a1);
u8g_FirstPage(v23);
do
{
u8g_SetFont(v23, a1);
u8g_GetFontBBXWidth(v23);
u8g_GetFontBBXWidth(v23);
v7 = u8g_GetFontBBXHeight(v23);
v8 = v7;
if ( v7 <= 0xDu )
v8 = 14;
v9 = v8;
v18 = v8;
sprintf(s, "%s, %s", a2, a4);
u8g_SetFont(v23, &u8g_font_7x13);
u8g_DrawStrFontBBX(v23, 0LL, 14LL, 0LL, s);
u8g_SetFont(v23, a1);
v10 = u8g_GetFontCapitalAHeight(v23);
v11 = u8g_GetFontBBXHeight(v23);
v12 = u8g_GetFontBBXWidth(v23);
sprintf(s, "BBX Width %d, Height %d, Capital A %d", v12, v11, v10);
u8g_SetFont(v23, &u8g_font_7x13);
u8g_DrawStrFontBBX(v23, 0LL, 28LL, 0LL, s);
v13 = u8g_font_GetSize(a1);
sprintf(s, "Font data size: %d", v13);
u8g_DrawStrFontBBX(v23, 0LL, 42LL, 0LL, s);
v6 = v21 - (v21 & 0xF);
v16 = v9 + 42;
v19 = 16;
do
{
u8g_SetFont(v23, &u8g_font_7x13);
if ( v20 >= v6 )
{
sprintf(s, "%3d/0x%02x", v6, v6);
u8g_DrawStrFontBBX(v23, 0LL, v16, 0LL, s);
}
v4 = 75;
v5 = 16;
do
{
if ( v20 >= v6 )
{
u8g_SetFont(v23, a1);
u8g_DrawGlyphFontBBX(v23, v4, v16, 0LL, (unsigned __int8)v6++);
}
v4 += a3;
--v5;
}
while ( v5 );
v16 += v18;
--v19;
}
while ( v19 );
}
while ( (unsigned __int8)u8g_NextPage(v23) );
u8g_SetFont(v23, a1);
sprintf(command, "convert u8g.pbm -trim %s.png", a2);
return system(command);
}

original_code:
void pic_gen_font(const u8g_pgm_uint8_t *font, const char *name, u8g_uint_t width, const char *real_name)
{
  char s[256];
  const u8g_pgm_uint8_t *disp_font;
  uint16_t i;
  u8g_uint_t x,y,w,h, hcnt, disp_line_height, disp_line_indent;
  uint8_t start, end;
  u8g_t u8g;
  pic_gen_short_desc(font, name, width, real_name);
  u8g_Init(&u8g, &u8g_dev_pbm);
  disp_font = u8g_font_7x13;
  disp_line_height = 14;
  disp_line_indent = 75;
  start = u8g_font_GetFontStartEncoding(font);
  end = u8g_font_GetFontEndEncoding(font);
  u8g_FirstPage(&u8g);
  do
  {
    u8g_SetFont(&u8g, font);
    hcnt = ((&u8g)->width);
    hcnt /= u8g_GetFontBBXWidth(&u8g);
    hcnt -= 4;
    w = u8g_GetFontBBXWidth(&u8g);
    w = width;
    h = u8g_GetFontBBXHeight(&u8g);
    if ( h < disp_line_height )
      h = disp_line_height ;
    sprintf(s, "%s, %s", name,
        real_name);
    u8g_SetFont(&u8g, disp_font);
    u8g_DrawStrFontBBX(&u8g, 0, disp_line_height, 0, s);
    u8g_SetFont(&u8g, font);
    sprintf(s, "BBX Width %d, Height %d,  Capital A %d",
        u8g_GetFontBBXWidth(&u8g),
        u8g_GetFontBBXHeight(&u8g),
        u8g_GetFontCapitalAHeight(&u8g));
    u8g_SetFont(&u8g, disp_font);
    u8g_DrawStrFontBBX(&u8g, 0, disp_line_height*2, 0, s);
    sprintf(s, "Font data size: %d", u8g_font_GetSize(font));
    u8g_DrawStrFontBBX(&u8g, 0, disp_line_height*3, 0, s);
    hcnt = 16;
    i = start - start % hcnt;
    for( y = 0; y < 16; y++ )
    {
      u8g_SetFont(&u8g, disp_font);
      if ( i <= end )
      {
        sprintf(s, "%3d/0x%02x", i, i);
        u8g_DrawStrFontBBX(&u8g, 0, y*h+disp_line_height*3+h, 0, s);
      }
      for( x = 0; x < hcnt; x++ )
      {
        if ( i <= end )
        {
          u8g_SetFont(&u8g, font);
          u8g_DrawGlyphFontBBX(&u8g, x*w+disp_line_indent, y*h+disp_line_height*3+h, 0, i);
          i++;
        }
      }
    }
  }while( u8g_NextPage(&u8g) );
  {
    char cmd[256];
    u8g_SetFont(&u8g, font);
    sprintf(cmd, "convert u8g.pbm -trim %s.png", name );
    system(cmd);
  }
}

canonical_original_code:
void pic_gen_font(unsigned char *font, char *name, unsigned short width, char *real_name)
{
  char s[256];
  unsigned char *disp_font;
  unsigned short i;
  unsigned short x; unsigned short y; unsigned short w; unsigned short h; unsigned short hcnt; unsigned short disp_line_height; unsigned short disp_line_indent;
  unsigned char start; unsigned char end;
  struct _u8g_t u8g;
  pic_gen_short_desc(font, name, width, real_name);
  u8g_Init(&u8g, &u8g_dev_pbm);
  disp_font = u8g_font_7x13;
  disp_line_height = 14;
  disp_line_indent = 75;
  start = u8g_font_GetFontStartEncoding(font);
  end = u8g_font_GetFontEndEncoding(font);
  u8g_FirstPage(&u8g);
  do
  {
    u8g_SetFont(&u8g, font);
    hcnt = ((&u8g)->width);
    hcnt /= u8g_GetFontBBXWidth(&u8g);
    hcnt -= 4;
    w = u8g_GetFontBBXWidth(&u8g);
    w = width;
    h = u8g_GetFontBBXHeight(&u8g);
    if ( h < disp_line_height )
      h = disp_line_height ;
    sprintf(s, "%s, %s", name,
        real_name);
    u8g_SetFont(&u8g, disp_font);
    u8g_DrawStrFontBBX(&u8g, 0, disp_line_height, 0, s);
    u8g_SetFont(&u8g, font);
    sprintf(s, "BBX Width %d, Height %d,  Capital A %d",
        u8g_GetFontBBXWidth(&u8g),
        u8g_GetFontBBXHeight(&u8g),
        u8g_GetFontCapitalAHeight(&u8g));
    u8g_SetFont(&u8g, disp_font);
    u8g_DrawStrFontBBX(&u8g, 0, disp_line_height*2, 0, s);
    sprintf(s, "Font data size: %d", u8g_font_GetSize(font));
    u8g_DrawStrFontBBX(&u8g, 0, disp_line_height*3, 0, s);
    hcnt = 16;
    i = start - start % hcnt;
    for( y = 0; y < 16; y++ )
    {
      u8g_SetFont(&u8g, disp_font);
      if ( i <= end )
      {
        sprintf(s, "%3d/0x%02x", i, i);
        u8g_DrawStrFontBBX(&u8g, 0, y*h+disp_line_height*3+h, 0, s);
      }
      for( x = 0; x < hcnt; x++ )
      {
        if ( i <= end )
        {
          u8g_SetFont(&u8g, font);
          u8g_DrawGlyphFontBBX(&u8g, x*w+disp_line_indent, y*h+disp_line_height*3+h, 0, i);
          i++;
        }
      }
    }
  }while( u8g_NextPage(&u8g) );
  {
    char cmd[256];
    u8g_SetFont(&u8g, font);
    sprintf(cmd, "convert u8g.pbm -trim %s.png", name );
    system(cmd);
  }
}

variable_types:
i
unsigned short

variable_types:
x
unsigned short

variable_types:
y
unsigned short

variable_types:
hcnt
unsigned short

variable_types:
start
unsigned char

variable_types:
end
unsigned char


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
pic_gen_font((__int64)&u8g_font_unifont_72_73, "u8g_font_unifont_72_73", 17, "Unifont");
pic_gen_font((__int64)&u8g_font_unifont_67_75, "u8g_font_unifont_67_75", 17, "Unifont");
pic_gen_font((__int64)&u8g_font_unifont_75r, "u8g_font_unifont_75r", 17, "Unifont");
pic_gen_font((__int64)&u8g_font_unifont_76, "u8g_font_unifont_76", 17, "Unifont");
pic_gen_font((__int64)&u8g_font_unifont_77, "u8g_font_unifont_77", 17, "Unifont");
pic_gen_font((__int64)&u8g_font_unifont_78_79, "u8g_font_unifont_78_79", 17, "Unifont");
pic_gen_font((__int64)&u8g_font_unifont_86, "u8g_font_unifont_86", 17, "Unifont");
pic_gen_font((__int64)&u8g_font_unifont, "u8g_font_unifont", 17, "Unifont");
pic_gen_font((__int64)&u8g_font_unifontr, "u8g_font_unifontr", 17, "Unifont");
pic_gen_font((__int64)&u8g_font_unifont_0_8, "u8g_font_unifont_0_8", 17, "Unifont");
pic_gen_font((__int64)&u8g_font_unifont_2_3, "u8g_font_unifont_2_3", 17, "Unifont");
pic_gen_font((__int64)&u8g_font_unifont_4_5, "u8g_font_unifont_4_5", 17, "Unifont");
pic_gen_font((__int64)&u8g_font_unifont_8_9, "u8g_font_unifont_8_9", 17, "Unifont");
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
func1((__int64)&u8g_font_unifont_72_73, "u8g_font_unifont_72_73", 17, "Unifont");
func1((__int64)&u8g_font_unifont_67_75, "u8g_font_unifont_67_75", 17, "Unifont");
func1((__int64)&u8g_font_unifont_75r, "u8g_font_unifont_75r", 17, "Unifont");
func1((__int64)&u8g_font_unifont_76, "u8g_font_unifont_76", 17, "Unifont");
func1((__int64)&u8g_font_unifont_77, "u8g_font_unifont_77", 17, "Unifont");
func1((__int64)&u8g_font_unifont_78_79, "u8g_font_unifont_78_79", 17, "Unifont");
func1((__int64)&u8g_font_unifont_86, "u8g_font_unifont_86", 17, "Unifont");
func1((__int64)&u8g_font_unifont, "u8g_font_unifont", 17, "Unifont");
func1((__int64)&u8g_font_unifontr, "u8g_font_unifontr", 17, "Unifont");
func1((__int64)&u8g_font_unifont_0_8, "u8g_font_unifont_0_8", 17, "Unifont");
func1((__int64)&u8g_font_unifont_2_3, "u8g_font_unifont_2_3", 17, "Unifont");
func1((__int64)&u8g_font_unifont_4_5, "u8g_font_unifont_4_5", 17, "Unifont");
func1((__int64)&u8g_font_unifont_8_9, "u8g_font_unifont_8_9", 17, "Unifont");
return 0;
}

original_code:
int main(void)
{
  pic_gen_font(u8g_font_unifont_72_73, "u8g_font_unifont_72_73", 17, "Unifont");
  pic_gen_font(u8g_font_unifont_67_75, "u8g_font_unifont_67_75", 17, "Unifont");
  pic_gen_font(u8g_font_unifont_75r, "u8g_font_unifont_75r", 17, "Unifont");
  pic_gen_font(u8g_font_unifont_76, "u8g_font_unifont_76", 17, "Unifont");
  pic_gen_font(u8g_font_unifont_77, "u8g_font_unifont_77", 17, "Unifont");
  pic_gen_font(u8g_font_unifont_78_79, "u8g_font_unifont_78_79", 17, "Unifont");
  pic_gen_font(u8g_font_unifont_86, "u8g_font_unifont_86", 17, "Unifont");
  pic_gen_font(u8g_font_unifont, "u8g_font_unifont", 17, "Unifont");
  pic_gen_font(u8g_font_unifontr, "u8g_font_unifontr", 17, "Unifont");
  pic_gen_font(u8g_font_unifont_0_8, "u8g_font_unifont_0_8", 17, "Unifont");
  pic_gen_font(u8g_font_unifont_2_3, "u8g_font_unifont_2_3", 17, "Unifont");
  pic_gen_font(u8g_font_unifont_4_5, "u8g_font_unifont_4_5", 17, "Unifont");
  pic_gen_font(u8g_font_unifont_8_9, "u8g_font_unifont_8_9", 17, "Unifont");
  return 0;
}

canonical_original_code:
int main()
{
  pic_gen_font(u8g_font_unifont_72_73, "u8g_font_unifont_72_73", 17, "Unifont");
  pic_gen_font(u8g_font_unifont_67_75, "u8g_font_unifont_67_75", 17, "Unifont");
  pic_gen_font(u8g_font_unifont_75r, "u8g_font_unifont_75r", 17, "Unifont");
  pic_gen_font(u8g_font_unifont_76, "u8g_font_unifont_76", 17, "Unifont");
  pic_gen_font(u8g_font_unifont_77, "u8g_font_unifont_77", 17, "Unifont");
  pic_gen_font(u8g_font_unifont_78_79, "u8g_font_unifont_78_79", 17, "Unifont");
  pic_gen_font(u8g_font_unifont_86, "u8g_font_unifont_86", 17, "Unifont");
  pic_gen_font(u8g_font_unifont, "u8g_font_unifont", 17, "Unifont");
  pic_gen_font(u8g_font_unifontr, "u8g_font_unifontr", 17, "Unifont");
  pic_gen_font(u8g_font_unifont_0_8, "u8g_font_unifont_0_8", 17, "Unifont");
  pic_gen_font(u8g_font_unifont_2_3, "u8g_font_unifont_2_3", 17, "Unifont");
  pic_gen_font(u8g_font_unifont_4_5, "u8g_font_unifont_4_5", 17, "Unifont");
  pic_gen_font(u8g_font_unifont_8_9, "u8g_font_unifont_8_9", 17, "Unifont");
  return 0;
}


xmain

decompiled_code:
__int64 xmain()
{
_BYTE v1[104]; // [rsp+0h] [rbp-68h] BYREF

u8g_Init(v1, &u8g_dev_sdl_1bit);
u8g_FirstPage(v1);
u8g_SetCursorFont(v1, &u8g_font_cursor);
do
{
u8g_SetColorIndex(v1, 1LL);
u8g_SetFont(v1, &u8g_font_9x18);
u8g_GetFontBBXWidth(v1);
u8g_GetFontBBXHeight(v1);
u8g_DrawStrDir(v1, 0LL, 5LL, 0LL, &unk_2C0);
u8g_DrawStrDir(v1, 10LL, 7LL, 0LL, &unk_2C0);
u8g_DrawStrDir(v1, 20LL, 9LL, 0LL, &unk_2C0);
u8g_DrawStrDir(v1, 20LL, 9LL, 0LL, &unk_2C2);
u8g_DrawStr(v1, 73LL, 25LL, "gabc");
u8g_DrawStr90(v1, 70LL, 28LL, "gabc");
u8g_DrawStr180(v1, 67LL, 25LL, "gabc");
u8g_DrawStr270(v1, 70LL, 22LL, "gabc");
u8g_SetColorIndex(v1, 1LL);
u8g_DrawHLine(v1, 0LL, 3LL, 127LL);
u8g_SetColorIndex(v1, 0LL);
u8g_DrawHLine(v1, 0LL, 4LL, 127LL);
}
while ( (unsigned __int8)u8g_NextPage(v1) );
while ( (int)u8g_sdl_get_key() < 0 )
;
return 0LL;
}

canonical_decompiled_code:
__int64 func0()
{
_BYTE v1[104]; // [rsp+0h] [rbp-68h] BYREF

u8g_Init(v1, &u8g_dev_sdl_1bit);
u8g_FirstPage(v1);
u8g_SetCursorFont(v1, &u8g_font_cursor);
do
{
u8g_SetColorIndex(v1, 1LL);
u8g_SetFont(v1, &u8g_font_9x18);
u8g_GetFontBBXWidth(v1);
u8g_GetFontBBXHeight(v1);
u8g_DrawStrDir(v1, 0LL, 5LL, 0LL, &unk_2C0);
u8g_DrawStrDir(v1, 10LL, 7LL, 0LL, &unk_2C0);
u8g_DrawStrDir(v1, 20LL, 9LL, 0LL, &unk_2C0);
u8g_DrawStrDir(v1, 20LL, 9LL, 0LL, &unk_2C2);
u8g_DrawStr(v1, 73LL, 25LL, "gabc");
u8g_DrawStr90(v1, 70LL, 28LL, "gabc");
u8g_DrawStr180(v1, 67LL, 25LL, "gabc");
u8g_DrawStr270(v1, 70LL, 22LL, "gabc");
u8g_SetColorIndex(v1, 1LL);
u8g_DrawHLine(v1, 0LL, 3LL, 127LL);
u8g_SetColorIndex(v1, 0LL);
u8g_DrawHLine(v1, 0LL, 4LL, 127LL);
}
while ( (unsigned __int8)u8g_NextPage(v1) );
while ( (int)u8g_sdl_get_key() < 0 )
;
return 0LL;
}

original_code:
int xmain(void)
{
  u8g_uint_t w,h;
  u8g_t u8g;
  u8g_Init(&u8g, &u8g_dev_sdl_1bit);
  u8g_FirstPage(&u8g);
  u8g_SetCursorFont(&u8g, u8g_font_cursor);
  do
  {
    u8g_SetColorIndex(&u8g, 1);
    u8g_SetFont(&u8g, u8g_font_9x18);
    w = u8g_GetFontBBXWidth(&u8g);
    h = u8g_GetFontBBXHeight(&u8g);
    u8g_DrawStrDir(&u8g, 0, 5, 0, "g");
    u8g_DrawStrDir(&u8g, 10, 7, 0, "g");
    u8g_DrawStrDir(&u8g, 20, 9, 0, "g");
    u8g_DrawStrDir(&u8g, 20, 9, 0, "ga");
    u8g_DrawStr(&u8g, 70+3, 25, "gabc");
    u8g_DrawStr90(&u8g, 70, 25+3, "gabc");
    u8g_DrawStr180(&u8g, 70-3, 25, "gabc");
    u8g_DrawStr270(&u8g, 70, 25-3, "gabc");
    u8g_SetColorIndex(&u8g, 1);
    u8g_DrawHLine( &u8g, 0, 3, 127 );
    u8g_SetColorIndex(&u8g, 0);
    u8g_DrawHLine( &u8g, 0, 4, 127 );
  }while( u8g_NextPage(&u8g) );
  while( u8g_sdl_get_key() < 0 )
    ;
  return 0;
}

canonical_original_code:
int xmain()
{
  unsigned short w; unsigned short h;
  struct _u8g_t u8g;
  u8g_Init(&u8g, &u8g_dev_sdl_1bit);
  u8g_FirstPage(&u8g);
  u8g_SetCursorFont(&u8g, u8g_font_cursor);
  do
  {
    u8g_SetColorIndex(&u8g, 1);
    u8g_SetFont(&u8g, u8g_font_9x18);
    w = u8g_GetFontBBXWidth(&u8g);
    h = u8g_GetFontBBXHeight(&u8g);
    u8g_DrawStrDir(&u8g, 0, 5, 0, "g");
    u8g_DrawStrDir(&u8g, 10, 7, 0, "g");
    u8g_DrawStrDir(&u8g, 20, 9, 0, "g");
    u8g_DrawStrDir(&u8g, 20, 9, 0, "ga");
    u8g_DrawStr(&u8g, 70+3, 25, "gabc");
    u8g_DrawStr90(&u8g, 70, 25+3, "gabc");
    u8g_DrawStr180(&u8g, 70-3, 25, "gabc");
    u8g_DrawStr270(&u8g, 70, 25-3, "gabc");
    u8g_SetColorIndex(&u8g, 1);
    u8g_DrawHLine( &u8g, 0, 3, 127 );
    u8g_SetColorIndex(&u8g, 0);
    u8g_DrawHLine( &u8g, 0, 4, 127 );
  }while( u8g_NextPage(&u8g) );
  while( u8g_sdl_get_key() < 0 )
    ;
  return 0;
}


draw

decompiled_code:
__int64 draw()
{
u8g_SetFont(&u8g, &u8g_font_helvR08);
u8g_SetFontPosTop(&u8g);
u8g_DrawStr(&u8g, 0LL, 0LL, "Hello World!");
u8g_SetFont(&u8g, &u8g_font_profont11);
u8g_SetFontPosTop(&u8g);
u8g_DrawStr(&u8g, 32LL, 25LL, "see yah!");
return u8g_DrawPixel(&u8g, 32LL, 25LL);
}

canonical_decompiled_code:
__int64 func1()
{
u8g_SetFont(&u8g, &u8g_font_helvR08);
u8g_SetFontPosTop(&u8g);
u8g_DrawStr(&u8g, 0LL, 0LL, "Hello World!");
u8g_SetFont(&u8g, &u8g_font_profont11);
u8g_SetFontPosTop(&u8g);
u8g_DrawStr(&u8g, 32LL, 25LL, "see yah!");
return u8g_DrawPixel(&u8g, 32LL, 25LL);
}

original_code:
void draw(void) {
  u8g_SetFont(&u8g, u8g_font_helvR08);
  u8g_SetFontPosTop(&u8g);
  u8g_DrawStr( &u8g, 0, 0, "Hello World!");
  u8g_SetFont(&u8g, u8g_font_profont11);
  u8g_SetFontPosTop(&u8g);
  u8g_DrawStr( &u8g, 32, 25, "see yah!");
  u8g_DrawPixel(&u8g, 32, 25);
}

canonical_original_code:
void draw() {
  u8g_SetFont(&u8g, u8g_font_helvR08);
  u8g_SetFontPosTop(&u8g);
  u8g_DrawStr( &u8g, 0, 0, "Hello World!");
  u8g_SetFont(&u8g, u8g_font_profont11);
  u8g_SetFontPosTop(&u8g);
  u8g_DrawStr( &u8g, 32, 25, "see yah!");
  u8g_DrawPixel(&u8g, 32, 25);
}


decompiled_code:
__int64 __fastcall col_find(char *s2)
{
int v1; // er13
const char *v2; // rbp
unsigned int v3; // ebx

v1 = col_cnt;
if ( col_cnt <= 0 )
return (unsigned int)-1;
v2 = col_name;
v3 = 0;
while ( strcmp(v2, s2) )
{
++v3;
v2 += 1024;
if ( v3 == v1 )
return (unsigned int)-1;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func7(char *s2)
{
int v1; // er13
const char *v2; // rbp
unsigned int v3; // ebx

v1 = col_cnt;
if ( col_cnt <= 0 )
return (unsigned int)-1;
v2 = col_name;
v3 = 0;
while ( strcmp(v2, s2) )
{
++v3;
v2 += 1024;
if ( v3 == v1 )
return (unsigned int)-1;
}
return v3;
}

original_code:
int col_find(const char *name)
{
  int i;
  for( i = 0; i < col_cnt; i++ )
    if ( strcmp(col_name[i], name) == 0 )
      return i;
  return -1;
}

canonical_original_code:
int col_find(char *name)
{
  int i;
  for( i = 0; i < col_cnt; i++ )
    if ( strcmp(col_name[i], name) == 0 )
      return i;
  return -1;
}

variable_types: i int


decompiled_code:
__int64 __fastcall col_add(char *src)
{
unsigned int v1; // ebx

v1 = col_cnt;
if ( col_cnt > 15 )
{
fwrite("maximum number of columns reached\n", 1uLL, 0x22uLL, stderr);
exit(1);
}
strcpy((char *)(((__int64)col_cnt << 10) + 4243008), src);
col_cnt = v1 + 1;
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func8(char *src)
{
unsigned int v1; // ebx

v1 = col_cnt;
if ( col_cnt > 15 )
{
fwrite("maximum number of columns reached\n", 1uLL, 0x22uLL, stderr);
exit(1);
}
strcpy((char *)(((__int64)col_cnt << 10) + 4243008), src);
col_cnt = v1 + 1;
return v1;
}

original_code:
int col_add(const char *name)
{
  if ( col_cnt >= 16 )
  {
    fprintf(stderr, "maximum number of columns reached\n");
    exit(1);
  }
  strcpy(col_name[col_cnt], name);
  col_cnt++;
  return col_cnt-1;
}

canonical_original_code:
int col_add(char *name)
{
  if ( col_cnt >= 16 )
  {
    fprintf(stderr, "maximum number of columns reached\n");
    exit(1);
  }
  strcpy(col_name[col_cnt], name);
  col_cnt++;
  return col_cnt-1;
}


decompiled_code:
void col_clear_field_visibility()
{
int v0; // edx
__int64 v1; // rax

v0 = col_cnt;
if ( col_cnt > 0 )
{
v1 = 0LL;
do
col_field_visible[v1++] = 0;
while ( v1 != v0 );
}
}

canonical_decompiled_code:
void func9()
{
int v0; // edx
__int64 v1; // rax

v0 = col_cnt;
if ( col_cnt > 0 )
{
v1 = 0LL;
do
col_field_visible[v1++] = 0;
while ( v1 != v0 );
}
}

original_code:
void col_clear_field_visibility(void)
{
  int i;
  for( i = 0; i < col_cnt; i++ )
    col_field_visible[i] = 0;
}

canonical_original_code:
void col_clear_field_visibility()
{
  int i;
  for( i = 0; i < col_cnt; i++ )
    col_field_visible[i] = 0;
}


decompiled_code:
void __fastcall col_mark_field_visible(int a1)
{
col_field_visible[a1] = 1;
}

canonical_decompiled_code:
void __fastcall func10(int a1)
{
col_field_visible[a1] = 1;
}

original_code:
void col_mark_field_visible(int pos)
{
  col_field_visible[pos] = 1;
}

variable_types: pos int


decompiled_code:
__int64 __fastcall col_is_field_visible(int a1)
{
return (unsigned int)col_field_visible[a1];
}

canonical_decompiled_code:
__int64 __fastcall func11(int a1)
{
return (unsigned int)col_field_visible[a1];
}

original_code:
int col_is_field_visible(int pos)
{
  return col_field_visible[pos];
}


decompiled_code:
void table_next_line()
{
++table_line;
col_clear_field_visibility();
}

canonical_decompiled_code:
void func12()
{
++table_line;
func9();
}

original_code:
void table_next_line(void)
{
  table_line++;
  col_clear_field_visibility();
}

canonical_original_code:
void table_next_line()
{
  table_line++;
  col_clear_field_visibility();
}


decompiled_code:
void table_finish_line()
{
int v0; // ebp
__int64 v1; // r12
__int64 v2; // rbx

v0 = col_cnt;
if ( col_cnt > 0 )
{
v1 = 16LL * table_line;
v2 = 0LL;
do
{
table_visibility[v2 + v1] = col_is_field_visible(v2);
++v2;
}
while ( v2 != v0 );
}
table_next_line();
}

canonical_decompiled_code:
void func13()
{
int v0; // ebp
__int64 v1; // r12
__int64 v2; // rbx

v0 = col_cnt;
if ( col_cnt > 0 )
{
v1 = 16LL * table_line;
v2 = 0LL;
do
{
table_visibility[v2 + v1] = func11(v2);
++v2;
}
while ( v2 != v0 );
}
func12();
}

original_code:
void table_finish_line(void)
{
  int i;
  for( i = 0; i < col_cnt; i++ )
    table_visibility[table_line][i] = (unsigned char)col_is_field_visible(i);
  table_next_line();
}

canonical_original_code:
void table_finish_line()
{
  int i;
  for( i = 0; i < col_cnt; i++ )
    table_visibility[table_line][i] = (unsigned char)col_is_field_visible(i);
  table_next_line();
}


decompiled_code:
void __fastcall table_add_field(int a1)
{
if ( (unsigned int)col_is_field_visible(a1) )
table_finish_line();
col_mark_field_visible(a1);
}

canonical_decompiled_code:
void __fastcall func14(int a1)
{
if ( (unsigned int)func11(a1) )
func13();
func10(a1);
}

original_code:
void table_add_field(int pos)
{
  if ( col_is_field_visible(pos) == 0 )
  {
    col_mark_field_visible(pos);
  }
  else
  {
    table_finish_line();
    col_mark_field_visible(pos);
  }
}


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

v2 = 16LL * a1;
result = 0LL;
if ( table_visibility[a2 + v2] )
{
if ( a1 + 1 >= table_lines )
{
result = 1LL;
}
else
{
v4 = (char *)&unk_4040F0 + a2 + v2;
v5 = table_lines - a1;
result = 1LL;
while ( !*v4 )
{
result = (unsigned int)(result + 1);
v4 += 16;
if ( (_DWORD)result == v5 )
return v5;
}
}
}
return result;
}

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

v2 = 16LL * a1;
result = 0LL;
if ( table_visibility[a2 + v2] )
{
if ( a1 + 1 >= table_lines )
{
result = 1LL;
}
else
{
v4 = (char *)&unk_4040F0 + a2 + v2;
v5 = table_lines - a1;
result = 1LL;
while ( !*v4 )
{
result = (unsigned int)(result + 1);
v4 += 16;
if ( (_DWORD)result == v5 )
return v5;
}
}
}
return result;
}

original_code:
int table_get_row_span(int row, int pos)
{
  int i, span = 1;
  if ( table_visibility[row][pos] == 0 )
    return 0;
  i = row+1;
  while(i < table_lines)
  {
    if ( table_visibility[i][pos] != 0 )
      break;
    span++;
    i++;
  }
  return span;
}

canonical_original_code:
int table_get_row_span(int row, int pos)
{
  int i; int span = 1;
  if ( table_visibility[row][pos] == 0 )
    return 0;
  i = row+1;
  while(i < table_lines)
  {
    if ( table_visibility[i][pos] != 0 )
      break;
    span++;
    i++;
  }
  return span;
}

variable_types: row int

variable_types: span int


decompiled_code:
int __fastcall html_out(const char *a1)
{
return printf("%s", a1);
}

canonical_decompiled_code:
int __fastcall func16(const char *a1)
{
return printf("%s", a1);
}

original_code:
void html_out(const char *s)
{
  printf("%s", s);
}

canonical_original_code:
void html_out(char *s)
{
  printf("%s", s);
}

variable_types:
s
char *


decompiled_code:
int html_start_table()
{
return html_out("<table border=\"1\" cellspacing=\"0\">\n");
}

canonical_decompiled_code:
int func17()
{
return func16("<table border=\"1\" cellspacing=\"0\">\n");
}

original_code:
void html_start_table(void)
{
  html_out("<table border=\"1\" cellspacing=\"0\">\n");
}

canonical_original_code:
void html_start_table()
{
  html_out("<table border=\"1\" cellspacing=\"0\">\n");
}


decompiled_code:
int html_end_table()
{
return html_out("</table>\n");
}

canonical_decompiled_code:
int func18()
{
return func16("</table>\n");
}

original_code:
void html_end_table(void)
{
  html_out("</table>\n");
}

canonical_original_code:
void html_end_table()
{
  html_out("</table>\n");
}


decompiled_code:
int html_start_row()
{
is_in_row = 1;
return html_out("<tr>\n");
}

canonical_decompiled_code:
int func19()
{
is_in_row = 1;
return func16("<tr>\n");
}

original_code:
void html_start_row(void)
{
  is_in_row = 1;
  html_out("<tr>\n");
}

canonical_original_code:
void html_start_row()
{
  is_in_row = 1;
  html_out("<tr>\n");
}


decompiled_code:
int html_end_row()
{
int result; // eax

if ( is_in_row )
{
is_in_row = 0;
result = html_out("</tr>\n");
}
return result;
}

canonical_decompiled_code:
int func20()
{
int result; // eax

if ( is_in_row )
{
is_in_row = 0;
result = func16("</tr>\n");
}
return result;
}

original_code:
void html_end_row(void)
{
  if ( is_in_row == 0 )
    return;
  is_in_row = 0;
  html_out("</tr>\n");
}

canonical_original_code:
void html_end_row()
{
  if ( is_in_row == 0 )
    return;
  is_in_row = 0;
  html_out("</tr>\n");
}


decompiled_code:
int __fastcall html_start_field(int a1)
{
int v1; // eax
char v3[1032]; // [rsp+0h] [rbp-408h] BYREF

is_in_field = 1;
v1 = table_get_row_span(table_line, a1);
if ( v1 <= 1 )
strcpy(v3, "\n");
else
sprintf(v3, "\n", (unsigned int)v1);
return html_out(v3);
}

canonical_decompiled_code:
int __fastcall func21(int a1)
{
int v1; // eax
char v3[1032]; // [rsp+0h] [rbp-408h] BYREF

is_in_field = 1;
v1 = func15(table_line, a1);
if ( v1 <= 1 )
strcpy(v3, "\n");
else
sprintf(v3, "\n", (unsigned int)v1);
return func16(v3);
}

original_code:
void html_start_field(int pos)
{
  char buf[1024];
  int rowspan;
  is_in_field = 1;
  rowspan = table_get_row_span(table_line, pos);
  if ( rowspan >= 2 )
    sprintf(buf, "\n", rowspan);
  else
    sprintf(buf, "\n");
  html_out(buf);
}

variable_types:
buf
char [1024]

variable_types: rowspan int


decompiled_code:
int html_end_field()
{
int result; // eax

if ( is_in_field )
{
is_in_field = 0;
result = html_out("	\n");
}
return result;
}

canonical_decompiled_code:
int func22()
{
int result; // eax

if ( is_in_field )
{
is_in_field = 0;
result = func16("	\n");
}
return result;
}

original_code:
void html_end_field(int pos)
{
  if ( is_in_field == 0 )
    return;
  is_in_field = 0;
  html_out("	\n");
}


decompiled_code:
int __fastcall table_add_field_phase2(int a1)
{
if ( (unsigned int)col_is_field_visible(a1) )
{
html_end_field();
html_end_row();
table_next_line();
html_start_row();
}
else
{
html_end_field();
}
col_mark_field_visible(a1);
return html_start_field(a1);
}

canonical_decompiled_code:
int __fastcall func23(int a1)
{
if ( (unsigned int)func11(a1) )
{
func22();
func20();
func12();
func19();
}
else
{
func22();
}
func10(a1);
return func21(a1);
}

original_code:
void table_add_field_phase2(int pos)
{
  if ( col_is_field_visible(pos) == 0 )
  {
    html_end_field(col_last);
    col_mark_field_visible(pos);
    html_start_field(pos);
  }
  else
  {
    html_end_field(col_last);
    html_end_row();
    table_next_line();
    html_start_row();
    col_mark_field_visible(pos);
    html_start_field(pos);
  }
}


decompiled_code:
void table_show_visibilty_matrx()
{
__int64 v0; // r13
int i; // er12
unsigned int v2; // eax
__int64 j; // rbx

v0 = 0LL;
for ( i = 0; table_lines > i; v0 += 16LL )
{
for ( j = 0LL; col_cnt > (int)j; ++j )
{
if ( table_visibility[v0 + j] )
putchar(120);
else
putchar(46);
v2 = table_get_row_span(i, j);
printf("%d", v2);
}
putchar(10);
++i;
}
}

canonical_decompiled_code:
void func24()
{
__int64 v0; // r13
int i; // er12
unsigned int v2; // eax
__int64 j; // rbx

v0 = 0LL;
for ( i = 0; table_lines > i; v0 += 16LL )
{
for ( j = 0LL; col_cnt > (int)j; ++j )
{
if ( table_visibility[v0 + j] )
putchar(120);
else
putchar(46);
v2 = func15(i, j);
printf("%d", v2);
}
putchar(10);
++i;
}
}

original_code:
void table_show_visibilty_matrx(void)
{
  int i, j;
  for( j = 0; j < table_lines; j++ )
  {
    for( i = 0; i < col_cnt; i++ )
    {
      if ( table_visibility[j][i] == 0 )
        printf(".");
      else
        printf("x");
      printf("%d", table_get_row_span(j,i));
    }
    printf("\n");
  }
}

canonical_original_code:
void table_show_visibilty_matrx()
{
  int i; int j;
  for( j = 0; j < table_lines; j++ )
  {
    for( i = 0; i < col_cnt; i++ )
    {
      if ( table_visibility[j][i] == 0 )
        printf(".");
      else
        printf("x");
      printf("%d", table_get_row_span(j,i));
    }
    printf("\n");
  }
}

variable_types: j int


decompiled_code:
void __fastcall table_column(char *src)
{
int v1; // eax
int v2; // eax

if ( phase )
{
if ( phase == 1 )
{
v2 = col_find(src);
col_last = v2;
if ( v2 < 0 )
exit(0);
table_add_field(v2);
}
else if ( phase == 2 )
{
v1 = col_find(src);
col_last = v1;
if ( v1 < 0 )
exit(0);
table_add_field_phase2(v1);
}
}
else
{
col_last = col_find(src);
if ( col_last < 0 )
col_last = col_add(src);
}
}

canonical_decompiled_code:
void __fastcall func25(char *src)
{
int v1; // eax
int v2; // eax

if ( phase )
{
if ( phase == 1 )
{
v2 = func7(src);
col_last = v2;
if ( v2 < 0 )
exit(0);
func14(v2);
}
else if ( phase == 2 )
{
v1 = func7(src);
col_last = v1;
if ( v1 < 0 )
exit(0);
func23(v1);
}
}
else
{
col_last = func7(src);
if ( col_last < 0 )
col_last = func8(src);
}
}

original_code:
void table_column(const char *name)
{
  if ( phase == 0 )
  {
    col_last = col_find(name);
    if ( col_last < 0 )
      col_last = col_add(name);
  }
  else if ( phase == 1 )
  {
    col_last = col_find(name);
    if ( col_last < 0 )
      exit(0);
    table_add_field(col_last);
  }
  else if ( phase == 2 )
  {
    col_last = col_find(name);
    if ( col_last < 0 )
      exit(0);
    table_add_field_phase2(col_last);
  }
}

canonical_original_code:
void table_column(char *name)
{
  if ( phase == 0 )
  {
    col_last = col_find(name);
    if ( col_last < 0 )
      col_last = col_add(name);
  }
  else if ( phase == 1 )
  {
    col_last = col_find(name);
    if ( col_last < 0 )
      exit(0);
    table_add_field(col_last);
  }
  else if ( phase == 2 )
  {
    col_last = col_find(name);
    if ( col_last < 0 )
      exit(0);
    table_add_field_phase2(col_last);
  }
}

variable_types:
name
char *


decompiled_code:
int __fastcall table_text(const char *a1)
{
int result; // eax

if ( phase == 2 )
result = html_out(a1);
return result;
}

canonical_decompiled_code:
int __fastcall func26(const char *a1)
{
int result; // eax

if ( phase == 2 )
result = func16(a1);
return result;
}

original_code:
void table_text(const char *text)
{
  if ( phase == 2 )
  {
    html_out(text);
  }
}

canonical_original_code:
void table_text(char *text)
{
  if ( phase == 2 )
  {
    html_out(text);
  }
}

variable_types:
text
char *


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int result; // eax

if ( argc <= 1 )
{
printf("%s <tablefile>\n", *argv);
result = 1;
}
else
{
table_read_file((char *)argv[1]);
result = 0;
}
return result;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int result; // eax

if ( argc <= 1 )
{
printf("%s <tablefile>\n", *argv);
result = 1;
}
else
{
func28((char *)argv[1]);
result = 0;
}
return result;
}

original_code:
int main(int argc, char **argv)
{
  if ( argc <= 1 )
  {
    printf("%s <tablefile>\n", argv[0]);
    return 1;
  }
  table_read_file(argv[1]);
  return 0;
}

variable_types: argc int

variable_types:
argv
char **