; LLVM IR from Aryansh-S/USACO :: USACO/2020/Open/Silver (moop)

; 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 }
%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }

@n = external dso_local global i32, align 4
@ans = external dso_local global i32, align 4
@minl = external dso_local global [100000 x i32], align 16
@maxr = external dso_local global [100000 x i32], align 16
@pts = external dso_local global [100000 x %"struct.std::pair"], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str.5 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external global ptr, align 8
@.str.7 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external global ptr, align 8

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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
  store i32 0, ptr %1, align 4
  %6 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %7 = getelementptr i8, ptr %6, i64 -24
  %8 = load i64, ptr %7, align 8
  %9 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %8
  %10 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %9, ptr noundef null)
  %11 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %12 = call noalias ptr @fopen(ptr noundef @.str.5, ptr noundef @.str.6)
  %13 = icmp ne ptr %12, null
  br i1 %13, label %14, label %19

14:                                               ; preds = %0
  %15 = load ptr, ptr @stdin, align 8, !tbaa !8
  %16 = call ptr @freopen(ptr noundef @.str.5, ptr noundef @.str.6, ptr noundef %15)
  %17 = load ptr, ptr @stdout, align 8, !tbaa !8
  %18 = call ptr @freopen(ptr noundef @.str.7, ptr noundef @.str.8, ptr noundef %17)
  br label %19

19:                                               ; preds = %14, %0
  call void @_Z2inIiJEEvRT_DpRT0_(ptr noundef nonnull align 4 dereferenceable(4) @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  %20 = load i32, ptr @n, align 4, !tbaa !11
  %21 = icmp sgt i32 0, %20
  %22 = zext i1 %21 to i32
  %23 = sub nsw i32 0, %22
  store i32 %23, ptr %2, align 4, !tbaa !11
  br label %24

24:                                               ; preds = %42, %19
  %25 = load i32, ptr %2, align 4, !tbaa !11
  %26 = load i32, ptr @n, align 4, !tbaa !11
  %27 = load i32, ptr @n, align 4, !tbaa !11
  %28 = icmp sgt i32 0, %27
  %29 = zext i1 %28 to i32
  %30 = sub nsw i32 %26, %29
  %31 = icmp ne i32 %25, %30
  br i1 %31, label %33, label %32

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

33:                                               ; preds = %24
  %34 = load i32, ptr %2, align 4, !tbaa !11
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [100000 x %"struct.std::pair"], ptr @pts, i64 0, i64 %35
  %37 = getelementptr inbounds %"struct.std::pair", ptr %36, i32 0, i32 0
  %38 = load i32, ptr %2, align 4, !tbaa !11
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [100000 x %"struct.std::pair"], ptr @pts, i64 0, i64 %39
  %41 = getelementptr inbounds %"struct.std::pair", ptr %40, i32 0, i32 1
  call void @_Z2inIiJiEEvRT_DpRT0_(ptr noundef nonnull align 4 dereferenceable(4) %37, ptr noundef nonnull align 4 dereferenceable(4) %41)
  br label %42

42:                                               ; preds = %33
  %43 = load i32, ptr @n, align 4, !tbaa !11
  %44 = icmp sgt i32 0, %43
  %45 = zext i1 %44 to i64
  %46 = select i1 %44, i32 -1, i32 1
  %47 = load i32, ptr %2, align 4, !tbaa !11
  %48 = add nsw i32 %47, %46
  store i32 %48, ptr %2, align 4, !tbaa !11
  br label %24, !llvm.loop !13

49:                                               ; preds = %32
  %50 = load i32, ptr @n, align 4, !tbaa !11
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds %"struct.std::pair", ptr @pts, i64 %51
  call void @_ZSt4sortIPSt4pairIiiEEvT_S3_(ptr noundef @pts, ptr noundef %52)
  %53 = load i32, ptr getelementptr inbounds (%"struct.std::pair", ptr @pts, i32 0, i32 1), align 4, !tbaa !15
  store i32 %53, ptr @minl, align 16, !tbaa !11
  %54 = load i32, ptr @n, align 4, !tbaa !11
  %55 = sub nsw i32 %54, 1
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [100000 x %"struct.std::pair"], ptr @pts, i64 0, i64 %56
  %58 = getelementptr inbounds %"struct.std::pair", ptr %57, i32 0, i32 1
  %59 = load i32, ptr %58, align 4, !tbaa !15
  %60 = load i32, ptr @n, align 4, !tbaa !11
  %61 = sub nsw i32 %60, 1
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [100000 x i32], ptr @maxr, i64 0, i64 %62
  store i32 %59, ptr %63, align 4, !tbaa !11
  store i32 1, ptr @ans, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  %64 = load i32, ptr @n, align 4, !tbaa !11
  %65 = sub nsw i32 %64, 1
  %66 = add nsw i32 %65, 1
  %67 = icmp sgt i32 1, %66
  %68 = zext i1 %67 to i32
  %69 = sub nsw i32 1, %68
  store i32 %69, ptr %3, align 4, !tbaa !11
  br label %70

70:                                               ; preds = %97, %49
  %71 = load i32, ptr %3, align 4, !tbaa !11
  %72 = load i32, ptr @n, align 4, !tbaa !11
  %73 = sub nsw i32 %72, 1
  %74 = add nsw i32 %73, 1
  %75 = load i32, ptr @n, align 4, !tbaa !11
  %76 = sub nsw i32 %75, 1
  %77 = add nsw i32 %76, 1
  %78 = icmp sgt i32 1, %77
  %79 = zext i1 %78 to i32
  %80 = sub nsw i32 %74, %79
  %81 = icmp ne i32 %71, %80
  br i1 %81, label %83, label %82

82:                                               ; preds = %70
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  br label %106

83:                                               ; preds = %70
  %84 = load i32, ptr %3, align 4, !tbaa !11
  %85 = sub nsw i32 %84, 1
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [100000 x i32], ptr @minl, i64 0, i64 %86
  %88 = load i32, ptr %3, align 4, !tbaa !11
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [100000 x %"struct.std::pair"], ptr @pts, i64 0, i64 %89
  %91 = getelementptr inbounds %"struct.std::pair", ptr %90, i32 0, i32 1
  %92 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %87, ptr noundef nonnull align 4 dereferenceable(4) %91)
  %93 = load i32, ptr %92, align 4, !tbaa !11
  %94 = load i32, ptr %3, align 4, !tbaa !11
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [100000 x i32], ptr @minl, i64 0, i64 %95
  store i32 %93, ptr %96, align 4, !tbaa !11
  br label %97

97:                                               ; preds = %83
  %98 = load i32, ptr @n, align 4, !tbaa !11
  %99 = sub nsw i32 %98, 1
  %100 = add nsw i32 %99, 1
  %101 = icmp sgt i32 1, %100
  %102 = zext i1 %101 to i64
  %103 = select i1 %101, i32 -1, i32 1
  %104 = load i32, ptr %3, align 4, !tbaa !11
  %105 = add nsw i32 %104, %103
  store i32 %105, ptr %3, align 4, !tbaa !11
  br label %70, !llvm.loop !17

106:                                              ; preds = %82
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  %107 = load i32, ptr @n, align 4, !tbaa !11
  %108 = sub nsw i32 %107, 1
  %109 = load i32, ptr @n, align 4, !tbaa !11
  %110 = sub nsw i32 %109, 1
  %111 = icmp sgt i32 %110, 0
  %112 = zext i1 %111 to i32
  %113 = sub nsw i32 %108, %112
  store i32 %113, ptr %4, align 4, !tbaa !11
  br label %114

114:                                              ; preds = %137, %106
  %115 = load i32, ptr %4, align 4, !tbaa !11
  %116 = load i32, ptr @n, align 4, !tbaa !11
  %117 = sub nsw i32 %116, 1
  %118 = icmp sgt i32 %117, 0
  %119 = zext i1 %118 to i32
  %120 = sub nsw i32 0, %119
  %121 = icmp ne i32 %115, %120
  br i1 %121, label %123, label %122

122:                                              ; preds = %114
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  br label %145

123:                                              ; preds = %114
  %124 = load i32, ptr %4, align 4, !tbaa !11
  %125 = add nsw i32 %124, 1
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [100000 x i32], ptr @maxr, i64 0, i64 %126
  %128 = load i32, ptr %4, align 4, !tbaa !11
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds [100000 x %"struct.std::pair"], ptr @pts, i64 0, i64 %129
  %131 = getelementptr inbounds %"struct.std::pair", ptr %130, i32 0, i32 1
  %132 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %127, ptr noundef nonnull align 4 dereferenceable(4) %131)
  %133 = load i32, ptr %132, align 4, !tbaa !11
  %134 = load i32, ptr %4, align 4, !tbaa !11
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [100000 x i32], ptr @maxr, i64 0, i64 %135
  store i32 %133, ptr %136, align 4, !tbaa !11
  br label %137

137:                                              ; preds = %123
  %138 = load i32, ptr @n, align 4, !tbaa !11
  %139 = sub nsw i32 %138, 1
  %140 = icmp sgt i32 %139, 0
  %141 = zext i1 %140 to i64
  %142 = select i1 %140, i32 -1, i32 1
  %143 = load i32, ptr %4, align 4, !tbaa !11
  %144 = add nsw i32 %143, %142
  store i32 %144, ptr %4, align 4, !tbaa !11
  br label %114, !llvm.loop !18

145:                                              ; preds = %122
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  %146 = load i32, ptr @n, align 4, !tbaa !11
  %147 = sub nsw i32 %146, 1
  %148 = icmp sgt i32 0, %147
  %149 = zext i1 %148 to i32
  %150 = sub nsw i32 0, %149
  store i32 %150, ptr %5, align 4, !tbaa !11
  br label %151

151:                                              ; preds = %176, %145
  %152 = load i32, ptr %5, align 4, !tbaa !11
  %153 = load i32, ptr @n, align 4, !tbaa !11
  %154 = sub nsw i32 %153, 1
  %155 = load i32, ptr @n, align 4, !tbaa !11
  %156 = sub nsw i32 %155, 1
  %157 = icmp sgt i32 0, %156
  %158 = zext i1 %157 to i32
  %159 = sub nsw i32 %154, %158
  %160 = icmp ne i32 %152, %159
  br i1 %160, label %162, label %161

161:                                              ; preds = %151
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  br label %184

162:                                              ; preds = %151
  %163 = load i32, ptr %5, align 4, !tbaa !11
  %164 = sext i32 %163 to i64
  %165 = getelementptr inbounds [100000 x i32], ptr @minl, i64 0, i64 %164
  %166 = load i32, ptr %165, align 4, !tbaa !11
  %167 = load i32, ptr %5, align 4, !tbaa !11
  %168 = add nsw i32 %167, 1
  %169 = sext i32 %168 to i64
  %170 = getelementptr inbounds [100000 x i32], ptr @maxr, i64 0, i64 %169
  %171 = load i32, ptr %170, align 4, !tbaa !11
  %172 = icmp sgt i32 %166, %171
  %173 = zext i1 %172 to i32
  %174 = load i32, ptr @ans, align 4, !tbaa !11
  %175 = add nsw i32 %174, %173
  store i32 %175, ptr @ans, align 4, !tbaa !11
  br label %176

176:                                              ; preds = %162
  %177 = load i32, ptr @n, align 4, !tbaa !11
  %178 = sub nsw i32 %177, 1
  %179 = icmp sgt i32 0, %178
  %180 = zext i1 %179 to i64
  %181 = select i1 %179, i32 -1, i32 1
  %182 = load i32, ptr %5, align 4, !tbaa !11
  %183 = add nsw i32 %182, %181
  store i32 %183, ptr %5, align 4, !tbaa !11
  br label %151, !llvm.loop !19

184:                                              ; preds = %161
  %185 = load i32, ptr @ans, align 4, !tbaa !11
  call void @_Z3outIiEvT_(i32 noundef %185)
  ret i32 0
}

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) #2 align 2

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) #3

declare noalias ptr @fopen(ptr noundef, ptr noundef) #3

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z2inIiJEEvRT_DpRT0_(ptr noundef nonnull align 4 dereferenceable(4)) #4

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z2inIiJiEEvRT_DpRT0_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #4

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3outIiEvT_(i32 noundef) #4

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

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

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


; 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 }
%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }

@n = external dso_local global i32, align 4
@ans = external dso_local local_unnamed_addr global i32, align 4
@minl = external dso_local global [100000 x i32], align 16
@maxr = external dso_local global [100000 x i32], align 16
@pts = external dso_local global [100000 x %"struct.std::pair"], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str.5 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external local_unnamed_addr global ptr, align 8
@.str.7 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %2 = getelementptr i8, ptr %1, i64 -24
  %3 = load i64, ptr %2, align 8
  %4 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %3
  %5 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %4, ptr noundef null)
  %6 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %7 = tail call noalias ptr @fopen(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.6)
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %13, label %8

8:                                                ; preds = %0
  %9 = load ptr, ptr @stdin, align 8, !tbaa !8
  %10 = tail call ptr @freopen(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.6, ptr noundef %9)
  %11 = load ptr, ptr @stdout, align 8, !tbaa !8
  %12 = tail call ptr @freopen(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.8, ptr noundef %11)
  br label %13

13:                                               ; preds = %8, %0
  tail call void @_Z2inIiJEEvRT_DpRT0_(ptr noundef nonnull align 4 dereferenceable(4) @n)
  %14 = load i32, ptr @n, align 4, !tbaa !11
  %.not2233 = icmp eq i32 %14, 0
  br i1 %.not2233, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %13
  %.lobit.neg = ashr i32 %14, 31
  br label %.lr.ph

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %15 = sext i32 %31 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %13
  %.lcssa31 = phi i64 [ 0, %13 ], [ %15, %._crit_edge.loopexit ]
  %16 = getelementptr inbounds %"struct.std::pair", ptr @pts, i64 %.lcssa31
  tail call void @_ZSt4sortIPSt4pairIiiEEvT_S3_(ptr noundef nonnull @pts, ptr noundef nonnull %16)
  %17 = load i32, ptr getelementptr inbounds (i8, ptr @pts, i64 4), align 4, !tbaa !13
  store i32 %17, ptr @minl, align 16, !tbaa !11
  %18 = load i32, ptr @n, align 4, !tbaa !11
  %19 = add nsw i32 %18, -1
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [100000 x %"struct.std::pair"], ptr @pts, i64 0, i64 %20, i32 1
  %22 = load i32, ptr %21, align 4, !tbaa !13
  %23 = getelementptr inbounds [100000 x i32], ptr @maxr, i64 0, i64 %20
  store i32 %22, ptr %23, align 4, !tbaa !11
  store i32 1, ptr @ans, align 4, !tbaa !11
  %24 = icmp sgt i32 %18, 0
  %25 = zext i1 %24 to i32
  %26 = icmp slt i32 %18, 1
  %.neg35 = sext i1 %26 to i32
  %27 = add i32 %18, %.neg35
  %.not2336 = icmp eq i32 %27, %25
  br i1 %.not2336, label %._crit_edge40, label %.lr.ph39

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.02034 = phi i32 [ %33, %.lr.ph ], [ %.lobit.neg, %.lr.ph.preheader ]
  %28 = sext i32 %.02034 to i64
  %29 = getelementptr inbounds [100000 x %"struct.std::pair"], ptr @pts, i64 0, i64 %28
  %30 = getelementptr inbounds i8, ptr %29, i64 4
  tail call void @_Z2inIiJiEEvRT_DpRT0_(ptr noundef nonnull align 4 dereferenceable(4) %29, ptr noundef nonnull align 4 dereferenceable(4) %30)
  %31 = load i32, ptr @n, align 4, !tbaa !11
  %.inv = icmp sgt i32 %31, -1
  %32 = select i1 %.inv, i32 1, i32 -1
  %33 = add nsw i32 %32, %.02034
  %.lobit.neg21 = ashr i32 %31, 31
  %34 = add i32 %.lobit.neg21, %31
  %.not22 = icmp eq i32 %33, %34
  br i1 %.not22, label %._crit_edge.loopexit, label %.lr.ph, !llvm.loop !15

._crit_edge40.loopexit:                           ; preds = %.lr.ph39
  %.pre60 = add nsw i32 %46, -1
  br label %._crit_edge40

._crit_edge40:                                    ; preds = %._crit_edge40.loopexit, %._crit_edge
  %.pre-phi = phi i32 [ %.pre60, %._crit_edge40.loopexit ], [ %19, %._crit_edge ]
  %35 = phi i32 [ %46, %._crit_edge40.loopexit ], [ %18, %._crit_edge ]
  %.not2643 = icmp eq i32 %.pre-phi, 0
  br i1 %.not2643, label %._crit_edge47, label %.lr.ph46.preheader

.lr.ph46.preheader:                               ; preds = %._crit_edge40
  %36 = icmp sgt i32 %35, 1
  %.neg24 = sext i1 %36 to i32
  %37 = add i32 %.pre-phi, %.neg24
  br label %.lr.ph46

.lr.ph39:                                         ; preds = %._crit_edge, %.lr.ph39
  %.01937 = phi i32 [ %49, %.lr.ph39 ], [ %25, %._crit_edge ]
  %38 = add nsw i32 %.01937, -1
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [100000 x i32], ptr @minl, i64 0, i64 %39
  %41 = sext i32 %.01937 to i64
  %42 = getelementptr inbounds [100000 x %"struct.std::pair"], ptr @pts, i64 0, i64 %41, i32 1
  %43 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %40, ptr noundef nonnull align 4 dereferenceable(4) %42)
  %44 = load i32, ptr %43, align 4, !tbaa !11
  %45 = getelementptr inbounds [100000 x i32], ptr @minl, i64 0, i64 %41
  store i32 %44, ptr %45, align 4, !tbaa !11
  %46 = load i32, ptr @n, align 4, !tbaa !11
  %47 = icmp slt i32 %46, 1
  %48 = select i1 %47, i32 -1, i32 1
  %49 = add nsw i32 %48, %.01937
  %.neg = sext i1 %47 to i32
  %50 = add i32 %46, %.neg
  %.not23 = icmp eq i32 %49, %50
  br i1 %.not23, label %._crit_edge40.loopexit, label %.lr.ph39, !llvm.loop !17

._crit_edge47:                                    ; preds = %.lr.ph46, %._crit_edge40
  %.lcssa = phi i32 [ %35, %._crit_edge40 ], [ %64, %.lr.ph46 ]
  %51 = add nsw i32 %.lcssa, -1
  %.not2949 = icmp eq i32 %51, 0
  br i1 %.not2949, label %._crit_edge47._crit_edge, label %.lr.ph52

._crit_edge47._crit_edge:                         ; preds = %._crit_edge47
  %.pre = load i32, ptr @ans, align 4, !tbaa !11
  br label %68

.lr.ph52:                                         ; preds = %._crit_edge47
  %52 = icmp slt i32 %.lcssa, 1
  %.neg27 = sext i1 %52 to i32
  %53 = add i32 %51, %.neg27
  %ans.promoted = load i32, ptr @ans, align 4, !tbaa !11
  %54 = select i1 %52, i64 -1, i64 1
  %55 = sext i1 %52 to i64
  %sext = sext i32 %53 to i64
  br label %70

.lr.ph46:                                         ; preds = %.lr.ph46.preheader, %.lr.ph46
  %.01844 = phi i32 [ %67, %.lr.ph46 ], [ %37, %.lr.ph46.preheader ]
  %56 = add nsw i32 %.01844, 1
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [100000 x i32], ptr @maxr, i64 0, i64 %57
  %59 = sext i32 %.01844 to i64
  %60 = getelementptr inbounds [100000 x %"struct.std::pair"], ptr @pts, i64 0, i64 %59, i32 1
  %61 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %58, ptr noundef nonnull align 4 dereferenceable(4) %60)
  %62 = load i32, ptr %61, align 4, !tbaa !11
  %63 = getelementptr inbounds [100000 x i32], ptr @maxr, i64 0, i64 %59
  store i32 %62, ptr %63, align 4, !tbaa !11
  %64 = load i32, ptr @n, align 4, !tbaa !11
  %65 = icmp sgt i32 %64, 1
  %66 = select i1 %65, i32 -1, i32 1
  %67 = add nsw i32 %66, %.01844
  %.neg25 = sext i1 %65 to i32
  %.not26 = icmp eq i32 %67, %.neg25
  br i1 %.not26, label %._crit_edge47, label %.lr.ph46, !llvm.loop !18

._crit_edge53:                                    ; preds = %70
  store i32 %79, ptr @ans, align 4, !tbaa !11
  br label %68

68:                                               ; preds = %._crit_edge47._crit_edge, %._crit_edge53
  %69 = phi i32 [ %.pre, %._crit_edge47._crit_edge ], [ %79, %._crit_edge53 ]
  tail call void @_Z3outIiEvT_(i32 noundef %69)
  ret i32 0

70:                                               ; preds = %.lr.ph52, %70
  %indvars.iv = phi i64 [ %55, %.lr.ph52 ], [ %indvars.iv.next, %70 ]
  %71 = phi i32 [ %ans.promoted, %.lr.ph52 ], [ %79, %70 ]
  %72 = getelementptr inbounds [100000 x i32], ptr @minl, i64 0, i64 %indvars.iv
  %73 = load i32, ptr %72, align 4, !tbaa !11
  %74 = add nsw i64 %indvars.iv, 1
  %75 = getelementptr inbounds [100000 x i32], ptr @maxr, i64 0, i64 %74
  %76 = load i32, ptr %75, align 4, !tbaa !11
  %77 = icmp sgt i32 %73, %76
  %78 = zext i1 %77 to i32
  %79 = add nsw i32 %71, %78
  %indvars.iv.next = add nsw i64 %indvars.iv, %54
  %80 = icmp eq i64 %indvars.iv.next, %sext
  br i1 %80, label %._crit_edge53, label %70, !llvm.loop !19
}

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) local_unnamed_addr #1 align 2

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #3

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z2inIiJEEvRT_DpRT0_(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #4

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3outIiEvT_(i32 noundef) local_unnamed_addr #4

attributes #0 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { 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 #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 = { 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 #4 = { 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 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 = { 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" }

!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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !10, i64 0}
!13 = !{!14, !12, i64 4}
!14 = !{!"_ZTSSt4pairIiiE", !12, i64 0, !12, i64 4}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = distinct !{!18, !16}
!19 = distinct !{!19, !16}


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