// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Correct.cpp
// Function: gen_rphase_dp0_single_path(SnpStats*, long, haplotype_evdience*, Chain_Data*, asg64_v*, long, long, long, double, unsigned long, asg64_v*, unsigned char*)
void gen_rphase_dp0_single_path(SnpStats *a, int64_t an, haplotype_evdience *za, Chain_Data *dp, asg64_v *idx, int64_t het_cov, int64_t hom_cov, int64_t n_hap, double cut_rate, uint64_t cut_bd, asg64_v *res, uint8_t *qual_a)
{
    if(an <= 0) return;
    int64_t *p, i, k, j, st, max_f, max_j, sc, ch_n, plus = 0, rn, rn0; int32_t *f, *ii; uint64_t m, cc = 0;
    resize_Chain_Data(dp, an, NULL); idx->n = res->n = 0;
    f = dp->score; p = dp->pre; ii = dp->occ;
    cc = ((het_cov > 0)?(het_cov):(hom_cov/n_hap)); cc *= cut_rate; if(cc < cut_bd) cc = cut_bd;

    // fprintf(stderr, "\n\n\n[M::%s]\tcc::%lu\n\n\n", __func__, cc);

    for (i = 0; i < an; ++i) {
        max_f = 1; max_j = -1; 
        st = 0; ///if(a[i].occ_0 < cc) st = i;
        for (j = i - 1; j >= st; --j) {
            sc = comput_sc_rphase(&a[i], i, &a[j], j, za, 0/**cc**/);
            if (sc == INT64_MIN) continue;
            sc += f[j];
            if (sc > max_f) {
                max_f = sc; max_j = j;
            } 
        }

        f[i] = max_f; p[i] = max_j; ii[i] = 0;
        if(f[i] < plus) plus = f[i];
    }

    for (i = 0; i < an; i++) {
        f[i] -= plus;
        m = f[i]; m = ((uint32_t)-1) - m; m <<= 32; m |= i;
        kv_push(uint64_t, *idx, m);
    }
    radix_sort_bc64(idx->a, idx->a + idx->n);

    kv_resize(uint64_t, *res, ((uint64_t)an));
    for (i = rn = 0; i < an; i++) {///idx->a:: [0, ch_n) -> tree; [ch_n, ch_n + an) -> sort; [ch_n + an, -1) -> path
        rn0 = rn;
        for(k = (uint32_t)idx->a[i]; (k >= 0) && (!ii[k]);) {
            res->a[rn++] = k; ii[k] = 1; k = p[k];
        }
        if(rn0 == rn) continue;
        m = rn - rn0; m = ((uint32_t)-1) - m; m <<= 32; m |= rn0;
        kv_push(uint64_t, *idx, m);
    }

    radix_sort_bc64(idx->a + an, idx->a + idx->n);
    ch_n = idx->n; 
    if(!qual_a) {    
        for (k = an; k < ch_n; k++) {
            rn0 = ((uint32_t)idx->a[k]);
            rn = ((uint32_t)-1) - (idx->a[k]>>32);
            // break;
            plus = -1;
            if(rn > 1) {
                // for (i = 0; (i < rn) && (is_hpc_vec(&(a[res->a[rn0+rn-i-1]]), res->a[rn0+rn-i-1], za)); i++);
                // plus = ((i < rn)?(1):(-1));
                plus = 1;
                
                // for (i = 0; i < rn; i++) {
                //     a[res->a[rn0+rn-i-1]].score = plus;
                //     // fprintf(stderr, "pos::%u\tsc::%ld\tn0::%u\tn1::%u\tn2::%u\tk::%lu\n", a[res->a[rn0+rn-i-1]].site, plus, a[res->a[rn0+rn-i-1]].occ_0, a[res->a[rn0+rn-i-1]].occ_1, 
                //     // 1 + a[res->a[rn0+rn-i-1]].homopolymer_num - a[res->a[rn0+rn-i-1]].non_homopolymer_num - a[res->a[rn0+rn-i-1]].occ_0 - a[res->a[rn0+rn-i-1]].occ_1, res->a[rn0+rn-i-1]);
                // }
                
            } else {
                if((!is_hpc_vec(&(a[res->a[rn0]]), res->a[rn0], za)) && (a[res->a[rn0]].occ_0 >= cc)) plus = 1;
                ///a[res->a[rn0]].score = plus;
                // fprintf(stderr, "pos::%u\tsc::%ld\tn0::%u\tn1::%u\tn2::%u\tk::%lu\n", a[res->a[rn0]].site, plus, a[res->a[rn0]].occ_0, a[res->a[rn0]].occ_1, 
                // 1 + a[res->a[rn0]].homopolymer_num - a[res->a[rn0]].non_homopolymer_num - a[res->a[rn0]].occ_0 - a[res->a[rn0]].occ_1, res->a[rn0]);
            }

            // fprintf(stderr, "\n[M::%s]\tcnt::%lu\tplus::%ld\n", __func__, rn, plus);
            // if(plus > 0) {
            //     for (i = 0; (i < rn) && (a[res->a[rn0 + i]].occ_0 < cc); i++);
            //     if(i < rn) {
            //         for (i = 0; i < rn; i++) a[res->a[rn0 + i]].score = plus;
            //     }
            // }
            for (i = 0; i < rn; i++) {
                if(a[res->a[rn0 + i]].occ_0 >= cc) {
                    a[res->a[rn0 + i]].score = plus;
                } else {
                    a[res->a[rn0 + i]].score = -1;
                }
                // fprintf(stderr, "pos::%u\tsc::%d\tn0::%u\tn1::%u\tn2::%u\tk::%lu\n", a[res->a[rn0 + i]].site, a[res->a[rn0 + i]].score, a[res->a[rn0 + i]].occ_0, a[res->a[rn0 + i]].occ_1, 
                //     1 + a[res->a[rn0 + i]].homopolymer_num - a[res->a[rn0 + i]].non_homopolymer_num - a[res->a[rn0 + i]].occ_0 - a[res->a[rn0 + i]].occ_1, res->a[rn0 + i]);
            }
        }
   } else {
        int64_t b0l, b0h, b1l, b1h, krn;
        /**
        for (k = an; k < ch_n; k++) {
            rn0 = ((uint32_t)idx->a[k]);
            rn = ((uint32_t)-1) - (idx->a[k]>>32);
            // break;
            fprintf(stderr, "\n[M::%s]\tcnt::%lu\n", __func__, rn);
            if(rn > 1) {
                for (i = 0; i < rn; i++) {
                    get_hq_value(&(a[res->a[rn0 + i]]), res->a[rn0 + i], za, &b0l, &b0h, &b1l, &b1h, qual_a);
                    if(b0h > b0l && b0h >= asm_opt.s_hap_cov && b1h > b1l && b1h >= asm_opt.infor_cov) {
                        a[res->a[rn0 + i]].score = 1;
                    } else {
                        a[res->a[rn0 + i]].score = -1;
                    }
                    fprintf(stderr, "pos::%u\tsc::%d\tn0::%u\tn1::%u\tn2::%u\tk::%lu\tb0l::%ld\tb0h::%ld\tb1l::%ld\tb1h::%ld\n", a[res->a[rn0 + i]].site, a[res->a[rn0 + i]].score, a[res->a[rn0 + i]].occ_0, a[res->a[rn0 + i]].occ_1, 
                    1 + a[res->a[rn0 + i]].homopolymer_num - a[res->a[rn0 + i]].non_homopolymer_num - a[res->a[rn0 + i]].occ_0 - a[res->a[rn0 + i]].occ_1, res->a[rn0 + i], b0l, b0h, b1l, b1h);
                }
            } else {
                if((!is_hpc_vec(&(a[res->a[rn0]]), res->a[rn0], za))) {
                    get_hq_value(&(a[res->a[rn0]]), res->a[rn0], za, &b0l, &b0h, &b1l, &b1h, qual_a);
                    if(((b0h > b0l) && (b0h > ((b0h + b0l)*0.7)) && (b0h >= asm_opt.s_hap_cov) && (b0h >= (int64_t)cc)) && 
                            ((b1h > b1l) && (b1h > ((b1h + b1l)*0.7)) && (b1h >= asm_opt.infor_cov) && (b1h >= (int64_t)cc))) {
                        a[res->a[rn0]].score = 1;
                    } else {
                        a[res->a[rn0]].score = -1;
                    }
                }
            }
        }
        **/
       for (k = an; k < ch_n; k++) {
            rn0 = ((uint32_t)idx->a[k]);
            rn = ((uint32_t)-1) - (idx->a[k]>>32);
            krn = rn;
            // break;
            
            for (i = 1; (i < rn) && ((a[res->a[rn0 + i]].site + 8) >= a[res->a[rn0 + i - 1]].site); i++);
            if(i >= rn) krn = 1;
            // fprintf(stderr, "\n[M::%s]\tcnt::%lu\tkrn::%ld\n", __func__, rn, krn);

            for (i = 0; i < rn; i++) {
                get_hq_value(&(a[res->a[rn0 + i]]), res->a[rn0 + i], za, &b0l, &b0h, &b1l, &b1h, qual_a);
                if(krn > 1) {
                    if(b0h > b0l && b0h >= asm_opt.s_hap_cov && b1h > b1l && b1h >= asm_opt.infor_cov) {
                        a[res->a[rn0 + i]].score = 1;
                    } else {
                        a[res->a[rn0 + i]].score = -1;
                    }
                } else {
                    if(((b0h > b0l) && (b0h > ((b0h + b0l)*0.7)) && (b0h >= asm_opt.s_hap_cov) && (b0h >= (int64_t)cc)) && 
                            ((b1h > b1l) && (b1h > ((b1h + b1l)*0.7)) && (b1h >= asm_opt.infor_cov) && (b1h >= (int64_t)cc))) {
                        a[res->a[rn0 + i]].score = 1;
                    } else {
                        a[res->a[rn0 + i]].score = -1;
                    }
                }
                
                // fprintf(stderr, "pos::%u\tsc::%d\tn0::%u\tn1::%u\tn2::%u\tk::%lu\tb0l::%ld\tb0h::%ld\tb1l::%ld\tb1h::%ld\n", a[res->a[rn0 + i]].site, a[res->a[rn0 + i]].score, a[res->a[rn0 + i]].occ_0, a[res->a[rn0 + i]].occ_1, 
                // 1 + a[res->a[rn0 + i]].homopolymer_num - a[res->a[rn0 + i]].non_homopolymer_num - a[res->a[rn0 + i]].occ_0 - a[res->a[rn0 + i]].occ_1, res->a[rn0 + i], b0l, b0h, b1l, b1h);
            }

            for (i = j = 0; i < rn; i = j) {
                plus = a[res->a[rn0 + i]].score;
                for (j = i + 1; (j < rn) && ((a[res->a[rn0 + i]].site-a[res->a[rn0 + j]].site) == (j-i)); j++) {
                    if(a[res->a[rn0 + j]].score == -1) plus = -1;
                }
                // fprintf(stderr, "[M::%s]\ti::%ld\tj::%ld\tplus::%ld\n", __func__, i, j, plus);
                if(plus == -1) {
                    for (; i < j; i++) {
                        a[res->a[rn0 + i]].score = plus;
                    }
                } 
            }
            
        }
    }
    
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdx, 0x40(%rsp)
testq %rsi, %rsi
jle 0x54276
movq %r9, %r13
movq %rcx, %rbp
movq %rdi, %r15
movsd %xmm0, 0x8(%rsp)
movq 0xf8(%rsp), %r14
movq 0xf0(%rsp), %rbx
xorl %r12d, %r12d
movq %rcx, %rdi
movq %rsi, 0x10(%rsp)
xorl %edx, %edx
movq %r8, 0x18(%rsp)
callq 0x3ecb0
movq 0x18(%rsp), %r8
movq %r12, (%r14)
movq %r12, (%r8)
movq (%rbp), %rax
movq %rax, 0x20(%rsp)
movq 0x8(%rbp), %rsi
movq 0x20(%rbp), %rax
movq %rax, 0x50(%rsp)
testq %r13, %r13
jg 0x539f1
movq 0xe0(%rsp), %rax
cqto
idivq 0xe8(%rsp)
movq %rax, %r13
movq %r13, %xmm0
punpckldq 0x1dd882(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1dd88a(%rip), %xmm0   # 0x231290
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x8(%rsp), %xmm1
cvttsd2si %xmm1, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x1dd8dc(%rip), %xmm1   # 0x231308
cvttsd2si %xmm1, %rdx
andq %rcx, %rdx
orq %rax, %rdx
cmpq %rbx, %rdx
cmovbeq %rbx, %rdx
movq %rdx, 0x38(%rsp)
movq 0x40(%rsp), %rax
addq $0xc, %rax
movq %rax, 0x58(%rsp)
xorpd %xmm0, %xmm0
xorl %r10d, %r10d
xorl %r9d, %r9d
movq 0x10(%rsp), %rdx
movq %rsi, 0x48(%rsp)
testq %r10, %r10
je 0x53c59
movq %r9, 0x90(%rsp)
leaq (%r10,%r10,4), %rax
leaq (%r15,%rax,8), %rdi
movl 0x20(%rdi), %ebp
movl $0x1, %eax
movq %rax, 0x28(%rsp)
movq $-0x1, 0x30(%rsp)
movq %r10, 0x78(%rsp)
movq %r10, %r9
movq 0x58(%rsp), %r8
movl %ebp, 0x8(%rsp)
movq %r9, %r10
decq %r9
leaq (%r9,%r9,4), %rax
cmpl 0x20(%r15,%rax,8), %ebp
jne 0x53ac1
cmpq $0x1, %r10
jg 0x53aa5
jmp 0x53c31
leaq (%r15,%rax,8), %rax
movl 0x14(%rdi), %r11d
movl 0x18(%rdi), %ecx
movl 0x14(%rax), %r12d
movl 0x18(%rax), %eax
movapd %xmm0, 0x60(%rsp)
subl %ecx, %r11d
je 0x53ab6
cmpl %eax, %r12d
je 0x53ab6
leaq (%rcx,%rcx,2), %rcx
movq 0x40(%rsp), %rdx
leaq (%rdx,%rcx,8), %r14
subl %eax, %r12d
leaq (%rax,%rax,2), %rax
leaq (%r8,%rax,8), %rax
xorl %ebx, %ebx
xorl %edx, %edx
leaq (%rdx,%rdx,2), %rcx
movl 0x4(%r14,%rcx,8), %ebp
leaq (%rbx,%rbx,2), %rsi
leaq (%rax,%rsi,8), %rsi
cmpl %ebp, -0x8(%rsi)
jae 0x53b26
incq %rbx
addq $0x18, %rsi
cmpq %r12, %rbx
jl 0x53b10
jmp 0x53be4
jne 0x53bd3
leaq (%r14,%rcx,8), %rcx
xorl %ebp, %ebp
testb $0x1, 0xc(%rcx)
movl $0x0, %r13d
je 0x53b4f
movl 0x8(%rcx), %r13d
cmpq %r13, 0x78(%rsp)
setne %bpl
leal 0x1(%rbp), %r13d
testb $0x1, (%rsi)
jne 0x53b58
xorl %esi, %esi
jmp 0x53ba9
movl -0x4(%rsi), %esi
movq %rsi, 0x98(%rsp)
cmpq %rsi, %r9
setne %r8b
leal 0x1(%r8), %esi
andb %r8b, %bpl
cmpb $0x1, %bpl
jne 0x53ba4
cmpl $-0x1, 0x8(%rcx)
movq 0x58(%rsp), %r8
movl 0x8(%rsp), %ebp
je 0x53bad
cmpl $-0x1, 0x98(%rsp)
movzbl %r13b, %r13d
movl $0x0, %ecx
cmovnel %ecx, %r13d
movzbl %sil, %esi
cmovnel %ecx, %esi
jmp 0x53bad
movq 0x58(%rsp), %r8
movl 0x8(%rsp), %ebp
cmpb %sil, %r13b
jne 0x53ab6
cmpb $0x2, %r13b
je 0x53ab6
cmpb $0x2, %sil
je 0x53ab6
movzbl %r13b, %ecx
incq 0x60(%rsp,%rcx,8)
incq %rdx
cmpq %r11, %rdx
jae 0x53be4
cmpq %r12, %rbx
jl 0x53aff
cmpq $0x0, 0x60(%rsp)
movl 0x8(%rsp), %ebp
jle 0x53ab6
cmpq $0x0, 0x68(%rsp)
jle 0x53ab6
movq 0x20(%rsp), %rax
movslq (%rax,%r9,4), %rax
leaq 0x1(%rax), %rcx
movq 0x28(%rsp), %rdx
cmpq %rax, %rdx
cmovleq %rcx, %rdx
movq %rdx, 0x28(%rsp)
movq 0x30(%rsp), %rax
cmovleq %r9, %rax
movq %rax, 0x30(%rsp)
jmp 0x53ab6
movq 0x10(%rsp), %rdx
movq 0x18(%rsp), %r8
movq 0x48(%rsp), %rsi
movq 0x90(%rsp), %r9
movq 0x78(%rsp), %r10
movq 0x30(%rsp), %rax
movq 0x28(%rsp), %rdi
jmp 0x53c65
movq $-0x1, %rax
movl $0x1, %edi
movq 0x20(%rsp), %rcx
movl %edi, (%rcx,%r10,4)
movq %rax, (%rsi,%r10,8)
movq 0x50(%rsp), %rax
movl $0x0, (%rax,%r10,4)
movslq (%rcx,%r10,4), %rax
cmpq %rax, %r9
cmovgeq %rax, %r9
incq %r10
cmpq %rdx, %r10
jne 0x53a65
movq 0x10(%r8), %rdi
xorl %ebx, %ebx
movl $0x2, %r14d
movq 0x20(%rsp), %rax
movl (%rax,%rbx,4), %r12d
subl %r9d, %r12d
movl %r12d, (%rax,%rbx,4)
movq (%r8), %rax
cmpq 0x8(%r8), %rax
jne 0x53ced
leaq (%rax,%rax), %rsi
testq %rax, %rax
cmoveq %r14, %rsi
movq %rsi, 0x8(%r8)
shlq $0x3, %rsi
movq %r9, %r13
callq 0x2370
movq %r13, %r9
movq 0x18(%rsp), %r8
movq 0x10(%rsp), %rdx
movq %rax, %rdi
movq %rax, 0x10(%r8)
movq (%r8), %rax
notl %r12d
shlq $0x20, %r12
orq %rbx, %r12
leaq 0x1(%rax), %rcx
movq %rcx, (%r8)
movq %r12, (%rdi,%rax,8)
incq %rbx
cmpq %rbx, %rdx
jne 0x53ca2
movq (%r8), %rax
leaq (%rdi,%rax,8), %rsi
callq 0x45373
movq 0x10(%rsp), %r8
movq 0xf8(%rsp), %rdi
cmpq %r8, 0x8(%rdi)
jae 0x53d88
leaq -0x1(%r8), %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x10, %rcx
orq %rax, %rcx
leaq 0x1(%rcx), %rax
movq %rax, 0x8(%rdi)
movq 0x10(%rdi), %rdi
leaq 0x8(,%rcx,8), %rsi
callq 0x2370
movq 0xf8(%rsp), %rdi
movq 0x10(%rsp), %r8
movq %rax, 0x10(%rdi)
movq 0x18(%rsp), %r9
movq 0x10(%r9), %rax
xorl %ebx, %ebx
movl $0x2, %r13d
xorl %r12d, %r12d
movq 0x48(%rsp), %r10
movq 0x50(%rsp), %rsi
movq %r12, %r14
movl (%rax,%rbx,8), %ecx
cmpl $0x0, (%rsi,%rcx,4)
jne 0x53dcd
movq 0x10(%rdi), %rdx
movq %rcx, (%rdx,%r12,8)
incq %r12
movl $0x1, (%rsi,%rcx,4)
movq (%r10,%rcx,8), %rcx
testq %rcx, %rcx
jns 0x53dac
cmpq %r12, %r14
je 0x53e41
movq (%r9), %rcx
cmpq 0x8(%r9), %rcx
jne 0x53e14
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
cmoveq %r13, %rsi
movq %rsi, 0x8(%r9)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2370
movq 0x48(%rsp), %r10
movq 0x18(%rsp), %r9
movq 0xf8(%rsp), %rdi
movq 0x10(%rsp), %r8
movq %rax, 0x10(%r9)
movq (%r9), %rcx
movl %r14d, %edx
subl %r12d, %edx
shlq $0x20, %rdx
movabsq $-0x100000001, %rsi     # imm = 0xFFFFFFFEFFFFFFFF
addq %rsi, %rdx
incq %rdx
orq %r14, %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, (%r9)
movq %rdx, (%rax,%rcx,8)
movq 0x50(%rsp), %rsi
incq %rbx
cmpq %r8, %rbx
jne 0x53da6
leaq (%rax,%r8,8), %rdi
movq (%r9), %rcx
leaq (%rax,%rcx,8), %rsi
movq %r8, %rbx
callq 0x45373
movq 0x18(%rsp), %r10
movq (%r10), %r11
cmpq $0x0, 0x100(%rsp)
movq %r11, 0x8(%rsp)
je 0x54193
cmpq %rbx, %r11
jle 0x54276
movq %rbx, %rdi
movq 0x10(%r10), %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rax
movq (%rax,%rdi,8), %r9
movl %r9d, %r8d
movq %r9, %rbx
notq %rbx
shrq $0x20, %rbx
movabsq $-0x200000000, %rax     # imm = 0xFFFFFFFE00000000
cmpq %rax, %r9
movq 0xf8(%rsp), %rcx
movq %rdi, 0x10(%rsp)
jae 0x53f03
leaq (,%r8,8), %rax
addq 0x10(%rcx), %rax
movl $0x1, %ecx
movq -0x8(%rax,%rcx,8), %rdx
movq (%rax,%rcx,8), %rsi
leaq (%rsi,%rsi,4), %rsi
movl 0x20(%r15,%rsi,8), %esi
addl $0x8, %esi
leaq (%rdx,%rdx,4), %rdx
cmpl 0x20(%r15,%rdx,8), %esi
jb 0x53f08
incq %rcx
cmpq %rcx, %rbx
jne 0x53ed4
movl $0x1, %eax
jmp 0x53f0b
xorl %r13d, %r13d
jmp 0x53f12
movq %rbx, %rax
cmpl $0x2, %eax
setae %r13b
movabsq $-0x100000001, %rax     # imm = 0xFFFFFFFEFFFFFFFF
cmpq %rax, %r9
ja 0x540a8
movq %r9, 0x20(%rsp)
movq %r8, 0x28(%rsp)
leaq (,%r8,8), %rbp
movq 0xf8(%rsp), %rax
addq 0x10(%rax), %rbp
xorl %r12d, %r12d
movq (%rbp,%r12,8), %rsi
leaq (%rsi,%rsi,4), %r14
leaq (%r15,%r14,8), %rdi
movq 0x40(%rsp), %rdx
leaq 0x60(%rsp), %rcx
leaq 0xa0(%rsp), %r8
leaq 0x88(%rsp), %r9
pushq 0x100(%rsp)
leaq 0x88(%rsp), %rax
pushq %rax
callq 0x53888
addq $0x10, %rsp
movq 0xa0(%rsp), %rax
movq 0x60(%rsp), %rcx
testb %r13b, %r13b
je 0x53fe9
cmpq %rcx, %rax
jle 0x5407c
leaq 0x2417b0(%rip), %rcx    # 0x295758
cmpq 0x218(%rcx), %rax
jl 0x5407c
movq 0x80(%rsp), %rax
cmpq 0x88(%rsp), %rax
jle 0x5407c
movl $0x1, %ecx
leaq 0x241781(%rip), %rdx    # 0x295758
cmpq 0x210(%rdx), %rax
jge 0x54081
jmp 0x5407c
cmpq %rcx, %rax
jle 0x5407c
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
addq %rax, %rcx
xorps %xmm1, %xmm1
cvtsi2sd %rcx, %xmm1
mulsd 0x1dd593(%rip), %xmm1   # 0x2315a0
ucomisd %xmm1, %xmm0
jbe 0x5407c
leaq 0x24173e(%rip), %rcx    # 0x295758
cmpq 0x218(%rcx), %rax
jl 0x5407c
cmpq 0x38(%rsp), %rax
jl 0x5407c
movq 0x80(%rsp), %rax
movq 0x88(%rsp), %rcx
cmpq %rcx, %rax
jle 0x5407c
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
addq %rax, %rcx
xorps %xmm1, %xmm1
cvtsi2sd %rcx, %xmm1
mulsd 0x1dd546(%rip), %xmm1   # 0x2315a0
ucomisd %xmm1, %xmm0
jbe 0x5407c
leaq 0x2416f1(%rip), %rcx    # 0x295758
cmpq 0x210(%rcx), %rax
jl 0x5407c
movl $0x1, %ecx
cmpq 0x38(%rsp), %rax
jge 0x54081
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movl %ecx, 0x1c(%r15,%r14,8)
incq %r12
cmpq %r12, %rbx
jne 0x53f46
movabsq $-0x100000001, %rax     # imm = 0xFFFFFFFEFFFFFFFF
cmpq %rax, 0x20(%rsp)
movq 0x28(%rsp), %rcx
jbe 0x540c0
movq 0x10(%rsp), %rdi
incq %rdi
cmpq 0x8(%rsp), %rdi
jne 0x53e91
jmp 0x54276
movq 0xf8(%rsp), %rax
movq 0x10(%rax), %rax
leaq (%rax,%rcx,8), %rax
leaq -0x1(%rbx), %rcx
leaq -0x2(%rbx), %rdx
xorl %r9d, %r9d
movq %r9, %rsi
movq (%rax,%r9,8), %rdi
leaq (%rdi,%rdi,4), %rdi
movslq 0x1c(%r15,%rdi,8), %r8
incq %r9
cmpq %rbx, %r9
jge 0x54153
movl 0x20(%r15,%rdi,8), %r10d
movq 0x8(%rax,%rsi,8), %r11
leaq (%r11,%r11,4), %rdi
movl %r10d, %ebp
subl 0x20(%r15,%rdi,8), %ebp
cmpl $0x1, %ebp
jne 0x54153
movl $0x1, %r9d
movq %rsi, %rdi
movq $-0x1, %r13
leaq (%r11,%r11,4), %r11
cmpl $-0x1, 0x1c(%r15,%r11,8)
cmoveq %r13, %r8
cmpq %rdi, %rdx
je 0x5418b
movq 0x10(%rax,%rdi,8), %r11
leaq (%r11,%r11,4), %r14
movl %r10d, %r12d
subl 0x20(%r15,%r14,8), %r12d
incq %rdi
incq %r9
cmpq %r12, %r9
je 0x5411e
leaq 0x1(%rdi), %r9
jmp 0x54156
movq %rsi, %rdi
cmpq $-0x1, %r8
jne 0x5417d
cmpq %rdi, %rsi
jg 0x5417d
incq %rdi
movq (%rax,%rsi,8), %r8
leaq (%r8,%r8,4), %r8
movl $0xffffffff, 0x1c(%r15,%r8,8) # imm = 0xFFFFFFFF
incq %rsi
cmpq %rsi, %rdi
jne 0x54164
cmpq %rbx, %r9
jl 0x540db
jmp 0x540a8
movq %rcx, %rdi
movq %rbx, %r9
jmp 0x54156
cmpq %rbx, %r11
movq 0xf8(%rsp), %r9
jle 0x54276
movq %rbx, %r8
movabsq $-0x200000000, %rbx     # imm = 0xFFFFFFFE00000000
movq 0x10(%r10), %rax
movq (%rax,%r8,8), %r14
movl %r14d, %r12d
movl $0x1, %ecx
cmpq %rbx, %r14
jb 0x54231
movq %r8, %r13
movq 0x10(%r9), %rax
movq (%rax,%r12,8), %rsi
leaq (%rsi,%rsi,4), %rax
leaq (%r15,%rax,8), %rdi
movq 0x40(%rsp), %rdx
callq 0x537d5
movq 0xf8(%rsp), %r9
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
testq %rax, %rax
jne 0x54215
movq 0x10(%r9), %rax
movq (%rax,%r12,8), %rax
leaq (%rax,%rax,4), %rax
movl 0x8(%r15,%rax,8), %eax
cmpq 0x38(%rsp), %rax
movl $0x0, %ecx
sbbl %ecx, %ecx
orl $0x1, %ecx
movabsq $-0x100000001, %rax     # imm = 0xFFFFFFFEFFFFFFFF
cmpq %rax, %r14
movq %r13, %r8
movq 0x18(%rsp), %r10
movq 0x8(%rsp), %r11
ja 0x5426a
notq %r14
shrq $0x20, %r14
shlq $0x3, %r12
addq 0x10(%r9), %r12
xorl %eax, %eax
movq (%r12,%rax,8), %rdx
leaq (%rdx,%rdx,4), %rdx
movl 0x8(%r15,%rdx,8), %edi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
cmpq %rdi, 0x38(%rsp)
ja 0x5425d
movl %ecx, %esi
movl %esi, 0x1c(%r15,%rdx,8)
incq %rax
cmpq %rax, %r14
jne 0x54242
incq %r8
cmpq %r11, %r8
jne 0x541b1
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq