#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*/ mutateChromosome(struct parameters *, struct chromosome *);
void mutateEveryParent(struct parameters *params, struct chromosome **parents,
                       struct chromosome **children, int numParents,
                       int numChildren) {
  int i;
  int selectedParent;
  for (i = 0; i < numChildren; i++) {
    selectedParent = i % numParents;
    copyChromosome(children[i], parents[selectedParent]);
    mutateChromosome(params, children[i]);
  }
}


x86 assembly (clang, -O0):
<mutateEveryParent>:
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)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1198 <mutateEveryParent+0x78>
mov    -0x24(%rbp),%eax
cltd
idivl  -0x1c(%rbp)
mov    %edx,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1040 <copyChromosome@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <mutateChromosome@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1142 <mutateEveryParent+0x22>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mutateEveryParent>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %r8d,%r8d
jle    1178 <mutateEveryParent+0x58>
mov    %ecx,%r14d
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%r12
mov    %r8d,%r13d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebp,%eax
cltd
idiv   %r14d
mov    (%rbx,%rbp,8),%rdi
mov    (%r15,%rdx,8),%rsi
call   1040 <copyChromosome@plt>
mov    (%rbx,%rbp,8),%rsi
mov    %r12,%rdi
call   1030 <mutateChromosome@plt>
add    $0x1,%rbp
cmp    %rbp,%r13
jne    1150 <mutateEveryParent+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.parameters = type { i32 }
%struct.chromosome = type { i32 }
define void @mutateEveryParent(%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
%12 = 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
store i32 0, i32* %11
br label %13
13: ; preds = %39, %5
%14 = load i32, i32* %11
%15 = load i32, i32* %10
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %42
17: ; preds = %13
%18 = load i32, i32* %11
%19 = load i32, i32* %9
%20 = srem i32 %18, %19
store i32 %20, i32* %12
%21 = load %struct.chromosome**, %struct.chromosome*** %8
%22 = load i32, i32* %11
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds %struct.chromosome*, %struct.chromosome** %21, i64 %23
%25 = load %struct.chromosome*, %struct.chromosome** %24
%26 = load %struct.chromosome**, %struct.chromosome*** %7
%27 = load i32, i32* %12
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds %struct.chromosome*, %struct.chromosome** %26, i64 %28
%30 = load %struct.chromosome*, %struct.chromosome** %29
%31 = call i32 @copyChromosome(%struct.chromosome* %25, %struct.chromosome* %30)
%32 = load %struct.parameters*, %struct.parameters** %6
%33 = load %struct.chromosome**, %struct.chromosome*** %8
%34 = load i32, i32* %11
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds %struct.chromosome*, %struct.chromosome** %33, i64 %35
%37 = load %struct.chromosome*, %struct.chromosome** %36
%38 = call i32 @mutateChromosome(%struct.parameters* %32, %struct.chromosome* %37)
br label %39
39: ; preds = %17
%40 = load i32, i32* %11
%41 = add nsw i32 %40, 1
store i32 %41, i32* %11
br label %13
42: ; preds = %13
ret void
}

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