; LLVM IR from eyangch/competitive-programming :: USACOcontests/platinum/2021.02 (no_time_to_dry)

; 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<long long, std::allocator<long long>>::_Vector_impl" }
%"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl" = type { %"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl_data" }
%"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::pair.0" = type { %"struct.std::pair", i64 }
%"struct.std::pair" = type { i64, i64 }
%struct.BIT = type { [200001 x i64] }
%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::stack" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Deque_impl" }
%"struct.std::_Deque_base<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Deque_impl" = type { %"struct.std::_Deque_base<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Deque_impl_data" }
%"struct.std::_Deque_base<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }

@N = external dso_local global i64, align 8
@Q = external dso_local global i64, align 8
@a = external dso_local global [200000 x i64], align 16
@id = external dso_local global [200000 x i64], align 16
@ans = external dso_local global [200000 x i64], align 16
@spt = external dso_local global [200000 x i64], align 16
@seg = external dso_local global [200000 x %"class.std::vector"], align 16
@qr = external dso_local global [200000 x %"struct.std::pair.0"], align 16
@bit = external dso_local global %struct.BIT, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca %"class.std::stack", align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca %"struct.std::pair", align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i32, align 4
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  %17 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %18 = getelementptr i8, ptr %17, i64 -24
  %19 = load i64, ptr %18, align 8
  %20 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %19
  %21 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %20, ptr noundef null)
  %22 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %23 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @N)
  %24 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %23, ptr noundef nonnull align 8 dereferenceable(8) @Q)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #7
  store i64 0, ptr %2, align 8, !tbaa !8
  br label %25

25:                                               ; preds = %34, %0
  %26 = load i64, ptr %2, align 8, !tbaa !8
  %27 = load i64, ptr @N, align 8, !tbaa !8
  %28 = icmp slt i64 %26, %27
  br i1 %28, label %30, label %29

29:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #7
  br label %37

30:                                               ; preds = %25
  %31 = load i64, ptr %2, align 8, !tbaa !8
  %32 = getelementptr inbounds [200000 x i64], ptr @a, i64 0, i64 %31
  %33 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %32)
  br label %34

34:                                               ; preds = %30
  %35 = load i64, ptr %2, align 8, !tbaa !8
  %36 = add nsw i64 %35, 1
  store i64 %36, ptr %2, align 8, !tbaa !8
  br label %25, !llvm.loop !11

37:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #7
  store i64 0, ptr %3, align 8, !tbaa !8
  br label %38

38:                                               ; preds = %70, %37
  %39 = load i64, ptr %3, align 8, !tbaa !8
  %40 = load i64, ptr @Q, align 8, !tbaa !8
  %41 = icmp slt i64 %39, %40
  br i1 %41, label %43, label %42

42:                                               ; preds = %38
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #7
  br label %73

43:                                               ; preds = %38
  %44 = load i64, ptr %3, align 8, !tbaa !8
  %45 = getelementptr inbounds [200000 x %"struct.std::pair.0"], ptr @qr, i64 0, i64 %44
  %46 = getelementptr inbounds %"struct.std::pair.0", ptr %45, i32 0, i32 0
  %47 = getelementptr inbounds %"struct.std::pair", ptr %46, i32 0, i32 0
  %48 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %47)
  %49 = load i64, ptr %3, align 8, !tbaa !8
  %50 = getelementptr inbounds [200000 x %"struct.std::pair.0"], ptr @qr, i64 0, i64 %49
  %51 = getelementptr inbounds %"struct.std::pair.0", ptr %50, i32 0, i32 0
  %52 = getelementptr inbounds %"struct.std::pair", ptr %51, i32 0, i32 1
  %53 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %48, ptr noundef nonnull align 8 dereferenceable(8) %52)
  %54 = load i64, ptr %3, align 8, !tbaa !8
  %55 = getelementptr inbounds [200000 x %"struct.std::pair.0"], ptr @qr, i64 0, i64 %54
  %56 = getelementptr inbounds %"struct.std::pair.0", ptr %55, i32 0, i32 0
  %57 = getelementptr inbounds %"struct.std::pair", ptr %56, i32 0, i32 0
  %58 = load i64, ptr %57, align 8, !tbaa !13
  %59 = add nsw i64 %58, -1
  store i64 %59, ptr %57, align 8, !tbaa !13
  %60 = load i64, ptr %3, align 8, !tbaa !8
  %61 = getelementptr inbounds [200000 x %"struct.std::pair.0"], ptr @qr, i64 0, i64 %60
  %62 = getelementptr inbounds %"struct.std::pair.0", ptr %61, i32 0, i32 0
  %63 = getelementptr inbounds %"struct.std::pair", ptr %62, i32 0, i32 1
  %64 = load i64, ptr %63, align 8, !tbaa !16
  %65 = add nsw i64 %64, -1
  store i64 %65, ptr %63, align 8, !tbaa !16
  %66 = load i64, ptr %3, align 8, !tbaa !8
  %67 = load i64, ptr %3, align 8, !tbaa !8
  %68 = getelementptr inbounds [200000 x %"struct.std::pair.0"], ptr @qr, i64 0, i64 %67
  %69 = getelementptr inbounds %"struct.std::pair.0", ptr %68, i32 0, i32 1
  store i64 %66, ptr %69, align 8, !tbaa !17
  br label %70

70:                                               ; preds = %43
  %71 = load i64, ptr %3, align 8, !tbaa !8
  %72 = add nsw i64 %71, 1
  store i64 %72, ptr %3, align 8, !tbaa !8
  br label %38, !llvm.loop !18

73:                                               ; preds = %42
  %74 = load i64, ptr @Q, align 8, !tbaa !8
  %75 = getelementptr inbounds %"struct.std::pair.0", ptr @qr, i64 %74
  call void @_ZSt4sortIPSt4pairIS0_IxxExEEvT_S4_(ptr noundef @qr, ptr noundef %75)
  call void @llvm.lifetime.start.p0(i64 80, ptr %4) #7
  call void @_ZNSt5stackISt4pairIxxESt5dequeIS1_SaIS1_EEEC2IS4_vEEv(ptr noundef nonnull align 8 dereferenceable(80) %4)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  store i64 0, ptr %5, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  store i64 0, ptr %6, align 8, !tbaa !8
  br label %76

76:                                               ; preds = %142, %73
  %77 = load i64, ptr %6, align 8, !tbaa !8
  %78 = load i64, ptr @N, align 8, !tbaa !8
  %79 = icmp slt i64 %77, %78
  br i1 %79, label %81, label %80

80:                                               ; preds = %76
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  br label %146

81:                                               ; preds = %76
  br label %82

82:                                               ; preds = %97, %81
  %83 = invoke noundef zeroext i1 @_ZNKSt5stackISt4pairIxxESt5dequeIS1_SaIS1_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %4)
          to label %84 unwind label %98

84:                                               ; preds = %82
  br i1 %83, label %94, label %85

85:                                               ; preds = %84
  %86 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt5stackISt4pairIxxESt5dequeIS1_SaIS1_EEE3topEv(ptr noundef nonnull align 8 dereferenceable(80) %4)
          to label %87 unwind label %98

87:                                               ; preds = %85
  %88 = getelementptr inbounds %"struct.std::pair", ptr %86, i32 0, i32 0
  %89 = load i64, ptr %88, align 8, !tbaa !19
  %90 = load i64, ptr %6, align 8, !tbaa !8
  %91 = getelementptr inbounds [200000 x i64], ptr @a, i64 0, i64 %90
  %92 = load i64, ptr %91, align 8, !tbaa !8
  %93 = icmp sgt i64 %89, %92
  br label %94

94:                                               ; preds = %87, %84
  %95 = phi i1 [ false, %84 ], [ %93, %87 ]
  br i1 %95, label %96, label %102

96:                                               ; preds = %94
  invoke void @_ZNSt5stackISt4pairIxxESt5dequeIS1_SaIS1_EEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) %4)
          to label %97 unwind label %98

97:                                               ; preds = %96
  br label %82, !llvm.loop !20

98:                                               ; preds = %136, %129, %105, %102, %96, %85, %82
  %99 = landingpad { ptr, i32 }
          cleanup
  %100 = extractvalue { ptr, i32 } %99, 0
  store ptr %100, ptr %7, align 8
  %101 = extractvalue { ptr, i32 } %99, 1
  store i32 %101, ptr %8, align 4
  br label %145

102:                                              ; preds = %94
  %103 = invoke noundef zeroext i1 @_ZNKSt5stackISt4pairIxxESt5dequeIS1_SaIS1_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %4)
          to label %104 unwind label %98

104:                                              ; preds = %102
  br i1 %103, label %114, label %105

105:                                              ; preds = %104
  %106 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt5stackISt4pairIxxESt5dequeIS1_SaIS1_EEE3topEv(ptr noundef nonnull align 8 dereferenceable(80) %4)
          to label %107 unwind label %98

107:                                              ; preds = %105
  %108 = getelementptr inbounds %"struct.std::pair", ptr %106, i32 0, i32 0
  %109 = load i64, ptr %108, align 8, !tbaa !19
  %110 = load i64, ptr %6, align 8, !tbaa !8
  %111 = getelementptr inbounds [200000 x i64], ptr @a, i64 0, i64 %110
  %112 = load i64, ptr %111, align 8, !tbaa !8
  %113 = icmp slt i64 %109, %112
  br i1 %113, label %114, label %129

114:                                              ; preds = %107, %104
  %115 = load i64, ptr %5, align 8, !tbaa !8
  %116 = add nsw i64 %115, 1
  store i64 %116, ptr %5, align 8, !tbaa !8
  %117 = load i64, ptr %6, align 8, !tbaa !8
  %118 = getelementptr inbounds [200000 x i64], ptr @id, i64 0, i64 %117
  store i64 %115, ptr %118, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #7
  %119 = load i64, ptr %6, align 8, !tbaa !8
  %120 = getelementptr inbounds [200000 x i64], ptr @a, i64 0, i64 %119
  %121 = load i64, ptr %6, align 8, !tbaa !8
  %122 = getelementptr inbounds [200000 x i64], ptr @id, i64 0, i64 %121
  invoke void @_ZNSt4pairIxxEC2IRxS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 8 dereferenceable(16) %9, ptr noundef nonnull align 8 dereferenceable(8) %120, ptr noundef nonnull align 8 dereferenceable(8) %122)
          to label %123 unwind label %125

123:                                              ; preds = %114
  invoke void @_ZNSt5stackISt4pairIxxESt5dequeIS1_SaIS1_EEE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(80) %4, ptr noundef nonnull align 8 dereferenceable(16) %9)
          to label %124 unwind label %125

124:                                              ; preds = %123
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #7
  br label %136

125:                                              ; preds = %123, %114
  %126 = landingpad { ptr, i32 }
          cleanup
  %127 = extractvalue { ptr, i32 } %126, 0
  store ptr %127, ptr %7, align 8
  %128 = extractvalue { ptr, i32 } %126, 1
  store i32 %128, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #7
  br label %145

129:                                              ; preds = %107
  %130 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt5stackISt4pairIxxESt5dequeIS1_SaIS1_EEE3topEv(ptr noundef nonnull align 8 dereferenceable(80) %4)
          to label %131 unwind label %98

131:                                              ; preds = %129
  %132 = getelementptr inbounds %"struct.std::pair", ptr %130, i32 0, i32 1
  %133 = load i64, ptr %132, align 8, !tbaa !21
  %134 = load i64, ptr %6, align 8, !tbaa !8
  %135 = getelementptr inbounds [200000 x i64], ptr @id, i64 0, i64 %134
  store i64 %133, ptr %135, align 8, !tbaa !8
  br label %136

136:                                              ; preds = %131, %124
  %137 = load i64, ptr %6, align 8, !tbaa !8
  %138 = getelementptr inbounds [200000 x i64], ptr @id, i64 0, i64 %137
  %139 = load i64, ptr %138, align 8, !tbaa !8
  %140 = getelementptr inbounds [200000 x %"class.std::vector"], ptr @seg, i64 0, i64 %139
  invoke void @_ZNSt6vectorIxSaIxEE9push_backERKx(ptr noundef nonnull align 8 dereferenceable(24) %140, ptr noundef nonnull align 8 dereferenceable(8) %6)
          to label %141 unwind label %98

141:                                              ; preds = %136
  br label %142

142:                                              ; preds = %141
  %143 = load i64, ptr %6, align 8, !tbaa !8
  %144 = add nsw i64 %143, 1
  store i64 %144, ptr %6, align 8, !tbaa !8
  br label %76, !llvm.loop !22

145:                                              ; preds = %125, %98
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  br label %271

146:                                              ; preds = %80
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  store i64 0, ptr %10, align 8, !tbaa !8
  br label %147

147:                                              ; preds = %160, %146
  %148 = load i64, ptr %10, align 8, !tbaa !8
  %149 = load i64, ptr %5, align 8, !tbaa !8
  %150 = icmp slt i64 %148, %149
  br i1 %150, label %152, label %151

151:                                              ; preds = %147
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  br label %167

152:                                              ; preds = %147
  %153 = load i64, ptr %10, align 8, !tbaa !8
  %154 = getelementptr inbounds [200000 x i64], ptr @spt, i64 0, i64 %153
  store i64 0, ptr %154, align 8, !tbaa !8
  %155 = load i64, ptr %10, align 8, !tbaa !8
  %156 = getelementptr inbounds [200000 x %"class.std::vector"], ptr @seg, i64 0, i64 %155
  %157 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIxSaIxEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %156, i64 noundef 0) #7
  %158 = load i64, ptr %157, align 8, !tbaa !8
  invoke void @_ZN3BIT3updExx(ptr noundef nonnull align 8 dereferenceable(1600008) @bit, i64 noundef %158, i64 noundef 1)
          to label %159 unwind label %163

159:                                              ; preds = %152
  br label %160

160:                                              ; preds = %159
  %161 = load i64, ptr %10, align 8, !tbaa !8
  %162 = add nsw i64 %161, 1
  store i64 %162, ptr %10, align 8, !tbaa !8
  br label %147, !llvm.loop !23

163:                                              ; preds = %152
  %164 = landingpad { ptr, i32 }
          cleanup
  %165 = extractvalue { ptr, i32 } %164, 0
  store ptr %165, ptr %7, align 8
  %166 = extractvalue { ptr, i32 } %164, 1
  store i32 %166, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  br label %271

167:                                              ; preds = %151
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  store i64 0, ptr %11, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  store i64 0, ptr %12, align 8, !tbaa !8
  br label %168

168:                                              ; preds = %239, %167
  %169 = load i64, ptr %12, align 8, !tbaa !8
  %170 = load i64, ptr @Q, align 8, !tbaa !8
  %171 = icmp slt i64 %169, %170
  br i1 %171, label %173, label %172

172:                                              ; preds = %168
  store i32 16, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  br label %247

173:                                              ; preds = %168
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  %174 = load i64, ptr %11, align 8, !tbaa !8
  store i64 %174, ptr %14, align 8, !tbaa !8
  br label %175

175:                                              ; preds = %218, %173
  %176 = load i64, ptr %14, align 8, !tbaa !8
  %177 = load i64, ptr %12, align 8, !tbaa !8
  %178 = getelementptr inbounds [200000 x %"struct.std::pair.0"], ptr @qr, i64 0, i64 %177
  %179 = getelementptr inbounds %"struct.std::pair.0", ptr %178, i32 0, i32 0
  %180 = getelementptr inbounds %"struct.std::pair", ptr %179, i32 0, i32 0
  %181 = load i64, ptr %180, align 8, !tbaa !13
  %182 = icmp slt i64 %176, %181
  br i1 %182, label %184, label %183

183:                                              ; preds = %175
  store i32 19, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  br label %221

184:                                              ; preds = %175
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #7
  %185 = load i64, ptr %14, align 8, !tbaa !8
  %186 = getelementptr inbounds [200000 x i64], ptr @id, i64 0, i64 %185
  %187 = load i64, ptr %186, align 8, !tbaa !8
  store i64 %187, ptr %15, align 8, !tbaa !8
  %188 = load i64, ptr %15, align 8, !tbaa !8
  %189 = getelementptr inbounds [200000 x %"class.std::vector"], ptr @seg, i64 0, i64 %188
  %190 = load i64, ptr %15, align 8, !tbaa !8
  %191 = getelementptr inbounds [200000 x i64], ptr @spt, i64 0, i64 %190
  %192 = load i64, ptr %191, align 8, !tbaa !8
  %193 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIxSaIxEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %189, i64 noundef %192) #7
  %194 = load i64, ptr %193, align 8, !tbaa !8
  invoke void @_ZN3BIT3updExx(ptr noundef nonnull align 8 dereferenceable(1600008) @bit, i64 noundef %194, i64 noundef -1)
          to label %195 unwind label %213

195:                                              ; preds = %184
  %196 = load i64, ptr %15, align 8, !tbaa !8
  %197 = getelementptr inbounds [200000 x i64], ptr @spt, i64 0, i64 %196
  %198 = load i64, ptr %197, align 8, !tbaa !8
  %199 = add nsw i64 %198, 1
  store i64 %199, ptr %197, align 8, !tbaa !8
  %200 = load i64, ptr %15, align 8, !tbaa !8
  %201 = getelementptr inbounds [200000 x %"class.std::vector"], ptr @seg, i64 0, i64 %200
  %202 = call noundef i64 @_ZNKSt6vectorIxSaIxEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %201) #7
  %203 = icmp slt i64 %199, %202
  br i1 %203, label %204, label %217

204:                                              ; preds = %195
  %205 = load i64, ptr %15, align 8, !tbaa !8
  %206 = getelementptr inbounds [200000 x %"class.std::vector"], ptr @seg, i64 0, i64 %205
  %207 = load i64, ptr %15, align 8, !tbaa !8
  %208 = getelementptr inbounds [200000 x i64], ptr @spt, i64 0, i64 %207
  %209 = load i64, ptr %208, align 8, !tbaa !8
  %210 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIxSaIxEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %206, i64 noundef %209) #7
  %211 = load i64, ptr %210, align 8, !tbaa !8
  invoke void @_ZN3BIT3updExx(ptr noundef nonnull align 8 dereferenceable(1600008) @bit, i64 noundef %211, i64 noundef 1)
          to label %212 unwind label %213

212:                                              ; preds = %204
  br label %217

213:                                              ; preds = %204, %184
  %214 = landingpad { ptr, i32 }
          cleanup
  %215 = extractvalue { ptr, i32 } %214, 0
  store ptr %215, ptr %7, align 8
  %216 = extractvalue { ptr, i32 } %214, 1
  store i32 %216, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  br label %246

217:                                              ; preds = %212, %195
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  br label %218

218:                                              ; preds = %217
  %219 = load i64, ptr %14, align 8, !tbaa !8
  %220 = add nsw i64 %219, 1
  store i64 %220, ptr %14, align 8, !tbaa !8
  br label %175, !llvm.loop !24

221:                                              ; preds = %183
  %222 = load i64, ptr %12, align 8, !tbaa !8
  %223 = getelementptr inbounds [200000 x %"struct.std::pair.0"], ptr @qr, i64 0, i64 %222
  %224 = getelementptr inbounds %"struct.std::pair.0", ptr %223, i32 0, i32 0
  %225 = getelementptr inbounds %"struct.std::pair", ptr %224, i32 0, i32 0
  %226 = load i64, ptr %225, align 8, !tbaa !13
  store i64 %226, ptr %11, align 8, !tbaa !8
  %227 = load i64, ptr %12, align 8, !tbaa !8
  %228 = getelementptr inbounds [200000 x %"struct.std::pair.0"], ptr @qr, i64 0, i64 %227
  %229 = getelementptr inbounds %"struct.std::pair.0", ptr %228, i32 0, i32 0
  %230 = getelementptr inbounds %"struct.std::pair", ptr %229, i32 0, i32 1
  %231 = load i64, ptr %230, align 8, !tbaa !16
  %232 = invoke noundef i64 @_ZN3BIT3qryEx(ptr noundef nonnull align 8 dereferenceable(1600008) @bit, i64 noundef %231)
          to label %233 unwind label %242

233:                                              ; preds = %221
  %234 = load i64, ptr %12, align 8, !tbaa !8
  %235 = getelementptr inbounds [200000 x %"struct.std::pair.0"], ptr @qr, i64 0, i64 %234
  %236 = getelementptr inbounds %"struct.std::pair.0", ptr %235, i32 0, i32 1
  %237 = load i64, ptr %236, align 8, !tbaa !17
  %238 = getelementptr inbounds [200000 x i64], ptr @ans, i64 0, i64 %237
  store i64 %232, ptr %238, align 8, !tbaa !8
  br label %239

239:                                              ; preds = %233
  %240 = load i64, ptr %12, align 8, !tbaa !8
  %241 = add nsw i64 %240, 1
  store i64 %241, ptr %12, align 8, !tbaa !8
  br label %168, !llvm.loop !25

242:                                              ; preds = %221
  %243 = landingpad { ptr, i32 }
          cleanup
  %244 = extractvalue { ptr, i32 } %243, 0
  store ptr %244, ptr %7, align 8
  %245 = extractvalue { ptr, i32 } %243, 1
  store i32 %245, ptr %8, align 4
  br label %246

246:                                              ; preds = %242, %213
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  br label %270

247:                                              ; preds = %172
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #7
  store i64 0, ptr %16, align 8, !tbaa !8
  br label %248

248:                                              ; preds = %261, %247
  %249 = load i64, ptr %16, align 8, !tbaa !8
  %250 = load i64, ptr @Q, align 8, !tbaa !8
  %251 = icmp slt i64 %249, %250
  br i1 %251, label %253, label %252

252:                                              ; preds = %248
  store i32 22, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  br label %268

253:                                              ; preds = %248
  %254 = load i64, ptr %16, align 8, !tbaa !8
  %255 = getelementptr inbounds [200000 x i64], ptr @ans, i64 0, i64 %254
  %256 = load i64, ptr %255, align 8, !tbaa !8
  %257 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %256)
          to label %258 unwind label %264

258:                                              ; preds = %253
  %259 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %257, i8 noundef signext 10)
          to label %260 unwind label %264

260:                                              ; preds = %258
  br label %261

261:                                              ; preds = %260
  %262 = load i64, ptr %16, align 8, !tbaa !8
  %263 = add nsw i64 %262, 1
  store i64 %263, ptr %16, align 8, !tbaa !8
  br label %248, !llvm.loop !26

264:                                              ; preds = %258, %253
  %265 = landingpad { ptr, i32 }
          cleanup
  %266 = extractvalue { ptr, i32 } %265, 0
  store ptr %266, ptr %7, align 8
  %267 = extractvalue { ptr, i32 } %265, 1
  store i32 %267, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  br label %270

268:                                              ; preds = %252
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  call void @_ZNSt5stackISt4pairIxxESt5dequeIS1_SaIS1_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %4) #7
  call void @llvm.lifetime.end.p0(i64 80, ptr %4) #7
  %269 = load i32, ptr %1, align 4
  ret i32 %269

270:                                              ; preds = %264, %246
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  br label %271

271:                                              ; preds = %270, %163, %145
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  call void @_ZNSt5stackISt4pairIxxESt5dequeIS1_SaIS1_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %4) #7
  call void @llvm.lifetime.end.p0(i64 80, ptr %4) #7
  br label %272

272:                                              ; preds = %271
  %273 = load ptr, ptr %7, align 8
  %274 = load i32, ptr %8, align 4
  %275 = insertvalue { ptr, i32 } poison, ptr %273, 0
  %276 = insertvalue { ptr, i32 } %275, i32 %274, 1
  resume { ptr, i32 } %276
}

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

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) #2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) #3 align 2

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt5stackISt4pairIxxESt5dequeIS1_SaIS1_EEEC2IS4_vEEv(ptr noundef nonnull align 8 dereferenceable(80)) unnamed_addr #3 align 2

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

declare i32 @__gxx_personality_v0(...)

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt5stackISt4pairIxxESt5dequeIS1_SaIS1_EEE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(80), ptr noundef nonnull align 8 dereferenceable(16)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt4pairIxxEC2IRxS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3BIT3updExx(ptr noundef nonnull align 8 dereferenceable(1600008), i64 noundef, i64 noundef) #1 align 2

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) #5

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZNSt5stackISt4pairIxxESt5dequeIS1_SaIS1_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80)) unnamed_addr #6 align 2

attributes #0 = { 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 #1 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { "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 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"long long", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !9, i64 0}
!14 = !{!"_ZTSSt4pairIS_IxxExE", !15, i64 0, !9, i64 16}
!15 = !{!"_ZTSSt4pairIxxE", !9, i64 0, !9, i64 8}
!16 = !{!14, !9, i64 8}
!17 = !{!14, !9, i64 16}
!18 = distinct !{!18, !12}
!19 = !{!15, !9, i64 0}
!20 = distinct !{!20, !12}
!21 = !{!15, !9, i64 8}
!22 = distinct !{!22, !12}
!23 = distinct !{!23, !12}
!24 = distinct !{!24, !12}
!25 = distinct !{!25, !12}
!26 = distinct !{!26, !12}


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

%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl" }
%"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl" = type { %"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl_data" }
%"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::pair.0" = type { %"struct.std::pair", i64 }
%"struct.std::pair" = type { i64, i64 }
%struct.BIT = type { [200001 x i64] }
%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::stack" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Deque_impl" }
%"struct.std::_Deque_base<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Deque_impl" = type { %"struct.std::_Deque_base<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Deque_impl_data" }
%"struct.std::_Deque_base<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }

@N = external dso_local global i64, align 8
@Q = external dso_local global i64, align 8
@a = external dso_local global [200000 x i64], align 16
@id = external dso_local global [200000 x i64], align 16
@ans = external dso_local local_unnamed_addr global [200000 x i64], align 16
@spt = external dso_local local_unnamed_addr global [200000 x i64], align 16
@seg = external dso_local global [200000 x %"class.std::vector"], align 16
@qr = external dso_local global [200000 x %"struct.std::pair.0"], align 16
@bit = external dso_local global %struct.BIT, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca %"class.std::stack", align 8
  %2 = alloca i64, align 8
  %3 = alloca %"struct.std::pair", align 8
  %4 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %5 = getelementptr i8, ptr %4, i64 -24
  %6 = load i64, ptr %5, align 8
  %7 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %6
  %8 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %7, ptr noundef null)
  %9 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %10 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @N)
  %11 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %10, ptr noundef nonnull align 8 dereferenceable(8) @Q)
  %12 = load i64, ptr @N, align 8, !tbaa !8
  %13 = icmp sgt i64 %12, 0
  br i1 %13, label %.lr.ph, label %.preheader56

.preheader56:                                     ; preds = %.lr.ph, %0
  %14 = load i64, ptr @Q, align 8, !tbaa !8
  %15 = icmp sgt i64 %14, 0
  br i1 %15, label %.lr.ph63, label %._crit_edge

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.03861 = phi i64 [ %18, %.lr.ph ], [ 0, %0 ]
  %16 = getelementptr inbounds [200000 x i64], ptr @a, i64 0, i64 %.03861
  %17 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %16)
  %18 = add nuw nsw i64 %.03861, 1
  %19 = load i64, ptr @N, align 8, !tbaa !8
  %20 = icmp slt i64 %18, %19
  br i1 %20, label %.lr.ph, label %.preheader56, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph63, %.preheader56
  %.lcssa60 = phi i64 [ %14, %.preheader56 ], [ %32, %.lr.ph63 ]
  %21 = getelementptr inbounds %"struct.std::pair.0", ptr @qr, i64 %.lcssa60
  tail call void @_ZSt4sortIPSt4pairIS0_IxxExEEvT_S4_(ptr noundef nonnull @qr, ptr noundef nonnull %21)
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %1) #7
  call void @_ZNSt5stackISt4pairIxxESt5dequeIS1_SaIS1_EEEC2IS4_vEEv(ptr noundef nonnull align 8 dereferenceable(80) %1)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #7
  store i64 0, ptr %2, align 8, !tbaa !8
  %22 = load i64, ptr @N, align 8, !tbaa !8
  %23 = icmp sgt i64 %22, 0
  br i1 %23, label %.preheader55, label %._crit_edge67.thread

._crit_edge67.thread:                             ; preds = %._crit_edge
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  br label %.preheader54

.lr.ph63:                                         ; preds = %.preheader56, %.lr.ph63
  %.04862 = phi i64 [ %31, %.lr.ph63 ], [ 0, %.preheader56 ]
  %24 = getelementptr inbounds [200000 x %"struct.std::pair.0"], ptr @qr, i64 0, i64 %.04862
  %25 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %24)
  %26 = getelementptr inbounds i8, ptr %24, i64 8
  %27 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %25, ptr noundef nonnull align 8 dereferenceable(8) %26)
  %28 = load <2 x i64>, ptr %24, align 8, !tbaa !8
  %29 = add nsw <2 x i64> %28, <i64 -1, i64 -1>
  store <2 x i64> %29, ptr %24, align 8, !tbaa !8
  %30 = getelementptr inbounds i8, ptr %24, i64 16
  store i64 %.04862, ptr %30, align 8, !tbaa !13
  %31 = add nuw nsw i64 %.04862, 1
  %32 = load i64, ptr @Q, align 8, !tbaa !8
  %33 = icmp slt i64 %31, %32
  br i1 %33, label %.lr.ph63, label %._crit_edge, !llvm.loop !16

.preheader55:                                     ; preds = %._crit_edge, %71
  %.04666 = phi i64 [ %.147, %71 ], [ 0, %._crit_edge ]
  %34 = call noundef zeroext i1 @_ZNKSt5stackISt4pairIxxESt5dequeIS1_SaIS1_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %1)
  br i1 %34, label %.critedge, label %.lr.ph64

._crit_edge67:                                    ; preds = %71
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  %35 = icmp sgt i64 %.147, 0
  br i1 %35, label %.lr.ph71, label %.preheader54

.lr.ph64:                                         ; preds = %.preheader55, %42
  %36 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt5stackISt4pairIxxESt5dequeIS1_SaIS1_EEE3topEv(ptr noundef nonnull align 8 dereferenceable(80) %1)
  %37 = load i64, ptr %36, align 8, !tbaa !17
  %38 = load i64, ptr %2, align 8, !tbaa !8
  %39 = getelementptr inbounds [200000 x i64], ptr @a, i64 0, i64 %38
  %40 = load i64, ptr %39, align 8, !tbaa !8
  %41 = icmp sgt i64 %37, %40
  br i1 %41, label %42, label %.critedge

42:                                               ; preds = %.lr.ph64
  call void @_ZNSt5stackISt4pairIxxESt5dequeIS1_SaIS1_EEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) %1)
  %43 = call noundef zeroext i1 @_ZNKSt5stackISt4pairIxxESt5dequeIS1_SaIS1_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %1)
  br i1 %43, label %.critedge, label %.lr.ph64, !llvm.loop !18

44:                                               ; preds = %68
  %45 = landingpad { ptr, i32 }
          cleanup
  br label %76

.critedge:                                        ; preds = %.lr.ph64, %42, %.preheader55
  %46 = call noundef zeroext i1 @_ZNKSt5stackISt4pairIxxESt5dequeIS1_SaIS1_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %1)
  br i1 %46, label %.critedge._crit_edge, label %47

.critedge._crit_edge:                             ; preds = %.critedge
  %.pre = load i64, ptr %2, align 8, !tbaa !8
  br label %54

47:                                               ; preds = %.critedge
  %48 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt5stackISt4pairIxxESt5dequeIS1_SaIS1_EEE3topEv(ptr noundef nonnull align 8 dereferenceable(80) %1)
  %49 = load i64, ptr %48, align 8, !tbaa !17
  %50 = load i64, ptr %2, align 8, !tbaa !8
  %51 = getelementptr inbounds [200000 x i64], ptr @a, i64 0, i64 %50
  %52 = load i64, ptr %51, align 8, !tbaa !8
  %53 = icmp slt i64 %49, %52
  br i1 %53, label %54, label %62

54:                                               ; preds = %.critedge._crit_edge, %47
  %55 = phi i64 [ %.pre, %.critedge._crit_edge ], [ %50, %47 ]
  %56 = getelementptr inbounds [200000 x i64], ptr @id, i64 0, i64 %55
  store i64 %.04666, ptr %56, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #7
  %57 = getelementptr inbounds [200000 x i64], ptr @a, i64 0, i64 %55
  call void @_ZNSt4pairIxxEC2IRxS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull align 8 dereferenceable(8) %57, ptr noundef nonnull align 8 dereferenceable(8) %56)
  invoke void @_ZNSt5stackISt4pairIxxESt5dequeIS1_SaIS1_EEE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(80) %1, ptr noundef nonnull align 8 dereferenceable(16) %3)
          to label %58 unwind label %60

58:                                               ; preds = %54
  %59 = add nsw i64 %.04666, 1
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #7
  %.pre85 = load i64, ptr %2, align 8, !tbaa !8
  %.phi.trans.insert = getelementptr inbounds [200000 x i64], ptr @id, i64 0, i64 %.pre85
  %.pre86 = load i64, ptr %.phi.trans.insert, align 8, !tbaa !8
  br label %68

60:                                               ; preds = %54
  %61 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #7
  br label %76

62:                                               ; preds = %47
  %63 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt5stackISt4pairIxxESt5dequeIS1_SaIS1_EEE3topEv(ptr noundef nonnull align 8 dereferenceable(80) %1)
  %64 = getelementptr inbounds i8, ptr %63, i64 8
  %65 = load i64, ptr %64, align 8, !tbaa !19
  %66 = load i64, ptr %2, align 8, !tbaa !8
  %67 = getelementptr inbounds [200000 x i64], ptr @id, i64 0, i64 %66
  store i64 %65, ptr %67, align 8, !tbaa !8
  br label %68

68:                                               ; preds = %62, %58
  %69 = phi i64 [ %.pre86, %58 ], [ %65, %62 ]
  %.147 = phi i64 [ %59, %58 ], [ %.04666, %62 ]
  %70 = getelementptr inbounds [200000 x %"class.std::vector"], ptr @seg, i64 0, i64 %69
  invoke void @_ZNSt6vectorIxSaIxEE9push_backERKx(ptr noundef nonnull align 8 dereferenceable(24) %70, ptr noundef nonnull align 8 dereferenceable(8) %2)
          to label %71 unwind label %44

71:                                               ; preds = %68
  %72 = load i64, ptr %2, align 8, !tbaa !8
  %73 = add nsw i64 %72, 1
  store i64 %73, ptr %2, align 8, !tbaa !8
  %74 = load i64, ptr @N, align 8, !tbaa !8
  %75 = icmp slt i64 %73, %74
  br i1 %75, label %.preheader55, label %._crit_edge67, !llvm.loop !20

76:                                               ; preds = %60, %44
  %.pn = phi { ptr, i32 } [ %45, %44 ], [ %61, %60 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  br label %127

.preheader54:                                     ; preds = %.lr.ph71, %._crit_edge67.thread, %._crit_edge67
  %77 = load i64, ptr @Q, align 8, !tbaa !8
  %78 = icmp sgt i64 %77, 0
  br i1 %78, label %.preheader53, label %._crit_edge81

.lr.ph71:                                         ; preds = %._crit_edge67, %.lr.ph71
  %.04269 = phi i64 [ %83, %.lr.ph71 ], [ 0, %._crit_edge67 ]
  %79 = getelementptr inbounds [200000 x i64], ptr @spt, i64 0, i64 %.04269
  store i64 0, ptr %79, align 8, !tbaa !8
  %80 = getelementptr inbounds [200000 x %"class.std::vector"], ptr @seg, i64 0, i64 %.04269
  %81 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIxSaIxEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %80, i64 noundef 0) #7
  %82 = load i64, ptr %81, align 8, !tbaa !8
  call void @_ZN3BIT3updExx(ptr noundef nonnull align 8 dereferenceable(1600008) @bit, i64 noundef %82, i64 noundef 1)
  %83 = add nuw nsw i64 %.04269, 1
  %exitcond.not = icmp eq i64 %83, %.147
  br i1 %exitcond.not, label %.preheader54, label %.lr.ph71, !llvm.loop !21

.preheader53:                                     ; preds = %.preheader54, %._crit_edge74
  %.04078 = phi i64 [ %94, %._crit_edge74 ], [ 0, %.preheader54 ]
  %.04177 = phi i64 [ %.lcssa, %._crit_edge74 ], [ 0, %.preheader54 ]
  %84 = getelementptr inbounds [200000 x %"struct.std::pair.0"], ptr @qr, i64 0, i64 %.04078
  %85 = load i64, ptr %84, align 8, !tbaa !22
  %86 = icmp slt i64 %.04177, %85
  br i1 %86, label %.lr.ph73, label %._crit_edge74

.preheader:                                       ; preds = %._crit_edge74
  %87 = icmp sgt i64 %95, 0
  br i1 %87, label %.lr.ph80, label %._crit_edge81

._crit_edge74:                                    ; preds = %112, %.preheader53
  %.lcssa = phi i64 [ %85, %.preheader53 ], [ %114, %112 ]
  %88 = getelementptr inbounds i8, ptr %84, i64 8
  %89 = load i64, ptr %88, align 8, !tbaa !23
  %90 = call noundef i64 @_ZN3BIT3qryEx(ptr noundef nonnull align 8 dereferenceable(1600008) @bit, i64 noundef %89)
  %91 = getelementptr inbounds i8, ptr %84, i64 16
  %92 = load i64, ptr %91, align 8, !tbaa !13
  %93 = getelementptr inbounds [200000 x i64], ptr @ans, i64 0, i64 %92
  store i64 %90, ptr %93, align 8, !tbaa !8
  %94 = add nuw nsw i64 %.04078, 1
  %95 = load i64, ptr @Q, align 8, !tbaa !8
  %96 = icmp slt i64 %94, %95
  br i1 %96, label %.preheader53, label %.preheader, !llvm.loop !24

.lr.ph73:                                         ; preds = %.preheader53, %112
  %.03972 = phi i64 [ %113, %112 ], [ %.04177, %.preheader53 ]
  %97 = getelementptr inbounds [200000 x i64], ptr @id, i64 0, i64 %.03972
  %98 = load i64, ptr %97, align 8, !tbaa !8
  %99 = getelementptr inbounds [200000 x %"class.std::vector"], ptr @seg, i64 0, i64 %98
  %100 = getelementptr inbounds [200000 x i64], ptr @spt, i64 0, i64 %98
  %101 = load i64, ptr %100, align 8, !tbaa !8
  %102 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIxSaIxEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %99, i64 noundef %101) #7
  %103 = load i64, ptr %102, align 8, !tbaa !8
  call void @_ZN3BIT3updExx(ptr noundef nonnull align 8 dereferenceable(1600008) @bit, i64 noundef %103, i64 noundef -1)
  %104 = load i64, ptr %100, align 8, !tbaa !8
  %105 = add nsw i64 %104, 1
  store i64 %105, ptr %100, align 8, !tbaa !8
  %106 = call noundef i64 @_ZNKSt6vectorIxSaIxEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %99) #7
  %107 = icmp slt i64 %105, %106
  br i1 %107, label %108, label %112

108:                                              ; preds = %.lr.ph73
  %109 = load i64, ptr %100, align 8, !tbaa !8
  %110 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIxSaIxEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %99, i64 noundef %109) #7
  %111 = load i64, ptr %110, align 8, !tbaa !8
  call void @_ZN3BIT3updExx(ptr noundef nonnull align 8 dereferenceable(1600008) @bit, i64 noundef %111, i64 noundef 1)
  br label %112

112:                                              ; preds = %108, %.lr.ph73
  %113 = add nsw i64 %.03972, 1
  %114 = load i64, ptr %84, align 8, !tbaa !22
  %115 = icmp slt i64 %113, %114
  br i1 %115, label %.lr.ph73, label %._crit_edge74, !llvm.loop !25

._crit_edge81:                                    ; preds = %121, %.preheader54, %.preheader
  call void @_ZNSt5stackISt4pairIxxESt5dequeIS1_SaIS1_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %1) #7
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %1) #7
  ret i32 0

.lr.ph80:                                         ; preds = %.preheader, %121
  %.079 = phi i64 [ %122, %121 ], [ 0, %.preheader ]
  %116 = getelementptr inbounds [200000 x i64], ptr @ans, i64 0, i64 %.079
  %117 = load i64, ptr %116, align 8, !tbaa !8
  %118 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %117)
          to label %119 unwind label %125

119:                                              ; preds = %.lr.ph80
  %120 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %118, i8 noundef signext 10)
          to label %121 unwind label %125

121:                                              ; preds = %119
  %122 = add nuw nsw i64 %.079, 1
  %123 = load i64, ptr @Q, align 8, !tbaa !8
  %124 = icmp slt i64 %122, %123
  br i1 %124, label %.lr.ph80, label %._crit_edge81, !llvm.loop !26

125:                                              ; preds = %119, %.lr.ph80
  %126 = landingpad { ptr, i32 }
          cleanup
  br label %127

127:                                              ; preds = %125, %76
  %.pn.pn = phi { ptr, i32 } [ %.pn, %76 ], [ %126, %125 ]
  call void @_ZNSt5stackISt4pairIxxESt5dequeIS1_SaIS1_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %1) #7
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %1) #7
  resume { ptr, i32 } %.pn.pn
}

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

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3 align 2

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt5stackISt4pairIxxESt5dequeIS1_SaIS1_EEEC2IS4_vEEv(ptr noundef nonnull align 8 dereferenceable(80)) unnamed_addr #3 align 2

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

declare i32 @__gxx_personality_v0(...)

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt5stackISt4pairIxxESt5dequeIS1_SaIS1_EEE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(80), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt4pairIxxEC2IRxS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3BIT3updExx(ptr noundef nonnull align 8 dereferenceable(1600008), i64 noundef, i64 noundef) local_unnamed_addr #1 align 2

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) local_unnamed_addr #5

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZNSt5stackISt4pairIxxESt5dequeIS1_SaIS1_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80)) unnamed_addr #6 align 2

attributes #0 = { 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 #1 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { "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 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"long long", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !9, i64 16}
!14 = !{!"_ZTSSt4pairIS_IxxExE", !15, i64 0, !9, i64 16}
!15 = !{!"_ZTSSt4pairIxxE", !9, i64 0, !9, i64 8}
!16 = distinct !{!16, !12}
!17 = !{!15, !9, i64 0}
!18 = distinct !{!18, !12}
!19 = !{!15, !9, i64 8}
!20 = distinct !{!20, !12}
!21 = distinct !{!21, !12}
!22 = !{!14, !9, i64 0}
!23 = !{!14, !9, i64 8}
!24 = distinct !{!24, !12}
!25 = distinct !{!25, !12}
!26 = distinct !{!26, !12}


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