// File: prakhar2808[P]DBEngine/dbengine/sstable.cc
// Function: sstable::loadIndexInMemory()
void sstable::loadIndexInMemory() {
  std::ifstream readfd;
  std::string indexFilePath = filePath + ".index";
  readfd.open(indexFilePath);
  readfd >> std::noskipws;
  unsigned char ch;
  long long offset;
  while(readfd.peek() != EOF) {
    // Length of key
    readfd >> ch;
    std::string key((int)ch, '\0');
    // The key
    readfd.read(&key[0], (int)ch);
    std::cout << "Index : Read key " << key;
    // Length of offset
    readfd >> ch;
    offset = 0;
    // The offset
    std::string offsetStr((int)ch, '\0');
    readfd.read(&offsetStr[0], (int)ch);
    // Converting offset to long long from string
    for(int i = 0; i < (int)ch; i++) {
      offset = offset * 10 + (long long)(offsetStr[i] - '0');
    }
    std::cout << " Offset = " << offset << std::endl; 
    index[key] = offset;
  }
  readfd.close();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x310, %rsp            # imm = 0x310
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x2a0(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x65e0
movq -0x2a0(%rbp), %rsi
addq $0x38, %rsi
leaq 0x905b(%rip), %rdx      # 0x415a3
leaq -0x230(%rbp), %rdi
callq 0x346b0
jmp 0x38556
leaq -0x210(%rbp), %rdi
leaq -0x230(%rbp), %rsi
movl $0x8, %edx
callq 0x6450
jmp 0x38570
leaq -0x4127(%rip), %rsi     # 0x34450
leaq -0x210(%rbp), %rdi
callq 0x6830
jmp 0x38585
jmp 0x38587
leaq -0x210(%rbp), %rdi
callq 0x61d0
movl %eax, -0x2a4(%rbp)
jmp 0x3859b
movl -0x2a4(%rbp), %eax
cmpl $-0x1, %eax
je 0x388f7
leaq -0x210(%rbp), %rdi
leaq -0x23d(%rbp), %rsi
callq 0x65d0
jmp 0x385bf
movzbl -0x23d(%rbp), %eax
movq %rax, -0x2b8(%rbp)
leaq -0x269(%rbp), %rdi
movq %rdi, -0x2b0(%rbp)
callq 0x68d0
movq -0x2b8(%rbp), %rsi
movq -0x2b0(%rbp), %rcx
leaq -0x268(%rbp), %rdi
xorl %edx, %edx
callq 0x17140
jmp 0x385fe
leaq -0x269(%rbp), %rdi
callq 0x6560
xorl %eax, %eax
movl %eax, %esi
leaq -0x268(%rbp), %rdi
callq 0x69b0
movq %rax, -0x2c0(%rbp)
jmp 0x38623
movq -0x2c0(%rbp), %rsi
movzbl -0x23d(%rbp), %eax
movl %eax, %edx
leaq -0x210(%rbp), %rdi
callq 0x6660
jmp 0x38641
movq 0x26978(%rip), %rdi     # 0x5efc0
leaq 0x8f06(%rip), %rsi      # 0x41555
callq 0x64e0
movq %rax, -0x2c8(%rbp)
jmp 0x3865d
movq -0x2c8(%rbp), %rdi
leaq -0x268(%rbp), %rsi
callq 0x6480
jmp 0x38672
leaq -0x210(%rbp), %rdi
leaq -0x23d(%rbp), %rsi
callq 0x65d0
jmp 0x38687
movq $0x0, -0x248(%rbp)
movzbl -0x23d(%rbp), %eax
movq %rax, -0x2d8(%rbp)
leaq -0x291(%rbp), %rdi
movq %rdi, -0x2d0(%rbp)
callq 0x68d0
movq -0x2d8(%rbp), %rsi
movq -0x2d0(%rbp), %rcx
leaq -0x290(%rbp), %rdi
xorl %edx, %edx
callq 0x17140
jmp 0x386d1
leaq -0x291(%rbp), %rdi
callq 0x6560
xorl %eax, %eax
movl %eax, %esi
leaq -0x290(%rbp), %rdi
callq 0x69b0
movq %rax, -0x2e0(%rbp)
jmp 0x386f6
movq -0x2e0(%rbp), %rsi
movzbl -0x23d(%rbp), %eax
movl %eax, %edx
leaq -0x210(%rbp), %rdi
callq 0x6660
jmp 0x38714
movl $0x0, -0x298(%rbp)
movl -0x298(%rbp), %eax
movzbl -0x23d(%rbp), %ecx
cmpl %ecx, %eax
jge 0x38844
movq -0x248(%rbp), %rax
addq %rax, %rax
leaq (%rax,%rax,4), %rax
movq %rax, -0x2f0(%rbp)
movslq -0x298(%rbp), %rsi
leaq -0x290(%rbp), %rdi
callq 0x69b0
movq %rax, -0x2e8(%rbp)
jmp 0x38764
movq -0x2f0(%rbp), %rax
movq -0x2e8(%rbp), %rcx
movsbl (%rcx), %ecx
subl $0x30, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x248(%rbp)
movl -0x298(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x298(%rbp)
jmp 0x3871e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x238(%rbp)
movl %eax, -0x23c(%rbp)
jmp 0x38932
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x238(%rbp)
movl %eax, -0x23c(%rbp)
jmp 0x38926
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x238(%rbp)
movl %eax, -0x23c(%rbp)
leaq -0x269(%rbp), %rdi
callq 0x6560
jmp 0x38926
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x238(%rbp)
movl %eax, -0x23c(%rbp)
jmp 0x388e9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x238(%rbp)
movl %eax, -0x23c(%rbp)
leaq -0x291(%rbp), %rdi
callq 0x6560
jmp 0x388e9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x238(%rbp)
movl %eax, -0x23c(%rbp)
leaq -0x290(%rbp), %rdi
callq 0x6340
jmp 0x388e9
movq 0x26775(%rip), %rdi     # 0x5efc0
leaq 0x8d15(%rip), %rsi      # 0x41567
callq 0x64e0
movq %rax, -0x2f8(%rbp)
jmp 0x38860
movq -0x2f8(%rbp), %rdi
movq -0x248(%rbp), %rsi
callq 0x62b0
movq %rax, -0x300(%rbp)
jmp 0x3887c
movq -0x300(%rbp), %rdi
movq 0x26706(%rip), %rsi     # 0x5ef90
callq 0x6540
jmp 0x38891
movq -0x2a0(%rbp), %rdi
movq -0x248(%rbp), %rax
movq %rax, -0x310(%rbp)
leaq -0x268(%rbp), %rsi
callq 0x39900
movq %rax, -0x308(%rbp)
jmp 0x388bb
movq -0x308(%rbp), %rax
movq -0x310(%rbp), %rcx
movq %rcx, (%rax)
leaq -0x290(%rbp), %rdi
callq 0x6340
leaq -0x268(%rbp), %rdi
callq 0x6340
jmp 0x38587
leaq -0x268(%rbp), %rdi
callq 0x6340
jmp 0x38926
leaq -0x210(%rbp), %rdi
callq 0x60f0
jmp 0x38905
leaq -0x230(%rbp), %rdi
callq 0x6340
leaq -0x210(%rbp), %rdi
callq 0x6130
addq $0x310, %rsp            # imm = 0x310
popq %rbp
retq
leaq -0x230(%rbp), %rdi
callq 0x6340
leaq -0x210(%rbp), %rdi
callq 0x6130
movq -0x238(%rbp), %rdi
callq 0x68c0
nopw (%rax,%rax)