; LLVM IR from Dimandragon/non-parametric-dsp :: alglib-cpp/src (optimization)

; 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 speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

declare noundef double @_ZN11alglib_impl6ae_logEdPNS_8ae_stateE(double noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl32inequalityshiftedbarrierfunctionEdPdS0_S0_PNS_8ae_stateE(double noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #2 {
  %6 = alloca double, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  store double %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !9
  store ptr %4, ptr %10, align 8, !tbaa !9
  %11 = load ptr, ptr %7, align 8, !tbaa !9
  store double 0.000000e+00, ptr %11, align 8, !tbaa !5
  %12 = load ptr, ptr %8, align 8, !tbaa !9
  store double 0.000000e+00, ptr %12, align 8, !tbaa !5
  %13 = load ptr, ptr %9, align 8, !tbaa !9
  store double 0.000000e+00, ptr %13, align 8, !tbaa !5
  %14 = load double, ptr %6, align 8, !tbaa !5
  %15 = fcmp oge double %14, 5.000000e-01
  br i1 %15, label %16, label %31

16:                                               ; preds = %5
  %17 = load double, ptr %6, align 8, !tbaa !5
  %18 = load ptr, ptr %10, align 8, !tbaa !9
  %19 = call noundef double @_ZN11alglib_impl6ae_logEdPNS_8ae_stateE(double noundef %17, ptr noundef %18)
  %20 = fneg double %19
  %21 = load ptr, ptr %7, align 8, !tbaa !9
  store double %20, ptr %21, align 8, !tbaa !5
  %22 = load double, ptr %6, align 8, !tbaa !5
  %23 = fdiv double -1.000000e+00, %22
  %24 = load ptr, ptr %8, align 8, !tbaa !9
  store double %23, ptr %24, align 8, !tbaa !5
  %25 = load ptr, ptr %8, align 8, !tbaa !9
  %26 = load double, ptr %25, align 8, !tbaa !5
  %27 = load ptr, ptr %8, align 8, !tbaa !9
  %28 = load double, ptr %27, align 8, !tbaa !5
  %29 = fmul double %26, %28
  %30 = load ptr, ptr %9, align 8, !tbaa !9
  store double %29, ptr %30, align 8, !tbaa !5
  br label %48

31:                                               ; preds = %5
  %32 = load double, ptr %6, align 8, !tbaa !5
  %33 = fmul double 2.000000e+00, %32
  %34 = load double, ptr %6, align 8, !tbaa !5
  %35 = load double, ptr %6, align 8, !tbaa !5
  %36 = fmul double 4.000000e+00, %35
  %37 = fneg double %36
  %38 = call double @llvm.fmuladd.f64(double %33, double %34, double %37)
  %39 = load ptr, ptr %10, align 8, !tbaa !9
  %40 = call noundef double @_ZN11alglib_impl6ae_logEdPNS_8ae_stateE(double noundef 2.000000e+00, ptr noundef %39)
  %41 = fadd double %40, 1.500000e+00
  %42 = fadd double %38, %41
  %43 = load ptr, ptr %7, align 8, !tbaa !9
  store double %42, ptr %43, align 8, !tbaa !5
  %44 = load double, ptr %6, align 8, !tbaa !5
  %45 = call double @llvm.fmuladd.f64(double 4.000000e+00, double %44, double -4.000000e+00)
  %46 = load ptr, ptr %8, align 8, !tbaa !9
  store double %45, ptr %46, align 8, !tbaa !5
  %47 = load ptr, ptr %9, align 8, !tbaa !9
  store double 4.000000e+00, ptr %47, align 8, !tbaa !5
  br label %48

48:                                               ; preds = %31, %16
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { "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 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" }

!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"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}


; 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.fmuladd.f64(double, double, double) #0

declare noundef double @_ZN11alglib_impl6ae_logEdPNS_8ae_stateE(double noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl32inequalityshiftedbarrierfunctionEdPdS0_S0_PNS_8ae_stateE(double noundef %0, ptr nocapture noundef writeonly %1, ptr nocapture noundef writeonly %2, ptr nocapture noundef writeonly %3, ptr noundef %4) local_unnamed_addr #2 {
  store double 0.000000e+00, ptr %1, align 8, !tbaa !5
  store double 0.000000e+00, ptr %2, align 8, !tbaa !5
  store double 0.000000e+00, ptr %3, align 8, !tbaa !5
  %6 = fcmp ult double %0, 5.000000e-01
  br i1 %6, label %12, label %7

7:                                                ; preds = %5
  %8 = tail call noundef double @_ZN11alglib_impl6ae_logEdPNS_8ae_stateE(double noundef %0, ptr noundef %4)
  %9 = fneg double %8
  %10 = fdiv double -1.000000e+00, %0
  %11 = fmul double %10, %10
  br label %20

12:                                               ; preds = %5
  %13 = fmul double %0, 2.000000e+00
  %14 = fmul double %0, -4.000000e+00
  %15 = tail call double @llvm.fmuladd.f64(double %13, double %0, double %14)
  %16 = tail call noundef double @_ZN11alglib_impl6ae_logEdPNS_8ae_stateE(double noundef 2.000000e+00, ptr noundef %4)
  %17 = fadd double %16, 1.500000e+00
  %18 = fadd double %15, %17
  %19 = tail call double @llvm.fmuladd.f64(double %0, double 4.000000e+00, double -4.000000e+00)
  br label %20

20:                                               ; preds = %12, %7
  %.sink20 = phi double [ %18, %12 ], [ %9, %7 ]
  %.sink = phi double [ %19, %12 ], [ %10, %7 ]
  %storemerge = phi double [ 4.000000e+00, %12 ], [ %11, %7 ]
  store double %.sink20, ptr %1, align 8
  store double %.sink, ptr %2, align 8
  store double %storemerge, ptr %3, align 8, !tbaa !5
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { "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 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" }

!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"}


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