// File: /workspace/github_cpp_makefile_star2_O1/cybozu[P]yrmcds/src/server.cpp
// Function: yrmcds::server::serve_slave()
void server::serve_slave() {
    for( auto it1 = m_handlers.begin(); it1 != m_handlers.end(); ++it1 ) {
        if( ! (*it1)->on_slave_start() ) {
            // failed to start. stop already started handlers.
            for( auto it2 = m_handlers.begin(); it2 != it1; ++it2 )
                (*it2)->on_slave_end();
            return;
        }
    }

    cybozu::logger::info() << "Slave start";

    m_reactor.run([this](cybozu::reactor& r) {
            if( is_master() ) {
                cybozu::logger::info() << "Detected that this node is eligible to be master. Exit slave mode.";
                r.quit();
                return;
            }

            std::time_t now = std::time(nullptr);
            g_current_time.store(now, std::memory_order_relaxed);

            for( auto& handler: m_handlers )
                handler->on_slave_interval();

            r.fix_garbage();
            r.gc();
        });
    for( auto& handler: m_handlers )
        handler->on_slave_end();

    cybozu::logger::info() << "Slave end";
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
movq 0x120(%rdi), %r14
cmpq 0x128(%rdi), %r14
sete %bpl
je 0xf7a6
movq (%r14), %rdi
movq (%rdi), %rax
callq *0x38(%rax)
testb %al, %al
je 0xf782
addq $0x8, %r14
cmpq 0x128(%rbx), %r14
sete %bpl
je 0xf7a6
movq (%r14), %rdi
movq (%rdi), %rax
callq *0x38(%rax)
addq $0x8, %r14
testb %al, %al
jne 0xf760
addq $-0x8, %r14
movq 0x120(%rbx), %r15
cmpq %r14, %r15
je 0xf79d
movq (%r15), %rdi
movq (%rdi), %rax
callq *0x48(%rax)
addq $0x8, %r15
jmp 0xf789
testb %bpl, %bpl
je 0xf8a1
leaq 0x372eb(%rip), %r15     # 0x46a98
movl (%r15), %eax
xorl %esi, %esi
cmpl $0x2, %eax
setge %sil
leaq 0x25259(%rip), %rdx     # 0x34a19
movq %rsp, %r14
movq %r14, %rdi
callq 0x9718
cmpb $0x1, (%r14)
jne 0xf7e7
movq 0x8(%rsp), %rdi
leaq 0x251f6(%rip), %rsi     # 0x349d3
movl $0xb, %edx
callq 0x7580
movq %rsp, %rdi
callq 0x8f94
leaq 0x8(%rbx), %rdi
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rsi
movaps %xmm0, (%rsi)
movaps %xmm0, 0x10(%rsi)
movq %rbx, (%rsi)
leaq 0x69e(%rip), %rax       # 0xfeaa
movq %rax, 0x18(%rsi)
leaq 0x767(%rip), %rax       # 0xff7e
movq %rax, 0x10(%rsi)
movl $0x1, %edx
callq 0xa43c
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0xf83e
leaq 0x10(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq 0x120(%rbx), %r14
movq 0x128(%rbx), %rbx
cmpq %rbx, %r14
je 0xf860
movq (%r14), %rdi
movq (%rdi), %rax
callq *0x48(%rax)
addq $0x8, %r14
jmp 0xf84c
movl (%r15), %eax
xorl %esi, %esi
cmpl $0x2, %eax
setge %sil
leaq 0x251a6(%rip), %rdx     # 0x34a19
movq %rsp, %rbx
movq %rbx, %rdi
callq 0x9718
cmpb $0x1, (%rbx)
jne 0xf899
movq 0x8(%rsp), %rdi
leaq 0x25150(%rip), %rsi     # 0x349df
movl $0x9, %edx
callq 0x7580
movq %rsp, %rdi
callq 0x8f94
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0xf8ae
movq %rax, %rbx
movq %rsp, %rdi
callq 0x8f94
jmp 0xf8d9
jmp 0xf8e1
movq %rax, %rbx
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0xf8d9
leaq 0x10(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq %rbx, %rdi
callq 0x79b0
movq %rax, %rdi
callq 0x8fc6
nop