// File: 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
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movsd %xmm0, -0x38(%rbp)
cmpq $0x0, -0x10(%rbp)
jg 0x44fb8
jmp 0x45cee
movq $0x0, -0x88(%rbp)
movq $0x0, -0xb8(%rbp)
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x226f0
movq 0x28(%rbp), %rax
movq $0x0, (%rax)
movq -0x28(%rbp), %rax
movq $0x0, (%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xa0(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0xa8(%rbp)
cmpq $0x0, -0x30(%rbp)
jle 0x45032
movq -0x30(%rbp), %rax
movq %rax, -0xe8(%rbp)
jmp 0x45043
movq 0x10(%rbp), %rax
cqto
idivq 0x18(%rbp)
movq %rax, -0xe8(%rbp)
movq -0xe8(%rbp), %rax
movq %rax, -0xb8(%rbp)
movsd -0x38(%rbp), %xmm1
movaps 0x33cfb3(%rip), %xmm2   # 0x382010
movq -0xb8(%rbp), %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
movapd 0x33cfaf(%rip), %xmm2   # 0x382020
subpd %xmm2, %xmm0
movaps %xmm0, %xmm2
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm2, %xmm0
mulsd %xmm1, %xmm0
movaps %xmm0, %xmm1
cvttsd2si %xmm1, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
movsd 0x33cf5d(%rip), %xmm1   # 0x381ff8
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
cmpq 0x20(%rbp), %rax
jae 0x450c9
movq 0x20(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x10(%rbp), %rax
jge 0x45210
movq $0x1, -0x68(%rbp)
movq $-0x1, -0x70(%rbp)
movq $0x0, -0x60(%rbp)
movq -0x48(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
cmpq -0x60(%rbp), %rax
jl 0x45199
movq -0x8(%rbp), %rdi
imulq $0x28, -0x48(%rbp), %rax
addq %rax, %rdi
movq -0x48(%rbp), %rsi
movq -0x8(%rbp), %rdx
imulq $0x28, -0x58(%rbp), %rax
addq %rax, %rdx
movq -0x58(%rbp), %rcx
movq -0x18(%rbp), %r8
xorl %eax, %eax
movl %eax, %r9d
callq 0xa1fa0
movq %rax, -0x78(%rbp)
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
cmpq %rax, -0x78(%rbp)
jne 0x45155
jmp 0x45188
movq -0xa0(%rbp), %rax
movq -0x58(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
addq -0x78(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
cmpq -0x68(%rbp), %rax
jle 0x45186
movq -0x78(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x70(%rbp)
jmp 0x45188
movq -0x58(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x45103
movq -0x68(%rbp), %rax
movl %eax, %edx
movq -0xa0(%rbp), %rax
movq -0x48(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x70(%rbp), %rdx
movq -0x40(%rbp), %rax
movq -0x48(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0xa8(%rbp), %rax
movq -0x48(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movq -0xa0(%rbp), %rax
movq -0x48(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
cmpq -0x88(%rbp), %rax
jge 0x451fd
movq -0xa0(%rbp), %rax
movq -0x48(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
movq %rax, -0x88(%rbp)
jmp 0x451ff
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x450d1
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x10(%rbp), %rax
jge 0x45337
movq -0x88(%rbp), %rsi
movq -0xa0(%rbp), %rax
movq -0x48(%rbp), %rcx
movslq (%rax,%rcx,4), %rdx
subq %rsi, %rdx
movl %edx, (%rax,%rcx,4)
movq -0xa0(%rbp), %rax
movq -0x48(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
movq %rax, -0xb0(%rbp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
subq -0xb0(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rax
shlq $0x20, %rax
movq %rax, -0xb0(%rbp)
movq -0x48(%rbp), %rax
orq -0xb0(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq -0x28(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x45300
movq -0x28(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x452bf
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0xf0(%rbp)
jmp 0x452cd
movl $0x2, %eax
movq %rax, -0xf0(%rbp)
jmp 0x452cd
movq -0xf0(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rsi
shlq $0x3, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0xb0(%rbp), %rdx
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x28(%rbp), %rsi
movq (%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, (%rsi)
movq %rdx, (%rax,%rcx,8)
jmp 0x45326
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x45218
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x28(%rbp), %rax
movq (%rax), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x2da20
movq 0x28(%rbp), %rax
movq 0x8(%rax), %rax
cmpq -0x10(%rbp), %rax
jae 0x45433
movq -0x10(%rbp), %rcx
movq 0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movq 0x28(%rbp), %rax
movq 0x8(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x8(%rax)
movq 0x28(%rbp), %rax
movq 0x8(%rax), %rcx
shrq %rcx
movq 0x28(%rbp), %rax
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq 0x28(%rbp), %rax
movq 0x8(%rax), %rcx
shrq $0x2, %rcx
movq 0x28(%rbp), %rax
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq 0x28(%rbp), %rax
movq 0x8(%rax), %rcx
shrq $0x4, %rcx
movq 0x28(%rbp), %rax
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq 0x28(%rbp), %rax
movq 0x8(%rax), %rcx
shrq $0x8, %rcx
movq 0x28(%rbp), %rax
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq 0x28(%rbp), %rax
movq 0x8(%rax), %rcx
shrq $0x10, %rcx
movq 0x28(%rbp), %rax
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq 0x28(%rbp), %rax
movq 0x8(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x8(%rax)
movq 0x28(%rbp), %rax
movq 0x10(%rax), %rdi
movq 0x28(%rbp), %rax
movq 0x8(%rax), %rsi
shlq $0x3, %rsi
callq 0x2360
movq %rax, %rcx
movq 0x28(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x45435
movq $0x0, -0x90(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x10(%rbp), %rax
jge 0x45604
movq -0x90(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
movq %rax, -0x50(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x50(%rbp)
movb %al, -0xf1(%rbp)
jl 0x454a3
movq -0xa8(%rbp), %rax
movq -0x50(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
setne %al
xorb $-0x1, %al
movb %al, -0xf1(%rbp)
movb -0xf1(%rbp), %al
testb $0x1, %al
jne 0x454af
jmp 0x454f8
movq -0x50(%rbp), %rdx
movq 0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x90(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x90(%rbp)
movq %rdx, (%rax,%rcx,8)
movq -0xa8(%rbp), %rax
movq -0x50(%rbp), %rcx
movl $0x1, (%rax,%rcx,4)
movq -0x40(%rbp), %rax
movq -0x50(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x50(%rbp)
jmp 0x4547a
movq -0x98(%rbp), %rax
cmpq -0x90(%rbp), %rax
jne 0x4550d
jmp 0x455f3
movq -0x90(%rbp), %rax
subq -0x98(%rbp), %rax
movq %rax, -0xb0(%rbp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
subq -0xb0(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rax
shlq $0x20, %rax
movq %rax, -0xb0(%rbp)
movq -0x98(%rbp), %rax
orq -0xb0(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq -0x28(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x455cd
movq -0x28(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x4558c
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0x100(%rbp)
jmp 0x4559a
movl $0x2, %eax
movq %rax, -0x100(%rbp)
jmp 0x4559a
movq -0x100(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rsi
shlq $0x3, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0xb0(%rbp), %rdx
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x28(%rbp), %rsi
movq (%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, (%rsi)
movq %rdx, (%rax,%rcx,8)
jmp 0x455f3
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x45448
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x10(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x28(%rbp), %rax
movq (%rax), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x2da20
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x80(%rbp)
cmpq $0x0, 0x30(%rbp)
jne 0x457ef
movq -0x10(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x80(%rbp), %rax
jge 0x457ea
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x50(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
movq %rax, -0x98(%rbp)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x50(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
shrq $0x20, %rcx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
subq %rcx, %rax
movq %rax, -0x90(%rbp)
movq $-0x1, -0x88(%rbp)
cmpq $0x1, -0x90(%rbp)
jle 0x456bc
movq $0x1, -0x88(%rbp)
jmp 0x4572d
movq -0x8(%rbp), %rdi
movq 0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x98(%rbp), %rcx
imulq $0x28, (%rax,%rcx,8), %rax
addq %rax, %rdi
movq 0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x98(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x18(%rbp), %rdx
callq 0x44c50
cmpq $0x0, %rax
jne 0x4572b
movq -0x8(%rbp), %rax
movq 0x28(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x98(%rbp), %rdx
imulq $0x28, (%rcx,%rdx,8), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
cmpq -0xb8(%rbp), %rax
jb 0x4572b
movq $0x1, -0x88(%rbp)
jmp 0x4572d
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x90(%rbp), %rax
jge 0x457d7
movq -0x8(%rbp), %rax
movq 0x28(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x98(%rbp), %rdx
addq -0x48(%rbp), %rdx
imulq $0x28, (%rcx,%rdx,8), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
cmpq -0xb8(%rbp), %rax
jb 0x4579e
movq -0x88(%rbp), %rax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movq 0x28(%rbp), %rdx
movq 0x10(%rdx), %rdx
movq -0x98(%rbp), %rsi
addq -0x48(%rbp), %rsi
imulq $0x28, (%rdx,%rsi,8), %rdx
addq %rdx, %rax
movl %ecx, 0x1c(%rax)
jmp 0x457c4
movq -0x8(%rbp), %rax
movq 0x28(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x98(%rbp), %rdx
addq -0x48(%rbp), %rdx
imulq $0x28, (%rcx,%rdx,8), %rcx
addq %rcx, %rax
movl $0xffffffff, 0x1c(%rax) # imm = 0xFFFFFFFF
jmp 0x457c6
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x45735
jmp 0x457d9
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x45650
jmp 0x45cee
movq -0x10(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x80(%rbp), %rax
jge 0x45cec
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x50(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
movq %rax, -0x98(%rbp)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x50(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
shrq $0x20, %rcx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
subq %rcx, %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq $0x1, -0x48(%rbp)
movq -0x48(%rbp), %rcx
xorl %eax, %eax
cmpq -0x90(%rbp), %rcx
movb %al, -0x101(%rbp)
jge 0x458c0
movq -0x8(%rbp), %rax
movq 0x28(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x98(%rbp), %rdx
addq -0x48(%rbp), %rdx
imulq $0x28, (%rcx,%rdx,8), %rcx
addq %rcx, %rax
movl 0x20(%rax), %eax
addl $0x8, %eax
movq -0x8(%rbp), %rcx
movq 0x28(%rbp), %rdx
movq 0x10(%rdx), %rdx
movq -0x98(%rbp), %rsi
addq -0x48(%rbp), %rsi
subq $0x1, %rsi
imulq $0x28, (%rdx,%rsi,8), %rdx
addq %rdx, %rcx
cmpl 0x20(%rcx), %eax
setae %al
movb %al, -0x101(%rbp)
movb -0x101(%rbp), %al
testb $0x1, %al
jne 0x458cc
jmp 0x458df
jmp 0x458ce
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x45857
movq -0x48(%rbp), %rax
cmpq -0x90(%rbp), %rax
jl 0x458f7
movq $0x1, -0xe0(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x90(%rbp), %rax
jge 0x45b64
movq -0x8(%rbp), %rdi
movq 0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x98(%rbp), %rcx
addq -0x48(%rbp), %rcx
imulq $0x28, (%rax,%rcx,8), %rax
addq %rax, %rdi
movq 0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x98(%rbp), %rcx
addq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x18(%rbp), %rdx
movq 0x30(%rbp), %rax
leaq -0xc0(%rbp), %rcx
leaq -0xc8(%rbp), %r8
leaq -0xd0(%rbp), %r9
leaq -0xd8(%rbp), %r10
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x44de0
cmpq $0x1, -0xe0(%rbp)
jle 0x45a27
movq -0xc8(%rbp), %rax
cmpq -0xc0(%rbp), %rax
jle 0x459fc
movq -0xc8(%rbp), %rax
leaq 0x37ee54(%rip), %rcx    # 0x3c47f8
cmpq 0x218(%rcx), %rax
jl 0x459fc
movq -0xd8(%rbp), %rax
cmpq -0xd0(%rbp), %rax
jle 0x459fc
movq -0xd8(%rbp), %rax
leaq 0x37ee2d(%rip), %rcx    # 0x3c47f8
cmpq 0x210(%rcx), %rax
jl 0x459fc
movq -0x8(%rbp), %rax
movq 0x28(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x98(%rbp), %rdx
addq -0x48(%rbp), %rdx
imulq $0x28, (%rcx,%rdx,8), %rcx
addq %rcx, %rax
movl $0x1, 0x1c(%rax)
jmp 0x45a22
movq -0x8(%rbp), %rax
movq 0x28(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x98(%rbp), %rdx
addq -0x48(%rbp), %rdx
imulq $0x28, (%rcx,%rdx,8), %rcx
addq %rcx, %rax
movl $0xffffffff, 0x1c(%rax) # imm = 0xFFFFFFFF
jmp 0x45b51
movq -0xc8(%rbp), %rax
cmpq -0xc0(%rbp), %rax
jle 0x45b29
cvtsi2sdq -0xc8(%rbp), %xmm0
movq -0xc8(%rbp), %rax
addq -0xc0(%rbp), %rax
cvtsi2sd %rax, %xmm1
movsd 0x33c7c9(%rip), %xmm2   # 0x382228
mulsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x45b29
movq -0xc8(%rbp), %rax
leaq 0x37ed7d(%rip), %rcx    # 0x3c47f8
cmpq 0x218(%rcx), %rax
jl 0x45b29
movq -0xc8(%rbp), %rax
cmpq -0xb8(%rbp), %rax
jl 0x45b29
movq -0xd8(%rbp), %rax
cmpq -0xd0(%rbp), %rax
jle 0x45b29
cvtsi2sdq -0xd8(%rbp), %xmm0
movq -0xd8(%rbp), %rax
addq -0xd0(%rbp), %rax
cvtsi2sd %rax, %xmm1
movsd 0x33c758(%rip), %xmm2   # 0x382228
mulsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x45b29
movq -0xd8(%rbp), %rax
leaq 0x37ed10(%rip), %rcx    # 0x3c47f8
cmpq 0x210(%rcx), %rax
jl 0x45b29
movq -0xd8(%rbp), %rax
cmpq -0xb8(%rbp), %rax
jl 0x45b29
movq -0x8(%rbp), %rax
movq 0x28(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x98(%rbp), %rdx
addq -0x48(%rbp), %rdx
imulq $0x28, (%rcx,%rdx,8), %rcx
addq %rcx, %rax
movl $0x1, 0x1c(%rax)
jmp 0x45b4f
movq -0x8(%rbp), %rax
movq 0x28(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x98(%rbp), %rdx
addq -0x48(%rbp), %rdx
imulq $0x28, (%rcx,%rdx,8), %rcx
addq %rcx, %rax
movl $0xffffffff, 0x1c(%rax) # imm = 0xFFFFFFFF
jmp 0x45b51
jmp 0x45b53
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x458ff
movq $0x0, -0x58(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x90(%rbp), %rax
jge 0x45cd9
movq -0x8(%rbp), %rax
movq 0x28(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x98(%rbp), %rdx
addq -0x48(%rbp), %rdx
imulq $0x28, (%rcx,%rdx,8), %rcx
addq %rcx, %rax
movslq 0x1c(%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rcx
xorl %eax, %eax
cmpq -0x90(%rbp), %rcx
movb %al, -0x102(%rbp)
jge 0x45c2a
movq -0x8(%rbp), %rax
movq 0x28(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x98(%rbp), %rdx
addq -0x48(%rbp), %rdx
imulq $0x28, (%rcx,%rdx,8), %rcx
addq %rcx, %rax
movl 0x20(%rax), %eax
movq -0x8(%rbp), %rcx
movq 0x28(%rbp), %rdx
movq 0x10(%rdx), %rdx
movq -0x98(%rbp), %rsi
addq -0x58(%rbp), %rsi
imulq $0x28, (%rdx,%rsi,8), %rdx
addq %rdx, %rcx
subl 0x20(%rcx), %eax
movl %eax, %eax
movq -0x58(%rbp), %rcx
subq -0x48(%rbp), %rcx
cmpq %rcx, %rax
sete %al
movb %al, -0x102(%rbp)
movb -0x102(%rbp), %al
testb $0x1, %al
jne 0x45c36
jmp 0x45c79
movq -0x8(%rbp), %rax
movq 0x28(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x98(%rbp), %rdx
addq -0x58(%rbp), %rdx
imulq $0x28, (%rcx,%rdx,8), %rcx
addq %rcx, %rax
cmpl $-0x1, 0x1c(%rax)
jne 0x45c66
movq $-0x1, -0x88(%rbp)
jmp 0x45c68
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x45bbb
cmpq $-0x1, -0x88(%rbp)
jne 0x45cca
jmp 0x45c85
movq -0x48(%rbp), %rax
cmpq -0x58(%rbp), %rax
jge 0x45cc8
movq -0x88(%rbp), %rax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movq 0x28(%rbp), %rdx
movq 0x10(%rdx), %rdx
movq -0x98(%rbp), %rsi
addq -0x48(%rbp), %rsi
imulq $0x28, (%rdx,%rsi,8), %rdx
addq %rdx, %rax
movl %ecx, 0x1c(%rax)
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x45c85
jmp 0x45cca
jmp 0x45ccc
movq -0x58(%rbp), %rax
movq %rax, -0x48(%rbp)
jmp 0x45b74
jmp 0x45cdb
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x457f7
jmp 0x45cee
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nopw (%rax,%rax)