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

; 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 [300003 x i32], align 16
@cnt = external dso_local global i32, align 4
@p = external dso_local global [300003 x i32], align 16
@m = external dso_local global i32, align 4
@out = external dso_local global [300003 x i32], align 16
@f = external dso_local global [300003 x i64], align 16
@v = external dso_local global [300003 x i8], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [78 x i8], align 1
@__PRETTY_FUNCTION__.main = external hidden unnamed_addr constant [11 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z10descensioni(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 i64, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %17

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

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

22:                                               ; preds = %17
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds i32, ptr @a, i64 %24
  %26 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %25)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = sub nsw i32 %27, 2
  store i32 %28, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  store i32 0, ptr %5, align 4, !tbaa !5
  %29 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [300003 x i64], ptr @f, i64 0, i64 %31
  %33 = load i64, ptr %32, align 8, !tbaa !9
  %34 = load i32, ptr %2, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [300003 x i32], ptr @a, i64 0, i64 %35
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = add nsw i64 %33, %38
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  store i64 %39, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  %40 = load i32, ptr %2, align 4, !tbaa !5
  %41 = sub nsw i32 %40, 3
  store i32 %41, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  store i32 0, ptr %8, align 4, !tbaa !5
  %42 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %7, ptr noundef nonnull align 4 dereferenceable(4) %8)
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [300003 x i64], ptr @f, i64 0, i64 %44
  %46 = load i64, ptr %45, align 8, !tbaa !9
  %47 = load i32, ptr %2, align 4, !tbaa !5
  %48 = sub nsw i32 %47, 1
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [300003 x i32], ptr @a, i64 0, i64 %49
  %51 = load i32, ptr %2, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [300003 x i32], ptr @a, i64 0, i64 %52
  %54 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %50, ptr noundef nonnull align 4 dereferenceable(4) %53)
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = add nsw i64 %46, %56
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  store i64 %57, ptr %6, align 8, !tbaa !9
  %58 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %6)
  %59 = load i64, ptr %58, align 8, !tbaa !9
  %60 = load i32, ptr %2, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [300003 x i64], ptr @f, i64 0, i64 %61
  store i64 %59, ptr %62, align 8, !tbaa !9
  %63 = load i32, ptr %2, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [300003 x i64], ptr @f, i64 0, i64 %64
  %66 = load i64, ptr %65, align 8, !tbaa !9
  %67 = load i64, ptr %3, align 8, !tbaa !9
  %68 = icmp ne i64 %66, %67
  %69 = load i32, ptr %2, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [300003 x i8], ptr @v, i64 0, i64 %70
  %72 = zext i1 %68 to i8
  store i8 %72, ptr %71, align 1, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #7
  br label %73

73:                                               ; preds = %22
  %74 = load i32, ptr %2, align 4, !tbaa !5
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %2, align 4, !tbaa !5
  br label %17, !llvm.loop !13

76:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %77 = load i32, ptr @n, align 4, !tbaa !5
  %78 = sub nsw i32 %77, 1
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [300003 x i64], ptr @f, i64 0, i64 %79
  %81 = load i32, ptr @n, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [300003 x i64], ptr @f, i64 0, i64 %82
  %84 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %80, ptr noundef nonnull align 8 dereferenceable(8) %83)
  %85 = load i64, ptr %84, align 8, !tbaa !9
  store i64 %85, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  %86 = load i32, ptr @n, align 4, !tbaa !5
  %87 = load i64, ptr %9, align 8, !tbaa !9
  %88 = load i32, ptr @n, align 4, !tbaa !5
  %89 = sub nsw i32 %88, 1
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [300003 x i64], ptr @f, i64 0, i64 %90
  %92 = load i64, ptr %91, align 8, !tbaa !9
  %93 = icmp eq i64 %87, %92
  %94 = zext i1 %93 to i32
  %95 = sub nsw i32 %86, %94
  store i32 %95, ptr %10, align 4, !tbaa !5
  br label %96

96:                                               ; preds = %106, %76
  %97 = load i32, ptr %10, align 4, !tbaa !5
  %98 = icmp sgt i32 %97, 0
  br i1 %98, label %100, label %99

99:                                               ; preds = %96
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  br label %116

100:                                              ; preds = %96
  %101 = load i32, ptr %10, align 4, !tbaa !5
  %102 = load i32, ptr @cnt, align 4, !tbaa !5
  %103 = add nsw i32 %102, 1
  store i32 %103, ptr @cnt, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [300003 x i32], ptr @p, i64 0, i64 %104
  store i32 %101, ptr %105, align 4, !tbaa !5
  br label %106

106:                                              ; preds = %100
  %107 = load i32, ptr %10, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [300003 x i8], ptr @v, i64 0, i64 %108
  %110 = load i8, ptr %109, align 1, !tbaa !11, !range !15, !noundef !16
  %111 = trunc i8 %110 to i1
  %112 = zext i1 %111 to i32
  %113 = add nsw i32 2, %112
  %114 = load i32, ptr %10, align 4, !tbaa !5
  %115 = sub nsw i32 %114, %113
  store i32 %115, ptr %10, align 4, !tbaa !5
  br label %96, !llvm.loop !17

116:                                              ; preds = %99
  %117 = load i32, ptr @cnt, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds i32, ptr @p, i64 %118
  %120 = getelementptr inbounds i32, ptr %119, i64 1
  call void @_ZSt7reverseIPiEvT_S1_(ptr noundef getelementptr inbounds (i32, ptr @p, i64 1), ptr noundef %120)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  store i32 1, ptr %11, align 4, !tbaa !5
  br label %121

121:                                              ; preds = %173, %116
  %122 = load i32, ptr %11, align 4, !tbaa !5
  %123 = load i32, ptr @cnt, align 4, !tbaa !5
  %124 = icmp sle i32 %122, %123
  br i1 %124, label %126, label %125

125:                                              ; preds = %121
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  br label %176

126:                                              ; preds = %121
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  %127 = load i32, ptr %11, align 4, !tbaa !5
  %128 = sub nsw i32 %127, 1
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds [300003 x i32], ptr @p, i64 0, i64 %129
  %131 = load i32, ptr %130, align 4, !tbaa !5
  store i32 %131, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  %132 = load i32, ptr %11, align 4, !tbaa !5
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds [300003 x i32], ptr @p, i64 0, i64 %133
  %135 = load i32, ptr %134, align 4, !tbaa !5
  store i32 %135, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #7
  store i32 0, ptr %14, align 4, !tbaa !5
  %136 = load i32, ptr %13, align 4, !tbaa !5
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [300003 x i8], ptr @v, i64 0, i64 %137
  %139 = load i8, ptr %138, align 1, !tbaa !11, !range !15, !noundef !16
  %140 = trunc i8 %139 to i1
  br i1 %140, label %141, label %147

141:                                              ; preds = %126
  %142 = load i32, ptr %13, align 4, !tbaa !5
  %143 = sub nsw i32 %142, 1
  %144 = call noundef i32 @_Z10descensioni(i32 noundef %143)
  %145 = load i32, ptr %14, align 4, !tbaa !5
  %146 = add nsw i32 %145, %144
  store i32 %146, ptr %14, align 4, !tbaa !5
  br label %147

147:                                              ; preds = %141, %126
  %148 = load i32, ptr %12, align 4, !tbaa !5
  %149 = add nsw i32 %148, 1
  %150 = call noundef i32 @_Z10descensioni(i32 noundef %149)
  %151 = load i32, ptr %14, align 4, !tbaa !5
  %152 = add nsw i32 %151, %150
  store i32 %152, ptr %14, align 4, !tbaa !5
  %153 = load i32, ptr %13, align 4, !tbaa !5
  %154 = call noundef i32 @_Z10descensioni(i32 noundef %153)
  %155 = load i32, ptr %14, align 4, !tbaa !5
  %156 = add nsw i32 %155, %154
  store i32 %156, ptr %14, align 4, !tbaa !5
  %157 = load i32, ptr %14, align 4, !tbaa !5
  %158 = sext i32 %157 to i64
  %159 = load i32, ptr %13, align 4, !tbaa !5
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds [300003 x i64], ptr @f, i64 0, i64 %160
  %162 = load i64, ptr %161, align 8, !tbaa !9
  %163 = load i32, ptr %12, align 4, !tbaa !5
  %164 = sext i32 %163 to i64
  %165 = getelementptr inbounds [300003 x i64], ptr @f, i64 0, i64 %164
  %166 = load i64, ptr %165, align 8, !tbaa !9
  %167 = sub nsw i64 %162, %166
  %168 = icmp eq i64 %158, %167
  br i1 %168, label %169, label %170

169:                                              ; preds = %147
  br label %172

170:                                              ; preds = %147
  call void @__assert_fail(ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 36, ptr noundef @__PRETTY_FUNCTION__.main) #8
  unreachable

171:                                              ; No predecessors!
  br label %172

172:                                              ; preds = %171, %169
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  br label %173

173:                                              ; preds = %172
  %174 = load i32, ptr %11, align 4, !tbaa !5
  %175 = add nsw i32 %174, 1
  store i32 %175, ptr %11, align 4, !tbaa !5
  br label %121, !llvm.loop !18

176:                                              ; preds = %125
  %177 = load i32, ptr @m, align 4, !tbaa !5
  %178 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %177)
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  store i32 1, ptr %15, align 4, !tbaa !5
  br label %179

179:                                              ; preds = %190, %176
  %180 = load i32, ptr %15, align 4, !tbaa !5
  %181 = load i32, ptr @m, align 4, !tbaa !5
  %182 = icmp sle i32 %180, %181
  br i1 %182, label %184, label %183

183:                                              ; preds = %179
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  br label %193

184:                                              ; preds = %179
  %185 = load i32, ptr %15, align 4, !tbaa !5
  %186 = sext i32 %185 to i64
  %187 = getelementptr inbounds [300003 x i32], ptr @out, i64 0, i64 %186
  %188 = load i32, ptr %187, align 4, !tbaa !5
  %189 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %188)
  br label %190

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

193:                                              ; preds = %183
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  ret i32 0
}

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt7reverseIPiEvT_S1_(ptr noundef, ptr noundef) #5

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #6

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

attributes #0 = { 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 #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 = { 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 = { noreturn 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 #7 = { nounwind }
attributes #8 = { noreturn 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, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !14}
!19 = distinct !{!19, !14}


; 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 [300003 x i32], align 16
@cnt = external dso_local local_unnamed_addr global i32, align 4
@p = external dso_local global [300003 x i32], align 16
@m = external dso_local local_unnamed_addr global i32, align 4
@out = external dso_local local_unnamed_addr global [300003 x i32], align 16
@f = external dso_local global [300003 x i64], align 16
@v = external dso_local local_unnamed_addr global [300003 x i8], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [78 x i8], align 1
@__PRETTY_FUNCTION__.main = external hidden unnamed_addr constant [11 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z10descensioni(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 uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i64, align 8
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %8 = load i32, ptr @n, align 4, !tbaa !5
  %.not40 = icmp slt i32 %8, 1
  br i1 %.not40, label %.._crit_edge_crit_edge, label %.lr.ph

.._crit_edge_crit_edge:                           ; preds = %0
  %.pre = sext i32 %8 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre, %.._crit_edge_crit_edge ], [ %57, %.lr.ph ]
  %.lcssa = phi i32 [ %8, %.._crit_edge_crit_edge ], [ %56, %.lr.ph ]
  %9 = add nsw i32 %.lcssa, -1
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds [300003 x i64], ptr @f, i64 0, i64 %10
  %12 = getelementptr inbounds [300003 x i64], ptr @f, i64 0, i64 %.pre-phi
  %13 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef nonnull align 8 dereferenceable(8) %12)
  %14 = load i64, ptr %13, align 8, !tbaa !9
  %15 = load i32, ptr @n, align 4, !tbaa !5
  %16 = add nsw i32 %15, -1
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [300003 x i64], ptr @f, i64 0, i64 %17
  %19 = load i64, ptr %18, align 8, !tbaa !9
  %20 = icmp eq i64 %14, %19
  %.neg = sext i1 %20 to i32
  %21 = add i32 %15, %.neg
  %cnt.promoted = load i32, ptr @cnt, align 4, !tbaa !5
  %22 = icmp sgt i32 %21, 0
  br i1 %22, label %.lr.ph44.preheader, label %59

.lr.ph44.preheader:                               ; preds = %._crit_edge
  %23 = sext i32 %cnt.promoted to i64
  br label %.lr.ph44

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %0 ]
  %24 = getelementptr inbounds i32, ptr @a, i64 %indvars.iv
  %25 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %24)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  %26 = trunc i64 %indvars.iv to i32
  %27 = add i32 %26, -2
  store i32 %27, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #7
  store i32 0, ptr %3, align 4, !tbaa !5
  %28 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [300003 x i64], ptr @f, i64 0, i64 %30
  %32 = load i64, ptr %31, align 8, !tbaa !9
  %33 = load i32, ptr %24, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = add nsw i64 %32, %34
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  store i64 %35, ptr %1, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #7
  %36 = trunc i64 %indvars.iv to i32
  %37 = add i32 %36, -3
  store i32 %37, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #7
  store i32 0, ptr %6, align 4, !tbaa !5
  %38 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %6)
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [300003 x i64], ptr @f, i64 0, i64 %40
  %42 = load i64, ptr %41, align 8, !tbaa !9
  %43 = add nsw i64 %indvars.iv, -1
  %44 = getelementptr inbounds [300003 x i32], ptr @a, i64 0, i64 %43
  %45 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %44, ptr noundef nonnull align 4 dereferenceable(4) %24)
  %46 = load i32, ptr %45, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = add nsw i64 %42, %47
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #7
  store i64 %48, ptr %4, align 8, !tbaa !9
  %49 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %50 = load i64, ptr %49, align 8, !tbaa !9
  %51 = getelementptr inbounds [300003 x i64], ptr @f, i64 0, i64 %indvars.iv
  store i64 %50, ptr %51, align 8, !tbaa !9
  %52 = load i64, ptr %1, align 8, !tbaa !9
  %53 = icmp ne i64 %50, %52
  %54 = getelementptr inbounds [300003 x i8], ptr @v, i64 0, i64 %indvars.iv
  %55 = zext i1 %53 to i8
  store i8 %55, ptr %54, align 1, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #7
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %56 = load i32, ptr @n, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %.not.not = icmp slt i64 %indvars.iv, %57
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !13

._crit_edge45:                                    ; preds = %.lr.ph44
  %58 = trunc nsw i64 %indvars.iv.next61 to i32
  store i32 %58, ptr @cnt, align 4, !tbaa !5
  br label %59

59:                                               ; preds = %._crit_edge45, %._crit_edge
  %60 = phi i32 [ %58, %._crit_edge45 ], [ %cnt.promoted, %._crit_edge ]
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds i32, ptr @p, i64 %61
  %63 = getelementptr inbounds i8, ptr %62, i64 4
  call void @_ZSt7reverseIPiEvT_S1_(ptr noundef nonnull getelementptr inbounds (i8, ptr @p, i64 4), ptr noundef nonnull %63)
  %64 = load i32, ptr @cnt, align 4, !tbaa !5
  %.not3847 = icmp slt i32 %64, 1
  br i1 %.not3847, label %._crit_edge51, label %.lr.ph50

.lr.ph44:                                         ; preds = %.lr.ph44.preheader, %.lr.ph44
  %indvars.iv60 = phi i64 [ %23, %.lr.ph44.preheader ], [ %indvars.iv.next61, %.lr.ph44 ]
  %.03542 = phi i32 [ %21, %.lr.ph44.preheader ], [ %71, %.lr.ph44 ]
  %indvars.iv.next61 = add nsw i64 %indvars.iv60, 1
  %65 = getelementptr inbounds [300003 x i32], ptr @p, i64 0, i64 %indvars.iv.next61
  store i32 %.03542, ptr %65, align 4, !tbaa !5
  %66 = zext nneg i32 %.03542 to i64
  %67 = getelementptr inbounds [300003 x i8], ptr @v, i64 0, i64 %66
  %68 = load i8, ptr %67, align 1, !tbaa !11, !range !15, !noundef !16
  %69 = or disjoint i8 %68, 2
  %70 = zext nneg i8 %69 to i32
  %71 = sub nsw i32 %.03542, %70
  %72 = icmp sgt i32 %71, 0
  br i1 %72, label %.lr.ph44, label %._crit_edge45, !llvm.loop !17

73:                                               ; preds = %91
  %indvars.iv.next64 = add nuw nsw i64 %indvars.iv63, 1
  %74 = load i32, ptr @cnt, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %.not38.not = icmp slt i64 %indvars.iv63, %75
  br i1 %.not38.not, label %.lr.ph50, label %._crit_edge51, !llvm.loop !18

._crit_edge51:                                    ; preds = %73, %59
  %76 = load i32, ptr @m, align 4, !tbaa !5
  %77 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %76)
  %78 = load i32, ptr @m, align 4, !tbaa !5
  %.not3952 = icmp slt i32 %78, 1
  br i1 %.not3952, label %._crit_edge56, label %.lr.ph55

.lr.ph50:                                         ; preds = %59, %73
  %indvars.iv63 = phi i64 [ %indvars.iv.next64, %73 ], [ 1, %59 ]
  %79 = add nsw i64 %indvars.iv63, -1
  %80 = getelementptr inbounds [300003 x i32], ptr @p, i64 0, i64 %79
  %81 = load i32, ptr %80, align 4, !tbaa !5
  %82 = getelementptr inbounds [300003 x i32], ptr @p, i64 0, i64 %indvars.iv63
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [300003 x i8], ptr @v, i64 0, i64 %84
  %86 = load i8, ptr %85, align 1, !tbaa !11, !range !15, !noundef !16
  %87 = trunc nuw i8 %86 to i1
  br i1 %87, label %88, label %91

88:                                               ; preds = %.lr.ph50
  %89 = add nsw i32 %83, -1
  %90 = call noundef i32 @_Z10descensioni(i32 noundef %89)
  br label %91

91:                                               ; preds = %88, %.lr.ph50
  %.033 = phi i32 [ %90, %88 ], [ 0, %.lr.ph50 ]
  %92 = add nsw i32 %81, 1
  %93 = call noundef i32 @_Z10descensioni(i32 noundef %92)
  %94 = add nsw i32 %93, %.033
  %95 = call noundef i32 @_Z10descensioni(i32 noundef %83)
  %96 = add nsw i32 %94, %95
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [300003 x i64], ptr @f, i64 0, i64 %84
  %99 = load i64, ptr %98, align 8, !tbaa !9
  %100 = sext i32 %81 to i64
  %101 = getelementptr inbounds [300003 x i64], ptr @f, i64 0, i64 %100
  %102 = load i64, ptr %101, align 8, !tbaa !9
  %103 = sub nsw i64 %99, %102
  %104 = icmp eq i64 %103, %97
  br i1 %104, label %73, label %105

105:                                              ; preds = %91
  call void @__assert_fail(ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 36, ptr noundef nonnull @__PRETTY_FUNCTION__.main) #8
  unreachable

._crit_edge56:                                    ; preds = %.lr.ph55, %._crit_edge51
  ret i32 0

.lr.ph55:                                         ; preds = %._crit_edge51, %.lr.ph55
  %indvars.iv66 = phi i64 [ %indvars.iv.next67, %.lr.ph55 ], [ 1, %._crit_edge51 ]
  %106 = getelementptr inbounds [300003 x i32], ptr @out, i64 0, i64 %indvars.iv66
  %107 = load i32, ptr %106, align 4, !tbaa !5
  %108 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %107)
  %indvars.iv.next67 = add nuw nsw i64 %indvars.iv66, 1
  %109 = load i32, ptr @m, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %.not39.not = icmp slt i64 %indvars.iv66, %110
  br i1 %.not39.not, label %.lr.ph55, label %._crit_edge56, !llvm.loop !19
}

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt7reverseIPiEvT_S1_(ptr noundef, ptr noundef) local_unnamed_addr #5

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #6

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

attributes #0 = { 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 #1 = { mustprogress 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 = { 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 = { 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 = { noreturn 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 #7 = { nounwind }
attributes #8 = { noreturn 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, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !14}
!19 = distinct !{!19, !14}


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