; LLVM IR from eyangch/competitive-programming :: Codeforces/1712 (c)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.std::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<long long, std::pair<const long long, long long>, std::_Select1st<std::pair<const long long, long long>>, std::less<long long>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<long long, std::pair<const long long, long long>, std::_Select1st<std::pair<const long long, long long>>, std::less<long long>>::_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_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" }
%"class.std::set" = type { %"class.std::_Rb_tree.0" }
%"class.std::_Rb_tree.0" = type { %"struct.std::_Rb_tree<long long, long long, std::_Identity<long long>, std::less<long long>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<long long, long long, std::_Identity<long long>, std::less<long long>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }

@T = external dso_local global i64, align 8
@N = external dso_local global i64, align 8
@A = external dso_local global [100000 x i64], align 16
@mxc = external dso_local global [100001 x i64], align 16
@Z = external dso_local global [100001 x i8], align 16
@M = external dso_local global %"class.std::map", align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca %"class.std::set", align 8
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  %12 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  %13 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %14 = getelementptr i8, ptr %13, i64 -24
  %15 = load i64, ptr %14, align 8
  %16 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %15
  %17 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %16, ptr noundef null)
  %18 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %19 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @T)
  br label %20

20:                                               ; preds = %135, %0
  %21 = load i64, ptr @T, align 8, !tbaa !8
  %22 = add nsw i64 %21, -1
  store i64 %22, ptr @T, align 8, !tbaa !8
  %23 = icmp ne i64 %21, 0
  br i1 %23, label %24, label %142

24:                                               ; preds = %20
  %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)
  call void @_ZNSt3mapIxxSt4lessIxESaISt4pairIKxxEEE5clearEv(ptr noundef nonnull align 8 dereferenceable(48) @M) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #7
  store i64 0, ptr %2, align 8, !tbaa !8
  br label %26

26:                                               ; preds = %36, %24
  %27 = load i64, ptr %2, align 8, !tbaa !8
  %28 = load i64, ptr @N, align 8, !tbaa !8
  %29 = icmp sle i64 %27, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #7
  br label %39

31:                                               ; preds = %26
  %32 = load i64, ptr %2, align 8, !tbaa !8
  %33 = getelementptr inbounds [100001 x i8], ptr @Z, i64 0, i64 %32
  store i8 0, ptr %33, align 1, !tbaa !11
  %34 = load i64, ptr %2, align 8, !tbaa !8
  %35 = getelementptr inbounds [100001 x i64], ptr @mxc, i64 0, i64 %34
  store i64 -1, ptr %35, align 8, !tbaa !8
  br label %36

36:                                               ; preds = %31
  %37 = load i64, ptr %2, align 8, !tbaa !8
  %38 = add nsw i64 %37, 1
  store i64 %38, ptr %2, align 8, !tbaa !8
  br label %26, !llvm.loop !13

39:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 48, ptr %3) #7
  call void @_ZNSt3setIxSt4lessIxESaIxEEC2Ev(ptr noundef nonnull align 8 dereferenceable(48) %3) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #7
  store i64 0, ptr %4, align 8, !tbaa !8
  br label %40

40:                                               ; preds = %55, %39
  %41 = load i64, ptr %4, align 8, !tbaa !8
  %42 = load i64, ptr @N, align 8, !tbaa !8
  %43 = icmp slt i64 %41, %42
  br i1 %43, label %45, label %44

44:                                               ; preds = %40
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #7
  br label %62

45:                                               ; preds = %40
  %46 = load i64, ptr %4, align 8, !tbaa !8
  %47 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %46
  %48 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %47)
          to label %49 unwind label %58

49:                                               ; preds = %45
  %50 = load i64, ptr %4, align 8, !tbaa !8
  %51 = load i64, ptr %4, align 8, !tbaa !8
  %52 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %51
  %53 = load i64, ptr %52, align 8, !tbaa !8
  %54 = getelementptr inbounds [100001 x i64], ptr @mxc, i64 0, i64 %53
  store i64 %50, ptr %54, align 8, !tbaa !8
  br label %55

55:                                               ; preds = %49
  %56 = load i64, ptr %4, align 8, !tbaa !8
  %57 = add nsw i64 %56, 1
  store i64 %57, ptr %4, align 8, !tbaa !8
  br label %40, !llvm.loop !15

58:                                               ; preds = %45
  %59 = landingpad { ptr, i32 }
          cleanup
  %60 = extractvalue { ptr, i32 } %59, 0
  store ptr %60, ptr %5, align 8
  %61 = extractvalue { ptr, i32 } %59, 1
  store i32 %61, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #7
  br label %141

62:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  store i64 0, ptr %7, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  store i64 -1, ptr %8, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %63 = load i64, ptr @N, align 8, !tbaa !8
  %64 = sub nsw i64 %63, 1
  %65 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %64
  %66 = load i64, ptr %65, align 8, !tbaa !8
  store i64 %66, ptr %9, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  %67 = load i64, ptr @N, align 8, !tbaa !8
  %68 = sub nsw i64 %67, 2
  store i64 %68, ptr %10, align 8, !tbaa !8
  br label %69

69:                                               ; preds = %85, %62
  %70 = load i64, ptr %10, align 8, !tbaa !8
  %71 = icmp sge i64 %70, 0
  br i1 %71, label %73, label %72

72:                                               ; preds = %69
  store i32 10, ptr %11, align 4
  br label %88

73:                                               ; preds = %69
  %74 = load i64, ptr %10, align 8, !tbaa !8
  %75 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %74
  %76 = load i64, ptr %75, align 8, !tbaa !8
  %77 = load i64, ptr %9, align 8, !tbaa !8
  %78 = icmp sgt i64 %76, %77
  br i1 %78, label %79, label %81

79:                                               ; preds = %73
  %80 = load i64, ptr %10, align 8, !tbaa !8
  store i64 %80, ptr %8, align 8, !tbaa !8
  store i32 10, ptr %11, align 4
  br label %88

81:                                               ; preds = %73
  %82 = load i64, ptr %10, align 8, !tbaa !8
  %83 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %82
  %84 = load i64, ptr %83, align 8, !tbaa !8
  store i64 %84, ptr %9, align 8, !tbaa !8
  br label %85

85:                                               ; preds = %81
  %86 = load i64, ptr %10, align 8, !tbaa !8
  %87 = add nsw i64 %86, -1
  store i64 %87, ptr %10, align 8, !tbaa !8
  br label %69, !llvm.loop !16

88:                                               ; preds = %79, %72
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  br label %89

89:                                               ; preds = %88
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  store i64 0, ptr %12, align 8, !tbaa !8
  br label %90

90:                                               ; preds = %122, %89
  %91 = load i64, ptr %12, align 8, !tbaa !8
  %92 = load i64, ptr @N, align 8, !tbaa !8
  %93 = icmp slt i64 %91, %92
  br i1 %93, label %95, label %94

94:                                               ; preds = %90
  store i32 13, ptr %11, align 4
  br label %129

95:                                               ; preds = %90
  %96 = load i64, ptr %12, align 8, !tbaa !8
  %97 = load i64, ptr %8, align 8, !tbaa !8
  %98 = icmp sgt i64 %96, %97
  br i1 %98, label %99, label %100

99:                                               ; preds = %95
  store i32 13, ptr %11, align 4
  br label %129

100:                                              ; preds = %95
  %101 = load i64, ptr %12, align 8, !tbaa !8
  %102 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %101
  %103 = load i64, ptr %102, align 8, !tbaa !8
  %104 = getelementptr inbounds [100001 x i8], ptr @Z, i64 0, i64 %103
  %105 = load i8, ptr %104, align 1, !tbaa !11, !range !17, !noundef !18
  %106 = trunc i8 %105 to i1
  br i1 %106, label %107, label %108

107:                                              ; preds = %100
  br label %122

108:                                              ; preds = %100
  %109 = load i64, ptr %12, align 8, !tbaa !8
  %110 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %109
  %111 = load i64, ptr %110, align 8, !tbaa !8
  %112 = getelementptr inbounds [100001 x i64], ptr @mxc, i64 0, i64 %111
  %113 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef nonnull align 8 dereferenceable(8) %112)
          to label %114 unwind label %125

114:                                              ; preds = %108
  %115 = load i64, ptr %113, align 8, !tbaa !8
  store i64 %115, ptr %8, align 8, !tbaa !8
  %116 = load i64, ptr %12, align 8, !tbaa !8
  %117 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %116
  %118 = load i64, ptr %117, align 8, !tbaa !8
  %119 = getelementptr inbounds [100001 x i8], ptr @Z, i64 0, i64 %118
  store i8 1, ptr %119, align 1, !tbaa !11
  %120 = load i64, ptr %7, align 8, !tbaa !8
  %121 = add nsw i64 %120, 1
  store i64 %121, ptr %7, align 8, !tbaa !8
  br label %122

122:                                              ; preds = %114, %107
  %123 = load i64, ptr %12, align 8, !tbaa !8
  %124 = add nsw i64 %123, 1
  store i64 %124, ptr %12, align 8, !tbaa !8
  br label %90, !llvm.loop !19

125:                                              ; preds = %108
  %126 = landingpad { ptr, i32 }
          cleanup
  %127 = extractvalue { ptr, i32 } %126, 0
  store ptr %127, ptr %5, align 8
  %128 = extractvalue { ptr, i32 } %126, 1
  store i32 %128, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  br label %140

129:                                              ; preds = %99, %94
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  br label %130

130:                                              ; preds = %129
  %131 = load i64, ptr %7, align 8, !tbaa !8
  %132 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %131)
          to label %133 unwind label %136

133:                                              ; preds = %130
  %134 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %132, i8 noundef signext 10)
          to label %135 unwind label %136

135:                                              ; preds = %133
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  call void @_ZNSt3setIxSt4lessIxESaIxEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %3) #7
  call void @llvm.lifetime.end.p0(i64 48, ptr %3) #7
  br label %20, !llvm.loop !20

136:                                              ; preds = %133, %130
  %137 = landingpad { ptr, i32 }
          cleanup
  %138 = extractvalue { ptr, i32 } %137, 0
  store ptr %138, ptr %5, align 8
  %139 = extractvalue { ptr, i32 } %137, 1
  store i32 %139, ptr %6, align 4
  br label %140

140:                                              ; preds = %136, %125
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  br label %141

141:                                              ; preds = %140, %58
  call void @_ZNSt3setIxSt4lessIxESaIxEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %3) #7
  call void @llvm.lifetime.end.p0(i64 48, ptr %3) #7
  br label %144

142:                                              ; preds = %20
  %143 = load i32, ptr %1, align 4
  ret i32 %143

144:                                              ; preds = %141
  %145 = load ptr, ptr %5, align 8
  %146 = load i32, ptr %6, align 4
  %147 = insertvalue { ptr, i32 } poison, ptr %145, 0
  %148 = insertvalue { ptr, i32 } %147, i32 %146, 1
  resume { ptr, i32 } %148
}

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

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) #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)) #3 align 2

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

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

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

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #5

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

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

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

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

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


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.std::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<long long, std::pair<const long long, long long>, std::_Select1st<std::pair<const long long, long long>>, std::less<long long>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<long long, std::pair<const long long, long long>, std::_Select1st<std::pair<const long long, long long>>, std::less<long long>>::_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_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" }
%"class.std::set" = type { %"class.std::_Rb_tree.0" }
%"class.std::_Rb_tree.0" = type { %"struct.std::_Rb_tree<long long, long long, std::_Identity<long long>, std::less<long long>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<long long, long long, std::_Identity<long long>, std::less<long long>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }

@T = external dso_local global i64, align 8
@N = external dso_local global i64, align 8
@A = external dso_local global [100000 x i64], align 16
@mxc = external dso_local global [100001 x i64], align 16
@Z = external dso_local local_unnamed_addr global [100001 x i8], align 16
@M = external dso_local global %"class.std::map", align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca %"class.std::set", align 8
  %2 = alloca i64, align 8
  %3 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %4 = getelementptr i8, ptr %3, i64 -24
  %5 = load i64, ptr %4, align 8
  %6 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %5
  %7 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %6, ptr noundef null)
  %8 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %9 = 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) @T)
  %10 = load i64, ptr @T, align 8, !tbaa !8
  %11 = add nsw i64 %10, -1
  store i64 %11, ptr @T, align 8, !tbaa !8
  %.not55 = icmp eq i64 %10, 0
  br i1 %.not55, label %._crit_edge58, label %.lr.ph57

.lr.ph57:                                         ; preds = %0, %63
  %12 = 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)
  call void @_ZNSt3mapIxxSt4lessIxESaISt4pairIKxxEEE5clearEv(ptr noundef nonnull align 8 dereferenceable(48) @M) #8
  %13 = load i64, ptr @N, align 8, !tbaa !8
  %.not3338 = icmp slt i64 %13, 0
  br i1 %.not3338, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.lr.ph57
  %14 = add nuw i64 %13, 1
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1) @Z, i8 0, i64 %14, i1 false), !tbaa !11
  %15 = shl i64 %13, 3
  %16 = add i64 %15, 8
  call void @llvm.memset.p0.i64(ptr nonnull align 16 @mxc, i8 -1, i64 %16, i1 false), !tbaa !8
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph.preheader, %.lr.ph57
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %1) #8
  call void @_ZNSt3setIxSt4lessIxESaIxEEC2Ev(ptr noundef nonnull align 8 dereferenceable(48) %1) #8
  %17 = load i64, ptr @N, align 8, !tbaa !8
  %18 = icmp sgt i64 %17, 0
  br i1 %18, label %.lr.ph42, label %._crit_edge43.thread

._crit_edge43.thread:                             ; preds = %._crit_edge
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #8
  store i64 -1, ptr %2, align 8, !tbaa !8
  br label %._crit_edge53

._crit_edge43:                                    ; preds = %26
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #8
  store i64 -1, ptr %2, align 8, !tbaa !8
  %19 = icmp sgt i64 %30, 1
  br i1 %19, label %.lr.ph47.preheader, label %._crit_edge53

.lr.ph47.preheader:                               ; preds = %._crit_edge43
  %20 = add nsw i64 %30, -2
  %21 = add nsw i64 %30, -1
  %22 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %21
  %23 = load i64, ptr %22, align 8, !tbaa !8
  br label %.lr.ph47

.lr.ph42:                                         ; preds = %._crit_edge, %26
  %.03040 = phi i64 [ %29, %26 ], [ 0, %._crit_edge ]
  %24 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %.03040
  %25 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %24)
          to label %26 unwind label %32

26:                                               ; preds = %.lr.ph42
  %27 = load i64, ptr %24, align 8, !tbaa !8
  %28 = getelementptr inbounds [100001 x i64], ptr @mxc, i64 0, i64 %27
  store i64 %.03040, ptr %28, align 8, !tbaa !8
  %29 = add nuw nsw i64 %.03040, 1
  %30 = load i64, ptr @N, align 8, !tbaa !8
  %31 = icmp slt i64 %29, %30
  br i1 %31, label %.lr.ph42, label %._crit_edge43, !llvm.loop !13

32:                                               ; preds = %.lr.ph42
  %33 = landingpad { ptr, i32 }
          cleanup
  br label %68

.lr.ph47:                                         ; preds = %.lr.ph47.preheader, %37
  %.02545 = phi i64 [ %38, %37 ], [ %20, %.lr.ph47.preheader ]
  %.02644 = phi i64 [ %35, %37 ], [ %23, %.lr.ph47.preheader ]
  %34 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %.02545
  %35 = load i64, ptr %34, align 8, !tbaa !8
  %36 = icmp sgt i64 %35, %.02644
  br i1 %36, label %.loopexit, label %37

37:                                               ; preds = %.lr.ph47
  %38 = add nsw i64 %.02545, -1
  %39 = icmp sgt i64 %.02545, 0
  br i1 %39, label %.lr.ph47, label %._crit_edge53, !llvm.loop !15

.loopexit:                                        ; preds = %.lr.ph47
  store i64 %.02545, ptr %2, align 8, !tbaa !8
  br label %.lr.ph52

.lr.ph52:                                         ; preds = %.loopexit, %54
  %40 = phi i64 [ %55, %54 ], [ %.02545, %.loopexit ]
  %41 = phi i64 [ %56, %54 ], [ %30, %.loopexit ]
  %.050 = phi i64 [ %57, %54 ], [ 0, %.loopexit ]
  %.02749 = phi i64 [ %.1, %54 ], [ 0, %.loopexit ]
  %42 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %.050
  %43 = load i64, ptr %42, align 8, !tbaa !8
  %44 = getelementptr inbounds [100001 x i8], ptr @Z, i64 0, i64 %43
  %45 = load i8, ptr %44, align 1, !tbaa !11, !range !16, !noundef !17
  %46 = trunc nuw i8 %45 to i1
  br i1 %46, label %54, label %47

47:                                               ; preds = %.lr.ph52
  %48 = getelementptr inbounds [100001 x i64], ptr @mxc, i64 0, i64 %43
  %49 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %48)
  %50 = load i64, ptr %49, align 8, !tbaa !8
  store i64 %50, ptr %2, align 8, !tbaa !8
  %51 = load i64, ptr %42, align 8, !tbaa !8
  %52 = getelementptr inbounds [100001 x i8], ptr @Z, i64 0, i64 %51
  store i8 1, ptr %52, align 1, !tbaa !11
  %53 = add nsw i64 %.02749, 1
  %.pre = load i64, ptr @N, align 8, !tbaa !8
  br label %54

54:                                               ; preds = %.lr.ph52, %47
  %55 = phi i64 [ %40, %.lr.ph52 ], [ %50, %47 ]
  %56 = phi i64 [ %41, %.lr.ph52 ], [ %.pre, %47 ]
  %.1 = phi i64 [ %.02749, %.lr.ph52 ], [ %53, %47 ]
  %57 = add nuw nsw i64 %.050, 1
  %58 = icmp sge i64 %57, %56
  %59 = icmp sge i64 %.050, %55
  %or.cond = select i1 %58, i1 true, i1 %59
  br i1 %or.cond, label %._crit_edge53, label %.lr.ph52, !llvm.loop !18

._crit_edge53:                                    ; preds = %37, %54, %._crit_edge43, %._crit_edge43.thread
  %.027.lcssa = phi i64 [ 0, %._crit_edge43.thread ], [ 0, %._crit_edge43 ], [ %.1, %54 ], [ 0, %37 ]
  %60 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %.027.lcssa)
          to label %61 unwind label %66

61:                                               ; preds = %._crit_edge53
  %62 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %60, i8 noundef signext 10)
          to label %63 unwind label %66

63:                                               ; preds = %61
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #8
  call void @_ZNSt3setIxSt4lessIxESaIxEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %1) #8
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %1) #8
  %64 = load i64, ptr @T, align 8, !tbaa !8
  %65 = add nsw i64 %64, -1
  store i64 %65, ptr @T, align 8, !tbaa !8
  %.not = icmp eq i64 %64, 0
  br i1 %.not, label %._crit_edge58, label %.lr.ph57, !llvm.loop !19

66:                                               ; preds = %61, %._crit_edge53
  %67 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #8
  br label %68

68:                                               ; preds = %66, %32
  %.pn = phi { ptr, i32 } [ %33, %32 ], [ %67, %66 ]
  call void @_ZNSt3setIxSt4lessIxESaIxEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %1) #8
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %1) #8
  resume { ptr, i32 } %.pn

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

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

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) local_unnamed_addr #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 #3 align 2

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

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

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

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #5

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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #7

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

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

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


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