; LLVM IR from bqi343/cp-notebook :: Contests/USACO Solutions/2017-18/Open 2018/Plat (disrupt)

; 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::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 }
%"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 }
%struct.anon = type { [16 x [50001 x i32]], [16 x [50001 x i32]], [50001 x i32], [50001 x i32] }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"struct.std::pair" = type { i32, i32 }

@adj = external dso_local global [50001 x %"class.std::vector"], align 16
@N = external dso_local global i32, align 4
@M = external dso_local global i32, align 4
@ans = external dso_local global [50001 x i32], align 16
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.5 = 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
@L = external hidden global %struct.anon, align 4
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1

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

19:                                               ; preds = %34, %0
  %20 = load i32, ptr %2, align 4, !tbaa !9
  %21 = load i32, ptr @N, align 4, !tbaa !9
  %22 = sub nsw i32 %21, 1
  %23 = icmp slt i32 %20, %22
  br i1 %23, label %25, label %24

24:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %37

25:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  %26 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %27 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %26, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %28 = load i32, ptr %3, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [50001 x %"class.std::vector"], ptr @adj, i64 0, i64 %29
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  call void @_ZNSt4pairIiiEC2IRiS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8) %5, ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %2)
  call void @_ZNSt6vectorISt4pairIiiESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24) %30, ptr noundef nonnull align 4 dereferenceable(8) %5)
  %31 = load i32, ptr %4, align 4, !tbaa !9
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [50001 x %"class.std::vector"], ptr @adj, i64 0, i64 %32
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  call void @_ZNSt4pairIiiEC2IRiS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8) %6, ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %2)
  call void @_ZNSt6vectorISt4pairIiiESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24) %33, ptr noundef nonnull align 4 dereferenceable(8) %6)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %34

34:                                               ; preds = %25
  %35 = load i32, ptr %2, align 4, !tbaa !9
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %2, align 4, !tbaa !9
  br label %19, !llvm.loop !11

37:                                               ; preds = %24
  call void @"_ZN3$_03genEv"(ptr noundef nonnull align 4 dereferenceable(6800136) @L)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %38

38:                                               ; preds = %50, %37
  %39 = load i32, ptr %7, align 4, !tbaa !9
  %40 = load i32, ptr @M, align 4, !tbaa !9
  %41 = icmp slt i32 %39, %40
  br i1 %41, label %43, label %42

42:                                               ; preds = %38
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %53

43:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %44 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %8)
  %45 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %44, ptr noundef nonnull align 4 dereferenceable(4) %9)
  %46 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %45, ptr noundef nonnull align 4 dereferenceable(4) %10)
  %47 = load i32, ptr %8, align 4, !tbaa !9
  %48 = load i32, ptr %9, align 4, !tbaa !9
  %49 = load i32, ptr %10, align 4, !tbaa !9
  call void @"_ZN3$_02adEiii"(ptr noundef nonnull align 4 dereferenceable(6800136) @L, i32 noundef %47, i32 noundef %48, i32 noundef %49)
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %50

50:                                               ; preds = %43
  %51 = load i32, ptr %7, align 4, !tbaa !9
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr %7, align 4, !tbaa !9
  br label %38, !llvm.loop !13

53:                                               ; preds = %42
  call void @"_ZN3$_04pushEv"(ptr noundef nonnull align 4 dereferenceable(6800136) @L)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 1, ptr %11, align 4, !tbaa !9
  br label %54

54:                                               ; preds = %92, %53
  %55 = load i32, ptr %11, align 4, !tbaa !9
  %56 = load i32, ptr @N, align 4, !tbaa !9
  %57 = add nsw i32 %56, 1
  %58 = icmp slt i32 %55, %57
  br i1 %58, label %60, label %59

59:                                               ; preds = %54
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %95

60:                                               ; preds = %54
  %61 = load i32, ptr %11, align 4, !tbaa !9
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [50001 x i32], ptr getelementptr inbounds (%struct.anon, ptr @L, i32 0, i32 2), i64 0, i64 %62
  %64 = load i32, ptr %63, align 4, !tbaa !9
  %65 = icmp ne i32 %64, -1
  br i1 %65, label %66, label %91

66:                                               ; preds = %60
  %67 = load i32, ptr %11, align 4, !tbaa !9
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [50001 x i32], ptr getelementptr inbounds (%struct.anon, ptr @L, i32 0, i32 1), i64 0, i64 %68
  %70 = load i32, ptr %69, align 4, !tbaa !9
  %71 = icmp eq i32 %70, 1000000007
  br i1 %71, label %72, label %79

72:                                               ; preds = %66
  %73 = load i32, ptr %11, align 4, !tbaa !9
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [50001 x i32], ptr getelementptr inbounds (%struct.anon, ptr @L, i32 0, i32 2), i64 0, i64 %74
  %76 = load i32, ptr %75, align 4, !tbaa !9
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [50001 x i32], ptr @ans, i64 0, i64 %77
  store i32 -1, ptr %78, align 4, !tbaa !9
  br label %90

79:                                               ; preds = %66
  %80 = load i32, ptr %11, align 4, !tbaa !9
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [50001 x i32], ptr getelementptr inbounds (%struct.anon, ptr @L, i32 0, i32 1), i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !9
  %84 = load i32, ptr %11, align 4, !tbaa !9
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [50001 x i32], ptr getelementptr inbounds (%struct.anon, ptr @L, i32 0, i32 2), i64 0, i64 %85
  %87 = load i32, ptr %86, align 4, !tbaa !9
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [50001 x i32], ptr @ans, i64 0, i64 %88
  store i32 %83, ptr %89, align 4, !tbaa !9
  br label %90

90:                                               ; preds = %79, %72
  br label %91

91:                                               ; preds = %90, %60
  br label %92

92:                                               ; preds = %91
  %93 = load i32, ptr %11, align 4, !tbaa !9
  %94 = add nsw i32 %93, 1
  store i32 %94, ptr %11, align 4, !tbaa !9
  br label %54, !llvm.loop !14

95:                                               ; preds = %59
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %96

96:                                               ; preds = %109, %95
  %97 = load i32, ptr %12, align 4, !tbaa !9
  %98 = load i32, ptr @N, align 4, !tbaa !9
  %99 = sub nsw i32 %98, 1
  %100 = icmp slt i32 %97, %99
  br i1 %100, label %102, label %101

101:                                              ; preds = %96
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %112

102:                                              ; preds = %96
  %103 = load i32, ptr %12, align 4, !tbaa !9
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [50001 x i32], ptr @ans, i64 0, i64 %104
  %106 = load i32, ptr %105, align 4, !tbaa !9
  %107 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %106)
  %108 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %107, ptr noundef @.str.6)
  br label %109

109:                                              ; preds = %102
  %110 = load i32, ptr %12, align 4, !tbaa !9
  %111 = add nsw i32 %110, 1
  store i32 %111, ptr %12, align 4, !tbaa !9
  br label %96, !llvm.loop !15

112:                                              ; preds = %101
  %113 = load i32, ptr %1, align 4
  ret i32 %113
}

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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt4pairIiiEC2IRiS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #4 align 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 hidden void @"_ZN3$_03genEv"(ptr noundef nonnull align 4 dereferenceable(6800136)) #3 align 2

; Function Attrs: mustprogress uwtable
declare hidden void @"_ZN3$_02adEiii"(ptr noundef nonnull align 4 dereferenceable(6800136), i32 noundef, i32 noundef, i32 noundef) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @"_ZN3$_04pushEv"(ptr noundef nonnull align 4 dereferenceable(6800136)) #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #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 = { 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 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"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 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !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::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 }
%"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 }
%struct.anon = type { [16 x [50001 x i32]], [16 x [50001 x i32]], [50001 x i32], [50001 x i32] }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"struct.std::pair" = type { i32, i32 }

@adj = external dso_local global [50001 x %"class.std::vector"], align 16
@N = external dso_local global i32, align 4
@M = external dso_local global i32, align 4
@ans = external dso_local local_unnamed_addr global [50001 x i32], align 16
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external local_unnamed_addr global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.5 = 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
@L = external hidden global %struct.anon, align 4
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca %"struct.std::pair", align 4
  %5 = alloca %"struct.std::pair", align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = load ptr, ptr @stdin, align 8, !tbaa !5
  %10 = tail call ptr @freopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.3, ptr noundef %9)
  %11 = load ptr, ptr @stdout, align 8, !tbaa !5
  %12 = tail call ptr @freopen(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.5, ptr noundef %11)
  %13 = 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)
  %14 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %13, ptr noundef nonnull align 4 dereferenceable(4) @M)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  store i32 0, ptr %1, align 4, !tbaa !9
  %15 = load i32, ptr @N, align 4, !tbaa !9
  %16 = icmp sgt i32 %15, 1
  br i1 %16, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  call void @"_ZN3$_03genEv"(ptr noundef nonnull align 4 dereferenceable(6800136) @L)
  %17 = load i32, ptr @M, align 4, !tbaa !9
  %18 = icmp sgt i32 %17, 0
  br i1 %18, label %.lr.ph20, label %._crit_edge21

.lr.ph:                                           ; preds = %0, %.lr.ph
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #6
  %19 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %20 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %19, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %21 = load i32, ptr %2, align 4, !tbaa !9
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [50001 x %"class.std::vector"], ptr @adj, i64 0, i64 %22
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  call void @_ZNSt4pairIiiEC2IRiS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8) %4, ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @_ZNSt6vectorISt4pairIiiESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24) %23, ptr noundef nonnull align 4 dereferenceable(8) %4)
  %24 = load i32, ptr %3, align 4, !tbaa !9
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [50001 x %"class.std::vector"], ptr @adj, i64 0, i64 %25
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  call void @_ZNSt4pairIiiEC2IRiS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8) %5, ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @_ZNSt6vectorISt4pairIiiESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24) %26, ptr noundef nonnull align 4 dereferenceable(8) %5)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  %27 = load i32, ptr %1, align 4, !tbaa !9
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %1, align 4, !tbaa !9
  %29 = load i32, ptr @N, align 4, !tbaa !9
  %30 = add nsw i32 %29, -1
  %31 = icmp slt i32 %28, %30
  br i1 %31, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge21:                                    ; preds = %.lr.ph20, %._crit_edge
  call void @"_ZN3$_04pushEv"(ptr noundef nonnull align 4 dereferenceable(6800136) @L)
  %32 = load i32, ptr @N, align 4, !tbaa !9
  %.not22 = icmp slt i32 %32, 1
  br i1 %.not22, label %._crit_edge28, label %.lr.ph25.preheader

.lr.ph25.preheader:                               ; preds = %._crit_edge21
  %33 = zext nneg i32 %32 to i64
  %xtraiter = and i64 %33, 1
  %34 = icmp eq i32 %32, 1
  br i1 %34, label %.preheader.unr-lcssa, label %.lr.ph25.preheader.new

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

.lr.ph20:                                         ; preds = %._crit_edge, %.lr.ph20
  %.01418 = phi i32 [ %41, %.lr.ph20 ], [ 0, %._crit_edge ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #6
  %35 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %6)
  %36 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %35, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %37 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %36, ptr noundef nonnull align 4 dereferenceable(4) %8)
  %38 = load i32, ptr %6, align 4, !tbaa !9
  %39 = load i32, ptr %7, align 4, !tbaa !9
  %40 = load i32, ptr %8, align 4, !tbaa !9
  call void @"_ZN3$_02adEiii"(ptr noundef nonnull align 4 dereferenceable(6800136) @L, i32 noundef %38, i32 noundef %39, i32 noundef %40)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #6
  %41 = add nuw nsw i32 %.01418, 1
  %42 = load i32, ptr @M, align 4, !tbaa !9
  %43 = icmp slt i32 %41, %42
  br i1 %43, label %.lr.ph20, label %._crit_edge21, !llvm.loop !13

.preheader.unr-lcssa:                             ; preds = %65, %.lr.ph25.preheader
  %indvars.iv.unr = phi i64 [ 1, %.lr.ph25.preheader ], [ %indvars.iv.next.1, %65 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.preheader, label %.lr.ph25.epil

.lr.ph25.epil:                                    ; preds = %.preheader.unr-lcssa
  %44 = getelementptr inbounds [50001 x i32], ptr getelementptr inbounds (i8, ptr @L, i64 6400128), i64 0, i64 %indvars.iv.unr
  %45 = load i32, ptr %44, align 4, !tbaa !9
  %.not17.epil = icmp eq i32 %45, -1
  br i1 %.not17.epil, label %.preheader, label %.sink.split.epil

.sink.split.epil:                                 ; preds = %.lr.ph25.epil
  %46 = getelementptr inbounds [50001 x i32], ptr getelementptr inbounds (i8, ptr @L, i64 3200064), i64 0, i64 %indvars.iv.unr
  %47 = load i32, ptr %46, align 4, !tbaa !9
  %48 = icmp eq i32 %47, 1000000007
  %49 = sext i32 %45 to i64
  %50 = getelementptr inbounds [50001 x i32], ptr @ans, i64 0, i64 %49
  %..epil = select i1 %48, i32 -1, i32 %47
  store i32 %..epil, ptr %50, align 4, !tbaa !9
  br label %.preheader

.preheader:                                       ; preds = %.lr.ph25.epil, %.sink.split.epil, %.preheader.unr-lcssa
  %.not = icmp eq i32 %32, 1
  br i1 %.not, label %._crit_edge28, label %.lr.ph27

.lr.ph25:                                         ; preds = %65, %.lr.ph25.preheader.new
  %indvars.iv = phi i64 [ 1, %.lr.ph25.preheader.new ], [ %indvars.iv.next.1, %65 ]
  %niter = phi i64 [ 0, %.lr.ph25.preheader.new ], [ %niter.next.1, %65 ]
  %51 = getelementptr inbounds [50001 x i32], ptr getelementptr inbounds (i8, ptr @L, i64 6400128), i64 0, i64 %indvars.iv
  %52 = load i32, ptr %51, align 4, !tbaa !9
  %.not17 = icmp eq i32 %52, -1
  br i1 %.not17, label %.lr.ph25.1, label %.sink.split

.sink.split:                                      ; preds = %.lr.ph25
  %53 = getelementptr inbounds [50001 x i32], ptr getelementptr inbounds (i8, ptr @L, i64 3200064), i64 0, i64 %indvars.iv
  %54 = load i32, ptr %53, align 4, !tbaa !9
  %55 = icmp eq i32 %54, 1000000007
  %56 = sext i32 %52 to i64
  %57 = getelementptr inbounds [50001 x i32], ptr @ans, i64 0, i64 %56
  %. = select i1 %55, i32 -1, i32 %54
  store i32 %., ptr %57, align 4, !tbaa !9
  br label %.lr.ph25.1

.lr.ph25.1:                                       ; preds = %.sink.split, %.lr.ph25
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %58 = getelementptr inbounds [50001 x i32], ptr getelementptr inbounds (i8, ptr @L, i64 6400128), i64 0, i64 %indvars.iv.next
  %59 = load i32, ptr %58, align 4, !tbaa !9
  %.not17.1 = icmp eq i32 %59, -1
  br i1 %.not17.1, label %65, label %.sink.split.1

.sink.split.1:                                    ; preds = %.lr.ph25.1
  %60 = getelementptr inbounds [50001 x i32], ptr getelementptr inbounds (i8, ptr @L, i64 3200064), i64 0, i64 %indvars.iv.next
  %61 = load i32, ptr %60, align 4, !tbaa !9
  %62 = icmp eq i32 %61, 1000000007
  %63 = sext i32 %59 to i64
  %64 = getelementptr inbounds [50001 x i32], ptr @ans, i64 0, i64 %63
  %..1 = select i1 %62, i32 -1, i32 %61
  store i32 %..1, ptr %64, align 4, !tbaa !9
  br label %65

65:                                               ; preds = %.sink.split.1, %.lr.ph25.1
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %.preheader.unr-lcssa, label %.lr.ph25, !llvm.loop !14

._crit_edge28:                                    ; preds = %.lr.ph27, %._crit_edge21, %.preheader
  ret i32 0

.lr.ph27:                                         ; preds = %.preheader, %.lr.ph27
  %indvars.iv30 = phi i64 [ %indvars.iv.next31, %.lr.ph27 ], [ 0, %.preheader ]
  %66 = getelementptr inbounds [50001 x i32], ptr @ans, i64 0, i64 %indvars.iv30
  %67 = load i32, ptr %66, align 4, !tbaa !9
  %68 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %67)
  %69 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %68, ptr noundef nonnull @.str.6)
  %indvars.iv.next31 = add nuw nsw i64 %indvars.iv30, 1
  %70 = load i32, ptr @N, align 4, !tbaa !9
  %71 = add nsw i32 %70, -1
  %72 = sext i32 %71 to i64
  %73 = icmp slt i64 %indvars.iv.next31, %72
  br i1 %73, label %.lr.ph27, label %._crit_edge28, !llvm.loop !15
}

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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt4pairIiiEC2IRiS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #4 align 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 hidden void @"_ZN3$_03genEv"(ptr noundef nonnull align 4 dereferenceable(6800136)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare hidden void @"_ZN3$_02adEiii"(ptr noundef nonnull align 4 dereferenceable(6800136), i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @"_ZN3$_04pushEv"(ptr noundef nonnull align 4 dereferenceable(6800136)) local_unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) 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 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 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"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 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}


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