// File: /workspace/github_c_makefile_star2_O1/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 0x2099(%rip), %rdi      # 0xb329
xorl %eax, %eax
callq 0x6daa
leaq 0x20b9(%rip), %rsi      # 0xb357
movq %r15, %rdi
callq 0x44ae
movq %rax, %r14
leaq 0x20ae(%rip), %rsi      # 0xb35e
movq %r15, %rdi
callq 0x44ae
movq %rax, %r12
leaq 0x20a0(%rip), %rsi      # 0xb362
movq %r15, %rdi
callq 0x44ae
testq %r14, %r14
je 0x93ae
cmpl $0x4, 0x18(%r14)
jne 0x93ae
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 0x93ae
cmpl $0x4, 0x18(%r12)
jne 0x93ae
movq 0x20(%r12), %rdi
callq 0x20d0
cmpq $0xc, %rax
sete %al
testq %r15, %r15
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x93ae
cmpl $0x4, 0x18(%r15)
jne 0x93ae
movq 0x20(%r15), %rdi
callq 0x20d0
cmpq $0x20, %rax
jne 0x93ae
leaq -0x50(%rbp), %rsi
movl $0x20, %edx
movq %r13, %rdi
callq 0x87d7
cmpq $-0x1, %rax
je 0x93d1
movq 0x20(%r12), %rdi
leaq -0x2e(%rbp), %rsi
movl $0xc, %edx
callq 0x87d7
cmpq $-0x1, %rax
je 0x93d1
movq 0x20(%r15), %rdi
leaq -0x40(%rbp), %rsi
movl $0x20, %edx
callq 0x87d7
cmpq $-0x1, %rax
je 0x93d1
movq 0x20(%r14), %rdi
leaq -0x40(%rbp), %rsi
callq 0x96ab
cmpq $0x2, %rax
jne 0x93f2
leaq 0x1ffb(%rip), %rsi      # 0xb3a2
movl $0x20, %edx
jmp 0x9411
movq 0x30(%rbx), %rax
leaq 0x1fc5(%rip), %rsi      # 0xb37e
movl $0x24, %edx
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
leaq 0x1fa6(%rip), %rsi      # 0xb37e
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 0x973a
cmpq $0x7, %rax
jne 0x9421
leaq 0x2043(%rip), %rsi      # 0xb44f
movl $0x25, %edx
movq %rbx, %rdi
callq *0x30(%rbx)
movq %rbx, %rdi
callq 0x26a2
jmp 0x93e3
movq 0x20(%r14), %rsi
movq %rbx, %rdi
callq 0x97ea
testq %rax, %rax
je 0x943f
movq %rbx, %rdi
movq %rax, %rsi
callq 0x95fb
jmp 0x93e3
leaq 0x1f20(%rip), %rsi      # 0xb366
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 0x920a
jmp 0x93e3