// File: /workspace/github_c_makefile_star2_O3/kernfel[P]fNEAT/cppn.c
// Function: create_CPPN
int create_CPPN( CPPN *net, struct NEAT_Params *params )
{
	int i, j, err=0;
	
	// Determine number of nodes and links
	net->num_outputs = N_OUTPUTS;
	net->num_inputs = 2*DIMENSIONS + ((params->flags & CFL_USE_DIST)? 1:0) + ((params->flags & CFL_USE_BIAS)? 1:0);
	net->num_hidden = 0;
	if ( params->flags & CFL_MASK_INIT_UNLINKED ) {
		net->num_links = net->num_inputs * net->num_outputs;
	} else {
		net->num_links = 0;
		for ( i=0; i<net->num_outputs; i++ )
			if ( params->initially_linked_outputs[i] )
				net->num_links += net->num_inputs;
	}
	
	// Allocate the storage necessary
	if (( err = allocate_CPPN( net ) ))
		return err;

	// Create input and output nodes
	for ( i=0; i<net->num_inputs; i++ )
		net->nodes[i].func = CF_LINEAR;
	for ( i=0; i<net->num_outputs; i++ )
		net->nodes[i+net->num_inputs].func = params->output_funcs[i];

	// Create links from input to output nodes, where applicable
	for ( i=0; i<net->num_outputs; i++ ) {
		if ( ! (params->flags & CFL_MASK_INIT_UNLINKED) && ! params->initially_linked_outputs[i] )
			continue;
		for ( j=0; j<net->num_inputs; j++ ) {
			net->links[j].innov_id = ++params->innov_counter;
			net->links[j].from = j;
			net->links[j].to = i+net->num_inputs;
			net->links[j].weight = 0;
			net->links[j].is_disabled = ! params->initially_linked_outputs[i];
		}
	}

	return err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movl $0x1, 0xc(%rdi)
movl (%rsi), %ecx
movl %ecx, %eax
andl $0x1, %eax
btl $0x2, %ecx
adcl $0x0, %eax
orl $0x4, %eax
movl %eax, 0x8(%rdi)
movl $0x0, 0x10(%rdi)
testb %cl, %cl
js 0x1c0b
movl $0x0, 0x20(%r14)
movl 0x3c(%rbx), %ecx
testl %ecx, %ecx
cmovel %ecx, %eax
movl %eax, 0x20(%r14)
movq %r14, %rdi
callq 0x1dff
testl %eax, %eax
je 0x1c26
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movslq 0x8(%r14), %rcx
testq %rcx, %rcx
jle 0x1d38
movq (%r14), %rdx
leal 0x3(%rcx), %esi
leaq -0x1(%rcx), %rdi
movq %rdi, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
shrl $0x2, %esi
shlq $0x6, %rsi
movdqa 0x55fa(%rip), %xmm1     # 0x7250
movdqa 0x5602(%rip), %xmm2     # 0x7260
xorl %edi, %edi
movdqa 0x5608(%rip), %xmm3     # 0x7270
pxor %xmm3, %xmm0
pcmpeqd %xmm4, %xmm4
movdqa 0x5608(%rip), %xmm5     # 0x7280
movdqa %xmm2, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
movd %xmm6, %r8d
notl %r8d
testb $0x1, %r8b
je 0x1cb6
movl $0x3, (%rdx,%rdi)
pxor %xmm4, %xmm6
pextrw $0x4, %xmm6, %r8d
testb $0x1, %r8b
je 0x1cce
movl $0x3, 0x10(%rdx,%rdi)
movdqa %xmm1, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
pxor %xmm4, %xmm6
pextrw $0x0, %xmm6, %r8d
testb $0x1, %r8b
je 0x1d0f
movl $0x3, 0x20(%rdx,%rdi)
pextrw $0x4, %xmm6, %r8d
testb $0x1, %r8b
je 0x1d23
movl $0x3, 0x30(%rdx,%rdi)
paddq %xmm5, %xmm2
paddq %xmm5, %xmm1
addq $0x40, %rdi
cmpq %rdi, %rsi
jne 0x1c78
movslq 0xc(%r14), %rdx
testq %rdx, %rdx
jle 0x1c1b
movq %rcx, %rsi
shlq $0x4, %rsi
addq (%r14), %rsi
leaq (,%rdx,4), %rdi
xorl %r8d, %r8d
movl 0x38(%rbx,%r8), %r9d
movl %r9d, (%rsi,%r8,4)
addq $0x4, %r8
cmpq %r8, %rdi
jne 0x1d5a
testl %edx, %edx
jle 0x1c1b
movl (%rbx), %esi
cmpl $0x2, %ecx
movl $0x1, %edi
cmovgel %ecx, %edi
xorl %r8d, %r8d
testb %sil, %sil
js 0x1da0
testl %ecx, %ecx
setle %r9b
cmpl $0x0, 0x3c(%rbx,%r8,4)
sete %r10b
orb %r9b, %r10b
je 0x1da4
jmp 0x1df2
testl %ecx, %ecx
jle 0x1df2
movq 0x18(%r14), %r9
movl 0x108(%rbx), %r10d
leal (%r8,%rcx), %r11d
incl %r10d
xorl %r15d, %r15d
leal (%r10,%r15), %ebp
movl %ebp, 0x108(%rbx)
movl %ebp, (%r9)
movl %r15d, 0x4(%r9)
movl %r11d, 0x8(%r9)
movq $0x0, 0x10(%r9)
xorl %ebp, %ebp
cmpl $0x0, 0x3c(%rbx,%r8,4)
sete %bpl
movl %ebp, 0x18(%r9)
incq %r15
addq $0x20, %r9
cmpq %r15, %rdi
jne 0x1db9
incq %r8
cmpq %rdx, %r8
jne 0x1d84
jmp 0x1c1b