// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Overlaps.cpp
// Function: ma_ug_gen_primary(asg_t*, unsigned char)
ma_ug_t *ma_ug_gen_primary(asg_t *g, uint8_t flag)
{
    asg_cleanup(g);
	int32_t *mark;
	uint32_t i, v, n_vtx = g->n_seq * 2;
	///is a queue
	kdq_t(uint64_t) *q;
	ma_ug_t *ug;

	ug = (ma_ug_t*)calloc(1, sizeof(ma_ug_t));
	ug->g = asg_init();
    ///each node has two directions
	mark = (int32_t*)calloc(n_vtx, 4);

    ///for each untig, all node have the same direction
    ///and all node except the last one just have one edge
    ///the last one may have multiple edges
	q = kdq_init(uint64_t);
	for (v = 0; v < n_vtx; ++v) {
		uint32_t w, x, l, start, end, len;
		ma_utg_t *p;
        ///what's the usage of mark array
        ///mark array is used to mark if this node has already been included in a contig
        /****************************may have hap bugs********************************/
		///if (g->seq[v>>1].del || arc_cnt(g, v) == 0 || mark[v] || g->seq[v>>1].c != flag) continue;
        ///if (g->seq[v>>1].del || arc_cnt(g, v) == 0 || mark[v] || (g->seq[v>>1].c & flag) == 0) continue;
        ///if (g->seq[v>>1].del || arc_cnt(g, v) == 0 || mark[v]) continue;
        if (g->seq[v>>1].del || mark[v]) continue;
        if (arc_cnt(g, v) == 0 && arc_cnt(g, (v^1)) != 0) continue;
        if(flag == PRIMARY_LABLE && g->seq[v>>1].c == ALTER_LABLE) continue;
        if(flag == ALTER_LABLE && g->seq[v>>1].c != ALTER_LABLE) continue;
        /****************************may have hap bugs********************************/
		mark[v] = 1;
		q->count = 0, start = v, end = v^1, len = 0;
		// forward
		w = v;
		while (1) {
			/**
			 * w----->x
			 * w<-----x
			 * that means the only suffix of w is x, and the only prefix of x is w
			 **/
			if (arc_cnt(g, w) != 1) break;
			x = arc_first(g, w).v; // w->x
			if (arc_cnt(g, x^1) != 1) break;

			/**
			 * another direction of w would be marked as used (since w has been used)
			**/
			mark[x] = mark[w^1] = 1;
			///l is the edge length, instead of overlap length
            ///note: edge length is different with overlap length
			l = asg_arc_len(arc_first(g, w));
			kdq_push(uint64_t, q, (uint64_t)w<<32 | l);
			end = x^1, len += l;
			w = x;
			if (x == v) break;
		}
        ///kdq_size(q) == 0 means there is just one read
		if (start != (end^1) || kdq_size(q) == 0) { // linear unitig
			///length of seq, instead of edge
			l = g->seq[end>>1].len;
			kdq_push(uint64_t, q, (uint64_t)(end^1)<<32 | l);
			len += l;
		} else { // circular unitig
			start = end = UINT32_MAX;
			goto add_unitig; // then it is not necessary to do the backward
		}
		// backward
		x = v;
		while (1) { // similar to forward but not the same
			if (arc_cnt(g, x^1) != 1) break;
			w = arc_first(g, x^1).v ^ 1; // w->x
			if (arc_cnt(g, w) != 1) break;
			mark[x] = mark[w^1] = 1;
			l = asg_arc_len(arc_first(g, w));
			///w is the seq id + direction, l is the length of edge
			///push element to the front of a queue
			kdq_unshift(uint64_t, q, (uint64_t)w<<32 | l);
			start = w, len += l;
			x = w;
		}
add_unitig:
		if (start != UINT32_MAX) mark[start] = mark[end] = 1;
		kv_pushp(ma_utg_t, ug->u, &p);
		p->s = 0, p->start = start, p->end = end, p->len = len, p->n = kdq_size(q), p->circ = (start == UINT32_MAX);
		p->m = p->n;
		kv_roundup32(p->m);
		p->a = (uint64_t*)malloc(8 * p->m);
		//all elements are saved here
		for (i = 0; i < kdq_size(q); ++i)
			p->a[i] = kdq_at(q, i);
	}
	kdq_destroy(uint64_t, q);

	// add arcs between unitigs; reusing mark for a different purpose
	//ug saves all unitigs
	for (v = 0; v < n_vtx; ++v) mark[v] = -1;

    //mark all start nodes and end nodes of all unitigs
    ///note ug->u.a[i].start == ug->u.a[i].a[0]
    ///but ug->u.a[i].end = ug->u.a[i].a[ug->u.a[i].n-1]^1
    ///ug->u.a[i].start has the same direction as other non-end node
    ///while ug->u.a[i].end is the only one with reverse direction
	for (i = 0; i < ug->u.n; ++i) {
		if (ug->u.a[i].circ) continue;
        ///i is the untig id
		mark[ug->u.a[i].start] = i<<1 | 0;
		mark[ug->u.a[i].end] = i<<1 | 1;
	}

	//scan all edges
	for (i = 0; i < g->n_arc; ++i) {
		asg_arc_t *p = &g->arc[i];
		if (p->del) continue;
		/**
	p->ul: |____________31__________|__________1___________|______________32_____________|
	                    qns            direction of overlap       length of this node (not overlap length)
						                 (based on query)
	p->v : |___________31___________|__________1___________|
				        tns             reverse direction of overlap
						                  (based on target)
	p->ol: overlap length
	**/
		///to connect two unitigs, we need to connect the end of unitig x to the start of unitig y
		///so we need to ^1 to get the reverse direction of (x's end)?
        ///>=0 means this node is a start/end node of an unitig
        ///means this node is a intersaction node
        /**for one untig,
          start                end
         ----->              <------
         so if we want to find the edge between two untigs, their start and end look like: 

         start                end
         ----->              <------
         ---------------------------

                                    start                end
                                    ----->              <------
                                    ---------------------------
        p->ul>>32^1 is the end of the first untig,
        p->v is the start of the second untig
        **/
		if (mark[p->ul>>32^1] >= 0 && mark[p->v] >= 0) {
			asg_arc_t *q;
			uint32_t u = mark[p->ul>>32^1]^1;
			int l = ug->u.a[u>>1].len - p->ol;
			if (l < 0) l = 1;
			q = asg_arc_pushp(ug->g);
			q->ol = p->ol, q->del = 0;
			q->ul = (uint64_t)u<<32 | l;
			q->v = mark[p->v]; q->ou = 0;
            q->el = p->el;
		}
	}
	for (i = 0; i < ug->u.n; ++i)
		asg_seq_set(ug->g, i, ug->u.a[i].len, 0);
	asg_cleanup(ug->g);
	free(mark);
	return ug;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %esi, %r14d
movq %rdi, %rbx
movabsq $0x800000000000000, %r13 # imm = 0x800000000000000
callq 0xa0a7d
movq %rbx, 0x18(%rsp)
movl 0x14(%rbx), %ebx
addl %ebx, %ebx
movl $0x1, %edi
movl $0x38, %esi
callq 0x2120
movq %rax, %r15
movl $0x1, %edi
movl $0x48, %esi
callq 0x2120
movq %rax, 0x60(%rsp)
movq %rax, 0x18(%r15)
movl $0x4, %esi
movq %rbx, %rdi
callq 0x2120
movq %rax, 0x10(%rsp)
movl $0x1, %edi
movl $0x20, %esi
callq 0x2120
movq %rax, %r12
movq %r13, (%rax)
movq $0x3, 0x10(%rax)
movl $0x20, %edi
callq 0x2280
movq %r12, %r11
movq %rax, %r9
movq %rax, 0x18(%r12)
testl %ebx, %ebx
movq %r15, 0x30(%rsp)
je 0xb30cd
movq $0x0, 0x8(%rsp)
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movq $0x0, 0x58(%rsp)
movq $0x0, 0x48(%rsp)
xorl %ebp, %ebp
movq 0x10(%rsp), %r8
movq 0x18(%rsp), %r10
movq %rbx, 0x50(%rsp)
movl %r14d, 0x3c(%rsp)
movq %r11, 0x40(%rsp)
movq 0x20(%r10), %rdx
movl %ebp, %esi
shrl %esi
cmpl $0x0, (%rdx,%rsi,8)
js 0xb30a3
cmpl $0x0, (%r8,%rbp,4)
jne 0xb30a3
movq 0x28(%r10), %rax
movq (%rax,%rbp,8), %rcx
movq %rcx, %rdi
andq %r12, %rdi
je 0xb2ba5
cmpb $0x1, %r14b
je 0xb2bcb
movq %r10, %r12
movq %r8, %r10
movzbl %r14b, %r8d
testl %r8d, %r8d
movq %r10, %r8
movq %r12, %r10
jne 0xb2bd6
cmpb $0x1, 0x4(%rdx,%rsi,8)
jne 0xb2bd6
jmp 0xb3074
movl %r14d, %r15d
movq %r10, %r14
movq %r8, %r10
movl %ebp, %r8d
xorq $0x1, %r8
cmpl $0x0, (%rax,%r8,8)
movq %r10, %r8
movq %r14, %r10
movl %r15d, %r14d
jne 0xb30a3
jmp 0xb2b7e
cmpb $0x1, 0x4(%rdx,%rsi,8)
jne 0xb3074
movl $0x1, (%r8,%rbp,4)
movq $0x0, 0x8(%r11)
movl %ebp, %r15d
xorl $0x1, %r15d
cmpl $0x1, %edi
jne 0xb2cfc
movq %r10, %rdx
movq %r8, %r10
movq 0x8(%rdx), %rdx
shrq $0x20, %rcx
leaq (%rcx,%rcx,2), %rsi
movl 0x8(%rdx,%rsi,8), %esi
movq %rsi, %rdi
xorq $0x1, %rdi
cmpl $0x1, (%rax,%rdi,8)
movl %r15d, 0x24(%rsp)
jne 0xb2d08
xorl %r12d, %r12d
movl %ebp, %r8d
movq %rbp, %r14
xorl %eax, %eax
movl $0x1, %ebx
xorl %ebx, %r8d
movl %ebx, (%r10,%r8,4)
movl %edi, 0x28(%rsp)
movl %esi, 0x8(%rsp)
movl %esi, %r15d
movl %ebx, (%r10,%r15,4)
leaq (%rcx,%rcx,2), %rcx
movq (%rdx,%rcx,8), %rbx
movq %r13, %rcx
shrq $0x3a, %rcx
movl $0x1, %edx
shlq %cl, %rdx
cmpq %rdx, %rax
movq %r9, %rdi
jne 0xb2c88
incl %ecx
movq %r11, %rdi
movl %ecx, %esi
callq 0x105211
movq 0x40(%rsp), %r11
movq 0x10(%rsp), %r10
movq (%r11), %r13
movq 0x8(%r11), %rax
movq 0x18(%r11), %rdi
movl %ebx, %ecx
shlq $0x20, %r14
movq %r13, %rdx
movabsq $0x3ffffffffffffff, %rsi # imm = 0x3FFFFFFFFFFFFFF
andq %rsi, %rdx
addq %rax, %rdx
incq %rax
movq %rax, 0x8(%r11)
andq 0x10(%r11), %rdx
orq %rcx, %r14
movq %rdi, %r9
movq %r14, (%rdi,%rdx,8)
addl %ebx, %r12d
cmpq %r15, %rbp
je 0xb2d12
movq 0x18(%rsp), %rdx
movq 0x28(%rdx), %r8
movq (%r8,%r15,8), %rcx
cmpl $0x1, %ecx
jne 0xb2d12
movq 0x8(%rdx), %rdx
shrq $0x20, %rcx
leaq (%rcx,%rcx,2), %rsi
movl 0x8(%rdx,%rsi,8), %esi
movq %rsi, %rdi
xorq $0x1, %rdi
cmpl $0x1, (%r8,%rdi,8)
movq %r15, %r14
movl 0x8(%rsp), %r8d
je 0xb2c2d
jmp 0xb2d12
movl %ebp, %ebx
xorl %r12d, %r12d
movl %r15d, %edx
xorl %eax, %eax
jmp 0xb2d52
xorl %eax, %eax
movl %r15d, 0x28(%rsp)
xorl %r12d, %r12d
movl 0x28(%rsp), %edx
movl %edx, %ebx
xorl $0x1, %ebx
cmpq %rbx, %rbp
jne 0xb2d3e
testq %rax, %rax
movq 0x30(%rsp), %r15
je 0xb2d43
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0x80000000, %esi       # imm = 0x80000000
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
jmp 0xb2f32
movq %r10, %r8
jmp 0xb2d48
movq %r10, %r8
xorl %eax, %eax
movq 0x18(%rsp), %r10
movl 0x24(%rsp), %r15d
movq 0x20(%r10), %rcx
movl %edx, 0x28(%rsp)
shrl %edx
movl (%rcx,%rdx,8), %r14d
movq %r13, %rcx
shrq $0x3a, %rcx
movl $0x1, %edx
shlq %cl, %rdx
cmpq %rdx, %rax
jne 0xb2d9a
incl %ecx
movq %r11, %rdi
movl %ecx, %esi
callq 0x105211
movq 0x40(%rsp), %r11
movq 0x18(%rsp), %r10
movq 0x10(%rsp), %r8
movq (%r11), %r13
movq 0x8(%r11), %rax
movq 0x18(%r11), %r9
andl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
shlq $0x20, %rbx
orq %r14, %rbx
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%r11)
movq %r13, %rcx
movabsq $0x3ffffffffffffff, %rdx # imm = 0x3FFFFFFFFFFFFFF
andq %rdx, %rcx
addq %rax, %rcx
andq 0x10(%r11), %rcx
movq %rbx, (%r9,%rcx,8)
addl %r14d, %r12d
movq 0x28(%r10), %rax
movl %r15d, %ecx
movq (%rax,%rcx,8), %rdx
cmpl $0x1, %edx
jne 0xb2efa
movq 0x8(%r10), %rcx
shrq $0x20, %rdx
leaq (%rdx,%rdx,2), %rdx
movl 0x8(%rcx,%rdx,8), %edx
movq %rdx, %rbx
xorq $0x1, %rbx
movq (%rax,%rbx,8), %rsi
cmpl $0x1, %esi
jne 0xb2efa
movl %ebp, %edi
movl %edi, %edi
movl %ebx, 0x8(%rsp)
movl %edx, %r14d
movl $0x1, %edx
movl %edx, (%r8,%r14,4)
movl %edx, (%r8,%rdi,4)
shrq $0x20, %rsi
leaq (%rsi,%rsi,2), %rdx
movq (%rcx,%rdx,8), %r15
movq 0x8(%r11), %rdx
movq %r13, %rcx
shrq $0x3a, %rcx
movl $0x1, %esi
shlq %cl, %rsi
cmpq %rsi, %rdx
jne 0xb2e73
incl %ecx
movq %r11, %rdi
movl %ecx, %esi
callq 0x105211
movq 0x40(%rsp), %r11
movq 0x18(%rsp), %r10
movq 0x10(%rsp), %r8
movq (%r11), %r13
movq 0x8(%r11), %rdx
movq %r13, %rcx
shrq $0x3a, %rcx
movq 0x18(%r11), %r9
movq 0x28(%r10), %rax
movl %r15d, %esi
shlq $0x20, %rbx
orq %rsi, %rbx
incq %rdx
movq %rdx, 0x8(%r11)
movabsq $0x3ffffffffffffff, %rdi # imm = 0x3FFFFFFFFFFFFFF
leaq (%rdi,%r13), %rdx
movq $-0x1, %rsi
shlq %cl, %rsi
testq %rdi, %r13
notq %rsi
cmovneq %rdx, %rsi
andq %rdi, %rsi
movabsq $-0x400000000000000, %rcx # imm = 0xFC00000000000000
andq %rcx, %r13
orq %rsi, %r13
movq %r13, (%r11)
movq %rbx, (%r9,%rsi,8)
addl %r15d, %r12d
movq (%rax,%r14,8), %rdx
cmpl $0x1, %edx
jne 0xb30b1
movq 0x8(%r10), %rcx
shrq $0x20, %rdx
leaq (%rdx,%rdx,2), %rdx
movl 0x8(%rcx,%rdx,8), %edx
movq %rdx, %rbx
xorq $0x1, %rbx
movq (%rax,%rbx,8), %rsi
cmpl $0x1, %esi
movl 0x8(%rsp), %edi
je 0xb2e08
jmp 0xb2efc
movl %ebp, %edi
cmpl $-0x1, %edi
je 0xb2f1f
movl 0x28(%rsp), %edx
movl %edx, %eax
movl $0x1, %ecx
movl %ecx, (%r8,%rax,4)
movl %edi, %eax
movl %ecx, (%r8,%rax,4)
xorl %esi, %esi
movq 0x30(%rsp), %r15
jmp 0xb2f32
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl $0x80000000, %esi       # imm = 0x80000000
movq 0x30(%rsp), %r15
movl 0x28(%rsp), %edx
movq %r9, 0x28(%rsp)
movq (%r15), %r14
cmpq 0x8(%r15), %r14
jne 0xb2f88
leaq (%r14,%r14), %rax
testq %r14, %r14
movl $0x2, %ecx
cmoveq %rcx, %rax
movq %rax, 0x8(%r15)
shlq $0x3, %rax
movl %esi, 0x24(%rsp)
leaq (%rax,%rax,4), %rsi
movl %edi, 0x8(%rsp)
movq 0x48(%rsp), %rdi
movl %edx, %ebx
callq 0x2370
movl 0x24(%rsp), %esi
movl 0x8(%rsp), %edi
movl %ebx, %edx
movq 0x40(%rsp), %r11
movq %rax, 0x58(%rsp)
movq %rax, 0x10(%r15)
leaq 0x1(%r14), %rcx
movq %rcx, 0x8(%rsp)
movq %rcx, (%r15)
leaq (%r14,%r14,4), %r15
movq 0x58(%rsp), %rbx
movq $0x0, 0x20(%rbx,%r15,8)
movl %edi, 0x4(%rbx,%r15,8)
movl %edx, 0x8(%rbx,%r15,8)
andl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
movl (%rbx,%r15,8), %eax
movl $0x80000000, %ecx       # imm = 0x80000000
andl %ecx, %eax
orl %r12d, %eax
movl %eax, (%rbx,%r15,8)
movq 0x8(%r11), %r14
movl %r14d, 0x10(%rbx,%r15,8)
orl %esi, %r12d
movl %r12d, (%rbx,%r15,8)
leal -0x1(%r14), %eax
movl %eax, %ecx
shrl %ecx
orl %eax, %ecx
movl %ecx, %eax
shrl $0x2, %eax
orl %ecx, %eax
movl %eax, %ecx
shrl $0x4, %ecx
orl %eax, %ecx
movl %ecx, %eax
shrl $0x8, %eax
orl %ecx, %eax
movl %eax, %ecx
shrl $0x10, %ecx
orl %eax, %ecx
leal 0x1(%rcx), %eax
movl %eax, 0xc(%rbx,%r15,8)
leal 0x8(,%rcx,8), %edi
movq %r11, %r12
callq 0x2280
movq %rax, 0x18(%rbx,%r15,8)
movq %rbx, %r8
testq %r14, %r14
je 0xb307c
movq 0x10(%r12), %rcx
movq 0x18(%r12), %r9
movq %r13, %rdx
movabsq $0x3ffffffffffffff, %rsi # imm = 0x3FFFFFFFFFFFFFF
andq %rsi, %rdx
xorl %esi, %esi
movq 0x18(%rsp), %r10
movq 0x50(%rsp), %rbx
movq %r12, %r11
leaq (%rdx,%rsi), %rdi
andq %rcx, %rdi
movq (%r9,%rdi,8), %rdi
movq %rdi, (%rax,%rsi,8)
incq %rsi
movl %esi, %edi
cmpq %rdi, %r14
ja 0xb304c
movq %r8, 0x48(%rsp)
movq 0x10(%rsp), %r8
movl 0x3c(%rsp), %r14d
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
jmp 0xb30a3
movq %r8, 0x48(%rsp)
movq 0x10(%rsp), %r8
movq 0x18(%rsp), %r10
movq 0x50(%rsp), %rbx
movl 0x3c(%rsp), %r14d
movq %r12, %r11
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movq 0x28(%rsp), %r9
incq %rbp
cmpq %rbx, %rbp
jne 0xb2b51
jmp 0xb30ba
movl 0x8(%rsp), %edi
jmp 0xb2efc
movq 0x18(%r11), %r9
movq %r11, %r14
movq 0x8(%rsp), %r12
movq 0x30(%rsp), %r15
jmp 0xb30d3
xorl %r12d, %r12d
movq %r11, %r14
movq %r9, %rdi
callq 0x2220
movq %r14, %rdi
callq 0x2220
testq %rbx, %rbx
je 0xb30ff
leaq (,%rbx,4), %rdx
movq 0x10(%rsp), %rdi
movl $0xff, %esi
callq 0x20e0
testq %r12, %r12
movq 0x10(%rsp), %r8
movq 0x18(%rsp), %r9
je 0xb3146
movq 0x10(%r15), %rax
addq $0x8, %rax
movl $0x1, %ecx
movl $0x1, %edx
cmpl $0x0, -0x8(%rax)
js 0xb3136
leal -0x1(%rcx), %esi
movl -0x4(%rax), %edi
movl %esi, (%r8,%rdi,4)
movl (%rax), %esi
movl %ecx, (%r8,%rsi,4)
movl %edx, %esi
addq $0x28, %rax
incl %edx
addl $0x2, %ecx
cmpq %rsi, %r12
ja 0xb3120
movq %r12, 0x8(%rsp)
movl 0x4(%r9), %eax
testl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
je 0xb3287
movl $0x12, %ebx
xorl %r14d, %r14d
movl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
movq 0x60(%rsp), %rbp
movq 0x8(%r9), %r12
movl -0x6(%r12,%rbx), %ecx
testl %ecx, %ecx
js 0xb326f
movl -0xe(%r12,%rbx), %edx
shlq $0x2, %rdx
xorq $0x4, %rdx
movl (%r8,%rdx), %r13d
testl %r13d, %r13d
js 0xb326f
movl -0xa(%r12,%rbx), %edx
cmpl $0x0, (%r8,%rdx,4)
js 0xb326f
movq 0x10(%r15), %rax
movl %r13d, %edx
shrl %edx
leaq (%rdx,%rdx,4), %rdx
movl (%rax,%rdx,8), %eax
andl %edi, %eax
subl %ecx, %eax
movl $0x1, %r15d
js 0xb31c6
movl %eax, %r15d
movl 0x4(%rbp), %edx
movl %edx, %ecx
andl %edi, %ecx
cmpl (%rbp), %ecx
jne 0xb3213
leal (%rcx,%rcx), %eax
testl %ecx, %ecx
movl $0x10, %ecx
cmovel %ecx, %eax
movl %eax, (%rbp)
movq 0x8(%rbp), %rdi
shlq $0x3, %rax
leaq (%rax,%rax,2), %rsi
callq 0x2370
movl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
movq 0x18(%rsp), %r9
movq 0x10(%rsp), %r8
movq %rax, 0x8(%rbp)
movl 0x4(%rbp), %edx
movl %edx, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
jmp 0xb3217
movq 0x8(%rbp), %rax
xorl $0x1, %r13d
leal 0x1(%rdx), %esi
andl %edi, %esi
andl $0x80000000, %edx       # imm = 0x80000000
orl %esi, %edx
movl %edx, 0x4(%rbp)
movl %ecx, %ecx
leaq (%rcx,%rcx,2), %rcx
movl -0x6(%r12,%rbx), %edx
andl %edi, %edx
movl %edx, 0xc(%rax,%rcx,8)
shlq $0x20, %r13
movslq %r15d, %rdx
orq %r13, %rdx
movq %rdx, (%rax,%rcx,8)
movl -0xa(%r12,%rbx), %edx
movl (%r8,%rdx,4), %edx
movl %edx, 0x8(%rax,%rcx,8)
andw $0xc000, 0x10(%rax,%rcx,8) # imm = 0xC000
movb (%r12,%rbx), %dl
movb %dl, 0x12(%rax,%rcx,8)
movl 0x4(%r9), %eax
movq 0x30(%rsp), %r15
incq %r14
movl %eax, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
addq $0x18, %rbx
cmpq %rcx, %r14
jb 0xb316c
movq 0x8(%rsp), %r13
testq %r13, %r13
movq 0x60(%rsp), %r12
je 0xb32be
movq 0x10(%r15), %r14
xorl %ebx, %ebx
movl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
leaq (%rbx,%rbx,4), %rax
movl (%r14,%rax,8), %edx
andl %ebp, %edx
movq %r12, %rdi
movl %ebx, %esi
xorl %ecx, %ecx
callq 0xa0887
incl %ebx
cmpq %rbx, %r13
ja 0xb32a1
movq %r12, %rdi
callq 0xa0a7d
movq 0x10(%rsp), %rdi
callq 0x2220
movq %r15, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq