// File: cybozu[P]yrmcds/src/counter/gc.cpp
// Function: yrmcds::counter::gc_thread::run()
void gc_thread::run() {
    using namespace std::chrono;
    auto t1 = steady_clock::now();

    gc();
    g_stats.objects.store(m_objects, std::memory_order_relaxed);
    g_stats.used_memory.store(m_used_memory, std::memory_order_relaxed);
    g_stats.conflicts.store(m_conflicts, std::memory_order_relaxed);
    g_stats.gc_count.fetch_add(1, std::memory_order_relaxed);

    auto t2 = steady_clock::now();
    std::uint64_t us = (std::uint64_t)duration_cast<microseconds>(t2-t1).count();
    g_stats.last_gc_elapsed.store(us, std::memory_order_relaxed);
    g_stats.total_gc_elapsed.fetch_add(us, std::memory_order_relaxed);

    cybozu::logger::debug() << "Semaphore GC end: elapsed=" << us
                            << "us, survived=" << m_objects;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x190, %rsp            # imm = 0x190
movq %rdi, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
movq %rax, -0x110(%rbp)
callq 0x88b0
movq -0x110(%rbp), %rdi
movq %rax, -0xc0(%rbp)
callq 0x5f6c0
movq -0x110(%rbp), %rax
movl 0x18(%rax), %eax
leaq 0x50ca7(%rip), %rcx     # 0xafe40
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
movl $0x0, -0x90(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x108(%rbp)
movl -0x90(%rbp), %edi
movl $0xffff, %esi           # imm = 0xFFFF
callq 0x104e0
movl %eax, -0x100(%rbp)
jmp 0x5f1d6
movl -0x100(%rbp), %eax
movl %eax, -0x94(%rbp)
movl -0x90(%rbp), %eax
movl %eax, -0x114(%rbp)
movl -0x8c(%rbp), %ecx
movl %ecx, -0x98(%rbp)
subl $0x3, %eax
je 0x5f21f
jmp 0x5f201
movl -0x114(%rbp), %eax
subl $0x5, %eax
je 0x5f230
jmp 0x5f20e
movq -0x108(%rbp), %rax
movl -0x98(%rbp), %ecx
movl %ecx, (%rax)
jmp 0x5f249
movq -0x108(%rbp), %rax
movl -0x98(%rbp), %ecx
movl %ecx, (%rax)
jmp 0x5f249
movq -0x108(%rbp), %rcx
movl -0x98(%rbp), %eax
xchgl %eax, (%rcx)
jmp 0x5f249
movq %rax, %rdi
callq 0xa7e0
movq -0x110(%rbp), %rax
movq 0x20(%rax), %rax
leaq 0x50be5(%rip), %rcx     # 0xafe40
addq $0x8, %rcx
movq %rcx, -0x48(%rbp)
movq %rax, -0x50(%rbp)
movl $0x0, -0x54(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x120(%rbp)
movl -0x54(%rbp), %edi
movl $0xffff, %esi           # imm = 0xFFFF
callq 0x104e0
movl %eax, -0x58(%rbp)
movl -0x54(%rbp), %eax
movl %eax, -0x118(%rbp)
movq -0x50(%rbp), %rcx
movq %rcx, -0x60(%rbp)
subl $0x3, %eax
je 0x5f2be
jmp 0x5f2a1
movl -0x118(%rbp), %eax
subl $0x5, %eax
je 0x5f2ce
jmp 0x5f2ae
movq -0x120(%rbp), %rax
movq -0x60(%rbp), %rcx
movq %rcx, (%rax)
jmp 0x5f2dc
movq -0x120(%rbp), %rax
movq -0x60(%rbp), %rcx
movq %rcx, (%rax)
jmp 0x5f2dc
movq -0x120(%rbp), %rcx
movq -0x60(%rbp), %rax
xchgq %rax, (%rcx)
movq -0x110(%rbp), %rax
movl 0x1c(%rax), %eax
leaq 0x50b53(%rip), %rcx     # 0xafe40
addq $0x10, %rcx
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
movl $0x0, -0xa8(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0x130(%rbp)
movl -0xa8(%rbp), %edi
movl $0xffff, %esi           # imm = 0xFFFF
callq 0x104e0
movl %eax, -0x124(%rbp)
jmp 0x5f32e
movl -0x124(%rbp), %eax
movl %eax, -0xac(%rbp)
movl -0xa8(%rbp), %eax
movl %eax, -0x134(%rbp)
movl -0xa4(%rbp), %ecx
movl %ecx, -0xb0(%rbp)
subl $0x3, %eax
je 0x5f377
jmp 0x5f359
movl -0x134(%rbp), %eax
subl $0x5, %eax
je 0x5f388
jmp 0x5f366
movq -0x130(%rbp), %rax
movl -0xb0(%rbp), %ecx
movl %ecx, (%rax)
jmp 0x5f3a1
movq -0x130(%rbp), %rax
movl -0xb0(%rbp), %ecx
movl %ecx, (%rax)
jmp 0x5f3a1
movq -0x130(%rbp), %rcx
movl -0xb0(%rbp), %eax
xchgl %eax, (%rcx)
jmp 0x5f3a1
movq %rax, %rdi
callq 0xa7e0
leaq 0x50a98(%rip), %rax     # 0xafe40
addq $0x14, %rax
movq %rax, -0x30(%rbp)
movl $0x1, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x148(%rbp)
movl -0x38(%rbp), %eax
movl -0x34(%rbp), %ecx
movl %ecx, -0x3c(%rbp)
decl %eax
movl %eax, %ecx
movq %rcx, -0x140(%rbp)
subl $0x4, %eax
ja 0x5f3f9
movq -0x140(%rbp), %rax
leaq 0x1db2c(%rip), %rcx     # 0x7cf1c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x148(%rbp), %rcx
movl -0x3c(%rbp), %eax
lock
xaddl %eax, (%rcx)
movl %eax, -0x40(%rbp)
jmp 0x5f456
movq -0x148(%rbp), %rcx
movl -0x3c(%rbp), %eax
lock
xaddl %eax, (%rcx)
movl %eax, -0x40(%rbp)
jmp 0x5f456
movq -0x148(%rbp), %rcx
movl -0x3c(%rbp), %eax
lock
xaddl %eax, (%rcx)
movl %eax, -0x40(%rbp)
jmp 0x5f456
movq -0x148(%rbp), %rcx
movl -0x3c(%rbp), %eax
lock
xaddl %eax, (%rcx)
movl %eax, -0x40(%rbp)
jmp 0x5f456
movq -0x148(%rbp), %rcx
movl -0x3c(%rbp), %eax
lock
xaddl %eax, (%rcx)
movl %eax, -0x40(%rbp)
callq 0x88b0
movq %rax, -0xc8(%rbp)
leaq -0xc8(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0xfc70
movq %rax, -0xe0(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x5fc70
movq %rax, -0xd8(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x5fca0
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rax
leaq 0x50990(%rip), %rcx     # 0xafe40
addq $0x18, %rcx
movq %rcx, -0x68(%rbp)
movq %rax, -0x70(%rbp)
movl $0x0, -0x74(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x158(%rbp)
movl -0x74(%rbp), %edi
movl $0xffff, %esi           # imm = 0xFFFF
callq 0x104e0
movl %eax, -0x78(%rbp)
movl -0x74(%rbp), %eax
movl %eax, -0x14c(%rbp)
movq -0x70(%rbp), %rcx
movq %rcx, -0x80(%rbp)
subl $0x3, %eax
je 0x5f513
jmp 0x5f4f6
movl -0x14c(%rbp), %eax
subl $0x5, %eax
je 0x5f523
jmp 0x5f503
movq -0x158(%rbp), %rax
movq -0x80(%rbp), %rcx
movq %rcx, (%rax)
jmp 0x5f531
movq -0x158(%rbp), %rax
movq -0x80(%rbp), %rcx
movq %rcx, (%rax)
jmp 0x5f531
movq -0x158(%rbp), %rcx
movq -0x80(%rbp), %rax
xchgq %rax, (%rcx)
movq -0xd0(%rbp), %rax
leaq 0x50901(%rip), %rcx     # 0xafe40
addq $0x20, %rcx
movq %rcx, -0x8(%rbp)
movq %rax, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x168(%rbp)
movl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
movq %rcx, -0x20(%rbp)
decl %eax
movl %eax, %ecx
movq %rcx, -0x160(%rbp)
subl $0x4, %eax
ja 0x5f58f
movq -0x160(%rbp), %rax
leaq 0x1d9aa(%rip), %rcx     # 0x7cf30
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x168(%rbp), %rcx
movq -0x20(%rbp), %rax
lock
xaddq %rax, (%rcx)
movq %rax, -0x28(%rbp)
jmp 0x5f5fb
movq -0x168(%rbp), %rcx
movq -0x20(%rbp), %rax
lock
xaddq %rax, (%rcx)
movq %rax, -0x28(%rbp)
jmp 0x5f5fb
movq -0x168(%rbp), %rcx
movq -0x20(%rbp), %rax
lock
xaddq %rax, (%rcx)
movq %rax, -0x28(%rbp)
jmp 0x5f5fb
movq -0x168(%rbp), %rcx
movq -0x20(%rbp), %rax
lock
xaddq %rax, (%rcx)
movq %rax, -0x28(%rbp)
jmp 0x5f5fb
movq -0x168(%rbp), %rcx
movq -0x20(%rbp), %rax
lock
xaddq %rax, (%rcx)
movq %rax, -0x28(%rbp)
leaq -0xf0(%rbp), %rdi
movq %rdi, -0x178(%rbp)
callq 0xded0
movq -0x178(%rbp), %rdi
leaq 0x1d95e(%rip), %rsi     # 0x7cf7a
callq 0x5fcc0
movq %rax, -0x170(%rbp)
jmp 0x5f62a
movq -0x170(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x24e10
movq %rax, -0x180(%rbp)
jmp 0x5f646
movq -0x180(%rbp), %rdi
leaq 0x1d941(%rip), %rsi     # 0x7cf95
callq 0x3a9c0
movq %rax, -0x188(%rbp)
jmp 0x5f662
movq -0x188(%rbp), %rdi
movq -0x110(%rbp), %rsi
addq $0x18, %rsi
callq 0x24620
jmp 0x5f67b
leaq -0xf0(%rbp), %rdi
callq 0xa770
addq $0x190, %rsp            # imm = 0x190
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0xa770
movq -0xf8(%rbp), %rdi
callq 0x8bc0
nopw (%rax,%rax)