// File: obliviousram[P]oblivious-avl-tree/src/CorrectnessTester.cpp
// Function: CorrectnessTester::runTester1()
void CorrectnessTester::runTester1() {
    int bucketSize = 4;
    int numBlocks = pow(2, 10);
    Bucket::setMaxSize(bucketSize);    

    UntrustedStorageInterface* storage = new ServerStorage();
    RandForOramInterface* random = new RandomForOram();
    OAVLTreeInterface* oavl = new OAVLTreePathEviction(storage, random, bucketSize, numBlocks);

    cout << "Test begins..." << endl;

    cout << "insert " << 9<< endl;
    oavl->insert(9,9);
    storage->dumpAllValidBlocks();
    
    for (int i = 7; i >= 1; i-=2){
        cout << "insert " << i<< endl;
        oavl->insert(i,i);
        storage->dumpAllValidBlocks();
        cout << "insert " << i+1<< endl;
        oavl->insert(i+1,i+1);
        storage->dumpAllValidBlocks();
    }
    int res = oavl->search(9);
    cout << res << endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movl $0x4, -0xc(%rbp)
movl $0x2, %edi
movl $0xa, %esi
callq 0x6c00
cvttsd2si %xmm0, %eax
movl %eax, -0x10(%rbp)
movl -0xc(%rbp), %edi
callq 0x4730
movl $0x28, %edi
callq 0x3210
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x48(%rbp)
callq 0x13600
jmp 0x64ac
movq -0x48(%rbp), %rax
movq %rax, -0x18(%rbp)
movl $0x13d0, %edi           # imm = 0x13D0
callq 0x3210
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x50(%rbp)
callq 0x11de0
jmp 0x64cf
movq -0x50(%rbp), %rax
movq %rax, -0x30(%rbp)
movl $0x70, %edi
callq 0x3210
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rsi
movq -0x30(%rbp), %rdx
movl -0xc(%rbp), %ecx
movl -0x10(%rbp), %r8d
callq 0xd6e0
jmp 0x6501
movq -0x58(%rbp), %rax
movq %rax, -0x38(%rbp)
movq 0x17ac8(%rip), %rdi     # 0x1dfd8
leaq 0xfcd2(%rip), %rsi      # 0x161e9
callq 0x31f0
movq %rax, %rdi
movq 0x17aa2(%rip), %rsi     # 0x1dfc8
callq 0x3230
movq 0x17aa6(%rip), %rdi     # 0x1dfd8
leaq 0xfcc2(%rip), %rsi      # 0x161fb
callq 0x31f0
movq %rax, %rdi
movl $0x9, %esi
callq 0x3380
movq %rax, %rdi
movq 0x17a73(%rip), %rsi     # 0x1dfc8
callq 0x3230
movq -0x38(%rbp), %rdi
movq (%rdi), %rax
movl $0x9, %edx
movl %edx, %esi
callq *(%rax)
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
movl $0x7, -0x3c(%rbp)
cmpl $0x1, -0x3c(%rbp)
jl 0x667c
movq 0x17a4c(%rip), %rdi     # 0x1dfd8
leaq 0xfc68(%rip), %rsi      # 0x161fb
callq 0x31f0
movq %rax, %rdi
movl -0x3c(%rbp), %esi
callq 0x3380
movq %rax, %rdi
movq 0x17a1b(%rip), %rsi     # 0x1dfc8
callq 0x3230
movq -0x38(%rbp), %rdi
movl -0x3c(%rbp), %esi
movl -0x3c(%rbp), %edx
movq (%rdi), %rax
callq *(%rax)
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
movq 0x17a06(%rip), %rdi     # 0x1dfd8
leaq 0xfc22(%rip), %rsi      # 0x161fb
callq 0x31f0
movq %rax, %rdi
movl -0x3c(%rbp), %esi
addl $0x1, %esi
callq 0x3380
movq %rax, %rdi
movq 0x179d2(%rip), %rsi     # 0x1dfc8
callq 0x3230
movq -0x38(%rbp), %rdi
movl -0x3c(%rbp), %esi
addl $0x1, %esi
movl -0x3c(%rbp), %edx
addl $0x1, %edx
movq (%rdi), %rax
callq *(%rax)
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
movl -0x3c(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x3c(%rbp)
jmp 0x657b
movq -0x48(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x28, %esi
callq 0x3220
jmp 0x66b2
movq -0x50(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x13d0, %esi           # imm = 0x13D0
callq 0x3220
jmp 0x66b2
movq -0x58(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x70, %esi
callq 0x3220
jmp 0x66b2
movq -0x38(%rbp), %rdi
movq (%rdi), %rax
movl $0x9, %esi
callq *0x8(%rax)
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %esi
movq 0x17940(%rip), %rdi     # 0x1dfd8
callq 0x3380
movq %rax, %rdi
movq 0x17921(%rip), %rsi     # 0x1dfc8
callq 0x3230
addq $0x60, %rsp
popq %rbp
retq
movq -0x20(%rbp), %rdi
callq 0x33a0
nopl (%rax,%rax)