; LLVM IR from eyangch/competitive-programming :: USACOcontests/silver/2014.12 (marathon)

; 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 [12 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 [13 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 @_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 ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca %"struct.std::pair", align 4
  %16 = alloca %"struct.std::pair", align 4
  store i32 0, ptr %1, align 4
  %17 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %18 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %19 = getelementptr i8, ptr %18, i64 -24
  %20 = load i64, ptr %19, align 8
  %21 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %20
  %22 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %21, ptr noundef null)
  %23 = load ptr, ptr @stdin, align 8, !tbaa !8
  %24 = call ptr @freopen(ptr noundef @.str, ptr noundef @.str.1, ptr noundef %23)
  %25 = load ptr, ptr @stdout, align 8, !tbaa !8
  %26 = call ptr @freopen(ptr noundef @.str.2, ptr noundef @.str.3, ptr noundef %25)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #9
  %27 = 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)
  %28 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %27, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %29 = load i32, ptr %2, align 4, !tbaa !11
  %30 = zext i32 %29 to i64
  %31 = call ptr @llvm.stacksave.p0()
  store ptr %31, ptr %4, align 8
  %32 = alloca %"struct.std::pair", i64 %30, align 16
  store i64 %30, ptr %5, align 8
  %33 = icmp eq i64 %30, 0
  br i1 %33, label %40, label %34

34:                                               ; preds = %0
  %35 = getelementptr inbounds %"struct.std::pair", ptr %32, i64 %30
  br label %36

36:                                               ; preds = %36, %34
  %37 = phi ptr [ %32, %34 ], [ %38, %36 ]
  call void @_ZNSt4pairIiiEC2IiiTnNSt9enable_ifIXsr6__and_ISt37__is_implicitly_default_constructibleIT_ES3_IT0_EEE5valueEbE4typeELb1EEEv(ptr noundef nonnull align 4 dereferenceable(8) %37)
  %38 = getelementptr inbounds %"struct.std::pair", ptr %37, i64 1
  %39 = icmp eq ptr %38, %35
  br i1 %39, label %40, label %36

40:                                               ; preds = %36, %0
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #9
  store i32 0, ptr %6, align 4, !tbaa !11
  br label %41

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

45:                                               ; preds = %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #9
  br label %60

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

57:                                               ; preds = %46
  %58 = load i32, ptr %6, align 4, !tbaa !11
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %6, align 4, !tbaa !11
  br label %41, !llvm.loop !13

60:                                               ; preds = %45
  %61 = load i32, ptr %2, align 4, !tbaa !11
  %62 = zext i32 %61 to i64
  %63 = load i32, ptr %3, align 4, !tbaa !11
  %64 = add nsw i32 %63, 1
  %65 = zext i32 %64 to i64
  %66 = mul nuw i64 %62, %65
  %67 = alloca i32, i64 %66, align 16
  store i64 %62, ptr %7, align 8
  store i64 %65, ptr %8, align 8
  %68 = mul nsw i64 0, %65
  %69 = getelementptr inbounds i32, ptr %67, i64 %68
  %70 = load i32, ptr %2, align 4, !tbaa !11
  %71 = sub nsw i32 %70, 1
  %72 = sext i32 %71 to i64
  %73 = mul nsw i64 %72, %65
  %74 = getelementptr inbounds i32, ptr %67, i64 %73
  %75 = load i32, ptr %3, align 4, !tbaa !11
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds i32, ptr %74, i64 %76
  %78 = getelementptr inbounds i32, ptr %77, i64 1
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #9
  store i32 2000000, ptr %9, align 4, !tbaa !11
  call void @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef %69, ptr noundef %78, ptr noundef nonnull align 4 dereferenceable(4) %9)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #9
  %79 = mul nsw i64 0, %65
  %80 = getelementptr inbounds i32, ptr %67, i64 %79
  %81 = getelementptr inbounds i32, ptr %80, i64 0
  store i32 0, ptr %81, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #9
  store i32 0, ptr %10, align 4, !tbaa !11
  br label %82

82:                                               ; preds = %166, %60
  %83 = load i32, ptr %10, align 4, !tbaa !11
  %84 = load i32, ptr %2, align 4, !tbaa !11
  %85 = icmp slt i32 %83, %84
  br i1 %85, label %87, label %86

86:                                               ; preds = %82
  store i32 5, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #9
  br label %169

87:                                               ; preds = %82
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #9
  store i32 0, ptr %12, align 4, !tbaa !11
  br label %88

88:                                               ; preds = %162, %87
  %89 = load i32, ptr %12, align 4, !tbaa !11
  %90 = 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) %3)
  %91 = load i32, ptr %90, align 4, !tbaa !11
  %92 = icmp sle i32 %89, %91
  br i1 %92, label %94, label %93

93:                                               ; preds = %88
  store i32 8, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #9
  br label %165

94:                                               ; preds = %88
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #9
  %95 = load i32, ptr %10, align 4, !tbaa !11
  %96 = add nsw i32 %95, 1
  store i32 %96, ptr %13, align 4, !tbaa !11
  br label %97

97:                                               ; preds = %157, %94
  %98 = load i32, ptr %13, align 4, !tbaa !11
  %99 = load i32, ptr %2, align 4, !tbaa !11
  %100 = icmp slt i32 %98, %99
  br i1 %100, label %102, label %101

101:                                              ; preds = %97
  store i32 11, ptr %11, align 4
  br label %160

102:                                              ; preds = %97
  %103 = load i32, ptr %13, align 4, !tbaa !11
  %104 = load i32, ptr %10, align 4, !tbaa !11
  %105 = sub nsw i32 %103, %104
  %106 = sub nsw i32 %105, 1
  %107 = load i32, ptr %12, align 4, !tbaa !11
  %108 = add nsw i32 %106, %107
  %109 = load i32, ptr %3, align 4, !tbaa !11
  %110 = icmp sgt i32 %108, %109
  br i1 %110, label %111, label %112

111:                                              ; preds = %102
  store i32 11, ptr %11, align 4
  br label %160

112:                                              ; preds = %102
  %113 = load i32, ptr %13, align 4, !tbaa !11
  %114 = sext i32 %113 to i64
  %115 = mul nsw i64 %114, %65
  %116 = getelementptr inbounds i32, ptr %67, i64 %115
  %117 = load i32, ptr %13, align 4, !tbaa !11
  %118 = load i32, ptr %10, align 4, !tbaa !11
  %119 = sub nsw i32 %117, %118
  %120 = sub nsw i32 %119, 1
  %121 = load i32, ptr %12, align 4, !tbaa !11
  %122 = add nsw i32 %120, %121
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds i32, ptr %116, i64 %123
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #9
  %125 = load i32, ptr %10, align 4, !tbaa !11
  %126 = sext i32 %125 to i64
  %127 = mul nsw i64 %126, %65
  %128 = getelementptr inbounds i32, ptr %67, i64 %127
  %129 = load i32, ptr %12, align 4, !tbaa !11
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds i32, ptr %128, i64 %130
  %132 = load i32, ptr %131, align 4, !tbaa !11
  %133 = load i32, ptr %10, align 4, !tbaa !11
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds %"struct.std::pair", ptr %32, i64 %134
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %15, ptr align 8 %135, i64 8, i1 false)
  %136 = load i32, ptr %13, align 4, !tbaa !11
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds %"struct.std::pair", ptr %32, i64 %137
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %16, ptr align 8 %138, i64 8, i1 false)
  %139 = load i64, ptr %15, align 4
  %140 = load i64, ptr %16, align 4
  %141 = call noundef i32 @_Z4distSt4pairIiiES0_(i64 %139, i64 %140)
  %142 = add nsw i32 %132, %141
  store i32 %142, ptr %14, align 4, !tbaa !11
  %143 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %124, ptr noundef nonnull align 4 dereferenceable(4) %14)
  %144 = load i32, ptr %143, align 4, !tbaa !11
  %145 = load i32, ptr %13, align 4, !tbaa !11
  %146 = sext i32 %145 to i64
  %147 = mul nsw i64 %146, %65
  %148 = getelementptr inbounds i32, ptr %67, i64 %147
  %149 = load i32, ptr %13, align 4, !tbaa !11
  %150 = load i32, ptr %10, align 4, !tbaa !11
  %151 = sub nsw i32 %149, %150
  %152 = sub nsw i32 %151, 1
  %153 = load i32, ptr %12, align 4, !tbaa !11
  %154 = add nsw i32 %152, %153
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds i32, ptr %148, i64 %155
  store i32 %144, ptr %156, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #9
  br label %157

157:                                              ; preds = %112
  %158 = load i32, ptr %13, align 4, !tbaa !11
  %159 = add nsw i32 %158, 1
  store i32 %159, ptr %13, align 4, !tbaa !11
  br label %97, !llvm.loop !15

160:                                              ; preds = %111, %101
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #9
  br label %161

161:                                              ; preds = %160
  br label %162

162:                                              ; preds = %161
  %163 = load i32, ptr %12, align 4, !tbaa !11
  %164 = add nsw i32 %163, 1
  store i32 %164, ptr %12, align 4, !tbaa !11
  br label %88, !llvm.loop !16

165:                                              ; preds = %93
  br label %166

166:                                              ; preds = %165
  %167 = load i32, ptr %10, align 4, !tbaa !11
  %168 = add nsw i32 %167, 1
  store i32 %168, ptr %10, align 4, !tbaa !11
  br label %82, !llvm.loop !17

169:                                              ; preds = %86
  %170 = load i32, ptr %2, align 4, !tbaa !11
  %171 = sub nsw i32 %170, 1
  %172 = sext i32 %171 to i64
  %173 = mul nsw i64 %172, %65
  %174 = getelementptr inbounds i32, ptr %67, i64 %173
  %175 = load i32, ptr %3, align 4, !tbaa !11
  %176 = sext i32 %175 to i64
  %177 = getelementptr inbounds i32, ptr %174, i64 %176
  %178 = load i32, ptr %177, align 4, !tbaa !11
  %179 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %178)
  %180 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %179, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %11, align 4
  %181 = load ptr, ptr %4, align 8
  call void @llvm.stackrestore.p0(ptr %181)
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #9
  %182 = load i32, ptr %1, align 4
  ret i32 %182
}

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

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

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

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

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

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #8 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 = { 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 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #8 = { 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 #9 = { 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}
!17 = distinct !{!17, !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"

%"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 [12 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 [13 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 @_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 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
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #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 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %16, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %18 = load i32, ptr %1, align 4, !tbaa !11
  %19 = zext i32 %18 to i64
  %20 = call ptr @llvm.stacksave.p0()
  %21 = alloca %"struct.std::pair", i64 %19, align 16
  %22 = icmp eq i32 %18, 0
  br i1 %22, label %.loopexit, label %23

23:                                               ; preds = %0
  %24 = getelementptr inbounds %"struct.std::pair", ptr %21, i64 %19
  br label %25

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

.loopexit:                                        ; preds = %25, %0
  %29 = load i32, ptr %1, align 4, !tbaa !11
  %30 = icmp sgt i32 %29, 0
  br i1 %30, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.loopexit
  %.lcssa25 = phi i32 [ %29, %.loopexit ], [ %50, %.lr.ph ]
  %31 = zext i32 %.lcssa25 to i64
  %32 = load i32, ptr %2, align 4, !tbaa !11
  %33 = add nsw i32 %32, 1
  %34 = zext i32 %33 to i64
  %35 = mul nuw i64 %34, %31
  %36 = alloca i32, i64 %35, align 16
  %37 = add nsw i32 %.lcssa25, -1
  %38 = sext i32 %37 to i64
  %39 = mul nsw i64 %34, %38
  %40 = getelementptr inbounds i32, ptr %36, i64 %39
  %41 = sext i32 %32 to i64
  %42 = getelementptr inbounds i32, ptr %40, i64 %41
  %43 = getelementptr inbounds i8, ptr %42, i64 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #8
  store i32 2000000, ptr %3, align 4, !tbaa !11
  call void @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef nonnull %36, ptr noundef nonnull %43, ptr noundef nonnull align 4 dereferenceable(4) %3)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #8
  store i32 0, ptr %36, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #8
  store i32 0, ptr %4, align 4, !tbaa !11
  %44 = load i32, ptr %1, align 4, !tbaa !11
  %45 = icmp sgt i32 %44, 0
  br i1 %45, label %.preheader, label %._crit_edge38

.lr.ph:                                           ; preds = %.loopexit, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.loopexit ]
  %46 = getelementptr inbounds %"struct.std::pair", ptr %21, i64 %indvars.iv
  %47 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %46)
  %48 = getelementptr inbounds i8, ptr %46, i64 4
  %49 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %47, ptr noundef nonnull align 4 dereferenceable(4) %48)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %50 = load i32, ptr %1, align 4, !tbaa !11
  %51 = sext i32 %50 to i64
  %52 = icmp slt i64 %indvars.iv.next, %51
  br i1 %52, label %.lr.ph, label %._crit_edge, !llvm.loop !13

.preheader:                                       ; preds = %._crit_edge, %._crit_edge37
  %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) %2)
  %54 = load i32, ptr %53, align 4, !tbaa !11
  %.not34 = icmp slt i32 %54, 0
  br i1 %.not34, label %._crit_edge37, label %.lr.ph36

._crit_edge38:                                    ; preds = %._crit_edge37, %._crit_edge
  %.lcssa = phi i32 [ %44, %._crit_edge ], [ %67, %._crit_edge37 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #8
  %55 = add nsw i32 %.lcssa, -1
  %56 = sext i32 %55 to i64
  %57 = mul nsw i64 %56, %34
  %58 = getelementptr inbounds i32, ptr %36, i64 %57
  %59 = load i32, ptr %2, align 4, !tbaa !11
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds i32, ptr %58, i64 %60
  %62 = load i32, ptr %61, align 4, !tbaa !11
  %63 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %62)
  %64 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %63, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.stackrestore.p0(ptr %20)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #8
  ret i32 0

._crit_edge37:                                    ; preds = %._crit_edge32, %.preheader
  %65 = load i32, ptr %4, align 4, !tbaa !11
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %4, align 4, !tbaa !11
  %67 = load i32, ptr %1, align 4, !tbaa !11
  %68 = icmp slt i32 %66, %67
  br i1 %68, label %.preheader, label %._crit_edge38, !llvm.loop !15

.lr.ph36:                                         ; preds = %.preheader, %._crit_edge32
  %indvars.iv46 = phi i64 [ %indvars.iv.next47, %._crit_edge32 ], [ 0, %.preheader ]
  %69 = load i32, ptr %4, align 4, !tbaa !11
  %.02027 = add nsw i32 %69, 1
  %70 = load i32, ptr %1, align 4, !tbaa !11
  %71 = icmp slt i32 %.02027, %70
  br i1 %71, label %.lr.ph31, label %._crit_edge32

.lr.ph31:                                         ; preds = %.lr.ph36
  %invariant.gep = getelementptr i32, ptr %36, i64 %indvars.iv46
  %72 = sext i32 %69 to i64
  %73 = add nsw i64 %72, 1
  %74 = trunc nuw nsw i64 %indvars.iv46 to i32
  br label %75

75:                                               ; preds = %.lr.ph31, %81
  %76 = phi i32 [ %69, %.lr.ph31 ], [ %95, %81 ]
  %indvars.iv43 = phi i64 [ %73, %.lr.ph31 ], [ %indvars.iv.next44, %81 ]
  %.020.in28 = phi i32 [ %69, %.lr.ph31 ], [ %103, %81 ]
  %77 = sub i32 %.020.in28, %76
  %78 = add nsw i32 %77, %74
  %79 = load i32, ptr %2, align 4, !tbaa !11
  %80 = icmp sgt i32 %78, %79
  br i1 %80, label %._crit_edge32, label %81

81:                                               ; preds = %75
  %82 = mul nsw i64 %indvars.iv43, %34
  %83 = getelementptr inbounds i32, ptr %36, i64 %82
  %84 = sext i32 %78 to i64
  %85 = getelementptr inbounds i32, ptr %83, i64 %84
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #8
  %86 = sext i32 %76 to i64
  %87 = mul nsw i64 %86, %34
  %gep = getelementptr i32, ptr %invariant.gep, i64 %87
  %88 = load i32, ptr %gep, align 4, !tbaa !11
  %89 = getelementptr inbounds %"struct.std::pair", ptr %21, i64 %86
  %.sroa.01.0.copyload = load i64, ptr %89, align 8
  %90 = getelementptr inbounds %"struct.std::pair", ptr %21, i64 %indvars.iv43
  %.sroa.0.0.copyload = load i64, ptr %90, align 8
  %91 = call noundef i32 @_Z4distSt4pairIiiES0_(i64 %.sroa.01.0.copyload, i64 %.sroa.0.0.copyload)
  %92 = add nsw i32 %91, %88
  store i32 %92, ptr %5, align 4, !tbaa !11
  %93 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %85, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %94 = load i32, ptr %93, align 4, !tbaa !11
  %95 = load i32, ptr %4, align 4, !tbaa !11
  %96 = add i32 %.020.in28, %74
  %97 = sub i32 %96, %95
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds i32, ptr %83, i64 %98
  store i32 %94, ptr %99, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #8
  %indvars.iv.next44 = add nsw i64 %indvars.iv43, 1
  %100 = load i32, ptr %1, align 4, !tbaa !11
  %101 = sext i32 %100 to i64
  %102 = icmp slt i64 %indvars.iv.next44, %101
  %103 = trunc nsw i64 %indvars.iv43 to i32
  br i1 %102, label %75, label %._crit_edge32, !llvm.loop !16

._crit_edge32:                                    ; preds = %81, %75, %.lr.ph36
  %indvars.iv.next47 = add nuw nsw i64 %indvars.iv46, 1
  %104 = 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) %2)
  %105 = load i32, ptr %104, align 4, !tbaa !11
  %106 = sext i32 %105 to i64
  %.not.not = icmp slt i64 %indvars.iv46, %106
  br i1 %.not.not, label %.lr.ph36, label %._crit_edge37, !llvm.loop !17
}

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

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #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 #2

; 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: 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 @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) 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

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

; 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 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}


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