// File: /workspace/github_c_makefile_star2_O0/kernfel[P]fNEAT/neat.c
// Function: get_population_ranking
Individual ***get_population_ranking( Population *pop, int *err ) {
	Individual ***ranked=0;

	if (( *err = Malloc( ranked, pop->num_species*sizeof *ranked + pop->num_members*sizeof **ranked ) ))
		return 0;

	int i, j, all_indiv_seen=0, sp;
	for ( sp=0; sp<pop->num_species; sp++ ) {
		// Assign the primary array index to point to the right chunk
		ranked[sp] = (Individual **) &ranked[pop->num_species + all_indiv_seen];
		
		// Find all members...
		int sp_indiv_seen=0;
		for ( i=0; i<pop->num_members; i++ ) {
			// ...of that species...
			if ( pop->members[i].species_id == pop->species[sp].id ) {
				// Go through the conspecifics already in place...
				for ( j=0; j<sp_indiv_seen; j++ ) {
					// Shove the losers back...
					if ( pop->members[i].score > ranked[sp][j]->score ) {
						memmove( ranked[sp]+j+1, ranked[sp]+j, (sp_indiv_seen-j)*sizeof **ranked );
						break;
					}
				}
				// ... so as to maintain order.
				ranked[sp][j] = pop->members + i;
				sp_indiv_seen++;
			}
		}
		all_indiv_seen += sp_indiv_seen;
	}

	return ranked;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x10(%rbp), %rax
movslq 0x18(%rax), %rsi
shlq $0x3, %rsi
movq -0x10(%rbp), %rax
movslq 0x8(%rax), %rax
shlq $0x3, %rax
addq %rax, %rsi
leaq -0x20(%rbp), %rdi
callq 0x6330
movq -0x18(%rbp), %rcx
movl %eax, (%rcx)
cmpl $0x0, %eax
je 0x6194
movq $0x0, -0x8(%rbp)
jmp 0x631c
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jge 0x6314
movq -0x20(%rbp), %rdx
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
addl -0x2c(%rbp), %eax
cltq
shlq $0x3, %rax
addq %rax, %rdx
movq -0x20(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x62fd
movq -0x10(%rbp), %rax
movq (%rax), %rax
movslq -0x24(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl 0x30(%rax), %eax
movq -0x10(%rbp), %rcx
movq 0x10(%rcx), %rcx
movslq -0x30(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpl (%rcx), %eax
jne 0x62ed
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x62be
movq -0x10(%rbp), %rax
movq (%rax), %rax
movslq -0x24(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movsd 0x28(%rax), %xmm0
movq -0x20(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
ucomisd 0x28(%rax), %xmm0
jbe 0x62ae
movq -0x20(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movslq -0x28(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
addq $0x8, %rdi
movq -0x20(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movslq -0x28(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movl -0x34(%rbp), %eax
subl -0x28(%rbp), %eax
movslq %eax, %rdx
shlq $0x3, %rdx
callq 0x1120
jmp 0x62be
jmp 0x62b0
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x622a
movq -0x10(%rbp), %rax
movq (%rax), %rdx
movslq -0x24(%rbp), %rax
imulq $0x38, %rax, %rax
addq %rax, %rdx
movq -0x20(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x28(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x62ef
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x61e3
movl -0x34(%rbp), %eax
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x61a2
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)