; LLVM IR from tangjz/acm-icpc :: codechef/SEPT13/TMP01.ll (Z6removev)

; 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"

%struct.Node = type { i32, i32, i32, i32, %"class.std::map" }
%"class.std::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<char, std::pair<const char, int>, std::_Select1st<std::pair<const char, int>>, std::less<char>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<char, std::pair<const char, int>, std::_Select1st<std::pair<const char, int>>, std::less<char>>::_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 }

@len = external dso_local global i32, align 4
@rt = external dso_local global i32, align 4
@curP = external dso_local global i32, align 4
@curC = external dso_local global i32, align 4
@curL = external dso_local global i32, align 4
@rem = external dso_local global i32, align 4
@que = external dso_local global [1000001 x i32], align 16
@qL = external dso_local global i32, align 4
@qR = external dso_local global i32, align 4
@sum = external dso_local global i64, align 8
@e = external dso_local global [2000003 x %struct.Node], align 16
@buf = external dso_local global [1000001 x i8], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z7newNodeiii(i32 noundef, i32 noundef, 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN4Node4nextEc(ptr noundef nonnull align 8 dereferenceable(64), i8 noundef signext) #2 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z6removev() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = load i32, ptr @curL, align 4, !tbaa !5
  %6 = icmp ne i32 %5, 0
  br i1 %6, label %7, label %72

7:                                                ; preds = %0
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  %8 = load i32, ptr @curP, align 4, !tbaa !5
  %9 = sext i32 %8 to i64
  %10 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %9
  %11 = load i32, ptr @curC, align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds [1000001 x i8], ptr @buf, i64 0, i64 %12
  %14 = load i8, ptr %13, align 1, !tbaa !9
  %15 = call noundef i32 @_ZN4Node4nextEc(ptr noundef nonnull align 8 dereferenceable(64) %10, i8 noundef signext %14)
  store i32 %15, ptr %1, align 4, !tbaa !5
  br label %16

16:                                               ; preds = %35, %7
  %17 = load i32, ptr %1, align 4, !tbaa !5
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %33

19:                                               ; preds = %16
  %20 = load i32, ptr @curL, align 4, !tbaa !5
  %21 = load i32, ptr %1, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %22
  %24 = getelementptr inbounds %struct.Node, ptr %23, i32 0, i32 1
  %25 = load i32, ptr %24, align 4, !tbaa !10
  %26 = load i32, ptr %1, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %27
  %29 = getelementptr inbounds %struct.Node, ptr %28, i32 0, i32 0
  %30 = load i32, ptr %29, align 16, !tbaa !22
  %31 = sub nsw i32 %25, %30
  %32 = icmp sge i32 %20, %31
  br label %33

33:                                               ; preds = %19, %16
  %34 = phi i1 [ false, %16 ], [ %32, %19 ]
  br i1 %34, label %35, label %71

35:                                               ; preds = %33
  %36 = load i32, ptr %1, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %37
  %39 = getelementptr inbounds %struct.Node, ptr %38, i32 0, i32 1
  %40 = load i32, ptr %39, align 4, !tbaa !10
  %41 = load i32, ptr %1, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %42
  %44 = getelementptr inbounds %struct.Node, ptr %43, i32 0, i32 0
  %45 = load i32, ptr %44, align 16, !tbaa !22
  %46 = sub nsw i32 %40, %45
  %47 = load i32, ptr @curC, align 4, !tbaa !5
  %48 = add nsw i32 %47, %46
  store i32 %48, ptr @curC, align 4, !tbaa !5
  %49 = load i32, ptr %1, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %50
  %52 = getelementptr inbounds %struct.Node, ptr %51, i32 0, i32 1
  %53 = load i32, ptr %52, align 4, !tbaa !10
  %54 = load i32, ptr %1, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %55
  %57 = getelementptr inbounds %struct.Node, ptr %56, i32 0, i32 0
  %58 = load i32, ptr %57, align 16, !tbaa !22
  %59 = sub nsw i32 %53, %58
  %60 = load i32, ptr @curL, align 4, !tbaa !5
  %61 = sub nsw i32 %60, %59
  store i32 %61, ptr @curL, align 4, !tbaa !5
  %62 = load i32, ptr %1, align 4, !tbaa !5
  store i32 %62, ptr @curP, align 4, !tbaa !5
  %63 = load i32, ptr @curP, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %64
  %66 = load i32, ptr @curC, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [1000001 x i8], ptr @buf, i64 0, i64 %67
  %69 = load i8, ptr %68, align 1, !tbaa !9
  %70 = call noundef i32 @_ZN4Node4nextEc(ptr noundef nonnull align 8 dereferenceable(64) %65, i8 noundef signext %69)
  store i32 %70, ptr %1, align 4, !tbaa !5
  br label %16, !llvm.loop !23

71:                                               ; preds = %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  br label %72

72:                                               ; preds = %71, %0
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  %73 = load i32, ptr @qL, align 4, !tbaa !5
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr @qL, align 4, !tbaa !5
  %75 = sext i32 %73 to i64
  %76 = getelementptr inbounds [1000001 x i32], ptr @que, i64 0, i64 %75
  %77 = load i32, ptr %76, align 4, !tbaa !5
  store i32 %77, ptr %2, align 4, !tbaa !5
  br label %78

78:                                               ; preds = %92, %72
  %79 = load i32, ptr %2, align 4, !tbaa !5
  %80 = load i32, ptr @curP, align 4, !tbaa !5
  %81 = icmp ne i32 %79, %80
  br i1 %81, label %82, label %90

82:                                               ; preds = %78
  %83 = load i32, ptr %2, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %84
  %86 = getelementptr inbounds %struct.Node, ptr %85, i32 0, i32 4
  %87 = call noundef i64 @_ZNKSt3mapIciSt4lessIcESaISt4pairIKciEEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48) %86) #3
  %88 = icmp ne i64 %87, 0
  %89 = xor i1 %88, true
  br label %90

90:                                               ; preds = %82, %78
  %91 = phi i1 [ false, %78 ], [ %89, %82 ]
  br i1 %91, label %92, label %128

92:                                               ; preds = %90
  %93 = load i32, ptr %2, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %94
  %96 = getelementptr inbounds %struct.Node, ptr %95, i32 0, i32 2
  %97 = load i32, ptr %96, align 8, !tbaa !25
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %98
  %100 = getelementptr inbounds %struct.Node, ptr %99, i32 0, i32 4
  %101 = load i32, ptr %2, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %102
  %104 = getelementptr inbounds %struct.Node, ptr %103, i32 0, i32 0
  %105 = load i32, ptr %104, align 16, !tbaa !22
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [1000001 x i8], ptr @buf, i64 0, i64 %106
  %108 = call noundef i64 @_ZNSt3mapIciSt4lessIcESaISt4pairIKciEEE5eraseERS3_(ptr noundef nonnull align 8 dereferenceable(48) %100, ptr noundef nonnull align 1 dereferenceable(1) %107)
  %109 = load i32, ptr %2, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %110
  %112 = getelementptr inbounds %struct.Node, ptr %111, i32 0, i32 1
  %113 = load i32, ptr %112, align 4, !tbaa !10
  %114 = load i32, ptr %2, align 4, !tbaa !5
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %115
  %117 = getelementptr inbounds %struct.Node, ptr %116, i32 0, i32 0
  %118 = load i32, ptr %117, align 16, !tbaa !22
  %119 = sub nsw i32 %113, %118
  %120 = sext i32 %119 to i64
  %121 = load i64, ptr @sum, align 8, !tbaa !26
  %122 = sub nsw i64 %121, %120
  store i64 %122, ptr @sum, align 8, !tbaa !26
  %123 = load i32, ptr %2, align 4, !tbaa !5
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %124
  %126 = getelementptr inbounds %struct.Node, ptr %125, i32 0, i32 2
  %127 = load i32, ptr %126, align 8, !tbaa !25
  store i32 %127, ptr %2, align 4, !tbaa !5
  br label %78, !llvm.loop !28

128:                                              ; preds = %90
  %129 = load i32, ptr @rem, align 4, !tbaa !5
  %130 = icmp ne i32 %129, 0
  br i1 %130, label %131, label %252

131:                                              ; preds = %128
  %132 = load i32, ptr %2, align 4, !tbaa !5
  %133 = load i32, ptr @curP, align 4, !tbaa !5
  %134 = icmp eq i32 %132, %133
  br i1 %134, label %135, label %252

135:                                              ; preds = %131
  %136 = load i32, ptr @curL, align 4, !tbaa !5
  %137 = icmp ne i32 %136, 0
  br i1 %137, label %181, label %138

138:                                              ; preds = %135
  %139 = load i32, ptr %2, align 4, !tbaa !5
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %140
  %142 = getelementptr inbounds %struct.Node, ptr %141, i32 0, i32 4
  %143 = call noundef i64 @_ZNKSt3mapIciSt4lessIcESaISt4pairIKciEEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48) %142) #3
  %144 = icmp ne i64 %143, 0
  br i1 %144, label %181, label %145

145:                                              ; preds = %138
  %146 = load i32, ptr %2, align 4, !tbaa !5
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %147
  %149 = getelementptr inbounds %struct.Node, ptr %148, i32 0, i32 1
  %150 = load i32, ptr %149, align 4, !tbaa !10
  %151 = icmp slt i32 %150, 1000001
  br i1 %151, label %152, label %180

152:                                              ; preds = %145
  %153 = load i32, ptr @len, align 4, !tbaa !5
  %154 = load i32, ptr %2, align 4, !tbaa !5
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %155
  %157 = getelementptr inbounds %struct.Node, ptr %156, i32 0, i32 1
  %158 = load i32, ptr %157, align 4, !tbaa !10
  %159 = sub nsw i32 %153, %158
  %160 = load i32, ptr %2, align 4, !tbaa !5
  %161 = sext i32 %160 to i64
  %162 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %161
  %163 = getelementptr inbounds %struct.Node, ptr %162, i32 0, i32 0
  %164 = load i32, ptr %163, align 16, !tbaa !22
  %165 = add nsw i32 %164, %159
  store i32 %165, ptr %163, align 16, !tbaa !22
  %166 = load i32, ptr %2, align 4, !tbaa !5
  %167 = sext i32 %166 to i64
  %168 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %167
  %169 = getelementptr inbounds %struct.Node, ptr %168, i32 0, i32 1
  store i32 1000001, ptr %169, align 4, !tbaa !10
  %170 = load i32, ptr @len, align 4, !tbaa !5
  %171 = sub nsw i32 1000001, %170
  %172 = sext i32 %171 to i64
  %173 = load i64, ptr @sum, align 8, !tbaa !26
  %174 = add nsw i64 %173, %172
  store i64 %174, ptr @sum, align 8, !tbaa !26
  %175 = load i32, ptr %2, align 4, !tbaa !5
  %176 = load i32, ptr @qR, align 4, !tbaa !5
  %177 = add nsw i32 %176, 1
  store i32 %177, ptr @qR, align 4, !tbaa !5
  %178 = sext i32 %176 to i64
  %179 = getelementptr inbounds [1000001 x i32], ptr @que, i64 0, i64 %178
  store i32 %175, ptr %179, align 4, !tbaa !5
  br label %180

180:                                              ; preds = %152, %145
  br label %230

181:                                              ; preds = %138, %135
  %182 = load i32, ptr @curC, align 4, !tbaa !5
  %183 = load i32, ptr @len, align 4, !tbaa !5
  %184 = icmp slt i32 %182, %183
  br i1 %184, label %185, label %228

185:                                              ; preds = %181
  %186 = load i32, ptr %2, align 4, !tbaa !5
  %187 = sext i32 %186 to i64
  %188 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %187
  %189 = load i32, ptr @curC, align 4, !tbaa !5
  %190 = sext i32 %189 to i64
  %191 = getelementptr inbounds [1000001 x i8], ptr @buf, i64 0, i64 %190
  %192 = load i8, ptr %191, align 1, !tbaa !9
  %193 = call noundef i32 @_ZN4Node4nextEc(ptr noundef nonnull align 8 dereferenceable(64) %188, i8 noundef signext %192)
  %194 = icmp ne i32 %193, 0
  br i1 %194, label %228, label %195

195:                                              ; preds = %185
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  %196 = load i32, ptr @len, align 4, !tbaa !5
  %197 = load i32, ptr @curL, align 4, !tbaa !5
  %198 = sub nsw i32 %196, %197
  %199 = load i32, ptr %2, align 4, !tbaa !5
  %200 = call noundef i32 @_Z7newNodeiii(i32 noundef %198, i32 noundef 1000001, i32 noundef %199)
  %201 = load i32, ptr %2, align 4, !tbaa !5
  %202 = sext i32 %201 to i64
  %203 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %202
  %204 = getelementptr inbounds %struct.Node, ptr %203, i32 0, i32 4
  %205 = load i32, ptr @curC, align 4, !tbaa !5
  %206 = sext i32 %205 to i64
  %207 = getelementptr inbounds [1000001 x i8], ptr @buf, i64 0, i64 %206
  %208 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIciSt4lessIcESaISt4pairIKciEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) %204, ptr noundef nonnull align 1 dereferenceable(1) %207)
  store i32 %200, ptr %208, align 4, !tbaa !5
  store i32 %200, ptr %3, align 4, !tbaa !5
  %209 = load i32, ptr %3, align 4, !tbaa !5
  %210 = sext i32 %209 to i64
  %211 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %210
  %212 = getelementptr inbounds %struct.Node, ptr %211, i32 0, i32 1
  %213 = load i32, ptr %212, align 4, !tbaa !10
  %214 = load i32, ptr %3, align 4, !tbaa !5
  %215 = sext i32 %214 to i64
  %216 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %215
  %217 = getelementptr inbounds %struct.Node, ptr %216, i32 0, i32 0
  %218 = load i32, ptr %217, align 16, !tbaa !22
  %219 = sub nsw i32 %213, %218
  %220 = sext i32 %219 to i64
  %221 = load i64, ptr @sum, align 8, !tbaa !26
  %222 = add nsw i64 %221, %220
  store i64 %222, ptr @sum, align 8, !tbaa !26
  %223 = load i32, ptr %3, align 4, !tbaa !5
  %224 = load i32, ptr @qR, align 4, !tbaa !5
  %225 = add nsw i32 %224, 1
  store i32 %225, ptr @qR, align 4, !tbaa !5
  %226 = sext i32 %224 to i64
  %227 = getelementptr inbounds [1000001 x i32], ptr @que, i64 0, i64 %226
  store i32 %223, ptr %227, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %229

228:                                              ; preds = %185, %181
  store i32 1, ptr %4, align 4
  br label %253

229:                                              ; preds = %195
  br label %230

230:                                              ; preds = %229, %180
  %231 = load i32, ptr @curP, align 4, !tbaa !5
  %232 = load i32, ptr @rt, align 4, !tbaa !5
  %233 = icmp eq i32 %231, %232
  br i1 %233, label %234, label %242

234:                                              ; preds = %230
  %235 = load i32, ptr @curL, align 4, !tbaa !5
  %236 = icmp ne i32 %235, 0
  br i1 %236, label %237, label %242

237:                                              ; preds = %234
  %238 = load i32, ptr @curL, align 4, !tbaa !5
  %239 = add nsw i32 %238, -1
  store i32 %239, ptr @curL, align 4, !tbaa !5
  %240 = load i32, ptr @curC, align 4, !tbaa !5
  %241 = add nsw i32 %240, 1
  store i32 %241, ptr @curC, align 4, !tbaa !5
  br label %248

242:                                              ; preds = %234, %230
  %243 = load i32, ptr @curP, align 4, !tbaa !5
  %244 = sext i32 %243 to i64
  %245 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %244
  %246 = getelementptr inbounds %struct.Node, ptr %245, i32 0, i32 3
  %247 = load i32, ptr %246, align 4, !tbaa !29
  store i32 %247, ptr @curP, align 4, !tbaa !5
  br label %248

248:                                              ; preds = %242, %237
  %249 = phi ptr [ @curC, %237 ], [ @curP, %242 ]
  %250 = load i32, ptr @rem, align 4, !tbaa !5
  %251 = add nsw i32 %250, -1
  store i32 %251, ptr @rem, align 4, !tbaa !5
  br label %252

252:                                              ; preds = %248, %131, %128
  store i32 0, ptr %4, align 4
  br label %253

253:                                              ; preds = %252, %228
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  %254 = load i32, ptr %4, align 4
  switch i32 %254, label %256 [
    i32 0, label %255
    i32 1, label %255
  ]

255:                                              ; preds = %253, %253
  ret void

256:                                              ; preds = %253
  unreachable
}

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

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !6, i64 4}
!11 = !{!"_ZTS4Node", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !12, i64 16}
!12 = !{!"_ZTSSt3mapIciSt4lessIcESaISt4pairIKciEEE", !13, i64 0}
!13 = !{!"_ZTSSt8_Rb_treeIcSt4pairIKciESt10_Select1stIS2_ESt4lessIcESaIS2_EE", !14, i64 0}
!14 = !{!"_ZTSNSt8_Rb_treeIcSt4pairIKciESt10_Select1stIS2_ESt4lessIcESaIS2_EE13_Rb_tree_implIS6_Lb1EEE", !15, i64 0, !17, i64 8}
!15 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessIcEE", !16, i64 0}
!16 = !{!"_ZTSSt4lessIcE"}
!17 = !{!"_ZTSSt15_Rb_tree_header", !18, i64 0, !21, i64 32}
!18 = !{!"_ZTSSt18_Rb_tree_node_base", !19, i64 0, !20, i64 8, !20, i64 16, !20, i64 24}
!19 = !{!"_ZTSSt14_Rb_tree_color", !7, i64 0}
!20 = !{!"any pointer", !7, i64 0}
!21 = !{!"long", !7, i64 0}
!22 = !{!11, !6, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!11, !6, i64 8}
!26 = !{!27, !27, i64 0}
!27 = !{!"long long", !7, i64 0}
!28 = distinct !{!28, !24}
!29 = !{!11, !6, i64 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"

%struct.Node = type { i32, i32, i32, i32, %"class.std::map" }
%"class.std::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<char, std::pair<const char, int>, std::_Select1st<std::pair<const char, int>>, std::less<char>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<char, std::pair<const char, int>, std::_Select1st<std::pair<const char, int>>, std::less<char>>::_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 }

@len = external dso_local local_unnamed_addr global i32, align 4
@rt = external dso_local local_unnamed_addr global i32, align 4
@curP = external dso_local local_unnamed_addr global i32, align 4
@curC = external dso_local local_unnamed_addr global i32, align 4
@curL = external dso_local local_unnamed_addr global i32, align 4
@rem = external dso_local local_unnamed_addr global i32, align 4
@que = external dso_local local_unnamed_addr global [1000001 x i32], align 16
@qL = external dso_local local_unnamed_addr global i32, align 4
@qR = external dso_local local_unnamed_addr global i32, align 4
@sum = external dso_local local_unnamed_addr global i64, align 8
@e = external dso_local global [2000003 x %struct.Node], align 16
@buf = external dso_local global [1000001 x i8], align 16

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN4Node4nextEc(ptr noundef nonnull align 8 dereferenceable(64), i8 noundef signext) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z6removev() local_unnamed_addr #1 {
  %1 = load i32, ptr @curL, align 4, !tbaa !5
  %.not = icmp eq i32 %1, 0
  br i1 %.not, label %.critedge, label %2

2:                                                ; preds = %0
  %3 = load i32, ptr @curP, align 4, !tbaa !5
  %4 = sext i32 %3 to i64
  %5 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %4
  %6 = load i32, ptr @curC, align 4, !tbaa !5
  %7 = sext i32 %6 to i64
  %8 = getelementptr inbounds [1000001 x i8], ptr @buf, i64 0, i64 %7
  %9 = load i8, ptr %8, align 1, !tbaa !9
  %10 = tail call noundef i32 @_ZN4Node4nextEc(ptr noundef nonnull align 8 dereferenceable(64) %5, i8 noundef signext %9)
  %.not3648 = icmp eq i32 %10, 0
  br i1 %.not3648, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %2, %18
  %.049 = phi i32 [ %25, %18 ], [ %10, %2 ]
  %11 = load i32, ptr @curL, align 4, !tbaa !5
  %12 = sext i32 %.049 to i64
  %13 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %12
  %14 = getelementptr inbounds i8, ptr %13, i64 4
  %15 = load i32, ptr %14, align 4, !tbaa !10
  %16 = load i32, ptr %13, align 16, !tbaa !22
  %17 = sub nsw i32 %15, %16
  %.not37 = icmp slt i32 %11, %17
  br i1 %.not37, label %.critedge, label %18

18:                                               ; preds = %.lr.ph
  %19 = load i32, ptr @curC, align 4, !tbaa !5
  %20 = add nsw i32 %19, %17
  store i32 %20, ptr @curC, align 4, !tbaa !5
  %.neg = sub i32 %11, %15
  %21 = add i32 %.neg, %16
  store i32 %21, ptr @curL, align 4, !tbaa !5
  store i32 %.049, ptr @curP, align 4, !tbaa !5
  %22 = sext i32 %20 to i64
  %23 = getelementptr inbounds [1000001 x i8], ptr @buf, i64 0, i64 %22
  %24 = load i8, ptr %23, align 1, !tbaa !9
  %25 = tail call noundef i32 @_ZN4Node4nextEc(ptr noundef nonnull align 8 dereferenceable(64) %13, i8 noundef signext %24)
  %.not36 = icmp eq i32 %25, 0
  br i1 %.not36, label %.critedge, label %.lr.ph, !llvm.loop !23

.critedge:                                        ; preds = %18, %.lr.ph, %2, %0
  %26 = load i32, ptr @qL, align 4, !tbaa !5
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr @qL, align 4, !tbaa !5
  %28 = sext i32 %26 to i64
  %29 = getelementptr inbounds [1000001 x i32], ptr @que, i64 0, i64 %28
  %.03151 = load i32, ptr %29, align 4, !tbaa !5
  %30 = load i32, ptr @curP, align 4
  %.not3852 = icmp eq i32 %.03151, %30
  br i1 %.not3852, label %.critedge2, label %.lr.ph54

.lr.ph54:                                         ; preds = %.critedge, %35
  %.03153 = phi i32 [ %.031, %35 ], [ %.03151, %.critedge ]
  %31 = sext i32 %.03153 to i64
  %32 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %31
  %33 = getelementptr inbounds i8, ptr %32, i64 16
  %34 = tail call noundef i64 @_ZNKSt3mapIciSt4lessIcESaISt4pairIKciEEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48) %33) #2
  %.not39 = icmp eq i64 %34, 0
  br i1 %.not39, label %35, label %.lr.ph54..critedge2.loopexit_crit_edge

.lr.ph54..critedge2.loopexit_crit_edge:           ; preds = %.lr.ph54
  %.pre.pre = load i32, ptr @curP, align 4
  br label %.critedge2

35:                                               ; preds = %.lr.ph54
  %36 = getelementptr inbounds i8, ptr %32, i64 8
  %37 = load i32, ptr %36, align 8, !tbaa !25
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %38, i32 4
  %40 = load i32, ptr %32, align 16, !tbaa !22
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [1000001 x i8], ptr @buf, i64 0, i64 %41
  %43 = tail call noundef i64 @_ZNSt3mapIciSt4lessIcESaISt4pairIKciEEE5eraseERS3_(ptr noundef nonnull align 8 dereferenceable(48) %39, ptr noundef nonnull align 1 dereferenceable(1) %42)
  %44 = getelementptr inbounds i8, ptr %32, i64 4
  %45 = load i32, ptr %44, align 4, !tbaa !10
  %46 = load i32, ptr %32, align 16, !tbaa !22
  %47 = sub nsw i32 %45, %46
  %48 = sext i32 %47 to i64
  %49 = load i64, ptr @sum, align 8, !tbaa !26
  %50 = sub nsw i64 %49, %48
  store i64 %50, ptr @sum, align 8, !tbaa !26
  %.031 = load i32, ptr %36, align 8, !tbaa !5
  %51 = load i32, ptr @curP, align 4
  %.not38 = icmp eq i32 %.031, %51
  br i1 %.not38, label %.critedge2, label %.lr.ph54, !llvm.loop !28

.critedge2:                                       ; preds = %35, %.lr.ph54..critedge2.loopexit_crit_edge, %.critedge
  %52 = phi i32 [ %.03151, %.critedge ], [ %.pre.pre, %.lr.ph54..critedge2.loopexit_crit_edge ], [ %.031, %35 ]
  %.031.lcssa = phi i32 [ %.03151, %.critedge ], [ %.03153, %.lr.ph54..critedge2.loopexit_crit_edge ], [ %.031, %35 ]
  %53 = load i32, ptr @rem, align 4, !tbaa !5
  %.not40 = icmp ne i32 %53, 0
  %54 = icmp eq i32 %.031.lcssa, %52
  %or.cond45 = select i1 %.not40, i1 %54, i1 false
  br i1 %or.cond45, label %55, label %123

55:                                               ; preds = %.critedge2
  %56 = load i32, ptr @curL, align 4, !tbaa !5
  %.not41 = icmp eq i32 %56, 0
  br i1 %.not41, label %57, label %72

57:                                               ; preds = %55
  %58 = sext i32 %52 to i64
  %59 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %58
  %60 = getelementptr inbounds i8, ptr %59, i64 16
  %61 = tail call noundef i64 @_ZNKSt3mapIciSt4lessIcESaISt4pairIKciEEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48) %60) #2
  %.not42 = icmp eq i64 %61, 0
  br i1 %.not42, label %62, label %72

62:                                               ; preds = %57
  %63 = getelementptr inbounds i8, ptr %59, i64 4
  %64 = load i32, ptr %63, align 4, !tbaa !10
  %65 = icmp slt i32 %64, 1000001
  br i1 %65, label %66, label %106

66:                                               ; preds = %62
  %67 = load i32, ptr @len, align 4, !tbaa !5
  %68 = sub i32 %67, %64
  %69 = load i32, ptr %59, align 16, !tbaa !22
  %70 = add nsw i32 %68, %69
  store i32 %70, ptr %59, align 16, !tbaa !22
  store i32 1000001, ptr %63, align 4, !tbaa !10
  %71 = sub nsw i32 1000001, %67
  br label %.sink.split

72:                                               ; preds = %57, %55
  %73 = load i32, ptr @curC, align 4, !tbaa !5
  %74 = load i32, ptr @len, align 4, !tbaa !5
  %75 = icmp slt i32 %73, %74
  br i1 %75, label %76, label %123

76:                                               ; preds = %72
  %77 = sext i32 %52 to i64
  %78 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %77
  %79 = sext i32 %73 to i64
  %80 = getelementptr inbounds [1000001 x i8], ptr @buf, i64 0, i64 %79
  %81 = load i8, ptr %80, align 1, !tbaa !9
  %82 = tail call noundef i32 @_ZN4Node4nextEc(ptr noundef nonnull align 8 dereferenceable(64) %78, i8 noundef signext %81)
  %.not43 = icmp eq i32 %82, 0
  br i1 %.not43, label %83, label %123

83:                                               ; preds = %76
  %84 = load i32, ptr @len, align 4, !tbaa !5
  %85 = load i32, ptr @curL, align 4, !tbaa !5
  %86 = sub nsw i32 %84, %85
  %87 = tail call noundef i32 @_Z7newNodeiii(i32 noundef %86, i32 noundef 1000001, i32 noundef %52)
  %88 = getelementptr inbounds i8, ptr %78, i64 16
  %89 = load i32, ptr @curC, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [1000001 x i8], ptr @buf, i64 0, i64 %90
  %92 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIciSt4lessIcESaISt4pairIKciEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) %88, ptr noundef nonnull align 1 dereferenceable(1) %91)
  store i32 %87, ptr %92, align 4, !tbaa !5
  %93 = sext i32 %87 to i64
  %94 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %93
  %95 = getelementptr inbounds i8, ptr %94, i64 4
  %96 = load i32, ptr %95, align 4, !tbaa !10
  %97 = load i32, ptr %94, align 16, !tbaa !22
  %98 = sub nsw i32 %96, %97
  br label %.sink.split

.sink.split:                                      ; preds = %83, %66
  %.sink68 = phi i32 [ %71, %66 ], [ %98, %83 ]
  %.sink = phi i32 [ %52, %66 ], [ %87, %83 ]
  %99 = sext i32 %.sink68 to i64
  %100 = load i64, ptr @sum, align 8, !tbaa !26
  %101 = add nsw i64 %100, %99
  store i64 %101, ptr @sum, align 8, !tbaa !26
  %102 = load i32, ptr @qR, align 4, !tbaa !5
  %103 = add nsw i32 %102, 1
  store i32 %103, ptr @qR, align 4, !tbaa !5
  %104 = sext i32 %102 to i64
  %105 = getelementptr inbounds [1000001 x i32], ptr @que, i64 0, i64 %104
  store i32 %.sink, ptr %105, align 4, !tbaa !5
  br label %106

106:                                              ; preds = %.sink.split, %62
  %107 = load i32, ptr @curP, align 4, !tbaa !5
  %108 = load i32, ptr @rt, align 4, !tbaa !5
  %109 = icmp eq i32 %107, %108
  %110 = load i32, ptr @curL, align 4
  %111 = icmp ne i32 %110, 0
  %or.cond = select i1 %109, i1 %111, i1 false
  br i1 %or.cond, label %112, label %116

112:                                              ; preds = %106
  %113 = add nsw i32 %110, -1
  store i32 %113, ptr @curL, align 4, !tbaa !5
  %114 = load i32, ptr @curC, align 4, !tbaa !5
  %115 = add nsw i32 %114, 1
  store i32 %115, ptr @curC, align 4, !tbaa !5
  br label %120

116:                                              ; preds = %106
  %117 = sext i32 %107 to i64
  %118 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %117, i32 3
  %119 = load i32, ptr %118, align 4, !tbaa !29
  store i32 %119, ptr @curP, align 4, !tbaa !5
  br label %120

120:                                              ; preds = %116, %112
  %121 = load i32, ptr @rem, align 4, !tbaa !5
  %122 = add nsw i32 %121, -1
  store i32 %122, ptr @rem, align 4, !tbaa !5
  br label %123

123:                                              ; preds = %.critedge2, %120, %72, %76
  ret void
}

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

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

attributes #0 = { 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 #1 = { 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 #2 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !6, i64 4}
!11 = !{!"_ZTS4Node", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !12, i64 16}
!12 = !{!"_ZTSSt3mapIciSt4lessIcESaISt4pairIKciEEE", !13, i64 0}
!13 = !{!"_ZTSSt8_Rb_treeIcSt4pairIKciESt10_Select1stIS2_ESt4lessIcESaIS2_EE", !14, i64 0}
!14 = !{!"_ZTSNSt8_Rb_treeIcSt4pairIKciESt10_Select1stIS2_ESt4lessIcESaIS2_EE13_Rb_tree_implIS6_Lb1EEE", !15, i64 0, !17, i64 8}
!15 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessIcEE", !16, i64 0}
!16 = !{!"_ZTSSt4lessIcE"}
!17 = !{!"_ZTSSt15_Rb_tree_header", !18, i64 0, !21, i64 32}
!18 = !{!"_ZTSSt18_Rb_tree_node_base", !19, i64 0, !20, i64 8, !20, i64 16, !20, i64 24}
!19 = !{!"_ZTSSt14_Rb_tree_color", !7, i64 0}
!20 = !{!"any pointer", !7, i64 0}
!21 = !{!"long", !7, i64 0}
!22 = !{!11, !6, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!11, !6, i64 8}
!26 = !{!27, !27, i64 0}
!27 = !{!"long long", !7, i64 0}
!28 = distinct !{!28, !24}
!29 = !{!11, !6, i64 12}


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