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

; 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 { i64, i64 }

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@sz = external dso_local global [2 x i32], align 4
@sum = external dso_local global i64, align 8
@vec = external dso_local global [61 x i64], align 16
@f = external dso_local global [2 x [10001 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 [10 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z6modifyRiPSt4pairIxxEx(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef, i64 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 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 i64, align 8
  %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 @t)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %13

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

17:                                               ; preds = %13
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %185

18:                                               ; preds = %13
  %19 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @sz)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %31, %18
  %21 = load i32, ptr %4, align 4, !tbaa !5
  %22 = load i32, ptr @sz, align 4, !tbaa !5
  %23 = icmp slt i32 %21, %22
  br i1 %23, label %25, label %24

24:                                               ; preds = %20
  store i32 5, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %34

25:                                               ; preds = %20
  %26 = load i32, ptr %4, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [10001 x %"struct.std::pair"], ptr @f, i64 0, i64 %27
  %29 = getelementptr inbounds %"struct.std::pair", ptr %28, i32 0, i32 0
  %30 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %29)
  br label %31

31:                                               ; preds = %25
  %32 = load i32, ptr %4, align 4, !tbaa !5
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %4, align 4, !tbaa !5
  br label %20, !llvm.loop !9

34:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %46, %34
  %36 = load i32, ptr %5, align 4, !tbaa !5
  %37 = load i32, ptr @sz, align 4, !tbaa !5
  %38 = icmp slt i32 %36, %37
  br i1 %38, label %40, label %39

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

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

46:                                               ; preds = %40
  %47 = load i32, ptr %5, align 4, !tbaa !5
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %5, align 4, !tbaa !5
  br label %35, !llvm.loop !11

49:                                               ; preds = %39
  %50 = load i32, ptr @sz, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds %"struct.std::pair", ptr @f, i64 %51
  call void @_ZSt4sortIPSt4pairIxxEEvT_S3_(ptr noundef @f, ptr noundef %52)
  %53 = load i64, ptr @f, align 16, !tbaa !12
  %54 = sub nsw i64 0, %53
  store i64 %54, ptr @sum, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %55

55:                                               ; preds = %68, %49
  %56 = load i32, ptr %6, align 4, !tbaa !5
  %57 = load i32, ptr @sz, align 4, !tbaa !5
  %58 = icmp slt i32 %56, %57
  br i1 %58, label %60, label %59

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

60:                                               ; preds = %55
  %61 = load i64, ptr @sum, align 8, !tbaa !15
  %62 = load i32, ptr %6, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [10001 x %"struct.std::pair"], ptr @f, i64 0, i64 %63
  %65 = getelementptr inbounds %"struct.std::pair", ptr %64, i32 0, i32 0
  %66 = load i64, ptr %65, align 16, !tbaa !12
  %67 = add nsw i64 %66, %61
  store i64 %67, ptr %65, align 16, !tbaa !12
  br label %68

68:                                               ; preds = %60
  %69 = load i32, ptr %6, align 4, !tbaa !5
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %6, align 4, !tbaa !5
  br label %55, !llvm.loop !16

71:                                               ; preds = %59
  %72 = load i32, ptr @sz, align 4, !tbaa !5
  store i32 %72, ptr getelementptr inbounds ([2 x i32], ptr @sz, i64 0, i64 1), align 4, !tbaa !5
  %73 = load i32, ptr @sz, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = mul i64 %74, 16
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 getelementptr inbounds ([2 x [10001 x %"struct.std::pair"]], ptr @f, i64 0, i64 1), ptr align 16 @f, i64 %75, i1 false)
  store i32 0, ptr @n, align 4, !tbaa !5
  br label %76

76:                                               ; preds = %99, %71
  %77 = load i64, ptr getelementptr inbounds (%"struct.std::pair", ptr @f, i32 0, i32 1), align 8, !tbaa !17
  %78 = icmp sgt i64 %77, 1
  br i1 %78, label %79, label %100

79:                                               ; preds = %76
  %80 = load i32, ptr @n, align 4, !tbaa !5
  %81 = add nsw i32 %80, 1
  store i32 %81, ptr @n, align 4, !tbaa !5
  %82 = sext i32 %80 to i64
  %83 = getelementptr inbounds [61 x i64], ptr @vec, i64 0, i64 %82
  store i64 0, ptr %83, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %84

84:                                               ; preds = %96, %79
  %85 = load i32, ptr %7, align 4, !tbaa !5
  %86 = load i32, ptr @sz, align 4, !tbaa !5
  %87 = icmp slt i32 %85, %86
  br i1 %87, label %89, label %88

88:                                               ; preds = %84
  store i32 16, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %99

89:                                               ; preds = %84
  %90 = load i32, ptr %7, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [10001 x %"struct.std::pair"], ptr @f, i64 0, i64 %91
  %93 = getelementptr inbounds %"struct.std::pair", ptr %92, i32 0, i32 1
  %94 = load i64, ptr %93, align 8, !tbaa !17
  %95 = ashr i64 %94, 1
  store i64 %95, ptr %93, align 8, !tbaa !17
  br label %96

96:                                               ; preds = %89
  %97 = load i32, ptr %7, align 4, !tbaa !5
  %98 = add nsw i32 %97, 1
  store i32 %98, ptr %7, align 4, !tbaa !5
  br label %84, !llvm.loop !18

99:                                               ; preds = %88
  br label %76, !llvm.loop !19

100:                                              ; preds = %76
  br label %101

101:                                              ; preds = %104, %100
  %102 = load i32, ptr @sz, align 4, !tbaa !5
  %103 = icmp sgt i32 %102, 1
  br i1 %103, label %104, label %110

104:                                              ; preds = %101
  %105 = load i64, ptr getelementptr inbounds ([10001 x %"struct.std::pair"], ptr @f, i64 0, i64 1), align 16, !tbaa !12
  %106 = load i32, ptr @n, align 4, !tbaa !5
  %107 = add nsw i32 %106, 1
  store i32 %107, ptr @n, align 4, !tbaa !5
  %108 = sext i32 %106 to i64
  %109 = getelementptr inbounds [61 x i64], ptr @vec, i64 0, i64 %108
  store i64 %105, ptr %109, align 8, !tbaa !15
  call void @_Z6modifyRiPSt4pairIxxEx(ptr noundef nonnull align 4 dereferenceable(4) @sz, ptr noundef @f, i64 noundef %105)
  br label %101, !llvm.loop !20

110:                                              ; preds = %101
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %111 = load i32, ptr @n, align 4, !tbaa !5
  %112 = sub nsw i32 %111, 1
  store i32 %112, ptr %8, align 4, !tbaa !5
  br label %113

113:                                              ; preds = %157, %110
  %114 = load i64, ptr @sum, align 8, !tbaa !15
  %115 = icmp sgt i64 %114, 0
  br i1 %115, label %117, label %116

116:                                              ; preds = %113
  store i32 21, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %160

117:                                              ; preds = %113
  %118 = load i32, ptr %8, align 4, !tbaa !5
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [61 x i64], ptr @vec, i64 0, i64 %119
  %121 = load i64, ptr %120, align 8, !tbaa !15
  call void @_Z6modifyRiPSt4pairIxxEx(ptr noundef nonnull align 4 dereferenceable(4) getelementptr inbounds ([2 x i32], ptr @sz, i64 0, i64 1), ptr noundef getelementptr inbounds ([2 x [10001 x %"struct.std::pair"]], ptr @f, i64 0, i64 1), i64 noundef %121)
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %122 = load i64, ptr @sum, align 8, !tbaa !15
  %123 = load i32, ptr %8, align 4, !tbaa !5
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [61 x i64], ptr @vec, i64 0, i64 %124
  %126 = load i64, ptr %125, align 8, !tbaa !15
  %127 = sub nsw i64 %122, %126
  store i64 %127, ptr %9, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %128

128:                                              ; preds = %152, %117
  %129 = load i32, ptr %10, align 4, !tbaa !5
  %130 = load i32, ptr getelementptr inbounds ([2 x i32], ptr @sz, i64 0, i64 1), align 4, !tbaa !5
  %131 = icmp slt i32 %129, %130
  br i1 %131, label %133, label %132

132:                                              ; preds = %128
  store i32 24, ptr %3, align 4
  br label %155

133:                                              ; preds = %128
  %134 = load i32, ptr %10, align 4, !tbaa !5
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [10001 x %"struct.std::pair"], ptr getelementptr inbounds ([2 x [10001 x %"struct.std::pair"]], ptr @f, i64 0, i64 1), i64 0, i64 %135
  %137 = getelementptr inbounds %"struct.std::pair", ptr %136, i32 0, i32 0
  %138 = load i64, ptr %137, align 16, !tbaa !12
  %139 = load i64, ptr %9, align 8, !tbaa !15
  %140 = icmp eq i64 %138, %139
  br i1 %140, label %141, label %151

141:                                              ; preds = %133
  %142 = load i64, ptr %9, align 8, !tbaa !15
  store i64 %142, ptr @sum, align 8, !tbaa !15
  %143 = load i32, ptr %8, align 4, !tbaa !5
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds [61 x i64], ptr @vec, i64 0, i64 %144
  %146 = load i64, ptr %145, align 8, !tbaa !15
  %147 = sub nsw i64 0, %146
  %148 = load i32, ptr %8, align 4, !tbaa !5
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds [61 x i64], ptr @vec, i64 0, i64 %149
  store i64 %147, ptr %150, align 8, !tbaa !15
  store i32 24, ptr %3, align 4
  br label %155

151:                                              ; preds = %133
  br label %152

152:                                              ; preds = %151
  %153 = load i32, ptr %10, align 4, !tbaa !5
  %154 = add nsw i32 %153, 1
  store i32 %154, ptr %10, align 4, !tbaa !5
  br label %128, !llvm.loop !21

155:                                              ; preds = %141, %132
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %156

156:                                              ; preds = %155
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  br label %157

157:                                              ; preds = %156
  %158 = load i32, ptr %8, align 4, !tbaa !5
  %159 = add nsw i32 %158, -1
  store i32 %159, ptr %8, align 4, !tbaa !5
  br label %113, !llvm.loop !22

160:                                              ; preds = %116
  %161 = load i32, ptr @n, align 4, !tbaa !5
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds i64, ptr @vec, i64 %162
  call void @_ZSt4sortIPxEvT_S1_(ptr noundef @vec, ptr noundef %163)
  %164 = load i32, ptr %2, align 4, !tbaa !5
  %165 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %164)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %166

166:                                              ; preds = %177, %160
  %167 = load i32, ptr %11, align 4, !tbaa !5
  %168 = load i32, ptr @n, align 4, !tbaa !5
  %169 = icmp slt i32 %167, %168
  br i1 %169, label %171, label %170

170:                                              ; preds = %166
  store i32 27, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %180

171:                                              ; preds = %166
  %172 = load i32, ptr %11, align 4, !tbaa !5
  %173 = sext i32 %172 to i64
  %174 = getelementptr inbounds [61 x i64], ptr @vec, i64 0, i64 %173
  %175 = load i64, ptr %174, align 8, !tbaa !15
  %176 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i64 noundef %175)
  br label %177

177:                                              ; preds = %171
  %178 = load i32, ptr %11, align 4, !tbaa !5
  %179 = add nsw i32 %178, 1
  store i32 %179, ptr %11, align 4, !tbaa !5
  br label %166, !llvm.loop !23

180:                                              ; preds = %170
  %181 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  br label %182

182:                                              ; preds = %180
  %183 = load i32, ptr %2, align 4, !tbaa !5
  %184 = add nsw i32 %183, 1
  store i32 %184, ptr %2, align 4, !tbaa !5
  br label %13, !llvm.loop !24

185:                                              ; preds = %17
  ret i32 0
}

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

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

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 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 nounwind willreturn memory(argmem: readwrite) }
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 = !{!13, !14, i64 0}
!13 = !{!"_ZTSSt4pairIxxE", !14, i64 0, !14, i64 8}
!14 = !{!"long long", !7, i64 0}
!15 = !{!14, !14, i64 0}
!16 = distinct !{!16, !10}
!17 = !{!13, !14, i64 8}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}
!21 = distinct !{!21, !10}
!22 = distinct !{!22, !10}
!23 = distinct !{!23, !10}
!24 = distinct !{!24, !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 { i64, i64 }

@t = external dso_local global i32, align 4
@n = external dso_local local_unnamed_addr global i32, align 4
@sz = external dso_local global [2 x i32], align 4
@sum = external dso_local local_unnamed_addr global i64, align 8
@vec = external dso_local global [61 x i64], align 16
@f = external dso_local global [2 x [10001 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 [10 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z6modifyRiPSt4pairIxxEx(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef, i64 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 @t)
  %2 = load i32, ptr @t, align 4, !tbaa !5
  %.not69 = icmp slt i32 %2, 1
  br i1 %.not69, label %._crit_edge73, label %.lr.ph72

._crit_edge73:                                    ; preds = %._crit_edge68, %0
  ret i32 0

.lr.ph72:                                         ; preds = %0, %._crit_edge68
  %.02970 = phi i32 [ %100, %._crit_edge68 ], [ 1, %0 ]
  %3 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @sz)
  %4 = load i32, ptr @sz, align 4, !tbaa !5
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.lr.ph, label %.preheader39.._crit_edge_crit_edge

.preheader39:                                     ; preds = %.lr.ph
  %6 = icmp sgt i32 %10, 0
  br i1 %6, label %.lr.ph43, label %.preheader39.._crit_edge_crit_edge

.preheader39.._crit_edge_crit_edge:               ; preds = %.lr.ph72, %.preheader39
  %7 = phi i32 [ %10, %.preheader39 ], [ %4, %.lr.ph72 ]
  %.pre105 = sext i32 %7 to i64
  br label %._crit_edge

.lr.ph:                                           ; preds = %.lr.ph72, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.lr.ph72 ]
  %8 = getelementptr inbounds [10001 x %"struct.std::pair"], ptr @f, i64 0, i64 %indvars.iv
  %9 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %8)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %10 = load i32, ptr @sz, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %12 = icmp slt i64 %indvars.iv.next, %11
  br i1 %12, label %.lr.ph, label %.preheader39, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph43, %.preheader39.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre105, %.preheader39.._crit_edge_crit_edge ], [ %22, %.lr.ph43 ]
  %13 = getelementptr inbounds %"struct.std::pair", ptr @f, i64 %.pre-phi
  tail call void @_ZSt4sortIPSt4pairIxxEEvT_S3_(ptr noundef nonnull @f, ptr noundef nonnull %13)
  %14 = load i64, ptr @f, align 16, !tbaa !11
  %15 = sub nsw i64 0, %14
  store i64 %15, ptr @sum, align 8, !tbaa !14
  %16 = load i32, ptr @sz, align 4, !tbaa !5
  %17 = icmp sgt i32 %16, 0
  br i1 %17, label %.lr.ph46.preheader, label %._crit_edge47

.lr.ph46.preheader:                               ; preds = %._crit_edge
  %wide.trip.count = zext nneg i32 %16 to i64
  %xtraiter = and i64 %wide.trip.count, 3
  %18 = icmp ult i32 %16, 4
  br i1 %18, label %._crit_edge47.loopexit.unr-lcssa, label %.lr.ph46.preheader.new

.lr.ph46.preheader.new:                           ; preds = %.lr.ph46.preheader
  %unroll_iter = and i64 %wide.trip.count, 2147483644
  br label %.lr.ph46

.lr.ph43:                                         ; preds = %.preheader39, %.lr.ph43
  %indvars.iv77 = phi i64 [ %indvars.iv.next78, %.lr.ph43 ], [ 0, %.preheader39 ]
  %19 = getelementptr inbounds [10001 x %"struct.std::pair"], ptr @f, i64 0, i64 %indvars.iv77, i32 1
  %20 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %19)
  %indvars.iv.next78 = add nuw nsw i64 %indvars.iv77, 1
  %21 = load i32, ptr @sz, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = icmp slt i64 %indvars.iv.next78, %22
  br i1 %23, label %.lr.ph43, label %._crit_edge, !llvm.loop !15

._crit_edge47.loopexit.unr-lcssa:                 ; preds = %.lr.ph46, %.lr.ph46.preheader
  %indvars.iv80.unr = phi i64 [ 0, %.lr.ph46.preheader ], [ %indvars.iv.next81.3, %.lr.ph46 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge47, label %.lr.ph46.epil

.lr.ph46.epil:                                    ; preds = %._crit_edge47.loopexit.unr-lcssa, %.lr.ph46.epil
  %indvars.iv80.epil = phi i64 [ %indvars.iv.next81.epil, %.lr.ph46.epil ], [ %indvars.iv80.unr, %._crit_edge47.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph46.epil ], [ 0, %._crit_edge47.loopexit.unr-lcssa ]
  %24 = getelementptr inbounds [10001 x %"struct.std::pair"], ptr @f, i64 0, i64 %indvars.iv80.epil
  %25 = load i64, ptr %24, align 16, !tbaa !11
  %26 = sub i64 %25, %14
  store i64 %26, ptr %24, align 16, !tbaa !11
  %indvars.iv.next81.epil = add nuw nsw i64 %indvars.iv80.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_edge47, label %.lr.ph46.epil, !llvm.loop !16

._crit_edge47:                                    ; preds = %._crit_edge47.loopexit.unr-lcssa, %.lr.ph46.epil, %._crit_edge
  store i32 %16, ptr getelementptr inbounds (i8, ptr @sz, i64 4), align 4, !tbaa !5
  %27 = sext i32 %16 to i64
  %28 = shl nsw i64 %27, 4
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 getelementptr inbounds (i8, ptr @f, i64 160016), ptr nonnull align 16 @f, i64 %28, i1 false)
  store i32 0, ptr @n, align 4, !tbaa !5
  %29 = load i64, ptr getelementptr inbounds (i8, ptr @f, i64 8), align 8, !tbaa !18
  %30 = icmp sgt i64 %29, 1
  br i1 %30, label %.lr.ph53, label %.preheader

.lr.ph53:                                         ; preds = %._crit_edge47
  %wide.trip.count86 = zext i32 %16 to i64
  %xtraiter109 = and i64 %wide.trip.count86, 3
  %31 = icmp ult i32 %16, 4
  %unroll_iter112 = and i64 %wide.trip.count86, 2147483644
  %lcmp.mod111.not = icmp eq i64 %xtraiter109, 0
  br label %52

.lr.ph46:                                         ; preds = %.lr.ph46, %.lr.ph46.preheader.new
  %indvars.iv80 = phi i64 [ 0, %.lr.ph46.preheader.new ], [ %indvars.iv.next81.3, %.lr.ph46 ]
  %niter = phi i64 [ 0, %.lr.ph46.preheader.new ], [ %niter.next.3, %.lr.ph46 ]
  %32 = getelementptr inbounds [10001 x %"struct.std::pair"], ptr @f, i64 0, i64 %indvars.iv80
  %33 = load i64, ptr %32, align 16, !tbaa !11
  %34 = sub i64 %33, %14
  store i64 %34, ptr %32, align 16, !tbaa !11
  %indvars.iv.next81 = or disjoint i64 %indvars.iv80, 1
  %35 = getelementptr inbounds [10001 x %"struct.std::pair"], ptr @f, i64 0, i64 %indvars.iv.next81
  %36 = load i64, ptr %35, align 16, !tbaa !11
  %37 = sub i64 %36, %14
  store i64 %37, ptr %35, align 16, !tbaa !11
  %indvars.iv.next81.1 = or disjoint i64 %indvars.iv80, 2
  %38 = getelementptr inbounds [10001 x %"struct.std::pair"], ptr @f, i64 0, i64 %indvars.iv.next81.1
  %39 = load i64, ptr %38, align 16, !tbaa !11
  %40 = sub i64 %39, %14
  store i64 %40, ptr %38, align 16, !tbaa !11
  %indvars.iv.next81.2 = or disjoint i64 %indvars.iv80, 3
  %41 = getelementptr inbounds [10001 x %"struct.std::pair"], ptr @f, i64 0, i64 %indvars.iv.next81.2
  %42 = load i64, ptr %41, align 16, !tbaa !11
  %43 = sub i64 %42, %14
  store i64 %43, ptr %41, align 16, !tbaa !11
  %indvars.iv.next81.3 = add nuw nsw i64 %indvars.iv80, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge47.loopexit.unr-lcssa, label %.lr.ph46, !llvm.loop !19

.loopexit38.loopexit.unr-lcssa:                   ; preds = %.lr.ph51, %.lr.ph51.preheader
  %indvars.iv83.unr = phi i64 [ 0, %.lr.ph51.preheader ], [ %indvars.iv.next84.3, %.lr.ph51 ]
  br i1 %lcmp.mod111.not, label %.loopexit38.loopexit, label %.lr.ph51.epil

.lr.ph51.epil:                                    ; preds = %.loopexit38.loopexit.unr-lcssa, %.lr.ph51.epil
  %indvars.iv83.epil = phi i64 [ %indvars.iv.next84.epil, %.lr.ph51.epil ], [ %indvars.iv83.unr, %.loopexit38.loopexit.unr-lcssa ]
  %epil.iter110 = phi i64 [ %epil.iter110.next, %.lr.ph51.epil ], [ 0, %.loopexit38.loopexit.unr-lcssa ]
  %44 = getelementptr inbounds [10001 x %"struct.std::pair"], ptr @f, i64 0, i64 %indvars.iv83.epil, i32 1
  %45 = load i64, ptr %44, align 8, !tbaa !18
  %46 = ashr i64 %45, 1
  store i64 %46, ptr %44, align 8, !tbaa !18
  %indvars.iv.next84.epil = add nuw nsw i64 %indvars.iv83.epil, 1
  %epil.iter110.next = add i64 %epil.iter110, 1
  %epil.iter110.cmp.not = icmp eq i64 %epil.iter110.next, %xtraiter109
  br i1 %epil.iter110.cmp.not, label %.loopexit38.loopexit, label %.lr.ph51.epil, !llvm.loop !20

.loopexit38.loopexit:                             ; preds = %.lr.ph51.epil, %.loopexit38.loopexit.unr-lcssa
  %.pre = load i64, ptr getelementptr inbounds (i8, ptr @f, i64 8), align 8, !tbaa !18
  br label %.loopexit38

.loopexit38:                                      ; preds = %.loopexit38.loopexit, %52
  %47 = phi i64 [ %.pre, %.loopexit38.loopexit ], [ %53, %52 ]
  %48 = icmp sgt i64 %47, 1
  br i1 %48, label %52, label %..preheader_crit_edge, !llvm.loop !21

..preheader_crit_edge:                            ; preds = %.loopexit38
  %49 = trunc nsw i64 %indvars.iv.next89 to i32
  store i32 %49, ptr @n, align 4, !tbaa !5
  br label %.preheader

.preheader:                                       ; preds = %..preheader_crit_edge, %._crit_edge47
  %50 = phi i32 [ %49, %..preheader_crit_edge ], [ 0, %._crit_edge47 ]
  %51 = icmp sgt i32 %16, 1
  br i1 %51, label %.lr.ph55, label %._crit_edge56

52:                                               ; preds = %.lr.ph53, %.loopexit38
  %53 = phi i64 [ %29, %.lr.ph53 ], [ %47, %.loopexit38 ]
  %indvars.iv88 = phi i64 [ 0, %.lr.ph53 ], [ %indvars.iv.next89, %.loopexit38 ]
  %indvars.iv.next89 = add nuw nsw i64 %indvars.iv88, 1
  %54 = getelementptr inbounds [61 x i64], ptr @vec, i64 0, i64 %indvars.iv88
  store i64 0, ptr %54, align 8, !tbaa !14
  br i1 %17, label %.lr.ph51.preheader, label %.loopexit38

.lr.ph51.preheader:                               ; preds = %52
  br i1 %31, label %.loopexit38.loopexit.unr-lcssa, label %.lr.ph51

.lr.ph51:                                         ; preds = %.lr.ph51.preheader, %.lr.ph51
  %indvars.iv83 = phi i64 [ %indvars.iv.next84.3, %.lr.ph51 ], [ 0, %.lr.ph51.preheader ]
  %niter113 = phi i64 [ %niter113.next.3, %.lr.ph51 ], [ 0, %.lr.ph51.preheader ]
  %55 = getelementptr inbounds [10001 x %"struct.std::pair"], ptr @f, i64 0, i64 %indvars.iv83, i32 1
  %56 = load i64, ptr %55, align 8, !tbaa !18
  %57 = ashr i64 %56, 1
  store i64 %57, ptr %55, align 8, !tbaa !18
  %indvars.iv.next84 = or disjoint i64 %indvars.iv83, 1
  %58 = getelementptr inbounds [10001 x %"struct.std::pair"], ptr @f, i64 0, i64 %indvars.iv.next84, i32 1
  %59 = load i64, ptr %58, align 8, !tbaa !18
  %60 = ashr i64 %59, 1
  store i64 %60, ptr %58, align 8, !tbaa !18
  %indvars.iv.next84.1 = or disjoint i64 %indvars.iv83, 2
  %61 = getelementptr inbounds [10001 x %"struct.std::pair"], ptr @f, i64 0, i64 %indvars.iv.next84.1, i32 1
  %62 = load i64, ptr %61, align 8, !tbaa !18
  %63 = ashr i64 %62, 1
  store i64 %63, ptr %61, align 8, !tbaa !18
  %indvars.iv.next84.2 = or disjoint i64 %indvars.iv83, 3
  %64 = getelementptr inbounds [10001 x %"struct.std::pair"], ptr @f, i64 0, i64 %indvars.iv.next84.2, i32 1
  %65 = load i64, ptr %64, align 8, !tbaa !18
  %66 = ashr i64 %65, 1
  store i64 %66, ptr %64, align 8, !tbaa !18
  %indvars.iv.next84.3 = add nuw nsw i64 %indvars.iv83, 4
  %niter113.next.3 = add i64 %niter113, 4
  %niter113.ncmp.3 = icmp eq i64 %niter113.next.3, %unroll_iter112
  br i1 %niter113.ncmp.3, label %.loopexit38.loopexit.unr-lcssa, label %.lr.ph51, !llvm.loop !22

.lr.ph55:                                         ; preds = %.preheader, %.lr.ph55
  %67 = load i64, ptr getelementptr inbounds (i8, ptr @f, i64 16), align 16, !tbaa !11
  %68 = load i32, ptr @n, align 4, !tbaa !5
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr @n, align 4, !tbaa !5
  %70 = sext i32 %68 to i64
  %71 = getelementptr inbounds [61 x i64], ptr @vec, i64 0, i64 %70
  store i64 %67, ptr %71, align 8, !tbaa !14
  tail call void @_Z6modifyRiPSt4pairIxxEx(ptr noundef nonnull align 4 dereferenceable(4) @sz, ptr noundef nonnull @f, i64 noundef %67)
  %72 = load i32, ptr @sz, align 4, !tbaa !5
  %73 = icmp sgt i32 %72, 1
  br i1 %73, label %.lr.ph55, label %._crit_edge56.loopexit, !llvm.loop !23

._crit_edge56.loopexit:                           ; preds = %.lr.ph55
  %.pre102 = load i32, ptr @n, align 4, !tbaa !5
  %.pre103 = load i64, ptr @sum, align 8, !tbaa !14
  br label %._crit_edge56

._crit_edge56:                                    ; preds = %._crit_edge56.loopexit, %.preheader
  %74 = phi i64 [ %.pre103, %._crit_edge56.loopexit ], [ %15, %.preheader ]
  %75 = phi i32 [ %.pre102, %._crit_edge56.loopexit ], [ %50, %.preheader ]
  %76 = icmp sgt i64 %74, 0
  br i1 %76, label %.lr.ph63.preheader, label %._crit_edge64

.lr.ph63.preheader:                               ; preds = %._crit_edge56
  %77 = sext i32 %75 to i64
  br label %.lr.ph63

._crit_edge64.loopexit:                           ; preds = %.loopexit
  %.pre104 = load i32, ptr @n, align 4, !tbaa !5
  br label %._crit_edge64

._crit_edge64:                                    ; preds = %._crit_edge64.loopexit, %._crit_edge56
  %78 = phi i32 [ %.pre104, %._crit_edge64.loopexit ], [ %75, %._crit_edge56 ]
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds i64, ptr @vec, i64 %79
  tail call void @_ZSt4sortIPxEvT_S1_(ptr noundef nonnull @vec, ptr noundef nonnull %80)
  %81 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %.02970)
  %82 = load i32, ptr @n, align 4, !tbaa !5
  %83 = icmp sgt i32 %82, 0
  br i1 %83, label %.lr.ph67, label %._crit_edge68

.lr.ph63:                                         ; preds = %.lr.ph63.preheader, %.loopexit
  %indvars.iv96 = phi i64 [ %77, %.lr.ph63.preheader ], [ %indvars.iv.next97, %.loopexit ]
  %indvars.iv.next97 = add nsw i64 %indvars.iv96, -1
  %84 = getelementptr inbounds [61 x i64], ptr @vec, i64 0, i64 %indvars.iv.next97
  %85 = load i64, ptr %84, align 8, !tbaa !14
  tail call void @_Z6modifyRiPSt4pairIxxEx(ptr noundef nonnull align 4 dereferenceable(4) getelementptr inbounds (i8, ptr @sz, i64 4), ptr noundef nonnull getelementptr inbounds (i8, ptr @f, i64 160016), i64 noundef %85)
  %86 = load i64, ptr @sum, align 8, !tbaa !14
  %87 = load i64, ptr %84, align 8, !tbaa !14
  %88 = sub nsw i64 %86, %87
  %89 = load i32, ptr getelementptr inbounds (i8, ptr @sz, i64 4), align 4, !tbaa !5
  %90 = icmp sgt i32 %89, 0
  br i1 %90, label %.lr.ph59.preheader, label %.loopexit

.lr.ph59.preheader:                               ; preds = %.lr.ph63
  %wide.trip.count94 = zext nneg i32 %89 to i64
  br label %.lr.ph59

91:                                               ; preds = %.lr.ph59
  %indvars.iv.next92 = add nuw nsw i64 %indvars.iv91, 1
  %exitcond95.not = icmp eq i64 %indvars.iv.next92, %wide.trip.count94
  br i1 %exitcond95.not, label %.loopexit, label %.lr.ph59, !llvm.loop !24

.lr.ph59:                                         ; preds = %.lr.ph59.preheader, %91
  %indvars.iv91 = phi i64 [ 0, %.lr.ph59.preheader ], [ %indvars.iv.next92, %91 ]
  %92 = getelementptr inbounds [10001 x %"struct.std::pair"], ptr getelementptr inbounds (i8, ptr @f, i64 160016), i64 0, i64 %indvars.iv91
  %93 = load i64, ptr %92, align 16, !tbaa !11
  %94 = icmp eq i64 %93, %88
  br i1 %94, label %95, label %91

95:                                               ; preds = %.lr.ph59
  store i64 %88, ptr @sum, align 8, !tbaa !14
  %96 = sub nsw i64 0, %87
  store i64 %96, ptr %84, align 8, !tbaa !14
  br label %.loopexit

.loopexit:                                        ; preds = %91, %.lr.ph63, %95
  %97 = phi i64 [ %86, %.lr.ph63 ], [ %88, %95 ], [ %86, %91 ]
  %98 = icmp sgt i64 %97, 0
  br i1 %98, label %.lr.ph63, label %._crit_edge64.loopexit, !llvm.loop !25

._crit_edge68:                                    ; preds = %.lr.ph67, %._crit_edge64
  %99 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  %100 = add nuw nsw i32 %.02970, 1
  %101 = load i32, ptr @t, align 4, !tbaa !5
  %.not.not = icmp slt i32 %.02970, %101
  br i1 %.not.not, label %.lr.ph72, label %._crit_edge73, !llvm.loop !26

.lr.ph67:                                         ; preds = %._crit_edge64, %.lr.ph67
  %indvars.iv99 = phi i64 [ %indvars.iv.next100, %.lr.ph67 ], [ 0, %._crit_edge64 ]
  %102 = getelementptr inbounds [61 x i64], ptr @vec, i64 0, i64 %indvars.iv99
  %103 = load i64, ptr %102, align 8, !tbaa !14
  %104 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i64 noundef %103)
  %indvars.iv.next100 = add nuw nsw i64 %indvars.iv99, 1
  %105 = load i32, ptr @n, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = icmp slt i64 %indvars.iv.next100, %106
  br i1 %107, label %.lr.ph67, label %._crit_edge68, !llvm.loop !27
}

; 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 @_ZSt4sortIPSt4pairIxxEEvT_S3_(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

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

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

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 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }

!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 = !{!12, !13, i64 0}
!12 = !{!"_ZTSSt4pairIxxE", !13, i64 0, !13, i64 8}
!13 = !{!"long long", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.unroll.disable"}
!18 = !{!12, !13, i64 8}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !17}
!21 = distinct !{!21, !10}
!22 = distinct !{!22, !10}
!23 = distinct !{!23, !10}
!24 = distinct !{!24, !10}
!25 = distinct !{!25, !10}
!26 = distinct !{!26, !10}
!27 = distinct !{!27, !10}


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