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

; 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
@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 [10201 x i32], align 16
@str = external dso_local global [101 x [101 x i8]], align 16
@vis = external dso_local global [10201 x i8], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [7 x i8], align 1

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

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #4 {
  %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
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  store i32 0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  store i32 0, ptr %4, align 4, !tbaa !5
  %11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m)
  %12 = load i32, ptr @n, align 4, !tbaa !5
  %13 = load i32, ptr @m, align 4, !tbaa !5
  %14 = mul nsw i32 %12, %13
  %15 = add nsw i32 %14, 2
  store i32 %15, ptr @N, align 4, !tbaa !5
  store i32 0, ptr @M, align 4, !tbaa !5
  %16 = load i32, ptr @N, align 4, !tbaa !5
  %17 = sub nsw i32 %16, 2
  store i32 %17, ptr @S, align 4, !tbaa !5
  %18 = load i32, ptr @N, align 4, !tbaa !5
  %19 = sub nsw i32 %18, 1
  store i32 %19, ptr @T, align 4, !tbaa !5
  %20 = load i32, ptr @N, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = mul i64 %21, 4
  call void @llvm.memset.p0.i64(ptr align 16 @lnk, i8 -1, i64 %22, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %163, %0
  %24 = load i32, ptr %5, align 4, !tbaa !5
  %25 = load i32, ptr @n, align 4, !tbaa !5
  %26 = icmp slt i32 %24, %25
  br i1 %26, label %28, label %27

27:                                               ; preds = %23
  store i32 2, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  br label %166

28:                                               ; preds = %23
  %29 = load i32, ptr %5, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [101 x [101 x i8]], ptr @str, i64 0, i64 %30
  %32 = getelementptr inbounds [101 x i8], ptr %31, i64 0, i64 0
  %33 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %32)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %159, %28
  %35 = load i32, ptr %7, align 4, !tbaa !5
  %36 = load i32, ptr @m, align 4, !tbaa !5
  %37 = icmp slt i32 %35, %36
  br i1 %37, label %39, label %38

38:                                               ; preds = %34
  store i32 5, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  br label %162

39:                                               ; preds = %34
  %40 = load i32, ptr %5, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [101 x [101 x i8]], ptr @str, i64 0, i64 %41
  %43 = load i32, ptr %7, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [101 x i8], ptr %42, i64 0, i64 %44
  %46 = load i8, ptr %45, align 1, !tbaa !9
  %47 = sext i8 %46 to i32
  %48 = icmp eq i32 %47, 35
  br i1 %48, label %49, label %50

49:                                               ; preds = %39
  br label %159

50:                                               ; preds = %39
  %51 = load i32, ptr %5, align 4, !tbaa !5
  %52 = and i32 %51, 1
  %53 = load i32, ptr %7, align 4, !tbaa !5
  %54 = and i32 %53, 1
  %55 = icmp eq i32 %52, %54
  br i1 %55, label %56, label %107

56:                                               ; preds = %50
  %57 = load i32, ptr %2, align 4, !tbaa !5
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %2, align 4, !tbaa !5
  %59 = load i32, ptr @S, align 4, !tbaa !5
  %60 = load i32, ptr %5, align 4, !tbaa !5
  %61 = load i32, ptr %7, align 4, !tbaa !5
  %62 = call noundef i32 @_Z4tidxii(i32 noundef %60, i32 noundef %61)
  call void @_Z7addEdgeiii(i32 noundef %59, i32 noundef %62, i32 noundef 1)
  %63 = load i32, ptr %5, align 4, !tbaa !5
  %64 = icmp sgt i32 %63, 0
  br i1 %64, label %65, label %84

65:                                               ; preds = %56
  %66 = load i32, ptr %5, align 4, !tbaa !5
  %67 = sub nsw i32 %66, 1
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [101 x [101 x i8]], ptr @str, i64 0, i64 %68
  %70 = load i32, ptr %7, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [101 x i8], ptr %69, i64 0, i64 %71
  %73 = load i8, ptr %72, align 1, !tbaa !9
  %74 = sext i8 %73 to i32
  %75 = icmp ne i32 %74, 35
  br i1 %75, label %76, label %84

76:                                               ; preds = %65
  %77 = load i32, ptr %5, align 4, !tbaa !5
  %78 = load i32, ptr %7, align 4, !tbaa !5
  %79 = call noundef i32 @_Z4tidxii(i32 noundef %77, i32 noundef %78)
  %80 = load i32, ptr %5, align 4, !tbaa !5
  %81 = sub nsw i32 %80, 1
  %82 = load i32, ptr %7, align 4, !tbaa !5
  %83 = call noundef i32 @_Z4tidxii(i32 noundef %81, i32 noundef %82)
  call void @_Z7addEdgeiii(i32 noundef %79, i32 noundef %83, i32 noundef 1)
  br label %84

84:                                               ; preds = %76, %65, %56
  %85 = load i32, ptr %7, align 4, !tbaa !5
  %86 = icmp sgt i32 %85, 0
  br i1 %86, label %87, label %106

87:                                               ; preds = %84
  %88 = load i32, ptr %5, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [101 x [101 x i8]], ptr @str, i64 0, i64 %89
  %91 = load i32, ptr %7, align 4, !tbaa !5
  %92 = sub nsw i32 %91, 1
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [101 x i8], ptr %90, i64 0, i64 %93
  %95 = load i8, ptr %94, align 1, !tbaa !9
  %96 = sext i8 %95 to i32
  %97 = icmp ne i32 %96, 35
  br i1 %97, label %98, label %106

98:                                               ; preds = %87
  %99 = load i32, ptr %5, align 4, !tbaa !5
  %100 = load i32, ptr %7, align 4, !tbaa !5
  %101 = call noundef i32 @_Z4tidxii(i32 noundef %99, i32 noundef %100)
  %102 = load i32, ptr %5, align 4, !tbaa !5
  %103 = load i32, ptr %7, align 4, !tbaa !5
  %104 = sub nsw i32 %103, 1
  %105 = call noundef i32 @_Z4tidxii(i32 noundef %102, i32 noundef %104)
  call void @_Z7addEdgeiii(i32 noundef %101, i32 noundef %105, i32 noundef 1)
  br label %106

106:                                              ; preds = %98, %87, %84
  br label %158

107:                                              ; preds = %50
  %108 = load i32, ptr %3, align 4, !tbaa !5
  %109 = add nsw i32 %108, 1
  store i32 %109, ptr %3, align 4, !tbaa !5
  %110 = load i32, ptr %5, align 4, !tbaa !5
  %111 = load i32, ptr %7, align 4, !tbaa !5
  %112 = call noundef i32 @_Z4tidxii(i32 noundef %110, i32 noundef %111)
  %113 = load i32, ptr @T, align 4, !tbaa !5
  call void @_Z7addEdgeiii(i32 noundef %112, i32 noundef %113, i32 noundef 1)
  %114 = load i32, ptr %5, align 4, !tbaa !5
  %115 = icmp sgt i32 %114, 0
  br i1 %115, label %116, label %135

116:                                              ; preds = %107
  %117 = load i32, ptr %5, align 4, !tbaa !5
  %118 = sub nsw i32 %117, 1
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [101 x [101 x i8]], ptr @str, i64 0, i64 %119
  %121 = load i32, ptr %7, align 4, !tbaa !5
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [101 x i8], ptr %120, i64 0, i64 %122
  %124 = load i8, ptr %123, align 1, !tbaa !9
  %125 = sext i8 %124 to i32
  %126 = icmp ne i32 %125, 35
  br i1 %126, label %127, label %135

127:                                              ; preds = %116
  %128 = load i32, ptr %5, align 4, !tbaa !5
  %129 = sub nsw i32 %128, 1
  %130 = load i32, ptr %7, align 4, !tbaa !5
  %131 = call noundef i32 @_Z4tidxii(i32 noundef %129, i32 noundef %130)
  %132 = load i32, ptr %5, align 4, !tbaa !5
  %133 = load i32, ptr %7, align 4, !tbaa !5
  %134 = call noundef i32 @_Z4tidxii(i32 noundef %132, i32 noundef %133)
  call void @_Z7addEdgeiii(i32 noundef %131, i32 noundef %134, i32 noundef 1)
  br label %135

135:                                              ; preds = %127, %116, %107
  %136 = load i32, ptr %7, align 4, !tbaa !5
  %137 = icmp sgt i32 %136, 0
  br i1 %137, label %138, label %157

138:                                              ; preds = %135
  %139 = load i32, ptr %5, align 4, !tbaa !5
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [101 x [101 x i8]], ptr @str, i64 0, i64 %140
  %142 = load i32, ptr %7, align 4, !tbaa !5
  %143 = sub nsw i32 %142, 1
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds [101 x i8], ptr %141, i64 0, i64 %144
  %146 = load i8, ptr %145, align 1, !tbaa !9
  %147 = sext i8 %146 to i32
  %148 = icmp ne i32 %147, 35
  br i1 %148, label %149, label %157

149:                                              ; preds = %138
  %150 = load i32, ptr %5, align 4, !tbaa !5
  %151 = load i32, ptr %7, align 4, !tbaa !5
  %152 = sub nsw i32 %151, 1
  %153 = call noundef i32 @_Z4tidxii(i32 noundef %150, i32 noundef %152)
  %154 = load i32, ptr %5, align 4, !tbaa !5
  %155 = load i32, ptr %7, align 4, !tbaa !5
  %156 = call noundef i32 @_Z4tidxii(i32 noundef %154, i32 noundef %155)
  call void @_Z7addEdgeiii(i32 noundef %153, i32 noundef %156, i32 noundef 1)
  br label %157

157:                                              ; preds = %149, %138, %135
  br label %158

158:                                              ; preds = %157, %106
  br label %159

159:                                              ; preds = %158, %49
  %160 = load i32, ptr %7, align 4, !tbaa !5
  %161 = add nsw i32 %160, 1
  store i32 %161, ptr %7, align 4, !tbaa !5
  br label %34, !llvm.loop !10

162:                                              ; preds = %38
  br label %163

163:                                              ; preds = %162
  %164 = load i32, ptr %5, align 4, !tbaa !5
  %165 = add nsw i32 %164, 1
  store i32 %165, ptr %5, align 4, !tbaa !5
  br label %23, !llvm.loop !12

166:                                              ; preds = %27
  br label %167

167:                                              ; preds = %180, %166
  %168 = call noundef zeroext i1 @_Z3bfsv()
  br i1 %168, label %169, label %181

169:                                              ; preds = %167
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  br label %170

170:                                              ; preds = %176, %169
  %171 = load i32, ptr @S, align 4, !tbaa !5
  %172 = call noundef i32 @_Z3dfsii(i32 noundef %171, i32 noundef 10201)
  store i32 %172, ptr %8, align 4, !tbaa !5
  %173 = icmp ne i32 %172, 0
  br i1 %173, label %175, label %174

174:                                              ; preds = %170
  store i32 10, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  br label %180

175:                                              ; preds = %170
  br label %176

176:                                              ; preds = %175
  %177 = load i32, ptr %8, align 4, !tbaa !5
  %178 = load i32, ptr %4, align 4, !tbaa !5
  %179 = add nsw i32 %178, %177
  store i32 %179, ptr %4, align 4, !tbaa !5
  br label %170, !llvm.loop !13

180:                                              ; preds = %174
  br label %167, !llvm.loop !14

181:                                              ; preds = %167
  %182 = load i32, ptr %4, align 4, !tbaa !5
  %183 = load i32, ptr %2, align 4, !tbaa !5
  %184 = icmp eq i32 %182, %183
  br i1 %184, label %185, label %191

185:                                              ; preds = %181
  %186 = load i32, ptr %4, align 4, !tbaa !5
  %187 = load i32, ptr %3, align 4, !tbaa !5
  %188 = icmp eq i32 %186, %187
  br i1 %188, label %189, label %191

189:                                              ; preds = %185
  %190 = call i32 @puts(ptr noundef @.str.2)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %6, align 4
  br label %234

191:                                              ; preds = %185, %181
  %192 = load i32, ptr @S, align 4, !tbaa !5
  call void @_Z5checkii(i32 noundef %192, i32 noundef 0)
  %193 = load i32, ptr @N, align 4, !tbaa !5
  %194 = sext i32 %193 to i64
  %195 = mul i64 %194, 1
  call void @llvm.memset.p0.i64(ptr align 16 @vis, i8 0, i64 %195, i1 false)
  %196 = load i32, ptr @T, align 4, !tbaa !5
  call void @_Z5checkii(i32 noundef %196, i32 noundef 1)
  %197 = call i32 @puts(ptr noundef @.str.3)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %198

198:                                              ; preds = %230, %191
  %199 = load i32, ptr %9, align 4, !tbaa !5
  %200 = load i32, ptr @n, align 4, !tbaa !5
  %201 = icmp slt i32 %199, %200
  br i1 %201, label %203, label %202

202:                                              ; preds = %198
  store i32 13, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  br label %233

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

204:                                              ; preds = %226, %203
  %205 = load i32, ptr %10, align 4, !tbaa !5
  %206 = load i32, ptr @m, align 4, !tbaa !5
  %207 = icmp slt i32 %205, %206
  br i1 %207, label %209, label %208

208:                                              ; preds = %204
  store i32 16, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  br label %229

209:                                              ; preds = %204
  %210 = load i32, ptr %9, align 4, !tbaa !5
  %211 = sext i32 %210 to i64
  %212 = getelementptr inbounds [101 x [101 x i8]], ptr @str, i64 0, i64 %211
  %213 = load i32, ptr %10, align 4, !tbaa !5
  %214 = sext i32 %213 to i64
  %215 = getelementptr inbounds [101 x i8], ptr %212, i64 0, i64 %214
  %216 = load i8, ptr %215, align 1, !tbaa !9
  %217 = sext i8 %216 to i32
  %218 = icmp eq i32 %217, 42
  br i1 %218, label %219, label %225

219:                                              ; preds = %209
  %220 = load i32, ptr %9, align 4, !tbaa !5
  %221 = add nsw i32 %220, 1
  %222 = load i32, ptr %10, align 4, !tbaa !5
  %223 = add nsw i32 %222, 1
  %224 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i32 noundef %221, i32 noundef %223)
  br label %225

225:                                              ; preds = %219, %209
  br label %226

226:                                              ; preds = %225
  %227 = load i32, ptr %10, align 4, !tbaa !5
  %228 = add nsw i32 %227, 1
  store i32 %228, ptr %10, align 4, !tbaa !5
  br label %204, !llvm.loop !15

229:                                              ; preds = %208
  br label %230

230:                                              ; preds = %229
  %231 = load i32, ptr %9, align 4, !tbaa !5
  %232 = add nsw i32 %231, 1
  store i32 %232, ptr %9, align 4, !tbaa !5
  br label %198, !llvm.loop !16

233:                                              ; preds = %202
  store i32 0, ptr %1, align 4
  store i32 1, ptr %6, align 4
  br label %234

234:                                              ; preds = %233, %189
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  %235 = load i32, ptr %1, align 4
  ret i32 %235
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z4tidxii(i32 noundef, i32 noundef) #6

declare i32 @puts(ptr noundef) #5

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

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: 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 = { 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 #5 = { "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 = { 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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}
!13 = distinct !{!13, !11}
!14 = distinct !{!14, !11}
!15 = distinct !{!15, !11}
!16 = distinct !{!16, !11}


; 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
@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 [10201 x i32], align 16
@str = external dso_local global [101 x [101 x i8]], align 16
@vis = external dso_local local_unnamed_addr global [10201 x i8], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [7 x i8], align 1

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

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

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %2 = load i32, ptr @n, align 4, !tbaa !5
  %3 = load i32, ptr @m, align 4, !tbaa !5
  %4 = mul nsw i32 %3, %2
  %5 = add nsw i32 %4, 2
  store i32 %5, ptr @N, align 4, !tbaa !5
  store i32 0, ptr @M, align 4, !tbaa !5
  store i32 %4, ptr @S, align 4, !tbaa !5
  %6 = add nsw i32 %4, 1
  store i32 %6, ptr @T, align 4, !tbaa !5
  %7 = sext i32 %5 to i64
  %8 = shl nsw i64 %7, 2
  tail call void @llvm.memset.p0.i64(ptr nonnull align 16 @lnk, i8 -1, i64 %8, i1 false)
  %9 = icmp sgt i32 %2, 0
  br i1 %9, label %.lr.ph88, label %.preheader79

.preheader79:                                     ; preds = %._crit_edge, %0
  %.065.lcssa = phi i32 [ 0, %0 ], [ %.166.lcssa, %._crit_edge ]
  %.063.lcssa = phi i32 [ 0, %0 ], [ %.164.lcssa, %._crit_edge ]
  %10 = tail call noundef zeroext i1 @_Z3bfsv()
  br i1 %10, label %.preheader77.outer, label %._crit_edge92

.lr.ph88:                                         ; preds = %0, %._crit_edge
  %indvars.iv101 = phi i64 [ %indvars.iv.next102, %._crit_edge ], [ 0, %0 ]
  %.06385 = phi i32 [ %.164.lcssa, %._crit_edge ], [ 0, %0 ]
  %.06584 = phi i32 [ %.166.lcssa, %._crit_edge ], [ 0, %0 ]
  %11 = getelementptr inbounds [101 x [101 x i8]], ptr @str, i64 0, i64 %indvars.iv101
  %12 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %11)
  %13 = load i32, ptr @m, align 4, !tbaa !5
  %14 = icmp sgt i32 %13, 0
  br i1 %14, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.lr.ph88
  %.not69 = icmp eq i64 %indvars.iv101, 0
  %15 = add nsw i64 %indvars.iv101, -1
  %16 = load i8, ptr %11, align 1, !tbaa !9
  %17 = icmp eq i8 %16, 35
  br i1 %17, label %43, label %18

18:                                               ; preds = %.lr.ph
  %19 = trunc nuw nsw i64 %indvars.iv101 to i32
  %20 = and i32 %19, 1
  %21 = icmp eq i32 %20, 0
  br i1 %21, label %32, label %22

22:                                               ; preds = %18
  %23 = add nsw i32 %.06385, 1
  %24 = tail call noundef i32 @_Z4tidxii(i32 noundef %19, i32 noundef 0)
  %25 = load i32, ptr @T, align 4, !tbaa !5
  tail call void @_Z7addEdgeiii(i32 noundef %24, i32 noundef %25, i32 noundef 1)
  br i1 %.not69, label %43, label %26

26:                                               ; preds = %22
  %27 = getelementptr inbounds [101 x [101 x i8]], ptr @str, i64 0, i64 %15, i64 0
  %28 = load i8, ptr %27, align 1, !tbaa !9
  %.not70.peel = icmp eq i8 %28, 35
  br i1 %.not70.peel, label %43, label %29

29:                                               ; preds = %26
  %30 = trunc nsw i64 %15 to i32
  %31 = tail call noundef i32 @_Z4tidxii(i32 noundef %30, i32 noundef 0)
  br label %.sink.split

32:                                               ; preds = %18
  %33 = add nsw i32 %.06584, 1
  %34 = load i32, ptr @S, align 4, !tbaa !5
  %35 = tail call noundef i32 @_Z4tidxii(i32 noundef %19, i32 noundef 0)
  tail call void @_Z7addEdgeiii(i32 noundef %34, i32 noundef %35, i32 noundef 1)
  br i1 %.not69, label %43, label %36

36:                                               ; preds = %32
  %37 = getelementptr inbounds [101 x [101 x i8]], ptr @str, i64 0, i64 %15, i64 0
  %38 = load i8, ptr %37, align 1, !tbaa !9
  %.not74.peel = icmp eq i8 %38, 35
  br i1 %.not74.peel, label %43, label %39

39:                                               ; preds = %36
  %40 = tail call noundef i32 @_Z4tidxii(i32 noundef %19, i32 noundef 0)
  %41 = trunc nsw i64 %15 to i32
  br label %.sink.split

.sink.split:                                      ; preds = %29, %39
  %.sink122 = phi i32 [ %41, %39 ], [ %19, %29 ]
  %.sink = phi i32 [ %40, %39 ], [ %31, %29 ]
  %.267.peel.ph = phi i32 [ %33, %39 ], [ %.06584, %29 ]
  %.2.peel.ph = phi i32 [ %.06385, %39 ], [ %23, %29 ]
  %42 = tail call noundef i32 @_Z4tidxii(i32 noundef %.sink122, i32 noundef 0)
  tail call void @_Z7addEdgeiii(i32 noundef %.sink, i32 noundef %42, i32 noundef 1)
  br label %43

43:                                               ; preds = %.sink.split, %32, %36, %22, %26, %.lr.ph
  %.267.peel = phi i32 [ %.06584, %.lr.ph ], [ %.06584, %26 ], [ %.06584, %22 ], [ %33, %36 ], [ %33, %32 ], [ %.267.peel.ph, %.sink.split ]
  %.2.peel = phi i32 [ %.06385, %.lr.ph ], [ %23, %26 ], [ %23, %22 ], [ %.06385, %36 ], [ %.06385, %32 ], [ %.2.peel.ph, %.sink.split ]
  %44 = load i32, ptr @m, align 4, !tbaa !5
  %45 = icmp sgt i32 %44, 1
  br i1 %45, label %.peel.next, label %._crit_edge

.peel.next:                                       ; preds = %43
  %46 = trunc nuw nsw i64 %indvars.iv101 to i32
  %47 = trunc nsw i64 %15 to i32
  %48 = trunc nsw i64 %15 to i32
  br label %52

._crit_edge:                                      ; preds = %96, %43, %.lr.ph88
  %.166.lcssa = phi i32 [ %.06584, %.lr.ph88 ], [ %.267.peel, %43 ], [ %.267, %96 ]
  %.164.lcssa = phi i32 [ %.06385, %.lr.ph88 ], [ %.2.peel, %43 ], [ %.2, %96 ]
  %indvars.iv.next102 = add nuw nsw i64 %indvars.iv101, 1
  %49 = load i32, ptr @n, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = icmp slt i64 %indvars.iv.next102, %50
  br i1 %51, label %.lr.ph88, label %.preheader79, !llvm.loop !10

52:                                               ; preds = %.peel.next, %96
  %indvars.iv = phi i64 [ 1, %.peel.next ], [ %indvars.iv.next, %96 ]
  %.16481 = phi i32 [ %.2.peel, %.peel.next ], [ %.2, %96 ]
  %.16680 = phi i32 [ %.267.peel, %.peel.next ], [ %.267, %96 ]
  %53 = getelementptr inbounds [101 x [101 x i8]], ptr @str, i64 0, i64 %indvars.iv101, i64 %indvars.iv
  %54 = load i8, ptr %53, align 1, !tbaa !9
  %55 = icmp eq i8 %54, 35
  br i1 %55, label %96, label %56

56:                                               ; preds = %52
  %57 = trunc nuw nsw i64 %indvars.iv to i32
  %58 = xor i32 %57, %46
  %59 = and i32 %58, 1
  %60 = icmp eq i32 %59, 0
  br i1 %60, label %61, label %78

61:                                               ; preds = %56
  %62 = add nsw i32 %.16680, 1
  %63 = load i32, ptr @S, align 4, !tbaa !5
  %64 = tail call noundef i32 @_Z4tidxii(i32 noundef %46, i32 noundef %57)
  tail call void @_Z7addEdgeiii(i32 noundef %63, i32 noundef %64, i32 noundef 1)
  br i1 %.not69, label %71, label %65

65:                                               ; preds = %61
  %66 = getelementptr inbounds [101 x [101 x i8]], ptr @str, i64 0, i64 %15, i64 %indvars.iv
  %67 = load i8, ptr %66, align 1, !tbaa !9
  %.not74 = icmp eq i8 %67, 35
  br i1 %.not74, label %71, label %68

68:                                               ; preds = %65
  %69 = tail call noundef i32 @_Z4tidxii(i32 noundef %46, i32 noundef %57)
  %70 = tail call noundef i32 @_Z4tidxii(i32 noundef %48, i32 noundef %57)
  tail call void @_Z7addEdgeiii(i32 noundef %69, i32 noundef %70, i32 noundef 1)
  br label %71

71:                                               ; preds = %61, %65, %68
  %72 = add nsw i64 %indvars.iv, -1
  %73 = getelementptr inbounds [101 x [101 x i8]], ptr @str, i64 0, i64 %indvars.iv101, i64 %72
  %74 = load i8, ptr %73, align 1, !tbaa !9
  %.not76 = icmp eq i8 %74, 35
  br i1 %.not76, label %96, label %75

75:                                               ; preds = %71
  %76 = tail call noundef i32 @_Z4tidxii(i32 noundef %46, i32 noundef %57)
  %77 = trunc nsw i64 %72 to i32
  br label %.sink.split123

78:                                               ; preds = %56
  %79 = add nsw i32 %.16481, 1
  %80 = tail call noundef i32 @_Z4tidxii(i32 noundef %46, i32 noundef %57)
  %81 = load i32, ptr @T, align 4, !tbaa !5
  tail call void @_Z7addEdgeiii(i32 noundef %80, i32 noundef %81, i32 noundef 1)
  br i1 %.not69, label %88, label %82

82:                                               ; preds = %78
  %83 = getelementptr inbounds [101 x [101 x i8]], ptr @str, i64 0, i64 %15, i64 %indvars.iv
  %84 = load i8, ptr %83, align 1, !tbaa !9
  %.not70 = icmp eq i8 %84, 35
  br i1 %.not70, label %88, label %85

85:                                               ; preds = %82
  %86 = tail call noundef i32 @_Z4tidxii(i32 noundef %47, i32 noundef %57)
  %87 = tail call noundef i32 @_Z4tidxii(i32 noundef %46, i32 noundef %57)
  tail call void @_Z7addEdgeiii(i32 noundef %86, i32 noundef %87, i32 noundef 1)
  br label %88

88:                                               ; preds = %78, %82, %85
  %89 = add nsw i64 %indvars.iv, -1
  %90 = getelementptr inbounds [101 x [101 x i8]], ptr @str, i64 0, i64 %indvars.iv101, i64 %89
  %91 = load i8, ptr %90, align 1, !tbaa !9
  %.not72 = icmp eq i8 %91, 35
  br i1 %.not72, label %96, label %92

92:                                               ; preds = %88
  %93 = trunc nsw i64 %89 to i32
  %94 = tail call noundef i32 @_Z4tidxii(i32 noundef %46, i32 noundef %93)
  br label %.sink.split123

.sink.split123:                                   ; preds = %92, %75
  %.sink126 = phi i32 [ %77, %75 ], [ %57, %92 ]
  %.sink124 = phi i32 [ %76, %75 ], [ %94, %92 ]
  %.267.ph = phi i32 [ %62, %75 ], [ %.16680, %92 ]
  %.2.ph = phi i32 [ %.16481, %75 ], [ %79, %92 ]
  %95 = tail call noundef i32 @_Z4tidxii(i32 noundef %46, i32 noundef %.sink126)
  tail call void @_Z7addEdgeiii(i32 noundef %.sink124, i32 noundef %95, i32 noundef 1)
  br label %96

96:                                               ; preds = %.sink.split123, %71, %88, %52
  %.267 = phi i32 [ %.16680, %52 ], [ %62, %71 ], [ %.16680, %88 ], [ %.267.ph, %.sink.split123 ]
  %.2 = phi i32 [ %.16481, %52 ], [ %.16481, %71 ], [ %79, %88 ], [ %.2.ph, %.sink.split123 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %97 = load i32, ptr @m, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = icmp slt i64 %indvars.iv.next, %98
  br i1 %99, label %52, label %._crit_edge, !llvm.loop !12

.loopexit78:                                      ; preds = %.preheader77
  %100 = tail call noundef zeroext i1 @_Z3bfsv()
  br i1 %100, label %.preheader77, label %._crit_edge92, !llvm.loop !14

.preheader77:                                     ; preds = %.preheader77.outer, %.loopexit78
  %101 = load i32, ptr @S, align 4, !tbaa !5
  %102 = tail call noundef i32 @_Z3dfsii(i32 noundef %101, i32 noundef 10201)
  %.not = icmp eq i32 %102, 0
  br i1 %.not, label %.loopexit78, label %.preheader77.outer.loopexit

.preheader77.outer.loopexit:                      ; preds = %.preheader77
  %103 = add nsw i32 %102, %.1.ph
  br label %.preheader77.outer, !llvm.loop !15

.preheader77.outer:                               ; preds = %.preheader79, %.preheader77.outer.loopexit
  %.1.ph = phi i32 [ %103, %.preheader77.outer.loopexit ], [ 0, %.preheader79 ]
  br label %.preheader77

._crit_edge92:                                    ; preds = %.loopexit78, %.preheader79
  %.062.lcssa = phi i32 [ 0, %.preheader79 ], [ %.1.ph, %.loopexit78 ]
  %104 = icmp eq i32 %.062.lcssa, %.065.lcssa
  %105 = icmp eq i32 %.062.lcssa, %.063.lcssa
  %or.cond = select i1 %104, i1 %105, i1 false
  br i1 %or.cond, label %106, label %108

106:                                              ; preds = %._crit_edge92
  %107 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %.loopexit

108:                                              ; preds = %._crit_edge92
  %109 = load i32, ptr @S, align 4, !tbaa !5
  tail call void @_Z5checkii(i32 noundef %109, i32 noundef 0)
  %110 = load i32, ptr @N, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  tail call void @llvm.memset.p0.i64(ptr nonnull align 16 @vis, i8 0, i64 %111, i1 false)
  %112 = load i32, ptr @T, align 4, !tbaa !5
  tail call void @_Z5checkii(i32 noundef %112, i32 noundef 1)
  %113 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.3)
  %114 = load i32, ptr @n, align 4, !tbaa !5
  %115 = icmp sgt i32 %114, 0
  %116 = load i32, ptr @m, align 4
  %117 = icmp sgt i32 %116, 0
  %or.cond128 = select i1 %115, i1 %117, i1 false
  br i1 %or.cond128, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %108, %._crit_edge96
  %118 = phi i32 [ %124, %._crit_edge96 ], [ %114, %108 ]
  %119 = phi i32 [ %125, %._crit_edge96 ], [ %116, %108 ]
  %120 = phi i32 [ %126, %._crit_edge96 ], [ %116, %108 ]
  %indvars.iv107 = phi i64 [ %122, %._crit_edge96 ], [ 0, %108 ]
  %121 = icmp sgt i32 %120, 0
  %122 = add nuw nsw i64 %indvars.iv107, 1
  br i1 %121, label %.lr.ph95, label %._crit_edge96

.lr.ph95:                                         ; preds = %.preheader
  %123 = trunc nuw nsw i64 %122 to i32
  br label %129

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

._crit_edge96:                                    ; preds = %.preheader, %._crit_edge96.loopexit
  %124 = phi i32 [ %.pre114, %._crit_edge96.loopexit ], [ %118, %.preheader ]
  %125 = phi i32 [ %138, %._crit_edge96.loopexit ], [ %119, %.preheader ]
  %126 = phi i32 [ %138, %._crit_edge96.loopexit ], [ %120, %.preheader ]
  %127 = sext i32 %124 to i64
  %128 = icmp slt i64 %122, %127
  br i1 %128, label %.preheader, label %.loopexit, !llvm.loop !16

129:                                              ; preds = %.lr.ph95, %._crit_edge118
  %130 = phi i32 [ %119, %.lr.ph95 ], [ %138, %._crit_edge118 ]
  %indvars.iv104 = phi i64 [ 0, %.lr.ph95 ], [ %134, %._crit_edge118 ]
  %131 = getelementptr inbounds [101 x [101 x i8]], ptr @str, i64 0, i64 %indvars.iv107, i64 %indvars.iv104
  %132 = load i8, ptr %131, align 1, !tbaa !9
  %133 = icmp eq i8 %132, 42
  %134 = add nuw nsw i64 %indvars.iv104, 1
  br i1 %133, label %135, label %._crit_edge118

135:                                              ; preds = %129
  %136 = trunc nuw nsw i64 %134 to i32
  %137 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %123, i32 noundef %136)
  %.pre = load i32, ptr @m, align 4, !tbaa !5
  br label %._crit_edge118

._crit_edge118:                                   ; preds = %129, %135
  %138 = phi i32 [ %.pre, %135 ], [ %130, %129 ]
  %139 = sext i32 %138 to i64
  %140 = icmp slt i64 %134, %139
  br i1 %140, label %129, label %._crit_edge96.loopexit, !llvm.loop !18

.loopexit:                                        ; preds = %._crit_edge96, %108, %106
  ret i32 0
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z4tidxii(i32 noundef, i32 noundef) local_unnamed_addr #5

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #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: write) }
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 = { 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 #5 = { 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" }

!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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11, !13}
!13 = !{!"llvm.loop.peeled.count", i32 1}
!14 = distinct !{!14, !11}
!15 = distinct !{!15, !11}
!16 = distinct !{!16, !11, !17}
!17 = !{!"llvm.loop.unswitch.partial.disable"}
!18 = distinct !{!18, !11}


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