// File: /workspace/github_c_makefile_star2_O0/kernfel[P]fNEAT/network.c
// Function: build_pNetwork
int build_pNetwork( pNetwork *net, CPPN *cppn, struct NEAT_Params *params, int num_inputs, const pNode *inputs, int num_outputs, const pNode *outputs ) {
	int block, index, err=0;
	unsigned int i;

	// Set up static input and output nodes
	pNode *tmp;
	for ( i=0; i<num_inputs; i++ ) {
		if (( err = add_pNode( net, inputs[i].x, &tmp ) ))
			return err;
	}
	for ( i=0; i<num_outputs; i++ ) {
		if (( err = add_pNode( net, outputs[i].x, &tmp ) ))
			return err;
	}
	net->num_inputs = num_inputs;
	net->num_outputs = num_outputs;

	struct Extraction_Params eparams = {0};
	eparams.params = params;
	eparams.cppn = cppn;
	eparams.net = net;

	if ( params->max_network_depth ) {
		// Extract links from input to first hidden layer
		eparams.outgoing = 1;
		eparams.create_nodes = 1;
		block = -1;
		for ( i=0; i<num_inputs; i++ ) {
			index = i % BLOCKSIZE_NODES;
			if ( ! index )
				block++;
			memcpy( eparams.ref, net->p_nodes[block][index].x, DIMENSIONS*sizeof *eparams.ref );
			if (( err = extract_links( &eparams ) ))
				return err;
		}

		// Extract deeper layers
		int depth;
		unsigned int i_start=num_inputs+num_outputs, i_end;
		block = (num_inputs+num_outputs-1) / BLOCKSIZE_NODES;
		for ( depth=1; depth < params->max_network_depth; depth++ ) {
			i_end = net->num_nodes;
			for ( i=i_start; i<i_end; i++ ) {
				index = i % BLOCKSIZE_NODES;
				if ( ! index )
					block++;
				memcpy( eparams.ref, net->p_nodes[block][index].x, DIMENSIONS*sizeof *eparams.ref );
				if (( err = extract_links( &eparams ) ))
					return err;
			}
			i_start = i_end;
		}
	}

	// Extract links to the output layer
	eparams.outgoing = 0;
	eparams.create_nodes = 0;
	block = (num_inputs-1) / BLOCKSIZE_NODES;
	for ( i=num_inputs; i<num_inputs+num_outputs; i++ ) {
		index = i % BLOCKSIZE_NODES;
		if ( ! index )
			block++;
		memcpy( eparams.ref, net->p_nodes[block][index].x, DIMENSIONS*sizeof *eparams.ref );
		if (( err = extract_links( &eparams ) ))
			return err;

		// Mark everything that connects to this output node
		if ( ! (params->flags & EFL_NO_BACKTRACKING) ) {
			backtrack( net, &net->p_nodes[block][index] );
		}
	}

	return err;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq %r8, -0x30(%rbp)
movl %r9d, -0x34(%rbp)
movl $0x0, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x24(%rbp), %eax
jae 0x78c7
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl -0x44(%rbp), %eax
imulq $0x18, %rax, %rax
addq %rax, %rsi
leaq -0x50(%rbp), %rdx
callq 0x7270
movl %eax, -0x40(%rbp)
cmpl $0x0, %eax
je 0x78ba
movl -0x40(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x7bb5
jmp 0x78bc
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x7884
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x34(%rbp), %eax
jae 0x7911
movq -0x10(%rbp), %rdi
movq 0x10(%rbp), %rsi
movl -0x44(%rbp), %eax
imulq $0x18, %rax, %rax
addq %rax, %rsi
leaq -0x50(%rbp), %rdx
callq 0x7270
movl %eax, -0x40(%rbp)
cmpl $0x0, %eax
je 0x7904
movl -0x40(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x7bb5
jmp 0x7906
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x78ce
movl -0x24(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x18(%rax)
movl -0x34(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1c(%rax)
leaq -0x88(%rbp), %rdi
xorl %esi, %esi
movl $0x38, %edx
callq 0x1070
movq -0x20(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, 0xc(%rax)
je 0x7adb
movb $0x1, -0x70(%rbp)
movb $0x1, -0x6f(%rbp)
movl $0xffffffff, -0x38(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x24(%rbp), %eax
jae 0x79ec
movl -0x44(%rbp), %eax
andl $0xff, %eax
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
jne 0x7996
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x3c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq %rcx, -0x80(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x78(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x6410
movl %eax, -0x40(%rbp)
cmpl $0x0, %eax
je 0x79df
movl -0x40(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x7bb5
jmp 0x79e1
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x7974
movl -0x24(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x90(%rbp)
movl -0x24(%rbp), %eax
addl -0x34(%rbp), %eax
subl $0x1, %eax
movl $0x100, %ecx            # imm = 0x100
cltd
idivl %ecx
movl %eax, -0x38(%rbp)
movl $0x1, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jge 0x7ad9
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x94(%rbp)
movl -0x90(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x94(%rbp), %eax
jae 0x7ab9
movl -0x44(%rbp), %eax
andl $0xff, %eax
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
jne 0x7a63
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x3c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq %rcx, -0x80(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x78(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x6410
movl %eax, -0x40(%rbp)
cmpl $0x0, %eax
je 0x7aac
movl -0x40(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x7bb5
jmp 0x7aae
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x7a3e
movl -0x94(%rbp), %eax
movl %eax, -0x90(%rbp)
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0x7a16
jmp 0x7adb
movb $0x0, -0x70(%rbp)
movb $0x0, -0x6f(%rbp)
movl -0x24(%rbp), %eax
subl $0x1, %eax
movl $0x100, %ecx            # imm = 0x100
cltd
idivl %ecx
movl %eax, -0x38(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
movl -0x24(%rbp), %ecx
addl -0x34(%rbp), %ecx
cmpl %ecx, %eax
jae 0x7baf
movl -0x44(%rbp), %eax
andl $0xff, %eax
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
jne 0x7b25
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x3c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq %rcx, -0x80(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x78(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x6410
movl %eax, -0x40(%rbp)
cmpl $0x0, %eax
je 0x7b6b
movl -0x40(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x7bb5
movq -0x20(%rbp), %rax
movl (%rax), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
jne 0x7b9f
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movslq -0x3c(%rbp), %rax
imulq $0x18, %rax, %rax
addq %rax, %rsi
callq 0x7bd0
jmp 0x7ba1
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x7afa
movl -0x40(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)