; LLVM IR from upupming/algorithm :: bytedance/2021ByteCamp/a. 最短全集子串.ll (Z5validii)

; 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::unordered_set" = type { %"class.std::_Hashtable" }
%"class.std::_Hashtable" = type { ptr, i64, %"struct.std::__detail::_Hash_node_base", i64, %"struct.std::__detail::_Prime_rehash_policy", ptr }
%"struct.std::__detail::_Hash_node_base" = type { ptr }
%"struct.std::__detail::_Prime_rehash_policy" = type { float, i64 }

@sum = external dso_local global [26 x [100000 x i32]], align 16
@st = external dso_local global %"class.std::unordered_set", align 8

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z5validii(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
  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
  store i32 0, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %7

7:                                                ; preds = %33, %2
  %8 = load i32, ptr %6, align 4, !tbaa !5
  %9 = icmp slt i32 %8, 26
  br i1 %9, label %11, label %10

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

11:                                               ; preds = %7
  %12 = load i32, ptr %6, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [26 x [100000 x i32]], ptr @sum, i64 0, i64 %13
  %15 = load i32, ptr %4, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [100000 x i32], ptr %14, i64 0, i64 %16
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = load i32, ptr %6, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [26 x [100000 x i32]], ptr @sum, i64 0, i64 %20
  %22 = load i32, ptr %3, align 4, !tbaa !5
  %23 = sub nsw i32 %22, 1
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [100000 x i32], ptr %21, i64 0, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = sub nsw i32 %18, %26
  %28 = icmp sge i32 %27, 1
  br i1 %28, label %29, label %32

29:                                               ; preds = %11
  %30 = load i32, ptr %5, align 4, !tbaa !5
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %5, align 4, !tbaa !5
  br label %32

32:                                               ; preds = %29, %11
  br label %33

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

36:                                               ; preds = %10
  %37 = load i32, ptr %5, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = call noundef i64 @_ZNKSt13unordered_setIcSt4hashIcESt8equal_toIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(56) @st) #2
  %40 = icmp eq i64 %38, %39
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret i1 %40
}

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt13unordered_setIcSt4hashIcESt8equal_toIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(56)) #0 align 2

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 = { 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::unordered_set" = type { %"class.std::_Hashtable" }
%"class.std::_Hashtable" = type { ptr, i64, %"struct.std::__detail::_Hash_node_base", i64, %"struct.std::__detail::_Prime_rehash_policy", ptr }
%"struct.std::__detail::_Hash_node_base" = type { ptr }
%"struct.std::__detail::_Prime_rehash_policy" = type { float, i64 }

@sum = external dso_local local_unnamed_addr global [26 x [100000 x i32]], align 16
@st = external dso_local global %"class.std::unordered_set", align 8

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt13unordered_setIcSt4hashIcESt8equal_toIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(56)) local_unnamed_addr #0 align 2

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LICMPass,LoopRotatePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass