; LLVM IR from eyangch/competitive-programming :: Codeforces/1618 (g)

; 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 { i64, i64 }
%"class.std::priority_queue" = type <{ %"class.std::vector", [8 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"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.anon = type { i8 }

@N = external dso_local global i64, align 8
@M = external dso_local global i64, align 8
@A = external dso_local global i64, align 8
@Q = external dso_local global i64, align 8
@a = external dso_local global [400000 x i64], align 16
@r = external dso_local global [400000 x i64], align 16
@pfx = external dso_local global [400001 x i64], align 16
@par = external dso_local global [400000 x i64], align 16
@sz = external dso_local global [400000 x i64], align 16
@ac = external dso_local global [400000 x i64], align 16
@rv = external dso_local global [400000 x i64], align 16
@tot = external dso_local global i64, align 8
@ans = external dso_local global [200000 x i64], align 16
@q = external dso_local global [200000 x %"struct.std::pair"], align 16
@pq = external dso_local global %"class.std::priority_queue", align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z1pxx(i64 noundef, i64 noundef) #0

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

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

28:                                               ; preds = %37, %0
  %29 = load i64, ptr %2, align 8, !tbaa !8
  %30 = load i64, ptr @N, align 8, !tbaa !8
  %31 = icmp slt i64 %29, %30
  br i1 %31, label %33, label %32

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

33:                                               ; preds = %28
  %34 = load i64, ptr %2, align 8, !tbaa !8
  %35 = getelementptr inbounds [400000 x i64], ptr @a, i64 0, i64 %34
  %36 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %35)
  br label %37

37:                                               ; preds = %33
  %38 = load i64, ptr %2, align 8, !tbaa !8
  %39 = add nsw i64 %38, 1
  store i64 %39, ptr %2, align 8, !tbaa !8
  br label %28, !llvm.loop !11

40:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  store i64 0, ptr %3, align 8, !tbaa !8
  br label %41

41:                                               ; preds = %52, %40
  %42 = load i64, ptr %3, align 8, !tbaa !8
  %43 = load i64, ptr @M, align 8, !tbaa !8
  %44 = icmp slt i64 %42, %43
  br i1 %44, label %46, label %45

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

46:                                               ; preds = %41
  %47 = load i64, ptr %3, align 8, !tbaa !8
  %48 = load i64, ptr @N, align 8, !tbaa !8
  %49 = add nsw i64 %47, %48
  %50 = getelementptr inbounds [400000 x i64], ptr @a, i64 0, i64 %49
  %51 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %50)
  br label %52

52:                                               ; preds = %46
  %53 = load i64, ptr %3, align 8, !tbaa !8
  %54 = add nsw i64 %53, 1
  store i64 %54, ptr %3, align 8, !tbaa !8
  br label %41, !llvm.loop !13

55:                                               ; preds = %45
  %56 = load i64, ptr @A, align 8, !tbaa !8
  %57 = getelementptr inbounds i64, ptr @r, i64 %56
  call void @_ZSt4iotaIPxiEvT_S1_T0_(ptr noundef @r, ptr noundef %57, i32 noundef 0)
  %58 = load i64, ptr @A, align 8, !tbaa !8
  %59 = getelementptr inbounds i64, ptr @r, i64 %58
  call void @"_ZSt4sortIPxZ4mainE3$_0EvT_S2_T0_"(ptr noundef @r, ptr noundef %59)
  %60 = load i64, ptr @A, align 8, !tbaa !8
  %61 = getelementptr inbounds i64, ptr @a, i64 %60
  call void @_ZSt4sortIPxEvT_S1_(ptr noundef @a, ptr noundef %61)
  store i64 0, ptr @pfx, align 16, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  store i64 0, ptr %5, align 8, !tbaa !8
  br label %62

62:                                               ; preds = %78, %55
  %63 = load i64, ptr %5, align 8, !tbaa !8
  %64 = load i64, ptr @A, align 8, !tbaa !8
  %65 = icmp slt i64 %63, %64
  br i1 %65, label %67, label %66

66:                                               ; preds = %62
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  br label %81

67:                                               ; preds = %62
  %68 = load i64, ptr %5, align 8, !tbaa !8
  %69 = getelementptr inbounds [400001 x i64], ptr @pfx, i64 0, i64 %68
  %70 = load i64, ptr %69, align 8, !tbaa !8
  %71 = load i64, ptr %5, align 8, !tbaa !8
  %72 = getelementptr inbounds [400000 x i64], ptr @a, i64 0, i64 %71
  %73 = load i64, ptr %72, align 8, !tbaa !8
  %74 = add nsw i64 %70, %73
  %75 = load i64, ptr %5, align 8, !tbaa !8
  %76 = add nsw i64 %75, 1
  %77 = getelementptr inbounds [400001 x i64], ptr @pfx, i64 0, i64 %76
  store i64 %74, ptr %77, align 8, !tbaa !8
  br label %78

78:                                               ; preds = %67
  %79 = load i64, ptr %5, align 8, !tbaa !8
  %80 = add nsw i64 %79, 1
  store i64 %80, ptr %5, align 8, !tbaa !8
  br label %62, !llvm.loop !14

81:                                               ; preds = %66
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  store i64 0, ptr %6, align 8, !tbaa !8
  br label %82

82:                                               ; preds = %97, %81
  %83 = load i64, ptr %6, align 8, !tbaa !8
  %84 = load i64, ptr @A, align 8, !tbaa !8
  %85 = sub nsw i64 %84, 1
  %86 = icmp slt i64 %83, %85
  br i1 %86, label %88, label %87

87:                                               ; preds = %82
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  br label %100

88:                                               ; preds = %82
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %89 = load i64, ptr %6, align 8, !tbaa !8
  %90 = add nsw i64 %89, 1
  %91 = getelementptr inbounds [400000 x i64], ptr @a, i64 0, i64 %90
  %92 = load i64, ptr %91, align 8, !tbaa !8
  %93 = load i64, ptr %6, align 8, !tbaa !8
  %94 = getelementptr inbounds [400000 x i64], ptr @a, i64 0, i64 %93
  %95 = load i64, ptr %94, align 8, !tbaa !8
  %96 = sub nsw i64 %92, %95
  store i64 %96, ptr %8, align 8, !tbaa !8
  call void @_ZNSt4pairIxxEC2IxRxTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 8 dereferenceable(16) %7, ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef nonnull align 8 dereferenceable(8) %6)
  call void @_ZNSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt7greaterIS1_EE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(25) @pq, ptr noundef nonnull align 8 dereferenceable(16) %7)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #6
  br label %97

97:                                               ; preds = %88
  %98 = load i64, ptr %6, align 8, !tbaa !8
  %99 = add nsw i64 %98, 1
  store i64 %99, ptr %6, align 8, !tbaa !8
  br label %82, !llvm.loop !15

100:                                              ; preds = %87
  %101 = load i64, ptr @A, align 8, !tbaa !8
  %102 = getelementptr inbounds i64, ptr @par, i64 %101
  call void @_ZSt4iotaIPxiEvT_S1_T0_(ptr noundef @par, ptr noundef %102, i32 noundef 0)
  %103 = load i64, ptr @A, align 8, !tbaa !8
  %104 = getelementptr inbounds i64, ptr @rv, i64 %103
  call void @_ZSt4iotaIPxiEvT_S1_T0_(ptr noundef @rv, ptr noundef %104, i32 noundef 0)
  %105 = load i64, ptr @A, align 8, !tbaa !8
  %106 = getelementptr inbounds i64, ptr @sz, i64 %105
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  store i32 1, ptr %9, align 4, !tbaa !16
  call void @_ZSt4fillIPxiEvT_S1_RKT0_(ptr noundef @sz, ptr noundef %106, ptr noundef nonnull align 4 dereferenceable(4) %9)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  store i64 0, ptr %10, align 8, !tbaa !8
  br label %107

107:                                              ; preds = %128, %100
  %108 = load i64, ptr %10, align 8, !tbaa !8
  %109 = load i64, ptr @A, align 8, !tbaa !8
  %110 = icmp slt i64 %108, %109
  br i1 %110, label %112, label %111

111:                                              ; preds = %107
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  br label %131

112:                                              ; preds = %107
  %113 = load i64, ptr %10, align 8, !tbaa !8
  %114 = getelementptr inbounds [400000 x i64], ptr @r, i64 0, i64 %113
  %115 = load i64, ptr %114, align 8, !tbaa !8
  %116 = load i64, ptr @N, align 8, !tbaa !8
  %117 = icmp slt i64 %115, %116
  %118 = zext i1 %117 to i64
  %119 = load i64, ptr %10, align 8, !tbaa !8
  %120 = getelementptr inbounds [400000 x i64], ptr @ac, i64 0, i64 %119
  store i64 %118, ptr %120, align 8, !tbaa !8
  %121 = load i64, ptr %10, align 8, !tbaa !8
  %122 = load i64, ptr %10, align 8, !tbaa !8
  %123 = getelementptr inbounds [400000 x i64], ptr @ac, i64 0, i64 %122
  %124 = load i64, ptr %123, align 8, !tbaa !8
  %125 = call noundef i64 @_Z1pxx(i64 noundef %121, i64 noundef %124)
  %126 = load i64, ptr @tot, align 8, !tbaa !8
  %127 = add nsw i64 %126, %125
  store i64 %127, ptr @tot, align 8, !tbaa !8
  br label %128

128:                                              ; preds = %112
  %129 = load i64, ptr %10, align 8, !tbaa !8
  %130 = add nsw i64 %129, 1
  store i64 %130, ptr %10, align 8, !tbaa !8
  br label %107, !llvm.loop !18

131:                                              ; preds = %111
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  store i64 0, ptr %11, align 8, !tbaa !8
  br label %132

132:                                              ; preds = %146, %131
  %133 = load i64, ptr %11, align 8, !tbaa !8
  %134 = load i64, ptr @Q, align 8, !tbaa !8
  %135 = icmp slt i64 %133, %134
  br i1 %135, label %137, label %136

136:                                              ; preds = %132
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  br label %149

137:                                              ; preds = %132
  %138 = load i64, ptr %11, align 8, !tbaa !8
  %139 = getelementptr inbounds [200000 x %"struct.std::pair"], ptr @q, i64 0, i64 %138
  %140 = getelementptr inbounds %"struct.std::pair", ptr %139, i32 0, i32 0
  %141 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %140)
  %142 = load i64, ptr %11, align 8, !tbaa !8
  %143 = load i64, ptr %11, align 8, !tbaa !8
  %144 = getelementptr inbounds [200000 x %"struct.std::pair"], ptr @q, i64 0, i64 %143
  %145 = getelementptr inbounds %"struct.std::pair", ptr %144, i32 0, i32 1
  store i64 %142, ptr %145, align 8, !tbaa !19
  br label %146

146:                                              ; preds = %137
  %147 = load i64, ptr %11, align 8, !tbaa !8
  %148 = add nsw i64 %147, 1
  store i64 %148, ptr %11, align 8, !tbaa !8
  br label %132, !llvm.loop !21

149:                                              ; preds = %136
  %150 = load i64, ptr @Q, align 8, !tbaa !8
  %151 = getelementptr inbounds %"struct.std::pair", ptr @q, i64 %150
  call void @_ZSt4sortIPSt4pairIxxEEvT_S3_(ptr noundef @q, ptr noundef %151)
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  store i64 0, ptr %12, align 8, !tbaa !8
  br label %152

152:                                              ; preds = %186, %149
  %153 = load i64, ptr %12, align 8, !tbaa !8
  %154 = load i64, ptr @Q, align 8, !tbaa !8
  %155 = icmp slt i64 %153, %154
  br i1 %155, label %157, label %156

156:                                              ; preds = %152
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  br label %189

157:                                              ; preds = %152
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %158 = load i64, ptr %12, align 8, !tbaa !8
  %159 = getelementptr inbounds [200000 x %"struct.std::pair"], ptr @q, i64 0, i64 %158
  %160 = getelementptr inbounds %"struct.std::pair", ptr %159, i32 0, i32 0
  %161 = load i64, ptr %160, align 16, !tbaa !22
  store i64 %161, ptr %13, align 8, !tbaa !8
  br label %162

162:                                              ; preds = %172, %157
  %163 = call noundef zeroext i1 @_ZNKSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt7greaterIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) @pq)
  br i1 %163, label %170, label %164

164:                                              ; preds = %162
  %165 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt7greaterIS1_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25) @pq)
  %166 = getelementptr inbounds %"struct.std::pair", ptr %165, i32 0, i32 0
  %167 = load i64, ptr %166, align 8, !tbaa !22
  %168 = load i64, ptr %13, align 8, !tbaa !8
  %169 = icmp sle i64 %167, %168
  br label %170

170:                                              ; preds = %164, %162
  %171 = phi i1 [ false, %162 ], [ %169, %164 ]
  br i1 %171, label %172, label %179

172:                                              ; preds = %170
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %173 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt7greaterIS1_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25) @pq)
  %174 = getelementptr inbounds %"struct.std::pair", ptr %173, i32 0, i32 1
  %175 = load i64, ptr %174, align 8, !tbaa !19
  store i64 %175, ptr %14, align 8, !tbaa !8
  call void @_ZNSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt7greaterIS1_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25) @pq)
  %176 = load i64, ptr %14, align 8, !tbaa !8
  %177 = load i64, ptr %14, align 8, !tbaa !8
  %178 = add nsw i64 %177, 1
  call void @_Z2unxx(i64 noundef %176, i64 noundef %178)
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  br label %162, !llvm.loop !23

179:                                              ; preds = %170
  %180 = load i64, ptr @tot, align 8, !tbaa !8
  %181 = load i64, ptr %12, align 8, !tbaa !8
  %182 = getelementptr inbounds [200000 x %"struct.std::pair"], ptr @q, i64 0, i64 %181
  %183 = getelementptr inbounds %"struct.std::pair", ptr %182, i32 0, i32 1
  %184 = load i64, ptr %183, align 8, !tbaa !19
  %185 = getelementptr inbounds [200000 x i64], ptr @ans, i64 0, i64 %184
  store i64 %180, ptr %185, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  br label %186

186:                                              ; preds = %179
  %187 = load i64, ptr %12, align 8, !tbaa !8
  %188 = add nsw i64 %187, 1
  store i64 %188, ptr %12, align 8, !tbaa !8
  br label %152, !llvm.loop !24

189:                                              ; preds = %156
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  store i64 0, ptr %15, align 8, !tbaa !8
  br label %190

190:                                              ; preds = %201, %189
  %191 = load i64, ptr %15, align 8, !tbaa !8
  %192 = load i64, ptr @Q, align 8, !tbaa !8
  %193 = icmp slt i64 %191, %192
  br i1 %193, label %195, label %194

194:                                              ; preds = %190
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  br label %204

195:                                              ; preds = %190
  %196 = load i64, ptr %15, align 8, !tbaa !8
  %197 = getelementptr inbounds [200000 x i64], ptr @ans, i64 0, i64 %196
  %198 = load i64, ptr %197, align 8, !tbaa !8
  %199 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %198)
  %200 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %199, i8 noundef signext 10)
  br label %201

201:                                              ; preds = %195
  %202 = load i64, ptr %15, align 8, !tbaa !8
  %203 = add nsw i64 %202, 1
  store i64 %203, ptr %15, align 8, !tbaa !8
  br label %190, !llvm.loop !25

204:                                              ; preds = %194
  %205 = load i32, ptr %1, align 4
  ret i32 %205
}

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

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

; 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)) #1 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: mustprogress nounwind uwtable
declare dso_local void @_ZSt4iotaIPxiEvT_S1_T0_(ptr noundef, ptr noundef, i32 noundef) #0

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZSt4sortIPxZ4mainE3$_0EvT_S2_T0_"(ptr noundef, ptr noundef) #5

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt4pairIxxEC2IxRxTnNSt9enable_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 #0 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt7greaterIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt7greaterIS1_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25)) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt7greaterIS1_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25)) #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) #1 align 2

attributes #0 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
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 = { "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 = { 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 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}
!16 = !{!17, !17, i64 0}
!17 = !{!"int", !10, i64 0}
!18 = distinct !{!18, !12}
!19 = !{!20, !9, i64 8}
!20 = !{!"_ZTSSt4pairIxxE", !9, i64 0, !9, i64 8}
!21 = distinct !{!21, !12}
!22 = !{!20, !9, i64 0}
!23 = distinct !{!23, !12}
!24 = distinct !{!24, !12}
!25 = distinct !{!25, !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"

%"struct.std::pair" = type { i64, i64 }
%"class.std::priority_queue" = type <{ %"class.std::vector", [8 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"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" }

@N = external dso_local global i64, align 8
@M = external dso_local global i64, align 8
@A = external dso_local local_unnamed_addr global i64, align 8
@Q = external dso_local global i64, align 8
@a = external dso_local global [400000 x i64], align 16
@r = external dso_local global [400000 x i64], align 16
@pfx = external dso_local local_unnamed_addr global [400001 x i64], align 16
@par = external dso_local global [400000 x i64], align 16
@sz = external dso_local global [400000 x i64], align 16
@ac = external dso_local local_unnamed_addr global [400000 x i64], align 16
@rv = external dso_local global [400000 x i64], align 16
@tot = external dso_local local_unnamed_addr global i64, align 8
@ans = external dso_local local_unnamed_addr global [200000 x i64], align 16
@q = external dso_local global [200000 x %"struct.std::pair"], align 16
@pq = external dso_local global %"class.std::priority_queue", align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z1pxx(i64 noundef, i64 noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i64, align 8
  %2 = alloca %"struct.std::pair", align 8
  %3 = alloca i64, align 8
  %4 = alloca i32, align 4
  %5 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %6 = getelementptr i8, ptr %5, i64 -24
  %7 = load i64, ptr %6, align 8
  %8 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %7
  %9 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %8, ptr noundef null)
  %10 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %11 = 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)
  %12 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %11, ptr noundef nonnull align 8 dereferenceable(8) @M)
  %13 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %12, ptr noundef nonnull align 8 dereferenceable(8) @Q)
  %14 = load i64, ptr @N, align 8, !tbaa !8
  %15 = load i64, ptr @M, align 8, !tbaa !8
  %16 = add nsw i64 %15, %14
  store i64 %16, ptr @A, align 8, !tbaa !8
  %17 = icmp sgt i64 %14, 0
  br i1 %17, label %.lr.ph, label %.preheader41

.preheader41.loopexit:                            ; preds = %.lr.ph
  %.pre = load i64, ptr @M, align 8, !tbaa !8
  br label %.preheader41

.preheader41:                                     ; preds = %.preheader41.loopexit, %0
  %18 = phi i64 [ %.pre, %.preheader41.loopexit ], [ %15, %0 ]
  %19 = icmp sgt i64 %18, 0
  br i1 %19, label %.lr.ph45, label %._crit_edge

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.03343 = phi i64 [ %22, %.lr.ph ], [ 0, %0 ]
  %20 = getelementptr inbounds [400000 x i64], ptr @a, i64 0, i64 %.03343
  %21 = 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) %20)
  %22 = add nuw nsw i64 %.03343, 1
  %23 = load i64, ptr @N, align 8, !tbaa !8
  %24 = icmp slt i64 %22, %23
  br i1 %24, label %.lr.ph, label %.preheader41.loopexit, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph45, %.preheader41
  %25 = load i64, ptr @A, align 8, !tbaa !8
  %26 = getelementptr inbounds i64, ptr @r, i64 %25
  tail call void @_ZSt4iotaIPxiEvT_S1_T0_(ptr noundef nonnull @r, ptr noundef nonnull %26, i32 noundef 0)
  %27 = load i64, ptr @A, align 8, !tbaa !8
  %28 = getelementptr inbounds i64, ptr @r, i64 %27
  tail call void @"_ZSt4sortIPxZ4mainE3$_0EvT_S2_T0_"(ptr noundef nonnull @r, ptr noundef nonnull %28)
  %29 = load i64, ptr @A, align 8, !tbaa !8
  %30 = getelementptr inbounds i64, ptr @a, i64 %29
  tail call void @_ZSt4sortIPxEvT_S1_(ptr noundef nonnull @a, ptr noundef nonnull %30)
  store i64 0, ptr @pfx, align 16, !tbaa !8
  %31 = load i64, ptr @A, align 8, !tbaa !8
  %32 = icmp sgt i64 %31, 0
  br i1 %32, label %.lr.ph48.preheader, label %._crit_edge49.thread

.lr.ph48.preheader:                               ; preds = %._crit_edge
  %xtraiter = and i64 %31, 3
  %33 = icmp ult i64 %31, 4
  br i1 %33, label %._crit_edge49.unr-lcssa, label %.lr.ph48.preheader.new

.lr.ph48.preheader.new:                           ; preds = %.lr.ph48.preheader
  %unroll_iter = and i64 %31, 9223372036854775804
  br label %.lr.ph48

._crit_edge49.thread:                             ; preds = %._crit_edge
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #6
  br label %._crit_edge53

.lr.ph45:                                         ; preds = %.preheader41, %.lr.ph45
  %.03444 = phi i64 [ %38, %.lr.ph45 ], [ 0, %.preheader41 ]
  %34 = load i64, ptr @N, align 8, !tbaa !8
  %35 = add nsw i64 %34, %.03444
  %36 = getelementptr inbounds [400000 x i64], ptr @a, i64 0, i64 %35
  %37 = 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) %36)
  %38 = add nuw nsw i64 %.03444, 1
  %39 = load i64, ptr @M, align 8, !tbaa !8
  %40 = icmp slt i64 %38, %39
  br i1 %40, label %.lr.ph45, label %._crit_edge, !llvm.loop !13

._crit_edge49.unr-lcssa:                          ; preds = %.lr.ph48, %.lr.ph48.preheader
  %.unr = phi i64 [ 0, %.lr.ph48.preheader ], [ %65, %.lr.ph48 ]
  %.03846.unr = phi i64 [ 0, %.lr.ph48.preheader ], [ %66, %.lr.ph48 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge49, label %.lr.ph48.epil

.lr.ph48.epil:                                    ; preds = %._crit_edge49.unr-lcssa, %.lr.ph48.epil
  %41 = phi i64 [ %44, %.lr.ph48.epil ], [ %.unr, %._crit_edge49.unr-lcssa ]
  %.03846.epil = phi i64 [ %45, %.lr.ph48.epil ], [ %.03846.unr, %._crit_edge49.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph48.epil ], [ 0, %._crit_edge49.unr-lcssa ]
  %42 = getelementptr inbounds [400000 x i64], ptr @a, i64 0, i64 %.03846.epil
  %43 = load i64, ptr %42, align 8, !tbaa !8
  %44 = add nsw i64 %43, %41
  %45 = add nuw nsw i64 %.03846.epil, 1
  %46 = getelementptr inbounds [400001 x i64], ptr @pfx, i64 0, i64 %45
  store i64 %44, ptr %46, align 8, !tbaa !8
  %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 %._crit_edge49, label %.lr.ph48.epil, !llvm.loop !14

._crit_edge49:                                    ; preds = %.lr.ph48.epil, %._crit_edge49.unr-lcssa
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #6
  store i64 0, ptr %1, align 8, !tbaa !8
  %.not75 = icmp eq i64 %31, 1
  br i1 %.not75, label %._crit_edge53, label %.lr.ph52

.lr.ph48:                                         ; preds = %.lr.ph48, %.lr.ph48.preheader.new
  %47 = phi i64 [ 0, %.lr.ph48.preheader.new ], [ %65, %.lr.ph48 ]
  %.03846 = phi i64 [ 0, %.lr.ph48.preheader.new ], [ %66, %.lr.ph48 ]
  %niter = phi i64 [ 0, %.lr.ph48.preheader.new ], [ %niter.next.3, %.lr.ph48 ]
  %48 = getelementptr inbounds [400000 x i64], ptr @a, i64 0, i64 %.03846
  %49 = load i64, ptr %48, align 16, !tbaa !8
  %50 = add nsw i64 %49, %47
  %51 = or disjoint i64 %.03846, 1
  %52 = getelementptr inbounds [400001 x i64], ptr @pfx, i64 0, i64 %51
  store i64 %50, ptr %52, align 8, !tbaa !8
  %53 = getelementptr inbounds [400000 x i64], ptr @a, i64 0, i64 %51
  %54 = load i64, ptr %53, align 8, !tbaa !8
  %55 = add nsw i64 %54, %50
  %56 = or disjoint i64 %.03846, 2
  %57 = getelementptr inbounds [400001 x i64], ptr @pfx, i64 0, i64 %56
  store i64 %55, ptr %57, align 16, !tbaa !8
  %58 = getelementptr inbounds [400000 x i64], ptr @a, i64 0, i64 %56
  %59 = load i64, ptr %58, align 16, !tbaa !8
  %60 = add nsw i64 %59, %55
  %61 = or disjoint i64 %.03846, 3
  %62 = getelementptr inbounds [400001 x i64], ptr @pfx, i64 0, i64 %61
  store i64 %60, ptr %62, align 8, !tbaa !8
  %63 = getelementptr inbounds [400000 x i64], ptr @a, i64 0, i64 %61
  %64 = load i64, ptr %63, align 8, !tbaa !8
  %65 = add nsw i64 %64, %60
  %66 = add nuw nsw i64 %.03846, 4
  %67 = getelementptr inbounds [400001 x i64], ptr @pfx, i64 0, i64 %66
  store i64 %65, ptr %67, align 16, !tbaa !8
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge49.unr-lcssa, label %.lr.ph48, !llvm.loop !16

._crit_edge53:                                    ; preds = %.lr.ph52, %._crit_edge49.thread, %._crit_edge49
  %.lcssa42 = phi i64 [ %31, %._crit_edge49 ], [ %31, %._crit_edge49.thread ], [ %83, %.lr.ph52 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #6
  %68 = getelementptr inbounds i64, ptr @par, i64 %.lcssa42
  call void @_ZSt4iotaIPxiEvT_S1_T0_(ptr noundef nonnull @par, ptr noundef nonnull %68, i32 noundef 0)
  %69 = load i64, ptr @A, align 8, !tbaa !8
  %70 = getelementptr inbounds i64, ptr @rv, i64 %69
  call void @_ZSt4iotaIPxiEvT_S1_T0_(ptr noundef nonnull @rv, ptr noundef nonnull %70, i32 noundef 0)
  %71 = load i64, ptr @A, align 8, !tbaa !8
  %72 = getelementptr inbounds i64, ptr @sz, i64 %71
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #6
  store i32 1, ptr %4, align 4, !tbaa !17
  call void @_ZSt4fillIPxiEvT_S1_RKT0_(ptr noundef nonnull @sz, ptr noundef nonnull %72, ptr noundef nonnull align 4 dereferenceable(4) %4)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #6
  %73 = load i64, ptr @A, align 8, !tbaa !8
  %74 = icmp sgt i64 %73, 0
  br i1 %74, label %.lr.ph56, label %.preheader40

.lr.ph52:                                         ; preds = %._crit_edge49, %.lr.ph52
  %storemerge50 = phi i64 [ %82, %.lr.ph52 ], [ 0, %._crit_edge49 ]
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  %75 = add nsw i64 %storemerge50, 1
  %76 = getelementptr inbounds [400000 x i64], ptr @a, i64 0, i64 %75
  %77 = load i64, ptr %76, align 8, !tbaa !8
  %78 = getelementptr inbounds [400000 x i64], ptr @a, i64 0, i64 %storemerge50
  %79 = load i64, ptr %78, align 8, !tbaa !8
  %80 = sub nsw i64 %77, %79
  store i64 %80, ptr %3, align 8, !tbaa !8
  call void @_ZNSt4pairIxxEC2IxRxTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %1)
  call void @_ZNSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt7greaterIS1_EE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(25) @pq, ptr noundef nonnull align 8 dereferenceable(16) %2)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #6
  %81 = load i64, ptr %1, align 8, !tbaa !8
  %82 = add nsw i64 %81, 1
  store i64 %82, ptr %1, align 8, !tbaa !8
  %83 = load i64, ptr @A, align 8, !tbaa !8
  %84 = add nsw i64 %83, -1
  %85 = icmp slt i64 %82, %84
  br i1 %85, label %.lr.ph52, label %._crit_edge53, !llvm.loop !19

.preheader40:                                     ; preds = %.lr.ph56, %._crit_edge53
  %86 = load i64, ptr @Q, align 8, !tbaa !8
  %87 = icmp sgt i64 %86, 0
  br i1 %87, label %.lr.ph58, label %._crit_edge59

.lr.ph56:                                         ; preds = %._crit_edge53, %.lr.ph56
  %.03754 = phi i64 [ %97, %.lr.ph56 ], [ 0, %._crit_edge53 ]
  %88 = getelementptr inbounds [400000 x i64], ptr @r, i64 0, i64 %.03754
  %89 = load i64, ptr %88, align 8, !tbaa !8
  %90 = load i64, ptr @N, align 8, !tbaa !8
  %91 = icmp slt i64 %89, %90
  %92 = zext i1 %91 to i64
  %93 = getelementptr inbounds [400000 x i64], ptr @ac, i64 0, i64 %.03754
  store i64 %92, ptr %93, align 8, !tbaa !8
  %94 = call noundef i64 @_Z1pxx(i64 noundef %.03754, i64 noundef %92)
  %95 = load i64, ptr @tot, align 8, !tbaa !8
  %96 = add nsw i64 %95, %94
  store i64 %96, ptr @tot, align 8, !tbaa !8
  %97 = add nuw nsw i64 %.03754, 1
  %98 = load i64, ptr @A, align 8, !tbaa !8
  %99 = icmp slt i64 %97, %98
  br i1 %99, label %.lr.ph56, label %.preheader40, !llvm.loop !20

._crit_edge59:                                    ; preds = %.lr.ph58, %.preheader40
  %.lcssa = phi i64 [ %86, %.preheader40 ], [ %107, %.lr.ph58 ]
  %100 = getelementptr inbounds %"struct.std::pair", ptr @q, i64 %.lcssa
  call void @_ZSt4sortIPSt4pairIxxEEvT_S3_(ptr noundef nonnull @q, ptr noundef nonnull %100)
  %101 = load i64, ptr @Q, align 8, !tbaa !8
  %102 = icmp sgt i64 %101, 0
  br i1 %102, label %.lr.ph66, label %._crit_edge69

.lr.ph58:                                         ; preds = %.preheader40, %.lr.ph58
  %.03657 = phi i64 [ %106, %.lr.ph58 ], [ 0, %.preheader40 ]
  %103 = getelementptr inbounds [200000 x %"struct.std::pair"], ptr @q, i64 0, i64 %.03657
  %104 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %103)
  %105 = getelementptr inbounds i8, ptr %103, i64 8
  store i64 %.03657, ptr %105, align 8, !tbaa !21
  %106 = add nuw nsw i64 %.03657, 1
  %107 = load i64, ptr @Q, align 8, !tbaa !8
  %108 = icmp slt i64 %106, %107
  br i1 %108, label %.lr.ph58, label %._crit_edge59, !llvm.loop !23

.preheader:                                       ; preds = %.critedge
  %109 = icmp sgt i64 %126, 0
  br i1 %109, label %.lr.ph68, label %._crit_edge69

.lr.ph66:                                         ; preds = %._crit_edge59, %.critedge
  %.03564 = phi i64 [ %125, %.critedge ], [ 0, %._crit_edge59 ]
  %110 = getelementptr inbounds [200000 x %"struct.std::pair"], ptr @q, i64 0, i64 %.03564
  %111 = load i64, ptr %110, align 16, !tbaa !24
  %112 = call noundef zeroext i1 @_ZNKSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt7greaterIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) @pq)
  br i1 %112, label %.critedge, label %.lr.ph62

.lr.ph62:                                         ; preds = %.lr.ph66, %115
  %113 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt7greaterIS1_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25) @pq)
  %114 = load i64, ptr %113, align 8, !tbaa !24
  %.not = icmp sgt i64 %114, %111
  br i1 %.not, label %.critedge, label %115

115:                                              ; preds = %.lr.ph62
  %116 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt7greaterIS1_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25) @pq)
  %117 = getelementptr inbounds i8, ptr %116, i64 8
  %118 = load i64, ptr %117, align 8, !tbaa !21
  call void @_ZNSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt7greaterIS1_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25) @pq)
  %119 = add nsw i64 %118, 1
  call void @_Z2unxx(i64 noundef %118, i64 noundef %119)
  %120 = call noundef zeroext i1 @_ZNKSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt7greaterIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) @pq)
  br i1 %120, label %.critedge, label %.lr.ph62, !llvm.loop !25

.critedge:                                        ; preds = %.lr.ph62, %115, %.lr.ph66
  %121 = load i64, ptr @tot, align 8, !tbaa !8
  %122 = getelementptr inbounds i8, ptr %110, i64 8
  %123 = load i64, ptr %122, align 8, !tbaa !21
  %124 = getelementptr inbounds [200000 x i64], ptr @ans, i64 0, i64 %123
  store i64 %121, ptr %124, align 8, !tbaa !8
  %125 = add nuw nsw i64 %.03564, 1
  %126 = load i64, ptr @Q, align 8, !tbaa !8
  %127 = icmp slt i64 %125, %126
  br i1 %127, label %.lr.ph66, label %.preheader, !llvm.loop !26

._crit_edge69:                                    ; preds = %.lr.ph68, %._crit_edge59, %.preheader
  ret i32 0

.lr.ph68:                                         ; preds = %.preheader, %.lr.ph68
  %.067 = phi i64 [ %132, %.lr.ph68 ], [ 0, %.preheader ]
  %128 = getelementptr inbounds [200000 x i64], ptr @ans, i64 0, i64 %.067
  %129 = load i64, ptr %128, align 8, !tbaa !8
  %130 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %129)
  %131 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %130, i8 noundef signext 10)
  %132 = add nuw nsw i64 %.067, 1
  %133 = load i64, ptr @Q, align 8, !tbaa !8
  %134 = icmp slt i64 %132, %133
  br i1 %134, label %.lr.ph68, label %._crit_edge69, !llvm.loop !27
}

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

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

; 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 #1 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: mustprogress nounwind uwtable
declare dso_local void @_ZSt4iotaIPxiEvT_S1_T0_(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZSt4sortIPxZ4mainE3$_0EvT_S2_T0_"(ptr noundef, ptr noundef) local_unnamed_addr #5

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt7greaterIS1_EE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(25), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt4pairIxxEC2IxRxTnNSt9enable_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 #0 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt7greaterIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt7greaterIS1_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueISt4pairIxxESt6vectorIS1_SaIS1_EESt7greaterIS1_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25)) 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 #1 align 2

attributes #0 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
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 = { "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 = { 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 = distinct !{!13, !12}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.unroll.disable"}
!16 = distinct !{!16, !12}
!17 = !{!18, !18, i64 0}
!18 = !{!"int", !10, i64 0}
!19 = distinct !{!19, !12}
!20 = distinct !{!20, !12}
!21 = !{!22, !9, i64 8}
!22 = !{!"_ZTSSt4pairIxxE", !9, i64 0, !9, i64 8}
!23 = distinct !{!23, !12}
!24 = !{!22, !9, i64 0}
!25 = distinct !{!25, !12}
!26 = distinct !{!26, !12}
!27 = distinct !{!27, !12}


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