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

; 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
@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
define dso_local void @_Z6appendc(i8 noundef signext %0) #2 {
  %2 = alloca i8, align 1
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store i8 %0, ptr %2, align 1, !tbaa !5
  %9 = load i8, ptr %2, align 1, !tbaa !5
  %10 = load i32, ptr @len, align 4, !tbaa !8
  %11 = add nsw i32 %10, 1
  store i32 %11, ptr @len, align 4, !tbaa !8
  %12 = sext i32 %10 to i64
  %13 = getelementptr inbounds [1000001 x i8], ptr @buf, i64 0, i64 %12
  store i8 %9, ptr %13, align 1, !tbaa !5
  %14 = load i32, ptr @rem, align 4, !tbaa !8
  %15 = add nsw i32 %14, 1
  store i32 %15, ptr @rem, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 0, ptr %3, align 4, !tbaa !8
  br label %16

16:                                               ; preds = %282, %1
  %17 = load i32, ptr @rem, align 4, !tbaa !8
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %20, label %19

19:                                               ; preds = %16
  store i32 2, ptr %4, align 4
  br label %285

20:                                               ; preds = %16
  %21 = load i32, ptr @curL, align 4, !tbaa !8
  %22 = icmp ne i32 %21, 0
  br i1 %22, label %27, label %23

23:                                               ; preds = %20
  %24 = load i32, ptr @len, align 4, !tbaa !8
  %25 = sub nsw i32 %24, 1
  store i32 %25, ptr @curC, align 4, !tbaa !8
  %26 = icmp ne i32 %25, 0
  br label %27

27:                                               ; preds = %23, %20
  %28 = phi i1 [ false, %20 ], [ %26, %23 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %29 = load i32, ptr @curP, align 4, !tbaa !8
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %30
  %32 = load i32, ptr @curC, align 4, !tbaa !8
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [1000001 x i8], ptr @buf, i64 0, i64 %33
  %35 = load i8, ptr %34, align 1, !tbaa !5
  %36 = call noundef i32 @_ZN4Node4nextEc(ptr noundef nonnull align 8 dereferenceable(64) %31, i8 noundef signext %35)
  store i32 %36, ptr %5, align 4, !tbaa !8
  br label %37

37:                                               ; preds = %56, %27
  %38 = load i32, ptr %5, align 4, !tbaa !8
  %39 = icmp ne i32 %38, 0
  br i1 %39, label %40, label %54

40:                                               ; preds = %37
  %41 = load i32, ptr @curL, align 4, !tbaa !8
  %42 = load i32, ptr %5, align 4, !tbaa !8
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %43
  %45 = getelementptr inbounds %struct.Node, ptr %44, i32 0, i32 1
  %46 = load i32, ptr %45, align 4, !tbaa !10
  %47 = load i32, ptr %5, align 4, !tbaa !8
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %48
  %50 = getelementptr inbounds %struct.Node, ptr %49, i32 0, i32 0
  %51 = load i32, ptr %50, align 16, !tbaa !22
  %52 = sub nsw i32 %46, %51
  %53 = icmp sge i32 %41, %52
  br label %54

54:                                               ; preds = %40, %37
  %55 = phi i1 [ false, %37 ], [ %53, %40 ]
  br i1 %55, label %56, label %92

56:                                               ; preds = %54
  %57 = load i32, ptr %5, align 4, !tbaa !8
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %58
  %60 = getelementptr inbounds %struct.Node, ptr %59, i32 0, i32 1
  %61 = load i32, ptr %60, align 4, !tbaa !10
  %62 = load i32, ptr %5, align 4, !tbaa !8
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %63
  %65 = getelementptr inbounds %struct.Node, ptr %64, i32 0, i32 0
  %66 = load i32, ptr %65, align 16, !tbaa !22
  %67 = sub nsw i32 %61, %66
  %68 = load i32, ptr @curC, align 4, !tbaa !8
  %69 = add nsw i32 %68, %67
  store i32 %69, ptr @curC, align 4, !tbaa !8
  %70 = load i32, ptr %5, align 4, !tbaa !8
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %71
  %73 = getelementptr inbounds %struct.Node, ptr %72, i32 0, i32 1
  %74 = load i32, ptr %73, align 4, !tbaa !10
  %75 = load i32, ptr %5, align 4, !tbaa !8
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %76
  %78 = getelementptr inbounds %struct.Node, ptr %77, i32 0, i32 0
  %79 = load i32, ptr %78, align 16, !tbaa !22
  %80 = sub nsw i32 %74, %79
  %81 = load i32, ptr @curL, align 4, !tbaa !8
  %82 = sub nsw i32 %81, %80
  store i32 %82, ptr @curL, align 4, !tbaa !8
  %83 = load i32, ptr %5, align 4, !tbaa !8
  store i32 %83, ptr @curP, align 4, !tbaa !8
  %84 = load i32, ptr @curP, align 4, !tbaa !8
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %85
  %87 = load i32, ptr @curC, align 4, !tbaa !8
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [1000001 x i8], ptr @buf, i64 0, i64 %88
  %90 = load i8, ptr %89, align 1, !tbaa !5
  %91 = call noundef i32 @_ZN4Node4nextEc(ptr noundef nonnull align 8 dereferenceable(64) %86, i8 noundef signext %90)
  store i32 %91, ptr %5, align 4, !tbaa !8
  br label %37, !llvm.loop !23

92:                                               ; preds = %54
  %93 = load i32, ptr %5, align 4, !tbaa !8
  %94 = icmp ne i32 %93, 0
  br i1 %94, label %139, label %95

95:                                               ; preds = %92
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %96 = load i32, ptr @len, align 4, !tbaa !8
  %97 = sub nsw i32 %96, 1
  %98 = load i32, ptr @curP, align 4, !tbaa !8
  %99 = call noundef i32 @_Z7newNodeiii(i32 noundef %97, i32 noundef 1000001, i32 noundef %98)
  %100 = load i32, ptr @curP, align 4, !tbaa !8
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %101
  %103 = getelementptr inbounds %struct.Node, ptr %102, i32 0, i32 4
  %104 = load i32, ptr @curC, align 4, !tbaa !8
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [1000001 x i8], ptr @buf, i64 0, i64 %105
  %107 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIciSt4lessIcESaISt4pairIKciEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) %103, ptr noundef nonnull align 1 dereferenceable(1) %106)
  store i32 %99, ptr %107, align 4, !tbaa !8
  store i32 %99, ptr %6, align 4, !tbaa !8
  %108 = load i32, ptr %6, align 4, !tbaa !8
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %109
  %111 = getelementptr inbounds %struct.Node, ptr %110, i32 0, i32 1
  %112 = load i32, ptr %111, align 4, !tbaa !10
  %113 = load i32, ptr %6, align 4, !tbaa !8
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %114
  %116 = getelementptr inbounds %struct.Node, ptr %115, i32 0, i32 0
  %117 = load i32, ptr %116, align 16, !tbaa !22
  %118 = sub nsw i32 %112, %117
  %119 = sext i32 %118 to i64
  %120 = load i64, ptr @sum, align 8, !tbaa !25
  %121 = add nsw i64 %120, %119
  store i64 %121, ptr @sum, align 8, !tbaa !25
  %122 = load i32, ptr %6, align 4, !tbaa !8
  %123 = load i32, ptr @qR, align 4, !tbaa !8
  %124 = add nsw i32 %123, 1
  store i32 %124, ptr @qR, align 4, !tbaa !8
  %125 = sext i32 %123 to i64
  %126 = getelementptr inbounds [1000001 x i32], ptr @que, i64 0, i64 %125
  store i32 %122, ptr %126, align 4, !tbaa !8
  %127 = load i32, ptr %3, align 4, !tbaa !8
  %128 = icmp ne i32 %127, 0
  br i1 %128, label %129, label %136

129:                                              ; preds = %95
  %130 = load i32, ptr @curP, align 4, !tbaa !8
  %131 = load i32, ptr %3, align 4, !tbaa !8
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %132
  %134 = getelementptr inbounds %struct.Node, ptr %133, i32 0, i32 3
  store i32 %130, ptr %134, align 4, !tbaa !27
  %135 = icmp ne i32 %130, 0
  br label %136

136:                                              ; preds = %129, %95
  %137 = phi i1 [ false, %95 ], [ %135, %129 ]
  %138 = load i32, ptr @curP, align 4, !tbaa !8
  store i32 %138, ptr %3, align 4, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %259

139:                                              ; preds = %92
  %140 = load i32, ptr %5, align 4, !tbaa !8
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %141
  %143 = getelementptr inbounds %struct.Node, ptr %142, i32 0, i32 0
  %144 = load i32, ptr %143, align 16, !tbaa !22
  %145 = load i32, ptr @curL, align 4, !tbaa !8
  %146 = add nsw i32 %144, %145
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds [1000001 x i8], ptr @buf, i64 0, i64 %147
  %149 = load i8, ptr %148, align 1, !tbaa !5
  %150 = sext i8 %149 to i32
  %151 = load i8, ptr %2, align 1, !tbaa !5
  %152 = sext i8 %151 to i32
  %153 = icmp eq i32 %150, %152
  br i1 %153, label %154, label %168

154:                                              ; preds = %139
  %155 = load i32, ptr @curL, align 4, !tbaa !8
  %156 = add nsw i32 %155, 1
  store i32 %156, ptr @curL, align 4, !tbaa !8
  %157 = load i32, ptr %3, align 4, !tbaa !8
  %158 = icmp ne i32 %157, 0
  br i1 %158, label %159, label %166

159:                                              ; preds = %154
  %160 = load i32, ptr @curP, align 4, !tbaa !8
  %161 = load i32, ptr %3, align 4, !tbaa !8
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %162
  %164 = getelementptr inbounds %struct.Node, ptr %163, i32 0, i32 3
  store i32 %160, ptr %164, align 4, !tbaa !27
  %165 = icmp ne i32 %160, 0
  br label %166

166:                                              ; preds = %159, %154
  %167 = phi i1 [ false, %154 ], [ %165, %159 ]
  store i32 2, ptr %4, align 4
  br label %279

168:                                              ; preds = %139
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %169 = load i32, ptr %5, align 4, !tbaa !8
  %170 = sext i32 %169 to i64
  %171 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %170
  %172 = getelementptr inbounds %struct.Node, ptr %171, i32 0, i32 0
  %173 = load i32, ptr %172, align 16, !tbaa !22
  %174 = load i32, ptr %5, align 4, !tbaa !8
  %175 = sext i32 %174 to i64
  %176 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %175
  %177 = getelementptr inbounds %struct.Node, ptr %176, i32 0, i32 0
  %178 = load i32, ptr %177, align 16, !tbaa !22
  %179 = load i32, ptr @curL, align 4, !tbaa !8
  %180 = add nsw i32 %178, %179
  %181 = load i32, ptr @curP, align 4, !tbaa !8
  %182 = call noundef i32 @_Z7newNodeiii(i32 noundef %173, i32 noundef %180, i32 noundef %181)
  store i32 %182, ptr %7, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %183 = load i32, ptr @len, align 4, !tbaa !8
  %184 = sub nsw i32 %183, 1
  %185 = load i32, ptr %7, align 4, !tbaa !8
  %186 = call noundef i32 @_Z7newNodeiii(i32 noundef %184, i32 noundef 1000001, i32 noundef %185)
  store i32 %186, ptr %8, align 4, !tbaa !8
  %187 = load i32, ptr %8, align 4, !tbaa !8
  %188 = sext i32 %187 to i64
  %189 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %188
  %190 = getelementptr inbounds %struct.Node, ptr %189, i32 0, i32 1
  %191 = load i32, ptr %190, align 4, !tbaa !10
  %192 = load i32, ptr %8, align 4, !tbaa !8
  %193 = sext i32 %192 to i64
  %194 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %193
  %195 = getelementptr inbounds %struct.Node, ptr %194, i32 0, i32 0
  %196 = load i32, ptr %195, align 16, !tbaa !22
  %197 = sub nsw i32 %191, %196
  %198 = sext i32 %197 to i64
  %199 = load i64, ptr @sum, align 8, !tbaa !25
  %200 = add nsw i64 %199, %198
  store i64 %200, ptr @sum, align 8, !tbaa !25
  %201 = load i32, ptr %8, align 4, !tbaa !8
  %202 = load i32, ptr @qR, align 4, !tbaa !8
  %203 = add nsw i32 %202, 1
  store i32 %203, ptr @qR, align 4, !tbaa !8
  %204 = sext i32 %202 to i64
  %205 = getelementptr inbounds [1000001 x i32], ptr @que, i64 0, i64 %204
  store i32 %201, ptr %205, align 4, !tbaa !8
  %206 = load i32, ptr %7, align 4, !tbaa !8
  %207 = load i32, ptr %5, align 4, !tbaa !8
  %208 = sext i32 %207 to i64
  %209 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %208
  %210 = getelementptr inbounds %struct.Node, ptr %209, i32 0, i32 2
  store i32 %206, ptr %210, align 8, !tbaa !28
  %211 = load i32, ptr %7, align 4, !tbaa !8
  %212 = load i32, ptr @curP, align 4, !tbaa !8
  %213 = sext i32 %212 to i64
  %214 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %213
  %215 = getelementptr inbounds %struct.Node, ptr %214, i32 0, i32 4
  %216 = load i32, ptr @curC, align 4, !tbaa !8
  %217 = sext i32 %216 to i64
  %218 = getelementptr inbounds [1000001 x i8], ptr @buf, i64 0, i64 %217
  %219 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIciSt4lessIcESaISt4pairIKciEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) %215, ptr noundef nonnull align 1 dereferenceable(1) %218)
  store i32 %211, ptr %219, align 4, !tbaa !8
  %220 = load i32, ptr @curL, align 4, !tbaa !8
  %221 = load i32, ptr %5, align 4, !tbaa !8
  %222 = sext i32 %221 to i64
  %223 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %222
  %224 = getelementptr inbounds %struct.Node, ptr %223, i32 0, i32 0
  %225 = load i32, ptr %224, align 16, !tbaa !22
  %226 = add nsw i32 %225, %220
  store i32 %226, ptr %224, align 16, !tbaa !22
  %227 = load i32, ptr %5, align 4, !tbaa !8
  %228 = load i32, ptr %7, align 4, !tbaa !8
  %229 = sext i32 %228 to i64
  %230 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %229
  %231 = getelementptr inbounds %struct.Node, ptr %230, i32 0, i32 4
  %232 = load i32, ptr %5, align 4, !tbaa !8
  %233 = sext i32 %232 to i64
  %234 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %233
  %235 = getelementptr inbounds %struct.Node, ptr %234, i32 0, i32 0
  %236 = load i32, ptr %235, align 16, !tbaa !22
  %237 = sext i32 %236 to i64
  %238 = getelementptr inbounds [1000001 x i8], ptr @buf, i64 0, i64 %237
  %239 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIciSt4lessIcESaISt4pairIKciEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) %231, ptr noundef nonnull align 1 dereferenceable(1) %238)
  store i32 %227, ptr %239, align 4, !tbaa !8
  %240 = load i32, ptr %8, align 4, !tbaa !8
  %241 = load i32, ptr %7, align 4, !tbaa !8
  %242 = sext i32 %241 to i64
  %243 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %242
  %244 = getelementptr inbounds %struct.Node, ptr %243, i32 0, i32 4
  %245 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIciSt4lessIcESaISt4pairIKciEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) %244, ptr noundef nonnull align 1 dereferenceable(1) %2)
  store i32 %240, ptr %245, align 4, !tbaa !8
  %246 = load i32, ptr %3, align 4, !tbaa !8
  %247 = icmp ne i32 %246, 0
  br i1 %247, label %248, label %255

248:                                              ; preds = %168
  %249 = load i32, ptr %7, align 4, !tbaa !8
  %250 = load i32, ptr %3, align 4, !tbaa !8
  %251 = sext i32 %250 to i64
  %252 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %251
  %253 = getelementptr inbounds %struct.Node, ptr %252, i32 0, i32 3
  store i32 %249, ptr %253, align 4, !tbaa !27
  %254 = icmp ne i32 %249, 0
  br label %255

255:                                              ; preds = %248, %168
  %256 = phi i1 [ false, %168 ], [ %254, %248 ]
  %257 = load i32, ptr %7, align 4, !tbaa !8
  store i32 %257, ptr %3, align 4, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %258

258:                                              ; preds = %255
  br label %259

259:                                              ; preds = %258, %136
  %260 = load i32, ptr @curP, align 4, !tbaa !8
  %261 = load i32, ptr @rt, align 4, !tbaa !8
  %262 = icmp eq i32 %260, %261
  br i1 %262, label %263, label %271

263:                                              ; preds = %259
  %264 = load i32, ptr @curL, align 4, !tbaa !8
  %265 = icmp ne i32 %264, 0
  br i1 %265, label %266, label %271

266:                                              ; preds = %263
  %267 = load i32, ptr @curL, align 4, !tbaa !8
  %268 = add nsw i32 %267, -1
  store i32 %268, ptr @curL, align 4, !tbaa !8
  %269 = load i32, ptr @curC, align 4, !tbaa !8
  %270 = add nsw i32 %269, 1
  store i32 %270, ptr @curC, align 4, !tbaa !8
  br label %277

271:                                              ; preds = %263, %259
  %272 = load i32, ptr @curP, align 4, !tbaa !8
  %273 = sext i32 %272 to i64
  %274 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %273
  %275 = getelementptr inbounds %struct.Node, ptr %274, i32 0, i32 3
  %276 = load i32, ptr %275, align 4, !tbaa !27
  store i32 %276, ptr @curP, align 4, !tbaa !8
  br label %277

277:                                              ; preds = %271, %266
  %278 = phi ptr [ @curC, %266 ], [ @curP, %271 ]
  store i32 0, ptr %4, align 4
  br label %279

279:                                              ; preds = %277, %166
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  %280 = load i32, ptr %4, align 4
  switch i32 %280, label %285 [
    i32 0, label %281
  ]

281:                                              ; preds = %279
  br label %282

282:                                              ; preds = %281
  %283 = load i32, ptr @rem, align 4, !tbaa !8
  %284 = add nsw i32 %283, -1
  store i32 %284, ptr @rem, align 4, !tbaa !8
  br label %16, !llvm.loop !29

285:                                              ; preds = %279, %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %286

286:                                              ; preds = %285
  ret void
}

; 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

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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = !{!11, !9, i64 4}
!11 = !{!"_ZTS4Node", !9, i64 0, !9, i64 4, !9, i64 8, !9, 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", !6, i64 0}
!20 = !{!"any pointer", !6, i64 0}
!21 = !{!"long", !6, i64 0}
!22 = !{!11, !9, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!26, !26, i64 0}
!26 = !{!"long long", !6, i64 0}
!27 = !{!11, !9, i64 12}
!28 = !{!11, !9, i64 8}
!29 = distinct !{!29, !24}


; 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
@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
define dso_local void @_Z6appendc(i8 noundef signext %0) local_unnamed_addr #1 {
  %2 = alloca i8, align 1
  store i8 %0, ptr %2, align 1, !tbaa !5
  %3 = load i32, ptr @len, align 4, !tbaa !8
  %4 = add nsw i32 %3, 1
  store i32 %4, ptr @len, align 4, !tbaa !8
  %5 = sext i32 %3 to i64
  %6 = getelementptr inbounds [1000001 x i8], ptr @buf, i64 0, i64 %5
  store i8 %0, ptr %6, align 1, !tbaa !5
  %7 = load i32, ptr @rem, align 4, !tbaa !8
  %8 = add nsw i32 %7, 1
  store i32 %8, ptr @rem, align 4, !tbaa !8
  %.not59 = icmp eq i32 %8, 0
  br i1 %.not59, label %.loopexit, label %.lr.ph61.preheader

.lr.ph61.preheader:                               ; preds = %1
  %.pre = load i32, ptr @curL, align 4, !tbaa !8
  br label %.lr.ph61

.lr.ph61:                                         ; preds = %.lr.ph61.preheader, %125
  %9 = phi i32 [ %126, %125 ], [ %.pre, %.lr.ph61.preheader ]
  %.060 = phi i32 [ %.1, %125 ], [ 0, %.lr.ph61.preheader ]
  %.not42 = icmp eq i32 %9, 0
  br i1 %.not42, label %10, label %.lr.ph61._crit_edge

.lr.ph61._crit_edge:                              ; preds = %.lr.ph61
  %.pre69 = load i32, ptr @curC, align 4, !tbaa !8
  br label %13

10:                                               ; preds = %.lr.ph61
  %11 = load i32, ptr @len, align 4, !tbaa !8
  %12 = add nsw i32 %11, -1
  store i32 %12, ptr @curC, align 4, !tbaa !8
  br label %13

13:                                               ; preds = %.lr.ph61._crit_edge, %10
  %14 = phi i32 [ %.pre69, %.lr.ph61._crit_edge ], [ %12, %10 ]
  %15 = load i32, ptr @curP, align 4, !tbaa !8
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %16
  %18 = sext i32 %14 to i64
  %19 = getelementptr inbounds [1000001 x i8], ptr @buf, i64 0, i64 %18
  %20 = load i8, ptr %19, align 1, !tbaa !5
  %21 = call noundef i32 @_ZN4Node4nextEc(ptr noundef nonnull align 8 dereferenceable(64) %17, i8 noundef signext %20)
  %.not4357 = icmp eq i32 %21, 0
  br i1 %.not4357, label %.critedge48, label %.lr.ph

.lr.ph:                                           ; preds = %13, %29
  %.03958 = phi i32 [ %36, %29 ], [ %21, %13 ]
  %22 = load i32, ptr @curL, align 4, !tbaa !8
  %23 = sext i32 %.03958 to i64
  %24 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %23
  %25 = getelementptr inbounds i8, ptr %24, i64 4
  %26 = load i32, ptr %25, align 4, !tbaa !10
  %27 = load i32, ptr %24, align 16, !tbaa !22
  %28 = sub nsw i32 %26, %27
  %.not44 = icmp slt i32 %22, %28
  br i1 %.not44, label %.critedge, label %29

29:                                               ; preds = %.lr.ph
  %30 = load i32, ptr @curC, align 4, !tbaa !8
  %31 = add nsw i32 %30, %28
  store i32 %31, ptr @curC, align 4, !tbaa !8
  %.neg = sub i32 %22, %26
  %32 = add i32 %.neg, %27
  store i32 %32, ptr @curL, align 4, !tbaa !8
  store i32 %.03958, ptr @curP, align 4, !tbaa !8
  %33 = sext i32 %31 to i64
  %34 = getelementptr inbounds [1000001 x i8], ptr @buf, i64 0, i64 %33
  %35 = load i8, ptr %34, align 1, !tbaa !5
  %36 = call noundef i32 @_ZN4Node4nextEc(ptr noundef nonnull align 8 dereferenceable(64) %24, i8 noundef signext %35)
  %.not43 = icmp eq i32 %36, 0
  br i1 %.not43, label %.critedge48, label %.lr.ph, !llvm.loop !23

.critedge48:                                      ; preds = %29, %13
  %37 = load i32, ptr @len, align 4, !tbaa !8
  %38 = add nsw i32 %37, -1
  %39 = load i32, ptr @curP, align 4, !tbaa !8
  %40 = call noundef i32 @_Z7newNodeiii(i32 noundef %38, i32 noundef 1000001, i32 noundef %39)
  %41 = load i32, ptr @curP, align 4, !tbaa !8
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %42, i32 4
  %44 = load i32, ptr @curC, align 4, !tbaa !8
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [1000001 x i8], ptr @buf, i64 0, i64 %45
  %47 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIciSt4lessIcESaISt4pairIKciEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) %43, ptr noundef nonnull align 1 dereferenceable(1) %46)
  store i32 %40, ptr %47, align 4, !tbaa !8
  %48 = sext i32 %40 to i64
  %49 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %48
  %50 = getelementptr inbounds i8, ptr %49, i64 4
  %51 = load i32, ptr %50, align 4, !tbaa !10
  %52 = load i32, ptr %49, align 16, !tbaa !22
  %53 = sub nsw i32 %51, %52
  %54 = sext i32 %53 to i64
  %55 = load i64, ptr @sum, align 8, !tbaa !25
  %56 = add nsw i64 %55, %54
  store i64 %56, ptr @sum, align 8, !tbaa !25
  %57 = load i32, ptr @qR, align 4, !tbaa !8
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr @qR, align 4, !tbaa !8
  %59 = sext i32 %57 to i64
  %60 = getelementptr inbounds [1000001 x i32], ptr @que, i64 0, i64 %59
  store i32 %40, ptr %60, align 4, !tbaa !8
  %.not45 = icmp eq i32 %.060, 0
  %.pre70 = load i32, ptr @curP, align 4, !tbaa !8
  br i1 %.not45, label %111, label %.sink.split

.critedge:                                        ; preds = %.lr.ph
  %61 = add nsw i32 %27, %22
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [1000001 x i8], ptr @buf, i64 0, i64 %62
  %64 = load i8, ptr %63, align 1, !tbaa !5
  %65 = load i8, ptr %2, align 1, !tbaa !5
  %66 = icmp eq i8 %64, %65
  br i1 %66, label %67, label %73

67:                                               ; preds = %.critedge
  %68 = add nsw i32 %22, 1
  store i32 %68, ptr @curL, align 4, !tbaa !8
  %.not47 = icmp eq i32 %.060, 0
  br i1 %.not47, label %.loopexit, label %69

69:                                               ; preds = %67
  %70 = load i32, ptr @curP, align 4, !tbaa !8
  %71 = sext i32 %.060 to i64
  %72 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %71, i32 3
  store i32 %70, ptr %72, align 4, !tbaa !27
  br label %.loopexit

73:                                               ; preds = %.critedge
  %74 = load i32, ptr @curP, align 4, !tbaa !8
  %75 = call noundef i32 @_Z7newNodeiii(i32 noundef %27, i32 noundef %61, i32 noundef %74)
  %76 = load i32, ptr @len, align 4, !tbaa !8
  %77 = add nsw i32 %76, -1
  %78 = call noundef i32 @_Z7newNodeiii(i32 noundef %77, i32 noundef 1000001, i32 noundef %75)
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %79
  %81 = getelementptr inbounds i8, ptr %80, i64 4
  %82 = load i32, ptr %81, align 4, !tbaa !10
  %83 = load i32, ptr %80, align 16, !tbaa !22
  %84 = sub nsw i32 %82, %83
  %85 = sext i32 %84 to i64
  %86 = load i64, ptr @sum, align 8, !tbaa !25
  %87 = add nsw i64 %86, %85
  store i64 %87, ptr @sum, align 8, !tbaa !25
  %88 = load i32, ptr @qR, align 4, !tbaa !8
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr @qR, align 4, !tbaa !8
  %90 = sext i32 %88 to i64
  %91 = getelementptr inbounds [1000001 x i32], ptr @que, i64 0, i64 %90
  store i32 %78, ptr %91, align 4, !tbaa !8
  %92 = getelementptr inbounds i8, ptr %24, i64 8
  store i32 %75, ptr %92, align 8, !tbaa !28
  %93 = load i32, ptr @curP, align 4, !tbaa !8
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %94, i32 4
  %96 = load i32, ptr @curC, align 4, !tbaa !8
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [1000001 x i8], ptr @buf, i64 0, i64 %97
  %99 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIciSt4lessIcESaISt4pairIKciEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) %95, ptr noundef nonnull align 1 dereferenceable(1) %98)
  store i32 %75, ptr %99, align 4, !tbaa !8
  %100 = load i32, ptr @curL, align 4, !tbaa !8
  %101 = load i32, ptr %24, align 16, !tbaa !22
  %102 = add nsw i32 %101, %100
  store i32 %102, ptr %24, align 16, !tbaa !22
  %103 = sext i32 %75 to i64
  %104 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %103, i32 4
  %105 = sext i32 %102 to i64
  %106 = getelementptr inbounds [1000001 x i8], ptr @buf, i64 0, i64 %105
  %107 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIciSt4lessIcESaISt4pairIKciEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) %104, ptr noundef nonnull align 1 dereferenceable(1) %106)
  store i32 %.03958, ptr %107, align 4, !tbaa !8
  %108 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIciSt4lessIcESaISt4pairIKciEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) %104, ptr noundef nonnull align 1 dereferenceable(1) %2)
  store i32 %78, ptr %108, align 4, !tbaa !8
  %.not46 = icmp eq i32 %.060, 0
  br i1 %.not46, label %111, label %.sink.split

.sink.split:                                      ; preds = %73, %.critedge48
  %.pre70.sink = phi i32 [ %.pre70, %.critedge48 ], [ %75, %73 ]
  %109 = sext i32 %.060 to i64
  %110 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %109, i32 3
  store i32 %.pre70.sink, ptr %110, align 4, !tbaa !27
  br label %111

111:                                              ; preds = %.sink.split, %.critedge48, %73
  %.1 = phi i32 [ %75, %73 ], [ %.pre70, %.critedge48 ], [ %.pre70.sink, %.sink.split ]
  %112 = load i32, ptr @curP, align 4, !tbaa !8
  %113 = load i32, ptr @rt, align 4, !tbaa !8
  %114 = icmp eq i32 %112, %113
  %115 = load i32, ptr @curL, align 4
  %116 = icmp ne i32 %115, 0
  %or.cond = select i1 %114, i1 %116, i1 false
  br i1 %or.cond, label %117, label %121

117:                                              ; preds = %111
  %118 = add nsw i32 %115, -1
  store i32 %118, ptr @curL, align 4, !tbaa !8
  %119 = load i32, ptr @curC, align 4, !tbaa !8
  %120 = add nsw i32 %119, 1
  store i32 %120, ptr @curC, align 4, !tbaa !8
  br label %125

121:                                              ; preds = %111
  %122 = sext i32 %112 to i64
  %123 = getelementptr inbounds [2000003 x %struct.Node], ptr @e, i64 0, i64 %122, i32 3
  %124 = load i32, ptr %123, align 4, !tbaa !27
  store i32 %124, ptr @curP, align 4, !tbaa !8
  br label %125

125:                                              ; preds = %121, %117
  %126 = phi i32 [ %115, %121 ], [ %118, %117 ]
  %127 = load i32, ptr @rem, align 4, !tbaa !8
  %128 = add nsw i32 %127, -1
  store i32 %128, ptr @rem, align 4, !tbaa !8
  %.not = icmp eq i32 %128, 0
  br i1 %.not, label %.loopexit, label %.lr.ph61, !llvm.loop !29

.loopexit:                                        ; preds = %125, %1, %69, %67
  ret void
}

; 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

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

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = !{!11, !9, i64 4}
!11 = !{!"_ZTS4Node", !9, i64 0, !9, i64 4, !9, i64 8, !9, 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", !6, i64 0}
!20 = !{!"any pointer", !6, i64 0}
!21 = !{!"long", !6, i64 0}
!22 = !{!11, !9, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!26, !26, i64 0}
!26 = !{!"long long", !6, i64 0}
!27 = !{!11, !9, i64 12}
!28 = !{!11, !9, i64 8}
!29 = distinct !{!29, !24}


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