repo: aerospike/aerospike-common

decompiled_code:
__int64 __fastcall as_serializer_cons(__int64 a1, char a2, __int64 a3)
{
__int64 result; // rax

result = a1;
if ( a1 )
{
*(_BYTE *)a1 = a2;
*(_QWORD *)(a1 + 8) = a3;
}
return result;
}

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

result = a1;
if ( a1 )
{
*(_BYTE *)a1 = a2;
*(_QWORD *)(a1 + 8) = a3;
}
return result;
}

original_code:
as_serializer *as_serializer_cons(as_serializer *serializer, _Bool free, const as_serializer_hooks *hooks)
{
 if (! serializer) {
  return serializer;
 }
 serializer->free = free;
 serializer->hooks = hooks;
 return serializer;
}

canonical_original_code:
struct as_serializer_s *as_serializer_cons(struct as_serializer_s *serializer, _Bool free, struct as_serializer_hooks_s *hooks)
{
 if (! serializer) {
  return serializer;
 }
 serializer->free = free;
 serializer->hooks = hooks;
 return serializer;
}

variable_types:
serializer
struct as_serializer_s *

variable_types:
hooks
struct as_serializer_hooks_s *

return_type: struct as_serializer_s { _Bool free; struct as_serializer_hooks_s { void (*destroy)(struct as_serializer_s *); int (*serialize)(struct as_serializer_s *, struct as_val_s { unsigned int count; unsigned char type; _Bool free; } *, struct as_buffer_s { unsigned int capacity; unsigned int size; unsigned char *data; } *); int (*serialize_presized)(struct as_serializer_s *, struct as_val_s *, unsigned char *); int (*deserialize)(struct as_serializer_s *, struct as_buffer_s *, struct as_val_s **); unsigned int (*serialize_getsize)(struct as_serializer_s *, struct as_val_s *); } *hooks; } *

user_defined_types: struct as_serializer_s { _Bool free; struct as_serializer_hooks_s *hooks; }

user_defined_types: struct as_serializer_hooks_s { void (*destroy)(struct as_serializer_s *); int (*serialize)(struct as_serializer_s *, struct as_val_s *, struct as_buffer_s *); int (*serialize_presized)(struct as_serializer_s *, struct as_val_s *, unsigned char *); int (*deserialize)(struct as_serializer_s *, struct as_buffer_s *, struct as_val_s **); unsigned int (*serialize_getsize)(struct as_serializer_s *, struct as_val_s *); }


decompiled_code:
__int64 __fastcall as_serializer_init(__int64 a1, __int64 a2)
{
return as_serializer_cons(a1, 0, a2);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
return func0(a1, 0, a2);
}

original_code:
as_serializer *as_serializer_init(as_serializer *serializer, const as_serializer_hooks *hooks)
{
 return as_serializer_cons(serializer, 0, hooks);
}

canonical_original_code:
struct as_serializer_s *as_serializer_init(struct as_serializer_s *serializer, struct as_serializer_hooks_s *hooks)
{
 return as_serializer_cons(serializer, 0, hooks);
}

user_defined_types: struct as_val_s { unsigned int count; unsigned char type; _Bool free; }

user_defined_types: struct as_buffer_s { unsigned int capacity; unsigned int size; unsigned char *data; }


decompiled_code:
__int64 __fastcall as_serializer_new(__int64 a1)
{
__int64 v1; // rax

v1 = cf_malloc(16LL);
return as_serializer_cons(v1, 1, a1);
}

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

v1 = cf_malloc(16LL);
return func0(v1, 1, a1);
}

original_code:
as_serializer *as_serializer_new(const as_serializer_hooks *hooks)
{
 as_serializer *serializer = (as_serializer *)cf_malloc(sizeof(as_serializer));
 return as_serializer_cons(serializer, 1, hooks);
}

canonical_original_code:
struct as_serializer_s *as_serializer_new(struct as_serializer_hooks_s *hooks)
{
 struct as_serializer_s *serializer = (as_serializer *)cf_malloc(sizeof(as_serializer));
 return as_serializer_cons(serializer, 1, hooks);
}

variable_types: struct as_serializer_s { _Bool free; struct as_serializer_hooks_s { void (*destroy)(struct as_serializer_s *); int (*serialize)(struct as_serializer_s *, struct as_val_s { unsigned int count; unsigned char type; _Bool free; } *, struct as_buffer_s { unsigned int capacity; unsigned int size; unsigned char *data; } *); int (*serialize_presized)(struct as_serializer_s *, struct as_val_s *, unsigned char *); int (*deserialize)(struct as_serializer_s *, struct as_buffer_s *, struct as_val_s **); unsigned int (*serialize_getsize)(struct as_serializer_s *, struct as_val_s *); } *hooks; } *


decompiled_code:
__int64 __fastcall as_serializer_destroy(_BYTE *a1)
{
__int64 result; // rax

if ( *a1 )
result = cf_free();
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(_BYTE *a1)
{
__int64 result; // rax

if ( *a1 )
result = cf_free();
return result;
}

original_code:
void as_serializer_destroy(as_serializer *serializer)
{
 if (serializer->free) {
  cf_free(serializer);
 }
}

canonical_original_code:
void as_serializer_destroy(struct as_serializer_s *serializer)
{
 if (serializer->free) {
  cf_free(serializer);
 }
}

return_type: void


decompiled_code:
void as_val_destroy_noop()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
static void as_val_destroy_noop(as_val * v)
{
 return;
}

canonical_original_code:
static void as_val_destroy_noop(struct as_val_s *v)
{
 return;
}

variable_types: struct as_val_s { unsigned int count; unsigned char type; _Bool free; } *


decompiled_code:
__int64 __fastcall as_val_reserve_noop(__int64 a1)
{
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
return a1;
}

original_code:
static as_val * as_val_reserve_noop(as_val * v)
{
 return v;
}

canonical_original_code:
static struct as_val_s *as_val_reserve_noop(struct as_val_s *v)
{
 return v;
}

variable_types:
v
struct as_val_s *

return_type: struct as_val_s { unsigned int count; unsigned char type; _Bool free; } *


decompiled_code:
__int64 as_val_hashcode_noop()
{
return 0LL;
}

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

original_code:
static uint32_t as_val_hashcode_noop(const as_val * v)
{
 return 0;
}

canonical_original_code:
static unsigned int as_val_hashcode_noop(struct as_val_s *v)
{
 return 0;
}

return_type: unsigned int


decompiled_code:
__int64 as_val_tostring_noop()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func3()
{
return 0LL;
}

original_code:
static char * as_val_tostring_noop(const as_val * v)
{
 return 0;
}

canonical_original_code:
static char *as_val_tostring_noop(struct as_val_s *v)
{
 return 0;
}

return_type: char *


decompiled_code:
void __fastcall as_incr_uint32(volatile signed __int32 *a1)
{
_InterlockedAdd(a1, 1u);
}

canonical_decompiled_code:
void __fastcall func4(volatile signed __int32 *a1)
{
_InterlockedAdd(a1, 1u);
}

original_code:
static inline void
as_incr_uint32(uint32_t* target)
{
 __atomic_fetch_add(target, 1, 0);
}

canonical_original_code:
static inline void as_incr_uint32(unsigned int *target)
{
 __atomic_fetch_add(target, 1, 0);
}

variable_types:
target
unsigned int *


decompiled_code:
void __fastcall as_val_reserve_count(volatile signed __int32 *a1)
{
as_incr_uint32(a1);
}

canonical_decompiled_code:
void __fastcall func5(volatile signed __int32 *a1)
{
func4(a1);
}

original_code:
static as_val * as_val_reserve_count(as_val * v)
{
 as_incr_uint32(&v->count);
 return v;
}

canonical_original_code:
static struct as_val_s *as_val_reserve_count(struct as_val_s *v)
{
 as_incr_uint32(&v->count);
 return v;
}


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

if ( a1 )
result = ((__int64 (__fastcall *)(__int64))*(&as_val_reserve_callbacks + *(unsigned __int8 *)(a1 + 4)))(a1);
else
result = 0LL;
return result;
}

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

if ( a1 )
result = ((__int64 (__fastcall *)(__int64))*(&as_val_reserve_callbacks + *(unsigned __int8 *)(a1 + 4)))(a1);
else
result = 0LL;
return result;
}

original_code:
as_val * as_val_val_reserve(as_val * v)
{
 if ( !v ) return v;
 return as_val_reserve_callbacks[ v->type ](v);
}

canonical_original_code:
struct as_val_s *as_val_val_reserve(struct as_val_s *v)
{
 if ( !v ) return v;
 return as_val_reserve_callbacks[ v->type ](v);
}


decompiled_code:
__int64 __fastcall as_val_val_destroy(__int64 a1)
{
if ( !a1 )
return 0LL;
if ( !*(_DWORD *)a1 || (unsigned int)as_aaf_uint32_rls_constprop_0((volatile signed __int32 *)a1) )
return a1;
(*(&as_val_destroy_callbacks + *(unsigned __int8 *)(a1 + 4)))();
if ( *(_BYTE *)(a1 + 5) )
cf_free(a1);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
if ( !a1 )
return 0LL;
if ( !*(_DWORD *)a1 || (unsigned int)func6((volatile signed __int32 *)a1) )
return a1;
(*(&as_val_destroy_callbacks + *(unsigned __int8 *)(a1 + 4)))();
if ( *(_BYTE *)(a1 + 5) )
cf_free(a1);
return 0LL;
}

original_code:
as_val * as_val_val_destroy(as_val * v)
{
 if (v == ((void *)0) || !v->count) {
  return v;
 }
 if (as_aaf_uint32_rls(&v->count, -1) == 0) {
  __atomic_thread_fence(2);
  as_val_destroy_callbacks[v->type](v);
  if (v->free) {
   cf_free(v);
  }
  v = ((void *)0);
 }
 return v;
}

canonical_original_code:
struct as_val_s *as_val_val_destroy(struct as_val_s *v)
{
 if (v == ((void *)0) || !v->count) {
  return v;
 }
 if (as_aaf_uint32_rls(&v->count, -1) == 0) {
  __atomic_thread_fence(2);
  as_val_destroy_callbacks[v->type](v);
  if (v->free) {
   cf_free(v);
  }
  v = ((void *)0);
 }
 return v;
}


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

if ( a1 )
result = (*(&as_val_hashcode_callbacks + *(unsigned __int8 *)(a1 + 4)))();
else
result = 0LL;
return result;
}

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

if ( a1 )
result = (*(&as_val_hashcode_callbacks + *(unsigned __int8 *)(a1 + 4)))();
else
result = 0LL;
return result;
}

original_code:
uint32_t as_val_val_hashcode(const as_val * v)
{
 if (v == 0) return 0;
 return as_val_hashcode_callbacks[ v->type ](v);
}

canonical_original_code:
unsigned int as_val_val_hashcode(struct as_val_s *v)
{
 if (v == 0) return 0;
 return as_val_hashcode_callbacks[ v->type ](v);
}


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

if ( a1 )
result = (*(&as_val_tostring_callbacks + *(unsigned __int8 *)(a1 + 4)))();
else
result = 0LL;
return result;
}

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

if ( a1 )
result = (*(&as_val_tostring_callbacks + *(unsigned __int8 *)(a1 + 4)))();
else
result = 0LL;
return result;
}

original_code:
char * as_val_val_tostring(const as_val * v)
{
 if (v == 0) return 0;
 return as_val_tostring_callbacks[ v->type ](v);
}

canonical_original_code:
char *as_val_val_tostring(struct as_val_s *v)
{
 if (v == 0) return 0;
 return as_val_tostring_callbacks[ v->type ](v);
}


decompiled_code:
__int64 __fastcall as_val_tobool(__int64 a1)
{
char v1; // al
unsigned int v2; // er8

if ( !a1 )
return 0LL;
v1 = *(_BYTE *)(a1 + 4);
if ( v1 == 2 )
return *(unsigned __int8 *)(a1 + 8);
v2 = 0;
if ( v1 == 3 )
LOBYTE(v2) = *(_QWORD *)(a1 + 8) != 0LL;
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1)
{
char v1; // al
unsigned int v2; // er8

if ( !a1 )
return 0LL;
v1 = *(_BYTE *)(a1 + 4);
if ( v1 == 2 )
return *(unsigned __int8 *)(a1 + 8);
v2 = 0;
if ( v1 == 3 )
LOBYTE(v2) = *(_QWORD *)(a1 + 8) != 0LL;
return v2;
}

original_code:
_Bool as_val_tobool(const as_val* v)
{
 if (!v) {
  return 0;
 }
 if (v->type == AS_BOOLEAN) {
  return ((as_boolean*)v)->value;
 }
 if (v->type == AS_INTEGER) {
  return ((as_integer*)v)->value;
 }
 return 0;
}

canonical_original_code:
_Bool as_val_tobool(struct as_val_s *v)
{
 if (!v) {
  return 0;
 }
 if (v->type == AS_BOOLEAN) {
  return ((struct as_boolean_s *)v)->value;
 }
 if (v->type == AS_INTEGER) {
  return ((struct as_integer_s *)v)->value;
 }
 return 0;
}

user_defined_types: struct as_boolean_s { struct as_val_s _; _Bool value; }

user_defined_types: struct as_integer_s { struct as_val_s _; long value; }


decompiled_code:
__int64 __fastcall as_timer_init(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

result = a1;
if ( a1 )
{
*(_QWORD *)(a1 + 8) = a2;
*(_QWORD *)(a1 + 16) = a3;
}
return result;
}

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

result = a1;
if ( a1 )
{
*(_QWORD *)(a1 + 8) = a2;
*(_QWORD *)(a1 + 16) = a3;
}
return result;
}

original_code:
as_timer * as_timer_init(as_timer * timer, void * source, const as_timer_hooks * hooks) {
    if ( timer == ((void *)0) ) return timer;
    timer->source = source;
    timer->hooks = hooks;
    return timer;
}

canonical_original_code:
struct as_timer_s *as_timer_init(struct as_timer_s *timer, void *source, struct as_timer_hooks_s *hooks) {
    if ( timer == ((void *)0) ) return timer;
    timer->source = source;
    timer->hooks = hooks;
    return timer;
}

variable_types:
timer
struct as_timer_s *

variable_types:
source
void *

variable_types:
hooks
struct as_timer_hooks_s *

return_type: struct as_timer_s { _Bool is_malloc; void *source; struct as_timer_hooks_s { int (*destroy)(struct as_timer_s *); _Bool (*timedout)(struct as_timer_s *); unsigned long (*timeslice)(struct as_timer_s *); } *hooks; } *

user_defined_types: struct as_timer_s { _Bool is_malloc; void *source; struct as_timer_hooks_s *hooks; }


decompiled_code:
__int64 __fastcall as_timer_new(__int64 a1, __int64 a2)
{
__int64 result; // rax

result = cf_malloc(24LL);
if ( result )
{
*(_QWORD *)(result + 8) = a1;
*(_QWORD *)(result + 16) = a2;
}
return result;
}

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

result = cf_malloc(24LL);
if ( result )
{
*(_QWORD *)(result + 8) = a1;
*(_QWORD *)(result + 16) = a2;
}
return result;
}

original_code:
as_timer * as_timer_new(void * source, const as_timer_hooks * hooks) {
    as_timer * timer = (as_timer *) cf_malloc(sizeof(as_timer));
    if (!timer) return timer;
    timer->source = source;
    timer->hooks = hooks;
    return timer;
}

canonical_original_code:
struct as_timer_s *as_timer_new(void *source, struct as_timer_hooks_s *hooks) {
    struct as_timer_s *timer = (as_timer *) cf_malloc(sizeof(as_timer));
    if (!timer) return timer;
    timer->source = source;
    timer->hooks = hooks;
    return timer;
}

variable_types: struct as_timer_s { _Bool is_malloc; void *source; struct as_timer_hooks_s { int (*destroy)(struct as_timer_s *); _Bool (*timedout)(struct as_timer_s *); unsigned long (*timeslice)(struct as_timer_s *); } *hooks; } *


decompiled_code:
__int64 __fastcall as_timer_destroy(__int64 a1)
{
__int64 result; // rax
__int64 (**v2)(void); // rdx
__int64 (*v3)(void); // rdx

result = 1LL;
if ( a1 )
{
v2 = *(__int64 (***)(void))(a1 + 16);
if ( v2 )
{
v3 = *v2;
if ( v3 )
{
result = v3();
if ( !(_DWORD)result )
{
if ( *(_BYTE *)a1 )
{
cf_free(a1);
result = 0LL;
}
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
__int64 result; // rax
__int64 (**v2)(void); // rdx
__int64 (*v3)(void); // rdx

result = 1LL;
if ( a1 )
{
v2 = *(__int64 (***)(void))(a1 + 16);
if ( v2 )
{
v3 = *v2;
if ( v3 )
{
result = v3();
if ( !(_DWORD)result )
{
if ( *(_BYTE *)a1 )
{
cf_free(a1);
result = 0LL;
}
}
}
}
}
return result;
}

original_code:
int as_timer_destroy(as_timer * timer) {
    int rc = (timer && timer->hooks && timer->hooks->destroy ? timer->hooks->destroy(timer) : 1);
    if ( rc == 0 && timer->is_malloc ) {
        cf_free(timer);
    }
    return rc;
}

canonical_original_code:
int as_timer_destroy(struct as_timer_s *timer) {
    int rc = (timer && timer->hooks && timer->hooks->destroy ? timer->hooks->destroy(timer) : 1);
    if ( rc == 0 && timer->is_malloc ) {
        cf_free(timer);
    }
    return rc;
}

variable_types: rc int

return_type: int

user_defined_types: struct as_timer_hooks_s { int (*destroy)(struct as_timer_s *); _Bool (*timedout)(struct as_timer_s *); unsigned long (*timeslice)(struct as_timer_s *); }


decompiled_code:
__int64 __fastcall as_timer_timeslice(__int64 a1)
{
__int64 v1; // rax
__int64 (*v2)(void); // rax
__int64 result; // rax

if ( a1 && (v1 = *(_QWORD *)(a1 + 16)) != 0 && (v2 = *(__int64 (**)(void))(v1 + 16)) != 0LL )
result = v2();
else
result = 0LL;
return result;
}

original_code:
uint64_t as_timer_timeslice(const as_timer * timer) {
 if (timer == ((void *)0)) return 0;
 return (timer && timer->hooks && timer->hooks->timeslice ? timer->hooks->timeslice(timer) : 0);
}

canonical_original_code:
unsigned long as_timer_timeslice(struct as_timer_s *timer) {
 if (timer == ((void *)0)) return 0;
 return (timer && timer->hooks && timer->hooks->timeslice ? timer->hooks->timeslice(timer) : 0);
}

return_type: unsigned long


decompiled_code:
__int64 __fastcall cf_set_wait_timespec(int a1, struct timespec *a2)
{
__int64 result; // rax
__time_t v3; // rdx
__int64 v4; // rbx

clock_gettime(0, a2);
result = (unsigned int)(1000 * (a1 / 1000));
v3 = a2->tv_sec + a1 / 1000;
a2->tv_sec = v3;
v4 = a2->tv_nsec + 1000000 * (a1 % 1000);
if ( v4 > 1000000000 )
{
a2->tv_nsec = v4 - 1000000000;
a2->tv_sec = v3 + 1;
}
else
{
a2->tv_nsec = v4;
}
return result;
}

original_code:
static inline void
cf_set_wait_timespec(int ms_wait, struct timespec* out)
{
 clock_gettime(0, out);
 out->tv_sec += ms_wait / 1000;
 out->tv_nsec += (ms_wait % 1000) * 1000 * 1000;
 if (out->tv_nsec > (1000 * 1000 * 1000)) {
  out->tv_nsec -= 1000 * 1000 * 1000;
  out->tv_sec++;
 }
}

canonical_original_code:
static inline void cf_set_wait_timespec(int ms_wait, struct timespec *out)
{
 clock_gettime(0, out);
 out->tv_sec += ms_wait / 1000;
 out->tv_nsec += (ms_wait % 1000) * 1000 * 1000;
 if (out->tv_nsec > (1000 * 1000 * 1000)) {
  out->tv_nsec -= 1000 * 1000 * 1000;
  out->tv_sec++;
 }
}

variable_types: struct timespec { long tv_sec; long tv_nsec; } *


decompiled_code:
__int64 __fastcall as_queue_pop_tail(__int64 a1)
{
int v1; // ecx
bool v2; // r8
__int64 result; // rax
unsigned int v4; // ecx
int v5; // er9
unsigned int v6; // esi
const void *v7; // rax
unsigned int v8; // er9
void *v9; // r10

v2 = as_queue_empty_isra_0(*(_DWORD *)(a1 + 12), *(_DWORD *)(a1 + 16));
result = 0LL;
if ( !v2 )
{
v4 = v1 - 1;
v5 = *(_DWORD *)(a1 + 20);
v6 = *(_DWORD *)(a1 + 8);
*(_DWORD *)(a1 + 16) = v4;
v7 = (const void *)as_queue_get_isra_0(*(_QWORD *)a1, v6, v5, v4);
memcpy(v9, v7, v8);
result = 1LL;
if ( *(_DWORD *)(a1 + 12) == *(_DWORD *)(a1 + 16) )
*(_QWORD *)(a1 + 12) = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
int v1; // ecx
bool v2; // r8
__int64 result; // rax
unsigned int v4; // ecx
int v5; // er9
unsigned int v6; // esi
const void *v7; // rax
unsigned int v8; // er9
void *v9; // r10

v2 = func2(*(_DWORD *)(a1 + 12), *(_DWORD *)(a1 + 16));
result = 0LL;
if ( !v2 )
{
v4 = v1 - 1;
v5 = *(_DWORD *)(a1 + 20);
v6 = *(_DWORD *)(a1 + 8);
*(_DWORD *)(a1 + 16) = v4;
v7 = (const void *)func1(*(_QWORD *)a1, v6, v5, v4);
memcpy(v9, v7, v8);
result = 1LL;
if ( *(_DWORD *)(a1 + 12) == *(_DWORD *)(a1 + 16) )
*(_QWORD *)(a1 + 12) = 0LL;
}
return result;
}

original_code:
static inline _Bool
as_queue_pop_tail(as_queue* queue, void* ptr)
{
 if (as_queue_empty(queue)) {
  return 0;
 }
 queue->tail--;
 memcpy(ptr, as_queue_get(queue, queue->tail), queue->item_size);
 if (queue->head == queue->tail) {
  queue->head = queue->tail = 0;
 }
 return 1;
}

canonical_original_code:
static inline _Bool as_queue_pop_tail(struct as_queue_s *queue, void *ptr)
{
 if (as_queue_empty(queue)) {
  return 0;
 }
 queue->tail--;
 memcpy(ptr, as_queue_get(queue, queue->tail), queue->item_size);
 if (queue->head == queue->tail) {
  queue->head = queue->tail = 0;
 }
 return 1;
}

variable_types: struct as_queue_s { unsigned char *data; unsigned int capacity; unsigned int head; unsigned int tail; unsigned int item_size; unsigned int total; unsigned int flags; } *

variable_types:
ptr
void *


decompiled_code:
__int64 __fastcall as_queue_pop(__int64 a1)
{
unsigned int v1; // ecx
bool v2; // r8
__int64 result; // rax
const void *v4; // rax
unsigned int v5; // er9
void *v6; // r10
int v7; // edx

v2 = as_queue_empty_isra_0(*(_DWORD *)(a1 + 12), *(_DWORD *)(a1 + 16));
result = 0LL;
if ( !v2 )
{
v4 = (const void *)as_queue_get_isra_0(*(_QWORD *)a1, *(_DWORD *)(a1 + 8), *(_DWORD *)(a1 + 20), v1);
memcpy(v6, v4, v5);
v7 = *(_DWORD *)(a1 + 12) + 1;
result = 1LL;
*(_DWORD *)(a1 + 12) = v7;
if ( v7 == *(_DWORD *)(a1 + 16) )
*(_QWORD *)(a1 + 12) = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
unsigned int v1; // ecx
bool v2; // r8
__int64 result; // rax
const void *v4; // rax
unsigned int v5; // er9
void *v6; // r10
int v7; // edx

v2 = func2(*(_DWORD *)(a1 + 12), *(_DWORD *)(a1 + 16));
result = 0LL;
if ( !v2 )
{
v4 = (const void *)func1(*(_QWORD *)a1, *(_DWORD *)(a1 + 8), *(_DWORD *)(a1 + 20), v1);
memcpy(v6, v4, v5);
v7 = *(_DWORD *)(a1 + 12) + 1;
result = 1LL;
*(_DWORD *)(a1 + 12) = v7;
if ( v7 == *(_DWORD *)(a1 + 16) )
*(_QWORD *)(a1 + 12) = 0LL;
}
return result;
}

original_code:
static inline _Bool
as_queue_pop(as_queue* queue, void* ptr)
{
 if (as_queue_empty(queue)) {
  return 0;
 }
 memcpy(ptr, as_queue_get(queue, queue->head), queue->item_size);
 queue->head++;
 if (queue->head == queue->tail) {
  queue->head = queue->tail = 0;
 }
 return 1;
}

canonical_original_code:
static inline _Bool as_queue_pop(struct as_queue_s *queue, void *ptr)
{
 if (as_queue_empty(queue)) {
  return 0;
 }
 memcpy(ptr, as_queue_get(queue, queue->head), queue->item_size);
 queue->head++;
 if (queue->head == queue->tail) {
  queue->head = queue->tail = 0;
 }
 return 1;
}

user_defined_types: struct as_queue_s { unsigned char *data; unsigned int capacity; unsigned int head; unsigned int tail; unsigned int item_size; unsigned int total; unsigned int flags; }


decompiled_code:
void __fastcall as_queue_mt_wait(__int64 a1, int a2)
{
int v2; // er8
struct timespec v3[3]; // [rsp-38h] [rbp-38h] BYREF

if ( a2 && as_queue_empty_isra_0(*(_DWORD *)(a1 + 12), *(_DWORD *)(a1 + 16)) )
{
if ( v2 == -1 )
{
do
pthread_cond_wait((pthread_cond_t *)(a1 + 72), (pthread_mutex_t *)(a1 + 32));
while ( as_queue_empty_isra_0(*(_DWORD *)(a1 + 12), *(_DWORD *)(a1 + 16)) );
}
else
{
cf_set_wait_timespec(v2, v3);
pthread_cond_timedwait((pthread_cond_t *)(a1 + 72), (pthread_mutex_t *)(a1 + 32), v3);
}
}
}

canonical_decompiled_code:
void __fastcall func5(__int64 a1, int a2)
{
int v2; // er8
struct timespec v3[3]; // [rsp-38h] [rbp-38h] BYREF

if ( a2 && func2(*(_DWORD *)(a1 + 12), *(_DWORD *)(a1 + 16)) )
{
if ( v2 == -1 )
{
do
pthread_cond_wait((pthread_cond_t *)(a1 + 72), (pthread_mutex_t *)(a1 + 32));
while ( func2(*(_DWORD *)(a1 + 12), *(_DWORD *)(a1 + 16)) );
}
else
{
func0(v2, v3);
pthread_cond_timedwait((pthread_cond_t *)(a1 + 72), (pthread_mutex_t *)(a1 + 32), v3);
}
}
}

original_code:
static void
as_queue_mt_wait(as_queue_mt* queue, int wait_ms)
{
 if (wait_ms == 0 || ! as_queue_empty(&queue->queue)) {
  return;
 }
 if (wait_ms == -1) {
  do {
   pthread_cond_wait(&queue->cond, &queue->lock);
  } while (as_queue_empty(&queue->queue));
  return;
 }
 struct timespec tp;
 cf_set_wait_timespec(wait_ms, &tp);
 pthread_cond_timedwait(&queue->cond, &queue->lock, &tp);
}

canonical_original_code:
static void as_queue_mt_wait(struct as_queue_mt_s *queue, int wait_ms)
{
 if (wait_ms == 0 || ! as_queue_empty(&queue->queue)) {
  return;
 }
 if (wait_ms == -1) {
  do {
   pthread_cond_wait(&queue->cond, &queue->lock);
  } while (as_queue_empty(&queue->queue));
  return;
 }
 struct timespec tp;
 cf_set_wait_timespec(wait_ms, &tp);
 pthread_cond_timedwait(&queue->cond, &queue->lock, &tp);
}

variable_types: struct as_queue_mt_s { struct as_queue_s { unsigned char *data; unsigned int capacity; unsigned int head; unsigned int tail; unsigned int item_size; unsigned int total; unsigned int flags; } queue; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } lock; union pthread_cond_t { struct __pthread_cond_s { union { unsigned long long __wseq; struct { unsigned int __low; unsigned int __high; } __wseq32; }; union { unsigned long long __g1_start; struct { unsigned int __low; unsigned int __high; } __g1_start32; }; unsigned int __g_refs[2]; unsigned int __g_size[2]; unsigned int __g1_orig_size; unsigned int __wrefs; unsigned int __g_signals[2]; } __data; char __size[48]; long long __align; } cond; } *

variable_types: struct timespec { long tv_sec; long tv_nsec; }

user_defined_types: struct as_queue_mt_s { struct as_queue_s queue; union pthread_mutex_t lock; union pthread_cond_t cond; }

user_defined_types: union pthread_mutex_t { struct __pthread_mutex_s __data; char __size[40]; long __align; }

user_defined_types: union pthread_cond_t { struct __pthread_cond_s __data; char __size[48]; long long __align; }

user_defined_types: struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list __list; }


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

v1 = as_queue_init();
if ( !(_BYTE)v1 )
return v1;
if ( !pthread_mutex_init((pthread_mutex_t *)(a1 + 32), 0LL) )
{
if ( !pthread_cond_init((pthread_cond_t *)(a1 + 72), 0LL) )
return v1;
pthread_mutex_destroy((pthread_mutex_t *)(a1 + 32));
}
as_queue_destroy(a1);
return 0LL;
}

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

v1 = as_queue_init();
if ( !(_BYTE)v1 )
return v1;
if ( !pthread_mutex_init((pthread_mutex_t *)(a1 + 32), 0LL) )
{
if ( !pthread_cond_init((pthread_cond_t *)(a1 + 72), 0LL) )
return v1;
pthread_mutex_destroy((pthread_mutex_t *)(a1 + 32));
}
as_queue_destroy(a1);
return 0LL;
}

original_code:
_Bool
as_queue_mt_init(as_queue_mt* queue, uint32_t item_size, uint32_t capacity)
{
 if (! as_queue_init(&queue->queue, item_size, capacity)) {
  return 0;
 }
 if (pthread_mutex_init(&queue->lock, ((void *)0)) != 0) {
  as_queue_destroy(&queue->queue);
  return 0;
 }
 if (pthread_cond_init(&queue->cond, ((void *)0)) != 0) {
  pthread_mutex_destroy(&queue->lock);
  as_queue_destroy(&queue->queue);
  return 0;
 }
 return 1;
}

canonical_original_code:
_Bool as_queue_mt_init(struct as_queue_mt_s *queue, unsigned int item_size, unsigned int capacity)
{
 if (! as_queue_init(&queue->queue, item_size, capacity)) {
  return 0;
 }
 if (pthread_mutex_init(&queue->lock, ((void *)0)) != 0) {
  as_queue_destroy(&queue->queue);
  return 0;
 }
 if (pthread_cond_init(&queue->cond, ((void *)0)) != 0) {
  pthread_mutex_destroy(&queue->lock);
  as_queue_destroy(&queue->queue);
  return 0;
 }
 return 1;
}

variable_types:
capacity
unsigned int

user_defined_types: struct __pthread_cond_s { union { unsigned long long __wseq; struct { unsigned int __low; unsigned int __high; } __wseq32; }; union { unsigned long long __g1_start; struct { unsigned int __low; unsigned int __high; } __g1_start32; }; unsigned int __g_refs[2]; unsigned int __g_size[2]; unsigned int __g1_orig_size; unsigned int __wrefs; unsigned int __g_signals[2]; }

user_defined_types: struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; }


decompiled_code:
__int64 __fastcall as_queue_mt_create(unsigned int a1)
{
__int64 v2; // rax
__int64 v3; // r12
__int64 v5; // rdi

v2 = cf_malloc(120LL);
v3 = v2;
if ( v2 )
{
if ( (unsigned __int8)as_queue_mt_init(v2) )
{
*(_DWORD *)(v3 + 28) = 3;
}
else
{
v5 = v3;
v3 = 0LL;
cf_free(v5, a1);
}
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned int a1)
{
__int64 v2; // rax
__int64 v3; // r12
__int64 v5; // rdi

v2 = cf_malloc(120LL);
v3 = v2;
if ( v2 )
{
if ( (unsigned __int8)func6(v2) )
{
*(_DWORD *)(v3 + 28) = 3;
}
else
{
v5 = v3;
v3 = 0LL;
cf_free(v5, a1);
}
}
return v3;
}

original_code:
as_queue_mt*
as_queue_mt_create(uint32_t item_size, uint32_t capacity)
{
 as_queue_mt* queue = cf_malloc(sizeof(as_queue_mt));
 if (! queue) {
  return ((void *)0);
 }
 if (! as_queue_mt_init(queue, item_size, capacity)) {
  cf_free(queue);
  return ((void *)0);
 }
 queue->queue.flags = 1 | 2;
 return queue;
}

canonical_original_code:
struct as_queue_mt_s *as_queue_mt_create(unsigned int item_size, unsigned int capacity)
{
 struct as_queue_mt_s *queue = cf_malloc(sizeof(as_queue_mt));
 if (! queue) {
  return ((void *)0);
 }
 if (! as_queue_mt_init(queue, item_size, capacity)) {
  cf_free(queue);
  return ((void *)0);
 }
 queue->queue.flags = 1 | 2;
 return queue;
}

return_type: struct as_queue_mt_s { struct as_queue_s { unsigned char *data; unsigned int capacity; unsigned int head; unsigned int tail; unsigned int item_size; unsigned int total; unsigned int flags; } queue; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } lock; union pthread_cond_t { struct __pthread_cond_s { union { unsigned long long __wseq; struct { unsigned int __low; unsigned int __high; } __wseq32; }; union { unsigned long long __g1_start; struct { unsigned int __low; unsigned int __high; } __g1_start32; }; unsigned int __g_refs[2]; unsigned int __g_size[2]; unsigned int __g1_orig_size; unsigned int __wrefs; unsigned int __g_signals[2]; } __data; char __size[48]; long long __align; } cond; } *


decompiled_code:
__int64 __fastcall as_queue_mt_pop(__int64 a1, __int64 a2, int a3)
{
unsigned int v4; // er12

pthread_mutex_lock((pthread_mutex_t *)(a1 + 32));
as_queue_mt_wait(a1, a3);
v4 = as_queue_pop(a1);
pthread_mutex_unlock((pthread_mutex_t *)(a1 + 32));
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, __int64 a2, int a3)
{
unsigned int v4; // er12

pthread_mutex_lock((pthread_mutex_t *)(a1 + 32));
func5(a1, a3);
v4 = func4(a1);
pthread_mutex_unlock((pthread_mutex_t *)(a1 + 32));
return v4;
}

original_code:
_Bool
as_queue_mt_pop(as_queue_mt* queue, void* ptr, int wait_ms)
{
 pthread_mutex_lock(&queue->lock);
 as_queue_mt_wait(queue, wait_ms);
 _Bool status = as_queue_pop(&queue->queue, ptr);
 pthread_mutex_unlock(&queue->lock);
 return status;
}

canonical_original_code:
_Bool as_queue_mt_pop(struct as_queue_mt_s *queue, void *ptr, int wait_ms)
{
 pthread_mutex_lock(&queue->lock);
 as_queue_mt_wait(queue, wait_ms);
 _Bool status = as_queue_pop(&queue->queue, ptr);
 pthread_mutex_unlock(&queue->lock);
 return status;
}


decompiled_code:
__int64 __fastcall as_queue_mt_pop_tail(__int64 a1, __int64 a2, int a3)
{
unsigned int v4; // er12

pthread_mutex_lock((pthread_mutex_t *)(a1 + 32));
as_queue_mt_wait(a1, a3);
v4 = as_queue_pop_tail(a1);
pthread_mutex_unlock((pthread_mutex_t *)(a1 + 32));
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, __int64 a2, int a3)
{
unsigned int v4; // er12

pthread_mutex_lock((pthread_mutex_t *)(a1 + 32));
func5(a1, a3);
v4 = func3(a1);
pthread_mutex_unlock((pthread_mutex_t *)(a1 + 32));
return v4;
}

original_code:
_Bool
as_queue_mt_pop_tail(as_queue_mt* queue, void* ptr, int wait_ms)
{
 pthread_mutex_lock(&queue->lock);
 as_queue_mt_wait(queue, wait_ms);
 _Bool status = as_queue_pop_tail(&queue->queue, ptr);
 pthread_mutex_unlock(&queue->lock);
 return status;
}

canonical_original_code:
_Bool as_queue_mt_pop_tail(struct as_queue_mt_s *queue, void *ptr, int wait_ms)
{
 pthread_mutex_lock(&queue->lock);
 as_queue_mt_wait(queue, wait_ms);
 _Bool status = as_queue_pop_tail(&queue->queue, ptr);
 pthread_mutex_unlock(&queue->lock);
 return status;
}


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

if ( !a1 )
return 0LL;
result = 0LL;
if ( *(_BYTE *)(a1 + 4) == 3 )
result = a1;
return result;
}

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

if ( !a1 )
return 0LL;
result = 0LL;
if ( *(_BYTE *)(a1 + 4) == 3 )
result = a1;
return result;
}

original_code:
static inline as_integer * as_integer_fromval(const as_val * v) {
 return (v && (v ? (as_val_type_e)((as_val *)v)->type : AS_UNDEF) == AS_INTEGER ? (as_integer *) v : ((void *)0));
}

canonical_original_code:
static inline struct as_integer_s *as_integer_fromval(struct as_val_s *v) {
 return (v && (v ? (as_val_type_e)((struct as_val_s *)v)->type : AS_UNDEF) == AS_INTEGER ? (struct as_integer_s *) v : ((void *)0));
}

return_type: struct as_integer_s { struct as_val_s { unsigned int count; unsigned char type; _Bool free; } _; long value; } *


decompiled_code:
void __fastcall as_integer_cons(__int64 a1, char a2)
{
__int64 v2; // rdx

if ( a1 )
{
as_val_cons_constprop_0_isra_0(a1, a2);
*(_QWORD *)(a1 + 8) = v2;
}
}

canonical_decompiled_code:
void __fastcall func2(__int64 a1, char a2)
{
__int64 v2; // rdx

if ( a1 )
{
func1(a1, a2);
*(_QWORD *)(a1 + 8) = v2;
}
}

original_code:
static as_integer * as_integer_cons(as_integer * integer, _Bool free, int64_t value)
{
 if ( !integer ) return integer;
 as_val_cons((as_val *) integer, AS_INTEGER, free);
 integer->value = value;
 return integer;
}

canonical_original_code:
static struct as_integer_s *as_integer_cons(struct as_integer_s *integer, _Bool free, long value)
{
 if ( !integer ) return integer;
 as_val_cons((struct as_val_s *) integer, AS_INTEGER, free);
 integer->value = value;
 return integer;
}

variable_types:
integer
struct as_integer_s *

variable_types: value long


decompiled_code:
void __fastcall as_integer_init(__int64 a1)
{
as_integer_cons(a1, 0);
}

canonical_decompiled_code:
void __fastcall func3(__int64 a1)
{
func2(a1, 0);
}

original_code:
as_integer * as_integer_init(as_integer * integer, int64_t value)
{
 return as_integer_cons(integer, 0, value);
}

canonical_original_code:
struct as_integer_s *as_integer_init(struct as_integer_s *integer, long value)
{
 return as_integer_cons(integer, 0, value);
}


decompiled_code:
void as_integer_new()
{
__int64 v0; // rax

v0 = cf_malloc(16LL);
as_integer_cons(v0, 1);
}

canonical_decompiled_code:
void func4()
{
__int64 v0; // rax

v0 = cf_malloc(16LL);
func2(v0, 1);
}

original_code:
as_integer * as_integer_new(int64_t value)
{
 as_integer * integer = (as_integer *) cf_malloc(sizeof(as_integer));
 return as_integer_cons(integer, 1, value);
}

canonical_original_code:
struct as_integer_s *as_integer_new(long value)
{
 struct as_integer_s *integer = (as_integer *) cf_malloc(sizeof(as_integer));
 return as_integer_cons(integer, 1, value);
}

variable_types: struct as_integer_s { struct as_val_s { unsigned int count; unsigned char type; _Bool free; } _; long value; } *


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

result = as_integer_fromval(a1);
if ( result )
*(_QWORD *)(result + 8) = 0x8000000000000000LL;
return result;
}

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

result = func0(a1);
if ( result )
*(_QWORD *)(result + 8) = 0x8000000000000000LL;
return result;
}

original_code:
void as_integer_val_destroy(as_val * v)
{
 as_integer * integer = as_integer_fromval(v);
 if ( !integer ) return;
 integer->value = (-9223372036854775807L -1);
}

canonical_original_code:
void as_integer_val_destroy(struct as_val_s *v)
{
 struct as_integer_s *integer = as_integer_fromval(v);
 if ( !integer ) return;
 integer->value = (-9223372036854775807L -1);
}

variable_types: struct as_val_s { unsigned int count; unsigned char type; _Bool free; } *


decompiled_code:
__int64 __fastcall as_integer_val_hashcode(__int64 a1)
{
__int64 v1; // rax
unsigned int v2; // er8

v1 = as_integer_fromval(a1);
v2 = 0;
if ( v1 )
v2 = *(_DWORD *)(v1 + 8);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
__int64 v1; // rax
unsigned int v2; // er8

v1 = func0(a1);
v2 = 0;
if ( v1 )
v2 = *(_DWORD *)(v1 + 8);
return v2;
}

original_code:
uint32_t as_integer_val_hashcode(const as_val * v)
{
 as_integer * i = as_integer_fromval(v);
 return i != ((void *)0) ? (uint32_t)i->value : 0;
}

canonical_original_code:
unsigned int as_integer_val_hashcode(struct as_val_s *v)
{
 struct as_integer_s *i = as_integer_fromval(v);
 return i != ((void *)0) ? (unsigned int)i->value : 0;
}


decompiled_code:
__int64 __fastcall as_integer_val_tostring(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // r12

v1 = cf_malloc(32LL);
*(_OWORD *)v1 = 0LL;
v2 = v1;
*(_OWORD *)(v1 + 16) = 0LL;
sprintf((char *)v1, "%ld", *(_QWORD *)(a1 + 8));
return v2;
}

original_code:
char * as_integer_val_tostring(const as_val * v)
{
 as_integer * i = (as_integer *) v;
 char * str = (char *) cf_malloc(sizeof(char) * 32);
 memset(str, 0, 32);
 sprintf(str, "%" "l" "d", i->value);
 return str;
}

canonical_original_code:
char *as_integer_val_tostring(struct as_val_s *v)
{
 struct as_integer_s *i = (as_integer *) v;
 char *str = (char *) cf_malloc(sizeof(char) * 32);
 memset(str, 0, 32);
 sprintf(str, "%" "l" "d", i->value);
 return str;
}

variable_types:
str
char *


decompiled_code:
__int64 __fastcall as_aerospike_new(__int64 a1, __int64 a2)
{
__int64 result; // rax

result = cf_rc_alloc(24LL);
*(_BYTE *)(result + 16) = 1;
*(_QWORD *)result = a1;
*(_QWORD *)(result + 8) = a2;
return result;
}

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

result = cf_rc_alloc(24LL);
*(_BYTE *)(result + 16) = 1;
*(_QWORD *)result = a1;
*(_QWORD *)(result + 8) = a2;
return result;
}

original_code:
as_aerospike * as_aerospike_new(void * s, const as_aerospike_hooks * h)
{
 as_aerospike * a = (as_aerospike *) cf_rc_alloc(sizeof(as_aerospike));
 a->is_rcalloc = 1;
 a->source = s;
 a->hooks = h;
 return a;
}

canonical_original_code:
struct as_aerospike_s *as_aerospike_new(void *s, struct as_aerospike_hooks_s *h)
{
 struct as_aerospike_s *a = (as_aerospike *) cf_rc_alloc(sizeof(as_aerospike));
 a->is_rcalloc = 1;
 a->source = s;
 a->hooks = h;
 return a;
}

variable_types:
s
void *

variable_types:
h
struct as_aerospike_hooks_s *

variable_types: struct as_aerospike_s { void *source; struct as_aerospike_hooks_s { void (*destroy)(struct as_aerospike_s *); int (*rec_create)(struct as_aerospike_s *, struct as_rec_s { struct as_val_s { unsigned int count; unsigned char type; _Bool free; } _; void *data; struct as_rec_hooks_s { _Bool (*destroy)(struct as_rec_s *rec); unsigned int (*hashcode)(struct as_rec_s *rec); struct as_val_s *(*get)(struct as_rec_s *rec, char *name); int (*set)(struct as_rec_s *rec, char *name, struct as_val_s *value); int (*remove)(struct as_rec_s *rec, char *bin); unsigned int (*ttl)(struct as_rec_s *rec); unsigned long (*last_update_time)(struct as_rec_s *rec); unsigned short (*gen)(struct as_rec_s *rec); unsigned int (*memory_size)(struct as_rec_s *rec); unsigned int (*device_size)(struct as_rec_s *rec); struct as_val_s *(*key)(struct as_rec_s *rec); char *(*setname)(struct as_rec_s *rec); unsigned short (*numbins)(struct as_rec_s *rec); int (*bin_names)(struct as_rec_s *rec, void (*callback)(char *bin_names, unsigned int nbins, unsigned short max_name_size, void *udata), void *udata); struct as_bytes_s { struct as_val_s _; unsigned int capacity; unsigned int size; unsigned char *value; _Bool free; enum as_bytes_type_e { AS_BYTES_UNDEF=0, AS_BYTES_INTEGER=1, AS_BYTES_DOUBLE=2, AS_BYTES_STRING=3, AS_BYTES_BLOB=4, AS_BYTES_JAVA=7, AS_BYTES_CSHARP=8, AS_BYTES_PYTHON=9, AS_BYTES_RUBY=10, AS_BYTES_PHP=11, AS_BYTES_ERLANG=12, AS_BYTES_BOOL=17, AS_BYTES_HLL=18, AS_BYTES_MAP=19, AS_BYTES_LIST=20, AS_BYTES_GEOJSON=23, AS_BYTES_TYPE_MAX=24 } type; } *(*digest)(struct as_rec_s *rec); int (*set_ttl)(struct as_rec_s *rec, unsigned int ttl); int (*drop_key)(struct as_rec_s *rec); _Bool (*foreach)(struct as_rec_s *rec, _Bool (*callback)(char *name, struct as_val_s *value, void *udata), void *udata); } *hooks; } *); int (*rec_update)(struct as_aerospike_s *, struct as_rec_s *); int (*rec_remove)(struct as_aerospike_s *, struct as_rec_s *); int (*rec_exists)(struct as_aerospike_s *, struct as_rec_s *); int (*log)(struct as_aerospike_s *, char *, int, int, char *); unsigned long (*get_current_time)(struct as_aerospike_s *); int (*set_context)(struct as_aerospike_s *, struct as_rec_s *, unsigned int context); int (*get_config)(struct as_aerospike_s *, struct as_rec_s *, char *); } *hooks; _Bool is_rcalloc; } *

user_defined_types: struct as_aerospike_s { void *source; struct as_aerospike_hooks_s *hooks; _Bool is_rcalloc; }

user_defined_types: struct as_aerospike_hooks_s { void (*destroy)(struct as_aerospike_s *); int (*rec_create)(struct as_aerospike_s *, struct as_rec_s *); int (*rec_update)(struct as_aerospike_s *, struct as_rec_s *); int (*rec_remove)(struct as_aerospike_s *, struct as_rec_s *); int (*rec_exists)(struct as_aerospike_s *, struct as_rec_s *); int (*log)(struct as_aerospike_s *, char *, int, int, char *); unsigned long (*get_current_time)(struct as_aerospike_s *); int (*set_context)(struct as_aerospike_s *, struct as_rec_s *, unsigned int context); int (*get_config)(struct as_aerospike_s *, struct as_rec_s *, char *); }

user_defined_types: struct as_rec_s { struct as_val_s _; void *data; struct as_rec_hooks_s *hooks; }

user_defined_types: struct as_rec_hooks_s { _Bool (*destroy)(struct as_rec_s *rec); unsigned int (*hashcode)(struct as_rec_s *rec); struct as_val_s *(*get)(struct as_rec_s *rec, char *name); int (*set)(struct as_rec_s *rec, char *name, struct as_val_s *value); int (*remove)(struct as_rec_s *rec, char *bin); unsigned int (*ttl)(struct as_rec_s *rec); unsigned long (*last_update_time)(struct as_rec_s *rec); unsigned short (*gen)(struct as_rec_s *rec); unsigned int (*memory_size)(struct as_rec_s *rec); unsigned int (*device_size)(struct as_rec_s *rec); struct as_val_s *(*key)(struct as_rec_s *rec); char *(*setname)(struct as_rec_s *rec); unsigned short (*numbins)(struct as_rec_s *rec); int (*bin_names)(struct as_rec_s *rec, void (*callback)(char *bin_names, unsigned int nbins, unsigned short max_name_size, void *udata), void *udata); struct as_bytes_s *(*digest)(struct as_rec_s *rec); int (*set_ttl)(struct as_rec_s *rec, unsigned int ttl); int (*drop_key)(struct as_rec_s *rec); _Bool (*foreach)(struct as_rec_s *rec, _Bool (*callback)(char *name, struct as_val_s *value, void *udata), void *udata); }

user_defined_types: struct as_bytes_s { struct as_val_s _; unsigned int capacity; unsigned int size; unsigned char *value; _Bool free; enum as_bytes_type_e type; }


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

if ( *(_BYTE *)(a1 + 16) )
result = cf_rc_releaseandfree();
return result;
}

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

if ( *(_BYTE *)(a1 + 16) )
result = cf_rc_releaseandfree();
return result;
}

original_code:
void as_aerospike_destroy(as_aerospike * a)
{
 if (a->is_rcalloc)
    cf_rc_releaseandfree(a);
}

canonical_original_code:
void as_aerospike_destroy(struct as_aerospike_s *a)
{
 if (a->is_rcalloc)
    cf_rc_releaseandfree(a);
}

user_defined_types: struct as_val_s { unsigned int count; unsigned char type; _Bool free; }

user_defined_types: enum as_bytes_type_e { AS_BYTES_UNDEF=0, AS_BYTES_INTEGER=1, AS_BYTES_DOUBLE=2, AS_BYTES_STRING=3, AS_BYTES_BLOB=4, AS_BYTES_JAVA=7, AS_BYTES_CSHARP=8, AS_BYTES_PYTHON=9, AS_BYTES_RUBY=10, AS_BYTES_PHP=11, AS_BYTES_ERLANG=12, AS_BYTES_BOOL=17, AS_BYTES_HLL=18, AS_BYTES_MAP=19, AS_BYTES_LIST=20, AS_BYTES_GEOJSON=23, AS_BYTES_TYPE_MAX=24 }


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

if ( !a1 )
return 0LL;
result = 0LL;
if ( *(_BYTE *)(a1 + 4) == 6 )
result = a1;
return result;
}

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

if ( !a1 )
return 0LL;
result = 0LL;
if ( *(_BYTE *)(a1 + 4) == 6 )
result = a1;
return result;
}

original_code:
static inline as_map* as_map_fromval(const as_val* val)
{
 return (val && (val ? (as_val_type_e)((as_val *)val)->type : AS_UNDEF) == AS_MAP ? (as_map *) val : ((void *)0));
}

canonical_original_code:
static inline struct as_map_s *as_map_fromval(struct as_val_s *val)
{
 return (val && (val ? (as_val_type_e)((struct as_val_s *)val)->type : AS_UNDEF) == AS_MAP ? (struct as_map_s *) val : ((void *)0));
}

variable_types:
val
struct as_val_s *

return_type: struct as_map_s { struct as_val_s { unsigned int count; unsigned char type; _Bool free; } _; unsigned int flags; struct as_map_hooks_s { _Bool (*destroy)(struct as_map_s *map); unsigned int (*hashcode)(struct as_map_s *map); unsigned int (*size)(struct as_map_s *map); int (*set)(struct as_map_s *map, struct as_val_s *key, struct as_val_s *val); struct as_val_s *(*get)(struct as_map_s *map, struct as_val_s *key); int (*clear)(struct as_map_s *map); int (*remove)(struct as_map_s *map, struct as_val_s *key); void (*set_flags)(struct as_map_s *map, unsigned int flags); _Bool (*foreach)(struct as_map_s *map, _Bool (*callback)(struct as_val_s *key, struct as_val_s *value, void *udata), void *udata); union as_map_iterator_u { struct as_orderedmap_iterator_s { struct as_iterator_s { _Bool free; void *data; struct as_iterator_hooks_s { _Bool (*destroy)(struct as_iterator_s *); _Bool (*has_next)(struct as_iterator_s *); struct as_val_s *(*next)(struct as_iterator_s *); } *hooks; } _; struct as_orderedmap_s { struct as_map_s _; unsigned int count; unsigned int capacity; struct map_entry_s { struct as_val_s *key; struct as_val_s *value; } *table; unsigned int hold_count; struct map_entry_s *hold_table; unsigned int *hold_locations; } *map; unsigned int ix; struct as_pair_s { struct as_val_s _; struct as_val_s *_1; struct as_val_s *_2; } pair; } orderedmap; } *(*iterator_new)(struct as_map_s *map); union as_map_iterator_u *(*iterator_init)(struct as_map_s *map, union as_map_iterator_u *it); } *hooks; } *

user_defined_types: struct as_map_s { struct as_val_s _; unsigned int flags; struct as_map_hooks_s *hooks; }

user_defined_types: struct as_map_hooks_s { _Bool (*destroy)(struct as_map_s *map); unsigned int (*hashcode)(struct as_map_s *map); unsigned int (*size)(struct as_map_s *map); int (*set)(struct as_map_s *map, struct as_val_s *key, struct as_val_s *val); struct as_val_s *(*get)(struct as_map_s *map, struct as_val_s *key); int (*clear)(struct as_map_s *map); int (*remove)(struct as_map_s *map, struct as_val_s *key); void (*set_flags)(struct as_map_s *map, unsigned int flags); _Bool (*foreach)(struct as_map_s *map, _Bool (*callback)(struct as_val_s *key, struct as_val_s *value, void *udata), void *udata); union as_map_iterator_u *(*iterator_new)(struct as_map_s *map); union as_map_iterator_u *(*iterator_init)(struct as_map_s *map, union as_map_iterator_u *it); }

user_defined_types: union as_map_iterator_u { struct as_orderedmap_iterator_s orderedmap; }

user_defined_types: struct as_orderedmap_iterator_s { struct as_iterator_s _; struct as_orderedmap_s *map; unsigned int ix; struct as_pair_s pair; }

user_defined_types: struct as_iterator_s { _Bool free; void *data; struct as_iterator_hooks_s *hooks; }

user_defined_types: struct as_orderedmap_s { struct as_map_s _; unsigned int count; unsigned int capacity; struct map_entry_s *table; unsigned int hold_count; struct map_entry_s *hold_table; unsigned int *hold_locations; }


original_code:
static _Bool as_map_val_tostring_foreach(const as_val* key, const as_val* val, void* udata)
{
 as_map_val_tostring_data * data = (as_map_val_tostring_data *) udata;
 char * keystr = ( as_val_val_tostring((as_val *)key) );
 if (!keystr) {
  return 0;
 }
 int keylen = (int)strlen(keystr);
 char * valstr = ( as_val_val_tostring((as_val *)val) );
    if (!valstr) {
  cf_free(keystr);
     return 0;
    }
 int vallen = (int)strlen(valstr);
 uint32_t entlen = keylen + 2 + vallen + 2;
 if ( data->pos + entlen >= data->cap ) {
  uint32_t adj = entlen > data->blk ? entlen : data->blk;
  data->buf = cf_realloc(data->buf, sizeof(char) * (data->cap + adj));
  memset(data->buf + data->cap, 0, sizeof(char) * adj);
  data->cap += adj;
 }
 if ( data->sep ) {
  data->buf[data->pos] = ',';
  data->buf[data->pos + 1] = ' ';
  data->pos += 2;
 }
 strcpy(data->buf + data->pos, keystr);
 data->pos += keylen;
 strcpy(data->buf + data->pos, ":");
 data->pos += 1;
 strcpy(data->buf + data->pos, valstr);
 data->pos += vallen;
 data->sep = 1;
 cf_free(keystr);
 keystr = ((void *)0);
 cf_free(valstr);
 valstr = ((void *)0);
 return 1;
}

canonical_original_code:
static _Bool as_map_val_tostring_foreach(struct as_val_s *key, struct as_val_s *val, void *udata)
{
 struct as_map_val_tostring_data_s *data = (as_map_val_tostring_data *) udata;
 char *keystr = ( as_val_val_tostring((as_val *)key) );
 if (!keystr) {
  return 0;
 }
 int keylen = (int)strlen(keystr);
 char *valstr = ( as_val_val_tostring((as_val *)val) );
    if (!valstr) {
  cf_free(keystr);
     return 0;
    }
 int vallen = (int)strlen(valstr);
 unsigned int entlen = keylen + 2 + vallen + 2;
 if ( data->pos + entlen >= data->cap ) {
  unsigned int adj = entlen > data->blk ? entlen : data->blk;
  data->buf = cf_realloc(data->buf, sizeof(char) * (data->cap + adj));
  memset(data->buf + data->cap, 0, sizeof(char) * adj);
  data->cap += adj;
 }
 if ( data->sep ) {
  data->buf[data->pos] = ',';
  data->buf[data->pos + 1] = ' ';
  data->pos += 2;
 }
 strcpy(data->buf + data->pos, keystr);
 data->pos += keylen;
 strcpy(data->buf + data->pos, ":");
 data->pos += 1;
 strcpy(data->buf + data->pos, valstr);
 data->pos += vallen;
 data->sep = 1;
 cf_free(keystr);
 keystr = ((void *)0);
 cf_free(valstr);
 valstr = ((void *)0);
 return 1;
}

variable_types:
udata
void *

variable_types: struct as_map_val_tostring_data_s { char *buf; unsigned int blk; unsigned int cap; unsigned int pos; _Bool sep; } *

variable_types:
keystr
char *

variable_types: keylen int

variable_types:
valstr
char *

variable_types: vallen int

variable_types:
entlen
unsigned int

variable_types:
adj
unsigned int


decompiled_code:
void __fastcall as_map_cons(__int64 a1, char a2)
{
int v2; // edx
__int64 v3; // rcx

if ( a1 )
{
as_val_cons_constprop_0_isra_0(a1, a2);
*(_DWORD *)(a1 + 8) = v2;
*(_QWORD *)(a1 + 16) = v3;
}
}

original_code:
as_map* as_map_cons(as_map* map, _Bool free, uint32_t flags, const as_map_hooks* hooks)
{
 if ( !map ) return map;
 as_val_cons((as_val*) map, AS_MAP, free);
 map->flags = flags;
 map->hooks = hooks;
 return map;
}

canonical_original_code:
struct as_map_s *as_map_cons(struct as_map_s *map, _Bool free, unsigned int flags, struct as_map_hooks_s *hooks)
{
 if ( !map ) return map;
 as_val_cons((struct as_val_s *) map, AS_MAP, free);
 map->flags = flags;
 map->hooks = hooks;
 return map;
}

variable_types:
map
struct as_map_s *

variable_types:
flags
unsigned int

variable_types:
hooks
struct as_map_hooks_s *

user_defined_types: struct as_pair_s { struct as_val_s _; struct as_val_s *_1; struct as_val_s *_2; }

user_defined_types: struct as_iterator_hooks_s { _Bool (*destroy)(struct as_iterator_s *); _Bool (*has_next)(struct as_iterator_s *); struct as_val_s *(*next)(struct as_iterator_s *); }

user_defined_types: struct map_entry_s { struct as_val_s *key; struct as_val_s *value; }


decompiled_code:
void __fastcall as_map_init(__int64 a1)
{
as_map_cons(a1, 0);
}

canonical_decompiled_code:
void __fastcall func5(__int64 a1)
{
func4(a1, 0);
}

original_code:
as_map* as_map_init(as_map* map, const as_map_hooks* hooks)
{
 return as_map_cons(map, 0, 0, hooks);
}

canonical_original_code:
struct as_map_s *as_map_init(struct as_map_s *map, struct as_map_hooks_s *hooks)
{
 return as_map_cons(map, 0, 0, hooks);
}


decompiled_code:
void as_map_new()
{
__int64 v0; // rax

v0 = cf_malloc(24LL);
as_map_cons(v0, 1);
}

canonical_decompiled_code:
void func6()
{
__int64 v0; // rax

v0 = cf_malloc(24LL);
func4(v0, 1);
}

original_code:
as_map* as_map_new(const as_map_hooks* hooks)
{
 as_map* map = (as_map*) cf_malloc(sizeof(as_map));
 return as_map_cons(map, 1, 0, hooks);
}

canonical_original_code:
struct as_map_s *as_map_new(struct as_map_hooks_s *hooks)
{
 struct as_map_s *map = (as_map*) cf_malloc(sizeof(as_map));
 return as_map_cons(map, 1, 0, hooks);
}

variable_types: struct as_map_s { struct as_val_s { unsigned int count; unsigned char type; _Bool free; } _; unsigned int flags; struct as_map_hooks_s { _Bool (*destroy)(struct as_map_s *map); unsigned int (*hashcode)(struct as_map_s *map); unsigned int (*size)(struct as_map_s *map); int (*set)(struct as_map_s *map, struct as_val_s *key, struct as_val_s *val); struct as_val_s *(*get)(struct as_map_s *map, struct as_val_s *key); int (*clear)(struct as_map_s *map); int (*remove)(struct as_map_s *map, struct as_val_s *key); void (*set_flags)(struct as_map_s *map, unsigned int flags); _Bool (*foreach)(struct as_map_s *map, _Bool (*callback)(struct as_val_s *key, struct as_val_s *value, void *udata), void *udata); union as_map_iterator_u { struct as_orderedmap_iterator_s { struct as_iterator_s { _Bool free; void *data; struct as_iterator_hooks_s { _Bool (*destroy)(struct as_iterator_s *); _Bool (*has_next)(struct as_iterator_s *); struct as_val_s *(*next)(struct as_iterator_s *); } *hooks; } _; struct as_orderedmap_s { struct as_map_s _; unsigned int count; unsigned int capacity; struct map_entry_s { struct as_val_s *key; struct as_val_s *value; } *table; unsigned int hold_count; struct map_entry_s *hold_table; unsigned int *hold_locations; } *map; unsigned int ix; struct as_pair_s { struct as_val_s _; struct as_val_s *_1; struct as_val_s *_2; } pair; } orderedmap; } *(*iterator_new)(struct as_map_s *map); union as_map_iterator_u *(*iterator_init)(struct as_map_s *map, union as_map_iterator_u *it); } *hooks; } *


decompiled_code:
__int64 __fastcall as_map_val_destroy(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rdi

result = as_map_fromval(a1);
if ( result )
{
v2 = result;
result = *(_QWORD *)(result + 16);
if ( result )
{
result = *(_QWORD *)result;
if ( result )
result = ((__int64 (__fastcall *)(__int64))result)(v2);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rdi

result = func0(a1);
if ( result )
{
v2 = result;
result = *(_QWORD *)(result + 16);
if ( result )
{
result = *(_QWORD *)result;
if ( result )
result = ((__int64 (__fastcall *)(__int64))result)(v2);
}
}
return result;
}

original_code:
void as_map_val_destroy(as_val* v) {
 as_map* m = as_map_fromval(v);
 (m && m->hooks && m->hooks->destroy ? m->hooks->destroy(m) : 0);
}

canonical_original_code:
void as_map_val_destroy(struct as_val_s *v) {
 struct as_map_s *m = as_map_fromval(v);
 (m && m->hooks && m->hooks->destroy ? m->hooks->destroy(m) : 0);
}

variable_types: struct as_val_s { unsigned int count; unsigned char type; _Bool free; } *


decompiled_code:
__int64 __fastcall as_map_val_hashcode(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rdi
__int64 v3; // rax
__int64 (__fastcall *v4)(__int64); // rax
__int64 result; // rax

v1 = as_map_fromval(a1);
if ( v1 && (v2 = v1, (v3 = *(_QWORD *)(v1 + 16)) != 0) && (v4 = *(__int64 (__fastcall **)(__int64))(v3 + 8)) != 0LL )
result = v4(v2);
else
result = 0LL;
return result;
}

original_code:
uint32_t as_map_val_hashcode(const as_val* v) {
 as_map* m = as_map_fromval(v);
 return (m && m->hooks && m->hooks->hashcode ? m->hooks->hashcode(m) : 0);
}

canonical_original_code:
unsigned int as_map_val_hashcode(struct as_val_s *v) {
 struct as_map_s *m = as_map_fromval(v);
 return (m && m->hooks && m->hooks->hashcode ? m->hooks->hashcode(m) : 0);
}


decompiled_code:
int __fastcall as_set_echo(char a1)
{
tcflag_t v1; // eax
struct termios v3; // [rsp+0h] [rbp-58h] BYREF

tcgetattr(0, &v3);
if ( a1 )
v1 = v3.c_lflag | 8;
else
v1 = v3.c_lflag & 0xFFFFFFF7;
v3.c_lflag = v1;
return tcsetattr(0, 0, &v3);
}

canonical_decompiled_code:
int __fastcall func0(char a1)
{
tcflag_t v1; // eax
struct termios v3; // [rsp+0h] [rbp-58h] BYREF

tcgetattr(0, &v3);
if ( a1 )
v1 = v3.c_lflag | 8;
else
v1 = v3.c_lflag & 0xFFFFFFF7;
v3.c_lflag = v1;
return tcsetattr(0, 0, &v3);
}

original_code:
static void
as_set_echo(_Bool echo)
{
 struct termios tty;
 tcgetattr(0, &tty);
 if (echo)
 {
  tty.c_lflag |= 0000010;
 }
 else
 {
  tty.c_lflag &= ~0000010;
 }
 tcsetattr(0, 0, &tty);
}

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


decompiled_code:
int __fastcall as_password_prompt(char *s, int n)
{
int v2; // eax

as_set_echo(0);
printf("Enter Password: ");
fflush(stdout);
if ( fgets(s, n, stdin) )
{
v2 = strlen(s);
if ( s[v2 - 1] == 10 )
s[v2 - 1] = 0;
}
else
{
*s = 0;
}
as_set_echo(1);
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func1(char *s, int n)
{
int v2; // eax

func0(0);
printf("Enter Password: ");
fflush(stdout);
if ( fgets(s, n, stdin) )
{
v2 = strlen(s);
if ( s[v2 - 1] == 10 )
s[v2 - 1] = 0;
}
else
{
*s = 0;
}
func0(1);
return putchar(10);
}

original_code:
static void
as_password_prompt(char* password, int size)
{
 as_set_echo(0);
 printf("Enter Password: ");
 fflush(stdout);
 char* s = fgets(password, size, stdin);
 if (s) {
  int len = (int)strlen(password);
  if (password[len - 1] == '\n') {
   password[--len] = 0;
  }
 }
 else {
  password[0] = 0;
 }
 as_set_echo(1);
 printf("\n");
}

canonical_original_code:
static void as_password_prompt(char *password, int size)
{
 as_set_echo(0);
 printf("Enter Password: ");
 fflush(stdout);
 char *s = fgets(password, size, stdin);
 if (s) {
  int len = (int)strlen(password);
  if (password[len - 1] == '\n') {
   password[--len] = 0;
  }
 }
 else {
  password[0] = 0;
 }
 as_set_echo(1);
 printf("\n");
}

variable_types:
password
char *

variable_types: size int

variable_types:
s
char *

variable_types: len int


decompiled_code:
bool __fastcall as_password_gen_salt(__int64 a1)
{
_BYTE v2[40]; // [rsp+0h] [rbp-28h] BYREF

as_random_get_bytes_constprop_0((__int64)v2);
return crypt_gensalt_blowfish_rn("$2a$", 10LL, v2, 16LL, a1, 64LL) != 0;
}

canonical_decompiled_code:
bool __fastcall func3(__int64 a1)
{
_BYTE v2[40]; // [rsp+0h] [rbp-28h] BYREF

func2((__int64)v2);
return crypt_gensalt_blowfish_rn("$2a$", 10LL, v2, 16LL, a1, 64LL) != 0;
}

original_code:
_Bool
as_password_gen_salt(char* salt)
{
 char rnd[16];
 as_random_get_bytes((uint8_t*)rnd, 16);
 return (_Bool) _crypt_gensalt_blowfish_rn("$2a$", 10, rnd, 16, salt, 64);
}

canonical_original_code:
_Bool as_password_gen_salt(char *salt)
{
 char rnd[16];
 as_random_get_bytes((unsigned char *)rnd, 16);
 return (_Bool) _crypt_gensalt_blowfish_rn("$2a$", 10, rnd, 16, salt, 64);
}

variable_types:
salt
char *

variable_types:
rnd
char [16]


decompiled_code:
bool __fastcall as_password_gen_hash(__int64 a1, __int64 a2, __int64 a3)
{
return crypt_blowfish_rn(a1, a2, a3, 64LL) != 0;
}

canonical_decompiled_code:
bool __fastcall func4(__int64 a1, __int64 a2, __int64 a3)
{
return crypt_blowfish_rn(a1, a2, a3, 64LL) != 0;
}

original_code:
_Bool
as_password_gen_hash(const char* password, const char* salt, char* hash)
{
 return (_Bool) _crypt_blowfish_rn(password, salt, hash, 64);
}

canonical_original_code:
_Bool as_password_gen_hash(char *password, char *salt, char *hash)
{
 return (_Bool) _crypt_blowfish_rn(password, salt, hash, 64);
}

variable_types:
hash
char *


decompiled_code:
bool __fastcall as_password_gen_constant_hash(__int64 a1, __int64 a2)
{
return crypt_blowfish_rn(a1, "$2a$10$7EqJtq98hPqEX7fNZaFWoO", a2, 64LL) != 0;
}

canonical_decompiled_code:
bool __fastcall func5(__int64 a1, __int64 a2)
{
return crypt_blowfish_rn(a1, "$2a$10$7EqJtq98hPqEX7fNZaFWoO", a2, 64LL) != 0;
}

original_code:
_Bool
as_password_gen_constant_hash(const char* password, char* hash)
{
 return (_Bool) _crypt_blowfish_rn(password, "$2a$10$7EqJtq98hPqEX7fNZaFWoO", hash, 64);
}

canonical_original_code:
_Bool as_password_gen_constant_hash(char *password, char *hash)
{
 return (_Bool) _crypt_blowfish_rn(password, "$2a$10$7EqJtq98hPqEX7fNZaFWoO", hash, 64);
}


decompiled_code:
bool __fastcall as_password_get_constant_hash(void *a1, __int64 a2)
{
if ( !a1 )
a1 = &LC3;
return as_password_gen_constant_hash((__int64)a1, a2);
}

canonical_decompiled_code:
bool __fastcall func6(void *a1, __int64 a2)
{
if ( !a1 )
a1 = &LC3;
return func5((__int64)a1, a2);
}

original_code:
_Bool
as_password_get_constant_hash(const char* password, char* hash)
{
 if (! password) {
  password = "";
 }
 return as_password_gen_constant_hash(password, hash);
}

canonical_original_code:
_Bool as_password_get_constant_hash(char *password, char *hash)
{
 if (! password) {
  password = "";
 }
 return as_password_gen_constant_hash(password, hash);
}


decompiled_code:
bool __fastcall as_password_prompt_hash(_BYTE *a1, __int64 a2)
{
char v3[88]; // [rsp+0h] [rbp-58h] BYREF

if ( a1 && *a1 )
as_strncpy(v3, a1, 64LL);
else
as_password_prompt(v3, 64);
return as_password_get_constant_hash(v3, a2);
}

canonical_decompiled_code:
bool __fastcall func7(_BYTE *a1, __int64 a2)
{
char v3[88]; // [rsp+0h] [rbp-58h] BYREF

if ( a1 && *a1 )
as_strncpy(v3, a1, 64LL);
else
func1(v3, 64);
return func6(v3, a2);
}

original_code:
_Bool
as_password_prompt_hash(const char* password, char* hash)
{
 char pass[64];
 if (password && *password) {
  as_strncpy(pass, password, sizeof(pass));
 }
 else {
  as_password_prompt(pass, sizeof(pass));
 }
 return as_password_get_constant_hash(pass, hash);
}

canonical_original_code:
_Bool as_password_prompt_hash(char *password, char *hash)
{
 char pass[64];
 if (password && *password) {
  as_strncpy(pass, password, sizeof(pass));
 }
 else {
  as_password_prompt(pass, sizeof(pass));
 }
 return as_password_get_constant_hash(pass, hash);
}

variable_types:
pass
char [64]


decompiled_code:
int __fastcall as_password_acquire(char *a1, _BYTE *a2, __int64 a3)
{
int result; // eax

if ( a2 && *a2 )
result = as_strncpy(a1, a2, a3);
else
result = as_password_prompt(a1, a3);
return result;
}

canonical_decompiled_code:
int __fastcall func8(char *a1, _BYTE *a2, __int64 a3)
{
int result; // eax

if ( a2 && *a2 )
result = as_strncpy(a1, a2, a3);
else
result = func1(a1, a3);
return result;
}

original_code:
void
as_password_acquire(char* password_trg, const char* password_src, int size)
{
 if (password_src && *password_src) {
  as_strncpy(password_trg, password_src, size);
 }
 else {
  as_password_prompt(password_trg, size);
 }
}

canonical_original_code:
void as_password_acquire(char *password_trg, char *password_src, int size)
{
 if (password_src && *password_src) {
  as_strncpy(password_trg, password_src, size);
 }
 else {
  as_password_prompt(password_trg, size);
 }
}


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

if ( !a1 )
return 0LL;
result = 0LL;
if ( *(_BYTE *)(a1 + 4) == 4 )
result = a1;
return result;
}

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

if ( !a1 )
return 0LL;
result = 0LL;
if ( *(_BYTE *)(a1 + 4) == 4 )
result = a1;
return result;
}

original_code:
static inline as_string * as_string_fromval(const as_val * v)
{
 return (v && (v ? (as_val_type_e)((as_val *)v)->type : AS_UNDEF) == AS_STRING ? (as_string *) v : ((void *)0));
}

canonical_original_code:
static inline struct as_string_s *as_string_fromval(struct as_val_s *v)
{
 return (v && (v ? (as_val_type_e)((struct as_val_s *)v)->type : AS_UNDEF) == AS_STRING ? (struct as_string_s *) v : ((void *)0));
}

variable_types:
v
struct as_val_s *

return_type: struct as_string_s { struct as_val_s { unsigned int count; unsigned char type; _Bool free; } _; _Bool free; char *value; unsigned long len; } *

user_defined_types: struct as_string_s { struct as_val_s _; _Bool free; char *value; unsigned long len; }


decompiled_code:
__int64 __fastcall as_is_file_separator(char a1, __int64 a2, int a3)
{
unsigned int v3; // eax

LOBYTE(v3) = a1 == 47;
LOBYTE(a3) = a1 == 92;
return a3 | v3;
}

canonical_decompiled_code:
__int64 __fastcall func1(char a1, __int64 a2, int a3)
{
unsigned int v3; // eax

LOBYTE(v3) = a1 == 47;
LOBYTE(a3) = a1 == 92;
return a3 | v3;
}

original_code:
static inline _Bool
as_is_file_separator(char c)
{
 return c == '/' || c == '\\';
}

variable_types: c char


decompiled_code:
void __fastcall as_string_cons(__int64 a1, char a2)
{
char v2; // r8
__int64 v3; // rdx
__int64 v4; // rcx

if ( a1 )
{
as_val_cons_constprop_0_isra_0(a1, a2);
*(_BYTE *)(a1 + 8) = v2;
*(_QWORD *)(a1 + 16) = v3;
*(_QWORD *)(a1 + 24) = v4;
}
}

original_code:
static inline as_string * as_string_cons(as_string * string, _Bool free, char * value, size_t len, _Bool value_free)
{
 if ( !string ) return string;
 as_val_cons((as_val *) string, AS_STRING, free);
 string->free = value_free;
 string->value = value;
 string->len = len;
 return string;
}

canonical_original_code:
static inline struct as_string_s *as_string_cons(struct as_string_s *string, _Bool free, char *value, unsigned long len, _Bool value_free)
{
 if ( !string ) return string;
 as_val_cons((struct as_val_s *) string, AS_STRING, free);
 string->free = value_free;
 string->value = value;
 string->len = len;
 return string;
}

variable_types:
string
struct as_string_s *

variable_types:
value
char *

variable_types:
len
unsigned long


decompiled_code:
void __fastcall as_string_init(__int64 a1)
{
as_string_cons(a1, 0);
}

canonical_decompiled_code:
void __fastcall func4(__int64 a1)
{
func3(a1, 0);
}

original_code:
as_string * as_string_init(as_string * string, char * value, _Bool free)
{
 return as_string_cons(string, 0, value, (18446744073709551615UL), free);
}

canonical_original_code:
struct as_string_s *as_string_init(struct as_string_s *string, char *value, _Bool free)
{
 return as_string_cons(string, 0, value, (18446744073709551615UL), free);
}


decompiled_code:
void __fastcall as_string_init_wlen(__int64 a1)
{
as_string_cons(a1, 0);
}

canonical_decompiled_code:
void __fastcall func5(__int64 a1)
{
func3(a1, 0);
}

original_code:
as_string * as_string_init_wlen(as_string * string, char * value, size_t len, _Bool free)
{
 return as_string_cons(string, 0, value, len, free);
}

canonical_original_code:
struct as_string_s *as_string_init_wlen(struct as_string_s *string, char *value, unsigned long len, _Bool free)
{
 return as_string_cons(string, 0, value, len, free);
}


decompiled_code:
void as_string_new()
{
__int64 v0; // rax

v0 = cf_malloc(32LL);
as_string_cons(v0, 1);
}

canonical_decompiled_code:
void func6()
{
__int64 v0; // rax

v0 = cf_malloc(32LL);
func3(v0, 1);
}

original_code:
as_string * as_string_new(char * value, _Bool free)
{
 as_string * string = (as_string *) cf_malloc(sizeof(as_string));
 return as_string_cons(string, 1, value, (18446744073709551615UL), free);
}

canonical_original_code:
struct as_string_s *as_string_new(char *value, _Bool free)
{
 struct as_string_s *string = (as_string *) cf_malloc(sizeof(as_string));
 return as_string_cons(string, 1, value, (18446744073709551615UL), free);
}

variable_types: struct as_string_s { struct as_val_s { unsigned int count; unsigned char type; _Bool free; } _; _Bool free; char *value; unsigned long len; } *


decompiled_code:
void as_string_new_wlen()
{
__int64 v0; // rax

v0 = cf_malloc(32LL);
as_string_cons(v0, 1);
}

canonical_decompiled_code:
void func7()
{
__int64 v0; // rax

v0 = cf_malloc(32LL);
func3(v0, 1);
}

original_code:
as_string * as_string_new_wlen(char * value, size_t len, _Bool free)
{
 as_string * string = (as_string *) cf_malloc(sizeof(as_string));
 return as_string_cons(string, 1, value, len, free);
}

canonical_original_code:
struct as_string_s *as_string_new_wlen(char *value, unsigned long len, _Bool free)
{
 struct as_string_s *string = (as_string *) cf_malloc(sizeof(as_string));
 return as_string_cons(string, 1, value, len, free);
}


decompiled_code:
void as_string_new_strdup()
{
cf_strdup();
as_string_new();
}

canonical_decompiled_code:
void func8()
{
cf_strdup();
func6();
}

original_code:
as_string *as_string_new_strdup(const char * s)
{
 return as_string_new(cf_strdup(s), 1);
}

canonical_original_code:
struct as_string_s *as_string_new_strdup(char *s)
{
 return as_string_new(cf_strdup(s), 1);
}


decompiled_code:
size_t __fastcall as_string_len(__int64 a1)
{
const char *v2; // rdi
size_t result; // rax

v2 = *(const char **)(a1 + 16);
if ( !v2 )
return 0LL;
result = *(_QWORD *)(a1 + 24);
if ( result == -1LL )
{
result = strlen(v2);
*(_QWORD *)(a1 + 24) = result;
}
return result;
}

canonical_decompiled_code:
size_t __fastcall func9(__int64 a1)
{
const char *v2; // rdi
size_t result; // rax

v2 = *(const char **)(a1 + 16);
if ( !v2 )
return 0LL;
result = *(_QWORD *)(a1 + 24);
if ( result == -1LL )
{
result = strlen(v2);
*(_QWORD *)(a1 + 24) = result;
}
return result;
}

original_code:
size_t as_string_len(as_string * string)
{
 if (string->value == ((void *)0)) {
  return 0;
 }
 if (string->len == (18446744073709551615UL)) {
  string->len = strlen(string->value);
 }
 return string->len;
}

canonical_original_code:
unsigned long as_string_len(struct as_string_s *string)
{
 if (string->value == ((void *)0)) {
  return 0;
 }
 if (string->len == (18446744073709551615UL)) {
  string->len = strlen(string->value);
 }
 return string->len;
}


decompiled_code:
char *__fastcall as_basename(__int64 a1, char *a2, int a3)
{
char v4; // di
char *v5; // r12
char v6; // al
char *v7; // r9
char *v8; // rcx
char *v9; // rcx
char *result; // rax
char *v11; // r9
char *v12; // rcx
char *v13; // r13
char v14; // al
char *v15; // r9
signed __int64 v16; // rsi
__int64 v17; // rdi
size_t v18; // r14
void *v19; // r12
char *v20; // rsi

if ( a2 && (v4 = *a2, v5 = 0LL, *a2) )
{
do
{
v6 = as_is_file_separator(v4, (__int64)a2, a3);
a2 = v8;
v4 = v8[1];
v9 = v8 + 1;
if ( v6 )
v5 = v9;
}
while ( v4 );
if ( !v5 )
{
v5 = v7;
as_string_cons(a1, 0);
return v5;
}
if ( v5 != v9 )
{
as_string_cons(a1, 0);
return v5;
}
while ( (unsigned __int8)as_is_file_separator(*a2, (__int64)a2, a3) )
{
if ( a2 == v11 )
{
as_string_cons(a1, 0);
return (char *)&LC1;
}
--a2;
}
if ( a2 == v11 )
{
v13 = a2;
v18 = 1LL;
v17 = 2LL;
}
else
{
v12 = a2;
while ( 1 )
{
v13 = v12;
v14 = as_is_file_separator(*(v12 - 1), (__int64)a2, a3);
if ( v15 == v12 )
break;
if ( v14 )
goto LABEL_17;
}
if ( v14 )
{
LABEL_17:
v16 = a2 - v13;
v17 = v16 + 2;
v18 = v16 + 1;
goto LABEL_18;
}
v20 = (char *)(a2 - v15);
v13 = v15;
v17 = (__int64)(v20 + 2);
v18 = (size_t)(v20 + 1);
}
LABEL_18:
v19 = (void *)cf_malloc(v17);
memcpy(v19, v13, v18);
*((_BYTE *)v19 + v18) = 0;
as_string_cons(a1, 0);
result = (char *)v19;
}
else
{
as_string_cons(a1, 0);
result = (char *)&LC0;
}
return result;
}

original_code:
const char* as_basename(as_string * filename, const char* path)
{
 if (path == 0 || *path == 0) {
  char* value = ".";
  as_string_cons(filename, 0, value, 1, 0);
  return value;
 }
 const char* p = path;
 const char* begin = 0;
 while (*p) {
  if (as_is_file_separator(*p)) {
   begin = p + 1;
  }
  p++;
 }
 if (begin == 0) {
  as_string_cons(filename, 0, (char*)path, p - path, 0);
  return path;
 }
 if (begin == p) {
  p--;
  while (as_is_file_separator(*p)) {
   if (p == path) {
    char* value = "/";
    as_string_cons(filename, 0, value, 1, 0);
    return value;
   }
   p--;
  }
  const char* end = p;
  while (p != path && !as_is_file_separator(*p)) {
   p--;
  }
  if (as_is_file_separator(*p)) {
   p++;
  }
  size_t len = (end - p) + 1;
  char* str = cf_malloc(len + 1);
  memcpy(str, p, len);
  *(str + len) = 0;
  as_string_cons(filename, 0, str, len, 1);
  return str;
 }
 as_string_cons(filename, 0, (char*)begin, p - begin, 0);
 return begin;
}

canonical_original_code:
char *as_basename(struct as_string_s *filename, char *path)
{
 if (path == 0 || *path == 0) {
  char *value = ".";
  as_string_cons(filename, 0, value, 1, 0);
  return value;
 }
 char *p = path;
 char *begin = 0;
 while (*p) {
  if (as_is_file_separator(*p)) {
   begin = p + 1;
  }
  p++;
 }
 if (begin == 0) {
  as_string_cons(filename, 0, (char *)path, p - path, 0);
  return path;
 }
 if (begin == p) {
  p--;
  while (as_is_file_separator(*p)) {
   if (p == path) {
    char *value = "/";
    as_string_cons(filename, 0, value, 1, 0);
    return value;
   }
   p--;
  }
  char *end = p;
  while (p != path && !as_is_file_separator(*p)) {
   p--;
  }
  if (as_is_file_separator(*p)) {
   p++;
  }
  unsigned long len = (end - p) + 1;
  char *str = cf_malloc(len + 1);
  memcpy(str, p, len);
  *(str + len) = 0;
  as_string_cons(filename, 0, str, len, 1);
  return str;
 }
 as_string_cons(filename, 0, (char *)begin, p - begin, 0);
 return begin;
}

variable_types:
path
char *

variable_types:
p
char *

variable_types:
begin
char *

variable_types:
end
char *

variable_types:
str
char *


decompiled_code:
__int64 __fastcall as_string_val_destroy(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rbx

result = as_string_fromval(a1);
if ( result )
{
v2 = result;
if ( *(_QWORD *)(result + 16) && *(_BYTE *)(result + 8) )
{
result = cf_free();
*(_QWORD *)(v2 + 16) = 0LL;
*(_BYTE *)(v2 + 8) = 0;
}
else
{
*(_QWORD *)(result + 16) = 0LL;
*(_BYTE *)(result + 8) = 0;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rbx

result = func0(a1);
if ( result )
{
v2 = result;
if ( *(_QWORD *)(result + 16) && *(_BYTE *)(result + 8) )
{
result = cf_free();
*(_QWORD *)(v2 + 16) = 0LL;
*(_BYTE *)(v2 + 8) = 0;
}
else
{
*(_QWORD *)(result + 16) = 0LL;
*(_BYTE *)(result + 8) = 0;
}
}
return result;
}

original_code:
void as_string_val_destroy(as_val * v)
{
 as_string * string = as_string_fromval(v);
 if ( !string ) return;
 if ( string->value && string->free ) {
  cf_free(string->value);
 }
 string->value = ((void *)0);
 string->free = 0;
}

canonical_original_code:
void as_string_val_destroy(struct as_val_s *v)
{
 struct as_string_s *string = as_string_fromval(v);
 if ( !string ) return;
 if ( string->value && string->free ) {
  cf_free(string->value);
 }
 string->value = ((void *)0);
 string->free = 0;
}

variable_types: struct as_val_s { unsigned int count; unsigned char type; _Bool free; } *


decompiled_code:
__int64 __fastcall as_string_val_hashcode(__int64 a1)
{
__int64 v1; // rax
char *v2; // rax
char *v3; // rdx
int v4; // eax
unsigned int v5; // er8

v1 = as_string_fromval(a1);
if ( !v1 )
return 0LL;
v2 = *(char **)(v1 + 16);
if ( !v2 )
return 0LL;
v3 = v2 + 1;
v4 = *v2;
v5 = 0;
if ( (_BYTE)v4 )
{
do
{
++v3;
v5 = v4 + 65599 * v5;
v4 = *(v3 - 1);
}
while ( *(v3 - 1) );
}
return v5;
}

original_code:
uint32_t as_string_val_hashcode(const as_val * v)
{
 as_string * string = as_string_fromval(v);
 if ( string == ((void *)0) || string->value == ((void *)0)) return 0;
 uint32_t hash = 0;
 int c;
 char * str = string->value;
 while ( (c = *str++) ) {
  hash = c + (hash << 6) + (hash << 16) - hash;
 }
 return hash;
}

canonical_original_code:
unsigned int as_string_val_hashcode(struct as_val_s *v)
{
 struct as_string_s *string = as_string_fromval(v);
 if ( string == ((void *)0) || string->value == ((void *)0)) return 0;
 unsigned int hash = 0;
 int c;
 char *str = string->value;
 while ( (c = *str++) ) {
  hash = c + (hash << 6) + (hash << 16) - hash;
 }
 return hash;
}

variable_types:
hash
unsigned int

variable_types: c int


original_code:
_Bool
as_strncpy(char* trg, const char* src, int size)
{
 if (src) {
  int max = size - 1;
  int i = 0;
  while (*src) {
   if (i >= max) {
    *trg = 0;
    return 1;
   }
   *trg++ = *src++;
   i++;
  }
 }
 *trg = 0;
 return 0;
}

canonical_original_code:
_Bool as_strncpy(char *trg, char *src, int size)
{
 if (src) {
  int max = size - 1;
  int i = 0;
  while (*src) {
   if (i >= max) {
    *trg = 0;
    return 1;
   }
   *trg++ = *src++;
   i++;
  }
 }
 *trg = 0;
 return 0;
}

variable_types:
trg
char *

variable_types:
src
char *

variable_types: size int

variable_types: max int

variable_types: i int


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

if ( !a1 )
return 0LL;
result = 0LL;
if ( *(_BYTE *)(a1 + 4) == 11 )
result = a1;
return result;
}

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

if ( !a1 )
return 0LL;
result = 0LL;
if ( *(_BYTE *)(a1 + 4) == 11 )
result = a1;
return result;
}

original_code:
static inline as_geojson * as_geojson_fromval(const as_val * v)
{
 return (v && (v ? (as_val_type_e)((as_val *)v)->type : AS_UNDEF) == AS_GEOJSON ? (as_geojson *) v : ((void *)0));
}

canonical_original_code:
static inline struct as_geojson_s *as_geojson_fromval(struct as_val_s *v)
{
 return (v && (v ? (as_val_type_e)((struct as_val_s *)v)->type : AS_UNDEF) == AS_GEOJSON ? (struct as_geojson_s *) v : ((void *)0));
}

variable_types:
v
struct as_val_s *

return_type: struct as_geojson_s { struct as_val_s { unsigned int count; unsigned char type; _Bool free; } _; _Bool free; char *value; unsigned long len; } *

user_defined_types: struct as_geojson_s { struct as_val_s _; _Bool free; char *value; unsigned long len; }


decompiled_code:
void __fastcall as_geojson_cons(__int64 a1, char a2)
{
char v2; // r8
__int64 v3; // rdx
__int64 v4; // rcx

if ( a1 )
{
as_val_cons_constprop_0_isra_0(a1, a2);
*(_BYTE *)(a1 + 8) = v2;
*(_QWORD *)(a1 + 16) = v3;
*(_QWORD *)(a1 + 24) = v4;
}
}

original_code:
static inline as_geojson * as_geojson_cons(as_geojson * string, _Bool free, char * value, size_t len, _Bool value_free)
{
 if ( !string ) return string;
 as_val_cons((as_val *) string, AS_GEOJSON, free);
 string->free = value_free;
 string->value = value;
 string->len = len;
 return string;
}

canonical_original_code:
static inline struct as_geojson_s *as_geojson_cons(struct as_geojson_s *string, _Bool free, char *value, unsigned long len, _Bool value_free)
{
 if ( !string ) return string;
 as_val_cons((struct as_val_s *) string, AS_GEOJSON, free);
 string->free = value_free;
 string->value = value;
 string->len = len;
 return string;
}

variable_types:
string
struct as_geojson_s *

variable_types:
value
char *


decompiled_code:
void __fastcall as_geojson_init(__int64 a1)
{
as_geojson_cons(a1, 0);
}

canonical_decompiled_code:
void __fastcall func3(__int64 a1)
{
func2(a1, 0);
}

original_code:
as_geojson * as_geojson_init(as_geojson * string, char * value, _Bool free)
{
 return as_geojson_cons(string, 0, value, (18446744073709551615UL), free);
}

canonical_original_code:
struct as_geojson_s *as_geojson_init(struct as_geojson_s *string, char *value, _Bool free)
{
 return as_geojson_cons(string, 0, value, (18446744073709551615UL), free);
}


decompiled_code:
void __fastcall as_geojson_init_wlen(__int64 a1)
{
as_geojson_cons(a1, 0);
}

canonical_decompiled_code:
void __fastcall func4(__int64 a1)
{
func2(a1, 0);
}

original_code:
as_geojson * as_geojson_init_wlen(as_geojson * string, char * value, size_t len, _Bool free)
{
 return as_geojson_cons(string, 0, value, len, free);
}

canonical_original_code:
struct as_geojson_s *as_geojson_init_wlen(struct as_geojson_s *string, char *value, unsigned long len, _Bool free)
{
 return as_geojson_cons(string, 0, value, len, free);
}

variable_types:
len
unsigned long


decompiled_code:
void as_geojson_new()
{
__int64 v0; // rax

v0 = cf_malloc(32LL);
as_geojson_cons(v0, 1);
}

canonical_decompiled_code:
void func5()
{
__int64 v0; // rax

v0 = cf_malloc(32LL);
func2(v0, 1);
}

original_code:
as_geojson * as_geojson_new(char * value, _Bool free)
{
 as_geojson * string = (as_geojson *) cf_malloc(sizeof(as_geojson));
 return as_geojson_cons(string, 1, value, (18446744073709551615UL), free);
}

canonical_original_code:
struct as_geojson_s *as_geojson_new(char *value, _Bool free)
{
 struct as_geojson_s *string = (as_geojson *) cf_malloc(sizeof(as_geojson));
 return as_geojson_cons(string, 1, value, (18446744073709551615UL), free);
}

variable_types: struct as_geojson_s { struct as_val_s { unsigned int count; unsigned char type; _Bool free; } _; _Bool free; char *value; unsigned long len; } *


decompiled_code:
void as_geojson_new_wlen()
{
__int64 v0; // rax

v0 = cf_malloc(32LL);
as_geojson_cons(v0, 1);
}

canonical_decompiled_code:
void func6()
{
__int64 v0; // rax

v0 = cf_malloc(32LL);
func2(v0, 1);
}

original_code:
as_geojson * as_geojson_new_wlen(char * value, size_t len, _Bool free)
{
 as_geojson * string = (as_geojson *) cf_malloc(sizeof(as_geojson));
 return as_geojson_cons(string, 1, value, len, free);
}

canonical_original_code:
struct as_geojson_s *as_geojson_new_wlen(char *value, unsigned long len, _Bool free)
{
 struct as_geojson_s *string = (as_geojson *) cf_malloc(sizeof(as_geojson));
 return as_geojson_cons(string, 1, value, len, free);
}


decompiled_code:
void as_geojson_new_strdup()
{
cf_strdup();
as_geojson_new();
}

canonical_decompiled_code:
void func7()
{
cf_strdup();
func5();
}

original_code:
as_geojson *as_geojson_new_strdup(const char * s)
{
 return as_geojson_new(cf_strdup(s), 1);
}

canonical_original_code:
struct as_geojson_s *as_geojson_new_strdup(char *s)
{
 return as_geojson_new(cf_strdup(s), 1);
}

variable_types:
s
char *


decompiled_code:
size_t __fastcall as_geojson_len(__int64 a1)
{
const char *v2; // rdi
size_t result; // rax

v2 = *(const char **)(a1 + 16);
if ( !v2 )
return 0LL;
result = *(_QWORD *)(a1 + 24);
if ( result == -1LL )
{
result = strlen(v2);
*(_QWORD *)(a1 + 24) = result;
}
return result;
}

canonical_decompiled_code:
size_t __fastcall func8(__int64 a1)
{
const char *v2; // rdi
size_t result; // rax

v2 = *(const char **)(a1 + 16);
if ( !v2 )
return 0LL;
result = *(_QWORD *)(a1 + 24);
if ( result == -1LL )
{
result = strlen(v2);
*(_QWORD *)(a1 + 24) = result;
}
return result;
}

original_code:
size_t as_geojson_len(as_geojson * string)
{
 if (string->value == ((void *)0)) {
  return 0;
 }
 if (string->len == (18446744073709551615UL)) {
  string->len = strlen(string->value);
 }
 return string->len;
}

canonical_original_code:
unsigned long as_geojson_len(struct as_geojson_s *string)
{
 if (string->value == ((void *)0)) {
  return 0;
 }
 if (string->len == (18446744073709551615UL)) {
  string->len = strlen(string->value);
 }
 return string->len;
}


decompiled_code:
__int64 __fastcall as_geojson_val_destroy(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rbx

result = as_geojson_fromval(a1);
if ( result )
{
v2 = result;
if ( *(_QWORD *)(result + 16) && *(_BYTE *)(result + 8) )
{
result = cf_free();
*(_QWORD *)(v2 + 16) = 0LL;
*(_BYTE *)(v2 + 8) = 0;
}
else
{
*(_QWORD *)(result + 16) = 0LL;
*(_BYTE *)(result + 8) = 0;
}
}
return result;
}

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

result = func0(a1);
if ( result )
{
v2 = result;
if ( *(_QWORD *)(result + 16) && *(_BYTE *)(result + 8) )
{
result = cf_free();
*(_QWORD *)(v2 + 16) = 0LL;
*(_BYTE *)(v2 + 8) = 0;
}
else
{
*(_QWORD *)(result + 16) = 0LL;
*(_BYTE *)(result + 8) = 0;
}
}
return result;
}

original_code:
void as_geojson_val_destroy(as_val * v)
{
 as_geojson * string = as_geojson_fromval(v);
 if ( !string ) return;
 if ( string->value && string->free ) {
  cf_free(string->value);
 }
 string->value = ((void *)0);
 string->free = 0;
}

canonical_original_code:
void as_geojson_val_destroy(struct as_val_s *v)
{
 struct as_geojson_s *string = as_geojson_fromval(v);
 if ( !string ) return;
 if ( string->value && string->free ) {
  cf_free(string->value);
 }
 string->value = ((void *)0);
 string->free = 0;
}


decompiled_code:
__int64 __fastcall as_geojson_val_hashcode(__int64 a1)
{
__int64 v1; // rax
char *v2; // rax
char *v3; // rdx
int v4; // eax
unsigned int v5; // er8

v1 = as_geojson_fromval(a1);
if ( !v1 )
return 0LL;
v2 = *(char **)(v1 + 16);
if ( !v2 )
return 0LL;
v3 = v2 + 1;
v4 = *v2;
v5 = 0;
if ( (_BYTE)v4 )
{
do
{
++v3;
v5 = v4 + 65599 * v5;
v4 = *(v3 - 1);
}
while ( *(v3 - 1) );
}
return v5;
}

original_code:
uint32_t as_geojson_val_hashcode(const as_val * v)
{
 as_geojson * string = as_geojson_fromval(v);
 if ( string == ((void *)0) || string->value == ((void *)0)) return 0;
 uint32_t hash = 0;
 int c;
 char * str = string->value;
 while ( (c = *str++) ) {
  hash = c + (hash << 6) + (hash << 16) - hash;
 }
 return hash;
}

canonical_original_code:
unsigned int as_geojson_val_hashcode(struct as_val_s *v)
{
 struct as_geojson_s *string = as_geojson_fromval(v);
 if ( string == ((void *)0) || string->value == ((void *)0)) return 0;
 unsigned int hash = 0;
 int c;
 char *str = string->value;
 while ( (c = *str++) ) {
  hash = c + (hash << 6) + (hash << 16) - hash;
 }
 return hash;
}


decompiled_code:
__int64 cf_rand_reload()
{
int v0; // ebp
int v1; // ebx
const char *v3; // r8
__int64 v4; // rcx
void (__fastcall *v5)(_QWORD, const char *, const char *, __int64, const char *); // r9

if ( seeded )
{
LABEL_4:
if ( (unsigned int)RAND_bytes(&rand_buf, 0x2000LL) == 1 )
{
rand_buf_off = 0x2000;
return 0LL;
}
v5 = (void (__fastcall *)(_QWORD, const char *, const char *, __int64, const char *))g_as_log[1];
if ( v5 )
{
v3 = "Failed to reload random buffer";
v4 = 56LL;
goto LABEL_7;
}
return 0xFFFFFFFFLL;
}
v0 = open64("/dev/urandom", 0);
v1 = read(v0, &rand_buf, 0x40uLL);
if ( v1 > 63 )
{
close(v0);
RAND_seed(&rand_buf, (unsigned int)v1);
seeded = 1;
goto LABEL_4;
}
v3 = "Failed to seed random number generator";
v4 = 45LL;
v5 = (void (__fastcall *)(_QWORD, const char *, const char *, __int64, const char *))g_as_log[1];
if ( v5 )
LABEL_7:
v5(0LL, "cf_rand_reload", "src/main/citrusleaf/cf_random.c", v4, v3);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func0()
{
int v0; // ebp
int v1; // ebx
const char *v3; // r8
__int64 v4; // rcx
void (__fastcall *v5)(_QWORD, const char *, const char *, __int64, const char *); // r9

if ( seeded )
{
LABEL_4:
if ( (unsigned int)RAND_bytes(&rand_buf, 0x2000LL) == 1 )
{
rand_buf_off = 0x2000;
return 0LL;
}
v5 = (void (__fastcall *)(_QWORD, const char *, const char *, __int64, const char *))g_as_log[1];
if ( v5 )
{
v3 = "Failed to reload random buffer";
v4 = 56LL;
goto LABEL_7;
}
return 0xFFFFFFFFLL;
}
v0 = open64("/dev/urandom", 0);
v1 = read(v0, &rand_buf, 0x40uLL);
if ( v1 > 63 )
{
close(v0);
RAND_seed(&rand_buf, (unsigned int)v1);
seeded = 1;
goto LABEL_4;
}
v3 = "Failed to seed random number generator";
v4 = 45LL;
v5 = (void (__fastcall *)(_QWORD, const char *, const char *, __int64, const char *))g_as_log[1];
if ( v5 )
LABEL_7:
v5(0LL, "cf_rand_reload", "src/main/citrusleaf/cf_random.c", v4, v3);
return 0xFFFFFFFFLL;
}

original_code:
int
cf_rand_reload()
{
 if (seeded == 0) {
  int rfd = open("/dev/urandom", 00);
  int rsz = (int)read(rfd, rand_buf, 64);
  if (rsz < 64) {
   if (g_as_log.callback) { (g_as_log.callback) (AS_LOG_LEVEL_ERROR, __func__, "src/main/citrusleaf/cf_random.c", 45, "Failed to seed random number generator"); };
   return(-1);
  }
  close(rfd);
  RAND_seed(rand_buf, rsz);
  seeded = 1;
 }
 if (1 != RAND_bytes(rand_buf, sizeof(rand_buf))) {
  if (g_as_log.callback) { (g_as_log.callback) (AS_LOG_LEVEL_ERROR, __func__, "src/main/citrusleaf/cf_random.c", 56, "Failed to reload random buffer"); };
  return(-1);
 }
 rand_buf_off = sizeof(rand_buf);
 return 0;
}

variable_types: rfd int

variable_types: rsz int


decompiled_code:
__int64 __fastcall cf_get_rand_buf(_DWORD *a1, unsigned int a2)
{
__int64 v2; // rbx
int v3; // esi
unsigned int v4; // er12
__int64 v5; // rsi
char *v6; // rsi

v2 = a2;
if ( a2 > 0x1FFF )
return (unsigned int)-1;
pthread_mutex_lock(&rand_buf_lock);
v3 = rand_buf_off;
if ( (unsigned int)v2 > rand_buf_off )
{
v4 = cf_rand_reload();
if ( v4 == -1 )
{
pthread_mutex_unlock(&rand_buf_lock);
return v4;
}
v3 = rand_buf_off;
}
v5 = (unsigned int)(v3 - v2);
rand_buf_off = v5;
v6 = (char *)&rand_buf + v5;
if ( (unsigned int)v2 < 8 )
{
if ( (v2 & 4) != 0 )
{
*a1 = *(_DWORD *)v6;
*(_DWORD *)((char *)a1 + v2 - 4) = *(_DWORD *)&v6[v2 - 4];
}
else if ( (_DWORD)v2 )
{
*(_BYTE *)a1 = *v6;
if ( (v2 & 2) != 0 )
*(_WORD *)((char *)a1 + v2 - 2) = *(_WORD *)&v6[v2 - 2];
}
}
else
{
*(_QWORD *)a1 = *(_QWORD *)v6;
*(_QWORD *)((char *)a1 + (unsigned int)v2 - 8) = *(_QWORD *)&v6[(unsigned int)v2 - 8];
qmemcpy(
(void *)((unsigned __int64)(a1 + 2) & 0xFFFFFFFFFFFFFFF8LL),
(const void *)(v6 - ((char *)a1 - ((unsigned __int64)(a1 + 2) & 0xFFFFFFFFFFFFFFF8LL))),
8LL * (((unsigned int)v2 + (_DWORD)a1 - (((_DWORD)a1 + 8) & 0xFFFFFFF8)) >> 3));
}
v4 = 0;
pthread_mutex_unlock(&rand_buf_lock);
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func1(_DWORD *a1, unsigned int a2)
{
__int64 v2; // rbx
int v3; // esi
unsigned int v4; // er12
__int64 v5; // rsi
char *v6; // rsi

v2 = a2;
if ( a2 > 0x1FFF )
return (unsigned int)-1;
pthread_mutex_lock(&rand_buf_lock);
v3 = rand_buf_off;
if ( (unsigned int)v2 > rand_buf_off )
{
v4 = func0();
if ( v4 == -1 )
{
pthread_mutex_unlock(&rand_buf_lock);
return v4;
}
v3 = rand_buf_off;
}
v5 = (unsigned int)(v3 - v2);
rand_buf_off = v5;
v6 = (char *)&rand_buf + v5;
if ( (unsigned int)v2 < 8 )
{
if ( (v2 & 4) != 0 )
{
*a1 = *(_DWORD *)v6;
*(_DWORD *)((char *)a1 + v2 - 4) = *(_DWORD *)&v6[v2 - 4];
}
else if ( (_DWORD)v2 )
{
*(_BYTE *)a1 = *v6;
if ( (v2 & 2) != 0 )
*(_WORD *)((char *)a1 + v2 - 2) = *(_WORD *)&v6[v2 - 2];
}
}
else
{
*(_QWORD *)a1 = *(_QWORD *)v6;
*(_QWORD *)((char *)a1 + (unsigned int)v2 - 8) = *(_QWORD *)&v6[(unsigned int)v2 - 8];
qmemcpy(
(void *)((unsigned __int64)(a1 + 2) & 0xFFFFFFFFFFFFFFF8LL),
(const void *)(v6 - ((char *)a1 - ((unsigned __int64)(a1 + 2) & 0xFFFFFFFFFFFFFFF8LL))),
8LL * (((unsigned int)v2 + (_DWORD)a1 - (((_DWORD)a1 + 8) & 0xFFFFFFF8)) >> 3));
}
v4 = 0;
pthread_mutex_unlock(&rand_buf_lock);
return v4;
}

original_code:
int
cf_get_rand_buf(uint8_t *buf, int len)
{
    if ((uint32_t)len >= sizeof(rand_buf)) return(-1);
    pthread_mutex_lock(&rand_buf_lock);
    if (rand_buf_off < (uint32_t)len ) {
        if (-1 == cf_rand_reload()) {
            pthread_mutex_unlock(&rand_buf_lock);
            return(-1);
        }
    }
    rand_buf_off -= len;
    memcpy(buf, &rand_buf[rand_buf_off] ,len);
    pthread_mutex_unlock(&rand_buf_lock);
    return(0);
}

canonical_original_code:
int cf_get_rand_buf(unsigned char *buf, int len)
{
    if ((unsigned int)len >= sizeof(rand_buf)) return(-1);
    pthread_mutex_lock(&rand_buf_lock);
    if (rand_buf_off < (unsigned int)len ) {
        if (-1 == cf_rand_reload()) {
            pthread_mutex_unlock(&rand_buf_lock);
            return(-1);
        }
    }
    rand_buf_off -= len;
    memcpy(buf, &rand_buf[rand_buf_off] ,len);
    pthread_mutex_unlock(&rand_buf_lock);
    return(0);
}

variable_types:
buf
unsigned char *

variable_types: len int


decompiled_code:
__int64 cf_get_rand64()
{
int v0; // eax
__int64 v1; // r12

pthread_mutex_lock(&rand_buf_lock);
v0 = rand_buf_off;
if ( (unsigned int)rand_buf_off <= 7 )
{
if ( (unsigned int)cf_rand_reload() == -1 )
{
v1 = 0LL;
pthread_mutex_unlock(&rand_buf_lock);
return v1;
}
v0 = rand_buf_off;
}
rand_buf_off = v0 - 8;
v1 = *(_QWORD *)((char *)&rand_buf + (unsigned int)(v0 - 8));
pthread_mutex_unlock(&rand_buf_lock);
return v1;
}

canonical_decompiled_code:
__int64 func2()
{
int v0; // eax
__int64 v1; // r12

pthread_mutex_lock(&rand_buf_lock);
v0 = rand_buf_off;
if ( (unsigned int)rand_buf_off <= 7 )
{
if ( (unsigned int)func0() == -1 )
{
v1 = 0LL;
pthread_mutex_unlock(&rand_buf_lock);
return v1;
}
v0 = rand_buf_off;
}
rand_buf_off = v0 - 8;
v1 = *(_QWORD *)((char *)&rand_buf + (unsigned int)(v0 - 8));
pthread_mutex_unlock(&rand_buf_lock);
return v1;
}

original_code:
uint64_t
cf_get_rand64()
{
    pthread_mutex_lock(&rand_buf_lock);
    if (rand_buf_off < sizeof(uint64_t) ) {
        if (-1 == cf_rand_reload()) {
            pthread_mutex_unlock(&rand_buf_lock);
            return(0);
        }
    }
    rand_buf_off -= sizeof(uint64_t);
    uint64_t r = *(uint64_t *) (&rand_buf[rand_buf_off]);
    pthread_mutex_unlock(&rand_buf_lock);
    return(r);
}

canonical_original_code:
unsigned long cf_get_rand64()
{
    pthread_mutex_lock(&rand_buf_lock);
    if (rand_buf_off < sizeof(unsigned long) ) {
        if (-1 == cf_rand_reload()) {
            pthread_mutex_unlock(&rand_buf_lock);
            return(0);
        }
    }
    rand_buf_off -= sizeof(unsigned long);
    unsigned long r = *(uint64_t *) (&rand_buf[rand_buf_off]);
    pthread_mutex_unlock(&rand_buf_lock);
    return(r);
}

variable_types:
r
unsigned long


decompiled_code:
__int64 cf_get_rand32()
{
int v0; // eax
unsigned int v1; // eax
__int64 v2; // rbx

pthread_mutex_lock(&rand_buf_lock);
v0 = rand_buf_off;
if ( (unsigned int)rand_buf_off > 7 )
goto LABEL_4;
if ( (unsigned int)cf_rand_reload() != -1 )
{
v0 = rand_buf_off;
LABEL_4:
v1 = v0 - 8;
v2 = *(_QWORD *)((char *)&rand_buf + v1);
rand_buf_off = v1;
pthread_mutex_unlock(&rand_buf_lock);
return (unsigned int)v2;
}
pthread_mutex_unlock(&rand_buf_lock);
return 0LL;
}

canonical_decompiled_code:
__int64 func3()
{
int v0; // eax
unsigned int v1; // eax
__int64 v2; // rbx

pthread_mutex_lock(&rand_buf_lock);
v0 = rand_buf_off;
if ( (unsigned int)rand_buf_off > 7 )
goto LABEL_4;
if ( (unsigned int)func0() != -1 )
{
v0 = rand_buf_off;
LABEL_4:
v1 = v0 - 8;
v2 = *(_QWORD *)((char *)&rand_buf + v1);
rand_buf_off = v1;
pthread_mutex_unlock(&rand_buf_lock);
return (unsigned int)v2;
}
pthread_mutex_unlock(&rand_buf_lock);
return 0LL;
}

original_code:
uint32_t
cf_get_rand32()
{
    pthread_mutex_lock(&rand_buf_lock);
    if (rand_buf_off < sizeof(uint64_t) ) {
        if (-1 == cf_rand_reload()) {
            pthread_mutex_unlock(&rand_buf_lock);
            return(0);
        }
    }
    rand_buf_off -= sizeof(uint64_t);
    uint64_t r = *(uint64_t *) (&rand_buf[rand_buf_off]);
    pthread_mutex_unlock(&rand_buf_lock);
    return((uint32_t)r);
}

canonical_original_code:
unsigned int cf_get_rand32()
{
    pthread_mutex_lock(&rand_buf_lock);
    if (rand_buf_off < sizeof(unsigned long) ) {
        if (-1 == cf_rand_reload()) {
            pthread_mutex_unlock(&rand_buf_lock);
            return(0);
        }
    }
    rand_buf_off -= sizeof(unsigned long);
    unsigned long r = *(uint64_t *) (&rand_buf[rand_buf_off]);
    pthread_mutex_unlock(&rand_buf_lock);
    return((unsigned int)r);
}


decompiled_code:
__int64 __fastcall as_buffer_init(_QWORD *a1)
{
__int64 result; // rax

*a1 = 0LL;
result = 0LL;
a1[1] = 0LL;
return result;
}

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

*a1 = 0LL;
result = 0LL;
a1[1] = 0LL;
return result;
}

original_code:
int as_buffer_init(as_buffer * b) {
    b->capacity = 0;
    b->size = 0;
    b->data = ((void *)0);
    return 0;
}

canonical_original_code:
int as_buffer_init(struct as_buffer_s *b) {
    b->capacity = 0;
    b->size = 0;
    b->data = ((void *)0);
    return 0;
}

variable_types: struct as_buffer_s { unsigned int capacity; unsigned int size; unsigned char *data; } *


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

if ( *(_QWORD *)(a1 + 8) )
{
result = cf_free();
*(_QWORD *)(a1 + 8) = 0LL;
}
return result;
}

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

if ( *(_QWORD *)(a1 + 8) )
{
result = cf_free();
*(_QWORD *)(a1 + 8) = 0LL;
}
return result;
}

original_code:
void as_buffer_destroy(as_buffer * b) {
 if ( b->data ) {
  cf_free(b->data);
  b->data = 0;
 }
    return;
}

canonical_original_code:
void as_buffer_destroy(struct as_buffer_s *b) {
 if ( b->data ) {
  cf_free(b->data);
  b->data = 0;
 }
    return;
}

user_defined_types: struct as_buffer_s { unsigned int capacity; unsigned int size; unsigned char *data; }


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

if ( !a1 )
return 0LL;
result = 0LL;
if ( *(_BYTE *)(a1 + 4) == 2 )
result = a1;
return result;
}

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

if ( !a1 )
return 0LL;
result = 0LL;
if ( *(_BYTE *)(a1 + 4) == 2 )
result = a1;
return result;
}

original_code:
static inline as_boolean * as_boolean_fromval(const as_val * v) {
 return (v && (v ? (as_val_type_e)((as_val *)v)->type : AS_UNDEF) == AS_BOOLEAN ? (as_boolean *) v : ((void *)0));
}

canonical_original_code:
static inline struct as_boolean_s *as_boolean_fromval(struct as_val_s *v) {
 return (v && (v ? (as_val_type_e)((struct as_val_s *)v)->type : AS_UNDEF) == AS_BOOLEAN ? (struct as_boolean_s *) v : ((void *)0));
}

return_type: struct as_boolean_s { struct as_val_s { unsigned int count; unsigned char type; _Bool free; } _; _Bool value; } *

user_defined_types: struct as_boolean_s { struct as_val_s _; _Bool value; }


decompiled_code:
void __fastcall as_boolean_cons(__int64 a1, char a2)
{
char v2; // dl

if ( a1 )
{
as_val_cons_constprop_0_isra_0(a1, a2);
*(_BYTE *)(a1 + 8) = v2;
}
}

canonical_decompiled_code:
void __fastcall func2(__int64 a1, char a2)
{
char v2; // dl

if ( a1 )
{
func1(a1, a2);
*(_BYTE *)(a1 + 8) = v2;
}
}

original_code:
static inline as_boolean * as_boolean_cons(as_boolean * boolean, _Bool free, _Bool value)
{
 if ( !boolean ) return boolean;
 as_val_cons((as_val *) boolean, AS_BOOLEAN, free);
 boolean->value = value;
 return boolean;
}

canonical_original_code:
static inline struct as_boolean_s *as_boolean_cons(struct as_boolean_s *boolean, _Bool free, _Bool value)
{
 if ( !boolean ) return boolean;
 as_val_cons((struct as_val_s *) boolean, AS_BOOLEAN, free);
 boolean->value = value;
 return boolean;
}

variable_types:
boolean
struct as_boolean_s *


decompiled_code:
void __fastcall as_boolean_init(__int64 a1)
{
as_boolean_cons(a1, 0);
}

original_code:
as_boolean * as_boolean_init(as_boolean * boolean, _Bool value)
{
 return as_boolean_cons(boolean, 0, value);
}

canonical_original_code:
struct as_boolean_s *as_boolean_init(struct as_boolean_s *boolean, _Bool value)
{
 return as_boolean_cons(boolean, 0, value);
}


decompiled_code:
void as_boolean_new()
{
__int64 v0; // rax

v0 = cf_malloc(12LL);
as_boolean_cons(v0, 1);
}

canonical_decompiled_code:
void func4()
{
__int64 v0; // rax

v0 = cf_malloc(12LL);
func2(v0, 1);
}

original_code:
as_boolean * as_boolean_new(_Bool value)
{
 as_boolean * boolean = (as_boolean *) cf_malloc(sizeof(as_boolean));
 return as_boolean_cons(boolean, 1, value);
}

canonical_original_code:
struct as_boolean_s *as_boolean_new(_Bool value)
{
 struct as_boolean_s *boolean = (as_boolean *) cf_malloc(sizeof(as_boolean));
 return as_boolean_cons(boolean, 1, value);
}

variable_types: struct as_boolean_s { struct as_val_s { unsigned int count; unsigned char type; _Bool free; } _; _Bool value; } *


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

result = as_boolean_fromval(a1);
if ( result )
*(_BYTE *)(result + 8) = 0;
return result;
}

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

result = func0(a1);
if ( result )
*(_BYTE *)(result + 8) = 0;
return result;
}

original_code:
void as_boolean_val_destroy(as_val * v)
{
 as_boolean * boolean = as_boolean_fromval(v);
 if ( !boolean ) return;
 boolean->value = 0;
}

canonical_original_code:
void as_boolean_val_destroy(struct as_val_s *v)
{
 struct as_boolean_s *boolean = as_boolean_fromval(v);
 if ( !boolean ) return;
 boolean->value = 0;
}

variable_types: struct as_val_s { unsigned int count; unsigned char type; _Bool free; } *