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

; 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 @_ZN10maxiSample16playUntilAtSpeedEdd(ptr noundef nonnull align 8 dereferenceable(176) %0, double noundef %1, double noundef %2) #2 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store double %1, ptr %5, align 8, !tbaa !9
  store double %2, ptr %6, align 8, !tbaa !9
  %8 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %9 = getelementptr inbounds %class.maxiSample, ptr %8, i32 0, i32 0
  %10 = load double, ptr %9, align 8, !tbaa !11
  %11 = getelementptr inbounds %class.maxiSample, ptr %8, i32 0, i32 0
  %12 = load double, ptr %11, align 8, !tbaa !11
  %13 = fptosi double %12 to i64
  %14 = sitofp i64 %13 to double
  %15 = fsub double %10, %14
  store double %15, ptr %7, align 8, !tbaa !9
  %16 = load double, ptr %5, align 8, !tbaa !9
  %17 = fcmp ogt double %16, 1.000000e+00
  br i1 %17, label %18, label %19

18:                                               ; preds = %3
  store double 1.000000e+00, ptr %5, align 8, !tbaa !9
  br label %19

19:                                               ; preds = %18, %3
  %20 = getelementptr inbounds %class.maxiSample, ptr %8, i32 0, i32 0
  %21 = load double, ptr %20, align 8, !tbaa !11
  %22 = fptosi double %21 to i64
  %23 = sitofp i64 %22 to double
  %24 = getelementptr inbounds %class.maxiSample, ptr %8, i32 0, i32 10
  %25 = call noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %24) #3
  %26 = uitofp i64 %25 to double
  %27 = load double, ptr %5, align 8, !tbaa !9
  %28 = fmul double %26, %27
  %29 = fcmp olt double %23, %28
  br i1 %29, label %30, label %51

30:                                               ; preds = %19
  %31 = load double, ptr %7, align 8, !tbaa !9
  %32 = fsub double 1.000000e+00, %31
  %33 = getelementptr inbounds %class.maxiSample, ptr %8, i32 0, i32 10
  %34 = getelementptr inbounds %class.maxiSample, ptr %8, i32 0, i32 0
  %35 = load double, ptr %34, align 8, !tbaa !11
  %36 = fptosi double %35 to i64
  %37 = add nsw i64 1, %36
  %38 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %33, i64 noundef %37) #3
  %39 = load double, ptr %38, align 8, !tbaa !9
  %40 = load double, ptr %7, align 8, !tbaa !9
  %41 = getelementptr inbounds %class.maxiSample, ptr %8, i32 0, i32 10
  %42 = getelementptr inbounds %class.maxiSample, ptr %8, i32 0, i32 0
  %43 = load double, ptr %42, align 8, !tbaa !11
  %44 = fptosi double %43 to i64
  %45 = add nsw i64 2, %44
  %46 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %41, i64 noundef %45) #3
  %47 = load double, ptr %46, align 8, !tbaa !9
  %48 = fmul double %40, %47
  %49 = call double @llvm.fmuladd.f64(double %32, double %39, double %48)
  %50 = getelementptr inbounds %class.maxiSample, ptr %8, i32 0, i32 3
  store double %49, ptr %50, align 8, !tbaa !25
  br label %53

51:                                               ; preds = %19
  %52 = getelementptr inbounds %class.maxiSample, ptr %8, i32 0, i32 3
  store double 0.000000e+00, ptr %52, align 8, !tbaa !25
  br label %53

53:                                               ; preds = %51, %30
  %54 = getelementptr inbounds %class.maxiSample, ptr %8, i32 0, i32 0
  %55 = load double, ptr %54, align 8, !tbaa !11
  %56 = load double, ptr %6, align 8, !tbaa !9
  %57 = load float, ptr @chandiv, align 4, !tbaa !26
  %58 = fpext float %57 to double
  %59 = fmul double %56, %58
  %60 = load i64, ptr @_ZN12maxiSettings10sampleRateE, align 8, !tbaa !28
  %61 = getelementptr inbounds %class.maxiSample, ptr %8, i32 0, i32 6
  %62 = load i32, ptr %61, align 4, !tbaa !29
  %63 = sext i32 %62 to i64
  %64 = udiv i64 %60, %63
  %65 = uitofp i64 %64 to double
  %66 = fdiv double %59, %65
  %67 = fadd double %55, %66
  %68 = getelementptr inbounds %class.maxiSample, ptr %8, i32 0, i32 0
  store double %67, ptr %68, align 8, !tbaa !11
  %69 = getelementptr inbounds %class.maxiSample, ptr %8, i32 0, i32 3
  %70 = load double, ptr %69, align 8, !tbaa !25
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret double %70
}

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 @_ZN10maxiSample16playUntilAtSpeedEdd(ptr noundef nonnull align 8 dereferenceable(176) %0, double noundef %1, double noundef %2) local_unnamed_addr #1 align 2 {
  %4 = load double, ptr %0, align 8, !tbaa !5
  %5 = fptosi double %4 to i64
  %6 = sitofp i64 %5 to double
  %7 = fcmp ogt double %1, 1.000000e+00
  %.0 = select i1 %7, double 1.000000e+00, double %1
  %8 = getelementptr inbounds i8, ptr %0, i64 88
  %9 = tail call noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %8) #2
  %10 = uitofp i64 %9 to double
  %11 = fmul double %.0, %10
  %12 = fcmp ogt double %11, %6
  br i1 %12, label %13, label %28

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

28:                                               ; preds = %3, %13
  %.sink = phi double [ %27, %13 ], [ 0.000000e+00, %3 ]
  %29 = getelementptr inbounds i8, ptr %0, i64 24
  store double %.sink, ptr %29, align 8
  %30 = load double, ptr %0, align 8, !tbaa !5
  %31 = load float, ptr @chandiv, align 4, !tbaa !24
  %32 = fpext float %31 to double
  %33 = fmul double %32, %2
  %34 = load i64, ptr @_ZN12maxiSettings10sampleRateE, align 8, !tbaa !26
  %35 = getelementptr inbounds i8, ptr %0, i64 60
  %36 = load i32, ptr %35, align 4, !tbaa !27
  %37 = sext i32 %36 to i64
  %38 = udiv i64 %34, %37
  %39 = uitofp i64 %38 to double
  %40 = fdiv double %33, %39
  %41 = fadd double %30, %40
  store double %41, 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,SimplifyCFGPass,TailCallElimPass