// File: cpottamus[P]btree_lab/sim.cc
// Function: main
int main(int argc, char *argv[])
{

  // CONFORMS to the interface of ref_impl.pl

  if (argc != 3){
    usage();
    return 1;
  }

  char *filestem=argv[1];
  SIZE_T cachesize=atoi(argv[2]);
  SIZE_T superblocknum;

  FILE *file; 
  char line[1024];
  int max = 8192;
  ERROR_T rc;
  
  // We'll connect to the btree only once and then
  // run lots of operations
  // so we need to do this outside the loop
  DiskSystem disk(filestem);
  BufferCache cache(&disk,cachesize);
  // will be set on init
  BTreeIndex *btree;


  if ((rc=cache.Attach())!=ERROR_NOERROR) {
    cerr << "Can't attach cache due to error "<<rc<<"\n";
    return -1;
  }
  
  file=stdin;

  //Now simply read each line and call btree functions corresponding to the same
  while (fgets(line, max, file) != NULL){
    // foreach line read we will refer to a case switch statement
    string line2, action, key, value;
    line2 = line;
    istrstream is(line2.c_str(),line2.size());
    is >> action >> key >> value;

    if (action == "INIT") {
      btree = new BTreeIndex(atoi(key.c_str()),atoi(value.c_str()),&cache);
      if ((rc=btree->Attach(0, true))!=ERROR_NOERROR) {
	cerr << "Can't attach btree with initialization due to error "<<rc<<"\n";
	cout << "FAIL\n";
      } else {
	cout << "OK\n";
      }
    } else if (action == "INSERT"){
      if ((rc=btree->Insert(KEY_T(key.c_str()),VALUE_T(value.c_str())))!=ERROR_NOERROR) { 
        cout <<"FAIL"<<endl;
	cerr <<"Can't insert due to error "<<rc<<"\n";
      } else {
        cout <<"OK\n";
      }
    } else if (action == "UPDATE"){
      if ((rc=btree->Update(KEY_T(key.c_str()),VALUE_T(value.c_str())))!=ERROR_NOERROR) { 
        cout <<"FAIL" <<endl;
	cerr <<"Can't update due to error "<<rc<<"\n";
      } else {
        cout <<"OK\n";
      }
    } else if (action == "DELETE"){
      if ((rc=btree->Delete(KEY_T(key.c_str())))!=ERROR_NOERROR) { 
        cout <<"FAIL"<<endl;
	cerr <<"Can't delete due to error "<<rc<<endl;
      } else {
        cout <<"OK\n";
      }
    } else if (action == "LOOKUP"){
      VALUE_T lookup_value;
      if ((rc=btree->Lookup(KEY_T(key.c_str()),lookup_value))!=ERROR_NOERROR) { 
        cout <<"FAIL"<< endl;
	cerr <<"Can't lookup due to error "<<rc<<endl;
      } else {
        cout <<"OK ";
 	for (unsigned int k=0; k<lookup_value.length; k++) {
 	    cout << lookup_value.data[k];
	}
 	cout << endl;
      }
    } else if (action == "DISPLAY") {
      // This should always be OK
      cout <<"OK BEGIN DISPLAY\n";
      btree->Display(cout,BTREE_SORTED_KEYVAL);
      cout <<"OK END DISPLAY\n";
    } else if (action == "DEINIT"){
      if ((rc=btree->Detach(superblocknum))!=ERROR_NOERROR) { 
	cout << "FAIL"<<endl;
	cerr << "Can't detach btree due to error "<<rc<<endl;
      } else {
	if ((rc=cache.Detach())!=ERROR_NOERROR) { 
	  cout <<"FAIL"<<endl;
	  cerr <<"Can't detach cache due to error "<<rc<<endl;
	} else {
	  delete btree;
	  cout << "OK\n";
	}
      }
    }
  }
    
  fclose(file);

  return 0;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa10, %rsp            # imm = 0xA10
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x3, -0x8(%rbp)
je 0x37c0
callq 0x3770
movl $0x1, -0x4(%rbp)
jmp 0x45e6
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x3410
movl %eax, -0x1c(%rbp)
movl $0x2000, -0x434(%rbp)   # imm = 0x2000
movq -0x18(%rbp), %rax
movq %rax, -0x880(%rbp)
leaq -0x4d9(%rbp), %rdi
movq %rdi, -0x878(%rbp)
callq 0x3480
movq -0x880(%rbp), %rsi
movq -0x878(%rbp), %rdx
leaq -0x4d8(%rbp), %rdi
callq 0x4600
jmp 0x3820
movq %rsp, %rax
movl $0x0, 0x10(%rax)
movl $0x0, 0x8(%rax)
movl $0x0, (%rax)
leaq -0x4b8(%rbp), %rdi
leaq -0x4d8(%rbp), %rsi
xorl %r9d, %r9d
xorps %xmm2, %xmm2
movl %r9d, %edx
movl %r9d, %ecx
movl %r9d, %r8d
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
callq 0x4fe0
jmp 0x3861
leaq -0x4d8(%rbp), %rdi
callq 0x3140
leaq -0x4d9(%rbp), %rdi
callq 0x32a0
movl -0x1c(%rbp), %edx
leaq -0x550(%rbp), %rdi
leaq -0x4b8(%rbp), %rsi
callq 0x7d50
jmp 0x3891
leaq -0x550(%rbp), %rdi
callq 0x7f10
movl %eax, -0x884(%rbp)
jmp 0x38a5
movl -0x884(%rbp), %eax
movl %eax, -0x438(%rbp)
cmpl $0x0, %eax
je 0x398d
movq 0x1372f(%rip), %rdi     # 0x16ff0
leaq 0xd767(%rip), %rsi      # 0x1102f
callq 0x3220
movq %rax, -0x890(%rbp)
jmp 0x38d6
movq -0x890(%rbp), %rdi
movl -0x438(%rbp), %esi
callq 0x3460
movq %rax, -0x898(%rbp)
jmp 0x38f1
movq -0x898(%rbp), %rdi
leaq 0xd72e(%rip), %rsi      # 0x1102d
callq 0x3220
jmp 0x3906
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x55c(%rbp)
jmp 0x45b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x4e8(%rbp)
movl %eax, -0x4ec(%rbp)
jmp 0x394e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x4e8(%rbp)
movl %eax, -0x4ec(%rbp)
leaq -0x4d8(%rbp), %rdi
callq 0x3140
leaq -0x4d9(%rbp), %rdi
callq 0x32a0
jmp 0x45f2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x4e8(%rbp)
movl %eax, -0x4ec(%rbp)
jmp 0x45d8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x4e8(%rbp)
movl %eax, -0x4ec(%rbp)
jmp 0x45cc
movq 0x13634(%rip), %rax     # 0x16fc8
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movl -0x434(%rbp), %esi
movq -0x28(%rbp), %rdx
leaq -0x430(%rbp), %rdi
callq 0x3420
movq %rax, -0x8a0(%rbp)
jmp 0x39ba
movq -0x8a0(%rbp), %rax
cmpq $0x0, %rax
je 0x4596
leaq -0x580(%rbp), %rdi
movq %rdi, -0x8a8(%rbp)
callq 0x3390
leaq -0x5a0(%rbp), %rdi
callq 0x3390
leaq -0x5c0(%rbp), %rdi
callq 0x3390
leaq -0x5e0(%rbp), %rdi
callq 0x3390
movq -0x8a8(%rbp), %rdi
leaq -0x430(%rbp), %rsi
callq 0x3370
jmp 0x3a17
leaq -0x580(%rbp), %rdi
movq %rdi, -0x8b8(%rbp)
callq 0x30c0
movq -0x8b8(%rbp), %rdi
movq %rax, -0x8b0(%rbp)
callq 0x3180
movq -0x8b0(%rbp), %rsi
movq %rax, %rdx
leaq -0x750(%rbp), %rdi
callq 0x3070
jmp 0x3a55
leaq -0x750(%rbp), %rdi
leaq -0x5a0(%rbp), %rsi
callq 0x3340
movq %rax, -0x8c0(%rbp)
jmp 0x3a71
movq -0x8c0(%rbp), %rdi
leaq -0x5c0(%rbp), %rsi
callq 0x3340
movq %rax, -0x8c8(%rbp)
jmp 0x3a8d
movq -0x8c8(%rbp), %rdi
leaq -0x5e0(%rbp), %rsi
callq 0x3340
jmp 0x3aa2
leaq 0xd6a3(%rip), %rsi      # 0x1114c
leaq -0x5a0(%rbp), %rdi
callq 0x46b0
movb %al, -0x8c9(%rbp)
jmp 0x3abd
movb -0x8c9(%rbp), %al
testb $0x1, %al
jne 0x3acc
jmp 0x3c43
movl $0x48, %edi
callq 0x3240
movq %rax, -0x8d8(%rbp)
jmp 0x3adf
leaq -0x5c0(%rbp), %rdi
callq 0x30c0
movq %rax, %rdi
callq 0x3410
movl %eax, -0x8dc(%rbp)
leaq -0x5e0(%rbp), %rdi
callq 0x30c0
movq %rax, %rdi
callq 0x3410
movq -0x8d8(%rbp), %rdi
movl -0x8dc(%rbp), %esi
movl %eax, %edx
leaq -0x550(%rbp), %rcx
movl $0x1, %r8d
callq 0xa250
jmp 0x3b30
movq -0x8d8(%rbp), %rax
movq %rax, -0x558(%rbp)
movq -0x558(%rbp), %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0xa620
movl %eax, -0x8e0(%rbp)
jmp 0x3b59
movl -0x8e0(%rbp), %eax
movl %eax, -0x438(%rbp)
cmpl $0x0, %eax
je 0x3c27
movq 0x1347b(%rip), %rdi     # 0x16ff0
leaq 0xd4d4(%rip), %rsi      # 0x11050
callq 0x3220
movq %rax, -0x8e8(%rbp)
jmp 0x3b8a
movq -0x8e8(%rbp), %rdi
movl -0x438(%rbp), %esi
callq 0x3460
movq %rax, -0x8f0(%rbp)
jmp 0x3ba5
movq -0x8f0(%rbp), %rdi
leaq 0xd47a(%rip), %rsi      # 0x1102d
callq 0x3220
jmp 0x3bba
movq 0x1340f(%rip), %rdi     # 0x16fd0
leaq 0xd4bd(%rip), %rsi      # 0x11085
callq 0x3220
jmp 0x3bcf
jmp 0x3c3e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x4e8(%rbp)
movl %eax, -0x4ec(%rbp)
jmp 0x4564
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x4e8(%rbp)
movl %eax, -0x4ec(%rbp)
jmp 0x4558
movq -0x8d8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x4e8(%rbp)
movl %eax, -0x4ec(%rbp)
movl $0x48, %esi
callq 0x3250
jmp 0x4558
movq 0x133a2(%rip), %rdi     # 0x16fd0
leaq 0xd456(%rip), %rsi      # 0x1108b
callq 0x3220
jmp 0x3c3c
jmp 0x3c3e
jmp 0x4517
leaq 0xd445(%rip), %rsi      # 0x1108f
leaq -0x5a0(%rbp), %rdi
callq 0x46b0
movb %al, -0x8f1(%rbp)
jmp 0x3c5e
movb -0x8f1(%rbp), %al
testb $0x1, %al
jne 0x3c6d
jmp 0x3de8
movq -0x558(%rbp), %rax
movq %rax, -0x900(%rbp)
leaq -0x5c0(%rbp), %rdi
callq 0x30c0
movq %rax, %rsi
leaq -0x778(%rbp), %rdi
callq 0x4bc0
jmp 0x3c98
leaq -0x5e0(%rbp), %rdi
callq 0x30c0
movq %rax, %rsi
leaq -0x7a0(%rbp), %rdi
callq 0x4bc0
jmp 0x3cb5
movq -0x900(%rbp), %rdi
leaq -0x778(%rbp), %rsi
leaq -0x7a0(%rbp), %rdx
callq 0xaeb0
movl %eax, -0x904(%rbp)
jmp 0x3cd7
movl -0x904(%rbp), %eax
movl %eax, -0x438(%rbp)
leaq -0x7a0(%rbp), %rdi
callq 0x4c80
leaq -0x778(%rbp), %rdi
callq 0x4c80
movl -0x904(%rbp), %eax
cmpl $0x0, %eax
je 0x3dcc
movq 0x132bf(%rip), %rdi     # 0x16fd0
leaq 0xd37e(%rip), %rsi      # 0x11096
callq 0x3220
movq %rax, -0x910(%rbp)
jmp 0x3d26
movq -0x910(%rbp), %rdi
movq 0x13284(%rip), %rsi     # 0x16fb8
callq 0x3270
jmp 0x3d3b
movq 0x132ae(%rip), %rdi     # 0x16ff0
leaq 0xd352(%rip), %rsi      # 0x1109b
callq 0x3220
movq %rax, -0x918(%rbp)
jmp 0x3d57
movq -0x918(%rbp), %rdi
movl -0x438(%rbp), %esi
callq 0x3460
movq %rax, -0x920(%rbp)
jmp 0x3d72
movq -0x920(%rbp), %rdi
leaq 0xd2ad(%rip), %rsi      # 0x1102d
callq 0x3220
jmp 0x3d87
jmp 0x3de3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x4e8(%rbp)
movl %eax, -0x4ec(%rbp)
jmp 0x3dbb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x4e8(%rbp)
movl %eax, -0x4ec(%rbp)
leaq -0x7a0(%rbp), %rdi
callq 0x4c80
leaq -0x778(%rbp), %rdi
callq 0x4c80
jmp 0x4558
movq 0x131fd(%rip), %rdi     # 0x16fd0
leaq 0xd2b1(%rip), %rsi      # 0x1108b
callq 0x3220
jmp 0x3de1
jmp 0x3de3
jmp 0x4515
leaq 0xd2c7(%rip), %rsi      # 0x110b6
leaq -0x5a0(%rbp), %rdi
callq 0x46b0
movb %al, -0x921(%rbp)
jmp 0x3e03
movb -0x921(%rbp), %al
testb $0x1, %al
jne 0x3e12
jmp 0x3f8d
movq -0x558(%rbp), %rax
movq %rax, -0x930(%rbp)
leaq -0x5c0(%rbp), %rdi
callq 0x30c0
movq %rax, %rsi
leaq -0x7c8(%rbp), %rdi
callq 0x4bc0
jmp 0x3e3d
leaq -0x5e0(%rbp), %rdi
callq 0x30c0
movq %rax, %rsi
leaq -0x7f0(%rbp), %rdi
callq 0x4bc0
jmp 0x3e5a
movq -0x930(%rbp), %rdi
leaq -0x7c8(%rbp), %rsi
leaq -0x7f0(%rbp), %rdx
callq 0xcfe0
movl %eax, -0x934(%rbp)
jmp 0x3e7c
movl -0x934(%rbp), %eax
movl %eax, -0x438(%rbp)
leaq -0x7f0(%rbp), %rdi
callq 0x4c80
leaq -0x7c8(%rbp), %rdi
callq 0x4c80
movl -0x934(%rbp), %eax
cmpl $0x0, %eax
je 0x3f71
movq 0x1311a(%rip), %rdi     # 0x16fd0
leaq 0xd1d9(%rip), %rsi      # 0x11096
callq 0x3220
movq %rax, -0x940(%rbp)
jmp 0x3ecb
movq -0x940(%rbp), %rdi
movq 0x130df(%rip), %rsi     # 0x16fb8
callq 0x3270
jmp 0x3ee0
movq 0x13109(%rip), %rdi     # 0x16ff0
leaq 0xd1cf(%rip), %rsi      # 0x110bd
callq 0x3220
movq %rax, -0x948(%rbp)
jmp 0x3efc
movq -0x948(%rbp), %rdi
movl -0x438(%rbp), %esi
callq 0x3460
movq %rax, -0x950(%rbp)
jmp 0x3f17
movq -0x950(%rbp), %rdi
leaq 0xd108(%rip), %rsi      # 0x1102d
callq 0x3220
jmp 0x3f2c
jmp 0x3f88
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x4e8(%rbp)
movl %eax, -0x4ec(%rbp)
jmp 0x3f60
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x4e8(%rbp)
movl %eax, -0x4ec(%rbp)
leaq -0x7f0(%rbp), %rdi
callq 0x4c80
leaq -0x7c8(%rbp), %rdi
callq 0x4c80
jmp 0x4558
movq 0x13058(%rip), %rdi     # 0x16fd0
leaq 0xd10c(%rip), %rsi      # 0x1108b
callq 0x3220
jmp 0x3f86
jmp 0x3f88
jmp 0x4513
leaq 0xd144(%rip), %rsi      # 0x110d8
leaq -0x5a0(%rbp), %rdi
callq 0x46b0
movb %al, -0x951(%rbp)
jmp 0x3fa8
movb -0x951(%rbp), %al
testb $0x1, %al
jne 0x3fb7
jmp 0x40e2
movq -0x558(%rbp), %rax
movq %rax, -0x960(%rbp)
leaq -0x5c0(%rbp), %rdi
callq 0x30c0
movq %rax, %rsi
leaq -0x818(%rbp), %rdi
callq 0x4bc0
jmp 0x3fe2
movq -0x960(%rbp), %rdi
leaq -0x818(%rbp), %rsi
callq 0xd060
movl %eax, -0x964(%rbp)
jmp 0x3ffd
movl -0x964(%rbp), %eax
movl %eax, -0x438(%rbp)
leaq -0x818(%rbp), %rdi
callq 0x4c80
movl -0x964(%rbp), %eax
cmpl $0x0, %eax
je 0x40c6
movq 0x12fa5(%rip), %rdi     # 0x16fd0
leaq 0xd064(%rip), %rsi      # 0x11096
callq 0x3220
movq %rax, -0x970(%rbp)
jmp 0x4040
movq -0x970(%rbp), %rdi
movq 0x12f6a(%rip), %rsi     # 0x16fb8
callq 0x3270
jmp 0x4055
movq 0x12f94(%rip), %rdi     # 0x16ff0
leaq 0xd07c(%rip), %rsi      # 0x110df
callq 0x3220
movq %rax, -0x978(%rbp)
jmp 0x4071
movq -0x978(%rbp), %rdi
movl -0x438(%rbp), %esi
callq 0x3460
movq %rax, -0x980(%rbp)
jmp 0x408c
movq -0x980(%rbp), %rdi
movq 0x12f1e(%rip), %rsi     # 0x16fb8
callq 0x3270
jmp 0x40a1
jmp 0x40dd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x4e8(%rbp)
movl %eax, -0x4ec(%rbp)
leaq -0x818(%rbp), %rdi
callq 0x4c80
jmp 0x4558
movq 0x12f03(%rip), %rdi     # 0x16fd0
leaq 0xcfb7(%rip), %rsi      # 0x1108b
callq 0x3220
jmp 0x40db
jmp 0x40dd
jmp 0x4511
leaq 0xd011(%rip), %rsi      # 0x110fa
leaq -0x5a0(%rbp), %rdi
callq 0x46b0
movb %al, -0x981(%rbp)
jmp 0x40fd
movb -0x981(%rbp), %al
testb $0x1, %al
jne 0x410c
jmp 0x42e2
leaq -0x840(%rbp), %rdi
callq 0x4980
jmp 0x411a
movq -0x558(%rbp), %rax
movq %rax, -0x990(%rbp)
leaq -0x5c0(%rbp), %rdi
callq 0x30c0
movq %rax, %rsi
leaq -0x868(%rbp), %rdi
callq 0x4bc0
jmp 0x4145
movq -0x990(%rbp), %rdi
leaq -0x868(%rbp), %rsi
leaq -0x840(%rbp), %rdx
callq 0xae70
movl %eax, -0x994(%rbp)
jmp 0x4167
movl -0x994(%rbp), %eax
movl %eax, -0x438(%rbp)
leaq -0x868(%rbp), %rdi
callq 0x4c80
movl -0x994(%rbp), %eax
cmpl $0x0, %eax
je 0x424a
movq 0x12e3b(%rip), %rdi     # 0x16fd0
leaq 0xcefa(%rip), %rsi      # 0x11096
callq 0x3220
movq %rax, -0x9a0(%rbp)
jmp 0x41aa
movq -0x9a0(%rbp), %rdi
movq 0x12e00(%rip), %rsi     # 0x16fb8
callq 0x3270
jmp 0x41bf
movq 0x12e2a(%rip), %rdi     # 0x16ff0
leaq 0xcf34(%rip), %rsi      # 0x11101
callq 0x3220
movq %rax, -0x9a8(%rbp)
jmp 0x41db
movq -0x9a8(%rbp), %rdi
movl -0x438(%rbp), %esi
callq 0x3460
movq %rax, -0x9b0(%rbp)
jmp 0x41f6
movq -0x9b0(%rbp), %rdi
movq 0x12db4(%rip), %rsi     # 0x16fb8
callq 0x3270
jmp 0x420b
jmp 0x42c0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x4e8(%rbp)
movl %eax, -0x4ec(%rbp)
jmp 0x42d1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x4e8(%rbp)
movl %eax, -0x4ec(%rbp)
leaq -0x868(%rbp), %rdi
callq 0x4c80
jmp 0x42d1
movq 0x12d7f(%rip), %rdi     # 0x16fd0
leaq 0xcec4(%rip), %rsi      # 0x1111c
callq 0x3220
jmp 0x425f
movl $0x0, -0x86c(%rbp)
movl -0x86c(%rbp), %eax
cmpl -0x830(%rbp), %eax
jae 0x42a9
movq -0x838(%rbp), %rax
movl -0x86c(%rbp), %ecx
movzbl (%rax,%rcx), %esi
movq 0x12d41(%rip), %rdi     # 0x16fd0
callq 0x33e0
jmp 0x4296
jmp 0x4298
movl -0x86c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x86c(%rbp)
jmp 0x4269
movq 0x12d20(%rip), %rdi     # 0x16fd0
movq 0x12d01(%rip), %rsi     # 0x16fb8
callq 0x3270
jmp 0x42be
jmp 0x42c0
leaq -0x840(%rbp), %rdi
callq 0x4c80
jmp 0x450f
leaq -0x840(%rbp), %rdi
callq 0x4c80
jmp 0x4558
leaq 0xce37(%rip), %rsi      # 0x11120
leaq -0x5a0(%rbp), %rdi
callq 0x46b0
movb %al, -0x9b1(%rbp)
jmp 0x42fd
movb -0x9b1(%rbp), %al
testb $0x1, %al
jne 0x4309
jmp 0x4352
movq 0x12cc0(%rip), %rdi     # 0x16fd0
leaq 0xce11(%rip), %rsi      # 0x11128
callq 0x3220
jmp 0x431e
movq -0x558(%rbp), %rdi
movq 0x12ca4(%rip), %rsi     # 0x16fd0
movl $0x2, %edx
callq 0xda10
jmp 0x4338
movq 0x12c91(%rip), %rdi     # 0x16fd0
leaq 0xcdf4(%rip), %rsi      # 0x1113a
callq 0x3220
jmp 0x434d
jmp 0x450d
leaq 0xcdf1(%rip), %rsi      # 0x1114a
leaq -0x5a0(%rbp), %rdi
callq 0x46b0
movb %al, -0x9b2(%rbp)
jmp 0x436d
movb -0x9b2(%rbp), %al
testb $0x1, %al
jne 0x437c
jmp 0x450b
movq -0x558(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0xaa00
movl %eax, -0x9b8(%rbp)
jmp 0x4394
movl -0x9b8(%rbp), %eax
movl %eax, -0x438(%rbp)
cmpl $0x0, %eax
je 0x442b
movq 0x12c20(%rip), %rdi     # 0x16fd0
leaq 0xccdf(%rip), %rsi      # 0x11096
callq 0x3220
movq %rax, -0x9c0(%rbp)
jmp 0x43c5
movq -0x9c0(%rbp), %rdi
movq 0x12be5(%rip), %rsi     # 0x16fb8
callq 0x3270
jmp 0x43da
movq 0x12c0f(%rip), %rdi     # 0x16ff0
leaq 0xcd69(%rip), %rsi      # 0x11151
callq 0x3220
movq %rax, -0x9c8(%rbp)
jmp 0x43f6
movq -0x9c8(%rbp), %rdi
movl -0x438(%rbp), %esi
callq 0x3460
movq %rax, -0x9d0(%rbp)
jmp 0x4411
movq -0x9d0(%rbp), %rdi
movq 0x12b99(%rip), %rsi     # 0x16fb8
callq 0x3270
jmp 0x4426
jmp 0x4509
leaq -0x550(%rbp), %rdi
callq 0x7e20
movl %eax, -0x9d4(%rbp)
jmp 0x443f
movl -0x9d4(%rbp), %eax
movl %eax, -0x438(%rbp)
cmpl $0x0, %eax
je 0x44cf
movq 0x12b79(%rip), %rdi     # 0x16fd0
leaq 0xcc38(%rip), %rsi      # 0x11096
callq 0x3220
movq %rax, -0x9e0(%rbp)
jmp 0x446c
movq -0x9e0(%rbp), %rdi
movq 0x12b3e(%rip), %rsi     # 0x16fb8
callq 0x3270
jmp 0x4481
movq 0x12b68(%rip), %rdi     # 0x16ff0
leaq 0xcce3(%rip), %rsi      # 0x11172
callq 0x3220
movq %rax, -0x9e8(%rbp)
jmp 0x449d
movq -0x9e8(%rbp), %rdi
movl -0x438(%rbp), %esi
callq 0x3460
movq %rax, -0x9f0(%rbp)
jmp 0x44b8
movq -0x9f0(%rbp), %rdi
movq 0x12af2(%rip), %rsi     # 0x16fb8
callq 0x3270
jmp 0x44cd
jmp 0x4507
movq -0x558(%rbp), %rax
movq %rax, -0x9f8(%rbp)
cmpq $0x0, %rax
je 0x44f0
movq -0x9f8(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x12ad9(%rip), %rdi     # 0x16fd0
leaq 0xcb8d(%rip), %rsi      # 0x1108b
callq 0x3220
jmp 0x4505
jmp 0x4507
jmp 0x4509
jmp 0x450b
jmp 0x450d
jmp 0x450f
jmp 0x4511
jmp 0x4513
jmp 0x4515
jmp 0x4517
leaq -0x750(%rbp), %rdi
callq 0x33a0
leaq -0x5e0(%rbp), %rdi
callq 0x3140
leaq -0x5c0(%rbp), %rdi
callq 0x3140
leaq -0x5a0(%rbp), %rdi
callq 0x3140
leaq -0x580(%rbp), %rdi
callq 0x3140
jmp 0x399b
leaq -0x750(%rbp), %rdi
callq 0x33a0
leaq -0x5e0(%rbp), %rdi
callq 0x3140
leaq -0x5c0(%rbp), %rdi
callq 0x3140
leaq -0x5a0(%rbp), %rdi
callq 0x3140
leaq -0x580(%rbp), %rdi
callq 0x3140
jmp 0x45cc
movq -0x28(%rbp), %rdi
callq 0x3230
jmp 0x45a1
movl $0x0, -0x4(%rbp)
movl $0x1, -0x55c(%rbp)
leaq -0x550(%rbp), %rdi
callq 0x7dc0
leaq -0x4b8(%rbp), %rdi
callq 0x5850
jmp 0x45e6
leaq -0x550(%rbp), %rdi
callq 0x7dc0
leaq -0x4b8(%rbp), %rdi
callq 0x5850
jmp 0x45f2
movl -0x4(%rbp), %eax
addq $0xa10, %rsp            # imm = 0xA10
popq %rbp
retq
movq -0x4e8(%rbp), %rdi
callq 0x3470
nop