// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
leaq -0x28(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x10c0
movq -0x8(%rbp), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movl %eax, -0x2c(%rbp)
movl $0x0, -0x38(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jae 0x4791
movl $0xffffffff, -0x44(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x50(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x30(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x455e
jmp 0x4783
movq -0x8(%rbp), %rdi
movl -0x30(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x3fc0
cmpl $0x3, %eax
je 0x4578
jmp 0x4783
movq -0x8(%rbp), %rdi
movl -0x30(%rbp), %esi
movl -0xc(%rbp), %edx
leaq -0x28(%rbp), %rcx
callq 0x3e40
cmpl $0x2, %eax
je 0x4595
jmp 0x4783
movq -0x18(%rbp), %rax
movq -0x28(%rbp), %rcx
subq $0x1, %rcx
movq (%rax,%rcx,8), %rax
xorl $0x1, %eax
movl %eax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x30(%rbp), %ecx
xorl $0x1, %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x3c(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x20(%rcx), %rcx
movl -0x30(%rbp), %edx
xorl $0x1, %edx
movl %edx, %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jae 0x4639
movq -0x58(%rbp), %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
jne 0x462c
movq -0x58(%rbp), %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
xorl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x462e
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x45f4
cmpl $-0x1, -0x44(%rbp)
je 0x4641
jmp 0x4660
leaq 0xab21(%rip), %rdi      # 0xf169
leaq 0xab2a(%rip), %rsi      # 0xf179
movl $0x120, %edx            # imm = 0x120
leaq 0xab2c(%rip), %rcx      # 0xf187
callq 0x10b0
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x44(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x20(%rcx), %rcx
movl -0x44(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x40(%rbp), %eax
jae 0x4734
movq -0x60(%rbp), %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x46c6
jmp 0x4726
movq -0x60(%rbp), %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
cmpl -0x48(%rbp), %eax
jne 0x46f5
movq -0x60(%rbp), %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, -0x50(%rbp)
movq -0x60(%rbp), %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
cmpl -0x30(%rbp), %eax
jne 0x4724
movq -0x60(%rbp), %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, -0x4c(%rbp)
jmp 0x4726
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x469f
cmpl $0x0, -0x4c(%rbp)
jne 0x4742
cmpl $0x0, -0x50(%rbp)
jne 0x4742
jmp 0x4783
movl -0x4c(%rbp), %eax
cmpl -0x50(%rbp), %eax
jbe 0x4781
movq -0x8(%rbp), %rdi
movl -0x44(%rbp), %esi
movl -0x48(%rbp), %edx
movl $0x1, %ecx
callq 0x47e0
movq -0x8(%rbp), %rdi
movl -0x48(%rbp), %esi
xorl $0x1, %esi
movl -0x44(%rbp), %edx
xorl $0x1, %edx
movl $0x1, %ecx
callq 0x47e0
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x4783
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x451e
movq -0x18(%rbp), %rdi
callq 0x1040
cmpl $0x0, -0x38(%rbp)
jbe 0x47a9
movq -0x8(%rbp), %rdi
callq 0x35d0
movq 0xe848(%rip), %rax      # 0x12ff8
movq (%rax), %rdi
movl -0x38(%rbp), %ecx
leaq 0xa9eb(%rip), %rsi      # 0xf1a8
leaq 0xaa03(%rip), %rdx      # 0xf1c7
movb $0x0, %al
callq 0x1110
movl -0x38(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)