; LLVM IR from BabitMF/bmf :: bmf_lite/src/media/video_buffer/video_buffer_pool.ll (ZN8bmf_lite15VideoBufferPoolD2Ev)

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

%"class.bmf_lite::VideoBufferPool" = type { %"class.bmf_lite::Pool", i32, i32, %"class.bmf_lite::HardwareDataInfo", i32, %"class.std::vector", %"class.std::vector.3", %"class.std::shared_ptr.0", %"class.std::shared_ptr" }
%"class.bmf_lite::Pool" = type { ptr }
%"class.bmf_lite::HardwareDataInfo" = type { i32, i32, i32, i32, i32 }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<bmf_lite::VideoBuffer *, std::allocator<bmf_lite::VideoBuffer *>>::_Vector_impl" }
%"struct.std::_Vector_base<bmf_lite::VideoBuffer *, std::allocator<bmf_lite::VideoBuffer *>>::_Vector_impl" = type { %"struct.std::_Vector_base<bmf_lite::VideoBuffer *, std::allocator<bmf_lite::VideoBuffer *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<bmf_lite::VideoBuffer *, std::allocator<bmf_lite::VideoBuffer *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.3" = type { %"struct.std::_Vector_base.4" }
%"struct.std::_Vector_base.4" = type { %"struct.std::_Vector_base<std::shared_ptr<bmf_lite::VideoBuffer>, std::allocator<std::shared_ptr<bmf_lite::VideoBuffer>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::shared_ptr<bmf_lite::VideoBuffer>, std::allocator<std::shared_ptr<bmf_lite::VideoBuffer>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::shared_ptr<bmf_lite::VideoBuffer>, std::allocator<std::shared_ptr<bmf_lite::VideoBuffer>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::shared_ptr<bmf_lite::VideoBuffer>, std::allocator<std::shared_ptr<bmf_lite::VideoBuffer>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::shared_ptr.0" = type { %"class.std::__shared_ptr.1" }
%"class.std::__shared_ptr.1" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }
%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }

@_ZTVN8bmf_lite15VideoBufferPoolE = external dso_local unnamed_addr constant { [5 x ptr] }, align 8

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN8bmf_lite15VideoBufferPoolD2Ev(ptr noundef nonnull align 8 dereferenceable(120) %0) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  store ptr getelementptr inbounds inrange(-16, 24) ({ [5 x ptr] }, ptr @_ZTVN8bmf_lite15VideoBufferPoolE, i32 0, i32 0, i32 2), ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 0, ptr %3, align 4, !tbaa !11
  br label %5

5:                                                ; preds = %19, %1
  %6 = load i32, ptr %3, align 4, !tbaa !11
  %7 = sext i32 %6 to i64
  %8 = getelementptr inbounds %"class.bmf_lite::VideoBufferPool", ptr %4, i32 0, i32 5
  %9 = call noundef i64 @_ZNKSt6vectorIPN8bmf_lite11VideoBufferESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %8) #3
  %10 = icmp ult i64 %7, %9
  br i1 %10, label %12, label %11

11:                                               ; preds = %5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %22

12:                                               ; preds = %5
  %13 = getelementptr inbounds %"class.bmf_lite::VideoBufferPool", ptr %4, i32 0, i32 5
  %14 = load i32, ptr %3, align 4, !tbaa !11
  %15 = sext i32 %14 to i64
  %16 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN8bmf_lite11VideoBufferESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %13, i64 noundef %15) #3
  %17 = load ptr, ptr %16, align 8, !tbaa !5
  invoke void @_ZN8bmf_lite11VideoBuffer7setPoolEPNS_4PoolE(ptr noundef nonnull align 8 dereferenceable(76) %17, ptr noundef null)
          to label %18 unwind label %27

18:                                               ; preds = %12
  br label %19

19:                                               ; preds = %18
  %20 = load i32, ptr %3, align 4, !tbaa !11
  %21 = add nsw i32 %20, 1
  store i32 %21, ptr %3, align 4, !tbaa !11
  br label %5, !llvm.loop !13

22:                                               ; preds = %11
  %23 = getelementptr inbounds %"class.bmf_lite::VideoBufferPool", ptr %4, i32 0, i32 8
  call void @_ZNSt12__shared_ptrIN8bmf_lite20VideoBufferAllocatorELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %23) #3
  %24 = getelementptr inbounds %"class.bmf_lite::VideoBufferPool", ptr %4, i32 0, i32 7
  call void @_ZNSt12__shared_ptrIN8bmf_lite15HWDeviceContextELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %24) #3
  %25 = getelementptr inbounds %"class.bmf_lite::VideoBufferPool", ptr %4, i32 0, i32 6
  call void @_ZNSt6vectorISt10shared_ptrIN8bmf_lite11VideoBufferEESaIS3_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %25) #3
  %26 = getelementptr inbounds %"class.bmf_lite::VideoBufferPool", ptr %4, i32 0, i32 5
  call void @_ZNSt6vectorIPN8bmf_lite11VideoBufferESaIS2_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %26) #3
  call void @_ZN8bmf_lite4PoolD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #3
  ret void

27:                                               ; preds = %12
  %28 = landingpad { ptr, i32 }
          catch ptr null
  %29 = extractvalue { ptr, i32 } %28, 0
  call void @__clang_call_terminate(ptr %29) #4
  unreachable
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIPN8bmf_lite11VideoBufferESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN8bmf_lite11VideoBufferESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN8bmf_lite11VideoBuffer7setPoolEPNS_4PoolE(ptr noundef nonnull align 8 dereferenceable(76), ptr noundef) #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) #2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt12__shared_ptrIN8bmf_lite20VideoBufferAllocatorELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt12__shared_ptrIN8bmf_lite15HWDeviceContextELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorISt10shared_ptrIN8bmf_lite11VideoBufferEESaIS3_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIPN8bmf_lite11VideoBufferESaIS2_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN8bmf_lite4PoolD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #0 align 2

attributes #0 = { mustprogress 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { noinline noreturn nounwind uwtable "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 }
attributes #4 = { noreturn 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !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"

@_ZTVN8bmf_lite15VideoBufferPoolE = external dso_local unnamed_addr constant { [5 x ptr] }, align 8

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN8bmf_lite15VideoBufferPoolD2Ev(ptr noundef nonnull align 8 dereferenceable(120) %0) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  store ptr getelementptr inbounds inrange(-16, 24) (i8, ptr @_ZTVN8bmf_lite15VideoBufferPoolE, i64 16), ptr %0, align 8, !tbaa !5
  %2 = getelementptr inbounds i8, ptr %0, i64 40
  %3 = tail call noundef i64 @_ZNKSt6vectorIPN8bmf_lite11VideoBufferESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #1
  %.not = icmp eq i64 %3, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %1
  %4 = getelementptr inbounds i8, ptr %0, i64 104
  tail call void @_ZNSt12__shared_ptrIN8bmf_lite20VideoBufferAllocatorELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %4) #1
  %5 = getelementptr inbounds i8, ptr %0, i64 88
  tail call void @_ZNSt12__shared_ptrIN8bmf_lite15HWDeviceContextELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %5) #1
  %6 = getelementptr inbounds i8, ptr %0, i64 64
  tail call void @_ZNSt6vectorISt10shared_ptrIN8bmf_lite11VideoBufferEESaIS3_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %6) #1
  tail call void @_ZNSt6vectorIPN8bmf_lite11VideoBufferESaIS2_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %2) #1
  tail call void @_ZN8bmf_lite4PoolD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0) #1
  ret void

.lr.ph:                                           ; preds = %1, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %1 ]
  %7 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN8bmf_lite11VideoBufferESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %indvars.iv) #1
  %8 = load ptr, ptr %7, align 8, !tbaa !8
  tail call void @_ZN8bmf_lite11VideoBuffer7setPoolEPNS_4PoolE(ptr noundef nonnull align 8 dereferenceable(76) %8, ptr noundef null)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %9 = tail call noundef i64 @_ZNKSt6vectorIPN8bmf_lite11VideoBufferESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #1
  %10 = icmp ugt i64 %9, %indvars.iv.next
  br i1 %10, label %.lr.ph, label %._crit_edge, !llvm.loop !11
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIPN8bmf_lite11VideoBufferESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN8bmf_lite11VideoBufferESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN8bmf_lite11VideoBuffer7setPoolEPNS_4PoolE(ptr noundef nonnull align 8 dereferenceable(76), ptr noundef) local_unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt12__shared_ptrIN8bmf_lite20VideoBufferAllocatorELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt12__shared_ptrIN8bmf_lite15HWDeviceContextELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorISt10shared_ptrIN8bmf_lite11VideoBufferEESaIS3_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIPN8bmf_lite11VideoBufferESaIS2_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN8bmf_lite4PoolD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #0 align 2

attributes #0 = { mustprogress 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 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass