#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 */
double coth(double);
double ranf();
double sqrt(double);
double genicSelectionStochastic(double dt, double currentFreq, double alpha) {
  double newFreq;
  double ux = (-0.5 * alpha * currentFreq * (1.0 - currentFreq)) *
              coth(0.5 * alpha * currentFreq * (1.0 - currentFreq));
  if (ranf() < 0.5) {
    newFreq = (ux * dt) + sqrt(currentFreq * (1.0 - currentFreq) * dt);
  } else {
    newFreq = (ux * dt) - sqrt(currentFreq * (1.0 - currentFreq) * dt);
  }
  return (newFreq);
}


x86 assembly (clang, -O0):
<genicSelectionStochastic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  0xec1(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  0xea7(%rip),%xmm1
subsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe89(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  0xe7f(%rip),%xmm1
subsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1040 <coth@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    $0x0,%al
call   1030 <ranf@plt>
movaps %xmm0,%xmm1
movsd  0xe46(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1217 <genicSelectionStochastic+0xe7>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe23(%rip),%xmm1
subsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
mulsd  -0x8(%rbp),%xmm0
call   1050 <sqrt@plt>
movsd  -0x40(%rbp),%xmm2
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    127c <genicSelectionStochastic+0x14c>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xdd0(%rip),%xmm1
subsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
mulsd  -0x8(%rbp),%xmm0
call   1050 <sqrt@plt>
movsd  -0x50(%rbp),%xmm2
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<genicSelectionStochastic>:
sub    $0x28,%rsp
movsd  %xmm0,0x8(%rsp)
movsd  0xebe(%rip),%xmm3
mulsd  %xmm2,%xmm3
movsd  %xmm1,0x10(%rsp)
mulsd  %xmm1,%xmm3
movsd  0xeb0(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,0x20(%rsp)
mulsd  %xmm0,%xmm3
movsd  %xmm3,(%rsp)
mulsd  0xe9d(%rip),%xmm2
mulsd  %xmm1,%xmm2
mulsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
call   1040 <coth@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <ranf@plt>
movapd %xmm0,%xmm2
movsd  0x20(%rsp),%xmm1
mulsd  0x10(%rsp),%xmm1
mulsd  0x8(%rsp),%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
movapd %xmm1,%xmm0
jb     11bf <genicSelectionStochastic+0x8f>
sqrtsd %xmm0,%xmm0
jmp    11d0 <genicSelectionStochastic+0xa0>
movapd %xmm2,0x10(%rsp)
call   1050 <sqrt@plt>
movapd 0x10(%rsp),%xmm2
movapd 0xe48(%rip),%xmm1
xorpd  %xmm0,%xmm1
cmpltsd 0xe2b(%rip),%xmm2
andpd  %xmm2,%xmm0
andnpd %xmm1,%xmm2
orpd   %xmm0,%xmm2
movsd  (%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
addsd  %xmm2,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @genicSelectionStochastic(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
%9 = load double, double* %6
%10 = fmul double -5.000000e-01, %9
%11 = load double, double* %5
%12 = fmul double %10, %11
%13 = load double, double* %5
%14 = fsub double 1.000000e+00, %13
%15 = fmul double %12, %14
%16 = load double, double* %6
%17 = fmul double 5.000000e-01, %16
%18 = load double, double* %5
%19 = fmul double %17, %18
%20 = load double, double* %5
%21 = fsub double 1.000000e+00, %20
%22 = fmul double %19, %21
%23 = call double @coth(double %22)
%24 = fmul double %15, %23
store double %24, double* %8
%25 = call double (...) @ranf()
%26 = fcmp olt double %25, 5.000000e-01
br i1 %26, label %27, label %38
27: ; preds = %3
%28 = load double, double* %8
%29 = load double, double* %4
%30 = load double, double* %5
%31 = load double, double* %5
%32 = fsub double 1.000000e+00, %31
%33 = fmul double %30, %32
%34 = load double, double* %4
%35 = fmul double %33, %34
%36 = call double @sqrt(double %35)
%37 = call double @llvm.fmuladd.f64(double %28, double %29, double %36)
store double %37, double* %7
br label %50
38: ; preds = %3
%39 = load double, double* %8
%40 = load double, double* %4
%41 = load double, double* %5
%42 = load double, double* %5
%43 = fsub double 1.000000e+00, %42
%44 = fmul double %41, %43
%45 = load double, double* %4
%46 = fmul double %44, %45
%47 = call double @sqrt(double %46)
%48 = fneg double %47
%49 = call double @llvm.fmuladd.f64(double %39, double %40, double %48)
store double %49, double* %7
br label %50
50: ; preds = %38, %27
%51 = load double, double* %7
ret double %51
}

LLVM IR (-O2):
define double @genicSelectionStochastic(double %0, double %1, double %2) {
%4 = fmul double %2, -5.000000e-01
%5 = fmul double %4, %1
%6 = fsub double 1.000000e+00, %1
%7 = fmul double %6, %5
%8 = fmul double %2, 5.000000e-01
%9 = fmul double %8, %1
%10 = fmul double %6, %9
%11 = tail call double @coth(double %10)
%12 = fmul double %7, %11
%13 = tail call double (...) @ranf()
%14 = fcmp olt double %13, 5.000000e-01
%15 = fmul double %6, %1
%16 = fmul double %15, %0
%17 = tail call double @sqrt(double %16)
%18 = fneg double %17
%19 = select i1 %14, double %17, double %18
%20 = tail call double @llvm.fmuladd.f64(double %12, double %0, double %19)
ret double %20
}