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

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::pair" = type { i32, i32 }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@pre = external dso_local global [300001 x i32], align 16
@suf = external dso_local global [300001 x i32], align 16
@e = external dso_local global [300001 x %"class.std::vector"], align 16
@g = external dso_local global [300001 x %"class.std::vector"], align 16
@seg = external dso_local global [300001 x %"struct.std::pair"], align 16
@p = external dso_local global [300001 x %"struct.std::pair"], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z9tree_initii(i32 noundef, i32 noundef) #1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z8tree_updi(i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z8tree_quei(i32 noundef) #1

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

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

26:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #8
  br label %40

27:                                               ; preds = %22
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [300001 x %"struct.std::pair"], ptr @p, i64 0, i64 %29
  %31 = getelementptr inbounds %"struct.std::pair", ptr %30, i32 0, i32 0
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [300001 x %"struct.std::pair"], ptr @p, i64 0, i64 %33
  %35 = getelementptr inbounds %"struct.std::pair", ptr %34, i32 0, i32 1
  %36 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.5, ptr noundef %31, ptr noundef %35)
  br label %37

37:                                               ; preds = %27
  %38 = load i32, ptr %2, align 4, !tbaa !5
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %2, align 4, !tbaa !5
  br label %22, !llvm.loop !9

40:                                               ; preds = %26
  %41 = load i32, ptr @n, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds %"struct.std::pair", ptr @p, i64 %42
  %44 = getelementptr inbounds %"struct.std::pair", ptr %43, i64 1
  call void @_ZSt4sortIPSt4pairIiiEEvT_S3_(ptr noundef getelementptr inbounds (%"struct.std::pair", ptr @p, i64 1), ptr noundef %44)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #8
  store i32 1, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #8
  br label %45

45:                                               ; preds = %100, %40
  %46 = load i32, ptr %3, align 4, !tbaa !5
  %47 = load i32, ptr @n, align 4, !tbaa !5
  %48 = icmp sle i32 %46, %47
  br i1 %48, label %50, label %49

49:                                               ; preds = %45
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #8
  br label %102

50:                                               ; preds = %45
  %51 = load i32, ptr %3, align 4, !tbaa !5
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr %4, align 4, !tbaa !5
  br label %53

53:                                               ; preds = %88, %50
  %54 = load i32, ptr %4, align 4, !tbaa !5
  %55 = load i32, ptr @n, align 4, !tbaa !5
  %56 = icmp sle i32 %54, %55
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #8
  br i1 %56, label %57, label %76

57:                                               ; preds = %53
  %58 = load i32, ptr %4, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [300001 x %"struct.std::pair"], ptr @p, i64 0, i64 %59
  %61 = load i32, ptr %3, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [300001 x %"struct.std::pair"], ptr @p, i64 0, i64 %62
  %64 = getelementptr inbounds %"struct.std::pair", ptr %63, i32 0, i32 0
  %65 = load i32, ptr %3, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [300001 x %"struct.std::pair"], ptr @p, i64 0, i64 %66
  %68 = getelementptr inbounds %"struct.std::pair", ptr %67, i32 0, i32 1
  %69 = load i32, ptr %68, align 4, !tbaa !11
  %70 = load i32, ptr %4, align 4, !tbaa !5
  %71 = add nsw i32 %69, %70
  %72 = load i32, ptr %3, align 4, !tbaa !5
  %73 = sub nsw i32 %71, %72
  store i32 %73, ptr %6, align 4, !tbaa !5
  %74 = call i64 @_ZSt9make_pairIRiiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %64, ptr noundef nonnull align 4 dereferenceable(4) %6)
  store i64 %74, ptr %5, align 4
  %75 = call noundef zeroext i1 @_ZSteqIiiEbRKSt4pairIT_T0_ES5_(ptr noundef nonnull align 4 dereferenceable(8) %60, ptr noundef nonnull align 4 dereferenceable(8) %5)
  br label %76

76:                                               ; preds = %57, %53
  %77 = phi i1 [ false, %53 ], [ %75, %57 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #8
  br i1 %77, label %78, label %91

78:                                               ; preds = %76
  %79 = load i32, ptr %4, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [300001 x %"class.std::vector"], ptr @e, i64 0, i64 %80
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #8
  %82 = load i32, ptr %4, align 4, !tbaa !5
  %83 = sub nsw i32 %82, 1
  store i32 %83, ptr %7, align 4, !tbaa !5
  call void @_ZNSt6vectorIiSaIiEE9push_backEOi(ptr noundef nonnull align 8 dereferenceable(24) %81, ptr noundef nonnull align 4 dereferenceable(4) %7)
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #8
  %84 = load i32, ptr %4, align 4, !tbaa !5
  %85 = sub nsw i32 %84, 1
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [300001 x %"class.std::vector"], ptr @e, i64 0, i64 %86
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %87, ptr noundef nonnull align 4 dereferenceable(4) %4)
  br label %88

88:                                               ; preds = %78
  %89 = load i32, ptr %4, align 4, !tbaa !5
  %90 = add nsw i32 %89, 1
  store i32 %90, ptr %4, align 4, !tbaa !5
  br label %53, !llvm.loop !13

91:                                               ; preds = %76
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #8
  %92 = load i32, ptr %4, align 4, !tbaa !5
  %93 = sub nsw i32 %92, 1
  store i32 %93, ptr %9, align 4, !tbaa !5
  %94 = call i64 @_ZSt9make_pairIRiiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %9)
  store i64 %94, ptr %8, align 4
  %95 = load i32, ptr @m, align 4, !tbaa !5
  %96 = add nsw i32 %95, 1
  store i32 %96, ptr @m, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [300001 x %"struct.std::pair"], ptr @seg, i64 0, i64 %97
  %99 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8) %98, ptr noundef nonnull align 4 dereferenceable(8) %8) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #8
  br label %100

100:                                              ; preds = %91
  %101 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %101, ptr %3, align 4, !tbaa !5
  br label %45, !llvm.loop !14

102:                                              ; preds = %49
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #8
  store i32 1, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #8
  store i32 1, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #8
  store i32 1, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #8
  store i32 1, ptr %13, align 4, !tbaa !5
  br label %103

103:                                              ; preds = %189, %102
  %104 = load i32, ptr %10, align 4, !tbaa !5
  %105 = load i32, ptr @n, align 4, !tbaa !5
  %106 = icmp sle i32 %104, %105
  br i1 %106, label %108, label %107

107:                                              ; preds = %103
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  br label %192

108:                                              ; preds = %103
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #8
  %109 = load i32, ptr %10, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [300001 x %"struct.std::pair"], ptr @p, i64 0, i64 %110
  %112 = getelementptr inbounds %"struct.std::pair", ptr %111, i32 0, i32 0
  %113 = load i32, ptr %112, align 8, !tbaa !15
  %114 = sub nsw i32 %113, 1
  store i32 %114, ptr %15, align 4, !tbaa !5
  %115 = load i32, ptr %10, align 4, !tbaa !5
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds [300001 x %"struct.std::pair"], ptr @p, i64 0, i64 %116
  %118 = getelementptr inbounds %"struct.std::pair", ptr %117, i32 0, i32 1
  %119 = call i64 @_ZSt9make_pairIiRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %15, ptr noundef nonnull align 4 dereferenceable(4) %118)
  store i64 %119, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #8
  br label %120

120:                                              ; preds = %142, %108
  %121 = load i32, ptr %11, align 4, !tbaa !5
  %122 = load i32, ptr %10, align 4, !tbaa !5
  %123 = icmp slt i32 %121, %122
  br i1 %123, label %124, label %129

124:                                              ; preds = %120
  %125 = load i32, ptr %11, align 4, !tbaa !5
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [300001 x %"struct.std::pair"], ptr @p, i64 0, i64 %126
  %128 = call noundef zeroext i1 @_ZStltIiiEbRKSt4pairIT_T0_ES5_(ptr noundef nonnull align 4 dereferenceable(8) %127, ptr noundef nonnull align 4 dereferenceable(8) %14)
  br label %129

129:                                              ; preds = %124, %120
  %130 = phi i1 [ false, %120 ], [ %128, %124 ]
  br i1 %130, label %131, label %145

131:                                              ; preds = %129
  %132 = load i32, ptr %11, align 4, !tbaa !5
  %133 = load i32, ptr %13, align 4, !tbaa !5
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds [300001 x %"struct.std::pair"], ptr @seg, i64 0, i64 %134
  %136 = getelementptr inbounds %"struct.std::pair", ptr %135, i32 0, i32 1
  %137 = load i32, ptr %136, align 4, !tbaa !11
  %138 = icmp eq i32 %132, %137
  %139 = zext i1 %138 to i32
  %140 = load i32, ptr %13, align 4, !tbaa !5
  %141 = add nsw i32 %140, %139
  store i32 %141, ptr %13, align 4, !tbaa !5
  br label %142

142:                                              ; preds = %131
  %143 = load i32, ptr %11, align 4, !tbaa !5
  %144 = add nsw i32 %143, 1
  store i32 %144, ptr %11, align 4, !tbaa !5
  br label %120, !llvm.loop !16

145:                                              ; preds = %129
  %146 = load i32, ptr %11, align 4, !tbaa !5
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds [300001 x %"struct.std::pair"], ptr @p, i64 0, i64 %147
  %149 = call noundef zeroext i1 @_ZSteqIiiEbRKSt4pairIT_T0_ES5_(ptr noundef nonnull align 4 dereferenceable(8) %148, ptr noundef nonnull align 4 dereferenceable(8) %14)
  br i1 %149, label %150, label %178

150:                                              ; preds = %145
  %151 = load i32, ptr %10, align 4, !tbaa !5
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds [300001 x %"class.std::vector"], ptr @e, i64 0, i64 %152
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %153, ptr noundef nonnull align 4 dereferenceable(4) %11)
  %154 = load i32, ptr %11, align 4, !tbaa !5
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds [300001 x %"class.std::vector"], ptr @e, i64 0, i64 %155
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %156, ptr noundef nonnull align 4 dereferenceable(4) %10)
  %157 = load i32, ptr %12, align 4, !tbaa !5
  %158 = sext i32 %157 to i64
  %159 = getelementptr inbounds [300001 x %"class.std::vector"], ptr @g, i64 0, i64 %158
  %160 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %159) #8
  %161 = icmp ne i64 %160, 0
  br i1 %161, label %162, label %170

162:                                              ; preds = %150
  %163 = load i32, ptr %12, align 4, !tbaa !5
  %164 = sext i32 %163 to i64
  %165 = getelementptr inbounds [300001 x %"class.std::vector"], ptr @g, i64 0, i64 %164
  %166 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEE4backEv(ptr noundef nonnull align 8 dereferenceable(24) %165) #8
  %167 = load i32, ptr %166, align 4, !tbaa !5
  %168 = load i32, ptr %13, align 4, !tbaa !5
  %169 = icmp ne i32 %167, %168
  br i1 %169, label %170, label %177

170:                                              ; preds = %162, %150
  %171 = load i32, ptr %12, align 4, !tbaa !5
  %172 = sext i32 %171 to i64
  %173 = getelementptr inbounds [300001 x %"class.std::vector"], ptr @g, i64 0, i64 %172
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %173, ptr noundef nonnull align 4 dereferenceable(4) %13)
  %174 = load i32, ptr %13, align 4, !tbaa !5
  %175 = sext i32 %174 to i64
  %176 = getelementptr inbounds [300001 x %"class.std::vector"], ptr @g, i64 0, i64 %175
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %176, ptr noundef nonnull align 4 dereferenceable(4) %12)
  br label %177

177:                                              ; preds = %170, %162
  br label %178

178:                                              ; preds = %177, %145
  %179 = load i32, ptr %10, align 4, !tbaa !5
  %180 = load i32, ptr %12, align 4, !tbaa !5
  %181 = sext i32 %180 to i64
  %182 = getelementptr inbounds [300001 x %"struct.std::pair"], ptr @seg, i64 0, i64 %181
  %183 = getelementptr inbounds %"struct.std::pair", ptr %182, i32 0, i32 1
  %184 = load i32, ptr %183, align 4, !tbaa !11
  %185 = icmp eq i32 %179, %184
  %186 = zext i1 %185 to i32
  %187 = load i32, ptr %12, align 4, !tbaa !5
  %188 = add nsw i32 %187, %186
  store i32 %188, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #8
  br label %189

189:                                              ; preds = %178
  %190 = load i32, ptr %10, align 4, !tbaa !5
  %191 = add nsw i32 %190, 1
  store i32 %191, ptr %10, align 4, !tbaa !5
  br label %103, !llvm.loop !17

192:                                              ; preds = %107
  call void @_Z9tree_initii(i32 noundef 0, i32 noundef 1)
  %193 = load i32, ptr @n, align 4, !tbaa !5
  %194 = sext i32 %193 to i64
  %195 = mul i64 %194, 4
  call void @llvm.memset.p0.i64(ptr align 4 getelementptr inbounds (i32, ptr @pre, i64 1), i8 63, i64 %195, i1 false)
  %196 = load i32, ptr @n, align 4, !tbaa !5
  %197 = sext i32 %196 to i64
  %198 = mul i64 %197, 4
  call void @llvm.memset.p0.i64(ptr align 4 getelementptr inbounds (i32, ptr @suf, i64 1), i8 63, i64 %198, i1 false)
  %199 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @q)
  call void @llvm.lifetime.start.p0(i64 1, ptr %16) #8
  store i8 0, ptr %16, align 1, !tbaa !18
  br label %200

200:                                              ; preds = %230, %192
  %201 = load i32, ptr @q, align 4, !tbaa !5
  %202 = add nsw i32 %201, -1
  store i32 %202, ptr @q, align 4, !tbaa !5
  %203 = icmp ne i32 %201, 0
  br i1 %203, label %204, label %231

204:                                              ; preds = %200
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #8
  %205 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.6, ptr noundef %17, ptr noundef %18, ptr noundef %19)
  %206 = load i32, ptr @n, align 4, !tbaa !5
  %207 = sext i32 %206 to i64
  %208 = getelementptr inbounds %"struct.std::pair", ptr @p, i64 %207
  %209 = getelementptr inbounds %"struct.std::pair", ptr %208, i64 1
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #8
  %210 = call i64 @_ZSt9make_pairIRiS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %18, ptr noundef nonnull align 4 dereferenceable(4) %19)
  store i64 %210, ptr %20, align 4
  %211 = call noundef ptr @_ZSt11lower_boundIPSt4pairIiiES1_ET_S3_S3_RKT0_(ptr noundef getelementptr inbounds (%"struct.std::pair", ptr @p, i64 1), ptr noundef %209, ptr noundef nonnull align 4 dereferenceable(8) %20)
  %212 = ptrtoint ptr %211 to i64
  %213 = sub i64 %212, ptrtoint (ptr @p to i64)
  %214 = sdiv exact i64 %213, 8
  %215 = trunc i64 %214 to i32
  store i32 %215, ptr %18, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #8
  %216 = load i32, ptr %17, align 4, !tbaa !5
  %217 = icmp eq i32 %216, 1
  br i1 %217, label %218, label %220

218:                                              ; preds = %204
  %219 = load i32, ptr %18, align 4, !tbaa !5
  call void @_Z8tree_updi(i32 noundef %219)
  store i8 1, ptr %16, align 1, !tbaa !18
  br label %230

220:                                              ; preds = %204
  %221 = load i8, ptr %16, align 1, !tbaa !18, !range !20, !noundef !21
  %222 = trunc i8 %221 to i1
  br i1 %222, label %223, label %226

223:                                              ; preds = %220
  %224 = load i32, ptr %18, align 4, !tbaa !5
  %225 = call noundef i32 @_Z8tree_quei(i32 noundef %224)
  br label %227

226:                                              ; preds = %220
  br label %227

227:                                              ; preds = %226, %223
  %228 = phi i32 [ %225, %223 ], [ -1, %226 ]
  %229 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, i32 noundef %228)
  br label %230

230:                                              ; preds = %227, %218
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #8
  br label %200, !llvm.loop !22

231:                                              ; preds = %200
  call void @llvm.lifetime.end.p0(i64 1, ptr %16) #8
  ret i32 0
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPSt4pairIiiEEvT_S3_(ptr noundef, ptr noundef) #5

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

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

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

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

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

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZSt11lower_boundIPSt4pairIiiES1_ET_S3_S3_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(8)) #5

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

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

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


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

%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::pair" = type { i32, i32 }

@n = external dso_local global i32, align 4
@m = external dso_local local_unnamed_addr global i32, align 4
@q = external dso_local global i32, align 4
@pre = external dso_local local_unnamed_addr global [300001 x i32], align 16
@suf = external dso_local local_unnamed_addr global [300001 x i32], align 16
@e = external dso_local global [300001 x %"class.std::vector"], align 16
@g = external dso_local global [300001 x %"class.std::vector"], align 16
@seg = external dso_local global [300001 x %"struct.std::pair"], align 16
@p = external dso_local global [300001 x %"struct.std::pair"], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z9tree_initii(i32 noundef, i32 noundef) local_unnamed_addr #1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z8tree_updi(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z8tree_quei(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca %"struct.std::pair", align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca %"struct.std::pair", align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca %"struct.std::pair", align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca %"struct.std::pair", align 8
  %18 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %19 = load i32, ptr @n, align 4, !tbaa !5
  %.not17 = icmp slt i32 %19, 1
  br i1 %.not17, label %.._crit_edge_crit_edge, label %.lr.ph

.._crit_edge_crit_edge:                           ; preds = %0
  %.pre41 = sext i32 %19 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre41, %.._crit_edge_crit_edge ], [ %27, %.lr.ph ]
  %20 = getelementptr inbounds %"struct.std::pair", ptr @p, i64 %.pre-phi
  %21 = getelementptr inbounds i8, ptr %20, i64 8
  tail call void @_ZSt4sortIPSt4pairIiiEEvT_S3_(ptr noundef nonnull getelementptr inbounds (i8, ptr @p, i64 8), ptr noundef nonnull %21)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #8
  store i32 1, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #8
  %22 = load i32, ptr @n, align 4, !tbaa !5
  %.not1123 = icmp slt i32 %22, 1
  br i1 %.not1123, label %._crit_edge24.thread, label %.preheader

._crit_edge24.thread:                             ; preds = %._crit_edge
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %10) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %11) #8
  br label %._crit_edge31

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %0 ]
  %23 = getelementptr inbounds [300001 x %"struct.std::pair"], ptr @p, i64 0, i64 %indvars.iv
  %24 = getelementptr inbounds i8, ptr %23, i64 4
  %25 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.5, ptr noundef nonnull %23, ptr noundef nonnull %24)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %26 = load i32, ptr @n, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %.not.not = icmp slt i64 %indvars.iv, %27
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !9

.preheader:                                       ; preds = %._crit_edge, %.loopexit
  %28 = phi i32 [ %63, %.loopexit ], [ %22, %._crit_edge ]
  %29 = phi i32 [ %62, %.loopexit ], [ 1, %._crit_edge ]
  %storemerge19 = add nsw i32 %29, 1
  store i32 %storemerge19, ptr %2, align 4, !tbaa !5
  %.not16.not20 = icmp slt i32 %29, %28
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #8
  br i1 %.not16.not20, label %.lr.ph22, label %.critedge

._crit_edge24:                                    ; preds = %.loopexit
  %30 = icmp slt i32 %63, 1
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #8
  store i32 1, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #8
  store i32 1, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %10) #8
  store i32 1, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %11) #8
  store i32 1, ptr %11, align 4, !tbaa !5
  br i1 %30, label %._crit_edge31, label %.lr.ph30

.lr.ph22:                                         ; preds = %.preheader, %43
  %storemerge21 = phi i32 [ %storemerge, %43 ], [ %storemerge19, %.preheader ]
  %31 = sext i32 %storemerge21 to i64
  %32 = getelementptr inbounds [300001 x %"struct.std::pair"], ptr @p, i64 0, i64 %31
  %33 = load i32, ptr %1, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [300001 x %"struct.std::pair"], ptr @p, i64 0, i64 %34
  %36 = getelementptr inbounds i8, ptr %35, i64 4
  %37 = load i32, ptr %36, align 4, !tbaa !11
  %38 = sub i32 %storemerge21, %33
  %39 = add i32 %38, %37
  store i32 %39, ptr %4, align 4, !tbaa !5
  %40 = call i64 @_ZSt9make_pairIRiiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %35, ptr noundef nonnull align 4 dereferenceable(4) %4)
  store i64 %40, ptr %3, align 8
  %41 = call noundef zeroext i1 @_ZSteqIiiEbRKSt4pairIT_T0_ES5_(ptr noundef nonnull align 4 dereferenceable(8) %32, ptr noundef nonnull align 4 dereferenceable(8) %3)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #8
  %42 = load i32, ptr %2, align 4, !tbaa !5
  br i1 %41, label %43, label %.loopexit

43:                                               ; preds = %.lr.ph22
  %44 = sext i32 %42 to i64
  %45 = getelementptr inbounds [300001 x %"class.std::vector"], ptr @e, i64 0, i64 %44
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #8
  %46 = add nsw i32 %42, -1
  store i32 %46, ptr %5, align 4, !tbaa !5
  call void @_ZNSt6vectorIiSaIiEE9push_backEOi(ptr noundef nonnull align 8 dereferenceable(24) %45, ptr noundef nonnull align 4 dereferenceable(4) %5)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #8
  %47 = load i32, ptr %2, align 4, !tbaa !5
  %48 = add nsw i32 %47, -1
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [300001 x %"class.std::vector"], ptr @e, i64 0, i64 %49
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %50, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %51 = load i32, ptr %2, align 4, !tbaa !5
  %storemerge = add nsw i32 %51, 1
  store i32 %storemerge, ptr %2, align 4, !tbaa !5
  %52 = load i32, ptr @n, align 4, !tbaa !5
  %.not16.not = icmp slt i32 %51, %52
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #8
  br i1 %.not16.not, label %.lr.ph22, label %.critedge, !llvm.loop !13

.critedge:                                        ; preds = %43, %.preheader
  %53 = phi i32 [ %storemerge19, %.preheader ], [ %storemerge, %43 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #8
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph22, %.critedge
  %54 = phi i32 [ %53, %.critedge ], [ %42, %.lr.ph22 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #8
  %55 = add nsw i32 %54, -1
  store i32 %55, ptr %7, align 4, !tbaa !5
  %56 = call i64 @_ZSt9make_pairIRiiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 4 dereferenceable(4) %7)
  store i64 %56, ptr %6, align 8
  %57 = load i32, ptr @m, align 4, !tbaa !5
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr @m, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [300001 x %"struct.std::pair"], ptr @seg, i64 0, i64 %59
  %61 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8) %60, ptr noundef nonnull align 4 dereferenceable(8) %6) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #8
  %62 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %62, ptr %1, align 4, !tbaa !5
  %63 = load i32, ptr @n, align 4, !tbaa !5
  %.not11 = icmp sgt i32 %62, %63
  br i1 %.not11, label %._crit_edge24, label %.preheader, !llvm.loop !14

._crit_edge31:                                    ; preds = %124, %._crit_edge24.thread, %._crit_edge24
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %11) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %10) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #8
  call void @_Z9tree_initii(i32 noundef 0, i32 noundef 1)
  %64 = load i32, ptr @n, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = shl nsw i64 %65, 2
  call void @llvm.memset.p0.i64(ptr nonnull align 4 getelementptr inbounds (i8, ptr @pre, i64 4), i8 63, i64 %66, i1 false)
  call void @llvm.memset.p0.i64(ptr nonnull align 4 getelementptr inbounds (i8, ptr @suf, i64 4), i8 63, i64 %66, i1 false)
  %67 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @q)
  %68 = load i32, ptr @q, align 4, !tbaa !5
  %69 = add nsw i32 %68, -1
  store i32 %69, ptr @q, align 4, !tbaa !5
  %.not1332 = icmp eq i32 %68, 0
  br i1 %.not1332, label %._crit_edge36, label %.lr.ph35

.lr.ph30:                                         ; preds = %._crit_edge24, %124
  %70 = phi i32 [ %133, %124 ], [ 1, %._crit_edge24 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %12) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %13) #8
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [300001 x %"struct.std::pair"], ptr @p, i64 0, i64 %71
  %73 = load i32, ptr %72, align 8, !tbaa !15
  %74 = add nsw i32 %73, -1
  store i32 %74, ptr %13, align 4, !tbaa !5
  %75 = getelementptr inbounds [300001 x %"struct.std::pair"], ptr @p, i64 0, i64 %71, i32 1
  %76 = call i64 @_ZSt9make_pairIiRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %13, ptr noundef nonnull align 4 dereferenceable(4) %75)
  store i64 %76, ptr %12, align 8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %13) #8
  %77 = load i32, ptr %9, align 4, !tbaa !5
  %78 = load i32, ptr %8, align 4, !tbaa !5
  %79 = icmp slt i32 %77, %78
  br i1 %79, label %.lr.ph26, label %.critedge2

.lr.ph26:                                         ; preds = %.lr.ph30, %84
  %80 = phi i32 [ %92, %84 ], [ %77, %.lr.ph30 ]
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [300001 x %"struct.std::pair"], ptr @p, i64 0, i64 %81
  %83 = call noundef zeroext i1 @_ZStltIiiEbRKSt4pairIT_T0_ES5_(ptr noundef nonnull align 4 dereferenceable(8) %82, ptr noundef nonnull align 4 dereferenceable(8) %12)
  %.pre39.pre = load i32, ptr %9, align 4, !tbaa !5
  br i1 %83, label %84, label %.critedge2

84:                                               ; preds = %.lr.ph26
  %85 = load i32, ptr %11, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [300001 x %"struct.std::pair"], ptr @seg, i64 0, i64 %86, i32 1
  %88 = load i32, ptr %87, align 4, !tbaa !11
  %89 = icmp eq i32 %.pre39.pre, %88
  %90 = zext i1 %89 to i32
  %91 = add nsw i32 %85, %90
  store i32 %91, ptr %11, align 4, !tbaa !5
  %92 = add nsw i32 %.pre39.pre, 1
  store i32 %92, ptr %9, align 4, !tbaa !5
  %93 = load i32, ptr %8, align 4, !tbaa !5
  %94 = icmp slt i32 %92, %93
  br i1 %94, label %.lr.ph26, label %.critedge2, !llvm.loop !16

.critedge2:                                       ; preds = %.lr.ph26, %84, %.lr.ph30
  %95 = phi i32 [ %77, %.lr.ph30 ], [ %.pre39.pre, %.lr.ph26 ], [ %92, %84 ]
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [300001 x %"struct.std::pair"], ptr @p, i64 0, i64 %96
  %98 = call noundef zeroext i1 @_ZSteqIiiEbRKSt4pairIT_T0_ES5_(ptr noundef nonnull align 4 dereferenceable(8) %97, ptr noundef nonnull align 4 dereferenceable(8) %12)
  br i1 %98, label %99, label %124

99:                                               ; preds = %.critedge2
  %100 = load i32, ptr %8, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [300001 x %"class.std::vector"], ptr @e, i64 0, i64 %101
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %102, ptr noundef nonnull align 4 dereferenceable(4) %9)
  %103 = load i32, ptr %9, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [300001 x %"class.std::vector"], ptr @e, i64 0, i64 %104
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %105, ptr noundef nonnull align 4 dereferenceable(4) %8)
  %106 = load i32, ptr %10, align 4, !tbaa !5
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [300001 x %"class.std::vector"], ptr @g, i64 0, i64 %107
  %109 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %108) #8
  %.not14 = icmp eq i64 %109, 0
  br i1 %.not14, label %117, label %110

110:                                              ; preds = %99
  %111 = load i32, ptr %10, align 4, !tbaa !5
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [300001 x %"class.std::vector"], ptr @g, i64 0, i64 %112
  %114 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEE4backEv(ptr noundef nonnull align 8 dereferenceable(24) %113) #8
  %115 = load i32, ptr %114, align 4, !tbaa !5
  %116 = load i32, ptr %11, align 4, !tbaa !5
  %.not15 = icmp eq i32 %115, %116
  br i1 %.not15, label %124, label %117

117:                                              ; preds = %110, %99
  %118 = load i32, ptr %10, align 4, !tbaa !5
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [300001 x %"class.std::vector"], ptr @g, i64 0, i64 %119
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %120, ptr noundef nonnull align 4 dereferenceable(4) %11)
  %121 = load i32, ptr %11, align 4, !tbaa !5
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [300001 x %"class.std::vector"], ptr @g, i64 0, i64 %122
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %123, ptr noundef nonnull align 4 dereferenceable(4) %10)
  br label %124

124:                                              ; preds = %110, %117, %.critedge2
  %125 = load i32, ptr %8, align 4, !tbaa !5
  %126 = load i32, ptr %10, align 4, !tbaa !5
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds [300001 x %"struct.std::pair"], ptr @seg, i64 0, i64 %127, i32 1
  %129 = load i32, ptr %128, align 4, !tbaa !11
  %130 = icmp eq i32 %125, %129
  %131 = zext i1 %130 to i32
  %132 = add nsw i32 %126, %131
  store i32 %132, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %12) #8
  %133 = add nsw i32 %125, 1
  store i32 %133, ptr %8, align 4, !tbaa !5
  %134 = load i32, ptr @n, align 4, !tbaa !5
  %.not12.not = icmp slt i32 %125, %134
  br i1 %.not12.not, label %.lr.ph30, label %._crit_edge31, !llvm.loop !17

.lr.ph35:                                         ; preds = %._crit_edge31, %153
  %.033 = phi i1 [ %.1, %153 ], [ false, %._crit_edge31 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %14) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %15) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %16) #8
  %135 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.6, ptr noundef nonnull %14, ptr noundef nonnull %15, ptr noundef nonnull %16)
  %136 = load i32, ptr @n, align 4, !tbaa !5
  %137 = sext i32 %136 to i64
  %gep = getelementptr %"struct.std::pair", ptr getelementptr inbounds (i8, ptr @p, i64 8), i64 %137
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %17) #8
  %138 = call i64 @_ZSt9make_pairIRiS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %15, ptr noundef nonnull align 4 dereferenceable(4) %16)
  store i64 %138, ptr %17, align 8
  %139 = call noundef ptr @_ZSt11lower_boundIPSt4pairIiiES1_ET_S3_S3_RKT0_(ptr noundef nonnull getelementptr inbounds (i8, ptr @p, i64 8), ptr noundef nonnull %gep, ptr noundef nonnull align 4 dereferenceable(8) %17)
  %140 = ptrtoint ptr %139 to i64
  %141 = sub i64 %140, ptrtoint (ptr @p to i64)
  %142 = lshr exact i64 %141, 3
  %143 = trunc i64 %142 to i32
  store i32 %143, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %17) #8
  %144 = load i32, ptr %14, align 4, !tbaa !5
  %145 = icmp eq i32 %144, 1
  br i1 %145, label %146, label %147

146:                                              ; preds = %.lr.ph35
  call void @_Z8tree_updi(i32 noundef %143)
  br label %153

147:                                              ; preds = %.lr.ph35
  br i1 %.033, label %148, label %150

148:                                              ; preds = %147
  %149 = call noundef i32 @_Z8tree_quei(i32 noundef %143)
  br label %150

150:                                              ; preds = %147, %148
  %151 = phi i32 [ %149, %148 ], [ -1, %147 ]
  %152 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, i32 noundef %151)
  br label %153

153:                                              ; preds = %150, %146
  %.1 = phi i1 [ true, %146 ], [ %.033, %150 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %16) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %15) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %14) #8
  %154 = load i32, ptr @q, align 4, !tbaa !5
  %155 = add nsw i32 %154, -1
  store i32 %155, ptr @q, align 4, !tbaa !5
  %.not13 = icmp eq i32 %154, 0
  br i1 %.not13, label %._crit_edge36, label %.lr.ph35, !llvm.loop !18

._crit_edge36:                                    ; preds = %153, %._crit_edge31
  ret i32 0
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPSt4pairIiiEEvT_S3_(ptr noundef, ptr noundef) local_unnamed_addr #5

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

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

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

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

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

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZSt11lower_boundIPSt4pairIiiES1_ET_S3_S3_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #5

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

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

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


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