// File: /workspace/github_cpp_makefile_star2_O1/Laakeri[P]Triangulator/src/minfill.cpp
// Function: MinFill::BackTrack::searchNaive(Graph&, int, int, int, int)
vector<pair<int, int> > searchNaive(Graph& G, int lowerBound, int upperBound, int step, int depth) {
	assert(lowerBound >= 0);
	if (upperBound < lowerBound) return FAILSOLUTION;
	vector<int> cycle = MCS::getChordlessCycle(G);
	if (cycle.size() == 0) {
		return {};
	}
	lowerBound = max(lowerBound, (int)cycle.size()-3);
	if (lowerBound > upperBound) return FAILSOLUTION;
	
	if (step == 3) {
		auto sol = SolveGraph::solveGraph(G, lowerBound, upperBound, depth);
		return sol;
	}
	
	G.addEdge(cycle[0], cycle[2]);
	auto sol1 = searchNaive(G, max(0, lowerBound-1), upperBound-1, step+1, depth+1);
	G.popEdge(cycle[0], cycle[2]);
	if (sol1 != FAILSOLUTION) {
		sol1.push_back({cycle[0], cycle[2]});
		assert((int)sol1.size() <= upperBound && (int)sol1.size() >= lowerBound);
		upperBound = min(upperBound, (int)sol1.size()-1);
		if ((int)sol1.size() == lowerBound) return sol1;
	}
	
	for (int i = 3; i < (int)cycle.size(); i++) {
		G.addEdge(cycle[1], cycle[i]);
		auto sol0 = searchNaive(G, max(0, lowerBound-1), upperBound-1, step+1, depth+1);
		G.popEdge(cycle[1], cycle[i]);
		
		if (sol0 != FAILSOLUTION) {
			sol0.push_back({cycle[1], cycle[i]});
			assert((int)sol0.size() <= upperBound && (int)sol0.size() >= lowerBound);
			upperBound = min(upperBound, (int)sol0.size()-1);
			if ((int)sol0.size() == lowerBound) return sol0;
			if (sol1 != FAILSOLUTION) {
				assert(sol0.size() < sol1.size());
			}
			sol1 = sol0;
		}
	}
	return sol1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
testl %edx, %edx
js 0x16328
movl %edx, %ebp
movq %rdi, %rbx
cmpl %edx, %ecx
jge 0x15f07
leaq 0x4b4156(%rip), %rsi    # 0x4ca050
movq %rbx, %rdi
callq 0x402a
jmp 0x16316
movl %r9d, %r12d
movq %rcx, 0x8(%rsp)
movl %r8d, %r15d
leaq 0x30(%rsp), %r13
movq %r13, %rdi
movq %rsi, %r14
xorl %edx, %edx
callq 0x153c7
movq (%r13), %rax
movq 0x8(%r13), %r13
subq %rax, %r13
je 0x15f5b
shrq $0x2, %r13
addl $-0x3, %r13d
cmpl %ebp, %r13d
cmovlel %ebp, %r13d
cmpl 0x8(%rsp), %r13d
jle 0x15f6e
leaq 0x4b4102(%rip), %rsi    # 0x4ca050
movq %rbx, %rdi
callq 0x402a
jmp 0x162ff
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
jmp 0x162ff
cmpl $0x3, %r15d
jne 0x15f8f
movq %rbx, %rdi
movq %r14, %rsi
movl %r13d, %edx
movq 0x8(%rsp), %rcx
movl %r12d, %r8d
callq 0x16405
jmp 0x162ff
movl (%rax), %esi
movl 0x8(%rax), %edx
movq %r14, %rdi
callq 0x9512
cmpl $0x2, %r13d
movl $0x1, %edx
cmovgel %r13d, %edx
decl %edx
movq 0x8(%rsp), %rax
leal -0x1(%rax), %ecx
incl %r15d
incl %r12d
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
movl %edx, 0x48(%rsp)
movl %r15d, 0x4c(%rsp)
movl %r15d, %r8d
movl %r12d, %r9d
callq 0x15ed4
movq %r14, %r15
movq 0x30(%rsp), %rax
movl (%rax), %esi
movl 0x8(%rax), %edx
movq %r14, %rdi
callq 0x9836
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %rax
movq %rax, %rsi
subq %rcx, %rsi
movq 0x4b4057(%rip), %rdi    # 0x4ca058
movq 0x4b4048(%rip), %rdx    # 0x4ca050
subq %rdx, %rdi
cmpq %rdi, %rsi
movq 0x8(%rsp), %r14
jne 0x1605d
cmpq %rax, %rcx
sete %sil
je 0x16058
movl (%rcx), %esi
cmpl (%rdx), %esi
jne 0x1605d
movl 0x4(%rdx), %esi
cmpl %esi, 0x4(%rcx)
jne 0x1605d
addq $0x8, %rcx
addq $0xc, %rdx
cmpq %rax, %rcx
sete %sil
je 0x16058
movl (%rcx), %esi
cmpl -0x4(%rdx), %esi
jne 0x1605d
leaq 0x8(%rcx), %rsi
movl (%rdx), %edi
addq $0x8, %rdx
cmpl %edi, 0x4(%rcx)
movq %rsi, %rcx
je 0x16034
jmp 0x1605d
testb %sil, %sil
jne 0x160b8
movq 0x30(%rsp), %rax
movl (%rax), %ecx
leaq 0x50(%rsp), %rsi
movl %ecx, (%rsi)
movl 0x8(%rax), %eax
movl %eax, 0x4(%rsi)
leaq 0x10(%rsp), %rdi
callq 0xafe4
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %rax
movq %rax, %rdx
subq %rcx, %rdx
shrq $0x3, %rdx
cmpl %r14d, %edx
jg 0x16385
cmpl %edx, %r13d
jg 0x16385
leal -0x1(%rdx), %esi
cmpl %r14d, %esi
cmovll %esi, %r14d
cmpl %edx, %r13d
jne 0x160b8
movq %rcx, (%rbx)
jmp 0x162ca
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
subq %rax, %rcx
shrq $0x2, %rcx
cmpl $0x4, %ecx
jl 0x162bd
movl $0x3, %ebp
movl %r12d, 0x8(%rsp)
movl 0x4(%rax), %esi
movl (%rax,%rbp,4), %edx
movq %r15, %rdi
callq 0x9512
leal -0x1(%r14), %ecx
movq %rbx, %rdi
movq %r15, %rsi
movl 0x48(%rsp), %edx
movl 0x4c(%rsp), %r8d
movl %r12d, %r9d
callq 0x15ed4
movq 0x30(%rsp), %rax
movl 0x4(%rax), %esi
movl (%rax,%rbp,4), %edx
movq %r15, %rdi
callq 0x9836
movq (%rbx), %rcx
movq 0x8(%rbx), %rax
movq %rax, %rsi
subq %rcx, %rsi
movq 0x4b3f2c(%rip), %rdi    # 0x4ca058
movq 0x4b3f1d(%rip), %rdx    # 0x4ca050
subq %rdx, %rdi
cmpq %rdi, %rsi
jne 0x16187
cmpq %rax, %rcx
sete %sil
je 0x1617e
movl (%rcx), %esi
cmpl (%rdx), %esi
jne 0x16187
movl 0x4(%rdx), %esi
cmpl %esi, 0x4(%rcx)
jne 0x16187
addq $0x8, %rcx
addq $0xc, %rdx
cmpq %rax, %rcx
sete %sil
je 0x1617e
movl (%rcx), %esi
cmpl -0x4(%rdx), %esi
jne 0x16187
leaq 0x8(%rcx), %rsi
movl (%rdx), %edi
addq $0x8, %rdx
cmpl %edi, 0x4(%rcx)
movq %rsi, %rcx
je 0x1615a
jmp 0x16187
testb %sil, %sil
jne 0x16276
movq 0x30(%rsp), %rax
movl 0x4(%rax), %ecx
movl %ecx, 0x50(%rsp)
movl (%rax,%rbp,4), %eax
movl %eax, 0x54(%rsp)
movq %rbx, %rdi
leaq 0x50(%rsp), %rsi
callq 0xafe4
movq 0x8(%rbx), %rax
subq (%rbx), %rax
movq %rax, %rcx
shrq $0x3, %rcx
cmpl %ecx, %r14d
jl 0x16347
cmpl %ecx, %r13d
jg 0x16347
leal -0x1(%rcx), %edx
cmpl %r14d, %edx
cmovll %edx, %r14d
cmpl %ecx, %r13d
jne 0x161e0
movb $0x1, %al
xorl %r12d, %r12d
jmp 0x1627b
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %rdx, %rcx
subq %rsi, %rcx
movq 0x4b3e61(%rip), %r8     # 0x4ca058
movq 0x4b3e52(%rip), %rdi    # 0x4ca050
subq %rdi, %r8
cmpq %r8, %rcx
jne 0x16257
cmpq %rdx, %rsi
sete %r8b
je 0x1625a
movl (%rsi), %r9d
xorl %r8d, %r8d
cmpl (%rdi), %r9d
jne 0x1625a
movl 0x4(%rdi), %r9d
cmpl %r9d, 0x4(%rsi)
jne 0x1625a
addq $0x8, %rsi
addq $0xc, %rdi
cmpq %rdx, %rsi
sete %r8b
je 0x1625a
movl (%rsi), %r9d
xorl %r8d, %r8d
cmpl -0x4(%rdi), %r9d
jne 0x1625a
leaq 0x8(%rsi), %r9
movl (%rdi), %r10d
addq $0x8, %rdi
cmpl %r10d, 0x4(%rsi)
movq %r9, %rsi
je 0x1622c
jmp 0x1625a
xorl %r8d, %r8d
cmpq %rcx, %rax
setb %al
orb %r8b, %al
je 0x16366
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x1a862
movb $0x1, %r12b
xorl %eax, %eax
testb %al, %al
jne 0x16293
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x16293
movq 0x10(%rbx), %rsi
subq %rdi, %rsi
callq 0x2210
testb %r12b, %r12b
je 0x162e8
incq %rbp
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
subq %rax, %rcx
shrq $0x2, %rcx
movslq %ecx, %rcx
cmpq %rcx, %rbp
movl 0x8(%rsp), %r12d
jl 0x160dc
movq 0x10(%rsp), %rax
movq %rax, (%rbx)
movq 0x18(%rsp), %rax
movq %rax, 0x8(%rbx)
movq 0x20(%rsp), %rax
movq %rax, 0x10(%rbx)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x162ff
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x16316
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1400f(%rip), %rdi     # 0x2a33e
leaq 0x14dd2(%rip), %rsi     # 0x2b108
leaq 0x14dd7(%rip), %rcx     # 0x2b114
movl $0x17, %edx
callq 0x2140
leaq 0x14e5b(%rip), %rdi     # 0x2b1a9
leaq 0x14db3(%rip), %rsi     # 0x2b108
leaq 0x14db8(%rip), %rcx     # 0x2b114
movl $0x36, %edx
callq 0x2140
leaq 0x14e7d(%rip), %rdi     # 0x2b1ea
leaq 0x14d94(%rip), %rsi     # 0x2b108
leaq 0x14d99(%rip), %rcx     # 0x2b114
movl $0x3a, %edx
callq 0x2140
leaq 0x14ddc(%rip), %rdi     # 0x2b168
leaq 0x14d75(%rip), %rsi     # 0x2b108
leaq 0x14d7a(%rip), %rcx     # 0x2b114
movl $0x2a, %edx
callq 0x2140
jmp 0x163b3
jmp 0x163b3
jmp 0x163ac
jmp 0x163b8
movq %rax, %r14
jmp 0x163e6
jmp 0x163b3
movq %rax, %r14
jmp 0x163cf
movq %rax, %r14
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x163cf
movq 0x10(%rbx), %rsi
subq %rdi, %rsi
callq 0x2210
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x163e6
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x163fd
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq %r14, %rdi
callq 0x2310