// File: 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
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdx, -0xd8(%rbp)
movq %rsi, %rax
movq -0xd8(%rbp), %rsi
movq %rdi, -0xf0(%rbp)
movq %rdi, %rdx
movq %rdx, -0xe8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rax, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xe0(%rbp)
movb $0x0, -0x29(%rbp)
callq 0x8c00
movq -0xd8(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x8c00
jmp 0x94d6
movq -0xe0(%rbp), %rsi
leaq -0x50(%rbp), %rdi
leaq -0x70(%rbp), %rdx
callq 0x9330
jmp 0x94ec
movq -0xd8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
movq %rsi, -0x100(%rbp)
callq 0x9840
movq -0x100(%rbp), %rdi
callq 0x5840
leaq -0x70(%rbp), %rdi
callq 0x5840
movq -0xd8(%rbp), %rdi
movq -0xf0(%rbp), %rsi
callq 0x6000
movb %al, -0xf1(%rbp)
jmp 0x9533
movb -0xf1(%rbp), %al
testb $0x1, %al
jne 0x953f
jmp 0x9581
movq -0xd8(%rbp), %rsi
movq -0xf0(%rbp), %rdi
callq 0x9880
jmp 0x9554
jmp 0x9581
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x9717
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x5840
jmp 0x9717
movq $0x2, -0x88(%rbp)
movl $0x0, -0x8c(%rbp)
cvtsi2sdl -0x8c(%rbp), %xmm1
cvtsi2sdl -0x1c(%rbp), %xmm0
movsd 0x5af5(%rip), %xmm2     # 0xf0a0
mulsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x96f1
movq -0xd8(%rbp), %rsi
movq -0xe0(%rbp), %rdi
movl -0x8c(%rbp), %eax
incl %eax
movl %eax, -0x8c(%rbp)
movl -0x88(%rbp), %edx
movq -0x28(%rbp), %rcx
callq 0x9730
jmp 0x95e6
movq -0xe0(%rbp), %rcx
movq -0x88(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq (%rcx), %rcx
cmpq 0x30(%rcx), %rax
jbe 0x961a
movq $0x2, -0x88(%rbp)
movq -0xd8(%rbp), %rsi
leaq -0xd0(%rbp), %rdi
callq 0x8c00
jmp 0x962f
movq -0xe0(%rbp), %rsi
leaq -0xb0(%rbp), %rdi
leaq -0xd0(%rbp), %rdx
callq 0x9330
jmp 0x964b
movq -0xd8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
movq %rsi, -0x110(%rbp)
callq 0x9840
movq -0x110(%rbp), %rdi
callq 0x5840
leaq -0xd0(%rbp), %rdi
callq 0x5840
movq -0xd8(%rbp), %rdi
movq -0xf0(%rbp), %rsi
callq 0x6000
movb %al, -0x101(%rbp)
jmp 0x9698
movb -0x101(%rbp), %al
testb $0x1, %al
jne 0x96a4
jmp 0x96d5
movq -0xd8(%rbp), %rsi
movq -0xf0(%rbp), %rdi
callq 0x9880
jmp 0x96b9
jmp 0x96ec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x5840
jmp 0x9717
movq -0xf0(%rbp), %rsi
movq -0xd8(%rbp), %rdi
callq 0x9880
jmp 0x96ea
jmp 0x96ec
jmp 0x9596
movb $0x1, -0x29(%rbp)
testb $0x1, -0x29(%rbp)
jne 0x9707
movq -0xf0(%rbp), %rdi
callq 0x5840
movq -0xe8(%rbp), %rax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
movq -0xf0(%rbp), %rdi
callq 0x5840
movq -0x78(%rbp), %rdi
callq 0x22d0
nopl (%rax)