// File: /workspace/github_c_makefile_star2_O3/qq-smart[P]qq_sh_server/app/qq_ios_app.c
// Function: qq_ios_app_wait_request_handler
static void
qq_ios_app_wait_request_handler(qq_event_t *rev)
{
    qq_connection_t   *c;
    ssize_t            n;
    size_t             size;
    qq_buf_t          *b;
    qq_listening_t    *ls;

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

    qq_log_debug("qq_ios_app_wait_request_handler()");

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

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

    b = c->buffer;
    if (b == NULL) {
        b = qq_pcalloc(c->pool, sizeof(qq_buf_t));
        if (b == NULL) {
            qq_app_close_connection(c);
            return;
        }
        c->buffer = b;

        size = ls->pool_size -
            ((size_t)((uintptr_t)b - (uintptr_t)c->pool) + sizeof(qq_buf_t));
        b->start = qq_pnalloc(c->pool, size);
        if (b->start == NULL) {
            qq_app_close_connection(c);
            return;
        }
        b->pos = b->start;
        b->last = b->start;
        b->end = b->last + size;
        b->temporary = 1;
    }

    n = c->recv(c, b->pos, (size_t)((uintptr_t)b->end - (uintptr_t)b->start));
    if (n == QQ_AGAIN) {
        if (!rev->timer_set) {
            qq_event_add_timer(rev, QQ_IOS_APP_ACCEPT_TIMEOUT);
        }
        return;
    }

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

    if (n == 0) {
        qq_log_error(0, "client closed connection");
        qq_app_close_connection(c);
        return;
    }
    b->last += n;

    rev->handler = qq_ios_app_process_request_handler;
    qq_ios_app_process_request_handler(rev);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %r14
movq 0x38(%r14), %r12
leaq 0x6b02(%rip), %rdi      # 0xa806
xorl %eax, %eax
callq 0x6c74
testb $0x4, 0x9(%rbx)
jne 0x3e01
testb $0x20, 0x98(%r14)
jne 0x3e01
movq 0x20(%r14), %r15
testq %r15, %r15
je 0x3d97
movq (%r15), %rsi
movq 0x20(%r15), %rax
movq 0x28(%r15), %r12
subq %rax, %r12
movq %r14, %rdi
movq %r12, %rdx
callq *0x28(%r14)
testq %rax, %rax
je 0x3df1
cmpq $-0x1, %rax
je 0x3e01
cmpq $-0x2, %rax
jne 0x3e11
testb $0x8, 0x9(%rbx)
jne 0x3d8e
leaq 0xb952(%rip), %rax      # 0xf6c0
movl $0xbb8, %ecx            # imm = 0xBB8
addq (%rax), %rcx
leaq 0x20(%rbx), %rsi
movq %rcx, 0x20(%rbx)
leaq 0xb58b(%rip), %rdi      # 0xf310
callq 0x7f4c
orb $0x8, 0x9(%rbx)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x40(%r14), %rdi
movl $0x38, %esi
callq 0x7d16
testq %rax, %rax
je 0x3e01
movq %rax, %r15
movq %rax, 0x20(%r14)
movq 0x50(%r12), %rax
movq 0x40(%r14), %rdi
subq %r15, %rax
leaq (%rax,%rdi), %r12
addq $-0x38, %r12
movq %r12, %rsi
callq 0x7cf7
movq %rax, 0x20(%r15)
testq %rax, %rax
je 0x3e01
movq %rax, (%r15)
movq %rax, 0x8(%r15)
addq %rax, %r12
movq %r12, 0x28(%r15)
orb $0x1, 0x30(%r15)
movq %rax, %rsi
jmp 0x3d37
leaq 0x6a30(%rip), %rsi      # 0xa828
xorl %edi, %edi
xorl %eax, %eax
callq 0x6b27
movq %r14, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x26a2
addq %rax, 0x8(%r15)
leaq 0x24(%rip), %rax        # 0x3e40
movq %rax, 0x10(%rbx)
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x3e40