// File: /workspace/github_c_makefile_star2_O0/kernfel[P]fNEAT/neat.c
// Function: epoch
int epoch( Population *pop, struct NEAT_Params *params ) {
	int i, err=0;

	// Initialise next generation whilst saving a set of species representatives
	Individual reps[pop->num_species];
	Individual *champions[pop->num_species];
	int num_reps = pop->num_species;
	if (( err = reproduce_population( pop, params, reps, champions ) ))
		goto cleanup;

	// Mutate the entire new generation
	if (( err = mutate_population( pop, params, champions ) ))
		goto cleanup;

	// Divide the offspring into species
	if (( err = speciate_population( pop, params, reps ) ))
		goto cleanup;
	
	// Adjust the speciation threshold for next generation
	if ( params->target_num_species ) {
		if ( pop->num_species < params->target_num_species && params->speciation_threshold > params->d_speciation_threshold )
			params->speciation_threshold -= params->d_speciation_threshold;
		else if ( pop->num_species > params->target_num_species \
		 && params->speciation_threshold + params->d_speciation_threshold <= params->max_speciation_threshold )
			params->speciation_threshold += params->d_speciation_threshold;
	}

cleanup:
	if ( err != E_NO_OFFSPRING )
		for ( i=0; i<num_reps; i++ )
			if ( reps[i].species_id )
				delete_CPPN( &reps[i].genotype );

	return err;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x18(%rbp)
movq -0x8(%rbp), %rax
movl 0x18(%rax), %eax
movq %rsp, %rcx
movq %rcx, -0x20(%rbp)
imulq $0x38, %rax, %rcx
addq $0xf, %rcx
andq $-0x10, %rcx
movq %rsp, %rdx
subq %rcx, %rdx
movq %rdx, -0x48(%rbp)
movq %rdx, %rsp
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movl 0x18(%rax), %eax
leaq 0xf(,%rax,8), %rsi
andq $-0x10, %rsi
movq %rsp, %rcx
subq %rsi, %rcx
movq %rcx, -0x40(%rbp)
movq %rcx, %rsp
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x34(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x4980
movl %eax, -0x18(%rbp)
cmpl $0x0, %eax
je 0x484a
jmp 0x4923
movq -0x40(%rbp), %rdx
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x5050
movl %eax, -0x18(%rbp)
cmpl $0x0, %eax
je 0x4868
jmp 0x4923
movq -0x48(%rbp), %rdx
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x54e0
movl %eax, -0x18(%rbp)
cmpl $0x0, %eax
je 0x4886
jmp 0x4923
movq -0x10(%rbp), %rax
cmpl $0x0, 0x5c(%rax)
je 0x4921
movq -0x8(%rbp), %rax
movl 0x18(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x5c(%rcx), %eax
jge 0x48d5
movq -0x10(%rbp), %rax
movsd 0x68(%rax), %xmm0
movq -0x10(%rbp), %rax
ucomisd 0x70(%rax), %xmm0
jbe 0x48d5
movq -0x10(%rbp), %rax
movsd 0x70(%rax), %xmm1
movq -0x10(%rbp), %rax
movsd 0x68(%rax), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, 0x68(%rax)
jmp 0x491f
movq -0x8(%rbp), %rax
movl 0x18(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x5c(%rcx), %eax
jle 0x491d
movq -0x10(%rbp), %rax
movsd 0x68(%rax), %xmm1
movq -0x10(%rbp), %rax
addsd 0x70(%rax), %xmm1
movq -0x10(%rbp), %rax
movsd 0x78(%rax), %xmm0
ucomisd %xmm1, %xmm0
jb 0x491d
movq -0x10(%rbp), %rax
movsd 0x70(%rax), %xmm0
movq -0x10(%rbp), %rax
addsd 0x68(%rax), %xmm0
movsd %xmm0, 0x68(%rax)
jmp 0x491f
jmp 0x4921
jmp 0x4923
cmpl $-0xa, -0x18(%rbp)
je 0x4970
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x496e
movq -0x48(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x30(%rax)
je 0x4961
movq -0x48(%rbp), %rdi
movslq -0x14(%rbp), %rax
imulq $0x38, %rax, %rax
addq %rax, %rdi
callq 0x23a0
jmp 0x4963
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x4930
jmp 0x4970
movl -0x18(%rbp), %eax
movq -0x20(%rbp), %rcx
movq %rcx, %rsp
movq %rbp, %rsp
popq %rbp
retq
nop