// File: /workspace/github_c_makefile_star2_O1/xiongxu[P]bam2bedGraph2/samtools-0.1.19/misc/bamcheck.c
// Function: collect_stats
void collect_stats(bam1_t *bam_line, stats_t *stats)
{
    if ( stats->rg_hash )
    {
        const uint8_t *rg = bam_aux_get(bam_line, "RG");
        if ( !rg ) return; 
        khiter_t k = kh_get(kh_rg, stats->rg_hash, (const char*)(rg + 1));
        if ( k == kh_end(stats->rg_hash) ) return;
    }
    if ( stats->flag_require && (bam_line->core.flag & stats->flag_require)!=stats->flag_require )
    {
        stats->nreads_filtered++;
        return;
    }
    if ( stats->flag_filter && (bam_line->core.flag & stats->flag_filter) )
    {
        stats->nreads_filtered++;
        return;
    }
    if ( !is_in_regions(bam_line,stats) )
        return;
    if ( stats->filter_readlen!=-1 && bam_line->core.l_qseq!=stats->filter_readlen ) 
        return;

    if ( bam_line->core.flag & BAM_FQCFAIL ) stats->nreads_QCfailed++;
    if ( bam_line->core.flag & BAM_FSECONDARY ) stats->nreads_secondary++;

    int seq_len = bam_line->core.l_qseq;
    if ( !seq_len ) return;

    if ( seq_len >= stats->nbases )
        realloc_buffers(stats,seq_len);
    if ( stats->max_len<seq_len )
        stats->max_len = seq_len;

    stats->read_lengths[seq_len]++;

    // Count GC and ACGT per cycle
    uint8_t base, *seq  = bam1_seq(bam_line);
    int gc_count  = 0;
    int i;
    int reverse = IS_REVERSE(bam_line);
    for (i=0; i<seq_len; i++)
    {
        // Conversion from uint8_t coding to ACGT
        //      -12-4---8-------
        //      =ACMGRSVTWYHKDBN
        //       01 2   3
        base = bam1_seqi(seq,i);
        base /= 2;
        if ( base==1 || base==2 ) gc_count++;
        else if ( base>2 ) base=3;
        if ( 4*(reverse ? seq_len-i-1 : i) + base >= stats->nbases*4 ) 
            error("FIXME: acgt_cycles\n");
        stats->acgt_cycles[ 4*(reverse ? seq_len-i-1 : i) + base ]++;
    }
    int gc_idx_min = gc_count*(stats->ngc-1)/seq_len;
    int gc_idx_max = (gc_count+1)*(stats->ngc-1)/seq_len;
    if ( gc_idx_max >= stats->ngc ) gc_idx_max = stats->ngc - 1;

    // Determine which array (1st or 2nd read) will these stats go to,
    //  trim low quality bases from end the same way BWA does, 
    //  fill GC histogram
    uint64_t *quals;
    uint8_t *bam_quals = bam1_qual(bam_line);
    if ( bam_line->core.flag&BAM_FREAD2 )
    {
        quals  = stats->quals_2nd;
        stats->nreads_2nd++;
        for (i=gc_idx_min; i<gc_idx_max; i++)
            stats->gc_2nd[i]++;
    }
    else
    {
        quals = stats->quals_1st;
        stats->nreads_1st++;
        for (i=gc_idx_min; i<gc_idx_max; i++)
            stats->gc_1st[i]++;
    }
    if ( stats->trim_qual>0 ) 
        stats->nbases_trimmed += bwa_trim_read(stats->trim_qual, bam_quals, seq_len, reverse);

    // Quality histogram and average quality
    for (i=0; i<seq_len; i++)
    {
        uint8_t qual = bam_quals[ reverse ? seq_len-i-1 : i];
        if ( qual>=stats->nquals )
            error("TODO: quality too high %d>=%d (%s %d %s)\n", qual,stats->nquals,stats->sam->header->target_name[bam_line->core.tid],bam_line->core.pos+1,bam1_qname(bam_line));
        if ( qual>stats->max_qual )
            stats->max_qual = qual;

        quals[ i*stats->nquals+qual ]++;
        stats->sum_qual += qual;
    }

    // Look at the flags and increment appropriate counters (mapped, paired, etc)
    if ( IS_UNMAPPED(bam_line) )
        stats->nreads_unmapped++;
    else
    {
        if ( !bam_line->core.qual )
            stats->nreads_mq0++;

        count_indels(stats,bam_line);

        if ( !IS_PAIRED(bam_line) )
            stats->nreads_unpaired++;
        else 
        {
            stats->nreads_paired++;

            if ( bam_line->core.tid!=bam_line->core.mtid )
                stats->nreads_anomalous++;

            // The insert size is tricky, because for long inserts the libraries are
            // prepared differently and the pairs point in other direction. BWA does
            // not set the paired flag for them.  Similar thing is true also for 454
            // reads. Mates mapped to different chromosomes have isize==0.
            int32_t isize = bam_line->core.isize;
            if ( isize<0 ) isize = -isize;
            if ( isize >= stats->nisize )
                isize = stats->nisize-1;
            if ( isize>0 || bam_line->core.tid==bam_line->core.mtid )
            {
                int pos_fst = bam_line->core.mpos - bam_line->core.pos;
                int is_fst  = IS_READ1(bam_line) ? 1 : -1;
                int is_fwd  = IS_REVERSE(bam_line) ? -1 : 1;
                int is_mfwd = IS_MATE_REVERSE(bam_line) ? -1 : 1;

                if ( is_fwd*is_mfwd>0 )
                    stats->isize_other[isize]++;
                else if ( is_fst*pos_fst>0 )
                {
                    if ( is_fst*is_fwd>0 )
                        stats->isize_inward[isize]++;
                    else
                        stats->isize_outward[isize]++;
                }
                else if ( is_fst*pos_fst<0 )
                {
                    if ( is_fst*is_fwd>0 )
                        stats->isize_outward[isize]++;
                    else
                        stats->isize_inward[isize]++;
                }
            }
        }

        // Number of mismatches 
        uint8_t *nm = bam_aux_get(bam_line,"NM");
        if (nm) 
            stats->nmismatches += bam_aux2i(nm);

        // Number of mapped bases from cigar 
        // Conversion from uint32_t to MIDNSHP
        //  012-4--
        //  MIDNSHP
        if ( bam_line->core.n_cigar == 0) 
            error("FIXME: mapped read with no cigar?\n");
        int readlen=seq_len;
        if ( stats->regions )
        {
            // Count only on-target bases
            int iref = bam_line->core.pos + 1;
            for (i=0; i<bam_line->core.n_cigar; i++)
            {
                int cig  = bam1_cigar(bam_line)[i]&BAM_CIGAR_MASK;
                int ncig = bam1_cigar(bam_line)[i]>>BAM_CIGAR_SHIFT;
                if ( cig==2 ) readlen += ncig;
                else if ( cig==0 ) 
                {
                    if ( iref < stats->reg_from ) ncig -= stats->reg_from-iref;
                    else if ( iref+ncig-1 > stats->reg_to ) ncig -= iref+ncig-1 - stats->reg_to;
                    if ( ncig<0 ) ncig = 0;
                    stats->nbases_mapped_cigar += ncig;
                    iref += bam1_cigar(bam_line)[i]>>BAM_CIGAR_SHIFT;
                }
                else if ( cig==1 )
                {
                    iref += ncig;
                    if ( iref>=stats->reg_from && iref<=stats->reg_to )
                        stats->nbases_mapped_cigar += ncig;
                }
            }
        }
        else
        {
            // Count the whole read
            for (i=0; i<bam_line->core.n_cigar; i++) 
            {
                if ( (bam1_cigar(bam_line)[i]&BAM_CIGAR_MASK)==0 || (bam1_cigar(bam_line)[i]&BAM_CIGAR_MASK)==1 )
                    stats->nbases_mapped_cigar += bam1_cigar(bam_line)[i]>>BAM_CIGAR_SHIFT;
                if ( (bam1_cigar(bam_line)[i]&BAM_CIGAR_MASK)==2 )
                    readlen += bam1_cigar(bam_line)[i]>>BAM_CIGAR_SHIFT;
            }
        }
        stats->nbases_mapped += seq_len;

        if ( stats->tid==bam_line->core.tid && bam_line->core.pos<stats->pos )
            stats->is_sorted = 0;
        stats->pos = bam_line->core.pos;

        if ( stats->is_sorted )
        {
            if ( stats->tid==-1 || stats->tid!=bam_line->core.tid )
                round_buffer_flush(stats,-1);

            // Mismatches per cycle and GC-depth graph. For simplicity, reads overlapping GCD bins
            //  are not splitted which results in up to seq_len-1 overlaps. The default bin size is
            //  20kbp, so the effect is negligible.
            if ( stats->fai )
            {
                int inc_ref = 0, inc_gcd = 0;
                // First pass or new chromosome
                if ( stats->rseq_pos==-1 || stats->tid != bam_line->core.tid ) { inc_ref=1; inc_gcd=1; }
                // Read goes beyond the end of the rseq buffer
                else if ( stats->rseq_pos+stats->nrseq_buf < bam_line->core.pos+readlen ) { inc_ref=1; inc_gcd=1; }
                // Read overlaps the next gcd bin
                else if ( stats->gcd_pos+stats->gcd_bin_size < bam_line->core.pos+readlen ) 
                { 
                    inc_gcd = 1;
                    if ( stats->rseq_pos+stats->nrseq_buf < bam_line->core.pos+stats->gcd_bin_size ) inc_ref = 1;
                }
                if ( inc_gcd )
                {
                    stats->igcd++;
                    if ( stats->igcd >= stats->ngcd )
                        realloc_gcd_buffer(stats, readlen);
                    if ( inc_ref )
                        read_ref_seq(stats,bam_line->core.tid,bam_line->core.pos);
                    stats->gcd_pos = bam_line->core.pos;
                    stats->gcd[ stats->igcd ].gc = fai_gc_content(stats, stats->gcd_pos, stats->gcd_bin_size);
                }

                count_mismatches_per_cycle(stats,bam_line);
            }
            // No reference and first pass, new chromosome or sequence going beyond the end of the gcd bin
            else if ( stats->gcd_pos==-1 || stats->tid != bam_line->core.tid || bam_line->core.pos - stats->gcd_pos > stats->gcd_bin_size )
            {
                // First pass or a new chromosome
                stats->tid     = bam_line->core.tid;
                stats->gcd_pos = bam_line->core.pos;
                stats->igcd++;
                if ( stats->igcd >= stats->ngcd )
                    realloc_gcd_buffer(stats, readlen);
            }
            stats->gcd[ stats->igcd ].depth++;
            // When no reference sequence is given, approximate the GC from the read (much shorter window, but otherwise OK)
            if ( !stats->fai )
                stats->gcd[ stats->igcd ].gc += (float) gc_count / seq_len;

            // Coverage distribution graph
            round_buffer_flush(stats,bam_line->core.pos);
            round_buffer_insert_read(&(stats->cov_rbuf),bam_line->core.pos,bam_line->core.pos+seq_len-1);
        }
    }

    stats->total_len += seq_len;
    if ( IS_DUP(bam_line) )
    {
        stats->total_len_dup += seq_len;
        stats->nreads_dup++;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rbp
movq %rdi, %rbx
cmpq $0x0, 0x1d0(%rsi)
je 0x5724
leaq 0x13fae(%rip), %rsi     # 0x195bf
movq %rbx, %rdi
callq 0x858e
testq %rax, %rax
je 0x575b
movq 0x1d0(%rbp), %rcx
movq %rcx, 0x18(%rsp)
movl (%rcx), %r15d
testl %r15d, %r15d
je 0x5671
leaq 0x1(%rax), %rcx
movq %rcx, 0x20(%rsp)
movsbl (%rcx), %esi
xorl %edi, %edi
movl $0x0, %ecx
testl %esi, %esi
je 0x567b
movb 0x2(%rax), %dl
testb %dl, %dl
je 0x5679
addq $0x3, %rax
movl %esi, %ecx
movl %ecx, %esi
shll $0x5, %esi
subl %ecx, %esi
movsbl %dl, %ecx
addl %esi, %ecx
movb (%rax), %dl
incq %rax
testb %dl, %dl
jne 0x565a
jmp 0x567b
xorl %r14d, %r14d
jmp 0x571f
movl %esi, %ecx
movq %rbx, 0x8(%rsp)
movq %rbp, 0x10(%rsp)
movl %ecx, %eax
xorl %edx, %edx
divl %r15d
movl %edx, %ebx
leal -0x1(%r15), %esi
movl %ecx, %eax
xorl %edx, %edx
divl %esi
incl %edx
movq 0x18(%rsp), %rax
movq 0x10(%rax), %r12
movl %ebx, %r14d
movl %edx, 0x4(%rsp)
movl %r14d, %eax
shrl $0x4, %eax
movl (%r12,%rax,4), %ebp
leal (%r14,%r14), %r13d
andl $0x1e, %r13d
movl %ebp, %eax
movl %r13d, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x5708
testb $0x1, %al
jne 0x56ef
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rax
movl %r14d, %ecx
movq (%rax,%rcx,8), %rdi
movq 0x20(%rsp), %rsi
callq 0x3300
movl 0x4(%rsp), %edx
xorl %edi, %edi
testl %eax, %eax
je 0x5708
addl %edx, %r14d
cmpl %r15d, %r14d
movl %r15d, %eax
cmovbl %edi, %eax
subl %eax, %r14d
cmpl %ebx, %r14d
jne 0x56aa
movl %r15d, %r14d
jmp 0x5715
movl %r13d, %ecx
shrl %cl, %ebp
testb $0x3, %bpl
cmovnel %r15d, %r14d
movq 0x10(%rsp), %rbp
movq 0x8(%rsp), %rbx
cmpl %r15d, %r14d
je 0x575b
movl 0x1b8(%rbp), %ecx
testl %ecx, %ecx
je 0x573f
movl 0xc(%rbx), %eax
andl %ecx, %eax
movzwl %ax, %edx
movl $0xc0, %eax
cmpl %ecx, %edx
jne 0x5756
movl 0x1bc(%rbp), %ecx
testl %ecx, %ecx
je 0x576a
movl 0xc(%rbx), %edx
movl $0xc0, %eax
testw %dx, %cx
je 0x576a
incq (%rbp,%rax)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x5eb7
testl %eax, %eax
je 0x575b
movl 0x1a0(%rbp), %eax
cmpl $-0x1, %eax
je 0x5789
cmpl %eax, 0x10(%rbx)
jne 0x575b
testb $0x2, 0xd(%rbx)
je 0x5796
incq 0x118(%rbp)
testb $0x1, 0xd(%rbx)
je 0x57a3
incq 0x120(%rbp)
movslq 0x10(%rbx), %r15
testq %r15, %r15
je 0x575b
cmpl 0x8(%rbp), %r15d
jl 0x57bd
movq %rbp, %rdi
movl %r15d, %esi
callq 0x5208
cmpl %r15d, 0x90(%rbp)
jge 0x57cd
movl %r15d, 0x90(%rbp)
movq 0x58(%rbp), %rax
incq (%rax,%r15,8)
movq 0x8(%rbx), %rax
movq %rax, %rdi
shrq $0x20, %rdi
testl %r15d, %r15d
jle 0x5883
movq %rax, %rcx
shrq $0x30, %rcx
shlq $0x2, %rcx
addq 0x30(%rbx), %rcx
shrl $0x18, %eax
addq %rcx, %rax
movl 0x8(%rbp), %edx
shll $0x2, %edx
leal -0x1(%r15), %esi
xorl %r8d, %r8d
movl $0x3, %r9d
xorl %r13d, %r13d
xorl %r10d, %r10d
movl %r10d, %ecx
shrl %ecx
movzbl (%rax,%rcx), %r11d
movl %r8d, %ecx
notb %cl
andb $0x4, %cl
shrl %cl, %r11d
shrb %r11b
andb $0x7, %r11b
leal -0x1(%r11), %ecx
cmpb $0x1, %cl
ja 0x5841
incl %r13d
jmp 0x5850
cmpb $0x3, %r11b
movzbl %r11b, %ecx
cmovael %r9d, %ecx
movl %ecx, %r11d
testb $0x10, %dil
movl %esi, %ecx
cmovel %r10d, %ecx
movzbl %r11b, %r11d
leal (%r11,%rcx,4), %ecx
cmpl %edx, %ecx
jge 0x5e71
movq 0x50(%rbp), %r11
movslq %ecx, %rcx
incq (%r11,%rcx,8)
incl %r10d
addl $0x4, %r8d
addl $-0x1, %esi
jb 0x5817
jmp 0x5886
xorl %r13d, %r13d
movl 0x10(%rbp), %r8d
leal -0x1(%r8), %esi
movl %esi, %eax
imull %r13d, %eax
cltd
idivl %r15d
movl %eax, %ecx
leal 0x1(%r13), %eax
imull %esi, %eax
cltd
idivl %r15d
cmpl %r8d, %eax
cmovll %eax, %esi
movq 0x8(%rbx), %r8
movq %r8, %rax
shrq $0x30, %rax
shlq $0x2, %rax
movl %r8d, %r9d
shrl $0x18, %r9d
movl 0x10(%rbx), %edx
incl %edx
sarl %edx
movslq %edx, %rdx
addq %r9, %rdx
addq 0x30(%rbx), %rax
btq $0x27, %r8
jb 0x5900
incq 0xb0(%rbp)
movq 0x18(%rbp), %r8
cmpl %esi, %ecx
jge 0x5925
movq 0x28(%rbp), %r9
movslq %ecx, %rcx
movslq %esi, %rsi
incq (%r9,%rcx,8)
incq %rcx
cmpq %rcx, %rsi
jne 0x58f2
jmp 0x5925
incq 0xb8(%rbp)
movq 0x20(%rbp), %r8
cmpl %esi, %ecx
jge 0x5925
movq 0x30(%rbp), %r9
movslq %ecx, %rcx
movslq %esi, %rsi
incq (%r9,%rcx,8)
incq %rcx
cmpq %rcx, %rsi
jne 0x5919
addq %rdx, %rax
movl (%rbp), %edx
testl %edx, %edx
jle 0x5990
xorl %ecx, %ecx
cmpl $0x23, %r15d
jl 0x5989
movq %rbx, %r12
movq %rbp, %r14
leal -0x1(%r15), %esi
xorl %r9d, %r9d
xorl %r11d, %r11d
xorl %r10d, %r10d
movl %r11d, %ebx
testb $0x10, %dil
movl %r10d, %r11d
cmovel %esi, %r11d
movslq %r11d, %r11
movzbl (%rax,%r11), %ebp
movl %edx, %r11d
subl %ebp, %r11d
addl %ebx, %r11d
js 0x5980
cmpl %r9d, %r11d
cmovgl %r11d, %r9d
cmovgl %r10d, %ecx
incl %r10d
decl %esi
cmpl $0x21, %esi
jne 0x594a
movslq %ecx, %rcx
movq %r14, %rbp
movq %r12, %rbx
addq %rcx, 0x108(%rbp)
testl %r15d, %r15d
jle 0x59f7
movl 0x4(%rbp), %edx
leal -0x1(%r15), %ecx
xorl %r9d, %r9d
testb $0x10, %dil
movl %ecx, %esi
cmovel %r9d, %esi
movslq %esi, %rsi
movzbl (%rax,%rsi), %esi
cmpl %esi, %edx
jle 0x5e7f
cmpl %esi, 0x94(%rbp)
jge 0x59c6
movl %esi, 0x94(%rbp)
movslq 0x4(%rbp), %r10
movslq %r9d, %r9
imulq %r9, %r10
addq %rsi, %r10
incq (%r8,%r10,8)
xorps %xmm0, %xmm0
cvtsi2sd %esi, %xmm0
addsd 0x1c0(%rbp), %xmm0
movsd %xmm0, 0x1c0(%rbp)
incl %r9d
addl $-0x1, %ecx
jb 0x599f
movq 0x8(%rbx), %rax
btq $0x22, %rax
jb 0x5aad
testl $0xff0000, %eax         # imm = 0xFF0000
jne 0x5a14
incq 0xf0(%rbp)
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x4905
movabsq $0xd00000000, %rax      # imm = 0xD00000000
andq 0x8(%rbx), %rax
movabsq $0x100000000, %rcx      # imm = 0x100000000
cmpq %rcx, %rax
jne 0x5ab9
incq 0xe0(%rbp)
movl (%rbx), %ecx
movl 0x14(%rbx), %edx
cmpl %edx, %ecx
je 0x5a53
incq 0xe8(%rbp)
movl 0x1c(%rbx), %eax
movl %eax, %esi
negl %esi
cmovsl %eax, %esi
movl 0xc(%rbp), %edi
leal -0x1(%rdi), %eax
cmpl %edi, %esi
cmovll %esi, %eax
cmpl %edx, %ecx
je 0x5a70
testl %eax, %eax
jle 0x5ac3
movl 0xc(%rbx), %esi
movl %esi, %ecx
andl $0x40, %ecx
xorl %edx, %edx
cmpl $0x1, %ecx
movl $0x0, %ecx
sbbl %ecx, %ecx
testb $0x10, %sil
sete %dil
btl $0x4, %esi
sbbl %edx, %edx
andl $0x20, %esi
shrl $0x5, %esi
cmpb %sil, %dil
je 0x5e2c
cltq
shlq $0x3, %rax
addq 0x48(%rbp), %rax
jmp 0x5ac0
incq 0xd0(%rbp)
jmp 0x5e0a
leaq 0xd8(%rbp), %rax
incq (%rax)
leaq 0x13b0c(%rip), %rsi     # 0x195d6
movq %rbx, %rdi
callq 0x858e
testq %rax, %rax
je 0x5ae8
movq %rax, %rdi
callq 0x934b
cltq
addq %rax, 0x110(%rbp)
cmpw $0x0, 0xe(%rbx)
je 0x5eae
movabsq $0x1000000000000, %rax  # imm = 0x1000000000000
cmpq $0x0, 0x1b0(%rbp)
movq 0x8(%rbx), %rdi
movl %r15d, %r12d
je 0x5bd1
cmpq %rax, %rdi
jb 0x5c2a
movl 0x4(%rbx), %eax
incl %eax
movq 0x30(%rbx), %rcx
xorl %edx, %edx
xorl %esi, %esi
movl %r15d, %r12d
shrl $0x18, %edi
movl (%rcx,%rdi), %r8d
movl %r8d, %edi
shrl $0x4, %edi
andl $0xf, %r8d
je 0x5b6d
cmpl $0x1, %r8d
je 0x5b52
cmpl $0x2, %r8d
jne 0x5bb4
addl %r12d, %edi
movl %edi, %r12d
jmp 0x5bb4
addl %edi, %eax
cmpl 0x1a8(%rbp), %eax
jl 0x5bb4
cmpl 0x1ac(%rbp), %eax
jg 0x5bb4
addq %rdi, 0x100(%rbp)
jmp 0x5bb4
movl 0x1a8(%rbp), %r8d
cmpl %r8d, %eax
jge 0x5b80
addl %eax, %edi
subl %r8d, %edi
jmp 0x5b9c
leal (%rax,%rdi), %r9d
decl %r9d
movl 0x1ac(%rbp), %r8d
cmpl %r8d, %r9d
jle 0x5b9c
subl %eax, %r8d
incl %r8d
movl %r8d, %edi
testl %edi, %edi
cmovlel %edx, %edi
addq %rdi, 0x100(%rbp)
movzbl 0xb(%rbx), %edi
movl (%rcx,%rdi), %edi
shrl $0x4, %edi
addl %edi, %eax
incq %rsi
movq 0x8(%rbx), %rdi
movq %rdi, %r8
shrq $0x30, %r8
addq $0x4, %rcx
cmpq %r8, %rsi
jb 0x5b2b
jmp 0x5c2a
cmpq %rax, %rdi
jb 0x5c2a
movq 0x30(%rbx), %rax
xorl %ecx, %ecx
xorl %edx, %edx
movl %r15d, %r12d
shrl $0x18, %edi
movl (%rax,%rdi), %esi
testb $0xe, %sil
jne 0x5bf7
shrl $0x4, %esi
addq %rsi, 0x100(%rbp)
movq 0x8(%rbx), %rdi
movl %edi, %esi
shrl $0x18, %esi
movl (%rax,%rsi), %esi
movl %esi, %r8d
andl $0xf, %r8d
shrl $0x4, %esi
cmpl $0x2, %r8d
cmovnel %ecx, %esi
addl %esi, %r12d
incq %rdx
movq %rdi, %rsi
shrq $0x30, %rsi
addq $0x4, %rax
cmpq %rsi, %rdx
jb 0x5be1
addq %r15, 0xf8(%rbp)
movl 0x140(%rbp), %eax
movl (%rbx), %ecx
cmpl %ecx, %eax
jne 0x5c52
movl 0x4(%rbx), %edx
cmpl 0x148(%rbp), %edx
jge 0x5c52
movl $0x0, 0x9c(%rbp)
movl 0x4(%rbx), %edx
movl %edx, 0x148(%rbp)
cmpl $0x0, 0x9c(%rbp)
je 0x5e0a
cmpl %ecx, %eax
sete %cl
cmpl $-0x1, %eax
setne %al
testb %cl, %al
jne 0x5c86
movq %rbp, %rdi
movq $-0x1, %rsi
callq 0x44bc
cmpq $0x0, 0x1d8(%rbp)
je 0x5d5b
movl 0x18c(%rbp), %eax
cmpl $-0x1, %eax
je 0x5cdf
movl 0x140(%rbp), %ecx
cmpl (%rbx), %ecx
jne 0x5cdf
addl 0x190(%rbp), %eax
movq %rbx, %r14
movl 0x4(%rbx), %ecx
leal (%rcx,%r12), %edi
cmpl %edi, %eax
jl 0x5ce2
movl 0x138(%rbp), %esi
movl 0x144(%rbp), %r8d
addl %esi, %r8d
movb $0x1, %bl
movb $0x1, %dl
cmpl %edi, %r8d
jge 0x5ce6
addl %ecx, %esi
cmpl %esi, %eax
setge %bl
jmp 0x5ce4
movq %rbx, %r14
xorl %ebx, %ebx
xorl %edx, %edx
testb %dl, %dl
jne 0x5d4b
movl 0x12c(%rbp), %eax
incl %eax
movl %eax, 0x12c(%rbp)
cmpl 0x128(%rbp), %eax
jb 0x5d0b
movq %rbp, %rdi
movl %r12d, %esi
callq 0x5150
testb %bl, %bl
movq %r14, %rbx
jne 0x5d1f
movl (%rbx), %esi
movl 0x4(%rbx), %edx
movq %rbp, %rdi
callq 0x4d95
movq %rbx, %r14
movl 0x4(%rbx), %esi
movl %esi, 0x144(%rbp)
movl 0x138(%rbp), %edx
movq %rbp, %rdi
callq 0x506f
movq 0x130(%rbp), %rax
movl 0x12c(%rbp), %ecx
movss %xmm0, (%rax,%rcx,8)
movq %rbp, %rdi
movq %r14, %rbx
movq %r14, %rsi
callq 0x4a91
jmp 0x5daf
movl 0x144(%rbp), %eax
cmpl $-0x1, %eax
je 0x5d7d
movl 0x140(%rbp), %ecx
cmpl (%rbx), %ecx
jne 0x5d7d
movl 0x4(%rbx), %ecx
subl %eax, %ecx
cmpl 0x138(%rbp), %ecx
jle 0x5daf
movl (%rbx), %eax
movl %eax, 0x140(%rbp)
movl 0x4(%rbx), %eax
movl %eax, 0x144(%rbp)
movl 0x12c(%rbp), %eax
incl %eax
movl %eax, 0x12c(%rbp)
cmpl 0x128(%rbp), %eax
jb 0x5daf
movq %rbp, %rdi
movl %r12d, %esi
callq 0x5150
movq 0x130(%rbp), %rax
movl 0x12c(%rbp), %ecx
incl 0x4(%rax,%rcx,8)
cmpq $0x0, 0x1d8(%rbp)
jne 0x5de5
xorps %xmm0, %xmm0
cvtsi2ss %r13d, %xmm0
cvtsi2ss %r15d, %xmm1
divss %xmm1, %xmm0
addss (%rax,%rcx,8), %xmm0
movss %xmm0, (%rax,%rcx,8)
movslq 0x4(%rbx), %rsi
movq %rbp, %rdi
callq 0x44bc
leaq 0x168(%rbp), %rdi
movslq 0x4(%rbx), %rsi
leal (%r15,%rsi), %eax
decl %eax
movslq %eax, %rdx
callq 0x47fa
addq %r15, 0xa0(%rbp)
testb $0x4, 0xd(%rbx)
je 0x575b
addq %r15, 0xa8(%rbp)
movl $0xc8, %eax
jmp 0x5756
orl $0x1, %ecx
orl $0x1, %edx
movl 0x18(%rbx), %esi
subl 0x4(%rbx), %esi
imull %ecx, %esi
testl %esi, %esi
jle 0x5e55
imull %edx, %ecx
cltq
testl %ecx, %ecx
jle 0x5e64
shlq $0x3, %rax
addq 0x38(%rbp), %rax
jmp 0x5ac0
jns 0x5ac3
imull %edx, %ecx
cltq
testl %ecx, %ecx
jle 0x5e48
shlq $0x3, %rax
addq 0x40(%rbp), %rax
jmp 0x5ac0
leaq 0x1374a(%rip), %rdi     # 0x195c2
xorl %eax, %eax
callq 0x465a
movq 0x1c8(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
movslq (%rbx), %rcx
movq (%rax,%rcx,8), %rcx
movl 0x4(%rbx), %r8d
incl %r8d
movq 0x30(%rbx), %r9
leaq 0x13458(%rip), %rdi     # 0x192ff
xorl %eax, %eax
callq 0x465a
leaq 0x13724(%rip), %rdi     # 0x195d9
jmp 0x5e78