// File: /workspace/github_c_makefile_star2_O2/goghcrow[P]dubbo_ab/dubbo_client.c
// Function: cli_on_read
static void cli_on_read(struct aeEventLoop *el, int fd, void *ud, int mask)
{
    UNUSED(el);
    UNUSED(mask);

    struct dubbo_client *cli = (struct dubbo_client *)ud;
    assert(cli->connected);

    for (;;)
    {
        int errno_ = 0;
        ssize_t recv_n = buf_readFd(cli->rcv_buf, fd, &errno_);
        if (recv_n < 0)
        {
            if (errno_ == EINTR)
            {
                continue;
            }
            else if (errno_ == EAGAIN)
            {
            }
            else
            {
                LOG_ERROR("从 Dubbo 服务端读取数据: %s", strerror(errno));
                cli_reconnect(cli);
                return;
            }
        }
        else if (recv_n == 0)
        {
            LOG_ERROR("Dubbo 服务端断开连接");
            cli_reconnect(cli);
            return;
        }
        break;
    }

    if (!is_dubbo_pkt(cli->rcv_buf))
    {
        LOG_ERROR("接收到非 dubbo 数据包");
        cli_reconnect(cli);
        return;
    }

    int remaining = 0;
    if (!is_completed_dubbo_pkt(cli->rcv_buf, &remaining))
    {
        LOG_ERROR("接收到异常 dubbo 数据包");
        cli_reconnect(cli);
        return;
    }
    if (remaining) {
        return;
    }

    cli->pipe_left++;
    cli->req_left--;

    if (((cli->req_n - cli->req_left) % 1000) == 0)
    {
        fprintf(stderr, "已发送请求 %d\n", cli->req_n - cli->req_left);
    }

    bool ok = cli_decode_resp(cli);
    
    if (cli->req_left <= 0)
    {
        cli_end(cli);
    }
    else
    {
        if (ok)
        {
            cli_pipe_send(cli);
        }
        else
        {
            cli_reconnect(cli);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
cmpb $0x1, 0x6c(%rdx)
jne 0x8704
movq %rdx, %rbx
movl %esi, %r14d
leaq -0x2c(%rbp), %r15
andl $0x0, -0x2c(%rbp)
movq 0x40(%rbx), %rdi
movl %r14d, %esi
movq %r15, %rdx
callq 0x5ea2
testq %rax, %rax
jns 0x8489
movl -0x2c(%rbp), %eax
cmpl $0x4, %eax
je 0x8421
cmpl $0xb, %eax
je 0x848f
movq 0x6bab(%rip), %rax      # 0xeff8
movq (%rax), %r14
callq 0x2050
movl (%rax), %edi
callq 0x2350
leaq 0x1da6(%rip), %rsi      # 0xa209
leaq 0x1dec(%rip), %rcx      # 0xa256
leaq 0x1c81(%rip), %r8       # 0xa0f2
movq %r14, %rdi
movq %rax, %rdx
movl $0x19d, %r9d            # imm = 0x19D
xorl %eax, %eax
callq 0x21e0
jmp 0x863d
je 0x8611
movq 0x40(%rbx), %rdi
callq 0x7b49
testb %al, %al
je 0x852b
leaq -0x30(%rbp), %rsi
andl $0x0, (%rsi)
movq 0x40(%rbx), %rdi
callq 0x7b77
testb %al, %al
je 0x8555
cmpl $0x0, -0x30(%rbp)
jne 0x86f5
incl 0x54(%rbx)
movl 0x58(%rbx), %ecx
movl 0x5c(%rbx), %eax
decl %eax
movl %eax, 0x5c(%rbx)
subl %eax, %ecx
movl $0x3e8, %esi            # imm = 0x3E8
movl %ecx, %eax
cltd
idivl %esi
testl %edx, %edx
je 0x864a
movq 0x40(%rbx), %rdi
callq 0x7728
testq %rax, %rax
je 0x851c
movq %rax, %r14
movb 0x9(%rax), %r13b
incl 0x60(%rbx)
cmpb $0x1, 0x6e(%rbx)
jne 0x86d5
cmpb $0x1, 0x8(%r14)
jne 0x857f
movq (%r14), %rsi
leaq 0x1e33(%rip), %rdi      # 0xa34a
jmp 0x8673
cmpl $0x0, 0x5c(%rbx)
jg 0x863d
jmp 0x86ed
movq 0x6ac6(%rip), %rax      # 0xeff8
movq (%rax), %rdi
leaq 0x1d6b(%rip), %rsi      # 0xa2a7
leaq 0x1d13(%rip), %rdx      # 0xa256
leaq 0x1ba8(%rip), %rcx      # 0xa0f2
movl $0x1ad, %r8d            # imm = 0x1AD
jmp 0x8636
movq 0x6a9c(%rip), %rax      # 0xeff8
movq (%rax), %rdi
leaq 0x1d87(%rip), %rsi      # 0xa2ed
leaq 0x1ce9(%rip), %rdx      # 0xa256
leaq 0x1b7e(%rip), %rcx      # 0xa0f2
movl $0x1b5, %r8d            # imm = 0x1B5
jmp 0x8636
movq 0x20(%r14), %r12
testq %r12, %r12
je 0x8669
leaq 0x1(%r12), %rdi
callq 0x23a8
testq %rax, %rax
je 0x8723
movq %rax, %r15
movq 0x18(%r14), %rsi
movq %rax, %rdi
movq %r12, %rdx
callq 0x2200
movb $0x0, (%r15,%r12)
movzbl (%r15), %eax
orl $0x20, %eax
cmpl $0x7b, %eax
jne 0x867c
movq %r15, %rdi
callq 0x372f
movb 0x9(%r14), %r13b
testq %rax, %rax
je 0x867c
movq %rax, %r12
movq (%r14), %rax
movq %rax, -0x38(%rbp)
testb $0x1, %r13b
je 0x86a1
movq %r12, %rdi
callq 0x373d
leaq 0x1d8d(%rip), %rdi      # 0xa38b
movq -0x38(%rbp), %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2100
jmp 0x86c5
movq 0x69e0(%rip), %rax      # 0xeff8
movq (%rax), %rdi
leaq 0x1c40(%rip), %rsi      # 0xa262
leaq 0x1c2d(%rip), %rdx      # 0xa256
leaq 0x1ac2(%rip), %rcx      # 0xa0f2
movl $0x1a4, %r8d            # imm = 0x1A4
xorl %eax, %eax
callq 0x21e0
movq %rbx, %rdi
callq 0x7c53
jmp 0x86f5
movq 0x69a7(%rip), %rax      # 0xeff8
movq (%rax), %rdi
leaq 0x1cdb(%rip), %rsi      # 0xa336
movl %ecx, %edx
xorl %eax, %eax
callq 0x21e0
jmp 0x84e4
movq (%r14), %rsi
leaq 0x1d94(%rip), %rdi      # 0xa407
xorl %eax, %eax
callq 0x2100
jmp 0x86d5
movq (%r14), %rsi
testb $0x1, %r13b
je 0x868e
leaq 0x1cff(%rip), %rdi      # 0xa38b
jmp 0x8695
leaq 0x1d4e(%rip), %rdi      # 0xa3e3
movq %r15, %rdx
xorl %eax, %eax
callq 0x2100
jmp 0x86cd
movq 0x10(%r14), %r13
movq %r12, %rdi
callq 0x373d
leaq 0x1cfb(%rip), %rdi      # 0xa3af
movq -0x38(%rbp), %rsi
movq %r13, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x2100
movq %r12, %rdi
callq 0x3060
movq %r15, %rdi
callq 0x23a0
movq %r14, %rdi
callq 0x7258
cmpl $0x0, 0x5c(%rbx)
jle 0x86ed
movq %rbx, %rdi
callq 0x8742
jmp 0x86f5
movq %rbx, %rdi
callq 0x7e48
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1ab6(%rip), %rdi      # 0xa1c1
leaq 0x19e0(%rip), %rsi      # 0xa0f2
leaq 0x1ab7(%rip), %rcx      # 0xa1d0
movl $0x18c, %edx            # imm = 0x18C
callq 0x2150
leaq 0x1a47(%rip), %rdi      # 0xa171
leaq 0x19c1(%rip), %rsi      # 0xa0f2
leaq 0x1c26(%rip), %rcx      # 0xa35e
movl $0x1f4, %edx            # imm = 0x1F4
callq 0x2150