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

; 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.1 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [44 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local float @randweibf(float noundef %0, float noundef %1, float noundef %2) #0 {
  %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
  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
  %9 = load float, ptr %5, align 4, !tbaa !5
  %10 = fcmp ole float %9, 0.000000e+00
  br i1 %10, label %11, label %13

11:                                               ; preds = %3
  %12 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str, i32 noundef 40, ptr noundef @.str.1)
  store float 0.000000e+00, ptr %4, align 4
  br label %35

13:                                               ; preds = %3
  %14 = load float, ptr %6, align 4, !tbaa !5
  %15 = fcmp ole float %14, 0.000000e+00
  br i1 %15, label %16, label %18

16:                                               ; preds = %13
  %17 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str, i32 noundef 43, ptr noundef @.str.2)
  store float 0.000000e+00, ptr %4, align 4
  br label %35

18:                                               ; preds = %13
  br label %19

19:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  br label %20

20:                                               ; preds = %22, %19
  %21 = call float (...) @randf()
  store float %21, ptr %8, align 4, !tbaa !5
  br label %22

22:                                               ; preds = %20
  %23 = load float, ptr %8, align 4, !tbaa !5
  %24 = fcmp oeq float %23, 0.000000e+00
  br i1 %24, label %20, label %25, !llvm.loop !9

25:                                               ; preds = %22
  %26 = load float, ptr %7, align 4, !tbaa !5
  %27 = load float, ptr %6, align 4, !tbaa !5
  %28 = load float, ptr %8, align 4, !tbaa !5
  %29 = call float @logf(float noundef %28) #5
  %30 = fneg float %29
  %31 = load float, ptr %5, align 4, !tbaa !5
  %32 = fdiv float 1.000000e+00, %31
  %33 = call float @powf(float noundef %30, float noundef %32) #5
  %34 = call float @llvm.fmuladd.f32(float %27, float %33, float %26)
  store float %34, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %35

35:                                               ; preds = %25, %16, %11
  %36 = load float, ptr %4, align 4
  ret float %36
}

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

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

declare float @randf(...) #1

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

; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

attributes #0 = { 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 #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = distinct !{!9, !10}
!10 = !{!"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"

@.str = external hidden unnamed_addr constant [80 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [44 x i8], align 1

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

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

7:                                                ; preds = %3
  %8 = fcmp ugt float %1, 0.000000e+00
  br i1 %8, label %.preheader, 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 43, ptr noundef nonnull @.str.2) #4
  br label %19

.preheader:                                       ; preds = %7, %.preheader
  %11 = tail call float (...) @randf() #4
  %12 = fcmp oeq float %11, 0.000000e+00
  br i1 %12, label %.preheader, label %13, !llvm.loop !5

13:                                               ; preds = %.preheader
  %14 = tail call float @logf(float noundef %11) #4
  %15 = fneg float %14
  %16 = fdiv float 1.000000e+00, %0
  %17 = tail call float @powf(float noundef %15, float noundef %16) #4
  %18 = tail call float @llvm.fmuladd.f32(float %1, float %17, float %2)
  br label %19

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

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

declare float @randf(...) local_unnamed_addr #1

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

; 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

attributes #0 = { 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 #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 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass