// File: yuryu[P]tfoecho/server.cpp
// Function: process_client_socket(int, int)
void process_client_socket(int s, int epollfd)
{
    static std::vector<char> buf(BUFFER_SIZE);
    ssize_t rs;
    while( (rs = recv(s, &buf[0], buf.size(), 0)) != 0 )
    {
        if( rs == -1 )
        {
            if( errno == EINTR ) continue;
            if( errno == EAGAIN || errno == EWOULDBLOCK ) return;
            cerror("recv");
            break;
        }
        ssize_t sent;
        // EAGAIN or EWOULDBLOCK is retuned when the socket buffer is full
        // We should try with another socket for maximum performance, however,
        // we just wait until the buffer becomes available as we don't have
        // enough buffer for that.
        do {
            sent = send(s, &buf[0], rs, 0);
        } while( sent == -1 && 
                 (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) );
        if( sent == -1 )
        {
            cerror("send");
            break;
        }
    }
    if( epoll_ctl(epollfd, EPOLL_CTL_DEL, s, nullptr) == -1 )
        cerror("epoll_ctl: EPOLL_CTL_DEL");
    close(s);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
cmpb $0x0, 0x3a9b(%rip)      # 0x61b0
jne 0x277b
leaq 0x3a92(%rip), %rdi      # 0x61b0
callq 0x22c0
cmpl $0x0, %eax
je 0x277b
leaq -0x9(%rbp), %rdi
movq %rdi, -0x38(%rbp)
callq 0x22a0
movq -0x38(%rbp), %rdx
leaq 0x3a58(%rip), %rdi      # 0x6198
movl $0x1000, %esi           # imm = 0x1000
callq 0x2c30
jmp 0x274c
leaq -0x9(%rbp), %rdi
callq 0x21d0
leaq 0x544(%rip), %rdi       # 0x2ca0
leaq 0x3a35(%rip), %rsi      # 0x6198
leaq 0x3a0e(%rip), %rdx      # 0x6178
callq 0x2180
leaq 0x3a3a(%rip), %rdi      # 0x61b0
callq 0x2150
jmp 0x277d
movl -0x4(%rbp), %eax
movl %eax, -0x44(%rbp)
leaq 0x3a0e(%rip), %rdi      # 0x6198
xorl %eax, %eax
movl %eax, %esi
callq 0x2d00
movq %rax, -0x40(%rbp)
leaq 0x39fa(%rip), %rdi      # 0x6198
callq 0x2d20
movl -0x44(%rbp), %edi
movq -0x40(%rbp), %rsi
movq %rax, %rdx
xorl %ecx, %ecx
callq 0x2080
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0x28b7
cmpq $-0x1, -0x28(%rbp)
jne 0x2825
callq 0x2030
cmpl $0x4, (%rax)
jne 0x27fb
jmp 0x277d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x9(%rbp), %rdi
callq 0x21d0
leaq 0x39bf(%rip), %rdi      # 0x61b0
callq 0x2140
jmp 0x28ea
callq 0x2030
cmpl $0xb, (%rax)
je 0x280f
callq 0x2030
cmpl $0xb, (%rax)
jne 0x2814
jmp 0x28e4
leaq 0x1838(%rip), %rdi      # 0x4053
callq 0x25f0
jmp 0x28b7
jmp 0x2827
movl -0x4(%rbp), %eax
movl %eax, -0x48(%rbp)
leaq 0x3964(%rip), %rdi      # 0x6198
xorl %eax, %eax
movl %eax, %esi
callq 0x2d00
movl -0x48(%rbp), %edi
movq %rax, %rsi
movq -0x28(%rbp), %rdx
xorl %ecx, %ecx
callq 0x20f0
movq %rax, -0x30(%rbp)
xorl %eax, %eax
cmpq $-0x1, -0x30(%rbp)
movb %al, -0x49(%rbp)
jne 0x2896
callq 0x2030
movq %rax, %rcx
movb $0x1, %al
cmpl $0x4, (%rcx)
movb %al, -0x4a(%rbp)
je 0x2890
callq 0x2030
movq %rax, %rcx
movb $0x1, %al
cmpl $0xb, (%rcx)
movb %al, -0x4a(%rbp)
je 0x2890
callq 0x2030
cmpl $0xb, (%rax)
sete %al
movb %al, -0x4a(%rbp)
movb -0x4a(%rbp), %al
movb %al, -0x49(%rbp)
movb -0x49(%rbp), %al
testb $0x1, %al
jne 0x2827
cmpq $-0x1, -0x30(%rbp)
jne 0x28b2
leaq 0x17ad(%rip), %rdi      # 0x4058
callq 0x25f0
jmp 0x28b7
jmp 0x277d
movl -0x8(%rbp), %edi
movl -0x4(%rbp), %edx
movl $0x2, %esi
xorl %eax, %eax
movl %eax, %ecx
callq 0x2240
cmpl $-0x1, %eax
jne 0x28dc
leaq 0x1786(%rip), %rdi      # 0x405d
callq 0x25f0
movl -0x4(%rbp), %edi
callq 0x22d0
addq $0x50, %rsp
popq %rbp
retq
movq -0x18(%rbp), %rdi
callq 0x2290
nopw %cs:(%rax,%rax)