; LLVM IR from eyangch/competitive-programming :: Codeforces/1615 (e)

; 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<long long, std::allocator<long long>>::_Vector_impl" }
%"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl" = type { %"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl_data" }
%"struct.std::_Vector_base<long long, std::allocator<long long>>::_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 }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%class.anon = type { i8 }
%class.anon.0 = type { i8 }

@N = external dso_local global i64, align 8
@K = external dso_local global i64, align 8
@graph = external dso_local global [200000 x %"class.std::vector"], align 16
@d = external dso_local global [200000 x i64], align 16
@o = external dso_local global [200000 x i64], align 16
@p = external dso_local global [200000 x i64], align 16
@f = external dso_local global [200000 x i64], align 16
@vis = external dso_local global [200000 x i8], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3dfsxxx(i64 noundef, i64 noundef, i64 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 i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca %class.anon, align 1
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca i64, align 8
  %11 = alloca %class.anon.0, align 1
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  %19 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %20 = getelementptr i8, ptr %19, i64 -24
  %21 = load i64, ptr %20, align 8
  %22 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %21
  %23 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %22, ptr noundef null)
  %24 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %25 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @N)
  %26 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %25, ptr noundef nonnull align 8 dereferenceable(8) @K)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #7
  store i64 0, ptr %2, align 8, !tbaa !8
  br label %27

27:                                               ; preds = %46, %0
  %28 = load i64, ptr %2, align 8, !tbaa !8
  %29 = load i64, ptr @N, align 8, !tbaa !8
  %30 = sub nsw i64 %29, 1
  %31 = icmp slt i64 %28, %30
  br i1 %31, label %33, label %32

32:                                               ; preds = %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #7
  br label %49

33:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #7
  %34 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %35 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %34, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %36 = load i64, ptr %3, align 8, !tbaa !8
  %37 = sub nsw i64 %36, 1
  %38 = getelementptr inbounds [200000 x %"class.std::vector"], ptr @graph, i64 0, i64 %37
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  %39 = load i64, ptr %4, align 8, !tbaa !8
  %40 = sub nsw i64 %39, 1
  store i64 %40, ptr %5, align 8, !tbaa !8
  call void @_ZNSt6vectorIxSaIxEE9push_backEOx(ptr noundef nonnull align 8 dereferenceable(24) %38, ptr noundef nonnull align 8 dereferenceable(8) %5)
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  %41 = load i64, ptr %4, align 8, !tbaa !8
  %42 = sub nsw i64 %41, 1
  %43 = getelementptr inbounds [200000 x %"class.std::vector"], ptr @graph, i64 0, i64 %42
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  %44 = load i64, ptr %3, align 8, !tbaa !8
  %45 = sub nsw i64 %44, 1
  store i64 %45, ptr %6, align 8, !tbaa !8
  call void @_ZNSt6vectorIxSaIxEE9push_backEOx(ptr noundef nonnull align 8 dereferenceable(24) %43, ptr noundef nonnull align 8 dereferenceable(8) %6)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #7
  br label %46

46:                                               ; preds = %33
  %47 = load i64, ptr %2, align 8, !tbaa !8
  %48 = add nsw i64 %47, 1
  store i64 %48, ptr %2, align 8, !tbaa !8
  br label %27, !llvm.loop !11

49:                                               ; preds = %32
  call void @_Z3dfsxxx(i64 noundef 0, i64 noundef 0, i64 noundef 0)
  %50 = load i64, ptr @N, align 8, !tbaa !8
  %51 = getelementptr inbounds i64, ptr @o, i64 %50
  call void @_ZSt4iotaIPxiEvT_S1_T0_(ptr noundef @o, ptr noundef %51, i32 noundef 0)
  %52 = load i64, ptr @N, align 8, !tbaa !8
  %53 = getelementptr inbounds i64, ptr @o, i64 %52
  call void @"_ZSt4sortIPxZ4mainE3$_0EvT_S2_T0_"(ptr noundef @o, ptr noundef %53)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  store i64 0, ptr %8, align 8, !tbaa !8
  br label %54

54:                                               ; preds = %90, %49
  %55 = load i64, ptr %8, align 8, !tbaa !8
  %56 = load i64, ptr @N, align 8, !tbaa !8
  %57 = icmp slt i64 %55, %56
  br i1 %57, label %59, label %58

58:                                               ; preds = %54
  store i32 5, ptr %9, align 4
  br label %93

59:                                               ; preds = %54
  %60 = load i64, ptr %8, align 8, !tbaa !8
  %61 = getelementptr inbounds [200000 x i64], ptr @o, i64 0, i64 %60
  %62 = load i64, ptr %61, align 8, !tbaa !8
  %63 = getelementptr inbounds [200000 x i64], ptr @d, i64 0, i64 %62
  %64 = load i64, ptr %63, align 8, !tbaa !8
  %65 = icmp eq i64 %64, 0
  br i1 %65, label %66, label %67

66:                                               ; preds = %59
  store i32 5, ptr %9, align 4
  br label %93

67:                                               ; preds = %59
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  %68 = load i64, ptr %8, align 8, !tbaa !8
  %69 = getelementptr inbounds [200000 x i64], ptr @o, i64 0, i64 %68
  %70 = load i64, ptr %69, align 8, !tbaa !8
  store i64 %70, ptr %10, align 8, !tbaa !8
  br label %71

71:                                               ; preds = %77, %67
  %72 = load i64, ptr %10, align 8, !tbaa !8
  %73 = getelementptr inbounds [200000 x i8], ptr @vis, i64 0, i64 %72
  %74 = load i8, ptr %73, align 1, !tbaa !13, !range !15, !noundef !16
  %75 = trunc i8 %74 to i1
  %76 = xor i1 %75, true
  br i1 %76, label %77, label %89

77:                                               ; preds = %71
  %78 = load i64, ptr %10, align 8, !tbaa !8
  %79 = getelementptr inbounds [200000 x i8], ptr @vis, i64 0, i64 %78
  store i8 1, ptr %79, align 1, !tbaa !13
  %80 = load i64, ptr %10, align 8, !tbaa !8
  %81 = getelementptr inbounds [200000 x i64], ptr @p, i64 0, i64 %80
  %82 = load i64, ptr %81, align 8, !tbaa !8
  store i64 %82, ptr %10, align 8, !tbaa !8
  %83 = load i64, ptr %8, align 8, !tbaa !8
  %84 = getelementptr inbounds [200000 x i64], ptr @o, i64 0, i64 %83
  %85 = load i64, ptr %84, align 8, !tbaa !8
  %86 = getelementptr inbounds [200000 x i64], ptr @f, i64 0, i64 %85
  %87 = load i64, ptr %86, align 8, !tbaa !8
  %88 = add nsw i64 %87, 1
  store i64 %88, ptr %86, align 8, !tbaa !8
  br label %71, !llvm.loop !17

89:                                               ; preds = %71
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  br label %90

90:                                               ; preds = %89
  %91 = load i64, ptr %8, align 8, !tbaa !8
  %92 = add nsw i64 %91, 1
  store i64 %92, ptr %8, align 8, !tbaa !8
  br label %54, !llvm.loop !18

93:                                               ; preds = %66, %58
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  br label %94

94:                                               ; preds = %93
  %95 = load i64, ptr @N, align 8, !tbaa !8
  %96 = getelementptr inbounds i64, ptr @o, i64 %95
  call void @"_ZSt4sortIPxZ4mainE3$_1EvT_S2_T0_"(ptr noundef @o, ptr noundef %96)
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  store i64 -1000000000000000, ptr %12, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  store i64 0, ptr %13, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  %97 = load i64, ptr @N, align 8, !tbaa !8
  store i64 %97, ptr %14, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #7
  store i64 0, ptr %15, align 8, !tbaa !8
  br label %98

98:                                               ; preds = %130, %94
  %99 = load i64, ptr %15, align 8, !tbaa !8
  %100 = load i64, ptr @K, align 8, !tbaa !8
  %101 = icmp slt i64 %99, %100
  br i1 %101, label %103, label %102

102:                                              ; preds = %98
  store i32 10, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  br label %133

103:                                              ; preds = %98
  %104 = load i64, ptr %15, align 8, !tbaa !8
  %105 = getelementptr inbounds [200000 x i64], ptr @o, i64 0, i64 %104
  %106 = load i64, ptr %105, align 8, !tbaa !8
  %107 = getelementptr inbounds [200000 x i64], ptr @f, i64 0, i64 %106
  %108 = load i64, ptr %107, align 8, !tbaa !8
  %109 = load i64, ptr %14, align 8, !tbaa !8
  %110 = sub nsw i64 %109, %108
  store i64 %110, ptr %14, align 8, !tbaa !8
  %111 = load i64, ptr %13, align 8, !tbaa !8
  %112 = add nsw i64 %111, 1
  store i64 %112, ptr %13, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #7
  %113 = load i64, ptr @N, align 8, !tbaa !8
  %114 = load i64, ptr %13, align 8, !tbaa !8
  %115 = sub nsw i64 %113, %114
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #7
  %116 = load i64, ptr @N, align 8, !tbaa !8
  %117 = sdiv i64 %116, 2
  store i64 %117, ptr %17, align 8, !tbaa !8
  %118 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %17, ptr noundef nonnull align 8 dereferenceable(8) %14)
  %119 = load i64, ptr %118, align 8, !tbaa !8
  %120 = sub nsw i64 %115, %119
  %121 = load i64, ptr %13, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #7
  %122 = load i64, ptr @N, align 8, !tbaa !8
  %123 = sdiv i64 %122, 2
  store i64 %123, ptr %18, align 8, !tbaa !8
  %124 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %18, ptr noundef nonnull align 8 dereferenceable(8) %14)
  %125 = load i64, ptr %124, align 8, !tbaa !8
  %126 = sub nsw i64 %121, %125
  %127 = mul nsw i64 %120, %126
  store i64 %127, ptr %16, align 8, !tbaa !8
  %128 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %12, ptr noundef nonnull align 8 dereferenceable(8) %16)
  %129 = load i64, ptr %128, align 8, !tbaa !8
  store i64 %129, ptr %12, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  br label %130

130:                                              ; preds = %103
  %131 = load i64, ptr %15, align 8, !tbaa !8
  %132 = add nsw i64 %131, 1
  store i64 %132, ptr %15, align 8, !tbaa !8
  br label %98, !llvm.loop !19

133:                                              ; preds = %102
  %134 = load i64, ptr %12, align 8, !tbaa !8
  %135 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %134)
  %136 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %135, i8 noundef signext 10)
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  %137 = load i32, ptr %1, align 4
  ret i32 %137
}

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) #3 align 2

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) #4

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZSt4iotaIPxiEvT_S1_T0_(ptr noundef, ptr noundef, i32 noundef) #3

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZSt4sortIPxZ4mainE3$_0EvT_S2_T0_"(ptr noundef, ptr noundef) #5

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZSt4sortIPxZ4mainE3$_1EvT_S2_T0_"(ptr noundef, ptr noundef) #5

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #6

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #6

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) #5

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #0 align 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 = { 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 = { 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 #4 = { "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 = { 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 #7 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"long long", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"bool", !10, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !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<long long, std::allocator<long long>>::_Vector_impl" }
%"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl" = type { %"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl_data" }
%"struct.std::_Vector_base<long long, std::allocator<long long>>::_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 }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@N = external dso_local global i64, align 8
@K = external dso_local global i64, align 8
@graph = external dso_local global [200000 x %"class.std::vector"], align 16
@d = external dso_local local_unnamed_addr global [200000 x i64], align 16
@o = external dso_local global [200000 x i64], align 16
@p = external dso_local local_unnamed_addr global [200000 x i64], align 16
@f = external dso_local local_unnamed_addr global [200000 x i64], align 16
@vis = external dso_local local_unnamed_addr global [200000 x i8], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

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

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

; Function Attrs: mustprogress 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() local_unnamed_addr #2 {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %11 = getelementptr i8, ptr %10, i64 -24
  %12 = load i64, ptr %11, align 8
  %13 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %12
  %14 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %13, ptr noundef null)
  %15 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %16 = 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) @N)
  %17 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %16, ptr noundef nonnull align 8 dereferenceable(8) @K)
  %18 = load i64, ptr @N, align 8, !tbaa !8
  %19 = icmp sgt i64 %18, 1
  br i1 %19, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %0
  call void @_Z3dfsxxx(i64 noundef 0, i64 noundef 0, i64 noundef 0)
  %20 = load i64, ptr @N, align 8, !tbaa !8
  %21 = getelementptr inbounds i64, ptr @o, i64 %20
  call void @_ZSt4iotaIPxiEvT_S1_T0_(ptr noundef nonnull @o, ptr noundef nonnull %21, i32 noundef 0)
  %22 = load i64, ptr @N, align 8, !tbaa !8
  %23 = getelementptr inbounds i64, ptr @o, i64 %22
  call void @"_ZSt4sortIPxZ4mainE3$_0EvT_S2_T0_"(ptr noundef nonnull @o, ptr noundef nonnull %23)
  %24 = load i64, ptr @N, align 8, !tbaa !8
  %25 = icmp sgt i64 %24, 0
  br i1 %25, label %.lr.ph30, label %._crit_edge31

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.02023 = phi i64 [ %38, %.lr.ph ], [ 0, %0 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #7
  %26 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %1)
  %27 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %26, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %28 = load i64, ptr %1, align 8, !tbaa !8
  %29 = add nsw i64 %28, -1
  %30 = getelementptr inbounds [200000 x %"class.std::vector"], ptr @graph, i64 0, i64 %29
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #7
  %31 = load i64, ptr %2, align 8, !tbaa !8
  %32 = add nsw i64 %31, -1
  store i64 %32, ptr %3, align 8, !tbaa !8
  call void @_ZNSt6vectorIxSaIxEE9push_backEOx(ptr noundef nonnull align 8 dereferenceable(24) %30, ptr noundef nonnull align 8 dereferenceable(8) %3)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #7
  %33 = load i64, ptr %2, align 8, !tbaa !8
  %34 = add nsw i64 %33, -1
  %35 = getelementptr inbounds [200000 x %"class.std::vector"], ptr @graph, i64 0, i64 %34
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #7
  %36 = load i64, ptr %1, align 8, !tbaa !8
  %37 = add nsw i64 %36, -1
  store i64 %37, ptr %4, align 8, !tbaa !8
  call void @_ZNSt6vectorIxSaIxEE9push_backEOx(ptr noundef nonnull align 8 dereferenceable(24) %35, ptr noundef nonnull align 8 dereferenceable(8) %4)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #7
  %38 = add nuw nsw i64 %.02023, 1
  %39 = load i64, ptr @N, align 8, !tbaa !8
  %40 = add nsw i64 %39, -1
  %41 = icmp slt i64 %38, %40
  br i1 %41, label %.lr.ph, label %._crit_edge, !llvm.loop !11

.lr.ph30:                                         ; preds = %._crit_edge, %60
  %.01928 = phi i64 [ %61, %60 ], [ 0, %._crit_edge ]
  %42 = getelementptr inbounds [200000 x i64], ptr @o, i64 0, i64 %.01928
  %43 = load i64, ptr %42, align 8, !tbaa !8
  %44 = getelementptr inbounds [200000 x i64], ptr @d, i64 0, i64 %43
  %45 = load i64, ptr %44, align 8, !tbaa !8
  %46 = icmp eq i64 %45, 0
  br i1 %46, label %._crit_edge31, label %.preheader

.preheader:                                       ; preds = %.lr.ph30
  %47 = getelementptr inbounds [200000 x i8], ptr @vis, i64 0, i64 %43
  %48 = load i8, ptr %47, align 1, !tbaa !13, !range !15, !noundef !16
  %49 = trunc nuw i8 %48 to i1
  br i1 %49, label %60, label %.lr.ph25

.lr.ph25:                                         ; preds = %.preheader
  %50 = getelementptr inbounds [200000 x i64], ptr @f, i64 0, i64 %43
  %.promoted = load i64, ptr %50, align 8, !tbaa !8
  br label %51

51:                                               ; preds = %.lr.ph25, %51
  %52 = phi i64 [ %.promoted, %.lr.ph25 ], [ %56, %51 ]
  %53 = phi ptr [ %47, %.lr.ph25 ], [ %57, %51 ]
  %.01824 = phi i64 [ %43, %.lr.ph25 ], [ %55, %51 ]
  store i8 1, ptr %53, align 1, !tbaa !13
  %54 = getelementptr inbounds [200000 x i64], ptr @p, i64 0, i64 %.01824
  %55 = load i64, ptr %54, align 8, !tbaa !8
  %56 = add nsw i64 %52, 1
  %57 = getelementptr inbounds [200000 x i8], ptr @vis, i64 0, i64 %55
  %58 = load i8, ptr %57, align 1, !tbaa !13, !range !15, !noundef !16
  %59 = trunc nuw i8 %58 to i1
  br i1 %59, label %._crit_edge26, label %51, !llvm.loop !17

._crit_edge26:                                    ; preds = %51
  store i64 %56, ptr %50, align 8, !tbaa !8
  br label %60

60:                                               ; preds = %._crit_edge26, %.preheader
  %61 = add nuw nsw i64 %.01928, 1
  %exitcond.not = icmp eq i64 %61, %24
  br i1 %exitcond.not, label %._crit_edge31, label %.lr.ph30, !llvm.loop !18

._crit_edge31:                                    ; preds = %60, %.lr.ph30, %._crit_edge
  %62 = getelementptr inbounds i64, ptr @o, i64 %24
  call void @"_ZSt4sortIPxZ4mainE3$_1EvT_S2_T0_"(ptr noundef nonnull @o, ptr noundef nonnull %62)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #7
  store i64 -1000000000000000, ptr %5, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #7
  %63 = load i64, ptr @N, align 8, !tbaa !8
  store i64 %63, ptr %6, align 8, !tbaa !8
  %64 = load i64, ptr @K, align 8, !tbaa !8
  %65 = icmp sgt i64 %64, 0
  br i1 %65, label %.lr.ph37, label %._crit_edge38

._crit_edge38:                                    ; preds = %.lr.ph37, %._crit_edge31
  %66 = phi i64 [ -1000000000000000, %._crit_edge31 ], [ %88, %.lr.ph37 ]
  %67 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %66)
  %68 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %67, i8 noundef signext 10)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #7
  ret i32 0

.lr.ph37:                                         ; preds = %._crit_edge31, %.lr.ph37
  %.035 = phi i64 [ %75, %.lr.ph37 ], [ 0, %._crit_edge31 ]
  %69 = getelementptr inbounds [200000 x i64], ptr @o, i64 0, i64 %.035
  %70 = load i64, ptr %69, align 8, !tbaa !8
  %71 = getelementptr inbounds [200000 x i64], ptr @f, i64 0, i64 %70
  %72 = load i64, ptr %71, align 8, !tbaa !8
  %73 = load i64, ptr %6, align 8, !tbaa !8
  %74 = sub nsw i64 %73, %72
  store i64 %74, ptr %6, align 8, !tbaa !8
  %75 = add nuw nsw i64 %.035, 1
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #7
  %76 = load i64, ptr @N, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #7
  %77 = sdiv i64 %76, 2
  store i64 %77, ptr %8, align 8, !tbaa !8
  %78 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef nonnull align 8 dereferenceable(8) %6)
  %79 = load i64, ptr %78, align 8, !tbaa !8
  %.neg = xor i64 %.035, -1
  %.neg22 = add i64 %76, %.neg
  %80 = sub i64 %.neg22, %79
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #7
  %81 = load i64, ptr @N, align 8, !tbaa !8
  %82 = sdiv i64 %81, 2
  store i64 %82, ptr %9, align 8, !tbaa !8
  %83 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef nonnull align 8 dereferenceable(8) %6)
  %84 = load i64, ptr %83, align 8, !tbaa !8
  %85 = sub nsw i64 %75, %84
  %86 = mul nsw i64 %85, %80
  store i64 %86, ptr %7, align 8, !tbaa !8
  %87 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %7)
  %88 = load i64, ptr %87, align 8, !tbaa !8
  store i64 %88, ptr %5, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #7
  %89 = load i64, ptr @K, align 8, !tbaa !8
  %90 = icmp slt i64 %75, %89
  br i1 %90, label %.lr.ph37, label %._crit_edge38, !llvm.loop !19
}

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) local_unnamed_addr #3 align 2

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) local_unnamed_addr #4

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZSt4iotaIPxiEvT_S1_T0_(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZSt4sortIPxZ4mainE3$_0EvT_S2_T0_"(ptr noundef, ptr noundef) local_unnamed_addr #5

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZSt4sortIPxZ4mainE3$_1EvT_S2_T0_"(ptr noundef, ptr noundef) local_unnamed_addr #5

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #6

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #6

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) local_unnamed_addr #5

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) local_unnamed_addr #0 align 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 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 = { 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 #4 = { "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 = { 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 #7 = { nounwind }

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

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


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