// File: momohatt[P]seccampDB/database.cpp
// Function: Transaction::get(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
optional<int> Transaction::get(Key key) {
    TXLOG;

    if (!has_key(key)) {
        wait();
        return nullopt;
    }

    // read from the write set
    if (write_set.count(key) > 0) {
        if (write_set[key].first != New) {
            UNREACHABLE;
            return nullopt;
        }
        // db_->get_lock(this, key, DataBase::Read);
        wait();
        scheduler_->log(id_, key, Read);
        return write_set[key].second;
    }

    while (!db_->get_lock(this, key, Read)) {
        wait();
    }
    lock_set.push_back(key);
    wait();
    scheduler_->log(id_, key, Read);
    return db_->table[key].value;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rsi, -0xc8(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xc0(%rbp)
movl 0x74(%rax), %esi
leaq 0x16611(%rip), %rdi     # 0x1c4d0
leaq 0x16179(%rip), %rdx     # 0x1c03f
xorl %eax, %eax
movl $0x43, %ecx
callq 0x3070
movq -0xc8(%rbp), %rsi
leaq -0x38(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
callq 0x3150
movq -0xc0(%rbp), %rdi
movq -0xb8(%rbp), %rsi
callq 0x61f0
movb %al, -0xa9(%rbp)
jmp 0x5f04
movb -0xa9(%rbp), %al
xorb $-0x1, %al
movb %al, -0xc9(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x35f8
movb -0xc9(%rbp), %al
testb $0x1, %al
jne 0x5f27
jmp 0x5f5b
movq -0xc0(%rbp), %rdi
callq 0x55a0
leaq -0x8(%rbp), %rdi
callq 0x9620
jmp 0x61da
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x35f8
jmp 0x61e7
movq -0xc8(%rbp), %rsi
movq -0xc0(%rbp), %rdi
callq 0x9640
cmpq $0x0, %rax
jbe 0x606b
movq -0xc8(%rbp), %rsi
movq -0xc0(%rbp), %rdi
callq 0x9510
cmpl $0x0, (%rax)
je 0x5fc2
movq 0x26039(%rip), %rax     # 0x2bfd0
movq (%rax), %rdi
leaq 0x16547(%rip), %rsi     # 0x1c4e8
leaq 0x16097(%rip), %rdx     # 0x1c03f
movl $0x4d, %ecx
movb $0x0, %al
callq 0x3470
leaq -0x8(%rbp), %rdi
callq 0x9620
jmp 0x61da
movq -0xc0(%rbp), %rdi
callq 0x55a0
movq -0xc0(%rbp), %rax
movq -0xc8(%rbp), %rsi
movq 0xe0(%rax), %rcx
movq %rcx, -0xe8(%rbp)
movl 0x74(%rax), %eax
movl %eax, -0xdc(%rbp)
leaq -0x68(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x3150
movq -0xe8(%rbp), %rdi
movl -0xdc(%rbp), %esi
movq -0xd8(%rbp), %rdx
xorl %ecx, %ecx
callq 0x93b0
jmp 0x6020
leaq -0x68(%rbp), %rdi
callq 0x35f8
movq -0xc0(%rbp), %rdi
movq -0xc8(%rbp), %rsi
callq 0x9510
movq %rax, %rsi
addq $0x4, %rsi
leaq -0x8(%rbp), %rdi
callq 0x96a0
jmp 0x61da
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x35f8
jmp 0x61e7
jmp 0x606d
movq -0xc0(%rbp), %rax
movq -0xc8(%rbp), %rsi
movq 0xd8(%rax), %rax
movq %rax, -0x100(%rbp)
leaq -0x88(%rbp), %rdi
movq %rdi, -0xf8(%rbp)
callq 0x3150
movq -0x100(%rbp), %rdi
movq -0xc0(%rbp), %rsi
movq -0xf8(%rbp), %rdx
xorl %ecx, %ecx
callq 0x5c80
movb %al, -0xe9(%rbp)
jmp 0x60c0
movb -0xe9(%rbp), %al
xorb $-0x1, %al
movb %al, -0x101(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x35f8
movb -0x101(%rbp), %al
testb $0x1, %al
jne 0x60e6
jmp 0x6114
movq -0xc0(%rbp), %rdi
callq 0x55a0
jmp 0x606d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x35f8
jmp 0x61e7
movq -0xc8(%rbp), %rsi
movq -0xc0(%rbp), %rdi
addq $0x30, %rdi
callq 0x9470
movq -0xc0(%rbp), %rdi
callq 0x55a0
movq -0xc0(%rbp), %rax
movq -0xc8(%rbp), %rsi
movq 0xe0(%rax), %rcx
movq %rcx, -0x120(%rbp)
movl 0x74(%rax), %eax
movl %eax, -0x114(%rbp)
leaq -0xa8(%rbp), %rdi
movq %rdi, -0x110(%rbp)
callq 0x3150
movq -0x120(%rbp), %rdi
movl -0x114(%rbp), %esi
movq -0x110(%rbp), %rdx
xorl %ecx, %ecx
callq 0x93b0
jmp 0x618c
leaq -0xa8(%rbp), %rdi
callq 0x35f8
movq -0xc0(%rbp), %rax
movq -0xc8(%rbp), %rsi
movq 0xd8(%rax), %rdi
callq 0x96d0
movq %rax, %rsi
leaq -0x8(%rbp), %rdi
callq 0x96a0
jmp 0x61da
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x35f8
jmp 0x61e7
movq -0x8(%rbp), %rax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x3540