; LLVM IR from Tunghohin/Competitive_Coding :: Poj/poj3694.ll (Z6tarjanii)

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

@e = external dso_local global [400010 x %struct.edge], align 16
@head = external dso_local global [100010 x i32], align 16
@dfn = external dso_local global [100010 x i32], align 16
@low = external dso_local global [100010 x i32], align 16
@timestamp = external dso_local global i32, align 4
@f = external dso_local global [100010 x i32], align 16
@depth = external dso_local global [100010 x i32], align 16
@in_bridge = external dso_local global [100010 x i8], align 16
@cnt = external dso_local global i32, align 4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z8inv_edgei(i32 noundef) #0

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

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

22:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %101

23:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %24 = load i32, ptr %5, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [400010 x %struct.edge], ptr @e, i64 0, i64 %25
  %27 = getelementptr inbounds %struct.edge, ptr %26, i32 0, i32 0
  %28 = load i32, ptr %27, align 8, !tbaa !9
  store i32 %28, ptr %6, align 4, !tbaa !5
  %29 = load i32, ptr %6, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [100010 x i32], ptr @dfn, i64 0, i64 %30
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %33 = icmp ne i32 %32, 0
  br i1 %33, label %76, label %34

34:                                               ; preds = %23
  %35 = load i32, ptr %3, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [100010 x i32], ptr @depth, i64 0, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = add nsw i32 %38, 1
  %40 = load i32, ptr %6, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [100010 x i32], ptr @depth, i64 0, i64 %41
  store i32 %39, ptr %42, align 4, !tbaa !5
  %43 = load i32, ptr %3, align 4, !tbaa !5
  %44 = load i32, ptr %6, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [100010 x i32], ptr @f, i64 0, i64 %45
  store i32 %43, ptr %46, align 4, !tbaa !5
  %47 = load i32, ptr %6, align 4, !tbaa !5
  %48 = load i32, ptr %5, align 4, !tbaa !5
  call void @_Z6tarjanii(i32 noundef %47, i32 noundef %48)
  %49 = load i32, ptr %3, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [100010 x i32], ptr @low, i64 0, i64 %50
  %52 = load i32, ptr %6, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [100010 x i32], ptr @low, i64 0, i64 %53
  %55 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %51, ptr noundef nonnull align 4 dereferenceable(4) %54)
  %56 = load i32, ptr %55, align 4, !tbaa !5
  %57 = load i32, ptr %3, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [100010 x i32], ptr @low, i64 0, i64 %58
  store i32 %56, ptr %59, align 4, !tbaa !5
  %60 = load i32, ptr %3, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [100010 x i32], ptr @dfn, i64 0, i64 %61
  %63 = load i32, ptr %62, align 4, !tbaa !5
  %64 = load i32, ptr %6, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [100010 x i32], ptr @low, i64 0, i64 %65
  %67 = load i32, ptr %66, align 4, !tbaa !5
  %68 = icmp slt i32 %63, %67
  br i1 %68, label %69, label %75

69:                                               ; preds = %34
  %70 = load i32, ptr %6, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [100010 x i8], ptr @in_bridge, i64 0, i64 %71
  store i8 1, ptr %72, align 1, !tbaa !11
  %73 = load i32, ptr @cnt, align 4, !tbaa !5
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr @cnt, align 4, !tbaa !5
  br label %75

75:                                               ; preds = %69, %34
  br label %94

76:                                               ; preds = %23
  %77 = load i32, ptr %5, align 4, !tbaa !5
  %78 = load i32, ptr %4, align 4, !tbaa !5
  %79 = call noundef i32 @_Z8inv_edgei(i32 noundef %78)
  %80 = icmp ne i32 %77, %79
  br i1 %80, label %81, label %93

81:                                               ; preds = %76
  %82 = load i32, ptr %3, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [100010 x i32], ptr @low, i64 0, i64 %83
  %85 = load i32, ptr %6, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [100010 x i32], ptr @dfn, i64 0, i64 %86
  %88 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %84, ptr noundef nonnull align 4 dereferenceable(4) %87)
  %89 = load i32, ptr %88, align 4, !tbaa !5
  %90 = load i32, ptr %3, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [100010 x i32], ptr @low, i64 0, i64 %91
  store i32 %89, ptr %92, align 4, !tbaa !5
  br label %93

93:                                               ; preds = %81, %76
  br label %94

94:                                               ; preds = %93, %75
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %95

95:                                               ; preds = %94
  %96 = load i32, ptr %5, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [400010 x %struct.edge], ptr @e, i64 0, i64 %97
  %99 = getelementptr inbounds %struct.edge, ptr %98, i32 0, i32 1
  %100 = load i32, ptr %99, align 4, !tbaa !13
  store i32 %100, ptr %5, align 4, !tbaa !5
  br label %19, !llvm.loop !14

101:                                              ; preds = %22
  ret void
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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 0}
!10 = !{!"_ZTS4edge", !6, i64 0, !6, i64 4}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!10, !6, i64 4}
!14 = distinct !{!14, !15}
!15 = !{!"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.edge = type { i32, i32 }

@e = external dso_local local_unnamed_addr global [400010 x %struct.edge], align 16
@head = external dso_local local_unnamed_addr global [100010 x i32], align 16
@dfn = external dso_local global [100010 x i32], align 16
@low = external dso_local global [100010 x i32], align 16
@timestamp = external dso_local local_unnamed_addr global i32, align 4
@f = external dso_local local_unnamed_addr global [100010 x i32], align 16
@depth = external dso_local local_unnamed_addr global [100010 x i32], align 16
@in_bridge = external dso_local local_unnamed_addr global [100010 x i8], align 16
@cnt = external dso_local local_unnamed_addr global i32, align 4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z8inv_edgei(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z6tarjanii(i32 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = load i32, ptr @timestamp, align 4, !tbaa !5
  %4 = add nsw i32 %3, 1
  store i32 %4, ptr @timestamp, align 4, !tbaa !5
  %5 = sext i32 %0 to i64
  %6 = getelementptr inbounds [100010 x i32], ptr @low, i64 0, i64 %5
  store i32 %4, ptr %6, align 4, !tbaa !5
  %7 = getelementptr inbounds [100010 x i32], ptr @dfn, i64 0, i64 %5
  store i32 %4, ptr %7, align 4, !tbaa !5
  %8 = getelementptr inbounds [100010 x i32], ptr @head, i64 0, i64 %5
  %.026 = load i32, ptr %8, align 4, !tbaa !5
  %.not27 = icmp eq i32 %.026, 0
  br i1 %.not27, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %9 = getelementptr inbounds [100010 x i32], ptr @depth, i64 0, i64 %5
  br label %10

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

10:                                               ; preds = %.lr.ph, %37
  %.028 = phi i32 [ %.026, %.lr.ph ], [ %.0, %37 ]
  %11 = sext i32 %.028 to i64
  %12 = getelementptr inbounds [400010 x %struct.edge], ptr @e, i64 0, i64 %11
  %13 = load i32, ptr %12, align 8, !tbaa !9
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [100010 x i32], ptr @dfn, i64 0, i64 %14
  %16 = load i32, ptr %15, align 4, !tbaa !5
  %.not24 = icmp eq i32 %16, 0
  br i1 %.not24, label %17, label %32

17:                                               ; preds = %10
  %18 = load i32, ptr %9, align 4, !tbaa !5
  %19 = add nsw i32 %18, 1
  %20 = getelementptr inbounds [100010 x i32], ptr @depth, i64 0, i64 %14
  store i32 %19, ptr %20, align 4, !tbaa !5
  %21 = getelementptr inbounds [100010 x i32], ptr @f, i64 0, i64 %14
  store i32 %0, ptr %21, align 4, !tbaa !5
  tail call void @_Z6tarjanii(i32 noundef %13, i32 noundef %.028)
  %22 = getelementptr inbounds [100010 x i32], ptr @low, i64 0, i64 %14
  %23 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(4) %22)
  %24 = load i32, ptr %23, align 4, !tbaa !5
  store i32 %24, ptr %6, align 4, !tbaa !5
  %25 = load i32, ptr %7, align 4, !tbaa !5
  %26 = load i32, ptr %22, align 4, !tbaa !5
  %27 = icmp slt i32 %25, %26
  br i1 %27, label %28, label %37

28:                                               ; preds = %17
  %29 = getelementptr inbounds [100010 x i8], ptr @in_bridge, i64 0, i64 %14
  store i8 1, ptr %29, align 1, !tbaa !11
  %30 = load i32, ptr @cnt, align 4, !tbaa !5
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr @cnt, align 4, !tbaa !5
  br label %37

32:                                               ; preds = %10
  %33 = tail call noundef i32 @_Z8inv_edgei(i32 noundef %1)
  %.not25 = icmp eq i32 %.028, %33
  br i1 %.not25, label %37, label %34

34:                                               ; preds = %32
  %35 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(4) %15)
  %36 = load i32, ptr %35, align 4, !tbaa !5
  store i32 %36, ptr %6, align 4, !tbaa !5
  br label %37

37:                                               ; preds = %32, %34, %17, %28
  %38 = getelementptr inbounds i8, ptr %12, i64 4
  %.0 = load i32, ptr %38, align 4, !tbaa !5
  %.not = icmp eq i32 %.0, 0
  br i1 %.not, label %._crit_edge, label %10, !llvm.loop !13
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) 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 0}
!10 = !{!"_ZTS4edge", !6, i64 0, !6, i64 4}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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