; LLVM IR from tangjz/acm-icpc :: poj (3152)

; 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::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<int, std::pair<const int, std::pair<int, std::map<int, int>>>, std::_Select1st<std::pair<const int, std::pair<int, std::map<int, int>>>>, std::greater<int>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<int, std::pair<const int, std::pair<int, std::map<int, int>>>, std::_Select1st<std::pair<const int, std::pair<int, std::map<int, int>>>>, std::greater<int>>::_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 }
%"class.std::map.0" = type { %"class.std::_Rb_tree.1" }
%"class.std::_Rb_tree.1" = type { %"struct.std::_Rb_tree<int, std::pair<const int, std::pair<int, std::map<int, int>>>, std::_Select1st<std::pair<const int, std::pair<int, std::map<int, int>>>>, std::less<int>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<int, std::pair<const int, std::pair<int, std::map<int, int>>>, std::_Select1st<std::pair<const int, std::pair<int, std::map<int, int>>>>, std::less<int>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_iterator" = type { ptr }
%"struct.std::_Rb_tree_iterator.10" = type { ptr }
%"struct.std::pair.3" = type { i32, %"class.std::map.5" }
%"class.std::map.5" = type { %"class.std::_Rb_tree.6" }
%"class.std::_Rb_tree.6" = type { %"struct.std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int>>, std::less<int>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int>>, std::less<int>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::pair" = type { i32, %"struct.std::pair.3" }

@Buy = external dso_local global %"class.std::map", align 8
@Sell = external dso_local global %"class.std::map.0", align 8
@n = external dso_local global i32, align 4
@id = external dso_local global i32, align 4
@p = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@P = external dso_local global [16384 x i32], align 16
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z8MaintainRSt3mapIiSt4pairIiS_IiiSt4lessIiESaIS0_IKiiEEEESt7greaterIiESaIS0_IS3_S7_EEERS_IiS7_S2_SB_E(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(48)) #0

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

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

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

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

declare i32 @printf(ptr noundef, ...) #3

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

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

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

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

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z8MaintainRSt3mapIiSt4pairIiS_IiiSt4lessIiESaIS0_IKiiEEEES2_SaIS0_IS3_S7_EEERS_IiS7_St7greaterIiES9_E(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(48)) #0

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

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

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

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

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #4 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca [10 x i8], align 1
  %4 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %5 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %6 = alloca ptr, align 8
  %7 = alloca %"struct.std::_Rb_tree_iterator.10", align 8
  %8 = alloca %"struct.std::_Rb_tree_iterator.10", align 8
  %9 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %10 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %11 = alloca ptr, align 8
  %12 = alloca %"struct.std::_Rb_tree_iterator.10", align 8
  %13 = alloca %"struct.std::_Rb_tree_iterator.10", align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %19 = alloca %"struct.std::_Rb_tree_iterator", align 8
  store i32 0, ptr %1, align 4
  %20 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %176, %0
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = load i32, ptr @n, align 4, !tbaa !5
  %24 = icmp sle i32 %22, %23
  br i1 %24, label %26, label %25

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

26:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 10, ptr %3) #5
  %27 = getelementptr inbounds [10 x i8], ptr %3, i64 0, i64 0
  %28 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.3, ptr noundef %27)
  %29 = getelementptr inbounds [10 x i8], ptr %3, i64 0, i64 0
  %30 = load i8, ptr %29, align 1, !tbaa !9
  %31 = sext i8 %30 to i32
  %32 = icmp eq i32 %31, 66
  br i1 %32, label %38, label %33

33:                                               ; preds = %26
  %34 = getelementptr inbounds [10 x i8], ptr %3, i64 0, i64 0
  %35 = load i8, ptr %34, align 1, !tbaa !9
  %36 = sext i8 %35 to i32
  %37 = icmp eq i32 %36, 83
  br i1 %37, label %38, label %52

38:                                               ; preds = %33, %26
  %39 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.4, ptr noundef @q, ptr noundef @p)
  %40 = load i32, ptr @p, align 4, !tbaa !5
  %41 = load i32, ptr %2, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [16384 x i32], ptr @P, i64 0, i64 %42
  store i32 %40, ptr %43, align 4, !tbaa !5
  %44 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %44, ptr @id, align 4, !tbaa !5
  %45 = getelementptr inbounds [10 x i8], ptr %3, i64 0, i64 0
  %46 = load i8, ptr %45, align 1, !tbaa !9
  %47 = sext i8 %46 to i32
  %48 = icmp eq i32 %47, 66
  br i1 %48, label %49, label %50

49:                                               ; preds = %38
  call void @_Z8MaintainRSt3mapIiSt4pairIiS_IiiSt4lessIiESaIS0_IKiiEEEESt7greaterIiESaIS0_IS3_S7_EEERS_IiS7_S2_SB_E(ptr noundef nonnull align 8 dereferenceable(48) @Buy, ptr noundef nonnull align 8 dereferenceable(48) @Sell)
  br label %51

50:                                               ; preds = %38
  call void @_Z8MaintainRSt3mapIiSt4pairIiS_IiiSt4lessIiESaIS0_IKiiEEEES2_SaIS0_IS3_S7_EEERS_IiS7_St7greaterIiES9_E(ptr noundef nonnull align 8 dereferenceable(48) @Sell, ptr noundef nonnull align 8 dereferenceable(48) @Buy)
  br label %51

51:                                               ; preds = %50, %49
  br label %146

52:                                               ; preds = %33
  %53 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef @id)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %54 = load i32, ptr @id, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [16384 x i32], ptr @P, i64 0, i64 %55
  %57 = call ptr @_ZNSt3mapIiSt4pairIiS_IiiSt4lessIiESaIS0_IKiiEEEESt7greaterIiESaIS0_IS3_S7_EEE4findERS3_(ptr noundef nonnull align 8 dereferenceable(48) @Buy, ptr noundef nonnull align 4 dereferenceable(4) %56)
  %58 = getelementptr inbounds %"struct.std::_Rb_tree_iterator", ptr %4, i32 0, i32 0
  store ptr %57, ptr %58, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %59 = call ptr @_ZNSt3mapIiSt4pairIiS_IiiSt4lessIiESaIS0_IKiiEEEESt7greaterIiESaIS0_IS3_S7_EEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @Buy) #5
  %60 = getelementptr inbounds %"struct.std::_Rb_tree_iterator", ptr %5, i32 0, i32 0
  store ptr %59, ptr %60, align 8
  %61 = call noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKiS0_IiSt3mapIiiSt4lessIiESaIS0_IS1_iEEEEEESC_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  br i1 %61, label %62, label %99

62:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %63 = load i32, ptr @id, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [16384 x i32], ptr @P, i64 0, i64 %64
  %66 = call noundef nonnull align 8 dereferenceable(56) ptr @_ZNSt3mapIiSt4pairIiS_IiiSt4lessIiESaIS0_IKiiEEEESt7greaterIiESaIS0_IS3_S7_EEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @Buy, ptr noundef nonnull align 4 dereferenceable(4) %65)
  store ptr %66, ptr %6, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %67 = load ptr, ptr %6, align 8, !tbaa !10
  %68 = getelementptr inbounds %"struct.std::pair.3", ptr %67, i32 0, i32 1
  %69 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE4findERS3_(ptr noundef nonnull align 8 dereferenceable(48) %68, ptr noundef nonnull align 4 dereferenceable(4) @id)
  %70 = getelementptr inbounds %"struct.std::_Rb_tree_iterator.10", ptr %7, i32 0, i32 0
  store ptr %69, ptr %70, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %71 = load ptr, ptr %6, align 8, !tbaa !10
  %72 = getelementptr inbounds %"struct.std::pair.3", ptr %71, i32 0, i32 1
  %73 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) %72) #5
  %74 = getelementptr inbounds %"struct.std::_Rb_tree_iterator.10", ptr %8, i32 0, i32 0
  store ptr %73, ptr %74, align 8
  %75 = call noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKiiEES5_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br i1 %75, label %76, label %88

76:                                               ; preds = %62
  %77 = load ptr, ptr %6, align 8, !tbaa !10
  %78 = getelementptr inbounds %"struct.std::pair.3", ptr %77, i32 0, i32 1
  %79 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) %78, ptr noundef nonnull align 4 dereferenceable(4) @id)
  %80 = load i32, ptr %79, align 4, !tbaa !5
  %81 = load ptr, ptr %6, align 8, !tbaa !10
  %82 = getelementptr inbounds %"struct.std::pair.3", ptr %81, i32 0, i32 0
  %83 = load i32, ptr %82, align 8, !tbaa !12
  %84 = sub nsw i32 %83, %80
  store i32 %84, ptr %82, align 8, !tbaa !12
  %85 = load ptr, ptr %6, align 8, !tbaa !10
  %86 = getelementptr inbounds %"struct.std::pair.3", ptr %85, i32 0, i32 1
  %87 = call noundef i64 @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE5eraseERS3_(ptr noundef nonnull align 8 dereferenceable(48) %86, ptr noundef nonnull align 4 dereferenceable(4) @id)
  br label %88

88:                                               ; preds = %76, %62
  %89 = load ptr, ptr %6, align 8, !tbaa !10
  %90 = getelementptr inbounds %"struct.std::pair.3", ptr %89, i32 0, i32 0
  %91 = load i32, ptr %90, align 8, !tbaa !12
  %92 = icmp ne i32 %91, 0
  br i1 %92, label %98, label %93

93:                                               ; preds = %88
  %94 = load i32, ptr @id, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [16384 x i32], ptr @P, i64 0, i64 %95
  %97 = call noundef i64 @_ZNSt3mapIiSt4pairIiS_IiiSt4lessIiESaIS0_IKiiEEEESt7greaterIiESaIS0_IS3_S7_EEE5eraseERS3_(ptr noundef nonnull align 8 dereferenceable(48) @Buy, ptr noundef nonnull align 4 dereferenceable(4) %96)
  br label %98

98:                                               ; preds = %93, %88
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %99

99:                                               ; preds = %98, %52
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %100 = load i32, ptr @id, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [16384 x i32], ptr @P, i64 0, i64 %101
  %103 = call ptr @_ZNSt3mapIiSt4pairIiS_IiiSt4lessIiESaIS0_IKiiEEEES2_SaIS0_IS3_S7_EEE4findERS3_(ptr noundef nonnull align 8 dereferenceable(48) @Sell, ptr noundef nonnull align 4 dereferenceable(4) %102)
  %104 = getelementptr inbounds %"struct.std::_Rb_tree_iterator", ptr %9, i32 0, i32 0
  store ptr %103, ptr %104, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %105 = call ptr @_ZNSt3mapIiSt4pairIiS_IiiSt4lessIiESaIS0_IKiiEEEES2_SaIS0_IS3_S7_EEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @Sell) #5
  %106 = getelementptr inbounds %"struct.std::_Rb_tree_iterator", ptr %10, i32 0, i32 0
  store ptr %105, ptr %106, align 8
  %107 = call noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKiS0_IiSt3mapIiiSt4lessIiESaIS0_IS1_iEEEEEESC_(ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef nonnull align 8 dereferenceable(8) %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  br i1 %107, label %108, label %145

108:                                              ; preds = %99
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %109 = load i32, ptr @id, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [16384 x i32], ptr @P, i64 0, i64 %110
  %112 = call noundef nonnull align 8 dereferenceable(56) ptr @_ZNSt3mapIiSt4pairIiS_IiiSt4lessIiESaIS0_IKiiEEEES2_SaIS0_IS3_S7_EEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @Sell, ptr noundef nonnull align 4 dereferenceable(4) %111)
  store ptr %112, ptr %11, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %113 = load ptr, ptr %11, align 8, !tbaa !10
  %114 = getelementptr inbounds %"struct.std::pair.3", ptr %113, i32 0, i32 1
  %115 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE4findERS3_(ptr noundef nonnull align 8 dereferenceable(48) %114, ptr noundef nonnull align 4 dereferenceable(4) @id)
  %116 = getelementptr inbounds %"struct.std::_Rb_tree_iterator.10", ptr %12, i32 0, i32 0
  store ptr %115, ptr %116, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %117 = load ptr, ptr %11, align 8, !tbaa !10
  %118 = getelementptr inbounds %"struct.std::pair.3", ptr %117, i32 0, i32 1
  %119 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) %118) #5
  %120 = getelementptr inbounds %"struct.std::_Rb_tree_iterator.10", ptr %13, i32 0, i32 0
  store ptr %119, ptr %120, align 8
  %121 = call noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKiiEES5_(ptr noundef nonnull align 8 dereferenceable(8) %12, ptr noundef nonnull align 8 dereferenceable(8) %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  br i1 %121, label %122, label %134

122:                                              ; preds = %108
  %123 = load ptr, ptr %11, align 8, !tbaa !10
  %124 = getelementptr inbounds %"struct.std::pair.3", ptr %123, i32 0, i32 1
  %125 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) %124, ptr noundef nonnull align 4 dereferenceable(4) @id)
  %126 = load i32, ptr %125, align 4, !tbaa !5
  %127 = load ptr, ptr %11, align 8, !tbaa !10
  %128 = getelementptr inbounds %"struct.std::pair.3", ptr %127, i32 0, i32 0
  %129 = load i32, ptr %128, align 8, !tbaa !12
  %130 = sub nsw i32 %129, %126
  store i32 %130, ptr %128, align 8, !tbaa !12
  %131 = load ptr, ptr %11, align 8, !tbaa !10
  %132 = getelementptr inbounds %"struct.std::pair.3", ptr %131, i32 0, i32 1
  %133 = call noundef i64 @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE5eraseERS3_(ptr noundef nonnull align 8 dereferenceable(48) %132, ptr noundef nonnull align 4 dereferenceable(4) @id)
  br label %134

134:                                              ; preds = %122, %108
  %135 = load ptr, ptr %11, align 8, !tbaa !10
  %136 = getelementptr inbounds %"struct.std::pair.3", ptr %135, i32 0, i32 0
  %137 = load i32, ptr %136, align 8, !tbaa !12
  %138 = icmp ne i32 %137, 0
  br i1 %138, label %144, label %139

139:                                              ; preds = %134
  %140 = load i32, ptr @id, align 4, !tbaa !5
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [16384 x i32], ptr @P, i64 0, i64 %141
  %143 = call noundef i64 @_ZNSt3mapIiSt4pairIiS_IiiSt4lessIiESaIS0_IKiiEEEES2_SaIS0_IS3_S7_EEE5eraseERS3_(ptr noundef nonnull align 8 dereferenceable(48) @Sell, ptr noundef nonnull align 4 dereferenceable(4) %142)
  br label %144

144:                                              ; preds = %139, %134
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  br label %145

145:                                              ; preds = %144, %99
  br label %146

146:                                              ; preds = %145, %51
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  store i32 0, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  store i32 0, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  store i32 0, ptr %16, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  store i32 99999, ptr %17, align 4, !tbaa !5
  %147 = call noundef zeroext i1 @_ZNKSt3mapIiSt4pairIiS_IiiSt4lessIiESaIS0_IKiiEEEESt7greaterIiESaIS0_IS3_S7_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(48) @Buy) #5
  br i1 %147, label %158, label %148

148:                                              ; preds = %146
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  %149 = call ptr @_ZNSt3mapIiSt4pairIiS_IiiSt4lessIiESaIS0_IKiiEEEESt7greaterIiESaIS0_IS3_S7_EEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @Buy) #5
  %150 = getelementptr inbounds %"struct.std::_Rb_tree_iterator", ptr %18, i32 0, i32 0
  store ptr %149, ptr %150, align 8
  %151 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKiS0_IiSt3mapIiiSt4lessIiESaIS0_IS1_iEEEEEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %18) #5
  %152 = getelementptr inbounds %"struct.std::pair", ptr %151, i32 0, i32 1
  %153 = getelementptr inbounds %"struct.std::pair.3", ptr %152, i32 0, i32 0
  %154 = load i32, ptr %153, align 8, !tbaa !23
  store i32 %154, ptr %14, align 4, !tbaa !5
  %155 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKiS0_IiSt3mapIiiSt4lessIiESaIS0_IS1_iEEEEEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %18) #5
  %156 = getelementptr inbounds %"struct.std::pair", ptr %155, i32 0, i32 0
  %157 = load i32, ptr %156, align 8, !tbaa !25
  store i32 %157, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  br label %158

158:                                              ; preds = %148, %146
  %159 = call noundef zeroext i1 @_ZNKSt3mapIiSt4pairIiS_IiiSt4lessIiESaIS0_IKiiEEEES2_SaIS0_IS3_S7_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(48) @Sell) #5
  br i1 %159, label %170, label %160

160:                                              ; preds = %158
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #5
  %161 = call ptr @_ZNSt3mapIiSt4pairIiS_IiiSt4lessIiESaIS0_IKiiEEEES2_SaIS0_IS3_S7_EEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @Sell) #5
  %162 = getelementptr inbounds %"struct.std::_Rb_tree_iterator", ptr %19, i32 0, i32 0
  store ptr %161, ptr %162, align 8
  %163 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKiS0_IiSt3mapIiiSt4lessIiESaIS0_IS1_iEEEEEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %19) #5
  %164 = getelementptr inbounds %"struct.std::pair", ptr %163, i32 0, i32 1
  %165 = getelementptr inbounds %"struct.std::pair.3", ptr %164, i32 0, i32 0
  %166 = load i32, ptr %165, align 8, !tbaa !23
  store i32 %166, ptr %16, align 4, !tbaa !5
  %167 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKiS0_IiSt3mapIiiSt4lessIiESaIS0_IS1_iEEEEEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %19) #5
  %168 = getelementptr inbounds %"struct.std::pair", ptr %167, i32 0, i32 0
  %169 = load i32, ptr %168, align 8, !tbaa !25
  store i32 %169, ptr %17, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  br label %170

170:                                              ; preds = %160, %158
  %171 = load i32, ptr %14, align 4, !tbaa !5
  %172 = load i32, ptr %15, align 4, !tbaa !5
  %173 = load i32, ptr %16, align 4, !tbaa !5
  %174 = load i32, ptr %17, align 4, !tbaa !5
  %175 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, i32 noundef %171, i32 noundef %172, i32 noundef %173, i32 noundef %174)
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 10, ptr %3) #5
  br label %176

176:                                              ; preds = %170
  %177 = load i32, ptr %2, align 4, !tbaa !5
  %178 = add nsw i32 %177, 1
  store i32 %178, ptr %2, align 4, !tbaa !5
  br label %21, !llvm.loop !26

179:                                              ; preds = %25
  ret i32 0
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #3

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE3endEv(ptr noundef nonnull align 8 dereferenceable(48)) #1 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 nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!13, !6, i64 0}
!13 = !{!"_ZTSSt4pairIiSt3mapIiiSt4lessIiESaIS_IKiiEEEE", !6, i64 0, !14, i64 8}
!14 = !{!"_ZTSSt3mapIiiSt4lessIiESaISt4pairIKiiEEE", !15, i64 0}
!15 = !{!"_ZTSSt8_Rb_treeIiSt4pairIKiiESt10_Select1stIS2_ESt4lessIiESaIS2_EE", !16, i64 0}
!16 = !{!"_ZTSNSt8_Rb_treeIiSt4pairIKiiESt10_Select1stIS2_ESt4lessIiESaIS2_EE13_Rb_tree_implIS6_Lb1EEE", !17, i64 0, !19, i64 8}
!17 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessIiEE", !18, i64 0}
!18 = !{!"_ZTSSt4lessIiE"}
!19 = !{!"_ZTSSt15_Rb_tree_header", !20, i64 0, !22, i64 32}
!20 = !{!"_ZTSSt18_Rb_tree_node_base", !21, i64 0, !11, i64 8, !11, i64 16, !11, i64 24}
!21 = !{!"_ZTSSt14_Rb_tree_color", !7, i64 0}
!22 = !{!"long", !7, i64 0}
!23 = !{!24, !6, i64 8}
!24 = !{!"_ZTSSt4pairIKiS_IiSt3mapIiiSt4lessIiESaIS_IS0_iEEEEE", !6, i64 0, !13, i64 8}
!25 = !{!24, !6, i64 0}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}


; 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::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<int, std::pair<const int, std::pair<int, std::map<int, int>>>, std::_Select1st<std::pair<const int, std::pair<int, std::map<int, int>>>>, std::greater<int>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<int, std::pair<const int, std::pair<int, std::map<int, int>>>, std::_Select1st<std::pair<const int, std::pair<int, std::map<int, int>>>>, std::greater<int>>::_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 }
%"class.std::map.0" = type { %"class.std::_Rb_tree.1" }
%"class.std::_Rb_tree.1" = type { %"struct.std::_Rb_tree<int, std::pair<const int, std::pair<int, std::map<int, int>>>, std::_Select1st<std::pair<const int, std::pair<int, std::map<int, int>>>>, std::less<int>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<int, std::pair<const int, std::pair<int, std::map<int, int>>>, std::_Select1st<std::pair<const int, std::pair<int, std::map<int, int>>>>, std::less<int>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_iterator" = type { ptr }
%"struct.std::_Rb_tree_iterator.10" = type { ptr }

@Buy = external dso_local global %"class.std::map", align 8
@Sell = external dso_local global %"class.std::map.0", align 8
@n = external dso_local global i32, align 4
@id = external dso_local global i32, align 4
@p = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@P = external dso_local global [16384 x i32], align 16
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z8MaintainRSt3mapIiSt4pairIiS_IiiSt4lessIiESaIS0_IKiiEEEESt7greaterIiESaIS0_IS3_S7_EEERS_IiS7_S2_SB_E(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #0

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

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

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

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

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

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

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

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z8MaintainRSt3mapIiSt4pairIiS_IiiSt4lessIiESaIS0_IKiiEEEES2_SaIS0_IS3_S7_EEERS_IiS7_St7greaterIiES9_E(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #0

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

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

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

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

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #4 {
  %1 = alloca [10 x i8], align 1
  %2 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %3 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %4 = alloca %"struct.std::_Rb_tree_iterator.10", align 8
  %5 = alloca %"struct.std::_Rb_tree_iterator.10", align 8
  %6 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %7 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %8 = alloca %"struct.std::_Rb_tree_iterator.10", align 8
  %9 = alloca %"struct.std::_Rb_tree_iterator.10", align 8
  %10 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %11 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %12 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull @n)
  %13 = load i32, ptr @n, align 4, !tbaa !5
  %.not28 = icmp slt i32 %13, 1
  br i1 %.not28, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %102, %0
  ret i32 0

.lr.ph:                                           ; preds = %0, %102
  %indvars.iv = phi i64 [ %indvars.iv.next, %102 ], [ 1, %0 ]
  call void @llvm.lifetime.start.p0(i64 10, ptr nonnull %1) #5
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.3, ptr noundef nonnull %1)
  %15 = load i8, ptr %1, align 1
  switch i8 %15, label %25 [
    i8 83, label %16
    i8 66, label %16
  ]

16:                                               ; preds = %.lr.ph, %.lr.ph
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.4, ptr noundef nonnull @q, ptr noundef nonnull @p)
  %18 = load i32, ptr @p, align 4, !tbaa !5
  %19 = getelementptr inbounds [16384 x i32], ptr @P, i64 0, i64 %indvars.iv
  store i32 %18, ptr %19, align 4, !tbaa !5
  %20 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %20, ptr @id, align 4, !tbaa !5
  %21 = load i8, ptr %1, align 1, !tbaa !9
  %22 = icmp eq i8 %21, 66
  br i1 %22, label %23, label %24

23:                                               ; preds = %16
  call void @_Z8MaintainRSt3mapIiSt4pairIiS_IiiSt4lessIiESaIS0_IKiiEEEESt7greaterIiESaIS0_IS3_S7_EEERS_IiS7_S2_SB_E(ptr noundef nonnull align 8 dereferenceable(48) @Buy, ptr noundef nonnull align 8 dereferenceable(48) @Sell)
  br label %84

24:                                               ; preds = %16
  call void @_Z8MaintainRSt3mapIiSt4pairIiS_IiiSt4lessIiESaIS0_IKiiEEEES2_SaIS0_IS3_S7_EEERS_IiS7_St7greaterIiES9_E(ptr noundef nonnull align 8 dereferenceable(48) @Sell, ptr noundef nonnull align 8 dereferenceable(48) @Buy)
  br label %84

25:                                               ; preds = %.lr.ph
  %26 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull @id)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  %27 = load i32, ptr @id, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [16384 x i32], ptr @P, i64 0, i64 %28
  %30 = call ptr @_ZNSt3mapIiSt4pairIiS_IiiSt4lessIiESaIS0_IKiiEEEESt7greaterIiESaIS0_IS3_S7_EEE4findERS3_(ptr noundef nonnull align 8 dereferenceable(48) @Buy, ptr noundef nonnull align 4 dereferenceable(4) %29)
  store ptr %30, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  %31 = call ptr @_ZNSt3mapIiSt4pairIiS_IiiSt4lessIiESaIS0_IKiiEEEESt7greaterIiESaIS0_IS3_S7_EEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @Buy) #5
  store ptr %31, ptr %3, align 8
  %32 = call noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKiS0_IiSt3mapIiiSt4lessIiESaIS0_IS1_iEEEEEESC_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  br i1 %32, label %33, label %55

33:                                               ; preds = %25
  %34 = load i32, ptr @id, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [16384 x i32], ptr @P, i64 0, i64 %35
  %37 = call noundef nonnull align 8 dereferenceable(56) ptr @_ZNSt3mapIiSt4pairIiS_IiiSt4lessIiESaIS0_IKiiEEEESt7greaterIiESaIS0_IS3_S7_EEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @Buy, ptr noundef nonnull align 4 dereferenceable(4) %36)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  %38 = getelementptr inbounds i8, ptr %37, i64 8
  %39 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE4findERS3_(ptr noundef nonnull align 8 dereferenceable(48) %38, ptr noundef nonnull align 4 dereferenceable(4) @id)
  store ptr %39, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #5
  %40 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) %38) #5
  store ptr %40, ptr %5, align 8
  %41 = call noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKiiEES5_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  br i1 %41, label %42, label %48

42:                                               ; preds = %33
  %43 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) %38, ptr noundef nonnull align 4 dereferenceable(4) @id)
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = load i32, ptr %37, align 8, !tbaa !10
  %46 = sub nsw i32 %45, %44
  store i32 %46, ptr %37, align 8, !tbaa !10
  %47 = call noundef i64 @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE5eraseERS3_(ptr noundef nonnull align 8 dereferenceable(48) %38, ptr noundef nonnull align 4 dereferenceable(4) @id)
  br label %48

48:                                               ; preds = %42, %33
  %49 = load i32, ptr %37, align 8, !tbaa !10
  %.not26 = icmp eq i32 %49, 0
  br i1 %.not26, label %50, label %55

50:                                               ; preds = %48
  %51 = load i32, ptr @id, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [16384 x i32], ptr @P, i64 0, i64 %52
  %54 = call noundef i64 @_ZNSt3mapIiSt4pairIiS_IiiSt4lessIiESaIS0_IKiiEEEESt7greaterIiESaIS0_IS3_S7_EEE5eraseERS3_(ptr noundef nonnull align 8 dereferenceable(48) @Buy, ptr noundef nonnull align 4 dereferenceable(4) %53)
  br label %55

55:                                               ; preds = %48, %50, %25
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #5
  %56 = load i32, ptr @id, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [16384 x i32], ptr @P, i64 0, i64 %57
  %59 = call ptr @_ZNSt3mapIiSt4pairIiS_IiiSt4lessIiESaIS0_IKiiEEEES2_SaIS0_IS3_S7_EEE4findERS3_(ptr noundef nonnull align 8 dereferenceable(48) @Sell, ptr noundef nonnull align 4 dereferenceable(4) %58)
  store ptr %59, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #5
  %60 = call ptr @_ZNSt3mapIiSt4pairIiS_IiiSt4lessIiESaIS0_IKiiEEEES2_SaIS0_IS3_S7_EEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @Sell) #5
  store ptr %60, ptr %7, align 8
  %61 = call noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKiS0_IiSt3mapIiiSt4lessIiESaIS0_IS1_iEEEEEESC_(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(8) %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #5
  br i1 %61, label %62, label %84

62:                                               ; preds = %55
  %63 = load i32, ptr @id, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [16384 x i32], ptr @P, i64 0, i64 %64
  %66 = call noundef nonnull align 8 dereferenceable(56) ptr @_ZNSt3mapIiSt4pairIiS_IiiSt4lessIiESaIS0_IKiiEEEES2_SaIS0_IS3_S7_EEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @Sell, ptr noundef nonnull align 4 dereferenceable(4) %65)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #5
  %67 = getelementptr inbounds i8, ptr %66, i64 8
  %68 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE4findERS3_(ptr noundef nonnull align 8 dereferenceable(48) %67, ptr noundef nonnull align 4 dereferenceable(4) @id)
  store ptr %68, ptr %8, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #5
  %69 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) %67) #5
  store ptr %69, ptr %9, align 8
  %70 = call noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKiiEES5_(ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef nonnull align 8 dereferenceable(8) %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #5
  br i1 %70, label %71, label %77

71:                                               ; preds = %62
  %72 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) %67, ptr noundef nonnull align 4 dereferenceable(4) @id)
  %73 = load i32, ptr %72, align 4, !tbaa !5
  %74 = load i32, ptr %66, align 8, !tbaa !10
  %75 = sub nsw i32 %74, %73
  store i32 %75, ptr %66, align 8, !tbaa !10
  %76 = call noundef i64 @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE5eraseERS3_(ptr noundef nonnull align 8 dereferenceable(48) %67, ptr noundef nonnull align 4 dereferenceable(4) @id)
  br label %77

77:                                               ; preds = %71, %62
  %78 = load i32, ptr %66, align 8, !tbaa !10
  %.not27 = icmp eq i32 %78, 0
  br i1 %.not27, label %79, label %84

79:                                               ; preds = %77
  %80 = load i32, ptr @id, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [16384 x i32], ptr @P, i64 0, i64 %81
  %83 = call noundef i64 @_ZNSt3mapIiSt4pairIiS_IiiSt4lessIiESaIS0_IKiiEEEES2_SaIS0_IS3_S7_EEE5eraseERS3_(ptr noundef nonnull align 8 dereferenceable(48) @Sell, ptr noundef nonnull align 4 dereferenceable(4) %82)
  br label %84

84:                                               ; preds = %77, %79, %55, %23, %24
  %85 = call noundef zeroext i1 @_ZNKSt3mapIiSt4pairIiS_IiiSt4lessIiESaIS0_IKiiEEEESt7greaterIiESaIS0_IS3_S7_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(48) @Buy) #5
  br i1 %85, label %93, label %86

86:                                               ; preds = %84
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #5
  %87 = call ptr @_ZNSt3mapIiSt4pairIiS_IiiSt4lessIiESaIS0_IKiiEEEESt7greaterIiESaIS0_IS3_S7_EEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @Buy) #5
  store ptr %87, ptr %10, align 8
  %88 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKiS0_IiSt3mapIiiSt4lessIiESaIS0_IS1_iEEEEEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %10) #5
  %89 = getelementptr inbounds i8, ptr %88, i64 8
  %90 = load i32, ptr %89, align 8, !tbaa !22
  %91 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKiS0_IiSt3mapIiiSt4lessIiESaIS0_IS1_iEEEEEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %10) #5
  %92 = load i32, ptr %91, align 8, !tbaa !24
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #5
  br label %93

93:                                               ; preds = %86, %84
  %.024 = phi i32 [ 0, %84 ], [ %90, %86 ]
  %.023 = phi i32 [ 0, %84 ], [ %92, %86 ]
  %94 = call noundef zeroext i1 @_ZNKSt3mapIiSt4pairIiS_IiiSt4lessIiESaIS0_IKiiEEEES2_SaIS0_IS3_S7_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(48) @Sell) #5
  br i1 %94, label %102, label %95

95:                                               ; preds = %93
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %11) #5
  %96 = call ptr @_ZNSt3mapIiSt4pairIiS_IiiSt4lessIiESaIS0_IKiiEEEES2_SaIS0_IS3_S7_EEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @Sell) #5
  store ptr %96, ptr %11, align 8
  %97 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKiS0_IiSt3mapIiiSt4lessIiESaIS0_IS1_iEEEEEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %11) #5
  %98 = getelementptr inbounds i8, ptr %97, i64 8
  %99 = load i32, ptr %98, align 8, !tbaa !22
  %100 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKiS0_IiSt3mapIiiSt4lessIiESaIS0_IS1_iEEEEEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %11) #5
  %101 = load i32, ptr %100, align 8, !tbaa !24
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #5
  br label %102

102:                                              ; preds = %95, %93
  %.022 = phi i32 [ 0, %93 ], [ %99, %95 ]
  %.0 = phi i32 [ 99999, %93 ], [ %101, %95 ]
  %103 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %.024, i32 noundef %.023, i32 noundef %.022, i32 noundef %.0)
  call void @llvm.lifetime.end.p0(i64 10, ptr nonnull %1) #5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %104 = load i32, ptr @n, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %.not.not = icmp slt i64 %indvars.iv, %105
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !25
}

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE3endEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #1 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 nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !6, i64 0}
!11 = !{!"_ZTSSt4pairIiSt3mapIiiSt4lessIiESaIS_IKiiEEEE", !6, i64 0, !12, i64 8}
!12 = !{!"_ZTSSt3mapIiiSt4lessIiESaISt4pairIKiiEEE", !13, i64 0}
!13 = !{!"_ZTSSt8_Rb_treeIiSt4pairIKiiESt10_Select1stIS2_ESt4lessIiESaIS2_EE", !14, i64 0}
!14 = !{!"_ZTSNSt8_Rb_treeIiSt4pairIKiiESt10_Select1stIS2_ESt4lessIiESaIS2_EE13_Rb_tree_implIS6_Lb1EEE", !15, i64 0, !17, i64 8}
!15 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessIiEE", !16, i64 0}
!16 = !{!"_ZTSSt4lessIiE"}
!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 = !{!23, !6, i64 8}
!23 = !{!"_ZTSSt4pairIKiS_IiSt3mapIiiSt4lessIiESaIS_IS0_iEEEEE", !6, i64 0, !11, i64 8}
!24 = !{!23, !6, i64 0}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}


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