#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);
void roc_gauss_vector(float *fa, float *roc, int n_fa, float mu0, float sigma0,
                      float mu1, float sigma1) {
  float p1, p2;
  float phiinv;
  float aux;
  float y;
  float phiy;
  float p;
  int i;
  p1 = sigma0 / sigma1;
  p2 = ((mu1 - mu0) / sigma1) / sqrt(2);
  for (i = 1; i <= n_fa; i++) {
    aux = 2 * (1 - fa[i]) - 1;
    phiinv = erfinv(aux);
    y = p1 * phiinv - p2;
    phiy = erf1(y);
    roc[i] = 1 - 0.5 * (1 + phiy);
  }
}


x86 assembly (clang, -O0):
<roc_gauss_vector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movss  %xmm0,-0x18(%rbp)
movss  %xmm1,-0x1c(%rbp)
movss  %xmm2,-0x20(%rbp)
movss  %xmm3,-0x24(%rbp)
movss  -0x1c(%rbp),%xmm0
divss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x20(%rbp),%xmm0
subss  -0x18(%rbp),%xmm0
divss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x48(%rbp)
mov    $0x2,%edi
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movss  -0x48(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x2c(%rbp)
movl   $0x1,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1261 <roc_gauss_vector+0x131>
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
movss  0xe58(%rip),%xmm0
subss  (%rax,%rcx,4),%xmm0
addss  %xmm0,%xmm0
movss  0xe4b(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x34(%rbp),%xmm0
call   1030 <erfinv@plt>
movss  %xmm0,-0x30(%rbp)
movss  -0x28(%rbp),%xmm0
movss  -0x30(%rbp),%xmm2
movss  -0x2c(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x38(%rbp)
movss  -0x38(%rbp),%xmm0
call   1040 <erf1@plt>
movss  %xmm0,-0x3c(%rbp)
movss  0xdef(%rip),%xmm0
addss  -0x3c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdce(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdca(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x44(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    119c <roc_gauss_vector+0x6c>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<roc_gauss_vector>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
movss  %xmm3,0xc(%rsp)
movaps %xmm2,0x10(%rsp)
movss  %xmm1,0x4(%rsp)
movss  %xmm0,0x8(%rsp)
mov    %edx,%r12d
mov    %rsi,%r14
mov    %rdi,%r15
mov    $0x2,%edi
call   1050 <sqrt@plt>
test   %r12d,%r12d
jle    120f <roc_gauss_vector+0xdf>
movss  0x4(%rsp),%xmm1
movss  0xc(%rsp),%xmm2
divss  %xmm2,%xmm1
movss  %xmm1,0x4(%rsp)
movaps 0x10(%rsp),%xmm1
subss  0x8(%rsp),%xmm1
xorps  0xe6a(%rip),%xmm1
divss  %xmm2,%xmm1
divss  %xmm0,%xmm1
movaps %xmm1,0x10(%rsp)
add    $0x1,%r12d
mov    $0x1,%ebx
nopl   0x0(%rax)
movss  0xe58(%rip),%xmm0
subss  (%r15,%rbx,4),%xmm0
addss  %xmm0,%xmm0
addss  0xe4a(%rip),%xmm0
call   1030 <erfinv@plt>
mulss  0x4(%rsp),%xmm0
addss  0x10(%rsp),%xmm0
call   1040 <erf1@plt>
addss  0xe28(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xe24(%rip),%xmm0
addsd  0xe24(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    11b0 <roc_gauss_vector+0x80>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @roc_gauss_vector(float* %0, float* %1, i32 %2, float %3, float %4, float %5, float %6) {
%8 = alloca float*
%9 = alloca float*
%10 = alloca i32
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca float
%15 = alloca float
%16 = alloca float
%17 = alloca float
%18 = alloca float
%19 = alloca float
%20 = alloca float
%21 = alloca float
%22 = alloca i32
store float* %0, float** %8
store float* %1, float** %9
store i32 %2, i32* %10
store float %3, float* %11
store float %4, float* %12
store float %5, float* %13
store float %6, float* %14
%23 = load float, float* %12
%24 = load float, float* %14
%25 = fdiv float %23, %24
store float %25, float* %15
%26 = load float, float* %13
%27 = load float, float* %11
%28 = fsub float %26, %27
%29 = load float, float* %14
%30 = fdiv float %28, %29
%31 = call float @sqrt(i32 2)
%32 = fdiv float %30, %31
store float %32, float* %16
store i32 1, i32* %22
br label %33
33: ; preds = %63, %7
%34 = load i32, i32* %22
%35 = load i32, i32* %10
%36 = icmp sle i32 %34, %35
br i1 %36, label %37, label %66
37: ; preds = %33
%38 = load float*, float** %8
%39 = load i32, i32* %22
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds float, float* %38, i64 %40
%42 = load float, float* %41
%43 = fsub float 1.000000e+00, %42
%44 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %43, float -1.000000e+00)
store float %44, float* %18
%45 = load float, float* %18
%46 = call float @erfinv(float %45)
store float %46, float* %17
%47 = load float, float* %15
%48 = load float, float* %17
%49 = load float, float* %16
%50 = fneg float %49
%51 = call float @llvm.fmuladd.f32(float %47, float %48, float %50)
store float %51, float* %19
%52 = load float, float* %19
%53 = call float @erf1(float %52)
store float %53, float* %20
%54 = load float, float* %20
%55 = fadd float 1.000000e+00, %54
%56 = fpext float %55 to double
%57 = call double @llvm.fmuladd.f64(double -5.000000e-01, double %56, double 1.000000e+00)
%58 = fptrunc double %57 to float
%59 = load float*, float** %9
%60 = load i32, i32* %22
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds float, float* %59, i64 %61
store float %58, float* %62
br label %63
63: ; preds = %37
%64 = load i32, i32* %22
%65 = add nsw i32 %64, 1
store i32 %65, i32* %22
br label %33
66: ; preds = %33
ret void
}

LLVM IR (-O2):
define void @roc_gauss_vector(float* nocapture %0, float* nocapture writeonly %1, i32 %2, float %3, float %4, float %5, float %6) {
%8 = fdiv float %4, %6
%9 = tail call float @sqrt(i32 2)
%10 = icmp slt i32 %2, 1
br i1 %10, label %34, label %11
11: ; preds = %7
%12 = fsub float %5, %3
%13 = fneg float %12
%14 = fdiv float %13, %6
%15 = fdiv float %14, %9
%16 = add nuw i32 %2, 1
%17 = zext i32 %16 to i64
br label %18
18: ; preds = %11, %18
%19 = phi i64 [ 1, %11 ], [ %32, %18 ]
%20 = getelementptr inbounds float, float* %0, i64 %19
%21 = load float, float* %20
%22 = fsub float 1.000000e+00, %21
%23 = tail call float @llvm.fmuladd.f32(float %22, float 2.000000e+00, float -1.000000e+00)
%24 = tail call float @erfinv(float %23)
%25 = tail call float @llvm.fmuladd.f32(float %8, float %24, float %15)
%26 = tail call float @erf1(float %25)
%27 = fadd float %26, 1.000000e+00
%28 = fpext float %27 to double
%29 = tail call double @llvm.fmuladd.f64(double %28, double -5.000000e-01, double 1.000000e+00)
%30 = fptrunc double %29 to float
%31 = getelementptr inbounds float, float* %1, i64 %19
store float %30, float* %31
%32 = add nuw nsw i64 %19, 1
%33 = icmp eq i64 %32, %17
br i1 %33, label %34, label %18
34: ; preds = %18, %7
ret void
}