#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 /*<<< orphan*/ assert(int);
double comb(int, int);
double survive(int w, int b, int r) {
  assert(w + b + r >= 3);
  double tc = comb(w + b + r, 3);
  return 1.0 - (comb(w, 3) + comb(r, 2) * comb(b + w, 1) / tc +
                comb(b, 1) * comb(w + r, 2) / tc) /
                   tc;
}


x86 assembly (clang, -O0):
<survive>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
cmp    $0x3,%eax
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x4(%rbp),%edi
add    -0x8(%rbp),%edi
add    -0xc(%rbp),%edi
mov    $0x3,%esi
call   1030 <comb@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x3,%esi
call   1030 <comb@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x2,%esi
call   1030 <comb@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%edi
add    -0x4(%rbp),%edi
mov    $0x1,%esi
call   1030 <comb@plt>
movsd  -0x38(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm2,%xmm1
divsd  -0x18(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x1,%esi
call   1030 <comb@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x4(%rbp),%edi
add    -0xc(%rbp),%edi
mov    $0x2,%esi
call   1030 <comb@plt>
movsd  -0x28(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm2,%xmm0
divsd  -0x18(%rbp),%xmm0
addsd  %xmm0,%xmm1
divsd  -0x18(%rbp),%xmm1
movsd  0xe02(%rip),%xmm0
subsd  %xmm1,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<survive>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x50,%rsp
mov    %edx,%ebx
mov    %esi,%r15d
mov    %edi,%r14d
lea    (%r15,%r14,1),%r12d
lea    (%r12,%rbx,1),%ebp
xor    %edi,%edi
cmp    $0x3,%ebp
setge  %dil
call   1040 <assert@plt>
mov    %ebp,%edi
mov    $0x3,%esi
call   1030 <comb@plt>
movapd %xmm0,0x40(%rsp)
mov    %r14d,%edi
mov    $0x3,%esi
call   1030 <comb@plt>
movsd  %xmm0,0x8(%rsp)
mov    %ebx,%edi
mov    $0x2,%esi
call   1030 <comb@plt>
movapd %xmm0,0x30(%rsp)
mov    %r12d,%edi
mov    $0x1,%esi
call   1030 <comb@plt>
movapd %xmm0,0x20(%rsp)
mov    %r15d,%edi
mov    $0x1,%esi
call   1030 <comb@plt>
movapd %xmm0,0x10(%rsp)
add    %r14d,%ebx
mov    %ebx,%edi
mov    $0x2,%esi
call   1030 <comb@plt>
movapd 0x30(%rsp),%xmm1
unpcklpd 0x10(%rsp),%xmm1
movapd 0x20(%rsp),%xmm2
unpcklpd %xmm0,%xmm2
mulpd  %xmm1,%xmm2
movapd 0x40(%rsp),%xmm1
movapd %xmm1,%xmm0
unpcklpd %xmm1,%xmm0
divpd  %xmm0,%xmm2
movsd  0x8(%rsp),%xmm0
addsd  %xmm2,%xmm0
unpckhpd %xmm2,%xmm2
addsd  %xmm0,%xmm2
divsd  %xmm1,%xmm2
movsd  0xe00(%rip),%xmm0
subsd  %xmm2,%xmm0
add    $0x50,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @survive(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %4
%9 = load i32, i32* %5
%10 = add nsw i32 %8, %9
%11 = load i32, i32* %6
%12 = add nsw i32 %10, %11
%13 = icmp sge i32 %12, 3
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = load i32, i32* %4
%17 = load i32, i32* %5
%18 = add nsw i32 %16, %17
%19 = load i32, i32* %6
%20 = add nsw i32 %18, %19
%21 = call double @comb(i32 %20, i32 3)
store double %21, double* %7
%22 = load i32, i32* %4
%23 = call double @comb(i32 %22, i32 3)
%24 = load i32, i32* %6
%25 = call double @comb(i32 %24, i32 2)
%26 = load i32, i32* %5
%27 = load i32, i32* %4
%28 = add nsw i32 %26, %27
%29 = call double @comb(i32 %28, i32 1)
%30 = fmul double %25, %29
%31 = load double, double* %7
%32 = fdiv double %30, %31
%33 = fadd double %23, %32
%34 = load i32, i32* %5
%35 = call double @comb(i32 %34, i32 1)
%36 = load i32, i32* %4
%37 = load i32, i32* %6
%38 = add nsw i32 %36, %37
%39 = call double @comb(i32 %38, i32 2)
%40 = fmul double %35, %39
%41 = load double, double* %7
%42 = fdiv double %40, %41
%43 = fadd double %33, %42
%44 = load double, double* %7
%45 = fdiv double %43, %44
%46 = fsub double 1.000000e+00, %45
ret double %46
}

LLVM IR (-O2):
define double @survive(i32 %0, i32 %1, i32 %2) {
%4 = add nsw i32 %1, %0
%5 = add nsw i32 %4, %2
%6 = icmp sgt i32 %5, 2
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = tail call double @comb(i32 %5, i32 3)
%10 = tail call double @comb(i32 %0, i32 3)
%11 = tail call double @comb(i32 %2, i32 2)
%12 = tail call double @comb(i32 %4, i32 1)
%13 = tail call double @comb(i32 %1, i32 1)
%14 = add nsw i32 %2, %0
%15 = tail call double @comb(i32 %14, i32 2)
%16 = insertelement <2 x double> poison, double %11, i64 0
%17 = insertelement <2 x double> %16, double %13, i64 1
%18 = insertelement <2 x double> poison, double %12, i64 0
%19 = insertelement <2 x double> %18, double %15, i64 1
%20 = fmul <2 x double> %17, %19
%21 = insertelement <2 x double> poison, double %9, i64 0
%22 = shufflevector <2 x double> %21, <2 x double> poison, <2 x i32> zeroinitializer
%23 = fdiv <2 x double> %20, %22
%24 = extractelement <2 x double> %23, i64 0
%25 = fadd double %10, %24
%26 = extractelement <2 x double> %23, i64 1
%27 = fadd double %25, %26
%28 = fdiv double %27, %9
%29 = fsub double 1.000000e+00, %28
ret double %29
}