// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/Correct.cpp
// Function: mask_ovlps(ul_idx_t const*, ug_opt_t const*, ma_ug_t*, overlap_region_alloc*, mask_ul_ov_t*, kv_ul_ov_t*, asg64_v*, asg64_v*, idx_emask_t*, double, unsigned long, long)
uint64_t mask_ovlps(const ul_idx_t *uref, const ug_opt_t *uopt, ma_ug_t *ug, overlap_region_alloc* ol, mask_ul_ov_t *mk, kv_ul_ov_t *ov_db, asg64_v *coor_srt, asg64_v* buf1, idx_emask_t *mm, double len_diff, uint64_t rlen, int64_t bd)
{
    mk->srt.n = mk->idx.n = 0;
    int64_t k, m, i, osrt_n, osrt_n1, on = ol->length; uint64_t wt, w[2], is_exact, sid, tot, tol, qi, ti; 
    overlap_region *z; ul_ov_t ou; kv_ul_ov_t *osrt = &(mk->srt); ul_ov_t p, q;
    for (k = osrt->n = 0; k < on; k++) {
        z = &(ol->list[k]); if(!(z->x_pos_strand)) continue;///x_pos_strand: how many masks
        if(gen_aln_ul_ov_t(k, ug->g->seq[z->y_id].len, z, &ou)) {
            kv_push(ul_ov_t, *osrt, ou);
        }
    }
    if(!(osrt->n)) return 0;

    osrt_n = osrt->n; memset(&ou, 0, sizeof(ou));
    radix_sort_uov_srt_qs(osrt->a, osrt->a+osrt->n); ///sort by qs; for quick filtering between overlaps
    for (k = tot = tol = 0; k < osrt_n; k++) {
        tol += osrt->a[k].qe-osrt->a[k].qs; 
        convert_ul_ov_t(&p, &(ol->list[osrt->a[k].qn]), ug); p.qn = osrt->a[k].qn;
        for (i = k+1; i < osrt_n && osrt->a[i].qs < osrt->a[k].qe; i++) {
            ///for a pair of overlap, only need to calculate it in one side
            if(ol->list[osrt->a[i].qn].y_id >= ol->list[osrt->a[k].qn].y_id) continue;
            is_exact = 0; sid = (uint32_t)-1;
            convert_ul_ov_t(&q, &(ol->list[osrt->a[i].qn]), ug); q.qn = osrt->a[i].qn;
            if(if_direct_mask(uref, uopt, &p, &q, 16, len_diff)) is_exact = 1;
            if((!is_exact) && (!check_mask_exist(ug, &(ol->list[osrt->a[i].qn]), &(ol->list[osrt->a[k].qn]), ov_db, mm, len_diff, &is_exact, &sid))) {
                continue;
            }
            
            if(is_exact) {///if two overlaps are exactly the same; no need to do anything
                ou.qs = 0; ou.qe = sid; ou.ts = ou.te = 0; ou.el = 1;
            } else {
                w[0] = ol->list[osrt->a[k].qn].non_homopolymer_errors;
                w[1] = ol->list[osrt->a[i].qn].non_homopolymer_errors;
                wt = w[0] + w[1] + ((w[0]>=w[1])?(w[0]-w[1]):(w[1]-w[0]));
                if(wt > (uint32_t)-1) wt = (uint32_t)-1;
                //qs: weight; qe: idx with in ov_db; el: exact match?
                ou.qs = wt; ou.qe = sid; ou.el = 0;
                ou.ts = osrt->a[i].qe-osrt->a[i].qs;
                ou.te = osrt->a[k].qe-osrt->a[k].qs;
            }
            ou.qn = osrt->a[i].qn; ou.tn = osrt->a[k].qn;///id of the ol->list, instead of real yid
            tot += ou.ts + ou.te;
            kv_push(ul_ov_t, *osrt, ou);
        }
        for (i = k-1; i >= 0; i--) {
            ///for a pair of overlap, only need to calculate it in one side
            if(ol->list[osrt->a[i].qn].y_id >= ol->list[osrt->a[k].qn].y_id) continue;
            is_exact = 0; sid = (uint32_t)-1;
            convert_ul_ov_t(&q, &(ol->list[osrt->a[i].qn]), ug); q.qn = osrt->a[i].qn;
            if(if_direct_mask(uref, uopt, &p, &q, 16, len_diff)) is_exact = 1;
            if((!is_exact) && (!check_mask_exist(ug, &(ol->list[osrt->a[i].qn]), &(ol->list[osrt->a[k].qn]), ov_db, mm, len_diff, &is_exact, &sid))) {
                continue;
            }
            
            if(is_exact) {
                ou.qs = 0; ou.qe = sid; ou.ts = ou.te = 0; ou.el = 1;
            } else {
                w[0] = ol->list[osrt->a[k].qn].non_homopolymer_errors;
                w[1] = ol->list[osrt->a[i].qn].non_homopolymer_errors;
                wt = w[0] + w[1] + ((w[0]>=w[1])?(w[0]-w[1]):(w[1]-w[0]));
                if(wt > (uint32_t)-1) wt = (uint32_t)-1;
                ou.qs = wt; ou.qe = sid; ou.el = 0;
                ou.ts = osrt->a[i].qe-osrt->a[i].qs;
                ou.te = osrt->a[k].qe-osrt->a[k].qs;
            }
            ou.qn = osrt->a[i].qn; ou.tn = osrt->a[k].qn;///id of the ol->list, instead of real yid
            tot += ou.ts + ou.te;
            kv_push(ul_ov_t, *osrt, ou);
        }
    }

    // fprintf(stderr, "0[M::%s]\tosrt_n::%u\tosrt->n::%u\n", __func__, (uint32_t)osrt_n, (uint32_t)osrt->n);

    if((tot > (rlen*256)) && (tot > (tol*32))) {
        tot = MAX((rlen*256), (tol*32)); osrt_n1 = osrt->n;
        radix_sort_uov_srt_qs(osrt->a+osrt_n, osrt->a+osrt->n); ///sort by weight (qs)
        for (k = osrt_n, wt = 0; k < osrt_n1 && wt <= tot; k++) {
            if(osrt->a[k].el) continue;///exact match, no additional work
            wt += (uint64_t)osrt->a[k].ts + (uint64_t)osrt->a[k].te;
        }
        osrt->n = k;
    }

    memset(&ou, 0, sizeof(ou)); osrt_n1 = osrt->n;
    ///note: osrt will be updated here, so do not use the address within osrt
    for (k = osrt_n, m = 0; k < osrt_n1; k++) {
        qi = osrt->a[k].qn; ti = osrt->a[k].tn; ///represent a pair of read ol->list[qi] <-> ol->list[ti]
        sid = osrt->a[k].qe; wt = 1;
        ///p->qn/p->tn:: id within the ol->list
        ///p->el:: if equally best
        ///p->qs:: err(query)-err(target)
        ///p->ts:: err(target)-err(query)
        if(osrt->a[k].el) {///exact match; no need base-check
            ou.qn = qi; ou.tn = ti; ou.el = 1; ou.qs = ou.ts = 0;
        } else {///do base-check
            wt = gen_mask_ovlp0(ug, ol->list, qi, ti, ov_db, osrt, mm, len_diff, rlen, sid, coor_srt, buf1, bd, &(ou));
        }
        if(wt) {
            osrt->a[m++] = ou;
            // fprintf(stderr, "[M::%s]\tutg%.6u%c\tqerr::%u\t\tutg%.6u%c\tterr::%u\tel::%u\n", 
            // __func__, ol->list[ou.qn].y_id+1, "lc"[ug->u.a[ol->list[ou.qn].y_id].circ], ou.qs, 
            // ol->list[ou.tn].y_id+1, "lc"[ug->u.a[ol->list[ou.tn].y_id].circ], ou.ts, ou.el);
        }
    }
    osrt->n = m;
    if(!(osrt->n)) return 0;

    ///double
    ///p->qn/p->tn:: id within the ol->list
    ///p->el:: if equally best
    ///p->qs:: err(query)-err(target)
    ///p->ts:: err(target)-err(query)
    kv_resize(ul_ov_t, *osrt, (osrt->n<<1)); 
    memcpy(osrt->a+osrt->n, osrt->a, (sizeof((*(osrt->a)))*osrt->n));
    osrt_n = osrt->n; osrt->n <<= 1; osrt_n1 = osrt->n;
    for (k = osrt_n; k < osrt_n1; k++) {
        m = osrt->a[k].qn; osrt->a[k].qn = osrt->a[k].tn; osrt->a[k].tn = m;
        m = osrt->a[k].qs; osrt->a[k].qs = osrt->a[k].ts; osrt->a[k].ts = m;
    }

    ///osrt = &(mk->srt);
    radix_sort_ul_ov_srt_qn1(osrt->a, osrt->a+osrt->n);
    kv_resize(uint64_t, mk->idx, ol->length); mk->idx.n = ol->length;
    memset(mk->idx.a, 0, sizeof((*(mk->idx.a)))*ol->length);
    for (k = 1, i = 0; k <= osrt_n1; k++) {
        if(k == osrt_n1 || osrt->a[i].qn != osrt->a[k].qn) {
            if(k - i > 1) radix_sort_ul_ov_srt_tn1(osrt->a+i, osrt->a+k);
            mk->idx.a[osrt->a[i].qn] = (((uint64_t)i)<<32)|((uint64_t)k);
            i = k;
        }
    }

    return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movsd %xmm0, 0x90(%rsp)
movq %r9, 0xd0(%rsp)
movq %rdx, 0x98(%rsp)
movq %rsi, 0xf8(%rsp)
movq %rdi, 0xf0(%rsp)
andq $0x0, (%r8)
movq 0x10(%rcx), %rbx
andq $0x0, 0x20(%r8)
xorl %r14d, %r14d
testq %rbx, %rbx
cmovleq %r14, %rbx
movq %r8, %r15
leaq 0x18(%r8), %r13
xorl %r12d, %r12d
movq %rcx, 0x40(%rsp)
cmpq %r12, %rbx
je 0x4498f
movq (%rcx), %rdx
cmpl $0x0, 0xc(%rdx,%r14)
je 0x44980
movq 0x98(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rax
movl 0x10(%rdx,%r14), %ecx
addq %r14, %rdx
movl (%rax,%rcx,8), %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
movq %r12, %rdi
leaq 0x50(%rsp), %rcx
callq 0x41714
movq 0x40(%rsp), %rcx
testq %rax, %rax
je 0x44980
movq %r15, %rbp
movq 0x18(%r15), %rax
movq 0x20(%r15), %rsi
cmpq 0x28(%r15), %rsi
jne 0x44961
leaq (%rsi,%rsi), %rdx
testq %rsi, %rsi
pushq $0x2
popq %rcx
cmoveq %rcx, %rdx
movq %rdx, 0x28(%rbp)
imulq $0x1c, %rdx, %rsi
movq %rax, %rdi
callq 0x2370
movq 0x40(%rsp), %rcx
movq %rax, 0x18(%rbp)
movq 0x20(%rbp), %rsi
leaq 0x1(%rsi), %rdx
movq %rdx, 0x20(%rbp)
imulq $0x1c, %rsi, %rdx
movups 0x50(%rsp), %xmm0
movups 0x5c(%rsp), %xmm1
movups %xmm1, 0xc(%rax,%rdx)
movups %xmm0, (%rax,%rdx)
incq %r12
addq $0xa8, %r14
jmp 0x448d5
movq %r15, 0x70(%rsp)
movq 0x20(%r15), %r12
movq $0x0, 0x78(%rsp)
testq %r12, %r12
je 0x452f9
xorps %xmm0, %xmm0
movups %xmm0, 0x5c(%rsp)
movaps %xmm0, 0x50(%rsp)
movq (%r13), %rdi
imulq $0x1c, %r12, %rax
movq %rax, 0xe8(%rsp)
leaq (%rdi,%rax), %rsi
callq 0x1a05e
movq 0x40(%rsp), %r10
testq %r12, %r12
movl $0x0, %eax
cmovgq %r12, %rax
movq %rax, 0x100(%rsp)
pushq $0x1c
popq %rax
movq %rax, 0xe0(%rsp)
xorl %ecx, %ecx
movq $0x0, 0xd8(%rsp)
xorl %r8d, %r8d
movq %r13, 0x48(%rsp)
movq %r12, 0xa8(%rsp)
cmpq 0x100(%rsp), %r8
je 0x450a5
movq %rcx, 0xb8(%rsp)
movq (%r13), %r14
imulq $0x1c, %r8, %rbx
movl (%r14,%rbx), %eax
movl 0x8(%r14,%rbx), %ecx
subl 0x4(%r14,%rbx), %ecx
addq %rcx, 0xd8(%rsp)
imulq $0xa8, %rax, %rsi
addq (%r10), %rsi
leaq 0x12c(%rsp), %rdi
movq 0x98(%rsp), %rdx
movq %r8, %r15
callq 0x3d508
movq %r15, %r11
movq 0x40(%rsp), %r10
movl (%r14,%rbx), %eax
movl %eax, 0x12c(%rsp)
leaq 0x1(%r15), %rax
movq 0xe0(%rsp), %r14
movq %rax, 0x108(%rsp)
movq %rax, %rdx
movq %rbx, 0x80(%rsp)
movq %r15, 0xb0(%rsp)
cmpq %r12, %rdx
jge 0x44dc1
movq (%r13), %rbp
movl 0x4(%rbp,%r14), %eax
cmpl 0x8(%rbp,%rbx), %eax
jae 0x44dc1
leaq (%rbx,%rbp), %r15
movq (%r10), %r12
movl (%rbp,%r14), %eax
imulq $0xa8, %rax, %rsi
movl 0x10(%r12,%rsi), %eax
movl (%r15), %ecx
imulq $0xa8, %rcx, %rcx
cmpl 0x10(%r12,%rcx), %eax
jae 0x44c4f
movq %rdx, 0xc8(%rsp)
andq $0x0, 0x88(%rsp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, 0xa0(%rsp)
addq %r12, %rsi
leaq 0x110(%rsp), %r13
movq %r13, %rdi
movq 0x98(%rsp), %rbx
movq %rbx, %rdx
callq 0x3d508
movq %r14, 0xc0(%rsp)
movl (%rbp,%r14), %r14d
movl %r14d, 0x110(%rsp)
movq 0xf0(%rsp), %rdi
movq 0xf8(%rsp), %rsi
leaq 0x12c(%rsp), %rdx
movq %r13, %rcx
pushq $0x10
popq %r8
movsd 0x90(%rsp), %xmm0
callq 0x447cd
testq %rax, %rax
je 0x44c68
movq $0x1, 0x88(%rsp)
pushq $-0x1
popq %rax
movl %eax, %ecx
movq 0x48(%rsp), %r13
movq 0x40(%rsp), %r10
movq 0x78(%rsp), %rax
movq 0xb0(%rsp), %r11
movq 0x80(%rsp), %rbx
movq %r14, %r15
movq 0xc0(%rsp), %r14
andl $0x0, 0x54(%rsp)
movl %ecx, 0x58(%rsp)
andq $0x0, 0x60(%rsp)
orl $0x40000000, %eax       # imm = 0x40000000
movq %rax, 0x78(%rsp)
movl %eax, 0x68(%rsp)
movl (%rbp,%rbx), %eax
xorl %r12d, %r12d
movl %r15d, 0x50(%rsp)
movl %eax, 0x5c(%rsp)
movq 0x70(%rsp), %r15
movq 0x20(%r15), %rax
cmpq 0x28(%r15), %rax
jne 0x44c1d
leaq (%rax,%rax), %rcx
testq %rax, %rax
pushq $0x2
popq %rax
cmoveq %rax, %rcx
movq %rcx, 0x28(%r15)
imulq $0x1c, %rcx, %rsi
movq %rbp, %rdi
movq %r11, %rbp
callq 0x2370
movq %rbp, %r11
movq 0x40(%rsp), %r10
movq %rax, %rbp
movq %rax, 0x18(%r15)
movq 0x20(%r15), %rax
movq 0xc8(%rsp), %rdx
addq %r12, 0xb8(%rsp)
leaq 0x1(%rax), %rcx
movq %rcx, 0x20(%r15)
imulq $0x1c, %rax, %rax
movups 0x5c(%rsp), %xmm0
movups %xmm0, 0xc(%rbp,%rax)
movaps 0x50(%rsp), %xmm0
movups %xmm0, (%rbp,%rax)
jmp 0x44c54
movq 0x48(%rsp), %r13
movq 0xa8(%rsp), %r12
incq %rdx
addq $0x1c, %r14
jmp 0x44aa2
imulq $0xa8, %r14, %rsi
addq %r12, %rsi
movl (%r15), %eax
imulq $0xa8, %rax, %rdx
addq %r12, %rdx
leaq 0xa0(%rsp), %rax
movq %rax, (%rsp)
movq %rbx, %rdi
movq 0xd0(%rsp), %rcx
movq 0x190(%rsp), %r8
movsd 0x90(%rsp), %xmm0
leaq 0x88(%rsp), %r9
callq 0x42389
testq %rax, %rax
je 0x44d01
cmpq $0x0, 0x88(%rsp)
movq 0xa0(%rsp), %rcx
movq 0x48(%rsp), %r13
movq (%r13), %rbp
movq 0x40(%rsp), %r10
movq 0xb0(%rsp), %r11
movq 0x80(%rsp), %rbx
movq 0xc0(%rsp), %r14
je 0x44d38
movl (%rbp,%r14), %r15d
movq 0x78(%rsp), %rax
jmp 0x44bad
movq 0x48(%rsp), %r13
movq 0x40(%rsp), %r10
movq 0xa8(%rsp), %r12
movq 0xb0(%rsp), %r11
movq 0x80(%rsp), %rbx
movq 0xc8(%rsp), %rdx
movq 0xc0(%rsp), %r14
jmp 0x44c5c
movq (%r10), %rdx
movl (%rbp,%rbx), %eax
imulq $0xa8, %rax, %rsi
movl 0x30(%rdx,%rsi), %esi
movl (%rbp,%r14), %r15d
imulq $0xa8, %r15, %rdi
movl 0x30(%rdx,%rdi), %edx
leaq (%rdx,%rsi), %rdi
movq %rsi, %r8
subq %rdx, %r8
movq %rdx, %r9
subq %rsi, %r9
cmpl %edx, %esi
cmovaeq %r8, %r9
addq %rdi, %r9
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
cmpq %rdx, %r9
cmovaeq %rdx, %r9
movl %r9d, 0x54(%rsp)
movl %ecx, 0x58(%rsp)
movq 0x78(%rsp), %rcx
andl $0xbfffffff, %ecx       # imm = 0xBFFFFFFF
movq %rcx, 0x78(%rsp)
movl %ecx, 0x68(%rsp)
movl 0x8(%rbp,%r14), %ecx
subl 0x4(%rbp,%r14), %ecx
movl %ecx, 0x60(%rsp)
movl 0x8(%rbp,%rbx), %r12d
subl 0x4(%rbp,%rbx), %r12d
movl %r12d, 0x64(%rsp)
addl %ecx, %r12d
jmp 0x44bd1
imulq $0x1c, %r11, %r14
addq $-0x1c, %r14
testq %r11, %r11
jle 0x4507f
movq (%r10), %r12
movq (%r13), %rbp
movl (%rbp,%r14), %eax
imulq $0xa8, %rax, %rsi
movl 0x10(%r12,%rsi), %eax
movl (%rbp,%rbx), %ecx
imulq $0xa8, %rcx, %rcx
cmpl 0x10(%r12,%rcx), %eax
jae 0x44ee3
movq %r11, %r15
andq $0x0, 0x88(%rsp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, 0xa0(%rsp)
addq %r12, %rsi
leaq 0x110(%rsp), %rdi
movq 0x98(%rsp), %r13
movq %r13, %rdx
callq 0x3d508
movl (%rbp,%r14), %ebx
movl %ebx, 0x110(%rsp)
movq 0xf0(%rsp), %rdi
movq 0xf8(%rsp), %rsi
leaq 0x12c(%rsp), %rdx
leaq 0x110(%rsp), %rcx
pushq $0x10
popq %r8
movsd 0x90(%rsp), %xmm0
callq 0x447cd
testq %rax, %rax
jne 0x44eef
movq 0x80(%rsp), %rax
addq %rax, %rbp
imulq $0xa8, %rbx, %rsi
movq %rax, %rbx
addq %r12, %rsi
movl (%rbp), %eax
imulq $0xa8, %rax, %rdx
addq %r12, %rdx
leaq 0xa0(%rsp), %rax
movq %rax, (%rsp)
movq %r13, %rdi
movq 0xd0(%rsp), %rcx
movq 0x190(%rsp), %r8
movsd 0x90(%rsp), %xmm0
leaq 0x88(%rsp), %r9
callq 0x42389
testq %rax, %rax
movq 0x48(%rsp), %r13
movq 0x40(%rsp), %r10
movq %r15, %r11
jne 0x44f0f
addq $-0x1c, %r14
decq %r11
jmp 0x44dc9
movq $0x1, 0x88(%rsp)
pushq $-0x1
popq %rax
movl %eax, %ecx
movq 0x40(%rsp), %r10
movq 0x78(%rsp), %r12
movq %r15, %r11
jmp 0x44f34
cmpq $0x0, 0x88(%rsp)
movq 0xa0(%rsp), %rcx
movq (%r13), %rbp
je 0x44feb
movl (%rbp,%r14), %ebx
movq 0x78(%rsp), %r12
movq 0x70(%rsp), %r15
andl $0x0, 0x54(%rsp)
movl %ecx, 0x58(%rsp)
andq $0x0, 0x60(%rsp)
orl $0x40000000, %r12d      # imm = 0x40000000
movl %r12d, 0x68(%rsp)
movq 0x80(%rsp), %rax
movl (%rbp,%rax), %eax
xorl %r14d, %r14d
movl %ebx, 0x50(%rsp)
movl %eax, 0x5c(%rsp)
movq 0x20(%r15), %rax
cmpq 0x28(%r15), %rax
jne 0x44fa9
leaq (%rax,%rax), %rcx
testq %rax, %rax
pushq $0x2
popq %rax
cmoveq %rax, %rcx
movq %rcx, 0x28(%r15)
imulq $0x1c, %rcx, %rsi
movq %rbp, %rdi
movq %r11, %rbx
callq 0x2370
movq %rbx, %r11
movq 0x40(%rsp), %r10
movq %rax, %rbp
movq %rax, 0x18(%r15)
movq 0x20(%r15), %rax
movq 0x48(%rsp), %r13
movq 0x80(%rsp), %rbx
movq %r12, 0x78(%rsp)
addq %r14, 0xb8(%rsp)
decq %r11
leaq 0x1(%rax), %rcx
movq %rcx, 0x20(%r15)
imulq $0x1c, %rax, %rax
movups 0x5c(%rsp), %xmm0
movups %xmm0, 0xc(%rbp,%rax)
movaps 0x50(%rsp), %xmm0
movups %xmm0, (%rbp,%rax)
jmp 0x44dc1
movq (%r10), %rdx
movl (%rbp,%rbx), %eax
imulq $0xa8, %rax, %rsi
movl 0x30(%rdx,%rsi), %esi
movq %r11, %r15
movq %rbx, %r11
movl (%rbp,%r14), %ebx
imulq $0xa8, %rbx, %rdi
movl 0x30(%rdx,%rdi), %edx
leaq (%rdx,%rsi), %rdi
movq %rsi, %r8
subq %rdx, %r8
movq %rdx, %r9
subq %rsi, %r9
cmpl %edx, %esi
cmovaeq %r8, %r9
addq %rdi, %r9
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
cmpq %rdx, %r9
cmovaeq %rdx, %r9
movl %r9d, 0x54(%rsp)
movl %ecx, 0x58(%rsp)
movq 0x78(%rsp), %r12
andl $0xbfffffff, %r12d      # imm = 0xBFFFFFFF
movl %r12d, 0x68(%rsp)
movl 0x8(%rbp,%r14), %ecx
subl 0x4(%rbp,%r14), %ecx
movl %ecx, 0x60(%rsp)
movl 0x8(%rbp,%r11), %r14d
subl 0x4(%rbp,%r11), %r14d
movq %r15, %r11
movl %r14d, 0x64(%rsp)
addl %ecx, %r14d
movq 0x70(%rsp), %r15
jmp 0x44f63
addq $0x1c, 0xe0(%rsp)
movq 0x108(%rsp), %r8
movq 0xa8(%rsp), %r12
movq 0xb8(%rsp), %rcx
jmp 0x44a12
movq 0x198(%rsp), %rax
shlq $0x8, %rax
cmpq %rax, %rcx
movq 0x70(%rsp), %rbx
jbe 0x4512e
movq 0xd8(%rsp), %rbp
shlq $0x5, %rbp
movq 0x20(%rbx), %r14
cmpq %rbp, %rcx
jbe 0x45134
cmpq %rbp, %rax
cmovaq %rax, %rbp
movq (%r13), %rax
imulq $0x1c, %r12, %r15
leaq (%rax,%r15), %rdi
imulq $0x1c, %r14, %rsi
addq %rax, %rsi
callq 0x1a05e
addq $0x18, %r15
xorl %eax, %eax
movq %r12, %rbx
movq %rbp, %rsi
cmpq %r14, %rbx
jge 0x45139
cmpq %rsi, %rax
ja 0x45139
movq 0x48(%rsp), %rcx
movq (%rcx), %rcx
testb $0x40, 0x3(%rcx,%r15)
jne 0x45125
movl -0x8(%rcx,%r15), %edx
movl -0x4(%rcx,%r15), %ecx
addq %rdx, %rax
addq %rcx, %rax
incq %rbx
addq $0x1c, %r15
jmp 0x450fb
movq 0x20(%rbx), %rbx
jmp 0x4514c
movq %r14, %rbx
jmp 0x4514c
movq 0x70(%rsp), %rax
movq %rbx, 0x20(%rax)
movq 0x48(%rsp), %r13
movq 0x40(%rsp), %r10
xorps %xmm0, %xmm0
movups %xmm0, 0x5c(%rsp)
movaps %xmm0, 0x50(%rsp)
xorl %r14d, %r14d
movsd 0x90(%rsp), %xmm0
cmpq %rbx, %r12
jge 0x45241
movq (%r13), %rax
movq 0xe8(%rsp), %rsi
movl (%rax,%rsi), %edx
movl 0xc(%rax,%rsi), %ecx
testb $0x40, 0x1b(%rax,%rsi)
jne 0x451f8
movl 0x8(%rax,%rsi), %eax
movq (%r10), %rsi
leaq 0x50(%rsp), %rdi
movq %rdi, 0x30(%rsp)
movq 0x1a0(%rsp), %rdi
movq %rdi, 0x28(%rsp)
movq 0x188(%rsp), %rdi
movq %rdi, 0x20(%rsp)
movq 0x180(%rsp), %rdi
movq %rdi, 0x18(%rsp)
movq %rax, 0x10(%rsp)
movq 0x190(%rsp), %rax
movq %rax, (%rsp)
movq 0x98(%rsp), %rdi
movq 0xd0(%rsp), %r8
movq %r13, %r9
callq 0x44445
testl %eax, %eax
je 0x4523a
movq (%r13), %rax
movq 0x40(%rsp), %r10
jmp 0x4520f
movl %edx, 0x50(%rsp)
movl %ecx, 0x5c(%rsp)
orb $0x40, 0x6b(%rsp)
andl $0x0, 0x60(%rsp)
andl $0x0, 0x54(%rsp)
imulq $0x1c, %r14, %rcx
incq %r14
movups 0x5c(%rsp), %xmm0
movups %xmm0, 0xc(%rax,%rcx)
movaps 0x50(%rsp), %xmm0
movups %xmm0, (%rax,%rcx)
incq %r12
addq $0x1c, 0xe8(%rsp)
jmp 0x4515c
movq 0x40(%rsp), %r10
jmp 0x45229
movq 0x70(%rsp), %rbx
movq %r14, 0x20(%rbx)
testq %r14, %r14
je 0x452f9
movq 0x18(%rbx), %rsi
leaq (%r14,%r14), %rax
cmpq %rax, 0x28(%rbx)
jae 0x452b6
decq %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x10, %rcx
orq %rax, %rcx
incq %rcx
movq %rcx, 0x28(%rbx)
imulq $0x1c, %rcx, %rax
movq %rsi, %rdi
movq %rax, %rsi
callq 0x2370
movq %rax, %rsi
movq %rax, 0x18(%rbx)
movq 0x20(%rbx), %r14
imulq $0x1c, %r14, %rdx
leaq (%rsi,%rdx), %rdi
callq 0x2160
movq 0x18(%rbx), %rdi
movq 0x20(%rbx), %rax
movq %rbx, %rcx
leaq (%rax,%rax), %rbx
movq %rbx, 0x20(%rcx)
imulq $0x1c, %rax, %rcx
addq %rdi, %rcx
cmpq %rbx, %rax
jge 0x45300
movq (%rcx), %rdx
movq 0xc(%rcx), %rsi
movq %rsi, (%rcx)
movq %rdx, 0xc(%rcx)
incq %rax
addq $0x1c, %rcx
jmp 0x452dd
xorl %eax, %eax
jmp 0x45406
imulq $0x1c, %rbx, %rsi
addq %rdi, %rsi
callq 0x1ad03
movq 0x40(%rsp), %r8
movq 0x10(%r8), %rdx
movq 0x70(%rsp), %r15
cmpq %rdx, 0x8(%r15)
jae 0x4537d
decq %rdx
movq %rdx, %rax
shrq %rax
orq %rdx, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x10, %rax
orq %rcx, %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%r15)
movq 0x10(%r15), %rdi
leaq 0x8(,%rax,8), %rsi
movq %r8, %r14
callq 0x2370
movq %rax, %rdi
movq %rax, 0x10(%r15)
movq 0x10(%r14), %rdx
jmp 0x45381
movq 0x10(%r15), %rdi
movq %rdx, (%r15)
shlq $0x3, %rdx
xorl %r14d, %r14d
xorl %esi, %esi
callq 0x20e0
pushq $0x1
popq %r12
pushq $0x1c
popq %r15
movq %r12, %rbp
cmpq %rbx, %r12
jg 0x45403
movq 0x48(%rsp), %rax
movq (%rax), %rsi
je 0x453b9
imulq $0x1c, %r14, %rax
movl (%rsi,%rax), %eax
cmpl (%rsi,%r15), %eax
je 0x453fa
movq %r12, %rax
subq %r14, %rax
cmpq $0x2, %rax
jl 0x453dc
imulq $0x1c, %r14, %rdi
addq %rsi, %rdi
addq %r15, %rsi
callq 0x1aa87
movq 0x48(%rsp), %rax
movq (%rax), %rsi
imulq $0x1c, %r14, %rax
shlq $0x20, %r14
orq %r12, %r14
movq 0x70(%rsp), %rcx
movq 0x10(%rcx), %rcx
movl (%rsi,%rax), %eax
movq %r14, (%rcx,%rax,8)
movq %r12, %r14
incq %r12
addq $0x1c, %r15
jmp 0x4539d
movq %rbp, %rax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq