// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/hic.cpp
// Function: bub_phase(ma_ug_t*, unsigned int, unsigned int, bub_p_t_warp*, kv_u_trans_t*, ps_t*)
uint32_t bub_phase(ma_ug_t *ug, uint32_t beg, uint32_t end, bub_p_t_warp *b, kv_u_trans_t *ta, ps_t *s)
{
    asg_t *g = ug->g;
    if(g->seq[beg>>1].del) return 0; // already deleted
    if(get_real_length(g, beg, NULL)<2) return 0;
    uint32_t i, is_end, n_pending, to_replace, cur_nc, cur_uc, cur_ac, n_tips, tip_end, n_pop;
    double cur_nh, cur_w0, cur_w1, cur_rate, max_rate, cur_weight, min_weight;
    ///S saves nodes with all incoming edges visited
    b->S.n = b->T.n = b->b.n = b->e.n = 0;
    ///for each node, b->a saves all related information
    b->a[beg].d = b->a[beg].nc = b->a[beg].ac = b->a[beg].uc = 0; 
    b->a[beg].nh = b->a[beg].w[0] = b->a[beg].w[1] = 0;
    b->a[beg].p = (uint32_t)-1;
    ///b->S is the nodes with all incoming edges visited
    kv_push(uint32_t, b->S, beg);
    n_pop = n_tips = n_pending = 0;
    tip_end = (uint32_t)-1;

    do {
        ///v is a node that all incoming edges have been visited
        ///d is the distance from v0 to v
        uint32_t v = kv_pop(b->S);
        uint32_t d = b->a[v].d, nc = b->a[v].nc, uc = b->a[v].uc, ac = b->a[v].ac; 
        double nh = b->a[v].nh;///path weight
        double nw_0 = b->a[v].w[0], nw_1 = b->a[v].w[1];///weight to haplotype 1/2

        uint32_t nv = asg_arc_n(g, v);
        asg_arc_t *av = asg_arc_a(g, v);
        for (i = 0; i < nv; ++i) {
            uint32_t w = av[i].v, l = (uint32_t)av[i].ul; // v->w with length l, not overlap length
            bub_p_t *t = &b->a[w];
            is_end = 0;
            if((w>>1) == (end>>1)) is_end = 1;
            //got a circle
            if ((w>>1) == (beg>>1)) goto pop_reset;
            if (av[i].del) continue;
            ///push the edge
            kv_push(uint32_t, b->e, (g->idx[v]>>32) + i);

            if (t->s == 0) 
            { // this vertex has never been visited
                kv_push(uint32_t, b->b, w); // save it for revert
                ///t->p is the parent node of 
                ///t->s = 1 means w has been visited
                ///d is len(v0->v), l is len(v->w), so t->d is len(v0->w)
                t->p = v, t->s = 1, t->d = d + l; 
                t->r = get_real_length(g, w^1, NULL);

                if(is_end == 0)
                {
                    t->nc = nc + ug->u.a[(w>>1)].n;
                    t->nh = nh + get_path_phasing_weight(w, v, beg, b, ta);
                    get_related_phasing_weight(w>>1, ta, &(t->w[0]), &(t->w[1]), s->s);
                    t->w[0] += nw_0; t->w[1] += nw_1; 
                    t->ac = ac + ((s->s[w>>1] == 0)? ug->u.a[(w>>1)].n : 0);
                    t->uc = uc + ((s->s[w>>1] != 0)? ug->u.a[(w>>1)].n : 0);
                }

                ++n_pending;
            }
            else {
                to_replace = 0;

                if(is_end)
                {
                    cur_nc = nc; cur_nh = nh; 
                    cur_w0 = nw_0; cur_w1= nw_1;
                    cur_ac = ac; cur_uc = uc;
                }
                else
                {
                    cur_nc = nc + ug->u.a[(w>>1)].n;
                    cur_nh = nh + get_path_phasing_weight(w, v, beg, b, ta);
                    get_related_phasing_weight(w>>1, ta, &cur_w0, &cur_w1, s->s);
                    cur_w0 += nw_0; cur_w1 += nw_1;
                    cur_ac = ac + ((s->s[w>>1] == 0)? ug->u.a[(w>>1)].n : 0);
                    cur_uc = uc + ((s->s[w>>1] != 0)? ug->u.a[(w>>1)].n : 0);
                }
                
                cur_weight = cur_nh + MIN(cur_w0, cur_w1) - MAX(cur_w0, cur_w1);
                min_weight = t->nh + MIN(t->w[0], t->w[1]) - MAX(t->w[0], t->w[1]);
                cur_rate = ((cur_ac+cur_uc == 0)? -1 : ((double)(cur_ac)/(double)(cur_ac+cur_uc)));
                max_rate = ((t->ac+t->uc == 0)? -1 : ((double)(t->ac)/(double)(t->ac+t->uc)));

                if(cur_rate > max_rate)
                {
                    to_replace = 1;
                }
                else if(cur_rate == max_rate)
                {
                    if(cur_weight < min_weight)
                    {
                        to_replace = 1;
                    }
                    else if(cur_weight == min_weight)
                    {
                        if(cur_nc > t->nc)
                        {
                            to_replace = 1;
                        }
                        else if(cur_nc == t->nc)
                        {
                            if(d + l > t->d)
                            {
                                to_replace = 1;
                            }
                        }
                    }
                }


                if(to_replace)
                {
                    t->p = v;
                    t->nc = cur_nc;
                    t->nh = cur_nh;
                    t->ac = cur_ac;
                    t->uc = cur_uc;
                    t->w[0] = cur_w0;
                    t->w[1] = cur_w1;
                }


                if (d + l < t->d) t->d = d + l; // update dist
            }

            if (--(t->r) == 0) {
                uint32_t x = get_real_length(g, w, NULL);
                if(x > 0)
                {
                    kv_push(uint32_t, b->S, w);
                }
                else
                {
                    ///at most one tip
                    if(n_tips != 0) goto pop_reset;
                    n_tips++;
                    tip_end = w;
                }
                --n_pending;
            }
        }

        if(n_tips == 1)
        {
            if(tip_end != (uint32_t)-1 && n_pending == 0 && b->S.n == 0)
            {
                ///sink is b.S.a[0]
                kv_push(uint32_t, b->S, tip_end);
                break;
            }
            else
            {
                goto pop_reset;
            }
        }

        if (i < nv || b->S.n == 0) goto pop_reset;
    }while (b->S.n > 1 || n_pending);

    n_pop = 1;
    /**need fix**/
    set_phase_path(b, beg, ta, s);

    pop_reset:

    for (i = 0; i < b->b.n; ++i) { // clear the states of visited vertices
        bub_p_t *t = &b->a[b->b.a[i]];
        t->p = t->d = t->nc = t->ac = t->uc = t->r = t->s = 0;
        t->nh = t->w[0] = t->w[1] = 0;
    }
    return n_pop;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %r9, 0x68(%rsp)
movq %r8, 0x60(%rsp)
movq %rcx, %rbx
movl %edx, 0x2c(%rsp)
movq %rdi, 0x30(%rsp)
movq 0x18(%rdi), %r9
movq 0x20(%r9), %rcx
movl %esi, %r12d
shrl %r12d
xorl %eax, %eax
cmpl $0x0, (%rcx,%r12,8)
js 0x151cef
movl %esi, %ebp
movq 0x28(%r9), %rdx
movl %esi, %ecx
movq (%rdx,%rcx,8), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
andq %rsi, %rdx
je 0x151cef
movq 0x8(%r9), %rax
shrq $0x20, %rsi
leaq (%rsi,%rsi,2), %rsi
leaq (%rax,%rsi,8), %rax
addq $0xc, %rax
shlq $0x3, %rdx
leaq (%rdx,%rdx,2), %rdx
xorl %esi, %esi
xorl %edi, %edi
movl (%rax,%rsi), %r8d
notl %r8d
shrl $0x1f, %r8d
addl %r8d, %edi
addq $0x18, %rsi
cmpq %rsi, %rdx
jne 0x15142c
xorl %eax, %eax
cmpl $0x2, %edi
jl 0x151cef
xorl %esi, %esi
movq %rsi, 0x50(%rbx)
movq %rsi, 0x38(%rbx)
movq %rsi, 0x20(%rbx)
movq %rsi, 0x8(%rbx)
movq (%rbx), %rax
imulq $0x38, %rcx, %rcx
movl $0x0, 0x8(%rax,%rcx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x10(%rax,%rcx)
movupd %xmm0, 0x20(%rax,%rcx)
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rdx, (%rax,%rcx)
movq $0x0, 0x8(%rsp)
cmpq %rsi, 0x10(%rbx)
movq %r9, 0x10(%rsp)
jne 0x1514bb
movq $0x2, 0x10(%rbx)
movq 0x18(%rbx), %rdi
movl $0x8, %esi
callq 0x2370
movq 0x10(%rsp), %r9
movq %rax, 0x18(%rbx)
movq 0x8(%rbx), %rax
movq 0x18(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x8(%rbx)
movl %ebp, 0x1c(%rsp)
movl %ebp, (%rcx,%rax,4)
shrl 0x2c(%rsp)
movl $0xffffffff, 0x4(%rsp)  # imm = 0xFFFFFFFF
movl $0x0, (%rsp)
movq %rbx, 0x98(%rsp)
movq %r12, 0xa0(%rsp)
movq 0x18(%rbx), %rax
movq (%rbx), %rcx
movq 0x8(%rbx), %rdx
leaq -0x1(%rdx), %rsi
movq %rsi, 0x8(%rbx)
movl -0x4(%rax,%rdx,4), %esi
movq 0x28(%r9), %rax
movq (%rax,%rsi,8), %rax
testl %eax, %eax
je 0x151bcb
imulq $0x38, %rsi, %rdx
movl 0x4(%rcx,%rdx), %edi
movq %rdi, 0x88(%rsp)
movl 0x8(%rcx,%rdx), %edi
movl %edi, 0x28(%rsp)
movl 0x28(%rcx,%rdx), %edi
movl %edi, 0x24(%rsp)
movl 0x2c(%rcx,%rdx), %edi
movl %edi, 0x20(%rsp)
movsd 0x10(%rcx,%rdx), %xmm0
movsd %xmm0, 0x80(%rsp)
movsd 0x18(%rcx,%rdx), %xmm0
movsd %xmm0, 0x78(%rsp)
movsd 0x20(%rcx,%rdx), %xmm0
movsd %xmm0, 0x70(%rsp)
movq %rax, %rcx
shrq $0x20, %rcx
leaq (%rcx,%rcx,2), %r10
shlq $0x3, %r10
addq 0x8(%r9), %r10
movl %eax, %r13d
xorl %ebp, %ebp
movq %rsi, 0x40(%rsp)
movq %r10, 0x38(%rsp)
movq %r13, 0xa8(%rsp)
leaq (,%rbp,2), %rax
addq %rbp, %rax
movl 0x8(%r10,%rax,8), %r15d
movl %r15d, %r14d
shrl %r14d
cmpl %r12d, %r14d
jne 0x1515bb
movl $0x9, %r14d
jmp 0x151b93
leaq (%r10,%rax,8), %rcx
cmpl $0x0, 0xc(%rcx)
js 0x1516fd
imulq $0x38, %r15, %r13
addq (%rbx), %r13
movl (%r10,%rax,8), %r12d
movq 0x58(%rbx), %rax
cmpq %rax, 0x50(%rbx)
jne 0x151612
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x58(%rbx)
movq 0x60(%rbx), %rdi
shlq $0x2, %rsi
callq 0x2370
movq 0x38(%rsp), %r10
movq 0x40(%rsp), %rsi
movq 0x10(%rsp), %r9
movq %rax, 0x60(%rbx)
movq 0x28(%r9), %rax
movl 0x4(%rax,%rsi,8), %eax
addl %ebp, %eax
movq 0x50(%rbx), %rcx
movq 0x60(%rbx), %rdx
leaq 0x1(%rcx), %rdi
movq %rdi, 0x50(%rbx)
movl %eax, (%rdx,%rcx,4)
cmpl $0x0, 0x30(%r13)
js 0x151708
movq 0x40(%rbx), %rax
cmpq %rax, 0x38(%rbx)
jne 0x151678
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x40(%rbx)
movq 0x48(%rbx), %rdi
shlq $0x2, %rsi
callq 0x2370
movq 0x38(%rsp), %r10
movq 0x40(%rsp), %rsi
movq 0x10(%rsp), %r9
movq %rax, 0x48(%rbx)
movq 0x38(%rbx), %rax
movq 0x48(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x38(%rbx)
movl %r15d, (%rcx,%rax,4)
movl %esi, (%r13)
orb $-0x80, 0x33(%r13)
addl 0x88(%rsp), %r12d
movl %r12d, 0x4(%r13)
movq %r15, %rax
xorq $0x1, %rax
movq 0x28(%r9), %rcx
movq (%rcx,%rax,8), %rcx
movq %rcx, %rax
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
andq %rdx, %rax
je 0x151747
movq 0x8(%r9), %rdx
shrq $0x20, %rcx
leaq (%rcx,%rcx,2), %rcx
leaq (%rdx,%rcx,8), %rcx
addq $0xc, %rcx
shlq $0x3, %rax
leaq (%rax,%rax,2), %rdx
xorl %r8d, %r8d
xorl %eax, %eax
movl (%rcx,%r8), %edi
notl %edi
shrl $0x1f, %edi
addl %edi, %eax
addq $0x18, %r8
cmpq %r8, %rdx
jne 0x1516e2
orl $0x80000000, %eax       # imm = 0x80000000
jmp 0x15174c
movl $0x8, %r14d
jmp 0x151b93
cmpl 0x2c(%rsp), %r14d
jne 0x15184b
movsd 0x78(%rsp), %xmm0
movsd %xmm0, 0x58(%rsp)
movsd 0x70(%rsp), %xmm0
movsd %xmm0, 0x50(%rsp)
movsd 0x80(%rsp), %xmm8
movl 0x20(%rsp), %ecx
movl 0x24(%rsp), %eax
movl 0x28(%rsp), %r8d
jmp 0x151945
movl $0x80000000, %eax       # imm = 0x80000000
movl %eax, 0x30(%r13)
cmpl 0x2c(%rsp), %r14d
je 0x151843
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rax
leaq (%r14,%r14,4), %rcx
movq %rcx, 0x48(%rsp)
movl 0x10(%rax,%rcx,8), %eax
addl 0x28(%rsp), %eax
movl %eax, 0x8(%r13)
movl %r15d, %edi
movl 0x1c(%rsp), %edx
movq %rbx, %rcx
movq 0x60(%rsp), %rbx
movq %rbx, %r8
callq 0x151173
addsd 0x80(%rsp), %xmm0
movsd %xmm0, 0x10(%r13)
leaq 0x18(%r13), %rdx
leaq 0x20(%r13), %rcx
movq 0x68(%rsp), %r12
movq (%r12), %r8
movl %r14d, %edi
movq %rbx, %rsi
callq 0x151210
movsd 0x18(%r13), %xmm0
addsd 0x78(%rsp), %xmm0
movsd %xmm0, 0x18(%r13)
movsd 0x20(%r13), %xmm0
addsd 0x70(%rsp), %xmm0
movsd %xmm0, 0x20(%r13)
movq (%r12), %rcx
xorl %eax, %eax
cmpb $0x0, (%rcx,%r14)
movl $0x0, %edx
jne 0x151803
movq 0x30(%rsp), %rdx
movq 0x10(%rdx), %rdx
movq 0x48(%rsp), %rsi
movl 0x10(%rdx,%rsi,8), %edx
addl 0x20(%rsp), %edx
movl %edx, 0x2c(%r13)
cmpb $0x0, (%rcx,%r14)
je 0x151824
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x48(%rsp), %rcx
movl 0x10(%rax,%rcx,8), %eax
addl 0x24(%rsp), %eax
movl %eax, 0x28(%r13)
movq 0x98(%rsp), %rbx
movq 0x10(%rsp), %r9
movq 0x40(%rsp), %rsi
movq 0x38(%rsp), %r10
incl (%rsp)
jmp 0x151a74
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rax
leaq (%r14,%r14,4), %rcx
movq %rcx, 0x90(%rsp)
movl 0x10(%rax,%rcx,8), %eax
addl 0x28(%rsp), %eax
movl %eax, 0x48(%rsp)
movl %r15d, %edi
movl 0x1c(%rsp), %edx
movq %rbx, %rcx
movq 0x60(%rsp), %rbx
movq %rbx, %r8
callq 0x151173
movsd %xmm0, 0xb0(%rsp)
movq 0x68(%rsp), %rax
movq (%rax), %r8
movl %r14d, %edi
movq %rbx, %rsi
leaq 0x58(%rsp), %rdx
leaq 0x50(%rsp), %rcx
movq %r8, %rbx
callq 0x151210
movsd 0x58(%rsp), %xmm0
addsd 0x78(%rsp), %xmm0
movsd %xmm0, 0x58(%rsp)
movsd 0x50(%rsp), %xmm0
addsd 0x70(%rsp), %xmm0
movsd %xmm0, 0x50(%rsp)
movb (%rbx,%r14), %dl
xorl %eax, %eax
movl $0x0, %ecx
testb %dl, %dl
jne 0x1518f4
movq 0x30(%rsp), %rcx
movq 0x10(%rcx), %rcx
movq 0x90(%rsp), %rsi
movl 0x10(%rcx,%rsi,8), %ecx
testb %dl, %dl
je 0x15190d
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x90(%rsp), %rdx
movl 0x10(%rax,%rdx,8), %eax
movsd 0xb0(%rsp), %xmm8
addsd 0x80(%rsp), %xmm8
addl 0x20(%rsp), %ecx
addl 0x24(%rsp), %eax
movq 0x98(%rsp), %rbx
movq 0x10(%rsp), %r9
movq 0x40(%rsp), %rsi
movq 0x38(%rsp), %r10
movl 0x48(%rsp), %r8d
movsd 0x58(%rsp), %xmm0
movsd 0x18(%r13), %xmm3
movsd 0x20(%r13), %xmm4
movapd %xmm3, %xmm2
cmplesd %xmm4, %xmm2
movapd %xmm2, %xmm1
andpd %xmm3, %xmm1
andnpd %xmm4, %xmm2
orpd %xmm1, %xmm2
addsd 0x10(%r13), %xmm2
movsd 0x50(%rsp), %xmm1
movl %eax, %edx
movsd 0xd3bb2(%rip), %xmm5    # 0x225538
addl %ecx, %edx
je 0x15199d
movl %ecx, %edi
xorps %xmm5, %xmm5
cvtsi2sd %rdi, %xmm5
cvtsi2sd %rdx, %xmm6
divsd %xmm6, %xmm5
movl 0x2c(%r13), %edx
movl 0x28(%r13), %edi
movsd 0xd3b8b(%rip), %xmm6    # 0x225538
addl %edx, %edi
je 0x1519c2
xorps %xmm6, %xmm6
cvtsi2sd %rdx, %xmm6
cvtsi2sd %rdi, %xmm7
divsd %xmm7, %xmm6
ucomisd %xmm6, %xmm5
ja 0x151a40
jne 0x151a62
jp 0x151a62
movapd %xmm0, %xmm5
cmplesd %xmm1, %xmm5
movapd %xmm5, %xmm6
andpd %xmm0, %xmm6
andnpd %xmm1, %xmm5
orpd %xmm6, %xmm5
addsd %xmm8, %xmm5
movapd %xmm1, %xmm6
cmplesd %xmm0, %xmm6
movapd %xmm6, %xmm7
andpd %xmm0, %xmm7
andnpd %xmm1, %xmm6
orpd %xmm7, %xmm6
subsd %xmm6, %xmm5
movapd %xmm4, %xmm6
cmplesd %xmm3, %xmm6
andpd %xmm6, %xmm3
andnpd %xmm4, %xmm6
orpd %xmm3, %xmm6
subsd %xmm6, %xmm2
ucomisd %xmm5, %xmm2
ja 0x151a40
ucomisd %xmm2, %xmm5
jne 0x151a62
jp 0x151a62
cmpl 0x8(%r13), %r8d
jbe 0x151bab
movl %esi, (%r13)
movl %r8d, 0x8(%r13)
movsd %xmm8, 0x10(%r13)
movl %ecx, 0x2c(%r13)
movl %eax, 0x28(%r13)
movsd %xmm0, 0x18(%r13)
movsd %xmm1, 0x20(%r13)
addl 0x88(%rsp), %r12d
cmpl 0x4(%r13), %r12d
jae 0x151a74
movl %r12d, 0x4(%r13)
movl 0x30(%r13), %eax
leal -0x1(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andl $0x80000000, %eax       # imm = 0x80000000
orl %ecx, %eax
movl %eax, 0x30(%r13)
xorl %r14d, %r14d
testl %ecx, %ecx
je 0x151aa8
movq 0xa0(%rsp), %r12
movq 0xa8(%rsp), %r13
jmp 0x151b93
movq 0x28(%r9), %rax
movq (%rax,%r15,8), %rax
movq %rax, %rcx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
andq %rdx, %rcx
movq 0xa0(%rsp), %r12
movq 0xa8(%rsp), %r13
je 0x151b6b
movq 0x8(%r9), %rdx
shrq $0x20, %rax
leaq (%rax,%rax,2), %rax
leaq (%rdx,%rax,8), %rax
addq $0xc, %rax
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rcx
xorl %edx, %edx
xorl %r8d, %r8d
movl (%rax,%rdx), %edi
notl %edi
shrl $0x1f, %edi
addl %edi, %r8d
addq $0x18, %rdx
cmpq %rdx, %rcx
jne 0x151af2
testl %r8d, %r8d
je 0x151b6b
movq 0x10(%rbx), %rax
cmpq %rax, 0x8(%rbx)
jne 0x151b49
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x10(%rbx)
movq 0x18(%rbx), %rdi
shlq $0x2, %rsi
callq 0x2370
movq 0x38(%rsp), %r10
movq 0x40(%rsp), %rsi
movq 0x10(%rsp), %r9
movq %rax, 0x18(%rbx)
movq 0x8(%rbx), %rax
movq 0x18(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x8(%rbx)
movl %r15d, (%rcx,%rax,4)
movl 0x4(%rsp), %eax
movl %eax, %r15d
movq 0x8(%rsp), %rax
jmp 0x151b86
movl $0x1, %eax
cmpl $0x0, 0x8(%rsp)
je 0x151b86
movl $0x1, %eax
movq %rax, 0x8(%rsp)
jmp 0x1515b0
decl (%rsp)
movl %r15d, 0x4(%rsp)
movq %rax, 0x8(%rsp)
testb $0x7, %r14b
jne 0x151c59
incq %rbp
cmpq %r13, %rbp
jne 0x151595
jmp 0x151bcb
jne 0x151a62
movq 0x88(%rsp), %rdx
addl %r12d, %edx
cmpl 0x4(%r13), %edx
ja 0x151a40
jmp 0x151a62
cmpl $0x1, 0x8(%rsp)
jne 0x151c42
movl $0x9, %r14d
movl $0x1, %eax
movq %rax, 0x8(%rsp)
cmpl $-0x1, 0x4(%rsp)
je 0x151c59
cmpl $0x0, (%rsp)
jne 0x151c59
cmpq $0x0, 0x8(%rbx)
jne 0x151c59
cmpq $0x0, 0x10(%rbx)
jne 0x151c1c
movq $0x2, 0x10(%rbx)
movq 0x18(%rbx), %rdi
movl $0x8, %esi
callq 0x2370
movq 0x10(%rsp), %r9
movq %rax, 0x18(%rbx)
movq 0x8(%rbx), %rax
movq 0x18(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x8(%rbx)
movl 0x4(%rsp), %edx
movl %edx, (%rcx,%rax,4)
movl $0x4, %r14d
movl $0x0, (%rsp)
jmp 0x151c59
xorl %eax, %eax
cmpq $0x0, 0x8(%rbx)
sete %al
leal (%rax,%rax,8), %r14d
movq $0x0, 0x8(%rsp)
testl %r14d, %r14d
jne 0x151c75
cmpq $0x1, 0x8(%rbx)
ja 0x1514f5
cmpl $0x0, (%rsp)
jne 0x1514f5
jmp 0x151c85
cmpl $0x4, %r14d
je 0x151c85
cmpl $0x9, %r14d
jne 0x151cef
xorl %eax, %eax
jmp 0x151ca0
movq %rbx, %rdi
movl 0x1c(%rsp), %esi
movq 0x60(%rsp), %rdx
movq 0x68(%rsp), %rcx
callq 0x151289
movl $0x1, %eax
cmpq $0x0, 0x38(%rbx)
je 0x151cef
movl $0x1, %ecx
xorl %edx, %edx
xorpd %xmm0, %xmm0
xorl %esi, %esi
movq (%rbx), %rdi
movq 0x48(%rbx), %r8
movl (%r8,%rsi,4), %esi
imulq $0x38, %rsi, %r8
movl %edx, 0x8(%rdi,%r8)
movq $0x0, (%rdi,%r8)
movl %ecx, %esi
movupd %xmm0, 0x10(%rdi,%r8)
movupd %xmm0, 0x20(%rdi,%r8)
movl %edx, 0x30(%rdi,%r8)
incl %ecx
cmpq %rsi, 0x38(%rbx)
ja 0x151cb4
jmp 0x151cef
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq