; LLVM IR from sunkafei/xcpc-algorithm-templates :: 算法/字符串算法/基于后缀自动机构建后缀树.ll (Z6extendii)

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

@par = external dso_local global [2010000 x i32], align 16
@len = external dso_local global [2010000 x i32], align 16
@root = external dso_local global i32, align 4
@last = external dso_local global i32, align 4
@ch = external dso_local global [2010000 x [26 x i32]], align 16
@issuf = external dso_local global [2010000 x i8], align 16
@pos = external dso_local global [2010000 x i32], align 16
@node = external dso_local global [2010000 x i32], align 16

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z6extendii(i32 noundef %0, i32 noundef %1) #0 {
  %3 = alloca i32, align 4
  %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
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %9 = load i32, ptr @last, align 4, !tbaa !5
  store i32 %9, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %10 = load i32, ptr %5, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds [2010000 x i32], ptr @len, i64 0, i64 %11
  %13 = load i32, ptr %12, align 4, !tbaa !5
  %14 = add nsw i32 %13, 1
  %15 = load i32, ptr %4, align 4, !tbaa !5
  %16 = call noundef i32 @_Z8newstateii(i32 noundef %14, i32 noundef %15)
  store i32 %16, ptr %6, align 4, !tbaa !5
  %17 = load i32, ptr %6, align 4, !tbaa !5
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [2010000 x i32], ptr @node, i64 0, i64 %19
  store i32 %17, ptr %20, align 4, !tbaa !5
  %21 = load i32, ptr %6, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [2010000 x i8], ptr @issuf, i64 0, i64 %22
  store i8 1, ptr %23, align 1, !tbaa !9
  br label %24

24:                                               ; preds = %39, %2
  %25 = load i32, ptr %5, align 4, !tbaa !5
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %27, label %37

27:                                               ; preds = %24
  %28 = load i32, ptr %5, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [2010000 x [26 x i32]], ptr @ch, i64 0, i64 %29
  %31 = load i32, ptr %3, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [26 x i32], ptr %30, i64 0, i64 %32
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = icmp ne i32 %34, 0
  %36 = xor i1 %35, true
  br label %37

37:                                               ; preds = %27, %24
  %38 = phi i1 [ false, %24 ], [ %36, %27 ]
  br i1 %38, label %39, label %51

39:                                               ; preds = %37
  %40 = load i32, ptr %6, align 4, !tbaa !5
  %41 = load i32, ptr %5, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [2010000 x [26 x i32]], ptr @ch, i64 0, i64 %42
  %44 = load i32, ptr %3, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [26 x i32], ptr %43, i64 0, i64 %45
  store i32 %40, ptr %46, align 4, !tbaa !5
  %47 = load i32, ptr %5, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [2010000 x i32], ptr @par, i64 0, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !5
  store i32 %50, ptr %5, align 4, !tbaa !5
  br label %24, !llvm.loop !11

51:                                               ; preds = %37
  %52 = load i32, ptr %5, align 4, !tbaa !5
  %53 = icmp ne i32 %52, 0
  br i1 %53, label %59, label %54

54:                                               ; preds = %51
  %55 = load i32, ptr @root, align 4, !tbaa !5
  %56 = load i32, ptr %6, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [2010000 x i32], ptr @par, i64 0, i64 %57
  store i32 %55, ptr %58, align 4, !tbaa !5
  br label %144

59:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %60 = load i32, ptr %5, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [2010000 x [26 x i32]], ptr @ch, i64 0, i64 %61
  %63 = load i32, ptr %3, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [26 x i32], ptr %62, i64 0, i64 %64
  %66 = load i32, ptr %65, align 4, !tbaa !5
  store i32 %66, ptr %7, align 4, !tbaa !5
  %67 = load i32, ptr %5, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [2010000 x i32], ptr @len, i64 0, i64 %68
  %70 = load i32, ptr %69, align 4, !tbaa !5
  %71 = add nsw i32 %70, 1
  %72 = load i32, ptr %7, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [2010000 x i32], ptr @len, i64 0, i64 %73
  %75 = load i32, ptr %74, align 4, !tbaa !5
  %76 = icmp eq i32 %71, %75
  br i1 %76, label %77, label %82

77:                                               ; preds = %59
  %78 = load i32, ptr %7, align 4, !tbaa !5
  %79 = load i32, ptr %6, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [2010000 x i32], ptr @par, i64 0, i64 %80
  store i32 %78, ptr %81, align 4, !tbaa !5
  br label %143

82:                                               ; preds = %59
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %83 = load i32, ptr %5, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [2010000 x i32], ptr @len, i64 0, i64 %84
  %86 = load i32, ptr %85, align 4, !tbaa !5
  %87 = add nsw i32 %86, 1
  %88 = load i32, ptr %7, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [2010000 x i32], ptr @pos, i64 0, i64 %89
  %91 = load i32, ptr %90, align 4, !tbaa !5
  %92 = call noundef i32 @_Z8newstateii(i32 noundef %87, i32 noundef %91)
  store i32 %92, ptr %8, align 4, !tbaa !5
  %93 = load i32, ptr %8, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [2010000 x [26 x i32]], ptr @ch, i64 0, i64 %94
  %96 = getelementptr inbounds [26 x i32], ptr %95, i64 0, i64 0
  %97 = load i32, ptr %7, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [2010000 x [26 x i32]], ptr @ch, i64 0, i64 %98
  %100 = getelementptr inbounds [26 x i32], ptr %99, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %96, ptr align 8 %100, i64 104, i1 false)
  %101 = load i32, ptr %7, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [2010000 x i32], ptr @par, i64 0, i64 %102
  %104 = load i32, ptr %103, align 4, !tbaa !5
  %105 = load i32, ptr %8, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [2010000 x i32], ptr @par, i64 0, i64 %106
  store i32 %104, ptr %107, align 4, !tbaa !5
  %108 = load i32, ptr %8, align 4, !tbaa !5
  %109 = load i32, ptr %7, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [2010000 x i32], ptr @par, i64 0, i64 %110
  store i32 %108, ptr %111, align 4, !tbaa !5
  %112 = load i32, ptr %6, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [2010000 x i32], ptr @par, i64 0, i64 %113
  store i32 %108, ptr %114, align 4, !tbaa !5
  br label %115

115:                                              ; preds = %130, %82
  %116 = load i32, ptr %5, align 4, !tbaa !5
  %117 = icmp ne i32 %116, 0
  br i1 %117, label %118, label %128

118:                                              ; preds = %115
  %119 = load i32, ptr %5, align 4, !tbaa !5
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds [2010000 x [26 x i32]], ptr @ch, i64 0, i64 %120
  %122 = load i32, ptr %3, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds [26 x i32], ptr %121, i64 0, i64 %123
  %125 = load i32, ptr %124, align 4, !tbaa !5
  %126 = load i32, ptr %7, align 4, !tbaa !5
  %127 = icmp eq i32 %125, %126
  br label %128

128:                                              ; preds = %118, %115
  %129 = phi i1 [ false, %115 ], [ %127, %118 ]
  br i1 %129, label %130, label %142

130:                                              ; preds = %128
  %131 = load i32, ptr %8, align 4, !tbaa !5
  %132 = load i32, ptr %5, align 4, !tbaa !5
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds [2010000 x [26 x i32]], ptr @ch, i64 0, i64 %133
  %135 = load i32, ptr %3, align 4, !tbaa !5
  %136 = sext i32 %135 to i64
  %137 = getelementptr inbounds [26 x i32], ptr %134, i64 0, i64 %136
  store i32 %131, ptr %137, align 4, !tbaa !5
  %138 = load i32, ptr %5, align 4, !tbaa !5
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds [2010000 x i32], ptr @par, i64 0, i64 %139
  %141 = load i32, ptr %140, align 4, !tbaa !5
  store i32 %141, ptr %5, align 4, !tbaa !5
  br label %115, !llvm.loop !13

142:                                              ; preds = %128
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %143

143:                                              ; preds = %142, %77
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %144

144:                                              ; preds = %143, %54
  %145 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %145, ptr @last, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #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 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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

@par = external dso_local local_unnamed_addr global [2010000 x i32], align 16
@len = external dso_local local_unnamed_addr global [2010000 x i32], align 16
@root = external dso_local local_unnamed_addr global i32, align 4
@last = external dso_local local_unnamed_addr global i32, align 4
@ch = external dso_local local_unnamed_addr global [2010000 x [26 x i32]], align 16
@issuf = external dso_local local_unnamed_addr global [2010000 x i8], align 16
@pos = external dso_local local_unnamed_addr global [2010000 x i32], align 16
@node = external dso_local local_unnamed_addr global [2010000 x i32], align 16

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z6extendii(i32 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = load i32, ptr @last, align 4, !tbaa !5
  %4 = sext i32 %3 to i64
  %5 = getelementptr inbounds [2010000 x i32], ptr @len, i64 0, i64 %4
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %7 = add nsw i32 %6, 1
  %8 = tail call noundef i32 @_Z8newstateii(i32 noundef %7, i32 noundef %1)
  %9 = sext i32 %1 to i64
  %10 = getelementptr inbounds [2010000 x i32], ptr @node, i64 0, i64 %9
  store i32 %8, ptr %10, align 4, !tbaa !5
  %11 = sext i32 %8 to i64
  %12 = getelementptr inbounds [2010000 x i8], ptr @issuf, i64 0, i64 %11
  store i8 1, ptr %12, align 1, !tbaa !9
  %.not47 = icmp eq i32 %3, 0
  br i1 %.not47, label %.critedge43, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %13 = sext i32 %0 to i64
  br label %14

14:                                               ; preds = %.lr.ph, %18
  %.048 = phi i32 [ %3, %.lr.ph ], [ %20, %18 ]
  %15 = sext i32 %.048 to i64
  %16 = getelementptr inbounds [2010000 x [26 x i32]], ptr @ch, i64 0, i64 %15, i64 %13
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %.not41 = icmp eq i32 %17, 0
  br i1 %.not41, label %18, label %.critedge

18:                                               ; preds = %14
  store i32 %8, ptr %16, align 4, !tbaa !5
  %19 = getelementptr inbounds [2010000 x i32], ptr @par, i64 0, i64 %15
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %.not = icmp eq i32 %20, 0
  br i1 %.not, label %.critedge43, label %14, !llvm.loop !11

.critedge43:                                      ; preds = %18, %2
  %21 = load i32, ptr @root, align 4, !tbaa !5
  br label %.critedge2.sink.split

.critedge:                                        ; preds = %14
  %22 = getelementptr inbounds [2010000 x i32], ptr @len, i64 0, i64 %15
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = add nsw i32 %23, 1
  %25 = sext i32 %17 to i64
  %26 = getelementptr inbounds [2010000 x i32], ptr @len, i64 0, i64 %25
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %28 = icmp eq i32 %24, %27
  br i1 %28, label %.critedge2.sink.split, label %29

29:                                               ; preds = %.critedge
  %30 = getelementptr inbounds [2010000 x i32], ptr @pos, i64 0, i64 %25
  %31 = load i32, ptr %30, align 4, !tbaa !5
  %32 = tail call noundef i32 @_Z8newstateii(i32 noundef %24, i32 noundef %31)
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [2010000 x [26 x i32]], ptr @ch, i64 0, i64 %33
  %35 = getelementptr inbounds [2010000 x [26 x i32]], ptr @ch, i64 0, i64 %25
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(104) %34, ptr noundef nonnull align 8 dereferenceable(104) %35, i64 104, i1 false)
  %36 = getelementptr inbounds [2010000 x i32], ptr @par, i64 0, i64 %25
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = getelementptr inbounds [2010000 x i32], ptr @par, i64 0, i64 %33
  store i32 %37, ptr %38, align 4, !tbaa !5
  store i32 %32, ptr %36, align 4, !tbaa !5
  %39 = getelementptr inbounds [2010000 x i32], ptr @par, i64 0, i64 %11
  store i32 %32, ptr %39, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %29, %45
  %.149 = phi i32 [ %.048, %29 ], [ %47, %45 ]
  %41 = sext i32 %.149 to i64
  %42 = getelementptr inbounds [2010000 x [26 x i32]], ptr @ch, i64 0, i64 %41, i64 %13
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = icmp eq i32 %43, %17
  br i1 %44, label %45, label %.critedge2

45:                                               ; preds = %40
  store i32 %32, ptr %42, align 4, !tbaa !5
  %46 = getelementptr inbounds [2010000 x i32], ptr @par, i64 0, i64 %41
  %47 = load i32, ptr %46, align 4, !tbaa !5
  %.not42 = icmp eq i32 %47, 0
  br i1 %.not42, label %.critedge2, label %40, !llvm.loop !13

.critedge2.sink.split:                            ; preds = %.critedge, %.critedge43
  %.lcssa.sink = phi i32 [ %21, %.critedge43 ], [ %17, %.critedge ]
  %48 = getelementptr inbounds [2010000 x i32], ptr @par, i64 0, i64 %11
  store i32 %.lcssa.sink, ptr %48, align 4, !tbaa !5
  br label %.critedge2

.critedge2:                                       ; preds = %45, %40, %.critedge2.sink.split
  store i32 %8, ptr @last, align 4, !tbaa !5
  ret void
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }

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


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