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

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

%"struct.std::pair" = type { i32, i32 }
%"struct.std::greater" = type { i8 }

@n = external dso_local global i32, align 4
@f = external dso_local global [2002 x [2002 x i32]], align 16
@p = external dso_local global [2002 x %"struct.std::pair"], align 16
@.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 [4 x i8], align 1

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

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

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

18:                                               ; preds = %13
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [2002 x [2002 x i32]], ptr @f, i64 0, i64 %20
  %22 = load i32, ptr @n, align 4, !tbaa !5
  %23 = add nsw i32 %22, 1
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [2002 x i32], ptr %21, i64 0, i64 %24
  store i32 -2147483647, ptr %25, align 4, !tbaa !5
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [2002 x i32], ptr @f, i64 0, i64 %27
  store i32 -2147483647, ptr %28, align 4, !tbaa !5
  br label %29

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

32:                                               ; preds = %17
  store i32 0, ptr getelementptr inbounds ([2002 x i32], ptr @f, i64 0, i64 1), align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %33

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

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

38:                                               ; preds = %33
  %39 = load i32, ptr %3, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [2002 x %"struct.std::pair"], ptr @p, i64 0, i64 %40
  %42 = getelementptr inbounds %"struct.std::pair", ptr %41, i32 0, i32 0
  %43 = load i32, ptr %3, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [2002 x %"struct.std::pair"], ptr @p, i64 0, i64 %44
  %46 = getelementptr inbounds %"struct.std::pair", ptr %45, i32 0, i32 1
  %47 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %42, ptr noundef %46)
  br label %48

48:                                               ; preds = %38
  %49 = load i32, ptr %3, align 4, !tbaa !5
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %3, align 4, !tbaa !5
  br label %33, !llvm.loop !11

51:                                               ; preds = %37
  %52 = load i32, ptr @n, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds %"struct.std::pair", ptr @p, i64 %53
  call void @_ZSt4sortIPSt4pairIiiESt7greaterIS1_EEvT_S5_T0_(ptr noundef @p, ptr noundef %54)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %55

55:                                               ; preds = %139, %51
  %56 = load i32, ptr %5, align 4, !tbaa !5
  %57 = load i32, ptr @n, align 4, !tbaa !5
  %58 = icmp sle i32 %56, %57
  br i1 %58, label %60, label %59

59:                                               ; preds = %55
  store i32 8, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %142

60:                                               ; preds = %55
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %61 = load i32, ptr %5, align 4, !tbaa !5
  %62 = sub nsw i32 %61, 1
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [2002 x %"struct.std::pair"], ptr @p, i64 0, i64 %63
  %65 = getelementptr inbounds %"struct.std::pair", ptr %64, i32 0, i32 0
  store ptr %65, ptr %7, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %66 = load i32, ptr %5, align 4, !tbaa !5
  %67 = sub nsw i32 %66, 1
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [2002 x %"struct.std::pair"], ptr @p, i64 0, i64 %68
  %70 = getelementptr inbounds %"struct.std::pair", ptr %69, i32 0, i32 1
  store ptr %70, ptr %8, align 8, !tbaa !12
  %71 = load ptr, ptr %7, align 8, !tbaa !12
  %72 = load i32, ptr %71, align 4, !tbaa !5
  %73 = add nsw i32 %72, -1
  store i32 %73, ptr %71, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %74

74:                                               ; preds = %135, %60
  %75 = load i32, ptr %9, align 4, !tbaa !5
  %76 = load i32, ptr @n, align 4, !tbaa !5
  %77 = icmp sle i32 %75, %76
  br i1 %77, label %79, label %78

78:                                               ; preds = %74
  store i32 11, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %138

79:                                               ; preds = %74
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %80 = load i32, ptr %9, align 4, !tbaa !5
  %81 = load ptr, ptr %7, align 8, !tbaa !12
  %82 = load i32, ptr %81, align 4, !tbaa !5
  %83 = sub nsw i32 %80, %82
  %84 = icmp sgt i32 %83, 1
  br i1 %84, label %85, label %90

85:                                               ; preds = %79
  %86 = load i32, ptr %9, align 4, !tbaa !5
  %87 = load ptr, ptr %7, align 8, !tbaa !12
  %88 = load i32, ptr %87, align 4, !tbaa !5
  %89 = sub nsw i32 %86, %88
  br label %91

90:                                               ; preds = %79
  br label %91

91:                                               ; preds = %90, %85
  %92 = phi i32 [ %89, %85 ], [ 1, %90 ]
  store i32 %92, ptr %10, align 4, !tbaa !5
  %93 = load i32, ptr %5, align 4, !tbaa !5
  %94 = sub nsw i32 %93, 1
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [2002 x [2002 x i32]], ptr @f, i64 0, i64 %95
  %97 = load i32, ptr %9, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [2002 x i32], ptr %96, i64 0, i64 %98
  %100 = load i32, ptr %99, align 4, !tbaa !5
  %101 = load i32, ptr %5, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [2002 x [2002 x i32]], ptr @f, i64 0, i64 %102
  %104 = load i32, ptr %9, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [2002 x i32], ptr %103, i64 0, i64 %105
  store i32 %100, ptr %106, align 4, !tbaa !5
  %107 = load i32, ptr %5, align 4, !tbaa !5
  %108 = sub nsw i32 %107, 1
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [2002 x [2002 x i32]], ptr @f, i64 0, i64 %109
  %111 = load i32, ptr %10, align 4, !tbaa !5
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [2002 x i32], ptr %110, i64 0, i64 %112
  %114 = load i32, ptr %113, align 4, !tbaa !5
  %115 = icmp ne i32 %114, -2147483647
  br i1 %115, label %116, label %134

116:                                              ; preds = %91
  %117 = load i32, ptr %5, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [2002 x [2002 x i32]], ptr @f, i64 0, i64 %118
  %120 = load i32, ptr %9, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [2002 x i32], ptr %119, i64 0, i64 %121
  %123 = load i32, ptr %5, align 4, !tbaa !5
  %124 = sub nsw i32 %123, 1
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [2002 x [2002 x i32]], ptr @f, i64 0, i64 %125
  %127 = load i32, ptr %10, align 4, !tbaa !5
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds [2002 x i32], ptr %126, i64 0, i64 %128
  %130 = load i32, ptr %129, align 4, !tbaa !5
  %131 = load ptr, ptr %8, align 8, !tbaa !12
  %132 = load i32, ptr %131, align 4, !tbaa !5
  %133 = add nsw i32 %130, %132
  call void @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4) %122, i32 noundef %133)
  br label %134

134:                                              ; preds = %116, %91
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %135

135:                                              ; preds = %134
  %136 = load i32, ptr %9, align 4, !tbaa !5
  %137 = add nsw i32 %136, 1
  store i32 %137, ptr %9, align 4, !tbaa !5
  br label %74, !llvm.loop !14

138:                                              ; preds = %78
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %139

139:                                              ; preds = %138
  %140 = load i32, ptr %5, align 4, !tbaa !5
  %141 = add nsw i32 %140, 1
  store i32 %141, ptr %5, align 4, !tbaa !5
  br label %55, !llvm.loop !15

142:                                              ; preds = %59
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  store i32 1, ptr %11, align 4, !tbaa !5
  br label %143

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

147:                                              ; preds = %143
  store i32 14, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %163

148:                                              ; preds = %143
  %149 = load i32, ptr @n, align 4, !tbaa !5
  %150 = sext i32 %149 to i64
  %151 = getelementptr inbounds [2002 x [2002 x i32]], ptr @f, i64 0, i64 %150
  %152 = getelementptr inbounds [2002 x i32], ptr %151, i64 0, i64 0
  %153 = load i32, ptr @n, align 4, !tbaa !5
  %154 = sext i32 %153 to i64
  %155 = getelementptr inbounds [2002 x [2002 x i32]], ptr @f, i64 0, i64 %154
  %156 = load i32, ptr %11, align 4, !tbaa !5
  %157 = sext i32 %156 to i64
  %158 = getelementptr inbounds [2002 x i32], ptr %155, i64 0, i64 %157
  %159 = load i32, ptr %158, align 4, !tbaa !5
  call void @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4) %152, i32 noundef %159)
  br label %160

160:                                              ; preds = %148
  %161 = load i32, ptr %11, align 4, !tbaa !5
  %162 = add nsw i32 %161, 1
  store i32 %162, ptr %11, align 4, !tbaa !5
  br label %143, !llvm.loop !16

163:                                              ; preds = %147
  %164 = load i32, ptr @n, align 4, !tbaa !5
  %165 = sext i32 %164 to i64
  %166 = getelementptr inbounds [2002 x [2002 x i32]], ptr @f, i64 0, i64 %165
  %167 = getelementptr inbounds [2002 x i32], ptr %166, i64 0, i64 0
  %168 = load i32, ptr %167, align 8, !tbaa !5
  %169 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %168)
  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 @_ZSt4sortIPSt4pairIiiESt7greaterIS1_EEvT_S5_T0_(ptr noundef, ptr noundef) #4

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 = { 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 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !7, i64 0}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !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"

%"struct.std::pair" = type { i32, i32 }

@n = external dso_local global i32, align 4
@f = external dso_local global [2002 x [2002 x i32]], align 16
@p = external dso_local global [2002 x %"struct.std::pair"], align 16
@.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 [4 x i8], align 1

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

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

._crit_edge.thread:                               ; preds = %0
  store i32 0, ptr getelementptr inbounds (i8, ptr @f, i64 4), align 4, !tbaa !5
  br label %._crit_edge.._crit_edge51_crit_edge

.lr.ph:                                           ; preds = %0
  %3 = add nuw nsw i32 %2, 1
  %4 = zext nneg i32 %3 to i64
  %xtraiter = and i64 %4, 3
  %5 = icmp ult i32 %2, 3
  br i1 %5, label %._crit_edge.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %4, 2147483644
  br label %8

._crit_edge.unr-lcssa:                            ; preds = %8, %.lr.ph
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next.3, %8 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge.unr-lcssa, %.epil.preheader
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.epil.preheader ], [ %indvars.iv.unr, %._crit_edge.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.epil.preheader ], [ 0, %._crit_edge.unr-lcssa ]
  %6 = getelementptr inbounds [2002 x [2002 x i32]], ptr @f, i64 0, i64 %indvars.iv.epil, i64 %4
  store i32 -2147483647, ptr %6, align 4, !tbaa !5
  %7 = getelementptr inbounds [2002 x i32], ptr @f, i64 0, i64 %indvars.iv.epil
  store i32 -2147483647, ptr %7, align 4, !tbaa !5
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.epil.preheader, !llvm.loop !9

._crit_edge:                                      ; preds = %.epil.preheader, %._crit_edge.unr-lcssa
  store i32 0, ptr getelementptr inbounds (i8, ptr @f, i64 4), align 4, !tbaa !5
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %._crit_edge.._crit_edge51_crit_edge, label %.lr.ph50

._crit_edge.._crit_edge51_crit_edge:              ; preds = %._crit_edge.thread, %._crit_edge
  %.pre87 = sext i32 %2 to i64
  br label %._crit_edge51

8:                                                ; preds = %8, %.lr.ph.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.new ], [ %indvars.iv.next.3, %8 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.3, %8 ]
  %9 = getelementptr inbounds [2002 x [2002 x i32]], ptr @f, i64 0, i64 %indvars.iv, i64 %4
  store i32 -2147483647, ptr %9, align 4, !tbaa !5
  %10 = getelementptr inbounds [2002 x i32], ptr @f, i64 0, i64 %indvars.iv
  store i32 -2147483647, ptr %10, align 16, !tbaa !5
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %11 = getelementptr inbounds [2002 x [2002 x i32]], ptr @f, i64 0, i64 %indvars.iv.next, i64 %4
  store i32 -2147483647, ptr %11, align 4, !tbaa !5
  %12 = getelementptr inbounds [2002 x i32], ptr @f, i64 0, i64 %indvars.iv.next
  store i32 -2147483647, ptr %12, align 4, !tbaa !5
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %13 = getelementptr inbounds [2002 x [2002 x i32]], ptr @f, i64 0, i64 %indvars.iv.next.1, i64 %4
  store i32 -2147483647, ptr %13, align 4, !tbaa !5
  %14 = getelementptr inbounds [2002 x i32], ptr @f, i64 0, i64 %indvars.iv.next.1
  store i32 -2147483647, ptr %14, align 8, !tbaa !5
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %15 = getelementptr inbounds [2002 x [2002 x i32]], ptr @f, i64 0, i64 %indvars.iv.next.2, i64 %4
  store i32 -2147483647, ptr %15, align 4, !tbaa !5
  %16 = getelementptr inbounds [2002 x i32], ptr @f, i64 0, i64 %indvars.iv.next.2
  store i32 -2147483647, ptr %16, align 4, !tbaa !5
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %niter.next.3 = add nuw i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.unr-lcssa, label %8, !llvm.loop !11

._crit_edge51:                                    ; preds = %.lr.ph50, %._crit_edge.._crit_edge51_crit_edge
  %.pre-phi = phi i64 [ %.pre87, %._crit_edge.._crit_edge51_crit_edge ], [ %23, %.lr.ph50 ]
  %17 = getelementptr inbounds %"struct.std::pair", ptr @p, i64 %.pre-phi
  tail call void @_ZSt4sortIPSt4pairIiiESt7greaterIS1_EEvT_S5_T0_(ptr noundef nonnull @p, ptr noundef nonnull %17)
  %18 = load i32, ptr @n, align 4, !tbaa !5
  %.not4157 = icmp slt i32 %18, 1
  br i1 %.not4157, label %.preheader.._crit_edge64_crit_edge, label %.lr.ph60.split

.lr.ph50:                                         ; preds = %._crit_edge, %.lr.ph50
  %indvars.iv70 = phi i64 [ %indvars.iv.next71, %.lr.ph50 ], [ 0, %._crit_edge ]
  %19 = getelementptr inbounds [2002 x %"struct.std::pair"], ptr @p, i64 0, i64 %indvars.iv70
  %20 = getelementptr inbounds i8, ptr %19, i64 4
  %21 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %19, ptr noundef nonnull %20)
  %indvars.iv.next71 = add nuw nsw i64 %indvars.iv70, 1
  %22 = load i32, ptr @n, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = icmp slt i64 %indvars.iv.next71, %23
  br i1 %24, label %.lr.ph50, label %._crit_edge51, !llvm.loop !13

.preheader:                                       ; preds = %._crit_edge56
  %.not4261 = icmp slt i32 %32, 1
  br i1 %.not4261, label %.preheader.._crit_edge64_crit_edge, label %.lr.ph63

.preheader.._crit_edge64_crit_edge:               ; preds = %._crit_edge51, %.preheader
  %25 = phi i32 [ %32, %.preheader ], [ %18, %._crit_edge51 ]
  %.pre88 = sext i32 %25 to i64
  br label %._crit_edge64

.lr.ph60.split:                                   ; preds = %._crit_edge51, %._crit_edge56
  %26 = phi i32 [ %32, %._crit_edge56 ], [ %18, %._crit_edge51 ]
  %indvars.iv76 = phi i64 [ %indvars.iv.next77, %._crit_edge56 ], [ 1, %._crit_edge51 ]
  %27 = add nsw i64 %indvars.iv76, -1
  %28 = getelementptr inbounds [2002 x %"struct.std::pair"], ptr @p, i64 0, i64 %27
  %29 = getelementptr inbounds i8, ptr %28, i64 4
  %30 = load i32, ptr %28, align 8, !tbaa !5
  %31 = add nsw i32 %30, -1
  store i32 %31, ptr %28, align 8, !tbaa !5
  %.not4352 = icmp slt i32 %26, 0
  br i1 %.not4352, label %._crit_edge56, label %.lr.ph55

._crit_edge56:                                    ; preds = %48, %.lr.ph60.split
  %32 = phi i32 [ %26, %.lr.ph60.split ], [ %49, %48 ]
  %indvars.iv.next77 = add nuw nsw i64 %indvars.iv76, 1
  %33 = sext i32 %32 to i64
  %.not41.not = icmp slt i64 %indvars.iv76, %33
  br i1 %.not41.not, label %.lr.ph60.split, label %.preheader, !llvm.loop !14

.lr.ph55:                                         ; preds = %.lr.ph60.split, %48
  %34 = phi i32 [ %49, %48 ], [ %26, %.lr.ph60.split ]
  %35 = phi i32 [ %50, %48 ], [ %26, %.lr.ph60.split ]
  %indvars.iv73 = phi i64 [ %indvars.iv.next74, %48 ], [ 0, %.lr.ph60.split ]
  %36 = load i32, ptr %28, align 8, !tbaa !5
  %37 = trunc nuw nsw i64 %indvars.iv73 to i32
  %38 = sub nsw i32 %37, %36
  %spec.select = tail call i32 @llvm.smax.i32(i32 %38, i32 1)
  %39 = getelementptr inbounds [2002 x [2002 x i32]], ptr @f, i64 0, i64 %27, i64 %indvars.iv73
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = getelementptr inbounds [2002 x [2002 x i32]], ptr @f, i64 0, i64 %indvars.iv76, i64 %indvars.iv73
  store i32 %40, ptr %41, align 4, !tbaa !5
  %42 = zext nneg i32 %spec.select to i64
  %43 = getelementptr inbounds [2002 x [2002 x i32]], ptr @f, i64 0, i64 %27, i64 %42
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %.not44 = icmp eq i32 %44, -2147483647
  br i1 %.not44, label %48, label %45

45:                                               ; preds = %.lr.ph55
  %46 = load i32, ptr %29, align 4, !tbaa !5
  %47 = add nsw i32 %46, %44
  tail call void @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4) %41, i32 noundef %47)
  %.pre = load i32, ptr @n, align 4, !tbaa !5
  br label %48

48:                                               ; preds = %45, %.lr.ph55
  %49 = phi i32 [ %.pre, %45 ], [ %34, %.lr.ph55 ]
  %50 = phi i32 [ %.pre, %45 ], [ %35, %.lr.ph55 ]
  %indvars.iv.next74 = add nuw nsw i64 %indvars.iv73, 1
  %51 = sext i32 %50 to i64
  %.not43.not = icmp slt i64 %indvars.iv73, %51
  br i1 %.not43.not, label %.lr.ph55, label %._crit_edge56, !llvm.loop !16

._crit_edge64:                                    ; preds = %.lr.ph63, %.preheader.._crit_edge64_crit_edge
  %.pre-phi89 = phi i64 [ %.pre88, %.preheader.._crit_edge64_crit_edge ], [ %61, %.lr.ph63 ]
  %52 = getelementptr inbounds [2002 x [2002 x i32]], ptr @f, i64 0, i64 %.pre-phi89
  %53 = load i32, ptr %52, align 8, !tbaa !5
  %54 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %53)
  ret i32 0

.lr.ph63:                                         ; preds = %.preheader, %.lr.ph63
  %indvars.iv84 = phi i64 [ %indvars.iv.next85, %.lr.ph63 ], [ 1, %.preheader ]
  %55 = phi i32 [ %60, %.lr.ph63 ], [ %32, %.preheader ]
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [2002 x [2002 x i32]], ptr @f, i64 0, i64 %56
  %58 = getelementptr inbounds [2002 x [2002 x i32]], ptr @f, i64 0, i64 %56, i64 %indvars.iv84
  %59 = load i32, ptr %58, align 4, !tbaa !5
  tail call void @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4) %57, i32 noundef %59)
  %indvars.iv.next85 = add nuw nsw i64 %indvars.iv84, 1
  %60 = load i32, ptr @n, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %.not42.not = icmp slt i64 %indvars.iv84, %61
  br i1 %.not42.not, label %.lr.ph63, label %._crit_edge64, !llvm.loop !17
}

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

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

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

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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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.unroll.disable"}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12, !15}
!15 = !{!"llvm.loop.unswitch.partial.disable"}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}


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