; LLVM IR from gstonge/spreading_CR :: src/HashPropensity.ll (ZNK3net14HashPropensityclEd)

; 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.net::HashPropensity" = type <{ double, double, double, i8, [7 x i8] }>

; Function Attrs: nounwind
declare double @log2(double noundef) #0

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i64 @_ZNK3net14HashPropensityclEd(ptr noundef nonnull align 8 dereferenceable(25) %0, double noundef %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca double, align 8
  %5 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store double %1, ptr %4, align 8, !tbaa !9
  %6 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %7 = load double, ptr %4, align 8, !tbaa !9
  %8 = getelementptr inbounds %"class.net::HashPropensity", ptr %6, i32 0, i32 0
  %9 = load double, ptr %8, align 8, !tbaa !11
  %10 = fdiv double %7, %9
  %11 = call double @log2(double noundef %10) #4
  %12 = getelementptr inbounds %"class.net::HashPropensity", ptr %6, i32 0, i32 2
  %13 = load double, ptr %12, align 8, !tbaa !14
  %14 = call double @log2(double noundef %13) #4
  %15 = fdiv double %11, %14
  %16 = call double @llvm.floor.f64(double %15)
  %17 = fptoui double %16 to i64
  store i64 %17, ptr %5, align 8, !tbaa !15
  %18 = getelementptr inbounds %"class.net::HashPropensity", ptr %6, i32 0, i32 3
  %19 = load i8, ptr %18, align 8, !tbaa !17, !range !18, !noundef !19
  %20 = trunc i8 %19 to i1
  br i1 %20, label %21, label %29

21:                                               ; preds = %2
  %22 = load double, ptr %4, align 8, !tbaa !9
  %23 = getelementptr inbounds %"class.net::HashPropensity", ptr %6, i32 0, i32 1
  %24 = load double, ptr %23, align 8, !tbaa !20
  %25 = fcmp oeq double %22, %24
  br i1 %25, label %26, label %29

26:                                               ; preds = %21
  %27 = load i64, ptr %5, align 8, !tbaa !15
  %28 = sub i64 %27, 1
  store i64 %28, ptr %5, align 8, !tbaa !15
  br label %29

29:                                               ; preds = %26, %21, %2
  %30 = load i64, ptr %5, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret i64 %30
}

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

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"double", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTSN3net14HashPropensityE", !10, i64 0, !10, i64 8, !10, i64 16, !13, i64 24}
!13 = !{!"bool", !7, i64 0}
!14 = !{!12, !10, i64 16}
!15 = !{!16, !16, i64 0}
!16 = !{!"long", !7, i64 0}
!17 = !{!12, !13, i64 24}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!12, !10, i64 8}


; 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 nofree nounwind willreturn memory(write)
declare double @log2(double noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write, argmem: readwrite) uwtable
define dso_local noundef i64 @_ZNK3net14HashPropensityclEd(ptr nocapture noundef nonnull readonly align 8 dereferenceable(25) %0, double noundef %1) local_unnamed_addr #2 align 2 {
  %3 = load double, ptr %0, align 8, !tbaa !5
  %4 = fdiv double %1, %3
  %5 = tail call double @log2(double noundef %4) #3
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = load double, ptr %6, align 8, !tbaa !11
  %8 = tail call double @log2(double noundef %7) #3
  %9 = fdiv double %5, %8
  %10 = tail call double @llvm.floor.f64(double %9)
  %11 = fptoui double %10 to i64
  %12 = getelementptr inbounds i8, ptr %0, i64 24
  %13 = load i8, ptr %12, align 8, !tbaa !12, !range !13, !noundef !14
  %14 = trunc nuw i8 %13 to i1
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  %16 = load double, ptr %15, align 8
  %17 = fcmp oeq double %16, %1
  %or.cond = select i1 %14, i1 %17, i1 false
  %18 = sext i1 %or.cond to i64
  %.0 = add i64 %18, %11
  ret i64 %.0
}

attributes #0 = { mustprogress nofree nounwind willreturn memory(write) "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 nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { mustprogress nofree nounwind willreturn memory(write, argmem: readwrite) 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 = { 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, !7, i64 0}
!6 = !{!"_ZTSN3net14HashPropensityE", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!6, !7, i64 16}
!12 = !{!6, !10, i64 24}
!13 = !{i8 0, i8 2}
!14 = !{}


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