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

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

%"class.std::map" = type { %"class.std::_Rb_tree.8" }
%"class.std::_Rb_tree.8" = type { %"struct.std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int>>, std::less<int>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int>>, std::less<int>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }

@len = external dso_local global [210000 x i32], align 16
@anc = external dso_local global [210000 x [25 x i32]], align 16
@trans = external dso_local global %"class.std::map", align 8

; 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
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 4 dereferenceable(4)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z5queryii(i32 noundef %0, i32 noundef %1) #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
  store i32 %1, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  %7 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @trans, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %8 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %8, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store i32 24, ptr %6, align 4, !tbaa !5
  br label %9

9:                                                ; preds = %35, %2
  %10 = load i32, ptr %6, align 4, !tbaa !5
  %11 = icmp sge i32 %10, 0
  br i1 %11, label %13, label %12

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

13:                                               ; preds = %9
  %14 = load i32, ptr %5, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [210000 x [25 x i32]], ptr @anc, i64 0, i64 %15
  %17 = load i32, ptr %6, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [25 x i32], ptr %16, i64 0, i64 %18
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [210000 x i32], ptr @len, i64 0, i64 %21
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = load i32, ptr %4, align 4, !tbaa !5
  %25 = icmp sge i32 %23, %24
  br i1 %25, label %26, label %34

26:                                               ; preds = %13
  %27 = load i32, ptr %5, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [210000 x [25 x i32]], ptr @anc, i64 0, i64 %28
  %30 = load i32, ptr %6, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [25 x i32], ptr %29, i64 0, i64 %31
  %33 = load i32, ptr %32, align 4, !tbaa !5
  store i32 %33, ptr %5, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %26, %13
  br label %35

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

38:                                               ; preds = %12
  %39 = load i32, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret i32 %39
}

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 = distinct !{!9, !10}
!10 = !{!"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"

%"class.std::map" = type { %"class.std::_Rb_tree.8" }
%"class.std::_Rb_tree.8" = type { %"struct.std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int>>, std::less<int>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int>>, std::less<int>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }

@len = external dso_local local_unnamed_addr global [210000 x i32], align 16
@anc = external dso_local local_unnamed_addr global [210000 x [25 x i32]], align 16
@trans = external dso_local global %"class.std::map", align 8

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z5queryii(i32 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  %4 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @trans, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %6 = sext i32 %5 to i64
  %7 = getelementptr inbounds [210000 x [25 x i32]], ptr @anc, i64 0, i64 %6, i64 24
  %8 = load i32, ptr %7, align 4, !tbaa !5
  %9 = sext i32 %8 to i64
  %10 = getelementptr inbounds [210000 x i32], ptr @len, i64 0, i64 %9
  %11 = load i32, ptr %10, align 4, !tbaa !5
  %.not = icmp slt i32 %11, %1
  %spec.select = select i1 %.not, i32 %5, i32 %8
  %12 = sext i32 %spec.select to i64
  %13 = getelementptr inbounds [210000 x [25 x i32]], ptr @anc, i64 0, i64 %12, i64 23
  %14 = load i32, ptr %13, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [210000 x i32], ptr @len, i64 0, i64 %15
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %.not.1 = icmp slt i32 %17, %1
  %spec.select.1 = select i1 %.not.1, i32 %spec.select, i32 %14
  %18 = sext i32 %spec.select.1 to i64
  %19 = getelementptr inbounds [210000 x [25 x i32]], ptr @anc, i64 0, i64 %18, i64 22
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [210000 x i32], ptr @len, i64 0, i64 %21
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %.not.2 = icmp slt i32 %23, %1
  %spec.select.2 = select i1 %.not.2, i32 %spec.select.1, i32 %20
  %24 = sext i32 %spec.select.2 to i64
  %25 = getelementptr inbounds [210000 x [25 x i32]], ptr @anc, i64 0, i64 %24, i64 21
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [210000 x i32], ptr @len, i64 0, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %.not.3 = icmp slt i32 %29, %1
  %spec.select.3 = select i1 %.not.3, i32 %spec.select.2, i32 %26
  %30 = sext i32 %spec.select.3 to i64
  %31 = getelementptr inbounds [210000 x [25 x i32]], ptr @anc, i64 0, i64 %30, i64 20
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [210000 x i32], ptr @len, i64 0, i64 %33
  %35 = load i32, ptr %34, align 4, !tbaa !5
  %.not.4 = icmp slt i32 %35, %1
  %spec.select.4 = select i1 %.not.4, i32 %spec.select.3, i32 %32
  %36 = sext i32 %spec.select.4 to i64
  %37 = getelementptr inbounds [210000 x [25 x i32]], ptr @anc, i64 0, i64 %36, i64 19
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [210000 x i32], ptr @len, i64 0, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !5
  %.not.5 = icmp slt i32 %41, %1
  %spec.select.5 = select i1 %.not.5, i32 %spec.select.4, i32 %38
  %42 = sext i32 %spec.select.5 to i64
  %43 = getelementptr inbounds [210000 x [25 x i32]], ptr @anc, i64 0, i64 %42, i64 18
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [210000 x i32], ptr @len, i64 0, i64 %45
  %47 = load i32, ptr %46, align 4, !tbaa !5
  %.not.6 = icmp slt i32 %47, %1
  %spec.select.6 = select i1 %.not.6, i32 %spec.select.5, i32 %44
  %48 = sext i32 %spec.select.6 to i64
  %49 = getelementptr inbounds [210000 x [25 x i32]], ptr @anc, i64 0, i64 %48, i64 17
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [210000 x i32], ptr @len, i64 0, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %.not.7 = icmp slt i32 %53, %1
  %spec.select.7 = select i1 %.not.7, i32 %spec.select.6, i32 %50
  %54 = sext i32 %spec.select.7 to i64
  %55 = getelementptr inbounds [210000 x [25 x i32]], ptr @anc, i64 0, i64 %54, i64 16
  %56 = load i32, ptr %55, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [210000 x i32], ptr @len, i64 0, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %.not.8 = icmp slt i32 %59, %1
  %spec.select.8 = select i1 %.not.8, i32 %spec.select.7, i32 %56
  %60 = sext i32 %spec.select.8 to i64
  %61 = getelementptr inbounds [210000 x [25 x i32]], ptr @anc, i64 0, i64 %60, i64 15
  %62 = load i32, ptr %61, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [210000 x i32], ptr @len, i64 0, i64 %63
  %65 = load i32, ptr %64, align 4, !tbaa !5
  %.not.9 = icmp slt i32 %65, %1
  %spec.select.9 = select i1 %.not.9, i32 %spec.select.8, i32 %62
  %66 = sext i32 %spec.select.9 to i64
  %67 = getelementptr inbounds [210000 x [25 x i32]], ptr @anc, i64 0, i64 %66, i64 14
  %68 = load i32, ptr %67, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [210000 x i32], ptr @len, i64 0, i64 %69
  %71 = load i32, ptr %70, align 4, !tbaa !5
  %.not.10 = icmp slt i32 %71, %1
  %spec.select.10 = select i1 %.not.10, i32 %spec.select.9, i32 %68
  %72 = sext i32 %spec.select.10 to i64
  %73 = getelementptr inbounds [210000 x [25 x i32]], ptr @anc, i64 0, i64 %72, i64 13
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [210000 x i32], ptr @len, i64 0, i64 %75
  %77 = load i32, ptr %76, align 4, !tbaa !5
  %.not.11 = icmp slt i32 %77, %1
  %spec.select.11 = select i1 %.not.11, i32 %spec.select.10, i32 %74
  %78 = sext i32 %spec.select.11 to i64
  %79 = getelementptr inbounds [210000 x [25 x i32]], ptr @anc, i64 0, i64 %78, i64 12
  %80 = load i32, ptr %79, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [210000 x i32], ptr @len, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %.not.12 = icmp slt i32 %83, %1
  %spec.select.12 = select i1 %.not.12, i32 %spec.select.11, i32 %80
  %84 = sext i32 %spec.select.12 to i64
  %85 = getelementptr inbounds [210000 x [25 x i32]], ptr @anc, i64 0, i64 %84, i64 11
  %86 = load i32, ptr %85, align 4, !tbaa !5
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [210000 x i32], ptr @len, i64 0, i64 %87
  %89 = load i32, ptr %88, align 4, !tbaa !5
  %.not.13 = icmp slt i32 %89, %1
  %spec.select.13 = select i1 %.not.13, i32 %spec.select.12, i32 %86
  %90 = sext i32 %spec.select.13 to i64
  %91 = getelementptr inbounds [210000 x [25 x i32]], ptr @anc, i64 0, i64 %90, i64 10
  %92 = load i32, ptr %91, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [210000 x i32], ptr @len, i64 0, i64 %93
  %95 = load i32, ptr %94, align 4, !tbaa !5
  %.not.14 = icmp slt i32 %95, %1
  %spec.select.14 = select i1 %.not.14, i32 %spec.select.13, i32 %92
  %96 = sext i32 %spec.select.14 to i64
  %97 = getelementptr inbounds [210000 x [25 x i32]], ptr @anc, i64 0, i64 %96, i64 9
  %98 = load i32, ptr %97, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [210000 x i32], ptr @len, i64 0, i64 %99
  %101 = load i32, ptr %100, align 4, !tbaa !5
  %.not.15 = icmp slt i32 %101, %1
  %spec.select.15 = select i1 %.not.15, i32 %spec.select.14, i32 %98
  %102 = sext i32 %spec.select.15 to i64
  %103 = getelementptr inbounds [210000 x [25 x i32]], ptr @anc, i64 0, i64 %102, i64 8
  %104 = load i32, ptr %103, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [210000 x i32], ptr @len, i64 0, i64 %105
  %107 = load i32, ptr %106, align 4, !tbaa !5
  %.not.16 = icmp slt i32 %107, %1
  %spec.select.16 = select i1 %.not.16, i32 %spec.select.15, i32 %104
  %108 = sext i32 %spec.select.16 to i64
  %109 = getelementptr inbounds [210000 x [25 x i32]], ptr @anc, i64 0, i64 %108, i64 7
  %110 = load i32, ptr %109, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [210000 x i32], ptr @len, i64 0, i64 %111
  %113 = load i32, ptr %112, align 4, !tbaa !5
  %.not.17 = icmp slt i32 %113, %1
  %spec.select.17 = select i1 %.not.17, i32 %spec.select.16, i32 %110
  %114 = sext i32 %spec.select.17 to i64
  %115 = getelementptr inbounds [210000 x [25 x i32]], ptr @anc, i64 0, i64 %114, i64 6
  %116 = load i32, ptr %115, align 4, !tbaa !5
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds [210000 x i32], ptr @len, i64 0, i64 %117
  %119 = load i32, ptr %118, align 4, !tbaa !5
  %.not.18 = icmp slt i32 %119, %1
  %spec.select.18 = select i1 %.not.18, i32 %spec.select.17, i32 %116
  %120 = sext i32 %spec.select.18 to i64
  %121 = getelementptr inbounds [210000 x [25 x i32]], ptr @anc, i64 0, i64 %120, i64 5
  %122 = load i32, ptr %121, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds [210000 x i32], ptr @len, i64 0, i64 %123
  %125 = load i32, ptr %124, align 4, !tbaa !5
  %.not.19 = icmp slt i32 %125, %1
  %spec.select.19 = select i1 %.not.19, i32 %spec.select.18, i32 %122
  %126 = sext i32 %spec.select.19 to i64
  %127 = getelementptr inbounds [210000 x [25 x i32]], ptr @anc, i64 0, i64 %126, i64 4
  %128 = load i32, ptr %127, align 4, !tbaa !5
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds [210000 x i32], ptr @len, i64 0, i64 %129
  %131 = load i32, ptr %130, align 4, !tbaa !5
  %.not.20 = icmp slt i32 %131, %1
  %spec.select.20 = select i1 %.not.20, i32 %spec.select.19, i32 %128
  %132 = sext i32 %spec.select.20 to i64
  %133 = getelementptr inbounds [210000 x [25 x i32]], ptr @anc, i64 0, i64 %132, i64 3
  %134 = load i32, ptr %133, align 4, !tbaa !5
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [210000 x i32], ptr @len, i64 0, i64 %135
  %137 = load i32, ptr %136, align 4, !tbaa !5
  %.not.21 = icmp slt i32 %137, %1
  %spec.select.21 = select i1 %.not.21, i32 %spec.select.20, i32 %134
  %138 = sext i32 %spec.select.21 to i64
  %139 = getelementptr inbounds [210000 x [25 x i32]], ptr @anc, i64 0, i64 %138, i64 2
  %140 = load i32, ptr %139, align 4, !tbaa !5
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [210000 x i32], ptr @len, i64 0, i64 %141
  %143 = load i32, ptr %142, align 4, !tbaa !5
  %.not.22 = icmp slt i32 %143, %1
  %spec.select.22 = select i1 %.not.22, i32 %spec.select.21, i32 %140
  %144 = sext i32 %spec.select.22 to i64
  %145 = getelementptr inbounds [210000 x [25 x i32]], ptr @anc, i64 0, i64 %144, i64 1
  %146 = load i32, ptr %145, align 4, !tbaa !5
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds [210000 x i32], ptr @len, i64 0, i64 %147
  %149 = load i32, ptr %148, align 4, !tbaa !5
  %.not.23 = icmp slt i32 %149, %1
  %spec.select.23 = select i1 %.not.23, i32 %spec.select.22, i32 %146
  %150 = sext i32 %spec.select.23 to i64
  %151 = getelementptr inbounds [210000 x [25 x i32]], ptr @anc, i64 0, i64 %150, i64 0
  %152 = load i32, ptr %151, align 4, !tbaa !5
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds [210000 x i32], ptr @len, i64 0, i64 %153
  %155 = load i32, ptr %154, align 4, !tbaa !5
  %.not.24 = icmp slt i32 %155, %1
  %spec.select.24 = select i1 %.not.24, i32 %spec.select.23, i32 %152
  ret i32 %spec.select.24
}

attributes #0 = { 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" }

!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"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,SROAPass,SimplifyCFGPass