; LLVM IR from jgaeddert/liquid-dsp :: src/buffer/bench (window_read_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: nounwind uwtable
define dso_local void @window_read_bench(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca { float, float }, align 4
  %13 = alloca { float, float }, align 4
  %14 = alloca { float, float }, align 4
  %15 = alloca { float, float }, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store i32 %3, ptr %8, align 4, !tbaa !9
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = load i64, ptr %16, align 8, !tbaa !11
  %18 = icmp ult i64 %17, 1
  br i1 %18, label %19, label %21

19:                                               ; preds = %4
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 1, ptr %20, align 8, !tbaa !11
  br label %21

21:                                               ; preds = %19, %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %22 = load i32, ptr %8, align 4, !tbaa !9
  %23 = call ptr @windowcf_create(i32 noundef %22)
  store ptr %23, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = call i32 @getrusage(i32 noundef 0, ptr noundef %24) #4
  store i64 0, ptr %10, align 8, !tbaa !11
  br label %26

26:                                               ; preds = %60, %21
  %27 = load i64, ptr %10, align 8, !tbaa !11
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = load i64, ptr %28, align 8, !tbaa !11
  %30 = icmp ult i64 %27, %29
  br i1 %30, label %31, label %63

31:                                               ; preds = %26
  %32 = load ptr, ptr %9, align 8, !tbaa !5
  %33 = getelementptr inbounds { float, float }, ptr %12, i32 0, i32 0
  %34 = getelementptr inbounds { float, float }, ptr %12, i32 0, i32 1
  store float 1.000000e+00, ptr %33, align 4
  store float 0.000000e+00, ptr %34, align 4
  %35 = load <2 x float>, ptr %12, align 4
  %36 = call i32 @windowcf_push(ptr noundef %32, <2 x float> noundef %35)
  %37 = load ptr, ptr %9, align 8, !tbaa !5
  %38 = call i32 @windowcf_read(ptr noundef %37, ptr noundef %11)
  %39 = load ptr, ptr %9, align 8, !tbaa !5
  %40 = getelementptr inbounds { float, float }, ptr %13, i32 0, i32 0
  %41 = getelementptr inbounds { float, float }, ptr %13, i32 0, i32 1
  store float 1.000000e+00, ptr %40, align 4
  store float 0.000000e+00, ptr %41, align 4
  %42 = load <2 x float>, ptr %13, align 4
  %43 = call i32 @windowcf_push(ptr noundef %39, <2 x float> noundef %42)
  %44 = load ptr, ptr %9, align 8, !tbaa !5
  %45 = call i32 @windowcf_read(ptr noundef %44, ptr noundef %11)
  %46 = load ptr, ptr %9, align 8, !tbaa !5
  %47 = getelementptr inbounds { float, float }, ptr %14, i32 0, i32 0
  %48 = getelementptr inbounds { float, float }, ptr %14, i32 0, i32 1
  store float 1.000000e+00, ptr %47, align 4
  store float 0.000000e+00, ptr %48, align 4
  %49 = load <2 x float>, ptr %14, align 4
  %50 = call i32 @windowcf_push(ptr noundef %46, <2 x float> noundef %49)
  %51 = load ptr, ptr %9, align 8, !tbaa !5
  %52 = call i32 @windowcf_read(ptr noundef %51, ptr noundef %11)
  %53 = load ptr, ptr %9, align 8, !tbaa !5
  %54 = getelementptr inbounds { float, float }, ptr %15, i32 0, i32 0
  %55 = getelementptr inbounds { float, float }, ptr %15, i32 0, i32 1
  store float 1.000000e+00, ptr %54, align 4
  store float 0.000000e+00, ptr %55, align 4
  %56 = load <2 x float>, ptr %15, align 4
  %57 = call i32 @windowcf_push(ptr noundef %53, <2 x float> noundef %56)
  %58 = load ptr, ptr %9, align 8, !tbaa !5
  %59 = call i32 @windowcf_read(ptr noundef %58, ptr noundef %11)
  br label %60

60:                                               ; preds = %31
  %61 = load i64, ptr %10, align 8, !tbaa !11
  %62 = add i64 %61, 1
  store i64 %62, ptr %10, align 8, !tbaa !11
  br label %26, !llvm.loop !13

63:                                               ; preds = %26
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = call i32 @getrusage(i32 noundef 0, ptr noundef %64) #4
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = load i64, ptr %66, align 8, !tbaa !11
  %68 = mul i64 %67, 4
  store i64 %68, ptr %66, align 8, !tbaa !11
  %69 = load ptr, ptr %9, align 8, !tbaa !5
  %70 = call i32 @windowcf_destroy(ptr noundef %69)
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  ret void
}

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

declare ptr @windowcf_create(i32 noundef) #2

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

declare i32 @windowcf_push(ptr noundef, <2 x float> noundef) #2

declare i32 @windowcf_read(ptr noundef, ptr noundef) #2

declare i32 @windowcf_destroy(ptr noundef) #2

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

attributes #0 = { nounwind uwtable "min-legal-vector-width"="64" "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 = { "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 = { 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 = !{!"long", !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 uwtable
define dso_local void @window_read_bench(ptr noundef %0, ptr noundef %1, ptr nocapture noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = alloca ptr, align 8
  %6 = load i64, ptr %2, align 8, !tbaa !5
  %7 = icmp eq i64 %6, 0
  br i1 %7, label %8, label %9

8:                                                ; preds = %4
  store i64 1, ptr %2, align 8, !tbaa !5
  br label %9

9:                                                ; preds = %8, %4
  %10 = tail call ptr @windowcf_create(i32 noundef %3) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  %11 = tail call i32 @getrusage(i32 noundef 0, ptr noundef %0) #4
  %12 = load i64, ptr %2, align 8, !tbaa !5
  %.not = icmp eq i64 %12, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %9, %.lr.ph
  %.024 = phi i64 [ %21, %.lr.ph ], [ 0, %9 ]
  %13 = call i32 @windowcf_push(ptr noundef %10, <2 x float> noundef <float 1.000000e+00, float 0.000000e+00>) #4
  %14 = call i32 @windowcf_read(ptr noundef %10, ptr noundef nonnull %5) #4
  %15 = call i32 @windowcf_push(ptr noundef %10, <2 x float> noundef <float 1.000000e+00, float 0.000000e+00>) #4
  %16 = call i32 @windowcf_read(ptr noundef %10, ptr noundef nonnull %5) #4
  %17 = call i32 @windowcf_push(ptr noundef %10, <2 x float> noundef <float 1.000000e+00, float 0.000000e+00>) #4
  %18 = call i32 @windowcf_read(ptr noundef %10, ptr noundef nonnull %5) #4
  %19 = call i32 @windowcf_push(ptr noundef %10, <2 x float> noundef <float 1.000000e+00, float 0.000000e+00>) #4
  %20 = call i32 @windowcf_read(ptr noundef %10, ptr noundef nonnull %5) #4
  %21 = add nuw i64 %.024, 1
  %22 = load i64, ptr %2, align 8, !tbaa !5
  %23 = icmp ult i64 %21, %22
  br i1 %23, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph, %9
  %24 = call i32 @getrusage(i32 noundef 0, ptr noundef %1) #4
  %25 = load i64, ptr %2, align 8, !tbaa !5
  %26 = shl i64 %25, 2
  store i64 %26, ptr %2, align 8, !tbaa !5
  %27 = call i32 @windowcf_destroy(ptr noundef %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  ret void
}

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

declare ptr @windowcf_create(i32 noundef) local_unnamed_addr #2

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

declare i32 @windowcf_push(ptr noundef, <2 x float> noundef) local_unnamed_addr #2

declare i32 @windowcf_read(ptr noundef, ptr noundef) local_unnamed_addr #2

declare i32 @windowcf_destroy(ptr noundef) local_unnamed_addr #2

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

attributes #0 = { nounwind uwtable "min-legal-vector-width"="64" "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 willreturn memory(argmem: readwrite) }
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 "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 = !{!"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,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass