; LLVM IR from lzyrapx/Competitive-Programming :: Retired_code/String/洛谷 P2444 (AC自动机).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"

@End = external dso_local global [100100 x i32], align 16
@ch = external dso_local global [100100 x [26 x i32]], align 16
@ins = external dso_local global [100100 x i8], align 16
@vis = external dso_local global [100100 x i8], 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 zeroext i1 @_Z3dfsi(i32 noundef %0) #1 {
  %2 = alloca i1, align 1
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  %7 = load i32, ptr %3, align 4, !tbaa !5
  %8 = sext i32 %7 to i64
  %9 = getelementptr inbounds [100100 x i8], ptr @ins, i64 0, i64 %8
  store i8 1, ptr %9, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %10

10:                                               ; preds = %54, %1
  %11 = load i32, ptr %4, align 4, !tbaa !5
  %12 = icmp sle i32 %11, 1
  br i1 %12, label %14, label %13

13:                                               ; preds = %10
  store i32 2, ptr %5, align 4
  br label %57

14:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  %15 = load i32, ptr %3, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [100100 x [26 x i32]], ptr @ch, i64 0, i64 %16
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [26 x i32], ptr %17, i64 0, i64 %19
  %21 = load i32, ptr %20, align 4, !tbaa !5
  store i32 %21, ptr %6, align 4, !tbaa !5
  %22 = load i32, ptr %6, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [100100 x i8], ptr @ins, i64 0, i64 %23
  %25 = load i8, ptr %24, align 1, !tbaa !9, !range !11, !noundef !12
  %26 = trunc i8 %25 to i1
  br i1 %26, label %27, label %28

27:                                               ; preds = %14
  store i1 true, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %51

28:                                               ; preds = %14
  %29 = load i32, ptr %6, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [100100 x i8], ptr @vis, i64 0, i64 %30
  %32 = load i8, ptr %31, align 1, !tbaa !9, !range !11, !noundef !12
  %33 = trunc i8 %32 to i1
  %34 = zext i1 %33 to i32
  %35 = icmp eq i32 %34, 1
  br i1 %35, label %42, label %36

36:                                               ; preds = %28
  %37 = load i32, ptr %6, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [100100 x i32], ptr @End, i64 0, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %42, label %43

42:                                               ; preds = %36, %28
  store i32 4, ptr %5, align 4
  br label %51

43:                                               ; preds = %36
  %44 = load i32, ptr %6, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [100100 x i8], ptr @vis, i64 0, i64 %45
  store i8 1, ptr %46, align 1, !tbaa !9
  %47 = load i32, ptr %6, align 4, !tbaa !5
  %48 = call noundef zeroext i1 @_Z3dfsi(i32 noundef %47)
  br i1 %48, label %49, label %50

49:                                               ; preds = %43
  store i1 true, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %51

50:                                               ; preds = %43
  store i32 0, ptr %5, align 4
  br label %51

51:                                               ; preds = %50, %49, %42, %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  %52 = load i32, ptr %5, align 4
  switch i32 %52, label %57 [
    i32 0, label %53
    i32 4, label %54
  ]

53:                                               ; preds = %51
  br label %54

54:                                               ; preds = %53, %51
  %55 = load i32, ptr %4, align 4, !tbaa !5
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %4, align 4, !tbaa !5
  br label %10, !llvm.loop !13

57:                                               ; preds = %51, %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  %58 = load i32, ptr %5, align 4
  switch i32 %58, label %65 [
    i32 2, label %59
    i32 1, label %63
  ]

59:                                               ; preds = %57
  %60 = load i32, ptr %3, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [100100 x i8], ptr @ins, i64 0, i64 %61
  store i8 0, ptr %62, align 1, !tbaa !9
  store i1 false, ptr %2, align 1
  br label %63

63:                                               ; preds = %59, %57
  %64 = load i1, ptr %2, align 1
  ret i1 %64

65:                                               ; preds = %57
  unreachable
}

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 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = distinct !{!13, !14}
!14 = !{!"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"

@End = external dso_local local_unnamed_addr global [100100 x i32], align 16
@ch = external dso_local local_unnamed_addr global [100100 x [26 x i32]], align 16
@ins = external dso_local local_unnamed_addr global [100100 x i8], align 16
@vis = external dso_local local_unnamed_addr global [100100 x i8], align 16

; Function Attrs: mustprogress nofree nosync nounwind memory(readwrite, argmem: none, inaccessiblemem: none) uwtable
define dso_local noundef zeroext i1 @_Z3dfsi(i32 noundef %0) local_unnamed_addr #0 {
  %2 = sext i32 %0 to i64
  %3 = getelementptr inbounds [100100 x i8], ptr @ins, i64 0, i64 %2
  store i8 1, ptr %3, align 1, !tbaa !5
  %4 = getelementptr inbounds [100100 x [26 x i32]], ptr @ch, i64 0, i64 %2, i64 0
  %5 = load i32, ptr %4, align 8, !tbaa !9
  %6 = sext i32 %5 to i64
  %7 = getelementptr inbounds [100100 x i8], ptr @ins, i64 0, i64 %6
  %8 = load i8, ptr %7, align 1, !tbaa !5, !range !11, !noundef !12
  %9 = trunc nuw i8 %8 to i1
  br i1 %9, label %.thread18, label %10

10:                                               ; preds = %1
  %11 = getelementptr inbounds [100100 x i8], ptr @vis, i64 0, i64 %6
  %12 = load i8, ptr %11, align 1, !tbaa !5, !range !11, !noundef !12
  %13 = trunc nuw i8 %12 to i1
  br i1 %13, label %19, label %14

14:                                               ; preds = %10
  %15 = getelementptr inbounds [100100 x i32], ptr @End, i64 0, i64 %6
  %16 = load i32, ptr %15, align 4, !tbaa !9
  %.not = icmp eq i32 %16, 0
  br i1 %.not, label %17, label %19

17:                                               ; preds = %14
  store i8 1, ptr %11, align 1, !tbaa !5
  %18 = tail call noundef zeroext i1 @_Z3dfsi(i32 noundef %5)
  br i1 %18, label %.thread18, label %19

19:                                               ; preds = %14, %10, %17
  %20 = getelementptr inbounds [100100 x [26 x i32]], ptr @ch, i64 0, i64 %2, i64 1
  %21 = load i32, ptr %20, align 4, !tbaa !9
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [100100 x i8], ptr @ins, i64 0, i64 %22
  %24 = load i8, ptr %23, align 1, !tbaa !5, !range !11, !noundef !12
  %25 = trunc nuw i8 %24 to i1
  br i1 %25, label %.thread18, label %26

26:                                               ; preds = %19
  %27 = getelementptr inbounds [100100 x i8], ptr @vis, i64 0, i64 %22
  %28 = load i8, ptr %27, align 1, !tbaa !5, !range !11, !noundef !12
  %29 = trunc nuw i8 %28 to i1
  br i1 %29, label %35, label %30

30:                                               ; preds = %26
  %31 = getelementptr inbounds [100100 x i32], ptr @End, i64 0, i64 %22
  %32 = load i32, ptr %31, align 4, !tbaa !9
  %.not.1 = icmp eq i32 %32, 0
  br i1 %.not.1, label %33, label %35

33:                                               ; preds = %30
  store i8 1, ptr %27, align 1, !tbaa !5
  %34 = tail call noundef zeroext i1 @_Z3dfsi(i32 noundef %21)
  br i1 %34, label %.thread18, label %35

35:                                               ; preds = %33, %30, %26
  store i8 0, ptr %3, align 1, !tbaa !5
  br label %.thread18

.thread18:                                        ; preds = %17, %1, %19, %33, %35
  %36 = phi i1 [ false, %35 ], [ true, %33 ], [ true, %19 ], [ true, %1 ], [ true, %17 ]
  ret i1 %36
}

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass