// File: chhylp123[P]hifiasm/Hash_Table.cpp
// Function: lchain_qdp_fix(k_mer_hit*, long, Chain_Data*, long, long, long, double, double, double, long, long, long, long, long)
uint64_t lchain_qdp_fix(k_mer_hit* a, int64_t a_n, Chain_Data* dp, int64_t max_skip, 
                int64_t max_iter, int64_t max_dis, double chn_pen_gap, double chn_pen_skip, 
                double bw_rate, int64_t xl, int64_t yl, int64_t quick_check, 
                int64_t left_fix, int64_t right_fix)
{
    int64_t *p, *t, max_f, n_skip, st, max_j, end_j, sc, msc, msc_i, bw, max_ii, ovl, movl; 
    int32_t *f, max, tmp; int64_t i, j, ret, cL = 0, must_p = 1, is_reorder = 0; k_mer_hit z;
    resize_Chain_Data(dp, a_n, NULL);
    t = dp->tmp; f = dp->score; p = dp->pre;
    bw = ((xl < yl)?xl:yl); bw *= bw_rate;
    msc = msc_i = -1; movl = INT32_MAX;

    if(quick_check) {
        ret = lchain_qcheck(a, a_n, dp, bw_rate);
        if (ret > 0) {
            a_n = ret; msc_i = a_n-1; msc = f[msc_i];
            goto skip_ldp;
        }
    }

    memset(t, 0, (a_n*sizeof((*t))));
    if((right_fix) && (!left_fix)) {
        // fprintf(stderr, "\n[M::%s::] a_n::%ld\n", __func__, a_n);
        // for (i = 0; i < a_n; ++i) {
        //     fprintf(stderr, "+[M::%s::] x::[%u, %u), y::[%u, %u)\n", __func__, 
        //     a[i].self_offset+1-(a[i].cnt&((uint32_t)(0xffu))), a[i].self_offset+1,
        //     a[i].offset+1-(a[i].cnt&((uint32_t)(0xffu))), a[i].offset+1);
        // }
        n_skip = a_n>>1;
        for (i=0; i<n_skip; ++i) {
            z = a[i]; a[i] = a[a_n-i-1]; a[a_n-i-1] = z; 
            rev_khit(a[i], xl, yl); rev_khit(a[a_n-i-1], xl, yl);
        }
        if(a_n&1) rev_khit(a[i], xl, yl);
        // for (i = 0; i < a_n; ++i) {
        //     fprintf(stderr, "-[M::%s::] x::[%u, %u), y::[%u, %u)\n", __func__, 
        //     a[i].self_offset+1-(a[i].cnt&((uint32_t)(0xffu))), a[i].self_offset+1,
        //     a[i].offset+1-(a[i].cnt&((uint32_t)(0xffu))), a[i].offset+1);
        // }
        is_reorder = 1;
    } 

    if((!right_fix) && (!left_fix)) must_p = 0;

    for (i = st = 0, max_ii = -1; i < a_n; ++i) {
        max_f = a[i].cnt&(0xffu); if(must_p) max_f = INT32_MIN;
        n_skip = 0; max_j = end_j = -1;
        if ((i-st) > max_iter) st = i-max_iter;
        // if(a[0].self_offset == 171728) {
        //     fprintf(stderr, "i::%ld[M::%s::] x::[%u, %u), y::[%u, %u)\n", i, __func__, 
        //         a[i].self_offset+1-(a[i].cnt&((uint32_t)(0xffu))), a[i].self_offset+1,
        //         a[i].offset+1-(a[i].cnt&((uint32_t)(0xffu))), a[i].offset+1);
        // }
        for (j = i - 1; j >= 0; --j) {
            sc = comput_sc_ff(&a[i], &a[j], bw_rate, chn_pen_gap, chn_pen_skip, xl, yl);
            // if(a[0].self_offset == 171728) {
            //     fprintf(stderr, "j::%ld[M::%s::sc->%ld] x::[%u, %u), y::[%u, %u)\n", j, __func__, sc,
            //     a[j].self_offset+1-(a[j].cnt&((uint32_t)(0xffu))), a[j].self_offset+1,
            //     a[j].offset+1-(a[j].cnt&((uint32_t)(0xffu))), a[j].offset+1);
            // }
            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) {
                    if((max_j != -1) || (must_p == 0)) break;
                } 
            }
            if (p[j] >= 0) t[p[j]] = i;
            ///put it here will allow at least one prefix no matter max_dis
            ///this is special for gap filling, not for chaining
            if (a[i].self_offset > (max_dis + a[j].self_offset)) {
                if((max_j != -1)) break;
            }
            if (j < st) {
                if((max_j != -1) || (must_p == 0)) break;
            }
        }
        end_j = j;

        if (max_ii < 0 || ((int64_t)a[i].self_offset) - ((int64_t)a[max_ii].self_offset) > max_dis) {
            max = INT32_MIN; max_ii = -1;
            for (j = i - 1; (j >= st) && ((((int64_t)a[i].self_offset)-((int64_t)a[j].self_offset))<=max_dis); --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_ff(&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;
        }
        if(max_j == -1) {
            f[i] = 0; p[i] = max_j;
        } else {
            f[i] = max_f; p[i] = max_j;
        }
        
        if ((max_ii < 0) || (((((int64_t)a[i].self_offset)-((int64_t)a[max_ii].self_offset))<=max_dis) && (f[max_ii]<f[i]))) {
            max_ii = i;
        }
        // if(a[0].self_offset == 171728) {
        //     fprintf(stderr, "i::%ld[M::%s::] f::%d, p::%ld\n", i, __func__, f[i], p[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;
            }
        }
    }
    
    skip_ldp:
    if(right_fix && left_fix) msc_i = a_n-1;
    ///a[] has been sorted by self_offset
    i = msc_i; cL = 0; 
    while (i >= 0) {
        t[cL++] = i; msc_i = i; i = p[i];
    }
    // if((right_fix) && (!left_fix)) {
    //     fprintf(stderr, "[M::%s::] cL::%ld\n", __func__, cL);
    // }

    if(is_reorder) {
        n_skip = a_n>>1;
        for (i=0; i<n_skip; ++i) {
            z = a[i]; a[i] = a[a_n-i-1]; a[a_n-i-1] = z; 
            rev_khit(a[i], xl, yl); rev_khit(a[a_n-i-1], xl, yl);
        }
        if(a_n&1) rev_khit(a[i], xl, yl);
        for (i = 0; i < cL; i++) {
            t[i] = a_n - t[i] - 1;
            // fprintf(stderr, ">[M::%s::] t[%ld]::%ld\n", __func__, i, t[i]);
        }
        // for (i = 0; i < a_n; ++i) {
        //     fprintf(stderr, ">[M::%s::] x::[%u, %u), y::[%u, %u)\n", __func__, 
        //     a[i].self_offset+1-(a[i].cnt&((uint32_t)(0xffu))), a[i].self_offset+1,
        //     a[i].offset+1-(a[i].cnt&((uint32_t)(0xffu))), a[i].offset+1);
        // }
    } else {
        n_skip = cL>>1;
        for (i = 0; i < n_skip; i++) {
            msc_i = t[i]; t[i] = t[cL-i-1]; t[cL-i-1] = msc_i;
        }
    } 
    // if(cL != a_n) {
    //     fprintf(stderr, "\n[M::%s::] a_n::%ld, left_fix::%ld, right_fix::%ld\n", __func__, a_n, left_fix, right_fix);
    //     for (i = 0; i < a_n; ++i) {
    //         fprintf(stderr, "+[M::%s::] x::[%u, %u), y::[%u, %u)\n", __func__, 
    //         a[i].self_offset+1-(a[i].cnt&((uint32_t)(0xffu))), a[i].self_offset+1,
    //         a[i].offset+1-(a[i].cnt&((uint32_t)(0xffu))), a[i].offset+1);
    //     }
    //     for (i = 0; i < cL; i++) {
    //         fprintf(stderr, ">[M::%s::] t[%ld]::%ld\n", __func__, i, t[i]);
    //     }
    // }
    return cL;
}

// 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)
movsd %xmm1, -0x40(%rbp)
movsd %xmm2, -0x48(%rbp)
movq $0x0, -0xe8(%rbp)
movq $0x1, -0xf0(%rbp)
movq $0x0, -0xf8(%rbp)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x226f0
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xc0(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
movq 0x10(%rbp), %rax
cmpq 0x18(%rbp), %rax
jge 0x28f45
movq 0x10(%rbp), %rax
movq %rax, -0x110(%rbp)
jmp 0x28f50
movq 0x18(%rbp), %rax
movq %rax, -0x110(%rbp)
movq -0x110(%rbp), %rax
movq %rax, -0xa0(%rbp)
movsd -0x48(%rbp), %xmm1
cvtsi2sdq -0xa0(%rbp), %xmm0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, -0xa0(%rbp)
movq $-0x1, -0x98(%rbp)
movq $-0x1, -0x90(%rbp)
movq $0x7fffffff, -0xb8(%rbp) # imm = 0x7FFFFFFF
cmpq $0x0, 0x20(%rbp)
je 0x29009
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl %eax, %esi
movq -0x18(%rbp), %rdx
movsd -0x48(%rbp), %xmm0
callq 0x237b0
cltq
movq %rax, -0xe0(%rbp)
cmpq $0x0, -0xe0(%rbp)
jle 0x29007
movq -0xe0(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x98(%rbp)
movq -0xc0(%rbp), %rax
movq -0x98(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
movq %rax, -0x90(%rbp)
jmp 0x299a4
jmp 0x29009
movq -0x58(%rbp), %rdi
movq -0x10(%rbp), %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x2100
cmpq $0x0, 0x30(%rbp)
je 0x2936b
cmpq $0x0, 0x28(%rbp)
jne 0x2936b
movq -0x10(%rbp), %rax
sarq %rax
movq %rax, -0x68(%rbp)
movq $0x0, -0xd0(%rbp)
movq -0xd0(%rbp), %rax
cmpq -0x68(%rbp), %rax
jge 0x29298
movq -0x8(%rbp), %rax
movq -0xd0(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq %rcx, -0x108(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x100(%rbp)
movq -0x8(%rbp), %rcx
movq -0x10(%rbp), %rax
subq -0xd0(%rbp), %rax
subq $0x1, %rax
shlq $0x4, %rax
addq %rax, %rcx
movq -0x8(%rbp), %rax
movq -0xd0(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq -0x10(%rbp), %rcx
subq -0xd0(%rbp), %rcx
subq $0x1, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq -0x108(%rbp), %rcx
movq %rcx, (%rax)
movq -0x100(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq 0x10(%rbp), %rax
subq $0x1, %rax
movq -0x8(%rbp), %rcx
movq -0xd0(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %ecx
addl $0x1, %ecx
movq -0x8(%rbp), %rdx
movq -0xd0(%rbp), %rsi
shlq $0x4, %rsi
addq %rsi, %rdx
movl 0xc(%rdx), %edx
andl $0xff, %edx
subl %edx, %ecx
movl %ecx, %ecx
subq %rcx, %rax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movq -0xd0(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movq 0x18(%rbp), %rax
subq $0x1, %rax
movq -0x8(%rbp), %rcx
movq -0xd0(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movl 0x4(%rcx), %ecx
addl $0x1, %ecx
movq -0x8(%rbp), %rdx
movq -0xd0(%rbp), %rsi
shlq $0x4, %rsi
addq %rsi, %rdx
movl 0xc(%rdx), %edx
andl $0xff, %edx
subl %edx, %ecx
movl %ecx, %ecx
subq %rcx, %rax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movq -0xd0(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
jmp 0x2919d
movq 0x10(%rbp), %rax
subq $0x1, %rax
movq -0x8(%rbp), %rcx
movq -0x10(%rbp), %rdx
subq -0xd0(%rbp), %rdx
subq $0x1, %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %ecx
addl $0x1, %ecx
movq -0x8(%rbp), %rdx
movq -0x10(%rbp), %rsi
subq -0xd0(%rbp), %rsi
subq $0x1, %rsi
shlq $0x4, %rsi
addq %rsi, %rdx
movl 0xc(%rdx), %edx
andl $0xff, %edx
subl %edx, %ecx
movl %ecx, %ecx
subq %rcx, %rax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movq -0x10(%rbp), %rdx
subq -0xd0(%rbp), %rdx
subq $0x1, %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movq 0x18(%rbp), %rax
subq $0x1, %rax
movq -0x8(%rbp), %rcx
movq -0x10(%rbp), %rdx
subq -0xd0(%rbp), %rdx
subq $0x1, %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movl 0x4(%rcx), %ecx
addl $0x1, %ecx
movq -0x8(%rbp), %rdx
movq -0x10(%rbp), %rsi
subq -0xd0(%rbp), %rsi
subq $0x1, %rsi
shlq $0x4, %rsi
addq %rsi, %rdx
movl 0xc(%rdx), %edx
andl $0xff, %edx
subl %edx, %ecx
movl %ecx, %ecx
subq %rcx, %rax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movq -0x10(%rbp), %rdx
subq -0xd0(%rbp), %rdx
subq $0x1, %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
jmp 0x29281
movq -0xd0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xd0(%rbp)
jmp 0x29048
movq -0x10(%rbp), %rax
andq $0x1, %rax
cmpq $0x0, %rax
je 0x29360
jmp 0x292ac
movq 0x10(%rbp), %rax
subq $0x1, %rax
movq -0x8(%rbp), %rcx
movq -0xd0(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %ecx
addl $0x1, %ecx
movq -0x8(%rbp), %rdx
movq -0xd0(%rbp), %rsi
shlq $0x4, %rsi
addq %rsi, %rdx
movl 0xc(%rdx), %edx
andl $0xff, %edx
subl %edx, %ecx
movl %ecx, %ecx
subq %rcx, %rax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movq -0xd0(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movq 0x18(%rbp), %rax
subq $0x1, %rax
movq -0x8(%rbp), %rcx
movq -0xd0(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movl 0x4(%rcx), %ecx
addl $0x1, %ecx
movq -0x8(%rbp), %rdx
movq -0xd0(%rbp), %rsi
shlq $0x4, %rsi
addq %rsi, %rdx
movl 0xc(%rdx), %edx
andl $0xff, %edx
subl %edx, %ecx
movl %ecx, %ecx
subq %rcx, %rax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movq -0xd0(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
jmp 0x29360
movq $0x1, -0xf8(%rbp)
cmpq $0x0, 0x30(%rbp)
jne 0x29384
cmpq $0x0, 0x28(%rbp)
jne 0x29384
movq $0x0, -0xf0(%rbp)
movq $0x0, -0x70(%rbp)
movq $0x0, -0xd0(%rbp)
movq $-0x1, -0xa8(%rbp)
movq -0xd0(%rbp), %rax
cmpq -0x10(%rbp), %rax
jge 0x299a2
movq -0x8(%rbp), %rax
movq -0xd0(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
andl $0xff, %eax
movl %eax, %eax
movq %rax, -0x60(%rbp)
cmpq $0x0, -0xf0(%rbp)
je 0x293e5
movq $-0x80000000, -0x60(%rbp) # imm = 0x80000000
movq $0x0, -0x68(%rbp)
movq $-0x1, -0x80(%rbp)
movq $-0x1, -0x78(%rbp)
movq -0xd0(%rbp), %rax
subq -0x70(%rbp), %rax
cmpq -0x28(%rbp), %rax
jle 0x2941d
movq -0xd0(%rbp), %rax
subq -0x28(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0xd0(%rbp), %rax
subq $0x1, %rax
movq %rax, -0xd8(%rbp)
cmpq $0x0, -0xd8(%rbp)
jl 0x295e8
movq -0x8(%rbp), %rdi
movq -0xd0(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rdi
movq -0x8(%rbp), %rsi
movq -0xd8(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rsi
movsd -0x48(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
movsd -0x40(%rbp), %xmm2
movq 0x10(%rbp), %rdx
movq 0x18(%rbp), %rcx
callq 0x2b620
cltq
movq %rax, -0x88(%rbp)
cmpq $-0x80000000, -0x88(%rbp) # imm = 0x80000000
jne 0x29498
jmp 0x295d1
movq -0xc0(%rbp), %rax
movq -0xd8(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
addq -0x88(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
cmpq -0x60(%rbp), %rax
jle 0x294f0
movq -0x88(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0xd8(%rbp), %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x68(%rbp)
jle 0x294ee
movq -0x68(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x68(%rbp)
jmp 0x2953c
movq -0x58(%rbp), %rax
movq -0xd8(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq -0xd0(%rbp), %rcx
movslq %ecx, %rcx
cmpq %rcx, %rax
jne 0x2953a
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
cmpq -0x20(%rbp), %rax
jle 0x29538
cmpq $-0x1, -0x78(%rbp)
jne 0x29531
cmpq $0x0, -0xf0(%rbp)
jne 0x29536
jmp 0x295e8
jmp 0x29538
jmp 0x2953a
jmp 0x2953c
movq -0x50(%rbp), %rax
movq -0xd8(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jl 0x2956c
movq -0xd0(%rbp), %rdx
movq -0x58(%rbp), %rax
movq -0x50(%rbp), %rcx
movq -0xd8(%rbp), %rsi
movq (%rcx,%rsi,8), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x8(%rbp), %rax
movq -0xd0(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq -0x30(%rbp), %rcx
movq -0x8(%rbp), %rdx
movq -0xd8(%rbp), %rsi
shlq $0x4, %rsi
addq %rsi, %rdx
movl 0x8(%rdx), %edx
addq %rdx, %rcx
cmpq %rcx, %rax
jle 0x295ad
cmpq $-0x1, -0x78(%rbp)
je 0x295ab
jmp 0x295e8
jmp 0x295ad
movq -0xd8(%rbp), %rax
cmpq -0x70(%rbp), %rax
jge 0x295cf
cmpq $-0x1, -0x78(%rbp)
jne 0x295cb
cmpq $0x0, -0xf0(%rbp)
jne 0x295cd
jmp 0x295e8
jmp 0x295cf
jmp 0x295d1
movq -0xd8(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0xd8(%rbp)
jmp 0x2942f
movq -0xd8(%rbp), %rax
movq %rax, -0x80(%rbp)
cmpq $0x0, -0xa8(%rbp)
jl 0x29634
movq -0x8(%rbp), %rax
movq -0xd0(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq -0x8(%rbp), %rcx
movq -0xa8(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %ecx
subq %rcx, %rax
cmpq -0x30(%rbp), %rax
jle 0x2970f
movl $0x80000000, -0xc4(%rbp) # imm = 0x80000000
movq $-0x1, -0xa8(%rbp)
movq -0xd0(%rbp), %rax
subq $0x1, %rax
movq %rax, -0xd8(%rbp)
movq -0xd8(%rbp), %rcx
xorl %eax, %eax
cmpq -0x70(%rbp), %rcx
movb %al, -0x111(%rbp)
jl 0x296aa
movq -0x8(%rbp), %rax
movq -0xd0(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq -0x8(%rbp), %rcx
movq -0xd8(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %ecx
subq %rcx, %rax
cmpq -0x30(%rbp), %rax
setle %al
movb %al, -0x111(%rbp)
movb -0x111(%rbp), %al
testb $0x1, %al
jne 0x296b6
jmp 0x2970d
movl -0xc4(%rbp), %eax
movq -0xc0(%rbp), %rcx
movq -0xd8(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x296f4
movq -0xc0(%rbp), %rax
movq -0xd8(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0xc4(%rbp)
movq -0xd8(%rbp), %rax
movq %rax, -0xa8(%rbp)
jmp 0x296f6
movq -0xd8(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0xd8(%rbp)
jmp 0x2965b
jmp 0x2970f
cmpq $0x0, -0xa8(%rbp)
jl 0x297cd
movq -0xa8(%rbp), %rax
cmpq -0x80(%rbp), %rax
jge 0x297cd
movq -0x8(%rbp), %rdi
movq -0xd0(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rdi
movq -0x8(%rbp), %rsi
movq -0xa8(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rsi
movsd -0x48(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
movsd -0x40(%rbp), %xmm2
movq 0x10(%rbp), %rdx
movq 0x18(%rbp), %rcx
callq 0x2b620
movl %eax, -0xc8(%rbp)
cmpl $0x80000000, -0xc8(%rbp) # imm = 0x80000000
je 0x297cb
movq -0x60(%rbp), %rax
movl -0xc8(%rbp), %ecx
movq -0xc0(%rbp), %rdx
movq -0xa8(%rbp), %rsi
addl (%rdx,%rsi,4), %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jge 0x297cb
movl -0xc8(%rbp), %eax
movq -0xc0(%rbp), %rcx
movq -0xa8(%rbp), %rdx
addl (%rcx,%rdx,4), %eax
cltq
movq %rax, -0x60(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0x78(%rbp)
jmp 0x297cd
cmpq $-0x1, -0x78(%rbp)
jne 0x297fe
movq -0xc0(%rbp), %rax
movq -0xd0(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movq -0x78(%rbp), %rdx
movq -0x50(%rbp), %rax
movq -0xd0(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x29828
movq -0x60(%rbp), %rax
movl %eax, %edx
movq -0xc0(%rbp), %rax
movq -0xd0(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x78(%rbp), %rdx
movq -0x50(%rbp), %rax
movq -0xd0(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
cmpq $0x0, -0xa8(%rbp)
jl 0x29889
movq -0x8(%rbp), %rax
movq -0xd0(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq -0x8(%rbp), %rcx
movq -0xa8(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %ecx
subq %rcx, %rax
cmpq -0x30(%rbp), %rax
jg 0x29897
movq -0xc0(%rbp), %rax
movq -0xa8(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq -0xc0(%rbp), %rcx
movq -0xd0(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x29897
movq -0xd0(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0xc0(%rbp), %rax
movq -0xd0(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
cmpq -0x90(%rbp), %rax
jl 0x29989
movq -0x8(%rbp), %rax
movq -0xd0(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, %edi
movq -0x8(%rbp), %rax
movq -0xd0(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, %esi
movq 0x10(%rbp), %rdx
movq -0x8(%rbp), %rax
movq -0xd0(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movq -0xd0(%rbp), %r8
shlq $0x4, %r8
addq %r8, %rax
movl 0x4(%rax), %eax
movl %eax, %r8d
movq 0x18(%rbp), %r9
callq 0x21580
movq %rax, -0xb0(%rbp)
movq -0xc0(%rbp), %rax
movq -0xd0(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
cmpq -0x90(%rbp), %rax
jg 0x29952
movq -0xb0(%rbp), %rax
cmpq -0xb8(%rbp), %rax
jge 0x29987
movq -0xc0(%rbp), %rax
movq -0xd0(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
movq %rax, -0x90(%rbp)
movq -0xd0(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0xb0(%rbp), %rax
movq %rax, -0xb8(%rbp)
jmp 0x29989
jmp 0x2998b
movq -0xd0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xd0(%rbp)
jmp 0x293a2
jmp 0x299a4
cmpq $0x0, 0x30(%rbp)
je 0x299c1
cmpq $0x0, 0x28(%rbp)
je 0x299c1
movq -0x10(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq $0x0, -0xe8(%rbp)
cmpq $0x0, -0xd0(%rbp)
jl 0x29a2e
movq -0xd0(%rbp), %rdx
movq -0x58(%rbp), %rax
movq -0xe8(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0xe8(%rbp)
movq %rdx, (%rax,%rcx,8)
movq -0xd0(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x50(%rbp), %rax
movq -0xd0(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xd0(%rbp)
jmp 0x299da
cmpq $0x0, -0xf8(%rbp)
je 0x29dc4
movq -0x10(%rbp), %rax
sarq %rax
movq %rax, -0x68(%rbp)
movq $0x0, -0xd0(%rbp)
movq -0xd0(%rbp), %rax
cmpq -0x68(%rbp), %rax
jge 0x29ca2
movq -0x8(%rbp), %rax
movq -0xd0(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq %rcx, -0x108(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x100(%rbp)
movq -0x8(%rbp), %rcx
movq -0x10(%rbp), %rax
subq -0xd0(%rbp), %rax
subq $0x1, %rax
shlq $0x4, %rax
addq %rax, %rcx
movq -0x8(%rbp), %rax
movq -0xd0(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq -0x10(%rbp), %rcx
subq -0xd0(%rbp), %rcx
subq $0x1, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq -0x108(%rbp), %rcx
movq %rcx, (%rax)
movq -0x100(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq 0x10(%rbp), %rax
subq $0x1, %rax
movq -0x8(%rbp), %rcx
movq -0xd0(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %ecx
addl $0x1, %ecx
movq -0x8(%rbp), %rdx
movq -0xd0(%rbp), %rsi
shlq $0x4, %rsi
addq %rsi, %rdx
movl 0xc(%rdx), %edx
andl $0xff, %edx
subl %edx, %ecx
movl %ecx, %ecx
subq %rcx, %rax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movq -0xd0(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movq 0x18(%rbp), %rax
subq $0x1, %rax
movq -0x8(%rbp), %rcx
movq -0xd0(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movl 0x4(%rcx), %ecx
addl $0x1, %ecx
movq -0x8(%rbp), %rdx
movq -0xd0(%rbp), %rsi
shlq $0x4, %rsi
addq %rsi, %rdx
movl 0xc(%rdx), %edx
andl $0xff, %edx
subl %edx, %ecx
movl %ecx, %ecx
subq %rcx, %rax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movq -0xd0(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
jmp 0x29ba7
movq 0x10(%rbp), %rax
subq $0x1, %rax
movq -0x8(%rbp), %rcx
movq -0x10(%rbp), %rdx
subq -0xd0(%rbp), %rdx
subq $0x1, %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %ecx
addl $0x1, %ecx
movq -0x8(%rbp), %rdx
movq -0x10(%rbp), %rsi
subq -0xd0(%rbp), %rsi
subq $0x1, %rsi
shlq $0x4, %rsi
addq %rsi, %rdx
movl 0xc(%rdx), %edx
andl $0xff, %edx
subl %edx, %ecx
movl %ecx, %ecx
subq %rcx, %rax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movq -0x10(%rbp), %rdx
subq -0xd0(%rbp), %rdx
subq $0x1, %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movq 0x18(%rbp), %rax
subq $0x1, %rax
movq -0x8(%rbp), %rcx
movq -0x10(%rbp), %rdx
subq -0xd0(%rbp), %rdx
subq $0x1, %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movl 0x4(%rcx), %ecx
addl $0x1, %ecx
movq -0x8(%rbp), %rdx
movq -0x10(%rbp), %rsi
subq -0xd0(%rbp), %rsi
subq $0x1, %rsi
shlq $0x4, %rsi
addq %rsi, %rdx
movl 0xc(%rdx), %edx
andl $0xff, %edx
subl %edx, %ecx
movl %ecx, %ecx
subq %rcx, %rax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movq -0x10(%rbp), %rdx
subq -0xd0(%rbp), %rdx
subq $0x1, %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
jmp 0x29c8b
movq -0xd0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xd0(%rbp)
jmp 0x29a52
movq -0x10(%rbp), %rax
andq $0x1, %rax
cmpq $0x0, %rax
je 0x29d6a
jmp 0x29cb6
movq 0x10(%rbp), %rax
subq $0x1, %rax
movq -0x8(%rbp), %rcx
movq -0xd0(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %ecx
addl $0x1, %ecx
movq -0x8(%rbp), %rdx
movq -0xd0(%rbp), %rsi
shlq $0x4, %rsi
addq %rsi, %rdx
movl 0xc(%rdx), %edx
andl $0xff, %edx
subl %edx, %ecx
movl %ecx, %ecx
subq %rcx, %rax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movq -0xd0(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movq 0x18(%rbp), %rax
subq $0x1, %rax
movq -0x8(%rbp), %rcx
movq -0xd0(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movl 0x4(%rcx), %ecx
addl $0x1, %ecx
movq -0x8(%rbp), %rdx
movq -0xd0(%rbp), %rsi
shlq $0x4, %rsi
addq %rsi, %rdx
movl 0xc(%rdx), %edx
andl $0xff, %edx
subl %edx, %ecx
movl %ecx, %ecx
subq %rcx, %rax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movq -0xd0(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
jmp 0x29d6a
movq $0x0, -0xd0(%rbp)
movq -0xd0(%rbp), %rax
cmpq -0xe8(%rbp), %rax
jge 0x29dbf
movq -0x10(%rbp), %rdx
movq -0x58(%rbp), %rax
movq -0xd0(%rbp), %rcx
subq (%rax,%rcx,8), %rdx
subq $0x1, %rdx
movq -0x58(%rbp), %rax
movq -0xd0(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0xd0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xd0(%rbp)
jmp 0x29d75
jmp 0x29e63
movq -0xe8(%rbp), %rax
sarq %rax
movq %rax, -0x68(%rbp)
movq $0x0, -0xd0(%rbp)
movq -0xd0(%rbp), %rax
cmpq -0x68(%rbp), %rax
jge 0x29e61
movq -0x58(%rbp), %rax
movq -0xd0(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x98(%rbp)
movq -0x58(%rbp), %rax
movq -0xe8(%rbp), %rcx
subq -0xd0(%rbp), %rcx
subq $0x1, %rcx
movq (%rax,%rcx,8), %rdx
movq -0x58(%rbp), %rax
movq -0xd0(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x98(%rbp), %rdx
movq -0x58(%rbp), %rax
movq -0xe8(%rbp), %rcx
subq -0xd0(%rbp), %rcx
subq $0x1, %rcx
movq %rdx, (%rax,%rcx,8)
movq -0xd0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xd0(%rbp)
jmp 0x29ddd
jmp 0x29e63
movq -0xe8(%rbp), %rax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nopw %cs:(%rax,%rax)