// File: /workspace/github_c_makefile_star2_O1/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 $0x38, %rsp
movq %rdi, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movl 0x14(%rdi), %r13d
movl $0x0, 0x8(%rsp)
addl %r13d, %r13d
je 0x4673
movl %esi, %ebp
xorl %r15d, %r15d
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movl $0x0, 0x8(%rsp)
movl %esi, 0xc(%rsp)
movq 0x18(%rbx), %rax
movl %r15d, %ecx
shrl %ecx
cmpl $0x0, (%rax,%rcx,4)
js 0x4667
movq 0x8(%rbx), %rax
movq 0x20(%rbx), %rcx
movl %r15d, %r14d
xorl $0x1, %r14d
movq (%rcx,%r14,8), %rdi
movq %rdi, %rdx
shrq $0x20, %rdx
shlq $0x4, %rdx
xorl %esi, %esi
andq %r12, %rdi
je 0x4470
leaq (%rax,%rdx), %r9
addq $0xc, %r9
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
xorl %r10d, %r10d
xorl %r11d, %r11d
cmpl $0x0, (%r9)
setns %r11b
cmovnsl %r10d, %r8d
addl %r11d, %esi
incq %r10
addq $0x10, %r9
cmpq %r10, %rdi
jne 0x4446
movslq %r8d, %rdi
cmpl $0x1, %esi
sete %sil
jmp 0x4477
movq $-0x1, %rdi
testb %sil, %sil
je 0x4667
addq %rax, %rdx
shlq $0x4, %rdi
movl 0x8(%rdx,%rdi), %edx
xorq $0x1, %rdx
movq (%rcx,%rdx,8), %rdx
movq %rdx, %rcx
andq %r12, %rcx
je 0x44ce
shrq $0x20, %rdx
shlq $0x4, %rcx
shlq $0x4, %rdx
addq %rdx, %rax
addq $0xc, %rax
xorl %edx, %edx
xorl %esi, %esi
movl (%rax,%rdx), %edi
notl %edi
shrl $0x1f, %edi
addl %edi, %esi
addq $0x10, %rdx
cmpq %rdx, %rcx
jne 0x44b2
cmpl $0x1, %esi
je 0x4667
movq %rbx, %rdi
movl %r15d, %esi
movl %ebp, %edx
leaq 0x10(%rsp), %rcx
callq 0x4218
cmpl $0x2, %eax
jne 0x4667
movq 0x8(%rbx), %r11
movq 0x20(%rbx), %rdi
movq (%rdi,%r14,8), %rax
testl %eax, %eax
je 0x4534
movq %rax, %rcx
shrq $0x20, %rcx
movl %eax, %edx
shlq $0x4, %rcx
leaq (%r11,%rcx), %rsi
addq $0xc, %rsi
shlq $0x4, %rdx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %r8d, %r8d
cmpl $0x0, (%rsi,%r8)
js 0x4529
movl -0x4(%rsi,%r8), %eax
xorl $0x1, %eax
addq $0x10, %r8
cmpq %r8, %rdx
jne 0x451a
jmp 0x4539
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl $-0x1, %eax
je 0x4697
movq 0x10(%rsp), %rcx
movq 0x20(%rsp), %rdx
movq -0x8(%rdx,%rcx,8), %rdx
movq %rdx, 0x30(%rsp)
movl %edx, %esi
xorl $0x1, %esi
movl %eax, %ecx
movq (%rdi,%rcx,8), %r9
movq %r9, %r8
shrq $0x20, %r8
movq %r9, %rdi
andq %r12, %rdi
movq %r11, 0x28(%rsp)
je 0x45ba
movl %r9d, %r10d
movq %r8, %rcx
shlq $0x4, %rcx
leaq (%r11,%rcx), %rbp
addq $0xc, %rbp
shlq $0x4, %r10
xorl %r12d, %r12d
xorl %r14d, %r14d
xorl %r11d, %r11d
movl (%rbp,%r12), %ecx
testl %ecx, %ecx
js 0x45af
movl -0x4(%rbp,%r12), %edx
cmpl %esi, %edx
cmovel %ecx, %r14d
cmpl %r15d, %edx
cmovel %ecx, %r11d
addq $0x10, %r12
cmpq %r12, %r10
jne 0x4594
jmp 0x45c0
xorl %r11d, %r11d
xorl %r14d, %r14d
movl %r11d, %ecx
orl %r14d, %ecx
je 0x465d
cmpl %r14d, %r11d
movl 0xc(%rsp), %ebp
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
jbe 0x4667
testl %r9d, %r9d
je 0x4611
shlq $0x4, %rdi
shlq $0x4, %r8
movq 0x28(%rsp), %rcx
addq %r8, %rcx
addq $0xc, %rcx
xorl %r8d, %r8d
cmpl %esi, -0x4(%rcx,%r8)
jne 0x4608
orb $-0x80, 0x3(%rcx,%r8)
addq $0x10, %r8
cmpq %r8, %rdi
jne 0x45fb
movl 0x30(%rsp), %ecx
movq 0x20(%rbx), %rdx
movq (%rdx,%rcx,8), %rdx
movq %rdx, %rcx
andq %r12, %rcx
je 0x4657
movq 0x8(%rbx), %rsi
shrq $0x20, %rdx
shlq $0x4, %rcx
shlq $0x4, %rdx
addq %rsi, %rdx
addq $0xc, %rdx
xorl %esi, %esi
movl -0x4(%rdx,%rsi), %edi
xorl %eax, %edi
cmpl $0x1, %edi
jne 0x464e
orb $-0x80, 0x3(%rdx,%rsi)
addq $0x10, %rsi
cmpq %rsi, %rcx
jne 0x463e
incl 0x8(%rsp)
jmp 0x4667
movl 0xc(%rsp), %ebp
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
incl %r15d
cmpl %r13d, %r15d
jne 0x43fd
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
movl 0x8(%rsp), %ebx
movl %ebx, %esi
callq 0x1b5d
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5af3(%rip), %rdi      # 0xa191
leaq 0x5afc(%rip), %rsi      # 0xa1a1
leaq 0x5b03(%rip), %rcx      # 0xa1af
movl $0x120, %edx            # imm = 0x120
callq 0x10c0