; LLVM IR from tangjz/acm-icpc :: hdu (6089)

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

%"struct.std::pair" = type { i32, i32 }
%struct.Segment = type { i32, i32, i64 }

@t = external dso_local global i32, align 4
@rr = external dso_local global i32, align 4
@cc = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@ord = external dso_local global [100001 x i32], align 16
@INF = external dso_local global i32, align 4
@a = external dso_local global [100001 x %"struct.std::pair"], align 16
@b = external dso_local global [100001 x %"struct.std::pair"], align 16
@ans = external dso_local global [100001 x i64], align 16
@segL = external dso_local global [200003 x %struct.Segment], align 16
@segR = external dso_local global [200003 x %struct.Segment], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z8seg_initP7Segmentii(ptr noundef, i32 noundef, i32 noundef) #0

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z7seg_idxii(i32 noundef, i32 noundef) #2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z7seg_updP7Segmentiiii(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #0

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

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

; 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)) #2

; 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 i32, align 4
  %6 = alloca i32, align 4
  %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 i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %20 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  br label %21

21:                                               ; preds = %505, %0
  %22 = load i32, ptr @t, align 4, !tbaa !5
  %23 = add nsw i32 %22, -1
  store i32 %23, ptr @t, align 4, !tbaa !5
  %24 = icmp ne i32 %22, 0
  br i1 %24, label %25, label %506

25:                                               ; preds = %21
  %26 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @rr, ptr noundef @cc, ptr noundef @n, ptr noundef @q)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %42, %25
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = load i32, ptr @n, align 4, !tbaa !5
  %30 = icmp slt i32 %28, %29
  br i1 %30, label %32, label %31

31:                                               ; preds = %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %45

32:                                               ; preds = %27
  %33 = load i32, ptr %2, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %34
  %36 = getelementptr inbounds %"struct.std::pair", ptr %35, i32 0, i32 0
  %37 = load i32, ptr %2, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %38
  %40 = getelementptr inbounds %"struct.std::pair", ptr %39, i32 0, i32 1
  %41 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %36, ptr noundef %40)
  br label %42

42:                                               ; preds = %32
  %43 = load i32, ptr %2, align 4, !tbaa !5
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr %2, align 4, !tbaa !5
  br label %27, !llvm.loop !9

45:                                               ; preds = %31
  %46 = load i32, ptr @n, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds %"struct.std::pair", ptr @a, i64 %47
  call void @_ZSt4sortIPSt4pairIiiEEvT_S3_(ptr noundef @a, ptr noundef %48)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %49

49:                                               ; preds = %71, %45
  %50 = load i32, ptr %3, align 4, !tbaa !5
  %51 = load i32, ptr @q, align 4, !tbaa !5
  %52 = icmp slt i32 %50, %51
  br i1 %52, label %54, label %53

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

54:                                               ; preds = %49
  %55 = load i32, ptr %3, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %56
  %58 = getelementptr inbounds %"struct.std::pair", ptr %57, i32 0, i32 0
  %59 = load i32, ptr %3, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %60
  %62 = getelementptr inbounds %"struct.std::pair", ptr %61, i32 0, i32 1
  %63 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %58, ptr noundef %62)
  %64 = load i32, ptr %3, align 4, !tbaa !5
  %65 = load i32, ptr %3, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %66
  store i32 %64, ptr %67, align 4, !tbaa !5
  %68 = load i32, ptr %3, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %69
  store i64 0, ptr %70, align 8, !tbaa !11
  br label %71

71:                                               ; preds = %54
  %72 = load i32, ptr %3, align 4, !tbaa !5
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %3, align 4, !tbaa !5
  br label %49, !llvm.loop !13

74:                                               ; preds = %53
  %75 = load i32, ptr @q, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds i32, ptr @ord, i64 %76
  call void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef @ord, ptr noundef %77, ptr noundef @_Z3cmpRKiS0_)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 0, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %78

78:                                               ; preds = %181, %74
  %79 = load i32, ptr %4, align 4, !tbaa !5
  %80 = load i32, ptr @q, align 4, !tbaa !5
  %81 = icmp slt i32 %79, %80
  br i1 %81, label %83, label %82

82:                                               ; preds = %78
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %184

83:                                               ; preds = %78
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  %84 = load i32, ptr %4, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %85
  %87 = load i32, ptr %86, align 4, !tbaa !5
  store i32 %87, ptr %6, align 4, !tbaa !5
  br label %88

88:                                               ; preds = %103, %83
  %89 = load i32, ptr %5, align 4, !tbaa !5
  %90 = load i32, ptr @n, align 4, !tbaa !5
  %91 = icmp slt i32 %89, %90
  br i1 %91, label %92, label %100

92:                                               ; preds = %88
  %93 = load i32, ptr %5, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %94
  %96 = load i32, ptr %6, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %97
  %99 = call noundef zeroext i1 @_ZStltIiiEbRKSt4pairIT_T0_ES5_(ptr noundef nonnull align 4 dereferenceable(8) %95, ptr noundef nonnull align 4 dereferenceable(8) %98)
  br label %100

100:                                              ; preds = %92, %88
  %101 = phi i1 [ false, %88 ], [ %99, %92 ]
  br i1 %101, label %102, label %106

102:                                              ; preds = %100
  br label %103

103:                                              ; preds = %102
  %104 = load i32, ptr %5, align 4, !tbaa !5
  %105 = add nsw i32 %104, 1
  store i32 %105, ptr %5, align 4, !tbaa !5
  br label %88, !llvm.loop !14

106:                                              ; preds = %100
  %107 = load i32, ptr %5, align 4, !tbaa !5
  %108 = load i32, ptr @n, align 4, !tbaa !5
  %109 = icmp eq i32 %107, %108
  br i1 %109, label %118, label %110

110:                                              ; preds = %106
  %111 = load i32, ptr %5, align 4, !tbaa !5
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %112
  %114 = load i32, ptr %6, align 4, !tbaa !5
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %115
  %117 = call noundef zeroext i1 @_ZStneIiiEbRKSt4pairIT_T0_ES5_(ptr noundef nonnull align 4 dereferenceable(8) %113, ptr noundef nonnull align 4 dereferenceable(8) %116)
  br i1 %117, label %118, label %180

118:                                              ; preds = %110, %106
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %119 = load i32, ptr %5, align 4, !tbaa !5
  %120 = icmp ne i32 %119, 0
  br i1 %120, label %121, label %141

121:                                              ; preds = %118
  %122 = load i32, ptr %5, align 4, !tbaa !5
  %123 = sub nsw i32 %122, 1
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %124
  %126 = getelementptr inbounds %"struct.std::pair", ptr %125, i32 0, i32 0
  %127 = load i32, ptr %126, align 8, !tbaa !15
  %128 = load i32, ptr %6, align 4, !tbaa !5
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %129
  %131 = getelementptr inbounds %"struct.std::pair", ptr %130, i32 0, i32 0
  %132 = load i32, ptr %131, align 8, !tbaa !15
  %133 = icmp eq i32 %127, %132
  br i1 %133, label %134, label %141

134:                                              ; preds = %121
  %135 = load i32, ptr %5, align 4, !tbaa !5
  %136 = sub nsw i32 %135, 1
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %137
  %139 = getelementptr inbounds %"struct.std::pair", ptr %138, i32 0, i32 1
  %140 = load i32, ptr %139, align 4, !tbaa !17
  br label %142

141:                                              ; preds = %121, %118
  br label %142

142:                                              ; preds = %141, %134
  %143 = phi i32 [ %140, %134 ], [ 0, %141 ]
  store i32 %143, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %144 = load i32, ptr %5, align 4, !tbaa !5
  %145 = load i32, ptr @n, align 4, !tbaa !5
  %146 = icmp slt i32 %144, %145
  br i1 %146, label %147, label %165

147:                                              ; preds = %142
  %148 = load i32, ptr %5, align 4, !tbaa !5
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %149
  %151 = getelementptr inbounds %"struct.std::pair", ptr %150, i32 0, i32 0
  %152 = load i32, ptr %151, align 8, !tbaa !15
  %153 = load i32, ptr %6, align 4, !tbaa !5
  %154 = sext i32 %153 to i64
  %155 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %154
  %156 = getelementptr inbounds %"struct.std::pair", ptr %155, i32 0, i32 0
  %157 = load i32, ptr %156, align 8, !tbaa !15
  %158 = icmp eq i32 %152, %157
  br i1 %158, label %159, label %165

159:                                              ; preds = %147
  %160 = load i32, ptr %5, align 4, !tbaa !5
  %161 = sext i32 %160 to i64
  %162 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %161
  %163 = getelementptr inbounds %"struct.std::pair", ptr %162, i32 0, i32 1
  %164 = load i32, ptr %163, align 4, !tbaa !17
  br label %168

165:                                              ; preds = %147, %142
  %166 = load i32, ptr @cc, align 4, !tbaa !5
  %167 = add nsw i32 %166, 1
  br label %168

168:                                              ; preds = %165, %159
  %169 = phi i32 [ %164, %159 ], [ %167, %165 ]
  store i32 %169, ptr %8, align 4, !tbaa !5
  %170 = load i32, ptr %8, align 4, !tbaa !5
  %171 = load i32, ptr %7, align 4, !tbaa !5
  %172 = sub nsw i32 %170, %171
  %173 = sub nsw i32 %172, 1
  %174 = sext i32 %173 to i64
  %175 = load i32, ptr %6, align 4, !tbaa !5
  %176 = sext i32 %175 to i64
  %177 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %176
  %178 = load i64, ptr %177, align 8, !tbaa !11
  %179 = sub nsw i64 %178, %174
  store i64 %179, ptr %177, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %180

180:                                              ; preds = %168, %110
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %181

181:                                              ; preds = %180
  %182 = load i32, ptr %4, align 4, !tbaa !5
  %183 = add nsw i32 %182, 1
  store i32 %183, ptr %4, align 4, !tbaa !5
  br label %78, !llvm.loop !18

184:                                              ; preds = %82
  %185 = load i32, ptr @cc, align 4, !tbaa !5
  call void @_Z8seg_initP7Segmentii(ptr noundef @segL, i32 noundef 1, i32 noundef %185)
  %186 = load i32, ptr @cc, align 4, !tbaa !5
  call void @_Z8seg_initP7Segmentii(ptr noundef @segR, i32 noundef 1, i32 noundef %186)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %187 = load i32, ptr @q, align 4, !tbaa !5
  %188 = sub nsw i32 %187, 1
  store i32 %188, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %189 = load i32, ptr @n, align 4, !tbaa !5
  %190 = sub nsw i32 %189, 1
  store i32 %190, ptr %10, align 4, !tbaa !5
  br label %191

191:                                              ; preds = %313, %184
  %192 = load i32, ptr %9, align 4, !tbaa !5
  %193 = icmp sge i32 %192, 0
  br i1 %193, label %195, label %194

194:                                              ; preds = %191
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %316

195:                                              ; preds = %191
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %196 = load i32, ptr %9, align 4, !tbaa !5
  %197 = sext i32 %196 to i64
  %198 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %197
  %199 = load i32, ptr %198, align 4, !tbaa !5
  store i32 %199, ptr %11, align 4, !tbaa !5
  br label %200

200:                                              ; preds = %243, %195
  %201 = load i32, ptr %10, align 4, !tbaa !5
  %202 = icmp sge i32 %201, 0
  br i1 %202, label %203, label %215

203:                                              ; preds = %200
  %204 = load i32, ptr %10, align 4, !tbaa !5
  %205 = sext i32 %204 to i64
  %206 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %205
  %207 = getelementptr inbounds %"struct.std::pair", ptr %206, i32 0, i32 0
  %208 = load i32, ptr %207, align 8, !tbaa !15
  %209 = load i32, ptr %11, align 4, !tbaa !5
  %210 = sext i32 %209 to i64
  %211 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %210
  %212 = getelementptr inbounds %"struct.std::pair", ptr %211, i32 0, i32 0
  %213 = load i32, ptr %212, align 8, !tbaa !15
  %214 = icmp sge i32 %208, %213
  br label %215

215:                                              ; preds = %203, %200
  %216 = phi i1 [ false, %200 ], [ %214, %203 ]
  br i1 %216, label %217, label %246

217:                                              ; preds = %215
  %218 = load i32, ptr @cc, align 4, !tbaa !5
  %219 = load i32, ptr %10, align 4, !tbaa !5
  %220 = sext i32 %219 to i64
  %221 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %220
  %222 = getelementptr inbounds %"struct.std::pair", ptr %221, i32 0, i32 1
  %223 = load i32, ptr %222, align 4, !tbaa !17
  %224 = load i32, ptr %10, align 4, !tbaa !5
  %225 = sext i32 %224 to i64
  %226 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %225
  %227 = getelementptr inbounds %"struct.std::pair", ptr %226, i32 0, i32 0
  %228 = load i32, ptr %227, align 8, !tbaa !15
  call void @_Z7seg_updP7Segmentiiii(ptr noundef @segL, i32 noundef 1, i32 noundef %218, i32 noundef %223, i32 noundef %228)
  %229 = load i32, ptr @cc, align 4, !tbaa !5
  %230 = load i32, ptr @cc, align 4, !tbaa !5
  %231 = load i32, ptr %10, align 4, !tbaa !5
  %232 = sext i32 %231 to i64
  %233 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %232
  %234 = getelementptr inbounds %"struct.std::pair", ptr %233, i32 0, i32 1
  %235 = load i32, ptr %234, align 4, !tbaa !17
  %236 = sub nsw i32 %230, %235
  %237 = add nsw i32 %236, 1
  %238 = load i32, ptr %10, align 4, !tbaa !5
  %239 = sext i32 %238 to i64
  %240 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %239
  %241 = getelementptr inbounds %"struct.std::pair", ptr %240, i32 0, i32 0
  %242 = load i32, ptr %241, align 8, !tbaa !15
  call void @_Z7seg_updP7Segmentiiii(ptr noundef @segR, i32 noundef 1, i32 noundef %229, i32 noundef %237, i32 noundef %242)
  br label %243

243:                                              ; preds = %217
  %244 = load i32, ptr %10, align 4, !tbaa !5
  %245 = add nsw i32 %244, -1
  store i32 %245, ptr %10, align 4, !tbaa !5
  br label %200, !llvm.loop !19

246:                                              ; preds = %215
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %247 = load i32, ptr %11, align 4, !tbaa !5
  %248 = sext i32 %247 to i64
  %249 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %248
  %250 = getelementptr inbounds %"struct.std::pair", ptr %249, i32 0, i32 1
  %251 = load i32, ptr %250, align 4, !tbaa !17
  %252 = load i32, ptr %11, align 4, !tbaa !5
  %253 = sext i32 %252 to i64
  %254 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %253
  %255 = getelementptr inbounds %"struct.std::pair", ptr %254, i32 0, i32 1
  %256 = load i32, ptr %255, align 4, !tbaa !17
  %257 = call noundef i32 @_Z7seg_idxii(i32 noundef %251, i32 noundef %256)
  %258 = sext i32 %257 to i64
  %259 = getelementptr inbounds [200003 x %struct.Segment], ptr @segL, i64 0, i64 %258
  %260 = getelementptr inbounds %struct.Segment, ptr %259, i32 0, i32 1
  %261 = load i32, ptr %260, align 4, !tbaa !20
  store i32 %261, ptr %12, align 4, !tbaa !5
  %262 = load i32, ptr @cc, align 4, !tbaa !5
  %263 = load i32, ptr %11, align 4, !tbaa !5
  %264 = sext i32 %263 to i64
  %265 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %264
  %266 = getelementptr inbounds %"struct.std::pair", ptr %265, i32 0, i32 1
  %267 = load i32, ptr %266, align 4, !tbaa !17
  %268 = load i32, ptr %12, align 4, !tbaa !5
  store i32 %268, ptr @INF, align 4, !tbaa !5
  %269 = call noundef i64 @_Z7seg_queP7SegmentiiiiRi(ptr noundef @segL, i32 noundef 1, i32 noundef %262, i32 noundef 1, i32 noundef %267, ptr noundef nonnull align 4 dereferenceable(4) @INF)
  %270 = load i32, ptr %11, align 4, !tbaa !5
  %271 = sext i32 %270 to i64
  %272 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %271
  %273 = load i64, ptr %272, align 8, !tbaa !11
  %274 = add nsw i64 %273, %269
  store i64 %274, ptr %272, align 8, !tbaa !11
  %275 = load i32, ptr %11, align 4, !tbaa !5
  %276 = sext i32 %275 to i64
  %277 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %276
  %278 = getelementptr inbounds %"struct.std::pair", ptr %277, i32 0, i32 1
  %279 = load i32, ptr %278, align 4, !tbaa !17
  %280 = load i32, ptr @cc, align 4, !tbaa !5
  %281 = icmp slt i32 %279, %280
  br i1 %281, label %282, label %298

282:                                              ; preds = %246
  %283 = load i32, ptr @cc, align 4, !tbaa !5
  %284 = load i32, ptr @cc, align 4, !tbaa !5
  %285 = load i32, ptr %11, align 4, !tbaa !5
  %286 = sext i32 %285 to i64
  %287 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %286
  %288 = getelementptr inbounds %"struct.std::pair", ptr %287, i32 0, i32 1
  %289 = load i32, ptr %288, align 4, !tbaa !17
  %290 = sub nsw i32 %284, %289
  %291 = load i32, ptr %12, align 4, !tbaa !5
  store i32 %291, ptr @INF, align 4, !tbaa !5
  %292 = call noundef i64 @_Z7seg_queP7SegmentiiiiRi(ptr noundef @segR, i32 noundef 1, i32 noundef %283, i32 noundef 1, i32 noundef %290, ptr noundef nonnull align 4 dereferenceable(4) @INF)
  %293 = load i32, ptr %11, align 4, !tbaa !5
  %294 = sext i32 %293 to i64
  %295 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %294
  %296 = load i64, ptr %295, align 8, !tbaa !11
  %297 = add nsw i64 %296, %292
  store i64 %297, ptr %295, align 8, !tbaa !11
  br label %298

298:                                              ; preds = %282, %246
  %299 = load i32, ptr %11, align 4, !tbaa !5
  %300 = sext i32 %299 to i64
  %301 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %300
  %302 = getelementptr inbounds %"struct.std::pair", ptr %301, i32 0, i32 0
  %303 = load i32, ptr %302, align 8, !tbaa !15
  %304 = sext i32 %303 to i64
  %305 = load i32, ptr @cc, align 4, !tbaa !5
  %306 = sext i32 %305 to i64
  %307 = mul nsw i64 %304, %306
  %308 = load i32, ptr %11, align 4, !tbaa !5
  %309 = sext i32 %308 to i64
  %310 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %309
  %311 = load i64, ptr %310, align 8, !tbaa !11
  %312 = sub nsw i64 %311, %307
  store i64 %312, ptr %310, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %313

313:                                              ; preds = %298
  %314 = load i32, ptr %9, align 4, !tbaa !5
  %315 = add nsw i32 %314, -1
  store i32 %315, ptr %9, align 4, !tbaa !5
  br label %191, !llvm.loop !22

316:                                              ; preds = %194
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %317

317:                                              ; preds = %335, %316
  %318 = load i32, ptr %13, align 4, !tbaa !5
  %319 = load i32, ptr @n, align 4, !tbaa !5
  %320 = icmp slt i32 %318, %319
  br i1 %320, label %322, label %321

321:                                              ; preds = %317
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  br label %338

322:                                              ; preds = %317
  %323 = load i32, ptr @rr, align 4, !tbaa !5
  %324 = load i32, ptr %13, align 4, !tbaa !5
  %325 = sext i32 %324 to i64
  %326 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %325
  %327 = getelementptr inbounds %"struct.std::pair", ptr %326, i32 0, i32 0
  %328 = load i32, ptr %327, align 8, !tbaa !15
  %329 = sub nsw i32 %323, %328
  %330 = add nsw i32 %329, 1
  %331 = load i32, ptr %13, align 4, !tbaa !5
  %332 = sext i32 %331 to i64
  %333 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %332
  %334 = getelementptr inbounds %"struct.std::pair", ptr %333, i32 0, i32 0
  store i32 %330, ptr %334, align 8, !tbaa !15
  br label %335

335:                                              ; preds = %322
  %336 = load i32, ptr %13, align 4, !tbaa !5
  %337 = add nsw i32 %336, 1
  store i32 %337, ptr %13, align 4, !tbaa !5
  br label %317, !llvm.loop !23

338:                                              ; preds = %321
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  store i32 0, ptr %14, align 4, !tbaa !5
  br label %339

339:                                              ; preds = %357, %338
  %340 = load i32, ptr %14, align 4, !tbaa !5
  %341 = load i32, ptr @q, align 4, !tbaa !5
  %342 = icmp slt i32 %340, %341
  br i1 %342, label %344, label %343

343:                                              ; preds = %339
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  br label %360

344:                                              ; preds = %339
  %345 = load i32, ptr @rr, align 4, !tbaa !5
  %346 = load i32, ptr %14, align 4, !tbaa !5
  %347 = sext i32 %346 to i64
  %348 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %347
  %349 = getelementptr inbounds %"struct.std::pair", ptr %348, i32 0, i32 0
  %350 = load i32, ptr %349, align 8, !tbaa !15
  %351 = sub nsw i32 %345, %350
  %352 = add nsw i32 %351, 1
  %353 = load i32, ptr %14, align 4, !tbaa !5
  %354 = sext i32 %353 to i64
  %355 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %354
  %356 = getelementptr inbounds %"struct.std::pair", ptr %355, i32 0, i32 0
  store i32 %352, ptr %356, align 8, !tbaa !15
  br label %357

357:                                              ; preds = %344
  %358 = load i32, ptr %14, align 4, !tbaa !5
  %359 = add nsw i32 %358, 1
  store i32 %359, ptr %14, align 4, !tbaa !5
  br label %339, !llvm.loop !24

360:                                              ; preds = %343
  %361 = load i32, ptr @cc, align 4, !tbaa !5
  call void @_Z8seg_initP7Segmentii(ptr noundef @segL, i32 noundef 1, i32 noundef %361)
  %362 = load i32, ptr @cc, align 4, !tbaa !5
  call void @_Z8seg_initP7Segmentii(ptr noundef @segR, i32 noundef 1, i32 noundef %362)
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  store i32 0, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  store i32 0, ptr %16, align 4, !tbaa !5
  br label %363

363:                                              ; preds = %487, %360
  %364 = load i32, ptr %15, align 4, !tbaa !5
  %365 = load i32, ptr @q, align 4, !tbaa !5
  %366 = icmp slt i32 %364, %365
  br i1 %366, label %368, label %367

367:                                              ; preds = %363
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  br label %490

368:                                              ; preds = %363
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  %369 = load i32, ptr %15, align 4, !tbaa !5
  %370 = sext i32 %369 to i64
  %371 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %370
  %372 = load i32, ptr %371, align 4, !tbaa !5
  store i32 %372, ptr %17, align 4, !tbaa !5
  br label %373

373:                                              ; preds = %417, %368
  %374 = load i32, ptr %16, align 4, !tbaa !5
  %375 = load i32, ptr @n, align 4, !tbaa !5
  %376 = icmp slt i32 %374, %375
  br i1 %376, label %377, label %389

377:                                              ; preds = %373
  %378 = load i32, ptr %16, align 4, !tbaa !5
  %379 = sext i32 %378 to i64
  %380 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %379
  %381 = getelementptr inbounds %"struct.std::pair", ptr %380, i32 0, i32 0
  %382 = load i32, ptr %381, align 8, !tbaa !15
  %383 = load i32, ptr %17, align 4, !tbaa !5
  %384 = sext i32 %383 to i64
  %385 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %384
  %386 = getelementptr inbounds %"struct.std::pair", ptr %385, i32 0, i32 0
  %387 = load i32, ptr %386, align 8, !tbaa !15
  %388 = icmp sge i32 %382, %387
  br label %389

389:                                              ; preds = %377, %373
  %390 = phi i1 [ false, %373 ], [ %388, %377 ]
  br i1 %390, label %391, label %420

391:                                              ; preds = %389
  %392 = load i32, ptr @cc, align 4, !tbaa !5
  %393 = load i32, ptr %16, align 4, !tbaa !5
  %394 = sext i32 %393 to i64
  %395 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %394
  %396 = getelementptr inbounds %"struct.std::pair", ptr %395, i32 0, i32 1
  %397 = load i32, ptr %396, align 4, !tbaa !17
  %398 = load i32, ptr %16, align 4, !tbaa !5
  %399 = sext i32 %398 to i64
  %400 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %399
  %401 = getelementptr inbounds %"struct.std::pair", ptr %400, i32 0, i32 0
  %402 = load i32, ptr %401, align 8, !tbaa !15
  call void @_Z7seg_updP7Segmentiiii(ptr noundef @segL, i32 noundef 1, i32 noundef %392, i32 noundef %397, i32 noundef %402)
  %403 = load i32, ptr @cc, align 4, !tbaa !5
  %404 = load i32, ptr @cc, align 4, !tbaa !5
  %405 = load i32, ptr %16, align 4, !tbaa !5
  %406 = sext i32 %405 to i64
  %407 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %406
  %408 = getelementptr inbounds %"struct.std::pair", ptr %407, i32 0, i32 1
  %409 = load i32, ptr %408, align 4, !tbaa !17
  %410 = sub nsw i32 %404, %409
  %411 = add nsw i32 %410, 1
  %412 = load i32, ptr %16, align 4, !tbaa !5
  %413 = sext i32 %412 to i64
  %414 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %413
  %415 = getelementptr inbounds %"struct.std::pair", ptr %414, i32 0, i32 0
  %416 = load i32, ptr %415, align 8, !tbaa !15
  call void @_Z7seg_updP7Segmentiiii(ptr noundef @segR, i32 noundef 1, i32 noundef %403, i32 noundef %411, i32 noundef %416)
  br label %417

417:                                              ; preds = %391
  %418 = load i32, ptr %16, align 4, !tbaa !5
  %419 = add nsw i32 %418, 1
  store i32 %419, ptr %16, align 4, !tbaa !5
  br label %373, !llvm.loop !25

420:                                              ; preds = %389
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #6
  %421 = load i32, ptr %17, align 4, !tbaa !5
  %422 = sext i32 %421 to i64
  %423 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %422
  %424 = getelementptr inbounds %"struct.std::pair", ptr %423, i32 0, i32 1
  %425 = load i32, ptr %424, align 4, !tbaa !17
  %426 = load i32, ptr %17, align 4, !tbaa !5
  %427 = sext i32 %426 to i64
  %428 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %427
  %429 = getelementptr inbounds %"struct.std::pair", ptr %428, i32 0, i32 1
  %430 = load i32, ptr %429, align 4, !tbaa !17
  %431 = call noundef i32 @_Z7seg_idxii(i32 noundef %425, i32 noundef %430)
  %432 = sext i32 %431 to i64
  %433 = getelementptr inbounds [200003 x %struct.Segment], ptr @segL, i64 0, i64 %432
  %434 = getelementptr inbounds %struct.Segment, ptr %433, i32 0, i32 1
  %435 = load i32, ptr %434, align 4, !tbaa !20
  store i32 %435, ptr %18, align 4, !tbaa !5
  %436 = load i32, ptr @cc, align 4, !tbaa !5
  %437 = load i32, ptr %17, align 4, !tbaa !5
  %438 = sext i32 %437 to i64
  %439 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %438
  %440 = getelementptr inbounds %"struct.std::pair", ptr %439, i32 0, i32 1
  %441 = load i32, ptr %440, align 4, !tbaa !17
  %442 = load i32, ptr %18, align 4, !tbaa !5
  store i32 %442, ptr @INF, align 4, !tbaa !5
  %443 = call noundef i64 @_Z7seg_queP7SegmentiiiiRi(ptr noundef @segL, i32 noundef 1, i32 noundef %436, i32 noundef 1, i32 noundef %441, ptr noundef nonnull align 4 dereferenceable(4) @INF)
  %444 = load i32, ptr %17, align 4, !tbaa !5
  %445 = sext i32 %444 to i64
  %446 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %445
  %447 = load i64, ptr %446, align 8, !tbaa !11
  %448 = add nsw i64 %447, %443
  store i64 %448, ptr %446, align 8, !tbaa !11
  %449 = load i32, ptr %17, align 4, !tbaa !5
  %450 = sext i32 %449 to i64
  %451 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %450
  %452 = getelementptr inbounds %"struct.std::pair", ptr %451, i32 0, i32 1
  %453 = load i32, ptr %452, align 4, !tbaa !17
  %454 = load i32, ptr @cc, align 4, !tbaa !5
  %455 = icmp slt i32 %453, %454
  br i1 %455, label %456, label %472

456:                                              ; preds = %420
  %457 = load i32, ptr @cc, align 4, !tbaa !5
  %458 = load i32, ptr @cc, align 4, !tbaa !5
  %459 = load i32, ptr %17, align 4, !tbaa !5
  %460 = sext i32 %459 to i64
  %461 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %460
  %462 = getelementptr inbounds %"struct.std::pair", ptr %461, i32 0, i32 1
  %463 = load i32, ptr %462, align 4, !tbaa !17
  %464 = sub nsw i32 %458, %463
  %465 = load i32, ptr %18, align 4, !tbaa !5
  store i32 %465, ptr @INF, align 4, !tbaa !5
  %466 = call noundef i64 @_Z7seg_queP7SegmentiiiiRi(ptr noundef @segR, i32 noundef 1, i32 noundef %457, i32 noundef 1, i32 noundef %464, ptr noundef nonnull align 4 dereferenceable(4) @INF)
  %467 = load i32, ptr %17, align 4, !tbaa !5
  %468 = sext i32 %467 to i64
  %469 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %468
  %470 = load i64, ptr %469, align 8, !tbaa !11
  %471 = add nsw i64 %470, %466
  store i64 %471, ptr %469, align 8, !tbaa !11
  br label %472

472:                                              ; preds = %456, %420
  %473 = load i32, ptr %17, align 4, !tbaa !5
  %474 = sext i32 %473 to i64
  %475 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %474
  %476 = getelementptr inbounds %"struct.std::pair", ptr %475, i32 0, i32 0
  %477 = load i32, ptr %476, align 8, !tbaa !15
  %478 = sext i32 %477 to i64
  %479 = load i32, ptr @cc, align 4, !tbaa !5
  %480 = sext i32 %479 to i64
  %481 = mul nsw i64 %478, %480
  %482 = load i32, ptr %17, align 4, !tbaa !5
  %483 = sext i32 %482 to i64
  %484 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %483
  %485 = load i64, ptr %484, align 8, !tbaa !11
  %486 = sub nsw i64 %485, %481
  store i64 %486, ptr %484, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  br label %487

487:                                              ; preds = %472
  %488 = load i32, ptr %15, align 4, !tbaa !5
  %489 = add nsw i32 %488, 1
  store i32 %489, ptr %15, align 4, !tbaa !5
  br label %363, !llvm.loop !26

490:                                              ; preds = %367
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #6
  store i32 0, ptr %19, align 4, !tbaa !5
  br label %491

491:                                              ; preds = %502, %490
  %492 = load i32, ptr %19, align 4, !tbaa !5
  %493 = load i32, ptr @q, align 4, !tbaa !5
  %494 = icmp slt i32 %492, %493
  br i1 %494, label %496, label %495

495:                                              ; preds = %491
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #6
  br label %505

496:                                              ; preds = %491
  %497 = load i32, ptr %19, align 4, !tbaa !5
  %498 = sext i32 %497 to i64
  %499 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %498
  %500 = load i64, ptr %499, align 8, !tbaa !11
  %501 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i64 noundef %500)
  br label %502

502:                                              ; preds = %496
  %503 = load i32, ptr %19, align 4, !tbaa !5
  %504 = add nsw i32 %503, 1
  store i32 %504, ptr %19, align 4, !tbaa !5
  br label %491, !llvm.loop !27

505:                                              ; preds = %495
  br label %21, !llvm.loop !28

506:                                              ; preds = %21
  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 uwtable
declare dso_local void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef, ptr noundef, ptr noundef) #5

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

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

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

%"struct.std::pair" = type { i32, i32 }
%struct.Segment = type { i32, i32, i64 }

@t = external dso_local global i32, align 4
@rr = external dso_local global i32, align 4
@cc = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@ord = external dso_local global [100001 x i32], align 16
@INF = external dso_local global i32, align 4
@a = external dso_local global [100001 x %"struct.std::pair"], align 16
@b = external dso_local global [100001 x %"struct.std::pair"], align 16
@ans = external dso_local local_unnamed_addr global [100001 x i64], align 16
@segL = external dso_local global [200003 x %struct.Segment], align 16
@segR = external dso_local global [200003 x %struct.Segment], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z8seg_initP7Segmentii(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z7seg_idxii(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z7seg_updP7Segmentiiii(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

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

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

; 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 #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @t)
  %2 = load i32, ptr @t, align 4, !tbaa !5
  %3 = add nsw i32 %2, -1
  store i32 %3, ptr @t, align 4, !tbaa !5
  %.not165 = icmp eq i32 %2, 0
  br i1 %.not165, label %._crit_edge168, label %.lr.ph167

.loopexit:                                        ; preds = %.lr.ph164, %._crit_edge152, %.preheader
  %4 = load i32, ptr @t, align 4, !tbaa !5
  %5 = add nsw i32 %4, -1
  store i32 %5, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %._crit_edge168, label %.lr.ph167, !llvm.loop !9

.lr.ph167:                                        ; preds = %0, %.loopexit
  %6 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @rr, ptr noundef nonnull @cc, ptr noundef nonnull @n, ptr noundef nonnull @q)
  %7 = load i32, ptr @n, align 4, !tbaa !5
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph, label %.lr.ph167.._crit_edge_crit_edge

.lr.ph167.._crit_edge_crit_edge:                  ; preds = %.lr.ph167
  %.pre215 = sext i32 %7 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph167.._crit_edge_crit_edge
  %.pre-phi216 = phi i64 [ %.pre215, %.lr.ph167.._crit_edge_crit_edge ], [ %16, %.lr.ph ]
  %9 = getelementptr inbounds %"struct.std::pair", ptr @a, i64 %.pre-phi216
  tail call void @_ZSt4sortIPSt4pairIiiEEvT_S3_(ptr noundef nonnull @a, ptr noundef nonnull %9)
  %10 = load i32, ptr @q, align 4, !tbaa !5
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %.lr.ph123, label %._crit_edge.._crit_edge124_crit_edge

._crit_edge.._crit_edge124_crit_edge:             ; preds = %._crit_edge
  %.pre217 = sext i32 %10 to i64
  br label %._crit_edge124

.lr.ph:                                           ; preds = %.lr.ph167, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.lr.ph167 ]
  %12 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %indvars.iv
  %13 = getelementptr inbounds i8, ptr %12, i64 4
  %14 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %12, ptr noundef nonnull %13)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %15 = load i32, ptr @n, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = icmp slt i64 %indvars.iv.next, %16
  br i1 %17, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge124:                                   ; preds = %.lr.ph123, %._crit_edge.._crit_edge124_crit_edge
  %.pre-phi218 = phi i64 [ %.pre217, %._crit_edge.._crit_edge124_crit_edge ], [ %28, %.lr.ph123 ]
  %18 = getelementptr inbounds i32, ptr @ord, i64 %.pre-phi218
  tail call void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef nonnull @ord, ptr noundef nonnull %18, ptr noundef nonnull @_Z3cmpRKiS0_)
  %19 = load i32, ptr @q, align 4, !tbaa !5
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %.lr.ph135.preheader, label %._crit_edge136

.lr.ph135.preheader:                              ; preds = %._crit_edge124
  %.pre208 = load i32, ptr @n, align 4, !tbaa !5
  br label %.lr.ph135

.lr.ph123:                                        ; preds = %._crit_edge, %.lr.ph123
  %indvars.iv172 = phi i64 [ %indvars.iv.next173, %.lr.ph123 ], [ 0, %._crit_edge ]
  %21 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %indvars.iv172
  %22 = getelementptr inbounds i8, ptr %21, i64 4
  %23 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %21, ptr noundef nonnull %22)
  %24 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %indvars.iv172
  %25 = trunc nuw nsw i64 %indvars.iv172 to i32
  store i32 %25, ptr %24, align 4, !tbaa !5
  %26 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %indvars.iv172
  store i64 0, ptr %26, align 8, !tbaa !12
  %indvars.iv.next173 = add nuw nsw i64 %indvars.iv172, 1
  %27 = load i32, ptr @q, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = icmp slt i64 %indvars.iv.next173, %28
  br i1 %29, label %.lr.ph123, label %._crit_edge124, !llvm.loop !14

._crit_edge136:                                   ; preds = %97, %._crit_edge124
  %30 = load i32, ptr @cc, align 4, !tbaa !5
  tail call void @_Z8seg_initP7Segmentii(ptr noundef nonnull @segL, i32 noundef 1, i32 noundef %30)
  %31 = load i32, ptr @cc, align 4, !tbaa !5
  tail call void @_Z8seg_initP7Segmentii(ptr noundef nonnull @segR, i32 noundef 1, i32 noundef %31)
  %32 = load i32, ptr @q, align 4, !tbaa !5
  %33 = load i32, ptr @n, align 4, !tbaa !5
  %34 = icmp sgt i32 %32, 0
  br i1 %34, label %.lr.ph147.preheader, label %.preheader118

.lr.ph147.preheader:                              ; preds = %._crit_edge136
  %35 = add nsw i32 %33, -1
  %36 = zext nneg i32 %32 to i64
  br label %.lr.ph147

.lr.ph135:                                        ; preds = %.lr.ph135.preheader, %97
  %37 = phi i32 [ %.pre208, %.lr.ph135.preheader ], [ %98, %97 ]
  %indvars.iv178 = phi i64 [ 0, %.lr.ph135.preheader ], [ %indvars.iv.next179, %97 ]
  %.098132 = phi i32 [ 0, %.lr.ph135.preheader ], [ %.199.lcssa, %97 ]
  %38 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %indvars.iv178
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %40 = icmp slt i32 %.098132, %37
  br i1 %40, label %.lr.ph128, label %.critedge

.lr.ph128:                                        ; preds = %.lr.ph135
  %41 = sext i32 %39 to i64
  %42 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %41
  %43 = sext i32 %.098132 to i64
  br label %44

44:                                               ; preds = %.lr.ph128, %47
  %indvars.iv175 = phi i64 [ %43, %.lr.ph128 ], [ %indvars.iv.next176, %47 ]
  %45 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %indvars.iv175
  %46 = tail call noundef zeroext i1 @_ZStltIiiEbRKSt4pairIT_T0_ES5_(ptr noundef nonnull align 4 dereferenceable(8) %45, ptr noundef nonnull align 4 dereferenceable(8) %42)
  %.pre209.pre = load i32, ptr @n, align 4, !tbaa !5
  br i1 %46, label %47, label %.critedge.loopexit

47:                                               ; preds = %44
  %indvars.iv.next176 = add nsw i64 %indvars.iv175, 1
  %48 = sext i32 %.pre209.pre to i64
  %49 = icmp slt i64 %indvars.iv.next176, %48
  br i1 %49, label %44, label %.critedge.loopexit, !llvm.loop !15

.critedge.loopexit:                               ; preds = %47, %44
  %.199.lcssa.ph.in = phi i64 [ %indvars.iv175, %44 ], [ %indvars.iv.next176, %47 ]
  %.199.lcssa.ph = trunc i64 %.199.lcssa.ph.in to i32
  br label %.critedge

.critedge:                                        ; preds = %.critedge.loopexit, %.lr.ph135
  %50 = phi i32 [ %37, %.lr.ph135 ], [ %.pre209.pre, %.critedge.loopexit ]
  %.199.lcssa = phi i32 [ %.098132, %.lr.ph135 ], [ %.199.lcssa.ph, %.critedge.loopexit ]
  %51 = icmp eq i32 %.199.lcssa, %50
  br i1 %51, label %58, label %52

52:                                               ; preds = %.critedge
  %53 = sext i32 %.199.lcssa to i64
  %54 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %53
  %55 = sext i32 %39 to i64
  %56 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %55
  %57 = tail call noundef zeroext i1 @_ZStneIiiEbRKSt4pairIT_T0_ES5_(ptr noundef nonnull align 4 dereferenceable(8) %54, ptr noundef nonnull align 4 dereferenceable(8) %56)
  %.pre = load i32, ptr @n, align 4, !tbaa !5
  br i1 %57, label %58, label %97

58:                                               ; preds = %52, %.critedge
  %59 = phi i32 [ %.pre, %52 ], [ %50, %.critedge ]
  %.not113 = icmp eq i32 %.199.lcssa, 0
  br i1 %.not113, label %72, label %60

60:                                               ; preds = %58
  %61 = add nsw i32 %.199.lcssa, -1
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %62
  %64 = load i32, ptr %63, align 8, !tbaa !16
  %65 = sext i32 %39 to i64
  %66 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %65
  %67 = load i32, ptr %66, align 8, !tbaa !16
  %68 = icmp eq i32 %64, %67
  br i1 %68, label %69, label %72

69:                                               ; preds = %60
  %70 = getelementptr inbounds i8, ptr %63, i64 4
  %71 = load i32, ptr %70, align 4, !tbaa !18
  br label %72

72:                                               ; preds = %58, %60, %69
  %73 = phi i32 [ %71, %69 ], [ 0, %60 ], [ 0, %58 ]
  %74 = icmp slt i32 %.199.lcssa, %59
  br i1 %74, label %75, label %._crit_edge214

._crit_edge214:                                   ; preds = %72
  %.pre223 = sext i32 %39 to i64
  br label %86

75:                                               ; preds = %72
  %76 = sext i32 %.199.lcssa to i64
  %77 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %76
  %78 = load i32, ptr %77, align 8, !tbaa !16
  %79 = sext i32 %39 to i64
  %80 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %79
  %81 = load i32, ptr %80, align 8, !tbaa !16
  %82 = icmp eq i32 %78, %81
  br i1 %82, label %83, label %86

83:                                               ; preds = %75
  %84 = getelementptr inbounds i8, ptr %77, i64 4
  %85 = load i32, ptr %84, align 4, !tbaa !18
  br label %89

86:                                               ; preds = %._crit_edge214, %75
  %.pre210.pre-phi = phi i64 [ %.pre223, %._crit_edge214 ], [ %79, %75 ]
  %87 = load i32, ptr @cc, align 4, !tbaa !5
  %88 = add nsw i32 %87, 1
  br label %89

89:                                               ; preds = %86, %83
  %.pre-phi = phi i64 [ %.pre210.pre-phi, %86 ], [ %79, %83 ]
  %90 = phi i32 [ %88, %86 ], [ %85, %83 ]
  %91 = xor i32 %73, -1
  %92 = add i32 %90, %91
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %.pre-phi
  %95 = load i64, ptr %94, align 8, !tbaa !12
  %96 = sub nsw i64 %95, %93
  store i64 %96, ptr %94, align 8, !tbaa !12
  br label %97

97:                                               ; preds = %89, %52
  %98 = phi i32 [ %59, %89 ], [ %.pre, %52 ]
  %indvars.iv.next179 = add nuw nsw i64 %indvars.iv178, 1
  %99 = load i32, ptr @q, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = icmp slt i64 %indvars.iv.next179, %100
  br i1 %101, label %.lr.ph135, label %._crit_edge136, !llvm.loop !19

.preheader118.loopexit:                           ; preds = %149
  %.pre212 = load i32, ptr @n, align 4, !tbaa !5
  br label %.preheader118

.preheader118:                                    ; preds = %.preheader118.loopexit, %._crit_edge136
  %102 = phi i32 [ %.pre212, %.preheader118.loopexit ], [ %33, %._crit_edge136 ]
  %103 = icmp sgt i32 %102, 0
  br i1 %103, label %.lr.ph149, label %.preheader117

.lr.ph149:                                        ; preds = %.preheader118
  %104 = load i32, ptr @rr, align 4, !tbaa !5
  %105 = add i32 %104, 1
  %wide.trip.count = zext nneg i32 %102 to i64
  %xtraiter = and i64 %wide.trip.count, 3
  %106 = icmp ult i32 %102, 4
  br i1 %106, label %.preheader117.loopexit.unr-lcssa, label %.lr.ph149.new

.lr.ph149.new:                                    ; preds = %.lr.ph149
  %unroll_iter = and i64 %wide.trip.count, 2147483644
  br label %166

.lr.ph147:                                        ; preds = %.lr.ph147.preheader, %149
  %indvars.iv182 = phi i64 [ %36, %.lr.ph147.preheader ], [ %indvars.iv.next183, %149 ]
  %.0100144 = phi i32 [ %35, %.lr.ph147.preheader ], [ %.1101.lcssa, %149 ]
  %indvars.iv.next183 = add nsw i64 %indvars.iv182, -1
  %107 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %indvars.iv.next183
  %108 = load i32, ptr %107, align 4, !tbaa !5
  %109 = icmp sgt i32 %.0100144, -1
  %110 = sext i32 %108 to i64
  br i1 %109, label %.lr.ph139, label %.critedge2

.lr.ph139:                                        ; preds = %.lr.ph147
  %111 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %110
  br label %112

112:                                              ; preds = %.lr.ph139, %117
  %.1101137 = phi i32 [ %.0100144, %.lr.ph139 ], [ %126, %117 ]
  %113 = zext nneg i32 %.1101137 to i64
  %114 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %113
  %115 = load i32, ptr %114, align 8, !tbaa !16
  %116 = load i32, ptr %111, align 8, !tbaa !16
  %.not112 = icmp slt i32 %115, %116
  br i1 %.not112, label %.critedge2, label %117

117:                                              ; preds = %112
  %118 = load i32, ptr @cc, align 4, !tbaa !5
  %119 = getelementptr inbounds i8, ptr %114, i64 4
  %120 = load i32, ptr %119, align 4, !tbaa !18
  tail call void @_Z7seg_updP7Segmentiiii(ptr noundef nonnull @segL, i32 noundef 1, i32 noundef %118, i32 noundef %120, i32 noundef %115)
  %121 = load i32, ptr @cc, align 4, !tbaa !5
  %122 = load i32, ptr %119, align 4, !tbaa !18
  %123 = add i32 %121, 1
  %124 = sub i32 %123, %122
  %125 = load i32, ptr %114, align 8, !tbaa !16
  tail call void @_Z7seg_updP7Segmentiiii(ptr noundef nonnull @segR, i32 noundef 1, i32 noundef %121, i32 noundef %124, i32 noundef %125)
  %126 = add nsw i32 %.1101137, -1
  %127 = icmp sgt i32 %.1101137, 0
  br i1 %127, label %112, label %.critedge2, !llvm.loop !20

.critedge2:                                       ; preds = %112, %117, %.lr.ph147
  %.1101.lcssa = phi i32 [ %.0100144, %.lr.ph147 ], [ -1, %117 ], [ %.1101137, %112 ]
  %128 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %110
  %129 = getelementptr inbounds i8, ptr %128, i64 4
  %130 = load i32, ptr %129, align 4, !tbaa !18
  %131 = tail call noundef i32 @_Z7seg_idxii(i32 noundef %130, i32 noundef %130)
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [200003 x %struct.Segment], ptr @segL, i64 0, i64 %132, i32 1
  %134 = load i32, ptr %133, align 4, !tbaa !21
  %135 = load i32, ptr @cc, align 4, !tbaa !5
  %136 = load i32, ptr %129, align 4, !tbaa !18
  store i32 %134, ptr @INF, align 4, !tbaa !5
  %137 = tail call noundef i64 @_Z7seg_queP7SegmentiiiiRi(ptr noundef nonnull @segL, i32 noundef 1, i32 noundef %135, i32 noundef 1, i32 noundef %136, ptr noundef nonnull align 4 dereferenceable(4) @INF)
  %138 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %110
  %139 = load i64, ptr %138, align 8, !tbaa !12
  %140 = add nsw i64 %139, %137
  store i64 %140, ptr %138, align 8, !tbaa !12
  %141 = load i32, ptr %129, align 4, !tbaa !18
  %142 = load i32, ptr @cc, align 4, !tbaa !5
  %143 = icmp slt i32 %141, %142
  br i1 %143, label %144, label %149

144:                                              ; preds = %.critedge2
  %145 = sub nsw i32 %142, %141
  store i32 %134, ptr @INF, align 4, !tbaa !5
  %146 = tail call noundef i64 @_Z7seg_queP7SegmentiiiiRi(ptr noundef nonnull @segR, i32 noundef 1, i32 noundef %142, i32 noundef 1, i32 noundef %145, ptr noundef nonnull align 4 dereferenceable(4) @INF)
  %147 = load i64, ptr %138, align 8, !tbaa !12
  %148 = add nsw i64 %147, %146
  %.pre211 = load i32, ptr @cc, align 4, !tbaa !5
  br label %149

149:                                              ; preds = %144, %.critedge2
  %150 = phi i64 [ %148, %144 ], [ %140, %.critedge2 ]
  %151 = phi i32 [ %.pre211, %144 ], [ %142, %.critedge2 ]
  %152 = load i32, ptr %128, align 8, !tbaa !16
  %153 = sext i32 %152 to i64
  %154 = sext i32 %151 to i64
  %155 = mul nsw i64 %154, %153
  %156 = sub nsw i64 %150, %155
  store i64 %156, ptr %138, align 8, !tbaa !12
  %157 = icmp sgt i64 %indvars.iv182, 1
  br i1 %157, label %.lr.ph147, label %.preheader118.loopexit, !llvm.loop !23

.preheader117.loopexit.unr-lcssa:                 ; preds = %166, %.lr.ph149
  %indvars.iv186.unr = phi i64 [ 0, %.lr.ph149 ], [ %indvars.iv.next187.3, %166 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.preheader117, label %.epil.preheader

.epil.preheader:                                  ; preds = %.preheader117.loopexit.unr-lcssa, %.epil.preheader
  %indvars.iv186.epil = phi i64 [ %indvars.iv.next187.epil, %.epil.preheader ], [ %indvars.iv186.unr, %.preheader117.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.epil.preheader ], [ 0, %.preheader117.loopexit.unr-lcssa ]
  %158 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %indvars.iv186.epil
  %159 = load i32, ptr %158, align 8, !tbaa !16
  %160 = sub i32 %105, %159
  store i32 %160, ptr %158, align 8, !tbaa !16
  %indvars.iv.next187.epil = add nuw nsw i64 %indvars.iv186.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.preheader117, label %.epil.preheader, !llvm.loop !24

.preheader117:                                    ; preds = %.preheader117.loopexit.unr-lcssa, %.epil.preheader, %.preheader118
  %161 = load i32, ptr @q, align 4, !tbaa !5
  %162 = icmp sgt i32 %161, 0
  br i1 %162, label %.lr.ph151, label %._crit_edge152

.lr.ph151:                                        ; preds = %.preheader117
  %163 = load i32, ptr @rr, align 4, !tbaa !5
  %164 = add i32 %163, 1
  %wide.trip.count194 = zext nneg i32 %161 to i64
  %xtraiter231 = and i64 %wide.trip.count194, 3
  %165 = icmp ult i32 %161, 4
  br i1 %165, label %._crit_edge152.loopexit.unr-lcssa, label %.lr.ph151.new

.lr.ph151.new:                                    ; preds = %.lr.ph151
  %unroll_iter234 = and i64 %wide.trip.count194, 2147483644
  br label %186

166:                                              ; preds = %166, %.lr.ph149.new
  %indvars.iv186 = phi i64 [ 0, %.lr.ph149.new ], [ %indvars.iv.next187.3, %166 ]
  %niter = phi i64 [ 0, %.lr.ph149.new ], [ %niter.next.3, %166 ]
  %167 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %indvars.iv186
  %168 = load i32, ptr %167, align 16, !tbaa !16
  %169 = sub i32 %105, %168
  store i32 %169, ptr %167, align 16, !tbaa !16
  %indvars.iv.next187 = or disjoint i64 %indvars.iv186, 1
  %170 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %indvars.iv.next187
  %171 = load i32, ptr %170, align 8, !tbaa !16
  %172 = sub i32 %105, %171
  store i32 %172, ptr %170, align 8, !tbaa !16
  %indvars.iv.next187.1 = or disjoint i64 %indvars.iv186, 2
  %173 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %indvars.iv.next187.1
  %174 = load i32, ptr %173, align 16, !tbaa !16
  %175 = sub i32 %105, %174
  store i32 %175, ptr %173, align 16, !tbaa !16
  %indvars.iv.next187.2 = or disjoint i64 %indvars.iv186, 3
  %176 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %indvars.iv.next187.2
  %177 = load i32, ptr %176, align 8, !tbaa !16
  %178 = sub i32 %105, %177
  store i32 %178, ptr %176, align 8, !tbaa !16
  %indvars.iv.next187.3 = add nuw nsw i64 %indvars.iv186, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %.preheader117.loopexit.unr-lcssa, label %166, !llvm.loop !26

._crit_edge152.loopexit.unr-lcssa:                ; preds = %186, %.lr.ph151
  %indvars.iv190.unr = phi i64 [ 0, %.lr.ph151 ], [ %indvars.iv.next191.3, %186 ]
  %lcmp.mod233.not = icmp eq i64 %xtraiter231, 0
  br i1 %lcmp.mod233.not, label %._crit_edge152, label %.epil.preheader230

.epil.preheader230:                               ; preds = %._crit_edge152.loopexit.unr-lcssa, %.epil.preheader230
  %indvars.iv190.epil = phi i64 [ %indvars.iv.next191.epil, %.epil.preheader230 ], [ %indvars.iv190.unr, %._crit_edge152.loopexit.unr-lcssa ]
  %epil.iter232 = phi i64 [ %epil.iter232.next, %.epil.preheader230 ], [ 0, %._crit_edge152.loopexit.unr-lcssa ]
  %179 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %indvars.iv190.epil
  %180 = load i32, ptr %179, align 8, !tbaa !16
  %181 = sub i32 %164, %180
  store i32 %181, ptr %179, align 8, !tbaa !16
  %indvars.iv.next191.epil = add nuw nsw i64 %indvars.iv190.epil, 1
  %epil.iter232.next = add i64 %epil.iter232, 1
  %epil.iter232.cmp.not = icmp eq i64 %epil.iter232.next, %xtraiter231
  br i1 %epil.iter232.cmp.not, label %._crit_edge152, label %.epil.preheader230, !llvm.loop !27

._crit_edge152:                                   ; preds = %._crit_edge152.loopexit.unr-lcssa, %.epil.preheader230, %.preheader117
  %182 = load i32, ptr @cc, align 4, !tbaa !5
  tail call void @_Z8seg_initP7Segmentii(ptr noundef nonnull @segL, i32 noundef 1, i32 noundef %182)
  %183 = load i32, ptr @cc, align 4, !tbaa !5
  tail call void @_Z8seg_initP7Segmentii(ptr noundef nonnull @segR, i32 noundef 1, i32 noundef %183)
  %184 = load i32, ptr @q, align 4, !tbaa !5
  %185 = icmp sgt i32 %184, 0
  br i1 %185, label %.lr.ph162, label %.loopexit

186:                                              ; preds = %186, %.lr.ph151.new
  %indvars.iv190 = phi i64 [ 0, %.lr.ph151.new ], [ %indvars.iv.next191.3, %186 ]
  %niter235 = phi i64 [ 0, %.lr.ph151.new ], [ %niter235.next.3, %186 ]
  %187 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %indvars.iv190
  %188 = load i32, ptr %187, align 16, !tbaa !16
  %189 = sub i32 %164, %188
  store i32 %189, ptr %187, align 16, !tbaa !16
  %indvars.iv.next191 = or disjoint i64 %indvars.iv190, 1
  %190 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %indvars.iv.next191
  %191 = load i32, ptr %190, align 8, !tbaa !16
  %192 = sub i32 %164, %191
  store i32 %192, ptr %190, align 8, !tbaa !16
  %indvars.iv.next191.1 = or disjoint i64 %indvars.iv190, 2
  %193 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %indvars.iv.next191.1
  %194 = load i32, ptr %193, align 16, !tbaa !16
  %195 = sub i32 %164, %194
  store i32 %195, ptr %193, align 16, !tbaa !16
  %indvars.iv.next191.2 = or disjoint i64 %indvars.iv190, 3
  %196 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %indvars.iv.next191.2
  %197 = load i32, ptr %196, align 8, !tbaa !16
  %198 = sub i32 %164, %197
  store i32 %198, ptr %196, align 8, !tbaa !16
  %indvars.iv.next191.3 = add nuw nsw i64 %indvars.iv190, 4
  %niter235.next.3 = add i64 %niter235, 4
  %niter235.ncmp.3 = icmp eq i64 %niter235.next.3, %unroll_iter234
  br i1 %niter235.ncmp.3, label %._crit_edge152.loopexit.unr-lcssa, label %186, !llvm.loop !28

.preheader:                                       ; preds = %244
  %199 = icmp sgt i32 %252, 0
  br i1 %199, label %.lr.ph164, label %.loopexit

.lr.ph162:                                        ; preds = %._crit_edge152, %244
  %indvars.iv200 = phi i64 [ %indvars.iv.next201, %244 ], [ 0, %._crit_edge152 ]
  %.093160 = phi i32 [ %.1.lcssa, %244 ], [ 0, %._crit_edge152 ]
  %200 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %indvars.iv200
  %201 = load i32, ptr %200, align 4, !tbaa !5
  %202 = load i32, ptr @n, align 4, !tbaa !5
  %203 = icmp slt i32 %.093160, %202
  %204 = sext i32 %201 to i64
  br i1 %203, label %.lr.ph155, label %.critedge4

.lr.ph155:                                        ; preds = %.lr.ph162
  %205 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %204
  %206 = sext i32 %.093160 to i64
  br label %207

207:                                              ; preds = %.lr.ph155, %211
  %indvars.iv196 = phi i64 [ %206, %.lr.ph155 ], [ %indvars.iv.next197, %211 ]
  %208 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %indvars.iv196
  %209 = load i32, ptr %208, align 8, !tbaa !16
  %210 = load i32, ptr %205, align 8, !tbaa !16
  %.not111 = icmp slt i32 %209, %210
  br i1 %.not111, label %.critedge4.loopexit, label %211

211:                                              ; preds = %207
  %212 = load i32, ptr @cc, align 4, !tbaa !5
  %213 = getelementptr inbounds i8, ptr %208, i64 4
  %214 = load i32, ptr %213, align 4, !tbaa !18
  tail call void @_Z7seg_updP7Segmentiiii(ptr noundef nonnull @segL, i32 noundef 1, i32 noundef %212, i32 noundef %214, i32 noundef %209)
  %215 = load i32, ptr @cc, align 4, !tbaa !5
  %216 = load i32, ptr %213, align 4, !tbaa !18
  %217 = add i32 %215, 1
  %218 = sub i32 %217, %216
  %219 = load i32, ptr %208, align 8, !tbaa !16
  tail call void @_Z7seg_updP7Segmentiiii(ptr noundef nonnull @segR, i32 noundef 1, i32 noundef %215, i32 noundef %218, i32 noundef %219)
  %indvars.iv.next197 = add nsw i64 %indvars.iv196, 1
  %220 = load i32, ptr @n, align 4, !tbaa !5
  %221 = sext i32 %220 to i64
  %222 = icmp slt i64 %indvars.iv.next197, %221
  br i1 %222, label %207, label %.critedge4.loopexit, !llvm.loop !29

.critedge4.loopexit:                              ; preds = %211, %207
  %.1.lcssa.ph.in = phi i64 [ %indvars.iv196, %207 ], [ %indvars.iv.next197, %211 ]
  %.1.lcssa.ph = trunc i64 %.1.lcssa.ph.in to i32
  br label %.critedge4

.critedge4:                                       ; preds = %.lr.ph162, %.critedge4.loopexit
  %.1.lcssa = phi i32 [ %.1.lcssa.ph, %.critedge4.loopexit ], [ %.093160, %.lr.ph162 ]
  %223 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %204
  %224 = getelementptr inbounds i8, ptr %223, i64 4
  %225 = load i32, ptr %224, align 4, !tbaa !18
  %226 = tail call noundef i32 @_Z7seg_idxii(i32 noundef %225, i32 noundef %225)
  %227 = sext i32 %226 to i64
  %228 = getelementptr inbounds [200003 x %struct.Segment], ptr @segL, i64 0, i64 %227, i32 1
  %229 = load i32, ptr %228, align 4, !tbaa !21
  %230 = load i32, ptr @cc, align 4, !tbaa !5
  %231 = load i32, ptr %224, align 4, !tbaa !18
  store i32 %229, ptr @INF, align 4, !tbaa !5
  %232 = tail call noundef i64 @_Z7seg_queP7SegmentiiiiRi(ptr noundef nonnull @segL, i32 noundef 1, i32 noundef %230, i32 noundef 1, i32 noundef %231, ptr noundef nonnull align 4 dereferenceable(4) @INF)
  %233 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %204
  %234 = load i64, ptr %233, align 8, !tbaa !12
  %235 = add nsw i64 %234, %232
  store i64 %235, ptr %233, align 8, !tbaa !12
  %236 = load i32, ptr %224, align 4, !tbaa !18
  %237 = load i32, ptr @cc, align 4, !tbaa !5
  %238 = icmp slt i32 %236, %237
  br i1 %238, label %239, label %244

239:                                              ; preds = %.critedge4
  %240 = sub nsw i32 %237, %236
  store i32 %229, ptr @INF, align 4, !tbaa !5
  %241 = tail call noundef i64 @_Z7seg_queP7SegmentiiiiRi(ptr noundef nonnull @segR, i32 noundef 1, i32 noundef %237, i32 noundef 1, i32 noundef %240, ptr noundef nonnull align 4 dereferenceable(4) @INF)
  %242 = load i64, ptr %233, align 8, !tbaa !12
  %243 = add nsw i64 %242, %241
  %.pre213 = load i32, ptr @cc, align 4, !tbaa !5
  br label %244

244:                                              ; preds = %239, %.critedge4
  %245 = phi i64 [ %243, %239 ], [ %235, %.critedge4 ]
  %246 = phi i32 [ %.pre213, %239 ], [ %237, %.critedge4 ]
  %247 = load i32, ptr %223, align 8, !tbaa !16
  %248 = sext i32 %247 to i64
  %249 = sext i32 %246 to i64
  %250 = mul nsw i64 %249, %248
  %251 = sub nsw i64 %245, %250
  store i64 %251, ptr %233, align 8, !tbaa !12
  %indvars.iv.next201 = add nuw nsw i64 %indvars.iv200, 1
  %252 = load i32, ptr @q, align 4, !tbaa !5
  %253 = sext i32 %252 to i64
  %254 = icmp slt i64 %indvars.iv.next201, %253
  br i1 %254, label %.lr.ph162, label %.preheader, !llvm.loop !30

.lr.ph164:                                        ; preds = %.preheader, %.lr.ph164
  %indvars.iv204 = phi i64 [ %indvars.iv.next205, %.lr.ph164 ], [ 0, %.preheader ]
  %255 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %indvars.iv204
  %256 = load i64, ptr %255, align 8, !tbaa !12
  %257 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i64 noundef %256)
  %indvars.iv.next205 = add nuw nsw i64 %indvars.iv204, 1
  %258 = load i32, ptr @q, align 4, !tbaa !5
  %259 = sext i32 %258 to i64
  %260 = icmp slt i64 %indvars.iv.next205, %259
  br i1 %260, label %.lr.ph164, label %.loopexit, !llvm.loop !31

._crit_edge168:                                   ; preds = %.loopexit, %0
  ret i32 0
}

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

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

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

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

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

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 = { 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 #2 = { 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 #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 = { 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" }

!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 = distinct !{!11, !10}
!12 = !{!13, !13, i64 0}
!13 = !{!"long long", !7, i64 0}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = !{!17, !6, i64 0}
!17 = !{!"_ZTSSt4pairIiiE", !6, i64 0, !6, i64 4}
!18 = !{!17, !6, i64 4}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}
!21 = !{!22, !6, i64 4}
!22 = !{!"_ZTS7Segment", !6, i64 0, !6, i64 4, !13, i64 8}
!23 = distinct !{!23, !10}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.unroll.disable"}
!26 = distinct !{!26, !10}
!27 = distinct !{!27, !25}
!28 = distinct !{!28, !10}
!29 = distinct !{!29, !10}
!30 = distinct !{!30, !10}
!31 = distinct !{!31, !10}


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