// File: /workspace/github_c_makefile_star2_O3/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 %ebp, %ebp
testl %r14d, %r14d
je 0x16da
xorl %ecx, %ecx
xorl %ebp, %ebp
movq %rbx, 0x10(%rsp)
movq %r14, 0x8(%rsp)
movq 0x20(%rbx), %rsi
movq (%rsi,%rcx,8), %r11
testl %r11d, %r11d
je 0x16ce
movq 0x8(%rbx), %r15
movq %r11, %r8
shrq $0x20, %r8
shlq $0x4, %r8
movq 0x18(%rbx), %rdx
movl %ecx, %edi
shrl %edi
cmpl $0x0, (%rdx,%rdi,4)
movl %r11d, %edi
js 0x16af
leaq (%r15,%r8), %r10
movq %r8, 0x18(%rsp)
addq %r15, %r8
addq $0x8, %r8
movq %rdi, %rdx
shlq $0x4, %rdx
xorl %ebx, %ebx
movl (%r8,%rbx), %r9d
movb $0x1, (%rax,%r9)
addq $0x10, %rbx
cmpq %rbx, %rdx
jne 0x15d7
decl %r11d
shlq $0x4, %r11
movl (%r10,%r11), %r11d
addl 0x4(%rsp), %r11d
movq %r15, 0x20(%rsp)
leaq 0x8(%r15), %r12
xorl %r13d, %r13d
movq %r13, %r8
shlq $0x4, %r8
movl 0x8(%r10,%r8), %r9d
cmpb $0x1, (%rax,%r9)
jne 0x1667
movq (%rsi,%r9,8), %rbx
movl %ebx, %r9d
testq %r9, %r9
je 0x1667
addq %r10, %r8
movq %rbx, %r14
shrq $0x20, %r14
movl (%r8), %r15d
movl %ebx, %ebx
shlq $0x4, %r14
addq %r12, %r14
shlq $0x4, %rbx
xorl %r8d, %r8d
movl -0x8(%r14,%r8), %r9d
addl %r15d, %r9d
cmpl %r11d, %r9d
ja 0x1667
movl (%r14,%r8), %r9d
cmpb $0x0, (%rax,%r9)
je 0x165e
movb $0x2, (%rax,%r9)
addq $0x10, %r8
cmpq %r8, %rbx
jne 0x1641
incq %r13
cmpq %rdi, %r13
jne 0x1605
movq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdi
addq %rdi, %rsi
addq $0xc, %rsi
xorl %edi, %edi
movq 0x10(%rsp), %rbx
movq 0x8(%rsp), %r14
movl -0x4(%rsi,%rdi), %r8d
cmpb $0x2, (%rax,%r8)
jne 0x169f
orb $-0x80, 0x3(%rsi,%rdi)
incl %ebp
movb $0x0, (%rax,%r8)
addq $0x10, %rdi
cmpq %rdi, %rdx
jne 0x168c
jmp 0x16ce
leaq (%r15,%r8), %rdx
addq $0xc, %rdx
shlq $0x4, %rdi
xorl %esi, %esi
orb $-0x80, 0x3(%rdx,%rsi)
addq $0x10, %rsi
cmpq %rsi, %rdi
jne 0x16bd
addl %r11d, %ebp
incq %rcx
cmpq %r14, %rcx
jne 0x1589
movq %rax, %rdi
callq 0x1040
movq 0xc90f(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x8a11(%rip), %rsi      # 0xa104
leaq 0x8a30(%rip), %rdx      # 0xa12a
movl %ebp, %ecx
xorl %eax, %eax
callq 0x1120
testl %ebp, %ebp
jne 0x1718
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0x40c7
movq %rbx, %rdi
callq 0x1394
movq %rbx, %rdi
callq 0x1480
orb $-0x80, 0x17(%rbx)
jmp 0x1707