; 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 [210000 x i32], align 16
@len = external dso_local global [210000 x i32], align 16
@go = external dso_local global [210000 x [26 x i32]], align 16
@root = external dso_local global i32, align 4
@last = external dso_local global i32, align 4

; 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 [210000 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
  br label %17

17:                                               ; preds = %32, %2
  %18 = load i32, ptr %5, align 4, !tbaa !5
  %19 = icmp ne i32 %18, 0
  br i1 %19, label %20, label %30

20:                                               ; preds = %17
  %21 = load i32, ptr %5, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [210000 x [26 x i32]], ptr @go, i64 0, i64 %22
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [26 x i32], ptr %23, i64 0, i64 %25
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %28 = icmp ne i32 %27, 0
  %29 = xor i1 %28, true
  br label %30

30:                                               ; preds = %20, %17
  %31 = phi i1 [ false, %17 ], [ %29, %20 ]
  br i1 %31, label %32, label %44

32:                                               ; preds = %30
  %33 = load i32, ptr %6, align 4, !tbaa !5
  %34 = load i32, ptr %5, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [210000 x [26 x i32]], ptr @go, i64 0, i64 %35
  %37 = load i32, ptr %3, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [26 x i32], ptr %36, i64 0, i64 %38
  store i32 %33, ptr %39, align 4, !tbaa !5
  %40 = load i32, ptr %5, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [210000 x i32], ptr @par, i64 0, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !5
  store i32 %43, ptr %5, align 4, !tbaa !5
  br label %17, !llvm.loop !9

44:                                               ; preds = %30
  %45 = load i32, ptr %5, align 4, !tbaa !5
  %46 = icmp ne i32 %45, 0
  br i1 %46, label %52, label %47

47:                                               ; preds = %44
  %48 = load i32, ptr @root, align 4, !tbaa !5
  %49 = load i32, ptr %6, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [210000 x i32], ptr @par, i64 0, i64 %50
  store i32 %48, ptr %51, align 4, !tbaa !5
  br label %134

52:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %53 = load i32, ptr %5, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [210000 x [26 x i32]], ptr @go, i64 0, i64 %54
  %56 = load i32, ptr %3, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [26 x i32], ptr %55, i64 0, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !5
  store i32 %59, ptr %7, align 4, !tbaa !5
  %60 = load i32, ptr %5, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [210000 x i32], ptr @len, i64 0, i64 %61
  %63 = load i32, ptr %62, align 4, !tbaa !5
  %64 = add nsw i32 %63, 1
  %65 = load i32, ptr %7, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [210000 x i32], ptr @len, i64 0, i64 %66
  %68 = load i32, ptr %67, align 4, !tbaa !5
  %69 = icmp eq i32 %64, %68
  br i1 %69, label %70, label %75

70:                                               ; preds = %52
  %71 = load i32, ptr %7, align 4, !tbaa !5
  %72 = load i32, ptr %6, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [210000 x i32], ptr @par, i64 0, i64 %73
  store i32 %71, ptr %74, align 4, !tbaa !5
  br label %133

75:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %76 = load i32, ptr %5, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [210000 x i32], ptr @len, i64 0, i64 %77
  %79 = load i32, ptr %78, align 4, !tbaa !5
  %80 = add nsw i32 %79, 1
  %81 = call noundef i32 @_Z8newstateii(i32 noundef %80, i32 noundef -1)
  store i32 %81, ptr %8, align 4, !tbaa !5
  %82 = load i32, ptr %8, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [210000 x [26 x i32]], ptr @go, i64 0, i64 %83
  %85 = getelementptr inbounds [26 x i32], ptr %84, i64 0, i64 0
  %86 = load i32, ptr %7, align 4, !tbaa !5
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [210000 x [26 x i32]], ptr @go, i64 0, i64 %87
  %89 = getelementptr inbounds [26 x i32], ptr %88, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %85, ptr align 8 %89, i64 104, i1 false)
  %90 = load i32, ptr %7, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [210000 x i32], ptr @par, i64 0, i64 %91
  %93 = load i32, ptr %92, align 4, !tbaa !5
  %94 = load i32, ptr %8, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [210000 x i32], ptr @par, i64 0, i64 %95
  store i32 %93, ptr %96, align 4, !tbaa !5
  %97 = load i32, ptr %8, align 4, !tbaa !5
  %98 = load i32, ptr %7, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [210000 x i32], ptr @par, i64 0, i64 %99
  store i32 %97, ptr %100, align 4, !tbaa !5
  %101 = load i32, ptr %8, align 4, !tbaa !5
  %102 = load i32, ptr %6, align 4, !tbaa !5
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [210000 x i32], ptr @par, i64 0, i64 %103
  store i32 %101, ptr %104, align 4, !tbaa !5
  br label %105

105:                                              ; preds = %120, %75
  %106 = load i32, ptr %5, align 4, !tbaa !5
  %107 = icmp ne i32 %106, 0
  br i1 %107, label %108, label %118

108:                                              ; preds = %105
  %109 = load i32, ptr %5, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [210000 x [26 x i32]], ptr @go, i64 0, i64 %110
  %112 = load i32, ptr %3, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [26 x i32], ptr %111, i64 0, i64 %113
  %115 = load i32, ptr %114, align 4, !tbaa !5
  %116 = load i32, ptr %7, align 4, !tbaa !5
  %117 = icmp eq i32 %115, %116
  br label %118

118:                                              ; preds = %108, %105
  %119 = phi i1 [ false, %105 ], [ %117, %108 ]
  br i1 %119, label %120, label %132

120:                                              ; preds = %118
  %121 = load i32, ptr %8, align 4, !tbaa !5
  %122 = load i32, ptr %5, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds [210000 x [26 x i32]], ptr @go, i64 0, i64 %123
  %125 = load i32, ptr %3, align 4, !tbaa !5
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [26 x i32], ptr %124, i64 0, i64 %126
  store i32 %121, ptr %127, align 4, !tbaa !5
  %128 = load i32, ptr %5, align 4, !tbaa !5
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds [210000 x i32], ptr @par, i64 0, i64 %129
  %131 = load i32, ptr %130, align 4, !tbaa !5
  store i32 %131, ptr %5, align 4, !tbaa !5
  br label %105, !llvm.loop !11

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

133:                                              ; preds = %132, %70
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %134

134:                                              ; preds = %133, %47
  %135 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %135, 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


; 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 [210000 x i32], align 16
@len = external dso_local local_unnamed_addr global [210000 x i32], align 16
@go = external dso_local local_unnamed_addr global [210000 x [26 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

; 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 [210000 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)
  %.not44 = icmp eq i32 %3, 0
  br i1 %.not44, label %.critedge40, label %.lr.ph

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

10:                                               ; preds = %.lr.ph, %14
  %.045 = phi i32 [ %3, %.lr.ph ], [ %16, %14 ]
  %11 = sext i32 %.045 to i64
  %12 = getelementptr inbounds [210000 x [26 x i32]], ptr @go, i64 0, i64 %11, i64 %9
  %13 = load i32, ptr %12, align 4, !tbaa !5
  %.not38 = icmp eq i32 %13, 0
  br i1 %.not38, label %14, label %.critedge

14:                                               ; preds = %10
  store i32 %8, ptr %12, align 4, !tbaa !5
  %15 = getelementptr inbounds [210000 x i32], ptr @par, i64 0, i64 %11
  %16 = load i32, ptr %15, align 4, !tbaa !5
  %.not = icmp eq i32 %16, 0
  br i1 %.not, label %.critedge40, label %10, !llvm.loop !9

.critedge40:                                      ; preds = %14, %2
  %17 = load i32, ptr @root, align 4, !tbaa !5
  br label %.critedge2.sink.split

.critedge:                                        ; preds = %10
  %18 = getelementptr inbounds [210000 x i32], ptr @len, i64 0, i64 %11
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = add nsw i32 %19, 1
  %21 = sext i32 %13 to i64
  %22 = getelementptr inbounds [210000 x i32], ptr @len, i64 0, i64 %21
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = icmp eq i32 %20, %23
  br i1 %24, label %.critedge2.sink.split, label %25

25:                                               ; preds = %.critedge
  %26 = tail call noundef i32 @_Z8newstateii(i32 noundef %20, i32 noundef -1)
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [210000 x [26 x i32]], ptr @go, i64 0, i64 %27
  %29 = getelementptr inbounds [210000 x [26 x i32]], ptr @go, i64 0, i64 %21
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(104) %28, ptr noundef nonnull align 8 dereferenceable(104) %29, i64 104, i1 false)
  %30 = getelementptr inbounds [210000 x i32], ptr @par, i64 0, i64 %21
  %31 = load i32, ptr %30, align 4, !tbaa !5
  %32 = getelementptr inbounds [210000 x i32], ptr @par, i64 0, i64 %27
  store i32 %31, ptr %32, align 4, !tbaa !5
  store i32 %26, ptr %30, align 4, !tbaa !5
  %33 = sext i32 %8 to i64
  %34 = getelementptr inbounds [210000 x i32], ptr @par, i64 0, i64 %33
  store i32 %26, ptr %34, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %25, %40
  %.146 = phi i32 [ %.045, %25 ], [ %42, %40 ]
  %36 = sext i32 %.146 to i64
  %37 = getelementptr inbounds [210000 x [26 x i32]], ptr @go, i64 0, i64 %36, i64 %9
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = icmp eq i32 %38, %13
  br i1 %39, label %40, label %.critedge2

40:                                               ; preds = %35
  store i32 %26, ptr %37, align 4, !tbaa !5
  %41 = getelementptr inbounds [210000 x i32], ptr @par, i64 0, i64 %36
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %.not39 = icmp eq i32 %42, 0
  br i1 %.not39, label %.critedge2, label %35, !llvm.loop !11

.critedge2.sink.split:                            ; preds = %.critedge, %.critedge40
  %.lcssa.sink = phi i32 [ %17, %.critedge40 ], [ %13, %.critedge ]
  %43 = sext i32 %8 to i64
  %44 = getelementptr inbounds [210000 x i32], ptr @par, i64 0, i64 %43
  store i32 %.lcssa.sink, ptr %44, align 4, !tbaa !5
  br label %.critedge2

.critedge2:                                       ; preds = %40, %35, %.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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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