// File: /workspace/github_c_makefile_star2_O0/kernfel[P]fNEAT/neat.c
// Function: mutate_population
int mutate_population( Population *pop, struct NEAT_Params *params, Individual **champions ) {
	int i, k, l, err=0;
	Node_Innovation ni[pop->num_members];
	Link_Innovation li[pop->num_members];
	int num_ni=0, num_li=0;
	for ( i=0; i<pop->num_members; i++ ) {
		// Don't mutate champions
		int is_champ=0;
		for ( k=0; k<pop->num_species; k++ ) {
			if ( &pop->members[i] == champions[k] ) {
				is_champ = 1;
				break;
			}
		}
		if ( is_champ )
			continue;
		
		// Shortcut
		CPPN *genotype =& pop->members[i].genotype;

		// Prepare for new innovations
		ni[num_ni].replaced_link = 0;
		li[num_li].innov_id = 0;

		// Mutate
		if (( err = mutate_CPPN( genotype, params, ni+num_ni, li+num_li ) ))
			return err;

		// Identify and collapse parallel node innovations
		if ( ni[num_ni].replaced_link ) {
			int collapsed=0;
			// Check through the previous innovations
			for ( k=0; k<num_ni; k++ ) {
				if ( ni[k].replaced_link == ni[num_ni].replaced_link ) {
					// An equivalent innovation is found. Find the relevant links and collapse their innov_id's
					// Note that updating moves the links within their containing array, hence the l++ as a security blanket
					for ( l=genotype->num_links-1; l>=0 && collapsed<2; l-- ) {
						if ( genotype->links[l].innov_id == ni[num_ni].link_out ) {
							CPPN_update_innov_id( genotype, genotype->links[l].innov_id, ni[k].link_out );
							collapsed++;
							l++;
						} else if ( genotype->links[l].innov_id == ni[num_ni].link_in ) {
							CPPN_update_innov_id( genotype, genotype->links[l].innov_id, ni[k].link_in );
							collapsed++;
							l++;
						}
					}
					ASSERT( collapsed==2 );
					break;
				}
			}
			
			// A truly new innovation
			if ( ! collapsed )
				num_ni++;
		}

		// Identify and collapse parallel link innovations
		if ( li[num_li].innov_id ) {
			int collapsed=0;
			// Check through the previous innovations
			for ( k=0; k<num_li; k++ ) {
				if ( li[k].type == li[num_li].type && li[k].from == li[num_li].from && li[k].to == li[num_li].to ) {
					// An equivalent innovation is found. Find the relevant link and collapse its innov_id
					for ( l=genotype->num_links-1; l>=0; l-- ) {
						if ( genotype->links[l].innov_id == li[num_li].innov_id ) {
							CPPN_update_innov_id( genotype, genotype->links[l].innov_id, li[k].innov_id );
							collapsed = 1;
							break;
						}
					}
					ASSERT( collapsed );
					break;
				}
			}
			
			// A truly new innovation
			if ( ! collapsed )
				num_li++;
		}
	}

	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, -0x30(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movq %rsp, %rcx
movq %rcx, -0x38(%rbp)
leaq (%rax,%rax,2), %rcx
leaq 0xf(,%rcx,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x80(%rbp)
movq %rcx, %rsp
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movq %rax, %rdx
shlq $0x4, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x78(%rbp)
movq %rcx, %rsp
movq %rax, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x50(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x54bc
movl $0x0, -0x54(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jge 0x5131
movq -0x10(%rbp), %rax
movq (%rax), %rax
movslq -0x24(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq -0x20(%rbp), %rcx
movslq -0x28(%rbp), %rdx
cmpq (%rcx,%rdx,8), %rax
jne 0x5124
movl $0x1, -0x54(%rbp)
jmp 0x5131
jmp 0x5126
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x50ef
cmpl $0x0, -0x54(%rbp)
je 0x513c
jmp 0x54ae
movq -0x78(%rbp), %rcx
movq -0x80(%rbp), %rdx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movslq -0x24(%rbp), %rsi
imulq $0x38, %rsi, %rsi
addq %rsi, %rax
movq %rax, -0x60(%rbp)
movslq -0x4c(%rbp), %rax
imulq $0xc, %rax, %rsi
movq %rdx, %rax
addq %rsi, %rax
movl $0x0, (%rax)
movslq -0x50(%rbp), %rsi
shlq $0x4, %rsi
movq %rcx, %rax
addq %rsi, %rax
movl $0x0, (%rax)
movq -0x60(%rbp), %rdi
movq -0x18(%rbp), %rsi
movslq -0x4c(%rbp), %rax
imulq $0xc, %rax, %rax
addq %rax, %rdx
movslq -0x50(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rcx
callq 0x24b0
movl %eax, -0x30(%rbp)
cmpl $0x0, %eax
je 0x51bf
movl -0x30(%rbp), %eax
movl %eax, -0x4(%rbp)
movl $0x1, -0x64(%rbp)
jmp 0x54c9
movq -0x80(%rbp), %rax
movslq -0x4c(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, (%rax)
je 0x535c
movl $0x0, -0x68(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jge 0x534b
movq -0x80(%rbp), %rcx
movslq -0x28(%rbp), %rax
imulq $0xc, %rax, %rdx
movq %rcx, %rax
addq %rdx, %rax
movl (%rax), %eax
movslq -0x4c(%rbp), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
cmpl (%rcx), %eax
jne 0x533b
movq -0x60(%rbp), %rax
movl 0x20(%rax), %eax
subl $0x1, %eax
movl %eax, -0x2c(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x2c(%rbp)
movb %al, -0x81(%rbp)
jl 0x5240
cmpl $0x2, -0x68(%rbp)
setl %al
movb %al, -0x81(%rbp)
movb -0x81(%rbp), %al
testb $0x1, %al
jne 0x524f
jmp 0x5339
movq -0x80(%rbp), %rcx
movq -0x60(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x2c(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movl (%rax), %eax
movslq -0x4c(%rbp), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x8(%rcx), %eax
jne 0x52bc
movq -0x80(%rbp), %rax
movq -0x60(%rbp), %rdi
movq -0x60(%rbp), %rcx
movq 0x18(%rcx), %rcx
movslq -0x2c(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movl (%rcx), %esi
movslq -0x28(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %edx
callq 0x3250
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x5329
movq -0x80(%rbp), %rcx
movq -0x60(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x2c(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movl (%rax), %eax
movslq -0x4c(%rbp), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x4(%rcx), %eax
jne 0x5327
movq -0x80(%rbp), %rax
movq -0x60(%rbp), %rdi
movq -0x60(%rbp), %rcx
movq 0x18(%rcx), %rcx
movslq -0x2c(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movl (%rcx), %esi
movslq -0x28(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %edx
callq 0x3250
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x5329
jmp 0x532b
movl -0x2c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x5225
jmp 0x534b
jmp 0x533d
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x51e5
cmpl $0x0, -0x68(%rbp)
jne 0x535a
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x535c
movq -0x78(%rbp), %rax
movslq -0x50(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
cmpl $0x0, (%rax)
je 0x54ac
movl $0x0, -0x6c(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x50(%rbp), %eax
jge 0x549b
movq -0x78(%rbp), %rcx
movslq -0x28(%rbp), %rdx
shlq $0x4, %rdx
movq %rcx, %rax
addq %rdx, %rax
movl 0x4(%rax), %eax
movslq -0x50(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
cmpl 0x4(%rcx), %eax
jne 0x548b
movq -0x78(%rbp), %rcx
movslq -0x28(%rbp), %rdx
shlq $0x4, %rdx
movq %rcx, %rax
addq %rdx, %rax
movl 0x8(%rax), %eax
movslq -0x50(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
cmpl 0x8(%rcx), %eax
jne 0x548b
movq -0x78(%rbp), %rcx
movslq -0x28(%rbp), %rdx
shlq $0x4, %rdx
movq %rcx, %rax
addq %rdx, %rax
movl 0xc(%rax), %eax
movslq -0x50(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
cmpl 0xc(%rcx), %eax
jne 0x548b
movq -0x60(%rbp), %rax
movl 0x20(%rax), %eax
subl $0x1, %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jl 0x5489
movq -0x78(%rbp), %rcx
movq -0x60(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x2c(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movl (%rax), %eax
movslq -0x50(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
cmpl (%rcx), %eax
jne 0x547c
movq -0x78(%rbp), %rax
movq -0x60(%rbp), %rdi
movq -0x60(%rbp), %rcx
movq 0x18(%rcx), %rcx
movslq -0x2c(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movl (%rcx), %esi
movslq -0x28(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl (%rax), %edx
callq 0x3250
movl $0x1, -0x6c(%rbp)
jmp 0x5489
jmp 0x547e
movl -0x2c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x5416
jmp 0x549b
jmp 0x548d
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x5382
cmpl $0x0, -0x6c(%rbp)
jne 0x54aa
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x54ac
jmp 0x54ae
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x50d1
movl -0x30(%rbp), %eax
movl %eax, -0x4(%rbp)
movl $0x1, -0x64(%rbp)
movq -0x38(%rbp), %rax
movq %rax, %rsp
movl -0x4(%rbp), %eax
movq %rbp, %rsp
popq %rbp
retq
nopl (%rax,%rax)