; LLVM IR from tangjz/acm-icpc :: lydsy (3417)

; 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"

%struct.Edge = type { i32, i32 }
%struct.Query = type { i32, i32, i32, i32 }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@tot = external dso_local global i32, align 4
@pre = external dso_local global [5001 x i32], align 16
@que = external dso_local global [10002 x i32], align 16
@L = external dso_local global i32, align 4
@R = external dso_local global i32, align 4
@dis = external dso_local global [5001 x [2 x i32]], align 16
@ans = external dso_local global [1000001 x i32], align 16
@e = external dso_local global [10002 x %struct.Edge], align 16
@Q = external dso_local global [1000001 x %struct.Query], align 16
@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4)) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca %struct.Edge, align 4
  %6 = alloca %struct.Edge, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4) @n)
  call void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4) @m)
  call void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4) @q)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #8
  store i32 1, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #8
  br label %15

15:                                               ; preds = %51, %0
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = load i32, ptr @m, align 4, !tbaa !5
  %18 = icmp sle i32 %16, %17
  br i1 %18, label %20, label %19

19:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #8
  br label %54

20:                                               ; preds = %15
  call void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4) %3)
  call void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4) %4)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #8
  %21 = getelementptr inbounds %struct.Edge, ptr %5, i32 0, i32 0
  %22 = load i32, ptr %3, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [5001 x i32], ptr @pre, i64 0, i64 %23
  %25 = load i32, ptr %24, align 4, !tbaa !5
  store i32 %25, ptr %21, align 4, !tbaa !9
  %26 = getelementptr inbounds %struct.Edge, ptr %5, i32 0, i32 1
  %27 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %27, ptr %26, align 4, !tbaa !11
  %28 = load i32, ptr @tot, align 4, !tbaa !5
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr @tot, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [10002 x %struct.Edge], ptr @e, i64 0, i64 %30
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %31, ptr align 4 %5, i64 8, i1 false), !tbaa.struct !12
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #8
  %32 = load i32, ptr @tot, align 4, !tbaa !5
  %33 = load i32, ptr %3, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [5001 x i32], ptr @pre, i64 0, i64 %34
  store i32 %32, ptr %35, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #8
  %36 = getelementptr inbounds %struct.Edge, ptr %6, i32 0, i32 0
  %37 = load i32, ptr %4, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [5001 x i32], ptr @pre, i64 0, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !5
  store i32 %40, ptr %36, align 4, !tbaa !9
  %41 = getelementptr inbounds %struct.Edge, ptr %6, i32 0, i32 1
  %42 = load i32, ptr %3, align 4, !tbaa !5
  store i32 %42, ptr %41, align 4, !tbaa !11
  %43 = load i32, ptr @tot, align 4, !tbaa !5
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr @tot, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [10002 x %struct.Edge], ptr @e, i64 0, i64 %45
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %46, ptr align 4 %6, i64 8, i1 false), !tbaa.struct !12
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #8
  %47 = load i32, ptr @tot, align 4, !tbaa !5
  %48 = load i32, ptr %4, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [5001 x i32], ptr @pre, i64 0, i64 %49
  store i32 %47, ptr %50, align 4, !tbaa !5
  br label %51

51:                                               ; preds = %20
  %52 = load i32, ptr %2, align 4, !tbaa !5
  %53 = add nsw i32 %52, 1
  store i32 %53, ptr %2, align 4, !tbaa !5
  br label %15, !llvm.loop !13

54:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #8
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %55

55:                                               ; preds = %99, %54
  %56 = load i32, ptr %7, align 4, !tbaa !5
  %57 = load i32, ptr @q, align 4, !tbaa !5
  %58 = icmp slt i32 %56, %57
  br i1 %58, label %60, label %59

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

60:                                               ; preds = %55
  %61 = load i32, ptr %7, align 4, !tbaa !5
  %62 = load i32, ptr %7, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [1000001 x %struct.Query], ptr @Q, i64 0, i64 %63
  %65 = getelementptr inbounds %struct.Query, ptr %64, i32 0, i32 0
  store i32 %61, ptr %65, align 16, !tbaa !15
  %66 = load i32, ptr %7, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [1000001 x %struct.Query], ptr @Q, i64 0, i64 %67
  %69 = getelementptr inbounds %struct.Query, ptr %68, i32 0, i32 1
  call void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4) %69)
  %70 = load i32, ptr %7, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [1000001 x %struct.Query], ptr @Q, i64 0, i64 %71
  %73 = getelementptr inbounds %struct.Query, ptr %72, i32 0, i32 2
  call void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4) %73)
  %74 = load i32, ptr %7, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [1000001 x %struct.Query], ptr @Q, i64 0, i64 %75
  %77 = getelementptr inbounds %struct.Query, ptr %76, i32 0, i32 3
  call void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4) %77)
  %78 = load i32, ptr %7, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [1000001 x %struct.Query], ptr @Q, i64 0, i64 %79
  %81 = getelementptr inbounds %struct.Query, ptr %80, i32 0, i32 1
  %82 = load i32, ptr %81, align 4, !tbaa !17
  %83 = load i32, ptr %7, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [1000001 x %struct.Query], ptr @Q, i64 0, i64 %84
  %86 = getelementptr inbounds %struct.Query, ptr %85, i32 0, i32 2
  %87 = load i32, ptr %86, align 8, !tbaa !18
  %88 = icmp sgt i32 %82, %87
  br i1 %88, label %89, label %98

89:                                               ; preds = %60
  %90 = load i32, ptr %7, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [1000001 x %struct.Query], ptr @Q, i64 0, i64 %91
  %93 = getelementptr inbounds %struct.Query, ptr %92, i32 0, i32 1
  %94 = load i32, ptr %7, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [1000001 x %struct.Query], ptr @Q, i64 0, i64 %95
  %97 = getelementptr inbounds %struct.Query, ptr %96, i32 0, i32 2
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %93, ptr noundef nonnull align 4 dereferenceable(4) %97) #8
  br label %98

98:                                               ; preds = %89, %60
  br label %99

99:                                               ; preds = %98
  %100 = load i32, ptr %7, align 4, !tbaa !5
  %101 = add nsw i32 %100, 1
  store i32 %101, ptr %7, align 4, !tbaa !5
  br label %55, !llvm.loop !19

102:                                              ; preds = %59
  %103 = load i32, ptr @q, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds %struct.Query, ptr @Q, i64 %104
  call void @_ZSt4sortIP5QueryEvT_S2_(ptr noundef @Q, ptr noundef %105)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #8
  store i32 1, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #8
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %106

106:                                              ; preds = %295, %102
  %107 = load i32, ptr %8, align 4, !tbaa !5
  %108 = load i32, ptr @n, align 4, !tbaa !5
  %109 = icmp sle i32 %107, %108
  br i1 %109, label %110, label %114

110:                                              ; preds = %106
  %111 = load i32, ptr %9, align 4, !tbaa !5
  %112 = load i32, ptr @q, align 4, !tbaa !5
  %113 = icmp slt i32 %111, %112
  br label %114

114:                                              ; preds = %110, %106
  %115 = phi i1 [ false, %106 ], [ %113, %110 ]
  br i1 %115, label %117, label %116

116:                                              ; preds = %114
  store i32 8, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #8
  br label %298

117:                                              ; preds = %114
  %118 = load i32, ptr %9, align 4, !tbaa !5
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [1000001 x %struct.Query], ptr @Q, i64 0, i64 %119
  %121 = getelementptr inbounds %struct.Query, ptr %120, i32 0, i32 1
  %122 = load i32, ptr %121, align 4, !tbaa !17
  %123 = load i32, ptr %8, align 4, !tbaa !5
  %124 = icmp sgt i32 %122, %123
  br i1 %124, label %125, label %126

125:                                              ; preds = %117
  br label %295

126:                                              ; preds = %117
  store i32 0, ptr @R, align 4, !tbaa !5
  store i32 0, ptr @L, align 4, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 16 @dis, i8 63, i64 40008, i1 false)
  %127 = load i32, ptr %8, align 4, !tbaa !5
  %128 = shl i32 %127, 1
  %129 = load i32, ptr @R, align 4, !tbaa !5
  %130 = add nsw i32 %129, 1
  store i32 %130, ptr @R, align 4, !tbaa !5
  %131 = sext i32 %129 to i64
  %132 = getelementptr inbounds [10002 x i32], ptr @que, i64 0, i64 %131
  store i32 %128, ptr %132, align 4, !tbaa !5
  %133 = load i32, ptr %8, align 4, !tbaa !5
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds [5001 x [2 x i32]], ptr @dis, i64 0, i64 %134
  %136 = getelementptr inbounds [2 x i32], ptr %135, i64 0, i64 0
  store i32 0, ptr %136, align 8, !tbaa !5
  br label %137

137:                                              ; preds = %213, %126
  %138 = load i32, ptr @L, align 4, !tbaa !5
  %139 = load i32, ptr @R, align 4, !tbaa !5
  %140 = icmp slt i32 %138, %139
  br i1 %140, label %141, label %214

141:                                              ; preds = %137
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #8
  %142 = load i32, ptr @L, align 4, !tbaa !5
  %143 = add nsw i32 %142, 1
  store i32 %143, ptr @L, align 4, !tbaa !5
  %144 = sext i32 %142 to i64
  %145 = getelementptr inbounds [10002 x i32], ptr @que, i64 0, i64 %144
  %146 = load i32, ptr %145, align 4, !tbaa !5
  store i32 %146, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #8
  %147 = load i32, ptr %11, align 4, !tbaa !5
  %148 = and i32 %147, 1
  store i32 %148, ptr %12, align 4, !tbaa !5
  %149 = load i32, ptr %11, align 4, !tbaa !5
  %150 = ashr i32 %149, 1
  store i32 %150, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #8
  %151 = load i32, ptr %11, align 4, !tbaa !5
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds [5001 x i32], ptr @pre, i64 0, i64 %152
  %154 = load i32, ptr %153, align 4, !tbaa !5
  store i32 %154, ptr %13, align 4, !tbaa !5
  br label %155

155:                                              ; preds = %207, %141
  %156 = load i32, ptr %13, align 4, !tbaa !5
  %157 = icmp ne i32 %156, 0
  br i1 %157, label %159, label %158

158:                                              ; preds = %155
  store i32 13, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #8
  br label %213

159:                                              ; preds = %155
  %160 = load i32, ptr %13, align 4, !tbaa !5
  %161 = sext i32 %160 to i64
  %162 = getelementptr inbounds [10002 x %struct.Edge], ptr @e, i64 0, i64 %161
  %163 = getelementptr inbounds %struct.Edge, ptr %162, i32 0, i32 1
  %164 = load i32, ptr %163, align 4, !tbaa !11
  %165 = sext i32 %164 to i64
  %166 = getelementptr inbounds [5001 x [2 x i32]], ptr @dis, i64 0, i64 %165
  %167 = load i32, ptr %12, align 4, !tbaa !5
  %168 = xor i32 %167, 1
  %169 = sext i32 %168 to i64
  %170 = getelementptr inbounds [2 x i32], ptr %166, i64 0, i64 %169
  %171 = load i32, ptr %170, align 4, !tbaa !5
  %172 = icmp eq i32 %171, 1061109567
  br i1 %172, label %173, label %206

173:                                              ; preds = %159
  %174 = load i32, ptr %11, align 4, !tbaa !5
  %175 = sext i32 %174 to i64
  %176 = getelementptr inbounds [5001 x [2 x i32]], ptr @dis, i64 0, i64 %175
  %177 = load i32, ptr %12, align 4, !tbaa !5
  %178 = sext i32 %177 to i64
  %179 = getelementptr inbounds [2 x i32], ptr %176, i64 0, i64 %178
  %180 = load i32, ptr %179, align 4, !tbaa !5
  %181 = add nsw i32 %180, 1
  %182 = load i32, ptr %13, align 4, !tbaa !5
  %183 = sext i32 %182 to i64
  %184 = getelementptr inbounds [10002 x %struct.Edge], ptr @e, i64 0, i64 %183
  %185 = getelementptr inbounds %struct.Edge, ptr %184, i32 0, i32 1
  %186 = load i32, ptr %185, align 4, !tbaa !11
  %187 = sext i32 %186 to i64
  %188 = getelementptr inbounds [5001 x [2 x i32]], ptr @dis, i64 0, i64 %187
  %189 = load i32, ptr %12, align 4, !tbaa !5
  %190 = xor i32 %189, 1
  %191 = sext i32 %190 to i64
  %192 = getelementptr inbounds [2 x i32], ptr %188, i64 0, i64 %191
  store i32 %181, ptr %192, align 4, !tbaa !5
  %193 = load i32, ptr %13, align 4, !tbaa !5
  %194 = sext i32 %193 to i64
  %195 = getelementptr inbounds [10002 x %struct.Edge], ptr @e, i64 0, i64 %194
  %196 = getelementptr inbounds %struct.Edge, ptr %195, i32 0, i32 1
  %197 = load i32, ptr %196, align 4, !tbaa !11
  %198 = shl i32 %197, 1
  %199 = load i32, ptr %12, align 4, !tbaa !5
  %200 = xor i32 %199, 1
  %201 = or i32 %198, %200
  %202 = load i32, ptr @R, align 4, !tbaa !5
  %203 = add nsw i32 %202, 1
  store i32 %203, ptr @R, align 4, !tbaa !5
  %204 = sext i32 %202 to i64
  %205 = getelementptr inbounds [10002 x i32], ptr @que, i64 0, i64 %204
  store i32 %201, ptr %205, align 4, !tbaa !5
  br label %206

206:                                              ; preds = %173, %159
  br label %207

207:                                              ; preds = %206
  %208 = load i32, ptr %13, align 4, !tbaa !5
  %209 = sext i32 %208 to i64
  %210 = getelementptr inbounds [10002 x %struct.Edge], ptr @e, i64 0, i64 %209
  %211 = getelementptr inbounds %struct.Edge, ptr %210, i32 0, i32 0
  %212 = load i32, ptr %211, align 8, !tbaa !9
  store i32 %212, ptr %13, align 4, !tbaa !5
  br label %155, !llvm.loop !20

213:                                              ; preds = %158
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  br label %137, !llvm.loop !21

214:                                              ; preds = %137
  br label %215

215:                                              ; preds = %291, %214
  %216 = load i32, ptr %9, align 4, !tbaa !5
  %217 = load i32, ptr @q, align 4, !tbaa !5
  %218 = icmp slt i32 %216, %217
  br i1 %218, label %219, label %227

219:                                              ; preds = %215
  %220 = load i32, ptr %9, align 4, !tbaa !5
  %221 = sext i32 %220 to i64
  %222 = getelementptr inbounds [1000001 x %struct.Query], ptr @Q, i64 0, i64 %221
  %223 = getelementptr inbounds %struct.Query, ptr %222, i32 0, i32 1
  %224 = load i32, ptr %223, align 4, !tbaa !17
  %225 = load i32, ptr %8, align 4, !tbaa !5
  %226 = icmp eq i32 %224, %225
  br label %227

227:                                              ; preds = %219, %215
  %228 = phi i1 [ false, %215 ], [ %226, %219 ]
  br i1 %228, label %229, label %294

229:                                              ; preds = %227
  %230 = load i32, ptr %8, align 4, !tbaa !5
  %231 = load i32, ptr %9, align 4, !tbaa !5
  %232 = sext i32 %231 to i64
  %233 = getelementptr inbounds [1000001 x %struct.Query], ptr @Q, i64 0, i64 %232
  %234 = getelementptr inbounds %struct.Query, ptr %233, i32 0, i32 2
  %235 = load i32, ptr %234, align 8, !tbaa !18
  %236 = icmp ne i32 %230, %235
  br i1 %236, label %243, label %237

237:                                              ; preds = %229
  %238 = load i32, ptr %8, align 4, !tbaa !5
  %239 = sext i32 %238 to i64
  %240 = getelementptr inbounds [5001 x i32], ptr @pre, i64 0, i64 %239
  %241 = load i32, ptr %240, align 4, !tbaa !5
  %242 = icmp ne i32 %241, 0
  br i1 %242, label %243, label %274

243:                                              ; preds = %237, %229
  %244 = load i32, ptr %9, align 4, !tbaa !5
  %245 = sext i32 %244 to i64
  %246 = getelementptr inbounds [1000001 x %struct.Query], ptr @Q, i64 0, i64 %245
  %247 = getelementptr inbounds %struct.Query, ptr %246, i32 0, i32 2
  %248 = load i32, ptr %247, align 8, !tbaa !18
  %249 = sext i32 %248 to i64
  %250 = getelementptr inbounds [5001 x [2 x i32]], ptr @dis, i64 0, i64 %249
  %251 = load i32, ptr %9, align 4, !tbaa !5
  %252 = sext i32 %251 to i64
  %253 = getelementptr inbounds [1000001 x %struct.Query], ptr @Q, i64 0, i64 %252
  %254 = getelementptr inbounds %struct.Query, ptr %253, i32 0, i32 3
  %255 = load i32, ptr %254, align 4, !tbaa !22
  %256 = and i32 %255, 1
  %257 = sext i32 %256 to i64
  %258 = getelementptr inbounds [2 x i32], ptr %250, i64 0, i64 %257
  %259 = load i32, ptr %258, align 4, !tbaa !5
  %260 = load i32, ptr %9, align 4, !tbaa !5
  %261 = sext i32 %260 to i64
  %262 = getelementptr inbounds [1000001 x %struct.Query], ptr @Q, i64 0, i64 %261
  %263 = getelementptr inbounds %struct.Query, ptr %262, i32 0, i32 3
  %264 = load i32, ptr %263, align 4, !tbaa !22
  %265 = icmp sle i32 %259, %264
  %266 = zext i1 %265 to i32
  %267 = load i32, ptr %9, align 4, !tbaa !5
  %268 = sext i32 %267 to i64
  %269 = getelementptr inbounds [1000001 x %struct.Query], ptr @Q, i64 0, i64 %268
  %270 = getelementptr inbounds %struct.Query, ptr %269, i32 0, i32 0
  %271 = load i32, ptr %270, align 16, !tbaa !15
  %272 = sext i32 %271 to i64
  %273 = getelementptr inbounds [1000001 x i32], ptr @ans, i64 0, i64 %272
  store i32 %266, ptr %273, align 4, !tbaa !5
  br label %290

274:                                              ; preds = %237
  %275 = load i32, ptr %9, align 4, !tbaa !5
  %276 = sext i32 %275 to i64
  %277 = getelementptr inbounds [1000001 x %struct.Query], ptr @Q, i64 0, i64 %276
  %278 = getelementptr inbounds %struct.Query, ptr %277, i32 0, i32 3
  %279 = load i32, ptr %278, align 4, !tbaa !22
  %280 = icmp ne i32 %279, 0
  %281 = xor i1 %280, true
  %282 = zext i1 %281 to i32
  %283 = load i32, ptr %9, align 4, !tbaa !5
  %284 = sext i32 %283 to i64
  %285 = getelementptr inbounds [1000001 x %struct.Query], ptr @Q, i64 0, i64 %284
  %286 = getelementptr inbounds %struct.Query, ptr %285, i32 0, i32 0
  %287 = load i32, ptr %286, align 16, !tbaa !15
  %288 = sext i32 %287 to i64
  %289 = getelementptr inbounds [1000001 x i32], ptr @ans, i64 0, i64 %288
  store i32 %282, ptr %289, align 4, !tbaa !5
  br label %290

290:                                              ; preds = %274, %243
  br label %291

291:                                              ; preds = %290
  %292 = load i32, ptr %9, align 4, !tbaa !5
  %293 = add nsw i32 %292, 1
  store i32 %293, ptr %9, align 4, !tbaa !5
  br label %215, !llvm.loop !23

294:                                              ; preds = %227
  br label %295

295:                                              ; preds = %294, %125
  %296 = load i32, ptr %8, align 4, !tbaa !5
  %297 = add nsw i32 %296, 1
  store i32 %297, ptr %8, align 4, !tbaa !5
  br label %106, !llvm.loop !24

298:                                              ; preds = %116
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #8
  store i32 0, ptr %14, align 4, !tbaa !5
  br label %299

299:                                              ; preds = %316, %298
  %300 = load i32, ptr %14, align 4, !tbaa !5
  %301 = load i32, ptr @q, align 4, !tbaa !5
  %302 = icmp slt i32 %300, %301
  br i1 %302, label %304, label %303

303:                                              ; preds = %299
  store i32 19, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #8
  br label %319

304:                                              ; preds = %299
  %305 = load i32, ptr %14, align 4, !tbaa !5
  %306 = sext i32 %305 to i64
  %307 = getelementptr inbounds [1000001 x i32], ptr @ans, i64 0, i64 %306
  %308 = load i32, ptr %307, align 4, !tbaa !5
  %309 = icmp ne i32 %308, 0
  br i1 %309, label %310, label %311

310:                                              ; preds = %304
  br label %312

311:                                              ; preds = %304
  br label %312

312:                                              ; preds = %311, %310
  %313 = phi ptr [ @.str, %310 ], [ @.str.1, %311 ]
  %314 = getelementptr inbounds [4 x i8], ptr %313, i64 0, i64 0
  %315 = call i32 @puts(ptr noundef %314)
  br label %316

316:                                              ; preds = %312
  %317 = load i32, ptr %14, align 4, !tbaa !5
  %318 = add nsw i32 %317, 1
  store i32 %318, ptr %14, align 4, !tbaa !5
  br label %299, !llvm.loop !25

319:                                              ; preds = %303
  ret i32 0
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; 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 nounwind uwtable
declare dso_local void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #4

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

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

declare i32 @puts(ptr noundef) #7

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

!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, !6, i64 0}
!10 = !{!"_ZTS4Edge", !6, i64 0, !6, i64 4}
!11 = !{!10, !6, i64 4}
!12 = !{i64 0, i64 4, !5, i64 4, i64 4, !5}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !6, i64 0}
!16 = !{!"_ZTS5Query", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12}
!17 = !{!16, !6, i64 4}
!18 = !{!16, !6, i64 8}
!19 = distinct !{!19, !14}
!20 = distinct !{!20, !14}
!21 = distinct !{!21, !14}
!22 = !{!16, !6, i64 12}
!23 = distinct !{!23, !14}
!24 = distinct !{!24, !14}
!25 = distinct !{!25, !14}


; 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"

%struct.Edge = type { i32, i32 }
%struct.Query = type { i32, i32, i32, i32 }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@tot = external dso_local local_unnamed_addr global i32, align 4
@pre = external dso_local local_unnamed_addr global [5001 x i32], align 16
@que = external dso_local local_unnamed_addr global [10002 x i32], align 16
@L = external dso_local local_unnamed_addr global i32, align 4
@R = external dso_local local_unnamed_addr global i32, align 4
@dis = external dso_local local_unnamed_addr global [5001 x [2 x i32]], align 16
@ans = external dso_local local_unnamed_addr global [1000001 x i32], align 16
@e = external dso_local local_unnamed_addr global [10002 x %struct.Edge], align 16
@Q = external dso_local global [1000001 x %struct.Query], align 16
@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  tail call void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4) @n)
  tail call void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4) @m)
  tail call void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4) @q)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  %3 = load i32, ptr @m, align 4, !tbaa !5
  %.not64 = icmp slt i32 %3, 1
  br i1 %.not64, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  %4 = load i32, ptr @q, align 4, !tbaa !5
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.lr.ph68, label %._crit_edge.._crit_edge69_crit_edge

._crit_edge.._crit_edge69_crit_edge:              ; preds = %._crit_edge
  %.pre = sext i32 %4 to i64
  br label %._crit_edge69

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.05265 = phi i32 [ %21, %.lr.ph ], [ 1, %0 ]
  call void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4) %2)
  %6 = load i32, ptr %1, align 4, !tbaa !5
  %7 = sext i32 %6 to i64
  %8 = getelementptr inbounds [5001 x i32], ptr @pre, i64 0, i64 %7
  %9 = load i32, ptr %8, align 4, !tbaa !5
  %10 = load i32, ptr %2, align 4, !tbaa !5
  %11 = load i32, ptr @tot, align 4, !tbaa !5
  %12 = add nsw i32 %11, 1
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [10002 x %struct.Edge], ptr @e, i64 0, i64 %13
  store i32 %9, ptr %14, align 8, !tbaa !5
  %.sroa.448.0..sroa_idx = getelementptr inbounds i8, ptr %14, i64 4
  store i32 %10, ptr %.sroa.448.0..sroa_idx, align 4, !tbaa !5
  store i32 %12, ptr %8, align 4, !tbaa !5
  %15 = sext i32 %10 to i64
  %16 = getelementptr inbounds [5001 x i32], ptr @pre, i64 0, i64 %15
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %18 = add nsw i32 %11, 2
  store i32 %18, ptr @tot, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [10002 x %struct.Edge], ptr @e, i64 0, i64 %19
  store i32 %17, ptr %20, align 8, !tbaa !5
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %20, i64 4
  store i32 %6, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !5
  store i32 %18, ptr %16, align 4, !tbaa !5
  %21 = add nuw nsw i32 %.05265, 1
  %22 = load i32, ptr @m, align 4, !tbaa !5
  %.not.not = icmp slt i32 %.05265, %22
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge69:                                    ; preds = %40, %._crit_edge.._crit_edge69_crit_edge
  %.pre-phi = phi i64 [ %.pre, %._crit_edge.._crit_edge69_crit_edge ], [ %42, %40 ]
  %23 = getelementptr inbounds %struct.Query, ptr @Q, i64 %.pre-phi
  call void @_ZSt4sortIP5QueryEvT_S2_(ptr noundef nonnull @Q, ptr noundef nonnull %23)
  %24 = load i32, ptr @n, align 4, !tbaa !5
  %25 = load i32, ptr @q, align 4
  %26 = icmp sgt i32 %24, 0
  %27 = icmp sgt i32 %25, 0
  %28 = select i1 %26, i1 %27, i1 false
  br i1 %28, label %.lr.ph94, label %.preheader

.lr.ph94:                                         ; preds = %._crit_edge69
  %29 = zext nneg i32 %25 to i64
  %30 = zext nneg i32 %24 to i64
  br label %44

.lr.ph68:                                         ; preds = %._crit_edge, %40
  %indvars.iv = phi i64 [ %indvars.iv.next, %40 ], [ 0, %._crit_edge ]
  %31 = getelementptr inbounds [1000001 x %struct.Query], ptr @Q, i64 0, i64 %indvars.iv
  %32 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %32, ptr %31, align 16, !tbaa !11
  %33 = getelementptr inbounds i8, ptr %31, i64 4
  call void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4) %33)
  %34 = getelementptr inbounds i8, ptr %31, i64 8
  call void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4) %34)
  %35 = getelementptr inbounds i8, ptr %31, i64 12
  call void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4) %35)
  %36 = load i32, ptr %33, align 4, !tbaa !13
  %37 = load i32, ptr %34, align 8, !tbaa !14
  %38 = icmp sgt i32 %36, %37
  br i1 %38, label %39, label %40

39:                                               ; preds = %.lr.ph68
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %33, ptr noundef nonnull align 4 dereferenceable(4) %34) #7
  br label %40

40:                                               ; preds = %.lr.ph68, %39
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %41 = load i32, ptr @q, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = icmp slt i64 %indvars.iv.next, %42
  br i1 %43, label %.lr.ph68, label %._crit_edge69, !llvm.loop !15

.preheader:                                       ; preds = %.critedge, %111, %._crit_edge69
  br i1 %27, label %.lr.ph96, label %._crit_edge97

44:                                               ; preds = %.lr.ph94, %.critedge
  %indvars.iv107 = phi i64 [ 1, %.lr.ph94 ], [ %indvars.iv.next108, %.critedge ]
  %.05392 = phi i32 [ 0, %.lr.ph94 ], [ %.2, %.critedge ]
  %45 = sext i32 %.05392 to i64
  %46 = getelementptr inbounds [1000001 x %struct.Query], ptr @Q, i64 0, i64 %45, i32 1
  %47 = load i32, ptr %46, align 4, !tbaa !13
  %48 = sext i32 %47 to i64
  %49 = icmp slt i64 %indvars.iv107, %48
  br i1 %49, label %.critedge, label %.lr.ph82.preheader

.lr.ph82.preheader:                               ; preds = %44
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(40008) @dis, i8 63, i64 40008, i1 false)
  store i32 1, ptr @R, align 4, !tbaa !5
  %indvars.iv107.tr = trunc i64 %indvars.iv107 to i32
  %50 = shl i32 %indvars.iv107.tr, 1
  store i32 %50, ptr @que, align 16, !tbaa !5
  %51 = getelementptr inbounds [5001 x [2 x i32]], ptr @dis, i64 0, i64 %indvars.iv107
  store i32 0, ptr %51, align 8, !tbaa !5
  br label %.lr.ph82

.loopexit:                                        ; preds = %85, %.lr.ph82
  %R.promoted78 = phi i32 [ %R.promoted7980, %.lr.ph82 ], [ %R.promoted76, %85 ]
  %52 = sext i32 %R.promoted78 to i64
  %53 = icmp slt i64 %indvars.iv.next102, %52
  br i1 %53, label %.lr.ph82, label %.preheader63, !llvm.loop !16

.preheader63:                                     ; preds = %.loopexit
  %54 = trunc nuw nsw i64 %indvars.iv.next102 to i32
  store i32 %54, ptr @L, align 4, !tbaa !5
  %55 = icmp slt i32 %.05392, %25
  br i1 %55, label %.lr.ph85, label %.critedge

.lr.ph85:                                         ; preds = %.preheader63
  %56 = getelementptr inbounds [5001 x i32], ptr @pre, i64 0, i64 %indvars.iv107
  br label %87

.lr.ph82:                                         ; preds = %.lr.ph82.preheader, %.loopexit
  %indvars.iv101 = phi i64 [ 0, %.lr.ph82.preheader ], [ %indvars.iv.next102, %.loopexit ]
  %R.promoted7980 = phi i32 [ 1, %.lr.ph82.preheader ], [ %R.promoted78, %.loopexit ]
  %indvars.iv.next102 = add nuw nsw i64 %indvars.iv101, 1
  %57 = getelementptr inbounds [10002 x i32], ptr @que, i64 0, i64 %indvars.iv101
  %58 = load i32, ptr %57, align 4, !tbaa !5
  %59 = ashr i32 %58, 1
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [5001 x i32], ptr @pre, i64 0, i64 %60
  %.05170 = load i32, ptr %61, align 4, !tbaa !5
  %.not6271 = icmp eq i32 %.05170, 0
  br i1 %.not6271, label %.loopexit, label %.lr.ph74

.lr.ph74:                                         ; preds = %.lr.ph82
  %62 = and i32 %58, 1
  %63 = xor i32 %62, 1
  %64 = zext nneg i32 %63 to i64
  %65 = zext nneg i32 %62 to i64
  %66 = getelementptr inbounds [5001 x [2 x i32]], ptr @dis, i64 0, i64 %60, i64 %65
  br label %67

67:                                               ; preds = %.lr.ph74, %85
  %R.promoted77 = phi i32 [ %R.promoted7980, %.lr.ph74 ], [ %R.promoted76, %85 ]
  %.05172 = phi i32 [ %.05170, %.lr.ph74 ], [ %.051, %85 ]
  %68 = phi i32 [ %R.promoted7980, %.lr.ph74 ], [ %86, %85 ]
  %69 = sext i32 %.05172 to i64
  %70 = getelementptr inbounds [10002 x %struct.Edge], ptr @e, i64 0, i64 %69
  %71 = getelementptr inbounds i8, ptr %70, i64 4
  %72 = load i32, ptr %71, align 4, !tbaa !17
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [5001 x [2 x i32]], ptr @dis, i64 0, i64 %73, i64 %64
  %75 = load i32, ptr %74, align 4, !tbaa !5
  %76 = icmp eq i32 %75, 1061109567
  br i1 %76, label %77, label %85

77:                                               ; preds = %67
  %78 = load i32, ptr %66, align 4, !tbaa !5
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr %74, align 4, !tbaa !5
  %80 = shl i32 %72, 1
  %81 = or disjoint i32 %80, %63
  %82 = add nsw i32 %68, 1
  store i32 %82, ptr @R, align 4, !tbaa !5
  %83 = sext i32 %68 to i64
  %84 = getelementptr inbounds [10002 x i32], ptr @que, i64 0, i64 %83
  store i32 %81, ptr %84, align 4, !tbaa !5
  br label %85

85:                                               ; preds = %67, %77
  %R.promoted76 = phi i32 [ %R.promoted77, %67 ], [ %82, %77 ]
  %86 = phi i32 [ %68, %67 ], [ %82, %77 ]
  %.051 = load i32, ptr %70, align 8, !tbaa !5
  %.not62 = icmp eq i32 %.051, 0
  br i1 %.not62, label %.loopexit, label %67, !llvm.loop !19

87:                                               ; preds = %.lr.ph85, %111
  %indvars.iv104 = phi i64 [ %45, %.lr.ph85 ], [ %indvars.iv.next105, %111 ]
  %88 = getelementptr inbounds [1000001 x %struct.Query], ptr @Q, i64 0, i64 %indvars.iv104
  %89 = getelementptr inbounds i8, ptr %88, i64 4
  %90 = load i32, ptr %89, align 4, !tbaa !13
  %91 = zext i32 %90 to i64
  %92 = icmp eq i64 %indvars.iv107, %91
  br i1 %92, label %93, label %.critedge.loopexit

93:                                               ; preds = %87
  %94 = getelementptr inbounds i8, ptr %88, i64 8
  %95 = load i32, ptr %94, align 8, !tbaa !14
  %96 = zext i32 %95 to i64
  %.not59 = icmp eq i64 %indvars.iv107, %96
  br i1 %.not59, label %97, label %99

97:                                               ; preds = %93
  %98 = load i32, ptr %56, align 4, !tbaa !5
  %.not60 = icmp eq i32 %98, 0
  br i1 %.not60, label %108, label %99

99:                                               ; preds = %97, %93
  %100 = sext i32 %95 to i64
  %101 = getelementptr inbounds i8, ptr %88, i64 12
  %102 = load i32, ptr %101, align 4, !tbaa !20
  %103 = and i32 %102, 1
  %104 = zext nneg i32 %103 to i64
  %105 = getelementptr inbounds [5001 x [2 x i32]], ptr @dis, i64 0, i64 %100, i64 %104
  %106 = load i32, ptr %105, align 4, !tbaa !5
  %107 = icmp sle i32 %106, %102
  br label %111

108:                                              ; preds = %97
  %109 = getelementptr inbounds i8, ptr %88, i64 12
  %110 = load i32, ptr %109, align 4, !tbaa !20
  %.not61 = icmp eq i32 %110, 0
  br label %111

111:                                              ; preds = %99, %108
  %.sink122 = phi i1 [ %107, %99 ], [ %.not61, %108 ]
  %112 = zext i1 %.sink122 to i32
  %113 = load i32, ptr %88, align 16, !tbaa !11
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [1000001 x i32], ptr @ans, i64 0, i64 %114
  store i32 %112, ptr %115, align 4, !tbaa !5
  %indvars.iv.next105 = add nsw i64 %indvars.iv104, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next105, %29
  br i1 %exitcond.not, label %.preheader, label %87, !llvm.loop !21

.critedge.loopexit:                               ; preds = %87
  %116 = trunc nsw i64 %indvars.iv104 to i32
  br label %.critedge

.critedge:                                        ; preds = %.critedge.loopexit, %.preheader63, %44
  %.2 = phi i32 [ %.05392, %44 ], [ %.05392, %.preheader63 ], [ %116, %.critedge.loopexit ]
  %indvars.iv.next108 = add nuw nsw i64 %indvars.iv107, 1
  %117 = icmp ult i64 %indvars.iv107, %30
  %118 = icmp slt i32 %.2, %25
  %119 = select i1 %117, i1 %118, i1 false
  br i1 %119, label %44, label %.preheader, !llvm.loop !22

._crit_edge97:                                    ; preds = %.lr.ph96, %.preheader
  ret i32 0

.lr.ph96:                                         ; preds = %.preheader, %.lr.ph96
  %indvars.iv110 = phi i64 [ %indvars.iv.next111, %.lr.ph96 ], [ 0, %.preheader ]
  %120 = getelementptr inbounds [1000001 x i32], ptr @ans, i64 0, i64 %indvars.iv110
  %121 = load i32, ptr %120, align 4, !tbaa !5
  %.not58 = icmp eq i32 %121, 0
  %.str..str.1 = select i1 %.not58, ptr @.str.1, ptr @.str
  %122 = call i32 @puts(ptr noundef nonnull dereferenceable(1) %.str..str.1)
  %indvars.iv.next111 = add nuw nsw i64 %indvars.iv110, 1
  %123 = load i32, ptr @q, align 4, !tbaa !5
  %124 = sext i32 %123 to i64
  %125 = icmp slt i64 %indvars.iv.next111, %124
  br i1 %125, label %.lr.ph96, label %._crit_edge97, !llvm.loop !23
}

; 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIP5QueryEvT_S2_(ptr noundef, ptr noundef) local_unnamed_addr #4

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

; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #6

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #7 = { 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, !6, i64 0}
!12 = !{!"_ZTS5Query", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12}
!13 = !{!12, !6, i64 4}
!14 = !{!12, !6, i64 8}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = !{!18, !6, i64 4}
!18 = !{!"_ZTS4Edge", !6, i64 0, !6, i64 4}
!19 = distinct !{!19, !10}
!20 = !{!12, !6, i64 12}
!21 = distinct !{!21, !10}
!22 = distinct !{!22, !10}
!23 = distinct !{!23, !10}


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