; LLVM IR from eyangch/competitive-programming :: USACOcontests/gold/2017.01 (bphoto)

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

%"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 }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"struct.std::pair" = type { i32, i32 }

@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str = external hidden unnamed_addr constant [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external global ptr, align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3getiRA100001_i(i32 noundef, ptr noundef nonnull align 4 dereferenceable(400004)) #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 nounwind uwtable
declare dso_local void @_Z3updiiiRA100001_i(i32 noundef, i32 noundef, i32 noundef, ptr noundef nonnull align 4 dereferenceable(400004)) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca [100001 x i32], align 16
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %12 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %13 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %14 = getelementptr i8, ptr %13, i64 -24
  %15 = load i64, ptr %14, align 8
  %16 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %15
  %17 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %16, ptr noundef null)
  %18 = load ptr, ptr @stdin, align 8, !tbaa !8
  %19 = call ptr @freopen(ptr noundef @.str, ptr noundef @.str.1, ptr noundef %18)
  %20 = load ptr, ptr @stdout, align 8, !tbaa !8
  %21 = call ptr @freopen(ptr noundef @.str.2, ptr noundef @.str.3, ptr noundef %20)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #8
  %22 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %23 = load i32, ptr %2, align 4, !tbaa !11
  %24 = zext i32 %23 to i64
  %25 = call ptr @llvm.stacksave.p0()
  store ptr %25, ptr %3, align 8
  %26 = alloca %"struct.std::pair", i64 %24, align 16
  store i64 %24, ptr %4, align 8
  %27 = icmp eq i64 %24, 0
  br i1 %27, label %34, label %28

28:                                               ; preds = %0
  %29 = getelementptr inbounds %"struct.std::pair", ptr %26, i64 %24
  br label %30

30:                                               ; preds = %30, %28
  %31 = phi ptr [ %26, %28 ], [ %32, %30 ]
  call void @_ZNSt4pairIiiEC2IiiTnNSt9enable_ifIXsr6__and_ISt37__is_implicitly_default_constructibleIT_ES3_IT0_EEE5valueEbE4typeELb1EEEv(ptr noundef nonnull align 4 dereferenceable(8) %31)
  %32 = getelementptr inbounds %"struct.std::pair", ptr %31, i64 1
  %33 = icmp eq ptr %32, %29
  br i1 %33, label %34, label %30

34:                                               ; preds = %30, %0
  call void @llvm.lifetime.start.p0(i64 400004, ptr %5) #8
  %35 = getelementptr inbounds [100001 x i32], ptr %5, i64 0, i64 0
  %36 = getelementptr inbounds [100001 x i32], ptr %5, i64 0, i64 0
  %37 = load i32, ptr %2, align 4, !tbaa !11
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds i32, ptr %36, i64 %38
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #8
  store i32 0, ptr %6, align 4, !tbaa !11
  call void @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef %35, ptr noundef %39, ptr noundef nonnull align 4 dereferenceable(4) %6)
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #8
  store i32 0, ptr %7, align 4, !tbaa !11
  br label %40

40:                                               ; preds = %57, %34
  %41 = load i32, ptr %7, align 4, !tbaa !11
  %42 = load i32, ptr %2, align 4, !tbaa !11
  %43 = icmp slt i32 %41, %42
  br i1 %43, label %45, label %44

44:                                               ; preds = %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #8
  br label %60

45:                                               ; preds = %40
  %46 = load i32, ptr %7, align 4, !tbaa !11
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds %"struct.std::pair", ptr %26, i64 %47
  %49 = getelementptr inbounds %"struct.std::pair", ptr %48, i32 0, i32 0
  %50 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %49)
  %51 = load i32, ptr %7, align 4, !tbaa !11
  %52 = add nsw i32 %51, 1
  %53 = load i32, ptr %7, align 4, !tbaa !11
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds %"struct.std::pair", ptr %26, i64 %54
  %56 = getelementptr inbounds %"struct.std::pair", ptr %55, i32 0, i32 1
  store i32 %52, ptr %56, align 4, !tbaa !13
  br label %57

57:                                               ; preds = %45
  %58 = load i32, ptr %7, align 4, !tbaa !11
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %7, align 4, !tbaa !11
  br label %40, !llvm.loop !15

60:                                               ; preds = %44
  %61 = load i32, ptr %2, align 4, !tbaa !11
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds %"struct.std::pair", ptr %26, i64 %62
  call void @_ZSt4sortIPSt4pairIiiEEvT_S3_(ptr noundef %26, ptr noundef %63)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #8
  store i32 0, ptr %8, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #8
  %64 = load i32, ptr %2, align 4, !tbaa !11
  %65 = sub nsw i32 %64, 1
  store i32 %65, ptr %9, align 4, !tbaa !11
  br label %66

66:                                               ; preds = %99, %60
  %67 = load i32, ptr %9, align 4, !tbaa !11
  %68 = icmp sge i32 %67, 0
  br i1 %68, label %70, label %69

69:                                               ; preds = %66
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #8
  br label %102

70:                                               ; preds = %66
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #8
  %71 = load i32, ptr %9, align 4, !tbaa !11
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds %"struct.std::pair", ptr %26, i64 %72
  %74 = getelementptr inbounds %"struct.std::pair", ptr %73, i32 0, i32 1
  %75 = load i32, ptr %74, align 4, !tbaa !13
  %76 = call noundef i32 @_Z3getiRA100001_i(i32 noundef %75, ptr noundef nonnull align 4 dereferenceable(400004) %5)
  store i32 %76, ptr %10, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #8
  %77 = load i32, ptr %2, align 4, !tbaa !11
  %78 = sub nsw i32 %77, 1
  %79 = load i32, ptr %9, align 4, !tbaa !11
  %80 = sub nsw i32 %78, %79
  %81 = load i32, ptr %10, align 4, !tbaa !11
  %82 = sub nsw i32 %80, %81
  store i32 %82, ptr %11, align 4, !tbaa !11
  %83 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 4 dereferenceable(4) %11)
  %84 = load i32, ptr %83, align 4, !tbaa !11
  %85 = mul nsw i32 %84, 2
  %86 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 4 dereferenceable(4) %11)
  %87 = load i32, ptr %86, align 4, !tbaa !11
  %88 = icmp slt i32 %85, %87
  br i1 %88, label %89, label %92

89:                                               ; preds = %70
  %90 = load i32, ptr %8, align 4, !tbaa !11
  %91 = add nsw i32 %90, 1
  store i32 %91, ptr %8, align 4, !tbaa !11
  br label %92

92:                                               ; preds = %89, %70
  %93 = load i32, ptr %9, align 4, !tbaa !11
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds %"struct.std::pair", ptr %26, i64 %94
  %96 = getelementptr inbounds %"struct.std::pair", ptr %95, i32 0, i32 1
  %97 = load i32, ptr %96, align 4, !tbaa !13
  %98 = load i32, ptr %2, align 4, !tbaa !11
  call void @_Z3updiiiRA100001_i(i32 noundef %97, i32 noundef 1, i32 noundef %98, ptr noundef nonnull align 4 dereferenceable(400004) %5)
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  br label %99

99:                                               ; preds = %92
  %100 = load i32, ptr %9, align 4, !tbaa !11
  %101 = add nsw i32 %100, -1
  store i32 %101, ptr %9, align 4, !tbaa !11
  br label %66, !llvm.loop !17

102:                                              ; preds = %69
  %103 = load i32, ptr %8, align 4, !tbaa !11
  %104 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %103)
  %105 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %104, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #8
  call void @llvm.lifetime.end.p0(i64 400004, ptr %5) #8
  %106 = load ptr, ptr %3, align 8
  call void @llvm.stackrestore.p0(ptr %106)
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #8
  %107 = load i32, ptr %1, align 4
  ret i32 %107
}

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

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

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #4

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

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

; 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

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #3

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #7 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #5

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #4

attributes #0 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { 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 = { nocallback nofree nosync nounwind willreturn }
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 = { 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 #8 = { 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 = !{!14, !12, i64 4}
!14 = !{!"_ZTSSt4pairIiiE", !12, i64 0, !12, i64 4}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


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

%"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 }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"struct.std::pair" = type { i32, i32 }

@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str = external hidden unnamed_addr constant [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

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

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

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i32, align 4
  %2 = alloca [100001 x i32], align 16
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %7 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %8 = getelementptr i8, ptr %7, i64 -24
  %9 = load i64, ptr %8, align 8
  %10 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %9
  %11 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %10, ptr noundef null)
  %12 = load ptr, ptr @stdin, align 8, !tbaa !8
  %13 = tail call ptr @freopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef %12)
  %14 = load ptr, ptr @stdout, align 8, !tbaa !8
  %15 = tail call ptr @freopen(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, ptr noundef %14)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #8
  %16 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %17 = load i32, ptr %1, align 4, !tbaa !11
  %18 = zext i32 %17 to i64
  %19 = call ptr @llvm.stacksave.p0()
  %20 = alloca %"struct.std::pair", i64 %18, align 16
  %21 = icmp eq i32 %17, 0
  br i1 %21, label %.loopexit, label %22

22:                                               ; preds = %0
  %23 = getelementptr inbounds %"struct.std::pair", ptr %20, i64 %18
  br label %24

24:                                               ; preds = %24, %22
  %25 = phi ptr [ %20, %22 ], [ %26, %24 ]
  call void @_ZNSt4pairIiiEC2IiiTnNSt9enable_ifIXsr6__and_ISt37__is_implicitly_default_constructibleIT_ES3_IT0_EEE5valueEbE4typeELb1EEEv(ptr noundef nonnull align 4 dereferenceable(8) %25)
  %26 = getelementptr inbounds i8, ptr %25, i64 8
  %27 = icmp eq ptr %26, %23
  br i1 %27, label %.loopexit, label %24

.loopexit:                                        ; preds = %24, %0
  call void @llvm.lifetime.start.p0(i64 400004, ptr nonnull %2) #8
  %28 = load i32, ptr %1, align 4, !tbaa !11
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds i32, ptr %2, i64 %29
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #8
  store i32 0, ptr %3, align 4, !tbaa !11
  call void @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef nonnull %2, ptr noundef nonnull %30, ptr noundef nonnull align 4 dereferenceable(4) %3)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #8
  %31 = load i32, ptr %1, align 4, !tbaa !11
  %32 = icmp sgt i32 %31, 0
  br i1 %32, label %.lr.ph, label %.loopexit.._crit_edge_crit_edge

.loopexit.._crit_edge_crit_edge:                  ; preds = %.loopexit
  %.pre = sext i32 %31 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.loopexit.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre, %.loopexit.._crit_edge_crit_edge ], [ %42, %.lr.ph ]
  %33 = getelementptr inbounds %"struct.std::pair", ptr %20, i64 %.pre-phi
  call void @_ZSt4sortIPSt4pairIiiEEvT_S3_(ptr noundef nonnull %20, ptr noundef nonnull %33)
  %34 = load i32, ptr %1, align 4, !tbaa !11
  %35 = icmp sgt i32 %34, 0
  br i1 %35, label %.lr.ph22.preheader, label %._crit_edge23

.lr.ph22.preheader:                               ; preds = %._crit_edge
  %36 = zext nneg i32 %34 to i64
  br label %.lr.ph22

.lr.ph:                                           ; preds = %.loopexit, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.loopexit ]
  %37 = getelementptr inbounds %"struct.std::pair", ptr %20, i64 %indvars.iv
  %38 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %37)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %39 = getelementptr inbounds i8, ptr %37, i64 4
  %40 = trunc nuw nsw i64 %indvars.iv.next to i32
  store i32 %40, ptr %39, align 4, !tbaa !13
  %41 = load i32, ptr %1, align 4, !tbaa !11
  %42 = sext i32 %41 to i64
  %43 = icmp slt i64 %indvars.iv.next, %42
  br i1 %43, label %.lr.ph, label %._crit_edge, !llvm.loop !15

._crit_edge23:                                    ; preds = %.lr.ph22, %._crit_edge
  %.013.lcssa = phi i32 [ 0, %._crit_edge ], [ %spec.select, %.lr.ph22 ]
  %44 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %.013.lcssa)
  %45 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %44, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 400004, ptr nonnull %2) #8
  call void @llvm.stackrestore.p0(ptr %19)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #8
  ret i32 0

.lr.ph22:                                         ; preds = %.lr.ph22.preheader, %.lr.ph22
  %indvars.iv27 = phi i64 [ %36, %.lr.ph22.preheader ], [ %indvars.iv.next28, %.lr.ph22 ]
  %.01319 = phi i32 [ 0, %.lr.ph22.preheader ], [ %spec.select, %.lr.ph22 ]
  %indvars.iv.next28 = add nsw i64 %indvars.iv27, -1
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #8
  %46 = getelementptr inbounds %"struct.std::pair", ptr %20, i64 %indvars.iv.next28, i32 1
  %47 = load i32, ptr %46, align 4, !tbaa !13
  %48 = call noundef i32 @_Z3getiRA100001_i(i32 noundef %47, ptr noundef nonnull align 4 dereferenceable(400004) %2)
  store i32 %48, ptr %4, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #8
  %49 = load i32, ptr %1, align 4, !tbaa !11
  %50 = trunc nuw nsw i64 %indvars.iv27 to i32
  %51 = add i32 %48, %50
  %52 = sub i32 %49, %51
  store i32 %52, ptr %5, align 4, !tbaa !11
  %53 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %54 = load i32, ptr %53, align 4, !tbaa !11
  %55 = shl nsw i32 %54, 1
  %56 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %57 = load i32, ptr %56, align 4, !tbaa !11
  %58 = icmp slt i32 %55, %57
  %59 = zext i1 %58 to i32
  %spec.select = add nuw nsw i32 %.01319, %59
  %60 = load i32, ptr %46, align 4, !tbaa !13
  %61 = load i32, ptr %1, align 4, !tbaa !11
  call void @_Z3updiiiRA100001_i(i32 noundef %60, i32 noundef 1, i32 noundef %61, ptr noundef nonnull align 4 dereferenceable(400004) %2)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #8
  %62 = icmp ugt i64 %indvars.iv27, 1
  br i1 %62, label %.lr.ph22, label %._crit_edge23, !llvm.loop !17
}

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

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

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #4

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

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

; 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

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #7 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #5

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #4

attributes #0 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress 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 = { mustprogress nocallback nofree nosync nounwind willreturn }
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 = { 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 #8 = { 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 = !{!14, !12, i64 4}
!14 = !{!"_ZTSSt4pairIiiE", !12, i64 0, !12, i64 4}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


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