// File: VanAndelInstitute[P]intent/main.cpp
// Function: main
int main(int argc, char *argv[]) {
  int c, distance = 2 ;
  bool expanded = false;
  bool v2 = false;
  std::set<std::string>::iterator it_bc1;
  std::set<std::string>::iterator it_bc2;
  int format = FORMAT_V3;

  while( ( c = getopt (argc, argv, "xthvd:") ) != -1 )
  {
      switch(c)
      {
          case 'h':
              usage();
              exit(0);
          case 'v':
              std::cout << "\n  intent version " << VERSION << "\n\n";
              exit(0);
          case 'x':
              expanded = true;
              format = FORMAT_EXTENDED;
              break;
          case 'd':
              if(optarg) {
                distance = std::atoi(optarg);
              } else {
                std::cout << "The -d flag requires a value.\n\n";
              }
              break;
          case 't':
              v2 = true;
              format = FORMAT_V3;
              break;
      }
  }

  if(expanded && v2) {
    std::cout << "The -x and -t flags are mutually exclusive. Please select only 1.\n\n";
  }

  if (argv[optind] == NULL || argv[optind + 1]  == NULL) {
    usage();
    exit(0);
  }

  std::string pathR1 = argv[optind];
  std::string pathR2 = argv[optind + 1];
  std::string pathR1_out, pathR2_out;
  auto start_time = std::chrono::steady_clock::now();

  // note R1 and R2 are swapped to mimic 10X libraries
  pathR1_out = reformatFileName(pathR2, "intent_R1.fastq.gz");
  pathR2_out = reformatFileName(pathR1, "intent_R2.fastq.gz");

  std::fstream r1_fs, r2_fs; //, r1_out_fs, r2_out_fs;

  r1_fs.open(pathR1, std::ios::in);
  r2_fs.open(pathR2, std::ios::in);
  //r1_out_fs.open(pathR1_out, std::ios::out);
  //r2_out_fs.open(pathR2_out, std::ios::out);

  zstr::istream r1(r1_fs),
                r2(r2_fs);

  zstr::ofstream r1_out(pathR1_out);
  zstr::ofstream r2_out(pathR2_out);
  
  int in = 0, ok = 0, bad_w1 = 0, other = 0, shortread = 0, bad_barcode = 0, corrected = 0;
  init_stats_table();

  while(r2.peek() != EOF ) {
    in++;
    if((in % 10000) == 0)
       update_stats(start_time, in, ok, bad_w1, shortread, corrected, bad_barcode);

    std::vector<std::string> lines_r1, lines_r2;
    std::vector<int> coords;
    lines_r1 = readFour(r1);
    lines_r2 = readFour(r2);
    ParsedBarcode bc = extract_v2_barcodes(lines_r2[1], lines_r2[3], 2, true);

    if(bc.status == BC_ERROR_SHORTREAD) {
      shortread++;
    } else if(bc.status == BC_ERROR_BAD_W1) {
      bad_w1++;
    } else if(bc.status == BC_ERROR_BAD_BARCODE) {
      bad_barcode++;
    } else if(bc.status == BC_ERROR) {
      other++;
      std::cout << "An undefined error occurred processing this read: \n" << 
      lines_r2[0] << std::endl << 
      lines_r2[1] << std::endl << 
      lines_r2[2] << std::endl << 
      lines_r2[3] << std::endl; 
    } else if(bc.status == BC_OK) {
      ok++;
      if(bc.bc_fixed) {
        corrected++;
      }
      FastqRead r = format_barcode(bc, lines_r2[0], lines_r2[2], format);

      writeFour(r1_out, {r.id,
                         r.read,
                         r.direction,
                         r.quality
                        });
      writeFour(r2_out, lines_r1);

    } else {
      std::cout << "An unknown error occurred processing this read: \n" << 
      lines_r2[0] << std::endl << 
      lines_r2[1] << std::endl << 
      lines_r2[2] << std::endl << 
      lines_r2[3] << std::endl; 
      other++;
    }
  }
  r1_fs.close();
  r2_fs.close();
  //r1_out_fs.close();
  //r2_out_fs.close();

  std::cout << "\n\nComplete. Job summary: " << std::endl <<
        "Reads: " << in <<std:: endl <<
        "OK: " << ok << std::endl <<
        "Poor W1 alignment: " << bad_w1 << std::endl <<
        "Barcode or UMI too short: " << shortread <<std::endl <<
        "Barcode succesfully corrected: " << corrected << std::endl <<
        "Barcode not recognized: " << bad_barcode << std::endl;
  if(other > 0) {
        std::cout << "Unknown errors (!!): " << other << std::endl;
  }
  std::cout << std::endl;
  return(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1410, %rsp           # imm = 0x1410
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x2, -0x18(%rbp)
movb $0x0, -0x19(%rbp)
movb $0x0, -0x1a(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x36480
leaq -0x30(%rbp), %rdi
callq 0x36480
movl $0x1, -0x34(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq 0x3a99d(%rip), %rdx     # 0x6f45c
callq 0x8110
movl %eax, -0x14(%rbp)
cmpl $-0x1, %eax
je 0x34b96
movl -0x14(%rbp), %eax
addl $-0x64, %eax
movl %eax, %ecx
movq %rcx, -0x1238(%rbp)
subl $0x14, %eax
ja 0x34b91
movq -0x1238(%rbp), %rax
leaq 0x3950e(%rip), %rcx     # 0x6e004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
callq 0x34570
xorl %edi, %edi
callq 0x86b0
movq 0x594a6(%rip), %rdi     # 0x8dfb8
leaq 0x3a94a(%rip), %rsi     # 0x6f463
callq 0x8540
movq %rax, %rdi
leaq 0x59ee0(%rip), %rsi     # 0x8ea08
callq 0x84f0
movq %rax, %rdi
leaq 0x3a9a0(%rip), %rsi     # 0x6f4d7
callq 0x8540
xorl %edi, %edi
callq 0x86b0
movb $0x1, -0x19(%rbp)
movl $0x2, -0x34(%rbp)
jmp 0x34b91
movq 0x59429(%rip), %rax     # 0x8df80
cmpq $0x0, (%rax)
je 0x34b71
movq 0x5941c(%rip), %rax     # 0x8df80
movq (%rax), %rdi
callq 0x8870
movl %eax, -0x18(%rbp)
jmp 0x34b84
movq 0x59440(%rip), %rdi     # 0x8dfb8
leaq 0x3a8f7(%rip), %rsi     # 0x6f476
callq 0x8540
jmp 0x34b91
movb $0x1, -0x1a(%rbp)
movl $0x1, -0x34(%rbp)
jmp 0x34ab1
testb $0x1, -0x19(%rbp)
je 0x34bb5
testb $0x1, -0x1a(%rbp)
je 0x34bb5
movq 0x5940f(%rip), %rdi     # 0x8dfb8
leaq 0x3a8e6(%rip), %rsi     # 0x6f496
callq 0x8540
movq -0x10(%rbp), %rax
movq 0x59400(%rip), %rcx     # 0x8dfc0
movslq (%rcx), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x34be4
movq -0x10(%rbp), %rax
movq 0x593eb(%rip), %rcx     # 0x8dfc0
movl (%rcx), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
cmpq $0x0, (%rax,%rcx,8)
jne 0x34bf0
callq 0x34570
xorl %edi, %edi
callq 0x86b0
movq -0x10(%rbp), %rax
movq 0x593c5(%rip), %rcx     # 0x8dfc0
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x1248(%rbp)
leaq -0x59(%rbp), %rdi
movq %rdi, -0x1240(%rbp)
callq 0x8980
movq -0x1248(%rbp), %rsi
movq -0x1240(%rbp), %rdx
leaq -0x58(%rbp), %rdi
callq 0x35e90
jmp 0x34c32
leaq -0x59(%rbp), %rdi
callq 0x85e0
movq -0x10(%rbp), %rax
movq 0x5937a(%rip), %rcx     # 0x8dfc0
movslq (%rcx), %rcx
movq 0x8(%rax,%rcx,8), %rax
movq %rax, -0x1258(%rbp)
leaq -0x91(%rbp), %rdi
movq %rdi, -0x1250(%rbp)
callq 0x8980
movq -0x1258(%rbp), %rsi
movq -0x1250(%rbp), %rdx
leaq -0x90(%rbp), %rdi
callq 0x35e90
jmp 0x34c84
leaq -0x91(%rbp), %rdi
callq 0x85e0
leaq -0xb8(%rbp), %rdi
callq 0x87c0
leaq -0xd8(%rbp), %rdi
callq 0x87c0
callq 0x8760
movq %rax, -0xe0(%rbp)
leaq -0x120(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x8280
jmp 0x34cc9
leaq -0x141(%rbp), %rdi
movq %rdi, -0x1260(%rbp)
callq 0x8980
movq -0x1260(%rbp), %rdx
leaq 0x3a7f0(%rip), %rsi     # 0x6f4da
leaq -0x140(%rbp), %rdi
callq 0x35e90
jmp 0x34cf8
leaq -0x100(%rbp), %rdi
leaq -0x120(%rbp), %rsi
leaq -0x140(%rbp), %rdx
callq 0x348f0
jmp 0x34d14
leaq -0xb8(%rbp), %rdi
leaq -0x100(%rbp), %rsi
movq %rsi, -0x1268(%rbp)
callq 0x86c0
movq -0x1268(%rbp), %rdi
callq 0x8a98
leaq -0x140(%rbp), %rdi
callq 0x8a98
leaq -0x141(%rbp), %rdi
callq 0x85e0
leaq -0x120(%rbp), %rdi
callq 0x8a98
leaq -0x188(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x8280
jmp 0x34d70
leaq -0x1a9(%rbp), %rdi
movq %rdi, -0x1270(%rbp)
callq 0x8980
movq -0x1270(%rbp), %rdx
leaq 0x3a75c(%rip), %rsi     # 0x6f4ed
leaq -0x1a8(%rbp), %rdi
callq 0x35e90
jmp 0x34d9f
leaq -0x168(%rbp), %rdi
leaq -0x188(%rbp), %rsi
leaq -0x1a8(%rbp), %rdx
callq 0x348f0
jmp 0x34dbb
leaq -0xd8(%rbp), %rdi
leaq -0x168(%rbp), %rsi
movq %rsi, -0x1278(%rbp)
callq 0x86c0
movq -0x1278(%rbp), %rdi
callq 0x8a98
leaq -0x1a8(%rbp), %rdi
callq 0x8a98
leaq -0x1a9(%rbp), %rdi
callq 0x85e0
leaq -0x188(%rbp), %rdi
callq 0x8a98
leaq -0x3c0(%rbp), %rdi
callq 0x8690
jmp 0x34e13
leaq -0x5d0(%rbp), %rdi
callq 0x8690
jmp 0x34e21
leaq -0x3c0(%rbp), %rdi
leaq -0x58(%rbp), %rsi
movl $0x8, %edx
callq 0x87a0
jmp 0x34e38
leaq -0x5d0(%rbp), %rdi
leaq -0x90(%rbp), %rsi
movl $0x8, %edx
callq 0x87a0
jmp 0x34e52
leaq -0x6e8(%rbp), %rdi
leaq -0x3c0(%rbp), %rsi
callq 0x364a0
jmp 0x34e67
leaq -0x800(%rbp), %rdi
leaq -0x5d0(%rbp), %rsi
callq 0x364a0
jmp 0x34e7c
leaq -0xb10(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
movl $0x10, %edx
callq 0x365b0
jmp 0x34e96
leaq -0xe20(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
movl $0x10, %edx
callq 0x365b0
jmp 0x34eb0
movl $0x0, -0xe24(%rbp)
movl $0x0, -0xe28(%rbp)
movl $0x0, -0xe2c(%rbp)
movl $0x0, -0xe30(%rbp)
movl $0x0, -0xe34(%rbp)
movl $0x0, -0xe38(%rbp)
movl $0x0, -0xe3c(%rbp)
callq 0x349a0
jmp 0x34efd
jmp 0x34eff
leaq -0x800(%rbp), %rdi
callq 0x8220
movl %eax, -0x127c(%rbp)
jmp 0x34f13
movl -0x127c(%rbp), %eax
cmpl $-0x1, %eax
je 0x35949
movl -0xe24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe24(%rbp)
movl -0xe24(%rbp), %eax
movl $0x2710, %ecx           # imm = 0x2710
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x350ca
movq -0xe0(%rbp), %rax
movq %rax, -0xe48(%rbp)
movl -0xe24(%rbp), %esi
movl -0xe28(%rbp), %edx
movl -0xe2c(%rbp), %ecx
movl -0xe34(%rbp), %r8d
movl -0xe3c(%rbp), %r9d
movl -0xe38(%rbp), %r10d
movq -0xe48(%rbp), %rdi
movq %rsp, %rax
movl %r10d, (%rax)
callq 0x349d0
jmp 0x34f91
jmp 0x350ca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x59(%rbp), %rdi
callq 0x85e0
jmp 0x35cf1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x91(%rbp), %rdi
callq 0x85e0
jmp 0x35ce8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x35cc4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x35004
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x8a98
leaq -0x141(%rbp), %rdi
callq 0x85e0
leaq -0x120(%rbp), %rdi
callq 0x8a98
jmp 0x35cc4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x35047
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x1a8(%rbp), %rdi
callq 0x8a98
leaq -0x1a9(%rbp), %rdi
callq 0x85e0
leaq -0x188(%rbp), %rdi
callq 0x8a98
jmp 0x35cc4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x35cb8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x35cac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x35ca0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x35c94
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x35c88
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x35c7c
leaq -0xe60(%rbp), %rdi
callq 0x36070
leaq -0xe78(%rbp), %rdi
callq 0x36070
leaq -0xe90(%rbp), %rdi
callq 0x36740
leaq -0xea8(%rbp), %rdi
leaq -0x6e8(%rbp), %rsi
callq 0x346b0
jmp 0x35103
leaq -0xe60(%rbp), %rdi
leaq -0xea8(%rbp), %rsi
movq %rsi, -0x1288(%rbp)
callq 0x36760
movq -0x1288(%rbp), %rdi
callq 0x36130
leaq -0xec0(%rbp), %rdi
leaq -0x800(%rbp), %rsi
callq 0x346b0
jmp 0x3513e
leaq -0xe78(%rbp), %rdi
movq %rdi, -0x1290(%rbp)
leaq -0xec0(%rbp), %rsi
movq %rsi, -0x1298(%rbp)
callq 0x36760
movq -0x1298(%rbp), %rdi
callq 0x36130
movq -0x1290(%rbp), %rdi
movl $0x1, %esi
callq 0x36210
movq %rax, %rsi
leaq -0xfb0(%rbp), %rdi
callq 0x8280
jmp 0x3518d
leaq -0xe78(%rbp), %rdi
movl $0x3, %esi
callq 0x36210
movq %rax, %rsi
leaq -0xfd0(%rbp), %rdi
callq 0x8280
jmp 0x351af
leaq -0xf90(%rbp), %rdi
leaq -0xfb0(%rbp), %rsi
leaq -0xfd0(%rbp), %rdx
movl $0x2, %ecx
movl $0x1, %r8d
callq 0x6aa80
jmp 0x351d6
leaq -0xfd0(%rbp), %rdi
callq 0x8a98
leaq -0xfb0(%rbp), %rdi
callq 0x8a98
cmpl $0x3, -0xf90(%rbp)
jne 0x35253
movl -0xe34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe34(%rbp)
jmp 0x358df
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x35920
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x35242
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xfd0(%rbp), %rdi
callq 0x8a98
leaq -0xfb0(%rbp), %rdi
callq 0x8a98
jmp 0x35920
cmpl $0x2, -0xf90(%rbp)
jne 0x35270
movl -0xe2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe2c(%rbp)
jmp 0x358dd
cmpl $0x4, -0xf90(%rbp)
jne 0x3528d
movl -0xe38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe38(%rbp)
jmp 0x358db
cmpl $0x1, -0xf90(%rbp)
jne 0x353e6
movl -0xe30(%rbp), %eax
incl %eax
movl %eax, -0xe30(%rbp)
movq 0x58d09(%rip), %rdi     # 0x8dfb8
leaq 0x3a24a(%rip), %rsi     # 0x6f500
callq 0x8540
movq %rax, -0x12a0(%rbp)
jmp 0x352c4
xorl %eax, %eax
movl %eax, %esi
leaq -0xe78(%rbp), %rdi
callq 0x36210
movq -0x12a0(%rbp), %rdi
movq %rax, %rsi
callq 0x84f0
movq %rax, -0x12a8(%rbp)
jmp 0x352ec
movq -0x12a8(%rbp), %rdi
movq 0x58c7e(%rip), %rsi     # 0x8df78
callq 0x85b0
movq %rax, -0x12b0(%rbp)
jmp 0x35308
leaq -0xe78(%rbp), %rdi
movl $0x1, %esi
callq 0x36210
movq -0x12b0(%rbp), %rdi
movq %rax, %rsi
callq 0x84f0
movq %rax, -0x12b8(%rbp)
jmp 0x35331
movq -0x12b8(%rbp), %rdi
movq 0x58c39(%rip), %rsi     # 0x8df78
callq 0x85b0
movq %rax, -0x12c0(%rbp)
jmp 0x3534d
leaq -0xe78(%rbp), %rdi
movl $0x2, %esi
callq 0x36210
movq -0x12c0(%rbp), %rdi
movq %rax, %rsi
callq 0x84f0
movq %rax, -0x12c8(%rbp)
jmp 0x35376
movq -0x12c8(%rbp), %rdi
movq 0x58bf4(%rip), %rsi     # 0x8df78
callq 0x85b0
movq %rax, -0x12d0(%rbp)
jmp 0x35392
leaq -0xe78(%rbp), %rdi
movl $0x3, %esi
callq 0x36210
movq -0x12d0(%rbp), %rdi
movq %rax, %rsi
callq 0x84f0
movq %rax, -0x12d8(%rbp)
jmp 0x353bb
movq -0x12d8(%rbp), %rdi
movq 0x58baf(%rip), %rsi     # 0x8df78
callq 0x85b0
jmp 0x353d0
jmp 0x358d9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x35914
cmpl $0x0, -0xf90(%rbp)
jne 0x357a0
movl -0xe28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe28(%rbp)
testb $0x1, -0xec8(%rbp)
je 0x3541a
movl -0xe3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe3c(%rbp)
leaq -0x1120(%rbp), %rdi
leaq -0xf90(%rbp), %rsi
callq 0x36790
jmp 0x3542f
xorl %eax, %eax
movl %eax, %esi
leaq -0xe78(%rbp), %rdi
callq 0x36210
movq %rax, %rsi
leaq -0x1140(%rbp), %rdi
callq 0x8280
jmp 0x35450
leaq -0xe78(%rbp), %rdi
movl $0x2, %esi
callq 0x36210
movq %rax, %rsi
leaq -0x1160(%rbp), %rdi
callq 0x8280
jmp 0x35472
movl -0x34(%rbp), %r8d
leaq -0x1050(%rbp), %rdi
leaq -0x1120(%rbp), %rsi
leaq -0x1140(%rbp), %rdx
leaq -0x1160(%rbp), %rcx
callq 0x6b7f0
jmp 0x35499
leaq -0x1160(%rbp), %rdi
callq 0x8a98
leaq -0x1140(%rbp), %rdi
callq 0x8a98
leaq -0x1120(%rbp), %rdi
callq 0x368f0
leaq -0x1208(%rbp), %rdi
movq %rdi, -0x1210(%rbp)
leaq -0x1050(%rbp), %rsi
callq 0x8280
jmp 0x354d9
leaq -0x11e8(%rbp), %rdi
movq %rdi, -0x1210(%rbp)
leaq -0x1030(%rbp), %rsi
callq 0x8280
jmp 0x354f5
leaq -0x11c8(%rbp), %rdi
movq %rdi, -0x1210(%rbp)
leaq -0x1010(%rbp), %rsi
callq 0x8280
jmp 0x35511
leaq -0x11a8(%rbp), %rdi
movq %rdi, -0x1210(%rbp)
leaq -0xff0(%rbp), %rsi
callq 0x8280
jmp 0x3552d
leaq -0x1208(%rbp), %rax
movq %rax, -0x1188(%rbp)
movq $0x4, -0x1180(%rbp)
leaq -0x1211(%rbp), %rdi
movq %rdi, -0x12e0(%rbp)
callq 0x35f40
movq -0x12e0(%rbp), %rcx
movq -0x1188(%rbp), %rsi
movq -0x1180(%rbp), %rdx
leaq -0x1178(%rbp), %rdi
callq 0x36960
jmp 0x3557c
leaq -0xb10(%rbp), %rdi
leaq -0x1178(%rbp), %rsi
callq 0x34830
jmp 0x35591
leaq -0x1178(%rbp), %rdi
callq 0x36130
leaq -0x1211(%rbp), %rdi
callq 0x36030
leaq -0x1208(%rbp), %rax
movq %rax, -0x12f0(%rbp)
addq $0x80, %rax
movq %rax, -0x12e8(%rbp)
movq -0x12e8(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x12f8(%rbp)
callq 0x8a98
movq -0x12f0(%rbp), %rcx
movq -0x12f8(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x12e8(%rbp)
jne 0x355c4
leaq -0x1230(%rbp), %rdi
leaq -0xe60(%rbp), %rsi
callq 0x369e0
jmp 0x3560a
leaq -0xe20(%rbp), %rdi
leaq -0x1230(%rbp), %rsi
callq 0x34830
jmp 0x3561f
leaq -0x1230(%rbp), %rdi
callq 0x36130
leaq -0x1050(%rbp), %rdi
callq 0x36ad0
jmp 0x358d7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x3567c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x35670
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x1160(%rbp), %rdi
callq 0x8a98
leaq -0x1140(%rbp), %rdi
callq 0x8a98
leaq -0x1120(%rbp), %rdi
callq 0x368f0
jmp 0x35914
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
movq -0x1210(%rbp), %rax
leaq -0x1208(%rbp), %rcx
cmpq %rax, %rcx
movq %rax, -0x1300(%rbp)
je 0x356e4
movq -0x1300(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x1308(%rbp)
callq 0x8a98
movq -0x1308(%rbp), %rax
leaq -0x1208(%rbp), %rcx
cmpq %rcx, %rax
movq %rax, -0x1300(%rbp)
jne 0x356b3
jmp 0x3578f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x3570f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x1178(%rbp), %rdi
callq 0x36130
leaq -0x1211(%rbp), %rdi
callq 0x36030
leaq -0x1208(%rbp), %rax
movq %rax, -0x1318(%rbp)
addq $0x80, %rax
movq %rax, -0x1310(%rbp)
movq -0x1310(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x1320(%rbp)
callq 0x8a98
movq -0x1318(%rbp), %rcx
movq -0x1320(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x1310(%rbp)
jne 0x35736
jmp 0x3578f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x3578f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x1230(%rbp), %rdi
callq 0x36130
leaq -0x1050(%rbp), %rdi
callq 0x36ad0
jmp 0x35914
movq 0x58811(%rip), %rdi     # 0x8dfb8
leaq 0x39d86(%rip), %rsi     # 0x6f534
callq 0x8540
movq %rax, -0x1328(%rbp)
jmp 0x357bc
xorl %eax, %eax
movl %eax, %esi
leaq -0xe78(%rbp), %rdi
callq 0x36210
movq -0x1328(%rbp), %rdi
movq %rax, %rsi
callq 0x84f0
movq %rax, -0x1330(%rbp)
jmp 0x357e4
movq -0x1330(%rbp), %rdi
movq 0x58786(%rip), %rsi     # 0x8df78
callq 0x85b0
movq %rax, -0x1338(%rbp)
jmp 0x35800
leaq -0xe78(%rbp), %rdi
movl $0x1, %esi
callq 0x36210
movq -0x1338(%rbp), %rdi
movq %rax, %rsi
callq 0x84f0
movq %rax, -0x1340(%rbp)
jmp 0x35829
movq -0x1340(%rbp), %rdi
movq 0x58741(%rip), %rsi     # 0x8df78
callq 0x85b0
movq %rax, -0x1348(%rbp)
jmp 0x35845
leaq -0xe78(%rbp), %rdi
movl $0x2, %esi
callq 0x36210
movq -0x1348(%rbp), %rdi
movq %rax, %rsi
callq 0x84f0
movq %rax, -0x1350(%rbp)
jmp 0x3586e
movq -0x1350(%rbp), %rdi
movq 0x586fc(%rip), %rsi     # 0x8df78
callq 0x85b0
movq %rax, -0x1358(%rbp)
jmp 0x3588a
leaq -0xe78(%rbp), %rdi
movl $0x3, %esi
callq 0x36210
movq -0x1358(%rbp), %rdi
movq %rax, %rsi
callq 0x84f0
movq %rax, -0x1360(%rbp)
jmp 0x358b3
movq -0x1360(%rbp), %rdi
movq 0x586b7(%rip), %rsi     # 0x8df78
callq 0x85b0
jmp 0x358c8
movl -0xe30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe30(%rbp)
jmp 0x358d9
jmp 0x358db
jmp 0x358dd
jmp 0x358df
leaq -0xf90(%rbp), %rdi
callq 0x368f0
leaq -0xe90(%rbp), %rdi
callq 0x36b20
leaq -0xe78(%rbp), %rdi
callq 0x36130
leaq -0xe60(%rbp), %rdi
callq 0x36130
jmp 0x34eff
leaq -0xf90(%rbp), %rdi
callq 0x368f0
leaq -0xe90(%rbp), %rdi
callq 0x36b20
leaq -0xe78(%rbp), %rdi
callq 0x36130
leaq -0xe60(%rbp), %rdi
callq 0x36130
jmp 0x35c7c
leaq -0x3c0(%rbp), %rdi
callq 0x80a0
jmp 0x35957
leaq -0x5d0(%rbp), %rdi
callq 0x80a0
jmp 0x35965
movq 0x5864c(%rip), %rdi     # 0x8dfb8
leaq 0x39bf3(%rip), %rsi     # 0x6f566
callq 0x8540
movq %rax, -0x1368(%rbp)
jmp 0x35981
movq -0x1368(%rbp), %rdi
movq 0x585e9(%rip), %rsi     # 0x8df78
callq 0x85b0
movq %rax, -0x1370(%rbp)
jmp 0x3599d
movq -0x1370(%rbp), %rdi
leaq 0x39bd5(%rip), %rsi     # 0x6f580
callq 0x8540
movq %rax, -0x1378(%rbp)
jmp 0x359b9
movq -0x1378(%rbp), %rdi
movl -0xe24(%rbp), %esi
callq 0x8940
movq %rax, -0x1380(%rbp)
jmp 0x359d4
movq -0x1380(%rbp), %rdi
movq 0x58596(%rip), %rsi     # 0x8df78
callq 0x85b0
movq %rax, -0x1388(%rbp)
jmp 0x359f0
movq -0x1388(%rbp), %rdi
leaq 0x39b8a(%rip), %rsi     # 0x6f588
callq 0x8540
movq %rax, -0x1390(%rbp)
jmp 0x35a0c
movq -0x1390(%rbp), %rdi
movl -0xe28(%rbp), %esi
callq 0x8940
movq %rax, -0x1398(%rbp)
jmp 0x35a27
movq -0x1398(%rbp), %rdi
movq 0x58543(%rip), %rsi     # 0x8df78
callq 0x85b0
movq %rax, -0x13a0(%rbp)
jmp 0x35a43
movq -0x13a0(%rbp), %rdi
leaq 0x39b3c(%rip), %rsi     # 0x6f58d
callq 0x8540
movq %rax, -0x13a8(%rbp)
jmp 0x35a5f
movq -0x13a8(%rbp), %rdi
movl -0xe2c(%rbp), %esi
callq 0x8940
movq %rax, -0x13b0(%rbp)
jmp 0x35a7a
movq -0x13b0(%rbp), %rdi
movq 0x584f0(%rip), %rsi     # 0x8df78
callq 0x85b0
movq %rax, -0x13b8(%rbp)
jmp 0x35a96
movq -0x13b8(%rbp), %rdi
leaq 0x39afd(%rip), %rsi     # 0x6f5a1
callq 0x8540
movq %rax, -0x13c0(%rbp)
jmp 0x35ab2
movq -0x13c0(%rbp), %rdi
movl -0xe34(%rbp), %esi
callq 0x8940
movq %rax, -0x13c8(%rbp)
jmp 0x35acd
movq -0x13c8(%rbp), %rdi
movq 0x5849d(%rip), %rsi     # 0x8df78
callq 0x85b0
movq %rax, -0x13d0(%rbp)
jmp 0x35ae9
movq -0x13d0(%rbp), %rdi
leaq 0x39ac5(%rip), %rsi     # 0x6f5bc
callq 0x8540
movq %rax, -0x13d8(%rbp)
jmp 0x35b05
movq -0x13d8(%rbp), %rdi
movl -0xe3c(%rbp), %esi
callq 0x8940
movq %rax, -0x13e0(%rbp)
jmp 0x35b20
movq -0x13e0(%rbp), %rdi
movq 0x5844a(%rip), %rsi     # 0x8df78
callq 0x85b0
movq %rax, -0x13e8(%rbp)
jmp 0x35b3c
movq -0x13e8(%rbp), %rdi
leaq 0x39a92(%rip), %rsi     # 0x6f5dc
callq 0x8540
movq %rax, -0x13f0(%rbp)
jmp 0x35b58
movq -0x13f0(%rbp), %rdi
movl -0xe38(%rbp), %esi
callq 0x8940
movq %rax, -0x13f8(%rbp)
jmp 0x35b73
movq -0x13f8(%rbp), %rdi
movq 0x583f7(%rip), %rsi     # 0x8df78
callq 0x85b0
jmp 0x35b88
cmpl $0x0, -0xe30(%rbp)
jle 0x35bdf
movq 0x58420(%rip), %rdi     # 0x8dfb8
leaq 0x39a56(%rip), %rsi     # 0x6f5f5
callq 0x8540
movq %rax, -0x1400(%rbp)
jmp 0x35bad
movq -0x1400(%rbp), %rdi
movl -0xe30(%rbp), %esi
callq 0x8940
movq %rax, -0x1408(%rbp)
jmp 0x35bc8
movq -0x1408(%rbp), %rdi
movq 0x583a2(%rip), %rsi     # 0x8df78
callq 0x85b0
jmp 0x35bdd
jmp 0x35bdf
movq 0x583d2(%rip), %rdi     # 0x8dfb8
movq 0x5838b(%rip), %rsi     # 0x8df78
callq 0x85b0
jmp 0x35bf4
movl $0x0, -0x4(%rbp)
leaq -0xe20(%rbp), %rdi
callq 0x36b80
leaq -0xb10(%rbp), %rdi
callq 0x36b80
leaq -0x800(%rbp), %rdi
callq 0x36bc0
leaq -0x6e8(%rbp), %rdi
callq 0x36bc0
leaq -0x5d0(%rbp), %rdi
callq 0x80f0
leaq -0x3c0(%rbp), %rdi
callq 0x80f0
leaq -0xd8(%rbp), %rdi
callq 0x8a98
leaq -0xb8(%rbp), %rdi
callq 0x8a98
leaq -0x90(%rbp), %rdi
callq 0x8a98
leaq -0x58(%rbp), %rdi
callq 0x8a98
movl -0x4(%rbp), %eax
addq $0x1410, %rsp           # imm = 0x1410
popq %rbp
retq
leaq -0xe20(%rbp), %rdi
callq 0x36b80
leaq -0xb10(%rbp), %rdi
callq 0x36b80
leaq -0x800(%rbp), %rdi
callq 0x36bc0
leaq -0x6e8(%rbp), %rdi
callq 0x36bc0
leaq -0x5d0(%rbp), %rdi
callq 0x80f0
leaq -0x3c0(%rbp), %rdi
callq 0x80f0
leaq -0xd8(%rbp), %rdi
callq 0x8a98
leaq -0xb8(%rbp), %rdi
callq 0x8a98
leaq -0x90(%rbp), %rdi
callq 0x8a98
leaq -0x58(%rbp), %rdi
callq 0x8a98
movq -0x68(%rbp), %rdi
callq 0x8970
nopw (%rax,%rax)