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

; Function Attrs: mustprogress uwtable
define dso_local i32 @bloom_init2(ptr noundef %0, i64 noundef %1, x86_fp80 noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca x86_fp80, align 16
  %8 = alloca x86_fp80, align 16
  %9 = alloca x86_fp80, align 16
  %10 = alloca x86_fp80, align 16
  %11 = alloca x86_fp80, align 16
  %12 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store x86_fp80 %2, ptr %7, align 16, !tbaa !11
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 16 %13, i8 0, i64 80, i1 false)
  %14 = load i64, ptr %6, align 8, !tbaa !9
  %15 = icmp ult i64 %14, 1000
  br i1 %15, label %22, label %16

16:                                               ; preds = %3
  %17 = load x86_fp80, ptr %7, align 16, !tbaa !11
  %18 = fcmp ole x86_fp80 %17, 0xK00000000000000000000
  br i1 %18, label %22, label %19

19:                                               ; preds = %16
  %20 = load x86_fp80, ptr %7, align 16, !tbaa !11
  %21 = fcmp oge x86_fp80 %20, 0xK3FFF8000000000000000
  br i1 %21, label %22, label %23

22:                                               ; preds = %19, %16, %3
  store i32 1, ptr %4, align 4
  br label %97

23:                                               ; preds = %19
  %24 = load i64, ptr %6, align 8, !tbaa !9
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.bloom, ptr %25, i32 0, i32 0
  store i64 %24, ptr %26, align 16, !tbaa !13
  %27 = load x86_fp80, ptr %7, align 16, !tbaa !11
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.bloom, ptr %28, i32 0, i32 4
  store x86_fp80 %27, ptr %29, align 16, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #6
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.bloom, ptr %30, i32 0, i32 4
  %32 = load x86_fp80, ptr %31, align 16, !tbaa !16
  %33 = call noundef x86_fp80 @_ZSt3loge(x86_fp80 noundef %32)
  %34 = fneg x86_fp80 %33
  store x86_fp80 %34, ptr %8, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #6
  store x86_fp80 0xK3FFDF5FDEFFC162C3800, ptr %9, align 16, !tbaa !11
  %35 = load x86_fp80, ptr %8, align 16, !tbaa !11
  %36 = load x86_fp80, ptr %9, align 16, !tbaa !11
  %37 = fdiv x86_fp80 %35, %36
  %38 = fptrunc x86_fp80 %37 to double
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.bloom, ptr %39, i32 0, i32 8
  store double %38, ptr %40, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #6
  %41 = load i64, ptr %6, align 8, !tbaa !9
  %42 = uitofp i64 %41 to x86_fp80
  store x86_fp80 %42, ptr %10, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #6
  %43 = load x86_fp80, ptr %10, align 16, !tbaa !11
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.bloom, ptr %44, i32 0, i32 8
  %46 = load double, ptr %45, align 8, !tbaa !17
  %47 = fpext double %46 to x86_fp80
  %48 = fmul x86_fp80 %43, %47
  store x86_fp80 %48, ptr %11, align 16, !tbaa !11
  %49 = load x86_fp80, ptr %11, align 16, !tbaa !11
  %50 = fptoui x86_fp80 %49 to i64
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.bloom, ptr %51, i32 0, i32 1
  store i64 %50, ptr %52, align 8, !tbaa !18
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.bloom, ptr %53, i32 0, i32 1
  %55 = load i64, ptr %54, align 8, !tbaa !18
  %56 = udiv i64 %55, 8
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.bloom, ptr %57, i32 0, i32 2
  store i64 %56, ptr %58, align 16, !tbaa !19
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.bloom, ptr %59, i32 0, i32 1
  %61 = load i64, ptr %60, align 8, !tbaa !18
  %62 = urem i64 %61, 8
  %63 = icmp ne i64 %62, 0
  br i1 %63, label %64, label %69

64:                                               ; preds = %23
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.bloom, ptr %65, i32 0, i32 2
  %67 = load i64, ptr %66, align 16, !tbaa !19
  %68 = add i64 %67, 1
  store i64 %68, ptr %66, align 16, !tbaa !19
  br label %69

69:                                               ; preds = %64, %23
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.bloom, ptr %70, i32 0, i32 8
  %72 = load double, ptr %71, align 8, !tbaa !17
  %73 = fmul double 0x3FE62E42FEFA39EC, %72
  %74 = call double @llvm.ceil.f64(double %73)
  %75 = fptoui double %74 to i8
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.bloom, ptr %76, i32 0, i32 3
  store i8 %75, ptr %77, align 8, !tbaa !20
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.bloom, ptr %78, i32 0, i32 2
  %80 = load i64, ptr %79, align 16, !tbaa !19
  %81 = call noalias ptr @calloc(i64 noundef %80, i64 noundef 1) #7
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.bloom, ptr %82, i32 0, i32 9
  store ptr %81, ptr %83, align 16, !tbaa !21
  %84 = load ptr, ptr %5, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.bloom, ptr %84, i32 0, i32 9
  %86 = load ptr, ptr %85, align 16, !tbaa !21
  %87 = icmp eq ptr %86, null
  br i1 %87, label %88, label %89

88:                                               ; preds = %69
  store i32 1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %96

89:                                               ; preds = %69
  %90 = load ptr, ptr %5, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.bloom, ptr %90, i32 0, i32 5
  store i8 1, ptr %91, align 16, !tbaa !22
  %92 = load ptr, ptr %5, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.bloom, ptr %92, i32 0, i32 6
  store i8 2, ptr %93, align 1, !tbaa !23
  %94 = load ptr, ptr %5, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.bloom, ptr %94, i32 0, i32 7
  store i8 -55, ptr %95, align 2, !tbaa !24
  store i32 0, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %96

96:                                               ; preds = %89, %88
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #6
  br label %97

97:                                               ; preds = %96, %22
  %98 = load i32, ptr %4, align 4
  ret i32 %98
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef x86_fp80 @_ZSt3loge(x86_fp80 noundef) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.ceil.f64(double) #4

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #5

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nounwind allocsize(0,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 #6 = { nounwind }
attributes #7 = { nounwind allocsize(0,1) }

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


; 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
define dso_local range(i32 0, 2) i32 @bloom_init2(ptr nocapture noundef writeonly %0, i64 noundef %1, x86_fp80 noundef %2) local_unnamed_addr #0 {
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(80) %0, i8 0, i64 80, i1 false)
  %4 = icmp ult i64 %1, 1000
  %5 = fcmp ole x86_fp80 %2, 0xK00000000000000000000
  %or.cond = or i1 %4, %5
  %6 = fcmp oge x86_fp80 %2, 0xK3FFF8000000000000000
  %or.cond3 = or i1 %6, %or.cond
  br i1 %or.cond3, label %33, label %7

7:                                                ; preds = %3
  store i64 %1, ptr %0, align 16, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 32
  store x86_fp80 %2, ptr %8, align 16, !tbaa !13
  %9 = tail call noundef x86_fp80 @_ZSt3loge(x86_fp80 noundef %2)
  %10 = fdiv x86_fp80 %9, 0xKBFFDF5FDEFFC162C3800
  %11 = fptrunc x86_fp80 %10 to double
  %12 = getelementptr inbounds i8, ptr %0, i64 56
  store double %11, ptr %12, align 8, !tbaa !14
  %13 = uitofp i64 %1 to x86_fp80
  %14 = fpext double %11 to x86_fp80
  %15 = fmul x86_fp80 %13, %14
  %16 = fptoui x86_fp80 %15 to i64
  %17 = getelementptr inbounds i8, ptr %0, i64 8
  store i64 %16, ptr %17, align 8, !tbaa !15
  %18 = lshr i64 %16, 3
  %19 = getelementptr inbounds i8, ptr %0, i64 16
  %20 = and i64 %16, 7
  %.not = icmp ne i64 %20, 0
  %21 = zext i1 %.not to i64
  %spec.select = add nuw nsw i64 %18, %21
  store i64 %spec.select, ptr %19, align 16, !tbaa !16
  %22 = fmul double %11, 0x3FE62E42FEFA39EC
  %23 = tail call double @llvm.ceil.f64(double %22)
  %24 = fptoui double %23 to i8
  %25 = getelementptr inbounds i8, ptr %0, i64 24
  store i8 %24, ptr %25, align 8, !tbaa !17
  %26 = tail call noalias ptr @calloc(i64 noundef %spec.select, i64 noundef 1) #5
  %27 = getelementptr inbounds i8, ptr %0, i64 64
  store ptr %26, ptr %27, align 16, !tbaa !18
  %28 = icmp eq ptr %26, null
  br i1 %28, label %33, label %29

29:                                               ; preds = %7
  %30 = getelementptr inbounds i8, ptr %0, i64 48
  store i8 1, ptr %30, align 16, !tbaa !19
  %31 = getelementptr inbounds i8, ptr %0, i64 49
  store i8 2, ptr %31, align 1, !tbaa !20
  %32 = getelementptr inbounds i8, ptr %0, i64 50
  store i8 -55, ptr %32, align 2, !tbaa !21
  br label %33

33:                                               ; preds = %29, %7, %3
  %.1 = phi i32 [ 1, %3 ], [ 0, %29 ], [ 1, %7 ]
  ret i32 %.1
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef x86_fp80 @_ZSt3loge(x86_fp80 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.ceil.f64(double) #3

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #4

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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #5 = { nounwind allocsize(0,1) }

!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 = !{!"_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, !10, i64 32}
!14 = !{!6, !11, i64 56}
!15 = !{!6, !7, i64 8}
!16 = !{!6, !7, i64 16}
!17 = !{!6, !8, i64 24}
!18 = !{!6, !12, i64 64}
!19 = !{!6, !8, i64 48}
!20 = !{!6, !8, i64 49}
!21 = !{!6, !8, i64 50}


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