; LLVM IR from Dev-XYS/Algorithms :: Heavy-Light-Decomposition.ll (Z4DFS2P6vertexS0_)

; 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"

%struct.vertex = type { ptr, i32, i32, i32, i32, ptr, ptr, ptr }
%struct.edge = type { ptr, ptr }

@nil = external dso_local global ptr, align 8
@ord = external dso_local global i32, align 4
@map = external dso_local global [100000 x ptr], align 16

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z4DFS2P6vertexS0_(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.vertex, ptr %7, i32 0, i32 7
  store ptr %6, ptr %8, align 8, !tbaa !9
  %9 = load i32, ptr @ord, align 4, !tbaa !12
  %10 = add nsw i32 %9, 1
  store i32 %10, ptr @ord, align 4, !tbaa !12
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.vertex, ptr %11, i32 0, i32 4
  store i32 %10, ptr %12, align 4, !tbaa !13
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = load i32, ptr @ord, align 4, !tbaa !12
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [100000 x ptr], ptr @map, i64 0, i64 %15
  store ptr %13, ptr %16, align 8, !tbaa !5
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.vertex, ptr %17, i32 0, i32 6
  %19 = load ptr, ptr %18, align 8, !tbaa !14
  %20 = load ptr, ptr @nil, align 8, !tbaa !5
  %21 = icmp ne ptr %19, %20
  br i1 %21, label %22, label %27

22:                                               ; preds = %2
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.vertex, ptr %23, i32 0, i32 6
  %25 = load ptr, ptr %24, align 8, !tbaa !14
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_Z4DFS2P6vertexS0_(ptr noundef %25, ptr noundef %26)
  br label %27

27:                                               ; preds = %22, %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.vertex, ptr %28, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8, !tbaa !15
  store ptr %30, ptr %5, align 8, !tbaa !5
  br label %31

31:                                               ; preds = %59, %27
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = icmp ne ptr %32, null
  br i1 %33, label %35, label %34

34:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  br label %63

35:                                               ; preds = %31
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.edge, ptr %36, i32 0, i32 1
  %38 = load ptr, ptr %37, align 8, !tbaa !16
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.vertex, ptr %39, i32 0, i32 6
  %41 = load ptr, ptr %40, align 8, !tbaa !14
  %42 = icmp ne ptr %38, %41
  br i1 %42, label %43, label %58

43:                                               ; preds = %35
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.edge, ptr %44, i32 0, i32 1
  %46 = load ptr, ptr %45, align 8, !tbaa !16
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.vertex, ptr %47, i32 0, i32 5
  %49 = load ptr, ptr %48, align 8, !tbaa !18
  %50 = icmp ne ptr %46, %49
  br i1 %50, label %51, label %58

51:                                               ; preds = %43
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.edge, ptr %52, i32 0, i32 1
  %54 = load ptr, ptr %53, align 8, !tbaa !16
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.edge, ptr %55, i32 0, i32 1
  %57 = load ptr, ptr %56, align 8, !tbaa !16
  call void @_Z4DFS2P6vertexS0_(ptr noundef %54, ptr noundef %57)
  br label %58

58:                                               ; preds = %51, %43, %35
  br label %59

59:                                               ; preds = %58
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.edge, ptr %60, i32 0, i32 0
  %62 = load ptr, ptr %61, align 8, !tbaa !19
  store ptr %62, ptr %5, align 8, !tbaa !5
  br label %31, !llvm.loop !20

63:                                               ; preds = %34
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 40}
!10 = !{!"_ZTS6vertex", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !6, i64 24, !6, i64 32, !6, i64 40}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !11, i64 20}
!14 = !{!10, !6, i64 32}
!15 = !{!10, !6, i64 0}
!16 = !{!17, !6, i64 8}
!17 = !{!"_ZTS4edge", !6, i64 0, !6, i64 8}
!18 = !{!10, !6, i64 24}
!19 = !{!17, !6, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"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"

@nil = external dso_local local_unnamed_addr global ptr, align 8
@ord = external dso_local local_unnamed_addr global i32, align 4
@map = external dso_local local_unnamed_addr global [100000 x ptr], align 16

; Function Attrs: mustprogress nofree nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @_Z4DFS2P6vertexS0_(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 40
  store ptr %1, ptr %3, align 8, !tbaa !5
  %4 = load i32, ptr @ord, align 4, !tbaa !11
  %5 = add nsw i32 %4, 1
  store i32 %5, ptr @ord, align 4, !tbaa !11
  %6 = getelementptr inbounds i8, ptr %0, i64 20
  store i32 %5, ptr %6, align 4, !tbaa !12
  %7 = sext i32 %5 to i64
  %8 = getelementptr inbounds [100000 x ptr], ptr @map, i64 0, i64 %7
  store ptr %0, ptr %8, align 8, !tbaa !13
  %9 = getelementptr inbounds i8, ptr %0, i64 32
  %10 = load ptr, ptr %9, align 8, !tbaa !14
  %11 = load ptr, ptr @nil, align 8, !tbaa !13
  %.not = icmp eq ptr %10, %11
  br i1 %.not, label %13, label %12

12:                                               ; preds = %2
  tail call void @_Z4DFS2P6vertexS0_(ptr noundef %10, ptr noundef %1)
  br label %13

13:                                               ; preds = %12, %2
  %.021 = load ptr, ptr %0, align 8, !tbaa !13
  %.not1822 = icmp eq ptr %.021, null
  br i1 %.not1822, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %13
  %14 = getelementptr inbounds i8, ptr %0, i64 24
  br label %15

._crit_edge:                                      ; preds = %22, %13
  ret void

15:                                               ; preds = %.lr.ph, %22
  %.023 = phi ptr [ %.021, %.lr.ph ], [ %.0, %22 ]
  %16 = getelementptr inbounds i8, ptr %.023, i64 8
  %17 = load ptr, ptr %16, align 8, !tbaa !15
  %18 = load ptr, ptr %9, align 8, !tbaa !14
  %.not19 = icmp eq ptr %17, %18
  br i1 %.not19, label %22, label %19

19:                                               ; preds = %15
  %20 = load ptr, ptr %14, align 8, !tbaa !17
  %.not20 = icmp eq ptr %17, %20
  br i1 %.not20, label %22, label %21

21:                                               ; preds = %19
  tail call void @_Z4DFS2P6vertexS0_(ptr noundef %17, ptr noundef %17)
  br label %22

22:                                               ; preds = %15, %19, %21
  %.0 = load ptr, ptr %.023, align 8, !tbaa !13
  %.not18 = icmp eq ptr %.0, null
  br i1 %.not18, label %._crit_edge, label %15, !llvm.loop !18
}

attributes #0 = { mustprogress nofree nosync nounwind memory(readwrite, inaccessiblemem: none) 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" }

!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 40}
!6 = !{!"_ZTS6vertex", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !7, i64 24, !7, i64 32, !7, i64 40}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!10, !10, i64 0}
!12 = !{!6, !10, i64 20}
!13 = !{!7, !7, i64 0}
!14 = !{!6, !7, i64 32}
!15 = !{!16, !7, i64 8}
!16 = !{!"_ZTS4edge", !7, i64 0, !7, i64 8}
!17 = !{!6, !7, i64 24}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


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