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

; 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: nounwind
declare float @sqrtf(float noundef) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

; 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 @randricekf_pdf(float noundef %0, float noundef %1, float noundef %2) #3 {
  %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 float, align 4
  %11 = alloca float, align 4
  %12 = alloca i32, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  store float %0, ptr %5, align 4, !tbaa !5
  store float %1, ptr %6, align 4, !tbaa !5
  store float %2, ptr %7, align 4, !tbaa !5
  %16 = load float, ptr %5, align 4, !tbaa !5
  %17 = fcmp olt float %16, 0.000000e+00
  br i1 %17, label %18, label %19

18:                                               ; preds = %3
  store float 0.000000e+00, ptr %4, align 4
  br label %73

19:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %20 = load float, ptr %7, align 4, !tbaa !5
  %21 = load float, ptr %6, align 4, !tbaa !5
  %22 = fmul float %20, %21
  %23 = load float, ptr %6, align 4, !tbaa !5
  %24 = fadd float %23, 1.000000e+00
  %25 = fdiv float %22, %24
  %26 = call float @sqrtf(float noundef %25) #5
  store float %26, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %27 = load float, ptr %7, align 4, !tbaa !5
  %28 = fmul float 5.000000e-01, %27
  %29 = load float, ptr %6, align 4, !tbaa !5
  %30 = fadd float %29, 1.000000e+00
  %31 = fdiv float %28, %30
  %32 = call float @sqrtf(float noundef %31) #5
  store float %32, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %33 = load float, ptr %5, align 4, !tbaa !5
  %34 = load float, ptr %5, align 4, !tbaa !5
  %35 = load float, ptr %8, align 4, !tbaa !5
  %36 = load float, ptr %8, align 4, !tbaa !5
  %37 = fmul float %35, %36
  %38 = call float @llvm.fmuladd.f32(float %33, float %34, float %37)
  store float %38, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %39 = load float, ptr %9, align 4, !tbaa !5
  %40 = load float, ptr %9, align 4, !tbaa !5
  %41 = fmul float %39, %40
  store float %41, ptr %11, align 4, !tbaa !5
  %42 = load float, ptr %5, align 4, !tbaa !5
  %43 = load float, ptr %8, align 4, !tbaa !5
  %44 = fmul float %42, %43
  %45 = load float, ptr %11, align 4, !tbaa !5
  %46 = fdiv float %44, %45
  %47 = fcmp ogt float %46, 8.000000e+01
  br i1 %47, label %48, label %49

48:                                               ; preds = %19
  store float 0.000000e+00, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %72

49:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %50 = load float, ptr %5, align 4, !tbaa !5
  %51 = call float @logf(float noundef %50) #5
  %52 = load float, ptr %11, align 4, !tbaa !5
  %53 = call float @logf(float noundef %52) #5
  %54 = fsub float %51, %53
  store float %54, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %55 = load float, ptr %10, align 4, !tbaa !5
  %56 = fneg float %55
  %57 = load float, ptr %11, align 4, !tbaa !5
  %58 = fmul float 2.000000e+00, %57
  %59 = fdiv float %56, %58
  store float %59, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  %60 = load float, ptr %5, align 4, !tbaa !5
  %61 = load float, ptr %8, align 4, !tbaa !5
  %62 = fmul float %60, %61
  %63 = load float, ptr %11, align 4, !tbaa !5
  %64 = fdiv float %62, %63
  %65 = call float @liquid_lnbesselif(float noundef 0.000000e+00, float noundef %64)
  store float %65, ptr %15, align 4, !tbaa !5
  %66 = load float, ptr %13, align 4, !tbaa !5
  %67 = load float, ptr %14, align 4, !tbaa !5
  %68 = fadd float %66, %67
  %69 = load float, ptr %15, align 4, !tbaa !5
  %70 = fadd float %68, %69
  %71 = call float @expf(float noundef %70) #5, !tbaa !9
  store float %71, ptr %4, align 4
  store i32 1, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  br label %72

72:                                               ; preds = %49, %48
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  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
  br label %73

73:                                               ; preds = %72, %18
  %74 = load float, ptr %4, align 4
  ret float %74
}

; Function Attrs: nounwind
declare float @logf(float noundef) #1

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

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

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


; 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 nofree nounwind willreturn memory(write)
declare float @sqrtf(float noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local float @randricekf_pdf(float noundef %0, float noundef %1, float noundef %2) local_unnamed_addr #2 {
  %4 = fcmp olt float %0, 0.000000e+00
  br i1 %4, label %29, label %5

5:                                                ; preds = %3
  %6 = fmul float %1, %2
  %7 = fadd float %1, 1.000000e+00
  %8 = fdiv float %6, %7
  %9 = tail call float @sqrtf(float noundef %8) #4
  %10 = fmul float %2, 5.000000e-01
  %11 = fdiv float %10, %7
  %12 = tail call float @sqrtf(float noundef %11) #4
  %13 = fmul float %12, %12
  %14 = fmul float %9, %0
  %15 = fdiv float %14, %13
  %16 = fcmp ogt float %15, 8.000000e+01
  br i1 %16, label %29, label %17

17:                                               ; preds = %5
  %18 = fmul float %9, %9
  %19 = tail call float @llvm.fmuladd.f32(float %0, float %0, float %18)
  %20 = tail call float @logf(float noundef %0) #4
  %21 = tail call float @logf(float noundef %13) #4
  %22 = fsub float %20, %21
  %23 = fmul float %13, 2.000000e+00
  %24 = tail call float @liquid_lnbesselif(float noundef 0.000000e+00, float noundef %15) #4
  %25 = fdiv float %19, %23
  %26 = fsub float %22, %25
  %27 = fadd float %24, %26
  %28 = tail call float @expf(float noundef %27) #4, !tbaa !5
  br label %29

29:                                               ; preds = %17, %5, %3
  %.1 = phi float [ 0.000000e+00, %3 ], [ %28, %17 ], [ 0.000000e+00, %5 ]
  ret float %.1
}

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

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

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

attributes #0 = { 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 #1 = { mustprogress 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 = { "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"}


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