// File: UBOdin[P]jitd-cpp/src/ds_tester.cpp
// Function: ds_test(std::istream&)
void ds_test(istream &input) 
{
  string line;
  shared_ptr<map<Key,Value>> ds(new map<Key,Value>());

  while(getline(input, line)){
    istringstream toks(line);
    string op;

    CASE_1("--") {
      // skip, comment
    } CASE("init") {
      RecordBuffer data = buffer_cmd(toks);
      vector<pair<Key, Value>> map_data;

      for(BufferElement<Record> curr = data->begin(); curr != data->end(); ++curr){
        map_data.push_back(std::make_pair(curr->key, curr->value));
      }

      timeval start, end;      
      gettimeofday(&start, NULL);
      for(vector<pair<Key,Value>>::iterator curr = map_data.begin(); curr != map_data.end(); curr++){
        ds->insert(*curr);
      }
      // for(BufferElement<Record> curr = data->begin(); curr != data->end(); ++curr){
      //   ds->emplace(curr->key, curr->value);
      // }
      gettimeofday(&end, NULL);
      cout << "Load Map: " << total_time(start, end) << " us" << endl;

    } else {
      cout << "Skipping irrelevant operation: " << line << endl;
    }

  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x380, %rsp            # imm = 0x380
movq %rdi, -0x8(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x4350
movl $0x30, %edi
callq 0x4290
movq %rax, -0x2d8(%rbp)
jmp 0x1c3bb
movq -0x2d8(%rbp), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
callq 0x1c920
movq -0x2d8(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x1c940
jmp 0x1c3e7
jmp 0x1c3e9
movq -0x8(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x4050
movq %rax, -0x2e0(%rbp)
jmp 0x1c3ff
movq -0x2e0(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x4310
movb %al, -0x2e1(%rbp)
jmp 0x1c41d
movb -0x2e1(%rbp), %al
testb $0x1, %al
jne 0x1c42c
jmp 0x1c8e7
leaq -0x1c8(%rbp), %rdi
leaq -0x28(%rbp), %rsi
movl $0x8, %edx
callq 0x43e0
jmp 0x1c443
leaq -0x1e8(%rbp), %rdi
movq %rdi, -0x2f0(%rbp)
callq 0x4350
movq -0x2f0(%rbp), %rsi
leaq -0x1c8(%rbp), %rdi
callq 0x4320
jmp 0x1c46b
leaq -0x209(%rbp), %rdi
movq %rdi, -0x2f8(%rbp)
callq 0x4430
movq -0x2f8(%rbp), %rdx
leaq 0x3c69(%rip), %rsi      # 0x200f5
leaq -0x208(%rbp), %rdi
callq 0x4340
jmp 0x1c49a
leaq -0x208(%rbp), %rdi
leaq -0x1e8(%rbp), %rsi
callq 0x7690
movb %al, -0x2f9(%rbp)
leaq -0x208(%rbp), %rdi
callq 0x4180
leaq -0x209(%rbp), %rdi
callq 0x42d0
movb -0x2f9(%rbp), %al
testb $0x1, %al
jne 0x1c4d7
jmp 0x1c52c
jmp 0x1c8b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1c90b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1c902
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1c8cd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x209(%rbp), %rdi
callq 0x42d0
jmp 0x1c8cd
leaq -0x231(%rbp), %rdi
movq %rdi, -0x308(%rbp)
callq 0x4430
movq -0x308(%rbp), %rdx
leaq 0x428d(%rip), %rsi      # 0x207da
leaq -0x230(%rbp), %rdi
callq 0x4340
jmp 0x1c55b
leaq -0x230(%rbp), %rdi
leaq -0x1e8(%rbp), %rsi
callq 0x7690
movb %al, -0x309(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x4180
leaq -0x231(%rbp), %rdi
callq 0x42d0
movb -0x309(%rbp), %al
testb $0x1, %al
jne 0x1c59b
jmp 0x1c862
leaq -0x248(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
callq 0x1e570
jmp 0x1c5b0
leaq -0x260(%rbp), %rdi
callq 0x1c970
leaq -0x248(%rbp), %rdi
callq 0x7310
movq %rax, %rdi
callq 0x73d0
movq %rax, -0x270(%rbp)
leaq -0x268(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0x7400
leaq -0x248(%rbp), %rdi
callq 0x7310
movq %rax, %rdi
callq 0x7440
movq %rax, -0x278(%rbp)
leaq -0x268(%rbp), %rdi
leaq -0x278(%rbp), %rsi
callq 0x1c990
testb $0x1, %al
jne 0x1c621
jmp 0x1c6f4
leaq -0x268(%rbp), %rdi
movq %rdi, -0x330(%rbp)
callq 0x7ad0
movq -0x330(%rbp), %rdi
movq %rax, -0x328(%rbp)
callq 0x7ad0
movq -0x328(%rbp), %rdi
movq %rax, %rsi
addq $0x8, %rsi
callq 0x1ca00
movq %rdx, -0x320(%rbp)
movq %rax, -0x318(%rbp)
jmp 0x1c66a
movq -0x320(%rbp), %rax
movq -0x318(%rbp), %rcx
movq %rcx, -0x288(%rbp)
movq %rax, -0x280(%rbp)
leaq -0x260(%rbp), %rdi
leaq -0x288(%rbp), %rsi
callq 0x1c9d0
jmp 0x1c69b
jmp 0x1c69d
leaq -0x268(%rbp), %rdi
callq 0xa030
jmp 0x1c5ea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x231(%rbp), %rdi
callq 0x42d0
jmp 0x1c8cd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x260(%rbp), %rdi
callq 0x1cb90
leaq -0x248(%rbp), %rdi
callq 0x72b0
jmp 0x1c8cd
leaq -0x298(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x43b0
leaq -0x260(%rbp), %rdi
callq 0x1ca30
movq %rax, -0x2b0(%rbp)
leaq -0x260(%rbp), %rdi
callq 0x1caa0
movq %rax, -0x2b8(%rbp)
leaq -0x2b0(%rbp), %rdi
leaq -0x2b8(%rbp), %rsi
callq 0x1ca60
testb $0x1, %al
jne 0x1c743
jmp 0x1c7b1
leaq -0x38(%rbp), %rdi
callq 0x1cad0
movq %rax, -0x348(%rbp)
leaq -0x2b0(%rbp), %rdi
callq 0x1cb30
movq -0x348(%rbp), %rdi
movq %rax, %rsi
callq 0x1caf0
movb %dl, -0x339(%rbp)
movq %rax, -0x338(%rbp)
jmp 0x1c77d
movb -0x339(%rbp), %al
movq -0x338(%rbp), %rcx
movq %rcx, -0x2c8(%rbp)
movb %al, -0x2c0(%rbp)
leaq -0x2b0(%rbp), %rdi
xorl %esi, %esi
callq 0x1cb50
movq %rax, -0x2d0(%rbp)
jmp 0x1c717
xorl %eax, %eax
movl %eax, %esi
leaq -0x2a8(%rbp), %rdi
callq 0x43b0
movq 0x13800(%rip), %rdi     # 0x2ffc8
leaq 0x4797(%rip), %rsi      # 0x20f66
callq 0x4280
movq %rax, -0x350(%rbp)
jmp 0x1c7dd
leaq -0x298(%rbp), %rdi
leaq -0x2a8(%rbp), %rsi
callq 0x1e520
movsd %xmm0, -0x358(%rbp)
jmp 0x1c7fa
movsd -0x358(%rbp), %xmm0
movq -0x350(%rbp), %rdi
callq 0x4470
movq %rax, -0x360(%rbp)
jmp 0x1c817
movq -0x360(%rbp), %rdi
leaq 0x38fc(%rip), %rsi      # 0x20121
callq 0x4280
movq %rax, -0x368(%rbp)
jmp 0x1c833
movq -0x368(%rbp), %rdi
movq 0x1375f(%rip), %rsi     # 0x2ffa0
callq 0x42c0
jmp 0x1c848
leaq -0x260(%rbp), %rdi
callq 0x1cb90
leaq -0x248(%rbp), %rdi
callq 0x72b0
jmp 0x1c8ae
movq 0x1375f(%rip), %rdi     # 0x2ffc8
leaq 0x4701(%rip), %rsi      # 0x20f71
callq 0x4280
movq %rax, -0x370(%rbp)
jmp 0x1c87e
movq -0x370(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x4240
movq %rax, -0x378(%rbp)
jmp 0x1c897
movq -0x378(%rbp), %rdi
movq 0x136fb(%rip), %rsi     # 0x2ffa0
callq 0x42c0
jmp 0x1c8ac
jmp 0x1c8ae
jmp 0x1c8b0
leaq -0x1e8(%rbp), %rdi
callq 0x4180
leaq -0x1c8(%rbp), %rdi
callq 0x4120
jmp 0x1c3e9
leaq -0x1e8(%rbp), %rdi
callq 0x4180
leaq -0x1c8(%rbp), %rdi
callq 0x4120
jmp 0x1c902
leaq -0x38(%rbp), %rdi
callq 0x1cbf0
leaq -0x28(%rbp), %rdi
callq 0x4180
addq $0x380, %rsp            # imm = 0x380
popq %rbp
retq
leaq -0x38(%rbp), %rdi
callq 0x1cbf0
leaq -0x28(%rbp), %rdi
callq 0x4180
movq -0x40(%rbp), %rdi
callq 0x4420
nopl (%rax)