; LLVM IR from tangjz/acm-icpc :: lydsy (3502)

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

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@tot = external dso_local global i32, align 4
@pL = external dso_local global [1000003 x i32], align 16
@pR = external dso_local global [1000003 x i32], align 16
@a = external dso_local global [1000003 x i64], align 16
@ans = external dso_local global i64, align 8
@Q = external dso_local global %"class.std::priority_queue", align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca %"struct.std::pair", align 8
  %6 = alloca i64, align 8
  %7 = alloca { i64, i32 }, align 8
  %8 = alloca %"struct.std::pair", align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca %"struct.std::pair", align 8
  %14 = alloca i64, align 8
  %15 = alloca { i64, i32 }, align 8
  store i32 0, ptr %1, align 4
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @tot, ptr noundef @m)
  br label %17

17:                                               ; preds = %46, %0
  %18 = load i32, ptr @tot, align 4, !tbaa !5
  %19 = add nsw i32 %18, -1
  store i32 %19, ptr @tot, align 4, !tbaa !5
  %20 = icmp ne i32 %18, 0
  br i1 %20, label %21, label %54

21:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  %22 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %2)
  %23 = load i32, ptr @n, align 4, !tbaa !5
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %25, label %43

25:                                               ; preds = %21
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = icmp sgt i32 %26, 0
  br i1 %27, label %28, label %34

28:                                               ; preds = %25
  %29 = load i32, ptr @n, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [1000003 x i64], ptr @a, i64 0, i64 %30
  %32 = load i64, ptr %31, align 8, !tbaa !9
  %33 = icmp slt i64 %32, 0
  br i1 %33, label %43, label %34

34:                                               ; preds = %28, %25
  %35 = load i32, ptr %2, align 4, !tbaa !5
  %36 = icmp slt i32 %35, 0
  br i1 %36, label %37, label %46

37:                                               ; preds = %34
  %38 = load i32, ptr @n, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [1000003 x i64], ptr @a, i64 0, i64 %39
  %41 = load i64, ptr %40, align 8, !tbaa !9
  %42 = icmp sgt i64 %41, 0
  br i1 %42, label %43, label %46

43:                                               ; preds = %37, %28, %21
  %44 = load i32, ptr @n, align 4, !tbaa !5
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr @n, align 4, !tbaa !5
  br label %46

46:                                               ; preds = %43, %37, %34
  %47 = load i32, ptr %2, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = load i32, ptr @n, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [1000003 x i64], ptr @a, i64 0, i64 %50
  %52 = load i64, ptr %51, align 8, !tbaa !9
  %53 = add nsw i64 %52, %48
  store i64 %53, ptr %51, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  br label %17, !llvm.loop !11

54:                                               ; preds = %17
  %55 = load i32, ptr @n, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [1000003 x i64], ptr @a, i64 0, i64 %56
  %58 = load i64, ptr %57, align 8, !tbaa !9
  %59 = icmp ne i64 %58, 0
  br i1 %59, label %63, label %60

60:                                               ; preds = %54
  %61 = load i32, ptr @n, align 4, !tbaa !5
  %62 = add nsw i32 %61, -1
  store i32 %62, ptr @n, align 4, !tbaa !5
  br label %63

63:                                               ; preds = %60, %54
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %64

64:                                               ; preds = %85, %63
  %65 = load i32, ptr %3, align 4, !tbaa !5
  %66 = load i32, ptr @n, align 4, !tbaa !5
  %67 = icmp sle i32 %65, %66
  br i1 %67, label %69, label %68

68:                                               ; preds = %64
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  br label %88

69:                                               ; preds = %64
  %70 = load i32, ptr %3, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [1000003 x i64], ptr @a, i64 0, i64 %71
  %73 = load i64, ptr %72, align 8, !tbaa !9
  %74 = icmp sgt i64 %73, 0
  br i1 %74, label %75, label %84

75:                                               ; preds = %69
  %76 = load i32, ptr %3, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [1000003 x i64], ptr @a, i64 0, i64 %77
  %79 = load i64, ptr %78, align 8, !tbaa !9
  %80 = load i64, ptr @ans, align 8, !tbaa !9
  %81 = add nsw i64 %80, %79
  store i64 %81, ptr @ans, align 8, !tbaa !9
  %82 = load i32, ptr @m, align 4, !tbaa !5
  %83 = add nsw i32 %82, -1
  store i32 %83, ptr @m, align 4, !tbaa !5
  br label %84

84:                                               ; preds = %75, %69
  br label %85

85:                                               ; preds = %84
  %86 = load i32, ptr %3, align 4, !tbaa !5
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr %3, align 4, !tbaa !5
  br label %64, !llvm.loop !13

88:                                               ; preds = %68
  %89 = load i32, ptr @m, align 4, !tbaa !5
  %90 = icmp sge i32 %89, 0
  br i1 %90, label %91, label %94

91:                                               ; preds = %88
  %92 = load i64, ptr @ans, align 8, !tbaa !9
  %93 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i64 noundef %92)
  store i32 0, ptr %1, align 4
  br label %240

94:                                               ; preds = %88
  store i32 0, ptr @pL, align 16, !tbaa !5
  store i32 1, ptr @pR, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %95

95:                                               ; preds = %118, %94
  %96 = load i32, ptr %4, align 4, !tbaa !5
  %97 = load i32, ptr @n, align 4, !tbaa !5
  %98 = icmp sle i32 %96, %97
  br i1 %98, label %100, label %99

99:                                               ; preds = %95
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  br label %121

100:                                              ; preds = %95
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  %101 = load i32, ptr %4, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [1000003 x i64], ptr @a, i64 0, i64 %102
  %104 = load i64, ptr %103, align 8, !tbaa !9
  %105 = call noundef i64 @_ZSt3absx(i64 noundef %104)
  %106 = sub nsw i64 0, %105
  store i64 %106, ptr %6, align 8, !tbaa !9
  %107 = call { i64, i32 } @_ZSt9make_pairIxRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 4 dereferenceable(4) %4)
  store { i64, i32 } %107, ptr %7, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %5, ptr align 8 %7, i64 12, i1 false)
  call void @_ZNSt14priority_queueISt4pairIxiESt6vectorIS1_SaIS1_EESt4lessIS1_EE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(25) @Q, ptr noundef nonnull align 8 dereferenceable(12) %5)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #7
  %108 = load i32, ptr %4, align 4, !tbaa !5
  %109 = sub nsw i32 %108, 1
  %110 = load i32, ptr %4, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [1000003 x i32], ptr @pL, i64 0, i64 %111
  store i32 %109, ptr %112, align 4, !tbaa !5
  %113 = load i32, ptr %4, align 4, !tbaa !5
  %114 = add nsw i32 %113, 1
  %115 = load i32, ptr %4, align 4, !tbaa !5
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds [1000003 x i32], ptr @pR, i64 0, i64 %116
  store i32 %114, ptr %117, align 4, !tbaa !5
  br label %118

118:                                              ; preds = %100
  %119 = load i32, ptr %4, align 4, !tbaa !5
  %120 = add nsw i32 %119, 1
  store i32 %120, ptr %4, align 4, !tbaa !5
  br label %95, !llvm.loop !14

121:                                              ; preds = %99
  %122 = load i32, ptr @n, align 4, !tbaa !5
  %123 = load i32, ptr @n, align 4, !tbaa !5
  %124 = add nsw i32 %123, 1
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [1000003 x i32], ptr @pL, i64 0, i64 %125
  store i32 %122, ptr %126, align 4, !tbaa !5
  %127 = load i32, ptr @n, align 4, !tbaa !5
  %128 = add nsw i32 %127, 1
  %129 = load i32, ptr @n, align 4, !tbaa !5
  %130 = add nsw i32 %129, 1
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds [1000003 x i32], ptr @pR, i64 0, i64 %131
  store i32 %128, ptr %132, align 4, !tbaa !5
  br label %133

133:                                              ; preds = %236, %234, %121
  %134 = load i32, ptr @m, align 4, !tbaa !5
  %135 = icmp slt i32 %134, 0
  br i1 %135, label %136, label %237

136:                                              ; preds = %133
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #7
  %137 = call noundef nonnull align 8 dereferenceable(12) ptr @_ZNKSt14priority_queueISt4pairIxiESt6vectorIS1_SaIS1_EESt4lessIS1_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %8, ptr align 8 %137, i64 16, i1 false)
  call void @_ZNSt14priority_queueISt4pairIxiESt6vectorIS1_SaIS1_EESt4lessIS1_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  %138 = getelementptr inbounds %"struct.std::pair", ptr %8, i32 0, i32 1
  %139 = load i32, ptr %138, align 8, !tbaa !15
  store i32 %139, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  %140 = load i32, ptr %9, align 4, !tbaa !5
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [1000003 x i32], ptr @pL, i64 0, i64 %141
  %143 = load i32, ptr %142, align 4, !tbaa !5
  store i32 %143, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  %144 = load i32, ptr %9, align 4, !tbaa !5
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds [1000003 x i32], ptr @pR, i64 0, i64 %145
  %147 = load i32, ptr %146, align 4, !tbaa !5
  store i32 %147, ptr %11, align 4, !tbaa !5
  %148 = load i32, ptr %9, align 4, !tbaa !5
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds [1000003 x i32], ptr @pR, i64 0, i64 %149
  %151 = load i32, ptr %150, align 4, !tbaa !5
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds [1000003 x i32], ptr @pL, i64 0, i64 %152
  %154 = load i32, ptr %153, align 4, !tbaa !5
  %155 = load i32, ptr %9, align 4, !tbaa !5
  %156 = icmp ne i32 %154, %155
  br i1 %156, label %170, label %157

157:                                              ; preds = %136
  %158 = load i32, ptr %9, align 4, !tbaa !5
  %159 = sext i32 %158 to i64
  %160 = getelementptr inbounds [1000003 x i64], ptr @a, i64 0, i64 %159
  %161 = load i64, ptr %160, align 8, !tbaa !9
  %162 = icmp sle i64 %161, 0
  br i1 %162, label %163, label %171

163:                                              ; preds = %157
  %164 = load i32, ptr %10, align 4, !tbaa !5
  %165 = icmp slt i32 %164, 1
  br i1 %165, label %170, label %166

166:                                              ; preds = %163
  %167 = load i32, ptr %11, align 4, !tbaa !5
  %168 = load i32, ptr @n, align 4, !tbaa !5
  %169 = icmp sgt i32 %167, %168
  br i1 %169, label %170, label %171

170:                                              ; preds = %166, %163, %136
  store i32 10, ptr %12, align 4
  br label %234, !llvm.loop !17

171:                                              ; preds = %166, %157
  %172 = getelementptr inbounds %"struct.std::pair", ptr %8, i32 0, i32 0
  %173 = load i64, ptr %172, align 8, !tbaa !18
  %174 = load i64, ptr @ans, align 8, !tbaa !9
  %175 = add nsw i64 %174, %173
  store i64 %175, ptr @ans, align 8, !tbaa !9
  %176 = load i32, ptr @m, align 4, !tbaa !5
  %177 = add nsw i32 %176, 1
  store i32 %177, ptr @m, align 4, !tbaa !5
  %178 = load i32, ptr %10, align 4, !tbaa !5
  %179 = icmp sge i32 %178, 1
  br i1 %179, label %180, label %206

180:                                              ; preds = %171
  %181 = load i32, ptr %11, align 4, !tbaa !5
  %182 = load i32, ptr @n, align 4, !tbaa !5
  %183 = icmp sle i32 %181, %182
  br i1 %183, label %184, label %206

184:                                              ; preds = %180
  %185 = load i32, ptr %10, align 4, !tbaa !5
  %186 = sext i32 %185 to i64
  %187 = getelementptr inbounds [1000003 x i64], ptr @a, i64 0, i64 %186
  %188 = load i64, ptr %187, align 8, !tbaa !9
  %189 = load i32, ptr %11, align 4, !tbaa !5
  %190 = sext i32 %189 to i64
  %191 = getelementptr inbounds [1000003 x i64], ptr @a, i64 0, i64 %190
  %192 = load i64, ptr %191, align 8, !tbaa !9
  %193 = add nsw i64 %188, %192
  %194 = load i32, ptr %9, align 4, !tbaa !5
  %195 = sext i32 %194 to i64
  %196 = getelementptr inbounds [1000003 x i64], ptr @a, i64 0, i64 %195
  %197 = load i64, ptr %196, align 8, !tbaa !9
  %198 = add nsw i64 %197, %193
  store i64 %198, ptr %196, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  %199 = load i32, ptr %9, align 4, !tbaa !5
  %200 = sext i32 %199 to i64
  %201 = getelementptr inbounds [1000003 x i64], ptr @a, i64 0, i64 %200
  %202 = load i64, ptr %201, align 8, !tbaa !9
  %203 = call noundef i64 @_ZSt3absx(i64 noundef %202)
  %204 = sub nsw i64 0, %203
  store i64 %204, ptr %14, align 8, !tbaa !9
  %205 = call { i64, i32 } @_ZSt9make_pairIxRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8) %14, ptr noundef nonnull align 4 dereferenceable(4) %9)
  store { i64, i32 } %205, ptr %15, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %13, ptr align 8 %15, i64 12, i1 false)
  call void @_ZNSt14priority_queueISt4pairIxiESt6vectorIS1_SaIS1_EESt4lessIS1_EE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(25) @Q, ptr noundef nonnull align 8 dereferenceable(12) %13)
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #7
  br label %206

206:                                              ; preds = %184, %180, %171
  %207 = load i32, ptr %10, align 4, !tbaa !5
  %208 = sext i32 %207 to i64
  %209 = getelementptr inbounds [1000003 x i32], ptr @pL, i64 0, i64 %208
  %210 = load i32, ptr %209, align 4, !tbaa !5
  %211 = load i32, ptr %9, align 4, !tbaa !5
  %212 = sext i32 %211 to i64
  %213 = getelementptr inbounds [1000003 x i32], ptr @pL, i64 0, i64 %212
  store i32 %210, ptr %213, align 4, !tbaa !5
  %214 = load i32, ptr %11, align 4, !tbaa !5
  %215 = sext i32 %214 to i64
  %216 = getelementptr inbounds [1000003 x i32], ptr @pR, i64 0, i64 %215
  %217 = load i32, ptr %216, align 4, !tbaa !5
  %218 = load i32, ptr %9, align 4, !tbaa !5
  %219 = sext i32 %218 to i64
  %220 = getelementptr inbounds [1000003 x i32], ptr @pR, i64 0, i64 %219
  store i32 %217, ptr %220, align 4, !tbaa !5
  %221 = load i32, ptr %9, align 4, !tbaa !5
  %222 = load i32, ptr %10, align 4, !tbaa !5
  %223 = sext i32 %222 to i64
  %224 = getelementptr inbounds [1000003 x i32], ptr @pL, i64 0, i64 %223
  %225 = load i32, ptr %224, align 4, !tbaa !5
  %226 = sext i32 %225 to i64
  %227 = getelementptr inbounds [1000003 x i32], ptr @pR, i64 0, i64 %226
  store i32 %221, ptr %227, align 4, !tbaa !5
  %228 = load i32, ptr %11, align 4, !tbaa !5
  %229 = sext i32 %228 to i64
  %230 = getelementptr inbounds [1000003 x i32], ptr @pR, i64 0, i64 %229
  %231 = load i32, ptr %230, align 4, !tbaa !5
  %232 = sext i32 %231 to i64
  %233 = getelementptr inbounds [1000003 x i32], ptr @pL, i64 0, i64 %232
  store i32 %221, ptr %233, align 4, !tbaa !5
  store i32 0, ptr %12, align 4
  br label %234

234:                                              ; preds = %206, %170
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #7
  %235 = load i32, ptr %12, align 4
  switch i32 %235, label %242 [
    i32 0, label %236
    i32 10, label %133
  ]

236:                                              ; preds = %234
  br label %133, !llvm.loop !17

237:                                              ; preds = %133
  %238 = load i64, ptr @ans, align 8, !tbaa !9
  %239 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i64 noundef %238)
  store i32 0, ptr %1, align 4
  br label %240

240:                                              ; preds = %237, %91
  %241 = load i32, ptr %1, align 4
  ret i32 %241

242:                                              ; preds = %234
  unreachable
}

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

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local { i64, i32 } @_ZSt9make_pairIxRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4)) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZSt3absx(i64 noundef) #4

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(12) ptr @_ZNKSt14priority_queueISt4pairIxiESt6vectorIS1_SaIS1_EESt4lessIS1_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25)) #6 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueISt4pairIxiESt6vectorIS1_SaIS1_EESt4lessIS1_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25)) #3 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 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 = { 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 #5 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = !{!16, !6, i64 8}
!16 = !{!"_ZTSSt4pairIxiE", !10, i64 0, !6, i64 8}
!17 = distinct !{!17, !12}
!18 = !{!16, !10, i64 0}


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

@n = external dso_local local_unnamed_addr global i32, align 4
@m = external dso_local global i32, align 4
@tot = external dso_local global i32, align 4
@pL = external dso_local local_unnamed_addr global [1000003 x i32], align 16
@pR = external dso_local local_unnamed_addr global [1000003 x i32], align 16
@a = external dso_local local_unnamed_addr global [1000003 x i64], align 16
@ans = external dso_local local_unnamed_addr global i64, align 8
@Q = external dso_local global %"class.std::priority_queue", align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca %"struct.std::pair", align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca %"struct.std::pair", align 8
  %7 = alloca i64, align 8
  %8 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @tot, ptr noundef nonnull @m)
  %9 = load i32, ptr @tot, align 4, !tbaa !5
  %10 = add nsw i32 %9, -1
  store i32 %10, ptr @tot, align 4, !tbaa !5
  %.not31 = icmp eq i32 %9, 0
  br i1 %.not31, label %.._crit_edge_crit_edge, label %.lr.ph

.._crit_edge_crit_edge:                           ; preds = %0
  %.pre47 = load i32, ptr @n, align 4, !tbaa !5
  %.phi.trans.insert = sext i32 %.pre47 to i64
  %.phi.trans.insert48 = getelementptr inbounds [1000003 x i64], ptr @a, i64 0, i64 %.phi.trans.insert
  %.pre49 = load i64, ptr %.phi.trans.insert48, align 8, !tbaa !9
  br label %._crit_edge

.lr.ph:                                           ; preds = %0, %.thread
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  %11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %1)
  %12 = load i32, ptr @n, align 4, !tbaa !5
  %.not28 = icmp eq i32 %12, 0
  %.pre.pre = load i32, ptr %1, align 4, !tbaa !5
  br i1 %.not28, label %27, label %13

13:                                               ; preds = %.lr.ph
  %14 = icmp sgt i32 %.pre.pre, 0
  br i1 %14, label %15, label %20

15:                                               ; preds = %13
  %16 = sext i32 %12 to i64
  %17 = getelementptr inbounds [1000003 x i64], ptr @a, i64 0, i64 %16
  %18 = load i64, ptr %17, align 8, !tbaa !9
  %19 = icmp slt i64 %18, 0
  br i1 %19, label %27, label %.thread

20:                                               ; preds = %13
  %21 = icmp slt i32 %.pre.pre, 0
  br i1 %21, label %22, label %.thread

22:                                               ; preds = %20
  %23 = sext i32 %12 to i64
  %24 = getelementptr inbounds [1000003 x i64], ptr @a, i64 0, i64 %23
  %25 = load i64, ptr %24, align 8, !tbaa !9
  %26 = icmp sgt i64 %25, 0
  br i1 %26, label %27, label %.thread

27:                                               ; preds = %22, %15, %.lr.ph
  %28 = add nsw i32 %12, 1
  store i32 %28, ptr @n, align 4, !tbaa !5
  br label %.thread

.thread:                                          ; preds = %15, %27, %22, %20
  %29 = phi i32 [ %12, %15 ], [ %28, %27 ], [ %12, %22 ], [ %12, %20 ]
  %30 = sext i32 %.pre.pre to i64
  %31 = sext i32 %29 to i64
  %32 = getelementptr inbounds [1000003 x i64], ptr @a, i64 0, i64 %31
  %33 = load i64, ptr %32, align 8, !tbaa !9
  %34 = add nsw i64 %33, %30
  store i64 %34, ptr %32, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  %35 = load i32, ptr @tot, align 4, !tbaa !5
  %36 = add nsw i32 %35, -1
  store i32 %36, ptr @tot, align 4, !tbaa !5
  %.not = icmp eq i32 %35, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11

._crit_edge:                                      ; preds = %.thread, %.._crit_edge_crit_edge
  %37 = phi i64 [ %.pre49, %.._crit_edge_crit_edge ], [ %34, %.thread ]
  %38 = phi i32 [ %.pre47, %.._crit_edge_crit_edge ], [ %29, %.thread ]
  %.not23 = icmp eq i64 %37, 0
  br i1 %.not23, label %39, label %41

39:                                               ; preds = %._crit_edge
  %40 = add nsw i32 %38, -1
  store i32 %40, ptr @n, align 4, !tbaa !5
  br label %41

41:                                               ; preds = %39, %._crit_edge
  %42 = phi i32 [ %40, %39 ], [ %38, %._crit_edge ]
  %ans.promoted = load i64, ptr @ans, align 8, !tbaa !9
  %m.promoted = load i32, ptr @m, align 4, !tbaa !5
  %.not2432 = icmp slt i32 %42, 1
  br i1 %.not2432, label %._crit_edge36.thread, label %.lr.ph35.preheader

.lr.ph35.preheader:                               ; preds = %41
  %43 = zext nneg i32 %42 to i64
  %xtraiter = and i64 %43, 1
  %44 = icmp eq i32 %42, 1
  br i1 %44, label %._crit_edge36.unr-lcssa, label %.lr.ph35.preheader.new

.lr.ph35.preheader.new:                           ; preds = %.lr.ph35.preheader
  %unroll_iter = and i64 %43, 2147483646
  br label %.lr.ph35

._crit_edge36.unr-lcssa:                          ; preds = %69, %.lr.ph35.preheader
  %.lcssa66.ph = phi i32 [ poison, %.lr.ph35.preheader ], [ %70, %69 ]
  %.lcssa65.ph = phi i64 [ poison, %.lr.ph35.preheader ], [ %71, %69 ]
  %indvars.iv.unr = phi i64 [ 1, %.lr.ph35.preheader ], [ %indvars.iv.next.1, %69 ]
  %.unr = phi i64 [ %ans.promoted, %.lr.ph35.preheader ], [ %71, %69 ]
  %.unr69 = phi i32 [ %m.promoted, %.lr.ph35.preheader ], [ %70, %69 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge36, label %.lr.ph35.epil

.lr.ph35.epil:                                    ; preds = %._crit_edge36.unr-lcssa
  %45 = getelementptr inbounds [1000003 x i64], ptr @a, i64 0, i64 %indvars.iv.unr
  %46 = load i64, ptr %45, align 8, !tbaa !9
  %47 = icmp sgt i64 %46, 0
  br i1 %47, label %48, label %._crit_edge36

48:                                               ; preds = %.lr.ph35.epil
  %49 = add nsw i64 %.unr, %46
  store i64 %49, ptr @ans, align 8, !tbaa !9
  %50 = add nsw i32 %.unr69, -1
  store i32 %50, ptr @m, align 4, !tbaa !5
  br label %._crit_edge36

._crit_edge36:                                    ; preds = %.lr.ph35.epil, %48, %._crit_edge36.unr-lcssa
  %.lcssa66 = phi i32 [ %.lcssa66.ph, %._crit_edge36.unr-lcssa ], [ %.unr69, %.lr.ph35.epil ], [ %50, %48 ]
  %.lcssa65 = phi i64 [ %.lcssa65.ph, %._crit_edge36.unr-lcssa ], [ %.unr, %.lr.ph35.epil ], [ %49, %48 ]
  %51 = icmp sgt i32 %.lcssa66, -1
  br i1 %51, label %147, label %72

._crit_edge36.thread:                             ; preds = %41
  %52 = icmp sgt i32 %m.promoted, -1
  br i1 %52, label %147, label %.thread55

.thread55:                                        ; preds = %._crit_edge36.thread
  store i32 0, ptr @pL, align 16, !tbaa !5
  store i32 1, ptr @pR, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  br label %._crit_edge41.thread

.lr.ph35:                                         ; preds = %69, %.lr.ph35.preheader.new
  %indvars.iv = phi i64 [ 1, %.lr.ph35.preheader.new ], [ %indvars.iv.next.1, %69 ]
  %53 = phi i64 [ %ans.promoted, %.lr.ph35.preheader.new ], [ %71, %69 ]
  %54 = phi i32 [ %m.promoted, %.lr.ph35.preheader.new ], [ %70, %69 ]
  %niter = phi i64 [ 0, %.lr.ph35.preheader.new ], [ %niter.next.1, %69 ]
  %55 = getelementptr inbounds [1000003 x i64], ptr @a, i64 0, i64 %indvars.iv
  %56 = load i64, ptr %55, align 8, !tbaa !9
  %57 = icmp sgt i64 %56, 0
  br i1 %57, label %58, label %.lr.ph35.1

58:                                               ; preds = %.lr.ph35
  %59 = add nsw i64 %53, %56
  store i64 %59, ptr @ans, align 8, !tbaa !9
  %60 = add nsw i32 %54, -1
  store i32 %60, ptr @m, align 4, !tbaa !5
  br label %.lr.ph35.1

.lr.ph35.1:                                       ; preds = %.lr.ph35, %58
  %61 = phi i32 [ %54, %.lr.ph35 ], [ %60, %58 ]
  %62 = phi i64 [ %53, %.lr.ph35 ], [ %59, %58 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %63 = getelementptr inbounds [1000003 x i64], ptr @a, i64 0, i64 %indvars.iv.next
  %64 = load i64, ptr %63, align 8, !tbaa !9
  %65 = icmp sgt i64 %64, 0
  br i1 %65, label %66, label %69

66:                                               ; preds = %.lr.ph35.1
  %67 = add nsw i64 %62, %64
  store i64 %67, ptr @ans, align 8, !tbaa !9
  %68 = add nsw i32 %61, -1
  store i32 %68, ptr @m, align 4, !tbaa !5
  br label %69

69:                                               ; preds = %66, %.lr.ph35.1
  %70 = phi i32 [ %61, %.lr.ph35.1 ], [ %68, %66 ]
  %71 = phi i64 [ %62, %.lr.ph35.1 ], [ %67, %66 ]
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge36.unr-lcssa, label %.lr.ph35, !llvm.loop !13

72:                                               ; preds = %._crit_edge36
  store i32 0, ptr @pL, align 16, !tbaa !5
  store i32 1, ptr @pR, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  store i32 1, ptr %2, align 4, !tbaa !5
  br i1 %.not2432, label %._crit_edge41.thread, label %.lr.ph40

.lr.ph40:                                         ; preds = %72
  %.sroa.214.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 8
  br label %82

._crit_edge41.thread:                             ; preds = %72, %.thread55
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  %73 = add nsw i32 %42, 1
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [1000003 x i32], ptr @pL, i64 0, i64 %74
  store i32 %42, ptr %75, align 4, !tbaa !5
  %76 = getelementptr inbounds [1000003 x i32], ptr @pR, i64 0, i64 %74
  store i32 %73, ptr %76, align 4, !tbaa !5
  br label %.lr.ph43

._crit_edge41:                                    ; preds = %82
  %.pre50 = load i32, ptr @m, align 4, !tbaa !5
  %77 = icmp slt i32 %.pre50, 0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  %78 = add nsw i32 %95, 1
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [1000003 x i32], ptr @pL, i64 0, i64 %79
  store i32 %95, ptr %80, align 4, !tbaa !5
  %81 = getelementptr inbounds [1000003 x i32], ptr @pR, i64 0, i64 %79
  store i32 %78, ptr %81, align 4, !tbaa !5
  br i1 %77, label %.lr.ph43, label %._crit_edge44

.lr.ph43:                                         ; preds = %._crit_edge41.thread, %._crit_edge41
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %6, i64 8
  br label %96

82:                                               ; preds = %.lr.ph40, %82
  %storemerge38 = phi i32 [ 1, %.lr.ph40 ], [ %93, %82 ]
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  %83 = sext i32 %storemerge38 to i64
  %84 = getelementptr inbounds [1000003 x i64], ptr @a, i64 0, i64 %83
  %85 = load i64, ptr %84, align 8, !tbaa !9
  %86 = call noundef i64 @_ZSt3absx(i64 noundef %85)
  %87 = sub nsw i64 0, %86
  store i64 %87, ptr %4, align 8, !tbaa !9
  %88 = call { i64, i32 } @_ZSt9make_pairIxRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %.fca.0.extract11 = extractvalue { i64, i32 } %88, 0
  %.fca.1.extract12 = extractvalue { i64, i32 } %88, 1
  store i64 %.fca.0.extract11, ptr %3, align 8
  store i32 %.fca.1.extract12, ptr %.sroa.214.0..sroa_idx, align 8
  call void @_ZNSt14priority_queueISt4pairIxiESt6vectorIS1_SaIS1_EESt4lessIS1_EE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(25) @Q, ptr noundef nonnull align 8 dereferenceable(12) %3)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #6
  %89 = load i32, ptr %2, align 4, !tbaa !5
  %90 = add nsw i32 %89, -1
  %91 = sext i32 %89 to i64
  %92 = getelementptr inbounds [1000003 x i32], ptr @pL, i64 0, i64 %91
  store i32 %90, ptr %92, align 4, !tbaa !5
  %93 = add nsw i32 %89, 1
  %94 = getelementptr inbounds [1000003 x i32], ptr @pR, i64 0, i64 %91
  store i32 %93, ptr %94, align 4, !tbaa !5
  store i32 %93, ptr %2, align 4, !tbaa !5
  %95 = load i32, ptr @n, align 4, !tbaa !5
  %.not25.not = icmp slt i32 %89, %95
  br i1 %.not25.not, label %82, label %._crit_edge41, !llvm.loop !14

96:                                               ; preds = %.lr.ph43, %143
  %97 = call noundef nonnull align 8 dereferenceable(12) ptr @_ZNKSt14priority_queueISt4pairIxiESt6vectorIS1_SaIS1_EESt4lessIS1_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %.sroa.010.0.copyload = load i64, ptr %97, align 8
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %97, i64 8
  %.sroa.4.0.copyload = load i32, ptr %.sroa.4.0..sroa_idx, align 8
  call void @_ZNSt14priority_queueISt4pairIxiESt6vectorIS1_SaIS1_EESt4lessIS1_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #6
  store i32 %.sroa.4.0.copyload, ptr %5, align 4, !tbaa !5
  %98 = sext i32 %.sroa.4.0.copyload to i64
  %99 = getelementptr inbounds [1000003 x i32], ptr @pL, i64 0, i64 %98
  %100 = load i32, ptr %99, align 4, !tbaa !5
  %101 = getelementptr inbounds [1000003 x i32], ptr @pR, i64 0, i64 %98
  %102 = load i32, ptr %101, align 4, !tbaa !5
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [1000003 x i32], ptr @pL, i64 0, i64 %103
  %105 = load i32, ptr %104, align 4, !tbaa !5
  %.not26 = icmp eq i32 %105, %.sroa.4.0.copyload
  br i1 %.not26, label %106, label %143, !llvm.loop !15

106:                                              ; preds = %96
  %107 = getelementptr inbounds [1000003 x i64], ptr @a, i64 0, i64 %98
  %108 = load i64, ptr %107, align 8, !tbaa !9
  %109 = icmp slt i64 %108, 1
  %.pre51 = load i32, ptr @n, align 4
  br i1 %109, label %110, label %._crit_edge54

110:                                              ; preds = %106
  %111 = icmp slt i32 %100, 1
  %112 = icmp sgt i32 %102, %.pre51
  %or.cond = select i1 %111, i1 true, i1 %112
  br i1 %or.cond, label %143, label %._crit_edge54, !llvm.loop !15

._crit_edge54:                                    ; preds = %106, %110
  %113 = load i64, ptr @ans, align 8, !tbaa !9
  %114 = add nsw i64 %113, %.sroa.010.0.copyload
  store i64 %114, ptr @ans, align 8, !tbaa !9
  %115 = load i32, ptr @m, align 4, !tbaa !5
  %116 = add nsw i32 %115, 1
  store i32 %116, ptr @m, align 4, !tbaa !5
  %117 = icmp slt i32 %100, 1
  %.not27 = icmp sgt i32 %102, %.pre51
  %or.cond30 = select i1 %117, i1 true, i1 %.not27
  br i1 %or.cond30, label %129, label %118

118:                                              ; preds = %._crit_edge54
  %119 = zext nneg i32 %100 to i64
  %120 = getelementptr inbounds [1000003 x i64], ptr @a, i64 0, i64 %119
  %121 = load i64, ptr %120, align 8, !tbaa !9
  %122 = getelementptr inbounds [1000003 x i64], ptr @a, i64 0, i64 %103
  %123 = load i64, ptr %122, align 8, !tbaa !9
  %124 = add i64 %121, %108
  %125 = add i64 %124, %123
  store i64 %125, ptr %107, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #6
  %126 = call noundef i64 @_ZSt3absx(i64 noundef %125)
  %127 = sub nsw i64 0, %126
  store i64 %127, ptr %7, align 8, !tbaa !9
  %128 = call { i64, i32 } @_ZSt9make_pairIxRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %.fca.0.extract = extractvalue { i64, i32 } %128, 0
  %.fca.1.extract = extractvalue { i64, i32 } %128, 1
  store i64 %.fca.0.extract, ptr %6, align 8
  store i32 %.fca.1.extract, ptr %.sroa.2.0..sroa_idx, align 8
  call void @_ZNSt14priority_queueISt4pairIxiESt6vectorIS1_SaIS1_EESt4lessIS1_EE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(25) @Q, ptr noundef nonnull align 8 dereferenceable(12) %6)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #6
  %.pre52 = load i32, ptr %5, align 4, !tbaa !5
  %.pre = sext i32 %.pre52 to i64
  br label %129

129:                                              ; preds = %118, %._crit_edge54
  %.pre-phi53 = phi i64 [ %.pre, %118 ], [ %98, %._crit_edge54 ]
  %130 = phi i32 [ %.pre52, %118 ], [ %.sroa.4.0.copyload, %._crit_edge54 ]
  %131 = sext i32 %100 to i64
  %132 = getelementptr inbounds [1000003 x i32], ptr @pL, i64 0, i64 %131
  %133 = load i32, ptr %132, align 4, !tbaa !5
  %134 = getelementptr inbounds [1000003 x i32], ptr @pL, i64 0, i64 %.pre-phi53
  store i32 %133, ptr %134, align 4, !tbaa !5
  %135 = getelementptr inbounds [1000003 x i32], ptr @pR, i64 0, i64 %103
  %136 = load i32, ptr %135, align 4, !tbaa !5
  %137 = getelementptr inbounds [1000003 x i32], ptr @pR, i64 0, i64 %.pre-phi53
  store i32 %136, ptr %137, align 4, !tbaa !5
  %138 = sext i32 %133 to i64
  %139 = getelementptr inbounds [1000003 x i32], ptr @pR, i64 0, i64 %138
  store i32 %130, ptr %139, align 4, !tbaa !5
  %140 = load i32, ptr %135, align 4, !tbaa !5
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [1000003 x i32], ptr @pL, i64 0, i64 %141
  store i32 %130, ptr %142, align 4, !tbaa !5
  br label %143

143:                                              ; preds = %96, %110, %129
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #6
  %144 = load i32, ptr @m, align 4, !tbaa !5
  %145 = icmp slt i32 %144, 0
  br i1 %145, label %96, label %._crit_edge44

._crit_edge44:                                    ; preds = %143, %._crit_edge41
  %146 = load i64, ptr @ans, align 8, !tbaa !9
  br label %147

147:                                              ; preds = %._crit_edge36, %._crit_edge36.thread, %._crit_edge44
  %.sink = phi i64 [ %146, %._crit_edge44 ], [ %ans.promoted, %._crit_edge36.thread ], [ %.lcssa65, %._crit_edge36 ]
  %148 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i64 noundef %.sink)
  ret i32 0
}

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

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local { i64, i32 } @_ZSt9make_pairIxRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZSt3absx(i64 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(12) ptr @_ZNKSt14priority_queueISt4pairIxiESt6vectorIS1_SaIS1_EESt4lessIS1_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25)) local_unnamed_addr #5 align 2

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}


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