// File: prakhar2808[P]DBEngine/dbengine/dbops.cc
// Function: filePutOp(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, int, database*)
opStatus filePutOp(std::string& inBuffer,
                   int clientSocket,
                   database* dbObject) {
  std::vector<keyValuePair_t> keyValuePairVec;
  int keylen, valuelen;
  std::string key, value;
  // Starting after "FILEPUT".
  for(int i = 7; i < (int)inBuffer.length(); ++i) {
    // Parse key value pairs and put in vector.
    keylen = inBuffer[i];
    valuelen = inBuffer[i + keylen + 1];
    key = inBuffer.substr(i+1, keylen);
    value = inBuffer.substr(i + keylen + 2, keylen);
    keyValuePairVec.push_back(keyValuePair_t(key, value));
    //std::cout << key << " -- " << value << std::endl;
    i = i + keylen + valuelen + 1;
  }
  return dbObject->writeKeyValuePair(keyValuePairVec, clientSocket);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
leaq -0x30(%rbp), %rdi
callq 0xaab0
leaq -0x58(%rbp), %rdi
callq 0x66e0
leaq -0x78(%rbp), %rdi
callq 0x66e0
movl $0x7, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
movl %eax, -0x154(%rbp)
movq -0x8(%rbp), %rdi
callq 0x6780
movq %rax, %rcx
movl -0x154(%rbp), %eax
cmpl %ecx, %eax
jge 0xa722
movq -0x8(%rbp), %rdi
movslq -0x7c(%rbp), %rsi
callq 0x69b0
movq %rax, -0x160(%rbp)
jmp 0xa551
movq -0x160(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x34(%rbp)
movq -0x8(%rbp), %rdi
movl -0x7c(%rbp), %edx
movl -0x34(%rbp), %eax
movl %eax, %ecx
movl %edx, %eax
leal 0x1(%rax,%rcx), %eax
movslq %eax, %rsi
callq 0x69b0
movq %rax, -0x168(%rbp)
jmp 0xa581
movq -0x168(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x38(%rbp)
movq -0x8(%rbp), %rsi
movl -0x7c(%rbp), %eax
incl %eax
movslq %eax, %rdx
movslq -0x34(%rbp), %rcx
leaq -0xb0(%rbp), %rdi
callq 0x6520
jmp 0xa5ac
leaq -0x58(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
movq %rsi, -0x170(%rbp)
callq 0x6630
movq -0x170(%rbp), %rdi
callq 0x6340
movq -0x8(%rbp), %rsi
movl -0x7c(%rbp), %edx
movslq -0x34(%rbp), %rcx
movl %ecx, %edi
movl %edx, %eax
movl %edi, %edx
leal 0x2(%rax,%rdx), %eax
movslq %eax, %rdx
leaq -0xd0(%rbp), %rdi
callq 0x6520
jmp 0xa5f5
leaq -0x78(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
movq %rsi, -0x178(%rbp)
callq 0x6630
movq -0x178(%rbp), %rdi
callq 0x6340
leaq -0x130(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x6210
jmp 0xa62a
leaq -0x150(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x6210
jmp 0xa63c
leaq -0x110(%rbp), %rdi
leaq -0x130(%rbp), %rsi
leaq -0x150(%rbp), %rdx
callq 0x9a20
jmp 0xa658
leaq -0x30(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0xaad0
jmp 0xa66a
leaq -0x110(%rbp), %rdi
callq 0x9890
leaq -0x150(%rbp), %rdi
callq 0x6340
leaq -0x130(%rbp), %rdi
callq 0x6340
movl -0x7c(%rbp), %eax
addl -0x34(%rbp), %eax
addl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0xa518
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0xa764
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0xa714
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0xa708
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x9890
leaq -0x150(%rbp), %rdi
callq 0x6340
leaq -0x130(%rbp), %rdi
callq 0x6340
jmp 0xa764
movq -0x18(%rbp), %rdi
movl -0xc(%rbp), %edx
leaq -0x30(%rbp), %rsi
callq 0x9410
movl %eax, -0x17c(%rbp)
jmp 0xa73a
leaq -0x78(%rbp), %rdi
callq 0x6340
leaq -0x58(%rbp), %rdi
callq 0x6340
leaq -0x30(%rbp), %rdi
callq 0xab00
movl -0x17c(%rbp), %eax
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
leaq -0x78(%rbp), %rdi
callq 0x6340
leaq -0x58(%rbp), %rdi
callq 0x6340
leaq -0x30(%rbp), %rdi
callq 0xab00
movq -0x88(%rbp), %rdi
callq 0x68c0
nopl (%rax,%rax)