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

; 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: nounwind uwtable
declare dso_local i32 @_support_histogram_add(float noundef, ptr noundef, i32 noundef, float noundef, float 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

; Function Attrs: nounwind uwtable
declare dso_local void @_support_histogram_validate(ptr noundef, ptr noundef, ptr noundef, i32 noundef, float noundef, float noundef, float noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @autotest_distribution_randnf() #0 {
  %1 = alloca i64, align 8
  %2 = alloca float, align 4
  %3 = alloca float, align 4
  %4 = alloca float, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca float, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #5
  store i64 248000, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store float 0.000000e+00, ptr %2, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store float 1.000000e+00, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store float 0x3FA99999A0000000, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 31, ptr %5, align 4, !tbaa !11
  %16 = load i32, ptr %5, align 4, !tbaa !11
  %17 = zext i32 %16 to i64
  %18 = call ptr @llvm.stacksave.p0()
  store ptr %18, ptr %6, align 8
  %19 = alloca float, i64 %17, align 16
  store i64 %17, ptr %7, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  store i64 0, ptr %8, align 8, !tbaa !5
  br label %20

20:                                               ; preds = %28, %0
  %21 = load i64, ptr %8, align 8, !tbaa !5
  %22 = load i32, ptr %5, align 4, !tbaa !11
  %23 = zext i32 %22 to i64
  %24 = icmp ult i64 %21, %23
  br i1 %24, label %25, label %31

25:                                               ; preds = %20
  %26 = load i64, ptr %8, align 8, !tbaa !5
  %27 = getelementptr inbounds float, ptr %19, i64 %26
  store float 0.000000e+00, ptr %27, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %25
  %29 = load i64, ptr %8, align 8, !tbaa !5
  %30 = add i64 %29, 1
  store i64 %30, ptr %8, align 8, !tbaa !5
  br label %20, !llvm.loop !13

31:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store float -5.000000e+00, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store float 5.000000e+00, ptr %10, align 4, !tbaa !9
  store i64 0, ptr %8, align 8, !tbaa !5
  br label %32

32:                                               ; preds = %46, %31
  %33 = load i64, ptr %8, align 8, !tbaa !5
  %34 = load i64, ptr %1, align 8, !tbaa !5
  %35 = icmp ult i64 %33, %34
  br i1 %35, label %36, label %49

36:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %37 = call float (...) @randnf()
  %38 = load float, ptr %3, align 4, !tbaa !9
  %39 = load float, ptr %2, align 4, !tbaa !9
  %40 = call float @llvm.fmuladd.f32(float %37, float %38, float %39)
  store float %40, ptr %11, align 4, !tbaa !9
  %41 = load float, ptr %11, align 4, !tbaa !9
  %42 = load i32, ptr %5, align 4, !tbaa !11
  %43 = load float, ptr %9, align 4, !tbaa !9
  %44 = load float, ptr %10, align 4, !tbaa !9
  %45 = call i32 @_support_histogram_add(float noundef %41, ptr noundef %19, i32 noundef %42, float noundef %43, float noundef %44)
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %46

46:                                               ; preds = %36
  %47 = load i64, ptr %8, align 8, !tbaa !5
  %48 = add i64 %47, 1
  store i64 %48, ptr %8, align 8, !tbaa !5
  br label %32, !llvm.loop !15

49:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %50 = load float, ptr %10, align 4, !tbaa !9
  %51 = load float, ptr %9, align 4, !tbaa !9
  %52 = fsub float %50, %51
  %53 = load i32, ptr %5, align 4, !tbaa !11
  %54 = sub i32 %53, 1
  %55 = uitofp i32 %54 to float
  %56 = fdiv float %52, %55
  store float %56, ptr %12, align 4, !tbaa !9
  %57 = load i32, ptr %5, align 4, !tbaa !11
  %58 = zext i32 %57 to i64
  %59 = alloca float, i64 %58, align 16
  store i64 %58, ptr %13, align 8
  %60 = load i32, ptr %5, align 4, !tbaa !11
  %61 = zext i32 %60 to i64
  %62 = alloca float, i64 %61, align 16
  store i64 %61, ptr %14, align 8
  store i64 0, ptr %8, align 8, !tbaa !5
  br label %63

63:                                               ; preds = %86, %49
  %64 = load i64, ptr %8, align 8, !tbaa !5
  %65 = load i32, ptr %5, align 4, !tbaa !11
  %66 = zext i32 %65 to i64
  %67 = icmp ult i64 %64, %66
  br i1 %67, label %68, label %89

68:                                               ; preds = %63
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  %69 = load float, ptr %9, align 4, !tbaa !9
  %70 = load i64, ptr %8, align 8, !tbaa !5
  %71 = uitofp i64 %70 to float
  %72 = load float, ptr %12, align 4, !tbaa !9
  %73 = call float @llvm.fmuladd.f32(float %71, float %72, float %69)
  store float %73, ptr %15, align 4, !tbaa !9
  %74 = load float, ptr %15, align 4, !tbaa !9
  %75 = load float, ptr %2, align 4, !tbaa !9
  %76 = load float, ptr %3, align 4, !tbaa !9
  %77 = call float @randnf_pdf(float noundef %74, float noundef %75, float noundef %76)
  %78 = load i64, ptr %8, align 8, !tbaa !5
  %79 = getelementptr inbounds float, ptr %59, i64 %78
  store float %77, ptr %79, align 4, !tbaa !9
  %80 = load float, ptr %15, align 4, !tbaa !9
  %81 = load float, ptr %2, align 4, !tbaa !9
  %82 = load float, ptr %3, align 4, !tbaa !9
  %83 = call float @randnf_cdf(float noundef %80, float noundef %81, float noundef %82)
  %84 = load i64, ptr %8, align 8, !tbaa !5
  %85 = getelementptr inbounds float, ptr %62, i64 %84
  store float %83, ptr %85, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  br label %86

86:                                               ; preds = %68
  %87 = load i64, ptr %8, align 8, !tbaa !5
  %88 = add i64 %87, 1
  store i64 %88, ptr %8, align 8, !tbaa !5
  br label %63, !llvm.loop !16

89:                                               ; preds = %63
  %90 = load i32, ptr %5, align 4, !tbaa !11
  %91 = load float, ptr %9, align 4, !tbaa !9
  %92 = load float, ptr %10, align 4, !tbaa !9
  %93 = load float, ptr %4, align 4, !tbaa !9
  call void @_support_histogram_validate(ptr noundef %19, ptr noundef %59, ptr noundef %62, i32 noundef %90, float noundef %91, float noundef %92, float noundef %93)
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #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 8, ptr %8) #5
  %94 = load ptr, ptr %6, align 8
  call void @llvm.stackrestore.p0(ptr %94)
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #5
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #3

declare float @randnf(...) #4

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nocallback nofree nosync nounwind willreturn }
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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


; 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: nounwind uwtable
declare dso_local i32 @_support_histogram_add(float noundef, ptr noundef, i32 noundef, float noundef, 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
declare dso_local void @_support_histogram_validate(ptr noundef, ptr noundef, ptr noundef, i32 noundef, float noundef, float noundef, float noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @autotest_distribution_randnf() local_unnamed_addr #0 {
.preheader.preheader:
  %0 = alloca [31 x float], align 16
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(124) %0, i8 0, i64 124, i1 false), !tbaa !5
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %.preheader
  %.138 = phi i64 [ %4, %.preheader ], [ 0, %.preheader.preheader ]
  %1 = call float (...) @randnf() #4
  %2 = fadd float %1, 0.000000e+00
  %3 = call i32 @_support_histogram_add(float noundef %2, ptr noundef nonnull %0, i32 noundef 31, float noundef -5.000000e+00, float noundef 5.000000e+00)
  %4 = add nuw nsw i64 %.138, 1
  %exitcond.not = icmp eq i64 %4, 248000
  br i1 %exitcond.not, label %5, label %.preheader, !llvm.loop !9

5:                                                ; preds = %.preheader
  %6 = alloca [31 x float], align 16
  %7 = alloca [31 x float], align 16
  br label %8

8:                                                ; preds = %5, %8
  %.239 = phi i64 [ 0, %5 ], [ %15, %8 ]
  %9 = uitofp nneg i64 %.239 to float
  %10 = call float @llvm.fmuladd.f32(float %9, float 0x3FD5555560000000, float -5.000000e+00)
  %11 = call float @randnf_pdf(float noundef %10, float noundef 0.000000e+00, float noundef 1.000000e+00) #4
  %12 = getelementptr inbounds float, ptr %6, i64 %.239
  store float %11, ptr %12, align 4, !tbaa !5
  %13 = call float @randnf_cdf(float noundef %10, float noundef 0.000000e+00, float noundef 1.000000e+00) #4
  %14 = getelementptr inbounds float, ptr %7, i64 %.239
  store float %13, ptr %14, align 4, !tbaa !5
  %15 = add nuw nsw i64 %.239, 1
  %exitcond40.not = icmp eq i64 %15, 31
  br i1 %exitcond40.not, label %16, label %8, !llvm.loop !11

16:                                               ; preds = %8
  call void @_support_histogram_validate(ptr noundef nonnull %0, ptr noundef nonnull %6, ptr noundef nonnull %7, i32 noundef 31, float noundef -5.000000e+00, float noundef 5.000000e+00, float noundef 0x3FA99999A0000000)
  ret void
}

declare float @randnf(...) local_unnamed_addr #2

declare float @randnf_pdf(float noundef, float noundef, float noundef) local_unnamed_addr #2

declare float @randnf_cdf(float noundef, float noundef, float noundef) local_unnamed_addr #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,SROAPass,SimplifyCFGPass