; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/338 Division 2/Problem D (D)

; 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::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int>>, std::less<int>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int>>, std::less<int>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"class.std::basic_ostream" = type { ptr, %"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 }
%"struct.std::_Rb_tree_iterator" = type { ptr }
%"struct.std::pair" = type { i32, i32 }

@p = external dso_local global %"class.std::map", align 8
@MOD = external dso_local global i64, align 8
@ans = external dso_local global i64, align 8
@pro = external dso_local global i64, align 8
@m = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z4fastxx(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 norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %6 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %7 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %8 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %9 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %10 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %11 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %12 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %13 = alloca i32, align 4
  %14 = alloca i64, align 8
  %15 = alloca i32, align 4
  %16 = alloca %"struct.std::_Rb_tree_iterator", align 8
  store i32 0, ptr %1, align 4
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %28, %0
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = load i32, ptr @m, align 4, !tbaa !5
  %21 = icmp slt i32 %19, %20
  br i1 %21, label %23, label %22

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

23:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  %24 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %3)
  %25 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @p, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr %25, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %28

28:                                               ; preds = %23
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %2, align 4, !tbaa !5
  br label %18, !llvm.loop !9

31:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 1, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %32 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @p) #6
  %33 = getelementptr inbounds %"struct.std::_Rb_tree_iterator", ptr %5, i32 0, i32 0
  store ptr %32, ptr %33, align 8
  br label %34

34:                                               ; preds = %72, %31
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %35 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @p) #6
  %36 = getelementptr inbounds %"struct.std::_Rb_tree_iterator", ptr %6, i32 0, i32 0
  store ptr %35, ptr %36, align 8
  %37 = call noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKiiEES5_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  br i1 %37, label %39, label %38

38:                                               ; preds = %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  br label %75

39:                                               ; preds = %34
  %40 = load i32, ptr %4, align 4, !tbaa !5
  %41 = icmp sgt i32 %40, 0
  br i1 %41, label %42, label %59

42:                                               ; preds = %39
  %43 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKiiEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %5) #6
  %44 = getelementptr inbounds %"struct.std::pair", ptr %43, i32 0, i32 1
  %45 = load i32, ptr %44, align 4, !tbaa !11
  %46 = srem i32 %45, 2
  %47 = icmp eq i32 %46, 1
  br i1 %47, label %48, label %59

48:                                               ; preds = %42
  %49 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKiiEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %5) #6
  %50 = getelementptr inbounds %"struct.std::pair", ptr %49, i32 0, i32 1
  %51 = load i32, ptr %50, align 4, !tbaa !11
  %52 = sext i32 %51 to i64
  %53 = add nsw i64 1, %52
  %54 = sdiv i64 %53, 2
  %55 = load i64, ptr @pro, align 8, !tbaa !13
  %56 = mul nsw i64 %55, %54
  store i64 %56, ptr @pro, align 8, !tbaa !13
  %57 = load i32, ptr %4, align 4, !tbaa !5
  %58 = add nsw i32 %57, -1
  store i32 %58, ptr %4, align 4, !tbaa !5
  br label %67

59:                                               ; preds = %42, %39
  %60 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKiiEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %5) #6
  %61 = getelementptr inbounds %"struct.std::pair", ptr %60, i32 0, i32 1
  %62 = load i32, ptr %61, align 4, !tbaa !11
  %63 = sext i32 %62 to i64
  %64 = add nsw i64 1, %63
  %65 = load i64, ptr @pro, align 8, !tbaa !13
  %66 = mul nsw i64 %65, %64
  store i64 %66, ptr @pro, align 8, !tbaa !13
  br label %67

67:                                               ; preds = %59, %48
  %68 = load i64, ptr @MOD, align 8, !tbaa !13
  %69 = sub nsw i64 %68, 1
  %70 = load i64, ptr @pro, align 8, !tbaa !13
  %71 = srem i64 %70, %69
  store i64 %71, ptr @pro, align 8, !tbaa !13
  br label %72

72:                                               ; preds = %67
  %73 = call ptr @_ZNSt17_Rb_tree_iteratorISt4pairIKiiEEppEi(ptr noundef nonnull align 8 dereferenceable(8) %5, i32 noundef 0) #6
  %74 = getelementptr inbounds %"struct.std::_Rb_tree_iterator", ptr %7, i32 0, i32 0
  store ptr %73, ptr %74, align 8
  br label %34, !llvm.loop !15

75:                                               ; preds = %38
  %76 = load i32, ptr %4, align 4, !tbaa !5
  %77 = icmp sgt i32 %76, 0
  br i1 %77, label %78, label %95

78:                                               ; preds = %75
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %79 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @p) #6
  %80 = getelementptr inbounds %"struct.std::_Rb_tree_iterator", ptr %8, i32 0, i32 0
  store ptr %79, ptr %80, align 8
  br label %81

81:                                               ; preds = %91, %78
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %82 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @p) #6
  %83 = getelementptr inbounds %"struct.std::_Rb_tree_iterator", ptr %9, i32 0, i32 0
  store ptr %82, ptr %83, align 8
  %84 = call noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKiiEES5_(ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef nonnull align 8 dereferenceable(8) %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  br i1 %84, label %86, label %85

85:                                               ; preds = %81
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %94

86:                                               ; preds = %81
  %87 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKiiEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %8) #6
  %88 = getelementptr inbounds %"struct.std::pair", ptr %87, i32 0, i32 1
  %89 = load i32, ptr %88, align 4, !tbaa !11
  %90 = sdiv i32 %89, 2
  store i32 %90, ptr %88, align 4, !tbaa !11
  br label %91

91:                                               ; preds = %86
  %92 = call ptr @_ZNSt17_Rb_tree_iteratorISt4pairIKiiEEppEi(ptr noundef nonnull align 8 dereferenceable(8) %8, i32 noundef 0) #6
  %93 = getelementptr inbounds %"struct.std::_Rb_tree_iterator", ptr %10, i32 0, i32 0
  store ptr %92, ptr %93, align 8
  br label %81, !llvm.loop !16

94:                                               ; preds = %85
  br label %95

95:                                               ; preds = %94, %75
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %96 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @p) #6
  %97 = getelementptr inbounds %"struct.std::_Rb_tree_iterator", ptr %11, i32 0, i32 0
  store ptr %96, ptr %97, align 8
  br label %98

98:                                               ; preds = %127, %95
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %99 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @p) #6
  %100 = getelementptr inbounds %"struct.std::_Rb_tree_iterator", ptr %12, i32 0, i32 0
  store ptr %99, ptr %100, align 8
  %101 = call noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKiiEES5_(ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef nonnull align 8 dereferenceable(8) %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  br i1 %101, label %103, label %102

102:                                              ; preds = %98
  store i32 11, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  br label %130

103:                                              ; preds = %98
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %104 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKiiEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %11) #6
  %105 = getelementptr inbounds %"struct.std::pair", ptr %104, i32 0, i32 0
  %106 = load i32, ptr %105, align 4, !tbaa !17
  %107 = sext i32 %106 to i64
  store i64 %107, ptr %14, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  store i32 0, ptr %15, align 4, !tbaa !5
  br label %108

108:                                              ; preds = %123, %103
  %109 = load i32, ptr %15, align 4, !tbaa !5
  %110 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKiiEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %11) #6
  %111 = getelementptr inbounds %"struct.std::pair", ptr %110, i32 0, i32 1
  %112 = load i32, ptr %111, align 4, !tbaa !11
  %113 = icmp slt i32 %109, %112
  br i1 %113, label %115, label %114

114:                                              ; preds = %108
  store i32 14, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  br label %126

115:                                              ; preds = %108
  %116 = load i64, ptr @ans, align 8, !tbaa !13
  %117 = load i64, ptr %14, align 8, !tbaa !13
  %118 = load i64, ptr @pro, align 8, !tbaa !13
  %119 = call noundef i64 @_Z4fastxx(i64 noundef %117, i64 noundef %118)
  %120 = mul nsw i64 %116, %119
  %121 = load i64, ptr @MOD, align 8, !tbaa !13
  %122 = srem i64 %120, %121
  store i64 %122, ptr @ans, align 8, !tbaa !13
  br label %123

123:                                              ; preds = %115
  %124 = load i32, ptr %15, align 4, !tbaa !5
  %125 = add nsw i32 %124, 1
  store i32 %125, ptr %15, align 4, !tbaa !5
  br label %108, !llvm.loop !18

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

127:                                              ; preds = %126
  %128 = call ptr @_ZNSt17_Rb_tree_iteratorISt4pairIKiiEEppEi(ptr noundef nonnull align 8 dereferenceable(8) %11, i32 noundef 0) #6
  %129 = getelementptr inbounds %"struct.std::_Rb_tree_iterator", ptr %16, i32 0, i32 0
  store ptr %128, ptr %129, align 8
  br label %98, !llvm.loop !19

130:                                              ; preds = %102
  %131 = load i64, ptr @ans, align 8, !tbaa !13
  %132 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %131)
  %133 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %132, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  %134 = load i32, ptr %1, align 4
  ret i32 %134
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #3

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

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

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

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

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

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

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

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


; 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::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int>>, std::less<int>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int>>, std::less<int>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"class.std::basic_ostream" = type { ptr, %"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 }
%"struct.std::_Rb_tree_iterator" = type { ptr }

@p = external dso_local global %"class.std::map", align 8
@MOD = external dso_local local_unnamed_addr global i64, align 8
@ans = external dso_local local_unnamed_addr global i64, align 8
@pro = external dso_local local_unnamed_addr global i64, align 8
@m = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z4fastxx(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 norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i32, align 4
  %2 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %3 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %4 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %5 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %6 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %7 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %8 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @m)
  %9 = load i32, ptr @m, align 4, !tbaa !5
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %0
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #6
  %11 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @p) #6
  store ptr %11, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  %12 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @p) #6
  store ptr %12, ptr %3, align 8
  %13 = call noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKiiEES5_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  br i1 %13, label %.lr.ph16, label %._crit_edge17.thread

._crit_edge17.thread:                             ; preds = %._crit_edge
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #6
  br label %51

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.01113 = phi i32 [ %18, %.lr.ph ], [ 0, %0 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %15 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @p, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %16 = load i32, ptr %15, align 4, !tbaa !5
  %17 = add nsw i32 %16, 1
  store i32 %17, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  %18 = add nuw nsw i32 %.01113, 1
  %19 = load i32, ptr @m, align 4, !tbaa !5
  %20 = icmp slt i32 %18, %19
  br i1 %20, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge17:                                    ; preds = %42
  %21 = icmp sgt i32 %.1, 0
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #6
  br i1 %21, label %51, label %62

.lr.ph16:                                         ; preds = %._crit_edge, %42
  %.01214 = phi i32 [ %.1, %42 ], [ 1, %._crit_edge ]
  %22 = icmp sgt i32 %.01214, 0
  br i1 %22, label %23, label %36

23:                                               ; preds = %.lr.ph16
  %24 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKiiEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %2) #6
  %25 = getelementptr inbounds i8, ptr %24, i64 4
  %26 = load i32, ptr %25, align 4, !tbaa !11
  %27 = and i32 %26, -2147483647
  %28 = icmp eq i32 %27, 1
  br i1 %28, label %29, label %36

29:                                               ; preds = %23
  %30 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKiiEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %2) #6
  %31 = getelementptr inbounds i8, ptr %30, i64 4
  %32 = load i32, ptr %31, align 4, !tbaa !11
  %33 = sext i32 %32 to i64
  %34 = add nsw i64 %33, 1
  %35 = sdiv i64 %34, 2
  br label %42

36:                                               ; preds = %23, %.lr.ph16
  %37 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKiiEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %2) #6
  %38 = getelementptr inbounds i8, ptr %37, i64 4
  %39 = load i32, ptr %38, align 4, !tbaa !11
  %40 = sext i32 %39 to i64
  %41 = add nsw i64 %40, 1
  br label %42

42:                                               ; preds = %36, %29
  %.sink = phi i64 [ %41, %36 ], [ %35, %29 ]
  %.1 = phi i32 [ %.01214, %36 ], [ 0, %29 ]
  %43 = load i64, ptr @pro, align 8, !tbaa !13
  %44 = mul nsw i64 %.sink, %43
  %45 = load i64, ptr @MOD, align 8, !tbaa !13
  %46 = add nsw i64 %45, -1
  %47 = srem i64 %44, %46
  store i64 %47, ptr @pro, align 8, !tbaa !13
  %48 = call ptr @_ZNSt17_Rb_tree_iteratorISt4pairIKiiEEppEi(ptr noundef nonnull align 8 dereferenceable(8) %2, i32 noundef 0) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  %49 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @p) #6
  store ptr %49, ptr %3, align 8
  %50 = call noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKiiEES5_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  br i1 %50, label %.lr.ph16, label %._crit_edge17, !llvm.loop !15

51:                                               ; preds = %._crit_edge17.thread, %._crit_edge17
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  %52 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @p) #6
  store ptr %52, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  %53 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @p) #6
  store ptr %53, ptr %5, align 8
  %54 = call noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKiiEES5_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  br i1 %54, label %.lr.ph19, label %._crit_edge20

._crit_edge20:                                    ; preds = %.lr.ph19, %51
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  br label %62

.lr.ph19:                                         ; preds = %51, %.lr.ph19
  %55 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKiiEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %4) #6
  %56 = getelementptr inbounds i8, ptr %55, i64 4
  %57 = load i32, ptr %56, align 4, !tbaa !11
  %58 = sdiv i32 %57, 2
  store i32 %58, ptr %56, align 4, !tbaa !11
  %59 = call ptr @_ZNSt17_Rb_tree_iteratorISt4pairIKiiEEppEi(ptr noundef nonnull align 8 dereferenceable(8) %4, i32 noundef 0) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  %60 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @p) #6
  store ptr %60, ptr %5, align 8
  %61 = call noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKiiEES5_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  br i1 %61, label %.lr.ph19, label %._crit_edge20, !llvm.loop !16

62:                                               ; preds = %._crit_edge20, %._crit_edge17
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #6
  %63 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @p) #6
  store ptr %63, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #6
  %64 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @p) #6
  store ptr %64, ptr %7, align 8
  %65 = call noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKiiEES5_(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(8) %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #6
  br i1 %65, label %.lr.ph26, label %._crit_edge27

._crit_edge27:                                    ; preds = %._crit_edge24, %62
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #6
  %66 = load i64, ptr @ans, align 8, !tbaa !13
  %67 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %66)
  %68 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %67, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0

.lr.ph26:                                         ; preds = %62, %._crit_edge24
  %69 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKiiEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %6) #6
  %70 = load i32, ptr %69, align 4, !tbaa !17
  %71 = sext i32 %70 to i64
  %72 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKiiEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %6) #6
  %73 = getelementptr inbounds i8, ptr %72, i64 4
  %74 = load i32, ptr %73, align 4, !tbaa !11
  %75 = icmp sgt i32 %74, 0
  br i1 %75, label %.lr.ph23, label %._crit_edge24

._crit_edge24:                                    ; preds = %.lr.ph23, %.lr.ph26
  %76 = call ptr @_ZNSt17_Rb_tree_iteratorISt4pairIKiiEEppEi(ptr noundef nonnull align 8 dereferenceable(8) %6, i32 noundef 0) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #6
  %77 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @p) #6
  store ptr %77, ptr %7, align 8
  %78 = call noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKiiEES5_(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(8) %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #6
  br i1 %78, label %.lr.ph26, label %._crit_edge27, !llvm.loop !18

.lr.ph23:                                         ; preds = %.lr.ph26, %.lr.ph23
  %.021 = phi i32 [ %85, %.lr.ph23 ], [ 0, %.lr.ph26 ]
  %79 = load i64, ptr @ans, align 8, !tbaa !13
  %80 = load i64, ptr @pro, align 8, !tbaa !13
  %81 = call noundef i64 @_Z4fastxx(i64 noundef %71, i64 noundef %80)
  %82 = mul nsw i64 %81, %79
  %83 = load i64, ptr @MOD, align 8, !tbaa !13
  %84 = srem i64 %82, %83
  store i64 %84, ptr @ans, align 8, !tbaa !13
  %85 = add nuw nsw i32 %.021, 1
  %86 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKiiEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %6) #6
  %87 = getelementptr inbounds i8, ptr %86, i64 4
  %88 = load i32, ptr %87, align 4, !tbaa !11
  %89 = icmp slt i32 %85, %88
  br i1 %89, label %.lr.ph23, label %._crit_edge24, !llvm.loop !19
}

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKiiEES5_(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 ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE3endEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #0 align 2

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

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

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

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


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