// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/Hash_Table.cpp
// Function: lchain_qdp_mcopy_fast(Candidates_list*, long, long, long, Chain_Data*, overlap_region_alloc*, long, long, long, double, double, double, unsigned int, long, long, long, unsigned int, long, long, double, long, long)
uint64_t lchain_qdp_mcopy_fast(Candidates_list *cl, int64_t a_idx, int64_t a_n, int64_t des_idx, 
              Chain_Data* dp, overlap_region_alloc* res, int64_t max_skip, int64_t max_iter, 
              int64_t max_dis, double chn_pen_gap, double chn_pen_skip, double bw_rate, 
              uint32_t xid, int64_t xl, int64_t yl, int64_t quick_check, uint32_t apend_be, 
              int64_t gen_cigar, int64_t mcopy_num, double mcopy_rate, int64_t mcopy_khit_cutoff, 
              int64_t khit_n)
{
    if(a_n <= 0) return 0;
    int64_t *p, *t, max_f, n_skip, st, max_j, end_j, sc, msc, msc_i, max_ii, ovl, movl, plus = 0, min_sc, ch_n, si, ei; 
    int32_t *f, max, tmp, *ii; int64_t i, k, j, cL = 0; k_mer_hit* a; k_mer_hit* des; k_mer_hit *swap; overlap_region *z;
    resize_Chain_Data(dp, a_n, NULL); ch_n = 1; // int64_t bw; bw = ((xl < yl)?xl:yl); bw *= bw_rate;
    t = dp->tmp; f = dp->score; p = dp->pre; ii = dp->occ;
    
    a = cl->list + a_idx; des = cl->list + des_idx;
    // if(a_n && a[0].readID == 0) {
    //     fprintf(stderr, "---[M::%s::utg%.6dl::%c]\n", 
    //                     __func__, (int32_t)a[0].readID+1, "+-"[a[0].strand]);
    // }
    if(quick_check) {
        quick_ck_lchain(a, a_n, xl, yl, chn_pen_gap, chn_pen_skip, bw_rate, p, t, f, ii, &plus, &msc, &msc_i, &movl, &si, &ei);
    } else {
        msc = msc_i = INT32_MIN; movl = INT32_MAX; plus = 0; si = 0; ei = a_n;
        memset(t, 0, (a_n*sizeof((*t))));
    }   
    // if(a_n && a[0].readID == 4412344) {
    //     fprintf(stderr, "[M::%s::] si::%ld, ei::%ld, a_n::%ld\n", __func__, si, ei, a_n);
    // }
    for (i = st = si, max_ii = -1; i < ei; ++i) {
        max_f = a[i].cnt&(0xffu); 
        n_skip = 0; max_j = end_j = -1;
        if ((i-st) > max_iter) st = i-max_iter;
        while (a[i].strand != a[st].strand) ++st;

        for (j = i - 1; j >= st; --j) {
            sc = comput_sc_ch_ec(&a[i], &a[j], bw_rate, chn_pen_gap, chn_pen_skip, xl, yl);
            if (sc == INT32_MIN) continue;
            sc += f[j];
            if (sc > max_f) {
                max_f = sc, max_j = j;
                if (n_skip > 0) --n_skip;
            } else if (t[j] == (int32_t)i) {
                if (++n_skip > max_skip)
                    break;
            }
            if (p[j] >= 0) t[p[j]] = i;
        }
        end_j = j;

        if ((max_ii<0) || (a[i].self_offset>a[max_ii].self_offset+max_dis) || (a[i].strand!=a[max_ii].strand)) {
            max = INT32_MIN; max_ii = -1;
            for (j=i-1; (j>=st) && (a[i].self_offset<=max_dis+a[j].self_offset)&&(a[i].strand==a[j].strand); --j) {
                if (max < f[j]) {
                    max = f[j], max_ii = j;
                }
            }
        }

        if ((max_ii >= 0) && (max_ii < end_j) && (a[i].strand == a[max_ii].strand)) {///just have a try with a[i]<->a[max_ii]
            tmp = comput_sc_ch_ec(&a[i], &a[max_ii], bw_rate, chn_pen_gap, chn_pen_skip, xl, yl);
            if (tmp != INT32_MIN && max_f < tmp + f[max_ii])
                max_f = tmp + f[max_ii], max_j = max_ii;
        }
        f[i] = max_f; p[i] = max_j;
        if ((max_ii < 0) || ((a[i].self_offset<=max_dis+a[max_ii].self_offset)&&(a[i].strand==a[max_ii].strand)&&(f[max_ii]<f[i]))) {
            max_ii = i;
        }
        if(f[i] >= msc) {
            ovl = get_chainLen(a[i].self_offset, a[i].self_offset, xl, a[i].offset, a[i].offset, yl);
            if(f[i] > msc || ovl < movl) {
                msc = f[i]; msc_i = i; movl = ovl;
            }
        }
        if(f[i] < plus) plus = f[i];
        ii[i] = 0;///for mcopy, not here
        // if(a_n && a[0].readID == 4412344) {
        //     fprintf(stderr, "i::%ld[M::%s::%c] q::%u, t::%u, st::%ld, max_ii::%ld, f[i]::%d, p[i]::%ld, msc_i::%ld, msc::%ld, movl::%ld\n", 
        //                     i, __func__, "+-"[a[i].strand], 
        //                     a[i].self_offset, a[i].offset, st, max_ii, f[i], p[i], msc_i, msc, movl);
        // }
    }

    for (i = msc_i, cL = 0; i >= 0; i = p[i]) { ii[i] = 1; t[cL++] = i;}///label the best chain

    if(mcopy_num > 1) {
        // if(a[0].readID == 4412344) {
        //     fprintf(stderr, "[M::%s::] msc::%ld, cL::%ld\n", __func__, msc, cL);
        // }
        if(cL >= mcopy_khit_cutoff) {///if there are too few k-mers, disable mcopy
            msc -= plus; min_sc = msc*mcopy_rate/**0.2**/; ii[msc_i] = 0;
            for (i = ch_n = 0; i < a_n; ++i) {///make all f[] positive
                f[i] -= plus; if(i >= ch_n) t[i] = 0;
                if((!(ii[i])) && (f[i] >= min_sc)) {///!(ii[i]): skip the best chain
                    t[ch_n] = ((uint64_t)f[i])<<32; t[ch_n] += (i<<1); ch_n++;
                }
            }
            // if(a[0].readID == 4412344) {
            //     fprintf(stderr, "[M::%s::] msc::%ld, min_sc::%ld, cL::%ld, ch_n::%ld, mcopy_num::%ld\n", __func__, msc, min_sc, cL, ch_n, mcopy_num);
            // }
            if(ch_n > 1) {
                int64_t n_v, n_v0, ni, n_u, n_u0 = res->length; 
                radix_sort_hc64i(t, t + ch_n);
                for (k = ch_n-1, n_v = n_u = 0; k >= 0 && n_u < mcopy_num; --k) {
                    n_v0 = n_v;
                    for (i = ((uint32_t)t[k])>>1; i >= 0 && (t[i]&1) == 0; ) {
                        ii[n_v++] = i; t[i] |= 1; i = p[i];
                    }
                    if(n_v0 == n_v) continue;
                    sc = (i<0?(t[k]>>32):((t[k]>>32)-f[i]));
                    // if(a[0].readID == 4412344) {
                    //     fprintf(stderr, "+[M::%s::] sc::%ld, n_a::%ld\n", __func__, sc, n_v-n_v0);
                    // }
                    if(sc >= min_sc) {
                        kv_pushp_ol(overlap_region, (*res), &z);
                        push_ovlp_chain_qgen(z, xid, xl, yl, sc+plus, &(a[ii[n_v-1]]), &(a[ii[n_v0]]));
                        // if(a[0].readID == 4412344) {
                        //     fprintf(stderr, "-[M::%s::] sc::%ld, n_a::%ld, q::[%u,%u), t::[%u,%u), %c\n", __func__, sc, n_v-n_v0, z->x_pos_s, z->x_pos_e + 1, z->y_pos_s, z->y_pos_e + 1, "+-"[z->y_pos_strand]);
                        // }
                        ///mcopy_khit_cutoff <= 1: disable the mcopy_khit_cutoff filtering, for the realignment
                        // if((mcopy_khit_cutoff <= 1) || ((z->x_pos_e+1-z->x_pos_s) <= (movl<<2))) {
                        if((!n_u) || (n_v - n_v0 > 1)) {
                            z->align_length = n_v-n_v0; z->x_id = n_v0;
                            n_u++;
                        } else {///non-best is tiny
                            res->length--; n_v = n_v0;
                        }
                    } else {
                        n_v = n_v0;
                    }
                }

                // if(n_u > 1) ks_introsort_or_sss(n_u, res->list + n_u0); 
                // res->length = n_u0 + filter_non_ovlp_xchains(res->list + n_u0, n_u, &n_v);
                n_u = res->length;
                if(n_u > n_u0 + 1) {
                    kv_resize_cl(k_mer_hit, (*cl), (n_v+cl->length));
                    a = cl->list + a_idx; des = cl->list + des_idx; swap = cl->list + cl->length; 
                    for (k = n_u0, i = n_v0 = n_v = 0; k < n_u; k++) {
                        z = &(res->list[k]);
                        z->non_homopolymer_errors = des_idx + i;
                        n_v0 = z->x_id; ni = z->align_length;
                        for (j = 0; j < ni; j++, i++) {
                            ///k0 + (ni - j - 1)
                            swap[i] = a[ii[n_v0 + (ni- j - 1)]]; 
                            swap[i].readID = k; 
                        }
                        z->x_id = xid; 
                        if(gen_cigar) gen_fake_cigar(&(z->f_cigar), z, apend_be, swap+i-ni, ni);
                        if(!khit_n) z->align_length = 0; 
                    }
                    memcpy(des, swap, i*sizeof((*swap))); //assert(i == ch_n);
                    
                    // fprintf(stderr, "[M::%s::msc->%ld] msc_k_hits::%u, cL::%ld, min_sc::%ld, best_sc::%ld, n_u0_sc::%d, mcopy_rate::%f, # chains::%ld\n", 
                    // __func__, msc, res->list[n_u0].align_length, cL, min_sc, msc+plus, res->list[n_u0].shared_seed,
                    // mcopy_rate, n_u-n_u0);
                } else if(n_u == n_u0 + 1) {
                    z = &(res->list[n_u0]); k = n_u0; i = 0;
                    z->non_homopolymer_errors = des_idx + i;
                    n_v0 = z->x_id; ni = z->align_length;
                    for (j = 0; j < ni; j++, i++) {
                        ///k0 + (ni - j - 1)
                        des[i] = a[ii[n_v0 + (ni- j - 1)]]; 
                        des[i].readID = k; 
                    }
                    z->x_id = xid; 
                    if(gen_cigar) gen_fake_cigar(&(z->f_cigar), z, apend_be, des+i-ni, ni);
                    if(!khit_n) z->align_length = 0; 
                }
                return i;
            } else {
                msc += plus; i = msc_i; cL = 0; 
                while (i >= 0) {t[cL++] = i; i = p[i];}
            }
        }
    }



    ///a[] has been sorted by self_offset
    // i = msc_i; cL = 0; 
    // while (i >= 0) {t[cL++] = i; i = p[i];}
    kv_pushp_ol(overlap_region, (*res), &z);
    push_ovlp_chain_qgen(z, xid, xl, yl, msc, &(a[t[cL-1]]), &(a[t[0]]));
    for (i = 0; i < cL; i++) {des[i] = a[t[cL-i-1]]; des[i].readID = res->length-1;}
    z->non_homopolymer_errors = des_idx;
    if(gen_cigar) gen_fake_cigar(&(z->f_cigar), z, apend_be, des, cL);
    if(khit_n) z->align_length = cL;
    return cL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rcx, 0x78(%rsp)
testq %rdx, %rdx
jle 0x429ac
movq %r8, %rbx
movq %rdx, %rbp
movsd %xmm0, 0xb0(%rsp)
movsd %xmm1, 0xb8(%rsp)
movsd %xmm2, 0xc0(%rsp)
movsd %xmm3, 0xf8(%rsp)
movq %r9, (%rsp)
movq %rdi, %r14
movq $0x0, 0x68(%rsp)
movq %r8, %rdi
movq %rsi, %r15
movq %rdx, %rsi
xorl %edx, %edx
callq 0x3f828
movq 0x28(%rbx), %r9
movq (%rbx), %r13
movq 0x8(%rbx), %r8
movq 0x20(%rbx), %r12
movq %r14, 0xe8(%rsp)
movq (%r14), %rax
shlq $0x4, %r15
movq %rax, 0x48(%rsp)
movq %r15, 0xa8(%rsp)
leaq (%rax,%r15), %rdi
cmpq $0x0, 0x1a0(%rsp)
movq %r12, 0x20(%rsp)
movq %rdi, 0x50(%rsp)
movq %r9, 0x18(%rsp)
movq %r8, 0x38(%rsp)
movq %rbp, 0xf0(%rsp)
je 0x429b4
leaq 0xd8(%rsp), %rax
leaq 0xe0(%rsp), %r10
leaq 0xa0(%rsp), %r11
leaq 0x70(%rsp), %rbx
leaq 0x40(%rsp), %r14
leaq 0x68(%rsp), %r15
movq %rbp, %rsi
movq 0x190(%rsp), %rdx
movq 0x198(%rsp), %rcx
movsd 0xb0(%rsp), %xmm0
movsd 0xb8(%rsp), %xmm1
movsd 0xc0(%rsp), %xmm2
pushq %rax
pushq %r10
pushq %r11
pushq %rbx
pushq %r14
pushq %r15
pushq %r12
pushq %r13
callq 0x423a9
addq $0x40, %rsp
jmp 0x429fa
xorl %r14d, %r14d
jmp 0x43899
movq $-0x80000000, %rax      # imm = 0x80000000
movq %rax, 0x70(%rsp)
movq %rax, 0x40(%rsp)
movq $0x7fffffff, 0xa0(%rsp) # imm = 0x7FFFFFFF
xorl %eax, %eax
movq %rax, 0x68(%rsp)
movq %rax, 0xe0(%rsp)
movq %rbp, 0xd8(%rsp)
leaq (,%rbp,8), %rdx
movq %r9, %rdi
xorl %esi, %esi
callq 0x20e0
movq %r13, %rbx
movq 0xe0(%rsp), %r15
movq 0xd8(%rsp), %rcx
movq 0x40(%rsp), %r14
movq 0xa0(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0x70(%rsp), %rax
movq %rax, 0xc8(%rsp)
movq 0x68(%rsp), %rdx
movq %rcx, 0x118(%rsp)
cmpq %rcx, %r15
movq %r13, 0x60(%rsp)
movsd 0xf8(%rsp), %xmm4
jge 0x430ce
movq 0x178(%rsp), %rcx
movq 0x190(%rsp), %rax
decq %rax
movq %rax, 0x100(%rsp)
movq %rcx, %rax
notq %rax
movq %rax, 0x110(%rsp)
negq %rcx
movq %rcx, 0x108(%rsp)
movq %r15, %rax
shlq $0x4, %rax
addq 0xa8(%rsp), %rax
movq 0x48(%rsp), %rcx
leaq (%rcx,%rax), %rbp
addq $-0x8, %rbp
movq $-0x1, %r9
movq %r15, %rsi
movq 0x50(%rsp), %r12
movsd 0xc0(%rsp), %xmm5
movsd 0xb8(%rsp), %xmm6
movsd 0xb0(%rsp), %xmm7
movq %rdx, 0xd0(%rsp)
movq %r15, %rcx
shlq $0x4, %rcx
leaq (%r12,%rcx), %r10
movl (%r12,%rcx), %eax
movl 0xc(%r12,%rcx), %edi
movzbl %dil, %ecx
movq %rcx, 0x10(%rsp)
movq %r15, %rcx
subq %rsi, %rcx
movq 0x178(%rsp), %rdx
cmpq %rcx, %rdx
cmovgq %rdx, %rcx
movq 0x110(%rsp), %rdx
addq %rsi, %rdx
addq %rcx, %rdx
addq 0x108(%rsp), %rsi
addq %rcx, %rsi
shlq $0x4, %rsi
addq %r12, %rsi
movq %rsi, %rcx
movq %rdx, %rsi
incq %rsi
movl (%rcx), %edx
addq $0x10, %rcx
xorl %eax, %edx
js 0x42b2d
movq %r14, 0x128(%rsp)
leaq -0x1(%r15), %r8
cmpq %rsi, %r15
movq %r10, 0x8(%rsp)
movq %r15, 0x28(%rsp)
movq %rbp, 0x98(%rsp)
movq %rdi, 0x120(%rsp)
jle 0x42d65
movl 0x8(%r10), %r14d
leal 0x1(%r14), %ecx
movq 0x190(%rsp), %rdx
movq %rcx, 0x80(%rsp)
subq %rcx, %rdx
movq %rdx, 0x130(%rsp)
movl %edi, %eax
shrl $0x8, %eax
movl %eax, 0x58(%rsp)
movslq %r15d, %rax
movq %rax, 0x88(%rsp)
movq $-0x1, 0x30(%rsp)
movq 0x10(%rsp), %r11
xorl %r12d, %r12d
movl (%rbp), %ecx
movl %r14d, %r13d
subl %ecx, %r13d
movl $0x80000000, %eax       # imm = 0x80000000
testl %r13d, %r13d
jle 0x42cd9
movl 0x4(%r10), %ebx
movl -0x4(%rbp), %edx
movl %ebx, %r15d
subl %edx, %r15d
testl %r15d, %r15d
jle 0x42cd9
movl %r15d, %r10d
subl %r13d, %r10d
movl %r10d, %edi
negl %edi
cmovsl %r10d, %edi
movq 0x8(%rsp), %r10
cmpl $0x11, %edi
jb 0x42c51
incl %ebx
movq 0x198(%rsp), %r10
subq %rbx, %r10
movq %rdx, %rbx
subq %rcx, %rbx
cmpl %edx, %ecx
movl $0x0, %ecx
cmovbeq %rcx, %rbx
movq 0x80(%rsp), %rcx
addq %r10, %rcx
cmpq %r10, 0x130(%rsp)
movq 0x8(%rsp), %r10
cmovleq 0x190(%rsp), %rcx
addq %rbx, %rcx
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
mulsd %xmm5, %xmm0
cvttsd2si %xmm0, %ecx
cmpl %ecx, %edi
jg 0x42cd9
cmpl %r13d, %r15d
movl %r13d, %ebx
cmovll %r15d, %ebx
movq 0x10(%rsp), %rax
cmpl %ebx, %eax
movl %ebx, %ecx
cmovll %eax, %ecx
movl $0x1, %eax
cmpl 0x58(%rsp), %ecx
jl 0x42c7a
movl %ecx, %eax
xorl %edx, %edx
divl 0x58(%rsp)
cmpl %r13d, %r15d
jne 0x42c85
cmpl %ebx, 0x10(%rsp)
jge 0x42cd9
xorps %xmm0, %xmm0
cvtsi2sd %edi, %xmm0
movapd %xmm0, %xmm2
mulsd %xmm7, %xmm2
cvtsi2sd %eax, %xmm3
xorps %xmm1, %xmm1
cvtsi2sd %ebx, %xmm1
divsd %xmm1, %xmm0
divsd %xmm5, %xmm0
mulsd %xmm3, %xmm0
xorl %ecx, %ecx
ucomisd %xmm2, %xmm0
seta %cl
xorl %edx, %edx
ucomisd %xmm0, %xmm2
seta %dl
cmpl $0x4, %edi
cmovbl %edx, %ecx
testb %cl, %cl
jne 0x42ccb
movapd %xmm2, %xmm0
mulsd %xmm6, %xmm1
addsd %xmm0, %xmm1
cvttsd2si %xmm1, %ecx
subl %ecx, %eax
movl %eax, %ecx
negl %ecx
jno 0x42ce4
movq %r11, %rdi
jmp 0x42d4c
cltq
movq 0x60(%rsp), %rcx
movslq (%rcx,%r8,4), %rdi
addq %rax, %rdi
cmpq %r11, %rdi
jle 0x42d09
xorl %eax, %eax
testq %r12, %r12
setg %al
subq %rax, %r12
movq %r8, 0x30(%rsp)
jmp 0x42d30
movq 0x18(%rsp), %rax
movq 0x88(%rsp), %rcx
cmpq %rcx, (%rax,%r8,8)
jne 0x42d2d
cmpq 0x170(%rsp), %r12
jge 0x430c3
incq %r12
movq %r11, %rdi
movq 0x38(%rsp), %rax
movq (%rax,%r8,8), %rax
testq %rax, %rax
js 0x42d4c
movq 0x18(%rsp), %rcx
movq 0x28(%rsp), %rdx
movq %rdx, (%rcx,%rax,8)
leaq -0x1(%r8), %rax
addq $-0x10, %rbp
movq %rdi, %r11
cmpq %rsi, %r8
movq %rax, %r8
jg 0x42bb1
jmp 0x42d76
movq $-0x1, 0x30(%rsp)
movq %r8, %rax
movq 0x10(%rsp), %rdi
testq %r9, %r9
movq 0x50(%rsp), %r12
movq 0x60(%rsp), %rbx
movq 0x28(%rsp), %r15
movq 0x180(%rsp), %r13
movq 0x98(%rsp), %rbp
js 0x42dc4
movq 0x8(%rsp), %rcx
movl 0x8(%rcx), %edx
movq %r9, %rcx
shlq $0x4, %rcx
movl 0x8(%r12,%rcx), %r8d
addq %r13, %r8
cmpq %rdx, %r8
jl 0x42dc4
addq %r12, %rcx
movl (%rcx), %ecx
movq 0x8(%rsp), %rdx
xorl (%rdx), %ecx
jns 0x42e18
movq $-0x1, %r9
cmpq %rsi, %r15
jle 0x42e18
movq 0x8(%rsp), %rcx
movl 0x8(%rcx), %ecx
movl $0x80000000, %edx       # imm = 0x80000000
movq %rbp, %r8
movq %r15, %r10
movl (%r8), %r11d
addq %r13, %r11
cmpq %rcx, %r11
jl 0x42e18
movl -0x8(%r8), %r11d
movq 0x8(%rsp), %r14
xorl (%r14), %r11d
js 0x42e18
movl -0x4(%rbx,%r10,4), %r11d
decq %r10
cmpl %r11d, %edx
cmovlq %r10, %r9
cmovlel %r11d, %edx
addq $-0x10, %r8
cmpq %rsi, %r10
jg 0x42de3
testq %r9, %r9
sets %cl
cmpq %rax, %r9
setge %al
orb %cl, %al
jne 0x42fb8
movq %r9, %r8
shlq $0x4, %r8
movl (%r12,%r8), %eax
movq 0x8(%rsp), %r10
xorl (%r10), %eax
js 0x42fbd
addq %r12, %r8
movl 0x8(%r10), %ecx
movl 0x8(%r8), %edx
movl %ecx, %r11d
subl %edx, %r11d
movl $0x80000000, %eax       # imm = 0x80000000
testl %r11d, %r11d
jle 0x42f73
movl 0x4(%r10), %ebx
movl 0x4(%r8), %r10d
movl %ebx, %ebp
subl %r10d, %ebp
testl %ebp, %ebp
jle 0x42f73
movl %ebp, %r14d
subl %r11d, %r14d
movl %r14d, %r8d
negl %r8d
cmovsl %r14d, %r8d
cmpl $0x11, %r8d
jb 0x42ee1
incl %ecx
incl %ebx
movq 0x190(%rsp), %r13
movq %r13, %r14
subq %rcx, %r14
movq 0x198(%rsp), %r15
subq %rbx, %r15
movq %r10, %rbx
subq %rdx, %rbx
cmpl %r10d, %edx
movl $0x0, %edx
cmovbeq %rdx, %rbx
addq %r15, %rcx
cmpq %r15, %r14
cmovleq %r13, %rcx
addq %rbx, %rcx
cvtsi2sd %rcx, %xmm0
mulsd %xmm5, %xmm0
cvttsd2si %xmm0, %ecx
cmpl %ecx, %r8d
jg 0x42f73
cmpl %r11d, %ebp
movl %r11d, %r10d
cmovll %ebp, %r10d
movq 0x10(%rsp), %rax
cmpl %r10d, %eax
movl %r10d, %ecx
cmovll %eax, %ecx
movq 0x120(%rsp), %rbx
shrl $0x8, %ebx
movl $0x1, %eax
cmpl %ebx, %ecx
jl 0x42f13
movl %ecx, %eax
xorl %edx, %edx
divl %ebx
cmpl %r11d, %ebp
jne 0x42f1f
cmpl %r10d, 0x10(%rsp)
jge 0x42f73
xorps %xmm0, %xmm0
cvtsi2sd %r8d, %xmm0
movapd %xmm0, %xmm2
mulsd %xmm7, %xmm2
cvtsi2sd %eax, %xmm3
cvtsi2sd %r10d, %xmm1
divsd %xmm1, %xmm0
divsd %xmm5, %xmm0
mulsd %xmm3, %xmm0
xorl %ecx, %ecx
ucomisd %xmm2, %xmm0
seta %cl
xorl %edx, %edx
ucomisd %xmm0, %xmm2
seta %dl
cmpl $0x4, %r8d
cmovbl %edx, %ecx
testb %cl, %cl
jne 0x42f65
movapd %xmm2, %xmm0
mulsd %xmm6, %xmm1
addsd %xmm0, %xmm1
cvttsd2si %xmm1, %ecx
subl %ecx, %eax
movl %eax, %ecx
negl %ecx
jno 0x42f80
movq 0x60(%rsp), %rbx
jmp 0x42fa3
movq 0x60(%rsp), %rbx
movslq (%rbx,%r9,4), %rcx
cltq
addq %rcx, %rax
cmpq %rax, %rdi
movq 0x30(%rsp), %rcx
cmovlq %r9, %rcx
movq %rcx, 0x30(%rsp)
cmovleq %rax, %rdi
movq 0x28(%rsp), %r15
movq 0x180(%rsp), %r13
movq 0x98(%rsp), %rbp
movq 0x8(%rsp), %r10
movl %edi, (%rbx,%r15,4)
movq 0x38(%rsp), %rax
movq 0x30(%rsp), %rcx
movq %rcx, (%rax,%r15,8)
testq %r9, %r9
js 0x42ffc
movl 0x8(%r10), %ecx
movq %r9, %rax
shlq $0x4, %rax
movl 0x8(%r12,%rax), %edx
addq %r13, %rdx
cmpq %rcx, %rdx
jl 0x42fff
addq %r12, %rax
movl (%rax), %eax
xorl (%r10), %eax
js 0x42fff
cmpl %edi, (%rbx,%r9,4)
jge 0x42fff
movq %r15, %r9
movslq %edi, %rax
movq 0x128(%rsp), %r14
cmpq %rax, %r14
jle 0x4301e
movq 0x20(%rsp), %r8
movq 0xd0(%rsp), %rdx
jmp 0x4309a
movl 0x4(%r10), %edx
movl 0x8(%r10), %edi
movq %rdx, %rcx
subq %rdi, %rcx
incq %rcx
movq %rdi, %r8
notq %r8
addq 0x190(%rsp), %r8
movq %rdx, %r10
notq %r10
addq 0x198(%rsp), %r10
movq %rdi, %r11
addq %r10, %r11
cmpq %r10, %r8
cmovleq 0x100(%rsp), %r11
cmpl %edx, %edi
movl $0x1, %edx
cmovbeq %rdx, %rcx
addq %r11, %rcx
cmpq %rax, %r14
movq 0x20(%rsp), %r8
movq 0xd0(%rsp), %rdx
jl 0x43087
cmpq 0x90(%rsp), %rcx
jge 0x4309a
movq %r15, 0xc8(%rsp)
movq %rcx, 0x90(%rsp)
movq %rax, %r14
cmpq %rax, %rdx
cmovlq %rdx, %rax
movl $0x0, (%r8,%r15,4)
incq %r15
addq $0x10, %rbp
movq %rax, %rdx
cmpq 0x118(%rsp), %r15
jne 0x42acd
jmp 0x430db
movq %r8, %rax
movq %r11, %rdi
jmp 0x42d76
movq %rdx, %rax
movq 0x20(%rsp), %r8
movq 0x50(%rsp), %r12
movq 0x78(%rsp), %r10
shlq $0x4, %r10
movq 0x1c0(%rsp), %rcx
movq 0x1b8(%rsp), %rbp
movq %r14, 0x40(%rsp)
movq 0x90(%rsp), %rdx
movq %rdx, 0xa0(%rsp)
movq 0xc8(%rsp), %rdx
movq %rdx, 0x70(%rsp)
movq %rax, 0x68(%rsp)
testq %rdx, %rdx
js 0x4314e
movq %rdx, %rax
xorl %r14d, %r14d
movq (%rsp), %rsi
movq 0x18(%rsp), %rdi
movq 0x38(%rsp), %r9
movl $0x1, (%r8,%rax,4)
movq %rax, (%rdi,%r14,8)
incq %r14
movq (%r9,%rax,8), %rax
testq %rax, %rax
jns 0x43134
jmp 0x4315f
xorl %r14d, %r14d
movq (%rsp), %rsi
movq 0x18(%rsp), %rdi
movq 0x38(%rsp), %r9
addq %r10, 0x48(%rsp)
cmpq $0x2, %rbp
setl %al
cmpq %rcx, %r14
setl %cl
orb %al, %cl
je 0x432d9
movq 0x8(%rsi), %rax
cmpq %rax, 0x10(%rsi)
jne 0x431e3
movq (%rsi), %rdi
imulq $0x150, %rax, %rcx      # imm = 0x150
testq %rax, %rax
movl $0x150, %esi            # imm = 0x150
cmovneq %rcx, %rsi
callq 0x2370
movq (%rsp), %rcx
movq %rax, (%rcx)
movq (%rsp), %rcx
movq 0x8(%rcx), %rcx
imulq $0xa8, %rcx, %rdi
addq %rax, %rdi
leaq (%rcx,%rcx), %rax
testq %rcx, %rcx
movl $0x2, %ebx
cmovneq %rax, %rbx
movq %rbx, %rax
subq %rcx, %rax
imulq $0xa8, %rax, %rdx
xorl %esi, %esi
callq 0x20e0
movq (%rsp), %rsi
movq %rbx, 0x8(%rsi)
movq 0x10(%rsi), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x10(%rsi)
imulq $0xa8, %rax, %r15
addq (%rsi), %r15
movq 0x40(%rsp), %r8
movq 0x18(%rsp), %rax
movq -0x8(%rax,%r14,8), %r9
shlq $0x4, %r9
addq %r12, %r9
movq 0x18(%rsp), %rax
movq (%rax), %rax
shlq $0x4, %rax
addq %r12, %rax
subq $0x8, %rsp
movq %r15, %rdi
movl 0x190(%rsp), %esi
movq 0x198(%rsp), %rdx
movq 0x1a0(%rsp), %rcx
pushq %rax
callq 0x410df
movq 0x28(%rsp), %r9
movq 0x10(%rsp), %r8
addq $0x10, %rsp
testq %r14, %r14
je 0x43292
movl $0x80000000, %eax       # imm = 0x80000000
movq 0x48(%rsp), %rcx
movq %r14, %rdx
movq -0x8(%r9,%rdx,8), %rsi
shlq $0x4, %rsi
movupd (%r12,%rsi), %xmm0
movupd %xmm0, (%rcx)
movl 0x10(%r8), %esi
decl %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
movl (%rcx), %edi
andl %eax, %edi
orl %esi, %edi
movl %edi, (%rcx)
addq $0x10, %rcx
decq %rdx
jne 0x43262
movq 0x78(%rsp), %rax
movl %eax, 0x30(%r15)
cmpq $0x0, 0x1b0(%rsp)
je 0x432c1
leaq 0x38(%r15), %rdi
movl 0x1a8(%rsp), %edx
movq %r15, %rsi
movq 0x48(%rsp), %rcx
movq %r14, %r8
callq 0x3dc52
cmpq $0x0, 0x1c8(%rsp)
je 0x43899
movl %r14d, 0x28(%r15)
jmp 0x43899
movq 0x68(%rsp), %r13
movq 0x40(%rsp), %rax
movq %rax, %rcx
subq %r13, %rcx
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
movq %rcx, 0x40(%rsp)
mulsd %xmm4, %xmm0
cvttsd2si %xmm0, %r11
movq 0x70(%rsp), %rcx
movl $0x0, (%r8,%rcx,4)
movq 0xf0(%rsp), %rdx
cmpq $0x2, %rdx
movl $0x1, %ecx
cmovgeq %rdx, %rcx
xorl %r14d, %r14d
xorl %r15d, %r15d
movl (%rbx,%r14,4), %edx
subl %r13d, %edx
movl %edx, (%rbx,%r14,4)
cmpq %r15, %r14
jl 0x4333f
movq $0x0, (%rdi,%r14,8)
cmpl $0x0, (%r8,%r14,4)
jne 0x4335d
movslq %edx, %rdx
cmpq %r11, %rdx
jl 0x4335d
shlq $0x20, %rdx
leaq (%rdx,%r14,2), %rdx
movq %rdx, (%rdi,%r15,8)
incq %r15
incq %r14
cmpq %rcx, %r14
jne 0x43327
cmpq $0x2, %r15
jl 0x4358c
movq %r11, 0x8(%rsp)
movq %r10, 0x80(%rsp)
movq 0x10(%rsi), %rax
movq %rax, 0x88(%rsp)
leaq (%rdi,%r15,8), %rsi
callq 0x3d221
testq %rbp, %rbp
jle 0x435af
movq %r13, 0x30(%rsp)
xorl %r9d, %r9d
xorl %r13d, %r13d
movq %r13, %r12
movq (%rsp), %rdi
movq 0x20(%rsp), %r11
movq 0x18(%rsp), %rsi
movq 0x198(%rsp), %rcx
movq 0x190(%rsp), %rdx
movq 0x38(%rsp), %r8
leaq -0x1(%r15), %r10
movl -0x8(%rsi,%r15,8), %r14d
shrl %r14d
movq (%rsi,%r14,8), %rax
testb $0x1, %al
jne 0x433f7
movl %r14d, (%r11,%r12,4)
incq %r12
orq $0x1, %rax
movq %rax, (%rsi,%r14,8)
movq (%r8,%r14,8), %r14
testq %r14, %r14
jns 0x433d7
movq %r12, %rbx
subq %r13, %rbx
je 0x43575
movslq 0x4(%rsi,%r10,8), %rbp
testq %r14, %r14
js 0x43419
movq 0x60(%rsp), %rax
movslq (%rax,%r14,4), %rax
subq %rax, %rbp
cmpq 0x8(%rsp), %rbp
jge 0x43430
movq %r13, %r12
movq 0x1b8(%rsp), %rbp
jmp 0x43575
movq %r10, 0x58(%rsp)
movq %r9, 0x10(%rsp)
movq 0x8(%rdi), %rax
cmpq %rax, 0x10(%rdi)
jne 0x434c3
movq (%rdi), %rdi
imulq $0x150, %rax, %rsi      # imm = 0x150
testq %rax, %rax
movl $0x150, %eax            # imm = 0x150
cmoveq %rax, %rsi
callq 0x2370
movq (%rsp), %rcx
movq %rax, (%rcx)
movq (%rsp), %rcx
movq 0x8(%rcx), %rcx
imulq $0xa8, %rcx, %rdi
addq %rax, %rdi
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
movl $0x2, %eax
cmoveq %rax, %rdx
movq %rdx, 0x28(%rsp)
movq %rdx, %rax
subq %rcx, %rax
imulq $0xa8, %rax, %rdx
xorl %esi, %esi
callq 0x20e0
movq 0x190(%rsp), %rdx
movq 0x198(%rsp), %rcx
movq 0x20(%rsp), %r11
movq (%rsp), %rdi
movq 0x28(%rsp), %rax
movq %rax, 0x8(%rdi)
movq 0x10(%rdi), %rax
leaq 0x1(%rax), %rsi
movq %rsi, 0x10(%rdi)
movq %rdi, %rsi
imulq $0xa8, %rax, %rdi
addq (%rsi), %rdi
addq 0x30(%rsp), %rbp
movslq -0x4(%r11,%r12,4), %r9
shlq $0x4, %r9
movq 0x50(%rsp), %rsi
addq %rsi, %r9
movslq (%r11,%r13,4), %rax
shlq $0x4, %rax
addq %rsi, %rax
subq $0x8, %rsp
movq %rdi, 0x30(%rsp)
movl 0x190(%rsp), %esi
movq %rbp, %r8
pushq %rax
callq 0x410df
addq $0x10, %rsp
movq 0x10(%rsp), %r9
testq %r9, %r9
je 0x43537
cmpq $0x2, %rbx
jge 0x43537
movq (%rsp), %rdi
decq 0x10(%rdi)
movq %r13, %r12
jmp 0x43549
movq 0x28(%rsp), %rax
movl %ebx, 0x28(%rax)
movl %r13d, (%rax)
incq %r9
movq (%rsp), %rdi
movq 0x20(%rsp), %r11
movq 0x18(%rsp), %rsi
movq 0x198(%rsp), %rcx
movq 0x190(%rsp), %rdx
movq 0x38(%rsp), %r8
movq 0x1b8(%rsp), %rbp
movq 0x58(%rsp), %r10
cmpq $0x2, %r15
jl 0x435bb
movq %r10, %r15
movq %r12, %r13
cmpq %rbp, %r9
jl 0x433cb
jmp 0x435bb
movq %rax, 0x40(%rsp)
movq 0x70(%rsp), %rax
xorl %r14d, %r14d
testq %rax, %rax
js 0x43179
movq %rax, (%rdi,%r14,8)
incq %r14
movq (%r9,%rax,8), %rax
jmp 0x43599
xorl %r12d, %r12d
movq (%rsp), %rdi
movq 0x20(%rsp), %r11
movq 0x10(%rdi), %rcx
movq 0x88(%rsp), %rdx
leaq 0x1(%rdx), %rax
movq %rcx, 0x10(%rsp)
cmpq %rax, %rcx
jle 0x4378d
movq 0xe8(%rsp), %rbx
addq 0x8(%rbx), %r12
cmpq %r12, 0x10(%rbx)
movq 0x1c8(%rsp), %r13
jge 0x4364e
decq %r12
movq %r12, %rax
sarq %rax
orq %r12, %rax
movq %rax, %rcx
sarq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
sarq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
sarq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
sarq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x10(%rbx)
movq (%rbx), %rdi
shlq $0x4, %rsi
callq 0x2370
movq 0x88(%rsp), %rdx
movq 0x20(%rsp), %r11
movq (%rsp), %rdi
movq %rax, (%rbx)
movq (%rbx), %rbp
movq 0x8(%rbx), %rax
addq %rbp, 0x80(%rsp)
shlq $0x4, %rax
addq %rbp, %rax
movq %rax, 0x8(%rsp)
cmpq 0x10(%rsp), %rdx
jge 0x43828
addq 0xa8(%rsp), %rbp
addq $-0x4, %r11
xorl %r14d, %r14d
movl $0x80000000, %r15d      # imm = 0x80000000
movq %r13, %rbx
movq (%rdi), %r12
imulq $0xa8, %rdx, %rax
movq 0x78(%rsp), %rcx
addl %r14d, %ecx
movl %ecx, 0x30(%r12,%rax)
movl 0x28(%r12,%rax), %r8d
testq %r8, %r8
je 0x43711
movl (%r12,%rax), %esi
movq %rdx, %r13
movl %edx, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movq %r8, %rdx
negq %rdx
shlq $0x2, %rsi
leaq (%rsi,%r8,4), %rsi
addq %r11, %rsi
movq %r14, %rdi
shlq $0x4, %rdi
addq 0x8(%rsp), %rdi
xorl %r9d, %r9d
movslq (%rsi,%r9,4), %r10
shlq $0x4, %r10
movupd (%rbp,%r10), %xmm0
movupd %xmm0, (%rdi)
movl (%rdi), %r10d
andl %r15d, %r10d
orl %ecx, %r10d
movl %r10d, (%rdi)
decq %r9
addq $0x10, %rdi
cmpq %r9, %rdx
jne 0x436dc
subq %r9, %r14
movq (%rsp), %rdi
movq %r13, %rdx
addq %rax, %r12
movl 0x188(%rsp), %eax
movl %eax, (%r12)
cmpq $0x0, 0x1b0(%rsp)
je 0x4376c
leaq 0x38(%r12), %rdi
movq %r14, %rcx
shlq $0x4, %rcx
addq 0x8(%rsp), %rcx
movq %r8, %rax
shlq $0x4, %rax
subq %rax, %rcx
movq %r12, %rsi
movq %rdx, %rbx
movl 0x1a8(%rsp), %edx
movq %r11, %r13
callq 0x3dc52
movq %rbx, %rdx
movq %r13, %r11
movq 0x1c8(%rsp), %rbx
movq (%rsp), %rdi
testq %rbx, %rbx
jne 0x4377a
movl $0x0, 0x28(%r12)
incq %rdx
cmpq 0x10(%rsp), %rdx
jne 0x4368c
jmp 0x4382b
movq 0x1c8(%rsp), %r15
jne 0x43899
movq (%rdi), %rax
imulq $0xa8, %rdx, %rcx
leaq (%rax,%rcx), %rbx
movq %rdx, %r12
movq 0x78(%rsp), %rdx
movl %edx, 0x30(%rax,%rcx)
movl 0x28(%rax,%rcx), %r8d
testq %r8, %r8
je 0x43846
movl (%rax,%rcx), %ecx
andl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
movq %r8, %rax
negq %rax
shlq $0x2, %rcx
leaq (%rcx,%r8,4), %rcx
addq %r11, %rcx
addq $-0x4, %rcx
xorl %r14d, %r14d
movl $0x80000000, %edx       # imm = 0x80000000
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %r9
movl 0x1a8(%rsp), %r10d
movslq (%rcx,%r14,4), %rdi
shlq $0x4, %rdi
movupd (%r9,%rdi), %xmm0
movupd %xmm0, (%rsi)
movl (%rsi), %edi
andl %edx, %edi
orl %r12d, %edi
movl %edi, (%rsi)
addq $0x10, %rsi
decq %r14
cmpq %r14, %rax
jne 0x437fc
negq %r14
jmp 0x43851
xorl %r14d, %r14d
movq %r14, %rdx
shlq $0x4, %rdx
movq 0x80(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x2160
jmp 0x43899
xorl %r14d, %r14d
movl 0x1a8(%rsp), %r10d
movl 0x188(%rsp), %eax
movl %eax, (%rbx)
cmpq $0x0, 0x1b0(%rsp)
je 0x4388d
leaq 0x38(%rbx), %rdi
movl %r10d, %edx
movq %r14, %rax
shlq $0x4, %rax
movq 0x48(%rsp), %rcx
addq %rax, %rcx
movq %r8, %rax
shlq $0x4, %rax
subq %rax, %rcx
movq %rbx, %rsi
callq 0x3dc52
testq %r15, %r15
jne 0x43899
movl $0x0, 0x28(%rbx)
movq %r14, %rax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq