; LLVM IR from VastoLorde95/Competitive-Programming :: CodeChef/SHORT/COOK66/Problem B (B)

; 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::priority_queue" = type <{ %"class.std::vector", [8 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::_Rb_tree_iterator" = type { ptr }
%"struct.std::pair" = type { i32, i32 }

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@a = external dso_local global [50010 x i32], align 16
@m = external dso_local global %"class.std::map", align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca %"class.std::priority_queue", align 8
  %5 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %6 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  br label %13

13:                                               ; preds = %113, %0
  %14 = load i32, ptr @t, align 4, !tbaa !5
  %15 = add nsw i32 %14, -1
  store i32 %15, ptr @t, align 4, !tbaa !5
  %16 = icmp ne i32 %14, 0
  br i1 %16, label %17, label %115

17:                                               ; preds = %13
  %18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE5clearEv(ptr noundef nonnull align 8 dereferenceable(48) @m) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %35, %17
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = load i32, ptr @n, align 4, !tbaa !5
  %22 = icmp slt i32 %20, %21
  br i1 %22, label %24, label %23

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

24:                                               ; preds = %19
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [50010 x i32], ptr @a, i64 0, i64 %26
  %28 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %27)
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [50010 x i32], ptr @a, i64 0, i64 %30
  %32 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @m, ptr noundef nonnull align 4 dereferenceable(4) %31)
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %32, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %24
  %36 = load i32, ptr %2, align 4, !tbaa !5
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %2, align 4, !tbaa !5
  br label %19, !llvm.loop !9

38:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 32, ptr %4) #6
  call void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEEC2IS2_vEEv(ptr noundef nonnull align 8 dereferenceable(25) %4)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %39 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @m) #6
  %40 = getelementptr inbounds %"struct.std::_Rb_tree_iterator", ptr %5, i32 0, i32 0
  store ptr %39, ptr %40, align 8
  br label %41

41:                                               ; preds = %50, %38
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %42 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @m) #6
  %43 = getelementptr inbounds %"struct.std::_Rb_tree_iterator", ptr %6, i32 0, i32 0
  store ptr %42, ptr %43, align 8
  %44 = 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 %44, label %46, label %45

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

46:                                               ; preds = %41
  %47 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKiiEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %5) #6
  %48 = getelementptr inbounds %"struct.std::pair", ptr %47, i32 0, i32 1
  invoke void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE4pushERKi(ptr noundef nonnull align 8 dereferenceable(25) %4, ptr noundef nonnull align 4 dereferenceable(4) %48)
          to label %49 unwind label %53

49:                                               ; preds = %46
  br label %50

50:                                               ; preds = %49
  %51 = call ptr @_ZNSt17_Rb_tree_iteratorISt4pairIKiiEEppEi(ptr noundef nonnull align 8 dereferenceable(8) %5, i32 noundef 0) #6
  %52 = getelementptr inbounds %"struct.std::_Rb_tree_iterator", ptr %9, i32 0, i32 0
  store ptr %51, ptr %52, align 8
  br label %41, !llvm.loop !11

53:                                               ; preds = %46
  %54 = landingpad { ptr, i32 }
          cleanup
  %55 = extractvalue { ptr, i32 } %54, 0
  store ptr %55, ptr %7, align 8
  %56 = extractvalue { ptr, i32 } %54, 1
  store i32 %56, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  br label %114

57:                                               ; preds = %45
  br label %58

58:                                               ; preds = %98, %57
  %59 = invoke noundef i64 @_ZNKSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(25) %4)
          to label %60 unwind label %81

60:                                               ; preds = %58
  %61 = icmp ugt i64 %59, 1
  br i1 %61, label %62, label %100

62:                                               ; preds = %60
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %63 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE3topEv(ptr noundef nonnull align 8 dereferenceable(25) %4)
          to label %64 unwind label %85

64:                                               ; preds = %62
  %65 = load i32, ptr %63, align 4, !tbaa !5
  store i32 %65, ptr %10, align 4, !tbaa !5
  invoke void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE3popEv(ptr noundef nonnull align 8 dereferenceable(25) %4)
          to label %66 unwind label %85

66:                                               ; preds = %64
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %67 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE3topEv(ptr noundef nonnull align 8 dereferenceable(25) %4)
          to label %68 unwind label %89

68:                                               ; preds = %66
  %69 = load i32, ptr %67, align 4, !tbaa !5
  store i32 %69, ptr %11, align 4, !tbaa !5
  invoke void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE3popEv(ptr noundef nonnull align 8 dereferenceable(25) %4)
          to label %70 unwind label %89

70:                                               ; preds = %68
  %71 = load i32, ptr %10, align 4, !tbaa !5
  %72 = add nsw i32 %71, -1
  store i32 %72, ptr %10, align 4, !tbaa !5
  %73 = load i32, ptr %11, align 4, !tbaa !5
  %74 = add nsw i32 %73, -1
  store i32 %74, ptr %11, align 4, !tbaa !5
  %75 = load i32, ptr %3, align 4, !tbaa !5
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %3, align 4, !tbaa !5
  %77 = load i32, ptr %10, align 4, !tbaa !5
  %78 = icmp sgt i32 %77, 0
  br i1 %78, label %79, label %93

79:                                               ; preds = %70
  invoke void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE4pushERKi(ptr noundef nonnull align 8 dereferenceable(25) %4, ptr noundef nonnull align 4 dereferenceable(4) %10)
          to label %80 unwind label %89

80:                                               ; preds = %79
  br label %93

81:                                               ; preds = %110, %104, %100, %58
  %82 = landingpad { ptr, i32 }
          cleanup
  %83 = extractvalue { ptr, i32 } %82, 0
  store ptr %83, ptr %7, align 8
  %84 = extractvalue { ptr, i32 } %82, 1
  store i32 %84, ptr %8, align 4
  br label %114

85:                                               ; preds = %64, %62
  %86 = landingpad { ptr, i32 }
          cleanup
  %87 = extractvalue { ptr, i32 } %86, 0
  store ptr %87, ptr %7, align 8
  %88 = extractvalue { ptr, i32 } %86, 1
  store i32 %88, ptr %8, align 4
  br label %99

89:                                               ; preds = %96, %79, %68, %66
  %90 = landingpad { ptr, i32 }
          cleanup
  %91 = extractvalue { ptr, i32 } %90, 0
  store ptr %91, ptr %7, align 8
  %92 = extractvalue { ptr, i32 } %90, 1
  store i32 %92, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %99

93:                                               ; preds = %80, %70
  %94 = load i32, ptr %11, align 4, !tbaa !5
  %95 = icmp sgt i32 %94, 0
  br i1 %95, label %96, label %98

96:                                               ; preds = %93
  invoke void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE4pushERKi(ptr noundef nonnull align 8 dereferenceable(25) %4, ptr noundef nonnull align 4 dereferenceable(4) %11)
          to label %97 unwind label %89

97:                                               ; preds = %96
  br label %98

98:                                               ; preds = %97, %93
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %58, !llvm.loop !12

99:                                               ; preds = %89, %85
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %114

100:                                              ; preds = %60
  %101 = invoke noundef i64 @_ZNKSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(25) %4)
          to label %102 unwind label %81

102:                                              ; preds = %100
  %103 = icmp ugt i64 %101, 0
  br i1 %103, label %104, label %110

104:                                              ; preds = %102
  %105 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE3topEv(ptr noundef nonnull align 8 dereferenceable(25) %4)
          to label %106 unwind label %81

106:                                              ; preds = %104
  %107 = load i32, ptr %105, align 4, !tbaa !5
  %108 = load i32, ptr %3, align 4, !tbaa !5
  %109 = add nsw i32 %108, %107
  store i32 %109, ptr %3, align 4, !tbaa !5
  br label %110

110:                                              ; preds = %106, %102
  %111 = load i32, ptr %3, align 4, !tbaa !5
  %112 = invoke i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %111)
          to label %113 unwind label %81

113:                                              ; preds = %110
  call void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEED2Ev(ptr noundef nonnull align 8 dereferenceable(25) %4) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %13, !llvm.loop !13

114:                                              ; preds = %99, %81, %53
  call void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEED2Ev(ptr noundef nonnull align 8 dereferenceable(25) %4) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %116

115:                                              ; preds = %13
  ret i32 0

116:                                              ; preds = %114
  %117 = load ptr, ptr %7, align 8
  %118 = load i32, ptr %8, align 4
  %119 = insertvalue { ptr, i32 } poison, ptr %117, 0
  %120 = insertvalue { ptr, i32 } %119, i32 %118, 1
  resume { ptr, i32 } %120
}

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEEC2IS2_vEEv(ptr noundef nonnull align 8 dereferenceable(25)) unnamed_addr #2 align 2

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

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

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

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

declare i32 @__gxx_personality_v0(...)

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE3popEv(ptr noundef nonnull align 8 dereferenceable(25)) #4 align 2

declare i32 @printf(ptr noundef, ...) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEED2Ev(ptr noundef nonnull align 8 dereferenceable(25)) unnamed_addr #5 align 2

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 = { 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 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !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::priority_queue" = type <{ %"class.std::vector", [8 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::_Rb_tree_iterator" = type { ptr }

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@a = external dso_local global [50010 x i32], align 16
@m = external dso_local global %"class.std::map", align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca %"class.std::priority_queue", align 8
  %2 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %3 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @t)
  %7 = load i32, ptr @t, align 4, !tbaa !5
  %8 = add nsw i32 %7, -1
  store i32 %8, ptr @t, align 4, !tbaa !5
  %.not27 = icmp eq i32 %7, 0
  br i1 %.not27, label %._crit_edge30, label %.lr.ph29

.lr.ph29:                                         ; preds = %0, %63
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  call void @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE5clearEv(ptr noundef nonnull align 8 dereferenceable(48) @m) #6
  %10 = load i32, ptr @n, align 4, !tbaa !5
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph29
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %1) #6
  call void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEEC2IS2_vEEv(ptr noundef nonnull align 8 dereferenceable(25) %1)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #6
  %12 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @m) #6
  store ptr %12, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  %13 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @m) #6
  store ptr %13, ptr %3, align 8
  %14 = 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 %14, label %.lr.ph21, label %._crit_edge22

.lr.ph:                                           ; preds = %.lr.ph29, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.lr.ph29 ]
  %15 = getelementptr inbounds [50010 x i32], ptr @a, i64 0, i64 %indvars.iv
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %15)
  %17 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @m, ptr noundef nonnull align 4 dereferenceable(4) %15)
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = add nsw i32 %18, 1
  store i32 %19, ptr %17, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %20 = load i32, ptr @n, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = icmp slt i64 %indvars.iv.next, %21
  br i1 %22, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge22:                                    ; preds = %27, %._crit_edge
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #6
  %23 = call noundef i64 @_ZNKSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(25) %1)
  %24 = icmp ugt i64 %23, 1
  br i1 %24, label %.lr.ph25, label %._crit_edge26

.lr.ph21:                                         ; preds = %._crit_edge, %27
  %25 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKiiEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %2) #6
  %26 = getelementptr inbounds i8, ptr %25, i64 4
  invoke void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE4pushERKi(ptr noundef nonnull align 8 dereferenceable(25) %1, ptr noundef nonnull align 4 dereferenceable(4) %26)
          to label %27 unwind label %31

27:                                               ; preds = %.lr.ph21
  %28 = 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
  %29 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @m) #6
  store ptr %29, ptr %3, align 8
  %30 = 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 %30, label %.lr.ph21, label %._crit_edge22, !llvm.loop !11

31:                                               ; preds = %.lr.ph21
  %32 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #6
  br label %67

.lr.ph25:                                         ; preds = %._crit_edge22, %54
  %.01123 = phi i32 [ %43, %54 ], [ 0, %._crit_edge22 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #6
  %33 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE3topEv(ptr noundef nonnull align 8 dereferenceable(25) %1)
  %34 = load i32, ptr %33, align 4, !tbaa !5
  store i32 %34, ptr %4, align 4, !tbaa !5
  invoke void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE3popEv(ptr noundef nonnull align 8 dereferenceable(25) %1)
          to label %35 unwind label %46

35:                                               ; preds = %.lr.ph25
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #6
  %36 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE3topEv(ptr noundef nonnull align 8 dereferenceable(25) %1)
  %37 = load i32, ptr %36, align 4, !tbaa !5
  store i32 %37, ptr %5, align 4, !tbaa !5
  invoke void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE3popEv(ptr noundef nonnull align 8 dereferenceable(25) %1)
          to label %38 unwind label %48

38:                                               ; preds = %35
  %39 = load i32, ptr %4, align 4, !tbaa !5
  %40 = add nsw i32 %39, -1
  store i32 %40, ptr %4, align 4, !tbaa !5
  %41 = load i32, ptr %5, align 4, !tbaa !5
  %42 = add nsw i32 %41, -1
  store i32 %42, ptr %5, align 4, !tbaa !5
  %43 = add nuw nsw i32 %.01123, 1
  %44 = icmp sgt i32 %39, 1
  br i1 %44, label %45, label %50

45:                                               ; preds = %38
  invoke void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE4pushERKi(ptr noundef nonnull align 8 dereferenceable(25) %1, ptr noundef nonnull align 4 dereferenceable(4) %4)
          to label %thread-pre-split unwind label %48

46:                                               ; preds = %.lr.ph25
  %47 = landingpad { ptr, i32 }
          cleanup
  br label %57

48:                                               ; preds = %53, %45, %35
  %49 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #6
  br label %57

thread-pre-split:                                 ; preds = %45
  %.pr = load i32, ptr %5, align 4, !tbaa !5
  br label %50

50:                                               ; preds = %thread-pre-split, %38
  %51 = phi i32 [ %.pr, %thread-pre-split ], [ %42, %38 ]
  %52 = icmp sgt i32 %51, 0
  br i1 %52, label %53, label %54

53:                                               ; preds = %50
  invoke void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE4pushERKi(ptr noundef nonnull align 8 dereferenceable(25) %1, ptr noundef nonnull align 4 dereferenceable(4) %5)
          to label %54 unwind label %48

54:                                               ; preds = %53, %50
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #6
  %55 = call noundef i64 @_ZNKSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(25) %1)
  %56 = icmp ugt i64 %55, 1
  br i1 %56, label %.lr.ph25, label %._crit_edge26, !llvm.loop !12

57:                                               ; preds = %48, %46
  %.pn = phi { ptr, i32 } [ %49, %48 ], [ %47, %46 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #6
  br label %67

._crit_edge26:                                    ; preds = %54, %._crit_edge22
  %.011.lcssa = phi i32 [ 0, %._crit_edge22 ], [ %43, %54 ]
  %58 = call noundef i64 @_ZNKSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(25) %1)
  %.not13 = icmp eq i64 %58, 0
  br i1 %.not13, label %63, label %59

59:                                               ; preds = %._crit_edge26
  %60 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE3topEv(ptr noundef nonnull align 8 dereferenceable(25) %1)
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = add nsw i32 %61, %.011.lcssa
  br label %63

63:                                               ; preds = %59, %._crit_edge26
  %.112 = phi i32 [ %62, %59 ], [ %.011.lcssa, %._crit_edge26 ]
  %64 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %.112)
  call void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEED2Ev(ptr noundef nonnull align 8 dereferenceable(25) %1) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %1) #6
  %65 = load i32, ptr @t, align 4, !tbaa !5
  %66 = add nsw i32 %65, -1
  store i32 %66, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %65, 0
  br i1 %.not, label %._crit_edge30, label %.lr.ph29, !llvm.loop !13

67:                                               ; preds = %57, %31
  %.pn15 = phi { ptr, i32 } [ %32, %31 ], [ %.pn, %57 ]
  call void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEED2Ev(ptr noundef nonnull align 8 dereferenceable(25) %1) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %1) #6
  resume { ptr, i32 } %.pn15

._crit_edge30:                                    ; preds = %63, %0
  ret i32 0
}

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEEC2IS2_vEEv(ptr noundef nonnull align 8 dereferenceable(25)) unnamed_addr #2 align 2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE4pushERKi(ptr noundef nonnull align 8 dereferenceable(25), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #4 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 #2 align 2

declare i32 @__gxx_personality_v0(...)

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEE3popEv(ptr noundef nonnull align 8 dereferenceable(25)) local_unnamed_addr #4 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZNSt14priority_queueIiSt6vectorIiSaIiEESt4lessIiEED2Ev(ptr noundef nonnull align 8 dereferenceable(25)) unnamed_addr #5 align 2

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 = { 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 #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 = { 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 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}


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