; LLVM IR from flashlight/flashlight :: flashlight/fl/tensor/backend/jit/ir/Node.ll (ZN2fl4NodeD2Ev)

; 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.fl::Node" = type { ptr, %"class.std::vector", %"class.std::vector.4", %"class.std::__cxx11::list", %"class.std::__cxx11::list.12", %"class.fl::Shape", %"class.std::optional" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::shared_ptr<fl::Node>, std::allocator<std::shared_ptr<fl::Node>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::shared_ptr<fl::Node>, std::allocator<std::shared_ptr<fl::Node>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::shared_ptr<fl::Node>, std::allocator<std::shared_ptr<fl::Node>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::shared_ptr<fl::Node>, std::allocator<std::shared_ptr<fl::Node>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.4" = type { %"struct.std::_Vector_base.5" }
%"struct.std::_Vector_base.5" = type { %"struct.std::_Vector_base<std::_List_iterator<std::unique_ptr<fl::Use>>, std::allocator<std::_List_iterator<std::unique_ptr<fl::Use>>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::_List_iterator<std::unique_ptr<fl::Use>>, std::allocator<std::_List_iterator<std::unique_ptr<fl::Use>>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::_List_iterator<std::unique_ptr<fl::Use>>, std::allocator<std::_List_iterator<std::unique_ptr<fl::Use>>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::_List_iterator<std::unique_ptr<fl::Use>>, std::allocator<std::_List_iterator<std::unique_ptr<fl::Use>>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::__cxx11::list" = type { %"class.std::__cxx11::_List_base" }
%"class.std::__cxx11::_List_base" = type { %"struct.std::__cxx11::_List_base<std::unique_ptr<fl::Use>, std::allocator<std::unique_ptr<fl::Use>>>::_List_impl" }
%"struct.std::__cxx11::_List_base<std::unique_ptr<fl::Use>, std::allocator<std::unique_ptr<fl::Use>>>::_List_impl" = type { %"struct.std::__detail::_List_node_header" }
%"struct.std::__detail::_List_node_header" = type { %"struct.std::__detail::_List_node_base", i64 }
%"struct.std::__detail::_List_node_base" = type { ptr, ptr }
%"class.std::__cxx11::list.12" = type { %"class.std::__cxx11::_List_base.13" }
%"class.std::__cxx11::_List_base.13" = type { %"struct.std::__cxx11::_List_base<fl::ExternalUse *, std::allocator<fl::ExternalUse *>>::_List_impl" }
%"struct.std::__cxx11::_List_base<fl::ExternalUse *, std::allocator<fl::ExternalUse *>>::_List_impl" = type { %"struct.std::__detail::_List_node_header" }
%"class.fl::Shape" = type { %"class.std::vector.17" }
%"class.std::vector.17" = type { %"struct.std::_Vector_base.18" }
%"struct.std::_Vector_base.18" = type { %"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl" }
%"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl" = type { %"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl_data" }
%"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::optional" = type { %"struct.std::_Optional_base" }
%"struct.std::_Optional_base" = type { %"struct.std::_Optional_payload" }
%"struct.std::_Optional_payload" = type { %"struct.std::_Optional_payload.base", [7 x i8] }
%"struct.std::_Optional_payload.base" = type { %"struct.std::_Optional_payload_base.base" }
%"struct.std::_Optional_payload_base.base" = type <{ %"union.std::_Optional_payload_base<fl::Tensor>::_Storage", i8 }>
%"union.std::_Optional_payload_base<fl::Tensor>::_Storage" = type { %"class.fl::Tensor" }
%"class.fl::Tensor" = type { ptr, %"class.std::unique_ptr" }
%"class.std::unique_ptr" = type { %"struct.std::__uniq_ptr_data" }
%"struct.std::__uniq_ptr_data" = type { %"class.std::__uniq_ptr_impl" }
%"class.std::__uniq_ptr_impl" = type { %"class.std::tuple" }
%"class.std::tuple" = type { %"struct.std::_Tuple_impl" }
%"struct.std::_Tuple_impl" = type { %"struct.std::_Head_base.24" }
%"struct.std::_Head_base.24" = type { ptr }

@_ZTVN2fl4NodeE = external dso_local unnamed_addr constant { [5 x ptr] }, align 8

; 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 @_ZN2fl4Node11unlinkInputEj(ptr noundef nonnull align 8 dereferenceable(152), i32 noundef) #1 align 2

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

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

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

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN2fl4NodeD2Ev(ptr noundef nonnull align 8 dereferenceable(152) %0) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  store ptr getelementptr inbounds inrange(-16, 24) ({ [5 x ptr] }, ptr @_ZTVN2fl4NodeE, i32 0, i32 0, i32 2), ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 0, ptr %3, align 4, !tbaa !11
  br label %5

5:                                                ; preds = %15, %1
  %6 = load i32, ptr %3, align 4, !tbaa !11
  %7 = zext i32 %6 to i64
  %8 = getelementptr inbounds %"class.fl::Node", ptr %4, i32 0, i32 1
  %9 = call noundef i64 @_ZNKSt6vectorISt10shared_ptrIN2fl4NodeEESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %8) #5
  %10 = icmp ult i64 %7, %9
  br i1 %10, label %12, label %11

11:                                               ; preds = %5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %18

12:                                               ; preds = %5
  %13 = load i32, ptr %3, align 4, !tbaa !11
  invoke void @_ZN2fl4Node11unlinkInputEj(ptr noundef nonnull align 8 dereferenceable(152) %4, i32 noundef %13)
          to label %14 unwind label %25

14:                                               ; preds = %12
  br label %15

15:                                               ; preds = %14
  %16 = load i32, ptr %3, align 4, !tbaa !11
  %17 = add i32 %16, 1
  store i32 %17, ptr %3, align 4, !tbaa !11
  br label %5, !llvm.loop !13

18:                                               ; preds = %11
  %19 = getelementptr inbounds %"class.fl::Node", ptr %4, i32 0, i32 6
  call void @_ZNSt14_Optional_baseIN2fl6TensorELb0ELb0EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %19) #5
  %20 = getelementptr inbounds %"class.fl::Node", ptr %4, i32 0, i32 5
  call void @_ZN2fl5ShapeD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %20) #5
  %21 = getelementptr inbounds %"class.fl::Node", ptr %4, i32 0, i32 4
  call void @_ZNSt7__cxx1110_List_baseIPN2fl11ExternalUseESaIS3_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %21) #5
  %22 = getelementptr inbounds %"class.fl::Node", ptr %4, i32 0, i32 3
  call void @_ZNSt7__cxx1110_List_baseISt10unique_ptrIN2fl3UseESt14default_deleteIS3_EESaIS6_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %22) #5
  %23 = getelementptr inbounds %"class.fl::Node", ptr %4, i32 0, i32 2
  call void @_ZNSt6vectorISt14_List_iteratorISt10unique_ptrIN2fl3UseESt14default_deleteIS3_EEESaIS7_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %23) #5
  %24 = getelementptr inbounds %"class.fl::Node", ptr %4, i32 0, i32 1
  call void @_ZNSt6vectorISt10shared_ptrIN2fl4NodeEESaIS3_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %24) #5
  ret void

25:                                               ; preds = %12
  %26 = landingpad { ptr, i32 }
          catch ptr null
  %27 = extractvalue { ptr, i32 } %26, 0
  call void @__clang_call_terminate(ptr %27) #6
  unreachable
}

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) #4

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 = { 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 #4 = { noinline noreturn nounwind uwtable "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 #5 = { nounwind }
attributes #6 = { noreturn 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 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

@_ZTVN2fl4NodeE = external dso_local unnamed_addr constant { [5 x ptr] }, align 8

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2fl4Node11unlinkInputEj(ptr noundef nonnull align 8 dereferenceable(152), i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorISt10shared_ptrIN2fl4NodeEESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

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

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

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN2fl4NodeD2Ev(ptr noundef nonnull align 8 dereferenceable(152) %0) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  store ptr getelementptr inbounds inrange(-16, 24) (i8, ptr @_ZTVN2fl4NodeE, i64 16), ptr %0, align 8, !tbaa !5
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = tail call noundef i64 @_ZNKSt6vectorISt10shared_ptrIN2fl4NodeEESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #4
  %.not = icmp eq i64 %3, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %9, %1
  %4 = getelementptr inbounds i8, ptr %0, i64 128
  tail call void @_ZNSt14_Optional_baseIN2fl6TensorELb0ELb0EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %4) #4
  %5 = getelementptr inbounds i8, ptr %0, i64 104
  tail call void @_ZN2fl5ShapeD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %5) #4
  %6 = getelementptr inbounds i8, ptr %0, i64 80
  tail call void @_ZNSt7__cxx1110_List_baseIPN2fl11ExternalUseESaIS3_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %6) #4
  %7 = getelementptr inbounds i8, ptr %0, i64 56
  tail call void @_ZNSt7__cxx1110_List_baseISt10unique_ptrIN2fl3UseESt14default_deleteIS3_EESaIS6_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %7) #4
  %8 = getelementptr inbounds i8, ptr %0, i64 32
  tail call void @_ZNSt6vectorISt14_List_iteratorISt10unique_ptrIN2fl3UseESt14default_deleteIS3_EEESaIS7_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %8) #4
  tail call void @_ZNSt6vectorISt10shared_ptrIN2fl4NodeEESaIS3_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %2) #4
  ret void

.lr.ph:                                           ; preds = %1, %9
  %.04 = phi i32 [ %10, %9 ], [ 0, %1 ]
  invoke void @_ZN2fl4Node11unlinkInputEj(ptr noundef nonnull align 8 dereferenceable(152) %0, i32 noundef %.04)
          to label %9 unwind label %14

9:                                                ; preds = %.lr.ph
  %10 = add i32 %.04, 1
  %11 = zext i32 %10 to i64
  %12 = tail call noundef i64 @_ZNKSt6vectorISt10shared_ptrIN2fl4NodeEESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #4
  %13 = icmp ugt i64 %12, %11
  br i1 %13, label %.lr.ph, label %._crit_edge, !llvm.loop !8

14:                                               ; preds = %.lr.ph
  %15 = landingpad { ptr, i32 }
          catch ptr null
  %16 = extractvalue { ptr, i32 } %15, 0
  tail call void @__clang_call_terminate(ptr %16) #5
  unreachable
}

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) local_unnamed_addr #3

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 = { 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 = { noinline noreturn nounwind uwtable "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 #4 = { nounwind }
attributes #5 = { noreturn 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass