; LLVM IR from chriskiefer/libcccrt :: benchmarks/maximilian.ll (ZN10maxiSample15playOnceAtSpeedEd)

; 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.maxiSample = type { double, double, double, double, %class.maxiLagExp, i16, i32, i16, [6 x i8], %class.maxiTrigger, %"class.std::vector", %"class.std::__cxx11::basic_string", i32, i32, i32, i16, i32, i16, i8, double }
%class.maxiLagExp = type { double, double, double }
%class.maxiTrigger = type <{ double, i8, [7 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_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] }

@chandiv = external dso_local global float, align 4
@_ZN12maxiSettings10sampleRateE = external dso_local global i64, align 8

; 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZN10maxiSample15playOnceAtSpeedEd(ptr noundef nonnull align 8 dereferenceable(176) %0, double noundef %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store double %1, ptr %4, align 8, !tbaa !9
  %6 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %7 = getelementptr inbounds %class.maxiSample, ptr %6, i32 0, i32 0
  %8 = load double, ptr %7, align 8, !tbaa !11
  %9 = getelementptr inbounds %class.maxiSample, ptr %6, i32 0, i32 0
  %10 = load double, ptr %9, align 8, !tbaa !11
  %11 = fptosi double %10 to i64
  %12 = sitofp i64 %11 to double
  %13 = fsub double %8, %12
  store double %13, ptr %5, align 8, !tbaa !9
  %14 = getelementptr inbounds %class.maxiSample, ptr %6, i32 0, i32 0
  %15 = load double, ptr %14, align 8, !tbaa !11
  %16 = fptosi double %15 to i64
  %17 = add nsw i64 %16, 1
  %18 = getelementptr inbounds %class.maxiSample, ptr %6, i32 0, i32 10
  %19 = call noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %18) #3
  %20 = icmp ult i64 %17, %19
  br i1 %20, label %21, label %41

21:                                               ; preds = %2
  %22 = load double, ptr %5, align 8, !tbaa !9
  %23 = fsub double 1.000000e+00, %22
  %24 = getelementptr inbounds %class.maxiSample, ptr %6, i32 0, i32 10
  %25 = getelementptr inbounds %class.maxiSample, ptr %6, i32 0, i32 0
  %26 = load double, ptr %25, align 8, !tbaa !11
  %27 = fptosi double %26 to i64
  %28 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %24, i64 noundef %27) #3
  %29 = load double, ptr %28, align 8, !tbaa !9
  %30 = load double, ptr %5, align 8, !tbaa !9
  %31 = getelementptr inbounds %class.maxiSample, ptr %6, i32 0, i32 10
  %32 = getelementptr inbounds %class.maxiSample, ptr %6, i32 0, i32 0
  %33 = load double, ptr %32, align 8, !tbaa !11
  %34 = fptosi double %33 to i64
  %35 = add nsw i64 1, %34
  %36 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %31, i64 noundef %35) #3
  %37 = load double, ptr %36, align 8, !tbaa !9
  %38 = fmul double %30, %37
  %39 = call double @llvm.fmuladd.f64(double %23, double %29, double %38)
  %40 = getelementptr inbounds %class.maxiSample, ptr %6, i32 0, i32 3
  store double %39, ptr %40, align 8, !tbaa !25
  br label %43

41:                                               ; preds = %2
  %42 = getelementptr inbounds %class.maxiSample, ptr %6, i32 0, i32 3
  store double 0.000000e+00, ptr %42, align 8, !tbaa !25
  br label %43

43:                                               ; preds = %41, %21
  %44 = getelementptr inbounds %class.maxiSample, ptr %6, i32 0, i32 0
  %45 = load double, ptr %44, align 8, !tbaa !11
  %46 = load double, ptr %4, align 8, !tbaa !9
  %47 = load float, ptr @chandiv, align 4, !tbaa !26
  %48 = fpext float %47 to double
  %49 = fmul double %46, %48
  %50 = load i64, ptr @_ZN12maxiSettings10sampleRateE, align 8, !tbaa !28
  %51 = getelementptr inbounds %class.maxiSample, ptr %6, i32 0, i32 6
  %52 = load i32, ptr %51, align 4, !tbaa !29
  %53 = sext i32 %52 to i64
  %54 = udiv i64 %50, %53
  %55 = uitofp i64 %54 to double
  %56 = fdiv double %49, %55
  %57 = fadd double %45, %56
  %58 = getelementptr inbounds %class.maxiSample, ptr %6, i32 0, i32 0
  store double %57, ptr %58, align 8, !tbaa !11
  %59 = getelementptr inbounds %class.maxiSample, ptr %6, i32 0, i32 3
  %60 = load double, ptr %59, align 8, !tbaa !25
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret double %60
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { 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 = !{!"double", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTS10maxiSample", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !13, i64 32, !14, i64 56, !15, i64 60, !14, i64 64, !16, i64 72, !18, i64 88, !22, i64 112, !15, i64 144, !15, i64 148, !15, i64 152, !14, i64 156, !15, i64 160, !14, i64 164, !17, i64 166, !10, i64 168}
!13 = !{!"_ZTS10maxiLagExpIdE", !10, i64 0, !10, i64 8, !10, i64 16}
!14 = !{!"short", !7, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!"_ZTS11maxiTrigger", !10, i64 0, !17, i64 8}
!17 = !{!"bool", !7, i64 0}
!18 = !{!"_ZTSSt6vectorIdSaIdEE", !19, i64 0}
!19 = !{!"_ZTSSt12_Vector_baseIdSaIdEE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE12_Vector_implE", !21, i64 0}
!21 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!22 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !23, i64 0, !24, i64 8, !7, i64 16}
!23 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!24 = !{!"long", !7, i64 0}
!25 = !{!12, !10, i64 24}
!26 = !{!27, !27, i64 0}
!27 = !{!"float", !7, i64 0}
!28 = !{!24, !24, i64 0}
!29 = !{!12, !15, i64 60}


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

@chandiv = external dso_local local_unnamed_addr global float, align 4
@_ZN12maxiSettings10sampleRateE = external dso_local local_unnamed_addr global i64, align 8

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(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 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZN10maxiSample15playOnceAtSpeedEd(ptr noundef nonnull align 8 dereferenceable(176) %0, double noundef %1) local_unnamed_addr #1 align 2 {
  %3 = load double, ptr %0, align 8, !tbaa !5
  %4 = fptosi double %3 to i64
  %5 = add nsw i64 %4, 1
  %6 = getelementptr inbounds i8, ptr %0, i64 88
  %7 = tail call noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %6) #2
  %8 = icmp ult i64 %5, %7
  br i1 %8, label %9, label %24

9:                                                ; preds = %2
  %10 = sitofp i64 %4 to double
  %11 = fsub double %3, %10
  %12 = fsub double 1.000000e+00, %11
  %13 = load double, ptr %0, align 8, !tbaa !5
  %14 = fptosi double %13 to i64
  %15 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %6, i64 noundef %14) #2
  %16 = load double, ptr %15, align 8, !tbaa !23
  %17 = load double, ptr %0, align 8, !tbaa !5
  %18 = fptosi double %17 to i64
  %19 = add nsw i64 %18, 1
  %20 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %6, i64 noundef %19) #2
  %21 = load double, ptr %20, align 8, !tbaa !23
  %22 = fmul double %11, %21
  %23 = tail call double @llvm.fmuladd.f64(double %12, double %16, double %22)
  br label %24

24:                                               ; preds = %2, %9
  %.sink = phi double [ %23, %9 ], [ 0.000000e+00, %2 ]
  %25 = getelementptr inbounds i8, ptr %0, i64 24
  store double %.sink, ptr %25, align 8
  %26 = load double, ptr %0, align 8, !tbaa !5
  %27 = load float, ptr @chandiv, align 4, !tbaa !24
  %28 = fpext float %27 to double
  %29 = fmul double %28, %1
  %30 = load i64, ptr @_ZN12maxiSettings10sampleRateE, align 8, !tbaa !26
  %31 = getelementptr inbounds i8, ptr %0, i64 60
  %32 = load i32, ptr %31, align 4, !tbaa !27
  %33 = sext i32 %32 to i64
  %34 = udiv i64 %30, %33
  %35 = uitofp i64 %34 to double
  %36 = fdiv double %29, %35
  %37 = fadd double %26, %36
  store double %37, ptr %0, align 8, !tbaa !5
  ret double %.sink
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { 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, !7, i64 0}
!6 = !{!"_ZTS10maxiSample", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !11, i64 56, !12, i64 60, !11, i64 64, !13, i64 72, !15, i64 88, !20, i64 112, !12, i64 144, !12, i64 148, !12, i64 152, !11, i64 156, !12, i64 160, !11, i64 164, !14, i64 166, !7, i64 168}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTS10maxiLagExpIdE", !7, i64 0, !7, i64 8, !7, i64 16}
!11 = !{!"short", !8, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!"_ZTS11maxiTrigger", !7, i64 0, !14, i64 8}
!14 = !{!"bool", !8, i64 0}
!15 = !{!"_ZTSSt6vectorIdSaIdEE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseIdSaIdEE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE12_Vector_implE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE17_Vector_impl_dataE", !19, i64 0, !19, i64 8, !19, i64 16}
!19 = !{!"any pointer", !8, i64 0}
!20 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !21, i64 0, !22, i64 8, !8, i64 16}
!21 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !19, i64 0}
!22 = !{!"long", !8, i64 0}
!23 = !{!7, !7, i64 0}
!24 = !{!25, !25, i64 0}
!25 = !{!"float", !8, i64 0}
!26 = !{!22, !22, i64 0}
!27 = !{!6, !12, i64 60}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,MergedLoadStoreMotionPass,ReassociatePass,SROAPass,TailCallElimPass