// File: chhylp123[P]hifiasm/gfa_ut.cpp
// Function: refine_integer_ovlps(all_ul_t*, bubble_type*, ma_ug_t*, ul_str_t*, integer_aln_t*, ul_chain_t*, long, integer_t*, unsigned long*, unsigned long)
int64_t refine_integer_ovlps(all_ul_t *ul_idx, bubble_type *bub, ma_ug_t *ug, ul_str_t *str, integer_aln_t *aln, ul_chain_t *idx, int64_t qid, integer_t *buf, 
uint64_t *cns, uint64_t cns_occ)
{
    if(idx->e<=idx->s) return 0;
    int64_t qk, tk, is_rev, tid, q_end, t_end, z; 
    ul_str_t *q_str, *t_str; uc_block_t *t_b; integer_aln_t *x, *y; 
    tid = aln[idx->s].tn_rev_qk>>33; is_rev = ((aln[idx->s].tn_rev_qk>>32)&1);
    q_str = &(str[qid]); t_str = &(str[tid]); 
    kv_resize(uint64_t, buf->u, buf->u.n + q_str->cn + t_str->cn);
    uint64_t *q_cov_buf = buf->u.a + buf->u.n, *t_cov_buf = buf->u.a + buf->u.n + q_str->cn, k, rg_occ, cn_k, mm;
    memset(q_cov_buf, -1, sizeof((*q_cov_buf))*q_str->cn); memset(t_cov_buf, -1, sizeof((*t_cov_buf))*t_str->cn);
    // if(tid != 392) return 0;
    //beg
    x = &(aln[idx->s]);
    qk = (uint32_t)(x->tn_rev_qk); tk = ((is_rev == 0)? (x->tk):(t_str->cn - x->tk - 1));

    ///direction
    if((qk > 0) && (x->tk > 0)) {
        integer_align_extention(ug, ul_idx, qid, q_str, tid, t_str, is_rev, q_cov_buf, t_cov_buf, x, 1, &q_end, &t_end);
        idx->q_sidx = q_end; idx->t_sidx = ((is_rev == 0)? (t_end):(t_str->cn - t_end - 1));
    } else {
        idx->q_sidx = (uint32_t)(x->tn_rev_qk); idx->t_sidx = x->tk;
    }
    // if(!((idx->q_sidx <= ((uint32_t)(x->tn_rev_qk))) && (idx->t_sidx <= x->tk))) {
    //     fprintf(stderr, "[M::%s] qid::%ld, tid::%ld\n", __func__, qid, tid);
    // }
    assert((idx->q_sidx <= ((uint32_t)(x->tn_rev_qk)))); assert(idx->t_sidx <= x->tk);
    // assert((is_rev && idx->t_sidx >= x->tk) || (is_rev == 0 && idx->t_sidx <= x->tk));

    //end
    x = &(aln[idx->e-1]);
    qk = (uint32_t)(x->tn_rev_qk); tk = ((is_rev == 0)? (x->tk):(t_str->cn - x->tk - 1));
    // if(tid == 316) {
    //     fprintf(stderr, "[end-M::%s::tid->%ld] qk::%ld, tk::%ld, x->tk::%u, t_str->cn::%u\n", 
    //     __func__, tid, qk, tk, x->tk, t_str->cn);
    // }
    ///direction
    if((((uint32_t)qk + 1) < q_str->cn) && ((x->tk + 1) < t_str->cn)) {
        integer_align_extention(ug, ul_idx, qid, q_str, tid, t_str, is_rev, q_cov_buf, t_cov_buf, x, 0, &q_end, &t_end);
        idx->q_eidx = q_end + 1; idx->t_eidx = ((is_rev == 0)? (t_end + 1):(t_str->cn - t_end));
    } else {
        idx->q_eidx = (uint32_t)(x->tn_rev_qk)+1; idx->t_eidx = x->tk+1;
    }

    assert(idx->q_eidx > ((uint32_t)(x->tn_rev_qk))); assert(idx->t_eidx > x->tk);
    // assert((is_rev && idx->t_eidx < x->tk) || (is_rev == 0 && idx->t_eidx > x->tk));

    assert(idx->q_eidx > idx->q_sidx); assert(idx->t_eidx > idx->t_sidx);
    // assert((is_rev && idx->t_eidx < idx->t_sidx) || (is_rev == 0 && idx->t_eidx > idx->t_sidx));
    // if(tid == 284) {
    //     fprintf(stderr, "[M::%s::tid->%ld] idx->q_sidx::%u, idx->q_eidx::%u, idx->t_sidx::%u, idx->t_eidx::%u\n", 
    //     __func__, tid, idx->q_sidx, idx->q_eidx, idx->t_sidx, idx->t_eidx);
    // }

    ///mid
    for (k = idx->s; k < idx->e; k++) {///go through all alignment pairs
        // if(qid == 3113 && tid == 3075) {
        //     fprintf(stderr, "+[M::%s] qid::%ld, tid::%ld, idx->s::%u, idx->e::%u, k::%lu, qk::%u, tk::%u, (idx->v>>1)::%u\n", 
        //     __func__, qid, tid, idx->s, idx->e, k, (uint32_t)(aln[k].tn_rev_qk), aln[k].tk, idx->v>>1);
        // }   
        
        x = &(aln[k]); y = ((k > idx->s)? (&(aln[k-1])):(NULL));
        qk = (uint32_t)(x->tn_rev_qk); 
        q_cov_buf[qk] = buf->u.a[qk]; 

        tk = ((is_rev == 0)? (x->tk):(t_str->cn - x->tk - 1));
        t_b = &(ul_idx->a[tid].bb.a[t_str->a[tk]>>32]);
        assert(((t_b->hid<<1)+t_b->rev)==((uint32_t)t_str->a[tk]));
        t_cov_buf[tk] = ug_occ_w(t_b->ts, t_b->te, &(ug->u.a[t_b->hid]));
    
        q_cov_buf[qk] += ((uint64_t)(0x8000000000000000));
        t_cov_buf[tk] += ((uint64_t)(0x8000000000000000));
        
        if(!y) continue;
        mm = 0;
        if(gap_chain_check(ug, y, x, is_rev, q_str, t_str, ul_idx->a[qid].bb.a, ul_idx->a[tid].bb.a, qid, tid, 0.08, 2000)) {
            mm = ((uint64_t)(0x8000000000000000));
        }
        for (z = ((uint32_t)(y->tn_rev_qk)) + 1; z < qk; z++) {
            q_cov_buf[z] = buf->u.a[z] + mm; 
        }

        z = ((is_rev == 0)? (y->tk):(t_str->cn - x->tk - 1)) + 1;
        tk = ((is_rev == 0)? (x->tk):(t_str->cn - y->tk - 1));
        assert(z <= tk);
        for (; z < tk; z++) {
            t_b = &(ul_idx->a[tid].bb.a[t_str->a[z]>>32]);
            assert(((t_b->hid<<1)+t_b->rev)==((uint32_t)t_str->a[z]));
            t_cov_buf[z] = ug_occ_w(t_b->ts, t_b->te, &(ug->u.a[t_b->hid])) + mm;
        }
    }

    if(cns) {
        int64_t cns_cov_occ = 0, cns_het_occ = 0, match_cns_occ = 0, match_cns_het_occ = 0, hm;
        rg_occ = idx->q_eidx;
        for (k = idx->q_sidx, cn_k = 0; k < rg_occ; k++) {
            assert((q_cov_buf[k]!=(uint64_t)-1) && (q_cov_buf[k] > 0));
            hm = ((q_cov_buf[k]<<1)>>1);
            for (; cn_k < cns_occ; cn_k++) {
                if(cns[cn_k] == k) {
                    cns_cov_occ += hm; 
                    if(q_cov_buf[k]&((uint64_t)(0x8000000000000000))) match_cns_occ += hm; 
                    if(!IF_HOM((((uint32_t)q_str->a[k])>>1), (*bub))) {
                        cns_het_occ += hm;
                        if(q_cov_buf[k]&((uint64_t)(0x8000000000000000))) match_cns_het_occ += hm; 
                    }
                } else if(cns[cn_k] > k) {
                    break;
                }
            }
        }

        if(cns_cov_occ <= 0) return 0;
        if((cns_het_occ > 0) && (match_cns_het_occ <= (cns_het_occ*0.5))) return 0;
        if(match_cns_occ <= (cns_cov_occ*0.5)) return 0;

        k = idx->t_sidx; rg_occ = idx->t_eidx; 
        if(is_rev) {
            k = t_str->cn - idx->t_eidx; rg_occ = t_str->cn - idx->t_sidx;
        }
        cns_cov_occ = match_cns_occ = 0; 
        assert(k < rg_occ);
        for (; k < rg_occ; k++) {
            assert((t_cov_buf[k]!=(uint64_t)-1) && (t_cov_buf[k] > 0));
            hm = ((t_cov_buf[k]<<1)>>1);
            cns_cov_occ += hm; 
            if(t_cov_buf[k]&((uint64_t)(0x8000000000000000))) match_cns_occ += hm; 
        }

        if(cns_cov_occ <= 0 || match_cns_occ <= 0) return 0;
        if(match_cns_occ <= (cns_cov_occ*0.5)) return 0;
    }
    ///not useful for correction
    if((idx->q_sidx + 1 == idx->q_eidx) && (idx->t_sidx + 1 == idx->t_eidx)) {///must matched with at least one cns node
        return 0;
    }

    // /**if(tid == 3074)**/ {
    //     print_integer_ovlps(ug, str, buf->b.a, buf->b.n, idx, 1, qid, buf->o.n);
    //     fprintf(stderr, "[M::%s::tid->%ld] idx->q_sidx::%u, idx->q_eidx::%u, idx->t_sidx::%u, idx->t_eidx::%u\n******************************************************\n", 
    //         __func__, tid, idx->q_sidx, idx->q_eidx, idx->t_sidx, idx->t_eidx);
    // }

    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x28(%rbp)
movq %rsi, -0x30(%rbp)
movq %rdx, -0x38(%rbp)
movq %rcx, -0x40(%rbp)
movq %r8, -0x48(%rbp)
movq %r9, -0x50(%rbp)
movq -0x50(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x50(%rbp), %rcx
cmpl (%rcx), %eax
ja 0x32c584
movq $0x0, -0x20(%rbp)
jmp 0x32d66d
movq -0x48(%rbp), %rax
movq -0x50(%rbp), %rcx
movl (%rcx), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
shrq $0x21, %rax
movq %rax, -0x70(%rbp)
movq -0x48(%rbp), %rax
movq -0x50(%rbp), %rcx
movl (%rcx), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
shrq $0x20, %rax
andq $0x1, %rax
movq %rax, -0x68(%rbp)
movq -0x40(%rbp), %rax
movq 0x10(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x90(%rbp)
movq -0x40(%rbp), %rax
movq -0x70(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x98(%rbp)
movq 0x18(%rbp), %rax
movq 0x98(%rax), %rax
movq 0x18(%rbp), %rcx
movq 0x90(%rcx), %rcx
movq -0x90(%rbp), %rdx
movl 0x18(%rdx), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movl %edx, %edx
addq %rdx, %rcx
movq -0x98(%rbp), %rdx
movl 0x18(%rdx), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movl %edx, %edx
addq %rdx, %rcx
cmpq %rcx, %rax
jae 0x32c772
movq 0x18(%rbp), %rax
movq 0x90(%rax), %rcx
movq -0x90(%rbp), %rax
movl 0x18(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
addq %rax, %rcx
movq -0x98(%rbp), %rax
movl 0x18(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
addq %rax, %rcx
movq 0x18(%rbp), %rax
movq %rcx, 0x98(%rax)
movq 0x18(%rbp), %rax
movq 0x98(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x98(%rax)
movq 0x18(%rbp), %rax
movq 0x98(%rax), %rcx
shrq %rcx
movq 0x18(%rbp), %rax
orq 0x98(%rax), %rcx
movq %rcx, 0x98(%rax)
movq 0x18(%rbp), %rax
movq 0x98(%rax), %rcx
shrq $0x2, %rcx
movq 0x18(%rbp), %rax
orq 0x98(%rax), %rcx
movq %rcx, 0x98(%rax)
movq 0x18(%rbp), %rax
movq 0x98(%rax), %rcx
shrq $0x4, %rcx
movq 0x18(%rbp), %rax
orq 0x98(%rax), %rcx
movq %rcx, 0x98(%rax)
movq 0x18(%rbp), %rax
movq 0x98(%rax), %rcx
shrq $0x8, %rcx
movq 0x18(%rbp), %rax
orq 0x98(%rax), %rcx
movq %rcx, 0x98(%rax)
movq 0x18(%rbp), %rax
movq 0x98(%rax), %rcx
shrq $0x10, %rcx
movq 0x18(%rbp), %rax
orq 0x98(%rax), %rcx
movq %rcx, 0x98(%rax)
movq 0x18(%rbp), %rax
movq 0x98(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x98(%rax)
movq 0x18(%rbp), %rax
movq 0xa0(%rax), %rdi
movq 0x18(%rbp), %rax
movq 0x98(%rax), %rsi
shlq $0x3, %rsi
callq 0x2360
movq %rax, %rcx
movq 0x18(%rbp), %rax
movq %rcx, 0xa0(%rax)
jmp 0x32c774
movq 0x18(%rbp), %rax
movq 0xa0(%rax), %rax
movq 0x18(%rbp), %rcx
movq 0x90(%rcx), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0xb8(%rbp)
movq 0x18(%rbp), %rax
movq 0xa0(%rax), %rax
movq 0x18(%rbp), %rcx
movq 0x90(%rcx), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq -0x90(%rbp), %rcx
movl 0x18(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0xc0(%rbp)
movq -0xb8(%rbp), %rdi
movq -0x90(%rbp), %rax
movl 0x18(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %edx
shlq $0x3, %rdx
movl $0xff, %esi
callq 0x2100
movq -0xc0(%rbp), %rdi
movq -0x98(%rbp), %rax
movl 0x18(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %edx
shlq $0x3, %rdx
movl $0xff, %esi
callq 0x2100
movq -0x48(%rbp), %rax
movq -0x50(%rbp), %rcx
movl (%rcx), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
movq 0x10(%rax), %rax
movl %eax, %eax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x68(%rbp)
jne 0x32c867
movq -0xa8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x10c(%rbp)
jmp 0x32c888
movq -0x98(%rbp), %rax
movl 0x18(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq -0xa8(%rbp), %rcx
subl (%rcx), %eax
subl $0x1, %eax
movl %eax, -0x10c(%rbp)
movl -0x10c(%rbp), %eax
movl %eax, %eax
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x58(%rbp)
jle 0x32c96c
movq -0xa8(%rbp), %rax
cmpl $0x0, (%rax)
jbe 0x32c96c
movq -0x38(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq 0x10(%rbp), %rdx
movq -0x90(%rbp), %rcx
movq -0x70(%rbp), %r8
movq -0x98(%rbp), %r9
movq -0x68(%rbp), %r15
movq -0xb8(%rbp), %r14
movq -0xc0(%rbp), %rbx
movq -0xa8(%rbp), %r11
leaq -0x78(%rbp), %r10
leaq -0x80(%rbp), %rax
movq %r15, (%rsp)
movq %r14, 0x8(%rsp)
movq %rbx, 0x10(%rsp)
movq %r11, 0x18(%rsp)
movq $0x1, 0x20(%rsp)
movq %r10, 0x28(%rsp)
movq %rax, 0x30(%rsp)
callq 0x32bcb0
movq -0x78(%rbp), %rax
movl %eax, %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x18(%rax)
cmpq $0x0, -0x68(%rbp)
jne 0x32c93a
movq -0x80(%rbp), %rax
movq %rax, -0x118(%rbp)
jmp 0x32c95a
movq -0x98(%rbp), %rax
movl 0x18(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
subq -0x80(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x118(%rbp)
movq -0x118(%rbp), %rax
movl %eax, %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x20(%rax)
jmp 0x32c990
movq -0xa8(%rbp), %rax
movq 0x10(%rax), %rax
movl %eax, %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0xa8(%rbp), %rax
movl (%rax), %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x50(%rbp), %rax
movl 0x18(%rax), %eax
movq -0xa8(%rbp), %rcx
movq 0x10(%rcx), %rcx
cmpl %ecx, %eax
ja 0x32c9a8
jmp 0x32c9c7
leaq 0x6ab3a(%rip), %rdi     # 0x3974e9
leaq 0x69803(%rip), %rsi     # 0x3961b9
movl $0x13eb, %edx           # imm = 0x13EB
leaq 0x6ab53(%rip), %rcx     # 0x397515
callq 0x2130
movq -0x50(%rbp), %rax
movl 0x20(%rax), %eax
movq -0xa8(%rbp), %rcx
cmpl (%rcx), %eax
ja 0x32c9db
jmp 0x32c9fa
leaq 0x6abcd(%rip), %rdi     # 0x3975af
leaq 0x697d0(%rip), %rsi     # 0x3961b9
movl $0x13eb, %edx           # imm = 0x13EB
leaq 0x6ab20(%rip), %rcx     # 0x397515
callq 0x2130
movq -0x48(%rbp), %rax
movq -0x50(%rbp), %rcx
movl 0x4(%rcx), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
movq 0x10(%rax), %rax
movl %eax, %eax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x68(%rbp)
jne 0x32ca41
movq -0xa8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x11c(%rbp)
jmp 0x32ca62
movq -0x98(%rbp), %rax
movl 0x18(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq -0xa8(%rbp), %rcx
subl (%rcx), %eax
subl $0x1, %eax
movl %eax, -0x11c(%rbp)
movl -0x11c(%rbp), %eax
movl %eax, %eax
movq %rax, -0x60(%rbp)
movq -0x58(%rbp), %rax
addl $0x1, %eax
movq -0x90(%rbp), %rcx
movl 0x18(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpl %ecx, %eax
jae 0x32cb74
movq -0xa8(%rbp), %rax
movl (%rax), %eax
addl $0x1, %eax
movq -0x98(%rbp), %rcx
movl 0x18(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpl %ecx, %eax
jae 0x32cb74
movq -0x38(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq 0x10(%rbp), %rdx
movq -0x90(%rbp), %rcx
movq -0x70(%rbp), %r8
movq -0x98(%rbp), %r9
movq -0x68(%rbp), %r15
movq -0xb8(%rbp), %r14
movq -0xc0(%rbp), %rbx
movq -0xa8(%rbp), %r11
xorl %eax, %eax
leaq -0x78(%rbp), %r10
leaq -0x80(%rbp), %rax
movq %r15, (%rsp)
movq %r14, 0x8(%rsp)
movq %rbx, 0x10(%rsp)
movq %r11, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
movq %r10, 0x28(%rsp)
movq %rax, 0x30(%rsp)
callq 0x32bcb0
movq -0x78(%rbp), %rax
addq $0x1, %rax
movl %eax, %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x1c(%rax)
cmpq $0x0, -0x68(%rbp)
jne 0x32cb46
movq -0x80(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x128(%rbp)
jmp 0x32cb62
movq -0x98(%rbp), %rax
movl 0x18(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
subq -0x80(%rbp), %rax
movq %rax, -0x128(%rbp)
movq -0x128(%rbp), %rax
movl %eax, %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x24(%rax)
jmp 0x32cb9e
movq -0xa8(%rbp), %rax
movq 0x10(%rax), %rax
movl %eax, %ecx
addl $0x1, %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x1c(%rax)
movq -0xa8(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x24(%rax)
movq -0x50(%rbp), %rax
movl 0x1c(%rax), %eax
movq -0xa8(%rbp), %rcx
movq 0x10(%rcx), %rcx
cmpl %ecx, %eax
jbe 0x32cbb6
jmp 0x32cbd5
leaq 0x6aa07(%rip), %rdi     # 0x3975c4
leaq 0x695f5(%rip), %rsi     # 0x3961b9
movl $0x13fd, %edx           # imm = 0x13FD
leaq 0x6a945(%rip), %rcx     # 0x397515
callq 0x2130
movq -0x50(%rbp), %rax
movl 0x24(%rax), %eax
movq -0xa8(%rbp), %rcx
cmpl (%rcx), %eax
jbe 0x32cbe9
jmp 0x32cc08
leaq 0x6a9fd(%rip), %rdi     # 0x3975ed
leaq 0x695c2(%rip), %rsi     # 0x3961b9
movl $0x13fd, %edx           # imm = 0x13FD
leaq 0x6a912(%rip), %rcx     # 0x397515
callq 0x2130
movq -0x50(%rbp), %rax
movl 0x1c(%rax), %eax
movq -0x50(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jbe 0x32cc1a
jmp 0x32cc39
leaq 0x6a9e0(%rip), %rdi     # 0x397601
leaq 0x69591(%rip), %rsi     # 0x3961b9
movl $0x1400, %edx           # imm = 0x1400
leaq 0x6a8e1(%rip), %rcx     # 0x397515
callq 0x2130
movq -0x50(%rbp), %rax
movl 0x24(%rax), %eax
movq -0x50(%rbp), %rcx
cmpl 0x20(%rcx), %eax
jbe 0x32cc4b
jmp 0x32cc6a
leaq 0x6a9c9(%rip), %rdi     # 0x39761b
leaq 0x69560(%rip), %rsi     # 0x3961b9
movl $0x1400, %edx           # imm = 0x1400
leaq 0x6a8b0(%rip), %rcx     # 0x397515
callq 0x2130
movq -0x50(%rbp), %rax
movl (%rax), %eax
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rax
movq -0x50(%rbp), %rcx
movl 0x4(%rcx), %ecx
cmpq %rcx, %rax
jae 0x32d176
movq -0x48(%rbp), %rax
imulq $0x18, -0xc8(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0xa8(%rbp)
movq -0xc8(%rbp), %rax
movq -0x50(%rbp), %rcx
movl (%rcx), %ecx
cmpq %rcx, %rax
jbe 0x32ccd5
movq -0x48(%rbp), %rax
movq -0xc8(%rbp), %rcx
subq $0x1, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x130(%rbp)
jmp 0x32cce0
xorl %eax, %eax
movq %rax, -0x130(%rbp)
jmp 0x32cce0
movq -0x130(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0xa8(%rbp), %rax
movq 0x10(%rax), %rax
movl %eax, %eax
movq %rax, -0x58(%rbp)
movq 0x18(%rbp), %rax
movq 0xa0(%rax), %rax
movq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movq -0xb8(%rbp), %rax
movq -0x58(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
cmpq $0x0, -0x68(%rbp)
jne 0x32cd39
movq -0xa8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x134(%rbp)
jmp 0x32cd5a
movq -0x98(%rbp), %rax
movl 0x18(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq -0xa8(%rbp), %rcx
subl (%rcx), %eax
subl $0x1, %eax
movl %eax, -0x134(%rbp)
movl -0x134(%rbp), %eax
movl %eax, %eax
movq %rax, -0x60(%rbp)
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
imulq $0x58, -0x70(%rbp), %rcx
addq %rcx, %rax
movq 0x30(%rax), %rax
movq -0x98(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x60(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movl (%rax), %eax
shll %eax
movq -0xa0(%rbp), %rcx
movb 0x20(%rcx), %cl
shrb $0x5, %cl
andb $0x1, %cl
movzbl %cl, %ecx
addl %ecx, %eax
movq -0x98(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x60(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
cmpl %ecx, %eax
jne 0x32cdd8
jmp 0x32cdf7
leaq 0x6a856(%rip), %rdi     # 0x397635
leaq 0x693d3(%rip), %rsi     # 0x3961b9
movl $0x1414, %edx           # imm = 0x1414
leaq 0x6a723(%rip), %rcx     # 0x397515
callq 0x2130
movq -0xa0(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, %edi
movq -0xa0(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, %esi
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdx
movq -0xa0(%rbp), %rax
movl (%rax), %eax
imulq $0x28, %rax, %rax
addq %rax, %rdx
callq 0x327090
movq %rax, %rdx
movq -0xc0(%rbp), %rax
movq -0x60(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0xb8(%rbp), %rax
movq -0x58(%rbp), %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
addq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movq -0xc0(%rbp), %rax
movq -0x60(%rbp), %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
addq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
cmpq $0x0, -0xb0(%rbp)
jne 0x32ce87
jmp 0x32d15f
movq $0x0, -0xe0(%rbp)
movq -0x38(%rbp), %rdi
movq -0xb0(%rbp), %rsi
movq -0xa8(%rbp), %rdx
movq -0x68(%rbp), %rcx
movq -0x90(%rbp), %r8
movq -0x98(%rbp), %r9
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
imulq $0x58, 0x10(%rbp), %r10
addq %r10, %rax
movq 0x30(%rax), %rbx
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
imulq $0x58, -0x70(%rbp), %r10
addq %r10, %rax
movq 0x30(%rax), %r11
movq 0x10(%rbp), %r10
movq -0x70(%rbp), %rax
movsd 0x553a2(%rip), %xmm0    # 0x382290
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movq %rax, 0x18(%rsp)
movq $0x7d0, 0x20(%rsp)      # imm = 0x7D0
callq 0x32c030
cmpq $0x0, %rax
je 0x32cf26
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
movq %rax, -0xe0(%rbp)
movq -0xb0(%rbp), %rax
movq 0x10(%rax), %rax
addl $0x1, %eax
movl %eax, %eax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
cmpq -0x58(%rbp), %rax
jge 0x32cf8d
movq 0x18(%rbp), %rax
movq 0xa0(%rax), %rax
movq -0x88(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
addq -0xe0(%rbp), %rdx
movq -0xb8(%rbp), %rax
movq -0x88(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x88(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x88(%rbp)
jmp 0x32cf3d
cmpq $0x0, -0x68(%rbp)
jne 0x32cfa5
movq -0xb0(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x138(%rbp)
jmp 0x32cfc6
movq -0x98(%rbp), %rax
movl 0x18(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq -0xa8(%rbp), %rcx
subl (%rcx), %eax
subl $0x1, %eax
movl %eax, -0x138(%rbp)
movl -0x138(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
movq %rax, -0x88(%rbp)
cmpq $0x0, -0x68(%rbp)
jne 0x32cff0
movq -0xa8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x13c(%rbp)
jmp 0x32d011
movq -0x98(%rbp), %rax
movl 0x18(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq -0xb0(%rbp), %rcx
subl (%rcx), %eax
subl $0x1, %eax
movl %eax, -0x13c(%rbp)
movl -0x13c(%rbp), %eax
movl %eax, %eax
movq %rax, -0x60(%rbp)
movq -0x88(%rbp), %rax
cmpq -0x60(%rbp), %rax
jg 0x32d02c
jmp 0x32d04b
leaq 0x6a635(%rip), %rdi     # 0x397668
leaq 0x6917f(%rip), %rsi     # 0x3961b9
movl $0x1425, %edx           # imm = 0x1425
leaq 0x6a4cf(%rip), %rcx     # 0x397515
callq 0x2130
jmp 0x32d04d
movq -0x88(%rbp), %rax
cmpq -0x60(%rbp), %rax
jge 0x32d15d
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
imulq $0x58, -0x70(%rbp), %rcx
addq %rcx, %rax
movq 0x30(%rax), %rax
movq -0x98(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x88(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movl (%rax), %eax
shll %eax
movq -0xa0(%rbp), %rcx
movb 0x20(%rcx), %cl
shrb $0x5, %cl
andb $0x1, %cl
movzbl %cl, %ecx
addl %ecx, %eax
movq -0x98(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x88(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
cmpl %ecx, %eax
jne 0x32d0d6
jmp 0x32d0f5
leaq 0x6a593(%rip), %rdi     # 0x397670
leaq 0x690d5(%rip), %rsi     # 0x3961b9
movl $0x1428, %edx           # imm = 0x1428
leaq 0x6a425(%rip), %rcx     # 0x397515
callq 0x2130
movq -0xa0(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, %edi
movq -0xa0(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, %esi
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdx
movq -0xa0(%rbp), %rax
movl (%rax), %eax
imulq $0x28, %rax, %rax
addq %rax, %rdx
callq 0x327090
movq %rax, %rdx
addq -0xe0(%rbp), %rdx
movq -0xc0(%rbp), %rax
movq -0x88(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x88(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x88(%rbp)
jmp 0x32d04d
jmp 0x32d15f
movq -0xc8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xc8(%rbp)
jmp 0x32cc77
cmpq $0x0, 0x20(%rbp)
je 0x32d635
movq $0x0, -0xe8(%rbp)
movq $0x0, -0xf0(%rbp)
movq $0x0, -0xf8(%rbp)
movq $0x0, -0x100(%rbp)
movq -0x50(%rbp), %rax
movl 0x1c(%rax), %eax
movq %rax, -0xd0(%rbp)
movq -0x50(%rbp), %rax
movl 0x18(%rax), %eax
movq %rax, -0xc8(%rbp)
movq $0x0, -0xd8(%rbp)
movq -0xc8(%rbp), %rax
cmpq -0xd0(%rbp), %rax
jae 0x32d3bc
movq -0xb8(%rbp), %rcx
movq -0xc8(%rbp), %rdx
xorl %eax, %eax
cmpq $-0x1, (%rcx,%rdx,8)
movb %al, -0x13d(%rbp)
je 0x32d221
movq -0xb8(%rbp), %rax
movq -0xc8(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
seta %al
movb %al, -0x13d(%rbp)
movb -0x13d(%rbp), %al
testb $0x1, %al
jne 0x32d22d
jmp 0x32d22f
jmp 0x32d24e
leaq 0x6a46c(%rip), %rdi     # 0x3976a2
leaq 0x68f7c(%rip), %rsi     # 0x3961b9
movl $0x1431, %edx           # imm = 0x1431
leaq 0x6a2cc(%rip), %rcx     # 0x397515
callq 0x2130
movq -0xb8(%rbp), %rax
movq -0xc8(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shlq %rax
shrq %rax
movq %rax, -0x108(%rbp)
movq -0xd8(%rbp), %rax
cmpq 0x28(%rbp), %rax
jae 0x32d3a3
movq 0x20(%rbp), %rax
movq -0xd8(%rbp), %rcx
movq (%rax,%rcx,8), %rax
cmpq -0xc8(%rbp), %rax
jne 0x32d36e
movq -0x108(%rbp), %rax
addq -0xe8(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0xb8(%rbp), %rcx
movq -0xc8(%rbp), %rdx
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
andq (%rcx,%rdx,8), %rax
cmpq $0x0, %rax
je 0x32d2e6
movq -0x108(%rbp), %rax
addq -0xf8(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq -0x90(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0xc8(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movq -0x30(%rbp), %rcx
movq 0x80(%rcx), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
ja 0x32d36c
movq -0x108(%rbp), %rax
addq -0xf0(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0xb8(%rbp), %rcx
movq -0xc8(%rbp), %rdx
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
andq (%rcx,%rdx,8), %rax
cmpq $0x0, %rax
je 0x32d36a
movq -0x108(%rbp), %rax
addq -0x100(%rbp), %rax
movq %rax, -0x100(%rbp)
jmp 0x32d36c
jmp 0x32d38a
movq 0x20(%rbp), %rax
movq -0xd8(%rbp), %rcx
movq (%rax,%rcx,8), %rax
cmpq -0xc8(%rbp), %rax
jbe 0x32d388
jmp 0x32d3a3
jmp 0x32d38a
jmp 0x32d38c
movq -0xd8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xd8(%rbp)
jmp 0x32d26d
jmp 0x32d3a5
movq -0xc8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xc8(%rbp)
jmp 0x32d1d4
cmpq $0x0, -0xe8(%rbp)
jg 0x32d3d3
movq $0x0, -0x20(%rbp)
jmp 0x32d66d
cmpq $0x0, -0xf0(%rbp)
jle 0x32d40e
cvtsi2sdq -0x100(%rbp), %xmm1
cvtsi2sdq -0xf0(%rbp), %xmm0
movsd 0x54e79(%rip), %xmm2    # 0x382270
mulsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jb 0x32d40e
movq $0x0, -0x20(%rbp)
jmp 0x32d66d
cvtsi2sdq -0xf8(%rbp), %xmm1
cvtsi2sdq -0xe8(%rbp), %xmm0
movsd 0x54e48(%rip), %xmm2    # 0x382270
mulsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jb 0x32d43f
movq $0x0, -0x20(%rbp)
jmp 0x32d66d
movq -0x50(%rbp), %rax
movl 0x20(%rax), %eax
movq %rax, -0xc8(%rbp)
movq -0x50(%rbp), %rax
movl 0x24(%rax), %eax
movq %rax, -0xd0(%rbp)
cmpq $0x0, -0x68(%rbp)
je 0x32d4a0
movq -0x98(%rbp), %rax
movl 0x18(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq -0x50(%rbp), %rcx
subl 0x24(%rcx), %eax
movl %eax, %eax
movq %rax, -0xc8(%rbp)
movq -0x98(%rbp), %rax
movl 0x18(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq -0x50(%rbp), %rcx
subl 0x20(%rcx), %eax
movl %eax, %eax
movq %rax, -0xd0(%rbp)
movq $0x0, -0xf8(%rbp)
movq $0x0, -0xe8(%rbp)
movq -0xc8(%rbp), %rax
cmpq -0xd0(%rbp), %rax
jae 0x32d4c8
jmp 0x32d4e7
leaq 0x6a206(%rip), %rdi     # 0x3976d5
leaq 0x68ce3(%rip), %rsi     # 0x3961b9
movl $0x144a, %edx           # imm = 0x144A
leaq 0x6a033(%rip), %rcx     # 0x397515
callq 0x2130
jmp 0x32d4e9
movq -0xc8(%rbp), %rax
cmpq -0xd0(%rbp), %rax
jae 0x32d5e7
movq -0xc0(%rbp), %rcx
movq -0xc8(%rbp), %rdx
xorl %eax, %eax
cmpq $-0x1, (%rcx,%rdx,8)
movb %al, -0x13e(%rbp)
je 0x32d536
movq -0xc0(%rbp), %rax
movq -0xc8(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
seta %al
movb %al, -0x13e(%rbp)
movb -0x13e(%rbp), %al
testb $0x1, %al
jne 0x32d542
jmp 0x32d544
jmp 0x32d563
leaq 0x6a195(%rip), %rdi     # 0x3976e0
leaq 0x68c67(%rip), %rsi     # 0x3961b9
movl $0x144c, %edx           # imm = 0x144C
leaq 0x69fb7(%rip), %rcx     # 0x397515
callq 0x2130
movq -0xc0(%rbp), %rax
movq -0xc8(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shlq %rax
shrq %rax
movq %rax, -0x108(%rbp)
movq -0x108(%rbp), %rax
addq -0xe8(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0xc0(%rbp), %rcx
movq -0xc8(%rbp), %rdx
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
andq (%rcx,%rdx,8), %rax
cmpq $0x0, %rax
je 0x32d5ce
movq -0x108(%rbp), %rax
addq -0xf8(%rbp), %rax
movq %rax, -0xf8(%rbp)
jmp 0x32d5d0
movq -0xc8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xc8(%rbp)
jmp 0x32d4e9
cmpq $0x0, -0xe8(%rbp)
jle 0x32d5fb
cmpq $0x0, -0xf8(%rbp)
jg 0x32d605
movq $0x0, -0x20(%rbp)
jmp 0x32d66d
cvtsi2sdq -0xf8(%rbp), %xmm1
cvtsi2sdq -0xe8(%rbp), %xmm0
movsd 0x54c51(%rip), %xmm2    # 0x382270
mulsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jb 0x32d633
movq $0x0, -0x20(%rbp)
jmp 0x32d66d
jmp 0x32d635
movq -0x50(%rbp), %rax
movl 0x18(%rax), %eax
addl $0x1, %eax
movq -0x50(%rbp), %rcx
cmpl 0x1c(%rcx), %eax
jne 0x32d665
movq -0x50(%rbp), %rax
movl 0x20(%rax), %eax
addl $0x1, %eax
movq -0x50(%rbp), %rcx
cmpl 0x24(%rcx), %eax
jne 0x32d665
movq $0x0, -0x20(%rbp)
jmp 0x32d66d
movq $0x1, -0x20(%rbp)
movq -0x20(%rbp), %rax
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop