// File: /workspace/github_cpp_makefile_star2_O3/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, %r14
movq 0x18(%rdi), %rbx
cmpq %rbx, (%rdi)
je 0x1702b
movq %rdi, %r15
leaq 0x78(%rsp), %r12
movq 0x10(%rbx), %r13
movq %r12, 0x68(%rsp)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x68(%rsp), %rbp
movq %rbp, %rdi
callq 0x6924
movq %r13, %rdi
movq %rbp, %rsi
callq 0x15d6a
movl %eax, %ebp
movq 0x68(%rsp), %rdi
cmpq %r12, %rdi
je 0x17019
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x5390
testb %bpl, %bpl
jne 0x17154
movq 0x8(%rbx), %rbx
cmpq (%r15), %rbx
jne 0x16fd5
movq 0x10(%rbx), %r15
leaq 0x98(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x88(%rsp), %r12
movq %r12, %rdi
callq 0x6924
movq %r15, %rdi
movq %r12, %rsi
callq 0x15d6a
movl %eax, %r15d
movq 0x88(%rsp), %rdi
cmpq %r13, %rdi
je 0x17080
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x5390
movl $0x3, %ebp
testb %r15b, %r15b
je 0x17233
movq 0x10(%rbx), %r15
leaq 0xb8(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0xa8(%rsp), %r14
movq %r14, %rdi
callq 0x6924
leaq 0x8(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x15d80
movq 0xa8(%rsp), %rdi
cmpq %r12, %rdi
movl 0x4(%rsp), %ebx
je 0x170ea
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x5390
leaq 0x42f3(%rip), %rsi      # 0x1b3e4
leaq 0x8(%rsp), %rdi
callq 0x50f0
testl %eax, %eax
je 0x17213
leaq 0x38(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x28(%rsp), %rdi
callq 0x6924
leaq 0x28(%rsp), %rsi
movl %ebx, %edi
callq 0x1a9d7
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
je 0x17146
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x5390
xorl %ebp, %ebp
movl %ebx, %edi
callq 0x1aa11
jmp 0x17218
movq 0x10(%rbx), %r15
leaq 0xd8(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0xc8(%rsp), %r14
movq %r14, %rdi
callq 0x6924
leaq 0x8(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x15d80
movq 0xc8(%rsp), %rdi
cmpq %r12, %rdi
movl 0x4(%rsp), %ebx
je 0x171b0
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x5390
leaq 0x422d(%rip), %rsi      # 0x1b3e4
leaq 0x8(%rsp), %rdi
callq 0x50f0
testl %eax, %eax
je 0x17213
leaq 0x58(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x48(%rsp), %rdi
callq 0x6924
leaq 0x48(%rsp), %rsi
movl %ebx, %edi
callq 0x1a9d7
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0x17208
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x5390
xorl %ebp, %ebp
movl %ebx, %edi
callq 0x1aa11
jmp 0x17218
movl $0x2, %ebp
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x17233
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x5390
movl %ebp, %eax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0x17296
movq 0x58(%rsp), %rsi
jmp 0x1726d
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
je 0x17296
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x5390
jmp 0x17296
movq %rax, %rbx
movq 0xc8(%rsp), %rdi
jmp 0x172a0
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
jmp 0x172a0
jmp 0x17293
movq %rax, %rbx
leaq 0x18(%rsp), %r12
movq -0x10(%r12), %rdi
cmpq %r12, %rdi
je 0x172df
movq (%r12), %rsi
jmp 0x172d7
movq %rax, %rbx
movq 0x88(%rsp), %rdi
cmpq %r13, %rdi
je 0x172df
movq 0x98(%rsp), %rsi
jmp 0x172d7
movq %rax, %rbx
movq 0x68(%rsp), %rdi
cmpq %r12, %rdi
je 0x172df
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x5390
movq %rbx, %rdi
callq 0x5670
nop