// File: /workspace/github_c_makefile_star2_O2/rikuu[P]kermit/miniasm/asg.c
// Function: asg_cut_biloop
int asg_cut_biloop(asg_t *g, int max_ext)
{
	asg64_v a = {0,0,0};
	uint32_t n_vtx = g->n_seq * 2, v, i, cnt = 0;
	for (v = 0; v < n_vtx; ++v) {
		uint32_t nv, nw, w = UINT32_MAX, x, ov = 0, ox = 0;
		asg_arc_t *av, *aw;
		if (g->seq[v>>1].del) continue;
		if (asg_is_utg_end(g, v, 0) != ASG_ET_MULTI_NEI) continue;
		if (asg_extend(g, v, max_ext, &a) != ASG_ET_MULTI_OUT) continue;
		x = (uint32_t)a.a[a.n - 1] ^ 1;
		nv = asg_arc_n(g, v ^ 1), av = asg_arc_a(g, v ^ 1);
		for (i = 0; i < nv; ++i)
			if (!av[i].del) w = av[i].v ^ 1;
		assert(w != UINT32_MAX);
		nw = asg_arc_n(g, w), aw = asg_arc_a(g, w);
		for (i = 0; i < nw; ++i) { // we are looking for: v->...->x', w->v and w->x
			if (aw[i].del) continue;
			if (aw[i].v == x) ox = aw[i].ol;
			if (aw[i].v == v) ov = aw[i].ol;
		}
		if (ov == 0 && ox == 0) continue;
		if (ov > ox) {
			asg_arc_del(g, w, x, 1);
			asg_arc_del(g, x^1, w^1, 1);
			++cnt;
		}
	}
	free(a.a);
	if (cnt > 0) asg_cleanup(g);
	fprintf(stderr, "[M::%s] cut %d small bi-loops\n", __func__, cnt);
	return cnt;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %esi, %ebp
movq %rdi, %r14
leaq 0x10(%rsp), %rbx
andq $0x0, 0x10(%rbx)
xorps %xmm0, %xmm0
movaps %xmm0, (%rbx)
movl 0x14(%rdi), %r15d
addl %r15d, %r15d
movq $0x0, 0x8(%rsp)
xorl %r13d, %r13d
movl %esi, 0x4(%rsp)
cmpl %r15d, %r13d
je 0x2e70
movq 0x18(%r14), %rax
movl %r13d, %ecx
shrl %ecx
cmpl $0x0, (%rax,%rcx,4)
js 0x2e68
movq %r14, %rdi
movl %r13d, %esi
xorl %edx, %edx
callq 0x29a5
cmpl $0x3, %eax
jne 0x2e68
movq %r14, %rdi
movl %r13d, %esi
movl %ebp, %edx
movq %rbx, %rcx
callq 0x28dc
cmpl $0x2, %eax
jne 0x2e68
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movl -0x8(%rcx,%rax,8), %r12d
movq 0x8(%r14), %rax
movq 0x20(%r14), %rcx
movl %r13d, %edx
xorl $0x1, %edx
movq (%rcx,%rdx,8), %rsi
movl %esi, %edx
shlq $0x4, %rdx
shrq $0x1c, %rsi
andq $-0x10, %rsi
addq %rax, %rsi
addq $0xc, %rsi
xorl %edi, %edi
pushq $-0x1
popq %rbx
cmpq %rdi, %rdx
je 0x2dcf
cmpl $0x0, (%rsi,%rdi)
js 0x2dc9
movl -0x4(%rsi,%rdi), %ebx
xorl $0x1, %ebx
addq $0x10, %rdi
jmp 0x2db7
cmpl $-0x1, %ebx
je 0x2ebd
movl %r12d, %edx
xorl $0x1, %edx
movl %ebx, %esi
movq (%rcx,%rsi,8), %rsi
movl %esi, %ecx
shlq $0x4, %rcx
shrq $0x1c, %rsi
andq $-0x10, %rsi
leaq (%rax,%rsi), %rdi
addq $0xc, %rdi
xorl %r8d, %r8d
xorl %eax, %eax
xorl %esi, %esi
cmpq %r8, %rcx
je 0x2e28
movl (%rdi,%r8), %r9d
testl %r9d, %r9d
js 0x2e22
movl -0x4(%rdi,%r8), %r10d
cmpl %edx, %r10d
cmovel %r9d, %esi
cmpl %r13d, %r10d
cmovel %r9d, %eax
addq $0x10, %r8
jmp 0x2e01
movl %eax, %ecx
orl %esi, %ecx
je 0x2e5f
cmpl %esi, %eax
jbe 0x2e5f
movq %r14, %rdi
movl %ebx, %esi
pushq $0x1
popq %rbp
movl %ebp, %ecx
callq 0x2edc
xorl $0x1, %ebx
movq %r14, %rdi
movl %r12d, %esi
movl %ebx, %edx
movl %ebp, %ecx
callq 0x2edc
movq 0x8(%rsp), %rax
incl %eax
movq %rax, 0x8(%rsp)
leaq 0x10(%rsp), %rbx
movl 0x4(%rsp), %ebp
incl %r13d
jmp 0x2d31
movq 0x20(%rsp), %rdi
callq 0x1040
movq 0x8(%rsp), %rbx
testl %ebx, %ebx
je 0x2e8b
movq %r14, %rdi
callq 0x2447
movq 0xb166(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x6334(%rip), %rsi      # 0x91d0
leaq 0x634c(%rip), %rdx      # 0x91ef
movl %ebx, %ecx
xorl %eax, %eax
callq 0x1120
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x62cd(%rip), %rdi      # 0x9191
leaq 0x62d6(%rip), %rsi      # 0x91a1
leaq 0x62dd(%rip), %rcx      # 0x91af
movl $0x120, %edx            # imm = 0x120
callq 0x10c0