// File: /workspace/github_c_makefile_star2_O3/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/leda.c
// Function: threadpool_recv_proc
void threadpool_recv_proc(void *arg)
{
    parsed_msg_t *parsed_msg;
    char *payload_str = NULL, *pk, *dn;
    cJSON *item, *service_name;
    leda_device_data_t *data = NULL;
    int data_cnt = 0;

    if (!arg) {
        return;
    }
    parsed_msg = (parsed_msg_t *)arg;

    if (parsed_msg->msg_type == MSG_RSP) {
        payload_str = cJSON_Print(parsed_msg->payload);
        if (wsa_set_reply_result(parsed_msg->msg_id, parsed_msg->code, payload_str) < 0) {
            if (g_devs_cb.report_reply_cb) {
                g_devs_cb.report_reply_cb(parsed_msg->msg_id, parsed_msg->code, g_devs_cb.usr_data_report_reply);
            }
        }
        if (payload_str) {
            free(payload_str);
        }
        goto end;
    } else if (parsed_msg->msg_type == MSG_METHOD) {
        item = cJSON_GetObjectItem(parsed_msg->payload, "productKey");
        if (!item) {
            goto end;
        }
        pk = item->valuestring;
        item = cJSON_GetObjectItem(parsed_msg->payload, "deviceName");
        if (!item) {
            goto end;
        }
        dn = item->valuestring;
        item = cJSON_GetObjectItem(parsed_msg->payload, "properties");
        if (!item) {
            item = cJSON_GetObjectItem(parsed_msg->payload, "inputData");
        }
        if (!item) {
            goto end;
        }
        
        if (LE_SUCCESS != json_data_to_struct_data(item, &data, &data_cnt)) {
            goto end;
        }
        if (0 == strcmp(parsed_msg->method, METHOD_GET_PROPERTY)) {
            leda_rsp_get_properties(pk, dn, parsed_msg->msg_id, data, data_cnt);
        } else if (0 == strcmp(parsed_msg->method, METHOD_SET_PROPERTY)) {
            leda_rsp_set_properties(pk, dn, parsed_msg->msg_id, data, data_cnt);
        } else if (0 == strcmp(parsed_msg->method, METHOD_CALL_SERVICE)) {
            service_name = cJSON_GetObjectItem(parsed_msg->payload, "identifier");
            if (!service_name) {
                goto end;
            }
            leda_rsp_call_service(pk, dn, parsed_msg->msg_id, service_name->valuestring, data, data_cnt);
        } else {
            goto end;
        }
    } else {
        goto end;
    }

end:
    if (parsed_msg) {
        if (parsed_msg->payload) {
            cJSON_Delete(parsed_msg->payload);
        }
        free(parsed_msg);
    }
    if (data) {
        free(data);
    }
    return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq $0x0, -0x30(%rbp)
movl $0x0, -0x24(%rbp)
testq %rdi, %rdi
je 0x5c2e
movq %rdi, %rbx
movl (%rdi), %eax
cmpl $0x1, %eax
je 0x5b8e
testl %eax, %eax
jne 0x5bfe
movq 0x20(%rbx), %rdi
callq 0x40b0
movq %rax, %r14
movl 0x4(%rbx), %edi
movl 0x8(%rbx), %esi
movq %rax, %rdx
callq 0x41b0
testq %r14, %r14
je 0x5bfe
movq %r14, %rdi
callq 0x46d0
jmp 0x5bfe
movq 0x20(%rbx), %rdi
leaq 0x466d(%rip), %rsi      # 0xa206
callq 0x40a0
testq %rax, %rax
je 0x5bfe
movq 0x20(%rax), %r14
movq 0x20(%rbx), %rdi
leaq 0x465f(%rip), %rsi      # 0xa211
callq 0x40a0
testq %rax, %rax
je 0x5bfe
movq 0x20(%rax), %r15
movq 0x20(%rbx), %rdi
leaq 0x46f8(%rip), %rsi      # 0xa2c3
callq 0x40a0
testq %rax, %rax
jne 0x5bea
movq 0x20(%rbx), %rdi
leaq 0x4798(%rip), %rsi      # 0xa378
callq 0x40a0
testq %rax, %rax
je 0x5bfe
leaq -0x30(%rbp), %rsi
leaq -0x24(%rbp), %rdx
movq %rax, %rdi
callq 0x4150
testl %eax, %eax
je 0x5c3b
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x5c0c
callq 0x41a0
movq %rbx, %rdi
callq 0x46d0
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
je 0x5c2e
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x46d0
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0xc(%rbx), %r12
leaq 0x473c(%rip), %rsi      # 0xa382
movq %r12, %rdi
callq 0x4380
testl %eax, %eax
je 0x5cb0
leaq 0x4735(%rip), %rsi      # 0xa38e
movq %r12, %rdi
callq 0x4380
testl %eax, %eax
je 0x5ccb
leaq 0x472e(%rip), %rsi      # 0xa39a
movq %r12, %rdi
callq 0x4380
testl %eax, %eax
jne 0x5bfe
movq 0x20(%rbx), %rdi
leaq 0x43f7(%rip), %rsi      # 0xa07a
callq 0x40a0
testq %rax, %rax
je 0x5bfe
movl 0x4(%rbx), %edx
movq 0x20(%rax), %rcx
movq -0x30(%rbp), %r8
movl -0x24(%rbp), %r9d
movq %r14, %rdi
movq %r15, %rsi
callq 0x4100
jmp 0x5bfe
movl 0x4(%rbx), %edx
movq -0x30(%rbp), %rcx
movl -0x24(%rbp), %r8d
movq %r14, %rdi
movq %r15, %rsi
callq 0x4550
jmp 0x5bfe
movl 0x4(%rbx), %edx
movq -0x30(%rbp), %rcx
movl -0x24(%rbp), %r8d
movq %r14, %rdi
movq %r15, %rsi
callq 0x42a0
jmp 0x5bfe