// File: /workspace/github_c_makefile_star2_O1/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, 0xc(%rsp)
movq %rdi, %rbx
movl 0x14(%rdi), %r15d
addl %r15d, %r15d
pushq $0x1
popq %rsi
movq %r15, %rdi
callq 0x10f0
xorl %ebp, %ebp
testl %r15d, %r15d
je 0x1697
movl %r15d, %r10d
xorl %edx, %edx
xorl %ebp, %ebp
movq %rbx, 0x18(%rsp)
movq %r10, 0x10(%rsp)
movq 0x20(%rbx), %rdi
movq (%rdi,%rdx,8), %r11
testl %r11d, %r11d
je 0x168b
movq 0x8(%rbx), %r14
movq %r11, %r9
shrq $0x20, %r9
shlq $0x4, %r9
movq 0x18(%rbx), %rcx
movl %edx, %esi
shrl %esi
cmpl $0x0, (%rcx,%rsi,4)
movl %r11d, %esi
js 0x166c
leaq (%r14,%r9), %r10
leaq (%r14,%r9), %rcx
addq $0x8, %rcx
shlq $0x4, %rsi
xorl %ebx, %ebx
movl (%rcx,%rbx), %r8d
movb $0x1, (%rax,%r8)
addq $0x10, %rbx
cmpq %rbx, %rsi
jne 0x15a2
leal -0x1(%r11), %ecx
shlq $0x4, %rcx
movl (%r10,%rcx), %r15d
addl 0xc(%rsp), %r15d
movl %r11d, %r11d
movq %r14, 0x20(%rsp)
leaq 0x8(%r14), %r12
xorl %r13d, %r13d
movq %r13, %rbx
shlq $0x4, %rbx
movl 0x8(%r10,%rbx), %ecx
cmpb $0x1, (%rax,%rcx)
jne 0x1624
movq (%rdi,%rcx,8), %rcx
testl %ecx, %ecx
je 0x1624
addq %r10, %rbx
movq %rcx, %r14
shrq $0x20, %r14
movl (%rbx), %ebx
shlq $0x4, %r14
addq %r12, %r14
movl -0x8(%r14), %r8d
addl %ebx, %r8d
cmpl %r15d, %r8d
ja 0x1624
movl (%r14), %r8d
cmpb $0x0, (%rax,%r8)
je 0x161c
movb $0x2, (%rax,%r8)
addq $0x10, %r14
decl %ecx
jne 0x1601
incq %r13
cmpq %r11, %r13
jne 0x15d4
movq 0x20(%rsp), %rcx
addq %r9, %rcx
addq $0xc, %rcx
xorl %edi, %edi
movq 0x18(%rsp), %rbx
movq 0x10(%rsp), %r10
movl -0x4(%rcx,%rdi), %r8d
cmpb $0x2, (%rax,%r8)
jne 0x1657
orb $-0x80, 0x3(%rcx,%rdi)
incl %ebp
movl -0x4(%rcx,%rdi), %r8d
movb $0x0, (%rax,%r8)
addq $0x10, %rdi
cmpq %rdi, %rsi
jne 0x1644
jmp 0x168b
leaq (%r14,%r9), %rcx
addq $0xc, %rcx
shlq $0x4, %rsi
xorl %edi, %edi
orb $-0x80, 0x3(%rcx,%rdi)
addq $0x10, %rdi
cmpq %rdi, %rsi
jne 0x167a
addl %r11d, %ebp
incq %rdx
cmpq %r10, %rdx
jne 0x155b
movq %rax, %rdi
callq 0x1040
movq 0xd952(%rip), %rax      # 0xeff8
movq (%rax), %rdi
leaq 0x8a54(%rip), %rsi      # 0xa104
leaq 0x8a73(%rip), %rdx      # 0xa12a
movl %ebp, %ecx
xorl %eax, %eax
callq 0x1120
testl %ebp, %ebp
jne 0x16d5
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0x41c9
movq %rbx, %rdi
callq 0x1392
movq %rbx, %rdi
callq 0x1461
orb $-0x80, 0x17(%rbx)
jmp 0x16c4