// File: /workspace/github_c_makefile_star2_O2/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/leda.c
// Function: cb_ws_recv
static void cb_ws_recv(const char *msg, size_t len, void *user)
{
    cJSON *root, *payload = NULL;
    int msg_type, msg_id = 0;
    char *method = NULL;
    parsed_msg_t *parsed_msg;
    
    if (!msg) {
        return;
    }
    log_i(LOG_TAG, "received msg: %s", msg);

    root = cJSON_Parse(msg);
    if (!root) {
        return;
    }
    parsed_msg = malloc(sizeof(parsed_msg_t));
    if (!parsed_msg) {
        cJSON_Delete(root);
        log_e(LOG_TAG, "no memory!\n");
        return;
    }
    memset(parsed_msg, 0, sizeof(parsed_msg_t));
    
    parsed_msg->msg_type = leda_parse_received_msg(root, &parsed_msg->msg_id, &parsed_msg->code, &method, &payload);
    if (method) {
        snprintf(parsed_msg->method, sizeof(parsed_msg->method), "%s", method);
    }
    if (payload) {
        parsed_msg->payload = cJSON_Duplicate(payload, 1);
        if (!parsed_msg->payload) {
            log_e(LOG_TAG, "no memory!");
            free(parsed_msg);
            cJSON_Delete(root);
            return;
        }
    }
    cJSON_Delete(root);

    threadpool_add(g_threadpool_recv_proc, threadpool_recv_proc, (void *)parsed_msg, 0);     

    return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x28, %rsp
andq $0x0, -0x20(%rbp)
andq $0x0, -0x28(%rbp)
testq %rdi, %rdi
je 0x6140
movq %rdi, %rbx
movq %rdi, 0x8(%rsp)
leaq 0x4437(%rip), %rax      # 0xa458
movq %rax, (%rsp)
leaq 0x4216(%rip), %rsi      # 0xa242
leaq 0x4063(%rip), %rdx      # 0xa096
leaq 0x4061(%rip), %rcx      # 0xa09b
leaq 0x440c(%rip), %r8       # 0xa44d
pushq $0x1
popq %rdi
movl $0x2f9, %r9d            # imm = 0x2F9
xorl %eax, %eax
callq 0x4290
movq %rbx, %rdi
callq 0x4280
testq %rax, %rax
je 0x6140
movq %rax, %rbx
pushq $0x1
popq %rdi
pushq $0x28
popq %rsi
callq 0x43a0
testq %rax, %rax
je 0x6101
movq %rax, %r14
leaq 0x4(%rax), %rsi
leaq 0x8(%rax), %rdx
leaq -0x28(%rbp), %r15
leaq -0x20(%rbp), %r8
movq %rbx, %rdi
movq %r15, %rcx
callq 0x4490
movl %eax, (%r14)
movq (%r15), %rcx
testq %rcx, %rcx
je 0x60ba
movq %r14, %rdi
addq $0xc, %rdi
leaq 0x4499(%rip), %rdx      # 0xa549
pushq $0x10
popq %rsi
xorl %eax, %eax
callq 0x42b0
movq -0x20(%rbp), %rdi
testq %rdi, %rdi
je 0x60d4
pushq $0x1
popq %rsi
callq 0x45d0
movq %rax, 0x20(%r14)
testq %rax, %rax
je 0x614b
movq %rbx, %rdi
callq 0x41d0
movq 0x7ea5(%rip), %rax      # 0xdf88
movq (%rax), %rdi
movq 0x7efb(%rip), %rsi      # 0xdfe8
movq %r14, %rdx
xorl %ecx, %ecx
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x4220
movq %rbx, %rdi
callq 0x41d0
leaq 0x4359(%rip), %rax      # 0xa469
movq %rax, (%rsp)
leaq 0x3f75(%rip), %rsi      # 0xa090
leaq 0x3f74(%rip), %rdx      # 0xa096
leaq 0x3f72(%rip), %rcx      # 0xa09b
leaq 0x431d(%rip), %r8       # 0xa44d
pushq $0x3
popq %rdi
movl $0x302, %r9d            # imm = 0x302
xorl %eax, %eax
callq 0x4290
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3fa6(%rip), %rax      # 0xa0f8
movq %rax, (%rsp)
leaq 0x3f33(%rip), %rsi      # 0xa090
leaq 0x3f32(%rip), %rdx      # 0xa096
leaq 0x3f30(%rip), %rcx      # 0xa09b
leaq 0x42db(%rip), %r8       # 0xa44d
pushq $0x3
popq %rdi
movl $0x30e, %r9d            # imm = 0x30E
xorl %eax, %eax
callq 0x4290
movq %r14, %rdi
callq 0x4750
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x41d0