; LLVM IR from atlantis13579/Riemann :: Src/Solver/NumericalODESolver.ll (ZN18NumericalODESolver13ExplicitEuler9IntegrateEfiPf)

; 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.NumericalODESolver::ExplicitEuler" = type <{ %"class.std::function", %"class.std::vector", float, [4 x i8] }>
%"class.std::function" = type { %"class.std::_Function_base", ptr }
%"class.std::_Function_base" = type { %"union.std::_Any_data", ptr }
%"union.std::_Any_data" = type { %"union.std::_Nocopy_types" }
%"union.std::_Nocopy_types" = type { { i64, i64 } }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = 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 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN18NumericalODESolver13ExplicitEuler9IntegrateEfiPf(ptr noundef nonnull align 8 dereferenceable(60) %0, float noundef %1, i32 noundef %2, ptr noundef %3) #0 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca float, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store float %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !11
  store ptr %3, ptr %8, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8
  %12 = getelementptr inbounds %"class.NumericalODESolver::ExplicitEuler", ptr %11, i32 0, i32 1
  %13 = call noundef i64 @_ZNKSt6vectorIfSaIfEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %12) #4
  %14 = load i32, ptr %7, align 4, !tbaa !11
  %15 = sext i32 %14 to i64
  %16 = icmp ult i64 %13, %15
  br i1 %16, label %17, label %21

17:                                               ; preds = %4
  %18 = getelementptr inbounds %"class.NumericalODESolver::ExplicitEuler", ptr %11, i32 0, i32 1
  %19 = load i32, ptr %7, align 4, !tbaa !11
  %20 = sext i32 %19 to i64
  call void @_ZNSt6vectorIfSaIfEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) %18, i64 noundef %20)
  br label %21

21:                                               ; preds = %17, %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %22 = getelementptr inbounds %"class.NumericalODESolver::ExplicitEuler", ptr %11, i32 0, i32 1
  %23 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %22, i64 noundef 0) #4
  store ptr %23, ptr %9, align 8, !tbaa !5
  %24 = getelementptr inbounds %"class.NumericalODESolver::ExplicitEuler", ptr %11, i32 0, i32 0
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = load i32, ptr %7, align 4, !tbaa !11
  %27 = getelementptr inbounds %"class.NumericalODESolver::ExplicitEuler", ptr %11, i32 0, i32 2
  %28 = load float, ptr %27, align 8, !tbaa !13
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  call void @_ZNKSt8functionIFvPKfifPfEEclES1_ifS2_(ptr noundef nonnull align 8 dereferenceable(32) %24, ptr noundef %25, i32 noundef %26, float noundef %28, ptr noundef %29)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 0, ptr %10, align 4, !tbaa !11
  br label %30

30:                                               ; preds = %52, %21
  %31 = load i32, ptr %10, align 4, !tbaa !11
  %32 = load i32, ptr %7, align 4, !tbaa !11
  %33 = icmp slt i32 %31, %32
  br i1 %33, label %35, label %34

34:                                               ; preds = %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %55

35:                                               ; preds = %30
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = load i32, ptr %10, align 4, !tbaa !11
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds float, ptr %36, i64 %38
  %40 = load float, ptr %39, align 4, !tbaa !9
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  %42 = load i32, ptr %10, align 4, !tbaa !11
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds float, ptr %41, i64 %43
  %45 = load float, ptr %44, align 4, !tbaa !9
  %46 = load float, ptr %6, align 4, !tbaa !9
  %47 = call float @llvm.fmuladd.f32(float %45, float %46, float %40)
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = load i32, ptr %10, align 4, !tbaa !11
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds float, ptr %48, i64 %50
  store float %47, ptr %51, align 4, !tbaa !9
  br label %52

52:                                               ; preds = %35
  %53 = load i32, ptr %10, align 4, !tbaa !11
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %10, align 4, !tbaa !11
  br label %30, !llvm.loop !21

55:                                               ; preds = %34
  %56 = load float, ptr %6, align 4, !tbaa !9
  %57 = getelementptr inbounds %"class.NumericalODESolver::ExplicitEuler", ptr %11, i32 0, i32 2
  %58 = load float, ptr %57, align 8, !tbaa !13
  %59 = fadd float %58, %56
  store float %59, ptr %57, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  ret void
}

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #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) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNKSt8functionIFvPKfifPfEEclES1_ifS2_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef, i32 noundef, float noundef, ptr noundef) #0 align 2

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"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 56}
!14 = !{!"_ZTSN18NumericalODESolver13ExplicitEulerE", !15, i64 0, !17, i64 32, !10, i64 56}
!15 = !{!"_ZTSSt8functionIFvPKfifPfEE", !16, i64 0, !6, i64 24}
!16 = !{!"_ZTSSt14_Function_base", !7, i64 0, !6, i64 16}
!17 = !{!"_ZTSSt6vectorIfSaIfEE", !18, i64 0}
!18 = !{!"_ZTSSt12_Vector_baseIfSaIfEE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseIfSaIfEE12_Vector_implE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseIfSaIfEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!21 = distinct !{!21, !22}
!22 = !{!"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 uwtable
define dso_local void @_ZN18NumericalODESolver13ExplicitEuler9IntegrateEfiPf(ptr noundef nonnull align 8 dereferenceable(60) %0, float noundef %1, i32 noundef %2, ptr noundef %3) local_unnamed_addr #0 align 2 {
  %5 = getelementptr inbounds i8, ptr %0, i64 32
  %6 = tail call noundef i64 @_ZNKSt6vectorIfSaIfEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %5) #4
  %7 = sext i32 %2 to i64
  %8 = icmp ult i64 %6, %7
  br i1 %8, label %9, label %10

9:                                                ; preds = %4
  tail call void @_ZNSt6vectorIfSaIfEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %7)
  br label %10

10:                                               ; preds = %9, %4
  %11 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef 0) #4
  %12 = getelementptr inbounds i8, ptr %0, i64 56
  %13 = load float, ptr %12, align 8, !tbaa !5
  tail call void @_ZNKSt8functionIFvPKfifPfEEclES1_ifS2_(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef %3, i32 noundef %2, float noundef %13, ptr noundef nonnull %11)
  %14 = icmp sgt i32 %2, 0
  br i1 %14, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %10
  %wide.trip.count = zext nneg i32 %2 to i64
  %min.iters.check = icmp ult i32 %2, 8
  br i1 %min.iters.check, label %.lr.ph.preheader23, label %vector.memcheck

.lr.ph.preheader23:                               ; preds = %middle.block, %vector.memcheck, %.lr.ph.preheader
  %indvars.iv.ph = phi i64 [ 0, %vector.memcheck ], [ 0, %.lr.ph.preheader ], [ %n.vec, %middle.block ]
  %xtraiter = and i64 %wide.trip.count, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol

.lr.ph.prol:                                      ; preds = %.lr.ph.preheader23
  %15 = getelementptr inbounds float, ptr %3, i64 %indvars.iv.ph
  %16 = load float, ptr %15, align 4, !tbaa !17
  %17 = getelementptr inbounds float, ptr %11, i64 %indvars.iv.ph
  %18 = load float, ptr %17, align 4, !tbaa !17
  %19 = tail call float @llvm.fmuladd.f32(float %18, float %1, float %16)
  store float %19, ptr %15, align 4, !tbaa !17
  %indvars.iv.next.prol = or disjoint i64 %indvars.iv.ph, 1
  br label %.lr.ph.prol.loopexit

.lr.ph.prol.loopexit:                             ; preds = %.lr.ph.prol, %.lr.ph.preheader23
  %indvars.iv.unr = phi i64 [ %indvars.iv.ph, %.lr.ph.preheader23 ], [ %indvars.iv.next.prol, %.lr.ph.prol ]
  %20 = add nsw i64 %wide.trip.count, -1
  %21 = icmp eq i64 %indvars.iv.ph, %20
  br i1 %21, label %._crit_edge, label %.lr.ph

vector.memcheck:                                  ; preds = %.lr.ph.preheader
  %22 = shl nuw nsw i64 %wide.trip.count, 2
  %scevgep = getelementptr i8, ptr %3, i64 %22
  %scevgep19 = getelementptr i8, ptr %11, i64 %22
  %bound0 = icmp ugt ptr %scevgep19, %3
  %bound1 = icmp ult ptr %11, %scevgep
  %found.conflict = and i1 %bound0, %bound1
  br i1 %found.conflict, label %.lr.ph.preheader23, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %n.vec = and i64 %wide.trip.count, 2147483640
  %broadcast.splatinsert = insertelement <4 x float> poison, float %1, i64 0
  %broadcast.splat = shufflevector <4 x float> %broadcast.splatinsert, <4 x float> poison, <4 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %23 = getelementptr inbounds float, ptr %3, i64 %index
  %24 = getelementptr inbounds i8, ptr %23, i64 16
  %wide.load = load <4 x float>, ptr %23, align 4, !tbaa !17, !alias.scope !18, !noalias !21
  %wide.load20 = load <4 x float>, ptr %24, align 4, !tbaa !17, !alias.scope !18, !noalias !21
  %25 = getelementptr inbounds float, ptr %11, i64 %index
  %26 = getelementptr inbounds i8, ptr %25, i64 16
  %wide.load21 = load <4 x float>, ptr %25, align 4, !tbaa !17, !alias.scope !21
  %wide.load22 = load <4 x float>, ptr %26, align 4, !tbaa !17, !alias.scope !21
  %27 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %wide.load21, <4 x float> %broadcast.splat, <4 x float> %wide.load)
  %28 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %wide.load22, <4 x float> %broadcast.splat, <4 x float> %wide.load20)
  store <4 x float> %27, ptr %23, align 4, !tbaa !17, !alias.scope !18, !noalias !21
  store <4 x float> %28, ptr %24, align 4, !tbaa !17, !alias.scope !18, !noalias !21
  %index.next = add nuw i64 %index, 8
  %29 = icmp eq i64 %index.next, %n.vec
  br i1 %29, label %middle.block, label %vector.body, !llvm.loop !23

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph.preheader23

._crit_edge:                                      ; preds = %.lr.ph.prol.loopexit, %.lr.ph, %middle.block, %10
  %30 = load float, ptr %12, align 8, !tbaa !5
  %31 = fadd float %30, %1
  store float %31, ptr %12, align 8, !tbaa !5
  ret void

.lr.ph:                                           ; preds = %.lr.ph.prol.loopexit, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %.lr.ph ], [ %indvars.iv.unr, %.lr.ph.prol.loopexit ]
  %32 = getelementptr inbounds float, ptr %3, i64 %indvars.iv
  %33 = load float, ptr %32, align 4, !tbaa !17
  %34 = getelementptr inbounds float, ptr %11, i64 %indvars.iv
  %35 = load float, ptr %34, align 4, !tbaa !17
  %36 = tail call float @llvm.fmuladd.f32(float %35, float %1, float %33)
  store float %36, ptr %32, align 4, !tbaa !17
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %37 = getelementptr inbounds float, ptr %3, i64 %indvars.iv.next
  %38 = load float, ptr %37, align 4, !tbaa !17
  %39 = getelementptr inbounds float, ptr %11, i64 %indvars.iv.next
  %40 = load float, ptr %39, align 4, !tbaa !17
  %41 = tail call float @llvm.fmuladd.f32(float %40, float %1, float %38)
  store float %41, ptr %37, align 4, !tbaa !17
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, %wide.trip.count
  br i1 %exitcond.not.1, label %._crit_edge, label %.lr.ph, !llvm.loop !27
}

; 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 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 uwtable
declare dso_local void @_ZNKSt8functionIFvPKfifPfEEclES1_ifS2_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef, i32 noundef, float noundef, ptr noundef) local_unnamed_addr #0 align 2

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <4 x float> @llvm.fmuladd.v4f32(<4 x float>, <4 x float>, <4 x float>) #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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !16, i64 56}
!6 = !{!"_ZTSN18NumericalODESolver13ExplicitEulerE", !7, i64 0, !12, i64 32, !16, i64 56}
!7 = !{!"_ZTSSt8functionIFvPKfifPfEE", !8, i64 0, !11, i64 24}
!8 = !{!"_ZTSSt14_Function_base", !9, i64 0, !11, i64 16}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!"_ZTSSt6vectorIfSaIfEE", !13, i64 0}
!13 = !{!"_ZTSSt12_Vector_baseIfSaIfEE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIfSaIfEE12_Vector_implE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIfSaIfEE17_Vector_impl_dataE", !11, i64 0, !11, i64 8, !11, i64 16}
!16 = !{!"float", !9, i64 0}
!17 = !{!16, !16, i64 0}
!18 = !{!19}
!19 = distinct !{!19, !20}
!20 = distinct !{!20, !"LVerDomain"}
!21 = !{!22}
!22 = distinct !{!22, !20}
!23 = distinct !{!23, !24, !25, !26}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!"llvm.loop.isvectorized", i32 1}
!26 = !{!"llvm.loop.unroll.runtime.disable"}
!27 = distinct !{!27, !24, !25}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass