; LLVM IR from tangjz/acm-icpc :: hdu (6119)

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

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@tmp = external dso_local global i64, align 8
@sum = external dso_local global i64, align 8
@ans = external dso_local global i64, align 8
@a = external dso_local global [100001 x %"struct.std::pair"], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3cmpRKSt4pairIiiES2_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) #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 i64, align 8
  store i32 0, ptr %1, align 4
  br label %8

8:                                                ; preds = %208, %0
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m)
  %10 = icmp eq i32 %9, 2
  br i1 %10, label %11, label %211

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

12:                                               ; preds = %27, %11
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = load i32, ptr @n, align 4, !tbaa !5
  %15 = icmp slt 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 %30

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

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

30:                                               ; preds = %16
  %31 = load i32, ptr @n, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds %"struct.std::pair", ptr @a, i64 %32
  call void @_ZSt4sortIPSt4pairIiiEPFbRKS1_S4_EEvT_S7_T0_(ptr noundef @a, ptr noundef %33, ptr noundef @_Z3cmpRKSt4pairIiiES2_)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %34

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

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

39:                                               ; preds = %34
  %40 = load i32, ptr %3, align 4, !tbaa !5
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %42, label %55

42:                                               ; preds = %39
  %43 = load i32, ptr %4, align 4, !tbaa !5
  %44 = sub nsw i32 %43, 1
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %45
  %47 = getelementptr inbounds %"struct.std::pair", ptr %46, i32 0, i32 0
  %48 = load i32, ptr %47, align 8, !tbaa !11
  %49 = load i32, ptr %4, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %50
  %52 = getelementptr inbounds %"struct.std::pair", ptr %51, i32 0, i32 0
  %53 = load i32, ptr %52, align 8, !tbaa !11
  %54 = icmp ne i32 %48, %53
  br i1 %54, label %55, label %98

55:                                               ; preds = %42, %39
  %56 = load i32, ptr %3, align 4, !tbaa !5
  %57 = icmp ne i32 %56, 0
  br i1 %57, label %58, label %88

58:                                               ; preds = %55
  %59 = load i32, ptr %3, align 4, !tbaa !5
  %60 = sub nsw i32 %59, 1
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %61
  %63 = getelementptr inbounds %"struct.std::pair", ptr %62, i32 0, i32 1
  %64 = load i32, ptr %63, align 4, !tbaa !13
  %65 = load i32, ptr %4, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %66
  %68 = getelementptr inbounds %"struct.std::pair", ptr %67, i32 0, i32 0
  %69 = load i32, ptr %68, align 8, !tbaa !11
  %70 = icmp sge i32 %64, %69
  br i1 %70, label %71, label %88

71:                                               ; preds = %58
  %72 = load i32, ptr %3, align 4, !tbaa !5
  %73 = sub nsw i32 %72, 1
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %74
  %76 = getelementptr inbounds %"struct.std::pair", ptr %75, i32 0, i32 1
  %77 = load i32, ptr %4, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %78
  %80 = getelementptr inbounds %"struct.std::pair", ptr %79, i32 0, i32 1
  %81 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %76, ptr noundef nonnull align 4 dereferenceable(4) %80)
  %82 = load i32, ptr %81, align 4, !tbaa !5
  %83 = load i32, ptr %3, align 4, !tbaa !5
  %84 = sub nsw i32 %83, 1
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %85
  %87 = getelementptr inbounds %"struct.std::pair", ptr %86, i32 0, i32 1
  store i32 %82, ptr %87, align 4, !tbaa !13
  br label %97

88:                                               ; preds = %58, %55
  %89 = load i32, ptr %4, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %90
  %92 = load i32, ptr %3, align 4, !tbaa !5
  %93 = add nsw i32 %92, 1
  store i32 %93, ptr %3, align 4, !tbaa !5
  %94 = sext i32 %92 to i64
  %95 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %94
  %96 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSERKS0_(ptr noundef nonnull align 4 dereferenceable(8) %95, ptr noundef nonnull align 4 dereferenceable(8) %91)
  br label %97

97:                                               ; preds = %88, %71
  br label %98

98:                                               ; preds = %97, %42
  br label %99

99:                                               ; preds = %98
  %100 = load i32, ptr %4, align 4, !tbaa !5
  %101 = add nsw i32 %100, 1
  store i32 %101, ptr %4, align 4, !tbaa !5
  br label %34, !llvm.loop !14

102:                                              ; preds = %38
  %103 = load i32, ptr %3, align 4, !tbaa !5
  store i32 %103, ptr @n, align 4, !tbaa !5
  store i64 0, ptr @sum, align 8, !tbaa !15
  store i64 0, ptr @tmp, align 8, !tbaa !15
  store i64 0, ptr @ans, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 0, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %104

104:                                              ; preds = %205, %102
  %105 = load i32, ptr %5, align 4, !tbaa !5
  %106 = load i32, ptr @n, align 4, !tbaa !5
  %107 = icmp slt i32 %105, %106
  br i1 %107, label %109, label %108

108:                                              ; preds = %104
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  br label %208

109:                                              ; preds = %104
  %110 = load i32, ptr %5, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %111
  %113 = getelementptr inbounds %"struct.std::pair", ptr %112, i32 0, i32 1
  %114 = load i32, ptr %113, align 4, !tbaa !13
  %115 = load i32, ptr %5, align 4, !tbaa !5
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %116
  %118 = getelementptr inbounds %"struct.std::pair", ptr %117, i32 0, i32 0
  %119 = load i32, ptr %118, align 8, !tbaa !11
  %120 = sub nsw i32 %114, %119
  %121 = add nsw i32 %120, 1
  %122 = sext i32 %121 to i64
  %123 = load i64, ptr @sum, align 8, !tbaa !15
  %124 = add nsw i64 %123, %122
  store i64 %124, ptr @sum, align 8, !tbaa !15
  %125 = load i32, ptr %6, align 4, !tbaa !5
  %126 = load i32, ptr %5, align 4, !tbaa !5
  %127 = icmp slt i32 %125, %126
  br i1 %127, label %128, label %145

128:                                              ; preds = %109
  %129 = load i32, ptr %5, align 4, !tbaa !5
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %130
  %132 = getelementptr inbounds %"struct.std::pair", ptr %131, i32 0, i32 0
  %133 = load i32, ptr %132, align 8, !tbaa !11
  %134 = load i32, ptr %5, align 4, !tbaa !5
  %135 = sub nsw i32 %134, 1
  %136 = sext i32 %135 to i64
  %137 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %136
  %138 = getelementptr inbounds %"struct.std::pair", ptr %137, i32 0, i32 1
  %139 = load i32, ptr %138, align 4, !tbaa !13
  %140 = sub nsw i32 %133, %139
  %141 = sub nsw i32 %140, 1
  %142 = sext i32 %141 to i64
  %143 = load i64, ptr @tmp, align 8, !tbaa !15
  %144 = add nsw i64 %143, %142
  store i64 %144, ptr @tmp, align 8, !tbaa !15
  br label %145

145:                                              ; preds = %128, %109
  br label %146

146:                                              ; preds = %189, %145
  %147 = load i32, ptr %6, align 4, !tbaa !5
  %148 = load i32, ptr %5, align 4, !tbaa !5
  %149 = icmp slt i32 %147, %148
  br i1 %149, label %150, label %155

150:                                              ; preds = %146
  %151 = load i64, ptr @tmp, align 8, !tbaa !15
  %152 = load i32, ptr @m, align 4, !tbaa !5
  %153 = sext i32 %152 to i64
  %154 = icmp sgt i64 %151, %153
  br label %155

155:                                              ; preds = %150, %146
  %156 = phi i1 [ false, %146 ], [ %154, %150 ]
  br i1 %156, label %157, label %192

157:                                              ; preds = %155
  %158 = load i32, ptr %6, align 4, !tbaa !5
  %159 = sext i32 %158 to i64
  %160 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %159
  %161 = getelementptr inbounds %"struct.std::pair", ptr %160, i32 0, i32 1
  %162 = load i32, ptr %161, align 4, !tbaa !13
  %163 = load i32, ptr %6, align 4, !tbaa !5
  %164 = sext i32 %163 to i64
  %165 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %164
  %166 = getelementptr inbounds %"struct.std::pair", ptr %165, i32 0, i32 0
  %167 = load i32, ptr %166, align 8, !tbaa !11
  %168 = sub nsw i32 %162, %167
  %169 = add nsw i32 %168, 1
  %170 = sext i32 %169 to i64
  %171 = load i64, ptr @sum, align 8, !tbaa !15
  %172 = sub nsw i64 %171, %170
  store i64 %172, ptr @sum, align 8, !tbaa !15
  %173 = load i32, ptr %6, align 4, !tbaa !5
  %174 = add nsw i32 %173, 1
  %175 = sext i32 %174 to i64
  %176 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %175
  %177 = getelementptr inbounds %"struct.std::pair", ptr %176, i32 0, i32 0
  %178 = load i32, ptr %177, align 8, !tbaa !11
  %179 = load i32, ptr %6, align 4, !tbaa !5
  %180 = sext i32 %179 to i64
  %181 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %180
  %182 = getelementptr inbounds %"struct.std::pair", ptr %181, i32 0, i32 1
  %183 = load i32, ptr %182, align 4, !tbaa !13
  %184 = sub nsw i32 %178, %183
  %185 = sub nsw i32 %184, 1
  %186 = sext i32 %185 to i64
  %187 = load i64, ptr @tmp, align 8, !tbaa !15
  %188 = sub nsw i64 %187, %186
  store i64 %188, ptr @tmp, align 8, !tbaa !15
  br label %189

189:                                              ; preds = %157
  %190 = load i32, ptr %6, align 4, !tbaa !5
  %191 = add nsw i32 %190, 1
  store i32 %191, ptr %6, align 4, !tbaa !5
  br label %146, !llvm.loop !17

192:                                              ; preds = %155
  %193 = load i64, ptr @tmp, align 8, !tbaa !15
  %194 = load i32, ptr @m, align 4, !tbaa !5
  %195 = sext i32 %194 to i64
  %196 = icmp sle i64 %193, %195
  br i1 %196, label %197, label %204

197:                                              ; preds = %192
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %198 = load i64, ptr @sum, align 8, !tbaa !15
  %199 = load i32, ptr @m, align 4, !tbaa !5
  %200 = sext i32 %199 to i64
  %201 = add nsw i64 %198, %200
  store i64 %201, ptr %7, align 8, !tbaa !15
  %202 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) @ans, ptr noundef nonnull align 8 dereferenceable(8) %7)
  %203 = load i64, ptr %202, align 8, !tbaa !15
  store i64 %203, ptr @ans, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  br label %204

204:                                              ; preds = %197, %192
  br label %205

205:                                              ; preds = %204
  %206 = load i32, ptr %5, align 4, !tbaa !5
  %207 = add nsw i32 %206, 1
  store i32 %207, ptr %5, align 4, !tbaa !5
  br label %104, !llvm.loop !18

208:                                              ; preds = %108
  %209 = load i64, ptr @ans, align 8, !tbaa !15
  %210 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %209)
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %8, !llvm.loop !19

211:                                              ; preds = %8
  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 @_ZSt4sortIPSt4pairIiiEPFbRKS1_S4_EEvT_S7_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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #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 = !{!12, !6, i64 0}
!12 = !{!"_ZTSSt4pairIiiE", !6, i64 0, !6, i64 4}
!13 = !{!12, !6, i64 4}
!14 = distinct !{!14, !10}
!15 = !{!16, !16, i64 0}
!16 = !{!"long long", !7, i64 0}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !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
@m = external dso_local global i32, align 4
@tmp = external dso_local local_unnamed_addr global i64, align 8
@sum = external dso_local local_unnamed_addr global i64, align 8
@ans = external dso_local global i64, align 8
@a = external dso_local global [100001 x %"struct.std::pair"], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = alloca i64, align 8
  %2 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %3 = icmp eq i32 %2, 2
  br i1 %3, label %.preheader, label %._crit_edge66

.preheader:                                       ; preds = %0, %._crit_edge65
  %4 = load i32, ptr @n, align 4, !tbaa !5
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.lr.ph, label %.preheader.._crit_edge_crit_edge

.preheader.._crit_edge_crit_edge:                 ; preds = %.preheader
  %.pre91 = sext i32 %4 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.preheader.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre91, %.preheader.._crit_edge_crit_edge ], [ %13, %.lr.ph ]
  %6 = getelementptr inbounds %"struct.std::pair", ptr @a, i64 %.pre-phi
  call void @_ZSt4sortIPSt4pairIiiEPFbRKS1_S4_EEvT_S7_T0_(ptr noundef nonnull @a, ptr noundef nonnull %6, ptr noundef nonnull @_Z3cmpRKSt4pairIiiES2_)
  %7 = load i32, ptr @n, align 4, !tbaa !5
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph49, label %._crit_edge50.thread

._crit_edge50.thread:                             ; preds = %._crit_edge
  store i32 0, ptr @n, align 4, !tbaa !5
  store i64 0, ptr @sum, align 8, !tbaa !9
  store i64 0, ptr @tmp, align 8, !tbaa !9
  store i64 0, ptr @ans, align 8, !tbaa !9
  br label %._crit_edge65

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.preheader ]
  %9 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %indvars.iv
  %10 = getelementptr inbounds i8, ptr %9, i64 4
  %11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %9, ptr noundef nonnull %10)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %12 = load i32, ptr @n, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = icmp slt i64 %indvars.iv.next, %13
  br i1 %14, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge50:                                    ; preds = %36
  store i32 %.136, ptr @n, align 4, !tbaa !5
  store i64 0, ptr @sum, align 8, !tbaa !9
  store i64 0, ptr @tmp, align 8, !tbaa !9
  store i64 0, ptr @ans, align 8, !tbaa !9
  %15 = icmp sgt i32 %.136, 0
  br i1 %15, label %.lr.ph64, label %._crit_edge65

.lr.ph49:                                         ; preds = %._crit_edge, %36
  %indvars.iv73 = phi i64 [ %indvars.iv.next74, %36 ], [ 0, %._crit_edge ]
  %.03546 = phi i32 [ %.136, %36 ], [ 0, %._crit_edge ]
  %.not39 = icmp eq i32 %.03546, 0
  br i1 %.not39, label %.critedge, label %16

16:                                               ; preds = %.lr.ph49
  %17 = add nsw i64 %indvars.iv73, -1
  %18 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %17
  %19 = load i32, ptr %18, align 8, !tbaa !13
  %20 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %indvars.iv73
  %21 = load i32, ptr %20, align 8, !tbaa !13
  %.not40 = icmp eq i32 %19, %21
  br i1 %.not40, label %36, label %22

22:                                               ; preds = %16
  %23 = add nsw i32 %.03546, -1
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %24, i32 1
  %26 = load i32, ptr %25, align 4, !tbaa !15
  %.not41 = icmp slt i32 %26, %21
  br i1 %.not41, label %.critedge, label %27

27:                                               ; preds = %22
  %28 = getelementptr inbounds i8, ptr %20, i64 4
  %29 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %25, ptr noundef nonnull align 4 dereferenceable(4) %28)
  %30 = load i32, ptr %29, align 4, !tbaa !5
  store i32 %30, ptr %25, align 4, !tbaa !15
  br label %36

.critedge:                                        ; preds = %.lr.ph49, %22
  %31 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %indvars.iv73
  %32 = add nsw i32 %.03546, 1
  %33 = sext i32 %.03546 to i64
  %34 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %33
  %35 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSERKS0_(ptr noundef nonnull align 4 dereferenceable(8) %34, ptr noundef nonnull align 4 dereferenceable(8) %31)
  br label %36

36:                                               ; preds = %16, %.critedge, %27
  %.136 = phi i32 [ %.03546, %27 ], [ %32, %.critedge ], [ %.03546, %16 ]
  %indvars.iv.next74 = add nuw nsw i64 %indvars.iv73, 1
  %37 = load i32, ptr @n, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = icmp slt i64 %indvars.iv.next74, %38
  br i1 %39, label %.lr.ph49, label %._crit_edge50, !llvm.loop !16

._crit_edge65:                                    ; preds = %96, %._crit_edge50.thread, %._crit_edge50
  %40 = phi i64 [ 0, %._crit_edge50 ], [ 0, %._crit_edge50.thread ], [ %97, %96 ]
  %41 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %40)
  %42 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %43 = icmp eq i32 %42, 2
  br i1 %43, label %.preheader, label %._crit_edge66, !llvm.loop !17

.lr.ph64:                                         ; preds = %._crit_edge50, %96
  %tmp.promoted.pre = phi i64 [ %tmp.promoted.pre87, %96 ], [ 0, %._crit_edge50 ]
  %44 = phi i64 [ %97, %96 ], [ 0, %._crit_edge50 ]
  %45 = phi i32 [ %98, %96 ], [ %.136, %._crit_edge50 ]
  %46 = phi i64 [ %99, %96 ], [ 0, %._crit_edge50 ]
  %indvars.iv79 = phi i64 [ %indvars.iv.next80, %96 ], [ 0, %._crit_edge50 ]
  %.062 = phi i32 [ %.1.lcssa95, %96 ], [ 0, %._crit_edge50 ]
  %47 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %indvars.iv79
  %48 = getelementptr inbounds i8, ptr %47, i64 4
  %49 = load i32, ptr %48, align 4, !tbaa !15
  %50 = load i32, ptr %47, align 8, !tbaa !13
  %51 = add i32 %49, 1
  %52 = sub i32 %51, %50
  %53 = sext i32 %52 to i64
  %54 = add nsw i64 %46, %53
  store i64 %54, ptr @sum, align 8, !tbaa !9
  %55 = sext i32 %.062 to i64
  %56 = icmp sgt i64 %indvars.iv79, %55
  br i1 %56, label %60, label %.thread

.thread:                                          ; preds = %.lr.ph64
  %57 = load i32, ptr @m, align 4
  %58 = sext i32 %57 to i64
  %59 = icmp sgt i64 %tmp.promoted.pre, %58
  br i1 %59, label %96, label %90

60:                                               ; preds = %.lr.ph64
  %61 = add nsw i64 %indvars.iv79, -1
  %62 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %61, i32 1
  %63 = load i32, ptr %62, align 4, !tbaa !15
  %64 = xor i32 %63, -1
  %65 = add i32 %50, %64
  %66 = sext i32 %65 to i64
  %67 = add nsw i64 %tmp.promoted.pre, %66
  store i64 %67, ptr @tmp, align 8, !tbaa !9
  %68 = load i32, ptr @m, align 4
  %69 = sext i32 %68 to i64
  %70 = icmp sgt i64 %67, %69
  br i1 %70, label %.lr.ph54.preheader, label %90

.lr.ph54.preheader:                               ; preds = %60
  %.phi.trans.insert = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %55
  %.pre84 = load i32, ptr %.phi.trans.insert, align 8, !tbaa !13
  br label %.lr.ph54

.lr.ph54:                                         ; preds = %.lr.ph54.preheader, %.lr.ph54
  %71 = phi i32 [ %.pre84, %.lr.ph54.preheader ], [ %81, %.lr.ph54 ]
  %indvars.iv76 = phi i64 [ %55, %.lr.ph54.preheader ], [ %indvars.iv.next77, %.lr.ph54 ]
  %72 = phi i64 [ %67, %.lr.ph54.preheader ], [ %85, %.lr.ph54 ]
  %73 = phi i64 [ %54, %.lr.ph54.preheader ], [ %79, %.lr.ph54 ]
  %74 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %indvars.iv76, i32 1
  %75 = load i32, ptr %74, align 4, !tbaa !15
  %76 = add i32 %75, 1
  %77 = sub i32 %76, %71
  %78 = sext i32 %77 to i64
  %79 = sub nsw i64 %73, %78
  %indvars.iv.next77 = add nsw i64 %indvars.iv76, 1
  %80 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %indvars.iv.next77
  %81 = load i32, ptr %80, align 8, !tbaa !13
  %82 = xor i32 %75, -1
  %83 = add i32 %81, %82
  %84 = sext i32 %83 to i64
  %85 = sub nsw i64 %72, %84
  %86 = icmp slt i64 %indvars.iv.next77, %indvars.iv79
  %87 = icmp sgt i64 %85, %69
  %88 = select i1 %86, i1 %87, i1 false
  br i1 %88, label %.lr.ph54, label %._crit_edge55, !llvm.loop !18

._crit_edge55:                                    ; preds = %.lr.ph54
  %89 = trunc nsw i64 %indvars.iv.next77 to i32
  store i64 %79, ptr @sum, align 8, !tbaa !9
  store i64 %85, ptr @tmp, align 8, !tbaa !9
  br i1 %87, label %96, label %90

90:                                               ; preds = %60, %.thread, %._crit_edge55
  %.1.lcssa94 = phi i32 [ %89, %._crit_edge55 ], [ %.062, %.thread ], [ %.062, %60 ]
  %91 = phi i64 [ %79, %._crit_edge55 ], [ %54, %.thread ], [ %54, %60 ]
  %92 = phi i64 [ %69, %._crit_edge55 ], [ %58, %.thread ], [ %69, %60 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #6
  %93 = add nsw i64 %91, %92
  store i64 %93, ptr %1, align 8, !tbaa !9
  %94 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) @ans, ptr noundef nonnull align 8 dereferenceable(8) %1)
  %95 = load i64, ptr %94, align 8, !tbaa !9
  store i64 %95, ptr @ans, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #6
  %.pre = load i64, ptr @sum, align 8, !tbaa !9
  %.pre85 = load i32, ptr @n, align 4, !tbaa !5
  %tmp.promoted.pre.pre = load i64, ptr @tmp, align 8
  br label %96

96:                                               ; preds = %.thread, %._crit_edge55, %90
  %.1.lcssa95 = phi i32 [ %.1.lcssa94, %90 ], [ %89, %._crit_edge55 ], [ %.062, %.thread ]
  %tmp.promoted.pre87 = phi i64 [ %tmp.promoted.pre.pre, %90 ], [ %85, %._crit_edge55 ], [ %tmp.promoted.pre, %.thread ]
  %97 = phi i64 [ %95, %90 ], [ %44, %._crit_edge55 ], [ %44, %.thread ]
  %98 = phi i32 [ %.pre85, %90 ], [ %45, %._crit_edge55 ], [ %45, %.thread ]
  %99 = phi i64 [ %.pre, %90 ], [ %79, %._crit_edge55 ], [ %54, %.thread ]
  %indvars.iv.next80 = add nuw nsw i64 %indvars.iv79, 1
  %100 = sext i32 %98 to i64
  %101 = icmp slt i64 %indvars.iv.next80, %100
  br i1 %101, label %.lr.ph64, label %._crit_edge65, !llvm.loop !19

._crit_edge66:                                    ; preds = %._crit_edge65, %0
  ret i32 0
}

; 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 @_ZSt4sortIPSt4pairIiiEPFbRKS1_S4_EEvT_S7_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: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSERKS0_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #0 align 2

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #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 = { 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 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !6, i64 0}
!14 = !{!"_ZTSSt4pairIiiE", !6, i64 0, !6, i64 4}
!15 = !{!14, !6, i64 4}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !12}


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