// File: 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
movq %rsp, %rbp
subq $0x1c0, %rsp            # imm = 0x1C0
movq %rsi, -0x160(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x158(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x36bd0
movq -0x158(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x158(%rbp), %rdi
callq 0x36c30
movq %rax, -0x30(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x36ec0
testb $0x1, %al
jne 0x366a6
jmp 0x3687e
leaq -0x28(%rbp), %rdi
callq 0x36c80
movq -0x160(%rbp), %rsi
movq (%rax), %rax
movq %rax, -0x178(%rbp)
leaq -0x50(%rbp), %rdi
movq %rdi, -0x170(%rbp)
callq 0x6210
movq -0x178(%rbp), %rdi
movq -0x170(%rbp), %rsi
callq 0x33fa0
movb %al, -0x161(%rbp)
jmp 0x366eb
leaq -0x50(%rbp), %rdi
callq 0x6340
movb -0x161(%rbp), %al
testb $0x1, %al
jne 0x36703
jmp 0x36865
leaq -0x28(%rbp), %rdi
callq 0x36c80
movq -0x160(%rbp), %rsi
movq (%rax), %rax
movq %rax, -0x188(%rbp)
leaq -0xa0(%rbp), %rdi
movq %rdi, -0x180(%rbp)
callq 0x6210
movq -0x188(%rbp), %rsi
movq -0x180(%rbp), %rdx
leaq -0x80(%rbp), %rdi
callq 0x34000
jmp 0x36749
leaq -0xa0(%rbp), %rdi
callq 0x6340
leaq 0xaf22(%rip), %rsi      # 0x4167e
leaq -0x80(%rbp), %rdi
callq 0xaa80
movb %al, -0x189(%rbp)
jmp 0x3676d
movb -0x189(%rbp), %al
testb $0x1, %al
jne 0x36779
jmp 0x367d7
movl $0x2, -0x4(%rbp)
movl $0x1, -0xa4(%rbp)
jmp 0x36849
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x6340
jmp 0x36a62
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x6340
jmp 0x36a62
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x36857
movl -0x1c(%rbp), %eax
movl %eax, -0x190(%rbp)
leaq -0xc8(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x6210
jmp 0x367f2
movl -0x190(%rbp), %edi
leaq -0xc8(%rbp), %rsi
callq 0x3e3a0
jmp 0x36806
leaq -0xc8(%rbp), %rdi
callq 0x6340
movl -0x1c(%rbp), %edi
callq 0x3e410
jmp 0x3681c
movl $0x0, -0x4(%rbp)
movl $0x1, -0xa4(%rbp)
jmp 0x36849
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x6340
jmp 0x36857
leaq -0x80(%rbp), %rdi
callq 0x6340
jmp 0x36a56
leaq -0x80(%rbp), %rdi
callq 0x6340
jmp 0x36a62
jmp 0x36867
leaq -0x28(%rbp), %rdi
xorl %esi, %esi
callq 0x36ef0
movq %rax, -0xd0(%rbp)
jmp 0x36680
leaq -0x28(%rbp), %rdi
callq 0x36c80
movq -0x160(%rbp), %rsi
movq (%rax), %rax
movq %rax, -0x1a8(%rbp)
leaq -0xf0(%rbp), %rdi
movq %rdi, -0x1a0(%rbp)
callq 0x6210
movq -0x1a8(%rbp), %rdi
movq -0x1a0(%rbp), %rsi
callq 0x33fa0
movb %al, -0x191(%rbp)
jmp 0x368c6
leaq -0xf0(%rbp), %rdi
callq 0x6340
movb -0x191(%rbp), %al
testb $0x1, %al
jne 0x368e1
jmp 0x36a4f
leaq -0x28(%rbp), %rdi
callq 0x36c80
movq -0x160(%rbp), %rsi
movq (%rax), %rax
movq %rax, -0x1b8(%rbp)
leaq -0x130(%rbp), %rdi
movq %rdi, -0x1b0(%rbp)
callq 0x6210
movq -0x1b8(%rbp), %rsi
movq -0x1b0(%rbp), %rdx
leaq -0x110(%rbp), %rdi
callq 0x34000
jmp 0x3692a
leaq -0x130(%rbp), %rdi
callq 0x6340
leaq 0xad41(%rip), %rsi      # 0x4167e
leaq -0x110(%rbp), %rdi
callq 0xaa80
movb %al, -0x1b9(%rbp)
jmp 0x36951
movb -0x1b9(%rbp), %al
testb $0x1, %al
jne 0x3695d
jmp 0x369be
movl $0x2, -0x4(%rbp)
movl $0x1, -0xa4(%rbp)
jmp 0x36a33
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x6340
jmp 0x36a62
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x6340
jmp 0x36a62
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x36a41
movl -0x1c(%rbp), %eax
movl %eax, -0x1c0(%rbp)
leaq -0x150(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x6210
jmp 0x369dc
movl -0x1c0(%rbp), %edi
leaq -0x150(%rbp), %rsi
callq 0x3e3a0
jmp 0x369f0
leaq -0x150(%rbp), %rdi
callq 0x6340
movl -0x1c(%rbp), %edi
callq 0x3e410
jmp 0x36a06
movl $0x0, -0x4(%rbp)
movl $0x1, -0xa4(%rbp)
jmp 0x36a33
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x150(%rbp), %rdi
callq 0x6340
jmp 0x36a41
leaq -0x110(%rbp), %rdi
callq 0x6340
jmp 0x36a56
leaq -0x110(%rbp), %rdi
callq 0x6340
jmp 0x36a62
movl $0x3, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x68c0
nopl (%rax,%rax)