; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/372 Division 1/Problem B/B.ll (Z3sp1xPx)

; 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::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::pair<long long, std::pair<long long, long long>>, std::allocator<std::pair<long long, std::pair<long long, long long>>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<long long, std::pair<long long, long long>>, std::allocator<std::pair<long long, std::pair<long long, long long>>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<long long, std::pair<long long, long long>>, std::allocator<std::pair<long long, std::pair<long long, long long>>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<long long, std::pair<long long, long long>>, std::allocator<std::pair<long long, std::pair<long long, long long>>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::set" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<std::pair<long long, long long>, std::pair<long long, long long>, std::_Identity<std::pair<long long, long long>>, std::less<std::pair<long long, long long>>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<std::pair<long long, long long>, std::pair<long long, long long>, std::_Identity<std::pair<long long, long long>>, std::less<std::pair<long long, 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 }
%"struct.std::pair.3" = type { i64, i64 }
%"struct.std::pair" = type <{ %"struct.std::_Rb_tree_const_iterator", i8, [7 x i8] }>
%"struct.std::_Rb_tree_const_iterator" = type { ptr }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }
%"struct.std::pair.5" = type { i64, %"struct.std::pair.3" }

@g = external dso_local global [1010 x %"class.std::vector"], align 16
@n = external dso_local global i64, align 8
@vis = external dso_local global [1010 x i64], align 16
@q = external dso_local global %"class.std::set", align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_Z3sp1xPx(i64 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca %"struct.std::pair.3", align 8
  %8 = alloca %"struct.std::pair", align 8
  %9 = alloca %"struct.std::pair.3", align 8
  %10 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i32, align 4
  %14 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %15 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca i64, align 8
  %19 = alloca %"struct.std::pair.3", align 8
  %20 = alloca %"struct.std::pair", align 8
  store i64 %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  store i64 0, ptr %5, align 8, !tbaa !5
  br label %21

21:                                               ; preds = %29, %2
  %22 = load i64, ptr %5, align 8, !tbaa !5
  %23 = load i64, ptr @n, align 8, !tbaa !5
  %24 = icmp slt i64 %22, %23
  br i1 %24, label %26, label %25

25:                                               ; preds = %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  br label %32

26:                                               ; preds = %21
  %27 = load i64, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds [1010 x i64], ptr @vis, i64 0, i64 %27
  store i64 0, ptr %28, align 8, !tbaa !5
  br label %29

29:                                               ; preds = %26
  %30 = load i64, ptr %5, align 8, !tbaa !5
  %31 = add nsw i64 %30, 1
  store i64 %31, ptr %5, align 8, !tbaa !5
  br label %21, !llvm.loop !11

32:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  store i64 0, ptr %6, align 8, !tbaa !5
  br label %33

33:                                               ; preds = %42, %32
  %34 = load i64, ptr %6, align 8, !tbaa !5
  %35 = load i64, ptr @n, align 8, !tbaa !5
  %36 = icmp slt i64 %34, %35
  br i1 %36, label %38, label %37

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

38:                                               ; preds = %33
  %39 = load ptr, ptr %4, align 8, !tbaa !9
  %40 = load i64, ptr %6, align 8, !tbaa !5
  %41 = getelementptr inbounds i64, ptr %39, i64 %40
  store i64 10000000000000, ptr %41, align 8, !tbaa !5
  br label %42

42:                                               ; preds = %38
  %43 = load i64, ptr %6, align 8, !tbaa !5
  %44 = add nsw i64 %43, 1
  store i64 %44, ptr %6, align 8, !tbaa !5
  br label %33, !llvm.loop !13

45:                                               ; preds = %37
  call void @_ZNSt3setISt4pairIxxESt4lessIS1_ESaIS1_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(48) @q) #5
  %46 = load ptr, ptr %4, align 8, !tbaa !9
  %47 = load i64, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds i64, ptr %46, i64 %47
  store i64 0, ptr %48, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #5
  %49 = load ptr, ptr %4, align 8, !tbaa !9
  %50 = load i64, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds i64, ptr %49, i64 %50
  %52 = call { i64, i64 } @_ZSt9make_pairIRxS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8) %51, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %53 = getelementptr inbounds { i64, i64 }, ptr %7, i32 0, i32 0
  %54 = extractvalue { i64, i64 } %52, 0
  store i64 %54, ptr %53, align 8
  %55 = getelementptr inbounds { i64, i64 }, ptr %7, i32 0, i32 1
  %56 = extractvalue { i64, i64 } %52, 1
  store i64 %56, ptr %55, align 8
  %57 = call { ptr, i8 } @_ZNSt3setISt4pairIxxESt4lessIS1_ESaIS1_EE6insertEOS1_(ptr noundef nonnull align 8 dereferenceable(48) @q, ptr noundef nonnull align 8 dereferenceable(16) %7)
  %58 = getelementptr inbounds { ptr, i8 }, ptr %8, i32 0, i32 0
  %59 = extractvalue { ptr, i8 } %57, 0
  store ptr %59, ptr %58, align 8
  %60 = getelementptr inbounds { ptr, i8 }, ptr %8, i32 0, i32 1
  %61 = extractvalue { ptr, i8 } %57, 1
  store i8 %61, ptr %60, align 8
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #5
  br label %62

62:                                               ; preds = %146, %144, %45
  %63 = call noundef zeroext i1 @_ZNKSt3setISt4pairIxxESt4lessIS1_ESaIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(48) @q) #5
  %64 = xor i1 %63, true
  br i1 %64, label %65, label %147

65:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %66 = call ptr @_ZNKSt3setISt4pairIxxESt4lessIS1_ESaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @q) #5
  %67 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %10, i32 0, i32 0
  store ptr %66, ptr %67, align 8
  %68 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt23_Rb_tree_const_iteratorISt4pairIxxEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %10) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %9, ptr align 8 %68, i64 16, i1 false)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  %69 = call noundef i64 @_ZNSt3setISt4pairIxxESt4lessIS1_ESaIS1_EE5eraseERKS1_(ptr noundef nonnull align 8 dereferenceable(48) @q, ptr noundef nonnull align 8 dereferenceable(16) %9)
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %70 = getelementptr inbounds %"struct.std::pair.3", ptr %9, i32 0, i32 0
  %71 = load i64, ptr %70, align 8, !tbaa !14
  store i64 %71, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %72 = getelementptr inbounds %"struct.std::pair.3", ptr %9, i32 0, i32 1
  %73 = load i64, ptr %72, align 8, !tbaa !16
  store i64 %73, ptr %12, align 8, !tbaa !5
  %74 = load i64, ptr %12, align 8, !tbaa !5
  %75 = getelementptr inbounds [1010 x i64], ptr @vis, i64 0, i64 %74
  %76 = load i64, ptr %75, align 8, !tbaa !5
  %77 = icmp ne i64 %76, 0
  br i1 %77, label %78, label %79

78:                                               ; preds = %65
  store i32 8, ptr %13, align 4
  br label %144, !llvm.loop !17

79:                                               ; preds = %65
  %80 = load i64, ptr %12, align 8, !tbaa !5
  %81 = getelementptr inbounds [1010 x i64], ptr @vis, i64 0, i64 %80
  store i64 1, ptr %81, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %82 = load i64, ptr %12, align 8, !tbaa !5
  %83 = getelementptr inbounds [1010 x %"class.std::vector"], ptr @g, i64 0, i64 %82
  %84 = call ptr @_ZNSt6vectorISt4pairIxS0_IxxEESaIS2_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %83) #5
  %85 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %14, i32 0, i32 0
  store ptr %84, ptr %85, align 8
  br label %86

86:                                               ; preds = %141, %79
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %87 = load i64, ptr %12, align 8, !tbaa !5
  %88 = getelementptr inbounds [1010 x %"class.std::vector"], ptr @g, i64 0, i64 %87
  %89 = call ptr @_ZNSt6vectorISt4pairIxS0_IxxEESaIS2_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %88) #5
  %90 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %15, i32 0, i32 0
  store ptr %89, ptr %90, align 8
  %91 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPSt4pairIxS1_IxxEESt6vectorIS3_SaIS3_EEEEbRKNS_17__normal_iteratorIT_T0_EESD_(ptr noundef nonnull align 8 dereferenceable(8) %14, ptr noundef nonnull align 8 dereferenceable(8) %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  br i1 %91, label %93, label %92

92:                                               ; preds = %86
  store i32 10, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  br label %143

93:                                               ; preds = %86
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %94 = call noundef ptr @_ZNK9__gnu_cxx17__normal_iteratorIPSt4pairIxS1_IxxEESt6vectorIS3_SaIS3_EEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %14) #5
  %95 = getelementptr inbounds %"struct.std::pair.5", ptr %94, i32 0, i32 0
  %96 = load i64, ptr %95, align 8, !tbaa !18
  store i64 %96, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  %97 = call noundef ptr @_ZNK9__gnu_cxx17__normal_iteratorIPSt4pairIxS1_IxxEESt6vectorIS3_SaIS3_EEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %14) #5
  %98 = getelementptr inbounds %"struct.std::pair.5", ptr %97, i32 0, i32 1
  %99 = getelementptr inbounds %"struct.std::pair.3", ptr %98, i32 0, i32 0
  %100 = load i64, ptr %99, align 8, !tbaa !20
  store i64 %100, ptr %17, align 8, !tbaa !5
  %101 = load i64, ptr %16, align 8, !tbaa !5
  %102 = getelementptr inbounds [1010 x i64], ptr @vis, i64 0, i64 %101
  %103 = load i64, ptr %102, align 8, !tbaa !5
  %104 = icmp ne i64 %103, 0
  br i1 %104, label %108, label %105

105:                                              ; preds = %93
  %106 = load i64, ptr %17, align 8, !tbaa !5
  %107 = icmp eq i64 %106, 0
  br i1 %107, label %108, label %109

108:                                              ; preds = %105, %93
  store i32 12, ptr %13, align 4
  br label %138

109:                                              ; preds = %105
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  %110 = load i64, ptr %11, align 8, !tbaa !5
  %111 = load i64, ptr %17, align 8, !tbaa !5
  %112 = add nsw i64 %110, %111
  store i64 %112, ptr %18, align 8, !tbaa !5
  %113 = load i64, ptr %18, align 8, !tbaa !5
  %114 = load ptr, ptr %4, align 8, !tbaa !9
  %115 = load i64, ptr %16, align 8, !tbaa !5
  %116 = getelementptr inbounds i64, ptr %114, i64 %115
  %117 = load i64, ptr %116, align 8, !tbaa !5
  %118 = icmp slt i64 %113, %117
  br i1 %118, label %119, label %137

119:                                              ; preds = %109
  %120 = load i64, ptr %18, align 8, !tbaa !5
  %121 = load ptr, ptr %4, align 8, !tbaa !9
  %122 = load i64, ptr %16, align 8, !tbaa !5
  %123 = getelementptr inbounds i64, ptr %121, i64 %122
  store i64 %120, ptr %123, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %19) #5
  %124 = load ptr, ptr %4, align 8, !tbaa !9
  %125 = load i64, ptr %16, align 8, !tbaa !5
  %126 = getelementptr inbounds i64, ptr %124, i64 %125
  %127 = call { i64, i64 } @_ZSt9make_pairIRxS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8) %126, ptr noundef nonnull align 8 dereferenceable(8) %16)
  %128 = getelementptr inbounds { i64, i64 }, ptr %19, i32 0, i32 0
  %129 = extractvalue { i64, i64 } %127, 0
  store i64 %129, ptr %128, align 8
  %130 = getelementptr inbounds { i64, i64 }, ptr %19, i32 0, i32 1
  %131 = extractvalue { i64, i64 } %127, 1
  store i64 %131, ptr %130, align 8
  %132 = call { ptr, i8 } @_ZNSt3setISt4pairIxxESt4lessIS1_ESaIS1_EE6insertEOS1_(ptr noundef nonnull align 8 dereferenceable(48) @q, ptr noundef nonnull align 8 dereferenceable(16) %19)
  %133 = getelementptr inbounds { ptr, i8 }, ptr %20, i32 0, i32 0
  %134 = extractvalue { ptr, i8 } %132, 0
  store ptr %134, ptr %133, align 8
  %135 = getelementptr inbounds { ptr, i8 }, ptr %20, i32 0, i32 1
  %136 = extractvalue { ptr, i8 } %132, 1
  store i8 %136, ptr %135, align 8
  call void @llvm.lifetime.end.p0(i64 16, ptr %19) #5
  br label %137

137:                                              ; preds = %119, %109
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  store i32 0, ptr %13, align 4
  br label %138

138:                                              ; preds = %137, %108
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  %139 = load i32, ptr %13, align 4
  switch i32 %139, label %148 [
    i32 0, label %140
    i32 12, label %141
  ]

140:                                              ; preds = %138
  br label %141

141:                                              ; preds = %140, %138
  %142 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN9__gnu_cxx17__normal_iteratorIPSt4pairIxS1_IxxEESt6vectorIS3_SaIS3_EEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %14) #5
  br label %86, !llvm.loop !21

143:                                              ; preds = %92
  store i32 0, ptr %13, align 4
  br label %144

144:                                              ; preds = %143, %78
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #5
  %145 = load i32, ptr %13, align 4
  switch i32 %145, label %148 [
    i32 0, label %146
    i32 8, label %62
  ]

146:                                              ; preds = %144
  br label %62, !llvm.loop !17

147:                                              ; preds = %62
  ret void

148:                                              ; preds = %144, %138
  unreachable
}

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local { ptr, i8 } @_ZNSt3setISt4pairIxxESt4lessIS1_ESaIS1_EE6insertEOS1_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(16)) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local { i64, i64 } @_ZSt9make_pairIRxS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #0

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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

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

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

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

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

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

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

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


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

%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::pair<long long, std::pair<long long, long long>>, std::allocator<std::pair<long long, std::pair<long long, long long>>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<long long, std::pair<long long, long long>>, std::allocator<std::pair<long long, std::pair<long long, long long>>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<long long, std::pair<long long, long long>>, std::allocator<std::pair<long long, std::pair<long long, long long>>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<long long, std::pair<long long, long long>>, std::allocator<std::pair<long long, std::pair<long long, long long>>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::set" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<std::pair<long long, long long>, std::pair<long long, long long>, std::_Identity<std::pair<long long, long long>>, std::less<std::pair<long long, long long>>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<std::pair<long long, long long>, std::pair<long long, long long>, std::_Identity<std::pair<long long, long long>>, std::less<std::pair<long long, 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 }
%"struct.std::pair.3" = type { i64, i64 }
%"struct.std::_Rb_tree_const_iterator" = type { ptr }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }

@g = external dso_local global [1010 x %"class.std::vector"], align 16
@n = external dso_local local_unnamed_addr global i64, align 8
@vis = external dso_local local_unnamed_addr global [1010 x i64], align 16
@q = external dso_local global %"class.std::set", align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_Z3sp1xPx(i64 noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = alloca i64, align 8
  %4 = alloca %"struct.std::pair.3", align 8
  %5 = alloca %"struct.std::pair.3", align 8
  %6 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %7 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %8 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %9 = alloca i64, align 8
  %10 = alloca %"struct.std::pair.3", align 8
  store i64 %0, ptr %3, align 8, !tbaa !5
  %11 = load i64, ptr @n, align 8, !tbaa !5
  %12 = icmp sgt i64 %11, 0
  br i1 %12, label %.lr.ph28.preheader, label %._crit_edge

.lr.ph28.preheader:                               ; preds = %2
  %13 = shl nuw i64 %11, 3
  tail call void @llvm.memset.p0.i64(ptr nonnull align 16 @vis, i8 0, i64 %13, i1 false), !tbaa !5
  br label %.lr.ph28

._crit_edge:                                      ; preds = %.lr.ph28, %2
  tail call void @_ZNSt3setISt4pairIxxESt4lessIS1_ESaIS1_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(48) @q) #6
  %14 = getelementptr inbounds i64, ptr %1, i64 %0
  store i64 0, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #6
  %15 = call { i64, i64 } @_ZSt9make_pairIRxS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8) %14, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %16 = extractvalue { i64, i64 } %15, 0
  store i64 %16, ptr %4, align 8
  %17 = getelementptr inbounds i8, ptr %4, i64 8
  %18 = extractvalue { i64, i64 } %15, 1
  store i64 %18, ptr %17, align 8
  %19 = call { ptr, i8 } @_ZNSt3setISt4pairIxxESt4lessIS1_ESaIS1_EE6insertEOS1_(ptr noundef nonnull align 8 dereferenceable(48) @q, ptr noundef nonnull align 8 dereferenceable(16) %4)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #6
  %20 = call noundef zeroext i1 @_ZNKSt3setISt4pairIxxESt4lessIS1_ESaIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(48) @q) #6
  br i1 %20, label %._crit_edge34, label %.lr.ph33

.lr.ph33:                                         ; preds = %._crit_edge
  %21 = getelementptr inbounds i8, ptr %5, i64 8
  %22 = getelementptr inbounds i8, ptr %10, i64 8
  br label %27

.lr.ph28:                                         ; preds = %.lr.ph28.preheader, %.lr.ph28
  %.02327 = phi i64 [ %24, %.lr.ph28 ], [ 0, %.lr.ph28.preheader ]
  %23 = getelementptr inbounds i64, ptr %1, i64 %.02327
  store i64 10000000000000, ptr %23, align 8, !tbaa !5
  %24 = add nuw nsw i64 %.02327, 1
  %25 = load i64, ptr @n, align 8, !tbaa !5
  %26 = icmp slt i64 %24, %25
  br i1 %26, label %.lr.ph28, label %._crit_edge, !llvm.loop !9

27:                                               ; preds = %.lr.ph33, %64
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #6
  %28 = call ptr @_ZNKSt3setISt4pairIxxESt4lessIS1_ESaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @q) #6
  store ptr %28, ptr %6, align 8
  %29 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt23_Rb_tree_const_iteratorISt4pairIxxEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %6) #6
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 8 dereferenceable(16) %29, i64 16, i1 false)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #6
  %30 = call noundef i64 @_ZNSt3setISt4pairIxxESt4lessIS1_ESaIS1_EE5eraseERKS1_(ptr noundef nonnull align 8 dereferenceable(48) @q, ptr noundef nonnull align 8 dereferenceable(16) %5)
  %31 = load i64, ptr %5, align 8, !tbaa !11
  %32 = load i64, ptr %21, align 8, !tbaa !13
  %33 = getelementptr inbounds [1010 x i64], ptr @vis, i64 0, i64 %32
  %34 = load i64, ptr %33, align 8, !tbaa !5
  %.not = icmp eq i64 %34, 0
  br i1 %.not, label %35, label %64, !llvm.loop !14

35:                                               ; preds = %27
  store i64 1, ptr %33, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #6
  %36 = getelementptr inbounds [1010 x %"class.std::vector"], ptr @g, i64 0, i64 %32
  %37 = call ptr @_ZNSt6vectorISt4pairIxS0_IxxEESaIS2_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %36) #6
  store ptr %37, ptr %7, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #6
  %38 = call ptr @_ZNSt6vectorISt4pairIxS0_IxxEESaIS2_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %36) #6
  store ptr %38, ptr %8, align 8
  %39 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPSt4pairIxS1_IxxEESt6vectorIS3_SaIS3_EEEEbRKNS_17__normal_iteratorIT_T0_EESD_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #6
  br i1 %39, label %.lr.ph30, label %._crit_edge31

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

.lr.ph30:                                         ; preds = %35, %60
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #6
  %40 = call noundef ptr @_ZNK9__gnu_cxx17__normal_iteratorIPSt4pairIxS1_IxxEESt6vectorIS3_SaIS3_EEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %7) #6
  %41 = load i64, ptr %40, align 8, !tbaa !15
  store i64 %41, ptr %9, align 8, !tbaa !5
  %42 = call noundef ptr @_ZNK9__gnu_cxx17__normal_iteratorIPSt4pairIxS1_IxxEESt6vectorIS3_SaIS3_EEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %7) #6
  %43 = getelementptr inbounds i8, ptr %42, i64 8
  %44 = load i64, ptr %43, align 8, !tbaa !17
  %45 = load i64, ptr %9, align 8, !tbaa !5
  %46 = getelementptr inbounds [1010 x i64], ptr @vis, i64 0, i64 %45
  %47 = load i64, ptr %46, align 8, !tbaa !5
  %48 = icmp ne i64 %47, 0
  %49 = icmp eq i64 %44, 0
  %or.cond = select i1 %48, i1 true, i1 %49
  br i1 %or.cond, label %60, label %50

50:                                               ; preds = %.lr.ph30
  %51 = add nsw i64 %44, %31
  %52 = getelementptr inbounds i64, ptr %1, i64 %45
  %53 = load i64, ptr %52, align 8, !tbaa !5
  %54 = icmp slt i64 %51, %53
  br i1 %54, label %55, label %60

55:                                               ; preds = %50
  store i64 %51, ptr %52, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %10) #6
  %56 = call { i64, i64 } @_ZSt9make_pairIRxS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8) %52, ptr noundef nonnull align 8 dereferenceable(8) %9)
  %57 = extractvalue { i64, i64 } %56, 0
  store i64 %57, ptr %10, align 8
  %58 = extractvalue { i64, i64 } %56, 1
  store i64 %58, ptr %22, align 8
  %59 = call { ptr, i8 } @_ZNSt3setISt4pairIxxESt4lessIS1_ESaIS1_EE6insertEOS1_(ptr noundef nonnull align 8 dereferenceable(48) @q, ptr noundef nonnull align 8 dereferenceable(16) %10)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %10) #6
  br label %60

60:                                               ; preds = %50, %55, %.lr.ph30
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #6
  %61 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN9__gnu_cxx17__normal_iteratorIPSt4pairIxS1_IxxEESt6vectorIS3_SaIS3_EEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %7) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #6
  %62 = call ptr @_ZNSt6vectorISt4pairIxS0_IxxEESaIS2_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %36) #6
  store ptr %62, ptr %8, align 8
  %63 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPSt4pairIxS1_IxxEESt6vectorIS3_SaIS3_EEEEbRKNS_17__normal_iteratorIT_T0_EESD_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #6
  br i1 %63, label %.lr.ph30, label %._crit_edge31, !llvm.loop !18

64:                                               ; preds = %27, %._crit_edge31
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #6
  %65 = call noundef zeroext i1 @_ZNKSt3setISt4pairIxxESt4lessIS1_ESaIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(48) @q) #6
  br i1 %65, label %._crit_edge34, label %27

._crit_edge34:                                    ; preds = %64, %._crit_edge
  ret void
}

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local { ptr, i8 } @_ZNSt3setISt4pairIxxESt4lessIS1_ESaIS1_EE6insertEOS1_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local { i64, i64 } @_ZSt9make_pairIRxS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0

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

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

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN9__gnu_cxxneIPSt4pairIxS1_IxxEESt6vectorIS3_SaIS3_EEEEbRKNS_17__normal_iteratorIT_T0_EESD_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #4

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

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

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

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

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


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