; LLVM IR from tangjz/acm-icpc :: codeforces/gym (101201F)

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

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@ord = external dso_local global [2001 x i32], align 16
@x = external dso_local global [2001 x i32], align 16
@y = external dso_local global [2001 x i32], align 16
@tot = external dso_local global i32, align 4
@pre = external dso_local global [2001 x i32], align 16
@rev = external dso_local global [2001 x i32], align 16
@seq = external dso_local global [2001 x i32], align 16
@scc = external dso_local global [2001 x i32], align 16
@vis = external dso_local global [2001 x i8], align 16
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z7addEdgeii(i32 noundef, i32 noundef) #0

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4dfs1i(i32 noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4dfs2i(i32 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3cmpRKiS0_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %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 i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i8, align 1
  %16 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @m, ptr noundef @q, ptr noundef @n)
  call void @llvm.memset.p0.i64(ptr align 16 @pre, i8 -1, i64 8004, i1 false)
  call void @llvm.memset.p0.i64(ptr align 16 @rev, i8 -1, i64 8004, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #8
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %35, %0
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = load i32, ptr @n, align 4, !tbaa !5
  %21 = icmp slt i32 %19, %20
  br i1 %21, label %23, label %22

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

23:                                               ; preds = %18
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds i32, ptr @x, i64 %25
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds i32, ptr @y, i64 %28
  %30 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %26, ptr noundef %29)
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [2001 x i32], ptr @ord, i64 0, i64 %33
  store i32 %31, ptr %34, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %23
  %36 = load i32, ptr %2, align 4, !tbaa !5
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %2, align 4, !tbaa !5
  br label %18, !llvm.loop !9

38:                                               ; preds = %22
  %39 = load i32, ptr @n, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds i32, ptr @ord, i64 %40
  call void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef @ord, ptr noundef %41, ptr noundef @_Z3cmpRKiS0_)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #8
  store i32 0, 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
  br label %42

42:                                               ; preds = %138, %38
  %43 = load i32, ptr %3, align 4, !tbaa !5
  %44 = load i32, ptr @n, align 4, !tbaa !5
  %45 = icmp slt i32 %43, %44
  br i1 %45, label %47, label %46

46:                                               ; preds = %42
  store i32 5, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #8
  br label %140

47:                                               ; preds = %42
  br label %48

48:                                               ; preds = %71, %47
  %49 = load i32, ptr %4, align 4, !tbaa !5
  %50 = load i32, ptr @n, align 4, !tbaa !5
  %51 = icmp slt i32 %49, %50
  br i1 %51, label %52, label %68

52:                                               ; preds = %48
  %53 = load i32, ptr %3, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [2001 x i32], ptr @ord, i64 0, i64 %54
  %56 = load i32, ptr %55, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [2001 x i32], ptr @x, i64 0, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = load i32, ptr %4, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [2001 x i32], ptr @ord, i64 0, i64 %61
  %63 = load i32, ptr %62, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [2001 x i32], ptr @x, i64 0, i64 %64
  %66 = load i32, ptr %65, align 4, !tbaa !5
  %67 = icmp eq i32 %59, %66
  br label %68

68:                                               ; preds = %52, %48
  %69 = phi i1 [ false, %48 ], [ %67, %52 ]
  br i1 %69, label %70, label %74

70:                                               ; preds = %68
  br label %71

71:                                               ; preds = %70
  %72 = load i32, ptr %4, align 4, !tbaa !5
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %4, align 4, !tbaa !5
  br label %48, !llvm.loop !11

74:                                               ; preds = %68
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #8
  %75 = load i32, ptr %3, align 4, !tbaa !5
  store i32 %75, ptr %6, align 4, !tbaa !5
  br label %76

76:                                               ; preds = %134, %74
  %77 = load i32, ptr %6, align 4, !tbaa !5
  %78 = load i32, ptr %4, align 4, !tbaa !5
  %79 = icmp slt i32 %77, %78
  br i1 %79, label %81, label %80

80:                                               ; preds = %76
  store i32 11, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #8
  br label %137

81:                                               ; preds = %76
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #8
  %82 = load i32, ptr %6, align 4, !tbaa !5
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %7, align 4, !tbaa !5
  br label %84

84:                                               ; preds = %130, %81
  %85 = load i32, ptr %7, align 4, !tbaa !5
  %86 = load i32, ptr %4, align 4, !tbaa !5
  %87 = icmp slt i32 %85, %86
  br i1 %87, label %89, label %88

88:                                               ; preds = %84
  store i32 14, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #8
  br label %133

89:                                               ; preds = %84
  %90 = load i32, ptr %7, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [2001 x i32], ptr @ord, i64 0, i64 %91
  %93 = load i32, ptr %92, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [2001 x i32], ptr @y, i64 0, i64 %94
  %96 = load i32, ptr %95, align 4, !tbaa !5
  %97 = load i32, ptr %6, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [2001 x i32], ptr @ord, i64 0, i64 %98
  %100 = load i32, ptr %99, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [2001 x i32], ptr @y, i64 0, i64 %101
  %103 = load i32, ptr %102, align 4, !tbaa !5
  %104 = sub nsw i32 %96, %103
  %105 = load i32, ptr @q, align 4, !tbaa !5
  %106 = shl i32 %105, 1
  %107 = icmp sle i32 %104, %106
  br i1 %107, label %108, label %129

108:                                              ; preds = %89
  %109 = load i32, ptr @n, align 4, !tbaa !5
  %110 = load i32, ptr %7, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [2001 x i32], ptr @ord, i64 0, i64 %111
  %113 = load i32, ptr %112, align 4, !tbaa !5
  %114 = add nsw i32 %109, %113
  %115 = load i32, ptr %6, align 4, !tbaa !5
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds [2001 x i32], ptr @ord, i64 0, i64 %116
  %118 = load i32, ptr %117, align 4, !tbaa !5
  call void @_Z7addEdgeii(i32 noundef %114, i32 noundef %118)
  %119 = load i32, ptr @n, align 4, !tbaa !5
  %120 = load i32, ptr %6, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [2001 x i32], ptr @ord, i64 0, i64 %121
  %123 = load i32, ptr %122, align 4, !tbaa !5
  %124 = add nsw i32 %119, %123
  %125 = load i32, ptr %7, align 4, !tbaa !5
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [2001 x i32], ptr @ord, i64 0, i64 %126
  %128 = load i32, ptr %127, align 4, !tbaa !5
  call void @_Z7addEdgeii(i32 noundef %124, i32 noundef %128)
  br label %129

129:                                              ; preds = %108, %89
  br label %130

130:                                              ; preds = %129
  %131 = load i32, ptr %7, align 4, !tbaa !5
  %132 = add nsw i32 %131, 1
  store i32 %132, ptr %7, align 4, !tbaa !5
  br label %84, !llvm.loop !12

133:                                              ; preds = %88
  br label %134

134:                                              ; preds = %133
  %135 = load i32, ptr %6, align 4, !tbaa !5
  %136 = add nsw i32 %135, 1
  store i32 %136, ptr %6, align 4, !tbaa !5
  br label %76, !llvm.loop !13

137:                                              ; preds = %80
  br label %138

138:                                              ; preds = %137
  %139 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %139, ptr %3, align 4, !tbaa !5
  br label %42, !llvm.loop !14

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

141:                                              ; preds = %153, %140
  %142 = load i32, ptr %8, align 4, !tbaa !5
  %143 = load i32, ptr @n, align 4, !tbaa !5
  %144 = icmp slt i32 %142, %143
  br i1 %144, label %146, label %145

145:                                              ; preds = %141
  store i32 17, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #8
  br label %156

146:                                              ; preds = %141
  %147 = load i32, ptr %8, align 4, !tbaa !5
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds [2001 x i32], ptr @x, i64 0, i64 %148
  %150 = load i32, ptr %8, align 4, !tbaa !5
  %151 = sext i32 %150 to i64
  %152 = getelementptr inbounds [2001 x i32], ptr @y, i64 0, i64 %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) %149, ptr noundef nonnull align 4 dereferenceable(4) %152) #8
  br label %153

153:                                              ; preds = %146
  %154 = load i32, ptr %8, align 4, !tbaa !5
  %155 = add nsw i32 %154, 1
  store i32 %155, ptr %8, align 4, !tbaa !5
  br label %141, !llvm.loop !15

156:                                              ; preds = %145
  %157 = load i32, ptr @n, align 4, !tbaa !5
  %158 = sext i32 %157 to i64
  %159 = getelementptr inbounds i32, ptr @ord, i64 %158
  call void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef @ord, ptr noundef %159, ptr noundef @_Z3cmpRKiS0_)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #8
  store i32 0, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #8
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %160

160:                                              ; preds = %256, %156
  %161 = load i32, ptr %9, align 4, !tbaa !5
  %162 = load i32, ptr @n, align 4, !tbaa !5
  %163 = icmp slt i32 %161, %162
  br i1 %163, label %165, label %164

164:                                              ; preds = %160
  store i32 20, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #8
  br label %258

165:                                              ; preds = %160
  br label %166

166:                                              ; preds = %189, %165
  %167 = load i32, ptr %10, align 4, !tbaa !5
  %168 = load i32, ptr @n, align 4, !tbaa !5
  %169 = icmp slt i32 %167, %168
  br i1 %169, label %170, label %186

170:                                              ; preds = %166
  %171 = load i32, ptr %9, align 4, !tbaa !5
  %172 = sext i32 %171 to i64
  %173 = getelementptr inbounds [2001 x i32], ptr @ord, i64 0, i64 %172
  %174 = load i32, ptr %173, align 4, !tbaa !5
  %175 = sext i32 %174 to i64
  %176 = getelementptr inbounds [2001 x i32], ptr @x, i64 0, i64 %175
  %177 = load i32, ptr %176, align 4, !tbaa !5
  %178 = load i32, ptr %10, align 4, !tbaa !5
  %179 = sext i32 %178 to i64
  %180 = getelementptr inbounds [2001 x i32], ptr @ord, i64 0, i64 %179
  %181 = load i32, ptr %180, align 4, !tbaa !5
  %182 = sext i32 %181 to i64
  %183 = getelementptr inbounds [2001 x i32], ptr @x, i64 0, i64 %182
  %184 = load i32, ptr %183, align 4, !tbaa !5
  %185 = icmp eq i32 %177, %184
  br label %186

186:                                              ; preds = %170, %166
  %187 = phi i1 [ false, %166 ], [ %185, %170 ]
  br i1 %187, label %188, label %192

188:                                              ; preds = %186
  br label %189

189:                                              ; preds = %188
  %190 = load i32, ptr %10, align 4, !tbaa !5
  %191 = add nsw i32 %190, 1
  store i32 %191, ptr %10, align 4, !tbaa !5
  br label %166, !llvm.loop !16

192:                                              ; preds = %186
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #8
  %193 = load i32, ptr %9, align 4, !tbaa !5
  store i32 %193, ptr %11, align 4, !tbaa !5
  br label %194

194:                                              ; preds = %252, %192
  %195 = load i32, ptr %11, align 4, !tbaa !5
  %196 = load i32, ptr %10, align 4, !tbaa !5
  %197 = icmp slt i32 %195, %196
  br i1 %197, label %199, label %198

198:                                              ; preds = %194
  store i32 26, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  br label %255

199:                                              ; preds = %194
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #8
  %200 = load i32, ptr %11, align 4, !tbaa !5
  %201 = add nsw i32 %200, 1
  store i32 %201, ptr %12, align 4, !tbaa !5
  br label %202

202:                                              ; preds = %248, %199
  %203 = load i32, ptr %12, align 4, !tbaa !5
  %204 = load i32, ptr %10, align 4, !tbaa !5
  %205 = icmp slt i32 %203, %204
  br i1 %205, label %207, label %206

206:                                              ; preds = %202
  store i32 29, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #8
  br label %251

207:                                              ; preds = %202
  %208 = load i32, ptr %12, align 4, !tbaa !5
  %209 = sext i32 %208 to i64
  %210 = getelementptr inbounds [2001 x i32], ptr @ord, i64 0, i64 %209
  %211 = load i32, ptr %210, align 4, !tbaa !5
  %212 = sext i32 %211 to i64
  %213 = getelementptr inbounds [2001 x i32], ptr @y, i64 0, i64 %212
  %214 = load i32, ptr %213, align 4, !tbaa !5
  %215 = load i32, ptr %11, align 4, !tbaa !5
  %216 = sext i32 %215 to i64
  %217 = getelementptr inbounds [2001 x i32], ptr @ord, i64 0, i64 %216
  %218 = load i32, ptr %217, align 4, !tbaa !5
  %219 = sext i32 %218 to i64
  %220 = getelementptr inbounds [2001 x i32], ptr @y, i64 0, i64 %219
  %221 = load i32, ptr %220, align 4, !tbaa !5
  %222 = sub nsw i32 %214, %221
  %223 = load i32, ptr @q, align 4, !tbaa !5
  %224 = shl i32 %223, 1
  %225 = icmp sle i32 %222, %224
  br i1 %225, label %226, label %247

226:                                              ; preds = %207
  %227 = load i32, ptr %12, align 4, !tbaa !5
  %228 = sext i32 %227 to i64
  %229 = getelementptr inbounds [2001 x i32], ptr @ord, i64 0, i64 %228
  %230 = load i32, ptr %229, align 4, !tbaa !5
  %231 = load i32, ptr @n, align 4, !tbaa !5
  %232 = load i32, ptr %11, align 4, !tbaa !5
  %233 = sext i32 %232 to i64
  %234 = getelementptr inbounds [2001 x i32], ptr @ord, i64 0, i64 %233
  %235 = load i32, ptr %234, align 4, !tbaa !5
  %236 = add nsw i32 %231, %235
  call void @_Z7addEdgeii(i32 noundef %230, i32 noundef %236)
  %237 = load i32, ptr %11, align 4, !tbaa !5
  %238 = sext i32 %237 to i64
  %239 = getelementptr inbounds [2001 x i32], ptr @ord, i64 0, i64 %238
  %240 = load i32, ptr %239, align 4, !tbaa !5
  %241 = load i32, ptr @n, align 4, !tbaa !5
  %242 = load i32, ptr %12, align 4, !tbaa !5
  %243 = sext i32 %242 to i64
  %244 = getelementptr inbounds [2001 x i32], ptr @ord, i64 0, i64 %243
  %245 = load i32, ptr %244, align 4, !tbaa !5
  %246 = add nsw i32 %241, %245
  call void @_Z7addEdgeii(i32 noundef %240, i32 noundef %246)
  br label %247

247:                                              ; preds = %226, %207
  br label %248

248:                                              ; preds = %247
  %249 = load i32, ptr %12, align 4, !tbaa !5
  %250 = add nsw i32 %249, 1
  store i32 %250, ptr %12, align 4, !tbaa !5
  br label %202, !llvm.loop !17

251:                                              ; preds = %206
  br label %252

252:                                              ; preds = %251
  %253 = load i32, ptr %11, align 4, !tbaa !5
  %254 = add nsw i32 %253, 1
  store i32 %254, ptr %11, align 4, !tbaa !5
  br label %194, !llvm.loop !18

255:                                              ; preds = %198
  br label %256

256:                                              ; preds = %255
  %257 = load i32, ptr %10, align 4, !tbaa !5
  store i32 %257, ptr %9, align 4, !tbaa !5
  br label %160, !llvm.loop !19

258:                                              ; preds = %164
  %259 = load i32, ptr @n, align 4, !tbaa !5
  %260 = shl i32 %259, 1
  store i32 %260, ptr @n, align 4, !tbaa !5
  store i32 0, ptr @tot, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #8
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %261

261:                                              ; preds = %275, %258
  %262 = load i32, ptr %13, align 4, !tbaa !5
  %263 = load i32, ptr @n, align 4, !tbaa !5
  %264 = icmp slt i32 %262, %263
  br i1 %264, label %266, label %265

265:                                              ; preds = %261
  store i32 32, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #8
  br label %278

266:                                              ; preds = %261
  %267 = load i32, ptr %13, align 4, !tbaa !5
  %268 = sext i32 %267 to i64
  %269 = getelementptr inbounds [2001 x i8], ptr @vis, i64 0, i64 %268
  %270 = load i8, ptr %269, align 1, !tbaa !20, !range !22, !noundef !23
  %271 = trunc i8 %270 to i1
  br i1 %271, label %274, label %272

272:                                              ; preds = %266
  %273 = load i32, ptr %13, align 4, !tbaa !5
  call void @_Z4dfs1i(i32 noundef %273)
  br label %274

274:                                              ; preds = %272, %266
  br label %275

275:                                              ; preds = %274
  %276 = load i32, ptr %13, align 4, !tbaa !5
  %277 = add nsw i32 %276, 1
  store i32 %277, ptr %13, align 4, !tbaa !5
  br label %261, !llvm.loop !24

278:                                              ; preds = %265
  store i32 0, ptr @tot, align 4, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 16 @scc, i8 -1, i64 8004, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #8
  %279 = load i32, ptr @n, align 4, !tbaa !5
  %280 = sub nsw i32 %279, 1
  store i32 %280, ptr %14, align 4, !tbaa !5
  br label %281

281:                                              ; preds = %302, %278
  %282 = load i32, ptr %14, align 4, !tbaa !5
  %283 = icmp sge i32 %282, 0
  br i1 %283, label %285, label %284

284:                                              ; preds = %281
  store i32 35, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #8
  br label %305

285:                                              ; preds = %281
  %286 = load i32, ptr %14, align 4, !tbaa !5
  %287 = sext i32 %286 to i64
  %288 = getelementptr inbounds [2001 x i32], ptr @seq, i64 0, i64 %287
  %289 = load i32, ptr %288, align 4, !tbaa !5
  %290 = sext i32 %289 to i64
  %291 = getelementptr inbounds [2001 x i32], ptr @scc, i64 0, i64 %290
  %292 = load i32, ptr %291, align 4, !tbaa !5
  %293 = icmp eq i32 %292, -1
  br i1 %293, label %294, label %301

294:                                              ; preds = %285
  %295 = load i32, ptr %14, align 4, !tbaa !5
  %296 = sext i32 %295 to i64
  %297 = getelementptr inbounds [2001 x i32], ptr @seq, i64 0, i64 %296
  %298 = load i32, ptr %297, align 4, !tbaa !5
  call void @_Z4dfs2i(i32 noundef %298)
  %299 = load i32, ptr @tot, align 4, !tbaa !5
  %300 = add nsw i32 %299, 1
  store i32 %300, ptr @tot, align 4, !tbaa !5
  br label %301

301:                                              ; preds = %294, %285
  br label %302

302:                                              ; preds = %301
  %303 = load i32, ptr %14, align 4, !tbaa !5
  %304 = add nsw i32 %303, -1
  store i32 %304, ptr %14, align 4, !tbaa !5
  br label %281, !llvm.loop !25

305:                                              ; preds = %284
  %306 = load i32, ptr @n, align 4, !tbaa !5
  %307 = ashr i32 %306, 1
  store i32 %307, ptr @n, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %15) #8
  store i8 1, ptr %15, align 1, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #8
  store i32 0, ptr %16, align 4, !tbaa !5
  br label %308

308:                                              ; preds = %332, %305
  %309 = load i32, ptr %16, align 4, !tbaa !5
  %310 = load i32, ptr @n, align 4, !tbaa !5
  %311 = icmp slt i32 %309, %310
  br i1 %311, label %313, label %312

312:                                              ; preds = %308
  store i32 38, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #8
  br label %335

313:                                              ; preds = %308
  %314 = load i32, ptr %16, align 4, !tbaa !5
  %315 = sext i32 %314 to i64
  %316 = getelementptr inbounds [2001 x i32], ptr @scc, i64 0, i64 %315
  %317 = load i32, ptr %316, align 4, !tbaa !5
  %318 = load i32, ptr @n, align 4, !tbaa !5
  %319 = load i32, ptr %16, align 4, !tbaa !5
  %320 = add nsw i32 %318, %319
  %321 = sext i32 %320 to i64
  %322 = getelementptr inbounds [2001 x i32], ptr @scc, i64 0, i64 %321
  %323 = load i32, ptr %322, align 4, !tbaa !5
  %324 = icmp ne i32 %317, %323
  %325 = zext i1 %324 to i32
  %326 = load i8, ptr %15, align 1, !tbaa !20, !range !22, !noundef !23
  %327 = trunc i8 %326 to i1
  %328 = zext i1 %327 to i32
  %329 = and i32 %328, %325
  %330 = icmp ne i32 %329, 0
  %331 = zext i1 %330 to i8
  store i8 %331, ptr %15, align 1, !tbaa !20
  br label %332

332:                                              ; preds = %313
  %333 = load i32, ptr %16, align 4, !tbaa !5
  %334 = add nsw i32 %333, 1
  store i32 %334, ptr %16, align 4, !tbaa !5
  br label %308, !llvm.loop !26

335:                                              ; preds = %312
  %336 = load i8, ptr %15, align 1, !tbaa !20, !range !22, !noundef !23
  %337 = trunc i8 %336 to i1
  %338 = zext i1 %337 to i64
  %339 = select i1 %337, ptr @.str.2, ptr @.str.3
  %340 = call i32 @puts(ptr noundef %339)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %15) #8
  %341 = load i32, ptr %1, align 4
  ret i32 %341
}

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

; 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: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef, ptr noundef, ptr noundef) #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

declare i32 @puts(ptr noundef) #4

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #4 = { "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 = { 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 #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 = !{!"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 = distinct !{!17, !10}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}
!20 = !{!21, !21, i64 0}
!21 = !{!"bool", !7, i64 0}
!22 = !{i8 0, i8 2}
!23 = !{}
!24 = distinct !{!24, !10}
!25 = distinct !{!25, !10}
!26 = distinct !{!26, !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"

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@ord = external dso_local global [2001 x i32], align 16
@x = external dso_local global [2001 x i32], align 16
@y = external dso_local global [2001 x i32], align 16
@tot = external dso_local local_unnamed_addr global i32, align 4
@pre = external dso_local local_unnamed_addr global [2001 x i32], align 16
@rev = external dso_local local_unnamed_addr global [2001 x i32], align 16
@seq = external dso_local local_unnamed_addr global [2001 x i32], align 16
@scc = external dso_local local_unnamed_addr global [2001 x i32], align 16
@vis = external dso_local local_unnamed_addr global [2001 x i8], align 16
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z7addEdgeii(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4dfs1i(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4dfs2i(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3cmpRKiS0_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @m, ptr noundef nonnull @q, ptr noundef nonnull @n)
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(8004) @pre, i8 -1, i64 8004, i1 false)
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(8004) @rev, i8 -1, i64 8004, i1 false)
  %2 = load i32, ptr @n, align 4, !tbaa !5
  %3 = icmp sgt i32 %2, 0
  br i1 %3, label %.lr.ph, label %.._crit_edge_crit_edge

.._crit_edge_crit_edge:                           ; preds = %0
  %.pre182 = sext i32 %2 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre182, %.._crit_edge_crit_edge ], [ %13, %.lr.ph ]
  %4 = getelementptr inbounds i32, ptr @ord, i64 %.pre-phi
  tail call void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef nonnull @ord, ptr noundef nonnull %4, ptr noundef nonnull @_Z3cmpRKiS0_)
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.preheader90, label %.preheader87.._crit_edge104_crit_edge

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %7 = getelementptr inbounds i32, ptr @x, i64 %indvars.iv
  %8 = getelementptr inbounds i32, ptr @y, i64 %indvars.iv
  %9 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %7, ptr noundef nonnull %8)
  %10 = getelementptr inbounds [2001 x i32], ptr @ord, i64 0, i64 %indvars.iv
  %11 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %11, ptr %10, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %12 = load i32, ptr @n, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = icmp slt i64 %indvars.iv.next, %13
  br i1 %14, label %.lr.ph, label %._crit_edge, !llvm.loop !9

.loopexit89.loopexit:                             ; preds = %.loopexit88
  %.pre176 = load i32, ptr @n, align 4, !tbaa !5
  br label %.loopexit89

.loopexit89:                                      ; preds = %.loopexit89.loopexit, %.critedge
  %15 = phi i32 [ %.pre176, %.loopexit89.loopexit ], [ %17, %.critedge ]
  %16 = icmp slt i32 %.178.lcssa, %15
  br i1 %16, label %.preheader90, label %.preheader87, !llvm.loop !11

.preheader90:                                     ; preds = %._crit_edge, %.loopexit89
  %17 = phi i32 [ %15, %.loopexit89 ], [ %5, %._crit_edge ]
  %.077101 = phi i32 [ %.178.lcssa, %.loopexit89 ], [ 0, %._crit_edge ]
  %18 = sext i32 %.077101 to i64
  %19 = getelementptr inbounds [2001 x i32], ptr @ord, i64 0, i64 %18
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [2001 x i32], ptr @x, i64 0, i64 %21
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = sext i32 %17 to i64
  %25 = add nsw i32 %.077101, 1
  %smax = tail call i32 @llvm.smax.i32(i32 %17, i32 %25)
  br label %28

.preheader87:                                     ; preds = %.loopexit89
  %26 = icmp sgt i32 %15, 0
  br i1 %26, label %.lr.ph103, label %.preheader87.._crit_edge104_crit_edge

.preheader87.._crit_edge104_crit_edge:            ; preds = %._crit_edge, %.preheader87
  %27 = phi i32 [ %15, %.preheader87 ], [ %5, %._crit_edge ]
  %.pre183 = sext i32 %27 to i64
  br label %._crit_edge104

28:                                               ; preds = %.preheader90, %35
  %indvars.iv137 = phi i64 [ %18, %.preheader90 ], [ %indvars.iv.next138, %35 ]
  %29 = getelementptr inbounds [2001 x i32], ptr @ord, i64 0, i64 %indvars.iv137
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [2001 x i32], ptr @x, i64 0, i64 %31
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %34 = icmp eq i32 %23, %33
  br i1 %34, label %35, label %.critedge.split.loop.exit191

35:                                               ; preds = %28
  %indvars.iv.next138 = add nsw i64 %indvars.iv137, 1
  %36 = icmp slt i64 %indvars.iv.next138, %24
  br i1 %36, label %28, label %.critedge, !llvm.loop !12

.critedge.split.loop.exit191:                     ; preds = %28
  %37 = trunc nsw i64 %indvars.iv137 to i32
  br label %.critedge

.critedge:                                        ; preds = %35, %.critedge.split.loop.exit191
  %.178.lcssa = phi i32 [ %37, %.critedge.split.loop.exit191 ], [ %smax, %35 ]
  %38 = icmp slt i32 %.077101, %.178.lcssa
  br i1 %38, label %.lr.ph100.preheader, label %.loopexit89

.lr.ph100.preheader:                              ; preds = %.critedge
  %39 = sext i32 %.178.lcssa to i64
  br label %.lr.ph100

.loopexit88:                                      ; preds = %62, %.lr.ph100
  %exitcond.not = icmp eq i64 %indvars.iv.next146, %39
  br i1 %exitcond.not, label %.loopexit89.loopexit, label %.lr.ph100, !llvm.loop !13

.lr.ph100:                                        ; preds = %.lr.ph100.preheader, %.loopexit88
  %indvars.iv145 = phi i64 [ %18, %.lr.ph100.preheader ], [ %indvars.iv.next146, %.loopexit88 ]
  %indvars.iv140.in = phi i64 [ %18, %.lr.ph100.preheader ], [ %indvars.iv140, %.loopexit88 ]
  %indvars.iv140 = add nsw i64 %indvars.iv140.in, 1
  %indvars.iv.next146 = add nsw i64 %indvars.iv145, 1
  %40 = icmp slt i64 %indvars.iv.next146, %39
  br i1 %40, label %.lr.ph98, label %.loopexit88

.lr.ph98:                                         ; preds = %.lr.ph100
  %41 = getelementptr inbounds [2001 x i32], ptr @ord, i64 0, i64 %indvars.iv145
  %.pre175 = load i32, ptr @q, align 4, !tbaa !5
  br label %42

42:                                               ; preds = %.lr.ph98, %62
  %43 = phi i32 [ %.pre175, %.lr.ph98 ], [ %63, %62 ]
  %indvars.iv142 = phi i64 [ %indvars.iv140, %.lr.ph98 ], [ %indvars.iv.next143, %62 ]
  %44 = getelementptr inbounds [2001 x i32], ptr @ord, i64 0, i64 %indvars.iv142
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [2001 x i32], ptr @y, i64 0, i64 %46
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = load i32, ptr %41, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [2001 x i32], ptr @y, i64 0, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = sub nsw i32 %48, %52
  %54 = shl i32 %43, 1
  %.not85 = icmp sgt i32 %53, %54
  br i1 %.not85, label %62, label %55

55:                                               ; preds = %42
  %56 = load i32, ptr @n, align 4, !tbaa !5
  %57 = add nsw i32 %56, %45
  tail call void @_Z7addEdgeii(i32 noundef %57, i32 noundef %49)
  %58 = load i32, ptr @n, align 4, !tbaa !5
  %59 = load i32, ptr %41, align 4, !tbaa !5
  %60 = add nsw i32 %59, %58
  %61 = load i32, ptr %44, align 4, !tbaa !5
  tail call void @_Z7addEdgeii(i32 noundef %60, i32 noundef %61)
  %.pre = load i32, ptr @q, align 4, !tbaa !5
  br label %62

62:                                               ; preds = %42, %55
  %63 = phi i32 [ %43, %42 ], [ %.pre, %55 ]
  %indvars.iv.next143 = add nsw i64 %indvars.iv142, 1
  %64 = icmp slt i64 %indvars.iv.next143, %39
  br i1 %64, label %42, label %.loopexit88, !llvm.loop !14

._crit_edge104:                                   ; preds = %.lr.ph103, %.preheader87.._crit_edge104_crit_edge
  %.pre-phi184 = phi i64 [ %.pre183, %.preheader87.._crit_edge104_crit_edge ], [ %71, %.lr.ph103 ]
  %65 = getelementptr inbounds i32, ptr @ord, i64 %.pre-phi184
  tail call void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef nonnull @ord, ptr noundef nonnull %65, ptr noundef nonnull @_Z3cmpRKiS0_)
  %66 = load i32, ptr @n, align 4, !tbaa !5
  %67 = icmp sgt i32 %66, 0
  br i1 %67, label %.preheader, label %._crit_edge113

.lr.ph103:                                        ; preds = %.preheader87, %.lr.ph103
  %indvars.iv148 = phi i64 [ %indvars.iv.next149, %.lr.ph103 ], [ 0, %.preheader87 ]
  %68 = getelementptr inbounds [2001 x i32], ptr @x, i64 0, i64 %indvars.iv148
  %69 = getelementptr inbounds [2001 x i32], ptr @y, i64 0, i64 %indvars.iv148
  tail 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) %68, ptr noundef nonnull align 4 dereferenceable(4) %69) #8
  %indvars.iv.next149 = add nuw nsw i64 %indvars.iv148, 1
  %70 = load i32, ptr @n, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = icmp slt i64 %indvars.iv.next149, %71
  br i1 %72, label %.lr.ph103, label %._crit_edge104, !llvm.loop !15

.loopexit86.loopexit:                             ; preds = %.loopexit
  %.pre179 = load i32, ptr @n, align 4, !tbaa !5
  br label %.loopexit86

.loopexit86:                                      ; preds = %.loopexit86.loopexit, %.critedge2
  %73 = phi i32 [ %.pre179, %.loopexit86.loopexit ], [ %75, %.critedge2 ]
  %74 = icmp slt i32 %.1.lcssa, %73
  br i1 %74, label %.preheader, label %._crit_edge113, !llvm.loop !16

.preheader:                                       ; preds = %._crit_edge104, %.loopexit86
  %75 = phi i32 [ %73, %.loopexit86 ], [ %66, %._crit_edge104 ]
  %.072112 = phi i32 [ %.1.lcssa, %.loopexit86 ], [ 0, %._crit_edge104 ]
  %76 = sext i32 %.072112 to i64
  %77 = getelementptr inbounds [2001 x i32], ptr @ord, i64 0, i64 %76
  %78 = load i32, ptr %77, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [2001 x i32], ptr @x, i64 0, i64 %79
  %81 = load i32, ptr %80, align 4, !tbaa !5
  %82 = sext i32 %75 to i64
  %83 = add nsw i32 %.072112, 1
  %smax153 = tail call i32 @llvm.smax.i32(i32 %75, i32 %83)
  br label %86

._crit_edge113:                                   ; preds = %.loopexit86, %._crit_edge104
  %.lcssa91 = phi i32 [ %66, %._crit_edge104 ], [ %73, %.loopexit86 ]
  %84 = shl i32 %.lcssa91, 1
  store i32 %84, ptr @n, align 4, !tbaa !5
  store i32 0, ptr @tot, align 4, !tbaa !5
  %85 = icmp sgt i32 %84, 0
  br i1 %85, label %.lr.ph117, label %._crit_edge118.thread

._crit_edge118.thread:                            ; preds = %._crit_edge113
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(8004) @scc, i8 -1, i64 8004, i1 false)
  br label %._crit_edge124

86:                                               ; preds = %.preheader, %93
  %indvars.iv151 = phi i64 [ %76, %.preheader ], [ %indvars.iv.next152, %93 ]
  %87 = getelementptr inbounds [2001 x i32], ptr @ord, i64 0, i64 %indvars.iv151
  %88 = load i32, ptr %87, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [2001 x i32], ptr @x, i64 0, i64 %89
  %91 = load i32, ptr %90, align 4, !tbaa !5
  %92 = icmp eq i32 %81, %91
  br i1 %92, label %93, label %.critedge2.split.loop.exit193

93:                                               ; preds = %86
  %indvars.iv.next152 = add nsw i64 %indvars.iv151, 1
  %94 = icmp slt i64 %indvars.iv.next152, %82
  br i1 %94, label %86, label %.critedge2, !llvm.loop !17

.critedge2.split.loop.exit193:                    ; preds = %86
  %95 = trunc nsw i64 %indvars.iv151 to i32
  br label %.critedge2

.critedge2:                                       ; preds = %93, %.critedge2.split.loop.exit193
  %.1.lcssa = phi i32 [ %95, %.critedge2.split.loop.exit193 ], [ %smax153, %93 ]
  %96 = icmp slt i32 %.072112, %.1.lcssa
  br i1 %96, label %.lr.ph111.preheader, label %.loopexit86

.lr.ph111.preheader:                              ; preds = %.critedge2
  %97 = sext i32 %.1.lcssa to i64
  br label %.lr.ph111

.loopexit:                                        ; preds = %120, %.lr.ph111
  %exitcond164.not = icmp eq i64 %indvars.iv.next161, %97
  br i1 %exitcond164.not, label %.loopexit86.loopexit, label %.lr.ph111, !llvm.loop !18

.lr.ph111:                                        ; preds = %.lr.ph111.preheader, %.loopexit
  %indvars.iv160 = phi i64 [ %76, %.lr.ph111.preheader ], [ %indvars.iv.next161, %.loopexit ]
  %indvars.iv155.in = phi i64 [ %76, %.lr.ph111.preheader ], [ %indvars.iv155, %.loopexit ]
  %indvars.iv155 = add nsw i64 %indvars.iv155.in, 1
  %indvars.iv.next161 = add nsw i64 %indvars.iv160, 1
  %98 = icmp slt i64 %indvars.iv.next161, %97
  br i1 %98, label %.lr.ph109, label %.loopexit

.lr.ph109:                                        ; preds = %.lr.ph111
  %99 = getelementptr inbounds [2001 x i32], ptr @ord, i64 0, i64 %indvars.iv160
  %.pre178 = load i32, ptr @q, align 4, !tbaa !5
  br label %100

100:                                              ; preds = %.lr.ph109, %120
  %101 = phi i32 [ %.pre178, %.lr.ph109 ], [ %121, %120 ]
  %indvars.iv157 = phi i64 [ %indvars.iv155, %.lr.ph109 ], [ %indvars.iv.next158, %120 ]
  %102 = getelementptr inbounds [2001 x i32], ptr @ord, i64 0, i64 %indvars.iv157
  %103 = load i32, ptr %102, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [2001 x i32], ptr @y, i64 0, i64 %104
  %106 = load i32, ptr %105, align 4, !tbaa !5
  %107 = load i32, ptr %99, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [2001 x i32], ptr @y, i64 0, i64 %108
  %110 = load i32, ptr %109, align 4, !tbaa !5
  %111 = sub nsw i32 %106, %110
  %112 = shl i32 %101, 1
  %.not = icmp sgt i32 %111, %112
  br i1 %.not, label %120, label %113

113:                                              ; preds = %100
  %114 = load i32, ptr @n, align 4, !tbaa !5
  %115 = add nsw i32 %114, %107
  tail call void @_Z7addEdgeii(i32 noundef %103, i32 noundef %115)
  %116 = load i32, ptr %99, align 4, !tbaa !5
  %117 = load i32, ptr @n, align 4, !tbaa !5
  %118 = load i32, ptr %102, align 4, !tbaa !5
  %119 = add nsw i32 %118, %117
  tail call void @_Z7addEdgeii(i32 noundef %116, i32 noundef %119)
  %.pre177 = load i32, ptr @q, align 4, !tbaa !5
  br label %120

120:                                              ; preds = %100, %113
  %121 = phi i32 [ %101, %100 ], [ %.pre177, %113 ]
  %indvars.iv.next158 = add nsw i64 %indvars.iv157, 1
  %122 = icmp slt i64 %indvars.iv.next158, %97
  br i1 %122, label %100, label %.loopexit, !llvm.loop !19

._crit_edge118:                                   ; preds = %131
  store i32 0, ptr @tot, align 4, !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(8004) @scc, i8 -1, i64 8004, i1 false)
  %123 = icmp sgt i32 %132, 0
  br i1 %123, label %.lr.ph123.preheader, label %._crit_edge124

.lr.ph123.preheader:                              ; preds = %._crit_edge118
  %124 = zext nneg i32 %132 to i64
  br label %.lr.ph123

.lr.ph117:                                        ; preds = %._crit_edge113, %131
  %125 = phi i32 [ %132, %131 ], [ %84, %._crit_edge113 ]
  %indvars.iv165 = phi i64 [ %indvars.iv.next166, %131 ], [ 0, %._crit_edge113 ]
  %126 = getelementptr inbounds [2001 x i8], ptr @vis, i64 0, i64 %indvars.iv165
  %127 = load i8, ptr %126, align 1, !tbaa !20, !range !22, !noundef !23
  %128 = trunc nuw i8 %127 to i1
  br i1 %128, label %131, label %129

129:                                              ; preds = %.lr.ph117
  %130 = trunc nuw nsw i64 %indvars.iv165 to i32
  tail call void @_Z4dfs1i(i32 noundef %130)
  %.pre180 = load i32, ptr @n, align 4, !tbaa !5
  br label %131

131:                                              ; preds = %.lr.ph117, %129
  %132 = phi i32 [ %125, %.lr.ph117 ], [ %.pre180, %129 ]
  %indvars.iv.next166 = add nuw nsw i64 %indvars.iv165, 1
  %133 = sext i32 %132 to i64
  %134 = icmp slt i64 %indvars.iv.next166, %133
  br i1 %134, label %.lr.ph117, label %._crit_edge118, !llvm.loop !24

._crit_edge124.loopexit:                          ; preds = %160
  %.pre181 = load i32, ptr @n, align 4, !tbaa !5
  br label %._crit_edge124

._crit_edge124:                                   ; preds = %._crit_edge118.thread, %._crit_edge124.loopexit, %._crit_edge118
  %135 = phi i32 [ %.pre181, %._crit_edge124.loopexit ], [ %132, %._crit_edge118 ], [ %84, %._crit_edge118.thread ]
  %136 = ashr i32 %135, 1
  store i32 %136, ptr @n, align 4, !tbaa !5
  %137 = icmp sgt i32 %136, 0
  br i1 %137, label %.lr.ph128.preheader, label %._crit_edge129

.lr.ph128.preheader:                              ; preds = %._crit_edge124
  %138 = zext nneg i32 %136 to i64
  %min.iters.check = icmp ult i32 %136, 8
  br i1 %min.iters.check, label %.lr.ph128.preheader206, label %vector.ph

.lr.ph128.preheader206:                           ; preds = %middle.block, %.lr.ph128.preheader
  %indvars.iv171.ph = phi i64 [ 0, %.lr.ph128.preheader ], [ %n.vec, %middle.block ]
  %.067125.ph = phi i1 [ true, %.lr.ph128.preheader ], [ %150, %middle.block ]
  br label %.lr.ph128

vector.ph:                                        ; preds = %.lr.ph128.preheader
  %n.vec = and i64 %138, 2147483640
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <4 x i1> [ <i1 true, i1 true, i1 true, i1 true>, %vector.ph ], [ %146, %vector.body ]
  %vec.phi202 = phi <4 x i1> [ <i1 true, i1 true, i1 true, i1 true>, %vector.ph ], [ %147, %vector.body ]
  %139 = getelementptr inbounds [2001 x i32], ptr @scc, i64 0, i64 %index
  %140 = getelementptr inbounds i8, ptr %139, i64 16
  %wide.load = load <4 x i32>, ptr %139, align 16, !tbaa !5
  %wide.load203 = load <4 x i32>, ptr %140, align 16, !tbaa !5
  %141 = add nuw nsw i64 %index, %138
  %142 = getelementptr inbounds [2001 x i32], ptr @scc, i64 0, i64 %141
  %143 = getelementptr inbounds i8, ptr %142, i64 16
  %wide.load204 = load <4 x i32>, ptr %142, align 4, !tbaa !5
  %wide.load205 = load <4 x i32>, ptr %143, align 4, !tbaa !5
  %144 = icmp ne <4 x i32> %wide.load, %wide.load204
  %145 = icmp ne <4 x i32> %wide.load203, %wide.load205
  %146 = and <4 x i1> %vec.phi, %144
  %147 = and <4 x i1> %vec.phi202, %145
  %index.next = add nuw i64 %index, 8
  %148 = icmp eq i64 %index.next, %n.vec
  br i1 %148, label %middle.block, label %vector.body, !llvm.loop !25

middle.block:                                     ; preds = %vector.body
  %bin.rdx = and <4 x i1> %147, %146
  %149 = bitcast <4 x i1> %bin.rdx to i4
  %150 = icmp eq i4 %149, -1
  %cmp.n = icmp eq i64 %n.vec, %138
  br i1 %cmp.n, label %._crit_edge129.loopexit, label %.lr.ph128.preheader206

.lr.ph123:                                        ; preds = %.lr.ph123.preheader, %160
  %indvars.iv168 = phi i64 [ %124, %.lr.ph123.preheader ], [ %indvars.iv.next169, %160 ]
  %indvars.iv.next169 = add nsw i64 %indvars.iv168, -1
  %151 = getelementptr inbounds [2001 x i32], ptr @seq, i64 0, i64 %indvars.iv.next169
  %152 = load i32, ptr %151, align 4, !tbaa !5
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds [2001 x i32], ptr @scc, i64 0, i64 %153
  %155 = load i32, ptr %154, align 4, !tbaa !5
  %156 = icmp eq i32 %155, -1
  br i1 %156, label %157, label %160

157:                                              ; preds = %.lr.ph123
  tail call void @_Z4dfs2i(i32 noundef %152)
  %158 = load i32, ptr @tot, align 4, !tbaa !5
  %159 = add nsw i32 %158, 1
  store i32 %159, ptr @tot, align 4, !tbaa !5
  br label %160

160:                                              ; preds = %.lr.ph123, %157
  %161 = icmp ugt i64 %indvars.iv168, 1
  br i1 %161, label %.lr.ph123, label %._crit_edge124.loopexit, !llvm.loop !28

._crit_edge129.loopexit:                          ; preds = %.lr.ph128, %middle.block
  %.lcssa = phi i1 [ %150, %middle.block ], [ %170, %.lr.ph128 ]
  %162 = select i1 %.lcssa, ptr @.str.2, ptr @.str.3
  br label %._crit_edge129

._crit_edge129:                                   ; preds = %._crit_edge129.loopexit, %._crit_edge124
  %.067.lcssa = phi ptr [ @.str.2, %._crit_edge124 ], [ %162, %._crit_edge129.loopexit ]
  %163 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) %.067.lcssa)
  ret i32 0

.lr.ph128:                                        ; preds = %.lr.ph128.preheader206, %.lr.ph128
  %indvars.iv171 = phi i64 [ %indvars.iv.next172, %.lr.ph128 ], [ %indvars.iv171.ph, %.lr.ph128.preheader206 ]
  %.067125 = phi i1 [ %170, %.lr.ph128 ], [ %.067125.ph, %.lr.ph128.preheader206 ]
  %164 = getelementptr inbounds [2001 x i32], ptr @scc, i64 0, i64 %indvars.iv171
  %165 = load i32, ptr %164, align 4, !tbaa !5
  %166 = add nuw nsw i64 %indvars.iv171, %138
  %167 = getelementptr inbounds [2001 x i32], ptr @scc, i64 0, i64 %166
  %168 = load i32, ptr %167, align 4, !tbaa !5
  %169 = icmp ne i32 %165, %168
  %170 = and i1 %.067125, %169
  %indvars.iv.next172 = add nuw nsw i64 %indvars.iv171, 1
  %exitcond174.not = icmp eq i64 %indvars.iv.next172, %138
  br i1 %exitcond174.not, label %._crit_edge129.loopexit, label %.lr.ph128, !llvm.loop !29
}

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

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

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

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #7

attributes #0 = { 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 #1 = { 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 #2 = { 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 #3 = { 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 #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #7 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = distinct !{!17, !10}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}
!20 = !{!21, !21, i64 0}
!21 = !{!"bool", !7, i64 0}
!22 = !{i8 0, i8 2}
!23 = !{}
!24 = distinct !{!24, !10}
!25 = distinct !{!25, !10, !26, !27}
!26 = !{!"llvm.loop.isvectorized", i32 1}
!27 = !{!"llvm.loop.unroll.runtime.disable"}
!28 = distinct !{!28, !10}
!29 = distinct !{!29, !10, !27, !26}


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