// File: /workspace/github_c_makefile_star2_O2/lh3[P]minigraph/gfa-base.c
// Function: gfa_fix_symm_add
uint32_t gfa_fix_symm_add(gfa_t *g)
{
	uint32_t n_err = 0, v, n_vtx = gfa_n_vtx(g);
	int i;
	for (v = 0; v < n_vtx; ++v) {
		int nv = gfa_arc_n(g, v);
		gfa_arc_t *av = gfa_arc_a(g, v);
		for (i = 0; i < nv; ++i) {
			int j, nw;
			gfa_arc_t *aw, *avi = &av[i];
			if (avi->del || avi->comp) continue;
			nw = gfa_arc_n(g, avi->w^1);
			aw = gfa_arc_a(g, avi->w^1);
			for (j = 0; j < nw; ++j) {
				gfa_arc_t *awj = &aw[j];
				if (awj->del || awj->comp) continue;
				if (awj->w == (v^1) && awj->ov == avi->ow && awj->ow == avi->ov) { // complement found
					awj->comp = 1;
					awj->link_id = avi->link_id;
					break;
				}
			}
			if (j == nw) {
				gfa_arc_t *arc_old = g->arc, *arc_new;
				arc_new = gfa_add_arc1(g, avi->w^1, v^1, avi->ow, avi->ov, avi->link_id, 1);
				if (arc_old != g->arc) av = gfa_arc_a(g, v); // g->arc may be reallocated
				arc_new->rank = av[i].rank;
			}
		}
	}
	if (n_vtx < gfa_n_vtx(g)) {
		gfa_arc_sort(g);
		gfa_arc_index(g);
	}
	return n_err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movabsq $0x4000000000000000, %r15 # imm = 0x4000000000000000
movl 0x4(%rdi), %eax
addl %eax, %eax
movq %rax, 0x10(%rsp)
xorl %r13d, %r13d
cmpq 0x10(%rsp), %r13
je 0x4dc2
movq 0x58(%rbx), %rax
movq (%rax,%r13,8), %rax
movq %rax, %r14
shrq $0x1b, %r14
andq $-0x20, %r14
addq 0x48(%rbx), %r14
movl %r13d, %ecx
xorl $0x1, %ecx
movl %ecx, 0xc(%rsp)
testl %eax, %eax
movl $0x0, %r11d
cmovgl %eax, %r11d
xorl %r12d, %r12d
movq %r11, 0x18(%rsp)
cmpq %r11, %r12
je 0x4dba
movq %r12, %rbp
shlq $0x5, %rbp
cmpq %r15, 0x18(%r14,%rbp)
jae 0x4db2
leaq (%r14,%rbp), %rax
movq 0x48(%rbx), %rsi
movq 0x58(%rbx), %rcx
movl 0x8(%rax), %edx
xorq $0x1, %rdx
movq (%rcx,%rdx,8), %rcx
testl %ecx, %ecx
movl $0x0, %edx
cmovgl %ecx, %edx
movq %rcx, %r8
shrq $0x1b, %r8
andq $-0x20, %r8
addq %r8, %rsi
addq $0x18, %rsi
xorl %r10d, %r10d
cmpq %r10, %rdx
je 0x4d49
movq (%rsi), %r8
cmpq %r15, %r8
jae 0x4d11
movl -0x10(%rsi), %r9d
xorl %r13d, %r9d
cmpl $0x1, %r9d
jne 0x4d11
movl -0x8(%rsi), %r9d
cmpl 0x14(%rax), %r9d
jne 0x4d11
movl -0x4(%rsi), %r9d
cmpl 0x10(%rax), %r9d
je 0x4d1a
incq %r10
addq $0x20, %rsi
jmp 0x4ce3
btsq $0x3f, %r8
movq %r8, (%rsi)
movq 0x18(%rax), %rdx
movabsq $0x1fffffffffffffff, %r9 # imm = 0x1FFFFFFFFFFFFFFF
andq %r9, %rdx
movabsq $-0x6000000000000000, %r9 # imm = 0xA000000000000000
andq %r9, %r8
orq %rdx, %r8
movq %r8, (%rsi)
movl %r10d, %edx
cmpl %ecx, %edx
jne 0x4db2
movq 0x48(%rbx), %rcx
movq %rcx, 0x20(%rsp)
movl 0x8(%rax), %esi
movl 0x10(%rax), %r8d
xorl $0x1, %esi
movl 0x14(%rax), %ecx
movq 0x18(%rax), %r9
movabsq $0x1fffffffffffffff, %rax # imm = 0x1FFFFFFFFFFFFFFF
andq %rax, %r9
movl $0x1, (%rsp)
movq %rbx, %rdi
movl 0xc(%rsp), %edx
callq 0x4639
movq 0x48(%rbx), %rcx
cmpq %rcx, 0x20(%rsp)
je 0x4da5
movq 0x58(%rbx), %rdx
movl 0x4(%rdx,%r13,8), %edx
shlq $0x5, %rdx
addq %rdx, %rcx
movq %rcx, %r14
movl 0xc(%r14,%rbp), %ecx
movl %ecx, 0xc(%rax)
movq 0x18(%rsp), %r11
incq %r12
jmp 0x4c92
incq %r13
jmp 0x4c52
movl 0x4(%rbx), %eax
addl %eax, %eax
cmpl %eax, 0x10(%rsp)
jae 0x4ddd
movq %rbx, %rdi
callq 0x47b5
movq %rbx, %rdi
callq 0x483a
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq