// File: /workspace/github_c_makefile_star2_O0/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
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x0, -0x28(%rbp)
movl $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0x6997
jmp 0x6b4c
movq -0x8(%rbp), %rax
movl $0x1, %edi
leaq 0x789b(%rip), %rsi      # 0xe242
leaq 0x76e8(%rip), %rdx      # 0xe096
leaq 0x76e6(%rip), %rcx      # 0xe09b
leaq 0x7a91(%rip), %r8       # 0xe44d
movl $0x2f9, %r9d            # imm = 0x2F9
leaq 0x7a8f(%rip), %r10      # 0xe458
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x42b0
movq -0x8(%rbp), %rdi
callq 0x42a0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x69f2
jmp 0x6b4c
movl $0x28, %edi
callq 0x4798
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x6a4e
movq -0x20(%rbp), %rdi
callq 0x41e0
movl $0x3, %edi
leaq 0x7674(%rip), %rsi      # 0xe090
leaq 0x7673(%rip), %rdx      # 0xe096
leaq 0x7671(%rip), %rcx      # 0xe09b
leaq 0x7a1c(%rip), %r8       # 0xe44d
movl $0x302, %r9d            # imm = 0x302
leaq 0x7a2b(%rip), %rax      # 0xe469
movq %rax, (%rsp)
movb $0x0, %al
callq 0x42b0
jmp 0x6b4c
movq -0x40(%rbp), %rdi
xorl %esi, %esi
movl $0x28, %edx
callq 0x4300
movq -0x20(%rbp), %rdi
movq -0x40(%rbp), %rsi
addq $0x4, %rsi
movq -0x40(%rbp), %rdx
addq $0x8, %rdx
leaq -0x38(%rbp), %rcx
leaq -0x28(%rbp), %r8
callq 0x44b0
movl %eax, %ecx
movq -0x40(%rbp), %rax
movl %ecx, (%rax)
cmpq $0x0, -0x38(%rbp)
je 0x6aad
movq -0x40(%rbp), %rdi
addq $0xc, %rdi
movq -0x38(%rbp), %rcx
movl $0x10, %esi
leaq 0x7aab(%rip), %rdx      # 0xe551
movb $0x0, %al
callq 0x42d0
cmpq $0x0, -0x28(%rbp)
je 0x6b27
movq -0x28(%rbp), %rdi
movl $0x1, %esi
callq 0x4600
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x40(%rbp), %rax
cmpq $0x0, 0x20(%rax)
jne 0x6b25
movl $0x3, %edi
leaq 0x75ac(%rip), %rsi      # 0xe090
leaq 0x75ab(%rip), %rdx      # 0xe096
leaq 0x75a9(%rip), %rcx      # 0xe09b
leaq 0x7954(%rip), %r8       # 0xe44d
movl $0x30e, %r9d            # imm = 0x30E
leaq 0x75f2(%rip), %rax      # 0xe0f8
movq %rax, (%rsp)
movb $0x0, %al
callq 0x42b0
movq -0x40(%rbp), %rdi
callq 0x4790
movq -0x20(%rbp), %rdi
callq 0x41e0
jmp 0x6b4c
jmp 0x6b27
movq -0x20(%rbp), %rdi
callq 0x41e0
movq 0xb451(%rip), %rax      # 0x11f88
movq (%rax), %rdi
movq -0x40(%rbp), %rdx
movq 0xb4a3(%rip), %rsi      # 0x11fe8
xorl %ecx, %ecx
callq 0x4240
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)