// File: /workspace/github_cpp_makefile_star2_O3/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
movq %r9, 0xb8(%rsp)
movq %rsi, 0xe0(%rsp)
movq %rdi, 0xd8(%rsp)
xorl %eax, %eax
movq %rax, (%r8)
movq 0x10(%rcx), %r14
movq %rax, 0x20(%r8)
testq %r14, %r14
jle 0x7762f
movq %rdx, 0xa0(%rsp)
movq %r8, 0x48(%rsp)
leaq 0x18(%r8), %rax
movq %rax, 0x40(%rsp)
xorl %ebx, %ebx
movl $0x2, %r15d
xorl %r12d, %r12d
movq %rcx, 0x38(%rsp)
movsd %xmm0, 0x80(%rsp)
movq 0x48(%rsp), %r13
movq (%rcx), %rdx
cmpl $0x0, 0xc(%rdx,%rbx)
je 0x76b8f
movq 0xa0(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rax
movl 0x10(%rdx,%rbx), %ecx
addq %rbx, %rdx
movl (%rax,%rcx,8), %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
movq %r12, %rdi
leaq 0x50(%rsp), %rcx
callq 0x735d2
movq 0x38(%rsp), %rcx
testq %rax, %rax
je 0x76b8f
movq 0x18(%r13), %rax
movq 0x20(%r13), %rsi
cmpq 0x28(%r13), %rsi
jne 0x76b69
leaq (%rsi,%rsi), %rdx
testq %rsi, %rsi
cmoveq %r15, %rdx
movq %rdx, 0x28(%r13)
leaq (%rdx,%rdx,8), %rcx
leaq (%rcx,%rcx,2), %rsi
addq %rdx, %rsi
movq %rax, %rdi
callq 0x2370
movq 0x38(%rsp), %rcx
movq %rax, 0x18(%r13)
movq 0x20(%r13), %rsi
leaq 0x1(%rsi), %rdx
movq %rdx, 0x20(%r13)
leaq (%rsi,%rsi,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rsi, %rdx
movups 0x50(%rsp), %xmm0
movups 0x5c(%rsp), %xmm1
movups %xmm1, 0xc(%rax,%rdx)
movups %xmm0, (%rax,%rdx)
incq %r12
addq $0xa8, %rbx
cmpq %r12, %r14
jne 0x76ae7
movq 0x48(%rsp), %r14
movq 0x20(%r14), %r15
testq %r15, %r15
je 0x7762d
xorps %xmm0, %xmm0
movups %xmm0, 0x5c(%rsp)
movaps %xmm0, 0x50(%rsp)
movq 0x40(%rsp), %rbx
movq (%rbx), %rdi
leaq (%r15,%r15,8), %rax
leaq (%rax,%rax,2), %rax
leaq (%rdi,%r15), %rsi
movq %rax, 0xb0(%rsp)
addq %rax, %rsi
callq 0x463ee
movq 0x38(%rsp), %r10
testq %r15, %r15
jle 0x7739a
movq $0x0, 0x88(%rsp)
movl $0x1c, %r14d
movl $0x1, %eax
movq %rax, 0xc8(%rsp)
movq $-0x1c, 0xc0(%rsp)
xorl %eax, %eax
xorl %r12d, %r12d
movq $0x0, 0x90(%rsp)
movq %r15, 0xd0(%rsp)
movq %r12, 0x108(%rsp)
movq %rax, %r13
movq (%rbx), %rbx
leaq (%rax,%rax,8), %rax
leaq (%rax,%rax,2), %r12
addq %r13, %r12
movl 0x8(%rbx,%r12), %eax
subl 0x4(%rbx,%r12), %eax
movq %rax, 0xf0(%rsp)
movl (%rbx,%r12), %eax
imulq $0xa8, %rax, %rsi
addq (%r10), %rsi
leaq 0x12c(%rsp), %rdi
movq 0xa0(%rsp), %rdx
callq 0x6ecd8
movq %r12, %r11
movl (%rbx,%r12), %eax
movl %eax, 0x12c(%rsp)
movq %r13, 0xe8(%rsp)
incq %r13
cmpq %r15, %r13
movq %r12, 0x78(%rsp)
movq %r14, 0x100(%rsp)
movq %r13, 0xf8(%rsp)
jge 0x76fa4
movq %r14, %r15
movq 0x40(%rsp), %rbx
movq 0x38(%rsp), %r10
movq (%rbx), %r12
movl 0x4(%r12,%r15), %eax
cmpl 0x8(%r12,%r11), %eax
jae 0x76fae
leaq (%r12,%r11), %r14
movq (%r10), %rbp
movl (%r12,%r15), %eax
imulq $0xa8, %rax, %rsi
movl 0x10(%rbp,%rsi), %eax
movl (%r14), %ecx
imulq $0xa8, %rcx, %rcx
cmpl 0x10(%rbp,%rcx), %eax
jae 0x76e61
movq $0x0, 0x98(%rsp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, 0xa8(%rsp)
addq %rbp, %rsi
leaq 0x110(%rsp), %rdi
movq 0xa0(%rsp), %rdx
callq 0x6ecd8
movl (%r12,%r15), %ebx
movl %ebx, 0x110(%rsp)
movl $0x10, %r8d
movq 0xd8(%rsp), %rdi
movq 0xe0(%rsp), %rsi
leaq 0x12c(%rsp), %rdx
leaq 0x110(%rsp), %rcx
movsd 0x80(%rsp), %xmm0
callq 0x769ca
testq %rax, %rax
je 0x76e7b
movq $0x1, 0x98(%rsp)
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq 0x48(%rsp), %r14
movq 0x38(%rsp), %r10
movq 0x78(%rsp), %r11
movl $0x0, 0x54(%rsp)
movl %ecx, 0x58(%rsp)
movq $0x0, 0x60(%rsp)
movq 0x88(%rsp), %rax
orl $0x40000000, %eax       # imm = 0x40000000
movq %rax, 0x88(%rsp)
movl %eax, 0x68(%rsp)
movl (%r12,%r11), %eax
xorl %ebp, %ebp
movl %ebx, 0x50(%rsp)
movl %eax, 0x5c(%rsp)
movq 0x20(%r14), %rax
cmpq 0x28(%r14), %rax
jne 0x76e21
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rcx
movq %rcx, 0x28(%r14)
leaq (%rcx,%rcx,8), %rax
leaq (%rax,%rax,2), %rsi
addq %rcx, %rsi
movq %r12, %rdi
callq 0x2370
movq 0x78(%rsp), %r11
movq 0x38(%rsp), %r10
movq %rax, %r12
movq %rax, 0x18(%r14)
movq 0x20(%r14), %rax
movq 0x40(%rsp), %rbx
movq 0x90(%rsp), %rcx
addq %rbp, %rcx
movq %rcx, 0x90(%rsp)
leaq 0x1(%rax), %rcx
movq %rcx, 0x20(%r14)
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %rax, %rcx
movups 0x5c(%rsp), %xmm0
movups %xmm0, 0xc(%r12,%rcx)
movaps 0x50(%rsp), %xmm0
movups %xmm0, (%r12,%rcx)
incq %r13
addq $0x1c, %r15
cmpq 0xd0(%rsp), %r13
jl 0x76cc9
jmp 0x76fae
imulq $0xa8, %rbx, %rsi
addq %rbp, %rsi
movl (%r14), %eax
imulq $0xa8, %rax, %rdx
addq %rbp, %rdx
leaq 0xa8(%rsp), %rax
movq %rax, (%rsp)
movq 0xa0(%rsp), %rdi
movq 0xb8(%rsp), %rcx
movq 0x190(%rsp), %r8
movsd 0x80(%rsp), %xmm0
leaq 0x98(%rsp), %r9
callq 0x74490
testq %rax, %rax
je 0x76f04
cmpq $0x0, 0x98(%rsp)
movq 0xa8(%rsp), %rcx
movq 0x40(%rsp), %rax
movq (%rax), %r12
movq 0x48(%rsp), %r14
movq 0x38(%rsp), %r10
movq 0x78(%rsp), %r11
je 0x76f18
movl (%r12,%r15), %ebx
jmp 0x76d9f
movq 0x40(%rsp), %rbx
movq 0x38(%rsp), %r10
movq 0x78(%rsp), %r11
jmp 0x76e61
movq (%r10), %rdx
movl (%r12,%r11), %eax
imulq $0xa8, %rax, %rsi
movl 0x30(%rdx,%rsi), %esi
movl (%r12,%r15), %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 0x88(%rsp), %rcx
andl $0xbfffffff, %ecx       # imm = 0xBFFFFFFF
movq %rcx, 0x88(%rsp)
movl %ecx, 0x68(%rsp)
movl 0x8(%r12,%r15), %ecx
subl 0x4(%r12,%r15), %ecx
movl %ecx, 0x60(%rsp)
movl 0x8(%r12,%r11), %ebp
subl 0x4(%r12,%r11), %ebp
movl %ebp, 0x64(%rsp)
addl %ecx, %ebp
jmp 0x76dd3
movq 0x40(%rsp), %rbx
movq 0x38(%rsp), %r10
cmpq $0x0, 0xe8(%rsp)
je 0x77295
movq 0xc0(%rsp), %r15
movq 0xc8(%rsp), %r13
movq (%r10), %rbp
movq (%rbx), %r12
movl (%r12,%r15), %eax
imulq $0xa8, %rax, %rsi
movl 0x10(%rbp,%rsi), %eax
movl (%r12,%r11), %ecx
imulq $0xa8, %rcx, %rcx
cmpl 0x10(%rbp,%rcx), %eax
jae 0x77155
movq $0x0, 0x98(%rsp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, 0xa8(%rsp)
addq %rbp, %rsi
leaq 0x110(%rsp), %rdi
movq 0xa0(%rsp), %r14
movq %r14, %rdx
callq 0x6ecd8
movl (%r12,%r15), %ebx
movl %ebx, 0x110(%rsp)
movl $0x10, %r8d
movq 0xd8(%rsp), %rdi
movq 0xe0(%rsp), %rsi
leaq 0x12c(%rsp), %rdx
leaq 0x110(%rsp), %rcx
movsd 0x80(%rsp), %xmm0
callq 0x769ca
testq %rax, %rax
je 0x7716b
movq $0x1, 0x98(%rsp)
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq 0x38(%rsp), %r10
movq 0x48(%rsp), %r14
movq 0x78(%rsp), %r11
movl $0x0, 0x54(%rsp)
movl %ecx, 0x58(%rsp)
movq $0x0, 0x60(%rsp)
movq 0x88(%rsp), %rax
orl $0x40000000, %eax       # imm = 0x40000000
movq %rax, 0x88(%rsp)
movl %eax, 0x68(%rsp)
movl (%r12,%r11), %eax
xorl %ebp, %ebp
movl %ebx, 0x50(%rsp)
movl %eax, 0x5c(%rsp)
movq 0x20(%r14), %rax
cmpq 0x28(%r14), %rax
jne 0x77115
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rcx
movq %rcx, 0x28(%r14)
leaq (%rcx,%rcx,8), %rax
leaq (%rax,%rax,2), %rsi
addq %rcx, %rsi
movq %r12, %rdi
callq 0x2370
movq 0x78(%rsp), %r11
movq 0x38(%rsp), %r10
movq %rax, %r12
movq %rax, 0x18(%r14)
movq 0x20(%r14), %rax
movq 0x40(%rsp), %rbx
movq 0x90(%rsp), %rcx
addq %rbp, %rcx
movq %rcx, 0x90(%rsp)
leaq 0x1(%rax), %rcx
movq %rcx, 0x20(%r14)
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %rax, %rcx
movups 0x5c(%rsp), %xmm0
movups %xmm0, 0xc(%r12,%rcx)
movaps 0x50(%rsp), %xmm0
movups %xmm0, (%r12,%rcx)
decq %r13
addq $-0x1c, %r15
cmpq $0x1, %r13
jg 0x76fcd
jmp 0x77295
addq 0x78(%rsp), %r12
imulq $0xa8, %rbx, %rsi
addq %rbp, %rsi
movl (%r12), %eax
imulq $0xa8, %rax, %rdx
addq %rbp, %rdx
leaq 0xa8(%rsp), %rax
movq %rax, (%rsp)
movq %r14, %rdi
movq 0xb8(%rsp), %rcx
movq 0x190(%rsp), %r8
movsd 0x80(%rsp), %xmm0
leaq 0x98(%rsp), %r9
callq 0x74490
testq %rax, %rax
je 0x771f0
cmpq $0x0, 0x98(%rsp)
movq 0xa8(%rsp), %rcx
movq 0x40(%rsp), %rax
movq (%rax), %r12
movq 0x38(%rsp), %r10
movq 0x48(%rsp), %r14
je 0x77204
movl (%r12,%r15), %ebx
jmp 0x7708e
movq 0x40(%rsp), %rbx
movq 0x38(%rsp), %r10
movq 0x78(%rsp), %r11
jmp 0x77155
movq (%r10), %rdx
movq 0x78(%rsp), %r11
movl (%r12,%r11), %eax
imulq $0xa8, %rax, %rsi
movl 0x30(%rdx,%rsi), %esi
movl (%r12,%r15), %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 0x88(%rsp), %rcx
andl $0xbfffffff, %ecx       # imm = 0xBFFFFFFF
movq %rcx, 0x88(%rsp)
movl %ecx, 0x68(%rsp)
movl 0x8(%r12,%r15), %ecx
subl 0x4(%r12,%r15), %ecx
movl %ecx, 0x60(%rsp)
movl 0x8(%r12,%r11), %ebp
subl 0x4(%r12,%r11), %ebp
movl %ebp, 0x64(%rsp)
addl %ecx, %ebp
jmp 0x770c7
movq 0x108(%rsp), %r12
addq 0xf0(%rsp), %r12
movq 0x100(%rsp), %r14
addq $0x1c, %r14
incq 0xc8(%rsp)
addq $0x1c, 0xc0(%rsp)
movq 0xd0(%rsp), %r15
movq 0xf8(%rsp), %rax
cmpq %r15, %rax
jne 0x76c37
movq 0x198(%rsp), %rcx
shlq $0x8, %rcx
movq 0x90(%rsp), %rdx
cmpq %rcx, %rdx
movq 0x48(%rsp), %r14
jbe 0x7739a
movq %rcx, %rax
shlq $0x5, %r12
movq 0x20(%r14), %r14
cmpq %r12, %rdx
jbe 0x7739e
cmpq %r12, %rax
cmovaq %rax, %r12
movq (%rbx), %rsi
movq 0xb0(%rsp), %rax
leaq (%rax,%r15), %rbx
leaq (%rsi,%rbx), %rdi
leaq (%r14,%r14,8), %rax
leaq (%rax,%rax,2), %rax
addq %r14, %rsi
addq %rax, %rsi
callq 0x463ee
movq %r15, %rax
cmpq %r14, %r15
movsd 0x80(%rsp), %xmm0
jge 0x77387
movq 0x40(%rsp), %rax
movq (%rax), %rax
leaq (%rax,%rbx), %rcx
addq $0x18, %rcx
xorl %edx, %edx
movq %r15, %rax
testb $0x40, 0x3(%rcx)
jne 0x77376
movl -0x8(%rcx), %esi
movl -0x4(%rcx), %edi
addq %rsi, %rdx
addq %rdi, %rdx
incq %rax
cmpq %r14, %rax
jge 0x77387
addq $0x1c, %rcx
cmpq %r12, %rdx
jbe 0x77364
movq 0x48(%rsp), %rcx
movq %rax, 0x20(%rcx)
movq %rax, %r14
movq 0x38(%rsp), %r10
jmp 0x773a7
movq 0x20(%r14), %r14
movsd 0x80(%rsp), %xmm0
movq 0xb0(%rsp), %rsi
xorps %xmm1, %xmm1
movups %xmm1, 0x5c(%rsp)
movaps %xmm1, 0x50(%rsp)
subq %r15, %r14
jle 0x774be
addq %r15, %rsi
xorl %r15d, %r15d
xorl %ebx, %ebx
movq 0x40(%rsp), %r13
movq (%r13), %rax
movl (%rax,%rsi), %edx
movl 0x8(%rax,%rsi), %r12d
movl 0xc(%rax,%rsi), %ecx
testb $0x40, 0x1b(%rax,%rsi)
jne 0x77464
movq %rsi, %rbp
movq (%r10), %rsi
leaq 0x50(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x1a0(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x188(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x180(%rsp), %rax
movq %rax, 0x18(%rsp)
movq %r12, 0x10(%rsp)
movq 0x190(%rsp), %rax
movq %rax, (%rsp)
movq 0xa0(%rsp), %rdi
movq 0xb8(%rsp), %r8
movq %r13, %r9
callq 0x7661f
testl %eax, %eax
je 0x774ab
movq (%r13), %rax
movq 0x38(%rsp), %r10
movsd 0x80(%rsp), %xmm0
movq %rbp, %rsi
jmp 0x7747b
movl %edx, 0x50(%rsp)
movl %ecx, 0x5c(%rsp)
orb $0x40, 0x6b(%rsp)
movl %r15d, 0x60(%rsp)
movl %r15d, 0x54(%rsp)
leaq (%rbx,%rbx,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %rbx, %rcx
incq %rbx
movups 0x5c(%rsp), %xmm1
movups %xmm1, 0xc(%rax,%rcx)
movaps 0x50(%rsp), %xmm1
movups %xmm1, (%rax,%rcx)
addq $0x1c, %rsi
decq %r14
jne 0x773d2
jmp 0x774d0
movq 0x38(%rsp), %r10
movsd 0x80(%rsp), %xmm0
movq %rbp, %rsi
jmp 0x7749c
movq 0x48(%rsp), %rax
movq $0x0, 0x20(%rax)
jmp 0x7762d
movq %r12, 0xa8(%rsp)
movq 0x48(%rsp), %r14
movq %rbx, 0x20(%r14)
testq %rbx, %rbx
je 0x7762d
movq 0x18(%r14), %rsi
leaq (%rbx,%rbx), %rax
cmpq %rax, 0x28(%r14)
jae 0x77558
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
leaq 0x1(%rcx), %rax
movq %rax, 0x28(%r14)
leaq (%rax,%rax,8), %rax
leaq (%rax,%rax,2), %rax
addq %rcx, %rax
incq %rax
movq %rsi, %rdi
movq %rax, %rsi
callq 0x2370
movq %rax, %rsi
movq %rax, 0x18(%r14)
movq 0x20(%r14), %rbx
leaq (%rbx,%rbx,8), %rax
leaq (%rax,%rax,2), %rdx
addq %rbx, %rdx
leaq (%rsi,%rdx), %rdi
callq 0x2160
movq 0x18(%r14), %rdi
movq 0x20(%r14), %rax
movq %r14, %rcx
leaq (%rax,%rax), %r14
movq %r14, 0x20(%rcx)
cmpq %r14, %rax
jge 0x775a9
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %rdi, %rcx
addq %rax, %rcx
movq (%rcx), %rdx
movq 0xc(%rcx), %rsi
movq %rsi, (%rcx)
movq %rdx, 0xc(%rcx)
addq $0x1c, %rcx
decq %rax
jne 0x77592
leaq (%r14,%r14,8), %rax
leaq (%rax,%rax,2), %rsi
addq %r14, %rsi
addq %rdi, %rsi
callq 0x4709d
movq 0x38(%rsp), %r8
movq 0x10(%r8), %rdx
movq 0x48(%rsp), %rbx
cmpq %rdx, 0x8(%rbx)
jae 0x77641
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(%rbx)
movq 0x10(%rbx), %rdi
leaq 0x8(,%rax,8), %rsi
movq %r8, %r15
callq 0x2370
movq %rax, %rdi
movq %rax, 0x10(%rbx)
movq 0x10(%r15), %rdx
jmp 0x77645
xorl %eax, %eax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%rbx), %rdi
movq %rdx, (%rbx)
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x20e0
testq %r14, %r14
jle 0x776f4
movq 0x40(%rsp), %rax
movq (%rax), %rsi
negq %r14
movl $0x1, %ebx
movl $0x1c, %r15d
xorl %r12d, %r12d
movq %r14, %rax
addq %rbx, %rax
je 0x77691
leaq (%r12,%r12,8), %rax
leaq (%rax,%rax,2), %rax
addq %r12, %rax
movl (%rsi,%rax), %eax
cmpl (%rsi,%r15), %eax
je 0x776e0
movq %rbx, %rax
subq %r12, %rax
cmpq $0x2, %rax
jl 0x776bb
leaq (%r12,%r12,8), %rax
leaq (%rax,%rax,2), %rdi
addq %rsi, %rdi
addq %r12, %rdi
addq %r15, %rsi
callq 0x46e1e
movq 0x40(%rsp), %rax
movq (%rax), %rsi
leaq (%r12,%r12,8), %rax
leaq (%rax,%rax,2), %rax
addq %r12, %rax
shlq $0x20, %r12
orq %rbx, %r12
movq 0x48(%rsp), %rcx
movq 0x10(%rcx), %rcx
movl (%rsi,%rax), %eax
movq %r12, (%rcx,%rax,8)
movq %rbx, %r12
leaq (%r14,%rbx), %rax
incq %rax
incq %rbx
addq $0x1c, %r15
cmpq $0x1, %rax
jne 0x77675
movl $0x1, %eax
jmp 0x7762f