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

; 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 i32 @getrusage(i32 noundef, ptr noundef) #1

; 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 @benchmark_random_weibull(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = load i64, ptr %12, align 8, !tbaa !9
  %14 = mul i64 %13, 2
  store i64 %14, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store float 0.000000e+00, ptr %7, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store float 1.000000e+00, ptr %8, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store float 2.000000e+00, ptr %9, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store float 6.000000e+00, ptr %10, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = call i32 @getrusage(i32 noundef 0, ptr noundef %15) #4
  store i64 0, ptr %11, align 8, !tbaa !9
  br label %17

17:                                               ; preds = %47, %3
  %18 = load i64, ptr %11, align 8, !tbaa !9
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = load i64, ptr %19, align 8, !tbaa !9
  %21 = icmp ult i64 %18, %20
  br i1 %21, label %22, label %50

22:                                               ; preds = %17
  %23 = load float, ptr %8, align 4, !tbaa !11
  %24 = load float, ptr %9, align 4, !tbaa !11
  %25 = load float, ptr %10, align 4, !tbaa !11
  %26 = call float @randweibf(float noundef %23, float noundef %24, float noundef %25)
  %27 = load float, ptr %7, align 4, !tbaa !11
  %28 = fadd float %27, %26
  store float %28, ptr %7, align 4, !tbaa !11
  %29 = load float, ptr %8, align 4, !tbaa !11
  %30 = load float, ptr %9, align 4, !tbaa !11
  %31 = load float, ptr %10, align 4, !tbaa !11
  %32 = call float @randweibf(float noundef %29, float noundef %30, float noundef %31)
  %33 = load float, ptr %7, align 4, !tbaa !11
  %34 = fadd float %33, %32
  store float %34, ptr %7, align 4, !tbaa !11
  %35 = load float, ptr %8, align 4, !tbaa !11
  %36 = load float, ptr %9, align 4, !tbaa !11
  %37 = load float, ptr %10, align 4, !tbaa !11
  %38 = call float @randweibf(float noundef %35, float noundef %36, float noundef %37)
  %39 = load float, ptr %7, align 4, !tbaa !11
  %40 = fadd float %39, %38
  store float %40, ptr %7, align 4, !tbaa !11
  %41 = load float, ptr %8, align 4, !tbaa !11
  %42 = load float, ptr %9, align 4, !tbaa !11
  %43 = load float, ptr %10, align 4, !tbaa !11
  %44 = call float @randweibf(float noundef %41, float noundef %42, float noundef %43)
  %45 = load float, ptr %7, align 4, !tbaa !11
  %46 = fadd float %45, %44
  store float %46, ptr %7, align 4, !tbaa !11
  br label %47

47:                                               ; preds = %22
  %48 = load i64, ptr %11, align 8, !tbaa !9
  %49 = add i64 %48, 1
  store i64 %49, ptr %11, align 8, !tbaa !9
  br label %17, !llvm.loop !13

50:                                               ; preds = %17
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = call i32 @getrusage(i32 noundef 0, ptr noundef %51) #4
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = load i64, ptr %53, align 8, !tbaa !9
  %55 = mul i64 %54, 4
  store i64 %55, ptr %53, align 8, !tbaa !9
  %56 = load float, ptr %7, align 4, !tbaa !11
  %57 = fcmp ogt float %56, 0.000000e+00
  %58 = zext i1 %57 to i32
  %59 = sext i32 %58 to i64
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = load i64, ptr %60, align 8, !tbaa !9
  %62 = add i64 %61, %59
  store i64 %62, ptr %60, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, 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
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  ret void
}

declare float @randweibf(float noundef, float noundef, float noundef) #3

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 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

; Function Attrs: nounwind
declare i32 @getrusage(i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @benchmark_random_weibull(ptr noundef %0, ptr noundef %1, ptr nocapture noundef %2) local_unnamed_addr #1 {
  %4 = load i64, ptr %2, align 8, !tbaa !5
  %5 = shl i64 %4, 1
  store i64 %5, ptr %2, align 8, !tbaa !5
  %6 = tail call i32 @getrusage(i32 noundef 0, ptr noundef %0) #3
  %7 = load i64, ptr %2, align 8, !tbaa !5
  %.not = icmp eq i64 %7, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3, %.lr.ph
  %.026 = phi i64 [ %16, %.lr.ph ], [ 0, %3 ]
  %.02425 = phi float [ %15, %.lr.ph ], [ 0.000000e+00, %3 ]
  %8 = tail call float @randweibf(float noundef 1.000000e+00, float noundef 2.000000e+00, float noundef 6.000000e+00) #3
  %9 = fadd float %.02425, %8
  %10 = tail call float @randweibf(float noundef 1.000000e+00, float noundef 2.000000e+00, float noundef 6.000000e+00) #3
  %11 = fadd float %9, %10
  %12 = tail call float @randweibf(float noundef 1.000000e+00, float noundef 2.000000e+00, float noundef 6.000000e+00) #3
  %13 = fadd float %11, %12
  %14 = tail call float @randweibf(float noundef 1.000000e+00, float noundef 2.000000e+00, float noundef 6.000000e+00) #3
  %15 = fadd float %13, %14
  %16 = add nuw i64 %.026, 1
  %17 = load i64, ptr %2, align 8, !tbaa !5
  %18 = icmp ult i64 %16, %17
  br i1 %18, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !9

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %19 = fcmp ogt float %15, 0.000000e+00
  %20 = zext i1 %19 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %3
  %.024.lcssa = phi i64 [ 0, %3 ], [ %20, %._crit_edge.loopexit ]
  %21 = tail call i32 @getrusage(i32 noundef 0, ptr noundef %1) #3
  %22 = load i64, ptr %2, align 8, !tbaa !5
  %23 = shl i64 %22, 2
  %24 = or disjoint i64 %23, %.024.lcssa
  store i64 %24, ptr %2, align 8, !tbaa !5
  ret void
}

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

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


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