// File: 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
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
movsd %xmm0, -0x28(%rbp)
movsd %xmm1, -0x30(%rbp)
movl %r9d, -0x34(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x18(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movl %eax, -0x60(%rbp)
leaq -0xa8(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x2100
movq $0x0, -0xb0(%rbp)
movl $0xffffffff, -0xdc(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0xe0(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0xec(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x37a72b
movq -0x10(%rbp), %rax
movq %rax, -0xb0(%rbp)
jmp 0x37a739
leaq -0xa8(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rax
movq $0x0, (%rax)
movl $0x0, -0x58(%rbp)
movl -0x58(%rbp), %eax
cmpl -0x60(%rbp), %eax
jae 0x37aa40
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x58(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x37a779
jmp 0x37aa32
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x48(%rbp), %rcx
movq 0x28(%rcx), %rcx
movl -0x58(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xb8(%rbp)
movq -0x48(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x58(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x64(%rbp)
cmpl $0x2, -0x64(%rbp)
jae 0x37a7bf
jmp 0x37aa32
movl $0x0, -0x80(%rbp)
movl $0x0, -0x78(%rbp)
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
cmpl -0x64(%rbp), %eax
jae 0x37a876
movq -0xb8(%rbp), %rax
movl -0x6c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x37a7fe
jmp 0x37a868
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rax
movl -0x58(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movq -0xb8(%rbp), %rcx
movl -0x6c(%rbp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x8(%rcx), %eax
jne 0x37a85f
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rax
movq -0xb8(%rbp), %rcx
movl -0x6c(%rbp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %ecx
xorl $0x1, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl -0x58(%rbp), %ecx
xorl $0x1, %ecx
cmpl %ecx, %eax
jne 0x37a85f
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x37a7d4
cmpl $0x2, -0x78(%rbp)
jb 0x37a88a
cmpl $0x0, -0x80(%rbp)
je 0x37a88a
movl -0x78(%rbp), %eax
cmpl -0x80(%rbp), %eax
ja 0x37a88f
jmp 0x37aa32
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
cmpl -0x64(%rbp), %eax
jae 0x37aa30
movq -0xb8(%rbp), %rax
movl -0x6c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x37a8c3
jmp 0x37aa22
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rax
movl -0x58(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movq -0xb8(%rbp), %rcx
movl -0x6c(%rbp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x8(%rcx), %eax
jne 0x37a920
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rax
movq -0xb8(%rbp), %rcx
movl -0x6c(%rbp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %ecx
xorl $0x1, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl -0x58(%rbp), %ecx
xorl $0x1, %ecx
cmpl %ecx, %eax
jne 0x37a920
jmp 0x37aa22
jmp 0x37a922
movq -0xb0(%rbp), %rax
movq (%rax), %rax
movq -0xb0(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x37a9ab
movq -0xb0(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x37a95e
movq -0xb0(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0x100(%rbp)
jmp 0x37a96c
movl $0x2, %eax
movq %rax, -0x100(%rbp)
jmp 0x37a96c
movq -0x100(%rbp), %rcx
movq -0xb0(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0xb0(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0xb0(%rbp), %rax
movq 0x8(%rax), %rsi
shlq $0x3, %rsi
callq 0x2360
movq %rax, %rcx
movq -0xb0(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0xb8(%rbp), %rax
movl -0x6c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
shlq $0x20, %rax
movq %rax, -0x108(%rbp)
movq -0xb8(%rbp), %rax
movq -0x48(%rbp), %rcx
movq 0x8(%rcx), %rcx
subq %rcx, %rax
movl $0x18, %ecx
cqto
idivq %rcx
movq -0x108(%rbp), %rdx
movl -0x6c(%rbp), %ecx
addq %rcx, %rax
orq %rax, %rdx
movq -0xb0(%rbp), %rax
movq 0x10(%rax), %rax
movq -0xb0(%rbp), %rsi
movq (%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, (%rsi)
movq %rdx, (%rax,%rcx,8)
jmp 0x37aa22
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x37a896
jmp 0x37aa32
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x37a74e
movq -0xb0(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0xb0(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0xb0(%rbp), %rax
movq (%rax), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x30ed90
movl $0x0, -0x70(%rbp)
movl -0x70(%rbp), %eax
movq -0xb0(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x37b51a
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq -0xb0(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x70(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x37aab9
jmp 0x37b50c
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq -0xb0(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x70(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
shrq $0x20, %rax
movl %eax, -0x58(%rbp)
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq -0xb0(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x70(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
xorl $0x1, %eax
movl %eax, -0x5c(%rbp)
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x58(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
jne 0x37ab46
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x5c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x37ab4b
jmp 0x37b50c
movq -0x48(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x58(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x64(%rbp)
movq -0x48(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x5c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x68(%rbp)
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x48(%rbp), %rcx
movq 0x28(%rcx), %rcx
movl -0x58(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xb8(%rbp)
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x48(%rbp), %rcx
movq 0x28(%rcx), %rcx
movl -0x5c(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xc0(%rbp)
cmpl $0x1, -0x64(%rbp)
ja 0x37abd2
cmpl $0x1, -0x68(%rbp)
ja 0x37abd2
jmp 0x37b50c
cmpl $0x0, -0x18(%rbp)
je 0x37ac65
movq -0x48(%rbp), %rdi
movl -0x58(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
xorl %ecx, %ecx
callq 0x311ba0
cmpl $0x1, %eax
ja 0x37ac0f
movq -0x48(%rbp), %rdi
movl -0x5c(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
xorl %ecx, %ecx
callq 0x311ba0
cmpl $0x1, %eax
ja 0x37ac0f
jmp 0x37b50c
movq -0x40(%rbp), %rdi
movl -0x58(%rbp), %esi
xorl $0x1, %esi
callq 0x318e70
movzbl %al, %eax
movl %eax, -0xdc(%rbp)
cmpl $0x1, -0xdc(%rbp)
jne 0x37ac3d
movl $0x2, %eax
movl %eax, -0x10c(%rbp)
jmp 0x37ac59
movl -0xdc(%rbp), %edx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl $0x1, %ecx
cmpl $0x2, %edx
cmovel %ecx, %eax
movl %eax, -0x10c(%rbp)
movl -0x10c(%rbp), %eax
movl %eax, -0xe0(%rbp)
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq -0xb0(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x70(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xc8(%rbp)
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
cmpl -0x68(%rbp), %eax
jae 0x37ace3
movq -0xc0(%rbp), %rax
movl -0x6c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl -0x58(%rbp), %ecx
xorl $0x1, %ecx
cmpl %ecx, %eax
jne 0x37acd6
movq -0xc0(%rbp), %rax
movl -0x6c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xd0(%rbp)
jmp 0x37ace3
jmp 0x37acd8
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x37ac96
movq -0xc8(%rbp), %rax
movl 0xc(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq -0xd0(%rbp), %rcx
movl 0xc(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpl %ecx, %eax
jg 0x37ad1d
movq -0xc8(%rbp), %rax
movl 0xc(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, -0x110(%rbp)
jmp 0x37ad32
movq -0xd0(%rbp), %rax
movl 0xc(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, -0x110(%rbp)
movl -0x110(%rbp), %eax
movl %eax, -0xe4(%rbp)
movq -0xc8(%rbp), %rax
movw 0x10(%rax), %ax
andw $0x3fff, %ax            # imm = 0x3FFF
movzwl %ax, %eax
movq -0xd0(%rbp), %rcx
movw 0x10(%rcx), %cx
andw $0x3fff, %cx            # imm = 0x3FFF
movzwl %cx, %ecx
cmpl %ecx, %eax
jg 0x37ad7f
movq -0xc8(%rbp), %rax
movw 0x10(%rax), %ax
andw $0x3fff, %ax            # imm = 0x3FFF
movw %ax, -0x112(%rbp)
jmp 0x37ad95
movq -0xd0(%rbp), %rax
movw 0x10(%rax), %ax
andw $0x3fff, %ax            # imm = 0x3FFF
movw %ax, -0x112(%rbp)
movw -0x112(%rbp), %ax
movzwl %ax, %eax
movl %eax, -0xe8(%rbp)
movl $0x0, -0x54(%rbp)
movl $0x0, -0x50(%rbp)
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x78(%rbp)
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
cmpl -0x64(%rbp), %eax
jae 0x37af62
movq -0xb8(%rbp), %rax
movl -0x6c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x37adf5
jmp 0x37af54
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
cmpl $0x0, -0x18(%rbp)
je 0x37ae31
movq -0x40(%rbp), %rdi
movq -0xb8(%rbp), %rax
movl -0x6c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %esi
callq 0x318e70
movzbl %al, %eax
cmpl -0xe0(%rbp), %eax
jne 0x37ae31
jmp 0x37af54
movl -0x4c(%rbp), %eax
movq -0xb8(%rbp), %rcx
movl -0x6c(%rbp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movl 0xc(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpl %ecx, %eax
jae 0x37ae6e
movq -0xb8(%rbp), %rax
movl -0x6c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, -0x4c(%rbp)
movl -0x50(%rbp), %eax
movq -0xb8(%rbp), %rcx
movl -0x6c(%rbp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movw 0x10(%rcx), %cx
andw $0x3fff, %cx            # imm = 0x3FFF
movzwl %cx, %ecx
cmpl %ecx, %eax
jae 0x37aeb1
movq -0xb8(%rbp), %rax
movl -0x6c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movw 0x10(%rax), %ax
andw $0x3fff, %ax            # imm = 0x3FFF
movzwl %ax, %eax
movl %eax, -0x50(%rbp)
cmpl $0x0, -0x54(%rbp)
jne 0x37af52
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rax
movl -0x58(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movq -0xb8(%rbp), %rcx
movl -0x6c(%rbp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x8(%rcx), %eax
jne 0x37af52
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rax
movq -0xb8(%rbp), %rcx
movl -0x6c(%rbp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %ecx
xorl $0x1, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl -0x58(%rbp), %ecx
xorl $0x1, %ecx
cmpl %ecx, %eax
jne 0x37af52
movq -0x40(%rbp), %rdi
movl -0x58(%rbp), %esi
xorl $0x1, %esi
callq 0x37a5c0
cmpl 0x10(%rbp), %eax
jae 0x37af49
movq -0x40(%rbp), %rdi
movq -0xb8(%rbp), %rax
movl -0x6c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %esi
callq 0x37a5c0
cmpl 0x10(%rbp), %eax
jb 0x37af50
movl $0x1, -0x54(%rbp)
jmp 0x37af52
jmp 0x37af54
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x37adc8
cmpl $0x1, -0x78(%rbp)
jae 0x37af6d
jmp 0x37b50c
cmpl $0x2, -0x78(%rbp)
jb 0x37afcc
movl -0xe4(%rbp), %eax
cvtsi2sd %rax, %xmm0
movl -0x4c(%rbp), %eax
cvtsi2sd %rax, %xmm1
mulsd -0x28(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x37af96
jmp 0x37b50c
cmpl $0x0, -0x1c(%rbp)
je 0x37afca
movl -0xe8(%rbp), %eax
cmpl -0x34(%rbp), %eax
jbe 0x37afca
movl -0xe8(%rbp), %eax
cvtsi2sd %rax, %xmm0
movl -0x50(%rbp), %eax
cvtsi2sd %rax, %xmm1
mulsd -0x30(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x37afca
jmp 0x37b50c
jmp 0x37afcc
movl $0x0, -0x50(%rbp)
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x7c(%rbp)
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
cmpl -0x68(%rbp), %eax
jae 0x37b182
movq -0xc0(%rbp), %rax
movl -0x6c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x37b015
jmp 0x37b174
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
cmpl $0x0, -0x18(%rbp)
je 0x37b051
movq -0x40(%rbp), %rdi
movq -0xc0(%rbp), %rax
movl -0x6c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %esi
callq 0x318e70
movzbl %al, %eax
cmpl -0xe0(%rbp), %eax
jne 0x37b051
jmp 0x37b174
movl -0x4c(%rbp), %eax
movq -0xc0(%rbp), %rcx
movl -0x6c(%rbp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movl 0xc(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpl %ecx, %eax
jae 0x37b08e
movq -0xc0(%rbp), %rax
movl -0x6c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, -0x4c(%rbp)
movl -0x50(%rbp), %eax
movq -0xc0(%rbp), %rcx
movl -0x6c(%rbp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movw 0x10(%rcx), %cx
andw $0x3fff, %cx            # imm = 0x3FFF
movzwl %cx, %ecx
cmpl %ecx, %eax
jae 0x37b0d1
movq -0xc0(%rbp), %rax
movl -0x6c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movw 0x10(%rax), %ax
andw $0x3fff, %ax            # imm = 0x3FFF
movzwl %ax, %eax
movl %eax, -0x50(%rbp)
cmpl $0x0, -0x54(%rbp)
jne 0x37b172
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rax
movl -0x5c(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movq -0xc0(%rbp), %rcx
movl -0x6c(%rbp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x8(%rcx), %eax
jne 0x37b172
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rax
movq -0xc0(%rbp), %rcx
movl -0x6c(%rbp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %ecx
xorl $0x1, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl -0x5c(%rbp), %ecx
xorl $0x1, %ecx
cmpl %ecx, %eax
jne 0x37b172
movq -0x40(%rbp), %rdi
movl -0x5c(%rbp), %esi
xorl $0x1, %esi
callq 0x37a5c0
cmpl 0x10(%rbp), %eax
jae 0x37b169
movq -0x40(%rbp), %rdi
movq -0xc0(%rbp), %rax
movl -0x6c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %esi
callq 0x37a5c0
cmpl 0x10(%rbp), %eax
jb 0x37b170
movl $0x1, -0x54(%rbp)
jmp 0x37b172
jmp 0x37b174
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x37afe8
cmpl $0x1, -0x7c(%rbp)
jae 0x37b18d
jmp 0x37b50c
cmpl $0x2, -0x7c(%rbp)
jb 0x37b1ec
movl -0xe4(%rbp), %eax
cvtsi2sd %rax, %xmm0
movl -0x4c(%rbp), %eax
cvtsi2sd %rax, %xmm1
mulsd -0x28(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x37b1b6
jmp 0x37b50c
cmpl $0x0, -0x1c(%rbp)
je 0x37b1ea
movl -0xe8(%rbp), %eax
cmpl -0x34(%rbp), %eax
jbe 0x37b1ea
movl -0xe8(%rbp), %eax
cvtsi2sd %rax, %xmm0
movl -0x50(%rbp), %eax
cvtsi2sd %rax, %xmm1
mulsd -0x30(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x37b1ea
jmp 0x37b50c
jmp 0x37b1ec
cmpl $0x1, -0x78(%rbp)
ja 0x37b1fd
cmpl $0x1, -0x7c(%rbp)
ja 0x37b1fd
jmp 0x37b50c
cmpl $0x0, -0x54(%rbp)
jne 0x37b208
jmp 0x37b50c
movl $0x0, -0x84(%rbp)
movl $0xffffffff, -0xf4(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0xf0(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x8c(%rbp)
cmpl $0x1, -0x78(%rbp)
jbe 0x37b24b
cmpl $0x1, -0x7c(%rbp)
jbe 0x37b24b
movl $0x1, -0x84(%rbp)
jmp 0x37b2d9
cmpl $0x1, -0x7c(%rbp)
jne 0x37b290
movq -0x40(%rbp), %rdi
movl -0x5c(%rbp), %esi
xorl $0x1, %esi
movl -0x14(%rbp), %edx
xorl %eax, %eax
movl %eax, %ecx
callq 0x37a480
movl %eax, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jae 0x37b28e
movl $0x1, -0x84(%rbp)
movl -0x5c(%rbp), %eax
xorl $0x1, %eax
movl %eax, -0xf4(%rbp)
jmp 0x37b2d7
cmpl $0x1, -0x78(%rbp)
jne 0x37b2d5
movq -0x40(%rbp), %rdi
movl -0x58(%rbp), %esi
xorl $0x1, %esi
movl -0x14(%rbp), %edx
xorl %eax, %eax
movl %eax, %ecx
callq 0x37a480
movl %eax, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jae 0x37b2d3
movl $0x1, -0x84(%rbp)
movl -0x58(%rbp), %eax
xorl $0x1, %eax
movl %eax, -0xf0(%rbp)
jmp 0x37b2d5
jmp 0x37b2d7
jmp 0x37b2d9
cmpl $0x0, -0x84(%rbp)
je 0x37b50a
movq -0xb0(%rbp), %rax
movq (%rax), %rax
movl %eax, -0x88(%rbp)
cmpl $-0x1, -0xf0(%rbp)
je 0x37b318
movq -0x40(%rbp), %rdi
movl -0xf0(%rbp), %esi
movl -0x14(%rbp), %edx
movq -0xb0(%rbp), %rcx
callq 0x37a480
cmpl $-0x1, -0xf4(%rbp)
je 0x37b33a
movq -0x40(%rbp), %rdi
movl -0xf4(%rbp), %esi
movl -0x14(%rbp), %edx
movq -0xb0(%rbp), %rcx
callq 0x37a480
movl -0x88(%rbp), %eax
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
movq -0xb0(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x37b455
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
movq -0xb0(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x6c(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xd8(%rbp)
movq -0xd8(%rbp), %rax
cmpl $0x0, 0xc(%rax)
jne 0x37b393
jmp 0x37b447
movl $0x0, -0x74(%rbp)
movl -0x74(%rbp), %eax
movq -0xd8(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0x37b3d9
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0xd8(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x74(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x21, %rax
movl %eax, %esi
callq 0x312c50
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x37b39a
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0xb0(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x6c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq %rax
movl %eax, %esi
callq 0x312c50
movq -0xd8(%rbp), %rax
cmpl $0x0, 0xc(%rax)
je 0x37b445
movq -0xd8(%rbp), %rax
movl $0x0, 0x10(%rax)
movq -0xd8(%rbp), %rax
movl $0x0, 0xc(%rax)
movq -0xd8(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x2210
movq -0xd8(%rbp), %rax
movq $0x0, 0x18(%rax)
jmp 0x37b447
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x37b343
movl -0x88(%rbp), %eax
movl %eax, %ecx
movq -0xb0(%rbp), %rax
movq %rcx, (%rax)
movq -0xd0(%rbp), %rax
movl 0xc(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl $0x80000000, %ecx       # imm = 0x80000000
movl %ecx, 0xc(%rax)
movq -0xc8(%rbp), %rax
movl 0xc(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl $0x80000000, %ecx       # imm = 0x80000000
movl %ecx, 0xc(%rax)
movl -0xec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xec(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x40(%rbp), %rsi
movq -0xc8(%rbp), %rax
movq (%rax), %rax
shrq $0x20, %rax
movl %eax, %edx
movq -0xc8(%rbp), %rax
movl 0x8(%rax), %ecx
movl $0x1, %r8d
callq 0x37de20
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x40(%rbp), %rsi
movq -0xd0(%rbp), %rax
movq (%rax), %rax
shrq $0x20, %rax
movl %eax, %edx
movq -0xd0(%rbp), %rax
movl 0x8(%rax), %ecx
movl $0x1, %r8d
callq 0x37de20
jmp 0x37b50c
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x37aa73
cmpq $0x0, -0x10(%rbp)
jne 0x37b52d
movq -0x98(%rbp), %rdi
callq 0x2210
cmpl $0x0, -0xec(%rbp)
jbe 0x37b54c
movq -0x48(%rbp), %rdi
callq 0xcdd10
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0xcdd10
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nopw %cs:(%rax,%rax)