#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 neutralStochastic(double dt, double currentFreq) {
  double ux = -1.0 * 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):
<neutralStochastic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  0xece(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    $0x0,%al
call   1030 <ranf@plt>
movaps %xmm0,%xmm1
movsd  0xeaa(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11b8 <neutralStochastic+0x98>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe8f(%rip),%xmm1
subsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
mulsd  -0x8(%rbp),%xmm0
call   1040 <sqrt@plt>
movsd  -0x28(%rbp),%xmm2
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1222 <neutralStochastic+0x102>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe37(%rip),%xmm1
subsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
mulsd  -0x8(%rbp),%xmm0
call   1040 <sqrt@plt>
movsd  -0x38(%rbp),%xmm2
movaps %xmm0,%xmm1
movsd  -0x30(%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    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<neutralStochastic>:
sub    $0x48,%rsp
movapd %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
movapd 0xec8(%rip),%xmm0
xorpd  %xmm1,%xmm0
movapd %xmm0,0x30(%rsp)
xor    %eax,%eax
call   1030 <ranf@plt>
movapd %xmm0,%xmm2
movsd  0xebb(%rip),%xmm0
movapd 0x10(%rsp),%xmm1
subsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  0x8(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1179 <neutralStochastic+0x59>
sqrtsd %xmm0,%xmm0
jmp    118a <neutralStochastic+0x6a>
movapd %xmm2,0x20(%rsp)
call   1040 <sqrt@plt>
movapd 0x20(%rsp),%xmm2
movapd 0xe6e(%rip),%xmm1
xorpd  %xmm0,%xmm1
cmpltsd 0xe79(%rip),%xmm2
andpd  %xmm2,%xmm0
andnpd %xmm1,%xmm2
orpd   %xmm0,%xmm2
movapd 0x30(%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
addsd  %xmm2,%xmm0
addsd  0x10(%rsp),%xmm0
add    $0x48,%rsp
ret

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

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