; LLVM IR from tangjz/acm-icpc :: codeforces/complete (700D)

; 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.anon = type { i8 }
%"class.std::queue" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Deque_impl" }
%"struct.std::_Deque_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Deque_impl" = type { %"struct.std::_Deque_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Deque_impl_data" }
%"struct.std::_Deque_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }
%class.anon.0 = type { ptr, ptr }
%"struct.std::pair" = type { i32, i32 }

@n = external dso_local global i32, align 4
@sq = external dso_local global i32, align 4
@a = external dso_local global [100003 x i32], align 16
@d = external dso_local global [100003 x i32], align 16
@dL = external dso_local global [100003 x i32], align 16
@dR = external dso_local global [100003 x i32], align 16
@q = external dso_local global i32, align 4
@pos = external dso_local global [100003 x i32], align 16
@qL = external dso_local global [100003 x i32], align 16
@qR = external dso_local global [100003 x i32], align 16
@ord = external dso_local global [100003 x i32], align 16
@ans = external dso_local global [100003 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@_ZL4maxn = external hidden constant i32, align 4
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca %class.anon, align 1
  %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 ptr, align 8
  %13 = alloca %"class.std::queue", align 8
  %14 = alloca %class.anon.0, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = alloca %"struct.std::pair", align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %24 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  br label %25

25:                                               ; preds = %32, %0
  %26 = load i32, ptr @sq, align 4, !tbaa !5
  %27 = load i32, ptr @sq, align 4, !tbaa !5
  %28 = mul nsw i32 %26, %27
  %29 = load i32, ptr @n, align 4, !tbaa !5
  %30 = icmp sle i32 %28, %29
  br i1 %30, label %31, label %35

31:                                               ; preds = %25
  br label %32

32:                                               ; preds = %31
  %33 = load i32, ptr @sq, align 4, !tbaa !5
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr @sq, align 4, !tbaa !5
  br label %25, !llvm.loop !9

35:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #8
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %36

36:                                               ; preds = %58, %35
  %37 = load i32, ptr %2, align 4, !tbaa !5
  %38 = load i32, ptr @n, align 4, !tbaa !5
  %39 = icmp sle i32 %37, %38
  br i1 %39, label %41, label %40

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

41:                                               ; preds = %36
  %42 = load i32, ptr %2, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds i32, ptr @a, i64 %43
  %45 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %44)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #8
  %46 = load i32, ptr %2, align 4, !tbaa !5
  %47 = load i32, ptr @sq, align 4, !tbaa !5
  %48 = sub nsw i32 %46, %47
  store i32 %48, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #8
  store i32 0, ptr %4, align 4, !tbaa !5
  %49 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [100003 x i32], ptr @pos, i64 0, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = add nsw i32 %53, 1
  %55 = load i32, ptr %2, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [100003 x i32], ptr @pos, i64 0, i64 %56
  store i32 %54, ptr %57, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #8
  br label %58

58:                                               ; preds = %41
  %59 = load i32, ptr %2, align 4, !tbaa !5
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %2, align 4, !tbaa !5
  br label %36, !llvm.loop !11

61:                                               ; preds = %40
  %62 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @q)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #8
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %63

63:                                               ; preds = %80, %61
  %64 = load i32, ptr %5, align 4, !tbaa !5
  %65 = load i32, ptr @q, align 4, !tbaa !5
  %66 = icmp sle i32 %64, %65
  br i1 %66, label %68, label %67

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

68:                                               ; preds = %63
  %69 = load i32, ptr %5, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds i32, ptr @qL, i64 %70
  %72 = load i32, ptr %5, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds i32, ptr @qR, i64 %73
  %75 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %71, ptr noundef %74)
  %76 = load i32, ptr %5, align 4, !tbaa !5
  %77 = load i32, ptr %5, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [100003 x i32], ptr @ord, i64 0, i64 %78
  store i32 %76, ptr %79, align 4, !tbaa !5
  br label %80

80:                                               ; preds = %68
  %81 = load i32, ptr %5, align 4, !tbaa !5
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr %5, align 4, !tbaa !5
  br label %63, !llvm.loop !12

83:                                               ; preds = %67
  %84 = load i32, ptr @q, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds i32, ptr @ord, i64 %85
  %87 = getelementptr inbounds i32, ptr %86, i64 1
  call void @"_ZSt4sortIPiZ4mainE3$_0EvT_S2_T0_"(ptr noundef getelementptr inbounds (i32, ptr @ord, i64 1), ptr noundef %87)
  %88 = load i32, ptr @n, align 4, !tbaa !5
  %89 = add nsw i32 %88, 1
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [100003 x i32], ptr @d, i64 0, i64 %90
  store i32 100003, ptr %91, align 4, !tbaa !5
  store i32 100003, ptr @d, align 16, !tbaa !5
  %92 = load i32, ptr @n, align 4, !tbaa !5
  %93 = add nsw i32 %92, 1
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [100003 x i32], ptr @dL, i64 0, i64 %94
  store i32 0, ptr %95, align 4, !tbaa !5
  %96 = load i32, ptr @n, align 4, !tbaa !5
  %97 = add nsw i32 %96, 1
  store i32 %97, ptr @dR, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #8
  store i32 1, ptr %7, align 4, !tbaa !5
  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 %98

98:                                               ; preds = %283, %83
  %99 = load i32, ptr %7, align 4, !tbaa !5
  %100 = load i32, ptr @q, align 4, !tbaa !5
  %101 = icmp sle i32 %99, %100
  br i1 %101, label %103, label %102

102:                                              ; preds = %98
  store i32 11, 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
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #8
  br label %286

103:                                              ; preds = %98
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #8
  %104 = load i32, ptr %7, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [100003 x i32], ptr @ord, i64 0, i64 %105
  %107 = load i32, ptr %106, align 4, !tbaa !5
  store i32 %107, ptr %11, align 4, !tbaa !5
  br label %108

108:                                              ; preds = %116, %103
  %109 = load i32, ptr %8, align 4, !tbaa !5
  %110 = load i32, ptr %11, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [100003 x i32], ptr @qL, i64 0, i64 %111
  %113 = load i32, ptr %112, align 4, !tbaa !5
  %114 = icmp sgt i32 %109, %113
  br i1 %114, label %115, label %122

115:                                              ; preds = %108
  br label %116

116:                                              ; preds = %115
  %117 = load i32, ptr %8, align 4, !tbaa !5
  %118 = add nsw i32 %117, -1
  store i32 %118, ptr %8, align 4, !tbaa !5
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [100003 x i32], ptr @a, i64 0, i64 %119
  %121 = load i32, ptr %120, align 4, !tbaa !5
  call void @_Z3updii(i32 noundef %121, i32 noundef 1)
  br label %108, !llvm.loop !13

122:                                              ; preds = %108
  br label %123

123:                                              ; preds = %131, %122
  %124 = load i32, ptr %9, align 4, !tbaa !5
  %125 = load i32, ptr %11, align 4, !tbaa !5
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [100003 x i32], ptr @qR, i64 0, i64 %126
  %128 = load i32, ptr %127, align 4, !tbaa !5
  %129 = icmp slt i32 %124, %128
  br i1 %129, label %130, label %137

130:                                              ; preds = %123
  br label %131

131:                                              ; preds = %130
  %132 = load i32, ptr %9, align 4, !tbaa !5
  %133 = add nsw i32 %132, 1
  store i32 %133, ptr %9, align 4, !tbaa !5
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds [100003 x i32], ptr @a, i64 0, i64 %134
  %136 = load i32, ptr %135, align 4, !tbaa !5
  call void @_Z3updii(i32 noundef %136, i32 noundef 1)
  br label %123, !llvm.loop !14

137:                                              ; preds = %123
  br label %138

138:                                              ; preds = %146, %137
  %139 = load i32, ptr %9, align 4, !tbaa !5
  %140 = load i32, ptr %11, align 4, !tbaa !5
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [100003 x i32], ptr @qR, i64 0, i64 %141
  %143 = load i32, ptr %142, align 4, !tbaa !5
  %144 = icmp sgt i32 %139, %143
  br i1 %144, label %145, label %152

145:                                              ; preds = %138
  br label %146

146:                                              ; preds = %145
  %147 = load i32, ptr %9, align 4, !tbaa !5
  %148 = add nsw i32 %147, -1
  store i32 %148, ptr %9, align 4, !tbaa !5
  %149 = sext i32 %147 to i64
  %150 = getelementptr inbounds [100003 x i32], ptr @a, i64 0, i64 %149
  %151 = load i32, ptr %150, align 4, !tbaa !5
  call void @_Z3updii(i32 noundef %151, i32 noundef -1)
  br label %138, !llvm.loop !15

152:                                              ; preds = %138
  br label %153

153:                                              ; preds = %161, %152
  %154 = load i32, ptr %8, align 4, !tbaa !5
  %155 = load i32, ptr %11, align 4, !tbaa !5
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds [100003 x i32], ptr @qL, i64 0, i64 %156
  %158 = load i32, ptr %157, align 4, !tbaa !5
  %159 = icmp slt i32 %154, %158
  br i1 %159, label %160, label %167

160:                                              ; preds = %153
  br label %161

161:                                              ; preds = %160
  %162 = load i32, ptr %8, align 4, !tbaa !5
  %163 = add nsw i32 %162, 1
  store i32 %163, ptr %8, align 4, !tbaa !5
  %164 = sext i32 %162 to i64
  %165 = getelementptr inbounds [100003 x i32], ptr @a, i64 0, i64 %164
  %166 = load i32, ptr %165, align 4, !tbaa !5
  call void @_Z3updii(i32 noundef %166, i32 noundef -1)
  br label %153, !llvm.loop !16

167:                                              ; preds = %153
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #8
  %168 = load i32, ptr %11, align 4, !tbaa !5
  %169 = sext i32 %168 to i64
  %170 = getelementptr inbounds [100003 x i32], ptr @ans, i64 0, i64 %169
  store i32 0, ptr %170, align 4, !tbaa !5
  store ptr %170, ptr %12, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 80, ptr %13) #8
  call void @_ZNSt5queueISt4pairIiiESt5dequeIS1_SaIS1_EEEC2IS4_vEEv(ptr noundef nonnull align 8 dereferenceable(80) %13)
  call void @llvm.lifetime.start.p0(i64 16, ptr %14) #8
  %171 = getelementptr inbounds %class.anon.0, ptr %14, i32 0, i32 0
  %172 = load ptr, ptr %12, align 8, !tbaa !17
  store ptr %172, ptr %171, align 8, !tbaa !17
  %173 = getelementptr inbounds %class.anon.0, ptr %14, i32 0, i32 1
  store ptr %13, ptr %173, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #8
  %174 = load i32, ptr @dR, align 16, !tbaa !5
  store i32 %174, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #8
  store i32 0, ptr %16, align 4, !tbaa !5
  br label %175

175:                                              ; preds = %278, %167
  %176 = load i32, ptr %15, align 4, !tbaa !5
  %177 = load i32, ptr @n, align 4, !tbaa !5
  %178 = icmp sle i32 %176, %177
  br i1 %178, label %183, label %179

179:                                              ; preds = %175
  %180 = invoke noundef zeroext i1 @_ZNKSt5queueISt4pairIiiESt5dequeIS1_SaIS1_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %13)
          to label %181 unwind label %186

181:                                              ; preds = %179
  %182 = xor i1 %180, true
  br label %183

183:                                              ; preds = %181, %175
  %184 = phi i1 [ true, %175 ], [ %182, %181 ]
  br i1 %184, label %190, label %185

185:                                              ; preds = %183
  store i32 26, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #8
  br label %282

186:                                              ; preds = %179
  %187 = landingpad { ptr, i32 }
          cleanup
  %188 = extractvalue { ptr, i32 } %187, 0
  store ptr %188, ptr %17, align 8
  %189 = extractvalue { ptr, i32 } %187, 1
  store i32 %189, ptr %18, align 4
  br label %281

190:                                              ; preds = %183
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #8
  %191 = invoke noundef zeroext i1 @_ZNKSt5queueISt4pairIiiESt5dequeIS1_SaIS1_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %13)
          to label %192 unwind label %225

192:                                              ; preds = %190
  br i1 %191, label %193, label %196

193:                                              ; preds = %192
  store i32 0, ptr %20, align 4, !tbaa !5
  %194 = invoke i64 @_ZSt9make_pairIRKiiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS3_INS4_IT0_E4typeEE6__typeEEOS5_OSA_(ptr noundef nonnull align 4 dereferenceable(4) @_ZL4maxn, ptr noundef nonnull align 4 dereferenceable(4) %20)
          to label %195 unwind label %229

195:                                              ; preds = %193
  store i64 %194, ptr %19, align 4
  br label %199

196:                                              ; preds = %192
  %197 = invoke noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt5queueISt4pairIiiESt5dequeIS1_SaIS1_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) %13)
          to label %198 unwind label %229

198:                                              ; preds = %196
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %19, ptr align 4 %197, i64 8, i1 false)
  br label %199

199:                                              ; preds = %198, %195
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #8
  %200 = load i32, ptr %15, align 4, !tbaa !5
  %201 = load i32, ptr @n, align 4, !tbaa !5
  %202 = icmp sle i32 %200, %201
  br i1 %202, label %203, label %204

203:                                              ; preds = %199
  br label %205

204:                                              ; preds = %199
  br label %205

205:                                              ; preds = %204, %203
  %206 = phi ptr [ %15, %203 ], [ @_ZL4maxn, %204 ]
  %207 = getelementptr inbounds %"struct.std::pair", ptr %19, i32 0, i32 0
  %208 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %206, ptr noundef nonnull align 4 dereferenceable(4) %207)
          to label %209 unwind label %233

209:                                              ; preds = %205
  %210 = load i32, ptr %208, align 4, !tbaa !5
  store i32 %210, ptr %21, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #8
  store i32 0, ptr %22, align 4, !tbaa !5
  %211 = load i32, ptr %21, align 4, !tbaa !5
  %212 = load i32, ptr %15, align 4, !tbaa !5
  %213 = icmp eq i32 %211, %212
  br i1 %213, label %214, label %237

214:                                              ; preds = %209
  %215 = load i32, ptr %15, align 4, !tbaa !5
  %216 = sext i32 %215 to i64
  %217 = getelementptr inbounds [100003 x i32], ptr @d, i64 0, i64 %216
  %218 = load i32, ptr %217, align 4, !tbaa !5
  %219 = load i32, ptr %22, align 4, !tbaa !5
  %220 = add nsw i32 %219, %218
  store i32 %220, ptr %22, align 4, !tbaa !5
  %221 = load i32, ptr %15, align 4, !tbaa !5
  %222 = sext i32 %221 to i64
  %223 = getelementptr inbounds [100003 x i32], ptr @dR, i64 0, i64 %222
  %224 = load i32, ptr %223, align 4, !tbaa !5
  store i32 %224, ptr %15, align 4, !tbaa !5
  br label %237

225:                                              ; preds = %190
  %226 = landingpad { ptr, i32 }
          cleanup
  %227 = extractvalue { ptr, i32 } %226, 0
  store ptr %227, ptr %17, align 8
  %228 = extractvalue { ptr, i32 } %226, 1
  store i32 %228, ptr %18, align 4
  br label %280

229:                                              ; preds = %196, %193
  %230 = landingpad { ptr, i32 }
          cleanup
  %231 = extractvalue { ptr, i32 } %230, 0
  store ptr %231, ptr %17, align 8
  %232 = extractvalue { ptr, i32 } %230, 1
  store i32 %232, ptr %18, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #8
  br label %280

233:                                              ; preds = %205
  %234 = landingpad { ptr, i32 }
          cleanup
  %235 = extractvalue { ptr, i32 } %234, 0
  store ptr %235, ptr %17, align 8
  %236 = extractvalue { ptr, i32 } %234, 1
  store i32 %236, ptr %18, align 4
  br label %279

237:                                              ; preds = %214, %209
  %238 = load i32, ptr %21, align 4, !tbaa !5
  %239 = getelementptr inbounds %"struct.std::pair", ptr %19, i32 0, i32 0
  %240 = load i32, ptr %239, align 4, !tbaa !19
  %241 = icmp eq i32 %238, %240
  br i1 %241, label %242, label %252

242:                                              ; preds = %237
  %243 = getelementptr inbounds %"struct.std::pair", ptr %19, i32 0, i32 1
  %244 = load i32, ptr %243, align 4, !tbaa !21
  %245 = load i32, ptr %22, align 4, !tbaa !5
  %246 = add nsw i32 %245, %244
  store i32 %246, ptr %22, align 4, !tbaa !5
  invoke void @_ZNSt5queueISt4pairIiiESt5dequeIS1_SaIS1_EEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) %13)
          to label %247 unwind label %248

247:                                              ; preds = %242
  br label %252

248:                                              ; preds = %265, %255, %242
  %249 = landingpad { ptr, i32 }
          cleanup
  %250 = extractvalue { ptr, i32 } %249, 0
  store ptr %250, ptr %17, align 8
  %251 = extractvalue { ptr, i32 } %249, 1
  store i32 %251, ptr %18, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #8
  br label %279

252:                                              ; preds = %247, %237
  %253 = load i32, ptr %16, align 4, !tbaa !5
  %254 = icmp ne i32 %253, 0
  br i1 %254, label %255, label %262

255:                                              ; preds = %252
  %256 = load i32, ptr %16, align 4, !tbaa !5
  %257 = load i32, ptr %21, align 4, !tbaa !5
  %258 = add nsw i32 %256, %257
  invoke void @"_ZZ4mainENK3$_1clEii"(ptr noundef nonnull align 8 dereferenceable(16) %14, i32 noundef %258, i32 noundef 1)
          to label %259 unwind label %248

259:                                              ; preds = %255
  store i32 0, ptr %16, align 4, !tbaa !5
  %260 = load i32, ptr %22, align 4, !tbaa !5
  %261 = add nsw i32 %260, -1
  store i32 %261, ptr %22, align 4, !tbaa !5
  br label %262

262:                                              ; preds = %259, %252
  %263 = load i32, ptr %22, align 4, !tbaa !5
  %264 = icmp sgt i32 %263, 1
  br i1 %264, label %265, label %272

265:                                              ; preds = %262
  %266 = load i32, ptr %21, align 4, !tbaa !5
  %267 = load i32, ptr %21, align 4, !tbaa !5
  %268 = add nsw i32 %266, %267
  %269 = load i32, ptr %22, align 4, !tbaa !5
  %270 = ashr i32 %269, 1
  invoke void @"_ZZ4mainENK3$_1clEii"(ptr noundef nonnull align 8 dereferenceable(16) %14, i32 noundef %268, i32 noundef %270)
          to label %271 unwind label %248

271:                                              ; preds = %265
  br label %272

272:                                              ; preds = %271, %262
  %273 = load i32, ptr %22, align 4, !tbaa !5
  %274 = and i32 %273, 1
  %275 = icmp ne i32 %274, 0
  br i1 %275, label %276, label %278

276:                                              ; preds = %272
  %277 = load i32, ptr %21, align 4, !tbaa !5
  store i32 %277, ptr %16, align 4, !tbaa !5
  br label %278

278:                                              ; preds = %276, %272
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #8
  br label %175, !llvm.loop !22

279:                                              ; preds = %248, %233
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #8
  br label %280

280:                                              ; preds = %279, %229, %225
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #8
  br label %281

281:                                              ; preds = %280, %186
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr %14) #8
  call void @_ZNSt5queueISt4pairIiiESt5dequeIS1_SaIS1_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %13) #8
  call void @llvm.lifetime.end.p0(i64 80, ptr %13) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #8
  br label %302

282:                                              ; preds = %185
  call void @llvm.lifetime.end.p0(i64 16, ptr %14) #8
  call void @_ZNSt5queueISt4pairIiiESt5dequeIS1_SaIS1_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %13) #8
  call void @llvm.lifetime.end.p0(i64 80, ptr %13) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  br label %283

283:                                              ; preds = %282
  %284 = load i32, ptr %7, align 4, !tbaa !5
  %285 = add nsw i32 %284, 1
  store i32 %285, ptr %7, align 4, !tbaa !5
  br label %98, !llvm.loop !23

286:                                              ; preds = %102
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #8
  store i32 1, ptr %23, align 4, !tbaa !5
  br label %287

287:                                              ; preds = %298, %286
  %288 = load i32, ptr %23, align 4, !tbaa !5
  %289 = load i32, ptr @q, align 4, !tbaa !5
  %290 = icmp sle i32 %288, %289
  br i1 %290, label %292, label %291

291:                                              ; preds = %287
  store i32 28, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #8
  br label %301

292:                                              ; preds = %287
  %293 = load i32, ptr %23, align 4, !tbaa !5
  %294 = sext i32 %293 to i64
  %295 = getelementptr inbounds [100003 x i32], ptr @ans, i64 0, i64 %294
  %296 = load i32, ptr %295, align 4, !tbaa !5
  %297 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %296)
  br label %298

298:                                              ; preds = %292
  %299 = load i32, ptr %23, align 4, !tbaa !5
  %300 = add nsw i32 %299, 1
  store i32 %300, ptr %23, align 4, !tbaa !5
  br label %287, !llvm.loop !24

301:                                              ; preds = %291
  ret i32 0

302:                                              ; preds = %281
  %303 = load ptr, ptr %17, align 8
  %304 = load i32, ptr %18, align 4
  %305 = insertvalue { ptr, i32 } poison, ptr %303, 0
  %306 = insertvalue { ptr, i32 } %305, i32 %304, 1
  resume { ptr, i32 } %306
}

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #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 uwtable
declare hidden void @"_ZSt4sortIPiZ4mainE3$_0EvT_S2_T0_"(ptr noundef, ptr noundef) #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z3updii(i32 noundef, i32 noundef) #3

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt5queueISt4pairIiiESt5dequeIS1_SaIS1_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80)) #6 align 2

declare i32 @__gxx_personality_v0(...)

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

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZZ4mainENK3$_1clEii"(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef, i32 noundef) #4 align 2

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

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

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


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

%"class.std::queue" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Deque_impl" }
%"struct.std::_Deque_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Deque_impl" = type { %"struct.std::_Deque_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Deque_impl_data" }
%"struct.std::_Deque_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }
%class.anon.0 = type { ptr, ptr }
%"struct.std::pair" = type { i32, i32 }

@n = external dso_local global i32, align 4
@sq = external dso_local local_unnamed_addr global i32, align 4
@a = external dso_local global [100003 x i32], align 16
@d = external dso_local local_unnamed_addr global [100003 x i32], align 16
@dL = external dso_local local_unnamed_addr global [100003 x i32], align 16
@dR = external dso_local local_unnamed_addr global [100003 x i32], align 16
@q = external dso_local global i32, align 4
@pos = external dso_local local_unnamed_addr global [100003 x i32], align 16
@qL = external dso_local global [100003 x i32], align 16
@qR = external dso_local global [100003 x i32], align 16
@ord = external dso_local global [100003 x i32], align 16
@ans = external dso_local global [100003 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@_ZL4maxn = external hidden constant i32, align 4
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca %"class.std::queue", align 8
  %4 = alloca %class.anon.0, align 8
  %5 = alloca i32, align 4
  %6 = alloca %"struct.std::pair", align 8
  %7 = alloca i32, align 4
  %8 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %9 = load i32, ptr @n, align 4, !tbaa !5
  %sq.promoted = load i32, ptr @sq, align 4, !tbaa !5
  %10 = mul nsw i32 %sq.promoted, %sq.promoted
  %.not79 = icmp sgt i32 %10, %9
  br i1 %.not79, label %.preheader75, label %.lr.ph

..preheader75_crit_edge:                          ; preds = %.lr.ph
  store i32 %12, ptr @sq, align 4, !tbaa !5
  br label %.preheader75

.preheader75:                                     ; preds = %..preheader75_crit_edge, %0
  %.not6381 = icmp slt i32 %9, 1
  br i1 %.not6381, label %._crit_edge, label %.lr.ph83

.lr.ph:                                           ; preds = %0, %.lr.ph
  %11 = phi i32 [ %12, %.lr.ph ], [ %sq.promoted, %0 ]
  %12 = add nsw i32 %11, 1
  %13 = mul nsw i32 %12, %12
  %.not = icmp sgt i32 %13, %9
  br i1 %.not, label %..preheader75_crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph83, %.preheader75
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @q)
  %15 = load i32, ptr @q, align 4, !tbaa !5
  %.not6484 = icmp slt i32 %15, 1
  br i1 %.not6484, label %._crit_edge.._crit_edge88_crit_edge, label %.lr.ph87

._crit_edge.._crit_edge88_crit_edge:              ; preds = %._crit_edge
  %.pre143 = sext i32 %15 to i64
  br label %._crit_edge88

.lr.ph83:                                         ; preds = %.preheader75, %.lr.ph83
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph83 ], [ 1, %.preheader75 ]
  %16 = getelementptr inbounds i32, ptr @a, i64 %indvars.iv
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %16)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  %18 = load i32, ptr @sq, align 4, !tbaa !5
  %19 = trunc nuw nsw i64 %indvars.iv to i32
  %20 = sub nsw i32 %19, %18
  store i32 %20, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  store i32 0, ptr %2, align 4, !tbaa !5
  %21 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %22 = load i32, ptr %21, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [100003 x i32], ptr @pos, i64 0, i64 %23
  %25 = load i32, ptr %24, align 4, !tbaa !5
  %26 = add nsw i32 %25, 1
  %27 = getelementptr inbounds [100003 x i32], ptr @pos, i64 0, i64 %indvars.iv
  store i32 %26, ptr %27, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %28 = load i32, ptr @n, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %.not63.not = icmp slt i64 %indvars.iv, %29
  br i1 %.not63.not, label %.lr.ph83, label %._crit_edge, !llvm.loop !11

._crit_edge88:                                    ; preds = %.lr.ph87, %._crit_edge.._crit_edge88_crit_edge
  %.pre-phi = phi i64 [ %.pre143, %._crit_edge.._crit_edge88_crit_edge ], [ %46, %.lr.ph87 ]
  %30 = getelementptr inbounds i32, ptr @ord, i64 %.pre-phi
  %31 = getelementptr inbounds i8, ptr %30, i64 4
  call void @"_ZSt4sortIPiZ4mainE3$_0EvT_S2_T0_"(ptr noundef nonnull getelementptr inbounds (i8, ptr @ord, i64 4), ptr noundef nonnull %31)
  %32 = load i32, ptr @n, align 4, !tbaa !5
  %33 = add nsw i32 %32, 1
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [100003 x i32], ptr @d, i64 0, i64 %34
  store i32 100003, ptr %35, align 4, !tbaa !5
  store i32 100003, ptr @d, align 16, !tbaa !5
  %36 = getelementptr inbounds [100003 x i32], ptr @dL, i64 0, i64 %34
  store i32 0, ptr %36, align 4, !tbaa !5
  store i32 %33, ptr @dR, align 16, !tbaa !5
  %37 = load i32, ptr @q, align 4, !tbaa !5
  %.not65106 = icmp slt i32 %37, 1
  br i1 %.not65106, label %._crit_edge115, label %.lr.ph111

.lr.ph111:                                        ; preds = %._crit_edge88
  %38 = getelementptr inbounds i8, ptr %4, i64 8
  %39 = getelementptr inbounds i8, ptr %6, i64 4
  br label %48

.lr.ph87:                                         ; preds = %._crit_edge, %.lr.ph87
  %indvars.iv122 = phi i64 [ %indvars.iv.next123, %.lr.ph87 ], [ 1, %._crit_edge ]
  %40 = getelementptr inbounds i32, ptr @qL, i64 %indvars.iv122
  %41 = getelementptr inbounds i32, ptr @qR, i64 %indvars.iv122
  %42 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %40, ptr noundef nonnull %41)
  %43 = getelementptr inbounds [100003 x i32], ptr @ord, i64 0, i64 %indvars.iv122
  %44 = trunc nuw nsw i64 %indvars.iv122 to i32
  store i32 %44, ptr %43, align 4, !tbaa !5
  %indvars.iv.next123 = add nuw nsw i64 %indvars.iv122, 1
  %45 = load i32, ptr @q, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %.not64.not = icmp slt i64 %indvars.iv122, %46
  br i1 %.not64.not, label %.lr.ph87, label %._crit_edge88, !llvm.loop !12

.preheader:                                       ; preds = %97
  %47 = icmp slt i32 %98, 1
  br i1 %47, label %._crit_edge115, label %.lr.ph114

48:                                               ; preds = %.lr.ph111, %97
  %indvars.iv137 = phi i64 [ 1, %.lr.ph111 ], [ %indvars.iv.next138, %97 ]
  %.055108 = phi i32 [ 0, %.lr.ph111 ], [ %.257.lcssa, %97 ]
  %.058107 = phi i32 [ 1, %.lr.ph111 ], [ %.260.lcssa, %97 ]
  %49 = getelementptr inbounds [100003 x i32], ptr @ord, i64 0, i64 %indvars.iv137
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [100003 x i32], ptr @qL, i64 0, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = icmp sgt i32 %.058107, %53
  br i1 %54, label %.lr.ph92.preheader, label %.preheader74

.lr.ph92.preheader:                               ; preds = %48
  %55 = sext i32 %.058107 to i64
  br label %.lr.ph92

.preheader74.loopexit:                            ; preds = %.lr.ph92
  %56 = trunc nsw i64 %indvars.iv.next126 to i32
  br label %.preheader74

.preheader74:                                     ; preds = %.preheader74.loopexit, %48
  %.159.lcssa = phi i32 [ %.058107, %48 ], [ %56, %.preheader74.loopexit ]
  %57 = getelementptr inbounds [100003 x i32], ptr @qR, i64 0, i64 %51
  %58 = load i32, ptr %57, align 4, !tbaa !5
  %59 = icmp slt i32 %.055108, %58
  br i1 %59, label %.lr.ph97.preheader, label %.preheader73

.lr.ph97.preheader:                               ; preds = %.preheader74
  %60 = sext i32 %.055108 to i64
  br label %.lr.ph97

.lr.ph92:                                         ; preds = %.lr.ph92.preheader, %.lr.ph92
  %indvars.iv125 = phi i64 [ %55, %.lr.ph92.preheader ], [ %indvars.iv.next126, %.lr.ph92 ]
  %indvars.iv.next126 = add nsw i64 %indvars.iv125, -1
  %61 = getelementptr inbounds [100003 x i32], ptr @a, i64 0, i64 %indvars.iv.next126
  %62 = load i32, ptr %61, align 4, !tbaa !5
  call void @_Z3updii(i32 noundef %62, i32 noundef 1)
  %63 = load i32, ptr %52, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = icmp sgt i64 %indvars.iv.next126, %64
  br i1 %65, label %.lr.ph92, label %.preheader74.loopexit, !llvm.loop !13

.preheader73.loopexit:                            ; preds = %.lr.ph97
  %66 = trunc nsw i64 %indvars.iv.next129 to i32
  br label %.preheader73

.preheader73:                                     ; preds = %.preheader73.loopexit, %.preheader74
  %67 = phi i32 [ %58, %.preheader74 ], [ %72, %.preheader73.loopexit ]
  %.156.lcssa = phi i32 [ %.055108, %.preheader74 ], [ %66, %.preheader73.loopexit ]
  %68 = icmp sgt i32 %.156.lcssa, %67
  br i1 %68, label %.lr.ph100.preheader, label %.preheader72

.lr.ph100.preheader:                              ; preds = %.preheader73
  %69 = sext i32 %.156.lcssa to i64
  br label %.lr.ph100

.lr.ph97:                                         ; preds = %.lr.ph97.preheader, %.lr.ph97
  %indvars.iv128 = phi i64 [ %60, %.lr.ph97.preheader ], [ %indvars.iv.next129, %.lr.ph97 ]
  %indvars.iv.next129 = add nsw i64 %indvars.iv128, 1
  %70 = getelementptr inbounds [100003 x i32], ptr @a, i64 0, i64 %indvars.iv.next129
  %71 = load i32, ptr %70, align 4, !tbaa !5
  call void @_Z3updii(i32 noundef %71, i32 noundef 1)
  %72 = load i32, ptr %57, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = icmp slt i64 %indvars.iv.next129, %73
  br i1 %74, label %.lr.ph97, label %.preheader73.loopexit, !llvm.loop !14

.preheader72.loopexit:                            ; preds = %.lr.ph100
  %75 = trunc nsw i64 %indvars.iv.next132 to i32
  br label %.preheader72

.preheader72:                                     ; preds = %.preheader72.loopexit, %.preheader73
  %.257.lcssa = phi i32 [ %.156.lcssa, %.preheader73 ], [ %75, %.preheader72.loopexit ]
  %76 = load i32, ptr %52, align 4, !tbaa !5
  %77 = icmp slt i32 %.159.lcssa, %76
  br i1 %77, label %.lr.ph103.preheader, label %._crit_edge104

.lr.ph103.preheader:                              ; preds = %.preheader72
  %78 = sext i32 %.159.lcssa to i64
  br label %.lr.ph103

.lr.ph100:                                        ; preds = %.lr.ph100.preheader, %.lr.ph100
  %indvars.iv131 = phi i64 [ %69, %.lr.ph100.preheader ], [ %indvars.iv.next132, %.lr.ph100 ]
  %indvars.iv.next132 = add nsw i64 %indvars.iv131, -1
  %79 = getelementptr inbounds [100003 x i32], ptr @a, i64 0, i64 %indvars.iv131
  %80 = load i32, ptr %79, align 4, !tbaa !5
  call void @_Z3updii(i32 noundef %80, i32 noundef -1)
  %81 = load i32, ptr %57, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = icmp sgt i64 %indvars.iv.next132, %82
  br i1 %83, label %.lr.ph100, label %.preheader72.loopexit, !llvm.loop !15

.lr.ph103:                                        ; preds = %.lr.ph103.preheader, %.lr.ph103
  %indvars.iv134 = phi i64 [ %78, %.lr.ph103.preheader ], [ %indvars.iv.next135, %.lr.ph103 ]
  %indvars.iv.next135 = add nsw i64 %indvars.iv134, 1
  %84 = getelementptr inbounds [100003 x i32], ptr @a, i64 0, i64 %indvars.iv134
  %85 = load i32, ptr %84, align 4, !tbaa !5
  call void @_Z3updii(i32 noundef %85, i32 noundef -1)
  %86 = load i32, ptr %52, align 4, !tbaa !5
  %87 = sext i32 %86 to i64
  %88 = icmp slt i64 %indvars.iv.next135, %87
  br i1 %88, label %.lr.ph103, label %._crit_edge104.loopexit, !llvm.loop !16

._crit_edge104.loopexit:                          ; preds = %.lr.ph103
  %89 = trunc nsw i64 %indvars.iv.next135 to i32
  br label %._crit_edge104

._crit_edge104:                                   ; preds = %._crit_edge104.loopexit, %.preheader72
  %.260.lcssa = phi i32 [ %.159.lcssa, %.preheader72 ], [ %89, %._crit_edge104.loopexit ]
  %90 = getelementptr inbounds [100003 x i32], ptr @ans, i64 0, i64 %51
  store i32 0, ptr %90, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %3) #7
  call void @_ZNSt5queueISt4pairIiiESt5dequeIS1_SaIS1_EEEC2IS4_vEEv(ptr noundef nonnull align 8 dereferenceable(80) %3)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #7
  store ptr %90, ptr %4, align 8, !tbaa !17
  store ptr %3, ptr %38, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #7
  %91 = load i32, ptr @dR, align 16, !tbaa !5
  store i32 %91, ptr %5, align 4, !tbaa !5
  br label %92

92:                                               ; preds = %139, %._crit_edge104
  %93 = phi i32 [ %91, %._crit_edge104 ], [ %.pre, %139 ]
  %.050 = phi i32 [ 0, %._crit_edge104 ], [ %spec.select, %139 ]
  %94 = load i32, ptr @n, align 4, !tbaa !5
  %.not67 = icmp sgt i32 %93, %94
  br i1 %.not67, label %95, label %.critedge

95:                                               ; preds = %92
  %96 = call noundef zeroext i1 @_ZNKSt5queueISt4pairIiiESt5dequeIS1_SaIS1_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %3)
  br i1 %96, label %97, label %.critedge

97:                                               ; preds = %95
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #7
  call void @_ZNSt5queueISt4pairIiiESt5dequeIS1_SaIS1_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %3) #7
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %3) #7
  %indvars.iv.next138 = add nuw nsw i64 %indvars.iv137, 1
  %98 = load i32, ptr @q, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %.not65.not = icmp slt i64 %indvars.iv137, %99
  br i1 %.not65.not, label %48, label %.preheader, !llvm.loop !19

.critedge:                                        ; preds = %92, %95
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #7
  %100 = call noundef zeroext i1 @_ZNKSt5queueISt4pairIiiESt5dequeIS1_SaIS1_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %3)
  br i1 %100, label %101, label %103

101:                                              ; preds = %.critedge
  store i32 0, ptr %7, align 4, !tbaa !5
  %102 = invoke i64 @_ZSt9make_pairIRKiiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS3_INS4_IT0_E4typeEE6__typeEEOS5_OSA_(ptr noundef nonnull align 4 dereferenceable(4) @_ZL4maxn, ptr noundef nonnull align 4 dereferenceable(4) %7)
          to label %106 unwind label %119

103:                                              ; preds = %.critedge
  %104 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt5queueISt4pairIiiESt5dequeIS1_SaIS1_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) %3)
  %105 = load i64, ptr %104, align 4
  br label %106

106:                                              ; preds = %101, %103
  %storemerge = phi i64 [ %105, %103 ], [ %102, %101 ]
  store i64 %storemerge, ptr %6, align 8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #7
  %107 = load i32, ptr %5, align 4, !tbaa !5
  %108 = load i32, ptr @n, align 4, !tbaa !5
  %.not68 = icmp sgt i32 %107, %108
  %._ZL4maxn = select i1 %.not68, ptr @_ZL4maxn, ptr %5
  %109 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %._ZL4maxn, ptr noundef nonnull align 4 dereferenceable(4) %6)
  %110 = load i32, ptr %109, align 4, !tbaa !5
  %111 = load i32, ptr %5, align 4, !tbaa !5
  %112 = icmp eq i32 %110, %111
  br i1 %112, label %113, label %121

113:                                              ; preds = %106
  %114 = sext i32 %110 to i64
  %115 = getelementptr inbounds [100003 x i32], ptr @d, i64 0, i64 %114
  %116 = load i32, ptr %115, align 4, !tbaa !5
  %117 = getelementptr inbounds [100003 x i32], ptr @dR, i64 0, i64 %114
  %118 = load i32, ptr %117, align 4, !tbaa !5
  store i32 %118, ptr %5, align 4, !tbaa !5
  br label %121

119:                                              ; preds = %101
  %120 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #7
  br label %141

121:                                              ; preds = %113, %106
  %.046 = phi i32 [ %116, %113 ], [ 0, %106 ]
  %122 = load i32, ptr %6, align 8, !tbaa !20
  %123 = icmp eq i32 %110, %122
  br i1 %123, label %124, label %129

124:                                              ; preds = %121
  %125 = load i32, ptr %39, align 4, !tbaa !22
  %126 = add nsw i32 %125, %.046
  call void @_ZNSt5queueISt4pairIiiESt5dequeIS1_SaIS1_EEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) %3)
  br label %129

127:                                              ; preds = %136, %130
  %128 = landingpad { ptr, i32 }
          cleanup
  br label %141

129:                                              ; preds = %124, %121
  %.1 = phi i32 [ %126, %124 ], [ %.046, %121 ]
  %.not69 = icmp eq i32 %.050, 0
  br i1 %.not69, label %134, label %130

130:                                              ; preds = %129
  %131 = add nsw i32 %110, %.050
  invoke void @"_ZZ4mainENK3$_1clEii"(ptr noundef nonnull align 8 dereferenceable(16) %4, i32 noundef %131, i32 noundef 1)
          to label %132 unwind label %127

132:                                              ; preds = %130
  %133 = add nsw i32 %.1, -1
  br label %134

134:                                              ; preds = %132, %129
  %.2 = phi i32 [ %133, %132 ], [ %.1, %129 ]
  %135 = icmp sgt i32 %.2, 1
  br i1 %135, label %136, label %139

136:                                              ; preds = %134
  %137 = shl nsw i32 %110, 1
  %138 = lshr i32 %.2, 1
  invoke void @"_ZZ4mainENK3$_1clEii"(ptr noundef nonnull align 8 dereferenceable(16) %4, i32 noundef %137, i32 noundef %138)
          to label %139 unwind label %127

139:                                              ; preds = %136, %134
  %140 = and i32 %.2, 1
  %.not71 = icmp eq i32 %140, 0
  %spec.select = select i1 %.not71, i32 0, i32 %110
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #7
  %.pre = load i32, ptr %5, align 4, !tbaa !5
  br label %92, !llvm.loop !23

141:                                              ; preds = %127, %119
  %.pn = phi { ptr, i32 } [ %128, %127 ], [ %120, %119 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #7
  call void @_ZNSt5queueISt4pairIiiESt5dequeIS1_SaIS1_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %3) #7
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %3) #7
  resume { ptr, i32 } %.pn

._crit_edge115:                                   ; preds = %.lr.ph114, %._crit_edge88, %.preheader
  ret i32 0

.lr.ph114:                                        ; preds = %.preheader, %.lr.ph114
  %indvars.iv140 = phi i64 [ %indvars.iv.next141, %.lr.ph114 ], [ 1, %.preheader ]
  %142 = getelementptr inbounds [100003 x i32], ptr @ans, i64 0, i64 %indvars.iv140
  %143 = load i32, ptr %142, align 4, !tbaa !5
  %144 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %143)
  %indvars.iv.next141 = add nuw nsw i64 %indvars.iv140, 1
  %145 = load i32, ptr @q, align 4, !tbaa !5
  %146 = sext i32 %145 to i64
  %.not66.not = icmp slt i64 %indvars.iv140, %146
  br i1 %.not66.not, label %.lr.ph114, label %._crit_edge115, !llvm.loop !24
}

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

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZSt4sortIPiZ4mainE3$_0EvT_S2_T0_"(ptr noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z3updii(i32 noundef, i32 noundef) local_unnamed_addr #3

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt5queueISt4pairIiiESt5dequeIS1_SaIS1_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #6 align 2

declare i32 @__gxx_personality_v0(...)

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt5queueISt4pairIiiESt5dequeIS1_SaIS1_EEE3popEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #6 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZZ4mainENK3$_1clEii"(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef, i32 noundef) local_unnamed_addr #4 align 2

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

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

attributes #0 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { 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 #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 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 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #7 = { nounwind }

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

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


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