// File: obliviousram[P]oblivious-avl-tree/src/OAVLTreeDeterministicEviction.cpp
// Function: OAVLTreeDeterministicEviction::evictAfterSearch()
void OAVLTreeDeterministicEviction::evictAfterSearch() {
    while (local.size() > 1)
    {
        local[local.size()-1].leaf_id = rand_gen->getRandomLeaf();
        if (local[local.size()-2].leftChildId == local[local.size()-1].id) {
            local[local.size()-2].leftChildPos = local[local.size()-1].leaf_id;
        } else local[local.size()-2].rightChildPos = local[local.size()-1].leaf_id;
        stash.push_back(local[local.size()-1]);
        local.pop_back();
        evictTwoPaths();
    }
    local[0].leaf_id = rand_gen->getRandomLeaf();
    stash.push_back(local[0]);
    root.id = local[0].id;
    root.leaf_id = local[0].leaf_id;
    local.pop_back();
    evictTwoPaths();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
addq $0x48, %rdi
callq 0x4b50
cmpq $0x1, %rax
jbe 0xc531
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq (%rdi), %rax
callq *(%rax)
movq -0x10(%rbp), %rdi
movl %eax, -0x2c(%rbp)
movq %rdi, %rax
addq $0x48, %rax
movq %rax, -0x38(%rbp)
addq $0x48, %rdi
callq 0x4b50
movq -0x38(%rbp), %rdi
movq %rax, %rsi
subq $0x1, %rsi
callq 0x4a10
movl -0x2c(%rbp), %ecx
movq -0x10(%rbp), %rdi
movl %ecx, 0x8(%rax)
movq %rdi, %rax
addq $0x48, %rax
movq %rax, -0x28(%rbp)
addq $0x48, %rdi
callq 0x4b50
movq -0x28(%rbp), %rdi
movq %rax, %rsi
subq $0x2, %rsi
callq 0x4a10
movq -0x10(%rbp), %rdi
movl 0x24(%rax), %eax
movl %eax, -0x14(%rbp)
movq %rdi, %rax
addq $0x48, %rax
movq %rax, -0x20(%rbp)
addq $0x48, %rdi
callq 0x4b50
movq -0x20(%rbp), %rdi
movq %rax, %rsi
subq $0x1, %rsi
callq 0x4a10
movq %rax, %rcx
movl -0x14(%rbp), %eax
cmpl 0xc(%rcx), %eax
jne 0xc47b
movq -0x10(%rbp), %rdi
movq %rdi, %rax
addq $0x48, %rax
movq %rax, -0x50(%rbp)
addq $0x48, %rdi
callq 0x4b50
movq -0x50(%rbp), %rdi
movq %rax, %rsi
subq $0x1, %rsi
callq 0x4a10
movq -0x10(%rbp), %rdi
movl 0x8(%rax), %eax
movl %eax, -0x3c(%rbp)
movq %rdi, %rax
addq $0x48, %rax
movq %rax, -0x48(%rbp)
addq $0x48, %rdi
callq 0x4b50
movq -0x48(%rbp), %rdi
movq %rax, %rsi
subq $0x2, %rsi
callq 0x4a10
movl -0x3c(%rbp), %ecx
movl %ecx, 0x20(%rax)
jmp 0xc4d7
movq -0x10(%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 -0x10(%rbp), %rdi
movl 0x8(%rax), %eax
movl %eax, -0x54(%rbp)
movq %rdi, %rax
addq $0x48, %rax
movq %rax, -0x60(%rbp)
addq $0x48, %rdi
callq 0x4b50
movq -0x60(%rbp), %rdi
movq %rax, %rsi
subq $0x2, %rsi
callq 0x4a10
movl -0x54(%rbp), %ecx
movl %ecx, 0x28(%rax)
movq -0x10(%rbp), %rdi
movq %rdi, %rax
addq $0x30, %rax
movq %rax, -0x70(%rbp)
movq %rdi, %rax
addq $0x48, %rax
movq %rax, -0x78(%rbp)
addq $0x48, %rdi
callq 0x4b50
movq -0x78(%rbp), %rdi
movq %rax, %rsi
subq $0x1, %rsi
callq 0x4a10
movq -0x70(%rbp), %rdi
movq %rax, %rsi
callq 0x4b80
movq -0x10(%rbp), %rdi
addq $0x48, %rdi
callq 0xd120
movq -0x10(%rbp), %rdi
callq 0xbf70
jmp 0xc367
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq (%rdi), %rax
callq *(%rax)
movq -0x10(%rbp), %rdi
movl %eax, -0x84(%rbp)
addq $0x48, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x4a10
movl -0x84(%rbp), %ecx
movq -0x10(%rbp), %rdi
movl %ecx, 0x8(%rax)
movq %rdi, %rax
addq $0x30, %rax
movq %rax, -0x80(%rbp)
addq $0x48, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x4a10
movq -0x80(%rbp), %rdi
movq %rax, %rsi
callq 0x4b80
movq -0x10(%rbp), %rdi
addq $0x48, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x4a10
movq -0x10(%rbp), %rdi
movl 0xc(%rax), %eax
movl %eax, 0x68(%rdi)
addq $0x48, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x4a10
movq -0x10(%rbp), %rdi
movl 0x8(%rax), %eax
movl %eax, 0x6c(%rdi)
addq $0x48, %rdi
callq 0xd120
movq -0x10(%rbp), %rdi
callq 0xbf70
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)