; 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::CharRange" = type { i32, i32 }
%"class.vl::regex_internal::CharSetExpression" = type <{ %"class.vl::regex_internal::Expression", %"class.vl::collections::SortedList.1001", i8, [7 x i8] }>
%"class.vl::regex_internal::Expression" = type { %"class.vl::Object" }
%"class.vl::Object" = type { ptr }
%"class.vl::collections::SortedList.1001" = type { %"class.vl::collections::ListBase.base.1007", %"class.vl::collections::IEnumerable.1005" }
%"class.vl::collections::ListBase.base.1007" = type <{ %"class.vl::collections::ArrayBase.base.1006", i64, i8 }>
%"class.vl::collections::ArrayBase.base.1006" = type { %"class.vl::collections::ListStore.1004", ptr, i64 }
%"class.vl::collections::ListStore.1004" = type { %"class.vl::Object" }
%"class.vl::collections::IEnumerable.1005" = type { %"class.vl::Interface" }
%"class.vl::Interface" = 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: 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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK2vl14regex_internal9CharRangeltES1_(ptr noundef nonnull align 4 dereferenceable(8), i64) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK2vl14regex_internal9CharRangegtES1_(ptr noundef nonnull align 4 dereferenceable(8), i64) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN2vl14regex_internal17CharSetExpression20AddRangeWithConflictENS0_9CharRangeE(ptr noundef nonnull align 8 dereferenceable(57) %0, i64 %1) #3 align 2 {
  %3 = alloca i1, align 1
  %4 = alloca %"class.vl::regex_internal::CharRange", align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca %"class.vl::regex_internal::CharRange", align 4
  %10 = alloca %"class.vl::regex_internal::CharRange", align 4
  store i64 %1, ptr %4, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8
  %12 = getelementptr inbounds %"class.vl::regex_internal::CharRange", ptr %4, i32 0, i32 0
  %13 = load i32, ptr %12, align 4, !tbaa !9
  %14 = getelementptr inbounds %"class.vl::regex_internal::CharRange", ptr %4, i32 0, i32 1
  %15 = load i32, ptr %14, align 4, !tbaa !12
  %16 = icmp sgt i32 %13, %15
  br i1 %16, label %17, label %25

17:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %18 = getelementptr inbounds %"class.vl::regex_internal::CharRange", ptr %4, i32 0, i32 0
  %19 = load i32, ptr %18, align 4, !tbaa !9
  store i32 %19, ptr %6, align 4, !tbaa !13
  %20 = getelementptr inbounds %"class.vl::regex_internal::CharRange", ptr %4, i32 0, i32 1
  %21 = load i32, ptr %20, align 4, !tbaa !12
  %22 = getelementptr inbounds %"class.vl::regex_internal::CharRange", ptr %4, i32 0, i32 0
  store i32 %21, ptr %22, align 4, !tbaa !9
  %23 = load i32, ptr %6, align 4, !tbaa !13
  %24 = getelementptr inbounds %"class.vl::regex_internal::CharRange", ptr %4, i32 0, i32 1
  store i32 %23, ptr %24, align 4, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %25

25:                                               ; preds = %17, %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  store i64 0, ptr %7, align 8, !tbaa !14
  br label %26

26:                                               ; preds = %46, %25
  %27 = load i64, ptr %7, align 8, !tbaa !14
  %28 = getelementptr inbounds %"class.vl::regex_internal::CharSetExpression", ptr %11, i32 0, i32 1
  %29 = call noundef i64 @_ZNK2vl11collections9ArrayBaseINS_14regex_internal9CharRangeEE5CountEv(ptr noundef nonnull align 8 dereferenceable(24) %28)
  %30 = icmp slt i64 %27, %29
  br i1 %30, label %32, label %31

31:                                               ; preds = %26
  store i32 2, ptr %8, align 4
  br label %49

32:                                               ; preds = %26
  %33 = getelementptr inbounds %"class.vl::regex_internal::CharSetExpression", ptr %11, i32 0, i32 1
  %34 = load i64, ptr %7, align 8, !tbaa !14
  %35 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNK2vl11collections9ArrayBaseINS_14regex_internal9CharRangeEEixEl(ptr noundef nonnull align 8 dereferenceable(24) %33, i64 noundef %34)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %9, ptr align 4 %35, i64 8, i1 false), !tbaa.struct !16
  %36 = load i64, ptr %9, align 4
  %37 = call noundef zeroext i1 @_ZNK2vl14regex_internal9CharRangeltES1_(ptr noundef nonnull align 4 dereferenceable(8) %4, i64 %36)
  br i1 %37, label %45, label %38

38:                                               ; preds = %32
  %39 = getelementptr inbounds %"class.vl::regex_internal::CharSetExpression", ptr %11, i32 0, i32 1
  %40 = load i64, ptr %7, align 8, !tbaa !14
  %41 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNK2vl11collections9ArrayBaseINS_14regex_internal9CharRangeEEixEl(ptr noundef nonnull align 8 dereferenceable(24) %39, i64 noundef %40)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 4 %41, i64 8, i1 false), !tbaa.struct !16
  %42 = load i64, ptr %10, align 4
  %43 = call noundef zeroext i1 @_ZNK2vl14regex_internal9CharRangegtES1_(ptr noundef nonnull align 4 dereferenceable(8) %4, i64 %42)
  br i1 %43, label %45, label %44

44:                                               ; preds = %38
  store i1 false, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %49

45:                                               ; preds = %38, %32
  br label %46

46:                                               ; preds = %45
  %47 = load i64, ptr %7, align 8, !tbaa !14
  %48 = add nsw i64 %47, 1
  store i64 %48, ptr %7, align 8, !tbaa !14
  br label %26, !llvm.loop !17

49:                                               ; preds = %44, %31
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  %50 = load i32, ptr %8, align 4
  switch i32 %50, label %56 [
    i32 2, label %51
    i32 1, label %54
  ]

51:                                               ; preds = %49
  %52 = getelementptr inbounds %"class.vl::regex_internal::CharSetExpression", ptr %11, i32 0, i32 1
  %53 = call noundef i64 @_ZN2vl11collections10SortedListINS_14regex_internal9CharRangeES3_E3AddERKS3_(ptr noundef nonnull align 8 dereferenceable(33) %52, ptr noundef nonnull align 4 dereferenceable(8) %4)
  store i1 true, ptr %3, align 1
  br label %54

54:                                               ; preds = %51, %49
  %55 = load i1, ptr %3, align 1
  ret i1 %55

56:                                               ; preds = %49
  unreachable
}

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZNK2vl11collections9ArrayBaseINS_14regex_internal9CharRangeEEixEl(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN2vl11collections10SortedListINS_14regex_internal9CharRangeES3_E3AddERKS3_(ptr noundef nonnull align 8 dereferenceable(33), ptr noundef nonnull align 4 dereferenceable(8)) #3 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #4 = { 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_internal9CharRangeE", !11, i64 0, !11, i64 4}
!11 = !{!"wchar_t", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{!11, !11, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{i64 0, i64 4, !13, i64 4, i64 4, !13}
!17 = distinct !{!17, !18}
!18 = !{!"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.vl::regex_internal::CharRange" = type { i32, i32 }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK2vl14regex_internal9CharRangeltES1_(ptr noundef nonnull align 4 dereferenceable(8), i64) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK2vl14regex_internal9CharRangegtES1_(ptr noundef nonnull align 4 dereferenceable(8), i64) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN2vl14regex_internal17CharSetExpression20AddRangeWithConflictENS0_9CharRangeE(ptr noundef nonnull align 8 dereferenceable(57) %0, i64 %1) local_unnamed_addr #1 align 2 {
  %3 = alloca %"class.vl::regex_internal::CharRange", align 8
  store i64 %1, ptr %3, align 8
  %4 = trunc i64 %1 to i32
  %5 = lshr i64 %1, 32
  %6 = trunc nuw i64 %5 to i32
  %7 = icmp sgt i32 %4, %6
  br i1 %7, label %8, label %10

8:                                                ; preds = %2
  %9 = getelementptr inbounds i8, ptr %3, i64 4
  store i32 %6, ptr %3, align 8, !tbaa !5
  store i32 %4, ptr %9, align 4, !tbaa !10
  br label %10

10:                                               ; preds = %8, %2
  %11 = getelementptr inbounds i8, ptr %0, i64 8
  %12 = tail call noundef i64 @_ZNK2vl11collections9ArrayBaseINS_14regex_internal9CharRangeEE5CountEv(ptr noundef nonnull align 8 dereferenceable(24) %11)
  %13 = icmp slt i64 %12, 1
  br i1 %13, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %10, %19
  %.0817 = phi i64 [ %20, %19 ], [ 0, %10 ]
  %14 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNK2vl11collections9ArrayBaseINS_14regex_internal9CharRangeEEixEl(ptr noundef nonnull align 8 dereferenceable(24) %11, i64 noundef %.0817)
  %.sroa.01.0.copyload = load i64, ptr %14, align 4
  %15 = call noundef zeroext i1 @_ZNK2vl14regex_internal9CharRangeltES1_(ptr noundef nonnull align 4 dereferenceable(8) %3, i64 %.sroa.01.0.copyload)
  br i1 %15, label %19, label %16

16:                                               ; preds = %.lr.ph
  %17 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNK2vl11collections9ArrayBaseINS_14regex_internal9CharRangeEEixEl(ptr noundef nonnull align 8 dereferenceable(24) %11, i64 noundef %.0817)
  %.sroa.0.0.copyload = load i64, ptr %17, align 4
  %18 = call noundef zeroext i1 @_ZNK2vl14regex_internal9CharRangegtES1_(ptr noundef nonnull align 4 dereferenceable(8) %3, i64 %.sroa.0.0.copyload)
  br i1 %18, label %19, label %.loopexit

19:                                               ; preds = %.lr.ph, %16
  %20 = add nuw nsw i64 %.0817, 1
  %21 = call noundef i64 @_ZNK2vl11collections9ArrayBaseINS_14regex_internal9CharRangeEE5CountEv(ptr noundef nonnull align 8 dereferenceable(24) %11)
  %.not = icmp slt i64 %20, %21
  br i1 %.not, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge:                                      ; preds = %19, %10
  %22 = call noundef i64 @_ZN2vl11collections10SortedListINS_14regex_internal9CharRangeES3_E3AddERKS3_(ptr noundef nonnull align 8 dereferenceable(33) %11, ptr noundef nonnull align 4 dereferenceable(8) %3)
  br label %.loopexit

.loopexit:                                        ; preds = %16, %._crit_edge
  %23 = phi i1 [ true, %._crit_edge ], [ false, %16 ]
  ret i1 %23
}

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZNK2vl11collections9ArrayBaseINS_14regex_internal9CharRangeEEixEl(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN2vl11collections10SortedListINS_14regex_internal9CharRangeES3_E3AddERKS3_(ptr noundef nonnull align 8 dereferenceable(33), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #1 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 = { 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, !7, i64 0}
!6 = !{!"_ZTSN2vl14regex_internal9CharRangeE", !7, i64 0, !7, i64 4}
!7 = !{!"wchar_t", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 4}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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