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

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

%union.anon = type { [2 x i32] }

@s_values = external hidden constant %union.anon, align 4

; 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

; Function Attrs: nounwind uwtable
declare dso_local float @qFFMath_Floor(float noundef) #3

; Function Attrs: nounwind uwtable
define dso_local float @qFFMath_Exp2(float noundef %0) #3 {
  %2 = alloca float, align 4
  %3 = alloca float, align 4
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca i32, align 4
  store float %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  %8 = load float, ptr %2, align 4, !tbaa !5
  %9 = fcmp ole float %8, -1.260000e+02
  br i1 %9, label %10, label %11

10:                                               ; preds = %1
  store float 0.000000e+00, ptr %3, align 4, !tbaa !5
  br label %49

11:                                               ; preds = %1
  %12 = load float, ptr %2, align 4, !tbaa !5
  %13 = fcmp ogt float %12, 1.280000e+02
  br i1 %13, label %14, label %16

14:                                               ; preds = %11
  %15 = load float, ptr @s_values, align 4, !tbaa !5
  store float %15, ptr %3, align 4, !tbaa !5
  br label %48

16:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store float 0.000000e+00, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %17 = load float, ptr %2, align 4, !tbaa !5
  %18 = fadd float %17, 5.000000e-01
  %19 = call float @qFFMath_Floor(float noundef %18)
  store float %19, ptr %4, align 4, !tbaa !5
  %20 = load float, ptr %2, align 4, !tbaa !5
  %21 = load float, ptr %4, align 4, !tbaa !5
  %22 = fsub float %20, %21
  store float %22, ptr %5, align 4, !tbaa !5
  %23 = load float, ptr %4, align 4, !tbaa !5
  %24 = fptosi float %23 to i32
  %25 = add nsw i32 %24, 127
  %26 = shl i32 %25, 23
  store i32 %26, ptr %7, align 4, !tbaa !9
  store float 0x3F241FBBC0000000, ptr %2, align 4, !tbaa !5
  %27 = load float, ptr %2, align 4, !tbaa !5
  %28 = load float, ptr %5, align 4, !tbaa !5
  %29 = call float @llvm.fmuladd.f32(float %27, float %28, float 0x3F55F3E520000000)
  store float %29, ptr %2, align 4, !tbaa !5
  %30 = load float, ptr %2, align 4, !tbaa !5
  %31 = load float, ptr %5, align 4, !tbaa !5
  %32 = call float @llvm.fmuladd.f32(float %30, float %31, float 0x3F83B2D4C0000000)
  store float %32, ptr %2, align 4, !tbaa !5
  %33 = load float, ptr %2, align 4, !tbaa !5
  %34 = load float, ptr %5, align 4, !tbaa !5
  %35 = call float @llvm.fmuladd.f32(float %33, float %34, float 0x3FAC6AEE80000000)
  store float %35, ptr %2, align 4, !tbaa !5
  %36 = load float, ptr %2, align 4, !tbaa !5
  %37 = load float, ptr %5, align 4, !tbaa !5
  %38 = call float @llvm.fmuladd.f32(float %36, float %37, float 0x3FCEBFBDC0000000)
  store float %38, ptr %2, align 4, !tbaa !5
  %39 = load float, ptr %2, align 4, !tbaa !5
  %40 = load float, ptr %5, align 4, !tbaa !5
  %41 = call float @llvm.fmuladd.f32(float %39, float %40, float 0x3FE62E4300000000)
  store float %41, ptr %2, align 4, !tbaa !5
  %42 = load float, ptr %2, align 4, !tbaa !5
  %43 = load float, ptr %5, align 4, !tbaa !5
  %44 = call float @llvm.fmuladd.f32(float %42, float %43, float 1.000000e+00)
  store float %44, ptr %2, align 4, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %6, ptr align 4 %7, i64 4, i1 false)
  %45 = load float, ptr %6, align 4, !tbaa !5
  %46 = load float, ptr %2, align 4, !tbaa !5
  %47 = fmul float %45, %46
  store float %47, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %48

48:                                               ; preds = %16, %14
  br label %49

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 = { 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"

%union.anon = type { [2 x i32] }

@s_values = external hidden local_unnamed_addr constant %union.anon, align 4

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #0

; Function Attrs: nounwind uwtable
declare dso_local float @qFFMath_Floor(float noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local float @qFFMath_Exp2(float noundef %0) local_unnamed_addr #1 {
  %2 = fcmp ugt float %0, -1.260000e+02
  br i1 %2, label %3, label %22

3:                                                ; preds = %1
  %4 = fcmp ogt float %0, 1.280000e+02
  br i1 %4, label %5, label %7

5:                                                ; preds = %3
  %6 = load float, ptr @s_values, align 4, !tbaa !5
  br label %22

7:                                                ; preds = %3
  %8 = fadd float %0, 5.000000e-01
  %9 = tail call float @qFFMath_Floor(float noundef %8)
  %10 = fsub float %0, %9
  %11 = fptosi float %9 to i32
  %12 = shl i32 %11, 23
  %13 = add i32 %12, 1065353216
  %14 = tail call float @llvm.fmuladd.f32(float %10, float 0x3F241FBBC0000000, float 0x3F55F3E520000000)
  %15 = tail call float @llvm.fmuladd.f32(float %14, float %10, float 0x3F83B2D4C0000000)
  %16 = tail call float @llvm.fmuladd.f32(float %15, float %10, float 0x3FAC6AEE80000000)
  %17 = tail call float @llvm.fmuladd.f32(float %16, float %10, float 0x3FCEBFBDC0000000)
  %18 = tail call float @llvm.fmuladd.f32(float %17, float %10, float 0x3FE62E4300000000)
  %19 = tail call float @llvm.fmuladd.f32(float %18, float %10, float 1.000000e+00)
  %20 = bitcast i32 %13 to float
  %21 = fmul float %19, %20
  br label %22

22:                                               ; preds = %1, %5, %7
  %.0 = phi float [ %6, %5 ], [ %21, %7 ], [ 0.000000e+00, %1 ]
  ret float %.0
}

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

!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"}


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