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

; 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_Ceil(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 %50

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

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

20:                                               ; preds = %17
  store i32 -2147483648, ptr %3, align 4, !tbaa !9
  br label %27

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

24:                                               ; preds = %21
  store i32 1065353216, ptr %3, align 4, !tbaa !9
  br label %26

25:                                               ; preds = %21
  br label %26

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

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

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

35:                                               ; preds = %28
  %36 = load i32, ptr %3, align 4, !tbaa !9
  %37 = icmp sgt i32 %36, 0
  br i1 %37, label %38, label %43

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

43:                                               ; preds = %38, %35
  %44 = load i32, ptr %6, align 4, !tbaa !9
  %45 = xor i32 %44, -1
  %46 = load i32, ptr %3, align 4, !tbaa !9
  %47 = and i32 %46, %45
  store i32 %47, 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 %48

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

49:                                               ; preds = %48, %27
  br label %50

50:                                               ; preds = %49, %1
  %51 = 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 %51
}

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_Ceil(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 slt i32 %2, 0
  %.not22 = icmp eq i32 %2, 0
  %spec.store.select = select i1 %.not22, i32 0, i32 1065353216
  %11 = bitcast i32 %spec.store.select to float
  %.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 sgt i32 %2, 0
  %17 = lshr i32 8388608, %5
  %18 = select i1 %16, i32 %17, i32 0
  %.1 = add nuw 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