// File: 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 %rbx
subq $0x1c070, %rsp          # imm = 0x1C070
movq 0x1c080(%rsp), %rax
movq %rdi, 0x1c068(%rsp)
movq %rsi, 0x1c060(%rsp)
movq %rdx, 0x1c058(%rsp)
movq %rcx, 0x1c050(%rsp)
movl %r8d, 0x1c04c(%rsp)
movl %r9d, 0x1c048(%rsp)
movq 0x17b49(%rip), %rax     # 0x1afe0
movq (%rax), %rdi
movl 0x1c04c(%rsp), %edx
movl 0x1c048(%rsp), %ecx
leaq 0x10d47(%rip), %rsi     # 0x141f6
movb $0x0, %al
callq 0x2240
movq 0x1c080(%rsp), %rax
movl $0x0, (%rax)
movq 0x17b15(%rip), %rax     # 0x1afe0
movq (%rax), %rdi
movq 0x1c068(%rsp), %rdx
leaq 0x10d62(%rip), %rsi     # 0x1423f
movb $0x0, %al
callq 0x2240
movq 0x17af5(%rip), %rax     # 0x1afe0
movq (%rax), %rdi
leaq 0x10d6f(%rip), %rsi     # 0x14264
movb $0x0, %al
callq 0x2240
movq 0x1c060(%rsp), %rdi
callq 0x4f10
cltq
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2040
movq %rax, 0x1c040(%rsp)
movl $0x0, 0x1c03c(%rsp)
movl 0x1c03c(%rsp), %eax
movl %eax, 0x9c(%rsp)
movq 0x1c060(%rsp), %rdi
callq 0x4f10
movq %rax, %rcx
movl 0x9c(%rsp), %eax
cmpl %ecx, %eax
jge 0x371d
movq 0x1c058(%rsp), %rdi
movslq 0x1c03c(%rsp), %rsi
callq 0x4f30
movl (%rax), %eax
movl %eax, 0x1c038(%rsp)
leaq 0x1bc50(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0x1c050(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0x1c060(%rsp), %rdi
movslq 0x1c03c(%rsp), %rsi
callq 0x4f70
movq 0x88(%rsp), %rdi
movq 0x90(%rsp), %rdx
movq (%rax), %rcx
leaq 0x10ca6(%rip), %rsi     # 0x1427f
movb $0x0, %al
callq 0x2070
leaq 0x1bc50(%rsp), %rdi
callq 0x6e70
testb $0x1, %al
jne 0x35f6
jmp 0x36e2
movl $0x0, 0x1bc4c(%rsp)
leaq 0x1bc50(%rsp), %rdi
leaq 0x1bc4c(%rsp), %rsi
callq 0x2760
movq %rax, %rdx
movq 0x1c040(%rsp), %rax
movslq 0x1c03c(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movl 0x1bc4c(%rsp), %eax
movl %eax, 0x84(%rsp)
movq 0x1c058(%rsp), %rdi
movslq 0x1c03c(%rsp), %rsi
callq 0x4f30
movq %rax, %rcx
movl 0x84(%rsp), %eax
cmpl (%rcx), %eax
je 0x36c0
movq 0x1797b(%rip), %rax     # 0x1afe0
movq (%rax), %rax
movq %rax, 0x70(%rsp)
movq 0x1c060(%rsp), %rdi
movslq 0x1c03c(%rsp), %rsi
callq 0x4f70
movq (%rax), %rax
movq %rax, 0x78(%rsp)
movq 0x1c058(%rsp), %rdi
movslq 0x1c03c(%rsp), %rsi
callq 0x4f30
movq 0x70(%rsp), %rdi
movq 0x78(%rsp), %rdx
movl (%rax), %ecx
leaq 0x10be5(%rip), %rsi     # 0x14297
movb $0x0, %al
callq 0x2240
xorl %edi, %edi
callq 0x21d0
movq 0x17919(%rip), %rax     # 0x1afe0
movq (%rax), %rdi
leaq 0x1bc50(%rsp), %rdx
leaq 0x10c07(%rip), %rsi     # 0x142e0
movb $0x0, %al
callq 0x2240
jmp 0x3705
movl 0x1c038(%rsp), %edi
callq 0x2420
movq %rax, %rdx
movq 0x1c040(%rsp), %rax
movslq 0x1c03c(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x3707
movl 0x1c03c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c03c(%rsp)
jmp 0x353f
movq 0x178bc(%rip), %rax     # 0x1afe0
movq (%rax), %rdi
leaq 0x10bd3(%rip), %rsi     # 0x14301
movb $0x0, %al
callq 0x2240
movl $0x10000, 0x1bc48(%rsp) # imm = 0x10000
movq 0x17899(%rip), %rax     # 0x1afe0
movq (%rax), %rdi
movl 0x1bc48(%rsp), %edx
leaq 0x10bb0(%rip), %rsi     # 0x14308
movb $0x0, %al
callq 0x2240
movq $0x0, 0x1bc40(%rsp)
movq 0x1c068(%rsp), %rdi
leaq 0x10bb9(%rip), %rsi     # 0x14333
callq 0x2220
cmpl $0x0, %eax
jne 0x3798
movq 0x1784d(%rip), %rax     # 0x1afd8
movq (%rax), %rax
movq %rax, 0x1bc40(%rsp)
jmp 0x37b4
movq 0x1c068(%rsp), %rdi
leaq 0x10863(%rip), %rsi     # 0x1400a
callq 0x21b0
movq %rax, 0x1bc40(%rsp)
callq 0x24c0
movq %rax, 0x1bc38(%rsp)
movl $0x0, 0x4dc(%rsp)
movl $0x0, 0x4d8(%rsp)
movl $0xffffff85, 0x4d4(%rsp) # imm = 0xFFFFFF85
movq 0x1bc40(%rsp), %rdi
callq 0x6cd0
movq %rax, 0x4c8(%rsp)
cmpq $0x0, 0x4c8(%rsp)
jne 0x3807
jmp 0x3f6e
movq 0x4c8(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x40, %eax
jne 0x3836
movq 0x4c8(%rsp), %rax
movq %rax, 0x68(%rsp)
cmpq $0x0, %rax
je 0x3834
movq 0x68(%rsp), %rdi
callq 0x2200
jmp 0x37e2
movq 0x4c8(%rsp), %rdi
leaq 0x1b850(%rsp), %rdx
leaq 0x18c60(%rsp), %rcx
leaq 0x1b7e0(%rsp), %r8
leaq 0x18bf0(%rsp), %r9
leaq 0x4e0(%rsp), %rbx
leaq 0x190c0(%rsp), %r11
leaq 0x18cd0(%rsp), %r10
leaq 0x550(%rsp), %rax
leaq 0x10ab4(%rip), %rsi     # 0x14339
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movq %rax, 0x18(%rsp)
movb $0x0, %al
callq 0x2160
cmpl $0x8, %eax
jne 0x3f25
cmpl $-0x7b, 0x4d4(%rsp)
jne 0x39cd
leaq 0x550(%rsp), %rdi
callq 0x20d0
movl %eax, 0x4c4(%rsp)
movl $0x0, 0x4c0(%rsp)
movl 0x4c0(%rsp), %eax
cmpl 0x4c4(%rsp), %eax
jge 0x39cb
movslq 0x4c0(%rsp), %rax
movsbl 0x550(%rsp,%rax), %eax
cmpl $0x4a, %eax
jle 0x394d
movq 0x176db(%rip), %rax     # 0x1afe0
movq (%rax), %rdi
movq 0x1c080(%rsp), %rax
movl (%rax), %edx
movslq 0x4c0(%rsp), %rax
movsbl 0x550(%rsp,%rax), %ecx
leaq 0x18cd0(%rsp), %r8
leaq 0x550(%rsp), %r9
leaq 0x10a45(%rip), %rsi     # 0x1437e
movb $0x0, %al
callq 0x2240
movl $0x3b, 0x4d4(%rsp)
jmp 0x39cb
movslq 0x4c0(%rsp), %rax
movsbl 0x550(%rsp,%rax), %eax
cmpl $0x3b, %eax
jge 0x39b1
movq 0x17677(%rip), %rax     # 0x1afe0
movq (%rax), %rdi
movq 0x1c080(%rsp), %rax
movl (%rax), %edx
movslq 0x4c0(%rsp), %rax
movsbl 0x550(%rsp,%rax), %ecx
leaq 0x18cd0(%rsp), %r8
leaq 0x550(%rsp), %r9
leaq 0x10a0b(%rip), %rsi     # 0x143a8
movb $0x0, %al
callq 0x2240
movl $0x21, 0x4d4(%rsp)
jmp 0x39cb
jmp 0x39b3
jmp 0x39b5
movl 0x4c0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c0(%rsp)
jmp 0x38d5
jmp 0x39cd
leaq 0x4e0(%rsp), %rdi
callq 0x2280
cmpl 0x1c04c(%rsp), %eax
jge 0x3a16
movl 0x4d8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4d8(%rsp)
movq 0x4c8(%rsp), %rax
movq %rax, 0x60(%rsp)
cmpq $0x0, %rax
je 0x3a11
movq 0x60(%rsp), %rdi
callq 0x2200
jmp 0x37e2
leaq 0x1b7e0(%rsp), %rdi
callq 0x25b0
leaq 0x18c60(%rsp), %rdi
callq 0x2280
movl %eax, 0x4bc(%rsp)
movq 0x1c060(%rsp), %rdi
leaq 0x1b7e0(%rsp), %rsi
callq 0x9370
movl %eax, 0x4b8(%rsp)
movl 0x4b8(%rsp), %eax
movl %eax, 0x5c(%rsp)
movq 0x1c060(%rsp), %rdi
callq 0x4f10
movq %rax, %rcx
movl 0x5c(%rsp), %eax
cmpl %ecx, %eax
jne 0x3aa9
movl 0x4dc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4dc(%rsp)
movq 0x4c8(%rsp), %rax
movq %rax, 0x50(%rsp)
cmpq $0x0, %rax
je 0x3aa4
movq 0x50(%rsp), %rdi
callq 0x2200
jmp 0x37e2
leaq 0x18bf0(%rsp), %rdi
callq 0x2280
movl %eax, 0x4b4(%rsp)
movl 0x4b4(%rsp), %edi
movl $0x1, %edx
movl %edx, %esi
callq 0x4fb0
movl %eax, 0x1b7dc(%rsp)
movl 0x4bc(%rsp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x3aeb
jmp 0x3f23
movq 0x1c080(%rsp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movq 0x1c080(%rsp), %rax
movl (%rax), %eax
movl $0xf4240, %ecx          # imm = 0xF4240
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x3b33
movq 0x174c8(%rip), %rax     # 0x1afe0
movq (%rax), %rdi
movq 0x1c080(%rsp), %rax
movl (%rax), %edx
leaq 0x108a6(%rip), %rsi     # 0x143d2
movb $0x0, %al
callq 0x2240
testb $0x1, 0x1766f(%rip)     # 0x1b1a9
je 0x3b64
movq 0x1749d(%rip), %rax     # 0x1afe0
movq (%rax), %rdi
leaq 0x18cd0(%rsp), %rdx
leaq 0x550(%rsp), %rcx
leaq 0x10897(%rip), %rsi     # 0x143f4
movb $0x0, %al
callq 0x2240
movl $0x0, 0x4b0(%rsp)
movb $0x0, 0x4af(%rsp)
movb $0x0, 0x4ad(%rsp)
leaq 0x190c0(%rsp), %rdi
leaq 0x4ad(%rsp), %rsi
callq 0x2a90
andb $0x1, %al
movb %al, 0x4ac(%rsp)
movl $0x0, 0x4a8(%rsp)
xorl %eax, %eax
testb $0x1, 0x4ac(%rsp)
movb %al, 0x4f(%rsp)
je 0x3bd2
movslq 0x4b0(%rsp), %rax
movsbl 0x190c0(%rsp,%rax), %eax
cmpl $0x0, %eax
setne %al
movb %al, 0x4f(%rsp)
movb 0x4f(%rsp), %al
testb $0x1, %al
jne 0x3bdf
jmp 0x3f21
leaq 0x190c0(%rsp), %rdi
leaq 0x4b0(%rsp), %rsi
leaq 0x4af(%rsp), %rdx
leaq 0x4a4(%rsp), %rcx
leaq 0x4ae(%rsp), %r8
callq 0x2c40
testb $0x1, 0x4af(%rsp)
je 0x3e17
movl 0x4a8(%rsp), %eax
movl %eax, 0x4a0(%rsp)
movl 0x1b7dc(%rsp), %eax
movl %eax, 0x49c(%rsp)
movl 0x49c(%rsp), %eax
movl 0x1b7dc(%rsp), %ecx
addl 0x4a4(%rsp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jg 0x3e12
movq 0x1bc38(%rsp), %rax
movslq 0x4a0(%rsp), %rcx
movsbl 0x18cd0(%rsp,%rcx), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0x498(%rsp)
cmpl $0x4, 0x498(%rsp)
jge 0x3deb
movq 0x1c040(%rsp), %rax
movslq 0x4b8(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x498(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x49c(%rsp), %rcx
movzwl (%rax,%rcx,2), %eax
movl 0x1bc48(%rsp), %ecx
subl $0x5, %ecx
cmpl %ecx, %eax
jge 0x3de9
movslq 0x4a0(%rsp), %rax
movsbl 0x550(%rsp,%rax), %eax
subl 0x4d4(%rsp), %eax
cmpl 0x1c048(%rsp), %eax
jle 0x3d83
testb $0x1, 0x174b7(%rip)     # 0x1b1a9
je 0x3d4d
movq 0x172e5(%rip), %rax     # 0x1afe0
movq (%rax), %rdi
movl 0x4a0(%rsp), %edx
movslq 0x4a0(%rsp), %rax
movsbl 0x18cd0(%rsp,%rax), %ecx
movslq 0x4a0(%rsp), %rax
movsbl 0x550(%rsp,%rax), %r8d
movslq 0x4a0(%rsp), %rax
movsbl 0x550(%rsp,%rax), %r9d
subl 0x4d4(%rsp), %r9d
leaq 0x106c1(%rip), %rsi     # 0x14407
movb $0x0, %al
callq 0x2240
movq 0x1c040(%rsp), %rax
movslq 0x4b8(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x498(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x49c(%rsp), %rcx
movw (%rax,%rcx,2), %dx
addw $0x1, %dx
movw %dx, (%rax,%rcx,2)
jmp 0x3de7
testb $0x1, 0x1741f(%rip)     # 0x1b1a9
je 0x3de5
movq 0x1724d(%rip), %rax     # 0x1afe0
movq (%rax), %rdi
movl 0x4a0(%rsp), %edx
movslq 0x4a0(%rsp), %rax
movsbl 0x18cd0(%rsp,%rax), %ecx
movslq 0x4a0(%rsp), %rax
movsbl 0x550(%rsp,%rax), %r8d
movslq 0x4a0(%rsp), %rax
movsbl 0x550(%rsp,%rax), %r9d
subl 0x4d4(%rsp), %r9d
leaq 0x10641(%rip), %rsi     # 0x1441f
movb $0x0, %al
callq 0x2240
jmp 0x3de7
jmp 0x3de9
jmp 0x3deb
movl 0x4a0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4a0(%rsp)
movl 0x49c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x49c(%rsp)
jmp 0x3c36
jmp 0x3ecc
movsbl 0x4ae(%rsp), %eax
cmpl $0x44, %eax
jne 0x3e8f
movl 0x1b7dc(%rsp), %eax
movl %eax, 0x494(%rsp)
movl 0x494(%rsp), %eax
movl 0x1b7dc(%rsp), %ecx
addl 0x4a4(%rsp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jg 0x3e8d
movq 0x1c040(%rsp), %rax
movslq 0x4b8(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x20(%rax), %rax
movslq 0x494(%rsp), %rcx
movw (%rax,%rcx,2), %dx
addw $0x1, %dx
movw %dx, (%rax,%rcx,2)
movl 0x494(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x494(%rsp)
jmp 0x3e32
jmp 0x3eca
movsbl 0x4ae(%rsp), %eax
cmpl $0x49, %eax
jne 0x3ec8
movq 0x1c040(%rsp), %rax
movslq 0x4b8(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x20(%rax), %rax
movslq 0x1b7dc(%rsp), %rcx
movw (%rax,%rcx,2), %dx
addw $0x1, %dx
movw %dx, (%rax,%rcx,2)
jmp 0x3eca
jmp 0x3ecc
movsbl 0x4ae(%rsp), %edi
callq 0x33d0
testb $0x1, %al
jne 0x3edf
jmp 0x3ef4
movl 0x4a4(%rsp), %eax
addl 0x1b7dc(%rsp), %eax
movl %eax, 0x1b7dc(%rsp)
movsbl 0x4ae(%rsp), %edi
callq 0x3410
testb $0x1, %al
jne 0x3f07
jmp 0x3f1c
movl 0x4a4(%rsp), %eax
addl 0x4a8(%rsp), %eax
movl %eax, 0x4a8(%rsp)
jmp 0x3ba8
jmp 0x3f23
jmp 0x3f4c
movq 0x170b4(%rip), %rax     # 0x1afe0
movq (%rax), %rdi
movq 0x4c8(%rsp), %rdx
leaq 0x104fb(%rip), %rsi     # 0x14439
movb $0x0, %al
callq 0x2240
xorl %edi, %edi
callq 0x21d0
movq 0x4c8(%rsp), %rax
movq %rax, 0x40(%rsp)
cmpq $0x0, %rax
je 0x3f69
movq 0x40(%rsp), %rdi
callq 0x2200
jmp 0x37e2
movq 0x1706b(%rip), %rax     # 0x1afe0
movq (%rax), %rdi
leaq 0x104ce(%rip), %rsi     # 0x1444d
movb $0x0, %al
callq 0x2240
movq 0x1bc40(%rsp), %rdi
callq 0x2170
movl $0x0, 0x490(%rsp)
movl 0x490(%rsp), %eax
movl %eax, 0x3c(%rsp)
movq 0x1c060(%rsp), %rdi
callq 0x4f10
movq %rax, %rcx
movl 0x3c(%rsp), %eax
cmpl %ecx, %eax
jge 0x4067
leaq 0xa0(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x1c050(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x1c060(%rsp), %rdi
movslq 0x490(%rsp), %rsi
callq 0x4f70
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rdx
movq (%rax), %rcx
leaq 0x10277(%rip), %rsi     # 0x1427f
movb $0x0, %al
callq 0x2070
movq 0x1c040(%rsp), %rax
movslq 0x490(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x30(%rsp)
movq 0x1c058(%rsp), %rdi
movslq 0x490(%rsp), %rsi
callq 0x4f30
movq 0x30(%rsp), %rdi
movl (%rax), %esi
leaq 0xa0(%rsp), %rdx
callq 0x2d30
movl 0x490(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x490(%rsp)
jmp 0x3f9e
addq $0x1c070, %rsp          # imm = 0x1C070
popq %rbx
retq