; LLVM IR from tangjz/acm-icpc :: TDL_training/2015-10-21/upsolved (I - Improvements - dby)

; 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 [200030 x i32], align 16
@f = external dso_local global [200030 x i32], align 16
@stk = external dso_local global [200030 x i32], align 16
@.str = external hidden unnamed_addr constant [16 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = 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
  store i32 0, ptr %1, align 4
  %10 = load ptr, ptr @stdin, align 8, !tbaa !5
  %11 = call ptr @freopen(ptr noundef @.str, ptr noundef @.str.1, ptr noundef %10)
  %12 = load ptr, ptr @stdout, align 8, !tbaa !5
  %13 = call ptr @freopen(ptr noundef @.str.2, ptr noundef @.str.3, ptr noundef %12)
  br label %14

14:                                               ; preds = %177, %0
  %15 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.4, ptr noundef @n)
  %16 = icmp ne i32 %15, -1
  br i1 %16, label %17, label %180

17:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 1, ptr %2, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  br label %18

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

22:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %32

23:                                               ; preds = %18
  %24 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.4, ptr noundef %3)
  %25 = load i32, ptr %2, align 4, !tbaa !9
  %26 = load i32, ptr %3, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [200030 x i32], ptr @a, i64 0, i64 %27
  store i32 %25, ptr %28, align 4, !tbaa !9
  br label %29

29:                                               ; preds = %23
  %30 = load i32, ptr %2, align 4, !tbaa !9
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %2, align 4, !tbaa !9
  br label %18, !llvm.loop !11

32:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %33

33:                                               ; preds = %90, %32
  %34 = load i32, ptr %5, align 4, !tbaa !9
  %35 = load i32, ptr @n, align 4, !tbaa !9
  %36 = icmp sle i32 %34, %35
  br i1 %36, label %38, label %37

37:                                               ; preds = %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %93

38:                                               ; preds = %33
  %39 = load i32, ptr %4, align 4, !tbaa !9
  %40 = icmp eq i32 %39, 0
  br i1 %40, label %52, label %41

41:                                               ; preds = %38
  %42 = load i32, ptr %4, align 4, !tbaa !9
  %43 = sub nsw i32 %42, 1
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [200030 x i32], ptr @stk, i64 0, i64 %44
  %46 = load i32, ptr %45, align 4, !tbaa !9
  %47 = load i32, ptr %5, align 4, !tbaa !9
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [200030 x i32], ptr @a, i64 0, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !9
  %51 = icmp slt i32 %46, %50
  br i1 %51, label %52, label %65

52:                                               ; preds = %41, %38
  %53 = load i32, ptr %5, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [200030 x i32], ptr @a, i64 0, i64 %54
  %56 = load i32, ptr %55, align 4, !tbaa !9
  %57 = load i32, ptr %4, align 4, !tbaa !9
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %4, align 4, !tbaa !9
  %59 = sext i32 %57 to i64
  %60 = getelementptr inbounds [200030 x i32], ptr @stk, i64 0, i64 %59
  store i32 %56, ptr %60, align 4, !tbaa !9
  %61 = load i32, ptr %4, align 4, !tbaa !9
  %62 = load i32, ptr %5, align 4, !tbaa !9
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [200030 x i32], ptr @f, i64 0, i64 %63
  store i32 %61, ptr %64, align 4, !tbaa !9
  br label %89

65:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %66 = load i32, ptr %4, align 4, !tbaa !9
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds i32, ptr @stk, i64 %67
  %69 = load i32, ptr %5, align 4, !tbaa !9
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [200030 x i32], ptr @a, i64 0, i64 %70
  %72 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef @stk, ptr noundef %68, ptr noundef nonnull align 4 dereferenceable(4) %71)
  %73 = ptrtoint ptr %72 to i64
  %74 = sub i64 %73, ptrtoint (ptr @stk to i64)
  %75 = sdiv exact i64 %74, 4
  %76 = trunc i64 %75 to i32
  store i32 %76, ptr %6, align 4, !tbaa !9
  %77 = load i32, ptr %5, align 4, !tbaa !9
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [200030 x i32], ptr @a, i64 0, i64 %78
  %80 = load i32, ptr %79, align 4, !tbaa !9
  %81 = load i32, ptr %6, align 4, !tbaa !9
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [200030 x i32], ptr @stk, i64 0, i64 %82
  store i32 %80, ptr %83, align 4, !tbaa !9
  %84 = load i32, ptr %6, align 4, !tbaa !9
  %85 = add nsw i32 %84, 1
  %86 = load i32, ptr %5, align 4, !tbaa !9
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [200030 x i32], ptr @f, i64 0, i64 %87
  store i32 %85, ptr %88, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %89

89:                                               ; preds = %65, %52
  br label %90

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

93:                                               ; preds = %37
  store i32 0, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %94 = load i32, ptr @n, align 4, !tbaa !9
  store i32 %94, ptr %8, align 4, !tbaa !9
  br label %95

95:                                               ; preds = %174, %93
  %96 = load i32, ptr %8, align 4, !tbaa !9
  %97 = icmp ne i32 %96, 0
  br i1 %97, label %99, label %98

98:                                               ; preds = %95
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %177

99:                                               ; preds = %95
  %100 = load i32, ptr %4, align 4, !tbaa !9
  %101 = icmp eq i32 %100, 0
  br i1 %101, label %113, label %102

102:                                              ; preds = %99
  %103 = load i32, ptr %4, align 4, !tbaa !9
  %104 = sub nsw i32 %103, 1
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [200030 x i32], ptr @stk, i64 0, i64 %105
  %107 = load i32, ptr %106, align 4, !tbaa !9
  %108 = load i32, ptr %8, align 4, !tbaa !9
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [200030 x i32], ptr @a, i64 0, i64 %109
  %111 = load i32, ptr %110, align 4, !tbaa !9
  %112 = icmp slt i32 %107, %111
  br i1 %112, label %113, label %138

113:                                              ; preds = %102, %99
  %114 = load i32, ptr %4, align 4, !tbaa !9
  %115 = load i32, ptr %8, align 4, !tbaa !9
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds [200030 x i32], ptr @f, i64 0, i64 %116
  %118 = load i32, ptr %117, align 4, !tbaa !9
  %119 = add nsw i32 %114, %118
  %120 = load i32, ptr %7, align 4, !tbaa !9
  %121 = icmp sgt i32 %119, %120
  br i1 %121, label %122, label %129

122:                                              ; preds = %113
  %123 = load i32, ptr %4, align 4, !tbaa !9
  %124 = load i32, ptr %8, align 4, !tbaa !9
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [200030 x i32], ptr @f, i64 0, i64 %125
  %127 = load i32, ptr %126, align 4, !tbaa !9
  %128 = add nsw i32 %123, %127
  store i32 %128, ptr %7, align 4, !tbaa !9
  br label %129

129:                                              ; preds = %122, %113
  %130 = load i32, ptr %8, align 4, !tbaa !9
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds [200030 x i32], ptr @a, i64 0, i64 %131
  %133 = load i32, ptr %132, align 4, !tbaa !9
  %134 = load i32, ptr %4, align 4, !tbaa !9
  %135 = add nsw i32 %134, 1
  store i32 %135, ptr %4, align 4, !tbaa !9
  %136 = sext i32 %134 to i64
  %137 = getelementptr inbounds [200030 x i32], ptr @stk, i64 0, i64 %136
  store i32 %133, ptr %137, align 4, !tbaa !9
  br label %173

138:                                              ; preds = %102
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %139 = load i32, ptr %4, align 4, !tbaa !9
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds i32, ptr @stk, i64 %140
  %142 = load i32, ptr %8, align 4, !tbaa !9
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds [200030 x i32], ptr @a, i64 0, i64 %143
  %145 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef @stk, ptr noundef %141, ptr noundef nonnull align 4 dereferenceable(4) %144)
  %146 = ptrtoint ptr %145 to i64
  %147 = sub i64 %146, ptrtoint (ptr @stk to i64)
  %148 = sdiv exact i64 %147, 4
  %149 = trunc i64 %148 to i32
  store i32 %149, ptr %9, align 4, !tbaa !9
  %150 = load i32, ptr %8, align 4, !tbaa !9
  %151 = sext i32 %150 to i64
  %152 = getelementptr inbounds [200030 x i32], ptr @a, i64 0, i64 %151
  %153 = load i32, ptr %152, align 4, !tbaa !9
  %154 = load i32, ptr %9, align 4, !tbaa !9
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds [200030 x i32], ptr @stk, i64 0, i64 %155
  store i32 %153, ptr %156, align 4, !tbaa !9
  %157 = load i32, ptr %9, align 4, !tbaa !9
  %158 = load i32, ptr %8, align 4, !tbaa !9
  %159 = sext i32 %158 to i64
  %160 = getelementptr inbounds [200030 x i32], ptr @f, i64 0, i64 %159
  %161 = load i32, ptr %160, align 4, !tbaa !9
  %162 = add nsw i32 %157, %161
  %163 = load i32, ptr %7, align 4, !tbaa !9
  %164 = icmp sgt i32 %162, %163
  br i1 %164, label %165, label %172

165:                                              ; preds = %138
  %166 = load i32, ptr %9, align 4, !tbaa !9
  %167 = load i32, ptr %8, align 4, !tbaa !9
  %168 = sext i32 %167 to i64
  %169 = getelementptr inbounds [200030 x i32], ptr @f, i64 0, i64 %168
  %170 = load i32, ptr %169, align 4, !tbaa !9
  %171 = add nsw i32 %166, %170
  store i32 %171, ptr %7, align 4, !tbaa !9
  br label %172

172:                                              ; preds = %165, %138
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %173

173:                                              ; preds = %172, %129
  br label %174

174:                                              ; preds = %173
  %175 = load i32, ptr %8, align 4, !tbaa !9
  %176 = add nsw i32 %175, -1
  store i32 %176, ptr %8, align 4, !tbaa !9
  br label %95, !llvm.loop !14

177:                                              ; preds = %98
  %178 = load i32, ptr %7, align 4, !tbaa !9
  %179 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, i32 noundef %178)
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %14, !llvm.loop !15

180:                                              ; preds = %14
  ret i32 0
}

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) #1

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

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

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

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

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

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


; 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 [200030 x i32], align 16
@f = external dso_local local_unnamed_addr global [200030 x i32], align 16
@stk = external dso_local global [200030 x i32], align 16
@.str = external hidden unnamed_addr constant [16 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = load ptr, ptr @stdin, align 8, !tbaa !5
  %3 = tail call ptr @freopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef %2)
  %4 = load ptr, ptr @stdout, align 8, !tbaa !5
  %5 = tail call ptr @freopen(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, ptr noundef %4)
  %6 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.4, ptr noundef nonnull @n)
  %.not69 = icmp eq i32 %6, -1
  br i1 %.not69, label %._crit_edge72, label %.lr.ph71

.lr.ph71:                                         ; preds = %0, %._crit_edge67
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  %7 = load i32, ptr @n, align 4, !tbaa !9
  %.not5055 = icmp slt i32 %7, 1
  br i1 %.not5055, label %._crit_edge.thread, label %.lr.ph

._crit_edge.thread:                               ; preds = %.lr.ph71
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  br label %.preheader

._crit_edge:                                      ; preds = %.lr.ph
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  %.not5157 = icmp slt i32 %13, 1
  br i1 %.not5157, label %.preheader, label %.lr.ph61

.lr.ph:                                           ; preds = %.lr.ph71, %.lr.ph
  %.056 = phi i32 [ %12, %.lr.ph ], [ 1, %.lr.ph71 ]
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.4, ptr noundef nonnull %1)
  %9 = load i32, ptr %1, align 4, !tbaa !9
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds [200030 x i32], ptr @a, i64 0, i64 %10
  store i32 %.056, ptr %11, align 4, !tbaa !9
  %12 = add nuw nsw i32 %.056, 1
  %13 = load i32, ptr @n, align 4, !tbaa !9
  %.not50.not = icmp slt i32 %.056, %13
  br i1 %.not50.not, label %.lr.ph, label %._crit_edge, !llvm.loop !11

.preheader:                                       ; preds = %44, %._crit_edge.thread, %._crit_edge
  %.lcssa = phi i32 [ %13, %._crit_edge ], [ %7, %._crit_edge.thread ], [ %45, %44 ]
  %.not5262 = icmp eq i32 %.lcssa, 0
  br i1 %.not5262, label %._crit_edge67, label %.lr.ph66.preheader

.lr.ph66.preheader:                               ; preds = %.preheader
  %14 = sext i32 %.lcssa to i64
  br label %.lr.ph66

.lr.ph61:                                         ; preds = %._crit_edge, %44
  %15 = phi i32 [ %45, %44 ], [ %13, %._crit_edge ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %44 ], [ 1, %._crit_edge ]
  %.04259 = phi i32 [ %.143, %44 ], [ 0, %._crit_edge ]
  %16 = icmp eq i32 %.04259, 0
  br i1 %16, label %.lr.ph61._crit_edge, label %17

.lr.ph61._crit_edge:                              ; preds = %.lr.ph61
  %.phi.trans.insert = getelementptr inbounds [200030 x i32], ptr @a, i64 0, i64 %indvars.iv
  %.pre = load i32, ptr %.phi.trans.insert, align 4, !tbaa !9
  br label %25

17:                                               ; preds = %.lr.ph61
  %18 = add nsw i32 %.04259, -1
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [200030 x i32], ptr @stk, i64 0, i64 %19
  %21 = load i32, ptr %20, align 4, !tbaa !9
  %22 = getelementptr inbounds [200030 x i32], ptr @a, i64 0, i64 %indvars.iv
  %23 = load i32, ptr %22, align 4, !tbaa !9
  %24 = icmp slt i32 %21, %23
  br i1 %24, label %25, label %31

25:                                               ; preds = %.lr.ph61._crit_edge, %17
  %26 = phi i32 [ %.pre, %.lr.ph61._crit_edge ], [ %23, %17 ]
  %27 = add nsw i32 %.04259, 1
  %28 = sext i32 %.04259 to i64
  %29 = getelementptr inbounds [200030 x i32], ptr @stk, i64 0, i64 %28
  store i32 %26, ptr %29, align 4, !tbaa !9
  %30 = getelementptr inbounds [200030 x i32], ptr @f, i64 0, i64 %indvars.iv
  store i32 %27, ptr %30, align 4, !tbaa !9
  br label %44

31:                                               ; preds = %17
  %32 = sext i32 %.04259 to i64
  %33 = getelementptr inbounds i32, ptr @stk, i64 %32
  %34 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull @stk, ptr noundef nonnull %33, ptr noundef nonnull align 4 dereferenceable(4) %22)
  %35 = ptrtoint ptr %34 to i64
  %36 = sub i64 %35, ptrtoint (ptr @stk to i64)
  %37 = lshr exact i64 %36, 2
  %38 = trunc i64 %37 to i32
  %39 = load i32, ptr %22, align 4, !tbaa !9
  %sext53 = shl i64 %36, 30
  %40 = ashr i64 %sext53, 32
  %41 = getelementptr inbounds [200030 x i32], ptr @stk, i64 0, i64 %40
  store i32 %39, ptr %41, align 4, !tbaa !9
  %42 = add nsw i32 %38, 1
  %43 = getelementptr inbounds [200030 x i32], ptr @f, i64 0, i64 %indvars.iv
  store i32 %42, ptr %43, align 4, !tbaa !9
  %.pre78 = load i32, ptr @n, align 4, !tbaa !9
  br label %44

44:                                               ; preds = %25, %31
  %45 = phi i32 [ %15, %25 ], [ %.pre78, %31 ]
  %.143 = phi i32 [ %27, %25 ], [ %.04259, %31 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %46 = sext i32 %45 to i64
  %.not51.not = icmp slt i64 %indvars.iv, %46
  br i1 %.not51.not, label %.lr.ph61, label %.preheader, !llvm.loop !13

._crit_edge67:                                    ; preds = %80, %.preheader
  %.041.lcssa = phi i32 [ 0, %.preheader ], [ %.3, %80 ]
  %47 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %.041.lcssa)
  %48 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.4, ptr noundef nonnull @n)
  %.not = icmp eq i32 %48, -1
  br i1 %.not, label %._crit_edge72, label %.lr.ph71, !llvm.loop !14

.lr.ph66:                                         ; preds = %.lr.ph66.preheader, %80
  %indvars.iv75 = phi i64 [ %14, %.lr.ph66.preheader ], [ %indvars.iv.next76, %80 ]
  %.04164 = phi i32 [ 0, %.lr.ph66.preheader ], [ %.3, %80 ]
  %.24463 = phi i32 [ 0, %.lr.ph66.preheader ], [ %.345, %80 ]
  %49 = icmp eq i32 %.24463, 0
  br i1 %49, label %.lr.ph66._crit_edge, label %50

.lr.ph66._crit_edge:                              ; preds = %.lr.ph66
  %.phi.trans.insert79 = getelementptr inbounds [200030 x i32], ptr @a, i64 0, i64 %indvars.iv75
  %.pre80 = load i32, ptr %.phi.trans.insert79, align 4, !tbaa !9
  br label %58

50:                                               ; preds = %.lr.ph66
  %51 = add nsw i32 %.24463, -1
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [200030 x i32], ptr @stk, i64 0, i64 %52
  %54 = load i32, ptr %53, align 4, !tbaa !9
  %55 = getelementptr inbounds [200030 x i32], ptr @a, i64 0, i64 %indvars.iv75
  %56 = load i32, ptr %55, align 4, !tbaa !9
  %57 = icmp slt i32 %54, %56
  br i1 %57, label %58, label %66

58:                                               ; preds = %.lr.ph66._crit_edge, %50
  %59 = phi i32 [ %.pre80, %.lr.ph66._crit_edge ], [ %56, %50 ]
  %60 = getelementptr inbounds [200030 x i32], ptr @f, i64 0, i64 %indvars.iv75
  %61 = load i32, ptr %60, align 4, !tbaa !9
  %62 = add nsw i32 %61, %.24463
  %spec.select = call i32 @llvm.smax.i32(i32 %62, i32 %.04164)
  %63 = add nsw i32 %.24463, 1
  %64 = sext i32 %.24463 to i64
  %65 = getelementptr inbounds [200030 x i32], ptr @stk, i64 0, i64 %64
  store i32 %59, ptr %65, align 4, !tbaa !9
  br label %80

66:                                               ; preds = %50
  %67 = sext i32 %.24463 to i64
  %68 = getelementptr inbounds i32, ptr @stk, i64 %67
  %69 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull @stk, ptr noundef nonnull %68, ptr noundef nonnull align 4 dereferenceable(4) %55)
  %70 = ptrtoint ptr %69 to i64
  %71 = sub i64 %70, ptrtoint (ptr @stk to i64)
  %72 = lshr exact i64 %71, 2
  %73 = trunc i64 %72 to i32
  %74 = load i32, ptr %55, align 4, !tbaa !9
  %sext = shl i64 %71, 30
  %75 = ashr i64 %sext, 32
  %76 = getelementptr inbounds [200030 x i32], ptr @stk, i64 0, i64 %75
  store i32 %74, ptr %76, align 4, !tbaa !9
  %77 = getelementptr inbounds [200030 x i32], ptr @f, i64 0, i64 %indvars.iv75
  %78 = load i32, ptr %77, align 4, !tbaa !9
  %79 = add nsw i32 %78, %73
  %spec.select54 = call i32 @llvm.smax.i32(i32 %79, i32 %.04164)
  br label %80

80:                                               ; preds = %58, %66
  %.345 = phi i32 [ %63, %58 ], [ %.24463, %66 ]
  %.3 = phi i32 [ %spec.select, %58 ], [ %spec.select54, %66 ]
  %indvars.iv.next76 = add nsw i64 %indvars.iv75, -1
  %.not52 = icmp eq i64 %indvars.iv.next76, 0
  br i1 %.not52, label %._crit_edge67, label %.lr.ph66, !llvm.loop !15

._crit_edge72:                                    ; preds = %._crit_edge67, %0
  ret i32 0
}

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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

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

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

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #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 = { 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 #3 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}


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