; LLVM IR from albertobsd/keyhunt :: bloom (bloom)

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

%struct.bloom = type { i64, i64, i64, i8, x86_fp80, i8, i8, i8, double, ptr }

@.str = external hidden unnamed_addr constant [30 x i8], align 1

; 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 uwtable
define dso_local i32 @bloom_check(ptr noundef %0, ptr noundef %1, i32 noundef %2) #1 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i8, align 1
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i8, align 1
  %13 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.bloom, ptr %14, i32 0, i32 5
  %16 = load i8, ptr %15, align 16, !tbaa !11
  %17 = zext i8 %16 to i32
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %19, label %22

19:                                               ; preds = %3
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef %20)
  store i32 -1, ptr %4, align 4
  br label %76

22:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #4
  store i8 0, ptr %8, align 1, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = load i32, ptr %7, align 4, !tbaa !9
  %25 = sext i32 %24 to i64
  %26 = call i64 @XXH64(ptr noundef %23, i64 noundef %25, i64 noundef 6481385041966929816)
  store i64 %26, ptr %9, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = load i32, ptr %7, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = load i64, ptr %9, align 8, !tbaa !17
  %31 = call i64 @XXH64(ptr noundef %27, i64 noundef %29, i64 noundef %30)
  store i64 %31, ptr %10, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #4
  store i8 0, ptr %12, align 1, !tbaa !16
  br label %32

32:                                               ; preds = %62, %22
  %33 = load i8, ptr %12, align 1, !tbaa !16
  %34 = zext i8 %33 to i32
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.bloom, ptr %35, i32 0, i32 3
  %37 = load i8, ptr %36, align 8, !tbaa !18
  %38 = zext i8 %37 to i32
  %39 = icmp slt i32 %34, %38
  br i1 %39, label %40, label %65

40:                                               ; preds = %32
  %41 = load i64, ptr %9, align 8, !tbaa !17
  %42 = load i64, ptr %10, align 8, !tbaa !17
  %43 = load i8, ptr %12, align 1, !tbaa !16
  %44 = zext i8 %43 to i64
  %45 = mul i64 %42, %44
  %46 = add i64 %41, %45
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.bloom, ptr %47, i32 0, i32 1
  %49 = load i64, ptr %48, align 8, !tbaa !19
  %50 = urem i64 %46, %49
  store i64 %50, ptr %11, align 8, !tbaa !17
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.bloom, ptr %51, i32 0, i32 9
  %53 = load ptr, ptr %52, align 16, !tbaa !20
  %54 = load i64, ptr %11, align 8, !tbaa !17
  %55 = call noundef i32 @_ZL8test_bitPhm(ptr noundef %53, i64 noundef %54)
  %56 = icmp ne i32 %55, 0
  br i1 %56, label %57, label %60

57:                                               ; preds = %40
  %58 = load i8, ptr %8, align 1, !tbaa !16
  %59 = add i8 %58, 1
  store i8 %59, ptr %8, align 1, !tbaa !16
  br label %61

60:                                               ; preds = %40
  store i32 0, ptr %4, align 4
  store i32 1, ptr %13, align 4
  br label %75

61:                                               ; preds = %57
  br label %62

62:                                               ; preds = %61
  %63 = load i8, ptr %12, align 1, !tbaa !16
  %64 = add i8 %63, 1
  store i8 %64, ptr %12, align 1, !tbaa !16
  br label %32, !llvm.loop !21

65:                                               ; preds = %32
  %66 = load i8, ptr %8, align 1, !tbaa !16
  %67 = zext i8 %66 to i32
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.bloom, ptr %68, i32 0, i32 3
  %70 = load i8, ptr %69, align 8, !tbaa !18
  %71 = zext i8 %70 to i32
  %72 = icmp eq i32 %67, %71
  br i1 %72, label %73, label %74

73:                                               ; preds = %65
  store i32 1, ptr %4, align 4
  store i32 1, ptr %13, align 4
  br label %75

74:                                               ; preds = %65
  store i32 0, ptr %4, align 4
  store i32 1, ptr %13, align 4
  br label %75

75:                                               ; preds = %74, %73, %60
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #4
  br label %76

76:                                               ; preds = %75, %19
  %77 = load i32, ptr %4, align 4
  ret i32 %77
}

declare i32 @printf(ptr noundef, ...) #2

declare i64 @XXH64(ptr noundef, i64 noundef, i64 noundef) #2

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

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 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !7, i64 48}
!12 = !{!"_ZTS5bloom", !13, i64 0, !13, i64 8, !13, i64 16, !7, i64 24, !14, i64 32, !7, i64 48, !7, i64 49, !7, i64 50, !15, i64 56, !6, i64 64}
!13 = !{!"long", !7, i64 0}
!14 = !{!"long double", !7, i64 0}
!15 = !{!"double", !7, i64 0}
!16 = !{!7, !7, i64 0}
!17 = !{!13, !13, i64 0}
!18 = !{!12, !7, i64 24}
!19 = !{!12, !13, i64 8}
!20 = !{!12, !6, i64 64}
!21 = distinct !{!21, !22}
!22 = !{!"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"

@.str = external hidden unnamed_addr constant [30 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local range(i32 -1, 2) i32 @bloom_check(ptr noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 48
  %5 = load i8, ptr %4, align 16, !tbaa !5
  %6 = icmp eq i8 %5, 0
  br i1 %6, label %7, label %9

7:                                                ; preds = %3
  %8 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, ptr noundef nonnull %0)
  br label %.loopexit

9:                                                ; preds = %3
  %10 = sext i32 %2 to i64
  %11 = tail call i64 @XXH64(ptr noundef %1, i64 noundef %10, i64 noundef 6481385041966929816)
  %12 = tail call i64 @XXH64(ptr noundef %1, i64 noundef %10, i64 noundef %11)
  %13 = getelementptr inbounds i8, ptr %0, i64 24
  %14 = load i8, ptr %13, align 8, !tbaa !13
  %.not27 = icmp eq i8 %14, 0
  br i1 %.not27, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %9
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  %16 = getelementptr inbounds i8, ptr %0, i64 64
  br label %17

17:                                               ; preds = %.lr.ph, %24
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %24 ]
  %18 = mul i64 %12, %indvars.iv
  %19 = add i64 %18, %11
  %20 = load i64, ptr %15, align 8, !tbaa !14
  %21 = urem i64 %19, %20
  %22 = load ptr, ptr %16, align 16, !tbaa !15
  %23 = tail call noundef i32 @_ZL8test_bitPhm(ptr noundef %22, i64 noundef %21)
  %.not = icmp eq i32 %23, 0
  br i1 %.not, label %.loopexit, label %24

24:                                               ; preds = %17
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %25 = load i8, ptr %13, align 8, !tbaa !13
  %26 = zext i8 %25 to i64
  %27 = icmp ult i64 %indvars.iv.next, %26
  br i1 %27, label %17, label %._crit_edge.loopexit, !llvm.loop !16

._crit_edge.loopexit:                             ; preds = %24
  %indvars31 = trunc i64 %indvars.iv.next to i8
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %9
  %.020.lcssa = phi i8 [ 0, %9 ], [ %indvars31, %._crit_edge.loopexit ]
  %.lcssa = phi i8 [ 0, %9 ], [ %25, %._crit_edge.loopexit ]
  %28 = icmp eq i8 %.020.lcssa, %.lcssa
  %. = zext i1 %28 to i32
  br label %.loopexit

.loopexit:                                        ; preds = %17, %._crit_edge, %7
  %.1 = phi i32 [ -1, %7 ], [ %., %._crit_edge ], [ 0, %17 ]
  ret i32 %.1
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

declare i64 @XXH64(ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL8test_bitPhm(ptr noundef, i64 noundef) local_unnamed_addr #3

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 = { nofree nounwind "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 = { 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" }

!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, !8, i64 48}
!6 = !{!"_ZTS5bloom", !7, i64 0, !7, i64 8, !7, i64 16, !8, i64 24, !10, i64 32, !8, i64 48, !8, i64 49, !8, i64 50, !11, i64 56, !12, i64 64}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"long double", !8, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!6, !8, i64 24}
!14 = !{!6, !7, i64 8}
!15 = !{!6, !12, i64 64}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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