; LLVM IR from nsccgz-storage/nvlsm :: table/filter_block.ll (ZN7leveldb17FilterBlockReaderC2EPKNS_12FilterPolicyERKNS_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::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 noundef ptr @_ZNK7leveldb5Slice4dataEv(ptr noundef nonnull align 8 dereferenceable(16)) #1 align 2

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

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

21:                                               ; preds = %3
  store i32 1, ptr %8, align 4
  br label %59

22:                                               ; preds = %3
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = load i64, ptr %7, align 8, !tbaa !16
  %25 = sub i64 %24, 1
  %26 = call noundef signext i8 @_ZNK7leveldb5SliceixEm(ptr noundef nonnull align 8 dereferenceable(16) %23, i64 noundef %25)
  %27 = sext i8 %26 to i64
  %28 = getelementptr inbounds %"class.leveldb::FilterBlockReader", ptr %10, i32 0, i32 4
  store i64 %27, ptr %28, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = call noundef ptr @_ZNK7leveldb5Slice4dataEv(ptr noundef nonnull align 8 dereferenceable(16) %29)
  %31 = load i64, ptr %7, align 8, !tbaa !16
  %32 = getelementptr inbounds i8, ptr %30, i64 %31
  %33 = getelementptr inbounds i8, ptr %32, i64 -5
  %34 = call noundef i32 @_ZN7leveldb13DecodeFixed32EPKc(ptr noundef %33)
  store i32 %34, ptr %9, align 4, !tbaa !17
  %35 = load i32, ptr %9, align 4, !tbaa !17
  %36 = zext i32 %35 to i64
  %37 = load i64, ptr %7, align 8, !tbaa !16
  %38 = sub i64 %37, 5
  %39 = icmp ugt i64 %36, %38
  br i1 %39, label %40, label %41

40:                                               ; preds = %22
  store i32 1, ptr %8, align 4
  br label %58

41:                                               ; preds = %22
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = call noundef ptr @_ZNK7leveldb5Slice4dataEv(ptr noundef nonnull align 8 dereferenceable(16) %42)
  %44 = getelementptr inbounds %"class.leveldb::FilterBlockReader", ptr %10, i32 0, i32 1
  store ptr %43, ptr %44, align 8, !tbaa !12
  %45 = getelementptr inbounds %"class.leveldb::FilterBlockReader", ptr %10, i32 0, i32 1
  %46 = load ptr, ptr %45, align 8, !tbaa !12
  %47 = load i32, ptr %9, align 4, !tbaa !17
  %48 = zext i32 %47 to i64
  %49 = getelementptr inbounds i8, ptr %46, i64 %48
  %50 = getelementptr inbounds %"class.leveldb::FilterBlockReader", ptr %10, i32 0, i32 2
  store ptr %49, ptr %50, align 8, !tbaa !13
  %51 = load i64, ptr %7, align 8, !tbaa !16
  %52 = sub i64 %51, 5
  %53 = load i32, ptr %9, align 4, !tbaa !17
  %54 = zext i32 %53 to i64
  %55 = sub i64 %52, %54
  %56 = udiv i64 %55, 4
  %57 = getelementptr inbounds %"class.leveldb::FilterBlockReader", ptr %10, i32 0, i32 3
  store i64 %56, ptr %57, align 8, !tbaa !14
  store i32 0, ptr %8, align 4
  br label %58

58:                                               ; preds = %41, %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %59

59:                                               ; preds = %58, %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  %60 = load i32, ptr %8, align 4
  switch i32 %60, label %62 [
    i32 0, label %61
    i32 1, label %61
  ]

61:                                               ; preds = %59, %59
  ret void

62:                                               ; preds = %59
  unreachable
}

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

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN7leveldb17FilterBlockReaderC2EPKNS_12FilterPolicyERKNS_5SliceE(ptr nocapture noundef nonnull writeonly align 8 dereferenceable(40) %0, ptr noundef %1, ptr noundef nonnull align 8 dereferenceable(16) %2) unnamed_addr #0 align 2 {
  store ptr %1, ptr %0, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %4, i8 0, i64 32, i1 false)
  %7 = tail call noundef i64 @_ZNK7leveldb5Slice4sizeEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
  %8 = icmp ult i64 %7, 5
  br i1 %8, label %26, label %9

9:                                                ; preds = %3
  %10 = getelementptr inbounds i8, ptr %0, i64 32
  %11 = add i64 %7, -1
  %12 = tail call noundef signext i8 @_ZNK7leveldb5SliceixEm(ptr noundef nonnull align 8 dereferenceable(16) %2, i64 noundef %11)
  %13 = sext i8 %12 to i64
  store i64 %13, ptr %10, align 8, !tbaa !11
  %14 = tail call noundef ptr @_ZNK7leveldb5Slice4dataEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
  %15 = getelementptr inbounds i8, ptr %14, i64 %7
  %16 = getelementptr inbounds i8, ptr %15, i64 -5
  %17 = tail call noundef i32 @_ZN7leveldb13DecodeFixed32EPKc(ptr noundef nonnull %16)
  %18 = zext i32 %17 to i64
  %19 = add i64 %7, -5
  %20 = icmp ult i64 %19, %18
  br i1 %20, label %26, label %21

21:                                               ; preds = %9
  %22 = tail call noundef ptr @_ZNK7leveldb5Slice4dataEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
  store ptr %22, ptr %4, align 8, !tbaa !12
  %23 = getelementptr inbounds i8, ptr %22, i64 %18
  store ptr %23, ptr %5, align 8, !tbaa !13
  %24 = sub i64 %19, %18
  %25 = lshr i64 %24, 2
  store i64 %25, ptr %6, align 8, !tbaa !14
  br label %26

26:                                               ; preds = %21, %9, %3
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef signext i8 @_ZNK7leveldb5SliceixEm(ptr noundef nonnull align 8 dereferenceable(16), i64 noundef) local_unnamed_addr #0 align 2

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 = { 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 #2 = { 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 = !{!"_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 32}
!12 = !{!6, !7, i64 8}
!13 = !{!6, !7, i64 16}
!14 = !{!6, !10, i64 24}


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