// File: /workspace/github_cpp_makefile_star2_O3/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 $0xd8, %rsp
movq %r9, 0x58(%rsp)
movq %r8, 0x68(%rsp)
movq %rcx, %rbx
movl %edx, 0x1c(%rsp)
movq %rdi, 0x28(%rsp)
movq 0x18(%rdi), %r9
movq 0x20(%r9), %rdx
movl %esi, %ecx
shrl %ecx
xorl %eax, %eax
movq %rcx, 0xb8(%rsp)
cmpl $0x0, (%rdx,%rcx,8)
js 0x15843c
movl %esi, %ebp
movq 0x28(%r9), %rcx
movl %esi, %r10d
movq (%rcx,%r10,8), %rcx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
andq %rcx, %rdx
je 0x15843c
movq 0x8(%r9), %rsi
shrq $0x20, %rcx
leaq (%rcx,%rcx,2), %rcx
leaq (%rsi,%rcx,8), %rcx
addq $0xc, %rcx
shlq $0x3, %rdx
leaq (%rdx,%rdx,2), %rdx
xorl %esi, %esi
xorl %edi, %edi
movl (%rcx,%rsi), %r8d
notl %r8d
shrl $0x1f, %r8d
addl %r8d, %edi
addq $0x18, %rsi
cmpq %rsi, %rdx
jne 0x157c02
xorl %eax, %eax
cmpl $0x2, %edi
jl 0x15843c
xorl %ecx, %ecx
movq %rcx, 0x50(%rbx)
movq %rcx, 0x38(%rbx)
movq %rcx, 0x20(%rbx)
movq %rcx, 0x8(%rbx)
movq (%rbx), %rdx
imulq $0x38, %r10, %rax
movl $0x0, 0x8(%rdx,%rax)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x10(%rdx,%rax)
movupd %xmm0, 0x20(%rdx,%rax)
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movq %rsi, (%rdx,%rax)
cmpq %rcx, 0x10(%rbx)
movq %r9, 0x20(%rsp)
je 0x157c71
movq 0x18(%rbx), %rax
xorl %ecx, %ecx
jmp 0x157c94
movq $0x2, 0x10(%rbx)
movq 0x18(%rbx), %rdi
movl $0x8, %esi
callq 0x2370
movq 0x20(%rsp), %r9
movq %rax, 0x18(%rbx)
movq 0x8(%rbx), %rcx
movl %ebp, (%rax,%rcx,4)
incq %rcx
shrl 0x1c(%rsp)
movl $0xffffffff, 0x4(%rsp)  # imm = 0xFFFFFFFF
movl $0x0, 0x8(%rsp)
movl %ebp, 0x4c(%rsp)
movq (%rbx), %rax
movq 0x18(%rbx), %rdx
leaq -0x1(%rcx), %rsi
movq %rsi, 0x8(%rbx)
movl -0x4(%rdx,%rcx,4), %esi
movq 0x28(%r9), %rcx
movq (%rcx,%rsi,8), %r12
testl %r12d, %r12d
je 0x158388
imulq $0x38, %rsi, %rcx
movl 0x4(%rax,%rcx), %edx
movq %rdx, 0x70(%rsp)
movl 0x8(%rax,%rcx), %edx
movl %edx, 0x18(%rsp)
movl 0x28(%rax,%rcx), %edx
movl %edx, 0x14(%rsp)
movl 0x2c(%rax,%rcx), %edx
movl %edx, 0x10(%rsp)
movsd 0x10(%rax,%rcx), %xmm0
movsd %xmm0, 0x60(%rsp)
movupd 0x18(%rax,%rcx), %xmm0
movq %r12, %rax
shrq $0x20, %rax
leaq (%rax,%rax,2), %r13
shlq $0x3, %r13
addq 0x8(%r9), %r13
movapd %xmm0, 0x90(%rsp)
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
movapd %xmm0, 0xc0(%rsp)
xorl %r14d, %r14d
movl $0x0, 0xc(%rsp)
movq %rsi, 0x38(%rsp)
movq %r12, 0x88(%rsp)
movq %r13, 0x30(%rsp)
movl %r14d, %eax
leaq (%rax,%rax,2), %rax
movl 0x8(%r13,%rax,8), %edi
movl %edi, %r15d
shrl %r15d
cmpl 0xb8(%rsp), %r15d
je 0x1583ef
leaq (,%rax,8), %rcx
addq %r13, %rcx
cmpl $0x0, 0xc(%rcx)
js 0x158355
movl (%r13,%rax,8), %r13d
imulq $0x38, %rdi, %r12
addq (%rbx), %r12
movq 0x50(%rbx), %rcx
movq 0x60(%rbx), %rax
cmpq 0x58(%rbx), %rcx
movq %rdi, 0x40(%rsp)
jne 0x157dde
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x58(%rbx)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq 0x40(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq 0x20(%rsp), %r9
movq %rax, 0x60(%rbx)
movq 0x50(%rbx), %rcx
movq 0x28(%r9), %rdx
movl 0x4(%rdx,%rsi,8), %edx
addl %r14d, %edx
leaq 0x1(%rcx), %r8
movq %r8, 0x50(%rbx)
movl %edx, (%rax,%rcx,4)
cmpl $0x0, 0x30(%r12)
js 0x157ec8
movq 0x38(%rbx), %rcx
movq 0x48(%rbx), %rax
cmpq 0x40(%rbx), %rcx
jne 0x157e45
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x40(%rbx)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq 0x40(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq 0x20(%rsp), %r9
movq %rax, 0x48(%rbx)
movq 0x38(%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x38(%rbx)
movl %edi, (%rax,%rcx,4)
movl %esi, (%r12)
orb $-0x80, 0x33(%r12)
addl 0x70(%rsp), %r13d
movl %r13d, 0x4(%r12)
movq %rdi, %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 0x157f0b
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
movq 0x30(%rsp), %r13
movl (%rcx,%r8), %r10d
notl %r10d
shrl $0x1f, %r10d
addl %r10d, %eax
addq $0x18, %r8
cmpq %r8, %rdx
jne 0x157eaa
orl $0x80000000, %eax       # imm = 0x80000000
jmp 0x157f15
cmpl 0x1c(%rsp), %r15d
jne 0x158008
movapd 0x90(%rsp), %xmm0
movsd %xmm0, 0x80(%rsp)
movaps 0xc0(%rsp), %xmm1
movsd %xmm1, 0x78(%rsp)
movsd 0x60(%rsp), %xmm6
movl 0x10(%rsp), %ecx
movl 0x14(%rsp), %eax
movl 0x18(%rsp), %r8d
jmp 0x1580fa
movl $0x80000000, %eax       # imm = 0x80000000
movq 0x30(%rsp), %r13
movl %eax, 0x30(%r12)
cmpl 0x1c(%rsp), %r15d
je 0x157fff
movq 0x28(%rsp), %rax
movq 0x10(%rax), %rax
leaq (%r15,%r15,4), %rcx
movq %rcx, 0x50(%rsp)
movl 0x10(%rax,%rcx,8), %eax
addl 0x18(%rsp), %eax
movl %eax, 0x8(%r12)
movl %ebp, %edx
movq %rbx, %rcx
movq 0x68(%rsp), %rbp
movq %rbp, %r8
callq 0x157951
addsd 0x60(%rsp), %xmm0
movsd %xmm0, 0x10(%r12)
leaq 0x18(%r12), %rdx
leaq 0x20(%r12), %rcx
movq 0x58(%rsp), %r13
movq (%r13), %r8
movl %r15d, %edi
movq %rbp, %rsi
callq 0x1579ee
movupd 0x18(%r12), %xmm0
addpd 0x90(%rsp), %xmm0
movupd %xmm0, 0x18(%r12)
movq (%r13), %rcx
xorl %eax, %eax
cmpb $0x0, (%rcx,%r15)
movl $0x0, %edx
jne 0x157fbc
movq 0x28(%rsp), %rdx
movq 0x10(%rdx), %rdx
movq 0x50(%rsp), %rsi
movl 0x10(%rdx,%rsi,8), %edx
addl 0x10(%rsp), %edx
movl %edx, 0x2c(%r12)
cmpb $0x0, (%rcx,%r15)
je 0x157fde
movq 0x28(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x50(%rsp), %rcx
movl 0x10(%rax,%rcx,8), %eax
addl 0x14(%rsp), %eax
movl %eax, 0x28(%r12)
movl 0x4c(%rsp), %ebp
movq 0x20(%rsp), %r9
movq 0x38(%rsp), %rsi
movq 0x30(%rsp), %r13
movq 0x40(%rsp), %rdi
incl 0x8(%rsp)
jmp 0x158259
movq 0x28(%rsp), %rax
movq 0x10(%rax), %rax
leaq (,%r15,8), %rcx
leaq (%rcx,%rcx,4), %rcx
movq %rcx, 0xb0(%rsp)
movq %r13, 0x50(%rsp)
movl 0x10(%rax,%rcx), %r13d
addl 0x18(%rsp), %r13d
movl %ebp, %edx
movq %rbx, %rcx
movq 0x68(%rsp), %rbp
movq %rbp, %r8
callq 0x157951
addsd 0x60(%rsp), %xmm0
movsd %xmm0, 0xa8(%rsp)
movq 0x58(%rsp), %rax
movq (%rax), %r8
movl %r15d, %edi
movq %rbp, %rsi
movl 0x4c(%rsp), %ebp
leaq 0x80(%rsp), %rdx
leaq 0x78(%rsp), %rcx
callq 0x1579ee
movsd 0xa8(%rsp), %xmm6
movl %r13d, %r8d
movq 0x50(%rsp), %r13
movq 0x40(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq 0x20(%rsp), %r9
movsd 0x80(%rsp), %xmm0
movhpd 0x78(%rsp), %xmm0       # xmm0 = xmm0[0],mem[0]
addpd 0x90(%rsp), %xmm0
movlpd %xmm0, 0x80(%rsp)
movhpd %xmm0, 0x78(%rsp)
movq 0x58(%rsp), %rax
movq (%rax), %rax
cmpb $0x0, (%rax,%r15)
movq 0x28(%rsp), %rax
movq 0x10(%rax), %rax
movq 0xb0(%rsp), %rcx
movl 0x10(%rax,%rcx), %eax
movl $0x0, %ecx
cmovel %eax, %ecx
movl $0x0, %edx
cmovel %edx, %eax
addl 0x10(%rsp), %ecx
addl 0x14(%rsp), %eax
movd 0x28(%r12), %xmm1
movd %eax, %xmm2
punpckldq %xmm1, %xmm2    # xmm2 = xmm2[0],xmm1[0],xmm2[1],xmm1[1]
movd 0x2c(%r12), %xmm1
movd %ecx, %xmm3
punpckldq %xmm1, %xmm3    # xmm3 = xmm3[0],xmm1[0],xmm3[1],xmm1[1]
paddd %xmm3, %xmm2
pshufd $0x50, %xmm2, %xmm1     # xmm1 = xmm2[0,0,1,1]
pxor %xmm4, %xmm4
pcmpeqd %xmm4, %xmm1
punpckldq %xmm4, %xmm3    # xmm3 = xmm3[0],xmm4[0],xmm3[1],xmm4[1]
movdqa 0xddb4b(%rip), %xmm5    # 0x235c80
por %xmm5, %xmm3
subpd %xmm5, %xmm3
punpckldq %xmm4, %xmm2    # xmm2 = xmm2[0],xmm4[0],xmm2[1],xmm4[1]
por %xmm5, %xmm2
subpd %xmm5, %xmm2
divpd %xmm2, %xmm3
movdqa %xmm1, %xmm2
pandn %xmm3, %xmm2
pand 0xe3093(%rip), %xmm1    # 0x23b1f0
por %xmm2, %xmm1
pshufd $0xee, %xmm1, %xmm2     # xmm2 = xmm1[2,3,2,3]
ucomisd %xmm2, %xmm1
ja 0x158222
ucomisd %xmm2, %xmm1
jne 0x158243
jp 0x158243
movapd %xmm0, %xmm2
unpckhpd %xmm0, %xmm2            # xmm2 = xmm2[1],xmm0[1]
movapd %xmm0, %xmm1
cmplesd %xmm2, %xmm1
movapd %xmm1, %xmm3
andpd %xmm0, %xmm3
andnpd %xmm2, %xmm1
orpd %xmm3, %xmm1
addsd %xmm6, %xmm1
movapd %xmm2, %xmm3
cmplesd %xmm0, %xmm3
movapd %xmm3, %xmm4
andpd %xmm0, %xmm4
andnpd %xmm2, %xmm3
orpd %xmm4, %xmm3
subsd %xmm3, %xmm1
movsd 0x18(%r12), %xmm3
movsd 0x20(%r12), %xmm4
movapd %xmm3, %xmm2
cmplesd %xmm4, %xmm2
movapd %xmm2, %xmm5
andpd %xmm3, %xmm5
andnpd %xmm4, %xmm2
orpd %xmm5, %xmm2
addsd 0x10(%r12), %xmm2
movapd %xmm4, %xmm5
cmplesd %xmm3, %xmm5
andpd %xmm5, %xmm3
andnpd %xmm4, %xmm5
orpd %xmm3, %xmm5
subsd %xmm5, %xmm2
ucomisd %xmm1, %xmm2
ja 0x158222
ucomisd %xmm2, %xmm1
jne 0x158243
jp 0x158243
cmpl 0x8(%r12), %r8d
jbe 0x158363
movl %esi, (%r12)
movl %r8d, 0x8(%r12)
movsd %xmm6, 0x10(%r12)
movl %ecx, 0x2c(%r12)
movl %eax, 0x28(%r12)
movupd %xmm0, 0x18(%r12)
addl 0x70(%rsp), %r13d
cmpl 0x4(%r12), %r13d
jae 0x158254
movl %r13d, 0x4(%r12)
movq 0x30(%rsp), %r13
movl 0x30(%r12), %eax
leal -0x1(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andl $0x80000000, %eax       # imm = 0x80000000
orl %ecx, %eax
movl %eax, 0x30(%r12)
testl %ecx, %ecx
je 0x158284
movq 0x88(%rsp), %r12
jmp 0x158355
movq 0x28(%r9), %rax
movq (%rax,%rdi,8), %rax
movq %rax, %rcx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
andq %rdx, %rcx
movq 0x88(%rsp), %r12
je 0x15833a
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), %r10d
notl %r10d
shrl $0x1f, %r10d
addl %r10d, %r8d
addq $0x18, %rdx
cmpq %rdx, %rcx
jne 0x1582c6
testl %r8d, %r8d
je 0x15833a
movq 0x8(%rbx), %rcx
movq 0x18(%rbx), %rax
cmpq 0x10(%rbx), %rcx
jne 0x158327
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x10(%rbx)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq 0x40(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq 0x20(%rsp), %r9
movq %rax, 0x18(%rbx)
movq 0x8(%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rbx)
movl %edi, (%rax,%rcx,4)
movl 0x4(%rsp), %eax
movl %eax, %edi
jmp 0x15834d
cmpl $0x0, 0xc(%rsp)
movl $0x1, 0xc(%rsp)
jne 0x1583ef
decl 0x8(%rsp)
movl %edi, 0x4(%rsp)
incl %r14d
cmpl %r12d, %r14d
jne 0x157d53
jmp 0x158381
jne 0x158243
movq 0x70(%rsp), %rdx
addl %r13d, %edx
cmpl 0x4(%r12), %edx
ja 0x158222
jmp 0x158243
cmpl $0x1, 0xc(%rsp)
je 0x1583c1
movq 0x8(%rbx), %rcx
testq %rcx, %rcx
je 0x1583ef
cmpq $0x1, %rcx
jne 0x157cb2
cmpl $0x0, 0x8(%rsp)
jne 0x157cb2
movq %rbx, %rdi
movl %ebp, %esi
movq 0x68(%rsp), %rdx
movq 0x58(%rsp), %rcx
callq 0x157a67
movl $0x1, %eax
jmp 0x1583f1
movl 0x4(%rsp), %esi
cmpl $-0x1, %esi
je 0x1583ef
cmpl $0x0, 0x8(%rsp)
movl $0x0, %eax
jne 0x1583f1
cmpq $0x0, 0x8(%rbx)
jne 0x1583f1
cmpq $0x0, 0x10(%rbx)
movq 0x18(%rbx), %rax
je 0x15844e
xorl %ecx, %ecx
jmp 0x15846f
xorl %eax, %eax
cmpq $0x0, 0x38(%rbx)
je 0x15843c
movl $0x1, %r8d
xorl %ecx, %ecx
xorpd %xmm0, %xmm0
xorl %edx, %edx
movq (%rbx), %rsi
movq 0x48(%rbx), %rdi
movl (%rdi,%rdx,4), %edx
imulq $0x38, %rdx, %rdi
movl %ecx, 0x8(%rsi,%rdi)
movq $0x0, (%rsi,%rdi)
movl %r8d, %edx
movupd %xmm0, 0x10(%rsi,%rdi)
movupd %xmm0, 0x20(%rsi,%rdi)
movl %ecx, 0x30(%rsi,%rdi)
incl %r8d
cmpq %rdx, 0x38(%rbx)
ja 0x158406
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq $0x2, 0x10(%rbx)
movl $0x8, %esi
movq %rax, %rdi
callq 0x2370
movl 0x4(%rsp), %esi
movq %rax, 0x18(%rbx)
movq 0x8(%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rbx)
movl %esi, (%rax,%rcx,4)
jmp 0x1583a6