// File: /workspace/github_cpp_makefile_star2_O2/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 $0x1bbc8, %rsp          # imm = 0x1BBC8
movq %rcx, 0x58(%rsp)
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %r15
movq 0x1bc00(%rsp), %r14
movq 0xc378(%rip), %rbx      # 0xefe0
movq (%rbx), %rdi
leaq 0x6556(%rip), %rsi      # 0x91c8
movl %r8d, 0x4c(%rsp)
movl %r8d, %edx
movl %r9d, 0x14(%rsp)
movl %r9d, %ecx
xorl %eax, %eax
callq 0x2240
andl $0x0, (%r14)
movq (%rbx), %rdi
leaq 0x657a(%rip), %rsi      # 0x9211
movq %r15, 0x30(%rsp)
movq %r15, %rdx
xorl %eax, %eax
callq 0x2240
movq (%rbx), %rcx
leaq 0x6586(%rip), %rdi      # 0x9236
pushq $0x1a
popq %rsi
pushq $0x1
popq %rdx
callq 0x22f0
movq (%r13), %r14
movq 0x8(%r13), %rbx
movq %rbx, %rax
subq %r14, %rax
shlq $0x1d, %rax
movq %rax, %rcx
sarq $0x1d, %rcx
testq %rax, %rax
pushq $-0x1
popq %rdi
cmovnsq %rcx, %rdi
callq 0x2040
movq %rax, 0x20(%rsp)
leaq 0x6562(%rip), %rbp      # 0x9251
xorl %r15d, %r15d
subq %r14, %rbx
shrq $0x3, %rbx
movslq %ebx, %rax
cmpq %rax, %r15
jge 0x2dca
movq %r12, %rdi
movq %r15, %rsi
callq 0x3bc0
movl (%rax), %ebx
movq %r13, %rdi
movq %r15, %rsi
callq 0x3be2
movq (%rax), %rcx
leaq 0x3520(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
movq 0x58(%rsp), %rdx
xorl %eax, %eax
callq 0x2060
movq %r14, %rdi
callq 0x4676
testb %al, %al
jne 0x2d63
movl %ebx, %edi
callq 0x23fc
movq 0x20(%rsp), %rcx
movq %rax, (%rcx,%r15,8)
incq %r15
movq (%r13), %r14
movq 0x8(%r13), %rbx
jmp 0x2cf2
andl $0x0, 0xe10(%rsp)
leaq 0x3520(%rsp), %rdi
leaq 0xe10(%rsp), %rsi
callq 0x25f6
movq 0x20(%rsp), %rcx
movq %rax, (%rcx,%r15,8)
movl 0xe10(%rsp), %r14d
movq %r12, %rdi
movq %r15, %rsi
callq 0x3bc0
movq 0xc23d(%rip), %rcx      # 0xefe0
movq (%rcx), %rbx
cmpl (%rax), %r14d
jne 0x336c
movq %rbx, %rdi
leaq 0x64f9(%rip), %rsi      # 0x92b2
leaq 0x3520(%rsp), %rdx
xorl %eax, %eax
callq 0x2240
jmp 0x2d56
movq 0xc20f(%rip), %rbx      # 0xefe0
movq (%rbx), %rcx
leaq 0x64f8(%rip), %rdi      # 0x92d3
pushq $0x6
popq %rsi
pushq $0x1
popq %rdx
callq 0x22f0
movq (%rbx), %rdi
leaq 0x64ea(%rip), %rsi      # 0x92da
movl $0x10000, %edx          # imm = 0x10000
xorl %eax, %eax
callq 0x2240
leaq 0x6502(%rip), %rsi      # 0x9305
movq 0x30(%rsp), %rbx
movq %rbx, %rdi
callq 0x2220
testl %eax, %eax
jne 0x2e20
movq 0xc1bd(%rip), %rax      # 0xefd8
movq (%rax), %r15
jmp 0x2e32
leaq 0x61ff(%rip), %rsi      # 0x9026
movq %rbx, %rdi
callq 0x21a0
movq %rax, %r15
leaq 0x3520(%rsp), %r14
callq 0x245a
movq %rax, 0x40(%rsp)
pushq $-0x7b
popq %rax
leaq 0x80(%rsp), %rbp
movl %eax, 0xc(%rsp)
movq %r12, 0x70(%rsp)
movq %r15, %rdi
callq 0x459e
testq %rax, %rax
je 0x32c7
movq %rax, %rbx
cmpb $0x40, (%rax)
jne 0x2e7b
movq %rbx, %rdi
callq 0x2200
jmp 0x2e58
movq %rbx, %rdi
leaq 0x6486(%rip), %rsi      # 0x930b
leaq 0xa20(%rsp), %rdx
leaq 0x160(%rsp), %rcx
leaq 0x1d0(%rsp), %r8
leaq 0xf0(%rsp), %r9
xorl %eax, %eax
pushq %r14
leaq 0x248(%rsp), %r10
pushq %r10
leaq 0xe20(%rsp), %r10
pushq %r10
pushq %rbp
callq 0x2150
addq $0x20, %rsp
cmpl $0x8, %eax
jne 0x33a2
movl 0xc(%rsp), %eax
cmpl $-0x7b, %eax
jne 0x2f3f
movq %r14, %rdi
callq 0x20c0
testl %eax, %eax
movl $0x0, %ecx
cmovlel %ecx, %eax
xorl %edx, %edx
cmpq %rdx, %rax
je 0x2f3c
movsbl 0x3520(%rsp,%rdx), %ecx
cmpl $0x4b, %ecx
jge 0x324c
incq %rdx
cmpb $0x3a, %cl
jg 0x2eed
movq 0xc0ce(%rip), %rax      # 0xefe0
movq (%rax), %rdi
movq 0x1bc00(%rsp), %rax
movl (%rax), %edx
leaq 0x6454(%rip), %rsi      # 0x937a
leaq 0x240(%rsp), %r8
movq %r14, %r9
xorl %eax, %eax
callq 0x2240
pushq $0x21
jmp 0x2f3e
pushq $-0x7b
popq %rax
movl %eax, 0xc(%rsp)
movq %rbp, %rdi
callq 0x2280
cmpl 0x4c(%rsp), %eax
jl 0x2e71
leaq 0x1d0(%rsp), %r12
movq %r12, %rdi
callq 0x24c2
leaq 0x160(%rsp), %rdi
callq 0x2280
movl %eax, 0x30(%rsp)
movq %r13, %rdi
movq %r12, %rsi
callq 0x5532
movl %eax, %r12d
movq 0x8(%r13), %rax
subq (%r13), %rax
shrq $0x3, %rax
cmpl %eax, %r12d
je 0x2e71
leaq 0xf0(%rsp), %rdi
callq 0x2280
movl %eax, 0x10(%rsp)
testb $0x4, 0x30(%rsp)
jne 0x2e71
movq 0x1bc00(%rsp), %rax
movl (%rax), %ecx
incl %ecx
movl %ecx, (%rax)
movl %ecx, %eax
cltd
movl $0xf4240, %esi          # imm = 0xF4240
idivl %esi
testl %edx, %edx
je 0x3280
cmpb $0x1, 0xc1bd(%rip)      # 0xf199
je 0x329f
andl $0x0, 0x630(%rsp)
movb $0x0, 0xb(%rsp)
leaq 0xe10(%rsp), %rdi
leaq 0x1f(%rsp), %rsi
callq 0x282f
testb %al, %al
je 0x2e71
movslq %r12d, %rsi
xorl %eax, %eax
movl $0x0, 0x3c(%rsp)
movq %r13, 0x68(%rsp)
movq %r15, 0x60(%rsp)
movq %rsi, 0x28(%rsp)
cltq
cmpb $0x0, 0xe10(%rsp,%rax)
je 0x2e71
leaq 0xe10(%rsp), %rdi
leaq 0x630(%rsp), %rsi
leaq 0xb(%rsp), %rdx
leaq 0x18(%rsp), %rcx
leaq 0xa(%rsp), %r8
callq 0x288c
cmpb $0x1, 0xb(%rsp)
jne 0x3194
movslq 0x18(%rsp), %r15
movslq 0x10(%rsp), %rbp
addq %rbp, %r15
movslq 0x3c(%rsp), %rax
movl %eax, %ecx
movq %rcx, 0x50(%rsp)
leaq (%rsp,%rax), %rcx
addq $0x240, %rcx            # imm = 0x240
movq %rcx, 0x30(%rsp)
addq %rsp, %rax
addq $0x3520, %rax           # imm = 0x3520
movq %rax, 0x78(%rsp)
xorl %r13d, %r13d
movl 0x14(%rsp), %edi
movq 0x40(%rsp), %r10
movl 0xc(%rsp), %r11d
movq 0x28(%rsp), %rsi
cmpq %r15, %rbp
jge 0x31d0
movq 0x30(%rsp), %rax
movsbq (%rax,%r13), %rcx
movslq (%r10,%rcx,4), %r14
cmpq $0x3, %r14
jg 0x311d
movq 0x20(%rsp), %rax
movq (%rax,%rsi,8), %r12
movq (%r12,%r14,8), %rax
movzwl (%rax,%rbp,2), %edx
cmpw $-0x6, %dx
ja 0x311d
movq 0x78(%rsp), %rsi
movsbl (%rsi,%r13), %r8d
movl %r8d, %r9d
subl %r11d, %r9d
movb 0xc09d(%rip), %sil      # 0xf199
cmpl %edi, %r9d
jle 0x3113
testb %sil, %sil
jne 0x3125
incl %edx
movw %dx, (%rax,%rbp,2)
movq 0x28(%rsp), %rsi
jmp 0x311d
testb %sil, %sil
movq 0x28(%rsp), %rsi
jne 0x315e
incq %rbp
incq %r13
jmp 0x30b1
movq 0xbeb4(%rip), %rax      # 0xefe0
movq (%rax), %rdi
movq 0x50(%rsp), %rax
leal (%rax,%r13), %edx
leaq 0x629a(%rip), %rsi      # 0x93d9
xorl %eax, %eax
callq 0x2240
movl 0xc(%rsp), %r11d
movq 0x40(%rsp), %r10
movl 0x14(%rsp), %edi
movq (%r12,%r14,8), %rax
movzwl (%rax,%rbp,2), %edx
jmp 0x3106
movq 0xbe7b(%rip), %rax      # 0xefe0
movq (%rax), %rdi
movq 0x50(%rsp), %rax
leal (%rax,%r13), %edx
leaq 0x6279(%rip), %rsi      # 0x93f1
xorl %eax, %eax
callq 0x2240
movq 0x28(%rsp), %rsi
movl 0xc(%rsp), %r11d
movq 0x40(%rsp), %r10
movl 0x14(%rsp), %edi
jmp 0x311d
movzbl 0xa(%rsp), %eax
cmpl $0x49, %eax
movq 0x28(%rsp), %rsi
je 0x31f4
cmpl $0x44, %eax
jne 0x320c
movslq 0x10(%rsp), %rax
movslq 0x18(%rsp), %rcx
addq %rax, %rcx
cmpq %rcx, %rax
jge 0x31f0
movq 0x20(%rsp), %rdx
movq (%rdx,%rsi,8), %rdx
movq 0x20(%rdx), %rdx
incw (%rdx,%rax,2)
incq %rax
jmp 0x31b5
movb 0xa(%rsp), %al
movq 0x68(%rsp), %r13
leaq 0x3520(%rsp), %r14
movq 0x60(%rsp), %r15
leaq 0x80(%rsp), %rbp
jmp 0x320c
movb $0x44, %al
jmp 0x320c
movq 0x20(%rsp), %rax
movq (%rax,%rsi,8), %rax
movq 0x20(%rax), %rax
movslq 0x10(%rsp), %rcx
incw (%rax,%rcx,2)
movb $0x49, %al
leal -0x4d(%rax), %ecx
cmpb $0x2, %cl
movl 0x18(%rsp), %ecx
movl $0x0, %edx
cmovbl %ecx, %edx
cmpb $0x44, %al
cmovel %ecx, %edx
addl %edx, 0x10(%rsp)
movl %eax, %edx
andb $-0x5, %dl
cmpb $0x49, %dl
movl $0x0, %edx
cmovel %ecx, %edx
cmpb $0x53, %al
cmovel %ecx, %edx
addl %edx, 0x3c(%rsp)
movl 0x630(%rsp), %eax
jmp 0x3025
movq 0xbd8d(%rip), %rax      # 0xefe0
movq (%rax), %rdi
movq 0x1bc00(%rsp), %rax
movl (%rax), %edx
leaq 0x60e9(%rip), %rsi      # 0x9350
leaq 0x240(%rsp), %r8
movq %r14, %r9
xorl %eax, %eax
callq 0x2240
pushq $0x3b
jmp 0x2f3e
movq 0xbd59(%rip), %rax      # 0xefe0
movq (%rax), %rdi
leaq 0x6113(%rip), %rsi      # 0x93a4
movl %ecx, %edx
xorl %eax, %eax
callq 0x2240
jmp 0x2fd5
movq 0xbd3a(%rip), %rax      # 0xefe0
movq (%rax), %rdi
leaq 0x6116(%rip), %rsi      # 0x93c6
leaq 0x240(%rsp), %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x2240
jmp 0x2fe2
movq 0xbd12(%rip), %rax      # 0xefe0
movq (%rax), %rcx
leaq 0x6147(%rip), %rdi      # 0x941f
pushq $0x12
popq %rsi
pushq $0x1
popq %rdx
callq 0x22f0
movq %r15, %rdi
callq 0x2160
leaq 0x5f5f(%rip), %rbx      # 0x9251
leaq 0x630(%rsp), %r15
movq %r13, %r14
xorl %r13d, %r13d
movq 0x8(%r14), %rax
subq (%r14), %rax
shrq $0x3, %rax
cltq
cmpq %rax, %r13
jge 0x335a
movq %r14, %rdi
movq %r13, %rsi
callq 0x3be2
movq (%rax), %rcx
movq %r15, %rdi
movq %rbx, %rsi
movq 0x58(%rsp), %rdx
xorl %eax, %eax
callq 0x2060
movq 0x20(%rsp), %rax
movq (%rax,%r13,8), %rbp
movq 0x70(%rsp), %rdi
movq %r13, %rsi
callq 0x3bc0
movl (%rax), %esi
movq %rbp, %rdi
movq %r15, %rdx
callq 0x28cf
incq %r13
jmp 0x3300
addq $0x1bbc8, %rsp          # imm = 0x1BBC8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r13, %rdi
movq %r15, %rsi
callq 0x3be2
movq (%rax), %r14
movq %r12, %rdi
movq %r15, %rsi
callq 0x3bc0
movl (%rax), %ecx
leaq 0x5edb(%rip), %rsi      # 0x9269
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x2240
xorl %edi, %edi
callq 0x21c0
movq 0xbc37(%rip), %rax      # 0xefe0
movq (%rax), %rdi
leaq 0x6058(%rip), %rsi      # 0x940b
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2240
jmp 0x339b