LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/leda.c
// Function: leda_parse_received_msg
int leda_parse_received_msg(cJSON *root, int *msg_id, int *code, char **method, cJSON **payload)
{
    cJSON *item = NULL;

    item = cJSON_GetObjectItem(root, "messageId");
    if ((NULL == item) || (cJSON_Number != item->type)) {
        log_e(LOG_TAG, "msg id type is not integer\n");
        return MSG_INVALID;
    }
    *msg_id = item->valueint;
    *payload = cJSON_GetObjectItem(root, "payload");
    item = cJSON_GetObjectItem(root, "code");    
    if (item) {
        if (cJSON_Number != item->type) {
            log_e(LOG_TAG, "code type is not integer\n");
            return MSG_INVALID;
        }
        *code = item->valueint;
        return MSG_RSP;
    }
    item = cJSON_GetObjectItem(root, "method");
    if ((NULL == item) || (cJSON_String != item->type)) {
        return MSG_INVALID;
    }
    *method = item->valuestring;

    return MSG_METHOD;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r8, %r12
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r13
movq %rdi, %r15
leaq 0x6089(%rip), %rsi      # 0xb194
callq 0x40a0
testq %rax, %rax
je 0x515d
cmpl $0x8, 0x18(%rax)
jne 0x515d
movl 0x28(%rax), %eax
movl %eax, (%r13)
leaq 0x60a9(%rip), %rsi      # 0xb1d2
movq %r15, %rdi
callq 0x40a0
movq %rax, (%r12)
leaq 0x609e(%rip), %rsi      # 0xb1da
movq %r15, %rdi
callq 0x40a0
testq %rax, %rax
je 0x51aa
cmpl $0x8, 0x18(%rax)
jne 0x51da
movl 0x28(%rax), %eax
movl %eax, (%r14)
xorl %eax, %eax
jmp 0x519b
leaq 0x6052(%rip), %rax      # 0xb1b6
movq %rax, (%rsp)
leaq 0x5f21(%rip), %rsi      # 0xb090
leaq 0x5f20(%rip), %rdx      # 0xb096
leaq 0x5f1e(%rip), %rcx      # 0xb09b
leaq 0x601a(%rip), %r8       # 0xb19e
movl $0x3, %edi
movl $0x17e, %r9d            # imm = 0x17E
xorl %eax, %eax
callq 0x4260
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x60e1(%rip), %rsi      # 0xb292
movq %r15, %rdi
callq 0x40a0
movq %rax, %rcx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testq %rcx, %rcx
je 0x519b
cmpl $0x10, 0x18(%rcx)
jne 0x519b
movq 0x20(%rcx), %rax
movq %rax, (%rbx)
movl $0x1, %eax
jmp 0x519b
leaq 0x5ffe(%rip), %rax      # 0xb1df
movq %rax, (%rsp)
leaq 0x5ea4(%rip), %rsi      # 0xb090
leaq 0x5ea3(%rip), %rdx      # 0xb096
leaq 0x5ea1(%rip), %rcx      # 0xb09b
leaq 0x5f9d(%rip), %r8       # 0xb19e
movl $0x3, %edi
movl $0x186, %r9d            # imm = 0x186
jmp 0x518f
// File: /workspace/github_c_makefile_star2_O1/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/leda.c
// Function: leda_send_rsp
int leda_send_rsp(int code, int msg_id, cJSON *payload)
{
    cJSON *root;
    char *msg;
    int ret;

    root = cJSON_CreateObject();
    if (!root) {
        return LE_ERROR_ALLOCATING_MEM;
    }
    cJSON_AddNumberToObject(root, "code", code);
    cJSON_AddNumberToObject(root, "messageId", msg_id);
    if (!payload) {
        payload  = cJSON_CreateObject();
        if (!payload) {
            cJSON_Delete(root);
            return LE_ERROR_ALLOCATING_MEM;
        }
    }
    cJSON_AddItemToObject(root, "payload", payload);

    msg = cJSON_Print(root);
    cJSON_Delete(root);
    if (!msg) {
        return LE_ERROR_ALLOCATING_MEM;
    }
    log_i(LOG_TAG, "send messege to server: %s", msg);
    ret = wsc_add_msg(msg, strlen(msg) + 1, 0);
    free(msg);

    return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %r14
movl %esi, %r15d
movl %edi, %r12d
callq 0x45b0
testq %rax, %rax
je 0x5838
movq %rax, %rbx
cvtsi2sd %r12d, %xmm0
leaq 0x5a6a(%rip), %rsi      # 0xb1da
movq %rax, %rdi
callq 0x4210
xorps %xmm0, %xmm0
cvtsi2sd %r15d, %xmm0
leaq 0x5a0d(%rip), %rsi      # 0xb194
movq %rbx, %rdi
callq 0x4210
testq %r14, %r14
jne 0x57a5
callq 0x45b0
movq %rax, %r14
testq %rax, %rax
je 0x5830
leaq 0x5a26(%rip), %rsi      # 0xb1d2
movq %rbx, %rdi
movq %r14, %rdx
callq 0x45f0
movq %rbx, %rdi
callq 0x40b0
movq %rax, %r14
movq %rbx, %rdi
callq 0x41a0
testq %r14, %r14
je 0x5838
leaq 0x5a88(%rip), %r10      # 0xb25e
leaq 0x5a65(%rip), %rsi      # 0xb242
leaq 0x58b2(%rip), %rdx      # 0xb096
leaq 0x58b0(%rip), %rcx      # 0xb09b
leaq 0x5ab6(%rip), %r8       # 0xb2a8
movl $0x1, %edi
movl $0x23d, %r9d            # imm = 0x23D
xorl %eax, %eax
pushq %r14
pushq %r10
callq 0x4260
addq $0x10, %rsp
movq %r14, %rdi
callq 0x4200
leaq 0x1(%rax), %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x4470
movl %eax, %ebx
movq %r14, %rdi
callq 0x46b0
movl %ebx, %eax
jmp 0x583d
movq %rbx, %rdi
callq 0x41a0
movl $0x186a2, %eax          # imm = 0x186A2
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/leda.c
// Function: leda_rsp_get_properties
int leda_rsp_get_properties(char *pk, char *dn, int msg_id, leda_device_data_t *data, int data_cnt)
{
    int ret = LE_ERROR_UNKNOWN;
    cJSON *root, *payload, *properties;
    char *msg;

    payload = cJSON_CreateObject();
    if (!payload) {
        return LE_ERROR_ALLOCATING_MEM;
    }

    if (g_devs_cb.get_properties_cb) {
        ret = g_devs_cb.get_properties_cb(pk, dn, data, data_cnt, g_devs_cb.usr_data_get_property);
    } else {
        log_e(LOG_TAG, "callback get_properties_cb unregistered!\n");
    }
    
    if (ret == LE_SUCCESS) {
        properties = struct_data_to_json_data(data, data_cnt);
        cJSON_AddItemToObject(payload, "properties", properties);
    }

    return leda_send_rsp(ret, msg_id, payload);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r8d, %r15d
movq %rcx, %r12
movl %edx, -0x2c(%rbp)
movq %rsi, %r13
movq %rdi, %rbx
callq 0x45b0
testq %rax, %rax
je 0x5899
movq %rax, %r14
movq 0x9c0e(%rip), %rax      # 0xf488
testq %rax, %rax
je 0x58ad
movq 0x9c0a(%rip), %r8       # 0xf490
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rdx
movl %r15d, %ecx
callq *%rax
movl %eax, %r13d
jmp 0x58ec
movl $0x186a2, %eax          # imm = 0x186A2
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5a1a(%rip), %rax      # 0xb2ce
movq %rax, (%rsp)
leaq 0x57d1(%rip), %rsi      # 0xb090
leaq 0x57d0(%rip), %rdx      # 0xb096
leaq 0x57ce(%rip), %rcx      # 0xb09b
leaq 0x59e2(%rip), %r8       # 0xb2b6
movl $0x3, %edi
movl $0x252, %r9d            # imm = 0x252
xorl %eax, %eax
callq 0x4260
movl $0x186a0, %r13d         # imm = 0x186A0
testl %r13d, %r13d
jne 0x590e
movq %r12, %rdi
movl %r15d, %esi
callq 0x4570
leaq 0x59c0(%rip), %rsi      # 0xb2c3
movq %r14, %rdi
movq %rax, %rdx
callq 0x45f0
movl %r13d, %edi
movl -0x2c(%rbp), %esi
movq %r14, %rdx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4370
// File: /workspace/github_c_makefile_star2_O1/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/leda.c
// Function: leda_rsp_set_properties
int leda_rsp_set_properties(char *pk, char *dn, int msg_id, leda_device_data_t *data, int data_cnt)
{
    int ret = LE_ERROR_UNKNOWN;

    if (g_devs_cb.set_properties_cb) {
        ret = g_devs_cb.set_properties_cb(pk, dn, data, data_cnt, g_devs_cb.set_properties_cb);
    } else {
        log_e(LOG_TAG, "callback set_properties_cb unregistered!\n");
    }

    return leda_send_rsp(ret, msg_id, NULL);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl %edx, %ebx
movq 0x9b5f(%rip), %rax      # 0xf498
testq %rax, %rax
je 0x594d
movq %rcx, %rdx
movl %r8d, %ecx
movq %rax, %r8
callq *%rax
movl %eax, %edi
jmp 0x598b
leaq 0x59bc(%rip), %rax      # 0xb310
movq %rax, (%rsp)
leaq 0x5731(%rip), %rsi      # 0xb090
leaq 0x5730(%rip), %rdx      # 0xb096
leaq 0x572e(%rip), %rcx      # 0xb09b
leaq 0x5984(%rip), %r8       # 0xb2f8
movl $0x3, %edi
movl $0x265, %r9d            # imm = 0x265
xorl %eax, %eax
callq 0x4260
movl $0x186a0, %edi          # imm = 0x186A0
movl %ebx, %esi
xorl %edx, %edx
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x4370
// File: /workspace/github_c_makefile_star2_O1/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/leda.c
// Function: cb_ws_estab
static void cb_ws_estab(void *user)
{
    g_conn_state = LEDA_WS_CONNECTED;
    log_i(LOG_TAG, "connection establish.\n");

    if (g_conn_cb.conn_state_change_cb) {
        g_conn_cb.conn_state_change_cb(LEDA_WS_CONNECTED, g_conn_cb.usr_data);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl $0x0, 0x943a(%rip)      # 0xf388
leaq 0x54c1(%rip), %rax      # 0xb416
movq %rax, (%rsp)
leaq 0x52e2(%rip), %rsi      # 0xb242
leaq 0x512f(%rip), %rdx      # 0xb096
leaq 0x512d(%rip), %rcx      # 0xb09b
leaq 0x5495(%rip), %r8       # 0xb40a
movl $0x1, %edi
movl $0x329, %r9d            # imm = 0x329
xorl %eax, %eax
callq 0x4260
movq 0x9532(%rip), %rax      # 0xf4c0
testq %rax, %rax
je 0x5fa3
movq 0x952e(%rip), %rsi      # 0xf4c8
xorl %edi, %edi
addq $0x10, %rsp
popq %rbp
jmpq *%rax
addq $0x10, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/leda.c
// Function: cb_ws_close
static void cb_ws_close(void *user)
{
    g_conn_state = LEDA_WS_DISCONNECTED;
    log_i(LOG_TAG, "connection closed.\n");

    if (g_conn_cb.conn_state_change_cb) {
        g_conn_cb.conn_state_change_cb(LEDA_WS_DISCONNECTED, g_conn_cb.usr_data);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl $0x1, 0x93cd(%rip)      # 0xf388
leaq 0x5477(%rip), %rax      # 0xb439
movq %rax, (%rsp)
leaq 0x5275(%rip), %rsi      # 0xb242
leaq 0x50c2(%rip), %rdx      # 0xb096
leaq 0x50c0(%rip), %rcx      # 0xb09b
leaq 0x544b(%rip), %r8       # 0xb42d
movl $0x1, %edi
movl $0x31f, %r9d            # imm = 0x31F
xorl %eax, %eax
callq 0x4260
movq 0x94c5(%rip), %rax      # 0xf4c0
testq %rax, %rax
je 0x6013
movq 0x94c1(%rip), %rsi      # 0xf4c8
movl $0x1, %edi
addq $0x10, %rsp
popq %rbp
jmpq *%rax
addq $0x10, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/leda.c
// Function: leda_wsc_exit
int leda_wsc_exit()
{
    g_is_init = 0;
    force_exit = 1;
    
    if (g_threadpool_recv_proc) {
        threadpool_destroy(g_threadpool_recv_proc, threadpool_graceful);
    }
    if (context) {
        lws_cancel_service(context);
        context = NULL;
    }

    return ws_client_destroy();

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movb $0x0, 0x92d1(%rip)      # 0xf4bc
movq 0x8dfe(%rip), %rax      # 0xeff0
movl $0x1, (%rax)
movq 0x8d89(%rip), %rax      # 0xef88
movq (%rax), %rdi
testq %rdi, %rdi
je 0x6211
movl $0x1, %esi
callq 0x4580
movq 0x8db0(%rip), %rbx      # 0xefc8
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x622c
callq 0x4330
movq $0x0, (%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x40f0
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O1/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/ali_ws/ws_client.c
// Function: wsc_init
int wsc_init(p_wsc_param_conn pc, p_wsc_param_cb cb)
{
    int ret = 0;
    if (!pc || !cb || !pc->url) {
        printf("wsc init failed, param should not be NULL.\n");
        return LE_ERROR_INVAILD_PARAM;
    }

    if (!strncmp(pc->url, "wss", 3) && !pc->ca_path) {
        printf("ca path must not be NULL when use ssl\n");
    }

    g_cbs = malloc(sizeof(wsc_param_cb));
    if (!g_cbs) {
        printf("malloc error.\n");
        return LE_ERROR_ALLOCATING_MEM;
    }

    memset(g_cbs, 0, sizeof(wsc_param_cb));
    memcpy(g_cbs, cb, sizeof(wsc_param_cb));
    
    force_exit = 0;

    ret = client_buf_mgmt_init(1024 * 2, 1024);
    if (ret != LE_SUCCESS) {
        free(g_cbs);
        g_cbs = NULL;
        return ret;
    }

    pthread_t id;
    ret = pthread_create(&id, NULL, thread_wsc_network, pc);
    if (ret == 0) {
        printf("wsc init ok\n");
    } else {
        free(g_cbs);
        g_cbs = NULL;
#ifndef _WIN32
        printf("wsc init faild, %s.\n", strerror(errno));
#else
        char buffer[64] = { 0 };
        strerror_s(buffer, sizeof(buffer), errno);
        printf("wsc init faild, %s.\n", buffer);
#endif
        client_buf_mgmt_destroy();

        return LE_ERROR_UNKNOWN;
    }
    pthread_detach(id);

    return LE_SUCCESS;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
jne 0x62fa
movq %rdi, %rbx
movq (%rdi), %rdi
testq %rdi, %rdi
je 0x62fa
movq %rsi, %r14
leaq 0x5202(%rip), %rsi      # 0xb475
movl $0x3, %edx
callq 0x4080
testl %eax, %eax
jne 0x6294
cmpq $0x0, 0x10(%rbx)
jne 0x6294
leaq 0x522a(%rip), %rdi      # 0xb4b9
callq 0x40d0
movl $0x30, %edi
callq 0x46b8
movq 0x8cfb(%rip), %r15      # 0xefa0
movq %rax, (%r15)
testq %rax, %rax
je 0x631a
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups 0x20(%r14), %xmm2
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
movq 0x8d23(%rip), %rax      # 0xeff0
movl $0x0, (%rax)
movl $0x800, %edi            # imm = 0x800
movl $0x400, %esi            # imm = 0x400
callq 0x44a0
testl %eax, %eax
je 0x632e
movl %eax, %r14d
movq (%r15), %rdi
callq 0x46b0
movq $0x0, (%r15)
jmp 0x630c
leaq 0x518d(%rip), %rdi      # 0xb48e
callq 0x40d0
movl $0x186a1, %r14d         # imm = 0x186A1
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x51be(%rip), %rdi      # 0xb4df
callq 0x40d0
movl $0x186a2, %r14d         # imm = 0x186A2
jmp 0x630c
movq 0x8ca3(%rip), %rdx      # 0xefd8
xorl %r14d, %r14d
leaq -0x20(%rbp), %rdi
xorl %esi, %esi
movq %rbx, %rcx
callq 0x44d0
testl %eax, %eax
je 0x6383
movq (%r15), %rdi
callq 0x46b0
movq $0x0, (%r15)
callq 0x4070
movl (%rax), %edi
callq 0x4620
leaq 0x510d(%rip), %rdi      # 0xb479
movq %rax, %rsi
xorl %eax, %eax
callq 0x4240
callq 0x4220
movl $0x186a0, %r14d         # imm = 0x186A0
jmp 0x630c
leaq 0x5163(%rip), %rdi      # 0xb4ed
callq 0x40d0
movq -0x20(%rbp), %rdi
callq 0x4420
jmp 0x630c
// File: /workspace/github_c_makefile_star2_O1/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/ali_ws/ws_client.c
// Function: ws_client_destroy
int ws_client_destroy()
{
    force_exit = 1;
#ifndef _WIN32
    usleep(1000*1000);
#else
    Sleep(1000);
#endif
    if (g_cbs) {
        free(g_cbs);
        g_cbs = NULL;
    }

    return client_buf_mgmt_destroy();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq 0x8c1d(%rip), %rax      # 0xeff0
movl $0x1, (%rax)
movl $0xf4240, %edi          # imm = 0xF4240
callq 0x46a0
movq 0x8bb6(%rip), %rbx      # 0xefa0
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x63fe
callq 0x46b0
movq $0x0, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x4220
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O1/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/ali_ws/ws_client_callback.c
// Function: recvframeAppend
static int recvframeAppend(struct lws *wsi, void **appendBuffer, void *in, size_t preLen, size_t len)
{
    char *tmp = NULL;
    
    if (*appendBuffer == NULL){
        tmp = malloc(preLen + len + 1);
    } else {
        tmp = realloc((void *)*appendBuffer,preLen + len + 1);
    } 

    if(!tmp)
    {
        lwsl_notice("recv malloc error:  %p\n", wsi);
        return 0;
    }

    memcpy(tmp + preLen, (void *)in, len);
    *(tmp + preLen +len) = 0;
    *appendBuffer = tmp;
    return len;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r8, %rbx
movq %rcx, %r14
movq %rdx, %r13
movq %rsi, %r15
movq %rdi, -0x30(%rbp)
movq (%rsi), %rdi
leaq (%rcx,%r8), %rsi
incq %rsi
testq %rdi, %rdi
je 0x65c2
callq 0x46c0
jmp 0x65ca
movq %rsi, %rdi
callq 0x46b8
movq %rax, %r12
testq %rax, %rax
je 0x65ed
addq %r12, %r14
movq %r14, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x43a0
movb $0x0, (%rbx,%r14)
movq %r12, (%r15)
jmp 0x6606
leaq 0x4f30(%rip), %rsi      # 0xb524
xorl %ebx, %ebx
movl $0x4, %edi
movq -0x30(%rbp), %rdx
xorl %eax, %eax
callq 0x4230
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O1/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/ali_ws/wsc_buffer_mgmt.c
// Function: client_buf_mgmt_push
int client_buf_mgmt_push(const char *buf, size_t len, int msg_type)
{
	msg_buf_item *p_new_msg = NULL;
    char         *tmp = NULL;
    int           windex = 0;

    if(!buf || !g_ws_buf)
        return LE_ERROR_INVAILD_PARAM;

	pthread_mutex_lock(&g_ws_buf_state.locker);
    
    windex = g_ws_buf_state.wr_index;
	if (windex >= g_ws_buf_state.max_buf_cnt){
		g_ws_buf_state.wr_index = 0;
        windex = 0;
    }
    ++len;
    if(len > g_ws_buf_state.single_buf_size - LWS_PRE){
        tmp = realloc(g_ws_buf[windex].buf, len + LWS_PRE);    
        if(!tmp){
            printf("failed to alloc more memory to store msg\n");
            pthread_mutex_unlock(&g_ws_buf_state.locker);
            return LE_ERROR_ALLOCATING_MEM;
        }
        memset(tmp, 0, len + LWS_PRE);
        g_ws_buf[windex].buf = tmp;
    }

	memset(g_ws_buf[windex].buf, 0, g_ws_buf[windex].buf_len);
	memcpy(g_ws_buf[windex].buf + LWS_PRE, buf, len - 1);
	g_ws_buf[windex].buf[LWS_PRE + len - 1] = '\0';
	g_ws_buf[windex].buf_len = len;
	g_ws_buf[windex].type = msg_type;

	g_ws_buf_state.wr_index++;

	pthread_mutex_unlock(&g_ws_buf_state.locker);

    notify_network();
	return LE_SUCCESS;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl $0x186a1, %r12d         # imm = 0x186A1
testq %rdi, %rdi
je 0x6bb4
cmpq $0x0, 0x8ab0(%rip)      # 0xf560
je 0x6bb4
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, -0x48(%rbp)
leaq 0x8a62(%rip), %rdi      # 0xf528
callq 0x4680
movl 0x8a83(%rip), %eax      # 0xf554
cmpl 0x8a85(%rip), %eax      # 0xf55c
jl 0x6ae5
movl $0x0, 0x8a71(%rip)      # 0xf554
xorl %eax, %eax
leaq 0x1(%r14), %r15
movslq 0x8a68(%rip), %rcx      # 0xf558
addq $-0x10, %rcx
movslq %eax, %r12
cmpq %rcx, %r15
jbe 0x6b4c
movq %r15, -0x30(%rbp)
movq 0x8a59(%rip), %rax      # 0xf560
leaq (%r12,%r12,2), %rcx
movq %rax, -0x38(%rbp)
movq %rcx, %r15
movq (%rax,%rcx,8), %rdi
leaq 0x11(%r14), %rsi
movq %rsi, -0x40(%rbp)
callq 0x46c0
testq %rax, %rax
je 0x6bc6
movq %rax, %r13
movq -0x38(%rbp), %rax
leaq (%rax,%r15,8), %r15
movq %r13, %rdi
xorl %esi, %esi
movq -0x40(%rbp), %rdx
callq 0x42b0
movq %r13, (%r15)
movq -0x30(%rbp), %r15
movq 0x8a0d(%rip), %r13      # 0xf560
movl %ebx, -0x30(%rbp)
leaq (%r12,%r12,2), %rbx
movq (%r13,%rbx,8), %rdi
movq 0x8(%r13,%rbx,8), %rdx
xorl %r12d, %r12d
xorl %esi, %esi
callq 0x42b0
movq (%r13,%rbx,8), %rdi
addq $0x10, %rdi
movq -0x48(%rbp), %rsi
movq %r14, %rdx
callq 0x43a0
movq (%r13,%rbx,8), %rax
movb $0x0, 0x10(%rax,%r14)
movq %r15, 0x8(%r13,%rbx,8)
movl -0x30(%rbp), %eax
movl %eax, 0x10(%r13,%rbx,8)
leaq 0x8986(%rip), %rdi      # 0xf528
incl 0x89ac(%rip)            # 0xf554
callq 0x43e0
xorl %eax, %eax
callq 0x4040
movl %r12d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4ac3(%rip), %rdi      # 0xb690
callq 0x40d0
leaq 0x894f(%rip), %rdi      # 0xf528
callq 0x43e0
movl $0x186a2, %r12d         # imm = 0x186A2
jmp 0x6bb4
// File: /workspace/github_c_makefile_star2_O1/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/ali_ws/wsc_buffer_mgmt.c
// Function: client_buf_mgmt_pop
int client_buf_mgmt_pop(cb_del cb, void *usr)
{
	int ret = 0;
    int rindex = 0;

	pthread_mutex_lock(&g_ws_buf_state.locker);
    
    rindex = g_ws_buf_state.rd_index;
	if (rindex >= g_ws_buf_state.max_buf_cnt){
		g_ws_buf_state.rd_index = 0;
        rindex = 0; 
    }

	if (g_ws_buf[rindex].buf_len == 0) {
		pthread_mutex_unlock(&g_ws_buf_state.locker);
		return LE_SUCCESS;
	}
    
    ret = cb(g_ws_buf[rindex].buf + LWS_PRE, 
                        g_ws_buf[rindex].buf_len, g_ws_buf[rindex].type, usr);
    
    if(ret < g_ws_buf[rindex].buf_len){
        pthread_mutex_unlock(&g_ws_buf_state.locker);
        printf("failed to post msg to server.\n"); 
        return LE_ERROR_UNKNOWN;
    }
    g_ws_buf[rindex].buf_len = 0;
	g_ws_buf_state.rd_index++;
	pthread_mutex_unlock(&g_ws_buf_state.locker);
	
	notify_network();
	return LE_SUCCESS;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x892b(%rip), %rdi      # 0xf528
callq 0x4680
movl 0x8948(%rip), %eax      # 0xf550
cmpl 0x894e(%rip), %eax      # 0xf55c
jl 0x6c1c
movl $0x0, 0x8936(%rip)      # 0xf550
xorl %eax, %eax
movq 0x893d(%rip), %rcx      # 0xf560
cltq
leaq (%rax,%rax,2), %r15
movq 0x8(%rcx,%r15,8), %rsi
testq %rsi, %rsi
je 0x6c76
leaq (%rcx,%r15,8), %rax
movq (%rax), %rdi
addq $0x10, %rdi
movl 0x10(%rax), %edx
movq %r14, %rcx
callq *%rbx
movslq %eax, %rcx
movq 0x8910(%rip), %rax      # 0xf560
cmpq %rcx, 0x8(%rax,%r15,8)
jbe 0x6c86
leaq 0x88ca(%rip), %rdi      # 0xf528
callq 0x43e0
leaq 0x4a4f(%rip), %rdi      # 0xb6b9
callq 0x40d0
movl $0x186a0, %ebx          # imm = 0x186A0
jmp 0x6cb0
leaq 0x88ab(%rip), %rdi      # 0xf528
callq 0x43e0
xorl %ebx, %ebx
jmp 0x6cb0
leaq (%rax,%r15,8), %rax
addq $0x8, %rax
movq $0x0, (%rax)
leaq 0x888c(%rip), %rdi      # 0xf528
incl 0x88ae(%rip)            # 0xf550
callq 0x43e0
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x4040
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/ali_ws/wsc_buffer_mgmt.c
// Function: buf_mgmt_client_clear_msg
void buf_mgmt_client_clear_msg()
{
	int i = 0;
	pthread_mutex_lock(&g_ws_buf_state.locker);

	g_ws_buf_state.wr_index = 0;
	g_ws_buf_state.rd_index = 0;

	for (i = 0; i < MAX_MSG_BUF_COUNT; i++) {
		g_ws_buf[i].buf_len = 0;
	}
	pthread_mutex_unlock(&g_ws_buf_state.locker);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0x8860(%rip), %rdi      # 0xf528
callq 0x4680
movq $0x0, 0x8878(%rip) # 0xf550
movl $0x8, %eax
movq 0x887c(%rip), %rcx      # 0xf560
movq $0x0, (%rcx,%rax)
addq $0x18, %rax
cmpq $0xc8, %rax
jne 0x6ce4
leaq 0x8829(%rip), %rdi      # 0xf528
popq %rbp
jmp 0x43e0
// File: /workspace/github_c_makefile_star2_O1/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/ali_ws/wsc_buffer_mgmt.c
// Function: client_buf_mgmt_destroy
int client_buf_mgmt_destroy(void)
{
	int i = 0;
    
    if(!g_ws_buf)
        return 0;

	pthread_mutex_lock(&g_ws_buf_state.locker);
	for (i = 0; i < g_ws_buf_state.max_buf_cnt; i++) {
		if (NULL != g_ws_buf[i].buf)
			free(g_ws_buf[i].buf);
	}
    free(g_ws_buf);
    g_ws_buf = NULL;
	pthread_mutex_unlock(&g_ws_buf_state.locker);

	pthread_mutex_destroy(&g_ws_buf_state.locker);
    memset(&g_ws_buf_state, 0, sizeof(msg_buf_status));

    return LE_SUCCESS;
}

// Assembly:
cmpq $0x0, 0x8853(%rip)      # 0xf560
je 0x6da9
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
leaq 0x8807(%rip), %rdi      # 0xf528
callq 0x4680
cmpl $0x0, 0x882f(%rip)      # 0xf55c
jle 0x6d59
movq 0x882a(%rip), %rbx      # 0xf560
xorl %r14d, %r14d
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x6d46
callq 0x46b0
incq %r14
movslq 0x880c(%rip), %rax      # 0xf55c
addq $0x18, %rbx
cmpq %rax, %r14
jl 0x6d39
movq 0x8800(%rip), %rdi      # 0xf560
callq 0x46b0
xorl %r14d, %r14d
movq %r14, 0x87f1(%rip)      # 0xf560
leaq 0x87b2(%rip), %rbx      # 0xf528
movq %rbx, %rdi
callq 0x43e0
movq %rbx, %rdi
callq 0x4270
xorps %xmm0, %xmm0
movups %xmm0, 0x8798(%rip)     # 0xf528
movups %xmm0, 0x87a1(%rip)     # 0xf538
movups %xmm0, 0x87aa(%rip)     # 0xf548
movq %r14, 0x87b3(%rip)      # 0xf558
popq %rbx
popq %r14
popq %rbp
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/utility/json/cJSON.c
// Function: cJSON_InitHooks
CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks)
{
    if (hooks == NULL)
    {
        /* Reset hooks */
        global_hooks.allocate = malloc;
        global_hooks.deallocate = free;
        global_hooks.reallocate = realloc;
        return;
    }

    global_hooks.allocate = malloc;
    if (hooks->malloc_fn != NULL)
    {
        global_hooks.allocate = hooks->malloc_fn;
    }

    global_hooks.deallocate = free;
    if (hooks->free_fn != NULL)
    {
        global_hooks.deallocate = hooks->free_fn;
    }

    /* use realloc only if both free and malloc are used */
    global_hooks.reallocate = NULL;
    if ((global_hooks.allocate == malloc) && (global_hooks.deallocate == free))
    {
        global_hooks.reallocate = realloc;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq 0x8188(%rip), %rax      # 0xefb8
movq %rax, 0x85c9(%rip)      # 0xf400
testq %rdi, %rdi
je 0x6e83
movq (%rdi), %rdx
testq %rdx, %rdx
cmoveq %rax, %rdx
movq %rdx, 0x85b3(%rip)      # 0xf400
movq 0x811c(%rip), %rsi      # 0xef70
movq %rsi, 0x85ad(%rip)      # 0xf408
movq 0x8(%rdi), %rdi
testq %rdi, %rdi
cmoveq %rsi, %rdi
movq %rdi, 0x859b(%rip)      # 0xf408
xorl %ecx, %ecx
movq %rcx, 0x859a(%rip)      # 0xf410
xorq %rax, %rdx
xorq %rsi, %rdi
orq %rdx, %rdi
je 0x6e91
jmp 0x6e98
movq 0x80e6(%rip), %rax      # 0xef70
movq %rax, 0x8577(%rip)      # 0xf408
movq 0x8128(%rip), %rcx      # 0xefc0
movq %rcx, 0x8571(%rip)      # 0xf410
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/utility/json/cJSON.c
// Function: cJSON_ReplaceItemViaPointer
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement)
{
    if ((parent == NULL) || (replacement == NULL) || (item == NULL))
    {
        return false;
    }

    if (replacement == item)
    {
        return true;
    }

    replacement->next = item->next;
    replacement->prev = item->prev;

    if (replacement->next != NULL)
    {
        replacement->next->prev = replacement;
    }
    if (replacement->prev != NULL)
    {
        replacement->prev->next = replacement;
    }
    if (parent->child == item)
    {
        parent->child = replacement;
    }

    item->next = NULL;
    item->prev = NULL;
    cJSON_Delete(item);

    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
xorl %ebx, %ebx
testq %rsi, %rsi
je 0x880a
testq %rdi, %rdi
je 0x880a
testq %rdx, %rdx
je 0x880a
movl $0x1, %ebx
cmpq %rsi, %rdx
je 0x880a
movq (%rsi), %rax
movq %rax, (%rdx)
movq 0x8(%rsi), %rcx
movq %rcx, 0x8(%rdx)
testq %rax, %rax
je 0x87e6
movq %rdx, 0x8(%rax)
movq 0x8(%rdx), %rax
testq %rax, %rax
je 0x87f2
movq %rdx, (%rax)
cmpq %rsi, 0x10(%rdi)
jne 0x87fc
movq %rdx, 0x10(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, (%rsi)
movq %rsi, %rdi
callq 0x41a0
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/utility/json/cJSON.c
// Function: cJSON_Minify
CJSON_PUBLIC(void) cJSON_Minify(char *json)
{
    unsigned char *into = (unsigned char*)json;

    if (json == NULL)
    {
        return;
    }

    while (*json)
    {
        if (*json == ' ')
        {
            json++;
        }
        else if (*json == '\t')
        {
            /* Whitespace characters. */
            json++;
        }
        else if (*json == '\r')
        {
            json++;
        }
        else if (*json=='\n')
        {
            json++;
        }
        else if ((*json == '/') && (json[1] == '/'))
        {
            /* double-slash comments, to end of line. */
            while (*json && (*json != '\n'))
            {
                json++;
            }
        }
        else if ((*json == '/') && (json[1] == '*'))
        {
            /* multiline comments. */
            while (*json && !((*json == '*') && (json[1] == '/')))
            {
                json++;
            }
            json += 2;
        }
        else if (*json == '\"')
        {
            /* string literals, which are \" sensitive. */
            *into++ = (unsigned char)*json++;
            while (*json && (*json != '\"'))
            {
                if (*json == '\\')
                {
                    *into++ = (unsigned char)*json++;
                }
                *into++ = (unsigned char)*json++;
            }
            *into++ = (unsigned char)*json++;
        }
        else
        {
            /* All other characters. */
            *into++ = (unsigned char)*json++;
        }
    }

    /* and null-terminate. */
    *into = '\0';
}

// Assembly:
testq %rdi, %rdi
je 0x9040
pushq %rbp
movq %rsp, %rbp
movq %rdi, %rax
movb (%rdi), %cl
movzbl %cl, %edx
cmpl $0x1f, %edx
jg 0x8f8a
cmpl $0x9, %edx
jle 0x8f9f
cmpl $0xa, %edx
je 0x8fa1
cmpl $0xd, %edx
je 0x8fa1
jmp 0x8fef
cmpl $0x2f, %edx
je 0x8fa6
cmpl $0x22, %edx
je 0x9018
cmpl $0x20, %edx
je 0x8fa1
jmp 0x8fef
jne 0x8feb
incq %rdi
jmp 0x8f6f
cmpb $0x2f, 0x1(%rdi)
jne 0x8fbd
movzbl (%rdi), %ecx
testl %ecx, %ecx
je 0x8f6f
cmpl $0xa, %ecx
je 0x8f6f
incq %rdi
jmp 0x8fac
cmpl $0x22, %edx
je 0x9018
cmpl $0x2f, %edx
jne 0x8fef
cmpb $0x2a, 0x1(%rdi)
jne 0x8ffc
addq $0x2, %rdi
movzbl -0x2(%rdi), %ecx
cmpl $0x2a, %ecx
je 0x8fe0
testl %ecx, %ecx
jne 0x8fe6
jmp 0x8f6f
cmpb $0x2f, -0x1(%rdi)
je 0x8f6f
incq %rdi
jmp 0x8fd1
testl %edx, %edx
je 0x903c
incq %rdi
movb %cl, (%rax)
incq %rax
jmp 0x8f6f
cmpb $0x22, %cl
je 0x9018
jmp 0x8fef
incq %rax
incq %rdi
jmp 0x9016
addq $0x2, %rdi
movb %cl, 0x1(%rax)
addq $0x2, %rax
movb (%rdi), %cl
movb %cl, (%rax)
movzbl 0x1(%rdi), %ecx
cmpl $0x5c, %ecx
je 0x900b
testl %ecx, %ecx
je 0x902c
cmpl $0x22, %ecx
jne 0x9003
addq $0x2, %rdi
movb %cl, 0x1(%rax)
addq $0x2, %rax
jmp 0x8f6f
movb $0x0, (%rax)
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/utility/log/log.c
// Function: log_print
void log_print(LOG_LEVEL lvl, cchar *color, cchar *t, cchar *f, cchar *func, int l, cchar *fmt, ...)
{
    if (lvl < g_log_lvl) {
        return;
    }

    va_list ap;
    va_start(ap, fmt);

    char *tmp = NULL;
    char buf_date[20] = {0};
    time_t cur_time = time(NULL);

    t = !t ? "\b" : t;
    f = !f ? "\b" : f;
    func = !func ? "\b" : func;

    tmp = strrchr(f, '/');
    if (tmp) {
        f = tmp + 1;
    }

    //add color support
    if (color) {
        puts(color);
    }

    printf(LOG_FMT, get_timestamp(buf_date, 20, cur_time), g_log_desc[lvl], t, f, func, l);

    vprintf(fmt, ap);

    if (color) {
        puts(COL_DEF);
    }

    va_end(ap);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
testb %al, %al
je 0x9b4f
movaps %xmm0, -0xf0(%rbp)
movaps %xmm1, -0xe0(%rbp)
movaps %xmm2, -0xd0(%rbp)
movaps %xmm3, -0xc0(%rbp)
movaps %xmm4, -0xb0(%rbp)
movaps %xmm5, -0xa0(%rbp)
movaps %xmm6, -0x90(%rbp)
movaps %xmm7, -0x80(%rbp)
cmpl %edi, 0x58c3(%rip)      # 0xf418
ja 0x9c8d
movq %r8, %r14
movq %rcx, %r12
movq %rdx, %r15
movl %edi, %r13d
movl %r9d, -0x2c(%rbp)
leaq -0x120(%rbp), %rax
movq %rax, -0x40(%rbp)
leaq 0x18(%rbp), %rax
movq %rax, -0x48(%rbp)
movabsq $0x3000000030, %rax     # imm = 0x3000000030
movq %rax, -0x50(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x70(%rbp)
movl $0x0, -0x60(%rbp)
xorl %edi, %edi
movq %rsi, %rbx
callq 0x43c0
testq %r15, %r15
leaq 0x1be3(%rip), %rcx      # 0xb791
cmoveq %rcx, %r15
testq %r12, %r12
cmoveq %rcx, %r12
movq %rax, -0x38(%rbp)
testq %r14, %r14
cmoveq %rcx, %r14
movq %r12, %rdi
movl $0x2f, %esi
callq 0x4290
movq %rbx, %rdi
leaq 0x1(%rax), %rbx
testq %rax, %rax
cmoveq %r12, %rbx
testq %rdi, %rdi
je 0x9c42
callq 0x40d0
leaq -0x70(%rbp), %r12
movq %r12, %rdi
movq -0x38(%rbp), %rsi
callq 0x9c9f
movl %r13d, %eax
leaq 0x517d(%rip), %rcx      # 0xed80
movq (%rcx,%rax,8), %rdx
movl -0x2c(%rbp), %eax
movl %eax, (%rsp)
leaq 0x1b7f(%rip), %rdi      # 0xb793
movq %r12, %rsi
movq %r15, %rcx
movq %rbx, %r8
movq %r14, %r9
xorl %eax, %eax
callq 0x4240
leaq -0x50(%rbp), %rsi
movq 0x10(%rbp), %rdi
callq 0x4450
leaq 0x1b6f(%rip), %rdi      # 0xb7aa
callq 0x40d0
jmp 0x9c8d
leaq -0x70(%rbp), %r12
movq %r12, %rdi
movq -0x38(%rbp), %rsi
callq 0x9c9f
movl %r13d, %eax
leaq 0x5124(%rip), %rcx      # 0xed80
movq (%rcx,%rax,8), %rdx
movl -0x2c(%rbp), %eax
movl %eax, (%rsp)
leaq 0x1b26(%rip), %rdi      # 0xb793
movq %r12, %rsi
movq %r15, %rcx
movq %rbx, %r8
movq %r14, %r9
xorl %eax, %eax
callq 0x4240
leaq -0x50(%rbp), %rsi
movq 0x10(%rbp), %rdi
callq 0x4450
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/utility/log/log.c
// Function: get_timestamp
static char *get_timestamp(char *buf, int len, time_t cur_time)
{
    struct tm tm_time;

#ifndef _WIN32
    localtime_r(&cur_time, &tm_time);
#else
    localtime_s(&tm_time, &cur_time);
#endif

    snprintf(buf, len, "%d-%d-%d %d:%d:%d",
             1900 + tm_time.tm_year, 1 + tm_time.tm_mon,
             tm_time.tm_mday, tm_time.tm_hour,
             tm_time.tm_min, tm_time.tm_sec);
    return buf;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x40, %rsp
movq %rdi, %rbx
leaq -0x18(%rbp), %rdi
movq %rsi, (%rdi)
leaq -0x50(%rbp), %r14
movq %r14, %rsi
callq 0x4090
movl $0x76c, %ecx            # imm = 0x76C
addl 0x14(%r14), %ecx
movl 0x10(%r14), %r8d
incl %r8d
movl 0xc(%r14), %r9d
movl 0x8(%r14), %r10d
movl (%r14), %r11d
movl 0x4(%r14), %r14d
subq $0x8, %rsp
leaq 0x1ac5(%rip), %rdx      # 0xb7af
movl $0x14, %esi
movq %rbx, %rdi
xorl %eax, %eax
pushq %r11
pushq %r14
pushq %r10
callq 0x4280
addq $0x20, %rsp
movq %rbx, %rax
addq $0x40, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O1/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/utility/threadpool/threadpool.c
// Function: threadpool_create
threadpool_t *threadpool_create(int thread_count, int queue_size, int flags)
{
    threadpool_t *pool;
    int i;
    (void) flags;

    if(thread_count <= 0 || thread_count > MAX_THREADS || queue_size <= 0 || queue_size > MAX_QUEUE) {
        return NULL;
    }

    if((pool = (threadpool_t *)malloc(sizeof(threadpool_t))) == NULL) {
        goto err;
    }

    /* Initialize */
    pool->thread_count = 0;
    pool->queue_size = queue_size;
    pool->head = pool->tail = pool->count = 0;
    pool->shutdown = pool->started = 0;

    /* Allocate thread and task queue */
    pool->threads = (pthread_t *)malloc(sizeof(pthread_t) * thread_count);
    pool->queue = (threadpool_task_t *)malloc
        (sizeof(threadpool_task_t) * queue_size);

    /* Initialize mutex and conditional variable first */
    if((pthread_mutex_init(&(pool->lock), NULL) != 0) ||
       (pthread_cond_init(&(pool->notify), NULL) != 0) ||
       (pool->threads == NULL) ||
       (pool->queue == NULL)) {
        goto err;
    }

    /* Start worker threads */
    for(i = 0; i < thread_count; i++) {
        if(pthread_create(&(pool->threads[i]), NULL,
                          threadpool_thread, (void*)pool) != 0) {
            threadpool_destroy(pool, 0);
            return NULL;
        }
        pool->thread_count++;
        pool->started++;
    }

    return pool;

 err:
    if(pool) {
        threadpool_free(pool);
    }
    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %esi, %r15d
movl %edi, %r14d
leal -0x41(%r14), %eax
cmpl $-0x40, %eax
setb %al
leal -0x10001(%r15), %ecx
cmpl $0xffff0000, %ecx       # imm = 0xFFFF0000
setb %cl
orb %al, %cl
jne 0x9db3
movl $0x88, %edi
callq 0x46b8
xorl %r12d, %r12d
testq %rax, %rax
je 0x9db3
movq %rax, %rbx
movl %r12d, 0x68(%rax)
movl %r15d, 0x6c(%rax)
leal (,%r14,8), %edi
callq 0x46b8
xorps %xmm0, %xmm0
movups %xmm0, 0x70(%rbx)
movl %r12d, 0x80(%rbx)
movq %rax, 0x58(%rbx)
shll $0x4, %r15d
movq %r15, %rdi
callq 0x46b8
movq %rax, 0x60(%rbx)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x4660
testl %eax, %eax
jne 0x9dab
movq %rbx, %rdi
addq $0x28, %rdi
xorl %esi, %esi
callq 0x43d0
testl %eax, %eax
je 0x9dc1
movq %rbx, %rdi
callq 0x43b0
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
cmpq $0x0, 0x58(%rbx)
je 0x9dab
cmpq $0x0, 0x60(%rbx)
je 0x9dab
testl %r14d, %r14d
jle 0x9db5
movl %r14d, %r15d
shlq $0x3, %r15
xorl %r12d, %r12d
leaq 0x38(%rip), %r14        # 0x9e1d
movq 0x58(%rbx), %rdi
addq %r12, %rdi
xorl %esi, %esi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x44d0
testl %eax, %eax
jne 0x9e11
incl 0x68(%rbx)
incl 0x80(%rbx)
addq $0x8, %r12
cmpq %r12, %r15
jne 0x9de5
jmp 0x9db5
movq %rbx, %rdi
xorl %esi, %esi
callq 0x4580
jmp 0x9db3
// File: /workspace/github_c_makefile_star2_O1/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/utility/threadpool/threadpool.c
// Function: threadpool_thread
static void *threadpool_thread(void *threadpool)
{
    threadpool_t *pool = (threadpool_t *)threadpool;
    threadpool_task_t task;

    for(;;) {
        /* Lock must be taken to wait on conditional variable */
        pthread_mutex_lock(&(pool->lock));

        /* Wait on condition variable, check for spurious wakeups.
           When returning from pthread_cond_wait(), we own the lock. */
        while((pool->count == 0) && (!pool->shutdown)) {
            pthread_cond_wait(&(pool->notify), &(pool->lock));
        }

        if((pool->shutdown == immediate_shutdown) ||
           ((pool->shutdown == graceful_shutdown) &&
            (pool->count == 0))) {
            break;
        }

        /* Grab our task */
        task.function = pool->queue[pool->head].function;
        task.argument = pool->queue[pool->head].argument;
        pool->head = (pool->head + 1) % pool->queue_size;
        pool->count -= 1;

        /* Unlock */
        pthread_mutex_unlock(&(pool->lock));

        /* Get to work */
        (*(task.function))(task.argument);
    }

    pool->started--;

    pthread_mutex_unlock(&(pool->lock));
    pthread_exit(NULL);
    return(NULL);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
leaq 0x28(%rdi), %r14
movq %rbx, %rdi
callq 0x4680
movl 0x78(%rbx), %ecx
testl %ecx, %ecx
sete %al
jne 0x9e54
cmpl $0x0, 0x7c(%rbx)
jne 0x9e54
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4190
jmp 0x9e37
movl 0x7c(%rbx), %edx
cmpl $0x2, %edx
je 0x9e63
cmpl $0x1, %edx
jne 0x9e67
jmp 0x9e9b
testb %al, %al
jne 0x9e9b
movq 0x60(%rbx), %rdx
movslq 0x70(%rbx), %rsi
leal 0x1(%rsi), %eax
shlq $0x4, %rsi
movq (%rdx,%rsi), %r12
movq 0x8(%rdx,%rsi), %r15
cltd
idivl 0x6c(%rbx)
movl %edx, 0x70(%rbx)
decl %ecx
movl %ecx, 0x78(%rbx)
movq %rbx, %rdi
callq 0x43e0
movq %r15, %rdi
callq *%r12
jmp 0x9e2f
decl 0x80(%rbx)
movq %rbx, %rdi
callq 0x43e0
xorl %edi, %edi
callq 0x4410
// File: /workspace/github_c_makefile_star2_O1/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/utility/threadpool/threadpool.c
// Function: threadpool_destroy
int threadpool_destroy(threadpool_t *pool, int flags)
{
    int i, err = 0;

    if(pool == NULL) {
        return threadpool_invalid;
    }

    if(pthread_mutex_lock(&(pool->lock)) != 0) {
        return threadpool_lock_failure;
    }

    do {
        /* Already shutting down */
        if(pool->shutdown) {
            err = threadpool_shutdown;
            pthread_mutex_unlock(&(pool->lock));
            break;
        }

        pool->shutdown = (flags & threadpool_graceful) ?
            graceful_shutdown : immediate_shutdown;

        /* Wake up all worker threads */
        if(pthread_cond_broadcast(&(pool->notify)) != 0) {
            err = threadpool_lock_failure;
            pthread_mutex_unlock(&(pool->lock));
            break;
        }

        pthread_mutex_unlock(&(pool->lock));
        
        /* Join all worker thread */
        for(i = 0; i < pool->thread_count; i++) {
            if(pthread_join(pool->threads[i], NULL) != 0) {
                err = threadpool_thread_failure;
            }
        }
    } while(0);

    /* Only if everything went well do we deallocate the pool */
    if(!err) {
        threadpool_free(pool);
    }
    return err;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
testq %rdi, %rdi
je 0x9eef
movl %esi, %r15d
movq %rdi, %rbx
callq 0x4680
movl $0xfffffffe, %r14d      # imm = 0xFFFFFFFE
testl %eax, %eax
jne 0x9f60
cmpl $0x0, 0x7c(%rbx)
je 0x9ef7
movq %rbx, %rdi
callq 0x43e0
movl $0xfffffffc, %r14d      # imm = 0xFFFFFFFC
jmp 0x9f53
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
jmp 0x9f60
andl $0x1, %r15d
incl %r15d
movl %r15d, 0x7c(%rbx)
leaq 0x28(%rbx), %rdi
callq 0x40c0
movl %eax, %r15d
movq %rbx, %rdi
callq 0x43e0
testl %r15d, %r15d
jne 0x9f53
cmpl $0x0, 0x68(%rbx)
jle 0x9f50
xorl %r15d, %r15d
movl $0xfffffffb, %r12d      # imm = 0xFFFFFFFB
xorl %r14d, %r14d
movq 0x58(%rbx), %rax
movq (%rax,%r15,8), %rdi
xorl %esi, %esi
callq 0x4600
testl %eax, %eax
cmovnel %r12d, %r14d
incq %r15
movslq 0x68(%rbx), %rax
cmpq %rax, %r15
jl 0x9f2d
jmp 0x9f53
xorl %r14d, %r14d
testl %r14d, %r14d
jne 0x9f60
movq %rbx, %rdi
callq 0x43b0
movl %r14d, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/utility/threadpool/threadpool.c
// Function: threadpool_free
int threadpool_free(threadpool_t *pool)
{
    if(pool == NULL || pool->started > 0) {
        return -1;
    }

    /* Did we manage to allocate ? */
    if(pool->threads) {
        free(pool->threads);
        free(pool->queue);

#if 0   /* reth code  */ 
        /* Because we allocate pool->threads after initializing the
           mutex and condition variable, we're sure they're
           initialized. Let's lock the mutex just in case. */
        pthread_mutex_lock(&(pool->lock));
#endif
        pthread_mutex_destroy(&(pool->lock));
        pthread_cond_destroy(&(pool->notify));
    }
    free(pool);    
    return 0;
}

// Assembly:
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testq %rdi, %rdi
je 0x9fc0
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpl $0x0, 0x80(%rdi)
jg 0x9fba
movq 0x58(%rbx), %rdi
testq %rdi, %rdi
je 0x9fb0
callq 0x46b0
movq 0x60(%rbx), %rdi
callq 0x46b0
movq %rbx, %rdi
callq 0x4270
leaq 0x28(%rbx), %rdi
callq 0x4530
movq %rbx, %rdi
callq 0x46b0
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/utility/threadpool/threadpool.c
// Function: threadpool_add
int threadpool_add(threadpool_t *pool, void (*function)(void *),
                   void *argument, int flags)
{
    int err = 0;
    int next;
    (void) flags;

    if(pool == NULL || function == NULL) {
        return threadpool_invalid;
    }

    if(pthread_mutex_lock(&(pool->lock)) != 0) {
        return threadpool_lock_failure;
    }

    next = (pool->tail + 1) % pool->queue_size;

    do {
        /* Are we full ? */
        if(pool->count == pool->queue_size) {
            err = threadpool_queue_full;
            break;
        }

        /* Are we shutting down ? */
        if(pool->shutdown) {
            err = threadpool_shutdown;
            break;
        }

        /* Add task to queue */
        pool->queue[pool->tail].function = function;
        pool->queue[pool->tail].argument = argument;
        pool->tail = next;
        pool->count += 1;

        /* pthread_cond_broadcast */
        if(pthread_cond_signal(&(pool->notify)) != 0) {
            err = threadpool_lock_failure;
            break;
        }
    } while(0);

    if(pthread_mutex_unlock(&pool->lock) != 0) {
        err = threadpool_lock_failure;
    }

    return err;
}

// Assembly:
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jne 0xa070
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
callq 0x4680
movl %eax, %ecx
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
testl %ecx, %ecx
jne 0xa068
movslq 0x74(%rbx), %rcx
leal 0x1(%rcx), %eax
movl 0x6c(%rbx), %edi
movl 0x78(%rbx), %esi
cltd
idivl %edi
movl $0xfffffffd, %r12d      # imm = 0xFFFFFFFD
cmpl %edi, %esi
je 0xa055
movl $0xfffffffc, %r12d      # imm = 0xFFFFFFFC
cmpl $0x0, 0x7c(%rbx)
jne 0xa055
movq 0x60(%rbx), %rax
shlq $0x4, %rcx
movq %r15, (%rax,%rcx)
movq %r14, 0x8(%rax,%rcx)
movl %edx, 0x74(%rbx)
incl %esi
movl %esi, 0x78(%rbx)
leaq 0x28(%rbx), %rdi
callq 0x4340
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
leal -0x2(,%rcx,2), %r12d
movq %rbx, %rdi
callq 0x43e0
testl %eax, %eax
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
cmovel %r12d, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O1/anuwu[P]ERPLAG-Compiler/erplag.c
// Function: main
int main(int argc, char **argv)
{
	FILE *fpIn ;
	char *outputFile ;
	checkCommand (argc, argv, &outputFile) ;
 
 	if (!(fpIn = fopen (argv[1], "r")))
 	{
 		errFatal () ;
		#if defined __linux__ || defined __MACH__
 			printf ("Source file " ANSI_BOLD "%s" ANSI_RESET " does not exist\n", argv[1]) ;
		#endif
		#ifdef _WIN64
			printf ("Source file %s does not exist\n", argv[1]) ;
		#endif
 		exit (1) ;
 	}


	treeNode *root = parse (fpIn) ;
	if (root->syntax_error)
		exit (1) ;

	astNode *astRoot ;
	astRoot = applyASTRule (root) ;
	deletePT (root) ;
	
	realBase = fillSymbolTable (astRoot,0);

	if (!realBase->semanticError)
	{
		if (realPresent)
		{
			errCodegen () ;
			#if defined __linux__ || defined __MACH__
				printf ("Variables or static values of type " ANSI_BOLD ANSI_GREEN "real" ANSI_RESET " found in source file, which is not handled by the present version of the compiler.\n") ;
			#endif
			#ifdef _WIN64
				printf ("Variables or static values of type \"real\" found in source file, which is not handled by the present version of the compiler.\n") ;
			#endif
			exit (1) ;
		}

		int len ;
		if (!(fpOut = fopen (outputFile, "w")))
		{
			errFatal () ;
			#if defined __linux__ || defined __MACH__
				printf ("Error creating asm file " ANSI_BOLD "%s" ANSI_RESET "\n", outputFile) ;
			#endif
			#ifdef _WIN64
				printf ("Error creating asm file %s\n", outputFile) ;
			#endif
			exit (1) ;
		}

		preamble () ;
		codeGeneration (astRoot) ;
		postamble () ;
	}
	else
		exit (1) ;

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
leaq -0x18(%rbp), %rdx
callq 0x128c
movq 0x8(%rbx), %rdi
leaq 0x10df6(%rip), %rsi     # 0x12221
callq 0x1130
testq %rax, %rax
je 0x14ce
movq %rax, %rdi
callq 0xb7dc
cmpl $0x0, 0x24(%rax)
jne 0x150f
movq %rax, %r14
movq %rax, %rdi
callq 0x5eec
movq %rax, %rbx
movq %r14, %rdi
callq 0xbcc9
movq %rbx, %rdi
xorl %esi, %esi
callq 0xe1dd
leaq 0x30bb6(%rip), %rcx     # 0x32028
movq %rax, (%rcx)
cmpl $0x0, 0xd8(%rax)
jne 0x150f
leaq 0x30b9b(%rip), %rax     # 0x32024
cmpl $0x0, (%rax)
jne 0x14e2
movq -0x18(%rbp), %r14
leaq 0x10ec7(%rip), %rsi     # 0x12360
movq %r14, %rdi
callq 0x1130
movq %rax, 0x16ea0(%rip)     # 0x18348
testq %rax, %rax
je 0x14f7
xorl %eax, %eax
callq 0x3e92
movq %rbx, %rdi
callq 0x3d38
xorl %eax, %eax
callq 0x4380
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
xorl %eax, %eax
callq 0xf17f
movq 0x8(%rbx), %rsi
leaq 0xeb24(%rip), %rdi      # 0x10004
jmp 0x1508
xorl %eax, %eax
callq 0xf263
leaq 0xec02(%rip), %rdi      # 0x100f2
callq 0x1070
jmp 0x150f
xorl %eax, %eax
callq 0xf17f
leaq 0xeb26(%rip), %rdi      # 0x1002b
movq %r14, %rsi
xorl %eax, %eax
callq 0x10b0
movl $0x1, %edi
callq 0x1160
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O1/anuwu[P]ERPLAG-Compiler/codegen.c
// Function: codeComment
void codeComment (int tabCount, char *comment)
{
	int i ;
	for (i = 0 ; i < tabCount ; i++)
		codePrint ("\t") ;

	codePrint ("; %s\n", comment) ;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
testl %edi, %edi
jle 0x1567
movl %edi, %r14d
leaq 0x16df3(%rip), %r15     # 0x18348
movq (%r15), %rsi
movl $0x9, %edi
callq 0x10e0
decl %r14d
jne 0x1555
leaq 0x16dda(%rip), %rax     # 0x18348
movq (%rax), %rdi
leaq 0xecac(%rip), %rsi      # 0x10224
movq %rbx, %rdx
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x1100