; LLVM IR from eyangch/competitive-programming :: Codeforces/1692 (h)

; 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::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::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 }

@T = external dso_local global i64, align 8
@N = external dso_local global i64, align 8
@a = external dso_local global [200000 x i64], align 16
@nxt = external dso_local global [200000 x i64], align 16
@vis = external dso_local global [200000 x i8], align 16
@_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 %"class.std::map", align 8
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %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 i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  %16 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %17 = getelementptr i8, ptr %16, i64 -24
  %18 = load i64, ptr %17, align 8
  %19 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %18
  %20 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %19, ptr noundef null)
  %21 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %22 = 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 %23

23:                                               ; preds = %153, %0
  %24 = load i64, ptr @T, align 8, !tbaa !8
  %25 = add nsw i64 %24, -1
  store i64 %25, ptr @T, align 8, !tbaa !8
  %26 = icmp ne i64 %24, 0
  br i1 %26, label %27, label %159

27:                                               ; preds = %23
  %28 = 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 @llvm.lifetime.start.p0(i64 48, ptr %2) #6
  call void @_ZNSt3mapIxxSt4lessIxESaISt4pairIKxxEEEC2Ev(ptr noundef nonnull align 8 dereferenceable(48) %2) #6
  %29 = load i64, ptr @N, align 8, !tbaa !8
  %30 = getelementptr inbounds i64, ptr @nxt, i64 %29
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 -1, ptr %3, align 4, !tbaa !11
  invoke void @_ZSt4fillIPxiEvT_S1_RKT0_(ptr noundef @nxt, ptr noundef %30, ptr noundef nonnull align 4 dereferenceable(4) %3)
          to label %31 unwind label %40

31:                                               ; preds = %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  %32 = load i64, ptr @N, align 8, !tbaa !8
  %33 = getelementptr inbounds i8, ptr @vis, i64 %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 0, ptr %6, align 4, !tbaa !11
  invoke void @_ZSt4fillIPbiEvT_S1_RKT0_(ptr noundef @vis, ptr noundef %33, ptr noundef nonnull align 4 dereferenceable(4) %6)
          to label %34 unwind label %44

34:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  store i64 0, ptr %7, align 8, !tbaa !8
  br label %35

35:                                               ; preds = %76, %34
  %36 = load i64, ptr %7, align 8, !tbaa !8
  %37 = load i64, ptr @N, align 8, !tbaa !8
  %38 = icmp slt i64 %36, %37
  br i1 %38, label %48, label %39

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

40:                                               ; preds = %27
  %41 = landingpad { ptr, i32 }
          cleanup
  %42 = extractvalue { ptr, i32 } %41, 0
  store ptr %42, ptr %4, align 8
  %43 = extractvalue { ptr, i32 } %41, 1
  store i32 %43, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %158

44:                                               ; preds = %31
  %45 = landingpad { ptr, i32 }
          cleanup
  %46 = extractvalue { ptr, i32 } %45, 0
  store ptr %46, ptr %4, align 8
  %47 = extractvalue { ptr, i32 } %45, 1
  store i32 %47, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %158

48:                                               ; preds = %35
  %49 = load i64, ptr %7, align 8, !tbaa !8
  %50 = getelementptr inbounds [200000 x i64], ptr @a, i64 0, i64 %49
  %51 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %50)
          to label %52 unwind label %66

52:                                               ; preds = %48
  %53 = load i64, ptr %7, align 8, !tbaa !8
  %54 = getelementptr inbounds [200000 x i64], ptr @a, i64 0, i64 %53
  %55 = invoke noundef i64 @_ZNKSt3mapIxxSt4lessIxESaISt4pairIKxxEEE5countERS3_(ptr noundef nonnull align 8 dereferenceable(48) %2, ptr noundef nonnull align 8 dereferenceable(8) %54)
          to label %56 unwind label %66

56:                                               ; preds = %52
  %57 = icmp ne i64 %55, 0
  br i1 %57, label %58, label %70

58:                                               ; preds = %56
  %59 = load i64, ptr %7, align 8, !tbaa !8
  %60 = load i64, ptr %7, align 8, !tbaa !8
  %61 = getelementptr inbounds [200000 x i64], ptr @a, i64 0, i64 %60
  %62 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt3mapIxxSt4lessIxESaISt4pairIKxxEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) %2, ptr noundef nonnull align 8 dereferenceable(8) %61)
          to label %63 unwind label %66

63:                                               ; preds = %58
  %64 = load i64, ptr %62, align 8, !tbaa !8
  %65 = getelementptr inbounds [200000 x i64], ptr @nxt, i64 0, i64 %64
  store i64 %59, ptr %65, align 8, !tbaa !8
  br label %70

66:                                               ; preds = %70, %58, %52, %48
  %67 = landingpad { ptr, i32 }
          cleanup
  %68 = extractvalue { ptr, i32 } %67, 0
  store ptr %68, ptr %4, align 8
  %69 = extractvalue { ptr, i32 } %67, 1
  store i32 %69, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  br label %158

70:                                               ; preds = %63, %56
  %71 = load i64, ptr %7, align 8, !tbaa !8
  %72 = load i64, ptr %7, align 8, !tbaa !8
  %73 = getelementptr inbounds [200000 x i64], ptr @a, i64 0, i64 %72
  %74 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt3mapIxxSt4lessIxESaISt4pairIKxxEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) %2, ptr noundef nonnull align 8 dereferenceable(8) %73)
          to label %75 unwind label %66

75:                                               ; preds = %70
  store i64 %71, ptr %74, align 8, !tbaa !8
  br label %76

76:                                               ; preds = %75
  %77 = load i64, ptr %7, align 8, !tbaa !8
  %78 = add nsw i64 %77, 1
  store i64 %78, ptr %7, align 8, !tbaa !8
  br label %35, !llvm.loop !13

79:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  store i64 0, ptr %8, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  store i64 0, ptr %9, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  store i64 0, ptr %10, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  store i64 0, ptr %11, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  store i64 0, ptr %12, align 8, !tbaa !8
  br label %80

80:                                               ; preds = %133, %79
  %81 = load i64, ptr %12, align 8, !tbaa !8
  %82 = load i64, ptr @N, align 8, !tbaa !8
  %83 = icmp slt i64 %81, %82
  br i1 %83, label %85, label %84

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

85:                                               ; preds = %80
  %86 = load i64, ptr %12, align 8, !tbaa !8
  %87 = getelementptr inbounds [200000 x i8], ptr @vis, i64 0, i64 %86
  %88 = load i8, ptr %87, align 1, !tbaa !15, !range !17, !noundef !18
  %89 = trunc i8 %88 to i1
  br i1 %89, label %90, label %91

90:                                               ; preds = %85
  br label %133

91:                                               ; preds = %85
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %92 = load i64, ptr %12, align 8, !tbaa !8
  store i64 %92, ptr %13, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  store i64 1, ptr %14, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  %93 = load i64, ptr %12, align 8, !tbaa !8
  store i64 %93, ptr %15, align 8, !tbaa !8
  br label %94

94:                                               ; preds = %128, %91
  br label %95

95:                                               ; preds = %94
  %96 = load i64, ptr %13, align 8, !tbaa !8
  %97 = getelementptr inbounds [200000 x i8], ptr @vis, i64 0, i64 %96
  store i8 1, ptr %97, align 1, !tbaa !15
  %98 = load i64, ptr %14, align 8, !tbaa !8
  %99 = icmp slt i64 %98, 1
  br i1 %99, label %100, label %102

100:                                              ; preds = %95
  store i64 1, ptr %14, align 8, !tbaa !8
  %101 = load i64, ptr %13, align 8, !tbaa !8
  store i64 %101, ptr %15, align 8, !tbaa !8
  br label %102

102:                                              ; preds = %100, %95
  %103 = load i64, ptr %14, align 8, !tbaa !8
  %104 = load i64, ptr %8, align 8, !tbaa !8
  %105 = icmp sge i64 %103, %104
  br i1 %105, label %106, label %113

106:                                              ; preds = %102
  %107 = load i64, ptr %14, align 8, !tbaa !8
  store i64 %107, ptr %8, align 8, !tbaa !8
  %108 = load i64, ptr %12, align 8, !tbaa !8
  %109 = getelementptr inbounds [200000 x i64], ptr @a, i64 0, i64 %108
  %110 = load i64, ptr %109, align 8, !tbaa !8
  store i64 %110, ptr %9, align 8, !tbaa !8
  %111 = load i64, ptr %15, align 8, !tbaa !8
  store i64 %111, ptr %10, align 8, !tbaa !8
  %112 = load i64, ptr %13, align 8, !tbaa !8
  store i64 %112, ptr %11, align 8, !tbaa !8
  br label %113

113:                                              ; preds = %106, %102
  %114 = load i64, ptr %14, align 8, !tbaa !8
  %115 = add nsw i64 %114, 2
  store i64 %115, ptr %14, align 8, !tbaa !8
  %116 = load i64, ptr %13, align 8, !tbaa !8
  %117 = getelementptr inbounds [200000 x i64], ptr @nxt, i64 0, i64 %116
  %118 = load i64, ptr %117, align 8, !tbaa !8
  %119 = load i64, ptr %13, align 8, !tbaa !8
  %120 = sub nsw i64 %118, %119
  %121 = load i64, ptr %14, align 8, !tbaa !8
  %122 = sub nsw i64 %121, %120
  store i64 %122, ptr %14, align 8, !tbaa !8
  %123 = load i64, ptr %13, align 8, !tbaa !8
  %124 = getelementptr inbounds [200000 x i64], ptr @nxt, i64 0, i64 %123
  %125 = load i64, ptr %124, align 8, !tbaa !8
  %126 = icmp eq i64 %125, -1
  br i1 %126, label %127, label %128

127:                                              ; preds = %113
  br label %132

128:                                              ; preds = %113
  %129 = load i64, ptr %13, align 8, !tbaa !8
  %130 = getelementptr inbounds [200000 x i64], ptr @nxt, i64 0, i64 %129
  %131 = load i64, ptr %130, align 8, !tbaa !8
  store i64 %131, ptr %13, align 8, !tbaa !8
  br label %94, !llvm.loop !19

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

133:                                              ; preds = %132, %90
  %134 = load i64, ptr %12, align 8, !tbaa !8
  %135 = add nsw i64 %134, 1
  store i64 %135, ptr %12, align 8, !tbaa !8
  br label %80, !llvm.loop !20

136:                                              ; preds = %84
  %137 = load i64, ptr %9, align 8, !tbaa !8
  %138 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %137)
          to label %139 unwind label %154

139:                                              ; preds = %136
  %140 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %138, i8 noundef signext 32)
          to label %141 unwind label %154

141:                                              ; preds = %139
  %142 = load i64, ptr %10, align 8, !tbaa !8
  %143 = add nsw i64 %142, 1
  %144 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) %140, i64 noundef %143)
          to label %145 unwind label %154

145:                                              ; preds = %141
  %146 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %144, i8 noundef signext 32)
          to label %147 unwind label %154

147:                                              ; preds = %145
  %148 = load i64, ptr %11, align 8, !tbaa !8
  %149 = add nsw i64 %148, 1
  %150 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) %146, i64 noundef %149)
          to label %151 unwind label %154

151:                                              ; preds = %147
  %152 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %150, i8 noundef signext 10)
          to label %153 unwind label %154

153:                                              ; preds = %151
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @_ZNSt3mapIxxSt4lessIxESaISt4pairIKxxEEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %2) #6
  call void @llvm.lifetime.end.p0(i64 48, ptr %2) #6
  br label %23, !llvm.loop !21

154:                                              ; preds = %151, %147, %145, %141, %139, %136
  %155 = landingpad { ptr, i32 }
          cleanup
  %156 = extractvalue { ptr, i32 } %155, 0
  store ptr %156, ptr %4, align 8
  %157 = extractvalue { ptr, i32 } %155, 1
  store i32 %157, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %158

158:                                              ; preds = %154, %66, %44, %40
  call void @_ZNSt3mapIxxSt4lessIxESaISt4pairIKxxEEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %2) #6
  call void @llvm.lifetime.end.p0(i64 48, ptr %2) #6
  br label %161

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

161:                                              ; preds = %158
  %162 = load ptr, ptr %4, align 8
  %163 = load i32, ptr %5, align 4
  %164 = insertvalue { ptr, i32 } poison, ptr %162, 0
  %165 = insertvalue { ptr, i32 } %164, i32 %163, 1
  resume { ptr, i32 } %165
}

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4fillIPxiEvT_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) #5

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4fillIPbiEvT_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) #5

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

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

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

; 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 @_ZNSt3mapIxxSt4lessIxESaISt4pairIKxxEEED2Ev(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 uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nounwind }

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

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

@T = external dso_local global i64, align 8
@N = external dso_local global i64, align 8
@a = external dso_local global [200000 x i64], align 16
@nxt = external dso_local global [200000 x i64], align 16
@vis = external dso_local global [200000 x i8], align 16
@_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::map", align 8
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %5 = getelementptr i8, ptr %4, i64 -24
  %6 = load i64, ptr %5, align 8
  %7 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %6
  %8 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %7, ptr noundef null)
  %9 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %10 = 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)
  %11 = load i64, ptr @T, align 8, !tbaa !8
  %12 = add nsw i64 %11, -1
  store i64 %12, ptr @T, align 8, !tbaa !8
  %.not72 = icmp eq i64 %11, 0
  br i1 %.not72, label %._crit_edge75, label %.lr.ph74

.lr.ph74:                                         ; preds = %0, %75
  %13 = 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 @llvm.lifetime.start.p0(i64 48, ptr nonnull %1) #7
  call void @_ZNSt3mapIxxSt4lessIxESaISt4pairIKxxEEEC2Ev(ptr noundef nonnull align 8 dereferenceable(48) %1) #7
  %14 = load i64, ptr @N, align 8, !tbaa !8
  %15 = getelementptr inbounds i64, ptr @nxt, i64 %14
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  store i32 -1, ptr %2, align 4, !tbaa !11
  invoke void @_ZSt4fillIPxiEvT_S1_RKT0_(ptr noundef nonnull @nxt, ptr noundef nonnull %15, ptr noundef nonnull align 4 dereferenceable(4) %2)
          to label %16 unwind label %23

16:                                               ; preds = %.lr.ph74
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  %17 = load i64, ptr @N, align 8, !tbaa !8
  %18 = getelementptr inbounds i8, ptr @vis, i64 %17
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #7
  store i32 0, ptr %3, align 4, !tbaa !11
  invoke void @_ZSt4fillIPbiEvT_S1_RKT0_(ptr noundef nonnull @vis, ptr noundef nonnull %18, ptr noundef nonnull align 4 dereferenceable(4) %3)
          to label %19 unwind label %25

19:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #7
  %20 = load i64, ptr @N, align 8, !tbaa !8
  %21 = icmp sgt i64 %20, 0
  br i1 %21, label %.lr.ph, label %._crit_edge

.preheader60:                                     ; preds = %41
  %22 = icmp sgt i64 %43, 0
  br i1 %22, label %.lr.ph68, label %._crit_edge

23:                                               ; preds = %.lr.ph74
  %24 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  br label %80

25:                                               ; preds = %16
  %26 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #7
  br label %80

.lr.ph:                                           ; preds = %19, %41
  %.05162 = phi i64 [ %42, %41 ], [ 0, %19 ]
  %27 = getelementptr inbounds [200000 x i64], ptr @a, i64 0, i64 %.05162
  %28 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %27)
          to label %29 unwind label %37

29:                                               ; preds = %.lr.ph
  %30 = invoke noundef i64 @_ZNKSt3mapIxxSt4lessIxESaISt4pairIKxxEEE5countERS3_(ptr noundef nonnull align 8 dereferenceable(48) %1, ptr noundef nonnull align 8 dereferenceable(8) %27)
          to label %31 unwind label %37

31:                                               ; preds = %29
  %.not56 = icmp eq i64 %30, 0
  br i1 %.not56, label %39, label %32

32:                                               ; preds = %31
  %33 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt3mapIxxSt4lessIxESaISt4pairIKxxEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) %1, ptr noundef nonnull align 8 dereferenceable(8) %27)
          to label %34 unwind label %37

34:                                               ; preds = %32
  %35 = load i64, ptr %33, align 8, !tbaa !8
  %36 = getelementptr inbounds [200000 x i64], ptr @nxt, i64 0, i64 %35
  store i64 %.05162, ptr %36, align 8, !tbaa !8
  br label %39

37:                                               ; preds = %39, %32, %29, %.lr.ph
  %38 = landingpad { ptr, i32 }
          cleanup
  br label %80

39:                                               ; preds = %34, %31
  %40 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt3mapIxxSt4lessIxESaISt4pairIKxxEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) %1, ptr noundef nonnull align 8 dereferenceable(8) %27)
          to label %41 unwind label %37

41:                                               ; preds = %39
  store i64 %.05162, ptr %40, align 8, !tbaa !8
  %42 = add nuw nsw i64 %.05162, 1
  %43 = load i64, ptr @N, align 8, !tbaa !8
  %44 = icmp slt i64 %42, %43
  br i1 %44, label %.lr.ph, label %.preheader60, !llvm.loop !13

._crit_edge:                                      ; preds = %.loopexit, %19, %.preheader60
  %.043.lcssa = phi i64 [ 0, %.preheader60 ], [ 0, %19 ], [ %.346, %.loopexit ]
  %.039.lcssa = phi i64 [ 0, %.preheader60 ], [ 0, %19 ], [ %.342, %.loopexit ]
  %.037.lcssa = phi i64 [ 0, %.preheader60 ], [ 0, %19 ], [ %.3, %.loopexit ]
  %45 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %.043.lcssa)
          to label %63 unwind label %78

.lr.ph68:                                         ; preds = %.preheader60, %.loopexit
  %.03667 = phi i64 [ %62, %.loopexit ], [ 0, %.preheader60 ]
  %.03766 = phi i64 [ %.3, %.loopexit ], [ 0, %.preheader60 ]
  %.03965 = phi i64 [ %.342, %.loopexit ], [ 0, %.preheader60 ]
  %.04364 = phi i64 [ %.346, %.loopexit ], [ 0, %.preheader60 ]
  %.04763 = phi i64 [ %.350, %.loopexit ], [ 0, %.preheader60 ]
  %46 = getelementptr inbounds [200000 x i8], ptr @vis, i64 0, i64 %.03667
  %47 = load i8, ptr %46, align 1, !tbaa !15, !range !17, !noundef !18
  %48 = trunc nuw i8 %47 to i1
  br i1 %48, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %.lr.ph68
  %49 = getelementptr inbounds [200000 x i64], ptr @a, i64 0, i64 %.03667
  br label %50

50:                                               ; preds = %.preheader, %59
  %.148 = phi i64 [ %.249, %59 ], [ %.04763, %.preheader ]
  %.144 = phi i64 [ %.245, %59 ], [ %.04364, %.preheader ]
  %.140 = phi i64 [ %.241, %59 ], [ %.03965, %.preheader ]
  %.138 = phi i64 [ %.2, %59 ], [ %.03766, %.preheader ]
  %.035 = phi i64 [ %57, %59 ], [ %.03667, %.preheader ]
  %.033 = phi i64 [ %61, %59 ], [ 1, %.preheader ]
  %.0 = phi i64 [ %spec.select58, %59 ], [ %.03667, %.preheader ]
  %51 = getelementptr inbounds [200000 x i8], ptr @vis, i64 0, i64 %.035
  store i8 1, ptr %51, align 1, !tbaa !15
  %52 = icmp slt i64 %.033, 1
  %spec.select = call i64 @llvm.smax.i64(i64 %.033, i64 1)
  %spec.select58 = select i1 %52, i64 %.035, i64 %.0
  %.not55 = icmp slt i64 %spec.select, %.148
  br i1 %.not55, label %55, label %53

53:                                               ; preds = %50
  %54 = load i64, ptr %49, align 8, !tbaa !8
  br label %55

55:                                               ; preds = %53, %50
  %.249 = phi i64 [ %spec.select, %53 ], [ %.148, %50 ]
  %.245 = phi i64 [ %54, %53 ], [ %.144, %50 ]
  %.241 = phi i64 [ %spec.select58, %53 ], [ %.140, %50 ]
  %.2 = phi i64 [ %.035, %53 ], [ %.138, %50 ]
  %56 = getelementptr inbounds [200000 x i64], ptr @nxt, i64 0, i64 %.035
  %57 = load i64, ptr %56, align 8, !tbaa !8
  %58 = icmp eq i64 %57, -1
  br i1 %58, label %.loopexit, label %59

59:                                               ; preds = %55
  %.neg = add i64 %.035, 2
  %60 = add i64 %.neg, %spec.select
  %61 = sub i64 %60, %57
  br label %50, !llvm.loop !19

.loopexit:                                        ; preds = %55, %.lr.ph68
  %.350 = phi i64 [ %.04763, %.lr.ph68 ], [ %.249, %55 ]
  %.346 = phi i64 [ %.04364, %.lr.ph68 ], [ %.245, %55 ]
  %.342 = phi i64 [ %.03965, %.lr.ph68 ], [ %.241, %55 ]
  %.3 = phi i64 [ %.03766, %.lr.ph68 ], [ %.2, %55 ]
  %62 = add nuw nsw i64 %.03667, 1
  %exitcond.not = icmp eq i64 %62, %43
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph68, !llvm.loop !20

63:                                               ; preds = %._crit_edge
  %64 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %45, i8 noundef signext 32)
          to label %65 unwind label %78

65:                                               ; preds = %63
  %66 = add nsw i64 %.039.lcssa, 1
  %67 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) %64, i64 noundef %66)
          to label %68 unwind label %78

68:                                               ; preds = %65
  %69 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %67, i8 noundef signext 32)
          to label %70 unwind label %78

70:                                               ; preds = %68
  %71 = add nsw i64 %.037.lcssa, 1
  %72 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) %69, i64 noundef %71)
          to label %73 unwind label %78

73:                                               ; preds = %70
  %74 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %72, i8 noundef signext 10)
          to label %75 unwind label %78

75:                                               ; preds = %73
  call void @_ZNSt3mapIxxSt4lessIxESaISt4pairIKxxEEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %1) #7
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %1) #7
  %76 = load i64, ptr @T, align 8, !tbaa !8
  %77 = add nsw i64 %76, -1
  store i64 %77, ptr @T, align 8, !tbaa !8
  %.not = icmp eq i64 %76, 0
  br i1 %.not, label %._crit_edge75, label %.lr.ph74, !llvm.loop !21

78:                                               ; preds = %73, %70, %68, %65, %63, %._crit_edge
  %79 = landingpad { ptr, i32 }
          cleanup
  br label %80

80:                                               ; preds = %78, %37, %25, %23
  %.pn = phi { ptr, i32 } [ %38, %37 ], [ %79, %78 ], [ %26, %25 ], [ %24, %23 ]
  call void @_ZNSt3mapIxxSt4lessIxESaISt4pairIKxxEEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %1) #7
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %1) #7
  resume { ptr, i32 } %.pn

._crit_edge75:                                    ; preds = %75, %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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #4

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4fillIPxiEvT_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #5

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4fillIPbiEvT_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #5

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

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

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

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smax.i64(i64, i64) #6

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


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