// File: /workspace/github_c_makefile_star2_O2/qq-smart[P]qq_sh_server/app/qq_wifi_device.c
// Function: qq_wifi_device_pretreatment_process_handler
static void
qq_wifi_device_pretreatment_process_handler(qq_event_t *rev)
{
    qq_connection_t        *c;
    ssize_t                 n;
    size_t                  size;
    qq_wifi_device_t       *wd;
    qq_listening_t         *ls;
    cJSON                  *root, *cmd;

    qq_log_debug("qq_wifi_device_pretreatment_process_handler()");

    c = rev->data;
    ls = c->listening;

    if (rev->timedout) {
        qq_log_debug("timeout");
        qq_app_close_connection(c);
        return;
    }

    if (c->close) {
        qq_app_close_connection(c);
        return;
    }

    wd = c->data;
    if (wd == NULL) {
        wd = qq_pcalloc(c->pool, sizeof(qq_wifi_device_t));
        if (wd == NULL) {
            qq_app_close_connection(c);
            return;
        }
        c->data = (void *) wd;

        size = ls->pool_size -
            ((size_t)((uintptr_t)c->data - (uintptr_t)c->pool) + sizeof(qq_wifi_device_t));
        wd->buf = qq_pnalloc(c->pool, size);
        if (wd->buf == NULL) {
            qq_app_close_connection(c);
            return;
        }
        wd->buf_size = size;
    }

    n = c->recv(c, wd->buf, wd->buf_size);
    if (n == QQ_AGAIN) {
        qq_log_debug("recv not reday");
        return;
    }

    if (n == QQ_ERROR) {
        qq_app_close_connection(c);
        return;
    }

    if (n == 0) {
        qq_app_close_connection(c);
        return;
    }

    wd->buf_ndata = n;

    root = cJSON_Parse(wd->buf);
    if(root == NULL) {
        qq_log_error(0, "qq_wifi_device_process_connection_package()->cJSON_Parse() failed, before: %s",
            cJSON_GetErrorPtr());
    }
    else {
        cmd = cJSON_GetObjectItem(root, QQ_PKG_KEY_CMD);
        if (cmd != NULL && cmd->type == cJSON_String) {
            if (strcmp(cmd->valuestring, QQ_PKG_VALUE_CMD_CONN) == 0) {
                qq_wifi_device_connection_package_process(c, root);
            }
            else {
                if (wd->connection && strcmp(cmd->valuestring, QQ_PKG_VALUE_CMD_DEV_REPORT_STA) == 0) {
                    qq_wifi_device_status_package_process(c, root);
                }
            }
        }
        cJSON_Delete(root);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdi, %r14
leaq 0x1c24(%rip), %rdi      # 0xa275
xorl %eax, %eax
callq 0x6706
movq (%r14), %rbx
testb $0x4, 0x9(%r14)
jne 0x86b8
testb $0x20, 0x98(%rbx)
jne 0x86c6
movq (%rbx), %r15
testq %r15, %r15
je 0x86df
movq 0x8(%r15), %rsi
movq 0x10(%r15), %r14
movq %rbx, %rdi
movq %r14, %rdx
callq *0x28(%rbx)
testq %rax, %rax
je 0x86c6
cmpq $-0x1, %rax
je 0x86c6
cmpq $-0x2, %rax
jne 0x872f
leaq 0x1c03(%rip), %rdi      # 0xa2a3
xorl %eax, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6706
leaq 0xe07(%rip), %rdi       # 0x94c6
xorl %eax, %eax
callq 0x6706
movq %rbx, %rdi
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x26aa
movq 0x38(%rbx), %r14
movq 0x40(%rbx), %rdi
movl $0x120, %esi            # imm = 0x120
callq 0x7694
testq %rax, %rax
je 0x86c6
movq %rax, %r15
movq %rax, (%rbx)
movq 0x50(%r14), %rax
movq 0x40(%rbx), %rdi
subq %r15, %rax
leaq (%rax,%rdi), %r14
addq $-0x120, %r14           # imm = 0xFEE0
movq %r14, %rsi
callq 0x7675
movq %rax, 0x8(%r15)
testq %rax, %rax
je 0x86c6
movq %rax, %rsi
movq %r14, 0x10(%r15)
jmp 0x867b
movq %rax, 0x18(%r15)
movq 0x8(%r15), %rdi
callq 0x449b
testq %rax, %rax
je 0x87f8
movq %rax, %r14
leaq 0x1bb1(%rip), %rsi      # 0xa300
movq %rax, %rdi
callq 0x462e
testq %rax, %rax
je 0x89c7
cmpl $0x4, 0x18(%rax)
jne 0x89c7
movq 0x20(%rax), %r12
leaq 0x10c1(%rip), %rsi      # 0x9836
movq %r12, %rdi
callq 0x2290
testl %eax, %eax
je 0x8821
testb $0x1, 0x118(%r15)
je 0x89c7
leaq 0x1b6a(%rip), %rsi      # 0xa304
movq %r12, %rdi
callq 0x2290
testl %eax, %eax
jne 0x89c7
leaq 0x1cdc(%rip), %rdi      # 0xa48d
movq %r14, %rsi
xorl %eax, %eax
callq 0x6706
movq (%rbx), %r15
movb 0x118(%r15), %al
testb $0x2, %al
jne 0x89e1
orb $0x2, %al
movb %al, 0x118(%r15)
movq 0x18(%r15), %rax
leaq (%rax,%rax), %rcx
cmpq %rcx, 0x10(%r15)
jae 0x8a34
pushq $0x8
popq %rsi
movq %rbx, %rdi
callq 0x8c6d
jmp 0x89c7
callq 0x3e4d
leaq 0x1aae(%rip), %rsi      # 0xa2b2
xorl %edi, %edi
movq %rax, %rdx
xorl %eax, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x65bd
leaq 0x1af1(%rip), %rdi      # 0xa319
movq %r14, %rsi
xorl %eax, %eax
callq 0x6706
leaq 0x1b0e(%rip), %rsi      # 0xa347
movq %r14, %rdi
callq 0x462e
movq %rax, %r15
leaq 0x1b03(%rip), %rsi      # 0xa34e
movq %r14, %rdi
callq 0x462e
movq %rax, %r13
leaq 0x1af5(%rip), %rsi      # 0xa352
movq %r14, %rdi
callq 0x462e
testq %r15, %r15
je 0x89b7
cmpl $0x4, 0x18(%r15)
jne 0x89b7
movq %rax, %r12
movq 0x20(%r15), %rdi
movq %rdi, -0x30(%rbp)
callq 0x20d0
cmpq $0x20, %rax
sete %al
testq %r13, %r13
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x89b7
cmpl $0x4, 0x18(%r13)
jne 0x89b7
movq 0x20(%r13), %rdi
callq 0x20d0
cmpq $0xc, %rax
sete %al
testq %r12, %r12
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x89b7
cmpl $0x4, 0x18(%r12)
jne 0x89b7
movq 0x20(%r12), %rdi
callq 0x20d0
cmpq $0x20, %rax
jne 0x89b7
leaq -0x50(%rbp), %rsi
pushq $0x20
popq %rdx
movq -0x30(%rbp), %rdi
callq 0x7e21
cmpq $-0x1, %rax
je 0x89b7
movq 0x20(%r13), %rdi
leaq -0x36(%rbp), %rsi
pushq $0xc
popq %rdx
callq 0x7e21
cmpq $-0x1, %rax
je 0x89b7
movq 0x20(%r12), %rdi
leaq -0x60(%rbp), %rsi
pushq $0x20
popq %rdx
callq 0x7e21
cmpq $-0x1, %rax
je 0x89b7
movq 0x20(%r15), %rax
cmpb $0x0, 0x5ded(%rip)      # 0xe730
leaq 0x5e0b(%rip), %rcx      # 0xe755
leaq 0x5def(%rip), %r12      # 0xe740
cmoveq %r12, %rcx
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups %xmm0, (%rcx)
movups %xmm1, 0x10(%rcx)
leaq -0xc8(%rbp), %r13
movq %r13, %rdi
callq 0x6a30
movq %r12, %rdi
callq 0x20d0
movq %r13, %rdi
movq %r12, %rsi
movl %eax, %edx
callq 0x6a4e
leaq -0x70(%rbp), %r12
movq %r13, %rdi
movq %r12, %rsi
callq 0x7266
movdqa -0x60(%rbp), %xmm0
pcmpeqb (%r12), %xmm0
pmovmskb %xmm0, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x8a9b
pushq $0x2
jmp 0x87ea
leaq 0x19b0(%rip), %rsi      # 0xa36e
pushq $0x24
popq %rdx
movq %rbx, %rdi
callq *0x30(%rbx)
movq %r14, %rdi
callq 0x3ea2
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%r15), %rax
movq 0x20(%r15), %rcx
movq %rax, 0x20(%r15)
movq %rcx, 0x8(%r15)
leaq 0x70(%r15), %r12
xorl %r13d, %r13d
cmpq $0xa, %r13
je 0x8a24
cmpq 0x110(%r15), %r13
je 0x8a24
movq (%r12), %rdi
testq %rdi, %rdi
je 0x8a1b
movq 0x20(%r15), %rsi
movq 0x28(%r15), %rdx
callq *0x30(%rbx)
incq %r13
addq $0x10, %r12
jmp 0x89f8
movq 0x8(%rbx), %rdi
movl $0xea60, %esi           # imm = 0xEA60
callq 0x8c05
jmp 0x89c7
movq 0x8(%r15), %rcx
movq %rcx, 0x20(%r15)
movq %rax, 0x28(%r15)
addq %rax, %rcx
movq %rcx, 0x8(%r15)
movq %rax, 0x10(%r15)
leaq 0x78(%r15), %r12
xorl %r13d, %r13d
cmpq $0xa, %r13
je 0x89f1
cmpq 0x110(%r15), %r13
je 0x89f1
movq -0x8(%r12), %rdi
testq %rdi, %rdi
je 0x8a92
movl (%r12), %eax
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andl %ecx, %eax
cmpl $0x2, %eax
je 0x8a8a
cmpl $0x1, %eax
jne 0x8a92
movq %r15, %rsi
callq 0x258b
jmp 0x8a92
movq %r15, %rsi
callq 0x3bc3
incq %r13
addq $0x10, %r12
jmp 0x8a52
movq 0x5c7e(%rip), %rax      # 0xe720
movq %rax, -0x30(%rbp)
leaq 0x5c6b(%rip), %r12      # 0xe718
leaq -0x50(%rbp), %rax
movl (%rax), %r13d
movq (%r12), %r12
cmpq -0x30(%rbp), %r12
je 0x8b14
cmpq %r13, (%r12)
jne 0x8ae3
leaq 0x28(%r12), %rsi
leaq -0x50(%rbp), %rdi
pushq $0x10
popq %rdx
callq 0x20e0
pushq $0x8
popq %rcx
testl %eax, %eax
js 0x8af1
pushq $0x10
popq %rcx
jne 0x8af1
jmp 0x8af6
setbe %al
movzbl %al, %eax
leaq 0x8(,%rax,8), %rcx
addq %rcx, %r12
jmp 0x8ab4
addq $0x38, %r12
leaq -0x36(%rbp), %rsi
pushq $0x6
popq %rdx
movq %r12, %rdi
callq 0x2210
testl %eax, %eax
je 0x8b14
pushq $0x7
jmp 0x87ea
movq 0x20(%r15), %rdi
callq 0x73ec
testq %rax, %rax
je 0x8bac
movq %rax, %r15
pushq $0x6
popq %r12
movq %rax, %rdi
callq 0x21d0
testq %rax, %rax
je 0x8bbf
xorl %ecx, %ecx
cmpq $0xb, %rax
setae %dl
jae 0x8bbf
movb %dl, %cl
leaq (%rcx,%rcx,4), %rcx
movq %rcx, -0x30(%rbp)
movq (%rbx), %r12
movq %rax, 0x110(%r12)
xorl %r13d, %r13d
movq %r15, %rdi
callq 0x2200
testq %rax, %rax
je 0x8bb2
movq 0x8(%rax), %rcx
movzbl (%rcx), %edx
movsbl %dl, %ecx
movl %ecx, 0x78(%r12)
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
shrl $0x7, %edx
addq %rdx, %r13
cmpl $0x2, %ecx
je 0x8b9d
cmpl $0x1, %ecx
jne 0x8b61
movq (%rax), %rdi
callq 0x2583
jmp 0x8ba5
movq (%rax), %rdi
callq 0x3bbb
movq %rax, 0x70(%r12)
jmp 0x8b61
pushq $0x3
popq %r12
jmp 0x8bcc
cmpq $0x1, %r13
pushq $0x6
popq %r12
cmoveq -0x30(%rbp), %r12
movq %r15, %rdi
callq 0x21f0
testq %r12, %r12
je 0x8bd7
movq %rbx, %rdi
movq %r12, %rsi
jmp 0x87ee
leaq 0x1778(%rip), %rsi      # 0xa356
pushq $0x18
popq %rdx
movq %rbx, %rdi
callq *0x30(%rbx)
movq (%rbx), %rax
orb $0x1, 0x118(%rax)
movq 0x8(%rbx), %rdi
movl $0xbb8, %esi            # imm = 0xBB8
jmp 0x8a2d