original_code:
static int def_add_index(EX_CLASS_ITEM *item, long argl, void *argp,
                         CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
                         CRYPTO_EX_free *free_func)
{
    int toret = -1;
    CRYPTO_EX_DATA_FUNCS *a =
        (CRYPTO_EX_DATA_FUNCS *)CRYPTO_malloc((int)sizeof(CRYPTO_EX_DATA_FUNCS),"ex_data.c",354);
    if (!a) {
        ERR_put_error(15,(104),((1|64)),"ex_data.c",356);
        return -1;
    }
    a->argl = argl;
    a->argp = argp;
    a->new_func = new_func;
    a->dup_func = dup_func;
    a->free_func = free_func;
    CRYPTO_lock(1|8,2,"ex_data.c",364);
    while (sk_num(((_STACK*) (1 ? (item->meth) : (struct stack_st_CRYPTO_EX_DATA_FUNCS*)0))) <= item->meth_num) {
        if (!sk_push(((_STACK*) (1 ? (item->meth) : (struct stack_st_CRYPTO_EX_DATA_FUNCS*)0)), ((void*) (1 ? (((void *)0)) : (CRYPTO_EX_DATA_FUNCS*)0)))) {
            ERR_put_error(15,(104),((1|64)),"ex_data.c",367);
            CRYPTO_free(a);
            goto err;
        }
    }
    toret = item->meth_num++;
    (void)sk_set(((_STACK*) (1 ? (item->meth) : (struct stack_st_CRYPTO_EX_DATA_FUNCS*)0)), (toret), ((void*) (1 ? (a) : (CRYPTO_EX_DATA_FUNCS*)0)));
 err:
    CRYPTO_lock(2|8,2,"ex_data.c",375);
    return toret;
}

canonical_original_code:
static int def_add_index(struct st_ex_class_item *item, long argl, void *argp, int (*new_func)(void *parent, void *ptr, struct crypto_ex_data_st *ad, int idx, long argl, void *argp), int (*dup_func)(struct crypto_ex_data_st *to, struct crypto_ex_data_st *from, void *from_d, int idx, long argl, void *argp), void (*free_func)(void *parent, void *ptr, struct crypto_ex_data_st *ad, int idx, long argl, void *argp))
{
    int toret = -1;
    struct crypto_ex_data_func_st *a = (CRYPTO_EX_DATA_FUNCS *)CRYPTO_malloc((int)sizeof(CRYPTO_EX_DATA_FUNCS),"ex_data.c",354);
    if (!a) {
        ERR_put_error(15,(104),((1|64)),"ex_data.c",356);
        return -1;
    }
    a->argl = argl;
    a->argp = argp;
    a->new_func = new_func;
    a->dup_func = dup_func;
    a->free_func = free_func;
    CRYPTO_lock(1|8,2,"ex_data.c",364);
    while (sk_num(((struct stack_st *) (1 ? (item->meth) : (struct stack_st_CRYPTO_EX_DATA_FUNCS *)0))) <= item->meth_num) {
        if (!sk_push(((struct stack_st *) (1 ? (item->meth) : (struct stack_st_CRYPTO_EX_DATA_FUNCS *)0)), ((void *) (1 ? (((void *)0)) : (struct crypto_ex_data_func_st *)0)))) {
            ERR_put_error(15,(104),((1|64)),"ex_data.c",367);
            CRYPTO_free(a);
            goto err;
        }
    }
    toret = item->meth_num++;
    (void)sk_set(((struct stack_st *) (1 ? (item->meth) : (struct stack_st_CRYPTO_EX_DATA_FUNCS *)0)), (toret), ((void *) (1 ? (a) : (struct crypto_ex_data_func_st *)0)));
 err:
    CRYPTO_lock(2|8,2,"ex_data.c",375);
    return toret;
}

variable_types: argl long

variable_types:
argp
void *

variable_types: int (*)(void *parent, void *ptr, struct crypto_ex_data_st { struct stack_st_void { struct stack_st stack; } *sk; int dummy; } *ad, int idx, long argl, void *argp)

variable_types: int (*)(struct crypto_ex_data_st *to, struct crypto_ex_data_st *from, void *from_d, int idx, long argl, void *argp)

variable_types: void (*)(void *parent, void *ptr, struct crypto_ex_data_st *ad, int idx, long argl, void *argp)


decompiled_code:
__int64 __fastcall int_get_new_index(int a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6)
{
__int64 v10; // rax
__int64 result; // rax

v10 = def_get_class(a1);
if ( v10 )
result = def_add_index(v10, a2, a3, a4, a5, a6);
else
result = 0xFFFFFFFFLL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(int a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6)
{
__int64 v10; // rax
__int64 result; // rax

v10 = func4(a1);
if ( v10 )
result = func5(v10, a2, a3, a4, a5, a6);
else
result = 0xFFFFFFFFLL;
return result;
}

original_code:
static int int_get_new_index(int class_index, long argl, void *argp,
                             CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
                             CRYPTO_EX_free *free_func)
{
    EX_CLASS_ITEM *item = def_get_class(class_index);
    if (!item)
        return -1;
    return def_add_index(item, argl, argp, new_func, dup_func, free_func);
}

canonical_original_code:
static int int_get_new_index(int class_index, long argl, void *argp, int (*new_func)(void *parent, void *ptr, struct crypto_ex_data_st *ad, int idx, long argl, void *argp), int (*dup_func)(struct crypto_ex_data_st *to, struct crypto_ex_data_st *from, void *from_d, int idx, long argl, void *argp), void (*free_func)(void *parent, void *ptr, struct crypto_ex_data_st *ad, int idx, long argl, void *argp))
{
    struct st_ex_class_item *item = def_get_class(class_index);
    if (!item)
        return -1;
    return def_add_index(item, argl, argp, new_func, dup_func, free_func);
}

variable_types: int (*)(void *parent, void *ptr, 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; } *ad, int idx, long argl, void *argp)

variable_types: struct st_ex_class_item { int class_index; struct stack_st_CRYPTO_EX_DATA_FUNCS { struct stack_st { int num; char **data; int sorted; int num_alloc; int (*comp)(void *, void *); } stack; } *meth; int meth_num; } *

return_type: int

user_defined_types: struct st_ex_class_item { int class_index; struct stack_st_CRYPTO_EX_DATA_FUNCS *meth; int meth_num; }

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

user_defined_types: struct stack_st_CRYPTO_EX_DATA_FUNCS { struct stack_st stack; }

user_defined_types: struct stack_st_void { struct stack_st stack; }


decompiled_code:
__int64 int_cleanup()
{
__int64 v0; // rdi
__int64 result; // rax

v0 = ex_data;
if ( ex_data )
goto LABEL_2;
result = ex_data_check();
if ( (_DWORD)result )
{
v0 = ex_data;
LABEL_2:
lh_doall(v0, def_cleanup_cb);
result = lh_free(ex_data);
ex_data = 0LL;
impl = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 func7()
{
__int64 v0; // rdi
__int64 result; // rax

v0 = ex_data;
if ( ex_data )
goto LABEL_2;
result = func3();
if ( (_DWORD)result )
{
v0 = ex_data;
LABEL_2:
lh_doall(v0, def_cleanup_cb);
result = lh_free(ex_data);
ex_data = 0LL;
impl = 0LL;
}
return result;
}

original_code:
static void int_cleanup(void)
{
    if(!ex_data && !ex_data_check()) {return;}
        lh_doall(((_LHASH *)((void*) (1 ? ex_data : (struct lhash_st_EX_CLASS_ITEM*)0))), def_cleanup_cb);
    lh_free(((_LHASH *)((void*) (1 ? ex_data : (struct lhash_st_EX_CLASS_ITEM*)0))));
    ex_data = ((void *)0);
    impl = ((void *)0);
}

canonical_original_code:
static void int_cleanup()
{
    if(!ex_data && !ex_data_check()) {return;}
        lh_doall(((struct lhash_st *)((void *) (1 ? ex_data : (struct lhash_st_EX_CLASS_ITEM *)0))), def_cleanup_cb);
    lh_free(((struct lhash_st *)((void *) (1 ? ex_data : (struct lhash_st_EX_CLASS_ITEM *)0))));
    ex_data = ((void *)0);
    impl = ((void *)0);
}

return_type: void

user_defined_types: struct lhash_st { struct lhash_node_st **b; int (*comp)(void *, void *); unsigned long (*hash)(void *); unsigned int num_nodes; unsigned int num_alloc_nodes; unsigned int p; unsigned int pmax; unsigned long up_load; unsigned long down_load; unsigned long num_items; unsigned long num_expands; unsigned long num_expand_reallocs; unsigned long num_contracts; unsigned long num_contract_reallocs; unsigned long num_hash_calls; unsigned long num_comp_calls; unsigned long num_insert; unsigned long num_replace; unsigned long num_delete; unsigned long num_no_delete; unsigned long num_retrieve; unsigned long num_retrieve_miss; unsigned long num_hash_comps; int error; }

user_defined_types: struct lhash_st_EX_CLASS_ITEM { int dummy; }

user_defined_types: struct lhash_node_st { void *data; struct lhash_node_st *next; unsigned long hash; }


decompiled_code:
__int64 __fastcall ex_class_item_LHASH_COMP(int *a1, int *a2)
{
return ex_class_item_cmp_isra_0(*a1, *a2);
}

canonical_decompiled_code:
__int64 __fastcall func10(int *a1, int *a2)
{
return func9(*a1, *a2);
}

original_code: static int ex_class_item_LHASH_COMP(const void *arg1, const void *arg2) { const EX_CLASS_ITEM *a = arg1; const EX_CLASS_ITEM *b = arg2; return ex_class_item_cmp(a,b); }

canonical_original_code: static int ex_class_item_LHASH_COMP(void *arg1, void *arg2) { struct st_ex_class_item *a = arg1; struct st_ex_class_item *b = arg2; return ex_class_item_cmp(a,b); }

user_defined_types: struct stack_st { int num; char **data; int sorted; int num_alloc; int (*comp)(void *, void *); }


decompiled_code:
__int64 __fastcall ex_class_item_LHASH_HASH(int *a1)
{
return ex_class_item_hash_isra_0(*a1);
}

canonical_decompiled_code:
__int64 __fastcall func12(int *a1)
{
return func11(*a1);
}

original_code: static unsigned long ex_class_item_LHASH_HASH(const void *arg) { const EX_CLASS_ITEM *a = arg; return ex_class_item_hash(a); }

canonical_original_code: static unsigned long ex_class_item_LHASH_HASH(void *arg) { struct st_ex_class_item *a = arg; return ex_class_item_hash(a); }

variable_types:
arg
void *

return_type: unsigned long


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

result = impl;
if ( !impl )
{
impl_check();
result = impl;
}
return result;
}

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

result = impl;
if ( !impl )
{
func0();
result = impl;
}
return result;
}

original_code:
const CRYPTO_EX_DATA_IMPL *CRYPTO_get_ex_data_implementation(void)
{
    if(!impl) impl_check(); return impl;
}

canonical_original_code:
struct st_CRYPTO_EX_DATA_IMPL *CRYPTO_get_ex_data_implementation()
{
    if(!impl) impl_check(); return impl;
}

return_type: struct st_CRYPTO_EX_DATA_IMPL { int (*cb_new_class)(); void (*cb_cleanup)(); int (*cb_get_new_index)(int class_index, long argl, void *argp, int (*new_func)(void *parent, void *ptr, 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; } *ad, int idx, long argl, void *argp), int (*dup_func)(struct crypto_ex_data_st *to, struct crypto_ex_data_st *from, void *from_d, int idx, long argl, void *argp), void (*free_func)(void *parent, void *ptr, struct crypto_ex_data_st *ad, int idx, long argl, void *argp)); int (*cb_new_ex_data)(int class_index, void *obj, struct crypto_ex_data_st *ad); int (*cb_dup_ex_data)(int class_index, struct crypto_ex_data_st *to, struct crypto_ex_data_st *from); void (*cb_free_ex_data)(int class_index, void *obj, struct crypto_ex_data_st *ad); } *

user_defined_types: struct st_CRYPTO_EX_DATA_IMPL { int (*cb_new_class)(); void (*cb_cleanup)(); int (*cb_get_new_index)(int class_index, long argl, void *argp, int (*new_func)(void *parent, void *ptr, struct crypto_ex_data_st *ad, int idx, long argl, void *argp), int (*dup_func)(struct crypto_ex_data_st *to, struct crypto_ex_data_st *from, void *from_d, int idx, long argl, void *argp), void (*free_func)(void *parent, void *ptr, struct crypto_ex_data_st *ad, int idx, long argl, void *argp)); int (*cb_new_ex_data)(int class_index, void *obj, struct crypto_ex_data_st *ad); int (*cb_dup_ex_data)(int class_index, struct crypto_ex_data_st *to, struct crypto_ex_data_st *from); void (*cb_free_ex_data)(int class_index, void *obj, struct crypto_ex_data_st *ad); }


decompiled_code:
__int64 __fastcall CRYPTO_set_ex_data_implementation(__int64 a1)
{
unsigned int v1; // er12

v1 = 0;
CRYPTO_lock(9LL, 2LL, "ex_data.c", 222LL);
if ( !impl )
{
impl = a1;
v1 = 1;
}
CRYPTO_lock(10LL, 2LL, "ex_data.c", 227LL);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1)
{
unsigned int v1; // er12

v1 = 0;
CRYPTO_lock(9LL, 2LL, "ex_data.c", 222LL);
if ( !impl )
{
impl = a1;
v1 = 1;
}
CRYPTO_lock(10LL, 2LL, "ex_data.c", 227LL);
return v1;
}

original_code:
int CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i)
{
    int toret = 0;
    CRYPTO_lock(1|8,2,"ex_data.c",222);
    if (!impl) {
        impl = i;
        toret = 1;
    }
    CRYPTO_lock(2|8,2,"ex_data.c",227);
    return toret;
}

canonical_original_code:
int CRYPTO_set_ex_data_implementation(struct st_CRYPTO_EX_DATA_IMPL *i)
{
    int toret = 0;
    CRYPTO_lock(1|8,2,"ex_data.c",222);
    if (!impl) {
        impl = i;
        toret = 1;
    }
    CRYPTO_lock(2|8,2,"ex_data.c",227);
    return toret;
}

variable_types: struct st_CRYPTO_EX_DATA_IMPL { int (*cb_new_class)(); void (*cb_cleanup)(); int (*cb_get_new_index)(int class_index, long argl, void *argp, int (*new_func)(void *parent, void *ptr, 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; } *ad, int idx, long argl, void *argp), int (*dup_func)(struct crypto_ex_data_st *to, struct crypto_ex_data_st *from, void *from_d, int idx, long argl, void *argp), void (*free_func)(void *parent, void *ptr, struct crypto_ex_data_st *ad, int idx, long argl, void *argp)); int (*cb_new_ex_data)(int class_index, void *obj, struct crypto_ex_data_st *ad); int (*cb_dup_ex_data)(int class_index, struct crypto_ex_data_st *to, struct crypto_ex_data_st *from); void (*cb_free_ex_data)(int class_index, void *obj, struct crypto_ex_data_st *ad); } *

variable_types: toret int


decompiled_code:
__int64 CRYPTO_ex_data_new_class()
{
if ( !impl )
impl_check();
return (*(__int64 (**)(void))impl)();
}

original_code:
int CRYPTO_ex_data_new_class(void)
{
    if(!impl) impl_check(); return impl->cb_new_class ();
}

canonical_original_code:
int CRYPTO_ex_data_new_class()
{
    if(!impl) impl_check(); return impl->cb_new_class ();
}


decompiled_code:
__int64 __fastcall CRYPTO_get_ex_new_index(unsigned int a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6)
{
if ( impl )
return (*(__int64 (**)(void))(impl + 16))();
impl_check();
return (*(__int64 (__fastcall **)(_QWORD, __int64, __int64, __int64, __int64, __int64))(impl + 16))(
a1,
a2,
a3,
a4,
a5,
a6);
}

original_code:
int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp,
                            CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
                            CRYPTO_EX_free *free_func)
{
    int ret = -1;
    if(!impl) impl_check();
        ret = impl->cb_get_new_index (class_index,
                                      argl, argp, new_func, dup_func,
                                      free_func);
    return ret;
}

canonical_original_code:
int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp, int (*new_func)(void *parent, void *ptr, struct crypto_ex_data_st *ad, int idx, long argl, void *argp), int (*dup_func)(struct crypto_ex_data_st *to, struct crypto_ex_data_st *from, void *from_d, int idx, long argl, void *argp), void (*free_func)(void *parent, void *ptr, struct crypto_ex_data_st *ad, int idx, long argl, void *argp))
{
    int ret = -1;
    if(!impl) impl_check();
        ret = impl->cb_get_new_index (class_index,
                                      argl, argp, new_func, dup_func,
                                      free_func);
    return ret;
}

variable_types: ret int


decompiled_code:
__int64 __fastcall CRYPTO_new_ex_data(unsigned int a1, __int64 a2, __int64 a3)
{
if ( impl )
return (*(__int64 (**)(void))(impl + 24))();
impl_check();
return (*(__int64 (__fastcall **)(_QWORD, __int64, __int64))(impl + 24))(a1, a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func18(unsigned int a1, __int64 a2, __int64 a3)
{
if ( impl )
return (*(__int64 (**)(void))(impl + 24))();
func0();
return (*(__int64 (__fastcall **)(_QWORD, __int64, __int64))(impl + 24))(a1, a2, a3);
}

original_code:
int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)
{
    if(!impl) impl_check(); return impl->cb_new_ex_data (class_index, obj, ad);
}

canonical_original_code:
int CRYPTO_new_ex_data(int class_index, void *obj, struct crypto_ex_data_st *ad)
{
    if(!impl) impl_check(); return impl->cb_new_ex_data (class_index, obj, ad);
}

variable_types:
obj
void *

variable_types: 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; } *


decompiled_code:
__int64 __fastcall CRYPTO_dup_ex_data(unsigned int a1, __int64 a2, __int64 a3)
{
if ( impl )
return (*(__int64 (**)(void))(impl + 32))();
impl_check();
return (*(__int64 (__fastcall **)(_QWORD, __int64, __int64))(impl + 32))(a1, a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func19(unsigned int a1, __int64 a2, __int64 a3)
{
if ( impl )
return (*(__int64 (**)(void))(impl + 32))();
func0();
return (*(__int64 (__fastcall **)(_QWORD, __int64, __int64))(impl + 32))(a1, a2, a3);
}

original_code:
int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
                       CRYPTO_EX_DATA *from)
{
    if(!impl) impl_check(); return impl->cb_dup_ex_data (class_index, to, from);
}

canonical_original_code:
int CRYPTO_dup_ex_data(int class_index, struct crypto_ex_data_st *to, struct crypto_ex_data_st *from)
{
    if(!impl) impl_check(); return impl->cb_dup_ex_data (class_index, to, from);
}

variable_types:
from
struct crypto_ex_data_st *


decompiled_code:
__int64 __fastcall CRYPTO_free_ex_data(unsigned int a1, __int64 a2, __int64 a3)
{
if ( impl )
return (*(__int64 (**)(void))(impl + 40))();
impl_check();
return (*(__int64 (__fastcall **)(_QWORD, __int64, __int64))(impl + 40))(a1, a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func20(unsigned int a1, __int64 a2, __int64 a3)
{
if ( impl )
return (*(__int64 (**)(void))(impl + 40))();
func0();
return (*(__int64 (__fastcall **)(_QWORD, __int64, __int64))(impl + 40))(a1, a2, a3);
}

original_code:
void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)
{
    if(!impl) impl_check(); impl->cb_free_ex_data (class_index, obj, ad);
}

canonical_original_code:
void CRYPTO_free_ex_data(int class_index, void *obj, struct crypto_ex_data_st *ad)
{
    if(!impl) impl_check(); impl->cb_free_ex_data (class_index, obj, ad);
}


decompiled_code:
__int64 __fastcall CRYPTO_set_ex_data(__int64 *a1, signed int a2, __int64 a3)
{
__int64 v5; // rdi
int v6; // ebx
__int64 result; // rax
__int64 v8; // rax

v5 = *a1;
if ( v5 || (v8 = sk_new_null(0LL), *a1 = v8, (v5 = v8) != 0) )
{
v6 = sk_num(v5);
if ( v6 <= a2 )
{
while ( (unsigned int)sk_push(*a1, 0LL) )
{
if ( a2 < ++v6 )
goto LABEL_7;
}
ERR_put_error(15LL, 102LL, 65LL, "ex_data.c", 623LL);
result = 0LL;
}
else
{
LABEL_7:
sk_set(*a1, (unsigned int)a2, a3);
result = 1LL;
}
}
else
{
ERR_put_error(15LL, 102LL, 65LL, "ex_data.c", 615LL);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func21(__int64 *a1, signed int a2, __int64 a3)
{
__int64 v5; // rdi
int v6; // ebx
__int64 result; // rax
__int64 v8; // rax

v5 = *a1;
if ( v5 || (v8 = sk_new_null(0LL), *a1 = v8, (v5 = v8) != 0) )
{
v6 = sk_num(v5);
if ( v6 <= a2 )
{
while ( (unsigned int)sk_push(*a1, 0LL) )
{
if ( a2 < ++v6 )
goto LABEL_7;
}
ERR_put_error(15LL, 102LL, 65LL, "ex_data.c", 623LL);
result = 0LL;
}
else
{
LABEL_7:
sk_set(*a1, (unsigned int)a2, a3);
result = 1LL;
}
}
else
{
ERR_put_error(15LL, 102LL, 65LL, "ex_data.c", 615LL);
result = 0LL;
}
return result;
}

original_code:
int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val)
{
    int i;
    if (ad->sk == ((void *)0)) {
        if ((ad->sk = ((struct stack_st_void *)sk_new_null())) == ((void *)0)) {
            ERR_put_error(15,(102),((1|64)),"ex_data.c",615);
            return (0);
        }
    }
    i = sk_num(((_STACK*) (1 ? (ad->sk) : (struct stack_st_void*)0)));
    while (i <= idx) {
        if (!sk_push(((_STACK*) (1 ? (ad->sk) : (struct stack_st_void*)0)), ((void*) (1 ? (((void *)0)) : (void*)0)))) {
            ERR_put_error(15,(102),((1|64)),"ex_data.c",623);
            return (0);
        }
        i++;
    }
    sk_set(((_STACK*) (1 ? (ad->sk) : (struct stack_st_void*)0)), (idx), ((void*) (1 ? (val) : (void*)0)));
    return (1);
}

canonical_original_code:
int CRYPTO_set_ex_data(struct crypto_ex_data_st *ad, int idx, void *val)
{
    int i;
    if (ad->sk == ((void *)0)) {
        if ((ad->sk = ((struct stack_st_void *)sk_new_null())) == ((void *)0)) {
            ERR_put_error(15,(102),((1|64)),"ex_data.c",615);
            return (0);
        }
    }
    i = sk_num(((struct stack_st *) (1 ? (ad->sk) : (struct stack_st_void *)0)));
    while (i <= idx) {
        if (!sk_push(((struct stack_st *) (1 ? (ad->sk) : (struct stack_st_void *)0)), ((void *) (1 ? (((void *)0)) : (void *)0)))) {
            ERR_put_error(15,(102),((1|64)),"ex_data.c",623);
            return (0);
        }
        i++;
    }
    sk_set(((struct stack_st *) (1 ? (ad->sk) : (struct stack_st_void *)0)), (idx), ((void *) (1 ? (val) : (void *)0)));
    return (1);
}

variable_types: idx int

variable_types:
val
void *

variable_types: i int


decompiled_code:
__int64 __fastcall CRYPTO_get_ex_data(_QWORD *a1, int a2)
{
__int64 v3; // rdi
__int64 result; // rax

v3 = *a1;
if ( v3 && (int)sk_num(v3) > a2 )
result = sk_value(*a1, (unsigned int)a2);
else
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func22(_QWORD *a1, int a2)
{
__int64 v3; // rdi
__int64 result; // rax

v3 = *a1;
if ( v3 && (int)sk_num(v3) > a2 )
result = sk_value(*a1, (unsigned int)a2);
else
result = 0LL;
return result;
}

original_code:
void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)
{
    if (ad->sk == ((void *)0))
        return (0);
    else if (idx >= sk_num(((_STACK*) (1 ? (ad->sk) : (struct stack_st_void*)0))))
        return (0);
    else
        return (((void *)sk_value(((_STACK*) (1 ? (ad->sk) : (struct stack_st_void*)0)), (idx))));
}

canonical_original_code:
void *CRYPTO_get_ex_data(struct crypto_ex_data_st *ad, int idx)
{
    if (ad->sk == ((void *)0))
        return (0);
    else if (idx >= sk_num(((struct stack_st *) (1 ? (ad->sk) : (struct stack_st_void *)0))))
        return (0);
    else
        return (((void *)sk_value(((struct stack_st *) (1 ? (ad->sk) : (struct stack_st_void *)0)), (idx))));
}

return_type: void *


decompiled_code:
void __fastcall int_free_ex_data(int a1, __int64 a2, _QWORD *a3)
{
__int64 v4; // r15
int v5; // eax
__int64 v6; // rbp
__int64 v7; // r12
__int64 v8; // rbx
__int64 v9; // rbx
__int64 v10; // rax
__int64 v11; // rax

if ( ex_data )
{
v4 = def_get_class(a1);
if ( v4 )
{
CRYPTO_lock(5LL, 2LL, "ex_data.c", 507LL);
v5 = sk_num(*(_QWORD *)(v4 + 8));
v6 = v5;
if ( v5 > 0 )
{
v7 = CRYPTO_malloc((unsigned int)(8 * v5), "ex_data.c", 510LL);
if ( !v7 )
{
CRYPTO_lock(6LL, 2LL, "ex_data.c", 517LL);
ERR_put_error(15LL, 107LL, 65LL, "ex_data.c", 519LL);
return;
}
v8 = 0LL;
do
{
*(_QWORD *)(v7 + 8 * v8) = sk_value(*(_QWORD *)(v4 + 8), (unsigned int)v8);
++v8;
}
while ( v8 != v6 );
v9 = 0LL;
CRYPTO_lock(6LL, 2LL, "ex_data.c", 517LL);
do
{
v10 = *(_QWORD *)(v7 + 8 * v9);
if ( v10 && *(_QWORD *)(v10 + 24) )
{
v11 = CRYPTO_get_ex_data(a3, v9);
(*(void (__fastcall **)(__int64, __int64, _QWORD *, _QWORD, _QWORD, _QWORD))(*(_QWORD *)(v7 + 8 * v9) + 24LL))(
a2,
v11,
a3,
(unsigned int)v9,
**(_QWORD **)(v7 + 8 * v9),
*(_QWORD *)(*(_QWORD *)(v7 + 8 * v9) + 8LL));
}
++v9;
}
while ( v9 != v6 );
CRYPTO_free(v7);
}
else
{
CRYPTO_lock(6LL, 2LL, "ex_data.c", 517LL);
}
if ( *a3 )
{
sk_free();
*a3 = 0LL;
}
}
}
}

original_code:
static void int_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)
{
    int mx, i;
    EX_CLASS_ITEM *item;
    void *ptr;
    CRYPTO_EX_DATA_FUNCS **storage = ((void *)0);
    if (ex_data == ((void *)0))
        return;
    if ((item = def_get_class(class_index)) == ((void *)0))
        return;
    CRYPTO_lock(1|4,2,"ex_data.c",507);
    mx = sk_num(((_STACK*) (1 ? (item->meth) : (struct stack_st_CRYPTO_EX_DATA_FUNCS*)0)));
    if (mx > 0) {
        storage = CRYPTO_malloc((int)mx * sizeof(CRYPTO_EX_DATA_FUNCS *),"ex_data.c",510);
        if (!storage)
            goto skip;
        for (i = 0; i < mx; i++)
            storage[i] = ((CRYPTO_EX_DATA_FUNCS *)sk_value(((_STACK*) (1 ? (item->meth) : (struct stack_st_CRYPTO_EX_DATA_FUNCS*)0)), (i)));
    }
 skip:
    CRYPTO_lock(2|4,2,"ex_data.c",517);
    if ((mx > 0) && !storage) {
        ERR_put_error(15,(107),((1|64)),"ex_data.c",519);
        return;
    }
    for (i = 0; i < mx; i++) {
        if (storage[i] && storage[i]->free_func) {
            ptr = CRYPTO_get_ex_data(ad, i);
            storage[i]->free_func(obj, ptr, ad, i,
                                  storage[i]->argl, storage[i]->argp);
        }
    }
    if (storage)
        CRYPTO_free(storage);
    if (ad->sk) {
        sk_free(((_STACK*) (1 ? (ad->sk) : (struct stack_st_void*)0)));
        ad->sk = ((void *)0);
    }
}

canonical_original_code:
static void int_free_ex_data(int class_index, void *obj, struct crypto_ex_data_st *ad)
{
    int mx; int i;
    struct st_ex_class_item *item;
    void *ptr;
    struct crypto_ex_data_func_st **storage = ((void *)0);
    if (ex_data == ((void *)0))
        return;
    if ((item = def_get_class(class_index)) == ((void *)0))
        return;
    CRYPTO_lock(1|4,2,"ex_data.c",507);
    mx = sk_num(((struct stack_st *) (1 ? (item->meth) : (struct stack_st_CRYPTO_EX_DATA_FUNCS *)0)));
    if (mx > 0) {
        storage = CRYPTO_malloc((int)mx * sizeof(struct crypto_ex_data_func_st *),"ex_data.c",510);
        if (!storage)
            goto skip;
        for (i = 0; i < mx; i++)
            storage[i] = ((struct crypto_ex_data_func_st *)sk_value(((struct stack_st *) (1 ? (item->meth) : (struct stack_st_CRYPTO_EX_DATA_FUNCS *)0)), (i)));
    }
 skip:
    CRYPTO_lock(2|4,2,"ex_data.c",517);
    if ((mx > 0) && !storage) {
        ERR_put_error(15,(107),((1|64)),"ex_data.c",519);
        return;
    }
    for (i = 0; i < mx; i++) {
        if (storage[i] && storage[i]->free_func) {
            ptr = CRYPTO_get_ex_data(ad, i);
            storage[i]->free_func(obj, ptr, ad, i,
                                  storage[i]->argl, storage[i]->argp);
        }
    }
    if (storage)
        CRYPTO_free(storage);
    if (ad->sk) {
        sk_free(((struct stack_st *) (1 ? (ad->sk) : (struct stack_st_void *)0)));
        ad->sk = ((void *)0);
    }
}

variable_types: mx int

variable_types:
ptr
void *

variable_types: struct crypto_ex_data_func_st { long argl; void *argp; int (*new_func)(void *parent, void *ptr, 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; } *ad, int idx, long argl, void *argp); void (*free_func)(void *parent, void *ptr, struct crypto_ex_data_st *ad, int idx, long argl, void *argp); int (*dup_func)(struct crypto_ex_data_st *to, struct crypto_ex_data_st *from, void *from_d, int idx, long argl, void *argp); } **

user_defined_types: struct crypto_ex_data_func_st { long argl; void *argp; int (*new_func)(void *parent, void *ptr, struct crypto_ex_data_st *ad, int idx, long argl, void *argp); void (*free_func)(void *parent, void *ptr, struct crypto_ex_data_st *ad, int idx, long argl, void *argp); int (*dup_func)(struct crypto_ex_data_st *to, struct crypto_ex_data_st *from, void *from_d, int idx, long argl, void *argp); }


decompiled_code:
__int64 __fastcall int_dup_ex_data(int a1, __int64 *a2, _QWORD *a3)
{
unsigned int v3; // er12
__int64 v6; // r14
int v7; // ebx
int v8; // eax
__int64 v10; // r15
__int64 v11; // r12
__int64 i; // rbx
__int64 v13; // rbx
__int64 v14; // rdx
_QWORD *v15; // rax
void (__fastcall *v16)(__int64 *, _QWORD *, __int64 *, _QWORD, _QWORD, _QWORD); // r10
signed int v17; // esi
__int64 v18[8]; // [rsp+8h] [rbp-40h] BYREF

v3 = 1;
if ( *a3 )
{
v3 = 0;
v6 = def_get_class(a1);
if ( v6 )
{
CRYPTO_lock(5LL, 2LL, "ex_data.c", 466LL);
v7 = sk_num(*(_QWORD *)(v6 + 8));
v8 = sk_num(*a3);
if ( v7 > v8 )
v7 = v8;
if ( v7 > 0 )
{
v10 = CRYPTO_malloc((unsigned int)(8 * v7), "ex_data.c", 472LL);
if ( v10 )
{
v11 = v7;
for ( i = 0LL; i != v11; ++i )
*(_QWORD *)(v10 + 8 * i) = sk_value(*(_QWORD *)(v6 + 8), (unsigned int)i);
v13 = 0LL;
CRYPTO_lock(6LL, 2LL, "ex_data.c", 479LL);
do
{
v18[0] = CRYPTO_get_ex_data(a3, v13);
v14 = v18[0];
v15 = *(_QWORD **)(v10 + 8 * v13);
if ( v15 )
{
v16 = (void (__fastcall *)(__int64 *, _QWORD *, __int64 *, _QWORD, _QWORD, _QWORD))v15[4];
if ( v16 )
{
v16(a2, a3, v18, (unsigned int)v13, *v15, v15[1]);
v14 = v18[0];
}
}
v17 = v13++;
CRYPTO_set_ex_data(a2, v17, v14);
}
while ( v13 != v11 );
v3 = 1;
CRYPTO_free(v10);
}
else
{
CRYPTO_lock(6LL, 2LL, "ex_data.c", 479LL);
ERR_put_error(15LL, 106LL, 65LL, "ex_data.c", 481LL);
}
}
else
{
CRYPTO_lock(6LL, 2LL, "ex_data.c", 479LL);
v3 = 1;
}
}
}
return v3;
}

original_code:
static int int_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
                           CRYPTO_EX_DATA *from)
{
    int mx, j, i;
    char *ptr;
    CRYPTO_EX_DATA_FUNCS **storage = ((void *)0);
    EX_CLASS_ITEM *item;
    if (!from->sk)
        return 1;
    if ((item = def_get_class(class_index)) == ((void *)0))
        return 0;
    CRYPTO_lock(1|4,2,"ex_data.c",466);
    mx = sk_num(((_STACK*) (1 ? (item->meth) : (struct stack_st_CRYPTO_EX_DATA_FUNCS*)0)));
    j = sk_num(((_STACK*) (1 ? (from->sk) : (struct stack_st_void*)0)));
    if (j < mx)
        mx = j;
    if (mx > 0) {
        storage = CRYPTO_malloc((int)mx * sizeof(CRYPTO_EX_DATA_FUNCS *),"ex_data.c",472);
        if (!storage)
            goto skip;
        for (i = 0; i < mx; i++)
            storage[i] = ((CRYPTO_EX_DATA_FUNCS *)sk_value(((_STACK*) (1 ? (item->meth) : (struct stack_st_CRYPTO_EX_DATA_FUNCS*)0)), (i)));
    }
 skip:
    CRYPTO_lock(2|4,2,"ex_data.c",479);
    if ((mx > 0) && !storage) {
        ERR_put_error(15,(106),((1|64)),"ex_data.c",481);
        return 0;
    }
    for (i = 0; i < mx; i++) {
        ptr = CRYPTO_get_ex_data(from, i);
        if (storage[i] && storage[i]->dup_func)
            storage[i]->dup_func(to, from, &ptr, i,
                                 storage[i]->argl, storage[i]->argp);
        CRYPTO_set_ex_data(to, i, ptr);
    }
    if (storage)
        CRYPTO_free(storage);
    return 1;
}

canonical_original_code:
static int int_dup_ex_data(int class_index, struct crypto_ex_data_st *to, struct crypto_ex_data_st *from)
{
    int mx; int j; int i;
    char *ptr;
    struct crypto_ex_data_func_st **storage = ((void *)0);
    struct st_ex_class_item *item;
    if (!from->sk)
        return 1;
    if ((item = def_get_class(class_index)) == ((void *)0))
        return 0;
    CRYPTO_lock(1|4,2,"ex_data.c",466);
    mx = sk_num(((struct stack_st *) (1 ? (item->meth) : (struct stack_st_CRYPTO_EX_DATA_FUNCS *)0)));
    j = sk_num(((struct stack_st *) (1 ? (from->sk) : (struct stack_st_void *)0)));
    if (j < mx)
        mx = j;
    if (mx > 0) {
        storage = CRYPTO_malloc((int)mx * sizeof(struct crypto_ex_data_func_st *),"ex_data.c",472);
        if (!storage)
            goto skip;
        for (i = 0; i < mx; i++)
            storage[i] = ((struct crypto_ex_data_func_st *)sk_value(((struct stack_st *) (1 ? (item->meth) : (struct stack_st_CRYPTO_EX_DATA_FUNCS *)0)), (i)));
    }
 skip:
    CRYPTO_lock(2|4,2,"ex_data.c",479);
    if ((mx > 0) && !storage) {
        ERR_put_error(15,(106),((1|64)),"ex_data.c",481);
        return 0;
    }
    for (i = 0; i < mx; i++) {
        ptr = CRYPTO_get_ex_data(from, i);
        if (storage[i] && storage[i]->dup_func)
            storage[i]->dup_func(to, from, &ptr, i,
                                 storage[i]->argl, storage[i]->argp);
        CRYPTO_set_ex_data(to, i, ptr);
    }
    if (storage)
        CRYPTO_free(storage);
    return 1;
}

variable_types: j int

variable_types:
ptr
char *


original_code:
static int int_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)
{
    int mx, i;
    void *ptr;
    CRYPTO_EX_DATA_FUNCS **storage = ((void *)0);
    EX_CLASS_ITEM *item = def_get_class(class_index);
    if (!item)
        return 0;
    ad->sk = ((void *)0);
    CRYPTO_lock(1|4,2,"ex_data.c",426);
    mx = sk_num(((_STACK*) (1 ? (item->meth) : (struct stack_st_CRYPTO_EX_DATA_FUNCS*)0)));
    if (mx > 0) {
        storage = CRYPTO_malloc((int)mx * sizeof(CRYPTO_EX_DATA_FUNCS *),"ex_data.c",429);
        if (!storage)
            goto skip;
        for (i = 0; i < mx; i++)
            storage[i] = ((CRYPTO_EX_DATA_FUNCS *)sk_value(((_STACK*) (1 ? (item->meth) : (struct stack_st_CRYPTO_EX_DATA_FUNCS*)0)), (i)));
    }
 skip:
    CRYPTO_lock(2|4,2,"ex_data.c",436);
    if ((mx > 0) && !storage) {
        ERR_put_error(15,(108),((1|64)),"ex_data.c",438);
        return 0;
    }
    for (i = 0; i < mx; i++) {
        if (storage[i] && storage[i]->new_func) {
            ptr = CRYPTO_get_ex_data(ad, i);
            storage[i]->new_func(obj, ptr, ad, i,
                                 storage[i]->argl, storage[i]->argp);
        }
    }
    if (storage)
        CRYPTO_free(storage);
    return 1;
}

canonical_original_code:
static int int_new_ex_data(int class_index, void *obj, struct crypto_ex_data_st *ad)
{
    int mx; int i;
    void *ptr;
    struct crypto_ex_data_func_st **storage = ((void *)0);
    struct st_ex_class_item *item = def_get_class(class_index);
    if (!item)
        return 0;
    ad->sk = ((void *)0);
    CRYPTO_lock(1|4,2,"ex_data.c",426);
    mx = sk_num(((struct stack_st *) (1 ? (item->meth) : (struct stack_st_CRYPTO_EX_DATA_FUNCS *)0)));
    if (mx > 0) {
        storage = CRYPTO_malloc((int)mx * sizeof(struct crypto_ex_data_func_st *),"ex_data.c",429);
        if (!storage)
            goto skip;
        for (i = 0; i < mx; i++)
            storage[i] = ((struct crypto_ex_data_func_st *)sk_value(((struct stack_st *) (1 ? (item->meth) : (struct stack_st_CRYPTO_EX_DATA_FUNCS *)0)), (i)));
    }
 skip:
    CRYPTO_lock(2|4,2,"ex_data.c",436);
    if ((mx > 0) && !storage) {
        ERR_put_error(15,(108),((1|64)),"ex_data.c",438);
        return 0;
    }
    for (i = 0; i < mx; i++) {
        if (storage[i] && storage[i]->new_func) {
            ptr = CRYPTO_get_ex_data(ad, i);
            storage[i]->new_func(obj, ptr, ad, i,
                                 storage[i]->argl, storage[i]->argp);
        }
    }
    if (storage)
        CRYPTO_free(storage);
    return 1;
}


decompiled_code:
__int64 impl_check()
{
CRYPTO_lock(9LL, 2LL, "ex_data.c", 201LL);
if ( !impl )
impl = (__int64)&impl_default;
return CRYPTO_lock(10LL, 2LL, "ex_data.c", 204LL);
}

canonical_decompiled_code:
__int64 func0()
{
CRYPTO_lock(9LL, 2LL, "ex_data.c", 201LL);
if ( !impl )
impl = (__int64)&impl_default;
return CRYPTO_lock(10LL, 2LL, "ex_data.c", 204LL);
}

original_code:
static void impl_check(void)
{
    CRYPTO_lock(1|8,2,"ex_data.c",201);
    if (!impl)
        impl = &impl_default;
    CRYPTO_lock(2|8,2,"ex_data.c",204);
}

canonical_original_code:
static void impl_check()
{
    CRYPTO_lock(1|8,2,"ex_data.c",201);
    if (!impl)
        impl = &impl_default;
    CRYPTO_lock(2|8,2,"ex_data.c",204);
}


decompiled_code:
__int64 int_new_class()
{
unsigned int v0; // er12

CRYPTO_lock(9LL, 2LL, "ex_data.c", 385LL);
v0 = ex_class++;
CRYPTO_lock(10LL, 2LL, "ex_data.c", 387LL);
return v0;
}

canonical_decompiled_code:
__int64 func1()
{
unsigned int v0; // er12

CRYPTO_lock(9LL, 2LL, "ex_data.c", 385LL);
v0 = ex_class++;
CRYPTO_lock(10LL, 2LL, "ex_data.c", 387LL);
return v0;
}

original_code:
static int int_new_class(void)
{
    int toret;
    CRYPTO_lock(1|8,2,"ex_data.c",385);
    toret = ex_class++;
    CRYPTO_lock(2|8,2,"ex_data.c",387);
    return toret;
}

canonical_original_code:
static int int_new_class()
{
    int toret;
    CRYPTO_lock(1|8,2,"ex_data.c",385);
    toret = ex_class++;
    CRYPTO_lock(2|8,2,"ex_data.c",387);
    return toret;
}


decompiled_code:
__int64 CRYPTO_cleanup_all_ex_data()
{
if ( !impl )
impl_check();
return (*(__int64 (**)(void))(impl + 8))();
}

original_code:
void CRYPTO_cleanup_all_ex_data(void)
{
    if(!impl) impl_check(); impl->cb_cleanup ();
}

canonical_original_code:
void CRYPTO_cleanup_all_ex_data()
{
    if(!impl) impl_check(); impl->cb_cleanup ();
}


decompiled_code:
__int64 CONF_modules_free()
{
CONF_modules_finish();
return CONF_modules_unload(1);
}

canonical_decompiled_code:
__int64 func9()
{
func6();
return func7(1);
}

original_code:
void CONF_modules_free(void)
{
    CONF_modules_finish();
    CONF_modules_unload(1);
}

canonical_original_code:
void CONF_modules_free()
{
    CONF_modules_finish();
    CONF_modules_unload(1);
}


decompiled_code:
__int64 CONF_get1_default_config_file()
{
char *v0; // rax
const char *v2; // rax
__int64 v3; // r12
__int64 v4; // r13
__int64 v5; // rax

v0 = getenv("OPENSSL_CONF");
if ( v0 )
return BUF_strdup(v0);
v2 = (const char *)X509_get_default_cert_area();
v3 = (unsigned int)strlen(v2) + 13;
v4 = CRYPTO_malloc(v3, "conf_mod.c", 539LL);
if ( v4 )
{
v5 = X509_get_default_cert_area();
BUF_strlcpy(v4, v5, (int)v3);
BUF_strlcat(v4, "/", (int)v3);
BUF_strlcat(v4, "openssl.cnf", (int)v3);
}
return v4;
}

canonical_decompiled_code:
__int64 func19()
{
char *v0; // rax
const char *v2; // rax
__int64 v3; // r12
__int64 v4; // r13
__int64 v5; // rax

v0 = getenv("OPENSSL_CONF");
if ( v0 )
return BUF_strdup(v0);
v2 = (const char *)X509_get_default_cert_area();
v3 = (unsigned int)strlen(v2) + 13;
v4 = CRYPTO_malloc(v3, "conf_mod.c", 539LL);
if ( v4 )
{
v5 = X509_get_default_cert_area();
BUF_strlcpy(v4, v5, (int)v3);
BUF_strlcat(v4, "/", (int)v3);
BUF_strlcat(v4, "openssl.cnf", (int)v3);
}
return v4;
}

original_code:
char *CONF_get1_default_config_file(void)
{
    char *file;
    int len;

    file = getenv("OPENSSL_CONF");
    if (file)
        return BUF_strdup(file);

    len = strlen(X509_get_default_cert_area());
#ifndef OPENSSL_SYS_VMS
    len++;
#endif
    len += strlen(OPENSSL_CONF);

    file = OPENSSL_malloc(len + 1);

    if (!file)
        return NULL;
    BUF_strlcpy(file, X509_get_default_cert_area(), len + 1);
#ifndef OPENSSL_SYS_VMS
    BUF_strlcat(file, "/", len + 1);
#endif
    BUF_strlcat(file, OPENSSL_CONF, len + 1);

    return file;
}

canonical_original_code:
char *CONF_get1_default_config_file()
{
    char *file;
    int len;

    file = getenv("OPENSSL_CONF");
    if (file)
        return BUF_strdup(file);

    len = strlen(X509_get_default_cert_area());
#ifndef OPENSSL_SYS_VMS
    len++;
#endif
    len += strlen(OPENSSL_CONF);

    file = OPENSSL_malloc(len + 1);

    if (!file)
        return NULL;
    BUF_strlcpy(file, X509_get_default_cert_area(), len + 1);
#ifndef OPENSSL_SYS_VMS
    BUF_strlcat(file, "/", len + 1);
#endif
    BUF_strlcat(file, OPENSSL_CONF, len + 1);

    return file;
}

variable_types:
file
char *

variable_types: len int

return_type: char *


decompiled_code:
__int64 __fastcall CONF_parse_list(char *s, int c, int a3, __int64 (__fastcall *a4)(char *, _QWORD, __int64), __int64 a5)
{
char *i; // r15
char *v10; // rax
char *v11; // rbx
char *v12; // rsi
__int64 result; // rax
__int64 v14; // rbx
const unsigned __int16 *v15; // rax
const unsigned __int16 *v16; // rdx

if ( s )
{
for ( i = s; ; i = v11 + 1 )
{
if ( a3 )
{
v14 = (unsigned __int8)*i;
if ( !(_BYTE)v14 )
{
LABEL_15:
v11 = strchr(i, c);
goto LABEL_16;
}
v15 = *_ctype_b_loc();
while ( (v15[v14] & 0x2000) != 0 )
{
v14 = (unsigned __int8)*++i;
if ( !(_BYTE)v14 )
goto LABEL_15;
}
}
v10 = strchr(i, c);
v11 = v10;
if ( i != v10 && *i )
{
v12 = v10 - 1;
if ( v10 )
{
if ( !a3 )
goto LABEL_7;
LABEL_19:
v16 = *_ctype_b_loc();
while ( (v16[(unsigned __int8)*v12] & 0x2000) != 0 )
--v12;
}
else
{
v12 = &i[strlen(i) - 1];
if ( a3 )
goto LABEL_19;
}
LABEL_7:
result = a4(i, (unsigned int)((_DWORD)v12 - (_DWORD)i + 1), a5);
if ( (int)result <= 0 )
return result;
goto LABEL_8;
}
LABEL_16:
result = a4(0LL, 0LL, a5);
if ( (int)result <= 0 )
return result;
LABEL_8:
if ( !v11 )
return 1LL;
}
}
ERR_put_error(14LL, 119LL, 115LL, "conf_mod.c", 567LL);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func21(char *s, int c, int a3, __int64 (__fastcall *a4)(char *, _QWORD, __int64), __int64 a5)
{
char *i; // r15
char *v10; // rax
char *v11; // rbx
char *v12; // rsi
__int64 result; // rax
__int64 v14; // rbx
const unsigned __int16 *v15; // rax
const unsigned __int16 *v16; // rdx

if ( s )
{
for ( i = s; ; i = v11 + 1 )
{
if ( a3 )
{
v14 = (unsigned __int8)*i;
if ( !(_BYTE)v14 )
{
LABEL_15:
v11 = strchr(i, c);
goto LABEL_16;
}
v15 = *_ctype_b_loc();
while ( (v15[v14] & 0x2000) != 0 )
{
v14 = (unsigned __int8)*++i;
if ( !(_BYTE)v14 )
goto LABEL_15;
}
}
v10 = strchr(i, c);
v11 = v10;
if ( i != v10 && *i )
{
v12 = v10 - 1;
if ( v10 )
{
if ( !a3 )
goto LABEL_7;
LABEL_19:
v16 = *_ctype_b_loc();
while ( (v16[(unsigned __int8)*v12] & 0x2000) != 0 )
--v12;
}
else
{
v12 = &i[strlen(i) - 1];
if ( a3 )
goto LABEL_19;
}
LABEL_7:
result = a4(i, (unsigned int)((_DWORD)v12 - (_DWORD)i + 1), a5);
if ( (int)result <= 0 )
return result;
goto LABEL_8;
}
LABEL_16:
result = a4(0LL, 0LL, a5);
if ( (int)result <= 0 )
return result;
LABEL_8:
if ( !v11 )
return 1LL;
}
}
ERR_put_error(14LL, 119LL, 115LL, "conf_mod.c", 567LL);
return 0LL;
}

original_code:
int CONF_parse_list(const char *list_, int sep, int nospc,
                    int (*list_cb) (const char *elem, int len, void *usr),
                    void *arg)
{
    int ret;
    const char *lstart, *tmpend, *p;

    if (list_ == NULL) {
        CONFerr(CONF_F_CONF_PARSE_LIST, CONF_R_LIST_CANNOT_BE_NULL);
        return 0;
    }

    lstart = list_;
    for (;;) {
        if (nospc) {
            while (*lstart && isspace((unsigned char)*lstart))
                lstart++;
        }
        p = strchr(lstart, sep);
        if (p == lstart || !*lstart)
            ret = list_cb(NULL, 0, arg);
        else {
            if (p)
                tmpend = p - 1;
            else
                tmpend = lstart + strlen(lstart) - 1;
            if (nospc) {
                while (isspace((unsigned char)*tmpend))
                    tmpend--;
            }
            ret = list_cb(lstart, tmpend - lstart + 1, arg);
        }
        if (ret <= 0)
            return ret;
        if (p == NULL)
            return 1;
        lstart = p + 1;
    }
}

canonical_original_code:
int CONF_parse_list(char *list_, int sep, int nospc, int (*list_cb)(char *elem, int len, void *usr), void *arg)
{
    int ret;
    char *lstart; char *tmpend; char *p;

    if (list_ == NULL) {
        CONFerr(CONF_F_CONF_PARSE_LIST, CONF_R_LIST_CANNOT_BE_NULL);
        return 0;
    }

    lstart = list_;
    for (;;) {
        if (nospc) {
            while (*lstart && isspace((unsigned char)*lstart))
                lstart++;
        }
        p = strchr(lstart, sep);
        if (p == lstart || !*lstart)
            ret = list_cb(NULL, 0, arg);
        else {
            if (p)
                tmpend = p - 1;
            else
                tmpend = lstart + strlen(lstart) - 1;
            if (nospc) {
                while (isspace((unsigned char)*tmpend))
                    tmpend--;
            }
            ret = list_cb(lstart, tmpend - lstart + 1, arg);
        }
        if (ret <= 0)
            return ret;
        if (p == NULL)
            return 1;
        lstart = p + 1;
    }
}

variable_types: sep int

variable_types: nospc int

variable_types:
arg
void *

variable_types:
lstart
char *

variable_types:
tmpend
char *

variable_types:
p
char *


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

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

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

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

original_code:
void ERR_load_DSO_strings(void)
{
#ifndef OPENSSL_NO_ERR

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

canonical_original_code:
void ERR_load_DSO_strings()
{
#ifndef OPENSSL_NO_ERR

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


decompiled_code:
unsigned __int64 __fastcall lh_strhash(char *a1)
{
char v1; // dl
unsigned __int64 result; // rax
__int64 v3; // r9
unsigned __int64 v4; // rsi
unsigned __int64 v5; // rax
char v6; // dl
unsigned __int64 v7; // r8
char v8; // cl

if ( !a1 )
return 0LL;
v1 = *a1;
result = 0LL;
if ( *a1 )
{
v3 = 256LL;
v4 = 0LL;
do
{
++a1;
v5 = v3 | v1;
v3 += 256LL;
v6 = (v5 ^ (v5 >> 2)) & 0xF;
v7 = v4 << v6;
v8 = 32 - v6;
v1 = *a1;
v4 = (v5 * v5) ^ ((unsigned int)v7 | (unsigned int)(v4 >> v8));
}
while ( *a1 );
result = v4 ^ (v4 >> 16);
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func1(char *a1)
{
char v1; // dl
unsigned __int64 result; // rax
__int64 v3; // r9
unsigned __int64 v4; // rsi
unsigned __int64 v5; // rax
char v6; // dl
unsigned __int64 v7; // r8
char v8; // cl

if ( !a1 )
return 0LL;
v1 = *a1;
result = 0LL;
if ( *a1 )
{
v3 = 256LL;
v4 = 0LL;
do
{
++a1;
v5 = v3 | v1;
v3 += 256LL;
v6 = (v5 ^ (v5 >> 2)) & 0xF;
v7 = v4 << v6;
v8 = 32 - v6;
v1 = *a1;
v4 = (v5 * v5) ^ ((unsigned int)v7 | (unsigned int)(v4 >> v8));
}
while ( *a1 );
result = v4 ^ (v4 >> 16);
}
return result;
}

original_code:
unsigned long lh_strhash(const char *c)
{
    unsigned long ret = 0;
    long n;
    unsigned long v;
    int r;

    if ((c == NULL) || (*c == '\0'))
        return (ret);
/*-
    unsigned char b[16];
    MD5(c,strlen(c),b);
    return(b[0]|(b[1]<<8)|(b[2]<<16)|(b[3]<<24));
*/

    n = 0x100;
    while (*c) {
        v = n | (*c);
        n += 0x100;
        r = (int)((v >> 2) ^ v) & 0x0f;
        ret = (ret << r) | (ret >> (32 - r));
        ret &= 0xFFFFFFFFL;
        ret ^= v * v;
        c++;
    }
    return ((ret >> 16) ^ ret);
}

canonical_original_code:
unsigned long lh_strhash(char *c)
{
    unsigned long ret = 0;
    long n;
    unsigned long v;
    int r;

    if ((c == NULL) || (*c == '\0'))
        return (ret);
/*-
    unsigned char b[16];
    MD5(c,strlen(c),b);
    return(b[0]|(b[1]<<8)|(b[2]<<16)|(b[3]<<24));
*/

    n = 0x100;
    while (*c) {
        v = n | (*c);
        n += 0x100;
        r = (int)((v >> 2) ^ v) & 0x0f;
        ret = (ret << r) | (ret >> (32 - r));
        ret &= 0xFFFFFFFFL;
        ret ^= v * v;
        c++;
    }
    return ((ret >> 16) ^ ret);
}

variable_types:
c
char *

variable_types:
ret
unsigned long

variable_types: n long

variable_types:
v
unsigned long

variable_types: r int


decompiled_code:
const char *AES_options()
{
return "aes(partial)";
}

canonical_decompiled_code:
const char *func0()
{
return "aes(partial)";
}

original_code:
const char *AES_options(void)
{
#ifdef FULL_UNROLL
    return "aes(full)";
#else
    return "aes(partial)";
#endif
}

canonical_original_code:
char *AES_options()
{
#ifdef FULL_UNROLL
    return "aes(full)";
#else
    return "aes(partial)";
#endif
}


decompiled_code:
__int64 __fastcall RSA_padding_add_X931(_BYTE *a1, int a2, const void *a3, unsigned int a4)
{
int v4; // esi
_BYTE *v7; // rdi
__int64 result; // rax

v4 = a2 - a4;
if ( v4 - 2 < 0 )
{
ERR_put_error(4LL, 127LL, 110LL, "rsa_x931.c", 81LL);
result = 0xFFFFFFFFLL;
}
else
{
v7 = a1 + 1;
if ( v4 == 2 )
{
*a1 = 106;
}
else
{
*a1 = 107;
if ( v4 != 3 )
{
memset(v7, 187, v4 - 3);
v7 = &a1[v4 - 2];
}
*v7++ = -70;
}
*((_BYTE *)memcpy(v7, a3, a4) + (int)a4) = -52;
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1, int a2, const void *a3, unsigned int a4)
{
int v4; // esi
_BYTE *v7; // rdi
__int64 result; // rax

v4 = a2 - a4;
if ( v4 - 2 < 0 )
{
ERR_put_error(4LL, 127LL, 110LL, "rsa_x931.c", 81LL);
result = 0xFFFFFFFFLL;
}
else
{
v7 = a1 + 1;
if ( v4 == 2 )
{
*a1 = 106;
}
else
{
*a1 = 107;
if ( v4 != 3 )
{
memset(v7, 187, v4 - 3);
v7 = &a1[v4 - 2];
}
*v7++ = -70;
}
*((_BYTE *)memcpy(v7, a3, a4) + (int)a4) = -52;
result = 1LL;
}
return result;
}

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

    /*
     * Absolute minimum amount of padding is 1 header nibble, 1 padding
     * nibble and 2 trailer bytes: but 1 hash if is already in 'from'.
     */

    j = tlen - flen - 2;

    if (j < 0) {
        RSAerr(RSA_F_RSA_PADDING_ADD_X931, RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE);
        return -1;
    }

    p = (unsigned char *)to;

    /* If no padding start and end nibbles are in one byte */
    if (j == 0)
        *p++ = 0x6A;
    else {
        *p++ = 0x6B;
        if (j > 1) {
            memset(p, 0xBB, j - 1);
            p += j - 1;
        }
        *p++ = 0xBA;
    }
    memcpy(p, from, (unsigned int)flen);
    p += flen;
    *p = 0xCC;
    return (1);
}

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

    /*
     * Absolute minimum amount of padding is 1 header nibble, 1 padding
     * nibble and 2 trailer bytes: but 1 hash if is already in 'from'.
     */

    j = tlen - flen - 2;

    if (j < 0) {
        RSAerr(RSA_F_RSA_PADDING_ADD_X931, RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE);
        return -1;
    }

    p = (unsigned char *)to;

    /* If no padding start and end nibbles are in one byte */
    if (j == 0)
        *p++ = 0x6A;
    else {
        *p++ = 0x6B;
        if (j > 1) {
            memset(p, 0xBB, j - 1);
            p += j - 1;
        }
        *p++ = 0xBA;
    }
    memcpy(p, from, (unsigned int)flen);
    p += flen;
    *p = 0xCC;
    return (1);
}

variable_types:
to
unsigned char *

variable_types: tlen int

variable_types:
from
unsigned char *

variable_types: flen int

variable_types:
p
unsigned char *


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

    p = from;
    if ((num != flen) || ((*p != 0x6A) && (*p != 0x6B))) {
        RSAerr(RSA_F_RSA_PADDING_CHECK_X931, RSA_R_INVALID_HEADER);
        return -1;
    }

    if (*p++ == 0x6B) {
        j = flen - 3;
        for (i = 0; i < j; i++) {
            unsigned char c = *p++;
            if (c == 0xBA)
                break;
            if (c != 0xBB) {
                RSAerr(RSA_F_RSA_PADDING_CHECK_X931, RSA_R_INVALID_PADDING);
                return -1;
            }
        }

        j -= i;

        if (i == 0) {
            RSAerr(RSA_F_RSA_PADDING_CHECK_X931, RSA_R_INVALID_PADDING);
            return -1;
        }

    } else
        j = flen - 2;

    if (p[j] != 0xCC) {
        RSAerr(RSA_F_RSA_PADDING_CHECK_X931, RSA_R_INVALID_TRAILER);
        return -1;
    }

    memcpy(to, p, (unsigned int)j);

    return (j);
}

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

    p = from;
    if ((num != flen) || ((*p != 0x6A) && (*p != 0x6B))) {
        RSAerr(RSA_F_RSA_PADDING_CHECK_X931, RSA_R_INVALID_HEADER);
        return -1;
    }

    if (*p++ == 0x6B) {
        j = flen - 3;
        for (i = 0; i < j; i++) {
            unsigned char c = *p++;
            if (c == 0xBA)
                break;
            if (c != 0xBB) {
                RSAerr(RSA_F_RSA_PADDING_CHECK_X931, RSA_R_INVALID_PADDING);
                return -1;
            }
        }

        j -= i;

        if (i == 0) {
            RSAerr(RSA_F_RSA_PADDING_CHECK_X931, RSA_R_INVALID_PADDING);
            return -1;
        }

    } else
        j = flen - 2;

    if (p[j] != 0xCC) {
        RSAerr(RSA_F_RSA_PADDING_CHECK_X931, RSA_R_INVALID_TRAILER);
        return -1;
    }

    memcpy(to, p, (unsigned int)j);

    return (j);
}

variable_types: num int

variable_types: i int

variable_types: j int

variable_types:
c
unsigned char


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

if ( a1 == 673 )
return 54LL;
if ( a1 > 673 )
{
result = 0xFFFFFFFFLL;
if ( a1 == 674 )
result = 53LL;
}
else
{
result = 51LL;
if ( a1 != 64 )
{
result = 0xFFFFFFFFLL;
if ( a1 == 672 )
result = 52LL;
}
}
return result;
}

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

if ( a1 == 673 )
return 54LL;
if ( a1 > 673 )
{
result = 0xFFFFFFFFLL;
if ( a1 == 674 )
result = 53LL;
}
else
{
result = 51LL;
if ( a1 != 64 )
{
result = 0xFFFFFFFFLL;
if ( a1 == 672 )
result = 52LL;
}
}
return result;
}

original_code:
int RSA_X931_hash_id(int nid)
{
    switch (nid) {
    case NID_sha1:
        return 0x33;

    case NID_sha256:
        return 0x34;

    case NID_sha384:
        return 0x36;

    case NID_sha512:
        return 0x35;

    }
    return -1;
}

variable_types: nid int


original_code:
void BZ2_hbMakeCodeLengths ( UChar *len,
                             Int32 *freq,
                             Int32 alphaSize,
                             Int32 maxLen )
{
   Int32 nNodes, nHeap, n1, n2, i, j, k;
   Bool tooLong;
   Int32 heap [ 258 + 2 ];
   Int32 weight [ 258 * 2 ];
   Int32 parent [ 258 * 2 ];
   for (i = 0; i < alphaSize; i++)
      weight[i+1] = (freq[i] == 0 ? 1 : freq[i]) << 8;
   while (((Bool)1)) {
      nNodes = alphaSize;
      nHeap = 0;
      heap[0] = 0;
      weight[0] = 0;
      parent[0] = -2;
      for (i = 1; i <= alphaSize; i++) {
         parent[i] = -1;
         nHeap++;
         heap[nHeap] = i;
         { Int32 zz, tmp; zz = nHeap; tmp = heap[zz]; while (weight[tmp] < weight[heap[zz >> 1]]) { heap[zz] = heap[zz >> 1]; zz >>= 1; } heap[zz] = tmp; };
      }
      { if (!(nHeap < (258 +2))) BZ2_bz__AssertH__fail ( 2001 ); };
      while (nHeap > 1) {
         n1 = heap[1]; heap[1] = heap[nHeap]; nHeap--; { Int32 zz, yy, tmp; zz = 1; tmp = heap[zz]; while (((Bool)1)) { yy = zz << 1; if (yy > nHeap) break; if (yy < nHeap && weight[heap[yy+1]] < weight[heap[yy]]) yy++; if (weight[tmp] < weight[heap[yy]]) break; heap[zz] = heap[yy]; zz = yy; } heap[zz] = tmp; };
         n2 = heap[1]; heap[1] = heap[nHeap]; nHeap--; { Int32 zz, yy, tmp; zz = 1; tmp = heap[zz]; while (((Bool)1)) { yy = zz << 1; if (yy > nHeap) break; if (yy < nHeap && weight[heap[yy+1]] < weight[heap[yy]]) yy++; if (weight[tmp] < weight[heap[yy]]) break; heap[zz] = heap[yy]; zz = yy; } heap[zz] = tmp; };
         nNodes++;
         parent[n1] = parent[n2] = nNodes;
         weight[nNodes] = (((weight[n1]) & 0xffffff00)+((weight[n2]) & 0xffffff00)) | (1 + ((((weight[n1]) & 0x000000ff)) > (((weight[n2]) & 0x000000ff)) ? (((weight[n1]) & 0x000000ff)) : (((weight[n2]) & 0x000000ff))));
         parent[nNodes] = -1;
         nHeap++;
         heap[nHeap] = nNodes;
         { Int32 zz, tmp; zz = nHeap; tmp = heap[zz]; while (weight[tmp] < weight[heap[zz >> 1]]) { heap[zz] = heap[zz >> 1]; zz >>= 1; } heap[zz] = tmp; };
      }
      { if (!(nNodes < (258 * 2))) BZ2_bz__AssertH__fail ( 2002 ); };
      tooLong = ((Bool)0);
      for (i = 1; i <= alphaSize; i++) {
         j = 0;
         k = i;
         while (parent[k] >= 0) { k = parent[k]; j++; }
         len[i-1] = j;
         if (j > maxLen) tooLong = ((Bool)1);
      }
      if (! tooLong) break;
      for (i = 1; i <= alphaSize; i++) {
         j = weight[i] >> 8;
         j = 1 + (j / 2);
         weight[i] = j << 8;
      }
   }
}

canonical_original_code:
void BZ2_hbMakeCodeLengths(unsigned char *len, int *freq, int alphaSize, int maxLen)
{
   int nNodes; int nHeap; int n1; int n2; int i; int j; int k;
   unsigned char tooLong;
   int heap[-1];
   int weight[-1];
   int parent[-1];
   for (i = 0; i < alphaSize; i++)
      weight[i+1] = (freq[i] == 0 ? 1 : freq[i]) << 8;
   while (((unsigned char)1)) {
      nNodes = alphaSize;
      nHeap = 0;
      heap[0] = 0;
      weight[0] = 0;
      parent[0] = -2;
      for (i = 1; i <= alphaSize; i++) {
         parent[i] = -1;
         nHeap++;
         heap[nHeap] = i;
         { int zz; int tmp; zz = nHeap; tmp = heap[zz]; while (weight[tmp] < weight[heap[zz >> 1]]) { heap[zz] = heap[zz >> 1]; zz >>= 1; } heap[zz] = tmp; };
      }
      { if (!(nHeap < (258 +2))) BZ2_bz__AssertH__fail ( 2001 ); };
      while (nHeap > 1) {
         n1 = heap[1]; heap[1] = heap[nHeap]; nHeap--; { int zz; int yy; int tmp; zz = 1; tmp = heap[zz]; while (((unsigned char)1)) { yy = zz << 1; if (yy > nHeap) break; if (yy < nHeap && weight[heap[yy+1]] < weight[heap[yy]]) yy++; if (weight[tmp] < weight[heap[yy]]) break; heap[zz] = heap[yy]; zz = yy; } heap[zz] = tmp; };
         n2 = heap[1]; heap[1] = heap[nHeap]; nHeap--; { int zz; int yy; int tmp; zz = 1; tmp = heap[zz]; while (((unsigned char)1)) { yy = zz << 1; if (yy > nHeap) break; if (yy < nHeap && weight[heap[yy+1]] < weight[heap[yy]]) yy++; if (weight[tmp] < weight[heap[yy]]) break; heap[zz] = heap[yy]; zz = yy; } heap[zz] = tmp; };
         nNodes++;
         parent[n1] = parent[n2] = nNodes;
         weight[nNodes] = (((weight[n1]) & 0xffffff00)+((weight[n2]) & 0xffffff00)) | (1 + ((((weight[n1]) & 0x000000ff)) > (((weight[n2]) & 0x000000ff)) ? (((weight[n1]) & 0x000000ff)) : (((weight[n2]) & 0x000000ff))));
         parent[nNodes] = -1;
         nHeap++;
         heap[nHeap] = nNodes;
         { int zz; int tmp; zz = nHeap; tmp = heap[zz]; while (weight[tmp] < weight[heap[zz >> 1]]) { heap[zz] = heap[zz >> 1]; zz >>= 1; } heap[zz] = tmp; };
      }
      { if (!(nNodes < (258 * 2))) BZ2_bz__AssertH__fail ( 2002 ); };
      tooLong = ((unsigned char)0);
      for (i = 1; i <= alphaSize; i++) {
         j = 0;
         k = i;
         while (parent[k] >= 0) { k = parent[k]; j++; }
         len[i-1] = j;
         if (j > maxLen) tooLong = ((unsigned char)1);
      }
      if (! tooLong) break;
      for (i = 1; i <= alphaSize; i++) {
         j = weight[i] >> 8;
         j = 1 + (j / 2);
         weight[i] = j << 8;
      }
   }
}

variable_types:
len
unsigned char *

variable_types:
freq
int *

variable_types: alphaSize int

variable_types: maxLen int

variable_types: nNodes int

variable_types: nHeap int

variable_types: k int

variable_types:
tooLong
unsigned char

variable_types:
heap
int [-1]

variable_types:
weight
int [-1]

variable_types:
parent
int [-1]

variable_types: zz int

variable_types: tmp int

variable_types: yy int


original_code:
void BZ2_hbAssignCodes ( Int32 *code,
                         UChar *length,
                         Int32 minLen,
                         Int32 maxLen,
                         Int32 alphaSize )
{
   Int32 n, vec, i;
   vec = 0;
   for (n = minLen; n <= maxLen; n++) {
      for (i = 0; i < alphaSize; i++)
         if (length[i] == n) { code[i] = vec; vec++; };
      vec <<= 1;
   }
}

canonical_original_code:
void BZ2_hbAssignCodes(int *code, unsigned char *length, int minLen, int maxLen, int alphaSize)
{
   int n; int vec; int i;
   vec = 0;
   for (n = minLen; n <= maxLen; n++) {
      for (i = 0; i < alphaSize; i++)
         if (length[i] == n) { code[i] = vec; vec++; };
      vec <<= 1;
   }
}

variable_types:
code
int *

variable_types:
length
unsigned char *

variable_types: minLen int

variable_types: n int

variable_types: vec int

variable_types: i int


original_code:
void BZ2_hbCreateDecodeTables ( Int32 *limit,
                                Int32 *base,
                                Int32 *perm,
                                UChar *length,
                                Int32 minLen,
                                Int32 maxLen,
                                Int32 alphaSize )
{
   Int32 pp, i, j, vec;
   pp = 0;
   for (i = minLen; i <= maxLen; i++)
      for (j = 0; j < alphaSize; j++)
         if (length[j] == i) { perm[pp] = j; pp++; };
   for (i = 0; i < 23; i++) base[i] = 0;
   for (i = 0; i < alphaSize; i++) base[length[i]+1]++;
   for (i = 1; i < 23; i++) base[i] += base[i-1];
   for (i = 0; i < 23; i++) limit[i] = 0;
   vec = 0;
   for (i = minLen; i <= maxLen; i++) {
      vec += (base[i+1] - base[i]);
      limit[i] = vec-1;
      vec <<= 1;
   }
   for (i = minLen + 1; i <= maxLen; i++)
      base[i] = ((limit[i-1] + 1) << 1) - base[i];
}

canonical_original_code:
void BZ2_hbCreateDecodeTables(int *limit, int *base, int *perm, unsigned char *length, int minLen, int maxLen, int alphaSize)
{
   int pp; int i; int j; int vec;
   pp = 0;
   for (i = minLen; i <= maxLen; i++)
      for (j = 0; j < alphaSize; j++)
         if (length[j] == i) { perm[pp] = j; pp++; };
   for (i = 0; i < 23; i++) base[i] = 0;
   for (i = 0; i < alphaSize; i++) base[length[i]+1]++;
   for (i = 1; i < 23; i++) base[i] += base[i-1];
   for (i = 0; i < 23; i++) limit[i] = 0;
   vec = 0;
   for (i = minLen; i <= maxLen; i++) {
      vec += (base[i+1] - base[i]);
      limit[i] = vec-1;
      vec <<= 1;
   }
   for (i = minLen + 1; i <= maxLen; i++)
      base[i] = ((limit[i-1] + 1) << 1) - base[i];
}

variable_types:
limit
int *

variable_types:
base
int *

variable_types:
perm
int *

variable_types: maxLen int

variable_types: alphaSize int

variable_types: pp int

variable_types: j int


decompiled_code:
__int64 ASN1_add_oid_module()
{
return CONF_module_add("oid_section", oid_module_init, oid_module_finish);
}

canonical_decompiled_code:
__int64 func3()
{
return CONF_module_add("oid_section", oid_module_init, oid_module_finish);
}

original_code:
void ASN1_add_oid_module(void)
{
    CONF_module_add("oid_section", oid_module_init, oid_module_finish);
}

canonical_original_code:
void ASN1_add_oid_module()
{
    CONF_module_add("oid_section", oid_module_init, oid_module_finish);
}


original_code:
int OCSP_parse_url(char *url, char **phost, char **pport, char **ppath,
                   int *pssl)
{
    char *p, *buf;

    char *host, *port;

    *phost = NULL;
    *pport = NULL;
    *ppath = NULL;

    /* dup the buffer since we are going to mess with it */
    buf = BUF_strdup(url);
    if (!buf)
        goto mem_err;

    /* Check for initial colon */
    p = strchr(buf, ':');

    if (!p)
        goto parse_err;

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

    if (!strcmp(buf, "http")) {
        *pssl = 0;
        port = "80";
    } else if (!strcmp(buf, "https")) {
        *pssl = 1;
        port = "443";
    } else
        goto parse_err;

    /* Check for double slash */
    if ((p[0] != '/') || (p[1] != '/'))
        goto parse_err;

    p += 2;

    host = p;

    /* Check for trailing part of path */

    p = strchr(p, '/');

    if (!p)
        *ppath = BUF_strdup("/");
    else {
        *ppath = BUF_strdup(p);
        /* Set start of path to 0 so hostname is valid */
        *p = '\0';
    }

    if (!*ppath)
        goto mem_err;

    p = host;
    if (host[0] == '[') {
        /* ipv6 literal */
        host++;
        p = strchr(host, ']');
        if (!p)
            goto parse_err;
        *p = '\0';
        p++;
    }

    /* Look for optional ':' for port number */
    if ((p = strchr(p, ':'))) {
        *p = 0;
        port = p + 1;
    } else {
        /* Not found: set default port */
        if (*pssl)
            port = "443";
        else
            port = "80";
    }

    *pport = BUF_strdup(port);
    if (!*pport)
        goto mem_err;

    *phost = BUF_strdup(host);

    if (!*phost)
        goto mem_err;

    OPENSSL_free(buf);

    return 1;

 mem_err:
    OCSPerr(OCSP_F_OCSP_PARSE_URL, ERR_R_MALLOC_FAILURE);
    goto err;

 parse_err:
    OCSPerr(OCSP_F_OCSP_PARSE_URL, OCSP_R_ERROR_PARSING_URL);

 err:
    if (buf)
        OPENSSL_free(buf);
    if (*ppath)
        OPENSSL_free(*ppath);
    if (*pport)
        OPENSSL_free(*pport);
    if (*phost)
        OPENSSL_free(*phost);
    return 0;

}

canonical_original_code:
int OCSP_parse_url(char *url, char **phost, char **pport, char **ppath, int *pssl)
{
    char *p; char *buf;

    char *host; char *port;

    *phost = NULL;
    *pport = NULL;
    *ppath = NULL;

    /* dup the buffer since we are going to mess with it */
    buf = BUF_strdup(url);
    if (!buf)
        goto mem_err;

    /* Check for initial colon */
    p = strchr(buf, ':');

    if (!p)
        goto parse_err;

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

    if (!strcmp(buf, "http")) {
        *pssl = 0;
        port = "80";
    } else if (!strcmp(buf, "https")) {
        *pssl = 1;
        port = "443";
    } else
        goto parse_err;

    /* Check for double slash */
    if ((p[0] != '/') || (p[1] != '/'))
        goto parse_err;

    p += 2;

    host = p;

    /* Check for trailing part of path */

    p = strchr(p, '/');

    if (!p)
        *ppath = BUF_strdup("/");
    else {
        *ppath = BUF_strdup(p);
        /* Set start of path to 0 so hostname is valid */
        *p = '\0';
    }

    if (!*ppath)
        goto mem_err;

    p = host;
    if (host[0] == '[') {
        /* ipv6 literal */
        host++;
        p = strchr(host, ']');
        if (!p)
            goto parse_err;
        *p = '\0';
        p++;
    }

    /* Look for optional ':' for port number */
    if ((p = strchr(p, ':'))) {
        *p = 0;
        port = p + 1;
    } else {
        /* Not found: set default port */
        if (*pssl)
            port = "443";
        else
            port = "80";
    }

    *pport = BUF_strdup(port);
    if (!*pport)
        goto mem_err;

    *phost = BUF_strdup(host);

    if (!*phost)
        goto mem_err;

    OPENSSL_free(buf);

    return 1;

 mem_err:
    OCSPerr(OCSP_F_OCSP_PARSE_URL, ERR_R_MALLOC_FAILURE);
    goto err;

 parse_err:
    OCSPerr(OCSP_F_OCSP_PARSE_URL, OCSP_R_ERROR_PARSING_URL);

 err:
    if (buf)
        OPENSSL_free(buf);
    if (*ppath)
        OPENSSL_free(*ppath);
    if (*pport)
        OPENSSL_free(*pport);
    if (*phost)
        OPENSSL_free(*phost);
    return 0;

}

variable_types:
url
char *

variable_types:
phost
char **

variable_types:
pport
char **

variable_types:
ppath
char **

variable_types:
pssl
int *

variable_types:
p
char *

variable_types:
buf
char *

variable_types:
host
char *

variable_types:
port
char *


showbn

decompiled_code:
int __fastcall showbn(const char *a1, __int64 a2)
{
fputs(a1, stdout);
fwrite(&unk_371, 1uLL, 3uLL, stdout);
BN_print_fp(stdout, a2);
return putc(10, stdout);
}

canonical_decompiled_code:
int __fastcall func0(const char *a1, __int64 a2)
{
fputs(a1, stdout);
fwrite(&unk_371, 1uLL, 3uLL, stdout);
BN_print_fp(stdout, a2);
return putc(10, stdout);
}

original_code:
static void showbn(const char *name, const BIGNUM *bn)
{
    fputs(name, stdout);
    fputs(" = ", stdout);
    BN_print_fp(stdout, bn);
    putc('\n', stdout);
}

canonical_original_code:
static void showbn(char *name, struct bignum_st *bn)
{
    fputs(name, stdout);
    fputs(" = ", stdout);
    BN_print_fp(stdout, bn);
    putc('\n', stdout);
}

variable_types:
name
char *

variable_types: struct bignum_st { unsigned long *d; int top; int dmax; int neg; int flags; } *


main

canonical_name: main

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

v3 = BIO_new_fp(stderr, 0LL, envp);
CRYPTO_set_mem_debug_functions(
&CRYPTO_dbg_malloc,
&CRYPTO_dbg_realloc,
&CRYPTO_dbg_free,
&CRYPTO_dbg_set_options,
&CRYPTO_dbg_get_options);
CRYPTO_dbg_set_options(3LL);
CRYPTO_mem_ctrl(1LL);
ERR_load_crypto_strings();
if ( (unsigned int)run_srp_constprop_0((__int64)"password1", (__int64)"password2") )
{
v4 = run_srp_constprop_0((__int64)"password", (__int64)"password");
if ( v4 )
{
v4 = 1;
fwrite("Plain SRP run failed\n", 1uLL, 0x15uLL, stderr);
}
else
{
CRYPTO_cleanup_all_ex_data();
ERR_remove_thread_state(0LL);
ERR_free_strings();
CRYPTO_mem_leaks(v3);
}
}
else
{
v4 = 1;
fwrite("Mismatched SRP run failed\n", 1uLL, 0x1AuLL, stderr);
}
return v4;
}

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

v3 = BIO_new_fp(stderr, 0LL, envp);
CRYPTO_set_mem_debug_functions(
&CRYPTO_dbg_malloc,
&CRYPTO_dbg_realloc,
&CRYPTO_dbg_free,
&CRYPTO_dbg_set_options,
&CRYPTO_dbg_get_options);
CRYPTO_dbg_set_options(3LL);
CRYPTO_mem_ctrl(1LL);
ERR_load_crypto_strings();
if ( (unsigned int)func1((__int64)"password1", (__int64)"password2") )
{
v4 = func1((__int64)"password", (__int64)"password");
if ( v4 )
{
v4 = 1;
fwrite("Plain SRP run failed\n", 1uLL, 0x15uLL, stderr);
}
else
{
CRYPTO_cleanup_all_ex_data();
ERR_remove_thread_state(0LL);
ERR_free_strings();
CRYPTO_mem_leaks(v3);
}
}
else
{
v4 = 1;
fwrite("Mismatched SRP run failed\n", 1uLL, 0x1AuLL, stderr);
}
return v4;
}

original_code:
int main(int argc, char **argv)
{
    BIO *bio_err;
    bio_err = BIO_new_fp(stderr, 0x00);
    do { CRYPTO_set_mem_debug_functions( CRYPTO_dbg_malloc, CRYPTO_dbg_realloc, CRYPTO_dbg_free, CRYPTO_dbg_set_options, CRYPTO_dbg_get_options); } while(0);
    CRYPTO_dbg_set_options((0x1 | 0x2));
    CRYPTO_mem_ctrl(0x1);
    ERR_load_crypto_strings();
    if (run_srp("alice", "password1", "password2") == 0) {
        fprintf(stderr, "Mismatched SRP run failed\n");
        return 1;
    }
    if (run_srp("alice", "password", "password") != 0) {
        fprintf(stderr, "Plain SRP run failed\n");
        return 1;
    }
    CRYPTO_cleanup_all_ex_data();
    ERR_remove_thread_state(((void *)0));
    ERR_free_strings();
    CRYPTO_mem_leaks(bio_err);
    return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
    struct bio_st *bio_err;
    bio_err = BIO_new_fp(stderr, 0x00);
    do { CRYPTO_set_mem_debug_functions( CRYPTO_dbg_malloc, CRYPTO_dbg_realloc, CRYPTO_dbg_free, CRYPTO_dbg_set_options, CRYPTO_dbg_get_options); } while(0);
    CRYPTO_dbg_set_options((0x1 | 0x2));
    CRYPTO_mem_ctrl(0x1);
    ERR_load_crypto_strings();
    if (run_srp("alice", "password1", "password2") == 0) {
        fprintf(stderr, "Mismatched SRP run failed\n");
        return 1;
    }
    if (run_srp("alice", "password", "password") != 0) {
        fprintf(stderr, "Plain SRP run failed\n");
        return 1;
    }
    CRYPTO_cleanup_all_ex_data();
    ERR_remove_thread_state(((void *)0));
    ERR_free_strings();
    CRYPTO_mem_leaks(bio_err);
    return 0;
}

variable_types: argc int

variable_types:
argv
char **

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; } *

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; }


decompiled_code:
__int64 engine_unregister_all_DSA()
{
return engine_table_cleanup(&dsa_table);
}

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

original_code:
static void engine_unregister_all_DSA(void)
{
    engine_table_cleanup(&dsa_table);
}

canonical_original_code:
static void engine_unregister_all_DSA()
{
    engine_table_cleanup(&dsa_table);
}


decompiled_code:
void COMP_zlib_cleanup()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
void COMP_zlib_cleanup(void)
{
#ifdef ZLIB_SHARED
    if (zlib_dso)
        DSO_free(zlib_dso);
#endif
}

canonical_original_code:
void COMP_zlib_cleanup()
{
#ifdef ZLIB_SHARED
    if (zlib_dso)
        DSO_free(zlib_dso);
#endif
}


decompiled_code:
const char *X509_get_default_private_dir()
{
return "/usr/src/repo/third-party/tree/ssl/private";
}

canonical_decompiled_code:
const char *func0()
{
return "/usr/src/repo/third-party/tree/ssl/private";
}

original_code:
const char *X509_get_default_private_dir(void)
{
    return (X509_PRIVATE_DIR);
}

canonical_original_code:
char *X509_get_default_private_dir()
{
    return (X509_PRIVATE_DIR);
}


decompiled_code:
const char *X509_get_default_cert_area()
{
return "/usr/src/repo/third-party/tree/ssl";
}

canonical_decompiled_code:
const char *func1()
{
return "/usr/src/repo/third-party/tree/ssl";
}

original_code:
const char *X509_get_default_cert_area(void)
{
    return (X509_CERT_AREA);
}

canonical_original_code:
char *X509_get_default_cert_area()
{
    return (X509_CERT_AREA);
}


decompiled_code:
const char *X509_get_default_cert_dir()
{
return "/usr/src/repo/third-party/tree/ssl/certs";
}

canonical_decompiled_code:
const char *func2()
{
return "/usr/src/repo/third-party/tree/ssl/certs";
}

original_code:
const char *X509_get_default_cert_dir(void)
{
    return (X509_CERT_DIR);
}

canonical_original_code:
char *X509_get_default_cert_dir()
{
    return (X509_CERT_DIR);
}


decompiled_code:
const char *X509_get_default_cert_file()
{
return "/usr/src/repo/third-party/tree/ssl/cert.pem";
}

canonical_decompiled_code:
const char *func3()
{
return "/usr/src/repo/third-party/tree/ssl/cert.pem";
}

original_code:
const char *X509_get_default_cert_file(void)
{
    return (X509_CERT_FILE);
}

canonical_original_code:
char *X509_get_default_cert_file()
{
    return (X509_CERT_FILE);
}


decompiled_code:
const char *X509_get_default_cert_dir_env()
{
return "SSL_CERT_DIR";
}

canonical_decompiled_code:
const char *func4()
{
return "SSL_CERT_DIR";
}

original_code:
const char *X509_get_default_cert_dir_env(void)
{
    return (X509_CERT_DIR_EVP);
}

canonical_original_code:
char *X509_get_default_cert_dir_env()
{
    return (X509_CERT_DIR_EVP);
}


decompiled_code:
const char *X509_get_default_cert_file_env()
{
return "SSL_CERT_FILE";
}

canonical_decompiled_code:
const char *func5()
{
return "SSL_CERT_FILE";
}

original_code:
const char *X509_get_default_cert_file_env(void)
{
    return (X509_CERT_FILE_EVP);
}

canonical_original_code:
char *X509_get_default_cert_file_env()
{
    return (X509_CERT_FILE_EVP);
}


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

result = (const char *)ATALLA_LIBNAME;
if ( !ATALLA_LIBNAME )
result = "atasi";
return result;
}

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

result = (const char *)ATALLA_LIBNAME;
if ( !ATALLA_LIBNAME )
result = "atasi";
return result;
}

original_code:
static const char *get_ATALLA_LIBNAME(void)
{
    if (ATALLA_LIBNAME)
        return ATALLA_LIBNAME;
    return "atasi";
}

canonical_original_code:
static char *get_ATALLA_LIBNAME()
{
    if (ATALLA_LIBNAME)
        return ATALLA_LIBNAME;
    return "atasi";
}


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

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

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

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

original_code:
static void free_ATALLA_LIBNAME(void)
{
    if (ATALLA_LIBNAME)
        CRYPTO_free((void *)ATALLA_LIBNAME);
    ATALLA_LIBNAME = ((void *)0);
}

canonical_original_code:
static void free_ATALLA_LIBNAME()
{
    if (ATALLA_LIBNAME)
        CRYPTO_free((void *)ATALLA_LIBNAME);
    ATALLA_LIBNAME = ((void *)0);
}


decompiled_code:
_BOOL8 __fastcall set_ATALLA_LIBNAME(__int64 a1)
{
free_ATALLA_LIBNAME();
ATALLA_LIBNAME = BUF_strdup(a1);
return ATALLA_LIBNAME != 0;
}

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

original_code:
static long set_ATALLA_LIBNAME(const char *name)
{
    free_ATALLA_LIBNAME();
    return (((ATALLA_LIBNAME = BUF_strdup(name)) != ((void *)0)) ? 1 : 0);
}

canonical_original_code:
static long set_ATALLA_LIBNAME(char *name)
{
    free_ATALLA_LIBNAME();
    return (((ATALLA_LIBNAME = BUF_strdup(name)) != ((void *)0)) ? 1 : 0);
}

return_type: long


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

result = (unsigned int)ATALLA_error_init;
if ( !ATALLA_error_init )
{
ERR_unload_strings((unsigned int)ATALLA_lib_error_code, &ATALLA_str_functs);
ERR_unload_strings((unsigned int)ATALLA_lib_error_code, &ATALLA_str_reasons);
result = ERR_unload_strings(0LL, &ATALLA_lib_name);
ATALLA_error_init = 1;
}
return result;
}

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

result = (unsigned int)ATALLA_error_init;
if ( !ATALLA_error_init )
{
ERR_unload_strings((unsigned int)ATALLA_lib_error_code, &ATALLA_str_functs);
ERR_unload_strings((unsigned int)ATALLA_lib_error_code, &ATALLA_str_reasons);
result = ERR_unload_strings(0LL, &ATALLA_lib_name);
ATALLA_error_init = 1;
}
return result;
}

original_code:
static void ERR_unload_ATALLA_strings(void)
{
    if (ATALLA_error_init == 0) {
        ERR_unload_strings(ATALLA_lib_error_code, ATALLA_str_functs);
        ERR_unload_strings(ATALLA_lib_error_code, ATALLA_str_reasons);
        ERR_unload_strings(0, ATALLA_lib_name);
        ATALLA_error_init = 1;
    }
}

canonical_original_code:
static void ERR_unload_ATALLA_strings()
{
    if (ATALLA_error_init == 0) {
        ERR_unload_strings(ATALLA_lib_error_code, ATALLA_str_functs);
        ERR_unload_strings(ATALLA_lib_error_code, ATALLA_str_reasons);
        ERR_unload_strings(0, ATALLA_lib_name);
        ATALLA_error_init = 1;
    }
}


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

if ( ATALLA_lib_error_code )
{
result = (unsigned int)ATALLA_error_init;
if ( !ATALLA_error_init )
return result;
LABEL_5:
ATALLA_error_init = 0;
ERR_load_strings((unsigned int)ATALLA_lib_error_code, &ATALLA_str_functs);
ERR_load_strings((unsigned int)ATALLA_lib_error_code, &ATALLA_str_reasons);
ATALLA_lib_name = (unsigned __int64)(unsigned __int8)ATALLA_lib_error_code << 24;
return ERR_load_strings(0LL, &ATALLA_lib_name);
}
ATALLA_lib_error_code = ERR_get_next_error_library();
result = (unsigned int)ATALLA_error_init;
if ( ATALLA_error_init )
goto LABEL_5;
return result;
}

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

if ( ATALLA_lib_error_code )
{
result = (unsigned int)ATALLA_error_init;
if ( !ATALLA_error_init )
return result;
LABEL_5:
ATALLA_error_init = 0;
ERR_load_strings((unsigned int)ATALLA_lib_error_code, &ATALLA_str_functs);
ERR_load_strings((unsigned int)ATALLA_lib_error_code, &ATALLA_str_reasons);
ATALLA_lib_name = (unsigned __int64)(unsigned __int8)ATALLA_lib_error_code << 24;
return ERR_load_strings(0LL, &ATALLA_lib_name);
}
ATALLA_lib_error_code = ERR_get_next_error_library();
result = (unsigned int)ATALLA_error_init;
if ( ATALLA_error_init )
goto LABEL_5;
return result;
}

original_code:
static void ERR_load_ATALLA_strings(void)
{
    if (ATALLA_lib_error_code == 0)
        ATALLA_lib_error_code = ERR_get_next_error_library();
    if (ATALLA_error_init) {
        ATALLA_error_init = 0;
        ERR_load_strings(ATALLA_lib_error_code, ATALLA_str_functs);
        ERR_load_strings(ATALLA_lib_error_code, ATALLA_str_reasons);
        ATALLA_lib_name->error = (((((unsigned long)ATALLA_lib_error_code)&0xffL)*0x1000000)| ((((unsigned long)0)&0xfffL)*0x1000)| ((((unsigned long)0)&0xfffL)));
        ERR_load_strings(0, ATALLA_lib_name);
    }
}

canonical_original_code:
static void ERR_load_ATALLA_strings()
{
    if (ATALLA_lib_error_code == 0)
        ATALLA_lib_error_code = ERR_get_next_error_library();
    if (ATALLA_error_init) {
        ATALLA_error_init = 0;
        ERR_load_strings(ATALLA_lib_error_code, ATALLA_str_functs);
        ERR_load_strings(ATALLA_lib_error_code, ATALLA_str_reasons);
        ATALLA_lib_name->error = (((((unsigned long)ATALLA_lib_error_code)&0xffL)*0x1000000)| ((((unsigned long)0)&0xfffL)*0x1000)| ((((unsigned long)0)&0xfffL)));
        ERR_load_strings(0, ATALLA_lib_name);
    }
}


decompiled_code:
const char *__fastcall OCSP_response_status_str(__int64 a1)
{
return table2string(a1, &rstat_tbl_2, 6);
}

canonical_decompiled_code:
const char *__fastcall func2(__int64 a1)
{
return func0(a1, &rstat_tbl_2, 6);
}

original_code:
const char *OCSP_response_status_str(long s)
{
    static const OCSP_TBLSTR rstat_tbl[] = {
        {OCSP_RESPONSE_STATUS_SUCCESSFUL, "successful"},
        {OCSP_RESPONSE_STATUS_MALFORMEDREQUEST, "malformedrequest"},
        {OCSP_RESPONSE_STATUS_INTERNALERROR, "internalerror"},
        {OCSP_RESPONSE_STATUS_TRYLATER, "trylater"},
        {OCSP_RESPONSE_STATUS_SIGREQUIRED, "sigrequired"},
        {OCSP_RESPONSE_STATUS_UNAUTHORIZED, "unauthorized"}
    };
    return table2string(s, rstat_tbl, 6);
}

canonical_original_code:
char *OCSP_response_status_str(long s)
{
    static struct OCSP_TBLSTR rstat_tbl[] = {
        {OCSP_RESPONSE_STATUS_SUCCESSFUL, "successful"},
        {OCSP_RESPONSE_STATUS_MALFORMEDREQUEST, "malformedrequest"},
        {OCSP_RESPONSE_STATUS_INTERNALERROR, "internalerror"},
        {OCSP_RESPONSE_STATUS_TRYLATER, "trylater"},
        {OCSP_RESPONSE_STATUS_SIGREQUIRED, "sigrequired"},
        {OCSP_RESPONSE_STATUS_UNAUTHORIZED, "unauthorized"}
    };
    return table2string(s, rstat_tbl, 6);
}

variable_types: s long

variable_types: struct OCSP_TBLSTR { long t; char *m; } []


decompiled_code:
const char *__fastcall OCSP_cert_status_str(__int64 a1)
{
return table2string(a1, &cstat_tbl_1, 3);
}

canonical_decompiled_code:
const char *__fastcall func3(__int64 a1)
{
return func0(a1, &cstat_tbl_1, 3);
}

original_code:
const char *OCSP_cert_status_str(long s)
{
    static const OCSP_TBLSTR cstat_tbl[] = {
        {V_OCSP_CERTSTATUS_GOOD, "good"},
        {V_OCSP_CERTSTATUS_REVOKED, "revoked"},
        {V_OCSP_CERTSTATUS_UNKNOWN, "unknown"}
    };
    return table2string(s, cstat_tbl, 3);
}

canonical_original_code:
char *OCSP_cert_status_str(long s)
{
    static struct OCSP_TBLSTR cstat_tbl[] = {
        {V_OCSP_CERTSTATUS_GOOD, "good"},
        {V_OCSP_CERTSTATUS_REVOKED, "revoked"},
        {V_OCSP_CERTSTATUS_UNKNOWN, "unknown"}
    };
    return table2string(s, cstat_tbl, 3);
}


decompiled_code:
const char *__fastcall OCSP_crl_reason_str(__int64 a1)
{
return table2string(a1, &reason_tbl_0, 8);
}

canonical_decompiled_code:
const char *__fastcall func4(__int64 a1)
{
return func0(a1, &reason_tbl_0, 8);
}

original_code:
const char *OCSP_crl_reason_str(long s)
{
    static const OCSP_TBLSTR reason_tbl[] = {
        {OCSP_REVOKED_STATUS_UNSPECIFIED, "unspecified"},
        {OCSP_REVOKED_STATUS_KEYCOMPROMISE, "keyCompromise"},
        {OCSP_REVOKED_STATUS_CACOMPROMISE, "cACompromise"},
        {OCSP_REVOKED_STATUS_AFFILIATIONCHANGED, "affiliationChanged"},
        {OCSP_REVOKED_STATUS_SUPERSEDED, "superseded"},
        {OCSP_REVOKED_STATUS_CESSATIONOFOPERATION, "cessationOfOperation"},
        {OCSP_REVOKED_STATUS_CERTIFICATEHOLD, "certificateHold"},
        {OCSP_REVOKED_STATUS_REMOVEFROMCRL, "removeFromCRL"}
    };
    return table2string(s, reason_tbl, 8);
}

canonical_original_code:
char *OCSP_crl_reason_str(long s)
{
    static struct OCSP_TBLSTR reason_tbl[] = {
        {OCSP_REVOKED_STATUS_UNSPECIFIED, "unspecified"},
        {OCSP_REVOKED_STATUS_KEYCOMPROMISE, "keyCompromise"},
        {OCSP_REVOKED_STATUS_CACOMPROMISE, "cACompromise"},
        {OCSP_REVOKED_STATUS_AFFILIATIONCHANGED, "affiliationChanged"},
        {OCSP_REVOKED_STATUS_SUPERSEDED, "superseded"},
        {OCSP_REVOKED_STATUS_CESSATIONOFOPERATION, "cessationOfOperation"},
        {OCSP_REVOKED_STATUS_CERTIFICATEHOLD, "certificateHold"},
        {OCSP_REVOKED_STATUS_REMOVEFROMCRL, "removeFromCRL"}
    };
    return table2string(s, reason_tbl, 8);
}


getbnfrombuf

decompiled_code:
__int64 __fastcall getbnfrombuf(_BYTE *a1, __int64 a2)
{
__int64 v2; // r12

if ( !*a1 )
{
while ( a2 )
{
++a1;
--a2;
if ( *a1 )
goto LABEL_6;
}
goto LABEL_5;
}
LABEL_6:
if ( !a2 )
{
LABEL_5:
v2 = BN_new();
BN_set_word(v2, 0LL);
return v2;
}
return BN_bin2bn(a1, a2, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func3(_BYTE *a1, __int64 a2)
{
__int64 v2; // r12

if ( !*a1 )
{
while ( a2 )
{
++a1;
--a2;
if ( *a1 )
goto LABEL_6;
}
goto LABEL_5;
}
LABEL_6:
if ( !a2 )
{
LABEL_5:
v2 = BN_new();
BN_set_word(v2, 0LL);
return v2;
}
return BN_bin2bn(a1, a2, 0LL);
}

original_code:
BIGNUM *getbnfrombuf(const unsigned char *buf, size_t len)
{
    while (*buf == 0 && len > 0) {
        buf++;
        len--;
    }
    if (len) {
        return BN_bin2bn(buf, len, ((void *)0));
    } else {
        BIGNUM *b = BN_new();
        (BN_set_word((b),0));
        return b;
    }
}

canonical_original_code:
struct bignum_st *getbnfrombuf(unsigned char *buf, unsigned long len)
{
    while (*buf == 0 && len > 0) {
        buf++;
        len--;
    }
    if (len) {
        return BN_bin2bn(buf, len, ((void *)0));
    } else {
        struct bignum_st *b = BN_new();
        (BN_set_word((b),0));
        return b;
    }
}

variable_types:
buf
unsigned char *

variable_types:
len
unsigned long

return_type: struct bignum_st { unsigned long *d; int top; int dmax; int neg; int flags; } *


decompiled_code:
__int64 __fastcall hashsum2bn(char *a1)
{
char *v1; // rax
char v2; // dl
char *v3; // rdx
_BYTE v5[31]; // [rsp+0h] [rbp-28h] BYREF
char v6; // [rsp+1Fh] [rbp-9h] BYREF

v1 = &v6;
do
{
v2 = *a1++;
*v1 = v2;
v3 = v1--;
}
while ( v3 != v5 );
return getbnfrombuf(v5, 32LL);
}

canonical_decompiled_code:
__int64 __fastcall func4(char *a1)
{
char *v1; // rax
char v2; // dl
char *v3; // rdx
_BYTE v5[31]; // [rsp+0h] [rbp-28h] BYREF
char v6; // [rsp+1Fh] [rbp-9h] BYREF

v1 = &v6;
do
{
v2 = *a1++;
*v1 = v2;
v3 = v1--;
}
while ( v3 != v5 );
return func3(v5, 32LL);
}

original_code:
BIGNUM *hashsum2bn(const unsigned char *dgst)
{
    unsigned char buf[32];
    int i;
    for (i = 0; i < 32; i++) {
        buf[31 - i] = dgst[i];
    }
    return getbnfrombuf(buf, 32);
}

canonical_original_code:
struct bignum_st *hashsum2bn(unsigned char *dgst)
{
    unsigned char buf[32];
    int i;
    for (i = 0; i < 32; i++) {
        buf[31 - i] = dgst[i];
    }
    return getbnfrombuf(buf, 32);
}

variable_types:
dgst
unsigned char *

variable_types:
buf
unsigned char [32]

variable_types: i int

user_defined_types: struct bignum_st { unsigned long *d; int top; int dmax; int neg; int flags; }


decompiled_code:
__int64 __fastcall store_bignum(__int64 a1, char *a2, int a3)
{
size_t v3; // r12
int v4; // eax
int v5; // ebx
int v6; // eax
__int64 result; // rax
int v8; // ebx

v3 = a3;
v4 = BN_num_bits();
v5 = v4 + 14;
v6 = v4 + 7;
if ( v6 >= 0 )
v5 = v6;
result = 0LL;
v8 = v5 >> 3;
if ( v8 <= (int)v3 )
{
memset(a2, 0, v3);
BN_bn2bin(a1, &a2[v3 - v8]);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, char *a2, int a3)
{
size_t v3; // r12
int v4; // eax
int v5; // ebx
int v6; // eax
__int64 result; // rax
int v8; // ebx

v3 = a3;
v4 = BN_num_bits();
v5 = v4 + 14;
v6 = v4 + 7;
if ( v6 >= 0 )
v5 = v6;
result = 0LL;
v8 = v5 >> 3;
if ( v8 <= (int)v3 )
{
memset(a2, 0, v3);
BN_bn2bin(a1, &a2[v3 - v8]);
result = 1LL;
}
return result;
}

original_code:
int store_bignum(BIGNUM *bn, unsigned char *buf, int len)
{
    int bytes = ((BN_num_bits(bn)+7)/8);
    if (bytes > len)
        return 0;
    memset(buf, 0, len);
    BN_bn2bin(bn, buf + len - bytes);
    return 1;
}

canonical_original_code:
int store_bignum(struct bignum_st *bn, unsigned char *buf, int len)
{
    int bytes = ((BN_num_bits(bn)+7)/8);
    if (bytes > len)
        return 0;
    memset(buf, 0, len);
    BN_bn2bin(bn, buf + len - bytes);
    return 1;
}

variable_types: len int

variable_types: bytes int


decompiled_code:
__int64 __fastcall pack_sign_cp(__int64 *a1, int a2, void *a3, _QWORD *a4)
{
*a4 = 2 * a2;
memset(a3, 0, 2 * a2);
store_bignum(a1[1], (char *)a3, a2);
store_bignum(*a1, (char *)a3 + a2, a2);
DSA_SIG_free(a1);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 *a1, int a2, void *a3, _QWORD *a4)
{
*a4 = 2 * a2;
memset(a3, 0, 2 * a2);
func6(a1[1], (char *)a3, a2);
func6(*a1, (char *)a3 + a2, a2);
DSA_SIG_free(a1);
return 1LL;
}

original_code:
int pack_sign_cp(DSA_SIG *s, int order, unsigned char *sig, size_t *siglen)
{
    *siglen = 2 * order;
    memset(sig, 0, *siglen);
    store_bignum(s->s, sig, order);
    store_bignum(s->r, sig + order, order);
    ;
    DSA_SIG_free(s);
    return 1;
}

canonical_original_code:
int pack_sign_cp(struct DSA_SIG_st *s, int order, unsigned char *sig, unsigned long *siglen)
{
    *siglen = 2 * order;
    memset(sig, 0, *siglen);
    store_bignum(s->s, sig, order);
    store_bignum(s->r, sig + order, order);
    ;
    DSA_SIG_free(s);
    return 1;
}

variable_types: struct DSA_SIG_st { struct bignum_st { unsigned long *d; int top; int dmax; int neg; int flags; } *r; struct bignum_st *s; } *

variable_types: order int

variable_types:
sig
unsigned char *

variable_types:
siglen
unsigned long *

user_defined_types: struct DSA_SIG_st { struct bignum_st *r; struct bignum_st *s; }


decompiled_code:
__int64 __fastcall asn1_get_length(unsigned __int8 **a1, _DWORD *a2, __int64 *a3, int a4)
{
char *v6; // rsi
unsigned __int8 *v7; // rax
unsigned __int8 v8; // r8
__int64 v9; // rdx
__int64 result; // rax
unsigned __int8 *v11; // rcx
unsigned __int8 *v12; // r8
__int64 v13; // rsi

if ( a4 <= 0 )
return 0LL;
v6 = (char *)*a1;
v7 = *a1 + 1;
if ( **a1 != 0x80 )
{
*a2 = 0;
v8 = *v6 & 0x7F;
v9 = v8;
if ( *v6 >= 0 )
goto LABEL_4;
if ( v8 <= 8u && a4 != 1 )
{
v9 = 0LL;
v11 = (unsigned __int8 *)&v6[a4];
v12 = (unsigned __int8 *)&v6[(unsigned __int8)(v8 + 1)];
while ( v7 != v12 )
{
v13 = *v7++;
v9 = v13 | (v9 << 8);
if ( v7 == v11 )
return 0LL;
}
if ( v9 >= 0 )
{
LABEL_4:
*a1 = v7;
result = 1LL;
*a3 = v9;
return result;
}
}
return 0LL;
}
*a2 = 1;
*a1 = v7;
result = 1LL;
*a3 = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned __int8 **a1, _DWORD *a2, __int64 *a3, int a4)
{
char *v6; // rsi
unsigned __int8 *v7; // rax
unsigned __int8 v8; // r8
__int64 v9; // rdx
__int64 result; // rax
unsigned __int8 *v11; // rcx
unsigned __int8 *v12; // r8
__int64 v13; // rsi

if ( a4 <= 0 )
return 0LL;
v6 = (char *)*a1;
v7 = *a1 + 1;
if ( **a1 != 0x80 )
{
*a2 = 0;
v8 = *v6 & 0x7F;
v9 = v8;
if ( *v6 >= 0 )
goto LABEL_4;
if ( v8 <= 8u && a4 != 1 )
{
v9 = 0LL;
v11 = (unsigned __int8 *)&v6[a4];
v12 = (unsigned __int8 *)&v6[(unsigned __int8)(v8 + 1)];
while ( v7 != v12 )
{
v13 = *v7++;
v9 = v13 | (v9 << 8);
if ( v7 == v11 )
return 0LL;
}
if ( v9 >= 0 )
{
LABEL_4:
*a1 = v7;
result = 1LL;
*a3 = v9;
return result;
}
}
return 0LL;
}
*a2 = 1;
*a1 = v7;
result = 1LL;
*a3 = 0LL;
return result;
}

original_code:
static int asn1_get_length(const unsigned char **pp, int *inf, long *rl,
                           int max)
{
    const unsigned char *p = *pp;
    unsigned long ret = 0;
    unsigned int i;

    if (max-- < 1)
        return (0);
    if (*p == 0x80) {
        *inf = 1;
        ret = 0;
        p++;
    } else {
        *inf = 0;
        i = *p & 0x7f;
        if (*(p++) & 0x80) {
            if (i > sizeof(long))
                return 0;
            if (max-- == 0)
                return (0);
            while (i-- > 0) {
                ret <<= 8L;
                ret |= *(p++);
                if (max-- == 0)
                    return (0);
            }
        } else
            ret = i;
    }
    if (ret > LONG_MAX)
        return 0;
    *pp = p;
    *rl = (long)ret;
    return (1);
}

canonical_original_code:
static int asn1_get_length(unsigned char **pp, int *inf, long *rl, int max)
{
    unsigned char *p = *pp;
    unsigned long ret = 0;
    unsigned int i;

    if (max-- < 1)
        return (0);
    if (*p == 0x80) {
        *inf = 1;
        ret = 0;
        p++;
    } else {
        *inf = 0;
        i = *p & 0x7f;
        if (*(p++) & 0x80) {
            if (i > sizeof(long))
                return 0;
            if (max-- == 0)
                return (0);
            while (i-- > 0) {
                ret <<= 8L;
                ret |= *(p++);
                if (max-- == 0)
                    return (0);
            }
        } else
            ret = i;
    }
    if (ret > LONG_MAX)
        return 0;
    *pp = p;
    *rl = (long)ret;
    return (1);
}

variable_types:
pp
unsigned char **

variable_types:
inf
int *

variable_types:
rl
long *

variable_types: max int

variable_types:
p
unsigned char *

variable_types:
ret
unsigned long

variable_types:
i
unsigned int


decompiled_code:
// attributes: thunk
__int64 __fastcall ASN1_check_infinite_end(_QWORD *a1, __int64 a2)
{
return asn1_check_infinite_end(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func3(_QWORD *a1, __int64 a2)
{
return func0(a1, a2);
}

original_code:
int ASN1_check_infinite_end(unsigned char **p, long len)
{
    return _asn1_check_infinite_end((const unsigned char **)p, len);
}

canonical_original_code:
int ASN1_check_infinite_end(unsigned char **p, long len)
{
    return _asn1_check_infinite_end((unsigned char **)p, len);
}

variable_types:
p
unsigned char **

variable_types: len long


decompiled_code:
// attributes: thunk
__int64 __fastcall ASN1_const_check_infinite_end(_QWORD *a1, __int64 a2)
{
return ASN1_check_infinite_end(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func5(_QWORD *a1, __int64 a2)
{
return func3(a1, a2);
}

original_code:
int ASN1_const_check_infinite_end(const unsigned char **p, long len)
{
    return _asn1_check_infinite_end(p, len);
}

canonical_original_code:
int ASN1_const_check_infinite_end(unsigned char **p, long len)
{
    return _asn1_check_infinite_end(p, len);
}


original_code:
int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag,
                    int *pclass, long omax)
{
    int i, ret;
    long l;
    const unsigned char *p = *pp;
    int tag, xclass, inf;
    long max = omax;

    if (!max)
        goto err;
    ret = (*p & V_ASN1_CONSTRUCTED);
    xclass = (*p & V_ASN1_PRIVATE);
    i = *p & V_ASN1_PRIMITIVE_TAG;
    if (i == V_ASN1_PRIMITIVE_TAG) { /* high-tag */
        p++;
        if (--max == 0)
            goto err;
        l = 0;
        while (*p & 0x80) {
            l <<= 7L;
            l |= *(p++) & 0x7f;
            if (--max == 0)
                goto err;
            if (l > (INT_MAX >> 7L))
                goto err;
        }
        l <<= 7L;
        l |= *(p++) & 0x7f;
        tag = (int)l;
        if (--max == 0)
            goto err;
    } else {
        tag = i;
        p++;
        if (--max == 0)
            goto err;
    }
    *ptag = tag;
    *pclass = xclass;
    if (!asn1_get_length(&p, &inf, plength, (int)max))
        goto err;

    if (inf && !(ret & V_ASN1_CONSTRUCTED))
        goto err;

#if 0
    fprintf(stderr, "p=%d + *plength=%ld > omax=%ld + *pp=%d  (%d > %d)\n",
            (int)p, *plength, omax, (int)*pp, (int)(p + *plength),
            (int)(omax + *pp));

#endif
    if (*plength > (omax - (p - *pp))) {
        ASN1err(ASN1_F_ASN1_GET_OBJECT, ASN1_R_TOO_LONG);
        /*
         * Set this so that even if things are not long enough the values are
         * set correctly
         */
        ret |= 0x80;
    }
    *pp = p;
    return (ret | inf);
 err:
    ASN1err(ASN1_F_ASN1_GET_OBJECT, ASN1_R_HEADER_TOO_LONG);
    return (0x80);
}

canonical_original_code:
int ASN1_get_object(unsigned char **pp, long *plength, int *ptag, int *pclass, long omax)
{
    int i; int ret;
    long l;
    unsigned char *p = *pp;
    int tag; int xclass; int inf;
    long max = omax;

    if (!max)
        goto err;
    ret = (*p & V_ASN1_CONSTRUCTED);
    xclass = (*p & V_ASN1_PRIVATE);
    i = *p & V_ASN1_PRIMITIVE_TAG;
    if (i == V_ASN1_PRIMITIVE_TAG) { /* high-tag */
        p++;
        if (--max == 0)
            goto err;
        l = 0;
        while (*p & 0x80) {
            l <<= 7L;
            l |= *(p++) & 0x7f;
            if (--max == 0)
                goto err;
            if (l > (INT_MAX >> 7L))
                goto err;
        }
        l <<= 7L;
        l |= *(p++) & 0x7f;
        tag = (int)l;
        if (--max == 0)
            goto err;
    } else {
        tag = i;
        p++;
        if (--max == 0)
            goto err;
    }
    *ptag = tag;
    *pclass = xclass;
    if (!asn1_get_length(&p, &inf, plength, (int)max))
        goto err;

    if (inf && !(ret & V_ASN1_CONSTRUCTED))
        goto err;

#if 0
    fprintf(stderr, "p=%d + *plength=%ld > omax=%ld + *pp=%d  (%d > %d)\n",
            (int)p, *plength, omax, (int)*pp, (int)(p + *plength),
            (int)(omax + *pp));

#endif
    if (*plength > (omax - (p - *pp))) {
        ASN1err(ASN1_F_ASN1_GET_OBJECT, ASN1_R_TOO_LONG);
        /*
         * Set this so that even if things are not long enough the values are
         * set correctly
         */
        ret |= 0x80;
    }
    *pp = p;
    return (ret | inf);
 err:
    ASN1err(ASN1_F_ASN1_GET_OBJECT, ASN1_R_HEADER_TOO_LONG);
    return (0x80);
}

variable_types:
plength
long *

variable_types:
ptag
int *

variable_types:
pclass
int *

variable_types: omax long

variable_types: ret int

variable_types: l long

variable_types: tag int

variable_types: xclass int

variable_types: inf int

variable_types: max long


decompiled_code:
__int64 __fastcall ASN1_put_eoc(_WORD **a1)
{
_WORD *v1; // rax

v1 = *a1;
*v1 = 0;
*a1 = v1 + 1;
return 2LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(_WORD **a1)
{
_WORD *v1; // rax

v1 = *a1;
*v1 = 0;
*a1 = v1 + 1;
return 2LL;
}

original_code:
int ASN1_put_eoc(unsigned char **pp)
{
    unsigned char *p = *pp;
    *p++ = 0;
    *p++ = 0;
    *pp = p;
    return 2;
}

variable_types:
pp
unsigned char **


decompiled_code:
__int64 __fastcall ASN1_object_size(int a1, int a2, int a3)
{
int v3; // eax
__int64 result; // rax
int v5; // edx

v3 = a2 + 1;
if ( a3 > 30 )
{
do
{
++v3;
v5 = a3 >> 7;
if ( !v5 )
break;
++v3;
a3 = v5 >> 7;
}
while ( a3 );
}
if ( a1 == 2 )
return (unsigned int)(v3 + 3);
result = (unsigned int)(v3 + 1);
if ( a2 > 127 )
{
do
{
result = (unsigned int)(result + 1);
a2 >>= 8;
}
while ( a2 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(int a1, int a2, int a3)
{
int v3; // eax
__int64 result; // rax
int v5; // edx

v3 = a2 + 1;
if ( a3 > 30 )
{
do
{
++v3;
v5 = a3 >> 7;
if ( !v5 )
break;
++v3;
a3 = v5 >> 7;
}
while ( a3 );
}
if ( a1 == 2 )
return (unsigned int)(v3 + 3);
result = (unsigned int)(v3 + 1);
if ( a2 > 127 )
{
do
{
result = (unsigned int)(result + 1);
a2 >>= 8;
}
while ( a2 );
}
return result;
}

original_code:
int ASN1_object_size(int constructed, int length, int tag)
{
    int ret;

    ret = length;
    ret++;
    if (tag >= 31) {
        while (tag > 0) {
            tag >>= 7;
            ret++;
        }
    }
    if (constructed == 2)
        return ret + 3;
    ret++;
    if (length > 127) {
        while (length > 0) {
            length >>= 8;
            ret++;
        }
    }
    return (ret);
}

variable_types: constructed int

variable_types: length int