; LLVM IR from Tunghohin/Competitive_Coding :: Luogu/p2341.ll (Z6tarjani)

; 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 [100010 x %struct.edge], align 16
@head = external dso_local global [10010 x i32], align 16
@scc_cnt = external dso_local global i32, align 4
@scc_id = external dso_local global [10010 x i32], align 16
@scc_size = external dso_local global [10010 x i32], align 16
@timestamp = external dso_local global i32, align 4
@dfn = external dso_local global [10010 x i32], align 16
@low = external dso_local global [10010 x i32], align 16
@stk = external dso_local global [10010 x i32], align 16
@top = external dso_local global i32, align 4
@in_stk = external dso_local global [10010 x i32], align 16

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

26:                                               ; preds = %74, %1
  %27 = load i32, ptr %3, align 4, !tbaa !5
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %30, label %29

29:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %80

30:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %31 = load i32, ptr %3, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [100010 x %struct.edge], ptr @e, i64 0, i64 %32
  %34 = getelementptr inbounds %struct.edge, ptr %33, i32 0, i32 0
  %35 = load i32, ptr %34, align 8, !tbaa !9
  store i32 %35, ptr %4, align 4, !tbaa !5
  %36 = load i32, ptr %4, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [10010 x i32], ptr @dfn, i64 0, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %40 = icmp ne i32 %39, 0
  br i1 %40, label %54, label %41

41:                                               ; preds = %30
  %42 = load i32, ptr %4, align 4, !tbaa !5
  call void @_Z6tarjani(i32 noundef %42)
  %43 = load i32, ptr %2, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [10010 x i32], ptr @low, i64 0, i64 %44
  %46 = load i32, ptr %4, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [10010 x i32], ptr @low, i64 0, i64 %47
  %49 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %45, ptr noundef nonnull align 4 dereferenceable(4) %48)
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = load i32, ptr %2, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [10010 x i32], ptr @low, i64 0, i64 %52
  store i32 %50, ptr %53, align 4, !tbaa !5
  br label %73

54:                                               ; preds = %30
  %55 = load i32, ptr %2, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [10010 x i32], ptr @in_stk, i64 0, i64 %56
  %58 = load i32, ptr %57, align 4, !tbaa !5
  %59 = icmp ne i32 %58, 0
  br i1 %59, label %60, label %72

60:                                               ; preds = %54
  %61 = load i32, ptr %2, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [10010 x i32], ptr @low, i64 0, i64 %62
  %64 = load i32, ptr %4, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [10010 x i32], ptr @dfn, i64 0, i64 %65
  %67 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %63, ptr noundef nonnull align 4 dereferenceable(4) %66)
  %68 = load i32, ptr %67, align 4, !tbaa !5
  %69 = load i32, ptr %2, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [10010 x i32], ptr @low, i64 0, i64 %70
  store i32 %68, ptr %71, align 4, !tbaa !5
  br label %72

72:                                               ; preds = %60, %54
  br label %73

73:                                               ; preds = %72, %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %74

74:                                               ; preds = %73
  %75 = load i32, ptr %3, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [100010 x %struct.edge], ptr @e, i64 0, i64 %76
  %78 = getelementptr inbounds %struct.edge, ptr %77, i32 0, i32 1
  %79 = load i32, ptr %78, align 4, !tbaa !11
  store i32 %79, ptr %3, align 4, !tbaa !5
  br label %26, !llvm.loop !12

80:                                               ; preds = %29
  %81 = load i32, ptr %2, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [10010 x i32], ptr @dfn, i64 0, i64 %82
  %84 = load i32, ptr %83, align 4, !tbaa !5
  %85 = load i32, ptr %2, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [10010 x i32], ptr @low, i64 0, i64 %86
  %88 = load i32, ptr %87, align 4, !tbaa !5
  %89 = icmp eq i32 %84, %88
  br i1 %89, label %90, label %116

90:                                               ; preds = %80
  %91 = load i32, ptr @scc_cnt, align 4, !tbaa !5
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr @scc_cnt, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  br label %93

93:                                               ; preds = %111, %90
  %94 = load i32, ptr @top, align 4, !tbaa !5
  %95 = add nsw i32 %94, -1
  store i32 %95, ptr @top, align 4, !tbaa !5
  %96 = sext i32 %94 to i64
  %97 = getelementptr inbounds [10010 x i32], ptr @stk, i64 0, i64 %96
  %98 = load i32, ptr %97, align 4, !tbaa !5
  store i32 %98, ptr %5, align 4, !tbaa !5
  %99 = load i32, ptr %5, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [10010 x i32], ptr @in_stk, i64 0, i64 %100
  store i32 0, ptr %101, align 4, !tbaa !5
  %102 = load i32, ptr @scc_cnt, align 4, !tbaa !5
  %103 = load i32, ptr %5, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [10010 x i32], ptr @scc_id, i64 0, i64 %104
  store i32 %102, ptr %105, align 4, !tbaa !5
  %106 = load i32, ptr @scc_cnt, align 4, !tbaa !5
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [10010 x i32], ptr @scc_size, i64 0, i64 %107
  %109 = load i32, ptr %108, align 4, !tbaa !5
  %110 = add nsw i32 %109, 1
  store i32 %110, ptr %108, align 4, !tbaa !5
  br label %111

111:                                              ; preds = %93
  %112 = load i32, ptr %5, align 4, !tbaa !5
  %113 = load i32, ptr %2, align 4, !tbaa !5
  %114 = icmp ne i32 %112, %113
  br i1 %114, label %93, label %115, !llvm.loop !14

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

116:                                              ; preds = %115, %80
  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 nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #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 0}
!10 = !{!"_ZTS4edge", !6, i64 0, !6, i64 4}
!11 = !{!10, !6, i64 4}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


; 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 [100010 x %struct.edge], align 16
@head = external dso_local local_unnamed_addr global [10010 x i32], align 16
@scc_cnt = external dso_local local_unnamed_addr global i32, align 4
@scc_id = external dso_local local_unnamed_addr global [10010 x i32], align 16
@scc_size = external dso_local local_unnamed_addr global [10010 x i32], align 16
@timestamp = external dso_local local_unnamed_addr global i32, align 4
@dfn = external dso_local global [10010 x i32], align 16
@low = external dso_local global [10010 x i32], align 16
@stk = external dso_local local_unnamed_addr global [10010 x i32], align 16
@top = external dso_local local_unnamed_addr global i32, align 4
@in_stk = external dso_local local_unnamed_addr global [10010 x i32], align 16

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

._crit_edge:                                      ; preds = %27
  %.pre = load i32, ptr %6, align 4, !tbaa !5
  %13 = icmp eq i32 %.pre, %28
  br i1 %13, label %._crit_edge.thread, label %44

.lr.ph:                                           ; preds = %1, %27
  %14 = phi i32 [ %28, %27 ], [ %3, %1 ]
  %.028 = phi i32 [ %.0, %27 ], [ %.026, %1 ]
  %15 = sext i32 %.028 to i64
  %16 = getelementptr inbounds [100010 x %struct.edge], ptr @e, i64 0, i64 %15
  %17 = load i32, ptr %16, align 8, !tbaa !9
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [10010 x i32], ptr @dfn, i64 0, i64 %18
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %.not24 = icmp eq i32 %20, 0
  br i1 %.not24, label %21, label %23

21:                                               ; preds = %.lr.ph
  tail call void @_Z6tarjani(i32 noundef %17)
  %22 = getelementptr inbounds [10010 x i32], ptr @low, i64 0, i64 %18
  br label %.sink.split

23:                                               ; preds = %.lr.ph
  %24 = load i32, ptr %11, align 4, !tbaa !5
  %.not25 = icmp eq i32 %24, 0
  br i1 %.not25, label %27, label %.sink.split

.sink.split:                                      ; preds = %23, %21
  %.sink = phi ptr [ %22, %21 ], [ %19, %23 ]
  %25 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %.sink)
  %26 = load i32, ptr %25, align 4, !tbaa !5
  store i32 %26, ptr %5, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %.sink.split, %23
  %28 = phi i32 [ %14, %23 ], [ %26, %.sink.split ]
  %29 = getelementptr inbounds i8, ptr %16, i64 4
  %.0 = load i32, ptr %29, align 4, !tbaa !5
  %.not = icmp eq i32 %.0, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11

._crit_edge.thread:                               ; preds = %1, %._crit_edge
  %30 = load i32, ptr @scc_cnt, align 4, !tbaa !5
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr @scc_cnt, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [10010 x i32], ptr @scc_size, i64 0, i64 %32
  %top.promoted = load i32, ptr @top, align 4, !tbaa !5
  %.promoted = load i32, ptr %33, align 4, !tbaa !5
  %34 = sext i32 %top.promoted to i64
  br label %35

35:                                               ; preds = %35, %._crit_edge.thread
  %indvars.iv = phi i64 [ %indvars.iv.next, %35 ], [ %34, %._crit_edge.thread ]
  %36 = phi i32 [ %42, %35 ], [ %.promoted, %._crit_edge.thread ]
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %37 = getelementptr inbounds [10010 x i32], ptr @stk, i64 0, i64 %indvars.iv
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [10010 x i32], ptr @in_stk, i64 0, i64 %39
  store i32 0, ptr %40, align 4, !tbaa !5
  %41 = getelementptr inbounds [10010 x i32], ptr @scc_id, i64 0, i64 %39
  store i32 %31, ptr %41, align 4, !tbaa !5
  %42 = add nsw i32 %36, 1
  %.not23 = icmp eq i32 %38, %0
  br i1 %.not23, label %.loopexit, label %35, !llvm.loop !13

.loopexit:                                        ; preds = %35
  %43 = trunc nsw i64 %indvars.iv.next to i32
  store i32 %43, ptr @top, align 4, !tbaa !5
  store i32 %42, ptr %33, align 4, !tbaa !5
  br label %44

44:                                               ; preds = %.loopexit, %._crit_edge
  ret void
}

; 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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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