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

; 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_Automaton3parE = external dso_local global [210000 x i32], align 16
@_ZN28Generalized_Suffix_Automaton5labelE = external dso_local global [210000 x i32], align 16
@_ZN28Generalized_Suffix_Automaton5timesE = external dso_local global [210000 x i32], align 16
@_ZN28Generalized_Suffix_Automaton3curE = external dso_local global i32, align 4
@_ZN28Generalized_Suffix_Automaton4rootE = external dso_local global i32, align 4
@_ZN28Generalized_Suffix_Automaton4lastE = external dso_local global i32, align 4
@_ZN28Generalized_Suffix_Automaton3posE = external dso_local global [210000 x i32], 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: 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)) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN28Generalized_Suffix_Automaton6extendEii(i32 noundef, i32 noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN28Generalized_Suffix_Automaton6insertERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %10 = load i32, ptr @_ZN28Generalized_Suffix_Automaton4rootE, align 4, !tbaa !9
  store i32 %10, ptr @_ZN28Generalized_Suffix_Automaton4lastE, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %11 = load i32, ptr @_ZN28Generalized_Suffix_Automaton3curE, align 4, !tbaa !9
  store i32 %11, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %34, %2
  %13 = load i32, ptr %6, align 4, !tbaa !9
  %14 = sext i32 %13 to i64
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %15) #4
  %17 = icmp ult i64 %14, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %37

19:                                               ; preds = %12
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = load i32, ptr %6, align 4, !tbaa !9
  %22 = sext i32 %21 to i64
  %23 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %20, i64 noundef %22) #4
  %24 = load i8, ptr %23, align 1, !tbaa !11
  %25 = sext i8 %24 to i32
  %26 = sub nsw i32 %25, 97
  %27 = load i32, ptr %4, align 4, !tbaa !9
  %28 = icmp eq i32 %27, 0
  br i1 %28, label %29, label %31

29:                                               ; preds = %19
  %30 = load i32, ptr %6, align 4, !tbaa !9
  br label %32

31:                                               ; preds = %19
  br label %32

32:                                               ; preds = %31, %29
  %33 = phi i32 [ %30, %29 ], [ 210000, %31 ]
  call void @_ZN28Generalized_Suffix_Automaton6extendEii(i32 noundef %26, i32 noundef %33)
  br label %34

34:                                               ; preds = %32
  %35 = load i32, ptr %6, align 4, !tbaa !9
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %6, align 4, !tbaa !9
  br label %12, !llvm.loop !12

37:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %38 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %38, ptr %7, align 4, !tbaa !9
  br label %39

39:                                               ; preds = %92, %37
  %40 = load i32, ptr %7, align 4, !tbaa !9
  %41 = load i32, ptr @_ZN28Generalized_Suffix_Automaton3curE, align 4, !tbaa !9
  %42 = icmp slt i32 %40, %41
  br i1 %42, label %44, label %43

43:                                               ; preds = %39
  store i32 5, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %95

44:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %45 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %45, ptr %9, align 4, !tbaa !9
  br label %46

46:                                               ; preds = %86, %44
  %47 = load i32, ptr %9, align 4, !tbaa !9
  %48 = icmp ne i32 %47, 0
  br i1 %48, label %49, label %56

49:                                               ; preds = %46
  %50 = load i32, ptr %9, align 4, !tbaa !9
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [210000 x i32], ptr @_ZN28Generalized_Suffix_Automaton5labelE, i64 0, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !9
  %54 = load i32, ptr %4, align 4, !tbaa !9
  %55 = icmp ne i32 %53, %54
  br label %56

56:                                               ; preds = %49, %46
  %57 = phi i1 [ false, %46 ], [ %55, %49 ]
  br i1 %57, label %59, label %58

58:                                               ; preds = %56
  store i32 8, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %91

59:                                               ; preds = %56
  %60 = load i32, ptr %4, align 4, !tbaa !9
  %61 = load i32, ptr %9, align 4, !tbaa !9
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [210000 x i32], ptr @_ZN28Generalized_Suffix_Automaton5labelE, i64 0, i64 %62
  store i32 %60, ptr %63, align 4, !tbaa !9
  %64 = load i32, ptr %9, align 4, !tbaa !9
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [210000 x i32], ptr @_ZN28Generalized_Suffix_Automaton5timesE, i64 0, i64 %65
  %67 = load i32, ptr %66, align 4, !tbaa !9
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %66, align 4, !tbaa !9
  %69 = load i32, ptr %9, align 4, !tbaa !9
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [210000 x i32], ptr @_ZN28Generalized_Suffix_Automaton3parE, i64 0, i64 %70
  %72 = load i32, ptr %71, align 4, !tbaa !9
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [210000 x i32], ptr @_ZN28Generalized_Suffix_Automaton3posE, i64 0, i64 %73
  %75 = load i32, ptr %9, align 4, !tbaa !9
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [210000 x i32], ptr @_ZN28Generalized_Suffix_Automaton3posE, i64 0, i64 %76
  %78 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %74, ptr noundef nonnull align 4 dereferenceable(4) %77)
  %79 = load i32, ptr %78, align 4, !tbaa !9
  %80 = load i32, ptr %9, align 4, !tbaa !9
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [210000 x i32], ptr @_ZN28Generalized_Suffix_Automaton3parE, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !9
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [210000 x i32], ptr @_ZN28Generalized_Suffix_Automaton3posE, i64 0, i64 %84
  store i32 %79, ptr %85, align 4, !tbaa !9
  br label %86

86:                                               ; preds = %59
  %87 = load i32, ptr %9, align 4, !tbaa !9
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [210000 x i32], ptr @_ZN28Generalized_Suffix_Automaton3parE, i64 0, i64 %88
  %90 = load i32, ptr %89, align 4, !tbaa !9
  store i32 %90, ptr %9, align 4, !tbaa !9
  br label %46, !llvm.loop !14

91:                                               ; preds = %58
  br label %92

92:                                               ; preds = %91
  %93 = load i32, ptr %7, align 4, !tbaa !9
  %94 = add nsw i32 %93, 1
  store i32 %94, ptr %7, align 4, !tbaa !9
  br label %39, !llvm.loop !15

95:                                               ; preds = %43
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { 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 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = distinct !{!15, !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"

@_ZN28Generalized_Suffix_Automaton3parE = external dso_local local_unnamed_addr global [210000 x i32], align 16
@_ZN28Generalized_Suffix_Automaton5labelE = external dso_local local_unnamed_addr global [210000 x i32], align 16
@_ZN28Generalized_Suffix_Automaton5timesE = external dso_local local_unnamed_addr global [210000 x i32], align 16
@_ZN28Generalized_Suffix_Automaton3curE = external dso_local local_unnamed_addr global i32, align 4
@_ZN28Generalized_Suffix_Automaton4rootE = external dso_local local_unnamed_addr global i32, align 4
@_ZN28Generalized_Suffix_Automaton4lastE = external dso_local local_unnamed_addr global i32, align 4
@_ZN28Generalized_Suffix_Automaton3posE = external dso_local global [210000 x i32], align 16

; 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 #0

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN28Generalized_Suffix_Automaton6insertERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = load i32, ptr @_ZN28Generalized_Suffix_Automaton4rootE, align 4, !tbaa !5
  store i32 %3, ptr @_ZN28Generalized_Suffix_Automaton4lastE, align 4, !tbaa !5
  %4 = load i32, ptr @_ZN28Generalized_Suffix_Automaton3curE, align 4, !tbaa !5
  %5 = tail call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %0) #2
  %.not32 = icmp eq i64 %5, 0
  br i1 %.not32, label %.preheader25, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %6 = icmp eq i32 %1, 0
  br i1 %6, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %.lr.ph.split.us
  %indvars.iv35 = phi i64 [ %indvars.iv.next36, %.lr.ph.split.us ], [ 0, %.lr.ph ]
  %7 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef %indvars.iv35) #2
  %8 = load i8, ptr %7, align 1, !tbaa !9
  %9 = sext i8 %8 to i32
  %10 = add nsw i32 %9, -97
  %11 = trunc nuw nsw i64 %indvars.iv35 to i32
  tail call void @_ZN28Generalized_Suffix_Automaton6extendEii(i32 noundef %10, i32 noundef %11)
  %indvars.iv.next36 = add nuw nsw i64 %indvars.iv35, 1
  %12 = tail call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %0) #2
  %13 = icmp ugt i64 %12, %indvars.iv.next36
  br i1 %13, label %.lr.ph.split.us, label %.preheader25, !llvm.loop !10

.preheader25:                                     ; preds = %.lr.ph.split, %.lr.ph.split.us, %2
  %14 = load i32, ptr @_ZN28Generalized_Suffix_Automaton3curE, align 4, !tbaa !5
  %15 = icmp slt i32 %4, %14
  br i1 %15, label %.preheader, label %._crit_edge

.lr.ph.split:                                     ; preds = %.lr.ph, %.lr.ph.split
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph.split ], [ 0, %.lr.ph ]
  %16 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef %indvars.iv) #2
  %17 = load i8, ptr %16, align 1, !tbaa !9
  %18 = sext i8 %17 to i32
  %19 = add nsw i32 %18, -97
  tail call void @_ZN28Generalized_Suffix_Automaton6extendEii(i32 noundef %19, i32 noundef 210000)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %20 = tail call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %0) #2
  %21 = icmp ugt i64 %20, %indvars.iv.next
  br i1 %21, label %.lr.ph.split, label %.preheader25, !llvm.loop !10

.preheader:                                       ; preds = %.preheader25, %.critedge
  %22 = phi i32 [ %26, %.critedge ], [ %14, %.preheader25 ]
  %.02031 = phi i32 [ %27, %.critedge ], [ %4, %.preheader25 ]
  %.not27 = icmp eq i32 %.02031, 0
  br i1 %.not27, label %.critedge, label %.lr.ph29

._crit_edge:                                      ; preds = %.critedge, %.preheader25
  ret void

.lr.ph29:                                         ; preds = %.preheader, %29
  %.028 = phi i32 [ %40, %29 ], [ %.02031, %.preheader ]
  %23 = sext i32 %.028 to i64
  %24 = getelementptr inbounds [210000 x i32], ptr @_ZN28Generalized_Suffix_Automaton5labelE, i64 0, i64 %23
  %25 = load i32, ptr %24, align 4, !tbaa !5
  %.not24 = icmp eq i32 %25, %1
  br i1 %.not24, label %.critedge.loopexit, label %29

.critedge.loopexit:                               ; preds = %29, %.lr.ph29
  %.pre = load i32, ptr @_ZN28Generalized_Suffix_Automaton3curE, align 4, !tbaa !5
  br label %.critedge

.critedge:                                        ; preds = %.critedge.loopexit, %.preheader
  %26 = phi i32 [ %.pre, %.critedge.loopexit ], [ %22, %.preheader ]
  %27 = add nsw i32 %.02031, 1
  %28 = icmp slt i32 %27, %26
  br i1 %28, label %.preheader, label %._crit_edge, !llvm.loop !12

29:                                               ; preds = %.lr.ph29
  store i32 %1, ptr %24, align 4, !tbaa !5
  %30 = getelementptr inbounds [210000 x i32], ptr @_ZN28Generalized_Suffix_Automaton5timesE, i64 0, i64 %23
  %31 = load i32, ptr %30, align 4, !tbaa !5
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %30, align 4, !tbaa !5
  %33 = getelementptr inbounds [210000 x i32], ptr @_ZN28Generalized_Suffix_Automaton3parE, i64 0, i64 %23
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [210000 x i32], ptr @_ZN28Generalized_Suffix_Automaton3posE, i64 0, i64 %35
  %37 = getelementptr inbounds [210000 x i32], ptr @_ZN28Generalized_Suffix_Automaton3posE, i64 0, i64 %23
  %38 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %36, ptr noundef nonnull align 4 dereferenceable(4) %37)
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %40 = load i32, ptr %33, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [210000 x i32], ptr @_ZN28Generalized_Suffix_Automaton3posE, i64 0, i64 %41
  store i32 %39, ptr %42, align 4, !tbaa !5
  %.not = icmp eq i32 %40, 0
  br i1 %.not, label %.critedge.loopexit, label %.lr.ph29, !llvm.loop !13
}

; Function Attrs: mustprogress nounwind uwtable
declare noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) local_unnamed_addr #1 align 2

attributes #0 = { 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 #1 = { 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 #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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}
!13 = distinct !{!13, !11}


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