// File: /workspace/github_c_makefile_star2_O0/lh3[P]minigraph/gfa-base.c
// Function: gfa_fix_multi
uint32_t gfa_fix_multi(gfa_t *g)
{
	uint32_t v, n_vtx = gfa_n_vtx(g), n_rm = 0;
	int32_t max_nv = -1;
	uint64_t *buf; // actually, uint32_t is enough
	for (v = 0; v < n_vtx; ++v) {
		int32_t nv = gfa_arc_n(g, v);
		max_nv = max_nv > nv? max_nv : nv;
	}
	if (max_nv == 1) return 0;
	GFA_MALLOC(buf, max_nv);
	for (v = 0; v < n_vtx; ++v) {
		int32_t i, j, s, nv = gfa_arc_n(g, v), nb;
		gfa_arc_t *av = gfa_arc_a(g, v);
		for (i = j = 0; i < nv; ++i)
			if (!av[i].del) buf[j++] = (uint64_t)av[i].w<<32 | i;
		nb = j;
		if (nb < 1) continue;
		radix_sort_gfa64(buf, buf + nb);
		for (s = 0, i = 1; i <= nb; ++i) {
			if (i == nv || buf[i]>>32 != buf[s]>>32) {
				if (i - s > 1) {
					int32_t k = (int32_t)buf[s], min_rank = av[k].rank; // prefer longest overlap
					for (j = s + 1; j < i; ++j) { // rank has higher priority
						int32_t t = (int32_t)buf[j];
						if (av[t].rank >= 0 && av[t].rank < min_rank)
							min_rank = av[t].rank, k = t;
					}
					if (av[k].w == (v^1)) { // a weird loop
						if (gfa_verbose >= 2)
							fprintf(stderr, "[W::%s] can't fix multiple edges due to '>v -- <v' involving segment %s\n", __func__, g->seg[v>>1].name);
					} else {
						int32_t nw = gfa_arc_n(g, av[k].w^1), n_wdel;
						gfa_arc_t *aw = gfa_arc_a(g, av[k].w^1);
						uint64_t link_id = av[k].link_id;
						n_rm += i - s - 1;
						for (j = s + 1; j < i; ++j)
							av[(int32_t)buf[j]].del = 1;
						for (j = 0, n_wdel = 0; j < nw; ++j)
							if (aw[j].w == (v^1) && aw[j].link_id != link_id)
								aw[j].del = 1, ++n_wdel;
						assert(n_wdel == i - s - 1);
					}
				}
				s = i;
			}
		}
	}
	free(buf);
	if (n_rm > 0) {
		if (gfa_verbose >= 2)
			fprintf(stderr, "[W::%s] removed %d multiple link(s)\n", __func__, n_rm);
		gfa_arc_rm(g);
		gfa_arc_index(g);
	}
	return n_rm;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
shll %eax
movl %eax, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0xffffffff, -0x20(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x18(%rbp), %eax
jae 0x6f41
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movl -0x14(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x2c(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jle 0x6f2a
movl -0x20(%rbp), %eax
movl %eax, -0x74(%rbp)
jmp 0x6f30
movl -0x2c(%rbp), %eax
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x6f00
cmpl $0x1, -0x20(%rbp)
jne 0x6f53
movl $0x0, -0x4(%rbp)
jmp 0x73d8
movslq -0x20(%rbp), %rdi
shlq $0x3, %rdi
callq 0x2280
movq %rax, -0x28(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x18(%rbp), %eax
jae 0x7386
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movl -0x14(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x58(%rcx), %rcx
movl -0x14(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0x7028
movq -0x48(%rbp), %rax
movslq -0x30(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
shrq $0x3e, %rax
andq $0x1, %rax
cmpq $0x0, %rax
jne 0x701b
movq -0x48(%rbp), %rax
movslq -0x30(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, %edx
shlq $0x20, %rdx
movslq -0x30(%rbp), %rax
orq %rax, %rdx
movq -0x28(%rbp), %rax
movl -0x34(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x34(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x701d
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x6fbd
movl -0x34(%rbp), %eax
movl %eax, -0x40(%rbp)
cmpl $0x1, -0x40(%rbp)
jge 0x7039
jmp 0x7378
movq -0x28(%rbp), %rdi
movq -0x28(%rbp), %rsi
movslq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x5440
movl $0x0, -0x38(%rbp)
movl $0x1, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x40(%rbp), %eax
jg 0x7376
movl -0x30(%rbp), %eax
cmpl -0x3c(%rbp), %eax
je 0x709c
movq -0x28(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movq -0x28(%rbp), %rcx
movslq -0x38(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
cmpq %rcx, %rax
je 0x7366
movl -0x30(%rbp), %eax
subl -0x38(%rbp), %eax
cmpl $0x1, %eax
jle 0x7360
movq -0x28(%rbp), %rax
movslq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, -0x4c(%rbp)
movq -0x48(%rbp), %rax
movslq -0x4c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
movl %eax, -0x50(%rbp)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x30(%rbp), %eax
jge 0x7143
movq -0x28(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, -0x54(%rbp)
movq -0x48(%rbp), %rax
movslq -0x54(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $0x0, 0xc(%rax)
jl 0x7136
movq -0x48(%rbp), %rax
movslq -0x54(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
cmpl -0x50(%rbp), %eax
jge 0x7136
movq -0x48(%rbp), %rax
movslq -0x54(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
movl %eax, -0x50(%rbp)
movl -0x54(%rbp), %eax
movl %eax, -0x4c(%rbp)
jmp 0x7138
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x70d8
movq -0x48(%rbp), %rax
movslq -0x4c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl -0x14(%rbp), %ecx
xorl $0x1, %ecx
cmpl %ecx, %eax
jne 0x71a6
cmpl $0x2, 0x3e07a(%rip)     # 0x451e0
jl 0x71a1
movq 0x3de89(%rip), %rax     # 0x44ff8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x14(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
shlq $0x6, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rcx
leaq 0x351cf(%rip), %rsi     # 0x3c362
leaq 0x35211(%rip), %rdx     # 0x3c3ab
movb $0x0, %al
callq 0x2210
jmp 0x735e
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x48(%rbp), %rcx
movslq -0x4c(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %ecx
xorl $0x1, %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x58(%rcx), %rcx
movq -0x48(%rbp), %rdx
movslq -0x4c(%rbp), %rsi
shlq $0x5, %rsi
addq %rsi, %rdx
movl 0x8(%rdx), %edx
xorl $0x1, %edx
movl %edx, %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x48(%rbp), %rcx
movslq -0x4c(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rcx
movabsq $0x1fffffffffffffff, %rax # imm = 0x1FFFFFFFFFFFFFFF
andq 0x18(%rcx), %rax
movq %rax, -0x70(%rbp)
movl -0x30(%rbp), %eax
subl -0x38(%rbp), %eax
subl $0x1, %eax
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x30(%rbp), %eax
jge 0x728b
movq -0x48(%rbp), %rax
movq -0x28(%rbp), %rcx
movslq -0x34(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq %ecx, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movabsq $-0x4000000000000001, %rcx # imm = 0xBFFFFFFFFFFFFFFF
andq 0x18(%rax), %rcx
movabsq $0x4000000000000000, %rdx # imm = 0x4000000000000000
orq %rdx, %rcx
movq %rcx, 0x18(%rax)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x723f
movl $0x0, -0x34(%rbp)
movl $0x0, -0x5c(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x58(%rbp), %eax
jge 0x732b
movq -0x68(%rbp), %rax
movslq -0x34(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl -0x14(%rbp), %ecx
xorl $0x1, %ecx
cmpl %ecx, %eax
jne 0x731b
movq -0x68(%rbp), %rcx
movslq -0x34(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rcx
movabsq $0x1fffffffffffffff, %rax # imm = 0x1FFFFFFFFFFFFFFF
andq 0x18(%rcx), %rax
cmpq -0x70(%rbp), %rax
je 0x731b
movq -0x68(%rbp), %rax
movslq -0x34(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movabsq $-0x4000000000000001, %rcx # imm = 0xBFFFFFFFFFFFFFFF
andq 0x18(%rax), %rcx
movabsq $0x4000000000000000, %rdx # imm = 0x4000000000000000
orq %rdx, %rcx
movq %rcx, 0x18(%rax)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x731d
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x7299
movl -0x5c(%rbp), %eax
movl -0x30(%rbp), %ecx
subl -0x38(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x733d
jmp 0x735c
leaq 0x35075(%rip), %rdi     # 0x3c3b9
leaq 0x34e95(%rip), %rsi     # 0x3c1e0
movl $0x194, %edx            # imm = 0x194
leaq 0x35076(%rip), %rcx     # 0x3c3cd
callq 0x2170
jmp 0x735e
jmp 0x7360
movl -0x30(%rbp), %eax
movl %eax, -0x38(%rbp)
jmp 0x7368
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x705f
jmp 0x7378
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x6f6b
movq -0x28(%rbp), %rdi
callq 0x2040
cmpl $0x0, -0x1c(%rbp)
jbe 0x73d2
cmpl $0x2, 0x3de44(%rip)     # 0x451e0
jl 0x73c0
movq 0x3dc53(%rip), %rax     # 0x44ff8
movq (%rax), %rdi
movl -0x1c(%rbp), %ecx
leaq 0x3503b(%rip), %rsi     # 0x3c3ed
leaq 0x34ff2(%rip), %rdx     # 0x3c3ab
movb $0x0, %al
callq 0x2210
movq -0x10(%rbp), %rdi
callq 0x6a80
movq -0x10(%rbp), %rdi
callq 0x6140
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)