// File: /workspace/github_cpp_makefile_star2_O1/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 0x304c6(%rip), %r14     # 0x46bc0
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x12244
movq (%r15), %rdi
movzwl 0x22(%r14), %esi
movl $0xa, %edx
callq 0x200b4
movl %eax, %ebp
cmpl $-0x1, %eax
je 0x167bb
movq 0x48(%rbx), %r14
movq 0x50(%rbx), %r15
cmpq %r15, %r14
je 0x16742
movq %r14, %rdi
callq 0x17510
addq $0x30, %r14
jmp 0x1672f
leaq 0x30777(%rip), %rax     # 0x46ec0
movq $0x0, 0x80(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x68(%rax)
movq $0x0, 0x78(%rax)
movl $0x130, %edi            # imm = 0x130
callq 0x7500
movq %rax, %r15
leaq 0x40(%rbx), %rdx
movq %rax, %rdi
movl %ebp, %esi
callq 0x17498
movq %r15, 0xa8(%rbx)
movq 0x28(%rbx), %rdi
leaq 0x18(%rsp), %rsi
movq %r15, (%rsi)
movl $0x5, %edx
callq 0xa33e
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x167ab
movq (%rdi), %rax
callq *0x8(%rax)
movq $0x0, 0x18(%rsp)
movb $0x1, %bl
jmp 0x16844
leaq 0x302d6(%rip), %rax     # 0x46a98
movl (%rax), %esi
notl %esi
shrl $0x1f, %esi
leaq 0x1d9f6(%rip), %rdx     # 0x341c6
leaq 0x8(%rsp), %rdi
callq 0x9718
cmpb $0x1, 0x8(%rsp)
jne 0x167f7
movq 0x10(%rsp), %rdi
leaq 0x1eb3a(%rip), %rsi     # 0x35327
movl $0x21, %edx
callq 0x7580
cmpb $0x1, 0x8(%rsp)
jne 0x16812
movq 0x10(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
callq 0x7580
cmpb $0x1, 0x8(%rsp)
jne 0x1682f
movq 0x10(%rsp), %rdi
leaq 0x1e586(%rip), %rsi     # 0x34dab
movl $0x1, %edx
callq 0x7580
leaq 0x8(%rsp), %rdi
callq 0x8f94
movq 0x28(%rbx), %rdi
callq 0xa4c6
xorl %ebx, %ebx
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1685f
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x7510
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x168ad
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x8f94
jmp 0x168b0
movq %rax, %r14
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x16890
movq (%rdi), %rax
callq *0x8(%rax)
movq $0x0, 0x18(%rsp)
jmp 0x168b0
movq %rax, %r14
movl $0x130, %esi            # imm = 0x130
movq %r15, %rdi
callq 0x7510
jmp 0x168b0
movq %rax, %r14
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x168cb
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x7510
movq %r14, %rdi
callq 0x79b0
movq %rax, %r14
cmpl $0x1, %edx
jne 0x168b0
movq %r14, %rdi
callq 0x71a0
movq %rax, %r14
leaq 0x301ab(%rip), %rax     # 0x46a98
movl (%rax), %esi
notl %esi
shrl $0x1f, %esi
leaq 0x1d8cb(%rip), %rdx     # 0x341c6
leaq 0x8(%rsp), %rdi
callq 0x9718
leaq 0x1ea1b(%rip), %rsi     # 0x35327
leaq 0x8(%rsp), %rdi
callq 0x17464
movq %rax, %r15
cmpb $0x1, (%rax)
jne 0x16931
movq 0x8(%r15), %rdi
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
callq 0x7580
leaq 0x1da17(%rip), %rsi     # 0x3434f
movq %r15, %rdi
callq 0x8fd2
movq %rax, %r15
movq (%r14), %rax
movq %r14, %rdi
callq *0x10(%rax)
leaq 0x40(%rsp), %rsi
movq %rax, (%rsi)
movq %r15, %rdi
callq 0x8f42
leaq 0x8(%rsp), %rdi
callq 0x8f94
movq 0x28(%rbx), %rdi
callq 0xa4c6
callq 0x78f0
jmp 0x16842
jmp 0x168ad
jmp 0x16982
jmp 0x16987
movq %rax, %r14
jmp 0x16994
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x8f94
callq 0x78f0
jmp 0x168b0
movq %rax, %rdi
callq 0x8fc6