// File: /workspace/github_c_makefile_star2_O3/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 %rdi, 0x8(%rsp)
movq %rsi, (%rsp)
cmpq $0x0, 0x1d0(%rsi)
je 0x5959
leaq 0x14e18(%rip), %rsi     # 0x1a66f
movq 0x8(%rsp), %rdi
callq 0x8974
testq %rax, %rax
je 0x5998
movq (%rsp), %rcx
movq 0x1d0(%rcx), %rcx
movq %rcx, 0x18(%rsp)
movl (%rcx), %r14d
testl %r14d, %r14d
je 0x58bd
leaq 0x1(%rax), %rcx
movq %rcx, 0x20(%rsp)
movsbl (%rcx), %esi
xorl %edi, %edi
movl $0x0, %ecx
testl %esi, %esi
je 0x58c7
movb 0x2(%rax), %dl
testb %dl, %dl
je 0x58c5
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 0x58a6
jmp 0x58c7
xorl %r15d, %r15d
jmp 0x5954
movl %esi, %ecx
movl %ecx, %eax
xorl %edx, %edx
divl %r14d
movl %edx, %ebx
leal -0x1(%r14), %esi
movl %ecx, %eax
xorl %edx, %edx
divl %esi
incl %edx
movq 0x18(%rsp), %rax
movq 0x10(%rax), %r12
movl %ebx, %r15d
movl %edx, 0x14(%rsp)
movl %r15d, %eax
shrl $0x4, %eax
movl (%r12,%rax,4), %ebp
leal (%r15,%r15), %r13d
andl $0x1e, %r13d
movl %ebp, %eax
movl %r13d, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x5947
testb $0x1, %al
jne 0x5931
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rax
movl %r15d, %ecx
movq (%rax,%rcx,8), %rdi
movq 0x20(%rsp), %rsi
callq 0x3300
movl 0x14(%rsp), %edx
xorl %edi, %edi
testl %eax, %eax
je 0x5947
addl %edx, %r15d
cmpl %r14d, %r15d
movl %r14d, %eax
cmovbl %edi, %eax
subl %eax, %r15d
cmpl %ebx, %r15d
jne 0x58ec
jmp 0x5998
movl %r13d, %ecx
shrl %cl, %ebp
testb $0x3, %bpl
cmovnel %r14d, %r15d
cmpl %r14d, %r15d
je 0x5998
movq (%rsp), %rsi
movl 0x1b8(%rsi), %ecx
testl %ecx, %ecx
movq 0x8(%rsp), %rdi
je 0x597d
movl 0xc(%rdi), %eax
andl %ecx, %eax
movzwl %ax, %edx
movl $0xc0, %eax
cmpl %ecx, %edx
jne 0x5994
movl 0x1bc(%rsi), %ecx
testl %ecx, %ecx
je 0x59a7
movl 0xc(%rdi), %edx
movl $0xc0, %eax
testw %dx, %cx
je 0x59a7
incq (%rsi,%rax)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x6130
testl %eax, %eax
je 0x5998
movq (%rsp), %rax
movl 0x1a0(%rax), %eax
cmpl $-0x1, %eax
je 0x59c9
movq 0x8(%rsp), %rcx
cmpl %eax, 0x10(%rcx)
jne 0x5998
movq 0x8(%rsp), %rdx
movq 0x8(%rdx), %rax
btq $0x29, %rax
movq (%rsp), %rcx
jae 0x59e8
incq 0x118(%rcx)
movq 0x8(%rdx), %rax
btq $0x28, %rax
jae 0x59f6
incq 0x120(%rcx)
movslq 0x10(%rdx), %r15
testq %r15, %r15
je 0x5998
movq (%rsp), %r14
cmpl 0x8(%r14), %r15d
jl 0x5a14
movq %r14, %rdi
movl %r15d, %esi
callq 0x5484
cmpl %r15d, 0x90(%r14)
movq 0x8(%rsp), %rbp
jge 0x5a29
movl %r15d, 0x90(%r14)
movq 0x58(%r14), %rax
incq (%rax,%r15,8)
movq 0x8(%rbp), %rsi
movq 0x30(%rbp), %r9
movq %rsi, %r10
shrq $0x30, %r10
movl %esi, %r8d
shrl $0x18, %r8d
movq %rsi, %rdi
shrq $0x20, %rdi
testl %r15d, %r15d
jle 0x5af0
leaq (%r9,%r10,4), %rax
addq %r8, %rax
movl 0x8(%r14), %edx
shll $0x2, %edx
leal -0x1(%r15), %esi
xorl %r8d, %r8d
movl $0x3, %r10d
xorl %r13d, %r13d
xorl %r11d, %r11d
movl %r11d, %ecx
shrl %ecx
movzbl (%rax,%rcx), %ebx
movl %r8d, %ecx
notb %cl
andb $0x4, %cl
shrl %cl, %ebx
shrb %bl
andb $0x7, %bl
leal -0x1(%rbx), %ecx
cmpb $0x1, %cl
ja 0x5a9d
incl %r13d
jmp 0x5aa9
cmpb $0x3, %bl
movzbl %bl, %ecx
cmovael %r10d, %ecx
movl %ecx, %ebx
testb $0x10, %dil
movl %esi, %ecx
cmovel %r11d, %ecx
movzbl %bl, %ebx
leal (%rbx,%rcx,4), %ecx
cmpl %edx, %ecx
jge 0x60ed
movq 0x50(%r14), %rbx
movslq %ecx, %rcx
incq (%rbx,%rcx,8)
incl %r11d
addl $0x4, %r8d
addl $-0x1, %esi
jb 0x5a78
movq 0x8(%rbp), %rsi
movq %rsi, %r10
shrq $0x2e, %r10
andl $-0x4, %r10d
movl %esi, %r8d
shrl $0x18, %r8d
jmp 0x5af7
shlq $0x2, %r10
xorl %r13d, %r13d
movl 0x10(%r14), %ebx
leal -0x1(%rbx), %r11d
movl %r11d, %eax
imull %r13d, %eax
cltd
idivl %r15d
movl %eax, %ecx
leal 0x1(%r13), %eax
imull %r11d, %eax
cltd
idivl %r15d
cmpl %ebx, %eax
cmovll %eax, %r11d
addq %r9, %r8
addq %r10, %r8
movl 0x10(%rbp), %eax
incl %eax
sarl %eax
movslq %eax, %rdx
btq $0x27, %rsi
jb 0x5b5d
incq 0xb0(%r14)
movq 0x18(%r14), %rax
cmpl %r11d, %ecx
jge 0x5b83
movq 0x28(%r14), %rsi
movslq %ecx, %rcx
movslq %r11d, %r10
incq (%rsi,%rcx,8)
incq %rcx
cmpq %rcx, %r10
jne 0x5b4f
jmp 0x5b83
incq 0xb8(%r14)
movq 0x20(%r14), %rax
cmpl %r11d, %ecx
jge 0x5b83
movq 0x30(%r14), %rsi
movslq %ecx, %rcx
movslq %r11d, %r10
incq (%rsi,%rcx,8)
incq %rcx
cmpq %rcx, %r10
jne 0x5b77
addq %rdx, %r8
movl (%r14), %edx
testl %edx, %edx
jle 0x5be6
xorl %ecx, %ecx
cmpl $0x23, %r15d
jl 0x5bdf
leal -0x1(%r15), %esi
xorl %r10d, %r10d
xorl %ebx, %ebx
xorl %r11d, %r11d
movl %ebx, %ebp
testb $0x10, %dil
movl %r11d, %ebx
cmovel %esi, %ebx
movslq %ebx, %rbx
movzbl (%r8,%rbx), %r14d
movl %edx, %ebx
subl %r14d, %ebx
addl %ebp, %ebx
js 0x5bd3
cmpl %r10d, %ebx
cmovgl %ebx, %r10d
cmovgl %r11d, %ecx
incl %r11d
decl %esi
cmpl $0x21, %esi
jne 0x5ba1
movslq %ecx, %rcx
movq (%rsp), %r14
movq 0x8(%rsp), %rbp
addq %rcx, 0x108(%r14)
testl %r15d, %r15d
jle 0x5c52
movl 0x4(%r14), %edx
leal -0x1(%r15), %ecx
xorl %r10d, %r10d
xorl %r11d, %r11d
testb $0x10, %dil
movl %ecx, %esi
cmovel %r11d, %esi
movslq %esi, %rsi
movzbl (%r8,%rsi), %esi
cmpl %esi, %edx
jle 0x60fb
cmpl %esi, 0x94(%r14)
jge 0x5c23
movl %esi, 0x94(%r14)
leal (%r10,%rsi), %ebx
movslq %ebx, %rbx
incq (%rax,%rbx,8)
xorps %xmm0, %xmm0
cvtsi2sd %esi, %xmm0
addsd 0x1c0(%r14), %xmm0
movsd %xmm0, 0x1c0(%r14)
incl %r11d
addl %edx, %r10d
addl $-0x1, %ecx
jb 0x5bf9
movq 0x8(%rbp), %rax
btq $0x22, %rax
jb 0x5d0a
testl $0xff0000, %eax         # imm = 0xFF0000
jne 0x5c6f
incq 0xf0(%r14)
movq %r14, %rdi
movq %rbp, %rsi
callq 0x4bc6
movabsq $0xd00000000, %rax      # imm = 0xD00000000
andq 0x8(%rbp), %rax
movabsq $0x100000000, %rcx      # imm = 0x100000000
cmpq %rcx, %rax
jne 0x5d16
incq 0xe0(%r14)
movl (%rbp), %ecx
movl 0x14(%rbp), %edx
cmpl %edx, %ecx
je 0x5caf
incq 0xe8(%r14)
movl 0x1c(%rbp), %eax
movl %eax, %esi
negl %esi
cmovsl %eax, %esi
movl 0xc(%r14), %edi
leal -0x1(%rdi), %eax
cmpl %edi, %esi
cmovll %esi, %eax
cmpl %edx, %ecx
je 0x5ccd
testl %eax, %eax
jle 0x5d20
movl 0xc(%rbp), %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 0x5fc1
cltq
shlq $0x3, %rax
addq 0x48(%r14), %rax
jmp 0x5d1d
incq 0xd0(%r14)
jmp 0x6083
leaq 0xd8(%r14), %rax
incq (%rax)
leaq 0x1495f(%rip), %rsi     # 0x1a686
movq %rbp, %rdi
callq 0x8974
testq %rax, %rax
je 0x5d45
movq %rax, %rdi
callq 0x99b4
cltq
addq %rax, 0x110(%r14)
movq 0x8(%rbp), %rax
movq %rax, %rcx
shrq $0x30, %rcx
je 0x6127
cmpq $0x0, 0x1b0(%r14)
je 0x5e2c
movl 0x4(%rbp), %ecx
incl %ecx
movq 0x30(%rbp), %rdx
xorl %esi, %esi
xorl %edi, %edi
movl %r15d, %r12d
movl %eax, %r8d
shrl $0x18, %r8d
movl (%rdx,%r8), %r9d
movl %r9d, %r8d
shrl $0x4, %r8d
andl $0xf, %r9d
je 0x5dc2
cmpl $0x1, %r9d
je 0x5da0
cmpl $0x2, %r9d
jne 0x5e13
addl %r12d, %r8d
movl %r8d, %r12d
jmp 0x5e13
addl %r8d, %ecx
cmpl 0x1a8(%r14), %ecx
jl 0x5e13
cmpl 0x1ac(%r14), %ecx
jg 0x5e13
addq %r8, 0x100(%r14)
movq 0x8(%rbp), %rax
jmp 0x5e13
movl 0x1a8(%r14), %eax
cmpl %eax, %ecx
jge 0x5dd5
addl %ecx, %r8d
subl %eax, %r8d
jmp 0x5def
leal (%rcx,%r8), %r9d
decl %r9d
movl 0x1ac(%r14), %eax
cmpl %eax, %r9d
jle 0x5def
subl %ecx, %eax
incl %eax
movl %eax, %r8d
testl %r8d, %r8d
cmovlel %esi, %r8d
addq %r8, 0x100(%r14)
movq 0x8(%rbp), %rax
movl %eax, %r8d
shrl $0x18, %r8d
movl (%rdx,%r8), %r8d
shrl $0x4, %r8d
addl %r8d, %ecx
incq %rdi
movq %rax, %r8
shrq $0x30, %r8
addq $0x4, %rdx
cmpq %r8, %rdi
jb 0x5d74
jmp 0x5e84
movq 0x30(%rbp), %rcx
xorl %edx, %edx
xorl %esi, %esi
movl %r15d, %r12d
movl %eax, %edi
shrl $0x18, %edi
movl (%rcx,%rdi), %r8d
testb $0xe, %r8b
jne 0x5e5a
shrl $0x4, %r8d
addq %r8, 0x100(%r14)
movq 0x8(%rbp), %rax
movl %eax, %edi
shrl $0x18, %edi
movl (%rcx,%rdi), %edi
movl %edi, %r8d
andl $0xf, %r8d
shrl $0x4, %edi
cmpl $0x2, %r8d
cmovnel %edx, %edi
addl %edi, %r12d
incq %rsi
movq %rax, %rdi
shrq $0x30, %rdi
addq $0x4, %rcx
cmpq %rdi, %rsi
jb 0x5e37
addq %r15, 0xf8(%r14)
movl 0x140(%r14), %eax
movl (%rbp), %ecx
movl 0x4(%rbp), %edx
cmpl %ecx, %eax
jne 0x5eb0
cmpl 0x148(%r14), %edx
jge 0x5eb0
movl $0x0, 0x9c(%r14)
movl %edx, 0x148(%r14)
cmpl $0x0, 0x9c(%r14)
je 0x6083
cmpl %ecx, %eax
sete %cl
cmpl $-0x1, %eax
setne %al
testb %cl, %al
jne 0x5ee3
movq %r14, %rdi
movq $-0x1, %rsi
callq 0x478c
cmpq $0x0, 0x1d8(%r14)
je 0x5f97
movl 0x18c(%r14), %eax
cmpl $-0x1, %eax
je 0x5f1f
movl 0x140(%r14), %ecx
cmpl (%rbp), %ecx
jne 0x5f1f
addl 0x190(%r14), %eax
movl 0x4(%rbp), %ecx
leal (%rcx,%r12), %esi
cmpl %esi, %eax
jge 0x60a9
xorl %ebx, %ebx
movl 0x12c(%r14), %eax
incl %eax
movl %eax, 0x12c(%r14)
cmpl 0x128(%r14), %eax
jb 0x5f45
movq %r14, %rdi
movl %r12d, %esi
callq 0x53df
movl 0x4(%rbp), %eax
testb %bl, %bl
jne 0x5f5c
movl (%rbp), %esi
movq %r14, %rdi
movl %eax, %edx
callq 0x505c
movl 0x4(%rbp), %eax
movl %eax, 0x144(%r14)
movl 0x138(%r14), %edx
movq %r14, %rdi
movl %eax, %esi
callq 0x5309
movq 0x130(%r14), %rax
movl 0x12c(%r14), %ecx
movss %xmm0, (%rax,%rcx,8)
movq %r14, %rdi
movq %rbp, %rsi
callq 0x4d3e
jmp 0x6027
movl 0x144(%r14), %edx
movl (%rbp), %eax
cmpl $-0x1, %edx
je 0x5ff2
movl 0x4(%rbp), %ecx
cmpl %eax, 0x140(%r14)
jne 0x5ff5
movl %ecx, %esi
subl %edx, %esi
cmpl 0x138(%r14), %esi
jg 0x5ff5
jmp 0x6027
orl $0x1, %ecx
orl $0x1, %edx
movl 0x18(%rbp), %esi
subl 0x4(%rbp), %esi
imull %ecx, %esi
testl %esi, %esi
jle 0x60cd
imull %edx, %ecx
cltq
testl %ecx, %ecx
jle 0x60e0
shlq $0x3, %rax
addq 0x38(%r14), %rax
jmp 0x5d1d
movl 0x4(%rbp), %ecx
movl %eax, 0x140(%r14)
movl %ecx, 0x144(%r14)
movl 0x12c(%r14), %eax
incl %eax
movl %eax, 0x12c(%r14)
cmpl 0x128(%r14), %eax
jb 0x6027
movq %r14, %rdi
movl %r12d, %esi
callq 0x53df
movq 0x130(%r14), %rax
movl 0x12c(%r14), %ecx
incl 0x4(%rax,%rcx,8)
cmpq $0x0, 0x1d8(%r14)
jne 0x605e
xorps %xmm0, %xmm0
cvtsi2ss %r13d, %xmm0
cvtsi2ss %r15d, %xmm1
divss %xmm1, %xmm0
addss (%rax,%rcx,8), %xmm0
movss %xmm0, (%rax,%rcx,8)
movslq 0x4(%rbp), %rsi
movq %r14, %rdi
callq 0x478c
leaq 0x168(%r14), %rdi
movslq 0x4(%rbp), %rsi
leal (%r15,%rsi), %eax
decl %eax
movslq %eax, %rdx
callq 0x4ac6
addq %r15, 0xa0(%r14)
testb $0x4, 0xd(%rbp)
je 0x5998
movq (%rsp), %rsi
addq %r15, 0xa8(%rsi)
movl $0xc8, %eax
jmp 0x5994
movl 0x138(%r14), %edx
movl 0x144(%r14), %edi
addl %edx, %edi
cmpl %esi, %edi
jge 0x5f87
addl %ecx, %edx
cmpl %edx, %eax
setge %bl
jmp 0x5f21
jns 0x5d20
imull %edx, %ecx
cltq
testl %ecx, %ecx
jle 0x5fe5
shlq $0x3, %rax
addq 0x40(%r14), %rax
jmp 0x5d1d
leaq 0x1457e(%rip), %rdi     # 0x1a672
xorl %eax, %eax
callq 0x4926
movq 0x1c8(%r14), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
movslq (%rbp), %rcx
movq (%rax,%rcx,8), %rcx
movl 0x4(%rbp), %r8d
incl %r8d
leaq 0x1428f(%rip), %rdi     # 0x1a3af
xorl %eax, %eax
callq 0x4926
leaq 0x1455b(%rip), %rdi     # 0x1a689
jmp 0x60f4