// File: /workspace/github_c_makefile_star2_O1/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 0x6b12(%rip), %rdi      # 0xa806
xorl %eax, %eax
callq 0x6daa
testb $0x4, 0x9(%rbx)
jne 0x3de8
testb $0x20, 0x98(%r14)
jne 0x3de8
movq 0x20(%r14), %r15
testq %r15, %r15
je 0x3d81
movq (%r15), %rsi
movq 0x28(%r15), %rdx
subq 0x20(%r15), %rdx
movq %r14, %rdi
callq *0x28(%r14)
testq %rax, %rax
je 0x3dd8
cmpq $-0x1, %rax
je 0x3de8
cmpq $-0x2, %rax
jne 0x3df8
testb $0x8, 0x9(%rbx)
jne 0x3d78
leaq 0xb968(%rip), %rax      # 0xf6c0
movl $0xbb8, %ecx            # imm = 0xBB8
addq (%rax), %rcx
leaq 0x20(%rbx), %rsi
movq %rcx, 0x20(%rbx)
leaq 0xb5a1(%rip), %rdi      # 0xf310
callq 0x8098
orb $0x8, 0x9(%rbx)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x40(%r14), %rdi
movl $0x38, %esi
callq 0x7e46
testq %rax, %rax
je 0x3de8
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 0x7e27
movq %rax, 0x20(%r15)
testq %rax, %rax
je 0x3de8
movq %rax, (%r15)
movq %rax, 0x8(%r15)
addq %rax, %r12
movq %r12, 0x28(%r15)
orb $0x1, 0x30(%r15)
jmp 0x3d1c
leaq 0x6a49(%rip), %rsi      # 0xa828
xorl %edi, %edi
xorl %eax, %eax
callq 0x6c5d
movq %r14, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x26a2
addq %rax, 0x8(%r15)
leaq 0x24(%rip), %rax        # 0x3e27
movq %rax, 0x10(%rbx)
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x3e27