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

; 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.windowf_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 @windowf_create(i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @windowf_recreate(ptr noundef %0, i32 noundef %1) #1 {
  %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
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %9 = load i32, ptr %5, align 4, !tbaa !9
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.windowf_s, ptr %10, i32 0, i32 1
  %12 = load i32, ptr %11, align 8, !tbaa !11
  %13 = icmp eq i32 %9, %12
  br i1 %13, label %14, label %16

14:                                               ; preds = %2
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %15, ptr %3, align 8
  br label %88

16:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %17 = load i32, ptr %5, align 4, !tbaa !9
  %18 = call ptr @windowf_create(i32 noundef %17)
  store ptr %18, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = call i32 @windowf_read(ptr noundef %19, ptr noundef %7)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  %21 = load i32, ptr %5, align 4, !tbaa !9
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.windowf_s, ptr %22, i32 0, i32 1
  %24 = load i32, ptr %23, align 8, !tbaa !11
  %25 = icmp ugt i32 %21, %24
  br i1 %25, label %26, label %60

26:                                               ; preds = %16
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %27

27:                                               ; preds = %38, %26
  %28 = load i32, ptr %8, align 4, !tbaa !9
  %29 = load i32, ptr %5, align 4, !tbaa !9
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.windowf_s, ptr %30, i32 0, i32 1
  %32 = load i32, ptr %31, align 8, !tbaa !11
  %33 = sub i32 %29, %32
  %34 = icmp ult i32 %28, %33
  br i1 %34, label %35, label %41

35:                                               ; preds = %27
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = call i32 @windowf_push(ptr noundef %36, float noundef 0.000000e+00)
  br label %38

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

41:                                               ; preds = %27
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %42

42:                                               ; preds = %56, %41
  %43 = load i32, ptr %8, align 4, !tbaa !9
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.windowf_s, ptr %44, i32 0, i32 1
  %46 = load i32, ptr %45, align 8, !tbaa !11
  %47 = icmp ult i32 %43, %46
  br i1 %47, label %48, label %59

48:                                               ; preds = %42
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = load i32, ptr %8, align 4, !tbaa !9
  %52 = zext i32 %51 to i64
  %53 = getelementptr inbounds float, ptr %50, i64 %52
  %54 = load float, ptr %53, align 4, !tbaa !15
  %55 = call i32 @windowf_push(ptr noundef %49, float noundef %54)
  br label %56

56:                                               ; preds = %48
  %57 = load i32, ptr %8, align 4, !tbaa !9
  %58 = add i32 %57, 1
  store i32 %58, ptr %8, align 4, !tbaa !9
  br label %42, !llvm.loop !17

59:                                               ; preds = %42
  br label %84

60:                                               ; preds = %16
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.windowf_s, ptr %61, i32 0, i32 1
  %63 = load i32, ptr %62, align 8, !tbaa !11
  %64 = load i32, ptr %5, align 4, !tbaa !9
  %65 = sub i32 %63, %64
  store i32 %65, ptr %8, align 4, !tbaa !9
  br label %66

66:                                               ; preds = %80, %60
  %67 = load i32, ptr %8, align 4, !tbaa !9
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.windowf_s, ptr %68, i32 0, i32 1
  %70 = load i32, ptr %69, align 8, !tbaa !11
  %71 = icmp ult i32 %67, %70
  br i1 %71, label %72, label %83

72:                                               ; preds = %66
  %73 = load ptr, ptr %6, align 8, !tbaa !5
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = load i32, ptr %8, align 4, !tbaa !9
  %76 = zext i32 %75 to i64
  %77 = getelementptr inbounds float, ptr %74, i64 %76
  %78 = load float, ptr %77, align 4, !tbaa !15
  %79 = call i32 @windowf_push(ptr noundef %73, float noundef %78)
  br label %80

80:                                               ; preds = %72
  %81 = load i32, ptr %8, align 4, !tbaa !9
  %82 = add i32 %81, 1
  store i32 %82, ptr %8, align 4, !tbaa !9
  br label %66, !llvm.loop !18

83:                                               ; preds = %66
  br label %84

84:                                               ; preds = %83, %59
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  %86 = call i32 @windowf_destroy(ptr noundef %85)
  %87 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %87, ptr %3, align 8
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  br label %88

88:                                               ; preds = %84, %14
  %89 = load ptr, ptr %3, align 8
  ret ptr %89
}

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @windowf_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 }

!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 = !{!"windowf_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 = !{!16, !16, i64 0}
!16 = !{!"float", !7, i64 0}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !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 @windowf_create(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local ptr @windowf_recreate(ptr noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %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 @windowf_create(i32 noundef %1)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #2
  %9 = call i32 @windowf_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.ph33, label %24

.preheader:                                       ; preds = %.lr.ph33
  %.not36 = icmp eq i32 %14, 0
  br i1 %.not36, label %.loopexit, label %.lr.ph35

.lr.ph33:                                         ; preds = %7, %.lr.ph33
  %.032 = phi i32 [ %13, %.lr.ph33 ], [ 0, %7 ]
  %12 = call i32 @windowf_push(ptr noundef %8, float noundef 0.000000e+00)
  %13 = add nuw i32 %.032, 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.ph33, label %.preheader, !llvm.loop !11

.lr.ph35:                                         ; preds = %.preheader, %.lr.ph35
  %indvars.iv39 = phi i64 [ %indvars.iv.next40, %.lr.ph35 ], [ 0, %.preheader ]
  %17 = load ptr, ptr %3, align 8, !tbaa !13
  %18 = getelementptr inbounds float, ptr %17, i64 %indvars.iv39
  %19 = load float, ptr %18, align 4, !tbaa !14
  %20 = call i32 @windowf_push(ptr noundef %8, float noundef %19)
  %indvars.iv.next40 = add nuw nsw i64 %indvars.iv39, 1
  %21 = load i32, ptr %4, align 8, !tbaa !5
  %22 = zext i32 %21 to i64
  %23 = icmp ult i64 %indvars.iv.next40, %22
  br i1 %23, label %.lr.ph35, label %.loopexit, !llvm.loop !16

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, ptr %28, i64 %indvars.iv
  %30 = load float, ptr %29, align 4, !tbaa !14
  %31 = call i32 @windowf_push(ptr noundef %8, 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 !17

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

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @windowf_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 }

!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 = !{!"windowf_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 = !{!15, !15, i64 0}
!15 = !{!"float", !8, i64 0}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}


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