; LLVM IR from jgaeddert/liquid-dsp :: src/math/src (math)

; 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 speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

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

; Function Attrs: nounwind uwtable
define dso_local float @liquid_MarcumQ1f(float noundef %0, float noundef %1) #2 {
  %3 = alloca float, align 4
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca i32, align 4
  store float %0, ptr %3, align 4, !tbaa !5
  store float %1, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  %11 = load float, ptr %3, align 4, !tbaa !5
  %12 = load float, ptr %3, align 4, !tbaa !5
  %13 = load float, ptr %4, align 4, !tbaa !5
  %14 = load float, ptr %4, align 4, !tbaa !5
  %15 = fmul float %13, %14
  %16 = call float @llvm.fmuladd.f32(float %11, float %12, float %15)
  %17 = fmul float -5.000000e-01, %16
  %18 = call float @expf(float noundef %17) #5, !tbaa !9
  store float %18, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store float 1.000000e+00, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %19 = load float, ptr %3, align 4, !tbaa !5
  %20 = load float, ptr %4, align 4, !tbaa !5
  %21 = fdiv float %19, %20
  store float %21, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %22 = load float, ptr %3, align 4, !tbaa !5
  %23 = load float, ptr %4, align 4, !tbaa !5
  %24 = fmul float %22, %23
  store float %24, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store float 0.000000e+00, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %25

25:                                               ; preds = %39, %2
  %26 = load i32, ptr %10, align 4, !tbaa !9
  %27 = icmp ult i32 %26, 64
  br i1 %27, label %28, label %42

28:                                               ; preds = %25
  %29 = load float, ptr %6, align 4, !tbaa !5
  %30 = load i32, ptr %10, align 4, !tbaa !9
  %31 = uitofp i32 %30 to float
  %32 = load float, ptr %8, align 4, !tbaa !5
  %33 = call float @liquid_besselif(float noundef %31, float noundef %32)
  %34 = load float, ptr %9, align 4, !tbaa !5
  %35 = call float @llvm.fmuladd.f32(float %29, float %33, float %34)
  store float %35, ptr %9, align 4, !tbaa !5
  %36 = load float, ptr %7, align 4, !tbaa !5
  %37 = load float, ptr %6, align 4, !tbaa !5
  %38 = fmul float %37, %36
  store float %38, ptr %6, align 4, !tbaa !5
  br label %39

39:                                               ; preds = %28
  %40 = load i32, ptr %10, align 4, !tbaa !9
  %41 = add i32 %40, 1
  store i32 %41, ptr %10, align 4, !tbaa !9
  br label %25, !llvm.loop !11

42:                                               ; preds = %25
  %43 = load float, ptr %5, align 4, !tbaa !5
  %44 = load float, ptr %9, align 4, !tbaa !5
  %45 = fmul float %43, %44
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  ret float %45
}

; Function Attrs: nounwind
declare float @expf(float noundef) #3

declare float @liquid_besselif(float noundef, float noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #3 = { 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 #4 = { "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 #5 = { 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; 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 float @llvm.fmuladd.f32(float, float, float) #0

; Function Attrs: nounwind uwtable
define dso_local float @liquid_MarcumQ1f(float noundef %0, float noundef %1) local_unnamed_addr #1 {
  %3 = fmul float %1, %1
  %4 = tail call float @llvm.fmuladd.f32(float %0, float %0, float %3)
  %5 = fmul float %4, -5.000000e-01
  %6 = tail call float @expf(float noundef %5) #4, !tbaa !5
  %7 = fdiv float %0, %1
  %8 = fmul float %0, %1
  br label %9

9:                                                ; preds = %2, %9
  %.021 = phi i32 [ 0, %2 ], [ %14, %9 ]
  %.01720 = phi float [ 0.000000e+00, %2 ], [ %12, %9 ]
  %.01819 = phi float [ 1.000000e+00, %2 ], [ %13, %9 ]
  %10 = uitofp nneg i32 %.021 to float
  %11 = tail call float @liquid_besselif(float noundef %10, float noundef %8) #4
  %12 = tail call float @llvm.fmuladd.f32(float %.01819, float %11, float %.01720)
  %13 = fmul float %7, %.01819
  %14 = add nuw nsw i32 %.021, 1
  %exitcond.not = icmp eq i32 %14, 64
  br i1 %exitcond.not, label %15, label %9, !llvm.loop !9

15:                                               ; preds = %9
  %16 = fmul float %6, %12
  ret float %16
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @expf(float noundef) local_unnamed_addr #2

declare float @liquid_besselif(float noundef, float noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { 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 #2 = { 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 #3 = { "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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass