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


x86 assembly (clang, -O0):
<mutateRandomParent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%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    11b5 <mutateRandomParent+0x85>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x1c(%rbp),%edi
call   1050 <randInt@plt>
mov    -0x38(%rbp),%rdi
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
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    1152 <mutateRandomParent+0x22>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mutateRandomParent>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,(%rsp)
test   %r8d,%r8d
jle    1191 <mutateRandomParent+0x61>
mov    %ecx,%r15d
mov    %rdx,%rbx
mov    %rdi,%r12
mov    %r8d,%r13d
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%rbx,%r14,8),%rbp
mov    %r15d,%edi
call   1050 <randInt@plt>
mov    (%rsp),%rcx
mov    (%rcx,%rax,8),%rsi
mov    %rbp,%rdi
call   1040 <copyChromosome@plt>
mov    (%rbx,%r14,8),%rsi
mov    %r12,%rdi
call   1030 <mutateChromosome@plt>
add    $0x1,%r14
cmp    %r14,%r13
jne    1160 <mutateRandomParent+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 @mutateRandomParent(%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
store i32 0, i32* %11
br label %12
12: ; preds = %35, %5
%13 = load i32, i32* %11
%14 = load i32, i32* %10
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %38
16: ; preds = %12
%17 = load %struct.chromosome**, %struct.chromosome*** %8
%18 = load i32, i32* %11
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds %struct.chromosome*, %struct.chromosome** %17, i64 %19
%21 = load %struct.chromosome*, %struct.chromosome** %20
%22 = load %struct.chromosome**, %struct.chromosome*** %7
%23 = load i32, i32* %9
%24 = call i64 @randInt(i32 %23)
%25 = getelementptr inbounds %struct.chromosome*, %struct.chromosome** %22, i64 %24
%26 = load %struct.chromosome*, %struct.chromosome** %25
%27 = call i32 @copyChromosome(%struct.chromosome* %21, %struct.chromosome* %26)
%28 = load %struct.parameters*, %struct.parameters** %6
%29 = load %struct.chromosome**, %struct.chromosome*** %8
%30 = load i32, i32* %11
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds %struct.chromosome*, %struct.chromosome** %29, i64 %31
%33 = load %struct.chromosome*, %struct.chromosome** %32
%34 = call i32 @mutateChromosome(%struct.parameters* %28, %struct.chromosome* %33)
br label %35
35: ; preds = %16
%36 = load i32, i32* %11
%37 = add nsw i32 %36, 1
store i32 %37, i32* %11
br label %12
38: ; preds = %12
ret void
}

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