// File: /workspace/github_c_makefile_star2_O3/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 0x619a
movq %rdi, %rbx
movq %rdi, 0x8(%rsp)
leaq 0x43e9(%rip), %rax      # 0xa458
movq %rax, (%rsp)
leaq 0x41c8(%rip), %rsi      # 0xa242
leaq 0x4015(%rip), %rdx      # 0xa096
leaq 0x4013(%rip), %rcx      # 0xa09b
leaq 0x43be(%rip), %r8       # 0xa44d
movl $0x1, %edi
movl $0x2f9, %r9d            # imm = 0x2F9
xorl %eax, %eax
callq 0x4260
movq %rbx, %rdi
callq 0x4250
testq %rax, %rax
je 0x619a
movq %rax, %rbx
movl $0x1, %edi
movl $0x28, %esi
callq 0x4370
testq %rax, %rax
je 0x6159
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 0x4430
movl %eax, (%r14)
movq (%r15), %rcx
testq %rcx, %rcx
je 0x6110
movq %r14, %rdi
addq $0xc, %rdi
leaq 0x4445(%rip), %rdx      # 0xa549
movl $0x10, %esi
xorl %eax, %eax
callq 0x4280
movq -0x20(%rbp), %rdi
testq %rdi, %rdi
je 0x612c
movl $0x1, %esi
callq 0x4570
movq %rax, 0x20(%r14)
testq %rax, %rax
je 0x61a5
movq %rbx, %rdi
callq 0x41a0
movq 0x7e4d(%rip), %rax      # 0xdf88
movq (%rax), %rdi
movq 0x7ea3(%rip), %rsi      # 0xdfe8
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 0x4301(%rip), %rax      # 0xa469
movq %rax, (%rsp)
leaq 0x3f1d(%rip), %rsi      # 0xa090
leaq 0x3f1c(%rip), %rdx      # 0xa096
leaq 0x3f1a(%rip), %rcx      # 0xa09b
leaq 0x42c5(%rip), %r8       # 0xa44d
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 0x3f4c(%rip), %rax      # 0xa0f8
movq %rax, (%rsp)
leaq 0x3ed9(%rip), %rsi      # 0xa090
leaq 0x3ed8(%rip), %rdx      # 0xa096
leaq 0x3ed6(%rip), %rcx      # 0xa09b
leaq 0x4281(%rip), %r8       # 0xa44d
movl $0x3, %edi
movl $0x30e, %r9d            # imm = 0x30E
xorl %eax, %eax
callq 0x4260
movq %r14, %rdi
callq 0x46d0
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x41a0