// File: /workspace/github_c_makefile_star2_O1/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
xorl %eax, %eax
movq %rax, -0x20(%rbp)
movq %rax, -0x28(%rbp)
testq %rdi, %rdi
je 0x6180
movq %rdi, %rbx
movq %rdi, 0x8(%rsp)
leaq 0x5410(%rip), %rax      # 0xb458
movq %rax, (%rsp)
leaq 0x51ef(%rip), %rsi      # 0xb242
leaq 0x503c(%rip), %rdx      # 0xb096
leaq 0x503a(%rip), %rcx      # 0xb09b
leaq 0x53e5(%rip), %r8       # 0xb44d
movl $0x1, %edi
movl $0x2f9, %r9d            # imm = 0x2F9
xorl %eax, %eax
callq 0x4260
movq %rbx, %rdi
callq 0x4250
testq %rax, %rax
je 0x6180
movq %rax, %rbx
movl $0x28, %edi
callq 0x46b8
testq %rax, %rax
je 0x613f
movq %rax, %r14
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
movq $0x0, 0x20(%rax)
leaq 0x4(%rax), %rsi
leaq 0x8(%rax), %rdx
leaq -0x28(%rbp), %r15
leaq -0x20(%rbp), %r8
movq %rbx, %rdi
movq %r15, %rcx
callq 0x4400
movl %eax, (%r14)
movq (%r15), %rcx
testq %rcx, %rcx
je 0x60f6
movq %r14, %rdi
addq $0xc, %rdi
leaq 0x5463(%rip), %rdx      # 0xb54d
movl $0x10, %esi
xorl %eax, %eax
callq 0x4280
movq -0x20(%rbp), %rdi
testq %rdi, %rdi
je 0x6112
movl $0x1, %esi
callq 0x4540
movq %rax, 0x20(%r14)
testq %rax, %rax
je 0x618b
movq %rbx, %rdi
callq 0x41a0
movq 0x8e67(%rip), %rax      # 0xef88
movq (%rax), %rdi
movq 0x8ebd(%rip), %rsi      # 0xefe8
movq %r14, %rdx
xorl %ecx, %ecx
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x41f0
movq %rbx, %rdi
callq 0x41a0
leaq 0x531b(%rip), %rax      # 0xb469
movq %rax, (%rsp)
leaq 0x4f37(%rip), %rsi      # 0xb090
leaq 0x4f36(%rip), %rdx      # 0xb096
leaq 0x4f34(%rip), %rcx      # 0xb09b
leaq 0x52df(%rip), %r8       # 0xb44d
movl $0x3, %edi
movl $0x302, %r9d            # imm = 0x302
xorl %eax, %eax
callq 0x4260
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4f66(%rip), %rax      # 0xb0f8
movq %rax, (%rsp)
leaq 0x4ef3(%rip), %rsi      # 0xb090
leaq 0x4ef2(%rip), %rdx      # 0xb096
leaq 0x4ef0(%rip), %rcx      # 0xb09b
leaq 0x529b(%rip), %r8       # 0xb44d
movl $0x3, %edi
movl $0x30e, %r9d            # imm = 0x30E
xorl %eax, %eax
callq 0x4260
movq %r14, %rdi
callq 0x46b0
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x41a0