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


x86 assembly (clang, -O0):
<genicSelectionStochasticForwards>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  0xeaf(%rip),%xmm1
subsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1030 <tanh@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    $0x0,%al
call   1040 <ranf@plt>
movaps %xmm0,%xmm1
movsd  0xe67(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11fb <genicSelectionStochasticForwards+0xcb>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe44(%rip),%xmm1
subsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
mulsd  -0x8(%rbp),%xmm0
call   1050 <sqrt@plt>
movsd  -0x38(%rbp),%xmm2
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1265 <genicSelectionStochasticForwards+0x135>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xdec(%rip),%xmm1
subsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
mulsd  -0x8(%rbp),%xmm0
call   1050 <sqrt@plt>
movsd  -0x48(%rbp),%xmm2
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<genicSelectionStochasticForwards>:
sub    $0x38,%rsp
movsd  %xmm0,0x10(%rsp)
movsd  %xmm1,0x18(%rsp)
mulsd  %xmm1,%xmm2
movsd  0xeb4(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,0x20(%rsp)
mulsd  %xmm2,%xmm0
movsd  %xmm0,0x8(%rsp)
movapd %xmm2,%xmm0
call   1030 <tanh@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
xor    %eax,%eax
call   1040 <ranf@plt>
movapd %xmm0,%xmm2
movsd  0x20(%rsp),%xmm1
mulsd  0x18(%rsp),%xmm1
mulsd  0x10(%rsp),%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
movapd %xmm1,%xmm0
jb     11aa <genicSelectionStochasticForwards+0x7a>
sqrtsd %xmm0,%xmm0
jmp    11bb <genicSelectionStochasticForwards+0x8b>
movapd %xmm2,0x20(%rsp)
call   1050 <sqrt@plt>
movapd 0x20(%rsp),%xmm2
movapd 0xe4d(%rip),%xmm1
xorpd  %xmm0,%xmm1
cmpltsd 0xe38(%rip),%xmm2
andpd  %xmm2,%xmm0
andnpd %xmm1,%xmm2
orpd   %xmm0,%xmm2
movsd  0x8(%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
addsd  %xmm2,%xmm0
addsd  0x18(%rsp),%xmm0
add    $0x38,%rsp
ret

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

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