// File: /workspace/github_cpp_makefile_star2_O3/akdess[P]BAFExtract/src/main.cpp
// Function: dump_nucleotide_pileup_per_SAM_file(char*, std::vector<char*, std::allocator<char*>>*, std::vector<int, std::allocator<int>>*, char*, int, int, int&)
void dump_nucleotide_pileup_per_SAM_file(char* sam_fp, vector<char*>* chr_ids, vector<int>* chr_lengths, char* op_dir, int min_mapp_qual, int min_phred_qual, int& n_processed_reads)
{
  fprintf(stderr, "Generating pileup from SAM file with min mapp qual %d, min base qual %d\n", min_mapp_qual, min_phred_qual);

  //// Init the file.
  //char summary_fp[1000];
  //sprintf(summary_fp, "%s/%s", op_dir, t_config_params::OP_filenames[OP_PILEUP_SUMMARY_FN]);
  //FILE* f_summary = open_f(summary_fp, "w");
  //fclose(f_summary);

  // Initialize the number of processed readss.
  n_processed_reads = 0;

  //// Make sure we do not overwrite on an existing set of pileup file, since they are time consuming to generate.
  //bool allele_counts_are_there = true;
  //for(int i_chr = 0; i_chr < (int)chr_ids->size(); i_chr++)
  //{
  //  char cur_allele_fp[1000];
  //  sprintf(cur_allele_fp, "%s/%s_allele_counts.bin", op_dir, chr_ids->at(i_chr));
  //  if(!check_file(cur_allele_fp))
  //  {
  //    // This file does not exist, not all the allele counts are there.
  //    allele_counts_are_there = false;
  //    break;
  //  }
  //} // i_chr loop.

  //if(allele_counts_are_there)
  //{
  //  fprintf(stderr, "All the chromosome pileups exist, will not process data.\n");
  //  return;
  //}

  fprintf(stderr, "Dumping the pileups per SAM file %s\n", sam_fp);

  fprintf(stderr, "Allocating pileup memory.\n");
  unsigned short*** per_chrom_nuc_count_per_allele = new unsigned short**[(int)chr_ids->size()];
  //int** per_chrom_coverage = new int*[(int)chr_ids->size()];
  for(int i_chr = 0; i_chr < (int)chr_ids->size(); i_chr++)
  {
    int l_sig = chr_lengths->at(i_chr);

    // Check the existing pileup file, if it is there, add to it.
    char cur_allele_fp[1000];
    sprintf(cur_allele_fp, "%s/%s_allele_counts.bin", op_dir, chr_ids->at(i_chr));
    if(check_file(cur_allele_fp))
    {
      int l_loaded_pileup = 0;
      per_chrom_nuc_count_per_allele[i_chr] = load_compressed_pileups(cur_allele_fp, l_loaded_pileup);
      if(l_loaded_pileup != chr_lengths->at(i_chr))
      {
        fprintf(stderr, "Loaded pileup is not the same length as the chromosome info: %s: %d, %d\n", chr_ids->at(i_chr), chr_lengths->at(i_chr));
        exit(0);
      }
      else
      {
        fprintf(stderr, "Loaded existing pileup from %s.\n", cur_allele_fp);
      }
    }
    else
    {
      per_chrom_nuc_count_per_allele[i_chr] = allocate_pileup(l_sig);
    }
  } // i_chr loop.
  fprintf(stderr, "Done.\n");

  int max_n_alleles_per_posn = 1<<16;
  fprintf(stderr, "Maximum # of alleles at each position: %d\n", max_n_alleles_per_posn);

  // Start reading the file.
  FILE* f_sam = NULL;
  if(strcmp(sam_fp, "stdin") == 0)
  {
    f_sam = stdin;
  }
  else
  {
    f_sam = fopen(sam_fp, "r");
  }

  int* per_nuc_val = get_per_char_as_nuc_2_num_coding_array();
  //for(int i = 0; i < 256; i++)
  //{
  //  per_nuc_val[i] = 4;
  //} // i loop.
  //per_nuc_val[(int)'A'] = 0;
  //per_nuc_val[(int)'C'] = 1;
  //per_nuc_val[(int)'G'] = 2;
  //per_nuc_val[(int)'T'] = 3;
  //per_nuc_val[(int)'U'] = 3;
  //per_nuc_val[(int)'a'] = 0;
  //per_nuc_val[(int)'c'] = 1;
  //per_nuc_val[(int)'g'] = 2;
  //per_nuc_val[(int)'t'] = 3;
  //per_nuc_val[(int)'u'] = 3;

  // Enter file reading loop.
  char read_id[1000];
  //int flag;
  char chrom[100];
  int chr_index;
  char mapping_map_str[10000];
  char cur_fragment[1000];
  char flag_str[100];
  char _chr_index_str[100];
  char phred_quality_str[100000];
  char mapp_quality_str[100];

  int n_unmapped_reads = 0;
  int n_low_quality_reads = 0;

  int phred_score_base = -123;

  while(1)
  {
    char* cur_line = getline(f_sam);

    if(cur_line == NULL)
    {
      break;
    }

    // If this is a comment line, skip it.
    if(cur_line[0] == '@')
    {
      delete [] cur_line;
      continue;
    }

    if(sscanf(cur_line, "%[^\t] %[^\t] %[^\t] %[^\t] %[^\t] %[^\t] %*[^\t] %*[^\t] %*[^\t] %[^\t] %[^\t]", read_id, flag_str, chrom, _chr_index_str, mapp_quality_str ,mapping_map_str, cur_fragment, phred_quality_str) == 8)
    {
      if(phred_score_base == -123)
      {
        int l_read = strlen(phred_quality_str);
        for(int i = 0; i < l_read; i++)
        {
          if(phred_quality_str[i] > 'J')
          {
            fprintf(stderr, "Phred+64 encoding @ %d. read (%c):\n%s\n%s\n", n_processed_reads, phred_quality_str[i],
              cur_fragment, phred_quality_str);
            phred_score_base = ';';
            break;
          }
          else if(phred_quality_str[i] < ';')
          {
            fprintf(stderr, "Phred+33 encoding @ %d. read (%c):\n%s\n%s\n", n_processed_reads, phred_quality_str[i],
              cur_fragment, phred_quality_str);
            phred_score_base = '!';
            break;
          }
        } // i loop.
      }

      //fprintf(stderr, "Processing read @ %d parsed with %s:\n%s\n", chr_index, mapping_map_str, cur_fragment);
      // If the quality is not adequate, do not use this read.
      if(atoi(mapp_quality_str) < min_mapp_qual)
      {
        n_low_quality_reads++;
        delete [] cur_line;
        continue;
      }

      // Make sure the normalized chromosome ids match.
      normalize_chr_id(chrom);

      int flag = atoi(flag_str);

      int i_chr = t_string::get_i_str(chr_ids, chrom);

      // If we do not have the chromosome, do not process.
      if(i_chr == (int)chr_ids->size())
      {
        n_unmapped_reads++;
        delete [] cur_line;
        continue;
      }

      int _chr_index = atoi(_chr_index_str);

      // Translate the 0 based index in SAM file to codebase's indexing, which is 1 based inclusive.
      chr_index = translate_coord(_chr_index, SAM_COORDS::start_base, CODEBASE_COORDS::start_base);

      // Sanity check. Is this fragment mapped?
      if(flag & 0x04)
      {
        // The read is not mapping.
      }
      else
      {
        n_processed_reads++;
          
        if(n_processed_reads % 1000000 == 0)
        {
          fprintf(stderr, "Processing %d. read             \r", n_processed_reads);
        }

if(__DUMP_MAPPED_READ_TOOLS_MSGS__)
{
        fprintf(stderr, "Processing:\n%s\n%s\n", cur_fragment, phred_quality_str);
}

        int i_mapp_map = 0;
        //t_string* cur_entry_length_str = new t_string();
        bool is_matching = false;
        char entry_type_char;

        // Parse the cigar string to get the fragments.
        bool is_read_spliced = false;
        bool mapping_map_str_valid = validate_mapping_map_str(mapping_map_str, is_read_spliced);

        int read_nuc_index = 0;

        // Check if the mapping map string has splicing information, if it does and there extension length is not 0, 
        while(mapping_map_str_valid && 
          mapping_map_str[i_mapp_map] != 0)
        {
          int l_cur_entry;
          get_next_entry_per_mapp_map_string(mapping_map_str,
                            i_mapp_map, 
                            is_matching,
                            l_cur_entry,
                            entry_type_char);

          // If this block is matching, update the pileup.
          if(is_matching)
          {
            // Update the counts for the nucleotides.
            int cur_read_nuc_i = read_nuc_index;
            for(int cur_genome_i = chr_index; cur_genome_i <= chr_index+l_cur_entry-1; cur_genome_i++)
            {
              int cur_nuc_num = per_nuc_val[(int)cur_fragment[cur_read_nuc_i]];

              //if(numerized_sequence_signal[cur_genome_i] > 0 &&
              //  nuc_2_num(cur_fragment[cur_read_nuc_i]) != (numerized_sequence_signal[cur_genome_i]))
              //{
              //  fprintf(stderr, "Found %c->%c @ %d\n", num_2_nuc(numerized_sequence_signal[cur_genome_i]), cur_fragment[cur_read_nuc_i], cur_genome_i);
              //}

              if(cur_nuc_num < 4)
              {
                // Update the count: The allelic counts must be checked for bounds.
                if(per_chrom_nuc_count_per_allele[i_chr][cur_nuc_num][cur_genome_i] < max_n_alleles_per_posn-5)
                {
                  if(phred_quality_str[cur_read_nuc_i] - phred_score_base > min_phred_qual)
                  {
if(__DUMP_MAPPED_READ_TOOLS_MSGS__)
{
                    fprintf(stderr, "Adding %d: %c, %c (%d)\n", 
                        cur_read_nuc_i, 
                        cur_fragment[cur_read_nuc_i], phred_quality_str[cur_read_nuc_i], 
                        (int)(phred_quality_str[cur_read_nuc_i]-phred_score_base));
}

                    // Phred quality holds, update the pileup position.
                    per_chrom_nuc_count_per_allele[i_chr][cur_nuc_num][cur_genome_i]++;
                  } // phred qual pass check.
                  else
                  {
if(__DUMP_MAPPED_READ_TOOLS_MSGS__)
{
                    fprintf(stderr, "Skipping %d: %c, %c (%d)\n", 
                      cur_read_nuc_i, 
                      cur_fragment[cur_read_nuc_i], phred_quality_str[cur_read_nuc_i], 
                      (int)(phred_quality_str[cur_read_nuc_i]-phred_score_base));
}
                  } // phred qual nopass check.
                } // max_n_alleles_per_posn check.
              } // char < 4 check.

              // Update the read's nucleotide index.
              cur_read_nuc_i++;
            } // i_cur loop.
          } // genomic match check.
          else if(entry_type_char == 'D')
          {
            // Deletion from the reference: Update the 4th entry: Add all of these entries as deletions.
            for(int cur_genome_i = chr_index; cur_genome_i <= chr_index+l_cur_entry-1; cur_genome_i++)
            {
              per_chrom_nuc_count_per_allele[i_chr][4][cur_genome_i]++;
            } // cur_genome_i loop.
          }
          else if(entry_type_char == 'I')
          {
            // Insertion to the reference: This is included to one position.
            per_chrom_nuc_count_per_allele[i_chr][4][chr_index]++;
          }
          // Update the base for the current entry.
          if(check_genome_index_update_per_CIGAR_entry(entry_type_char))
          {
            chr_index += l_cur_entry;
          }

          // Update the base for the current read if requested.
          if(check_read_nuc_index_update_per_CIGAR_entry(entry_type_char))
          {
            read_nuc_index += l_cur_entry;
          }
        } // mapping map string processing loop.

        //delete(cur_entry_length_str);
      } // mapping check for the current read.
    } // SAM read line parse check.
    else
    {
      fprintf(stderr, "Could not parse %s\n", cur_line);
      exit(0);
    }

    delete [] cur_line;
  } // file reading loop.

  fprintf(stderr, "Finished reading.\n");

  fclose(f_sam);

  // Dump the counts per position.
  for(int i_chr = 0; i_chr < (int)chr_ids->size(); i_chr++)
  {
    char cur_allele_fp[1000];
    sprintf(cur_allele_fp, "%s/%s_allele_counts.bin", op_dir, chr_ids->at(i_chr));

    // compress and dump the current file.
    compress_nucleotide_pileup_track(per_chrom_nuc_count_per_allele[i_chr], chr_lengths->at(i_chr), cur_allele_fp);
  } // i_chr loop.

  //char analysis_summary_str[1000];
  //sprintf(analysis_summary_str, "Processed %d reads, %d low quality reads, %d unmapped reads.\n", n_processed_reads, n_low_quality, n_unmapped_reads);
  //t_config_params::copy_analysis_summary_string(analysis_summary_str);

  //// Write the summary file.
  //f_summary = open_f(summary_fp, "w");
  //fprintf(f_summary, "Processed %d reads, %d low quality reads, %d unmapped reads.\n", n_processed_reads, n_low_quality_reads, n_unmapped_reads);
  //fclose(f_summary);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1bbb8, %rsp          # imm = 0x1BBB8
movq %rcx, 0x50(%rsp)
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r13
movq 0x1bbf0(%rsp), %r15
movq 0xccb2(%rip), %r14      # 0xefe0
movq (%r14), %rdi
leaq 0x7ea0(%rip), %rsi      # 0xa1d8
movl %r8d, 0xc(%rsp)
movl %r8d, %edx
movl %r9d, 0x8(%rsp)
movl %r9d, %ecx
xorl %eax, %eax
callq 0x2230
andl $0x0, (%r15)
movq (%r14), %rdi
leaq 0x7ec4(%rip), %rsi      # 0xa221
movq %r13, 0x20(%rsp)
movq %r13, %rdx
xorl %eax, %eax
callq 0x2230
movq (%r14), %rcx
leaq 0x7ed0(%rip), %rdi      # 0xa246
pushq $0x1a
popq %rsi
pushq $0x1
popq %rdx
callq 0x22e0
movq (%rbx), %r14
movq %rbx, 0x18(%rsp)
movq 0x8(%rbx), %rbx
subq %r14, %rbx
movq %rbx, %rax
shlq $0x1d, %rax
movq %rax, %rcx
sarq $0x1d, %rcx
testq %rax, %rax
pushq $-0x1
popq %rdi
cmovnsq %rcx, %rdi
callq 0x2040
movq %rax, 0x10(%rsp)
sarq $0x3, %rbx
testl %ebx, %ebx
jle 0x24bc
leaq 0x7e9c(%rip), %rbp      # 0xa261
leaq 0x3510(%rsp), %r15
xorl %r13d, %r13d
movq (%r12), %rax
movq 0x8(%r12), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %r13, %rdx
jbe 0x2b30
cmpq %r13, %rbx
jbe 0x2b3c
movl (%rax,%r13,4), %ebx
movq (%r14,%r13,8), %rcx
movq %r15, %rdi
movq %rbp, %rsi
movq 0x50(%rsp), %rdx
xorl %eax, %eax
callq 0x2060
movq %r15, %rdi
callq 0x4aa5
testb %al, %al
jne 0x244e
movl %ebx, %edi
callq 0x2ffc
movq 0x10(%rsp), %rcx
movq %rax, (%rcx,%r13,8)
incq %r13
movq 0x18(%rsp), %rax
movq (%rax), %r14
movq 0x8(%rax), %rax
subq %r14, %rax
movq %rax, %rbx
sarq $0x3, %rbx
shrq $0x3, %rax
cltq
cmpq %rax, %r13
jl 0x23d0
jmp 0x24bc
andl $0x0, 0xe00(%rsp)
movq %r15, %rdi
leaq 0xe00(%rsp), %rsi
callq 0x3215
movq 0x10(%rsp), %rcx
movq %rax, (%rcx,%r13,8)
movq (%r12), %rax
movq 0x8(%r12), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %r13, %rdx
jbe 0x2b30
movl 0xe00(%rsp), %ecx
movq 0xcb4a(%rip), %rdx      # 0xefe0
movq (%rdx), %rbx
cmpl (%rax,%r13,4), %ecx
jne 0x2b50
movq %rbx, %rdi
leaq 0x7e15(%rip), %rsi      # 0xa2c2
movq %r15, %rdx
xorl %eax, %eax
callq 0x2230
jmp 0x2428
movq 0xcb1d(%rip), %rbx      # 0xefe0
movq (%rbx), %rcx
leaq 0x7e16(%rip), %rdi      # 0xa2e3
pushq $0x6
popq %rsi
pushq $0x1
popq %rdx
callq 0x22e0
movq (%rbx), %rdi
leaq 0x7e08(%rip), %rsi      # 0xa2ea
movl $0x10000, %edx          # imm = 0x10000
xorl %eax, %eax
callq 0x2230
leaq 0x7e20(%rip), %rsi      # 0xa315
movq 0x20(%rsp), %rbx
movq %rbx, %rdi
callq 0x2210
testl %eax, %eax
jne 0x2512
movq 0xcacb(%rip), %rax      # 0xefd8
movq (%rax), %rbx
jmp 0x2524
leaq 0x7b1d(%rip), %rsi      # 0xa036
movq %rbx, %rdi
callq 0x2190
movq %rax, %rbx
callq 0x305d
movq %rax, 0x30(%rsp)
movq %rbx, %rdi
callq 0x498e
testq %rax, %rax
movl 0xc(%rsp), %ebp
jne 0x2616
movq 0xca96(%rip), %rax      # 0xefe0
movq (%rax), %rcx
leaq 0x7edb(%rip), %rdi      # 0xa42f
pushq $0x12
popq %rsi
pushq $0x1
popq %rdx
callq 0x22e0
movq %rbx, %rdi
callq 0x2150
movq 0x18(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
testl %edx, %edx
jle 0x2604
leaq 0x7cd8(%rip), %r15      # 0xa261
leaq 0x620(%rsp), %r13
xorl %ebx, %ebx
cmpq %rbx, %rdx
jbe 0x2ba7
movq (%rax,%rbx,8), %rcx
movq %r13, %rdi
movq %r15, %rsi
movq 0x50(%rsp), %rdx
xorl %eax, %eax
callq 0x2060
movq (%r12), %rax
movq 0x8(%r12), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %rbx, %rdx
jbe 0x2ba7
movq 0x10(%rsp), %rcx
movq (%rcx,%rbx,8), %rdi
movl (%rax,%rbx,4), %esi
movq %r13, %rdx
callq 0x350f
incq %rbx
movq 0x18(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
subq %rax, %rcx
movq %rcx, %rdx
sarq $0x3, %rdx
shrq $0x3, %rcx
movslq %ecx, %rcx
cmpq %rcx, %rbx
jl 0x2593
addq $0x1bbb8, %rsp          # imm = 0x1BBB8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rdi
pushq $-0x7b
popq %rax
leaq 0x3510(%rsp), %r14
leaq 0x70(%rsp), %r13
leaq 0xe0(%rsp), %r15
movl %eax, 0x4(%rsp)
movq %r12, 0x58(%rsp)
movq %rbx, 0x48(%rsp)
cmpb $0x40, (%rdi)
je 0x26f6
movq %rdi, 0x28(%rsp)
leaq 0x7cc7(%rip), %rsi      # 0xa31b
leaq 0xa10(%rsp), %rdx
movq %r15, %rcx
leaq 0x1c0(%rsp), %r8
leaq 0x150(%rsp), %r9
xorl %eax, %eax
pushq %r14
leaq 0x238(%rsp), %r10
pushq %r10
leaq 0xe10(%rsp), %r10
pushq %r10
pushq %r13
callq 0x2140
addq $0x20, %rsp
cmpl $0x8, %eax
jne 0x2b83
cmpl $-0x7b, 0x4(%rsp)
jne 0x26e5
movq %r14, %rdi
callq 0x20a0
pushq $-0x7b
popq %rcx
movl %ecx, 0x4(%rsp)
testl %eax, %eax
jle 0x26e5
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
xorl %edx, %edx
movsbl 0x3510(%rsp,%rdx), %ecx
cmpl $0x4b, %ecx
jge 0x2a81
cmpb $0x3a, %cl
jle 0x2ab5
incq %rdx
cmpq %rdx, %rax
jne 0x26bc
pushq $-0x7b
popq %rax
movl %eax, 0x4(%rsp)
movq %r13, %rdi
callq 0x2270
cmpl %ebp, %eax
jge 0x2714
movq 0x28(%rsp), %rdi
callq 0x21f0
movq %rbx, %rdi
callq 0x498e
movq %rax, %rdi
testq %rax, %rax
jne 0x263f
jmp 0x2543
leaq 0x1c0(%rsp), %rbx
movq %rbx, %rdi
callq 0x30cc
movq %r15, %rdi
callq 0x2270
movl %eax, %r14d
movq 0x18(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x5bea
movl %eax, %ebx
movq 0x8(%r15), %rax
subq (%r15), %rax
shrq $0x3, %rax
cmpl %eax, %ebx
jne 0x2771
movq 0x28(%rsp), %rdi
callq 0x21f0
movq 0x48(%rsp), %rbx
leaq 0x3510(%rsp), %r14
leaq 0xe0(%rsp), %r15
jmp 0x26fb
leaq 0x150(%rsp), %rdi
callq 0x2270
testb $0x4, %r14b
leaq 0xe0(%rsp), %r15
jne 0x2a65
movl %eax, %edi
movq 0x1bbf0(%rsp), %rax
movl (%rax), %ecx
incl %ecx
movl %ecx, (%rax)
movl %ecx, %eax
cltd
movl $0xf4240, %esi          # imm = 0xF4240
idivl %esi
testl %edx, %edx
leaq 0x3510(%rsp), %r14
movq %rdi, %rbp
je 0x2ae9
cmpb $0x1, 0xc9cd(%rip)      # 0xf191
je 0x2b08
leaq 0xe00(%rsp), %rdi
leaq 0x620(%rsp), %rsi
callq 0x3453
testb %al, %al
movq 0x10(%rsp), %rdi
movl 0x8(%rsp), %r10d
movq 0x30(%rsp), %r11
movabsq $0x100000000, %r8       # imm = 0x100000000
movq %rbp, %r9
movl 0xc(%rsp), %ebp
je 0x2a60
movb 0xe00(%rsp), %al
testb %al, %al
je 0x2a60
movslq %ebx, %rcx
movq %rcx, 0x20(%rsp)
xorl %ecx, %ecx
xorl %r14d, %r14d
xorl %ebx, %ebx
leal -0x3a(%rax), %edx
cmpb $-0xa, %dl
jae 0x2842
incl %r14d
xorl %r12d, %r12d
movb $0x4d, %cl
cmpb $0x4d, %al
jne 0x299a
jmp 0x2a1e
movslq %r9d, %r13
movq %rcx, %rdx
shlq $0x20, %rdx
leal 0x1(%rcx), %r14d
leaq 0xe01(%rsp), %rsi
addq %rsi, %rcx
xorl %r12d, %r12d
addq %r8, %rdx
imull $0xa, %r12d, %esi
addb $-0x30, %al
movzbl %al, %r12d
addl %esi, %r12d
movb (%rcx), %al
leal -0x3a(%rax), %esi
incl %r14d
incq %rcx
cmpb $-0xb, %sil
ja 0x285e
sarq $0x20, %rdx
movb 0xe00(%rsp,%rdx), %cl
cmpb $0x4d, %al
jne 0x2993
testl %r12d, %r12d
jle 0x2a15
movq %rcx, 0x60(%rsp)
movq %r9, 0x68(%rsp)
leal (%r12,%r9), %eax
movslq %eax, %rsi
movl %ebx, 0x44(%rsp)
movslq %ebx, %rbx
movq %rsi, 0x38(%rsp)
movsbq 0x230(%rsp,%rbx), %rcx
movslq (%r11,%rcx,4), %r15
cmpq $0x3, %r15
jg 0x291e
movq 0x20(%rsp), %rax
movq (%rdi,%rax,8), %rbp
movq (%rbp,%r15,8), %rax
movzwl (%rax,%r13,2), %edx
cmpw $-0x6, %dx
ja 0x291e
movsbl 0x3510(%rsp,%rbx), %r8d
movl %r8d, %r9d
subl 0x4(%rsp), %r9d
movb 0xc895(%rip), %sil      # 0xf191
cmpl %r10d, %r9d
jle 0x2914
testb %sil, %sil
jne 0x292e
incl %edx
movw %dx, (%rax,%r13,2)
movq 0x38(%rsp), %rsi
jmp 0x291e
testb %sil, %sil
movq 0x38(%rsp), %rsi
jne 0x2963
incq %rbx
incq %r13
cmpq %rsi, %r13
jl 0x28b8
jmp 0x29ea
movq 0xc6ab(%rip), %rax      # 0xefe0
movq (%rax), %rdi
leaq 0x7aaa(%rip), %rsi      # 0xa3e9
movl %ebx, %edx
xorl %eax, %eax
callq 0x2230
movq 0x30(%rsp), %r11
movl 0x8(%rsp), %r10d
movq 0x10(%rsp), %rdi
movq (%rbp,%r15,8), %rax
movzwl (%rax,%r13,2), %edx
jmp 0x2906
movq 0xc676(%rip), %rax      # 0xefe0
movq (%rax), %rdi
leaq 0x7a8d(%rip), %rsi      # 0xa401
movl %ebx, %edx
xorl %eax, %eax
callq 0x2230
movq 0x38(%rsp), %rsi
movq 0x30(%rsp), %r11
movl 0x8(%rsp), %r10d
movq 0x10(%rsp), %rdi
jmp 0x291e
movl %ecx, %eax
leaq 0x70(%rsp), %r13
cmpb $0x49, %al
je 0x29d2
movzbl %al, %ecx
cmpl $0x44, %ecx
jne 0x29ce
testl %r12d, %r12d
jle 0x2a1c
leal (%r12,%r9), %esi
movq 0x20(%rsp), %rcx
movq (%rdi,%rcx,8), %rcx
movq 0x20(%rcx), %rcx
movslq %r9d, %rdx
movslq %esi, %rsi
incw (%rcx,%rdx,2)
incq %rdx
cmpq %rsi, %rdx
jl 0x29c2
movl %eax, %ecx
jmp 0x2a1e
movq 0x20(%rsp), %rax
movq (%rdi,%rax,8), %rax
movq 0x20(%rax), %rax
movslq %r9d, %rcx
incw (%rax,%rcx,2)
movb $0x49, %cl
jmp 0x2a1e
movl 0xc(%rsp), %ebp
leaq 0x70(%rsp), %r13
leaq 0xe0(%rsp), %r15
movabsq $0x100000000, %r8       # imm = 0x100000000
movq 0x68(%rsp), %r9
movl 0x44(%rsp), %ebx
movq 0x60(%rsp), %rcx
jmp 0x2a1e
leaq 0x70(%rsp), %r13
jmp 0x2a1e
movb $0x44, %cl
leal -0x4d(%rcx), %eax
cmpb $0x2, %al
movl $0x0, %eax
cmovbl %r12d, %eax
cmpb $0x44, %cl
cmovel %r12d, %eax
addl %eax, %r9d
movl %ecx, %eax
andb $-0x5, %al
cmpb $0x49, %al
movl $0x0, %eax
cmovel %r12d, %eax
cmpb $0x53, %cl
cmovel %r12d, %eax
addl %eax, %ebx
movslq %r14d, %rcx
movb 0xe00(%rsp,%rcx), %al
testb %al, %al
jne 0x2825
movq 0x58(%rsp), %r12
movq 0x28(%rsp), %rdi
callq 0x21f0
movq 0x48(%rsp), %rbx
leaq 0x3510(%rsp), %r14
jmp 0x26fb
movq 0xc558(%rip), %rax      # 0xefe0
movq (%rax), %rdi
movq 0x1bbf0(%rsp), %rax
movl (%rax), %edx
leaq 0x78c4(%rip), %rsi      # 0xa360
leaq 0x230(%rsp), %r8
movq %r14, %r9
xorl %eax, %eax
callq 0x2230
pushq $0x3b
jmp 0x26e0
movq 0xc524(%rip), %rax      # 0xefe0
movq (%rax), %rdi
movq 0x1bbf0(%rsp), %rax
movl (%rax), %edx
leaq 0x78ba(%rip), %rsi      # 0xa38a
leaq 0x230(%rsp), %r8
movq %r14, %r9
xorl %eax, %eax
callq 0x2230
pushq $0x21
jmp 0x26e0
movq 0xc4f0(%rip), %rax      # 0xefe0
movq (%rax), %rdi
leaq 0x78ba(%rip), %rsi      # 0xa3b4
movl %ecx, %edx
xorl %eax, %eax
callq 0x2230
jmp 0x27bd
movq 0xc4d1(%rip), %rax      # 0xefe0
movq (%rax), %rdi
leaq 0x78bd(%rip), %rsi      # 0xa3d6
leaq 0x230(%rsp), %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x2230
jmp 0x27ca
leaq 0x7e2d(%rip), %rdi      # 0xa964
movq %r13, %rsi
jmp 0x2b49
leaq 0x7e21(%rip), %rdi      # 0xa964
movq %r13, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2250
movq 0x18(%rsp), %rdi
movq %r13, %rsi
callq 0x3fee
movq (%rax), %r14
movq %r12, %rdi
movq %r13, %rsi
callq 0x3fc6
movl (%rax), %ecx
leaq 0x7705(%rip), %rsi      # 0xa279
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x2230
jmp 0x2ba0
movq 0xc456(%rip), %rax      # 0xefe0
movq (%rax), %rdi
leaq 0x7887(%rip), %rsi      # 0xa41b
movq 0x28(%rsp), %rdx
xorl %eax, %eax
callq 0x2230
xorl %edi, %edi
callq 0x21b0
leaq 0x7db6(%rip), %rdi      # 0xa964
movq %rbx, %rsi
jmp 0x2b49