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

; 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"

@.str = external hidden unnamed_addr constant [80 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [49 x i8], align 1

declare i32 @liquid_error_fl(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) #0

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

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

; Function Attrs: nounwind uwtable
define dso_local float @randnakmf_pdf(float noundef %0, float noundef %1, float noundef %2) #2 {
  %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
  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
  %12 = load float, ptr %6, align 4, !tbaa !5
  %13 = fcmp olt float %12, 5.000000e-01
  br i1 %13, label %14, label %16

14:                                               ; preds = %3
  %15 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str, i32 noundef 68, ptr noundef @.str.3)
  store float 0.000000e+00, ptr %4, align 4
  br label %58

16:                                               ; preds = %3
  %17 = load float, ptr %7, align 4, !tbaa !5
  %18 = fcmp ole float %17, 0.000000e+00
  br i1 %18, label %19, label %21

19:                                               ; preds = %16
  %20 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str, i32 noundef 71, ptr noundef @.str.4)
  store float 0.000000e+00, ptr %4, align 4
  br label %58

21:                                               ; preds = %16
  br label %22

22:                                               ; preds = %21
  %23 = load float, ptr %5, align 4, !tbaa !5
  %24 = fcmp ole float %23, 0.000000e+00
  br i1 %24, label %25, label %26

25:                                               ; preds = %22
  store float 0.000000e+00, ptr %4, align 4
  br label %58

26:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %27 = load float, ptr %6, align 4, !tbaa !5
  %28 = call float @liquid_lngammaf(float noundef %27)
  store float %28, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %29 = load float, ptr %6, align 4, !tbaa !5
  %30 = load float, ptr %6, align 4, !tbaa !5
  %31 = load float, ptr %7, align 4, !tbaa !5
  %32 = fdiv float %30, %31
  %33 = call float @logf(float noundef %32) #5
  %34 = fmul float %29, %33
  store float %34, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %35 = load float, ptr %6, align 4, !tbaa !5
  %36 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %35, float -1.000000e+00)
  %37 = load float, ptr %5, align 4, !tbaa !5
  %38 = call float @logf(float noundef %37) #5
  %39 = fmul float %36, %38
  store float %39, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %40 = load float, ptr %6, align 4, !tbaa !5
  %41 = load float, ptr %7, align 4, !tbaa !5
  %42 = fdiv float %40, %41
  %43 = fneg float %42
  %44 = load float, ptr %5, align 4, !tbaa !5
  %45 = fmul float %43, %44
  %46 = load float, ptr %5, align 4, !tbaa !5
  %47 = fmul float %45, %46
  store float %47, ptr %11, align 4, !tbaa !5
  %48 = load float, ptr %8, align 4, !tbaa !5
  %49 = fneg float %48
  %50 = load float, ptr %9, align 4, !tbaa !5
  %51 = fadd float %49, %50
  %52 = load float, ptr %10, align 4, !tbaa !5
  %53 = fadd float %51, %52
  %54 = load float, ptr %11, align 4, !tbaa !5
  %55 = fadd float %53, %54
  %56 = call float @expf(float noundef %55) #5, !tbaa !9
  %57 = fmul float 2.000000e+00, %56
  store float %57, ptr %4, align 4
  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 %58

58:                                               ; preds = %26, %25, %19, %14
  %59 = load float, ptr %4, align 4
  ret float %59
}

declare float @liquid_lngammaf(float noundef) #0

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

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

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

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

@.str = external hidden unnamed_addr constant [80 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [49 x i8], align 1

declare i32 @liquid_error_fl(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local float @randnakmf_pdf(float noundef %0, float noundef %1, float noundef %2) local_unnamed_addr #1 {
  %4 = fcmp olt float %1, 5.000000e-01
  br i1 %4, label %5, label %7

5:                                                ; preds = %3
  %6 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str, i32 noundef 68, ptr noundef nonnull @.str.3) #4
  br label %29

7:                                                ; preds = %3
  %8 = fcmp ugt float %2, 0.000000e+00
  br i1 %8, label %11, label %9

9:                                                ; preds = %7
  %10 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str, i32 noundef 71, ptr noundef nonnull @.str.4) #4
  br label %29

11:                                               ; preds = %7
  %12 = fcmp ugt float %0, 0.000000e+00
  br i1 %12, label %13, label %29

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

29:                                               ; preds = %11, %13, %9, %5
  %.0 = phi float [ 0.000000e+00, %5 ], [ 0.000000e+00, %9 ], [ %28, %13 ], [ 0.000000e+00, %11 ]
  ret float %.0
}

declare float @liquid_lngammaf(float noundef) local_unnamed_addr #0

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

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

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

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