// File: /workspace/github_cpp_makefile_star2_O2/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, 0x10(%rsp)
leaq 0x68(%rsp), %rdi
callq 0x141f4
leaq 0x18(%rsp), %rdi
callq 0x141f4
xorl %eax, %eax
leaq 0x18(%rsp), %rbx
leaq 0x8(%rsp), %r15
movl %eax, 0x8(%rsp)
cmpl 0x50(%r14), %eax
jge 0x12ece
movslq %eax, %rcx
movq 0x38(%r14), %rdx
imulq $0x18, %rcx, %rsi
movq 0x8(%rdx,%rsi), %rcx
subq (%rdx,%rsi), %rcx
cmpq $0x4, %rcx
jbe 0x1316e
cmpq $0x8, %rcx
jne 0x12eca
movq %rbx, %rdi
movq %r15, %rsi
callq 0x148c6
movl 0x8(%rsp), %eax
incl %eax
jmp 0x12e8d
xorps %xmm0, %xmm0
movq 0x10(%rsp), %rax
movups %xmm0, (%rax)
andq $0x0, 0x10(%rax)
leaq 0x18(%rsp), %r15
leaq 0x68(%rsp), %r12
leaq 0x4(%rsp), %rbp
leaq 0x8(%rsp), %rbx
movq 0x78(%rsp), %rax
movq 0x98(%rsp), %rcx
cmpq %rax, %rcx
jne 0x12fc3
movq 0x48(%rsp), %rdx
cmpq 0x28(%rsp), %rdx
jne 0x12fc3
jmp 0x13124
movslq (%rax), %r13
movq %r12, %rdi
callq 0x14afa
movq 0x38(%r14), %rcx
imulq $0x18, %r13, %rdx
movq (%rcx,%rdx), %rax
movq 0x8(%rcx,%rdx), %rcx
movq %rcx, %rdx
subq %rax, %rdx
cmpq $0x5, %rdx
jae 0x1314f
cmpq %rax, %rcx
je 0x12fb6
movl (%rax), %edx
movl %edx, 0x8(%rsp)
movq %r14, %rdi
movl %r13d, %esi
callq 0x7d28
movslq 0x8(%rsp), %rax
movq 0x38(%r14), %rcx
imulq $0x18, %rax, %rdx
movq (%rcx,%rdx), %rax
movq 0x8(%rcx,%rdx), %rcx
movq %rcx, %rdx
subq %rax, %rdx
cmpq $0x4, %rdx
jne 0x12fa2
movq %r12, %rdi
movq %rbx, %rsi
callq 0x148c6
movslq 0x8(%rsp), %rax
movq 0x38(%r14), %rcx
imulq $0x18, %rax, %rdx
movq (%rcx,%rdx), %rax
movq 0x8(%rcx,%rdx), %rcx
subq %rax, %rcx
cmpq $0x8, %rcx
jne 0x12fb6
movq %r15, %rdi
movq %rbx, %rsi
callq 0x148c6
movq 0x78(%rsp), %rax
movq 0x98(%rsp), %rcx
cmpq %rax, %rcx
jne 0x12f1d
movq 0x28(%rsp), %rax
cmpq %rax, 0x48(%rsp)
je 0x12ef2
movslq (%rax), %r13
movq %r15, %rdi
callq 0x14afa
movq 0x38(%r14), %rcx
imulq $0x18, %r13, %rdx
movq (%rcx,%rdx), %rax
movq 0x8(%rcx,%rdx), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
je 0x12ef2
cmpq $0x2, %rcx
jne 0x1318d
movl (%rax), %esi
movl %esi, (%rsp)
movl 0x4(%rax), %edx
movl %edx, 0x4(%rsp)
movq %r14, %rdi
callq 0x7f98
testb %al, %al
jne 0x13052
movl (%rsp), %eax
movl %eax, 0x8(%rsp)
movl 0x4(%rsp), %eax
movl %eax, 0xc(%rsp)
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x92ce
movl (%rsp), %esi
movl 0x4(%rsp), %edx
movq %r14, %rdi
callq 0x7a8e
movl (%rsp), %edx
movq %r14, %rdi
movl %r13d, %esi
callq 0x7d28
movl 0x4(%rsp), %edx
movq %r14, %rdi
movl %r13d, %esi
callq 0x7d28
movslq (%rsp), %rcx
movq 0x38(%r14), %rax
imulq $0x18, %rcx, %rdx
movq (%rax,%rdx), %rcx
movq 0x8(%rax,%rdx), %rdx
movq %rdx, %rsi
subq %rcx, %rsi
cmpq $0x4, %rsi
jne 0x130b0
movq %r12, %rdi
movq %rsp, %rsi
callq 0x148c6
movslq (%rsp), %rcx
movq 0x38(%r14), %rax
imulq $0x18, %rcx, %rdx
movq (%rax,%rdx), %rcx
movq 0x8(%rax,%rdx), %rdx
subq %rcx, %rdx
cmpq $0x8, %rdx
jne 0x130c8
movq %r15, %rdi
movq %rsp, %rsi
callq 0x148c6
movq 0x38(%r14), %rax
movslq 0x4(%rsp), %rcx
imulq $0x18, %rcx, %rdx
movq (%rax,%rdx), %rcx
movq 0x8(%rax,%rdx), %rax
movq %rax, %rdx
subq %rcx, %rdx
cmpq $0x4, %rdx
jne 0x13107
movq %r12, %rdi
movq %rbp, %rsi
callq 0x148c6
movslq 0x4(%rsp), %rax
movq 0x38(%r14), %rdx
imulq $0x18, %rax, %rax
movq (%rdx,%rax), %rcx
movq 0x8(%rdx,%rax), %rax
subq %rcx, %rax
cmpq $0x8, %rax
jne 0x12ef2
movq %r15, %rdi
movq %rbp, %rsi
callq 0x148c6
jmp 0x12ef2
leaq 0x18(%rsp), %rdi
callq 0x14210
leaq 0x68(%rsp), %rdi
callq 0x14210
movq 0x10(%rsp), %rax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xe381(%rip), %rdi      # 0x214d7
leaq 0xdfbb(%rip), %rsi      # 0x21118
leaq 0xe331(%rip), %rcx      # 0x21495
movl $0x1c1, %edx            # imm = 0x1C1
callq 0x2150
leaq 0xe30e(%rip), %rdi      # 0x21483
leaq 0xdf9c(%rip), %rsi      # 0x21118
leaq 0xe312(%rip), %rcx      # 0x21495
movl $0x1b7, %edx            # imm = 0x1B7
callq 0x2150
leaq 0xe356(%rip), %rdi      # 0x214ea
leaq 0xdf7d(%rip), %rsi      # 0x21118
leaq 0xe2f3(%rip), %rcx      # 0x21495
movl $0x1cb, %edx            # imm = 0x1CB
callq 0x2150
movq %rax, %rbx
jmp 0x131d1
jmp 0x131ba
movq %rax, %rbx
jmp 0x131c7
jmp 0x131ba
movq %rax, %rbx
movq 0x10(%rsp), %rdi
callq 0x3bfe
leaq 0x18(%rsp), %rdi
callq 0x14210
leaq 0x68(%rsp), %rdi
callq 0x14210
movq %rbx, %rdi
callq 0x2340