// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movl %r9d, 0x44(%rsp)
movq %rcx, 0xc8(%rsp)
movq 0x20(%rdi), %rax
movl %edx, %ebp
shrl %ebp
cmpl $0x0, (%rax,%rbp,8)
js 0xbf42c
cmpb $0x1, 0x4(%rax,%rbp,8)
je 0xbf42c
movl %edx, %r15d
movq 0x28(%rdi), %rax
movl %edx, %ecx
movq %rcx, 0x78(%rsp)
movq (%rax,%rcx,8), %rax
xorl %r13d, %r13d
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
andq %rax, %rcx
je 0xbf42f
movq %rsi, %r11
movq 0x8(%rdi), %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
movl (%rax,%rdx), %esi
notl %esi
shrl $0x1f, %esi
addl %esi, %r13d
addq $0x18, %rdx
cmpq %rdx, %rcx
jne 0xbf412
cmpl $0x2, %r13d
jge 0xbf444
xorl %r13d, %r13d
movq %r13, %rax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %esi, %esi
movq %rsi, 0x50(%r8)
movq %rsi, 0x38(%r8)
movq %rsi, 0x20(%r8)
movq %rsi, 0x8(%r8)
movq (%r8), %rax
movq 0x78(%rsp), %rdx
leaq (%rdx,%rdx,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %rdx, %rcx
xorps %xmm0, %xmm0
movups %xmm0, 0x4(%rax,%rcx)
movl $0x0, 0x14(%rax,%rcx)
movq $0x0, 0x38(%rsp)
cmpq %rsi, 0x10(%r8)
movq %r8, 0x8(%rsp)
movq %r11, (%rsp)
movq %rdi, 0x20(%rsp)
jne 0xbf4be
movq $0x2, 0x10(%r8)
movq 0x18(%r8), %rdi
movl $0x8, %esi
callq 0x2370
movq 0x20(%rsp), %rdi
movq (%rsp), %r11
movq 0x8(%rsp), %r8
movq %rax, 0x18(%r8)
movq 0x8(%r8), %rax
movq 0x18(%r8), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x8(%r8)
movl %r15d, (%rcx,%rax,4)
xorl %eax, %eax
movl 0x44(%rsp), %ecx
cmpl $0x1, %ecx
sete %al
leal (%rax,%rax,2), %eax
decl %eax
cmpl $0x2, %ecx
movl $0x1, %r9d
cmovel %r9d, %eax
movl %eax, 0x60(%rsp)
movl $0xffffffff, 0x2c(%rsp) # imm = 0xFFFFFFFF
movl $0x0, 0x1c(%rsp)
movl %r15d, 0x14(%rsp)
movq %rbp, 0x48(%rsp)
movq 0x18(%r8), %rax
movq (%r8), %rcx
movq 0x8(%r8), %rdx
leaq -0x1(%rdx), %rsi
movq %rsi, 0x8(%r8)
movl -0x4(%rax,%rdx,4), %r10d
movq 0x28(%rdi), %rax
movq (%rax,%r10,8), %rax
movq %rax, %rdx
shlq $0x20, %rdx
setne %r15b
je 0xbfa93
leaq (%r10,%r10,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %r10, %rdx
movl 0x4(%rcx,%rdx), %esi
movl %esi, 0x9c(%rsp)
movl 0x8(%rcx,%rdx), %esi
movl %esi, 0x6c(%rsp)
movl 0xc(%rcx,%rdx), %esi
movl %esi, 0x68(%rsp)
movl 0x14(%rcx,%rdx), %esi
movq %rsi, 0x80(%rsp)
movq %rax, %rsi
shrq $0x20, %rsi
leaq (%rsi,%rsi,2), %r12
shlq $0x3, %r12
addq 0x8(%rdi), %r12
movl 0x10(%rcx,%rdx), %ecx
movl %ecx, 0x64(%rsp)
cmpl $0x0, 0x150(%rsp)
setne %cl
movl %r9d, 0x98(%rsp)
testl %r9d, %r9d
setne %dl
andb %cl, %dl
movb %dl, 0x1b(%rsp)
movl %eax, %ecx
xorl %ebx, %ebx
movq %r10, 0x58(%rsp)
movq %r12, 0x88(%rsp)
movq %rcx, 0x70(%rsp)
leaq (%rbx,%rbx,2), %rax
cmpl $0x0, 0xc(%r12,%rax,8)
js 0xbf981
leaq (%r12,%rax,8), %rax
movl 0x8(%rax), %edx
movl %edx, %r13d
shrl %r13d
cmpl %ebp, %r13d
jne 0xbf5ee
movl $0x9, %r14d
jmp 0xbf978
xorl %ebp, %ebp
cmpb $0x0, 0x1b(%rsp)
jne 0xbf5f9
movl (%rax), %ebp
leaq (%rdx,%rdx,8), %rax
leaq (%rax,%rax,2), %r12
movq %rdx, 0x50(%rsp)
addq %rdx, %r12
addq (%r8), %r12
movq 0x58(%r8), %rax
cmpq %rax, 0x50(%r8)
jne 0xbf64e
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x58(%r8)
movq 0x60(%r8), %rdi
shlq $0x2, %rsi
callq 0x2370
movq 0x58(%rsp), %r10
movq 0x20(%rsp), %rdi
movq (%rsp), %r11
movq 0x8(%rsp), %r8
movq %rax, 0x60(%r8)
movq 0x28(%rdi), %rax
movl 0x4(%rax,%r10,8), %eax
addl %ebx, %eax
movq 0x50(%r8), %rcx
movq 0x60(%r8), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, 0x50(%r8)
movl %eax, (%rdx,%rcx,4)
addl 0x9c(%rsp), %ebp
movl $0x6, %r14d
cmpq 0xc8(%rsp), %rbp
jbe 0xbf68d
movq 0x48(%rsp), %rbp
jmp 0xbf96b
cmpl $0x0, 0x18(%r12)
js 0xbf746
movq 0x40(%r8), %rax
cmpq %rax, 0x38(%r8)
jne 0xbf6d6
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x40(%r8)
movq 0x48(%r8), %rdi
shlq $0x2, %rsi
callq 0x2370
movq 0x58(%rsp), %r10
movq (%rsp), %r11
movq 0x8(%rsp), %r8
movq %rax, 0x48(%r8)
movq 0x38(%r8), %rax
movq 0x48(%r8), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x38(%r8)
movq 0x50(%rsp), %rsi
movl %esi, (%rcx,%rax,4)
orb $-0x80, 0x1b(%r12)
movl %r10d, (%r12)
movl %ebp, 0x4(%r12)
testq %r11, %r11
je 0xbf7a0
movq %r11, %rdi
movl %r13d, %esi
movl 0x44(%rsp), %edx
movq %r11, %r14
callq 0xbb6ba
movl %eax, %ebp
movq %r14, %rdi
movl %r13d, %esi
movl 0x120(%rsp), %edx
callq 0xbb6ba
movl %eax, %r14d
movl 0x60(%rsp), %edx
cmpl $-0x1, %edx
je 0xbf7b3
movq (%rsp), %rdi
movl %r13d, %esi
callq 0xbb6ba
jmp 0xbf7b5
testq %r11, %r11
je 0xbf884
movq %r11, %rdi
movl %r13d, %esi
movl 0x44(%rsp), %edx
movq %r11, %r14
callq 0xbb6ba
movq %rax, 0xc0(%rsp)
movq %r14, %rdi
movl %r13d, %esi
movl 0x120(%rsp), %edx
callq 0xbb6ba
movq %rax, 0xb8(%rsp)
movl 0x60(%rsp), %edx
cmpl $-0x1, %edx
je 0xbf893
movq %r14, %rdi
movl %r13d, %esi
callq 0xbb6ba
jmp 0xbf895
xorl %eax, %eax
movl $0x1, %ecx
xorl %ebp, %ebp
xorl %r14d, %r14d
movq 0x20(%rsp), %rdi
jmp 0xbf7e0
xorl %eax, %eax
movq 0x20(%rsp), %rdi
movq (%rsp), %r11
movq 0x10(%r11), %rcx
leaq (,%r13,4), %rdx
addq %r13, %rdx
movl 0x10(%rcx,%rdx,8), %ecx
movq 0x8(%rsp), %r8
movq 0x58(%rsp), %r10
movq 0x50(%rsp), %rsi
addl 0x6c(%rsp), %ebp
movl %ebp, 0x8(%r12)
addl 0x68(%rsp), %r14d
movl %r14d, 0xc(%r12)
addl 0x80(%rsp), %ecx
movl %ecx, 0x14(%r12)
addl 0x64(%rsp), %eax
movl %eax, 0x10(%r12)
movq %rsi, %rax
xorq $0x1, %rax
movq 0x28(%rdi), %rcx
movq (%rcx,%rax,8), %rcx
movq %rcx, %rax
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
andq %rdx, %rax
je 0xbf86c
movq 0x8(%rdi), %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 %esi, %esi
xorl %eax, %eax
movq 0x48(%rsp), %rbp
movl (%rcx,%rsi), %r9d
notl %r9d
shrl $0x1f, %r9d
addl %r9d, %eax
addq $0x18, %rsi
cmpq %rsi, %rdx
jne 0xbf849
orl $0x80000000, %eax       # imm = 0x80000000
movq 0x50(%rsp), %rsi
jmp 0xbf876
movl $0x80000000, %eax       # imm = 0x80000000
movq 0x48(%rsp), %rbp
movl %eax, 0x18(%r12)
incl 0x1c(%rsp)
jmp 0xbf94a
xorl %eax, %eax
movl $0x1, %ecx
xorl %r14d, %r14d
xorl %r13d, %r13d
jmp 0xbf8c1
xorl %eax, %eax
movq 0x10(%r14), %rcx
movl %r13d, %edx
leaq (%rdx,%rdx,4), %rdx
movl 0x10(%rcx,%rdx,8), %ecx
movq 0x8(%rsp), %r8
movq %r14, %r11
movq 0x20(%rsp), %rdi
movq 0xc0(%rsp), %r14
movq 0xb8(%rsp), %r13
addl 0x6c(%rsp), %r14d
addl 0x68(%rsp), %r13d
addl 0x64(%rsp), %eax
movq %r14, %rsi
subq %rax, %rsi
subq %r13, %rsi
movl 0x8(%r12), %edx
movl 0xc(%r12), %r10d
movl 0x10(%r12), %r9d
addq %r10, %r9
subq %r9, %rdx
cmpq %rdx, %rsi
movq 0x58(%rsp), %r10
jle 0xbf918
movl %r10d, (%r12)
movl %r13d, 0xc(%r12)
movl %r14d, 0x8(%r12)
addl 0x80(%rsp), %ecx
movl %ecx, 0x14(%r12)
movl %eax, 0x10(%r12)
jmp 0xbf934
jne 0xbf934
movq 0x80(%rsp), %rdx
addl %ecx, %edx
cmpl 0x14(%r12), %edx
ja 0xbf8f7
jne 0xbf934
cmpl 0x4(%r12), %ebp
ja 0xbf8f7
cmpl 0x4(%r12), %ebp
movq 0x50(%rsp), %rsi
jae 0xbf945
movl %ebp, 0x4(%r12)
movq 0x48(%rsp), %rbp
movl 0x18(%r12), %eax
leal -0x1(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andl $0x80000000, %eax       # imm = 0x80000000
orl %ecx, %eax
movl %eax, 0x18(%r12)
xorl %r14d, %r14d
testl %ecx, %ecx
je 0xbf996
movq 0x88(%rsp), %r12
movq 0x70(%rsp), %rcx
testl %r14d, %r14d
jne 0xbfa89
incq %rbx
cmpq %rcx, %rbx
setb %r15b
jne 0xbf5c1
jmp 0xbfa93
movq 0x28(%rdi), %rax
movq (%rax,%rsi,8), %rax
movq %rax, %rcx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
andq %rdx, %rcx
movq 0x88(%rsp), %r12
je 0xbfa5e
movq 0x8(%rdi), %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 %esi, %esi
movl (%rax,%rdx), %r9d
notl %r9d
shrl $0x1f, %r9d
addl %r9d, %esi
addq $0x18, %rdx
cmpq %rdx, %rcx
jne 0xbf9d7
testl %esi, %esi
movq 0x50(%rsp), %rsi
je 0xbfa5e
movq 0x10(%r8), %rax
cmpq %rax, 0x8(%r8)
jne 0xbfa3e
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x10(%r8)
movq 0x18(%r8), %rdi
shlq $0x2, %rsi
callq 0x2370
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %r10
movq 0x20(%rsp), %rdi
movq (%rsp), %r11
movq 0x8(%rsp), %r8
movq %rax, 0x18(%r8)
movq 0x8(%r8), %rax
movq 0x18(%r8), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x8(%r8)
movl %esi, (%rcx,%rax,4)
movl 0x2c(%rsp), %eax
movl %eax, %esi
movq 0x38(%rsp), %rax
jmp 0xbfa77
movl $0x1, %eax
cmpl $0x0, 0x38(%rsp)
je 0xbfa77
movl $0x9, %r14d
movl $0x1, %eax
jmp 0xbfa7f
decl 0x1c(%rsp)
movl %esi, 0x2c(%rsp)
movq %rax, 0x38(%rsp)
jmp 0xbf973
cmpl $0x6, %r14d
jne 0xbfb5d
cmpl $0x1, 0x38(%rsp)
jne 0xbfb30
xorl %r9d, %r9d
movl $0x1, %eax
movq %rax, 0x38(%rsp)
movl $0x9, %r14d
cmpl $-0x1, 0x2c(%rsp)
movl 0x14(%rsp), %r15d
je 0xbfb6a
cmpl $0x0, 0x1c(%rsp)
jne 0xbfb6a
cmpq $0x0, 0x8(%r8)
jne 0xbfb6a
cmpq $0x0, 0x10(%r8)
jne 0xbfb06
movq $0x2, 0x10(%r8)
movq 0x18(%r8), %rdi
movl $0x8, %esi
callq 0x2370
movq 0x20(%rsp), %rdi
movq (%rsp), %r11
movq 0x8(%rsp), %r8
movq %rax, 0x18(%r8)
movq 0x8(%r8), %rax
movq 0x18(%r8), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x8(%r8)
movl 0x2c(%rsp), %edx
movl %edx, (%rcx,%rax,4)
xorl %r9d, %r9d
movl $0x4, %r14d
movl $0x0, 0x1c(%rsp)
jmp 0xbfb6a
movq $0x0, 0x38(%rsp)
movl $0x9, %r14d
testb $0x1, %r15b
jne 0xbfb53
xorl %eax, %eax
cmpq $0x0, 0x8(%r8)
sete %al
leal (%rax,%rax,8), %r14d
xorl %r9d, %r9d
movl 0x14(%rsp), %r15d
jmp 0xbfb6a
movl 0x14(%rsp), %r15d
movl 0x98(%rsp), %r9d
testl %r14d, %r14d
jne 0xbfb87
cmpq $0x1, 0x8(%r8)
ja 0xbf50e
cmpl $0x0, 0x1c(%rsp)
jne 0xbf50e
jmp 0xbfb8d
cmpl $0x4, %r14d
jne 0xbfbc4
cmpq $0x0, 0x140(%rsp)
sete %al
testq %r11, %r11
sete %cl
orb %al, %cl
jne 0xc03d9
xorl %eax, %eax
cmpl $0x0, 0x148(%rsp)
je 0xbfbcc
movq 0x140(%rsp), %rcx
movq 0xa8(%rcx), %rbp
jmp 0xbfbce
xorl %r13d, %r13d
jmp 0xc0467
xorl %ebp, %ebp
movq 0x38(%r8), %rcx
testq %rcx, %rcx
je 0xbfc44
movq 0x8(%rsp), %rdx
movq 0x18(%rdx), %rax
movq 0x48(%rdx), %rdx
movl (%rax), %esi
shrl %esi
xorl %edi, %edi
xorl %eax, %eax
movl (%rdx,%rdi,4), %r8d
shrl %r8d
cmpl %esi, %r8d
je 0xbfc39
movq (%rsp), %r9
movq 0x10(%r9), %r9
leaq (%r8,%r8,4), %r10
movl 0x10(%r9,%r10,8), %r8d
testq %r8, %r8
je 0xbfc39
leaq (%r9,%r10,8), %r9
movq 0x18(%r9), %r9
movq 0x140(%rsp), %r10
movq 0x8(%r10), %r10
xorl %r11d, %r11d
movq (%r9,%r11,8), %rbx
shrq $0x21, %rbx
addl (%r10,%rbx,4), %eax
incq %r11
cmpq %r11, %r8
jne 0xbfc25
incq %rdi
movl %edi, %r8d
cmpq %r8, %rcx
ja 0xbfbec
movq 0x8(%rsp), %rcx
movq (%rcx), %rsi
movq 0x18(%rcx), %rcx
movl (%rcx), %edi
xorl %r8d, %r8d
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movl %edi, %r11d
movl %r11d, %r9d
leaq (%r9,%r9,8), %r10
leaq (%r10,%r10,2), %r10
addq %r9, %r10
movl (%rsi,%r10), %r9d
cmpl %edi, %r11d
je 0xbfcd7
movl %r11d, %r10d
shrl %r10d
movq (%rsp), %rbx
movq 0x10(%rbx), %rbx
leaq (%r10,%r10,4), %r14
movl 0x10(%rbx,%r14,8), %r10d
testq %r10, %r10
je 0xbfcd4
leaq (%rbx,%r14,8), %r11
movq 0x18(%r11), %r11
movq 0x140(%rsp), %r14
movq 0x8(%r14), %rbx
movq 0x30(%r14), %r14
movq 0x20(%r14), %r14
xorl %r15d, %r15d
movq (%r11,%r15,8), %r12
shrq $0x21, %r12
subl (%rbx,%r12,4), %eax
movl (%r14,%r12,8), %r12d
andl %edx, %r12d
addl %r12d, %r8d
incq %r15
cmpq %r15, %r10
jne 0xbfcaf
movl 0x14(%rsp), %r15d
jmp 0xbfcd7
movl %r11d, %r9d
movl %r9d, %r11d
cmpl %r15d, %r9d
jne 0xbfc5d
testl %r8d, %r8d
je 0xbfcef
xorl %edx, %edx
divl %r8d
jmp 0xbfcf1
xorl %eax, %eax
movq (%rsp), %r11
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movl %edi, %r8d
leaq (%r8,%r8,8), %r9
leaq (%r9,%r9,2), %r9
addq %r8, %r9
movl (%rsi,%r9), %r8d
cmpl (%rcx), %edi
jne 0xbfd15
movl %r8d, %edi
jmp 0xbfd78
movl %edi, %r10d
shrl %r10d
movq 0x10(%r11), %r9
leaq (%r10,%r10,4), %r10
cmpl $0x0, 0x10(%r9,%r10,8)
je 0xbfd78
leaq (%r9,%r10,8), %rdi
movq 0x18(%rdi), %r9
movq 0x140(%rsp), %r11
movq 0x8(%r11), %r10
movq 0x30(%r11), %r11
movq 0x20(%r11), %r11
xorl %ebx, %ebx
movq (%r9,%rbx,8), %r14
shrq $0x21, %r14
movl (%r11,%r14,8), %r15d
andl %edx, %r15d
imull %eax, %r15d
addl %r15d, (%r10,%r14,4)
incq %rbx
movl 0x10(%rdi), %r14d
cmpq %r14, %rbx
jb 0xbfd49
movl %r8d, %edi
movl 0x14(%rsp), %r15d
movq (%rsp), %r11
cmpl %r15d, %edi
jne 0xbfcfa
testq %rbp, %rbp
movq 0x8(%rsp), %r8
je 0xc03d9
movq 0x18(%r11), %rdi
movq 0x28(%rdi), %rax
movq 0x78(%rsp), %rdx
movq (%rax,%rdx,8), %r9
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
andq %r9, %rsi
je 0xc0240
movq 0x8(%rdi), %rdx
shrq $0x20, %r9
shlq $0x3, %rsi
leaq (%rsi,%rsi,2), %rsi
leaq (%r9,%r9,2), %r8
leaq (%rdx,%r8,8), %r8
addq $0xc, %r8
xorl %r9d, %r9d
xorl %r10d, %r10d
movl (%r8,%r9), %r11d
notl %r11d
shrl $0x1f, %r11d
addl %r11d, %r10d
addq $0x18, %r9
cmpq %r9, %rsi
jne 0xbfdd0
cmpl $0x2, %r10d
movq 0x8(%rsp), %r8
movq (%rsp), %r11
jne 0xc0240
movl (%rcx), %esi
xorq $0x1, %rsi
movq (%rax,%rsi,8), %r9
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
andq %r9, %rsi
je 0xc0240
shrq $0x20, %r9
shlq $0x3, %rsi
leaq (%rsi,%rsi,2), %rsi
leaq (%r9,%r9,2), %r8
leaq (%rdx,%r8,8), %rdx
addq $0xc, %rdx
xorl %r8d, %r8d
xorl %r9d, %r9d
movl (%rdx,%r8), %r10d
notl %r10d
shrl $0x1f, %r10d
addl %r10d, %r9d
addq $0x18, %r8
cmpq %r8, %rsi
jne 0xbfe30
cmpl $0x2, %r9d
movq 0x8(%rsp), %r8
jne 0xc0240
movq 0x78(%rsp), %rdx
movq (%rax,%rdx,8), %rdx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
andq %rdx, %rax
je 0xbfeb1
movq 0x8(%rdi), %rsi
shrq $0x20, %rdx
shlq $0x3, %rax
leaq (%rax,%rax,2), %rax
leaq (%rdx,%rdx,2), %rdx
leaq (%rsi,%rdx,8), %rdx
addq $0xc, %rdx
xorl %esi, %esi
xorl %r11d, %r11d
cmpl $0x0, (%rdx,%rsi)
js 0xbfea8
movl -0x4(%rdx,%rsi), %r9d
movl %r11d, %r10d
movl %r9d, 0xa0(%rsp,%r10,4)
movq 0x8(%rsp), %r8
incl %r11d
addq $0x18, %rsi
cmpq %rsi, %rax
jne 0xbfe8a
movl 0xa0(%rsp), %r13d
movl %r13d, %edx
shrl %edx
movl (%rcx), %eax
shrl %eax
cmpl %eax, %edx
je 0xc0237
movl 0xa4(%rsp), %r14d
movl %r14d, %ecx
shrl %ecx
cmpl %eax, %ecx
je 0xc0237
xorl %r10d, %r10d
movl $0x1, %eax
leaq 0xa8(%rsp), %r15
leaq 0xb0(%rsp), %rbx
leaq 0x30(%rsp), %rcx
leaq 0xd0(%rsp), %r8
leaq 0x90(%rsp), %r9
xorl %esi, %esi
movl %r13d, %edx
pushq %r10
pushq %rax
pushq %r15
pushq %rbx
callq 0x10109f
addq $0x20, %rsp
movq (%rsp), %rax
movq 0x18(%rax), %rdi
leaq 0x34(%rsp), %rcx
leaq 0xd8(%rsp), %r12
xorl %esi, %esi
movl %r14d, %edx
movq %r12, %r8
leaq 0x90(%rsp), %r9
xorl %eax, %eax
pushq %rax
movl $0x1, %eax
pushq %rax
pushq %r15
pushq %rbx
callq 0x10109f
movq 0x28(%rsp), %r8
addq $0x20, %rsp
movq -0x8(%r12), %rax
movq (%r12), %rcx
addq %rcx, %rax
incq %rax
movl 0x38(%r8), %ecx
cmpq %rcx, %rax
jne 0xc0237
movq (%rsp), %rax
movq 0x18(%rax), %rdi
movl 0x30(%rsp), %esi
movq 0x28(%rdi), %rcx
movq (%rcx,%rsi,8), %r9
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
andq %r9, %rdx
je 0xc0237
movq %r12, %r15
movq 0x8(%rdi), %rax
shrq $0x20, %r9
shlq $0x3, %rdx
leaq (%rdx,%rdx,2), %rdx
leaq (%r9,%r9,2), %r8
leaq (%rax,%r8,8), %r8
addq $0xc, %r8
xorl %r9d, %r9d
xorl %r10d, %r10d
movl (%r8,%r9), %r11d
notl %r11d
shrl $0x1f, %r11d
addl %r11d, %r10d
addq $0x18, %r9
cmpq %r9, %rdx
jne 0xbffc2
cmpl $0x1, %r10d
movq 0x8(%rsp), %r8
jne 0xc0237
movl 0x34(%rsp), %edx
movq (%rcx,%rdx,8), %rdx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
andq %rdx, %rcx
je 0xc0237
shrq $0x20, %rdx
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rcx
leaq (%rdx,%rdx,2), %rdx
leaq (%rax,%rdx,8), %rax
addq $0xc, %rax
xorl %edx, %edx
xorl %r8d, %r8d
movl (%rax,%rdx), %r9d
notl %r9d
shrl $0x1f, %r9d
addl %r9d, %r8d
addq $0x18, %rdx
cmpq %rdx, %rcx
jne 0xc001b
cmpl $0x1, %r8d
movq 0x8(%rsp), %r8
jne 0xc0237
leaq 0x30(%rsp), %r14
movq %r14, %rdx
callq 0x101046
movq (%rsp), %rax
movq 0x18(%rax), %rdi
movl 0x4(%r14), %esi
leaq 0x34(%rsp), %rdx
callq 0x101046
movq 0x8(%rsp), %r8
movq 0x18(%r8), %rax
movl (%rax), %eax
cmpl %eax, (%r14)
jne 0xc0237
cmpl %eax, 0x34(%rsp)
jne 0xc0237
leaq 0x68(%rbp), %r12
movq $0x0, 0xa0(%rbp)
movq (%rsp), %rbx
movq 0x18(%rbx), %rdi
xorl %r14d, %r14d
leaq 0x30(%rsp), %rcx
leaq 0xd0(%rsp), %r8
leaq 0x90(%rsp), %r9
xorl %esi, %esi
movl %r13d, %edx
pushq %r12
pushq $0x1
leaq 0xb8(%rsp), %rax
pushq %rax
leaq 0xc8(%rsp), %rax
pushq %rax
callq 0x10109f
movq %rbx, %r10
addq $0x20, %rsp
cmpq $0x0, 0xa0(%rbp)
je 0xc0142
movq 0xb0(%rbp), %rax
movl (%rax,%r14,4), %eax
movl %eax, %edx
shrl %edx
movq 0x10(%r10), %rcx
leaq (%rdx,%rdx,4), %rsi
movl 0x10(%rcx,%rsi,8), %edx
testl %edx, %edx
je 0xc0136
leaq (%rcx,%rsi,8), %rcx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edi, %edi
addl %esi, %edx
testb $0x1, %al
movq 0x10(%rbp), %r8
movq 0x18(%rcx), %r9
cmoveq %rdi, %rdx
movq (%r9,%rdx,8), %rdx
shrq $0x21, %rdx
orb $0x2, (%r8,%rdx)
incq %rdi
movl 0x10(%rcx), %edx
decl %esi
cmpq %rdx, %rdi
jb 0xc010c
incl %r14d
cmpq %r14, 0xa0(%rbp)
ja 0xc00e2
leaq 0xd0(%rbp), %r13
movq $0x0, 0x108(%rbp)
movq 0x18(%r10), %rdi
movl 0xa4(%rsp), %edx
xorl %r14d, %r14d
leaq 0x90(%rsp), %r9
xorl %esi, %esi
leaq 0x34(%rsp), %rcx
movq %r15, %r8
pushq %r13
pushq $0x1
leaq 0xb8(%rsp), %rax
pushq %rax
leaq 0xc8(%rsp), %rax
pushq %rax
callq 0x10109f
movq 0x20(%rsp), %r8
addq $0x20, %rsp
cmpq $0x0, 0x108(%rbp)
je 0xc0202
movq 0x118(%rbp), %rax
movl (%rax,%r14,4), %eax
movl %eax, %edx
shrl %edx
movq 0x10(%r8), %rcx
leaq (%rdx,%rdx,4), %rsi
movl 0x10(%rcx,%rsi,8), %edx
testl %edx, %edx
je 0xc01f6
leaq (%rcx,%rsi,8), %rcx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edi, %edi
addl %esi, %edx
testb $0x1, %al
movq 0x10(%rbp), %r10
movq 0x18(%rcx), %r9
cmoveq %rdi, %rdx
movq (%r9,%rdx,8), %rdx
shrq $0x21, %rdx
orb $0x2, (%r10,%rdx)
incq %rdi
movl 0x10(%rcx), %edx
decl %esi
cmpq %rdx, %rdi
jb 0xc01cc
incl %r14d
cmpq %r14, 0x108(%rbp)
ja 0xc01a2
movq 0x8(%rsp), %rbx
movq 0x18(%rbx), %rax
movl (%rax), %ecx
xorl $0x1, %ecx
movq %r12, %rdi
movq %r13, %rsi
movl 0x14(%rsp), %r15d
movl %r15d, %edx
movq 0x140(%rsp), %r9
callq 0xe103f
movq (%rsp), %r11
movq %rbx, %r8
jmp 0xc03d9
movl 0x14(%rsp), %r15d
movq (%rsp), %r11
movq 0x18(%r11), %rdi
movq 0x18(%r8), %rax
movl (%rax), %ecx
movq 0x140(%rsp), %rbx
movq %rbx, %rsi
movl %r15d, %edx
callq 0xe0d8a
movq (%rsp), %r11
movq 0x8(%rsp), %r8
movq 0xa8(%rbx), %rax
cmpq $0x0, 0x50(%rax)
je 0xc03d9
leaq 0x68(%rbp), %r13
xorl %ebx, %ebx
movq 0x60(%rax), %rax
movl (%rax,%rbx,4), %edx
shrl %edx
movq 0x18(%r8), %rax
movl (%rax), %r8d
shrl %r8d
cmpl %r8d, %edx
je 0xc03b9
movq 0x18(%r11), %rdi
movq 0x140(%rsp), %r14
movq %r14, %rsi
movq 0x48(%rsp), %rcx
callq 0xe068d
movq (%rsp), %r11
movq 0xa8(%r14), %rax
cmpq $0x0, 0xa0(%rax)
je 0xc03b9
movq 0x60(%rax), %rax
movl (%rax,%rbx,4), %edi
movq %r13, %rsi
movq 0x8(%rsp), %rdx
movq %r11, %rcx
movq 0x140(%rsp), %r14
movq %r14, %r8
callq 0xe1323
movq (%rsp), %r11
movq 0xa8(%r14), %rax
movq 0x60(%rax), %rax
movl (%rax,%rbx,4), %eax
movl %eax, %edx
shrl %edx
movq 0x10(%r11), %rcx
leaq (%rdx,%rdx,4), %rsi
movl 0x10(%rcx,%rsi,8), %edx
testl %edx, %edx
je 0xc03b9
leaq (%rcx,%rsi,8), %rcx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edi, %edi
addl %esi, %edx
testb $0x1, %al
movq 0x10(%rbp), %r8
movq 0x18(%rcx), %r9
cmoveq %rdi, %rdx
movq (%r9,%rdx,8), %rdx
shrq $0x21, %rdx
orb $0x2, (%r8,%rdx)
incq %rdi
movl 0x10(%rcx), %edx
decl %esi
cmpq %rdx, %rdi
jb 0xc0323
cmpq $0x0, 0xa0(%rbp)
je 0xc03b9
xorl %eax, %eax
movq 0xb0(%rbp), %rcx
movl (%rcx,%rax,4), %ecx
movl %ecx, %esi
shrl %esi
movq 0x10(%r11), %rdx
leaq (%rsi,%rsi,4), %rdi
movl 0x10(%rdx,%rdi,8), %esi
testl %esi, %esi
je 0xc03ae
leaq (%rdx,%rdi,8), %rdx
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
xorl %r8d, %r8d
addl %edi, %esi
testb $0x1, %cl
movq 0x10(%rbp), %r9
movq 0x18(%rdx), %r10
cmoveq %r8, %rsi
movq (%r10,%rsi,8), %rsi
shrq $0x21, %rsi
orb $0x2, (%r9,%rsi)
incq %r8
movl 0x10(%rdx), %esi
decl %edi
cmpq %rsi, %r8
jb 0xc0383
incl %eax
cmpq %rax, 0xa0(%rbp)
ja 0xc0359
incl %ebx
movq 0x140(%rsp), %rax
movq 0xa8(%rax), %rax
cmpq %rbx, 0x50(%rax)
movq 0x8(%rsp), %r8
ja 0xc027e
testq %r11, %r11
sete %al
movq 0x158(%rsp), %rcx
testq %rcx, %rcx
sete %dl
orb %al, %dl
jne 0xc0408
movq %r11, %rdi
movl %r15d, %esi
movq %r8, %rdx
callq 0x18febe
movq (%rsp), %r11
movq 0x8(%rsp), %r8
cmpl $0x0, 0x128(%rsp)
je 0xc042b
movq 0x20(%rsp), %rdi
movl %r15d, %esi
movq %r8, %rdx
callq 0xe1472
movq (%rsp), %r11
movq 0x8(%rsp), %r8
movl $0x1, %r13d
movq 0x130(%rsp), %rcx
movq %rcx, %rax
movq 0x138(%rsp), %r9
orq %r9, %rax
movq 0x20(%rsp), %rdi
je 0xc0467
movq %r11, %rsi
movl %r15d, %edx
movq %rcx, %rax
movq %r8, %rcx
movq %rax, %r8
callq 0xe1666
movq 0x8(%rsp), %r8
cmpq $0x0, 0x38(%r8)
je 0xbf42f
movl $0x1, %eax
xorl %ecx, %ecx
xorps %xmm0, %xmm0
movq (%r8), %rdx
movq 0x48(%r8), %rsi
movl (%rsi,%rcx,4), %ecx
leaq (%rcx,%rcx,8), %rsi
leaq (%rsi,%rsi,2), %rsi
addq %rcx, %rsi
movups %xmm0, 0x4(%rdx,%rsi)
movl $0x0, 0x14(%rdx,%rsi)
andb $0x7f, 0x1b(%rdx,%rsi)
movl %eax, %ecx
incl %eax
cmpq %rcx, 0x38(%r8)
ja 0xc047c
jmp 0xbf42f