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

; 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 [14 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local void @_support_histogram_log(ptr noundef %0, i32 noundef %1, float noundef %2, float noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca i32, align 4
  %10 = alloca float, align 4
  %11 = alloca i32, align 4
  %12 = alloca float, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store float %2, ptr %7, align 4, !tbaa !11
  store float %3, ptr %8, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store float 0.000000e+00, ptr %10, align 4, !tbaa !11
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %15

15:                                               ; preds = %37, %4
  %16 = load i32, ptr %9, align 4, !tbaa !9
  %17 = load i32, ptr %6, align 4, !tbaa !9
  %18 = icmp ult i32 %16, %17
  br i1 %18, label %19, label %40

19:                                               ; preds = %15
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = load i32, ptr %9, align 4, !tbaa !9
  %22 = zext i32 %21 to i64
  %23 = getelementptr inbounds float, ptr %20, i64 %22
  %24 = load float, ptr %23, align 4, !tbaa !11
  %25 = load float, ptr %10, align 4, !tbaa !11
  %26 = fcmp ogt float %24, %25
  br i1 %26, label %27, label %33

27:                                               ; preds = %19
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = load i32, ptr %9, align 4, !tbaa !9
  %30 = zext i32 %29 to i64
  %31 = getelementptr inbounds float, ptr %28, i64 %30
  %32 = load float, ptr %31, align 4, !tbaa !11
  br label %35

33:                                               ; preds = %19
  %34 = load float, ptr %10, align 4, !tbaa !11
  br label %35

35:                                               ; preds = %33, %27
  %36 = phi float [ %32, %27 ], [ %34, %33 ]
  store float %36, ptr %10, align 4, !tbaa !11
  br label %37

37:                                               ; preds = %35
  %38 = load i32, ptr %9, align 4, !tbaa !9
  %39 = add i32 %38, 1
  store i32 %39, ptr %9, align 4, !tbaa !9
  br label %15, !llvm.loop !13

40:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 72, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %41 = load float, ptr %8, align 4, !tbaa !11
  %42 = load float, ptr %7, align 4, !tbaa !11
  %43 = fsub float %41, %42
  %44 = load i32, ptr %6, align 4, !tbaa !9
  %45 = sub i32 %44, 1
  %46 = uitofp i32 %45 to float
  %47 = fdiv float %43, %46
  store float %47, ptr %12, align 4, !tbaa !11
  %48 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef @.str.1, ptr noundef @.str.2)
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %49

49:                                               ; preds = %92, %40
  %50 = load i32, ptr %9, align 4, !tbaa !9
  %51 = load i32, ptr %6, align 4, !tbaa !9
  %52 = icmp ult i32 %50, %51
  br i1 %52, label %53, label %95

53:                                               ; preds = %49
  %54 = load float, ptr %7, align 4, !tbaa !11
  %55 = load i32, ptr %9, align 4, !tbaa !9
  %56 = uitofp i32 %55 to float
  %57 = load float, ptr %12, align 4, !tbaa !11
  %58 = call float @llvm.fmuladd.f32(float %56, float %57, float %54)
  %59 = fpext float %58 to double
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = load i32, ptr %9, align 4, !tbaa !9
  %62 = zext i32 %61 to i64
  %63 = getelementptr inbounds float, ptr %60, i64 %62
  %64 = load float, ptr %63, align 4, !tbaa !11
  %65 = fpext float %64 to double
  %66 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, double noundef %59, double noundef %65)
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %67 = load i32, ptr %11, align 4, !tbaa !9
  %68 = uitofp i32 %67 to float
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = load i32, ptr %9, align 4, !tbaa !9
  %71 = zext i32 %70 to i64
  %72 = getelementptr inbounds float, ptr %69, i64 %71
  %73 = load float, ptr %72, align 4, !tbaa !11
  %74 = fmul float %68, %73
  %75 = load float, ptr %10, align 4, !tbaa !11
  %76 = fdiv float %74, %75
  %77 = fpext float %76 to double
  %78 = call double @llvm.round.f64(double %77)
  %79 = fptoui double %78 to i32
  store i32 %79, ptr %14, align 4, !tbaa !9
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %80

80:                                               ; preds = %86, %53
  %81 = load i32, ptr %13, align 4, !tbaa !9
  %82 = load i32, ptr %14, align 4, !tbaa !9
  %83 = icmp ult i32 %81, %82
  br i1 %83, label %84, label %89

84:                                               ; preds = %80
  %85 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  br label %86

86:                                               ; preds = %84
  %87 = load i32, ptr %13, align 4, !tbaa !9
  %88 = add i32 %87, 1
  store i32 %88, ptr %13, align 4, !tbaa !9
  br label %80, !llvm.loop !15

89:                                               ; preds = %80
  %90 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  %91 = call i32 (ptr, ...) @printf(ptr noundef @.str.6)
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  br label %92

92:                                               ; preds = %89
  %93 = load i32, ptr %9, align 4, !tbaa !9
  %94 = add i32 %93, 1
  store i32 %94, ptr %9, align 4, !tbaa !9
  br label %49, !llvm.loop !16

95:                                               ; preds = %49
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  ret void
}

declare i32 @printf(ptr noundef, ...) #2

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.round.f64(double) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 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 = !{!"any pointer", !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 = !{!12, !12, i64 0}
!12 = !{!"float", !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"

@.str = external hidden unnamed_addr constant [14 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local void @_support_histogram_log(ptr nocapture noundef readonly %0, i32 noundef %1, float noundef %2, float noundef %3) local_unnamed_addr #0 {
  %.not = icmp eq i32 %1, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %4
  %wide.trip.count = zext i32 %1 to i64
  %xtraiter = and i64 %wide.trip.count, 3
  %5 = icmp ult i32 %1, 4
  br i1 %5, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %wide.trip.count, 4294967292
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader.new ], [ %indvars.iv.next.3, %.lr.ph ]
  %.02730 = phi float [ 0.000000e+00, %.lr.ph.preheader.new ], [ %..027.3, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.3, %.lr.ph ]
  %6 = getelementptr inbounds float, ptr %0, i64 %indvars.iv
  %7 = load float, ptr %6, align 4, !tbaa !5
  %8 = fcmp ogt float %7, %.02730
  %..027 = select i1 %8, float %7, float %.02730
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %9 = getelementptr inbounds float, ptr %0, i64 %indvars.iv.next
  %10 = load float, ptr %9, align 4, !tbaa !5
  %11 = fcmp ogt float %10, %..027
  %..027.1 = select i1 %11, float %10, float %..027
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %12 = getelementptr inbounds float, ptr %0, i64 %indvars.iv.next.1
  %13 = load float, ptr %12, align 4, !tbaa !5
  %14 = fcmp ogt float %13, %..027.1
  %..027.2 = select i1 %14, float %13, float %..027.1
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %15 = getelementptr inbounds float, ptr %0, i64 %indvars.iv.next.2
  %16 = load float, ptr %15, align 4, !tbaa !5
  %17 = fcmp ogt float %16, %..027.2
  %..027.3 = select i1 %17, float %16, float %..027.2
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !9

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph, %.lr.ph.preheader
  %..027.lcssa.ph = phi float [ poison, %.lr.ph.preheader ], [ %..027.3, %.lr.ph ]
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next.3, %.lr.ph ]
  %.02730.unr = phi float [ 0.000000e+00, %.lr.ph.preheader ], [ %..027.3, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.lr.ph.epil ], [ %indvars.iv.unr, %._crit_edge.loopexit.unr-lcssa ]
  %.02730.epil = phi float [ %..027.epil, %.lr.ph.epil ], [ %.02730.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %18 = getelementptr inbounds float, ptr %0, i64 %indvars.iv.epil
  %19 = load float, ptr %18, align 4, !tbaa !5
  %20 = fcmp ogt float %19, %.02730.epil
  %..027.epil = select i1 %20, float %19, float %.02730.epil
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.lr.ph.epil, !llvm.loop !11

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil, %4
  %.027.lcssa = phi float [ 0.000000e+00, %4 ], [ %..027.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %..027.epil, %.lr.ph.epil ]
  %21 = fsub float %3, %2
  %22 = add i32 %1, -1
  %23 = uitofp i32 %22 to float
  %24 = fdiv float %21, %23
  %25 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2)
  br i1 %.not, label %._crit_edge39, label %.lr.ph38.preheader

.lr.ph38.preheader:                               ; preds = %._crit_edge
  %wide.trip.count47 = zext i32 %1 to i64
  br label %.lr.ph38

.lr.ph38:                                         ; preds = %.lr.ph38.preheader, %._crit_edge35
  %indvars.iv44 = phi i64 [ 0, %.lr.ph38.preheader ], [ %indvars.iv.next45, %._crit_edge35 ]
  %26 = trunc nuw i64 %indvars.iv44 to i32
  %27 = uitofp i32 %26 to float
  %28 = tail call float @llvm.fmuladd.f32(float %27, float %24, float %2)
  %29 = fpext float %28 to double
  %30 = getelementptr inbounds float, ptr %0, i64 %indvars.iv44
  %31 = load float, ptr %30, align 4, !tbaa !5
  %32 = fpext float %31 to double
  %33 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, double noundef %29, double noundef %32)
  %34 = load float, ptr %30, align 4, !tbaa !5
  %35 = fmul float %34, 7.200000e+01
  %36 = fdiv float %35, %.027.lcssa
  %37 = tail call float @llvm.round.f32(float %36)
  %38 = fptoui float %37 to i32
  %.not41 = icmp eq i32 %38, 0
  br i1 %.not41, label %._crit_edge35, label %.lr.ph34

.lr.ph34:                                         ; preds = %.lr.ph38, %.lr.ph34
  %.02632 = phi i32 [ %40, %.lr.ph34 ], [ 0, %.lr.ph38 ]
  %39 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  %40 = add nuw i32 %.02632, 1
  %exitcond43.not = icmp eq i32 %40, %38
  br i1 %exitcond43.not, label %._crit_edge35, label %.lr.ph34, !llvm.loop !13

._crit_edge35:                                    ; preds = %.lr.ph34, %.lr.ph38
  %41 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  %42 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6)
  %indvars.iv.next45 = add nuw nsw i64 %indvars.iv44, 1
  %exitcond48.not = icmp eq i64 %indvars.iv.next45, %wide.trip.count47
  br i1 %exitcond48.not, label %._crit_edge39, label %.lr.ph38, !llvm.loop !14

._crit_edge39:                                    ; preds = %._crit_edge35, %._crit_edge
  ret void
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

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

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

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

!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, !12}
!12 = !{!"llvm.loop.unroll.disable"}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass