; LLVM IR from buresjan/optim_lbm :: nomad/ext/sgtelib/src/Surrogate_Utils.ll (ZN7SGTELIB7normcdfEd)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; Function Attrs: nounwind
declare double @exp(double noundef) #2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZN7SGTELIB7normcdfEd(double noundef %0) #3 {
  %2 = alloca double, align 8
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  store double %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %7 = load double, ptr %2, align 8, !tbaa !5
  %8 = call double @llvm.fabs.f64(double %7)
  %9 = fcmp olt double %8, 1.000000e-13
  br i1 %9, label %10, label %11

10:                                               ; preds = %1
  store double 5.000000e-01, ptr %6, align 8, !tbaa !5
  br label %51

11:                                               ; preds = %1
  %12 = load double, ptr %2, align 8, !tbaa !5
  %13 = call double @llvm.fabs.f64(double %12)
  %14 = call double @llvm.fmuladd.f64(double 0x3FCDA6711871100E, double %13, double 1.000000e+00)
  %15 = fdiv double 1.000000e+00, %14
  store double %15, ptr %3, align 8, !tbaa !5
  %16 = load double, ptr %3, align 8, !tbaa !5
  %17 = load double, ptr %3, align 8, !tbaa !5
  %18 = fmul double %16, %17
  store double %18, ptr %4, align 8, !tbaa !5
  %19 = load double, ptr %2, align 8, !tbaa !5
  %20 = fneg double %19
  %21 = load double, ptr %2, align 8, !tbaa !5
  %22 = fmul double %20, %21
  %23 = fdiv double %22, 2.000000e+00
  %24 = call double @exp(double noundef %23) #4
  %25 = load double, ptr %3, align 8, !tbaa !5
  %26 = fmul double %24, %25
  %27 = load double, ptr %3, align 8, !tbaa !5
  %28 = call double @llvm.fmuladd.f64(double 0xBFD6D1F0E5A8325B, double %27, double 0x3FD470BF3A92F8EC)
  %29 = load double, ptr %4, align 8, !tbaa !5
  %30 = call double @llvm.fmuladd.f64(double 0x3FFC80EF025F5E68, double %29, double %28)
  %31 = load double, ptr %3, align 8, !tbaa !5
  %32 = fmul double 0x3FFD23DD4EF278D0, %31
  %33 = load double, ptr %4, align 8, !tbaa !5
  %34 = fneg double %32
  %35 = call double @llvm.fmuladd.f64(double %34, double %33, double %30)
  %36 = load double, ptr %4, align 8, !tbaa !5
  %37 = fmul double 0x3FF548CDD6F42943, %36
  %38 = load double, ptr %4, align 8, !tbaa !5
  %39 = call double @llvm.fmuladd.f64(double %37, double %38, double %35)
  %40 = fmul double %26, %39
  %41 = fdiv double %40, 0x40040D931FF62704
  store double %41, ptr %5, align 8, !tbaa !5
  %42 = load double, ptr %2, align 8, !tbaa !5
  %43 = fcmp olt double %42, 0.000000e+00
  br i1 %43, label %44, label %46

44:                                               ; preds = %11
  %45 = load double, ptr %5, align 8, !tbaa !5
  br label %49

46:                                               ; preds = %11
  %47 = load double, ptr %5, align 8, !tbaa !5
  %48 = fsub double 1.000000e+00, %47
  br label %49

49:                                               ; preds = %46, %44
  %50 = phi double [ %45, %44 ], [ %48, %46 ]
  store double %50, ptr %6, align 8, !tbaa !5
  br label %51

51:                                               ; preds = %49, %10
  %52 = load double, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret double %52
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @exp(double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write) uwtable
define dso_local noundef double @_ZN7SGTELIB7normcdfEd(double noundef %0) local_unnamed_addr #2 {
  %2 = tail call double @llvm.fabs.f64(double %0)
  %3 = fcmp olt double %2, 1.000000e-13
  br i1 %3, label %24, label %4

4:                                                ; preds = %1
  %5 = tail call double @llvm.fmuladd.f64(double %2, double 0x3FCDA6711871100E, double 1.000000e+00)
  %6 = fdiv double 1.000000e+00, %5
  %7 = fmul double %6, %6
  %8 = fneg double %0
  %9 = fmul double %8, %0
  %10 = fmul double %9, 5.000000e-01
  %11 = tail call double @exp(double noundef %10) #3
  %12 = fmul double %6, %11
  %13 = tail call double @llvm.fmuladd.f64(double %6, double 0xBFD6D1F0E5A8325B, double 0x3FD470BF3A92F8EC)
  %14 = tail call double @llvm.fmuladd.f64(double %7, double 0x3FFC80EF025F5E68, double %13)
  %15 = fmul double %6, 0xBFFD23DD4EF278D0
  %16 = tail call double @llvm.fmuladd.f64(double %15, double %7, double %14)
  %17 = fmul double %7, 0x3FF548CDD6F42943
  %18 = tail call double @llvm.fmuladd.f64(double %17, double %7, double %16)
  %19 = fmul double %18, %12
  %20 = fdiv double %19, 0x40040D931FF62704
  %21 = fcmp olt double %0, 0.000000e+00
  %22 = fsub double 1.000000e+00, %20
  %23 = select i1 %21, double %20, double %22
  br label %24

24:                                               ; preds = %1, %4
  %.0 = phi double [ %23, %4 ], [ 5.000000e-01, %1 ]
  ret double %.0
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree nounwind willreturn memory(write) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nofree nounwind willreturn memory(write) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass