; LLVM IR from bqi343/cp-notebook :: Contests/USACO Solutions/2017-18/Dec 2017/Gold (17 Dec Gold 3)

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

@N = external dso_local global i32, align 4
@M = external dso_local global i64, align 8
@F = external dso_local global [100000 x i64], align 16
@S = external dso_local global [100000 x i64], align 16
@ans = external dso_local global i32, align 4
@d = external dso_local global %"class.std::deque", align 8
@.str = external hidden unnamed_addr constant [16 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external global ptr, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca %"struct.std::pair", align 4
  store i32 0, ptr %1, align 4
  %7 = load ptr, ptr @stdin, align 8, !tbaa !5
  %8 = call ptr @freopen(ptr noundef @.str, ptr noundef @.str.2, ptr noundef %7)
  %9 = load ptr, ptr @stdout, align 8, !tbaa !5
  %10 = call ptr @freopen(ptr noundef @.str.3, ptr noundef @.str.4, ptr noundef %9)
  %11 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @N)
  %12 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %11, ptr noundef nonnull align 8 dereferenceable(8) @M)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 0, ptr %2, align 4, !tbaa !9
  br label %13

13:                                               ; preds = %27, %0
  %14 = load i32, ptr %2, align 4, !tbaa !9
  %15 = load i32, ptr @N, align 4, !tbaa !9
  %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 %2) #6
  br label %30

18:                                               ; preds = %13
  %19 = load i32, ptr %2, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [100000 x i64], ptr @F, i64 0, i64 %20
  %22 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %21)
  %23 = load i32, ptr %2, align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [100000 x i64], ptr @S, i64 0, i64 %24
  %26 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %22, ptr noundef nonnull align 8 dereferenceable(8) %25)
  br label %27

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

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

31:                                               ; preds = %110, %30
  %32 = load i32, ptr %5, align 4, !tbaa !9
  %33 = load i32, ptr @N, align 4, !tbaa !9
  %34 = icmp slt i32 %32, %33
  br i1 %34, label %36, label %35

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

36:                                               ; preds = %31
  %37 = call noundef i64 @_ZNKSt5dequeISt4pairIiiESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(80) @d) #6
  %38 = trunc i64 %37 to i32
  %39 = icmp ne i32 %38, 0
  br i1 %39, label %40, label %48

40:                                               ; preds = %36
  %41 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt5dequeISt4pairIiiESaIS1_EE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) @d) #6
  %42 = getelementptr inbounds %"struct.std::pair", ptr %41, i32 0, i32 1
  %43 = load i32, ptr %42, align 4, !tbaa !15
  %44 = load i32, ptr %5, align 4, !tbaa !9
  %45 = sub nsw i32 %44, 1
  %46 = icmp eq i32 %43, %45
  br i1 %46, label %47, label %48

47:                                               ; preds = %40
  call void @_ZNSt5dequeISt4pairIiiESaIS1_EE9pop_frontEv(ptr noundef nonnull align 8 dereferenceable(80) @d) #6
  br label %48

48:                                               ; preds = %47, %40, %36
  %49 = load i32, ptr %5, align 4, !tbaa !9
  %50 = icmp ne i32 %49, 0
  br i1 %50, label %51, label %59

51:                                               ; preds = %48
  %52 = load i32, ptr %5, align 4, !tbaa !9
  %53 = sub nsw i32 %52, 1
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [100000 x i64], ptr @F, i64 0, i64 %54
  %56 = load i64, ptr %55, align 8, !tbaa !13
  %57 = load i64, ptr %4, align 8, !tbaa !13
  %58 = sub nsw i64 %57, %56
  store i64 %58, ptr %4, align 8, !tbaa !13
  br label %59

59:                                               ; preds = %51, %48
  br label %60

60:                                               ; preds = %96, %59
  %61 = load i32, ptr %3, align 4, !tbaa !9
  %62 = load i32, ptr @N, align 4, !tbaa !9
  %63 = sub nsw i32 %62, 1
  %64 = icmp slt i32 %61, %63
  br i1 %64, label %65, label %69

65:                                               ; preds = %60
  %66 = load i64, ptr %4, align 8, !tbaa !13
  %67 = load i64, ptr @M, align 8, !tbaa !13
  %68 = icmp slt i64 %66, %67
  br label %69

69:                                               ; preds = %65, %60
  %70 = phi i1 [ false, %60 ], [ %68, %65 ]
  br i1 %70, label %71, label %100

71:                                               ; preds = %69
  %72 = load i32, ptr %3, align 4, !tbaa !9
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %3, align 4, !tbaa !9
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [100000 x i64], ptr @F, i64 0, i64 %74
  %76 = load i64, ptr %75, align 8, !tbaa !13
  %77 = load i64, ptr %4, align 8, !tbaa !13
  %78 = add nsw i64 %77, %76
  store i64 %78, ptr %4, align 8, !tbaa !13
  br label %79

79:                                               ; preds = %95, %71
  %80 = call noundef i64 @_ZNKSt5dequeISt4pairIiiESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(80) @d) #6
  %81 = trunc i64 %80 to i32
  %82 = icmp ne i32 %81, 0
  br i1 %82, label %83, label %93

83:                                               ; preds = %79
  %84 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt5dequeISt4pairIiiESaIS1_EE4backEv(ptr noundef nonnull align 8 dereferenceable(80) @d) #6
  %85 = getelementptr inbounds %"struct.std::pair", ptr %84, i32 0, i32 0
  %86 = load i32, ptr %85, align 4, !tbaa !17
  %87 = sext i32 %86 to i64
  %88 = load i32, ptr %3, align 4, !tbaa !9
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [100000 x i64], ptr @S, i64 0, i64 %89
  %91 = load i64, ptr %90, align 8, !tbaa !13
  %92 = icmp sle i64 %87, %91
  br label %93

93:                                               ; preds = %83, %79
  %94 = phi i1 [ false, %79 ], [ %92, %83 ]
  br i1 %94, label %95, label %96

95:                                               ; preds = %93
  call void @_ZNSt5dequeISt4pairIiiESaIS1_EE8pop_backEv(ptr noundef nonnull align 8 dereferenceable(80) @d) #6
  br label %79, !llvm.loop !18

96:                                               ; preds = %93
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %97 = load i32, ptr %3, align 4, !tbaa !9
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [100000 x i64], ptr @S, i64 0, i64 %98
  call void @_ZNSt4pairIiiEC2IRxRiTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS5_S6_EEEbE4typeELb1EEEOS5_OS6_(ptr noundef nonnull align 4 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(8) %99, ptr noundef nonnull align 4 dereferenceable(4) %3)
  call void @_ZNSt5dequeISt4pairIiiESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(80) @d, ptr noundef nonnull align 4 dereferenceable(8) %6)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  br label %60, !llvm.loop !19

100:                                              ; preds = %69
  %101 = load i64, ptr %4, align 8, !tbaa !13
  %102 = load i64, ptr @M, align 8, !tbaa !13
  %103 = icmp sge i64 %101, %102
  br i1 %103, label %104, label %109

104:                                              ; preds = %100
  %105 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt5dequeISt4pairIiiESaIS1_EE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) @d) #6
  %106 = getelementptr inbounds %"struct.std::pair", ptr %105, i32 0, i32 0
  %107 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @ans, ptr noundef nonnull align 4 dereferenceable(4) %106)
  %108 = load i32, ptr %107, align 4, !tbaa !9
  store i32 %108, ptr @ans, align 4, !tbaa !9
  br label %109

109:                                              ; preds = %104, %100
  br label %110

110:                                              ; preds = %109
  %111 = load i32, ptr %5, align 4, !tbaa !9
  %112 = add nsw i32 %111, 1
  store i32 %112, ptr %5, align 4, !tbaa !9
  br label %31, !llvm.loop !20

113:                                              ; preds = %35
  %114 = load i32, ptr @ans, align 4, !tbaa !9
  %115 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %114)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  %116 = load i32, ptr %1, align 4
  ret i32 %116
}

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) #1

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #1

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

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

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

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

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

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

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

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

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

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

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

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 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 = { 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 #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"long long", !7, i64 0}
!15 = !{!16, !10, i64 4}
!16 = !{!"_ZTSSt4pairIiiE", !10, i64 0, !10, i64 4}
!17 = !{!16, !10, i64 0}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !12}
!20 = distinct !{!20, !12}


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

%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Deque_impl" }
%"struct.std::_Deque_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Deque_impl" = type { %"struct.std::_Deque_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Deque_impl_data" }
%"struct.std::_Deque_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }
%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"struct.std::pair" = type { i32, i32 }

@N = external dso_local global i32, align 4
@M = external dso_local global i64, align 8
@F = external dso_local global [100000 x i64], align 16
@S = external dso_local global [100000 x i64], align 16
@ans = external dso_local global i32, align 4
@d = external dso_local global %"class.std::deque", align 8
@.str = external hidden unnamed_addr constant [16 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external local_unnamed_addr global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca %"struct.std::pair", align 4
  %3 = load ptr, ptr @stdin, align 8, !tbaa !5
  %4 = tail call ptr @freopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.2, ptr noundef %3)
  %5 = load ptr, ptr @stdout, align 8, !tbaa !5
  %6 = tail call ptr @freopen(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.4, ptr noundef %5)
  %7 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @N)
  %8 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %7, ptr noundef nonnull align 8 dereferenceable(8) @M)
  %9 = load i32, ptr @N, align 4, !tbaa !9
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph, label %._crit_edge.thread

._crit_edge.thread:                               ; preds = %0
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  store i32 -1, ptr %1, align 4, !tbaa !9
  br label %._crit_edge35

._crit_edge:                                      ; preds = %.lr.ph
  %11 = icmp sgt i32 %16, 0
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  store i32 -1, ptr %1, align 4, !tbaa !9
  br i1 %11, label %.lr.ph34, label %._crit_edge35

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %12 = getelementptr inbounds [100000 x i64], ptr @F, i64 0, i64 %indvars.iv
  %13 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %12)
  %14 = getelementptr inbounds [100000 x i64], ptr @S, i64 0, i64 %indvars.iv
  %15 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %13, ptr noundef nonnull align 8 dereferenceable(8) %14)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %16 = load i32, ptr @N, align 4, !tbaa !9
  %17 = sext i32 %16 to i64
  %18 = icmp slt i64 %indvars.iv.next, %17
  br i1 %18, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge35:                                    ; preds = %78, %._crit_edge.thread, %._crit_edge
  %19 = load i32, ptr @ans, align 4, !tbaa !9
  %20 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %19)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  ret i32 0

.lr.ph34:                                         ; preds = %._crit_edge, %78
  %indvars.iv39 = phi i64 [ %indvars.iv.next40, %78 ], [ 0, %._crit_edge ]
  %.01431 = phi i64 [ %.2.lcssa, %78 ], [ 0, %._crit_edge ]
  %21 = call noundef i64 @_ZNKSt5dequeISt4pairIiiESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(80) @d) #6
  %22 = and i64 %21, 4294967295
  %.not = icmp eq i64 %22, 0
  br i1 %.not, label %31, label %23

23:                                               ; preds = %.lr.ph34
  %24 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt5dequeISt4pairIiiESaIS1_EE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) @d) #6
  %25 = getelementptr inbounds i8, ptr %24, i64 4
  %26 = load i32, ptr %25, align 4, !tbaa !13
  %27 = trunc i64 %indvars.iv39 to i32
  %28 = add i32 %27, -1
  %29 = icmp eq i32 %26, %28
  br i1 %29, label %30, label %31

30:                                               ; preds = %23
  call void @_ZNSt5dequeISt4pairIiiESaIS1_EE9pop_frontEv(ptr noundef nonnull align 8 dereferenceable(80) @d) #6
  br label %31

31:                                               ; preds = %30, %23, %.lr.ph34
  %.not17 = icmp eq i64 %indvars.iv39, 0
  br i1 %.not17, label %37, label %32

32:                                               ; preds = %31
  %33 = add nsw i64 %indvars.iv39, -1
  %34 = getelementptr inbounds [100000 x i64], ptr @F, i64 0, i64 %33
  %35 = load i64, ptr %34, align 8, !tbaa !15
  %36 = sub nsw i64 %.01431, %35
  br label %37

37:                                               ; preds = %32, %31
  %.1 = phi i64 [ %36, %32 ], [ %.01431, %31 ]
  %38 = load i32, ptr %1, align 4, !tbaa !9
  %39 = load i32, ptr @N, align 4, !tbaa !9
  %40 = add nsw i32 %39, -1
  %41 = icmp slt i32 %38, %40
  %42 = load i64, ptr @M, align 8
  %43 = icmp slt i64 %.1, %42
  %44 = select i1 %41, i1 %43, i1 false
  br i1 %44, label %.lr.ph28, label %._crit_edge29

.lr.ph28:                                         ; preds = %37, %.critedge
  %45 = phi i32 [ %66, %.critedge ], [ %38, %37 ]
  %.226 = phi i64 [ %50, %.critedge ], [ %.1, %37 ]
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %1, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [100000 x i64], ptr @F, i64 0, i64 %47
  %49 = load i64, ptr %48, align 8, !tbaa !15
  %50 = add nsw i64 %49, %.226
  %51 = call noundef i64 @_ZNKSt5dequeISt4pairIiiESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(80) @d) #6
  %52 = and i64 %51, 4294967295
  %.not1922 = icmp eq i64 %52, 0
  br i1 %.not1922, label %.critedge, label %.lr.ph24

.lr.ph24:                                         ; preds = %.lr.ph28, %60
  %53 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt5dequeISt4pairIiiESaIS1_EE4backEv(ptr noundef nonnull align 8 dereferenceable(80) @d) #6
  %54 = load i32, ptr %53, align 4, !tbaa !17
  %55 = sext i32 %54 to i64
  %56 = load i32, ptr %1, align 4, !tbaa !9
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [100000 x i64], ptr @S, i64 0, i64 %57
  %59 = load i64, ptr %58, align 8, !tbaa !15
  %.not20 = icmp slt i64 %59, %55
  br i1 %.not20, label %.critedge, label %60

60:                                               ; preds = %.lr.ph24
  call void @_ZNSt5dequeISt4pairIiiESaIS1_EE8pop_backEv(ptr noundef nonnull align 8 dereferenceable(80) @d) #6
  %61 = call noundef i64 @_ZNKSt5dequeISt4pairIiiESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(80) @d) #6
  %62 = and i64 %61, 4294967295
  %.not19 = icmp eq i64 %62, 0
  br i1 %.not19, label %.critedge, label %.lr.ph24, !llvm.loop !18

.critedge:                                        ; preds = %.lr.ph24, %60, %.lr.ph28
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #6
  %63 = load i32, ptr %1, align 4, !tbaa !9
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [100000 x i64], ptr @S, i64 0, i64 %64
  call void @_ZNSt4pairIiiEC2IRxRiTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS5_S6_EEEbE4typeELb1EEEOS5_OS6_(ptr noundef nonnull align 4 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %65, ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @_ZNSt5dequeISt4pairIiiESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(80) @d, ptr noundef nonnull align 4 dereferenceable(8) %2)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #6
  %66 = load i32, ptr %1, align 4, !tbaa !9
  %67 = load i32, ptr @N, align 4, !tbaa !9
  %68 = add nsw i32 %67, -1
  %69 = icmp slt i32 %66, %68
  %70 = load i64, ptr @M, align 8
  %71 = icmp slt i64 %50, %70
  %72 = select i1 %69, i1 %71, i1 false
  br i1 %72, label %.lr.ph28, label %._crit_edge29, !llvm.loop !19

._crit_edge29:                                    ; preds = %.critedge, %37
  %73 = phi i32 [ %39, %37 ], [ %67, %.critedge ]
  %.2.lcssa = phi i64 [ %.1, %37 ], [ %50, %.critedge ]
  %.lcssa = phi i1 [ %43, %37 ], [ %71, %.critedge ]
  br i1 %.lcssa, label %78, label %74

74:                                               ; preds = %._crit_edge29
  %75 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt5dequeISt4pairIiiESaIS1_EE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) @d) #6
  %76 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @ans, ptr noundef nonnull align 4 dereferenceable(4) %75)
  %77 = load i32, ptr %76, align 4, !tbaa !9
  store i32 %77, ptr @ans, align 4, !tbaa !9
  %.pre = load i32, ptr @N, align 4, !tbaa !9
  br label %78

78:                                               ; preds = %._crit_edge29, %74
  %79 = phi i32 [ %73, %._crit_edge29 ], [ %.pre, %74 ]
  %indvars.iv.next40 = add nuw nsw i64 %indvars.iv39, 1
  %80 = sext i32 %79 to i64
  %81 = icmp slt i64 %indvars.iv.next40, %80
  br i1 %81, label %.lr.ph34, label %._crit_edge35, !llvm.loop !20
}

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1

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

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

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

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

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

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

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

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

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

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

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

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) 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 = { "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 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !10, i64 4}
!14 = !{!"_ZTSSt4pairIiiE", !10, i64 0, !10, i64 4}
!15 = !{!16, !16, i64 0}
!16 = !{!"long long", !7, i64 0}
!17 = !{!14, !10, i64 0}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !12}
!20 = distinct !{!20, !12}


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