// File: /workspace/github_c_makefile_star2_O2/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
andq $0x0, -0x30(%rbp)
andl $0x0, -0x24(%rbp)
testq %rdi, %rdi
je 0x5b62
movq %rdi, %rbx
movl (%rdi), %eax
cmpl $0x1, %eax
je 0x5b6f
testl %eax, %eax
jne 0x5bdf
movq 0x20(%rbx), %rdi
callq 0x40e0
movq %rax, %r14
movl 0x4(%rbx), %edi
movl 0x8(%rbx), %esi
movq %rax, %rdx
callq 0x41e0
movq %r14, %rdi
callq 0x4750
jmp 0x5bdf
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x20(%rbx), %rdi
leaq 0x468c(%rip), %rsi      # 0xa206
callq 0x40d0
testq %rax, %rax
je 0x5bdf
movq 0x20(%rax), %r14
movq 0x20(%rbx), %rdi
leaq 0x467e(%rip), %rsi      # 0xa211
callq 0x40d0
testq %rax, %rax
je 0x5bdf
movq 0x20(%rax), %r15
movq 0x20(%rbx), %rdi
leaq 0x4717(%rip), %rsi      # 0xa2c3
callq 0x40d0
testq %rax, %rax
jne 0x5bcb
movq 0x20(%rbx), %rdi
leaq 0x47b7(%rip), %rsi      # 0xa378
callq 0x40d0
testq %rax, %rax
je 0x5bdf
leaq -0x30(%rbp), %rsi
leaq -0x24(%rbp), %rdx
movq %rax, %rdi
callq 0x4180
testl %eax, %eax
je 0x5c0a
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x5bed
callq 0x41d0
movq %rbx, %rdi
callq 0x4750
movq -0x30(%rbp), %rdi
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x4750
leaq 0xc(%rbx), %r12
leaq 0x476d(%rip), %rsi      # 0xa382
movq %r12, %rdi
callq 0x43b0
testl %eax, %eax
je 0x5c7b
leaq 0x4766(%rip), %rsi      # 0xa38e
movq %r12, %rdi
callq 0x43b0
testl %eax, %eax
je 0x5c96
leaq 0x475f(%rip), %rsi      # 0xa39a
movq %r12, %rdi
callq 0x43b0
testl %eax, %eax
jne 0x5bdf
movq 0x20(%rbx), %rdi
leaq 0x4428(%rip), %rsi      # 0xa07a
callq 0x40d0
testq %rax, %rax
je 0x5bdf
movl 0x4(%rbx), %edx
movq 0x20(%rax), %rcx
movq -0x30(%rbp), %r8
movl -0x24(%rbp), %r9d
movq %r14, %rdi
movq %r15, %rsi
callq 0x4130
jmp 0x5bdf
movl 0x4(%rbx), %edx
movq -0x30(%rbp), %rcx
movl -0x24(%rbp), %r8d
movq %r14, %rdi
movq %r15, %rsi
callq 0x45b0
jmp 0x5bdf
movl 0x4(%rbx), %edx
movq -0x30(%rbp), %rcx
movl -0x24(%rbp), %r8d
movq %r14, %rdi
movq %r15, %rsi
callq 0x42d0
jmp 0x5bdf