// File: /workspace/github_cpp_makefile_star2_O3/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, 0x68(%rsp)
testq %rdx, %rdx
jle 0x42211
movq %r8, %rbx
movq %rsi, %r15
movq %rdi, %r13
movsd %xmm0, 0xb0(%rsp)
movsd %xmm1, 0xb8(%rsp)
movsd %xmm2, 0xc0(%rsp)
movsd %xmm3, 0xe0(%rsp)
movq %r9, 0x48(%rsp)
movq %rdx, %r14
movq 0x198(%rsp), %rbp
movq 0x190(%rsp), %r12
movq $0x0, 0x118(%rsp)
movq %r8, %rdi
movq %rdx, %rsi
xorl %edx, %edx
callq 0x3ecb0
movq 0x28(%rbx), %r9
movq (%rbx), %r11
movq 0x8(%rbx), %r8
movq 0x20(%rbx), %r10
movq %r13, 0xd8(%rsp)
movq (%r13), %rax
shlq $0x4, %r15
movq %rax, 0x40(%rsp)
leaq (%rax,%r15), %rdi
cmpq $0x0, 0x1a0(%rsp)
movq %r10, 0x30(%rsp)
movq %r15, 0x88(%rsp)
movq %rdi, 0x20(%rsp)
movq %r9, 0x8(%rsp)
movq %r8, 0x28(%rsp)
movq %r11, 0x50(%rsp)
movq %r14, 0xa8(%rsp)
je 0x42218
leaq 0xd0(%rsp), %rax
leaq 0x110(%rsp), %r13
leaq 0x128(%rsp), %r15
leaq 0x130(%rsp), %rbx
movq %r14, %rsi
movq %r12, %rdx
movq %rbp, %rcx
movsd 0xb0(%rsp), %xmm0
movsd 0xb8(%rsp), %xmm1
movsd 0xc0(%rsp), %xmm2
pushq %rax
pushq %r13
leaq 0x130(%rsp), %rbp
pushq %rbp
pushq %r15
pushq %rbx
leaq 0x140(%rsp), %r14
pushq %r14
pushq %r10
pushq %r11
callq 0x41baa
addq $0x40, %rsp
movq (%r13), %r12
leaq 0xd0(%rsp), %rax
movq (%rax), %r9
movq (%rbx), %r8
movq (%rbp), %rax
movq %rax, 0x98(%rsp)
movq (%r15), %rax
movq %rax, 0x90(%rsp)
movq 0x88(%rsp), %r15
movq (%r14), %r13
jmp 0x42267
xorl %ebx, %ebx
jmp 0x42f66
movq $0x0, 0x110(%rsp)
movq %r14, 0xd0(%rsp)
leaq (,%r14,8), %rdx
xorl %r13d, %r13d
movq %r9, %rdi
xorl %esi, %esi
callq 0x20e0
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, 0x98(%rsp)
movq $-0x80000000, 0x90(%rsp) # imm = 0x80000000
movq $-0x80000000, %r8       # imm = 0x80000000
movq %r14, %r9
xorl %r12d, %r12d
cmpq %r9, %r12
movsd 0xe0(%rsp), %xmm4
jge 0x4294a
movq %r13, 0x70(%rsp)
movq 0x178(%rsp), %rax
movq 0x190(%rsp), %rdx
leaq -0x1(%rdx), %rcx
movq %rcx, 0xe8(%rsp)
movq %rax, %rcx
notq %rcx
movq %rcx, 0xf8(%rsp)
negq %rax
movq %rax, 0xf0(%rsp)
movq %r12, %rax
shlq $0x4, %rax
addq %r15, %rax
movq 0x40(%rsp), %rcx
leaq (%rcx,%rax), %rbx
addq $-0x8, %rbx
movq $-0x1, 0x58(%rsp)
movq %r12, %r15
movq 0x20(%rsp), %r14
movsd 0xc0(%rsp), %xmm5
movsd 0xb8(%rsp), %xmm6
movsd 0xb0(%rsp), %xmm7
movq %r9, 0xc8(%rsp)
movq %r12, %rcx
shlq $0x4, %rcx
leaq (%r14,%rcx), %rbp
movl (%r14,%rcx), %eax
movl 0xc(%r14,%rcx), %r10d
movzbl %r10b, %r11d
movq %r12, %rcx
subq %r15, %rcx
movq 0x178(%rsp), %rsi
cmpq %rcx, %rsi
cmovgq %rsi, %rcx
movq 0xf8(%rsp), %rsi
addq %r15, %rsi
addq %rcx, %rsi
addq 0xf0(%rsp), %r15
addq %rcx, %r15
shlq $0x4, %r15
addq %r14, %r15
movq %r15, %rcx
movq %rsi, %r15
incq %r15
movl (%rcx), %esi
addq $0x10, %rcx
xorl %eax, %esi
js 0x42351
movq %r8, 0x108(%rsp)
leaq -0x1(%r12), %rdi
cmpq %r15, %r12
movq %r11, 0x60(%rsp)
movq %r12, 0x80(%rsp)
movq %rbx, 0x10(%rsp)
movq %r10, 0x100(%rsp)
jle 0x4256a
movq %r12, %rax
movl 0x8(%rbp), %r14d
leal 0x1(%r14), %esi
movq %rsi, 0x38(%rsp)
subq %rsi, %rdx
movq %rdx, 0x78(%rsp)
movl %r10d, %r12d
shrl $0x8, %r12d
cltq
movq %rax, 0xa0(%rsp)
movq $-0x1, 0x18(%rsp)
movq %rbx, %r10
movq %r11, %r9
xorl %r13d, %r13d
movl (%r10), %r8d
movl %r14d, %ebx
subl %r8d, %ebx
testl %ebx, %ebx
jle 0x4245a
movq %rbp, %rdx
movl 0x4(%rbp), %ecx
movl -0x4(%r10), %ebp
movl %ecx, %eax
subl %ebp, %eax
testl %eax, %eax
jle 0x4244f
movl %ebx, %r11d
subl %eax, %r11d
negl %r11d
movl %ebx, %esi
subl %eax, %esi
cmovbl %r11d, %esi
cmpl $0x11, %esi
jl 0x42462
incl %ecx
movq 0x198(%rsp), %r11
subq %rcx, %r11
movq %rbp, %rcx
subq %r8, %rcx
cmpl %ebp, %r8d
movl $0x0, %r8d
cmovbeq %r8, %rcx
movq 0x38(%rsp), %r8
addq %r11, %r8
cmpq %r11, 0x78(%rsp)
cmovleq 0x190(%rsp), %r8
addq %rcx, %r8
xorps %xmm0, %xmm0
cvtsi2sd %r8, %xmm0
mulsd %xmm5, %xmm0
cvttsd2si %xmm0, %ecx
cmpl %ecx, %esi
jle 0x42462
movq %r9, %r11
movq %rdx, %rbp
jmp 0x42551
movq %r9, %r11
jmp 0x42551
cmpl %ebx, %eax
cmovbl %eax, %ebx
movq 0x60(%rsp), %r8
cmpl %ebx, %r8d
movl %ebx, %ecx
cmovbl %r8d, %ecx
movl $0x1, %eax
cmpl %r12d, %ecx
jb 0x42488
movzbl %cl, %eax
divb %r12b
movzbl %al, %eax
cmpl %ebx, %r8d
jb 0x42491
testl %esi, %esi
je 0x424e8
xorps %xmm0, %xmm0
cvtsi2sd %esi, %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 %r8d, %r8d
ucomisd %xmm0, %xmm2
seta %r8b
cmpl $0x4, %esi
cmovll %r8d, %ecx
testb %cl, %cl
jne 0x424da
movapd %xmm2, %xmm0
mulsd %xmm6, %xmm1
addsd %xmm0, %xmm1
cvttsd2si %xmm1, %ecx
subl %ecx, %eax
movq 0x8(%rsp), %rcx
movq %rdx, %rbp
cltq
movq 0x50(%rsp), %rsi
movslq (%rsi,%rdi,4), %r11
addq %rax, %r11
cmpq %r9, %r11
jle 0x42515
xorl %eax, %eax
testq %r13, %r13
setg %al
subq %rax, %r13
movq %rdi, 0x18(%rsp)
jmp 0x42537
movq 0xa0(%rsp), %rax
cmpq %rax, (%rcx,%rdi,8)
jne 0x42534
cmpq 0x170(%rsp), %r13
jge 0x42798
incq %r13
movq %r9, %r11
movq 0x28(%rsp), %rax
movq (%rax,%rdi,8), %rax
testq %rax, %rax
js 0x42551
movq 0x80(%rsp), %rsi
movq %rsi, (%rcx,%rax,8)
leaq -0x1(%rdi), %rax
addq $-0x10, %r10
movq %r11, %r9
cmpq %r15, %rdi
movq %rax, %rdi
jg 0x423c9
jmp 0x42576
movq $-0x1, 0x18(%rsp)
movq %rdi, %rax
movq 0x58(%rsp), %r8
testq %r8, %r8
movq 0x20(%rsp), %r14
movq 0x50(%rsp), %r13
movq 0x80(%rsp), %r12
movq 0x180(%rsp), %rdi
js 0x425be
movl 0x8(%rbp), %edx
movq %r8, %rcx
shlq $0x4, %rcx
movl 0x8(%r14,%rcx), %esi
addq %rdi, %rsi
cmpq %rdx, %rsi
jl 0x425be
addq %r14, %rcx
movl (%rcx), %ecx
xorl (%rbp), %ecx
movq %r8, %rdx
jns 0x42610
cmpq %r15, %r12
jle 0x426f8
movl 0x8(%rbp), %r8d
movq $-0x1, %rdx
movl $0x80000000, %r9d       # imm = 0x80000000
movq 0x10(%rsp), %r10
movq %r12, %rbx
movl (%r10), %ecx
addq %rdi, %rcx
cmpq %r8, %rcx
jl 0x42610
movl -0x8(%r10), %ecx
xorl (%rbp), %ecx
js 0x42610
movl -0x4(%r13,%rbx,4), %ecx
decq %rbx
cmpl %ecx, %r9d
cmovlq %rbx, %rdx
cmovlel %ecx, %r9d
addq $-0x10, %r10
cmpq %r15, %rbx
jg 0x425e0
testq %rdx, %rdx
sets %cl
cmpq %rax, %rdx
setge %al
orb %cl, %al
jne 0x42718
movq %rdx, %rcx
shlq $0x4, %rcx
movl (%r14,%rcx), %eax
xorl (%rbp), %eax
js 0x42741
addq %r14, %rcx
movl 0x8(%rbp), %eax
movl 0x8(%rcx), %ebx
movl %eax, %r8d
subl %ebx, %r8d
testl %r8d, %r8d
jle 0x42741
movq %rbp, %rsi
movq %r12, %rbp
movq %rsi, 0x38(%rsp)
movl 0x4(%rsi), %r12d
movl 0x4(%rcx), %r14d
movl %r12d, %r10d
subl %r14d, %r10d
testl %r10d, %r10d
jle 0x426e1
movl %r8d, %ecx
subl %r10d, %ecx
negl %ecx
movl %r8d, %r9d
subl %r10d, %r9d
cmovbl %ecx, %r9d
cmpl $0x11, %r9d
jl 0x4274b
incl %eax
incl %r12d
movq 0x190(%rsp), %rdi
movq %rdi, %rcx
subq %rax, %rcx
movq 0x198(%rsp), %rsi
subq %r12, %rsi
movq %r14, %r12
subq %rbx, %r12
cmpl %r14d, %ebx
movl $0x0, %ebx
cmovbeq %rbx, %r12
addq %rsi, %rax
cmpq %rsi, %rcx
cmovleq %rdi, %rax
movq 0x180(%rsp), %rdi
addq %r12, %rax
cvtsi2sd %rax, %xmm0
mulsd %xmm5, %xmm0
cvttsd2si %xmm0, %eax
cmpl %eax, %r9d
jle 0x4274b
movq 0x20(%rsp), %r14
movq %rbp, %r12
movq 0x10(%rsp), %rbx
movq 0x38(%rsp), %rbp
jmp 0x42829
movl %r11d, (%r13,%r12,4)
movq 0x28(%rsp), %rax
movq 0x18(%rsp), %rcx
movq %rcx, (%rax,%r12,8)
movq %r12, %rax
movq 0x10(%rsp), %rbx
jmp 0x42869
movl %r11d, (%r13,%r12,4)
movq 0x28(%rsp), %rax
movq 0x18(%rsp), %rcx
movq %rcx, (%rax,%r12,8)
movq %r12, %rax
testq %rdx, %rdx
movq 0x10(%rsp), %rbx
jns 0x4283c
jmp 0x42869
movq 0x10(%rsp), %rbx
jmp 0x42829
cmpl %r8d, %r10d
cmovbl %r10d, %r8d
movq 0x60(%rsp), %rax
cmpl %r8d, %eax
movl %r8d, %ecx
cmovbl %eax, %ecx
movq 0x100(%rsp), %rsi
shrl $0x8, %esi
movl $0x1, %eax
cmpl %esi, %ecx
jb 0x4277d
movzbl %cl, %eax
divb %sil
movzbl %al, %eax
cmpl %r8d, 0x60(%rsp)
jb 0x427a3
testl %r9d, %r9d
jne 0x427a3
movq 0x20(%rsp), %r14
movq %rbp, %r12
movq 0x10(%rsp), %rbx
jmp 0x42805
movq %rdi, %rax
movq %r9, %r11
jmp 0x42576
xorps %xmm0, %xmm0
cvtsi2sd %r9d, %xmm0
movapd %xmm0, %xmm2
mulsd %xmm7, %xmm2
cvtsi2sd %eax, %xmm3
cvtsi2sd %r8d, %xmm1
divsd %xmm1, %xmm0
divsd %xmm5, %xmm0
mulsd %xmm3, %xmm0
xorl %ecx, %ecx
ucomisd %xmm2, %xmm0
seta %cl
xorl %esi, %esi
ucomisd %xmm0, %xmm2
seta %sil
cmpl $0x4, %r9d
cmovll %esi, %ecx
testb %cl, %cl
movq 0x20(%rsp), %r14
movq %rbp, %r12
movq 0x10(%rsp), %rbx
jne 0x427f7
movapd %xmm2, %xmm0
mulsd %xmm6, %xmm1
addsd %xmm0, %xmm1
cvttsd2si %xmm1, %ecx
subl %ecx, %eax
movq 0x38(%rsp), %rbp
movslq (%r13,%rdx,4), %rcx
cltq
addq %rcx, %rax
cmpq %rax, %r11
movq 0x18(%rsp), %rcx
cmovlq %rdx, %rcx
movq %rcx, 0x18(%rsp)
cmovleq %rax, %r11
movl %r11d, (%r13,%r12,4)
movq 0x28(%rsp), %rax
movq 0x18(%rsp), %rcx
movq %rcx, (%rax,%r12,8)
movl 0x8(%rbp), %ecx
movq %rdx, %rax
shlq $0x4, %rax
movl 0x8(%r14,%rax), %esi
addq %rdi, %rsi
cmpq %rcx, %rsi
jl 0x42866
addq %r14, %rax
movl (%rax), %eax
xorl (%rbp), %eax
js 0x42866
cmpl %r11d, (%r13,%rdx,4)
cmovlq %r12, %rdx
movq %rdx, %rax
movq %rax, 0x58(%rsp)
movslq %r11d, %r13
movq 0x108(%rsp), %r8
cmpq %r13, %r8
jle 0x4289d
movq 0x30(%rsp), %rsi
movq 0x8(%rsp), %rdi
movq 0x190(%rsp), %rdx
movq 0xc8(%rsp), %r9
jmp 0x4291f
movl 0x4(%rbp), %ecx
movl 0x8(%rbp), %edi
movq %rcx, %rax
subq %rdi, %rax
incq %rax
movq %rdi, %rsi
notq %rsi
movq 0x190(%rsp), %rdx
addq %rdx, %rsi
movq %rcx, %r10
notq %r10
addq 0x198(%rsp), %r10
movq %rdi, %r9
addq %r10, %r9
cmpq %r10, %rsi
cmovleq 0xe8(%rsp), %r9
cmpl %ecx, %edi
movl $0x1, %ecx
cmovbeq %rcx, %rax
addq %r9, %rax
cmpq %r13, %r8
movq 0x30(%rsp), %rsi
movq 0x8(%rsp), %rdi
movq 0xc8(%rsp), %r9
jl 0x4290c
cmpq 0x98(%rsp), %rax
jge 0x4291f
movq %r12, 0x90(%rsp)
movq %rax, 0x98(%rsp)
movq %r13, %r8
movq 0x70(%rsp), %rax
cmpq %r13, %rax
cmovlq %rax, %r13
movl $0x0, (%rsi,%r12,4)
incq %r12
addq $0x10, %rbx
movq %r13, 0x70(%rsp)
cmpq %r9, %r12
jne 0x422fe
jmp 0x4295c
movq 0x30(%rsp), %rsi
movq 0x8(%rsp), %rdi
movq 0x190(%rsp), %rdx
movq 0x68(%rsp), %r14
shlq $0x4, %r14
movq 0x1c0(%rsp), %rax
movq 0x90(%rsp), %r11
xorl %ebx, %ebx
testq %r11, %r11
js 0x429a5
movq %r11, %rcx
movq 0x28(%rsp), %r9
movq 0xa8(%rsp), %r10
movl $0x1, (%rsi,%rcx,4)
movq %rcx, (%rdi,%rbx,8)
incq %rbx
movq (%r9,%rcx,8), %rcx
testq %rcx, %rcx
jns 0x4298c
jmp 0x429ad
movq 0xa8(%rsp), %r10
addq %r14, 0x40(%rsp)
cmpq $0x2, 0x1b8(%rsp)
setl %cl
cmpq %rax, %rbx
setl %al
orb %cl, %al
jne 0x42e11
movq %r8, %rax
subq %r13, %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
mulsd %xmm4, %xmm0
cvttsd2si %xmm0, %rbx
movl $0x0, (%rsi,%r11,4)
xorl %eax, %eax
xorl %r12d, %r12d
movq 0x50(%rsp), %r9
movl (%r9,%rax,4), %ecx
subl %r13d, %ecx
movl %ecx, (%r9,%rax,4)
cmpq %r12, %rax
jl 0x42a0d
movq $0x0, (%rdi,%rax,8)
cmpl $0x0, (%rsi,%rax,4)
jne 0x42a2a
movslq %ecx, %rcx
cmpq %rbx, %rcx
jl 0x42a2a
shlq $0x20, %rcx
leaq (%rcx,%rax,2), %rcx
movq %rcx, (%rdi,%r12,8)
incq %r12
incq %rax
cmpq %r10, %rax
jne 0x429f5
cmpq $0x2, %r12
jl 0x42df5
movq %rbx, 0x60(%rsp)
movq %r14, 0x58(%rsp)
movq 0x48(%rsp), %rax
movq 0x10(%rax), %rbp
leaq (%rdi,%r12,8), %rsi
callq 0x3c6fd
movq 0x8(%rsp), %rcx
movq 0x30(%rsp), %r11
xorl %edi, %edi
xorl %r15d, %r15d
movq %r15, %r14
movq 0x28(%rsp), %rdx
movq 0x1b8(%rsp), %rsi
movq %rbp, 0x78(%rsp)
leaq -0x1(%r12), %r10
movl -0x8(%rcx,%r12,8), %ebx
shrl %ebx
movq (%rcx,%rbx,8), %rax
testb $0x1, %al
jne 0x42aa8
movl %ebx, (%r11,%r14,4)
incq %r14
orq $0x1, %rax
movq %rax, (%rcx,%rbx,8)
movq (%rdx,%rbx,8), %rbx
testq %rbx, %rbx
jns 0x42a88
movq %r14, %r9
subq %r15, %r9
je 0x42acd
movslq 0x4(%rcx,%r10,8), %r8
testq %rbx, %rbx
js 0x42ac6
movq 0x50(%rsp), %rax
movslq (%rax,%rbx,4), %rax
subq %rax, %r8
cmpq 0x60(%rsp), %r8
jge 0x42ad5
movq %r15, %r14
jmp 0x42c23
movq %r9, 0x38(%rsp)
movq %r10, 0x18(%rsp)
movq %rdi, 0x80(%rsp)
movq 0x48(%rsp), %rbp
movq (%rbp), %rdi
movq 0x10(%rbp), %rax
cmpq 0x8(%rbp), %rax
jne 0x42b79
imulq $0x150, %rax, %rsi      # imm = 0x150
testq %rax, %rax
movl $0x150, %eax            # imm = 0x150
cmoveq %rax, %rsi
movq %r8, 0xa0(%rsp)
callq 0x2370
movq %rax, 0x10(%rsp)
movq %rax, (%rbp)
movq 0x8(%rbp), %rdx
imulq $0xa8, %rdx, %rdi
addq %rax, %rdi
leaq (%rdx,%rdx), %rax
testq %rdx, %rdx
movl $0x2, %ecx
cmoveq %rcx, %rax
movq %rax, 0x70(%rsp)
movq %rax, %rcx
subq %rdx, %rcx
imulq $0xa8, %rcx, %rdx
xorl %esi, %esi
callq 0x20e0
movq 0x10(%rsp), %rdi
movq 0xa0(%rsp), %r8
movq 0x30(%rsp), %r11
movq 0x70(%rsp), %rax
movq %rax, 0x8(%rbp)
movq 0x10(%rbp), %rax
movq 0x198(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x10(%rbp)
imulq $0xa8, %rax, %rbp
addq %rdi, %rbp
addq %r13, %r8
movslq -0x4(%r11,%r14,4), %r9
shlq $0x4, %r9
movq 0x20(%rsp), %rdx
addq %rdx, %r9
movslq (%r11,%r15,4), %rax
shlq $0x4, %rax
addq %rdx, %rax
subq $0x8, %rsp
movq %rbp, %rdi
movl 0x190(%rsp), %esi
movq 0x198(%rsp), %rdx
pushq %rax
callq 0x408f3
addq $0x10, %rsp
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
movq 0x38(%rsp), %rax
je 0x42bf8
cmpq $0x2, %rax
jge 0x42bf8
movq 0x48(%rsp), %rax
decq 0x10(%rax)
movq %r15, %r14
jmp 0x42c02
movl %eax, 0x28(%rbp)
movl %r15d, (%rbp)
incq %rdi
movq 0x30(%rsp), %r11
movq 0x8(%rsp), %rcx
movq 0x28(%rsp), %rdx
movq 0x78(%rsp), %rbp
movq 0x1b8(%rsp), %rsi
movq 0x18(%rsp), %r10
cmpq $0x2, %r12
jl 0x42c38
movq %r10, %r12
movq %r14, %r15
cmpq %rsi, %rdi
jl 0x42a7c
movq 0x48(%rsp), %r13
movq 0x10(%r13), %rcx
leaq 0x1(%rbp), %rax
movq %rcx, 0x50(%rsp)
cmpq %rax, %rcx
jle 0x42f7b
movq 0xd8(%rsp), %rbx
movq (%rbx), %rax
movq 0x8(%rbx), %r12
addq %r12, %r14
cmpq %r14, 0x10(%rbx)
jge 0x42cbe
decq %r14
movq %r14, %rcx
sarq %rcx
orq %r14, %rcx
movq %rcx, %rdx
sarq $0x2, %rdx
orq %rcx, %rdx
movq %rdx, %rcx
sarq $0x4, %rcx
orq %rdx, %rcx
movq %rcx, %rdx
sarq $0x8, %rdx
orq %rcx, %rdx
movq %rdx, %rsi
sarq $0x10, %rsi
orq %rdx, %rsi
incq %rsi
movq %rsi, 0x10(%rbx)
shlq $0x4, %rsi
movq %rax, %rdi
callq 0x2370
movq 0x30(%rsp), %r11
movq %rax, (%rbx)
movq 0x8(%rbx), %r12
movq 0x88(%rsp), %r15
addq %rax, %r15
addq %rax, 0x58(%rsp)
shlq $0x4, %r12
addq %rax, %r12
addq $-0x4, %r11
xorl %ebx, %ebx
movl $0x80000000, %r14d      # imm = 0x80000000
movq %r12, 0x8(%rsp)
movq (%r13), %r13
imulq $0xa8, %rbp, %rax
movq 0x68(%rsp), %rcx
addl %ebx, %ecx
movl %ecx, 0x30(%r13,%rax)
movl 0x28(%r13,%rax), %r8d
testq %r8, %r8
je 0x42d5f
movl (%r13,%rax), %esi
movl %ebp, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movq %r8, %rdx
negq %rdx
shlq $0x2, %rsi
leaq (%rsi,%r8,4), %rsi
addq %r11, %rsi
movq %rbx, %rdi
shlq $0x4, %rdi
addq %r12, %rdi
xorl %r9d, %r9d
movslq (%rsi,%r9,4), %r10
shlq $0x4, %r10
movupd (%r15,%r10), %xmm0
movupd %xmm0, (%rdi)
movl (%rdi), %r10d
andl %r14d, %r10d
orl %ecx, %r10d
movl %r10d, (%rdi)
decq %r9
addq $0x10, %rdi
cmpq %r9, %rdx
jne 0x42d32
subq %r9, %rbx
addq %rax, %r13
movl 0x188(%rsp), %eax
movl %eax, (%r13)
cmpq $0x0, 0x1b0(%rsp)
je 0x42db6
leaq 0x38(%r13), %rdi
movq %rbx, %rcx
shlq $0x4, %rcx
addq %r12, %rcx
movq %r8, %rax
shlq $0x4, %rax
subq %rax, %rcx
movq %r13, %rsi
movl 0x1a8(%rsp), %edx
movq %rbp, %r12
movq %r15, %rbp
movq %r11, %r15
callq 0x3d133
movq %r15, %r11
movq %rbp, %r15
movq %r12, %rbp
movq 0x8(%rsp), %r12
cmpq $0x0, 0x1c8(%rsp)
jne 0x42dc9
movl $0x0, 0x28(%r13)
incq %rbp
cmpq 0x50(%rsp), %rbp
movq 0x48(%rsp), %r13
jne 0x42ce6
movq %rbx, %rdx
shlq $0x4, %rdx
movq 0x58(%rsp), %rdi
movq %r12, %rsi
callq 0x2160
jmp 0x42f66
xorl %ebx, %ebx
testq %r11, %r11
js 0x42e11
movq 0x28(%rsp), %rax
movq %r11, (%rdi,%rbx,8)
incq %rbx
movq (%rax,%r11,8), %r11
testq %r11, %r11
jns 0x42e01
movq 0x48(%rsp), %r13
movq (%r13), %r12
movq 0x10(%r13), %rax
cmpq 0x8(%r13), %rax
jne 0x42e94
imulq $0x150, %rax, %rcx      # imm = 0x150
testq %rax, %rax
movl $0x150, %esi            # imm = 0x150
cmovneq %rcx, %rsi
movq %r12, %rdi
movq %r8, %r15
callq 0x2370
movq %rax, %r12
movq %rax, (%r13)
movq 0x8(%r13), %rax
imulq $0xa8, %rax, %rdi
addq %r12, %rdi
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %r14d
cmovneq %rcx, %r14
movq %r14, %rcx
subq %rax, %rcx
imulq $0xa8, %rcx, %rdx
xorl %esi, %esi
callq 0x20e0
movq %r15, %r8
movq 0x190(%rsp), %rdx
movq 0x8(%rsp), %rdi
movq %r14, 0x8(%r13)
movq 0x10(%r13), %rax
movq 0x198(%rsp), %rcx
leaq 0x1(%rax), %rsi
movq %rsi, 0x10(%r13)
imulq $0xa8, %rax, %r15
addq %r12, %r15
movq -0x8(%rdi,%rbx,8), %r9
shlq $0x4, %r9
movq 0x20(%rsp), %r14
addq %r14, %r9
movq (%rdi), %rax
shlq $0x4, %rax
addq %r14, %rax
subq $0x8, %rsp
movq %r15, %rdi
movl 0x190(%rsp), %esi
pushq %rax
callq 0x408f3
movq 0x18(%rsp), %r8
addq $0x10, %rsp
testq %rbx, %rbx
je 0x42f28
movl $0x80000000, %eax       # imm = 0x80000000
movq 0x40(%rsp), %rcx
movq %rbx, %rdx
movq -0x8(%r8,%rdx,8), %rsi
shlq $0x4, %rsi
movupd (%r14,%rsi), %xmm0
movupd %xmm0, (%rcx)
movl 0x10(%r13), %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 0x42ef8
movq 0x68(%rsp), %rax
movl %eax, 0x30(%r15)
cmpq $0x0, 0x1b0(%rsp)
je 0x42f57
leaq 0x38(%r15), %rdi
movl 0x1a8(%rsp), %edx
movq %r15, %rsi
movq 0x40(%rsp), %rcx
movq %rbx, %r8
callq 0x3d133
cmpq $0x0, 0x1c8(%rsp)
je 0x42f66
movl %ebx, 0x28(%r15)
movq %rbx, %rax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jne 0x42f66
movq (%r13), %rax
imulq $0xa8, %rbp, %rcx
leaq (%rax,%rcx), %r14
movq 0x68(%rsp), %rdx
movl %edx, 0x30(%rax,%rcx)
movl 0x28(%rax,%rcx), %ebx
testq %rbx, %rbx
movq 0x20(%rsp), %r8
je 0x42fe4
movl (%rax,%rcx), %eax
andl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
leaq (%r11,%rax,4), %rax
addq $-0x4, %rax
movl $0x80000000, %ecx       # imm = 0x80000000
movq %rbx, %rdx
movq 0x40(%rsp), %rsi
movslq (%rax,%rdx,4), %rdi
shlq $0x4, %rdi
movupd (%r8,%rdi), %xmm0
movupd %xmm0, (%rsi)
movl (%rsi), %edi
andl %ecx, %edi
orl %ebp, %edi
movl %edi, (%rsi)
addq $0x10, %rsi
decq %rdx
jne 0x42fc1
movl 0x188(%rsp), %eax
movl %eax, (%r14)
cmpq $0x0, 0x1b0(%rsp)
je 0x43014
leaq 0x38(%r14), %rdi
movl 0x1a8(%rsp), %edx
movq %r14, %rsi
movq 0x40(%rsp), %rcx
movq %rbx, %r8
callq 0x3d133
cmpq $0x0, 0x1c8(%rsp)
jne 0x42f66
movl $0x0, 0x28(%r14)
jmp 0x42f66