// File: /workspace/github_c_makefile_star2_O3/skoren[P]bacValidation/samToErrorRate.C
// Function: main
int
main (int argc, char **argv) {
    map<string, string> reference;
    // loadFasta
    FILE *in = fopen(argv[2], "r");
    gzFile f = gzdopen(fileno(in), "r");
    kseq_t *seq = kseq_init(f);
    int l = 0;
    while ((l=kseq_read(seq)) >= 0) {
       reference[seq->name.s] = seq->seq.s;
       string name = seq->name.s;
       name.append("rc");
       reference[name] = rc(seq->seq.s, strlen(seq->seq.s));
    }
    kseq_destroy(seq);
    gzclose(f);
    fclose(in);

    bam1_t *b = bam_init1();
    samfile_t * fp = open_alignment_file(argv[1]);
    if (fp == NULL) {
        exit(1);
    }
    bam_header_t* head = fp->header; // sam header
    while (samread(fp, b) >= 0) {
        //Get bam core.
        const bam1_core_t *core = &b->core;
        if (core == NULL) {
            printf("Input file is corrupt!");
            exit(1);
        }
        if (!is_mapped(core)) {
            continue;
        }

        string id = bam1_qname(b);
        string ref = head->target_name[core->tid];
        uint32_t* cigar = bam1_cigar(b);
        uint32_t refLen = head->target_len[core->tid];
        uint32_t refLo = core->pos + 1;
        uint32_t refHigh = bam_calend(core, cigar);
        uint32_t seqLow = 0;
        uint32_t seqHi = core->l_qseq; 
        uint32_t seqLen = core->l_qseq;
        bool isFwd = !(core->flag & BAM_FREVERSE);

        // now parse, we need both sequecnes for this
        if (strlen(reference[ref].c_str()) <= 0) { 
           fprintf(stderr, "Error: unknown reference sequence %s", ref.c_str());
           exit(1);
        }
        char *refSeq = (char*)reference[ref].c_str()+refLo-1;
        char *qrySeq = new char[core->l_qseq+1];
        char *orig = qrySeq;
        for (int i = 0; i < core->l_qseq; i++) {
          qrySeq[i] = bam_nt16_rev_table[bam1_seqi(bam1_seq(b), i)];
        }
        qrySeq[core->l_qseq]='\0';
        int errors = 0;
        int matches = 0;
        int indels = 0;
        uint32_t len = 0;
        for (int k = 0; k < core->n_cigar; ++k) {
            int cop = cigar[k] & BAM_CIGAR_MASK; // operation
            int cl = cigar[k] >> BAM_CIGAR_SHIFT; // length
            switch (cop) {
            // we don't care about clipping, not part of length
            case BAM_CSOFT_CLIP:
                 if (k == 0) seqLow+=cl;
                 else seqHi-=cl;
                 qrySeq+=cl;
                 break;
            case BAM_CHARD_CLIP:
                 if (k == 0) seqLow+=cl;
                 else seqHi-=cl;
                 seqLen+=cl;
                 seqHi+=cl;
                 break;
            // we don't care about matches either, not an error
            case BAM_CMATCH:
            case BAM_CEQUAL:
            case BAM_CDIFF: 
              for (int i = 0; i < cl; i++) {
                 if (toupper(*refSeq) == toupper(*qrySeq)) {
                    matches++;
                 } else {
                    errors++;
                 }
                 refSeq++;
                 qrySeq++;
             }
             len+=cl;
             break;
            case BAM_CINS:
               errors+=cl;
               indels+=cl;
               qrySeq+=cl;
               len+=cl;
               break;
            case BAM_CREF_SKIP:
               refSeq+=cl;
               len+=cl;
               break;
            case BAM_CDEL:
               errors+=cl;
               indels+=cl;
               refSeq+=cl;
               len+=cl;
               break;
            default:
                cerr << "Error: unknown base " << cop << " of len " << cl << endl;
                exit(1);
                break;
            }
        }

        double idy = (1-((double) errors / len /*(seqHi-seqLow)*/ /*(refHigh - refLo + 1)*/)) * 100;
        double idyMismatches =  (1-((double) (errors-indels) / len /*(seqHi-seqLow)*/ /*(refHigh - refLo + 1)*/)) * 100;
        cout << id << "\t" << ref << "\t" << int(ceil(-1*idy/100*len)) << "\t" << idy << "\t0\t" << (isFwd == true ? seqLow : seqLen-seqHi) << "\t" << (isFwd == true ? seqHi : seqLen-seqLow) << "\t" << seqLen << "\t" <<  (isFwd == true ? 0 : 1) << "\t" << (isFwd == true ? refLo : refLen-refHigh) << "\t" << (isFwd == true ? refHigh : refLen-refLo) << "\t" << refLen << "\t" << len << "\t" << (seqHi-seqLow) << "\t" << (refHigh-refLo) << "\t" << matches << "\t" << errors << "\t" << idyMismatches << "\t" << indels << endl;
        delete[] orig;
    }
    samclose(fp);
return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
leaq -0x150(%rbp), %rax
movl $0x0, (%rax)
xorl %ecx, %ecx
movq %rcx, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %rcx, 0x20(%rax)
movq %rsi, -0x80(%rbp)
movq 0x10(%rsi), %rdi
leaq 0x1d98(%rip), %rbx      # 0xc402
movq %rbx, %rsi
callq 0x33a0
movq %rax, -0x98(%rbp)
movq %rax, %rdi
callq 0x3330
movl %eax, %edi
movq %rbx, %rsi
callq 0x35b0
movq %rax, %rbx
movl $0x1, %edi
movl $0x70, %esi
callq 0x31b0
movq %rax, %r12
movl $0x1, %edi
movl $0x20, %esi
callq 0x31b0
movq %rax, %r14
movq %rbx, -0x30(%rbp)
movq %rbx, 0x18(%rax)
movl $0x1000, %edi           # imm = 0x1000
callq 0x3440
movq %rax, (%r14)
movq %r14, 0x68(%r12)
leaq 0x18(%r12), %rax
movq %rax, -0x48(%rbp)
leaq -0x70(%rbp), %r15
xorl %ebx, %ebx
xorl %eax, %eax
testl %eax, %eax
jne 0xa768
movl 0x8(%r14), %ecx
movl 0xc(%r14), %eax
cmpl $0x0, 0x10(%r14)
je 0xa6fc
cmpl %eax, %ecx
jge 0xab7c
cmpl %eax, %ecx
jl 0xa734
movl $0x0, 0x8(%r14)
movq (%r14), %rsi
movq 0x18(%r14), %rdi
movl $0x1000, %edx           # imm = 0x1000
callq 0x35f0
movl %eax, 0xc(%r14)
cmpl $0xfff, %eax            # imm = 0xFFF
jg 0xa734
movl $0x1, 0x10(%r14)
testl %eax, %eax
je 0xab7c
movq (%r14), %rdx
movslq 0x8(%r14), %rsi
leal 0x1(%rsi), %ecx
movl %ecx, 0x8(%r14)
movzbl (%rdx,%rsi), %esi
movsbl %sil, %edx
movl %edx, -0x70(%rbp)
cmpl $0x3e, %esi
je 0xa763
cmpl $0xff, %esi
je 0xab7c
cmpl $0x40, %esi
jne 0xa6ed
movl %edx, 0x60(%r12)
xorl %eax, %eax
movq %rax, 0x48(%r12)
movq %rax, 0x30(%r12)
movq %rax, 0x18(%r12)
movq %r14, %rdi
xorl %esi, %esi
movq %r12, %rdx
movq %r15, %rcx
callq 0xb4cc
testl %eax, %eax
js 0xb3ac
cmpl $0xa, -0x70(%rbp)
je 0xa7aa
movq %r14, %rdi
movl $0xa, %esi
movq -0x48(%rbp), %rdx
xorl %ecx, %ecx
callq 0xb4cc
cmpl $0x0, 0x10(%r14)
sete %cl
movl 0xc(%r14), %ebx
cmpl %ebx, 0x8(%r14)
setl %al
orb %al, %cl
testb $0x1, %cl
je 0xa8df
testb $0x1, %al
jne 0xa802
movl $0x0, 0x8(%r14)
movq (%r14), %rsi
movq 0x18(%r14), %rdi
movl $0x1000, %edx           # imm = 0x1000
callq 0x35f0
movl %eax, %ebx
movl %eax, 0xc(%r14)
cmpl $0xfff, %eax            # imm = 0xFFF
jg 0xa802
movl $0x1, 0x10(%r14)
testl %ebx, %ebx
je 0xa8df
movq (%r14), %rax
movslq 0x8(%r14), %rcx
leal 0x1(%rcx), %r13d
movl %r13d, 0x8(%r14)
movb (%rax,%rcx), %r15b
movsbl %r15b, %edi
movl %edi, -0x70(%rbp)
movzbl %dil, %eax
cmpl $0x3f, %eax
jg 0xa838
cmpl $0x2b, %eax
je 0xa8ed
cmpl $0x3e, %eax
jne 0xa84c
jmp 0xa8e8
cmpl $0x40, %eax
je 0xa8e8
cmpl $0xff, %eax
je 0xa8ed
callq 0x3290
testl %eax, %eax
je 0xa8c5
movq 0x30(%r12), %rbx
movq 0x40(%r12), %rax
leaq 0x1(%rbx), %r13
cmpq 0x38(%r12), %r13
jb 0xa8b4
movq %r13, %rcx
shrq %rcx
orq %r13, %rcx
movq %rcx, %rdx
shrq $0x2, %rdx
orq %rcx, %rdx
movq %rdx, %rcx
shrq $0x4, %rcx
orq %rdx, %rcx
movq %rcx, %rdx
shrq $0x8, %rdx
orq %rcx, %rdx
movq %rdx, %rsi
shrq $0x10, %rsi
orq %rdx, %rsi
incq %rsi
movq %rsi, 0x38(%r12)
movq %rax, %rdi
callq 0x3560
movq %rax, 0x40(%r12)
movb -0x70(%rbp), %r15b
movq %r13, 0x30(%r12)
movb %r15b, (%rax,%rbx)
movl 0x8(%r14), %r13d
movl 0xc(%r14), %ebx
cmpl %ebx, %r13d
setl %al
cmpl $0x0, 0x10(%r14)
je 0xa7c8
cmpl %ebx, %r13d
jl 0xa7c8
movl $0xffffffff, -0x70(%rbp) # imm = 0xFFFFFFFF
jmp 0xa8ed
movl %edi, 0x60(%r12)
movq 0x30(%r12), %r15
movq 0x40(%r12), %rbx
movb $0x0, (%rbx,%r15)
cmpl $0x2b, -0x70(%rbp)
leaq -0x70(%rbp), %r13
jne 0xaa4f
movq 0x38(%r12), %rsi
cmpq %rsi, 0x50(%r12)
jae 0xa92a
movq %rsi, 0x50(%r12)
movq 0x58(%r12), %rdi
callq 0x3560
movq %rax, 0x58(%r12)
movl 0x8(%r14), %ecx
movl 0xc(%r14), %eax
cmpl $0x0, 0x10(%r14)
je 0xa941
cmpl %eax, %ecx
jge 0xab7c
cmpl %eax, %ecx
jl 0xa979
movl $0x0, 0x8(%r14)
movq (%r14), %rsi
movq 0x18(%r14), %rdi
movl $0x1000, %edx           # imm = 0x1000
callq 0x35f0
movl %eax, 0xc(%r14)
cmpl $0xfff, %eax            # imm = 0xFFF
jg 0xa979
movl $0x1, 0x10(%r14)
testl %eax, %eax
je 0xab7c
movq (%r14), %rdx
movslq 0x8(%r14), %rsi
leal 0x1(%rsi), %ecx
movl %ecx, 0x8(%r14)
movzbl (%rdx,%rsi), %edx
movsbl %dl, %esi
movl %esi, -0x70(%rbp)
cmpl $0xff, %edx
je 0xab7c
cmpl $0xa, %edx
jne 0xa932
jmp 0xa9c2
cmpb $0x21, %dl
jl 0xa9c2
movq 0x58(%r12), %rax
leaq 0x1(%rsi), %rcx
movq %rcx, 0x48(%r12)
movb %dl, (%rax,%rsi)
movl 0x8(%r14), %ecx
movl 0xc(%r14), %eax
cmpl %eax, %ecx
setl %dl
cmpl $0x0, 0x10(%r14)
je 0xa9d2
cmpl %eax, %ecx
jge 0xaa2f
testb $0x1, %dl
jne 0xaa07
movl $0x0, 0x8(%r14)
movq (%r14), %rsi
movq 0x18(%r14), %rdi
movl $0x1000, %edx           # imm = 0x1000
callq 0x35f0
movl %eax, 0xc(%r14)
cmpl $0xfff, %eax            # imm = 0xFFF
jg 0xaa07
movl $0x1, 0x10(%r14)
testl %eax, %eax
je 0xaa2f
movq (%r14), %rdx
movslq 0x8(%r14), %rsi
leal 0x1(%rsi), %ecx
movl %ecx, 0x8(%r14)
movsbl (%rdx,%rsi), %edx
movl %edx, -0x70(%rbp)
cmpl $-0x1, %edx
je 0xaa2f
movq 0x48(%r12), %rsi
cmpq %r15, %rsi
jb 0xa9a4
movq 0x48(%r12), %rax
movq 0x58(%r12), %rcx
movb $0x0, (%rcx,%rax)
movl $0x0, 0x60(%r12)
cmpq %rax, %r15
jne 0xab81
testl %r15d, %r15d
js 0xab81
movq 0x10(%r12), %r14
movq %r13, %rdi
movq %r14, %rsi
leaq -0xd8(%rbp), %rdx
callq 0xb724
leaq -0x158(%rbp), %rdi
movq %r13, %rsi
callq 0xb762
movq %rax, %r15
movq 0x8(%rax), %r13
movq %rbx, %rdi
callq 0x3120
movq %r15, %rdi
xorl %esi, %esi
movq %r13, %rdx
movq %rbx, %rcx
movq %rax, %r8
callq 0x3500
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
leaq -0x70(%rbp), %r13
je 0xaabd
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x32e0
movq %r13, %rdi
movq %r14, %rsi
leaq -0xd8(%rbp), %rdx
callq 0xb724
movq %r13, %rdi
leaq 0x200d(%rip), %rsi      # 0xcae6
callq 0x3600
movq %rbx, %rdi
callq 0x3120
movq %rax, %r15
incl %eax
movslq %eax, %rdi
callq 0x3030
movq %rax, %r14
testl %r15d, %r15d
leaq 0x1ec0(%rip), %rdx      # 0xc9c0
jle 0xab1f
andl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
movq %r14, %rax
movsbq -0x1(%rbx,%r15), %rcx
movb (%rcx,%rdx), %cl
movb %cl, (%rax)
incq %rax
decq %r15
jne 0xab0c
leaq -0x158(%rbp), %rdi
movq %r13, %rsi
callq 0xb7e2
movq %rax, %r15
movq 0x8(%rax), %r13
movq %r14, %rdi
callq 0x3120
movq %r15, %rdi
xorl %esi, %esi
movq %r13, %rdx
leaq -0x70(%rbp), %r15
movq %r14, %rcx
movq %rax, %r8
callq 0x3500
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0xab6d
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x32e0
movq 0x68(%r12), %r14
movl 0x60(%r12), %eax
jmp 0xa6dd
testq %r12, %r12
je 0xabc9
movq 0x10(%r12), %rdi
callq 0x33b0
movq 0x28(%r12), %rdi
callq 0x33b0
movq %rbx, %rdi
callq 0x33b0
movq 0x58(%r12), %rdi
callq 0x33b0
movq 0x68(%r12), %rbx
testq %rbx, %rbx
je 0xabc1
movq (%rbx), %rdi
callq 0x33b0
movq %rbx, %rdi
callq 0x33b0
movq %r12, %rdi
callq 0x33b0
movq -0x30(%rbp), %rdi
callq 0x3570
movq -0x98(%rbp), %rdi
callq 0x32c0
movl $0x1, %edi
movl $0x38, %esi
callq 0x31b0
movq %rax, %r12
movq -0x80(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x128(%rbp), %rdi
leaq -0x70(%rbp), %rdx
callq 0xb724
leaq -0x128(%rbp), %rdi
callq 0xa531
movq %rax, -0xa0(%rbp)
leaq -0x118(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xac3a
movq -0x118(%rbp), %rsi
incq %rsi
callq 0x32e0
movq -0xa0(%rbp), %rax
testq %rax, %rax
je 0xb3c4
movq 0x10(%rax), %r15
movq %r12, -0xe8(%rbp)
movq %r15, -0x78(%rbp)
movq -0xa0(%rbp), %rdi
movq %r12, %rsi
callq 0x4d18
testl %eax, %eax
js 0xb380
testq %r12, %r12
je 0xb3b6
movzwl 0xc(%r12), %eax
testl $0x104, %eax            # imm = 0x104
jne 0xac59
movq 0x30(%r12), %rsi
leaq -0x70(%rbp), %rdi
leaq -0xd8(%rbp), %rbx
movq %rbx, %rdx
callq 0xb724
movq 0x8(%r15), %rax
movslq (%r12), %rcx
movq (%rax,%rcx,8), %rsi
movq %rbx, %rdi
leaq -0x85(%rbp), %rdx
callq 0xb724
movzbl 0xb(%r12), %ebx
addq 0x30(%r12), %rbx
movq 0x10(%r15), %rax
movslq (%r12), %rcx
movl (%rax,%rcx,4), %eax
movq %rax, -0xb8(%rbp)
movl 0x4(%r12), %r13d
movq %r12, %rdi
movq %rbx, %rsi
callq 0x5ef4
movq %rax, -0xb0(%rbp)
movl 0x14(%r12), %eax
movq %rax, -0x40(%rbp)
movq 0x8(%r12), %rcx
movabsq $0x1000000000, %rax     # imm = 0x1000000000
andq %rax, %rcx
movq %rcx, -0x90(%rbp)
leaq -0x158(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0xb7e2
movq (%rax), %rax
cmpb $0x0, (%rax)
je 0xb422
movq %rbx, -0xe0(%rbp)
leaq -0x158(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0xb7e2
movq (%rax), %rbx
movl 0x14(%r12), %r15d
movslq %r15d, %r14
leaq 0x1(%r14), %rdi
callq 0x3030
movq %rax, -0xa8(%rbp)
testl %r15d, %r15d
jle 0xadc5
leaq 0x58d1(%rip), %rax      # 0x10640
movq (%rax), %rdx
movl 0x10(%r12), %eax
leal (,%rax,4), %ecx
addq 0x30(%r12), %rcx
movzbl 0xb(%r12), %esi
addq %rcx, %rsi
xorl %edi, %edi
xorl %r8d, %r8d
movq -0xa8(%rbp), %r10
movl %r8d, %ecx
shrl %ecx
movzbl (%rsi,%rcx), %r9d
movl %edi, %ecx
notb %cl
andb $0x4, %cl
shrl %cl, %r9d
andl $0xf, %r9d
movb (%rdx,%r9), %cl
movb %cl, (%r10,%r8)
incq %r8
addl $0x4, %edi
cmpq %r8, %r15
jne 0xad98
jmp 0xadca
movl 0x10(%r12), %eax
incl %r13d
movq -0xa8(%rbp), %rdx
movb $0x0, (%rdx,%r14)
testl %eax, %eax
movq -0x78(%rbp), %r15
movl %r13d, -0x84(%rbp)
je 0xafa8
movl %r13d, %ecx
leaq (%rbx,%rcx), %r10
decq %r10
movl %eax, %r11d
xorl %ebx, %ebx
movl $0x0, -0x48(%rbp)
xorl %esi, %esi
xorl %r13d, %r13d
xorl %edi, %edi
movq %rdx, %r14
xorl %r8d, %r8d
movq -0x40(%rbp), %rax
movl %eax, -0x34(%rbp)
movq -0xe0(%rbp), %r9
movq %r11, -0xf0(%rbp)
movl (%r9,%rbx,4), %edx
movl %edx, %r15d
andl $0xf, %r15d
movl %edx, %eax
shrl $0x4, %eax
movq %rax, -0x30(%rbp)
cmpl $0x8, %r15d
ja 0xb3ce
leaq 0x1b47(%rip), %rcx      # 0xc990
movslq (%rcx,%r15,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpl $0x10, %edx
jb 0xaf1a
movq %rbx, -0x108(%rbp)
movl %r8d, -0x38(%rbp)
movl %esi, -0x4c(%rbp)
movq -0x30(%rbp), %rax
decl %eax
movq %rax, -0x100(%rbp)
leaq 0x1(%r14), %rax
movq %rax, -0xf8(%rbp)
shrl $0x4, %edx
xorl %r12d, %r12d
movq %r14, -0x98(%rbp)
movq %rdx, -0x80(%rbp)
movl %r13d, %ebx
movl %edi, %r13d
movsbl (%r10,%r12), %edi
movq %r10, %r14
callq 0x35e0
movl %eax, %r15d
movq -0x98(%rbp), %rax
movsbl (%rax,%r12), %edi
callq 0x35e0
movq %r14, %r10
movl %r13d, %edi
movl %ebx, %r13d
xorl %ecx, %ecx
xorl %edx, %edx
cmpl %eax, %r15d
sete %cl
setne %dl
addl %edx, %edi
movq -0x80(%rbp), %rdx
addl %ecx, %r13d
incq %r12
cmpl %r12d, %edx
jne 0xae92
movq -0x100(%rbp), %rax
addq %rax, %r10
incq %r10
movq -0xf8(%rbp), %r14
addq %rax, %r14
movq -0xe8(%rbp), %r12
movl -0x4c(%rbp), %esi
movl -0x38(%rbp), %r8d
movq -0xe0(%rbp), %r9
movq -0xf0(%rbp), %r11
movq -0x108(%rbp), %rbx
movq -0x30(%rbp), %rax
addl -0x48(%rbp), %eax
movl %eax, -0x48(%rbp)
jmp 0xaf96
movq -0x30(%rbp), %rcx
addl %ecx, %edi
addl %ecx, %esi
jmp 0xaf34
movq -0x30(%rbp), %rcx
movl %ecx, %eax
addq %rax, %r10
jmp 0xaf69
testq %rbx, %rbx
movl $0x0, %eax
movq -0x30(%rbp), %rcx
cmovel %ecx, %eax
addl %eax, %r8d
addl %ecx, -0x34(%rbp)
movq -0x40(%rbp), %rcx
addl %eax, %ecx
movq %rcx, -0x40(%rbp)
jmp 0xaf96
movq -0x30(%rbp), %rcx
addl %ecx, %edi
addl %ecx, %esi
movl %ecx, %eax
addq %rax, %r14
addl %ecx, -0x48(%rbp)
jmp 0xaf96
testq %rbx, %rbx
movq -0x30(%rbp), %r15
movl %r15d, %eax
movl $0x0, %edx
cmovel %edx, %eax
movl %r15d, %ecx
cmovnel %edx, %ecx
movq -0x40(%rbp), %rdx
subl %eax, %edx
movq %rdx, -0x40(%rbp)
addl %ecx, %r8d
addq %r15, %r14
movq -0x78(%rbp), %r15
incq %rbx
cmpq %r11, %rbx
jne 0xae24
jmp 0xafc0
xorl %r8d, %r8d
movq -0x40(%rbp), %rax
movl %eax, -0x34(%rbp)
xorl %edi, %edi
xorl %r13d, %r13d
xorl %esi, %esi
movl $0x0, -0x48(%rbp)
movl %r8d, -0x38(%rbp)
movl %edi, -0x80(%rbp)
movl %esi, -0x4c(%rbp)
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
movq 0x4fef(%rip), %rdi      # 0xffc8
callq 0x3370
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1b55(%rip), %rsi      # 0xcb45
callq 0x3370
movq -0xd8(%rbp), %rsi
movq -0xd0(%rbp), %rdx
movq %rbx, %rdi
callq 0x3370
movq %rax, %r14
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1b28(%rip), %rsi      # 0xcb45
callq 0x3370
cvtsi2sdl -0x80(%rbp), %xmm0
movl -0x48(%rbp), %ebx
cvtsi2sd %rbx, %xmm2
divsd %xmm2, %xmm0
movsd 0x1935(%rip), %xmm1     # 0xc970
subsd %xmm0, %xmm1
mulsd 0x1931(%rip), %xmm1     # 0xc978
movsd %xmm1, -0x98(%rbp)
movapd %xmm1, %xmm0
divsd 0x1925(%rip), %xmm0     # 0xc980
movsd %xmm2, -0x30(%rbp)
mulsd %xmm2, %xmm0
callq 0x30b0
cvttsd2si %xmm0, %esi
movq %r14, %rdi
callq 0x3580
movq %rax, %r14
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1abe(%rip), %rsi      # 0xcb45
callq 0x3370
movq %r14, %rdi
movsd -0x98(%rbp), %xmm0
callq 0x3530
movq %rax, %r14
movl $0x3, %edx
movq %rax, %rdi
leaq 0x1a95(%rip), %rsi      # 0xcb43
callq 0x3370
movl -0x34(%rbp), %eax
movl %eax, %esi
subl -0x40(%rbp), %esi
cmpq $0x0, -0x90(%rbp)
cmovel -0x38(%rbp), %esi
movq %r14, %rdi
callq 0x31c0
movq %rax, %r14
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1a64(%rip), %rsi      # 0xcb45
callq 0x3370
movl -0x34(%rbp), %eax
movl %eax, %esi
subl -0x38(%rbp), %esi
cmpq $0x0, -0x90(%rbp)
cmovel -0x40(%rbp), %esi
movq %r14, %rdi
callq 0x31c0
movq %rax, %r14
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1a31(%rip), %rsi      # 0xcb45
callq 0x3370
movl -0x34(%rbp), %esi
movq %r14, %rdi
callq 0x31c0
movq %rax, %r14
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1a0f(%rip), %rsi      # 0xcb45
callq 0x3370
movq -0x90(%rbp), %rsi
shrq $0x24, %rsi
movq %r14, %rdi
callq 0x3580
movq %rax, %r14
movl $0x1, %edx
movq %rax, %rdi
leaq 0x19e5(%rip), %rsi      # 0xcb45
callq 0x3370
movq -0xb8(%rbp), %rsi
subl -0xb0(%rbp), %esi
cmpq $0x0, -0x90(%rbp)
cmovel -0x84(%rbp), %esi
movq %r14, %rdi
callq 0x31c0
movq %rax, %r14
movl $0x1, %edx
movq %rax, %rdi
leaq 0x19aa(%rip), %rsi      # 0xcb45
callq 0x3370
movq -0xb8(%rbp), %rsi
subl -0x84(%rbp), %esi
cmpq $0x0, -0x90(%rbp)
cmovel -0xb0(%rbp), %esi
movq %r14, %rdi
callq 0x31c0
movq %rax, %r14
movl $0x1, %edx
movq %rax, %rdi
leaq 0x196f(%rip), %rsi      # 0xcb45
callq 0x3370
movq %r14, %rdi
movq -0xb8(%rbp), %rsi
callq 0x31c0
movq %rax, %r14
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1949(%rip), %rsi      # 0xcb45
callq 0x3370
movq %r14, %rdi
movq %rbx, %rsi
callq 0x31c0
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1927(%rip), %rsi      # 0xcb45
callq 0x3370
movq -0x40(%rbp), %rsi
subl -0x38(%rbp), %esi
movq %rbx, %rdi
callq 0x31c0
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1901(%rip), %rsi      # 0xcb45
callq 0x3370
movq -0xb0(%rbp), %rsi
subl -0x84(%rbp), %esi
movq %rbx, %rdi
callq 0x31c0
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
leaq 0x18d5(%rip), %rsi      # 0xcb45
callq 0x3370
movq %rbx, %rdi
movl %r13d, %esi
callq 0x3580
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
leaq 0x18b3(%rip), %rsi      # 0xcb45
callq 0x3370
movq %rbx, %rdi
movl -0x80(%rbp), %esi
callq 0x3580
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1891(%rip), %rsi      # 0xcb45
callq 0x3370
movl -0x80(%rbp), %eax
subl -0x4c(%rbp), %eax
cvtsi2sd %eax, %xmm1
divsd -0x30(%rbp), %xmm1
movsd 0x16a0(%rip), %xmm0     # 0xc970
subsd %xmm1, %xmm0
mulsd 0x169c(%rip), %xmm0     # 0xc978
movq %rbx, %rdi
callq 0x3530
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
leaq 0x184f(%rip), %rsi      # 0xcb45
callq 0x3370
movq %rbx, %rdi
movl -0x4c(%rbp), %esi
callq 0x3580
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x32b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31d0
movq -0xa8(%rbp), %rdi
callq 0x3420
movq -0xd8(%rbp), %rdi
leaq -0xc8(%rbp), %rax
cmpq %rax, %rdi
je 0xb35e
movq -0xc8(%rbp), %rsi
incq %rsi
callq 0x32e0
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0xac59
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x32e0
jmp 0xac59
movq -0xa0(%rbp), %rdi
callq 0x4acb
leaq -0x158(%rbp), %rdi
callq 0xb870
xorl %eax, %eax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x40(%r12), %rbx
jmp 0xab81
leaq 0x172c(%rip), %rdi      # 0xcae9
xorl %eax, %eax
callq 0x3060
movl $0x1, %edi
callq 0x33d0
movq 0x4c1b(%rip), %rdi      # 0xfff0
leaq 0x1749(%rip), %rsi      # 0xcb25
movl $0x14, %edx
callq 0x3370
movq 0x4c03(%rip), %rdi      # 0xfff0
movl %r15d, %esi
callq 0x3580
movq %rax, %r14
leaq 0x173b(%rip), %rsi      # 0xcb3a
movl $0x8, %edx
movq %rax, %rdi
callq 0x3370
movq %r14, %rdi
movq -0x30(%rbp), %rsi
callq 0x3580
movq %rax, %rdi
callq 0x3140
jmp 0xb3c4
leaq -0xd8(%rbp), %rdi
callq 0x4056
jmp 0xb475
jmp 0xb475
jmp 0xb475
jmp 0xb475
movq %rax, %rbx
leaq -0x118(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb4b8
movq -0x118(%rbp), %rsi
jmp 0xb4b0
jmp 0xb475
jmp 0xb475
jmp 0xb475
jmp 0xb46c
jmp 0xb475
jmp 0xb475
jmp 0xb475
jmp 0xb475
jmp 0xb46c
jmp 0xb47a
jmp 0xb47a
jmp 0xb475
jmp 0xb47a
movq %rax, %rbx
jmp 0xb49f
jmp 0xb47a
jmp 0xb47a
movq %rax, %rbx
jmp 0xb4b8
movq %rax, %rbx
movq -0xd8(%rbp), %rdi
leaq -0xc8(%rbp), %rax
cmpq %rax, %rdi
je 0xb49f
movq -0xc8(%rbp), %rsi
incq %rsi
callq 0x32e0
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0xb4b8
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x32e0
leaq -0x158(%rbp), %rdi
callq 0xb870
movq %rbx, %rdi
callq 0x3590