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

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

@t = external dso_local global i32, align 4
@p = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@a = external dso_local global [1000001 x i32], align 16
@b = external dso_local global [1000001 x i32], align 16
@pos = external dso_local global [1000001 x i32], align 16
@f = external dso_local global [1000001 x i32], align 16
@sz = external dso_local global i32, align 4
@out = external dso_local global [1000001 x i32], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = 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
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t, ptr noundef @p)
  br label %12

12:                                               ; preds = %210, %0
  %13 = load i32, ptr @t, align 4, !tbaa !5
  %14 = add nsw i32 %13, -1
  store i32 %14, ptr @t, align 4, !tbaa !5
  %15 = icmp ne i32 %13, 0
  br i1 %15, label %16, label %212

16:                                               ; preds = %12
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m)
  %18 = load i32, ptr @p, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = mul i64 %19, 4
  call void @llvm.memset.p0.i64(ptr align 4 getelementptr inbounds (i32, ptr @pos, i64 1), i8 -1, i64 %20, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %57, %16
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = load i32, ptr @n, align 4, !tbaa !5
  %24 = icmp slt i32 %22, %23
  br i1 %24, label %26, label %25

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

26:                                               ; preds = %21
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds i32, ptr @a, i64 %28
  %30 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %29)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [1000001 x i32], ptr @a, i64 0, i64 %32
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [1000001 x i32], ptr @pos, i64 0, i64 %35
  %37 = load i32, ptr %36, align 4, !tbaa !5
  store i32 %37, ptr %3, align 4, !tbaa !5
  %38 = load i32, ptr %2, align 4, !tbaa !5
  %39 = load i32, ptr %2, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [1000001 x i32], ptr @a, i64 0, i64 %40
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [1000001 x i32], ptr @pos, i64 0, i64 %43
  store i32 %38, ptr %44, align 4, !tbaa !5
  %45 = load i32, ptr %3, align 4, !tbaa !5
  %46 = icmp slt i32 %45, 0
  br i1 %46, label %47, label %48

47:                                               ; preds = %26
  br label %52

48:                                               ; preds = %26
  %49 = load i32, ptr %2, align 4, !tbaa !5
  %50 = load i32, ptr %3, align 4, !tbaa !5
  %51 = sub nsw i32 %49, %50
  br label %52

52:                                               ; preds = %48, %47
  %53 = phi i32 [ -1, %47 ], [ %51, %48 ]
  %54 = load i32, ptr %2, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [1000001 x i32], ptr @a, i64 0, i64 %55
  store i32 %53, ptr %56, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %57

57:                                               ; preds = %52
  %58 = load i32, ptr %2, align 4, !tbaa !5
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %2, align 4, !tbaa !5
  br label %21, !llvm.loop !9

60:                                               ; preds = %25
  %61 = load i32, ptr @p, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = mul i64 %62, 4
  call void @llvm.memset.p0.i64(ptr align 4 getelementptr inbounds (i32, ptr @pos, i64 1), i8 -1, i64 %63, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %64

64:                                               ; preds = %100, %60
  %65 = load i32, ptr %4, align 4, !tbaa !5
  %66 = load i32, ptr @m, align 4, !tbaa !5
  %67 = icmp slt i32 %65, %66
  br i1 %67, label %69, label %68

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

69:                                               ; preds = %64
  %70 = load i32, ptr %4, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds i32, ptr @b, i64 %71
  %73 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %72)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  %74 = load i32, ptr %4, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [1000001 x i32], ptr @b, i64 0, i64 %75
  %77 = load i32, ptr %76, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [1000001 x i32], ptr @pos, i64 0, i64 %78
  %80 = load i32, ptr %79, align 4, !tbaa !5
  store i32 %80, ptr %5, align 4, !tbaa !5
  %81 = load i32, ptr %4, align 4, !tbaa !5
  %82 = load i32, ptr %4, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [1000001 x i32], ptr @b, i64 0, i64 %83
  %85 = load i32, ptr %84, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [1000001 x i32], ptr @pos, i64 0, i64 %86
  store i32 %81, ptr %87, align 4, !tbaa !5
  %88 = load i32, ptr %5, align 4, !tbaa !5
  %89 = icmp slt i32 %88, 0
  br i1 %89, label %90, label %91

90:                                               ; preds = %69
  br label %95

91:                                               ; preds = %69
  %92 = load i32, ptr %4, align 4, !tbaa !5
  %93 = load i32, ptr %5, align 4, !tbaa !5
  %94 = sub nsw i32 %92, %93
  br label %95

95:                                               ; preds = %91, %90
  %96 = phi i32 [ -1, %90 ], [ %94, %91 ]
  %97 = load i32, ptr %4, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [1000001 x i32], ptr @b, i64 0, i64 %98
  store i32 %96, ptr %99, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  br label %100

100:                                              ; preds = %95
  %101 = load i32, ptr %4, align 4, !tbaa !5
  %102 = add nsw i32 %101, 1
  store i32 %102, ptr %4, align 4, !tbaa !5
  br label %64, !llvm.loop !11

103:                                              ; preds = %68
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 1, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %104

104:                                              ; preds = %139, %103
  %105 = load i32, ptr %6, align 4, !tbaa !5
  %106 = load i32, ptr @m, align 4, !tbaa !5
  %107 = icmp slt i32 %105, %106
  br i1 %107, label %109, label %108

108:                                              ; preds = %104
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %142

109:                                              ; preds = %104
  br label %110

110:                                              ; preds = %121, %109
  %111 = load i32, ptr %7, align 4, !tbaa !5
  %112 = icmp ne i32 %111, 0
  br i1 %112, label %113, label %118

113:                                              ; preds = %110
  %114 = load i32, ptr %7, align 4, !tbaa !5
  %115 = load i32, ptr %6, align 4, !tbaa !5
  %116 = call noundef zeroext i1 @_Z3chkPiiS_i(ptr noundef @b, i32 noundef %114, ptr noundef @b, i32 noundef %115)
  %117 = xor i1 %116, true
  br label %118

118:                                              ; preds = %113, %110
  %119 = phi i1 [ false, %110 ], [ %117, %113 ]
  br i1 %119, label %120, label %126

120:                                              ; preds = %118
  br label %121

121:                                              ; preds = %120
  %122 = load i32, ptr %7, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %123
  %125 = load i32, ptr %124, align 4, !tbaa !5
  store i32 %125, ptr %7, align 4, !tbaa !5
  br label %110, !llvm.loop !12

126:                                              ; preds = %118
  %127 = load i32, ptr %7, align 4, !tbaa !5
  %128 = load i32, ptr %6, align 4, !tbaa !5
  %129 = call noundef zeroext i1 @_Z3chkPiiS_i(ptr noundef @b, i32 noundef %127, ptr noundef @b, i32 noundef %128)
  br i1 %129, label %130, label %133

130:                                              ; preds = %126
  %131 = load i32, ptr %7, align 4, !tbaa !5
  %132 = add nsw i32 %131, 1
  store i32 %132, ptr %7, align 4, !tbaa !5
  br label %133

133:                                              ; preds = %130, %126
  %134 = load i32, ptr %7, align 4, !tbaa !5
  %135 = load i32, ptr %6, align 4, !tbaa !5
  %136 = add nsw i32 %135, 1
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %137
  store i32 %134, ptr %138, align 4, !tbaa !5
  br label %139

139:                                              ; preds = %133
  %140 = load i32, ptr %6, align 4, !tbaa !5
  %141 = add nsw i32 %140, 1
  store i32 %141, ptr %6, align 4, !tbaa !5
  br label %104, !llvm.loop !13

142:                                              ; preds = %108
  store i32 0, ptr @sz, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 0, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %143

143:                                              ; preds = %190, %142
  %144 = load i32, ptr %8, align 4, !tbaa !5
  %145 = load i32, ptr @n, align 4, !tbaa !5
  %146 = icmp slt i32 %144, %145
  br i1 %146, label %148, label %147

147:                                              ; preds = %143
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %193

148:                                              ; preds = %143
  br label %149

149:                                              ; preds = %160, %148
  %150 = load i32, ptr %9, align 4, !tbaa !5
  %151 = icmp ne i32 %150, 0
  br i1 %151, label %152, label %157

152:                                              ; preds = %149
  %153 = load i32, ptr %9, align 4, !tbaa !5
  %154 = load i32, ptr %8, align 4, !tbaa !5
  %155 = call noundef zeroext i1 @_Z3chkPiiS_i(ptr noundef @b, i32 noundef %153, ptr noundef @a, i32 noundef %154)
  %156 = xor i1 %155, true
  br label %157

157:                                              ; preds = %152, %149
  %158 = phi i1 [ false, %149 ], [ %156, %152 ]
  br i1 %158, label %159, label %165

159:                                              ; preds = %157
  br label %160

160:                                              ; preds = %159
  %161 = load i32, ptr %9, align 4, !tbaa !5
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %162
  %164 = load i32, ptr %163, align 4, !tbaa !5
  store i32 %164, ptr %9, align 4, !tbaa !5
  br label %149, !llvm.loop !14

165:                                              ; preds = %157
  %166 = load i32, ptr %9, align 4, !tbaa !5
  %167 = load i32, ptr %8, align 4, !tbaa !5
  %168 = call noundef zeroext i1 @_Z3chkPiiS_i(ptr noundef @b, i32 noundef %166, ptr noundef @a, i32 noundef %167)
  br i1 %168, label %169, label %172

169:                                              ; preds = %165
  %170 = load i32, ptr %9, align 4, !tbaa !5
  %171 = add nsw i32 %170, 1
  store i32 %171, ptr %9, align 4, !tbaa !5
  br label %172

172:                                              ; preds = %169, %165
  %173 = load i32, ptr %9, align 4, !tbaa !5
  %174 = load i32, ptr @m, align 4, !tbaa !5
  %175 = icmp eq i32 %173, %174
  br i1 %175, label %176, label %189

176:                                              ; preds = %172
  %177 = load i32, ptr %8, align 4, !tbaa !5
  %178 = load i32, ptr @m, align 4, !tbaa !5
  %179 = sub nsw i32 %177, %178
  %180 = add nsw i32 %179, 2
  %181 = load i32, ptr @sz, align 4, !tbaa !5
  %182 = add nsw i32 %181, 1
  store i32 %182, ptr @sz, align 4, !tbaa !5
  %183 = sext i32 %181 to i64
  %184 = getelementptr inbounds [1000001 x i32], ptr @out, i64 0, i64 %183
  store i32 %180, ptr %184, align 4, !tbaa !5
  %185 = load i32, ptr %9, align 4, !tbaa !5
  %186 = sext i32 %185 to i64
  %187 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %186
  %188 = load i32, ptr %187, align 4, !tbaa !5
  store i32 %188, ptr %9, align 4, !tbaa !5
  br label %189

189:                                              ; preds = %176, %172
  br label %190

190:                                              ; preds = %189
  %191 = load i32, ptr %8, align 4, !tbaa !5
  %192 = add nsw i32 %191, 1
  store i32 %192, ptr %8, align 4, !tbaa !5
  br label %143, !llvm.loop !15

193:                                              ; preds = %147
  %194 = load i32, ptr @sz, align 4, !tbaa !5
  %195 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %194)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %196

196:                                              ; preds = %207, %193
  %197 = load i32, ptr %10, align 4, !tbaa !5
  %198 = load i32, ptr @sz, align 4, !tbaa !5
  %199 = icmp slt i32 %197, %198
  br i1 %199, label %201, label %200

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

201:                                              ; preds = %196
  %202 = load i32, ptr %10, align 4, !tbaa !5
  %203 = sext i32 %202 to i64
  %204 = getelementptr inbounds [1000001 x i32], ptr @out, i64 0, i64 %203
  %205 = load i32, ptr %204, align 4, !tbaa !5
  %206 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %205)
  br label %207

207:                                              ; preds = %201
  %208 = load i32, ptr %10, align 4, !tbaa !5
  %209 = add nsw i32 %208, 1
  store i32 %209, ptr %10, align 4, !tbaa !5
  br label %196, !llvm.loop !16

210:                                              ; preds = %200
  %211 = call i32 @putchar(i32 noundef 10)
  br label %12, !llvm.loop !17

212:                                              ; preds = %12
  ret i32 0
}

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

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

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

; 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 noundef zeroext i1 @_Z3chkPiiS_i(ptr noundef, i32 noundef, ptr noundef, i32 noundef) #4

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

; Function Attrs: inlinehint mustprogress uwtable
declare i32 @putchar(i32 noundef) #5

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

@t = external dso_local global i32, align 4
@p = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@a = external dso_local global [1000001 x i32], align 16
@b = external dso_local global [1000001 x i32], align 16
@pos = external dso_local local_unnamed_addr global [1000001 x i32], align 16
@f = external dso_local local_unnamed_addr global [1000001 x i32], align 16
@sz = external dso_local local_unnamed_addr global i32, align 4
@out = external dso_local local_unnamed_addr global [1000001 x i32], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = 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 @t, ptr noundef nonnull @p)
  %2 = load i32, ptr @t, align 4, !tbaa !5
  %3 = add nsw i32 %2, -1
  store i32 %3, ptr @t, align 4, !tbaa !5
  %.not88 = icmp eq i32 %2, 0
  br i1 %.not88, label %._crit_edge91, label %.lr.ph90

.lr.ph90:                                         ; preds = %0, %._crit_edge87
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %5 = load i32, ptr @p, align 4, !tbaa !5
  %6 = sext i32 %5 to i64
  %7 = shl nsw i64 %6, 2
  tail call void @llvm.memset.p0.i64(ptr nonnull align 4 getelementptr inbounds (i8, ptr @pos, i64 4), i8 -1, i64 %7, i1 false)
  %8 = load i32, ptr @n, align 4, !tbaa !5
  %9 = icmp sgt i32 %8, 0
  br i1 %9, label %.lr.ph, label %._crit_edge

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %.pre = load i32, ptr @p, align 4, !tbaa !5
  %.pre103 = sext i32 %.pre to i64
  %.pre104 = shl nsw i64 %.pre103, 2
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.lr.ph90
  %.pre-phi105 = phi i64 [ %.pre104, %._crit_edge.loopexit ], [ %7, %.lr.ph90 ]
  tail call void @llvm.memset.p0.i64(ptr nonnull align 4 getelementptr inbounds (i8, ptr @pos, i64 4), i8 -1, i64 %.pre-phi105, i1 false)
  %10 = load i32, ptr @m, align 4, !tbaa !5
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %.lr.ph66, label %._crit_edge74

.lr.ph:                                           ; preds = %.lr.ph90, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.lr.ph90 ]
  %12 = getelementptr inbounds i32, ptr @a, i64 %indvars.iv
  %13 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %12)
  %14 = load i32, ptr %12, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [1000001 x i32], ptr @pos, i64 0, i64 %15
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %18 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %18, ptr %16, align 4, !tbaa !5
  %19 = sub nsw i32 %18, %17
  %.inv59 = icmp sgt i32 %17, -1
  %20 = select i1 %.inv59, i32 %19, i32 -1
  store i32 %20, ptr %12, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %21 = load i32, ptr @n, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = icmp slt i64 %indvars.iv.next, %22
  br i1 %23, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !9

.preheader62:                                     ; preds = %.lr.ph66
  %24 = icmp sgt i32 %34, 1
  br i1 %24, label %.preheader61, label %._crit_edge74

.lr.ph66:                                         ; preds = %._crit_edge, %.lr.ph66
  %indvars.iv93 = phi i64 [ %indvars.iv.next94, %.lr.ph66 ], [ 0, %._crit_edge ]
  %25 = getelementptr inbounds i32, ptr @b, i64 %indvars.iv93
  %26 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %25)
  %27 = load i32, ptr %25, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [1000001 x i32], ptr @pos, i64 0, i64 %28
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = trunc nuw nsw i64 %indvars.iv93 to i32
  store i32 %31, ptr %29, align 4, !tbaa !5
  %32 = sub nsw i32 %31, %30
  %.inv = icmp sgt i32 %30, -1
  %33 = select i1 %.inv, i32 %32, i32 -1
  store i32 %33, ptr %25, align 4, !tbaa !5
  %indvars.iv.next94 = add nuw nsw i64 %indvars.iv93, 1
  %34 = load i32, ptr @m, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = icmp slt i64 %indvars.iv.next94, %35
  br i1 %36, label %.lr.ph66, label %.preheader62, !llvm.loop !11

.preheader61:                                     ; preds = %.preheader62, %.critedge
  %indvars.iv96 = phi i64 [ %indvars.iv.next97, %.critedge ], [ 1, %.preheader62 ]
  %.05073 = phi i32 [ %spec.select, %.critedge ], [ 0, %.preheader62 ]
  %.not5867 = icmp eq i32 %.05073, 0
  %.pre106 = trunc nuw nsw i64 %indvars.iv96 to i32
  br i1 %.not5867, label %.critedge, label %.lr.ph69

._crit_edge74:                                    ; preds = %.critedge, %._crit_edge, %.preheader62
  store i32 0, ptr @sz, align 4, !tbaa !5
  %37 = load i32, ptr @n, align 4, !tbaa !5
  %38 = icmp sgt i32 %37, 0
  br i1 %38, label %.preheader, label %._crit_edge83

.lr.ph69:                                         ; preds = %.preheader61, %40
  %.15168 = phi i32 [ %43, %40 ], [ %.05073, %.preheader61 ]
  %39 = tail call noundef zeroext i1 @_Z3chkPiiS_i(ptr noundef nonnull @b, i32 noundef %.15168, ptr noundef nonnull @b, i32 noundef %.pre106)
  br i1 %39, label %.critedge, label %40

40:                                               ; preds = %.lr.ph69
  %41 = sext i32 %.15168 to i64
  %42 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %.not58 = icmp eq i32 %43, 0
  br i1 %.not58, label %.critedge, label %.lr.ph69, !llvm.loop !12

.critedge:                                        ; preds = %.lr.ph69, %40, %.preheader61
  %.151.lcssa = phi i32 [ 0, %.preheader61 ], [ 0, %40 ], [ %.15168, %.lr.ph69 ]
  %44 = tail call noundef zeroext i1 @_Z3chkPiiS_i(ptr noundef nonnull @b, i32 noundef %.151.lcssa, ptr noundef nonnull @b, i32 noundef %.pre106)
  %45 = zext i1 %44 to i32
  %spec.select = add nsw i32 %.151.lcssa, %45
  %indvars.iv.next97 = add nuw nsw i64 %indvars.iv96, 1
  %46 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %indvars.iv.next97
  store i32 %spec.select, ptr %46, align 4, !tbaa !5
  %47 = load i32, ptr @m, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = icmp slt i64 %indvars.iv.next97, %48
  br i1 %49, label %.preheader61, label %._crit_edge74, !llvm.loop !13

.preheader:                                       ; preds = %._crit_edge74, %73
  %.04882 = phi i32 [ %.3, %73 ], [ 0, %._crit_edge74 ]
  %.04981 = phi i32 [ %74, %73 ], [ 0, %._crit_edge74 ]
  %.not5775 = icmp eq i32 %.04882, 0
  br i1 %.not5775, label %.critedge2, label %.lr.ph77

._crit_edge83.loopexit:                           ; preds = %73
  %.pre102 = load i32, ptr @sz, align 4, !tbaa !5
  br label %._crit_edge83

._crit_edge83:                                    ; preds = %._crit_edge83.loopexit, %._crit_edge74
  %50 = phi i32 [ %.pre102, %._crit_edge83.loopexit ], [ 0, %._crit_edge74 ]
  %51 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %50)
  %52 = load i32, ptr @sz, align 4, !tbaa !5
  %53 = icmp sgt i32 %52, 0
  br i1 %53, label %.lr.ph86, label %._crit_edge87

.lr.ph77:                                         ; preds = %.preheader, %55
  %.176 = phi i32 [ %58, %55 ], [ %.04882, %.preheader ]
  %54 = tail call noundef zeroext i1 @_Z3chkPiiS_i(ptr noundef nonnull @b, i32 noundef %.176, ptr noundef nonnull @a, i32 noundef %.04981)
  br i1 %54, label %.critedge2, label %55

55:                                               ; preds = %.lr.ph77
  %56 = sext i32 %.176 to i64
  %57 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %56
  %58 = load i32, ptr %57, align 4, !tbaa !5
  %.not57 = icmp eq i32 %58, 0
  br i1 %.not57, label %.critedge2, label %.lr.ph77, !llvm.loop !14

.critedge2:                                       ; preds = %.lr.ph77, %55, %.preheader
  %.1.lcssa = phi i32 [ 0, %.preheader ], [ 0, %55 ], [ %.176, %.lr.ph77 ]
  %59 = tail call noundef zeroext i1 @_Z3chkPiiS_i(ptr noundef nonnull @b, i32 noundef %.1.lcssa, ptr noundef nonnull @a, i32 noundef %.04981)
  %60 = zext i1 %59 to i32
  %spec.select60 = add nsw i32 %.1.lcssa, %60
  %61 = load i32, ptr @m, align 4, !tbaa !5
  %62 = icmp eq i32 %spec.select60, %61
  br i1 %62, label %63, label %73

63:                                               ; preds = %.critedge2
  %64 = add nuw i32 %.04981, 2
  %65 = sub i32 %64, %spec.select60
  %66 = load i32, ptr @sz, align 4, !tbaa !5
  %67 = add nsw i32 %66, 1
  store i32 %67, ptr @sz, align 4, !tbaa !5
  %68 = sext i32 %66 to i64
  %69 = getelementptr inbounds [1000001 x i32], ptr @out, i64 0, i64 %68
  store i32 %65, ptr %69, align 4, !tbaa !5
  %70 = sext i32 %spec.select60 to i64
  %71 = getelementptr inbounds [1000001 x i32], ptr @f, i64 0, i64 %70
  %72 = load i32, ptr %71, align 4, !tbaa !5
  br label %73

73:                                               ; preds = %.critedge2, %63
  %.3 = phi i32 [ %72, %63 ], [ %spec.select60, %.critedge2 ]
  %74 = add nuw nsw i32 %.04981, 1
  %75 = load i32, ptr @n, align 4, !tbaa !5
  %76 = icmp slt i32 %74, %75
  br i1 %76, label %.preheader, label %._crit_edge83.loopexit, !llvm.loop !15

._crit_edge87:                                    ; preds = %.lr.ph86, %._crit_edge83
  %77 = tail call i32 @putchar(i32 noundef 10)
  %78 = load i32, ptr @t, align 4, !tbaa !5
  %79 = add nsw i32 %78, -1
  store i32 %79, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %78, 0
  br i1 %.not, label %._crit_edge91, label %.lr.ph90, !llvm.loop !16

.lr.ph86:                                         ; preds = %._crit_edge83, %.lr.ph86
  %indvars.iv99 = phi i64 [ %indvars.iv.next100, %.lr.ph86 ], [ 0, %._crit_edge83 ]
  %80 = getelementptr inbounds [1000001 x i32], ptr @out, i64 0, i64 %indvars.iv99
  %81 = load i32, ptr %80, align 4, !tbaa !5
  %82 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %81)
  %indvars.iv.next100 = add nuw nsw i64 %indvars.iv99, 1
  %83 = load i32, ptr @sz, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = icmp slt i64 %indvars.iv.next100, %84
  br i1 %85, label %.lr.ph86, label %._crit_edge87, !llvm.loop !17

._crit_edge91:                                    ; preds = %._crit_edge87, %0
  ret i32 0
}

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3chkPiiS_i(ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

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

; Function Attrs: inlinehint mustprogress nofree nounwind uwtable
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #4

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}


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