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

; 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::ImplicitEuler_FixedPointIteration" = type <{ %"class.std::function", %"class.std::vector", float, i32, 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 nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIfSaIfEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIfSaIfEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 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) #0 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) #1 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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN18NumericalODESolver33ImplicitEuler_FixedPointIteration9IntegrateEfiPf(ptr noundef nonnull align 8 dereferenceable(68) %0, float noundef %1, i32 noundef %2, ptr noundef %3) #1 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
  %11 = alloca i8, align 1
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca float, 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
  %15 = load ptr, ptr %5, align 8
  %16 = getelementptr inbounds %"class.NumericalODESolver::ImplicitEuler_FixedPointIteration", ptr %15, i32 0, i32 1
  %17 = call noundef i64 @_ZNKSt6vectorIfSaIfEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %16) #4
  %18 = load i32, ptr %7, align 4, !tbaa !11
  %19 = sext i32 %18 to i64
  %20 = icmp ult i64 %17, %19
  br i1 %20, label %21, label %25

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

25:                                               ; preds = %21, %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %26 = getelementptr inbounds %"class.NumericalODESolver::ImplicitEuler_FixedPointIteration", ptr %15, i32 0, i32 1
  %27 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %26, i64 noundef 0) #4
  store ptr %27, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 0, ptr %10, align 4, !tbaa !11
  br label %28

28:                                               ; preds = %90, %25
  %29 = load i32, ptr %10, align 4, !tbaa !11
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %10, align 4, !tbaa !11
  %31 = getelementptr inbounds %"class.NumericalODESolver::ImplicitEuler_FixedPointIteration", ptr %15, i32 0, i32 3
  %32 = load i32, ptr %31, align 4, !tbaa !13
  %33 = icmp slt i32 %29, %32
  br i1 %33, label %34, label %91

34:                                               ; preds = %28
  %35 = getelementptr inbounds %"class.NumericalODESolver::ImplicitEuler_FixedPointIteration", ptr %15, i32 0, i32 0
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = load i32, ptr %7, align 4, !tbaa !11
  %38 = getelementptr inbounds %"class.NumericalODESolver::ImplicitEuler_FixedPointIteration", ptr %15, i32 0, i32 2
  %39 = load float, ptr %38, align 8, !tbaa !21
  %40 = load ptr, ptr %9, align 8, !tbaa !5
  call void @_ZNKSt8functionIFvPKfifPfEEclES1_ifS2_(ptr noundef nonnull align 8 dereferenceable(32) %35, ptr noundef %36, i32 noundef %37, float noundef %39, ptr noundef %40)
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #4
  store i8 1, ptr %11, align 1, !tbaa !22
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  store i32 0, ptr %12, align 4, !tbaa !11
  br label %41

41:                                               ; preds = %80, %34
  %42 = load i32, ptr %12, align 4, !tbaa !11
  %43 = load i32, ptr %7, align 4, !tbaa !11
  %44 = icmp slt i32 %42, %43
  br i1 %44, label %46, label %45

45:                                               ; preds = %41
  store i32 4, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %83

46:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %47 = load ptr, ptr %9, align 8, !tbaa !5
  %48 = load i32, ptr %12, align 4, !tbaa !11
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds float, ptr %47, i64 %49
  %51 = load float, ptr %50, align 4, !tbaa !9
  %52 = load float, ptr %6, align 4, !tbaa !9
  %53 = fmul float %51, %52
  %54 = call float @llvm.fabs.f32(float %53)
  store float %54, ptr %14, align 4, !tbaa !9
  %55 = load float, ptr %14, align 4, !tbaa !9
  %56 = getelementptr inbounds %"class.NumericalODESolver::ImplicitEuler_FixedPointIteration", ptr %15, i32 0, i32 4
  %57 = load float, ptr %56, align 8, !tbaa !24
  %58 = fcmp olt float %55, %57
  br i1 %58, label %59, label %60

59:                                               ; preds = %46
  store i32 6, ptr %13, align 4
  br label %77

60:                                               ; preds = %46
  %61 = load ptr, ptr %8, align 8, !tbaa !5
  %62 = load i32, ptr %12, align 4, !tbaa !11
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds float, ptr %61, i64 %63
  %65 = load float, ptr %64, align 4, !tbaa !9
  %66 = load ptr, ptr %9, align 8, !tbaa !5
  %67 = load i32, ptr %12, align 4, !tbaa !11
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds float, ptr %66, i64 %68
  %70 = load float, ptr %69, align 4, !tbaa !9
  %71 = load float, ptr %6, align 4, !tbaa !9
  %72 = call float @llvm.fmuladd.f32(float %70, float %71, float %65)
  %73 = load ptr, ptr %8, align 8, !tbaa !5
  %74 = load i32, ptr %12, align 4, !tbaa !11
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds float, ptr %73, i64 %75
  store float %72, ptr %76, align 4, !tbaa !9
  store i8 0, ptr %11, align 1, !tbaa !22
  store i32 0, ptr %13, align 4
  br label %77

77:                                               ; preds = %60, %59
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  %78 = load i32, ptr %13, align 4
  switch i32 %78, label %96 [
    i32 0, label %79
    i32 6, label %80
  ]

79:                                               ; preds = %77
  br label %80

80:                                               ; preds = %79, %77
  %81 = load i32, ptr %12, align 4, !tbaa !11
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr %12, align 4, !tbaa !11
  br label %41, !llvm.loop !25

83:                                               ; preds = %45
  %84 = load i8, ptr %11, align 1, !tbaa !22, !range !27, !noundef !28
  %85 = trunc i8 %84 to i1
  br i1 %85, label %86, label %87

86:                                               ; preds = %83
  store i32 3, ptr %13, align 4
  br label %88

87:                                               ; preds = %83
  store i32 0, ptr %13, align 4
  br label %88

88:                                               ; preds = %87, %86
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #4
  %89 = load i32, ptr %13, align 4
  switch i32 %89, label %96 [
    i32 0, label %90
    i32 3, label %91
  ]

90:                                               ; preds = %88
  br label %28, !llvm.loop !29

91:                                               ; preds = %88, %28
  %92 = load float, ptr %6, align 4, !tbaa !9
  %93 = getelementptr inbounds %"class.NumericalODESolver::ImplicitEuler_FixedPointIteration", ptr %15, i32 0, i32 2
  %94 = load float, ptr %93, align 8, !tbaa !21
  %95 = fadd float %94, %92
  store float %95, ptr %93, align 8, !tbaa !21
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  ret void

96:                                               ; preds = %88, %77
  unreachable
}

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

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 = { 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 = { 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, !12, i64 60}
!14 = !{!"_ZTSN18NumericalODESolver33ImplicitEuler_FixedPointIterationE", !15, i64 0, !17, i64 32, !10, i64 56, !12, i64 60, !10, i64 64}
!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 = !{!14, !10, i64 56}
!22 = !{!23, !23, i64 0}
!23 = !{!"bool", !7, i64 0}
!24 = !{!14, !10, i64 64}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = !{i8 0, i8 2}
!28 = !{}
!29 = distinct !{!29, !26}


; 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 i64 @_ZNKSt6vectorIfSaIfEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIfSaIfEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #1 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 #0 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 #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN18NumericalODESolver33ImplicitEuler_FixedPointIteration9IntegrateEfiPf(ptr noundef nonnull align 8 dereferenceable(68) %0, float noundef %1, i32 noundef %2, ptr noundef %3) local_unnamed_addr #1 align 2 {
  %5 = getelementptr inbounds i8, ptr %0, i64 32
  %6 = tail call noundef i64 @_ZNKSt6vectorIfSaIfEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %5) #3
  %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) #3
  %12 = getelementptr inbounds i8, ptr %0, i64 60
  %13 = getelementptr inbounds i8, ptr %0, i64 56
  %14 = icmp sgt i32 %2, 0
  %15 = getelementptr inbounds i8, ptr %0, i64 64
  br i1 %14, label %.split.us.preheader, label %.split

.split.us.preheader:                              ; preds = %10
  %wide.trip.count = zext nneg i32 %2 to i64
  br label %.split.us

.split.us:                                        ; preds = %.split.us.preheader, %._crit_edge.us
  %.0.us = phi i32 [ %16, %._crit_edge.us ], [ 0, %.split.us.preheader ]
  %16 = add nuw nsw i32 %.0.us, 1
  %17 = load i32, ptr %12, align 4, !tbaa !5
  %18 = icmp slt i32 %.0.us, %17
  br i1 %18, label %.lr.ph.us, label %.split30.us

.lr.ph.us:                                        ; preds = %.split.us
  %19 = load float, ptr %13, align 8, !tbaa !18
  tail call void @_ZNKSt8functionIFvPKfifPfEEclES1_ifS2_(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef %3, i32 noundef %2, float noundef %19, ptr noundef nonnull %11)
  br label %20

20:                                               ; preds = %.lr.ph.us, %31
  %indvars.iv = phi i64 [ 0, %.lr.ph.us ], [ %indvars.iv.next, %31 ]
  %.02527.us = phi i1 [ true, %.lr.ph.us ], [ %.1.us, %31 ]
  %21 = getelementptr inbounds float, ptr %11, i64 %indvars.iv
  %22 = load float, ptr %21, align 4, !tbaa !19
  %23 = fmul float %22, %1
  %24 = tail call float @llvm.fabs.f32(float %23)
  %25 = load float, ptr %15, align 8, !tbaa !20
  %26 = fcmp olt float %24, %25
  br i1 %26, label %31, label %27

27:                                               ; preds = %20
  %28 = getelementptr inbounds float, ptr %3, i64 %indvars.iv
  %29 = load float, ptr %28, align 4, !tbaa !19
  %30 = tail call float @llvm.fmuladd.f32(float %22, float %1, float %29)
  store float %30, ptr %28, align 4, !tbaa !19
  br label %31

31:                                               ; preds = %27, %20
  %.1.us = phi i1 [ false, %27 ], [ %.02527.us, %20 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge.us, label %20, !llvm.loop !21

._crit_edge.us:                                   ; preds = %31
  br i1 %.1.us, label %.split30.us, label %.split.us

.split:                                           ; preds = %10
  %32 = load i32, ptr %12, align 4, !tbaa !5
  %33 = icmp sgt i32 %32, 0
  br i1 %33, label %34, label %.split30.us

34:                                               ; preds = %.split
  %35 = load float, ptr %13, align 8, !tbaa !18
  tail call void @_ZNKSt8functionIFvPKfifPfEEclES1_ifS2_(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef %3, i32 noundef %2, float noundef %35, ptr noundef nonnull %11)
  br label %.split30.us

.split30.us:                                      ; preds = %.split.us, %._crit_edge.us, %.split, %34
  %36 = load float, ptr %13, align 8, !tbaa !18
  %37 = fadd float %36, %1
  store float %37, ptr %13, align 8, !tbaa !18
  ret void
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fabs.f32(float) #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 = { 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !17, i64 60}
!6 = !{!"_ZTSN18NumericalODESolver33ImplicitEuler_FixedPointIterationE", !7, i64 0, !12, i64 32, !16, i64 56, !17, i64 60, !16, i64 64}
!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 = !{!"int", !9, i64 0}
!18 = !{!6, !16, i64 56}
!19 = !{!16, !16, i64 0}
!20 = !{!6, !16, i64 64}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: AggressiveInstCombinePass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass