; LLVM IR from nsccgz-storage/nvlsm :: table/filter_block.ll (ZN7leveldb17FilterBlockReader11KeyMayMatchEmRKNS_5SliceE)

; 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.leveldb::Slice" = type { ptr, i64 }
%"class.leveldb::FilterBlockReader" = type { ptr, ptr, ptr, i64, i64 }

; 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
declare dso_local void @_ZN7leveldb5SliceC2EPKcm(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, i64 noundef) unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN7leveldb13DecodeFixed32EPKc(ptr noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN7leveldb17FilterBlockReader11KeyMayMatchEmRKNS_5SliceE(ptr noundef nonnull align 8 dereferenceable(40) %0, i64 noundef %1, ptr noundef nonnull align 8 dereferenceable(16) %2) #3 align 2 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca %"class.leveldb::Slice", align 8
  %12 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  %13 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %14 = load i64, ptr %6, align 8, !tbaa !9
  %15 = getelementptr inbounds %"class.leveldb::FilterBlockReader", ptr %13, i32 0, i32 4
  %16 = load i64, ptr %15, align 8, !tbaa !11
  %17 = lshr i64 %14, %16
  store i64 %17, ptr %8, align 8, !tbaa !9
  %18 = load i64, ptr %8, align 8, !tbaa !9
  %19 = getelementptr inbounds %"class.leveldb::FilterBlockReader", ptr %13, i32 0, i32 3
  %20 = load i64, ptr %19, align 8, !tbaa !13
  %21 = icmp ult i64 %18, %20
  br i1 %21, label %22, label %77

22:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %23 = getelementptr inbounds %"class.leveldb::FilterBlockReader", ptr %13, i32 0, i32 2
  %24 = load ptr, ptr %23, align 8, !tbaa !14
  %25 = load i64, ptr %8, align 8, !tbaa !9
  %26 = mul i64 %25, 4
  %27 = getelementptr inbounds i8, ptr %24, i64 %26
  %28 = call noundef i32 @_ZN7leveldb13DecodeFixed32EPKc(ptr noundef %27)
  store i32 %28, ptr %9, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %29 = getelementptr inbounds %"class.leveldb::FilterBlockReader", ptr %13, i32 0, i32 2
  %30 = load ptr, ptr %29, align 8, !tbaa !14
  %31 = load i64, ptr %8, align 8, !tbaa !9
  %32 = mul i64 %31, 4
  %33 = getelementptr inbounds i8, ptr %30, i64 %32
  %34 = getelementptr inbounds i8, ptr %33, i64 4
  %35 = call noundef i32 @_ZN7leveldb13DecodeFixed32EPKc(ptr noundef %34)
  store i32 %35, ptr %10, align 4, !tbaa !15
  %36 = load i32, ptr %9, align 4, !tbaa !15
  %37 = load i32, ptr %10, align 4, !tbaa !15
  %38 = icmp ule i32 %36, %37
  br i1 %38, label %39, label %67

39:                                               ; preds = %22
  %40 = load i32, ptr %10, align 4, !tbaa !15
  %41 = zext i32 %40 to i64
  %42 = getelementptr inbounds %"class.leveldb::FilterBlockReader", ptr %13, i32 0, i32 2
  %43 = load ptr, ptr %42, align 8, !tbaa !14
  %44 = getelementptr inbounds %"class.leveldb::FilterBlockReader", ptr %13, i32 0, i32 1
  %45 = load ptr, ptr %44, align 8, !tbaa !17
  %46 = ptrtoint ptr %43 to i64
  %47 = ptrtoint ptr %45 to i64
  %48 = sub i64 %46, %47
  %49 = icmp ule i64 %41, %48
  br i1 %49, label %50, label %67

50:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #4
  %51 = getelementptr inbounds %"class.leveldb::FilterBlockReader", ptr %13, i32 0, i32 1
  %52 = load ptr, ptr %51, align 8, !tbaa !17
  %53 = load i32, ptr %9, align 4, !tbaa !15
  %54 = zext i32 %53 to i64
  %55 = getelementptr inbounds i8, ptr %52, i64 %54
  %56 = load i32, ptr %10, align 4, !tbaa !15
  %57 = load i32, ptr %9, align 4, !tbaa !15
  %58 = sub i32 %56, %57
  %59 = zext i32 %58 to i64
  call void @_ZN7leveldb5SliceC2EPKcm(ptr noundef nonnull align 8 dereferenceable(16) %11, ptr noundef %55, i64 noundef %59)
  %60 = getelementptr inbounds %"class.leveldb::FilterBlockReader", ptr %13, i32 0, i32 0
  %61 = load ptr, ptr %60, align 8, !tbaa !18
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = load ptr, ptr %61, align 8, !tbaa !19
  %64 = getelementptr inbounds ptr, ptr %63, i64 4
  %65 = load ptr, ptr %64, align 8
  %66 = call noundef zeroext i1 %65(ptr noundef nonnull align 8 dereferenceable(8) %61, ptr noundef nonnull align 8 dereferenceable(16) %62, ptr noundef nonnull align 8 dereferenceable(16) %11)
  store i1 %66, ptr %4, align 1
  store i32 1, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #4
  br label %74

67:                                               ; preds = %39, %22
  %68 = load i32, ptr %9, align 4, !tbaa !15
  %69 = load i32, ptr %10, align 4, !tbaa !15
  %70 = icmp eq i32 %68, %69
  br i1 %70, label %71, label %72

71:                                               ; preds = %67
  store i1 false, ptr %4, align 1
  store i32 1, ptr %12, align 4
  br label %74

72:                                               ; preds = %67
  br label %73

73:                                               ; preds = %72
  store i32 0, ptr %12, align 4
  br label %74

74:                                               ; preds = %73, %71, %50
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  %75 = load i32, ptr %12, align 4
  switch i32 %75, label %78 [
    i32 0, label %76
  ]

76:                                               ; preds = %74
  br label %77

77:                                               ; preds = %76, %3
  store i1 true, ptr %4, align 1
  store i32 1, ptr %12, align 4
  br label %78

78:                                               ; preds = %77, %74
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  %79 = load i1, ptr %4, align 1
  ret i1 %79
}

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 = { inlinehint 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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 32}
!12 = !{!"_ZTSN7leveldb17FilterBlockReaderE", !6, i64 0, !6, i64 8, !6, i64 16, !10, i64 24, !10, i64 32}
!13 = !{!12, !10, i64 24}
!14 = !{!12, !6, i64 16}
!15 = !{!16, !16, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = !{!12, !6, i64 8}
!18 = !{!12, !6, i64 0}
!19 = !{!20, !20, i64 0}
!20 = !{!"vtable pointer", !8, i64 0}


; 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.leveldb::Slice" = type { ptr, i64 }

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7leveldb5SliceC2EPKcm(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, i64 noundef) unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN7leveldb13DecodeFixed32EPKc(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN7leveldb17FilterBlockReader11KeyMayMatchEmRKNS_5SliceE(ptr nocapture noundef nonnull readonly align 8 dereferenceable(40) %0, i64 noundef %1, ptr noundef nonnull align 8 dereferenceable(16) %2) local_unnamed_addr #3 align 2 {
  %4 = alloca %"class.leveldb::Slice", align 8
  %5 = getelementptr inbounds i8, ptr %0, i64 32
  %6 = load i64, ptr %5, align 8, !tbaa !5
  %7 = lshr i64 %1, %6
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = load i64, ptr %8, align 8, !tbaa !11
  %10 = icmp ult i64 %7, %9
  br i1 %10, label %11, label %39

11:                                               ; preds = %3
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  %13 = load ptr, ptr %12, align 8, !tbaa !12
  %14 = shl i64 %7, 2
  %15 = getelementptr inbounds i8, ptr %13, i64 %14
  %16 = tail call noundef i32 @_ZN7leveldb13DecodeFixed32EPKc(ptr noundef %15)
  %17 = load ptr, ptr %12, align 8, !tbaa !12
  %18 = getelementptr inbounds i8, ptr %17, i64 %14
  %19 = getelementptr inbounds i8, ptr %18, i64 4
  %20 = tail call noundef i32 @_ZN7leveldb13DecodeFixed32EPKc(ptr noundef nonnull %19)
  %.not = icmp ugt i32 %16, %20
  br i1 %.not, label %38, label %21

21:                                               ; preds = %11
  %22 = zext i32 %20 to i64
  %23 = load ptr, ptr %12, align 8, !tbaa !12
  %24 = getelementptr inbounds i8, ptr %0, i64 8
  %25 = load ptr, ptr %24, align 8, !tbaa !13
  %26 = ptrtoint ptr %23 to i64
  %27 = ptrtoint ptr %25 to i64
  %28 = sub i64 %26, %27
  %.not19 = icmp ult i64 %28, %22
  br i1 %.not19, label %38, label %.thread

.thread:                                          ; preds = %21
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #4
  %29 = zext i32 %16 to i64
  %30 = getelementptr inbounds i8, ptr %25, i64 %29
  %31 = sub i32 %20, %16
  %32 = zext i32 %31 to i64
  call void @_ZN7leveldb5SliceC2EPKcm(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef %30, i64 noundef %32)
  %33 = load ptr, ptr %0, align 8, !tbaa !14
  %34 = load ptr, ptr %33, align 8, !tbaa !15
  %35 = getelementptr inbounds i8, ptr %34, i64 32
  %36 = load ptr, ptr %35, align 8
  %37 = call noundef zeroext i1 %36(ptr noundef nonnull align 8 dereferenceable(8) %33, ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 8 dereferenceable(16) %4)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #4
  br label %40

38:                                               ; preds = %11, %21
  %.not23 = icmp eq i32 %16, %20
  br i1 %.not23, label %40, label %39

39:                                               ; preds = %38, %3
  br label %40

40:                                               ; preds = %.thread, %38, %39
  %.1 = phi i1 [ true, %39 ], [ false, %38 ], [ %37, %.thread ]
  ret i1 %.1
}

attributes #0 = { mustprogress 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 = { inlinehint 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, !10, i64 32}
!6 = !{!"_ZTSN7leveldb17FilterBlockReaderE", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !10, i64 32}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !10, i64 24}
!12 = !{!6, !7, i64 16}
!13 = !{!6, !7, i64 8}
!14 = !{!6, !7, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"vtable pointer", !9, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass