; LLVM IR from LukeMcCulloch/cfd_solvers_cpp :: src/EulerShockTube1D.ll (ZN13EulerSolver1D6Solver6minmodEff)

; 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.EulerSolver1D::Solver" = type { float, float, float, float, float, float, float, float, float, float, float, i32, i32, i32, i32, i32, i32, %class.Array2D, %class.Array2D, %class.Array2D, %class.Array2D, %class.Array2D, ptr }
%class.Array2D = type { i32, i32, i32, i32, i32, i32, i8, i8, ptr }

; 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 uwtable
define dso_local noundef float @_ZN13EulerSolver1D6Solver6minmodEff(ptr noundef nonnull align 8 dereferenceable(280) %0, float noundef %1, float noundef %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store float %1, ptr %5, align 4, !tbaa !9
  store float %2, ptr %6, align 4, !tbaa !9
  %8 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %9 = load float, ptr %5, align 4, !tbaa !9
  %10 = load float, ptr %6, align 4, !tbaa !9
  %11 = fmul float %9, %10
  %12 = getelementptr inbounds %"class.EulerSolver1D::Solver", ptr %8, i32 0, i32 0
  %13 = load float, ptr %12, align 8, !tbaa !11
  %14 = fcmp ole float %11, %13
  br i1 %14, label %15, label %18

15:                                               ; preds = %3
  %16 = getelementptr inbounds %"class.EulerSolver1D::Solver", ptr %8, i32 0, i32 0
  %17 = load float, ptr %16, align 8, !tbaa !11
  store float %17, ptr %7, align 4, !tbaa !9
  br label %38

18:                                               ; preds = %3
  %19 = load float, ptr %5, align 4, !tbaa !9
  %20 = call noundef float @_ZSt3absf(float noundef %19)
  %21 = load float, ptr %6, align 4, !tbaa !9
  %22 = call noundef float @_ZSt3absf(float noundef %21)
  %23 = fcmp olt float %20, %22
  br i1 %23, label %24, label %26

24:                                               ; preds = %18
  %25 = load float, ptr %5, align 4, !tbaa !9
  store float %25, ptr %7, align 4, !tbaa !9
  br label %37

26:                                               ; preds = %18
  %27 = load float, ptr %6, align 4, !tbaa !9
  %28 = call noundef float @_ZSt3absf(float noundef %27)
  %29 = load float, ptr %5, align 4, !tbaa !9
  %30 = call noundef float @_ZSt3absf(float noundef %29)
  %31 = fcmp olt float %28, %30
  br i1 %31, label %32, label %34

32:                                               ; preds = %26
  %33 = load float, ptr %6, align 4, !tbaa !9
  store float %33, ptr %7, align 4, !tbaa !9
  br label %36

34:                                               ; preds = %26
  %35 = load float, ptr %5, align 4, !tbaa !9
  store float %35, ptr %7, align 4, !tbaa !9
  br label %36

36:                                               ; preds = %34, %32
  br label %37

37:                                               ; preds = %36, %24
  br label %38

38:                                               ; preds = %37, %15
  %39 = load float, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  ret float %39
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt3absf(float noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { inlinehint 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 = !{!"float", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTSN13EulerSolver1D6SolverE", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !13, i64 44, !13, i64 48, !13, i64 52, !13, i64 56, !13, i64 60, !13, i64 64, !14, i64 72, !14, i64 112, !14, i64 152, !14, i64 192, !14, i64 232, !6, i64 272}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTS7Array2DIfE", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !15, i64 24, !15, i64 25, !6, i64 32}
!15 = !{!"bool", !7, i64 0}


; 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
define dso_local noundef float @_ZN13EulerSolver1D6Solver6minmodEff(ptr nocapture noundef nonnull readonly align 8 dereferenceable(280) %0, float noundef %1, float noundef %2) local_unnamed_addr #0 align 2 {
  %4 = fmul float %1, %2
  %5 = load float, ptr %0, align 8, !tbaa !5
  %6 = fcmp ugt float %4, %5
  br i1 %6, label %7, label %15

7:                                                ; preds = %3
  %8 = tail call noundef float @_ZSt3absf(float noundef %1)
  %9 = tail call noundef float @_ZSt3absf(float noundef %2)
  %10 = fcmp olt float %8, %9
  br i1 %10, label %15, label %11

11:                                               ; preds = %7
  %12 = tail call noundef float @_ZSt3absf(float noundef %2)
  %13 = tail call noundef float @_ZSt3absf(float noundef %1)
  %14 = fcmp olt float %12, %13
  %. = select i1 %14, float %2, float %1
  br label %15

15:                                               ; preds = %11, %7, %3
  %.0 = phi float [ %5, %3 ], [ %1, %7 ], [ %., %11 ]
  ret float %.0
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt3absf(float noundef) local_unnamed_addr #1

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 = { inlinehint 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" }

!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 = !{!"_ZTSN13EulerSolver1D6SolverE", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !7, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !11, i64 72, !11, i64 112, !11, i64 152, !11, i64 192, !11, i64 232, !13, i64 272}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_ZTS7Array2DIfE", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !12, i64 24, !12, i64 25, !13, i64 32}
!12 = !{!"bool", !8, i64 0}
!13 = !{!"any pointer", !8, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass