// File: chhylp123[P]hifiasm/Overlaps.cpp
// Function: asg_bub_pop1_primary_trio(asg_t*, ma_ug_t*, unsigned int, unsigned long, buf_t*, unsigned int, unsigned int, unsigned int, unsigned long*, unsigned long*, hap_cov_t*, unsigned int, unsigned int, utg_trans_t*)
uint64_t asg_bub_pop1_primary_trio(asg_t *g, ma_ug_t *utg, uint32_t v0, uint64_t max_dist, buf_t *b, 
uint32_t positive_flag, uint32_t negative_flag, uint32_t is_pop, uint64_t* path_base_len, uint64_t* path_nodes, 
hap_cov_t *cov, uint32_t is_update_chain, uint32_t keep_d, utg_trans_t *o)
{   
	uint32_t i, n_pending = 0, is_first = 1, cur_m, cur_c, cur_np, cur_nc, to_replace, n_tips, tip_end;
	uint64_t n_pop = 0;
    long long cur_weight = -1, max_weight = -1;
	///if this node has been deleted
	if (g->seq[v0>>1].del || g->seq[v0>>1].c == ALTER_LABLE) return 0; // already deleted
	///if ((uint32_t)g->idx[v0] < 2) return 0; // no bubbles
    if(get_real_length(g, v0, NULL)<2) return 0;
	///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[v0].c = b->a[v0].d = b->a[v0].m = b->a[v0].nc = b->a[v0].np = 0;
	///b->S is the nodes with all incoming edges visited
	kv_push(uint32_t, b->S, v0);
    n_tips = 0;
    tip_end = (uint32_t)-1;
    uint32_t non_positive_flag = (uint32_t)-1;
    if(positive_flag == FATHER) non_positive_flag = MOTHER;
    if(positive_flag == MOTHER) non_positive_flag = FATHER;

	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), d = b->a[v].d, c = b->a[v].c, m = b->a[v].m, nc = b->a[v].nc, np = b->a[v].np;
		uint32_t nv = asg_arc_n(g, v);
		asg_arc_t *av = asg_arc_a(g, v);
		///why we have this assert?
		///assert(nv > 0);
		///all out-edges of v
		for (i = 0; i < nv; ++i) { // loop through v's neighbors
			/**
			p->ul: |____________31__________|__________1___________|______________32_____________|
								qn            direction of overlap       length of this node (not overlap length)
												(in the view of query)
			p->v : |___________31___________|__________1___________|
								tn             reverse direction of overlap
											(in the view of target)
			p->ol: overlap length
			**/
            ///if this edge has been deleted
			if (av[i].del) continue;
            
			uint32_t w = av[i].v, l = (uint32_t)av[i].ul; // v->w with length l
			binfo_t *t = &b->a[w];
			///that means there is a circle, directly terminate the whole bubble poping
			///if (w == v0) goto pop_reset;
            if ((w>>1) == (v0>>1)) {
                goto pop_reset;
            }
            /****************************may have bugs********************************/
            ///important when poping at long untig graph
            if(is_first && keep_d) l = 0;
            /****************************may have bugs********************************/

			

			///push the edge
            ///high 32-bit of g->idx[v] is the start point of v's edges
            //so here is the point of this specfic edge
			kv_push(uint32_t, b->e, (g->idx[v]>>32) + i);
			///find a too far path? directly terminate the whole bubble poping
			if (d + l > max_dist) break; // too far

            ///if this node
			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;
                /****************************may have bugs********************************/
                cur_c = cur_m = cur_np = 0; cur_nc = 1;
                if(utg)
                {
                    cur_c = get_num_trio_flag(utg, w>>1, positive_flag);
                    cur_m = get_num_trio_flag(utg, w>>1, negative_flag);
                    cur_np = 0; 
                    if(non_positive_flag != (uint32_t)-1) 
                    {
                        cur_np = get_num_trio_flag(utg, w>>1, non_positive_flag);
                    }
                    cur_nc = utg->u.a[(w>>1)].n;
                }
                

                t->c = c + cur_c;
                t->m = m + cur_m;
                t->nc = nc + cur_nc;
                t->np = np + cur_np;
                /****************************may have bugs********************************/
				///incoming edges of w
				///t->r = count_out(g, w^1);
                t->r = get_real_length(g, w^1, NULL);
				++n_pending;
			} else { // visited before
                /****************************may have bugs********************************/
                cur_c = cur_m = cur_np = 0; cur_nc = 1;
                if(utg)
                {
                    cur_c = get_num_trio_flag(utg, w>>1, positive_flag);
                    cur_m = get_num_trio_flag(utg, w>>1, negative_flag);
                    cur_np = 0; 
                    if(non_positive_flag != (uint32_t)-1) 
                    {
                        cur_np = get_num_trio_flag(utg, w>>1, non_positive_flag);
                    }
                    cur_nc = utg->u.a[(w>>1)].n;
                }
                ///BUG: select the path with less negative_flag, less non_positive_flag, more positive_flag, more distance
                ///FIXED: select the path with less (negative_flag+non_positive_flag), more positive_flag, more distance
                to_replace = 0;

                /****************************may have bugs********************************/
                cur_weight = (long long)(c + cur_c) - ((long long)(m + cur_m) + (long long)(np + cur_np));
                max_weight = (long long)t->c - ((long long)t->m + (long long)t->np);
                if(cur_weight > max_weight)
                {
                    to_replace = 1;
                }
                else if(cur_weight == max_weight)
                {
                    if(nc + cur_nc > t->nc)
                    {
                        to_replace = 1;
                    }
                    else if(nc + cur_nc == t->nc)
                    {
                        if(d + l > t->d)
                        {
                            to_replace = 1;
                        }
                    }
                }
                /****************************may have bugs********************************/
                if(to_replace)
                {
                    t->p = v;
                    t->m = m + cur_m;
                    t->c = c + cur_c;
                    t->nc = nc + cur_nc;
                    t->np = np + cur_np;
                }
				///c is the weight (is very likely the number of node in this edge) of the parent node
				///select the longest edge (longest meams most reads/longest edge)
                // if (c + 1 > t->c || (c + 1 == t->c && d + l > t->d)) t->p = v;
				// if (c + 1 > t->c) t->c = c + 1;
                /****************************may have bugs********************************/
				///update len(v0->w)
                ///node: t->d is not the length from this node's parent
                ///it is the shortest edge
				if (d + l < t->d) t->d = d + l; // update dist
			}
			///assert(t->r > 0);
			//if all incoming edges of w have visited
			//push it to b->S
			if (--(t->r) == 0) {
                uint32_t x = get_real_length(g, w, NULL);
                /****************************may have bugs for bubble********************************/
                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;
                }
                /****************************may have bugs for bubble********************************/
				--n_pending;
			}
		}
        is_first = 0;
        //if found a tip
        /****************************may have bugs for bubble********************************/
        if(n_tips == 1)
        {
            if(tip_end != (uint32_t)-1 && n_pending == 0 && b->S.n == 0)
            {
                kv_push(uint32_t, b->S, tip_end);
                break;
            }
            else
            {
                goto pop_reset;
            }
        }
        /****************************may have bugs for bubble********************************/
		///if i < nv, that means (d + l > max_dist)
		if (i < nv || b->S.n == 0) {
            goto pop_reset;
        }
	} while (b->S.n > 1 || n_pending);


    /****************************may have bugs********************************/
    ///if(keep_d != 0) debug_asg_bub_pop1_primary_trio(g, utg, v0, max_dist, b, positive_flag, negative_flag, 1);
    /****************************may have bugs********************************/
    if(cov && utg) asg_bub_backtrack_primary_cov(utg, v0, b, cov, is_update_chain);
    if(o && utg) asg_bub_collect_ovlp(utg, v0, b, o);
	if(is_pop) asg_bub_backtrack_primary(g, v0, b);
    if(path_base_len || path_nodes) asg_bub_backtrack_primary_length(g, utg, v0, b, path_base_len, path_nodes);

    n_pop = 1;
pop_reset:

    /****************************may have bugs********************************/
    ///if(!n_pop && keep_d != 0) debug_asg_bub_pop1_primary_trio(g, utg, v0, max_dist, b, positive_flag, negative_flag, 0);
    /****************************may have bugs********************************/

	for (i = 0; i < b->b.n; ++i) { // clear the states of visited vertices
		binfo_t *t = &b->a[b->b.a[i]];
		t->s = t->c = t->d = t->m = t->nc = t->np = 0;
	}
	return n_pop;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq 0x48(%rbp), %rax
movl 0x40(%rbp), %eax
movl 0x38(%rbp), %eax
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movl %r9d, -0x34(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x1, -0x40(%rbp)
movq $0x0, -0x68(%rbp)
movq $-0x1, -0x70(%rbp)
movq $-0x1, -0x78(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x1c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
jne 0xfe0d7
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x1c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movzbl 0x4(%rax,%rcx,8), %eax
cmpl $0x1, %eax
jne 0xfe0e4
movq $0x0, -0x8(%rbp)
jmp 0xfec45
movq -0x10(%rbp), %rdi
movl -0x1c(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x166b50
cmpl $0x2, %eax
jge 0xfe106
movq $0x0, -0x8(%rbp)
jmp 0xfec45
movq -0x30(%rbp), %rax
movq $0x0, 0x50(%rax)
movq -0x30(%rbp), %rax
movq $0x0, 0x38(%rax)
movq -0x30(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x30(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl -0x1c(%rbp), %ecx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x10(%rax)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl -0x1c(%rbp), %ecx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x14(%rax)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl -0x1c(%rbp), %ecx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0xc(%rax)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl -0x1c(%rbp), %ecx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x4(%rax)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl -0x1c(%rbp), %ecx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x8(%rax)
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x30(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0xfe220
movq -0x30(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0xfe1df
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
shlq %rax
movq %rax, -0xc8(%rbp)
jmp 0xfe1ed
movl $0x2, %eax
movq %rax, -0xc8(%rbp)
jmp 0xfe1ed
movq -0xc8(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x18(%rax)
movl -0x1c(%rbp), %edx
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x30(%rbp), %rsi
movq 0x8(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x8(%rsi)
movl %edx, (%rax,%rcx,4)
movl $0x0, -0x58(%rbp)
movl $0xffffffff, -0x5c(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x7c(%rbp) # imm = 0xFFFFFFFF
cmpl $0x1, -0x34(%rbp)
jne 0xfe263
movl $0x2, -0x7c(%rbp)
cmpl $0x2, -0x34(%rbp)
jne 0xfe270
movl $0x1, -0x7c(%rbp)
jmp 0xfe272
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x30(%rbp), %rdx
movq 0x8(%rdx), %rcx
movq %rcx, %rsi
addq $-0x1, %rsi
movq %rsi, 0x8(%rdx)
movl -0x4(%rax,%rcx,4), %eax
movl %eax, -0x80(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl -0x80(%rbp), %ecx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x84(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl -0x80(%rbp), %ecx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x88(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl -0x80(%rbp), %ecx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
movl %eax, -0x8c(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl -0x80(%rbp), %ecx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movl %eax, -0x90(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl -0x80(%rbp), %ecx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, -0x94(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x80(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x98(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x28(%rcx), %rcx
movl -0x80(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xa0(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x98(%rbp), %eax
jae 0xfe9ed
movq -0xa0(%rbp), %rax
movl -0x38(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0xfe38b
jmp 0xfe9df
movq -0xa0(%rbp), %rax
movl -0x38(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0xa4(%rbp)
movq -0xa0(%rbp), %rax
movl -0x38(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl %eax, -0xa8(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl -0xa4(%rbp), %ecx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xb0(%rbp)
movl -0xa4(%rbp), %eax
shrl %eax
movl -0x1c(%rbp), %ecx
shrl %ecx
cmpl %ecx, %eax
jne 0xfe3f0
jmp 0xfeb98
cmpl $0x0, -0x40(%rbp)
je 0xfe406
cmpl $0x0, 0x40(%rbp)
je 0xfe406
movl $0x0, -0xa8(%rbp)
jmp 0xfe408
movq -0x30(%rbp), %rax
movq 0x50(%rax), %rax
movq -0x30(%rbp), %rcx
cmpq 0x58(%rcx), %rax
jne 0xfe47a
movq -0x30(%rbp), %rax
cmpq $0x0, 0x58(%rax)
je 0xfe439
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rax
shlq %rax
movq %rax, -0xd0(%rbp)
jmp 0xfe447
movl $0x2, %eax
movq %rax, -0xd0(%rbp)
jmp 0xfe447
movq -0xd0(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x58(%rax)
movq -0x30(%rbp), %rax
movq 0x60(%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x60(%rax)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x80(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movl -0x38(%rbp), %ecx
addq %rcx, %rax
movl %eax, %edx
movq -0x30(%rbp), %rax
movq 0x60(%rax), %rax
movq -0x30(%rbp), %rsi
movq 0x50(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x50(%rsi)
movl %edx, (%rax,%rcx,4)
movl -0x84(%rbp), %eax
addl -0xa8(%rbp), %eax
movl %eax, %eax
cmpq -0x28(%rbp), %rax
jbe 0xfe4cc
jmp 0xfe9ed
movq -0xb0(%rbp), %rax
movl 0x18(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
jne 0xfe6d6
jmp 0xfe4e4
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x30(%rbp), %rcx
cmpq 0x40(%rcx), %rax
jne 0xfe556
movq -0x30(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0xfe515
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rax
shlq %rax
movq %rax, -0xd8(%rbp)
jmp 0xfe523
movl $0x2, %eax
movq %rax, -0xd8(%rbp)
jmp 0xfe523
movq -0xd8(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x48(%rax)
movl -0xa4(%rbp), %edx
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x30(%rbp), %rsi
movq 0x38(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x38(%rsi)
movl %edx, (%rax,%rcx,4)
movl -0x80(%rbp), %ecx
movq -0xb0(%rbp), %rax
movl %ecx, (%rax)
movq -0xb0(%rbp), %rax
movl 0x18(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl $0x80000000, %ecx       # imm = 0x80000000
movl %ecx, 0x18(%rax)
movl -0x84(%rbp), %ecx
addl -0xa8(%rbp), %ecx
movq -0xb0(%rbp), %rax
movl %ecx, 0x4(%rax)
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x44(%rbp)
movl $0x0, -0x48(%rbp)
movl $0x1, -0x50(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0xfe649
movq -0x18(%rbp), %rdi
movl -0xa4(%rbp), %esi
shrl %esi
movl -0x34(%rbp), %edx
callq 0xf7240
movl %eax, -0x48(%rbp)
movq -0x18(%rbp), %rdi
movl -0xa4(%rbp), %esi
shrl %esi
movl 0x10(%rbp), %edx
callq 0xf7240
movl %eax, -0x44(%rbp)
movl $0x0, -0x4c(%rbp)
cmpl $-0x1, -0x7c(%rbp)
je 0xfe62a
movq -0x18(%rbp), %rdi
movl -0xa4(%rbp), %esi
shrl %esi
movl -0x7c(%rbp), %edx
callq 0xf7240
movl %eax, -0x4c(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl -0xa4(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, -0x50(%rbp)
movl -0x88(%rbp), %ecx
addl -0x48(%rbp), %ecx
movq -0xb0(%rbp), %rax
movl %ecx, 0x8(%rax)
movl -0x8c(%rbp), %ecx
addl -0x44(%rbp), %ecx
movq -0xb0(%rbp), %rax
movl %ecx, 0xc(%rax)
movl -0x90(%rbp), %ecx
addl -0x50(%rbp), %ecx
movq -0xb0(%rbp), %rax
movl %ecx, 0x14(%rax)
movl -0x94(%rbp), %ecx
addl -0x4c(%rbp), %ecx
movq -0xb0(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x10(%rbp), %rdi
movl -0xa4(%rbp), %esi
xorl $0x1, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x166b50
movl %eax, %edx
movq -0xb0(%rbp), %rax
movl 0x18(%rax), %ecx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andl $0x80000000, %ecx       # imm = 0x80000000
orl %edx, %ecx
movl %ecx, 0x18(%rax)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0xfe8c9
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x44(%rbp)
movl $0x0, -0x48(%rbp)
movl $0x1, -0x50(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0xfe76a
movq -0x18(%rbp), %rdi
movl -0xa4(%rbp), %esi
shrl %esi
movl -0x34(%rbp), %edx
callq 0xf7240
movl %eax, -0x48(%rbp)
movq -0x18(%rbp), %rdi
movl -0xa4(%rbp), %esi
shrl %esi
movl 0x10(%rbp), %edx
callq 0xf7240
movl %eax, -0x44(%rbp)
movl $0x0, -0x4c(%rbp)
cmpl $-0x1, -0x7c(%rbp)
je 0xfe74b
movq -0x18(%rbp), %rdi
movl -0xa4(%rbp), %esi
shrl %esi
movl -0x7c(%rbp), %edx
callq 0xf7240
movl %eax, -0x4c(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl -0xa4(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, -0x50(%rbp)
movl $0x0, -0x54(%rbp)
movl -0x88(%rbp), %eax
addl -0x48(%rbp), %eax
movl %eax, %eax
movl -0x8c(%rbp), %ecx
addl -0x44(%rbp), %ecx
movl %ecx, %ecx
movl -0x94(%rbp), %edx
addl -0x4c(%rbp), %edx
movl %edx, %edx
addq %rdx, %rcx
subq %rcx, %rax
movq %rax, -0x70(%rbp)
movq -0xb0(%rbp), %rax
movl 0x8(%rax), %eax
movq -0xb0(%rbp), %rcx
movl 0xc(%rcx), %ecx
movq -0xb0(%rbp), %rdx
movl 0x10(%rdx), %edx
addq %rdx, %rcx
subq %rcx, %rax
movq %rax, -0x78(%rbp)
movq -0x70(%rbp), %rax
cmpq -0x78(%rbp), %rax
jle 0xfe7d7
movl $0x1, -0x54(%rbp)
jmp 0xfe83b
movq -0x70(%rbp), %rax
cmpq -0x78(%rbp), %rax
jne 0xfe839
movl -0x90(%rbp), %eax
addl -0x50(%rbp), %eax
movq -0xb0(%rbp), %rcx
cmpl 0x14(%rcx), %eax
jbe 0xfe7ff
movl $0x1, -0x54(%rbp)
jmp 0xfe837
movl -0x90(%rbp), %eax
addl -0x50(%rbp), %eax
movq -0xb0(%rbp), %rcx
cmpl 0x14(%rcx), %eax
jne 0xfe835
movl -0x84(%rbp), %eax
addl -0xa8(%rbp), %eax
movq -0xb0(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jbe 0xfe833
movl $0x1, -0x54(%rbp)
jmp 0xfe835
jmp 0xfe837
jmp 0xfe839
jmp 0xfe83b
cmpl $0x0, -0x54(%rbp)
je 0xfe899
movl -0x80(%rbp), %ecx
movq -0xb0(%rbp), %rax
movl %ecx, (%rax)
movl -0x8c(%rbp), %ecx
addl -0x44(%rbp), %ecx
movq -0xb0(%rbp), %rax
movl %ecx, 0xc(%rax)
movl -0x88(%rbp), %ecx
addl -0x48(%rbp), %ecx
movq -0xb0(%rbp), %rax
movl %ecx, 0x8(%rax)
movl -0x90(%rbp), %ecx
addl -0x50(%rbp), %ecx
movq -0xb0(%rbp), %rax
movl %ecx, 0x14(%rax)
movl -0x94(%rbp), %ecx
addl -0x4c(%rbp), %ecx
movq -0xb0(%rbp), %rax
movl %ecx, 0x10(%rax)
movl -0x84(%rbp), %eax
addl -0xa8(%rbp), %eax
movq -0xb0(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jae 0xfe8c7
movl -0x84(%rbp), %ecx
addl -0xa8(%rbp), %ecx
movq -0xb0(%rbp), %rax
movl %ecx, 0x4(%rax)
jmp 0xfe8c9
movq -0xb0(%rbp), %rcx
movl 0x18(%rcx), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
addl $-0x1, %eax
movl 0x18(%rcx), %edx
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andl $0x80000000, %edx       # imm = 0x80000000
orl %eax, %edx
movl %edx, 0x18(%rcx)
cmpl $0x0, %eax
jne 0xfe9dd
movq -0x10(%rbp), %rdi
movl -0xa4(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x166b50
movl %eax, -0xb4(%rbp)
cmpl $0x0, -0xb4(%rbp)
jbe 0xfe9b7
jmp 0xfe91f
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x30(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0xfe991
movq -0x30(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0xfe950
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
shlq %rax
movq %rax, -0xe0(%rbp)
jmp 0xfe95e
movl $0x2, %eax
movq %rax, -0xe0(%rbp)
jmp 0xfe95e
movq -0xe0(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x18(%rax)
movl -0xa4(%rbp), %edx
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x30(%rbp), %rsi
movq 0x8(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x8(%rsi)
movl %edx, (%rax,%rcx,4)
jmp 0xfe9d4
cmpl $0x0, -0x58(%rbp)
je 0xfe9c2
jmp 0xfeb98
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
movl -0xa4(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x3c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0xfe9df
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0xfe35b
movl $0x0, -0x40(%rbp)
cmpl $0x1, -0x58(%rbp)
jne 0xfeabd
cmpl $-0x1, -0x5c(%rbp)
je 0xfeab8
cmpl $0x0, -0x3c(%rbp)
jne 0xfeab8
movq -0x30(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0xfeab8
jmp 0xfea23
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x30(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0xfea95
movq -0x30(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0xfea54
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
shlq %rax
movq %rax, -0xe8(%rbp)
jmp 0xfea62
movl $0x2, %eax
movq %rax, -0xe8(%rbp)
jmp 0xfea62
movq -0xe8(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x18(%rax)
movl -0x5c(%rbp), %edx
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x30(%rbp), %rsi
movq 0x8(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x8(%rsi)
movl %edx, (%rax,%rcx,4)
jmp 0xfeb08
jmp 0xfeb98
movl -0x38(%rbp), %eax
cmpl -0x98(%rbp), %eax
jb 0xfead3
movq -0x30(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0xfead8
jmp 0xfeb98
jmp 0xfeada
movq -0x30(%rbp), %rcx
movb $0x1, %al
cmpq $0x1, 0x8(%rcx)
movb %al, -0xe9(%rbp)
ja 0xfeafa
cmpl $0x0, -0x3c(%rbp)
setne %al
movb %al, -0xe9(%rbp)
movb -0xe9(%rbp), %al
testb $0x1, %al
jne 0xfe272
cmpq $0x0, 0x30(%rbp)
je 0xfeb2e
cmpq $0x0, -0x18(%rbp)
je 0xfeb2e
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
movq -0x30(%rbp), %rdx
movq 0x30(%rbp), %rcx
movl 0x38(%rbp), %r8d
callq 0x13ad90
cmpq $0x0, 0x48(%rbp)
je 0xfeb50
cmpq $0x0, -0x18(%rbp)
je 0xfeb50
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
movq -0x30(%rbp), %rdx
movq 0x48(%rbp), %rcx
callq 0x271e00
cmpl $0x0, 0x18(%rbp)
je 0xfeb66
movq -0x10(%rbp), %rdi
movl -0x1c(%rbp), %esi
movq -0x30(%rbp), %rdx
callq 0x135530
cmpq $0x0, 0x20(%rbp)
jne 0xfeb74
cmpq $0x0, 0x28(%rbp)
je 0xfeb90
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
movq -0x30(%rbp), %rcx
movq 0x20(%rbp), %r8
movq 0x28(%rbp), %r9
callq 0x135750
movq $0x1, -0x68(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpq 0x38(%rcx), %rax
jae 0xfec3d
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq -0x30(%rbp), %rcx
movq 0x48(%rcx), %rcx
movl -0x38(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
movl $0x0, 0x10(%rax)
movq -0xc0(%rbp), %rax
movl $0x0, 0x14(%rax)
movq -0xc0(%rbp), %rax
movl $0x0, 0xc(%rax)
movq -0xc0(%rbp), %rax
movl $0x0, 0x4(%rax)
movq -0xc0(%rbp), %rax
movl $0x0, 0x8(%rax)
movq -0xc0(%rbp), %rax
movl 0x18(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl $0x0, %ecx
movl %ecx, 0x18(%rax)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0xfeb9f
movq -0x68(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xf0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)