; LLVM IR from jgaeddert/liquid-dsp :: src/buffer/src (buffercf)

; 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"

%struct.windowcf_s = type { ptr, i32, i32, i32, i32, i32, i32 }

; 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
declare dso_local ptr @windowcf_create(i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @windowcf_recreate(ptr noundef %0, i32 noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca { float, float }, align 4
  %10 = alloca { float, float }, align 4
  %11 = alloca { float, float }, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %12 = load i32, ptr %5, align 4, !tbaa !9
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.windowcf_s, ptr %13, i32 0, i32 1
  %15 = load i32, ptr %14, align 8, !tbaa !11
  %16 = icmp eq i32 %12, %15
  br i1 %16, label %17, label %19

17:                                               ; preds = %2
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %18, ptr %3, align 8
  br label %106

19:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %20 = load i32, ptr %5, align 4, !tbaa !9
  %21 = call ptr @windowcf_create(i32 noundef %20)
  store ptr %21, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = call i32 @windowcf_read(ptr noundef %22, ptr noundef %7)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %24 = load i32, ptr %5, align 4, !tbaa !9
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.windowcf_s, ptr %25, i32 0, i32 1
  %27 = load i32, ptr %26, align 8, !tbaa !11
  %28 = icmp ugt i32 %24, %27
  br i1 %28, label %29, label %72

29:                                               ; preds = %19
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %30

30:                                               ; preds = %44, %29
  %31 = load i32, ptr %8, align 4, !tbaa !9
  %32 = load i32, ptr %5, align 4, !tbaa !9
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.windowcf_s, ptr %33, i32 0, i32 1
  %35 = load i32, ptr %34, align 8, !tbaa !11
  %36 = sub i32 %32, %35
  %37 = icmp ult i32 %31, %36
  br i1 %37, label %38, label %47

38:                                               ; preds = %30
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %41 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  store float 0.000000e+00, ptr %40, align 4
  store float 0.000000e+00, ptr %41, align 4
  %42 = load <2 x float>, ptr %9, align 4
  %43 = call i32 @windowcf_push(ptr noundef %39, <2 x float> noundef %42)
  br label %44

44:                                               ; preds = %38
  %45 = load i32, ptr %8, align 4, !tbaa !9
  %46 = add i32 %45, 1
  store i32 %46, ptr %8, align 4, !tbaa !9
  br label %30, !llvm.loop !13

47:                                               ; preds = %30
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %48

48:                                               ; preds = %68, %47
  %49 = load i32, ptr %8, align 4, !tbaa !9
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.windowcf_s, ptr %50, i32 0, i32 1
  %52 = load i32, ptr %51, align 8, !tbaa !11
  %53 = icmp ult i32 %49, %52
  br i1 %53, label %54, label %71

54:                                               ; preds = %48
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = load i32, ptr %8, align 4, !tbaa !9
  %58 = zext i32 %57 to i64
  %59 = getelementptr inbounds { float, float }, ptr %56, i64 %58
  %60 = getelementptr inbounds { float, float }, ptr %59, i32 0, i32 0
  %61 = load float, ptr %60, align 4
  %62 = getelementptr inbounds { float, float }, ptr %59, i32 0, i32 1
  %63 = load float, ptr %62, align 4
  %64 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 0
  %65 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 1
  store float %61, ptr %64, align 4
  store float %63, ptr %65, align 4
  %66 = load <2 x float>, ptr %10, align 4
  %67 = call i32 @windowcf_push(ptr noundef %55, <2 x float> noundef %66)
  br label %68

68:                                               ; preds = %54
  %69 = load i32, ptr %8, align 4, !tbaa !9
  %70 = add i32 %69, 1
  store i32 %70, ptr %8, align 4, !tbaa !9
  br label %48, !llvm.loop !15

71:                                               ; preds = %48
  br label %102

72:                                               ; preds = %19
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.windowcf_s, ptr %73, i32 0, i32 1
  %75 = load i32, ptr %74, align 8, !tbaa !11
  %76 = load i32, ptr %5, align 4, !tbaa !9
  %77 = sub i32 %75, %76
  store i32 %77, ptr %8, align 4, !tbaa !9
  br label %78

78:                                               ; preds = %98, %72
  %79 = load i32, ptr %8, align 4, !tbaa !9
  %80 = load ptr, ptr %4, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.windowcf_s, ptr %80, i32 0, i32 1
  %82 = load i32, ptr %81, align 8, !tbaa !11
  %83 = icmp ult i32 %79, %82
  br i1 %83, label %84, label %101

84:                                               ; preds = %78
  %85 = load ptr, ptr %6, align 8, !tbaa !5
  %86 = load ptr, ptr %7, align 8, !tbaa !5
  %87 = load i32, ptr %8, align 4, !tbaa !9
  %88 = zext i32 %87 to i64
  %89 = getelementptr inbounds { float, float }, ptr %86, i64 %88
  %90 = getelementptr inbounds { float, float }, ptr %89, i32 0, i32 0
  %91 = load float, ptr %90, align 4
  %92 = getelementptr inbounds { float, float }, ptr %89, i32 0, i32 1
  %93 = load float, ptr %92, align 4
  %94 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 0
  %95 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 1
  store float %91, ptr %94, align 4
  store float %93, ptr %95, align 4
  %96 = load <2 x float>, ptr %11, align 4
  %97 = call i32 @windowcf_push(ptr noundef %85, <2 x float> noundef %96)
  br label %98

98:                                               ; preds = %84
  %99 = load i32, ptr %8, align 4, !tbaa !9
  %100 = add i32 %99, 1
  store i32 %100, ptr %8, align 4, !tbaa !9
  br label %78, !llvm.loop !16

101:                                              ; preds = %78
  br label %102

102:                                              ; preds = %101, %71
  %103 = load ptr, ptr %4, align 8, !tbaa !5
  %104 = call i32 @windowcf_destroy(ptr noundef %103)
  %105 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %105, ptr %3, align 8
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %106

106:                                              ; preds = %102, %17
  %107 = load ptr, ptr %3, align 8
  ret ptr %107
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @windowcf_read(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @windowcf_push(ptr noundef, <2 x float> noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @windowcf_destroy(ptr noundef) #1

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 = { 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 #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 = !{!"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, !10, i64 8}
!12 = !{!"windowcf_s", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28}
!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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @windowcf_create(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local ptr @windowcf_recreate(ptr noundef %0, i32 noundef %1) local_unnamed_addr #2 {
  %3 = alloca ptr, align 8
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %6 = icmp eq i32 %5, %1
  br i1 %6, label %36, label %7

7:                                                ; preds = %2
  %8 = tail call ptr @windowcf_create(i32 noundef %1)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  %9 = call i32 @windowcf_read(ptr noundef nonnull %0, ptr noundef nonnull %3)
  %10 = load i32, ptr %4, align 8, !tbaa !5
  %11 = icmp ult i32 %10, %1
  br i1 %11, label %.lr.ph38, label %24

.preheader:                                       ; preds = %.lr.ph38
  %.not41 = icmp eq i32 %14, 0
  br i1 %.not41, label %.loopexit, label %.lr.ph40

.lr.ph38:                                         ; preds = %7, %.lr.ph38
  %.037 = phi i32 [ %13, %.lr.ph38 ], [ 0, %7 ]
  %12 = call i32 @windowcf_push(ptr noundef %8, <2 x float> noundef zeroinitializer)
  %13 = add nuw i32 %.037, 1
  %14 = load i32, ptr %4, align 8, !tbaa !5
  %15 = sub i32 %1, %14
  %16 = icmp ult i32 %13, %15
  br i1 %16, label %.lr.ph38, label %.preheader, !llvm.loop !11

.lr.ph40:                                         ; preds = %.preheader, %.lr.ph40
  %indvars.iv44 = phi i64 [ %indvars.iv.next45, %.lr.ph40 ], [ 0, %.preheader ]
  %17 = load ptr, ptr %3, align 8, !tbaa !13
  %18 = getelementptr inbounds { float, float }, ptr %17, i64 %indvars.iv44
  %19 = load <2 x float>, ptr %18, align 4
  %20 = call i32 @windowcf_push(ptr noundef %8, <2 x float> noundef %19)
  %indvars.iv.next45 = add nuw nsw i64 %indvars.iv44, 1
  %21 = load i32, ptr %4, align 8, !tbaa !5
  %22 = zext i32 %21 to i64
  %23 = icmp ult i64 %indvars.iv.next45, %22
  br i1 %23, label %.lr.ph40, label %.loopexit, !llvm.loop !14

24:                                               ; preds = %7
  %25 = sub i32 %10, %1
  %26 = icmp ult i32 %25, %10
  br i1 %26, label %.lr.ph.preheader, label %.loopexit

.lr.ph.preheader:                                 ; preds = %24
  %27 = zext i32 %25 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %27, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %28 = load ptr, ptr %3, align 8, !tbaa !13
  %29 = getelementptr inbounds { float, float }, ptr %28, i64 %indvars.iv
  %30 = load <2 x float>, ptr %29, align 4
  %31 = call i32 @windowcf_push(ptr noundef %8, <2 x float> noundef %30)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %32 = load i32, ptr %4, align 8, !tbaa !5
  %33 = zext i32 %32 to i64
  %34 = icmp ult i64 %indvars.iv.next, %33
  br i1 %34, label %.lr.ph, label %.loopexit, !llvm.loop !15

.loopexit:                                        ; preds = %.lr.ph, %.lr.ph40, %24, %.preheader
  %35 = call i32 @windowcf_destroy(ptr noundef nonnull %0)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  br label %36

36:                                               ; preds = %2, %.loopexit
  %.031 = phi ptr [ %8, %.loopexit ], [ %0, %2 ]
  ret ptr %.031
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @windowcf_read(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @windowcf_push(ptr noundef, <2 x float> noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @windowcf_destroy(ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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 = { 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 #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, !10, i64 8}
!6 = !{!"windowcf_s", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}


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