#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 Individual {
  int dummy;
};
struct Encoding {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ assert(int /*<<< orphan*/);
double random_double_inclusive(double, double);
int /*<<< orphan*/ single_point_mutation(struct Individual *,
                                         struct Encoding *);
double stub1(struct Individual *);
int mutagen(double (*risk)(struct Individual *), struct Individual *victim,
            struct Encoding *e) {
  assert(risk != NULL);
  assert(victim != NULL);
  assert(e != NULL);
  int mutated = 0;
  double luck = random_double_inclusive(0.0, 1.0);
  if (luck < (*risk)(victim)) {
    single_point_mutation(victim, e);
    mutated = 1;
  }
  return mutated;
}


x86 assembly (clang, -O0):
<mutagen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpq   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movl   $0x0,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movsd  0xe74(%rip),%xmm1
call   1040 <random_double_inclusive@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rdi
call   *%rax
movsd  -0x30(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    11cd <mutagen+0x9d>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <single_point_mutation@plt>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mutagen>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1030 <assert@plt>
xor    %edi,%edi
test   %r15,%r15
setne  %dil
call   1030 <assert@plt>
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1030 <assert@plt>
movsd  0xe8c(%rip),%xmm1
xorpd  %xmm0,%xmm0
call   1040 <random_double_inclusive@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r15,%rdi
call   *%rbx
xor    %eax,%eax
ucomisd 0x8(%rsp),%xmm0
jbe    11a2 <mutagen+0x72>
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <single_point_mutation@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.Individual = type { i32 }
%struct.Encoding = type { i32 }
define i32 @mutagen(double (%struct.Individual*)* %0, %struct.Individual* %1, %struct.Encoding* %2) {
%4 = alloca double (%struct.Individual*)*
%5 = alloca %struct.Individual*
%6 = alloca %struct.Encoding*
%7 = alloca i32
%8 = alloca double
store double (%struct.Individual*)* %0, double (%struct.Individual*)** %4
store %struct.Individual* %1, %struct.Individual** %5
store %struct.Encoding* %2, %struct.Encoding** %6
%9 = load double (%struct.Individual*)*, double (%struct.Individual*)** %4
%10 = icmp ne double (%struct.Individual*)* %9, null
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = load %struct.Individual*, %struct.Individual** %5
%14 = icmp ne %struct.Individual* %13, null
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = load %struct.Encoding*, %struct.Encoding** %6
%18 = icmp ne %struct.Encoding* %17, null
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
store i32 0, i32* %7
%21 = call double @random_double_inclusive(double 0.000000e+00, double 1.000000e+00)
store double %21, double* %8
%22 = load double, double* %8
%23 = load double (%struct.Individual*)*, double (%struct.Individual*)** %4
%24 = load %struct.Individual*, %struct.Individual** %5
%25 = call double %23(%struct.Individual* %24)
%26 = fcmp olt double %22, %25
br i1 %26, label %27, label %31
27: ; preds = %3
%28 = load %struct.Individual*, %struct.Individual** %5
%29 = load %struct.Encoding*, %struct.Encoding** %6
%30 = call i32 @single_point_mutation(%struct.Individual* %28, %struct.Encoding* %29)
store i32 1, i32* %7
br label %31
31: ; preds = %27, %3
%32 = load i32, i32* %7
ret i32 %32
}

LLVM IR (-O2):
%struct.Individual = type { i32 }
%struct.Encoding = type { i32 }
define i32 @mutagen(double (%struct.Individual*)* %0, %struct.Individual* %1, %struct.Encoding* %2) {
%4 = icmp ne double (%struct.Individual*)* %0, null
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = icmp ne %struct.Individual* %1, null
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = icmp ne %struct.Encoding* %2, null
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = tail call double @random_double_inclusive(double 0.000000e+00, double 1.000000e+00)
%14 = tail call double %0(%struct.Individual* %1)
%15 = fcmp olt double %13, %14
br i1 %15, label %16, label %18
16: ; preds = %3
%17 = tail call i32 @single_point_mutation(%struct.Individual* %1, %struct.Encoding* %2)
br label %18
18: ; preds = %16, %3
%19 = phi i32 [ 1, %16 ], [ 0, %3 ]
ret i32 %19
}