; LLVM IR from weicao/cascadb :: src/util/bloom.ll (ZN7cascadb13bloom_matchesERKNS_5SliceES2_)

; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL5_hashPKcmj(ptr noundef, i64 noundef, i32 noundef) #1

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

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

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

19:                                               ; preds = %2
  store i1 false, ptr %3, align 1
  store i32 1, ptr %13, align 4
  br label %76

20:                                               ; preds = %2
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = call noundef ptr @_ZNK7cascadb5Slice4dataEv(ptr noundef nonnull align 8 dereferenceable(12) %21)
  store ptr %22, ptr %12, align 8, !tbaa !5
  %23 = load i64, ptr %7, align 8, !tbaa !9
  %24 = sub i64 %23, 1
  %25 = mul i64 %24, 8
  store i64 %25, ptr %8, align 8, !tbaa !9
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = call noundef ptr @_ZNK7cascadb5Slice4dataEv(ptr noundef nonnull align 8 dereferenceable(12) %26)
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = call noundef i64 @_ZNK7cascadb5Slice4sizeEv(ptr noundef nonnull align 8 dereferenceable(12) %28)
  %30 = call noundef i32 @_ZL5_hashPKcmj(ptr noundef %27, i64 noundef %29, i32 noundef -1130422988)
  store i32 %30, ptr %9, align 4, !tbaa !11
  %31 = load i32, ptr %9, align 4, !tbaa !11
  %32 = lshr i32 %31, 17
  %33 = load i32, ptr %9, align 4, !tbaa !11
  %34 = shl i32 %33, 15
  %35 = or i32 %32, %34
  store i32 %35, ptr %10, align 4, !tbaa !11
  %36 = load ptr, ptr %12, align 8, !tbaa !5
  %37 = load i64, ptr %7, align 8, !tbaa !9
  %38 = sub i64 %37, 1
  %39 = getelementptr inbounds i8, ptr %36, i64 %38
  %40 = load i8, ptr %39, align 1, !tbaa !13
  %41 = sext i8 %40 to i64
  store i64 %41, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  store i64 0, ptr %14, align 8, !tbaa !9
  br label %42

42:                                               ; preds = %70, %20
  %43 = load i64, ptr %14, align 8, !tbaa !9
  %44 = load i64, ptr %6, align 8, !tbaa !9
  %45 = icmp ult i64 %43, %44
  br i1 %45, label %47, label %46

46:                                               ; preds = %42
  store i32 2, ptr %13, align 4
  br label %73

47:                                               ; preds = %42
  %48 = load i32, ptr %9, align 4, !tbaa !11
  %49 = zext i32 %48 to i64
  %50 = load i64, ptr %8, align 8, !tbaa !9
  %51 = urem i64 %49, %50
  %52 = trunc i64 %51 to i32
  store i32 %52, ptr %11, align 4, !tbaa !11
  %53 = load ptr, ptr %12, align 8, !tbaa !5
  %54 = load i32, ptr %11, align 4, !tbaa !11
  %55 = udiv i32 %54, 8
  %56 = zext i32 %55 to i64
  %57 = getelementptr inbounds i8, ptr %53, i64 %56
  %58 = load i8, ptr %57, align 1, !tbaa !13
  %59 = sext i8 %58 to i32
  %60 = load i32, ptr %11, align 4, !tbaa !11
  %61 = urem i32 %60, 8
  %62 = shl i32 1, %61
  %63 = and i32 %59, %62
  %64 = icmp eq i32 %63, 0
  br i1 %64, label %65, label %66

65:                                               ; preds = %47
  store i1 false, ptr %3, align 1
  store i32 1, ptr %13, align 4
  br label %73

66:                                               ; preds = %47
  %67 = load i32, ptr %10, align 4, !tbaa !11
  %68 = load i32, ptr %9, align 4, !tbaa !11
  %69 = add i32 %68, %67
  store i32 %69, ptr %9, align 4, !tbaa !11
  br label %70

70:                                               ; preds = %66
  %71 = load i64, ptr %14, align 8, !tbaa !9
  %72 = add i64 %71, 1
  store i64 %72, ptr %14, align 8, !tbaa !9
  br label %42, !llvm.loop !14

73:                                               ; preds = %65, %46
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  %74 = load i32, ptr %13, align 4
  switch i32 %74, label %76 [
    i32 2, label %75
  ]

75:                                               ; preds = %73
  store i1 true, ptr %3, align 1
  store i32 1, ptr %13, align 4
  br label %76

76:                                               ; preds = %75, %73, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %77 = load i1, ptr %3, align 1
  ret i1 %77
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!7, !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: inlinehint mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL5_hashPKcmj(ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK7cascadb5Slice4dataEv(ptr noundef nonnull align 8 dereferenceable(12)) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN7cascadb13bloom_matchesERKNS_5SliceES2_(ptr noundef nonnull align 8 dereferenceable(12) %0, ptr noundef nonnull align 8 dereferenceable(12) %1) local_unnamed_addr #1 {
  %3 = tail call noundef i64 @_ZNK7cascadb5Slice4sizeEv(ptr noundef nonnull align 8 dereferenceable(12) %1)
  %4 = icmp ult i64 %3, 2
  br i1 %4, label %.loopexit, label %5

5:                                                ; preds = %2
  %6 = tail call noundef ptr @_ZNK7cascadb5Slice4dataEv(ptr noundef nonnull align 8 dereferenceable(12) %1)
  %7 = add i64 %3, -1
  %8 = shl i64 %7, 3
  %9 = tail call noundef ptr @_ZNK7cascadb5Slice4dataEv(ptr noundef nonnull align 8 dereferenceable(12) %0)
  %10 = tail call noundef i64 @_ZNK7cascadb5Slice4sizeEv(ptr noundef nonnull align 8 dereferenceable(12) %0)
  %11 = tail call noundef i32 @_ZL5_hashPKcmj(ptr noundef %9, i64 noundef %10, i32 noundef -1130422988)
  %12 = tail call i32 @llvm.fshl.i32(i32 %11, i32 %11, i32 15)
  %13 = getelementptr inbounds i8, ptr %6, i64 %7
  %14 = load i8, ptr %13, align 1, !tbaa !5
  %15 = sext i8 %14 to i64
  %.not25 = icmp eq i8 %14, 0
  br i1 %.not25, label %.loopexit, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %5
  %16 = zext i32 %11 to i64
  %17 = urem i64 %16, %8
  %18 = trunc nuw i64 %17 to i32
  %19 = lshr i64 %17, 3
  %20 = getelementptr inbounds i8, ptr %6, i64 %19
  %21 = load i8, ptr %20, align 1, !tbaa !5
  %22 = zext i8 %21 to i32
  %23 = and i32 %18, 7
  %24 = shl nuw nsw i32 1, %23
  %25 = and i32 %24, %22
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %.loopexit, label %.lr.ph33

.lr.ph:                                           ; preds = %.lr.ph33
  %27 = add i32 %.0232632, %12
  %28 = zext i32 %27 to i64
  %29 = urem i64 %28, %8
  %30 = trunc nuw i64 %29 to i32
  %31 = lshr i64 %29, 3
  %32 = getelementptr inbounds i8, ptr %6, i64 %31
  %33 = load i8, ptr %32, align 1, !tbaa !5
  %34 = zext i8 %33 to i32
  %35 = and i32 %30, 7
  %36 = shl nuw nsw i32 1, %35
  %37 = and i32 %36, %34
  %38 = icmp eq i32 %37, 0
  br i1 %38, label %.loopexit.loopexit, label %.lr.ph33, !llvm.loop !8

.lr.ph33:                                         ; preds = %.lr.ph.preheader, %.lr.ph
  %.0232632 = phi i32 [ %27, %.lr.ph ], [ %11, %.lr.ph.preheader ]
  %.02731 = phi i64 [ %39, %.lr.ph ], [ 0, %.lr.ph.preheader ]
  %39 = add nuw i64 %.02731, 1
  %exitcond = icmp eq i64 %39, %15
  br i1 %exitcond, label %.loopexit.loopexit, label %.lr.ph, !llvm.loop !8

.loopexit.loopexit:                               ; preds = %.lr.ph, %.lr.ph33
  %.not.le = icmp uge i64 %39, %15
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %.lr.ph.preheader, %5, %2
  %.1 = phi i1 [ false, %2 ], [ true, %5 ], [ false, %.lr.ph.preheader ], [ %.not.le, %.loopexit.loopexit ]
  ret i1 %.1
}

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

attributes #0 = { 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 #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 = { 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,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass