; LLVM IR from tangjz/acm-icpc :: codeforces/gym (101471D)

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

%"struct.std::pair" = type { i32, i32 }
%"struct.std::greater" = type { i8 }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@a = external dso_local global [500001 x %"struct.std::pair"], align 16
@b = external dso_local global [500001 x %"struct.std::pair"], align 16
@f = external dso_local global [500001 x i64], align 16
@ans = external dso_local global i64, align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1

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

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca %"struct.std::greater", align 1
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %13

13:                                               ; preds = %28, %0
  %14 = load i32, ptr %3, align 4, !tbaa !5
  %15 = load i32, ptr @n, align 4, !tbaa !5
  %16 = icmp slt i32 %14, %15
  br i1 %16, label %18, label %17

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

18:                                               ; preds = %13
  %19 = load i32, ptr %3, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [500001 x %"struct.std::pair"], ptr @a, i64 0, i64 %20
  %22 = getelementptr inbounds %"struct.std::pair", ptr %21, i32 0, i32 0
  %23 = load i32, ptr %3, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [500001 x %"struct.std::pair"], ptr @a, i64 0, i64 %24
  %26 = getelementptr inbounds %"struct.std::pair", ptr %25, i32 0, i32 1
  %27 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %22, ptr noundef %26)
  br label %28

28:                                               ; preds = %18
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %3, align 4, !tbaa !5
  br label %13, !llvm.loop !9

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

32:                                               ; preds = %47, %31
  %33 = load i32, ptr %4, align 4, !tbaa !5
  %34 = load i32, ptr @m, align 4, !tbaa !5
  %35 = icmp slt i32 %33, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %32
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %50

37:                                               ; preds = %32
  %38 = load i32, ptr %4, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [500001 x %"struct.std::pair"], ptr @b, i64 0, i64 %39
  %41 = getelementptr inbounds %"struct.std::pair", ptr %40, i32 0, i32 0
  %42 = load i32, ptr %4, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [500001 x %"struct.std::pair"], ptr @b, i64 0, i64 %43
  %45 = getelementptr inbounds %"struct.std::pair", ptr %44, i32 0, i32 1
  %46 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %41, ptr noundef %45)
  br label %47

47:                                               ; preds = %37
  %48 = load i32, ptr %4, align 4, !tbaa !5
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %4, align 4, !tbaa !5
  br label %32, !llvm.loop !11

50:                                               ; preds = %36
  %51 = load i32, ptr @n, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds %"struct.std::pair", ptr @a, i64 %52
  call void @_ZSt4sortIPSt4pairIiiEEvT_S3_(ptr noundef @a, ptr noundef %53)
  store i32 0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 0, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 1061109567, ptr %7, align 4, !tbaa !5
  br label %54

54:                                               ; preds = %108, %50
  %55 = load i32, ptr %5, align 4, !tbaa !5
  %56 = load i32, ptr @n, align 4, !tbaa !5
  %57 = icmp slt i32 %55, %56
  br i1 %57, label %59, label %58

58:                                               ; preds = %54
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  br label %109

59:                                               ; preds = %54
  %60 = load i32, ptr %5, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [500001 x %"struct.std::pair"], ptr @a, i64 0, i64 %61
  %63 = getelementptr inbounds %"struct.std::pair", ptr %62, i32 0, i32 1
  %64 = load i32, ptr %63, align 4, !tbaa !12
  %65 = load i32, ptr %7, align 4, !tbaa !5
  %66 = icmp slt i32 %64, %65
  br i1 %66, label %67, label %84

67:                                               ; preds = %59
  %68 = load i32, ptr %2, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [500001 x i64], ptr @f, i64 0, i64 %69
  store i64 -1125953513178927489, ptr %70, align 8, !tbaa !14
  %71 = load i32, ptr %5, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [500001 x %"struct.std::pair"], ptr @a, i64 0, i64 %72
  %74 = load i32, ptr %2, align 4, !tbaa !5
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %2, align 4, !tbaa !5
  %76 = sext i32 %74 to i64
  %77 = getelementptr inbounds [500001 x %"struct.std::pair"], ptr @a, i64 0, i64 %76
  %78 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSERKS0_(ptr noundef nonnull align 4 dereferenceable(8) %77, ptr noundef nonnull align 4 dereferenceable(8) %73)
  %79 = load i32, ptr %5, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [500001 x %"struct.std::pair"], ptr @a, i64 0, i64 %80
  %82 = getelementptr inbounds %"struct.std::pair", ptr %81, i32 0, i32 1
  %83 = load i32, ptr %82, align 4, !tbaa !12
  store i32 %83, ptr %7, align 4, !tbaa !5
  br label %84

84:                                               ; preds = %67, %59
  %85 = load i32, ptr %5, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [500001 x %"struct.std::pair"], ptr @a, i64 0, i64 %86
  %88 = getelementptr inbounds %"struct.std::pair", ptr %87, i32 0, i32 0
  %89 = load i32, ptr %88, align 8, !tbaa !16
  store i32 %89, ptr %6, align 4, !tbaa !5
  br label %90

90:                                               ; preds = %105, %84
  %91 = load i32, ptr %5, align 4, !tbaa !5
  %92 = load i32, ptr @n, align 4, !tbaa !5
  %93 = icmp slt i32 %91, %92
  br i1 %93, label %94, label %102

94:                                               ; preds = %90
  %95 = load i32, ptr %5, align 4, !tbaa !5
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [500001 x %"struct.std::pair"], ptr @a, i64 0, i64 %96
  %98 = getelementptr inbounds %"struct.std::pair", ptr %97, i32 0, i32 0
  %99 = load i32, ptr %98, align 8, !tbaa !16
  %100 = load i32, ptr %6, align 4, !tbaa !5
  %101 = icmp eq i32 %99, %100
  br label %102

102:                                              ; preds = %94, %90
  %103 = phi i1 [ false, %90 ], [ %101, %94 ]
  br i1 %103, label %104, label %108

104:                                              ; preds = %102
  br label %105

105:                                              ; preds = %104
  %106 = load i32, ptr %5, align 4, !tbaa !5
  %107 = add nsw i32 %106, 1
  store i32 %107, ptr %5, align 4, !tbaa !5
  br label %90, !llvm.loop !17

108:                                              ; preds = %102
  br label %54, !llvm.loop !18

109:                                              ; preds = %58
  %110 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %110, ptr @n, align 4, !tbaa !5
  %111 = load i32, ptr @m, align 4, !tbaa !5
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds %"struct.std::pair", ptr @b, i64 %112
  call void @_ZSt4sortIPSt4pairIiiESt7greaterIS1_EEvT_S5_T0_(ptr noundef @b, ptr noundef %113)
  store i32 0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  store i32 0, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %114

114:                                              ; preds = %165, %109
  %115 = load i32, ptr %9, align 4, !tbaa !5
  %116 = load i32, ptr @m, align 4, !tbaa !5
  %117 = icmp slt i32 %115, %116
  br i1 %117, label %119, label %118

118:                                              ; preds = %114
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %166

119:                                              ; preds = %114
  %120 = load i32, ptr %9, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [500001 x %"struct.std::pair"], ptr @b, i64 0, i64 %121
  %123 = getelementptr inbounds %"struct.std::pair", ptr %122, i32 0, i32 1
  %124 = load i32, ptr %123, align 4, !tbaa !12
  %125 = load i32, ptr %11, align 4, !tbaa !5
  %126 = icmp sgt i32 %124, %125
  br i1 %126, label %127, label %141

127:                                              ; preds = %119
  %128 = load i32, ptr %9, align 4, !tbaa !5
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds [500001 x %"struct.std::pair"], ptr @b, i64 0, i64 %129
  %131 = load i32, ptr %2, align 4, !tbaa !5
  %132 = add nsw i32 %131, 1
  store i32 %132, ptr %2, align 4, !tbaa !5
  %133 = sext i32 %131 to i64
  %134 = getelementptr inbounds [500001 x %"struct.std::pair"], ptr @b, i64 0, i64 %133
  %135 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSERKS0_(ptr noundef nonnull align 4 dereferenceable(8) %134, ptr noundef nonnull align 4 dereferenceable(8) %130)
  %136 = load i32, ptr %9, align 4, !tbaa !5
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [500001 x %"struct.std::pair"], ptr @b, i64 0, i64 %137
  %139 = getelementptr inbounds %"struct.std::pair", ptr %138, i32 0, i32 1
  %140 = load i32, ptr %139, align 4, !tbaa !12
  store i32 %140, ptr %11, align 4, !tbaa !5
  br label %141

141:                                              ; preds = %127, %119
  %142 = load i32, ptr %9, align 4, !tbaa !5
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds [500001 x %"struct.std::pair"], ptr @b, i64 0, i64 %143
  %145 = getelementptr inbounds %"struct.std::pair", ptr %144, i32 0, i32 0
  %146 = load i32, ptr %145, align 8, !tbaa !16
  store i32 %146, ptr %10, align 4, !tbaa !5
  br label %147

147:                                              ; preds = %162, %141
  %148 = load i32, ptr %9, align 4, !tbaa !5
  %149 = load i32, ptr @m, align 4, !tbaa !5
  %150 = icmp slt i32 %148, %149
  br i1 %150, label %151, label %159

151:                                              ; preds = %147
  %152 = load i32, ptr %9, align 4, !tbaa !5
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds [500001 x %"struct.std::pair"], ptr @b, i64 0, i64 %153
  %155 = getelementptr inbounds %"struct.std::pair", ptr %154, i32 0, i32 0
  %156 = load i32, ptr %155, align 8, !tbaa !16
  %157 = load i32, ptr %10, align 4, !tbaa !5
  %158 = icmp eq i32 %156, %157
  br label %159

159:                                              ; preds = %151, %147
  %160 = phi i1 [ false, %147 ], [ %158, %151 ]
  br i1 %160, label %161, label %165

161:                                              ; preds = %159
  br label %162

162:                                              ; preds = %161
  %163 = load i32, ptr %9, align 4, !tbaa !5
  %164 = add nsw i32 %163, 1
  store i32 %164, ptr %9, align 4, !tbaa !5
  br label %147, !llvm.loop !19

165:                                              ; preds = %159
  br label %114, !llvm.loop !20

166:                                              ; preds = %118
  %167 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %167, ptr @m, align 4, !tbaa !5
  %168 = load i32, ptr @m, align 4, !tbaa !5
  %169 = sext i32 %168 to i64
  %170 = getelementptr inbounds %"struct.std::pair", ptr @b, i64 %169
  call void @_ZSt7reverseIPSt4pairIiiEEvT_S3_(ptr noundef @b, ptr noundef %170)
  %171 = load i32, ptr @n, align 4, !tbaa !5
  %172 = sub nsw i32 %171, 1
  %173 = load i32, ptr @m, align 4, !tbaa !5
  %174 = sub nsw i32 %173, 1
  call void @_Z5solveiiii(i32 noundef 0, i32 noundef %172, i32 noundef 0, i32 noundef %174)
  %175 = load i64, ptr @ans, align 8, !tbaa !14
  %176 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %175)
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  ret i32 0
}

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

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

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

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

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

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

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


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

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

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@a = external dso_local global [500001 x %"struct.std::pair"], align 16
@b = external dso_local global [500001 x %"struct.std::pair"], align 16
@f = external dso_local local_unnamed_addr global [500001 x i64], align 16
@ans = external dso_local local_unnamed_addr global i64, align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %2 = load i32, ptr @n, align 4, !tbaa !5
  %3 = icmp sgt i32 %2, 0
  br i1 %3, label %.lr.ph, label %.preheader

.preheader:                                       ; preds = %.lr.ph, %0
  %4 = phi i32 [ %2, %0 ], [ %10, %.lr.ph ]
  %5 = load i32, ptr @m, align 4, !tbaa !5
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.lr.ph47, label %._crit_edge

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %7 = getelementptr inbounds [500001 x %"struct.std::pair"], ptr @a, i64 0, i64 %indvars.iv
  %8 = getelementptr inbounds i8, ptr %7, i64 4
  %9 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %7, ptr noundef nonnull %8)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %10 = load i32, ptr @n, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %12 = icmp slt i64 %indvars.iv.next, %11
  br i1 %12, label %.lr.ph, label %.preheader, !llvm.loop !9

._crit_edge.loopexit:                             ; preds = %.lr.ph47
  %.pre = load i32, ptr @n, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %13 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %4, %.preheader ]
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds %"struct.std::pair", ptr @a, i64 %14
  tail call void @_ZSt4sortIPSt4pairIiiEEvT_S3_(ptr noundef nonnull @a, ptr noundef nonnull %15)
  %16 = load i32, ptr @n, align 4, !tbaa !5
  %17 = icmp sgt i32 %16, 0
  br i1 %17, label %.lr.ph57, label %._crit_edge58

.lr.ph47:                                         ; preds = %.preheader, %.lr.ph47
  %indvars.iv74 = phi i64 [ %indvars.iv.next75, %.lr.ph47 ], [ 0, %.preheader ]
  %18 = getelementptr inbounds [500001 x %"struct.std::pair"], ptr @b, i64 0, i64 %indvars.iv74
  %19 = getelementptr inbounds i8, ptr %18, i64 4
  %20 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %18, ptr noundef nonnull %19)
  %indvars.iv.next75 = add nuw nsw i64 %indvars.iv74, 1
  %21 = load i32, ptr @m, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = icmp slt i64 %indvars.iv.next75, %22
  br i1 %23, label %.lr.ph47, label %._crit_edge.loopexit, !llvm.loop !11

._crit_edge58:                                    ; preds = %.critedge, %50, %._crit_edge
  %.035.lcssa = phi i32 [ 0, %._crit_edge ], [ %.136, %50 ], [ %.136, %.critedge ]
  store i32 %.035.lcssa, ptr @n, align 4, !tbaa !5
  %24 = load i32, ptr @m, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds %"struct.std::pair", ptr @b, i64 %25
  tail call void @_ZSt4sortIPSt4pairIiiESt7greaterIS1_EEvT_S5_T0_(ptr noundef nonnull @b, ptr noundef nonnull %26)
  %27 = load i32, ptr @m, align 4, !tbaa !5
  %28 = icmp sgt i32 %27, 0
  br i1 %28, label %.lr.ph70, label %._crit_edge71

.lr.ph57:                                         ; preds = %._crit_edge, %.critedge
  %29 = phi i32 [ %43, %.critedge ], [ %16, %._crit_edge ]
  %.03555 = phi i32 [ %.136, %.critedge ], [ 0, %._crit_edge ]
  %.03954 = phi i32 [ %.140, %.critedge ], [ 1061109567, %._crit_edge ]
  %.04253 = phi i32 [ %.143.lcssa, %.critedge ], [ 0, %._crit_edge ]
  %30 = sext i32 %.04253 to i64
  %31 = getelementptr inbounds [500001 x %"struct.std::pair"], ptr @a, i64 0, i64 %30
  %32 = getelementptr inbounds i8, ptr %31, i64 4
  %33 = load i32, ptr %32, align 4, !tbaa !12
  %34 = icmp slt i32 %33, %.03954
  br i1 %34, label %35, label %42

35:                                               ; preds = %.lr.ph57
  %36 = sext i32 %.03555 to i64
  %37 = getelementptr inbounds [500001 x i64], ptr @f, i64 0, i64 %36
  store i64 -1125953513178927489, ptr %37, align 8, !tbaa !14
  %38 = add nsw i32 %.03555, 1
  %39 = getelementptr inbounds [500001 x %"struct.std::pair"], ptr @a, i64 0, i64 %36
  %40 = tail call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSERKS0_(ptr noundef nonnull align 4 dereferenceable(8) %39, ptr noundef nonnull align 4 dereferenceable(8) %31)
  %41 = load i32, ptr %32, align 4, !tbaa !12
  %.pre84 = load i32, ptr @n, align 4, !tbaa !5
  br label %42

42:                                               ; preds = %35, %.lr.ph57
  %43 = phi i32 [ %.pre84, %35 ], [ %29, %.lr.ph57 ]
  %.140 = phi i32 [ %41, %35 ], [ %.03954, %.lr.ph57 ]
  %.136 = phi i32 [ %38, %35 ], [ %.03555, %.lr.ph57 ]
  %44 = load i32, ptr %31, align 8, !tbaa !16
  %45 = icmp slt i32 %.04253, %43
  br i1 %45, label %.lr.ph50.preheader, label %.critedge

.lr.ph50.preheader:                               ; preds = %42
  %46 = sext i32 %43 to i64
  br label %.lr.ph50

.lr.ph50:                                         ; preds = %.lr.ph50.preheader, %50
  %indvars.iv77 = phi i64 [ %30, %.lr.ph50.preheader ], [ %indvars.iv.next78, %50 ]
  %47 = getelementptr inbounds [500001 x %"struct.std::pair"], ptr @a, i64 0, i64 %indvars.iv77
  %48 = load i32, ptr %47, align 8, !tbaa !16
  %49 = icmp eq i32 %48, %44
  br i1 %49, label %50, label %.critedge.loopexit

50:                                               ; preds = %.lr.ph50
  %indvars.iv.next78 = add nsw i64 %indvars.iv77, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next78, %46
  br i1 %exitcond.not, label %._crit_edge58, label %.lr.ph50, !llvm.loop !17

.critedge.loopexit:                               ; preds = %.lr.ph50
  %51 = trunc nsw i64 %indvars.iv77 to i32
  br label %.critedge

.critedge:                                        ; preds = %.critedge.loopexit, %42
  %.143.lcssa = phi i32 [ %.04253, %42 ], [ %51, %.critedge.loopexit ]
  %52 = icmp slt i32 %.143.lcssa, %43
  br i1 %52, label %.lr.ph57, label %._crit_edge58, !llvm.loop !18

._crit_edge71:                                    ; preds = %.critedge2, %81, %._crit_edge58
  %.2.lcssa = phi i32 [ 0, %._crit_edge58 ], [ %.3, %81 ], [ %.3, %.critedge2 ]
  store i32 %.2.lcssa, ptr @m, align 4, !tbaa !5
  %53 = sext i32 %.2.lcssa to i64
  %54 = getelementptr inbounds %"struct.std::pair", ptr @b, i64 %53
  tail call void @_ZSt7reverseIPSt4pairIiiEEvT_S3_(ptr noundef nonnull @b, ptr noundef nonnull %54)
  %55 = load i32, ptr @n, align 4, !tbaa !5
  %56 = add nsw i32 %55, -1
  %57 = load i32, ptr @m, align 4, !tbaa !5
  %58 = add nsw i32 %57, -1
  tail call void @_Z5solveiiii(i32 noundef 0, i32 noundef %56, i32 noundef 0, i32 noundef %58)
  %59 = load i64, ptr @ans, align 8, !tbaa !14
  %60 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %59)
  ret i32 0

.lr.ph70:                                         ; preds = %._crit_edge58, %.critedge2
  %61 = phi i32 [ %74, %.critedge2 ], [ %27, %._crit_edge58 ]
  %.068 = phi i32 [ %.1, %.critedge2 ], [ 0, %._crit_edge58 ]
  %.267 = phi i32 [ %.3, %.critedge2 ], [ 0, %._crit_edge58 ]
  %.03766 = phi i32 [ %.138.lcssa, %.critedge2 ], [ 0, %._crit_edge58 ]
  %62 = sext i32 %.03766 to i64
  %63 = getelementptr inbounds [500001 x %"struct.std::pair"], ptr @b, i64 0, i64 %62
  %64 = getelementptr inbounds i8, ptr %63, i64 4
  %65 = load i32, ptr %64, align 4, !tbaa !12
  %66 = icmp sgt i32 %65, %.068
  br i1 %66, label %67, label %73

67:                                               ; preds = %.lr.ph70
  %68 = add nsw i32 %.267, 1
  %69 = sext i32 %.267 to i64
  %70 = getelementptr inbounds [500001 x %"struct.std::pair"], ptr @b, i64 0, i64 %69
  %71 = tail call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSERKS0_(ptr noundef nonnull align 4 dereferenceable(8) %70, ptr noundef nonnull align 4 dereferenceable(8) %63)
  %72 = load i32, ptr %64, align 4, !tbaa !12
  %.pre85 = load i32, ptr @m, align 4, !tbaa !5
  br label %73

73:                                               ; preds = %67, %.lr.ph70
  %74 = phi i32 [ %.pre85, %67 ], [ %61, %.lr.ph70 ]
  %.3 = phi i32 [ %68, %67 ], [ %.267, %.lr.ph70 ]
  %.1 = phi i32 [ %72, %67 ], [ %.068, %.lr.ph70 ]
  %75 = load i32, ptr %63, align 8, !tbaa !16
  %76 = icmp slt i32 %.03766, %74
  br i1 %76, label %.lr.ph62.preheader, label %.critedge2

.lr.ph62.preheader:                               ; preds = %73
  %77 = sext i32 %74 to i64
  br label %.lr.ph62

.lr.ph62:                                         ; preds = %.lr.ph62.preheader, %81
  %indvars.iv80 = phi i64 [ %62, %.lr.ph62.preheader ], [ %indvars.iv.next81, %81 ]
  %78 = getelementptr inbounds [500001 x %"struct.std::pair"], ptr @b, i64 0, i64 %indvars.iv80
  %79 = load i32, ptr %78, align 8, !tbaa !16
  %80 = icmp eq i32 %79, %75
  br i1 %80, label %81, label %.critedge2.loopexit

81:                                               ; preds = %.lr.ph62
  %indvars.iv.next81 = add nsw i64 %indvars.iv80, 1
  %exitcond83.not = icmp eq i64 %indvars.iv.next81, %77
  br i1 %exitcond83.not, label %._crit_edge71, label %.lr.ph62, !llvm.loop !19

.critedge2.loopexit:                              ; preds = %.lr.ph62
  %82 = trunc nsw i64 %indvars.iv80 to i32
  br label %.critedge2

.critedge2:                                       ; preds = %.critedge2.loopexit, %73
  %.138.lcssa = phi i32 [ %.03766, %73 ], [ %82, %.critedge2.loopexit ]
  %83 = icmp slt i32 %.138.lcssa, %74
  br i1 %83, label %.lr.ph70, label %._crit_edge71, !llvm.loop !20
}

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

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

; 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: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPSt4pairIiiESt7greaterIS1_EEvT_S5_T0_(ptr noundef, ptr noundef) local_unnamed_addr #3

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

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

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { 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 #2 = { 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 #3 = { 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 #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" }

!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 = !{!15, !15, i64 0}
!15 = !{!"long long", !7, i64 0}
!16 = !{!13, !6, i64 0}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}


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