#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 */

/* Variables and functions */
int arc4random_uniform(int);
int /*<<< orphan*/ choose_random(int *, int, int *, int);
void mutate(float chance, int *population, int population_size,
            int **playable_dates, int *playable_date_sizes, int team_size) {
  int treshold = chance * 1000;
  for (int i = 0; i < team_size; i++) {
    if (arc4random_uniform(1000) <= treshold) {
      choose_random((population + (i * (team_size - 1))), team_size - 1,
                    playable_dates[i], playable_date_sizes[i]);
    }
  }
}


x86 assembly (clang, -O0):
<mutate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movss  %xmm0,-0x4(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
movss  0xeb8(%rip),%xmm0
mulss  -0x4(%rbp),%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    11c8 <mutate+0xa8>
mov    $0x3e8,%edi
call   1040 <arc4random_uniform@plt>
cmp    -0x30(%rbp),%eax
jg     11b5 <mutate+0x95>
mov    -0x10(%rbp),%rdi
mov    -0x34(%rbp),%eax
mov    -0x2c(%rbp),%ecx
sub    $0x1,%ecx
imul   %ecx,%eax
cltq
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x2c(%rbp),%esi
sub    $0x1,%esi
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
call   1030 <choose_random@plt>
jmp    11ba <mutate+0x9a>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    115b <mutate+0x3b>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mutate>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,0x10(%rsp)
mov    %rdx,0x8(%rsp)
test   %r8d,%r8d
jle    11aa <mutate+0x8a>
mov    %rdi,%rbx
mulss  0xeb8(%rip),%xmm0
cvttss2si %xmm0,%r13d
lea    -0x1(%r8),%r12d
mov    %r8d,%ebp
lea    0x0(,%r12,4),%r14
xor    %r15d,%r15d
jmp    117c <mutate+0x5c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r15
add    %r14,%rbx
cmp    %r15,%rbp
je     11aa <mutate+0x8a>
mov    $0x3e8,%edi
call   1040 <arc4random_uniform@plt>
cmp    %r13d,%eax
jg     1170 <mutate+0x50>
mov    0x8(%rsp),%rax
mov    (%rax,%r15,8),%rdx
mov    0x10(%rsp),%rax
mov    (%rax,%r15,4),%ecx
mov    %rbx,%rdi
mov    %r12d,%esi
call   1030 <choose_random@plt>
jmp    1170 <mutate+0x50>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @mutate(float %0, i32* %1, i32 %2, i32** %3, i32* %4, i32 %5) {
%7 = alloca float
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32**
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store float %0, float* %7
store i32* %1, i32** %8
store i32 %2, i32* %9
store i32** %3, i32*** %10
store i32* %4, i32** %11
store i32 %5, i32* %12
%15 = load float, float* %7
%16 = fmul float %15, 1.000000e+03
%17 = fptosi float %16 to i32
store i32 %17, i32* %13
store i32 0, i32* %14
br label %18
18: ; preds = %48, %6
%19 = load i32, i32* %14
%20 = load i32, i32* %12
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %51
22: ; preds = %18
%23 = call i32 @arc4random_uniform(i32 1000)
%24 = load i32, i32* %13
%25 = icmp sle i32 %23, %24
br i1 %25, label %26, label %47
26: ; preds = %22
%27 = load i32*, i32** %8
%28 = load i32, i32* %14
%29 = load i32, i32* %12
%30 = sub nsw i32 %29, 1
%31 = mul nsw i32 %28, %30
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %27, i64 %32
%34 = load i32, i32* %12
%35 = sub nsw i32 %34, 1
%36 = load i32**, i32*** %10
%37 = load i32, i32* %14
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32*, i32** %36, i64 %38
%40 = load i32*, i32** %39
%41 = load i32*, i32** %11
%42 = load i32, i32* %14
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i32, i32* %41, i64 %43
%45 = load i32, i32* %44
%46 = call i32 @choose_random(i32* %33, i32 %35, i32* %40, i32 %45)
br label %47
47: ; preds = %26, %22
br label %48
48: ; preds = %47
%49 = load i32, i32* %14
%50 = add nsw i32 %49, 1
store i32 %50, i32* %14
br label %18
51: ; preds = %18
ret void
}

LLVM IR (-O2):
define void @mutate(float %0, i32* %1, i32 %2, i32** nocapture %3, i32* nocapture %4, i32 %5) {
%7 = fmul float %0, 1.000000e+03
%8 = fptosi float %7 to i32
%9 = icmp sgt i32 %5, 0
br i1 %9, label %10, label %14
10: ; preds = %6
%11 = add nsw i32 %5, -1
%12 = zext i32 %11 to i64
%13 = zext i32 %5 to i64
br label %15
14: ; preds = %27, %6
ret void
15: ; preds = %10, %27
%16 = phi i64 [ 0, %10 ], [ %28, %27 ]
%17 = tail call i32 @arc4random_uniform(i32 1000)
%18 = icmp sgt i32 %17, %8
br i1 %18, label %27, label %19
19: ; preds = %15
%20 = mul nsw i64 %16, %12
%21 = getelementptr inbounds i32, i32* %1, i64 %20
%22 = getelementptr inbounds i32*, i32** %3, i64 %16
%23 = load i32*, i32** %22
%24 = getelementptr inbounds i32, i32* %4, i64 %16
%25 = load i32, i32* %24
%26 = tail call i32 @choose_random(i32* %21, i32 %11, i32* %23, i32 %25)
br label %27
27: ; preds = %15, %19
%28 = add nuw nsw i64 %16, 1
%29 = icmp eq i64 %28, %13
br i1 %29, label %14, label %15
}