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

; 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::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.qtorch::Timer" = type <{ %"class.std::chrono::time_point", i64, i8, [7 x i8] }>
%"class.std::chrono::time_point" = type { %"class.std::chrono::duration" }
%"class.std::chrono::duration" = type { i64 }
%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }
%"class.std::shared_ptr.178" = type { %"class.std::__shared_ptr.179" }
%"class.std::__shared_ptr.179" = type { ptr, %"class.std::__shared_count" }
%"class.std::uniform_int_distribution" = type { %"struct.std::uniform_int_distribution<>::param_type" }
%"struct.std::uniform_int_distribution<>::param_type" = type { i32, i32 }
%"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::mersenne_twister_engine" = type { [624 x i64], i64 }

@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@_ZN6qtorch8totTimerE = external dso_local global %"class.qtorch::Timer", align 8
@_ZN6qtorch7maxTimeE = external dso_local global double, align 8
@_ZTIN6qtorch18ContractionFailureE = external dso_local constant { ptr, ptr, ptr }, align 8
@.str.83 = external hidden unnamed_addr constant [13 x i8], align 1

; 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: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #1

declare ptr @__cxa_allocate_exception(i64)

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

declare void @__cxa_throw(ptr, ptr, ptr)

; 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) #4

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_ZN6qtorch5Timer10getElapsedEv(ptr noundef nonnull align 8 dereferenceable(17)) #2 align 2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6qtorch7Network13ContractNodesESt10shared_ptrINS_4NodeEES3_i(ptr dead_on_unwind noalias writable sret(%"class.std::shared_ptr") align 8, ptr noundef nonnull align 8 dereferenceable(380), ptr noundef, ptr noundef, i32 noundef) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #5 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)) #5 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)) #5 align 2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEm(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #2 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt10shared_ptrIN6qtorch7NetworkEEaSEOS2_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #5 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6qtorch16ContractionTools26CostBasedContractionSimpleEi(ptr dead_on_unwind noalias writable sret(%"class.std::shared_ptr.178") align 8 %0, ptr noundef nonnull align 8 dereferenceable(10128) %1, i32 noundef %2) #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca %"class.std::shared_ptr.178", align 8
  %8 = alloca i64, align 8
  %9 = alloca [2 x i32], align 4
  %10 = alloca %"class.std::uniform_int_distribution", align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca %"class.std::shared_ptr", align 8
  %19 = alloca %"class.std::shared_ptr", align 8
  %20 = alloca ptr, align 8
  %21 = alloca i32, align 4
  %22 = alloca i64, align 8
  %23 = alloca %"class.std::shared_ptr", align 8
  %24 = alloca %"class.std::shared_ptr", align 8
  %25 = alloca %"class.std::shared_ptr", align 8
  store ptr %0, ptr %4, align 8
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  %26 = load ptr, ptr %5, align 8
  %27 = getelementptr inbounds %"class.qtorch::ContractionTools", ptr %26, i32 0, i32 7
  %28 = load i8, ptr %27, align 8, !tbaa !11, !range !27, !noundef !28
  %29 = trunc i8 %28 to i1
  br i1 %29, label %39, label %30

30:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #8
  %31 = getelementptr inbounds %"class.qtorch::ContractionTools", ptr %26, i32 0, i32 0
  %32 = getelementptr inbounds %"class.qtorch::ContractionTools", ptr %26, i32 0, i32 1
  call void @_ZSt11make_sharedIN6qtorch7NetworkEJRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_EESt10shared_ptrINSt9enable_ifIXntsr8is_arrayIT_EE5valueESB_E4typeEEDpOT0_(ptr dead_on_unwind writable sret(%"class.std::shared_ptr.178") align 8 %7, ptr noundef nonnull align 8 dereferenceable(32) %31, ptr noundef nonnull align 8 dereferenceable(32) %32)
  %33 = getelementptr inbounds %"class.qtorch::ContractionTools", ptr %26, i32 0, i32 5
  %34 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt10shared_ptrIN6qtorch7NetworkEEaSEOS2_(ptr noundef nonnull align 8 dereferenceable(16) %33, ptr noundef nonnull align 8 dereferenceable(16) %7) #8
  call void @_ZNSt12__shared_ptrIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %7) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #8
  %35 = getelementptr inbounds %"class.qtorch::ContractionTools", ptr %26, i32 0, i32 5
  %36 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %35) #8
  %37 = getelementptr inbounds %"class.qtorch::ContractionTools", ptr %26, i32 0, i32 8
  %38 = load i32, ptr %37, align 4, !tbaa !29
  call void @_ZN6qtorch7Network13SetNumThreadsEi(ptr noundef nonnull align 8 dereferenceable(380) %36, i32 noundef %38) #8
  br label %39

39:                                               ; preds = %30, %3
  %40 = getelementptr inbounds %"class.qtorch::ContractionTools", ptr %26, i32 0, i32 5
  %41 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %40) #8
  %42 = call noundef zeroext i1 @_ZNK6qtorch7Network9HasFailedEv(ptr noundef nonnull align 8 dereferenceable(380) %41) #8
  br i1 %42, label %43, label %44

43:                                               ; preds = %39
  call void @_ZNSt10shared_ptrIN6qtorch7NetworkEEC2EDn(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr null) #8
  br label %232

44:                                               ; preds = %39
  br label %45

45:                                               ; preds = %206, %44
  %46 = getelementptr inbounds %"class.qtorch::ContractionTools", ptr %26, i32 0, i32 5
  %47 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %46) #8
  %48 = call noundef zeroext i1 @_ZN6qtorch7Network6IsDoneEv(ptr noundef nonnull align 8 dereferenceable(380) %47) #8
  br i1 %48, label %53, label %49

49:                                               ; preds = %45
  %50 = call noundef double @_ZN6qtorch5Timer10getElapsedEv(ptr noundef nonnull align 8 dereferenceable(17) @_ZN6qtorch8totTimerE)
  %51 = load double, ptr @_ZN6qtorch7maxTimeE, align 8, !tbaa !30
  %52 = fcmp olt double %50, %51
  br label %53

53:                                               ; preds = %49, %45
  %54 = phi i1 [ false, %45 ], [ %52, %49 ]
  br i1 %54, label %55, label %219

55:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #8
  store i64 -1, ptr %8, align 8, !tbaa !32
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #8
  %56 = getelementptr inbounds [2 x i32], ptr %9, i64 0, i64 0
  store i32 0, ptr %56, align 4, !tbaa !9
  %57 = getelementptr inbounds [2 x i32], ptr %9, i64 0, i64 1
  store i32 1, ptr %57, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #8
  %58 = getelementptr inbounds %"class.qtorch::ContractionTools", ptr %26, i32 0, i32 5
  %59 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %58) #8
  %60 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6qtorch7Network20GetUncontractedNodesEv(ptr noundef nonnull align 8 dereferenceable(380) %59) #8
  %61 = call noundef i64 @_ZNKSt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %60) #8
  %62 = sub i64 %61, 1
  %63 = trunc i64 %62 to i32
  call void @_ZNSt24uniform_int_distributionIiEC2Eii(ptr noundef nonnull align 4 dereferenceable(8) %10, i32 noundef 0, i32 noundef %63)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #8
  store i32 0, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #8
  store i32 11, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #8
  store i32 8, ptr %13, align 4, !tbaa !9
  %64 = getelementptr inbounds %"class.qtorch::ContractionTools", ptr %26, i32 0, i32 5
  %65 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %64) #8
  %66 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6qtorch7Network20GetUncontractedNodesEv(ptr noundef nonnull align 8 dereferenceable(380) %65) #8
  %67 = call noundef i64 @_ZNKSt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %66) #8
  %68 = icmp ne i64 %67, 2
  br i1 %68, label %69, label %189

69:                                               ; preds = %55
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #8
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %70

70:                                               ; preds = %185, %69
  %71 = load i32, ptr %14, align 4, !tbaa !9
  %72 = sitofp i32 %71 to double
  %73 = getelementptr inbounds %"class.qtorch::ContractionTools", ptr %26, i32 0, i32 5
  %74 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %73) #8
  %75 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6qtorch7Network20GetUncontractedNodesEv(ptr noundef nonnull align 8 dereferenceable(380) %74) #8
  %76 = call noundef i64 @_ZNKSt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %75) #8
  %77 = uitofp i64 %76 to double
  %78 = call double @log2(double noundef %77) #8
  %79 = fcmp olt double %72, %78
  br i1 %79, label %80, label %84

80:                                               ; preds = %70
  %81 = call noundef double @_ZN6qtorch5Timer10getElapsedEv(ptr noundef nonnull align 8 dereferenceable(17) @_ZN6qtorch8totTimerE)
  %82 = load double, ptr @_ZN6qtorch7maxTimeE, align 8, !tbaa !30
  %83 = fcmp olt double %81, %82
  br label %84

84:                                               ; preds = %80, %70
  %85 = phi i1 [ false, %70 ], [ %83, %80 ]
  br i1 %85, label %87, label %86

86:                                               ; preds = %84
  store i32 4, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #8
  br label %188

87:                                               ; preds = %84
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #8
  %88 = getelementptr inbounds %"class.qtorch::ContractionTools", ptr %26, i32 0, i32 6
  %89 = call noundef i32 @_ZNSt24uniform_int_distributionIiEclISt23mersenne_twister_engineImLm32ELm624ELm397ELm31ELm2567483615ELm11ELm4294967295ELm7ELm2636928640ELm15ELm4022730752ELm18ELm1812433253EEEEiRT_(ptr noundef nonnull align 4 dereferenceable(8) %10, ptr noundef nonnull align 8 dereferenceable(5000) %88)
  store i32 %89, ptr %16, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #8
  %90 = getelementptr inbounds %"class.qtorch::ContractionTools", ptr %26, i32 0, i32 6
  %91 = call noundef i32 @_ZNSt24uniform_int_distributionIiEclISt23mersenne_twister_engineImLm32ELm624ELm397ELm31ELm2567483615ELm11ELm4294967295ELm7ELm2636928640ELm15ELm4022730752ELm18ELm1812433253EEEEiRT_(ptr noundef nonnull align 4 dereferenceable(8) %10, ptr noundef nonnull align 8 dereferenceable(5000) %90)
  store i32 %91, ptr %17, align 4, !tbaa !9
  %92 = getelementptr inbounds %"class.qtorch::ContractionTools", ptr %26, i32 0, i32 5
  %93 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %92) #8
  %94 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6qtorch7Network20GetUncontractedNodesEv(ptr noundef nonnull align 8 dereferenceable(380) %93) #8
  %95 = load i32, ptr %16, align 4, !tbaa !9
  %96 = sext i32 %95 to i64
  %97 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %94, i64 noundef %96) #8
  call void @_ZNSt10shared_ptrIN6qtorch4NodeEEC2ERKS2_(ptr noundef nonnull align 8 dereferenceable(16) %18, ptr noundef nonnull align 8 dereferenceable(16) %97) #8
  %98 = getelementptr inbounds %"class.qtorch::ContractionTools", ptr %26, i32 0, i32 5
  %99 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %98) #8
  %100 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6qtorch7Network20GetUncontractedNodesEv(ptr noundef nonnull align 8 dereferenceable(380) %99) #8
  %101 = load i32, ptr %17, align 4, !tbaa !9
  %102 = sext i32 %101 to i64
  %103 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %100, i64 noundef %102) #8
  call void @_ZNSt10shared_ptrIN6qtorch4NodeEEC2ERKS2_(ptr noundef nonnull align 8 dereferenceable(16) %19, ptr noundef nonnull align 8 dereferenceable(16) %103) #8
  %104 = invoke noundef i32 @_ZN6qtorch16ContractionTools22NumberOfConnectedWiresESt10shared_ptrINS_4NodeEES3_(ptr noundef nonnull align 8 dereferenceable(10128) %26, ptr noundef %18, ptr noundef %19)
          to label %105 unwind label %136

105:                                              ; preds = %87
  %106 = icmp eq i32 %104, 0
  br i1 %106, label %131, label %107

107:                                              ; preds = %105
  %108 = getelementptr inbounds [2 x i32], ptr %9, i64 0, i64 0
  %109 = load i32, ptr %108, align 4, !tbaa !9
  %110 = load i32, ptr %16, align 4, !tbaa !9
  %111 = icmp eq i32 %109, %110
  br i1 %111, label %112, label %117

112:                                              ; preds = %107
  %113 = getelementptr inbounds [2 x i32], ptr %9, i64 0, i64 1
  %114 = load i32, ptr %113, align 4, !tbaa !9
  %115 = load i32, ptr %17, align 4, !tbaa !9
  %116 = icmp eq i32 %114, %115
  br i1 %116, label %131, label %117

117:                                              ; preds = %112, %107
  %118 = getelementptr inbounds [2 x i32], ptr %9, i64 0, i64 1
  %119 = load i32, ptr %118, align 4, !tbaa !9
  %120 = load i32, ptr %16, align 4, !tbaa !9
  %121 = icmp eq i32 %119, %120
  br i1 %121, label %122, label %127

122:                                              ; preds = %117
  %123 = getelementptr inbounds [2 x i32], ptr %9, i64 0, i64 0
  %124 = load i32, ptr %123, align 4, !tbaa !9
  %125 = load i32, ptr %17, align 4, !tbaa !9
  %126 = icmp eq i32 %124, %125
  br i1 %126, label %131, label %127

127:                                              ; preds = %122, %117
  %128 = load i32, ptr %16, align 4, !tbaa !9
  %129 = load i32, ptr %17, align 4, !tbaa !9
  %130 = icmp eq i32 %128, %129
  br label %131

131:                                              ; preds = %127, %122, %112, %105
  %132 = phi i1 [ true, %122 ], [ true, %112 ], [ true, %105 ], [ %130, %127 ]
  call void @_ZNSt12__shared_ptrIN6qtorch4NodeELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %19) #8
  call void @_ZNSt12__shared_ptrIN6qtorch4NodeELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %18) #8
  br i1 %132, label %133, label %140

133:                                              ; preds = %131
  %134 = load i32, ptr %14, align 4, !tbaa !9
  %135 = add nsw i32 %134, -1
  store i32 %135, ptr %14, align 4, !tbaa !9
  store i32 6, ptr %15, align 4
  br label %182

136:                                              ; preds = %87
  %137 = landingpad { ptr, i32 }
          cleanup
  %138 = extractvalue { ptr, i32 } %137, 0
  store ptr %138, ptr %20, align 8
  %139 = extractvalue { ptr, i32 } %137, 1
  store i32 %139, ptr %21, align 4
  call void @_ZNSt12__shared_ptrIN6qtorch4NodeELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %19) #8
  call void @_ZNSt12__shared_ptrIN6qtorch4NodeELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %18) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #8
  br label %218

140:                                              ; preds = %131
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #8
  %141 = load i32, ptr %6, align 4, !tbaa !9
  %142 = load i32, ptr %16, align 4, !tbaa !9
  %143 = load i32, ptr %17, align 4, !tbaa !9
  %144 = load i32, ptr %12, align 4, !tbaa !9
  %145 = load i32, ptr %13, align 4, !tbaa !9
  %146 = call noundef i64 @_ZN6qtorch16ContractionTools13CalculateCostEiiiii(ptr noundef nonnull align 8 dereferenceable(10128) %26, i32 noundef %141, i32 noundef %142, i32 noundef %143, i32 noundef %144, i32 noundef %145)
  store i64 %146, ptr %22, align 8, !tbaa !32
  %147 = load i64, ptr %22, align 8, !tbaa !32
  %148 = icmp eq i64 %147, -1
  br i1 %148, label %149, label %167

149:                                              ; preds = %140
  %150 = load i32, ptr %11, align 4, !tbaa !9
  %151 = add nsw i32 %150, 1
  store i32 %151, ptr %11, align 4, !tbaa !9
  %152 = load i32, ptr %14, align 4, !tbaa !9
  %153 = add nsw i32 %152, -1
  store i32 %153, ptr %14, align 4, !tbaa !9
  %154 = load i32, ptr %11, align 4, !tbaa !9
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds %"class.qtorch::ContractionTools", ptr %26, i32 0, i32 5
  %157 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %156) #8
  %158 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6qtorch7Network20GetUncontractedNodesEv(ptr noundef nonnull align 8 dereferenceable(380) %157) #8
  %159 = call noundef i64 @_ZNKSt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %158) #8
  %160 = icmp ugt i64 %155, %159
  br i1 %160, label %161, label %166

161:                                              ; preds = %149
  %162 = load i32, ptr %12, align 4, !tbaa !9
  %163 = add nsw i32 %162, 1
  store i32 %163, ptr %12, align 4, !tbaa !9
  %164 = load i32, ptr %13, align 4, !tbaa !9
  %165 = add nsw i32 %164, 1
  store i32 %165, ptr %13, align 4, !tbaa !9
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %166

166:                                              ; preds = %161, %149
  store i32 6, ptr %15, align 4
  br label %181

167:                                              ; preds = %140
  %168 = load i64, ptr %22, align 8, !tbaa !32
  %169 = load i64, ptr %8, align 8, !tbaa !32
  %170 = icmp slt i64 %168, %169
  br i1 %170, label %174, label %171

171:                                              ; preds = %167
  %172 = load i32, ptr %14, align 4, !tbaa !9
  %173 = icmp eq i32 %172, 0
  br i1 %173, label %174, label %180

174:                                              ; preds = %171, %167
  %175 = load i32, ptr %16, align 4, !tbaa !9
  %176 = getelementptr inbounds [2 x i32], ptr %9, i64 0, i64 0
  store i32 %175, ptr %176, align 4, !tbaa !9
  %177 = load i32, ptr %17, align 4, !tbaa !9
  %178 = getelementptr inbounds [2 x i32], ptr %9, i64 0, i64 1
  store i32 %177, ptr %178, align 4, !tbaa !9
  %179 = load i64, ptr %22, align 8, !tbaa !32
  store i64 %179, ptr %8, align 8, !tbaa !32
  br label %180

180:                                              ; preds = %174, %171
  store i32 0, ptr %15, align 4
  br label %181

181:                                              ; preds = %180, %166
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #8
  br label %182

182:                                              ; preds = %181, %133
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #8
  %183 = load i32, ptr %15, align 4
  switch i32 %183, label %238 [
    i32 0, label %184
    i32 6, label %185
  ]

184:                                              ; preds = %182
  br label %185

185:                                              ; preds = %184, %182
  %186 = load i32, ptr %14, align 4, !tbaa !9
  %187 = add nsw i32 %186, 1
  store i32 %187, ptr %14, align 4, !tbaa !9
  br label %70, !llvm.loop !34

188:                                              ; preds = %86
  br label %189

189:                                              ; preds = %188, %55
  %190 = getelementptr inbounds %"class.qtorch::ContractionTools", ptr %26, i32 0, i32 5
  %191 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %190) #8
  %192 = getelementptr inbounds %"class.qtorch::ContractionTools", ptr %26, i32 0, i32 5
  %193 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %192) #8
  %194 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6qtorch7Network20GetUncontractedNodesEv(ptr noundef nonnull align 8 dereferenceable(380) %193) #8
  %195 = getelementptr inbounds [2 x i32], ptr %9, i64 0, i64 0
  %196 = load i32, ptr %195, align 4, !tbaa !9
  %197 = sext i32 %196 to i64
  %198 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %194, i64 noundef %197) #8
  call void @_ZNSt10shared_ptrIN6qtorch4NodeEEC2ERKS2_(ptr noundef nonnull align 8 dereferenceable(16) %24, ptr noundef nonnull align 8 dereferenceable(16) %198) #8
  %199 = getelementptr inbounds %"class.qtorch::ContractionTools", ptr %26, i32 0, i32 5
  %200 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %199) #8
  %201 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6qtorch7Network20GetUncontractedNodesEv(ptr noundef nonnull align 8 dereferenceable(380) %200) #8
  %202 = getelementptr inbounds [2 x i32], ptr %9, i64 0, i64 1
  %203 = load i32, ptr %202, align 4, !tbaa !9
  %204 = sext i32 %203 to i64
  %205 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %201, i64 noundef %204) #8
  call void @_ZNSt10shared_ptrIN6qtorch4NodeEEC2ERKS2_(ptr noundef nonnull align 8 dereferenceable(16) %25, ptr noundef nonnull align 8 dereferenceable(16) %205) #8
  invoke void @_ZN6qtorch7Network13ContractNodesESt10shared_ptrINS_4NodeEES3_i(ptr dead_on_unwind writable sret(%"class.std::shared_ptr") align 8 %23, ptr noundef nonnull align 8 dereferenceable(380) %191, ptr noundef %24, ptr noundef %25, i32 noundef 1000000)
          to label %206 unwind label %214

206:                                              ; preds = %189
  call void @_ZNSt12__shared_ptrIN6qtorch4NodeELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %23) #8
  call void @_ZNSt12__shared_ptrIN6qtorch4NodeELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %25) #8
  call void @_ZNSt12__shared_ptrIN6qtorch4NodeELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %24) #8
  %207 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str.83)
  %208 = getelementptr inbounds %"class.qtorch::ContractionTools", ptr %26, i32 0, i32 5
  %209 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %208) #8
  %210 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6qtorch7Network20GetUncontractedNodesEv(ptr noundef nonnull align 8 dereferenceable(380) %209) #8
  %211 = call noundef i64 @_ZNKSt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %210) #8
  %212 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEm(ptr noundef nonnull align 8 dereferenceable(8) %207, i64 noundef %211)
  %213 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %212, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #8
  br label %45, !llvm.loop !36

214:                                              ; preds = %189
  %215 = landingpad { ptr, i32 }
          cleanup
  %216 = extractvalue { ptr, i32 } %215, 0
  store ptr %216, ptr %20, align 8
  %217 = extractvalue { ptr, i32 } %215, 1
  store i32 %217, ptr %21, align 4
  call void @_ZNSt12__shared_ptrIN6qtorch4NodeELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %25) #8
  call void @_ZNSt12__shared_ptrIN6qtorch4NodeELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %24) #8
  br label %218

218:                                              ; preds = %214, %136
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #8
  br label %233

219:                                              ; preds = %53
  %220 = getelementptr inbounds %"class.qtorch::ContractionTools", ptr %26, i32 0, i32 5
  %221 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %220) #8
  %222 = call noundef zeroext i1 @_ZN6qtorch7Network6IsDoneEv(ptr noundef nonnull align 8 dereferenceable(380) %221) #8
  br i1 %222, label %223, label %228

223:                                              ; preds = %219
  %224 = getelementptr inbounds %"class.qtorch::ContractionTools", ptr %26, i32 0, i32 5
  %225 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %224) #8
  %226 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK6qtorch7Network13GetFinalValueEv(ptr noundef nonnull align 8 dereferenceable(380) %225) #8
  %227 = getelementptr inbounds %"class.qtorch::ContractionTools", ptr %26, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %227, ptr align 8 %226, i64 16, i1 false), !tbaa.struct !37
  br label %230

228:                                              ; preds = %219
  %229 = call ptr @__cxa_allocate_exception(i64 8) #8
  call void @llvm.memset.p0.i64(ptr align 16 %229, i8 0, i64 8, i1 false)
  call void @_ZN6qtorch18ContractionFailureC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %229) #8
  call void @__cxa_throw(ptr %229, ptr @_ZTIN6qtorch18ContractionFailureE, ptr @_ZNSt9exceptionD2Ev) #9
  unreachable

230:                                              ; preds = %223
  %231 = getelementptr inbounds %"class.qtorch::ContractionTools", ptr %26, i32 0, i32 5
  call void @_ZNSt10shared_ptrIN6qtorch7NetworkEEC2ERKS2_(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %231) #8
  br label %232

232:                                              ; preds = %230, %43
  ret void

233:                                              ; preds = %218
  %234 = load ptr, ptr %20, align 8
  %235 = load i32, ptr %21, align 4
  %236 = insertvalue { ptr, i32 } poison, ptr %234, 0
  %237 = insertvalue { ptr, i32 } %236, i32 %235, 1
  resume { ptr, i32 } %237

238:                                              ; preds = %182
  unreachable
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt11make_sharedIN6qtorch7NetworkEJRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_EESt10shared_ptrINSt9enable_ifIXntsr8is_arrayIT_EE5valueESB_E4typeEEDpOT0_(ptr dead_on_unwind noalias writable sret(%"class.std::shared_ptr.178") align 8, ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) #1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK6qtorch7Network9HasFailedEv(ptr noundef nonnull align 8 dereferenceable(380)) #5 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6qtorch7Network6IsDoneEv(ptr noundef nonnull align 8 dereferenceable(380)) #5 align 2

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

; Function Attrs: nounwind
declare void @_ZNSt9exceptionD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #7

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt24uniform_int_distributionIiEC2Eii(ptr noundef nonnull align 4 dereferenceable(8), i32 noundef, i32 noundef) unnamed_addr #2 align 2

; Function Attrs: nounwind
declare double @log2(double noundef) #7

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNSt24uniform_int_distributionIiEclISt23mersenne_twister_engineImLm32ELm624ELm397ELm31ELm2567483615ELm11ELm4294967295ELm7ELm2636928640ELm15ELm4022730752ELm18ELm1812433253EEEEiRT_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(5000)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN6qtorch16ContractionTools22NumberOfConnectedWiresESt10shared_ptrINS_4NodeEES3_(ptr noundef nonnull align 8 dereferenceable(10128), ptr noundef, ptr noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN6qtorch16ContractionTools13CalculateCostEiiiii(ptr noundef nonnull align 8 dereferenceable(10128), i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #2 align 2

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 = { 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 #7 = { nounwind "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 #8 = { nounwind }
attributes #9 = { noreturn }

!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 = !{!12, !26, i64 10120}
!12 = !{!"_ZTSN6qtorch16ContractionToolsE", !13, i64 0, !13, i64 32, !16, i64 64, !17, i64 80, !21, i64 104, !22, i64 5104, !25, i64 5120, !26, i64 10120, !10, i64 10124}
!13 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !14, i64 0, !15, i64 8, !7, i64 16}
!14 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!"_ZTSSt7complexIdE", !7, i64 0}
!17 = !{!"_ZTSSt6vectorISt10shared_ptrIS_IS0_IN6qtorch4NodeEESaIS3_EEESaIS6_EE", !18, i64 0}
!18 = !{!"_ZTSSt12_Vector_baseISt10shared_ptrISt6vectorIS0_IN6qtorch4NodeEESaIS4_EEESaIS7_EE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseISt10shared_ptrISt6vectorIS0_IN6qtorch4NodeEESaIS4_EEESaIS7_EE12_Vector_implE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseISt10shared_ptrISt6vectorIS0_IN6qtorch4NodeEESaIS4_EEESaIS7_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!21 = !{!"_ZTSSt13random_device", !7, i64 0}
!22 = !{!"_ZTSSt10shared_ptrIN6qtorch7NetworkEE", !23, i64 0}
!23 = !{!"_ZTSSt12__shared_ptrIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0, !24, i64 8}
!24 = !{!"_ZTSSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0}
!25 = !{!"_ZTSSt23mersenne_twister_engineImLm32ELm624ELm397ELm31ELm2567483615ELm11ELm4294967295ELm7ELm2636928640ELm15ELm4022730752ELm18ELm1812433253EE", !7, i64 0, !15, i64 4992}
!26 = !{!"bool", !7, i64 0}
!27 = !{i8 0, i8 2}
!28 = !{}
!29 = !{!12, !10, i64 10124}
!30 = !{!31, !31, i64 0}
!31 = !{!"double", !7, i64 0}
!32 = !{!33, !33, i64 0}
!33 = !{!"long long", !7, i64 0}
!34 = distinct !{!34, !35}
!35 = !{!"llvm.loop.mustprogress"}
!36 = distinct !{!36, !35}
!37 = !{i64 0, i64 16, !38}
!38 = !{!7, !7, i64 0}


; 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::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.qtorch::Timer" = type <{ %"class.std::chrono::time_point", i64, i8, [7 x i8] }>
%"class.std::chrono::time_point" = type { %"class.std::chrono::duration" }
%"class.std::chrono::duration" = type { i64 }
%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }
%"class.std::shared_ptr.178" = type { %"class.std::__shared_ptr.179" }
%"class.std::__shared_ptr.179" = type { ptr, %"class.std::__shared_count" }
%"class.std::uniform_int_distribution" = type { %"struct.std::uniform_int_distribution<>::param_type" }
%"struct.std::uniform_int_distribution<>::param_type" = type { i32, i32 }

@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@_ZN6qtorch8totTimerE = external dso_local global %"class.qtorch::Timer", align 8
@_ZN6qtorch7maxTimeE = external dso_local local_unnamed_addr global double, align 8
@_ZTIN6qtorch18ContractionFailureE = external dso_local constant { ptr, ptr, ptr }, align 8
@.str.83 = external hidden unnamed_addr constant [13 x i8], align 1

; 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: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #1

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

declare void @__cxa_throw(ptr, ptr, ptr) local_unnamed_addr

; 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 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) #3

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_ZN6qtorch5Timer10getElapsedEv(ptr noundef nonnull align 8 dereferenceable(17)) local_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)) local_unnamed_addr #4 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6qtorch7Network13ContractNodesESt10shared_ptrINS_4NodeEES3_i(ptr dead_on_unwind noalias writable sret(%"class.std::shared_ptr") align 8, ptr noundef nonnull align 8 dereferenceable(380), ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #4 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 #4 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 #4 align 2

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt10shared_ptrIN6qtorch7NetworkEEaSEOS2_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6qtorch16ContractionTools26CostBasedContractionSimpleEi(ptr dead_on_unwind noalias writable sret(%"class.std::shared_ptr.178") align 8 %0, ptr noundef nonnull align 8 dereferenceable(10128) %1, i32 noundef %2) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %"class.std::shared_ptr.178", align 8
  %5 = alloca %"class.std::uniform_int_distribution", align 4
  %6 = alloca %"class.std::shared_ptr", align 8
  %7 = alloca %"class.std::shared_ptr", align 8
  %8 = alloca %"class.std::shared_ptr", align 8
  %9 = alloca %"class.std::shared_ptr", align 8
  %10 = alloca %"class.std::shared_ptr", align 8
  %11 = getelementptr inbounds i8, ptr %1, i64 10120
  %12 = load i8, ptr %11, align 8, !tbaa !5, !range !25, !noundef !26
  %13 = trunc nuw i8 %12 to i1
  br i1 %13, label %21, label %14

14:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #8
  %15 = getelementptr inbounds i8, ptr %1, i64 32
  call void @_ZSt11make_sharedIN6qtorch7NetworkEJRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_EESt10shared_ptrINSt9enable_ifIXntsr8is_arrayIT_EE5valueESB_E4typeEEDpOT0_(ptr dead_on_unwind nonnull writable sret(%"class.std::shared_ptr.178") align 8 %4, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(32) %15)
  %16 = getelementptr inbounds i8, ptr %1, i64 5104
  %17 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt10shared_ptrIN6qtorch7NetworkEEaSEOS2_(ptr noundef nonnull align 8 dereferenceable(16) %16, ptr noundef nonnull align 8 dereferenceable(16) %4) #8
  call void @_ZNSt12__shared_ptrIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %4) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #8
  %18 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %16) #8
  %19 = getelementptr inbounds i8, ptr %1, i64 10124
  %20 = load i32, ptr %19, align 4, !tbaa !27
  call void @_ZN6qtorch7Network13SetNumThreadsEi(ptr noundef nonnull align 8 dereferenceable(380) %18, i32 noundef %20) #8
  br label %21

21:                                               ; preds = %14, %3
  %22 = getelementptr inbounds i8, ptr %1, i64 5104
  %23 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %22) #8
  %24 = call noundef zeroext i1 @_ZNK6qtorch7Network9HasFailedEv(ptr noundef nonnull align 8 dereferenceable(380) %23) #8
  br i1 %24, label %28, label %.preheader62

.preheader62:                                     ; preds = %21
  %25 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %22) #8
  %26 = call noundef zeroext i1 @_ZN6qtorch7Network6IsDoneEv(ptr noundef nonnull align 8 dereferenceable(380) %25) #8
  br i1 %26, label %.critedge, label %.lr.ph83

.lr.ph83:                                         ; preds = %.preheader62
  %27 = getelementptr inbounds i8, ptr %1, i64 5120
  br label %29

28:                                               ; preds = %21
  call void @_ZNSt10shared_ptrIN6qtorch7NetworkEEC2EDn(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr null) #8
  br label %130

29:                                               ; preds = %.lr.ph83, %110
  %30 = call noundef double @_ZN6qtorch5Timer10getElapsedEv(ptr noundef nonnull align 8 dereferenceable(17) @_ZN6qtorch8totTimerE)
  %31 = load double, ptr @_ZN6qtorch7maxTimeE, align 8, !tbaa !28
  %32 = fcmp olt double %30, %31
  br i1 %32, label %33, label %.critedge

33:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #8
  %34 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %22) #8
  %35 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6qtorch7Network20GetUncontractedNodesEv(ptr noundef nonnull align 8 dereferenceable(380) %34) #8
  %36 = call noundef i64 @_ZNKSt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %35) #8
  %37 = trunc i64 %36 to i32
  %38 = add i32 %37, -1
  call void @_ZNSt24uniform_int_distributionIiEC2Eii(ptr noundef nonnull align 4 dereferenceable(8) %5, i32 noundef 0, i32 noundef %38)
  %39 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %22) #8
  %40 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6qtorch7Network20GetUncontractedNodesEv(ptr noundef nonnull align 8 dereferenceable(380) %39) #8
  %41 = call noundef i64 @_ZNKSt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %40) #8
  %.not = icmp eq i64 %41, 2
  br i1 %.not, label %.critedge2, label %.preheader

.preheader:                                       ; preds = %33
  %42 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %22) #8
  %43 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6qtorch7Network20GetUncontractedNodesEv(ptr noundef nonnull align 8 dereferenceable(380) %42) #8
  %44 = call noundef i64 @_ZNKSt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %43) #8
  %45 = uitofp i64 %44 to double
  %46 = call double @log2(double noundef %45) #8
  %47 = fcmp ogt double %46, 0.000000e+00
  br i1 %47, label %.lr.ph, label %.critedge2

.lr.ph:                                           ; preds = %.preheader, %92
  %.077 = phi i64 [ %.3, %92 ], [ -1, %.preheader ]
  %.sroa.8.075 = phi i32 [ %.sroa.8.3, %92 ], [ 1, %.preheader ]
  %.sroa.0.073 = phi i32 [ %.sroa.0.3, %92 ], [ 0, %.preheader ]
  %.04171 = phi i32 [ %93, %92 ], [ 0, %.preheader ]
  %.04469 = phi i32 [ %.347, %92 ], [ 8, %.preheader ]
  %.04867 = phi i32 [ %.351, %92 ], [ 11, %.preheader ]
  %.05265 = phi i32 [ %.355, %92 ], [ 0, %.preheader ]
  %48 = call noundef double @_ZN6qtorch5Timer10getElapsedEv(ptr noundef nonnull align 8 dereferenceable(17) @_ZN6qtorch8totTimerE)
  %49 = load double, ptr @_ZN6qtorch7maxTimeE, align 8, !tbaa !28
  %50 = fcmp olt double %48, %49
  br i1 %50, label %51, label %.critedge2

51:                                               ; preds = %.lr.ph
  %52 = call noundef i32 @_ZNSt24uniform_int_distributionIiEclISt23mersenne_twister_engineImLm32ELm624ELm397ELm31ELm2567483615ELm11ELm4294967295ELm7ELm2636928640ELm15ELm4022730752ELm18ELm1812433253EEEEiRT_(ptr noundef nonnull align 4 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(5000) %27)
  %53 = call noundef i32 @_ZNSt24uniform_int_distributionIiEclISt23mersenne_twister_engineImLm32ELm624ELm397ELm31ELm2567483615ELm11ELm4294967295ELm7ELm2636928640ELm15ELm4022730752ELm18ELm1812433253EEEEiRT_(ptr noundef nonnull align 4 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(5000) %27)
  %54 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %22) #8
  %55 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6qtorch7Network20GetUncontractedNodesEv(ptr noundef nonnull align 8 dereferenceable(380) %54) #8
  %56 = sext i32 %52 to i64
  %57 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %55, i64 noundef %56) #8
  call void @_ZNSt10shared_ptrIN6qtorch4NodeEEC2ERKS2_(ptr noundef nonnull align 8 dereferenceable(16) %6, ptr noundef nonnull align 8 dereferenceable(16) %57) #8
  %58 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %22) #8
  %59 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6qtorch7Network20GetUncontractedNodesEv(ptr noundef nonnull align 8 dereferenceable(380) %58) #8
  %60 = sext i32 %53 to i64
  %61 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %59, i64 noundef %60) #8
  call void @_ZNSt10shared_ptrIN6qtorch4NodeEEC2ERKS2_(ptr noundef nonnull align 8 dereferenceable(16) %7, ptr noundef nonnull align 8 dereferenceable(16) %61) #8
  %62 = invoke noundef i32 @_ZN6qtorch16ContractionTools22NumberOfConnectedWiresESt10shared_ptrINS_4NodeEES3_(ptr noundef nonnull align 8 dereferenceable(10128) %1, ptr noundef nonnull %6, ptr noundef nonnull %7)
          to label %63 unwind label %75

63:                                               ; preds = %51
  %64 = icmp eq i32 %62, 0
  br i1 %64, label %.critedge4, label %65

65:                                               ; preds = %63
  %66 = icmp eq i32 %.sroa.0.073, %52
  %67 = icmp eq i32 %.sroa.8.075, %53
  %or.cond60 = select i1 %66, i1 %67, i1 false
  br i1 %or.cond60, label %.critedge4, label %68

68:                                               ; preds = %65
  %69 = icmp eq i32 %.sroa.8.075, %52
  %70 = icmp eq i32 %.sroa.0.073, %53
  %or.cond61 = select i1 %69, i1 %70, i1 false
  br i1 %or.cond61, label %.critedge4, label %71

71:                                               ; preds = %68
  %72 = icmp eq i32 %52, %53
  call void @_ZNSt12__shared_ptrIN6qtorch4NodeELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %7) #8
  call void @_ZNSt12__shared_ptrIN6qtorch4NodeELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %6) #8
  br i1 %72, label %73, label %77

.critedge4:                                       ; preds = %68, %65, %63
  call void @_ZNSt12__shared_ptrIN6qtorch4NodeELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %7) #8
  call void @_ZNSt12__shared_ptrIN6qtorch4NodeELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %6) #8
  br label %73

73:                                               ; preds = %.critedge4, %71
  %74 = add nsw i32 %.04171, -1
  br label %92

75:                                               ; preds = %51
  %76 = landingpad { ptr, i32 }
          cleanup
  br label %121

77:                                               ; preds = %71
  %78 = call noundef i64 @_ZN6qtorch16ContractionTools13CalculateCostEiiiii(ptr noundef nonnull align 8 dereferenceable(10128) %1, i32 noundef %2, i32 noundef %52, i32 noundef %53, i32 noundef %.04867, i32 noundef %.04469)
  %79 = icmp eq i64 %78, -1
  br i1 %79, label %80, label %89

80:                                               ; preds = %77
  %81 = add nsw i32 %.05265, 1
  %82 = add nsw i32 %.04171, -1
  %83 = sext i32 %81 to i64
  %84 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %22) #8
  %85 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6qtorch7Network20GetUncontractedNodesEv(ptr noundef nonnull align 8 dereferenceable(380) %84) #8
  %86 = call noundef i64 @_ZNKSt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %85) #8
  %87 = icmp ult i64 %86, %83
  %.153 = select i1 %87, i32 0, i32 %81
  %88 = zext i1 %87 to i32
  %.149 = add nsw i32 %.04867, %88
  %.145 = add nsw i32 %.04469, %88
  br label %92

89:                                               ; preds = %77
  %90 = icmp slt i64 %78, %.077
  %91 = icmp eq i32 %.04171, 0
  %or.cond = select i1 %90, i1 true, i1 %91
  %.sroa.0.1 = select i1 %or.cond, i32 %52, i32 %.sroa.0.073
  %.sroa.8.1 = select i1 %or.cond, i32 %53, i32 %.sroa.8.075
  %.1 = select i1 %or.cond, i64 %78, i64 %.077
  br label %92

92:                                               ; preds = %80, %89, %73
  %.355 = phi i32 [ %.05265, %73 ], [ %.153, %80 ], [ %.05265, %89 ]
  %.351 = phi i32 [ %.04867, %73 ], [ %.149, %80 ], [ %.04867, %89 ]
  %.347 = phi i32 [ %.04469, %73 ], [ %.145, %80 ], [ %.04469, %89 ]
  %.243 = phi i32 [ %74, %73 ], [ %82, %80 ], [ %.04171, %89 ]
  %.sroa.0.3 = phi i32 [ %.sroa.0.073, %73 ], [ %.sroa.0.073, %80 ], [ %.sroa.0.1, %89 ]
  %.sroa.8.3 = phi i32 [ %.sroa.8.075, %73 ], [ %.sroa.8.075, %80 ], [ %.sroa.8.1, %89 ]
  %.3 = phi i64 [ %.077, %73 ], [ %.077, %80 ], [ %.1, %89 ]
  %93 = add nsw i32 %.243, 1
  %94 = sitofp i32 %93 to double
  %95 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %22) #8
  %96 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6qtorch7Network20GetUncontractedNodesEv(ptr noundef nonnull align 8 dereferenceable(380) %95) #8
  %97 = call noundef i64 @_ZNKSt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %96) #8
  %98 = uitofp i64 %97 to double
  %99 = call double @log2(double noundef %98) #8
  %100 = fcmp ogt double %99, %94
  br i1 %100, label %.lr.ph, label %.critedge2, !llvm.loop !30

.critedge2:                                       ; preds = %92, %.lr.ph, %.preheader, %33
  %.sroa.0.4 = phi i32 [ 0, %33 ], [ 0, %.preheader ], [ %.sroa.0.3, %92 ], [ %.sroa.0.073, %.lr.ph ]
  %.sroa.8.4 = phi i32 [ 1, %33 ], [ 1, %.preheader ], [ %.sroa.8.3, %92 ], [ %.sroa.8.075, %.lr.ph ]
  %101 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %22) #8
  %102 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %22) #8
  %103 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6qtorch7Network20GetUncontractedNodesEv(ptr noundef nonnull align 8 dereferenceable(380) %102) #8
  %104 = sext i32 %.sroa.0.4 to i64
  %105 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %103, i64 noundef %104) #8
  call void @_ZNSt10shared_ptrIN6qtorch4NodeEEC2ERKS2_(ptr noundef nonnull align 8 dereferenceable(16) %9, ptr noundef nonnull align 8 dereferenceable(16) %105) #8
  %106 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %22) #8
  %107 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6qtorch7Network20GetUncontractedNodesEv(ptr noundef nonnull align 8 dereferenceable(380) %106) #8
  %108 = sext i32 %.sroa.8.4 to i64
  %109 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %107, i64 noundef %108) #8
  call void @_ZNSt10shared_ptrIN6qtorch4NodeEEC2ERKS2_(ptr noundef nonnull align 8 dereferenceable(16) %10, ptr noundef nonnull align 8 dereferenceable(16) %109) #8
  invoke void @_ZN6qtorch7Network13ContractNodesESt10shared_ptrINS_4NodeEES3_i(ptr dead_on_unwind nonnull writable sret(%"class.std::shared_ptr") align 8 %8, ptr noundef nonnull align 8 dereferenceable(380) %101, ptr noundef nonnull %9, ptr noundef nonnull %10, i32 noundef 1000000)
          to label %110 unwind label %119

110:                                              ; preds = %.critedge2
  call void @_ZNSt12__shared_ptrIN6qtorch4NodeELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %8) #8
  call void @_ZNSt12__shared_ptrIN6qtorch4NodeELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %10) #8
  call void @_ZNSt12__shared_ptrIN6qtorch4NodeELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %9) #8
  %111 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @.str.83)
  %112 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %22) #8
  %113 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6qtorch7Network20GetUncontractedNodesEv(ptr noundef nonnull align 8 dereferenceable(380) %112) #8
  %114 = call noundef i64 @_ZNKSt6vectorISt10shared_ptrIN6qtorch4NodeEESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %113) #8
  %115 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEm(ptr noundef nonnull align 8 dereferenceable(8) %111, i64 noundef %114)
  %116 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %115, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #8
  %117 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %22) #8
  %118 = call noundef zeroext i1 @_ZN6qtorch7Network6IsDoneEv(ptr noundef nonnull align 8 dereferenceable(380) %117) #8
  br i1 %118, label %.critedge, label %29, !llvm.loop !32

119:                                              ; preds = %.critedge2
  %120 = landingpad { ptr, i32 }
          cleanup
  br label %121

121:                                              ; preds = %119, %75
  %.sink85 = phi ptr [ %10, %119 ], [ %7, %75 ]
  %.sink = phi ptr [ %9, %119 ], [ %6, %75 ]
  %.pn = phi { ptr, i32 } [ %120, %119 ], [ %76, %75 ]
  call void @_ZNSt12__shared_ptrIN6qtorch4NodeELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %.sink85) #8
  call void @_ZNSt12__shared_ptrIN6qtorch4NodeELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %.sink) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #8
  resume { ptr, i32 } %.pn

.critedge:                                        ; preds = %29, %110, %.preheader62
  %122 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %22) #8
  %123 = call noundef zeroext i1 @_ZN6qtorch7Network6IsDoneEv(ptr noundef nonnull align 8 dereferenceable(380) %122) #8
  br i1 %123, label %124, label %128

124:                                              ; preds = %.critedge
  %125 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %22) #8
  %126 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK6qtorch7Network13GetFinalValueEv(ptr noundef nonnull align 8 dereferenceable(380) %125) #8
  %127 = getelementptr inbounds i8, ptr %1, i64 64
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %127, ptr noundef nonnull align 8 dereferenceable(16) %126, i64 16, i1 false), !tbaa.struct !33
  call void @_ZNSt10shared_ptrIN6qtorch7NetworkEEC2ERKS2_(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %22) #8
  br label %130

128:                                              ; preds = %.critedge
  %129 = call ptr @__cxa_allocate_exception(i64 8) #8
  store i64 0, ptr %129, align 16
  call void @_ZN6qtorch18ContractionFailureC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %129) #8
  call void @__cxa_throw(ptr nonnull %129, ptr nonnull @_ZTIN6qtorch18ContractionFailureE, ptr nonnull @_ZNSt9exceptionD2Ev) #9
  unreachable

130:                                              ; preds = %124, %28
  ret void
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK6qtorch7Network9HasFailedEv(ptr noundef nonnull align 8 dereferenceable(380)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6qtorch7Network6IsDoneEv(ptr noundef nonnull align 8 dereferenceable(380)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNK6qtorch7Network13GetFinalValueEv(ptr noundef nonnull align 8 dereferenceable(380)) local_unnamed_addr #4 align 2

; Function Attrs: nounwind
declare void @_ZNSt9exceptionD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #6

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt24uniform_int_distributionIiEC2Eii(ptr noundef nonnull align 4 dereferenceable(8), i32 noundef, i32 noundef) unnamed_addr #2 align 2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @log2(double noundef) local_unnamed_addr #7

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNSt24uniform_int_distributionIiEclISt23mersenne_twister_engineImLm32ELm624ELm397ELm31ELm2567483615ELm11ELm4294967295ELm7ELm2636928640ELm15ELm4022730752ELm18ELm1812433253EEEEiRT_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(5000)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN6qtorch16ContractionTools22NumberOfConnectedWiresESt10shared_ptrINS_4NodeEES3_(ptr noundef nonnull align 8 dereferenceable(10128), ptr noundef, ptr noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN6qtorch16ContractionTools13CalculateCostEiiiii(ptr noundef nonnull align 8 dereferenceable(10128), i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2 align 2

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 = { 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 "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 #7 = { mustprogress nofree nounwind willreturn memory(write) "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 #8 = { nounwind }
attributes #9 = { noreturn }

!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, !23, i64 10120}
!6 = !{!"_ZTSN6qtorch16ContractionToolsE", !7, i64 0, !7, i64 32, !13, i64 64, !14, i64 80, !18, i64 104, !19, i64 5104, !22, i64 5120, !23, i64 10120, !24, i64 10124}
!7 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !8, i64 0, !12, i64 8, !10, i64 16}
!8 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !9, i64 0}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"long", !10, i64 0}
!13 = !{!"_ZTSSt7complexIdE", !10, i64 0}
!14 = !{!"_ZTSSt6vectorISt10shared_ptrIS_IS0_IN6qtorch4NodeEESaIS3_EEESaIS6_EE", !15, i64 0}
!15 = !{!"_ZTSSt12_Vector_baseISt10shared_ptrISt6vectorIS0_IN6qtorch4NodeEESaIS4_EEESaIS7_EE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseISt10shared_ptrISt6vectorIS0_IN6qtorch4NodeEESaIS4_EEESaIS7_EE12_Vector_implE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseISt10shared_ptrISt6vectorIS0_IN6qtorch4NodeEESaIS4_EEESaIS7_EE17_Vector_impl_dataE", !9, i64 0, !9, i64 8, !9, i64 16}
!18 = !{!"_ZTSSt13random_device", !10, i64 0}
!19 = !{!"_ZTSSt10shared_ptrIN6qtorch7NetworkEE", !20, i64 0}
!20 = !{!"_ZTSSt12__shared_ptrIN6qtorch7NetworkELN9__gnu_cxx12_Lock_policyE2EE", !9, i64 0, !21, i64 8}
!21 = !{!"_ZTSSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EE", !9, i64 0}
!22 = !{!"_ZTSSt23mersenne_twister_engineImLm32ELm624ELm397ELm31ELm2567483615ELm11ELm4294967295ELm7ELm2636928640ELm15ELm4022730752ELm18ELm1812433253EE", !10, i64 0, !12, i64 4992}
!23 = !{!"bool", !10, i64 0}
!24 = !{!"int", !10, i64 0}
!25 = !{i8 0, i8 2}
!26 = !{}
!27 = !{!6, !24, i64 10124}
!28 = !{!29, !29, i64 0}
!29 = !{!"double", !10, i64 0}
!30 = distinct !{!30, !31}
!31 = !{!"llvm.loop.mustprogress"}
!32 = distinct !{!32, !31}
!33 = !{i64 0, i64 16, !34}
!34 = !{!10, !10, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass