; LLVM IR from kmilo17pet/qlibs :: qffmath (qFFMath_Floor)

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

; Function Attrs: nounwind uwtable
define dso_local float @qFFMath_Floor(float noundef %0) #2 {
  %2 = alloca float, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca float, align 4
  %6 = alloca i32, align 4
  store float %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 0, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %7 = load float, ptr %2, align 4, !tbaa !5
  store float %7, ptr %5, align 4, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %3, ptr align 4 %2, i64 4, i1 false)
  %8 = load i32, ptr %3, align 4, !tbaa !9
  %9 = ashr i32 %8, 23
  %10 = and i32 %9, 255
  %11 = sub nsw i32 %10, 127
  store i32 %11, ptr %4, align 4, !tbaa !9
  %12 = load i32, ptr %4, align 4, !tbaa !9
  %13 = icmp slt i32 %12, 23
  br i1 %13, label %14, label %51

14:                                               ; preds = %1
  %15 = load i32, ptr %4, align 4, !tbaa !9
  %16 = icmp slt i32 %15, 0
  br i1 %16, label %17, label %29

17:                                               ; preds = %14
  %18 = load i32, ptr %3, align 4, !tbaa !9
  %19 = icmp sge i32 %18, 0
  br i1 %19, label %20, label %21

20:                                               ; preds = %17
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %28

21:                                               ; preds = %17
  %22 = load i32, ptr %3, align 4, !tbaa !9
  %23 = and i32 %22, 2147483647
  %24 = icmp ne i32 0, %23
  br i1 %24, label %25, label %26

25:                                               ; preds = %21
  store i32 -1082130432, ptr %3, align 4, !tbaa !9
  br label %27

26:                                               ; preds = %21
  br label %27

27:                                               ; preds = %26, %25
  br label %28

28:                                               ; preds = %27, %20
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %5, ptr align 4 %3, i64 4, i1 false)
  br label %50

29:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %30 = load i32, ptr %4, align 4, !tbaa !9
  %31 = ashr i32 8388607, %30
  store i32 %31, ptr %6, align 4, !tbaa !9
  %32 = load i32, ptr %3, align 4, !tbaa !9
  %33 = load i32, ptr %6, align 4, !tbaa !9
  %34 = and i32 %32, %33
  %35 = icmp ne i32 0, %34
  br i1 %35, label %36, label %49

36:                                               ; preds = %29
  %37 = load i32, ptr %3, align 4, !tbaa !9
  %38 = icmp slt i32 %37, 0
  br i1 %38, label %39, label %44

39:                                               ; preds = %36
  %40 = load i32, ptr %4, align 4, !tbaa !9
  %41 = ashr i32 8388608, %40
  %42 = load i32, ptr %3, align 4, !tbaa !9
  %43 = add nsw i32 %42, %41
  store i32 %43, ptr %3, align 4, !tbaa !9
  br label %44

44:                                               ; preds = %39, %36
  %45 = load i32, ptr %6, align 4, !tbaa !9
  %46 = xor i32 %45, -1
  %47 = load i32, ptr %3, align 4, !tbaa !9
  %48 = and i32 %47, %46
  store i32 %48, ptr %3, align 4, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %5, ptr align 4 %3, i64 4, i1 false)
  br label %49

49:                                               ; preds = %44, %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %50

50:                                               ; preds = %49, %28
  br label %51

51:                                               ; preds = %50, %1
  %52 = load float, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret float %52
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !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 nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local float @qFFMath_Floor(float noundef %0) local_unnamed_addr #0 {
  %2 = bitcast float %0 to i32
  %3 = lshr i32 %2, 23
  %4 = and i32 %3, 255
  %5 = add nsw i32 %4, -127
  %6 = icmp ult i32 %4, 150
  br i1 %6, label %7, label %22

7:                                                ; preds = %1
  %8 = icmp ult i32 %4, 127
  br i1 %8, label %9, label %12

9:                                                ; preds = %7
  %10 = icmp sgt i32 %2, -1
  %.not22 = fcmp oeq float %0, 0.000000e+00
  %11 = select i1 %.not22, float %0, float -1.000000e+00
  %.0 = select i1 %10, float 0.000000e+00, float %11
  br label %22

12:                                               ; preds = %7
  %13 = lshr i32 8388607, %5
  %14 = and i32 %13, %2
  %.not = icmp eq i32 %14, 0
  br i1 %.not, label %22, label %15

15:                                               ; preds = %12
  %16 = icmp slt i32 %2, 0
  %17 = lshr i32 8388608, %5
  %18 = select i1 %16, i32 %17, i32 0
  %.1 = add nsw i32 %18, %2
  %19 = ashr i32 -8388608, %5
  %20 = and i32 %.1, %19
  %21 = bitcast i32 %20 to float
  br label %22

22:                                               ; preds = %12, %15, %9, %1
  %.118 = phi float [ %.0, %9 ], [ %0, %1 ], [ %21, %15 ], [ %0, %12 ]
  ret float %.118
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) 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)"}


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