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

; 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: 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: mustprogress uwtable
define dso_local void @_ZN13EulerSolver1D6Solver3w2uER7Array2DIfE(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 ptr, align 8
  %9 = 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
  %10 = 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)
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  %12 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %11, i32 noundef 0)
          to label %13 unwind label %58

13:                                               ; preds = %3
  %14 = load float, ptr %12, align 4, !tbaa !9
  %15 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %0, i32 noundef 0)
          to label %16 unwind label %58

16:                                               ; preds = %13
  store float %14, ptr %15, align 4, !tbaa !9
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %17, i32 noundef 0)
          to label %19 unwind label %58

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

23:                                               ; preds = %19
  %24 = load float, ptr %22, align 4, !tbaa !9
  %25 = fmul float %20, %24
  %26 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %0, i32 noundef 1)
          to label %27 unwind label %58

27:                                               ; preds = %23
  store float %25, ptr %26, align 4, !tbaa !9
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %28, i32 noundef 2)
          to label %30 unwind label %58

30:                                               ; preds = %27
  %31 = load float, ptr %29, align 4, !tbaa !9
  %32 = getelementptr inbounds %"class.EulerSolver1D::Solver", ptr %10, i32 0, i32 3
  %33 = load float, ptr %32, align 4, !tbaa !11
  %34 = getelementptr inbounds %"class.EulerSolver1D::Solver", ptr %10, i32 0, i32 1
  %35 = load float, ptr %34, align 4, !tbaa !16
  %36 = fsub float %33, %35
  %37 = fdiv float %31, %36
  %38 = getelementptr inbounds %"class.EulerSolver1D::Solver", ptr %10, i32 0, i32 2
  %39 = load float, ptr %38, align 8, !tbaa !17
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %40, i32 noundef 0)
          to label %42 unwind label %58

42:                                               ; preds = %30
  %43 = load float, ptr %41, align 4, !tbaa !9
  %44 = fmul float %39, %43
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %45, i32 noundef 1)
          to label %47 unwind label %58

47:                                               ; preds = %42
  %48 = load float, ptr %46, align 4, !tbaa !9
  %49 = fmul float %44, %48
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %50, i32 noundef 1)
          to label %52 unwind label %58

52:                                               ; preds = %47
  %53 = load float, ptr %51, align 4, !tbaa !9
  %54 = call float @llvm.fmuladd.f32(float %49, float %53, float %37)
  %55 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %0, i32 noundef 2)
          to label %56 unwind label %58

56:                                               ; preds = %52
  store float %54, ptr %55, align 4, !tbaa !9
  store i1 true, ptr %7, align 1
  %57 = load i1, ptr %7, align 1
  br i1 %57, label %63, label %62

58:                                               ; preds = %52, %47, %42, %30, %27, %23, %19, %16, %13, %3
  %59 = landingpad { ptr, i32 }
          cleanup
  %60 = extractvalue { ptr, i32 } %59, 0
  store ptr %60, ptr %8, align 8
  %61 = extractvalue { ptr, i32 } %59, 1
  store i32 %61, ptr %9, align 4
  call void @_ZN7Array2DIfED2Ev(ptr noundef nonnull align 8 dereferenceable(40) %0) #3
  br label %64

62:                                               ; preds = %56
  call void @_ZN7Array2DIfED2Ev(ptr noundef nonnull align 8 dereferenceable(40) %0) #3
  br label %63

63:                                               ; preds = %62, %56
  ret void

64:                                               ; preds = %58
  %65 = load ptr, ptr %8, align 8
  %66 = load i32, ptr %9, align 4
  %67 = insertvalue { ptr, i32 } poison, ptr %65, 0
  %68 = insertvalue { ptr, i32 } %67, i32 %66, 1
  resume { ptr, i32 } %68
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #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 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 = !{!"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}
!17 = !{!12, !10, i64 8}


; 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 uwtable
define dso_local void @_ZN13EulerSolver1D6Solver3w2uER7Array2DIfE(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 %43

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) %0, i32 noundef 0)
          to label %8 unwind label %43

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

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

13:                                               ; preds = %10
  %14 = load float, ptr %12, align 4, !tbaa !5
  %15 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %0, i32 noundef 1)
          to label %16 unwind label %43

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

19:                                               ; preds = %16
  %20 = load float, ptr %18, align 4, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %1, i64 12
  %22 = load float, ptr %21, align 4, !tbaa !9
  %23 = getelementptr inbounds i8, ptr %1, i64 4
  %24 = load float, ptr %23, align 4, !tbaa !15
  %25 = getelementptr inbounds i8, ptr %1, i64 8
  %26 = load float, ptr %25, align 8, !tbaa !16
  %27 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %2, i32 noundef 0)
          to label %28 unwind label %43

28:                                               ; preds = %19
  %29 = load float, ptr %27, align 4, !tbaa !5
  %30 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %2, i32 noundef 1)
          to label %31 unwind label %43

31:                                               ; preds = %28
  %32 = load float, ptr %30, align 4, !tbaa !5
  %33 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %2, i32 noundef 1)
          to label %34 unwind label %43

34:                                               ; preds = %31
  %35 = load float, ptr %33, align 4, !tbaa !5
  %36 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %0, i32 noundef 2)
          to label %37 unwind label %43

37:                                               ; preds = %34
  %38 = fsub float %22, %24
  %39 = fdiv float %20, %38
  %40 = fmul float %26, %29
  %41 = fmul float %40, %32
  %42 = tail call float @llvm.fmuladd.f32(float %41, float %35, float %39)
  store float %42, ptr %36, align 4, !tbaa !5
  ret void

43:                                               ; preds = %34, %31, %28, %19, %16, %13, %10, %8, %5, %3
  %44 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZN7Array2DIfED2Ev(ptr noundef nonnull align 8 dereferenceable(40) %0) #3
  resume { ptr, i32 } %44
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #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 = { 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}
!16 = !{!10, !6, i64 8}


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