; LLVM IR from tangjz/acm-icpc :: hdu/4673.ll (Z4calci)

; 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
@S = external dso_local global i32, align 4
@T = external dso_local global i32, align 4
@lnk = external dso_local global [3003 x i32], align 16
@cur = external dso_local global [3003 x i32], align 16
@n = external dso_local global i32, align 4
@a = external dso_local global [30001 x i32], align 16
@b = external dso_local global [30001 x i32], align 16
@d = external dso_local global [30001 x i32], align 16
@sz = external dso_local global [1001 x i32], align 16
@typ = external dso_local global [1001 x [3 x i32]], align 16
@cst = external dso_local global [1001 x [3 x i32]], align 16
@va = external dso_local global [30001 x i8], align 16
@vb = external dso_local global [30001 x i8], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z7addEdgeiii(i32 noundef, 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3bfsv() #0

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z3dfsii(i32 noundef, i32 noundef) #4

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z4calci(i32 noundef %0) #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
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 16 @lnk, i8 -1, i64 12012, i1 false)
  store i32 2002, ptr @N, align 4, !tbaa !5
  store i32 0, ptr @M, align 4, !tbaa !5
  store i32 0, ptr @S, align 4, !tbaa !5
  %10 = load i32, ptr @N, align 4, !tbaa !5
  %11 = sub nsw i32 %10, 1
  store i32 %11, ptr @T, align 4, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 16 @va, i8 0, i64 30001, i1 false)
  call void @llvm.memset.p0.i64(ptr align 16 @vb, i8 0, i64 30001, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %182, %1
  %13 = load i32, ptr %3, align 4, !tbaa !5
  %14 = load i32, ptr %2, align 4, !tbaa !5
  %15 = icmp slt i32 %13, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %12
  store i32 2, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %185

17:                                               ; preds = %12
  %18 = load i32, ptr %3, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [1001 x i32], ptr @sz, i64 0, i64 %19
  %21 = load i32, ptr %20, align 4, !tbaa !5
  %22 = icmp eq i32 %21, 1
  br i1 %22, label %23, label %57

23:                                               ; preds = %17
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [1001 x [3 x i32]], ptr @typ, i64 0, i64 %25
  %27 = getelementptr inbounds [3 x i32], ptr %26, i64 0, i64 0
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %29 = icmp slt i32 %28, 0
  br i1 %29, label %30, label %43

30:                                               ; preds = %23
  %31 = load i32, ptr @S, align 4, !tbaa !5
  %32 = load i32, ptr %3, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [1001 x [3 x i32]], ptr @typ, i64 0, i64 %33
  %35 = getelementptr inbounds [3 x i32], ptr %34, i64 0, i64 0
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = sub nsw i32 0, %36
  %38 = load i32, ptr %3, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [1001 x [3 x i32]], ptr @cst, i64 0, i64 %39
  %41 = getelementptr inbounds [3 x i32], ptr %40, i64 0, i64 0
  %42 = load i32, ptr %41, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %31, i32 noundef %37, i32 noundef %42)
  br label %56

43:                                               ; preds = %23
  %44 = load i32, ptr %3, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [1001 x [3 x i32]], ptr @typ, i64 0, i64 %45
  %47 = getelementptr inbounds [3 x i32], ptr %46, i64 0, i64 0
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = add nsw i32 1000, %48
  %50 = load i32, ptr @T, align 4, !tbaa !5
  %51 = load i32, ptr %3, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [1001 x [3 x i32]], ptr @cst, i64 0, i64 %52
  %54 = getelementptr inbounds [3 x i32], ptr %53, i64 0, i64 0
  %55 = load i32, ptr %54, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %49, i32 noundef %50, i32 noundef %55)
  br label %56

56:                                               ; preds = %43, %30
  br label %138

57:                                               ; preds = %17
  %58 = load i32, ptr %3, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [1001 x i32], ptr @sz, i64 0, i64 %59
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = icmp eq i32 %61, 2
  br i1 %62, label %63, label %137

63:                                               ; preds = %57
  %64 = load i32, ptr %3, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [1001 x [3 x i32]], ptr @typ, i64 0, i64 %65
  %67 = getelementptr inbounds [3 x i32], ptr %66, i64 0, i64 0
  %68 = load i32, ptr %67, align 4, !tbaa !5
  %69 = icmp slt i32 %68, 0
  br i1 %69, label %70, label %102

70:                                               ; preds = %63
  %71 = load i32, ptr @S, align 4, !tbaa !5
  %72 = load i32, ptr @N, align 4, !tbaa !5
  %73 = load i32, ptr %3, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [1001 x [3 x i32]], ptr @cst, i64 0, i64 %74
  %76 = getelementptr inbounds [3 x i32], ptr %75, i64 0, i64 2
  %77 = load i32, ptr %76, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %71, i32 noundef %72, i32 noundef %77)
  %78 = load i32, ptr @N, align 4, !tbaa !5
  %79 = load i32, ptr %3, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [1001 x [3 x i32]], ptr @typ, i64 0, i64 %80
  %82 = getelementptr inbounds [3 x i32], ptr %81, i64 0, i64 0
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = sub nsw i32 0, %83
  %85 = load i32, ptr %3, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [1001 x [3 x i32]], ptr @cst, i64 0, i64 %86
  %88 = getelementptr inbounds [3 x i32], ptr %87, i64 0, i64 0
  %89 = load i32, ptr %88, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %78, i32 noundef %84, i32 noundef %89)
  %90 = load i32, ptr @N, align 4, !tbaa !5
  %91 = load i32, ptr %3, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [1001 x [3 x i32]], ptr @typ, i64 0, i64 %92
  %94 = getelementptr inbounds [3 x i32], ptr %93, i64 0, i64 1
  %95 = load i32, ptr %94, align 4, !tbaa !5
  %96 = sub nsw i32 0, %95
  %97 = load i32, ptr %3, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [1001 x [3 x i32]], ptr @cst, i64 0, i64 %98
  %100 = getelementptr inbounds [3 x i32], ptr %99, i64 0, i64 1
  %101 = load i32, ptr %100, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %90, i32 noundef %96, i32 noundef %101)
  br label %134

102:                                              ; preds = %63
  %103 = load i32, ptr %3, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [1001 x [3 x i32]], ptr @typ, i64 0, i64 %104
  %106 = getelementptr inbounds [3 x i32], ptr %105, i64 0, i64 0
  %107 = load i32, ptr %106, align 4, !tbaa !5
  %108 = add nsw i32 1000, %107
  %109 = load i32, ptr @N, align 4, !tbaa !5
  %110 = load i32, ptr %3, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [1001 x [3 x i32]], ptr @cst, i64 0, i64 %111
  %113 = getelementptr inbounds [3 x i32], ptr %112, i64 0, i64 0
  %114 = load i32, ptr %113, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %108, i32 noundef %109, i32 noundef %114)
  %115 = load i32, ptr %3, align 4, !tbaa !5
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds [1001 x [3 x i32]], ptr @typ, i64 0, i64 %116
  %118 = getelementptr inbounds [3 x i32], ptr %117, i64 0, i64 1
  %119 = load i32, ptr %118, align 4, !tbaa !5
  %120 = add nsw i32 1000, %119
  %121 = load i32, ptr @N, align 4, !tbaa !5
  %122 = load i32, ptr %3, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds [1001 x [3 x i32]], ptr @cst, i64 0, i64 %123
  %125 = getelementptr inbounds [3 x i32], ptr %124, i64 0, i64 1
  %126 = load i32, ptr %125, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %120, i32 noundef %121, i32 noundef %126)
  %127 = load i32, ptr @N, align 4, !tbaa !5
  %128 = load i32, ptr @T, align 4, !tbaa !5
  %129 = load i32, ptr %3, align 4, !tbaa !5
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds [1001 x [3 x i32]], ptr @cst, i64 0, i64 %130
  %132 = getelementptr inbounds [3 x i32], ptr %131, i64 0, i64 2
  %133 = load i32, ptr %132, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %127, i32 noundef %128, i32 noundef %133)
  br label %134

134:                                              ; preds = %102, %70
  %135 = load i32, ptr @N, align 4, !tbaa !5
  %136 = add nsw i32 %135, 1
  store i32 %136, ptr @N, align 4, !tbaa !5
  br label %137

137:                                              ; preds = %134, %57
  br label %138

138:                                              ; preds = %137, %56
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %139

139:                                              ; preds = %178, %138
  %140 = load i32, ptr %5, align 4, !tbaa !5
  %141 = load i32, ptr %3, align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [1001 x i32], ptr @sz, i64 0, i64 %142
  %144 = load i32, ptr %143, align 4, !tbaa !5
  %145 = icmp slt i32 %140, %144
  br i1 %145, label %147, label %146

146:                                              ; preds = %139
  store i32 5, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %181

147:                                              ; preds = %139
  %148 = load i32, ptr %3, align 4, !tbaa !5
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds [1001 x [3 x i32]], ptr @typ, i64 0, i64 %149
  %151 = load i32, ptr %5, align 4, !tbaa !5
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds [3 x i32], ptr %150, i64 0, i64 %152
  %154 = load i32, ptr %153, align 4, !tbaa !5
  %155 = icmp slt i32 %154, 0
  br i1 %155, label %156, label %167

156:                                              ; preds = %147
  %157 = load i32, ptr %3, align 4, !tbaa !5
  %158 = sext i32 %157 to i64
  %159 = getelementptr inbounds [1001 x [3 x i32]], ptr @typ, i64 0, i64 %158
  %160 = load i32, ptr %5, align 4, !tbaa !5
  %161 = sext i32 %160 to i64
  %162 = getelementptr inbounds [3 x i32], ptr %159, i64 0, i64 %161
  %163 = load i32, ptr %162, align 4, !tbaa !5
  %164 = sub nsw i32 0, %163
  %165 = sext i32 %164 to i64
  %166 = getelementptr inbounds [30001 x i8], ptr @va, i64 0, i64 %165
  store i8 1, ptr %166, align 1, !tbaa !9
  br label %177

167:                                              ; preds = %147
  %168 = load i32, ptr %3, align 4, !tbaa !5
  %169 = sext i32 %168 to i64
  %170 = getelementptr inbounds [1001 x [3 x i32]], ptr @typ, i64 0, i64 %169
  %171 = load i32, ptr %5, align 4, !tbaa !5
  %172 = sext i32 %171 to i64
  %173 = getelementptr inbounds [3 x i32], ptr %170, i64 0, i64 %172
  %174 = load i32, ptr %173, align 4, !tbaa !5
  %175 = sext i32 %174 to i64
  %176 = getelementptr inbounds [30001 x i8], ptr @vb, i64 0, i64 %175
  store i8 1, ptr %176, align 1, !tbaa !9
  br label %177

177:                                              ; preds = %167, %156
  br label %178

178:                                              ; preds = %177
  %179 = load i32, ptr %5, align 4, !tbaa !5
  %180 = add nsw i32 %179, 1
  store i32 %180, ptr %5, align 4, !tbaa !5
  br label %139, !llvm.loop !11

181:                                              ; preds = %146
  br label %182

182:                                              ; preds = %181
  %183 = load i32, ptr %3, align 4, !tbaa !5
  %184 = add nsw i32 %183, 1
  store i32 %184, ptr %3, align 4, !tbaa !5
  br label %12, !llvm.loop !13

185:                                              ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %186

186:                                              ; preds = %210, %185
  %187 = load i32, ptr %6, align 4, !tbaa !5
  %188 = icmp sle i32 %187, 1000
  br i1 %188, label %190, label %189

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

190:                                              ; preds = %186
  %191 = load i32, ptr %6, align 4, !tbaa !5
  %192 = sext i32 %191 to i64
  %193 = getelementptr inbounds [30001 x i8], ptr @va, i64 0, i64 %192
  %194 = load i8, ptr %193, align 1, !tbaa !9, !range !14, !noundef !15
  %195 = trunc i8 %194 to i1
  br i1 %195, label %199, label %196

196:                                              ; preds = %190
  %197 = load i32, ptr @S, align 4, !tbaa !5
  %198 = load i32, ptr %6, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %197, i32 noundef %198, i32 noundef 1061109567)
  br label %199

199:                                              ; preds = %196, %190
  %200 = load i32, ptr %6, align 4, !tbaa !5
  %201 = sext i32 %200 to i64
  %202 = getelementptr inbounds [30001 x i8], ptr @vb, i64 0, i64 %201
  %203 = load i8, ptr %202, align 1, !tbaa !9, !range !14, !noundef !15
  %204 = trunc i8 %203 to i1
  br i1 %204, label %209, label %205

205:                                              ; preds = %199
  %206 = load i32, ptr %6, align 4, !tbaa !5
  %207 = add nsw i32 1000, %206
  %208 = load i32, ptr @T, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %207, i32 noundef %208, i32 noundef 1061109567)
  br label %209

209:                                              ; preds = %205, %199
  br label %210

210:                                              ; preds = %209
  %211 = load i32, ptr %6, align 4, !tbaa !5
  %212 = add nsw i32 %211, 1
  store i32 %212, ptr %6, align 4, !tbaa !5
  br label %186, !llvm.loop !16

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

214:                                              ; preds = %233, %213
  %215 = load i32, ptr %7, align 4, !tbaa !5
  %216 = load i32, ptr @n, align 4, !tbaa !5
  %217 = icmp slt i32 %215, %216
  br i1 %217, label %219, label %218

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

219:                                              ; preds = %214
  %220 = load i32, ptr %7, align 4, !tbaa !5
  %221 = sext i32 %220 to i64
  %222 = getelementptr inbounds [30001 x i32], ptr @a, i64 0, i64 %221
  %223 = load i32, ptr %222, align 4, !tbaa !5
  %224 = load i32, ptr %7, align 4, !tbaa !5
  %225 = sext i32 %224 to i64
  %226 = getelementptr inbounds [30001 x i32], ptr @b, i64 0, i64 %225
  %227 = load i32, ptr %226, align 4, !tbaa !5
  %228 = add nsw i32 1000, %227
  %229 = load i32, ptr %7, align 4, !tbaa !5
  %230 = sext i32 %229 to i64
  %231 = getelementptr inbounds [30001 x i32], ptr @d, i64 0, i64 %230
  %232 = load i32, ptr %231, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %223, i32 noundef %228, i32 noundef %232)
  br label %233

233:                                              ; preds = %219
  %234 = load i32, ptr %7, align 4, !tbaa !5
  %235 = add nsw i32 %234, 1
  store i32 %235, ptr %7, align 4, !tbaa !5
  br label %214, !llvm.loop !17

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

237:                                              ; preds = %252, %236
  %238 = call noundef zeroext i1 @_Z3bfsv()
  br i1 %238, label %239, label %253

239:                                              ; preds = %237
  %240 = load i32, ptr @N, align 4, !tbaa !5
  %241 = sext i32 %240 to i64
  %242 = mul i64 %241, 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 @cur, ptr align 16 @lnk, i64 %242, i1 false)
  br label %243

243:                                              ; preds = %248, %239
  %244 = load i32, ptr @S, align 4, !tbaa !5
  %245 = call noundef i32 @_Z3dfsii(i32 noundef %244, i32 noundef 1061109567)
  store i32 %245, ptr %9, align 4, !tbaa !5
  %246 = icmp sgt i32 %245, 0
  br i1 %246, label %247, label %252

247:                                              ; preds = %243
  br label %248

248:                                              ; preds = %247
  %249 = load i32, ptr %9, align 4, !tbaa !5
  %250 = load i32, ptr %8, align 4, !tbaa !5
  %251 = add nsw i32 %250, %249
  store i32 %251, ptr %8, align 4, !tbaa !5
  br label %243, !llvm.loop !18

252:                                              ; preds = %243
  br label %237, !llvm.loop !19

253:                                              ; preds = %237
  %254 = load i32, ptr %8, align 4, !tbaa !5
  store i32 1, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  ret i32 %254
}

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 = { nounwind }

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

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


; 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 local_unnamed_addr global i32, align 4
@M = external dso_local local_unnamed_addr global i32, align 4
@S = external dso_local local_unnamed_addr global i32, align 4
@T = external dso_local local_unnamed_addr global i32, align 4
@lnk = external dso_local local_unnamed_addr global [3003 x i32], align 16
@cur = external dso_local local_unnamed_addr global [3003 x i32], align 16
@n = external dso_local local_unnamed_addr global i32, align 4
@a = external dso_local local_unnamed_addr global [30001 x i32], align 16
@b = external dso_local local_unnamed_addr global [30001 x i32], align 16
@d = external dso_local local_unnamed_addr global [30001 x i32], align 16
@sz = external dso_local local_unnamed_addr global [1001 x i32], align 16
@typ = external dso_local local_unnamed_addr global [1001 x [3 x i32]], align 16
@cst = external dso_local local_unnamed_addr global [1001 x [3 x i32]], align 16
@va = external dso_local local_unnamed_addr global [30001 x i8], align 16
@vb = external dso_local local_unnamed_addr global [30001 x i8], align 16

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

; Function Attrs: mustprogress 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) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3bfsv() local_unnamed_addr #0

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z3dfsii(i32 noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, -2147483648) i32 @_Z4calci(i32 noundef %0) local_unnamed_addr #3 {
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(12012) @lnk, i8 -1, i64 12012, i1 false)
  store i32 2002, ptr @N, align 4, !tbaa !5
  store i32 0, ptr @M, align 4, !tbaa !5
  store i32 0, ptr @S, align 4, !tbaa !5
  store i32 2001, ptr @T, align 4, !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(30001) @va, i8 0, i64 30001, i1 false)
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(30001) @vb, i8 0, i64 30001, i1 false)
  %2 = icmp sgt i32 %0, 0
  br i1 %2, label %.lr.ph60.preheader, label %.preheader56.preheader

.preheader56.preheader:                           ; preds = %._crit_edge, %1
  br label %.preheader56

.lr.ph60.preheader:                               ; preds = %1
  %wide.trip.count71 = zext nneg i32 %0 to i64
  br label %.lr.ph60

.lr.ph60:                                         ; preds = %.lr.ph60.preheader, %._crit_edge
  %indvars.iv68 = phi i64 [ 0, %.lr.ph60.preheader ], [ %indvars.iv.next69, %._crit_edge ]
  %3 = getelementptr inbounds [1001 x i32], ptr @sz, i64 0, i64 %indvars.iv68
  %4 = load i32, ptr %3, align 4, !tbaa !5
  switch i32 %4, label %53 [
    i32 1, label %5
    i32 2, label %17
  ]

5:                                                ; preds = %.lr.ph60
  %6 = getelementptr inbounds [1001 x [3 x i32]], ptr @typ, i64 0, i64 %indvars.iv68
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %8 = icmp slt i32 %7, 0
  %9 = getelementptr inbounds [1001 x [3 x i32]], ptr @cst, i64 0, i64 %indvars.iv68
  %10 = load i32, ptr %9, align 4, !tbaa !5
  br i1 %8, label %11, label %14

11:                                               ; preds = %5
  %12 = load i32, ptr @S, align 4, !tbaa !5
  %13 = sub nsw i32 0, %7
  tail call void @_Z7addEdgeiii(i32 noundef %12, i32 noundef %13, i32 noundef %10)
  br label %thread-pre-split

14:                                               ; preds = %5
  %15 = add nuw nsw i32 %7, 1000
  %16 = load i32, ptr @T, align 4, !tbaa !5
  tail call void @_Z7addEdgeiii(i32 noundef %15, i32 noundef %16, i32 noundef %10)
  br label %thread-pre-split

17:                                               ; preds = %.lr.ph60
  %18 = getelementptr inbounds [1001 x [3 x i32]], ptr @typ, i64 0, i64 %indvars.iv68
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = icmp slt i32 %19, 0
  %21 = load i32, ptr @N, align 4, !tbaa !5
  %22 = getelementptr inbounds [1001 x [3 x i32]], ptr @cst, i64 0, i64 %indvars.iv68
  br i1 %20, label %23, label %37

23:                                               ; preds = %17
  %24 = load i32, ptr @S, align 4, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %22, i64 8
  %26 = load i32, ptr %25, align 4, !tbaa !5
  tail call void @_Z7addEdgeiii(i32 noundef %24, i32 noundef %21, i32 noundef %26)
  %27 = load i32, ptr @N, align 4, !tbaa !5
  %28 = load i32, ptr %18, align 4, !tbaa !5
  %29 = sub nsw i32 0, %28
  %30 = load i32, ptr %22, align 4, !tbaa !5
  tail call void @_Z7addEdgeiii(i32 noundef %27, i32 noundef %29, i32 noundef %30)
  %31 = load i32, ptr @N, align 4, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %18, i64 4
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %34 = sub nsw i32 0, %33
  %35 = getelementptr inbounds i8, ptr %22, i64 4
  %36 = load i32, ptr %35, align 4, !tbaa !5
  tail call void @_Z7addEdgeiii(i32 noundef %31, i32 noundef %34, i32 noundef %36)
  br label %50

37:                                               ; preds = %17
  %38 = add nuw nsw i32 %19, 1000
  %39 = load i32, ptr %22, align 4, !tbaa !5
  tail call void @_Z7addEdgeiii(i32 noundef %38, i32 noundef %21, i32 noundef %39)
  %40 = getelementptr inbounds i8, ptr %18, i64 4
  %41 = load i32, ptr %40, align 4, !tbaa !5
  %42 = add nsw i32 %41, 1000
  %43 = load i32, ptr @N, align 4, !tbaa !5
  %44 = getelementptr inbounds i8, ptr %22, i64 4
  %45 = load i32, ptr %44, align 4, !tbaa !5
  tail call void @_Z7addEdgeiii(i32 noundef %42, i32 noundef %43, i32 noundef %45)
  %46 = load i32, ptr @N, align 4, !tbaa !5
  %47 = load i32, ptr @T, align 4, !tbaa !5
  %48 = getelementptr inbounds i8, ptr %22, i64 8
  %49 = load i32, ptr %48, align 4, !tbaa !5
  tail call void @_Z7addEdgeiii(i32 noundef %46, i32 noundef %47, i32 noundef %49)
  br label %50

50:                                               ; preds = %37, %23
  %51 = load i32, ptr @N, align 4, !tbaa !5
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr @N, align 4, !tbaa !5
  br label %thread-pre-split

thread-pre-split:                                 ; preds = %14, %11, %50
  %.pr = load i32, ptr %3, align 4, !tbaa !5
  br label %53

53:                                               ; preds = %thread-pre-split, %.lr.ph60
  %54 = phi i32 [ %.pr, %thread-pre-split ], [ %4, %.lr.ph60 ]
  %55 = icmp sgt i32 %54, 0
  br i1 %55, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %53
  %wide.trip.count = zext nneg i32 %54 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %56 = icmp eq i32 %54, 1
  br i1 %56, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

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

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph, %.lr.ph.preheader
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next.1, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa
  %57 = getelementptr inbounds [1001 x [3 x i32]], ptr @typ, i64 0, i64 %indvars.iv68, i64 %indvars.iv.unr
  %58 = load i32, ptr %57, align 4, !tbaa !5
  %59 = icmp slt i32 %58, 0
  %.sink.epil = tail call i32 @llvm.abs.i32(i32 %58, i1 true)
  %va.sink.epil = select i1 %59, ptr @va, ptr @vb
  %60 = zext nneg i32 %.sink.epil to i64
  %61 = getelementptr inbounds [30001 x i8], ptr %va.sink.epil, i64 0, i64 %60
  store i8 1, ptr %61, align 1, !tbaa !9
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph.epil, %._crit_edge.loopexit.unr-lcssa, %53
  %indvars.iv.next69 = add nuw nsw i64 %indvars.iv68, 1
  %exitcond72.not = icmp eq i64 %indvars.iv.next69, %wide.trip.count71
  br i1 %exitcond72.not, label %.preheader56.preheader, label %.lr.ph60, !llvm.loop !11

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader.new ], [ %indvars.iv.next.1, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.1, %.lr.ph ]
  %62 = getelementptr inbounds [1001 x [3 x i32]], ptr @typ, i64 0, i64 %indvars.iv68, i64 %indvars.iv
  %63 = load i32, ptr %62, align 4, !tbaa !5
  %64 = icmp slt i32 %63, 0
  %.sink = tail call i32 @llvm.abs.i32(i32 %63, i1 true)
  %va.sink = select i1 %64, ptr @va, ptr @vb
  %65 = zext nneg i32 %.sink to i64
  %66 = getelementptr inbounds [30001 x i8], ptr %va.sink, i64 0, i64 %65
  store i8 1, ptr %66, align 1, !tbaa !9
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %67 = getelementptr inbounds [1001 x [3 x i32]], ptr @typ, i64 0, i64 %indvars.iv68, i64 %indvars.iv.next
  %68 = load i32, ptr %67, align 4, !tbaa !5
  %69 = icmp slt i32 %68, 0
  %.sink.1 = tail call i32 @llvm.abs.i32(i32 %68, i1 true)
  %va.sink.1 = select i1 %69, ptr @va, ptr @vb
  %70 = zext nneg i32 %.sink.1 to i64
  %71 = getelementptr inbounds [30001 x i8], ptr %va.sink.1, i64 0, i64 %70
  store i8 1, ptr %71, align 1, !tbaa !9
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !13

.preheader55:                                     ; preds = %88
  %72 = load i32, ptr @n, align 4, !tbaa !5
  %73 = icmp sgt i32 %72, 0
  br i1 %73, label %.lr.ph63, label %.preheader

.preheader56:                                     ; preds = %.preheader56.preheader, %88
  %indvars.iv73 = phi i64 [ %indvars.iv.next74, %88 ], [ 1, %.preheader56.preheader ]
  %74 = getelementptr inbounds [30001 x i8], ptr @va, i64 0, i64 %indvars.iv73
  %75 = load i8, ptr %74, align 1, !tbaa !9, !range !14, !noundef !15
  %76 = trunc nuw i8 %75 to i1
  br i1 %76, label %80, label %77

77:                                               ; preds = %.preheader56
  %78 = load i32, ptr @S, align 4, !tbaa !5
  %79 = trunc nuw nsw i64 %indvars.iv73 to i32
  tail call void @_Z7addEdgeiii(i32 noundef %78, i32 noundef %79, i32 noundef 1061109567)
  br label %80

80:                                               ; preds = %77, %.preheader56
  %81 = getelementptr inbounds [30001 x i8], ptr @vb, i64 0, i64 %indvars.iv73
  %82 = load i8, ptr %81, align 1, !tbaa !9, !range !14, !noundef !15
  %83 = trunc nuw i8 %82 to i1
  br i1 %83, label %88, label %84

84:                                               ; preds = %80
  %85 = load i32, ptr @T, align 4, !tbaa !5
  %86 = trunc i64 %indvars.iv73 to i32
  %87 = add i32 %86, 1000
  tail call void @_Z7addEdgeiii(i32 noundef %87, i32 noundef %85, i32 noundef 1061109567)
  br label %88

88:                                               ; preds = %80, %84
  %indvars.iv.next74 = add nuw nsw i64 %indvars.iv73, 1
  %exitcond76.not = icmp eq i64 %indvars.iv.next74, 1001
  br i1 %exitcond76.not, label %.preheader55, label %.preheader56, !llvm.loop !16

.preheader:                                       ; preds = %.lr.ph63, %.preheader55
  %89 = tail call noundef zeroext i1 @_Z3bfsv()
  br i1 %89, label %.lr.ph65, label %._crit_edge66

.lr.ph63:                                         ; preds = %.preheader55, %.lr.ph63
  %indvars.iv77 = phi i64 [ %indvars.iv.next78, %.lr.ph63 ], [ 0, %.preheader55 ]
  %90 = getelementptr inbounds [30001 x i32], ptr @a, i64 0, i64 %indvars.iv77
  %91 = load i32, ptr %90, align 4, !tbaa !5
  %92 = getelementptr inbounds [30001 x i32], ptr @b, i64 0, i64 %indvars.iv77
  %93 = load i32, ptr %92, align 4, !tbaa !5
  %94 = add nsw i32 %93, 1000
  %95 = getelementptr inbounds [30001 x i32], ptr @d, i64 0, i64 %indvars.iv77
  %96 = load i32, ptr %95, align 4, !tbaa !5
  tail call void @_Z7addEdgeiii(i32 noundef %91, i32 noundef %94, i32 noundef %96)
  %indvars.iv.next78 = add nuw nsw i64 %indvars.iv77, 1
  %97 = load i32, ptr @n, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = icmp slt i64 %indvars.iv.next78, %98
  br i1 %99, label %.lr.ph63, label %.preheader, !llvm.loop !17

.loopexit:                                        ; preds = %104
  %100 = tail call noundef zeroext i1 @_Z3bfsv()
  br i1 %100, label %.lr.ph65, label %._crit_edge66, !llvm.loop !18

.lr.ph65:                                         ; preds = %.preheader, %.loopexit
  %.04464 = phi i32 [ %.1, %.loopexit ], [ 0, %.preheader ]
  %101 = load i32, ptr @N, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = shl nsw i64 %102, 2
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 @cur, ptr nonnull align 16 @lnk, i64 %103, i1 false)
  br label %104

104:                                              ; preds = %104, %.lr.ph65
  %.1 = phi i32 [ %.04464, %.lr.ph65 ], [ %108, %104 ]
  %105 = load i32, ptr @S, align 4, !tbaa !5
  %106 = tail call noundef i32 @_Z3dfsii(i32 noundef %105, i32 noundef 1061109567)
  %107 = icmp sgt i32 %106, 0
  %108 = add nuw nsw i32 %106, %.1
  br i1 %107, label %104, label %.loopexit, !llvm.loop !19

._crit_edge66:                                    ; preds = %.loopexit, %.preheader
  %.044.lcssa = phi i32 [ 0, %.preheader ], [ %.1, %.loopexit ]
  ret i32 %.044.lcssa
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

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

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


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