// File: /workspace/github_cpp_makefile_star2_O1/Laakeri[P]Triangulator/src/minfill.cpp
// Function: MinFill::SolveAtom::greedyDegree2(Graph&)
vector<pair<int, int> > greedyDegree2(Graph& G) {
	queue<int> d1;
	queue<int> d2;
	for (int i = 0; i < G.n; i++) {
		assert(G.g[i].size() > 1);
		if (G.g[i].size() == 2) {
			d2.push(i);
		}
	}
	vector<pair<int, int> > sol;
	while (!d1.empty() || !d2.empty()) {
		while (!d1.empty()) {
			int x = d1.front();
			d1.pop();
			assert(G.g[x].size() <= 1);
			if (G.g[x].size() == 0) continue;
			int n1 = G.g[x][0];
			G.remEdge(x, n1);
			if (G.g[n1].size() == 1) d1.push(n1);
			if (G.g[n1].size() == 2) d2.push(n1);
		}
		if (!d2.empty()) {
			int x = d2.front();
			d2.pop();
			assert(G.g[x].size() == 0 || G.g[x].size() == 2);
			if (G.g[x].size() == 0) continue;
			int n1 = G.g[x][0];
			int n2 = G.g[x][1];
			if (!G.hasEdge(n1, n2)) {
				sol.push_back({n1, n2});
				G.addEdge(n1, n2);
			}
			G.remEdge(x, n1);
			G.remEdge(x, n2);
			if (G.g[n1].size() == 1) d1.push(n1);
			if (G.g[n1].size() == 2) d2.push(n1);
			if (G.g[n2].size() == 1) d1.push(n2);
			if (G.g[n2].size() == 2) d2.push(n2);
		}
	}
	return sol;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rsi, %r14
movq %rdi, %rbx
xorps %xmm0, %xmm0
leaq 0x60(%rsp), %rdi
movaps %xmm0, 0x40(%rdi)
movaps %xmm0, 0x30(%rdi)
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
xorl %esi, %esi
callq 0x1af06
leaq 0x10(%rsp), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rdi)
movaps %xmm0, 0x30(%rdi)
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
xorl %esi, %esi
callq 0x1af06
movl $0x0, 0x8(%rsp)
cmpl $0x0, 0x50(%r14)
jle 0x189bb
xorl %eax, %eax
leaq 0x10(%rsp), %r15
leaq 0x8(%rsp), %r12
movslq %eax, %rcx
movq 0x38(%r14), %rdx
leaq (%rcx,%rcx,2), %rsi
movq 0x8(%rdx,%rsi,8), %rcx
subq (%rdx,%rsi,8), %rcx
cmpq $0x4, %rcx
jbe 0x18dd4
cmpq $0x8, %rcx
jne 0x189ab
movq 0x40(%rsp), %rcx
movq 0x50(%rsp), %rdx
addq $-0x4, %rdx
cmpq %rdx, %rcx
je 0x189a0
movl %eax, (%rcx)
addq $0x4, %rcx
movq %rcx, 0x40(%rsp)
jmp 0x189ab
movq %r15, %rdi
movq %r12, %rsi
callq 0x1b07c
movl 0x8(%rsp), %eax
incl %eax
movl %eax, 0x8(%rsp)
cmpl 0x50(%r14), %eax
jl 0x1895c
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
leaq 0x60(%rsp), %r15
leaq 0x10(%rsp), %r13
leaq 0x8(%rsp), %r12
movq 0x90(%rsp), %rax
cmpq 0x70(%rsp), %rax
jne 0x189f7
movq 0x40(%rsp), %rax
cmpq 0x20(%rsp), %rax
je 0x18d6d
movq 0x70(%rsp), %rax
cmpq %rax, 0x90(%rsp)
je 0x18b48
movslq (%rax), %rbp
movq 0x80(%rsp), %rcx
addq $-0x4, %rcx
cmpq %rcx, %rax
je 0x18a24
addq $0x4, %rax
jmp 0x18a5f
movq 0x78(%rsp), %rdi
movl $0x200, %esi            # imm = 0x200
callq 0x2210
movq 0x88(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x88(%rsp)
movq 0x8(%rax), %rax
movq %rax, 0x78(%rsp)
leaq 0x200(%rax), %rcx
movq %rcx, 0x80(%rsp)
movq %rax, 0x70(%rsp)
movq 0x38(%r14), %rcx
leaq (,%rbp,2), %rdx
addq %rbp, %rdx
movq (%rcx,%rdx,8), %rax
movq 0x8(%rcx,%rdx,8), %rcx
movq %rcx, %rdx
subq %rax, %rdx
cmpq $0x5, %rdx
jae 0x18d96
cmpq %rax, %rcx
je 0x189f7
movl (%rax), %edx
movl %edx, 0x8(%rsp)
movq %r14, %rdi
movl %ebp, %esi
callq 0x98b2
movslq 0x8(%rsp), %rax
movq 0x38(%r14), %rcx
leaq (%rax,%rax,2), %rdx
movq 0x8(%rcx,%rdx,8), %rsi
subq (%rcx,%rdx,8), %rsi
cmpq $0x4, %rsi
jne 0x18af5
movq 0x90(%rsp), %rcx
movq 0xa0(%rsp), %rdx
addq $-0x4, %rdx
cmpq %rdx, %rcx
je 0x18aea
movl %eax, (%rcx)
addq $0x4, %rcx
movq %rcx, 0x90(%rsp)
jmp 0x18af5
movq %r15, %rdi
movq %r12, %rsi
callq 0x1b07c
movslq 0x8(%rsp), %rax
movq 0x38(%r14), %rcx
leaq (%rax,%rax,2), %rdx
movq 0x8(%rcx,%rdx,8), %rsi
subq (%rcx,%rdx,8), %rsi
cmpq $0x8, %rsi
jne 0x189f7
movq 0x40(%rsp), %rcx
movq 0x50(%rsp), %rdx
addq $-0x4, %rdx
cmpq %rdx, %rcx
je 0x18b38
movl %eax, (%rcx)
addq $0x4, %rcx
movq %rcx, 0x40(%rsp)
jmp 0x189f7
movq %r13, %rdi
movq %r12, %rsi
callq 0x1b07c
jmp 0x189f7
movq 0x20(%rsp), %rax
cmpq %rax, 0x40(%rsp)
je 0x189d8
movslq (%rax), %rbp
movq 0x30(%rsp), %rcx
addq $-0x4, %rcx
cmpq %rcx, %rax
je 0x18b6f
addq $0x4, %rax
jmp 0x18ba1
movq 0x28(%rsp), %rdi
movl $0x200, %esi            # imm = 0x200
callq 0x2210
movq 0x38(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x38(%rsp)
movq 0x8(%rax), %rax
movq %rax, 0x28(%rsp)
leaq 0x200(%rax), %rcx
movq %rcx, 0x30(%rsp)
movq %rax, 0x20(%rsp)
movq 0x38(%r14), %rcx
leaq (,%rbp,2), %rdx
addq %rbp, %rdx
movq (%rcx,%rdx,8), %rax
movq 0x8(%rcx,%rdx,8), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
je 0x189d8
cmpq $0x2, %rcx
jne 0x18db5
movl (%rax), %esi
movl %esi, 0x4(%rsp)
movl 0x4(%rax), %edx
movl %edx, (%rsp)
movq %r14, %rdi
callq 0x9b60
testb %al, %al
jne 0x18c16
movl 0x4(%rsp), %eax
movl %eax, 0x8(%rsp)
movl (%rsp), %eax
movl %eax, 0xc(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0xafe4
movl 0x4(%rsp), %esi
movl (%rsp), %edx
movq %r14, %rdi
callq 0x9512
movl 0x4(%rsp), %edx
movq %r14, %rdi
movl %ebp, %esi
callq 0x98b2
movl (%rsp), %edx
movq %r14, %rdi
movl %ebp, %esi
callq 0x98b2
movslq 0x4(%rsp), %rax
movq 0x38(%r14), %rcx
leaq (%rax,%rax,2), %rdx
movq 0x8(%rcx,%rdx,8), %rsi
subq (%rcx,%rdx,8), %rsi
cmpq $0x4, %rsi
jne 0x18c83
movq 0x90(%rsp), %rcx
movq 0xa0(%rsp), %rdx
addq $-0x4, %rdx
cmpq %rdx, %rcx
je 0x18c76
movl %eax, (%rcx)
addq $0x4, %rcx
movq %rcx, 0x90(%rsp)
jmp 0x18c83
movq %r15, %rdi
leaq 0x4(%rsp), %rsi
callq 0x1b07c
movslq 0x4(%rsp), %rax
movq 0x38(%r14), %rcx
leaq (%rax,%rax,2), %rdx
movq 0x8(%rcx,%rdx,8), %rsi
subq (%rcx,%rdx,8), %rsi
cmpq $0x8, %rsi
jne 0x18ccc
movq 0x40(%rsp), %rcx
movq 0x50(%rsp), %rdx
addq $-0x4, %rdx
cmpq %rdx, %rcx
je 0x18cbf
movl %eax, (%rcx)
addq $0x4, %rcx
movq %rcx, 0x40(%rsp)
jmp 0x18ccc
movq %r13, %rdi
leaq 0x4(%rsp), %rsi
callq 0x1b07c
movslq (%rsp), %rax
movq 0x38(%r14), %rcx
leaq (%rax,%rax,2), %rdx
movq 0x8(%rcx,%rdx,8), %rsi
subq (%rcx,%rdx,8), %rsi
cmpq $0x4, %rsi
jne 0x18d1b
movq 0x90(%rsp), %rcx
movq 0xa0(%rsp), %rdx
addq $-0x4, %rdx
cmpq %rdx, %rcx
je 0x18d10
movl %eax, (%rcx)
addq $0x4, %rcx
movq %rcx, 0x90(%rsp)
jmp 0x18d1b
movq %r15, %rdi
movq %rsp, %rsi
callq 0x1b07c
movslq (%rsp), %rax
movq 0x38(%r14), %rcx
leaq (%rax,%rax,2), %rdx
movq 0x8(%rcx,%rdx,8), %rsi
subq (%rcx,%rdx,8), %rsi
cmpq $0x8, %rsi
jne 0x189d8
movq 0x40(%rsp), %rcx
movq 0x50(%rsp), %rdx
addq $-0x4, %rdx
cmpq %rdx, %rcx
je 0x18d5d
movl %eax, (%rcx)
addq $0x4, %rcx
movq %rcx, 0x40(%rsp)
jmp 0x189d8
movq %r13, %rdi
movq %rsp, %rsi
callq 0x1b07c
jmp 0x189d8
leaq 0x10(%rsp), %rdi
callq 0x1aa48
leaq 0x60(%rsp), %rdi
callq 0x1aa48
movq %rbx, %rax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1272a(%rip), %rdi     # 0x2b4c7
leaq 0x12364(%rip), %rsi     # 0x2b108
leaq 0x126da(%rip), %rcx     # 0x2b485
movl $0x1c1, %edx            # imm = 0x1C1
callq 0x2140
leaq 0x1271e(%rip), %rdi     # 0x2b4da
leaq 0x12345(%rip), %rsi     # 0x2b108
leaq 0x126bb(%rip), %rcx     # 0x2b485
movl $0x1cb, %edx            # imm = 0x1CB
callq 0x2140
leaq 0x12698(%rip), %rdi     # 0x2b473
leaq 0x12326(%rip), %rsi     # 0x2b108
leaq 0x1269c(%rip), %rcx     # 0x2b485
movl $0x1b7, %edx            # imm = 0x1B7
callq 0x2140
movq %rax, %r14
jmp 0x18e22
movq %rax, %r14
jmp 0x18e18
jmp 0x18e01
jmp 0x18e01
movq %rax, %r14
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x18e18
movq 0x10(%rbx), %rsi
subq %rdi, %rsi
callq 0x2210
leaq 0x10(%rsp), %rdi
callq 0x1aa48
leaq 0x60(%rsp), %rdi
callq 0x1aa48
movq %r14, %rdi
callq 0x2310