// File: /workspace/github_cpp_makefile_star2_O1/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 $0x88, %rsp
movq %rdx, 0x40(%rsp)
testq %rsi, %rsi
jle 0x54e6e
movq %r9, %r14
movq %rcx, %r12
movq %rsi, %r13
movq %rdi, %rbp
movsd %xmm0, 0x10(%rsp)
movq 0xd8(%rsp), %rbx
xorl %r15d, %r15d
movq %rcx, %rdi
xorl %edx, %edx
movq %r8, 0x8(%rsp)
callq 0x3f828
movq 0x8(%rsp), %rdi
movq %r15, (%rbx)
movq %r15, (%rdi)
movq (%r12), %rax
movq %rax, 0x20(%rsp)
movq 0x8(%r12), %rsi
movq 0x20(%r12), %rax
movq %rax, 0x30(%rsp)
testq %r14, %r14
jg 0x54707
movq 0xc0(%rsp), %rax
cqto
idivq 0xc8(%rsp)
movq %rax, %r14
movq %r14, %xmm0
punpckldq 0x1d0b2c(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1d0b34(%rip), %xmm0   # 0x225250
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x10(%rsp), %xmm1
cvttsd2si %xmm1, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x1d0b26(%rip), %xmm1   # 0x225268
cvttsd2si %xmm1, %rdx
andq %rcx, %rdx
orq %rax, %rdx
movq 0xd0(%rsp), %rax
cmpq %rax, %rdx
cmovbeq %rax, %rdx
movq %rdx, 0x38(%rsp)
cmpq $0x2, %r13
movl $0x1, %eax
movq %r13, 0x28(%rsp)
cmovgeq %r13, %rax
movq %rax, 0x60(%rsp)
leaq -0x28(%rbp), %r14
movq $-0x1, %r12
xorl %r13d, %r13d
movq $0x0, 0x18(%rsp)
movq %rbp, 0x10(%rsp)
movq 0x30(%rsp), %rcx
movq %rsi, 0x48(%rsp)
testq %r13, %r13
je 0x54835
leaq (,%r13,4), %rax
addq %r13, %rax
leaq (%rbp,%rax,8), %rbp
movl $0x1, %ebx
movq $-0x1, %r15
movq %r14, 0x70(%rsp)
movq %r12, 0x68(%rsp)
movq %rbp, %rdi
movq %r13, %rsi
movq %r14, %rdx
movq %r12, %rcx
movq 0x40(%rsp), %r8
xorl %r9d, %r9d
callq 0x8792b
movq %rax, %rcx
negq %rcx
jo 0x54805
movq 0x20(%rsp), %rcx
movslq (%rcx,%r12,4), %rcx
addq %rcx, %rax
cmpq %rbx, %rax
cmovgq %rax, %rbx
cmovgq %r12, %r15
leaq -0x1(%r12), %rax
incq %r12
addq $-0x28, %r14
cmpq $0x1, %r12
movq %rax, %r12
jg 0x547cd
movq 0x10(%rsp), %rbp
movq 0x8(%rsp), %rdi
movq 0x30(%rsp), %rcx
movq 0x70(%rsp), %r14
movq 0x68(%rsp), %r12
jmp 0x54841
movl $0x1, %ebx
movq $-0x1, %r15
movq 0x20(%rsp), %rax
movl %ebx, (%rax,%r13,4)
movq 0x48(%rsp), %rsi
movq %r15, (%rsi,%r13,8)
movl $0x0, (%rcx,%r13,4)
movslq (%rax,%r13,4), %rax
movq 0x18(%rsp), %rdx
cmpq %rax, %rdx
cmovgeq %rax, %rdx
movq %rdx, 0x18(%rsp)
incq %r13
incq %r12
addq $0x28, %r14
cmpq 0x60(%rsp), %r13
jne 0x5479e
movq 0x28(%rsp), %r13
cmpq $0x2, %r13
movl $0x1, %ebx
cmovgeq %r13, %rbx
xorl %r14d, %r14d
movl $0x2, %r15d
movq 0x18(%rsp), %rbp
movq 0x20(%rsp), %rax
movl (%rax,%r14,4), %r12d
subl %ebp, %r12d
movl %r12d, (%rax,%r14,4)
movq 0x8(%rdi), %rax
cmpq %rax, (%rdi)
jne 0x548e3
leaq (%rax,%rax), %rsi
testq %rax, %rax
cmoveq %r15, %rsi
movq %rsi, 0x8(%rdi)
movq 0x10(%rdi), %rdi
shlq $0x3, %rsi
callq 0x2370
movq 0x8(%rsp), %rdi
movq %rax, 0x10(%rdi)
notl %r12d
shlq $0x20, %r12
orq %r14, %r12
movq (%rdi), %rax
movq 0x10(%rdi), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%rdi)
movq %r12, (%rcx,%rax,8)
incq %r14
cmpq %r14, %rbx
jne 0x548a5
movq (%rdi), %rax
movq 0x10(%rdi), %rdi
leaq (%rdi,%rax,8), %rsi
callq 0x45d47
movq 0xd8(%rsp), %r8
cmpq %r13, 0x8(%r8)
jae 0x5497f
leaq -0x1(%r13), %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(%r8)
movq 0x10(%r8), %rdi
leaq 0x8(,%rcx,8), %rsi
callq 0x2370
movq 0xd8(%rsp), %r8
movq %rax, 0x10(%r8)
cmpq $0x2, %r13
movl $0x1, %r14d
cmovgeq %r13, %r14
xorl %r12d, %r12d
movl $0x2, %r13d
xorl %ebp, %ebp
movq 0x8(%rsp), %r9
movq 0x48(%rsp), %r15
movq 0x30(%rsp), %rdx
movq %rbp, %rbx
movq 0x10(%r9), %rdi
movl (%rdi,%r12,8), %eax
cmpl $0x0, (%rdx,%rax,4)
jne 0x549d3
movq 0x10(%r8), %rcx
movq %rax, (%rcx,%rbp,8)
incq %rbp
movl $0x1, (%rdx,%rax,4)
movq (%r15,%rax,8), %rax
testq %rax, %rax
jns 0x549b2
cmpq %rbp, %rbx
je 0x54a3c
movq 0x8(%r9), %rax
cmpq %rax, (%r9)
jne 0x54a0a
leaq (%rax,%rax), %rsi
testq %rax, %rax
cmoveq %r13, %rsi
movq %rsi, 0x8(%r9)
shlq $0x3, %rsi
callq 0x2370
movq 0x8(%rsp), %r9
movq 0xd8(%rsp), %r8
movq %rax, 0x10(%r9)
movl %ebx, %eax
subl %ebp, %eax
shlq $0x20, %rax
movabsq $-0x100000001, %rcx     # imm = 0xFFFFFFFEFFFFFFFF
addq %rcx, %rax
incq %rax
orq %rbx, %rax
movq (%r9), %rcx
movq 0x10(%r9), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, (%r9)
movq %rax, (%rdx,%rcx,8)
movq 0x30(%rsp), %rdx
incq %r12
cmpq %r14, %r12
jne 0x549a7
movq (%r9), %rax
movq 0x10(%r9), %rcx
movq 0x28(%rsp), %r13
leaq (%rcx,%r13,8), %rdi
leaq (%rcx,%rax,8), %rsi
callq 0x45d47
movq 0x8(%rsp), %r9
movq (%r9), %rax
cmpq $0x0, 0xe0(%rsp)
movq %rax, 0x18(%rsp)
je 0x54d91
cmpq %r13, %rax
movq 0x10(%rsp), %r12
jle 0x54e6e
movq 0x10(%r9), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
movq (%rax,%r13,8), %r8
movl %r8d, %edi
movq %r8, %r14
notq %r14
shrq $0x20, %r14
movabsq $-0x200000000, %rax     # imm = 0xFFFFFFFE00000000
cmpq %rax, %r8
movq 0xd8(%rsp), %rcx
movq %rdi, 0x20(%rsp)
movq %r13, 0x28(%rsp)
jae 0x54b0b
leaq (,%rdi,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(%r12,%rsi,8), %esi
addl $0x8, %esi
leaq (%rdx,%rdx,4), %rdx
cmpl 0x20(%r12,%rdx,8), %esi
jb 0x54b10
incq %rcx
cmpq %rcx, %r14
jne 0x54adc
movl $0x1, %eax
jmp 0x54b13
xorl %r13d, %r13d
jmp 0x54b1a
movq %r14, %rax
cmpl $0x2, %eax
setae %r13b
movabsq $-0x100000001, %rax     # imm = 0xFFFFFFFEFFFFFFFF
movq %r8, %r15
cmpq %rax, %r8
movq 0x10(%rsp), %rax
ja 0x54c8f
movq 0x20(%rsp), %rcx
leaq (,%rcx,8), %rbp
movq 0xd8(%rsp), %rcx
addq 0x10(%rcx), %rbp
xorl %r12d, %r12d
movq (%rbp,%r12,8), %rsi
leaq (%rsi,%rsi,4), %rbx
leaq (%rax,%rbx,8), %rdi
movq 0x40(%rsp), %rdx
leaq 0x80(%rsp), %rcx
leaq 0x78(%rsp), %r8
leaq 0x58(%rsp), %r9
pushq 0xe0(%rsp)
leaq 0x58(%rsp), %rax
pushq %rax
callq 0x5459d
addq $0x10, %rsp
movq 0x78(%rsp), %rax
movq 0x80(%rsp), %rcx
testb %r13b, %r13b
je 0x54be8
cmpq %rcx, %rax
jle 0x54c75
leaq 0x235bab(%rip), %rcx    # 0x28a758
cmpq 0x218(%rcx), %rax
jl 0x54c75
movq 0x50(%rsp), %rax
cmpq 0x58(%rsp), %rax
jle 0x54c75
movl $0x1, %ecx
leaq 0x235b82(%rip), %rdx    # 0x28a758
cmpq 0x210(%rdx), %rax
jge 0x54c7a
jmp 0x54c75
cmpq %rcx, %rax
jle 0x54c75
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
addq %rax, %rcx
xorps %xmm1, %xmm1
cvtsi2sd %rcx, %xmm1
mulsd 0x1d0894(%rip), %xmm1   # 0x2254a0
ucomisd %xmm1, %xmm0
jbe 0x54c75
leaq 0x235b3f(%rip), %rcx    # 0x28a758
cmpq 0x218(%rcx), %rax
jl 0x54c75
cmpq 0x38(%rsp), %rax
jl 0x54c75
movq 0x50(%rsp), %rax
movq 0x58(%rsp), %rcx
cmpq %rcx, %rax
jle 0x54c75
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
addq %rax, %rcx
xorps %xmm1, %xmm1
cvtsi2sd %rcx, %xmm1
mulsd 0x1d084d(%rip), %xmm1   # 0x2254a0
ucomisd %xmm1, %xmm0
jbe 0x54c75
leaq 0x235af8(%rip), %rcx    # 0x28a758
cmpq 0x210(%rcx), %rax
jl 0x54c75
movl $0x1, %ecx
cmpq 0x38(%rsp), %rax
jge 0x54c7a
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq 0x10(%rsp), %rax
movl %ecx, 0x1c(%rax,%rbx,8)
incq %r12
cmpq %r12, %r14
jne 0x54b51
movabsq $-0x100000001, %rcx     # imm = 0xFFFFFFFEFFFFFFFF
cmpq %rcx, %r15
movq 0x28(%rsp), %r13
movq %rax, %r12
movq $-0x1, %rbp
jbe 0x54cc0
incq %r13
cmpq 0x18(%rsp), %r13
jne 0x54a94
jmp 0x54e6e
movq 0xd8(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x20(%rsp), %rcx
leaq (%rax,%rcx,8), %rax
leaq -0x1(%r14), %rcx
leaq -0x2(%r14), %rdx
xorl %r9d, %r9d
movq %r9, %rsi
movq (%rax,%r9,8), %rdi
leaq (%rdi,%rdi,4), %rdi
movslq 0x1c(%r12,%rdi,8), %r8
incq %r9
cmpq %r14, %r9
jge 0x54d51
movl 0x20(%r12,%rdi,8), %r10d
movq 0x8(%rax,%rsi,8), %r11
leaq (%r11,%r11,4), %rdi
movl %r10d, %ebx
subl 0x20(%r12,%rdi,8), %ebx
cmpl $0x1, %ebx
jne 0x54d51
movl $0x1, %r9d
movq %rsi, %rdi
leaq (%r11,%r11,4), %r11
cmpl $-0x1, 0x1c(%r12,%r11,8)
cmoveq %rbp, %r8
cmpq %rdi, %rdx
je 0x54d89
movq 0x10(%rax,%rdi,8), %r11
leaq (%r11,%r11,4), %rbx
movl %r10d, %r15d
subl 0x20(%r12,%rbx,8), %r15d
incq %rdi
incq %r9
cmpq %r15, %r9
je 0x54d1c
leaq 0x1(%rdi), %r9
jmp 0x54d54
movq %rsi, %rdi
cmpq $-0x1, %r8
jne 0x54d7b
cmpq %rdi, %rsi
jg 0x54d7b
incq %rdi
movq (%rax,%rsi,8), %r8
leaq (%r8,%r8,4), %r8
movl $0xffffffff, 0x1c(%r12,%r8,8) # imm = 0xFFFFFFFF
incq %rsi
cmpq %rsi, %rdi
jne 0x54d62
cmpq %r14, %r9
jl 0x54ce0
jmp 0x54cad
movq %rcx, %rdi
movq %r14, %r9
jmp 0x54d54
cmpq %r13, %rax
movq 0x10(%rsp), %r15
movq 0xd8(%rsp), %r8
movq 0x38(%rsp), %rbp
jle 0x54e6e
movabsq $-0x200000000, %rbx     # imm = 0xFFFFFFFE00000000
movq 0x10(%r9), %rax
movq (%rax,%r13,8), %r14
movl %r14d, %r12d
movl $0x1, %ecx
cmpq %rbx, %r14
jb 0x54e1a
movq 0x10(%r8), %rax
movq (%rax,%r12,8), %rsi
leaq (%rsi,%rsi,4), %rax
leaq (%r15,%rax,8), %rdi
movq 0x40(%rsp), %rdx
callq 0x544f8
movq 0x8(%rsp), %r9
movq 0xd8(%rsp), %r8
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
testq %rax, %rax
jne 0x54e1a
movq 0x10(%r8), %rax
movq (%rax,%r12,8), %rax
leaq (%rax,%rax,4), %rax
movl 0x8(%r15,%rax,8), %eax
cmpq %rbp, %rax
movl $0x0, %ecx
sbbl %ecx, %ecx
orl $0x1, %ecx
movabsq $-0x100000001, %rax     # imm = 0xFFFFFFFEFFFFFFFF
cmpq %rax, %r14
ja 0x54e60
notq %r14
shrq $0x20, %r14
shlq $0x3, %r12
addq 0x10(%r8), %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, %rbp
ja 0x54e53
movl %ecx, %esi
movl %esi, 0x1c(%r15,%rdx,8)
incq %rax
cmpq %rax, %r14
jne 0x54e3a
incq %r13
cmpq 0x18(%rsp), %r13
jne 0x54db6
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq