// File: /workspace/github_c_makefile_star2_O2/lh3[P]minigraph/gfa-base.c
// Function: gfa_fix_semi_arc
uint32_t gfa_fix_semi_arc(gfa_t *g)
{
	uint32_t n_err = 0, v, n_vtx = gfa_n_vtx(g);
	int i, j;
	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) {
			if (!av[i].del && (av[i].ow == INT32_MAX || av[i].ov == INT32_MAX)) { // overlap length is missing
				uint32_t w = av[i].w^1;
				int is_multi = 0, c, jv = -1, nw = gfa_arc_n(g, w);
				gfa_arc_t *aw = gfa_arc_a(g, w);
				for (j = 0, c = 0; j < nw; ++j)
					if (!aw[j].del && aw[j].w == (v^1)) ++c, jv = j;
				if (c == 1) {
					if (av[i].ov != INT32_MAX && aw[jv].ow != INT32_MAX && av[i].ov != aw[jv].ow) is_multi = 1;
					if (av[i].ow != INT32_MAX && aw[jv].ov != INT32_MAX && av[i].ow != aw[jv].ov) is_multi = 1;
				}
				if (c == 1 && !is_multi) {
					if (aw[jv].ov != INT32_MAX) av[i].ow = aw[jv].ov;
					if (aw[jv].ow != INT32_MAX) av[i].ov = aw[jv].ow;
				} else {
					if (gfa_verbose >= 2)
						fprintf(stderr, "[W] can't infer overlap length for %s%c -> %s%c\n",
								g->seg[v>>1].name, "+-"[v&1], g->seg[w>>1].name, "+-"[(w^1)&1]);
					++n_err;
					av[i].del = 1;
				}
			}
		}
	}
	return n_err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movabsq $0x4000000000000000, %r15 # imm = 0x4000000000000000
movq %rdi, 0x10(%rsp)
movl 0x4(%rdi), %eax
addl %eax, %eax
movq %rax, 0x18(%rsp)
xorl %r14d, %r14d
movl $0x0, 0x4(%rsp)
cmpq 0x18(%rsp), %r14
je 0x4c17
movq 0x10(%rsp), %rcx
movq 0x58(%rcx), %rax
movq (%rax,%r14,8), %rax
movq %rax, %r12
shrq $0x1b, %r12
andq $-0x20, %r12
addq 0x48(%rcx), %r12
movl %r14d, %ecx
shrl %ecx
movl %r14d, %edx
andl $0x1, %edx
movq %rdx, 0x20(%rsp)
testl %eax, %eax
movl $0x0, %edx
cmovgl %eax, %edx
shlq $0x6, %rcx
movq %rcx, 0x28(%rsp)
xorl %ebx, %ebx
movq %rdx, 0x8(%rsp)
cmpq %rdx, %rbx
je 0x4c0f
movq %rbx, %rbp
shlq $0x5, %rbp
movq 0x18(%r12,%rbp), %rax
testq %r15, %rax
jne 0x4b60
addq %r12, %rbp
movl 0x14(%rbp), %ecx
cmpl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
je 0x4a8f
cmpl $0x7fffffff, 0x10(%rbp) # imm = 0x7FFFFFFF
jne 0x4b60
movl 0x8(%rbp), %edx
movq %rdx, 0x30(%rsp)
xorq $0x1, %rdx
movq 0x10(%rsp), %rsi
movq 0x48(%rsi), %r9
movq 0x58(%rsi), %rdi
movq (%rdi,%rdx,8), %rdx
movq %rdx, %r10
shrq $0x1b, %r10
andq $-0x20, %r10
xorl %edi, %edi
testl %edx, %edx
movl $0x0, %r8d
cmovgl %edx, %r8d
leaq (%r9,%r10), %rdx
addq %r9, %r10
addq $0x18, %r10
xorl %r11d, %r11d
pushq $-0x1
popq %r9
cmpq %rdi, %r8
je 0x4b02
testq %r15, (%r10)
jne 0x4af9
movl -0x10(%r10), %r13d
xorl %r14d, %r13d
xorl %esi, %esi
cmpl $0x1, %r13d
sete %sil
cmovel %edi, %r9d
addl %esi, %r11d
incq %rdi
addq $0x20, %r10
jmp 0x4ad7
cmpl $0x1, %r11d
jne 0x4b47
movl 0x10(%rbp), %r10d
movb $0x1, %r8b
movslq %r9d, %rdi
cmpl $0x7fffffff, %r10d      # imm = 0x7FFFFFFF
je 0x4b3a
movq %rdi, %rsi
shlq $0x5, %rsi
movl 0x14(%rdx,%rsi), %esi
cmpl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
sete %r9b
cmpl %esi, %r10d
sete %r8b
orb %r9b, %r8b
cmpl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
jne 0x4b68
testb %r8b, %r8b
jne 0x4b8a
cmpl $0x2, 0x296a2(%rip)     # 0x2e1f0
jge 0x4bae
incl 0x4(%rsp)
orq %r15, %rax
movq %rax, 0x18(%rbp)
movq 0x8(%rsp), %rdx
incq %rbx
jmp 0x4a56
movq %rdi, %rsi
shlq $0x5, %rsi
movl 0x10(%rdx,%rsi), %esi
cmpl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
sete %r9b
cmpl %esi, %ecx
sete %cl
orb %r9b, %cl
testb %r8b, %cl
je 0x4b47
shlq $0x5, %rdi
movl 0x10(%rdx,%rdi), %eax
cmpl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
je 0x4b9c
movl %eax, 0x14(%rbp)
addq %rdi, %rdx
movl 0x14(%rdx), %eax
cmpl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
je 0x4b5b
movl %eax, 0x10(%rbp)
jmp 0x4b5b
movq 0x29443(%rip), %rax     # 0x2dff8
movq (%rax), %rdi
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x28(%rsp), %rcx
movq 0x18(%rax,%rcx), %rdx
leaq 0x1e79d(%rip), %r9      # 0x2336f
movq 0x20(%rsp), %rcx
movsbl (%rcx,%r9), %ecx
movq 0x30(%rsp), %r10
movl %r10d, %esi
shrl %esi
shlq $0x6, %rsi
movq 0x18(%rax,%rsi), %r8
andl $0x1, %r10d
movsbl (%r10,%r9), %r9d
leaq 0x1e73f(%rip), %rsi     # 0x2333e
xorl %eax, %eax
callq 0x2210
movq 0x18(%rbp), %rax
jmp 0x4b50
incq %r14
jmp 0x4a05
movl 0x4(%rsp), %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq