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

; 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] }

; 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: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIfSaIfEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

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

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4sptk6reaper12EpochTracker6WindowERKSt6vectorIfSaIfEEimPf(ptr noundef nonnull align 8 dereferenceable(500) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef %2, i64 noundef %3, ptr noundef %4) #1 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca float, align 4
  %12 = alloca i64, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i64, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i64 %3, ptr %9, align 8, !tbaa !11
  store ptr %4, ptr %10, align 8, !tbaa !5
  %15 = load ptr, ptr %6, align 8
  %16 = load i64, ptr %9, align 8, !tbaa !11
  %17 = getelementptr inbounds %"class.sptk::reaper::EpochTracker", ptr %15, i32 0, i32 12
  %18 = call noundef i64 @_ZNKSt6vectorIfSaIfEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %17) #5
  %19 = icmp ne i64 %16, %18
  br i1 %19, label %20, label %49

20:                                               ; preds = %5
  %21 = getelementptr inbounds %"class.sptk::reaper::EpochTracker", ptr %15, i32 0, i32 12
  %22 = load i64, ptr %9, align 8, !tbaa !11
  call void @_ZNSt6vectorIfSaIfEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) %21, i64 noundef %22)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %23 = load i64, ptr %9, align 8, !tbaa !11
  %24 = uitofp i64 %23 to double
  %25 = fdiv double 0x401921FB54442D18, %24
  %26 = fptrunc double %25 to float
  store float %26, ptr %11, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  store i64 0, ptr %12, align 8, !tbaa !11
  br label %27

27:                                               ; preds = %45, %20
  %28 = load i64, ptr %12, align 8, !tbaa !11
  %29 = load i64, ptr %9, align 8, !tbaa !11
  %30 = icmp ult i64 %28, %29
  br i1 %30, label %32, label %31

31:                                               ; preds = %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  br label %48

32:                                               ; preds = %27
  %33 = load i64, ptr %12, align 8, !tbaa !11
  %34 = uitofp i64 %33 to double
  %35 = fadd double %34, 5.000000e-01
  %36 = load float, ptr %11, align 4, !tbaa !13
  %37 = fpext float %36 to double
  %38 = fmul double %35, %37
  %39 = call double @cos(double noundef %38) #5
  %40 = call double @llvm.fmuladd.f64(double -5.000000e-01, double %39, double 5.000000e-01)
  %41 = fptrunc double %40 to float
  %42 = getelementptr inbounds %"class.sptk::reaper::EpochTracker", ptr %15, i32 0, i32 12
  %43 = load i64, ptr %12, align 8, !tbaa !11
  %44 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %42, i64 noundef %43) #5
  store float %41, ptr %44, align 4, !tbaa !13
  br label %45

45:                                               ; preds = %32
  %46 = load i64, ptr %12, align 8, !tbaa !11
  %47 = add i64 %46, 1
  store i64 %47, ptr %12, align 8, !tbaa !11
  br label %27, !llvm.loop !15

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

49:                                               ; preds = %48, %5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIfSaIfEE5frontEv(ptr noundef nonnull align 8 dereferenceable(24) %50) #5
  %52 = load i32, ptr %8, align 4, !tbaa !9
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds float, ptr %51, i64 %53
  store ptr %54, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  store i64 0, ptr %14, align 8, !tbaa !11
  br label %55

55:                                               ; preds = %73, %49
  %56 = load i64, ptr %14, align 8, !tbaa !11
  %57 = load i64, ptr %9, align 8, !tbaa !11
  %58 = icmp ult i64 %56, %57
  br i1 %58, label %60, label %59

59:                                               ; preds = %55
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  br label %76

60:                                               ; preds = %55
  %61 = load ptr, ptr %13, align 8, !tbaa !5
  %62 = load i64, ptr %14, align 8, !tbaa !11
  %63 = getelementptr inbounds float, ptr %61, i64 %62
  %64 = load float, ptr %63, align 4, !tbaa !13
  %65 = getelementptr inbounds %"class.sptk::reaper::EpochTracker", ptr %15, i32 0, i32 12
  %66 = load i64, ptr %14, align 8, !tbaa !11
  %67 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %65, i64 noundef %66) #5
  %68 = load float, ptr %67, align 4, !tbaa !13
  %69 = fmul float %64, %68
  %70 = load ptr, ptr %10, align 8, !tbaa !5
  %71 = load i64, ptr %14, align 8, !tbaa !11
  %72 = getelementptr inbounds float, ptr %70, i64 %71
  store float %69, ptr %72, align 4, !tbaa !13
  br label %73

73:                                               ; preds = %60
  %74 = load i64, ptr %14, align 8, !tbaa !11
  %75 = add i64 %74, 1
  store i64 %75, ptr %14, align 8, !tbaa !11
  br label %55, !llvm.loop !17

76:                                               ; preds = %59
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  ret void
}

; Function Attrs: nounwind
declare double @cos(double noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


; 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 uwtable
declare dso_local void @_ZNSt6vectorIfSaIfEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIfSaIfEE5frontEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4sptk6reaper12EpochTracker6WindowERKSt6vectorIfSaIfEEimPf(ptr noundef nonnull align 8 dereferenceable(500) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef %2, i64 noundef %3, ptr nocapture noundef writeonly %4) local_unnamed_addr #0 align 2 {
  %6 = getelementptr inbounds i8, ptr %0, i64 272
  %7 = tail call noundef i64 @_ZNKSt6vectorIfSaIfEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %6) #4
  %.not = icmp eq i64 %7, %3
  br i1 %.not, label %.loopexit, label %8

8:                                                ; preds = %5
  tail call void @_ZNSt6vectorIfSaIfEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) %6, i64 noundef %3)
  %.not24 = icmp eq i64 %3, 0
  br i1 %.not24, label %.loopexit.thread, label %.lr.ph

.loopexit.thread:                                 ; preds = %8
  %9 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIfSaIfEE5frontEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #4
  br label %._crit_edge

.lr.ph:                                           ; preds = %8
  %10 = uitofp i64 %3 to double
  %11 = fdiv double 0x401921FB54442D18, %10
  %12 = fptrunc double %11 to float
  %13 = fpext float %12 to double
  br label %14

14:                                               ; preds = %.lr.ph, %14
  %.01921 = phi i64 [ 0, %.lr.ph ], [ %22, %14 ]
  %15 = uitofp i64 %.01921 to double
  %16 = fadd double %15, 5.000000e-01
  %17 = fmul double %16, %13
  %18 = tail call double @cos(double noundef %17) #4
  %19 = tail call double @llvm.fmuladd.f64(double %18, double -5.000000e-01, double 5.000000e-01)
  %20 = fptrunc double %19 to float
  %21 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %6, i64 noundef %.01921) #4
  store float %20, ptr %21, align 4, !tbaa !5
  %22 = add nuw i64 %.01921, 1
  %exitcond.not = icmp eq i64 %22, %3
  br i1 %exitcond.not, label %.loopexit.thread28, label %14, !llvm.loop !9

.loopexit.thread28:                               ; preds = %14
  %23 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIfSaIfEE5frontEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #4
  %24 = sext i32 %2 to i64
  %25 = getelementptr inbounds float, ptr %23, i64 %24
  br label %.lr.ph23.preheader

.loopexit:                                        ; preds = %5
  %26 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIfSaIfEE5frontEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #4
  %27 = sext i32 %2 to i64
  %28 = getelementptr inbounds float, ptr %26, i64 %27
  %.not25 = icmp eq i64 %3, 0
  br i1 %.not25, label %._crit_edge, label %.lr.ph23.preheader

.lr.ph23.preheader:                               ; preds = %.loopexit.thread28, %.loopexit
  %29 = phi ptr [ %25, %.loopexit.thread28 ], [ %28, %.loopexit ]
  br label %.lr.ph23

._crit_edge:                                      ; preds = %.lr.ph23, %.loopexit.thread, %.loopexit
  ret void

.lr.ph23:                                         ; preds = %.lr.ph23.preheader, %.lr.ph23
  %.022 = phi i64 [ %36, %.lr.ph23 ], [ 0, %.lr.ph23.preheader ]
  %30 = getelementptr inbounds float, ptr %29, i64 %.022
  %31 = load float, ptr %30, align 4, !tbaa !5
  %32 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %6, i64 noundef %.022) #4
  %33 = load float, ptr %32, align 4, !tbaa !5
  %34 = fmul float %31, %33
  %35 = getelementptr inbounds float, ptr %4, i64 %.022
  store float %34, ptr %35, align 4, !tbaa !5
  %36 = add nuw i64 %.022, 1
  %exitcond26.not = icmp eq i64 %36, %3
  br i1 %exitcond26.not, label %._crit_edge, label %.lr.ph23, !llvm.loop !11
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @cos(double noundef) local_unnamed_addr #3

attributes #0 = { mustprogress 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 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { mustprogress nofree nounwind willreturn memory(write) "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 #4 = { 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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