decompiled_code:
const char *get_NURON_LIBNAME()
{
const char *result; // rax

result = (const char *)NURON_LIBNAME;
if ( !NURON_LIBNAME )
result = "nuronssl";
return result;
}

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

result = (const char *)NURON_LIBNAME;
if ( !NURON_LIBNAME )
result = "nuronssl";
return result;
}

original_code:
static const char *get_NURON_LIBNAME(void)
{
    if (NURON_LIBNAME)
        return NURON_LIBNAME;
    return "nuronssl";
}

canonical_original_code:
static char *get_NURON_LIBNAME()
{
    if (NURON_LIBNAME)
        return NURON_LIBNAME;
    return "nuronssl";
}


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

if ( NURON_LIBNAME )
result = CRYPTO_free();
NURON_LIBNAME = 0LL;
return result;
}

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

if ( NURON_LIBNAME )
result = CRYPTO_free();
NURON_LIBNAME = 0LL;
return result;
}

original_code:
static void free_NURON_LIBNAME(void)
{
    if (NURON_LIBNAME)
        CRYPTO_free((void *)NURON_LIBNAME);
    NURON_LIBNAME = ((void *)0);
}

canonical_original_code:
static void free_NURON_LIBNAME()
{
    if (NURON_LIBNAME)
        CRYPTO_free((void *)NURON_LIBNAME);
    NURON_LIBNAME = ((void *)0);
}

return_type: void


decompiled_code:
_BOOL8 __fastcall set_NURON_LIBNAME(__int64 a1)
{
free_NURON_LIBNAME();
NURON_LIBNAME = BUF_strdup(a1);
return NURON_LIBNAME != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(__int64 a1)
{
func1();
NURON_LIBNAME = BUF_strdup(a1);
return NURON_LIBNAME != 0;
}

original_code:
static long set_NURON_LIBNAME(const char *name)
{
    free_NURON_LIBNAME();
    return (((NURON_LIBNAME = BUF_strdup(name)) != ((void *)0)) ? 1 : 0);
}

canonical_original_code:
static long set_NURON_LIBNAME(char *name)
{
    free_NURON_LIBNAME();
    return (((NURON_LIBNAME = BUF_strdup(name)) != ((void *)0)) ? 1 : 0);
}

variable_types:
name
char *

return_type: long


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

result = (unsigned int)NURON_error_init;
if ( !NURON_error_init )
{
ERR_unload_strings((unsigned int)NURON_lib_error_code, &NURON_str_functs);
ERR_unload_strings((unsigned int)NURON_lib_error_code, &NURON_str_reasons);
result = ERR_unload_strings(0LL, &NURON_lib_name);
NURON_error_init = 1;
}
return result;
}

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

result = (unsigned int)NURON_error_init;
if ( !NURON_error_init )
{
ERR_unload_strings((unsigned int)NURON_lib_error_code, &NURON_str_functs);
ERR_unload_strings((unsigned int)NURON_lib_error_code, &NURON_str_reasons);
result = ERR_unload_strings(0LL, &NURON_lib_name);
NURON_error_init = 1;
}
return result;
}

original_code:
static void ERR_unload_NURON_strings(void)
{
    if (NURON_error_init == 0) {
        ERR_unload_strings(NURON_lib_error_code, NURON_str_functs);
        ERR_unload_strings(NURON_lib_error_code, NURON_str_reasons);
        ERR_unload_strings(0, NURON_lib_name);
        NURON_error_init = 1;
    }
}

canonical_original_code:
static void ERR_unload_NURON_strings()
{
    if (NURON_error_init == 0) {
        ERR_unload_strings(NURON_lib_error_code, NURON_str_functs);
        ERR_unload_strings(NURON_lib_error_code, NURON_str_reasons);
        ERR_unload_strings(0, NURON_lib_name);
        NURON_error_init = 1;
    }
}


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

if ( NURON_lib_error_code )
{
result = (unsigned int)NURON_error_init;
if ( !NURON_error_init )
return result;
LABEL_5:
NURON_error_init = 0;
ERR_load_strings((unsigned int)NURON_lib_error_code, &NURON_str_functs);
ERR_load_strings((unsigned int)NURON_lib_error_code, &NURON_str_reasons);
NURON_lib_name = (unsigned __int64)(unsigned __int8)NURON_lib_error_code << 24;
return ERR_load_strings(0LL, &NURON_lib_name);
}
NURON_lib_error_code = ERR_get_next_error_library();
result = (unsigned int)NURON_error_init;
if ( NURON_error_init )
goto LABEL_5;
return result;
}

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

if ( NURON_lib_error_code )
{
result = (unsigned int)NURON_error_init;
if ( !NURON_error_init )
return result;
LABEL_5:
NURON_error_init = 0;
ERR_load_strings((unsigned int)NURON_lib_error_code, &NURON_str_functs);
ERR_load_strings((unsigned int)NURON_lib_error_code, &NURON_str_reasons);
NURON_lib_name = (unsigned __int64)(unsigned __int8)NURON_lib_error_code << 24;
return ERR_load_strings(0LL, &NURON_lib_name);
}
NURON_lib_error_code = ERR_get_next_error_library();
result = (unsigned int)NURON_error_init;
if ( NURON_error_init )
goto LABEL_5;
return result;
}

original_code:
static void ERR_load_NURON_strings(void)
{
    if (NURON_lib_error_code == 0)
        NURON_lib_error_code = ERR_get_next_error_library();
    if (NURON_error_init) {
        NURON_error_init = 0;
        ERR_load_strings(NURON_lib_error_code, NURON_str_functs);
        ERR_load_strings(NURON_lib_error_code, NURON_str_reasons);
        NURON_lib_name->error = (((((unsigned long)NURON_lib_error_code)&0xffL)*0x1000000)| ((((unsigned long)0)&0xfffL)*0x1000)| ((((unsigned long)0)&0xfffL)));
        ERR_load_strings(0, NURON_lib_name);
    }
}

canonical_original_code:
static void ERR_load_NURON_strings()
{
    if (NURON_lib_error_code == 0)
        NURON_lib_error_code = ERR_get_next_error_library();
    if (NURON_error_init) {
        NURON_error_init = 0;
        ERR_load_strings(NURON_lib_error_code, NURON_str_functs);
        ERR_load_strings(NURON_lib_error_code, NURON_str_reasons);
        NURON_lib_name->error = (((((unsigned long)NURON_lib_error_code)&0xffL)*0x1000000)| ((((unsigned long)0)&0xfffL)*0x1000)| ((((unsigned long)0)&0xfffL)));
        ERR_load_strings(0, NURON_lib_name);
    }
}


decompiled_code:
void __fastcall ssleay_rand_seed(__int64 a1, int a2)
{
ssleay_rand_add(a1, a2, (double)a2);
}

canonical_decompiled_code:
void __fastcall func2(__int64 a1, int a2)
{
func1(a1, a2, (double)a2);
}

original_code:
static void ssleay_rand_seed(const void *buf, int num)
{
    ssleay_rand_add(buf, num, (double)num);
}

canonical_original_code:
static void ssleay_rand_seed(void *buf, int num)
{
    ssleay_rand_add(buf, num, (double)num);
}

variable_types:
buf
void *

variable_types: num int


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

OPENSSL_cleanse(state, 1043LL);
state_num = 0;
state_index = 0;
result = OPENSSL_cleanse(&md, 20LL);
md_count = 0LL;
qword_B38 = 0LL;
entropy = 0LL;
initialized = 0;
return result;
}

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

OPENSSL_cleanse(state, 1043LL);
state_num = 0;
state_index = 0;
result = OPENSSL_cleanse(&md, 20LL);
md_count = 0LL;
qword_B38 = 0LL;
entropy = 0LL;
initialized = 0;
return result;
}

original_code:
static void ssleay_rand_cleanup(void)
{
    OPENSSL_cleanse(state, sizeof(state));
    state_num = 0;
    state_index = 0;
    OPENSSL_cleanse(md, MD_DIGEST_LENGTH);
    md_count[0] = 0;
    md_count[1] = 0;
    entropy = 0;
    initialized = 0;
}

canonical_original_code:
static void ssleay_rand_cleanup()
{
    OPENSSL_cleanse(state, sizeof(state));
    state_num = 0;
    state_index = 0;
    OPENSSL_cleanse(md, MD_DIGEST_LENGTH);
    md_count[0] = 0;
    md_count[1] = 0;
    entropy = 0;
    initialized = 0;
}


decompiled_code:
__int64 __fastcall ssleay_rand_pseudo_bytes(_BYTE *a1, int a2)
{
return ssleay_rand_bytes(a1, a2, 1, 1);
}

canonical_decompiled_code:
__int64 __fastcall func5(_BYTE *a1, int a2)
{
return func4(a1, a2, 1, 1);
}

original_code:
static int ssleay_rand_pseudo_bytes(unsigned char *buf, int num)
{
    return ssleay_rand_bytes(buf, num, 1, 1);
}

variable_types:
buf
unsigned char *

return_type: int


decompiled_code:
__int64 __fastcall ssleay_rand_nopseudo_bytes(_BYTE *a1, int a2)
{
return ssleay_rand_bytes(a1, a2, 0, 1);
}

canonical_decompiled_code:
__int64 __fastcall func6(_BYTE *a1, int a2)
{
return func4(a1, a2, 0, 1);
}

original_code:
static int ssleay_rand_nopseudo_bytes(unsigned char *buf, int num)
{
    return ssleay_rand_bytes(buf, num, 0, 1);
}


decompiled_code:
char *__fastcall EVP_set_pw_prompt(char *src)
{
char *result; // rax

if ( src )
{
result = strncpy(&prompt_string, src, 0x4FuLL);
byte_46F = 0;
}
else
{
prompt_string = 0;
}
return result;
}

canonical_decompiled_code:
char *__fastcall func0(char *src)
{
char *result; // rax

if ( src )
{
result = strncpy(&prompt_string, src, 0x4FuLL);
byte_46F = 0;
}
else
{
prompt_string = 0;
}
return result;
}

original_code:
void EVP_set_pw_prompt(const char *prompt)
{
    if (prompt == NULL)
        prompt_string[0] = '\0';
    else {
        strncpy(prompt_string, prompt, 79);
        prompt_string[79] = '\0';
    }
}

canonical_original_code:
void EVP_set_pw_prompt(char *prompt)
{
    if (prompt == NULL)
        prompt_string[0] = '\0';
    else {
        strncpy(prompt_string, prompt, 79);
        prompt_string[79] = '\0';
    }
}

variable_types:
prompt
char *


decompiled_code:
char *EVP_get_pw_prompt()
{
char *result; // rax

result = &prompt_string;
if ( !prompt_string )
result = 0LL;
return result;
}

canonical_decompiled_code:
char *func1()
{
char *result; // rax

result = &prompt_string;
if ( !prompt_string )
result = 0LL;
return result;
}

original_code:
char *EVP_get_pw_prompt(void)
{
    if (prompt_string[0] == '\0')
        return (NULL);
    else
        return (prompt_string);
}

canonical_original_code:
char *EVP_get_pw_prompt()
{
    if (prompt_string[0] == '\0')
        return (NULL);
    else
        return (prompt_string);
}

return_type: char *


decompiled_code:
__int64 __fastcall EVP_read_pw_string(__int64 a1, int a2, char *a3, int a4)
{
return EVP_read_pw_string_min(a1, 0, a2, a3, a4);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, int a2, char *a3, int a4)
{
return func2(a1, 0, a2, a3, a4);
}

original_code:
int EVP_read_pw_string(char *buf, int len, const char *prompt, int verify)
{
    return EVP_read_pw_string_min(buf, 0, len, prompt, verify);
}

canonical_original_code:
int EVP_read_pw_string(char *buf, int len, char *prompt, int verify)
{
    return EVP_read_pw_string_min(buf, 0, len, prompt, verify);
}

variable_types:
buf
char *

variable_types: len int

variable_types: verify int


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

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

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

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

original_code:
void ERR_load_ENGINE_strings(void)
{
#ifndef OPENSSL_NO_ERR

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

canonical_original_code:
void ERR_load_ENGINE_strings()
{
#ifndef OPENSSL_NO_ERR

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


decompiled_code:
struct tm *__fastcall OPENSSL_gmtime(const time_t *a1, struct tm *a2)
{
gmtime_r(a1, a2);
return a2;
}

canonical_decompiled_code:
struct tm *__fastcall func2(const time_t *a1, struct tm *a2)
{
gmtime_r(a1, a2);
return a2;
}

original_code:
struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result)
{
    struct tm *ts = ((void *)0);
    gmtime_r(timer, result);
    ts = result;
    return ts;
}

canonical_original_code:
struct tm *OPENSSL_gmtime(long *timer, struct tm *result)
{
    struct tm *ts = ((void *)0);
    gmtime_r(timer, result);
    ts = result;
    return ts;
}

variable_types:
timer
long *

variable_types:
result
struct tm *

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


original_code:
int OPENSSL_gmtime_adj(struct tm *tm, int off_day, long offset_sec)
{
    int offset_hms, offset_day;
    long time_jd;
    int time_year, time_month, time_day;
    offset_day = offset_sec / (24 * 60 * 60);
    offset_hms = offset_sec - (offset_day * (24 * 60 * 60));
    offset_day += off_day;
    offset_hms += tm->tm_hour * 3600 + tm->tm_min * 60 + tm->tm_sec;
    if (offset_hms >= (24 * 60 * 60)) {
        offset_day++;
        offset_hms -= (24 * 60 * 60);
    } else if (offset_hms < 0) {
        offset_day--;
        offset_hms += (24 * 60 * 60);
    }
    time_year = tm->tm_year + 1900;
    time_month = tm->tm_mon + 1;
    time_day = tm->tm_mday;
    time_jd = date_to_julian(time_year, time_month, time_day);
    time_jd += offset_day;
    if (time_jd < 0)
        return 0;
    julian_to_date(time_jd, &time_year, &time_month, &time_day);
    if (time_year < 1900 || time_year > 9999)
        return 0;
    tm->tm_year = time_year - 1900;
    tm->tm_mon = time_month - 1;
    tm->tm_mday = time_day;
    tm->tm_hour = offset_hms / 3600;
    tm->tm_min = (offset_hms / 60) % 60;
    tm->tm_sec = offset_hms % 60;
    return 1;
}

canonical_original_code:
int OPENSSL_gmtime_adj(struct tm *tm, int off_day, long offset_sec)
{
    int offset_hms; int offset_day;
    long time_jd;
    int time_year; int time_month; int time_day;
    offset_day = offset_sec / (24 * 60 * 60);
    offset_hms = offset_sec - (offset_day * (24 * 60 * 60));
    offset_day += off_day;
    offset_hms += tm->tm_hour * 3600 + tm->tm_min * 60 + tm->tm_sec;
    if (offset_hms >= (24 * 60 * 60)) {
        offset_day++;
        offset_hms -= (24 * 60 * 60);
    } else if (offset_hms < 0) {
        offset_day--;
        offset_hms += (24 * 60 * 60);
    }
    time_year = tm->tm_year + 1900;
    time_month = tm->tm_mon + 1;
    time_day = tm->tm_mday;
    time_jd = date_to_julian(time_year, time_month, time_day);
    time_jd += offset_day;
    if (time_jd < 0)
        return 0;
    julian_to_date(time_jd, &time_year, &time_month, &time_day);
    if (time_year < 1900 || time_year > 9999)
        return 0;
    tm->tm_year = time_year - 1900;
    tm->tm_mon = time_month - 1;
    tm->tm_mday = time_day;
    tm->tm_hour = offset_hms / 3600;
    tm->tm_min = (offset_hms / 60) % 60;
    tm->tm_sec = offset_hms % 60;
    return 1;
}

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


decompiled_code:
void __fastcall ASN1_STRING_set_default_mask(__int64 a1)
{
global_mask = a1;
}

canonical_decompiled_code:
void __fastcall func5(__int64 a1)
{
global_mask = a1;
}

original_code:
void ASN1_STRING_set_default_mask(unsigned long mask)
{
    global_mask = mask;
}

variable_types:
mask
unsigned long


decompiled_code:
__int64 ASN1_STRING_get_default_mask()
{
return global_mask;
}

canonical_decompiled_code:
__int64 func6()
{
return global_mask;
}

original_code:
unsigned long ASN1_STRING_get_default_mask(void)
{
    return global_mask;
}

canonical_original_code:
unsigned long ASN1_STRING_get_default_mask()
{
    return global_mask;
}

return_type: unsigned long


decompiled_code:
__int64 __fastcall ASN1_STRING_set_default_mask_asc(const char *a1)
{
__int64 v3; // rdi
char *endptr; // [rsp+8h] [rbp-10h] BYREF

if ( !memcmp(a1, "MASK:", 5uLL) )
{
if ( !a1[5] )
return 0LL;
v3 = strtoul(a1 + 5, &endptr, 0);
if ( *endptr )
return 0LL;
}
else if ( !strcmp(a1, "nombstr") )
{
v3 = -10241LL;
}
else if ( !strcmp(a1, "pkix") )
{
v3 = -5LL;
}
else if ( !strcmp(a1, "utf8only") )
{
v3 = 0x2000LL;
}
else
{
v3 = 0xFFFFFFFFLL;
if ( strcmp(a1, "default") )
return 0LL;
}
ASN1_STRING_set_default_mask(v3);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(const char *a1)
{
__int64 v3; // rdi
char *endptr; // [rsp+8h] [rbp-10h] BYREF

if ( !memcmp(a1, "MASK:", 5uLL) )
{
if ( !a1[5] )
return 0LL;
v3 = strtoul(a1 + 5, &endptr, 0);
if ( *endptr )
return 0LL;
}
else if ( !strcmp(a1, "nombstr") )
{
v3 = -10241LL;
}
else if ( !strcmp(a1, "pkix") )
{
v3 = -5LL;
}
else if ( !strcmp(a1, "utf8only") )
{
v3 = 0x2000LL;
}
else
{
v3 = 0xFFFFFFFFLL;
if ( strcmp(a1, "default") )
return 0LL;
}
func5(v3);
return 1LL;
}

original_code:
int ASN1_STRING_set_default_mask_asc(const char *p)
{
    unsigned long mask;
    char *end;
    if (!strncmp(p, "MASK:", 5)) {
        if (!p[5])
            return 0;
        mask = strtoul(p + 5, &end, 0);
        if (*end)
            return 0;
    } else if (!strcmp(p, "nombstr"))
        mask = ~((unsigned long)(B_ASN1_BMPSTRING | B_ASN1_UTF8STRING));
    else if (!strcmp(p, "pkix"))
        mask = ~((unsigned long)B_ASN1_T61STRING);
    else if (!strcmp(p, "utf8only"))
        mask = B_ASN1_UTF8STRING;
    else if (!strcmp(p, "default"))
        mask = 0xFFFFFFFFL;
    else
        return 0;
    ASN1_STRING_set_default_mask(mask);
    return 1;
}

canonical_original_code:
int ASN1_STRING_set_default_mask_asc(char *p)
{
    unsigned long mask;
    char *end;
    if (!strncmp(p, "MASK:", 5)) {
        if (!p[5])
            return 0;
        mask = strtoul(p + 5, &end, 0);
        if (*end)
            return 0;
    } else if (!strcmp(p, "nombstr"))
        mask = ~((unsigned long)(B_ASN1_BMPSTRING | B_ASN1_UTF8STRING));
    else if (!strcmp(p, "pkix"))
        mask = ~((unsigned long)B_ASN1_T61STRING);
    else if (!strcmp(p, "utf8only"))
        mask = B_ASN1_UTF8STRING;
    else if (!strcmp(p, "default"))
        mask = 0xFFFFFFFFL;
    else
        return 0;
    ASN1_STRING_set_default_mask(mask);
    return 1;
}

variable_types:
p
char *

variable_types:
end
char *


decompiled_code:
__int64 __fastcall OBJ_dup(__int64 a1)
{
__int64 v1; // r12
__int64 v3; // rbp
void *v4; // rax
void *v5; // r13
const void *v6; // rsi
int v7; // eax
int v8; // eax
const char *v9; // r14
__int64 v10; // rbx
char *v11; // rax
const char *v12; // rdi
__int64 v13; // rbx
void *v14; // rax

v1 = a1;
if ( !a1 || (*(_BYTE *)(a1 + 32) & 1) == 0 )
return v1;
v3 = ASN1_OBJECT_new();
if ( !v3 )
{
v1 = 0LL;
ERR_put_error(8LL, 101LL, 13LL, "obj_lib.c", 80LL);
return v1;
}
v4 = (void *)CRYPTO_malloc(*(unsigned int *)(a1 + 20), "obj_lib.c", 83LL);
v5 = v4;
if ( !v4 )
{
ERR_put_error(8LL, 101LL, 65LL, "obj_lib.c", 115LL);
goto LABEL_17;
}
v6 = *(const void **)(a1 + 24);
if ( v6 )
memcpy(v4, v6, *(int *)(a1 + 20));
v7 = *(_DWORD *)(a1 + 20);
*(_QWORD *)(v3 + 24) = v5;
*(_DWORD *)(v3 + 20) = v7;
v8 = *(_DWORD *)(a1 + 16);
*(_QWORD *)(v3 + 8) = 0LL;
v9 = *(const char **)(a1 + 8);
*(_DWORD *)(v3 + 16) = v8;
*(_QWORD *)v3 = 0LL;
if ( v9 )
{
v10 = (unsigned int)strlen(v9) + 1;
v11 = (char *)CRYPTO_malloc(v10, "obj_lib.c", 95LL);
v9 = v11;
if ( !v11 )
{
ERR_put_error(8LL, 101LL, 65LL, "obj_lib.c", 115LL);
LABEL_16:
CRYPTO_free(v5);
LABEL_17:
v1 = 0LL;
CRYPTO_free(v3);
return v1;
}
memcpy(v11, *(const void **)(a1 + 8), (int)v10);
*(_QWORD *)(v3 + 8) = v9;
}
v12 = *(const char **)a1;
if ( *(_QWORD *)v1 )
{
v13 = (unsigned int)strlen(v12) + 1;
v14 = (void *)CRYPTO_malloc(v13, "obj_lib.c", 104LL);
if ( v14 )
{
*(_QWORD *)v3 = memcpy(v14, *(const void **)v1, (int)v13);
goto LABEL_14;
}
ERR_put_error(8LL, 101LL, 65LL, "obj_lib.c", 115LL);
if ( v9 )
CRYPTO_free(v9);
goto LABEL_16;
}
LABEL_14:
*(_DWORD *)(v3 + 32) = *(_DWORD *)(v1 + 32) | 0xD;
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
__int64 v1; // r12
__int64 v3; // rbp
void *v4; // rax
void *v5; // r13
const void *v6; // rsi
int v7; // eax
int v8; // eax
const char *v9; // r14
__int64 v10; // rbx
char *v11; // rax
const char *v12; // rdi
__int64 v13; // rbx
void *v14; // rax

v1 = a1;
if ( !a1 || (*(_BYTE *)(a1 + 32) & 1) == 0 )
return v1;
v3 = ASN1_OBJECT_new();
if ( !v3 )
{
v1 = 0LL;
ERR_put_error(8LL, 101LL, 13LL, "obj_lib.c", 80LL);
return v1;
}
v4 = (void *)CRYPTO_malloc(*(unsigned int *)(a1 + 20), "obj_lib.c", 83LL);
v5 = v4;
if ( !v4 )
{
ERR_put_error(8LL, 101LL, 65LL, "obj_lib.c", 115LL);
goto LABEL_17;
}
v6 = *(const void **)(a1 + 24);
if ( v6 )
memcpy(v4, v6, *(int *)(a1 + 20));
v7 = *(_DWORD *)(a1 + 20);
*(_QWORD *)(v3 + 24) = v5;
*(_DWORD *)(v3 + 20) = v7;
v8 = *(_DWORD *)(a1 + 16);
*(_QWORD *)(v3 + 8) = 0LL;
v9 = *(const char **)(a1 + 8);
*(_DWORD *)(v3 + 16) = v8;
*(_QWORD *)v3 = 0LL;
if ( v9 )
{
v10 = (unsigned int)strlen(v9) + 1;
v11 = (char *)CRYPTO_malloc(v10, "obj_lib.c", 95LL);
v9 = v11;
if ( !v11 )
{
ERR_put_error(8LL, 101LL, 65LL, "obj_lib.c", 115LL);
LABEL_16:
CRYPTO_free(v5);
LABEL_17:
v1 = 0LL;
CRYPTO_free(v3);
return v1;
}
memcpy(v11, *(const void **)(a1 + 8), (int)v10);
*(_QWORD *)(v3 + 8) = v9;
}
v12 = *(const char **)a1;
if ( *(_QWORD *)v1 )
{
v13 = (unsigned int)strlen(v12) + 1;
v14 = (void *)CRYPTO_malloc(v13, "obj_lib.c", 104LL);
if ( v14 )
{
*(_QWORD *)v3 = memcpy(v14, *(const void **)v1, (int)v13);
goto LABEL_14;
}
ERR_put_error(8LL, 101LL, 65LL, "obj_lib.c", 115LL);
if ( v9 )
CRYPTO_free(v9);
goto LABEL_16;
}
LABEL_14:
*(_DWORD *)(v3 + 32) = *(_DWORD *)(v1 + 32) | 0xD;
return v3;
}

original_code:
ASN1_OBJECT *OBJ_dup(const ASN1_OBJECT *o)
{
    ASN1_OBJECT *r;
    int i;
    char *ln = ((void *)0), *sn = ((void *)0);
    unsigned char *data = ((void *)0);
    if (o == ((void *)0))
        return (((void *)0));
    if (!(o->flags & 0x01))
        return ((ASN1_OBJECT *)o);
    r = ASN1_OBJECT_new();
    if (r == ((void *)0)) {
        ERR_put_error(8,(101),(13),"obj_lib.c",80);
        return (((void *)0));
    }
    data = CRYPTO_malloc((int)o->length,"obj_lib.c",83);
    if (data == ((void *)0))
        goto err;
    if (o->data != ((void *)0))
        memcpy(data, o->data, o->length);
    r->data = data;
    r->length = o->length;
    r->nid = o->nid;
    r->ln = r->sn = ((void *)0);
    if (o->ln != ((void *)0)) {
        i = strlen(o->ln) + 1;
        ln = CRYPTO_malloc((int)i,"obj_lib.c",95);
        if (ln == ((void *)0))
            goto err;
        memcpy(ln, o->ln, i);
        r->ln = ln;
    }
    if (o->sn != ((void *)0)) {
        i = strlen(o->sn) + 1;
        sn = CRYPTO_malloc((int)i,"obj_lib.c",104);
        if (sn == ((void *)0))
            goto err;
        memcpy(sn, o->sn, i);
        r->sn = sn;
    }
    r->flags = o->flags | (0x01 |
                           0x04 |
                           0x08);
    return (r);
 err:
    ERR_put_error(8,(101),((1|64)),"obj_lib.c",115);
    if (ln != ((void *)0))
        CRYPTO_free(ln);
    if (sn != ((void *)0))
        CRYPTO_free(sn);
    if (data != ((void *)0))
        CRYPTO_free(data);
    if (r != ((void *)0))
        CRYPTO_free(r);
    return (((void *)0));
}

canonical_original_code:
struct asn1_object_st *OBJ_dup(struct asn1_object_st *o)
{
    struct asn1_object_st *r;
    int i;
    char *ln = ((void *)0); char *sn = ((void *)0);
    unsigned char *data = ((void *)0);
    if (o == ((void *)0))
        return (((void *)0));
    if (!(o->flags & 0x01))
        return ((struct asn1_object_st *)o);
    r = ASN1_OBJECT_new();
    if (r == ((void *)0)) {
        ERR_put_error(8,(101),(13),"obj_lib.c",80);
        return (((void *)0));
    }
    data = CRYPTO_malloc((int)o->length,"obj_lib.c",83);
    if (data == ((void *)0))
        goto err;
    if (o->data != ((void *)0))
        memcpy(data, o->data, o->length);
    r->data = data;
    r->length = o->length;
    r->nid = o->nid;
    r->ln = r->sn = ((void *)0);
    if (o->ln != ((void *)0)) {
        i = strlen(o->ln) + 1;
        ln = CRYPTO_malloc((int)i,"obj_lib.c",95);
        if (ln == ((void *)0))
            goto err;
        memcpy(ln, o->ln, i);
        r->ln = ln;
    }
    if (o->sn != ((void *)0)) {
        i = strlen(o->sn) + 1;
        sn = CRYPTO_malloc((int)i,"obj_lib.c",104);
        if (sn == ((void *)0))
            goto err;
        memcpy(sn, o->sn, i);
        r->sn = sn;
    }
    r->flags = o->flags | (0x01 |
                           0x04 |
                           0x08);
    return (r);
 err:
    ERR_put_error(8,(101),((1|64)),"obj_lib.c",115);
    if (ln != ((void *)0))
        CRYPTO_free(ln);
    if (sn != ((void *)0))
        CRYPTO_free(sn);
    if (data != ((void *)0))
        CRYPTO_free(data);
    if (r != ((void *)0))
        CRYPTO_free(r);
    return (((void *)0));
}

variable_types:
o
struct asn1_object_st *

variable_types: struct asn1_object_st { char *sn; int nid; int length; unsigned char *data; int flags; } *

variable_types: i int

variable_types:
ln
char *

variable_types:
sn
char *

variable_types:
data
unsigned char *


decompiled_code:
int __fastcall OBJ_cmp(__int64 a1, __int64 a2)
{
int result; // eax

result = *(_DWORD *)(a1 + 20) - *(_DWORD *)(a2 + 20);
if ( !result )
result = memcmp(*(const void **)(a1 + 24), *(const void **)(a2 + 24), *(int *)(a1 + 20));
return result;
}

canonical_decompiled_code:
int __fastcall func1(__int64 a1, __int64 a2)
{
int result; // eax

result = *(_DWORD *)(a1 + 20) - *(_DWORD *)(a2 + 20);
if ( !result )
result = memcmp(*(const void **)(a1 + 24), *(const void **)(a2 + 24), *(int *)(a1 + 20));
return result;
}

original_code:
int OBJ_cmp(const ASN1_OBJECT *a, const ASN1_OBJECT *b)
{
    int ret;
    ret = (a->length - b->length);
    if (ret)
        return (ret);
    return (memcmp(a->data, b->data, a->length));
}

canonical_original_code:
int OBJ_cmp(struct asn1_object_st *a, struct asn1_object_st *b)
{
    int ret;
    ret = (a->length - b->length);
    if (ret)
        return (ret);
    return (memcmp(a->data, b->data, a->length));
}

variable_types:
b
struct asn1_object_st *

variable_types: ret int

user_defined_types: struct asn1_object_st { char *sn; int nid; int length; unsigned char *data; int flags; }


decompiled_code:
__int64 __fastcall restraint_forkpty(int *a1, char *a2, const struct termios *a3, const struct winsize *a4, void (*a5)(void))
{
unsigned int v7; // er12
__pid_t v8; // eax
unsigned int v9; // er12
__int64 result; // rax
int v11; // edi
int amaster; // [rsp+8h] [rbp-20h] BYREF
int aslave[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v7 = openpty(&amaster, aslave, a2, a3, a4);
if ( v7 == -1 )
return v7;
v8 = fork();
v9 = v8;
if ( v8 == -1 )
{
close(amaster);
close(aslave[0]);
result = 0xFFFFFFFFLL;
}
else
{
if ( !v8 )
{
close(amaster);
if ( a5 )
a5();
v7 = login_tty(aslave[0]);
if ( v7 )
exit(1);
return v7;
}
v11 = aslave[0];
*a1 = amaster;
close(v11);
result = v9;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int *a1, char *a2, const struct termios *a3, const struct winsize *a4, void (*a5)(void))
{
unsigned int v7; // er12
__pid_t v8; // eax
unsigned int v9; // er12
__int64 result; // rax
int v11; // edi
int amaster; // [rsp+8h] [rbp-20h] BYREF
int aslave[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v7 = openpty(&amaster, aslave, a2, a3, a4);
if ( v7 == -1 )
return v7;
v8 = fork();
v9 = v8;
if ( v8 == -1 )
{
close(amaster);
close(aslave[0]);
result = 0xFFFFFFFFLL;
}
else
{
if ( !v8 )
{
close(amaster);
if ( a5 )
a5();
v7 = login_tty(aslave[0]);
if ( v7 )
exit(1);
return v7;
}
v11 = aslave[0];
*a1 = amaster;
close(v11);
result = v9;
}
return result;
}

original_code:
int
restraint_forkpty (int *amaster, char *name, const struct termios *termp,
  const struct winsize *winp, void (*setup)(void))
{
  int master, slave, pid;
  if (openpty (&master, &slave, name, (struct termios*)termp, (struct winsize*)winp) == -1)
    return -1;
  switch (pid = fork ())
    {
    case -1:
      close (master);
      close (slave);
      return -1;
    case 0:
      close (master);
      if(setup != ((void *)0)) {
        setup();
      }
      if (login_tty (slave))
 _exit (1);
      return 0;
    default:
      *amaster = master;
      close (slave);
      return pid;
    }
}

canonical_original_code:
int restraint_forkpty(int *amaster, char *name, struct termios *termp, struct winsize *winp, void (*setup)())
{
  int master; int slave; int pid;
  if (openpty (&master, &slave, name, (struct termios *)termp, (struct winsize *)winp) == -1)
    return -1;
  switch (pid = fork ())
    {
    case -1:
      close (master);
      close (slave);
      return -1;
    case 0:
      close (master);
      if(setup != ((void *)0)) {
        setup();
      }
      if (login_tty (slave))
 _exit (1);
      return 0;
    default:
      *amaster = master;
      close (slave);
      return pid;
    }
}

variable_types:
amaster
int *

variable_types:
name
char *

variable_types: struct termios { unsigned int c_iflag; unsigned int c_oflag; unsigned int c_cflag; unsigned int c_lflag; unsigned char c_line; unsigned char c_cc[32]; unsigned int c_ispeed; unsigned int c_ospeed; } *

variable_types: struct winsize { unsigned short ws_row; unsigned short ws_col; unsigned short ws_xpixel; unsigned short ws_ypixel; } *

variable_types:
setup
void (*)()

variable_types: master int

variable_types: slave int

variable_types: pid int


decompiled_code:
__int64 engine_unregister_all_ECDSA()
{
return engine_table_cleanup(&ecdsa_table);
}

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

original_code:
static void engine_unregister_all_ECDSA(void)
{
    engine_table_cleanup(&ecdsa_table);
}

canonical_original_code:
static void engine_unregister_all_ECDSA()
{
    engine_table_cleanup(&ecdsa_table);
}


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

if ( param_table )
result = sk_pop_free(param_table, X509_VERIFY_PARAM_free);
param_table = 0LL;
return result;
}

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

if ( param_table )
result = sk_pop_free(param_table, X509_VERIFY_PARAM_free);
param_table = 0LL;
return result;
}

original_code:
void X509_VERIFY_PARAM_table_cleanup(void)
{
    if (param_table)
        sk_X509_VERIFY_PARAM_pop_free(param_table, X509_VERIFY_PARAM_free);
    param_table = NULL;
}

canonical_original_code:
void X509_VERIFY_PARAM_table_cleanup()
{
    if (param_table)
        sk_X509_VERIFY_PARAM_pop_free(param_table, X509_VERIFY_PARAM_free);
    param_table = NULL;
}


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

result = (unsigned int)openssl_configured;
if ( !openssl_configured )
{
OPENSSL_load_builtin_modules();
ENGINE_load_builtin_engines();
ERR_clear_error();
result = CONF_modules_load_file(0LL, a1, 48LL);
}
return result;
}

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

result = (unsigned int)openssl_configured;
if ( !openssl_configured )
{
OPENSSL_load_builtin_modules();
ENGINE_load_builtin_engines();
ERR_clear_error();
result = CONF_modules_load_file(0LL, a1, 48LL);
}
return result;
}

original_code:
void OPENSSL_config(const char *config_name)
{
    if (openssl_configured)
        return;

    OPENSSL_load_builtin_modules();
#ifndef OPENSSL_NO_ENGINE
    /* Need to load ENGINEs */
    ENGINE_load_builtin_engines();
#endif
    ERR_clear_error();
    CONF_modules_load_file(NULL, config_name,
                               CONF_MFLAGS_DEFAULT_SECTION |
                               CONF_MFLAGS_IGNORE_MISSING_FILE);
}

canonical_original_code:
void OPENSSL_config(char *config_name)
{
    if (openssl_configured)
        return;

    OPENSSL_load_builtin_modules();
#ifndef OPENSSL_NO_ENGINE
    /* Need to load ENGINEs */
    ENGINE_load_builtin_engines();
#endif
    ERR_clear_error();
    CONF_modules_load_file(NULL, config_name,
                               CONF_MFLAGS_DEFAULT_SECTION |
                               CONF_MFLAGS_IGNORE_MISSING_FILE);
}


decompiled_code:
void OPENSSL_no_config()
{
openssl_configured = 1;
}

canonical_decompiled_code:
void func1()
{
openssl_configured = 1;
}


decompiled_code:
int __fastcall TS_CONF_lookup_fail(const char *a1, const char *a2)
{
return fprintf(stderr, "variable lookup failed for %s::%s\n", a1, a2);
}

canonical_decompiled_code:
int __fastcall func0(const char *a1, const char *a2)
{
return fprintf(stderr, "variable lookup failed for %s::%s\n", a1, a2);
}

original_code:
static void TS_CONF_lookup_fail(const char *name, const char *tag)
{
    fprintf(stderr, "variable lookup failed for %s::%s\n", name, tag);
}

canonical_original_code:
static void TS_CONF_lookup_fail(char *name, char *tag)
{
    fprintf(stderr, "variable lookup failed for %s::%s\n", name, tag);
}

variable_types:
tag
char *


decompiled_code:
int __fastcall TS_CONF_invalid(const char *a1, const char *a2)
{
return fprintf(stderr, "invalid variable value for %s::%s\n", a1, a2);
}

canonical_decompiled_code:
int __fastcall func1(const char *a1, const char *a2)
{
return fprintf(stderr, "invalid variable value for %s::%s\n", a1, a2);
}

original_code:
static void TS_CONF_invalid(const char *name, const char *tag)
{
    fprintf(stderr, "invalid variable value for %s::%s\n", name, tag);
}

canonical_original_code:
static void TS_CONF_invalid(char *name, char *tag)
{
    fprintf(stderr, "invalid variable value for %s::%s\n", name, tag);
}


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

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

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

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

original_code:
void ERR_load_ECDH_strings(void)
{
#ifndef OPENSSL_NO_ERR

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

canonical_original_code:
void ERR_load_ECDH_strings()
{
#ifndef OPENSSL_NO_ERR

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


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

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

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

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

original_code:
void ERR_load_OCSP_strings(void)
{
#ifndef OPENSSL_NO_ERR

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

canonical_original_code:
void ERR_load_OCSP_strings()
{
#ifndef OPENSSL_NO_ERR

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


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

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

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

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

original_code:
void ERR_load_EC_strings(void)
{
#ifndef OPENSSL_NO_ERR

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

canonical_original_code:
void ERR_load_EC_strings()
{
#ifndef OPENSSL_NO_ERR

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


decompiled_code:
__int64 EVP_add_alg_module()
{
return CONF_module_add("alg_section", alg_module_init, 0LL);
}

canonical_decompiled_code:
__int64 func1()
{
return CONF_module_add("alg_section", alg_module_init, 0LL);
}

original_code:
void EVP_add_alg_module(void)
{
    CONF_module_add("alg_section", alg_module_init, 0);
}

canonical_original_code:
void EVP_add_alg_module()
{
    CONF_module_add("alg_section", alg_module_init, 0);
}


original_code:
int MD5_Update(MD5_CTX *c, const void *data_, size_t len)
{
    const unsigned char *data = data_;
    unsigned char *p;
    unsigned int l;
    size_t n;
    if (len == 0)
        return 1;
    l = (c->Nl + (((unsigned int) len) << 3)) & 0xffffffffUL;
    if (l < c->Nl)
        c->Nh++;
    c->Nh += (unsigned int) (len >> 29);
    c->Nl = l;
    n = c->num;
    if (n != 0) {
        p = (unsigned char *)c->data;
        if (len >= 64 || len + n >= 64) {
            memcpy(p + n, data, 64 - n);
            md5_block_asm_data_order(c, p, 1);
            n = 64 - n;
            data += n;
            len -= n;
            c->num = 0;
            memset(p, 0, 64);
        } else {
            memcpy(p + n, data, len);
            c->num += (unsigned int)len;
            return 1;
        }
    }
    n = len / 64;
    if (n > 0) {
        md5_block_asm_data_order(c, data, n);
        n *= 64;
        data += n;
        len -= n;
    }
    if (len != 0) {
        p = (unsigned char *)c->data;
        c->num = (unsigned int)len;
        memcpy(p, data, len);
    }
    return 1;
}

canonical_original_code:
int MD5_Update(struct MD5state_st *c, void *data_, unsigned long len)
{
    unsigned char *data = data_;
    unsigned char *p;
    unsigned int l;
    unsigned long n;
    if (len == 0)
        return 1;
    l = (c->Nl + (((unsigned int) len) << 3)) & 0xffffffffUL;
    if (l < c->Nl)
        c->Nh++;
    c->Nh += (unsigned int) (len >> 29);
    c->Nl = l;
    n = c->num;
    if (n != 0) {
        p = (unsigned char *)c->data;
        if (len >= 64 || len + n >= 64) {
            memcpy(p + n, data, 64 - n);
            md5_block_asm_data_order(c, p, 1);
            n = 64 - n;
            data += n;
            len -= n;
            c->num = 0;
            memset(p, 0, 64);
        } else {
            memcpy(p + n, data, len);
            c->num += (unsigned int)len;
            return 1;
        }
    }
    n = len / 64;
    if (n > 0) {
        md5_block_asm_data_order(c, data, n);
        n *= 64;
        data += n;
        len -= n;
    }
    if (len != 0) {
        p = (unsigned char *)c->data;
        c->num = (unsigned int)len;
        memcpy(p, data, len);
    }
    return 1;
}

variable_types: struct MD5state_st { unsigned int A; unsigned int Nl; unsigned int data[-1]; unsigned int num; } *

variable_types:
len
unsigned long

variable_types:
p
unsigned char *

variable_types:
l
unsigned int

variable_types:
n
unsigned long


decompiled_code:
__int64 __fastcall MD5_Transform(__int64 a1, __int64 a2)
{
return md5_block_asm_data_order(a1, a2, 1LL);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
return md5_block_asm_data_order(a1, a2, 1LL);
}

original_code:
void MD5_Transform(MD5_CTX *c, const unsigned char *data)
{
    md5_block_asm_data_order(c, data, 1);
}

canonical_original_code:
void MD5_Transform(struct MD5state_st *c, unsigned char *data)
{
    md5_block_asm_data_order(c, data, 1);
}

variable_types:
data
unsigned char *

user_defined_types: struct MD5state_st { unsigned int A; unsigned int Nl; unsigned int data[-1]; unsigned int num; }


original_code:
int MD5_Final(unsigned char *md, MD5_CTX *c)
{
    unsigned char *p = (unsigned char *)c->data;
    size_t n = c->num;
    p[n] = 0x80;
    n++;
    if (n > (64 - 8)) {
        memset(p + n, 0, 64 - n);
        n = 0;
        md5_block_asm_data_order(c, p, 1);
    }
    memset(p + n, 0, 64 - 8 - n);
    p += 64 - 8;
    (void)(*((unsigned int *)(p))=(c->Nl), (p)+=4, c->Nl);
    (void)(*((unsigned int *)(p))=(c->Nh), (p)+=4, c->Nh);
    p -= 64;
    md5_block_asm_data_order(c, p, 1);
    c->num = 0;
    memset(p, 0, 64);
    do { unsigned long ll; ll=(c)->A; (void)(*((unsigned int *)((md)))=(ll), ((md))+=4, ll); ll=(c)->B; (void)(*((unsigned int *)((md)))=(ll), ((md))+=4, ll); ll=(c)->C; (void)(*((unsigned int *)((md)))=(ll), ((md))+=4, ll); ll=(c)->D; (void)(*((unsigned int *)((md)))=(ll), ((md))+=4, ll); } while (0);
    return 1;
}

canonical_original_code:
int MD5_Final(unsigned char *md, struct MD5state_st *c)
{
    unsigned char *p = (unsigned char *)c->data;
    unsigned long n = c->num;
    p[n] = 0x80;
    n++;
    if (n > (64 - 8)) {
        memset(p + n, 0, 64 - n);
        n = 0;
        md5_block_asm_data_order(c, p, 1);
    }
    memset(p + n, 0, 64 - 8 - n);
    p += 64 - 8;
    (void)(*((unsigned int *)(p))=(c->Nl), (p)+=4, c->Nl);
    (void)(*((unsigned int *)(p))=(c->Nh), (p)+=4, c->Nh);
    p -= 64;
    md5_block_asm_data_order(c, p, 1);
    c->num = 0;
    memset(p, 0, 64);
    do { unsigned long ll; ll=(c)->A; (void)(*((unsigned int *)((md)))=(ll), ((md))+=4, ll); ll=(c)->B; (void)(*((unsigned int *)((md)))=(ll), ((md))+=4, ll); ll=(c)->C; (void)(*((unsigned int *)((md)))=(ll), ((md))+=4, ll); ll=(c)->D; (void)(*((unsigned int *)((md)))=(ll), ((md))+=4, ll); } while (0);
    return 1;
}

variable_types:
md
unsigned char *

variable_types:
ll
unsigned long


decompiled_code:
__int64 __fastcall MD5_Init(_QWORD *a1)
{
unsigned __int64 v2; // rdi

a1[2] = 0LL;
v2 = (unsigned __int64)(a1 + 3);
*(_QWORD *)(v2 + 60) = 0LL;
memset((void *)(v2 & 0xFFFFFFFFFFFFFFF8LL), 0, 8 * (((unsigned int)a1 - (v2 & 0xFFFFFFF8) + 92) >> 3));
*a1 = 0xEFCDAB8967452301LL;
a1[1] = 0x1032547698BADCFELL;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(_QWORD *a1)
{
unsigned __int64 v2; // rdi

a1[2] = 0LL;
v2 = (unsigned __int64)(a1 + 3);
*(_QWORD *)(v2 + 60) = 0LL;
memset((void *)(v2 & 0xFFFFFFFFFFFFFFF8LL), 0, 8 * (((unsigned int)a1 - (v2 & 0xFFFFFFF8) + 92) >> 3));
*a1 = 0xEFCDAB8967452301LL;
a1[1] = 0x1032547698BADCFELL;
return 1LL;
}

original_code:
int MD5_Init(MD5_CTX *c)
{
    memset(c, 0, sizeof(*c));
    c->A = (unsigned long)0x67452301L;
    c->B = (unsigned long)0xefcdab89L;
    c->C = (unsigned long)0x98badcfeL;
    c->D = (unsigned long)0x10325476L;
    return 1;
}

canonical_original_code:
int MD5_Init(struct MD5state_st *c)
{
    memset(c, 0, sizeof(*c));
    c->A = (unsigned long)0x67452301L;
    c->B = (unsigned long)0xefcdab89L;
    c->C = (unsigned long)0x98badcfeL;
    c->D = (unsigned long)0x10325476L;
    return 1;
}


decompiled_code:
void PKCS12_PBE_add()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
void PKCS12_PBE_add(void)
{
}

canonical_original_code:
void PKCS12_PBE_add()
{
}


decompiled_code:
__int64 __fastcall RSA_padding_add_none(void *a1, int a2, const void *a3, signed int a4)
{
__int64 result; // rax

if ( a4 > a2 )
{
ERR_put_error(4LL, 107LL, 110LL, "rsa_none.c", 69LL);
result = 0LL;
}
else if ( a4 < a2 )
{
ERR_put_error(4LL, 107LL, 122LL, "rsa_none.c", 74LL);
result = 0LL;
}
else
{
memcpy(a1, a3, (unsigned int)a4);
result = 1LL;
}
return result;
}

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

if ( a4 > a2 )
{
ERR_put_error(4LL, 107LL, 110LL, "rsa_none.c", 69LL);
result = 0LL;
}
else if ( a4 < a2 )
{
ERR_put_error(4LL, 107LL, 122LL, "rsa_none.c", 74LL);
result = 0LL;
}
else
{
memcpy(a1, a3, (unsigned int)a4);
result = 1LL;
}
return result;
}

original_code:
int RSA_padding_add_none(unsigned char *to, int tlen,
                         const unsigned char *from, int flen)
{
    if (flen > tlen) {
        RSAerr(RSA_F_RSA_PADDING_ADD_NONE, RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE);
        return (0);
    }

    if (flen < tlen) {
        RSAerr(RSA_F_RSA_PADDING_ADD_NONE, RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE);
        return (0);
    }

    memcpy(to, from, (unsigned int)flen);
    return (1);
}

canonical_original_code:
int RSA_padding_add_none(unsigned char *to, int tlen, unsigned char *from, int flen)
{
    if (flen > tlen) {
        RSAerr(RSA_F_RSA_PADDING_ADD_NONE, RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE);
        return (0);
    }

    if (flen < tlen) {
        RSAerr(RSA_F_RSA_PADDING_ADD_NONE, RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE);
        return (0);
    }

    memcpy(to, from, (unsigned int)flen);
    return (1);
}

variable_types:
to
unsigned char *

variable_types: tlen int

variable_types:
from
unsigned char *

variable_types: flen int


decompiled_code:
__int64 __fastcall RSA_padding_check_none(void *a1, unsigned int a2, const void *a3, int a4)
{
char *v6; // rax
__int64 result; // rax

if ( a4 > (int)a2 )
{
ERR_put_error(4LL, 111LL, 109LL, "rsa_none.c", 87LL);
result = 0xFFFFFFFFLL;
}
else
{
v6 = (char *)memset(a1, 0, (int)(a2 - a4));
memcpy(&v6[(int)a2 - (__int64)a4], a3, a4);
result = a2;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(void *a1, unsigned int a2, const void *a3, int a4)
{
char *v6; // rax
__int64 result; // rax

if ( a4 > (int)a2 )
{
ERR_put_error(4LL, 111LL, 109LL, "rsa_none.c", 87LL);
result = 0xFFFFFFFFLL;
}
else
{
v6 = (char *)memset(a1, 0, (int)(a2 - a4));
memcpy(&v6[(int)a2 - (__int64)a4], a3, a4);
result = a2;
}
return result;
}

original_code:
int RSA_padding_check_none(unsigned char *to, int tlen,
                           const unsigned char *from, int flen, int num)
{

    if (flen > tlen) {
        RSAerr(RSA_F_RSA_PADDING_CHECK_NONE, RSA_R_DATA_TOO_LARGE);
        return (-1);
    }

    memset(to, 0, tlen - flen);
    memcpy(to + tlen - flen, from, flen);
    return (tlen);
}

canonical_original_code:
int RSA_padding_check_none(unsigned char *to, int tlen, unsigned char *from, int flen, int num)
{

    if (flen > tlen) {
        RSAerr(RSA_F_RSA_PADDING_CHECK_NONE, RSA_R_DATA_TOO_LARGE);
        return (-1);
    }

    memset(to, 0, tlen - flen);
    memcpy(to + tlen - flen, from, flen);
    return (tlen);
}

variable_types: num int


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

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

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

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

original_code:
void ERR_load_DH_strings(void)
{
#ifndef OPENSSL_NO_ERR

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

canonical_original_code:
void ERR_load_DH_strings()
{
#ifndef OPENSSL_NO_ERR

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


decompiled_code:
__int64 __fastcall rand_main(__int64 a1, __int64 a2)
{
__int64 v3; // rdi
const char *v4; // rsi
__int64 v5; // rdx
__int64 v6; // rcx
__int64 v7; // r8
const char *v8; // rbp
__int64 v9; // r9
unsigned int v10; // er13
unsigned int v11; // er15
__int64 v12; // r10
__int64 v13; // r8
bool v14; // cf
bool v15; // zf
int v16; // er11
int v17; // er12
__int64 v18; // rdx
const char *v19; // rsi
const char *v20; // rdi
char v21; // al
bool v22; // cf
bool v23; // zf
char v24; // al
__int64 v25; // rdx
unsigned int v26; // er12
__int64 v27; // rdx
__int64 v28; // rcx
__int64 v29; // r8
const char *v31; // rdi
const char *v32; // rsi
char v33; // al
bool v34; // cf
bool v35; // zf
char v36; // al
__int64 v37; // r8
__int64 v38; // rax
__int64 v39; // rax
__int64 v40; // rax
__int64 v41; // rbp
__int64 v42; // rsi
int v43; // eax
__int64 v44; // rdx
__int64 v45; // rcx
__int64 v46; // r8
int v47; // eax
__int64 v48; // rsi
unsigned int v49; // er12
__int64 v50; // rdx
__int64 v51; // rcx
__int64 v52; // r8
char *v53; // rbx
__int64 v54; // rdx
const char *v55; // rdi
const char *v56; // rsi
char v57; // al
bool v58; // cf
bool v59; // zf
const char *v60; // rdi
const char *v61; // rsi
char v62; // al
bool v63; // cf
bool v64; // zf
const char *v65; // rdi
const char *v66; // rsi
const unsigned __int16 **v67; // rax
int v68; // eax
__int64 v69; // rax
__int64 v70; // rax
__int64 v71; // rdi
__int64 v72; // [rsp+8h] [rbp-1060h]
__int64 v73; // [rsp+8h] [rbp-1060h]
__int64 v74; // [rsp+8h] [rbp-1060h]
__int64 v75; // [rsp+10h] [rbp-1058h]
__int64 v76; // [rsp+10h] [rbp-1058h]
__int64 v77; // [rsp+18h] [rbp-1050h]
int v78; // [rsp+2Ch] [rbp-103Ch] BYREF
char v79[4152]; // [rsp+30h] [rbp-1038h] BYREF

v78 = -1;
signal(13, (__sighandler_t)((char *)rand_main + 1));
v3 = bio_err;
if ( !bio_err )
{
v69 = BIO_s_file();
bio_err = BIO_new(v69);
v3 = bio_err;
if ( bio_err )
{
BIO_ctrl(bio_err, 106LL, 16LL, stderr);
v3 = bio_err;
}
}
v4 = 0LL;
if ( !(unsigned int)load_config(v3, 0LL) )
goto LABEL_67;
v8 = *(const char **)(a2 + 8);
v9 = 0LL;
if ( !v8 )
{
v12 = 0LL;
v13 = 0LL;
v36 = 0;
v10 = 0;
v11 = 0;
goto LABEL_25;
}
v10 = 0;
v11 = 0;
v12 = 0LL;
v13 = 0LL;
v14 = 0;
v15 = 1;
v16 = 0;
v17 = 1;
v18 = 1LL;
do
{
while ( 1 )
{
v6 = 5LL;
v19 = v8;
v20 = "-out";
do
{
if ( !v6 )
break;
v14 = *v19 < (unsigned int)*v20;
v15 = *v19++ == *v20++;
--v6;
}
while ( v15 );
v21 = (!v14 && !v15) - v14;
v22 = 0;
v23 = v21 == 0;
if ( !v21 )
{
if ( !*(_QWORD *)(a2 + 8 * v18 + 8) || v13 )
goto LABEL_11;
v16 += 2;
v13 = *(_QWORD *)(a2 + 8LL * v16);
goto LABEL_59;
}
v31 = "-engine";
v6 = 8LL;
v32 = v8;
do
{
if ( !v6 )
break;
v22 = *v32 < (unsigned int)*v31;
v23 = *v32++ == *v31++;
--v6;
}
while ( v23 );
v33 = (!v22 && !v23) - v22;
v34 = 0;
v35 = v33 == 0;
if ( v33 )
break;
if ( !*(_QWORD *)(a2 + 8 * v18 + 8) || v9 )
goto LABEL_11;
v16 += 2;
v17 = v16 + 1;
v18 = v16 + 1;
v9 = *(_QWORD *)(a2 + 8LL * v16);
v8 = *(const char **)(a2 + 8 * v18);
v14 = 0;
v15 = v8 == 0LL;
if ( !v8 )
{
v24 = 0;
v25 = v10 & v11;
goto LABEL_23;
}
}
v55 = "-rand";
v6 = 6LL;
v56 = v8;
do
{
if ( !v6 )
break;
v34 = *v56 < (unsigned int)*v55;
v35 = *v56++ == *v55++;
--v6;
}
while ( v35 );
v57 = (!v34 && !v35) - v34;
v58 = 0;
v59 = v57 == 0;
if ( v57 )
{
v60 = "-base64";
v6 = 8LL;
v61 = v8;
do
{
if ( !v6 )
break;
v58 = *v61 < (unsigned int)*v60;
v59 = *v61++ == *v60++;
--v6;
}
while ( v59 );
v62 = (!v58 && !v59) - v58;
v63 = 0;
v64 = v62 == 0;
if ( v62 )
{
v65 = "-hex";
v6 = 5LL;
v66 = v8;
do
{
if ( !v6 )
break;
v63 = *v66 < (unsigned int)*v65;
v64 = *v66++ == *v65++;
--v6;
}
while ( v64 );
if ( (!v63 && !v64) == v63 )
{
if ( v10 )
{
v25 = v11;
v24 = v10;
goto LABEL_12;
}
v16 = v17;
v10 = 1;
}
else
{
v77 = v9;
v76 = v13;
v74 = v12;
v67 = _ctype_b_loc();
v12 = v74;
v13 = v76;
v9 = v77;
if ( ((*v67)[*(unsigned __int8 *)v8] & 0x800) == 0
|| v78 >= 0
|| (v68 = _isoc99_sscanf(v8, "%d", &v78), v12 = v74, v13 = v76, v9 = v77, !v68)
|| (v6 = (unsigned int)v78, v78 < 0) )
{
LABEL_11:
v24 = 1;
v25 = v10 & v11;
goto LABEL_12;
}
v16 = v17;
}
}
else
{
if ( v11 )
{
v25 = v10;
v24 = v11;
LABEL_12:
if ( (_DWORD)v25 )
goto LABEL_13;
goto LABEL_24;
}
v16 = v17;
v11 = 1;
}
}
else
{
if ( !*(_QWORD *)(a2 + 8 * v18 + 8) || v12 )
goto LABEL_11;
v16 += 2;
v12 = *(_QWORD *)(a2 + 8LL * v16);
}
LABEL_59:
v17 = v16 + 1;
v18 = v16 + 1;
v8 = *(const char **)(a2 + 8 * v18);
v14 = 0;
v15 = v8 == 0LL;
}
while ( v8 );
v24 = 0;
v25 = v10 & v11;
LABEL_23:
if ( (_DWORD)v25 )
goto LABEL_13;
LABEL_24:
v36 = v24 & 1;
LABEL_25:
v25 = (unsigned int)v78;
v75 = v13;
v72 = v12;
if ( v78 < 0 || v36 )
{
LABEL_13:
v26 = 1;
BIO_printf(bio_err, "Usage: rand [options] num\n", v25, v6, v13, v9);
BIO_printf(bio_err, "where options are\n");
BIO_printf(bio_err, "-out file - write to file\n");
BIO_printf(bio_err, "-engine e - use engine e, possibly a hardware device.\n");
BIO_printf(bio_err, "-rand file%cfile%c... - seed PRNG from files\n", 58LL, 58LL);
BIO_printf(bio_err, "-base64 - base64 encode output\n");
BIO_printf(bio_err, "-hex - hex encode output\n");
ERR_print_errors(bio_err, "-hex - hex encode output\n", v27, v28, v29);
return v26;
}
setup_engine(bio_err, v9, 0LL);
v4 = (const char *)bio_err;
app_RAND_load_file(0LL, bio_err, v72 != 0);
v37 = v75;
if ( v72 )
{
v38 = app_RAND_load_files(v72);
v4 = "%ld semi-random bytes loaded\n";
BIO_printf(bio_err, "%ld semi-random bytes loaded\n", v38);
v37 = v75;
}
v73 = v37;
v39 = BIO_s_file();
v40 = BIO_new(v39);
v7 = v73;
v41 = v40;
if ( !v40 )
{
LABEL_67:
v26 = 1;
ERR_print_errors(bio_err, v4, v5, v6, v7);
return v26;
}
if ( v73 )
{
v42 = 108LL;
v43 = BIO_ctrl(v40, 108LL, 5LL, v73);
}
else
{
v42 = 106LL;
v43 = BIO_ctrl(v40, 106LL, 16LL, stdout);
}
if ( v43 <= 0 )
goto LABEL_84;
if ( !v11 )
goto LABEL_34;
v70 = BIO_f_base64();
v71 = BIO_new(v70);
if ( !v71 )
{
LABEL_84:
v26 = 1;
ERR_print_errors(bio_err, v42, v44, v45, v46);
goto LABEL_82;
}
v41 = BIO_push(v71, v41);
LABEL_34:
v47 = v78;
if ( v78 > 0 )
{
while ( 1 )
{
if ( v47 > 4096 )
v47 = 4096;
v48 = (unsigned int)v47;
v49 = v47;
if ( (int)RAND_bytes(v79, (unsigned int)v47) <= 0 )
break;
if ( v10 )
{
v53 = v79;
do
{
v54 = (unsigned __int8)*v53++;
BIO_printf(v41, "%02x", v54);
}
while ( v53 != &v79[v49] );
}
else
{
BIO_write(v41, v79, v49);
}
v47 = v78 - v49;
v78 = v47;
if ( v47 <= 0 )
goto LABEL_78;
}
v26 = 1;
}
else
{
LABEL_78:
if ( v10 )
BIO_puts(v41, "\n");
BIO_ctrl(v41, 11LL, 0LL, 0LL);
v48 = bio_err;
v26 = 0;
app_RAND_write_file(0LL, bio_err);
}
ERR_print_errors(bio_err, v48, v50, v51, v52);
if ( v41 )
LABEL_82:
BIO_free_all(v41);
return v26;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
__int64 v3; // rdi
const char *v4; // rsi
__int64 v5; // rdx
__int64 v6; // rcx
__int64 v7; // r8
const char *v8; // rbp
__int64 v9; // r9
unsigned int v10; // er13
unsigned int v11; // er15
__int64 v12; // r10
__int64 v13; // r8
bool v14; // cf
bool v15; // zf
int v16; // er11
int v17; // er12
__int64 v18; // rdx
const char *v19; // rsi
const char *v20; // rdi
char v21; // al
bool v22; // cf
bool v23; // zf
char v24; // al
__int64 v25; // rdx
unsigned int v26; // er12
__int64 v27; // rdx
__int64 v28; // rcx
__int64 v29; // r8
const char *v31; // rdi
const char *v32; // rsi
char v33; // al
bool v34; // cf
bool v35; // zf
char v36; // al
__int64 v37; // r8
__int64 v38; // rax
__int64 v39; // rax
__int64 v40; // rax
__int64 v41; // rbp
__int64 v42; // rsi
int v43; // eax
__int64 v44; // rdx
__int64 v45; // rcx
__int64 v46; // r8
int v47; // eax
__int64 v48; // rsi
unsigned int v49; // er12
__int64 v50; // rdx
__int64 v51; // rcx
__int64 v52; // r8
char *v53; // rbx
__int64 v54; // rdx
const char *v55; // rdi
const char *v56; // rsi
char v57; // al
bool v58; // cf
bool v59; // zf
const char *v60; // rdi
const char *v61; // rsi
char v62; // al
bool v63; // cf
bool v64; // zf
const char *v65; // rdi
const char *v66; // rsi
const unsigned __int16 **v67; // rax
int v68; // eax
__int64 v69; // rax
__int64 v70; // rax
__int64 v71; // rdi
__int64 v72; // [rsp+8h] [rbp-1060h]
__int64 v73; // [rsp+8h] [rbp-1060h]
__int64 v74; // [rsp+8h] [rbp-1060h]
__int64 v75; // [rsp+10h] [rbp-1058h]
__int64 v76; // [rsp+10h] [rbp-1058h]
__int64 v77; // [rsp+18h] [rbp-1050h]
int v78; // [rsp+2Ch] [rbp-103Ch] BYREF
char v79[4152]; // [rsp+30h] [rbp-1038h] BYREF

v78 = -1;
signal(13, (__sighandler_t)((char *)rand_main + 1));
v3 = bio_err;
if ( !bio_err )
{
v69 = BIO_s_file();
bio_err = BIO_new(v69);
v3 = bio_err;
if ( bio_err )
{
BIO_ctrl(bio_err, 106LL, 16LL, stderr);
v3 = bio_err;
}
}
v4 = 0LL;
if ( !(unsigned int)load_config(v3, 0LL) )
goto LABEL_67;
v8 = *(const char **)(a2 + 8);
v9 = 0LL;
if ( !v8 )
{
v12 = 0LL;
v13 = 0LL;
v36 = 0;
v10 = 0;
v11 = 0;
goto LABEL_25;
}
v10 = 0;
v11 = 0;
v12 = 0LL;
v13 = 0LL;
v14 = 0;
v15 = 1;
v16 = 0;
v17 = 1;
v18 = 1LL;
do
{
while ( 1 )
{
v6 = 5LL;
v19 = v8;
v20 = "-out";
do
{
if ( !v6 )
break;
v14 = *v19 < (unsigned int)*v20;
v15 = *v19++ == *v20++;
--v6;
}
while ( v15 );
v21 = (!v14 && !v15) - v14;
v22 = 0;
v23 = v21 == 0;
if ( !v21 )
{
if ( !*(_QWORD *)(a2 + 8 * v18 + 8) || v13 )
goto LABEL_11;
v16 += 2;
v13 = *(_QWORD *)(a2 + 8LL * v16);
goto LABEL_59;
}
v31 = "-engine";
v6 = 8LL;
v32 = v8;
do
{
if ( !v6 )
break;
v22 = *v32 < (unsigned int)*v31;
v23 = *v32++ == *v31++;
--v6;
}
while ( v23 );
v33 = (!v22 && !v23) - v22;
v34 = 0;
v35 = v33 == 0;
if ( v33 )
break;
if ( !*(_QWORD *)(a2 + 8 * v18 + 8) || v9 )
goto LABEL_11;
v16 += 2;
v17 = v16 + 1;
v18 = v16 + 1;
v9 = *(_QWORD *)(a2 + 8LL * v16);
v8 = *(const char **)(a2 + 8 * v18);
v14 = 0;
v15 = v8 == 0LL;
if ( !v8 )
{
v24 = 0;
v25 = v10 & v11;
goto LABEL_23;
}
}
v55 = "-rand";
v6 = 6LL;
v56 = v8;
do
{
if ( !v6 )
break;
v34 = *v56 < (unsigned int)*v55;
v35 = *v56++ == *v55++;
--v6;
}
while ( v35 );
v57 = (!v34 && !v35) - v34;
v58 = 0;
v59 = v57 == 0;
if ( v57 )
{
v60 = "-base64";
v6 = 8LL;
v61 = v8;
do
{
if ( !v6 )
break;
v58 = *v61 < (unsigned int)*v60;
v59 = *v61++ == *v60++;
--v6;
}
while ( v59 );
v62 = (!v58 && !v59) - v58;
v63 = 0;
v64 = v62 == 0;
if ( v62 )
{
v65 = "-hex";
v6 = 5LL;
v66 = v8;
do
{
if ( !v6 )
break;
v63 = *v66 < (unsigned int)*v65;
v64 = *v66++ == *v65++;
--v6;
}
while ( v64 );
if ( (!v63 && !v64) == v63 )
{
if ( v10 )
{
v25 = v11;
v24 = v10;
goto LABEL_12;
}
v16 = v17;
v10 = 1;
}
else
{
v77 = v9;
v76 = v13;
v74 = v12;
v67 = _ctype_b_loc();
v12 = v74;
v13 = v76;
v9 = v77;
if ( ((*v67)[*(unsigned __int8 *)v8] & 0x800) == 0
|| v78 >= 0
|| (v68 = _isoc99_sscanf(v8, "%d", &v78), v12 = v74, v13 = v76, v9 = v77, !v68)
|| (v6 = (unsigned int)v78, v78 < 0) )
{
LABEL_11:
v24 = 1;
v25 = v10 & v11;
goto LABEL_12;
}
v16 = v17;
}
}
else
{
if ( v11 )
{
v25 = v10;
v24 = v11;
LABEL_12:
if ( (_DWORD)v25 )
goto LABEL_13;
goto LABEL_24;
}
v16 = v17;
v11 = 1;
}
}
else
{
if ( !*(_QWORD *)(a2 + 8 * v18 + 8) || v12 )
goto LABEL_11;
v16 += 2;
v12 = *(_QWORD *)(a2 + 8LL * v16);
}
LABEL_59:
v17 = v16 + 1;
v18 = v16 + 1;
v8 = *(const char **)(a2 + 8 * v18);
v14 = 0;
v15 = v8 == 0LL;
}
while ( v8 );
v24 = 0;
v25 = v10 & v11;
LABEL_23:
if ( (_DWORD)v25 )
goto LABEL_13;
LABEL_24:
v36 = v24 & 1;
LABEL_25:
v25 = (unsigned int)v78;
v75 = v13;
v72 = v12;
if ( v78 < 0 || v36 )
{
LABEL_13:
v26 = 1;
BIO_printf(bio_err, "Usage: rand [options] num\n", v25, v6, v13, v9);
BIO_printf(bio_err, "where options are\n");
BIO_printf(bio_err, "-out file - write to file\n");
BIO_printf(bio_err, "-engine e - use engine e, possibly a hardware device.\n");
BIO_printf(bio_err, "-rand file%cfile%c... - seed PRNG from files\n", 58LL, 58LL);
BIO_printf(bio_err, "-base64 - base64 encode output\n");
BIO_printf(bio_err, "-hex - hex encode output\n");
ERR_print_errors(bio_err, "-hex - hex encode output\n", v27, v28, v29);
return v26;
}
setup_engine(bio_err, v9, 0LL);
v4 = (const char *)bio_err;
app_RAND_load_file(0LL, bio_err, v72 != 0);
v37 = v75;
if ( v72 )
{
v38 = app_RAND_load_files(v72);
v4 = "%ld semi-random bytes loaded\n";
BIO_printf(bio_err, "%ld semi-random bytes loaded\n", v38);
v37 = v75;
}
v73 = v37;
v39 = BIO_s_file();
v40 = BIO_new(v39);
v7 = v73;
v41 = v40;
if ( !v40 )
{
LABEL_67:
v26 = 1;
ERR_print_errors(bio_err, v4, v5, v6, v7);
return v26;
}
if ( v73 )
{
v42 = 108LL;
v43 = BIO_ctrl(v40, 108LL, 5LL, v73);
}
else
{
v42 = 106LL;
v43 = BIO_ctrl(v40, 106LL, 16LL, stdout);
}
if ( v43 <= 0 )
goto LABEL_84;
if ( !v11 )
goto LABEL_34;
v70 = BIO_f_base64();
v71 = BIO_new(v70);
if ( !v71 )
{
LABEL_84:
v26 = 1;
ERR_print_errors(bio_err, v42, v44, v45, v46);
goto LABEL_82;
}
v41 = BIO_push(v71, v41);
LABEL_34:
v47 = v78;
if ( v78 > 0 )
{
while ( 1 )
{
if ( v47 > 4096 )
v47 = 4096;
v48 = (unsigned int)v47;
v49 = v47;
if ( (int)RAND_bytes(v79, (unsigned int)v47) <= 0 )
break;
if ( v10 )
{
v53 = v79;
do
{
v54 = (unsigned __int8)*v53++;
BIO_printf(v41, "%02x", v54);
}
while ( v53 != &v79[v49] );
}
else
{
BIO_write(v41, v79, v49);
}
v47 = v78 - v49;
v78 = v47;
if ( v47 <= 0 )
goto LABEL_78;
}
v26 = 1;
}
else
{
LABEL_78:
if ( v10 )
BIO_puts(v41, "\n");
BIO_ctrl(v41, 11LL, 0LL, 0LL);
v48 = bio_err;
v26 = 0;
app_RAND_write_file(0LL, bio_err);
}
ERR_print_errors(bio_err, v48, v50, v51, v52);
if ( v41 )
LABEL_82:
BIO_free_all(v41);
return v26;
}

original_code:
int rand_main(int argc,char **argv)
{
    int i, r, ret = 1;
    int badopt;
    char *outfile = ((void *)0);
    char *inrand = ((void *)0);
    int base64 = 0;
    int hex = 0;
    BIO *out = ((void *)0);
    int num = -1;
    char *engine = ((void *)0);
    signal(13,((__sighandler_t) 1));
    if (bio_err == ((void *)0))
        if ((bio_err = BIO_new(BIO_s_file())) != ((void *)0))
            BIO_ctrl(bio_err,106,0x00 | 0x10,(char *)stderr);
    if (!load_config(bio_err, ((void *)0)))
        goto err;
    badopt = 0;
    i = 0;
    while (!badopt && argv[++i] != ((void *)0)) {
        if (strcmp(argv[i], "-out") == 0) {
            if ((argv[i + 1] != ((void *)0)) && (outfile == ((void *)0)))
                outfile = argv[++i];
            else
                badopt = 1;
        }
        else if (strcmp(argv[i], "-engine") == 0) {
            if ((argv[i + 1] != ((void *)0)) && (engine == ((void *)0)))
                engine = argv[++i];
            else
                badopt = 1;
        }
        else if (strcmp(argv[i], "-rand") == 0) {
            if ((argv[i + 1] != ((void *)0)) && (inrand == ((void *)0)))
                inrand = argv[++i];
            else
                badopt = 1;
        } else if (strcmp(argv[i], "-base64") == 0) {
            if (!base64)
                base64 = 1;
            else
                badopt = 1;
        } else if (strcmp(argv[i], "-hex") == 0) {
            if (!hex)
                hex = 1;
            else
                badopt = 1;
        } else if (((*__ctype_b_loc ())[(int) (((unsigned char)argv[i][0]))] & (unsigned short int) _ISdigit)) {
            if (num < 0) {
                r = sscanf(argv[i], "%d", &num);
                if (r == 0 || num < 0)
                    badopt = 1;
            } else
                badopt = 1;
        } else
            badopt = 1;
    }
    if (hex && base64)
        badopt = 1;
    if (num < 0)
        badopt = 1;
    if (badopt) {
        BIO_printf(bio_err, "Usage: rand [options] num\n");
        BIO_printf(bio_err, "where options are\n");
        BIO_printf(bio_err, "-out file             - write to file\n");
        BIO_printf(bio_err,
                   "-engine e             - use engine e, possibly a hardware device.\n");
        BIO_printf(bio_err, "-rand file%cfile%c... - seed PRNG from files\n",
                   ':', ':');
        BIO_printf(bio_err, "-base64               - base64 encode output\n");
        BIO_printf(bio_err, "-hex                  - hex encode output\n");
        goto err;
    }
    setup_engine(bio_err, engine, 0);
    app_RAND_load_file(((void *)0), bio_err, (inrand != ((void *)0)));
    if (inrand != ((void *)0))
        BIO_printf(bio_err, "%ld semi-random bytes loaded\n",
                   app_RAND_load_files(inrand));
    out = BIO_new(BIO_s_file());
    if (out == ((void *)0))
        goto err;
    if (outfile != ((void *)0))
        r = BIO_ctrl(out,108, 0x01|0x04,outfile);
    else {
        r = BIO_ctrl(out,106,0x00 | 0x10,(char *)stdout);
    }
    if (r <= 0)
        goto err;
    if (base64) {
        BIO *b64 = BIO_new(BIO_f_base64());
        if (b64 == ((void *)0))
            goto err;
        out = BIO_push(b64, out);
    }
    while (num > 0) {
        unsigned char buf[4096];
        int chunk;
        chunk = num;
        if (chunk > (int)sizeof(buf))
            chunk = sizeof buf;
        r = RAND_bytes(buf, chunk);
        if (r <= 0)
            goto err;
        if (!hex)
            BIO_write(out, buf, chunk);
        else {
            for (i = 0; i < chunk; i++)
                BIO_printf(out, "%02x", buf[i]);
        }
        num -= chunk;
    }
    if (hex)
        BIO_puts(out, "\n");
    (void)(int)BIO_ctrl(out,11,0,((void *)0));
    app_RAND_write_file(((void *)0), bio_err);
    ret = 0;
 err:
    ERR_print_errors(bio_err);
    if (out)
        BIO_free_all(out);
    ;
    return(ret);
}

canonical_original_code:
int rand_main(int argc, char **argv)
{
    int i; int r; int ret = 1;
    int badopt;
    char *outfile = ((void *)0);
    char *inrand = ((void *)0);
    int base64 = 0;
    int hex = 0;
    struct bio_st *out = ((void *)0);
    int num = -1;
    char *engine = ((void *)0);
    signal(13,((void (*)(int)) 1));
    if (bio_err == ((void *)0))
        if ((bio_err = BIO_new(BIO_s_file())) != ((void *)0))
            BIO_ctrl(bio_err,106,0x00 | 0x10,(char *)stderr);
    if (!load_config(bio_err, ((void *)0)))
        goto err;
    badopt = 0;
    i = 0;
    while (!badopt && argv[++i] != ((void *)0)) {
        if (strcmp(argv[i], "-out") == 0) {
            if ((argv[i + 1] != ((void *)0)) && (outfile == ((void *)0)))
                outfile = argv[++i];
            else
                badopt = 1;
        }
        else if (strcmp(argv[i], "-engine") == 0) {
            if ((argv[i + 1] != ((void *)0)) && (engine == ((void *)0)))
                engine = argv[++i];
            else
                badopt = 1;
        }
        else if (strcmp(argv[i], "-rand") == 0) {
            if ((argv[i + 1] != ((void *)0)) && (inrand == ((void *)0)))
                inrand = argv[++i];
            else
                badopt = 1;
        } else if (strcmp(argv[i], "-base64") == 0) {
            if (!base64)
                base64 = 1;
            else
                badopt = 1;
        } else if (strcmp(argv[i], "-hex") == 0) {
            if (!hex)
                hex = 1;
            else
                badopt = 1;
        } else if (((*__ctype_b_loc ())[(int) (((unsigned char)argv[i][0]))] & (unsigned short) _ISdigit)) {
            if (num < 0) {
                r = sscanf(argv[i], "%d", &num);
                if (r == 0 || num < 0)
                    badopt = 1;
            } else
                badopt = 1;
        } else
            badopt = 1;
    }
    if (hex && base64)
        badopt = 1;
    if (num < 0)
        badopt = 1;
    if (badopt) {
        BIO_printf(bio_err, "Usage: rand [options] num\n");
        BIO_printf(bio_err, "where options are\n");
        BIO_printf(bio_err, "-out file             - write to file\n");
        BIO_printf(bio_err,
                   "-engine e             - use engine e, possibly a hardware device.\n");
        BIO_printf(bio_err, "-rand file%cfile%c... - seed PRNG from files\n",
                   ':', ':');
        BIO_printf(bio_err, "-base64               - base64 encode output\n");
        BIO_printf(bio_err, "-hex                  - hex encode output\n");
        goto err;
    }
    setup_engine(bio_err, engine, 0);
    app_RAND_load_file(((void *)0), bio_err, (inrand != ((void *)0)));
    if (inrand != ((void *)0))
        BIO_printf(bio_err, "%ld semi-random bytes loaded\n",
                   app_RAND_load_files(inrand));
    out = BIO_new(BIO_s_file());
    if (out == ((void *)0))
        goto err;
    if (outfile != ((void *)0))
        r = BIO_ctrl(out,108, 0x01|0x04,outfile);
    else {
        r = BIO_ctrl(out,106,0x00 | 0x10,(char *)stdout);
    }
    if (r <= 0)
        goto err;
    if (base64) {
        struct bio_st *b64 = BIO_new(BIO_f_base64());
        if (b64 == ((void *)0))
            goto err;
        out = BIO_push(b64, out);
    }
    while (num > 0) {
        unsigned char buf[4096];
        int chunk;
        chunk = num;
        if (chunk > (int)sizeof(buf))
            chunk = sizeof buf;
        r = RAND_bytes(buf, chunk);
        if (r <= 0)
            goto err;
        if (!hex)
            BIO_write(out, buf, chunk);
        else {
            for (i = 0; i < chunk; i++)
                BIO_printf(out, "%02x", buf[i]);
        }
        num -= chunk;
    }
    if (hex)
        BIO_puts(out, "\n");
    (void)(int)BIO_ctrl(out,11,0,((void *)0));
    app_RAND_write_file(((void *)0), bio_err);
    ret = 0;
 err:
    ERR_print_errors(bio_err);
    if (out)
        BIO_free_all(out);
    ;
    return(ret);
}

variable_types: argc int

variable_types:
argv
char **

variable_types: i int

variable_types: r int

variable_types: ret int

variable_types: badopt int

variable_types:
outfile
char *

variable_types:
inrand
char *

variable_types: hex int

variable_types: struct bio_st { struct bio_method_st { int type; char *name; int (*bwrite)(struct bio_st *, char *, int); int (*bread)(struct bio_st *, char *, int); int (*bputs)(struct bio_st *, char *); int (*bgets)(struct bio_st *, char *, int); long (*ctrl)(struct bio_st *, int, long, void *); int (*create)(struct bio_st *); int (*destroy)(struct bio_st *); long (*callback_ctrl)(struct bio_st *, int, void (*)(struct bio_st *, int, char *, int, long, long)); } *method; long (*callback)(struct bio_st *, int, char *, int, long, long); char *cb_arg; int init; int shutdown; int flags; int retry_reason; int num; void *ptr; struct bio_st *next_bio; struct bio_st *prev_bio; int references; unsigned long num_read; unsigned long num_write; struct crypto_ex_data_st { struct stack_st_void { struct stack_st { int num; char **data; int sorted; int num_alloc; int (*comp)(void *, void *); } stack; } *sk; int dummy; } ex_data; } *

variable_types:
engine
char *

variable_types:
buf
unsigned char [4096]

variable_types: chunk int

user_defined_types: struct bio_st { struct bio_method_st *method; long (*callback)(struct bio_st *, int, char *, int, long, long); char *cb_arg; int init; int shutdown; int flags; int retry_reason; int num; void *ptr; struct bio_st *next_bio; struct bio_st *prev_bio; int references; unsigned long num_read; unsigned long num_write; struct crypto_ex_data_st ex_data; }

user_defined_types: struct crypto_ex_data_st { struct stack_st_void *sk; int dummy; }

user_defined_types: struct stack_st_void { struct stack_st stack; }


decompiled_code:
__int64 engine_unregister_all_pkey_meths()
{
return engine_table_cleanup(&pkey_meth_table);
}

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

original_code:
static void engine_unregister_all_pkey_meths(void)
{
    engine_table_cleanup(&pkey_meth_table);
}

canonical_original_code:
static void engine_unregister_all_pkey_meths()
{
    engine_table_cleanup(&pkey_meth_table);
}


decompiled_code:
__int64 OpenSSL_add_all_digests()
{
__int64 v0; // rax
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rax
__int64 v12; // rax
__int64 v13; // rax

v0 = EVP_md4();
EVP_add_digest(v0);
v1 = EVP_md5();
EVP_add_digest(v1);
OBJ_NAME_add("ssl2-md5", 32769LL, &unk_174);
OBJ_NAME_add("ssl3-md5", 32769LL, &unk_174);
v2 = EVP_sha();
EVP_add_digest(v2);
v3 = EVP_dss();
EVP_add_digest(v3);
v4 = EVP_sha1();
EVP_add_digest(v4);
OBJ_NAME_add("ssl3-sha1", 32769LL, "SHA1");
OBJ_NAME_add("RSA-SHA1-2", 32769LL, "RSA-SHA1");
v5 = EVP_dss1();
EVP_add_digest(v5);
OBJ_NAME_add("DSA-SHA1-old", 32769LL, "DSA-SHA1");
OBJ_NAME_add("DSS1", 32769LL, "DSA-SHA1");
OBJ_NAME_add("dss1", 32769LL, "DSA-SHA1");
v6 = EVP_ecdsa();
EVP_add_digest(v6);
v7 = EVP_mdc2();
EVP_add_digest(v7);
v8 = EVP_ripemd160();
EVP_add_digest(v8);
OBJ_NAME_add("ripemd", 32769LL, "RIPEMD160");
OBJ_NAME_add("rmd160", 32769LL, "RIPEMD160");
v9 = EVP_sha224();
EVP_add_digest(v9);
v10 = EVP_sha256();
EVP_add_digest(v10);
v11 = EVP_sha384();
EVP_add_digest(v11);
v12 = EVP_sha512();
EVP_add_digest(v12);
v13 = EVP_whirlpool();
return EVP_add_digest(v13);
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v0; // rax
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rax
__int64 v12; // rax
__int64 v13; // rax

v0 = EVP_md4();
EVP_add_digest(v0);
v1 = EVP_md5();
EVP_add_digest(v1);
OBJ_NAME_add("ssl2-md5", 32769LL, &unk_174);
OBJ_NAME_add("ssl3-md5", 32769LL, &unk_174);
v2 = EVP_sha();
EVP_add_digest(v2);
v3 = EVP_dss();
EVP_add_digest(v3);
v4 = EVP_sha1();
EVP_add_digest(v4);
OBJ_NAME_add("ssl3-sha1", 32769LL, "SHA1");
OBJ_NAME_add("RSA-SHA1-2", 32769LL, "RSA-SHA1");
v5 = EVP_dss1();
EVP_add_digest(v5);
OBJ_NAME_add("DSA-SHA1-old", 32769LL, "DSA-SHA1");
OBJ_NAME_add("DSS1", 32769LL, "DSA-SHA1");
OBJ_NAME_add("dss1", 32769LL, "DSA-SHA1");
v6 = EVP_ecdsa();
EVP_add_digest(v6);
v7 = EVP_mdc2();
EVP_add_digest(v7);
v8 = EVP_ripemd160();
EVP_add_digest(v8);
OBJ_NAME_add("ripemd", 32769LL, "RIPEMD160");
OBJ_NAME_add("rmd160", 32769LL, "RIPEMD160");
v9 = EVP_sha224();
EVP_add_digest(v9);
v10 = EVP_sha256();
EVP_add_digest(v10);
v11 = EVP_sha384();
EVP_add_digest(v11);
v12 = EVP_sha512();
EVP_add_digest(v12);
v13 = EVP_whirlpool();
return EVP_add_digest(v13);
}

original_code:
void OpenSSL_add_all_digests(void)
{
#ifndef OPENSSL_NO_MD4
    EVP_add_digest(EVP_md4());
#endif
#ifndef OPENSSL_NO_MD5
    EVP_add_digest(EVP_md5());
    EVP_add_digest_alias(SN_md5, "ssl2-md5");
    EVP_add_digest_alias(SN_md5, "ssl3-md5");
#endif
#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA0)
    EVP_add_digest(EVP_sha());
# ifndef OPENSSL_NO_DSA
    EVP_add_digest(EVP_dss());
# endif
#endif
#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA1)
    EVP_add_digest(EVP_sha1());
    EVP_add_digest_alias(SN_sha1, "ssl3-sha1");
    EVP_add_digest_alias(SN_sha1WithRSAEncryption, SN_sha1WithRSA);
# ifndef OPENSSL_NO_DSA
    EVP_add_digest(EVP_dss1());
    EVP_add_digest_alias(SN_dsaWithSHA1, SN_dsaWithSHA1_2);
    EVP_add_digest_alias(SN_dsaWithSHA1, "DSS1");
    EVP_add_digest_alias(SN_dsaWithSHA1, "dss1");
# endif
# ifndef OPENSSL_NO_ECDSA
    EVP_add_digest(EVP_ecdsa());
# endif
#endif
#if !defined(OPENSSL_NO_MDC2) && !defined(OPENSSL_NO_DES)
    EVP_add_digest(EVP_mdc2());
#endif
#ifndef OPENSSL_NO_RIPEMD
    EVP_add_digest(EVP_ripemd160());
    EVP_add_digest_alias(SN_ripemd160, "ripemd");
    EVP_add_digest_alias(SN_ripemd160, "rmd160");
#endif
#ifndef OPENSSL_NO_SHA256
    EVP_add_digest(EVP_sha224());
    EVP_add_digest(EVP_sha256());
#endif
#ifndef OPENSSL_NO_SHA512
    EVP_add_digest(EVP_sha384());
    EVP_add_digest(EVP_sha512());
#endif
#ifndef OPENSSL_NO_WHIRLPOOL
    EVP_add_digest(EVP_whirlpool());
#endif
}

canonical_original_code:
void OpenSSL_add_all_digests()
{
#ifndef OPENSSL_NO_MD4
    EVP_add_digest(EVP_md4());
#endif
#ifndef OPENSSL_NO_MD5
    EVP_add_digest(EVP_md5());
    EVP_add_digest_alias(SN_md5, "ssl2-md5");
    EVP_add_digest_alias(SN_md5, "ssl3-md5");
#endif
#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA0)
    EVP_add_digest(EVP_sha());
# ifndef OPENSSL_NO_DSA
    EVP_add_digest(EVP_dss());
# endif
#endif
#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA1)
    EVP_add_digest(EVP_sha1());
    EVP_add_digest_alias(SN_sha1, "ssl3-sha1");
    EVP_add_digest_alias(SN_sha1WithRSAEncryption, SN_sha1WithRSA);
# ifndef OPENSSL_NO_DSA
    EVP_add_digest(EVP_dss1());
    EVP_add_digest_alias(SN_dsaWithSHA1, SN_dsaWithSHA1_2);
    EVP_add_digest_alias(SN_dsaWithSHA1, "DSS1");
    EVP_add_digest_alias(SN_dsaWithSHA1, "dss1");
# endif
# ifndef OPENSSL_NO_ECDSA
    EVP_add_digest(EVP_ecdsa());
# endif
#endif
#if !defined(OPENSSL_NO_MDC2) && !defined(OPENSSL_NO_DES)
    EVP_add_digest(EVP_mdc2());
#endif
#ifndef OPENSSL_NO_RIPEMD
    EVP_add_digest(EVP_ripemd160());
    EVP_add_digest_alias(SN_ripemd160, "ripemd");
    EVP_add_digest_alias(SN_ripemd160, "rmd160");
#endif
#ifndef OPENSSL_NO_SHA256
    EVP_add_digest(EVP_sha224());
    EVP_add_digest(EVP_sha256());
#endif
#ifndef OPENSSL_NO_SHA512
    EVP_add_digest(EVP_sha384());
    EVP_add_digest(EVP_sha512());
#endif
#ifndef OPENSSL_NO_WHIRLPOOL
    EVP_add_digest(EVP_whirlpool());
#endif
}


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

canonical_decompiled_code:
int __fastcall func1(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; } *


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

result = ssl3_get_cipher();
if ( result )
{
if ( *(_QWORD *)(result + 40) == 4LL )
result = 0LL;
}
return result;
}

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

result = ssl3_get_cipher();
if ( result )
{
if ( *(_QWORD *)(result + 40) == 4LL )
result = 0LL;
}
return result;
}

original_code:
const SSL_CIPHER *dtls1_get_cipher(unsigned int u)
{
    const SSL_CIPHER *ciph = ssl3_get_cipher(u);
    if (ciph != ((void *)0)) {
        if (ciph->algorithm_enc == 0x00000004L)
            return ((void *)0);
    }
    return ciph;
}

canonical_original_code:
struct ssl_cipher_st *dtls1_get_cipher(unsigned int u)
{
    struct ssl_cipher_st *ciph = ssl3_get_cipher(u);
    if (ciph != ((void *)0)) {
        if (ciph->algorithm_enc == 0x00000004L)
            return ((void *)0);
    }
    return ciph;
}

variable_types:
u
unsigned int

variable_types: struct ssl_cipher_st { int valid; char *name; unsigned long id; unsigned long algorithm_mkey; unsigned long algorithm_auth; unsigned long algorithm_enc; unsigned long algorithm_mac; unsigned long algorithm_ssl; unsigned long algo_strength; unsigned long algorithm2; int strength_bits; int alg_bits; } *


decompiled_code:
__int64 dtls1_default_timeout()
{
return 7200LL;
}

canonical_decompiled_code:
__int64 func2()
{
return 7200LL;
}

original_code:
long dtls1_default_timeout(void)
{
    return (60 * 60 * 2);
}

canonical_original_code:
long dtls1_default_timeout()
{
    return (60 * 60 * 2);
}


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

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

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

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

original_code:
void ERR_load_ASN1_strings(void)
{
#ifndef OPENSSL_NO_ERR

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

canonical_original_code:
void ERR_load_ASN1_strings()
{
#ifndef OPENSSL_NO_ERR

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


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

if ( app_methods )
result = (unsigned int)sk_num() + 11;
else
result = 11LL;
return result;
}

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

if ( app_methods )
result = (unsigned int)sk_num() + 11;
else
result = 11LL;
return result;
}

original_code:
int EVP_PKEY_asn1_get_count(void)
{
    int num = sizeof(standard_methods) / sizeof(EVP_PKEY_ASN1_METHOD *);
    if (app_methods)
        num += sk_EVP_PKEY_ASN1_METHOD_num(app_methods);
    return num;
}

canonical_original_code:
int EVP_PKEY_asn1_get_count()
{
    int num = sizeof(standard_methods) / sizeof(EVP_PKEY_ASN1_METHOD *);
    if (app_methods)
        num += sk_EVP_PKEY_ASN1_METHOD_num(app_methods);
    return num;
}

variable_types: num int


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

return_type: unsigned int


decompiled_code:
__int64 __fastcall constant_time_lt(int a1, int a2)
{
return constant_time_msb(a1 ^ (a1 ^ a2 | a2 ^ (unsigned int)(a1 - a2)));
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1, int a2)
{
return func0(a1 ^ (a1 ^ a2 | a2 ^ (unsigned int)(a1 - a2)));
}

original_code:
static inline unsigned int constant_time_lt(unsigned int a, unsigned int b)
{
    return constant_time_msb(a ^ ((a ^ b) | ((a - b) ^ b)));
}

variable_types:
b
unsigned int


decompiled_code:
__int64 __fastcall constant_time_ge(int a1, int a2)
{
return (unsigned int)~constant_time_lt(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1, int a2)
{
return (unsigned int)~func1(a1, a2);
}

original_code:
static inline unsigned int constant_time_ge(unsigned int a, unsigned int b)
{
    return ~constant_time_lt(a, b);
}


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

canonical_decompiled_code:
__int64 __fastcall func3(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 func4(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


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 func5(int a1, int a2, unsigned int a3)
{
return func4(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)));
}

variable_types: a int

variable_types: b int


decompiled_code:
__int64 __fastcall RSA_padding_add_PKCS1_type_1(_WORD *a1, int a2, const void *a3, unsigned int a4)
{
size_t v6; // rbx
_BYTE *v7; // rax
__int64 result; // rax

if ( a2 - 10 <= (int)a4 )
{
ERR_put_error(4LL, 108LL, 110LL, "rsa_pk1.c", 74LL);
result = 0LL;
}
else
{
*a1 = 256;
v6 = (int)(a2 - 3 - a4);
v7 = memset(a1 + 1, 255, v6);
v7[v6] = 0;
memcpy(&v7[v6 + 1], a3, a4);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(_WORD *a1, int a2, const void *a3, unsigned int a4)
{
size_t v6; // rbx
_BYTE *v7; // rax
__int64 result; // rax

if ( a2 - 10 <= (int)a4 )
{
ERR_put_error(4LL, 108LL, 110LL, "rsa_pk1.c", 74LL);
result = 0LL;
}
else
{
*a1 = 256;
v6 = (int)(a2 - 3 - a4);
v7 = memset(a1 + 1, 255, v6);
v7[v6] = 0;
memcpy(&v7[v6 + 1], a3, a4);
result = 1LL;
}
return result;
}

original_code:
int RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen,
                                 const unsigned char *from, int flen)
{
    int j;
    unsigned char *p;

    if (flen > (tlen - RSA_PKCS1_PADDING_SIZE)) {
        RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1,
               RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE);
        return (0);
    }

    p = (unsigned char *)to;

    *(p++) = 0;
    *(p++) = 1;                 /* Private Key BT (Block Type) */

    /* pad out with 0xff data */
    j = tlen - 3 - flen;
    memset(p, 0xff, j);
    p += j;
    *(p++) = '\0';
    memcpy(p, from, (unsigned int)flen);
    return (1);
}

canonical_original_code:
int RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen, unsigned char *from, int flen)
{
    int j;
    unsigned char *p;

    if (flen > (tlen - RSA_PKCS1_PADDING_SIZE)) {
        RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1,
               RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE);
        return (0);
    }

    p = (unsigned char *)to;

    *(p++) = 0;
    *(p++) = 1;                 /* Private Key BT (Block Type) */

    /* pad out with 0xff data */
    j = tlen - 3 - flen;
    memset(p, 0xff, j);
    p += j;
    *(p++) = '\0';
    memcpy(p, from, (unsigned int)flen);
    return (1);
}

variable_types:
to
unsigned char *

variable_types: tlen int

variable_types:
from
unsigned char *

variable_types: flen int

variable_types: j int

variable_types:
p
unsigned char *


decompiled_code:
__int64 __fastcall RSA_padding_check_PKCS1_type_1(void *a1, signed int a2, _BYTE *a3, int a4, int a5)
{
_BYTE *v6; // rsi
int v7; // ecx
int v8; // eax
const void *v9; // rsi
unsigned int v10; // ecx
unsigned int v11; // er12

if ( a4 + 1 != a5 || (v6 = a3 + 1, *a3 != 1) )
{
v11 = -1;
ERR_put_error(4LL, 112LL, 106LL, "rsa_pk1.c", 102LL);
return v11;
}
v7 = a4 - 1;
if ( v7 <= 0 )
{
if ( v7 )
goto LABEL_14;
LABEL_18:
v11 = -1;
ERR_put_error(4LL, 112LL, 113LL, "rsa_pk1.c", 124LL);
return v11;
}
v8 = 0;
while ( *v6 == 0xFF )
{
++v8;
++v6;
if ( v7 == v8 )
goto LABEL_18;
}
if ( *v6 )
{
v11 = -1;
ERR_put_error(4LL, 112LL, 102LL, "rsa_pk1.c", 115LL);
return v11;
}
v9 = v6 + 1;
if ( v8 == v7 )
goto LABEL_18;
if ( v8 <= 7 )
{
LABEL_14:
v11 = -1;
ERR_put_error(4LL, 112LL, 103LL, "rsa_pk1.c", 130LL);
return v11;
}
v10 = v7 - (v8 + 1);
v11 = v10;
if ( (int)v10 > a2 )
{
v11 = -1;
ERR_put_error(4LL, 112LL, 109LL, "rsa_pk1.c", 137LL);
}
else
{
memcpy(a1, v9, v10);
}
return v11;
}

canonical_decompiled_code:
__int64 __fastcall func8(void *a1, signed int a2, _BYTE *a3, int a4, int a5)
{
_BYTE *v6; // rsi
int v7; // ecx
int v8; // eax
const void *v9; // rsi
unsigned int v10; // ecx
unsigned int v11; // er12

if ( a4 + 1 != a5 || (v6 = a3 + 1, *a3 != 1) )
{
v11 = -1;
ERR_put_error(4LL, 112LL, 106LL, "rsa_pk1.c", 102LL);
return v11;
}
v7 = a4 - 1;
if ( v7 <= 0 )
{
if ( v7 )
goto LABEL_14;
LABEL_18:
v11 = -1;
ERR_put_error(4LL, 112LL, 113LL, "rsa_pk1.c", 124LL);
return v11;
}
v8 = 0;
while ( *v6 == 0xFF )
{
++v8;
++v6;
if ( v7 == v8 )
goto LABEL_18;
}
if ( *v6 )
{
v11 = -1;
ERR_put_error(4LL, 112LL, 102LL, "rsa_pk1.c", 115LL);
return v11;
}
v9 = v6 + 1;
if ( v8 == v7 )
goto LABEL_18;
if ( v8 <= 7 )
{
LABEL_14:
v11 = -1;
ERR_put_error(4LL, 112LL, 103LL, "rsa_pk1.c", 130LL);
return v11;
}
v10 = v7 - (v8 + 1);
v11 = v10;
if ( (int)v10 > a2 )
{
v11 = -1;
ERR_put_error(4LL, 112LL, 109LL, "rsa_pk1.c", 137LL);
}
else
{
memcpy(a1, v9, v10);
}
return v11;
}

original_code:
int RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen,
                                   const unsigned char *from, int flen,
                                   int num)
{
    int i, j;
    const unsigned char *p;

    p = from;
    if ((num != (flen + 1)) || (*(p++) != 01)) {
        RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1,
               RSA_R_BLOCK_TYPE_IS_NOT_01);
        return (-1);
    }

    /* scan over padding data */
    j = flen - 1;               /* one for type. */
    for (i = 0; i < j; i++) {
        if (*p != 0xff) {       /* should decrypt to 0xff */
            if (*p == 0) {
                p++;
                break;
            } else {
                RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1,
                       RSA_R_BAD_FIXED_HEADER_DECRYPT);
                return (-1);
            }
        }
        p++;
    }

    if (i == j) {
        RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1,
               RSA_R_NULL_BEFORE_BLOCK_MISSING);
        return (-1);
    }

    if (i < 8) {
        RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1,
               RSA_R_BAD_PAD_BYTE_COUNT);
        return (-1);
    }
    i++;                        /* Skip over the '\0' */
    j -= i;
    if (j > tlen) {
        RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1, RSA_R_DATA_TOO_LARGE);
        return (-1);
    }
    memcpy(to, p, (unsigned int)j);

    return (j);
}

canonical_original_code:
int RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen, unsigned char *from, int flen, int num)
{
    int i; int j;
    unsigned char *p;

    p = from;
    if ((num != (flen + 1)) || (*(p++) != 01)) {
        RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1,
               RSA_R_BLOCK_TYPE_IS_NOT_01);
        return (-1);
    }

    /* scan over padding data */
    j = flen - 1;               /* one for type. */
    for (i = 0; i < j; i++) {
        if (*p != 0xff) {       /* should decrypt to 0xff */
            if (*p == 0) {
                p++;
                break;
            } else {
                RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1,
                       RSA_R_BAD_FIXED_HEADER_DECRYPT);
                return (-1);
            }
        }
        p++;
    }

    if (i == j) {
        RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1,
               RSA_R_NULL_BEFORE_BLOCK_MISSING);
        return (-1);
    }

    if (i < 8) {
        RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1,
               RSA_R_BAD_PAD_BYTE_COUNT);
        return (-1);
    }
    i++;                        /* Skip over the '\0' */
    j -= i;
    if (j > tlen) {
        RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1, RSA_R_DATA_TOO_LARGE);
        return (-1);
    }
    memcpy(to, p, (unsigned int)j);

    return (j);
}

variable_types: i int


decompiled_code:
__int64 __fastcall RSA_padding_add_PKCS1_type_2(_WORD *a1, int a2, const void *a3, unsigned int a4)
{
_BYTE *v4; // rbx
int v5; // ebp
_BYTE *v8; // rbp
__int64 result; // rax

if ( a2 - 10 <= (int)a4 )
{
ERR_put_error(4LL, 109LL, 110LL, "rsa_pk1.c", 152LL);
result = 0LL;
}
else
{
v4 = a1 + 1;
*a1 = 512;
v5 = a2 - 3 - a4;
if ( (int)RAND_bytes(a1 + 1, (unsigned int)v5) <= 0 )
return 0LL;
if ( v5 > 0 )
{
v8 = (char *)a1 + (unsigned int)(v5 + 2);
LABEL_6:
while ( *v4 )
{
if ( v8 == ++v4 )
goto LABEL_8;
}
while ( (int)RAND_bytes(v4, 1LL) > 0 )
{
if ( *v4 )
{
if ( v8 == ++v4 )
goto LABEL_8;
goto LABEL_6;
}
}
return 0LL;
}
v8 = a1 + 1;
LABEL_8:
*v8 = 0;
memcpy(v8 + 1, a3, a4);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(_WORD *a1, int a2, const void *a3, unsigned int a4)
{
_BYTE *v4; // rbx
int v5; // ebp
_BYTE *v8; // rbp
__int64 result; // rax

if ( a2 - 10 <= (int)a4 )
{
ERR_put_error(4LL, 109LL, 110LL, "rsa_pk1.c", 152LL);
result = 0LL;
}
else
{
v4 = a1 + 1;
*a1 = 512;
v5 = a2 - 3 - a4;
if ( (int)RAND_bytes(a1 + 1, (unsigned int)v5) <= 0 )
return 0LL;
if ( v5 > 0 )
{
v8 = (char *)a1 + (unsigned int)(v5 + 2);
LABEL_6:
while ( *v4 )
{
if ( v8 == ++v4 )
goto LABEL_8;
}
while ( (int)RAND_bytes(v4, 1LL) > 0 )
{
if ( *v4 )
{
if ( v8 == ++v4 )
goto LABEL_8;
goto LABEL_6;
}
}
return 0LL;
}
v8 = a1 + 1;
LABEL_8:
*v8 = 0;
memcpy(v8 + 1, a3, a4);
result = 1LL;
}
return result;
}

original_code:
int RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen,
                                 const unsigned char *from, int flen)
{
    int i, j;
    unsigned char *p;

    if (flen > (tlen - 11)) {
        RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_2,
               RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE);
        return (0);
    }

    p = (unsigned char *)to;

    *(p++) = 0;
    *(p++) = 2;                 /* Public Key BT (Block Type) */

    /* pad out with non-zero random data */
    j = tlen - 3 - flen;

    if (RAND_bytes(p, j) <= 0)
        return (0);
    for (i = 0; i < j; i++) {
        if (*p == '\0')
            do {
                if (RAND_bytes(p, 1) <= 0)
                    return (0);
            } while (*p == '\0');
        p++;
    }

    *(p++) = '\0';

    memcpy(p, from, (unsigned int)flen);
    return (1);
}

canonical_original_code:
int RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen, unsigned char *from, int flen)
{
    int i; int j;
    unsigned char *p;

    if (flen > (tlen - 11)) {
        RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_2,
               RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE);
        return (0);
    }

    p = (unsigned char *)to;

    *(p++) = 0;
    *(p++) = 2;                 /* Public Key BT (Block Type) */

    /* pad out with non-zero random data */
    j = tlen - 3 - flen;

    if (RAND_bytes(p, j) <= 0)
        return (0);
    for (i = 0; i < j; i++) {
        if (*p == '\0')
            do {
                if (RAND_bytes(p, 1) <= 0)
                    return (0);
            } while (*p == '\0');
        p++;
    }

    *(p++) = '\0';

    memcpy(p, from, (unsigned int)flen);
    return (1);
}