; LLVM IR from kazunetakahashi/atcoder :: 2018/0526_ARC098 (E)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"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" }
%"struct.std::pair" = type { i32, i32 }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }
%class.BIT = type { i32, ptr }

@N = external dso_local global i32, align 4
@K = external dso_local global i32, align 4
@Q = external dso_local global i32, align 4
@A = external dso_local global [2010 x i32], align 16
@V = external dso_local global %"class.std::vector", align 8
@visited = external dso_local global [2010 x i8], align 16
@_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 %"struct.std::pair", align 4
  %4 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %5 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %6 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %7 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %8 = alloca i32, align 4
  %9 = alloca i8, align 1
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca [2010 x i32], align 16
  %15 = alloca [2010 x i32], align 16
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca %class.BIT, align 8
  %20 = alloca [2010 x i32], align 16
  %21 = alloca i32, align 4
  %22 = alloca ptr, align 8
  %23 = alloca i32, align 4
  %24 = alloca i32, align 4
  %25 = alloca i32, align 4
  %26 = alloca i32, align 4
  %27 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %28 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @N)
  %29 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %28, ptr noundef nonnull align 4 dereferenceable(4) @K)
  %30 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %29, ptr noundef nonnull align 4 dereferenceable(4) @Q)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %44, %0
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = load i32, ptr @N, align 4, !tbaa !5
  %34 = icmp slt i32 %32, %33
  br i1 %34, label %36, label %35

35:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  br label %47

36:                                               ; preds = %31
  %37 = load i32, ptr %2, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [2010 x i32], ptr @A, i64 0, i64 %38
  %40 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %39)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #7
  %41 = load i32, ptr %2, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [2010 x i32], ptr @A, i64 0, i64 %42
  call void @_ZNSt4pairIiiEC2IRiS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8) %3, ptr noundef nonnull align 4 dereferenceable(4) %43, ptr noundef nonnull align 4 dereferenceable(4) %2)
  call void @_ZNSt6vectorISt4pairIiiESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24) @V, ptr noundef nonnull align 4 dereferenceable(8) %3)
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #7
  br label %44

44:                                               ; preds = %36
  %45 = load i32, ptr %2, align 4, !tbaa !5
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %2, align 4, !tbaa !5
  br label %31, !llvm.loop !9

47:                                               ; preds = %35
  %48 = call ptr @_ZNSt6vectorISt4pairIiiESaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @V) #7
  %49 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %4, i32 0, i32 0
  store ptr %48, ptr %49, align 8
  %50 = call ptr @_ZNSt6vectorISt4pairIiiESaIS1_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @V) #7
  %51 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %5, i32 0, i32 0
  store ptr %50, ptr %51, align 8
  %52 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %4, i32 0, i32 0
  %53 = load ptr, ptr %52, align 8
  %54 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %5, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8
  call void @_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPSt4pairIiiESt6vectorIS3_SaIS3_EEEEEvT_S9_(ptr %53, ptr %55)
  %56 = call ptr @_ZNSt6vectorISt4pairIiiESaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @V) #7
  %57 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %6, i32 0, i32 0
  store ptr %56, ptr %57, align 8
  %58 = call ptr @_ZNSt6vectorISt4pairIiiESaIS1_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @V) #7
  %59 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %7, i32 0, i32 0
  store ptr %58, ptr %59, align 8
  %60 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %6, i32 0, i32 0
  %61 = load ptr, ptr %60, align 8
  %62 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %7, i32 0, i32 0
  %63 = load ptr, ptr %62, align 8
  call void @_ZSt7reverseIN9__gnu_cxx17__normal_iteratorIPSt4pairIiiESt6vectorIS3_SaIS3_EEEEEvT_S9_(ptr %61, ptr %63)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  store i32 1000000007, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #7
  store i8 0, ptr %9, align 1, !tbaa !11
  call void @_ZSt4fillIPbbEvT_S1_RKT0_(ptr noundef @visited, ptr noundef getelementptr inbounds (i8, ptr @visited, i64 2010), ptr noundef nonnull align 1 dereferenceable(1) %9)
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %64

64:                                               ; preds = %214, %47
  %65 = load i32, ptr %10, align 4, !tbaa !5
  %66 = load i32, ptr @N, align 4, !tbaa !5
  %67 = icmp slt i32 %65, %66
  br i1 %67, label %69, label %68

68:                                               ; preds = %64
  store i32 5, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  br label %218

69:                                               ; preds = %64
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  %70 = load i32, ptr %10, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorISt4pairIiiESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @V, i64 noundef %71) #7
  %73 = getelementptr inbounds %"struct.std::pair", ptr %72, i32 0, i32 0
  %74 = load i32, ptr %73, align 4, !tbaa !13
  store i32 %74, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  %75 = load i32, ptr %10, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorISt4pairIiiESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @V, i64 noundef %76) #7
  %78 = getelementptr inbounds %"struct.std::pair", ptr %77, i32 0, i32 1
  %79 = load i32, ptr %78, align 4, !tbaa !15
  store i32 %79, ptr %13, align 4, !tbaa !5
  %80 = load i32, ptr %13, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [2010 x i8], ptr @visited, i64 0, i64 %81
  store i8 1, ptr %82, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8040, ptr %14) #7
  call void @llvm.lifetime.start.p0(i64 8040, ptr %15) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #7
  store i32 -1, ptr %16, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #7
  store i32 0, ptr %17, align 4, !tbaa !5
  br label %83

83:                                               ; preds = %101, %69
  %84 = load i32, ptr %17, align 4, !tbaa !5
  %85 = load i32, ptr @N, align 4, !tbaa !5
  %86 = icmp slt i32 %84, %85
  br i1 %86, label %88, label %87

87:                                               ; preds = %83
  store i32 8, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #7
  br label %104

88:                                               ; preds = %83
  %89 = load i32, ptr %17, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [2010 x i8], ptr @visited, i64 0, i64 %90
  %92 = load i8, ptr %91, align 1, !tbaa !11, !range !16, !noundef !17
  %93 = trunc i8 %92 to i1
  br i1 %93, label %96, label %94

94:                                               ; preds = %88
  %95 = load i32, ptr %17, align 4, !tbaa !5
  store i32 %95, ptr %16, align 4, !tbaa !5
  br label %96

96:                                               ; preds = %94, %88
  %97 = load i32, ptr %16, align 4, !tbaa !5
  %98 = load i32, ptr %17, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [2010 x i32], ptr %14, i64 0, i64 %99
  store i32 %97, ptr %100, align 4, !tbaa !5
  br label %101

101:                                              ; preds = %96
  %102 = load i32, ptr %17, align 4, !tbaa !5
  %103 = add nsw i32 %102, 1
  store i32 %103, ptr %17, align 4, !tbaa !5
  br label %83, !llvm.loop !18

104:                                              ; preds = %87
  %105 = load i32, ptr @N, align 4, !tbaa !5
  store i32 %105, ptr %16, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #7
  %106 = load i32, ptr @N, align 4, !tbaa !5
  store i32 %106, ptr %18, align 4, !tbaa !5
  br label %107

107:                                              ; preds = %124, %104
  %108 = load i32, ptr %18, align 4, !tbaa !5
  %109 = icmp sge i32 %108, 0
  br i1 %109, label %111, label %110

110:                                              ; preds = %107
  store i32 11, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #7
  br label %127

111:                                              ; preds = %107
  %112 = load i32, ptr %18, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [2010 x i8], ptr @visited, i64 0, i64 %113
  %115 = load i8, ptr %114, align 1, !tbaa !11, !range !16, !noundef !17
  %116 = trunc i8 %115 to i1
  br i1 %116, label %119, label %117

117:                                              ; preds = %111
  %118 = load i32, ptr %18, align 4, !tbaa !5
  store i32 %118, ptr %16, align 4, !tbaa !5
  br label %119

119:                                              ; preds = %117, %111
  %120 = load i32, ptr %16, align 4, !tbaa !5
  %121 = load i32, ptr %18, align 4, !tbaa !5
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [2010 x i32], ptr %15, i64 0, i64 %122
  store i32 %120, ptr %123, align 4, !tbaa !5
  br label %124

124:                                              ; preds = %119
  %125 = load i32, ptr %18, align 4, !tbaa !5
  %126 = add nsw i32 %125, -1
  store i32 %126, ptr %18, align 4, !tbaa !5
  br label %107, !llvm.loop !19

127:                                              ; preds = %110
  call void @llvm.lifetime.start.p0(i64 16, ptr %19) #7
  %128 = load i32, ptr @N, align 4, !tbaa !5
  %129 = add nsw i32 %128, 1
  call void @_ZN3BITC2Ei(ptr noundef nonnull align 8 dereferenceable(16) %19, i32 noundef %129)
  call void @llvm.lifetime.start.p0(i64 8040, ptr %20) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #7
  store i32 0, ptr %21, align 4, !tbaa !5
  br label %130

130:                                              ; preds = %160, %127
  %131 = load i32, ptr %21, align 4, !tbaa !5
  %132 = load i32, ptr %10, align 4, !tbaa !5
  %133 = icmp sle i32 %131, %132
  br i1 %133, label %135, label %134

134:                                              ; preds = %130
  store i32 14, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #7
  br label %167

135:                                              ; preds = %130
  %136 = load i32, ptr %21, align 4, !tbaa !5
  %137 = sext i32 %136 to i64
  %138 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorISt4pairIiiESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @V, i64 noundef %137) #7
  %139 = getelementptr inbounds %"struct.std::pair", ptr %138, i32 0, i32 1
  %140 = load i32, ptr %139, align 4, !tbaa !15
  store i32 %140, ptr %13, align 4, !tbaa !5
  %141 = load i32, ptr %13, align 4, !tbaa !5
  %142 = add nsw i32 %141, 1
  invoke void @_ZN3BIT3addEi(ptr noundef nonnull align 8 dereferenceable(16) %19, i32 noundef %142)
          to label %143 unwind label %163

143:                                              ; preds = %135
  %144 = load i32, ptr %13, align 4, !tbaa !5
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds [2010 x i32], ptr %14, i64 0, i64 %145
  %147 = load i32, ptr %146, align 4, !tbaa !5
  %148 = add nsw i32 %147, 2
  %149 = load i32, ptr %13, align 4, !tbaa !5
  %150 = sext i32 %149 to i64
  %151 = getelementptr inbounds [2010 x i32], ptr %15, i64 0, i64 %150
  %152 = load i32, ptr %151, align 4, !tbaa !5
  %153 = add nsw i32 %152, 1
  %154 = invoke noundef i64 @_ZN3BIT3sumEii(ptr noundef nonnull align 8 dereferenceable(16) %19, i32 noundef %148, i32 noundef %153)
          to label %155 unwind label %163

155:                                              ; preds = %143
  %156 = trunc i64 %154 to i32
  %157 = load i32, ptr %13, align 4, !tbaa !5
  %158 = sext i32 %157 to i64
  %159 = getelementptr inbounds [2010 x i32], ptr %20, i64 0, i64 %158
  store i32 %156, ptr %159, align 4, !tbaa !5
  br label %160

160:                                              ; preds = %155
  %161 = load i32, ptr %21, align 4, !tbaa !5
  %162 = add nsw i32 %161, 1
  store i32 %162, ptr %21, align 4, !tbaa !5
  br label %130, !llvm.loop !20

163:                                              ; preds = %143, %135
  %164 = landingpad { ptr, i32 }
          cleanup
  %165 = extractvalue { ptr, i32 } %164, 0
  store ptr %165, ptr %22, align 8
  %166 = extractvalue { ptr, i32 } %164, 1
  store i32 %166, ptr %23, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #7
  br label %217

167:                                              ; preds = %134
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #7
  store i32 0, ptr %24, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #7
  %168 = load i32, ptr %10, align 4, !tbaa !5
  store i32 %168, ptr %25, align 4, !tbaa !5
  br label %169

169:                                              ; preds = %209, %167
  %170 = load i32, ptr %25, align 4, !tbaa !5
  %171 = icmp sge i32 %170, 0
  br i1 %171, label %173, label %172

172:                                              ; preds = %169
  store i32 17, ptr %11, align 4
  br label %212

173:                                              ; preds = %169
  %174 = load i32, ptr %25, align 4, !tbaa !5
  %175 = sext i32 %174 to i64
  %176 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorISt4pairIiiESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @V, i64 noundef %175) #7
  %177 = getelementptr inbounds %"struct.std::pair", ptr %176, i32 0, i32 1
  %178 = load i32, ptr %177, align 4, !tbaa !15
  store i32 %178, ptr %13, align 4, !tbaa !5
  %179 = load i32, ptr %13, align 4, !tbaa !5
  %180 = sext i32 %179 to i64
  %181 = getelementptr inbounds [2010 x i32], ptr %20, i64 0, i64 %180
  %182 = load i32, ptr %181, align 4, !tbaa !5
  %183 = load i32, ptr @K, align 4, !tbaa !5
  %184 = icmp sge i32 %182, %183
  br i1 %184, label %185, label %208

185:                                              ; preds = %173
  %186 = load i32, ptr %24, align 4, !tbaa !5
  %187 = add nsw i32 %186, 1
  store i32 %187, ptr %24, align 4, !tbaa !5
  %188 = load i32, ptr %24, align 4, !tbaa !5
  %189 = load i32, ptr @Q, align 4, !tbaa !5
  %190 = icmp eq i32 %188, %189
  br i1 %190, label %191, label %207

191:                                              ; preds = %185
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #7
  %192 = load i32, ptr %25, align 4, !tbaa !5
  %193 = sext i32 %192 to i64
  %194 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorISt4pairIiiESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @V, i64 noundef %193) #7
  %195 = getelementptr inbounds %"struct.std::pair", ptr %194, i32 0, i32 0
  %196 = load i32, ptr %195, align 4, !tbaa !13
  store i32 %196, ptr %26, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %27) #7
  %197 = load i32, ptr %26, align 4, !tbaa !5
  %198 = load i32, ptr %12, align 4, !tbaa !5
  %199 = sub nsw i32 %197, %198
  store i32 %199, ptr %27, align 4, !tbaa !5
  %200 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %8, ptr noundef nonnull align 4 dereferenceable(4) %27)
          to label %201 unwind label %203

201:                                              ; preds = %191
  %202 = load i32, ptr %200, align 4, !tbaa !5
  store i32 %202, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #7
  store i32 17, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #7
  br label %212

203:                                              ; preds = %191
  %204 = landingpad { ptr, i32 }
          cleanup
  %205 = extractvalue { ptr, i32 } %204, 0
  store ptr %205, ptr %22, align 8
  %206 = extractvalue { ptr, i32 } %204, 1
  store i32 %206, ptr %23, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #7
  br label %217

207:                                              ; preds = %185
  br label %208

208:                                              ; preds = %207, %173
  br label %209

209:                                              ; preds = %208
  %210 = load i32, ptr %25, align 4, !tbaa !5
  %211 = add nsw i32 %210, -1
  store i32 %211, ptr %25, align 4, !tbaa !5
  br label %169, !llvm.loop !21

212:                                              ; preds = %201, %172
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #7
  br label %213

213:                                              ; preds = %212
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #7
  call void @llvm.lifetime.end.p0(i64 8040, ptr %20) #7
  call void @_ZN3BITD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %19) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %19) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #7
  call void @llvm.lifetime.end.p0(i64 8040, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 8040, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  br label %214

214:                                              ; preds = %213
  %215 = load i32, ptr %10, align 4, !tbaa !5
  %216 = add nsw i32 %215, 1
  store i32 %216, ptr %10, align 4, !tbaa !5
  br label %64, !llvm.loop !22

217:                                              ; preds = %203, %163
  call void @llvm.lifetime.end.p0(i64 8040, ptr %20) #7
  call void @_ZN3BITD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %19) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %19) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #7
  call void @llvm.lifetime.end.p0(i64 8040, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 8040, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  br label %223

218:                                              ; preds = %68
  %219 = load i32, ptr %8, align 4, !tbaa !5
  %220 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %219)
  %221 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %220, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  %222 = load i32, ptr %1, align 4
  ret i32 %222

223:                                              ; preds = %217
  %224 = load ptr, ptr %22, align 8
  %225 = load i32, ptr %23, align 4
  %226 = insertvalue { ptr, i32 } poison, ptr %224, 0
  %227 = insertvalue { ptr, i32 } %226, i32 %225, 1
  resume { ptr, i32 } %227
}

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

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

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPSt4pairIiiESt6vectorIS3_SaIS3_EEEEEvT_S9_(ptr, ptr) #5

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt7reverseIN9__gnu_cxx17__normal_iteratorIPSt4pairIiiESt6vectorIS3_SaIS3_EEEEEvT_S9_(ptr, ptr) #5

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4fillIPbbEvT_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 1 dereferenceable(1)) #5

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

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

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #6

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

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { 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 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"_ZTSSt4pairIiiE", !6, i64 0, !6, i64 4}
!15 = !{!14, !6, i64 4}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}
!21 = distinct !{!21, !10}
!22 = distinct !{!22, !10}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"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" }
%"struct.std::pair" = type { i32, i32 }
%class.BIT = type { i32, ptr }

@N = external dso_local global i32, align 4
@K = external dso_local global i32, align 4
@Q = external dso_local global i32, align 4
@A = external dso_local global [2010 x i32], align 16
@V = external dso_local global %"class.std::vector", align 8
@visited = external dso_local global [2010 x i8], align 16
@_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 %"struct.std::pair", align 4
  %3 = alloca i32, align 4
  %4 = alloca i8, align 1
  %5 = alloca [2010 x i32], align 16
  %6 = alloca [2010 x i32], align 16
  %7 = alloca %class.BIT, align 8
  %8 = alloca [2010 x i32], align 16
  %9 = alloca i32, align 4
  %10 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @N)
  %11 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %10, ptr noundef nonnull align 4 dereferenceable(4) @K)
  %12 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %11, ptr noundef nonnull align 4 dereferenceable(4) @Q)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  store i32 0, ptr %1, align 4, !tbaa !5
  %13 = load i32, ptr @N, align 4, !tbaa !5
  %14 = icmp sgt i32 %13, 0
  br i1 %14, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  %15 = call ptr @_ZNSt6vectorISt4pairIiiESaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @V) #7
  %16 = call ptr @_ZNSt6vectorISt4pairIiiESaIS1_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @V) #7
  call void @_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPSt4pairIiiESt6vectorIS3_SaIS3_EEEEEvT_S9_(ptr %15, ptr %16)
  %17 = call ptr @_ZNSt6vectorISt4pairIiiESaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @V) #7
  %18 = call ptr @_ZNSt6vectorISt4pairIiiESaIS1_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @V) #7
  call void @_ZSt7reverseIN9__gnu_cxx17__normal_iteratorIPSt4pairIiiESt6vectorIS3_SaIS3_EEEEEvT_S9_(ptr %17, ptr %18)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #7
  store i32 1000000007, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %4) #7
  store i8 0, ptr %4, align 1, !tbaa !9
  call void @_ZSt4fillIPbbEvT_S1_RKT0_(ptr noundef nonnull @visited, ptr noundef nonnull getelementptr inbounds (i8, ptr @visited, i64 2010), ptr noundef nonnull align 1 dereferenceable(1) %4)
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %4) #7
  %19 = load i32, ptr @N, align 4, !tbaa !5
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %.lr.ph70, label %._crit_edge71

.lr.ph:                                           ; preds = %0, %.lr.ph
  %storemerge54 = phi i32 [ %28, %.lr.ph ], [ 0, %0 ]
  %21 = sext i32 %storemerge54 to i64
  %22 = getelementptr inbounds [2010 x i32], ptr @A, i64 0, i64 %21
  %23 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %22)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #7
  %24 = load i32, ptr %1, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [2010 x i32], ptr @A, i64 0, i64 %25
  call void @_ZNSt4pairIiiEC2IRiS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8) %2, ptr noundef nonnull align 4 dereferenceable(4) %26, ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @_ZNSt6vectorISt4pairIiiESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24) @V, ptr noundef nonnull align 4 dereferenceable(8) %2)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  %27 = load i32, ptr %1, align 4, !tbaa !5
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %1, align 4, !tbaa !5
  %29 = load i32, ptr @N, align 4, !tbaa !5
  %30 = icmp slt i32 %28, %29
  br i1 %30, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge71.loopexit:                           ; preds = %.loopexit
  %.pre = load i32, ptr %3, align 4, !tbaa !5
  br label %._crit_edge71

._crit_edge71:                                    ; preds = %._crit_edge71.loopexit, %._crit_edge
  %31 = phi i32 [ %.pre, %._crit_edge71.loopexit ], [ 1000000007, %._crit_edge ]
  %32 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %31)
  %33 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %32, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #7
  ret i32 0

.lr.ph70:                                         ; preds = %._crit_edge, %.loopexit
  %indvars.iv89 = phi i64 [ %indvars.iv.next90, %.loopexit ], [ 1, %._crit_edge ]
  %indvars.iv84 = phi i64 [ %indvars.iv.next85, %.loopexit ], [ 0, %._crit_edge ]
  %34 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorISt4pairIiiESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @V, i64 noundef %indvars.iv84) #7
  %35 = load i32, ptr %34, align 4, !tbaa !13
  %36 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorISt4pairIiiESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @V, i64 noundef %indvars.iv84) #7
  %37 = getelementptr inbounds i8, ptr %36, i64 4
  %38 = load i32, ptr %37, align 4, !tbaa !15
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [2010 x i8], ptr @visited, i64 0, i64 %39
  store i8 1, ptr %40, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8040, ptr nonnull %5) #7
  call void @llvm.lifetime.start.p0(i64 8040, ptr nonnull %6) #7
  %41 = load i32, ptr @N, align 4, !tbaa !5
  %42 = icmp sgt i32 %41, 0
  br i1 %42, label %.lr.ph58.preheader, label %.preheader52

.lr.ph58.preheader:                               ; preds = %.lr.ph70
  %wide.trip.count = zext nneg i32 %41 to i64
  %xtraiter = and i64 %wide.trip.count, 3
  %43 = icmp ult i32 %41, 4
  br i1 %43, label %.preheader52.loopexit.unr-lcssa, label %.lr.ph58.preheader.new

.lr.ph58.preheader.new:                           ; preds = %.lr.ph58.preheader
  %unroll_iter = and i64 %wide.trip.count, 2147483644
  br label %.lr.ph58

.preheader52.loopexit.unr-lcssa:                  ; preds = %.lr.ph58, %.lr.ph58.preheader
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph58.preheader ], [ %indvars.iv.next.3, %.lr.ph58 ]
  %.04555.unr = phi i32 [ -1, %.lr.ph58.preheader ], [ %spec.select.3, %.lr.ph58 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.preheader52, label %.lr.ph58.epil

.lr.ph58.epil:                                    ; preds = %.preheader52.loopexit.unr-lcssa, %.lr.ph58.epil
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.lr.ph58.epil ], [ %indvars.iv.unr, %.preheader52.loopexit.unr-lcssa ]
  %.04555.epil = phi i32 [ %spec.select.epil, %.lr.ph58.epil ], [ %.04555.unr, %.preheader52.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph58.epil ], [ 0, %.preheader52.loopexit.unr-lcssa ]
  %44 = getelementptr inbounds [2010 x i8], ptr @visited, i64 0, i64 %indvars.iv.epil
  %45 = load i8, ptr %44, align 1, !tbaa !9, !range !16, !noundef !17
  %46 = trunc nuw i8 %45 to i1
  %47 = trunc nuw nsw i64 %indvars.iv.epil to i32
  %spec.select.epil = select i1 %46, i32 %.04555.epil, i32 %47
  %48 = getelementptr inbounds [2010 x i32], ptr %5, i64 0, i64 %indvars.iv.epil
  store i32 %spec.select.epil, ptr %48, align 4, !tbaa !5
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.preheader52, label %.lr.ph58.epil, !llvm.loop !18

.preheader52:                                     ; preds = %.preheader52.loopexit.unr-lcssa, %.lr.ph58.epil, %.lr.ph70
  %49 = icmp sgt i32 %41, -1
  br i1 %49, label %.lr.ph61.preheader, label %._crit_edge62

.lr.ph61.preheader:                               ; preds = %.preheader52
  %50 = zext nneg i32 %41 to i64
  %51 = add nuw nsw i64 %50, 1
  %xtraiter97 = and i64 %51, 3
  %lcmp.mod98.not = icmp eq i64 %xtraiter97, 0
  br i1 %lcmp.mod98.not, label %.lr.ph61.prol.loopexit, label %.lr.ph61.prol

.lr.ph61.prol:                                    ; preds = %.lr.ph61.preheader, %.lr.ph61.prol
  %indvars.iv74.prol = phi i64 [ %indvars.iv.next75.prol, %.lr.ph61.prol ], [ %50, %.lr.ph61.preheader ]
  %.259.prol = phi i32 [ %spec.select51.prol, %.lr.ph61.prol ], [ %41, %.lr.ph61.preheader ]
  %prol.iter = phi i64 [ %prol.iter.next, %.lr.ph61.prol ], [ 0, %.lr.ph61.preheader ]
  %52 = getelementptr inbounds [2010 x i8], ptr @visited, i64 0, i64 %indvars.iv74.prol
  %53 = load i8, ptr %52, align 1, !tbaa !9, !range !16, !noundef !17
  %54 = trunc nuw i8 %53 to i1
  %55 = trunc nuw nsw i64 %indvars.iv74.prol to i32
  %spec.select51.prol = select i1 %54, i32 %.259.prol, i32 %55
  %56 = getelementptr inbounds [2010 x i32], ptr %6, i64 0, i64 %indvars.iv74.prol
  store i32 %spec.select51.prol, ptr %56, align 4, !tbaa !5
  %indvars.iv.next75.prol = add nsw i64 %indvars.iv74.prol, -1
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter97
  br i1 %prol.iter.cmp.not, label %.lr.ph61.prol.loopexit, label %.lr.ph61.prol, !llvm.loop !20

.lr.ph61.prol.loopexit:                           ; preds = %.lr.ph61.prol, %.lr.ph61.preheader
  %indvars.iv74.unr = phi i64 [ %50, %.lr.ph61.preheader ], [ %indvars.iv.next75.prol, %.lr.ph61.prol ]
  %.259.unr = phi i32 [ %41, %.lr.ph61.preheader ], [ %spec.select51.prol, %.lr.ph61.prol ]
  %57 = icmp ult i32 %41, 3
  br i1 %57, label %._crit_edge62, label %.lr.ph61

.lr.ph58:                                         ; preds = %.lr.ph58, %.lr.ph58.preheader.new
  %indvars.iv = phi i64 [ 0, %.lr.ph58.preheader.new ], [ %indvars.iv.next.3, %.lr.ph58 ]
  %.04555 = phi i32 [ -1, %.lr.ph58.preheader.new ], [ %spec.select.3, %.lr.ph58 ]
  %niter = phi i64 [ 0, %.lr.ph58.preheader.new ], [ %niter.next.3, %.lr.ph58 ]
  %58 = getelementptr inbounds [2010 x i8], ptr @visited, i64 0, i64 %indvars.iv
  %59 = load i8, ptr %58, align 4, !tbaa !9, !range !16, !noundef !17
  %60 = trunc nuw i8 %59 to i1
  %61 = trunc nuw nsw i64 %indvars.iv to i32
  %spec.select = select i1 %60, i32 %.04555, i32 %61
  %62 = getelementptr inbounds [2010 x i32], ptr %5, i64 0, i64 %indvars.iv
  store i32 %spec.select, ptr %62, align 16, !tbaa !5
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %63 = getelementptr inbounds [2010 x i8], ptr @visited, i64 0, i64 %indvars.iv.next
  %64 = load i8, ptr %63, align 1, !tbaa !9, !range !16, !noundef !17
  %65 = trunc nuw i8 %64 to i1
  %66 = trunc nuw nsw i64 %indvars.iv.next to i32
  %spec.select.1 = select i1 %65, i32 %spec.select, i32 %66
  %67 = getelementptr inbounds [2010 x i32], ptr %5, i64 0, i64 %indvars.iv.next
  store i32 %spec.select.1, ptr %67, align 4, !tbaa !5
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %68 = getelementptr inbounds [2010 x i8], ptr @visited, i64 0, i64 %indvars.iv.next.1
  %69 = load i8, ptr %68, align 2, !tbaa !9, !range !16, !noundef !17
  %70 = trunc nuw i8 %69 to i1
  %71 = trunc nuw nsw i64 %indvars.iv.next.1 to i32
  %spec.select.2 = select i1 %70, i32 %spec.select.1, i32 %71
  %72 = getelementptr inbounds [2010 x i32], ptr %5, i64 0, i64 %indvars.iv.next.1
  store i32 %spec.select.2, ptr %72, align 8, !tbaa !5
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %73 = getelementptr inbounds [2010 x i8], ptr @visited, i64 0, i64 %indvars.iv.next.2
  %74 = load i8, ptr %73, align 1, !tbaa !9, !range !16, !noundef !17
  %75 = trunc nuw i8 %74 to i1
  %76 = trunc nuw nsw i64 %indvars.iv.next.2 to i32
  %spec.select.3 = select i1 %75, i32 %spec.select.2, i32 %76
  %77 = getelementptr inbounds [2010 x i32], ptr %5, i64 0, i64 %indvars.iv.next.2
  store i32 %spec.select.3, ptr %77, align 4, !tbaa !5
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %.preheader52.loopexit.unr-lcssa, label %.lr.ph58, !llvm.loop !21

._crit_edge62:                                    ; preds = %.lr.ph61.prol.loopexit, %.lr.ph61, %.preheader52
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #7
  %78 = add nsw i32 %41, 1
  call void @_ZN3BITC2Ei(ptr noundef nonnull align 8 dereferenceable(16) %7, i32 noundef %78)
  call void @llvm.lifetime.start.p0(i64 8040, ptr nonnull %8) #7
  br label %99

.lr.ph61:                                         ; preds = %.lr.ph61.prol.loopexit, %.lr.ph61
  %indvars.iv74 = phi i64 [ %indvars.iv.next75.3, %.lr.ph61 ], [ %indvars.iv74.unr, %.lr.ph61.prol.loopexit ]
  %.259 = phi i32 [ %spec.select51.3, %.lr.ph61 ], [ %.259.unr, %.lr.ph61.prol.loopexit ]
  %79 = getelementptr inbounds [2010 x i8], ptr @visited, i64 0, i64 %indvars.iv74
  %80 = load i8, ptr %79, align 1, !tbaa !9, !range !16, !noundef !17
  %81 = trunc nuw i8 %80 to i1
  %82 = trunc nuw nsw i64 %indvars.iv74 to i32
  %spec.select51 = select i1 %81, i32 %.259, i32 %82
  %83 = getelementptr inbounds [2010 x i32], ptr %6, i64 0, i64 %indvars.iv74
  store i32 %spec.select51, ptr %83, align 4, !tbaa !5
  %indvars.iv.next75 = add nsw i64 %indvars.iv74, -1
  %84 = getelementptr inbounds [2010 x i8], ptr @visited, i64 0, i64 %indvars.iv.next75
  %85 = load i8, ptr %84, align 1, !tbaa !9, !range !16, !noundef !17
  %86 = trunc nuw i8 %85 to i1
  %87 = trunc nuw nsw i64 %indvars.iv.next75 to i32
  %spec.select51.1 = select i1 %86, i32 %spec.select51, i32 %87
  %88 = getelementptr inbounds [2010 x i32], ptr %6, i64 0, i64 %indvars.iv.next75
  store i32 %spec.select51.1, ptr %88, align 4, !tbaa !5
  %indvars.iv.next75.1 = add nsw i64 %indvars.iv74, -2
  %89 = getelementptr inbounds [2010 x i8], ptr @visited, i64 0, i64 %indvars.iv.next75.1
  %90 = load i8, ptr %89, align 1, !tbaa !9, !range !16, !noundef !17
  %91 = trunc nuw i8 %90 to i1
  %92 = trunc nuw nsw i64 %indvars.iv.next75.1 to i32
  %spec.select51.2 = select i1 %91, i32 %spec.select51.1, i32 %92
  %93 = getelementptr inbounds [2010 x i32], ptr %6, i64 0, i64 %indvars.iv.next75.1
  store i32 %spec.select51.2, ptr %93, align 4, !tbaa !5
  %indvars.iv.next75.2 = add nsw i64 %indvars.iv74, -3
  %94 = getelementptr inbounds [2010 x i8], ptr @visited, i64 0, i64 %indvars.iv.next75.2
  %95 = load i8, ptr %94, align 1, !tbaa !9, !range !16, !noundef !17
  %96 = trunc nuw i8 %95 to i1
  %97 = trunc nuw nsw i64 %indvars.iv.next75.2 to i32
  %spec.select51.3 = select i1 %96, i32 %spec.select51.2, i32 %97
  %98 = getelementptr inbounds [2010 x i32], ptr %6, i64 0, i64 %indvars.iv.next75.2
  store i32 %spec.select51.3, ptr %98, align 4, !tbaa !5
  %indvars.iv.next75.3 = add nsw i64 %indvars.iv74, -4
  %.not.3 = icmp eq i64 %indvars.iv.next75.2, 0
  br i1 %.not.3, label %._crit_edge62, label %.lr.ph61, !llvm.loop !22

99:                                               ; preds = %._crit_edge62, %113
  %indvars.iv77 = phi i64 [ 0, %._crit_edge62 ], [ %indvars.iv.next78, %113 ]
  %100 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorISt4pairIiiESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @V, i64 noundef %indvars.iv77) #7
  %101 = getelementptr inbounds i8, ptr %100, i64 4
  %102 = load i32, ptr %101, align 4, !tbaa !15
  %103 = add nsw i32 %102, 1
  invoke void @_ZN3BIT3addEi(ptr noundef nonnull align 8 dereferenceable(16) %7, i32 noundef %103)
          to label %104 unwind label %116

104:                                              ; preds = %99
  %105 = sext i32 %102 to i64
  %106 = getelementptr inbounds [2010 x i32], ptr %5, i64 0, i64 %105
  %107 = load i32, ptr %106, align 4, !tbaa !5
  %108 = add nsw i32 %107, 2
  %109 = getelementptr inbounds [2010 x i32], ptr %6, i64 0, i64 %105
  %110 = load i32, ptr %109, align 4, !tbaa !5
  %111 = add nsw i32 %110, 1
  %112 = invoke noundef i64 @_ZN3BIT3sumEii(ptr noundef nonnull align 8 dereferenceable(16) %7, i32 noundef %108, i32 noundef %111)
          to label %113 unwind label %116

113:                                              ; preds = %104
  %114 = trunc i64 %112 to i32
  %115 = getelementptr inbounds [2010 x i32], ptr %8, i64 0, i64 %105
  store i32 %114, ptr %115, align 4, !tbaa !5
  %indvars.iv.next78 = add nuw nsw i64 %indvars.iv77, 1
  %exitcond83.not = icmp eq i64 %indvars.iv.next78, %indvars.iv89
  br i1 %exitcond83.not, label %.lr.ph66, label %99, !llvm.loop !23

116:                                              ; preds = %104, %99
  %117 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8040, ptr nonnull %8) #7
  call void @_ZN3BITD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %7) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #7
  call void @llvm.lifetime.end.p0(i64 8040, ptr nonnull %6) #7
  call void @llvm.lifetime.end.p0(i64 8040, ptr nonnull %5) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #7
  resume { ptr, i32 } %117

.lr.ph66:                                         ; preds = %113, %135
  %indvars.iv86 = phi i64 [ %indvars.iv.next87, %135 ], [ %indvars.iv84, %113 ]
  %.04164 = phi i32 [ %.1, %135 ], [ 0, %113 ]
  %118 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorISt4pairIiiESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @V, i64 noundef %indvars.iv86) #7
  %119 = getelementptr inbounds i8, ptr %118, i64 4
  %120 = load i32, ptr %119, align 4, !tbaa !15
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [2010 x i32], ptr %8, i64 0, i64 %121
  %123 = load i32, ptr %122, align 4, !tbaa !5
  %124 = load i32, ptr @K, align 4, !tbaa !5
  %.not50 = icmp slt i32 %123, %124
  br i1 %.not50, label %135, label %125

125:                                              ; preds = %.lr.ph66
  %126 = add nsw i32 %.04164, 1
  %127 = load i32, ptr @Q, align 4, !tbaa !5
  %128 = icmp eq i32 %126, %127
  br i1 %128, label %129, label %135

129:                                              ; preds = %125
  %130 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorISt4pairIiiESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @V, i64 noundef %indvars.iv86) #7
  %131 = load i32, ptr %130, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #7
  %132 = sub nsw i32 %131, %35
  store i32 %132, ptr %9, align 4, !tbaa !5
  %133 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %9)
  %134 = load i32, ptr %133, align 4, !tbaa !5
  store i32 %134, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #7
  br label %.loopexit

135:                                              ; preds = %.lr.ph66, %125
  %.1 = phi i32 [ %126, %125 ], [ %.04164, %.lr.ph66 ]
  %indvars.iv.next87 = add nsw i64 %indvars.iv86, -1
  %136 = icmp sgt i64 %indvars.iv86, 0
  br i1 %136, label %.lr.ph66, label %.loopexit, !llvm.loop !24

.loopexit:                                        ; preds = %135, %129
  call void @llvm.lifetime.end.p0(i64 8040, ptr nonnull %8) #7
  call void @_ZN3BITD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %7) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #7
  call void @llvm.lifetime.end.p0(i64 8040, ptr nonnull %6) #7
  call void @llvm.lifetime.end.p0(i64 8040, ptr nonnull %5) #7
  %indvars.iv.next85 = add nuw nsw i64 %indvars.iv84, 1
  %137 = load i32, ptr @N, align 4, !tbaa !5
  %138 = sext i32 %137 to i64
  %139 = icmp slt i64 %indvars.iv.next85, %138
  %indvars.iv.next90 = add nuw nsw i64 %indvars.iv89, 1
  br i1 %139, label %.lr.ph70, label %._crit_edge71.loopexit, !llvm.loop !25
}

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

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPSt4pairIiiESt6vectorIS3_SaIS3_EEEEEvT_S9_(ptr, ptr) local_unnamed_addr #5

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt7reverseIN9__gnu_cxx17__normal_iteratorIPSt4pairIiiESt6vectorIS3_SaIS3_EEEEEvT_S9_(ptr, ptr) local_unnamed_addr #5

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4fillIPbbEvT_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #5

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

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

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #6

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

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

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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { 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 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !6, i64 0}
!14 = !{!"_ZTSSt4pairIiiE", !6, i64 0, !6, i64 4}
!15 = !{!14, !6, i64 4}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.unroll.disable"}
!20 = distinct !{!20, !19}
!21 = distinct !{!21, !12}
!22 = distinct !{!22, !12}
!23 = distinct !{!23, !12}
!24 = distinct !{!24, !12}
!25 = distinct !{!25, !12}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass