; LLVM IR from jgaeddert/liquid-dsp :: src/buffer/bench (cbuffercf_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"

@.str = external hidden unnamed_addr constant [93 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [46 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @cbuffercf_bench(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) #0 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i64, align 8
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i64, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store i32 %3, ptr %11, align 4, !tbaa !9
  store i32 %4, ptr %12, align 4, !tbaa !9
  store i32 %5, ptr %13, align 4, !tbaa !9
  %22 = load i32, ptr %11, align 4, !tbaa !9
  %23 = icmp ult i32 %22, 2
  br i1 %23, label %24, label %26

24:                                               ; preds = %6
  %25 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str, i32 noundef 44, ptr noundef @.str.1)
  store i32 %25, ptr %7, align 4
  br label %104

26:                                               ; preds = %6
  %27 = load i32, ptr %12, align 4, !tbaa !9
  %28 = load i32, ptr %11, align 4, !tbaa !9
  %29 = sub i32 %28, 1
  %30 = icmp ugt i32 %27, %29
  br i1 %30, label %31, label %33

31:                                               ; preds = %26
  %32 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str, i32 noundef 46, ptr noundef @.str.2)
  store i32 %32, ptr %7, align 4
  br label %104

33:                                               ; preds = %26
  %34 = load i32, ptr %13, align 4, !tbaa !9
  %35 = load i32, ptr %11, align 4, !tbaa !9
  %36 = sub i32 %35, 1
  %37 = icmp ugt i32 %34, %36
  br i1 %37, label %38, label %40

38:                                               ; preds = %33
  %39 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str, i32 noundef 48, ptr noundef @.str.3)
  store i32 %39, ptr %7, align 4
  br label %104

40:                                               ; preds = %33
  %41 = load i32, ptr %11, align 4, !tbaa !9
  %42 = zext i32 %41 to i64
  %43 = load ptr, ptr %10, align 8, !tbaa !5
  %44 = load i64, ptr %43, align 8, !tbaa !11
  %45 = mul i64 %44, %42
  store i64 %45, ptr %43, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %46 = load i32, ptr %11, align 4, !tbaa !9
  %47 = call ptr @cbuffercf_create(i32 noundef %46)
  store ptr %47, ptr %14, align 8, !tbaa !5
  %48 = load i32, ptr %12, align 4, !tbaa !9
  %49 = zext i32 %48 to i64
  %50 = call ptr @llvm.stacksave.p0()
  store ptr %50, ptr %15, align 8
  %51 = alloca { float, float }, i64 %49, align 16
  store i64 %49, ptr %16, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #5
  store i32 0, ptr %20, align 4, !tbaa !9
  br label %52

52:                                               ; preds = %62, %40
  %53 = load i32, ptr %20, align 4, !tbaa !9
  %54 = load i32, ptr %12, align 4, !tbaa !9
  %55 = icmp ult i32 %53, %54
  br i1 %55, label %56, label %65

56:                                               ; preds = %52
  %57 = load i32, ptr %20, align 4, !tbaa !9
  %58 = zext i32 %57 to i64
  %59 = getelementptr inbounds { float, float }, ptr %51, i64 %58
  %60 = getelementptr inbounds { float, float }, ptr %59, i32 0, i32 0
  %61 = getelementptr inbounds { float, float }, ptr %59, i32 0, i32 1
  store float 0.000000e+00, ptr %60, align 8
  store float 0.000000e+00, ptr %61, align 4
  br label %62

62:                                               ; preds = %56
  %63 = load i32, ptr %20, align 4, !tbaa !9
  %64 = add i32 %63, 1
  store i32 %64, ptr %20, align 4, !tbaa !9
  br label %52, !llvm.loop !13

65:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #5
  store i64 0, ptr %21, align 8, !tbaa !11
  %66 = load ptr, ptr %8, align 8, !tbaa !5
  %67 = call i32 @getrusage(i32 noundef 0, ptr noundef %66) #5
  br label %68

68:                                               ; preds = %84, %65
  %69 = load i64, ptr %21, align 8, !tbaa !11
  %70 = load ptr, ptr %10, align 8, !tbaa !5
  %71 = load i64, ptr %70, align 8, !tbaa !11
  %72 = icmp ult i64 %69, %71
  br i1 %72, label %73, label %96

73:                                               ; preds = %68
  %74 = load i32, ptr %11, align 4, !tbaa !9
  %75 = load ptr, ptr %14, align 8, !tbaa !5
  %76 = call i32 @cbuffercf_size(ptr noundef %75)
  %77 = sub i32 %74, %76
  %78 = load i32, ptr %12, align 4, !tbaa !9
  %79 = icmp ugt i32 %77, %78
  br i1 %79, label %80, label %84

80:                                               ; preds = %73
  %81 = load ptr, ptr %14, align 8, !tbaa !5
  %82 = load i32, ptr %12, align 4, !tbaa !9
  %83 = call i32 @cbuffercf_write(ptr noundef %81, ptr noundef %51, i32 noundef %82)
  br label %84

84:                                               ; preds = %80, %73
  %85 = load i32, ptr %13, align 4, !tbaa !9
  store i32 %85, ptr %18, align 4, !tbaa !9
  %86 = load ptr, ptr %14, align 8, !tbaa !5
  %87 = load i32, ptr %18, align 4, !tbaa !9
  %88 = call i32 @cbuffercf_read(ptr noundef %86, i32 noundef %87, ptr noundef %17, ptr noundef %19)
  %89 = load ptr, ptr %14, align 8, !tbaa !5
  %90 = load i32, ptr %19, align 4, !tbaa !9
  %91 = call i32 @cbuffercf_release(ptr noundef %89, i32 noundef %90)
  %92 = load i32, ptr %19, align 4, !tbaa !9
  %93 = zext i32 %92 to i64
  %94 = load i64, ptr %21, align 8, !tbaa !11
  %95 = add i64 %94, %93
  store i64 %95, ptr %21, align 8, !tbaa !11
  br label %68, !llvm.loop !15

96:                                               ; preds = %68
  %97 = load ptr, ptr %9, align 8, !tbaa !5
  %98 = call i32 @getrusage(i32 noundef 0, ptr noundef %97) #5
  %99 = load i64, ptr %21, align 8, !tbaa !11
  %100 = load ptr, ptr %10, align 8, !tbaa !5
  store i64 %99, ptr %100, align 8, !tbaa !11
  %101 = load ptr, ptr %14, align 8, !tbaa !5
  %102 = call i32 @cbuffercf_destroy(ptr noundef %101)
  store i32 0, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  %103 = load ptr, ptr %15, align 8
  call void @llvm.stackrestore.p0(ptr %103)
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  br label %104

104:                                              ; preds = %96, %38, %31, %24
  %105 = load i32, ptr %7, align 4
  ret i32 %105
}

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

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

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

declare i32 @cbuffercf_size(ptr noundef) #1

declare i32 @cbuffercf_write(ptr noundef, ptr noundef, i32 noundef) #1

declare i32 @cbuffercf_read(ptr noundef, i32 noundef, ptr noundef, ptr noundef) #1

declare i32 @cbuffercf_release(ptr noundef, i32 noundef) #1

declare i32 @cbuffercf_destroy(ptr noundef) #1

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

; 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 = { "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 = { nocallback nofree nosync nounwind willreturn }
attributes #4 = { 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 #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 = !{!"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"}
!15 = distinct !{!15, !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 [93 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [46 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @cbuffercf_bench(ptr noundef %0, ptr noundef %1, ptr nocapture noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) local_unnamed_addr #0 {
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = icmp ult i32 %3, 2
  br i1 %9, label %10, label %12

10:                                               ; preds = %6
  %11 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str, i32 noundef 44, ptr noundef nonnull @.str.1) #6
  br label %48

12:                                               ; preds = %6
  %13 = add i32 %3, -1
  %14 = icmp ult i32 %13, %4
  br i1 %14, label %15, label %17

15:                                               ; preds = %12
  %16 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str, i32 noundef 46, ptr noundef nonnull @.str.2) #6
  br label %48

17:                                               ; preds = %12
  %18 = icmp ult i32 %13, %5
  br i1 %18, label %19, label %21

19:                                               ; preds = %17
  %20 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str, i32 noundef 48, ptr noundef nonnull @.str.3) #6
  br label %48

21:                                               ; preds = %17
  %22 = zext i32 %3 to i64
  %23 = load i64, ptr %2, align 8, !tbaa !5
  %24 = mul i64 %23, %22
  store i64 %24, ptr %2, align 8, !tbaa !5
  %25 = tail call ptr @cbuffercf_create(i32 noundef %3) #6
  %26 = zext i32 %4 to i64
  %27 = tail call ptr @llvm.stacksave.p0()
  %28 = alloca { float, float }, i64 %26, align 16
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #6
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %21
  %29 = shl nuw nsw i64 %26, 3
  call void @llvm.memset.p0.i64(ptr nonnull align 16 %28, i8 0, i64 %29, i1 false)
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph.preheader, %21
  %30 = tail call i32 @getrusage(i32 noundef 0, ptr noundef %0) #6
  %31 = load i64, ptr %2, align 8, !tbaa !5
  %.not42 = icmp eq i64 %31, 0
  br i1 %.not42, label %._crit_edge41, label %.lr.ph40

.lr.ph40:                                         ; preds = %._crit_edge, %37
  %.038 = phi i64 [ %43, %37 ], [ 0, %._crit_edge ]
  %32 = call i32 @cbuffercf_size(ptr noundef %25) #6
  %33 = sub i32 %3, %32
  %34 = icmp ugt i32 %33, %4
  br i1 %34, label %35, label %37

35:                                               ; preds = %.lr.ph40
  %36 = call i32 @cbuffercf_write(ptr noundef %25, ptr noundef nonnull %28, i32 noundef %4) #6
  br label %37

37:                                               ; preds = %35, %.lr.ph40
  %38 = call i32 @cbuffercf_read(ptr noundef %25, i32 noundef %5, ptr noundef nonnull %7, ptr noundef nonnull %8) #6
  %39 = load i32, ptr %8, align 4, !tbaa !9
  %40 = call i32 @cbuffercf_release(ptr noundef %25, i32 noundef %39) #6
  %41 = load i32, ptr %8, align 4, !tbaa !9
  %42 = zext i32 %41 to i64
  %43 = add i64 %.038, %42
  %44 = load i64, ptr %2, align 8, !tbaa !5
  %45 = icmp ult i64 %43, %44
  br i1 %45, label %.lr.ph40, label %._crit_edge41, !llvm.loop !11

._crit_edge41:                                    ; preds = %37, %._crit_edge
  %.0.lcssa = phi i64 [ 0, %._crit_edge ], [ %43, %37 ]
  %46 = call i32 @getrusage(i32 noundef 0, ptr noundef %1) #6
  store i64 %.0.lcssa, ptr %2, align 8, !tbaa !5
  %47 = call i32 @cbuffercf_destroy(ptr noundef %25) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #6
  call void @llvm.stackrestore.p0(ptr %27)
  br label %48

48:                                               ; preds = %._crit_edge41, %19, %15, %10
  %.032 = phi i32 [ %11, %10 ], [ %16, %15 ], [ %20, %19 ], [ 0, %._crit_edge41 ]
  ret i32 %.032
}

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

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

declare ptr @cbuffercf_create(i32 noundef) local_unnamed_addr #1

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

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

declare i32 @cbuffercf_size(ptr noundef) local_unnamed_addr #1

declare i32 @cbuffercf_write(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

declare i32 @cbuffercf_read(ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare i32 @cbuffercf_release(ptr noundef, i32 noundef) local_unnamed_addr #1

declare i32 @cbuffercf_destroy(ptr noundef) local_unnamed_addr #1

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nocallback nofree nosync nounwind willreturn }
attributes #4 = { 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 #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { 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 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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