// File: /workspace/github_cpp_makefile_star2_O2/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, 0x20(%rsp)
movq %rsi, %rdi
callq 0x33d6
movl %eax, 0x48(%rsp)
movq (%rbx), %rbx
movq (%rbx), %rax
imulq $0x18, %r12, %r15
movq (%rax,%r15), %rax
movq %r15, 0x38(%rsp)
movl (%rax,%rbp,4), %r14d
movq %r13, %rdi
movl %r12d, %esi
callq 0x33cc
cltq
movq 0x18(%rbx), %rcx
movq %rcx, 0x10(%rsp)
imulq $0x18, %rax, %rbx
movq %r13, %rdi
movl %ebp, %esi
callq 0x33cc
cltq
movq 0x10(%rsp), %rcx
movq (%rcx,%rbx), %rcx
imull (%rcx,%rax,4), %r14d
movl %r14d, 0x8(%rsp)
movq 0x20(%rsp), %r14
movq (%r14), %rbx
movq (%rbx), %rax
movq (%rax,%r15), %rax
movl (%rax,%rbp,4), %eax
movl %eax, 0x10(%rsp)
movq %r13, %rdi
movl %ebp, %esi
callq 0x33cc
cltq
movq 0x18(%rbx), %rbx
imulq $0x18, %rax, %r15
movq %r13, %rdi
movl %r12d, %esi
callq 0x33cc
cltq
movq (%rbx,%r15), %rcx
movq (%r14), %r15
movq (%r15), %rdx
imulq $0x18, %rbp, %rsi
movq %rsi, 0x40(%rsp)
movq (%rdx,%rsi), %rdx
movl (%rdx,%r12,4), %r14d
movl 0x10(%rsp), %edx
imull (%rcx,%rax,4), %edx
movl %edx, 0x10(%rsp)
movq %r13, %rdi
movl %ebp, %esi
callq 0x33cc
cltq
movq 0x18(%r15), %r15
imulq $0x18, %rax, %rbx
movq %r13, %rdi
movl %r12d, %esi
callq 0x33cc
cltq
movq (%r15,%rbx), %rcx
movq %r14, %rbx
imull (%rcx,%rax,4), %ebx
addl 0x8(%rsp), %ebx
movq 0x20(%rsp), %rax
movq (%rax), %r14
movq (%r14), %rax
movq 0x40(%rsp), %rcx
movq (%rax,%rcx), %rax
movq %r12, 0x28(%rsp)
movl (%rax,%r12,4), %r15d
movq %r13, %rdi
movl %r12d, %esi
callq 0x33cc
cltq
movq 0x18(%r14), %r14
imulq $0x18, %rax, %r12
movq %r13, %rdi
movl %ebp, %esi
callq 0x33cc
cltq
movq (%r14,%r12), %rcx
movq 0x20(%rsp), %r14
movq (%r14), %r12
movq (%r12), %rdx
movq 0x38(%rsp), %rsi
movq (%rdx,%rsi), %rdx
movq 0x28(%rsp), %rsi
movl (%rdx,%rsi,4), %edx
movl %edx, 0x8(%rsp)
imull (%rcx,%rax,4), %r15d
addl 0x10(%rsp), %r15d
subl %r15d, %ebx
movq %rbx, 0x10(%rsp)
movq %r13, %rdi
movq %rsi, %rbx
callq 0x33cc
cltq
movq 0x18(%r12), %r15
imulq $0x18, %rax, %r12
movq %r13, %rdi
movl %ebx, %esi
callq 0x33cc
cltq
movq (%r15,%r12), %rcx
movl 0x8(%rsp), %edx
imull (%rcx,%rax,4), %edx
movl %edx, 0x8(%rsp)
movq (%r14), %r15
movq (%r15), %rax
movq 0x38(%rsp), %rcx
movq (%rax,%rcx), %rax
movl (%rax,%rbx,4), %r14d
movq %r13, %rdi
movl %ebp, %esi
callq 0x33cc
cltq
movq 0x18(%r15), %r15
imulq $0x18, %rax, %r12
movq %r13, %rdi
movl %ebp, %esi
callq 0x33cc
cltq
movq (%r15,%r12), %rcx
movq 0x20(%rsp), %rdx
movq (%rdx), %r12
movq (%r12), %rdx
movq 0x40(%rsp), %rbx
movq (%rdx,%rbx), %rdx
movl (%rdx,%rbp,4), %r15d
imull (%rcx,%rax,4), %r14d
movl %r14d, 0x1c(%rsp)
movq %r13, %rdi
movl %ebp, %esi
callq 0x33cc
cltq
movq 0x18(%r12), %r12
imulq $0x18, %rax, %r14
movq %r13, %rdi
movl %ebp, %esi
callq 0x33cc
cltq
movq (%r12,%r14), %rcx
imull (%rcx,%rax,4), %r15d
addl 0x8(%rsp), %r15d
movq 0x20(%rsp), %rax
movq (%rax), %r14
movq (%r14), %rax
movq (%rax,%rbx), %rax
movq %rbp, 0x58(%rsp)
movl (%rax,%rbp,4), %r12d
movq 0x28(%rsp), %rbx
movq %r13, %rdi
movl %ebx, %esi
callq 0x33cc
cltq
movq 0x18(%r14), %rcx
movq %rcx, 0x8(%rsp)
imulq $0x18, %rax, %r14
movq %r13, 0x60(%rsp)
movq %r13, %rdi
movq %rbx, %rbp
movl %ebx, %esi
callq 0x33cc
cltq
movq 0x8(%rsp), %rcx
movq (%rcx,%r14), %rcx
imull (%rcx,%rax,4), %r12d
addl 0x1c(%rsp), %r12d
subl %r12d, %r15d
movq 0x10(%rsp), %rax
leal (%rax,%r15,2), %esi
xorl %edx, %edx
xorl %r13d, %r13d
movq 0x60(%rsp), %rbx
movq 0x20(%rsp), %rax
movq (%rax), %r14
cmpq 0x30(%r14), %r13
jae 0x3ab9
cmpq %r13, %rbp
sete %al
movq 0x58(%rsp), %r12
cmpq %r13, %r12
sete %cl
orb %al, %cl
jne 0x3aad
movq (%r14), %rax
movq (%rax,%rdx), %rax
movq %rbp, %r15
movl (%rax,%rbp,4), %ebp
movq %rbx, %rdi
movl %esi, 0x54(%rsp)
movl %r13d, %esi
movq %rdx, 0x10(%rsp)
callq 0x33cc
cltq
movq 0x18(%r14), %rcx
movq %rcx, 0x8(%rsp)
imulq $0x18, %rax, %r14
movq %rbx, %rdi
movl %r15d, %esi
callq 0x33cc
cltq
movq 0x8(%rsp), %rcx
movq (%rcx,%r14), %rcx
imull (%rcx,%rax,4), %ebp
movl %ebp, 0x50(%rsp)
movq 0x20(%rsp), %rbp
movq (%rbp), %r14
movq (%r14), %rax
movq 0x10(%rsp), %rcx
movq (%rax,%rcx), %rax
movq 0x28(%rsp), %rcx
movl (%rax,%rcx,4), %r15d
movq %rbx, %rdi
movl %r13d, %esi
callq 0x33cc
cltq
movq 0x18(%r14), %rcx
movq %rcx, 0x8(%rsp)
imulq $0x18, %rax, %r14
movq %rbx, %rdi
movl %r12d, %esi
callq 0x33cc
cltq
movq 0x8(%rsp), %rcx
movq (%rcx,%r14), %rcx
movq (%rbp), %r14
movq (%r14), %rdx
movq 0x38(%rsp), %rsi
movq (%rdx,%rsi), %rdx
movl (%rdx,%r13,4), %ebp
imull (%rcx,%rax,4), %r15d
movl %r15d, 0x4c(%rsp)
movq %rbx, %rdi
movq 0x28(%rsp), %rsi
callq 0x33cc
cltq
movq 0x18(%r14), %r14
imulq $0x18, %rax, %r15
movq %rbx, %rdi
movl %r13d, %esi
callq 0x33cc
cltq
movq (%r14,%r15), %rcx
imull (%rcx,%rax,4), %ebp
movl %ebp, 0x34(%rsp)
movq 0x20(%rsp), %rbp
movq (%rbp), %r14
movq (%r14), %rax
movq 0x38(%rsp), %rcx
movq (%rax,%rcx), %rax
movl (%rax,%r13,4), %eax
movl %eax, 0x8(%rsp)
movq %rbx, %rdi
movl %r12d, %esi
callq 0x33cc
cltq
movq 0x18(%r14), %r15
imulq $0x18, %rax, %r14
movq %rbx, %rdi
movl %r13d, %esi
callq 0x33cc
cltq
movq (%r15,%r14), %rcx
movq (%rbp), %r14
movq (%r14), %rdx
movq 0x10(%rsp), %rsi
movq (%rdx,%rsi), %rdx
movl (%rdx,%r12,4), %edx
movl %edx, 0x1c(%rsp)
movl 0x8(%rsp), %r15d
imull (%rcx,%rax,4), %r15d
addl 0x4c(%rsp), %r15d
movl %r15d, 0x8(%rsp)
movq %rbx, %rdi
movl %r13d, %esi
callq 0x33cc
cltq
movq 0x18(%r14), %r14
imulq $0x18, %rax, %rbp
movq %rbx, %rdi
movq %r12, %r15
movl %r15d, %esi
callq 0x33cc
cltq
movq (%r14,%rbp), %rcx
movl 0x1c(%rsp), %edx
imull (%rcx,%rax,4), %edx
addl 0x34(%rsp), %edx
movl %edx, 0x1c(%rsp)
movq 0x20(%rsp), %r12
movq (%r12), %r14
movq (%r14), %rax
movq 0x10(%rsp), %rcx
movq (%rax,%rcx), %rax
movl (%rax,%r15,4), %ebp
movq %rbx, %rdi
movl %r13d, %esi
callq 0x33cc
cltq
movq 0x18(%r14), %r14
imulq $0x18, %rax, %r15
movq %rbx, %rdi
movq 0x28(%rsp), %rsi
callq 0x33cc
cltq
movq (%r14,%r15), %rcx
movq (%r12), %r14
movq (%r14), %rdx
movq 0x40(%rsp), %r12
movq (%rdx,%r12), %rdx
movl (%rdx,%r13,4), %r15d
imull (%rcx,%rax,4), %ebp
movl %ebp, 0x34(%rsp)
movq %rbx, %rdi
movq 0x58(%rsp), %rsi
callq 0x33cc
cltq
movq 0x18(%r14), %r14
imulq $0x18, %rax, %rbp
movq %rbx, %rdi
movl %r13d, %esi
callq 0x33cc
cltq
movq (%r14,%rbp), %rcx
imull (%rcx,%rax,4), %r15d
movq 0x20(%rsp), %rax
movq (%rax), %rbp
movq (%rbp), %rax
movq (%rax,%r12), %rax
movl (%rax,%r13,4), %r14d
movq %rbx, %rdi
movq 0x28(%rsp), %rsi
callq 0x33cc
cltq
movq 0x18(%rbp), %rbp
imulq $0x18, %rax, %r12
movq %rbx, %rdi
movl %r13d, %esi
callq 0x33cc
movq 0x10(%rsp), %rdx
cltq
movq (%rbp,%r12), %rcx
movq 0x28(%rsp), %rbp
imull (%rcx,%rax,4), %r14d
addl 0x34(%rsp), %r14d
addl 0x8(%rsp), %r14d
movl 0x50(%rsp), %esi
addl 0x54(%rsp), %esi
addl 0x1c(%rsp), %esi
addl %r15d, %esi
subl %r14d, %esi
incq %r13
addq $0x18, %rdx
jmp 0x37fe
movl 0x48(%rsp), %eax
subl %esi, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop