; LLVM IR from KoishiDB/Koishi-DB :: src/util/bloom_filter.ll (ZNK8koishidb11BloomFilter11KeyMayMatchERKNS_5SliceES3_)

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZN8koishidbL9BloomHashERKNS_5SliceE(ptr noundef nonnull align 8 dereferenceable(16)) #1

; 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 @_ZNK8koishidb11BloomFilter11KeyMayMatchERKNS_5SliceES3_(ptr noundef nonnull align 4 dereferenceable(8) %0, ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(16) %2) #1 align 2 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i64, align 8
  %16 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %17 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = call noundef i64 @_ZNK8koishidb5Slice4sizeEv(ptr noundef nonnull align 8 dereferenceable(16) %18)
  store i64 %19, ptr %8, align 8, !tbaa !9
  %20 = load i64, ptr %8, align 8, !tbaa !9
  %21 = icmp ult i64 %20, 2
  br i1 %21, label %22, label %23

22:                                               ; preds = %3
  store i1 false, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %85

23:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = call noundef ptr @_ZNK8koishidb5Slice4dataEv(ptr noundef nonnull align 8 dereferenceable(16) %24)
  store ptr %25, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %26 = load i64, ptr %8, align 8, !tbaa !9
  %27 = sub i64 %26, 1
  %28 = mul i64 %27, 8
  store i64 %28, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %29 = load ptr, ptr %10, align 8, !tbaa !5
  %30 = load i64, ptr %8, align 8, !tbaa !9
  %31 = sub i64 %30, 1
  %32 = getelementptr inbounds i8, ptr %29, i64 %31
  %33 = load i8, ptr %32, align 1, !tbaa !11
  %34 = sext i8 %33 to i64
  store i64 %34, ptr %12, align 8, !tbaa !9
  %35 = load i64, ptr %12, align 8, !tbaa !9
  %36 = icmp ugt i64 %35, 30
  br i1 %36, label %37, label %38

37:                                               ; preds = %23
  store i1 true, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %84

38:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = call noundef i32 @_ZN8koishidbL9BloomHashERKNS_5SliceE(ptr noundef nonnull align 8 dereferenceable(16) %39)
  store i32 %40, ptr %13, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  %41 = load i32, ptr %13, align 4, !tbaa !12
  %42 = lshr i32 %41, 17
  %43 = load i32, ptr %13, align 4, !tbaa !12
  %44 = shl i32 %43, 15
  %45 = or i32 %42, %44
  store i32 %45, ptr %14, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  store i64 0, ptr %15, align 8, !tbaa !9
  br label %46

46:                                               ; preds = %77, %38
  %47 = load i64, ptr %15, align 8, !tbaa !9
  %48 = load i64, ptr %12, align 8, !tbaa !9
  %49 = icmp ult i64 %47, %48
  br i1 %49, label %51, label %50

50:                                               ; preds = %46
  store i32 2, ptr %9, align 4
  br label %80

51:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  %52 = load i32, ptr %13, align 4, !tbaa !12
  %53 = zext i32 %52 to i64
  %54 = load i64, ptr %11, align 8, !tbaa !9
  %55 = urem i64 %53, %54
  %56 = trunc i64 %55 to i32
  store i32 %56, ptr %16, align 4, !tbaa !12
  %57 = load ptr, ptr %10, align 8, !tbaa !5
  %58 = load i32, ptr %16, align 4, !tbaa !12
  %59 = udiv i32 %58, 8
  %60 = zext i32 %59 to i64
  %61 = getelementptr inbounds i8, ptr %57, i64 %60
  %62 = load i8, ptr %61, align 1, !tbaa !11
  %63 = sext i8 %62 to i32
  %64 = load i32, ptr %16, align 4, !tbaa !12
  %65 = urem i32 %64, 8
  %66 = shl i32 1, %65
  %67 = and i32 %63, %66
  %68 = icmp eq i32 %67, 0
  br i1 %68, label %69, label %70

69:                                               ; preds = %51
  store i1 false, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %74

70:                                               ; preds = %51
  %71 = load i32, ptr %14, align 4, !tbaa !12
  %72 = load i32, ptr %13, align 4, !tbaa !12
  %73 = add i32 %72, %71
  store i32 %73, ptr %13, align 4, !tbaa !12
  store i32 0, ptr %9, align 4
  br label %74

74:                                               ; preds = %70, %69
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  %75 = load i32, ptr %9, align 4
  switch i32 %75, label %80 [
    i32 0, label %76
  ]

76:                                               ; preds = %74
  br label %77

77:                                               ; preds = %76
  %78 = load i64, ptr %15, align 8, !tbaa !9
  %79 = add i64 %78, 1
  store i64 %79, ptr %15, align 8, !tbaa !9
  br label %46, !llvm.loop !14

80:                                               ; preds = %74, %50
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  %81 = load i32, ptr %9, align 4
  switch i32 %81, label %83 [
    i32 2, label %82
  ]

82:                                               ; preds = %80
  store i1 true, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %83

83:                                               ; preds = %82, %80
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  br label %84

84:                                               ; preds = %83, %37
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %85

85:                                               ; preds = %84, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %86 = load i1, ptr %4, align 1
  ret i1 %86
}

declare noundef i64 @_ZNK8koishidb5Slice4sizeEv(ptr noundef nonnull align 8 dereferenceable(16)) #2

declare noundef ptr @_ZNK8koishidb5Slice4dataEv(ptr noundef nonnull align 8 dereferenceable(16)) #2

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 = { "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 = { 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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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 uwtable
declare hidden noundef i32 @_ZN8koishidbL9BloomHashERKNS_5SliceE(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK8koishidb11BloomFilter11KeyMayMatchERKNS_5SliceES3_(ptr nocapture noundef nonnull readnone align 4 dereferenceable(8) %0, ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(16) %2) local_unnamed_addr #0 align 2 {
  %4 = tail call noundef i64 @_ZNK8koishidb5Slice4sizeEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
  %5 = icmp ult i64 %4, 2
  br i1 %5, label %.critedge, label %6

6:                                                ; preds = %3
  %7 = tail call noundef ptr @_ZNK8koishidb5Slice4dataEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
  %8 = add i64 %4, -1
  %9 = shl i64 %8, 3
  %10 = getelementptr inbounds i8, ptr %7, i64 %8
  %11 = load i8, ptr %10, align 1, !tbaa !5
  %12 = sext i8 %11 to i64
  %13 = icmp ugt i8 %11, 30
  br i1 %13, label %.critedge, label %14

14:                                               ; preds = %6
  %15 = tail call noundef i32 @_ZN8koishidbL9BloomHashERKNS_5SliceE(ptr noundef nonnull align 8 dereferenceable(16) %1)
  %16 = tail call i32 @llvm.fshl.i32(i32 %15, i32 %15, i32 15)
  %.not31.not32.not = icmp eq i8 %11, 0
  br i1 %.not31.not32.not, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %14, %27
  %.02434 = phi i64 [ %29, %27 ], [ 0, %14 ]
  %.02733 = phi i32 [ %28, %27 ], [ %15, %14 ]
  %17 = zext i32 %.02733 to i64
  %18 = urem i64 %17, %9
  %19 = trunc nuw i64 %18 to i32
  %20 = lshr i64 %18, 3
  %21 = getelementptr inbounds i8, ptr %7, i64 %20
  %22 = load i8, ptr %21, align 1, !tbaa !5
  %23 = zext i8 %22 to i32
  %24 = and i32 %19, 7
  %25 = shl nuw nsw i32 1, %24
  %26 = and i32 %25, %23
  %.not.not = icmp ne i32 %26, 0
  br i1 %.not.not, label %27, label %.critedge

27:                                               ; preds = %.lr.ph
  %28 = add i32 %.02733, %16
  %29 = add nuw i64 %.02434, 1
  %exitcond.not = icmp eq i64 %29, %12
  br i1 %exitcond.not, label %.critedge, label %.lr.ph, !llvm.loop !8

.critedge:                                        ; preds = %.lr.ph, %27, %14, %6, %3
  %.5 = phi i1 [ false, %3 ], [ true, %6 ], [ true, %14 ], [ %.not.not, %27 ], [ %.not.not, %.lr.ph ]
  ret i1 %.5
}

declare noundef i64 @_ZNK8koishidb5Slice4sizeEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1

declare noundef ptr @_ZNK8koishidb5Slice4dataEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.fshl.i32(i32, i32, i32) #2

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" }
attributes #1 = { "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


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