; LLVM IR from UtkarshPathrabe/Competitive-Coding :: Model Algorithms/Graphs/Strongly Connected Components.ll (Z11DFSUtility1i)

; 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<Nodes, std::allocator<Nodes>>::_Vector_impl" }
%"struct.std::_Vector_base<Nodes, std::allocator<Nodes>>::_Vector_impl" = type { %"struct.std::_Vector_base<Nodes, std::allocator<Nodes>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Nodes, std::allocator<Nodes>>::_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<Edges, std::allocator<Edges>>::_Vector_impl" }
%"struct.std::_Vector_base<Edges, std::allocator<Edges>>::_Vector_impl" = type { %"struct.std::_Vector_base<Edges, std::allocator<Edges>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Edges, std::allocator<Edges>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::__cxx11::list" = type { %"class.std::__cxx11::_List_base" }
%"class.std::__cxx11::_List_base" = type { %"struct.std::__cxx11::_List_base<int, std::allocator<int>>::_List_impl" }
%"struct.std::__cxx11::_List_base<int, std::allocator<int>>::_List_impl" = type { %"struct.std::__detail::_List_node_header" }
%"struct.std::__detail::_List_node_header" = type { %"struct.std::__detail::_List_node_base", i64 }
%"struct.std::__detail::_List_node_base" = type { ptr, ptr }
%struct.Nodes = type { i8, i32, i32 }
%struct.Edges = type { i32, i32 }

@Node1 = external dso_local global %"class.std::vector", align 8
@Edge1 = external dso_local global %"class.std::vector.0", align 8
@_Z5StackB5cxx11 = external dso_local global %"class.std::__cxx11::list", align 8
@timer = external dso_local global i32, align 4

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

; 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 4 dereferenceable(8) ptr @_ZNSt6vectorI5EdgesSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #0 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z11DFSUtility1i(i32 noundef %0) #2 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  %4 = load i32, ptr %2, align 4, !tbaa !5
  %5 = sext i32 %4 to i64
  %6 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorI5NodesSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @Node1, i64 noundef %5) #3
  %7 = getelementptr inbounds %struct.Nodes, ptr %6, i32 0, i32 0
  store i8 1, ptr %7, align 4, !tbaa !9
  %8 = load i32, ptr @timer, align 4, !tbaa !5
  %9 = add nsw i32 %8, 1
  store i32 %9, ptr @timer, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  %10 = load i32, ptr %2, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %12 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorI5NodesSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @Node1, i64 noundef %11) #3
  %13 = getelementptr inbounds %struct.Nodes, ptr %12, i32 0, i32 2
  %14 = load i32, ptr %13, align 4, !tbaa !12
  store i32 %14, ptr %3, align 4, !tbaa !5
  br label %15

15:                                               ; preds = %37, %1
  %16 = load i32, ptr %3, align 4, !tbaa !5
  %17 = icmp ne i32 %16, -1
  br i1 %17, label %19, label %18

18:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %43

19:                                               ; preds = %15
  %20 = load i32, ptr %3, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI5EdgesSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @Edge1, i64 noundef %21) #3
  %23 = getelementptr inbounds %struct.Edges, ptr %22, i32 0, i32 0
  %24 = load i32, ptr %23, align 4, !tbaa !13
  %25 = sext i32 %24 to i64
  %26 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorI5NodesSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @Node1, i64 noundef %25) #3
  %27 = getelementptr inbounds %struct.Nodes, ptr %26, i32 0, i32 0
  %28 = load i8, ptr %27, align 4, !tbaa !9, !range !15, !noundef !16
  %29 = trunc i8 %28 to i1
  br i1 %29, label %36, label %30

30:                                               ; preds = %19
  %31 = load i32, ptr %3, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI5EdgesSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @Edge1, i64 noundef %32) #3
  %34 = getelementptr inbounds %struct.Edges, ptr %33, i32 0, i32 0
  %35 = load i32, ptr %34, align 4, !tbaa !13
  call void @_Z11DFSUtility1i(i32 noundef %35)
  br label %36

36:                                               ; preds = %30, %19
  br label %37

37:                                               ; preds = %36
  %38 = load i32, ptr %3, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI5EdgesSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @Edge1, i64 noundef %39) #3
  %41 = getelementptr inbounds %struct.Edges, ptr %40, i32 0, i32 1
  %42 = load i32, ptr %41, align 4, !tbaa !17
  store i32 %42, ptr %3, align 4, !tbaa !5
  br label %15, !llvm.loop !18

43:                                               ; preds = %18
  %44 = load i32, ptr @timer, align 4, !tbaa !5
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr @timer, align 4, !tbaa !5
  %46 = load i32, ptr %2, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorI5NodesSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @Node1, i64 noundef %47) #3
  %49 = getelementptr inbounds %struct.Nodes, ptr %48, i32 0, i32 1
  store i32 %45, ptr %49, align 4, !tbaa !20
  call void @_ZNSt7__cxx114listIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) @_Z5StackB5cxx11, ptr noundef nonnull align 4 dereferenceable(4) %2)
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt7__cxx114listIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(4)) #2 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nounwind }

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

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


; 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<Nodes, std::allocator<Nodes>>::_Vector_impl" }
%"struct.std::_Vector_base<Nodes, std::allocator<Nodes>>::_Vector_impl" = type { %"struct.std::_Vector_base<Nodes, std::allocator<Nodes>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Nodes, std::allocator<Nodes>>::_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<Edges, std::allocator<Edges>>::_Vector_impl" }
%"struct.std::_Vector_base<Edges, std::allocator<Edges>>::_Vector_impl" = type { %"struct.std::_Vector_base<Edges, std::allocator<Edges>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Edges, std::allocator<Edges>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::__cxx11::list" = type { %"class.std::__cxx11::_List_base" }
%"class.std::__cxx11::_List_base" = type { %"struct.std::__cxx11::_List_base<int, std::allocator<int>>::_List_impl" }
%"struct.std::__cxx11::_List_base<int, std::allocator<int>>::_List_impl" = type { %"struct.std::__detail::_List_node_header" }
%"struct.std::__detail::_List_node_header" = type { %"struct.std::__detail::_List_node_base", i64 }
%"struct.std::__detail::_List_node_base" = type { ptr, ptr }

@Node1 = external dso_local global %"class.std::vector", align 8
@Edge1 = external dso_local global %"class.std::vector.0", align 8
@_Z5StackB5cxx11 = external dso_local global %"class.std::__cxx11::list", align 8
@timer = external dso_local local_unnamed_addr global i32, align 4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorI5NodesSaIS0_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 4 dereferenceable(8) ptr @_ZNSt6vectorI5EdgesSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z11DFSUtility1i(i32 noundef %0) local_unnamed_addr #1 {
  %2 = alloca i32, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  %3 = sext i32 %0 to i64
  %4 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorI5NodesSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @Node1, i64 noundef %3) #2
  store i8 1, ptr %4, align 4, !tbaa !9
  %5 = load i32, ptr @timer, align 4, !tbaa !5
  %6 = add nsw i32 %5, 1
  store i32 %6, ptr @timer, align 4, !tbaa !5
  %7 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorI5NodesSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @Node1, i64 noundef %3) #2
  %8 = getelementptr inbounds i8, ptr %7, i64 8
  %.04 = load i32, ptr %8, align 4, !tbaa !5
  %.not5 = icmp eq i32 %.04, -1
  br i1 %.not5, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %23, %1
  %9 = load i32, ptr @timer, align 4, !tbaa !5
  %10 = add nsw i32 %9, 1
  store i32 %10, ptr @timer, align 4, !tbaa !5
  %11 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorI5NodesSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @Node1, i64 noundef %3) #2
  %12 = getelementptr inbounds i8, ptr %11, i64 4
  store i32 %10, ptr %12, align 4, !tbaa !12
  call void @_ZNSt7__cxx114listIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) @_Z5StackB5cxx11, ptr noundef nonnull align 4 dereferenceable(4) %2)
  ret void

.lr.ph:                                           ; preds = %1, %23
  %.06 = phi i32 [ %.0, %23 ], [ %.04, %1 ]
  %13 = sext i32 %.06 to i64
  %14 = tail call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI5EdgesSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @Edge1, i64 noundef %13) #2
  %15 = load i32, ptr %14, align 4, !tbaa !13
  %16 = sext i32 %15 to i64
  %17 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorI5NodesSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @Node1, i64 noundef %16) #2
  %18 = load i8, ptr %17, align 4, !tbaa !9, !range !15, !noundef !16
  %19 = trunc nuw i8 %18 to i1
  br i1 %19, label %23, label %20

20:                                               ; preds = %.lr.ph
  %21 = tail call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI5EdgesSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @Edge1, i64 noundef %13) #2
  %22 = load i32, ptr %21, align 4, !tbaa !13
  tail call void @_Z11DFSUtility1i(i32 noundef %22)
  br label %23

23:                                               ; preds = %.lr.ph, %20
  %24 = tail call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI5EdgesSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @Edge1, i64 noundef %13) #2
  %25 = getelementptr inbounds i8, ptr %24, i64 4
  %.0 = load i32, ptr %25, align 4, !tbaa !5
  %.not = icmp eq i32 %.0, -1
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !17
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt7__cxx114listIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1 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 = { 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 #2 = { nounwind }

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

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


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