; LLVM IR from tangjz/acm-icpc :: self_training/2015-02-23 (D)

; 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::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::_Select1st<std::pair<const std::pair<int, int>, int>>, std::less<std::pair<int, int>>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::_Select1st<std::pair<const std::pair<int, int>, int>>, std::less<std::pair<int, int>>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"struct.std::pair" = type { i32, i32 }

@Hash = external dso_local global %"class.std::map", align 8
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@p = external dso_local global [10001 x i32], align 16
@fa = external dso_local global [10001 x i32], align 16
@a = external dso_local global [20001 x i32], align 16
@b = external dso_local global [20001 x i32], align 16
@query = external dso_local global [50001 x [2 x i32]], align 16
@ans = external dso_local global [50001 x i32], align 16
@vis = external dso_local global [20001 x i8], align 16
@flag = external dso_local global i8, align 1
@op = external dso_local global [10 x i8], align 1
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z4findi(i32 noundef) #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 %"struct.std::pair", align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca %"struct.std::pair", 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
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  br label %17

17:                                               ; preds = %325, %0
  %18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  %19 = icmp ne i32 %18, -1
  br i1 %19, label %20, label %326

20:                                               ; preds = %17
  %21 = load i8, ptr @flag, align 1, !tbaa !5, !range !9, !noundef !10
  %22 = trunc i8 %21 to i1
  br i1 %22, label %23, label %25

23:                                               ; preds = %20
  %24 = call i32 @putchar(i32 noundef 10)
  br label %26

25:                                               ; preds = %20
  store i8 1, ptr @flag, align 1, !tbaa !5
  br label %26

26:                                               ; preds = %25, %23
  call void @_ZNSt3mapISt4pairIiiEiSt4lessIS1_ESaIS0_IKS1_iEEE5clearEv(ptr noundef nonnull align 8 dereferenceable(48) @Hash) #8
  call void @llvm.memset.p0.i64(ptr align 16 @vis, i8 0, i64 20001, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #8
  store i32 0, ptr %2, align 4, !tbaa !11
  br label %27

27:                                               ; preds = %41, %26
  %28 = load i32, ptr %2, align 4, !tbaa !11
  %29 = load i32, ptr @n, align 4, !tbaa !11
  %30 = icmp slt i32 %28, %29
  br i1 %30, label %32, label %31

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

32:                                               ; preds = %27
  %33 = load i32, ptr %2, align 4, !tbaa !11
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds i32, ptr @p, i64 %34
  %36 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %35)
  %37 = load i32, ptr %2, align 4, !tbaa !11
  %38 = load i32, ptr %2, align 4, !tbaa !11
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [10001 x i32], ptr @fa, i64 0, i64 %39
  store i32 %37, ptr %40, align 4, !tbaa !11
  br label %41

41:                                               ; preds = %32
  %42 = load i32, ptr %2, align 4, !tbaa !11
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %2, align 4, !tbaa !11
  br label %27, !llvm.loop !13

44:                                               ; preds = %31
  %45 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #8
  store i32 0, ptr %3, align 4, !tbaa !11
  br label %46

46:                                               ; preds = %85, %44
  %47 = load i32, ptr %3, align 4, !tbaa !11
  %48 = load i32, ptr @m, align 4, !tbaa !11
  %49 = icmp slt i32 %47, %48
  br i1 %49, label %51, label %50

50:                                               ; preds = %46
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #8
  br label %88

51:                                               ; preds = %46
  %52 = load i32, ptr %3, align 4, !tbaa !11
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds i32, ptr @a, i64 %53
  %55 = load i32, ptr %3, align 4, !tbaa !11
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds i32, ptr @b, i64 %56
  %58 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %54, ptr noundef %57)
  %59 = load i32, ptr %3, align 4, !tbaa !11
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [20001 x i32], ptr @a, i64 0, i64 %60
  %62 = load i32, ptr %61, align 4, !tbaa !11
  %63 = load i32, ptr %3, align 4, !tbaa !11
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [20001 x i32], ptr @b, i64 0, i64 %64
  %66 = load i32, ptr %65, align 4, !tbaa !11
  %67 = icmp sgt i32 %62, %66
  br i1 %67, label %68, label %75

68:                                               ; preds = %51
  %69 = load i32, ptr %3, align 4, !tbaa !11
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [20001 x i32], ptr @a, i64 0, i64 %70
  %72 = load i32, ptr %3, align 4, !tbaa !11
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [20001 x i32], ptr @b, i64 0, i64 %73
  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) %71, ptr noundef nonnull align 4 dereferenceable(4) %74) #8
  br label %75

75:                                               ; preds = %68, %51
  %76 = load i32, ptr %3, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #8
  %77 = load i32, ptr %3, align 4, !tbaa !11
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [20001 x i32], ptr @a, i64 0, i64 %78
  %80 = load i32, ptr %3, align 4, !tbaa !11
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [20001 x i32], ptr @b, i64 0, i64 %81
  %83 = call i64 @_ZSt9make_pairIRiS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %79, ptr noundef nonnull align 4 dereferenceable(4) %82)
  store i64 %83, ptr %4, align 4
  %84 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapISt4pairIiiEiSt4lessIS1_ESaIS0_IKS1_iEEEixEOS1_(ptr noundef nonnull align 8 dereferenceable(48) @Hash, ptr noundef nonnull align 4 dereferenceable(8) %4)
  store i32 %76, ptr %84, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #8
  br label %85

85:                                               ; preds = %75
  %86 = load i32, ptr %3, align 4, !tbaa !11
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr %3, align 4, !tbaa !11
  br label %46, !llvm.loop !15

88:                                               ; preds = %50
  %89 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @q)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #8
  store i32 0, ptr %5, align 4, !tbaa !11
  br label %90

90:                                               ; preds = %136, %88
  %91 = load i32, ptr %5, align 4, !tbaa !11
  %92 = load i32, ptr @q, align 4, !tbaa !11
  %93 = icmp slt i32 %91, %92
  br i1 %93, label %95, label %94

94:                                               ; preds = %90
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #8
  br label %139

95:                                               ; preds = %90
  %96 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef @op)
  %97 = load i8, ptr @op, align 1, !tbaa !16
  %98 = sext i8 %97 to i32
  %99 = icmp eq i32 %98, 113
  br i1 %99, label %100, label %110

100:                                              ; preds = %95
  %101 = load i32, ptr %5, align 4, !tbaa !11
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [50001 x [2 x i32]], ptr @query, i64 0, i64 %102
  %104 = getelementptr inbounds [2 x i32], ptr %103, i64 0, i64 0
  store i32 0, ptr %104, align 8, !tbaa !11
  %105 = load i32, ptr %5, align 4, !tbaa !11
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [50001 x [2 x i32]], ptr @query, i64 0, i64 %106
  %108 = getelementptr inbounds [2 x i32], ptr %107, i64 0, i64 1
  %109 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %108)
  br label %135

110:                                              ; preds = %95
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #8
  %111 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %6, ptr noundef %7)
  %112 = load i32, ptr %6, align 4, !tbaa !11
  %113 = load i32, ptr %7, align 4, !tbaa !11
  %114 = icmp sgt i32 %112, %113
  br i1 %114, label %115, label %116

115:                                              ; preds = %110
  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) %6, ptr noundef nonnull align 4 dereferenceable(4) %7) #8
  br label %116

116:                                              ; preds = %115, %110
  %117 = load i32, ptr %5, align 4, !tbaa !11
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [50001 x [2 x i32]], ptr @query, i64 0, i64 %118
  %120 = getelementptr inbounds [2 x i32], ptr %119, i64 0, i64 0
  store i32 1, ptr %120, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #8
  %121 = call i64 @_ZSt9make_pairIRiS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(4) %7)
  store i64 %121, ptr %8, align 4
  %122 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapISt4pairIiiEiSt4lessIS1_ESaIS0_IKS1_iEEEixEOS1_(ptr noundef nonnull align 8 dereferenceable(48) @Hash, ptr noundef nonnull align 4 dereferenceable(8) %8)
  %123 = load i32, ptr %122, align 4, !tbaa !11
  %124 = load i32, ptr %5, align 4, !tbaa !11
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [50001 x [2 x i32]], ptr @query, i64 0, i64 %125
  %127 = getelementptr inbounds [2 x i32], ptr %126, i64 0, i64 1
  store i32 %123, ptr %127, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #8
  %128 = load i32, ptr %5, align 4, !tbaa !11
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds [50001 x [2 x i32]], ptr @query, i64 0, i64 %129
  %131 = getelementptr inbounds [2 x i32], ptr %130, i64 0, i64 1
  %132 = load i32, ptr %131, align 4, !tbaa !11
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds [20001 x i8], ptr @vis, i64 0, i64 %133
  store i8 1, ptr %134, align 1, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #8
  br label %135

135:                                              ; preds = %116, %100
  br label %136

136:                                              ; preds = %135
  %137 = load i32, ptr %5, align 4, !tbaa !11
  %138 = add nsw i32 %137, 1
  store i32 %138, ptr %5, align 4, !tbaa !11
  br label %90, !llvm.loop !17

139:                                              ; preds = %94
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #8
  store i32 0, ptr %9, align 4, !tbaa !11
  br label %140

140:                                              ; preds = %192, %139
  %141 = load i32, ptr %9, align 4, !tbaa !11
  %142 = load i32, ptr @m, align 4, !tbaa !11
  %143 = icmp slt i32 %141, %142
  br i1 %143, label %145, label %144

144:                                              ; preds = %140
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #8
  br label %195

145:                                              ; preds = %140
  %146 = load i32, ptr %9, align 4, !tbaa !11
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds [20001 x i8], ptr @vis, i64 0, i64 %147
  %149 = load i8, ptr %148, align 1, !tbaa !5, !range !9, !noundef !10
  %150 = trunc i8 %149 to i1
  br i1 %150, label %191, label %151

151:                                              ; preds = %145
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #8
  %152 = load i32, ptr %9, align 4, !tbaa !11
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds [20001 x i32], ptr @a, i64 0, i64 %153
  %155 = load i32, ptr %154, align 4, !tbaa !11
  %156 = call noundef i32 @_Z4findi(i32 noundef %155)
  store i32 %156, ptr %10, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #8
  %157 = load i32, ptr %9, align 4, !tbaa !11
  %158 = sext i32 %157 to i64
  %159 = getelementptr inbounds [20001 x i32], ptr @b, i64 0, i64 %158
  %160 = load i32, ptr %159, align 4, !tbaa !11
  %161 = call noundef i32 @_Z4findi(i32 noundef %160)
  store i32 %161, ptr %11, align 4, !tbaa !11
  %162 = load i32, ptr %10, align 4, !tbaa !11
  %163 = sext i32 %162 to i64
  %164 = getelementptr inbounds [10001 x i32], ptr @p, i64 0, i64 %163
  %165 = load i32, ptr %164, align 4, !tbaa !11
  %166 = load i32, ptr %11, align 4, !tbaa !11
  %167 = sext i32 %166 to i64
  %168 = getelementptr inbounds [10001 x i32], ptr @p, i64 0, i64 %167
  %169 = load i32, ptr %168, align 4, !tbaa !11
  %170 = icmp sgt i32 %165, %169
  br i1 %170, label %185, label %171

171:                                              ; preds = %151
  %172 = load i32, ptr %10, align 4, !tbaa !11
  %173 = sext i32 %172 to i64
  %174 = getelementptr inbounds [10001 x i32], ptr @p, i64 0, i64 %173
  %175 = load i32, ptr %174, align 4, !tbaa !11
  %176 = load i32, ptr %11, align 4, !tbaa !11
  %177 = sext i32 %176 to i64
  %178 = getelementptr inbounds [10001 x i32], ptr @p, i64 0, i64 %177
  %179 = load i32, ptr %178, align 4, !tbaa !11
  %180 = icmp eq i32 %175, %179
  br i1 %180, label %181, label %186

181:                                              ; preds = %171
  %182 = load i32, ptr %10, align 4, !tbaa !11
  %183 = load i32, ptr %11, align 4, !tbaa !11
  %184 = icmp slt i32 %182, %183
  br i1 %184, label %185, label %186

185:                                              ; preds = %181, %151
  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) %10, ptr noundef nonnull align 4 dereferenceable(4) %11) #8
  br label %186

186:                                              ; preds = %185, %181, %171
  %187 = load i32, ptr %11, align 4, !tbaa !11
  %188 = load i32, ptr %10, align 4, !tbaa !11
  %189 = sext i32 %188 to i64
  %190 = getelementptr inbounds [10001 x i32], ptr @fa, i64 0, i64 %189
  store i32 %187, ptr %190, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  br label %191

191:                                              ; preds = %186, %145
  br label %192

192:                                              ; preds = %191
  %193 = load i32, ptr %9, align 4, !tbaa !11
  %194 = add nsw i32 %193, 1
  store i32 %194, ptr %9, align 4, !tbaa !11
  br label %140, !llvm.loop !18

195:                                              ; preds = %144
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #8
  %196 = load i32, ptr @q, align 4, !tbaa !11
  %197 = sub nsw i32 %196, 1
  store i32 %197, ptr %12, align 4, !tbaa !11
  br label %198

198:                                              ; preds = %299, %195
  %199 = load i32, ptr %12, align 4, !tbaa !11
  %200 = icmp sge i32 %199, 0
  br i1 %200, label %202, label %201

201:                                              ; preds = %198
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #8
  br label %302

202:                                              ; preds = %198
  %203 = load i32, ptr %12, align 4, !tbaa !11
  %204 = sext i32 %203 to i64
  %205 = getelementptr inbounds [50001 x [2 x i32]], ptr @query, i64 0, i64 %204
  %206 = getelementptr inbounds [2 x i32], ptr %205, i64 0, i64 0
  %207 = load i32, ptr %206, align 8, !tbaa !11
  %208 = icmp ne i32 %207, 0
  br i1 %208, label %209, label %268

209:                                              ; preds = %202
  %210 = load i32, ptr %12, align 4, !tbaa !11
  %211 = sext i32 %210 to i64
  %212 = getelementptr inbounds [50001 x [2 x i32]], ptr @query, i64 0, i64 %211
  %213 = getelementptr inbounds [2 x i32], ptr %212, i64 0, i64 1
  %214 = load i32, ptr %213, align 4, !tbaa !11
  %215 = sext i32 %214 to i64
  %216 = getelementptr inbounds [20001 x i8], ptr @vis, i64 0, i64 %215
  %217 = load i8, ptr %216, align 1, !tbaa !5, !range !9, !noundef !10
  %218 = trunc i8 %217 to i1
  br i1 %218, label %220, label %219

219:                                              ; preds = %209
  br label %299

220:                                              ; preds = %209
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #8
  %221 = load i32, ptr %12, align 4, !tbaa !11
  %222 = sext i32 %221 to i64
  %223 = getelementptr inbounds [50001 x [2 x i32]], ptr @query, i64 0, i64 %222
  %224 = getelementptr inbounds [2 x i32], ptr %223, i64 0, i64 1
  %225 = load i32, ptr %224, align 4, !tbaa !11
  %226 = sext i32 %225 to i64
  %227 = getelementptr inbounds [20001 x i32], ptr @a, i64 0, i64 %226
  %228 = load i32, ptr %227, align 4, !tbaa !11
  %229 = call noundef i32 @_Z4findi(i32 noundef %228)
  store i32 %229, ptr %13, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #8
  %230 = load i32, ptr %12, align 4, !tbaa !11
  %231 = sext i32 %230 to i64
  %232 = getelementptr inbounds [50001 x [2 x i32]], ptr @query, i64 0, i64 %231
  %233 = getelementptr inbounds [2 x i32], ptr %232, i64 0, i64 1
  %234 = load i32, ptr %233, align 4, !tbaa !11
  %235 = sext i32 %234 to i64
  %236 = getelementptr inbounds [20001 x i32], ptr @b, i64 0, i64 %235
  %237 = load i32, ptr %236, align 4, !tbaa !11
  %238 = call noundef i32 @_Z4findi(i32 noundef %237)
  store i32 %238, ptr %14, align 4, !tbaa !11
  %239 = load i32, ptr %13, align 4, !tbaa !11
  %240 = sext i32 %239 to i64
  %241 = getelementptr inbounds [10001 x i32], ptr @p, i64 0, i64 %240
  %242 = load i32, ptr %241, align 4, !tbaa !11
  %243 = load i32, ptr %14, align 4, !tbaa !11
  %244 = sext i32 %243 to i64
  %245 = getelementptr inbounds [10001 x i32], ptr @p, i64 0, i64 %244
  %246 = load i32, ptr %245, align 4, !tbaa !11
  %247 = icmp sgt i32 %242, %246
  br i1 %247, label %262, label %248

248:                                              ; preds = %220
  %249 = load i32, ptr %13, align 4, !tbaa !11
  %250 = sext i32 %249 to i64
  %251 = getelementptr inbounds [10001 x i32], ptr @p, i64 0, i64 %250
  %252 = load i32, ptr %251, align 4, !tbaa !11
  %253 = load i32, ptr %14, align 4, !tbaa !11
  %254 = sext i32 %253 to i64
  %255 = getelementptr inbounds [10001 x i32], ptr @p, i64 0, i64 %254
  %256 = load i32, ptr %255, align 4, !tbaa !11
  %257 = icmp eq i32 %252, %256
  br i1 %257, label %258, label %263

258:                                              ; preds = %248
  %259 = load i32, ptr %13, align 4, !tbaa !11
  %260 = load i32, ptr %14, align 4, !tbaa !11
  %261 = icmp slt i32 %259, %260
  br i1 %261, label %262, label %263

262:                                              ; preds = %258, %220
  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) %13, ptr noundef nonnull align 4 dereferenceable(4) %14) #8
  br label %263

263:                                              ; preds = %262, %258, %248
  %264 = load i32, ptr %14, align 4, !tbaa !11
  %265 = load i32, ptr %13, align 4, !tbaa !11
  %266 = sext i32 %265 to i64
  %267 = getelementptr inbounds [10001 x i32], ptr @fa, i64 0, i64 %266
  store i32 %264, ptr %267, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #8
  br label %298

268:                                              ; preds = %202
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #8
  %269 = load i32, ptr %12, align 4, !tbaa !11
  %270 = sext i32 %269 to i64
  %271 = getelementptr inbounds [50001 x [2 x i32]], ptr @query, i64 0, i64 %270
  %272 = getelementptr inbounds [2 x i32], ptr %271, i64 0, i64 1
  %273 = load i32, ptr %272, align 4, !tbaa !11
  %274 = call noundef i32 @_Z4findi(i32 noundef %273)
  store i32 %274, ptr %15, align 4, !tbaa !11
  %275 = load i32, ptr %15, align 4, !tbaa !11
  %276 = sext i32 %275 to i64
  %277 = getelementptr inbounds [10001 x i32], ptr @p, i64 0, i64 %276
  %278 = load i32, ptr %277, align 4, !tbaa !11
  %279 = load i32, ptr %12, align 4, !tbaa !11
  %280 = sext i32 %279 to i64
  %281 = getelementptr inbounds [50001 x [2 x i32]], ptr @query, i64 0, i64 %280
  %282 = getelementptr inbounds [2 x i32], ptr %281, i64 0, i64 1
  %283 = load i32, ptr %282, align 4, !tbaa !11
  %284 = sext i32 %283 to i64
  %285 = getelementptr inbounds [10001 x i32], ptr @p, i64 0, i64 %284
  %286 = load i32, ptr %285, align 4, !tbaa !11
  %287 = icmp sgt i32 %278, %286
  br i1 %287, label %288, label %293

288:                                              ; preds = %268
  %289 = load i32, ptr %15, align 4, !tbaa !11
  %290 = load i32, ptr %12, align 4, !tbaa !11
  %291 = sext i32 %290 to i64
  %292 = getelementptr inbounds [50001 x i32], ptr @ans, i64 0, i64 %291
  store i32 %289, ptr %292, align 4, !tbaa !11
  br label %297

293:                                              ; preds = %268
  %294 = load i32, ptr %12, align 4, !tbaa !11
  %295 = sext i32 %294 to i64
  %296 = getelementptr inbounds [50001 x i32], ptr @ans, i64 0, i64 %295
  store i32 -1, ptr %296, align 4, !tbaa !11
  br label %297

297:                                              ; preds = %293, %288
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #8
  br label %298

298:                                              ; preds = %297, %263
  br label %299

299:                                              ; preds = %298, %219
  %300 = load i32, ptr %12, align 4, !tbaa !11
  %301 = add nsw i32 %300, -1
  store i32 %301, ptr %12, align 4, !tbaa !11
  br label %198, !llvm.loop !19

302:                                              ; preds = %201
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #8
  store i32 0, ptr %16, align 4, !tbaa !11
  br label %303

303:                                              ; preds = %322, %302
  %304 = load i32, ptr %16, align 4, !tbaa !11
  %305 = load i32, ptr @q, align 4, !tbaa !11
  %306 = icmp slt i32 %304, %305
  br i1 %306, label %308, label %307

307:                                              ; preds = %303
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #8
  br label %325

308:                                              ; preds = %303
  %309 = load i32, ptr %16, align 4, !tbaa !11
  %310 = sext i32 %309 to i64
  %311 = getelementptr inbounds [50001 x [2 x i32]], ptr @query, i64 0, i64 %310
  %312 = getelementptr inbounds [2 x i32], ptr %311, i64 0, i64 0
  %313 = load i32, ptr %312, align 8, !tbaa !11
  %314 = icmp ne i32 %313, 0
  br i1 %314, label %321, label %315

315:                                              ; preds = %308
  %316 = load i32, ptr %16, align 4, !tbaa !11
  %317 = sext i32 %316 to i64
  %318 = getelementptr inbounds [50001 x i32], ptr @ans, i64 0, i64 %317
  %319 = load i32, ptr %318, align 4, !tbaa !11
  %320 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %319)
  br label %321

321:                                              ; preds = %315, %308
  br label %322

322:                                              ; preds = %321
  %323 = load i32, ptr %16, align 4, !tbaa !11
  %324 = add nsw i32 %323, 1
  store i32 %324, ptr %16, align 4, !tbaa !11
  br label %303, !llvm.loop !20

325:                                              ; preds = %307
  br label %17, !llvm.loop !21

326:                                              ; preds = %17
  ret i32 0
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #2

; Function Attrs: inlinehint mustprogress uwtable
declare i32 @putchar(i32 noundef) #3

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

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapISt4pairIiiEiSt4lessIS1_ESaIS0_IKS1_iEEEixEOS1_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 4 dereferenceable(8)) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local i64 @_ZSt9make_pairIRiS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #0

declare i32 @printf(ptr noundef, ...) #2

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

%"class.std::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::_Select1st<std::pair<const std::pair<int, int>, int>>, std::less<std::pair<int, int>>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::_Select1st<std::pair<const std::pair<int, int>, int>>, std::less<std::pair<int, int>>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"struct.std::pair" = type { i32, i32 }

@Hash = external dso_local global %"class.std::map", align 8
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@p = external dso_local global [10001 x i32], align 16
@fa = external dso_local local_unnamed_addr global [10001 x i32], align 16
@a = external dso_local global [20001 x i32], align 16
@b = external dso_local global [20001 x i32], align 16
@query = external dso_local global [50001 x [2 x i32]], align 16
@ans = external dso_local local_unnamed_addr global [50001 x i32], align 16
@vis = external dso_local local_unnamed_addr global [20001 x i8], align 16
@flag = external dso_local local_unnamed_addr global i8, align 1
@op = external dso_local global [10 x i8], align 1
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z4findi(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = alloca %"struct.std::pair", align 8
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca %"struct.std::pair", align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %.not74 = icmp eq i32 %9, -1
  br i1 %.not74, label %._crit_edge77, label %.lr.ph76

.loopexit:                                        ; preds = %163, %._crit_edge67, %.preheader
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %.not = icmp eq i32 %10, -1
  br i1 %.not, label %._crit_edge77, label %.lr.ph76, !llvm.loop !5

.lr.ph76:                                         ; preds = %0, %.loopexit
  %11 = load i8, ptr @flag, align 1, !tbaa !7, !range !11, !noundef !12
  %12 = trunc nuw i8 %11 to i1
  br i1 %12, label %13, label %15

13:                                               ; preds = %.lr.ph76
  %14 = call i32 @putchar(i32 noundef 10)
  br label %16

15:                                               ; preds = %.lr.ph76
  store i8 1, ptr @flag, align 1, !tbaa !7
  br label %16

16:                                               ; preds = %15, %13
  call void @_ZNSt3mapISt4pairIiiEiSt4lessIS1_ESaIS0_IKS1_iEEE5clearEv(ptr noundef nonnull align 8 dereferenceable(48) @Hash) #8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(20001) @vis, i8 0, i64 20001, i1 false)
  %17 = load i32, ptr @n, align 4, !tbaa !13
  %18 = icmp sgt i32 %17, 0
  br i1 %18, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %16
  %19 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @m)
  %20 = load i32, ptr @m, align 4, !tbaa !13
  %21 = icmp sgt i32 %20, 0
  br i1 %21, label %.lr.ph60, label %._crit_edge61

.lr.ph:                                           ; preds = %16, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %16 ]
  %22 = getelementptr inbounds i32, ptr @p, i64 %indvars.iv
  %23 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %22)
  %24 = getelementptr inbounds [10001 x i32], ptr @fa, i64 0, i64 %indvars.iv
  %25 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %25, ptr %24, align 4, !tbaa !13
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %26 = load i32, ptr @n, align 4, !tbaa !13
  %27 = sext i32 %26 to i64
  %28 = icmp slt i64 %indvars.iv.next, %27
  br i1 %28, label %.lr.ph, label %._crit_edge, !llvm.loop !15

._crit_edge61:                                    ; preds = %39, %._crit_edge
  %29 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @q)
  %30 = load i32, ptr @q, align 4, !tbaa !13
  %31 = icmp sgt i32 %30, 0
  br i1 %31, label %.lr.ph64, label %.preheader56

.lr.ph60:                                         ; preds = %._crit_edge, %39
  %indvars.iv79 = phi i64 [ %indvars.iv.next80, %39 ], [ 0, %._crit_edge ]
  %32 = getelementptr inbounds i32, ptr @a, i64 %indvars.iv79
  %33 = getelementptr inbounds i32, ptr @b, i64 %indvars.iv79
  %34 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %32, ptr noundef nonnull %33)
  %35 = load i32, ptr %32, align 4, !tbaa !13
  %36 = load i32, ptr %33, align 4, !tbaa !13
  %37 = icmp sgt i32 %35, %36
  br i1 %37, label %38, label %39

38:                                               ; preds = %.lr.ph60
  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) %32, ptr noundef nonnull align 4 dereferenceable(4) %33) #8
  br label %39

39:                                               ; preds = %38, %.lr.ph60
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #8
  %40 = call i64 @_ZSt9make_pairIRiS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %32, ptr noundef nonnull align 4 dereferenceable(4) %33)
  store i64 %40, ptr %1, align 8
  %41 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapISt4pairIiiEiSt4lessIS1_ESaIS0_IKS1_iEEEixEOS1_(ptr noundef nonnull align 8 dereferenceable(48) @Hash, ptr noundef nonnull align 4 dereferenceable(8) %1)
  %42 = trunc nuw nsw i64 %indvars.iv79 to i32
  store i32 %42, ptr %41, align 4, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #8
  %indvars.iv.next80 = add nuw nsw i64 %indvars.iv79, 1
  %43 = load i32, ptr @m, align 4, !tbaa !13
  %44 = sext i32 %43 to i64
  %45 = icmp slt i64 %indvars.iv.next80, %44
  br i1 %45, label %.lr.ph60, label %._crit_edge61, !llvm.loop !16

.preheader56:                                     ; preds = %70, %._crit_edge61
  %46 = phi i32 [ %30, %._crit_edge61 ], [ %71, %70 ]
  %47 = load i32, ptr @m, align 4, !tbaa !13
  %48 = icmp sgt i32 %47, 0
  br i1 %48, label %.lr.ph66, label %._crit_edge67

.lr.ph64:                                         ; preds = %._crit_edge61, %70
  %indvars.iv82 = phi i64 [ %indvars.iv.next83, %70 ], [ 0, %._crit_edge61 ]
  %49 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull @op)
  %50 = load i8, ptr @op, align 1, !tbaa !17
  %51 = icmp eq i8 %50, 113
  br i1 %51, label %52, label %56

52:                                               ; preds = %.lr.ph64
  %53 = getelementptr inbounds [50001 x [2 x i32]], ptr @query, i64 0, i64 %indvars.iv82
  store i32 0, ptr %53, align 8, !tbaa !13
  %54 = getelementptr inbounds i8, ptr %53, i64 4
  %55 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %54)
  br label %70

56:                                               ; preds = %.lr.ph64
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #8
  %57 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %2, ptr noundef nonnull %3)
  %58 = load i32, ptr %2, align 4, !tbaa !13
  %59 = load i32, ptr %3, align 4, !tbaa !13
  %60 = icmp sgt i32 %58, %59
  br i1 %60, label %61, label %62

61:                                               ; preds = %56
  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) %2, ptr noundef nonnull align 4 dereferenceable(4) %3) #8
  br label %62

62:                                               ; preds = %61, %56
  %63 = getelementptr inbounds [50001 x [2 x i32]], ptr @query, i64 0, i64 %indvars.iv82
  store i32 1, ptr %63, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #8
  %64 = call i64 @_ZSt9make_pairIRiS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %3)
  store i64 %64, ptr %4, align 8
  %65 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapISt4pairIiiEiSt4lessIS1_ESaIS0_IKS1_iEEEixEOS1_(ptr noundef nonnull align 8 dereferenceable(48) @Hash, ptr noundef nonnull align 4 dereferenceable(8) %4)
  %66 = load i32, ptr %65, align 4, !tbaa !13
  %67 = getelementptr inbounds i8, ptr %63, i64 4
  store i32 %66, ptr %67, align 4, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #8
  %68 = sext i32 %66 to i64
  %69 = getelementptr inbounds [20001 x i8], ptr @vis, i64 0, i64 %68
  store i8 1, ptr %69, align 1, !tbaa !7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #8
  br label %70

70:                                               ; preds = %52, %62
  %indvars.iv.next83 = add nuw nsw i64 %indvars.iv82, 1
  %71 = load i32, ptr @q, align 4, !tbaa !13
  %72 = sext i32 %71 to i64
  %73 = icmp slt i64 %indvars.iv.next83, %72
  br i1 %73, label %.lr.ph64, label %.preheader56, !llvm.loop !18

._crit_edge67.loopexit:                           ; preds = %103
  %.pre96 = load i32, ptr @q, align 4, !tbaa !13
  br label %._crit_edge67

._crit_edge67:                                    ; preds = %._crit_edge67.loopexit, %.preheader56
  %74 = phi i32 [ %.pre96, %._crit_edge67.loopexit ], [ %46, %.preheader56 ]
  %75 = icmp sgt i32 %74, 0
  br i1 %75, label %.lr.ph71.preheader, label %.loopexit

.lr.ph71.preheader:                               ; preds = %._crit_edge67
  %76 = zext nneg i32 %74 to i64
  br label %.lr.ph71

.lr.ph66:                                         ; preds = %.preheader56, %103
  %77 = phi i32 [ %104, %103 ], [ %47, %.preheader56 ]
  %indvars.iv85 = phi i64 [ %indvars.iv.next86, %103 ], [ 0, %.preheader56 ]
  %78 = getelementptr inbounds [20001 x i8], ptr @vis, i64 0, i64 %indvars.iv85
  %79 = load i8, ptr %78, align 1, !tbaa !7, !range !11, !noundef !12
  %80 = trunc nuw i8 %79 to i1
  br i1 %80, label %103, label %81

81:                                               ; preds = %.lr.ph66
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #8
  %82 = getelementptr inbounds [20001 x i32], ptr @a, i64 0, i64 %indvars.iv85
  %83 = load i32, ptr %82, align 4, !tbaa !13
  %84 = call noundef i32 @_Z4findi(i32 noundef %83)
  store i32 %84, ptr %5, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #8
  %85 = getelementptr inbounds [20001 x i32], ptr @b, i64 0, i64 %indvars.iv85
  %86 = load i32, ptr %85, align 4, !tbaa !13
  %87 = call noundef i32 @_Z4findi(i32 noundef %86)
  store i32 %87, ptr %6, align 4, !tbaa !13
  %88 = load i32, ptr %5, align 4, !tbaa !13
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [10001 x i32], ptr @p, i64 0, i64 %89
  %91 = load i32, ptr %90, align 4, !tbaa !13
  %92 = sext i32 %87 to i64
  %93 = getelementptr inbounds [10001 x i32], ptr @p, i64 0, i64 %92
  %94 = load i32, ptr %93, align 4, !tbaa !13
  %95 = icmp sgt i32 %91, %94
  br i1 %95, label %99, label %96

96:                                               ; preds = %81
  %97 = icmp eq i32 %91, %94
  %98 = icmp slt i32 %88, %87
  %or.cond = and i1 %98, %97
  br i1 %or.cond, label %99, label %100

99:                                               ; preds = %96, %81
  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) %5, ptr noundef nonnull align 4 dereferenceable(4) %6) #8
  %.pre = load i32, ptr %6, align 4, !tbaa !13
  %.pre94 = load i32, ptr %5, align 4, !tbaa !13
  %.pre102 = sext i32 %.pre94 to i64
  br label %100

100:                                              ; preds = %99, %96
  %.pre-phi103 = phi i64 [ %.pre102, %99 ], [ %89, %96 ]
  %101 = phi i32 [ %.pre, %99 ], [ %87, %96 ]
  %102 = getelementptr inbounds [10001 x i32], ptr @fa, i64 0, i64 %.pre-phi103
  store i32 %101, ptr %102, align 4, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #8
  %.pre95 = load i32, ptr @m, align 4, !tbaa !13
  br label %103

103:                                              ; preds = %.lr.ph66, %100
  %104 = phi i32 [ %77, %.lr.ph66 ], [ %.pre95, %100 ]
  %indvars.iv.next86 = add nuw nsw i64 %indvars.iv85, 1
  %105 = sext i32 %104 to i64
  %106 = icmp slt i64 %indvars.iv.next86, %105
  br i1 %106, label %.lr.ph66, label %._crit_edge67.loopexit, !llvm.loop !19

.preheader:                                       ; preds = %154
  %.pre99 = load i32, ptr @q, align 4, !tbaa !13
  %107 = icmp sgt i32 %.pre99, 0
  br i1 %107, label %.lr.ph73, label %.loopexit

.lr.ph71:                                         ; preds = %.lr.ph71.preheader, %154
  %indvars.iv88 = phi i64 [ %76, %.lr.ph71.preheader ], [ %indvars.iv.next89, %154 ]
  %indvars.iv.next89 = add nsw i64 %indvars.iv88, -1
  %108 = getelementptr inbounds [50001 x [2 x i32]], ptr @query, i64 0, i64 %indvars.iv.next89
  %109 = load i32, ptr %108, align 8, !tbaa !13
  %.not54 = icmp eq i32 %109, 0
  %110 = getelementptr inbounds i8, ptr %108, i64 4
  %111 = load i32, ptr %110, align 4, !tbaa !13
  br i1 %.not54, label %141, label %112

112:                                              ; preds = %.lr.ph71
  %113 = sext i32 %111 to i64
  %114 = getelementptr inbounds [20001 x i8], ptr @vis, i64 0, i64 %113
  %115 = load i8, ptr %114, align 1, !tbaa !7, !range !11, !noundef !12
  %116 = trunc nuw i8 %115 to i1
  br i1 %116, label %117, label %154

117:                                              ; preds = %112
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #8
  %118 = getelementptr inbounds [20001 x i32], ptr @a, i64 0, i64 %113
  %119 = load i32, ptr %118, align 4, !tbaa !13
  %120 = call noundef i32 @_Z4findi(i32 noundef %119)
  store i32 %120, ptr %7, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #8
  %121 = load i32, ptr %110, align 4, !tbaa !13
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [20001 x i32], ptr @b, i64 0, i64 %122
  %124 = load i32, ptr %123, align 4, !tbaa !13
  %125 = call noundef i32 @_Z4findi(i32 noundef %124)
  store i32 %125, ptr %8, align 4, !tbaa !13
  %126 = load i32, ptr %7, align 4, !tbaa !13
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds [10001 x i32], ptr @p, i64 0, i64 %127
  %129 = load i32, ptr %128, align 4, !tbaa !13
  %130 = sext i32 %125 to i64
  %131 = getelementptr inbounds [10001 x i32], ptr @p, i64 0, i64 %130
  %132 = load i32, ptr %131, align 4, !tbaa !13
  %133 = icmp sgt i32 %129, %132
  br i1 %133, label %137, label %134

134:                                              ; preds = %117
  %135 = icmp eq i32 %129, %132
  %136 = icmp slt i32 %126, %125
  %or.cond55 = and i1 %136, %135
  br i1 %or.cond55, label %137, label %138

137:                                              ; preds = %134, %117
  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) %7, ptr noundef nonnull align 4 dereferenceable(4) %8) #8
  %.pre97 = load i32, ptr %8, align 4, !tbaa !13
  %.pre98 = load i32, ptr %7, align 4, !tbaa !13
  %.pre101 = sext i32 %.pre98 to i64
  br label %138

138:                                              ; preds = %137, %134
  %.pre-phi = phi i64 [ %.pre101, %137 ], [ %127, %134 ]
  %139 = phi i32 [ %.pre97, %137 ], [ %125, %134 ]
  %140 = getelementptr inbounds [10001 x i32], ptr @fa, i64 0, i64 %.pre-phi
  store i32 %139, ptr %140, align 4, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #8
  br label %154

141:                                              ; preds = %.lr.ph71
  %142 = call noundef i32 @_Z4findi(i32 noundef %111)
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds [10001 x i32], ptr @p, i64 0, i64 %143
  %145 = load i32, ptr %144, align 4, !tbaa !13
  %146 = load i32, ptr %110, align 4, !tbaa !13
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds [10001 x i32], ptr @p, i64 0, i64 %147
  %149 = load i32, ptr %148, align 4, !tbaa !13
  %150 = icmp sgt i32 %145, %149
  %151 = getelementptr inbounds [50001 x i32], ptr @ans, i64 0, i64 %indvars.iv.next89
  br i1 %150, label %152, label %153

152:                                              ; preds = %141
  store i32 %142, ptr %151, align 4, !tbaa !13
  br label %154

153:                                              ; preds = %141
  store i32 -1, ptr %151, align 4, !tbaa !13
  br label %154

154:                                              ; preds = %152, %153, %138, %112
  %155 = icmp ugt i64 %indvars.iv88, 1
  br i1 %155, label %.lr.ph71, label %.preheader, !llvm.loop !20

.lr.ph73:                                         ; preds = %.preheader, %163
  %156 = phi i32 [ %164, %163 ], [ %.pre99, %.preheader ]
  %indvars.iv91 = phi i64 [ %indvars.iv.next92, %163 ], [ 0, %.preheader ]
  %157 = getelementptr inbounds [50001 x [2 x i32]], ptr @query, i64 0, i64 %indvars.iv91
  %158 = load i32, ptr %157, align 8, !tbaa !13
  %.not53 = icmp eq i32 %158, 0
  br i1 %.not53, label %159, label %163

159:                                              ; preds = %.lr.ph73
  %160 = getelementptr inbounds [50001 x i32], ptr @ans, i64 0, i64 %indvars.iv91
  %161 = load i32, ptr %160, align 4, !tbaa !13
  %162 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %161)
  %.pre100 = load i32, ptr @q, align 4, !tbaa !13
  br label %163

163:                                              ; preds = %.lr.ph73, %159
  %164 = phi i32 [ %156, %.lr.ph73 ], [ %.pre100, %159 ]
  %indvars.iv.next92 = add nuw nsw i64 %indvars.iv91, 1
  %165 = sext i32 %164 to i64
  %166 = icmp slt i64 %indvars.iv.next92, %165
  br i1 %166, label %.lr.ph73, label %.loopexit, !llvm.loop !21

._crit_edge77:                                    ; preds = %.loopexit, %0
  ret i32 0
}

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nofree nounwind uwtable
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #3

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapISt4pairIiiEiSt4lessIS1_ESaIS0_IKS1_iEEEixEOS1_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #0 align 2

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

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 = { 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 #3 = { inlinehint mustprogress nofree 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 = { 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { 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 #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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"bool", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !9, i64 0}
!15 = distinct !{!15, !6}
!16 = distinct !{!16, !6}
!17 = !{!9, !9, i64 0}
!18 = distinct !{!18, !6}
!19 = distinct !{!19, !6}
!20 = distinct !{!20, !6}
!21 = distinct !{!21, !6}


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