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

; 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 [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 getelementptr inbounds (i8, ptr @str, i64 1))
  %10 = call i64 @strlen(ptr noundef getelementptr inbounds (i8, ptr @str, i64 1)) #6
  %11 = trunc i64 %10 to i32
  store i32 %11, 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 %12

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

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

17:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  %18 = load i32, ptr @m, align 4, !tbaa !5
  store i32 %18, ptr %4, align 4, !tbaa !5
  %19 = load i32, ptr %4, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = mul i64 %20, 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 %21, 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 %22

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

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

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

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

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

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

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

103:                                              ; preds = %84, %68, %56
  br label %104

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

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

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

125:                                              ; preds = %120, %107
  %126 = load i32, ptr %2, align 4, !tbaa !5
  %127 = sub nsw i32 %126, 1
  %128 = load i32, ptr %2, align 4, !tbaa !5
  %129 = sub nsw i32 %128, 1
  call void @_Z6appendii(i32 noundef %127, i32 noundef %129)
  %130 = load i32, ptr %2, align 4, !tbaa !5
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds [300003 x i32], ptr getelementptr inbounds ([2 x [300003 x i32]], ptr @f, i64 0, i64 1), i64 0, i64 %131
  store i32 300003, ptr %132, align 4, !tbaa !5
  %133 = load i32, ptr %2, align 4, !tbaa !5
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds [300003 x i32], ptr @f, i64 0, i64 %134
  store i32 300003, ptr %135, 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 %136

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

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

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

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

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

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

219:                                              ; preds = %140
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  store i32 0, ptr %8, align 4, !tbaa !5
  %220 = load i32, ptr %2, align 4, !tbaa !5
  %221 = sext i32 %220 to i64
  %222 = getelementptr inbounds [300003 x i32], ptr @f, i64 0, i64 %221
  %223 = load i32, ptr %222, align 4, !tbaa !5
  %224 = icmp sle i32 %223, 31
  br i1 %224, label %225, label %233

225:                                              ; preds = %219
  %226 = load i32, ptr %2, align 4, !tbaa !5
  %227 = sext i32 %226 to i64
  %228 = getelementptr inbounds [300003 x i32], ptr @f, i64 0, i64 %227
  %229 = load i32, ptr %228, align 4, !tbaa !5
  %230 = shl i32 1431655765, %229
  %231 = load i32, ptr %8, align 4, !tbaa !5
  %232 = or i32 %231, %230
  store i32 %232, ptr %8, align 4, !tbaa !5
  br label %233

233:                                              ; preds = %225, %219
  %234 = load i32, ptr %2, align 4, !tbaa !5
  %235 = sext i32 %234 to i64
  %236 = getelementptr inbounds [300003 x i32], ptr getelementptr inbounds ([2 x [300003 x i32]], ptr @f, i64 0, i64 1), i64 0, i64 %235
  %237 = load i32, ptr %236, align 4, !tbaa !5
  %238 = icmp sle i32 %237, 31
  br i1 %238, label %239, label %247

239:                                              ; preds = %233
  %240 = load i32, ptr %2, align 4, !tbaa !5
  %241 = sext i32 %240 to i64
  %242 = getelementptr inbounds [300003 x i32], ptr getelementptr inbounds ([2 x [300003 x i32]], ptr @f, i64 0, i64 1), i64 0, i64 %241
  %243 = load i32, ptr %242, align 4, !tbaa !5
  %244 = shl i32 1431655765, %243
  %245 = load i32, ptr %8, align 4, !tbaa !5
  %246 = or i32 %245, %244
  store i32 %246, ptr %8, align 4, !tbaa !5
  br label %247

247:                                              ; preds = %239, %233
  %248 = load i32, ptr %8, align 4, !tbaa !5
  %249 = ashr i32 %248, 1
  %250 = load i32, ptr %2, align 4, !tbaa !5
  %251 = icmp slt i32 %250, 31
  br i1 %251, label %252, label %256

252:                                              ; preds = %247
  %253 = load i32, ptr %2, align 4, !tbaa !5
  %254 = shl i32 1, %253
  %255 = sub nsw i32 %254, 1
  br label %257

256:                                              ; preds = %247
  br label %257

257:                                              ; preds = %256, %252
  %258 = phi i32 [ %255, %252 ], [ 2147483647, %256 ]
  %259 = and i32 %249, %258
  store i32 %259, ptr %8, align 4, !tbaa !5
  %260 = load i32, ptr %8, align 4, !tbaa !5
  %261 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %260)
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  br label %262

262:                                              ; preds = %257
  %263 = load i32, ptr %2, align 4, !tbaa !5
  %264 = add nsw i32 %263, 1
  store i32 %264, ptr %2, align 4, !tbaa !5
  br label %12, !llvm.loop !17

265:                                              ; preds = %16
  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 [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 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
  %.not72 = icmp slt i32 %3, 1
  br i1 %.not72, label %._crit_edge76, label %.lr.ph75

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

.lr.ph75:                                         ; preds = %0, %.thread
  %indvars.iv81 = phi i64 [ %indvars.iv.next82, %.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
  %.not6165 = icmp slt i32 %4, 1
  br i1 %.not6165, label %._crit_edge, label %.lr.ph

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

._crit_edge:                                      ; preds = %41, %.lr.ph75
  %9 = add nsw i64 %indvars.iv81, -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.iv81
  %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
  %.not64 = icmp eq i32 %26, %28
  br i1 %.not64, 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.iv81 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.iv81
  store i32 300003, ptr %47, align 4, !tbaa !5
  %48 = getelementptr inbounds [300003 x i32], ptr @f, i64 0, i64 %indvars.iv81
  store i32 300003, ptr %48, align 4, !tbaa !5
  %49 = load i32, ptr @m, align 4, !tbaa !5
  %.not6267 = icmp slt i32 %49, 1
  br i1 %.not6267, label %.thread, label %.lr.ph70

._crit_edge71:                                    ; preds = %89
  %.pre85 = load i32, ptr %48, align 4, !tbaa !5
  %.pre85.fr = freeze i32 %.pre85
  %.pre86 = load i32, ptr %47, align 4, !tbaa !5
  %.pre86.fr = freeze i32 %.pre86
  %50 = icmp slt i32 %.pre85.fr, 32
  %51 = shl i32 1431655765, %.pre85.fr
  %spec.select = select i1 %50, i32 %51, i32 0
  %52 = icmp slt i32 %.pre86.fr, 32
  %53 = shl i32 1431655765, %.pre86.fr
  %spec.select90 = select i1 %52, i32 %53, i32 0
  %54 = or i32 %spec.select90, %spec.select
  br label %.thread

.thread:                                          ; preds = %._crit_edge71, %45
  %.1 = phi i32 [ 0, %45 ], [ %54, %._crit_edge71 ]
  %55 = lshr i32 %.1, 1
  %56 = icmp ult i64 %indvars.iv81, 31
  %57 = trunc nuw nsw i64 %indvars.iv81 to i32
  %notmask = shl nsw i32 -1, %57
  %58 = xor i32 %notmask, -1
  %59 = select i1 %56, i32 %58, i32 2147483647
  %60 = and i32 %55, %59
  %61 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %60)
  %indvars.iv.next82 = add nuw nsw i64 %indvars.iv81, 1
  %62 = load i32, ptr @n, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %.not.not = icmp slt i64 %indvars.iv81, %63
  br i1 %.not.not, label %.lr.ph75, label %._crit_edge76, !llvm.loop !16

.lr.ph70:                                         ; preds = %45, %89
  %indvars.iv78 = phi i64 [ %indvars.iv.next79, %89 ], [ 1, %45 ]
  %64 = getelementptr inbounds [25 x %struct.Border], ptr @seq, i64 0, i64 %indvars.iv78
  %65 = getelementptr inbounds i8, ptr %64, i64 8
  %66 = load i32, ptr %65, align 4, !tbaa !9
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [300003 x i32], ptr getelementptr inbounds (i8, ptr @f, i64 1200012), i64 0, i64 %67
  %69 = load i32, ptr %68, align 4, !tbaa !5
  %70 = add nsw i32 %69, 1
  %71 = getelementptr inbounds [300003 x i32], ptr @g, i64 0, i64 %67
  store i32 %70, ptr %71, align 4, !tbaa !5
  %72 = getelementptr inbounds [300003 x i32], ptr @f, i64 0, i64 %67
  %73 = load i32, ptr %72, align 4, !tbaa !5
  %74 = add nsw i32 %73, 1
  %75 = getelementptr inbounds [300003 x i32], ptr getelementptr inbounds (i8, ptr @g, i64 1200012), i64 0, i64 %67
  store i32 %74, ptr %75, align 4, !tbaa !5
  %76 = load i32, ptr %64, align 4, !tbaa !12
  %.not63 = icmp eq i32 %76, %66
  br i1 %.not63, label %89, label %77

77:                                               ; preds = %.lr.ph70
  %78 = getelementptr inbounds i8, ptr %64, i64 4
  %79 = load i32, ptr %78, align 4, !tbaa !13
  %80 = sub nsw i32 %66, %79
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [300003 x i32], ptr @g, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !5
  tail call void @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4) %71, i32 noundef %83)
  %84 = load i32, ptr %78, align 4, !tbaa !13
  %85 = sub nsw i32 %66, %84
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [300003 x i32], ptr getelementptr inbounds (i8, ptr @g, i64 1200012), i64 0, i64 %86
  %88 = load i32, ptr %87, align 4, !tbaa !5
  tail call void @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4) %75, i32 noundef %88)
  %.pre84 = load i32, ptr %71, align 4, !tbaa !5
  br label %89

89:                                               ; preds = %77, %.lr.ph70
  %90 = phi i32 [ %.pre84, %77 ], [ %70, %.lr.ph70 ]
  tail call void @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4) %48, i32 noundef %90)
  %91 = load i32, ptr %75, align 4, !tbaa !5
  tail call void @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4) %47, i32 noundef %91)
  %indvars.iv.next79 = add nuw nsw i64 %indvars.iv78, 1
  %92 = load i32, ptr @m, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %.not62.not = icmp slt i64 %indvars.iv78, %93
  br i1 %.not62.not, label %.lr.ph70, label %._crit_edge71, !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