; LLVM IR from sunkafei/xcpc-algorithm-templates :: 算法/字符串算法/后缀自动机.ll (ZN28Generalized_Suffix_Automaton3dfsEi)

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

@_ZN28Generalized_Suffix_Automaton2goE = external dso_local global [210000 x [26 x i32]], align 16
@_ZN28Generalized_Suffix_Automaton5timesE = external dso_local global [210000 x i32], align 16
@_ZN28Generalized_Suffix_Automaton1nE = external dso_local global i32, align 4
@_ZN28Generalized_Suffix_Automaton2dpE = external dso_local global [210000 x i64], 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 noundef i64 @_ZN28Generalized_Suffix_Automaton3dfsEi(i32 noundef %0) #1 {
  %2 = alloca i64, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  %5 = load i32, ptr %3, align 4, !tbaa !5
  %6 = sext i32 %5 to i64
  %7 = getelementptr inbounds [210000 x i64], ptr @_ZN28Generalized_Suffix_Automaton2dpE, i64 0, i64 %6
  %8 = load i64, ptr %7, align 8, !tbaa !9
  %9 = icmp sgt i64 %8, 0
  br i1 %9, label %10, label %15

10:                                               ; preds = %1
  %11 = load i32, ptr %3, align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds [210000 x i64], ptr @_ZN28Generalized_Suffix_Automaton2dpE, i64 0, i64 %12
  %14 = load i64, ptr %13, align 8, !tbaa !9
  store i64 %14, ptr %2, align 8
  br label %69

15:                                               ; preds = %1
  %16 = load i32, ptr %3, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [210000 x i64], ptr @_ZN28Generalized_Suffix_Automaton2dpE, i64 0, i64 %17
  store i64 0, ptr %18, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %61, %15
  %20 = load i32, ptr %4, align 4, !tbaa !5
  %21 = icmp slt i32 %20, 26
  br i1 %21, label %23, label %22

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

23:                                               ; preds = %19
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [210000 x [26 x i32]], ptr @_ZN28Generalized_Suffix_Automaton2goE, i64 0, i64 %25
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [26 x i32], ptr %26, i64 0, i64 %28
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %32, label %60

32:                                               ; preds = %23
  %33 = load i32, ptr %3, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [210000 x [26 x i32]], ptr @_ZN28Generalized_Suffix_Automaton2goE, i64 0, i64 %34
  %36 = load i32, ptr %4, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [26 x i32], ptr %35, i64 0, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [210000 x i32], ptr @_ZN28Generalized_Suffix_Automaton5timesE, i64 0, i64 %40
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %43 = load i32, ptr @_ZN28Generalized_Suffix_Automaton1nE, align 4, !tbaa !5
  %44 = icmp eq i32 %42, %43
  br i1 %44, label %45, label %60

45:                                               ; preds = %32
  %46 = load i32, ptr %3, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [210000 x [26 x i32]], ptr @_ZN28Generalized_Suffix_Automaton2goE, i64 0, i64 %47
  %49 = load i32, ptr %4, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [26 x i32], ptr %48, i64 0, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = call noundef i64 @_ZN28Generalized_Suffix_Automaton3dfsEi(i32 noundef %52)
  %54 = add nsw i64 %53, 1
  %55 = load i32, ptr %3, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [210000 x i64], ptr @_ZN28Generalized_Suffix_Automaton2dpE, i64 0, i64 %56
  %58 = load i64, ptr %57, align 8, !tbaa !9
  %59 = add nsw i64 %58, %54
  store i64 %59, ptr %57, align 8, !tbaa !9
  br label %60

60:                                               ; preds = %45, %32, %23
  br label %61

61:                                               ; preds = %60
  %62 = load i32, ptr %4, align 4, !tbaa !5
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %4, align 4, !tbaa !5
  br label %19, !llvm.loop !11

64:                                               ; preds = %22
  %65 = load i32, ptr %3, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [210000 x i64], ptr @_ZN28Generalized_Suffix_Automaton2dpE, i64 0, i64 %66
  %68 = load i64, ptr %67, align 8, !tbaa !9
  store i64 %68, ptr %2, align 8
  br label %69

69:                                               ; preds = %64, %10
  %70 = load i64, ptr %2, align 8
  ret i64 %70
}

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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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"

@_ZN28Generalized_Suffix_Automaton2goE = external dso_local local_unnamed_addr global [210000 x [26 x i32]], align 16
@_ZN28Generalized_Suffix_Automaton5timesE = external dso_local local_unnamed_addr global [210000 x i32], align 16
@_ZN28Generalized_Suffix_Automaton1nE = external dso_local local_unnamed_addr global i32, align 4
@_ZN28Generalized_Suffix_Automaton2dpE = external dso_local local_unnamed_addr global [210000 x i64], align 16

; Function Attrs: mustprogress nofree nosync nounwind memory(readwrite, argmem: none, inaccessiblemem: none) uwtable
define dso_local noundef i64 @_ZN28Generalized_Suffix_Automaton3dfsEi(i32 noundef %0) local_unnamed_addr #0 {
  %2 = sext i32 %0 to i64
  %3 = getelementptr inbounds [210000 x i64], ptr @_ZN28Generalized_Suffix_Automaton2dpE, i64 0, i64 %2
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %5 = icmp sgt i64 %4, 0
  br i1 %5, label %.loopexit, label %6

6:                                                ; preds = %1
  store i64 0, ptr %3, align 8, !tbaa !5
  br label %7

7:                                                ; preds = %6, %22
  %8 = phi i64 [ 0, %6 ], [ %23, %22 ]
  %indvars.iv = phi i64 [ 0, %6 ], [ %indvars.iv.next, %22 ]
  %9 = getelementptr inbounds [210000 x [26 x i32]], ptr @_ZN28Generalized_Suffix_Automaton2goE, i64 0, i64 %2, i64 %indvars.iv
  %10 = load i32, ptr %9, align 4, !tbaa !9
  %.not = icmp eq i32 %10, 0
  br i1 %.not, label %22, label %11

11:                                               ; preds = %7
  %12 = sext i32 %10 to i64
  %13 = getelementptr inbounds [210000 x i32], ptr @_ZN28Generalized_Suffix_Automaton5timesE, i64 0, i64 %12
  %14 = load i32, ptr %13, align 4, !tbaa !9
  %15 = load i32, ptr @_ZN28Generalized_Suffix_Automaton1nE, align 4, !tbaa !9
  %16 = icmp eq i32 %14, %15
  br i1 %16, label %17, label %22

17:                                               ; preds = %11
  %18 = tail call noundef i64 @_ZN28Generalized_Suffix_Automaton3dfsEi(i32 noundef %10)
  %19 = add nsw i64 %18, 1
  %20 = load i64, ptr %3, align 8, !tbaa !5
  %21 = add nsw i64 %19, %20
  store i64 %21, ptr %3, align 8, !tbaa !5
  br label %22

22:                                               ; preds = %7, %11, %17
  %23 = phi i64 [ %8, %7 ], [ %8, %11 ], [ %21, %17 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 26
  br i1 %exitcond.not, label %.loopexit, label %7, !llvm.loop !11

.loopexit:                                        ; preds = %22, %1
  %.014 = phi i64 [ %4, %1 ], [ %23, %22 ]
  ret i64 %.014
}

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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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