; LLVM IR from aspuru-guzik-group/qtorch :: src/main.ll (ZN6qtorch16ContractionTools19CreateChunksOfNodesERSt10shared_ptrINS_7NetworkEE)

; 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.__gnu_cxx::__normal_iterator.151" = type { ptr }
%"class.std::vector.14" = type { %"struct.std::_Vector_base.15" }
%"struct.std::_Vector_base.15" = type { %"struct.std::_Vector_base<std::shared_ptr<qtorch::Node>, std::allocator<std::shared_ptr<qtorch::Node>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::shared_ptr<qtorch::Node>, std::allocator<std::shared_ptr<qtorch::Node>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::shared_ptr<qtorch::Node>, std::allocator<std::shared_ptr<qtorch::Node>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::shared_ptr<qtorch::Node>, std::allocator<std::shared_ptr<qtorch::Node>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::back_insert_iterator.204" = type { ptr }
%"class.std::shared_ptr.200" = type { %"class.std::__shared_ptr.201" }
%"class.std::__shared_ptr.201" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }
%"class.qtorch::ContractionTools" = type { %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", %"class.std::complex", %"class.std::vector.186", %"class.std::random_device", %"class.std::shared_ptr.178", %"class.std::mersenne_twister_engine", i8, i32 }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon.0 }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon.0 = type { i64, [8 x i8] }
%"class.std::complex" = type { { double, double } }
%"class.std::vector.186" = type { %"struct.std::_Vector_base.187" }
%"struct.std::_Vector_base.187" = type { %"struct.std::_Vector_base<std::shared_ptr<std::vector<std::shared_ptr<qtorch::Node>>>, std::allocator<std::shared_ptr<std::vector<std::shared_ptr<qtorch::Node>>>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::shared_ptr<std::vector<std::shared_ptr<qtorch::Node>>>, std::allocator<std::shared_ptr<std::vector<std::shared_ptr<qtorch::Node>>>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::shared_ptr<std::vector<std::shared_ptr<qtorch::Node>>>, std::allocator<std::shared_ptr<std::vector<std::shared_ptr<qtorch::Node>>>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::shared_ptr<std::vector<std::shared_ptr<qtorch::Node>>>, std::allocator<std::shared_ptr<std::vector<std::shared_ptr<qtorch::Node>>>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::random_device" = type { %union.anon.191 }
%union.anon.191 = type { %"class.std::mersenne_twister_engine" }
%"class.std::shared_ptr.178" = type { %"class.std::__shared_ptr.179" }
%"class.std::__shared_ptr.179" = type { ptr, %"class.std::__shared_count" }
%"class.std::mersenne_twister_engine" = type { [624 x i64], i64 }

; 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1)) #2 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6qtorch16ContractionTools19CreateChunksOfNodesERSt10shared_ptrINS_7NetworkEE(ptr noundef nonnull align 8 dereferenceable(10128) %0, ptr noundef nonnull align 8 dereferenceable(16) %1) #3 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %"class.__gnu_cxx::__normal_iterator.151", align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca %"class.__gnu_cxx::__normal_iterator.151", align 8
  %11 = alloca %"class.std::vector.14", align 8
  %12 = alloca %"class.__gnu_cxx::__normal_iterator.151", align 8
  %13 = alloca %"class.std::back_insert_iterator.204", align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca %"class.std::back_insert_iterator.204", align 8
  %17 = alloca %"class.std::shared_ptr.200", align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %18 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %19) #6
  %21 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6qtorch7Network20GetUncontractedNodesEv(ptr noundef nonnull align 8 dereferenceable(380) %20) #6
  %22 = call ptr @_ZNKSt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS3_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %21) #6
  %23 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator.151", ptr %5, i32 0, i32 0
  store ptr %22, ptr %23, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 2, ptr %6, align 4, !tbaa !9
  %24 = getelementptr inbounds %"class.qtorch::ContractionTools", ptr %18, i32 0, i32 3
  %25 = load i32, ptr %6, align 4, !tbaa !9
  %26 = add nsw i32 %25, 1
  %27 = sext i32 %26 to i64
  call void @_ZNSt6vectorISt10shared_ptrIS_IS0_IN6qtorch4NodeEESaIS3_EEESaIS6_EE7reserveEm(ptr noundef nonnull align 8 dereferenceable(24) %24, i64 noundef %27)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %28) #6
  %30 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6qtorch7Network20GetUncontractedNodesEv(ptr noundef nonnull align 8 dereferenceable(380) %29) #6
  %31 = call noundef i64 @_ZNKSt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %30) #6
  %32 = trunc i64 %31 to i32
  store i32 %32, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %33 = load i32, ptr %7, align 4, !tbaa !9
  %34 = load i32, ptr %6, align 4, !tbaa !9
  %35 = sdiv i32 %33, %34
  store i32 %35, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %36

36:                                               ; preds = %85, %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %37) #6
  %39 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6qtorch7Network20GetUncontractedNodesEv(ptr noundef nonnull align 8 dereferenceable(380) %38) #6
  %40 = call ptr @_ZNKSt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS3_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %39) #6
  %41 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator.151", ptr %10, i32 0, i32 0
  store ptr %40, ptr %41, align 8
  %42 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPKSt10shared_ptrIN6qtorch4NodeEESt6vectorIS4_SaIS4_EEEEbRKNS_17__normal_iteratorIT_T0_EESF_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  br i1 %42, label %43, label %87

43:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 24, ptr %11) #6
  call void @_ZNSt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS3_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %11) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %12, ptr align 8 %5, i64 8, i1 false), !tbaa.struct !11
  %44 = load i32, ptr %8, align 4, !tbaa !9
  %45 = invoke ptr @_ZSt13back_inserterISt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS4_EEESt20back_insert_iteratorIT_ERS8_(ptr noundef nonnull align 8 dereferenceable(24) %11)
          to label %46 unwind label %72

46:                                               ; preds = %43
  %47 = getelementptr inbounds %"class.std::back_insert_iterator.204", ptr %13, i32 0, i32 0
  store ptr %45, ptr %47, align 8
  %48 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator.151", ptr %12, i32 0, i32 0
  %49 = load ptr, ptr %48, align 8
  %50 = getelementptr inbounds %"class.std::back_insert_iterator.204", ptr %13, i32 0, i32 0
  %51 = load ptr, ptr %50, align 8
  %52 = invoke ptr @_ZSt6copy_nIN9__gnu_cxx17__normal_iteratorIPKSt10shared_ptrIN6qtorch4NodeEESt6vectorIS5_SaIS5_EEEEiSt20back_insert_iteratorISA_EET1_T_T0_SE_(ptr %49, i32 noundef %44, ptr %51)
          to label %53 unwind label %72

53:                                               ; preds = %46
  %54 = getelementptr inbounds %"class.std::back_insert_iterator.204", ptr %16, i32 0, i32 0
  store ptr %52, ptr %54, align 8
  %55 = load i32, ptr %8, align 4, !tbaa !9
  invoke void @_ZSt7advanceIN9__gnu_cxx17__normal_iteratorIPKSt10shared_ptrIN6qtorch4NodeEESt6vectorIS5_SaIS5_EEEEiEvRT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %5, i32 noundef %55)
          to label %56 unwind label %72

56:                                               ; preds = %53
  %57 = getelementptr inbounds %"class.qtorch::ContractionTools", ptr %18, i32 0, i32 3
  call void @llvm.lifetime.start.p0(i64 16, ptr %17) #6
  invoke void @_ZSt11make_sharedISt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS4_EEJRS6_EES1_INSt9enable_ifIXntsr8is_arrayIT_EE5valueES9_E4typeEEDpOT0_(ptr dead_on_unwind writable sret(%"class.std::shared_ptr.200") align 8 %17, ptr noundef nonnull align 8 dereferenceable(24) %11)
          to label %58 unwind label %76

58:                                               ; preds = %56
  invoke void @_ZNSt6vectorISt10shared_ptrIS_IS0_IN6qtorch4NodeEESaIS3_EEESaIS6_EE9push_backEOS6_(ptr noundef nonnull align 8 dereferenceable(24) %57, ptr noundef nonnull align 8 dereferenceable(16) %17)
          to label %59 unwind label %80

59:                                               ; preds = %58
  call void @_ZNSt12__shared_ptrISt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS4_EELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %17) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %17) #6
  %60 = load i32, ptr %8, align 4, !tbaa !9
  %61 = load i32, ptr %9, align 4, !tbaa !9
  %62 = add nsw i32 %61, %60
  store i32 %62, ptr %9, align 4, !tbaa !9
  %63 = load i32, ptr %7, align 4, !tbaa !9
  %64 = load i32, ptr %9, align 4, !tbaa !9
  %65 = sub nsw i32 %63, %64
  %66 = load i32, ptr %8, align 4, !tbaa !9
  %67 = icmp slt i32 %65, %66
  br i1 %67, label %68, label %85

68:                                               ; preds = %59
  %69 = load i32, ptr %7, align 4, !tbaa !9
  %70 = load i32, ptr %9, align 4, !tbaa !9
  %71 = sub nsw i32 %69, %70
  store i32 %71, ptr %8, align 4, !tbaa !9
  br label %85

72:                                               ; preds = %53, %46, %43
  %73 = landingpad { ptr, i32 }
          cleanup
  %74 = extractvalue { ptr, i32 } %73, 0
  store ptr %74, ptr %14, align 8
  %75 = extractvalue { ptr, i32 } %73, 1
  store i32 %75, ptr %15, align 4
  br label %86

76:                                               ; preds = %56
  %77 = landingpad { ptr, i32 }
          cleanup
  %78 = extractvalue { ptr, i32 } %77, 0
  store ptr %78, ptr %14, align 8
  %79 = extractvalue { ptr, i32 } %77, 1
  store i32 %79, ptr %15, align 4
  br label %84

80:                                               ; preds = %58
  %81 = landingpad { ptr, i32 }
          cleanup
  %82 = extractvalue { ptr, i32 } %81, 0
  store ptr %82, ptr %14, align 8
  %83 = extractvalue { ptr, i32 } %81, 1
  store i32 %83, ptr %15, align 4
  call void @_ZNSt12__shared_ptrISt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS4_EELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %17) #6
  br label %84

84:                                               ; preds = %80, %76
  call void @llvm.lifetime.end.p0(i64 16, ptr %17) #6
  br label %86

85:                                               ; preds = %68, %59
  call void @_ZNSt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS3_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %11) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr %11) #6
  br label %36, !llvm.loop !12

86:                                               ; preds = %84, %72
  call void @_ZNSt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS3_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %11) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  br label %88

87:                                               ; preds = %36
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  ret void

88:                                               ; preds = %86
  %89 = load ptr, ptr %14, align 8
  %90 = load i32, ptr %15, align 4
  %91 = insertvalue { ptr, i32 } poison, ptr %89, 0
  %92 = insertvalue { ptr, i32 } %91, i32 %90, 1
  resume { ptr, i32 } %92
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local ptr @_ZSt13back_inserterISt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS4_EEESt20back_insert_iteratorIT_ERS8_(ptr noundef nonnull align 8 dereferenceable(24)) #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN9__gnu_cxxneIPKSt10shared_ptrIN6qtorch4NodeEESt6vectorIS4_SaIS4_EEEEbRKNS_17__normal_iteratorIT_T0_EESF_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #5

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorISt10shared_ptrIS_IS0_IN6qtorch4NodeEESaIS3_EEESaIS6_EE7reserveEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local ptr @_ZSt6copy_nIN9__gnu_cxx17__normal_iteratorIPKSt10shared_ptrIN6qtorch4NodeEESt6vectorIS5_SaIS5_EEEEiSt20back_insert_iteratorISA_EET1_T_T0_SE_(ptr, i32 noundef, ptr) #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZSt7advanceIN9__gnu_cxx17__normal_iteratorIPKSt10shared_ptrIN6qtorch4NodeEESt6vectorIS5_SaIS5_EEEEiEvRT_T0_(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #5

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorISt10shared_ptrIS_IS0_IN6qtorch4NodeEESaIS3_EEESaIS6_EE9push_backEOS6_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(16)) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt11make_sharedISt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS4_EEJRS6_EES1_INSt9enable_ifIXntsr8is_arrayIT_EE5valueES9_E4typeEEDpOT0_(ptr dead_on_unwind noalias writable sret(%"class.std::shared_ptr.200") align 8, ptr noundef nonnull align 8 dereferenceable(24)) #4

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #4 = { inlinehint 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 #5 = { 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 #6 = { 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 = !{i64 0, i64 8, !5}
!12 = distinct !{!12, !13}
!13 = !{!"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.__gnu_cxx::__normal_iterator.151" = type { ptr }
%"class.std::vector.14" = type { %"struct.std::_Vector_base.15" }
%"struct.std::_Vector_base.15" = type { %"struct.std::_Vector_base<std::shared_ptr<qtorch::Node>, std::allocator<std::shared_ptr<qtorch::Node>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::shared_ptr<qtorch::Node>, std::allocator<std::shared_ptr<qtorch::Node>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::shared_ptr<qtorch::Node>, std::allocator<std::shared_ptr<qtorch::Node>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::shared_ptr<qtorch::Node>, std::allocator<std::shared_ptr<qtorch::Node>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::shared_ptr.200" = type { %"class.std::__shared_ptr.201" }
%"class.std::__shared_ptr.201" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { 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 nounwind uwtable
declare dso_local void @_ZNSt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS3_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #1 align 2

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

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

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6qtorch16ContractionTools19CreateChunksOfNodesERSt10shared_ptrINS_7NetworkEE(ptr noundef nonnull align 8 dereferenceable(10128) %0, ptr noundef nonnull align 8 dereferenceable(16) %1) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"class.__gnu_cxx::__normal_iterator.151", align 8
  %4 = alloca %"class.__gnu_cxx::__normal_iterator.151", align 8
  %5 = alloca %"class.std::vector.14", align 8
  %6 = alloca %"class.std::shared_ptr.200", align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  %7 = tail call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %1) #6
  %8 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6qtorch7Network20GetUncontractedNodesEv(ptr noundef nonnull align 8 dereferenceable(380) %7) #6
  %9 = tail call ptr @_ZNKSt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS3_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %8) #6
  store ptr %9, ptr %3, align 8
  %10 = getelementptr inbounds i8, ptr %0, i64 80
  tail call void @_ZNSt6vectorISt10shared_ptrIS_IS0_IN6qtorch4NodeEESaIS3_EEESaIS6_EE7reserveEm(ptr noundef nonnull align 8 dereferenceable(24) %10, i64 noundef 3)
  %11 = tail call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %1) #6
  %12 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6qtorch7Network20GetUncontractedNodesEv(ptr noundef nonnull align 8 dereferenceable(380) %11) #6
  %13 = tail call noundef i64 @_ZNKSt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %12) #6
  %14 = trunc i64 %13 to i32
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  %15 = tail call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %1) #6
  %16 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6qtorch7Network20GetUncontractedNodesEv(ptr noundef nonnull align 8 dereferenceable(380) %15) #6
  %17 = tail call ptr @_ZNKSt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS3_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %16) #6
  store ptr %17, ptr %4, align 8
  %18 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPKSt10shared_ptrIN6qtorch4NodeEESt6vectorIS4_SaIS4_EEEEbRKNS_17__normal_iteratorIT_T0_EESF_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  br i1 %18, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %2
  %19 = sdiv i32 %14, 2
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %25
  %.028 = phi i32 [ %spec.select, %25 ], [ %19, %.lr.ph.preheader ]
  %.02327 = phi i32 [ %26, %25 ], [ 0, %.lr.ph.preheader ]
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #6
  call void @_ZNSt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS3_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %5) #6
  %.sroa.02.0.copyload = load ptr, ptr %3, align 8, !tbaa !5
  %20 = invoke ptr @_ZSt13back_inserterISt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS4_EEESt20back_insert_iteratorIT_ERS8_(ptr noundef nonnull align 8 dereferenceable(24) %5)
          to label %21 unwind label %32

21:                                               ; preds = %.lr.ph
  %22 = invoke ptr @_ZSt6copy_nIN9__gnu_cxx17__normal_iteratorIPKSt10shared_ptrIN6qtorch4NodeEESt6vectorIS5_SaIS5_EEEEiSt20back_insert_iteratorISA_EET1_T_T0_SE_(ptr %.sroa.02.0.copyload, i32 noundef %.028, ptr %20)
          to label %23 unwind label %32

23:                                               ; preds = %21
  call void @_ZSt7advanceIN9__gnu_cxx17__normal_iteratorIPKSt10shared_ptrIN6qtorch4NodeEESt6vectorIS5_SaIS5_EEEEiEvRT_T0_(ptr noundef nonnull align 8 dereferenceable(8) %3, i32 noundef %.028)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #6
  invoke void @_ZSt11make_sharedISt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS4_EEJRS6_EES1_INSt9enable_ifIXntsr8is_arrayIT_EE5valueES9_E4typeEEDpOT0_(ptr dead_on_unwind nonnull writable sret(%"class.std::shared_ptr.200") align 8 %6, ptr noundef nonnull align 8 dereferenceable(24) %5)
          to label %24 unwind label %34

24:                                               ; preds = %23
  invoke void @_ZNSt6vectorISt10shared_ptrIS_IS0_IN6qtorch4NodeEESaIS3_EEESaIS6_EE9push_backEOS6_(ptr noundef nonnull align 8 dereferenceable(24) %10, ptr noundef nonnull align 8 dereferenceable(16) %6)
          to label %25 unwind label %36

25:                                               ; preds = %24
  call void @_ZNSt12__shared_ptrISt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS4_EELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %6) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #6
  %26 = add nsw i32 %.028, %.02327
  %27 = sub nsw i32 %14, %26
  %spec.select = call i32 @llvm.smin.i32(i32 %27, i32 %.028)
  call void @_ZNSt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS3_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %5) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  %28 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %1) #6
  %29 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6qtorch7Network20GetUncontractedNodesEv(ptr noundef nonnull align 8 dereferenceable(380) %28) #6
  %30 = call ptr @_ZNKSt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS3_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %29) #6
  store ptr %30, ptr %4, align 8
  %31 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPKSt10shared_ptrIN6qtorch4NodeEESt6vectorIS4_SaIS4_EEEEbRKNS_17__normal_iteratorIT_T0_EESF_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  br i1 %31, label %.lr.ph, label %._crit_edge, !llvm.loop !9

32:                                               ; preds = %21, %.lr.ph
  %33 = landingpad { ptr, i32 }
          cleanup
  br label %39

34:                                               ; preds = %23
  %35 = landingpad { ptr, i32 }
          cleanup
  br label %38

36:                                               ; preds = %24
  %37 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt12__shared_ptrISt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS4_EELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %6) #6
  br label %38

38:                                               ; preds = %36, %34
  %.pn = phi { ptr, i32 } [ %37, %36 ], [ %35, %34 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #6
  br label %39

39:                                               ; preds = %38, %32
  %.pn.pn = phi { ptr, i32 } [ %.pn, %38 ], [ %33, %32 ]
  call void @_ZNSt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS3_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %5) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  resume { ptr, i32 } %.pn.pn

._crit_edge:                                      ; preds = %25, %2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local ptr @_ZSt13back_inserterISt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS4_EEESt20back_insert_iteratorIT_ERS8_(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN9__gnu_cxxneIPKSt10shared_ptrIN6qtorch4NodeEESt6vectorIS4_SaIS4_EEEEbRKNS_17__normal_iteratorIT_T0_EESF_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorISt10shared_ptrIS_IS0_IN6qtorch4NodeEESaIS3_EEESaIS6_EE7reserveEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local ptr @_ZSt6copy_nIN9__gnu_cxx17__normal_iteratorIPKSt10shared_ptrIN6qtorch4NodeEESt6vectorIS5_SaIS5_EEEEiSt20back_insert_iteratorISA_EET1_T_T0_SE_(ptr, i32 noundef, ptr) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZSt7advanceIN9__gnu_cxx17__normal_iteratorIPKSt10shared_ptrIN6qtorch4NodeEESt6vectorIS5_SaIS5_EEEEiEvRT_T0_(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorISt10shared_ptrIS_IS0_IN6qtorch4NodeEESaIS3_EEESaIS6_EE9push_backEOS6_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt11make_sharedISt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS4_EEJRS6_EES1_INSt9enable_ifIXntsr8is_arrayIT_EE5valueES9_E4typeEEDpOT0_(ptr dead_on_unwind noalias writable sret(%"class.std::shared_ptr.200") align 8, ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #3

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #5

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 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 = { 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 #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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