#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct parameters {
  int dummy;
};
struct chromosome {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ copyChromosome(struct chromosome *, struct chromosome *);
int /*<<< orphan*/ sortChromosomeArray(struct chromosome **, int);
void selectFittest(struct parameters *params, struct chromosome **parents,
                   struct chromosome **candidateChromos, int numParents,
                   int numCandidateChromos) {
  int i;
  sortChromosomeArray(candidateChromos, numCandidateChromos);
  for (i = 0; i < numParents; i++) {
    copyChromosome(parents[i], candidateChromos[i]);
  }
}


x86 assembly (clang, -O0):
<selectFittest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1030 <sortChromosomeArray@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1185 <selectFittest+0x65>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1040 <copyChromosome@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    114e <selectFittest+0x2e>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<selectFittest>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%ebp
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdx,%rdi
mov    %r8d,%esi
call   1030 <sortChromosomeArray@plt>
test   %ebp,%ebp
jle    1166 <selectFittest+0x46>
mov    %ebp,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r14,%rbx,8),%rdi
mov    (%r15,%rbx,8),%rsi
call   1040 <copyChromosome@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1150 <selectFittest+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.parameters = type { i32 }
%struct.chromosome = type { i32 }
define void @selectFittest(%struct.parameters* %0, %struct.chromosome** %1, %struct.chromosome** %2, i32 %3, i32 %4) {
%6 = alloca %struct.parameters*
%7 = alloca %struct.chromosome**
%8 = alloca %struct.chromosome**
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store %struct.parameters* %0, %struct.parameters** %6
store %struct.chromosome** %1, %struct.chromosome*** %7
store %struct.chromosome** %2, %struct.chromosome*** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%12 = load %struct.chromosome**, %struct.chromosome*** %8
%13 = load i32, i32* %10
%14 = call i32 @sortChromosomeArray(%struct.chromosome** %12, i32 %13)
store i32 0, i32* %11
br label %15
15: ; preds = %31, %5
%16 = load i32, i32* %11
%17 = load i32, i32* %9
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %34
19: ; preds = %15
%20 = load %struct.chromosome**, %struct.chromosome*** %7
%21 = load i32, i32* %11
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds %struct.chromosome*, %struct.chromosome** %20, i64 %22
%24 = load %struct.chromosome*, %struct.chromosome** %23
%25 = load %struct.chromosome**, %struct.chromosome*** %8
%26 = load i32, i32* %11
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds %struct.chromosome*, %struct.chromosome** %25, i64 %27
%29 = load %struct.chromosome*, %struct.chromosome** %28
%30 = call i32 @copyChromosome(%struct.chromosome* %24, %struct.chromosome* %29)
br label %31
31: ; preds = %19
%32 = load i32, i32* %11
%33 = add nsw i32 %32, 1
store i32 %33, i32* %11
br label %15
34: ; preds = %15
ret void
}

LLVM IR (-O2):
%struct.parameters = type { i32 }
%struct.chromosome = type { i32 }
define void @selectFittest(%struct.parameters* nocapture readnone %0, %struct.chromosome** nocapture %1, %struct.chromosome** %2, i32 %3, i32 %4) {
%6 = tail call i32 @sortChromosomeArray(%struct.chromosome** %2, i32 %4)
%7 = icmp sgt i32 %3, 0
br i1 %7, label %8, label %19
8: ; preds = %5
%9 = zext i32 %3 to i64
br label %10
10: ; preds = %8, %10
%11 = phi i64 [ 0, %8 ], [ %17, %10 ]
%12 = getelementptr inbounds %struct.chromosome*, %struct.chromosome** %1, i64 %11
%13 = load %struct.chromosome*, %struct.chromosome** %12
%14 = getelementptr inbounds %struct.chromosome*, %struct.chromosome** %2, i64 %11
%15 = load %struct.chromosome*, %struct.chromosome** %14
%16 = tail call i32 @copyChromosome(%struct.chromosome* %13, %struct.chromosome* %15)
%17 = add nuw nsw i64 %11, 1
%18 = icmp eq i64 %17, %9
br i1 %18, label %19, label %10
19: ; preds = %10, %5
ret void
}