; LLVM IR from tangjz/acm-icpc :: 51nod (1437)

; 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 [200010 x i32], align 16
@l = external dso_local global [200010 x i32], align 16
@r = external dso_local global [200010 x i32], align 16
@stack = external dso_local global [200010 x i32], align 16
@top = external dso_local global i32, align 4
@id = external dso_local global [200010 x i32], align 16
@ans = external dso_local global [200010 x i32], align 16
@last = 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 [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3cmpRKiS0_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #1 {
  %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 ptr, align 8
  %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 @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %12

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

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

17:                                               ; preds = %12
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [200010 x i32], ptr @a, i64 0, i64 %19
  %21 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %20)
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [200010 x i32], ptr @id, i64 0, i64 %24
  store i32 %22, ptr %25, align 4, !tbaa !5
  br label %26

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

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

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

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

35:                                               ; preds = %30
  br label %36

36:                                               ; preds = %55, %35
  %37 = load i32, ptr @top, align 4, !tbaa !5
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %39, label %53

39:                                               ; preds = %36
  %40 = load i32, ptr @top, align 4, !tbaa !5
  %41 = sub nsw i32 %40, 1
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [200010 x i32], ptr @stack, i64 0, i64 %42
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [200010 x i32], ptr @a, i64 0, i64 %45
  %47 = load i32, ptr %46, align 4, !tbaa !5
  %48 = load i32, ptr %3, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [200010 x i32], ptr @a, i64 0, i64 %49
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %52 = icmp sge i32 %47, %51
  br label %53

53:                                               ; preds = %39, %36
  %54 = phi i1 [ false, %36 ], [ %52, %39 ]
  br i1 %54, label %55, label %58

55:                                               ; preds = %53
  %56 = load i32, ptr @top, align 4, !tbaa !5
  %57 = add nsw i32 %56, -1
  store i32 %57, ptr @top, align 4, !tbaa !5
  br label %36, !llvm.loop !11

58:                                               ; preds = %53
  %59 = load i32, ptr @top, align 4, !tbaa !5
  %60 = icmp ne i32 %59, 0
  br i1 %60, label %61, label %71

61:                                               ; preds = %58
  %62 = load i32, ptr @top, align 4, !tbaa !5
  %63 = sub nsw i32 %62, 1
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [200010 x i32], ptr @stack, i64 0, i64 %64
  %66 = load i32, ptr %65, align 4, !tbaa !5
  %67 = add nsw i32 %66, 1
  %68 = load i32, ptr %3, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [200010 x i32], ptr @l, i64 0, i64 %69
  store i32 %67, ptr %70, align 4, !tbaa !5
  br label %75

71:                                               ; preds = %58
  %72 = load i32, ptr %3, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [200010 x i32], ptr @l, i64 0, i64 %73
  store i32 1, ptr %74, align 4, !tbaa !5
  br label %75

75:                                               ; preds = %71, %61
  %76 = load i32, ptr %3, align 4, !tbaa !5
  %77 = load i32, ptr @top, align 4, !tbaa !5
  %78 = add nsw i32 %77, 1
  store i32 %78, ptr @top, align 4, !tbaa !5
  %79 = sext i32 %77 to i64
  %80 = getelementptr inbounds [200010 x i32], ptr @stack, i64 0, i64 %79
  store i32 %76, ptr %80, align 4, !tbaa !5
  br label %81

81:                                               ; preds = %75
  %82 = load i32, ptr %3, align 4, !tbaa !5
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %3, align 4, !tbaa !5
  br label %30, !llvm.loop !12

84:                                               ; preds = %34
  store i32 0, ptr @top, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  %85 = load i32, ptr @n, align 4, !tbaa !5
  store i32 %85, ptr %4, align 4, !tbaa !5
  br label %86

86:                                               ; preds = %137, %84
  %87 = load i32, ptr %4, align 4, !tbaa !5
  %88 = icmp sge i32 %87, 1
  br i1 %88, label %90, label %89

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

90:                                               ; preds = %86
  br label %91

91:                                               ; preds = %110, %90
  %92 = load i32, ptr @top, align 4, !tbaa !5
  %93 = icmp ne i32 %92, 0
  br i1 %93, label %94, label %108

94:                                               ; preds = %91
  %95 = load i32, ptr @top, align 4, !tbaa !5
  %96 = sub nsw i32 %95, 1
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [200010 x i32], ptr @stack, i64 0, i64 %97
  %99 = load i32, ptr %98, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [200010 x i32], ptr @a, i64 0, i64 %100
  %102 = load i32, ptr %101, align 4, !tbaa !5
  %103 = load i32, ptr %4, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [200010 x i32], ptr @a, i64 0, i64 %104
  %106 = load i32, ptr %105, align 4, !tbaa !5
  %107 = icmp sge i32 %102, %106
  br label %108

108:                                              ; preds = %94, %91
  %109 = phi i1 [ false, %91 ], [ %107, %94 ]
  br i1 %109, label %110, label %113

110:                                              ; preds = %108
  %111 = load i32, ptr @top, align 4, !tbaa !5
  %112 = add nsw i32 %111, -1
  store i32 %112, ptr @top, align 4, !tbaa !5
  br label %91, !llvm.loop !13

113:                                              ; preds = %108
  %114 = load i32, ptr @top, align 4, !tbaa !5
  %115 = icmp ne i32 %114, 0
  br i1 %115, label %116, label %126

116:                                              ; preds = %113
  %117 = load i32, ptr @top, align 4, !tbaa !5
  %118 = sub nsw i32 %117, 1
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [200010 x i32], ptr @stack, i64 0, i64 %119
  %121 = load i32, ptr %120, align 4, !tbaa !5
  %122 = sub nsw i32 %121, 1
  %123 = load i32, ptr %4, align 4, !tbaa !5
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [200010 x i32], ptr @r, i64 0, i64 %124
  store i32 %122, ptr %125, align 4, !tbaa !5
  br label %131

126:                                              ; preds = %113
  %127 = load i32, ptr @n, align 4, !tbaa !5
  %128 = load i32, ptr %4, align 4, !tbaa !5
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds [200010 x i32], ptr @r, i64 0, i64 %129
  store i32 %127, ptr %130, align 4, !tbaa !5
  br label %131

131:                                              ; preds = %126, %116
  %132 = load i32, ptr %4, align 4, !tbaa !5
  %133 = load i32, ptr @top, align 4, !tbaa !5
  %134 = add nsw i32 %133, 1
  store i32 %134, ptr @top, align 4, !tbaa !5
  %135 = sext i32 %133 to i64
  %136 = getelementptr inbounds [200010 x i32], ptr @stack, i64 0, i64 %135
  store i32 %132, ptr %136, align 4, !tbaa !5
  br label %137

137:                                              ; preds = %131
  %138 = load i32, ptr %4, align 4, !tbaa !5
  %139 = add nsw i32 %138, -1
  store i32 %139, ptr %4, align 4, !tbaa !5
  br label %86, !llvm.loop !14

140:                                              ; preds = %89
  %141 = load i32, ptr @n, align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds i32, ptr @id, i64 %142
  %144 = getelementptr inbounds i32, ptr %143, i64 1
  call void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef getelementptr inbounds (i32, ptr @id, i64 1), ptr noundef %144, ptr noundef @_Z3cmpRKiS0_)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  %145 = load i32, ptr @n, align 4, !tbaa !5
  store i32 %145, ptr %5, align 4, !tbaa !5
  br label %146

146:                                              ; preds = %191, %140
  %147 = load i32, ptr %5, align 4, !tbaa !5
  %148 = icmp sge i32 %147, 1
  br i1 %148, label %150, label %149

149:                                              ; preds = %146
  store i32 15, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  br label %194

150:                                              ; preds = %146
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %151 = load i32, ptr %5, align 4, !tbaa !5
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds [200010 x i32], ptr @id, i64 0, i64 %152
  %154 = load i32, ptr %153, align 4, !tbaa !5
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds [200010 x i32], ptr @r, i64 0, i64 %155
  %157 = load i32, ptr %156, align 4, !tbaa !5
  %158 = load i32, ptr %5, align 4, !tbaa !5
  %159 = sext i32 %158 to i64
  %160 = getelementptr inbounds [200010 x i32], ptr @id, i64 0, i64 %159
  %161 = load i32, ptr %160, align 4, !tbaa !5
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds [200010 x i32], ptr @l, i64 0, i64 %162
  %164 = load i32, ptr %163, align 4, !tbaa !5
  %165 = sub nsw i32 %157, %164
  %166 = add nsw i32 %165, 1
  store i32 %166, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %167 = load i32, ptr %5, align 4, !tbaa !5
  %168 = sext i32 %167 to i64
  %169 = getelementptr inbounds [200010 x i32], ptr @id, i64 0, i64 %168
  %170 = load i32, ptr %169, align 4, !tbaa !5
  %171 = sext i32 %170 to i64
  %172 = getelementptr inbounds [200010 x i32], ptr @a, i64 0, i64 %171
  store ptr %172, ptr %8, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %173 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %173, ptr %9, align 4, !tbaa !5
  br label %174

174:                                              ; preds = %185, %150
  %175 = load i32, ptr %9, align 4, !tbaa !5
  %176 = load i32, ptr @last, align 4, !tbaa !5
  %177 = icmp sgt i32 %175, %176
  br i1 %177, label %179, label %178

178:                                              ; preds = %174
  store i32 18, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %188

179:                                              ; preds = %174
  %180 = load ptr, ptr %8, align 8, !tbaa !15
  %181 = load i32, ptr %180, align 4, !tbaa !5
  %182 = load i32, ptr %9, align 4, !tbaa !5
  %183 = sext i32 %182 to i64
  %184 = getelementptr inbounds [200010 x i32], ptr @ans, i64 0, i64 %183
  store i32 %181, ptr %184, align 4, !tbaa !5
  br label %185

185:                                              ; preds = %179
  %186 = load i32, ptr %9, align 4, !tbaa !5
  %187 = add nsw i32 %186, -1
  store i32 %187, ptr %9, align 4, !tbaa !5
  br label %174, !llvm.loop !17

188:                                              ; preds = %178
  %189 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @last, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %190 = load i32, ptr %189, align 4, !tbaa !5
  store i32 %190, ptr @last, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %191

191:                                              ; preds = %188
  %192 = load i32, ptr %5, align 4, !tbaa !5
  %193 = add nsw i32 %192, -1
  store i32 %193, ptr %5, align 4, !tbaa !5
  br label %146, !llvm.loop !18

194:                                              ; preds = %149
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 1, ptr %10, align 4, !tbaa !5
  br label %195

195:                                              ; preds = %213, %194
  %196 = load i32, ptr %10, align 4, !tbaa !5
  %197 = load i32, ptr @n, align 4, !tbaa !5
  %198 = icmp sle i32 %196, %197
  br i1 %198, label %200, label %199

199:                                              ; preds = %195
  store i32 21, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %216

200:                                              ; preds = %195
  %201 = load i32, ptr %10, align 4, !tbaa !5
  %202 = sext i32 %201 to i64
  %203 = getelementptr inbounds [200010 x i32], ptr @ans, i64 0, i64 %202
  %204 = load i32, ptr %203, align 4, !tbaa !5
  %205 = load i32, ptr %10, align 4, !tbaa !5
  %206 = load i32, ptr @n, align 4, !tbaa !5
  %207 = icmp eq i32 %205, %206
  %208 = zext i1 %207 to i64
  %209 = getelementptr inbounds [3 x i8], ptr @.str.2, i64 0, i64 %208
  %210 = load i8, ptr %209, align 1, !tbaa !19
  %211 = sext i8 %210 to i32
  %212 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %204, i32 noundef %211)
  br label %213

213:                                              ; preds = %200
  %214 = load i32, ptr %10, align 4, !tbaa !5
  %215 = add nsw i32 %214, 1
  store i32 %215, ptr %10, align 4, !tbaa !5
  br label %195, !llvm.loop !20

216:                                              ; preds = %199
  ret i32 0
}

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

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

; Function Attrs: nocallback nofree 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 void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef, ptr noundef, ptr noundef) #4

; 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)) #5

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

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

!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 = !{!16, !16, i64 0}
!16 = !{!"any pointer", !7, i64 0}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}
!19 = !{!7, !7, i64 0}
!20 = distinct !{!20, !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 [200010 x i32], align 16
@l = external dso_local local_unnamed_addr global [200010 x i32], align 16
@r = external dso_local local_unnamed_addr global [200010 x i32], align 16
@stack = external dso_local local_unnamed_addr global [200010 x i32], align 16
@top = external dso_local local_unnamed_addr global i32, align 4
@id = external dso_local global [200010 x i32], align 16
@ans = external dso_local local_unnamed_addr global [200010 x i32], align 16
@last = 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 [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3cmpRKiS0_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = alloca i32, align 4
  %2 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %3 = load i32, ptr @n, align 4, !tbaa !5
  %.not55 = icmp slt i32 %3, 1
  br i1 %.not55, label %.sink.split, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph
  %.not4162 = icmp slt i32 %9, 1
  br i1 %.not4162, label %.sink.split, label %thread-pre-split.preheader

thread-pre-split.preheader:                       ; preds = %._crit_edge
  %4 = add nuw i32 %9, 1
  %wide.trip.count = zext i32 %4 to i64
  br label %thread-pre-split

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

thread-pre-split49.preheader:                     ; preds = %._crit_edge59
  store i32 0, ptr @top, align 4, !tbaa !5
  %11 = zext nneg i32 %9 to i64
  br label %thread-pre-split49

thread-pre-split:                                 ; preds = %thread-pre-split.preheader, %._crit_edge59
  %indvars.iv103 = phi i64 [ 1, %thread-pre-split.preheader ], [ %indvars.iv.next104, %._crit_edge59 ]
  %.pr6163 = phi i32 [ 0, %thread-pre-split.preheader ], [ %30, %._crit_edge59 ]
  %.not4657 = icmp eq i32 %.pr6163, 0
  br i1 %.not4657, label %._crit_edge59, label %.lr.ph58

.lr.ph58:                                         ; preds = %thread-pre-split
  %12 = getelementptr inbounds [200010 x i32], ptr @a, i64 0, i64 %indvars.iv103
  %13 = load i32, ptr %12, align 4, !tbaa !5
  %14 = sext i32 %.pr6163 to i64
  br label %15

15:                                               ; preds = %.lr.ph58, %21
  %indvars.iv100 = phi i64 [ %14, %.lr.ph58 ], [ %indvars.iv.next101, %21 ]
  %indvars.iv.next101 = add nsw i64 %indvars.iv100, -1
  %16 = getelementptr inbounds [200010 x i32], ptr @stack, i64 0, i64 %indvars.iv.next101
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [200010 x i32], ptr @a, i64 0, i64 %18
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %.not47 = icmp slt i32 %20, %13
  br i1 %.not47, label %.critedge, label %21

21:                                               ; preds = %15
  %.not46 = icmp eq i64 %indvars.iv.next101, 0
  br i1 %.not46, label %._crit_edge59, label %15, !llvm.loop !11

.critedge:                                        ; preds = %15
  %22 = trunc nsw i64 %indvars.iv100 to i32
  %23 = shl i64 %indvars.iv100, 32
  %sext = add i64 %23, -4294967296
  %24 = ashr exact i64 %sext, 32
  %25 = getelementptr inbounds [200010 x i32], ptr @stack, i64 0, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = add nsw i32 %26, 1
  br label %._crit_edge59

._crit_edge59:                                    ; preds = %21, %thread-pre-split, %.critedge
  %.sink = phi i32 [ %27, %.critedge ], [ 1, %thread-pre-split ], [ 1, %21 ]
  %28 = phi i32 [ %22, %.critedge ], [ 0, %thread-pre-split ], [ 0, %21 ]
  %29 = getelementptr inbounds [200010 x i32], ptr @l, i64 0, i64 %indvars.iv103
  store i32 %.sink, ptr %29, align 4, !tbaa !5
  %30 = add nsw i32 %28, 1
  %31 = sext i32 %28 to i64
  %32 = getelementptr inbounds [200010 x i32], ptr @stack, i64 0, i64 %31
  %33 = trunc nuw nsw i64 %indvars.iv103 to i32
  store i32 %33, ptr %32, align 4, !tbaa !5
  %indvars.iv.next104 = add nuw nsw i64 %indvars.iv103, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next104, %wide.trip.count
  br i1 %exitcond.not, label %thread-pre-split49.preheader, label %thread-pre-split, !llvm.loop !12

.sink.split:                                      ; preds = %._crit_edge69, %._crit_edge, %0
  %.sink133 = phi i32 [ 0, %0 ], [ 0, %._crit_edge ], [ %58, %._crit_edge69 ]
  %.lcssa54125127.ph = phi i32 [ %3, %0 ], [ %9, %._crit_edge ], [ %9, %._crit_edge69 ]
  store i32 %.sink133, ptr @top, align 4, !tbaa !5
  %34 = sext i32 %.lcssa54125127.ph to i64
  %35 = getelementptr inbounds i32, ptr @id, i64 %34
  %36 = getelementptr inbounds i8, ptr %35, i64 4
  tail call void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef nonnull getelementptr inbounds (i8, ptr @id, i64 4), ptr noundef nonnull %36, ptr noundef nonnull @_Z3cmpRKiS0_)
  %37 = load i32, ptr @n, align 4, !tbaa !5
  %38 = icmp sgt i32 %37, 0
  br i1 %38, label %.lr.ph83.preheader, label %._crit_edge87

.lr.ph83.preheader:                               ; preds = %.sink.split
  %39 = zext nneg i32 %37 to i64
  %.pre = load i32, ptr @last, align 4, !tbaa !5
  br label %.lr.ph83

thread-pre-split49:                               ; preds = %thread-pre-split49.preheader, %._crit_edge69
  %indvars.iv109 = phi i64 [ %11, %thread-pre-split49.preheader ], [ %indvars.iv.next110, %._crit_edge69 ]
  %.pr507273 = phi i32 [ 0, %thread-pre-split49.preheader ], [ %58, %._crit_edge69 ]
  %.not4367 = icmp eq i32 %.pr507273, 0
  br i1 %.not4367, label %._crit_edge69, label %.lr.ph68

.lr.ph68:                                         ; preds = %thread-pre-split49
  %40 = getelementptr inbounds [200010 x i32], ptr @a, i64 0, i64 %indvars.iv109
  %41 = load i32, ptr %40, align 4, !tbaa !5
  %42 = sext i32 %.pr507273 to i64
  br label %43

43:                                               ; preds = %.lr.ph68, %49
  %indvars.iv106 = phi i64 [ %42, %.lr.ph68 ], [ %indvars.iv.next107, %49 ]
  %indvars.iv.next107 = add nsw i64 %indvars.iv106, -1
  %44 = getelementptr inbounds [200010 x i32], ptr @stack, i64 0, i64 %indvars.iv.next107
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [200010 x i32], ptr @a, i64 0, i64 %46
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %.not44 = icmp slt i32 %48, %41
  br i1 %.not44, label %.critedge2, label %49

49:                                               ; preds = %43
  %.not43 = icmp eq i64 %indvars.iv.next107, 0
  br i1 %.not43, label %._crit_edge69, label %43, !llvm.loop !13

.critedge2:                                       ; preds = %43
  %50 = trunc nsw i64 %indvars.iv106 to i32
  %51 = shl i64 %indvars.iv106, 32
  %sext122 = add i64 %51, -4294967296
  %52 = ashr exact i64 %sext122, 32
  %53 = getelementptr inbounds [200010 x i32], ptr @stack, i64 0, i64 %52
  %54 = load i32, ptr %53, align 4, !tbaa !5
  %55 = add nsw i32 %54, -1
  br label %._crit_edge69

._crit_edge69:                                    ; preds = %49, %thread-pre-split49, %.critedge2
  %.lcssa131.sink = phi i32 [ %55, %.critedge2 ], [ %9, %thread-pre-split49 ], [ %9, %49 ]
  %56 = phi i32 [ %50, %.critedge2 ], [ 0, %thread-pre-split49 ], [ 0, %49 ]
  %57 = getelementptr inbounds [200010 x i32], ptr @r, i64 0, i64 %indvars.iv109
  store i32 %.lcssa131.sink, ptr %57, align 4, !tbaa !5
  %58 = add nsw i32 %56, 1
  %59 = sext i32 %56 to i64
  %60 = getelementptr inbounds [200010 x i32], ptr @stack, i64 0, i64 %59
  %61 = trunc nuw nsw i64 %indvars.iv109 to i32
  store i32 %61, ptr %60, align 4, !tbaa !5
  %indvars.iv.next110 = add nsw i64 %indvars.iv109, -1
  %62 = icmp sgt i64 %indvars.iv109, 1
  br i1 %62, label %thread-pre-split49, label %.sink.split, !llvm.loop !14

.preheader:                                       ; preds = %._crit_edge80
  %.pre121 = load i32, ptr @n, align 4, !tbaa !5
  %.not4284 = icmp slt i32 %.pre121, 1
  br i1 %.not4284, label %._crit_edge87, label %.lr.ph86

.lr.ph83:                                         ; preds = %.lr.ph83.preheader, %._crit_edge80
  %63 = phi i32 [ %.pre, %.lr.ph83.preheader ], [ %84, %._crit_edge80 ]
  %indvars.iv115 = phi i64 [ %39, %.lr.ph83.preheader ], [ %indvars.iv.next116, %._crit_edge80 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  %64 = getelementptr inbounds [200010 x i32], ptr @id, i64 0, i64 %indvars.iv115
  %65 = load i32, ptr %64, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [200010 x i32], ptr @r, i64 0, i64 %66
  %68 = load i32, ptr %67, align 4, !tbaa !5
  %69 = getelementptr inbounds [200010 x i32], ptr @l, i64 0, i64 %66
  %70 = load i32, ptr %69, align 4, !tbaa !5
  %71 = sub nsw i32 %68, %70
  %72 = add i32 %71, 1
  store i32 %72, ptr %1, align 4, !tbaa !5
  %.not = icmp slt i32 %71, %63
  br i1 %.not, label %._crit_edge80, label %.lr.ph79

.lr.ph79:                                         ; preds = %.lr.ph83
  %73 = getelementptr inbounds [200010 x i32], ptr @a, i64 0, i64 %66
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = sext i32 %72 to i64
  %76 = sext i32 %63 to i64
  %77 = add nsw i64 %75, -1
  %smin = call i64 @llvm.smin.i64(i64 %77, i64 %76)
  %78 = sub i64 %75, %smin
  %min.iters.check = icmp ult i64 %78, 8
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

scalar.ph.preheader:                              ; preds = %middle.block, %.lr.ph79
  %indvars.iv112.ph = phi i64 [ %75, %.lr.ph79 ], [ %ind.end, %middle.block ]
  br label %scalar.ph

vector.ph:                                        ; preds = %.lr.ph79
  %n.vec = and i64 %78, -8
  %ind.end = sub i64 %75, %n.vec
  %broadcast.splatinsert = insertelement <4 x i32> poison, i32 %74, i64 0
  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = sub i64 %75, %index
  %79 = getelementptr inbounds [200010 x i32], ptr @ans, i64 0, i64 %offset.idx
  %80 = getelementptr inbounds i8, ptr %79, i64 -12
  %81 = getelementptr inbounds i8, ptr %79, i64 -28
  store <4 x i32> %broadcast.splat, ptr %80, align 4, !tbaa !5
  store <4 x i32> %broadcast.splat, ptr %81, align 4, !tbaa !5
  %index.next = add nuw i64 %index, 8
  %82 = icmp eq i64 %index.next, %n.vec
  br i1 %82, label %middle.block, label %vector.body, !llvm.loop !15

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %78, %n.vec
  br i1 %cmp.n, label %._crit_edge80, label %scalar.ph.preheader

._crit_edge80:                                    ; preds = %scalar.ph, %middle.block, %.lr.ph83
  %83 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @last, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %84 = load i32, ptr %83, align 4, !tbaa !5
  store i32 %84, ptr @last, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  %indvars.iv.next116 = add nsw i64 %indvars.iv115, -1
  %85 = icmp sgt i64 %indvars.iv115, 1
  br i1 %85, label %.lr.ph83, label %.preheader, !llvm.loop !18

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv112 = phi i64 [ %indvars.iv.next113, %scalar.ph ], [ %indvars.iv112.ph, %scalar.ph.preheader ]
  %86 = getelementptr inbounds [200010 x i32], ptr @ans, i64 0, i64 %indvars.iv112
  store i32 %74, ptr %86, align 4, !tbaa !5
  %indvars.iv.next113 = add nsw i64 %indvars.iv112, -1
  %87 = icmp sgt i64 %indvars.iv.next113, %76
  br i1 %87, label %scalar.ph, label %._crit_edge80, !llvm.loop !19

._crit_edge87:                                    ; preds = %.lr.ph86, %.sink.split, %.preheader
  ret i32 0

.lr.ph86:                                         ; preds = %.preheader, %.lr.ph86
  %indvars.iv118 = phi i64 [ %indvars.iv.next119, %.lr.ph86 ], [ 1, %.preheader ]
  %88 = phi i32 [ %98, %.lr.ph86 ], [ %.pre121, %.preheader ]
  %89 = getelementptr inbounds [200010 x i32], ptr @ans, i64 0, i64 %indvars.iv118
  %90 = load i32, ptr %89, align 4, !tbaa !5
  %91 = zext i32 %88 to i64
  %92 = icmp eq i64 %indvars.iv118, %91
  %93 = zext i1 %92 to i64
  %94 = getelementptr inbounds [3 x i8], ptr @.str.2, i64 0, i64 %93
  %95 = load i8, ptr %94, align 1, !tbaa !20
  %96 = sext i8 %95 to i32
  %97 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %90, i32 noundef %96)
  %indvars.iv.next119 = add nuw nsw i64 %indvars.iv118, 1
  %98 = load i32, ptr @n, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %.not42.not = icmp slt i64 %indvars.iv118, %99
  br i1 %.not42.not, label %.lr.ph86, label %._crit_edge87, !llvm.loop !21
}

; 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 void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

; 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 #5

; 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 i64 @llvm.smin.i64(i64, i64) #6

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 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 #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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10, !16, !17}
!16 = !{!"llvm.loop.isvectorized", i32 1}
!17 = !{!"llvm.loop.unroll.runtime.disable"}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10, !17, !16}
!20 = !{!7, !7, i64 0}
!21 = distinct !{!21, !10}


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