; LLVM IR from microsoft/Multiverso :: Applications/WordEmbedding/src/util.ll (ZN13wordembedding7Sampler12WordSamplingEllf)

; 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: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN13wordembedding7Sampler12WordSamplingEllf(ptr noundef nonnull align 8 dereferenceable(8) %0, i64 noundef %1, i64 noundef %2, float noundef %3) #1 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store i64 %2, ptr %7, align 8, !tbaa !9
  store float %3, ptr %8, align 4, !tbaa !11
  %10 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %11 = load i64, ptr %6, align 8, !tbaa !9
  %12 = sitofp i64 %11 to float
  %13 = load float, ptr %8, align 4, !tbaa !11
  %14 = load i64, ptr %7, align 8, !tbaa !9
  %15 = sitofp i64 %14 to float
  %16 = fmul float %13, %15
  %17 = fdiv float %12, %16
  %18 = fpext float %17 to double
  %19 = call double @sqrt(double noundef %18) #3
  %20 = fadd double %19, 1.000000e+00
  %21 = load float, ptr %8, align 4, !tbaa !11
  %22 = load i64, ptr %7, align 8, !tbaa !9
  %23 = sitofp i64 %22 to float
  %24 = fmul float %21, %23
  %25 = fpext float %24 to double
  %26 = fmul double %20, %25
  %27 = load i64, ptr %6, align 8, !tbaa !9
  %28 = sitofp i64 %27 to double
  %29 = fdiv double %26, %28
  %30 = fptrunc double %29 to float
  store float %30, ptr %9, align 4, !tbaa !11
  %31 = load float, ptr %9, align 4, !tbaa !11
  %32 = call i32 @rand() #3
  %33 = sitofp i32 %32 to float
  %34 = fdiv float %33, 0x41E0000000000000
  %35 = fcmp ogt float %31, %34
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  ret i1 %35
}

; Function Attrs: nounwind
declare double @sqrt(double noundef) #2

; Function Attrs: nounwind
declare i32 @rand() #2

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 = { 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 #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, !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 = !{!"float", !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
define dso_local noundef zeroext i1 @_ZN13wordembedding7Sampler12WordSamplingEllf(ptr nocapture noundef nonnull readnone align 8 dereferenceable(8) %0, i64 noundef %1, i64 noundef %2, float noundef %3) local_unnamed_addr #0 align 2 {
  %5 = sitofp i64 %1 to float
  %6 = sitofp i64 %2 to float
  %7 = fmul float %6, %3
  %8 = fdiv float %5, %7
  %9 = fpext float %8 to double
  %10 = tail call double @sqrt(double noundef %9) #3
  %11 = fadd double %10, 1.000000e+00
  %12 = fpext float %7 to double
  %13 = fmul double %11, %12
  %14 = sitofp i64 %1 to double
  %15 = fdiv double %13, %14
  %16 = fptrunc double %15 to float
  %17 = tail call i32 @rand() #3
  %18 = sitofp i32 %17 to float
  %19 = fmul float %18, 0x3E00000000000000
  %20 = fcmp olt float %19, %16
  ret i1 %20
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sqrt(double noundef) local_unnamed_addr #1

; Function Attrs: nounwind
declare i32 @rand() local_unnamed_addr #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 = { 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 #2 = { 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 #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)"}


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