// File: /workspace/github_cpp_makefile_star2_O1/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 0x16da5
movq $0x0, (%r14)
jmp 0x16f9f
movl %edx, %ebp
movq %rsi, %r12
movl $0x148, %edi            # imm = 0x148
callq 0x7500
movq %rax, %rbx
leaq 0x2fe02(%rip), %rax     # 0x46bc0
movl 0xf0(%rax), %edx
leaq 0x8(%r12), %rcx
movq %rbx, %rdi
movl %ebp, %esi
callq 0x1757e
movq %rbx, 0x28(%rsp)
movq 0x80(%r12), %rsi
cmpq 0x88(%r12), %rsi
je 0x16df8
movq %rbx, (%rsi)
addq $0x8, 0x80(%r12)
jmp 0x16e07
leaq 0x78(%r12), %rdi
leaq 0x28(%rsp), %rdx
callq 0x17dde
movq 0x30(%r12), %r13
movl $0x28, %edi
callq 0x7500
movq %rax, %r15
movq 0x28(%rsp), %rax
xorps %xmm0, %xmm0
leaq 0x50(%rsp), %rsi
movaps %xmm0, (%rsi)
movaps %xmm0, 0x10(%rsi)
movq %r12, (%rsi)
movq %rax, 0x8(%rsi)
leaq 0x2af(%rip), %rax       # 0x170ea
movq %rax, 0x18(%rsi)
leaq 0x2da(%rip), %rax       # 0x17120
movq %rax, 0x10(%rsi)
movq %r15, %rdi
callq 0x113fa
movq $0x0, 0x20(%r15)
movq %rsp, %rsi
movq %r15, (%rsi)
movq %r13, %rdi
callq 0x1102c
movq (%rsp), %rsi
testq %rsi, %rsi
je 0x16e79
movq %rsp, %rdi
callq 0x961a
movq $0x0, (%rsp)
movq 0x60(%rsp), %rax
testq %rax, %rax
je 0x16e9a
leaq 0x50(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
leaq 0x40(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x1e4f7(%rip), %rsi     # 0x353a2
leaq 0x1e4ff(%rip), %rdx     # 0x353b1
leaq 0x30(%rsp), %rdi
callq 0x97a0
leaq 0x78(%rsp), %rdi
movl %ebp, %esi
callq 0x123df
leaq 0x8(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x12244
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %r15
movq %r15, %rsi
callq 0x75e0
movq (%r15), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x16f03
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x7510
leaq 0x2fb8e(%rip), %rax     # 0x46a98
movl (%rax), %eax
xorl %esi, %esi
cmpl $0x2, %eax
setge %sil
leaq 0x1dafd(%rip), %rdx     # 0x34a19
leaq 0x8(%rsp), %rdi
callq 0x9718
cmpb $0x1, 0x8(%rsp)
jne 0x16f43
movq 0x10(%rsp), %rdi
leaq 0x1e479(%rip), %rsi     # 0x353b2
movl $0xd, %edx
callq 0x7580
cmpb $0x1, 0x8(%rsp)
jne 0x16f5e
movq 0x10(%rsp), %rdi
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
callq 0x7580
cmpb $0x1, 0x8(%rsp)
jne 0x16f7b
movq 0x10(%rsp), %rdi
leaq 0x1e44f(%rip), %rsi     # 0x353c0
movl $0xd, %edx
callq 0x7580
leaq 0x8(%rsp), %rdi
callq 0x8f94
movq %rbx, (%r14)
movq 0x30(%rsp), %rdi
cmpq %r12, %rdi
je 0x16f9f
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x7510
movq %r14, %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1700b
movq %rax, %r14
jmp 0x17037
jmp 0x17025
movq %rax, %r14
movq (%rsp), %rsi
testq %rsi, %rsi
je 0x16fd1
movq %rsp, %rdi
callq 0x961a
movq $0x0, (%rsp)
xorl %ebp, %ebp
jmp 0x16fe3
movq %rax, %r14
movb $0x1, %bpl
movq 0x60(%rsp), %rax
testq %rax, %rax
je 0x16ffc
leaq 0x50(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
testb %bpl, %bpl
je 0x1704e
movl $0x28, %esi
movq %r15, %rdi
jmp 0x17049
movq %rax, %rdi
callq 0x8fc6
movq %rax, %r14
movl $0x148, %esi            # imm = 0x148
movq %rbx, %rdi
callq 0x7510
jmp 0x17057
movq %rax, %r14
jmp 0x1704e
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x8f94
movq 0x30(%rsp), %rdi
cmpq %r12, %rdi
je 0x1704e
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x7510
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
movq %r14, %rdi
callq 0x79b0
movq %rax, %rdi
callq 0x71a0
callq 0x78f0
jmp 0x16f03
jmp 0x16fb6