// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rcx, %rbp
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %rbx
movq %rdi, 0x10(%rsp)
movq %rsi, %rdi
callq 0x3612
movl %eax, 0x3c(%rsp)
movq (%rbx), %rbx
movq (%rbx), %rax
leaq (,%r12,8), %rcx
leaq (%rcx,%rcx,2), %r15
movq (%rax,%r15), %rax
movq %r15, 0x30(%rsp)
movl (%rax,%rbp,4), %r14d
movq %r13, %rdi
movl %r12d, %esi
callq 0x3608
cltq
movq 0x18(%rbx), %rcx
movq %rcx, 0x8(%rsp)
leaq (%rax,%rax,2), %rbx
movq %r13, %rdi
movl %ebp, %esi
callq 0x3608
cltq
movq 0x8(%rsp), %rcx
movq (%rcx,%rbx,8), %rcx
imull (%rcx,%rax,4), %r14d
movl %r14d, 0x8(%rsp)
movq 0x10(%rsp), %r14
movq (%r14), %rbx
movq (%rbx), %rax
movq (%rax,%r15), %rax
movl (%rax,%rbp,4), %eax
movl %eax, (%rsp)
movq %r13, %rdi
movl %ebp, %esi
callq 0x3608
cltq
movq 0x18(%rbx), %rbx
leaq (%rax,%rax,2), %r15
movq %r13, %rdi
movl %r12d, %esi
callq 0x3608
cltq
movq (%rbx,%r15,8), %rcx
movq (%r14), %r15
movq (%r15), %rdx
leaq (,%rbp,8), %rsi
leaq (%rsi,%rsi,2), %rsi
movq %rsi, 0x20(%rsp)
movq (%rdx,%rsi), %rdx
movl (%rdx,%r12,4), %r14d
movl (%rsp), %edx
imull (%rcx,%rax,4), %edx
movl %edx, (%rsp)
movq %r13, %rdi
movl %ebp, %esi
callq 0x3608
cltq
movq 0x18(%r15), %r15
leaq (%rax,%rax,2), %rbx
movq %r13, %rdi
movl %r12d, %esi
callq 0x3608
cltq
movq (%r15,%rbx,8), %rcx
imull (%rcx,%rax,4), %r14d
addl 0x8(%rsp), %r14d
movq %r14, 0x8(%rsp)
movq 0x10(%rsp), %rbx
movq (%rbx), %r14
movq (%r14), %rax
movq 0x20(%rsp), %rcx
movq (%rax,%rcx), %rax
movq %r12, 0x18(%rsp)
movl (%rax,%r12,4), %r15d
movq %r13, %rdi
movl %r12d, %esi
callq 0x3608
cltq
movq 0x18(%r14), %r14
leaq (%rax,%rax,2), %r12
movq %r13, %rdi
movl %ebp, %esi
callq 0x3608
cltq
movq (%r14,%r12,8), %rcx
movq %rbx, %r14
movq (%rbx), %r12
movq (%r12), %rdx
movq 0x30(%rsp), %rsi
movq (%rdx,%rsi), %rdx
movq 0x18(%rsp), %rbx
movl (%rdx,%rbx,4), %edx
movl %edx, 0x4(%rsp)
imull (%rcx,%rax,4), %r15d
addl (%rsp), %r15d
movq 0x8(%rsp), %rax
subl %r15d, %eax
movq %rax, 0x8(%rsp)
movq %r13, %rdi
movl %ebx, %esi
callq 0x3608
cltq
movq 0x18(%r12), %r15
leaq (%rax,%rax,2), %r12
movq %r13, %rdi
movl %ebx, %esi
callq 0x3608
cltq
movq (%r15,%r12,8), %rcx
movl 0x4(%rsp), %edx
imull (%rcx,%rax,4), %edx
movl %edx, 0x4(%rsp)
movq (%r14), %r15
movq (%r15), %rax
movq 0x30(%rsp), %rcx
movq (%rax,%rcx), %rax
movl (%rax,%rbx,4), %eax
movl %eax, (%rsp)
movq %r13, %rdi
movl %ebp, %esi
callq 0x3608
cltq
movq 0x18(%r15), %r15
leaq (%rax,%rax,2), %r12
movq %r13, %rdi
movl %ebp, %esi
callq 0x3608
cltq
movq (%r15,%r12,8), %rcx
movq (%r14), %r12
movq (%r12), %rdx
movq 0x20(%rsp), %rsi
movq (%rdx,%rsi), %rdx
movl (%rdx,%rbp,4), %r15d
movl (%rsp), %edx
imull (%rcx,%rax,4), %edx
movl %edx, (%rsp)
movq %r13, %rdi
movl %ebp, %esi
callq 0x3608
cltq
movq 0x18(%r12), %r12
leaq (%rax,%rax,2), %r14
movq %r13, %rdi
movl %ebp, %esi
callq 0x3608
cltq
movq (%r12,%r14,8), %rcx
imull (%rcx,%rax,4), %r15d
addl 0x4(%rsp), %r15d
movq 0x10(%rsp), %rax
movq (%rax), %r14
movq (%r14), %rax
movq 0x20(%rsp), %rcx
movq (%rax,%rcx), %rax
movq %rbp, 0x28(%rsp)
movl (%rax,%rbp,4), %r12d
movq %r13, %rdi
movl %ebx, %esi
callq 0x3608
cltq
movq 0x18(%r14), %r14
leaq (%rax,%rax,2), %rbp
movq %r13, 0x50(%rsp)
movq %r13, %rdi
movl %ebx, %esi
callq 0x3608
cltq
movq (%r14,%rbp,8), %rcx
imull (%rcx,%rax,4), %r12d
addl (%rsp), %r12d
subl %r12d, %r15d
movq 0x8(%rsp), %rcx
leal (%rcx,%r15,2), %esi
movq 0x10(%rsp), %rax
movq (%rax), %r14
cmpq $0x0, 0x30(%r14)
je 0x3d6a
xorl %r8d, %r8d
xorl %r13d, %r13d
movq 0x28(%rsp), %rdi
movq 0x18(%rsp), %rdx
movq 0x50(%rsp), %rbx
cmpq %r13, %rdx
sete %al
cmpq %r13, %rdi
sete %cl
orb %al, %cl
jne 0x3d51
movq (%r14), %rax
movq (%rax,%r8), %rax
movl (%rax,%rdx,4), %r12d
movq %rbx, %rdi
movl %esi, 0x4c(%rsp)
movl %r13d, %esi
movq %r8, 0x8(%rsp)
callq 0x3608
cltq
movq 0x18(%r14), %r14
leaq (%rax,%rax,2), %r15
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
callq 0x3608
cltq
movq (%r14,%r15,8), %rcx
imull (%rcx,%rax,4), %r12d
movl %r12d, 0x48(%rsp)
movq 0x10(%rsp), %rax
movq (%rax), %r15
movq (%r15), %rax
movq 0x8(%rsp), %rcx
movq (%rax,%rcx), %rax
movq 0x18(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0x4(%rsp)
movq %rbx, %rdi
movl %r13d, %esi
callq 0x3608
cltq
movq 0x18(%r15), %r15
leaq (%rax,%rax,2), %r12
movq %rbx, %rdi
movq 0x28(%rsp), %rsi
callq 0x3608
cltq
movq (%r15,%r12,8), %rcx
movq 0x10(%rsp), %rdx
movq (%rdx), %r15
movq (%r15), %rdx
movq 0x30(%rsp), %rbp
movq (%rdx,%rbp), %rdx
movl (%rdx,%r13,4), %r14d
movl 0x4(%rsp), %edx
imull (%rcx,%rax,4), %edx
movl %edx, 0x4(%rsp)
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
callq 0x3608
cltq
movq 0x18(%r15), %r15
leaq (%rax,%rax,2), %r12
movq %rbx, %rdi
movl %r13d, %esi
callq 0x3608
cltq
movq (%r15,%r12,8), %rcx
imull (%rcx,%rax,4), %r14d
movl %r14d, 0x44(%rsp)
movq 0x10(%rsp), %rax
movq (%rax), %r15
movq (%r15), %rax
movq (%rax,%rbp), %rax
movl (%rax,%r13,4), %eax
movl %eax, (%rsp)
movq %rbx, %rdi
movq 0x28(%rsp), %rbp
movl %ebp, %esi
callq 0x3608
cltq
movq 0x18(%r15), %r15
leaq (%rax,%rax,2), %r12
movq %rbx, %rdi
movl %r13d, %esi
callq 0x3608
cltq
movq (%r15,%r12,8), %rcx
movq 0x10(%rsp), %rdx
movq (%rdx), %r15
movq (%r15), %rdx
movq 0x8(%rsp), %rsi
movq (%rdx,%rsi), %rdx
movl (%rdx,%rbp,4), %r12d
movl (%rsp), %edx
imull (%rcx,%rax,4), %edx
addl 0x4(%rsp), %edx
movl %edx, (%rsp)
movq %rbx, %rdi
movl %r13d, %esi
callq 0x3608
cltq
movq 0x18(%r15), %r14
leaq (%rax,%rax,2), %r15
movq %rbx, %rdi
movl %ebp, %esi
callq 0x3608
cltq
movq (%r14,%r15,8), %rcx
imull (%rcx,%rax,4), %r12d
movl %r12d, 0x4(%rsp)
movq 0x10(%rsp), %rax
movq (%rax), %r15
movq (%r15), %rax
movq 0x8(%rsp), %rcx
movq (%rax,%rcx), %rax
movl (%rax,%rbp,4), %r14d
movq %rbx, %rdi
movl %r13d, %esi
callq 0x3608
cltq
movq 0x18(%r15), %r15
leaq (%rax,%rax,2), %r12
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
callq 0x3608
cltq
movq (%r15,%r12,8), %rcx
movq 0x10(%rsp), %rdx
movq (%rdx), %r12
movq (%r12), %rdx
movq 0x20(%rsp), %rsi
movq (%rdx,%rsi), %rdx
movl (%rdx,%r13,4), %r15d
imull (%rcx,%rax,4), %r14d
movl %r14d, 0x40(%rsp)
movq %rbx, %rdi
movl %ebp, %esi
callq 0x3608
cltq
movq 0x18(%r12), %r12
leaq (%rax,%rax,2), %r14
movq %rbx, %rdi
movl %r13d, %esi
callq 0x3608
cltq
movq (%r12,%r14,8), %rcx
imull (%rcx,%rax,4), %r15d
addl 0x4(%rsp), %r15d
movq 0x10(%rsp), %rax
movq (%rax), %r14
movq (%r14), %rax
movq 0x20(%rsp), %rcx
movq (%rax,%rcx), %rax
movl (%rax,%r13,4), %r12d
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
callq 0x3608
cltq
movq 0x18(%r14), %rbp
leaq (%rax,%rax,2), %r14
movq %rbx, %rdi
movl %r13d, %esi
callq 0x3608
movq 0x8(%rsp), %r8
movq 0x18(%rsp), %rdx
cltq
movq (%rbp,%r14,8), %rcx
movq 0x28(%rsp), %rdi
imull (%rcx,%rax,4), %r12d
addl 0x40(%rsp), %r12d
addl (%rsp), %r12d
movl 0x48(%rsp), %esi
addl 0x4c(%rsp), %esi
addl 0x44(%rsp), %esi
addl %r15d, %esi
subl %r12d, %esi
incq %r13
movq 0x10(%rsp), %rax
movq (%rax), %r14
addq $0x18, %r8
cmpq 0x30(%r14), %r13
jb 0x3ac1
movl 0x3c(%rsp), %eax
subl %esi, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop