; LLVM IR from Dev-XYS/Algorithms :: Cut-Vertex.ll (Z3DFSii)

; 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 { i32, i32, i32, i8 }
%struct.edge = type { i32, i32 }

@V = external dso_local global [100000 x %struct.vertex], align 16
@E = external dso_local global [100000 x %struct.edge], align 16
@dfn = external dso_local global i32, align 4

; Function Attrs: mustprogress uwtable
define dso_local void @_Z3DFSii(i32 noundef %0, i32 noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !5
  %6 = load i32, ptr @dfn, align 4, !tbaa !5
  %7 = add nsw i32 %6, 1
  store i32 %7, ptr @dfn, align 4, !tbaa !5
  %8 = load i32, ptr %3, align 4, !tbaa !5
  %9 = sext i32 %8 to i64
  %10 = getelementptr inbounds [100000 x %struct.vertex], ptr @V, i64 0, i64 %9
  %11 = getelementptr inbounds %struct.vertex, ptr %10, i32 0, i32 2
  store i32 %6, ptr %11, align 8, !tbaa !9
  %12 = load i32, ptr %3, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [100000 x %struct.vertex], ptr @V, i64 0, i64 %13
  %15 = getelementptr inbounds %struct.vertex, ptr %14, i32 0, i32 1
  store i32 %6, ptr %15, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %16 = load i32, ptr %3, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [100000 x %struct.vertex], ptr @V, i64 0, i64 %17
  %19 = getelementptr inbounds %struct.vertex, ptr %18, i32 0, i32 0
  %20 = load i32, ptr %19, align 16, !tbaa !13
  store i32 %20, ptr %5, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %113, %2
  %22 = load i32, ptr %5, align 4, !tbaa !5
  %23 = icmp ne i32 %22, 0
  br i1 %23, label %25, label %24

24:                                               ; preds = %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %119

25:                                               ; preds = %21
  %26 = load i32, ptr %5, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [100000 x %struct.edge], ptr @E, i64 0, i64 %27
  %29 = getelementptr inbounds %struct.edge, ptr %28, i32 0, i32 0
  %30 = load i32, ptr %29, align 8, !tbaa !14
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [100000 x %struct.vertex], ptr @V, i64 0, i64 %31
  %33 = getelementptr inbounds %struct.vertex, ptr %32, i32 0, i32 1
  %34 = load i32, ptr %33, align 4, !tbaa !12
  %35 = icmp eq i32 %34, 0
  br i1 %35, label %36, label %83

36:                                               ; preds = %25
  %37 = load i32, ptr %5, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [100000 x %struct.edge], ptr @E, i64 0, i64 %38
  %40 = getelementptr inbounds %struct.edge, ptr %39, i32 0, i32 0
  %41 = load i32, ptr %40, align 8, !tbaa !14
  %42 = load i32, ptr %3, align 4, !tbaa !5
  call void @_Z3DFSii(i32 noundef %41, i32 noundef %42)
  %43 = load i32, ptr %3, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [100000 x %struct.vertex], ptr @V, i64 0, i64 %44
  %46 = getelementptr inbounds %struct.vertex, ptr %45, i32 0, i32 2
  %47 = load i32, ptr %46, align 8, !tbaa !9
  %48 = load i32, ptr %5, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [100000 x %struct.edge], ptr @E, i64 0, i64 %49
  %51 = getelementptr inbounds %struct.edge, ptr %50, i32 0, i32 0
  %52 = load i32, ptr %51, align 8, !tbaa !14
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [100000 x %struct.vertex], ptr @V, i64 0, i64 %53
  %55 = getelementptr inbounds %struct.vertex, ptr %54, i32 0, i32 2
  %56 = load i32, ptr %55, align 8, !tbaa !9
  %57 = call noundef i32 @_Z3minii(i32 noundef %47, i32 noundef %56)
  %58 = load i32, ptr %3, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [100000 x %struct.vertex], ptr @V, i64 0, i64 %59
  %61 = getelementptr inbounds %struct.vertex, ptr %60, i32 0, i32 2
  store i32 %57, ptr %61, align 8, !tbaa !9
  %62 = load i32, ptr %5, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [100000 x %struct.edge], ptr @E, i64 0, i64 %63
  %65 = getelementptr inbounds %struct.edge, ptr %64, i32 0, i32 0
  %66 = load i32, ptr %65, align 8, !tbaa !14
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [100000 x %struct.vertex], ptr @V, i64 0, i64 %67
  %69 = getelementptr inbounds %struct.vertex, ptr %68, i32 0, i32 2
  %70 = load i32, ptr %69, align 8, !tbaa !9
  %71 = load i32, ptr %3, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [100000 x %struct.vertex], ptr @V, i64 0, i64 %72
  %74 = getelementptr inbounds %struct.vertex, ptr %73, i32 0, i32 1
  %75 = load i32, ptr %74, align 4, !tbaa !12
  %76 = icmp sge i32 %70, %75
  br i1 %76, label %77, label %82

77:                                               ; preds = %36
  %78 = load i32, ptr %3, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [100000 x %struct.vertex], ptr @V, i64 0, i64 %79
  %81 = getelementptr inbounds %struct.vertex, ptr %80, i32 0, i32 3
  store i8 1, ptr %81, align 4, !tbaa !16
  br label %82

82:                                               ; preds = %77, %36
  br label %112

83:                                               ; preds = %25
  %84 = load i32, ptr %5, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [100000 x %struct.edge], ptr @E, i64 0, i64 %85
  %87 = getelementptr inbounds %struct.edge, ptr %86, i32 0, i32 0
  %88 = load i32, ptr %87, align 8, !tbaa !14
  %89 = load i32, ptr %4, align 4, !tbaa !5
  %90 = icmp ne i32 %88, %89
  br i1 %90, label %91, label %111

91:                                               ; preds = %83
  %92 = load i32, ptr %3, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [100000 x %struct.vertex], ptr @V, i64 0, i64 %93
  %95 = getelementptr inbounds %struct.vertex, ptr %94, i32 0, i32 2
  %96 = load i32, ptr %95, align 8, !tbaa !9
  %97 = load i32, ptr %5, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [100000 x %struct.edge], ptr @E, i64 0, i64 %98
  %100 = getelementptr inbounds %struct.edge, ptr %99, i32 0, i32 0
  %101 = load i32, ptr %100, align 8, !tbaa !14
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [100000 x %struct.vertex], ptr @V, i64 0, i64 %102
  %104 = getelementptr inbounds %struct.vertex, ptr %103, i32 0, i32 1
  %105 = load i32, ptr %104, align 4, !tbaa !12
  %106 = call noundef i32 @_Z3minii(i32 noundef %96, i32 noundef %105)
  %107 = load i32, ptr %3, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [100000 x %struct.vertex], ptr @V, i64 0, i64 %108
  %110 = getelementptr inbounds %struct.vertex, ptr %109, i32 0, i32 2
  store i32 %106, ptr %110, align 8, !tbaa !9
  br label %111

111:                                              ; preds = %91, %83
  br label %112

112:                                              ; preds = %111, %82
  br label %113

113:                                              ; preds = %112
  %114 = load i32, ptr %5, align 4, !tbaa !5
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [100000 x %struct.edge], ptr @E, i64 0, i64 %115
  %117 = getelementptr inbounds %struct.edge, ptr %116, i32 0, i32 1
  %118 = load i32, ptr %117, align 4, !tbaa !17
  store i32 %118, ptr %5, align 4, !tbaa !5
  br label %21, !llvm.loop !18

119:                                              ; preds = %24
  ret void
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3minii(i32 noundef, i32 noundef) #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 = { 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 #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, !6, i64 8}
!10 = !{!"_ZTS6vertex", !6, i64 0, !6, i64 4, !6, i64 8, !11, i64 12}
!11 = !{!"bool", !7, i64 0}
!12 = !{!10, !6, i64 4}
!13 = !{!10, !6, i64 0}
!14 = !{!15, !6, i64 0}
!15 = !{!"_ZTS4edge", !6, i64 0, !6, i64 4}
!16 = !{!10, !11, i64 12}
!17 = !{!15, !6, i64 4}
!18 = distinct !{!18, !19}
!19 = !{!"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"

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

@V = external dso_local local_unnamed_addr global [100000 x %struct.vertex], align 16
@E = external dso_local local_unnamed_addr global [100000 x %struct.edge], align 16
@dfn = external dso_local local_unnamed_addr global i32, align 4

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z3DFSii(i32 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = load i32, ptr @dfn, align 4, !tbaa !5
  %4 = add nsw i32 %3, 1
  store i32 %4, ptr @dfn, align 4, !tbaa !5
  %5 = sext i32 %0 to i64
  %6 = getelementptr inbounds [100000 x %struct.vertex], ptr @V, i64 0, i64 %5
  %7 = getelementptr inbounds i8, ptr %6, i64 8
  store i32 %3, ptr %7, align 8, !tbaa !9
  %8 = getelementptr inbounds i8, ptr %6, i64 4
  store i32 %3, ptr %8, align 4, !tbaa !12
  %.022 = load i32, ptr %6, align 16, !tbaa !5
  %.not23 = icmp eq i32 %.022, 0
  br i1 %.not23, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %9 = getelementptr inbounds i8, ptr %6, i64 12
  br label %10

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

10:                                               ; preds = %.lr.ph, %35
  %11 = phi i32 [ %3, %.lr.ph ], [ %36, %35 ]
  %.024 = phi i32 [ %.022, %.lr.ph ], [ %.0, %35 ]
  %12 = sext i32 %.024 to i64
  %13 = getelementptr inbounds [100000 x %struct.edge], ptr @E, i64 0, i64 %12
  %14 = load i32, ptr %13, align 8, !tbaa !13
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [100000 x %struct.vertex], ptr @V, i64 0, i64 %15, i32 1
  %17 = load i32, ptr %16, align 4, !tbaa !12
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %19, label %32

19:                                               ; preds = %10
  tail call void @_Z3DFSii(i32 noundef %14, i32 noundef %0)
  %20 = load i32, ptr %7, align 8, !tbaa !9
  %21 = load i32, ptr %13, align 8, !tbaa !13
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [100000 x %struct.vertex], ptr @V, i64 0, i64 %22, i32 2
  %24 = load i32, ptr %23, align 8, !tbaa !9
  %25 = tail call noundef i32 @_Z3minii(i32 noundef %20, i32 noundef %24)
  store i32 %25, ptr %7, align 8, !tbaa !9
  %26 = load i32, ptr %13, align 8, !tbaa !13
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [100000 x %struct.vertex], ptr @V, i64 0, i64 %27, i32 2
  %29 = load i32, ptr %28, align 8, !tbaa !9
  %30 = load i32, ptr %8, align 4, !tbaa !12
  %.not21 = icmp slt i32 %29, %30
  br i1 %.not21, label %35, label %31

31:                                               ; preds = %19
  store i8 1, ptr %9, align 4, !tbaa !15
  br label %35

32:                                               ; preds = %10
  %.not20 = icmp eq i32 %14, %1
  br i1 %.not20, label %35, label %33

33:                                               ; preds = %32
  %34 = tail call noundef i32 @_Z3minii(i32 noundef %11, i32 noundef %17)
  store i32 %34, ptr %7, align 8, !tbaa !9
  br label %35

35:                                               ; preds = %31, %19, %33, %32
  %36 = phi i32 [ %25, %31 ], [ %25, %19 ], [ %34, %33 ], [ %11, %32 ]
  %37 = getelementptr inbounds i8, ptr %13, i64 4
  %.0 = load i32, ptr %37, align 4, !tbaa !5
  %.not = icmp eq i32 %.0, 0
  br i1 %.not, label %._crit_edge, label %10, !llvm.loop !16
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3minii(i32 noundef, i32 noundef) local_unnamed_addr #1

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 = { 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" }

!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, !6, i64 8}
!10 = !{!"_ZTS6vertex", !6, i64 0, !6, i64 4, !6, i64 8, !11, i64 12}
!11 = !{!"bool", !7, i64 0}
!12 = !{!10, !6, i64 4}
!13 = !{!14, !6, i64 0}
!14 = !{!"_ZTS4edge", !6, i64 0, !6, i64 4}
!15 = !{!10, !11, i64 12}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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