// File: cybozu[P]yrmcds/src/memcache/handler.cpp
// Function: yrmcds::memcache::handler::make_repl_socket(int)
std::unique_ptr<cybozu::tcp_socket> handler::make_repl_socket(int s) {
    if( m_slaves.size() == MAX_SLAVES )
        return nullptr;
    std::unique_ptr<repl_socket> t(
        new repl_socket(s, g_config.repl_bufsize(), m_finder) );
    repl_socket* pt = t.get();
    m_slaves.push_back(pt);
    m_syncer.add_request(
        std::unique_ptr<sync_request>(
            new sync_request([this,pt]{ m_new_slaves.push_back(pt); })
            ));

    std::string addr = "unknown address";
    try {
        addr = cybozu::get_peer_ip_address(s).str();
    } catch (...) {
        // ignore errors
    }
    cybozu::logger::info() << "A new slave (" << addr << ") has joined.";

    // explicit move is required for C++11 (and gcc-4.8.x).
    // C++14 (and gcc-5.x) can implicitly move t.
    return std::move(t);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq %rdi, -0x108(%rbp)
movq %rdi, %rax
movq %rax, -0x100(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0xf8(%rbp)
addq $0x78, %rdi
callq 0x3a5e0
cmpq $0x5, %rax
jne 0x38916
movq -0x108(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2cb30
jmp 0x38c50
movl $0x148, %edi            # imm = 0x148
callq 0x8640
movq %rax, -0x118(%rbp)
movq %rax, -0x120(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x10c(%rbp)
leaq 0x773c2(%rip), %rdi     # 0xafd00
callq 0x3a770
movq -0xf8(%rbp), %rcx
movq -0x118(%rbp), %rdi
movl -0x10c(%rbp), %esi
movl %eax, %edx
addq $0x8, %rcx
callq 0x3a790
jmp 0x38964
movq -0x120(%rbp), %rsi
leaq -0x20(%rbp), %rdi
movq %rdi, -0x128(%rbp)
callq 0x3a8f0
movq -0x128(%rbp), %rdi
callq 0x3a920
movq -0xf8(%rbp), %rdi
movq %rax, -0x38(%rbp)
addq $0x78, %rdi
leaq -0x38(%rbp), %rsi
callq 0x3a950
jmp 0x389a1
movq -0xf8(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x138(%rbp)
movl $0x28, %edi
callq 0x8640
movq %rax, -0x130(%rbp)
jmp 0x389c6
movq -0xf8(%rbp), %rax
movb $0x1, -0x71(%rbp)
movq %rax, -0x70(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x68(%rbp)
leaq -0x60(%rbp), %rdi
movq %rdi, -0x140(%rbp)
leaq -0x70(%rbp), %rsi
callq 0x38c70
movq -0x130(%rbp), %rdi
movq -0x140(%rbp), %rsi
callq 0x26b70
jmp 0x38a06
movq -0x130(%rbp), %rsi
movb $0x0, -0x71(%rbp)
leaq -0x40(%rbp), %rdi
movq %rdi, -0x148(%rbp)
callq 0x26ba0
movq -0x138(%rbp), %rdi
movq -0x148(%rbp), %rsi
callq 0x26a80
jmp 0x38a36
leaq -0x40(%rbp), %rdi
callq 0xbe90
leaq -0x60(%rbp), %rdi
callq 0xc0b0
leaq -0x99(%rbp), %rdi
movq %rdi, -0x150(%rbp)
callq 0x8bd0
movq -0x150(%rbp), %rdx
leaq 0x42bc9(%rip), %rsi     # 0x7b632
leaq -0x98(%rbp), %rdi
callq 0xa160
jmp 0x38a77
leaq -0x99(%rbp), %rdi
callq 0x86a0
movl -0x14(%rbp), %esi
leaq -0xe0(%rbp), %rdi
callq 0x2a5c0
jmp 0x38a94
leaq -0xc0(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x2a250
jmp 0x38aa9
leaq -0x98(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x8790
leaq -0xc0(%rbp), %rdi
callq 0x83f0
jmp 0x38b85
movq -0x120(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x148, %esi            # imm = 0x148
callq 0x8650
jmp 0x38c60
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x38c45
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x38b23
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0xbe90
leaq -0x60(%rbp), %rdi
callq 0xc0b0
testb $0x1, -0x71(%rbp)
jne 0x38b34
jmp 0x38b45
movq -0x130(%rbp), %rdi
movl $0x28, %esi
callq 0x8650
jmp 0x38c45
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x99(%rbp), %rdi
callq 0x86a0
jmp 0x38c45
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movq -0x28(%rbp), %rdi
callq 0x8230
callq 0x8ae0
jmp 0x38b83
jmp 0x38b85
leaq -0xf0(%rbp), %rdi
callq 0x22390
jmp 0x38b93
leaq 0x42aa8(%rip), %rsi     # 0x7b642
leaq -0xf0(%rbp), %rdi
callq 0x3a9c0
movq %rax, -0x158(%rbp)
jmp 0x38baf
movq -0x158(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0xa690
movq %rax, -0x160(%rbp)
jmp 0x38bcb
movq -0x160(%rbp), %rdi
leaq 0x42a77(%rip), %rsi     # 0x7b650
callq 0x3a9c0
jmp 0x38be0
leaq -0xf0(%rbp), %rdi
callq 0xa770
movq -0x108(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x3aa00
leaq -0x98(%rbp), %rdi
callq 0x83f0
leaq -0x20(%rbp), %rdi
callq 0x3aa50
jmp 0x38c50
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x38c39
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0xa770
leaq -0x98(%rbp), %rdi
callq 0x83f0
leaq -0x20(%rbp), %rdi
callq 0x3aa50
jmp 0x38c60
movq -0x100(%rbp), %rax
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
movq -0x28(%rbp), %rdi
callq 0x8bc0
nopl (%rax)