; LLVM IR from tangjz/acm-icpc :: codeforces/complete (756E)

; 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
@a = external dso_local global [300001 x i32], align 16
@b = external dso_local global [300001 x i32], align 16
@len = external dso_local global i32, align 4
@num = external dso_local global [10001 x i32], align 16
@str = external dso_local global [10001 x i8], align 16
@f = external dso_local global [2 x [600003 x i32]], align 16
@sz = external dso_local global [2 x i32], align 4
@cur = external dso_local global i32, align 4
@pre = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z15divideAndRemaini(i32 noundef) #0

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  store i32 1, ptr getelementptr inbounds ([300001 x i32], ptr @a, i64 0, i64 1), align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 2, ptr %2, align 4, !tbaa !5
  br label %15

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

19:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %28

20:                                               ; preds = %15
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds i32, ptr @a, i64 %22
  %24 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %23)
  br label %25

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

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

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

33:                                               ; preds = %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %42

34:                                               ; preds = %29
  %35 = load i32, ptr %3, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds i32, ptr @b, i64 %36
  %38 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %37)
  br label %39

39:                                               ; preds = %34
  %40 = load i32, ptr %3, align 4, !tbaa !5
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %3, align 4, !tbaa !5
  br label %29, !llvm.loop !11

42:                                               ; preds = %33
  %43 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @str)
  %44 = call i64 @strlen(ptr noundef @str) #7
  %45 = trunc i64 %44 to i32
  store i32 %45, ptr @len, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %46

46:                                               ; preds = %90, %42
  %47 = load i32, ptr %4, align 4, !tbaa !5
  %48 = mul nsw i32 %47, 9
  %49 = load i32, ptr @len, align 4, !tbaa !5
  %50 = icmp slt i32 %48, %49
  br i1 %50, label %52, label %51

51:                                               ; preds = %46
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %93

52:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  %53 = load i32, ptr %4, align 4, !tbaa !5
  %54 = mul nsw i32 %53, 9
  store i32 %54, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %55 = load i32, ptr %4, align 4, !tbaa !5
  %56 = add nsw i32 %55, 1
  %57 = mul nsw i32 %56, 9
  store i32 %57, ptr %7, align 4, !tbaa !5
  %58 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %7, ptr noundef nonnull align 4 dereferenceable(4) @len)
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = sub nsw i32 %59, 1
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  store i32 %60, ptr %6, align 4, !tbaa !5
  %61 = load i32, ptr %4, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [10001 x i32], ptr @num, i64 0, i64 %62
  store i32 0, ptr %63, align 4, !tbaa !5
  br label %64

64:                                               ; preds = %69, %52
  %65 = load i32, ptr %5, align 4, !tbaa !5
  %66 = load i32, ptr %6, align 4, !tbaa !5
  %67 = icmp sle i32 %65, %66
  br i1 %67, label %68, label %89

68:                                               ; preds = %64
  br label %69

69:                                               ; preds = %68
  %70 = load i32, ptr %4, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [10001 x i32], ptr @num, i64 0, i64 %71
  %73 = load i32, ptr %72, align 4, !tbaa !5
  %74 = mul nsw i32 %73, 10
  %75 = load i32, ptr @len, align 4, !tbaa !5
  %76 = sub nsw i32 %75, 1
  %77 = load i32, ptr %6, align 4, !tbaa !5
  %78 = add nsw i32 %77, -1
  store i32 %78, ptr %6, align 4, !tbaa !5
  %79 = sub nsw i32 %76, %77
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [10001 x i8], ptr @str, i64 0, i64 %80
  %82 = load i8, ptr %81, align 1, !tbaa !12
  %83 = sext i8 %82 to i32
  %84 = sub nsw i32 %83, 48
  %85 = add nsw i32 %74, %84
  %86 = load i32, ptr %4, align 4, !tbaa !5
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [10001 x i32], ptr @num, i64 0, i64 %87
  store i32 %85, ptr %88, align 4, !tbaa !5
  br label %64, !llvm.loop !13

89:                                               ; preds = %64
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  br label %90

90:                                               ; preds = %89
  %91 = load i32, ptr %4, align 4, !tbaa !5
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr %4, align 4, !tbaa !5
  br label %46, !llvm.loop !14

93:                                               ; preds = %51
  %94 = load i32, ptr @len, align 4, !tbaa !5
  %95 = sub nsw i32 %94, 1
  %96 = sdiv i32 %95, 9
  %97 = add nsw i32 %96, 1
  store i32 %97, ptr @len, align 4, !tbaa !5
  %98 = load i32, ptr @cur, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [2 x [600003 x i32]], ptr @f, i64 0, i64 %99
  %101 = load i32, ptr @cur, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [2 x i32], ptr @sz, i64 0, i64 %102
  %104 = load i32, ptr %103, align 4, !tbaa !5
  %105 = add nsw i32 %104, 1
  store i32 %105, ptr %103, align 4, !tbaa !5
  %106 = sext i32 %104 to i64
  %107 = getelementptr inbounds [600003 x i32], ptr %100, i64 0, i64 %106
  store i32 1, ptr %107, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 1, ptr %8, align 4, !tbaa !5
  br label %108

108:                                              ; preds = %229, %93
  %109 = load i32, ptr %8, align 4, !tbaa !5
  %110 = load i32, ptr @n, align 4, !tbaa !5
  %111 = icmp sle i32 %109, %110
  br i1 %111, label %113, label %112

112:                                              ; preds = %108
  store i32 14, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %232

113:                                              ; preds = %108
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %114 = load i32, ptr %8, align 4, !tbaa !5
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [300001 x i32], ptr @a, i64 0, i64 %115
  %117 = load i32, ptr %116, align 4, !tbaa !5
  %118 = call noundef i32 @_Z15divideAndRemaini(i32 noundef %117)
  store i32 %118, ptr %10, align 4, !tbaa !5
  %119 = load i32, ptr @pre, align 4, !tbaa !5
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds [2 x i32], ptr @sz, i64 0, i64 %120
  store i32 0, ptr %121, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %122 = load i32, ptr %10, align 4, !tbaa !5
  store i32 %122, ptr %11, align 4, !tbaa !5
  br label %123

123:                                              ; preds = %148, %113
  %124 = load i32, ptr %11, align 4, !tbaa !5
  %125 = load i32, ptr @cur, align 4, !tbaa !5
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [2 x i32], ptr @sz, i64 0, i64 %126
  %128 = load i32, ptr %127, align 4, !tbaa !5
  %129 = icmp slt i32 %124, %128
  br i1 %129, label %131, label %130

130:                                              ; preds = %123
  store i32 17, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %160

131:                                              ; preds = %123
  %132 = load i32, ptr @cur, align 4, !tbaa !5
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds [2 x [600003 x i32]], ptr @f, i64 0, i64 %133
  %135 = load i32, ptr %11, align 4, !tbaa !5
  %136 = sext i32 %135 to i64
  %137 = getelementptr inbounds [600003 x i32], ptr %134, i64 0, i64 %136
  %138 = load i32, ptr %137, align 4, !tbaa !5
  %139 = load i32, ptr @pre, align 4, !tbaa !5
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [2 x [600003 x i32]], ptr @f, i64 0, i64 %140
  %142 = load i32, ptr @pre, align 4, !tbaa !5
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds [2 x i32], ptr @sz, i64 0, i64 %143
  %145 = load i32, ptr %144, align 4, !tbaa !5
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds [600003 x i32], ptr %141, i64 0, i64 %146
  store i32 %138, ptr %147, align 4, !tbaa !5
  br label %148

148:                                              ; preds = %131
  %149 = load i32, ptr %8, align 4, !tbaa !5
  %150 = sext i32 %149 to i64
  %151 = getelementptr inbounds [300001 x i32], ptr @a, i64 0, i64 %150
  %152 = load i32, ptr %151, align 4, !tbaa !5
  %153 = load i32, ptr %11, align 4, !tbaa !5
  %154 = add nsw i32 %153, %152
  store i32 %154, ptr %11, align 4, !tbaa !5
  %155 = load i32, ptr @pre, align 4, !tbaa !5
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds [2 x i32], ptr @sz, i64 0, i64 %156
  %158 = load i32, ptr %157, align 4, !tbaa !5
  %159 = add nsw i32 %158, 1
  store i32 %159, ptr %157, align 4, !tbaa !5
  br label %123, !llvm.loop !15

160:                                              ; preds = %130
  %161 = load i32, ptr @pre, align 4, !tbaa !5
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds [2 x i32], ptr @sz, i64 0, i64 %162
  %164 = load i32, ptr %163, align 4, !tbaa !5
  %165 = load i32, ptr %8, align 4, !tbaa !5
  %166 = sext i32 %165 to i64
  %167 = getelementptr inbounds [300001 x i32], ptr @b, i64 0, i64 %166
  %168 = load i32, ptr %167, align 4, !tbaa !5
  %169 = add nsw i32 %164, %168
  %170 = load i32, ptr @cur, align 4, !tbaa !5
  %171 = sext i32 %170 to i64
  %172 = getelementptr inbounds [2 x i32], ptr @sz, i64 0, i64 %171
  store i32 %169, ptr %172, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  store i32 0, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %173

173:                                              ; preds = %225, %160
  %174 = load i32, ptr %12, align 4, !tbaa !5
  %175 = load i32, ptr @cur, align 4, !tbaa !5
  %176 = sext i32 %175 to i64
  %177 = getelementptr inbounds [2 x i32], ptr @sz, i64 0, i64 %176
  %178 = load i32, ptr %177, align 4, !tbaa !5
  %179 = icmp slt i32 %174, %178
  br i1 %179, label %181, label %180

180:                                              ; preds = %173
  store i32 20, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %228

181:                                              ; preds = %173
  %182 = load i32, ptr %12, align 4, !tbaa !5
  %183 = load i32, ptr @pre, align 4, !tbaa !5
  %184 = sext i32 %183 to i64
  %185 = getelementptr inbounds [2 x i32], ptr @sz, i64 0, i64 %184
  %186 = load i32, ptr %185, align 4, !tbaa !5
  %187 = icmp slt i32 %182, %186
  br i1 %187, label %188, label %196

188:                                              ; preds = %181
  %189 = load i32, ptr @pre, align 4, !tbaa !5
  %190 = sext i32 %189 to i64
  %191 = getelementptr inbounds [2 x [600003 x i32]], ptr @f, i64 0, i64 %190
  %192 = load i32, ptr %12, align 4, !tbaa !5
  %193 = sext i32 %192 to i64
  %194 = getelementptr inbounds [600003 x i32], ptr %191, i64 0, i64 %193
  %195 = load i32, ptr %194, align 4, !tbaa !5
  call void @_Z7mod_addRii(ptr noundef nonnull align 4 dereferenceable(4) %13, i32 noundef %195)
  br label %196

196:                                              ; preds = %188, %181
  %197 = load i32, ptr %12, align 4, !tbaa !5
  %198 = load i32, ptr %8, align 4, !tbaa !5
  %199 = sext i32 %198 to i64
  %200 = getelementptr inbounds [300001 x i32], ptr @b, i64 0, i64 %199
  %201 = load i32, ptr %200, align 4, !tbaa !5
  %202 = icmp sgt i32 %197, %201
  br i1 %202, label %203, label %217

203:                                              ; preds = %196
  %204 = load i32, ptr @pre, align 4, !tbaa !5
  %205 = sext i32 %204 to i64
  %206 = getelementptr inbounds [2 x [600003 x i32]], ptr @f, i64 0, i64 %205
  %207 = load i32, ptr %12, align 4, !tbaa !5
  %208 = load i32, ptr %8, align 4, !tbaa !5
  %209 = sext i32 %208 to i64
  %210 = getelementptr inbounds [300001 x i32], ptr @b, i64 0, i64 %209
  %211 = load i32, ptr %210, align 4, !tbaa !5
  %212 = sub nsw i32 %207, %211
  %213 = sub nsw i32 %212, 1
  %214 = sext i32 %213 to i64
  %215 = getelementptr inbounds [600003 x i32], ptr %206, i64 0, i64 %214
  %216 = load i32, ptr %215, align 4, !tbaa !5
  call void @_Z7mod_subRii(ptr noundef nonnull align 4 dereferenceable(4) %13, i32 noundef %216)
  br label %217

217:                                              ; preds = %203, %196
  %218 = load i32, ptr %13, align 4, !tbaa !5
  %219 = load i32, ptr @cur, align 4, !tbaa !5
  %220 = sext i32 %219 to i64
  %221 = getelementptr inbounds [2 x [600003 x i32]], ptr @f, i64 0, i64 %220
  %222 = load i32, ptr %12, align 4, !tbaa !5
  %223 = sext i32 %222 to i64
  %224 = getelementptr inbounds [600003 x i32], ptr %221, i64 0, i64 %223
  store i32 %218, ptr %224, align 4, !tbaa !5
  br label %225

225:                                              ; preds = %217
  %226 = load i32, ptr %12, align 4, !tbaa !5
  %227 = add nsw i32 %226, 1
  store i32 %227, ptr %12, align 4, !tbaa !5
  br label %173, !llvm.loop !16

228:                                              ; preds = %180
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %229

229:                                              ; preds = %228
  %230 = load i32, ptr %8, align 4, !tbaa !5
  %231 = add nsw i32 %230, 1
  store i32 %231, ptr %8, align 4, !tbaa !5
  br label %108, !llvm.loop !17

232:                                              ; preds = %112
  %233 = load i32, ptr @len, align 4, !tbaa !5
  %234 = icmp eq i32 %233, 1
  br i1 %234, label %235, label %250

235:                                              ; preds = %232
  %236 = load i32, ptr @num, align 16, !tbaa !5
  %237 = load i32, ptr @cur, align 4, !tbaa !5
  %238 = sext i32 %237 to i64
  %239 = getelementptr inbounds [2 x i32], ptr @sz, i64 0, i64 %238
  %240 = load i32, ptr %239, align 4, !tbaa !5
  %241 = icmp slt i32 %236, %240
  br i1 %241, label %242, label %250

242:                                              ; preds = %235
  %243 = load i32, ptr @cur, align 4, !tbaa !5
  %244 = sext i32 %243 to i64
  %245 = getelementptr inbounds [2 x [600003 x i32]], ptr @f, i64 0, i64 %244
  %246 = load i32, ptr @num, align 16, !tbaa !5
  %247 = sext i32 %246 to i64
  %248 = getelementptr inbounds [600003 x i32], ptr %245, i64 0, i64 %247
  %249 = load i32, ptr %248, align 4, !tbaa !5
  br label %251

250:                                              ; preds = %235, %232
  br label %251

251:                                              ; preds = %250, %242
  %252 = phi i32 [ %249, %242 ], [ 0, %250 ]
  %253 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %252)
  ret i32 0
}

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

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

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

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

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

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

attributes #0 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { 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 #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 }
attributes #7 = { 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.mustprogress"}
!11 = distinct !{!11, !10}
!12 = !{!7, !7, i64 0}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !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 global i32, align 4
@a = external dso_local global [300001 x i32], align 16
@b = external dso_local global [300001 x i32], align 16
@len = external dso_local global i32, align 4
@num = external dso_local local_unnamed_addr global [10001 x i32], align 16
@str = external dso_local global [10001 x i8], align 16
@f = external dso_local local_unnamed_addr global [2 x [600003 x i32]], align 16
@sz = external dso_local local_unnamed_addr global [2 x i32], align 4
@cur = external dso_local local_unnamed_addr global i32, align 4
@pre = external dso_local local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

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

; Function Attrs: mustprogress norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  store i32 1, ptr getelementptr inbounds (i8, ptr @a, i64 4), align 4, !tbaa !5
  %4 = load i32, ptr @n, align 4, !tbaa !5
  %.not49 = icmp slt i32 %4, 2
  br i1 %.not49, label %.preheader, label %.lr.ph

.preheader:                                       ; preds = %.lr.ph, %0
  %5 = phi i32 [ %4, %0 ], [ %8, %.lr.ph ]
  %.not4451 = icmp slt i32 %5, 1
  br i1 %.not4451, label %._crit_edge, label %.lr.ph53

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 2, %0 ]
  %6 = getelementptr inbounds i32, ptr @a, i64 %indvars.iv
  %7 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %6)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %8 = load i32, ptr @n, align 4, !tbaa !5
  %9 = sext i32 %8 to i64
  %.not.not = icmp slt i64 %indvars.iv, %9
  br i1 %.not.not, label %.lr.ph, label %.preheader, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph53, %.preheader
  %10 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @str)
  %11 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) @str) #6
  %12 = trunc i64 %11 to i32
  store i32 %12, ptr @len, align 4, !tbaa !5
  %13 = icmp sgt i32 %12, 0
  br i1 %13, label %.lr.ph61, label %._crit_edge62

.lr.ph53:                                         ; preds = %.preheader, %.lr.ph53
  %indvars.iv81 = phi i64 [ %indvars.iv.next82, %.lr.ph53 ], [ 1, %.preheader ]
  %14 = getelementptr inbounds i32, ptr @b, i64 %indvars.iv81
  %15 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %14)
  %indvars.iv.next82 = add nuw nsw i64 %indvars.iv81, 1
  %16 = load i32, ptr @n, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %.not44.not = icmp slt i64 %indvars.iv81, %17
  br i1 %.not44.not, label %.lr.ph53, label %._crit_edge, !llvm.loop !11

.loopexit.loopexit.unr-lcssa:                     ; preds = %52, %.lr.ph58
  %.lcssa110.ph = phi i32 [ poison, %.lr.ph58 ], [ %71, %52 ]
  %indvars.iv84.unr = phi i64 [ %48, %.lr.ph58 ], [ %indvars.iv.next85.1, %52 ]
  %storemerge55.unr = phi i32 [ 0, %.lr.ph58 ], [ %71, %52 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.loopexit, label %.loopexit.loopexit.epilog-lcssa

.loopexit.loopexit.epilog-lcssa:                  ; preds = %.loopexit.loopexit.unr-lcssa
  %18 = mul nsw i32 %storemerge55.unr, 10
  %19 = trunc nsw i64 %indvars.iv84.unr to i32
  %20 = sub i32 %.pre, %19
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [10001 x i8], ptr @str, i64 0, i64 %21
  %23 = load i8, ptr %22, align 1, !tbaa !12
  %24 = sext i8 %23 to i32
  %25 = add i32 %18, -48
  %26 = add i32 %25, %24
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit.epilog-lcssa, %.loopexit.loopexit.unr-lcssa, %.lr.ph61
  %storemerge.lcssa = phi i32 [ 0, %.lr.ph61 ], [ %.lcssa110.ph, %.loopexit.loopexit.unr-lcssa ], [ %26, %.loopexit.loopexit.epilog-lcssa ]
  store i32 %storemerge.lcssa, ptr %45, align 4, !tbaa !5
  %27 = sext i32 %.pre to i64
  %28 = icmp slt i64 %41, %27
  br i1 %28, label %.lr.ph61, label %._crit_edge62, !llvm.loop !13

._crit_edge62:                                    ; preds = %.loopexit, %._crit_edge
  %.lcssa48 = phi i32 [ %12, %._crit_edge ], [ %.pre, %.loopexit ]
  %29 = add nsw i32 %.lcssa48, -1
  %30 = sdiv i32 %29, 9
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr @len, align 4, !tbaa !5
  %32 = load i32, ptr @cur, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [2 x i32], ptr @sz, i64 0, i64 %33
  %35 = load i32, ptr %34, align 4, !tbaa !5
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %34, align 4, !tbaa !5
  %37 = sext i32 %35 to i64
  %38 = getelementptr inbounds [2 x [600003 x i32]], ptr @f, i64 0, i64 %33, i64 %37
  store i32 1, ptr %38, align 4, !tbaa !5
  %39 = load i32, ptr @n, align 4, !tbaa !5
  %.not4574 = icmp slt i32 %39, 1
  br i1 %.not4574, label %._crit_edge78, label %.lr.ph77

.lr.ph61:                                         ; preds = %._crit_edge, %.loopexit
  %indvars.iv87 = phi i64 [ %indvars.iv.next88, %.loopexit ], [ 0, %._crit_edge ]
  %40 = phi i32 [ %42, %.loopexit ], [ 0, %._crit_edge ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  %indvars.iv.next88 = add nuw nsw i64 %indvars.iv87, 1
  %41 = mul nuw nsw i64 %indvars.iv.next88, 9
  %42 = trunc nsw i64 %41 to i32
  store i32 %42, ptr %1, align 4, !tbaa !5
  %43 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 4 dereferenceable(4) @len)
  %44 = load i32, ptr %43, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  %45 = getelementptr inbounds [10001 x i32], ptr @num, i64 0, i64 %indvars.iv87
  %.not46.not54 = icmp slt i32 %40, %44
  %.pre = load i32, ptr @len, align 4, !tbaa !5
  br i1 %.not46.not54, label %.lr.ph58, label %.loopexit

.lr.ph58:                                         ; preds = %.lr.ph61
  %46 = mul nsw i64 %indvars.iv87, -9
  %47 = add i64 %46, -1
  %48 = sext i32 %44 to i64
  %49 = add i64 %46, %48
  %xtraiter = and i64 %49, 1
  %50 = sub nsw i64 0, %48
  %51 = icmp eq i64 %47, %50
  br i1 %51, label %.loopexit.loopexit.unr-lcssa, label %.lr.ph58.new

.lr.ph58.new:                                     ; preds = %.lr.ph58
  %unroll_iter = and i64 %49, -2
  br label %52

52:                                               ; preds = %52, %.lr.ph58.new
  %indvars.iv84 = phi i64 [ %48, %.lr.ph58.new ], [ %indvars.iv.next85.1, %52 ]
  %storemerge55 = phi i32 [ 0, %.lr.ph58.new ], [ %71, %52 ]
  %niter = phi i64 [ 0, %.lr.ph58.new ], [ %niter.next.1, %52 ]
  %53 = mul nsw i32 %storemerge55, 10
  %54 = trunc nsw i64 %indvars.iv84 to i32
  %55 = sub i32 %.pre, %54
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [10001 x i8], ptr @str, i64 0, i64 %56
  %58 = load i8, ptr %57, align 1, !tbaa !12
  %59 = sext i8 %58 to i32
  %60 = add i32 %53, -48
  %61 = add i32 %60, %59
  %indvars.iv.next85.1 = add nsw i64 %indvars.iv84, -2
  %62 = mul nsw i32 %61, 10
  %63 = trunc i64 %indvars.iv84 to i32
  %64 = add i32 %63, -1
  %65 = sub i32 %.pre, %64
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [10001 x i8], ptr @str, i64 0, i64 %66
  %68 = load i8, ptr %67, align 1, !tbaa !12
  %69 = sext i8 %68 to i32
  %70 = add i32 %62, -48
  %71 = add i32 %70, %69
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1.not = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1.not, label %.loopexit.loopexit.unr-lcssa, label %52, !llvm.loop !14

._crit_edge78.loopexit:                           ; preds = %._crit_edge73
  %.pre99 = load i32, ptr @len, align 4, !tbaa !5
  br label %._crit_edge78

._crit_edge78:                                    ; preds = %._crit_edge78.loopexit, %._crit_edge62
  %72 = phi i32 [ %104, %._crit_edge78.loopexit ], [ %32, %._crit_edge62 ]
  %73 = phi i32 [ %.pre99, %._crit_edge78.loopexit ], [ %31, %._crit_edge62 ]
  %74 = icmp eq i32 %73, 1
  br i1 %74, label %138, label %148

.lr.ph77:                                         ; preds = %._crit_edge62, %._crit_edge73
  %indvars.iv96 = phi i64 [ %indvars.iv.next97, %._crit_edge73 ], [ 1, %._crit_edge62 ]
  %75 = getelementptr inbounds [300001 x i32], ptr @a, i64 0, i64 %indvars.iv96
  %76 = load i32, ptr %75, align 4, !tbaa !5
  %77 = call noundef i32 @_Z15divideAndRemaini(i32 noundef %76)
  %78 = load i32, ptr @pre, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [2 x i32], ptr @sz, i64 0, i64 %79
  %81 = load i32, ptr @cur, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [2 x i32], ptr @sz, i64 0, i64 %82
  store i32 0, ptr %80, align 4, !tbaa !5
  %84 = load i32, ptr %83, align 4, !tbaa !5
  %85 = icmp slt i32 %77, %84
  br i1 %85, label %.lr.ph67, label %._crit_edge68

.lr.ph67:                                         ; preds = %.lr.ph77
  %86 = load i32, ptr %75, align 4, !tbaa !5
  %87 = sext i32 %77 to i64
  %88 = sext i32 %86 to i64
  br label %94

._crit_edge68:                                    ; preds = %94, %.lr.ph77
  %89 = phi i32 [ 0, %.lr.ph77 ], [ %100, %94 ]
  %90 = getelementptr inbounds [300001 x i32], ptr @b, i64 0, i64 %indvars.iv96
  %91 = load i32, ptr %90, align 4, !tbaa !5
  %92 = add nsw i32 %91, %89
  store i32 %92, ptr %83, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  store i32 0, ptr %2, align 4, !tbaa !5
  %93 = icmp sgt i32 %92, 0
  br i1 %93, label %.lr.ph72, label %._crit_edge73

94:                                               ; preds = %.lr.ph67, %94
  %95 = phi i32 [ 0, %.lr.ph67 ], [ %100, %94 ]
  %indvars.iv90 = phi i64 [ %87, %.lr.ph67 ], [ %indvars.iv.next91, %94 ]
  %96 = getelementptr inbounds [2 x [600003 x i32]], ptr @f, i64 0, i64 %82, i64 %indvars.iv90
  %97 = load i32, ptr %96, align 4, !tbaa !5
  %98 = zext nneg i32 %95 to i64
  %99 = getelementptr inbounds [2 x [600003 x i32]], ptr @f, i64 0, i64 %79, i64 %98
  store i32 %97, ptr %99, align 4, !tbaa !5
  %indvars.iv.next91 = add nsw i64 %indvars.iv90, %88
  %100 = add nuw nsw i32 %95, 1
  store i32 %100, ptr %80, align 4, !tbaa !5
  %101 = load i32, ptr %83, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = icmp slt i64 %indvars.iv.next91, %102
  br i1 %103, label %94, label %._crit_edge68, !llvm.loop !15

._crit_edge73:                                    ; preds = %129, %._crit_edge68
  %104 = phi i32 [ %81, %._crit_edge68 ], [ %131, %129 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  %indvars.iv.next97 = add nuw nsw i64 %indvars.iv96, 1
  %105 = load i32, ptr @n, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %.not45.not = icmp slt i64 %indvars.iv96, %106
  br i1 %.not45.not, label %.lr.ph77, label %._crit_edge78.loopexit, !llvm.loop !16

.lr.ph72:                                         ; preds = %._crit_edge68, %129
  %indvars.iv93 = phi i64 [ %indvars.iv.next94, %129 ], [ 0, %._crit_edge68 ]
  %107 = load i32, ptr @pre, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [2 x i32], ptr @sz, i64 0, i64 %108
  %110 = load i32, ptr %109, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = icmp slt i64 %indvars.iv93, %111
  br i1 %112, label %113, label %116

113:                                              ; preds = %.lr.ph72
  %114 = getelementptr inbounds [2 x [600003 x i32]], ptr @f, i64 0, i64 %108, i64 %indvars.iv93
  %115 = load i32, ptr %114, align 4, !tbaa !5
  call void @_Z7mod_addRii(ptr noundef nonnull align 4 dereferenceable(4) %2, i32 noundef %115)
  br label %116

116:                                              ; preds = %113, %.lr.ph72
  %117 = load i32, ptr %90, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = icmp sgt i64 %indvars.iv93, %118
  br i1 %119, label %120, label %129

120:                                              ; preds = %116
  %121 = load i32, ptr @pre, align 4, !tbaa !5
  %122 = sext i32 %121 to i64
  %123 = xor i32 %117, -1
  %124 = trunc nuw nsw i64 %indvars.iv93 to i32
  %125 = add i32 %124, %123
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [2 x [600003 x i32]], ptr @f, i64 0, i64 %122, i64 %126
  %128 = load i32, ptr %127, align 4, !tbaa !5
  call void @_Z7mod_subRii(ptr noundef nonnull align 4 dereferenceable(4) %2, i32 noundef %128)
  br label %129

129:                                              ; preds = %120, %116
  %130 = load i32, ptr %2, align 4, !tbaa !5
  %131 = load i32, ptr @cur, align 4, !tbaa !5
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [2 x [600003 x i32]], ptr @f, i64 0, i64 %132, i64 %indvars.iv93
  store i32 %130, ptr %133, align 4, !tbaa !5
  %indvars.iv.next94 = add nuw nsw i64 %indvars.iv93, 1
  %134 = getelementptr inbounds [2 x i32], ptr @sz, i64 0, i64 %132
  %135 = load i32, ptr %134, align 4, !tbaa !5
  %136 = sext i32 %135 to i64
  %137 = icmp slt i64 %indvars.iv.next94, %136
  br i1 %137, label %.lr.ph72, label %._crit_edge73, !llvm.loop !17

138:                                              ; preds = %._crit_edge78
  %139 = load i32, ptr @num, align 16, !tbaa !5
  %140 = sext i32 %72 to i64
  %141 = getelementptr inbounds [2 x i32], ptr @sz, i64 0, i64 %140
  %142 = load i32, ptr %141, align 4, !tbaa !5
  %143 = icmp slt i32 %139, %142
  br i1 %143, label %144, label %148

144:                                              ; preds = %138
  %145 = sext i32 %139 to i64
  %146 = getelementptr inbounds [2 x [600003 x i32]], ptr @f, i64 0, i64 %140, i64 %145
  %147 = load i32, ptr %146, align 4, !tbaa !5
  br label %148

148:                                              ; preds = %._crit_edge78, %138, %144
  %149 = phi i32 [ %147, %144 ], [ 0, %138 ], [ 0, %._crit_edge78 ]
  %150 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %149)
  ret i32 0
}

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

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

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

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

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

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

attributes #0 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #4 = { 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 #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 = distinct !{!11, !10}
!12 = !{!7, !7, i64 0}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}


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