// File: /workspace/github_c_makefile_star2_O0/kernfel[P]fNEAT/cppn.c
// Function: get_genetic_distance
double get_genetic_distance( const CPPN *net1, const CPPN *net2, const struct NEAT_Params *params ) {
	int disjoint=0, excess=0, matches=0, n=max(net1->num_links, net2->num_links);
	double w1, w2, wdiff=0.0;
	int i=0, j=0;
	
	while ( i<net1->num_links && j<net2->num_links ) {
		if ( net1->links[i].innov_id == net2->links[j].innov_id ) {
			matches++;
			w1 = net1->links[i].is_disabled ? 0.0 : net1->links[i].weight;
			w2 = net2->links[j].is_disabled ? 0.0 : net2->links[j].weight;
			wdiff += fabs(w1-w2);
			i++;
			j++;
		} else if ( net1->links[i].innov_id > net2->links[j].innov_id ) {
			disjoint++;
			j++;
		} else {
			disjoint++;
			i++;
		}
	}

	if ( i == net1->num_links )
		excess = net2->num_links - j;
	else
		excess = net1->num_links - i;
	
	if ( params->flags & CFL_NO_DISTCALC_NORM )
		return params->disjoint_factor*disjoint + params->excess_factor*excess + params->weight_factor*wdiff/n;
	else
		return params->disjoint_factor*disjoint/n + params->excess_factor*excess/n + params->weight_factor*wdiff/n;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movl 0x20(%rax), %eax
movq -0x18(%rbp), %rcx
cmpl 0x20(%rcx), %eax
jle 0x3a11
movq -0x10(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, -0x54(%rbp)
jmp 0x3a1b
movq -0x18(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
movl %eax, -0x30(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x50(%rbp)
movl -0x4c(%rbp), %ecx
movq -0x10(%rbp), %rdx
xorl %eax, %eax
cmpl 0x20(%rdx), %ecx
movb %al, -0x55(%rbp)
jge 0x3a58
movl -0x50(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x20(%rcx), %eax
setl %al
movb %al, -0x55(%rbp)
movb -0x55(%rbp), %al
testb $0x1, %al
jne 0x3a64
jmp 0x3bbd
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x4c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl (%rax), %eax
movq -0x18(%rbp), %rcx
movq 0x18(%rcx), %rcx
movslq -0x50(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
cmpl (%rcx), %eax
jne 0x3b64
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x4c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $0x0, 0x18(%rax)
je 0x3ac0
xorps %xmm0, %xmm0
movsd %xmm0, -0x60(%rbp)
jmp 0x3add
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x4c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x60(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x50(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $0x0, 0x18(%rax)
je 0x3b0a
xorps %xmm0, %xmm0
movsd %xmm0, -0x68(%rbp)
jmp 0x3b27
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x50(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x68(%rbp)
movsd -0x68(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x38(%rbp), %xmm0
subsd -0x40(%rbp), %xmm0
movaps 0x666e(%rip), %xmm1     # 0xa1b0
pand %xmm1, %xmm0
addsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x3bb8
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x4c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl (%rax), %eax
movq -0x18(%rbp), %rcx
movq 0x18(%rcx), %rcx
movslq -0x50(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
cmpl (%rcx), %eax
jbe 0x3ba4
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x3bb6
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x3bb8
jmp 0x3a37
movl -0x4c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x20(%rcx), %eax
jne 0x3bd8
movq -0x18(%rbp), %rax
movl 0x20(%rax), %eax
subl -0x50(%rbp), %eax
movl %eax, -0x28(%rbp)
jmp 0x3be5
movq -0x10(%rbp), %rax
movl 0x20(%rax), %eax
subl -0x4c(%rbp), %eax
movl %eax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x3c48
movq -0x20(%rbp), %rax
movsd 0x80(%rax), %xmm0
cvtsi2sdl -0x24(%rbp), %xmm2
movq -0x20(%rbp), %rax
movsd 0x88(%rax), %xmm1
cvtsi2sdl -0x28(%rbp), %xmm3
mulsd %xmm3, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x20(%rbp), %rax
movsd 0x90(%rax), %xmm1
mulsd -0x48(%rbp), %xmm1
cvtsi2sdl -0x30(%rbp), %xmm2
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x3cab
movq -0x20(%rbp), %rax
movsd 0x80(%rax), %xmm0
cvtsi2sdl -0x24(%rbp), %xmm1
mulsd %xmm1, %xmm0
cvtsi2sdl -0x30(%rbp), %xmm1
divsd %xmm1, %xmm0
movq -0x20(%rbp), %rax
movsd 0x88(%rax), %xmm1
cvtsi2sdl -0x28(%rbp), %xmm2
mulsd %xmm2, %xmm1
cvtsi2sdl -0x30(%rbp), %xmm2
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movq -0x20(%rbp), %rax
movsd 0x90(%rax), %xmm1
mulsd -0x48(%rbp), %xmm1
cvtsi2sdl -0x30(%rbp), %xmm2
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, -0x8(%rbp)
movsd -0x8(%rbp), %xmm0
popq %rbp
retq
nopw %cs:(%rax,%rax)