; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/300/Problem C (C)

; 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 { i64, i64 }
%"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" }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@d = external dso_local global i64, align 8
@hi = external dso_local global i64, align 8
@mx = external dso_local global i64, align 8
@h1 = external dso_local global i64, align 8
@h2 = external dso_local global i64, align 8
@d1 = external dso_local global i64, align 8
@d2 = external dso_local global i64, align 8
@x = external dso_local global i64, align 8
@h = external dso_local global [100000 x %"struct.std::pair"], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [12 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca %"struct.std::pair", align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  %10 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %11 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %12 = getelementptr i8, ptr %11, i64 -24
  %13 = load i64, ptr %12, align 8
  %14 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %13
  %15 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %14, ptr noundef null)
  %16 = load ptr, ptr @_ZSt4cout, align 8, !tbaa !5
  %17 = getelementptr i8, ptr %16, i64 -24
  %18 = load i64, ptr %17, align 8
  %19 = getelementptr inbounds i8, ptr @_ZSt4cout, i64 %18
  %20 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %19, ptr noundef null)
  %21 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @n)
  %22 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %21, ptr noundef nonnull align 4 dereferenceable(4) @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 0, ptr %2, align 4, !tbaa !8
  br label %23

23:                                               ; preds = %40, %0
  %24 = load i32, ptr %2, align 4, !tbaa !8
  %25 = load i32, ptr @m, align 4, !tbaa !8
  %26 = icmp slt i32 %24, %25
  br i1 %26, label %28, label %27

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

28:                                               ; preds = %23
  %29 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @d)
  %30 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %29, ptr noundef nonnull align 8 dereferenceable(8) @hi)
  call void @llvm.lifetime.start.p0(i64 16, ptr %3) #7
  %31 = call { i64, i64 } @_ZSt9make_pairIRxS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8) @d, ptr noundef nonnull align 8 dereferenceable(8) @hi)
  %32 = getelementptr inbounds { i64, i64 }, ptr %3, i32 0, i32 0
  %33 = extractvalue { i64, i64 } %31, 0
  store i64 %33, ptr %32, align 8
  %34 = getelementptr inbounds { i64, i64 }, ptr %3, i32 0, i32 1
  %35 = extractvalue { i64, i64 } %31, 1
  store i64 %35, ptr %34, align 8
  %36 = load i32, ptr %2, align 4, !tbaa !8
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [100000 x %"struct.std::pair"], ptr @h, i64 0, i64 %37
  %39 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt4pairIxxEaSEOS0_(ptr noundef nonnull align 8 dereferenceable(16) %38, ptr noundef nonnull align 8 dereferenceable(16) %3) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %3) #7
  br label %40

40:                                               ; preds = %28
  %41 = load i32, ptr %2, align 4, !tbaa !8
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %2, align 4, !tbaa !8
  br label %23, !llvm.loop !11

43:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #7
  %44 = load i32, ptr @m, align 4, !tbaa !8
  %45 = sub nsw i32 %44, 1
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [100000 x %"struct.std::pair"], ptr @h, i64 0, i64 %46
  %48 = getelementptr inbounds %"struct.std::pair", ptr %47, i32 0, i32 1
  %49 = load i64, ptr %48, align 8, !tbaa !13
  %50 = load i32, ptr @n, align 4, !tbaa !8
  %51 = sext i32 %50 to i64
  %52 = load i32, ptr @m, align 4, !tbaa !8
  %53 = sub nsw i32 %52, 1
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [100000 x %"struct.std::pair"], ptr @h, i64 0, i64 %54
  %56 = getelementptr inbounds %"struct.std::pair", ptr %55, i32 0, i32 0
  %57 = load i64, ptr %56, align 16, !tbaa !16
  %58 = sub nsw i64 %51, %57
  %59 = add nsw i64 %49, %58
  store i64 %59, ptr %4, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  %60 = load i64, ptr getelementptr inbounds (%"struct.std::pair", ptr @h, i32 0, i32 1), align 8, !tbaa !13
  %61 = load i64, ptr @h, align 16, !tbaa !16
  %62 = sub nsw i64 %61, 1
  %63 = add nsw i64 %60, %62
  store i64 %63, ptr %5, align 8, !tbaa !17
  %64 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %5)
  %65 = load i64, ptr %64, align 8, !tbaa !17
  store i64 %65, ptr @mx, align 8, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  store i32 1, ptr %6, align 4, !tbaa !8
  br label %66

66:                                               ; preds = %150, %43
  %67 = load i32, ptr %6, align 4, !tbaa !8
  %68 = load i32, ptr @m, align 4, !tbaa !8
  %69 = icmp slt i32 %67, %68
  br i1 %69, label %71, label %70

70:                                               ; preds = %66
  store i32 5, ptr %7, align 4
  br label %153

71:                                               ; preds = %66
  %72 = load i32, ptr %6, align 4, !tbaa !8
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [100000 x %"struct.std::pair"], ptr @h, i64 0, i64 %73
  %75 = getelementptr inbounds %"struct.std::pair", ptr %74, i32 0, i32 1
  %76 = load i64, ptr %75, align 8, !tbaa !13
  store i64 %76, ptr @h1, align 8, !tbaa !17
  %77 = load i32, ptr %6, align 4, !tbaa !8
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [100000 x %"struct.std::pair"], ptr @h, i64 0, i64 %78
  %80 = getelementptr inbounds %"struct.std::pair", ptr %79, i32 0, i32 0
  %81 = load i64, ptr %80, align 16, !tbaa !16
  store i64 %81, ptr @d2, align 8, !tbaa !17
  %82 = load i32, ptr %6, align 4, !tbaa !8
  %83 = sub nsw i32 %82, 1
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [100000 x %"struct.std::pair"], ptr @h, i64 0, i64 %84
  %86 = getelementptr inbounds %"struct.std::pair", ptr %85, i32 0, i32 1
  %87 = load i64, ptr %86, align 8, !tbaa !13
  store i64 %87, ptr @h2, align 8, !tbaa !17
  %88 = load i32, ptr %6, align 4, !tbaa !8
  %89 = sub nsw i32 %88, 1
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [100000 x %"struct.std::pair"], ptr @h, i64 0, i64 %90
  %92 = getelementptr inbounds %"struct.std::pair", ptr %91, i32 0, i32 0
  %93 = load i64, ptr %92, align 16, !tbaa !16
  store i64 %93, ptr @d1, align 8, !tbaa !17
  %94 = load i64, ptr @h1, align 8, !tbaa !17
  %95 = load i64, ptr @h2, align 8, !tbaa !17
  %96 = icmp sle i64 %94, %95
  br i1 %96, label %97, label %123

97:                                               ; preds = %71
  %98 = load i64, ptr @h1, align 8, !tbaa !17
  %99 = load i64, ptr @d2, align 8, !tbaa !17
  %100 = load i64, ptr @d1, align 8, !tbaa !17
  %101 = sub nsw i64 %99, %100
  %102 = add nsw i64 %98, %101
  %103 = load i64, ptr @h2, align 8, !tbaa !17
  %104 = icmp slt i64 %102, %103
  br i1 %104, label %105, label %107

105:                                              ; preds = %97
  %106 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %7, align 4
  br label %153

107:                                              ; preds = %97
  %108 = load i64, ptr @h2, align 8, !tbaa !17
  %109 = load i64, ptr @h1, align 8, !tbaa !17
  %110 = sub nsw i64 %108, %109
  %111 = load i64, ptr @d2, align 8, !tbaa !17
  %112 = load i64, ptr @d1, align 8, !tbaa !17
  %113 = sub nsw i64 %111, %112
  %114 = sub nsw i64 %113, 1
  %115 = add nsw i64 %110, %114
  %116 = add nsw i64 %115, 1
  %117 = sdiv i64 %116, 2
  store i64 %117, ptr @x, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  %118 = load i64, ptr @h1, align 8, !tbaa !17
  %119 = load i64, ptr @x, align 8, !tbaa !17
  %120 = add nsw i64 %118, %119
  store i64 %120, ptr %8, align 8, !tbaa !17
  %121 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) @mx, ptr noundef nonnull align 8 dereferenceable(8) %8)
  %122 = load i64, ptr %121, align 8, !tbaa !17
  store i64 %122, ptr @mx, align 8, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  br label %149

123:                                              ; preds = %71
  %124 = load i64, ptr @h1, align 8, !tbaa !17
  %125 = load i64, ptr @d2, align 8, !tbaa !17
  %126 = load i64, ptr @d1, align 8, !tbaa !17
  %127 = sub nsw i64 %125, %126
  %128 = sub nsw i64 %124, %127
  %129 = load i64, ptr @h2, align 8, !tbaa !17
  %130 = icmp sgt i64 %128, %129
  br i1 %130, label %131, label %133

131:                                              ; preds = %123
  %132 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %7, align 4
  br label %153

133:                                              ; preds = %123
  %134 = load i64, ptr @h1, align 8, !tbaa !17
  %135 = load i64, ptr @h2, align 8, !tbaa !17
  %136 = sub nsw i64 %134, %135
  %137 = load i64, ptr @d2, align 8, !tbaa !17
  %138 = load i64, ptr @d1, align 8, !tbaa !17
  %139 = sub nsw i64 %137, %138
  %140 = sub nsw i64 %139, 1
  %141 = add nsw i64 %136, %140
  %142 = add nsw i64 %141, 1
  %143 = sdiv i64 %142, 2
  store i64 %143, ptr @x, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %144 = load i64, ptr @h2, align 8, !tbaa !17
  %145 = load i64, ptr @x, align 8, !tbaa !17
  %146 = add nsw i64 %144, %145
  store i64 %146, ptr %9, align 8, !tbaa !17
  %147 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) @mx, ptr noundef nonnull align 8 dereferenceable(8) %9)
  %148 = load i64, ptr %147, align 8, !tbaa !17
  store i64 %148, ptr @mx, align 8, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  br label %149

149:                                              ; preds = %133, %107
  br label %150

150:                                              ; preds = %149
  %151 = load i32, ptr %6, align 4, !tbaa !8
  %152 = add nsw i32 %151, 1
  store i32 %152, ptr %6, align 4, !tbaa !8
  br label %66, !llvm.loop !18

153:                                              ; preds = %131, %105, %70
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  %154 = load i32, ptr %7, align 4
  switch i32 %154, label %161 [
    i32 5, label %155
    i32 1, label %159
  ]

155:                                              ; preds = %153
  %156 = load i64, ptr @mx, align 8, !tbaa !17
  %157 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %156)
  %158 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %157, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  store i32 0, ptr %1, align 4
  br label %159

159:                                              ; preds = %155, %153
  %160 = load i32, ptr %1, align 4
  ret i32 %160

161:                                              ; preds = %153
  unreachable
}

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

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

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

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local { i64, i64 } @_ZSt9make_pairIRxS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt4pairIxxEaSEOS0_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #2 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 nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #5

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #6

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #4 align 2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #4 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)) #6

attributes #0 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { 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 #7 = { nounwind }

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

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


; 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 { i64, i64 }
%"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" }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@d = external dso_local global i64, align 8
@hi = external dso_local global i64, align 8
@mx = external dso_local global i64, align 8
@h1 = external dso_local local_unnamed_addr global i64, align 8
@h2 = external dso_local local_unnamed_addr global i64, align 8
@d1 = external dso_local local_unnamed_addr global i64, align 8
@d2 = external dso_local local_unnamed_addr global i64, align 8
@x = external dso_local local_unnamed_addr global i64, align 8
@h = external dso_local global [100000 x %"struct.std::pair"], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [12 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca %"struct.std::pair", align 8
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %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 @_ZSt4cout, align 8, !tbaa !5
  %13 = getelementptr i8, ptr %12, i64 -24
  %14 = load i64, ptr %13, align 8
  %15 = getelementptr inbounds i8, ptr @_ZSt4cout, i64 %14
  %16 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %15, ptr noundef null)
  %17 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @n)
  %18 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %17, ptr noundef nonnull align 4 dereferenceable(4) @m)
  %19 = load i32, ptr @m, align 4, !tbaa !8
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0
  %21 = getelementptr inbounds i8, ptr %1, i64 8
  br label %40

._crit_edge:                                      ; preds = %40, %0
  %.lcssa = phi i32 [ %19, %0 ], [ %48, %40 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #7
  %22 = add nsw i32 %.lcssa, -1
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [100000 x %"struct.std::pair"], ptr @h, i64 0, i64 %23
  %25 = getelementptr inbounds i8, ptr %24, i64 8
  %26 = load i64, ptr %25, align 8, !tbaa !11
  %27 = load i32, ptr @n, align 4, !tbaa !8
  %28 = sext i32 %27 to i64
  %29 = load i64, ptr %24, align 16, !tbaa !14
  %30 = sub i64 %26, %29
  %31 = add i64 %30, %28
  store i64 %31, ptr %2, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #7
  %32 = load i64, ptr getelementptr inbounds (i8, ptr @h, i64 8), align 8, !tbaa !11
  %33 = load i64, ptr @h, align 16, !tbaa !14
  %34 = add i64 %32, -1
  %35 = add i64 %34, %33
  store i64 %35, ptr %3, align 8, !tbaa !15
  %36 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %37 = load i64, ptr %36, align 8, !tbaa !15
  store i64 %37, ptr @mx, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  %38 = load i32, ptr @m, align 4, !tbaa !8
  %39 = icmp sgt i32 %38, 1
  br i1 %39, label %.lr.ph24, label %._crit_edge25

40:                                               ; preds = %.lr.ph, %40
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %40 ]
  %41 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @d)
  %42 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %41, ptr noundef nonnull align 8 dereferenceable(8) @hi)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %1) #7
  %43 = call { i64, i64 } @_ZSt9make_pairIRxS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8) @d, ptr noundef nonnull align 8 dereferenceable(8) @hi)
  %44 = extractvalue { i64, i64 } %43, 0
  store i64 %44, ptr %1, align 8
  %45 = extractvalue { i64, i64 } %43, 1
  store i64 %45, ptr %21, align 8
  %46 = getelementptr inbounds [100000 x %"struct.std::pair"], ptr @h, i64 0, i64 %indvars.iv
  %47 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt4pairIxxEaSEOS0_(ptr noundef nonnull align 8 dereferenceable(16) %46, ptr noundef nonnull align 8 dereferenceable(16) %1) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %1) #7
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %48 = load i32, ptr @m, align 4, !tbaa !8
  %49 = sext i32 %48 to i64
  %50 = icmp slt i64 %indvars.iv.next, %49
  br i1 %50, label %40, label %._crit_edge, !llvm.loop !16

.lr.ph24:                                         ; preds = %._crit_edge, %85
  %indvars.iv28 = phi i64 [ %indvars.iv.next29, %85 ], [ 1, %._crit_edge ]
  %51 = getelementptr inbounds [100000 x %"struct.std::pair"], ptr @h, i64 0, i64 %indvars.iv28
  %52 = getelementptr inbounds i8, ptr %51, i64 8
  %53 = load i64, ptr %52, align 8, !tbaa !11
  store i64 %53, ptr @h1, align 8, !tbaa !15
  %54 = load i64, ptr %51, align 16, !tbaa !14
  store i64 %54, ptr @d2, align 8, !tbaa !15
  %55 = add nsw i64 %indvars.iv28, -1
  %56 = getelementptr inbounds [100000 x %"struct.std::pair"], ptr @h, i64 0, i64 %55
  %57 = getelementptr inbounds i8, ptr %56, i64 8
  %58 = load i64, ptr %57, align 8, !tbaa !11
  store i64 %58, ptr @h2, align 8, !tbaa !15
  %59 = load i64, ptr %56, align 16, !tbaa !14
  store i64 %59, ptr @d1, align 8, !tbaa !15
  %.not = icmp sgt i64 %53, %58
  %60 = sub nsw i64 %54, %59
  br i1 %.not, label %73, label %61

61:                                               ; preds = %.lr.ph24
  %62 = add nsw i64 %60, %53
  %63 = icmp slt i64 %62, %58
  br i1 %63, label %64, label %66

64:                                               ; preds = %61
  %65 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @.str)
  br label %.thread

66:                                               ; preds = %61
  %67 = sub i64 %58, %53
  %68 = add i64 %67, %60
  %69 = sdiv i64 %68, 2
  store i64 %69, ptr @x, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #7
  %70 = add nsw i64 %69, %53
  store i64 %70, ptr %4, align 8, !tbaa !15
  %71 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) @mx, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %72 = load i64, ptr %71, align 8, !tbaa !15
  store i64 %72, ptr @mx, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #7
  br label %85

73:                                               ; preds = %.lr.ph24
  %74 = sub nsw i64 %53, %60
  %75 = icmp sgt i64 %74, %58
  br i1 %75, label %76, label %78

76:                                               ; preds = %73
  %77 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @.str)
  br label %.thread

78:                                               ; preds = %73
  %79 = sub i64 %53, %58
  %80 = add i64 %79, %60
  %81 = sdiv i64 %80, 2
  store i64 %81, ptr @x, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #7
  %82 = add nsw i64 %81, %58
  store i64 %82, ptr %5, align 8, !tbaa !15
  %83 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) @mx, ptr noundef nonnull align 8 dereferenceable(8) %5)
  %84 = load i64, ptr %83, align 8, !tbaa !15
  store i64 %84, ptr @mx, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #7
  br label %85

85:                                               ; preds = %66, %78
  %86 = phi i64 [ %72, %66 ], [ %84, %78 ]
  %indvars.iv.next29 = add nuw nsw i64 %indvars.iv28, 1
  %87 = load i32, ptr @m, align 4, !tbaa !8
  %88 = sext i32 %87 to i64
  %89 = icmp slt i64 %indvars.iv.next29, %88
  br i1 %89, label %.lr.ph24, label %._crit_edge25, !llvm.loop !18

._crit_edge25:                                    ; preds = %85, %._crit_edge
  %90 = phi i64 [ %37, %._crit_edge ], [ %86, %85 ]
  %91 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %90)
  %92 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %91, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  br label %.thread

.thread:                                          ; preds = %76, %64, %._crit_edge25
  ret i32 0
}

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

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

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 #1

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt4pairIxxEaSEOS0_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 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 nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #5

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #6

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) local_unnamed_addr #4 align 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 #4 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)) #6

attributes #0 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { 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 #7 = { nounwind }

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

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


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