// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdi, %r14
movq 0x80(%rsi), %rax
subq 0x78(%rsi), %rax
cmpq $0x28, %rax
jne 0x16cc9
movq $0x0, (%r14)
jmp 0x16ec2
movl %edx, %ebp
movq %rsi, %r12
movl $0x148, %edi            # imm = 0x148
callq 0x74f0
movq %rax, %rbx
leaq 0x2fede(%rip), %rax     # 0x46bc0
movl 0xf0(%rax), %edx
leaq 0x8(%r12), %rcx
movq %rbx, %rdi
movl %ebp, %esi
callq 0x174ae
movq %rbx, 0x30(%rsp)
movq 0x80(%r12), %rsi
cmpq 0x88(%r12), %rsi
je 0x16d1c
movq %rbx, (%rsi)
addq $0x8, 0x80(%r12)
jmp 0x16d2b
leaq 0x78(%r12), %rdi
leaq 0x30(%rsp), %rdx
callq 0x17d04
movq 0x30(%r12), %r13
movl $0x28, %edi
callq 0x74f0
movq %rax, %r15
movq 0x30(%rsp), %rax
leaq 0x58(%rsp), %rsi
movq %r12, (%rsi)
movq %rax, 0x8(%rsi)
leaq 0x2bf(%rip), %rax       # 0x17014
movq %rax, 0x18(%rsi)
leaq 0x2ea(%rip), %rax       # 0x1704a
movq %rax, 0x10(%rsi)
movq %r15, %rdi
callq 0x1143a
movq $0x0, 0x20(%r15)
leaq 0x8(%rsp), %rsi
movq %r15, (%rsi)
movq %r13, %rdi
callq 0x10fa4
movq 0x8(%rsp), %rsi
testq %rsi, %rsi
je 0x16d98
leaq 0x8(%rsp), %rdi
callq 0x95ea
movq $0x0, 0x8(%rsp)
movq 0x68(%rsp), %rax
testq %rax, %rax
je 0x16dba
leaq 0x58(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
leaq 0x48(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x1e61b(%rip), %rsi     # 0x353e6
leaq 0x1e623(%rip), %rdx     # 0x353f5
leaq 0x38(%rsp), %rdi
callq 0x9760
leaq 0x78(%rsp), %rdi
movl %ebp, %esi
callq 0x12418
leaq 0x10(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x1227c
leaq 0x38(%rsp), %rdi
leaq 0x10(%rsp), %r15
movq %r15, %rsi
callq 0x75d0
movq (%r15), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x16e23
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x7500
leaq 0x2fc5e(%rip), %rax     # 0x46a88
movl (%rax), %eax
xorl %esi, %esi
cmpl $0x2, %eax
setge %sil
leaq 0x1dc21(%rip), %rdx     # 0x34a5d
leaq 0x10(%rsp), %rdi
callq 0x96e6
movb 0x10(%rsp), %al
cmpb $0x1, %al
jne 0x16e68
movq 0x18(%rsp), %rdi
leaq 0x1e59c(%rip), %rsi     # 0x353f6
movl $0xd, %edx
callq 0x7570
movb 0x10(%rsp), %al
testb $0x1, %al
je 0x16e84
movq 0x18(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
callq 0x7570
movb 0x10(%rsp), %al
testb $0x1, %al
je 0x16e9e
movq 0x18(%rsp), %rdi
leaq 0x1e570(%rip), %rsi     # 0x35404
movl $0xd, %edx
callq 0x7570
leaq 0x10(%rsp), %rdi
callq 0x8f4e
movq %rbx, (%r14)
movq 0x38(%rsp), %rdi
cmpq %r12, %rdi
je 0x16ec2
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x7500
movq %r14, %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x16f35
movq %rax, %r14
jmp 0x16f61
jmp 0x16f4f
movq %rax, %r14
movq 0x8(%rsp), %rsi
testq %rsi, %rsi
je 0x16efa
leaq 0x8(%rsp), %rdi
callq 0x95ea
movq $0x0, 0x8(%rsp)
xorl %ebp, %ebp
jmp 0x16f0d
movq %rax, %r14
movb $0x1, %bpl
movq 0x68(%rsp), %rax
testq %rax, %rax
je 0x16f26
leaq 0x58(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
testb %bpl, %bpl
je 0x16f78
movl $0x28, %esi
movq %r15, %rdi
jmp 0x16f73
movq %rax, %rdi
callq 0x8f80
movq %rax, %r14
movl $0x148, %esi            # imm = 0x148
movq %rbx, %rdi
callq 0x7500
jmp 0x16f81
movq %rax, %r14
jmp 0x16f78
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x8f4e
movq 0x38(%rsp), %rdi
cmpq %r12, %rdi
je 0x16f78
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x7500
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
movq %r14, %rdi
callq 0x79a0
movq %rax, %rdi
callq 0x71a0
callq 0x78e0
jmp 0x16e23
jmp 0x16ed9