// File: /workspace/github_cpp_makefile_star2_O2/cybozu[P]yrmcds/src/memcache/handler.cpp
// Function: yrmcds::memcache::handler::on_slave_start()
bool handler::on_slave_start() {
    using logger = cybozu::logger;

    auto master_host = g_config.vip().str();
    int fd;
    try {
        fd = cybozu::tcp_connect(master_host.c_str(), g_config.repl_port());
    } catch( std::runtime_error& err ) {
        logger::error() << "Failed to connect to the master (" << master_host << "): " << err.what();
        m_reactor.run_once();
        return false;
    }
    if( fd == -1 ) {
        logger::error() << "Failed to connect to the master (" << master_host << ")";
        m_reactor.run_once();
        return false;
    }

    // on_slave_start may be called multiple times over the lifetime.
    // Therefore we need to clear the hash table.
    clear();

    m_repl_client_socket = new repl_client_socket(fd, m_hash);
    m_reactor.add_resource(std::unique_ptr<cybozu::resource>(m_repl_client_socket),
                           cybozu::reactor::EVENT_IN|cybozu::reactor::EVENT_OUT );
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
leaq 0x27496(%rip), %r14     # 0x3bbc0
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x10ac8
movq (%r15), %rdi
movzwl 0x22(%r14), %esi
pushq $0xa
popq %rdx
callq 0x1ba48
movl %eax, %ebp
cmpl $-0x1, %eax
je 0x147a9
movq %rbx, %rdi
callq 0x1491a
movl $0x130, %edi            # imm = 0x130
callq 0x7510
movq %rax, %r15
leaq 0x40(%rbx), %rdx
movq %rax, %rdi
movl %ebp, %esi
callq 0x151ea
movq %r15, 0xa8(%rbx)
movq 0x28(%rbx), %rdi
leaq 0x8(%rsp), %rsi
movq %r15, (%rsi)
pushq $0x5
popq %rdx
callq 0x98ce
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x1479f
movq (%rdi), %rax
callq *0x8(%rax)
andq $0x0, 0x8(%rsp)
movb $0x1, %bl
jmp 0x147f5
leaq 0x10(%rsp), %rdi
callq 0x865e
leaq 0x12b45(%rip), %rsi     # 0x272ff
leaq 0x10(%rsp), %rdi
callq 0x151d2
leaq 0x20(%rsp), %rsi
movq %rax, %rdi
callq 0x869a
leaq 0x125a8(%rip), %rsi     # 0x26d80
movq %rax, %rdi
callq 0x8682
leaq 0x10(%rsp), %rdi
callq 0x86e4
movq 0x28(%rbx), %rdi
callq 0x9a38
xorl %ebx, %ebx
leaq 0x20(%rsp), %rdi
callq 0x71d0
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x14841
movq %rax, %r14
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x14821
movq (%rdi), %rax
callq *0x8(%rax)
andq $0x0, 0x8(%rsp)
jmp 0x14907
movq %rax, %r14
movl $0x130, %esi            # imm = 0x130
movq %r15, %rdi
callq 0x7520
jmp 0x14907
movq %rax, %r14
jmp 0x14907
movq %rax, %r14
cmpl $0x1, %edx
jne 0x14907
movq %r14, %rdi
callq 0x71a0
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x865e
leaq 0x12a8e(%rip), %rsi     # 0x272ff
leaq 0x10(%rsp), %rdi
callq 0x151d2
leaq 0x20(%rsp), %rsi
movq %rax, %rdi
callq 0x869a
leaq 0x11ae0(%rip), %rsi     # 0x2636f
movq %rax, %rdi
callq 0x8716
movq %rax, %r15
movq (%r14), %rax
movq %r14, %rdi
callq *0x10(%rax)
leaq 0x40(%rsp), %rsi
movq %rax, (%rsi)
movq %r15, %rdi
callq 0x86ca
leaq 0x10(%rsp), %rdi
callq 0x86e4
movq 0x28(%rbx), %rdi
callq 0x9a38
callq 0x78e0
jmp 0x147f3
jmp 0x14841
jmp 0x148d9
jmp 0x148de
movq %rax, %r14
jmp 0x148eb
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x86e4
callq 0x78e0
jmp 0x14907
movq %rax, %rdi
callq 0x870a
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x86e4
leaq 0x20(%rsp), %rdi
callq 0x71d0
movq %r14, %rdi
callq 0x7990
nop