// File: 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
movq %rsp, %rbp
subq $0x1b0, %rsp            # imm = 0x1B0
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x14(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x1f6193
movl $0x0, -0x4(%rbp)
jmp 0x1f7160
movq -0x38(%rbp), %rdi
movl -0x14(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x166b50
cmpl $0x2, %eax
jge 0x1f61b4
movl $0x0, -0x4(%rbp)
jmp 0x1f7160
movq -0x20(%rbp), %rax
movq $0x0, 0x50(%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x38(%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movl -0x14(%rbp), %ecx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x28(%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movl -0x14(%rbp), %ecx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x2c(%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movl -0x14(%rbp), %ecx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x8(%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movl -0x14(%rbp), %ecx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x4(%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movl -0x14(%rbp), %ecx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x20(%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movl -0x14(%rbp), %ecx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x18(%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movl -0x14(%rbp), %ecx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x10(%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movl -0x14(%rbp), %ecx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x20(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0x1f6318
movq -0x20(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x1f62d7
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
shlq %rax
movq %rax, -0x100(%rbp)
jmp 0x1f62e5
movl $0x2, %eax
movq %rax, -0x100(%rbp)
jmp 0x1f62e5
movq -0x100(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x18(%rax)
movl -0x14(%rbp), %edx
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x20(%rbp), %rsi
movq 0x8(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x8(%rsi)
movl %edx, (%rax,%rcx,4)
movl $0x0, -0x44(%rbp)
movl $0x0, -0x58(%rbp)
movl $0x0, -0x60(%rbp)
movl $0xffffffff, -0x5c(%rbp) # imm = 0xFFFFFFFF
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x20(%rbp), %rdx
movq 0x8(%rdx), %rcx
movq %rcx, %rsi
addq $-0x1, %rsi
movq %rsi, 0x8(%rdx)
movl -0x4(%rax,%rcx,4), %eax
movl %eax, -0x9c(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movl -0x9c(%rbp), %ecx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0xa0(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movl -0x9c(%rbp), %ecx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0xa4(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movl -0x9c(%rbp), %ecx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl 0x28(%rax), %eax
movl %eax, -0xa8(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movl -0x9c(%rbp), %ecx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl 0x2c(%rax), %eax
movl %eax, -0xac(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movl -0x9c(%rbp), %ecx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0xb8(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movl -0x9c(%rbp), %ecx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movsd 0x18(%rax), %xmm0
movsd %xmm0, -0xc0(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movl -0x9c(%rbp), %ecx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movsd 0x20(%rax), %xmm0
movsd %xmm0, -0xc8(%rbp)
movq -0x38(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x9c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0xcc(%rbp)
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x38(%rbp), %rcx
movq 0x28(%rcx), %rcx
movl -0x9c(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xd8(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0xcc(%rbp), %eax
jae 0x1f6f4a
movq -0xd8(%rbp), %rax
movl -0x3c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0xdc(%rbp)
movq -0xd8(%rbp), %rax
movl -0x3c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl %eax, -0xe0(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movl -0xdc(%rbp), %ecx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xe8(%rbp)
movl $0x0, -0x40(%rbp)
movl -0xdc(%rbp), %eax
shrl %eax
movl -0x18(%rbp), %ecx
shrl %ecx
cmpl %ecx, %eax
jne 0x1f6519
movl $0x1, -0x40(%rbp)
movl -0xdc(%rbp), %eax
shrl %eax
movl -0x14(%rbp), %ecx
shrl %ecx
cmpl %ecx, %eax
jne 0x1f652f
jmp 0x1f7073
movq -0xd8(%rbp), %rax
movl -0x3c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x1f6550
jmp 0x1f6f3c
jmp 0x1f6552
movq -0x20(%rbp), %rax
movq 0x50(%rax), %rax
movq -0x20(%rbp), %rcx
cmpq 0x58(%rcx), %rax
jne 0x1f65c4
movq -0x20(%rbp), %rax
cmpq $0x0, 0x58(%rax)
je 0x1f6583
movq -0x20(%rbp), %rax
movq 0x58(%rax), %rax
shlq %rax
movq %rax, -0x108(%rbp)
jmp 0x1f6591
movl $0x2, %eax
movq %rax, -0x108(%rbp)
jmp 0x1f6591
movq -0x108(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x58(%rax)
movq -0x20(%rbp), %rax
movq 0x60(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x58(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x60(%rax)
movq -0x38(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x9c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movl -0x3c(%rbp), %ecx
addq %rcx, %rax
movl %eax, %edx
movq -0x20(%rbp), %rax
movq 0x60(%rax), %rax
movq -0x20(%rbp), %rsi
movq 0x50(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x50(%rsi)
movl %edx, (%rax,%rcx,4)
movq -0xe8(%rbp), %rax
movl 0x30(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
jne 0x1f68e6
jmp 0x1f6618
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x20(%rbp), %rcx
cmpq 0x40(%rcx), %rax
jne 0x1f668a
movq -0x20(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0x1f6649
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rax
shlq %rax
movq %rax, -0x110(%rbp)
jmp 0x1f6657
movl $0x2, %eax
movq %rax, -0x110(%rbp)
jmp 0x1f6657
movq -0x110(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x48(%rax)
movl -0xdc(%rbp), %edx
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x20(%rbp), %rsi
movq 0x38(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x38(%rsi)
movl %edx, (%rax,%rcx,4)
movl -0x9c(%rbp), %ecx
movq -0xe8(%rbp), %rax
movl %ecx, (%rax)
movq -0xe8(%rbp), %rax
movl 0x30(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl $0x80000000, %ecx       # imm = 0x80000000
movl %ecx, 0x30(%rax)
movl -0xa0(%rbp), %ecx
addl -0xe0(%rbp), %ecx
movq -0xe8(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x38(%rbp), %rdi
movl -0xdc(%rbp), %esi
xorl $0x1, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x166b50
movl %eax, %edx
movq -0xe8(%rbp), %rax
movl 0x30(%rax), %ecx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andl $0x80000000, %ecx       # imm = 0x80000000
orl %edx, %ecx
movl %ecx, 0x30(%rax)
cmpl $0x0, -0x40(%rbp)
jne 0x1f68d8
movl -0xa4(%rbp), %ecx
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0xdc(%rbp), %edx
shrl %edx
movl %edx, %edx
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
addl 0x10(%rax), %ecx
movq -0xe8(%rbp), %rax
movl %ecx, 0x8(%rax)
movsd -0xb8(%rbp), %xmm0
movsd %xmm0, -0x120(%rbp)
movl -0xdc(%rbp), %edi
movl -0x9c(%rbp), %esi
movl -0x14(%rbp), %edx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
callq 0x1f5d40
movaps %xmm0, %xmm1
movsd -0x120(%rbp), %xmm0
addsd %xmm1, %xmm0
movq -0xe8(%rbp), %rax
movsd %xmm0, 0x10(%rax)
movl -0xdc(%rbp), %edi
shrl %edi
movq -0x28(%rbp), %rsi
movq -0xe8(%rbp), %rdx
addq $0x18, %rdx
movq -0xe8(%rbp), %rcx
addq $0x18, %rcx
addq $0x8, %rcx
movq -0x30(%rbp), %rax
movq (%rax), %r8
callq 0x1f5e10
movsd -0xc0(%rbp), %xmm0
movq -0xe8(%rbp), %rax
addsd 0x18(%rax), %xmm0
movsd %xmm0, 0x18(%rax)
movsd -0xc8(%rbp), %xmm0
movq -0xe8(%rbp), %rax
addsd 0x20(%rax), %xmm0
movsd %xmm0, 0x20(%rax)
movl -0xac(%rbp), %eax
movl %eax, -0x114(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl -0xdc(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x1f684a
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0xdc(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, -0x124(%rbp)
jmp 0x1f6854
xorl %eax, %eax
movl %eax, -0x124(%rbp)
jmp 0x1f6854
movl -0x114(%rbp), %ecx
movl -0x124(%rbp), %eax
addl %eax, %ecx
movq -0xe8(%rbp), %rax
movl %ecx, 0x2c(%rax)
movl -0xa8(%rbp), %eax
movl %eax, -0x128(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl -0xdc(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x1f68b6
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0xdc(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, -0x12c(%rbp)
jmp 0x1f68c0
xorl %eax, %eax
movl %eax, -0x12c(%rbp)
jmp 0x1f68c0
movl -0x128(%rbp), %ecx
movl -0x12c(%rbp), %eax
addl %eax, %ecx
movq -0xe8(%rbp), %rax
movl %ecx, 0x28(%rax)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x1f6e26
movl $0x0, -0x48(%rbp)
cmpl $0x0, -0x40(%rbp)
je 0x1f693a
movl -0xa4(%rbp), %eax
movl %eax, -0x4c(%rbp)
movsd -0xb8(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movsd -0xc0(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0xc8(%rbp), %xmm0
movsd %xmm0, -0x78(%rbp)
movl -0xac(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0xa8(%rbp), %eax
movl %eax, -0x50(%rbp)
jmp 0x1f6aad
movl -0xa4(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0xdc(%rbp), %edx
shrl %edx
movl %edx, %edx
imulq $0x28, %rdx, %rdx
addq %rdx, %rcx
addl 0x10(%rcx), %eax
movl %eax, -0x4c(%rbp)
movsd -0xb8(%rbp), %xmm0
movsd %xmm0, -0x138(%rbp)
movl -0xdc(%rbp), %edi
movl -0x9c(%rbp), %esi
movl -0x14(%rbp), %edx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
callq 0x1f5d40
movaps %xmm0, %xmm1
movsd -0x138(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x68(%rbp)
movl -0xdc(%rbp), %edi
shrl %edi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rax
movq (%rax), %r8
leaq -0x70(%rbp), %rdx
leaq -0x78(%rbp), %rcx
callq 0x1f5e10
movsd -0xc0(%rbp), %xmm0
addsd -0x70(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0xc8(%rbp), %xmm0
addsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x78(%rbp)
movl -0xac(%rbp), %eax
movl %eax, -0x130(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl -0xdc(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x1f6a2d
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0xdc(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, -0x13c(%rbp)
jmp 0x1f6a37
xorl %eax, %eax
movl %eax, -0x13c(%rbp)
jmp 0x1f6a37
movl -0x130(%rbp), %eax
movl -0x13c(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x54(%rbp)
movl -0xa8(%rbp), %eax
movl %eax, -0x140(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl -0xdc(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x1f6a92
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0xdc(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, -0x144(%rbp)
jmp 0x1f6a9c
xorl %eax, %eax
movl %eax, -0x144(%rbp)
jmp 0x1f6a9c
movl -0x140(%rbp), %eax
movl -0x144(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x50(%rbp)
movsd -0x68(%rbp), %xmm0
movsd %xmm0, -0x150(%rbp)
movsd -0x70(%rbp), %xmm1
movsd -0x78(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x1f6ad9
movsd -0x70(%rbp), %xmm0
movsd %xmm0, -0x158(%rbp)
jmp 0x1f6ae6
movsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x158(%rbp)
movsd -0x150(%rbp), %xmm0
movsd -0x158(%rbp), %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, -0x160(%rbp)
movsd -0x70(%rbp), %xmm0
ucomisd -0x78(%rbp), %xmm0
jb 0x1f6b1d
movsd -0x70(%rbp), %xmm0
movsd %xmm0, -0x168(%rbp)
jmp 0x1f6b2a
movsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x168(%rbp)
movsd -0x160(%rbp), %xmm0
movsd -0x168(%rbp), %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, -0x90(%rbp)
movq -0xe8(%rbp), %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x170(%rbp)
movq -0xe8(%rbp), %rax
movsd 0x18(%rax), %xmm1
movq -0xe8(%rbp), %rax
movsd 0x20(%rax), %xmm0
ucomisd %xmm1, %xmm0
jb 0x1f6b8e
movq -0xe8(%rbp), %rax
movsd 0x18(%rax), %xmm0
movsd %xmm0, -0x178(%rbp)
jmp 0x1f6ba2
movq -0xe8(%rbp), %rax
movsd 0x20(%rax), %xmm0
movsd %xmm0, -0x178(%rbp)
movsd -0x170(%rbp), %xmm0
movsd -0x178(%rbp), %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, -0x180(%rbp)
movq -0xe8(%rbp), %rax
movsd 0x18(%rax), %xmm0
movq -0xe8(%rbp), %rax
ucomisd 0x20(%rax), %xmm0
jb 0x1f6bee
movq -0xe8(%rbp), %rax
movsd 0x18(%rax), %xmm0
movsd %xmm0, -0x188(%rbp)
jmp 0x1f6c02
movq -0xe8(%rbp), %rax
movsd 0x20(%rax), %xmm0
movsd %xmm0, -0x188(%rbp)
movsd -0x180(%rbp), %xmm0
movsd -0x188(%rbp), %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, -0x98(%rbp)
movl -0x54(%rbp), %eax
addl -0x50(%rbp), %eax
cmpl $0x0, %eax
jne 0x1f6c3b
movsd 0x18b647(%rip), %xmm0   # 0x382278
movsd %xmm0, -0x190(%rbp)
jmp 0x1f6c5d
movl -0x54(%rbp), %eax
movl %eax, %ecx
movl %ecx, %eax
cvtsi2sd %rcx, %xmm0
movl -0x50(%rbp), %ecx
addl %ecx, %eax
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x190(%rbp)
movsd -0x190(%rbp), %xmm0
movsd %xmm0, -0x80(%rbp)
movq -0xe8(%rbp), %rax
movl 0x2c(%rax), %eax
movq -0xe8(%rbp), %rcx
addl 0x28(%rcx), %eax
cmpl $0x0, %eax
jne 0x1f6c95
movsd 0x18b5ed(%rip), %xmm0   # 0x382278
movsd %xmm0, -0x198(%rbp)
jmp 0x1f6cbe
movq -0xe8(%rbp), %rax
movl 0x28(%rax), %ecx
movl 0x2c(%rax), %eax
movl %eax, %edx
movl %edx, %eax
cvtsi2sd %rdx, %xmm0
addl %ecx, %eax
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x198(%rbp)
movsd -0x198(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
movsd -0x80(%rbp), %xmm0
ucomisd -0x88(%rbp), %xmm0
jbe 0x1f6ce9
movl $0x1, -0x48(%rbp)
jmp 0x1f6d87
movsd -0x80(%rbp), %xmm0
ucomisd -0x88(%rbp), %xmm0
jne 0x1f6d85
jp 0x1f6d85
movsd -0x90(%rbp), %xmm1
movsd -0x98(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1f6d21
movl $0x1, -0x48(%rbp)
jmp 0x1f6d83
movsd -0x90(%rbp), %xmm0
ucomisd -0x98(%rbp), %xmm0
jne 0x1f6d81
jp 0x1f6d81
movl -0x4c(%rbp), %eax
movq -0xe8(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jbe 0x1f6d4d
movl $0x1, -0x48(%rbp)
jmp 0x1f6d7f
movl -0x4c(%rbp), %eax
movq -0xe8(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jne 0x1f6d7d
movl -0xa0(%rbp), %eax
addl -0xe0(%rbp), %eax
movq -0xe8(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jbe 0x1f6d7b
movl $0x1, -0x48(%rbp)
jmp 0x1f6d7d
jmp 0x1f6d7f
jmp 0x1f6d81
jmp 0x1f6d83
jmp 0x1f6d85
jmp 0x1f6d87
cmpl $0x0, -0x48(%rbp)
je 0x1f6df6
movl -0x9c(%rbp), %ecx
movq -0xe8(%rbp), %rax
movl %ecx, (%rax)
movl -0x4c(%rbp), %ecx
movq -0xe8(%rbp), %rax
movl %ecx, 0x8(%rax)
movsd -0x68(%rbp), %xmm0
movq -0xe8(%rbp), %rax
movsd %xmm0, 0x10(%rax)
movl -0x54(%rbp), %ecx
movq -0xe8(%rbp), %rax
movl %ecx, 0x2c(%rax)
movl -0x50(%rbp), %ecx
movq -0xe8(%rbp), %rax
movl %ecx, 0x28(%rax)
movsd -0x70(%rbp), %xmm0
movq -0xe8(%rbp), %rax
movsd %xmm0, 0x18(%rax)
movsd -0x78(%rbp), %xmm0
movq -0xe8(%rbp), %rax
movsd %xmm0, 0x20(%rax)
movl -0xa0(%rbp), %eax
addl -0xe0(%rbp), %eax
movq -0xe8(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jae 0x1f6e24
movl -0xa0(%rbp), %ecx
addl -0xe0(%rbp), %ecx
movq -0xe8(%rbp), %rax
movl %ecx, 0x4(%rax)
jmp 0x1f6e26
movq -0xe8(%rbp), %rcx
movl 0x30(%rcx), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
addl $-0x1, %eax
movl 0x30(%rcx), %edx
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andl $0x80000000, %edx       # imm = 0x80000000
orl %eax, %edx
movl %edx, 0x30(%rcx)
cmpl $0x0, %eax
jne 0x1f6f3a
movq -0x38(%rbp), %rdi
movl -0xdc(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x166b50
movl %eax, -0xec(%rbp)
cmpl $0x0, -0xec(%rbp)
jbe 0x1f6f14
jmp 0x1f6e7c
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x20(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0x1f6eee
movq -0x20(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x1f6ead
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
shlq %rax
movq %rax, -0x1a0(%rbp)
jmp 0x1f6ebb
movl $0x2, %eax
movq %rax, -0x1a0(%rbp)
jmp 0x1f6ebb
movq -0x1a0(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x18(%rax)
movl -0xdc(%rbp), %edx
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x20(%rbp), %rsi
movq 0x8(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x8(%rsi)
movl %edx, (%rax,%rcx,4)
jmp 0x1f6f31
cmpl $0x0, -0x58(%rbp)
je 0x1f6f1f
jmp 0x1f7073
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
movl -0xdc(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x44(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x1f6f3c
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x1f649c
cmpl $0x1, -0x58(%rbp)
jne 0x1f7010
cmpl $-0x1, -0x5c(%rbp)
je 0x1f700e
cmpl $0x0, -0x44(%rbp)
jne 0x1f700e
movq -0x20(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x1f700e
jmp 0x1f6f79
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x20(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0x1f6feb
movq -0x20(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x1f6faa
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
shlq %rax
movq %rax, -0x1a8(%rbp)
jmp 0x1f6fb8
movl $0x2, %eax
movq %rax, -0x1a8(%rbp)
jmp 0x1f6fb8
movq -0x1a8(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x18(%rax)
movl -0x5c(%rbp), %edx
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x20(%rbp), %rsi
movq 0x8(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x8(%rsi)
movl %edx, (%rax,%rcx,4)
jmp 0x1f7058
jmp 0x1f7073
movl -0x3c(%rbp), %eax
cmpl -0xcc(%rbp), %eax
jb 0x1f7026
movq -0x20(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x1f7028
jmp 0x1f7073
jmp 0x1f702a
movq -0x20(%rbp), %rcx
movb $0x1, %al
cmpq $0x1, 0x8(%rcx)
movb %al, -0x1a9(%rbp)
ja 0x1f704a
cmpl $0x0, -0x44(%rbp)
setne %al
movb %al, -0x1a9(%rbp)
movb -0x1a9(%rbp), %al
testb $0x1, %al
jne 0x1f6355
movl $0x1, -0x60(%rbp)
movq -0x20(%rbp), %rdi
movl -0x14(%rbp), %esi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
callq 0x1f5f50
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpq 0x38(%rcx), %rax
jae 0x1f715a
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq -0x20(%rbp), %rcx
movq 0x48(%rcx), %rcx
movl -0x3c(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xf8(%rbp)
movq -0xf8(%rbp), %rax
movl 0x30(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl $0x0, %ecx
movl %ecx, 0x30(%rax)
movq -0xf8(%rbp), %rax
movl 0x30(%rax), %ecx
andl $0x80000000, %ecx       # imm = 0x80000000
orl $0x0, %ecx
movl %ecx, 0x30(%rax)
movq -0xf8(%rbp), %rax
movl $0x0, 0x28(%rax)
movq -0xf8(%rbp), %rax
movl $0x0, 0x2c(%rax)
movq -0xf8(%rbp), %rax
movl $0x0, 0x8(%rax)
movq -0xf8(%rbp), %rax
movl $0x0, 0x4(%rax)
movq -0xf8(%rbp), %rax
movl $0x0, (%rax)
movq -0xf8(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x20(%rax)
movq -0xf8(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x18(%rax)
movq -0xf8(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x10(%rax)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x1f707a
movl -0x60(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbp
retq
nopl (%rax)