// File: dustin[P]kvtest/ep.cc
// Function: kvtest::EventuallyPersistentStore::flush(bool)
void EventuallyPersistentStore::flush(bool shouldWait) {
        LockHolder lh(&mutex);

        if (towrite->empty()) {
            if (shouldWait) {
                if(pthread_cond_wait(&cond, &mutex) != 0) {
                    throw std::runtime_error("Error waiting for signal.");
                }
            }
        } else {
            std::queue<std::string> *q = towrite;
            towrite = NULL;
            initQueue();
            lh.unlock();

            RememberingCallback<bool> cb;
            assert(underlying);

            underlying->begin();
            while (!q->empty()) {
                flushSome(q, cb);
            }
            underlying->commit();

            delete q;
        }
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movb %sil, %al
movq %rdi, -0x8(%rbp)
andb $0x1, %al
movb %al, -0x9(%rbp)
movq -0x8(%rbp), %rsi
movq %rsi, -0xb0(%rbp)
addq $0x48, %rsi
leaq -0x20(%rbp), %rdi
callq 0x7b50
movq -0xb0(%rbp), %rax
movq 0xa0(%rax), %rdi
callq 0xb820
movb %al, -0xa1(%rbp)
jmp 0xa7aa
movb -0xa1(%rbp), %al
testb $0x1, %al
jne 0xa7b9
jmp 0xa866
testb $0x1, -0x9(%rbp)
je 0xa861
movq -0xb0(%rbp), %rsi
movq %rsi, %rdi
addq $0x70, %rdi
addq $0x48, %rsi
callq 0x33f0
movl %eax, -0xb4(%rbp)
jmp 0xa7e2
movl -0xb4(%rbp), %eax
cmpl $0x0, %eax
je 0xa85f
movl $0x10, %edi
callq 0x3110
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xc0(%rbp)
leaq 0x3ed8(%rip), %rsi      # 0xe6e3
callq 0x30c0
jmp 0xa812
movq -0xc0(%rbp), %rdi
movq 0xa7d0(%rip), %rsi      # 0x14ff0
movq 0xa791(%rip), %rdx      # 0x14fb8
callq 0x3430
jmp 0xa9b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0xa9a0
movq -0xc0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x31d0
jmp 0xa9a0
jmp 0xa861
jmp 0xa98e
movq -0xb0(%rbp), %rdi
movq 0xa0(%rdi), %rax
movq %rax, -0x38(%rbp)
movq $0x0, 0xa0(%rdi)
callq 0xa1e0
jmp 0xa88a
leaq -0x20(%rbp), %rdi
callq 0x7c20
jmp 0xa895
leaq -0xa0(%rbp), %rdi
callq 0x6d50
jmp 0xa8a3
movq -0xb0(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0xa8b3
jmp 0xa8d2
leaq 0x3d73(%rip), %rdi      # 0xe62d
leaq 0x3d77(%rip), %rsi      # 0xe638
movl $0x88, %edx
leaq 0x3e30(%rip), %rcx      # 0xe6fd
callq 0x3170
movq -0xb0(%rbp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
movq 0x40(%rax), %rax
callq *%rax
jmp 0xa8e8
jmp 0xa8ea
movq -0x38(%rbp), %rdi
callq 0xb820
movb %al, -0xc1(%rbp)
jmp 0xa8fb
movb -0xc1(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0xa909
jmp 0xa93e
movq -0xb0(%rbp), %rdi
movq -0x38(%rbp), %rsi
leaq -0xa0(%rbp), %rdx
callq 0xad00
jmp 0xa922
jmp 0xa8ea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x7460
jmp 0xa9a0
movq -0xb0(%rbp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
movq 0x48(%rax), %rax
callq *%rax
jmp 0xa954
movq -0x38(%rbp), %rax
movq %rax, -0xd0(%rbp)
cmpq $0x0, %rax
je 0xa982
movq -0xd0(%rbp), %rdi
callq 0xb0a0
movq -0xd0(%rbp), %rdi
movl $0x50, %esi
callq 0x32a0
leaq -0xa0(%rbp), %rdi
callq 0x7460
leaq -0x20(%rbp), %rdi
callq 0x7bf0
addq $0xd0, %rsp
popq %rbp
retq
leaq -0x20(%rbp), %rdi
callq 0x7bf0
movq -0x28(%rbp), %rdi
callq 0x3450
nopw %cs:(%rax,%rax)