// File: /workspace/github_c_makefile_star2_O3/qq-smart[P]qq_sh_server/app/qq_wifi_device.c
// Function: qq_wifi_device_connection_package_process
static void
qq_wifi_device_connection_package_process(qq_connection_t *c, cJSON *root)
{
    qq_wifi_device_t       *wd;
    qq_int_t                reason;
    cJSON                  *json_id, *json_mac, *json_pwd;
    u_char                  id[16], mac[6], pwd[16];

    qq_log_debug("qq_wifi_device_connection_package_process(%s)", root);

    json_id = cJSON_GetObjectItem(root, QQ_PKG_KEY_DEV_ID);
    json_mac = cJSON_GetObjectItem(root, QQ_PKG_KEY_MAC);
    json_pwd = cJSON_GetObjectItem(root, QQ_PKG_KEY_PWD);

    if (json_id != NULL && json_id->type == cJSON_String && strlen(json_id->valuestring) == 32 &&
        json_mac != NULL && json_mac->type == cJSON_String && strlen(json_mac->valuestring) == 12 &&
        json_pwd != NULL && json_pwd->type == cJSON_String && strlen(json_pwd->valuestring) == 32)
    {
        if (qq_str_to_hex(json_id->valuestring, id, 32) == QQ_ERROR ||
            qq_str_to_hex(json_mac->valuestring, mac, 12) == QQ_ERROR ||
            qq_str_to_hex(json_pwd->valuestring, pwd, 32) == QQ_ERROR)
        {
            qq_wifi_device_close(c, QQ_WIFI_DEVICE_PKG_FAILED);
            return;
        }

        if (qq_wifi_device_md5_confirm(json_id->valuestring, pwd) == QQ_WIFI_DEVICE_MD5_FAILED) {
            qq_wifi_device_close(c, QQ_WIFI_DEVICE_MD5_FAILED);
            return;
        }

        if (qq_wifi_device_conflict_confirm(id, mac) == QQ_WIFI_DEVICE_CONFLICT) {
            qq_wifi_device_close(c, QQ_WIFI_DEVICE_CONFLICT);
            return;
        }

        if ((reason = qq_wifi_device_mysql_confirm(c, json_id->valuestring)) != QQ_OK) {
            qq_wifi_device_close(c, reason);
            return;
        }

        c->send(c, QQ_JSON_PKG_OK_STR, QQ_JSON_PKG_OK_STR_SIZE);

        wd = c->data;
        wd->connection = 1;
        qq_event_add_timer(c->read, QQ_WIFI_DEVICE_FIRST_STATUS_TIMEOUT);
        return;
    }

    qq_wifi_device_close(c, QQ_WIFI_DEVICE_PKG_FAILED);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x2217(%rip), %rdi      # 0xb319
xorl %eax, %eax
callq 0x6c74
leaq 0x2237(%rip), %rsi      # 0xb347
movq %r15, %rdi
callq 0x44d0
movq %rax, %r14
leaq 0x222c(%rip), %rsi      # 0xb34e
movq %r15, %rdi
callq 0x44d0
movq %rax, %r12
leaq 0x221e(%rip), %rsi      # 0xb352
movq %r15, %rdi
callq 0x44d0
testq %r14, %r14
je 0x9220
cmpl $0x4, 0x18(%r14)
jne 0x9220
movq %rax, %r15
movq 0x20(%r14), %r13
movq %r13, %rdi
callq 0x20d0
cmpq $0x20, %rax
sete %al
testq %r12, %r12
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x9220
cmpl $0x4, 0x18(%r12)
jne 0x9220
movq 0x20(%r12), %rdi
callq 0x20d0
cmpq $0xc, %rax
sete %al
testq %r15, %r15
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x9220
cmpl $0x4, 0x18(%r15)
jne 0x9220
movq 0x20(%r15), %rdi
callq 0x20d0
cmpq $0x20, %rax
jne 0x9220
leaq -0x50(%rbp), %rsi
movl $0x20, %edx
movq %r13, %rdi
callq 0x8642
cmpq $-0x1, %rax
je 0x9243
movq 0x20(%r12), %rdi
leaq -0x2e(%rbp), %rsi
movl $0xc, %edx
callq 0x8642
cmpq $-0x1, %rax
je 0x9243
movq 0x20(%r15), %rdi
leaq -0x40(%rbp), %rsi
movl $0x20, %edx
callq 0x8642
cmpq $-0x1, %rax
je 0x9243
movq 0x20(%r14), %rdi
leaq -0x40(%rbp), %rsi
callq 0x951d
cmpq $0x2, %rax
jne 0x9264
leaq 0x2179(%rip), %rsi      # 0xb392
movl $0x20, %edx
jmp 0x9283
movq 0x30(%rbx), %rax
leaq 0x2143(%rip), %rsi      # 0xb36e
movl $0x24, %edx
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
leaq 0x2124(%rip), %rsi      # 0xb36e
movl $0x24, %edx
movq %rbx, %rdi
callq *0x30(%rbx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0x50(%rbp), %rdi
leaq -0x2e(%rbp), %rsi
callq 0x95ac
cmpq $0x7, %rax
jne 0x9293
leaq 0x21c1(%rip), %rsi      # 0xb43f
movl $0x25, %edx
movq %rbx, %rdi
callq *0x30(%rbx)
movq %rbx, %rdi
callq 0x26a2
jmp 0x9255
movq 0x20(%r14), %rsi
movq %rbx, %rdi
callq 0x965a
testq %rax, %rax
je 0x92b1
movq %rbx, %rdi
movq %rax, %rsi
callq 0x946d
jmp 0x9255
leaq 0x209e(%rip), %rsi      # 0xb356
movl $0x18, %edx
movq %rbx, %rdi
callq *0x30(%rbx)
movq (%rbx), %rax
orb $0x1, 0x118(%rax)
movq 0x8(%rbx), %rdi
movl $0xbb8, %esi            # imm = 0xBB8
callq 0x907c
jmp 0x9255