// File: /workspace/github_cpp_makefile_star2_O3/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 0x305ae(%rip), %r14     # 0x46bc0
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x1227c
movq (%r15), %rdi
movzwl 0x22(%r14), %esi
movl $0xa, %edx
callq 0x1f884
movl %eax, %ebp
cmpl $-0x1, %eax
je 0x166d3
movq 0x48(%rbx), %r14
movq 0x50(%rbx), %r15
cmpq %r15, %r14
je 0x1665a
movq %r14, %rdi
callq 0x17440
addq $0x30, %r14
jmp 0x16647
leaq 0x3085f(%rip), %rax     # 0x46ec0
movq $0x0, 0x80(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x68(%rax)
movq $0x0, 0x78(%rax)
movl $0x130, %edi            # imm = 0x130
callq 0x74f0
movq %rax, %r15
leaq 0x40(%rbx), %rdx
movq %rax, %rdi
movl %ebp, %esi
callq 0x173c8
movq %r15, 0xa8(%rbx)
movq 0x28(%rbx), %rdi
leaq 0x18(%rsp), %rsi
movq %r15, (%rsi)
movl $0x5, %edx
callq 0xa31a
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x166c3
movq (%rdi), %rax
callq *0x8(%rax)
movq $0x0, 0x18(%rsp)
movb $0x1, %bl
jmp 0x1675f
leaq 0x303ae(%rip), %rax     # 0x46a88
movl (%rax), %esi
notl %esi
shrl $0x1f, %esi
leaq 0x1dade(%rip), %rdx     # 0x341c6
leaq 0x8(%rsp), %rdi
callq 0x96e6
movb 0x8(%rsp), %al
cmpb $0x1, %al
jne 0x16714
movq 0x10(%rsp), %rdi
leaq 0x1ec65(%rip), %rsi     # 0x3536b
movl $0x21, %edx
callq 0x7570
movb 0x8(%rsp), %al
testb $0x1, %al
je 0x16730
movq 0x10(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
callq 0x7570
movb 0x8(%rsp), %al
testb $0x1, %al
je 0x1674a
movq 0x10(%rsp), %rdi
leaq 0x1e6af(%rip), %rsi     # 0x34def
movl $0x1, %edx
callq 0x7570
leaq 0x8(%rsp), %rdi
callq 0x8f4e
movq 0x28(%rbx), %rdi
callq 0xa4a2
xorl %ebx, %ebx
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1677a
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x7500
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x167c8
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x8f4e
jmp 0x167cb
movq %rax, %r14
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x167ab
movq (%rdi), %rax
callq *0x8(%rax)
movq $0x0, 0x18(%rsp)
jmp 0x167cb
movq %rax, %r14
movl $0x130, %esi            # imm = 0x130
movq %r15, %rdi
callq 0x7500
jmp 0x167cb
movq %rax, %r14
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x167e6
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x7500
movq %r14, %rdi
callq 0x79a0
movq %rax, %r14
cmpl $0x1, %edx
jne 0x167cb
movq %r14, %rdi
callq 0x71a0
movq %rax, %r14
leaq 0x30280(%rip), %rax     # 0x46a88
movl (%rax), %esi
notl %esi
shrl $0x1f, %esi
leaq 0x1d9b0(%rip), %rdx     # 0x341c6
leaq 0x8(%rsp), %rdi
callq 0x96e6
leaq 0x1eb44(%rip), %rsi     # 0x3536b
leaq 0x8(%rsp), %rdi
callq 0x17394
movq %rax, %r15
cmpb $0x1, (%rax)
jne 0x1684c
movq 0x8(%r15), %rdi
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
callq 0x7570
leaq 0x1dafc(%rip), %rsi     # 0x3434f
movq %r15, %rdi
callq 0x8f8c
movq %rax, %r15
movq (%r14), %rax
movq %r14, %rdi
callq *0x10(%rax)
leaq 0x40(%rsp), %rsi
movq %rax, (%rsi)
movq %r15, %rdi
callq 0x8efc
leaq 0x8(%rsp), %rdi
callq 0x8f4e
movq 0x28(%rbx), %rdi
callq 0xa4a2
callq 0x78e0
jmp 0x1675d
jmp 0x167c8
jmp 0x1689d
jmp 0x168a2
movq %rax, %r14
jmp 0x168af
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x8f4e
callq 0x78e0
jmp 0x167cb
movq %rax, %rdi
callq 0x8f80
nop