; LLVM IR from sp-nitech/SPTK :: third_party/REAPER/epoch_tracker/epoch_tracker.ll (ZN4sptk6reaper12EpochTracker7CleanUpEv)

; 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.sptk::reaper::EpochTracker" = type <{ ptr, %"class.std::vector", %"class.std::vector.0", %"class.std::vector.5", %"class.std::vector.5", %"class.std::vector.5", %"class.std::vector.5", %"class.std::vector.5", %"class.std::vector.5", %"class.std::vector.5", %"class.std::vector.5", %"class.std::vector.5", %"class.std::vector.5", float, float, float, i32, i32, i32, %"class.std::__cxx11::basic_string", float, float, float, float, i8, i8, [2 x i8], float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, [4 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<sptk::reaper::EpochTracker::ResidPeak, std::allocator<sptk::reaper::EpochTracker::ResidPeak>>::_Vector_impl" }
%"struct.std::_Vector_base<sptk::reaper::EpochTracker::ResidPeak, std::allocator<sptk::reaper::EpochTracker::ResidPeak>>::_Vector_impl" = type { %"struct.std::_Vector_base<sptk::reaper::EpochTracker::ResidPeak, std::allocator<sptk::reaper::EpochTracker::ResidPeak>>::_Vector_impl_data" }
%"struct.std::_Vector_base<sptk::reaper::EpochTracker::ResidPeak, std::allocator<sptk::reaper::EpochTracker::ResidPeak>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<sptk::reaper::EpochTracker::TrackerResults, std::allocator<sptk::reaper::EpochTracker::TrackerResults>>::_Vector_impl" }
%"struct.std::_Vector_base<sptk::reaper::EpochTracker::TrackerResults, std::allocator<sptk::reaper::EpochTracker::TrackerResults>>::_Vector_impl" = type { %"struct.std::_Vector_base<sptk::reaper::EpochTracker::TrackerResults, std::allocator<sptk::reaper::EpochTracker::TrackerResults>>::_Vector_impl_data" }
%"struct.std::_Vector_base<sptk::reaper::EpochTracker::TrackerResults, std::allocator<sptk::reaper::EpochTracker::TrackerResults>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.5" = type { %"struct.std::_Vector_base.6" }
%"struct.std::_Vector_base.6" = type { %"struct.std::_Vector_base<float, std::allocator<float>>::_Vector_impl" }
%"struct.std::_Vector_base<float, std::allocator<float>>::_Vector_impl" = type { %"struct.std::_Vector_base<float, std::allocator<float>>::_Vector_impl_data" }
%"struct.std::_Vector_base<float, std::allocator<float>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"struct.sptk::reaper::EpochTracker::ResidPeak" = type { i32, i32, float, %"class.std::vector.5", %"class.std::vector.13", %"class.std::vector.18", %"class.std::vector.18" }
%"class.std::vector.13" = type { %"struct.std::_Vector_base.14" }
%"struct.std::_Vector_base.14" = type { %"struct.std::_Vector_base<short, std::allocator<short>>::_Vector_impl" }
%"struct.std::_Vector_base<short, std::allocator<short>>::_Vector_impl" = type { %"struct.std::_Vector_base<short, std::allocator<short>>::_Vector_impl_data" }
%"struct.std::_Vector_base<short, std::allocator<short>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.18" = type { %"struct.std::_Vector_base.19" }
%"struct.std::_Vector_base.19" = type { %"struct.std::_Vector_base<sptk::reaper::EpochTracker::EpochCand *, std::allocator<sptk::reaper::EpochTracker::EpochCand *>>::_Vector_impl" }
%"struct.std::_Vector_base<sptk::reaper::EpochTracker::EpochCand *, std::allocator<sptk::reaper::EpochTracker::EpochCand *>>::_Vector_impl" = type { %"struct.std::_Vector_base<sptk::reaper::EpochTracker::EpochCand *, std::allocator<sptk::reaper::EpochTracker::EpochCand *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<sptk::reaper::EpochTracker::EpochCand *, std::allocator<sptk::reaper::EpochTracker::EpochCand *>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4sptk6reaper12EpochTracker7CleanUpEv(ptr noundef nonnull align 8 dereferenceable(500) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  store i64 0, ptr %3, align 8, !tbaa !9
  br label %7

7:                                                ; preds = %38, %1
  %8 = load i64, ptr %3, align 8, !tbaa !9
  %9 = getelementptr inbounds %"class.sptk::reaper::EpochTracker", ptr %6, i32 0, i32 1
  %10 = call noundef i64 @_ZNKSt6vectorIN4sptk6reaper12EpochTracker9ResidPeakESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %9) #3
  %11 = icmp ult i64 %8, %10
  br i1 %11, label %13, label %12

12:                                               ; preds = %7
  store i32 2, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  br label %41

13:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store i64 0, ptr %5, align 8, !tbaa !9
  br label %14

14:                                               ; preds = %34, %13
  %15 = load i64, ptr %5, align 8, !tbaa !9
  %16 = getelementptr inbounds %"class.sptk::reaper::EpochTracker", ptr %6, i32 0, i32 1
  %17 = load i64, ptr %3, align 8, !tbaa !9
  %18 = call noundef nonnull align 8 dereferenceable(112) ptr @_ZNSt6vectorIN4sptk6reaper12EpochTracker9ResidPeakESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %16, i64 noundef %17) #3
  %19 = getelementptr inbounds %"struct.sptk::reaper::EpochTracker::ResidPeak", ptr %18, i32 0, i32 5
  %20 = call noundef i64 @_ZNKSt6vectorIPN4sptk6reaper12EpochTracker9EpochCandESaIS4_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %19) #3
  %21 = icmp ult i64 %15, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %14
  store i32 5, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  br label %37

23:                                               ; preds = %14
  %24 = getelementptr inbounds %"class.sptk::reaper::EpochTracker", ptr %6, i32 0, i32 1
  %25 = load i64, ptr %3, align 8, !tbaa !9
  %26 = call noundef nonnull align 8 dereferenceable(112) ptr @_ZNSt6vectorIN4sptk6reaper12EpochTracker9ResidPeakESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %24, i64 noundef %25) #3
  %27 = getelementptr inbounds %"struct.sptk::reaper::EpochTracker::ResidPeak", ptr %26, i32 0, i32 5
  %28 = load i64, ptr %5, align 8, !tbaa !9
  %29 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN4sptk6reaper12EpochTracker9EpochCandESaIS4_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %27, i64 noundef %28) #3
  %30 = load ptr, ptr %29, align 8, !tbaa !5
  %31 = icmp eq ptr %30, null
  br i1 %31, label %33, label %32

32:                                               ; preds = %23
  call void @_ZdlPvm(ptr noundef %30, i64 noundef 32) #4
  br label %33

33:                                               ; preds = %32, %23
  br label %34

34:                                               ; preds = %33
  %35 = load i64, ptr %5, align 8, !tbaa !9
  %36 = add i64 %35, 1
  store i64 %36, ptr %5, align 8, !tbaa !9
  br label %14, !llvm.loop !11

37:                                               ; preds = %22
  br label %38

38:                                               ; preds = %37
  %39 = load i64, ptr %3, align 8, !tbaa !9
  %40 = add i64 %39, 1
  store i64 %40, ptr %3, align 8, !tbaa !9
  br label %7, !llvm.loop !13

41:                                               ; preds = %12
  %42 = getelementptr inbounds %"class.sptk::reaper::EpochTracker", ptr %6, i32 0, i32 1
  call void @_ZNSt6vectorIN4sptk6reaper12EpochTracker9ResidPeakESaIS3_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %42) #3
  %43 = getelementptr inbounds %"class.sptk::reaper::EpochTracker", ptr %6, i32 0, i32 2
  call void @_ZNSt6vectorIN4sptk6reaper12EpochTracker14TrackerResultsESaIS3_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %43) #3
  %44 = getelementptr inbounds %"class.sptk::reaper::EpochTracker", ptr %6, i32 0, i32 11
  call void @_ZNSt6vectorIfSaIfEE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %44) #3
  ret void
}

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #1

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIPN4sptk6reaper12EpochTracker9EpochCandESaIS4_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 @_ZNSt6vectorIPN4sptk6reaper12EpochTracker9EpochCandESaIS4_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #0 align 2

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIfSaIfEE5clearEv(ptr noundef nonnull align 8 dereferenceable(24)) #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 = { nobuiltin 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nounwind }
attributes #4 = { builtin 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 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; 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 nounwind uwtable
define dso_local void @_ZN4sptk6reaper12EpochTracker7CleanUpEv(ptr noundef nonnull align 8 dereferenceable(500) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = tail call noundef i64 @_ZNKSt6vectorIN4sptk6reaper12EpochTracker9ResidPeakESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #2
  %.not = icmp eq i64 %3, 0
  br i1 %.not, label %._crit_edge11, label %.preheader

.preheader:                                       ; preds = %1, %._crit_edge
  %.0710 = phi i64 [ %9, %._crit_edge ], [ 0, %1 ]
  %4 = tail call noundef nonnull align 8 dereferenceable(112) ptr @_ZNSt6vectorIN4sptk6reaper12EpochTracker9ResidPeakESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %.0710) #2
  %5 = getelementptr inbounds i8, ptr %4, i64 64
  %6 = tail call noundef i64 @_ZNKSt6vectorIPN4sptk6reaper12EpochTracker9EpochCandESaIS4_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %5) #2
  %.not12 = icmp eq i64 %6, 0
  br i1 %.not12, label %._crit_edge, label %.lr.ph

._crit_edge11:                                    ; preds = %._crit_edge, %1
  tail call void @_ZNSt6vectorIN4sptk6reaper12EpochTracker9ResidPeakESaIS3_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #2
  %7 = getelementptr inbounds i8, ptr %0, i64 32
  tail call void @_ZNSt6vectorIN4sptk6reaper12EpochTracker14TrackerResultsESaIS3_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %7) #2
  %8 = getelementptr inbounds i8, ptr %0, i64 248
  tail call void @_ZNSt6vectorIfSaIfEE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %8) #2
  ret void

._crit_edge:                                      ; preds = %18, %.preheader
  %9 = add nuw i64 %.0710, 1
  %10 = tail call noundef i64 @_ZNKSt6vectorIN4sptk6reaper12EpochTracker9ResidPeakESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #2
  %11 = icmp ult i64 %9, %10
  br i1 %11, label %.preheader, label %._crit_edge11, !llvm.loop !5

.lr.ph:                                           ; preds = %.preheader, %18
  %.09 = phi i64 [ %19, %18 ], [ 0, %.preheader ]
  %12 = tail call noundef nonnull align 8 dereferenceable(112) ptr @_ZNSt6vectorIN4sptk6reaper12EpochTracker9ResidPeakESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %.0710) #2
  %13 = getelementptr inbounds i8, ptr %12, i64 64
  %14 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN4sptk6reaper12EpochTracker9EpochCandESaIS4_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %13, i64 noundef %.09) #2
  %15 = load ptr, ptr %14, align 8, !tbaa !7
  %16 = icmp eq ptr %15, null
  br i1 %16, label %18, label %17

17:                                               ; preds = %.lr.ph
  tail call void @_ZdlPvm(ptr noundef nonnull %15, i64 noundef 32) #3
  br label %18

18:                                               ; preds = %.lr.ph, %17
  %19 = add nuw i64 %.09, 1
  %20 = tail call noundef nonnull align 8 dereferenceable(112) ptr @_ZNSt6vectorIN4sptk6reaper12EpochTracker9ResidPeakESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %.0710) #2
  %21 = getelementptr inbounds i8, ptr %20, i64 64
  %22 = tail call noundef i64 @_ZNKSt6vectorIPN4sptk6reaper12EpochTracker9EpochCandESaIS4_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %21) #2
  %23 = icmp ult i64 %19, %22
  br i1 %23, label %.lr.ph, label %._crit_edge, !llvm.loop !11
}

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIN4sptk6reaper12EpochTracker9ResidPeakESaIS3_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(112) ptr @_ZNSt6vectorIN4sptk6reaper12EpochTracker9ResidPeakESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIPN4sptk6reaper12EpochTracker9EpochCandESaIS4_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 @_ZNSt6vectorIPN4sptk6reaper12EpochTracker9EpochCandESaIS4_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 @_ZNSt6vectorIN4sptk6reaper12EpochTracker9ResidPeakESaIS3_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIfSaIfEE5clearEv(ptr noundef nonnull align 8 dereferenceable(24)) local_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 = { nobuiltin 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 #2 = { nounwind }
attributes #3 = { builtin 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = distinct !{!11, !6}


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