// File: obliviousram[P]oblivious-avl-tree/src/OAVLTreeDeterministicEviction.cpp
// Function: OAVLTreeDeterministicEviction::search(int)
int OAVLTreeDeterministicEviction::search(int key) {
    if (root.id == -1) throw SearchFailureException();
    moveToLocal(root.leaf_id, root.id);
    Block b = local[0];
    while (b.data[0] != key) {
        if (b.data[0] < key) {
            if (b.rightChildId != -1) {
                moveToLocal(b.rightChildPos, b.rightChildId);
            } else {
                evictAfterSearch();
                throw SearchFailureException();
            }
        } else {
            if (b.leftChildId != -1) {
                moveToLocal(b.leftChildPos, b.leftChildId);
            } else {
                evictAfterSearch();
                throw SearchFailureException();
            }
        }
        b = local[local.size() - 1];
    }
    int val = b.data[1];
    int l = local.size();
    performDummyFinds(num_levels - l);
    evictAfterSearch();
    performDummyEvictions(num_levels - l);
    return val;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x60(%rbp)
cmpl $-0x1, 0x68(%rax)
jne 0xc1ba
movl $0x1, %edi
callq 0x30d0
movq %rax, %rdi
leaq 0x119d7(%rip), %rsi     # 0x1db88
xorl %eax, %eax
movl %eax, %edx
callq 0x3370
movq -0x60(%rbp), %rdi
movl 0x6c(%rdi), %esi
movl 0x68(%rdi), %edx
callq 0x8c10
movq -0x60(%rbp), %rdi
addq $0x48, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x4a10
movq %rax, %rsi
leaq -0x40(%rbp), %rdi
callq 0x3720
movl -0x30(%rbp), %eax
cmpl -0xc(%rbp), %eax
je 0xc2dd
movl -0x30(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0xc25c
cmpl $-0x1, -0x14(%rbp)
je 0xc22d
movq -0x60(%rbp), %rdi
movl -0x18(%rbp), %esi
movl -0x14(%rbp), %edx
callq 0x8c10
jmp 0xc211
jmp 0xc25a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x3830
jmp 0xc33c
movq -0x60(%rbp), %rdi
callq 0xc350
jmp 0xc238
movl $0x1, %edi
callq 0x30d0
movq %rax, %rdi
leaq 0x1193c(%rip), %rsi     # 0x1db88
xorl %eax, %eax
movl %eax, %edx
callq 0x3370
jmp 0xc345
jmp 0xc2a4
cmpl $-0x1, -0x1c(%rbp)
je 0xc275
movq -0x60(%rbp), %rdi
movl -0x20(%rbp), %esi
movl -0x1c(%rbp), %edx
callq 0x8c10
jmp 0xc273
jmp 0xc2a2
movq -0x60(%rbp), %rdi
callq 0xc350
jmp 0xc280
movl $0x1, %edi
callq 0x30d0
movq %rax, %rdi
leaq 0x118f4(%rip), %rsi     # 0x1db88
xorl %eax, %eax
movl %eax, %edx
callq 0x3370
jmp 0xc345
jmp 0xc2a4
movq -0x60(%rbp), %rdi
movq %rdi, %rax
addq $0x48, %rax
movq %rax, -0x68(%rbp)
addq $0x48, %rdi
callq 0x4b50
movq -0x68(%rbp), %rdi
movq %rax, %rsi
subq $0x1, %rsi
callq 0x4a10
movq %rax, %rsi
leaq -0x40(%rbp), %rdi
callq 0x4a30
jmp 0xc1e6
movq -0x60(%rbp), %rdi
movl -0x2c(%rbp), %eax
movl %eax, -0x50(%rbp)
addq $0x48, %rdi
callq 0x4b50
movq -0x60(%rbp), %rdi
movl %eax, -0x54(%rbp)
movl 0x20(%rdi), %esi
movl -0x54(%rbp), %eax
subl %eax, %esi
callq 0xbd30
jmp 0xc306
movq -0x60(%rbp), %rdi
callq 0xc350
jmp 0xc311
movq -0x60(%rbp), %rdi
movl 0x20(%rdi), %esi
movl -0x54(%rbp), %eax
subl %eax, %esi
callq 0xbfe0
jmp 0xc324
movl -0x50(%rbp), %eax
movl %eax, -0x6c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x3830
movl -0x6c(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x33a0
nopw %cs:(%rax,%rax)