#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;
};

/* Variables and functions */
int /*<<< orphan*/ assert(int /*<<< orphan*/);
double fitness_proportion(struct Individual *, struct Individual *);
double random_double_inclusive(double, double);
int fight(struct Individual *aspirant, struct Individual *rival) {
  assert(aspirant != NULL);
  assert(rival != NULL);
  double goodness = fitness_proportion(aspirant, rival);
  double bad_luck = random_double_inclusive(0.0, 1.0);
  return bad_luck > goodness;
}


x86 assembly (clang, -O0):
<fight>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <fitness_proportion@plt>
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  0xe7f(%rip),%xmm1
call   1050 <random_double_inclusive@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fight>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1040 <assert@plt>
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1040 <assert@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <fitness_proportion@plt>
movsd  %xmm0,(%rsp)
movsd  0xe92(%rip),%xmm1
xorpd  %xmm0,%xmm0
call   1050 <random_double_inclusive@plt>
xor    %eax,%eax
ucomisd (%rsp),%xmm0
seta   %al
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.Individual = type { i32 }
define i32 @fight(%struct.Individual* %0, %struct.Individual* %1) {
%3 = alloca %struct.Individual*
%4 = alloca %struct.Individual*
%5 = alloca double
%6 = alloca double
store %struct.Individual* %0, %struct.Individual** %3
store %struct.Individual* %1, %struct.Individual** %4
%7 = load %struct.Individual*, %struct.Individual** %3
%8 = icmp ne %struct.Individual* %7, null
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = load %struct.Individual*, %struct.Individual** %4
%12 = icmp ne %struct.Individual* %11, null
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = load %struct.Individual*, %struct.Individual** %3
%16 = load %struct.Individual*, %struct.Individual** %4
%17 = call double @fitness_proportion(%struct.Individual* %15, %struct.Individual* %16)
store double %17, double* %5
%18 = call double @random_double_inclusive(double 0.000000e+00, double 1.000000e+00)
store double %18, double* %6
%19 = load double, double* %6
%20 = load double, double* %5
%21 = fcmp ogt double %19, %20
%22 = zext i1 %21 to i32
ret i32 %22
}

LLVM IR (-O2):
%struct.Individual = type { i32 }
define i32 @fight(%struct.Individual* %0, %struct.Individual* %1) {
%3 = icmp ne %struct.Individual* %0, null
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = icmp ne %struct.Individual* %1, null
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = tail call double @fitness_proportion(%struct.Individual* %0, %struct.Individual* %1)
%10 = tail call double @random_double_inclusive(double 0.000000e+00, double 1.000000e+00)
%11 = fcmp ogt double %10, %9
%12 = zext i1 %11 to i32
ret i32 %12
}