// File: cybozu[P]yrmcds/src/memcache/handler.cpp
// Function: yrmcds::memcache::handler::gc_ready(long)
bool handler::gc_ready(std::time_t now) {
    if( m_gc_thread.get() != nullptr ) {
        if( ! m_gc_thread->done() )
            return false;
        m_last_gc = now;
        m_gc_thread = nullptr;
    }

    std::time_t t = g_stats.flush_time.load(relaxed);
    if( t != 0 && now >= t )
        return true;

    // run GC immediately if the heap is over used.
    if( g_stats.used_memory.load(relaxed) >
        g_config.memory_limit() ) return true;

    // Run GC when there are new slaves.
    // In case there are unstable slaves that try to connect to
    // the master too frequently, the number of consecutive GCs is limited.
    if( ! m_new_slaves.empty() && m_consecutive_gcs < MAX_CONSECUTIVE_GCS ) {
        ++m_consecutive_gcs;
        return true;
    }

    if( now > (m_last_gc + g_config.gc_interval()) ) {
        m_consecutive_gcs = 0;
        return true;
    }

    return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x40(%rbp)
movq %rsi, -0x48(%rbp)
movq -0x40(%rbp), %rdi
movq %rdi, -0x58(%rbp)
addq $0x68, %rdi
callq 0x39bb0
cmpq $0x0, %rax
je 0x36e25
movq -0x58(%rbp), %rdi
addq $0x68, %rdi
callq 0x39be0
movq %rax, %rdi
callq 0x39c00
testb $0x1, %al
jne 0x36e0c
movb $0x0, -0x31(%rbp)
jmp 0x36fd0
movq -0x58(%rbp), %rdi
movq -0x48(%rbp), %rax
movq %rax, 0x60(%rdi)
addq $0x68, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x39c30
leaq 0x791d4(%rip), %rax     # 0xb0000
addq $0xc0, %rax
movq %rax, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x68(%rbp)
movl -0x24(%rbp), %edi
movl $0xffff, %esi           # imm = 0xFFFF
callq 0x104e0
movl %eax, -0x28(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x5c(%rbp)
decl %eax
subl $0x2, %eax
jb 0x36e7b
jmp 0x36e64
movl -0x5c(%rbp), %eax
subl $0x5, %eax
je 0x36e88
jmp 0x36e6e
movq -0x68(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0x36e93
movq -0x68(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0x36e93
movq -0x68(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x36eb5
movq -0x48(%rbp), %rax
cmpq -0x50(%rbp), %rax
jl 0x36eb5
movb $0x1, -0x31(%rbp)
jmp 0x36fd0
leaq 0x79144(%rip), %rax     # 0xb0000
addq $0x28, %rax
movq %rax, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x78(%rbp)
movl -0xc(%rbp), %edi
movl $0xffff, %esi           # imm = 0xFFFF
callq 0x104e0
movl %eax, -0x10(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x6c(%rbp)
decl %eax
subl $0x2, %eax
jb 0x36f09
jmp 0x36ef2
movl -0x6c(%rbp), %eax
subl $0x5, %eax
je 0x36f16
jmp 0x36efc
movq -0x78(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x36f21
movq -0x78(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x36f21
movq -0x78(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x80(%rbp)
leaq 0x78dd0(%rip), %rdi     # 0xafd00
callq 0x39c60
movq %rax, %rcx
movq -0x80(%rbp), %rax
cmpq %rcx, %rax
jbe 0x36f4a
movb $0x1, -0x31(%rbp)
jmp 0x36fd0
movq -0x58(%rbp), %rdi
addq $0x90, %rdi
callq 0x39c80
testb $0x1, %al
jne 0x36f7b
movq -0x58(%rbp), %rax
cmpl $0x3, 0x70(%rax)
jge 0x36f7b
movq -0x58(%rbp), %rax
movl 0x70(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x70(%rax)
movb $0x1, -0x31(%rbp)
jmp 0x36fd0
movq -0x58(%rbp), %rax
movq -0x48(%rbp), %rcx
movq %rcx, -0x88(%rbp)
movq 0x60(%rax), %rax
movq %rax, -0x90(%rbp)
leaq 0x78d64(%rip), %rdi     # 0xafd00
callq 0x39cc0
movq -0x90(%rbp), %rcx
movl %eax, %edx
movq -0x88(%rbp), %rax
movl %edx, %edx
addq %rdx, %rcx
cmpq %rcx, %rax
jle 0x36fcc
movq -0x58(%rbp), %rax
movl $0x0, 0x70(%rax)
movb $0x1, -0x31(%rbp)
jmp 0x36fd0
movb $0x0, -0x31(%rbp)
movb -0x31(%rbp), %al
andb $0x1, %al
addq $0x90, %rsp
popq %rbp
retq
nop