; LLVM IR from Aryansh-S/USACO :: USACO/2014/Mar/Old Silver (Now Gold) (WateringTheFields)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"struct.std::pair" = type { i32, i32 }
%struct.Prim = type { %"class.std::priority_queue", [2005 x i8], [2005 x i32], [2005 x i32], [2005 x %"class.std::vector"] }
%"class.std::priority_queue" = type <{ %"class.std::vector", [8 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"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
@c = external dso_local global i32, align 4
@pts = external dso_local global [2005 x %"struct.std::pair"], align 16
@p = external dso_local global %struct.Prim, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external global ptr, align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z4distSt4pairIiiES0_(i64, i64) #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 %"struct.std::pair", align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca %"struct.std::pair", align 4
  %10 = alloca %"struct.std::pair", align 4
  %11 = alloca %"struct.std::pair", align 4
  %12 = alloca %"struct.std::pair", align 4
  store i32 0, ptr %1, align 4
  %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 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %19 = call noalias ptr @fopen(ptr noundef @.str.2, ptr noundef @.str.3)
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %26

21:                                               ; preds = %0
  %22 = load ptr, ptr @stdin, align 8, !tbaa !8
  %23 = call ptr @freopen(ptr noundef @.str.2, ptr noundef @.str.3, ptr noundef %22)
  %24 = load ptr, ptr @stdout, align 8, !tbaa !8
  %25 = call ptr @freopen(ptr noundef @.str.4, ptr noundef @.str.5, ptr noundef %24)
  br label %26

26:                                               ; preds = %21, %0
  call void @_Z2inIiJiEEvRT_DpRT0_(ptr noundef nonnull align 4 dereferenceable(4) @n, ptr noundef nonnull align 4 dereferenceable(4) @c)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  %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 0, %29
  store i32 %30, ptr %2, align 4, !tbaa !11
  br label %31

31:                                               ; preds = %46, %26
  %32 = load i32, ptr %2, align 4, !tbaa !11
  %33 = load i32, ptr @n, align 4, !tbaa !11
  %34 = load i32, ptr @n, align 4, !tbaa !11
  %35 = icmp sgt i32 0, %34
  %36 = zext i1 %35 to i32
  %37 = sub nsw i32 %33, %36
  %38 = icmp ne i32 %32, %37
  br i1 %38, label %40, label %39

39:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %53

40:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  call void @_Z2inIiJiEEvRT_DpRT0_(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %4)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %41 = call i64 @_ZSt9make_pairIRiS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %4)
  store i64 %41, ptr %5, align 4
  %42 = load i32, ptr %2, align 4, !tbaa !11
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [2005 x %"struct.std::pair"], ptr @pts, i64 0, i64 %43
  %45 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8) %44, ptr noundef nonnull align 4 dereferenceable(8) %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %46

46:                                               ; preds = %40
  %47 = load i32, ptr @n, align 4, !tbaa !11
  %48 = icmp sgt i32 0, %47
  %49 = zext i1 %48 to i64
  %50 = select i1 %48, i32 -1, i32 1
  %51 = load i32, ptr %2, align 4, !tbaa !11
  %52 = add nsw i32 %51, %50
  store i32 %52, ptr %2, align 4, !tbaa !11
  br label %31, !llvm.loop !13

53:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  %54 = load i32, ptr @n, align 4, !tbaa !11
  %55 = icmp sgt i32 0, %54
  %56 = zext i1 %55 to i32
  %57 = sub nsw i32 0, %56
  store i32 %57, ptr %6, align 4, !tbaa !11
  br label %58

58:                                               ; preds = %114, %53
  %59 = load i32, ptr %6, align 4, !tbaa !11
  %60 = load i32, ptr @n, align 4, !tbaa !11
  %61 = load i32, ptr @n, align 4, !tbaa !11
  %62 = icmp sgt i32 0, %61
  %63 = zext i1 %62 to i32
  %64 = sub nsw i32 %60, %63
  %65 = icmp ne i32 %59, %64
  br i1 %65, label %67, label %66

66:                                               ; preds = %58
  store i32 5, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %121

67:                                               ; preds = %58
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %68 = load i32, ptr @n, align 4, !tbaa !11
  %69 = icmp sgt i32 0, %68
  %70 = zext i1 %69 to i32
  %71 = sub nsw i32 0, %70
  store i32 %71, ptr %8, align 4, !tbaa !11
  br label %72

72:                                               ; preds = %106, %67
  %73 = load i32, ptr %8, align 4, !tbaa !11
  %74 = load i32, ptr @n, align 4, !tbaa !11
  %75 = load i32, ptr @n, align 4, !tbaa !11
  %76 = icmp sgt i32 0, %75
  %77 = zext i1 %76 to i32
  %78 = sub nsw i32 %74, %77
  %79 = icmp ne i32 %73, %78
  br i1 %79, label %81, label %80

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

81:                                               ; preds = %72
  %82 = load i32, ptr %6, align 4, !tbaa !11
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [2005 x %"struct.std::pair"], ptr @pts, i64 0, i64 %83
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %9, ptr align 8 %84, i64 8, i1 false)
  %85 = load i32, ptr %8, align 4, !tbaa !11
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [2005 x %"struct.std::pair"], ptr @pts, i64 0, i64 %86
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 8 %87, i64 8, i1 false)
  %88 = load i64, ptr %9, align 4
  %89 = load i64, ptr %10, align 4
  %90 = call noundef i32 @_Z4distSt4pairIiiES0_(i64 %88, i64 %89)
  %91 = load i32, ptr @c, align 4, !tbaa !11
  %92 = icmp sge i32 %90, %91
  br i1 %92, label %93, label %105

93:                                               ; preds = %81
  %94 = load i32, ptr %6, align 4, !tbaa !11
  %95 = load i32, ptr %8, align 4, !tbaa !11
  %96 = load i32, ptr %6, align 4, !tbaa !11
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [2005 x %"struct.std::pair"], ptr @pts, i64 0, i64 %97
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 8 %98, i64 8, i1 false)
  %99 = load i32, ptr %8, align 4, !tbaa !11
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [2005 x %"struct.std::pair"], ptr @pts, i64 0, i64 %100
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %12, ptr align 8 %101, i64 8, i1 false)
  %102 = load i64, ptr %11, align 4
  %103 = load i64, ptr %12, align 4
  %104 = call noundef i32 @_Z4distSt4pairIiiES0_(i64 %102, i64 %103)
  call void @_ZN4PrimIiLi2005EE4add_Eiii(ptr noundef nonnull align 8 dereferenceable(66200) @p, i32 noundef %94, i32 noundef %95, i32 noundef %104)
  br label %105

105:                                              ; preds = %93, %81
  br label %106

106:                                              ; preds = %105
  %107 = load i32, ptr @n, align 4, !tbaa !11
  %108 = icmp sgt i32 0, %107
  %109 = zext i1 %108 to i64
  %110 = select i1 %108, i32 -1, i32 1
  %111 = load i32, ptr %8, align 4, !tbaa !11
  %112 = add nsw i32 %111, %110
  store i32 %112, ptr %8, align 4, !tbaa !11
  br label %72, !llvm.loop !15

113:                                              ; preds = %80
  br label %114

114:                                              ; preds = %113
  %115 = load i32, ptr @n, align 4, !tbaa !11
  %116 = icmp sgt i32 0, %115
  %117 = zext i1 %116 to i64
  %118 = select i1 %116, i32 -1, i32 1
  %119 = load i32, ptr %6, align 4, !tbaa !11
  %120 = add nsw i32 %119, %118
  store i32 %120, ptr %6, align 4, !tbaa !11
  br label %58, !llvm.loop !16

121:                                              ; preds = %66
  call void @_ZN4PrimIiLi2005EE3updEi(ptr noundef nonnull align 8 dereferenceable(66200) @p, i32 noundef 0)
  %122 = call noundef zeroext i1 @_ZN4PrimIiLi2005EE3exiEv(ptr noundef nonnull align 8 dereferenceable(66200) @p)
  br i1 %122, label %123, label %125

123:                                              ; preds = %121
  %124 = call noundef i32 @_ZN4PrimIiLi2005EE3sumEv(ptr noundef nonnull align 8 dereferenceable(66200) @p)
  br label %126

125:                                              ; preds = %121
  br label %126

126:                                              ; preds = %125, %123
  %127 = phi i32 [ %124, %123 ], [ -1, %125 ]
  call void @_Z3outIiEvT_(i32 noundef %127)
  ret i32 0
}

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

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

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local i64 @_ZSt9make_pairIRiS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #3

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4PrimIiLi2005EE4add_Eiii(ptr noundef nonnull align 8 dereferenceable(66200), i32 noundef, i32 noundef, i32 noundef) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4PrimIiLi2005EE3updEi(ptr noundef nonnull align 8 dereferenceable(66200), i32 noundef) #3 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN4PrimIiLi2005EE3exiEv(ptr noundef nonnull align 8 dereferenceable(66200)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN4PrimIiLi2005EE3sumEv(ptr noundef nonnull align 8 dereferenceable(66200)) #0 align 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 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"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 = distinct !{!15, !14}
!16 = distinct !{!16, !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 }
%struct.Prim = type { %"class.std::priority_queue", [2005 x i8], [2005 x i32], [2005 x i32], [2005 x %"class.std::vector"] }
%"class.std::priority_queue" = type <{ %"class.std::vector", [8 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"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
@c = external dso_local global i32, align 4
@pts = external dso_local global [2005 x %"struct.std::pair"], align 16
@p = external dso_local global %struct.Prim, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external local_unnamed_addr global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z4distSt4pairIiiES0_(i64, i64) local_unnamed_addr #0

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

11:                                               ; preds = %0
  %12 = load ptr, ptr @stdin, align 8, !tbaa !8
  %13 = tail call ptr @freopen(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, ptr noundef %12)
  %14 = load ptr, ptr @stdout, align 8, !tbaa !8
  %15 = tail call ptr @freopen(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.5, ptr noundef %14)
  br label %16

16:                                               ; preds = %11, %0
  tail call void @_Z2inIiJiEEvRT_DpRT0_(ptr noundef nonnull align 4 dereferenceable(4) @n, ptr noundef nonnull align 4 dereferenceable(4) @c)
  %17 = load i32, ptr @n, align 4, !tbaa !11
  %.lobit.neg = ashr i32 %17, 31
  %18 = add nuw nsw i32 %.lobit.neg, %17
  %.not1831 = icmp eq i32 %17, 0
  br i1 %.not1831, label %.preheader29, label %.lr.ph

.preheader29:                                     ; preds = %.lr.ph, %16
  %.pre-phi = phi i32 [ %18, %16 ], [ %27, %.lr.ph ]
  %.lobit.neg2338.pre-phi = phi i32 [ 0, %16 ], [ %.lobit.neg20, %.lr.ph ]
  %19 = phi i32 [ 0, %16 ], [ %24, %.lr.ph ]
  %.not2139 = icmp eq i32 %.lobit.neg2338.pre-phi, %.pre-phi
  br i1 %.not2139, label %._crit_edge42, label %.preheader

.lr.ph:                                           ; preds = %16, %.lr.ph
  %.032 = phi i32 [ %26, %.lr.ph ], [ %.lobit.neg, %16 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  call void @_Z2inIiJiEEvRT_DpRT0_(ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 4 dereferenceable(4) %2)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  %20 = call i64 @_ZSt9make_pairIRiS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 4 dereferenceable(4) %2)
  store i64 %20, ptr %3, align 8
  %21 = sext i32 %.032 to i64
  %22 = getelementptr inbounds [2005 x %"struct.std::pair"], ptr @pts, i64 0, i64 %21
  %23 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8) %22, ptr noundef nonnull align 4 dereferenceable(8) %3) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  %24 = load i32, ptr @n, align 4, !tbaa !11
  %.inv28 = icmp sgt i32 %24, -1
  %25 = select i1 %.inv28, i32 1, i32 -1
  %26 = add nsw i32 %25, %.032
  %.lobit.neg20 = ashr i32 %24, 31
  %27 = add i32 %.lobit.neg20, %24
  %.not18 = icmp eq i32 %26, %27
  br i1 %.not18, label %.preheader29, label %.lr.ph, !llvm.loop !13

.preheader:                                       ; preds = %.preheader29, %._crit_edge
  %28 = phi i32 [ %33, %._crit_edge ], [ %19, %.preheader29 ]
  %.lobit.neg2341 = phi i32 [ %.lobit.neg23.pre-phi, %._crit_edge ], [ %.lobit.neg2338.pre-phi, %.preheader29 ]
  %.01640 = phi i32 [ %35, %._crit_edge ], [ %.lobit.neg2338.pre-phi, %.preheader29 ]
  %.lobit.neg2433 = ashr i32 %28, 31
  %29 = add i32 %.lobit.neg2433, %28
  %.not2534 = icmp eq i32 %.lobit.neg2341, %29
  br i1 %.not2534, label %._crit_edge, label %.lr.ph36

.lr.ph36:                                         ; preds = %.preheader
  %30 = sext i32 %.01640 to i64
  %31 = getelementptr inbounds [2005 x %"struct.std::pair"], ptr @pts, i64 0, i64 %30
  br label %36

._crit_edge42:                                    ; preds = %._crit_edge, %.preheader29
  call void @_ZN4PrimIiLi2005EE3updEi(ptr noundef nonnull align 8 dereferenceable(66200) @p, i32 noundef 0)
  %32 = call noundef zeroext i1 @_ZN4PrimIiLi2005EE3exiEv(ptr noundef nonnull align 8 dereferenceable(66200) @p)
  br i1 %32, label %48, label %50

._crit_edge:                                      ; preds = %43, %.preheader
  %.pre-phi45 = phi i32 [ %29, %.preheader ], [ %47, %43 ]
  %.lobit.neg23.pre-phi = phi i32 [ %.lobit.neg2433, %.preheader ], [ %.lobit.neg24, %43 ]
  %33 = phi i32 [ %28, %.preheader ], [ %44, %43 ]
  %.inv = icmp sgt i32 %33, -1
  %34 = select i1 %.inv, i32 1, i32 -1
  %35 = add nsw i32 %34, %.01640
  %.not21 = icmp eq i32 %35, %.pre-phi45
  br i1 %.not21, label %._crit_edge42, label %.preheader, !llvm.loop !15

36:                                               ; preds = %.lr.ph36, %43
  %.01735 = phi i32 [ %.lobit.neg2341, %.lr.ph36 ], [ %46, %43 ]
  %.sroa.03.0.copyload = load i64, ptr %31, align 8
  %37 = sext i32 %.01735 to i64
  %38 = getelementptr inbounds [2005 x %"struct.std::pair"], ptr @pts, i64 0, i64 %37
  %.sroa.02.0.copyload = load i64, ptr %38, align 8
  %39 = call noundef i32 @_Z4distSt4pairIiiES0_(i64 %.sroa.03.0.copyload, i64 %.sroa.02.0.copyload)
  %40 = load i32, ptr @c, align 4, !tbaa !11
  %.not26 = icmp slt i32 %39, %40
  br i1 %.not26, label %43, label %41

41:                                               ; preds = %36
  %.sroa.01.0.copyload = load i64, ptr %31, align 8
  %.sroa.0.0.copyload = load i64, ptr %38, align 8
  %42 = call noundef i32 @_Z4distSt4pairIiiES0_(i64 %.sroa.01.0.copyload, i64 %.sroa.0.0.copyload)
  call void @_ZN4PrimIiLi2005EE4add_Eiii(ptr noundef nonnull align 8 dereferenceable(66200) @p, i32 noundef %.01640, i32 noundef %.01735, i32 noundef %42)
  br label %43

43:                                               ; preds = %36, %41
  %44 = load i32, ptr @n, align 4, !tbaa !11
  %.inv27 = icmp sgt i32 %44, -1
  %45 = select i1 %.inv27, i32 1, i32 -1
  %46 = add nsw i32 %45, %.01735
  %.lobit.neg24 = ashr i32 %44, 31
  %47 = add i32 %.lobit.neg24, %44
  %.not25 = icmp eq i32 %46, %47
  br i1 %.not25, label %._crit_edge, label %36, !llvm.loop !16

48:                                               ; preds = %._crit_edge42
  %49 = call noundef i32 @_ZN4PrimIiLi2005EE3sumEv(ptr noundef nonnull align 8 dereferenceable(66200) @p)
  br label %50

50:                                               ; preds = %._crit_edge42, %48
  %51 = phi i32 [ %49, %48 ], [ -1, %._crit_edge42 ]
  call void @_Z3outIiEvT_(i32 noundef %51)
  ret i32 0
}

; 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 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 @_Z2inIiJiEEvRT_DpRT0_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #4

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4PrimIiLi2005EE4add_Eiii(ptr noundef nonnull align 8 dereferenceable(66200), i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4PrimIiLi2005EE3updEi(ptr noundef nonnull align 8 dereferenceable(66200), i32 noundef) local_unnamed_addr #4 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN4PrimIiLi2005EE3exiEv(ptr noundef nonnull align 8 dereferenceable(66200)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN4PrimIiLi2005EE3sumEv(ptr noundef nonnull align 8 dereferenceable(66200)) local_unnamed_addr #0 align 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 = { 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"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 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


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