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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZN10maxiSample8playLoopEdd(ptr noundef nonnull align 8 dereferenceable(176) %0, double noundef %1, double noundef %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca i64, 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
  %9 = getelementptr inbounds %class.maxiSample, ptr %8, i32 0, i32 0
  %10 = load double, ptr %9, align 8, !tbaa !11
  %11 = fadd double %10, 1.000000e+00
  store double %11, ptr %9, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %12 = getelementptr inbounds %class.maxiSample, ptr %8, i32 0, i32 10
  %13 = call noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %12) #2
  store i64 %13, ptr %7, align 8, !tbaa !25
  %14 = getelementptr inbounds %class.maxiSample, ptr %8, i32 0, i32 0
  %15 = load double, ptr %14, align 8, !tbaa !11
  %16 = load i64, ptr %7, align 8, !tbaa !25
  %17 = uitofp i64 %16 to double
  %18 = load double, ptr %5, align 8, !tbaa !9
  %19 = fmul double %17, %18
  %20 = fcmp olt double %15, %19
  br i1 %20, label %21, label %27

21:                                               ; preds = %3
  %22 = load i64, ptr %7, align 8, !tbaa !25
  %23 = uitofp i64 %22 to double
  %24 = load double, ptr %5, align 8, !tbaa !9
  %25 = fmul double %23, %24
  %26 = getelementptr inbounds %class.maxiSample, ptr %8, i32 0, i32 0
  store double %25, ptr %26, align 8, !tbaa !11
  br label %27

27:                                               ; preds = %21, %3
  %28 = getelementptr inbounds %class.maxiSample, ptr %8, i32 0, i32 0
  %29 = load double, ptr %28, align 8, !tbaa !11
  %30 = fptosi double %29 to i64
  %31 = sitofp i64 %30 to double
  %32 = load i64, ptr %7, align 8, !tbaa !25
  %33 = uitofp i64 %32 to double
  %34 = load double, ptr %6, align 8, !tbaa !9
  %35 = fmul double %33, %34
  %36 = fcmp oge double %31, %35
  br i1 %36, label %37, label %43

37:                                               ; preds = %27
  %38 = load i64, ptr %7, align 8, !tbaa !25
  %39 = uitofp i64 %38 to double
  %40 = load double, ptr %5, align 8, !tbaa !9
  %41 = fmul double %39, %40
  %42 = getelementptr inbounds %class.maxiSample, ptr %8, i32 0, i32 0
  store double %41, ptr %42, align 8, !tbaa !11
  br label %43

43:                                               ; preds = %37, %27
  %44 = getelementptr inbounds %class.maxiSample, ptr %8, i32 0, i32 10
  %45 = getelementptr inbounds %class.maxiSample, ptr %8, i32 0, i32 0
  %46 = load double, ptr %45, align 8, !tbaa !11
  %47 = fptosi double %46 to i64
  %48 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %44, i64 noundef %47) #2
  %49 = load double, ptr %48, align 8, !tbaa !9
  %50 = getelementptr inbounds %class.maxiSample, ptr %8, i32 0, i32 3
  store double %49, ptr %50, align 8, !tbaa !26
  %51 = getelementptr inbounds %class.maxiSample, ptr %8, i32 0, i32 3
  %52 = load double, ptr %51, align 8, !tbaa !26
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  ret double %52
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !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 = !{!24, !24, i64 0}
!26 = !{!12, !10, i64 24}


; 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
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(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 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZN10maxiSample8playLoopEdd(ptr noundef nonnull align 8 dereferenceable(176) %0, double noundef %1, double noundef %2) local_unnamed_addr #0 align 2 {
  %4 = load double, ptr %0, align 8, !tbaa !5
  %5 = fadd double %4, 1.000000e+00
  store double %5, ptr %0, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 88
  %7 = tail call noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %6) #1
  %8 = load double, ptr %0, align 8, !tbaa !5
  %9 = uitofp i64 %7 to double
  %10 = fmul double %9, %1
  %11 = fcmp olt double %8, %10
  br i1 %11, label %12, label %13

12:                                               ; preds = %3
  store double %10, ptr %0, align 8, !tbaa !5
  br label %13

13:                                               ; preds = %12, %3
  %14 = phi double [ %10, %12 ], [ %8, %3 ]
  %15 = fptosi double %14 to i64
  %16 = sitofp i64 %15 to double
  %17 = fmul double %9, %2
  %18 = fcmp ugt double %17, %16
  br i1 %18, label %20, label %19

19:                                               ; preds = %13
  store double %10, ptr %0, align 8, !tbaa !5
  %.pre = fptosi double %10 to i64
  br label %20

20:                                               ; preds = %19, %13
  %.pre-phi = phi i64 [ %.pre, %19 ], [ %15, %13 ]
  %21 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %6, i64 noundef %.pre-phi) #1
  %22 = load double, ptr %21, align 8, !tbaa !23
  %23 = getelementptr inbounds i8, ptr %0, i64 24
  store double %22, ptr %23, align 8, !tbaa !24
  ret double %22
}

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 = { 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 = !{!6, !7, i64 24}


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