#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 */
float erf1(float);
float erfinv(float);
float sqrt(int);
float roc_gauss(float fa, float mu0, float sigma0, float mu1, float sigma1) {
  float p1, p2;
  float phiinv;
  float aux;
  float y;
  float phiy;
  float p;
  p1 = sigma0 / sigma1;
  p2 = ((mu1 - mu0) / sigma1) / sqrt(2);
  aux = 2 * (1 - fa) - 1;
  phiinv = erfinv(aux);
  y = p1 * phiinv - p2;
  phiy = erf1(y);
  p = 1 - 0.5 * (1 + phiy);
  return p;
}


x86 assembly (clang, -O0):
<roc_gauss>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  %xmm3,-0x10(%rbp)
movss  %xmm4,-0x14(%rbp)
movss  -0xc(%rbp),%xmm0
divss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x10(%rbp),%xmm0
subss  -0x8(%rbp),%xmm0
divss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
mov    $0x2,%edi
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movss  -0x34(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  0xe79(%rip),%xmm0
subss  -0x4(%rbp),%xmm0
addss  %xmm0,%xmm0
movss  0xe6c(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
call   1030 <erfinv@plt>
movss  %xmm0,-0x20(%rbp)
movss  -0x18(%rbp),%xmm0
movss  -0x20(%rbp),%xmm2
movss  -0x1c(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x28(%rbp),%xmm0
call   1040 <erf1@plt>
movss  %xmm0,-0x2c(%rbp)
movss  0xe10(%rip),%xmm0
addss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdef(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdeb(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x30(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<roc_gauss>:
sub    $0x18,%rsp
movss  %xmm4,0x10(%rsp)
movss  %xmm0,0x4(%rsp)
divss  %xmm4,%xmm2
movss  %xmm2,0x14(%rsp)
subss  %xmm1,%xmm3
movss  %xmm3,0xc(%rsp)
mov    $0x2,%edi
call   1050 <sqrt@plt>
movss  %xmm0,0x8(%rsp)
movss  0xe94(%rip),%xmm0
subss  0x4(%rsp),%xmm0
addss  %xmm0,%xmm0
addss  0xe86(%rip),%xmm0
call   1030 <erfinv@plt>
movss  0xc(%rsp),%xmm1
divss  0x10(%rsp),%xmm1
divss  0x8(%rsp),%xmm1
mulss  0x14(%rsp),%xmm0
subss  %xmm1,%xmm0
call   1040 <erf1@plt>
addss  0xe54(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xe50(%rip),%xmm0
addsd  0xe50(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define float @roc_gauss(float %0, float %1, float %2, float %3, float %4) {
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca float
%15 = alloca float
%16 = alloca float
%17 = alloca float
store float %0, float* %6
store float %1, float* %7
store float %2, float* %8
store float %3, float* %9
store float %4, float* %10
%18 = load float, float* %8
%19 = load float, float* %10
%20 = fdiv float %18, %19
store float %20, float* %11
%21 = load float, float* %9
%22 = load float, float* %7
%23 = fsub float %21, %22
%24 = load float, float* %10
%25 = fdiv float %23, %24
%26 = call float @sqrt(i32 2)
%27 = fdiv float %25, %26
store float %27, float* %12
%28 = load float, float* %6
%29 = fsub float 1.000000e+00, %28
%30 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %29, float -1.000000e+00)
store float %30, float* %14
%31 = load float, float* %14
%32 = call float @erfinv(float %31)
store float %32, float* %13
%33 = load float, float* %11
%34 = load float, float* %13
%35 = load float, float* %12
%36 = fneg float %35
%37 = call float @llvm.fmuladd.f32(float %33, float %34, float %36)
store float %37, float* %15
%38 = load float, float* %15
%39 = call float @erf1(float %38)
store float %39, float* %16
%40 = load float, float* %16
%41 = fadd float 1.000000e+00, %40
%42 = fpext float %41 to double
%43 = call double @llvm.fmuladd.f64(double -5.000000e-01, double %42, double 1.000000e+00)
%44 = fptrunc double %43 to float
store float %44, float* %17
%45 = load float, float* %17
ret float %45
}

LLVM IR (-O2):
define float @roc_gauss(float %0, float %1, float %2, float %3, float %4) {
%6 = fdiv float %2, %4
%7 = fsub float %3, %1
%8 = tail call float @sqrt(i32 2)
%9 = fsub float 1.000000e+00, %0
%10 = tail call float @llvm.fmuladd.f32(float %9, float 2.000000e+00, float -1.000000e+00)
%11 = tail call float @erfinv(float %10)
%12 = fneg float %7
%13 = fdiv float %12, %4
%14 = fdiv float %13, %8
%15 = tail call float @llvm.fmuladd.f32(float %6, float %11, float %14)
%16 = tail call float @erf1(float %15)
%17 = fadd float %16, 1.000000e+00
%18 = fpext float %17 to double
%19 = tail call double @llvm.fmuladd.f64(double %18, double -5.000000e-01, double 1.000000e+00)
%20 = fptrunc double %19 to float
ret float %20
}