; LLVM IR from xirc/cp-algorithm :: atcoder/abc040/D (main)

; 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_istream" = type { ptr, i64, %"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.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<edge, std::allocator<edge>>::_Vector_impl" }
%"struct.std::_Vector_base<edge, std::allocator<edge>>::_Vector_impl" = type { %"struct.std::_Vector_base<edge, std::allocator<edge>>::_Vector_impl_data" }
%"struct.std::_Vector_base<edge, std::allocator<edge>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<query, std::allocator<query>>::_Vector_impl" }
%"struct.std::_Vector_base<query, std::allocator<query>>::_Vector_impl" = type { %"struct.std::_Vector_base<query, std::allocator<query>>::_Vector_impl_data" }
%"struct.std::_Vector_base<query, std::allocator<query>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.edge = type { i32, i32, i32 }
%struct.query = type { i32, i32, i32, i32 }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }
%class.anon = type { i8 }
%"class.__gnu_cxx::__normal_iterator.5" = type { ptr }
%class.anon.6 = type { i8 }
%class.UnionFindTree = type { i64, %"class.std::vector.8" }
%"class.std::vector.8" = type { %"struct.std::_Vector_base.9" }
%"struct.std::_Vector_base.9" = type { %"struct.std::_Vector_base<UnionFindTree::node, std::allocator<UnionFindTree::node>>::_Vector_impl" }
%"struct.std::_Vector_base<UnionFindTree::node, std::allocator<UnionFindTree::node>>::_Vector_impl" = type { %"struct.std::_Vector_base<UnionFindTree::node, std::allocator<UnionFindTree::node>>::_Vector_impl_data" }
%"struct.std::_Vector_base<UnionFindTree::node, std::allocator<UnionFindTree::node>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.UnionFindTree::node" = type { i64, i64, i64 }
%class.anon.13 = type { i8 }

@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca %"class.std::vector", align 8
  %6 = alloca %"class.std::vector.0", align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca %struct.edge, align 4
  %10 = alloca i32, align 4
  %11 = alloca %struct.query, align 4
  %12 = alloca i32, align 4
  %13 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %14 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %15 = alloca %class.anon, align 1
  %16 = alloca %"class.__gnu_cxx::__normal_iterator.5", align 8
  %17 = alloca %"class.__gnu_cxx::__normal_iterator.5", align 8
  %18 = alloca %class.anon.6, align 1
  %19 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %20 = alloca %class.UnionFindTree, align 8
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %25 = alloca %"struct.UnionFindTree::node", align 8
  %26 = alloca %"class.__gnu_cxx::__normal_iterator.5", align 8
  %27 = alloca %"class.__gnu_cxx::__normal_iterator.5", align 8
  %28 = alloca %class.anon.13, align 1
  %29 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %30 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %31 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %32 = getelementptr i8, ptr %31, i64 -24
  %33 = load i64, ptr %32, align 8
  %34 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %33
  %35 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %34, ptr noundef null)
  %36 = load ptr, ptr @_ZSt4cout, align 8, !tbaa !5
  %37 = getelementptr i8, ptr %36, i64 -24
  %38 = load i64, ptr %37, align 8
  %39 = getelementptr inbounds i8, ptr @_ZSt4cout, i64 %38
  %40 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %39, ptr noundef null)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  call void @llvm.lifetime.start.p0(i64 24, ptr %5) #7
  call void @_ZNSt6vectorIZ4mainE4edgeSaIS0_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %5) #7
  call void @llvm.lifetime.start.p0(i64 24, ptr %6) #7
  call void @_ZNSt6vectorIZ4mainE5querySaIS0_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %6) #7
  %41 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %2)
          to label %42 unwind label %56

42:                                               ; preds = %0
  %43 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %41, ptr noundef nonnull align 4 dereferenceable(4) %3)
          to label %44 unwind label %56

44:                                               ; preds = %42
  %45 = load i32, ptr %3, align 4, !tbaa !8
  %46 = sext i32 %45 to i64
  call void @llvm.lifetime.start.p0(i64 12, ptr %9) #7
  %47 = getelementptr inbounds %struct.edge, ptr %9, i32 0, i32 0
  store i32 0, ptr %47, align 4, !tbaa !11
  %48 = getelementptr inbounds %struct.edge, ptr %9, i32 0, i32 1
  store i32 0, ptr %48, align 4, !tbaa !13
  %49 = getelementptr inbounds %struct.edge, ptr %9, i32 0, i32 2
  store i32 0, ptr %49, align 4, !tbaa !14
  invoke void @_ZNSt6vectorIZ4mainE4edgeSaIS0_EE6assignEmRKS0_(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %46, ptr noundef nonnull align 4 dereferenceable(12) %9)
          to label %50 unwind label %60

50:                                               ; preds = %44
  call void @llvm.lifetime.end.p0(i64 12, ptr %9) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  store i32 0, ptr %10, align 4, !tbaa !8
  br label %51

51:                                               ; preds = %95, %50
  %52 = load i32, ptr %10, align 4, !tbaa !8
  %53 = load i32, ptr %3, align 4, !tbaa !8
  %54 = icmp slt i32 %52, %53
  br i1 %54, label %64, label %55

55:                                               ; preds = %51
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  br label %102

56:                                               ; preds = %161, %152, %102, %42, %0
  %57 = landingpad { ptr, i32 }
          cleanup
  %58 = extractvalue { ptr, i32 } %57, 0
  store ptr %58, ptr %7, align 8
  %59 = extractvalue { ptr, i32 } %57, 1
  store i32 %59, ptr %8, align 4
  br label %283

60:                                               ; preds = %44
  %61 = landingpad { ptr, i32 }
          cleanup
  %62 = extractvalue { ptr, i32 } %61, 0
  store ptr %62, ptr %7, align 8
  %63 = extractvalue { ptr, i32 } %61, 1
  store i32 %63, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 12, ptr %9) #7
  br label %283

64:                                               ; preds = %51
  %65 = load i32, ptr %10, align 4, !tbaa !8
  %66 = sext i32 %65 to i64
  %67 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorIZ4mainE4edgeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %66) #7
  %68 = getelementptr inbounds %struct.edge, ptr %67, i32 0, i32 0
  %69 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %68)
          to label %70 unwind label %98

70:                                               ; preds = %64
  %71 = load i32, ptr %10, align 4, !tbaa !8
  %72 = sext i32 %71 to i64
  %73 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorIZ4mainE4edgeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %72) #7
  %74 = getelementptr inbounds %struct.edge, ptr %73, i32 0, i32 1
  %75 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %69, ptr noundef nonnull align 4 dereferenceable(4) %74)
          to label %76 unwind label %98

76:                                               ; preds = %70
  %77 = load i32, ptr %10, align 4, !tbaa !8
  %78 = sext i32 %77 to i64
  %79 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorIZ4mainE4edgeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %78) #7
  %80 = getelementptr inbounds %struct.edge, ptr %79, i32 0, i32 2
  %81 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %75, ptr noundef nonnull align 4 dereferenceable(4) %80)
          to label %82 unwind label %98

82:                                               ; preds = %76
  %83 = load i32, ptr %10, align 4, !tbaa !8
  %84 = sext i32 %83 to i64
  %85 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorIZ4mainE4edgeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %84) #7
  %86 = getelementptr inbounds %struct.edge, ptr %85, i32 0, i32 0
  %87 = load i32, ptr %86, align 4, !tbaa !11
  %88 = add nsw i32 %87, -1
  store i32 %88, ptr %86, align 4, !tbaa !11
  %89 = load i32, ptr %10, align 4, !tbaa !8
  %90 = sext i32 %89 to i64
  %91 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorIZ4mainE4edgeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %90) #7
  %92 = getelementptr inbounds %struct.edge, ptr %91, i32 0, i32 1
  %93 = load i32, ptr %92, align 4, !tbaa !13
  %94 = add nsw i32 %93, -1
  store i32 %94, ptr %92, align 4, !tbaa !13
  br label %95

95:                                               ; preds = %82
  %96 = load i32, ptr %10, align 4, !tbaa !8
  %97 = add nsw i32 %96, 1
  store i32 %97, ptr %10, align 4, !tbaa !8
  br label %51, !llvm.loop !15

98:                                               ; preds = %76, %70, %64
  %99 = landingpad { ptr, i32 }
          cleanup
  %100 = extractvalue { ptr, i32 } %99, 0
  store ptr %100, ptr %7, align 8
  %101 = extractvalue { ptr, i32 } %99, 1
  store i32 %101, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  br label %283

102:                                              ; preds = %55
  %103 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %4)
          to label %104 unwind label %56

104:                                              ; preds = %102
  %105 = load i32, ptr %4, align 4, !tbaa !8
  %106 = sext i32 %105 to i64
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #7
  %107 = getelementptr inbounds %struct.query, ptr %11, i32 0, i32 0
  store i32 0, ptr %107, align 4, !tbaa !17
  %108 = getelementptr inbounds %struct.query, ptr %11, i32 0, i32 1
  store i32 0, ptr %108, align 4, !tbaa !19
  %109 = getelementptr inbounds %struct.query, ptr %11, i32 0, i32 2
  store i32 0, ptr %109, align 4, !tbaa !20
  %110 = getelementptr inbounds %struct.query, ptr %11, i32 0, i32 3
  store i32 0, ptr %110, align 4, !tbaa !21
  invoke void @_ZNSt6vectorIZ4mainE5querySaIS0_EE6assignEmRKS0_(ptr noundef nonnull align 8 dereferenceable(24) %6, i64 noundef %106, ptr noundef nonnull align 4 dereferenceable(16) %11)
          to label %111 unwind label %117

111:                                              ; preds = %104
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  store i32 0, ptr %12, align 4, !tbaa !8
  br label %112

112:                                              ; preds = %145, %111
  %113 = load i32, ptr %12, align 4, !tbaa !8
  %114 = load i32, ptr %4, align 4, !tbaa !8
  %115 = icmp slt i32 %113, %114
  br i1 %115, label %121, label %116

116:                                              ; preds = %112
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  br label %152

117:                                              ; preds = %104
  %118 = landingpad { ptr, i32 }
          cleanup
  %119 = extractvalue { ptr, i32 } %118, 0
  store ptr %119, ptr %7, align 8
  %120 = extractvalue { ptr, i32 } %118, 1
  store i32 %120, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #7
  br label %283

121:                                              ; preds = %112
  %122 = load i32, ptr %12, align 4, !tbaa !8
  %123 = load i32, ptr %12, align 4, !tbaa !8
  %124 = sext i32 %123 to i64
  %125 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNSt6vectorIZ4mainE5querySaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %6, i64 noundef %124) #7
  %126 = getelementptr inbounds %struct.query, ptr %125, i32 0, i32 0
  store i32 %122, ptr %126, align 4, !tbaa !17
  %127 = load i32, ptr %12, align 4, !tbaa !8
  %128 = sext i32 %127 to i64
  %129 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNSt6vectorIZ4mainE5querySaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %6, i64 noundef %128) #7
  %130 = getelementptr inbounds %struct.query, ptr %129, i32 0, i32 1
  %131 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %130)
          to label %132 unwind label %148

132:                                              ; preds = %121
  %133 = load i32, ptr %12, align 4, !tbaa !8
  %134 = sext i32 %133 to i64
  %135 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNSt6vectorIZ4mainE5querySaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %6, i64 noundef %134) #7
  %136 = getelementptr inbounds %struct.query, ptr %135, i32 0, i32 2
  %137 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %131, ptr noundef nonnull align 4 dereferenceable(4) %136)
          to label %138 unwind label %148

138:                                              ; preds = %132
  %139 = load i32, ptr %12, align 4, !tbaa !8
  %140 = sext i32 %139 to i64
  %141 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNSt6vectorIZ4mainE5querySaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %6, i64 noundef %140) #7
  %142 = getelementptr inbounds %struct.query, ptr %141, i32 0, i32 1
  %143 = load i32, ptr %142, align 4, !tbaa !19
  %144 = add nsw i32 %143, -1
  store i32 %144, ptr %142, align 4, !tbaa !19
  br label %145

145:                                              ; preds = %138
  %146 = load i32, ptr %12, align 4, !tbaa !8
  %147 = add nsw i32 %146, 1
  store i32 %147, ptr %12, align 4, !tbaa !8
  br label %112, !llvm.loop !22

148:                                              ; preds = %132, %121
  %149 = landingpad { ptr, i32 }
          cleanup
  %150 = extractvalue { ptr, i32 } %149, 0
  store ptr %150, ptr %7, align 8
  %151 = extractvalue { ptr, i32 } %149, 1
  store i32 %151, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  br label %283

152:                                              ; preds = %116
  %153 = call ptr @_ZNSt6vectorIZ4mainE4edgeSaIS0_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %5) #7
  %154 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %13, i32 0, i32 0
  store ptr %153, ptr %154, align 8
  %155 = call ptr @_ZNSt6vectorIZ4mainE4edgeSaIS0_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %5) #7
  %156 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %14, i32 0, i32 0
  store ptr %155, ptr %156, align 8
  %157 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %13, i32 0, i32 0
  %158 = load ptr, ptr %157, align 8
  %159 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %14, i32 0, i32 0
  %160 = load ptr, ptr %159, align 8
  invoke void @"_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPZ4mainE4edgeSt6vectorIS2_SaIS2_EEEEZ4mainE3$_0EvT_S9_T0_"(ptr %158, ptr %160)
          to label %161 unwind label %56

161:                                              ; preds = %152
  %162 = call ptr @_ZNSt6vectorIZ4mainE5querySaIS0_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %6) #7
  %163 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator.5", ptr %16, i32 0, i32 0
  store ptr %162, ptr %163, align 8
  %164 = call ptr @_ZNSt6vectorIZ4mainE5querySaIS0_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %6) #7
  %165 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator.5", ptr %17, i32 0, i32 0
  store ptr %164, ptr %165, align 8
  %166 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator.5", ptr %16, i32 0, i32 0
  %167 = load ptr, ptr %166, align 8
  %168 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator.5", ptr %17, i32 0, i32 0
  %169 = load ptr, ptr %168, align 8
  invoke void @"_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPZ4mainE5querySt6vectorIS2_SaIS2_EEEEZ4mainE3$_1EvT_S9_T0_"(ptr %167, ptr %169)
          to label %170 unwind label %56

170:                                              ; preds = %161
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #7
  %171 = call ptr @_ZNSt6vectorIZ4mainE4edgeSaIS0_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %5) #7
  %172 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %19, i32 0, i32 0
  store ptr %171, ptr %172, align 8
  call void @llvm.lifetime.start.p0(i64 32, ptr %20) #7
  %173 = load i32, ptr %2, align 4, !tbaa !8
  %174 = sext i32 %173 to i64
  invoke void @_ZN13UnionFindTreeC2Em(ptr noundef nonnull align 8 dereferenceable(32) %20, i64 noundef %174)
          to label %175 unwind label %181

175:                                              ; preds = %170
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #7
  store i32 0, ptr %21, align 4, !tbaa !8
  br label %176

176:                                              ; preds = %235, %175
  %177 = load i32, ptr %21, align 4, !tbaa !8
  %178 = load i32, ptr %4, align 4, !tbaa !8
  %179 = icmp slt i32 %177, %178
  br i1 %179, label %185, label %180

180:                                              ; preds = %176
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #7
  br label %243

181:                                              ; preds = %170
  %182 = landingpad { ptr, i32 }
          cleanup
  %183 = extractvalue { ptr, i32 } %182, 0
  store ptr %183, ptr %7, align 8
  %184 = extractvalue { ptr, i32 } %182, 1
  store i32 %184, ptr %8, align 4
  br label %282

185:                                              ; preds = %176
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #7
  %186 = load i32, ptr %21, align 4, !tbaa !8
  %187 = sext i32 %186 to i64
  %188 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNSt6vectorIZ4mainE5querySaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %6, i64 noundef %187) #7
  %189 = getelementptr inbounds %struct.query, ptr %188, i32 0, i32 1
  %190 = load i32, ptr %189, align 4, !tbaa !19
  store i32 %190, ptr %22, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #7
  %191 = load i32, ptr %21, align 4, !tbaa !8
  %192 = sext i32 %191 to i64
  %193 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNSt6vectorIZ4mainE5querySaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %6, i64 noundef %192) #7
  %194 = getelementptr inbounds %struct.query, ptr %193, i32 0, i32 2
  %195 = load i32, ptr %194, align 4, !tbaa !20
  store i32 %195, ptr %23, align 4, !tbaa !8
  br label %196

196:                                              ; preds = %218, %185
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #7
  %197 = call ptr @_ZNSt6vectorIZ4mainE4edgeSaIS0_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %5) #7
  %198 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %24, i32 0, i32 0
  store ptr %197, ptr %198, align 8
  %199 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPZ4mainE4edgeSt6vectorIS1_SaIS1_EEEEbRKNS_17__normal_iteratorIT_T0_EESB_(ptr noundef nonnull align 8 dereferenceable(8) %19, ptr noundef nonnull align 8 dereferenceable(8) %24) #7
  br i1 %199, label %200, label %206

200:                                              ; preds = %196
  %201 = call noundef ptr @_ZNK9__gnu_cxx17__normal_iteratorIPZ4mainE4edgeSt6vectorIS1_SaIS1_EEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %19) #7
  %202 = getelementptr inbounds %struct.edge, ptr %201, i32 0, i32 2
  %203 = load i32, ptr %202, align 4, !tbaa !14
  %204 = load i32, ptr %23, align 4, !tbaa !8
  %205 = icmp sgt i32 %203, %204
  br label %206

206:                                              ; preds = %200, %196
  %207 = phi i1 [ false, %196 ], [ %205, %200 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #7
  br i1 %207, label %208, label %224

208:                                              ; preds = %206
  %209 = call noundef ptr @_ZNK9__gnu_cxx17__normal_iteratorIPZ4mainE4edgeSt6vectorIS1_SaIS1_EEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %19) #7
  %210 = getelementptr inbounds %struct.edge, ptr %209, i32 0, i32 0
  %211 = load i32, ptr %210, align 4, !tbaa !11
  %212 = sext i32 %211 to i64
  %213 = call noundef ptr @_ZNK9__gnu_cxx17__normal_iteratorIPZ4mainE4edgeSt6vectorIS1_SaIS1_EEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %19) #7
  %214 = getelementptr inbounds %struct.edge, ptr %213, i32 0, i32 1
  %215 = load i32, ptr %214, align 4, !tbaa !13
  %216 = sext i32 %215 to i64
  %217 = invoke noundef zeroext i1 @_ZN13UnionFindTree5uniteEmm(ptr noundef nonnull align 8 dereferenceable(32) %20, i64 noundef %212, i64 noundef %216)
          to label %218 unwind label %220

218:                                              ; preds = %208
  %219 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN9__gnu_cxx17__normal_iteratorIPZ4mainE4edgeSt6vectorIS1_SaIS1_EEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %19) #7
  br label %196, !llvm.loop !23

220:                                              ; preds = %208
  %221 = landingpad { ptr, i32 }
          cleanup
  %222 = extractvalue { ptr, i32 } %221, 0
  store ptr %222, ptr %7, align 8
  %223 = extractvalue { ptr, i32 } %221, 1
  store i32 %223, ptr %8, align 4
  br label %242

224:                                              ; preds = %206
  call void @llvm.lifetime.start.p0(i64 24, ptr %25) #7
  %225 = load i32, ptr %22, align 4, !tbaa !8
  %226 = sext i32 %225 to i64
  invoke void @_ZN13UnionFindTree4findEm(ptr dead_on_unwind writable sret(%"struct.UnionFindTree::node") align 8 %25, ptr noundef nonnull align 8 dereferenceable(32) %20, i64 noundef %226)
          to label %227 unwind label %238

227:                                              ; preds = %224
  %228 = getelementptr inbounds %"struct.UnionFindTree::node", ptr %25, i32 0, i32 2
  %229 = load i64, ptr %228, align 8, !tbaa !24
  %230 = trunc i64 %229 to i32
  %231 = load i32, ptr %21, align 4, !tbaa !8
  %232 = sext i32 %231 to i64
  %233 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNSt6vectorIZ4mainE5querySaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %6, i64 noundef %232) #7
  %234 = getelementptr inbounds %struct.query, ptr %233, i32 0, i32 3
  store i32 %230, ptr %234, align 4, !tbaa !21
  call void @llvm.lifetime.end.p0(i64 24, ptr %25) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #7
  br label %235

235:                                              ; preds = %227
  %236 = load i32, ptr %21, align 4, !tbaa !8
  %237 = add nsw i32 %236, 1
  store i32 %237, ptr %21, align 4, !tbaa !8
  br label %176, !llvm.loop !27

238:                                              ; preds = %224
  %239 = landingpad { ptr, i32 }
          cleanup
  %240 = extractvalue { ptr, i32 } %239, 0
  store ptr %240, ptr %7, align 8
  %241 = extractvalue { ptr, i32 } %239, 1
  store i32 %241, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 24, ptr %25) #7
  br label %242

242:                                              ; preds = %238, %220
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #7
  br label %281

243:                                              ; preds = %180
  %244 = call ptr @_ZNSt6vectorIZ4mainE5querySaIS0_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %6) #7
  %245 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator.5", ptr %26, i32 0, i32 0
  store ptr %244, ptr %245, align 8
  %246 = call ptr @_ZNSt6vectorIZ4mainE5querySaIS0_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %6) #7
  %247 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator.5", ptr %27, i32 0, i32 0
  store ptr %246, ptr %247, align 8
  %248 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator.5", ptr %26, i32 0, i32 0
  %249 = load ptr, ptr %248, align 8
  %250 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator.5", ptr %27, i32 0, i32 0
  %251 = load ptr, ptr %250, align 8
  invoke void @"_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPZ4mainE5querySt6vectorIS2_SaIS2_EEEEZ4mainE3$_2EvT_S9_T0_"(ptr %249, ptr %251)
          to label %252 unwind label %258

252:                                              ; preds = %243
  call void @llvm.lifetime.start.p0(i64 4, ptr %29) #7
  store i32 0, ptr %29, align 4, !tbaa !8
  br label %253

253:                                              ; preds = %272, %252
  %254 = load i32, ptr %29, align 4, !tbaa !8
  %255 = load i32, ptr %4, align 4, !tbaa !8
  %256 = icmp slt i32 %254, %255
  br i1 %256, label %262, label %257

257:                                              ; preds = %253
  call void @llvm.lifetime.end.p0(i64 4, ptr %29) #7
  br label %279

258:                                              ; preds = %243
  %259 = landingpad { ptr, i32 }
          cleanup
  %260 = extractvalue { ptr, i32 } %259, 0
  store ptr %260, ptr %7, align 8
  %261 = extractvalue { ptr, i32 } %259, 1
  store i32 %261, ptr %8, align 4
  br label %281

262:                                              ; preds = %253
  %263 = load i32, ptr %29, align 4, !tbaa !8
  %264 = sext i32 %263 to i64
  %265 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNSt6vectorIZ4mainE5querySaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %6, i64 noundef %264) #7
  %266 = getelementptr inbounds %struct.query, ptr %265, i32 0, i32 3
  %267 = load i32, ptr %266, align 4, !tbaa !21
  %268 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %267)
          to label %269 unwind label %275

269:                                              ; preds = %262
  %270 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %268, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
          to label %271 unwind label %275

271:                                              ; preds = %269
  br label %272

272:                                              ; preds = %271
  %273 = load i32, ptr %29, align 4, !tbaa !8
  %274 = add nsw i32 %273, 1
  store i32 %274, ptr %29, align 4, !tbaa !8
  br label %253, !llvm.loop !28

275:                                              ; preds = %269, %262
  %276 = landingpad { ptr, i32 }
          cleanup
  %277 = extractvalue { ptr, i32 } %276, 0
  store ptr %277, ptr %7, align 8
  %278 = extractvalue { ptr, i32 } %276, 1
  store i32 %278, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %29) #7
  br label %281

279:                                              ; preds = %257
  store i32 0, ptr %1, align 4
  call void @_ZN13UnionFindTreeD2Ev(ptr noundef nonnull align 8 dereferenceable(32) %20) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr %20) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #7
  call void @_ZNSt6vectorIZ4mainE5querySaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %6) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr %6) #7
  call void @_ZNSt6vectorIZ4mainE4edgeSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %5) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  %280 = load i32, ptr %1, align 4
  ret i32 %280

281:                                              ; preds = %275, %258, %242
  call void @_ZN13UnionFindTreeD2Ev(ptr noundef nonnull align 8 dereferenceable(32) %20) #7
  br label %282

282:                                              ; preds = %281, %181
  call void @llvm.lifetime.end.p0(i64 32, ptr %20) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #7
  br label %283

283:                                              ; preds = %282, %148, %117, %98, %60, %56
  call void @_ZNSt6vectorIZ4mainE5querySaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %6) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr %6) #7
  call void @_ZNSt6vectorIZ4mainE4edgeSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %5) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  br label %284

284:                                              ; preds = %283
  %285 = load ptr, ptr %7, align 8
  %286 = load i32, ptr %8, align 4
  %287 = insertvalue { ptr, i32 } poison, ptr %285, 0
  %288 = insertvalue { ptr, i32 } %287, i32 %286, 1
  resume { ptr, i32 } %288
}

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) #1

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

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

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

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare hidden void @_ZNSt6vectorIZ4mainE4edgeSaIS0_EE6assignEmRKS0_(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef, ptr noundef nonnull align 4 dereferenceable(12)) #4 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorIZ4mainE4edgeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZNSt6vectorIZ4mainE5querySaIS0_EE6assignEmRKS0_(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef, ptr noundef nonnull align 4 dereferenceable(16)) #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef nonnull align 4 dereferenceable(16) ptr @_ZNSt6vectorIZ4mainE5querySaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPZ4mainE4edgeSt6vectorIS2_SaIS2_EEEEZ4mainE3$_0EvT_S9_T0_"(ptr, ptr) #5

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPZ4mainE5querySt6vectorIS2_SaIS2_EEEEZ4mainE3$_1EvT_S9_T0_"(ptr, ptr) #5

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef zeroext i1 @_ZN9__gnu_cxxneIPZ4mainE4edgeSt6vectorIS1_SaIS1_EEEEbRKNS_17__normal_iteratorIT_T0_EESB_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #6

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZNK9__gnu_cxx17__normal_iteratorIPZ4mainE4edgeSt6vectorIS1_SaIS1_EEEptEv(ptr noundef nonnull align 8 dereferenceable(8)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN13UnionFindTree5uniteEmm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef, i64 noundef) #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef nonnull align 8 dereferenceable(8) ptr @_ZN9__gnu_cxx17__normal_iteratorIPZ4mainE4edgeSt6vectorIS1_SaIS1_EEEppEv(ptr noundef nonnull align 8 dereferenceable(8)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN13UnionFindTree4findEm(ptr dead_on_unwind noalias writable sret(%"struct.UnionFindTree::node") align 8, ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPZ4mainE5querySt6vectorIS2_SaIS2_EEEEZ4mainE3$_2EvT_S9_T0_"(ptr, ptr) #5

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 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) #4 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)) #5

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

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

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

attributes #0 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 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 }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!12, !9, i64 0}
!12 = !{!"_ZTSZ4mainE4edge", !9, i64 0, !9, i64 4, !9, i64 8}
!13 = !{!12, !9, i64 4}
!14 = !{!12, !9, i64 8}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!18, !9, i64 0}
!18 = !{!"_ZTSZ4mainE5query", !9, i64 0, !9, i64 4, !9, i64 8, !9, i64 12}
!19 = !{!18, !9, i64 4}
!20 = !{!18, !9, i64 8}
!21 = !{!18, !9, i64 12}
!22 = distinct !{!22, !16}
!23 = distinct !{!23, !16}
!24 = !{!25, !26, i64 16}
!25 = !{!"_ZTSN13UnionFindTree4nodeE", !26, i64 0, !26, i64 8, !26, i64 16}
!26 = !{!"long", !10, i64 0}
!27 = distinct !{!27, !16}
!28 = distinct !{!28, !16}


; 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_istream" = type { ptr, i64, %"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.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<edge, std::allocator<edge>>::_Vector_impl" }
%"struct.std::_Vector_base<edge, std::allocator<edge>>::_Vector_impl" = type { %"struct.std::_Vector_base<edge, std::allocator<edge>>::_Vector_impl_data" }
%"struct.std::_Vector_base<edge, std::allocator<edge>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<query, std::allocator<query>>::_Vector_impl" }
%"struct.std::_Vector_base<query, std::allocator<query>>::_Vector_impl" = type { %"struct.std::_Vector_base<query, std::allocator<query>>::_Vector_impl_data" }
%"struct.std::_Vector_base<query, std::allocator<query>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.edge = type { i32, i32, i32 }
%struct.query = type { i32, i32, i32, i32 }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }
%class.UnionFindTree = type { i64, %"class.std::vector.8" }
%"class.std::vector.8" = type { %"struct.std::_Vector_base.9" }
%"struct.std::_Vector_base.9" = type { %"struct.std::_Vector_base<UnionFindTree::node, std::allocator<UnionFindTree::node>>::_Vector_impl" }
%"struct.std::_Vector_base<UnionFindTree::node, std::allocator<UnionFindTree::node>>::_Vector_impl" = type { %"struct.std::_Vector_base<UnionFindTree::node, std::allocator<UnionFindTree::node>>::_Vector_impl_data" }
%"struct.std::_Vector_base<UnionFindTree::node, std::allocator<UnionFindTree::node>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.UnionFindTree::node" = type { i64, i64, i64 }

@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca %"class.std::vector", align 8
  %5 = alloca %"class.std::vector.0", align 8
  %6 = alloca %struct.edge, align 4
  %7 = alloca %struct.query, align 4
  %8 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %9 = alloca %class.UnionFindTree, align 8
  %10 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %11 = alloca %"struct.UnionFindTree::node", align 8
  %12 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %13 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %14 = getelementptr i8, ptr %13, i64 -24
  %15 = load i64, ptr %14, align 8
  %16 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %15
  %17 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %16, ptr noundef null)
  %18 = load ptr, ptr @_ZSt4cout, align 8, !tbaa !5
  %19 = getelementptr i8, ptr %18, i64 -24
  %20 = load i64, ptr %19, align 8
  %21 = getelementptr inbounds i8, ptr @_ZSt4cout, i64 %20
  %22 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %21, ptr noundef null)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #8
  call void @_ZNSt6vectorIZ4mainE4edgeSaIS0_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %4) #8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #8
  call void @_ZNSt6vectorIZ4mainE5querySaIS0_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %5) #8
  %23 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
          to label %24 unwind label %35

24:                                               ; preds = %0
  %25 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %23, ptr noundef nonnull align 4 dereferenceable(4) %2)
          to label %26 unwind label %35

26:                                               ; preds = %24
  %27 = load i32, ptr %2, align 4, !tbaa !8
  %28 = sext i32 %27 to i64
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %6) #8
  store i32 0, ptr %6, align 4, !tbaa !11
  %29 = getelementptr inbounds i8, ptr %6, i64 4
  store i32 0, ptr %29, align 4, !tbaa !13
  %30 = getelementptr inbounds i8, ptr %6, i64 8
  store i32 0, ptr %30, align 4, !tbaa !14
  invoke void @_ZNSt6vectorIZ4mainE4edgeSaIS0_EE6assignEmRKS0_(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %28, ptr noundef nonnull align 4 dereferenceable(12) %6)
          to label %31 unwind label %37

31:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %6) #8
  %32 = load i32, ptr %2, align 4, !tbaa !8
  %33 = icmp sgt i32 %32, 0
  br i1 %33, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %49, %31
  %34 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %3)
          to label %62 unwind label %35

35:                                               ; preds = %91, %._crit_edge49, %._crit_edge, %24, %0
  %36 = landingpad { ptr, i32 }
          cleanup
  br label %162

37:                                               ; preds = %26
  %38 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %6) #8
  br label %162

.lr.ph:                                           ; preds = %31, %49
  %indvars.iv = phi i64 [ %indvars.iv.next, %49 ], [ 0, %31 ]
  %39 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorIZ4mainE4edgeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %indvars.iv) #8
  %40 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %39)
          to label %41 unwind label %60

41:                                               ; preds = %.lr.ph
  %42 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorIZ4mainE4edgeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %indvars.iv) #8
  %43 = getelementptr inbounds i8, ptr %42, i64 4
  %44 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %40, ptr noundef nonnull align 4 dereferenceable(4) %43)
          to label %45 unwind label %60

45:                                               ; preds = %41
  %46 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorIZ4mainE4edgeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %indvars.iv) #8
  %47 = getelementptr inbounds i8, ptr %46, i64 8
  %48 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %44, ptr noundef nonnull align 4 dereferenceable(4) %47)
          to label %49 unwind label %60

49:                                               ; preds = %45
  %50 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorIZ4mainE4edgeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %indvars.iv) #8
  %51 = load i32, ptr %50, align 4, !tbaa !11
  %52 = add nsw i32 %51, -1
  store i32 %52, ptr %50, align 4, !tbaa !11
  %53 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorIZ4mainE4edgeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %indvars.iv) #8
  %54 = getelementptr inbounds i8, ptr %53, i64 4
  %55 = load i32, ptr %54, align 4, !tbaa !13
  %56 = add nsw i32 %55, -1
  store i32 %56, ptr %54, align 4, !tbaa !13
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %57 = load i32, ptr %2, align 4, !tbaa !8
  %58 = sext i32 %57 to i64
  %59 = icmp slt i64 %indvars.iv.next, %58
  br i1 %59, label %.lr.ph, label %._crit_edge, !llvm.loop !15

60:                                               ; preds = %45, %41, %.lr.ph
  %61 = landingpad { ptr, i32 }
          cleanup
  br label %162

62:                                               ; preds = %._crit_edge
  %63 = load i32, ptr %3, align 4, !tbaa !8
  %64 = sext i32 %63 to i64
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(16) %7, i8 0, i64 16, i1 false)
  invoke void @_ZNSt6vectorIZ4mainE5querySaIS0_EE6assignEmRKS0_(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %64, ptr noundef nonnull align 4 dereferenceable(16) %7)
          to label %65 unwind label %70

65:                                               ; preds = %62
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #8
  %66 = load i32, ptr %3, align 4, !tbaa !8
  %67 = icmp sgt i32 %66, 0
  br i1 %67, label %.lr.ph48, label %._crit_edge49

._crit_edge49:                                    ; preds = %81, %65
  %68 = call ptr @_ZNSt6vectorIZ4mainE4edgeSaIS0_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %4) #8
  %69 = call ptr @_ZNSt6vectorIZ4mainE4edgeSaIS0_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %4) #8
  invoke void @"_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPZ4mainE4edgeSt6vectorIS2_SaIS2_EEEEZ4mainE3$_0EvT_S9_T0_"(ptr %68, ptr %69)
          to label %91 unwind label %35

70:                                               ; preds = %62
  %71 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #8
  br label %162

.lr.ph48:                                         ; preds = %65, %81
  %indvars.iv59 = phi i64 [ %indvars.iv.next60, %81 ], [ 0, %65 ]
  %72 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNSt6vectorIZ4mainE5querySaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %indvars.iv59) #8
  %73 = trunc nuw nsw i64 %indvars.iv59 to i32
  store i32 %73, ptr %72, align 4, !tbaa !17
  %74 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNSt6vectorIZ4mainE5querySaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %indvars.iv59) #8
  %75 = getelementptr inbounds i8, ptr %74, i64 4
  %76 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %75)
          to label %77 unwind label %89

77:                                               ; preds = %.lr.ph48
  %78 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNSt6vectorIZ4mainE5querySaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %indvars.iv59) #8
  %79 = getelementptr inbounds i8, ptr %78, i64 8
  %80 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %76, ptr noundef nonnull align 4 dereferenceable(4) %79)
          to label %81 unwind label %89

81:                                               ; preds = %77
  %82 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNSt6vectorIZ4mainE5querySaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %indvars.iv59) #8
  %83 = getelementptr inbounds i8, ptr %82, i64 4
  %84 = load i32, ptr %83, align 4, !tbaa !19
  %85 = add nsw i32 %84, -1
  store i32 %85, ptr %83, align 4, !tbaa !19
  %indvars.iv.next60 = add nuw nsw i64 %indvars.iv59, 1
  %86 = load i32, ptr %3, align 4, !tbaa !8
  %87 = sext i32 %86 to i64
  %88 = icmp slt i64 %indvars.iv.next60, %87
  br i1 %88, label %.lr.ph48, label %._crit_edge49, !llvm.loop !20

89:                                               ; preds = %77, %.lr.ph48
  %90 = landingpad { ptr, i32 }
          cleanup
  br label %162

91:                                               ; preds = %._crit_edge49
  %92 = call ptr @_ZNSt6vectorIZ4mainE5querySaIS0_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %5) #8
  %93 = call ptr @_ZNSt6vectorIZ4mainE5querySaIS0_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %5) #8
  invoke void @"_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPZ4mainE5querySt6vectorIS2_SaIS2_EEEEZ4mainE3$_1EvT_S9_T0_"(ptr %92, ptr %93)
          to label %94 unwind label %35

94:                                               ; preds = %91
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #8
  %95 = call ptr @_ZNSt6vectorIZ4mainE4edgeSaIS0_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %4) #8
  store ptr %95, ptr %8, align 8
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %9) #8
  %96 = load i32, ptr %1, align 4, !tbaa !8
  %97 = sext i32 %96 to i64
  invoke void @_ZN13UnionFindTreeC2Em(ptr noundef nonnull align 8 dereferenceable(32) %9, i64 noundef %97)
          to label %.preheader44 unwind label %105

.preheader44:                                     ; preds = %94
  %98 = load i32, ptr %3, align 4, !tbaa !8
  %99 = icmp sgt i32 %98, 0
  br i1 %99, label %.lr.ph53, label %._crit_edge54

.lr.ph53:                                         ; preds = %.preheader44
  %100 = getelementptr inbounds i8, ptr %11, i64 16
  br label %107

._crit_edge54:                                    ; preds = %136, %.preheader44
  %101 = call ptr @_ZNSt6vectorIZ4mainE5querySaIS0_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %5) #8
  %102 = call ptr @_ZNSt6vectorIZ4mainE5querySaIS0_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %5) #8
  invoke void @"_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPZ4mainE5querySt6vectorIS2_SaIS2_EEEEZ4mainE3$_2EvT_S9_T0_"(ptr %101, ptr %102)
          to label %.preheader unwind label %146

.preheader:                                       ; preds = %._crit_edge54
  %103 = load i32, ptr %3, align 4, !tbaa !8
  %104 = icmp sgt i32 %103, 0
  br i1 %104, label %.lr.ph56, label %._crit_edge57

105:                                              ; preds = %94
  %106 = landingpad { ptr, i32 }
          cleanup
  br label %161

107:                                              ; preds = %.lr.ph53, %136
  %indvars.iv62 = phi i64 [ 0, %.lr.ph53 ], [ %indvars.iv.next63, %136 ]
  %108 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNSt6vectorIZ4mainE5querySaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %indvars.iv62) #8
  %109 = getelementptr inbounds i8, ptr %108, i64 4
  %110 = load i32, ptr %109, align 4, !tbaa !19
  %111 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNSt6vectorIZ4mainE5querySaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %indvars.iv62) #8
  %112 = getelementptr inbounds i8, ptr %111, i64 8
  %113 = load i32, ptr %112, align 4, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #8
  %114 = call ptr @_ZNSt6vectorIZ4mainE4edgeSaIS0_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %4) #8
  store ptr %114, ptr %10, align 8
  %115 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPZ4mainE4edgeSt6vectorIS1_SaIS1_EEEEbRKNS_17__normal_iteratorIT_T0_EESB_(ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef nonnull align 8 dereferenceable(8) %10) #8
  br i1 %115, label %.lr.ph51, label %.critedge

.lr.ph51:                                         ; preds = %107, %129
  %116 = call noundef ptr @_ZNK9__gnu_cxx17__normal_iteratorIPZ4mainE4edgeSt6vectorIS1_SaIS1_EEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %8) #8
  %117 = getelementptr inbounds i8, ptr %116, i64 8
  %118 = load i32, ptr %117, align 4, !tbaa !14
  %119 = icmp sgt i32 %118, %113
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #8
  br i1 %119, label %120, label %.loopexit

120:                                              ; preds = %.lr.ph51
  %121 = call noundef ptr @_ZNK9__gnu_cxx17__normal_iteratorIPZ4mainE4edgeSt6vectorIS1_SaIS1_EEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %8) #8
  %122 = load i32, ptr %121, align 4, !tbaa !11
  %123 = sext i32 %122 to i64
  %124 = call noundef ptr @_ZNK9__gnu_cxx17__normal_iteratorIPZ4mainE4edgeSt6vectorIS1_SaIS1_EEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %8) #8
  %125 = getelementptr inbounds i8, ptr %124, i64 4
  %126 = load i32, ptr %125, align 4, !tbaa !13
  %127 = sext i32 %126 to i64
  %128 = invoke noundef zeroext i1 @_ZN13UnionFindTree5uniteEmm(ptr noundef nonnull align 8 dereferenceable(32) %9, i64 noundef %123, i64 noundef %127)
          to label %129 unwind label %133

129:                                              ; preds = %120
  %130 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN9__gnu_cxx17__normal_iteratorIPZ4mainE4edgeSt6vectorIS1_SaIS1_EEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %8) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #8
  %131 = call ptr @_ZNSt6vectorIZ4mainE4edgeSaIS0_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %4) #8
  store ptr %131, ptr %10, align 8
  %132 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPZ4mainE4edgeSt6vectorIS1_SaIS1_EEEEbRKNS_17__normal_iteratorIT_T0_EESB_(ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef nonnull align 8 dereferenceable(8) %10) #8
  br i1 %132, label %.lr.ph51, label %.critedge, !llvm.loop !22

133:                                              ; preds = %120
  %134 = landingpad { ptr, i32 }
          cleanup
  br label %160

.critedge:                                        ; preds = %129, %107
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #8
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph51, %.critedge
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %11) #8
  %135 = sext i32 %110 to i64
  invoke void @_ZN13UnionFindTree4findEm(ptr dead_on_unwind nonnull writable sret(%"struct.UnionFindTree::node") align 8 %11, ptr noundef nonnull align 8 dereferenceable(32) %9, i64 noundef %135)
          to label %136 unwind label %144

136:                                              ; preds = %.loopexit
  %137 = load i64, ptr %100, align 8, !tbaa !23
  %138 = trunc i64 %137 to i32
  %139 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNSt6vectorIZ4mainE5querySaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %indvars.iv62) #8
  %140 = getelementptr inbounds i8, ptr %139, i64 12
  store i32 %138, ptr %140, align 4, !tbaa !26
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %11) #8
  %indvars.iv.next63 = add nuw nsw i64 %indvars.iv62, 1
  %141 = load i32, ptr %3, align 4, !tbaa !8
  %142 = sext i32 %141 to i64
  %143 = icmp slt i64 %indvars.iv.next63, %142
  br i1 %143, label %107, label %._crit_edge54, !llvm.loop !27

144:                                              ; preds = %.loopexit
  %145 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %11) #8
  br label %160

._crit_edge57:                                    ; preds = %154, %.preheader
  call void @_ZN13UnionFindTreeD2Ev(ptr noundef nonnull align 8 dereferenceable(32) %9) #8
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %9) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #8
  call void @_ZNSt6vectorIZ4mainE5querySaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %5) #8
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #8
  call void @_ZNSt6vectorIZ4mainE4edgeSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %4) #8
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #8
  ret i32 0

146:                                              ; preds = %._crit_edge54
  %147 = landingpad { ptr, i32 }
          cleanup
  br label %160

.lr.ph56:                                         ; preds = %.preheader, %154
  %indvars.iv65 = phi i64 [ %indvars.iv.next66, %154 ], [ 0, %.preheader ]
  %148 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNSt6vectorIZ4mainE5querySaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %indvars.iv65) #8
  %149 = getelementptr inbounds i8, ptr %148, i64 12
  %150 = load i32, ptr %149, align 4, !tbaa !26
  %151 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %150)
          to label %152 unwind label %158

152:                                              ; preds = %.lr.ph56
  %153 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %151, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
          to label %154 unwind label %158

154:                                              ; preds = %152
  %indvars.iv.next66 = add nuw nsw i64 %indvars.iv65, 1
  %155 = load i32, ptr %3, align 4, !tbaa !8
  %156 = sext i32 %155 to i64
  %157 = icmp slt i64 %indvars.iv.next66, %156
  br i1 %157, label %.lr.ph56, label %._crit_edge57, !llvm.loop !28

158:                                              ; preds = %152, %.lr.ph56
  %159 = landingpad { ptr, i32 }
          cleanup
  br label %160

160:                                              ; preds = %133, %144, %158, %146
  %.pn.pn = phi { ptr, i32 } [ %159, %158 ], [ %147, %146 ], [ %134, %133 ], [ %145, %144 ]
  call void @_ZN13UnionFindTreeD2Ev(ptr noundef nonnull align 8 dereferenceable(32) %9) #8
  br label %161

161:                                              ; preds = %160, %105
  %.pn.pn.pn = phi { ptr, i32 } [ %.pn.pn, %160 ], [ %106, %105 ]
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %9) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #8
  br label %162

162:                                              ; preds = %161, %89, %70, %60, %37, %35
  %.pn42 = phi { ptr, i32 } [ %61, %60 ], [ %90, %89 ], [ %.pn.pn.pn, %161 ], [ %36, %35 ], [ %71, %70 ], [ %38, %37 ]
  call void @_ZNSt6vectorIZ4mainE5querySaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %5) #8
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #8
  call void @_ZNSt6vectorIZ4mainE4edgeSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %4) #8
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #8
  resume { ptr, i32 } %.pn42
}

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) local_unnamed_addr #1

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

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

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

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare hidden void @_ZNSt6vectorIZ4mainE4edgeSaIS0_EE6assignEmRKS0_(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef, ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #4 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorIZ4mainE4edgeSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZNSt6vectorIZ4mainE5querySaIS0_EE6assignEmRKS0_(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef, ptr noundef nonnull align 4 dereferenceable(16)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef nonnull align 4 dereferenceable(16) ptr @_ZNSt6vectorIZ4mainE5querySaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPZ4mainE4edgeSt6vectorIS2_SaIS2_EEEEZ4mainE3$_0EvT_S9_T0_"(ptr, ptr) local_unnamed_addr #5

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPZ4mainE5querySt6vectorIS2_SaIS2_EEEEZ4mainE3$_1EvT_S9_T0_"(ptr, ptr) local_unnamed_addr #5

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef zeroext i1 @_ZN9__gnu_cxxneIPZ4mainE4edgeSt6vectorIS1_SaIS1_EEEEbRKNS_17__normal_iteratorIT_T0_EESB_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #6

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZNK9__gnu_cxx17__normal_iteratorIPZ4mainE4edgeSt6vectorIS1_SaIS1_EEEptEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN13UnionFindTree5uniteEmm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef, i64 noundef) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef nonnull align 8 dereferenceable(8) ptr @_ZN9__gnu_cxx17__normal_iteratorIPZ4mainE4edgeSt6vectorIS1_SaIS1_EEEppEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN13UnionFindTree4findEm(ptr dead_on_unwind noalias writable sret(%"struct.UnionFindTree::node") align 8, ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) local_unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPZ4mainE5querySt6vectorIS2_SaIS2_EEEEZ4mainE3$_2EvT_S9_T0_"(ptr, ptr) local_unnamed_addr #5

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 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 #4 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)) #5

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

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

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

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

attributes #0 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #8 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!12, !9, i64 0}
!12 = !{!"_ZTSZ4mainE4edge", !9, i64 0, !9, i64 4, !9, i64 8}
!13 = !{!12, !9, i64 4}
!14 = !{!12, !9, i64 8}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!18, !9, i64 0}
!18 = !{!"_ZTSZ4mainE5query", !9, i64 0, !9, i64 4, !9, i64 8, !9, i64 12}
!19 = !{!18, !9, i64 4}
!20 = distinct !{!20, !16}
!21 = !{!18, !9, i64 8}
!22 = distinct !{!22, !16}
!23 = !{!24, !25, i64 16}
!24 = !{!"_ZTSN13UnionFindTree4nodeE", !25, i64 0, !25, i64 8, !25, i64 16}
!25 = !{!"long", !10, i64 0}
!26 = !{!18, !9, i64 12}
!27 = distinct !{!27, !16}
!28 = distinct !{!28, !16}


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