// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/Hash_Table.cpp
// Function: lchain_qdp_mcopy(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(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 enable_mcopy, 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, bw, max_ii, ovl, movl, plus = 0, min_sc, ch_n; 
    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);
    t = dp->tmp; f = dp->score; p = dp->pre; ii = dp->occ;
    bw = ((xl < yl)?xl:yl); bw *= bw_rate;
    msc = msc_i = INT32_MIN; movl = INT32_MAX; ch_n = 1;
    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]);
    // }

    memset(t, 0, (a_n*sizeof((*t))));
    for (i = st = plus = 0, max_ii = -1; i < a_n; ++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(&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) {///just have a try with a[i]<->a[max_ii]
            tmp = comput_sc_ch(&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 == 0) {
        //     fprintf(stderr, "i::%ld[M::%s::utg%.6dl::%c] x::%u, y::%u, st::%ld, max_ii::%ld, f[i]::%d, p[i]::%ld, msc_i::%ld, msc::%ld, movl::%ld\n", 
        //                     i, __func__, (int32_t)a[i].readID+1, "+-"[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((movl < xl) && enable_mcopy/**(movl < yl)**/) {
        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)) {
                    t[ch_n] = ((uint64_t)f[i])<<32; t[ch_n] += (i<<1); ch_n++;
                }
            }
            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; --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(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]]));
                        ///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))) {
                            z->align_length = n_v-n_v0; z->x_id = n_v0;
                            n_u++;
                        } else {///non-best is too long
                            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 $0x118, %rsp            # imm = 0x118
movq %rcx, 0x60(%rsp)
testq %rdx, %rdx
jle 0x41c52
movq %r8, %rbx
movq %rdx, %rcx
movq %rsi, %rax
movq %rdi, %r12
movsd %xmm3, 0xa0(%rsp)
movq %r9, 0x8(%rsp)
movq 0x158(%rsp), %r15
movq %r8, %rdi
movq %rdx, %rsi
xorl %edx, %edx
movq %rax, %r14
movq %rcx, %rbp
movsd %xmm2, 0xd0(%rsp)
movsd %xmm1, 0xc8(%rsp)
movsd %xmm0, 0xc0(%rsp)
callq 0x3f828
movq 0x28(%rbx), %rdi
movq (%rbx), %rax
movq %rax, 0x30(%rsp)
movq 0x8(%rbx), %rax
movq %rax, 0x20(%rsp)
movq 0x20(%rbx), %rax
movq %rax, 0x10(%rsp)
movq %r12, 0xb8(%rsp)
movq (%r12), %rbx
shlq $0x4, %r14
leaq (%rbx,%r14), %r13
movq %rbp, 0x80(%rsp)
leaq (,%rbp,8), %rdx
movq %rdi, 0x18(%rsp)
xorl %esi, %esi
callq 0x20e0
movsd 0xc0(%rsp), %xmm6
movsd 0xc8(%rsp), %xmm5
movsd 0xd0(%rsp), %xmm4
movq 0x170(%rsp), %rax
decq %rax
movq %rax, 0xd8(%rsp)
movq %r15, %rax
notq %rax
movq %rax, 0xe8(%rsp)
negq %r15
movq %r15, 0xe0(%rsp)
movq %rbx, 0x58(%rsp)
movq %r14, 0xa8(%rsp)
leaq (%rbx,%r14), %rsi
addq $-0x8, %rsi
movq $-0x80000000, %r12      # imm = 0x80000000
movq $-0x1, 0xb0(%rsp)
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, 0x50(%rsp)
xorl %r10d, %r10d
xorl %r8d, %r8d
xorl %ebx, %ebx
movq $-0x80000000, 0x68(%rsp) # imm = 0x80000000
movq %r13, 0x88(%rsp)
movq %rbx, 0xf8(%rsp)
movq %r10, %rcx
shlq $0x4, %rcx
leaq (%rcx,%r13), %rdi
movl (%r13,%rcx), %eax
movl 0xc(%r13,%rcx), %r9d
movzbl %r9b, %ecx
movq %rcx, 0x40(%rsp)
movq %r10, %rcx
subq %r8, %rcx
movq 0x158(%rsp), %rdx
cmpq %rcx, %rdx
cmovgq %rdx, %rcx
movq 0xe8(%rsp), %rdx
addq %r8, %rdx
addq %rcx, %rdx
addq 0xe0(%rsp), %r8
addq %rcx, %r8
shlq $0x4, %r8
addq %r13, %r8
movq %r8, %rcx
movq %rdx, %r8
incq %r8
movl (%rcx), %edx
addq $0x10, %rcx
xorl %eax, %edx
js 0x416a8
movq %r12, 0x100(%rsp)
leaq -0x1(%r10), %r15
cmpq %r8, %r10
movq %r10, 0x48(%rsp)
movq %rdi, 0x28(%rsp)
movq %rsi, 0x90(%rsp)
movq %r9, 0xf0(%rsp)
jle 0x418c4
movq %r10, %rcx
movl 0x8(%rdi), %r10d
leal 0x1(%r10), %edx
movq 0x170(%rsp), %rdi
movq %rdx, 0x110(%rsp)
subq %rdx, %rdi
movq %rdi, 0x108(%rsp)
movl %r9d, %eax
shrl $0x8, %eax
movl %eax, 0x70(%rsp)
movslq %ecx, %rax
movq %rax, 0x98(%rsp)
movq $-0x1, 0x38(%rsp)
movq %rsi, %r13
movq 0x40(%rsp), %r14
movq %r15, %r9
xorl %ebx, %ebx
movl (%r13), %ecx
movl %r10d, %r12d
subl %ecx, %r12d
movl $0x80000000, %eax       # imm = 0x80000000
testl %r12d, %r12d
jle 0x41838
movq 0x28(%rsp), %rdx
movl 0x4(%rdx), %ebp
movl -0x4(%r13), %edx
movl %ebp, %esi
subl %edx, %esi
testl %esi, %esi
jle 0x41838
movl %esi, %r11d
subl %r12d, %r11d
movl %r11d, %edi
negl %edi
cmovsl %r11d, %edi
cmpl $0x11, %edi
jb 0x417ca
incl %ebp
movq 0x178(%rsp), %r11
subq %rbp, %r11
movq %rdx, %rbp
subq %rcx, %rbp
cmpl %edx, %ecx
movl $0x0, %ecx
cmovbeq %rcx, %rbp
movq 0x110(%rsp), %rcx
addq %r11, %rcx
cmpq %r11, 0x108(%rsp)
cmovleq 0x170(%rsp), %rcx
addq %rbp, %rcx
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
mulsd %xmm4, %xmm0
cvttsd2si %xmm0, %ecx
cmpl %ecx, %edi
jg 0x41838
cmpl %r12d, %esi
movl %r12d, %ebp
cmovll %esi, %ebp
movq 0x40(%rsp), %rax
cmpl %ebp, %eax
movl %ebp, %ecx
cmovll %eax, %ecx
movl $0x1, %eax
cmpl 0x70(%rsp), %ecx
jl 0x417f2
movl %ecx, %eax
xorl %edx, %edx
divl 0x70(%rsp)
cmpl %r12d, %esi
jne 0x417fd
cmpl %ebp, 0x40(%rsp)
jge 0x41838
xorps %xmm0, %xmm0
cvtsi2sd %edi, %xmm0
movapd %xmm0, %xmm1
xorps %xmm2, %xmm2
cvtsi2sd %eax, %xmm2
mulsd %xmm6, %xmm1
xorps %xmm3, %xmm3
cvtsi2sd %ebp, %xmm3
divsd %xmm3, %xmm0
divsd %xmm4, %xmm0
mulsd %xmm2, %xmm0
minsd %xmm1, %xmm0
mulsd %xmm5, %xmm3
addsd %xmm0, %xmm3
cvttsd2si %xmm3, %ecx
subl %ecx, %eax
movl %eax, %ecx
negl %ecx
jno 0x41843
movq %r14, %r12
jmp 0x418ab
cltq
movq 0x30(%rsp), %rcx
movslq (%rcx,%r9,4), %r12
addq %rax, %r12
cmpq %r14, %r12
jle 0x41868
xorl %eax, %eax
testq %rbx, %rbx
setg %al
subq %rax, %rbx
movq %r9, 0x38(%rsp)
jmp 0x4188f
movq 0x18(%rsp), %rax
movq 0x98(%rsp), %rcx
cmpq %rcx, (%rax,%r9,8)
jne 0x4188c
cmpq 0x150(%rsp), %rbx
jge 0x41bfa
incq %rbx
movq %r14, %r12
movq 0x20(%rsp), %rax
movq (%rax,%r9,8), %rax
testq %rax, %rax
js 0x418ab
movq 0x18(%rsp), %rcx
movq 0x48(%rsp), %rdx
movq %rdx, (%rcx,%rax,8)
leaq -0x1(%r9), %rax
addq $-0x10, %r13
movq %r12, %r14
cmpq %r8, %r9
movq %rax, %r9
jg 0x41735
jmp 0x418d5
movq $-0x1, 0x38(%rsp)
movq %r15, %rax
movq 0x40(%rsp), %r12
movq 0xb0(%rsp), %r11
testq %r11, %r11
movq 0x88(%rsp), %r13
movq 0x20(%rsp), %r9
movq 0x160(%rsp), %r14
movq 0x48(%rsp), %r10
movq 0x28(%rsp), %rbx
js 0x41921
movl 0x8(%rbx), %edx
movq %r11, %rcx
shlq $0x4, %rcx
movl 0x8(%r13,%rcx), %esi
addq %r14, %rsi
cmpq %rdx, %rsi
jl 0x41921
addq %r13, %rcx
movl (%rcx), %ecx
xorl (%rbx), %ecx
jns 0x41970
movq $-0x1, %r11
cmpq %r8, %r10
jle 0x41970
movl 0x8(%rbx), %ecx
movl $0x80000000, %edx       # imm = 0x80000000
movq 0x90(%rsp), %rdi
movl (%rdi), %esi
addq %r14, %rsi
cmpq %rcx, %rsi
jl 0x41970
movl -0x8(%rdi), %esi
xorl (%rbx), %esi
js 0x41970
movq 0x30(%rsp), %rsi
movl (%rsi,%r15,4), %esi
cmpl %esi, %edx
cmovlq %r15, %r11
cmovlel %esi, %edx
leaq -0x1(%r15), %rsi
addq $-0x10, %rdi
cmpq %r8, %r15
movq %rsi, %r15
jg 0x4193d
testq %r11, %r11
sets %cl
cmpq %rax, %r11
setge %al
orb %cl, %al
jne 0x41ae4
movq %r11, %rdi
shlq $0x4, %rdi
movl 0x8(%rbx), %ecx
movl 0x8(%r13,%rdi), %edx
movl %ecx, %r9d
subl %edx, %r9d
movl $0x80000000, %eax       # imm = 0x80000000
movq %r11, %rbp
testl %r9d, %r9d
jle 0x41a9a
addq %r13, %rdi
movl 0x4(%rbx), %r11d
movl 0x4(%rdi), %edi
movl %r11d, %r10d
subl %edi, %r10d
testl %r10d, %r10d
jle 0x41a9a
movl %r10d, %esi
subl %r9d, %esi
movl %esi, %ebx
negl %ebx
cmovsl %esi, %ebx
cmpl $0x11, %ebx
jb 0x41a2a
incl %ecx
incl %r11d
movq 0x170(%rsp), %r15
movq %r15, %rsi
subq %rcx, %rsi
movq 0x178(%rsp), %r14
subq %r11, %r14
movq %rdi, %r11
subq %rdx, %r11
cmpl %edi, %edx
movl $0x0, %edx
cmovbeq %rdx, %r11
addq %r14, %rcx
cmpq %r14, %rsi
movq 0x160(%rsp), %r14
cmovleq %r15, %rcx
addq %r11, %rcx
cvtsi2sd %rcx, %xmm0
mulsd %xmm4, %xmm0
cvttsd2si %xmm0, %ecx
cmpl %ecx, %ebx
jg 0x41a9a
cmpl %r9d, %r10d
movl %r9d, %edi
cmovll %r10d, %edi
movq 0x40(%rsp), %rax
cmpl %edi, %eax
movl %edi, %ecx
cmovll %eax, %ecx
movq 0xf0(%rsp), %rsi
shrl $0x8, %esi
movl $0x1, %eax
cmpl %esi, %ecx
jl 0x41a5a
movl %ecx, %eax
xorl %edx, %edx
divl %esi
cmpl %r9d, %r10d
jne 0x41a65
cmpl %edi, 0x40(%rsp)
jge 0x41a9a
xorps %xmm0, %xmm0
cvtsi2sd %ebx, %xmm0
movapd %xmm0, %xmm1
cvtsi2sd %eax, %xmm2
mulsd %xmm6, %xmm1
cvtsi2sd %edi, %xmm3
divsd %xmm3, %xmm0
divsd %xmm4, %xmm0
mulsd %xmm2, %xmm0
minsd %xmm1, %xmm0
mulsd %xmm5, %xmm3
addsd %xmm0, %xmm3
cvttsd2si %xmm3, %ecx
subl %ecx, %eax
movl %eax, %ecx
negl %ecx
jno 0x41aaf
movq 0x20(%rsp), %r9
movq 0x48(%rsp), %r10
movq %rbp, %r11
jmp 0x41adf
movq 0x30(%rsp), %rcx
movq %rbp, %r11
movslq (%rcx,%rbp,4), %rcx
cltq
addq %rcx, %rax
cmpq %rax, %r12
movq 0x38(%rsp), %rcx
cmovlq %rbp, %rcx
movq %rcx, 0x38(%rsp)
cmovleq %rax, %r12
movq 0x20(%rsp), %r9
movq 0x48(%rsp), %r10
movq 0x28(%rsp), %rbx
movq 0x30(%rsp), %rax
movl %r12d, (%rax,%r10,4)
movq 0x38(%rsp), %rax
movq %rax, (%r9,%r10,8)
testq %r11, %r11
js 0x41b26
movl 0x8(%rbx), %ecx
movq %r11, %rax
shlq $0x4, %rax
movl 0x8(%r13,%rax), %edx
addq %r14, %rdx
cmpq %rcx, %rdx
jl 0x41b29
addq %r13, %rax
movl (%rax), %eax
xorl (%rbx), %eax
js 0x41b29
movq 0x30(%rsp), %rax
cmpl %r12d, (%rax,%r11,4)
jge 0x41b29
movq %r10, %r11
movq %r11, 0xb0(%rsp)
movslq %r12d, %rbx
movq 0x100(%rsp), %r12
cmpq %rbx, %r12
jle 0x41b53
movq 0x80(%rsp), %rcx
movq 0x90(%rsp), %rsi
jmp 0x41bcc
movq 0x28(%rsp), %rax
movl 0x4(%rax), %ecx
movl 0x8(%rax), %edx
movq %rcx, %rax
subq %rdx, %rax
incq %rax
movq %rdx, %rsi
notq %rsi
addq 0x170(%rsp), %rsi
movq %rcx, %rdi
notq %rdi
addq 0x178(%rsp), %rdi
movq %rdx, %r9
addq %rdi, %r9
cmpq %rdi, %rsi
cmovleq 0xd8(%rsp), %r9
cmpl %ecx, %edx
movl $0x1, %ecx
cmovbeq %rcx, %rax
addq %r9, %rax
cmpq %rbx, %r12
movq 0x80(%rsp), %rcx
movq 0x90(%rsp), %rsi
jl 0x41bbf
cmpq 0x50(%rsp), %rax
jge 0x41bcc
movq %r10, 0x68(%rsp)
movq %rbx, %r12
movq %rax, 0x50(%rsp)
movq 0xf8(%rsp), %rax
cmpq %rbx, %rax
cmovlq %rax, %rbx
movq 0x10(%rsp), %rax
movl $0x0, (%rax,%r10,4)
incq %r10
addq $0x10, %rsi
cmpq %rcx, %r10
jne 0x41647
jmp 0x41c05
movq %r9, %rax
movq %r14, %r12
jmp 0x418d5
movq 0x60(%rsp), %r15
shlq $0x4, %r15
movq 0x68(%rsp), %rax
xorl %r14d, %r14d
testq %rax, %rax
js 0x41c5a
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %r8
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %r9
movsd 0xa0(%rsp), %xmm1
movl $0x1, (%r8,%rax,4)
movq %rax, (%rdi,%r14,8)
incq %r14
movq (%r9,%rax,8), %rax
testq %rax, %rax
jns 0x41c38
jmp 0x41c77
xorl %r14d, %r14d
jmp 0x42394
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %r8
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %r9
movsd 0xa0(%rsp), %xmm1
addq %r15, 0x58(%rsp)
movq 0x50(%rsp), %rax
cmpq 0x170(%rsp), %rax
setge %al
cmpq $0x0, 0x198(%rsp)
sete %cl
orb %al, %cl
cmpq 0x1a0(%rsp), %r14
setl %al
orb %cl, %al
movq 0x68(%rsp), %rax
je 0x41e0b
movq 0x8(%rsi), %rax
cmpq %rax, 0x10(%rsi)
jne 0x41d24
movq (%rsi), %rdi
imulq $0x150, %rax, %rcx      # imm = 0x150
testq %rax, %rax
movl $0x150, %esi            # imm = 0x150
cmovneq %rcx, %rsi
callq 0x2370
movq 0x8(%rsp), %rcx
movq %rax, (%rcx)
movq 0x8(%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 0x18(%rsp), %rdi
movq 0x8(%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 -0x8(%rdi,%r14,8), %r9
shlq $0x4, %r9
addq %r13, %r9
movq (%rdi), %rax
shlq $0x4, %rax
addq %r13, %rax
movq %rax, (%rsp)
movq %r15, %rdi
movl 0x168(%rsp), %esi
movq 0x170(%rsp), %rdx
movq 0x178(%rsp), %rcx
movq %r12, %r8
callq 0x410df
movq 0x18(%rsp), %r10
movq 0x8(%rsp), %r8
testq %r14, %r14
movq 0x58(%rsp), %rcx
je 0x41dc9
movl $0x80000000, %eax       # imm = 0x80000000
movq %rcx, %r9
movq %r14, %rdx
movq -0x8(%r10,%rdx,8), %rsi
shlq $0x4, %rsi
movupd (%r13,%rsi), %xmm0
movupd %xmm0, (%r9)
movl 0x10(%r8), %esi
decl %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
movl (%r9), %edi
andl %eax, %edi
orl %esi, %edi
movl %edi, (%r9)
addq $0x10, %r9
decq %rdx
jne 0x41d95
movq 0x60(%rsp), %rax
movl %eax, 0x30(%r15)
cmpq $0x0, 0x190(%rsp)
je 0x41df3
leaq 0x38(%r15), %rdi
movl 0x188(%rsp), %edx
movq %r15, %rsi
movq %r14, %r8
callq 0x3dc52
cmpq $0x0, 0x1a8(%rsp)
je 0x42394
movl %r14d, 0x28(%r15)
jmp 0x42394
movq %r12, %r11
subq %rbx, %r12
xorps %xmm0, %xmm0
cvtsi2sd %r12, %xmm0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %r14
movl $0x0, (%r8,%rax,4)
movq 0x80(%rsp), %rcx
cmpq $0x2, %rcx
movl $0x1, %eax
cmovgeq %rcx, %rax
xorl %ecx, %ecx
xorl %r12d, %r12d
movq 0x30(%rsp), %r10
movl (%r10,%rcx,4), %edx
subl %ebx, %edx
movl %edx, (%r10,%rcx,4)
cmpq %r12, %rcx
jl 0x41e60
movq $0x0, (%rdi,%rcx,8)
cmpl $0x0, (%r8,%rcx,4)
jne 0x41e7e
movslq %edx, %rdx
cmpq %r14, %rdx
jl 0x41e7e
shlq $0x20, %rdx
leaq (%rdx,%rcx,2), %rdx
movq %rdx, (%rdi,%r12,8)
incq %r12
incq %rcx
cmpq %rax, %rcx
jne 0x41e49
cmpq $0x1, %r12
jle 0x4229d
movq %r14, 0x40(%rsp)
movq %r15, 0x38(%rsp)
movq 0x10(%rsi), %rax
movq %rax, 0x98(%rsp)
leaq (%rdi,%r12,8), %rsi
callq 0x3d221
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %rcx
movq 0x10(%rsp), %rsi
movq $0x0, 0x78(%rsp)
shlq $0x2, 0x50(%rsp)
movq $0x0, 0x48(%rsp)
xorl %r10d, %r10d
movq %r12, %r15
decq %r12
movl -0x8(%rcx,%r15,8), %r14d
shrl %r14d
movq %r10, %rbp
movq (%rcx,%r14,8), %rax
testb $0x1, %al
jne 0x41f0a
movl %r14d, (%rsi,%rbp,4)
incq %rbp
orq $0x1, %rax
movq %rax, (%rcx,%r14,8)
movq (%rdi,%r14,8), %r14
testq %r14, %r14
jns 0x41eea
cmpq %r10, %rbp
jne 0x41f17
movq %rbp, %r10
jmp 0x42081
movslq 0x4(%rcx,%r12,8), %r8
testq %r14, %r14
js 0x41f2d
movq 0x30(%rsp), %rax
movslq (%rax,%r14,4), %rax
subq %rax, %r8
movq 0x8(%rsp), %rdx
cmpq 0x40(%rsp), %r8
jl 0x42081
movq 0x8(%rdx), %rax
cmpq %rax, 0x10(%rdx)
movq %r10, 0x28(%rsp)
jne 0x41fc3
movq (%rdx), %rdi
imulq $0x150, %rax, %rsi      # imm = 0x150
testq %rax, %rax
movl $0x150, %eax            # imm = 0x150
cmoveq %rax, %rsi
movq %r8, 0x70(%rsp)
callq 0x2370
movq 0x8(%rsp), %rcx
movq %rax, (%rcx)
movq 0x8(%rsp), %rcx
movq 0x8(%rcx), %rcx
imulq $0xa8, %rcx, %rdi
addq %rax, %rdi
leaq (%rcx,%rcx), %r13
testq %rcx, %rcx
movl $0x2, %eax
cmoveq %rax, %r13
movq %r13, %rax
subq %rcx, %rax
imulq $0xa8, %rax, %rdx
xorl %esi, %esi
callq 0x20e0
movq 0x28(%rsp), %r10
movq 0x70(%rsp), %r8
movq 0x10(%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r13, 0x8(%rdx)
movq 0x10(%rdx), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x10(%rdx)
imulq $0xa8, %rax, %r13
addq (%rdx), %r13
addq %rbx, %r8
movslq -0x4(%rsi,%rbp,4), %r9
shlq $0x4, %r9
movq 0x88(%rsp), %rcx
addq %rcx, %r9
movslq (%rsi,%r10,4), %rax
shlq $0x4, %rax
addq %rcx, %rax
movq %rax, (%rsp)
movq %r13, %rdi
movl 0x168(%rsp), %esi
movq 0x170(%rsp), %rdx
movq 0x178(%rsp), %rcx
callq 0x410df
cmpq $0x2, 0x1a0(%rsp)
jl 0x42059
movl 0x8(%r13), %eax
subl 0x4(%r13), %eax
incl %eax
cmpq %rax, 0x50(%rsp)
jge 0x42059
movq 0x8(%rsp), %rax
decq 0x10(%rax)
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rcx
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %r10
jmp 0x42081
movl %ebp, %eax
movq 0x28(%rsp), %rcx
subl %ecx, %eax
movl %eax, 0x28(%r13)
movl %ecx, (%r13)
incq 0x48(%rsp)
movq %rbp, %r10
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rcx
movq 0x20(%rsp), %rdi
cmpq $0x1, %r15
jg 0x41ed9
movq %r10, 0x78(%rsp)
movq 0x48(%rsp), %r15
cmpq $0x2, %r15
movq 0x98(%rsp), %rbp
jl 0x420ba
imulq $0xa8, %rbp, %rsi
movq 0x8(%rsp), %rax
addq (%rax), %rsi
movq %r15, %rdi
callq 0x3d6d3
imulq $0xa8, %rbp, %r12
movq 0x8(%rsp), %rbx
movq (%rbx), %rdi
addq %r12, %rdi
leaq 0x78(%rsp), %rdx
movq %r15, %rsi
callq 0x4138d
movq %rbx, %r11
leaq (%rax,%rbp), %rcx
movq %rcx, 0x30(%rsp)
movq %rcx, 0x10(%rbx)
cmpq $0x2, %rax
movq 0x88(%rsp), %r9
movq 0xb8(%rsp), %rbx
jl 0x422be
movq 0x8(%rbx), %rax
addq 0x78(%rsp), %rax
cmpq %rax, 0x10(%rbx)
jge 0x42161
decq %rax
movq %rax, %rcx
sarq %rcx
orq %rax, %rcx
movq %rcx, %rax
sarq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
sarq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
sarq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
sarq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x10(%rbx)
movq (%rbx), %rdi
shlq $0x4, %rsi
callq 0x2370
movq 0x8(%rsp), %r11
movq %rax, (%rbx)
movq (%rbx), %rax
movq 0x8(%rbx), %rbx
addq %rax, 0xa8(%rsp)
addq %rax, 0x38(%rsp)
shlq $0x4, %rbx
addq %rax, %rbx
movq $0x0, 0x78(%rsp)
addq $-0x4, 0x10(%rsp)
xorl %r14d, %r14d
movl $0x80000000, %r12d      # imm = 0x80000000
movq (%r11), %r13
imulq $0xa8, %rbp, %rax
movq 0x60(%rsp), %rcx
addl %r14d, %ecx
movl %ecx, 0x30(%r13,%rax)
movl 0x28(%r13,%rax), %r8d
testq %r8, %r8
je 0x4221e
movl (%r13,%rax), %esi
movq %rbp, %r15
movl %ebp, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movq %r8, %rdx
negq %rdx
shlq $0x2, %rsi
leaq (%rsi,%r8,4), %rsi
addq 0x10(%rsp), %rsi
movq %r14, %rdi
shlq $0x4, %rdi
addq %rbx, %rdi
xorl %r9d, %r9d
movq 0xa8(%rsp), %rbp
movslq (%rsi,%r9,4), %r10
shlq $0x4, %r10
movupd (%rbp,%r10), %xmm0
movupd %xmm0, (%rdi)
movl (%rdi), %r10d
andl %r12d, %r10d
orl %ecx, %r10d
movl %r10d, (%rdi)
decq %r9
addq $0x10, %rdi
cmpq %r9, %rdx
jne 0x421ed
subq %r9, %r14
movq %r15, %rbp
addq %rax, %r13
movl 0x168(%rsp), %eax
movl %eax, (%r13)
cmpq $0x0, 0x190(%rsp)
je 0x42263
leaq 0x38(%r13), %rdi
movq %r14, %rcx
shlq $0x4, %rcx
addq %rbx, %rcx
movq %r8, %rax
shlq $0x4, %rax
subq %rax, %rcx
movq %r13, %rsi
movl 0x188(%rsp), %edx
callq 0x3dc52
movq 0x8(%rsp), %r11
cmpq $0x0, 0x1a8(%rsp)
jne 0x42276
movl $0x0, 0x28(%r13)
incq %rbp
cmpq 0x30(%rsp), %rbp
jl 0x42194
movq %r14, %rdx
shlq $0x4, %rdx
movq 0x38(%rsp), %rdi
movq %rbx, %rsi
callq 0x2160
jmp 0x42394
movq 0x68(%rsp), %rax
xorl %r14d, %r14d
movq %r11, %r12
testq %rax, %rax
js 0x41cb2
movq %rax, (%rdi,%r14,8)
incq %r14
movq (%r9,%rax,8), %rax
jmp 0x422a8
cmpq $0x1, %rax
jne 0x42394
movq (%r11), %rax
leaq (%rax,%r12), %rbx
movq 0x60(%rsp), %rcx
movl %ecx, 0x30(%rax,%r12)
movl 0x28(%rax,%r12), %r8d
testq %r8, %r8
je 0x4233f
movl (%rax,%r12), %ecx
andl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
movq %r8, %rax
negq %rax
shlq $0x2, %rcx
leaq (%rcx,%r8,4), %rcx
movq 0x10(%rsp), %rdx
addq %rdx, %rcx
addq $-0x4, %rcx
xorl %r14d, %r14d
movl $0x80000000, %edx       # imm = 0x80000000
movq 0x58(%rsp), %rsi
movslq (%rcx,%r14,4), %rdi
shlq $0x4, %rdi
movupd (%r9,%rdi), %xmm0
movupd %xmm0, (%rsi)
movl (%rsi), %edi
andl %edx, %edi
orl %ebp, %edi
movl %edi, (%rsi)
addq $0x10, %rsi
decq %r14
cmpq %r14, %rax
jne 0x42314
negq %r14
jmp 0x42342
xorl %r14d, %r14d
movl 0x168(%rsp), %eax
movl %eax, (%rbx)
cmpq $0x0, 0x190(%rsp)
je 0x42382
leaq 0x38(%rbx), %rdi
movl 0x188(%rsp), %edx
movq %r14, %rax
shlq $0x4, %rax
movq 0x58(%rsp), %rcx
addq %rax, %rcx
movq %r8, %rax
shlq $0x4, %rax
subq %rax, %rcx
movq %rbx, %rsi
callq 0x3dc52
cmpq $0x0, 0x1a8(%rsp)
jne 0x42394
movl $0x0, 0x28(%rbx)
movq %r14, %rax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq