// File: /workspace/github_cpp_makefile_star2_O1/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, 0x20(%rsp)
movl %ecx, %ebp
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %rbx
movq %rdx, %rsi
callq 0x2e46
movl 0x18(%r15), %eax
movq %rbx, (%rsp)
movl %eax, 0x18(%rbx)
leaq 0x68(%rsp), %rdi
movq %r15, %rsi
callq 0x2e46
leaq 0x18(%r15), %r13
movl (%r13), %eax
leaq 0x68(%rsp), %rdx
movl %eax, 0x18(%rdx)
leaq 0x28(%rsp), %rdi
movq %r12, %rsi
callq 0x46e8
leaq 0x28(%rsp), %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0x4b58
movl 0x18(%r14), %eax
movl %eax, 0x18(%r15)
movq (%r14), %rdi
testq %rdi, %rdi
je 0x487b
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x21a0
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x4892
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x21a0
movq %r15, %rdi
movq (%rsp), %rbx
movq %rbx, %rsi
callq 0x361a
leaq 0x18(%rbx), %rcx
movq %rcx, 0x10(%rsp)
testb %al, %al
je 0x48c5
movq (%rsp), %rdi
movq %r15, %rsi
callq 0x2cfe
movl (%r13), %eax
movq 0x10(%rsp), %rcx
movl %eax, (%rcx)
cvtsi2sd %ebp, %xmm1
mulsd 0x27cf(%rip), %xmm1     # 0x70a0
xorpd %xmm0, %xmm0
movsd %xmm1, 0x18(%rsp)
ucomisd %xmm0, %xmm1
jbe 0x49f6
movl $0x2, %eax
movq %rax, 0x8(%rsp)
movl $0x1, %ebp
movq %r12, %rdi
movq %r15, %rsi
movq 0x8(%rsp), %rdx
movq 0x20(%rsp), %rcx
callq 0x4a6a
movq 0x8(%rsp), %rax
incq %rax
movq (%r12), %rcx
movl $0x2, %edx
movq %rdx, 0x8(%rsp)
cmpq 0x30(%rcx), %rax
ja 0x492a
movq %rax, 0x8(%rsp)
movq %r12, %r14
leaq 0x48(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2e46
movq %r13, %r12
movl (%r13), %eax
movl %eax, 0x60(%rsp)
leaq 0x28(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x46e8
movq %r15, %rdi
movq %r13, %rsi
callq 0x4b58
movl 0x40(%rsp), %eax
movl %eax, 0x18(%r15)
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x4985
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x21a0
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
movq %r12, %r13
je 0x499f
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x21a0
movq %r15, %rdi
movq (%rsp), %rsi
callq 0x361a
movq %r14, %r12
testb %al, %al
je 0x49c8
movq (%rsp), %rdi
movq %r15, %rsi
callq 0x2cfe
movq %r13, %rcx
movq 0x10(%rsp), %rax
jmp 0x49dc
movq %r15, %rdi
movq (%rsp), %rsi
callq 0x2cfe
movq 0x10(%rsp), %rcx
movq %r13, %rax
movl (%rcx), %ecx
cvtsi2sd %ebp, %xmm0
movl %ecx, (%rax)
incl %ebp
movsd 0x18(%rsp), %xmm1
ucomisd %xmm0, %xmm1
ja 0x48f4
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 0x4a45
movq 0x78(%rsp), %rsi
jmp 0x4a38
jmp 0x4a42
jmp 0x4a42
jmp 0x4a42
movq %rax, %r14
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x4a45
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x21a0
jmp 0x4a45
movq %rax, %r14
movq (%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x4a61
movq (%rsp), %rax
movq 0x10(%rax), %rsi
subq %rdi, %rsi
callq 0x21a0
movq %r14, %rdi
callq 0x2280
nop