; LLVM IR from tangjz/acm-icpc :: codeforces/complete/936E.ll (Z9tree_initii)

; 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<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::pair" = type { i32, i32 }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }

@tot = external dso_local global i32, align 4
@ord = external dso_local global [300001 x i32], align 16
@idx = external dso_local global [19 x [300001 x i32]], align 16
@e = external dso_local global [300001 x %"class.std::vector"], align 16
@g = external dso_local global [300001 x %"class.std::vector"], align 16
@seg = external dso_local global [300001 x %"struct.std::pair"], align 16
@dis = external dso_local global [19 x [300001 x %"struct.std::pair"]], align 16
@banE = external dso_local global [300001 x i8], align 16
@banG = external dso_local global [300001 x i8], align 16

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z7getRooti(i32 noundef) #0

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

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

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

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

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

; 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 noundef nonnull align 8 dereferenceable(8) ptr @_ZN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEppEv(ptr noundef nonnull align 8 dereferenceable(8)) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z9tree_initii(i32 noundef %0, i32 noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca %"struct.std::pair", align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %16 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %17 = alloca ptr, align 8
  %18 = alloca %"struct.std::pair", align 4
  %19 = alloca i32, align 4
  %20 = alloca ptr, align 8
  %21 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %22 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %23 = alloca ptr, align 8
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !5
  %24 = load i32, ptr %4, align 4, !tbaa !5
  %25 = call noundef i32 @_Z7getRooti(i32 noundef %24)
  store i32 %25, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %26 = load i32, ptr %3, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [19 x [300001 x i32]], ptr @idx, i64 0, i64 %27
  %29 = getelementptr inbounds [300001 x i32], ptr %28, i64 0, i64 0
  store ptr %29, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %30 = load i32, ptr %3, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [19 x [300001 x %"struct.std::pair"]], ptr @dis, i64 0, i64 %31
  %33 = getelementptr inbounds [300001 x %"struct.std::pair"], ptr %32, i64 0, i64 0
  store ptr %33, ptr %6, align 8, !tbaa !9
  store i32 0, ptr @tot, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %34 = load i32, ptr %4, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [300001 x %"struct.std::pair"], ptr @seg, i64 0, i64 %35
  %37 = getelementptr inbounds %"struct.std::pair", ptr %36, i32 0, i32 0
  %38 = load i32, ptr %37, align 8, !tbaa !11
  store i32 %38, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 1, ptr %8, align 4, !tbaa !5
  br label %39

39:                                               ; preds = %68, %2
  %40 = load i32, ptr %7, align 4, !tbaa !5
  %41 = load i32, ptr %4, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [300001 x %"struct.std::pair"], ptr @seg, i64 0, i64 %42
  %44 = getelementptr inbounds %"struct.std::pair", ptr %43, i32 0, i32 1
  %45 = load i32, ptr %44, align 4, !tbaa !13
  %46 = icmp sle i32 %40, %45
  br i1 %46, label %48, label %47

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

48:                                               ; preds = %39
  %49 = load i32, ptr %7, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [300001 x i8], ptr @banE, i64 0, i64 %50
  store i8 1, ptr %51, align 1, !tbaa !14
  %52 = load i32, ptr %4, align 4, !tbaa !5
  %53 = load ptr, ptr %5, align 8, !tbaa !9
  %54 = load i32, ptr %7, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds i32, ptr %53, i64 %55
  store i32 %52, ptr %56, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 0, ptr %10, align 4, !tbaa !5
  %57 = call i64 @_ZSt9make_pairIiRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 4 dereferenceable(4) %8)
  store i64 %57, ptr %9, align 4
  %58 = load ptr, ptr %6, align 8, !tbaa !9
  %59 = load i32, ptr %7, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds %"struct.std::pair", ptr %58, i64 %60
  %62 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8) %61, ptr noundef nonnull align 4 dereferenceable(8) %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  %63 = load i32, ptr %7, align 4, !tbaa !5
  %64 = load i32, ptr @tot, align 4, !tbaa !5
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr @tot, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [300001 x i32], ptr @ord, i64 0, i64 %66
  store i32 %63, ptr %67, align 4, !tbaa !5
  br label %68

68:                                               ; preds = %48
  %69 = load i32, ptr %7, align 4, !tbaa !5
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %7, align 4, !tbaa !5
  %71 = load i32, ptr %8, align 4, !tbaa !5
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %8, align 4, !tbaa !5
  br label %39, !llvm.loop !16

73:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 1, ptr %11, align 4, !tbaa !5
  br label %74

74:                                               ; preds = %151, %73
  %75 = load i32, ptr %11, align 4, !tbaa !5
  %76 = load i32, ptr @tot, align 4, !tbaa !5
  %77 = icmp sle i32 %75, %76
  br i1 %77, label %79, label %78

78:                                               ; preds = %74
  store i32 5, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %154

79:                                               ; preds = %74
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %80 = load i32, ptr %11, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [300001 x i32], ptr @ord, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !5
  store i32 %83, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %84 = load i32, ptr %13, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [300001 x %"class.std::vector"], ptr @e, i64 0, i64 %85
  store ptr %86, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %87 = load ptr, ptr %14, align 8, !tbaa !9
  %88 = call ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %87) #4
  %89 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %15, i32 0, i32 0
  store ptr %88, ptr %89, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %90 = load ptr, ptr %14, align 8, !tbaa !9
  %91 = call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %90) #4
  %92 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %16, i32 0, i32 0
  store ptr %91, ptr %92, align 8
  br label %93

93:                                               ; preds = %148, %79
  %94 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESA_(ptr noundef nonnull align 8 dereferenceable(8) %15, ptr noundef nonnull align 8 dereferenceable(8) %16) #4
  br i1 %94, label %96, label %95

95:                                               ; preds = %93
  store i32 8, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  br label %150

96:                                               ; preds = %93
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  %97 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %15) #4
  store ptr %97, ptr %17, align 8, !tbaa !9
  %98 = load ptr, ptr %17, align 8, !tbaa !9
  %99 = load i32, ptr %98, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [300001 x i8], ptr @banE, i64 0, i64 %100
  %102 = load i8, ptr %101, align 1, !tbaa !14, !range !18, !noundef !19
  %103 = trunc i8 %102 to i1
  br i1 %103, label %112, label %104

104:                                              ; preds = %96
  %105 = load ptr, ptr %5, align 8, !tbaa !9
  %106 = load ptr, ptr %17, align 8, !tbaa !9
  %107 = load i32, ptr %106, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds i32, ptr %105, i64 %108
  %110 = load i32, ptr %109, align 4, !tbaa !5
  %111 = icmp ne i32 %110, 0
  br i1 %111, label %112, label %113

112:                                              ; preds = %104, %96
  store i32 9, ptr %12, align 4
  br label %145

113:                                              ; preds = %104
  %114 = load i32, ptr %4, align 4, !tbaa !5
  %115 = load ptr, ptr %5, align 8, !tbaa !9
  %116 = load ptr, ptr %17, align 8, !tbaa !9
  %117 = load i32, ptr %116, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds i32, ptr %115, i64 %118
  store i32 %114, ptr %119, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #4
  %120 = load ptr, ptr %6, align 8, !tbaa !9
  %121 = load i32, ptr %13, align 4, !tbaa !5
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds %"struct.std::pair", ptr %120, i64 %122
  %124 = getelementptr inbounds %"struct.std::pair", ptr %123, i32 0, i32 0
  %125 = load i32, ptr %124, align 4, !tbaa !11
  %126 = add nsw i32 %125, 1
  store i32 %126, ptr %19, align 4, !tbaa !5
  %127 = load ptr, ptr %6, align 8, !tbaa !9
  %128 = load i32, ptr %13, align 4, !tbaa !5
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds %"struct.std::pair", ptr %127, i64 %129
  %131 = getelementptr inbounds %"struct.std::pair", ptr %130, i32 0, i32 1
  %132 = call i64 @_ZSt9make_pairIiRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %19, ptr noundef nonnull align 4 dereferenceable(4) %131)
  store i64 %132, ptr %18, align 4
  %133 = load ptr, ptr %6, align 8, !tbaa !9
  %134 = load ptr, ptr %17, align 8, !tbaa !9
  %135 = load i32, ptr %134, align 4, !tbaa !5
  %136 = sext i32 %135 to i64
  %137 = getelementptr inbounds %"struct.std::pair", ptr %133, i64 %136
  %138 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8) %137, ptr noundef nonnull align 4 dereferenceable(8) %18) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #4
  %139 = load ptr, ptr %17, align 8, !tbaa !9
  %140 = load i32, ptr %139, align 4, !tbaa !5
  %141 = load i32, ptr @tot, align 4, !tbaa !5
  %142 = add nsw i32 %141, 1
  store i32 %142, ptr @tot, align 4, !tbaa !5
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds [300001 x i32], ptr @ord, i64 0, i64 %143
  store i32 %140, ptr %144, align 4, !tbaa !5
  store i32 0, ptr %12, align 4
  br label %145

145:                                              ; preds = %113, %112
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  %146 = load i32, ptr %12, align 4
  switch i32 %146, label %187 [
    i32 0, label %147
    i32 9, label %148
  ]

147:                                              ; preds = %145
  br label %148

148:                                              ; preds = %147, %145
  %149 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %15) #4
  br label %93

150:                                              ; preds = %95
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  br label %151

151:                                              ; preds = %150
  %152 = load i32, ptr %11, align 4, !tbaa !5
  %153 = add nsw i32 %152, 1
  store i32 %153, ptr %11, align 4, !tbaa !5
  br label %74, !llvm.loop !20

154:                                              ; preds = %78
  %155 = load i32, ptr %4, align 4, !tbaa !5
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds [300001 x i8], ptr @banG, i64 0, i64 %156
  store i8 1, ptr %157, align 1, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #4
  %158 = load i32, ptr %4, align 4, !tbaa !5
  %159 = sext i32 %158 to i64
  %160 = getelementptr inbounds [300001 x %"class.std::vector"], ptr @g, i64 0, i64 %159
  store ptr %160, ptr %20, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #4
  %161 = load ptr, ptr %20, align 8, !tbaa !9
  %162 = call ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %161) #4
  %163 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %21, i32 0, i32 0
  store ptr %162, ptr %163, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #4
  %164 = load ptr, ptr %20, align 8, !tbaa !9
  %165 = call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %164) #4
  %166 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %22, i32 0, i32 0
  store ptr %165, ptr %166, align 8
  br label %167

167:                                              ; preds = %184, %154
  %168 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESA_(ptr noundef nonnull align 8 dereferenceable(8) %21, ptr noundef nonnull align 8 dereferenceable(8) %22) #4
  br i1 %168, label %170, label %169

169:                                              ; preds = %167
  store i32 10, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #4
  br label %186

170:                                              ; preds = %167
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #4
  %171 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %21) #4
  store ptr %171, ptr %23, align 8, !tbaa !9
  %172 = load ptr, ptr %23, align 8, !tbaa !9
  %173 = load i32, ptr %172, align 4, !tbaa !5
  %174 = sext i32 %173 to i64
  %175 = getelementptr inbounds [300001 x i8], ptr @banG, i64 0, i64 %174
  %176 = load i8, ptr %175, align 1, !tbaa !14, !range !18, !noundef !19
  %177 = trunc i8 %176 to i1
  br i1 %177, label %183, label %178

178:                                              ; preds = %170
  %179 = load i32, ptr %3, align 4, !tbaa !5
  %180 = add nsw i32 %179, 1
  %181 = load ptr, ptr %23, align 8, !tbaa !9
  %182 = load i32, ptr %181, align 4, !tbaa !5
  call void @_Z9tree_initii(i32 noundef %180, i32 noundef %182)
  br label %183

183:                                              ; preds = %178, %170
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #4
  br label %184

184:                                              ; preds = %183
  %185 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %21) #4
  br label %167

186:                                              ; preds = %169
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret void

187:                                              ; preds = %145
  unreachable
}

; Function Attrs: mustprogress uwtable
declare dso_local i64 @_ZSt9make_pairIiRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 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 = { 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 #4 = { nounwind }

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

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


; 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<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::pair" = type { i32, i32 }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }

@tot = external dso_local local_unnamed_addr global i32, align 4
@ord = external dso_local local_unnamed_addr global [300001 x i32], align 16
@idx = external dso_local local_unnamed_addr global [19 x [300001 x i32]], align 16
@e = external dso_local global [300001 x %"class.std::vector"], align 16
@g = external dso_local global [300001 x %"class.std::vector"], align 16
@seg = external dso_local local_unnamed_addr global [300001 x %"struct.std::pair"], align 16
@dis = external dso_local global [19 x [300001 x %"struct.std::pair"]], align 16
@banE = external dso_local local_unnamed_addr global [300001 x i8], align 16
@banG = external dso_local local_unnamed_addr global [300001 x i8], align 16

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z7getRooti(i32 noundef) local_unnamed_addr #0

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

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

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

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

; 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 noundef nonnull align 8 dereferenceable(8) ptr @_ZN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEppEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z9tree_initii(i32 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = alloca i32, align 4
  %4 = alloca %"struct.std::pair", align 8
  %5 = alloca i32, align 4
  %6 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %7 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %8 = alloca %"struct.std::pair", align 8
  %9 = alloca i32, align 4
  %10 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %11 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %12 = tail call noundef i32 @_Z7getRooti(i32 noundef %1)
  %13 = sext i32 %0 to i64
  %14 = getelementptr inbounds [19 x [300001 x i32]], ptr @idx, i64 0, i64 %13
  %15 = getelementptr inbounds [19 x [300001 x %"struct.std::pair"]], ptr @dis, i64 0, i64 %13
  store i32 0, ptr @tot, align 4, !tbaa !5
  %16 = sext i32 %12 to i64
  %17 = getelementptr inbounds [300001 x %"struct.std::pair"], ptr @seg, i64 0, i64 %16
  %18 = load i32, ptr %17, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #4
  %19 = getelementptr inbounds i8, ptr %17, i64 4
  store i32 1, ptr %3, align 4, !tbaa !5
  %20 = load i32, ptr %19, align 4, !tbaa !11
  %.not42 = icmp sgt i32 %18, %20
  br i1 %.not42, label %._crit_edge.thread, label %.lr.ph.preheader

._crit_edge.thread:                               ; preds = %2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #4
  br label %._crit_edge51

.lr.ph.preheader:                                 ; preds = %2
  %21 = sext i32 %18 to i64
  br label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph
  %22 = icmp slt i32 %28, 0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #4
  br i1 %22, label %._crit_edge51, label %.lr.ph50

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %21, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %23 = getelementptr inbounds [300001 x i8], ptr @banE, i64 0, i64 %indvars.iv
  store i8 1, ptr %23, align 1, !tbaa !12
  %24 = getelementptr inbounds i32, ptr %14, i64 %indvars.iv
  store i32 %12, ptr %24, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #4
  store i32 0, ptr %5, align 4, !tbaa !5
  %25 = call i64 @_ZSt9make_pairIiRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %3)
  store i64 %25, ptr %4, align 8
  %26 = getelementptr inbounds %"struct.std::pair", ptr %15, i64 %indvars.iv
  %27 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8) %26, ptr noundef nonnull align 4 dereferenceable(8) %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  %28 = load i32, ptr @tot, align 4, !tbaa !5
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr @tot, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [300001 x i32], ptr @ord, i64 0, i64 %30
  %32 = trunc nsw i64 %indvars.iv to i32
  store i32 %32, ptr %31, align 4, !tbaa !5
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %33 = load i32, ptr %3, align 4, !tbaa !5
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %3, align 4, !tbaa !5
  %35 = load i32, ptr %19, align 4, !tbaa !11
  %36 = sext i32 %35 to i64
  %.not.not = icmp slt i64 %indvars.iv, %36
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !14

._crit_edge51:                                    ; preds = %._crit_edge46, %._crit_edge.thread, %._crit_edge
  %37 = getelementptr inbounds [300001 x i8], ptr @banG, i64 0, i64 %16
  store i8 1, ptr %37, align 1, !tbaa !12
  %38 = getelementptr inbounds [300001 x %"class.std::vector"], ptr @g, i64 0, i64 %16
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #4
  %39 = call ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %38) #4
  store ptr %39, ptr %10, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %11) #4
  %40 = call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %38) #4
  store ptr %40, ptr %11, align 8
  %41 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESA_(ptr noundef nonnull align 8 dereferenceable(8) %10, ptr noundef nonnull align 8 dereferenceable(8) %11) #4
  br i1 %41, label %.lr.ph53, label %._crit_edge54

.lr.ph53:                                         ; preds = %._crit_edge51
  %42 = add nsw i32 %0, 1
  br label %80

.lr.ph50:                                         ; preds = %._crit_edge, %._crit_edge46
  %indvars.iv56 = phi i64 [ %indvars.iv.next57, %._crit_edge46 ], [ 1, %._crit_edge ]
  %43 = getelementptr inbounds [300001 x i32], ptr @ord, i64 0, i64 %indvars.iv56
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [300001 x %"class.std::vector"], ptr @e, i64 0, i64 %45
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #4
  %47 = call ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %46) #4
  store ptr %47, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #4
  %48 = call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %46) #4
  store ptr %48, ptr %7, align 8
  %49 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESA_(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(8) %7) #4
  br i1 %49, label %.lr.ph45, label %._crit_edge46

.lr.ph45:                                         ; preds = %.lr.ph50
  %50 = getelementptr inbounds %"struct.std::pair", ptr %15, i64 %45
  %51 = getelementptr inbounds i8, ptr %50, i64 4
  br label %54

._crit_edge46:                                    ; preds = %77, %.lr.ph50
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #4
  %indvars.iv.next57 = add nuw nsw i64 %indvars.iv56, 1
  %52 = load i32, ptr @tot, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %.not40.not = icmp slt i64 %indvars.iv56, %53
  br i1 %.not40.not, label %.lr.ph50, label %._crit_edge51, !llvm.loop !16

54:                                               ; preds = %.lr.ph45, %77
  %55 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %6) #4
  %56 = load i32, ptr %55, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [300001 x i8], ptr @banE, i64 0, i64 %57
  %59 = load i8, ptr %58, align 1, !tbaa !12, !range !17, !noundef !18
  %60 = trunc nuw i8 %59 to i1
  br i1 %60, label %77, label %61

61:                                               ; preds = %54
  %62 = getelementptr inbounds i32, ptr %14, i64 %57
  %63 = load i32, ptr %62, align 4, !tbaa !5
  %.not41 = icmp eq i32 %63, 0
  br i1 %.not41, label %64, label %77

64:                                               ; preds = %61
  store i32 %12, ptr %62, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #4
  %65 = load i32, ptr %50, align 8, !tbaa !9
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %9, align 4, !tbaa !5
  %67 = call i64 @_ZSt9make_pairIiRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %9, ptr noundef nonnull align 4 dereferenceable(4) %51)
  store i64 %67, ptr %8, align 8
  %68 = load i32, ptr %55, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds %"struct.std::pair", ptr %15, i64 %69
  %71 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8) %70, ptr noundef nonnull align 4 dereferenceable(8) %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #4
  %72 = load i32, ptr %55, align 4, !tbaa !5
  %73 = load i32, ptr @tot, align 4, !tbaa !5
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr @tot, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [300001 x i32], ptr @ord, i64 0, i64 %75
  store i32 %72, ptr %76, align 4, !tbaa !5
  br label %77

77:                                               ; preds = %54, %61, %64
  %78 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %6) #4
  %79 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESA_(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(8) %7) #4
  br i1 %79, label %54, label %._crit_edge46

._crit_edge54:                                    ; preds = %88, %._crit_edge51
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #4
  ret void

80:                                               ; preds = %.lr.ph53, %88
  %81 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %10) #4
  %82 = load i32, ptr %81, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [300001 x i8], ptr @banG, i64 0, i64 %83
  %85 = load i8, ptr %84, align 1, !tbaa !12, !range !17, !noundef !18
  %86 = trunc nuw i8 %85 to i1
  br i1 %86, label %88, label %87

87:                                               ; preds = %80
  call void @_Z9tree_initii(i32 noundef %42, i32 noundef %82)
  br label %88

88:                                               ; preds = %87, %80
  %89 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %10) #4
  %90 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESA_(ptr noundef nonnull align 8 dereferenceable(8) %10, ptr noundef nonnull align 8 dereferenceable(8) %11) #4
  br i1 %90, label %80, label %._crit_edge54
}

; Function Attrs: mustprogress uwtable
declare dso_local i64 @_ZSt9make_pairIiRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #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 = { 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 = { 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 #4 = { nounwind }

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

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


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