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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7Array2DIfEC2Eii(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef, i32 noundef) unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7Array2DIfED2Ev(ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40), i32 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: mustprogress uwtable
define dso_local void @_ZN13EulerSolver1D6Solver19euler_physical_fluxER7Array2DIfE(ptr dead_on_unwind noalias writable sret(%class.Array2D) align 8 %0, ptr noundef nonnull align 8 dereferenceable(280) %1, ptr noundef nonnull align 8 dereferenceable(40) %2) #0 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i1, align 1
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %4, align 8
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %15 = load ptr, ptr %5, align 8
  store i1 false, ptr %7, align 1
  call void @_ZN7Array2DIfEC2Eii(ptr noundef nonnull align 8 dereferenceable(40) %0, i32 noundef 3, i32 noundef 1)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store float 5.000000e-01, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %16, i32 noundef 0)
          to label %18 unwind label %65

18:                                               ; preds = %3
  %19 = load float, ptr %17, align 4, !tbaa !9
  store float %19, ptr %9, align 4, !tbaa !9
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %20, i32 noundef 1)
          to label %22 unwind label %65

22:                                               ; preds = %18
  %23 = load float, ptr %21, align 4, !tbaa !9
  store float %23, ptr %10, align 4, !tbaa !9
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %24, i32 noundef 2)
          to label %26 unwind label %65

26:                                               ; preds = %22
  %27 = load float, ptr %25, align 4, !tbaa !9
  store float %27, ptr %11, align 4, !tbaa !9
  %28 = getelementptr inbounds %"class.EulerSolver1D::Solver", ptr %15, i32 0, i32 3
  %29 = load float, ptr %28, align 4, !tbaa !11
  %30 = load float, ptr %11, align 4, !tbaa !9
  %31 = fmul float %29, %30
  %32 = load float, ptr %9, align 4, !tbaa !9
  %33 = fdiv float %31, %32
  store float %33, ptr %12, align 4, !tbaa !9
  %34 = load float, ptr %9, align 4, !tbaa !9
  %35 = load float, ptr %10, align 4, !tbaa !9
  %36 = fmul float %34, %35
  %37 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %0, i32 noundef 0)
          to label %38 unwind label %65

38:                                               ; preds = %26
  store float %36, ptr %37, align 4, !tbaa !9
  %39 = load float, ptr %9, align 4, !tbaa !9
  %40 = load float, ptr %10, align 4, !tbaa !9
  %41 = fmul float %39, %40
  %42 = load float, ptr %10, align 4, !tbaa !9
  %43 = load float, ptr %11, align 4, !tbaa !9
  %44 = call float @llvm.fmuladd.f32(float %41, float %42, float %43)
  %45 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %0, i32 noundef 1)
          to label %46 unwind label %65

46:                                               ; preds = %38
  store float %44, ptr %45, align 4, !tbaa !9
  %47 = load float, ptr %9, align 4, !tbaa !9
  %48 = load float, ptr %10, align 4, !tbaa !9
  %49 = fmul float %47, %48
  %50 = load float, ptr %12, align 4, !tbaa !9
  %51 = getelementptr inbounds %"class.EulerSolver1D::Solver", ptr %15, i32 0, i32 3
  %52 = load float, ptr %51, align 4, !tbaa !11
  %53 = getelementptr inbounds %"class.EulerSolver1D::Solver", ptr %15, i32 0, i32 1
  %54 = load float, ptr %53, align 4, !tbaa !16
  %55 = fsub float %52, %54
  %56 = fdiv float %50, %55
  %57 = load float, ptr %10, align 4, !tbaa !9
  %58 = fmul float 5.000000e-01, %57
  %59 = load float, ptr %10, align 4, !tbaa !9
  %60 = call float @llvm.fmuladd.f32(float %58, float %59, float %56)
  %61 = fmul float %49, %60
  %62 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %0, i32 noundef 2)
          to label %63 unwind label %65

63:                                               ; preds = %46
  store float %61, ptr %62, align 4, !tbaa !9
  store i1 true, ptr %7, align 1
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %64 = load i1, ptr %7, align 1
  br i1 %64, label %70, label %69

65:                                               ; preds = %46, %38, %26, %22, %18, %3
  %66 = landingpad { ptr, i32 }
          cleanup
  %67 = extractvalue { ptr, i32 } %66, 0
  store ptr %67, ptr %13, align 8
  %68 = extractvalue { ptr, i32 } %66, 1
  store i32 %68, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @_ZN7Array2DIfED2Ev(ptr noundef nonnull align 8 dereferenceable(40) %0) #4
  br label %71

69:                                               ; preds = %63
  call void @_ZN7Array2DIfED2Ev(ptr noundef nonnull align 8 dereferenceable(40) %0) #4
  br label %70

70:                                               ; preds = %69, %63
  ret void

71:                                               ; preds = %65
  %72 = load ptr, ptr %13, align 8
  %73 = load i32, ptr %14, align 4
  %74 = insertvalue { ptr, i32 } poison, ptr %72, 0
  %75 = insertvalue { ptr, i32 } %74, i32 %73, 1
  resume { ptr, i32 } %75
}

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, !10, i64 12}
!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}
!16 = !{!12, !10, i64 4}


; 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"

%class.Array2D = type { i32, i32, i32, i32, i32, i32, i8, i8, ptr }

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7Array2DIfEC2Eii(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef, i32 noundef) unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7Array2DIfED2Ev(ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #1 align 2

; 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 #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: mustprogress uwtable
define dso_local void @_ZN13EulerSolver1D6Solver19euler_physical_fluxER7Array2DIfE(ptr dead_on_unwind noalias nonnull writable sret(%class.Array2D) align 8 %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(280) %1, ptr noundef nonnull align 8 dereferenceable(40) %2) local_unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  tail call void @_ZN7Array2DIfEC2Eii(ptr noundef nonnull align 8 dereferenceable(40) %0, i32 noundef 3, i32 noundef 1)
  %4 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %2, i32 noundef 0)
          to label %5 unwind label %33

5:                                                ; preds = %3
  %6 = load float, ptr %4, align 4, !tbaa !5
  %7 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %2, i32 noundef 1)
          to label %8 unwind label %33

8:                                                ; preds = %5
  %9 = load float, ptr %7, align 4, !tbaa !5
  %10 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %2, i32 noundef 2)
          to label %11 unwind label %33

11:                                               ; preds = %8
  %12 = load float, ptr %10, align 4, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %1, i64 12
  %14 = load float, ptr %13, align 4, !tbaa !9
  %15 = fmul float %6, %9
  %16 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %0, i32 noundef 0)
          to label %17 unwind label %33

17:                                               ; preds = %11
  store float %15, ptr %16, align 4, !tbaa !5
  %18 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %0, i32 noundef 1)
          to label %19 unwind label %33

19:                                               ; preds = %17
  %20 = tail call float @llvm.fmuladd.f32(float %15, float %9, float %12)
  store float %20, ptr %18, align 4, !tbaa !5
  %21 = load float, ptr %13, align 4, !tbaa !9
  %22 = getelementptr inbounds i8, ptr %1, i64 4
  %23 = load float, ptr %22, align 4, !tbaa !15
  %24 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %0, i32 noundef 2)
          to label %25 unwind label %33

25:                                               ; preds = %19
  %26 = fmul float %12, %14
  %27 = fdiv float %26, %6
  %28 = fmul float %9, 5.000000e-01
  %29 = fsub float %21, %23
  %30 = fdiv float %27, %29
  %31 = tail call float @llvm.fmuladd.f32(float %28, float %9, float %30)
  %32 = fmul float %15, %31
  store float %32, ptr %24, align 4, !tbaa !5
  ret void

33:                                               ; preds = %19, %17, %11, %8, %5, %3
  %34 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZN7Array2DIfED2Ev(ptr noundef nonnull align 8 dereferenceable(40) %0) #3
  resume { ptr, i32 } %34
}

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 = { 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, !6, i64 12}
!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 = !{!10, !6, i64 4}


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