// File: /workspace/github_cpp_makefile_star2_O2/prakhar2808[P]DBEngine/dbengine/memtableWrapper.cc
// Function: memtableWrapper::getValueFromKey(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int)
opStatus memtableWrapper::getValueFromKey(std::string key, int clientSocket) {
  std::list<memtable*>::iterator iter;
  for(iter = index; iter != memtableObjPointersList.begin(); iter--) {
    if((*iter)->isKeyPresent(key)) {
      std::string val = (*iter)->getValueFromKey(key);
      if(val == "") {
        return opStatus::opKeyNotFound;
      }
      sendToClient(clientSocket, val);
      sendEndMsgToClient(clientSocket);
      return opStatus::opSuccess;
    }
  }

  // Checking in the memtable at the head of the list.
  if((*iter)->isKeyPresent(key)) {
    std::string val = (*iter)->getValueFromKey(key);
    if(val == "") {
      return opStatus::opKeyNotFound;
    }
    sendToClient(clientSocket, val);
    sendEndMsgToClient(clientSocket);
    return opStatus::opSuccess;
  }
  
  return opStatus::opFail;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movl %edx, 0x4(%rsp)
movq %rsi, %r15
movq %rdi, %r14
movq 0x18(%rdi), %rbx
leaq 0xc8(%rsp), %r12
movq 0x10(%rbx), %r13
cmpq (%r14), %rbx
je 0x14009
movq %r12, %rdi
movq %r15, %rsi
callq 0x5540
movq %r13, %rdi
movq %r12, %rsi
callq 0x13202
movl %eax, %ebp
movq %r12, %rdi
callq 0x51d0
testb %bpl, %bpl
jne 0x140c0
movq 0x8(%rbx), %rbx
jmp 0x13fd1
leaq 0x68(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x5540
movq %r13, %rdi
movq %r14, %rsi
callq 0x13202
movl %eax, %ebp
leaq 0x68(%rsp), %rdi
callq 0x51d0
testb %bpl, %bpl
je 0x14112
movq 0x10(%rbx), %r12
leaq 0x88(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x5540
leaq 0x8(%rsp), %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x13218
leaq 0x88(%rsp), %rdi
callq 0x51d0
leaq 0x3370(%rip), %rsi      # 0x173e4
leaq 0x8(%rsp), %rdi
callq 0x7362
testb %al, %al
movl 0x4(%rsp), %ebx
jne 0x1410d
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %r14
movq %r14, %rsi
callq 0x5540
leaq 0x28(%rsp), %rsi
movl %ebx, %edi
callq 0x1677c
leaq 0x28(%rsp), %rdi
callq 0x51d0
xorl %ebp, %ebp
movl %ebx, %edi
callq 0x167ab
jmp 0x14148
movq 0x10(%rbx), %r12
leaq 0xa8(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x5540
leaq 0x8(%rsp), %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x13218
leaq 0xa8(%rsp), %rdi
callq 0x51d0
leaq 0x32e9(%rip), %rsi      # 0x173e4
leaq 0x8(%rsp), %rdi
callq 0x7362
testb %al, %al
movl 0x4(%rsp), %ebx
je 0x14117
pushq $0x2
popq %rbp
jmp 0x14148
pushq $0x3
popq %rbp
jmp 0x14152
leaq 0x48(%rsp), %rdi
leaq 0x8(%rsp), %r14
movq %r14, %rsi
callq 0x5540
leaq 0x48(%rsp), %rsi
movl %ebx, %edi
callq 0x1677c
leaq 0x48(%rsp), %rdi
callq 0x51d0
xorl %ebp, %ebp
movl %ebx, %edi
callq 0x167ab
leaq 0x8(%rsp), %rdi
callq 0x51d0
movl %ebp, %eax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
jmp 0x14178
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x51d0
jmp 0x14188
jmp 0x14185
jmp 0x14185
jmp 0x14185
movq %rax, %rbx
movq %r14, %rdi
jmp 0x141a2
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
jmp 0x141a2
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
callq 0x51d0
movq %rbx, %rdi
callq 0x56c0
nop