; LLVM IR from Gripnook/numerical-methods :: Assignment1/report/src (finite-differences)

; 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.std::vector.14" = type { %"struct.std::_Vector_base.15" }
%"struct.std::_Vector_base.15" = type { %"struct.std::_Vector_base<FiniteDifferences::Node_internal, std::allocator<FiniteDifferences::Node_internal>>::_Vector_impl" }
%"struct.std::_Vector_base<FiniteDifferences::Node_internal, std::allocator<FiniteDifferences::Node_internal>>::_Vector_impl" = type { %"struct.std::_Vector_base<FiniteDifferences::Node_internal, std::allocator<FiniteDifferences::Node_internal>>::_Vector_impl_data" }
%"struct.std::_Vector_base<FiniteDifferences::Node_internal, std::allocator<FiniteDifferences::Node_internal>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::pair.12" = type <{ %"class.Numeric::Matrix", i32, [4 x i8] }>
%"class.Numeric::Matrix" = type { i32, i32, %"class.std::vector" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<FiniteDifferences::Node, std::allocator<FiniteDifferences::Node>>::_Vector_impl" }
%"struct.std::_Vector_base<FiniteDifferences::Node, std::allocator<FiniteDifferences::Node>>::_Vector_impl" = type { %"struct.std::_Vector_base<FiniteDifferences::Node, std::allocator<FiniteDifferences::Node>>::_Vector_impl_data" }
%"struct.std::_Vector_base<FiniteDifferences::Node, std::allocator<FiniteDifferences::Node>>::_Vector_impl_data" = type { ptr, ptr, ptr }

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

declare i32 @__gxx_personality_v0(...)

; 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 void @_ZN17FiniteDifferences10precomputeERKN7Numeric6MatrixINS_4NodeEEERKSt6vectorISt4pairIiiESaIS8_EE(ptr dead_on_unwind noalias writable sret(%"class.std::vector.14") align 8, ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(24)) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN17FiniteDifferences4stopERKN7Numeric6MatrixINS_4NodeEEERKSt6vectorISt4pairIiiESaIS8_EERKS6_INS_13Node_internalESaISD_EE(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt4pairIN7Numeric6MatrixIN17FiniteDifferences4NodeEEEiEC2IRS4_RiTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairISA_SB_EEEbE4typeELb1EEEOSA_OSB_(ptr noundef nonnull align 8 dereferenceable(36), ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN17FiniteDifferences6jacobiEN7Numeric6MatrixINS_4NodeEEERKSt6vectorISt4pairIiiESaIS6_EE(ptr dead_on_unwind noalias writable sret(%"struct.std::pair.12") align 8 %0, ptr noundef %1, ptr noundef nonnull align 8 dereferenceable(24) %2) #1 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %"class.std::vector.14", align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = 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
  call void @llvm.lifetime.start.p0(i64 24, ptr %7) #3
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN17FiniteDifferences10precomputeERKN7Numeric6MatrixINS_4NodeEEERKSt6vectorISt4pairIiiESaIS8_EE(ptr dead_on_unwind writable sret(%"class.std::vector.14") align 8 %7, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(24) %11)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %20, %3
  %13 = load i32, ptr %8, align 4, !tbaa !9
  %14 = add nsw i32 %13, 1
  store i32 %14, ptr %8, align 4, !tbaa !9
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  invoke void @_ZN17FiniteDifferences12updateJacobiERN7Numeric6MatrixINS_4NodeEEERKSt6vectorISt4pairIiiESaIS7_EERKS5_INS_13Node_internalESaISC_EE(ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(24) %15, ptr noundef nonnull align 8 dereferenceable(24) %7)
          to label %16 unwind label %24

16:                                               ; preds = %12
  br label %17

17:                                               ; preds = %16
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = invoke noundef zeroext i1 @_ZN17FiniteDifferences4stopERKN7Numeric6MatrixINS_4NodeEEERKSt6vectorISt4pairIiiESaIS8_EERKS6_INS_13Node_internalESaISD_EE(ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(24) %18, ptr noundef nonnull align 8 dereferenceable(24) %7)
          to label %20 unwind label %24

20:                                               ; preds = %17
  %21 = xor i1 %19, true
  br i1 %21, label %12, label %22, !llvm.loop !11

22:                                               ; preds = %20
  invoke void @_ZNSt4pairIN7Numeric6MatrixIN17FiniteDifferences4NodeEEEiEC2IRS4_RiTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairISA_SB_EEEbE4typeELb1EEEOSA_OSB_(ptr noundef nonnull align 8 dereferenceable(36) %0, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 4 dereferenceable(4) %8)
          to label %23 unwind label %24

23:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @_ZNSt6vectorIN17FiniteDifferences13Node_internalESaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %7) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #3
  ret void

24:                                               ; preds = %22, %17, %12
  %25 = landingpad { ptr, i32 }
          cleanup
  %26 = extractvalue { ptr, i32 } %25, 0
  store ptr %26, ptr %9, align 8
  %27 = extractvalue { ptr, i32 } %25, 1
  store i32 %27, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @_ZNSt6vectorIN17FiniteDifferences13Node_internalESaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %7) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #3
  br label %28

28:                                               ; preds = %24
  %29 = load ptr, ptr %9, align 8
  %30 = load i32, ptr %10, align 4
  %31 = insertvalue { ptr, i32 } poison, ptr %29, 0
  %32 = insertvalue { ptr, i32 } %31, i32 %30, 1
  resume { ptr, i32 } %32
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN17FiniteDifferences12updateJacobiERN7Numeric6MatrixINS_4NodeEEERKSt6vectorISt4pairIiiESaIS7_EERKS5_INS_13Node_internalESaISC_EE(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) #1

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 = { 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 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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"

%"class.std::vector.14" = type { %"struct.std::_Vector_base.15" }
%"struct.std::_Vector_base.15" = type { %"struct.std::_Vector_base<FiniteDifferences::Node_internal, std::allocator<FiniteDifferences::Node_internal>>::_Vector_impl" }
%"struct.std::_Vector_base<FiniteDifferences::Node_internal, std::allocator<FiniteDifferences::Node_internal>>::_Vector_impl" = type { %"struct.std::_Vector_base<FiniteDifferences::Node_internal, std::allocator<FiniteDifferences::Node_internal>>::_Vector_impl_data" }
%"struct.std::_Vector_base<FiniteDifferences::Node_internal, std::allocator<FiniteDifferences::Node_internal>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::pair.12" = type <{ %"class.Numeric::Matrix", i32, [4 x i8] }>
%"class.Numeric::Matrix" = type { i32, i32, %"class.std::vector" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<FiniteDifferences::Node, std::allocator<FiniteDifferences::Node>>::_Vector_impl" }
%"struct.std::_Vector_base<FiniteDifferences::Node, std::allocator<FiniteDifferences::Node>>::_Vector_impl" = type { %"struct.std::_Vector_base<FiniteDifferences::Node, std::allocator<FiniteDifferences::Node>>::_Vector_impl_data" }
%"struct.std::_Vector_base<FiniteDifferences::Node, std::allocator<FiniteDifferences::Node>>::_Vector_impl_data" = type { ptr, ptr, ptr }

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

declare i32 @__gxx_personality_v0(...)

; 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 void @_ZN17FiniteDifferences10precomputeERKN7Numeric6MatrixINS_4NodeEEERKSt6vectorISt4pairIiiESaIS8_EE(ptr dead_on_unwind noalias writable sret(%"class.std::vector.14") align 8, ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN17FiniteDifferences4stopERKN7Numeric6MatrixINS_4NodeEEERKSt6vectorISt4pairIiiESaIS8_EERKS6_INS_13Node_internalESaISD_EE(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt4pairIN7Numeric6MatrixIN17FiniteDifferences4NodeEEEiEC2IRS4_RiTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairISA_SB_EEEbE4typeELb1EEEOSA_OSB_(ptr noundef nonnull align 8 dereferenceable(36), ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN17FiniteDifferences6jacobiEN7Numeric6MatrixINS_4NodeEEERKSt6vectorISt4pairIiiESaIS6_EE(ptr dead_on_unwind noalias writable sret(%"struct.std::pair.12") align 8 %0, ptr noundef nonnull %1, ptr noundef nonnull align 8 dereferenceable(24) %2) local_unnamed_addr #1 personality ptr @__gxx_personality_v0 {
  %4 = alloca %"class.std::vector.14", align 8
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #3
  call void @_ZN17FiniteDifferences10precomputeERKN7Numeric6MatrixINS_4NodeEEERKSt6vectorISt4pairIiiESaIS8_EE(ptr dead_on_unwind nonnull writable sret(%"class.std::vector.14") align 8 %4, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(24) %2)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #3
  br label %6

6:                                                ; preds = %11, %3
  %7 = phi i32 [ %8, %11 ], [ 0, %3 ]
  %8 = add nuw nsw i32 %7, 1
  store i32 %8, ptr %5, align 4, !tbaa !5
  invoke void @_ZN17FiniteDifferences12updateJacobiERN7Numeric6MatrixINS_4NodeEEERKSt6vectorISt4pairIiiESaIS7_EERKS5_INS_13Node_internalESaISC_EE(ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(24) %4)
          to label %9 unwind label %.loopexit

9:                                                ; preds = %6
  %10 = invoke noundef zeroext i1 @_ZN17FiniteDifferences4stopERKN7Numeric6MatrixINS_4NodeEEERKSt6vectorISt4pairIiiESaIS8_EERKS6_INS_13Node_internalESaISD_EE(ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(24) %4)
          to label %11 unwind label %.loopexit

11:                                               ; preds = %9
  br i1 %10, label %12, label %6, !llvm.loop !9

12:                                               ; preds = %11
  invoke void @_ZNSt4pairIN7Numeric6MatrixIN17FiniteDifferences4NodeEEEiEC2IRS4_RiTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairISA_SB_EEEbE4typeELb1EEEOSA_OSB_(ptr noundef nonnull align 8 dereferenceable(36) %0, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 4 dereferenceable(4) %5)
          to label %13 unwind label %.loopexit.split-lp

13:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #3
  call void @_ZNSt6vectorIN17FiniteDifferences13Node_internalESaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %4) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #3
  ret void

.loopexit:                                        ; preds = %6, %9
  %lpad.loopexit = landingpad { ptr, i32 }
          cleanup
  br label %14

.loopexit.split-lp:                               ; preds = %12
  %lpad.loopexit.split-lp = landingpad { ptr, i32 }
          cleanup
  br label %14

14:                                               ; preds = %.loopexit.split-lp, %.loopexit
  %lpad.phi = phi { ptr, i32 } [ %lpad.loopexit, %.loopexit ], [ %lpad.loopexit.split-lp, %.loopexit.split-lp ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #3
  call void @_ZNSt6vectorIN17FiniteDifferences13Node_internalESaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %4) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #3
  resume { ptr, i32 } %lpad.phi
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN17FiniteDifferences12updateJacobiERN7Numeric6MatrixINS_4NodeEEERKSt6vectorISt4pairIiiESaIS7_EERKS5_INS_13Node_internalESaISC_EE(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1

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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass