// File: /workspace/github_c_makefile_star2_O0/kernfel[P]fNEAT/cppn.c
// Function: crossover_CPPN
int crossover_CPPN( CPPN *net1, const CPPN *net2, struct NEAT_Params *params ) {
	int err=0, i, j;
	
	int num_nodes_net1 = net1->num_inputs+net1->num_outputs+net1->num_hidden;
	
	int nodemap[net2->num_inputs+net2->num_outputs+net2->num_hidden];
	for ( i=0; i<net2->num_inputs+net2->num_outputs+net2->num_hidden; i++ )
		nodemap[i] = -1;
	
	CPPN_Link *extra_links[net2->num_links];
	int num_extra=0;
	i=0;
	j=0;
	while ( i<net1->num_links && j<net2->num_links ) {
		if ( net1->links[i].innov_id == net2->links[j].innov_id ) {
			// Add matching nodes to the node mapping, then move on
			nodemap[net2->links[j].from] = net1->links[i].from;
			nodemap[net2->links[j].to] = net1->links[i].to;
			i++;
			j++;
		} else if ( net1->links[i].innov_id > net2->links[j].innov_id ) {
			// Disjoint in net2, track
			extra_links[num_extra++] = &net2->links[j];
			j++;
		} else {
			// Disjoint in net1, ignore
			i++;
		}
	}
	for ( ; j<net2->num_links; j++ ) {
		// Excess in net2
		extra_links[num_extra++] = &net2->links[j];
	}
	
	// Nothing to add, bail
	if ( ! num_extra )
		return 0;
	
	// Determine extra nodes - assume hidden for now
	CPPN_Node *extra_nodes[num_extra];
	int num_extra_nodes=0;
	for ( i=0; i<num_extra; i++ ) {
		if ( nodemap[extra_links[i]->from] == -1 ) {
			extra_nodes[num_extra_nodes] = &net2->nodes[extra_links[i]->from];
			nodemap[extra_links[i]->from] = num_nodes_net1 + num_extra_nodes;
			num_extra_nodes++;
		}
		if ( nodemap[extra_links[i]->to] == -1 ) {
			extra_nodes[num_extra_nodes] = &net2->nodes[extra_links[i]->to];
			nodemap[extra_links[i]->to] = num_nodes_net1 + num_extra_nodes;
			num_extra_nodes++;
		}
	}
	
	// Add extra nodes
	if ( num_extra_nodes ) {
		if (( err = Realloc( net1->nodes, (num_nodes_net1+num_extra_nodes)*sizeof *net1->nodes ) ))
			return err;
		for ( i=0; i<num_extra_nodes; i++ ) {
			memcpy( &net1->nodes[num_nodes_net1+i], extra_nodes[i], sizeof(CPPN_Node) );
		}
		net1->num_hidden += num_extra_nodes;
		num_nodes_net1 += num_extra_nodes;
	}

	// Eliminate duplicates and recursions, then add remaining links
	int *downstream_tpl, *downstream;
	if ( ! (params->flags & CFL_ALLOW_RECURRENCE) ) {
		if (( err = Malloc( downstream_tpl, num_nodes_net1*2*sizeof(int) ) ))
			return err;
		for ( i=0; i<num_nodes_net1; i++ )
			downstream_tpl[i] = 1;
		downstream = &downstream_tpl[num_nodes_net1];
	}
	for ( i=0; i<num_extra; i++ ) {
		
		// Exclude duplicates
		for ( j=0; j<net1->num_links; j++ ) {
			if ( net1->links[j].from == nodemap[extra_links[i]->from] \
			 && net1->links[j].to == nodemap[extra_links[i]->to] ) {
				extra_links[i] = 0;
				break;
			}
		}
		
		// Exclude recursions
		if ( ! (params->flags & CFL_ALLOW_RECURRENCE) && extra_links[i] ) {
			memcpy( downstream, downstream_tpl, num_nodes_net1*sizeof *downstream );
			CPPN_exclude_recurrent_links( net1, params, nodemap[extra_links[i]->to], downstream );
			if ( ! downstream[nodemap[extra_links[i]->from]] )
				extra_links[i] = 0;
		}

		if ( ! extra_links[i] )
			continue;

		// Add extra links
		if (( err = CPPN_insert_link(
			net1,
			params,
			nodemap[extra_links[i]->from],
			nodemap[extra_links[i]->to],
			extra_links[i]->weight,
			extra_links[i]->is_disabled,
			extra_links[i]->innov_id
		) ))
			goto cleanup;
	}

cleanup:
	if ( ! (params->flags & CFL_ALLOW_RECURRENCE) )
		free( downstream_tpl );
	
	return err;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x10(%rbp), %rcx
movl 0x8(%rcx), %eax
movl 0xc(%rcx), %edx
addl %edx, %eax
movl 0x10(%rcx), %ecx
addl %ecx, %eax
movl %eax, -0x30(%rbp)
movq -0x18(%rbp), %rcx
movl 0x8(%rcx), %eax
movl 0xc(%rcx), %edx
addl %edx, %eax
movl 0x10(%rcx), %ecx
addl %ecx, %eax
movq %rsp, %rcx
movq %rcx, -0x38(%rbp)
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x78(%rbp)
movq %rcx, %rsp
movq %rax, -0x40(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
movq -0x18(%rbp), %rcx
movl 0x8(%rcx), %ecx
movq -0x18(%rbp), %rdx
addl 0xc(%rdx), %ecx
movq -0x18(%rbp), %rdx
addl 0x10(%rdx), %ecx
cmpl %ecx, %eax
jge 0x3d64
movq -0x78(%rbp), %rax
movslq -0x28(%rbp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x3d2e
movq -0x18(%rbp), %rax
movl 0x20(%rax), %eax
leaq 0xf(,%rax,8), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x80(%rbp)
movq %rcx, %rsp
movq %rax, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x28(%rbp), %ecx
movq -0x10(%rbp), %rdx
xorl %eax, %eax
cmpl 0x20(%rdx), %ecx
movb %al, -0x81(%rbp)
jge 0x3dc4
movl -0x2c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x20(%rcx), %eax
setl %al
movb %al, -0x81(%rbp)
movb -0x81(%rbp), %al
testb $0x1, %al
jne 0x3dd3
jmp 0x3ee7
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x28(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl (%rax), %eax
movq -0x18(%rbp), %rcx
movq 0x18(%rcx), %rcx
movslq -0x2c(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
cmpl (%rcx), %eax
jne 0x3e77
movq -0x78(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
movslq -0x28(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movl 0x4(%rcx), %edx
movq -0x18(%rbp), %rcx
movq 0x18(%rcx), %rcx
movslq -0x2c(%rbp), %rsi
shlq $0x5, %rsi
addq %rsi, %rcx
movslq 0x4(%rcx), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
movslq -0x28(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %edx
movq -0x18(%rbp), %rcx
movq 0x18(%rcx), %rcx
movslq -0x2c(%rbp), %rsi
shlq $0x5, %rsi
addq %rsi, %rcx
movslq 0x8(%rcx), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x3ee2
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x28(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl (%rax), %eax
movq -0x18(%rbp), %rcx
movq 0x18(%rcx), %rcx
movslq -0x2c(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
cmpl (%rcx), %eax
jbe 0x3ed7
movq -0x80(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x18(%rcx), %rdx
movslq -0x2c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rdx
movl -0x4c(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x4c(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x3ee0
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x3ee2
jmp 0x3d9d
jmp 0x3ee9
movl -0x2c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x20(%rcx), %eax
jge 0x3f29
movq -0x80(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x18(%rcx), %rdx
movslq -0x2c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rdx
movl -0x4c(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x4c(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x3ee9
cmpl $0x0, -0x4c(%rbp)
jne 0x3f42
movl $0x0, -0x4(%rbp)
movl $0x1, -0x50(%rbp)
jmp 0x435e
movl -0x4c(%rbp), %eax
leaq 0xf(,%rax,8), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x90(%rbp)
movq %rcx, %rsp
movq %rax, -0x58(%rbp)
movl $0x0, -0x5c(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jge 0x4061
movq -0x78(%rbp), %rax
movq -0x80(%rbp), %rcx
movslq -0x28(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq 0x4(%rcx), %rcx
cmpl $-0x1, (%rax,%rcx,4)
jne 0x3fe8
movq -0x78(%rbp), %rax
movq -0x80(%rbp), %rcx
movq -0x90(%rbp), %rdx
movq -0x18(%rbp), %rsi
movq (%rsi), %rdi
movslq -0x28(%rbp), %rsi
movq (%rcx,%rsi,8), %rsi
movslq 0x4(%rsi), %rsi
shlq $0x4, %rsi
addq %rsi, %rdi
movslq -0x5c(%rbp), %rsi
movq %rdi, (%rdx,%rsi,8)
movl -0x30(%rbp), %edx
addl -0x5c(%rbp), %edx
movslq -0x28(%rbp), %rsi
movq (%rcx,%rsi,8), %rcx
movslq 0x4(%rcx), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
movq -0x78(%rbp), %rax
movq -0x80(%rbp), %rcx
movslq -0x28(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq 0x8(%rcx), %rcx
cmpl $-0x1, (%rax,%rcx,4)
jne 0x4051
movq -0x78(%rbp), %rax
movq -0x80(%rbp), %rcx
movq -0x90(%rbp), %rdx
movq -0x18(%rbp), %rsi
movq (%rsi), %rdi
movslq -0x28(%rbp), %rsi
movq (%rcx,%rsi,8), %rsi
movslq 0x8(%rsi), %rsi
shlq $0x4, %rsi
addq %rsi, %rdi
movslq -0x5c(%rbp), %rsi
movq %rdi, (%rdx,%rsi,8)
movl -0x30(%rbp), %edx
addl -0x5c(%rbp), %edx
movslq -0x28(%rbp), %rsi
movq (%rcx,%rsi,8), %rcx
movslq 0x8(%rcx), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x4053
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x3f73
cmpl $0x0, -0x5c(%rbp)
je 0x40ff
movq -0x10(%rbp), %rdi
movl -0x30(%rbp), %eax
addl -0x5c(%rbp), %eax
movslq %eax, %rsi
shlq $0x4, %rsi
callq 0x63c0
movl %eax, -0x24(%rbp)
cmpl $0x0, %eax
je 0x409b
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
movl $0x1, -0x50(%rbp)
jmp 0x435e
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jge 0x40e9
movq -0x90(%rbp), %rcx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl -0x30(%rbp), %edx
addl -0x28(%rbp), %edx
movslq %edx, %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movslq -0x28(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x8(%rax)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x40a2
movl -0x5c(%rbp), %ecx
movq -0x10(%rbp), %rax
addl 0x10(%rax), %ecx
movl %ecx, 0x10(%rax)
movl -0x5c(%rbp), %eax
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
jne 0x4178
movl -0x30(%rbp), %eax
shll %eax
movslq %eax, %rsi
shlq $0x2, %rsi
leaq -0x68(%rbp), %rdi
callq 0x6330
movl %eax, -0x24(%rbp)
cmpl $0x0, %eax
je 0x413c
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
movl $0x1, -0x50(%rbp)
jmp 0x435e
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x30(%rbp), %eax
jge 0x4165
movq -0x68(%rbp), %rax
movslq -0x28(%rbp), %rcx
movl $0x1, (%rax,%rcx,4)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x4143
movq -0x68(%rbp), %rax
movslq -0x30(%rbp), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jge 0x4338
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x20(%rcx), %eax
jge 0x4222
movq -0x78(%rbp), %rcx
movq -0x80(%rbp), %rdx
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x2c(%rbp), %rsi
shlq $0x5, %rsi
addq %rsi, %rax
movl 0x4(%rax), %eax
movslq -0x28(%rbp), %rsi
movq (%rdx,%rsi,8), %rdx
movslq 0x4(%rdx), %rdx
cmpl (%rcx,%rdx,4), %eax
jne 0x4212
movq -0x78(%rbp), %rcx
movq -0x80(%rbp), %rdx
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x2c(%rbp), %rsi
shlq $0x5, %rsi
addq %rsi, %rax
movl 0x8(%rax), %eax
movslq -0x28(%rbp), %rsi
movq (%rdx,%rsi,8), %rdx
movslq 0x8(%rdx), %rdx
cmpl (%rcx,%rdx,4), %eax
jne 0x4212
movq -0x80(%rbp), %rax
movslq -0x28(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
jmp 0x4222
jmp 0x4214
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x4192
movq -0x20(%rbp), %rax
movl (%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
jne 0x42b4
movq -0x80(%rbp), %rax
movslq -0x28(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x42b4
movq -0x70(%rbp), %rdi
movq -0x68(%rbp), %rsi
movslq -0x30(%rbp), %rdx
shlq $0x2, %rdx
callq 0x10d0
movq -0x80(%rbp), %rcx
movq -0x78(%rbp), %rax
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movslq -0x28(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq 0x8(%rcx), %rcx
movl (%rax,%rcx,4), %edx
movq -0x70(%rbp), %rcx
callq 0x3150
movq -0x80(%rbp), %rdx
movq -0x78(%rbp), %rcx
movq -0x70(%rbp), %rax
movslq -0x28(%rbp), %rsi
movq (%rdx,%rsi,8), %rdx
movslq 0x4(%rdx), %rdx
movslq (%rcx,%rdx,4), %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0x42b2
movq -0x80(%rbp), %rax
movslq -0x28(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
jmp 0x42b4
movq -0x80(%rbp), %rax
movslq -0x28(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jne 0x42c5
jmp 0x432a
movq -0x80(%rbp), %rax
movq -0x78(%rbp), %rcx
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movslq -0x28(%rbp), %rdx
movq (%rax,%rdx,8), %rdx
movslq 0x4(%rdx), %rdx
movl (%rcx,%rdx,4), %edx
movslq -0x28(%rbp), %r8
movq (%rax,%r8,8), %r8
movslq 0x8(%r8), %r8
movl (%rcx,%r8,4), %ecx
movslq -0x28(%rbp), %r8
movq (%rax,%r8,8), %r8
movsd 0x10(%r8), %xmm0
movslq -0x28(%rbp), %r8
movq (%rax,%r8,8), %r8
movl 0x18(%r8), %r8d
movslq -0x28(%rbp), %r9
movq (%rax,%r9,8), %rax
movl (%rax), %r9d
callq 0x3000
movl %eax, -0x24(%rbp)
cmpl $0x0, %eax
je 0x4328
jmp 0x433a
jmp 0x432a
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x417f
jmp 0x433a
movq -0x20(%rbp), %rax
movl (%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
jne 0x4351
movq -0x68(%rbp), %rdi
callq 0x1030
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
movl $0x1, -0x50(%rbp)
movq -0x38(%rbp), %rax
movq %rax, %rsp
movl -0x4(%rbp), %eax
movq %rbp, %rsp
popq %rbp
retq
nopl (%rax)