// File: cssartori[P]ga-qap/src/objectivefunction.cpp
// Function: ObjectiveFunction::eval_pair_change(Solution const&, unsigned long, unsigned long) const
int ObjectiveFunction::eval_pair_change(const Solution& s, size_t i, size_t j) const{
	int fitness = s.fitness();
	int delta = 0;	
	
	delta +=  data.flow[i][j]*data.distance[s[i]][s[j]];
	delta = delta - data.flow[i][j]*data.distance[s[j]][s[i]];
	delta +=  data.flow[j][i]*data.distance[s[j]][s[i]];
	delta = delta - data.flow[j][i]*data.distance[s[i]][s[j]];

	delta = delta + (2*data.flow[i][i]*data.distance[s[i]][s[i]]);
	delta = delta - (2*data.flow[i][i]*data.distance[s[j]][s[j]]);
	delta = delta + (2*data.flow[j][j]*data.distance[s[j]][s[j]]);
	delta = delta - (2*data.flow[j][j]*data.distance[s[i]][s[i]]);

	for(size_t k=0;k<data.n;k++){
		if(k == i || k==j)
			continue;

		delta = delta + data.flow[k][i]*data.distance[s[k]][s[i]];
		delta = delta - data.flow[k][i]*data.distance[s[k]][s[j]];
		delta = delta + data.flow[i][k]*data.distance[s[i]][s[k]];
		delta = delta - data.flow[i][k]*data.distance[s[j]][s[k]];

		delta = delta + data.flow[k][j]*data.distance[s[k]][s[j]];
		delta = delta - data.flow[k][j]*data.distance[s[k]][s[i]];
		delta = delta + data.flow[j][k]*data.distance[s[j]][s[k]];
		delta = delta - data.flow[j][k]*data.distance[s[i]][s[k]];
	}

	fitness -= delta;
	return fitness;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1c0, %rsp            # imm = 0x1C0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5fc0
movl %eax, %ecx
movq -0x50(%rbp), %rax
movl %ecx, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x7040
movq %rax, %rdi
movq -0x20(%rbp), %rsi
callq 0x6150
movq %rax, %rcx
movq -0x50(%rbp), %rax
movl (%rcx), %ecx
movl %ecx, -0xe4(%rbp)
movq (%rax), %rax
addq $0x18, %rax
movq %rax, -0xf8(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movl %eax, %esi
callq 0x5f90
movq -0xf8(%rbp), %rdi
movslq %eax, %rsi
callq 0x7040
movq %rax, -0xf0(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movl %eax, %esi
callq 0x5f90
movq -0xf0(%rbp), %rdi
movslq %eax, %rsi
callq 0x6150
movl -0xe4(%rbp), %ecx
movq %rax, %rdx
movq -0x50(%rbp), %rax
imull (%rdx), %ecx
addl -0x28(%rbp), %ecx
movl %ecx, -0x28(%rbp)
movl -0x28(%rbp), %ecx
movl %ecx, -0xcc(%rbp)
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x7040
movq %rax, %rdi
movq -0x20(%rbp), %rsi
callq 0x6150
movq %rax, %rcx
movq -0x50(%rbp), %rax
movl (%rcx), %ecx
movl %ecx, -0xd0(%rbp)
movq (%rax), %rax
addq $0x18, %rax
movq %rax, -0xe0(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movl %eax, %esi
callq 0x5f90
movq -0xe0(%rbp), %rdi
movslq %eax, %rsi
callq 0x7040
movq %rax, -0xd8(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movl %eax, %esi
callq 0x5f90
movq -0xd8(%rbp), %rdi
movslq %eax, %rsi
callq 0x6150
movl -0xd0(%rbp), %edx
movl -0xcc(%rbp), %ecx
movq %rax, %rsi
movq -0x50(%rbp), %rax
imull (%rsi), %edx
subl %edx, %ecx
movl %ecx, -0x28(%rbp)
movq (%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0x7040
movq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x6150
movq %rax, %rcx
movq -0x50(%rbp), %rax
movl (%rcx), %ecx
movl %ecx, -0xb4(%rbp)
movq (%rax), %rax
addq $0x18, %rax
movq %rax, -0xc8(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movl %eax, %esi
callq 0x5f90
movq -0xc8(%rbp), %rdi
movslq %eax, %rsi
callq 0x7040
movq %rax, -0xc0(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movl %eax, %esi
callq 0x5f90
movq -0xc0(%rbp), %rdi
movslq %eax, %rsi
callq 0x6150
movl -0xb4(%rbp), %ecx
movq %rax, %rdx
movq -0x50(%rbp), %rax
imull (%rdx), %ecx
addl -0x28(%rbp), %ecx
movl %ecx, -0x28(%rbp)
movl -0x28(%rbp), %ecx
movl %ecx, -0x9c(%rbp)
movq (%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0x7040
movq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x6150
movq %rax, %rcx
movq -0x50(%rbp), %rax
movl (%rcx), %ecx
movl %ecx, -0xa0(%rbp)
movq (%rax), %rax
addq $0x18, %rax
movq %rax, -0xb0(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movl %eax, %esi
callq 0x5f90
movq -0xb0(%rbp), %rdi
movslq %eax, %rsi
callq 0x7040
movq %rax, -0xa8(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movl %eax, %esi
callq 0x5f90
movq -0xa8(%rbp), %rdi
movslq %eax, %rsi
callq 0x6150
movl -0xa0(%rbp), %edx
movl -0x9c(%rbp), %ecx
movq %rax, %rsi
movq -0x50(%rbp), %rax
imull (%rsi), %edx
subl %edx, %ecx
movl %ecx, -0x28(%rbp)
movl -0x28(%rbp), %ecx
movl %ecx, -0x84(%rbp)
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x7040
movq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x6150
movq %rax, %rcx
movq -0x50(%rbp), %rax
movl (%rcx), %ecx
shll %ecx
movl %ecx, -0x88(%rbp)
movq (%rax), %rax
addq $0x18, %rax
movq %rax, -0x98(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movl %eax, %esi
callq 0x5f90
movq -0x98(%rbp), %rdi
movslq %eax, %rsi
callq 0x7040
movq %rax, -0x90(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movl %eax, %esi
callq 0x5f90
movq -0x90(%rbp), %rdi
movslq %eax, %rsi
callq 0x6150
movl -0x88(%rbp), %edx
movl -0x84(%rbp), %ecx
movq %rax, %rsi
movq -0x50(%rbp), %rax
imull (%rsi), %edx
addl %edx, %ecx
movl %ecx, -0x28(%rbp)
movl -0x28(%rbp), %ecx
movl %ecx, -0x6c(%rbp)
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x7040
movq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x6150
movq %rax, %rcx
movq -0x50(%rbp), %rax
movl (%rcx), %ecx
shll %ecx
movl %ecx, -0x70(%rbp)
movq (%rax), %rax
addq $0x18, %rax
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movl %eax, %esi
callq 0x5f90
movq -0x80(%rbp), %rdi
movslq %eax, %rsi
callq 0x7040
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movl %eax, %esi
callq 0x5f90
movq -0x78(%rbp), %rdi
movslq %eax, %rsi
callq 0x6150
movl -0x70(%rbp), %edx
movl -0x6c(%rbp), %ecx
movq %rax, %rsi
movq -0x50(%rbp), %rax
imull (%rsi), %edx
subl %edx, %ecx
movl %ecx, -0x28(%rbp)
movl -0x28(%rbp), %ecx
movl %ecx, -0x54(%rbp)
movq (%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0x7040
movq %rax, %rdi
movq -0x20(%rbp), %rsi
callq 0x6150
movq %rax, %rcx
movq -0x50(%rbp), %rax
movl (%rcx), %ecx
shll %ecx
movl %ecx, -0x58(%rbp)
movq (%rax), %rax
addq $0x18, %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movl %eax, %esi
callq 0x5f90
movq -0x68(%rbp), %rdi
movslq %eax, %rsi
callq 0x7040
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movl %eax, %esi
callq 0x5f90
movq -0x60(%rbp), %rdi
movslq %eax, %rsi
callq 0x6150
movl -0x58(%rbp), %edx
movl -0x54(%rbp), %ecx
movq %rax, %rsi
movq -0x50(%rbp), %rax
imull (%rsi), %edx
addl %edx, %ecx
movl %ecx, -0x28(%rbp)
movl -0x28(%rbp), %ecx
movl %ecx, -0x34(%rbp)
movq (%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0x7040
movq %rax, %rdi
movq -0x20(%rbp), %rsi
callq 0x6150
movq %rax, %rcx
movq -0x50(%rbp), %rax
movl (%rcx), %ecx
shll %ecx
movl %ecx, -0x38(%rbp)
movq (%rax), %rax
addq $0x18, %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movl %eax, %esi
callq 0x5f90
movq -0x48(%rbp), %rdi
movslq %eax, %rsi
callq 0x7040
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movl %eax, %esi
callq 0x5f90
movq -0x40(%rbp), %rdi
movslq %eax, %rsi
callq 0x6150
movl -0x38(%rbp), %ecx
movq %rax, %rdx
movl -0x34(%rbp), %eax
imull (%rdx), %ecx
subl %ecx, %eax
movl %eax, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x50(%rbp), %rcx
movq -0x30(%rbp), %rax
movq (%rcx), %rcx
cmpq 0x30(%rcx), %rax
jae 0x7023
movq -0x30(%rbp), %rax
cmpq -0x18(%rbp), %rax
je 0x6b2d
movq -0x30(%rbp), %rax
cmpq -0x20(%rbp), %rax
jne 0x6b32
jmp 0x7012
movq -0x50(%rbp), %rax
movl -0x28(%rbp), %ecx
movl %ecx, -0x1a4(%rbp)
movq (%rax), %rdi
movq -0x30(%rbp), %rsi
callq 0x7040
movq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x6150
movq %rax, %rcx
movq -0x50(%rbp), %rax
movl (%rcx), %ecx
movl %ecx, -0x1a8(%rbp)
movq (%rax), %rax
addq $0x18, %rax
movq %rax, -0x1b8(%rbp)
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movl %eax, %esi
callq 0x5f90
movq -0x1b8(%rbp), %rdi
movslq %eax, %rsi
callq 0x7040
movq %rax, -0x1b0(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movl %eax, %esi
callq 0x5f90
movq -0x1b0(%rbp), %rdi
movslq %eax, %rsi
callq 0x6150
movl -0x1a8(%rbp), %edx
movl -0x1a4(%rbp), %ecx
movq %rax, %rsi
movq -0x50(%rbp), %rax
imull (%rsi), %edx
addl %edx, %ecx
movl %ecx, -0x28(%rbp)
movl -0x28(%rbp), %ecx
movl %ecx, -0x18c(%rbp)
movq (%rax), %rdi
movq -0x30(%rbp), %rsi
callq 0x7040
movq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x6150
movq %rax, %rcx
movq -0x50(%rbp), %rax
movl (%rcx), %ecx
movl %ecx, -0x190(%rbp)
movq (%rax), %rax
addq $0x18, %rax
movq %rax, -0x1a0(%rbp)
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movl %eax, %esi
callq 0x5f90
movq -0x1a0(%rbp), %rdi
movslq %eax, %rsi
callq 0x7040
movq %rax, -0x198(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movl %eax, %esi
callq 0x5f90
movq -0x198(%rbp), %rdi
movslq %eax, %rsi
callq 0x6150
movl -0x190(%rbp), %edx
movl -0x18c(%rbp), %ecx
movq %rax, %rsi
movq -0x50(%rbp), %rax
imull (%rsi), %edx
subl %edx, %ecx
movl %ecx, -0x28(%rbp)
movl -0x28(%rbp), %ecx
movl %ecx, -0x174(%rbp)
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x7040
movq %rax, %rdi
movq -0x30(%rbp), %rsi
callq 0x6150
movq %rax, %rcx
movq -0x50(%rbp), %rax
movl (%rcx), %ecx
movl %ecx, -0x178(%rbp)
movq (%rax), %rax
addq $0x18, %rax
movq %rax, -0x188(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movl %eax, %esi
callq 0x5f90
movq -0x188(%rbp), %rdi
movslq %eax, %rsi
callq 0x7040
movq %rax, -0x180(%rbp)
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movl %eax, %esi
callq 0x5f90
movq -0x180(%rbp), %rdi
movslq %eax, %rsi
callq 0x6150
movl -0x178(%rbp), %edx
movl -0x174(%rbp), %ecx
movq %rax, %rsi
movq -0x50(%rbp), %rax
imull (%rsi), %edx
addl %edx, %ecx
movl %ecx, -0x28(%rbp)
movl -0x28(%rbp), %ecx
movl %ecx, -0x15c(%rbp)
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x7040
movq %rax, %rdi
movq -0x30(%rbp), %rsi
callq 0x6150
movq %rax, %rcx
movq -0x50(%rbp), %rax
movl (%rcx), %ecx
movl %ecx, -0x160(%rbp)
movq (%rax), %rax
addq $0x18, %rax
movq %rax, -0x170(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movl %eax, %esi
callq 0x5f90
movq -0x170(%rbp), %rdi
movslq %eax, %rsi
callq 0x7040
movq %rax, -0x168(%rbp)
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movl %eax, %esi
callq 0x5f90
movq -0x168(%rbp), %rdi
movslq %eax, %rsi
callq 0x6150
movl -0x160(%rbp), %edx
movl -0x15c(%rbp), %ecx
movq %rax, %rsi
movq -0x50(%rbp), %rax
imull (%rsi), %edx
subl %edx, %ecx
movl %ecx, -0x28(%rbp)
movl -0x28(%rbp), %ecx
movl %ecx, -0x144(%rbp)
movq (%rax), %rdi
movq -0x30(%rbp), %rsi
callq 0x7040
movq %rax, %rdi
movq -0x20(%rbp), %rsi
callq 0x6150
movq %rax, %rcx
movq -0x50(%rbp), %rax
movl (%rcx), %ecx
movl %ecx, -0x148(%rbp)
movq (%rax), %rax
addq $0x18, %rax
movq %rax, -0x158(%rbp)
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movl %eax, %esi
callq 0x5f90
movq -0x158(%rbp), %rdi
movslq %eax, %rsi
callq 0x7040
movq %rax, -0x150(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movl %eax, %esi
callq 0x5f90
movq -0x150(%rbp), %rdi
movslq %eax, %rsi
callq 0x6150
movl -0x148(%rbp), %edx
movl -0x144(%rbp), %ecx
movq %rax, %rsi
movq -0x50(%rbp), %rax
imull (%rsi), %edx
addl %edx, %ecx
movl %ecx, -0x28(%rbp)
movl -0x28(%rbp), %ecx
movl %ecx, -0x12c(%rbp)
movq (%rax), %rdi
movq -0x30(%rbp), %rsi
callq 0x7040
movq %rax, %rdi
movq -0x20(%rbp), %rsi
callq 0x6150
movq %rax, %rcx
movq -0x50(%rbp), %rax
movl (%rcx), %ecx
movl %ecx, -0x130(%rbp)
movq (%rax), %rax
addq $0x18, %rax
movq %rax, -0x140(%rbp)
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movl %eax, %esi
callq 0x5f90
movq -0x140(%rbp), %rdi
movslq %eax, %rsi
callq 0x7040
movq %rax, -0x138(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movl %eax, %esi
callq 0x5f90
movq -0x138(%rbp), %rdi
movslq %eax, %rsi
callq 0x6150
movl -0x130(%rbp), %edx
movl -0x12c(%rbp), %ecx
movq %rax, %rsi
movq -0x50(%rbp), %rax
imull (%rsi), %edx
subl %edx, %ecx
movl %ecx, -0x28(%rbp)
movl -0x28(%rbp), %ecx
movl %ecx, -0x114(%rbp)
movq (%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0x7040
movq %rax, %rdi
movq -0x30(%rbp), %rsi
callq 0x6150
movq %rax, %rcx
movq -0x50(%rbp), %rax
movl (%rcx), %ecx
movl %ecx, -0x118(%rbp)
movq (%rax), %rax
addq $0x18, %rax
movq %rax, -0x128(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movl %eax, %esi
callq 0x5f90
movq -0x128(%rbp), %rdi
movslq %eax, %rsi
callq 0x7040
movq %rax, -0x120(%rbp)
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movl %eax, %esi
callq 0x5f90
movq -0x120(%rbp), %rdi
movslq %eax, %rsi
callq 0x6150
movl -0x118(%rbp), %edx
movl -0x114(%rbp), %ecx
movq %rax, %rsi
movq -0x50(%rbp), %rax
imull (%rsi), %edx
addl %edx, %ecx
movl %ecx, -0x28(%rbp)
movl -0x28(%rbp), %ecx
movl %ecx, -0xfc(%rbp)
movq (%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0x7040
movq %rax, %rdi
movq -0x30(%rbp), %rsi
callq 0x6150
movq %rax, %rcx
movq -0x50(%rbp), %rax
movl (%rcx), %ecx
movl %ecx, -0x100(%rbp)
movq (%rax), %rax
addq $0x18, %rax
movq %rax, -0x110(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movl %eax, %esi
callq 0x5f90
movq -0x110(%rbp), %rdi
movslq %eax, %rsi
callq 0x7040
movq %rax, -0x108(%rbp)
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movl %eax, %esi
callq 0x5f90
movq -0x108(%rbp), %rdi
movslq %eax, %rsi
callq 0x6150
movl -0x100(%rbp), %ecx
movq %rax, %rdx
movl -0xfc(%rbp), %eax
imull (%rdx), %ecx
subl %ecx, %eax
movl %eax, -0x28(%rbp)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x6b04
movl -0x28(%rbp), %ecx
movl -0x24(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbp
retq
nopw (%rax,%rax)