; LLVM IR from tangjz/acm-icpc :: timus (2058)

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

%struct.Border = type { i32, i32, i32 }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@f = external dso_local global [2 x [300003 x i32]], align 16
@g = external dso_local global [2 x [300003 x i32]], align 16
@str = external dso_local global [300003 x i8], align 16
@seq = external dso_local global [25 x %struct.Border], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@_ZZ4mainE3tmp = external hidden global [25 x %struct.Border], align 16
@.str.1 = external hidden unnamed_addr constant [7 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
  store i32 0, ptr %1, align 4
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef getelementptr inbounds (i8, ptr @str, i64 1))
  %9 = call i64 @strlen(ptr noundef getelementptr inbounds (i8, ptr @str, i64 1)) #6
  %10 = trunc i64 %9 to i32
  store i32 %10, ptr @n, align 4, !tbaa !5
  store i32 -300003, ptr getelementptr inbounds (%struct.Border, ptr @seq, i32 0, i32 2), align 8, !tbaa !9
  store i32 300003, ptr getelementptr inbounds ([2 x [300003 x i32]], ptr @f, i64 0, i64 1), align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %11

11:                                               ; preds = %246, %0
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = load i32, ptr @n, align 4, !tbaa !5
  %14 = icmp sle i32 %12, %13
  br i1 %14, label %16, label %15

15:                                               ; preds = %11
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  br label %249

16:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  %17 = load i32, ptr @m, align 4, !tbaa !5
  store i32 %17, ptr %4, align 4, !tbaa !5
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = mul i64 %19, 12
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 getelementptr inbounds (%struct.Border, ptr @_ZZ4mainE3tmp, i64 1), ptr align 4 getelementptr inbounds (%struct.Border, ptr @seq, i64 1), i64 %20, i1 false)
  store i32 0, ptr @m, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %103, %16
  %22 = load i32, ptr %5, align 4, !tbaa !5
  %23 = load i32, ptr %4, align 4, !tbaa !5
  %24 = icmp sle i32 %22, %23
  br i1 %24, label %26, label %25

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

26:                                               ; preds = %21
  %27 = load i32, ptr %5, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [25 x %struct.Border], ptr @_ZZ4mainE3tmp, i64 0, i64 %28
  %30 = getelementptr inbounds %struct.Border, ptr %29, i32 0, i32 0
  %31 = load i32, ptr %30, align 4, !tbaa !11
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [300003 x i8], ptr @str, i64 0, i64 %32
  %34 = load i8, ptr %33, align 1, !tbaa !12
  %35 = sext i8 %34 to i32
  %36 = load i32, ptr %2, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [300003 x i8], ptr @str, i64 0, i64 %37
  %39 = load i8, ptr %38, align 1, !tbaa !12
  %40 = sext i8 %39 to i32
  %41 = icmp eq i32 %35, %40
  br i1 %41, label %42, label %55

42:                                               ; preds = %26
  %43 = load i32, ptr %5, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [25 x %struct.Border], ptr @_ZZ4mainE3tmp, i64 0, i64 %44
  %46 = getelementptr inbounds %struct.Border, ptr %45, i32 0, i32 0
  %47 = load i32, ptr %46, align 4, !tbaa !11
  %48 = sub nsw i32 %47, 1
  %49 = load i32, ptr %5, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [25 x %struct.Border], ptr @_ZZ4mainE3tmp, i64 0, i64 %50
  %52 = getelementptr inbounds %struct.Border, ptr %51, i32 0, i32 0
  %53 = load i32, ptr %52, align 4, !tbaa !11
  %54 = sub nsw i32 %53, 1
  call void @_Z6appendii(i32 noundef %48, i32 noundef %54)
  br label %55

55:                                               ; preds = %42, %26
  %56 = load i32, ptr %5, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [25 x %struct.Border], ptr @_ZZ4mainE3tmp, i64 0, i64 %57
  %59 = getelementptr inbounds %struct.Border, ptr %58, i32 0, i32 0
  %60 = load i32, ptr %59, align 4, !tbaa !11
  %61 = load i32, ptr %5, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [25 x %struct.Border], ptr @_ZZ4mainE3tmp, i64 0, i64 %62
  %64 = getelementptr inbounds %struct.Border, ptr %63, i32 0, i32 2
  %65 = load i32, ptr %64, align 4, !tbaa !9
  %66 = icmp ne i32 %60, %65
  br i1 %66, label %67, label %102

67:                                               ; preds = %55
  %68 = load i32, ptr %5, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [25 x %struct.Border], ptr @_ZZ4mainE3tmp, i64 0, i64 %69
  %71 = getelementptr inbounds %struct.Border, ptr %70, i32 0, i32 2
  %72 = load i32, ptr %71, align 4, !tbaa !9
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [300003 x i8], ptr @str, i64 0, i64 %73
  %75 = load i8, ptr %74, align 1, !tbaa !12
  %76 = sext i8 %75 to i32
  %77 = load i32, ptr %2, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [300003 x i8], ptr @str, i64 0, i64 %78
  %80 = load i8, ptr %79, align 1, !tbaa !12
  %81 = sext i8 %80 to i32
  %82 = icmp eq i32 %76, %81
  br i1 %82, label %83, label %102

83:                                               ; preds = %67
  %84 = load i32, ptr %5, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [25 x %struct.Border], ptr @_ZZ4mainE3tmp, i64 0, i64 %85
  %87 = getelementptr inbounds %struct.Border, ptr %86, i32 0, i32 0
  %88 = load i32, ptr %87, align 4, !tbaa !11
  %89 = load i32, ptr %5, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [25 x %struct.Border], ptr @_ZZ4mainE3tmp, i64 0, i64 %90
  %92 = getelementptr inbounds %struct.Border, ptr %91, i32 0, i32 1
  %93 = load i32, ptr %92, align 4, !tbaa !13
  %94 = add nsw i32 %88, %93
  %95 = sub nsw i32 %94, 1
  %96 = load i32, ptr %5, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [25 x %struct.Border], ptr @_ZZ4mainE3tmp, i64 0, i64 %97
  %99 = getelementptr inbounds %struct.Border, ptr %98, i32 0, i32 2
  %100 = load i32, ptr %99, align 4, !tbaa !9
  %101 = sub nsw i32 %100, 1
  call void @_Z6appendii(i32 noundef %95, i32 noundef %101)
  br label %102

102:                                              ; preds = %83, %67, %55
  br label %103

103:                                              ; preds = %102
  %104 = load i32, ptr %5, align 4, !tbaa !5
  %105 = add nsw i32 %104, 1
  store i32 %105, ptr %5, align 4, !tbaa !5
  br label %21, !llvm.loop !14

106:                                              ; preds = %25
  %107 = load i32, ptr %2, align 4, !tbaa !5
  %108 = sub nsw i32 %107, 1
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [300003 x i8], ptr @str, i64 0, i64 %109
  %111 = load i8, ptr %110, align 1, !tbaa !12
  %112 = sext i8 %111 to i32
  %113 = load i32, ptr %2, align 4, !tbaa !5
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [300003 x i8], ptr @str, i64 0, i64 %114
  %116 = load i8, ptr %115, align 1, !tbaa !12
  %117 = sext i8 %116 to i32
  %118 = icmp eq i32 %112, %117
  br i1 %118, label %119, label %124

119:                                              ; preds = %106
  %120 = load i32, ptr %2, align 4, !tbaa !5
  %121 = sub nsw i32 %120, 2
  %122 = load i32, ptr %2, align 4, !tbaa !5
  %123 = sub nsw i32 %122, 2
  call void @_Z6appendii(i32 noundef %121, i32 noundef %123)
  br label %124

124:                                              ; preds = %119, %106
  %125 = load i32, ptr %2, align 4, !tbaa !5
  %126 = sub nsw i32 %125, 1
  %127 = load i32, ptr %2, align 4, !tbaa !5
  %128 = sub nsw i32 %127, 1
  call void @_Z6appendii(i32 noundef %126, i32 noundef %128)
  %129 = load i32, ptr %2, align 4, !tbaa !5
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds [300003 x i32], ptr getelementptr inbounds ([2 x [300003 x i32]], ptr @f, i64 0, i64 1), i64 0, i64 %130
  store i32 300003, ptr %131, align 4, !tbaa !5
  %132 = load i32, ptr %2, align 4, !tbaa !5
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds [300003 x i32], ptr @f, i64 0, i64 %133
  store i32 300003, ptr %134, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %135

135:                                              ; preds = %215, %124
  %136 = load i32, ptr %6, align 4, !tbaa !5
  %137 = load i32, ptr @m, align 4, !tbaa !5
  %138 = icmp sle i32 %136, %137
  br i1 %138, label %140, label %139

139:                                              ; preds = %135
  store i32 8, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  br label %218

140:                                              ; preds = %135
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  %141 = load i32, ptr %6, align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [25 x %struct.Border], ptr @seq, i64 0, i64 %142
  %144 = getelementptr inbounds %struct.Border, ptr %143, i32 0, i32 2
  %145 = load i32, ptr %144, align 4, !tbaa !9
  store i32 %145, ptr %7, align 4, !tbaa !5
  %146 = load i32, ptr %7, align 4, !tbaa !5
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds [300003 x i32], ptr getelementptr inbounds ([2 x [300003 x i32]], ptr @f, i64 0, i64 1), i64 0, i64 %147
  %149 = load i32, ptr %148, align 4, !tbaa !5
  %150 = add nsw i32 %149, 1
  %151 = load i32, ptr %7, align 4, !tbaa !5
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds [300003 x i32], ptr @g, i64 0, i64 %152
  store i32 %150, ptr %153, align 4, !tbaa !5
  %154 = load i32, ptr %7, align 4, !tbaa !5
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds [300003 x i32], ptr @f, i64 0, i64 %155
  %157 = load i32, ptr %156, align 4, !tbaa !5
  %158 = add nsw i32 %157, 1
  %159 = load i32, ptr %7, align 4, !tbaa !5
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds [300003 x i32], ptr getelementptr inbounds ([2 x [300003 x i32]], ptr @g, i64 0, i64 1), i64 0, i64 %160
  store i32 %158, ptr %161, align 4, !tbaa !5
  %162 = load i32, ptr %6, align 4, !tbaa !5
  %163 = sext i32 %162 to i64
  %164 = getelementptr inbounds [25 x %struct.Border], ptr @seq, i64 0, i64 %163
  %165 = getelementptr inbounds %struct.Border, ptr %164, i32 0, i32 0
  %166 = load i32, ptr %165, align 4, !tbaa !11
  %167 = load i32, ptr %6, align 4, !tbaa !5
  %168 = sext i32 %167 to i64
  %169 = getelementptr inbounds [25 x %struct.Border], ptr @seq, i64 0, i64 %168
  %170 = getelementptr inbounds %struct.Border, ptr %169, i32 0, i32 2
  %171 = load i32, ptr %170, align 4, !tbaa !9
  %172 = icmp ne i32 %166, %171
  br i1 %172, label %173, label %200

173:                                              ; preds = %140
  %174 = load i32, ptr %7, align 4, !tbaa !5
  %175 = sext i32 %174 to i64
  %176 = getelementptr inbounds [300003 x i32], ptr @g, i64 0, i64 %175
  %177 = load i32, ptr %7, align 4, !tbaa !5
  %178 = load i32, ptr %6, align 4, !tbaa !5
  %179 = sext i32 %178 to i64
  %180 = getelementptr inbounds [25 x %struct.Border], ptr @seq, i64 0, i64 %179
  %181 = getelementptr inbounds %struct.Border, ptr %180, i32 0, i32 1
  %182 = load i32, ptr %181, align 4, !tbaa !13
  %183 = sub nsw i32 %177, %182
  %184 = sext i32 %183 to i64
  %185 = getelementptr inbounds [300003 x i32], ptr @g, i64 0, i64 %184
  %186 = load i32, ptr %185, align 4, !tbaa !5
  call void @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4) %176, i32 noundef %186)
  %187 = load i32, ptr %7, align 4, !tbaa !5
  %188 = sext i32 %187 to i64
  %189 = getelementptr inbounds [300003 x i32], ptr getelementptr inbounds ([2 x [300003 x i32]], ptr @g, i64 0, i64 1), i64 0, i64 %188
  %190 = load i32, ptr %7, align 4, !tbaa !5
  %191 = load i32, ptr %6, align 4, !tbaa !5
  %192 = sext i32 %191 to i64
  %193 = getelementptr inbounds [25 x %struct.Border], ptr @seq, i64 0, i64 %192
  %194 = getelementptr inbounds %struct.Border, ptr %193, i32 0, i32 1
  %195 = load i32, ptr %194, align 4, !tbaa !13
  %196 = sub nsw i32 %190, %195
  %197 = sext i32 %196 to i64
  %198 = getelementptr inbounds [300003 x i32], ptr getelementptr inbounds ([2 x [300003 x i32]], ptr @g, i64 0, i64 1), i64 0, i64 %197
  %199 = load i32, ptr %198, align 4, !tbaa !5
  call void @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4) %189, i32 noundef %199)
  br label %200

200:                                              ; preds = %173, %140
  %201 = load i32, ptr %2, align 4, !tbaa !5
  %202 = sext i32 %201 to i64
  %203 = getelementptr inbounds [300003 x i32], ptr @f, i64 0, i64 %202
  %204 = load i32, ptr %7, align 4, !tbaa !5
  %205 = sext i32 %204 to i64
  %206 = getelementptr inbounds [300003 x i32], ptr @g, i64 0, i64 %205
  %207 = load i32, ptr %206, align 4, !tbaa !5
  call void @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4) %203, i32 noundef %207)
  %208 = load i32, ptr %2, align 4, !tbaa !5
  %209 = sext i32 %208 to i64
  %210 = getelementptr inbounds [300003 x i32], ptr getelementptr inbounds ([2 x [300003 x i32]], ptr @f, i64 0, i64 1), i64 0, i64 %209
  %211 = load i32, ptr %7, align 4, !tbaa !5
  %212 = sext i32 %211 to i64
  %213 = getelementptr inbounds [300003 x i32], ptr getelementptr inbounds ([2 x [300003 x i32]], ptr @g, i64 0, i64 1), i64 0, i64 %212
  %214 = load i32, ptr %213, align 4, !tbaa !5
  call void @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4) %210, i32 noundef %214)
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  br label %215

215:                                              ; preds = %200
  %216 = load i32, ptr %6, align 4, !tbaa !5
  %217 = add nsw i32 %216, 1
  store i32 %217, ptr %6, align 4, !tbaa !5
  br label %135, !llvm.loop !16

218:                                              ; preds = %139
  %219 = load i32, ptr %2, align 4, !tbaa !5
  %220 = sext i32 %219 to i64
  %221 = getelementptr inbounds [300003 x i32], ptr getelementptr inbounds ([2 x [300003 x i32]], ptr @f, i64 0, i64 1), i64 0, i64 %220
  %222 = load i32, ptr %221, align 4, !tbaa !5
  %223 = icmp slt i32 %222, 300003
  br i1 %223, label %224, label %229

224:                                              ; preds = %218
  %225 = load i32, ptr %2, align 4, !tbaa !5
  %226 = sext i32 %225 to i64
  %227 = getelementptr inbounds [300003 x i32], ptr getelementptr inbounds ([2 x [300003 x i32]], ptr @f, i64 0, i64 1), i64 0, i64 %226
  %228 = load i32, ptr %227, align 4, !tbaa !5
  br label %230

229:                                              ; preds = %218
  br label %230

230:                                              ; preds = %229, %224
  %231 = phi i32 [ %228, %224 ], [ -1, %229 ]
  %232 = load i32, ptr %2, align 4, !tbaa !5
  %233 = sext i32 %232 to i64
  %234 = getelementptr inbounds [300003 x i32], ptr @f, i64 0, i64 %233
  %235 = load i32, ptr %234, align 4, !tbaa !5
  %236 = icmp slt i32 %235, 300003
  br i1 %236, label %237, label %242

237:                                              ; preds = %230
  %238 = load i32, ptr %2, align 4, !tbaa !5
  %239 = sext i32 %238 to i64
  %240 = getelementptr inbounds [300003 x i32], ptr @f, i64 0, i64 %239
  %241 = load i32, ptr %240, align 4, !tbaa !5
  br label %243

242:                                              ; preds = %230
  br label %243

243:                                              ; preds = %242, %237
  %244 = phi i32 [ %241, %237 ], [ -2, %242 ]
  %245 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %231, i32 noundef %244)
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  br label %246

246:                                              ; preds = %243
  %247 = load i32, ptr %2, align 4, !tbaa !5
  %248 = add nsw i32 %247, 1
  store i32 %248, ptr %2, align 4, !tbaa !5
  br label %11, !llvm.loop !17

249:                                              ; preds = %15
  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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #3

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

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

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

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

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 nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nocallback nofree 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 = !{!10, !6, i64 8}
!10 = !{!"_ZTS6Border", !6, i64 0, !6, i64 4, !6, i64 8}
!11 = !{!10, !6, i64 0}
!12 = !{!7, !7, i64 0}
!13 = !{!10, !6, i64 4}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}
!17 = distinct !{!17, !15}


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

%struct.Border = type { i32, i32, i32 }

@n = external dso_local local_unnamed_addr global i32, align 4
@m = external dso_local local_unnamed_addr global i32, align 4
@f = external dso_local global [2 x [300003 x i32]], align 16
@g = external dso_local global [2 x [300003 x i32]], align 16
@str = external dso_local global [300003 x i8], align 16
@seq = external dso_local local_unnamed_addr global [25 x %struct.Border], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@_ZZ4mainE3tmp = external hidden local_unnamed_addr global [25 x %struct.Border], align 16
@.str.1 = external hidden unnamed_addr constant [7 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 getelementptr inbounds (i8, ptr @str, i64 1))
  %2 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) getelementptr inbounds (i8, ptr @str, i64 1)) #5
  %3 = trunc i64 %2 to i32
  store i32 %3, ptr @n, align 4, !tbaa !5
  store i32 -300003, ptr getelementptr inbounds (i8, ptr @seq, i64 8), align 8, !tbaa !9
  store i32 300003, ptr getelementptr inbounds (i8, ptr @f, i64 1200012), align 4, !tbaa !5
  %.not65 = icmp slt i32 %3, 1
  br i1 %.not65, label %._crit_edge69, label %.lr.ph68

._crit_edge69:                                    ; preds = %.thread, %0
  ret i32 0

.lr.ph68:                                         ; preds = %0, %.thread
  %indvars.iv74 = phi i64 [ %indvars.iv.next75, %.thread ], [ 1, %0 ]
  %4 = load i32, ptr @m, align 4, !tbaa !5
  %5 = sext i32 %4 to i64
  %6 = mul nsw i64 %5, 12
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 4 getelementptr inbounds (i8, ptr @_ZZ4mainE3tmp, i64 12), ptr nonnull align 4 getelementptr inbounds (i8, ptr @seq, i64 12), i64 %6, i1 false)
  store i32 0, ptr @m, align 4, !tbaa !5
  %.not5458 = icmp slt i32 %4, 1
  br i1 %.not5458, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph68
  %7 = getelementptr inbounds [300003 x i8], ptr @str, i64 0, i64 %indvars.iv74
  %8 = add nuw i32 %4, 1
  %wide.trip.count = zext i32 %8 to i64
  br label %15

._crit_edge:                                      ; preds = %41, %.lr.ph68
  %9 = add nsw i64 %indvars.iv74, -1
  %10 = getelementptr inbounds [300003 x i8], ptr @str, i64 0, i64 %9
  %11 = load i8, ptr %10, align 1, !tbaa !11
  %12 = getelementptr inbounds [300003 x i8], ptr @str, i64 0, i64 %indvars.iv74
  %13 = load i8, ptr %12, align 1, !tbaa !11
  %14 = icmp eq i8 %11, %13
  br i1 %14, label %42, label %45

15:                                               ; preds = %.lr.ph, %41
  %indvars.iv = phi i64 [ 1, %.lr.ph ], [ %indvars.iv.next, %41 ]
  %16 = getelementptr inbounds [25 x %struct.Border], ptr @_ZZ4mainE3tmp, i64 0, i64 %indvars.iv
  %17 = load i32, ptr %16, align 4, !tbaa !12
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [300003 x i8], ptr @str, i64 0, i64 %18
  %20 = load i8, ptr %19, align 1, !tbaa !11
  %21 = load i8, ptr %7, align 1, !tbaa !11
  %22 = icmp eq i8 %20, %21
  br i1 %22, label %23, label %25

23:                                               ; preds = %15
  %24 = add nsw i32 %17, -1
  tail call void @_Z6appendii(i32 noundef %24, i32 noundef %24)
  %.pre = load i32, ptr %16, align 4, !tbaa !12
  br label %25

25:                                               ; preds = %23, %15
  %26 = phi i32 [ %.pre, %23 ], [ %17, %15 ]
  %27 = getelementptr inbounds i8, ptr %16, i64 8
  %28 = load i32, ptr %27, align 4, !tbaa !9
  %.not57 = icmp eq i32 %26, %28
  br i1 %.not57, label %41, label %29

29:                                               ; preds = %25
  %30 = sext i32 %28 to i64
  %31 = getelementptr inbounds [300003 x i8], ptr @str, i64 0, i64 %30
  %32 = load i8, ptr %31, align 1, !tbaa !11
  %33 = load i8, ptr %7, align 1, !tbaa !11
  %34 = icmp eq i8 %32, %33
  br i1 %34, label %35, label %41

35:                                               ; preds = %29
  %36 = getelementptr inbounds i8, ptr %16, i64 4
  %37 = load i32, ptr %36, align 4, !tbaa !13
  %38 = add i32 %26, -1
  %39 = add i32 %38, %37
  %40 = add nsw i32 %28, -1
  tail call void @_Z6appendii(i32 noundef %39, i32 noundef %40)
  br label %41

41:                                               ; preds = %25, %29, %35
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %15, !llvm.loop !14

42:                                               ; preds = %._crit_edge
  %43 = trunc i64 %indvars.iv74 to i32
  %44 = add i32 %43, -2
  tail call void @_Z6appendii(i32 noundef %44, i32 noundef %44)
  br label %45

45:                                               ; preds = %42, %._crit_edge
  %46 = trunc nuw nsw i64 %9 to i32
  tail call void @_Z6appendii(i32 noundef %46, i32 noundef %46)
  %47 = getelementptr inbounds [300003 x i32], ptr getelementptr inbounds (i8, ptr @f, i64 1200012), i64 0, i64 %indvars.iv74
  store i32 300003, ptr %47, align 4, !tbaa !5
  %48 = getelementptr inbounds [300003 x i32], ptr @f, i64 0, i64 %indvars.iv74
  store i32 300003, ptr %48, align 4, !tbaa !5
  %49 = load i32, ptr @m, align 4, !tbaa !5
  %.not5560 = icmp slt i32 %49, 1
  br i1 %.not5560, label %.thread, label %.lr.ph63

._crit_edge64:                                    ; preds = %82
  %.pre78 = load i32, ptr %47, align 4, !tbaa !5
  %.pre78.fr = freeze i32 %.pre78
  %.pre79 = load i32, ptr %48, align 4, !tbaa !5
  %.pre79.fr = freeze i32 %.pre79
  %50 = icmp slt i32 %.pre78.fr, 300003
  %spec.select = select i1 %50, i32 %.pre78.fr, i32 -1
  %51 = icmp slt i32 %.pre79.fr, 300003
  %spec.select83 = select i1 %51, i32 %.pre79.fr, i32 -2
  br label %.thread

.thread:                                          ; preds = %._crit_edge64, %45
  %52 = phi i32 [ -1, %45 ], [ %spec.select, %._crit_edge64 ]
  %53 = phi i32 [ -2, %45 ], [ %spec.select83, %._crit_edge64 ]
  %54 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %52, i32 noundef %53)
  %indvars.iv.next75 = add nuw nsw i64 %indvars.iv74, 1
  %55 = load i32, ptr @n, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %.not.not = icmp slt i64 %indvars.iv74, %56
  br i1 %.not.not, label %.lr.ph68, label %._crit_edge69, !llvm.loop !16

.lr.ph63:                                         ; preds = %45, %82
  %indvars.iv71 = phi i64 [ %indvars.iv.next72, %82 ], [ 1, %45 ]
  %57 = getelementptr inbounds [25 x %struct.Border], ptr @seq, i64 0, i64 %indvars.iv71
  %58 = getelementptr inbounds i8, ptr %57, i64 8
  %59 = load i32, ptr %58, align 4, !tbaa !9
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [300003 x i32], ptr getelementptr inbounds (i8, ptr @f, i64 1200012), i64 0, i64 %60
  %62 = load i32, ptr %61, align 4, !tbaa !5
  %63 = add nsw i32 %62, 1
  %64 = getelementptr inbounds [300003 x i32], ptr @g, i64 0, i64 %60
  store i32 %63, ptr %64, align 4, !tbaa !5
  %65 = getelementptr inbounds [300003 x i32], ptr @f, i64 0, i64 %60
  %66 = load i32, ptr %65, align 4, !tbaa !5
  %67 = add nsw i32 %66, 1
  %68 = getelementptr inbounds [300003 x i32], ptr getelementptr inbounds (i8, ptr @g, i64 1200012), i64 0, i64 %60
  store i32 %67, ptr %68, align 4, !tbaa !5
  %69 = load i32, ptr %57, align 4, !tbaa !12
  %.not56 = icmp eq i32 %69, %59
  br i1 %.not56, label %82, label %70

70:                                               ; preds = %.lr.ph63
  %71 = getelementptr inbounds i8, ptr %57, i64 4
  %72 = load i32, ptr %71, align 4, !tbaa !13
  %73 = sub nsw i32 %59, %72
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [300003 x i32], ptr @g, i64 0, i64 %74
  %76 = load i32, ptr %75, align 4, !tbaa !5
  tail call void @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4) %64, i32 noundef %76)
  %77 = load i32, ptr %71, align 4, !tbaa !13
  %78 = sub nsw i32 %59, %77
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [300003 x i32], ptr getelementptr inbounds (i8, ptr @g, i64 1200012), i64 0, i64 %79
  %81 = load i32, ptr %80, align 4, !tbaa !5
  tail call void @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4) %68, i32 noundef %81)
  %.pre77 = load i32, ptr %64, align 4, !tbaa !5
  br label %82

82:                                               ; preds = %70, %.lr.ph63
  %83 = phi i32 [ %.pre77, %70 ], [ %63, %.lr.ph63 ]
  tail call void @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4) %48, i32 noundef %83)
  %84 = load i32, ptr %68, align 4, !tbaa !5
  tail call void @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4) %47, i32 noundef %84)
  %indvars.iv.next72 = add nuw nsw i64 %indvars.iv71, 1
  %85 = load i32, ptr @m, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %.not55.not = icmp slt i64 %indvars.iv71, %86
  br i1 %.not55.not, label %.lr.ph63, label %._crit_edge64, !llvm.loop !17
}

; 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: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z6appendii(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 @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: readwrite) }
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 = !{!10, !6, i64 8}
!10 = !{!"_ZTS6Border", !6, i64 0, !6, i64 4, !6, i64 8}
!11 = !{!7, !7, i64 0}
!12 = !{!10, !6, i64 0}
!13 = !{!10, !6, i64 4}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}
!17 = distinct !{!17, !15}


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