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

; 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 @_ZN13EulerSolver1D6Solver3u2wER7Array2DIfE(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 %56

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 %56

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 1)
          to label %19 unwind label %56

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 0)
          to label %23 unwind label %56

23:                                               ; preds = %19
  %24 = load float, ptr %22, align 4, !tbaa !9
  %25 = fdiv 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 %56

27:                                               ; preds = %23
  store float %25, ptr %26, align 4, !tbaa !9
  %28 = getelementptr inbounds %"class.EulerSolver1D::Solver", ptr %10, i32 0, i32 3
  %29 = load float, ptr %28, align 4, !tbaa !11
  %30 = getelementptr inbounds %"class.EulerSolver1D::Solver", ptr %10, i32 0, i32 1
  %31 = load float, ptr %30, align 4, !tbaa !16
  %32 = fsub float %29, %31
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %33, i32 noundef 2)
          to label %35 unwind label %56

35:                                               ; preds = %27
  %36 = load float, ptr %34, align 4, !tbaa !9
  %37 = getelementptr inbounds %"class.EulerSolver1D::Solver", ptr %10, i32 0, i32 2
  %38 = load float, ptr %37, align 8, !tbaa !17
  %39 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %0, i32 noundef 0)
          to label %40 unwind label %56

40:                                               ; preds = %35
  %41 = load float, ptr %39, align 4, !tbaa !9
  %42 = fmul float %38, %41
  %43 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %0, i32 noundef 1)
          to label %44 unwind label %56

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

48:                                               ; preds = %44
  %49 = load float, ptr %47, align 4, !tbaa !9
  %50 = fneg float %46
  %51 = call float @llvm.fmuladd.f32(float %50, float %49, float %36)
  %52 = fmul float %32, %51
  %53 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %0, i32 noundef 2)
          to label %54 unwind label %56

54:                                               ; preds = %48
  store float %52, ptr %53, align 4, !tbaa !9
  store i1 true, ptr %7, align 1
  %55 = load i1, ptr %7, align 1
  br i1 %55, label %61, label %60

56:                                               ; preds = %48, %44, %40, %35, %27, %23, %19, %16, %13, %3
  %57 = landingpad { ptr, i32 }
          cleanup
  %58 = extractvalue { ptr, i32 } %57, 0
  store ptr %58, ptr %8, align 8
  %59 = extractvalue { ptr, i32 } %57, 1
  store i32 %59, ptr %9, align 4
  call void @_ZN7Array2DIfED2Ev(ptr noundef nonnull align 8 dereferenceable(40) %0) #3
  br label %62

60:                                               ; preds = %54
  call void @_ZN7Array2DIfED2Ev(ptr noundef nonnull align 8 dereferenceable(40) %0) #3
  br label %61

61:                                               ; preds = %60, %54
  ret void

62:                                               ; preds = %56
  %63 = load ptr, ptr %8, align 8
  %64 = load i32, ptr %9, align 4
  %65 = insertvalue { ptr, i32 } poison, ptr %63, 0
  %66 = insertvalue { ptr, i32 } %65, i32 %64, 1
  resume { ptr, i32 } %66
}

; 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 @_ZN13EulerSolver1D6Solver3u2wER7Array2DIfE(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 %44

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 %44

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 1)
          to label %10 unwind label %44

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 0)
          to label %13 unwind label %44

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 %44

16:                                               ; preds = %13
  %17 = fdiv float %11, %14
  store float %17, ptr %15, align 4, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %1, i64 12
  %19 = load float, ptr %18, align 4, !tbaa !9
  %20 = getelementptr inbounds i8, ptr %1, i64 4
  %21 = load float, ptr %20, align 4, !tbaa !15
  %22 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Array2DIfEclEi(ptr noundef nonnull align 8 dereferenceable(40) %2, i32 noundef 2)
          to label %23 unwind label %44

23:                                               ; preds = %16
  %24 = load float, ptr %22, align 4, !tbaa !5
  %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) %0, i32 noundef 0)
          to label %28 unwind label %44

28:                                               ; preds = %23
  %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) %0, i32 noundef 1)
          to label %31 unwind label %44

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) %0, i32 noundef 1)
          to label %34 unwind label %44

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 %44

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

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

; 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,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass