// File: /workspace/github_c_makefile_star2_O0/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
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rsi
leaq 0x24ea(%rip), %rdi      # 0x102f5
movb $0x0, %al
callq 0x9e70
movq -0x10(%rbp), %rdi
leaq 0x2506(%rip), %rsi      # 0x10323
callq 0x59f0
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x24f9(%rip), %rsi      # 0x1032a
callq 0x59f0
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x24e9(%rip), %rsi      # 0x1032e
callq 0x59f0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0xe00e
movq -0x28(%rbp), %rax
cmpl $0x4, 0x18(%rax)
jne 0xe00e
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x20e0
cmpq $0x20, %rax
jne 0xe00e
cmpq $0x0, -0x30(%rbp)
je 0xe00e
movq -0x30(%rbp), %rax
cmpl $0x4, 0x18(%rax)
jne 0xe00e
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x20e0
cmpq $0xc, %rax
jne 0xe00e
cmpq $0x0, -0x38(%rbp)
je 0xe00e
movq -0x38(%rbp), %rax
cmpl $0x4, 0x18(%rax)
jne 0xe00e
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x20e0
cmpq $0x20, %rax
jne 0xe00e
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rdi
leaq -0x50(%rbp), %rsi
movl $0x20, %edx
callq 0xcc50
cmpq $-0x1, %rax
je 0xdf32
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rdi
leaq -0x56(%rbp), %rsi
movl $0xc, %edx
callq 0xcc50
cmpq $-0x1, %rax
je 0xdf32
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rdi
leaq -0x70(%rbp), %rsi
movl $0x20, %edx
callq 0xcc50
cmpq $-0x1, %rax
jne 0xdf45
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0xe290
jmp 0xe01c
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rdi
leaq -0x70(%rbp), %rsi
callq 0xe3d0
cmpq $0x2, %rax
jne 0xdf6f
movq -0x8(%rbp), %rdi
movl $0x2, %esi
callq 0xe290
jmp 0xe01c
leaq -0x50(%rbp), %rdi
leaq -0x56(%rbp), %rsi
callq 0xe490
cmpq $0x7, %rax
jne 0xdf95
movq -0x8(%rbp), %rdi
movl $0x7, %esi
callq 0xe290
jmp 0xe01c
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rsi
callq 0xe510
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0xdfbf
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0xe290
jmp 0xe01c
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x8(%rbp), %rdi
leaq 0x2360(%rip), %rsi      # 0x10332
movl $0x18, %edx
callq *%rax
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movb 0x118(%rax), %cl
andb $-0x2, %cl
orb $0x1, %cl
movb %cl, 0x118(%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movl $0xbb8, %esi            # imm = 0xBB8
callq 0xdd30
jmp 0xe01c
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0xe290
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)