// File: /workspace/github_cpp_makefile_star2_O3/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 $0x68, %rsp
movq %rcx, %rbp
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %rbx
movq %rdi, 0x28(%rsp)
movq %rsi, %rdi
callq 0x3746
movl %eax, 0x50(%rsp)
movq (%rbx), %rbx
movq (%rbx), %rax
leaq (,%r12,8), %rcx
leaq (%rcx,%rcx,2), %r15
movq (%rax,%r15), %rax
movq %r15, 0x40(%rsp)
movl (%rax,%rbp,4), %r14d
movq %r13, %rdi
movl %r12d, %esi
callq 0x373c
cltq
movq 0x18(%rbx), %rcx
movq %rcx, 0x10(%rsp)
leaq (%rax,%rax,2), %rbx
movq %r13, %rdi
movl %ebp, %esi
callq 0x373c
cltq
movq 0x10(%rsp), %rcx
movq (%rcx,%rbx,8), %rcx
imull (%rcx,%rax,4), %r14d
movl %r14d, 0x8(%rsp)
movq 0x28(%rsp), %rbx
movq (%rbx), %r14
movq (%r14), %rax
movq (%rax,%r15), %rax
movl (%rax,%rbp,4), %eax
movl %eax, 0x10(%rsp)
movq %r13, %rdi
movl %ebp, %esi
callq 0x373c
cltq
movq 0x18(%r14), %r14
leaq (%rax,%rax,2), %r15
movq %r13, %rdi
movl %r12d, %esi
callq 0x373c
cltq
movq (%r14,%r15,8), %rcx
movq (%rbx), %r14
movq (%r14), %rdx
leaq (,%rbp,8), %rsi
leaq (%rsi,%rsi,2), %rsi
movq %rsi, 0x38(%rsp)
movq (%rdx,%rsi), %rdx
movl (%rdx,%r12,4), %edx
movq %rdx, 0x20(%rsp)
movl 0x10(%rsp), %edx
imull (%rcx,%rax,4), %edx
movl %edx, 0x10(%rsp)
movq %r13, %rdi
movl %ebp, %esi
callq 0x373c
cltq
movq 0x18(%r14), %r14
leaq (%rax,%rax,2), %r15
movq %r13, %rdi
movl %r12d, %esi
callq 0x373c
cltq
movq (%r14,%r15,8), %rcx
movq 0x20(%rsp), %rdx
imull (%rcx,%rax,4), %edx
addl 0x8(%rsp), %edx
movq %rdx, 0x20(%rsp)
movq (%rbx), %r14
movq (%r14), %rax
movq 0x38(%rsp), %rcx
movq (%rax,%rcx), %rax
movl (%rax,%r12,4), %r15d
movq %r13, %rdi
movl %r12d, %esi
callq 0x373c
cltq
movq 0x18(%r14), %rcx
movq %rcx, 0x8(%rsp)
leaq (%rax,%rax,2), %r14
movq %r13, %rdi
movl %ebp, %esi
callq 0x373c
cltq
movq 0x8(%rsp), %rcx
movq (%rcx,%r14,8), %rcx
movq (%rbx), %r14
movq (%r14), %rdx
movq 0x40(%rsp), %rsi
movq (%rdx,%rsi), %rdx
movl (%rdx,%r12,4), %edx
movl %edx, 0x8(%rsp)
imull (%rcx,%rax,4), %r15d
addl 0x10(%rsp), %r15d
movq 0x20(%rsp), %rax
subl %r15d, %eax
movq %rax, 0x20(%rsp)
movq %r13, %rdi
movl %r12d, %esi
callq 0x373c
cltq
movq 0x18(%r14), %rbx
leaq (%rax,%rax,2), %r14
movq %r13, %rdi
movl %r12d, %esi
callq 0x373c
cltq
movq (%rbx,%r14,8), %rcx
movl 0x8(%rsp), %edx
imull (%rcx,%rax,4), %edx
movl %edx, 0x8(%rsp)
movq 0x28(%rsp), %rbx
movq (%rbx), %r14
movq (%r14), %rax
movq 0x40(%rsp), %rcx
movq (%rax,%rcx), %rax
movl (%rax,%r12,4), %eax
movl %eax, 0x1c(%rsp)
movq %r13, %rdi
movl %ebp, %esi
callq 0x373c
cltq
movq 0x18(%r14), %r14
leaq (%rax,%rax,2), %r15
movq %r13, %rdi
movl %ebp, %esi
callq 0x373c
cltq
movq (%r14,%r15,8), %rcx
movq (%rbx), %r15
movq (%r15), %rdx
movq 0x38(%rsp), %rsi
movq (%rdx,%rsi), %rdx
movl (%rdx,%rbp,4), %r14d
movl 0x1c(%rsp), %edx
imull (%rcx,%rax,4), %edx
movl %edx, 0x1c(%rsp)
movq %r13, %rdi
movl %ebp, %esi
callq 0x373c
cltq
movq 0x18(%r15), %r15
leaq (%rax,%rax,2), %rbx
movq %r13, %rdi
movl %ebp, %esi
callq 0x373c
cltq
movq (%r15,%rbx,8), %rcx
imull (%rcx,%rax,4), %r14d
addl 0x8(%rsp), %r14d
movq 0x28(%rsp), %rax
movq (%rax), %r15
movq (%r15), %rax
movq 0x38(%rsp), %rcx
movq (%rax,%rcx), %rax
movq %rbp, 0x48(%rsp)
movl (%rax,%rbp,4), %ebp
movq %r13, %rdi
movl %r12d, %esi
callq 0x373c
cltq
movq 0x18(%r15), %r15
leaq (%rax,%rax,2), %rbx
movq %r13, 0x60(%rsp)
movq %r13, %rdi
movq %r12, 0x10(%rsp)
movl %r12d, %esi
callq 0x373c
cltq
movq (%r15,%rbx,8), %rcx
imull (%rcx,%rax,4), %ebp
addl 0x1c(%rsp), %ebp
subl %ebp, %r14d
movq 0x20(%rsp), %rax
leal (%rax,%r14,2), %esi
movq 0x28(%rsp), %rax
movq (%rax), %rbx
cmpq $0x0, 0x30(%rbx)
je 0x4177
xorl %edi, %edi
xorl %r13d, %r13d
movq 0x48(%rsp), %r12
movq 0x10(%rsp), %rdx
movq 0x60(%rsp), %rbp
cmpq %r13, %rdx
sete %al
cmpq %r13, %r12
sete %cl
orb %al, %cl
jne 0x4166
movq (%rbx), %rax
movq (%rax,%rdi), %rax
movl (%rax,%rdx,4), %r15d
movq %rdi, 0x20(%rsp)
movq %rbp, %rdi
movl %esi, 0x1c(%rsp)
movl %r13d, %esi
callq 0x373c
cltq
movq 0x18(%rbx), %rbx
leaq (%rax,%rax,2), %r14
movq %rbp, %rdi
movq 0x10(%rsp), %rsi
callq 0x373c
cltq
movq (%rbx,%r14,8), %rcx
imull (%rcx,%rax,4), %r15d
movl %r15d, 0x5c(%rsp)
movq 0x28(%rsp), %rbx
movq (%rbx), %r14
movq (%r14), %rax
movq 0x20(%rsp), %rcx
movq (%rax,%rcx), %rax
movq 0x10(%rsp), %rcx
movl (%rax,%rcx,4), %r15d
movq %rbp, %rdi
movl %r13d, %esi
callq 0x373c
cltq
movq 0x18(%r14), %rcx
movq %rcx, 0x8(%rsp)
leaq (%rax,%rax,2), %r14
movq %rbp, %rdi
movq %r12, %rsi
callq 0x373c
cltq
movq 0x8(%rsp), %rcx
movq (%rcx,%r14,8), %rcx
movq (%rbx), %r14
movq (%r14), %rdx
movq 0x40(%rsp), %rsi
movq (%rdx,%rsi), %rdx
movl (%rdx,%r13,4), %r12d
imull (%rcx,%rax,4), %r15d
movl %r15d, 0x34(%rsp)
movq %rbp, %rdi
movq 0x10(%rsp), %rsi
callq 0x373c
cltq
movq 0x18(%r14), %r14
leaq (%rax,%rax,2), %r15
movq %rbp, %rdi
movl %r13d, %esi
callq 0x373c
cltq
movq (%r14,%r15,8), %rcx
imull (%rcx,%rax,4), %r12d
movl %r12d, 0x58(%rsp)
movq (%rbx), %r14
movq (%r14), %rax
movq 0x40(%rsp), %rcx
movq (%rax,%rcx), %rax
movl (%rax,%r13,4), %eax
movl %eax, 0x8(%rsp)
movq %rbp, %rdi
movq 0x48(%rsp), %r12
movl %r12d, %esi
callq 0x373c
cltq
movq 0x18(%r14), %r14
leaq (%rax,%rax,2), %r15
movq %rbp, %rdi
movl %r13d, %esi
callq 0x373c
cltq
movq (%r14,%r15,8), %rcx
movq (%rbx), %r14
movq (%r14), %rdx
movq 0x20(%rsp), %rsi
movq (%rdx,%rsi), %rdx
movl (%rdx,%r12,4), %ebx
movq %r12, %r15
movl 0x8(%rsp), %edx
imull (%rcx,%rax,4), %edx
addl 0x34(%rsp), %edx
movl %edx, 0x8(%rsp)
movq %rbp, %rdi
movl %r13d, %esi
callq 0x373c
cltq
movq 0x18(%r14), %r12
leaq (%rax,%rax,2), %r14
movq %rbp, %rdi
movl %r15d, %esi
callq 0x373c
cltq
movq (%r12,%r14,8), %rcx
imull (%rcx,%rax,4), %ebx
movl %ebx, 0x34(%rsp)
movq 0x28(%rsp), %rbx
movq (%rbx), %r14
movq (%r14), %rax
movq 0x20(%rsp), %rcx
movq (%rax,%rcx), %rax
movl (%rax,%r15,4), %r12d
movq %rbp, %rdi
movl %r13d, %esi
callq 0x373c
cltq
movq 0x18(%r14), %r14
leaq (%rax,%rax,2), %r15
movq %rbp, %rdi
movq 0x10(%rsp), %rsi
callq 0x373c
cltq
movq (%r14,%r15,8), %rcx
movq (%rbx), %r15
movq (%r15), %rdx
movq 0x38(%rsp), %rsi
movq (%rdx,%rsi), %rdx
movl (%rdx,%r13,4), %r14d
imull (%rcx,%rax,4), %r12d
movl %r12d, 0x54(%rsp)
movq %rbp, %rdi
movq 0x48(%rsp), %rsi
callq 0x373c
cltq
movq 0x18(%r15), %r15
leaq (%rax,%rax,2), %rbx
movq %rbp, %rdi
movl %r13d, %esi
callq 0x373c
cltq
movq (%r15,%rbx,8), %rcx
imull (%rcx,%rax,4), %r14d
addl 0x34(%rsp), %r14d
movq 0x28(%rsp), %rax
movq (%rax), %rbx
movq (%rbx), %rax
movq 0x38(%rsp), %rcx
movq (%rax,%rcx), %rax
movl (%rax,%r13,4), %r15d
movq %rbp, %rdi
movq 0x10(%rsp), %rsi
callq 0x373c
cltq
movq 0x18(%rbx), %rbx
leaq (%rax,%rax,2), %r12
movq %rbp, %rdi
movl %r13d, %esi
callq 0x373c
movq 0x20(%rsp), %rdi
movq 0x10(%rsp), %rdx
cltq
movq (%rbx,%r12,8), %rcx
movq 0x48(%rsp), %r12
imull (%rcx,%rax,4), %r15d
addl 0x54(%rsp), %r15d
addl 0x8(%rsp), %r15d
movl 0x5c(%rsp), %esi
addl 0x1c(%rsp), %esi
addl 0x58(%rsp), %esi
addl %r14d, %esi
subl %r15d, %esi
movq 0x28(%rsp), %rax
movq (%rax), %rbx
incq %r13
addq $0x18, %rdi
cmpq 0x30(%rbx), %r13
jb 0x3ed3
movl 0x50(%rsp), %eax
subl %esi, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq