// File: /workspace/github_cpp_makefile_star2_O1/cybozu[P]yrmcds/src/memcache/sockets.cpp
// Function: yrmcds::memcache::repl_socket::on_readable(int)
bool repl_socket::on_readable(int fd) {
    // recv and drop.
    while( true ) {
        ssize_t n = ::recv(fd, &m_recvbuf[0], MAX_RECVSIZE, 0);
        if( n == -1 ) {
            if( errno == EAGAIN || errno == EWOULDBLOCK )
                break;
            if( errno == EINTR )
                continue;
            if( errno == ECONNRESET ) {
                std::string addr = "unknown address";
                try {
                    addr = cybozu::get_peer_ip_address(fd).str();
                } catch (...) {
                    // ignore errors
                }
                cybozu::logger::info() << "The connection to the slave (" << addr << ") has been reset.";
                return invalidate();
            }
            cybozu::throw_unix_error(errno, "recv");
        }
        if( n == 0 ) {
            std::string addr = "unknown address";
            try {
                addr = cybozu::get_peer_ip_address(fd).str();
            } catch (...) {
                // ignore errors
            }
            cybozu::logger::info() << "The connection to the slave (" << addr << ") has been closed.";
            return invalidate();
        }
        m_last_heartbeat = g_current_time.load(relaxed);
    }
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %esi, %ebx
movq %rdi, %r14
leaq 0x20(%rsp), %r15
movl $0x1, %eax
movl %eax, %r13d
movl $0x2, %eax
movl %eax, %eax
movq %rax, 0x40(%rsp)
leaq 0x19aa5(%rip), %rbp     # 0x3577c
movq 0x108(%r14), %rsi
movl $0x200000, %edx         # imm = 0x200000
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x7130
testq %rax, %rax
je 0x1bd31
cmpq $-0x1, %rax
jne 0x1be54
callq 0x7040
movl (%rax), %edi
cmpl $0x68, %edi
je 0x1be73
movl $0x3, %eax
cmpl $0xb, %edi
je 0x1be67
cmpl $0x4, %edi
jne 0x1bfd3
movq 0x40(%rsp), %rax
movslq (%rbp,%rax,4), %rax
addq %rbp, %rax
jmpq *%rax
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
movq %rsp, %rdi
leaq 0x1965e(%rip), %rsi     # 0x353a2
leaq 0x19666(%rip), %rdx     # 0x353b1
callq 0x97a0
leaq 0x48(%rsp), %r12
movq %r12, %rdi
movl %ebx, %esi
callq 0x123df
movq %r15, %rdi
movq %r12, %rsi
callq 0x12244
movq %rsp, %rdi
movq %r15, %rsi
callq 0x75e0
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x1bd91
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x7510
leaq 0x2ad00(%rip), %rax     # 0x46a98
movl (%rax), %eax
xorl %esi, %esi
cmpl $0x2, %eax
setge %sil
movq %r15, %rdi
leaq 0x18c6c(%rip), %rdx     # 0x34a19
callq 0x9718
cmpb $0x1, 0x20(%rsp)
jne 0x1bdcf
movq 0x28(%rsp), %rdi
movl $0x1d, %edx
leaq 0x1a602(%rip), %rsi     # 0x363cc
callq 0x7580
cmpb $0x1, 0x20(%rsp)
jne 0x1bde9
movq 0x28(%rsp), %rdi
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
callq 0x7580
cmpb $0x1, 0x20(%rsp)
jne 0x1be06
movq 0x28(%rsp), %rdi
movl $0x12, %edx
leaq 0x1a5fb(%rip), %rsi     # 0x363fc
callq 0x7580
movq %r15, %rdi
callq 0x8f94
movb $0x1, %al
xorl %ecx, %ecx
lock
cmpxchgb %cl, 0x10(%r14)
sete %r12b
jne 0x1be2b
movl 0x50(%r14), %esi
movq (%r14), %rax
movq %r14, %rdi
callq *0x10(%rax)
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x1be46
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x7510
xorb $0x1, %r12b
movslq (%rbp,%r13,4), %rax
addq %rbp, %rax
jmpq *%rax
leaq 0x2b025(%rip), %rax     # 0x46e80
movq (%rax), %rax
movq %rax, 0x140(%r14)
xorl %eax, %eax
movl %eax, %eax
movslq (%rbp,%rax,4), %rax
addq %rbp, %rax
jmpq *%rax
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
movq %rsp, %rdi
leaq 0x1951c(%rip), %rsi     # 0x353a2
leaq 0x19524(%rip), %rdx     # 0x353b1
callq 0x97a0
leaq 0x48(%rsp), %r12
movq %r12, %rdi
movl %ebx, %esi
callq 0x123df
movq %r15, %rdi
movq %r12, %rsi
callq 0x12244
movq %rsp, %rdi
movq %r15, %rsi
callq 0x75e0
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x1bed3
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x7510
leaq 0x2abbe(%rip), %rax     # 0x46a98
movl (%rax), %eax
xorl %esi, %esi
cmpl $0x2, %eax
setge %sil
movq %r15, %rdi
leaq 0x18b2a(%rip), %rdx     # 0x34a19
callq 0x9718
cmpb $0x1, 0x20(%rsp)
jne 0x1bf11
movq 0x28(%rsp), %rdi
movl $0x1d, %edx
leaq 0x1a4c0(%rip), %rsi     # 0x363cc
callq 0x7580
cmpb $0x1, 0x20(%rsp)
jne 0x1bf2b
movq 0x28(%rsp), %rdi
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
callq 0x7580
cmpb $0x1, 0x20(%rsp)
jne 0x1bf48
movq 0x28(%rsp), %rdi
movl $0x11, %edx
leaq 0x1a4a7(%rip), %rsi     # 0x363ea
callq 0x7580
movq %r15, %rdi
callq 0x8f94
movb $0x1, %al
xorl %ecx, %ecx
lock
cmpxchgb %cl, 0x10(%r14)
sete %r12b
jne 0x1bf6d
movl 0x50(%r14), %esi
movq (%r14), %rax
movq %r14, %rdi
callq *0x10(%rax)
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x1bf88
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x7510
xorb $0x1, %r12b
movslq (%rbp,%r13,4), %rax
addq %rbp, %rax
jmpq *%rax
movq %rax, %rdi
callq 0x71a0
callq 0x78f0
jmp 0x1bed3
movq %rax, %rdi
callq 0x71a0
callq 0x78f0
jmp 0x1bd91
movb $0x1, %r12b
andb $0x1, %r12b
movl %r12d, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x19238(%rip), %rsi     # 0x35212
callq 0x8dd3
jmp 0x1bfe9
jmp 0x1bfe9
jmp 0x1bfee
jmp 0x1bfe9
jmp 0x1bff3
movq %rax, %rbx
jmp 0x1c000
movq %rax, %rbx
jmp 0x1c01b
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x8f94
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x1c01b
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x7510
movq %rbx, %rdi
callq 0x79b0
nop