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

; 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 }
%"struct.EulerSolver1D::cell_data" = type { float, %class.Array2D, %class.Array2D, %class.Array2D, %class.Array2D, %class.Array2D }

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

; Function Attrs: mustprogress uwtable
define dso_local noundef float @_ZN13EulerSolver1D6Solver8timestepEfffi(ptr noundef nonnull align 8 dereferenceable(280) %0, float noundef %1, float noundef %2, float noundef %3, i32 noundef %4) #1 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca i32, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca float, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store float %1, ptr %7, align 4, !tbaa !9
  store float %2, ptr %8, align 4, !tbaa !9
  store float %3, ptr %9, align 4, !tbaa !9
  store i32 %4, ptr %10, align 4, !tbaa !11
  %19 = load ptr, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  store float 1.000000e+00, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  %20 = load float, ptr %12, align 4, !tbaa !9
  %21 = fneg float %20
  store float %21, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  store i32 1, ptr %17, align 4, !tbaa !11
  br label %22

22:                                               ; preds = %67, %5
  %23 = load i32, ptr %17, align 4, !tbaa !11
  %24 = load i32, ptr %10, align 4, !tbaa !11
  %25 = icmp slt i32 %23, %24
  br i1 %25, label %27, label %26

26:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  br label %70

27:                                               ; preds = %22
  %28 = getelementptr inbounds %"class.EulerSolver1D::Solver", ptr %19, i32 0, i32 22
  %29 = load ptr, ptr %28, align 8, !tbaa !13
  %30 = load i32, ptr %17, align 4, !tbaa !11
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds %"struct.EulerSolver1D::cell_data", ptr %29, i64 %31
  %33 = getelementptr inbounds %"struct.EulerSolver1D::cell_data", ptr %32, i32 0, i32 3
  %34 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %33, i32 noundef 1)
  %35 = load float, ptr %34, align 4, !tbaa !9
  store float %35, ptr %13, align 4, !tbaa !9
  %36 = load float, ptr %9, align 4, !tbaa !9
  %37 = getelementptr inbounds %"class.EulerSolver1D::Solver", ptr %19, i32 0, i32 22
  %38 = load ptr, ptr %37, align 8, !tbaa !13
  %39 = load i32, ptr %17, align 4, !tbaa !11
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds %"struct.EulerSolver1D::cell_data", ptr %38, i64 %40
  %42 = getelementptr inbounds %"struct.EulerSolver1D::cell_data", ptr %41, i32 0, i32 3
  %43 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %42, i32 noundef 2)
  %44 = load float, ptr %43, align 4, !tbaa !9
  %45 = fmul float %36, %44
  %46 = getelementptr inbounds %"class.EulerSolver1D::Solver", ptr %19, i32 0, i32 22
  %47 = load ptr, ptr %46, align 8, !tbaa !13
  %48 = load i32, ptr %17, align 4, !tbaa !11
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds %"struct.EulerSolver1D::cell_data", ptr %47, i64 %49
  %51 = getelementptr inbounds %"struct.EulerSolver1D::cell_data", ptr %50, i32 0, i32 3
  %52 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %51, i32 noundef 0)
  %53 = load float, ptr %52, align 4, !tbaa !9
  %54 = fdiv float %45, %53
  %55 = call noundef float @_ZSt4sqrtf(float noundef %54)
  store float %55, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  %56 = load float, ptr %13, align 4, !tbaa !9
  %57 = call noundef float @_ZSt3absf(float noundef %56)
  %58 = load float, ptr %14, align 4, !tbaa !9
  %59 = fadd float %57, %58
  store float %59, ptr %18, align 4, !tbaa !9
  %60 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIfERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %15, ptr noundef nonnull align 4 dereferenceable(4) %18)
  %61 = load float, ptr %60, align 4, !tbaa !9
  store float %61, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  %62 = load float, ptr %7, align 4, !tbaa !9
  %63 = load float, ptr %8, align 4, !tbaa !9
  %64 = fmul float %62, %63
  %65 = load float, ptr %15, align 4, !tbaa !9
  %66 = fdiv float %64, %65
  store float %66, ptr %11, align 4, !tbaa !9
  br label %67

67:                                               ; preds = %27
  %68 = load i32, ptr %17, align 4, !tbaa !11
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %17, align 4, !tbaa !11
  br label %22, !llvm.loop !17

70:                                               ; preds = %26
  %71 = load float, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  ret float %71
}

; 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
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef) #1 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIfERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #2

; 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, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 272}
!14 = !{!"_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, !12, i64 44, !12, i64 48, !12, i64 52, !12, i64 56, !12, i64 60, !12, i64 64, !15, i64 72, !15, i64 112, !15, i64 152, !15, i64 192, !15, i64 232, !6, i64 272}
!15 = !{!"_ZTS7Array2DIfE", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !16, i64 24, !16, i64 25, !6, i64 32}
!16 = !{!"bool", !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"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"

%"struct.EulerSolver1D::cell_data" = type { float, %class.Array2D, %class.Array2D, %class.Array2D, %class.Array2D, %class.Array2D }
%class.Array2D = type { i32, i32, i32, i32, i32, i32, i8, i8, ptr }

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

; Function Attrs: mustprogress uwtable
define dso_local noundef float @_ZN13EulerSolver1D6Solver8timestepEfffi(ptr nocapture noundef nonnull readonly align 8 dereferenceable(280) %0, float noundef %1, float noundef %2, float noundef %3, i32 noundef %4) local_unnamed_addr #1 align 2 {
.lr.ph:
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #4
  store float -1.000000e+00, ptr %5, align 4, !tbaa !5
  %7 = icmp sgt i32 %4, 1
  tail call void @llvm.assume(i1 %7)
  %8 = getelementptr inbounds i8, ptr %0, i64 272
  %wide.trip.count = zext nneg i32 %4 to i64
  br label %11

._crit_edge:                                      ; preds = %11
  %9 = fmul float %1, %2
  %10 = fdiv float %9, %30
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #4
  ret float %10

11:                                               ; preds = %.lr.ph, %11
  %indvars.iv = phi i64 [ 1, %.lr.ph ], [ %indvars.iv.next, %11 ]
  %12 = load ptr, ptr %8, align 8, !tbaa !9
  %13 = getelementptr inbounds %"struct.EulerSolver1D::cell_data", ptr %12, i64 %indvars.iv, i32 3
  %14 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %13, i32 noundef 1)
  %15 = load float, ptr %14, align 4, !tbaa !5
  %16 = load ptr, ptr %8, align 8, !tbaa !9
  %17 = getelementptr inbounds %"struct.EulerSolver1D::cell_data", ptr %16, i64 %indvars.iv, i32 3
  %18 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %17, i32 noundef 2)
  %19 = load float, ptr %18, align 4, !tbaa !5
  %20 = fmul float %19, %3
  %21 = load ptr, ptr %8, align 8, !tbaa !9
  %22 = getelementptr inbounds %"struct.EulerSolver1D::cell_data", ptr %21, i64 %indvars.iv, i32 3
  %23 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %22, i32 noundef 0)
  %24 = load float, ptr %23, align 4, !tbaa !5
  %25 = fdiv float %20, %24
  %26 = call noundef float @_ZSt4sqrtf(float noundef %25)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #4
  %27 = call noundef float @_ZSt3absf(float noundef %15)
  %28 = fadd float %26, %27
  store float %28, ptr %6, align 4, !tbaa !5
  %29 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIfERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %6)
  %30 = load float, ptr %29, align 4, !tbaa !5
  store float %30, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #4
  %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, label %11, !llvm.loop !15
}

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef) local_unnamed_addr #1 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIfERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)
declare void @llvm.assume(i1 noundef) #3

attributes #0 = { mustprogress 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 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }
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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !14, i64 272}
!10 = !{!"_ZTSN13EulerSolver1D6SolverE", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !6, i64 40, !11, i64 44, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 60, !11, i64 64, !12, i64 72, !12, i64 112, !12, i64 152, !12, i64 192, !12, i64 232, !14, i64 272}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_ZTS7Array2DIfE", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !13, i64 24, !13, i64 25, !14, i64 32}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"any pointer", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopRotatePass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass