; LLVM IR from tangjz/acm-icpc :: uvalive/6140.ll (Z3dfsi)

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

@nxt = external dso_local global [100010 x i32], align 16
@cir = external dso_local global [100010 x i32], align 16
@fa = external dso_local global [100010 x [18 x i32]], align 16
@gen = external dso_local global [100010 x i32], align 16
@vis = external dso_local global [100010 x i32], align 16
@dep = external dso_local global [100010 x i32], align 16

; Function Attrs: mustprogress uwtable
define dso_local void @_Z3dfsi(i32 noundef %0) #0 {
  %2 = alloca i32, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  %3 = load i32, ptr %2, align 4, !tbaa !5
  %4 = sext i32 %3 to i64
  %5 = getelementptr inbounds [100010 x i32], ptr @vis, i64 0, i64 %4
  store i32 1, ptr %5, align 4, !tbaa !5
  %6 = load i32, ptr %2, align 4, !tbaa !5
  %7 = sext i32 %6 to i64
  %8 = getelementptr inbounds [100010 x i32], ptr @cir, i64 0, i64 %7
  %9 = load i32, ptr %8, align 4, !tbaa !5
  %10 = icmp ne i32 %9, 0
  br i1 %10, label %55, label %11

11:                                               ; preds = %1
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [100010 x i32], ptr @nxt, i64 0, i64 %13
  %15 = load i32, ptr %14, align 4, !tbaa !5
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [100010 x [18 x i32]], ptr @fa, i64 0, i64 %17
  %19 = getelementptr inbounds [18 x i32], ptr %18, i64 0, i64 0
  store i32 %15, ptr %19, align 8, !tbaa !5
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [100010 x i32], ptr @nxt, i64 0, i64 %21
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [100010 x i32], ptr @vis, i64 0, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %33, label %28

28:                                               ; preds = %11
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [100010 x i32], ptr @nxt, i64 0, i64 %30
  %32 = load i32, ptr %31, align 4, !tbaa !5
  call void @_Z3dfsi(i32 noundef %32)
  br label %33

33:                                               ; preds = %28, %11
  %34 = load i32, ptr %2, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [100010 x i32], ptr @nxt, i64 0, i64 %35
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [100010 x i32], ptr @gen, i64 0, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = load i32, ptr %2, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [100010 x i32], ptr @gen, i64 0, i64 %42
  store i32 %40, ptr %43, align 4, !tbaa !5
  %44 = load i32, ptr %2, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [100010 x i32], ptr @nxt, i64 0, i64 %45
  %47 = load i32, ptr %46, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [100010 x i32], ptr @dep, i64 0, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = add nsw i32 %50, 1
  %52 = load i32, ptr %2, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [100010 x i32], ptr @dep, i64 0, i64 %53
  store i32 %51, ptr %54, align 4, !tbaa !5
  br label %67

55:                                               ; preds = %1
  %56 = load i32, ptr %2, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [100010 x [18 x i32]], ptr @fa, i64 0, i64 %57
  %59 = getelementptr inbounds [18 x i32], ptr %58, i64 0, i64 0
  store i32 0, ptr %59, align 8, !tbaa !5
  %60 = load i32, ptr %2, align 4, !tbaa !5
  %61 = load i32, ptr %2, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [100010 x i32], ptr @gen, i64 0, i64 %62
  store i32 %60, ptr %63, align 4, !tbaa !5
  %64 = load i32, ptr %2, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [100010 x i32], ptr @dep, i64 0, i64 %65
  store i32 0, ptr %66, align 4, !tbaa !5
  br label %67

67:                                               ; preds = %55, %33
  ret void
}

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

!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"}


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

@nxt = external dso_local local_unnamed_addr global [100010 x i32], align 16
@cir = external dso_local local_unnamed_addr global [100010 x i32], align 16
@fa = external dso_local local_unnamed_addr global [100010 x [18 x i32]], align 16
@gen = external dso_local local_unnamed_addr global [100010 x i32], align 16
@vis = external dso_local local_unnamed_addr global [100010 x i32], align 16
@dep = external dso_local local_unnamed_addr global [100010 x i32], align 16

; Function Attrs: mustprogress nofree nosync nounwind memory(readwrite, argmem: none, inaccessiblemem: none) uwtable
define dso_local void @_Z3dfsi(i32 noundef %0) local_unnamed_addr #0 {
  %2 = sext i32 %0 to i64
  %3 = getelementptr inbounds [100010 x i32], ptr @vis, i64 0, i64 %2
  store i32 1, ptr %3, align 4, !tbaa !5
  %4 = getelementptr inbounds [100010 x i32], ptr @cir, i64 0, i64 %2
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %6, label %21

6:                                                ; preds = %1
  %7 = getelementptr inbounds [100010 x i32], ptr @nxt, i64 0, i64 %2
  %8 = load i32, ptr %7, align 4, !tbaa !5
  %9 = getelementptr inbounds [100010 x [18 x i32]], ptr @fa, i64 0, i64 %2
  store i32 %8, ptr %9, align 8, !tbaa !5
  %10 = sext i32 %8 to i64
  %11 = getelementptr inbounds [100010 x i32], ptr @vis, i64 0, i64 %10
  %12 = load i32, ptr %11, align 4, !tbaa !5
  %.not14 = icmp eq i32 %12, 0
  br i1 %.not14, label %13, label %14

13:                                               ; preds = %6
  tail call void @_Z3dfsi(i32 noundef %8)
  %.pre = load i32, ptr %7, align 4, !tbaa !5
  %.pre15 = sext i32 %.pre to i64
  br label %14

14:                                               ; preds = %13, %6
  %.pre-phi = phi i64 [ %.pre15, %13 ], [ %10, %6 ]
  %15 = getelementptr inbounds [100010 x i32], ptr @gen, i64 0, i64 %.pre-phi
  %16 = load i32, ptr %15, align 4, !tbaa !5
  %17 = getelementptr inbounds [100010 x i32], ptr @gen, i64 0, i64 %2
  store i32 %16, ptr %17, align 4, !tbaa !5
  %18 = getelementptr inbounds [100010 x i32], ptr @dep, i64 0, i64 %.pre-phi
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = add nsw i32 %19, 1
  br label %24

21:                                               ; preds = %1
  %22 = getelementptr inbounds [100010 x [18 x i32]], ptr @fa, i64 0, i64 %2
  store i32 0, ptr %22, align 8, !tbaa !5
  %23 = getelementptr inbounds [100010 x i32], ptr @gen, i64 0, i64 %2
  store i32 %0, ptr %23, align 4, !tbaa !5
  br label %24

24:                                               ; preds = %21, %14
  %.sink = phi i32 [ 0, %21 ], [ %20, %14 ]
  %25 = getelementptr inbounds [100010 x i32], ptr @dep, i64 0, i64 %2
  store i32 %.sink, ptr %25, align 4, !tbaa !5
  ret void
}

attributes #0 = { mustprogress nofree nosync nounwind memory(readwrite, argmem: none, 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, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass