; LLVM IR from sp-nitech/SPTK :: third_party/REAPER/core/track.ll (ZN4sptk6reaper5Track8FillTimeEfi)

; 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::Track" = type { i32, i32, %"class.sptk::reaper::FloatMatrix", %"class.std::vector", i8, float }
%"class.sptk::reaper::FloatMatrix" = type { ptr, i32, i32 }
%"class.std::vector" = type { %"struct.std::_Bvector_base" }
%"struct.std::_Bvector_base" = type { %"struct.std::_Bvector_base<std::allocator<bool>>::_Bvector_impl" }
%"struct.std::_Bvector_base<std::allocator<bool>>::_Bvector_impl" = type { %"struct.std::_Bvector_base<std::allocator<bool>>::_Bvector_impl_data" }
%"struct.std::_Bvector_base<std::allocator<bool>>::_Bvector_impl_data" = type { %"struct.std::_Bit_iterator", %"struct.std::_Bit_iterator", ptr }
%"struct.std::_Bit_iterator" = type { %"struct.std::_Bit_iterator_base.base", [4 x i8] }
%"struct.std::_Bit_iterator_base.base" = type <{ ptr, 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: mustprogress uwtable
define dso_local void @_ZN4sptk6reaper5Track8FillTimeEfi(ptr noundef nonnull align 8 dereferenceable(72) %0, float noundef %1, i32 noundef %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store float %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !11
  %8 = load ptr, ptr %4, align 8
  %9 = load float, ptr %5, align 4, !tbaa !9
  %10 = getelementptr inbounds %"class.sptk::reaper::Track", ptr %8, i32 0, i32 5
  store float %9, ptr %10, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !11
  br label %11

11:                                               ; preds = %26, %3
  %12 = load i32, ptr %7, align 4, !tbaa !11
  %13 = getelementptr inbounds %"class.sptk::reaper::Track", ptr %8, i32 0, i32 0
  %14 = load i32, ptr %13, align 8, !tbaa !23
  %15 = icmp slt i32 %12, %14
  br i1 %15, label %17, label %16

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

17:                                               ; preds = %11
  %18 = getelementptr inbounds %"class.sptk::reaper::Track", ptr %8, i32 0, i32 2
  %19 = load i32, ptr %7, align 4, !tbaa !11
  %20 = load float, ptr %5, align 4, !tbaa !9
  %21 = load i32, ptr %7, align 4, !tbaa !11
  %22 = load i32, ptr %6, align 4, !tbaa !11
  %23 = add nsw i32 %21, %22
  %24 = sitofp i32 %23 to float
  %25 = fmul float %20, %24
  call void @_ZN4sptk6reaper11FloatMatrix3SetEjjf(ptr noundef nonnull align 8 dereferenceable(16) %18, i32 noundef 0, i32 noundef %19, float noundef %25)
  br label %26

26:                                               ; preds = %17
  %27 = load i32, ptr %7, align 4, !tbaa !11
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %7, align 4, !tbaa !11
  br label %11, !llvm.loop !24

29:                                               ; preds = %16
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4sptk6reaper11FloatMatrix3SetEjjf(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef, i32 noundef, float noundef) #2 align 2

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 = { inlinehint 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 = { 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 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !10, i64 68}
!14 = !{!"_ZTSN4sptk6reaper5TrackE", !12, i64 0, !12, i64 4, !15, i64 8, !16, i64 24, !22, i64 64, !10, i64 68}
!15 = !{!"_ZTSN4sptk6reaper11FloatMatrixE", !6, i64 0, !12, i64 8, !12, i64 12}
!16 = !{!"_ZTSSt6vectorIbSaIbEE", !17, i64 0}
!17 = !{!"_ZTSSt13_Bvector_baseISaIbEE", !18, i64 0}
!18 = !{!"_ZTSNSt13_Bvector_baseISaIbEE13_Bvector_implE", !19, i64 0}
!19 = !{!"_ZTSNSt13_Bvector_baseISaIbEE18_Bvector_impl_dataE", !20, i64 0, !20, i64 16, !6, i64 32}
!20 = !{!"_ZTSSt13_Bit_iterator", !21, i64 0}
!21 = !{!"_ZTSSt18_Bit_iterator_base", !6, i64 0, !12, i64 8}
!22 = !{!"bool", !7, i64 0}
!23 = !{!14, !12, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"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"

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4sptk6reaper5Track8FillTimeEfi(ptr noundef nonnull align 8 dereferenceable(72) %0, float noundef %1, i32 noundef %2) local_unnamed_addr #0 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 68
  store float %1, ptr %4, align 4, !tbaa !5
  %5 = load i32, ptr %0, align 8, !tbaa !20
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %3
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  br label %8

._crit_edge:                                      ; preds = %8, %3
  ret void

8:                                                ; preds = %.lr.ph, %8
  %.07 = phi i32 [ 0, %.lr.ph ], [ %12, %8 ]
  %9 = add nsw i32 %.07, %2
  %10 = sitofp i32 %9 to float
  %11 = fmul float %10, %1
  tail call void @_ZN4sptk6reaper11FloatMatrix3SetEjjf(ptr noundef nonnull align 8 dereferenceable(16) %7, i32 noundef 0, i32 noundef %.07, float noundef %11)
  %12 = add nuw nsw i32 %.07, 1
  %13 = load i32, ptr %0, align 8, !tbaa !20
  %14 = icmp slt i32 %12, %13
  br i1 %14, label %8, label %._crit_edge, !llvm.loop !21
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4sptk6reaper11FloatMatrix3SetEjjf(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef, i32 noundef, float noundef) local_unnamed_addr #1 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 = { inlinehint 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" }

!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, !19, i64 68}
!6 = !{!"_ZTSN4sptk6reaper5TrackE", !7, i64 0, !7, i64 4, !10, i64 8, !12, i64 24, !18, i64 64, !19, i64 68}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN4sptk6reaper11FloatMatrixE", !11, i64 0, !7, i64 8, !7, i64 12}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"_ZTSSt6vectorIbSaIbEE", !13, i64 0}
!13 = !{!"_ZTSSt13_Bvector_baseISaIbEE", !14, i64 0}
!14 = !{!"_ZTSNSt13_Bvector_baseISaIbEE13_Bvector_implE", !15, i64 0}
!15 = !{!"_ZTSNSt13_Bvector_baseISaIbEE18_Bvector_impl_dataE", !16, i64 0, !16, i64 16, !11, i64 32}
!16 = !{!"_ZTSSt13_Bit_iterator", !17, i64 0}
!17 = !{!"_ZTSSt18_Bit_iterator_base", !11, i64 0, !7, i64 8}
!18 = !{!"bool", !8, i64 0}
!19 = !{!"float", !8, i64 0}
!20 = !{!6, !7, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


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