decompiled_code:
__int64 __fastcall ht_cond_notify(unsigned __int64 *a1, int a2)
{
unsigned __int64 v2; // rax
__int64 v3; // rdx
unsigned __int64 v4; // rax
__int64 result; // rax

if ( a1 )
{
v2 = *a1;
if ( (*a1 & 1) != 0 )
{
if ( *((_DWORD *)a1 + 2) )
{
v3 = v2 | 6;
v4 = v2 & 0xFFFFFFFFFFFFFFFBLL | 2;
if ( a2 )
v4 = v3;
*a1 = v4 & 0xFFFFFFFFFFFFFFF7LL;
ht_yield(0LL);
}
result = 1LL;
}
else
{
*_errno_location() = 35;
result = 0LL;
}
}
else
{
*_errno_location() = 22;
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(unsigned __int64 *a1, int a2)
{
unsigned __int64 v2; // rax
__int64 v3; // rdx
unsigned __int64 v4; // rax
__int64 result; // rax

if ( a1 )
{
v2 = *a1;
if ( (*a1 & 1) != 0 )
{
if ( *((_DWORD *)a1 + 2) )
{
v3 = v2 | 6;
v4 = v2 & 0xFFFFFFFFFFFFFFFBLL | 2;
if ( a2 )
v4 = v3;
*a1 = v4 & 0xFFFFFFFFFFFFFFF7LL;
ht_yield(0LL);
}
result = 1LL;
}
else
{
*_errno_location() = 35;
result = 0LL;
}
}
else
{
*_errno_location() = 22;
result = 0LL;
}
return result;
}

original_code:
int
ht_cond_notify(ht_cond_t *cond, int broadcast)
{
    if (cond == ((void *)0))
        return ((*__errno_location ()) = (22), ((0)));
    if (!(cond->cn_state & (1<<(0))))
        return ((*__errno_location ()) = (35), ((0)));
    if (cond->cn_waiters > 0) {
        cond->cn_state |= (1<<(1));
        if (broadcast)
            cond->cn_state |= (1<<(2));
        else
            cond->cn_state &= ~((1<<(2)));
        cond->cn_state &= ~((1<<(3)));
        ht_yield(((void *)0));
    }
    return (!(0));
}

canonical_original_code:
int ht_cond_notify(struct ht_cond_st *cond, int broadcast)
{
    if (cond == ((void *)0))
        return ((*__errno_location ()) = (22), ((0)));
    if (!(cond->cn_state & (1<<(0))))
        return ((*__errno_location ()) = (35), ((0)));
    if (cond->cn_waiters > 0) {
        cond->cn_state |= (1<<(1));
        if (broadcast)
            cond->cn_state |= (1<<(2));
        else
            cond->cn_state &= ~((1<<(2)));
        cond->cn_state &= ~((1<<(3)));
        ht_yield(((void *)0));
    }
    return (!(0));
}

variable_types: broadcast int


repo: watsonjiang/hybirdthread

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

if ( a1 && a2 > 0 )
{
if ( (unsigned int)ht_mutex_init(a1 + 40) && (unsigned int)ht_cond_init(a1 + 24) )
{
*(_QWORD *)a1 = 1LL;
result = 1LL;
*(_DWORD *)(a1 + 8) = a2;
*(_DWORD *)(a1 + 12) = a2;
*(_DWORD *)(a1 + 16) = 0;
}
else
{
result = 0LL;
}
}
else
{
*_errno_location() = 22;
result = 0LL;
}
return result;
}

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

if ( a1 && a2 > 0 )
{
if ( (unsigned int)func0(a1 + 40) && (unsigned int)func8(a1 + 24) )
{
*(_QWORD *)a1 = 1LL;
result = 1LL;
*(_DWORD *)(a1 + 8) = a2;
*(_DWORD *)(a1 + 12) = a2;
*(_DWORD *)(a1 + 16) = 0;
}
else
{
result = 0LL;
}
}
else
{
*_errno_location() = 22;
result = 0LL;
}
return result;
}

original_code:
int
ht_barrier_init(ht_barrier_t *barrier, int threshold)
{
    if (barrier == ((void *)0) || threshold <= 0)
        return ((*__errno_location ()) = (22), ((0)));
    if (!ht_mutex_init(&(barrier->br_mutex)))
        return (0);
    if (!ht_cond_init(&(barrier->br_cond)))
        return (0);
    barrier->br_state = (1<<(0));
    barrier->br_threshold = threshold;
    barrier->br_count = threshold;
    barrier->br_cycle = (0);
    return (!(0));
}

canonical_original_code:
int ht_barrier_init(struct ht_barrier_st *barrier, int threshold)
{
    if (barrier == ((void *)0) || threshold <= 0)
        return ((*__errno_location ()) = (22), ((0)));
    if (!ht_mutex_init(&(barrier->br_mutex)))
        return (0);
    if (!ht_cond_init(&(barrier->br_cond)))
        return (0);
    barrier->br_state = (1<<(0));
    barrier->br_threshold = threshold;
    barrier->br_count = threshold;
    barrier->br_cycle = (0);
    return (!(0));
}

variable_types: struct ht_barrier_st { unsigned long br_state; int br_threshold; int br_count; int br_cycle; struct ht_cond_st { unsigned long cn_state; unsigned int cn_waiters; } br_cond; struct ht_mutex_st { struct ht_ringnode_st { struct ht_ringnode_st *rn_next; struct ht_ringnode_st *rn_prev; } mx_node; int mx_state; struct ht_st { struct ht_st *q_next; struct ht_st *q_prev; int q_prio; int prio; char name[40]; int dispatches; enum ht_state_en { HT_STATE_SCHEDULER=0, HT_STATE_NEW=1, HT_STATE_READY=2, HT_STATE_WAITING=3, HT_STATE_WAITING_FOR_SCHED_TO_WORKER=4, HT_STATE_DEAD=5 } state; struct timeval { long tv_sec; long tv_usec; } spawned; struct timeval lastran; struct timeval running; struct ht_event_st { struct ht_event_st *ev_next; struct ht_event_st *ev_prev; enum ht_status_t { HT_STATUS_PENDING=0, HT_STATUS_OCCURRED=1, HT_STATUS_FAILED=2 } ev_status; int ev_type; int ev_goal; union { struct { int fd; } FD; struct { int *n; int nfd; struct fd_set { long __fds_bits[-1]; } *rfds; } SELECT; struct { int fini; } TASK; struct { struct timeval tv; } TIME; struct { struct ht_msgport_st { struct ht_ringnode_st mp_node; char *mp_name; struct ht_st *mp_tid; struct ht_ring_st { struct ht_ringnode_st *r_hook; unsigned int r_nodes; } mp_queue; } *mp; } MSG; struct { struct ht_mutex_st *mutex; } MUTEX; struct { struct ht_cond_st *cond; } COND; struct { struct ht_st *tid; } TID; struct { int (*func)(void *); void *arg; struct timeval tv; } FUNC; } ev_args; } *events; struct ht_mctx_st { struct ucontext_t { unsigned long uc_flags; struct ucontext_t *uc_link; struct stack_t { void *ss_sp; int ss_flags; unsigned long ss_size; } uc_stack; struct mcontext_t { long long gregs[23]; struct _libc_fpstate { unsigned short cwd; unsigned short swd; unsigned short ftw; unsigned short fop; unsigned long rip; unsigned long rdp; unsigned int mxcsr; unsigned int mxcr_mask; struct _libc_fpxreg { unsigned short significand[4]; unsigned short exponent; unsigned short __glibc_reserved1[3]; } _st[8]; struct _libc_xmmreg { unsigned int element[4]; } _xmm[16]; unsigned int __glibc_reserved1[24]; } *fpregs; unsigned long long __reserved1[8]; } uc_mcontext; struct __sigset_t { unsigned long __val[-1]; } uc_sigmask; struct _libc_fpstate __fpregs_mem; unsigned long long __ssp[4]; } uc; int restored; int error; } mctx; char *stack; unsigned int stacksize; long *stackguard; int stackloan; void *(*start_func)(void *); void *start_arg; int joinable; void *join_arg; void **data_value; int data_count; int cancelreq; unsigned int cancelstate; struct ht_cleanup_st { struct ht_cleanup_st *next; void (*func)(void *); void *arg; } *cleanups; struct ht_ring_st mutexring; } *mx_owner; unsigned long mx_count; } br_mutex; } *

variable_types: threshold int

return_type: int

user_defined_types: struct ht_barrier_st { unsigned long br_state; int br_threshold; int br_count; int br_cycle; struct ht_cond_st br_cond; struct ht_mutex_st br_mutex; }

user_defined_types: struct ht_mutex_st { struct ht_ringnode_st mx_node; int mx_state; struct ht_st *mx_owner; unsigned long mx_count; }

user_defined_types: struct ht_st { struct ht_st *q_next; struct ht_st *q_prev; int q_prio; int prio; char name[40]; int dispatches; enum ht_state_en state; struct timeval spawned; struct timeval lastran; struct timeval running; struct ht_event_st *events; struct ht_mctx_st mctx; char *stack; unsigned int stacksize; long *stackguard; int stackloan; void *(*start_func)(void *); void *start_arg; int joinable; void *join_arg; void **data_value; int data_count; int cancelreq; unsigned int cancelstate; struct ht_cleanup_st *cleanups; struct ht_ring_st mutexring; }

user_defined_types: struct ht_mctx_st { struct ucontext_t uc; int restored; int error; }

user_defined_types: struct ht_event_st { struct ht_event_st *ev_next; struct ht_event_st *ev_prev; enum ht_status_t ev_status; int ev_type; int ev_goal; union { struct { int fd; } FD; struct { int *n; int nfd; struct fd_set *rfds; } SELECT; struct { int fini; } TASK; struct { struct timeval tv; } TIME; struct { struct ht_msgport_st *mp; } MSG; struct { struct ht_mutex_st *mutex; } MUTEX; struct { struct ht_cond_st *cond; } COND; struct { struct ht_st *tid; } TID; struct { int (*func)(void *); void *arg; struct timeval tv; } FUNC; } ev_args; }

user_defined_types: struct ucontext_t { unsigned long uc_flags; struct ucontext_t *uc_link; struct stack_t uc_stack; struct mcontext_t uc_mcontext; struct __sigset_t uc_sigmask; struct _libc_fpstate __fpregs_mem; unsigned long long __ssp[4]; }

user_defined_types: struct mcontext_t { long long gregs[23]; struct _libc_fpstate *fpregs; unsigned long long __reserved1[8]; }

user_defined_types: struct _libc_fpstate { unsigned short cwd; unsigned short swd; unsigned short ftw; unsigned short fop; unsigned long rip; unsigned long rdp; unsigned int mxcsr; unsigned int mxcr_mask; struct _libc_fpxreg _st[8]; struct _libc_xmmreg _xmm[16]; unsigned int __glibc_reserved1[24]; }

user_defined_types: struct ht_msgport_st { struct ht_ringnode_st mp_node; char *mp_name; struct ht_st *mp_tid; struct ht_ring_st mp_queue; }


decompiled_code:
__int64 __fastcall ht_barrier_reach(__int64 a1)
{
unsigned int v1; // er12
__int64 v3; // rbp
bool v4; // zf
int v5; // er13
unsigned int v6; // er12
unsigned int v7[11]; // [rsp+Ch] [rbp-2Ch] BYREF

if ( !a1 || (*(_BYTE *)a1 & 1) == 0 )
{
v1 = 0;
*_errno_location() = 22;
return v1;
}
v3 = a1 + 40;
v1 = ht_mutex_acquire(a1 + 40, 0, 0LL);
if ( !v1 )
return v1;
v4 = (*(_DWORD *)(a1 + 12))-- == 1;
v5 = *(_DWORD *)(a1 + 16);
if ( v4 )
{
*(_DWORD *)(a1 + 16) = v5 == 0;
*(_DWORD *)(a1 + 12) = *(_DWORD *)(a1 + 8);
v6 = ht_cond_notify((unsigned __int64 *)(a1 + 24), 1);
if ( v6 )
v6 = -2;
}
else
{
ht_cancel_state(2LL, v7);
v6 = 2 * (*(_DWORD *)(a1 + 8) != *(_DWORD *)(a1 + 12)) - 1;
do
{
if ( *(_DWORD *)(a1 + 16) != v5 )
break;
v6 = ht_cond_await(a1 + 24, v3, 0LL);
}
while ( v6 );
ht_cancel_state(v7[0], 0LL);
}
ht_mutex_release(v3);
return v6;
}

original_code:
int
ht_barrier_reach(ht_barrier_t *barrier)
{
    int cancel, cycle;
    int rv;
    if (barrier == ((void *)0))
        return ((*__errno_location ()) = (22), ((0)));
    if (!(barrier->br_state & (1<<(0))))
        return ((*__errno_location ()) = (22), ((0)));
    if (!ht_mutex_acquire(&(barrier->br_mutex), (0), ((void *)0)))
        return (0);
    cycle = barrier->br_cycle;
    if (--(barrier->br_count) == 0) {
        barrier->br_cycle = !(barrier->br_cycle);
        barrier->br_count = barrier->br_threshold;
        if ((rv = ht_cond_notify(&(barrier->br_cond), (!(0)))))
            rv = (-2);
    }
    else {
        ht_cancel_state((1<<(1)), &cancel);
        if (barrier->br_threshold == barrier->br_count)
            rv = (-1);
        else
            rv = (!(0));
        while (cycle == barrier->br_cycle) {
            if (!(rv = ht_cond_await(&(barrier->br_cond), &(barrier->br_mutex), ((void *)0))))
                break;
        }
        ht_cancel_state(cancel, ((void *)0));
    }
    ht_mutex_release(&(barrier->br_mutex));
    return rv;
}

canonical_original_code:
int ht_barrier_reach(struct ht_barrier_st *barrier)
{
    int cancel; int cycle;
    int rv;
    if (barrier == ((void *)0))
        return ((*__errno_location ()) = (22), ((0)));
    if (!(barrier->br_state & (1<<(0))))
        return ((*__errno_location ()) = (22), ((0)));
    if (!ht_mutex_acquire(&(barrier->br_mutex), (0), ((void *)0)))
        return (0);
    cycle = barrier->br_cycle;
    if (--(barrier->br_count) == 0) {
        barrier->br_cycle = !(barrier->br_cycle);
        barrier->br_count = barrier->br_threshold;
        if ((rv = ht_cond_notify(&(barrier->br_cond), (!(0)))))
            rv = (-2);
    }
    else {
        ht_cancel_state((1<<(1)), &cancel);
        if (barrier->br_threshold == barrier->br_count)
            rv = (-1);
        else
            rv = (!(0));
        while (cycle == barrier->br_cycle) {
            if (!(rv = ht_cond_await(&(barrier->br_cond), &(barrier->br_mutex), ((void *)0))))
                break;
        }
        ht_cancel_state(cancel, ((void *)0));
    }
    ht_mutex_release(&(barrier->br_mutex));
    return rv;
}

variable_types: cancel int

variable_types: cycle int

variable_types: rv int

user_defined_types: struct ht_cond_st { unsigned long cn_state; unsigned int cn_waiters; }

user_defined_types: struct ht_ringnode_st { struct ht_ringnode_st *rn_next; struct ht_ringnode_st *rn_prev; }

user_defined_types: enum ht_state_en { HT_STATE_SCHEDULER=0, HT_STATE_NEW=1, HT_STATE_READY=2, HT_STATE_WAITING=3, HT_STATE_WAITING_FOR_SCHED_TO_WORKER=4, HT_STATE_DEAD=5 }

user_defined_types: struct timeval { long tv_sec; long tv_usec; }

user_defined_types: struct ht_cleanup_st { struct ht_cleanup_st *next; void (*func)(void *); void *arg; }

user_defined_types: enum ht_status_t { HT_STATUS_PENDING=0, HT_STATUS_OCCURRED=1, HT_STATUS_FAILED=2 }

user_defined_types: struct stack_t { void *ss_sp; int ss_flags; unsigned long ss_size; }

user_defined_types: struct __sigset_t { unsigned long __val[-1]; }

user_defined_types: struct ht_ring_st { struct ht_ringnode_st *r_hook; unsigned int r_nodes; }

user_defined_types: struct _libc_fpxreg { unsigned short significand[4]; unsigned short exponent; unsigned short __glibc_reserved1[3]; }

user_defined_types: struct _libc_xmmreg { unsigned int element[4]; }


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

v2 = malloc(8LL * a2);
*(_DWORD *)(a1 + 8) = a2;
*(_QWORD *)a1 = v2;
pthread_cond_init((pthread_cond_t *)(a1 + 112), 0LL);
pthread_cond_init((pthread_cond_t *)(a1 + 64), 0LL);
pthread_mutex_init((pthread_mutex_t *)(a1 + 24), 0LL);
*(_DWORD *)(a1 + 12) = 0;
result = 0LL;
*(_QWORD *)(a1 + 16) = 0LL;
return result;
}

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

v2 = malloc(8LL * a2);
*(_DWORD *)(a1 + 8) = a2;
*(_QWORD *)a1 = v2;
pthread_cond_init((pthread_cond_t *)(a1 + 112), 0LL);
pthread_cond_init((pthread_cond_t *)(a1 + 64), 0LL);
pthread_mutex_init((pthread_mutex_t *)(a1 + 24), 0LL);
*(_DWORD *)(a1 + 12) = 0;
result = 0LL;
*(_QWORD *)(a1 + 16) = 0LL;
return result;
}

original_code:
int
ht_tqueue_init(ht_tqueue_t * q, int size)
{
   q->q_list = (ht_t*) malloc(sizeof(ht_t) * size);
   q->q_size = size;
   pthread_cond_init(&q->q_not_full, ((void *)0));
   pthread_cond_init(&q->q_not_empty, ((void *)0));
   pthread_mutex_init(&q->q_lock, ((void *)0));
   q->q_head = q->q_rear = 0;
   q->q_isfull = 0;
   return 0;
}

canonical_original_code:
int ht_tqueue_init(struct ht_tqueue_st *q, int size)
{
   q->q_list = (struct ht_st **) malloc(sizeof(ht_t) * size);
   q->q_size = size;
   pthread_cond_init(&q->q_not_full, ((void *)0));
   pthread_cond_init(&q->q_not_empty, ((void *)0));
   pthread_mutex_init(&q->q_lock, ((void *)0));
   q->q_head = q->q_rear = 0;
   q->q_isfull = 0;
   return 0;
}

variable_types: struct ht_tqueue_st { struct ht_st { struct ht_st *q_next; struct ht_st *q_prev; int q_prio; int prio; char name[40]; int dispatches; enum ht_state_en { HT_STATE_SCHEDULER=0, HT_STATE_NEW=1, HT_STATE_READY=2, HT_STATE_WAITING=3, HT_STATE_WAITING_FOR_SCHED_TO_WORKER=4, HT_STATE_DEAD=5 } state; struct timeval { long tv_sec; long tv_usec; } spawned; struct timeval lastran; struct timeval running; struct ht_event_st { struct ht_event_st *ev_next; struct ht_event_st *ev_prev; enum ht_status_t { HT_STATUS_PENDING=0, HT_STATUS_OCCURRED=1, HT_STATUS_FAILED=2 } ev_status; int ev_type; int ev_goal; union { struct { int fd; } FD; struct { int *n; int nfd; struct fd_set { long __fds_bits[-1]; } *rfds; } SELECT; struct { int fini; } TASK; struct { struct timeval tv; } TIME; struct { struct ht_msgport_st { struct ht_ringnode_st { struct ht_ringnode_st *rn_next; struct ht_ringnode_st *rn_prev; } mp_node; char *mp_name; struct ht_st *mp_tid; struct ht_ring_st { struct ht_ringnode_st *r_hook; unsigned int r_nodes; } mp_queue; } *mp; } MSG; struct { struct ht_mutex_st { struct ht_ringnode_st mx_node; int mx_state; struct ht_st *mx_owner; unsigned long mx_count; } *mutex; } MUTEX; struct { struct ht_cond_st { unsigned long cn_state; unsigned int cn_waiters; } *cond; } COND; struct { struct ht_st *tid; } TID; struct { int (*func)(void *); void *arg; struct timeval tv; } FUNC; } ev_args; } *events; struct ht_mctx_st { struct ucontext_t { unsigned long uc_flags; struct ucontext_t *uc_link; struct stack_t { void *ss_sp; int ss_flags; unsigned long ss_size; } uc_stack; struct mcontext_t { long long gregs[23]; struct _libc_fpstate { unsigned short cwd; unsigned short swd; unsigned short ftw; unsigned short fop; unsigned long rip; unsigned long rdp; unsigned int mxcsr; unsigned int mxcr_mask; struct _libc_fpxreg { unsigned short significand[4]; unsigned short exponent; unsigned short __glibc_reserved1[3]; } _st[8]; struct _libc_xmmreg { unsigned int element[4]; } _xmm[16]; unsigned int __glibc_reserved1[24]; } *fpregs; unsigned long long __reserved1[8]; } uc_mcontext; struct __sigset_t { unsigned long __val[-1]; } uc_sigmask; struct _libc_fpstate __fpregs_mem; unsigned long long __ssp[4]; } uc; int restored; int error; } mctx; char *stack; unsigned int stacksize; long *stackguard; int stackloan; void *(*start_func)(void *); void *start_arg; int joinable; void *join_arg; void **data_value; int data_count; int cancelreq; unsigned int cancelstate; struct ht_cleanup_st { struct ht_cleanup_st *next; void (*func)(void *); void *arg; } *cleanups; struct ht_ring_st mutexring; } **q_list; int q_size; int q_head; int q_rear; int q_isfull; 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; } q_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; } q_not_empty; union pthread_cond_t q_not_full; } *

variable_types: size int

user_defined_types: struct ht_tqueue_st { struct ht_st **q_list; int q_size; int q_head; int q_rear; int q_isfull; union pthread_mutex_t q_lock; union pthread_cond_t q_not_empty; union pthread_cond_t q_not_full; }

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 ht_st { struct ht_st *q_next; struct ht_st *q_prev; int q_prio; int prio; char name[40]; int dispatches; enum ht_state_en state; struct timeval spawned; struct timeval lastran; struct timeval running; struct ht_event_st *events; struct ht_mctx_st mctx; char *stack; unsigned int stacksize; long *stackguard; int stackloan; void *(*start_func)(void *); void *start_arg; int joinable; void *join_arg; void **data_value; int data_count; int cancelreq; unsigned int cancelstate; struct ht_cleanup_st *cleanups; struct ht_ring_st mutexring; }

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

user_defined_types: struct ht_mctx_st { struct ucontext_t uc; int restored; int error; }


decompiled_code:
__int64 __fastcall ht_tqueue_elements(unsigned int *a1)
{
unsigned int v1; // edx
__int64 result; // rax

v1 = a1[4];
result = abs32(a1[3] - v1);
if ( a1[3] == v1 )
{
result = 0LL;
if ( a1[5] )
result = a1[2];
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int *a1)
{
unsigned int v1; // edx
__int64 result; // rax

v1 = a1[4];
result = abs32(a1[3] - v1);
if ( a1[3] == v1 )
{
result = 0LL;
if ( a1[5] )
result = a1[2];
}
return result;
}

original_code:
unsigned int
ht_tqueue_elements(ht_tqueue_t * q)
{
   int n = q->q_head - q->q_rear;
   n = (n < 0) ? -n : n;
   if(n == 0)
   {
  return q->q_isfull ? q->q_size : 0;
   }
 return n;
}

canonical_original_code:
unsigned int ht_tqueue_elements(struct ht_tqueue_st *q)
{
   int n = q->q_head - q->q_rear;
   n = (n < 0) ? -n : n;
   if(n == 0)
   {
  return q->q_isfull ? q->q_size : 0;
   }
 return n;
}

variable_types: n int

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

user_defined_types: struct ht_event_st { struct ht_event_st *ev_next; struct ht_event_st *ev_prev; enum ht_status_t ev_status; int ev_type; int ev_goal; union { struct { int fd; } FD; struct { int *n; int nfd; struct fd_set *rfds; } SELECT; struct { int fini; } TASK; struct { struct timeval tv; } TIME; struct { struct ht_msgport_st *mp; } MSG; struct { struct ht_mutex_st *mutex; } MUTEX; struct { struct ht_cond_st *cond; } COND; struct { struct ht_st *tid; } TID; struct { int (*func)(void *); void *arg; struct timeval tv; } FUNC; } ev_args; }

user_defined_types: struct ucontext_t { unsigned long uc_flags; struct ucontext_t *uc_link; struct stack_t uc_stack; struct mcontext_t uc_mcontext; struct __sigset_t uc_sigmask; struct _libc_fpstate __fpregs_mem; unsigned long long __ssp[4]; }

user_defined_types: struct mcontext_t { long long gregs[23]; struct _libc_fpstate *fpregs; unsigned long long __reserved1[8]; }

user_defined_types: struct _libc_fpstate { unsigned short cwd; unsigned short swd; unsigned short ftw; unsigned short fop; unsigned long rip; unsigned long rdp; unsigned int mxcsr; unsigned int mxcr_mask; struct _libc_fpxreg _st[8]; struct _libc_xmmreg _xmm[16]; unsigned int __glibc_reserved1[24]; }

user_defined_types: struct ht_msgport_st { struct ht_ringnode_st mp_node; char *mp_name; struct ht_st *mp_tid; struct ht_ring_st mp_queue; }

user_defined_types: struct ht_mutex_st { struct ht_ringnode_st mx_node; int mx_state; struct ht_st *mx_owner; unsigned long mx_count; }

user_defined_types: struct ht_cond_st { unsigned long cn_state; unsigned int cn_waiters; }


decompiled_code:
__int64 __fastcall ht_tqueue_enqueue(__int64 a1, __int64 a2)
{
pthread_mutex_t *v2; // r12
int v3; // eax
int v4; // ecx
int v5; // eax
int v6; // et2

v2 = (pthread_mutex_t *)(a1 + 24);
pthread_mutex_lock((pthread_mutex_t *)(a1 + 24));
v3 = ht_tqueue_elements((unsigned int *)a1);
v4 = *(_DWORD *)(a1 + 8);
if ( v3 == v4 )
{
pthread_cond_wait((pthread_cond_t *)(a1 + 112), v2);
v4 = *(_DWORD *)(a1 + 8);
}
v5 = *(_DWORD *)(a1 + 12);
*(_QWORD *)(*(_QWORD *)a1 + 8LL * v5) = a2;
v6 = (v5 + 1) % v4;
*(_DWORD *)(a1 + 12) = v6;
if ( v6 == *(_DWORD *)(a1 + 16) )
*(_DWORD *)(a1 + 20) = 1;
pthread_cond_signal((pthread_cond_t *)(a1 + 64));
pthread_mutex_unlock(v2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
pthread_mutex_t *v2; // r12
int v3; // eax
int v4; // ecx
int v5; // eax
int v6; // et2

v2 = (pthread_mutex_t *)(a1 + 24);
pthread_mutex_lock((pthread_mutex_t *)(a1 + 24));
v3 = func1((unsigned int *)a1);
v4 = *(_DWORD *)(a1 + 8);
if ( v3 == v4 )
{
pthread_cond_wait((pthread_cond_t *)(a1 + 112), v2);
v4 = *(_DWORD *)(a1 + 8);
}
v5 = *(_DWORD *)(a1 + 12);
*(_QWORD *)(*(_QWORD *)a1 + 8LL * v5) = a2;
v6 = (v5 + 1) % v4;
*(_DWORD *)(a1 + 12) = v6;
if ( v6 == *(_DWORD *)(a1 + 16) )
*(_DWORD *)(a1 + 20) = 1;
pthread_cond_signal((pthread_cond_t *)(a1 + 64));
pthread_mutex_unlock(v2);
return 0LL;
}

original_code:
int
ht_tqueue_enqueue(ht_tqueue_t * q, ht_t t)
{
   pthread_mutex_lock(&q->q_lock);
   if(ht_tqueue_elements(q) == q->q_size)
      pthread_cond_wait(&q->q_not_full, &q->q_lock);
   q->q_list[q->q_head] = t;
   q->q_head = (q->q_head + 1) % q->q_size;
   if(0 == q->q_head - q->q_rear)
  q->q_isfull = 1;
   pthread_cond_signal(&q->q_not_empty);
   pthread_mutex_unlock(&q->q_lock);
   return 0;
}

canonical_original_code:
int ht_tqueue_enqueue(struct ht_tqueue_st *q, struct ht_st *t)
{
   pthread_mutex_lock(&q->q_lock);
   if(ht_tqueue_elements(q) == q->q_size)
      pthread_cond_wait(&q->q_not_full, &q->q_lock);
   q->q_list[q->q_head] = t;
   q->q_head = (q->q_head + 1) % q->q_size;
   if(0 == q->q_head - q->q_rear)
  q->q_isfull = 1;
   pthread_cond_signal(&q->q_not_empty);
   pthread_mutex_unlock(&q->q_lock);
   return 0;
}

variable_types:
t
struct ht_st *

user_defined_types: enum ht_state_en { HT_STATE_SCHEDULER=0, HT_STATE_NEW=1, HT_STATE_READY=2, HT_STATE_WAITING=3, HT_STATE_WAITING_FOR_SCHED_TO_WORKER=4, HT_STATE_DEAD=5 }

user_defined_types: struct timeval { long tv_sec; long tv_usec; }

user_defined_types: struct ht_cleanup_st { struct ht_cleanup_st *next; void (*func)(void *); void *arg; }

user_defined_types: enum ht_status_t { HT_STATUS_PENDING=0, HT_STATUS_OCCURRED=1, HT_STATUS_FAILED=2 }

user_defined_types: struct stack_t { void *ss_sp; int ss_flags; unsigned long ss_size; }

user_defined_types: struct __sigset_t { unsigned long __val[-1]; }

user_defined_types: struct ht_ringnode_st { struct ht_ringnode_st *rn_next; struct ht_ringnode_st *rn_prev; }

user_defined_types: struct ht_ring_st { struct ht_ringnode_st *r_hook; unsigned int r_nodes; }

user_defined_types: struct _libc_fpxreg { unsigned short significand[4]; unsigned short exponent; unsigned short __glibc_reserved1[3]; }


decompiled_code:
__int64 __fastcall ht_tqueue_dequeue(__int64 a1)
{
pthread_mutex_t *v1; // rbp
__int64 v2; // r12
int v3; // edx

v1 = (pthread_mutex_t *)(a1 + 24);
pthread_mutex_lock((pthread_mutex_t *)(a1 + 24));
if ( !(unsigned int)ht_tqueue_elements((unsigned int *)a1) )
pthread_cond_wait((pthread_cond_t *)(a1 + 64), v1);
v2 = *(_QWORD *)(*(_QWORD *)a1 + 8LL * *(int *)(a1 + 16));
v3 = (*(_DWORD *)(a1 + 16) + 1) % *(_DWORD *)(a1 + 8);
*(_DWORD *)(a1 + 16) = v3;
if ( v3 == *(_DWORD *)(a1 + 12) )
*(_DWORD *)(a1 + 20) = 0;
pthread_cond_signal((pthread_cond_t *)(a1 + 112));
pthread_mutex_unlock(v1);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
pthread_mutex_t *v1; // rbp
__int64 v2; // r12
int v3; // edx

v1 = (pthread_mutex_t *)(a1 + 24);
pthread_mutex_lock((pthread_mutex_t *)(a1 + 24));
if ( !(unsigned int)func1((unsigned int *)a1) )
pthread_cond_wait((pthread_cond_t *)(a1 + 64), v1);
v2 = *(_QWORD *)(*(_QWORD *)a1 + 8LL * *(int *)(a1 + 16));
v3 = (*(_DWORD *)(a1 + 16) + 1) % *(_DWORD *)(a1 + 8);
*(_DWORD *)(a1 + 16) = v3;
if ( v3 == *(_DWORD *)(a1 + 12) )
*(_DWORD *)(a1 + 20) = 0;
pthread_cond_signal((pthread_cond_t *)(a1 + 112));
pthread_mutex_unlock(v1);
return v2;
}

original_code:
ht_t
ht_tqueue_dequeue(ht_tqueue_t * q)
{
   pthread_mutex_lock(&q->q_lock);
   if(ht_tqueue_elements(q) == 0)
      pthread_cond_wait(&q->q_not_empty, &q->q_lock);
   ht_t r = q->q_list[q->q_rear];
   q->q_rear = (q->q_rear + 1) % q->q_size;
   if(0 == q->q_head - q->q_rear)
      q->q_isfull = 0;
   pthread_cond_signal(&q->q_not_full);
   pthread_mutex_unlock(&q->q_lock);
   return r;
}

canonical_original_code:
struct ht_st *ht_tqueue_dequeue(struct ht_tqueue_st *q)
{
   pthread_mutex_lock(&q->q_lock);
   if(ht_tqueue_elements(q) == 0)
      pthread_cond_wait(&q->q_not_empty, &q->q_lock);
   struct ht_st *r = q->q_list[q->q_rear];
   q->q_rear = (q->q_rear + 1) % q->q_size;
   if(0 == q->q_head - q->q_rear)
      q->q_isfull = 0;
   pthread_cond_signal(&q->q_not_full);
   pthread_mutex_unlock(&q->q_lock);
   return r;
}

variable_types: struct ht_tqueue_st { struct ht_st **q_list; int q_size; int q_head; int q_rear; int q_isfull; 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; } q_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; } q_not_empty; union pthread_cond_t q_not_full; } *

variable_types: struct ht_st { struct ht_st *q_next; struct ht_st *q_prev; int q_prio; int prio; char name[40]; int dispatches; enum ht_state_en { HT_STATE_SCHEDULER=0, HT_STATE_NEW=1, HT_STATE_READY=2, HT_STATE_WAITING=3, HT_STATE_WAITING_FOR_SCHED_TO_WORKER=4, HT_STATE_DEAD=5 } state; struct timeval { long tv_sec; long tv_usec; } spawned; struct timeval lastran; struct timeval running; struct ht_event_st { struct ht_event_st *ev_next; struct ht_event_st *ev_prev; enum ht_status_t { HT_STATUS_PENDING=0, HT_STATUS_OCCURRED=1, HT_STATUS_FAILED=2 } ev_status; int ev_type; int ev_goal; union { struct { int fd; } FD; struct { int *n; int nfd; struct fd_set { long __fds_bits[-1]; } *rfds; } SELECT; struct { int fini; } TASK; struct { struct timeval tv; } TIME; struct { struct ht_msgport_st { struct ht_ringnode_st { struct ht_ringnode_st *rn_next; struct ht_ringnode_st *rn_prev; } mp_node; char *mp_name; struct ht_st *mp_tid; struct ht_ring_st { struct ht_ringnode_st *r_hook; unsigned int r_nodes; } mp_queue; } *mp; } MSG; struct { struct ht_mutex_st { struct ht_ringnode_st mx_node; int mx_state; struct ht_st *mx_owner; unsigned long mx_count; } *mutex; } MUTEX; struct { struct ht_cond_st { unsigned long cn_state; unsigned int cn_waiters; } *cond; } COND; struct { struct ht_st *tid; } TID; struct { int (*func)(void *); void *arg; struct timeval tv; } FUNC; } ev_args; } *events; struct ht_mctx_st { struct ucontext_t { unsigned long uc_flags; struct ucontext_t *uc_link; struct stack_t { void *ss_sp; int ss_flags; unsigned long ss_size; } uc_stack; struct mcontext_t { long long gregs[23]; struct _libc_fpstate { unsigned short cwd; unsigned short swd; unsigned short ftw; unsigned short fop; unsigned long rip; unsigned long rdp; unsigned int mxcsr; unsigned int mxcr_mask; struct _libc_fpxreg { unsigned short significand[4]; unsigned short exponent; unsigned short __glibc_reserved1[3]; } _st[8]; struct _libc_xmmreg { unsigned int element[4]; } _xmm[16]; unsigned int __glibc_reserved1[24]; } *fpregs; unsigned long long __reserved1[8]; } uc_mcontext; struct __sigset_t { unsigned long __val[-1]; } uc_sigmask; struct _libc_fpstate __fpregs_mem; unsigned long long __ssp[4]; } uc; int restored; int error; } mctx; char *stack; unsigned int stacksize; long *stackguard; int stackloan; void *(*start_func)(void *); void *start_arg; int joinable; void *join_arg; void **data_value; int data_count; int cancelreq; unsigned int cancelstate; struct ht_cleanup_st { struct ht_cleanup_st *next; void (*func)(void *); void *arg; } *cleanups; struct ht_ring_st mutexring; } *

user_defined_types: struct ht_tqueue_st { struct ht_st **q_list; int q_size; int q_head; int q_rear; int q_isfull; union pthread_mutex_t q_lock; union pthread_cond_t q_not_empty; union pthread_cond_t q_not_full; }

user_defined_types: struct ht_st { struct ht_st *q_next; struct ht_st *q_prev; int q_prio; int prio; char name[40]; int dispatches; enum ht_state_en state; struct timeval spawned; struct timeval lastran; struct timeval running; struct ht_event_st *events; struct ht_mctx_st mctx; char *stack; unsigned int stacksize; long *stackguard; int stackloan; void *(*start_func)(void *); void *start_arg; int joinable; void *join_arg; void **data_value; int data_count; int cancelreq; unsigned int cancelstate; struct ht_cleanup_st *cleanups; struct ht_ring_st mutexring; }

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 ht_mctx_st { struct ucontext_t uc; int restored; int error; }

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:
void __fastcall ht_tqueue_destroy(__int64 a1)
{
pthread_cond_destroy((pthread_cond_t *)(a1 + 112));
pthread_cond_destroy((pthread_cond_t *)(a1 + 64));
pthread_mutex_destroy((pthread_mutex_t *)(a1 + 24));
free(*(void **)a1);
*(_QWORD *)a1 = 0LL;
}

canonical_decompiled_code:
void __fastcall func4(__int64 a1)
{
pthread_cond_destroy((pthread_cond_t *)(a1 + 112));
pthread_cond_destroy((pthread_cond_t *)(a1 + 64));
pthread_mutex_destroy((pthread_mutex_t *)(a1 + 24));
free(*(void **)a1);
*(_QWORD *)a1 = 0LL;
}

original_code:
void
ht_tqueue_destroy(ht_tqueue_t * q)
{
   pthread_cond_destroy(&q->q_not_full);
 pthread_cond_destroy(&q->q_not_empty);
 pthread_mutex_destroy(&q->q_lock);
 free(q->q_list);
 q->q_list = ((void *)0);
}

canonical_original_code:
void ht_tqueue_destroy(struct ht_tqueue_st *q)
{
   pthread_cond_destroy(&q->q_not_full);
 pthread_cond_destroy(&q->q_not_empty);
 pthread_mutex_destroy(&q->q_lock);
 free(q->q_list);
 q->q_list = ((void *)0);
}

return_type: void

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

user_defined_types: struct ht_event_st { struct ht_event_st *ev_next; struct ht_event_st *ev_prev; enum ht_status_t ev_status; int ev_type; int ev_goal; union { struct { int fd; } FD; struct { int *n; int nfd; struct fd_set *rfds; } SELECT; struct { int fini; } TASK; struct { struct timeval tv; } TIME; struct { struct ht_msgport_st *mp; } MSG; struct { struct ht_mutex_st *mutex; } MUTEX; struct { struct ht_cond_st *cond; } COND; struct { struct ht_st *tid; } TID; struct { int (*func)(void *); void *arg; struct timeval tv; } FUNC; } ev_args; }

user_defined_types: struct ucontext_t { unsigned long uc_flags; struct ucontext_t *uc_link; struct stack_t uc_stack; struct mcontext_t uc_mcontext; struct __sigset_t uc_sigmask; struct _libc_fpstate __fpregs_mem; unsigned long long __ssp[4]; }

user_defined_types: struct mcontext_t { long long gregs[23]; struct _libc_fpstate *fpregs; unsigned long long __reserved1[8]; }

user_defined_types: struct _libc_fpstate { unsigned short cwd; unsigned short swd; unsigned short ftw; unsigned short fop; unsigned long rip; unsigned long rdp; unsigned int mxcsr; unsigned int mxcr_mask; struct _libc_fpxreg _st[8]; struct _libc_xmmreg _xmm[16]; unsigned int __glibc_reserved1[24]; }

user_defined_types: struct ht_msgport_st { struct ht_ringnode_st mp_node; char *mp_name; struct ht_st *mp_tid; struct ht_ring_st mp_queue; }

user_defined_types: struct ht_mutex_st { struct ht_ringnode_st mx_node; int mx_state; struct ht_st *mx_owner; unsigned long mx_count; }

user_defined_types: struct _libc_xmmreg { unsigned int element[4]; }


decompiled_code:
_BOOL8 __fastcall ht_util_fd_valid(unsigned int a1)
{
_BOOL8 result; // rax
int v2; // er8

result = 0LL;
if ( a1 <= 0x3FF )
{
v2 = fcntl(a1, 3);
result = 1LL;
if ( v2 == -1 )
result = *_errno_location() != 9;
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(unsigned int a1)
{
_BOOL8 result; // rax
int v2; // er8

result = 0LL;
if ( a1 <= 0x3FF )
{
v2 = fcntl(a1, 3);
result = 1LL;
if ( v2 == -1 )
result = *_errno_location() != 9;
}
return result;
}

original_code:
int
ht_util_fd_valid(int fd)
{
    if (fd < 0 || fd >= 1024)
        return (0);
    if (fcntl(fd, 3) == -1 && (*__errno_location ()) == 9)
        return (0);
    return (!(0));
}

variable_types: fd int


canonical_original_code:
void ht_util_fds_merge(int nfd, struct fd_set *ifds1, struct fd_set *ofds1, struct fd_set *ifds2, struct fd_set *ofds2, struct fd_set *ifds3, struct fd_set *ofds3)
{
    register int s;
    for (s = 0; s < nfd; s++) {
        if (ifds1 != ((void *)0))
            if (((((ifds1)->__fds_bits)[((s) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) (1UL << ((s) % (8 * (int) sizeof (__fd_mask)))))) != 0))
                ((void) (((ofds1)->__fds_bits)[((s) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((s) % (8 * (int) sizeof (__fd_mask)))))));
        if (ifds2 != ((void *)0))
            if (((((ifds2)->__fds_bits)[((s) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) (1UL << ((s) % (8 * (int) sizeof (__fd_mask)))))) != 0))
                ((void) (((ofds2)->__fds_bits)[((s) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((s) % (8 * (int) sizeof (__fd_mask)))))));
        if (ifds3 != ((void *)0))
            if (((((ifds3)->__fds_bits)[((s) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) (1UL << ((s) % (8 * (int) sizeof (__fd_mask)))))) != 0))
                ((void) (((ofds3)->__fds_bits)[((s) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((s) % (8 * (int) sizeof (__fd_mask)))))));
    }
    return;
}

variable_types: nfd int

variable_types: struct fd_set { long __fds_bits[-1]; } *

variable_types: s int


canonical_original_code:
int ht_util_fds_test(int nfd, struct fd_set *ifds1, struct fd_set *ofds1, struct fd_set *ifds2, struct fd_set *ofds2, struct fd_set *ifds3, struct fd_set *ofds3)
{
    register int s;
    for (s = 0; s < nfd; s++) {
        if (ifds1 != ((void *)0))
            if (((((ifds1)->__fds_bits)[((s) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) (1UL << ((s) % (8 * (int) sizeof (__fd_mask)))))) != 0) && ((((ofds1)->__fds_bits)[((s) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) (1UL << ((s) % (8 * (int) sizeof (__fd_mask)))))) != 0))
                return (!(0));
        if (ifds2 != ((void *)0))
            if (((((ifds2)->__fds_bits)[((s) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) (1UL << ((s) % (8 * (int) sizeof (__fd_mask)))))) != 0) && ((((ofds2)->__fds_bits)[((s) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) (1UL << ((s) % (8 * (int) sizeof (__fd_mask)))))) != 0))
                return (!(0));
        if (ifds3 != ((void *)0))
            if (((((ifds3)->__fds_bits)[((s) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) (1UL << ((s) % (8 * (int) sizeof (__fd_mask)))))) != 0) && ((((ofds3)->__fds_bits)[((s) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) (1UL << ((s) % (8 * (int) sizeof (__fd_mask)))))) != 0))
                return (!(0));
    }
    return (0);
}


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

result = ht_current;
if ( *(_DWORD *)(ht_current + 1180LL) == 1 && (*(_BYTE *)(ht_current + 1184LL) & 1) != 0 )
{
*(_DWORD *)(ht_current + 1180LL) = 0;
result = ht_exit(-1LL);
}
return result;
}

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

result = ht_current;
if ( *(_DWORD *)(ht_current + 1180LL) == 1 && (*(_BYTE *)(ht_current + 1184LL) & 1) != 0 )
{
*(_DWORD *)(ht_current + 1180LL) = 0;
result = ht_exit(-1LL);
}
return result;
}

original_code:
void
ht_cancel_point(void)
{
    if ( ht_current->cancelreq == (!(0))
        && ht_current->cancelstate & (1<<(0))) {
        ht_current->cancelreq = (0);
        ;
        ht_exit(((void *)-1));
    }
    return;
}

canonical_original_code:
void ht_cancel_point()
{
    if ( ht_current->cancelreq == (!(0))
        && ht_current->cancelstate & (1<<(0))) {
        ht_current->cancelreq = (0);
        ;
        ht_exit(((void *)-1));
    }
    return;
}


decompiled_code:
__int64 __fastcall ht_cancel(__int64 a1)
{
int v1; // edx
int v2; // eax
unsigned int v3; // er13
__int64 result; // rax
void *v5; // rbp

if ( !a1 || ht_current == a1 )
{
*_errno_location() = 22;
result = 0LL;
}
else
{
v1 = *(_DWORD *)(a1 + 68);
if ( v1 != 5 )
{
v2 = *(_DWORD *)(a1 + 1184);
v3 = 1;
*(_DWORD *)(a1 + 1180) = 1;
if ( (v2 & 5) != 5 )
return v3;
switch ( v1 )
{
case 2:
v5 = &ht_RQ;
break;
case 3:
v5 = &ht_WQ;
break;
case 1:
v5 = &ht_NQ;
break;
default:
v3 = 0;
*_errno_location() = 3;
return v3;
}
v3 = ht_pqueue_contains(v5, a1);
if ( v3 )
{
ht_pqueue_delete(v5, a1);
ht_thread_cleanup(a1);
if ( *(_DWORD *)(a1 + 1152) )
{
*(_DWORD *)(a1 + 68) = 5;
*(_QWORD *)(a1 + 1160) = -1LL;
v3 = 1;
ht_pqueue_insert(&ht_DQ, 0LL, a1);
}
else
{
v3 = 1;
ht_tcb_free(a1);
}
}
else
{
*_errno_location() = 3;
}
return v3;
}
*_errno_location() = 1;
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
int v1; // edx
int v2; // eax
unsigned int v3; // er13
__int64 result; // rax
void *v5; // rbp

if ( !a1 || ht_current == a1 )
{
*_errno_location() = 22;
result = 0LL;
}
else
{
v1 = *(_DWORD *)(a1 + 68);
if ( v1 != 5 )
{
v2 = *(_DWORD *)(a1 + 1184);
v3 = 1;
*(_DWORD *)(a1 + 1180) = 1;
if ( (v2 & 5) != 5 )
return v3;
switch ( v1 )
{
case 2:
v5 = &ht_RQ;
break;
case 3:
v5 = &ht_WQ;
break;
case 1:
v5 = &ht_NQ;
break;
default:
v3 = 0;
*_errno_location() = 3;
return v3;
}
v3 = ht_pqueue_contains(v5, a1);
if ( v3 )
{
ht_pqueue_delete(v5, a1);
ht_thread_cleanup(a1);
if ( *(_DWORD *)(a1 + 1152) )
{
*(_DWORD *)(a1 + 68) = 5;
*(_QWORD *)(a1 + 1160) = -1LL;
v3 = 1;
ht_pqueue_insert(&ht_DQ, 0LL, a1);
}
else
{
v3 = 1;
ht_tcb_free(a1);
}
}
else
{
*_errno_location() = 3;
}
return v3;
}
*_errno_location() = 1;
result = 0LL;
}
return result;
}

original_code:
int
ht_cancel(ht_t thread)
{
    ht_pqueue_t *q;
    if (thread == ((void *)0))
        return ((*__errno_location ()) = (22), ((0)));
    if (thread == ht_current)
        return ((*__errno_location ()) = (22), ((0)));
    if (thread->state == HT_STATE_DEAD)
        return ((*__errno_location ()) = (1), ((0)));
    thread->cancelreq = (!(0));
    if ( thread->cancelstate & (1<<(0))
        && thread->cancelstate & (1<<(2))) {
        switch (thread->state) {
            case HT_STATE_NEW: q = &ht_NQ; break;
            case HT_STATE_READY: q = &ht_RQ; break;
            case HT_STATE_WAITING: q = &ht_WQ; break;
            default: q = ((void *)0);
        }
        if (q == ((void *)0))
            return ((*__errno_location ()) = (3), ((0)));
        if (!ht_pqueue_contains(q, thread))
            return ((*__errno_location ()) = (3), ((0)));
        ht_pqueue_delete(q, thread);
        ht_thread_cleanup(thread);
        if (!thread->joinable) {
            ;
            ht_tcb_free(thread);
        }
        else {
            ;
            thread->join_arg = ((void *)-1);
            thread->state = HT_STATE_DEAD;
            ht_pqueue_insert(&ht_DQ, 0, thread);
        }
    }
    return (!(0));
}

canonical_original_code:
int ht_cancel(struct ht_st *thread)
{
    struct ht_pqueue_st *q;
    if (thread == ((void *)0))
        return ((*__errno_location ()) = (22), ((0)));
    if (thread == ht_current)
        return ((*__errno_location ()) = (22), ((0)));
    if (thread->state == HT_STATE_DEAD)
        return ((*__errno_location ()) = (1), ((0)));
    thread->cancelreq = (!(0));
    if ( thread->cancelstate & (1<<(0))
        && thread->cancelstate & (1<<(2))) {
        switch (thread->state) {
            case HT_STATE_NEW: q = &ht_NQ; break;
            case HT_STATE_READY: q = &ht_RQ; break;
            case HT_STATE_WAITING: q = &ht_WQ; break;
            default: q = ((void *)0);
        }
        if (q == ((void *)0))
            return ((*__errno_location ()) = (3), ((0)));
        if (!ht_pqueue_contains(q, thread))
            return ((*__errno_location ()) = (3), ((0)));
        ht_pqueue_delete(q, thread);
        ht_thread_cleanup(thread);
        if (!thread->joinable) {
            ;
            ht_tcb_free(thread);
        }
        else {
            ;
            thread->join_arg = ((void *)-1);
            thread->state = HT_STATE_DEAD;
            ht_pqueue_insert(&ht_DQ, 0, thread);
        }
    }
    return (!(0));
}

variable_types: struct ht_pqueue_st { struct ht_st { struct ht_st *q_next; struct ht_st *q_prev; int q_prio; int prio; char name[40]; int dispatches; enum ht_state_en { HT_STATE_SCHEDULER=0, HT_STATE_NEW=1, HT_STATE_READY=2, HT_STATE_WAITING=3, HT_STATE_WAITING_FOR_SCHED_TO_WORKER=4, HT_STATE_DEAD=5 } state; struct timeval { long tv_sec; long tv_usec; } spawned; struct timeval lastran; struct timeval running; struct ht_event_st { struct ht_event_st *ev_next; struct ht_event_st *ev_prev; enum ht_status_t { HT_STATUS_PENDING=0, HT_STATUS_OCCURRED=1, HT_STATUS_FAILED=2 } ev_status; int ev_type; int ev_goal; union { struct { int fd; } FD; struct { int *n; int nfd; struct fd_set { long __fds_bits[-1]; } *rfds; } SELECT; struct { int fini; } TASK; struct { struct timeval tv; } TIME; struct { struct ht_msgport_st { struct ht_ringnode_st { struct ht_ringnode_st *rn_next; struct ht_ringnode_st *rn_prev; } mp_node; char *mp_name; struct ht_st *mp_tid; struct ht_ring_st { struct ht_ringnode_st *r_hook; unsigned int r_nodes; } mp_queue; } *mp; } MSG; struct { struct ht_mutex_st { struct ht_ringnode_st mx_node; int mx_state; struct ht_st *mx_owner; unsigned long mx_count; } *mutex; } MUTEX; struct { struct ht_cond_st { unsigned long cn_state; unsigned int cn_waiters; } *cond; } COND; struct { struct ht_st *tid; } TID; struct { int (*func)(void *); void *arg; struct timeval tv; } FUNC; } ev_args; } *events; struct ht_mctx_st { struct ucontext_t { unsigned long uc_flags; struct ucontext_t *uc_link; struct stack_t { void *ss_sp; int ss_flags; unsigned long ss_size; } uc_stack; struct mcontext_t { long long gregs[23]; struct _libc_fpstate { unsigned short cwd; unsigned short swd; unsigned short ftw; unsigned short fop; unsigned long rip; unsigned long rdp; unsigned int mxcsr; unsigned int mxcr_mask; struct _libc_fpxreg { unsigned short significand[4]; unsigned short exponent; unsigned short __glibc_reserved1[3]; } _st[8]; struct _libc_xmmreg { unsigned int element[4]; } _xmm[16]; unsigned int __glibc_reserved1[24]; } *fpregs; unsigned long long __reserved1[8]; } uc_mcontext; struct __sigset_t { unsigned long __val[-1]; } uc_sigmask; struct _libc_fpstate __fpregs_mem; unsigned long long __ssp[4]; } uc; int restored; int error; } mctx; char *stack; unsigned int stacksize; long *stackguard; int stackloan; void *(*start_func)(void *); void *start_arg; int joinable; void *join_arg; void **data_value; int data_count; int cancelreq; unsigned int cancelstate; struct ht_cleanup_st { struct ht_cleanup_st *next; void (*func)(void *); void *arg; } *cleanups; struct ht_ring_st mutexring; } *q_head; int q_num; } *

user_defined_types: struct ht_pqueue_st { struct ht_st *q_head; int q_num; }


decompiled_code:
_BOOL8 __fastcall ht_abort(_DWORD *a1)
{
_BOOL8 result; // rax

if ( !a1 || (_DWORD *)ht_current == a1 )
{
*_errno_location() = 22;
result = 0LL;
}
else if ( a1[17] == 5 && a1[288] )
{
result = (unsigned int)ht_join(a1, 0LL) != 0;
}
else
{
a1[288] = 0;
a1[296] = 5;
result = (unsigned int)ht_cancel((__int64)a1) != 0;
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(_DWORD *a1)
{
_BOOL8 result; // rax

if ( !a1 || (_DWORD *)ht_current == a1 )
{
*_errno_location() = 22;
result = 0LL;
}
else if ( a1[17] == 5 && a1[288] )
{
result = (unsigned int)ht_join(a1, 0LL) != 0;
}
else
{
a1[288] = 0;
a1[296] = 5;
result = (unsigned int)func2((__int64)a1) != 0;
}
return result;
}

original_code:
int
ht_abort(ht_t thread)
{
    if (thread == ((void *)0))
        return ((*__errno_location ()) = (22), ((0)));
    if (thread == ht_current)
        return ((*__errno_location ()) = (22), ((0)));
    if (thread->state == HT_STATE_DEAD && thread->joinable) {
        if (!ht_join(thread, ((void *)0)))
            return (0);
    }
    else {
        thread->joinable = (0);
        thread->cancelstate = ((1<<(0))|(1<<(2)));
        if (!ht_cancel(thread))
            return (0);
    }
    return (!(0));
}

canonical_original_code:
int ht_abort(struct ht_st *thread)
{
    if (thread == ((void *)0))
        return ((*__errno_location ()) = (22), ((0)));
    if (thread == ht_current)
        return ((*__errno_location ()) = (22), ((0)));
    if (thread->state == HT_STATE_DEAD && thread->joinable) {
        if (!ht_join(thread, ((void *)0)))
            return (0);
    }
    else {
        thread->joinable = (0);
        thread->cancelstate = ((1<<(0))|(1<<(2)));
        if (!ht_cancel(thread))
            return (0);
    }
    return (!(0));
}

user_defined_types: enum ht_state_en { HT_STATE_SCHEDULER=0, HT_STATE_NEW=1, HT_STATE_READY=2, HT_STATE_WAITING=3, HT_STATE_WAITING_FOR_SCHED_TO_WORKER=4, HT_STATE_DEAD=5 }

user_defined_types: struct timeval { long tv_sec; long tv_usec; }

user_defined_types: struct ht_cleanup_st { struct ht_cleanup_st *next; void (*func)(void *); void *arg; }

user_defined_types: enum ht_status_t { HT_STATUS_PENDING=0, HT_STATUS_OCCURRED=1, HT_STATUS_FAILED=2 }

user_defined_types: struct stack_t { void *ss_sp; int ss_flags; unsigned long ss_size; }

user_defined_types: struct __sigset_t { unsigned long __val[-1]; }

user_defined_types: struct ht_cond_st { unsigned long cn_state; unsigned int cn_waiters; }

user_defined_types: struct ht_ringnode_st { struct ht_ringnode_st *rn_next; struct ht_ringnode_st *rn_prev; }

user_defined_types: struct ht_ring_st { struct ht_ringnode_st *r_hook; unsigned int r_nodes; }

user_defined_types: struct _libc_fpxreg { unsigned short significand[4]; unsigned short exponent; unsigned short __glibc_reserved1[3]; }


decompiled_code:
__int64 __fastcall ht_msgport_pending(__int64 a1)
{
if ( a1 )
return *(unsigned int *)(a1 + 40);
*_errno_location() = 22;
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
if ( a1 )
return *(unsigned int *)(a1 + 40);
*_errno_location() = 22;
return 0xFFFFFFFFLL;
}

original_code:
int
ht_msgport_pending(ht_msgport_t mp)
{
    if (mp == ((void *)0))
        return ((*__errno_location ()) = (22), (-1));
    return ((&mp->mp_queue) == ((void *)0) ? (-1) : (&mp->mp_queue)->r_nodes);
}

canonical_original_code:
int ht_msgport_pending(struct ht_msgport_st *mp)
{
    if (mp == ((void *)0))
        return ((*__errno_location ()) = (22), (-1));
    return ((&mp->mp_queue) == ((void *)0) ? (-1) : (&mp->mp_queue)->r_nodes);
}

variable_types: struct ht_msgport_st { struct ht_ringnode_st { struct ht_ringnode_st *rn_next; struct ht_ringnode_st *rn_prev; } mp_node; char *mp_name; struct ht_st { struct ht_st *q_next; struct ht_st *q_prev; int q_prio; int prio; char name[40]; int dispatches; enum ht_state_en { HT_STATE_SCHEDULER=0, HT_STATE_NEW=1, HT_STATE_READY=2, HT_STATE_WAITING=3, HT_STATE_WAITING_FOR_SCHED_TO_WORKER=4, HT_STATE_DEAD=5 } state; struct timeval { long tv_sec; long tv_usec; } spawned; struct timeval lastran; struct timeval running; struct ht_event_st { struct ht_event_st *ev_next; struct ht_event_st *ev_prev; enum ht_status_t { HT_STATUS_PENDING=0, HT_STATUS_OCCURRED=1, HT_STATUS_FAILED=2 } ev_status; int ev_type; int ev_goal; union { struct { int fd; } FD; struct { int *n; int nfd; struct fd_set { long __fds_bits[-1]; } *rfds; } SELECT; struct { int fini; } TASK; struct { struct timeval tv; } TIME; struct { struct ht_msgport_st *mp; } MSG; struct { struct ht_mutex_st { struct ht_ringnode_st mx_node; int mx_state; struct ht_st *mx_owner; unsigned long mx_count; } *mutex; } MUTEX; struct { struct ht_cond_st { unsigned long cn_state; unsigned int cn_waiters; } *cond; } COND; struct { struct ht_st *tid; } TID; struct { int (*func)(void *); void *arg; struct timeval tv; } FUNC; } ev_args; } *events; struct ht_mctx_st { struct ucontext_t { unsigned long uc_flags; struct ucontext_t *uc_link; struct stack_t { void *ss_sp; int ss_flags; unsigned long ss_size; } uc_stack; struct mcontext_t { long long gregs[23]; struct _libc_fpstate { unsigned short cwd; unsigned short swd; unsigned short ftw; unsigned short fop; unsigned long rip; unsigned long rdp; unsigned int mxcsr; unsigned int mxcr_mask; struct _libc_fpxreg { unsigned short significand[4]; unsigned short exponent; unsigned short __glibc_reserved1[3]; } _st[8]; struct _libc_xmmreg { unsigned int element[4]; } _xmm[16]; unsigned int __glibc_reserved1[24]; } *fpregs; unsigned long long __reserved1[8]; } uc_mcontext; struct __sigset_t { unsigned long __val[-1]; } uc_sigmask; struct _libc_fpstate __fpregs_mem; unsigned long long __ssp[4]; } uc; int restored; int error; } mctx; char *stack; unsigned int stacksize; long *stackguard; int stackloan; void *(*start_func)(void *); void *start_arg; int joinable; void *join_arg; void **data_value; int data_count; int cancelreq; unsigned int cancelstate; struct ht_cleanup_st { struct ht_cleanup_st *next; void (*func)(void *); void *arg; } *cleanups; struct ht_ring_st { struct ht_ringnode_st *r_hook; unsigned int r_nodes; } mutexring; } *mp_tid; struct ht_ring_st mp_queue; } *

user_defined_types: struct ht_st { struct ht_st *q_next; struct ht_st *q_prev; int q_prio; int prio; char name[40]; int dispatches; enum ht_state_en state; struct timeval spawned; struct timeval lastran; struct timeval running; struct ht_event_st *events; struct ht_mctx_st mctx; char *stack; unsigned int stacksize; long *stackguard; int stackloan; void *(*start_func)(void *); void *start_arg; int joinable; void *join_arg; void **data_value; int data_count; int cancelreq; unsigned int cancelstate; struct ht_cleanup_st *cleanups; struct ht_ring_st mutexring; }

user_defined_types: struct ht_mctx_st { struct ucontext_t uc; int restored; int error; }

user_defined_types: struct ht_event_st { struct ht_event_st *ev_next; struct ht_event_st *ev_prev; enum ht_status_t ev_status; int ev_type; int ev_goal; union { struct { int fd; } FD; struct { int *n; int nfd; struct fd_set *rfds; } SELECT; struct { int fini; } TASK; struct { struct timeval tv; } TIME; struct { struct ht_msgport_st *mp; } MSG; struct { struct ht_mutex_st *mutex; } MUTEX; struct { struct ht_cond_st *cond; } COND; struct { struct ht_st *tid; } TID; struct { int (*func)(void *); void *arg; struct timeval tv; } FUNC; } ev_args; }

user_defined_types: struct ucontext_t { unsigned long uc_flags; struct ucontext_t *uc_link; struct stack_t uc_stack; struct mcontext_t uc_mcontext; struct __sigset_t uc_sigmask; struct _libc_fpstate __fpregs_mem; unsigned long long __ssp[4]; }


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

if ( a1 )
{
ht_ring_append(a1 + 32, a2);
result = 1LL;
}
else
{
*_errno_location() = 22;
result = 0LL;
}
return result;
}

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

if ( a1 )
{
ht_ring_append(a1 + 32, a2);
result = 1LL;
}
else
{
*_errno_location() = 22;
result = 0LL;
}
return result;
}

original_code:
int
ht_msgport_put(ht_msgport_t mp, ht_message_t *m)
{
    if (mp == ((void *)0))
        return ((*__errno_location ()) = (22), ((0)));
    ht_ring_append(&mp->mp_queue, (ht_ringnode_t *)m);
    return (!(0));
}

canonical_original_code:
int ht_msgport_put(struct ht_msgport_st *mp, struct ht_message_st *m)
{
    if (mp == ((void *)0))
        return ((*__errno_location ()) = (22), ((0)));
    ht_ring_append(&mp->mp_queue, (struct ht_ringnode_st *)m);
    return (!(0));
}

variable_types: struct ht_message_st { struct ht_ringnode_st m_node; struct ht_msgport_st *m_replyport; unsigned int m_size; void *m_data; } *

user_defined_types: struct ht_msgport_st { struct ht_ringnode_st mp_node; char *mp_name; struct ht_st *mp_tid; struct ht_ring_st mp_queue; }

user_defined_types: struct mcontext_t { long long gregs[23]; struct _libc_fpstate *fpregs; unsigned long long __reserved1[8]; }

user_defined_types: struct _libc_fpstate { unsigned short cwd; unsigned short swd; unsigned short ftw; unsigned short fop; unsigned long rip; unsigned long rdp; unsigned int mxcsr; unsigned int mxcr_mask; struct _libc_fpxreg _st[8]; struct _libc_xmmreg _xmm[16]; unsigned int __glibc_reserved1[24]; }

user_defined_types: struct ht_mutex_st { struct ht_ringnode_st mx_node; int mx_state; struct ht_st *mx_owner; unsigned long mx_count; }


decompiled_code:
__int64 __fastcall ht_msgport_get(__int64 a1)
{
if ( a1 )
return ht_ring_pop(a1 + 32);
*_errno_location() = 22;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
if ( a1 )
return ht_ring_pop(a1 + 32);
*_errno_location() = 22;
return 0LL;
}

original_code:
ht_message_t *
ht_msgport_get(ht_msgport_t mp)
{
    ht_message_t *m;
    if (mp == ((void *)0))
        return ((*__errno_location ()) = (22), ((ht_message_t *)((void *)0)));
    m = (ht_message_t *)ht_ring_pop(&mp->mp_queue);
    return m;
}

canonical_original_code:
struct ht_message_st *ht_msgport_get(struct ht_msgport_st *mp)
{
    struct ht_message_st *m;
    if (mp == ((void *)0))
        return ((*__errno_location ()) = (22), ((struct ht_message_st *)((void *)0)));
    m = (struct ht_message_st *)ht_ring_pop(&mp->mp_queue);
    return m;
}

variable_types:
mp
struct ht_msgport_st *

variable_types: struct ht_message_st { struct ht_ringnode_st { struct ht_ringnode_st *rn_next; struct ht_ringnode_st *rn_prev; } m_node; struct ht_msgport_st { struct ht_ringnode_st mp_node; char *mp_name; struct ht_st { struct ht_st *q_next; struct ht_st *q_prev; int q_prio; int prio; char name[40]; int dispatches; enum ht_state_en { HT_STATE_SCHEDULER=0, HT_STATE_NEW=1, HT_STATE_READY=2, HT_STATE_WAITING=3, HT_STATE_WAITING_FOR_SCHED_TO_WORKER=4, HT_STATE_DEAD=5 } state; struct timeval { long tv_sec; long tv_usec; } spawned; struct timeval lastran; struct timeval running; struct ht_event_st { struct ht_event_st *ev_next; struct ht_event_st *ev_prev; enum ht_status_t { HT_STATUS_PENDING=0, HT_STATUS_OCCURRED=1, HT_STATUS_FAILED=2 } ev_status; int ev_type; int ev_goal; union { struct { int fd; } FD; struct { int *n; int nfd; struct fd_set { long __fds_bits[-1]; } *rfds; } SELECT; struct { int fini; } TASK; struct { struct timeval tv; } TIME; struct { struct ht_msgport_st *mp; } MSG; struct { struct ht_mutex_st { struct ht_ringnode_st mx_node; int mx_state; struct ht_st *mx_owner; unsigned long mx_count; } *mutex; } MUTEX; struct { struct ht_cond_st { unsigned long cn_state; unsigned int cn_waiters; } *cond; } COND; struct { struct ht_st *tid; } TID; struct { int (*func)(void *); void *arg; struct timeval tv; } FUNC; } ev_args; } *events; struct ht_mctx_st { struct ucontext_t { unsigned long uc_flags; struct ucontext_t *uc_link; struct stack_t { void *ss_sp; int ss_flags; unsigned long ss_size; } uc_stack; struct mcontext_t { long long gregs[23]; struct _libc_fpstate { unsigned short cwd; unsigned short swd; unsigned short ftw; unsigned short fop; unsigned long rip; unsigned long rdp; unsigned int mxcsr; unsigned int mxcr_mask; struct _libc_fpxreg { unsigned short significand[4]; unsigned short exponent; unsigned short __glibc_reserved1[3]; } _st[8]; struct _libc_xmmreg { unsigned int element[4]; } _xmm[16]; unsigned int __glibc_reserved1[24]; } *fpregs; unsigned long long __reserved1[8]; } uc_mcontext; struct __sigset_t { unsigned long __val[-1]; } uc_sigmask; struct _libc_fpstate __fpregs_mem; unsigned long long __ssp[4]; } uc; int restored; int error; } mctx; char *stack; unsigned int stacksize; long *stackguard; int stackloan; void *(*start_func)(void *); void *start_arg; int joinable; void *join_arg; void **data_value; int data_count; int cancelreq; unsigned int cancelstate; struct ht_cleanup_st { struct ht_cleanup_st *next; void (*func)(void *); void *arg; } *cleanups; struct ht_ring_st { struct ht_ringnode_st *r_hook; unsigned int r_nodes; } mutexring; } *mp_tid; struct ht_ring_st mp_queue; } *m_replyport; unsigned int m_size; void *m_data; } *

user_defined_types: struct ht_message_st { struct ht_ringnode_st m_node; struct ht_msgport_st *m_replyport; unsigned int m_size; void *m_data; }


decompiled_code:
__int64 __fastcall ht_msgport_reply(__int64 a1)
{
if ( a1 )
return ht_msgport_put(*(_QWORD *)(a1 + 16), a1);
*_errno_location() = 22;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
if ( a1 )
return func1(*(_QWORD *)(a1 + 16), a1);
*_errno_location() = 22;
return 0LL;
}

original_code:
int
ht_msgport_reply(ht_message_t *m)
{
    if (m == ((void *)0))
        return ((*__errno_location ()) = (22), ((0)));
    return ht_msgport_put(m->m_replyport, m);
}

canonical_original_code:
int ht_msgport_reply(struct ht_message_st *m)
{
    if (m == ((void *)0))
        return ((*__errno_location ()) = (22), ((0)));
    return ht_msgport_put(m->m_replyport, m);
}

user_defined_types: enum ht_state_en { HT_STATE_SCHEDULER=0, HT_STATE_NEW=1, HT_STATE_READY=2, HT_STATE_WAITING=3, HT_STATE_WAITING_FOR_SCHED_TO_WORKER=4, HT_STATE_DEAD=5 }

user_defined_types: struct timeval { long tv_sec; long tv_usec; }

user_defined_types: struct ht_cleanup_st { struct ht_cleanup_st *next; void (*func)(void *); void *arg; }

user_defined_types: struct _libc_xmmreg { unsigned int element[4]; }


decompiled_code:
void __fastcall ht_msgport_destroy(void *ptr)
{
__int64 v2; // rdi

if ( ptr )
{
while ( 1 )
{
v2 = ht_msgport_get((__int64)ptr);
if ( !v2 )
break;
ht_msgport_reply(v2);
}
ht_ring_delete(&ht_msgport, ptr);
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func4(void *ptr)
{
__int64 v2; // rdi

if ( ptr )
{
while ( 1 )
{
v2 = func2((__int64)ptr);
if ( !v2 )
break;
func3(v2);
}
ht_ring_delete(&ht_msgport, ptr);
free(ptr);
}
}

original_code:
void
ht_msgport_destroy(ht_msgport_t mp)
{
    ht_message_t *m;
    if (mp == ((void *)0))
        return;
    while ((m = ht_msgport_get(mp)) != ((void *)0))
        ht_msgport_reply(m);
    ht_ring_delete(&ht_msgport, &mp->mp_node);
    free(mp);
    return;
}

canonical_original_code:
void ht_msgport_destroy(struct ht_msgport_st *mp)
{
    struct ht_message_st *m;
    if (mp == ((void *)0))
        return;
    while ((m = ht_msgport_get(mp)) != ((void *)0))
        ht_msgport_reply(m);
    ht_ring_delete(&ht_msgport, &mp->mp_node);
    free(mp);
    return;
}

user_defined_types: enum ht_status_t { HT_STATUS_PENDING=0, HT_STATUS_OCCURRED=1, HT_STATUS_FAILED=2 }

user_defined_types: struct stack_t { void *ss_sp; int ss_flags; unsigned long ss_size; }

user_defined_types: struct __sigset_t { unsigned long __val[-1]; }

user_defined_types: struct ht_cond_st { unsigned long cn_state; unsigned int cn_waiters; }


decompiled_code:
__int64 __fastcall ht_cleanup_push(__int64 a1, __int64 a2)
{
_QWORD *v2; // rax
__int64 v3; // rdx
__int64 result; // rax

if ( a1 )
{
v2 = malloc(0x18uLL);
if ( v2 )
{
v2[1] = a1;
v2[2] = a2;
v3 = ht_current;
*v2 = *(_QWORD *)(ht_current + 1192LL);
*(_QWORD *)(v3 + 1192) = v2;
result = 1LL;
}
else
{
*_errno_location() = 12;
result = 0LL;
}
}
else
{
*_errno_location() = 22;
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
_QWORD *v2; // rax
__int64 v3; // rdx
__int64 result; // rax

if ( a1 )
{
v2 = malloc(0x18uLL);
if ( v2 )
{
v2[1] = a1;
v2[2] = a2;
v3 = ht_current;
*v2 = *(_QWORD *)(ht_current + 1192LL);
*(_QWORD *)(v3 + 1192) = v2;
result = 1LL;
}
else
{
*_errno_location() = 12;
result = 0LL;
}
}
else
{
*_errno_location() = 22;
result = 0LL;
}
return result;
}

original_code:
int
ht_cleanup_push(void (*func)(void *), void *arg)
{
    ht_cleanup_t *cleanup;
    if (func == ((void *)0))
        return ((*__errno_location ()) = (22), ((0)));
    if ((cleanup = (ht_cleanup_t *)malloc(sizeof(ht_cleanup_t))) == ((void *)0))
        return ((*__errno_location ()) = (12), ((0)));
    cleanup->func = func;
    cleanup->arg = arg;
    cleanup->next = ht_current->cleanups;
    ht_current->cleanups = cleanup;
    return (!(0));
}

canonical_original_code:
int ht_cleanup_push(void (*func)(void *), void *arg)
{
    struct ht_cleanup_st *cleanup;
    if (func == ((void *)0))
        return ((*__errno_location ()) = (22), ((0)));
    if ((cleanup = (struct ht_cleanup_st *)malloc(sizeof(ht_cleanup_t))) == ((void *)0))
        return ((*__errno_location ()) = (12), ((0)));
    cleanup->func = func;
    cleanup->arg = arg;
    cleanup->next = ht_current->cleanups;
    ht_current->cleanups = cleanup;
    return (!(0));
}

variable_types:
func
void (*)(void *)

variable_types:
arg
void *

variable_types: struct ht_cleanup_st { struct ht_cleanup_st *next; void (*func)(void *); void *arg; } *


decompiled_code:
__int64 __fastcall ht_cleanup_pop(int a1)
{
__int64 result; // rax
void (__fastcall **v2)(_QWORD); // rbp

result = 0LL;
v2 = *(void (__fastcall ***)(_QWORD))(ht_current + 1192LL);
if ( v2 )
{
*(_QWORD *)(ht_current + 1192LL) = *v2;
if ( a1 )
v2[1](v2[2]);
free(v2);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
__int64 result; // rax
void (__fastcall **v2)(_QWORD); // rbp

result = 0LL;
v2 = *(void (__fastcall ***)(_QWORD))(ht_current + 1192LL);
if ( v2 )
{
*(_QWORD *)(ht_current + 1192LL) = *v2;
if ( a1 )
v2[1](v2[2]);
free(v2);
result = 1LL;
}
return result;
}

original_code:
int
ht_cleanup_pop(int execute)
{
    ht_cleanup_t *cleanup;
    int rc;
    rc = (0);
    if ((cleanup = ht_current->cleanups) != ((void *)0)) {
        ht_current->cleanups = cleanup->next;
        if (execute)
            cleanup->func(cleanup->arg);
        free(cleanup);
        rc = (!(0));
    }
    return rc;
}

canonical_original_code:
int ht_cleanup_pop(int execute)
{
    struct ht_cleanup_st *cleanup;
    int rc;
    rc = (0);
    if ((cleanup = ht_current->cleanups) != ((void *)0)) {
        ht_current->cleanups = cleanup->next;
        if (execute)
            cleanup->func(cleanup->arg);
        free(cleanup);
        rc = (!(0));
    }
    return rc;
}

variable_types: execute int

variable_types: rc int


decompiled_code:
// attributes: thunk
int ht_time_usleep(__useconds_t useconds)
{
return usleep(useconds);
}

canonical_decompiled_code:
int func0(__useconds_t useconds)
{
return usleep(useconds);
}

original_code:
void
ht_time_usleep(unsigned long usec)
{
    usleep((unsigned int )usec);
    return;
}

variable_types:
usec
unsigned long


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

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

original_code:
ht_time_t
ht_time(long sec, long usec)
{
    ht_time_t tv;
    tv.tv_sec = sec;
    tv.tv_usec = usec;
    return tv;
}

canonical_original_code:
struct timeval ht_time(long sec, long usec)
{
    struct timeval tv;
    tv.tv_sec = sec;
    tv.tv_usec = usec;
    return tv;
}

variable_types: sec long

variable_types: usec long

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


decompiled_code:
__time_t __fastcall ht_timeout(__int64 a1, __int64 a2)
{
__suseconds_t v2; // rbx
__time_t v3; // rdi
struct timeval v5; // [rsp+0h] [rbp-28h] BYREF

gettimeofday(&v5, 0LL);
v2 = v5.tv_usec + a2;
v5.tv_usec = v2;
v3 = a1 + v5.tv_sec;
v5.tv_sec = v3;
if ( v2 > 1000000 )
{
v5.tv_sec = v3 + 1;
v5.tv_usec = v2 - 1000000;
}
return v5.tv_sec;
}

canonical_decompiled_code:
__time_t __fastcall func2(__int64 a1, __int64 a2)
{
__suseconds_t v2; // rbx
__time_t v3; // rdi
struct timeval v5; // [rsp+0h] [rbp-28h] BYREF

gettimeofday(&v5, 0LL);
v2 = v5.tv_usec + a2;
v5.tv_usec = v2;
v3 = a1 + v5.tv_sec;
v5.tv_sec = v3;
if ( v2 > 1000000 )
{
v5.tv_sec = v3 + 1;
v5.tv_usec = v2 - 1000000;
}
return v5.tv_sec;
}

original_code:
ht_time_t
ht_timeout(long sec, long usec)
{
    ht_time_t tv;
    ht_time_t tvd;
    do { if (((ht_time_t *)(0)) == (ht_time_t *)(0)) gettimeofday((&tv), ((void *)0)); else { (&tv)->tv_sec = ((ht_time_t *)(0))->tv_sec; (&tv)->tv_usec = ((ht_time_t *)(0))->tv_usec; } } while (0);
    tvd.tv_sec = sec;
    tvd.tv_usec = usec;
    (&tv)->tv_sec += (&tvd)->tv_sec; (&tv)->tv_usec += (&tvd)->tv_usec; if ((&tv)->tv_usec > 1000000) { (&tv)->tv_sec += 1; (&tv)->tv_usec -= 1000000; };
    return tv;
}

canonical_original_code:
struct timeval ht_timeout(long sec, long usec)
{
    struct timeval tv;
    struct timeval tvd;
    do { if (((struct timeval *)(0)) == (struct timeval *)(0)) gettimeofday((&tv), ((void *)0)); else { (&tv)->tv_sec = ((struct timeval *)(0))->tv_sec; (&tv)->tv_usec = ((struct timeval *)(0))->tv_usec; } } while (0);
    tvd.tv_sec = sec;
    tvd.tv_usec = usec;
    (&tv)->tv_sec += (&tvd)->tv_sec; (&tv)->tv_usec += (&tvd)->tv_usec; if ((&tv)->tv_usec > 1000000) { (&tv)->tv_sec += 1; (&tv)->tv_usec -= 1000000; };
    return tv;
}

return_type: struct timeval { long tv_sec; long tv_usec; }


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

result = (unsigned int)*a1 - *a2;
if ( (unsigned int)*a1 == *a2 )
result = (unsigned int)a1[1] - a2[2];
return result;
}

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

result = (unsigned int)*a1 - *a2;
if ( (unsigned int)*a1 == *a2 )
result = (unsigned int)a1[1] - a2[2];
return result;
}

original_code:
int
ht_time_cmp(ht_time_t *t1, ht_time_t *t2)
{
    int rc;
    rc = t1->tv_sec - t2->tv_sec;
    if (rc == 0)
         rc = t1->tv_usec - t2->tv_usec;
    return rc;
}

canonical_original_code:
int ht_time_cmp(struct timeval *t1, struct timeval *t2)
{
    int rc;
    rc = t1->tv_sec - t2->tv_sec;
    if (rc == 0)
         rc = t1->tv_usec - t2->tv_usec;
    return rc;
}

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


original_code:
void
ht_time_mul(ht_time_t *t1, int n)
{
    t1->tv_sec *= n;
    t1->tv_usec *= n;
    t1->tv_sec += (t1->tv_usec / 1000000);
    t1->tv_usec = (t1->tv_usec % 1000000);
    return;
}

canonical_original_code:
void ht_time_mul(struct timeval *t1, int n)
{
    t1->tv_sec *= n;
    t1->tv_usec *= n;
    t1->tv_sec += (t1->tv_usec / 1000000);
    t1->tv_usec = (t1->tv_usec % 1000000);
    return;
}

variable_types: n int


decompiled_code:
double __fastcall ht_time_t2d(_QWORD *a1)
{
return ((double)(int)*a1 * 1000000.0 + (double)(int)a1[1]) / 1000000.0;
}

canonical_decompiled_code:
double __fastcall func6(_QWORD *a1)
{
return ((double)(int)*a1 * 1000000.0 + (double)(int)a1[1]) / 1000000.0;
}

original_code:
double
ht_time_t2d(ht_time_t *t)
{
    double d;
    d = ((double)t->tv_sec*1000000 + (double)t->tv_usec) / 1000000;
    return d;
}

canonical_original_code:
double ht_time_t2d(struct timeval *t)
{
    double d;
    d = ((double)t->tv_sec*1000000 + (double)t->tv_usec) / 1000000;
    return d;
}

variable_types: d double

return_type: double


original_code:
int
ht_time_t2i(ht_time_t *t)
{
    int i;
    i = (t->tv_sec*1000000 + t->tv_usec) / 1000000;
    return i;
}

canonical_original_code:
int ht_time_t2i(struct timeval *t)
{
    int i;
    i = (t->tv_sec*1000000 + t->tv_usec) / 1000000;
    return i;
}

variable_types: i int


decompiled_code:
_BOOL8 __fastcall ht_time_pos(__int64 *a1)
{
_BOOL8 result; // rax

result = 0LL;
if ( *a1 > 0 )
result = a1[1] > 0;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func8(__int64 *a1)
{
_BOOL8 result; // rax

result = 0LL;
if ( *a1 > 0 )
result = a1[1] > 0;
return result;
}

original_code:
int
ht_time_pos(ht_time_t *t)
{
    if (t->tv_sec > 0 && t->tv_usec > 0)
        return 1;
    else
        return 0;
}

canonical_original_code:
int ht_time_pos(struct timeval *t)
{
    if (t->tv_sec > 0 && t->tv_usec > 0)
        return 1;
    else
        return 0;
}


decompiled_code:
__int64 __fastcall ht_worker_init(int a1)
{
void *v1; // rax
int v2; // eax
bool v3; // cc
int arg; // [rsp+0h] [rbp-24h] BYREF
pthread_t newthread[4]; // [rsp+4h] [rbp-20h] BYREF

if ( a1 <= 0 )
return 0LL;
pthread_mutex_init(&ht_worker_start_mutex, 0LL);
pthread_cond_init(&ht_worker_cond_started, 0LL);
ht_tqueue_init(&ht_TQ, (unsigned int)(3 * a1));
v1 = malloc(8LL * a1);
ht_worker_num = a1;
ht_worker_tids = v1;
ht_worker_stop_flag = 0;
pthread_key_create(&ht_worker_ctx_key, 0LL);
arg = 0;
do
{
pthread_mutex_lock(&ht_worker_start_mutex);
pthread_create(newthread, 0LL, ht_worker, &arg);
pthread_cond_wait(&ht_worker_cond_started, &ht_worker_start_mutex);
pthread_mutex_unlock(&ht_worker_start_mutex);
v2 = arg + 1;
v3 = arg + 1 < ht_worker_num;
*((_QWORD *)ht_worker_tids + arg) = newthread[0];
arg = v2;
}
while ( v3 );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
void *v1; // rax
int v2; // eax
bool v3; // cc
int arg; // [rsp+0h] [rbp-24h] BYREF
pthread_t newthread[4]; // [rsp+4h] [rbp-20h] BYREF

if ( a1 <= 0 )
return 0LL;
pthread_mutex_init(&ht_worker_start_mutex, 0LL);
pthread_cond_init(&ht_worker_cond_started, 0LL);
ht_tqueue_init(&ht_TQ, (unsigned int)(3 * a1));
v1 = malloc(8LL * a1);
ht_worker_num = a1;
ht_worker_tids = v1;
ht_worker_stop_flag = 0;
pthread_key_create(&ht_worker_ctx_key, 0LL);
arg = 0;
do
{
pthread_mutex_lock(&ht_worker_start_mutex);
pthread_create(newthread, 0LL, ht_worker, &arg);
pthread_cond_wait(&ht_worker_cond_started, &ht_worker_start_mutex);
pthread_mutex_unlock(&ht_worker_start_mutex);
v2 = arg + 1;
v3 = arg + 1 < ht_worker_num;
*((_QWORD *)ht_worker_tids + arg) = newthread[0];
arg = v2;
}
while ( v3 );
return 0LL;
}

original_code:
int
ht_worker_init(int num_worker)
{
   if (num_worker <= 0)
      return 0;
   pthread_mutex_init(&_ht_worker_start_mutex, ((void *)0));
   pthread_cond_init(&_ht_worker_cond_started, ((void *)0));
   ht_tqueue_init(&ht_TQ, num_worker * 3);
   _ht_worker_tids = (pthread_t *) malloc(sizeof(pthread_t) * num_worker);
   _ht_worker_num = num_worker;
   _ht_worker_stop_flag = 0;
   pthread_key_create(&_ht_worker_ctx_key, ((void *)0));
   pthread_t t;
   int i = 0;
   for(i = 0; i < _ht_worker_num; i++)
   {
      ;
      pthread_mutex_lock(&_ht_worker_start_mutex);
      pthread_create(&t, ((void *)0), _ht_worker, (void*) &i);
      pthread_cond_wait(&_ht_worker_cond_started, &_ht_worker_start_mutex);
      pthread_mutex_unlock(&_ht_worker_start_mutex);
      _ht_worker_tids[i] = t;
   }
   return 0;
}

canonical_original_code:
int ht_worker_init(int num_worker)
{
   if (num_worker <= 0)
      return 0;
   pthread_mutex_init(&_ht_worker_start_mutex, ((void *)0));
   pthread_cond_init(&_ht_worker_cond_started, ((void *)0));
   ht_tqueue_init(&ht_TQ, num_worker * 3);
   _ht_worker_tids = (unsigned long *) malloc(sizeof(pthread_t) * num_worker);
   _ht_worker_num = num_worker;
   _ht_worker_stop_flag = 0;
   pthread_key_create(&_ht_worker_ctx_key, ((void *)0));
   unsigned long t;
   int i = 0;
   for(i = 0; i < _ht_worker_num; i++)
   {
      ;
      pthread_mutex_lock(&_ht_worker_start_mutex);
      pthread_create(&t, ((void *)0), _ht_worker, (void *) &i);
      pthread_cond_wait(&_ht_worker_cond_started, &_ht_worker_start_mutex);
      pthread_mutex_unlock(&_ht_worker_start_mutex);
      _ht_worker_tids[i] = t;
   }
   return 0;
}

variable_types:
t
unsigned long


decompiled_code:
__int64 ht_worker_kill()
{
int v0; // ebx
__int64 v1; // rbx
pthread_t v2; // rdi

ht_worker_stop_flag = 1;
if ( ht_worker_num > 0 )
{
v0 = 0;
do
{
++v0;
ht_tqueue_enqueue(&ht_TQ, 0LL);
}
while ( ht_worker_num > v0 );
if ( ht_worker_num > 0 )
{
v1 = 0LL;
do
{
v2 = *((_QWORD *)ht_worker_tids + v1++);
pthread_join(v2, 0LL);
}
while ( ht_worker_num > (int)v1 );
}
}
ht_worker_num = 0;
free(ht_worker_tids);
pthread_mutex_destroy(&ht_worker_start_mutex);
pthread_cond_destroy(&ht_worker_cond_started);
return 0LL;
}

canonical_decompiled_code:
__int64 func2()
{
int v0; // ebx
__int64 v1; // rbx
pthread_t v2; // rdi

ht_worker_stop_flag = 1;
if ( ht_worker_num > 0 )
{
v0 = 0;
do
{
++v0;
ht_tqueue_enqueue(&ht_TQ, 0LL);
}
while ( ht_worker_num > v0 );
if ( ht_worker_num > 0 )
{
v1 = 0LL;
do
{
v2 = *((_QWORD *)ht_worker_tids + v1++);
pthread_join(v2, 0LL);
}
while ( ht_worker_num > (int)v1 );
}
}
ht_worker_num = 0;
free(ht_worker_tids);
pthread_mutex_destroy(&ht_worker_start_mutex);
pthread_cond_destroy(&ht_worker_cond_started);
return 0LL;
}

original_code:
int
ht_worker_kill()
{
   _ht_worker_stop_flag = 1;
   int i = 0;
   for(i = 0; i < _ht_worker_num; i++)
   {
      ht_tqueue_enqueue(&ht_TQ, ((void *)0));
   }
   for(i = 0; i < _ht_worker_num; i++)
   {
      pthread_join(_ht_worker_tids[i], ((void *)0));
      ;
   }
   _ht_worker_num = 0;
   free(_ht_worker_tids);
   pthread_mutex_destroy(&_ht_worker_start_mutex);
   pthread_cond_destroy(&_ht_worker_cond_started);
   return 0;
}


decompiled_code:
__int64 ht_hand_out()
{
__int64 v0; // rax
ucontext_t *v1; // rdi

v0 = ht_event(8LL);
v1 = (ucontext_t *)ht_current;
*(_QWORD *)(ht_current + 120LL) = v0;
v1 = (ucontext_t *)((char *)v1 + 128);
v1[-1].__fpregs_mem.padding[9] = 4;
swapcontext(v1, (const ucontext_t *)(ht_sched + 128LL));
return 0LL;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v0; // rax
ucontext_t *v1; // rdi

v0 = ht_event(8LL);
v1 = (ucontext_t *)ht_current;
*(_QWORD *)(ht_current + 120LL) = v0;
v1 = (ucontext_t *)((char *)v1 + 128);
v1[-1].__fpregs_mem.padding[9] = 4;
swapcontext(v1, (const ucontext_t *)(ht_sched + 128LL));
return 0LL;
}

original_code:
int
ht_hand_out()
{
   ht_event_t ev = ht_event((1<<(3)));
   ht_current->events = ev;
 ht_current->state = HT_STATE_WAITING_FOR_SCHED_TO_WORKER;
 swapcontext(&((&ht_current->mctx)->uc), &((&ht_sched->mctx)->uc));;
   return 0;
}

canonical_original_code:
int ht_hand_out()
{
   struct ht_event_st *ev = ht_event((1<<(3)));
   ht_current->events = ev;
 ht_current->state = HT_STATE_WAITING_FOR_SCHED_TO_WORKER;
 swapcontext(&((&ht_current->mctx)->uc), &((&ht_sched->mctx)->uc));;
   return 0;
}

variable_types: struct ht_event_st { struct ht_event_st *ev_next; struct ht_event_st *ev_prev; enum ht_status_t { HT_STATUS_PENDING=0, HT_STATUS_OCCURRED=1, HT_STATUS_FAILED=2 } ev_status; int ev_type; int ev_goal; union { struct { int fd; } FD; struct { int *n; int nfd; struct fd_set { long __fds_bits[-1]; } *rfds; } SELECT; struct { int fini; } TASK; struct { struct timeval { long tv_sec; long tv_usec; } tv; } TIME; struct { struct ht_msgport_st { struct ht_ringnode_st { struct ht_ringnode_st *rn_next; struct ht_ringnode_st *rn_prev; } mp_node; char *mp_name; struct ht_st { struct ht_st *q_next; struct ht_st *q_prev; int q_prio; int prio; char name[40]; int dispatches; enum ht_state_en { HT_STATE_SCHEDULER=0, HT_STATE_NEW=1, HT_STATE_READY=2, HT_STATE_WAITING=3, HT_STATE_WAITING_FOR_SCHED_TO_WORKER=4, HT_STATE_DEAD=5 } state; struct timeval spawned; struct timeval lastran; struct timeval running; struct ht_event_st *events; struct ht_mctx_st { struct ucontext_t { unsigned long uc_flags; struct ucontext_t *uc_link; struct stack_t { void *ss_sp; int ss_flags; unsigned long ss_size; } uc_stack; struct mcontext_t { long long gregs[23]; struct _libc_fpstate { unsigned short cwd; unsigned short swd; unsigned short ftw; unsigned short fop; unsigned long rip; unsigned long rdp; unsigned int mxcsr; unsigned int mxcr_mask; struct _libc_fpxreg { unsigned short significand[4]; unsigned short exponent; unsigned short __glibc_reserved1[3]; } _st[8]; struct _libc_xmmreg { unsigned int element[4]; } _xmm[16]; unsigned int __glibc_reserved1[24]; } *fpregs; unsigned long long __reserved1[8]; } uc_mcontext; struct __sigset_t { unsigned long __val[-1]; } uc_sigmask; struct _libc_fpstate __fpregs_mem; unsigned long long __ssp[4]; } uc; int restored; int error; } mctx; char *stack; unsigned int stacksize; long *stackguard; int stackloan; void *(*start_func)(void *); void *start_arg; int joinable; void *join_arg; void **data_value; int data_count; int cancelreq; unsigned int cancelstate; struct ht_cleanup_st { struct ht_cleanup_st *next; void (*func)(void *); void *arg; } *cleanups; struct ht_ring_st { struct ht_ringnode_st *r_hook; unsigned int r_nodes; } mutexring; } *mp_tid; struct ht_ring_st mp_queue; } *mp; } MSG; struct { struct ht_mutex_st { struct ht_ringnode_st mx_node; int mx_state; struct ht_st *mx_owner; unsigned long mx_count; } *mutex; } MUTEX; struct { struct ht_cond_st { unsigned long cn_state; unsigned int cn_waiters; } *cond; } COND; struct { struct ht_st *tid; } TID; struct { int (*func)(void *); void *arg; struct timeval tv; } FUNC; } ev_args; } *

user_defined_types: struct ht_st { struct ht_st *q_next; struct ht_st *q_prev; int q_prio; int prio; char name[40]; int dispatches; enum ht_state_en state; struct timeval spawned; struct timeval lastran; struct timeval running; struct ht_event_st *events; struct ht_mctx_st mctx; char *stack; unsigned int stacksize; long *stackguard; int stackloan; void *(*start_func)(void *); void *start_arg; int joinable; void *join_arg; void **data_value; int data_count; int cancelreq; unsigned int cancelstate; struct ht_cleanup_st *cleanups; struct ht_ring_st mutexring; }


decompiled_code:
__int64 ht_get_back()
{
const ucontext_t *v0; // rax

v0 = (const ucontext_t *)pthread_getspecific(ht_worker_ctx_key);
swapcontext((ucontext_t *)(v0[1].uc_stack.ss_size + 128), v0);
ht_event_free(*(_QWORD *)(ht_current + 120LL), 1LL);
return 0LL;
}

canonical_decompiled_code:
__int64 func4()
{
const ucontext_t *v0; // rax

v0 = (const ucontext_t *)pthread_getspecific(ht_worker_ctx_key);
swapcontext((ucontext_t *)(v0[1].uc_stack.ss_size + 128), v0);
ht_event_free(*(_QWORD *)(ht_current + 120LL), 1LL);
return 0LL;
}

original_code:
int
ht_get_back()
{
   ht_worker_ctx_t* worker_ctx = (ht_worker_ctx_t*) pthread_getspecific(_ht_worker_ctx_key);
   ht_t t = worker_ctx->task;
   swapcontext(&t->mctx.uc, &worker_ctx->worker_mctx);
 ht_event_free(ht_current->events, HT_FREE_ALL);
   return 0;
}

canonical_original_code:
int ht_get_back()
{
   struct ht_worker_ctx_st *worker_ctx = (ht_worker_ctx_t*) pthread_getspecific(_ht_worker_ctx_key);
   struct ht_st *t = worker_ctx->task;
   swapcontext(&t->mctx.uc, &worker_ctx->worker_mctx);
 ht_event_free(ht_current->events, HT_FREE_ALL);
   return 0;
}

variable_types: struct ht_worker_ctx_st { struct ucontext_t { unsigned long uc_flags; struct ucontext_t *uc_link; struct stack_t { void *ss_sp; int ss_flags; unsigned long ss_size; } uc_stack; struct mcontext_t { long long gregs[23]; struct _libc_fpstate { unsigned short cwd; unsigned short swd; unsigned short ftw; unsigned short fop; unsigned long rip; unsigned long rdp; unsigned int mxcsr; unsigned int mxcr_mask; struct _libc_fpxreg { unsigned short significand[4]; unsigned short exponent; unsigned short __glibc_reserved1[3]; } _st[8]; struct _libc_xmmreg { unsigned int element[4]; } _xmm[16]; unsigned int __glibc_reserved1[24]; } *fpregs; unsigned long long __reserved1[8]; } uc_mcontext; struct __sigset_t { unsigned long __val[-1]; } uc_sigmask; struct _libc_fpstate __fpregs_mem; unsigned long long __ssp[4]; } worker_mctx; struct ht_st { struct ht_st *q_next; struct ht_st *q_prev; int q_prio; int prio; char name[40]; int dispatches; enum ht_state_en { HT_STATE_SCHEDULER=0, HT_STATE_NEW=1, HT_STATE_READY=2, HT_STATE_WAITING=3, HT_STATE_WAITING_FOR_SCHED_TO_WORKER=4, HT_STATE_DEAD=5 } state; struct timeval { long tv_sec; long tv_usec; } spawned; struct timeval lastran; struct timeval running; struct ht_event_st { struct ht_event_st *ev_next; struct ht_event_st *ev_prev; enum ht_status_t { HT_STATUS_PENDING=0, HT_STATUS_OCCURRED=1, HT_STATUS_FAILED=2 } ev_status; int ev_type; int ev_goal; union { struct { int fd; } FD; struct { int *n; int nfd; struct fd_set { long __fds_bits[-1]; } *rfds; } SELECT; struct { int fini; } TASK; struct { struct timeval tv; } TIME; struct { struct ht_msgport_st { struct ht_ringnode_st { struct ht_ringnode_st *rn_next; struct ht_ringnode_st *rn_prev; } mp_node; char *mp_name; struct ht_st *mp_tid; struct ht_ring_st { struct ht_ringnode_st *r_hook; unsigned int r_nodes; } mp_queue; } *mp; } MSG; struct { struct ht_mutex_st { struct ht_ringnode_st mx_node; int mx_state; struct ht_st *mx_owner; unsigned long mx_count; } *mutex; } MUTEX; struct { struct ht_cond_st { unsigned long cn_state; unsigned int cn_waiters; } *cond; } COND; struct { struct ht_st *tid; } TID; struct { int (*func)(void *); void *arg; struct timeval tv; } FUNC; } ev_args; } *events; struct ht_mctx_st { struct ucontext_t uc; int restored; int error; } mctx; char *stack; unsigned int stacksize; long *stackguard; int stackloan; void *(*start_func)(void *); void *start_arg; int joinable; void *join_arg; void **data_value; int data_count; int cancelreq; unsigned int cancelstate; struct ht_cleanup_st { struct ht_cleanup_st *next; void (*func)(void *); void *arg; } *cleanups; struct ht_ring_st mutexring; } *task; } *

variable_types: struct ht_st { struct ht_st *q_next; struct ht_st *q_prev; int q_prio; int prio; char name[40]; int dispatches; enum ht_state_en { HT_STATE_SCHEDULER=0, HT_STATE_NEW=1, HT_STATE_READY=2, HT_STATE_WAITING=3, HT_STATE_WAITING_FOR_SCHED_TO_WORKER=4, HT_STATE_DEAD=5 } state; struct timeval { long tv_sec; long tv_usec; } spawned; struct timeval lastran; struct timeval running; struct ht_event_st { struct ht_event_st *ev_next; struct ht_event_st *ev_prev; enum ht_status_t { HT_STATUS_PENDING=0, HT_STATUS_OCCURRED=1, HT_STATUS_FAILED=2 } ev_status; int ev_type; int ev_goal; union { struct { int fd; } FD; struct { int *n; int nfd; struct fd_set { long __fds_bits[-1]; } *rfds; } SELECT; struct { int fini; } TASK; struct { struct timeval tv; } TIME; struct { struct ht_msgport_st { struct ht_ringnode_st { struct ht_ringnode_st *rn_next; struct ht_ringnode_st *rn_prev; } mp_node; char *mp_name; struct ht_st *mp_tid; struct ht_ring_st { struct ht_ringnode_st *r_hook; unsigned int r_nodes; } mp_queue; } *mp; } MSG; struct { struct ht_mutex_st { struct ht_ringnode_st mx_node; int mx_state; struct ht_st *mx_owner; unsigned long mx_count; } *mutex; } MUTEX; struct { struct ht_cond_st { unsigned long cn_state; unsigned int cn_waiters; } *cond; } COND; struct { struct ht_st *tid; } TID; struct { int (*func)(void *); void *arg; struct timeval tv; } FUNC; } ev_args; } *events; struct ht_mctx_st { struct ucontext_t { unsigned long uc_flags; struct ucontext_t *uc_link; struct stack_t { void *ss_sp; int ss_flags; unsigned long ss_size; } uc_stack; struct mcontext_t { long long gregs[23]; struct _libc_fpstate { unsigned short cwd; unsigned short swd; unsigned short ftw; unsigned short fop; unsigned long rip; unsigned long rdp; unsigned int mxcsr; unsigned int mxcr_mask; struct _libc_fpxreg { unsigned short significand[4]; unsigned short exponent; unsigned short __glibc_reserved1[3]; } _st[8]; struct _libc_xmmreg { unsigned int element[4]; } _xmm[16]; unsigned int __glibc_reserved1[24]; } *fpregs; unsigned long long __reserved1[8]; } uc_mcontext; struct __sigset_t { unsigned long __val[-1]; } uc_sigmask; struct _libc_fpstate __fpregs_mem; unsigned long long __ssp[4]; } uc; int restored; int error; } mctx; char *stack; unsigned int stacksize; long *stackguard; int stackloan; void *(*start_func)(void *); void *start_arg; int joinable; void *join_arg; void **data_value; int data_count; int cancelreq; unsigned int cancelstate; struct ht_cleanup_st { struct ht_cleanup_st *next; void (*func)(void *); void *arg; } *cleanups; struct ht_ring_st mutexring; } *

user_defined_types: struct ht_worker_ctx_st { struct ucontext_t worker_mctx; struct ht_st *task; }


decompiled_code:
__int64 __fastcall ht_attr_destroy(void *a1)
{
__int64 result; // rax

if ( a1 )
{
free(a1);
result = 1LL;
}
else
{
*_errno_location() = 22;
result = 0LL;
}
return result;
}

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

if ( a1 )
{
free(a1);
result = 1LL;
}
else
{
*_errno_location() = 22;
result = 0LL;
}
return result;
}

original_code:
int
ht_attr_destroy(ht_attr_t a)
{
    if (a == ((void *)0))
        return ((*__errno_location ()) = (22), ((0)));
    free(a);
    return (!(0));
}

canonical_original_code:
int ht_attr_destroy(struct ht_attr_st *a)
{
    if (a == ((void *)0))
        return ((*__errno_location ()) = (22), ((0)));
    free(a);
    return (!(0));
}

variable_types: struct ht_attr_st { struct ht_st { struct ht_st *q_next; struct ht_st *q_prev; int q_prio; int prio; char name[40]; int dispatches; enum ht_state_en { HT_STATE_SCHEDULER=0, HT_STATE_NEW=1, HT_STATE_READY=2, HT_STATE_WAITING=3, HT_STATE_WAITING_FOR_SCHED_TO_WORKER=4, HT_STATE_DEAD=5 } state; struct timeval { long tv_sec; long tv_usec; } spawned; struct timeval lastran; struct timeval running; struct ht_event_st { struct ht_event_st *ev_next; struct ht_event_st *ev_prev; enum ht_status_t { HT_STATUS_PENDING=0, HT_STATUS_OCCURRED=1, HT_STATUS_FAILED=2 } ev_status; int ev_type; int ev_goal; union { struct { int fd; } FD; struct { int *n; int nfd; struct fd_set { long __fds_bits[-1]; } *rfds; } SELECT; struct { int fini; } TASK; struct { struct timeval tv; } TIME; struct { struct ht_msgport_st { struct ht_ringnode_st { struct ht_ringnode_st *rn_next; struct ht_ringnode_st *rn_prev; } mp_node; char *mp_name; struct ht_st *mp_tid; struct ht_ring_st { struct ht_ringnode_st *r_hook; unsigned int r_nodes; } mp_queue; } *mp; } MSG; struct { struct ht_mutex_st { struct ht_ringnode_st mx_node; int mx_state; struct ht_st *mx_owner; unsigned long mx_count; } *mutex; } MUTEX; struct { struct ht_cond_st { unsigned long cn_state; unsigned int cn_waiters; } *cond; } COND; struct { struct ht_st *tid; } TID; struct { int (*func)(void *); void *arg; struct timeval tv; } FUNC; } ev_args; } *events; struct ht_mctx_st { struct ucontext_t { unsigned long uc_flags; struct ucontext_t *uc_link; struct stack_t { void *ss_sp; int ss_flags; unsigned long ss_size; } uc_stack; struct mcontext_t { long long gregs[23]; struct _libc_fpstate { unsigned short cwd; unsigned short swd; unsigned short ftw; unsigned short fop; unsigned long rip; unsigned long rdp; unsigned int mxcsr; unsigned int mxcr_mask; struct _libc_fpxreg { unsigned short significand[4]; unsigned short exponent; unsigned short __glibc_reserved1[3]; } _st[8]; struct _libc_xmmreg { unsigned int element[4]; } _xmm[16]; unsigned int __glibc_reserved1[24]; } *fpregs; unsigned long long __reserved1[8]; } uc_mcontext; struct __sigset_t { unsigned long __val[-1]; } uc_sigmask; struct _libc_fpstate __fpregs_mem; unsigned long long __ssp[4]; } uc; int restored; int error; } mctx; char *stack; unsigned int stacksize; long *stackguard; int stackloan; void *(*start_func)(void *); void *start_arg; int joinable; void *join_arg; void **data_value; int data_count; int cancelreq; unsigned int cancelstate; struct ht_cleanup_st { struct ht_cleanup_st *next; void (*func)(void *); void *arg; } *cleanups; struct ht_ring_st mutexring; } *a_tid; int a_prio; int a_dispatches; char a_name[40]; int a_joinable; unsigned int a_cancelstate; unsigned int a_stacksize; char *a_stackaddr; } *

user_defined_types: struct ht_attr_st { struct ht_st *a_tid; int a_prio; int a_dispatches; char a_name[40]; int a_joinable; unsigned int a_cancelstate; unsigned int a_stacksize; char *a_stackaddr; }

user_defined_types: struct ht_mctx_st { struct ucontext_t uc; int restored; int error; }

user_defined_types: struct ht_event_st { struct ht_event_st *ev_next; struct ht_event_st *ev_prev; enum ht_status_t ev_status; int ev_type; int ev_goal; union { struct { int fd; } FD; struct { int *n; int nfd; struct fd_set *rfds; } SELECT; struct { int fini; } TASK; struct { struct timeval tv; } TIME; struct { struct ht_msgport_st *mp; } MSG; struct { struct ht_mutex_st *mutex; } MUTEX; struct { struct ht_cond_st *cond; } COND; struct { struct ht_st *tid; } TID; struct { int (*func)(void *); void *arg; struct timeval tv; } FUNC; } ev_args; }


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

if ( a1 )
{
if ( *(_QWORD *)a1 )
{
*_errno_location() = 1;
result = 0LL;
}
else
{
*(_DWORD *)(a1 + 8) = 0;
ht_util_cpystrn(a1 + 16, "unknown", 40LL);
*(_DWORD *)(a1 + 12) = 0;
*(_QWORD *)(a1 + 56) = 0x900000001LL;
result = 1LL;
*(_DWORD *)(a1 + 64) = 0x10000;
*(_QWORD *)(a1 + 72) = 0LL;
}
}
else
{
*_errno_location() = 22;
result = 0LL;
}
return result;
}

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

if ( a1 )
{
if ( *(_QWORD *)a1 )
{
*_errno_location() = 1;
result = 0LL;
}
else
{
*(_DWORD *)(a1 + 8) = 0;
ht_util_cpystrn(a1 + 16, "unknown", 40LL);
*(_DWORD *)(a1 + 12) = 0;
*(_QWORD *)(a1 + 56) = 0x900000001LL;
result = 1LL;
*(_DWORD *)(a1 + 64) = 0x10000;
*(_QWORD *)(a1 + 72) = 0LL;
}
}
else
{
*_errno_location() = 22;
result = 0LL;
}
return result;
}

original_code:
int
ht_attr_init(ht_attr_t a)
{
    if (a == ((void *)0))
        return ((*__errno_location ()) = (22), ((0)));
    if (a->a_tid != ((void *)0))
        return ((*__errno_location ()) = (1), ((0)));
    a->a_prio = 0;
    ht_util_cpystrn(a->a_name, "unknown", 40);
    a->a_dispatches = 0;
    a->a_joinable = (!(0));
    a->a_cancelstate = ((1<<(0))|(1<<(3)));
    a->a_stacksize = 64*1024;
    a->a_stackaddr = ((void *)0);
    return (!(0));
}

canonical_original_code:
int ht_attr_init(struct ht_attr_st *a)
{
    if (a == ((void *)0))
        return ((*__errno_location ()) = (22), ((0)));
    if (a->a_tid != ((void *)0))
        return ((*__errno_location ()) = (1), ((0)));
    a->a_prio = 0;
    ht_util_cpystrn(a->a_name, "unknown", 40);
    a->a_dispatches = 0;
    a->a_joinable = (!(0));
    a->a_cancelstate = ((1<<(0))|(1<<(3)));
    a->a_stacksize = 64*1024;
    a->a_stackaddr = ((void *)0);
    return (!(0));
}

user_defined_types: struct ucontext_t { unsigned long uc_flags; struct ucontext_t *uc_link; struct stack_t uc_stack; struct mcontext_t uc_mcontext; struct __sigset_t uc_sigmask; struct _libc_fpstate __fpregs_mem; unsigned long long __ssp[4]; }

user_defined_types: struct mcontext_t { long long gregs[23]; struct _libc_fpstate *fpregs; unsigned long long __reserved1[8]; }

user_defined_types: struct ht_msgport_st { struct ht_ringnode_st mp_node; char *mp_name; struct ht_st *mp_tid; struct ht_ring_st mp_queue; }

user_defined_types: struct ht_ringnode_st { struct ht_ringnode_st *rn_next; struct ht_ringnode_st *rn_prev; }

user_defined_types: struct ht_ring_st { struct ht_ringnode_st *r_hook; unsigned int r_nodes; }

user_defined_types: struct _libc_fpxreg { unsigned short significand[4]; unsigned short exponent; unsigned short __glibc_reserved1[3]; }


decompiled_code:
_QWORD *ht_attr_new()
{
_QWORD *v0; // rax
_QWORD *v1; // r12

v0 = malloc(0x50uLL);
v1 = v0;
if ( v0 )
{
*v0 = 0LL;
ht_attr_init((__int64)v0);
}
else
{
*_errno_location() = 12;
}
return v1;
}

canonical_decompiled_code:
_QWORD *func2()
{
_QWORD *v0; // rax
_QWORD *v1; // r12

v0 = malloc(0x50uLL);
v1 = v0;
if ( v0 )
{
*v0 = 0LL;
func1((__int64)v0);
}
else
{
*_errno_location() = 12;
}
return v1;
}

original_code:
ht_attr_t
ht_attr_new(void)
{
    ht_attr_t a;
    if ((a = (ht_attr_t)malloc(sizeof(struct ht_attr_st))) == ((void *)0))
        return ((*__errno_location ()) = (12), ((ht_attr_t)((void *)0)));
    a->a_tid = ((void *)0);
    ht_attr_init(a);
    return a;
}

canonical_original_code:
struct ht_attr_st *ht_attr_new()
{
    struct ht_attr_st *a;
    if ((a = (struct ht_attr_st *)malloc(sizeof(struct ht_attr_st))) == ((void *)0))
        return ((*__errno_location ()) = (12), ((ht_attr_t)((void *)0)));
    a->a_tid = ((void *)0);
    ht_attr_init(a);
    return a;
}

return_type: struct ht_attr_st { struct ht_st { struct ht_st *q_next; struct ht_st *q_prev; int q_prio; int prio; char name[40]; int dispatches; enum ht_state_en { HT_STATE_SCHEDULER=0, HT_STATE_NEW=1, HT_STATE_READY=2, HT_STATE_WAITING=3, HT_STATE_WAITING_FOR_SCHED_TO_WORKER=4, HT_STATE_DEAD=5 } state; struct timeval { long tv_sec; long tv_usec; } spawned; struct timeval lastran; struct timeval running; struct ht_event_st { struct ht_event_st *ev_next; struct ht_event_st *ev_prev; enum ht_status_t { HT_STATUS_PENDING=0, HT_STATUS_OCCURRED=1, HT_STATUS_FAILED=2 } ev_status; int ev_type; int ev_goal; union { struct { int fd; } FD; struct { int *n; int nfd; struct fd_set { long __fds_bits[-1]; } *rfds; } SELECT; struct { int fini; } TASK; struct { struct timeval tv; } TIME; struct { struct ht_msgport_st { struct ht_ringnode_st { struct ht_ringnode_st *rn_next; struct ht_ringnode_st *rn_prev; } mp_node; char *mp_name; struct ht_st *mp_tid; struct ht_ring_st { struct ht_ringnode_st *r_hook; unsigned int r_nodes; } mp_queue; } *mp; } MSG; struct { struct ht_mutex_st { struct ht_ringnode_st mx_node; int mx_state; struct ht_st *mx_owner; unsigned long mx_count; } *mutex; } MUTEX; struct { struct ht_cond_st { unsigned long cn_state; unsigned int cn_waiters; } *cond; } COND; struct { struct ht_st *tid; } TID; struct { int (*func)(void *); void *arg; struct timeval tv; } FUNC; } ev_args; } *events; struct ht_mctx_st { struct ucontext_t { unsigned long uc_flags; struct ucontext_t *uc_link; struct stack_t { void *ss_sp; int ss_flags; unsigned long ss_size; } uc_stack; struct mcontext_t { long long gregs[23]; struct _libc_fpstate { unsigned short cwd; unsigned short swd; unsigned short ftw; unsigned short fop; unsigned long rip; unsigned long rdp; unsigned int mxcsr; unsigned int mxcr_mask; struct _libc_fpxreg { unsigned short significand[4]; unsigned short exponent; unsigned short __glibc_reserved1[3]; } _st[8]; struct _libc_xmmreg { unsigned int element[4]; } _xmm[16]; unsigned int __glibc_reserved1[24]; } *fpregs; unsigned long long __reserved1[8]; } uc_mcontext; struct __sigset_t { unsigned long __val[-1]; } uc_sigmask; struct _libc_fpstate __fpregs_mem; unsigned long long __ssp[4]; } uc; int restored; int error; } mctx; char *stack; unsigned int stacksize; long *stackguard; int stackloan; void *(*start_func)(void *); void *start_arg; int joinable; void *join_arg; void **data_value; int data_count; int cancelreq; unsigned int cancelstate; struct ht_cleanup_st { struct ht_cleanup_st *next; void (*func)(void *); void *arg; } *cleanups; struct ht_ring_st mutexring; } *a_tid; int a_prio; int a_dispatches; char a_name[40]; int a_joinable; unsigned int a_cancelstate; unsigned int a_stacksize; char *a_stackaddr; } *

user_defined_types: struct _libc_fpstate { unsigned short cwd; unsigned short swd; unsigned short ftw; unsigned short fop; unsigned long rip; unsigned long rdp; unsigned int mxcsr; unsigned int mxcr_mask; struct _libc_fpxreg _st[8]; struct _libc_xmmreg _xmm[16]; unsigned int __glibc_reserved1[24]; }