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

; 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
@p = external dso_local global i32, align 4
@f = external dso_local global [2 x [501 x [501 x i32]]], align 16
@S = external dso_local global [501 x i8], align 16
@T = external dso_local global [501 x i8], align 16
@Q = external dso_local global [501 x i8], align 16
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %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
  store i32 0, ptr %1, align 4
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @S, ptr noundef @T, ptr noundef @Q)
  %10 = call i64 @strlen(ptr noundef @S) #6
  %11 = trunc i64 %10 to i32
  store i32 %11, ptr @n, align 4, !tbaa !5
  %12 = call i64 @strlen(ptr noundef @T) #6
  %13 = trunc i64 %12 to i32
  store i32 %13, ptr @m, align 4, !tbaa !5
  %14 = call i64 @strlen(ptr noundef @Q) #6
  %15 = trunc i64 %14 to i32
  store i32 %15, ptr @p, align 4, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 16 @f, i8 -1, i64 1004004, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %16

16:                                               ; preds = %26, %0
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = load i32, ptr @m, align 4, !tbaa !5
  %19 = icmp sle i32 %17, %18
  br i1 %19, label %21, label %20

20:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  br label %29

21:                                               ; preds = %16
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [501 x [501 x i32]], ptr @f, i64 0, i64 %23
  %25 = getelementptr inbounds [501 x i32], ptr %24, i64 0, i64 0
  store i32 0, ptr %25, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %21
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %2, align 4, !tbaa !5
  br label %16, !llvm.loop !9

29:                                               ; preds = %20
  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
  br label %30

30:                                               ; preds = %219, %29
  %31 = load i32, ptr %3, align 4, !tbaa !5
  %32 = load i32, ptr @n, align 4, !tbaa !5
  %33 = icmp sle i32 %31, %32
  br i1 %33, label %35, label %34

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

35:                                               ; preds = %30
  %36 = load i32, ptr %4, align 4, !tbaa !5
  %37 = xor i32 %36, 1
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [2 x [501 x [501 x i32]]], ptr @f, i64 0, i64 %38
  %40 = getelementptr inbounds [501 x [501 x i32]], ptr %39, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 4 %40, i8 -1, i64 1004004, i1 false)
  %41 = load i32, ptr %4, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [2 x [501 x [501 x i32]]], ptr @f, i64 0, i64 %42
  %44 = getelementptr inbounds [501 x [501 x i32]], ptr %43, i64 0, i64 0
  %45 = getelementptr inbounds [501 x i32], ptr %44, i64 0, i64 0
  store i32 0, ptr %45, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %46

46:                                               ; preds = %213, %35
  %47 = load i32, ptr %6, align 4, !tbaa !5
  %48 = load i32, ptr @m, align 4, !tbaa !5
  %49 = icmp sle i32 %47, %48
  br i1 %49, label %51, label %50

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

51:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  %52 = load i32, ptr %3, align 4, !tbaa !5
  %53 = load i32, ptr %6, align 4, !tbaa !5
  %54 = call noundef i32 @_Z3minii(i32 noundef %52, i32 noundef %53)
  %55 = load i32, ptr @p, align 4, !tbaa !5
  %56 = call noundef i32 @_Z3minii(i32 noundef %54, i32 noundef %55)
  store i32 %56, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %57

57:                                               ; preds = %209, %51
  %58 = load i32, ptr %8, align 4, !tbaa !5
  %59 = load i32, ptr %7, align 4, !tbaa !5
  %60 = icmp sle i32 %58, %59
  br i1 %60, label %62, label %61

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

62:                                               ; preds = %57
  %63 = load i32, ptr %4, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [2 x [501 x [501 x i32]]], ptr @f, i64 0, i64 %64
  %66 = load i32, ptr %6, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [501 x [501 x i32]], ptr %65, i64 0, i64 %67
  %69 = load i32, ptr %8, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [501 x i32], ptr %68, i64 0, i64 %70
  %72 = load i32, ptr %71, align 4, !tbaa !5
  %73 = icmp eq i32 %72, -1
  br i1 %73, label %74, label %75

74:                                               ; preds = %62
  br label %209

75:                                               ; preds = %62
  %76 = load i32, ptr %3, align 4, !tbaa !5
  %77 = load i32, ptr @n, align 4, !tbaa !5
  %78 = icmp slt i32 %76, %77
  br i1 %78, label %79, label %100

79:                                               ; preds = %75
  %80 = load i32, ptr %4, align 4, !tbaa !5
  %81 = xor i32 %80, 1
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [2 x [501 x [501 x i32]]], ptr @f, i64 0, i64 %82
  %84 = load i32, ptr %6, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [501 x [501 x i32]], ptr %83, i64 0, i64 %85
  %87 = load i32, ptr %8, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [501 x i32], ptr %86, i64 0, i64 %88
  %90 = load i32, ptr %4, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [2 x [501 x [501 x i32]]], ptr @f, i64 0, i64 %91
  %93 = load i32, ptr %6, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [501 x [501 x i32]], ptr %92, i64 0, i64 %94
  %96 = load i32, ptr %8, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [501 x i32], ptr %95, i64 0, i64 %97
  %99 = load i32, ptr %98, align 4, !tbaa !5
  call void @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4) %89, i32 noundef %99)
  br label %100

100:                                              ; preds = %79, %75
  %101 = load i32, ptr %6, align 4, !tbaa !5
  %102 = load i32, ptr @m, align 4, !tbaa !5
  %103 = icmp slt i32 %101, %102
  br i1 %103, label %104, label %125

104:                                              ; preds = %100
  %105 = load i32, ptr %4, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [2 x [501 x [501 x i32]]], ptr @f, i64 0, i64 %106
  %108 = load i32, ptr %6, align 4, !tbaa !5
  %109 = add nsw i32 %108, 1
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [501 x [501 x i32]], ptr %107, i64 0, i64 %110
  %112 = load i32, ptr %8, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [501 x i32], ptr %111, i64 0, i64 %113
  %115 = load i32, ptr %4, align 4, !tbaa !5
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds [2 x [501 x [501 x i32]]], ptr @f, i64 0, i64 %116
  %118 = load i32, ptr %6, align 4, !tbaa !5
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [501 x [501 x i32]], ptr %117, i64 0, i64 %119
  %121 = load i32, ptr %8, align 4, !tbaa !5
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [501 x i32], ptr %120, i64 0, i64 %122
  %124 = load i32, ptr %123, align 4, !tbaa !5
  call void @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4) %114, i32 noundef %124)
  br label %125

125:                                              ; preds = %104, %100
  %126 = load i32, ptr %3, align 4, !tbaa !5
  %127 = load i32, ptr @n, align 4, !tbaa !5
  %128 = icmp slt i32 %126, %127
  br i1 %128, label %129, label %208

129:                                              ; preds = %125
  %130 = load i32, ptr %6, align 4, !tbaa !5
  %131 = load i32, ptr @m, align 4, !tbaa !5
  %132 = icmp slt i32 %130, %131
  br i1 %132, label %133, label %208

133:                                              ; preds = %129
  %134 = load i32, ptr %3, align 4, !tbaa !5
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [501 x i8], ptr @S, i64 0, i64 %135
  %137 = load i8, ptr %136, align 1, !tbaa !11
  %138 = sext i8 %137 to i32
  %139 = load i32, ptr %6, align 4, !tbaa !5
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [501 x i8], ptr @T, i64 0, i64 %140
  %142 = load i8, ptr %141, align 1, !tbaa !11
  %143 = sext i8 %142 to i32
  %144 = icmp eq i32 %138, %143
  br i1 %144, label %145, label %208

145:                                              ; preds = %133
  %146 = load i32, ptr %4, align 4, !tbaa !5
  %147 = xor i32 %146, 1
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds [2 x [501 x [501 x i32]]], ptr @f, i64 0, i64 %148
  %150 = load i32, ptr %6, align 4, !tbaa !5
  %151 = add nsw i32 %150, 1
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds [501 x [501 x i32]], ptr %149, i64 0, i64 %152
  %154 = load i32, ptr %8, align 4, !tbaa !5
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds [501 x i32], ptr %153, i64 0, i64 %155
  %157 = load i32, ptr %4, align 4, !tbaa !5
  %158 = sext i32 %157 to i64
  %159 = getelementptr inbounds [2 x [501 x [501 x i32]]], ptr @f, i64 0, i64 %158
  %160 = load i32, ptr %6, align 4, !tbaa !5
  %161 = sext i32 %160 to i64
  %162 = getelementptr inbounds [501 x [501 x i32]], ptr %159, i64 0, i64 %161
  %163 = load i32, ptr %8, align 4, !tbaa !5
  %164 = sext i32 %163 to i64
  %165 = getelementptr inbounds [501 x i32], ptr %162, i64 0, i64 %164
  %166 = load i32, ptr %165, align 4, !tbaa !5
  %167 = add nsw i32 %166, 1
  call void @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4) %156, i32 noundef %167)
  %168 = load i32, ptr %8, align 4, !tbaa !5
  %169 = load i32, ptr @p, align 4, !tbaa !5
  %170 = icmp slt i32 %168, %169
  br i1 %170, label %171, label %207

171:                                              ; preds = %145
  %172 = load i32, ptr %3, align 4, !tbaa !5
  %173 = sext i32 %172 to i64
  %174 = getelementptr inbounds [501 x i8], ptr @S, i64 0, i64 %173
  %175 = load i8, ptr %174, align 1, !tbaa !11
  %176 = sext i8 %175 to i32
  %177 = load i32, ptr %8, align 4, !tbaa !5
  %178 = sext i32 %177 to i64
  %179 = getelementptr inbounds [501 x i8], ptr @Q, i64 0, i64 %178
  %180 = load i8, ptr %179, align 1, !tbaa !11
  %181 = sext i8 %180 to i32
  %182 = icmp eq i32 %176, %181
  br i1 %182, label %183, label %207

183:                                              ; preds = %171
  %184 = load i32, ptr %4, align 4, !tbaa !5
  %185 = xor i32 %184, 1
  %186 = sext i32 %185 to i64
  %187 = getelementptr inbounds [2 x [501 x [501 x i32]]], ptr @f, i64 0, i64 %186
  %188 = load i32, ptr %6, align 4, !tbaa !5
  %189 = add nsw i32 %188, 1
  %190 = sext i32 %189 to i64
  %191 = getelementptr inbounds [501 x [501 x i32]], ptr %187, i64 0, i64 %190
  %192 = load i32, ptr %8, align 4, !tbaa !5
  %193 = add nsw i32 %192, 1
  %194 = sext i32 %193 to i64
  %195 = getelementptr inbounds [501 x i32], ptr %191, i64 0, i64 %194
  %196 = load i32, ptr %4, align 4, !tbaa !5
  %197 = sext i32 %196 to i64
  %198 = getelementptr inbounds [2 x [501 x [501 x i32]]], ptr @f, i64 0, i64 %197
  %199 = load i32, ptr %6, align 4, !tbaa !5
  %200 = sext i32 %199 to i64
  %201 = getelementptr inbounds [501 x [501 x i32]], ptr %198, i64 0, i64 %200
  %202 = load i32, ptr %8, align 4, !tbaa !5
  %203 = sext i32 %202 to i64
  %204 = getelementptr inbounds [501 x i32], ptr %201, i64 0, i64 %203
  %205 = load i32, ptr %204, align 4, !tbaa !5
  %206 = add nsw i32 %205, 1
  call void @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4) %195, i32 noundef %206)
  br label %207

207:                                              ; preds = %183, %171, %145
  br label %208

208:                                              ; preds = %207, %133, %129, %125
  br label %209

209:                                              ; preds = %208, %74
  %210 = load i32, ptr %8, align 4, !tbaa !5
  %211 = add nsw i32 %210, 1
  store i32 %211, ptr %8, align 4, !tbaa !5
  br label %57, !llvm.loop !12

212:                                              ; preds = %61
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  br label %213

213:                                              ; preds = %212
  %214 = load i32, ptr %6, align 4, !tbaa !5
  %215 = add nsw i32 %214, 1
  store i32 %215, ptr %6, align 4, !tbaa !5
  br label %46, !llvm.loop !13

216:                                              ; preds = %50
  %217 = load i32, ptr %4, align 4, !tbaa !5
  %218 = xor i32 %217, 1
  store i32 %218, ptr %4, align 4, !tbaa !5
  br label %219

219:                                              ; preds = %216
  %220 = load i32, ptr %3, align 4, !tbaa !5
  %221 = add nsw i32 %220, 1
  store i32 %221, ptr %3, align 4, !tbaa !5
  br label %30, !llvm.loop !14

222:                                              ; preds = %34
  %223 = load i32, ptr @n, align 4, !tbaa !5
  %224 = and i32 %223, 1
  %225 = sext i32 %224 to i64
  %226 = getelementptr inbounds [2 x [501 x [501 x i32]]], ptr @f, i64 0, i64 %225
  %227 = load i32, ptr @m, align 4, !tbaa !5
  %228 = sext i32 %227 to i64
  %229 = getelementptr inbounds [501 x [501 x i32]], ptr %226, i64 0, i64 %228
  %230 = load i32, ptr @p, align 4, !tbaa !5
  %231 = sext i32 %230 to i64
  %232 = getelementptr inbounds [501 x i32], ptr %229, i64 0, i64 %231
  %233 = load i32, ptr %232, align 4, !tbaa !5
  %234 = icmp eq i32 %233, -1
  br i1 %234, label %235, label %237

235:                                              ; preds = %222
  %236 = call i32 @puts(ptr noundef @.str.1)
  br label %250

237:                                              ; preds = %222
  %238 = load i32, ptr @n, align 4, !tbaa !5
  %239 = and i32 %238, 1
  %240 = sext i32 %239 to i64
  %241 = getelementptr inbounds [2 x [501 x [501 x i32]]], ptr @f, i64 0, i64 %240
  %242 = load i32, ptr @m, align 4, !tbaa !5
  %243 = sext i32 %242 to i64
  %244 = getelementptr inbounds [501 x [501 x i32]], ptr %241, i64 0, i64 %243
  %245 = load i32, ptr @p, align 4, !tbaa !5
  %246 = sext i32 %245 to i64
  %247 = getelementptr inbounds [501 x i32], ptr %244, i64 0, i64 %246
  %248 = load i32, ptr %247, align 4, !tbaa !5
  %249 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %248)
  br label %250

250:                                              ; preds = %237, %235
  ret i32 0
}

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

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #2

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) #5

declare i32 @puts(ptr noundef) #1

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

attributes #0 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind willreturn memory(read) "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #6 = { nounwind willreturn memory(read) }
attributes #7 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !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 local_unnamed_addr global i32, align 4
@m = external dso_local local_unnamed_addr global i32, align 4
@p = external dso_local local_unnamed_addr global i32, align 4
@f = external dso_local global [2 x [501 x [501 x i32]]], align 16
@S = external dso_local global [501 x i8], align 16
@T = external dso_local global [501 x i8], align 16
@Q = external dso_local global [501 x i8], align 16
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @S, ptr noundef nonnull @T, ptr noundef nonnull @Q)
  %2 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) @S) #5
  %3 = trunc i64 %2 to i32
  store i32 %3, ptr @n, align 4, !tbaa !5
  %4 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) @T) #5
  %5 = trunc i64 %4 to i32
  store i32 %5, ptr @m, align 4, !tbaa !5
  %6 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) @Q) #5
  %7 = trunc i64 %6 to i32
  store i32 %7, ptr @p, align 4, !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1004004) @f, i8 -1, i64 1004004, i1 false)
  %.not62 = icmp slt i32 %5, 0
  br i1 %.not62, label %.preheader.thread, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %0
  %8 = add nuw nsw i64 %4, 1
  %wide.trip.count = and i64 %8, 4294967295
  %9 = add nsw i64 %wide.trip.count, -1
  %xtraiter = and i64 %8, 3
  %10 = icmp ult i64 %9, 3
  br i1 %10, label %.preheader.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = sub nsw i64 %wide.trip.count, %xtraiter
  br label %.lr.ph

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

.lr.ph.epil:                                      ; preds = %.preheader.unr-lcssa, %.lr.ph.epil
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.lr.ph.epil ], [ %indvars.iv.unr, %.preheader.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %.preheader.unr-lcssa ]
  %11 = getelementptr inbounds [501 x [501 x i32]], ptr @f, i64 0, i64 %indvars.iv.epil
  store i32 0, ptr %11, align 4, !tbaa !5
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.preheader, label %.lr.ph.epil, !llvm.loop !9

.preheader:                                       ; preds = %.lr.ph.epil, %.preheader.unr-lcssa
  %.not5872 = icmp slt i32 %3, 0
  br i1 %.not5872, label %._crit_edge76, label %.lr.ph75

.preheader.thread:                                ; preds = %0
  %.not587296 = icmp slt i32 %3, 0
  br i1 %.not587296, label %._crit_edge76, label %.lr.ph75.split.us.preheader

.lr.ph75:                                         ; preds = %.preheader
  br i1 %.not62, label %.lr.ph75.split.us.preheader, label %.lr.ph75.split

.lr.ph75.split.us.preheader:                      ; preds = %.preheader.thread, %.lr.ph75
  %12 = icmp eq i32 %3, 0
  br i1 %12, label %._crit_edge76.loopexit.unr-lcssa, label %.lr.ph75.split.us.preheader.new

.lr.ph75.split.us.preheader.new:                  ; preds = %.lr.ph75.split.us.preheader
  %13 = add i32 %3, 1
  %unroll_iter109 = and i32 %13, -2
  br label %.lr.ph75.split.us

.lr.ph75.split.us:                                ; preds = %.lr.ph75.split.us, %.lr.ph75.split.us.preheader.new
  %niter110 = phi i32 [ 0, %.lr.ph75.split.us.preheader.new ], [ %niter110.next.1, %.lr.ph75.split.us ]
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(1004004) getelementptr inbounds (i8, ptr @f, i64 1004004), i8 -1, i64 1004004, i1 false)
  store i32 0, ptr @f, align 16, !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1004004) @f, i8 -1, i64 1004004, i1 false)
  store i32 0, ptr getelementptr inbounds (i8, ptr @f, i64 1004004), align 4, !tbaa !5
  %niter110.next.1 = add i32 %niter110, 2
  %niter110.ncmp.1 = icmp eq i32 %niter110.next.1, %unroll_iter109
  br i1 %niter110.ncmp.1, label %._crit_edge76.loopexit.unr-lcssa, label %.lr.ph75.split.us, !llvm.loop !11

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader.new ], [ %indvars.iv.next.3, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.3, %.lr.ph ]
  %14 = getelementptr inbounds [501 x [501 x i32]], ptr @f, i64 0, i64 %indvars.iv
  store i32 0, ptr %14, align 16, !tbaa !5
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %15 = getelementptr inbounds [501 x [501 x i32]], ptr @f, i64 0, i64 %indvars.iv.next
  store i32 0, ptr %15, align 4, !tbaa !5
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %16 = getelementptr inbounds [501 x [501 x i32]], ptr @f, i64 0, i64 %indvars.iv.next.1
  store i32 0, ptr %16, align 8, !tbaa !5
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %17 = getelementptr inbounds [501 x [501 x i32]], ptr @f, i64 0, i64 %indvars.iv.next.2
  store i32 0, ptr %17, align 4, !tbaa !5
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %.preheader.unr-lcssa, label %.lr.ph, !llvm.loop !13

._crit_edge76.loopexit77:                         ; preds = %._crit_edge71
  %.pre93 = load i32, ptr @p, align 4, !tbaa !5
  br label %._crit_edge76

._crit_edge76.loopexit.unr-lcssa:                 ; preds = %.lr.ph75.split.us, %.lr.ph75.split.us.preheader
  %18 = and i32 %3, 1
  %lcmp.mod108.not.not = icmp eq i32 %18, 0
  br i1 %lcmp.mod108.not.not, label %.lr.ph75.split.us.epil, label %._crit_edge76

.lr.ph75.split.us.epil:                           ; preds = %._crit_edge76.loopexit.unr-lcssa
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(1004004) getelementptr inbounds (i8, ptr @f, i64 1004004), i8 -1, i64 1004004, i1 false)
  store i32 0, ptr @f, align 4, !tbaa !5
  br label %._crit_edge76

._crit_edge76:                                    ; preds = %.lr.ph75.split.us.epil, %._crit_edge76.loopexit.unr-lcssa, %.preheader.thread, %._crit_edge76.loopexit77, %.preheader
  %19 = phi i32 [ %7, %.preheader ], [ %.pre93, %._crit_edge76.loopexit77 ], [ %7, %.preheader.thread ], [ %7, %._crit_edge76.loopexit.unr-lcssa ], [ %7, %.lr.ph75.split.us.epil ]
  %20 = phi i32 [ %5, %.preheader ], [ %38, %._crit_edge76.loopexit77 ], [ %5, %.preheader.thread ], [ %5, %._crit_edge76.loopexit.unr-lcssa ], [ %5, %.lr.ph75.split.us.epil ]
  %.lcssa = phi i32 [ %3, %.preheader ], [ %37, %._crit_edge76.loopexit77 ], [ %3, %.preheader.thread ], [ %3, %._crit_edge76.loopexit.unr-lcssa ], [ %3, %.lr.ph75.split.us.epil ]
  %21 = and i32 %.lcssa, 1
  %22 = zext nneg i32 %21 to i64
  %23 = sext i32 %20 to i64
  %24 = sext i32 %19 to i64
  %25 = getelementptr inbounds [2 x [501 x [501 x i32]]], ptr @f, i64 0, i64 %22, i64 %23, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = icmp eq i32 %26, -1
  br i1 %27, label %93, label %95

.lr.ph75.split:                                   ; preds = %.lr.ph75, %._crit_edge71
  %28 = phi i32 [ %37, %._crit_edge71 ], [ %3, %.lr.ph75 ]
  %29 = phi i32 [ %38, %._crit_edge71 ], [ %5, %.lr.ph75 ]
  %indvars.iv88 = phi i64 [ %indvars.iv.next89, %._crit_edge71 ], [ 0, %.lr.ph75 ]
  %.05374 = phi i32 [ %30, %._crit_edge71 ], [ 0, %.lr.ph75 ]
  %30 = xor i32 %.05374, 1
  %31 = zext nneg i32 %30 to i64
  %32 = getelementptr inbounds [2 x [501 x [501 x i32]]], ptr @f, i64 0, i64 %31
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(1004004) %32, i8 -1, i64 1004004, i1 false)
  %33 = zext nneg i32 %.05374 to i64
  %34 = getelementptr inbounds [2 x [501 x [501 x i32]]], ptr @f, i64 0, i64 %33
  store i32 0, ptr %34, align 4, !tbaa !5
  %.not5967 = icmp slt i32 %29, 0
  br i1 %.not5967, label %._crit_edge71, label %.lr.ph70

.lr.ph70:                                         ; preds = %.lr.ph75.split
  %35 = getelementptr inbounds [501 x i8], ptr @S, i64 0, i64 %indvars.iv88
  %36 = trunc nuw nsw i64 %indvars.iv88 to i32
  br label %40

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

._crit_edge71:                                    ; preds = %._crit_edge71.loopexit, %.lr.ph75.split
  %37 = phi i32 [ %.pre92, %._crit_edge71.loopexit ], [ %28, %.lr.ph75.split ]
  %38 = phi i32 [ %47, %._crit_edge71.loopexit ], [ %29, %.lr.ph75.split ]
  %indvars.iv.next89 = add nuw nsw i64 %indvars.iv88, 1
  %39 = sext i32 %37 to i64
  %.not58.not = icmp slt i64 %indvars.iv88, %39
  br i1 %.not58.not, label %.lr.ph75.split, label %._crit_edge76.loopexit77, !llvm.loop !14

40:                                               ; preds = %.lr.ph70, %._crit_edge
  %indvars.iv85 = phi i64 [ 0, %.lr.ph70 ], [ %.pre95, %._crit_edge ]
  %41 = trunc nuw nsw i64 %indvars.iv85 to i32
  %42 = tail call noundef i32 @_Z3minii(i32 noundef %36, i32 noundef %41)
  %43 = load i32, ptr @p, align 4, !tbaa !5
  %44 = tail call noundef i32 @_Z3minii(i32 noundef %42, i32 noundef %43)
  %.not6064 = icmp slt i32 %44, 0
  %.pre95 = add nuw nsw i64 %indvars.iv85, 1
  br i1 %.not6064, label %._crit_edge, label %.lr.ph66

.lr.ph66:                                         ; preds = %40
  %45 = getelementptr inbounds [501 x i8], ptr @T, i64 0, i64 %indvars.iv85
  %46 = add nuw i32 %44, 1
  %wide.trip.count83 = zext i32 %46 to i64
  br label %49

._crit_edge:                                      ; preds = %92, %40
  %47 = load i32, ptr @m, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %.not59.not = icmp slt i64 %indvars.iv85, %48
  br i1 %.not59.not, label %40, label %._crit_edge71.loopexit, !llvm.loop !16

49:                                               ; preds = %.lr.ph66, %92
  %indvars.iv80 = phi i64 [ 0, %.lr.ph66 ], [ %indvars.iv.next81, %92 ]
  %50 = getelementptr inbounds [2 x [501 x [501 x i32]]], ptr @f, i64 0, i64 %33, i64 %indvars.iv85, i64 %indvars.iv80
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %52 = icmp eq i32 %51, -1
  br i1 %52, label %92, label %53

53:                                               ; preds = %49
  %54 = load i32, ptr @n, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = icmp slt i64 %indvars.iv88, %55
  br i1 %56, label %57, label %59

57:                                               ; preds = %53
  %58 = getelementptr inbounds [2 x [501 x [501 x i32]]], ptr @f, i64 0, i64 %31, i64 %indvars.iv85, i64 %indvars.iv80
  tail call void @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4) %58, i32 noundef %51)
  br label %59

59:                                               ; preds = %57, %53
  %60 = load i32, ptr @m, align 4
  %61 = sext i32 %60 to i64
  %62 = icmp slt i64 %indvars.iv85, %61
  br i1 %62, label %63, label %66

63:                                               ; preds = %59
  %64 = getelementptr inbounds [2 x [501 x [501 x i32]]], ptr @f, i64 0, i64 %33, i64 %.pre95, i64 %indvars.iv80
  %65 = load i32, ptr %50, align 4, !tbaa !5
  tail call void @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4) %64, i32 noundef %65)
  %.pre = load i32, ptr @m, align 4
  %.pre94 = sext i32 %.pre to i64
  br label %66

66:                                               ; preds = %63, %59
  %.pre-phi = phi i64 [ %.pre94, %63 ], [ %61, %59 ]
  %67 = load i32, ptr @n, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = icmp slt i64 %indvars.iv88, %68
  %70 = icmp slt i64 %indvars.iv85, %.pre-phi
  %or.cond = select i1 %69, i1 %70, i1 false
  br i1 %or.cond, label %71, label %92

71:                                               ; preds = %66
  %72 = load i8, ptr %35, align 1, !tbaa !17
  %73 = load i8, ptr %45, align 1, !tbaa !17
  %74 = icmp eq i8 %72, %73
  br i1 %74, label %75, label %92

75:                                               ; preds = %71
  %76 = getelementptr inbounds [2 x [501 x [501 x i32]]], ptr @f, i64 0, i64 %31, i64 %.pre95, i64 %indvars.iv80
  %77 = load i32, ptr %50, align 4, !tbaa !5
  %78 = add nsw i32 %77, 1
  tail call void @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4) %76, i32 noundef %78)
  %79 = load i32, ptr @p, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = icmp slt i64 %indvars.iv80, %80
  br i1 %81, label %82, label %92

82:                                               ; preds = %75
  %83 = load i8, ptr %35, align 1, !tbaa !17
  %84 = getelementptr inbounds [501 x i8], ptr @Q, i64 0, i64 %indvars.iv80
  %85 = load i8, ptr %84, align 1, !tbaa !17
  %86 = icmp eq i8 %83, %85
  br i1 %86, label %87, label %92

87:                                               ; preds = %82
  %88 = add nuw nsw i64 %indvars.iv80, 1
  %89 = getelementptr inbounds [2 x [501 x [501 x i32]]], ptr @f, i64 0, i64 %31, i64 %.pre95, i64 %88
  %90 = load i32, ptr %50, align 4, !tbaa !5
  %91 = add nsw i32 %90, 1
  tail call void @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4) %89, i32 noundef %91)
  br label %92

92:                                               ; preds = %66, %71, %87, %82, %75, %49
  %indvars.iv.next81 = add nuw nsw i64 %indvars.iv80, 1
  %exitcond84.not = icmp eq i64 %indvars.iv.next81, %wide.trip.count83
  br i1 %exitcond84.not, label %._crit_edge, label %49, !llvm.loop !18

93:                                               ; preds = %._crit_edge76
  %94 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.1)
  br label %97

95:                                               ; preds = %._crit_edge76
  %96 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %26)
  br label %97

97:                                               ; preds = %95, %93
  ret i32 0
}

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #2

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

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

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

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

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

attributes #0 = { mustprogress norecurse 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 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 #5 = { nounwind willreturn memory(read) }

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


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