// File: obliviousram[P]PathOHeap/src/Job.cpp
// Function: Job::run()
void Job::run() {
  int bucket_size = 4;
  int num_blocks = pow(2, 5);
  UntrustedStorageInterface* storage = new ServerStorage();
  RandForOHeapInterface* random = new RandomForOHeap();
  OHeapInterface* oheap = new OHeapReadPathEviction(storage, random, bucket_size, num_blocks, false);

  // Sample computation: fill the heap with some numbers, then read it back.
  for (int i = 0; i < num_blocks; i++) {
    oheap->insertBlock(i, Job::sampleData(i));
    std::cout << "Inserting Block " << i << " to OHeap. The stash size is: " <<
        oheap->getStashSize() << std::endl;
  }

  for (int i = 0; i < num_blocks; i++) {
    std::cout << "Extracting Block " << i << " from OHeap. " << oheap->extractMin() << std::endl;
  }

  delete oheap;
  delete random;
  delete storage;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movl $0x4, -0x4(%rbp)
movsd 0xbd0e(%rip), %xmm0     # 0x100e8
movsd 0xbd0e(%rip), %xmm1     # 0x100f0
callq 0x2290
cvttsd2si %xmm0, %eax
movl %eax, -0x8(%rbp)
movl $0x28, %edi
callq 0x2190
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xa8(%rbp)
callq 0xd5a0
jmp 0x440c
movq -0xa8(%rbp), %rax
movq %rax, -0x10(%rbp)
movl $0x20, %edi
callq 0x2190
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xb0(%rbp)
callq 0xd200
jmp 0x4435
movq -0xb0(%rbp), %rax
movq %rax, -0x28(%rbp)
movl $0x58, %edi
callq 0x2190
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xb8(%rbp)
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rdx
movl -0x4(%rbp), %ecx
movl -0x8(%rbp), %r8d
xorl %r9d, %r9d
callq 0x7970
jmp 0x4470
movq -0xb8(%rbp), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x45ba
movq -0x30(%rbp), %rax
movq %rax, -0xd0(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0xc4(%rbp)
movl -0x34(%rbp), %esi
leaq -0x58(%rbp), %rdi
callq 0x4310
movq -0xd0(%rbp), %rdi
movl -0xc4(%rbp), %esi
movq (%rdi), %rax
leaq -0x58(%rbp), %rcx
movq (%rcx), %rdx
movq %rdx, (%rsp)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rsp)
movq 0x10(%rcx), %rdx
movq %rdx, 0x10(%rsp)
movq 0x18(%rcx), %rcx
movq %rcx, 0x18(%rsp)
callq *0x8(%rax)
movq %rax, -0x60(%rbp)
movq 0x13ade(%rip), %rdi     # 0x17fd0
leaq 0xbbff(%rip), %rsi      # 0x100f8
callq 0x2180
movq %rax, %rdi
movl -0x34(%rbp), %esi
callq 0x2280
movq %rax, %rdi
leaq 0xbbf6(%rip), %rsi      # 0x10109
callq 0x2180
movq %rax, -0xc0(%rbp)
movq -0x30(%rbp), %rdi
movq (%rdi), %rax
callq *0x40(%rax)
movq -0xc0(%rbp), %rdi
movl %eax, %esi
callq 0x2280
movq %rax, %rdi
movq 0x13a6f(%rip), %rsi     # 0x17fb0
callq 0x21b0
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x4482
movq -0xa8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
movl $0x28, %esi
callq 0x21a0
jmp 0x46aa
movq -0xb0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
movl $0x20, %esi
callq 0x21a0
jmp 0x46aa
movq -0xb8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
movl $0x58, %esi
callq 0x21a0
jmp 0x46aa
movl $0x0, -0x64(%rbp)
movl -0x64(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x463b
movq 0x13a00(%rip), %rdi     # 0x17fd0
leaq 0xbb51(%rip), %rsi      # 0x10128
callq 0x2180
movq %rax, %rdi
movl -0x64(%rbp), %esi
callq 0x2280
movq %rax, %rdi
leaq 0xbb49(%rip), %rsi      # 0x1013a
callq 0x2180
movq %rax, -0xd8(%rbp)
movq -0x30(%rbp), %rsi
movq (%rsi), %rax
leaq -0xa0(%rbp), %rdi
callq *0x18(%rax)
movq -0xd8(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x2800
movq %rax, %rdi
movq 0x13985(%rip), %rsi     # 0x17fb0
callq 0x21b0
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x45c1
movq -0x30(%rbp), %rax
movq %rax, -0xe0(%rbp)
cmpq $0x0, %rax
je 0x465d
movq -0xe0(%rbp), %rdi
movl $0x8, %esi
callq 0x21a0
movq -0x28(%rbp), %rax
movq %rax, -0xe8(%rbp)
cmpq $0x0, %rax
je 0x467f
movq -0xe8(%rbp), %rdi
movl $0x8, %esi
callq 0x21a0
movq -0x10(%rbp), %rax
movq %rax, -0xf0(%rbp)
cmpq $0x0, %rax
je 0x46a1
movq -0xf0(%rbp), %rdi
movl $0x8, %esi
callq 0x21a0
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
movq -0x18(%rbp), %rdi
callq 0x22a0
nopw %cs:(%rax,%rax)
nopl (%rax)