; LLVM IR from vczh/herodb :: Kernel/Source (Vlpp)

; 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.vl::regex_internal::PureResult" = type { i64, i64, i64, i64 }
%"class.vl::regex_internal::PureInterpretor" = type { %"class.vl::Object", [1114112 x i64], ptr, ptr, ptr, i64, i64, i64 }
%"class.vl::Object" = type { ptr }

; 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 nounwind uwtable
define dso_local noundef zeroext i1 @_ZN2vl14regex_internal15PureInterpretor9MatchHeadEPKwS3_RNS0_10PureResultE(ptr noundef nonnull align 8 dereferenceable(8912952) %0, ptr noundef %1, ptr noundef %2, ptr noundef nonnull align 8 dereferenceable(32) %3) #1 align 2 {
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i64, align 8
  %15 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  %16 = load ptr, ptr %6, align 8
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = load ptr, ptr %8, align 8, !tbaa !5
  %19 = ptrtoint ptr %17 to i64
  %20 = ptrtoint ptr %18 to i64
  %21 = sub i64 %19, %20
  %22 = sdiv exact i64 %21, 4
  %23 = load ptr, ptr %9, align 8, !tbaa !5
  %24 = getelementptr inbounds %"class.vl::regex_internal::PureResult", ptr %23, i32 0, i32 0
  store i64 %22, ptr %24, align 8, !tbaa !9
  %25 = load ptr, ptr %9, align 8, !tbaa !5
  %26 = getelementptr inbounds %"class.vl::regex_internal::PureResult", ptr %25, i32 0, i32 1
  store i64 -1, ptr %26, align 8, !tbaa !12
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  %28 = getelementptr inbounds %"class.vl::regex_internal::PureResult", ptr %27, i32 0, i32 2
  store i64 -1, ptr %28, align 8, !tbaa !13
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  %30 = getelementptr inbounds %"class.vl::regex_internal::PureResult", ptr %29, i32 0, i32 3
  store i64 -1, ptr %30, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  %31 = getelementptr inbounds %"class.vl::regex_internal::PureInterpretor", ptr %16, i32 0, i32 7
  %32 = load i64, ptr %31, align 8, !tbaa !15
  store i64 %32, ptr %10, align 8, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #2
  store i64 -1, ptr %11, align 8, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #2
  store i64 -1, ptr %12, align 8, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #2
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %33, ptr %13, align 8, !tbaa !5
  br label %34

34:                                               ; preds = %69, %4
  %35 = load i64, ptr %10, align 8, !tbaa !18
  %36 = icmp ne i64 %35, -1
  br i1 %36, label %37, label %85

37:                                               ; preds = %34
  %38 = load i64, ptr %10, align 8, !tbaa !18
  store i64 %38, ptr %11, align 8, !tbaa !18
  %39 = load ptr, ptr %13, align 8, !tbaa !5
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = ptrtoint ptr %39 to i64
  %42 = ptrtoint ptr %40 to i64
  %43 = sub i64 %41, %42
  %44 = sdiv exact i64 %43, 4
  store i64 %44, ptr %12, align 8, !tbaa !18
  %45 = getelementptr inbounds %"class.vl::regex_internal::PureInterpretor", ptr %16, i32 0, i32 3
  %46 = load ptr, ptr %45, align 8, !tbaa !19
  %47 = load i64, ptr %10, align 8, !tbaa !18
  %48 = getelementptr inbounds i8, ptr %46, i64 %47
  %49 = load i8, ptr %48, align 1, !tbaa !20, !range !22, !noundef !23
  %50 = trunc i8 %49 to i1
  br i1 %50, label %51, label %58

51:                                               ; preds = %37
  %52 = load i64, ptr %12, align 8, !tbaa !18
  %53 = load ptr, ptr %9, align 8, !tbaa !5
  %54 = getelementptr inbounds %"class.vl::regex_internal::PureResult", ptr %53, i32 0, i32 1
  store i64 %52, ptr %54, align 8, !tbaa !12
  %55 = load i64, ptr %10, align 8, !tbaa !18
  %56 = load ptr, ptr %9, align 8, !tbaa !5
  %57 = getelementptr inbounds %"class.vl::regex_internal::PureResult", ptr %56, i32 0, i32 2
  store i64 %55, ptr %57, align 8, !tbaa !13
  br label %58

58:                                               ; preds = %51, %37
  %59 = load ptr, ptr %13, align 8, !tbaa !5
  %60 = load i32, ptr %59, align 4, !tbaa !24
  %61 = icmp ne i32 %60, 0
  br i1 %61, label %63, label %62

62:                                               ; preds = %58
  br label %85

63:                                               ; preds = %58
  %64 = load ptr, ptr %13, align 8, !tbaa !5
  %65 = load i32, ptr %64, align 4, !tbaa !24
  %66 = sext i32 %65 to i64
  %67 = icmp sge i64 %66, 1114112
  br i1 %67, label %68, label %69

68:                                               ; preds = %63
  br label %85

69:                                               ; preds = %63
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #2
  %70 = getelementptr inbounds %"class.vl::regex_internal::PureInterpretor", ptr %16, i32 0, i32 1
  %71 = load ptr, ptr %13, align 8, !tbaa !5
  %72 = getelementptr inbounds i32, ptr %71, i32 1
  store ptr %72, ptr %13, align 8, !tbaa !5
  %73 = load i32, ptr %71, align 4, !tbaa !24
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [1114112 x i64], ptr %70, i64 0, i64 %74
  %76 = load i64, ptr %75, align 8, !tbaa !18
  store i64 %76, ptr %14, align 8, !tbaa !18
  %77 = getelementptr inbounds %"class.vl::regex_internal::PureInterpretor", ptr %16, i32 0, i32 2
  %78 = load ptr, ptr %77, align 8, !tbaa !26
  %79 = load i64, ptr %10, align 8, !tbaa !18
  %80 = getelementptr inbounds ptr, ptr %78, i64 %79
  %81 = load ptr, ptr %80, align 8, !tbaa !5
  %82 = load i64, ptr %14, align 8, !tbaa !18
  %83 = getelementptr inbounds i64, ptr %81, i64 %82
  %84 = load i64, ptr %83, align 8, !tbaa !18
  store i64 %84, ptr %10, align 8, !tbaa !18
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #2
  br label %34, !llvm.loop !27

85:                                               ; preds = %68, %62, %34
  %86 = load ptr, ptr %9, align 8, !tbaa !5
  %87 = getelementptr inbounds %"class.vl::regex_internal::PureResult", ptr %86, i32 0, i32 2
  %88 = load i64, ptr %87, align 8, !tbaa !13
  %89 = icmp eq i64 %88, -1
  br i1 %89, label %90, label %101

90:                                               ; preds = %85
  %91 = load i64, ptr %12, align 8, !tbaa !18
  %92 = icmp sgt i64 %91, 0
  br i1 %92, label %93, label %97

93:                                               ; preds = %90
  %94 = load i64, ptr %11, align 8, !tbaa !18
  %95 = load ptr, ptr %9, align 8, !tbaa !5
  %96 = getelementptr inbounds %"class.vl::regex_internal::PureResult", ptr %95, i32 0, i32 3
  store i64 %94, ptr %96, align 8, !tbaa !14
  br label %97

97:                                               ; preds = %93, %90
  %98 = load i64, ptr %12, align 8, !tbaa !18
  %99 = load ptr, ptr %9, align 8, !tbaa !5
  %100 = getelementptr inbounds %"class.vl::regex_internal::PureResult", ptr %99, i32 0, i32 1
  store i64 %98, ptr %100, align 8, !tbaa !12
  store i1 false, ptr %5, align 1
  store i32 1, ptr %15, align 4
  br label %102

101:                                              ; preds = %85
  store i1 true, ptr %5, align 1
  store i32 1, ptr %15, align 4
  br label %102

102:                                              ; preds = %101, %97
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  %103 = load i1, ptr %5, align 1
  ret i1 %103
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTSN2vl14regex_internal10PureResultE", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !11, i64 8}
!13 = !{!10, !11, i64 16}
!14 = !{!10, !11, i64 24}
!15 = !{!16, !11, i64 8912944}
!16 = !{!"_ZTSN2vl14regex_internal15PureInterpretorE", !17, i64 0, !7, i64 8, !6, i64 8912904, !6, i64 8912912, !6, i64 8912920, !11, i64 8912928, !11, i64 8912936, !11, i64 8912944}
!17 = !{!"_ZTSN2vl6ObjectE"}
!18 = !{!11, !11, i64 0}
!19 = !{!16, !6, i64 8912912}
!20 = !{!21, !21, i64 0}
!21 = !{!"bool", !7, i64 0}
!22 = !{i8 0, i8 2}
!23 = !{}
!24 = !{!25, !25, i64 0}
!25 = !{!"wchar_t", !7, i64 0}
!26 = !{!16, !6, i64 8912904}
!27 = distinct !{!27, !28}
!28 = !{!"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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local noundef zeroext i1 @_ZN2vl14regex_internal15PureInterpretor9MatchHeadEPKwS3_RNS0_10PureResultE(ptr nocapture noundef nonnull readonly align 8 dereferenceable(8912952) %0, ptr noundef %1, ptr noundef %2, ptr nocapture noundef nonnull writeonly align 8 dereferenceable(32) %3) local_unnamed_addr #0 align 2 {
  %5 = ptrtoint ptr %1 to i64
  %6 = ptrtoint ptr %2 to i64
  %7 = sub i64 %5, %6
  %8 = ashr exact i64 %7, 2
  store i64 %8, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %3, i64 8
  %10 = getelementptr inbounds i8, ptr %3, i64 16
  %11 = getelementptr inbounds i8, ptr %3, i64 24
  %12 = getelementptr inbounds i8, ptr %0, i64 8912944
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %9, i8 -1, i64 24, i1 false)
  %.03236 = load i64, ptr %12, align 8, !tbaa !10
  %.not37 = icmp eq i64 %.03236, -1
  br i1 %.not37, label %.thread, label %.lr.ph

.lr.ph:                                           ; preds = %4
  %13 = getelementptr inbounds i8, ptr %0, i64 8912912
  %14 = load ptr, ptr %13, align 8, !tbaa !11
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  %16 = getelementptr inbounds i8, ptr %0, i64 8912904
  %17 = load ptr, ptr %16, align 8
  br label %18

18:                                               ; preds = %.lr.ph, %31
  %19 = phi i64 [ -1, %.lr.ph ], [ %28, %31 ]
  %.03239 = phi i64 [ %.03236, %.lr.ph ], [ %.032, %31 ]
  %.02838 = phi ptr [ %1, %.lr.ph ], [ %33, %31 ]
  %20 = ptrtoint ptr %.02838 to i64
  %21 = sub i64 %20, %5
  %22 = ashr exact i64 %21, 2
  %23 = getelementptr inbounds i8, ptr %14, i64 %.03239
  %24 = load i8, ptr %23, align 1, !tbaa !15, !range !17, !noundef !18
  %25 = trunc nuw i8 %24 to i1
  br i1 %25, label %26, label %27

26:                                               ; preds = %18
  store i64 %22, ptr %9, align 8, !tbaa !19
  store i64 %.03239, ptr %10, align 8, !tbaa !20
  br label %27

27:                                               ; preds = %26, %18
  %28 = phi i64 [ %.03239, %26 ], [ %19, %18 ]
  %29 = load i32, ptr %.02838, align 4, !tbaa !21
  %.not35 = icmp eq i32 %29, 0
  %30 = icmp sgt i32 %29, 1114111
  %or.cond = or i1 %.not35, %30
  br i1 %or.cond, label %._crit_edge, label %31

31:                                               ; preds = %27
  %32 = sext i32 %29 to i64
  %33 = getelementptr inbounds i8, ptr %.02838, i64 4
  %34 = getelementptr inbounds [1114112 x i64], ptr %15, i64 0, i64 %32
  %35 = load i64, ptr %34, align 8, !tbaa !10
  %36 = getelementptr inbounds ptr, ptr %17, i64 %.03239
  %37 = load ptr, ptr %36, align 8, !tbaa !23
  %38 = getelementptr inbounds i64, ptr %37, i64 %35
  %.032 = load i64, ptr %38, align 8, !tbaa !10
  %.not = icmp eq i64 %.032, -1
  br i1 %.not, label %._crit_edge, label %18, !llvm.loop !24

._crit_edge:                                      ; preds = %31, %27
  %.not52 = icmp eq i64 %28, -1
  br i1 %.not52, label %39, label %42

39:                                               ; preds = %._crit_edge
  %40 = icmp sgt i64 %22, 0
  br i1 %40, label %41, label %.thread

41:                                               ; preds = %39
  store i64 %.03239, ptr %11, align 8, !tbaa !26
  br label %.thread

.thread:                                          ; preds = %4, %41, %39
  %.14750 = phi i64 [ %22, %41 ], [ %22, %39 ], [ -1, %4 ]
  store i64 %.14750, ptr %9, align 8, !tbaa !19
  br label %42

42:                                               ; preds = %._crit_edge, %.thread
  %43 = phi i1 [ true, %._crit_edge ], [ false, %.thread ]
  ret i1 %43
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind memory(read, argmem: readwrite, 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" }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!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, !7, i64 0}
!6 = !{!"_ZTSN2vl14regex_internal10PureResultE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!7, !7, i64 0}
!11 = !{!12, !14, i64 8912912}
!12 = !{!"_ZTSN2vl14regex_internal15PureInterpretorE", !13, i64 0, !8, i64 8, !14, i64 8912904, !14, i64 8912912, !14, i64 8912920, !7, i64 8912928, !7, i64 8912936, !7, i64 8912944}
!13 = !{!"_ZTSN2vl6ObjectE"}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"bool", !8, i64 0}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!6, !7, i64 8}
!20 = !{!6, !7, i64 16}
!21 = !{!22, !22, i64 0}
!22 = !{!"wchar_t", !8, i64 0}
!23 = !{!14, !14, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{!6, !7, i64 24}


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