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

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

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@a = external dso_local global [100001 x i32], align 16
@pL = external dso_local global [100001 x i32], align 16
@pR = external dso_local global [100001 x i32], align 16
@ans = external dso_local global i32, align 4
@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 [4 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 %"struct.std::pair", align 4
  %5 = alloca i32, align 4
  %6 = alloca %"struct.std::pair", align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %11

11:                                               ; preds = %31, %0
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = load i32, ptr @n, align 4, !tbaa !5
  %14 = icmp sle i32 %12, %13
  br i1 %14, label %16, label %15

15:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %34

16:                                               ; preds = %11
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds i32, ptr @a, i64 %18
  %20 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %19)
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = sub nsw i32 %21, 1
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [100001 x i32], ptr @pL, i64 0, i64 %24
  store i32 %22, ptr %25, align 4, !tbaa !5
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = sub nsw i32 %27, 1
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [100001 x i32], ptr @pR, i64 0, i64 %29
  store i32 %26, ptr %30, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %16
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %2, align 4, !tbaa !5
  br label %11, !llvm.loop !9

34:                                               ; preds = %15
  store i32 0, ptr @pL, align 16, !tbaa !5
  %35 = load i32, ptr @n, align 4, !tbaa !5
  %36 = load i32, ptr @n, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [100001 x i32], ptr @pR, i64 0, i64 %37
  store i32 %35, ptr %38, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %39

39:                                               ; preds = %59, %34
  %40 = load i32, ptr %3, align 4, !tbaa !5
  %41 = load i32, ptr @n, align 4, !tbaa !5
  %42 = icmp slt i32 %40, %41
  br i1 %42, label %44, label %43

43:                                               ; preds = %39
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %62

44:                                               ; preds = %39
  %45 = load i32, ptr %3, align 4, !tbaa !5
  %46 = add nsw i32 %45, 1
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %50 = load i32, ptr %3, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = sub nsw i32 %53, %49
  store i32 %54, ptr %52, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %55 = load i32, ptr %3, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %56
  %58 = call i64 @_ZSt9make_pairIRiS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %57, ptr noundef nonnull align 4 dereferenceable(4) %3)
  store i64 %58, ptr %4, align 4
  call void @_ZNSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt4lessIS1_EE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(25) @Q, ptr noundef nonnull align 4 dereferenceable(8) %4)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  br label %59

59:                                               ; preds = %44
  %60 = load i32, ptr %3, align 4, !tbaa !5
  %61 = add nsw i32 %60, 1
  store i32 %61, ptr %3, align 4, !tbaa !5
  br label %39, !llvm.loop !11

62:                                               ; preds = %43
  %63 = load i32, ptr @n, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %64
  store i32 -1061109567, ptr %65, align 4, !tbaa !5
  store i32 -1061109567, ptr @a, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %66

66:                                               ; preds = %178, %62
  %67 = load i32, ptr %5, align 4, !tbaa !5
  %68 = load i32, ptr @m, align 4, !tbaa !5
  %69 = icmp slt i32 %67, %68
  br i1 %69, label %71, label %70

70:                                               ; preds = %66
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %181

71:                                               ; preds = %66
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  call void @_ZNSt4pairIiiEC2IiiTnNSt9enable_ifIXsr6__and_ISt37__is_implicitly_default_constructibleIT_ES3_IT0_EEE5valueEbE4typeELb1EEEv(ptr noundef nonnull align 4 dereferenceable(8) %6)
  br label %72

72:                                               ; preds = %99, %71
  %73 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNKSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt4lessIS1_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %74 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSERKS0_(ptr noundef nonnull align 4 dereferenceable(8) %6, ptr noundef nonnull align 4 dereferenceable(8) %73)
  call void @_ZNSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt4lessIS1_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  br label %75

75:                                               ; preds = %72
  %76 = getelementptr inbounds %"struct.std::pair", ptr %6, i32 0, i32 1
  %77 = load i32, ptr %76, align 4, !tbaa !12
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [100001 x i32], ptr @pR, i64 0, i64 %78
  %80 = load i32, ptr %79, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [100001 x i32], ptr @pL, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = getelementptr inbounds %"struct.std::pair", ptr %6, i32 0, i32 1
  %85 = load i32, ptr %84, align 4, !tbaa !12
  %86 = icmp eq i32 %83, %85
  br i1 %86, label %87, label %99

87:                                               ; preds = %75
  %88 = getelementptr inbounds %"struct.std::pair", ptr %6, i32 0, i32 1
  %89 = load i32, ptr %88, align 4, !tbaa !12
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [100001 x i32], ptr @pL, i64 0, i64 %90
  %92 = load i32, ptr %91, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [100001 x i32], ptr @pR, i64 0, i64 %93
  %95 = load i32, ptr %94, align 4, !tbaa !5
  %96 = getelementptr inbounds %"struct.std::pair", ptr %6, i32 0, i32 1
  %97 = load i32, ptr %96, align 4, !tbaa !12
  %98 = icmp eq i32 %95, %97
  br label %99

99:                                               ; preds = %87, %75
  %100 = phi i1 [ false, %75 ], [ %98, %87 ]
  %101 = xor i1 %100, true
  br i1 %101, label %72, label %102, !llvm.loop !14

102:                                              ; preds = %99
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %103 = getelementptr inbounds %"struct.std::pair", ptr %6, i32 0, i32 1
  %104 = load i32, ptr %103, align 4, !tbaa !12
  store i32 %104, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %105 = load i32, ptr %7, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [100001 x i32], ptr @pL, i64 0, i64 %106
  %108 = load i32, ptr %107, align 4, !tbaa !5
  store i32 %108, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %109 = load i32, ptr %7, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [100001 x i32], ptr @pR, i64 0, i64 %110
  %112 = load i32, ptr %111, align 4, !tbaa !5
  store i32 %112, ptr %9, align 4, !tbaa !5
  %113 = getelementptr inbounds %"struct.std::pair", ptr %6, i32 0, i32 0
  %114 = load i32, ptr %113, align 4, !tbaa !15
  %115 = sub nsw i32 0, %114
  %116 = load i32, ptr @ans, align 4, !tbaa !5
  %117 = add nsw i32 %116, %115
  store i32 %117, ptr @ans, align 4, !tbaa !5
  %118 = load i32, ptr %8, align 4, !tbaa !5
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %119
  %121 = load i32, ptr %120, align 4, !tbaa !5
  %122 = icmp ne i32 %121, -1061109567
  br i1 %122, label %123, label %146

123:                                              ; preds = %102
  %124 = load i32, ptr %9, align 4, !tbaa !5
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %125
  %127 = load i32, ptr %126, align 4, !tbaa !5
  %128 = icmp ne i32 %127, -1061109567
  br i1 %128, label %129, label %146

129:                                              ; preds = %123
  %130 = load i32, ptr %8, align 4, !tbaa !5
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %131
  %133 = load i32, ptr %132, align 4, !tbaa !5
  %134 = load i32, ptr %9, align 4, !tbaa !5
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %135
  %137 = load i32, ptr %136, align 4, !tbaa !5
  %138 = add nsw i32 %133, %137
  %139 = getelementptr inbounds %"struct.std::pair", ptr %6, i32 0, i32 0
  %140 = load i32, ptr %139, align 4, !tbaa !15
  %141 = sub nsw i32 %138, %140
  %142 = load i32, ptr %7, align 4, !tbaa !5
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %143
  store i32 %141, ptr %144, align 4, !tbaa !5
  %145 = getelementptr inbounds %"struct.std::pair", ptr %6, i32 0, i32 0
  store i32 %141, ptr %145, align 4, !tbaa !15
  call void @_ZNSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt4lessIS1_EE4pushERKS1_(ptr noundef nonnull align 8 dereferenceable(25) @Q, ptr noundef nonnull align 4 dereferenceable(8) %6)
  br label %150

146:                                              ; preds = %123, %102
  %147 = load i32, ptr %7, align 4, !tbaa !5
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %148
  store i32 -1061109567, ptr %149, align 4, !tbaa !5
  br label %150

150:                                              ; preds = %146, %129
  %151 = load i32, ptr %8, align 4, !tbaa !5
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds [100001 x i32], ptr @pL, i64 0, i64 %152
  %154 = load i32, ptr %153, align 4, !tbaa !5
  %155 = load i32, ptr %7, align 4, !tbaa !5
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds [100001 x i32], ptr @pL, i64 0, i64 %156
  store i32 %154, ptr %157, align 4, !tbaa !5
  %158 = load i32, ptr %9, align 4, !tbaa !5
  %159 = sext i32 %158 to i64
  %160 = getelementptr inbounds [100001 x i32], ptr @pR, i64 0, i64 %159
  %161 = load i32, ptr %160, align 4, !tbaa !5
  %162 = load i32, ptr %7, align 4, !tbaa !5
  %163 = sext i32 %162 to i64
  %164 = getelementptr inbounds [100001 x i32], ptr @pR, i64 0, i64 %163
  store i32 %161, ptr %164, align 4, !tbaa !5
  %165 = load i32, ptr %7, align 4, !tbaa !5
  %166 = load i32, ptr %9, align 4, !tbaa !5
  %167 = sext i32 %166 to i64
  %168 = getelementptr inbounds [100001 x i32], ptr @pR, i64 0, i64 %167
  %169 = load i32, ptr %168, align 4, !tbaa !5
  %170 = sext i32 %169 to i64
  %171 = getelementptr inbounds [100001 x i32], ptr @pL, i64 0, i64 %170
  store i32 %165, ptr %171, align 4, !tbaa !5
  %172 = load i32, ptr %8, align 4, !tbaa !5
  %173 = sext i32 %172 to i64
  %174 = getelementptr inbounds [100001 x i32], ptr @pL, i64 0, i64 %173
  %175 = load i32, ptr %174, align 4, !tbaa !5
  %176 = sext i32 %175 to i64
  %177 = getelementptr inbounds [100001 x i32], ptr @pR, i64 0, i64 %176
  store i32 %165, ptr %177, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %178

178:                                              ; preds = %150
  %179 = load i32, ptr %5, align 4, !tbaa !5
  %180 = add nsw i32 %179, 1
  store i32 %180, ptr %5, align 4, !tbaa !5
  br label %66, !llvm.loop !16

181:                                              ; preds = %70
  %182 = load i32, ptr @ans, align 4, !tbaa !5
  %183 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %182)
  ret i32 0
}

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

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

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

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

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

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

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

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

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

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 = { 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 = { nounwind }

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

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


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

%"class.std::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<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::pair" = type { i32, i32 }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@a = external dso_local global [100001 x i32], align 16
@pL = external dso_local local_unnamed_addr global [100001 x i32], align 16
@pR = external dso_local local_unnamed_addr global [100001 x i32], align 16
@ans = external dso_local local_unnamed_addr global i32, align 4
@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 [4 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 %"struct.std::pair", align 8
  %3 = alloca %"struct.std::pair", align 4
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %.not38 = icmp slt i32 %5, 1
  br i1 %.not38, label %._crit_edge.thread, label %.lr.ph

._crit_edge.thread:                               ; preds = %0
  %.pre57 = sext i32 %5 to i64
  store i32 0, ptr @pL, align 16, !tbaa !5
  %6 = getelementptr inbounds [100001 x i32], ptr @pR, i64 0, i64 %.pre57
  store i32 %5, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  br label %._crit_edge43

._crit_edge:                                      ; preds = %.lr.ph
  store i32 0, ptr @pL, align 16, !tbaa !5
  %7 = getelementptr inbounds [100001 x i32], ptr @pR, i64 0, i64 %17
  store i32 %16, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  store i32 1, ptr %1, align 4, !tbaa !5
  %8 = icmp sgt i32 %16, 1
  br i1 %8, label %.lr.ph42, label %._crit_edge43

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

._crit_edge43.loopexit:                           ; preds = %.lr.ph42
  %.pre = sext i32 %33 to i64
  br label %._crit_edge43

._crit_edge43:                                    ; preds = %._crit_edge.thread, %._crit_edge43.loopexit, %._crit_edge
  %.pre-phi = phi i64 [ %.pre, %._crit_edge43.loopexit ], [ %17, %._crit_edge ], [ %.pre57, %._crit_edge.thread ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  %18 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %.pre-phi
  store i32 -1061109567, ptr %18, align 4, !tbaa !5
  store i32 -1061109567, ptr @a, align 16, !tbaa !5
  %19 = load i32, ptr @m, align 4, !tbaa !5
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %.lr.ph49, label %._crit_edge50

.lr.ph49:                                         ; preds = %._crit_edge43
  %21 = getelementptr inbounds i8, ptr %3, i64 4
  br label %37

.lr.ph42:                                         ; preds = %._crit_edge, %.lr.ph42
  %storemerge40 = phi i32 [ %32, %.lr.ph42 ], [ 1, %._crit_edge ]
  %22 = add nsw i32 %storemerge40, 1
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %23
  %25 = load i32, ptr %24, align 4, !tbaa !5
  %26 = sext i32 %storemerge40 to i64
  %27 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %26
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %29 = sub nsw i32 %28, %25
  store i32 %29, ptr %27, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  %30 = call i64 @_ZSt9make_pairIRiS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %27, ptr noundef nonnull align 4 dereferenceable(4) %1)
  store i64 %30, ptr %2, align 8
  call void @_ZNSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt4lessIS1_EE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(25) @Q, ptr noundef nonnull align 4 dereferenceable(8) %2)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  %31 = load i32, ptr %1, align 4, !tbaa !5
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %1, align 4, !tbaa !5
  %33 = load i32, ptr @n, align 4, !tbaa !5
  %34 = icmp slt i32 %32, %33
  br i1 %34, label %.lr.ph42, label %._crit_edge43.loopexit, !llvm.loop !11

._crit_edge50:                                    ; preds = %72, %._crit_edge43
  %35 = load i32, ptr @ans, align 4, !tbaa !5
  %36 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %35)
  ret i32 0

37:                                               ; preds = %.lr.ph49, %72
  %.02447 = phi i32 [ 0, %.lr.ph49 ], [ %82, %72 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  call void @_ZNSt4pairIiiEC2IiiTnNSt9enable_ifIXsr6__and_ISt37__is_implicitly_default_constructibleIT_ES3_IT0_EEE5valueEbE4typeELb1EEEv(ptr noundef nonnull align 4 dereferenceable(8) %3)
  br label %.critedge

.critedge:                                        ; preds = %.critedge.backedge, %37
  %38 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNKSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt4lessIS1_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %39 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSERKS0_(ptr noundef nonnull align 4 dereferenceable(8) %3, ptr noundef nonnull align 4 dereferenceable(8) %38)
  call void @_ZNSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt4lessIS1_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25) @Q)
  %40 = load i32, ptr %21, align 4, !tbaa !12
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [100001 x i32], ptr @pR, i64 0, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [100001 x i32], ptr @pL, i64 0, i64 %44
  %46 = load i32, ptr %45, align 4, !tbaa !5
  %47 = icmp eq i32 %46, %40
  br i1 %47, label %48, label %.critedge.backedge

48:                                               ; preds = %.critedge
  %49 = getelementptr inbounds [100001 x i32], ptr @pL, i64 0, i64 %41
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [100001 x i32], ptr @pR, i64 0, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = icmp eq i32 %53, %40
  br i1 %54, label %55, label %.critedge.backedge

.critedge.backedge:                               ; preds = %48, %.critedge
  br label %.critedge, !llvm.loop !14

55:                                               ; preds = %48
  %56 = getelementptr inbounds [100001 x i32], ptr @pR, i64 0, i64 %41
  %57 = getelementptr inbounds [100001 x i32], ptr @pL, i64 0, i64 %41
  %58 = load i32, ptr %3, align 4, !tbaa !15
  %59 = load i32, ptr @ans, align 4, !tbaa !5
  %60 = sub i32 %59, %58
  store i32 %60, ptr @ans, align 4, !tbaa !5
  %61 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %51
  %62 = load i32, ptr %61, align 4, !tbaa !5
  %.not29 = icmp eq i32 %62, -1061109567
  br i1 %.not29, label %70, label %63

63:                                               ; preds = %55
  %64 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %44
  %65 = load i32, ptr %64, align 4, !tbaa !5
  %.not30 = icmp eq i32 %65, -1061109567
  br i1 %.not30, label %70, label %66

66:                                               ; preds = %63
  %67 = sub i32 %62, %58
  %68 = add i32 %67, %65
  %69 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %41
  store i32 %68, ptr %69, align 4, !tbaa !5
  store i32 %68, ptr %3, align 4, !tbaa !15
  call void @_ZNSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt4lessIS1_EE4pushERKS1_(ptr noundef nonnull align 8 dereferenceable(25) @Q, ptr noundef nonnull align 4 dereferenceable(8) %3)
  br label %72

70:                                               ; preds = %63, %55
  %71 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %41
  store i32 -1061109567, ptr %71, align 4, !tbaa !5
  br label %72

72:                                               ; preds = %70, %66
  %73 = getelementptr inbounds [100001 x i32], ptr @pL, i64 0, i64 %51
  %74 = load i32, ptr %73, align 4, !tbaa !5
  store i32 %74, ptr %57, align 4, !tbaa !5
  %75 = getelementptr inbounds [100001 x i32], ptr @pR, i64 0, i64 %44
  %76 = load i32, ptr %75, align 4, !tbaa !5
  store i32 %76, ptr %56, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [100001 x i32], ptr @pL, i64 0, i64 %77
  store i32 %40, ptr %78, align 4, !tbaa !5
  %79 = load i32, ptr %73, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [100001 x i32], ptr @pR, i64 0, i64 %80
  store i32 %40, ptr %81, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  %82 = add nuw nsw i32 %.02447, 1
  %83 = load i32, ptr @m, align 4, !tbaa !5
  %84 = icmp slt i32 %82, %83
  br i1 %84, label %37, label %._crit_edge50, !llvm.loop !16
}

; 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: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueISt4pairIiiESt6vectorIS1_SaIS1_EESt4lessIS1_EE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(25), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #3 align 2

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

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

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

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

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

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

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

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 = { 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 = { nounwind }

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

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


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