; LLVM IR from DionysiosB/CodeForces :: 0200-0299/219D-ChoosingCapitalForTreeland.ll (Z3dfsll)

; 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<long, long>, std::allocator<std::pair<long, long>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<long, long>, std::allocator<std::pair<long, long>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<long, long>, std::allocator<std::pair<long, long>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<long, long>, std::allocator<std::pair<long, long>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<std::vector<std::pair<long, bool>>, std::allocator<std::vector<std::pair<long, bool>>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::vector<std::pair<long, bool>>, std::allocator<std::vector<std::pair<long, bool>>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::vector<std::pair<long, bool>>, std::allocator<std::vector<std::pair<long, bool>>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::vector<std::pair<long, bool>>, std::allocator<std::vector<std::pair<long, bool>>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::pair" = type <{ i64, i8, [7 x i8] }>
%"struct.std::pair.10" = type { i64, i64 }

@dist = external dso_local global %"class.std::vector", align 8
@edges = external dso_local global %"class.std::vector.0", align 8
@totalInv = external dso_local global i64, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_Z3dfsll(i64 noundef %0, i64 noundef %1) #0 {
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  %8 = alloca i8, align 1
  store i64 %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store i64 0, ptr %5, align 8, !tbaa !5
  br label %9

9:                                                ; preds = %72, %2
  %10 = load i64, ptr %5, align 8, !tbaa !5
  %11 = load i64, ptr %3, align 8, !tbaa !5
  %12 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_ISt4pairIlbESaIS1_EESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @edges, i64 noundef %11) #3
  %13 = call noundef i64 @_ZNKSt6vectorISt4pairIlbESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %12) #3
  %14 = icmp ult i64 %10, %13
  br i1 %14, label %16, label %15

15:                                               ; preds = %9
  store i32 2, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  br label %75

16:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %17 = load i64, ptr %3, align 8, !tbaa !5
  %18 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_ISt4pairIlbESaIS1_EESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @edges, i64 noundef %17) #3
  %19 = load i64, ptr %5, align 8, !tbaa !5
  %20 = call noundef nonnull align 8 dereferenceable(9) ptr @_ZNSt6vectorISt4pairIlbESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %18, i64 noundef %19) #3
  %21 = getelementptr inbounds %"struct.std::pair", ptr %20, i32 0, i32 0
  %22 = load i64, ptr %21, align 8, !tbaa !9
  store i64 %22, ptr %7, align 8, !tbaa !5
  %23 = load i64, ptr %7, align 8, !tbaa !5
  %24 = load i64, ptr %4, align 8, !tbaa !5
  %25 = icmp eq i64 %23, %24
  br i1 %25, label %26, label %27

26:                                               ; preds = %16
  store i32 4, ptr %6, align 4
  br label %69

27:                                               ; preds = %16
  %28 = load i64, ptr %7, align 8, !tbaa !5
  %29 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIllESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @dist, i64 noundef %28) #3
  %30 = getelementptr inbounds %"struct.std::pair.10", ptr %29, i32 0, i32 0
  %31 = load i64, ptr %30, align 8, !tbaa !12
  %32 = icmp sgt i64 %31, 0
  br i1 %32, label %33, label %34

33:                                               ; preds = %27
  store i32 4, ptr %6, align 4
  br label %69

34:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #3
  %35 = load i64, ptr %3, align 8, !tbaa !5
  %36 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_ISt4pairIlbESaIS1_EESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @edges, i64 noundef %35) #3
  %37 = load i64, ptr %5, align 8, !tbaa !5
  %38 = call noundef nonnull align 8 dereferenceable(9) ptr @_ZNSt6vectorISt4pairIlbESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %36, i64 noundef %37) #3
  %39 = getelementptr inbounds %"struct.std::pair", ptr %38, i32 0, i32 1
  %40 = load i8, ptr %39, align 8, !tbaa !14, !range !15, !noundef !16
  %41 = trunc i8 %40 to i1
  %42 = zext i1 %41 to i8
  store i8 %42, ptr %8, align 1, !tbaa !17
  %43 = load i64, ptr %3, align 8, !tbaa !5
  %44 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIllESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @dist, i64 noundef %43) #3
  %45 = getelementptr inbounds %"struct.std::pair.10", ptr %44, i32 0, i32 0
  %46 = load i64, ptr %45, align 8, !tbaa !12
  %47 = add nsw i64 1, %46
  %48 = load i64, ptr %7, align 8, !tbaa !5
  %49 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIllESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @dist, i64 noundef %48) #3
  %50 = getelementptr inbounds %"struct.std::pair.10", ptr %49, i32 0, i32 0
  store i64 %47, ptr %50, align 8, !tbaa !12
  %51 = load i8, ptr %8, align 1, !tbaa !17, !range !15, !noundef !16
  %52 = trunc i8 %51 to i1
  %53 = zext i1 %52 to i64
  %54 = load i64, ptr %3, align 8, !tbaa !5
  %55 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIllESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @dist, i64 noundef %54) #3
  %56 = getelementptr inbounds %"struct.std::pair.10", ptr %55, i32 0, i32 1
  %57 = load i64, ptr %56, align 8, !tbaa !18
  %58 = add nsw i64 %53, %57
  %59 = load i64, ptr %7, align 8, !tbaa !5
  %60 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIllESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @dist, i64 noundef %59) #3
  %61 = getelementptr inbounds %"struct.std::pair.10", ptr %60, i32 0, i32 1
  store i64 %58, ptr %61, align 8, !tbaa !18
  %62 = load i8, ptr %8, align 1, !tbaa !17, !range !15, !noundef !16
  %63 = trunc i8 %62 to i1
  %64 = zext i1 %63 to i64
  %65 = load i64, ptr @totalInv, align 8, !tbaa !5
  %66 = add nsw i64 %65, %64
  store i64 %66, ptr @totalInv, align 8, !tbaa !5
  %67 = load i64, ptr %7, align 8, !tbaa !5
  %68 = load i64, ptr %3, align 8, !tbaa !5
  call void @_Z3dfsll(i64 noundef %67, i64 noundef %68)
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #3
  store i32 0, ptr %6, align 4
  br label %69

69:                                               ; preds = %34, %33, %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  %70 = load i32, ptr %6, align 4
  switch i32 %70, label %76 [
    i32 0, label %71
    i32 4, label %72
  ]

71:                                               ; preds = %69
  br label %72

72:                                               ; preds = %71, %69
  %73 = load i64, ptr %5, align 8, !tbaa !5
  %74 = add nsw i64 %73, 1
  store i64 %74, ptr %5, align 8, !tbaa !5
  br label %9, !llvm.loop !19

75:                                               ; preds = %15
  ret void

76:                                               ; preds = %69
  unreachable
}

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(9) ptr @_ZNSt6vectorISt4pairIlbESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIllESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #2 align 2

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

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 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 #3 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTSSt4pairIlbE", !6, i64 0, !11, i64 8}
!11 = !{!"bool", !7, i64 0}
!12 = !{!13, !6, i64 0}
!13 = !{!"_ZTSSt4pairIllE", !6, i64 0, !6, i64 8}
!14 = !{!10, !11, i64 8}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!11, !11, i64 0}
!18 = !{!13, !6, i64 8}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


; 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<long, long>, std::allocator<std::pair<long, long>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<long, long>, std::allocator<std::pair<long, long>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<long, long>, std::allocator<std::pair<long, long>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<long, long>, std::allocator<std::pair<long, long>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<std::vector<std::pair<long, bool>>, std::allocator<std::vector<std::pair<long, bool>>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::vector<std::pair<long, bool>>, std::allocator<std::vector<std::pair<long, bool>>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::vector<std::pair<long, bool>>, std::allocator<std::vector<std::pair<long, bool>>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::vector<std::pair<long, bool>>, std::allocator<std::vector<std::pair<long, bool>>>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@dist = external dso_local global %"class.std::vector", align 8
@edges = external dso_local global %"class.std::vector.0", align 8
@totalInv = external dso_local local_unnamed_addr global i64, align 8

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z3dfsll(i64 noundef %0, i64 noundef %1) local_unnamed_addr #0 {
  %3 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_ISt4pairIlbESaIS1_EESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @edges, i64 noundef %0) #1
  %4 = tail call noundef i64 @_ZNKSt6vectorISt4pairIlbESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %3) #1
  %.not = icmp eq i64 %4, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %31, %2
  ret void

.lr.ph:                                           ; preds = %2, %31
  %.019 = phi i64 [ %32, %31 ], [ 0, %2 ]
  %5 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_ISt4pairIlbESaIS1_EESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @edges, i64 noundef %0) #1
  %6 = tail call noundef nonnull align 8 dereferenceable(9) ptr @_ZNSt6vectorISt4pairIlbESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %.019) #1
  %7 = load i64, ptr %6, align 8, !tbaa !5
  %8 = icmp eq i64 %7, %1
  br i1 %8, label %31, label %9

9:                                                ; preds = %.lr.ph
  %10 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIllESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @dist, i64 noundef %7) #1
  %11 = load i64, ptr %10, align 8, !tbaa !11
  %12 = icmp sgt i64 %11, 0
  br i1 %12, label %31, label %13

13:                                               ; preds = %9
  %14 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_ISt4pairIlbESaIS1_EESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @edges, i64 noundef %0) #1
  %15 = tail call noundef nonnull align 8 dereferenceable(9) ptr @_ZNSt6vectorISt4pairIlbESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %14, i64 noundef %.019) #1
  %16 = getelementptr inbounds i8, ptr %15, i64 8
  %17 = load i8, ptr %16, align 8, !tbaa !13, !range !14, !noundef !15
  %18 = zext nneg i8 %17 to i64
  %19 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIllESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @dist, i64 noundef %0) #1
  %20 = load i64, ptr %19, align 8, !tbaa !11
  %21 = add nsw i64 %20, 1
  %22 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIllESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @dist, i64 noundef %7) #1
  store i64 %21, ptr %22, align 8, !tbaa !11
  %23 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIllESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @dist, i64 noundef %0) #1
  %24 = getelementptr inbounds i8, ptr %23, i64 8
  %25 = load i64, ptr %24, align 8, !tbaa !16
  %26 = add nsw i64 %25, %18
  %27 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIllESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @dist, i64 noundef %7) #1
  %28 = getelementptr inbounds i8, ptr %27, i64 8
  store i64 %26, ptr %28, align 8, !tbaa !16
  %29 = load i64, ptr @totalInv, align 8, !tbaa !17
  %30 = add nsw i64 %29, %18
  store i64 %30, ptr @totalInv, align 8, !tbaa !17
  tail call void @_Z3dfsll(i64 noundef %7, i64 noundef %0)
  br label %31

31:                                               ; preds = %9, %.lr.ph, %13
  %32 = add nuw nsw i64 %.019, 1
  %33 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_ISt4pairIlbESaIS1_EESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @edges, i64 noundef %0) #1
  %34 = tail call noundef i64 @_ZNKSt6vectorISt4pairIlbESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %33) #1
  %35 = icmp ult i64 %32, %34
  br i1 %35, label %.lr.ph, label %._crit_edge, !llvm.loop !18
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorISt4pairIlbESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(9) ptr @_ZNSt6vectorISt4pairIlbESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIllESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

attributes #0 = { 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 #1 = { 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, !7, i64 0}
!6 = !{!"_ZTSSt4pairIlbE", !7, i64 0, !10, i64 8}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!12, !7, i64 0}
!12 = !{!"_ZTSSt4pairIllE", !7, i64 0, !7, i64 8}
!13 = !{!6, !10, i64 8}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = !{!12, !7, i64 8}
!17 = !{!7, !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass