// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdx, 0x30(%rsp)
movq %rsi, 0x68(%rsp)
movq %rdi, 0x40(%rsp)
movl (%r9), %eax
cmpl %eax, 0x4(%r9)
jbe 0x1f5f90
movq %r9, %r15
movq %r8, %rbp
movq 0xb8(%rsp), %r13
movq 0xb0(%rsp), %rdx
leaq (%rax,%rax,2), %rax
movq 0x10(%r8,%rax,8), %rax
movq %rax, %rsi
shrq $0x21, %rsi
shrq $0x20, %rax
andl $0x1, %eax
movq %rax, 0x18(%rsp)
movq %rdx, %rax
shlq $0x5, %rax
leaq (%rcx,%rax), %rdx
movq %rdx, 0x20(%rsp)
movq %rsi, 0x10(%rsp)
movq %rsi, %rdx
shlq $0x5, %rdx
leaq (%rcx,%rdx), %rsi
movq %rsi, (%rsp)
movl 0x18(%rcx,%rax), %esi
movl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
andq %r14, %rsi
addq 0x90(%r13), %rsi
movl 0x18(%rcx,%rdx), %eax
andq %r14, %rax
addq %rsi, %rax
cmpq %rax, 0x98(%r13)
jae 0x1f58ea
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, 0x98(%r13)
movq 0xa0(%r13), %rdi
leaq 0x8(,%rcx,8), %rsi
callq 0x2370
movq %rax, 0xa0(%r13)
movq 0x90(%r13), %rdi
shlq $0x3, %rdi
addq 0xa0(%r13), %rdi
movq 0x20(%rsp), %rax
movl 0x18(%rax), %edx
andq %r14, %rdx
leaq (%rdi,%rdx,8), %rbx
shlq $0x3, %rdx
movq %rdi, 0x8(%rsp)
movl $0xff, %esi
callq 0x20e0
movq (%rsp), %rax
movl 0x18(%rax), %edx
andq %r14, %rdx
shlq $0x3, %rdx
movq %rbx, 0x28(%rsp)
movq %rbx, %rdi
movl $0xff, %esi
callq 0x20e0
movl (%r15), %eax
leaq (%rax,%rax,2), %rax
leaq (,%rax,8), %r14
addq %rbp, %r14
movl 0x10(%r14), %eax
testq %rax, %rax
je 0x1f59c1
cmpl $0x0, (%r14)
je 0x1f59c1
subq $0x8, %rsp
leaq 0x40(%rsp), %rax
leaq 0x78(%rsp), %rbx
movq 0x38(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq 0xb8(%rsp), %rdx
movq 0x28(%rsp), %rcx
movq 0x18(%rsp), %r8
movq 0x8(%rsp), %r13
movq %r13, %r9
pushq %rax
pushq %rbx
pushq $0x1
pushq %r14
pushq 0x50(%rsp)
pushq 0x38(%rsp)
movq 0x50(%rsp), %r12
pushq %r12
callq 0x1f53fb
addq $0x40, %rsp
movl (%rbx), %eax
movl %eax, 0x18(%r15)
testq %r12, %r12
jne 0x1f59ca
movq 0x38(%rsp), %rax
jmp 0x1f59df
movl %eax, 0x18(%r15)
movl (%r14), %eax
jmp 0x1f59e7
movl 0x18(%r13), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movq 0x38(%rsp), %rax
notq %rax
addq %rcx, %rax
movq 0xb8(%rsp), %r13
movl %eax, 0x20(%r15)
movl 0x18(%r15), %eax
cmpl 0x10(%r14), %eax
ja 0x1f6043
movl 0x20(%r15), %eax
cmpl (%r14), %eax
ja 0x1f604c
movl 0x4(%r15), %eax
decl %eax
leaq (%rax,%rax,2), %rax
leaq (,%rax,8), %r14
addq %rbp, %r14
movl 0x10(%r14), %eax
incl %eax
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movq 0x20(%rsp), %rdx
movl 0x18(%rdx), %edx
andl %ecx, %edx
cmpl %edx, %eax
jae 0x1f5aab
movl (%r14), %edx
incl %edx
movq (%rsp), %rsi
andl 0x18(%rsi), %ecx
cmpl %ecx, %edx
jae 0x1f5aab
subq $0x8, %rsp
leaq 0x40(%rsp), %rax
leaq 0x78(%rsp), %rbx
movq 0x38(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq 0xb8(%rsp), %rdx
movq 0x28(%rsp), %rcx
movq 0x18(%rsp), %r8
movq 0x8(%rsp), %r13
movq %r13, %r9
pushq %rax
pushq %rbx
pushq $0x0
pushq %r14
pushq 0x50(%rsp)
pushq 0x38(%rsp)
movq 0x50(%rsp), %r12
pushq %r12
callq 0x1f53fb
addq $0x40, %rsp
movl (%rbx), %eax
incl %eax
movl %eax, 0x1c(%r15)
testq %r12, %r12
jne 0x1f5ab6
movq 0x38(%rsp), %rax
incq %rax
jmp 0x1f5ac4
movl %eax, 0x1c(%r15)
movl (%r14), %eax
incl %eax
jmp 0x1f5acc
movl 0x18(%r13), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
subq 0x38(%rsp), %rax
movq 0xb8(%rsp), %r13
movl %eax, 0x24(%r15)
movl 0x1c(%r15), %eax
cmpl 0x10(%r14), %eax
jbe 0x1f606b
movl 0x24(%r15), %ecx
cmpl (%r14), %ecx
jbe 0x1f6074
cmpl 0x18(%r15), %eax
jbe 0x1f6093
cmpl 0x20(%r15), %ecx
jbe 0x1f609c
movl (%r15), %r12d
cmpl 0x4(%r15), %r12d
movq %r15, 0x48(%rsp)
jae 0x1f5da5
imulq $0x58, 0x10(%rsp), %rax
movq %rax, 0x50(%rsp)
imulq $0x58, 0xb0(%rsp), %rax
movq %rax, 0x58(%rsp)
movq %rbp, 0x60(%rsp)
leaq (%r12,%r12,2), %rax
leaq (,%rax,8), %rsi
addq %rbp, %rsi
movl (%r15), %ecx
cmpq %rcx, %r12
leaq -0x18(%rbp,%rax,8), %rax
movl $0x0, %ebp
cmovaq %rax, %rbp
movl 0x28(%rax), %r14d
movq 0xa0(%r13), %rax
movq (%rax,%r14,8), %rax
movq 0x8(%rsp), %rcx
movq %rax, (%rcx,%r14,8)
cmpq $0x0, 0x18(%rsp)
movq %rsi, 0x10(%rsp)
jne 0x1f5b7f
movl (%rsi), %eax
movq (%rsp), %rdx
jmp 0x1f5b93
movq (%rsp), %rdx
movl 0x18(%rdx), %ecx
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andl %eax, %ecx
movl (%rsi), %eax
notl %eax
addl %ecx, %eax
movl %eax, %r13d
movq 0x40(%rsp), %rax
movq 0x48(%rax), %r15
movq 0x50(%rsp), %rax
movq 0x30(%r15,%rax), %rbx
movq 0x10(%rdx), %rax
movq (%rax,%r13,8), %rdx
movq %rdx, %rax
shrq $0x20, %rax
leaq (%rax,%rax,8), %rcx
movl (%rbx,%rcx,4), %eax
movl 0x20(%rbx,%rcx,4), %esi
shrl $0x5, %esi
andl $0x1, %esi
leal (%rsi,%rax,2), %esi
cmpl %edx, %esi
jne 0x1f5fe6
leaq (%rbx,%rcx,4), %rcx
movl 0xc(%rcx), %edi
movl 0x10(%rcx), %esi
leaq (%rax,%rax,4), %rdx
shlq $0x3, %rdx
movq 0x30(%rsp), %rax
addq 0x10(%rax), %rdx
callq 0x1f2d50
movq 0x28(%rsp), %rcx
movq %rax, (%rcx,%r13,8)
movq 0x8(%rsp), %rax
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, (%rax,%r14,8)
xorq %rdx, (%rcx,%r13,8)
testq %rbp, %rbp
je 0x1f5d83
movq 0x58(%rsp), %rax
movq 0x30(%r15,%rax), %rax
subq $0x30, %rsp
movq %rbx, 0x8(%rsp)
movq %rax, (%rsp)
movq $0x7d0, 0x20(%rsp)      # imm = 0x7D0
movq 0x60(%rsp), %rdi
movq %rbp, %rsi
movq 0x40(%rsp), %rdx
movq 0x48(%rsp), %rcx
movq 0x50(%rsp), %r8
movq 0x30(%rsp), %rbx
movq %rbx, %r9
movsd 0x2f8a4(%rip), %xmm0    # 0x225508
callq 0x1f5553
addq $0x30, %rsp
movq %rax, %r13
testq %rax, %rax
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
cmovneq %rax, %r13
movl 0x10(%rbp), %eax
incl %eax
cmpq %r14, %rax
movq 0x8(%rsp), %rsi
jae 0x1f5cb2
movq 0xb8(%rsp), %rcx
movq 0xa0(%rcx), %rcx
movq (%rcx,%rax,8), %rdx
addq %r13, %rdx
movq %rdx, (%rsi,%rax,8)
incq %rax
cmpq %rax, %r14
jne 0x1f5c9f
cmpq $0x0, 0x18(%rsp)
jne 0x1f5cc5
movl (%rbp), %r14d
movq 0x10(%rsp), %rcx
jmp 0x1f5cdd
movl 0x18(%rbx), %eax
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andl %ecx, %eax
movq 0x10(%rsp), %rcx
movl (%rcx), %r14d
notl %r14d
addl %eax, %r14d
cmpq $0x0, 0x18(%rsp)
jne 0x1f5ce9
movl (%rcx), %eax
jmp 0x1f5cfa
movl 0x18(%rbx), %ecx
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andl %eax, %ecx
movl (%rbp), %eax
notl %eax
addl %ecx, %eax
incl %r14d
cmpl %eax, %r14d
ja 0x1f6005
movl %eax, %ebp
cmpl %ebp, %r14d
jae 0x1f5d83
movq 0x40(%rsp), %rax
movq 0x48(%rax), %rax
movq 0x50(%rsp), %rcx
movq 0x30(%rax,%rcx), %rbx
movq (%rsp), %rax
movq 0x10(%rax), %r15
movq (%r15,%r14,8), %rdx
movq %rdx, %rax
shrq $0x20, %rax
leaq (%rax,%rax,8), %rcx
movl (%rbx,%rcx,4), %eax
movl 0x20(%rbx,%rcx,4), %esi
shrl $0x5, %esi
andl $0x1, %esi
leal (%rsi,%rax,2), %esi
cmpl %edx, %esi
jne 0x1f5fa8
leaq (%rbx,%rcx,4), %rcx
movl 0xc(%rcx), %edi
movl 0x10(%rcx), %esi
leaq (%rax,%rax,4), %rdx
shlq $0x3, %rdx
movq 0x30(%rsp), %rax
addq 0x10(%rax), %rdx
callq 0x1f2d50
addq %r13, %rax
movq 0x28(%rsp), %rcx
movq %rax, (%rcx,%r14,8)
incq %r14
cmpq %r14, %rbp
jne 0x1f5d28
incq %r12
movq 0x48(%rsp), %r15
movl 0x4(%r15), %eax
cmpq %rax, %r12
movq 0x60(%rsp), %rbp
movq 0xb8(%rsp), %r13
jb 0x1f5b2f
movq 0xc0(%rsp), %rdx
testq %rdx, %rdx
je 0x1f5f78
movl 0x18(%r15), %esi
movl 0x1c(%r15), %edi
cmpl %edi, %esi
jae 0x1f5e88
movq 0xc8(%rsp), %r8
movabsq $-0x8000000000000000, %r10 # imm = 0x8000000000000000
xorl %r9d, %r9d
decq %r10
xorl %r11d, %r11d
xorl %ecx, %ecx
xorl %eax, %eax
xorl %r14d, %r14d
movq 0x8(%rsp), %rbx
movq (%rbx,%rsi,8), %rbx
leaq 0x1(%rbx), %r15
cmpq $0x1, %r15
jbe 0x1f5fc7
cmpq %r8, %r14
jae 0x1f5e63
movq %rbx, %r15
andq %r10, %r15
testq %rbx, %rbx
movl $0x0, %r12d
cmovsq %r15, %r12
cmpq %rsi, (%rdx,%r14,8)
jne 0x1f5e56
addq %r15, %rax
addq %r12, %r11
movq 0x20(%rsp), %rbx
movq 0x10(%rbx), %rbx
movl (%rbx,%rsi,8), %ebx
shrl %ebx
movq 0x68(%rsp), %rbp
movq (%rbp), %r13
movq 0x80(%rbp), %rbp
movl (%r13,%rbx,4), %ebx
incq %rbp
cmpq %rbx, %rbp
jb 0x1f5e58
addq %r15, %rcx
addq %r12, %r9
jmp 0x1f5e58
ja 0x1f5e63
incq %r14
cmpq %r14, %r8
jne 0x1f5e17
movq %r8, %r14
movq 0x8(%rsp), %rbx
incq %rsi
cmpq %rdi, %rsi
jne 0x1f5ded
cvtsi2sd %r9, %xmm1
xorps %xmm0, %xmm0
cvtsi2sd %r11, %xmm0
movq 0x48(%rsp), %r15
jmp 0x1f5e94
xorpd %xmm0, %xmm0
xorl %eax, %eax
xorl %ecx, %ecx
xorpd %xmm1, %xmm1
testq %rax, %rax
jle 0x1f5f90
testq %rcx, %rcx
jle 0x1f5eb9
cvtsi2sd %rcx, %xmm2
mulsd 0x2f641(%rip), %xmm2    # 0x2254f0
ucomisd %xmm1, %xmm2
jae 0x1f5f90
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
mulsd 0x2f627(%rip), %xmm1    # 0x2254f0
ucomisd %xmm0, %xmm1
jae 0x1f5f90
movl 0x20(%r15), %eax
movl 0x24(%r15), %ecx
cmpq $0x0, 0x18(%rsp)
je 0x1f5ef9
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movq (%rsp), %rsi
andl 0x18(%rsi), %edx
movl %edx, %esi
subl %ecx, %esi
subl %eax, %edx
movl %esi, %eax
movl %edx, %ecx
cmpl %ecx, %eax
jae 0x1f60bb
movl %ecx, %edx
movabsq $-0x8000000000000000, %rsi # imm = 0x8000000000000000
movl %eax, %edi
xorl %eax, %eax
decq %rsi
xorl %ecx, %ecx
movq 0x28(%rsp), %r8
movq (%r8,%rdi,8), %r8
leaq 0x1(%r8), %r9
cmpq $0x1, %r9
jbe 0x1f6024
movq %r8, %r9
andq %rsi, %r9
addq %r9, %rcx
sarq $0x3f, %r8
andq %r9, %r8
addq %r8, %rax
incq %rdi
cmpq %rdi, %rdx
jne 0x1f5f16
testq %rcx, %rcx
sete %dl
testq %rax, %rax
sete %sil
orb %dl, %sil
jne 0x1f5f90
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %rcx, %xmm1
mulsd 0x2f57e(%rip), %xmm1    # 0x2254f0
ucomisd %xmm0, %xmm1
jae 0x1f5f90
movl 0x18(%r15), %eax
incl %eax
cmpl 0x1c(%r15), %eax
jne 0x1f5fa1
movl 0x20(%r15), %eax
incl %eax
cmpl 0x24(%r15), %eax
jne 0x1f5fa1
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %eax
jmp 0x1f5f92
leaq 0x447a1(%rip), %rdi     # 0x23a750
leaq 0x4336f(%rip), %rsi     # 0x239325
leaq 0x44638(%rip), %rcx     # 0x23a5f5
movl $0x1428, %edx           # imm = 0x1428
callq 0x2110
leaq 0x447b4(%rip), %rdi     # 0x23a782
leaq 0x43350(%rip), %rsi     # 0x239325
leaq 0x44619(%rip), %rcx     # 0x23a5f5
movl $0x1431, %edx           # imm = 0x1431
callq 0x2110
leaq 0x44728(%rip), %rdi     # 0x23a715
leaq 0x43331(%rip), %rsi     # 0x239325
leaq 0x445fa(%rip), %rcx     # 0x23a5f5
movl $0x1414, %edx           # imm = 0x1414
callq 0x2110
leaq 0x4473c(%rip), %rdi     # 0x23a748
leaq 0x43312(%rip), %rsi     # 0x239325
leaq 0x445db(%rip), %rcx     # 0x23a5f5
movl $0x1425, %edx           # imm = 0x1425
callq 0x2110
leaq 0x44795(%rip), %rdi     # 0x23a7c0
leaq 0x432f3(%rip), %rsi     # 0x239325
leaq 0x445bc(%rip), %rcx     # 0x23a5f5
movl $0x144c, %edx           # imm = 0x144C
callq 0x2110
leaq 0x4457f(%rip), %rdi     # 0x23a5c9
jmp 0x1f6053
leaq 0x4463c(%rip), %rdi     # 0x23a68f
leaq 0x432cb(%rip), %rsi     # 0x239325
leaq 0x44594(%rip), %rcx     # 0x23a5f5
movl $0x13eb, %edx           # imm = 0x13EB
callq 0x2110
leaq 0x44632(%rip), %rdi     # 0x23a6a4
jmp 0x1f607b
leaq 0x44652(%rip), %rdi     # 0x23a6cd
leaq 0x432a3(%rip), %rsi     # 0x239325
leaq 0x4456c(%rip), %rcx     # 0x23a5f5
movl $0x13fd, %edx           # imm = 0x13FD
callq 0x2110
leaq 0x44647(%rip), %rdi     # 0x23a6e1
jmp 0x1f60a3
leaq 0x44658(%rip), %rdi     # 0x23a6fb
leaq 0x4327b(%rip), %rsi     # 0x239325
leaq 0x44544(%rip), %rcx     # 0x23a5f5
movl $0x1400, %edx           # imm = 0x1400
callq 0x2110
leaq 0x446f3(%rip), %rdi     # 0x23a7b5
leaq 0x4325c(%rip), %rsi     # 0x239325
leaq 0x44525(%rip), %rcx     # 0x23a5f5
movl $0x144a, %edx           # imm = 0x144A
callq 0x2110