// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: cal_bub_best_by_len(ug_clean_t*, asg64_v*, unsigned int, unsigned int, unsigned int, double, double, unsigned int, unsigned int)
void cal_bub_best_by_len(ug_clean_t *sl, asg64_v *in, uint32_t max_ext, uint32_t is_trio, uint32_t is_ou, double len_rat, double ou_rat, uint32_t min_ou, 
uint32_t min_node)
{
    // fprintf(stderr, "[M::%s]\tStart\n", __func__);
    ma_ug_t *ug = sl->ug; asg_t *g = sl->ug->g; uint32_t ol_max, ou_max, lnid;
    uint32_t v, w, n_vtx = (g->n_seq<<1), nv, nw, i, k, z, kv, kw, bb, to_del, bn, tip;
    asg64_v tx = {0,0,0}, *b = NULL; asg_arc_t *av, *aw, *ve, *we; ma_utg_t *u;
    uint32_t trioF = (uint32_t)-1, ntrioF = (uint32_t)-1, mm_ol, mm_ou, cnt = 0, del_v, del_w;

    if(in) b = in;
    else b = &tx;
    b->n = 0;

    for (v = 0; v < n_vtx; ++v) {
        if (g->seq[v>>1].del) continue;
        av = asg_arc_a(g, v); 
        nv = asg_arc_n(g, v);
        if (nv < 2) continue;

        for (i = kv = bb = 0; i < nv; ++i) {
            if(av[i].del) continue;
            if(is_best_arc((*sl), v, av[i].v)) bb++;
            kv++;
        }
        if((kv < 2) || (!bb) || (kv<=bb)) continue;///it is impossible that kv <= bv

        for (i = 0; i < nv; ++i) {
            if(av[i].del) continue;
            if(is_best_arc((*sl), v, av[i].v)) continue;
            kv_push(uint64_t, *b, (((uint64_t)av[i].ol)<<32) | ((uint64_t)(av-g->arc+i)));   
        }
    }

    radix_sort_srt64(b->a, b->a + b->n);
    for (k = 0; k < b->n; k++) {
        if(g->arc[(uint32_t)b->a[k]].del) continue;

        v = g->arc[(uint32_t)b->a[k]].ul>>32; w = g->arc[(uint32_t)b->a[k]].v^1;
        if(g->seq[v>>1].del || g->seq[w>>1].del) continue;
        nv = asg_arc_n(g, v); nw = asg_arc_n(g, w);
        av = asg_arc_a(g, v); aw = asg_arc_a(g, w);
        if(nv<=1 && nw <= 1) continue;

        if(is_trio) {
            if(get_arcs(g, v, NULL, 0)<=1 && get_arcs(g, w, NULL, 0)<=1) continue;///speedup
            trioF = get_ug_tip_trio_infor(ug, v^1);
            ntrioF = (trioF==FATHER? MOTHER : (trioF==MOTHER? FATHER : (uint32_t)-1));
        }

        ve = &(g->arc[(uint32_t)b->a[k]]);
        for (i = 0; i < nw; ++i) {
            if (aw[i].v == (v^1)) {
                we = &(aw[i]);
                break;
            }
        }
        ///mm_ol and mm_ou are used to make edge with long indel more easy to be cutted
        mm_ol = MIN(ve->ol, we->ol); mm_ou = MIN(ve->ou, we->ou); lnid = 0;

        for (i = kv = ol_max = ou_max = 0; i < nv; ++i) {
            if(av[i].del) continue;
            kv++; 
            if(is_trio && get_ug_tip_trio_infor(ug, av[i].v) == ntrioF) continue;
            if(ol_max < av[i].ol) ol_max = av[i].ol; 
            if(ou_max < av[i].ou) ou_max = av[i].ou;
            if((!lnid) && ((is_best_arc((*sl), v, av[i].v)))) {
                if((cal_utg_occ(ug, v^1) >= min_node) || (cal_utg_occ(ug, av[i].v) >= min_node)) lnid = 1;
            }
        }
        if (kv < 1) continue;
        if (kv >= 2) {
            if (mm_ol > ol_max*len_rat) continue;
            if ((is_ou) && (mm_ou > min_ou) && (mm_ou > (ou_max*ou_rat))) continue;
        }
        

        for (i = kw = ol_max = ou_max = 0; i < nw; ++i) {
            if(aw[i].del) continue;
            kw++; 
            if(is_trio && get_ug_tip_trio_infor(ug, aw[i].v) == ntrioF) continue;
            if(ol_max < aw[i].ol) ol_max = aw[i].ol; 
            if(ou_max < aw[i].ou) ou_max = aw[i].ou;
            if((!lnid) && ((is_best_arc((*sl), w, aw[i].v)))) {
                if((cal_utg_occ(ug, w^1) >= min_node) || (cal_utg_occ(ug, aw[i].v) >= min_node)) lnid = 1;
            }
        }
        if (kw < 1) continue;
        if (kw >= 2) {
            if (mm_ol > ol_max*len_rat) continue;
            if ((is_ou) && (mm_ou > min_ou) && (mm_ou > (ou_max*ou_rat))) continue;
        }

        if (kv <= 1 && kw <= 1) continue;
        if(!lnid) continue;

        to_del = 0; del_v = del_w = (uint32_t)-1; tip = 0;
        if (kv > 1 && kw > 1) {
            to_del = 1;
        } else if (kw == 1) {
            // tip = asg_topocut_aux(g, w^1, max_ext);
            tip = usg_topocut_aux_del(ug, w^1, max_ext, NULL);
            if (tip < max_ext) {
                to_del = 1; del_w = w^1;
            }
        } else if (kv == 1) {
            // tip = asg_topocut_aux(g, v^1, max_ext);
            tip = usg_topocut_aux_del(ug, v^1, max_ext, NULL);
            if (tip < max_ext) {
                to_del = 1; del_v = v^1;
            }
        }

        
        if (to_del) {
            bn = b->n;
            if(del_v != ((uint32_t)-1)) usg_topocut_aux_del(ug, del_v, max_ext, b);
            if(del_w != ((uint32_t)-1)) usg_topocut_aux_del(ug, del_w, max_ext, b);
            for (i = bn; i < b->n; i++) {
                u = &(ug->u.a[b->a[i]>>1]);
                if(u->m == 0) continue;
                for (z = 0; z < u->n; z++) asg_seq_del(sl->sg, u->a[z]>>33);
                asg_seq_del(ug->g, (b->a[i]>>1));
                if(u->m) {
                    u->m = u->n = 0; free(u->a); u->a = NULL;
                }
            }
            // assert(tip == (b->n-bn));
            b->n = bn;

            ve->del = we->del = 1, ++cnt;
            asg_arc_del_by_ug(sl->sg, ug, ve->ul>>32, ve->v, 1);
            asg_arc_del_by_ug(sl->sg, ug, we->ul>>32, we->v, 1);
            
        }
    }

    if(!in) free(tx.a);
    if (cnt > 0) {
        asg_cleanup(g); asg_cleanup(sl->sg);
    }
    // fprintf(stderr, "[M::%s]\tEnd\n", __func__);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movl %r9d, 0x74(%rsp)
movsd %xmm1, 0xa8(%rsp)
movsd %xmm0, 0xb0(%rsp)
movl %r8d, 0x78(%rsp)
movl %ecx, 0x64(%rsp)
movl %edx, 0x5c(%rsp)
movq %rdi, %r12
movq 0x10(%rdi), %rax
movq %rax, 0x28(%rsp)
movq 0x18(%rax), %r10
movl 0x14(%r10), %eax
addl %eax, %eax
xorl %ecx, %ecx
leaq 0xe0(%rsp), %r11
movq %rcx, 0x10(%r11)
xorpd %xmm0, %xmm0
movapd %xmm0, (%r11)
testq %rsi, %rsi
movq %rsi, 0xc8(%rsp)
cmovneq %rsi, %r11
movq %rcx, (%r11)
testl %eax, %eax
movq %r10, 0x30(%rsp)
movq %r11, 0x20(%rsp)
je 0x22bb2e
movl %eax, %eax
movq %rax, 0x8(%rsp)
xorl %r15d, %r15d
movq 0x20(%r10), %rax
movl %r15d, %ecx
shrl %ecx
cmpl $0x0, (%rax,%rcx,8)
js 0x22bb1d
movq 0x28(%r10), %rax
movq (%rax,%r15,8), %rax
testl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
je 0x22bb1d
movq 0x8(%r10), %rcx
movq %rax, %rdx
shrq $0x20, %rdx
leaq (%rdx,%rdx,2), %rdx
leaq (%rcx,%rdx,8), %r13
movl %eax, %r14d
leaq (%rcx,%rdx,8), %rbp
addq $0xc, %rbp
xorl %eax, %eax
movq %r14, %rsi
movq %rbp, %rdi
xorl %edx, %edx
cmpl $0x0, (%rdi)
js 0x22ba3d
movq 0x80(%r12), %r8
movl (%r8,%r15,4), %r9d
cmpl -0x4(%rdi), %r9d
jne 0x22ba3b
xorq $0x1, %r9
movl (%r8,%r9,4), %r8d
xorl %r15d, %r8d
xorl %r9d, %r9d
cmpl $0x1, %r8d
sete %r9b
addl %r9d, %eax
incl %edx
addq $0x18, %rdi
decq %rsi
jne 0x22ba0b
cmpl $0x2, %edx
setae %sil
testl %eax, %eax
setne %dil
cmpl %eax, %edx
seta %al
andb %sil, %dil
andb %al, %dil
cmpb $0x1, %dil
jne 0x22bb1d
xorl %ebx, %ebx
movl (%rbp), %edx
testl %edx, %edx
js 0x22bb0d
movq 0x80(%r12), %rax
movl (%rax,%r15,4), %esi
cmpl -0x4(%rbp), %esi
jne 0x22ba95
xorq $0x1, %rsi
movl (%rax,%rsi,4), %eax
xorl %r15d, %eax
cmpl $0x1, %eax
je 0x22bb0d
movq (%r11), %rdi
movq 0x10(%r11), %rax
cmpq 0x8(%r11), %rdi
jne 0x22bada
leaq (%rdi,%rdi), %rsi
testq %rdi, %rdi
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r11)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2370
movq 0x20(%rsp), %r11
movq 0x30(%rsp), %r10
movq %rax, 0x10(%r11)
movl (%rbp), %edx
movq 0x8(%r10), %rcx
movq (%r11), %rdi
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
shlq $0x20, %rdx
movq %r13, %rsi
subq %rcx, %rsi
sarq $0x3, %rsi
movabsq $-0x5555555555555555, %r8 # imm = 0xAAAAAAAAAAAAAAAB
imulq %r8, %rsi
addq %rbx, %rsi
orq %rdx, %rsi
leaq 0x1(%rdi), %rdx
movq %rdx, (%r11)
movq %rsi, (%rax,%rdi,8)
incq %rbx
addq $0x18, %rbp
cmpq %rbx, %r14
jne 0x22ba6a
incq %r15
cmpq 0x8(%rsp), %r15
jne 0x22b9bd
movq (%r11), %rcx
movq 0x10(%r11), %rdi
leaq (%rdi,%rcx,8), %rsi
callq 0x1ee586
movq 0x20(%rsp), %r10
movq (%r10), %rbx
testq %rbx, %rbx
je 0x22c610
movl $0xffffffff, 0x60(%rsp) # imm = 0xFFFFFFFF
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
xorl %eax, %eax
movl $0x0, 0x7c(%rsp)
xorl %r11d, %r11d
movq %r12, 0x50(%rsp)
movq 0x30(%rsp), %rdi
movq 0x8(%rdi), %r14
movq 0x10(%r10), %rcx
movl (%rcx,%rax,8), %eax
leaq (%rax,%rax,2), %r15
movl 0xc(%r14,%r15,8), %ebp
testl %ebp, %ebp
js 0x22c441
movq (%r14,%r15,8), %rcx
movq 0x20(%rdi), %rax
movq %rcx, %rdx
shrq $0x21, %rcx
cmpl $0x0, (%rax,%rcx,8)
js 0x22c441
movl 0x8(%r14,%r15,8), %esi
movl %esi, %ecx
shrl %ecx
cmpl $0x0, (%rax,%rcx,8)
js 0x22c441
shrq $0x20, %rdx
movq %rsi, 0xb8(%rsp)
xorq $0x1, %rsi
movq 0x28(%rdi), %rax
movq %rdx, 0x90(%rsp)
movq (%rax,%rdx,8), %r8
movq %rsi, 0xd8(%rsp)
movq (%rax,%rsi,8), %rcx
cmpl $0x1, %r8d
ja 0x22bbf4
cmpl $0x2, %ecx
jb 0x22c441
movq %rbx, 0x18(%rsp)
movq %r11, 0x10(%rsp)
movq %r8, %r9
shrq $0x20, %r9
movq %rcx, %rbx
shrq $0x20, %rbx
cmpl $0x0, 0x64(%rsp)
movq %rcx, 0xa0(%rsp)
je 0x22bcdd
movq %r8, %rax
andq %r13, %rax
je 0x22bc4b
xorl %ecx, %ecx
movq %r9, %rdx
movl %edx, %esi
leaq (%rsi,%rsi,2), %rsi
movl 0xc(%r14,%rsi,8), %esi
notl %esi
shrl $0x1f, %esi
addl %esi, %ecx
incq %rdx
decq %rax
jne 0x22bc2c
cmpl $0x1, %ecx
ja 0x22bc84
movq 0xa0(%rsp), %rax
andq %r13, %rax
je 0x22c437
xorl %ecx, %ecx
movq %rbx, %rdx
movl %edx, %esi
leaq (%rsi,%rsi,2), %rsi
movl 0xc(%r14,%rsi,8), %esi
notl %esi
shrl $0x1f, %esi
addl %esi, %ecx
incq %rdx
decq %rax
jne 0x22bc61
cmpl $0x2, %ecx
jb 0x22c437
movq 0x90(%rsp), %r12
movl %r12d, %esi
xorl $0x1, %esi
movq 0x28(%rsp), %rdi
movq %r8, 0x8(%rsp)
movq %r9, 0x40(%rsp)
callq 0x1f5161
movq 0x40(%rsp), %r9
movq 0x8(%rsp), %r8
movq 0x20(%rsp), %r10
movq 0x30(%rsp), %rdi
xorl %ecx, %ecx
cmpb $0x2, %al
sete %cl
cmpb $0x1, %al
leal -0x1(%rcx,%rcx), %ecx
movl $0x2, %eax
cmovel %eax, %ecx
movl %ecx, 0x60(%rsp)
movq 0xa0(%rsp), %rcx
jmp 0x22bce5
movq 0x90(%rsp), %r12
leaq (%rbx,%rbx,2), %rax
testl %ecx, %ecx
movq %rax, 0xd0(%rsp)
je 0x22bd1b
leaq (%r14,%rax,8), %rax
movl %ecx, %ecx
movq 0x10(%rsp), %r11
movq 0x18(%rsp), %rbx
movl 0x8(%rax), %edx
xorl %r12d, %edx
cmpl $0x1, %edx
je 0x22bd27
addq $0x18, %rax
decq %rcx
jne 0x22bd05
jmp 0x22bd2f
movq 0x10(%rsp), %r11
movq 0x18(%rsp), %rbx
jmp 0x22bd2f
movq %rax, 0x88(%rsp)
leaq (%r14,%r15,8), %rsi
movq 0x88(%rsp), %rdx
movl 0xc(%rdx), %ecx
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andl %eax, %ecx
cmpl %ecx, %ebp
cmovbl %ebp, %ecx
movl %ecx, 0x80(%rsp)
movzwl 0x10(%rsi), %eax
movl $0x3fff, %ecx           # imm = 0x3FFF
andl %ecx, %eax
movzwl 0x10(%rdx), %edx
andl %ecx, %edx
cmpw %dx, %ax
cmovbl %eax, %edx
testl %r8d, %r8d
je 0x22c3a9
movl %edx, 0x4c(%rsp)
movq %rsi, 0xc0(%rsp)
movl %r12d, %eax
xorl $0x1, %eax
movl %eax, 0x84(%rsp)
movl %r8d, %eax
leaq (%r9,%r9,2), %rcx
leaq (%r14,%rcx,8), %r9
addq $0x8, %r9
shlq $0x3, %rax
leaq (%rax,%rax,2), %r11
xorl %r15d, %r15d
xorl %r8d, %r8d
xorl %r12d, %r12d
xorl %ebx, %ebx
xorl %edx, %edx
movq %r9, 0x40(%rsp)
movq %r11, 0x68(%rsp)
movq %r14, 0x98(%rsp)
movl 0x4(%r9,%r15), %ebp
testl %ebp, %ebp
js 0x22bed3
incl %edx
cmpl $0x0, 0x64(%rsp)
je 0x22be27
movl (%r9,%r15), %esi
movq 0x28(%rsp), %rdi
movl %r12d, 0x8(%rsp)
movl %ebx, %r14d
movl %edx, %ebx
movl %r8d, %r12d
callq 0x1f5161
movq 0x68(%rsp), %r11
movq 0x40(%rsp), %r9
movl %r12d, %r8d
movl %ebx, %edx
movl %r14d, %ebx
movq 0x98(%rsp), %r14
movl 0x8(%rsp), %r12d
movq 0x20(%rsp), %r10
movq 0x30(%rsp), %rdi
movzbl %al, %eax
cmpl %eax, 0x60(%rsp)
je 0x22bed3
cmpl %ebp, %r8d
cmovbel %ebp, %r8d
movzwl 0x8(%r9,%r15), %eax
andl $0x3fff, %eax           # imm = 0x3FFF
cmpl %eax, %r12d
cmovbel %eax, %r12d
testl %ebx, %ebx
je 0x22be4e
movl $0x1, %ebx
jmp 0x22bed3
movq 0x50(%rsp), %rax
movq 0x80(%rax), %rax
movq 0x90(%rsp), %rcx
movl (%rax,%rcx,4), %ebp
xorl %ebx, %ebx
cmpl (%r9,%r15), %ebp
jne 0x22bed3
movq %rbp, %rcx
xorq $0x1, %rcx
movl 0x84(%rsp), %esi
cmpl %esi, (%rax,%rcx,4)
jne 0x22bed3
movl %r8d, 0x8(%rsp)
movl %edx, 0x3c(%rsp)
movq 0x28(%rsp), %rdi
callq 0x22b82c
cmpl 0x130(%rsp), %eax
jae 0x22beb1
movq 0x28(%rsp), %rdi
movl %ebp, %esi
callq 0x22b82c
cmpl 0x130(%rsp), %eax
jb 0x22beb6
movl $0x1, %ebx
movq 0x30(%rsp), %rdi
movq 0x20(%rsp), %r10
movl 0x3c(%rsp), %edx
movl 0x8(%rsp), %r8d
movq 0x40(%rsp), %r9
movq 0x68(%rsp), %r11
addq $0x18, %r15
cmpq %r15, %r11
jne 0x22bdc0
testl %edx, %edx
je 0x22c3b3
movl %r12d, %ecx
cmpl $0x1, %edx
movq 0x50(%rsp), %r12
jne 0x22c3ba
movq 0xa0(%rsp), %rax
testl %eax, %eax
je 0x22c437
movl %ebx, 0x8(%rsp)
movl %eax, %eax
movq 0xd0(%rsp), %rcx
leaq (%r14,%rcx,8), %r12
addq $0x8, %r12
shlq $0x3, %rax
leaq (%rax,%rax,2), %r9
xorl %r14d, %r14d
xorl %ebx, %ebx
xorl %r15d, %r15d
xorl %r8d, %r8d
movl %edx, 0x3c(%rsp)
movq %r9, 0x40(%rsp)
movq %r12, 0x68(%rsp)
movl 0x4(%r12,%r14), %ebp
testl %ebp, %ebp
js 0x22c053
incl %r8d
cmpl $0x0, 0x64(%rsp)
je 0x22bf9c
movl (%r12,%r14), %esi
movq 0x28(%rsp), %rdi
movl %ebx, %r12d
movl %r15d, %ebx
movl %r8d, %r15d
callq 0x1f5161
movq 0x40(%rsp), %r9
movl %r15d, %r8d
movl %ebx, %r15d
movl %r12d, %ebx
movq 0x68(%rsp), %r12
movl 0x3c(%rsp), %edx
movq 0x20(%rsp), %r10
movq 0x30(%rsp), %rdi
movzbl %al, %eax
cmpl %eax, 0x60(%rsp)
je 0x22c053
cmpl %ebp, %ebx
cmovbel %ebp, %ebx
movzwl 0x8(%r12,%r14), %eax
andl $0x3fff, %eax           # imm = 0x3FFF
cmpl %eax, %r15d
cmovbel %eax, %r15d
cmpl $0x0, 0x8(%rsp)
je 0x22bfc7
movl $0x1, 0x8(%rsp)
jmp 0x22c053
movq 0x50(%rsp), %rax
movq 0x80(%rax), %rax
movq 0xd8(%rsp), %rcx
movl (%rax,%rcx,4), %ebp
movl $0x0, 0x8(%rsp)
cmpl (%r12,%r14), %ebp
jne 0x22c053
movq %rbp, %rcx
xorq $0x1, %rcx
movq 0xb8(%rsp), %rsi
cmpl %esi, (%rax,%rcx,4)
jne 0x22c053
movl %r8d, 0x98(%rsp)
movq 0x28(%rsp), %rdi
callq 0x22b82c
cmpl 0x130(%rsp), %eax
jae 0x22c030
movq 0x28(%rsp), %rdi
movl %ebp, %esi
callq 0x22b82c
cmpl 0x130(%rsp), %eax
jb 0x22c038
movl $0x1, 0x8(%rsp)
movq 0x30(%rsp), %rdi
movq 0x20(%rsp), %r10
movl 0x3c(%rsp), %edx
movl 0x98(%rsp), %r8d
movq 0x40(%rsp), %r9
addq $0x18, %r14
cmpq %r14, %r9
jne 0x22bf40
testl %r8d, %r8d
je 0x22c3b3
cmpl $0x1, %r8d
movq 0x50(%rsp), %r12
jne 0x22c415
movl %edx, %eax
xorl $0x1, %eax
movl %r8d, %ecx
xorl $0x1, %ecx
orl %eax, %ecx
setne %al
cmpl $0x0, 0x8(%rsp)
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x22c437
cmpl $0x1, %r8d
setne %al
cmpl $0x1, %edx
setne %cl
testb %al, %cl
movq 0x18(%rsp), %rbx
je 0x22c558
movl %ebx, %eax
movq %rax, 0x8(%rsp)
cmpq %rax, (%r10)
jbe 0x22c2e4
movq 0x8(%rsp), %rax
movq %rbx, 0x18(%rsp)
movq 0x28(%rsp), %rcx
movq 0x10(%rcx), %rsi
movq 0x10(%r10), %rcx
movq (%rcx,%rax,8), %rcx
movq %rcx, %rdx
shrq %rdx
leaq (%rdx,%rdx,4), %rdi
cmpl $0x0, 0xc(%rsi,%rdi,8)
je 0x22c2d1
leaq (%rsi,%rdi,8), %rbp
cmpl $0x0, 0x10(%rbp)
je 0x22c1f2
xorl %ecx, %ecx
movq 0x8(%r12), %rdx
movq 0x18(%rbp), %rsi
movq (%rsi,%rcx,8), %rsi
shrq $0x21, %rsi
movq 0x20(%rdx), %rdi
orl $0x80000000, (%rdi,%rsi,8) # imm = 0x80000000
addl %esi, %esi
movb $0x1, %dil
xorl %r8d, %r8d
orq %rsi, %r8
movq 0x28(%rdx), %r9
movq (%r9,%r8,8), %r10
movq %r10, %r9
andq %r13, %r9
je 0x22c1b6
shrq $0x20, %r10
leaq (%r10,%r10,2), %r10
shlq $0x3, %r10
addq 0x8(%rdx), %r10
xorl %r11d, %r11d
leaq (%r11,%r11,2), %rbx
orb $-0x80, 0xf(%r10,%rbx,8)
movl 0x8(%r10,%rbx,8), %ebx
xorq $0x1, %rbx
movq 0x28(%rdx), %r15
movq (%r15,%rbx,8), %r15
movq %r15, %rbx
andq %r13, %rbx
je 0x22c1ae
movq 0x8(%rdx), %r12
shrq $0x20, %r15
shlq $0x3, %rbx
leaq (%rbx,%rbx,2), %rbx
leaq (%r15,%r15,2), %r15
leaq (%r12,%r15,8), %r15
addq $0xc, %r15
xorl %r12d, %r12d
movl -0x4(%r15,%r12), %r14d
xorl %r8d, %r14d
cmpl $0x1, %r14d
jne 0x22c1a5
orb $-0x80, 0x3(%r15,%r12)
addq $0x18, %r12
cmpq %r12, %rbx
jne 0x22c191
incq %r11
cmpq %r9, %r11
jne 0x22c14f
movl $0x1, %r8d
testb $0x1, %dil
movl $0x0, %edi
jne 0x22c129
incq %rcx
movl 0x10(%rbp), %edx
cmpq %rdx, %rcx
movq 0x50(%rsp), %r12
jb 0x22c105
movq 0x20(%rsp), %rcx
movq 0x10(%rcx), %rcx
movq (%rcx,%rax,8), %rcx
movq %rcx, %rdx
shrq %rdx
movq 0x28(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rsi
movl %edx, %edx
orl $0x80000000, (%rsi,%rdx,8) # imm = 0x80000000
andl $-0x2, %ecx
movb $0x1, %dl
xorl %esi, %esi
orq %rcx, %rsi
movq 0x28(%rax), %rdi
movq (%rdi,%rsi,8), %r8
movq %r8, %rdi
andq %r13, %rdi
je 0x22c29b
shrq $0x20, %r8
leaq (%r8,%r8,2), %r8
shlq $0x3, %r8
addq 0x8(%rax), %r8
xorl %r9d, %r9d
leaq (%r9,%r9,2), %r10
orb $-0x80, 0xf(%r8,%r10,8)
movl 0x8(%r8,%r10,8), %r10d
xorq $0x1, %r10
movq 0x28(%rax), %r11
movq (%r11,%r10,8), %r11
movq %r11, %r10
andq %r13, %r10
je 0x22c293
movq 0x8(%rax), %rbx
shrq $0x20, %r11
shlq $0x3, %r10
leaq (%r10,%r10,2), %r10
leaq (%r11,%r11,2), %r11
leaq (%rbx,%r11,8), %r11
addq $0xc, %r11
xorl %ebx, %ebx
movl -0x4(%r11,%rbx), %r14d
xorl %esi, %r14d
cmpl $0x1, %r14d
jne 0x22c28a
orb $-0x80, 0x3(%r11,%rbx)
addq $0x18, %rbx
cmpq %rbx, %r10
jne 0x22c276
incq %r9
cmpq %rdi, %r9
jne 0x22c235
movl $0x1, %esi
testb $0x1, %dl
movl $0x0, %edx
jne 0x22c20f
cmpl $0x0, 0xc(%rbp)
movq 0x20(%rsp), %r10
je 0x22c2d1
xorl %ebx, %ebx
movq %rbx, 0xc(%rbp)
movq 0x18(%rbp), %rdi
callq 0x2220
movq 0x20(%rsp), %r10
movq %rbx, 0x18(%rbp)
movq 0x18(%rsp), %rbx
incl %ebx
movq %rbx, %rax
cmpq %rbx, (%r10)
ja 0x22c0ca
movq 0x8(%rsp), %rax
movq %rax, (%r10)
movq 0x88(%rsp), %rax
orb $-0x80, 0xf(%rax)
movq 0xc0(%rsp), %r8
orb $-0x80, 0xf(%r8)
movq 0x8(%r12), %rax
movq (%r8), %rdx
xorl %esi, %esi
btq $0x20, %rdx
setae %sil
movq 0x28(%rsp), %rcx
movq 0x10(%rcx), %rcx
shrq $0x21, %rdx
leaq (%rdx,%rdx,4), %rdx
leaq (%rcx,%rdx,8), %rdx
movl 0x4(%rdx,%rsi,4), %edx
xorq $0x1, %rdx
movq 0x28(%rax), %rsi
movq (%rsi,%rdx,8), %rsi
movq %rsi, %rdx
andq %r13, %rdx
movq 0x30(%rsp), %rdi
movq 0x10(%rsp), %r11
je 0x22c659
incl 0x7c(%rsp)
movl 0x8(%r8), %r9d
movl %r9d, %r8d
shrl %r8d
leaq (%r8,%r8,4), %r8
leaq (%rcx,%r8,8), %rcx
andl $0x1, %r9d
movl 0x4(%rcx,%r9,4), %ecx
movq 0x8(%rax), %rax
shrq $0x20, %rsi
leaq (%rsi,%rsi,2), %rsi
leaq (%rax,%rsi,8), %r9
addq $0xc, %r9
shlq $0x3, %rdx
leaq (%rdx,%rdx,2), %r8
xorl %edx, %edx
cmpl %ecx, -0x4(%r9,%rdx)
je 0x22c494
addq $0x18, %rdx
cmpq %rdx, %r8
jne 0x22c390
jmp 0x22c659
movq 0x50(%rsp), %r12
jmp 0x22c441
movq 0x50(%rsp), %r12
jmp 0x22c437
cvtsi2sd %r8d, %xmm0
cvtsi2sdl 0x80(%rsp), %xmm1
mulsd 0xb0(%rsp), %xmm0
ucomisd %xmm0, %xmm1
ja 0x22c437
cmpl $0x0, 0x78(%rsp)
je 0x22bef9
movl 0x4c(%rsp), %eax
cmpl 0x74(%rsp), %eax
jbe 0x22bef9
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl 0x4c(%rsp), %xmm1
mulsd 0xa8(%rsp), %xmm0
ucomisd %xmm0, %xmm1
jbe 0x22bef9
jmp 0x22c437
xorps %xmm0, %xmm0
cvtsi2sd %ebx, %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl 0x80(%rsp), %xmm1
mulsd 0xb0(%rsp), %xmm0
ucomisd %xmm0, %xmm1
jbe 0x22c455
movq 0x10(%rsp), %r11
movq 0x18(%rsp), %rbx
incl %r11d
movq %r11, %rax
cmpq %r11, %rbx
ja 0x22bb71
jmp 0x22c606
cmpl $0x0, 0x78(%rsp)
je 0x22c078
movl 0x4c(%rsp), %eax
cmpl 0x74(%rsp), %eax
jbe 0x22c078
xorps %xmm0, %xmm0
cvtsi2sd %r15d, %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl 0x4c(%rsp), %xmm1
mulsd 0xa8(%rsp), %xmm0
ucomisd %xmm0, %xmm1
jbe 0x22c078
jmp 0x22c437
leaq (%rax,%rsi,8), %rax
orb $-0x80, 0xf(%rdx,%rax)
movq 0x8(%r12), %rax
movq 0x88(%rsp), %rcx
movq (%rcx), %rdx
xorl %esi, %esi
movabsq $0x100000000, %rcx      # imm = 0x100000000
testq %rcx, %rdx
sete %sil
movq 0x28(%rsp), %rcx
movq 0x10(%rcx), %rcx
shrq $0x21, %rdx
leaq (%rdx,%rdx,4), %rdx
leaq (%rcx,%rdx,8), %rdx
movl 0x4(%rdx,%rsi,4), %edx
xorq $0x1, %rdx
movq 0x28(%rax), %rsi
movq (%rsi,%rdx,8), %rsi
movq %rsi, %rdx
andq %r13, %rdx
je 0x22c659
movq 0x88(%rsp), %r8
movl 0x8(%r8), %r9d
movl %r9d, %r8d
shrl %r8d
leaq (%r8,%r8,4), %r8
leaq (%rcx,%r8,8), %rcx
andl $0x1, %r9d
movl 0x4(%rcx,%r9,4), %ecx
movq 0x8(%rax), %rax
shrq $0x20, %rsi
leaq (%rsi,%rsi,2), %rsi
leaq (%rax,%rsi,8), %r9
addq $0xc, %r9
shlq $0x3, %rdx
leaq (%rdx,%rdx,2), %r8
xorl %edx, %edx
cmpl %ecx, -0x4(%r9,%rdx)
je 0x22c547
addq $0x18, %rdx
cmpq %rdx, %r8
jne 0x22c532
jmp 0x22c659
leaq (%rax,%rsi,8), %rax
orb $-0x80, 0xf(%rdx,%rax)
movq (%r10), %rbx
jmp 0x22c441
cmpl $0x1, %r8d
jne 0x22c590
movq 0x28(%rsp), %rdi
movq 0xb8(%rsp), %r14
movl %r14d, %esi
movl 0x5c(%rsp), %ebx
movl %ebx, %edx
xorl %ecx, %ecx
callq 0x22b75b
movq 0x20(%rsp), %r10
movq (%r10), %rcx
cmpl %ebx, %eax
jae 0x22c5ea
movl %r14d, %ebp
cmpl $-0x1, %r14d
jmp 0x22c5c4
cmpl $0x1, %edx
jne 0x22c5fc
movq 0x28(%rsp), %rdi
movl 0x84(%rsp), %ebp
movl %ebp, %esi
movl 0x5c(%rsp), %ebx
movl %ebx, %edx
xorl %ecx, %ecx
callq 0x22b75b
movq 0x20(%rsp), %r10
movq (%r10), %rcx
cmpl %ebx, %eax
jae 0x22c5ea
cmpl $-0x2, 0x90(%rsp)
movq %rcx, %rbx
je 0x22c0b5
movq 0x28(%rsp), %rdi
movl %ebp, %esi
movl 0x5c(%rsp), %edx
movq %r10, %rcx
callq 0x22b75b
movq 0x20(%rsp), %r10
jmp 0x22c0b5
movq 0x30(%rsp), %rdi
movq 0x10(%rsp), %r11
movq %rcx, %rbx
jmp 0x22c441
movq 0x10(%rsp), %r11
jmp 0x22c441
cmpl $0x0, 0x7c(%rsp)
sete %bl
jmp 0x22c617
movb $0x1, %bl
movq 0x30(%rsp), %rdi
cmpq $0x0, 0xc8(%rsp)
jne 0x22c634
movq 0xf0(%rsp), %rdi
callq 0x2220
movq 0x30(%rsp), %rdi
testb %bl, %bl
jne 0x22c647
callq 0xa0a7d
movq 0x8(%r12), %rdi
callq 0xa0a7d
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9c3e(%rip), %rdi      # 0x23629e
leaq 0x18fa2(%rip), %rsi     # 0x245609
leaq 0x1e1f0(%rip), %rcx     # 0x24a85e
movl $0x45ce, %edx           # imm = 0x45CE
callq 0x2110