// File: /workspace/github_cpp_makefile_star2_O3/cssartori[P]ga-qap/src/localsearch.cpp
// Function: LocalSearch::limited_iterated_search(Solution, int, std::linear_congruential_engine<unsigned long, 16807ul, 0ul, 2147483647ul>&)
Solution LocalSearch::limited_iterated_search(Solution s, int max_iterations, std::default_random_engine& generator){	
	Solution best = s;
	/*Start picking a neighbor of s*/
	s = all_pair_changes(s);
	if(s < best) best = s;	

	size_t u = 2;
	int iter = 0;
	while(iter < max_iterations*0.1){
		iter++;
		/*Perturb the current solution s with u pair changes*/
		perturbation(s, u, generator);
		
		/*Updates u variable*/
		u++;
		if(u > data.n) u = 2;
		
		/*Improves s locally*/
		s = all_pair_changes(s);

		if(s < best) best = s;
        else s = best;
	}	
	
	return best;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %r8, 0x40(%rsp)
movl %ecx, %ebp
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %rbx
movq %rdx, %rsi
callq 0x2f74
movl 0x18(%r15), %eax
movq %rbx, (%rsp)
movl %eax, 0x18(%rbx)
leaq 0x68(%rsp), %rdi
movq %r15, %rsi
callq 0x2f74
leaq 0x18(%r15), %r14
movl (%r14), %eax
leaq 0x68(%rsp), %rdx
movl %eax, 0x18(%rdx)
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0x4ac0
movq (%r15), %rdi
movq 0x10(%r15), %rsi
movapd 0x10(%rsp), %xmm0
movupd %xmm0, (%r15)
movq 0x20(%rsp), %rax
movq %rax, 0x10(%r15)
testq %rdi, %rdi
je 0x4c41
subq %rdi, %rsi
callq 0x21a0
movl 0x28(%rsp), %eax
movl %eax, (%r14)
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x4c5f
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x21a0
movq %r15, %rdi
movq (%rsp), %rbx
movq %rbx, %rsi
callq 0x374e
leaq 0x18(%rbx), %rcx
movq %rcx, 0x8(%rsp)
testb %al, %al
je 0x4c91
movq (%rsp), %rdi
movq %r15, %rsi
callq 0x2e1e
movl (%r14), %eax
movq 0x8(%rsp), %rcx
movl %eax, (%rcx)
cvtsi2sd %ebp, %xmm1
mulsd 0x3443(%rip), %xmm1     # 0x80e0
xorpd %xmm0, %xmm0
movsd %xmm1, 0x38(%rsp)
ucomisd %xmm0, %xmm1
jbe 0x4dac
movl $0x2, %ebp
movl $0x1, %r13d
movq %r12, %rdi
movq %r15, %rsi
movl %ebp, %edx
movq 0x40(%rsp), %rcx
callq 0x4e20
movq %rbp, %rax
incq %rax
movq (%r12), %rcx
movl $0x2, %ebp
cmpq 0x30(%rcx), %rax
ja 0x4ce6
movq %rax, %rbp
leaq 0x48(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2f74
movl (%r14), %eax
movl %eax, 0x60(%rsp)
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x4ac0
movq (%r15), %rdi
movq 0x10(%r15), %rsi
movapd 0x10(%rsp), %xmm0
movupd %xmm0, (%r15)
movq 0x20(%rsp), %rax
movq %rax, 0x10(%r15)
testq %rdi, %rdi
je 0x4d35
subq %rdi, %rsi
callq 0x21a0
movl 0x28(%rsp), %eax
movl %eax, (%r14)
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x4d53
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x21a0
movq %r15, %rdi
movq (%rsp), %rsi
callq 0x374e
testb %al, %al
je 0x4d79
movq (%rsp), %rdi
movq %r15, %rsi
callq 0x2e1e
movq %r14, %rcx
movq 0x8(%rsp), %rax
jmp 0x4d8d
movq %r15, %rdi
movq (%rsp), %rsi
callq 0x2e1e
movq 0x8(%rsp), %rcx
movq %r14, %rax
movl (%rcx), %ecx
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
movl %ecx, (%rax)
incl %r13d
movsd 0x38(%rsp), %xmm1
ucomisd %xmm0, %xmm1
ja 0x4cbc
movq (%rsp), %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x4dfb
movq 0x78(%rsp), %rsi
jmp 0x4dee
jmp 0x4df8
jmp 0x4df8
jmp 0x4df8
movq %rax, %r14
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x4dfb
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x21a0
jmp 0x4dfb
movq %rax, %r14
movq (%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x4e17
movq (%rsp), %rax
movq 0x10(%rax), %rsi
subq %rdi, %rsi
callq 0x21a0
movq %r14, %rdi
callq 0x2280
nop