; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/179 Division 1/Problem A (A)

; 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.0" = type { i64, %"struct.std::pair" }
%"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 i64, align 8
@m = external dso_local global i64, align 8
@k = external dso_local global i64, align 8
@a = external dso_local global [262144 x i64], align 16
@o = external dso_local global [262144 x %"struct.std::pair.0"], align 16
@cnt = external dso_local global [262144 x i64], 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 [2 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5buildxxx(i64 noundef, i64 noundef, i64 noundef) #0

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z6updatexxxxxx(i64 noundef, i64 noundef, i64 noundef, i64 noundef, i64 noundef, i64 noundef) #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z5queryxxxx(i64 noundef, i64 noundef, i64 noundef, i64 noundef) #0

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

28:                                               ; preds = %37, %0
  %29 = load i64, ptr %2, align 8, !tbaa !8
  %30 = load i64, ptr @n, align 8, !tbaa !8
  %31 = icmp slt i64 %29, %30
  br i1 %31, label %33, label %32

32:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #6
  br label %40

33:                                               ; preds = %28
  %34 = load i64, ptr %2, align 8, !tbaa !8
  %35 = getelementptr inbounds [262144 x i64], ptr @a, i64 0, i64 %34
  %36 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %35)
  br label %37

37:                                               ; preds = %33
  %38 = load i64, ptr %2, align 8, !tbaa !8
  %39 = add nsw i64 %38, 1
  store i64 %39, ptr %2, align 8, !tbaa !8
  br label %28, !llvm.loop !11

40:                                               ; preds = %32
  %41 = load i64, ptr @n, align 8, !tbaa !8
  call void @_Z5buildxxx(i64 noundef 1, i64 noundef 0, i64 noundef %41)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  store i64 1, ptr %3, align 8, !tbaa !8
  br label %42

42:                                               ; preds = %59, %40
  %43 = load i64, ptr %3, align 8, !tbaa !8
  %44 = load i64, ptr @m, align 8, !tbaa !8
  %45 = icmp sle i64 %43, %44
  br i1 %45, label %47, label %46

46:                                               ; preds = %42
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  br label %62

47:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %48 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %49 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %48, ptr noundef nonnull align 8 dereferenceable(8) %5)
  %50 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %49, ptr noundef nonnull align 8 dereferenceable(8) %6)
  call void @llvm.lifetime.start.p0(i64 24, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #6
  %51 = call { i64, i64 } @_ZSt9make_pairIRxS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %5)
  %52 = getelementptr inbounds { i64, i64 }, ptr %8, i32 0, i32 0
  %53 = extractvalue { i64, i64 } %51, 0
  store i64 %53, ptr %52, align 8
  %54 = getelementptr inbounds { i64, i64 }, ptr %8, i32 0, i32 1
  %55 = extractvalue { i64, i64 } %51, 1
  store i64 %55, ptr %54, align 8
  call void @_ZSt9make_pairIRxSt4pairIxxEES1_INSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS3_INS4_IT0_E4typeEE6__typeEEOS5_OSA_(ptr dead_on_unwind writable sret(%"struct.std::pair.0") align 8 %7, ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(16) %8)
  %56 = load i64, ptr %3, align 8, !tbaa !8
  %57 = getelementptr inbounds [262144 x %"struct.std::pair.0"], ptr @o, i64 0, i64 %56
  %58 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt4pairIxS_IxxEEaSEOS1_(ptr noundef nonnull align 8 dereferenceable(24) %57, ptr noundef nonnull align 8 dereferenceable(24) %7) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  br label %59

59:                                               ; preds = %47
  %60 = load i64, ptr %3, align 8, !tbaa !8
  %61 = add nsw i64 %60, 1
  store i64 %61, ptr %3, align 8, !tbaa !8
  br label %42, !llvm.loop !13

62:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  store i64 0, ptr %9, align 8, !tbaa !8
  br label %63

63:                                               ; preds = %80, %62
  %64 = load i64, ptr %9, align 8, !tbaa !8
  %65 = load i64, ptr @k, align 8, !tbaa !8
  %66 = icmp slt i64 %64, %65
  br i1 %66, label %68, label %67

67:                                               ; preds = %63
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  br label %83

68:                                               ; preds = %63
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %69 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %10)
  %70 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %69, ptr noundef nonnull align 8 dereferenceable(8) %11)
  %71 = load i64, ptr %10, align 8, !tbaa !8
  %72 = getelementptr inbounds [262144 x i64], ptr @cnt, i64 0, i64 %71
  %73 = load i64, ptr %72, align 8, !tbaa !8
  %74 = add nsw i64 %73, 1
  store i64 %74, ptr %72, align 8, !tbaa !8
  %75 = load i64, ptr %11, align 8, !tbaa !8
  %76 = add nsw i64 %75, 1
  %77 = getelementptr inbounds [262144 x i64], ptr @cnt, i64 0, i64 %76
  %78 = load i64, ptr %77, align 8, !tbaa !8
  %79 = add nsw i64 %78, -1
  store i64 %79, ptr %77, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  br label %80

80:                                               ; preds = %68
  %81 = load i64, ptr %9, align 8, !tbaa !8
  %82 = add nsw i64 %81, 1
  store i64 %82, ptr %9, align 8, !tbaa !8
  br label %63, !llvm.loop !14

83:                                               ; preds = %67
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  store i64 1, ptr %12, align 8, !tbaa !8
  br label %84

84:                                               ; preds = %118, %83
  %85 = load i64, ptr %12, align 8, !tbaa !8
  %86 = load i64, ptr @m, align 8, !tbaa !8
  %87 = icmp sle i64 %85, %86
  br i1 %87, label %89, label %88

88:                                               ; preds = %84
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  br label %121

89:                                               ; preds = %84
  %90 = load i64, ptr %12, align 8, !tbaa !8
  %91 = sub nsw i64 %90, 1
  %92 = getelementptr inbounds [262144 x i64], ptr @cnt, i64 0, i64 %91
  %93 = load i64, ptr %92, align 8, !tbaa !8
  %94 = load i64, ptr %12, align 8, !tbaa !8
  %95 = getelementptr inbounds [262144 x i64], ptr @cnt, i64 0, i64 %94
  %96 = load i64, ptr %95, align 8, !tbaa !8
  %97 = add nsw i64 %96, %93
  store i64 %97, ptr %95, align 8, !tbaa !8
  %98 = load i64, ptr %12, align 8, !tbaa !8
  %99 = getelementptr inbounds [262144 x %"struct.std::pair.0"], ptr @o, i64 0, i64 %98
  %100 = getelementptr inbounds %"struct.std::pair.0", ptr %99, i32 0, i32 1
  %101 = getelementptr inbounds %"struct.std::pair", ptr %100, i32 0, i32 0
  %102 = load i64, ptr %101, align 8, !tbaa !15
  %103 = sub nsw i64 %102, 1
  %104 = load i64, ptr %12, align 8, !tbaa !8
  %105 = getelementptr inbounds [262144 x %"struct.std::pair.0"], ptr @o, i64 0, i64 %104
  %106 = getelementptr inbounds %"struct.std::pair.0", ptr %105, i32 0, i32 1
  %107 = getelementptr inbounds %"struct.std::pair", ptr %106, i32 0, i32 1
  %108 = load i64, ptr %107, align 8, !tbaa !18
  %109 = load i64, ptr %12, align 8, !tbaa !8
  %110 = getelementptr inbounds [262144 x i64], ptr @cnt, i64 0, i64 %109
  %111 = load i64, ptr %110, align 8, !tbaa !8
  %112 = load i64, ptr %12, align 8, !tbaa !8
  %113 = getelementptr inbounds [262144 x %"struct.std::pair.0"], ptr @o, i64 0, i64 %112
  %114 = getelementptr inbounds %"struct.std::pair.0", ptr %113, i32 0, i32 0
  %115 = load i64, ptr %114, align 8, !tbaa !19
  %116 = mul nsw i64 %111, %115
  %117 = load i64, ptr @n, align 8, !tbaa !8
  call void @_Z6updatexxxxxx(i64 noundef %103, i64 noundef %108, i64 noundef %116, i64 noundef 1, i64 noundef 0, i64 noundef %117)
  br label %118

118:                                              ; preds = %89
  %119 = load i64, ptr %12, align 8, !tbaa !8
  %120 = add nsw i64 %119, 1
  store i64 %120, ptr %12, align 8, !tbaa !8
  br label %84, !llvm.loop !20

121:                                              ; preds = %88
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  store i64 0, ptr %13, align 8, !tbaa !8
  br label %122

122:                                              ; preds = %133, %121
  %123 = load i64, ptr %13, align 8, !tbaa !8
  %124 = load i64, ptr @n, align 8, !tbaa !8
  %125 = icmp slt i64 %123, %124
  br i1 %125, label %127, label %126

126:                                              ; preds = %122
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  br label %136

127:                                              ; preds = %122
  %128 = load i64, ptr %13, align 8, !tbaa !8
  %129 = load i64, ptr @n, align 8, !tbaa !8
  %130 = call noundef i64 @_Z5queryxxxx(i64 noundef %128, i64 noundef 1, i64 noundef 0, i64 noundef %129)
  %131 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %130)
  %132 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %131, ptr noundef @.str)
  br label %133

133:                                              ; preds = %127
  %134 = load i64, ptr %13, align 8, !tbaa !8
  %135 = add nsw i64 %134, 1
  store i64 %135, ptr %13, align 8, !tbaa !8
  br label %122, !llvm.loop !21

136:                                              ; preds = %126
  %137 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str.1)
  ret i32 0
}

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZSt9make_pairIRxSt4pairIxxEES1_INSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS3_INS4_IT0_E4typeEE6__typeEEOS5_OSA_(ptr dead_on_unwind noalias writable sret(%"struct.std::pair.0") align 8, ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(16)) #0

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

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

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

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { 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 #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 = { 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 = !{!"long long", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = !{!16, !9, i64 8}
!16 = !{!"_ZTSSt4pairIxS_IxxEE", !9, i64 0, !17, i64 8}
!17 = !{!"_ZTSSt4pairIxxE", !9, i64 0, !9, i64 8}
!18 = !{!16, !9, i64 16}
!19 = !{!16, !9, i64 0}
!20 = distinct !{!20, !12}
!21 = distinct !{!21, !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.0" = type { i64, %"struct.std::pair" }
%"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 i64, align 8
@m = external dso_local global i64, align 8
@k = external dso_local global i64, align 8
@a = external dso_local global [262144 x i64], align 16
@o = external dso_local global [262144 x %"struct.std::pair.0"], align 16
@cnt = external dso_local local_unnamed_addr global [262144 x i64], 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 [2 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5buildxxx(i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #0

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z6updatexxxxxx(i64 noundef, i64 noundef, i64 noundef, i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #0

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

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

._crit_edge:                                      ; preds = %.lr.ph, %0
  %.lcssa = phi i64 [ %22, %0 ], [ %29, %.lr.ph ]
  tail call void @_Z5buildxxx(i64 noundef 1, i64 noundef 0, i64 noundef %.lcssa)
  %24 = load i64, ptr @m, align 8, !tbaa !8
  %.not29 = icmp slt i64 %24, 1
  br i1 %.not29, label %.preheader27, label %.lr.ph32

.lr.ph32:                                         ; preds = %._crit_edge
  %25 = getelementptr inbounds i8, ptr %5, i64 8
  br label %34

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.02228 = phi i64 [ %28, %.lr.ph ], [ 0, %0 ]
  %26 = getelementptr inbounds [262144 x i64], ptr @a, i64 0, i64 %.02228
  %27 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %26)
  %28 = add nuw nsw i64 %.02228, 1
  %29 = load i64, ptr @n, align 8, !tbaa !8
  %30 = icmp slt i64 %28, %29
  br i1 %30, label %.lr.ph, label %._crit_edge, !llvm.loop !11

.preheader27:                                     ; preds = %34, %._crit_edge
  %31 = phi i64 [ %24, %._crit_edge ], [ %44, %34 ]
  %32 = load i64, ptr @k, align 8, !tbaa !8
  %33 = icmp sgt i64 %32, 0
  br i1 %33, label %.lr.ph34, label %.preheader26

34:                                               ; preds = %.lr.ph32, %34
  %.02130 = phi i64 [ 1, %.lr.ph32 ], [ %43, %34 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  %35 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %1)
  %36 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %35, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %37 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %36, ptr noundef nonnull align 8 dereferenceable(8) %3)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #6
  %38 = call { i64, i64 } @_ZSt9make_pairIRxS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %39 = extractvalue { i64, i64 } %38, 0
  store i64 %39, ptr %5, align 8
  %40 = extractvalue { i64, i64 } %38, 1
  store i64 %40, ptr %25, align 8
  call void @_ZSt9make_pairIRxSt4pairIxxEES1_INSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS3_INS4_IT0_E4typeEE6__typeEEOS5_OSA_(ptr dead_on_unwind nonnull writable sret(%"struct.std::pair.0") align 8 %4, ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(16) %5)
  %41 = getelementptr inbounds [262144 x %"struct.std::pair.0"], ptr @o, i64 0, i64 %.02130
  %42 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt4pairIxS_IxxEEaSEOS1_(ptr noundef nonnull align 8 dereferenceable(24) %41, ptr noundef nonnull align 8 dereferenceable(24) %4) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #6
  %43 = add nuw nsw i64 %.02130, 1
  %44 = load i64, ptr @m, align 8, !tbaa !8
  %.not.not = icmp slt i64 %.02130, %44
  br i1 %.not.not, label %34, label %.preheader27, !llvm.loop !13

.preheader26.loopexit:                            ; preds = %.lr.ph34
  %.pre = load i64, ptr @m, align 8, !tbaa !8
  br label %.preheader26

.preheader26:                                     ; preds = %.preheader26.loopexit, %.preheader27
  %45 = phi i64 [ %.pre, %.preheader26.loopexit ], [ %31, %.preheader27 ]
  %.not2535 = icmp slt i64 %45, 1
  br i1 %.not2535, label %.preheader, label %.lr.ph37

.lr.ph34:                                         ; preds = %.preheader27, %.lr.ph34
  %.02033 = phi i64 [ %57, %.lr.ph34 ], [ 0, %.preheader27 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #6
  %46 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %6)
  %47 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %46, ptr noundef nonnull align 8 dereferenceable(8) %7)
  %48 = load i64, ptr %6, align 8, !tbaa !8
  %49 = getelementptr inbounds [262144 x i64], ptr @cnt, i64 0, i64 %48
  %50 = load i64, ptr %49, align 8, !tbaa !8
  %51 = add nsw i64 %50, 1
  store i64 %51, ptr %49, align 8, !tbaa !8
  %52 = load i64, ptr %7, align 8, !tbaa !8
  %53 = add nsw i64 %52, 1
  %54 = getelementptr inbounds [262144 x i64], ptr @cnt, i64 0, i64 %53
  %55 = load i64, ptr %54, align 8, !tbaa !8
  %56 = add nsw i64 %55, -1
  store i64 %56, ptr %54, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #6
  %57 = add nuw nsw i64 %.02033, 1
  %58 = load i64, ptr @k, align 8, !tbaa !8
  %59 = icmp slt i64 %57, %58
  br i1 %59, label %.lr.ph34, label %.preheader26.loopexit, !llvm.loop !14

.preheader:                                       ; preds = %.lr.ph37, %.preheader26
  %60 = load i64, ptr @n, align 8, !tbaa !8
  %61 = icmp sgt i64 %60, 0
  br i1 %61, label %.lr.ph39, label %._crit_edge40

.lr.ph37:                                         ; preds = %.preheader26, %.lr.ph37
  %.01936 = phi i64 [ %77, %.lr.ph37 ], [ 1, %.preheader26 ]
  %62 = add nsw i64 %.01936, -1
  %63 = getelementptr inbounds [262144 x i64], ptr @cnt, i64 0, i64 %62
  %64 = load i64, ptr %63, align 8, !tbaa !8
  %65 = getelementptr inbounds [262144 x i64], ptr @cnt, i64 0, i64 %.01936
  %66 = load i64, ptr %65, align 8, !tbaa !8
  %67 = add nsw i64 %66, %64
  store i64 %67, ptr %65, align 8, !tbaa !8
  %68 = getelementptr inbounds [262144 x %"struct.std::pair.0"], ptr @o, i64 0, i64 %.01936
  %69 = getelementptr inbounds i8, ptr %68, i64 8
  %70 = load i64, ptr %69, align 8, !tbaa !15
  %71 = add nsw i64 %70, -1
  %72 = getelementptr inbounds i8, ptr %68, i64 16
  %73 = load i64, ptr %72, align 8, !tbaa !18
  %74 = load i64, ptr %68, align 8, !tbaa !19
  %75 = mul nsw i64 %74, %67
  %76 = load i64, ptr @n, align 8, !tbaa !8
  call void @_Z6updatexxxxxx(i64 noundef %71, i64 noundef %73, i64 noundef %75, i64 noundef 1, i64 noundef 0, i64 noundef %76)
  %77 = add nuw nsw i64 %.01936, 1
  %78 = load i64, ptr @m, align 8, !tbaa !8
  %.not25.not = icmp slt i64 %.01936, %78
  br i1 %.not25.not, label %.lr.ph37, label %.preheader, !llvm.loop !20

._crit_edge40:                                    ; preds = %.lr.ph39, %.preheader
  %79 = 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.1)
  ret i32 0

.lr.ph39:                                         ; preds = %.preheader, %.lr.ph39
  %80 = phi i64 [ %85, %.lr.ph39 ], [ %60, %.preheader ]
  %.038 = phi i64 [ %84, %.lr.ph39 ], [ 0, %.preheader ]
  %81 = call noundef i64 @_Z5queryxxxx(i64 noundef %.038, i64 noundef 1, i64 noundef 0, i64 noundef %80)
  %82 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %81)
  %83 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %82, ptr noundef nonnull @.str)
  %84 = add nuw nsw i64 %.038, 1
  %85 = load i64, ptr @n, align 8, !tbaa !8
  %86 = icmp slt i64 %84, %85
  br i1 %86, label %.lr.ph39, label %._crit_edge40, !llvm.loop !21
}

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZSt9make_pairIRxSt4pairIxxEES1_INSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS3_INS4_IT0_E4typeEE6__typeEEOS5_OSA_(ptr dead_on_unwind noalias writable sret(%"struct.std::pair.0") align 8, ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0

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

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

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

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress 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 #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 = { 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 = !{!"long long", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = !{!16, !9, i64 8}
!16 = !{!"_ZTSSt4pairIxS_IxxEE", !9, i64 0, !17, i64 8}
!17 = !{!"_ZTSSt4pairIxxE", !9, i64 0, !9, i64 8}
!18 = !{!16, !9, i64 16}
!19 = !{!16, !9, i64 0}
!20 = distinct !{!20, !12}
!21 = distinct !{!21, !12}


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