// File: /workspace/github_c_makefile_star2_O2/rikuu[P]kermit/miniasm/asg.c
// Function: asg_arc_del_trans
int asg_arc_del_trans(asg_t *g, int fuzz)
{
	uint8_t *mark;
	uint32_t v, n_vtx = g->n_seq * 2, n_reduced = 0;

	mark = (uint8_t*)calloc(n_vtx, 1);
	for (v = 0; v < n_vtx; ++v) {
		uint32_t L, i, nv = asg_arc_n(g, v);
		asg_arc_t *av = asg_arc_a(g, v);
		if (nv == 0) continue; // no hits
		if (g->seq[v>>1].del) {
			for (i = 0; i < nv; ++i) av[i].del = 1, ++n_reduced;
			continue;
		}
		for (i = 0; i < nv; ++i) mark[av[i].v] = 1;
		L = asg_arc_len(av[nv-1]) + fuzz;
		for (i = 0; i < nv; ++i) {
			uint32_t w = av[i].v;
			uint32_t j, nw = asg_arc_n(g, w);
			asg_arc_t *aw = asg_arc_a(g, w);
			if (mark[av[i].v] != 1) continue;
			for (j = 0; j < nw && asg_arc_len(aw[j]) + asg_arc_len(av[i]) <= L; ++j)
				if (mark[aw[j].v]) mark[aw[j].v] = 2;
		}
		#if 0
		for (i = 0; i < nv; ++i) {
			uint32_t w = av[i].v;
			uint32_t j, nw = asg_arc_n(g, w);
			asg_arc_t *aw = asg_arc_a(g, w);
			for (j = 0; j < nw && (j == 0 || asg_arc_len(aw[j]) < fuzz); ++j)
				if (mark[aw[j].v]) mark[aw[j].v] = 2;
		}
		#endif
		for (i = 0; i < nv; ++i) {
			if (mark[av[i].v] == 2) av[i].del = 1, ++n_reduced;
			mark[av[i].v] = 0;
		}
	}
	free(mark);
	fprintf(stderr, "[M::%s] transitively reduced %d arcs\n", __func__, n_reduced);
	if (n_reduced) {
		asg_cleanup(g);
		asg_symm(g);
	}
	return n_reduced;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %esi, 0x4(%rsp)
movq %rdi, %rbx
movl 0x14(%rdi), %r14d
addl %r14d, %r14d
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x10f0
xorl %r8d, %r8d
xorl %ebp, %ebp
movq %rbx, 0x10(%rsp)
movq %r14, 0x8(%rsp)
cmpq %r14, %r8
je 0x288e
movq 0x20(%rbx), %rsi
movq (%rsi,%r8,8), %r11
testl %r11d, %r11d
je 0x2886
movq 0x8(%rbx), %r15
movq %r11, %r9
shrq $0x20, %r9
shlq $0x4, %r9
movq 0x18(%rbx), %rcx
movl %r8d, %edx
shrl %edx
cmpl $0x0, (%rcx,%rdx,4)
movl %r11d, %edi
js 0x2865
movq %r8, 0x20(%rsp)
leaq (%r15,%r9), %r10
movq %rdi, %rdx
shlq $0x4, %rdx
leaq (%r15,%r9), %r8
addq $0x8, %r8
xorl %ebx, %ebx
cmpq %rbx, %rdx
je 0x27a6
movl (%r8,%rbx), %ecx
movb $0x1, (%rax,%rcx)
addq $0x10, %rbx
jmp 0x2793
decl %r11d
shlq $0x4, %r11
movl (%r10,%r11), %r11d
addl 0x4(%rsp), %r11d
movq %r15, 0x18(%rsp)
leaq 0x8(%r15), %r12
xorl %r14d, %r14d
cmpq %rdi, %r14
je 0x2822
movq %r14, %r13
shlq $0x4, %r13
movl 0x8(%r10,%r13), %r8d
cmpb $0x1, (%rax,%r8)
jne 0x281d
addq %r10, %r13
movq (%rsi,%r8,8), %rbx
movl %ebx, %r15d
shrq $0x20, %rbx
shlq $0x4, %r15
shlq $0x4, %rbx
addq %r12, %rbx
xorl %r8d, %r8d
cmpq %r8, %r15
je 0x281d
movl (%r13), %ecx
addl -0x8(%rbx,%r8), %ecx
cmpl %r11d, %ecx
ja 0x281d
movl (%rbx,%r8), %ecx
cmpb $0x0, (%rax,%rcx)
je 0x2817
movb $0x2, (%rax,%rcx)
addq $0x10, %r8
jmp 0x27f6
incq %r14
jmp 0x27c2
movq 0x18(%rsp), %rcx
leaq (%rcx,%r9), %rsi
addq $0xc, %rsi
xorl %edi, %edi
movq 0x10(%rsp), %rbx
movq 0x8(%rsp), %r14
cmpq %rdi, %rdx
je 0x285e
movl -0x4(%rsi,%rdi), %r8d
cmpb $0x2, (%rax,%r8)
jne 0x2853
orb $-0x80, 0x3(%rsi,%rdi)
incl %ebp
movb $0x0, (%rax,%r8)
addq $0x10, %rdi
jmp 0x283b
movq 0x20(%rsp), %r8
jmp 0x2886
shlq $0x4, %rdi
leaq (%r15,%r9), %rdx
addq $0xc, %rdx
xorl %esi, %esi
cmpq %rsi, %rdi
je 0x2883
orb $-0x80, 0x3(%rdx,%rsi)
addq $0x10, %rsi
jmp 0x2873
addl %r11d, %ebp
incq %r8
jmp 0x273a
movq %rax, %rdi
callq 0x1040
movq 0xb75b(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x685d(%rip), %rsi      # 0x9104
leaq 0x687c(%rip), %rdx      # 0x912a
movl %ebp, %ecx
xorl %eax, %eax
callq 0x1120
testl %ebp, %ebp
je 0x28cb
movq %rbx, %rdi
callq 0x2447
movq %rbx, %rdi
callq 0x2586
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq