// File: prakhar2808[P]DBEngine/dbengine/sstableWrapper.cc
// Function: sstableWrapper::getValueFromKey(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int)
opStatus sstableWrapper::getValueFromKey(std::string key, int clientSocket) {
  std::list<sstable*>::reverse_iterator iter;
  int count = 0;
  for(iter = sstableObjRefList.rbegin();
      iter != sstableObjRefList.rend();
      ++iter) {
    ++count;
    // Check the in-memory bloom filter first.
    if(!((*iter)->isKeyPresent(key))) {
      continue;
    }
    // Now the SSTable may contain the key.
    opStatus ret = (*iter)->getValueFromKey(key, clientSocket);
    // The key is found in the SSTable then the return will be opSuccess.
    if(ret == opStatus::opSuccess) {
      std::cout << "Checked " << count << " SSTables and found!" << std::endl;
      return ret;
    }
    // The key is found as a tombstone.
    if(ret == opStatus::opKeyNotFound) {
      std::cout << "Checked " << count << " SSTables but NOT found!" 
                << std::endl;
      return ret;
    }
  }
  std::cout << "Checked " << count << " SSTables but NOT found!" << std::endl;
  return opStatus::opKeyNotFound;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rsi, -0xa0(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x98(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x3c8c0
movq -0x98(%rbp), %rsi
movl $0x0, -0x2c(%rbp)
addq $0x8, %rsi
leaq -0x38(%rbp), %rdi
callq 0x3c8e0
movq -0x38(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x98(%rbp), %rsi
addq $0x8, %rsi
leaq -0x40(%rbp), %rdi
callq 0x3c960
leaq -0x28(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x3c930
testb $0x1, %al
jne 0x3c33e
jmp 0x3c4f1
movl -0x2c(%rbp), %eax
incl %eax
movl %eax, -0x2c(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x3c9b0
movq -0xa0(%rbp), %rsi
movq (%rax), %rax
movq %rax, -0xb8(%rbp)
leaq -0x60(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
callq 0x6210
movq -0xb8(%rbp), %rdi
movq -0xb0(%rbp), %rsi
callq 0x38d80
movb %al, -0xa1(%rbp)
jmp 0x3c38b
movb -0xa1(%rbp), %al
xorb $-0x1, %al
movb %al, -0xb9(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x6340
movb -0xb9(%rbp), %al
testb $0x1, %al
jne 0x3c3ae
jmp 0x3c3cd
jmp 0x3c4e3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x6340
jmp 0x3c540
leaq -0x28(%rbp), %rdi
callq 0x3c9b0
movq -0xa0(%rbp), %rsi
movq (%rax), %rax
movq %rax, -0xd0(%rbp)
leaq -0x90(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
callq 0x6210
movq -0xd0(%rbp), %rdi
movq -0xc8(%rbp), %rsi
movl -0x1c(%rbp), %edx
callq 0x38df0
movl %eax, -0xc0(%rbp)
jmp 0x3c418
leaq -0x90(%rbp), %rdi
callq 0x6340
movl -0xc0(%rbp), %eax
movl %eax, -0x70(%rbp)
cmpl $0x0, -0x70(%rbp)
jne 0x3c497
movq 0x22b86(%rip), %rdi     # 0x5efc0
leaq 0x518a(%rip), %rsi      # 0x415cb
callq 0x64e0
movq %rax, %rdi
movl -0x2c(%rbp), %esi
callq 0x6880
movq %rax, %rdi
leaq 0x5179(%rip), %rsi      # 0x415d4
callq 0x64e0
movq %rax, %rdi
movq 0x22b26(%rip), %rsi     # 0x5ef90
callq 0x6540
movl -0x70(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3c534
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x6340
jmp 0x3c540
cmpl $0x2, -0x70(%rbp)
jne 0x3c4e1
movq 0x22b1c(%rip), %rdi     # 0x5efc0
leaq 0x5120(%rip), %rsi      # 0x415cb
callq 0x64e0
movq %rax, %rdi
movl -0x2c(%rbp), %esi
callq 0x6880
movq %rax, %rdi
leaq 0x5124(%rip), %rsi      # 0x415e9
callq 0x64e0
movq %rax, %rdi
movq 0x22abc(%rip), %rsi     # 0x5ef90
callq 0x6540
movl -0x70(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3c534
jmp 0x3c4e3
leaq -0x28(%rbp), %rdi
callq 0x3c9e0
jmp 0x3c314
movq 0x22ac8(%rip), %rdi     # 0x5efc0
leaq 0x50cc(%rip), %rsi      # 0x415cb
callq 0x64e0
movq %rax, %rdi
movl -0x2c(%rbp), %esi
callq 0x6880
movq %rax, %rdi
leaq 0x50d0(%rip), %rsi      # 0x415e9
callq 0x64e0
movq %rax, %rdi
movq 0x22a68(%rip), %rsi     # 0x5ef90
callq 0x6540
movl $0x2, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq
movq -0x68(%rbp), %rdi
callq 0x68c0
nopl (%rax)