decompiled_code:
__int64 __fastcall net_stack_create(__int64 a1, int a2, __int64 a3)
{
__int64 v4; // rbx

v4 = mhandle_calloc(1LL, 32LL, "message.c:70");
if ( !v4 )
fatal("%s: out of memory", "net_stack_create");
*(_QWORD *)v4 = a1;
*(_DWORD *)(v4 + 16) = a2;
*(_QWORD *)(v4 + 24) = a3;
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, int a2, __int64 a3)
{
__int64 v4; // rbx

v4 = mhandle_calloc(1LL, 32LL, "message.c:70");
if ( !v4 )
fatal("%s: out of memory", "net_stack_create");
*(_QWORD *)v4 = a1;
*(_DWORD *)(v4 + 16) = a2;
*(_QWORD *)(v4 + 24) = a3;
return v4;
}

original_code:
struct net_stack_t *net_stack_create(struct net_t *net,
 int retevent, void *retstack)
{
 struct net_stack_t *stack;
 stack = (mhandle_calloc(1, sizeof(struct net_stack_t), "message.c" ":" "70"));
 if (!stack)
  fatal("%s: out of memory", __FUNCTION__);
 stack->net = net;
 stack->ret_event = retevent;
 stack->ret_stack = retstack;
 return stack;
}

variable_types: retevent int

variable_types:
retstack
void *

variable_types: struct net_stack_t { struct net_t { char *name; long long msg_id_counter; struct list_t { int count; int error_code; int size; int head; int tail; void **elem; } *node_list; int node_count; int end_node_count; struct list_t *link_list; struct net_routing_table_t { struct net_t *net; int dim; struct net_routing_table_entry_t { int cost; struct net_node_t { struct net_t *net; enum net_node_kind_t { net_node_invalid=0, net_node_end=1, net_node_switch=2, net_node_bus=3 } kind; int index; char *name; void *user_data; int bandwidth; long long bus_busy; int input_buffer_size; int output_buffer_size; struct list_t *input_buffer_list; struct list_t *output_buffer_list; long long bytes_received; long long msgs_received; long long bytes_sent; long long msgs_sent; } *next_node; struct net_buffer_t { struct net_t *net; struct net_node_t *node; char *name; int index; int size; int count; long long read_busy; long long write_busy; struct net_link_t { struct net_t *net; char *name; struct net_node_t *src_node; struct net_node_t *dst_node; struct net_buffer_t *dst_buffer; struct net_buffer_t *src_buffer; int bandwidth; long long busy; int virtual_channel; long long sched_when; struct net_buffer_t *sched_buffer; long long busy_cycles; long long transferred_bytes; long long transferred_msgs; } *link; struct list_t *msg_list; long long sched_when; struct net_buffer_t *sched_buffer; struct linked_list_t { int count; int error_code; struct linked_list_elem_t { struct linked_list_elem_t *prev; struct linked_list_elem_t *next; void *data; } *head; int current_index; } *wakeup_list; int occupancy_bytes_value; int occupancy_msgs_value; long long occupancy_measured_cycle; long long occupancy_bytes_acc; long long occupancy_msgs_acc; } *output_buffer; } *entries; int has_cycle; } *routing_table; struct net_msg_t { struct net_t *net; long long id; int size; long long send_cycle; long long busy; struct net_node_t *src_node; struct net_node_t *dst_node; void *data; struct net_node_t *node; struct net_buffer_t *buffer; struct net_buffer_t *src_buffer; struct net_buffer_t *dst_buffer; struct net_msg_t *bucket_next; } *msg_table[32]; long long transfers; long long lat_acc; long long msg_size_acc; } *net; struct net_msg_t *msg; int ret_event; struct net_stack_t *ret_stack; } *

user_defined_types: struct net_stack_t { struct net_t *net; struct net_msg_t *msg; int ret_event; struct net_stack_t *ret_stack; }


decompiled_code:
__int64 __fastcall net_stack_return(__int64 a1)
{
unsigned int v1; // ebx
__int64 v2; // rbp

v1 = *(_DWORD *)(a1 + 16);
v2 = *(_QWORD *)(a1 + 24);
mhandle_free(a1, "message.c:89");
return esim_schedule_event(v1, v2, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
unsigned int v1; // ebx
__int64 v2; // rbp

v1 = *(_DWORD *)(a1 + 16);
v2 = *(_QWORD *)(a1 + 24);
mhandle_free(a1, "message.c:89");
return esim_schedule_event(v1, v2, 0LL);
}

original_code:
void net_stack_return(struct net_stack_t *stack)
{
 int retevent = stack->ret_event;
 struct net_stack_t *retstack = stack->ret_stack;
 (mhandle_free(stack, "message.c" ":" "89"));
 esim_schedule_event(retevent, retstack, 0);
}

return_type: void

user_defined_types: struct net_t { char *name; long long msg_id_counter; struct list_t *node_list; int node_count; int end_node_count; struct list_t *link_list; struct net_routing_table_t *routing_table; struct net_msg_t *msg_table[32]; long long transfers; long long lat_acc; long long msg_size_acc; }

user_defined_types: struct list_t { int count; int error_code; int size; int head; int tail; void **elem; }

user_defined_types: struct net_routing_table_t { struct net_t *net; int dim; struct net_routing_table_entry_t *entries; int has_cycle; }

user_defined_types: struct net_msg_t { struct net_t *net; long long id; int size; long long send_cycle; long long busy; struct net_node_t *src_node; struct net_node_t *dst_node; void *data; struct net_node_t *node; struct net_buffer_t *buffer; struct net_buffer_t *src_buffer; struct net_buffer_t *dst_buffer; struct net_msg_t *bucket_next; }

user_defined_types: struct net_routing_table_entry_t { int cost; struct net_node_t *next_node; struct net_buffer_t *output_buffer; }

user_defined_types: struct net_node_t { struct net_t *net; enum net_node_kind_t kind; int index; char *name; void *user_data; int bandwidth; long long bus_busy; int input_buffer_size; int output_buffer_size; struct list_t *input_buffer_list; struct list_t *output_buffer_list; long long bytes_received; long long msgs_received; long long bytes_sent; long long msgs_sent; }

user_defined_types: struct net_buffer_t { struct net_t *net; struct net_node_t *node; char *name; int index; int size; int count; long long read_busy; long long write_busy; struct net_link_t *link; struct list_t *msg_list; long long sched_when; struct net_buffer_t *sched_buffer; struct linked_list_t *wakeup_list; int occupancy_bytes_value; int occupancy_msgs_value; long long occupancy_measured_cycle; long long occupancy_bytes_acc; long long occupancy_msgs_acc; }

user_defined_types: enum net_node_kind_t { net_node_invalid=0, net_node_end=1, net_node_switch=2, net_node_bus=3 }

user_defined_types: struct net_link_t { struct net_t *net; char *name; struct net_node_t *src_node; struct net_node_t *dst_node; struct net_buffer_t *dst_buffer; struct net_buffer_t *src_buffer; int bandwidth; long long busy; int virtual_channel; long long sched_when; struct net_buffer_t *sched_buffer; long long busy_cycles; long long transferred_bytes; long long transferred_msgs; }

user_defined_types: struct linked_list_t { int count; int error_code; struct linked_list_elem_t *head; int current_index; }

user_defined_types: struct linked_list_elem_t { struct linked_list_elem_t *prev; struct linked_list_elem_t *next; void *data; }


decompiled_code:
__int64 __fastcall net_event_handler(unsigned int a1, __int64 a2)
{
const char **v2; // r13
__int64 v3; // rbx
__int64 v4; // r15
__int64 v5; // r14
__int64 result; // rax
__int64 v7; // r12
__int64 v8; // r14
__int64 v9; // rax
__int64 v10; // rdx
__int64 v11; // r15
__int64 v12; // rax
int v13; // er13
__int64 v14; // rdx
__int64 v15; // rax
int v16; // ecx
int v17; // er12
__int64 v18; // rax
__int64 v19; // rdx
__int64 v20; // [rsp+0h] [rbp-48h]
__int64 v21; // [rsp+0h] [rbp-48h]
__int64 v22; // [rsp+8h] [rbp-40h]

v2 = *(const char ***)a2;
v20 = *(_QWORD *)(*(_QWORD *)a2 + 40LL);
v3 = *(_QWORD *)(a2 + 8);
v4 = *(_QWORD *)(v3 + 48);
if ( EV_NET_SEND == a1 )
{
v7 = *(_QWORD *)(v3 + 40);
if ( net_debug_category )
_debug(
net_debug_category,
"msg a=\"send\" net=\"%s\" msg=%lld size=%d src=\"%s\" dst=\"%s\"\n",
*v2,
*(_QWORD *)(v3 + 8),
*(unsigned int *)(v3 + 16),
*(const char **)(v7 + 16),
*(const char **)(v4 + 16));
v8 = *(_QWORD *)(net_routing_table_lookup(v20, v7, v4) + 16);
if ( !v8 )
fatal(
"%s: no route from %s to %s.\n%s",
*v2,
*(const char **)(v7 + 16),
*(const char **)(v4 + 16),
err_net_no_route);
if ( *(_QWORD *)(v8 + 48) >= esim_cycle )
panic("%s: output buffer busy.\n%s", "net_event_handler", err_net_can_send);
if ( *(_DWORD *)(v3 + 16) > *(_DWORD *)(v8 + 28) )
panic("%s: message does not fit in buffer.\n%s", "net_event_handler", err_net_can_send);
if ( *(_DWORD *)(v8 + 32) + *(_DWORD *)(v3 + 16) > *(_DWORD *)(v8 + 28) )
panic("%s: output buffer full.\n%s", "net_event_handler", err_net_can_send);
net_buffer_insert(v8, v3);
v9 = esim_cycle;
*(_QWORD *)(v8 + 48) = esim_cycle;
*(_QWORD *)(v3 + 64) = v7;
*(_QWORD *)(v3 + 72) = v8;
*(_QWORD *)(v3 + 32) = v9;
result = esim_schedule_event(EV_NET_OUTPUT_BUFFER, a2, 1LL);
}
else
{
v22 = *(_QWORD *)(v3 + 64);
v5 = *(_QWORD *)(v3 + 72);
if ( EV_NET_OUTPUT_BUFFER == a1 )
{
if ( net_debug_category )
_debug(
net_debug_category,
"msg a=\"obuf\" net=\"%s\" msg=%lld node=\"%s\" buf=\"%s\"\n",
*v2,
*(_QWORD *)(v3 + 8),
*(const char **)(*(_QWORD *)(v3 + 64) + 16LL),
*(const char **)(v5 + 16));
if ( !(unsigned int)list_count(*(_QWORD *)(v5 + 64)) )
_assert_fail("list_count(buffer->msg_list)", "message.c", 0xA9u, "net_event_handler");
if ( v3 != list_get(*(_QWORD *)(v5 + 64), 0LL) )
return net_buffer_wait(v5, a1, a2);
v10 = *(_QWORD *)(v5 + 40);
if ( v10 >= esim_cycle )
return esim_schedule_event(a1, a2, (unsigned int)(v10 - esim_cycle + 1));
v11 = *(_QWORD *)(v5 + 56);
v10 = *(_QWORD *)(v11 + 56);
if ( esim_cycle <= v10 )
return esim_schedule_event(a1, a2, (unsigned int)(v10 - esim_cycle + 1));
if ( *(int *)(v11 + 64) > 1 && v5 != net_link_arbitrator_vc(*(_QWORD *)(v5 + 56), v22) )
{
if ( net_debug_category )
_debug(
net_debug_category,
"msg a=\"arbitrator stall\" net=\"%s\" msg=%lld why=\"sched\"\n",
*v2,
*(_QWORD *)(v3 + 8));
return esim_schedule_event(a1, a2, 1LL);
}
if ( *(_QWORD *)(v11 + 40) != v5 )
_assert_fail("buffer == link->src_buffer", "message.c", 0xD3u, "net_event_handler");
v21 = *(_QWORD *)(v11 + 32);
v12 = *(_QWORD *)(v21 + 48);
if ( v12 >= esim_cycle )
return esim_schedule_event(a1, a2, (unsigned int)(v12 - esim_cycle + 1));
if ( *(_DWORD *)(v3 + 16) > *(_DWORD *)(v21 + 28) )
fatal("%s: message does not fit in buffer.\n%s", *v2, err_net_large_message);
if ( *(_DWORD *)(v21 + 32) + *(_DWORD *)(v3 + 16) > *(_DWORD *)(v21 + 28) )
return net_buffer_wait(v21, a1, a2);
v13 = (*(_DWORD *)(v3 + 16) - 1) / *(_DWORD *)(v11 + 48) + 1;
if ( v13 <= 0 )
_assert_fail("lat > 0", "message.c", 0xE7u, "net_event_handler");
v14 = esim_cycle;
v15 = v13 + esim_cycle - 1LL;
*(_QWORD *)(v5 + 40) = v15;
*(_QWORD *)(v11 + 56) = v15;
*(_QWORD *)(v21 + 48) = v15;
if ( v14 <= *(_QWORD *)(v3 + 32) )
_assert_fail("msg->busy < esim_cycle", "message.c", 0xEDu, "net_event_handler");
net_buffer_extract(v5, v3);
net_buffer_insert(v21, v3);
*(_QWORD *)(v3 + 64) = *(_QWORD *)(v21 + 8);
*(_QWORD *)(v3 + 72) = v21;
*(_QWORD *)(v3 + 32) = esim_cycle + v13 - 1LL;
*(_QWORD *)(v11 + 88) += v13;
*(_QWORD *)(v11 + 96) += *(int *)(v3 + 16);
++*(_QWORD *)(v11 + 104);
*(_QWORD *)(v22 + 88) += *(int *)(v3 + 16);
++*(_QWORD *)(v22 + 96);
*(_QWORD *)(*(_QWORD *)(v21 + 8) + 72LL) += *(int *)(v3 + 16);
++*(_QWORD *)(*(_QWORD *)(v21 + 8) + 80LL);
result = esim_schedule_event(EV_NET_INPUT_BUFFER, a2, (unsigned int)v13);
}
else
{
if ( EV_NET_INPUT_BUFFER != a1 )
{
if ( EV_NET_RECEIVE != a1 )
return panic("%s: unknown event", "net_event_handler");
if ( net_debug_category )
_debug(
net_debug_category,
"msg a=\"receive\" net=\"%s\" msg=%lld node=\"%s\"\n",
*v2,
*(_QWORD *)(v3 + 8),
*(const char **)(v4 + 16));
++v2[38];
v2[39] += esim_cycle - *(_QWORD *)(v3 + 24);
v2[40] += *(int *)(v3 + 16);
if ( *(_DWORD *)(a2 + 16) == ESIM_EV_NONE )
net_receive(v2, v22, v3);
return net_stack_return(a2);
}
if ( net_debug_category )
_debug(
net_debug_category,
"msg a=\"ibuf\" net=\"%s\" msg=%lld node=\"%s\" buf=\"%s\"\n",
*v2,
*(_QWORD *)(v3 + 8),
*(const char **)(v22 + 16),
*(const char **)(v5 + 16));
if ( !(unsigned int)list_count(*(_QWORD *)(v5 + 64)) )
_assert_fail("list_count(buffer->msg_list)", "message.c", 0x114u, "net_event_handler");
if ( v3 != list_get(*(_QWORD *)(v5 + 64), 0LL) )
{
if ( net_debug_category )
_debug(net_debug_category, "msg a=\"stall\" net=\"%s\" msg=%lld why=\"not-head\"\n", *v2, *(_QWORD *)(v3 + 8));
return net_buffer_wait(v5, a1, a2);
}
if ( *(_QWORD *)(v3 + 48) == v22 )
return esim_schedule_event(EV_NET_RECEIVE, a2, 0LL);
if ( *(_QWORD *)(v5 + 40) >= esim_cycle )
{
if ( net_debug_category )
_debug(net_debug_category, "msg a=\"stall\" net=\"%s\" msg=%lld why=\"src-busy\"\n", *v2, *(_QWORD *)(v3 + 8));
return esim_schedule_event(a1, a2, (unsigned int)(*(_DWORD *)(v5 + 40) + 1 - esim_cycle));
}
v21 = *(_QWORD *)(net_routing_table_lookup(v20, v22, v4) + 16);
if ( !v21 )
fatal(
"%s: no route from %s to %s.\n%s",
*v2,
*(const char **)(v22 + 16),
*(const char **)(v4 + 16),
err_net_no_route);
if ( *(_QWORD *)(v21 + 48) >= esim_cycle )
{
if ( net_debug_category )
_debug(net_debug_category, "msg a=\"stall\" net=\"%s\" msg=%lld why=\"dst-busy\"\n", *v2, *(_QWORD *)(v3 + 8));
result = esim_schedule_event(a1, a2, (unsigned int)(*(_DWORD *)(v21 + 48) + 1 - esim_cycle));
}
else
{
if ( *(_DWORD *)(v3 + 16) > *(_DWORD *)(v21 + 28) )
fatal("%s: message does not fit in buffer.\n%s", *v2, err_net_large_message);
if ( *(_DWORD *)(v21 + 32) + *(_DWORD *)(v3 + 16) > *(_DWORD *)(v21 + 28) )
{
if ( net_debug_category )
_debug(
net_debug_category,
"msg a=\"stall\" net=\"%s\" msg=%lld why=\"dst-full\"\n",
*v2,
*(_QWORD *)(v3 + 8));
return net_buffer_wait(v21, a1, a2);
}
if ( v5 != net_node_schedule(v22, v21) )
{
if ( net_debug_category )
_debug(net_debug_category, "msg a=\"stall\" net=\"%s\" msg=%lld why=\"sched\"\n", *v2, *(_QWORD *)(v3 + 8));
return esim_schedule_event(a1, a2, 1LL);
}
if ( *(_DWORD *)(v22 + 8) == 1 )
_assert_fail("node->kind != net_node_end", "message.c", 0x16Cu, "net_event_handler");
v16 = *(_DWORD *)(v22 + 32);
if ( v16 <= 0 )
_assert_fail("node->bandwidth > 0", "message.c", 0x16Du, "net_event_handler");
v17 = (*(_DWORD *)(v3 + 16) - 1) / v16 + 1;
if ( v17 <= 0 )
_assert_fail("lat > 0", "message.c", 0x16Fu, "net_event_handler");
v18 = esim_cycle;
v19 = v17 + esim_cycle - 1LL;
*(_QWORD *)(v5 + 40) = v19;
*(_QWORD *)(v21 + 48) = v19;
if ( v18 <= *(_QWORD *)(v3 + 32) )
_assert_fail("msg->busy < esim_cycle", "message.c", 0x174u, "net_event_handler");
net_buffer_extract(v5, v3);
net_buffer_insert(v21, v3);
*(_QWORD *)(v3 + 72) = v21;
*(_QWORD *)(v3 + 32) = esim_cycle + v17 - 1LL;
result = esim_schedule_event(EV_NET_OUTPUT_BUFFER, a2, (unsigned int)v17);
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned int a1, __int64 a2)
{
const char **v2; // r13
__int64 v3; // rbx
__int64 v4; // r15
__int64 v5; // r14
__int64 result; // rax
__int64 v7; // r12
__int64 v8; // r14
__int64 v9; // rax
__int64 v10; // rdx
__int64 v11; // r15
__int64 v12; // rax
int v13; // er13
__int64 v14; // rdx
__int64 v15; // rax
int v16; // ecx
int v17; // er12
__int64 v18; // rax
__int64 v19; // rdx
__int64 v20; // [rsp+0h] [rbp-48h]
__int64 v21; // [rsp+0h] [rbp-48h]
__int64 v22; // [rsp+8h] [rbp-40h]

v2 = *(const char ***)a2;
v20 = *(_QWORD *)(*(_QWORD *)a2 + 40LL);
v3 = *(_QWORD *)(a2 + 8);
v4 = *(_QWORD *)(v3 + 48);
if ( EV_NET_SEND == a1 )
{
v7 = *(_QWORD *)(v3 + 40);
if ( net_debug_category )
_debug(
net_debug_category,
"msg a=\"send\" net=\"%s\" msg=%lld size=%d src=\"%s\" dst=\"%s\"\n",
*v2,
*(_QWORD *)(v3 + 8),
*(unsigned int *)(v3 + 16),
*(const char **)(v7 + 16),
*(const char **)(v4 + 16));
v8 = *(_QWORD *)(net_routing_table_lookup(v20, v7, v4) + 16);
if ( !v8 )
fatal(
"%s: no route from %s to %s.\n%s",
*v2,
*(const char **)(v7 + 16),
*(const char **)(v4 + 16),
err_net_no_route);
if ( *(_QWORD *)(v8 + 48) >= esim_cycle )
panic("%s: output buffer busy.\n%s", "net_event_handler", err_net_can_send);
if ( *(_DWORD *)(v3 + 16) > *(_DWORD *)(v8 + 28) )
panic("%s: message does not fit in buffer.\n%s", "net_event_handler", err_net_can_send);
if ( *(_DWORD *)(v8 + 32) + *(_DWORD *)(v3 + 16) > *(_DWORD *)(v8 + 28) )
panic("%s: output buffer full.\n%s", "net_event_handler", err_net_can_send);
net_buffer_insert(v8, v3);
v9 = esim_cycle;
*(_QWORD *)(v8 + 48) = esim_cycle;
*(_QWORD *)(v3 + 64) = v7;
*(_QWORD *)(v3 + 72) = v8;
*(_QWORD *)(v3 + 32) = v9;
result = esim_schedule_event(EV_NET_OUTPUT_BUFFER, a2, 1LL);
}
else
{
v22 = *(_QWORD *)(v3 + 64);
v5 = *(_QWORD *)(v3 + 72);
if ( EV_NET_OUTPUT_BUFFER == a1 )
{
if ( net_debug_category )
_debug(
net_debug_category,
"msg a=\"obuf\" net=\"%s\" msg=%lld node=\"%s\" buf=\"%s\"\n",
*v2,
*(_QWORD *)(v3 + 8),
*(const char **)(*(_QWORD *)(v3 + 64) + 16LL),
*(const char **)(v5 + 16));
if ( !(unsigned int)list_count(*(_QWORD *)(v5 + 64)) )
_assert_fail("list_count(buffer->msg_list)", "message.c", 0xA9u, "net_event_handler");
if ( v3 != list_get(*(_QWORD *)(v5 + 64), 0LL) )
return net_buffer_wait(v5, a1, a2);
v10 = *(_QWORD *)(v5 + 40);
if ( v10 >= esim_cycle )
return esim_schedule_event(a1, a2, (unsigned int)(v10 - esim_cycle + 1));
v11 = *(_QWORD *)(v5 + 56);
v10 = *(_QWORD *)(v11 + 56);
if ( esim_cycle <= v10 )
return esim_schedule_event(a1, a2, (unsigned int)(v10 - esim_cycle + 1));
if ( *(int *)(v11 + 64) > 1 && v5 != net_link_arbitrator_vc(*(_QWORD *)(v5 + 56), v22) )
{
if ( net_debug_category )
_debug(
net_debug_category,
"msg a=\"arbitrator stall\" net=\"%s\" msg=%lld why=\"sched\"\n",
*v2,
*(_QWORD *)(v3 + 8));
return esim_schedule_event(a1, a2, 1LL);
}
if ( *(_QWORD *)(v11 + 40) != v5 )
_assert_fail("buffer == link->src_buffer", "message.c", 0xD3u, "net_event_handler");
v21 = *(_QWORD *)(v11 + 32);
v12 = *(_QWORD *)(v21 + 48);
if ( v12 >= esim_cycle )
return esim_schedule_event(a1, a2, (unsigned int)(v12 - esim_cycle + 1));
if ( *(_DWORD *)(v3 + 16) > *(_DWORD *)(v21 + 28) )
fatal("%s: message does not fit in buffer.\n%s", *v2, err_net_large_message);
if ( *(_DWORD *)(v21 + 32) + *(_DWORD *)(v3 + 16) > *(_DWORD *)(v21 + 28) )
return net_buffer_wait(v21, a1, a2);
v13 = (*(_DWORD *)(v3 + 16) - 1) / *(_DWORD *)(v11 + 48) + 1;
if ( v13 <= 0 )
_assert_fail("lat > 0", "message.c", 0xE7u, "net_event_handler");
v14 = esim_cycle;
v15 = v13 + esim_cycle - 1LL;
*(_QWORD *)(v5 + 40) = v15;
*(_QWORD *)(v11 + 56) = v15;
*(_QWORD *)(v21 + 48) = v15;
if ( v14 <= *(_QWORD *)(v3 + 32) )
_assert_fail("msg->busy < esim_cycle", "message.c", 0xEDu, "net_event_handler");
net_buffer_extract(v5, v3);
net_buffer_insert(v21, v3);
*(_QWORD *)(v3 + 64) = *(_QWORD *)(v21 + 8);
*(_QWORD *)(v3 + 72) = v21;
*(_QWORD *)(v3 + 32) = esim_cycle + v13 - 1LL;
*(_QWORD *)(v11 + 88) += v13;
*(_QWORD *)(v11 + 96) += *(int *)(v3 + 16);
++*(_QWORD *)(v11 + 104);
*(_QWORD *)(v22 + 88) += *(int *)(v3 + 16);
++*(_QWORD *)(v22 + 96);
*(_QWORD *)(*(_QWORD *)(v21 + 8) + 72LL) += *(int *)(v3 + 16);
++*(_QWORD *)(*(_QWORD *)(v21 + 8) + 80LL);
result = esim_schedule_event(EV_NET_INPUT_BUFFER, a2, (unsigned int)v13);
}
else
{
if ( EV_NET_INPUT_BUFFER != a1 )
{
if ( EV_NET_RECEIVE != a1 )
return panic("%s: unknown event", "net_event_handler");
if ( net_debug_category )
_debug(
net_debug_category,
"msg a=\"receive\" net=\"%s\" msg=%lld node=\"%s\"\n",
*v2,
*(_QWORD *)(v3 + 8),
*(const char **)(v4 + 16));
++v2[38];
v2[39] += esim_cycle - *(_QWORD *)(v3 + 24);
v2[40] += *(int *)(v3 + 16);
if ( *(_DWORD *)(a2 + 16) == ESIM_EV_NONE )
net_receive(v2, v22, v3);
return func3(a2);
}
if ( net_debug_category )
_debug(
net_debug_category,
"msg a=\"ibuf\" net=\"%s\" msg=%lld node=\"%s\" buf=\"%s\"\n",
*v2,
*(_QWORD *)(v3 + 8),
*(const char **)(v22 + 16),
*(const char **)(v5 + 16));
if ( !(unsigned int)list_count(*(_QWORD *)(v5 + 64)) )
_assert_fail("list_count(buffer->msg_list)", "message.c", 0x114u, "net_event_handler");
if ( v3 != list_get(*(_QWORD *)(v5 + 64), 0LL) )
{
if ( net_debug_category )
_debug(net_debug_category, "msg a=\"stall\" net=\"%s\" msg=%lld why=\"not-head\"\n", *v2, *(_QWORD *)(v3 + 8));
return net_buffer_wait(v5, a1, a2);
}
if ( *(_QWORD *)(v3 + 48) == v22 )
return esim_schedule_event(EV_NET_RECEIVE, a2, 0LL);
if ( *(_QWORD *)(v5 + 40) >= esim_cycle )
{
if ( net_debug_category )
_debug(net_debug_category, "msg a=\"stall\" net=\"%s\" msg=%lld why=\"src-busy\"\n", *v2, *(_QWORD *)(v3 + 8));
return esim_schedule_event(a1, a2, (unsigned int)(*(_DWORD *)(v5 + 40) + 1 - esim_cycle));
}
v21 = *(_QWORD *)(net_routing_table_lookup(v20, v22, v4) + 16);
if ( !v21 )
fatal(
"%s: no route from %s to %s.\n%s",
*v2,
*(const char **)(v22 + 16),
*(const char **)(v4 + 16),
err_net_no_route);
if ( *(_QWORD *)(v21 + 48) >= esim_cycle )
{
if ( net_debug_category )
_debug(net_debug_category, "msg a=\"stall\" net=\"%s\" msg=%lld why=\"dst-busy\"\n", *v2, *(_QWORD *)(v3 + 8));
result = esim_schedule_event(a1, a2, (unsigned int)(*(_DWORD *)(v21 + 48) + 1 - esim_cycle));
}
else
{
if ( *(_DWORD *)(v3 + 16) > *(_DWORD *)(v21 + 28) )
fatal("%s: message does not fit in buffer.\n%s", *v2, err_net_large_message);
if ( *(_DWORD *)(v21 + 32) + *(_DWORD *)(v3 + 16) > *(_DWORD *)(v21 + 28) )
{
if ( net_debug_category )
_debug(
net_debug_category,
"msg a=\"stall\" net=\"%s\" msg=%lld why=\"dst-full\"\n",
*v2,
*(_QWORD *)(v3 + 8));
return net_buffer_wait(v21, a1, a2);
}
if ( v5 != net_node_schedule(v22, v21) )
{
if ( net_debug_category )
_debug(net_debug_category, "msg a=\"stall\" net=\"%s\" msg=%lld why=\"sched\"\n", *v2, *(_QWORD *)(v3 + 8));
return esim_schedule_event(a1, a2, 1LL);
}
if ( *(_DWORD *)(v22 + 8) == 1 )
_assert_fail("node->kind != net_node_end", "message.c", 0x16Cu, "net_event_handler");
v16 = *(_DWORD *)(v22 + 32);
if ( v16 <= 0 )
_assert_fail("node->bandwidth > 0", "message.c", 0x16Du, "net_event_handler");
v17 = (*(_DWORD *)(v3 + 16) - 1) / v16 + 1;
if ( v17 <= 0 )
_assert_fail("lat > 0", "message.c", 0x16Fu, "net_event_handler");
v18 = esim_cycle;
v19 = v17 + esim_cycle - 1LL;
*(_QWORD *)(v5 + 40) = v19;
*(_QWORD *)(v21 + 48) = v19;
if ( v18 <= *(_QWORD *)(v3 + 32) )
_assert_fail("msg->busy < esim_cycle", "message.c", 0x174u, "net_event_handler");
net_buffer_extract(v5, v3);
net_buffer_insert(v21, v3);
*(_QWORD *)(v3 + 72) = v21;
*(_QWORD *)(v3 + 32) = esim_cycle + v17 - 1LL;
result = esim_schedule_event(EV_NET_OUTPUT_BUFFER, a2, (unsigned int)v17);
}
}
}
return result;
}

original_code:
void net_event_handler(int event, void *data)
{
 struct net_stack_t *stack = data;
 struct net_t *net = stack->net;
 struct net_routing_table_t *routing_table = net->routing_table;
 struct net_msg_t *msg = stack->msg;
 struct net_node_t *src_node = msg->src_node;
 struct net_node_t *dst_node = msg->dst_node;
 struct net_node_t *node = msg->node;
 struct net_buffer_t *buffer = msg->buffer;
 if (event == EV_NET_SEND)
 {
  struct net_routing_table_entry_t *entry;
  struct net_buffer_t *output_buffer;
  ((net_debug_category) ? __debug((net_debug_category), "msg " "a=\"send\" " "net=\"%s\" " "msg=%lld " "size=%d " "src=\"%s\" " "dst=\"%s\"\n", net->name, msg->id, msg->size, src_node->name, dst_node->name) : (void) 0);
  entry = net_routing_table_lookup(routing_table, src_node, dst_node);
  output_buffer = entry->output_buffer;
  if (!output_buffer)
   fatal("%s: no route from %s to %s.\n%s", net->name, src_node->name,
    dst_node->name, err_net_no_route);
  if (output_buffer->write_busy >= esim_cycle)
   panic("%s: output buffer busy.\n%s", __FUNCTION__, err_net_can_send);
  if (msg->size > output_buffer->size)
   panic("%s: message does not fit in buffer.\n%s", __FUNCTION__, err_net_can_send);
  if (output_buffer->count + msg->size > output_buffer->size)
   panic("%s: output buffer full.\n%s", __FUNCTION__, err_net_can_send);
  net_buffer_insert(output_buffer, msg);
  output_buffer->write_busy = esim_cycle;
  msg->node = src_node;
  msg->buffer = output_buffer;
  msg->busy = esim_cycle;
  esim_schedule_event(EV_NET_OUTPUT_BUFFER, stack, 1);
 }
 else if (event == EV_NET_OUTPUT_BUFFER)
 {
  struct net_link_t *link;
  struct net_buffer_t *input_buffer;
  int lat;
  ((net_debug_category) ? __debug((net_debug_category), "msg " "a=\"obuf\" " "net=\"%s\" " "msg=%lld " "node=\"%s\" " "buf=\"%s\"\n", net->name, msg->id, node->name, buffer->name) : (void) 0);
  ((void) sizeof ((list_count(buffer->msg_list)) ? 1 : 0), __extension__ ({ if (list_count(buffer->msg_list)) ; else __assert_fail ("list_count(buffer->msg_list)", "message.c", 169, __extension__ __PRETTY_FUNCTION__); }));
  if (list_get(buffer->msg_list, 0) != msg)
  {
   net_buffer_wait(buffer, event, stack);
   return;
  }
  if (buffer->read_busy >= esim_cycle)
  {
   esim_schedule_event(event, stack, buffer->read_busy - esim_cycle + 1);
   return;
  }
  link = buffer->link;
  if (link->busy >= esim_cycle)
  {
   esim_schedule_event(event, stack, link->busy - esim_cycle + 1);
   return;
  }
  if (link->virtual_channel > 1)
  {
   struct net_buffer_t *temp_buffer;
   temp_buffer = net_link_arbitrator_vc(link, node);
   if (temp_buffer != buffer)
   {
    ((net_debug_category) ? __debug((net_debug_category), "msg " "a=\"arbitrator stall\" " "net=\"%s\" " "msg=%lld " "why=\"sched\"\n", net->name, msg->id) : (void) 0);
    esim_schedule_event(event, stack, 1);
    return;
   }
  }
  ((void) sizeof ((buffer == link->src_buffer) ? 1 : 0), __extension__ ({ if (buffer == link->src_buffer) ; else __assert_fail ("buffer == link->src_buffer", "message.c", 211, __extension__ __PRETTY_FUNCTION__); }));
  input_buffer = link->dst_buffer;
  if (input_buffer->write_busy >= esim_cycle)
  {
   esim_schedule_event(event, stack, input_buffer->write_busy - esim_cycle + 1);
   return;
  }
  if (msg->size > input_buffer->size)
   fatal("%s: message does not fit in buffer.\n%s",
    net->name, err_net_large_message);
  if (input_buffer->count + msg->size > input_buffer->size)
  {
   net_buffer_wait(input_buffer, event, stack);
   return;
  }
  lat = (msg->size - 1) / link->bandwidth + 1;
  ((void) sizeof ((lat > 0) ? 1 : 0), __extension__ ({ if (lat > 0) ; else __assert_fail ("lat > 0", "message.c", 231, __extension__ __PRETTY_FUNCTION__); }));
  buffer->read_busy = esim_cycle + lat - 1;
  link->busy = esim_cycle + lat - 1;
  input_buffer->write_busy = esim_cycle + lat - 1;
  ((void) sizeof ((msg->busy < esim_cycle) ? 1 : 0), __extension__ ({ if (msg->busy < esim_cycle) ; else __assert_fail ("msg->busy < esim_cycle", "message.c", 237, __extension__ __PRETTY_FUNCTION__); }));
  net_buffer_extract(buffer, msg);
  net_buffer_insert(input_buffer, msg);
  msg->node = input_buffer->node;
  msg->buffer = input_buffer;
  msg->busy = esim_cycle + lat - 1;
  link->busy_cycles += lat;
  link->transferred_bytes += msg->size;
  link->transferred_msgs++;
  node->bytes_sent += msg->size;
  node->msgs_sent++;
  input_buffer->node->bytes_received += msg->size;
  input_buffer->node->msgs_received++;
  esim_schedule_event(EV_NET_INPUT_BUFFER, stack, lat);
 }
 else if (event == EV_NET_INPUT_BUFFER)
 {
  struct net_routing_table_entry_t *entry;
  struct net_buffer_t *output_buffer;
  int lat;
  ((net_debug_category) ? __debug((net_debug_category), "msg " "a=\"ibuf\" " "net=\"%s\" " "msg=%lld " "node=\"%s\" " "buf=\"%s\"\n", net->name, msg->id, node->name, buffer->name) : (void) 0);
  ((void) sizeof ((list_count(buffer->msg_list)) ? 1 : 0), __extension__ ({ if (list_count(buffer->msg_list)) ; else __assert_fail ("list_count(buffer->msg_list)", "message.c", 276, __extension__ __PRETTY_FUNCTION__); }));
  if (list_get(buffer->msg_list, 0) != msg)
  {
   ((net_debug_category) ? __debug((net_debug_category), "msg " "a=\"stall\" " "net=\"%s\" " "msg=%lld " "why=\"not-head\"\n", net->name, msg->id) : (void) 0);
   net_buffer_wait(buffer, event, stack);
   return;
  }
  if (node == msg->dst_node)
  {
   esim_schedule_event(EV_NET_RECEIVE, stack, 0);
   return;
  }
  if (buffer->read_busy >= esim_cycle)
  {
   ((net_debug_category) ? __debug((net_debug_category), "msg " "a=\"stall\" " "net=\"%s\" " "msg=%lld " "why=\"src-busy\"\n", net->name, msg->id) : (void) 0);
   esim_schedule_event(event, stack, buffer->read_busy - esim_cycle + 1);
   return;
  }
  entry = net_routing_table_lookup(routing_table, node, dst_node);
  output_buffer = entry->output_buffer;
  if (!output_buffer)
   fatal("%s: no route from %s to %s.\n%s", net->name,
    node->name, dst_node->name, err_net_no_route);
  if (output_buffer->write_busy >= esim_cycle)
  {
   ((net_debug_category) ? __debug((net_debug_category), "msg " "a=\"stall\" " "net=\"%s\" " "msg=%lld " "why=\"dst-busy\"\n", net->name, msg->id) : (void) 0);
   esim_schedule_event(event, stack, output_buffer->write_busy - esim_cycle + 1);
   return;
  }
  if (msg->size > output_buffer->size)
   fatal("%s: message does not fit in buffer.\n%s",
    net->name, err_net_large_message);
  if (output_buffer->count + msg->size > output_buffer->size)
  {
   ((net_debug_category) ? __debug((net_debug_category), "msg " "a=\"stall\" " "net=\"%s\" " "msg=%lld " "why=\"dst-full\"\n", net->name, msg->id) : (void) 0);
   net_buffer_wait(output_buffer, event, stack);
   return;
  }
  if (net_node_schedule(node, output_buffer) != buffer)
  {
   ((net_debug_category) ? __debug((net_debug_category), "msg " "a=\"stall\" " "net=\"%s\" " "msg=%lld " "why=\"sched\"\n", net->name, msg->id) : (void) 0);
   esim_schedule_event(event, stack, 1);
   return;
  }
  ((void) sizeof ((node->kind != net_node_end) ? 1 : 0), __extension__ ({ if (node->kind != net_node_end) ; else __assert_fail ("node->kind != net_node_end", "message.c", 364, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((node->bandwidth > 0) ? 1 : 0), __extension__ ({ if (node->bandwidth > 0) ; else __assert_fail ("node->bandwidth > 0", "message.c", 365, __extension__ __PRETTY_FUNCTION__); }));
  lat = (msg->size - 1) / node->bandwidth + 1;
  ((void) sizeof ((lat > 0) ? 1 : 0), __extension__ ({ if (lat > 0) ; else __assert_fail ("lat > 0", "message.c", 367, __extension__ __PRETTY_FUNCTION__); }));
  buffer->read_busy = esim_cycle + lat - 1;
  output_buffer->write_busy = esim_cycle + lat - 1;
  ((void) sizeof ((msg->busy < esim_cycle) ? 1 : 0), __extension__ ({ if (msg->busy < esim_cycle) ; else __assert_fail ("msg->busy < esim_cycle", "message.c", 372, __extension__ __PRETTY_FUNCTION__); }));
  net_buffer_extract(buffer, msg);
  net_buffer_insert(output_buffer, msg);
  msg->buffer = output_buffer;
  msg->busy = esim_cycle + lat - 1;
  esim_schedule_event(EV_NET_OUTPUT_BUFFER, stack, lat);
 }
 else if (event == EV_NET_RECEIVE)
 {
  ((net_debug_category) ? __debug((net_debug_category), "msg " "a=\"receive\" " "net=\"%s\" " "msg=%lld " "node=\"%s\"\n", net->name, msg->id, dst_node->name) : (void) 0);
  net->transfers++;
  net->lat_acc += esim_cycle - msg->send_cycle;
  net->msg_size_acc += msg->size;
  if (stack->ret_event == ESIM_EV_NONE)
   net_receive(net, node, msg);
  net_stack_return(stack);
 }
 else
 {
  panic("%s: unknown event", __FUNCTION__);
 }
}

variable_types: event int

variable_types:
data
void *

variable_types: struct net_t { char *name; long long msg_id_counter; struct list_t { int count; int error_code; int size; int head; int tail; void **elem; } *node_list; int node_count; int end_node_count; struct list_t *link_list; struct net_routing_table_t { struct net_t *net; int dim; struct net_routing_table_entry_t { int cost; struct net_node_t { struct net_t *net; enum net_node_kind_t { net_node_invalid=0, net_node_end=1, net_node_switch=2, net_node_bus=3 } kind; int index; char *name; void *user_data; int bandwidth; long long bus_busy; int input_buffer_size; int output_buffer_size; struct list_t *input_buffer_list; struct list_t *output_buffer_list; long long bytes_received; long long msgs_received; long long bytes_sent; long long msgs_sent; } *next_node; struct net_buffer_t { struct net_t *net; struct net_node_t *node; char *name; int index; int size; int count; long long read_busy; long long write_busy; struct net_link_t { struct net_t *net; char *name; struct net_node_t *src_node; struct net_node_t *dst_node; struct net_buffer_t *dst_buffer; struct net_buffer_t *src_buffer; int bandwidth; long long busy; int virtual_channel; long long sched_when; struct net_buffer_t *sched_buffer; long long busy_cycles; long long transferred_bytes; long long transferred_msgs; } *link; struct list_t *msg_list; long long sched_when; struct net_buffer_t *sched_buffer; struct linked_list_t { int count; int error_code; struct linked_list_elem_t { struct linked_list_elem_t *prev; struct linked_list_elem_t *next; void *data; } *head; int current_index; } *wakeup_list; int occupancy_bytes_value; int occupancy_msgs_value; long long occupancy_measured_cycle; long long occupancy_bytes_acc; long long occupancy_msgs_acc; } *output_buffer; } *entries; int has_cycle; } *routing_table; struct net_msg_t { struct net_t *net; long long id; int size; long long send_cycle; long long busy; struct net_node_t *src_node; struct net_node_t *dst_node; void *data; struct net_node_t *node; struct net_buffer_t *buffer; struct net_buffer_t *src_buffer; struct net_buffer_t *dst_buffer; struct net_msg_t *bucket_next; } *msg_table[32]; long long transfers; long long lat_acc; long long msg_size_acc; } *

variable_types: struct net_routing_table_t { struct net_t { char *name; long long msg_id_counter; struct list_t { int count; int error_code; int size; int head; int tail; void **elem; } *node_list; int node_count; int end_node_count; struct list_t *link_list; struct net_routing_table_t *routing_table; struct net_msg_t { struct net_t *net; long long id; int size; long long send_cycle; long long busy; struct net_node_t { struct net_t *net; enum net_node_kind_t { net_node_invalid=0, net_node_end=1, net_node_switch=2, net_node_bus=3 } kind; int index; char *name; void *user_data; int bandwidth; long long bus_busy; int input_buffer_size; int output_buffer_size; struct list_t *input_buffer_list; struct list_t *output_buffer_list; long long bytes_received; long long msgs_received; long long bytes_sent; long long msgs_sent; } *src_node; struct net_node_t *dst_node; void *data; struct net_node_t *node; struct net_buffer_t { struct net_t *net; struct net_node_t *node; char *name; int index; int size; int count; long long read_busy; long long write_busy; struct net_link_t { struct net_t *net; char *name; struct net_node_t *src_node; struct net_node_t *dst_node; struct net_buffer_t *dst_buffer; struct net_buffer_t *src_buffer; int bandwidth; long long busy; int virtual_channel; long long sched_when; struct net_buffer_t *sched_buffer; long long busy_cycles; long long transferred_bytes; long long transferred_msgs; } *link; struct list_t *msg_list; long long sched_when; struct net_buffer_t *sched_buffer; struct linked_list_t { int count; int error_code; struct linked_list_elem_t { struct linked_list_elem_t *prev; struct linked_list_elem_t *next; void *data; } *head; int current_index; } *wakeup_list; int occupancy_bytes_value; int occupancy_msgs_value; long long occupancy_measured_cycle; long long occupancy_bytes_acc; long long occupancy_msgs_acc; } *buffer; struct net_buffer_t *src_buffer; struct net_buffer_t *dst_buffer; struct net_msg_t *bucket_next; } *msg_table[32]; long long transfers; long long lat_acc; long long msg_size_acc; } *net; int dim; struct net_routing_table_entry_t { int cost; struct net_node_t *next_node; struct net_buffer_t *output_buffer; } *entries; int has_cycle; } *

variable_types: struct net_msg_t { struct net_t { char *name; long long msg_id_counter; struct list_t { int count; int error_code; int size; int head; int tail; void **elem; } *node_list; int node_count; int end_node_count; struct list_t *link_list; struct net_routing_table_t { struct net_t *net; int dim; struct net_routing_table_entry_t { int cost; struct net_node_t { struct net_t *net; enum net_node_kind_t { net_node_invalid=0, net_node_end=1, net_node_switch=2, net_node_bus=3 } kind; int index; char *name; void *user_data; int bandwidth; long long bus_busy; int input_buffer_size; int output_buffer_size; struct list_t *input_buffer_list; struct list_t *output_buffer_list; long long bytes_received; long long msgs_received; long long bytes_sent; long long msgs_sent; } *next_node; struct net_buffer_t { struct net_t *net; struct net_node_t *node; char *name; int index; int size; int count; long long read_busy; long long write_busy; struct net_link_t { struct net_t *net; char *name; struct net_node_t *src_node; struct net_node_t *dst_node; struct net_buffer_t *dst_buffer; struct net_buffer_t *src_buffer; int bandwidth; long long busy; int virtual_channel; long long sched_when; struct net_buffer_t *sched_buffer; long long busy_cycles; long long transferred_bytes; long long transferred_msgs; } *link; struct list_t *msg_list; long long sched_when; struct net_buffer_t *sched_buffer; struct linked_list_t { int count; int error_code; struct linked_list_elem_t { struct linked_list_elem_t *prev; struct linked_list_elem_t *next; void *data; } *head; int current_index; } *wakeup_list; int occupancy_bytes_value; int occupancy_msgs_value; long long occupancy_measured_cycle; long long occupancy_bytes_acc; long long occupancy_msgs_acc; } *output_buffer; } *entries; int has_cycle; } *routing_table; struct net_msg_t *msg_table[32]; long long transfers; long long lat_acc; long long msg_size_acc; } *net; long long id; int size; long long send_cycle; long long busy; struct net_node_t *src_node; struct net_node_t *dst_node; void *data; struct net_node_t *node; struct net_buffer_t *buffer; struct net_buffer_t *src_buffer; struct net_buffer_t *dst_buffer; struct net_msg_t *bucket_next; } *

variable_types: struct net_node_t { struct net_t { char *name; long long msg_id_counter; struct list_t { int count; int error_code; int size; int head; int tail; void **elem; } *node_list; int node_count; int end_node_count; struct list_t *link_list; struct net_routing_table_t { struct net_t *net; int dim; struct net_routing_table_entry_t { int cost; struct net_node_t *next_node; struct net_buffer_t { struct net_t *net; struct net_node_t *node; char *name; int index; int size; int count; long long read_busy; long long write_busy; struct net_link_t { struct net_t *net; char *name; struct net_node_t *src_node; struct net_node_t *dst_node; struct net_buffer_t *dst_buffer; struct net_buffer_t *src_buffer; int bandwidth; long long busy; int virtual_channel; long long sched_when; struct net_buffer_t *sched_buffer; long long busy_cycles; long long transferred_bytes; long long transferred_msgs; } *link; struct list_t *msg_list; long long sched_when; struct net_buffer_t *sched_buffer; struct linked_list_t { int count; int error_code; struct linked_list_elem_t { struct linked_list_elem_t *prev; struct linked_list_elem_t *next; void *data; } *head; int current_index; } *wakeup_list; int occupancy_bytes_value; int occupancy_msgs_value; long long occupancy_measured_cycle; long long occupancy_bytes_acc; long long occupancy_msgs_acc; } *output_buffer; } *entries; int has_cycle; } *routing_table; struct net_msg_t { struct net_t *net; long long id; int size; long long send_cycle; long long busy; struct net_node_t *src_node; struct net_node_t *dst_node; void *data; struct net_node_t *node; struct net_buffer_t *buffer; struct net_buffer_t *src_buffer; struct net_buffer_t *dst_buffer; struct net_msg_t *bucket_next; } *msg_table[32]; long long transfers; long long lat_acc; long long msg_size_acc; } *net; enum net_node_kind_t { net_node_invalid=0, net_node_end=1, net_node_switch=2, net_node_bus=3 } kind; int index; char *name; void *user_data; int bandwidth; long long bus_busy; int input_buffer_size; int output_buffer_size; struct list_t *input_buffer_list; struct list_t *output_buffer_list; long long bytes_received; long long msgs_received; long long bytes_sent; long long msgs_sent; } *

variable_types: struct net_buffer_t { struct net_t { char *name; long long msg_id_counter; struct list_t { int count; int error_code; int size; int head; int tail; void **elem; } *node_list; int node_count; int end_node_count; struct list_t *link_list; struct net_routing_table_t { struct net_t *net; int dim; struct net_routing_table_entry_t { int cost; struct net_node_t { struct net_t *net; enum net_node_kind_t { net_node_invalid=0, net_node_end=1, net_node_switch=2, net_node_bus=3 } kind; int index; char *name; void *user_data; int bandwidth; long long bus_busy; int input_buffer_size; int output_buffer_size; struct list_t *input_buffer_list; struct list_t *output_buffer_list; long long bytes_received; long long msgs_received; long long bytes_sent; long long msgs_sent; } *next_node; struct net_buffer_t *output_buffer; } *entries; int has_cycle; } *routing_table; struct net_msg_t { struct net_t *net; long long id; int size; long long send_cycle; long long busy; struct net_node_t *src_node; struct net_node_t *dst_node; void *data; struct net_node_t *node; struct net_buffer_t *buffer; struct net_buffer_t *src_buffer; struct net_buffer_t *dst_buffer; struct net_msg_t *bucket_next; } *msg_table[32]; long long transfers; long long lat_acc; long long msg_size_acc; } *net; struct net_node_t *node; char *name; int index; int size; int count; long long read_busy; long long write_busy; struct net_link_t { struct net_t *net; char *name; struct net_node_t *src_node; struct net_node_t *dst_node; struct net_buffer_t *dst_buffer; struct net_buffer_t *src_buffer; int bandwidth; long long busy; int virtual_channel; long long sched_when; struct net_buffer_t *sched_buffer; long long busy_cycles; long long transferred_bytes; long long transferred_msgs; } *link; struct list_t *msg_list; long long sched_when; struct net_buffer_t *sched_buffer; struct linked_list_t { int count; int error_code; struct linked_list_elem_t { struct linked_list_elem_t *prev; struct linked_list_elem_t *next; void *data; } *head; int current_index; } *wakeup_list; int occupancy_bytes_value; int occupancy_msgs_value; long long occupancy_measured_cycle; long long occupancy_bytes_acc; long long occupancy_msgs_acc; } *

variable_types: struct net_routing_table_entry_t { int cost; struct net_node_t { struct net_t { char *name; long long msg_id_counter; struct list_t { int count; int error_code; int size; int head; int tail; void **elem; } *node_list; int node_count; int end_node_count; struct list_t *link_list; struct net_routing_table_t { struct net_t *net; int dim; struct net_routing_table_entry_t *entries; int has_cycle; } *routing_table; struct net_msg_t { struct net_t *net; long long id; int size; long long send_cycle; long long busy; struct net_node_t *src_node; struct net_node_t *dst_node; void *data; struct net_node_t *node; struct net_buffer_t { struct net_t *net; struct net_node_t *node; char *name; int index; int size; int count; long long read_busy; long long write_busy; struct net_link_t { struct net_t *net; char *name; struct net_node_t *src_node; struct net_node_t *dst_node; struct net_buffer_t *dst_buffer; struct net_buffer_t *src_buffer; int bandwidth; long long busy; int virtual_channel; long long sched_when; struct net_buffer_t *sched_buffer; long long busy_cycles; long long transferred_bytes; long long transferred_msgs; } *link; struct list_t *msg_list; long long sched_when; struct net_buffer_t *sched_buffer; struct linked_list_t { int count; int error_code; struct linked_list_elem_t { struct linked_list_elem_t *prev; struct linked_list_elem_t *next; void *data; } *head; int current_index; } *wakeup_list; int occupancy_bytes_value; int occupancy_msgs_value; long long occupancy_measured_cycle; long long occupancy_bytes_acc; long long occupancy_msgs_acc; } *buffer; struct net_buffer_t *src_buffer; struct net_buffer_t *dst_buffer; struct net_msg_t *bucket_next; } *msg_table[32]; long long transfers; long long lat_acc; long long msg_size_acc; } *net; enum net_node_kind_t { net_node_invalid=0, net_node_end=1, net_node_switch=2, net_node_bus=3 } kind; int index; char *name; void *user_data; int bandwidth; long long bus_busy; int input_buffer_size; int output_buffer_size; struct list_t *input_buffer_list; struct list_t *output_buffer_list; long long bytes_received; long long msgs_received; long long bytes_sent; long long msgs_sent; } *next_node; struct net_buffer_t *output_buffer; } *

variable_types: struct net_link_t { struct net_t { char *name; long long msg_id_counter; struct list_t { int count; int error_code; int size; int head; int tail; void **elem; } *node_list; int node_count; int end_node_count; struct list_t *link_list; struct net_routing_table_t { struct net_t *net; int dim; struct net_routing_table_entry_t { int cost; struct net_node_t { struct net_t *net; enum net_node_kind_t { net_node_invalid=0, net_node_end=1, net_node_switch=2, net_node_bus=3 } kind; int index; char *name; void *user_data; int bandwidth; long long bus_busy; int input_buffer_size; int output_buffer_size; struct list_t *input_buffer_list; struct list_t *output_buffer_list; long long bytes_received; long long msgs_received; long long bytes_sent; long long msgs_sent; } *next_node; struct net_buffer_t { struct net_t *net; struct net_node_t *node; char *name; int index; int size; int count; long long read_busy; long long write_busy; struct net_link_t *link; struct list_t *msg_list; long long sched_when; struct net_buffer_t *sched_buffer; struct linked_list_t { int count; int error_code; struct linked_list_elem_t { struct linked_list_elem_t *prev; struct linked_list_elem_t *next; void *data; } *head; int current_index; } *wakeup_list; int occupancy_bytes_value; int occupancy_msgs_value; long long occupancy_measured_cycle; long long occupancy_bytes_acc; long long occupancy_msgs_acc; } *output_buffer; } *entries; int has_cycle; } *routing_table; struct net_msg_t { struct net_t *net; long long id; int size; long long send_cycle; long long busy; struct net_node_t *src_node; struct net_node_t *dst_node; void *data; struct net_node_t *node; struct net_buffer_t *buffer; struct net_buffer_t *src_buffer; struct net_buffer_t *dst_buffer; struct net_msg_t *bucket_next; } *msg_table[32]; long long transfers; long long lat_acc; long long msg_size_acc; } *net; char *name; struct net_node_t *src_node; struct net_node_t *dst_node; struct net_buffer_t *dst_buffer; struct net_buffer_t *src_buffer; int bandwidth; long long busy; int virtual_channel; long long sched_when; struct net_buffer_t *sched_buffer; long long busy_cycles; long long transferred_bytes; long long transferred_msgs; } *

variable_types: lat int


decompiled_code:
void __fastcall trace_init(const char *a1)
{
__int64 v1; // rbx

if ( a1 && *a1 )
{
trace_file = gzopen(a1, &unk_360);
if ( !trace_file )
fatal("%s: cannot open trace file", a1);
trace_category_list = list_create();
v1 = mhandle_calloc(1LL, 4LL, "trace.c:67");
if ( !v1 )
fatal("%s: out of memory", "trace_init");
list_add(trace_category_list, v1);
}
}

canonical_decompiled_code:
void __fastcall func0(const char *a1)
{
__int64 v1; // rbx

if ( a1 && *a1 )
{
trace_file = gzopen(a1, &unk_360);
if ( !trace_file )
fatal("%s: cannot open trace file", a1);
trace_category_list = list_create();
v1 = mhandle_calloc(1LL, 4LL, "trace.c:67");
if ( !v1 )
fatal("%s: out of memory", "trace_init");
list_add(trace_category_list, v1);
}
}

original_code:
void trace_init(char *file_name)
{
 struct trace_category_t *c;
 if (!file_name || !*file_name)
  return;
 trace_file = gzopen(file_name, "wt");
 if (!trace_file)
  fatal("%s: cannot open trace file", file_name);
 trace_category_list = list_create();
 c = (mhandle_calloc(1, sizeof(struct trace_category_t), "trace.c" ":" "67"));
 if (!c)
  fatal("%s: out of memory", __FUNCTION__);
 list_add(trace_category_list, c);
}

variable_types: struct trace_category_t { enum trace_status_t { trace_status_invalid=0, trace_status_on=1, trace_status_off=2 } status; } *

user_defined_types: struct trace_category_t { enum trace_status_t status; }


decompiled_code:
void trace_done()
{
__int64 i; // rdi
__int64 v1; // rax

if ( trace_file )
{
gzclose();
for ( i = trace_category_list; *(_DWORD *)trace_category_list; i = trace_category_list )
{
v1 = list_remove_at(i, 0LL);
mhandle_free(v1, "trace.c:85");
}
list_free();
}
}

canonical_decompiled_code:
void func1()
{
__int64 i; // rdi
__int64 v1; // rax

if ( trace_file )
{
gzclose();
for ( i = trace_category_list; *(_DWORD *)trace_category_list; i = trace_category_list )
{
v1 = list_remove_at(i, 0LL);
mhandle_free(v1, "trace.c:85");
}
list_free();
}
}

original_code:
void trace_done(void)
{
 if (!trace_file)
  return;
 gzclose(trace_file);
 while (trace_category_list->count)
  (mhandle_free(list_remove_at(trace_category_list, 0), "trace.c" ":" "85"));
 list_free(trace_category_list);
}

canonical_original_code:
void trace_done()
{
 if (!trace_file)
  return;
 gzclose(trace_file);
 while (trace_category_list->count)
  (mhandle_free(list_remove_at(trace_category_list, 0), "trace.c" ":" "85"));
 list_free(trace_category_list);
}


decompiled_code:
__int64 trace_new_category()
{
__int64 result; // rax
_DWORD *v1; // rbx

result = 0LL;
if ( trace_file )
{
v1 = (_DWORD *)mhandle_calloc(1LL, 4LL, "trace.c:100");
if ( !v1 )
fatal("%s: out of memory", "trace_new_category");
*v1 = 1;
list_add(trace_category_list, v1);
result = (unsigned int)list_count(trace_category_list) - 1;
}
return result;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 result; // rax
_DWORD *v1; // rbx

result = 0LL;
if ( trace_file )
{
v1 = (_DWORD *)mhandle_calloc(1LL, 4LL, "trace.c:100");
if ( !v1 )
fatal("%s: out of memory", "trace_new_category");
*v1 = 1;
list_add(trace_category_list, v1);
result = (unsigned int)list_count(trace_category_list) - 1;
}
return result;
}

original_code:
int trace_new_category(void)
{
 struct trace_category_t *c;
 if (!trace_file)
  return 0;
 c = (mhandle_calloc(1, sizeof(struct trace_category_t), "trace.c" ":" "100"));
 if (!c)
  fatal("%s: out of memory", __FUNCTION__);
 c->status = trace_status_on;
 list_add(trace_category_list, c);
 return list_count(trace_category_list) - 1;
}

canonical_original_code:
int trace_new_category()
{
 struct trace_category_t *c;
 if (!trace_file)
  return 0;
 c = (mhandle_calloc(1, sizeof(struct trace_category_t), "trace.c" ":" "100"));
 if (!c)
  fatal("%s: out of memory", __FUNCTION__);
 c->status = trace_status_on;
 list_add(trace_category_list, c);
 return list_count(trace_category_list) - 1;
}

return_type: int

user_defined_types: enum trace_status_t { trace_status_invalid=0, trace_status_on=1, trace_status_off=2 }


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

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

original_code:
int arm_cpu_run(void)
{
 return 0;
}

canonical_original_code:
int arm_cpu_run()
{
 return 0;
}


decompiled_code:
__int64 arm_regs_create()
{
__int64 v0; // rbx

v0 = mhandle_calloc(1LL, 404LL, "regs.c:26");
if ( !v0 )
fatal("%s: out of memory", "arm_regs_create");
*(_BYTE *)(v0 + 64) = *(_BYTE *)(v0 + 64) & 0xE0 | 0x10;
return v0;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v0; // rbx

v0 = mhandle_calloc(1LL, 404LL, "regs.c:26");
if ( !v0 )
fatal("%s: out of memory", "arm_regs_create");
*(_BYTE *)(v0 + 64) = *(_BYTE *)(v0 + 64) & 0xE0 | 0x10;
return v0;
}

original_code:
struct arm_regs_t *arm_regs_create()
{
 struct arm_regs_t *regs;
 regs = (mhandle_calloc(1, sizeof(struct arm_regs_t), "regs.c" ":" "26"));
 if(!regs)
  fatal("%s: out of memory", __FUNCTION__);
 regs->cpsr.mode = 0x10;
 return regs;
}

variable_types: struct arm_regs_t { unsigned int r0; unsigned int r4; unsigned int sl; struct arm_cpsr_reg_t { unsigned int mode; unsigned int thumb; unsigned int fiq; unsigned int irq; unsigned int _reserved0; unsigned int jaz; unsigned int _reserved1; unsigned int q; unsigned int v; unsigned int C; unsigned int z; unsigned int n; } cpsr; struct arm_cpsr_reg_t spsr; struct arm_coproc_regs_t { unsigned int c0_cpuid; unsigned int c0_cachetype; unsigned int c0_ccsid[16]; unsigned int c0_clid; unsigned int c0_cssel; unsigned int c0_c1[8]; unsigned int c0_c2[8]; unsigned int c1_sys; unsigned int c1_coproc; unsigned int c1_xscaleauxcr; unsigned int c1_scr; unsigned int c2_base0; unsigned int c2_base1; unsigned int c2_control; unsigned int c2_mask; unsigned int c2_base_mask; unsigned int c2_data; unsigned int c2_insn; unsigned int c3; unsigned int c5_insn; unsigned int c5_data; unsigned int c6_region[8]; unsigned int c6_insn; unsigned int c6_data; unsigned int c7_par; unsigned int c9_insn; unsigned int c9_data; unsigned int c9_pmcr; unsigned int c9_pmcnten; unsigned int c9_pmovsr; unsigned int c9_pmxevtyper; unsigned int c9_pmuserenr; unsigned int c9_pminten; unsigned int c13_fcse; unsigned int c13_context; unsigned int c13_tls1; unsigned int c13_tls2; unsigned int c13_tls3; unsigned int c15_cpar; unsigned int c15_ticonfig; unsigned int c15_i_max; unsigned int c15_i_min; unsigned int c15_threadid; unsigned int c15_config_base_address; unsigned int c15_diagnostic; unsigned int c15_power_diagnostic; unsigned int c15_power_control; } cp15; } *

user_defined_types: struct arm_regs_t { unsigned int r0; unsigned int r4; unsigned int sl; struct arm_cpsr_reg_t cpsr; struct arm_cpsr_reg_t spsr; struct arm_coproc_regs_t cp15; }


decompiled_code:
__int64 __fastcall arm_regs_free(__int64 a1)
{
return mhandle_free(a1, "regs.c:37");
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
return mhandle_free(a1, "regs.c:37");
}

original_code:
void arm_regs_free(struct arm_regs_t *regs)
{
 (mhandle_free(regs, "regs.c" ":" "37"));
}

user_defined_types: struct arm_cpsr_reg_t { unsigned int mode; unsigned int thumb; unsigned int fiq; unsigned int irq; unsigned int _reserved0; unsigned int jaz; unsigned int _reserved1; unsigned int q; unsigned int v; unsigned int C; unsigned int z; unsigned int n; }

user_defined_types: struct arm_coproc_regs_t { unsigned int c0_cpuid; unsigned int c0_cachetype; unsigned int c0_ccsid[16]; unsigned int c0_clid; unsigned int c0_cssel; unsigned int c0_c1[8]; unsigned int c0_c2[8]; unsigned int c1_sys; unsigned int c1_coproc; unsigned int c1_xscaleauxcr; unsigned int c1_scr; unsigned int c2_base0; unsigned int c2_base1; unsigned int c2_control; unsigned int c2_mask; unsigned int c2_base_mask; unsigned int c2_data; unsigned int c2_insn; unsigned int c3; unsigned int c5_insn; unsigned int c5_data; unsigned int c6_region[8]; unsigned int c6_insn; unsigned int c6_data; unsigned int c7_par; unsigned int c9_insn; unsigned int c9_data; unsigned int c9_pmcr; unsigned int c9_pmcnten; unsigned int c9_pmovsr; unsigned int c9_pmxevtyper; unsigned int c9_pmuserenr; unsigned int c9_pminten; unsigned int c13_fcse; unsigned int c13_context; unsigned int c13_tls1; unsigned int c13_tls2; unsigned int c13_tls3; unsigned int c15_cpar; unsigned int c15_ticonfig; unsigned int c15_i_max; unsigned int c15_i_min; unsigned int c15_threadid; unsigned int c15_config_base_address; unsigned int c15_diagnostic; unsigned int c15_power_diagnostic; unsigned int c15_power_control; }


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

*a1 = *a2;
result = *(_QWORD *)((char *)a2 + 396);
*(_QWORD *)((char *)a1 + 396) = result;
qmemcpy(
(void *)((unsigned __int64)(a1 + 1) & 0xFFFFFFFFFFFFFFF8LL),
(const void *)((char *)a2 - ((char *)a1 - ((unsigned __int64)(a1 + 1) & 0xFFFFFFFFFFFFFFF8LL))),
8LL * (((unsigned int)a1 - (((_DWORD)a1 + 8) & 0xFFFFFFF8) + 404) >> 3));
return result;
}

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

*a1 = *a2;
result = *(_QWORD *)((char *)a2 + 396);
*(_QWORD *)((char *)a1 + 396) = result;
qmemcpy(
(void *)((unsigned __int64)(a1 + 1) & 0xFFFFFFFFFFFFFFF8LL),
(const void *)((char *)a2 - ((char *)a1 - ((unsigned __int64)(a1 + 1) & 0xFFFFFFFFFFFFFFF8LL))),
8LL * (((unsigned int)a1 - (((_DWORD)a1 + 8) & 0xFFFFFFF8) + 404) >> 3));
return result;
}

original_code:
void arm_regs_copy(struct arm_regs_t *dst, struct arm_regs_t *src)
{
 memcpy(dst, src, sizeof(struct arm_regs_t));
}

variable_types:
src
struct arm_regs_t *


decompiled_code:
_DWORD *si_opencl_context_create()
{
_DWORD *v0; // rbx

v0 = (_DWORD *)mhandle_calloc(1LL, 16LL, "opencl-context.c:35");
if ( !v0 )
fatal("%s: out of memory", "si_opencl_context_create");
*v0 = si_opencl_repo_new_object_id(*(_QWORD *)(si_emu + 8LL), 3LL);
v0[1] = 1;
si_opencl_repo_add_object(*(_QWORD *)(si_emu + 8LL), v0);
return v0;
}

canonical_decompiled_code:
_DWORD *func0()
{
_DWORD *v0; // rbx

v0 = (_DWORD *)mhandle_calloc(1LL, 16LL, "opencl-context.c:35");
if ( !v0 )
fatal("%s: out of memory", "si_opencl_context_create");
*v0 = si_opencl_repo_new_object_id(*(_QWORD *)(si_emu + 8LL), 3LL);
v0[1] = 1;
si_opencl_repo_add_object(*(_QWORD *)(si_emu + 8LL), v0);
return v0;
}

original_code:
struct si_opencl_context_t *si_opencl_context_create()
{
 struct si_opencl_context_t *context;
 context = (mhandle_calloc(1, sizeof(struct si_opencl_context_t), "opencl-context.c" ":" "35"));
 if (!context)
  fatal("%s: out of memory", __FUNCTION__);
 context->id = si_opencl_repo_new_object_id(si_emu->opencl_repo,
  si_opencl_object_context);
 context->ref_count = 1;
 si_opencl_repo_add_object(si_emu->opencl_repo, context);
 return context;
}

variable_types: struct si_opencl_context_t { unsigned int id; int ref_count; unsigned int platform_id; unsigned int device_id; } *


decompiled_code:
__int64 __fastcall si_opencl_context_free(__int64 a1)
{
si_opencl_repo_remove_object(*(_QWORD *)(si_emu + 8LL), a1);
return mhandle_free(a1, "opencl-context.c:54");
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
si_opencl_repo_remove_object(*(_QWORD *)(si_emu + 8LL), a1);
return mhandle_free(a1, "opencl-context.c:54");
}

original_code:
void si_opencl_context_free(struct si_opencl_context_t *context)
{
 si_opencl_repo_remove_object(si_emu->opencl_repo, context);
 (mhandle_free(context, "opencl-context.c" ":" "54"));
}

user_defined_types: struct si_opencl_context_t { unsigned int id; int ref_count; unsigned int platform_id; unsigned int device_id; }


decompiled_code:
__int64 __fastcall si_opencl_context_get_info(__int64 a1, __int64 a2, __int64 a3, unsigned int a4, unsigned int a5)
{
int *v6; // rcx
int v8; // [rsp+Ch] [rbp-Ch] BYREF

v8 = 1;
if ( (_DWORD)a2 == 4225 )
{
v6 = (int *)(a1 + 12);
}
else
{
if ( (_DWORD)a2 != 4227 )
{
fatal(
"opencl_context_get_info: invalid or not implemented value for 'name' (0x%x)\n%s",
a2,
si_err_opencl_param_note);
_assert_fail("info", "opencl-context.c", 0x56u, "si_opencl_context_get_info");
}
v6 = &v8;
}
if ( a4 && a5 > 3 )
mem_write(a3, a4, 4LL, v6);
return 4LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2, __int64 a3, unsigned int a4, unsigned int a5)
{
int *v6; // rcx
int v8; // [rsp+Ch] [rbp-Ch] BYREF

v8 = 1;
if ( (_DWORD)a2 == 4225 )
{
v6 = (int *)(a1 + 12);
}
else
{
if ( (_DWORD)a2 != 4227 )
{
fatal(
"opencl_context_get_info: invalid or not implemented value for 'name' (0x%x)\n%s",
a2,
si_err_opencl_param_note);
_assert_fail("info", "opencl-context.c", 0x56u, "si_opencl_context_get_info");
}
v6 = &v8;
}
if ( a4 && a5 > 3 )
mem_write(a3, a4, 4LL, v6);
return 4LL;
}

original_code:
uint32_t si_opencl_context_get_info(struct si_opencl_context_t *context, uint32_t name, struct mem_t *mem, uint32_t addr, uint32_t size)
{
 uint32_t num_devices = 1;
 uint32_t size_ret = 0;
 void *info = ((void *)0);
 switch (name)
 {
 case 0x1081:
  size_ret = 4;
  info = &context->device_id;
  break;
 case 0x1083:
  size_ret = 4;
  info = &num_devices;
  break;
 case 0x1080:
 case 0x1082:
 default:
  fatal("opencl_context_get_info: invalid or not implemented value for 'name' (0x%x)\n%s",
   name, si_err_opencl_param_note);
 }
 ((void) sizeof ((info) ? 1 : 0), __extension__ ({ if (info) ; else __assert_fail ("info", "opencl-context.c", 86, __extension__ __PRETTY_FUNCTION__); }));
 if (addr && size >= size_ret)
  mem_write(mem, addr, size_ret, info);
 return size_ret;
}

canonical_original_code:
unsigned int si_opencl_context_get_info(struct si_opencl_context_t *context, unsigned int name, struct mem_t *mem, unsigned int addr, unsigned int size)
{
 unsigned int num_devices = 1;
 unsigned int size_ret = 0;
 void *info = ((void *)0);
 switch (name)
 {
 case 0x1081:
  size_ret = 4;
  info = &context->device_id;
  break;
 case 0x1083:
  size_ret = 4;
  info = &num_devices;
  break;
 case 0x1080:
 case 0x1082:
 default:
  fatal("opencl_context_get_info: invalid or not implemented value for 'name' (0x%x)\n%s",
   name, si_err_opencl_param_note);
 }
 ((void) sizeof ((info) ? 1 : 0), __extension__ ({ if (info) ; else __assert_fail ("info", "opencl-context.c", 86, __extension__ __PRETTY_FUNCTION__); }));
 if (addr && size >= size_ret)
  mem_write(mem, addr, size_ret, info);
 return size_ret;
}

variable_types:
name
unsigned int

variable_types: struct mem_t { int num_links; struct mem_page_t { unsigned int tag; enum mem_access_t { mem_access_none=0, mem_access_read=1, mem_access_write=2, mem_access_exec=4, mem_access_init=8, mem_access_modif=16 } perm; struct mem_page_t *next; unsigned char *data; } *pages[1024]; int safe; unsigned int heap_break; unsigned int last_address; } *

variable_types:
addr
unsigned int

variable_types:
size
unsigned int

variable_types:
info
void *

return_type: unsigned int

user_defined_types: struct mem_t { int num_links; struct mem_page_t *pages[1024]; int safe; unsigned int heap_break; unsigned int last_address; }

user_defined_types: struct mem_page_t { unsigned int tag; enum mem_access_t perm; struct mem_page_t *next; unsigned char *data; }


decompiled_code:
__int64 __fastcall si_opencl_context_set_properties(__int64 a1, __int64 a2, unsigned int a3)
{
unsigned int i; // ebx
__int64 result; // rax
unsigned int v5; // [rsp+8h] [rbp-20h] BYREF
unsigned int v6[7]; // [rsp+Ch] [rbp-1Ch] BYREF

for ( i = a3; i; i += 8 )
{
result = mem_read(a2, i, 4LL, v6);
if ( !v6[0] )
break;
mem_read(a2, i + 4, 4LL, &v5);
if ( v6[0] == 4228 )
{
*(_DWORD *)(a1 + 8) = v5;
result = si_opencl_repo_get_object(*(_QWORD *)(si_emu + 8LL), 1LL);
if ( si_opencl_debug_category )
result = _debug(si_opencl_debug_category, " property CL_CONTEXT_PLATFORM assigned: 0x%x\n", v5);
}
else
{
result = fatal("opencl_context_read_properties: invalid property (0x%x)\n", v6[0]);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, unsigned int a3)
{
unsigned int i; // ebx
__int64 result; // rax
unsigned int v5; // [rsp+8h] [rbp-20h] BYREF
unsigned int v6[7]; // [rsp+Ch] [rbp-1Ch] BYREF

for ( i = a3; i; i += 8 )
{
result = mem_read(a2, i, 4LL, v6);
if ( !v6[0] )
break;
mem_read(a2, i + 4, 4LL, &v5);
if ( v6[0] == 4228 )
{
*(_DWORD *)(a1 + 8) = v5;
result = si_opencl_repo_get_object(*(_QWORD *)(si_emu + 8LL), 1LL);
if ( si_opencl_debug_category )
result = _debug(si_opencl_debug_category, " property CL_CONTEXT_PLATFORM assigned: 0x%x\n", v5);
}
else
{
result = fatal("opencl_context_read_properties: invalid property (0x%x)\n", v6[0]);
}
}
return result;
}

original_code:
void si_opencl_context_set_properties(struct si_opencl_context_t *context, struct mem_t *mem, uint32_t addr)
{
 uint32_t property;
 uint32_t value;
 while (addr)
 {
  mem_read(mem, addr, 4, &property);
  if (!property)
   break;
  mem_read(mem, addr + 4, 4, &value);
  addr += 8;
  switch (property)
  {
  case 0x1084:
   context->platform_id = value;
   si_opencl_repo_get_object(si_emu->opencl_repo, si_opencl_object_platform, value);
   ((si_opencl_debug_category) ? __debug((si_opencl_debug_category), "    property CL_CONTEXT_PLATFORM assigned: 0x%x\n", value) : (void) 0);
   break;
  default:
   fatal("opencl_context_read_properties: invalid property (0x%x)\n", property);
  }
 }
}

canonical_original_code:
void si_opencl_context_set_properties(struct si_opencl_context_t *context, struct mem_t *mem, unsigned int addr)
{
 unsigned int property;
 unsigned int value;
 while (addr)
 {
  mem_read(mem, addr, 4, &property);
  if (!property)
   break;
  mem_read(mem, addr + 4, 4, &value);
  addr += 8;
  switch (property)
  {
  case 0x1084:
   context->platform_id = value;
   si_opencl_repo_get_object(si_emu->opencl_repo, si_opencl_object_platform, value);
   ((si_opencl_debug_category) ? __debug((si_opencl_debug_category), "    property CL_CONTEXT_PLATFORM assigned: 0x%x\n", value) : (void) 0);
   break;
  default:
   fatal("opencl_context_read_properties: invalid property (0x%x)\n", property);
  }
 }
}

variable_types:
property
unsigned int

variable_types:
value
unsigned int

user_defined_types: enum mem_access_t { mem_access_none=0, mem_access_read=1, mem_access_write=2, mem_access_exec=4, mem_access_init=8, mem_access_modif=16 }


decompiled_code:
__int64 __fastcall si_opencl_kernel_arg_create(char *src)
{
size_t v1; // rax
__int64 v2; // rbx

v1 = strlen(src);
v2 = mhandle_calloc(1LL, v1 + 41, "opencl-kernel.c:80");
if ( !v2 )
fatal("%s: out of memory", "si_opencl_kernel_arg_create");
strcpy((char *)(v2 + 40), src);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func1(char *src)
{
size_t v1; // rax
__int64 v2; // rbx

v1 = strlen(src);
v2 = mhandle_calloc(1LL, v1 + 41, "opencl-kernel.c:80");
if ( !v2 )
fatal("%s: out of memory", "si_opencl_kernel_arg_create");
strcpy((char *)(v2 + 40), src);
return v2;
}

original_code:
struct si_opencl_kernel_arg_t *si_opencl_kernel_arg_create(char *name)
{
 struct si_opencl_kernel_arg_t *arg;
 arg = (mhandle_calloc(1, sizeof(struct si_opencl_kernel_arg_t) + strlen(name) + 1, "opencl-kernel.c" ":" "80"));
 if (!arg)
  fatal("%s: out of memory", __FUNCTION__);
 strcpy(arg->name, name);
 return arg;
}

variable_types:
name
char *

variable_types: struct si_opencl_kernel_arg_t { enum si_opencl_kernel_arg_kind_t { SI_OPENCL_KERNEL_ARG_KIND_VALUE=1, SI_OPENCL_KERNEL_ARG_KIND_POINTER=2, SI_OPENCL_KERNEL_ARG_KIND_IMAGE=3, SI_OPENCL_KERNEL_ARG_KIND_SAMPLER=4 } kind; enum si_opencl_mem_scope_t { SI_OPENCL_MEM_SCOPE_NONE=0, SI_OPENCL_MEM_SCOPE_GLOBAL=1, SI_OPENCL_MEM_SCOPE_LOCAL=2, SI_OPENCL_MEM_SCOPE_PRIVATE=3, SI_OPENCL_MEM_SCOPE_CONSTANT=4 } mem_scope; int uav; enum si_opencl_kernel_arg_access_type_t { SI_OPENCL_KERNEL_ARG_READ_ONLY=1, SI_OPENCL_KERNEL_ARG_WRITE_ONLY=2, SI_OPENCL_KERNEL_ARG_READ_WRITE=3 } access_type; int set; unsigned int size; union { unsigned int ptr; unsigned int value[4]; } data; char name[]; } *

user_defined_types: struct si_opencl_kernel_arg_t { enum si_opencl_kernel_arg_kind_t kind; enum si_opencl_mem_scope_t mem_scope; int uav; enum si_opencl_kernel_arg_access_type_t access_type; int set; unsigned int size; union { unsigned int ptr; unsigned int value[4]; } data; char name[]; }


decompiled_code:
__int64 __fastcall si_opencl_kernel_arg_free(__int64 a1)
{
return mhandle_free(a1, "opencl-kernel.c:94");
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
return mhandle_free(a1, "opencl-kernel.c:94");
}

original_code:
void si_opencl_kernel_arg_free(struct si_opencl_kernel_arg_t *arg)
{
 (mhandle_free(arg, "opencl-kernel.c" ":" "94"));
}

user_defined_types: enum si_opencl_kernel_arg_kind_t { SI_OPENCL_KERNEL_ARG_KIND_VALUE=1, SI_OPENCL_KERNEL_ARG_KIND_POINTER=2, SI_OPENCL_KERNEL_ARG_KIND_IMAGE=3, SI_OPENCL_KERNEL_ARG_KIND_SAMPLER=4 }

user_defined_types: enum si_opencl_mem_scope_t { SI_OPENCL_MEM_SCOPE_NONE=0, SI_OPENCL_MEM_SCOPE_GLOBAL=1, SI_OPENCL_MEM_SCOPE_LOCAL=2, SI_OPENCL_MEM_SCOPE_PRIVATE=3, SI_OPENCL_MEM_SCOPE_CONSTANT=4 }

user_defined_types: enum si_opencl_kernel_arg_access_type_t { SI_OPENCL_KERNEL_ARG_READ_ONLY=1, SI_OPENCL_KERNEL_ARG_WRITE_ONLY=2, SI_OPENCL_KERNEL_ARG_READ_WRITE=3 }


decompiled_code:
_DWORD *evg_opencl_device_create()
{
_DWORD *v0; // rbx

v0 = (_DWORD *)mhandle_calloc(1LL, 4LL, "opencl-device.c:35");
if ( !v0 )
fatal("%s: out of memory", "evg_opencl_device_create");
*v0 = evg_opencl_repo_new_object_id(*(_QWORD *)(evg_emu + 8LL), 2LL);
evg_opencl_repo_add_object(*(_QWORD *)(evg_emu + 8LL), v0);
return v0;
}

canonical_decompiled_code:
_DWORD *func0()
{
_DWORD *v0; // rbx

v0 = (_DWORD *)mhandle_calloc(1LL, 4LL, "opencl-device.c:35");
if ( !v0 )
fatal("%s: out of memory", "evg_opencl_device_create");
*v0 = evg_opencl_repo_new_object_id(*(_QWORD *)(evg_emu + 8LL), 2LL);
evg_opencl_repo_add_object(*(_QWORD *)(evg_emu + 8LL), v0);
return v0;
}

original_code:
struct evg_opencl_device_t *evg_opencl_device_create()
{
 struct evg_opencl_device_t *device;
 device = (mhandle_calloc(1, sizeof(struct evg_opencl_device_t), "opencl-device.c" ":" "35"));
 if (!device)
  fatal("%s: out of memory", __FUNCTION__);
 device->id = evg_opencl_repo_new_object_id(evg_emu->opencl_repo,
  evg_opencl_object_device);
 evg_opencl_repo_add_object(evg_emu->opencl_repo, device);
 return device;
}

variable_types: struct evg_opencl_device_t { unsigned int id; } *


decompiled_code:
__int64 __fastcall evg_opencl_device_free(__int64 a1)
{
evg_opencl_repo_remove_object(*(_QWORD *)(evg_emu + 8LL), a1);
return mhandle_free(a1, "opencl-device.c:53");
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
evg_opencl_repo_remove_object(*(_QWORD *)(evg_emu + 8LL), a1);
return mhandle_free(a1, "opencl-device.c:53");
}

original_code:
void evg_opencl_device_free(struct evg_opencl_device_t *device)
{
 evg_opencl_repo_remove_object(evg_emu->opencl_repo, device);
 (mhandle_free(device, "opencl-device.c" ":" "53"));
}

user_defined_types: struct evg_opencl_device_t { unsigned int id; }


decompiled_code:
__int64 __fastcall evg_opencl_device_get_info(__int64 a1, unsigned int a2, __int64 a3, unsigned int a4, unsigned int a5)
{
unsigned int v7; // edx
__int64 v8; // rsi
int *v9; // rcx
unsigned int v10; // ebx
int v12; // [rsp+Ch] [rbp-3Ch] BYREF
__int64 v13; // [rsp+10h] [rbp-38h] BYREF
int v14; // [rsp+1Ch] [rbp-2Ch] BYREF
int v15; // [rsp+20h] [rbp-28h] BYREF
int v16; // [rsp+24h] [rbp-24h] BYREF
int v17[3]; // [rsp+28h] [rbp-20h] BYREF
int v18; // [rsp+34h] [rbp-14h] BYREF
int v19; // [rsp+38h] [rbp-10h] BYREF
int v20; // [rsp+3Ch] [rbp-Ch] BYREF

v20 = 1;
v19 = 0x10000;
v18 = 3;
v16 = 1;
v15 = 0x8000;
v14 = 850;
v13 = 0x80000000LL;
v12 = 1;
v7 = a2 - 4098;
v8 = a4;
switch ( v7 )
{
case 0u:
v9 = &v20;
v10 = 4;
break;
case 1u:
v9 = &v18;
v10 = 4;
break;
case 2u:
v9 = &v19;
v10 = 4;
break;
case 3u:
v17[0] = 256;
v17[1] = 256;
v17[2] = 256;
v9 = v17;
v10 = 12;
break;
case 0xAu:
v9 = &v14;
v10 = 4;
break;
case 0x14u:
v9 = &v12;
v10 = 4;
break;
case 0x1Du:
v9 = (int *)&v13;
v10 = 8;
break;
case 0x20u:
v9 = &v16;
v10 = 4;
break;
case 0x21u:
v9 = &v15;
v10 = 4;
break;
case 0x29u:
v9 = (int *)"Multi2Sim Virtual GPU Device";
v10 = 29;
break;
case 0x2Au:
v9 = (int *)"www.multi2sim.org";
v10 = 18;
break;
case 0x2Bu:
v9 = (int *)"4.0";
v10 = 4;
break;
case 0x2Du:
v9 = (int *)"OpenCL 1.1 ATI-Stream-v2.3 (451)";
v10 = 33;
break;
case 0x2Eu:
v9 = (int *)"cl_amd_fp64 cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_b"
"ase_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_gl_sharing cl_ext"
"_device_fission cl_amd_device_attribute_query cl_amd_media_ops cl_amd_popcnt cl_amd_printf ";
v10 = 296;
break;
default:
fatal("opencl_device_get_info: invalid or not implemented value for 'name' (0x%x)\n%s", a2, evg_err_opencl_note);
_assert_fail("info", "opencl-device.c", 0xA4u, "evg_opencl_device_get_info");
}
if ( (_DWORD)v8 && v10 <= a5 )
mem_write(a3, v8, v10, v9);
return v10;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, unsigned int a2, __int64 a3, unsigned int a4, unsigned int a5)
{
unsigned int v7; // edx
__int64 v8; // rsi
int *v9; // rcx
unsigned int v10; // ebx
int v12; // [rsp+Ch] [rbp-3Ch] BYREF
__int64 v13; // [rsp+10h] [rbp-38h] BYREF
int v14; // [rsp+1Ch] [rbp-2Ch] BYREF
int v15; // [rsp+20h] [rbp-28h] BYREF
int v16; // [rsp+24h] [rbp-24h] BYREF
int v17[3]; // [rsp+28h] [rbp-20h] BYREF
int v18; // [rsp+34h] [rbp-14h] BYREF
int v19; // [rsp+38h] [rbp-10h] BYREF
int v20; // [rsp+3Ch] [rbp-Ch] BYREF

v20 = 1;
v19 = 0x10000;
v18 = 3;
v16 = 1;
v15 = 0x8000;
v14 = 850;
v13 = 0x80000000LL;
v12 = 1;
v7 = a2 - 4098;
v8 = a4;
switch ( v7 )
{
case 0u:
v9 = &v20;
v10 = 4;
break;
case 1u:
v9 = &v18;
v10 = 4;
break;
case 2u:
v9 = &v19;
v10 = 4;
break;
case 3u:
v17[0] = 256;
v17[1] = 256;
v17[2] = 256;
v9 = v17;
v10 = 12;
break;
case 0xAu:
v9 = &v14;
v10 = 4;
break;
case 0x14u:
v9 = &v12;
v10 = 4;
break;
case 0x1Du:
v9 = (int *)&v13;
v10 = 8;
break;
case 0x20u:
v9 = &v16;
v10 = 4;
break;
case 0x21u:
v9 = &v15;
v10 = 4;
break;
case 0x29u:
v9 = (int *)"Multi2Sim Virtual GPU Device";
v10 = 29;
break;
case 0x2Au:
v9 = (int *)"www.multi2sim.org";
v10 = 18;
break;
case 0x2Bu:
v9 = (int *)"4.0";
v10 = 4;
break;
case 0x2Du:
v9 = (int *)"OpenCL 1.1 ATI-Stream-v2.3 (451)";
v10 = 33;
break;
case 0x2Eu:
v9 = (int *)"cl_amd_fp64 cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_b"
"ase_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_gl_sharing cl_ext"
"_device_fission cl_amd_device_attribute_query cl_amd_media_ops cl_amd_popcnt cl_amd_printf ";
v10 = 296;
break;
default:
fatal("opencl_device_get_info: invalid or not implemented value for 'name' (0x%x)\n%s", a2, evg_err_opencl_note);
_assert_fail("info", "opencl-device.c", 0xA4u, "evg_opencl_device_get_info");
}
if ( (_DWORD)v8 && v10 <= a5 )
mem_write(a3, v8, v10, v9);
return v10;
}

original_code:
uint32_t evg_opencl_device_get_info(struct evg_opencl_device_t *device, uint32_t name, struct mem_t *mem, uint32_t addr, uint32_t size)
{
 uint32_t max_compute_units = 1;
 uint32_t max_work_group_size = 256 * 256;
 uint32_t max_work_item_dimensions = 3;
 uint32_t max_work_item_sizes[3];
 uint32_t local_mem_type = 1;
 uint32_t local_mem_size = 32 * 1024;
 uint32_t max_clock_frequency = 850;
 uint64_t global_mem_size = 1ull << 31;
 uint32_t image_support = 1;
 char *device_name = "Multi2Sim Virtual GPU Device";
 char *device_vendor = "www.multi2sim.org";
 char *device_extensions = "cl_amd_fp64 cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics "
  "cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store "
  "cl_khr_gl_sharing cl_ext_device_fission cl_amd_device_attribute_query cl_amd_media_ops cl_amd_popcnt "
  "cl_amd_printf ";
 char *device_version = "OpenCL 1.1 ATI-Stream-v2.3 (451)";
 char *driver_version = "4.0";
 uint32_t size_ret = 0;
 void *info = ((void *)0);
 switch (name)
 {
 case 0x1002:
  size_ret = 4;
  info = &max_compute_units;
  break;
 case 0x1003:
  size_ret = 4;
  info = &max_work_item_dimensions;
  break;
 case 0x1004:
  size_ret = 4;
  info = &max_work_group_size;
  break;
 case 0x1005:
  max_work_item_sizes[0] = 256;
  max_work_item_sizes[1] = 256;
  max_work_item_sizes[2] = 256;
  size_ret = 12;
  info = max_work_item_sizes;
  break;
 case 0x100c:
  size_ret = 4;
  info = &max_clock_frequency;
  break;
 case 0x1016:
  size_ret = 4;
  info = &image_support;
  break;
 case 0x101f:
  size_ret = 8;
  info = &global_mem_size;
  break;
 case 0x1022:
  size_ret = 4;
  info = &local_mem_type;
  break;
 case 0x1023:
  size_ret = 4;
  info = &local_mem_size;
  break;
 case 0x102b:
  size_ret = strlen(device_name) + 1;
  info = device_name;
  break;
 case 0x102c:
  size_ret = strlen(device_vendor) + 1;
  info = device_vendor;
  break;
 case 0x102d:
  size_ret = strlen(driver_version) + 1;
  info = driver_version;
  break;
 case 0x102f:
  size_ret = strlen(device_version) + 1;
  info = device_version;
  break;
 case 0x1030:
  size_ret = strlen(device_extensions) + 1;
  info = device_extensions;
  break;
 default:
  fatal("opencl_device_get_info: invalid or not implemented value for 'name' (0x%x)\n%s",
   name, evg_err_opencl_note);
 }
 ((void) sizeof ((info) ? 1 : 0), __extension__ ({ if (info) ; else __assert_fail ("info", "opencl-device.c", 164, __extension__ __PRETTY_FUNCTION__); }));
 if (addr && size >= size_ret)
  mem_write(mem, addr, size_ret, info);
 return size_ret;
}

canonical_original_code:
unsigned int evg_opencl_device_get_info(struct evg_opencl_device_t *device, unsigned int name, struct mem_t *mem, unsigned int addr, unsigned int size)
{
 unsigned int max_compute_units = 1;
 unsigned int max_work_group_size = 256 * 256;
 unsigned int max_work_item_dimensions = 3;
 unsigned int max_work_item_sizes[3];
 unsigned int local_mem_type = 1;
 unsigned int local_mem_size = 32 * 1024;
 unsigned int max_clock_frequency = 850;
 unsigned long global_mem_size = 1ull << 31;
 unsigned int image_support = 1;
 char *device_name = "Multi2Sim Virtual GPU Device";
 char *device_vendor = "www.multi2sim.org";
 char *device_extensions = "cl_amd_fp64 cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics "
  "cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store "
  "cl_khr_gl_sharing cl_ext_device_fission cl_amd_device_attribute_query cl_amd_media_ops cl_amd_popcnt "
  "cl_amd_printf ";
 char *device_version = "OpenCL 1.1 ATI-Stream-v2.3 (451)";
 char *driver_version = "4.0";
 unsigned int size_ret = 0;
 void *info = ((void *)0);
 switch (name)
 {
 case 0x1002:
  size_ret = 4;
  info = &max_compute_units;
  break;
 case 0x1003:
  size_ret = 4;
  info = &max_work_item_dimensions;
  break;
 case 0x1004:
  size_ret = 4;
  info = &max_work_group_size;
  break;
 case 0x1005:
  max_work_item_sizes[0] = 256;
  max_work_item_sizes[1] = 256;
  max_work_item_sizes[2] = 256;
  size_ret = 12;
  info = max_work_item_sizes;
  break;
 case 0x100c:
  size_ret = 4;
  info = &max_clock_frequency;
  break;
 case 0x1016:
  size_ret = 4;
  info = &image_support;
  break;
 case 0x101f:
  size_ret = 8;
  info = &global_mem_size;
  break;
 case 0x1022:
  size_ret = 4;
  info = &local_mem_type;
  break;
 case 0x1023:
  size_ret = 4;
  info = &local_mem_size;
  break;
 case 0x102b:
  size_ret = strlen(device_name) + 1;
  info = device_name;
  break;
 case 0x102c:
  size_ret = strlen(device_vendor) + 1;
  info = device_vendor;
  break;
 case 0x102d:
  size_ret = strlen(driver_version) + 1;
  info = driver_version;
  break;
 case 0x102f:
  size_ret = strlen(device_version) + 1;
  info = device_version;
  break;
 case 0x1030:
  size_ret = strlen(device_extensions) + 1;
  info = device_extensions;
  break;
 default:
  fatal("opencl_device_get_info: invalid or not implemented value for 'name' (0x%x)\n%s",
   name, evg_err_opencl_note);
 }
 ((void) sizeof ((info) ? 1 : 0), __extension__ ({ if (info) ; else __assert_fail ("info", "opencl-device.c", 164, __extension__ __PRETTY_FUNCTION__); }));
 if (addr && size >= size_ret)
  mem_write(mem, addr, size_ret, info);
 return size_ret;
}


decompiled_code:
_DWORD *si_opencl_platform_create()
{
_DWORD *v0; // rbx

v0 = (_DWORD *)mhandle_calloc(1LL, 4LL, "opencl-platform.c:34");
if ( !v0 )
fatal("%s: out of memory", "si_opencl_platform_create");
*v0 = si_opencl_repo_new_object_id(*(_QWORD *)(si_emu + 8LL), 1LL);
si_opencl_repo_add_object(*(_QWORD *)(si_emu + 8LL), v0);
return v0;
}

canonical_decompiled_code:
_DWORD *func0()
{
_DWORD *v0; // rbx

v0 = (_DWORD *)mhandle_calloc(1LL, 4LL, "opencl-platform.c:34");
if ( !v0 )
fatal("%s: out of memory", "si_opencl_platform_create");
*v0 = si_opencl_repo_new_object_id(*(_QWORD *)(si_emu + 8LL), 1LL);
si_opencl_repo_add_object(*(_QWORD *)(si_emu + 8LL), v0);
return v0;
}

original_code:
struct si_opencl_platform_t *si_opencl_platform_create()
{
 struct si_opencl_platform_t *platform;
 platform = (mhandle_calloc(1, sizeof(struct si_opencl_platform_t), "opencl-platform.c" ":" "34"));
 if (!platform)
  fatal("%s: out of memory", __FUNCTION__);
 platform->id = si_opencl_repo_new_object_id(si_emu->opencl_repo,
  si_opencl_object_platform);
 si_opencl_repo_add_object(si_emu->opencl_repo, platform);
 return platform;
}

variable_types: struct si_opencl_platform_t { unsigned int id; } *


decompiled_code:
__int64 __fastcall si_opencl_platform_free(__int64 a1)
{
si_opencl_repo_remove_object(*(_QWORD *)(si_emu + 8LL), a1);
return mhandle_free(a1, "opencl-platform.c:51");
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
si_opencl_repo_remove_object(*(_QWORD *)(si_emu + 8LL), a1);
return mhandle_free(a1, "opencl-platform.c:51");
}

original_code:
void si_opencl_platform_free(struct si_opencl_platform_t *platform)
{
 si_opencl_repo_remove_object(si_emu->opencl_repo, platform);
 (mhandle_free(platform, "opencl-platform.c" ":" "51"));
}

user_defined_types: struct si_opencl_platform_t { unsigned int id; }


decompiled_code:
__int64 __fastcall si_opencl_platform_get_info(__int64 a1, __int64 a2, __int64 a3, unsigned int a4, unsigned int a5)
{
const char *v8; // r14
unsigned int v9; // ebx

switch ( (int)a2 )
{
case 2304:
v8 = "FULL_PROFILE";
break;
case 2305:
v8 = "OpenCL 1.1 Multi2Sim-v4.0";
break;
case 2306:
v8 = "Multi2Sim";
break;
case 2307:
v8 = "www.multi2sim.org";
break;
case 2308:
v8 = (const char *)&unk_16F;
break;
default:
fatal("opencl_platform_get_info: invalid value for 'name' (0x%x)\n%s", a2, si_err_opencl_param_note);
_assert_fail("info", "opencl-platform.c", 0x5Fu, "si_opencl_platform_get_info");
}
v9 = strlen(v8) + 1;
if ( a4 && v9 <= a5 )
mem_write(a3, a4, v9, v8);
return v9;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2, __int64 a3, unsigned int a4, unsigned int a5)
{
const char *v8; // r14
unsigned int v9; // ebx

switch ( (int)a2 )
{
case 2304:
v8 = "FULL_PROFILE";
break;
case 2305:
v8 = "OpenCL 1.1 Multi2Sim-v4.0";
break;
case 2306:
v8 = "Multi2Sim";
break;
case 2307:
v8 = "www.multi2sim.org";
break;
case 2308:
v8 = (const char *)&unk_16F;
break;
default:
fatal("opencl_platform_get_info: invalid value for 'name' (0x%x)\n%s", a2, si_err_opencl_param_note);
_assert_fail("info", "opencl-platform.c", 0x5Fu, "si_opencl_platform_get_info");
}
v9 = strlen(v8) + 1;
if ( a4 && v9 <= a5 )
mem_write(a3, a4, v9, v8);
return v9;
}

original_code:
uint32_t si_opencl_platform_get_info(struct si_opencl_platform_t *platform, uint32_t name, struct mem_t *mem, uint32_t addr, uint32_t size)
{
 char *platform_profile = "FULL_PROFILE";
 char *platform_version = "OpenCL 1.1 Multi2Sim-v" "4.0";
 char *platform_name = "Multi2Sim";
 char *platform_vendor = "www.multi2sim.org";
 char *platform_extensions = "";
 uint32_t size_ret = 0;
 char *info;
 switch (name) {
 case 0x900:
  info = platform_profile;
  break;
 case 0x901:
  info = platform_version;
  break;
 case 0x902:
  info = platform_name;
  break;
 case 0x903:
  info = platform_vendor;
  break;
 case 0x904:
  info = platform_extensions;
  break;
 default:
  info = ((void *)0);
  fatal("opencl_platform_get_info: invalid value for 'name' (0x%x)\n%s",
   name, si_err_opencl_param_note);
 }
 ((void) sizeof ((info) ? 1 : 0), __extension__ ({ if (info) ; else __assert_fail ("info", "opencl-platform.c", 95, __extension__ __PRETTY_FUNCTION__); }));
 size_ret = strlen(info) + 1;
 if (addr && size >= size_ret)
  mem_write(mem, addr, size_ret, info);
 return size_ret;
}

canonical_original_code:
unsigned int si_opencl_platform_get_info(struct si_opencl_platform_t *platform, unsigned int name, struct mem_t *mem, unsigned int addr, unsigned int size)
{
 char *platform_profile = "FULL_PROFILE";
 char *platform_version = "OpenCL 1.1 Multi2Sim-v" "4.0";
 char *platform_name = "Multi2Sim";
 char *platform_vendor = "www.multi2sim.org";
 char *platform_extensions = "";
 unsigned int size_ret = 0;
 char *info;
 switch (name) {
 case 0x900:
  info = platform_profile;
  break;
 case 0x901:
  info = platform_version;
  break;
 case 0x902:
  info = platform_name;
  break;
 case 0x903:
  info = platform_vendor;
  break;
 case 0x904:
  info = platform_extensions;
  break;
 default:
  info = ((void *)0);
  fatal("opencl_platform_get_info: invalid value for 'name' (0x%x)\n%s",
   name, si_err_opencl_param_note);
 }
 ((void) sizeof ((info) ? 1 : 0), __extension__ ({ if (info) ; else __assert_fail ("info", "opencl-platform.c", 95, __extension__ __PRETTY_FUNCTION__); }));
 size_ret = strlen(info) + 1;
 if (addr && size >= size_ret)
  mem_write(mem, addr, size_ret, info);
 return size_ret;
}

variable_types:
info
char *


original_code:
static int mmu_page_compare(const void *ptr1, const void *ptr2)
{
 struct mmu_page_t *page1 = (struct mmu_page_t *) ptr1;
 struct mmu_page_t *page2 = (struct mmu_page_t *) ptr2;
 long long num_accesses1;
 long long num_accesses2;
 num_accesses1 = page1->num_read_accesses + page1->num_write_accesses
  + page1->num_execute_accesses;
 num_accesses2 = page2->num_read_accesses + page2->num_write_accesses
  + page2->num_execute_accesses;
 if (num_accesses1 < num_accesses2)
  return 1;
 else if (num_accesses1 == num_accesses2)
  return 0;
 else
  return -1;
}

canonical_original_code:
static int mmu_page_compare(void *ptr1, void *ptr2)
{
 struct mmu_page_t *page1 = (struct mmu_page_t *) ptr1;
 struct mmu_page_t *page2 = (struct mmu_page_t *) ptr2;
 long long num_accesses1;
 long long num_accesses2;
 num_accesses1 = page1->num_read_accesses + page1->num_write_accesses
  + page1->num_execute_accesses;
 num_accesses2 = page2->num_read_accesses + page2->num_write_accesses
  + page2->num_execute_accesses;
 if (num_accesses1 < num_accesses2)
  return 1;
 else if (num_accesses1 == num_accesses2)
  return 0;
 else
  return -1;
}

variable_types: struct mmu_page_t { struct mmu_page_t *next; int address_space_index; unsigned int vtl_addr; unsigned int phy_addr; long long num_read_accesses; long long num_write_accesses; long long num_execute_accesses; } *


decompiled_code:
__int64 __fastcall mmu_get_page(int a1, unsigned int a2)
{
int v2; // er13
int v3; // ebp
__int64 v4; // rcx
__int64 v5; // rbx
_QWORD *v6; // rdx
__int64 v8; // rax

v2 = (23 * (_WORD)a1 + (unsigned __int16)(a2 >> mmu_log_page_size)) & 0x3FF;
v3 = a2 & ~mmu_page_mask;
v4 = mmu + 8LL * ((23 * (_WORD)a1 + (unsigned __int16)(a2 >> mmu_log_page_size)) & 0x3FF);
v5 = *(_QWORD *)(v4 + 8);
if ( v5 )
{
v6 = 0LL;
while ( *(_DWORD *)(v5 + 12) != v3 || *(_DWORD *)(v5 + 8) != a1 )
{
v6 = (_QWORD *)v5;
if ( !*(_QWORD *)v5 )
goto LABEL_10;
v5 = *(_QWORD *)v5;
}
if ( v6 )
{
*v6 = *(_QWORD *)v5;
*(_QWORD *)v5 = *(_QWORD *)(v4 + 8);
*(_QWORD *)(v4 + 8) = v5;
}
}
else
{
LABEL_10:
v5 = mhandle_calloc(1LL, 48LL, "mmu.c:105");
if ( !v5 )
fatal("%s: out of memory", "mmu_get_page");
*(_DWORD *)(v5 + 12) = v3;
*(_DWORD *)(v5 + 8) = a1;
*(_DWORD *)(v5 + 16) = (unsigned int)list_count(*(_QWORD *)mmu) << mmu_log_page_size;
list_add(*(_QWORD *)mmu, v5);
v8 = mmu;
*(_QWORD *)v5 = *(_QWORD *)(mmu + 8LL * v2 + 8);
*(_QWORD *)(v8 + 8LL * v2 + 8) = v5;
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1, unsigned int a2)
{
int v2; // er13
int v3; // ebp
__int64 v4; // rcx
__int64 v5; // rbx
_QWORD *v6; // rdx
__int64 v8; // rax

v2 = (23 * (_WORD)a1 + (unsigned __int16)(a2 >> mmu_log_page_size)) & 0x3FF;
v3 = a2 & ~mmu_page_mask;
v4 = mmu + 8LL * ((23 * (_WORD)a1 + (unsigned __int16)(a2 >> mmu_log_page_size)) & 0x3FF);
v5 = *(_QWORD *)(v4 + 8);
if ( v5 )
{
v6 = 0LL;
while ( *(_DWORD *)(v5 + 12) != v3 || *(_DWORD *)(v5 + 8) != a1 )
{
v6 = (_QWORD *)v5;
if ( !*(_QWORD *)v5 )
goto LABEL_10;
v5 = *(_QWORD *)v5;
}
if ( v6 )
{
*v6 = *(_QWORD *)v5;
*(_QWORD *)v5 = *(_QWORD *)(v4 + 8);
*(_QWORD *)(v4 + 8) = v5;
}
}
else
{
LABEL_10:
v5 = mhandle_calloc(1LL, 48LL, "mmu.c:105");
if ( !v5 )
fatal("%s: out of memory", "mmu_get_page");
*(_DWORD *)(v5 + 12) = v3;
*(_DWORD *)(v5 + 8) = a1;
*(_DWORD *)(v5 + 16) = (unsigned int)list_count(*(_QWORD *)mmu) << mmu_log_page_size;
list_add(*(_QWORD *)mmu, v5);
v8 = mmu;
*(_QWORD *)v5 = *(_QWORD *)(mmu + 8LL * v2 + 8);
*(_QWORD *)(v8 + 8LL * v2 + 8) = v5;
}
return v5;
}

original_code:
static struct mmu_page_t *mmu_get_page(int address_space_index, unsigned int vtladdr)
{
 struct mmu_page_t *prev, *page;
 unsigned int tag;
 int index;
 index = ((vtladdr >> mmu_log_page_size) + address_space_index * 23) % (1 << 10);
 tag = vtladdr & ~mmu_page_mask;
 prev = ((void *)0);
 page = mmu->page_hash_table[index];
 while (page)
 {
  if (page->vtl_addr == tag && page->address_space_index == address_space_index)
   break;
  prev = page;
  page = page->next;
 }
 if (!page)
 {
  page = (mhandle_calloc(1, sizeof(struct mmu_page_t), "mmu.c" ":" "105"));
  if (!page)
   fatal("%s: out of memory", __FUNCTION__);
  page->vtl_addr = tag;
  page->address_space_index = address_space_index;
  page->phy_addr = list_count(mmu->page_list) << mmu_log_page_size;
  list_add(mmu->page_list, page);
  page->next = mmu->page_hash_table[index];
  mmu->page_hash_table[index] = page;
  prev = ((void *)0);
 }
 if (prev)
 {
  prev->next = page->next;
  page->next = mmu->page_hash_table[index];
  mmu->page_hash_table[index] = page;
 }
 return page;
}

canonical_original_code:
static struct mmu_page_t *mmu_get_page(int address_space_index, unsigned int vtladdr)
{
 struct mmu_page_t *prev; struct mmu_page_t *page;
 unsigned int tag;
 int index;
 index = ((vtladdr >> mmu_log_page_size) + address_space_index * 23) % (1 << 10);
 tag = vtladdr & ~mmu_page_mask;
 prev = ((void *)0);
 page = mmu->page_hash_table[index];
 while (page)
 {
  if (page->vtl_addr == tag && page->address_space_index == address_space_index)
   break;
  prev = page;
  page = page->next;
 }
 if (!page)
 {
  page = (mhandle_calloc(1, sizeof(struct mmu_page_t), "mmu.c" ":" "105"));
  if (!page)
   fatal("%s: out of memory", __FUNCTION__);
  page->vtl_addr = tag;
  page->address_space_index = address_space_index;
  page->phy_addr = list_count(mmu->page_list) << mmu_log_page_size;
  list_add(mmu->page_list, page);
  page->next = mmu->page_hash_table[index];
  mmu->page_hash_table[index] = page;
  prev = ((void *)0);
 }
 if (prev)
 {
  prev->next = page->next;
  page->next = mmu->page_hash_table[index];
  mmu->page_hash_table[index] = page;
 }
 return page;
}

variable_types:
vtladdr
unsigned int

variable_types:
tag
unsigned int

variable_types: index int

return_type: struct mmu_page_t { struct mmu_page_t *next; int address_space_index; unsigned int vtl_addr; unsigned int phy_addr; long long num_read_accesses; long long num_write_accesses; long long num_execute_accesses; } *


decompiled_code:
__int64 mmu_done()
{
int i; // ebx
__int64 v1; // rax

mmu_dump_report();
for ( i = 0; (int)list_count(*(_QWORD *)mmu) > i; ++i )
{
v1 = list_get(*(_QWORD *)mmu, (unsigned int)i);
mhandle_free(v1, "mmu.c:197");
}
list_free(*(_QWORD *)mmu);
return mhandle_free(mmu, "mmu.c:201");
}

canonical_decompiled_code:
__int64 func4()
{
int i; // ebx
__int64 v1; // rax

func3();
for ( i = 0; (int)list_count(*(_QWORD *)mmu) > i; ++i )
{
v1 = list_get(*(_QWORD *)mmu, (unsigned int)i);
mhandle_free(v1, "mmu.c:197");
}
list_free(*(_QWORD *)mmu);
return mhandle_free(mmu, "mmu.c:201");
}

original_code:
void mmu_done()
{
 int i;
 mmu_dump_report();
 for (i = 0; i < list_count(mmu->page_list); i++)
  (mhandle_free(list_get(mmu->page_list, i), "mmu.c" ":" "197"));
 list_free(mmu->page_list);
 (mhandle_free(mmu, "mmu.c" ":" "201"));
}

variable_types: i int


decompiled_code:
__int64 mmu_address_space_new()
{
return (unsigned int)mmu_address_space_index_3++;
}

canonical_decompiled_code:
__int64 func5()
{
return (unsigned int)mmu_address_space_index_3++;
}

original_code:
int mmu_address_space_new(void)
{
 static int mmu_address_space_index;
 return mmu_address_space_index++;
}

canonical_original_code:
int mmu_address_space_new()
{
 static int mmu_address_space_index;
 return mmu_address_space_index++;
}


decompiled_code:
__int64 __fastcall mmu_translate(int a1, unsigned int a2)
{
int v2; // ebx
__int64 v3; // rax

v2 = mmu_page_mask & a2;
v3 = mmu_get_page(a1, a2);
if ( !v3 )
_assert_fail("page", "mmu.c", 0x106u, "mmu_translate");
return *(_DWORD *)(v3 + 16) | (unsigned int)v2;
}

canonical_decompiled_code:
__int64 __fastcall func6(int a1, unsigned int a2)
{
int v2; // ebx
__int64 v3; // rax

v2 = mmu_page_mask & a2;
v3 = func1(a1, a2);
if ( !v3 )
_assert_fail("page", "mmu.c", 0x106u, "mmu_translate");
return *(_DWORD *)(v3 + 16) | (unsigned int)v2;
}

original_code:
unsigned int mmu_translate(int address_space_index, unsigned int vtl_addr)
{
 struct mmu_page_t *page;
 unsigned int offset;
 unsigned int phy_addr;
 offset = vtl_addr & mmu_page_mask;
 page = mmu_get_page(address_space_index, vtl_addr);
 ((void) sizeof ((page) ? 1 : 0), __extension__ ({ if (page) ; else __assert_fail ("page", "mmu.c", 262, __extension__ __PRETTY_FUNCTION__); }));
 phy_addr = page->phy_addr | offset;
 return phy_addr;
}

variable_types:
offset
unsigned int

user_defined_types: struct mmu_page_t { struct mmu_page_t *next; int address_space_index; unsigned int vtl_addr; unsigned int phy_addr; long long num_read_accesses; long long num_write_accesses; long long num_execute_accesses; }


decompiled_code:
_BOOL8 __fastcall mmu_valid_phy_addr(unsigned int a1)
{
return **(_DWORD **)mmu > (int)(a1 >> mmu_log_page_size);
}

canonical_decompiled_code:
_BOOL8 __fastcall func7(unsigned int a1)
{
return **(_DWORD **)mmu > (int)(a1 >> mmu_log_page_size);
}

original_code:
int mmu_valid_phy_addr(unsigned int phy_addr)
{
 int index;
 index = phy_addr >> mmu_log_page_size;
 return index < mmu->page_list->count;
}


decompiled_code:
_DWORD *si_opencl_sampler_create()
{
_DWORD *v0; // rbx

v0 = (_DWORD *)mhandle_calloc(1LL, 20LL, "opencl-sampler.c:34");
if ( !v0 )
fatal("%s: out of memory", "si_opencl_sampler_create");
*v0 = si_opencl_repo_new_object_id(*(_QWORD *)(si_emu + 8LL), 9LL);
v0[1] = 1;
si_opencl_repo_add_object(*(_QWORD *)(si_emu + 8LL), v0);
return v0;
}

canonical_decompiled_code:
_DWORD *func0()
{
_DWORD *v0; // rbx

v0 = (_DWORD *)mhandle_calloc(1LL, 20LL, "opencl-sampler.c:34");
if ( !v0 )
fatal("%s: out of memory", "si_opencl_sampler_create");
*v0 = si_opencl_repo_new_object_id(*(_QWORD *)(si_emu + 8LL), 9LL);
v0[1] = 1;
si_opencl_repo_add_object(*(_QWORD *)(si_emu + 8LL), v0);
return v0;
}

original_code:
struct si_opencl_sampler_t *si_opencl_sampler_create()
{
 struct si_opencl_sampler_t *sampler;
 sampler = (mhandle_calloc(1, sizeof(struct si_opencl_sampler_t), "opencl-sampler.c" ":" "34"));
 if (!sampler)
  fatal("%s: out of memory", __FUNCTION__);
 sampler->id = si_opencl_repo_new_object_id(si_emu->opencl_repo,
  si_opencl_object_sampler);
 sampler->ref_count = 1;
 si_opencl_repo_add_object(si_emu->opencl_repo, sampler);
 return sampler;
}

variable_types: struct si_opencl_sampler_t { unsigned int id; int ref_count; unsigned int normalized_coords; unsigned int filter_mode; unsigned int addressing_mode; } *


decompiled_code:
__int64 __fastcall si_opencl_sampler_free(__int64 a1)
{
si_opencl_repo_remove_object(*(_QWORD *)(si_emu + 8LL), a1);
return mhandle_free(a1, "opencl-sampler.c:52");
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
si_opencl_repo_remove_object(*(_QWORD *)(si_emu + 8LL), a1);
return mhandle_free(a1, "opencl-sampler.c:52");
}

original_code:
void si_opencl_sampler_free(struct si_opencl_sampler_t *sampler)
{
 si_opencl_repo_remove_object(si_emu->opencl_repo, sampler);
 (mhandle_free(sampler, "opencl-sampler.c" ":" "52"));
}

user_defined_types: struct si_opencl_sampler_t { unsigned int id; int ref_count; unsigned int normalized_coords; unsigned int filter_mode; unsigned int addressing_mode; }


decompiled_code:
void frm_gpu_init()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
void frm_gpu_init(void)
{
}

canonical_original_code:
void frm_gpu_init()
{
}


decompiled_code:
void frm_gpu_done()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
void frm_gpu_done(void)
{
}

canonical_original_code:
void frm_gpu_done()
{
}


decompiled_code:
__int64 evg_opencl_program_create()
{
__int64 v0; // rbp
int v1; // ebx

v0 = mhandle_calloc(1LL, 32LL, "opencl-program.c:35");
if ( !v0 )
fatal("%s: out of memory", "evg_opencl_program_create");
*(_DWORD *)v0 = evg_opencl_repo_new_object_id(*(_QWORD *)(evg_emu + 8LL), 5LL);
*(_DWORD *)(v0 + 4) = 1;
*(_QWORD *)(v0 + 24) = list_create_with_size(25LL);
v1 = 25;
do
{
list_add(*(_QWORD *)(v0 + 24), 0LL);
--v1;
}
while ( v1 );
evg_opencl_repo_add_object(*(_QWORD *)(evg_emu + 8LL), v0);
return v0;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v0; // rbp
int v1; // ebx

v0 = mhandle_calloc(1LL, 32LL, "opencl-program.c:35");
if ( !v0 )
fatal("%s: out of memory", "evg_opencl_program_create");
*(_DWORD *)v0 = evg_opencl_repo_new_object_id(*(_QWORD *)(evg_emu + 8LL), 5LL);
*(_DWORD *)(v0 + 4) = 1;
*(_QWORD *)(v0 + 24) = list_create_with_size(25LL);
v1 = 25;
do
{
list_add(*(_QWORD *)(v0 + 24), 0LL);
--v1;
}
while ( v1 );
evg_opencl_repo_add_object(*(_QWORD *)(evg_emu + 8LL), v0);
return v0;
}

original_code:
struct evg_opencl_program_t *evg_opencl_program_create()
{
 struct evg_opencl_program_t *program;
 int i;
 program = (mhandle_calloc(1, sizeof(struct evg_opencl_program_t), "opencl-program.c" ":" "35"));
 if (!program)
  fatal("%s: out of memory", __FUNCTION__);
 program->id = evg_opencl_repo_new_object_id(evg_emu->opencl_repo,
  evg_opencl_object_program);
 program->ref_count = 1;
 program->constant_buffer_list = list_create_with_size(25);
 for(i = 0; i < 25; i++)
  list_add(program->constant_buffer_list, ((void *)0));
 evg_opencl_repo_add_object(evg_emu->opencl_repo, program);
 return program;
}

variable_types: struct evg_opencl_program_t { unsigned int id; int ref_count; unsigned int device_id; unsigned int context_id; struct elf_file_t { char *path; struct elf_buffer_t { void *ptr; int size; int pos; } buffer; struct Elf32_Ehdr { unsigned char e_ident[-1]; unsigned short e_type; unsigned short e_machine; unsigned int e_version; unsigned int e_entry; unsigned int e_phoff; unsigned int e_shoff; unsigned int e_flags; unsigned short e_ehsize; unsigned short e_phentsize; unsigned short e_phnum; unsigned short e_shentsize; unsigned short e_shnum; unsigned short e_shstrndx; } *header; struct list_t { int count; int error_code; int size; int head; int tail; void **elem; } *section_list; struct elf_section_t { char *name; struct Elf32_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned int sh_flags; unsigned int sh_addr; unsigned int sh_offset; unsigned int sh_size; unsigned int sh_link; unsigned int sh_info; unsigned int sh_addralign; unsigned int sh_entsize; } *header; struct elf_buffer_t buffer; } *string_table; struct list_t *program_header_list; struct list_t *symbol_table; } *elf_file; struct list_t *constant_buffer_list; } *

user_defined_types: struct evg_opencl_program_t { unsigned int id; int ref_count; unsigned int device_id; unsigned int context_id; struct elf_file_t *elf_file; struct list_t *constant_buffer_list; }

user_defined_types: struct elf_file_t { char *path; struct elf_buffer_t buffer; struct Elf32_Ehdr *header; struct list_t *section_list; struct elf_section_t *string_table; struct list_t *program_header_list; struct list_t *symbol_table; }

user_defined_types: struct elf_section_t { char *name; struct Elf32_Shdr *header; struct elf_buffer_t buffer; }