; LLVM IR from jgaeddert/liquid-dsp :: src/utility/src (utility)

; 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: nounwind uwtable
define dso_local i32 @liquid_get_scale(float noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca float, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca float, align 4
  store float %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %8 = load float, ptr %4, align 4, !tbaa !5
  %9 = call float @llvm.fabs.f32(float %8)
  store float %9, ptr %7, align 4, !tbaa !5
  %10 = load float, ptr %7, align 4, !tbaa !5
  %11 = fpext float %10 to double
  %12 = fcmp olt double %11, 1.000000e-09
  br i1 %12, label %13, label %16

13:                                               ; preds = %3
  %14 = load ptr, ptr %6, align 8, !tbaa !9
  store float 0x426D1A94A0000000, ptr %14, align 4, !tbaa !5
  %15 = load ptr, ptr %5, align 8, !tbaa !9
  store i8 112, ptr %15, align 1, !tbaa !11
  br label %83

16:                                               ; preds = %3
  %17 = load float, ptr %7, align 4, !tbaa !5
  %18 = fpext float %17 to double
  %19 = fcmp olt double %18, 0x3EB0C6F7A0B5ED8D
  br i1 %19, label %20, label %23

20:                                               ; preds = %16
  %21 = load ptr, ptr %6, align 8, !tbaa !9
  store float 1.000000e+09, ptr %21, align 4, !tbaa !5
  %22 = load ptr, ptr %5, align 8, !tbaa !9
  store i8 110, ptr %22, align 1, !tbaa !11
  br label %82

23:                                               ; preds = %16
  %24 = load float, ptr %7, align 4, !tbaa !5
  %25 = fpext float %24 to double
  %26 = fcmp olt double %25, 1.000000e-03
  br i1 %26, label %27, label %30

27:                                               ; preds = %23
  %28 = load ptr, ptr %6, align 8, !tbaa !9
  store float 1.000000e+06, ptr %28, align 4, !tbaa !5
  %29 = load ptr, ptr %5, align 8, !tbaa !9
  store i8 117, ptr %29, align 1, !tbaa !11
  br label %81

30:                                               ; preds = %23
  %31 = load float, ptr %7, align 4, !tbaa !5
  %32 = fpext float %31 to double
  %33 = fcmp olt double %32, 1.000000e+00
  br i1 %33, label %34, label %37

34:                                               ; preds = %30
  %35 = load ptr, ptr %6, align 8, !tbaa !9
  store float 1.000000e+03, ptr %35, align 4, !tbaa !5
  %36 = load ptr, ptr %5, align 8, !tbaa !9
  store i8 109, ptr %36, align 1, !tbaa !11
  br label %80

37:                                               ; preds = %30
  %38 = load float, ptr %7, align 4, !tbaa !5
  %39 = fpext float %38 to double
  %40 = fcmp olt double %39, 1.000000e+03
  br i1 %40, label %41, label %44

41:                                               ; preds = %37
  %42 = load ptr, ptr %6, align 8, !tbaa !9
  store float 1.000000e+00, ptr %42, align 4, !tbaa !5
  %43 = load ptr, ptr %5, align 8, !tbaa !9
  store i8 32, ptr %43, align 1, !tbaa !11
  br label %79

44:                                               ; preds = %37
  %45 = load float, ptr %7, align 4, !tbaa !5
  %46 = fpext float %45 to double
  %47 = fcmp olt double %46, 1.000000e+06
  br i1 %47, label %48, label %51

48:                                               ; preds = %44
  %49 = load ptr, ptr %6, align 8, !tbaa !9
  store float 0x3F50624DE0000000, ptr %49, align 4, !tbaa !5
  %50 = load ptr, ptr %5, align 8, !tbaa !9
  store i8 107, ptr %50, align 1, !tbaa !11
  br label %78

51:                                               ; preds = %44
  %52 = load float, ptr %7, align 4, !tbaa !5
  %53 = fpext float %52 to double
  %54 = fcmp olt double %53, 1.000000e+09
  br i1 %54, label %55, label %58

55:                                               ; preds = %51
  %56 = load ptr, ptr %6, align 8, !tbaa !9
  store float 0x3EB0C6F7A0000000, ptr %56, align 4, !tbaa !5
  %57 = load ptr, ptr %5, align 8, !tbaa !9
  store i8 77, ptr %57, align 1, !tbaa !11
  br label %77

58:                                               ; preds = %51
  %59 = load float, ptr %7, align 4, !tbaa !5
  %60 = fpext float %59 to double
  %61 = fcmp olt double %60, 1.000000e+12
  br i1 %61, label %62, label %65

62:                                               ; preds = %58
  %63 = load ptr, ptr %6, align 8, !tbaa !9
  store float 0x3E112E0BE0000000, ptr %63, align 4, !tbaa !5
  %64 = load ptr, ptr %5, align 8, !tbaa !9
  store i8 71, ptr %64, align 1, !tbaa !11
  br label %76

65:                                               ; preds = %58
  %66 = load float, ptr %7, align 4, !tbaa !5
  %67 = fpext float %66 to double
  %68 = fcmp olt double %67, 1.000000e+15
  br i1 %68, label %69, label %72

69:                                               ; preds = %65
  %70 = load ptr, ptr %6, align 8, !tbaa !9
  store float 0x3D71979980000000, ptr %70, align 4, !tbaa !5
  %71 = load ptr, ptr %5, align 8, !tbaa !9
  store i8 84, ptr %71, align 1, !tbaa !11
  br label %75

72:                                               ; preds = %65
  %73 = load ptr, ptr %6, align 8, !tbaa !9
  store float 0x3CD203AFA0000000, ptr %73, align 4, !tbaa !5
  %74 = load ptr, ptr %5, align 8, !tbaa !9
  store i8 80, ptr %74, align 1, !tbaa !11
  br label %75

75:                                               ; preds = %72, %69
  br label %76

76:                                               ; preds = %75, %62
  br label %77

77:                                               ; preds = %76, %55
  br label %78

78:                                               ; preds = %77, %48
  br label %79

79:                                               ; preds = %78, %41
  br label %80

80:                                               ; preds = %79, %34
  br label %81

81:                                               ; preds = %80, %27
  br label %82

82:                                               ; preds = %81, %20
  br label %83

83:                                               ; preds = %82, %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  ret i32 0
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fabs.f32(float) #2

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

attributes #0 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"any pointer", !7, i64 0}
!11 = !{!7, !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(argmem: write) uwtable
define dso_local noundef i32 @liquid_get_scale(float noundef %0, ptr nocapture noundef writeonly %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #0 {
  %4 = tail call float @llvm.fabs.f32(float %0)
  %5 = fpext float %4 to double
  %6 = fcmp olt double %5, 1.000000e-09
  br i1 %6, label %23, label %7

7:                                                ; preds = %3
  %8 = fcmp olt double %5, 0x3EB0C6F7A0B5ED8D
  br i1 %8, label %23, label %9

9:                                                ; preds = %7
  %10 = fcmp olt double %5, 1.000000e-03
  br i1 %10, label %23, label %11

11:                                               ; preds = %9
  %12 = fcmp olt float %4, 1.000000e+00
  br i1 %12, label %23, label %13

13:                                               ; preds = %11
  %14 = fcmp olt float %4, 1.000000e+03
  br i1 %14, label %23, label %15

15:                                               ; preds = %13
  %16 = fcmp olt float %4, 1.000000e+06
  br i1 %16, label %23, label %17

17:                                               ; preds = %15
  %18 = fcmp olt float %4, 1.000000e+09
  br i1 %18, label %23, label %19

19:                                               ; preds = %17
  %20 = fcmp olt double %5, 1.000000e+12
  br i1 %20, label %23, label %21

21:                                               ; preds = %19
  %22 = fcmp olt double %5, 1.000000e+15
  %. = select i1 %22, float 0x3D71979980000000, float 0x3CD203AFA0000000
  %.31 = select i1 %22, i8 84, i8 80
  br label %23

23:                                               ; preds = %21, %19, %17, %15, %13, %11, %9, %7, %3
  %.sink30 = phi float [ 0x426D1A94A0000000, %3 ], [ 1.000000e+09, %7 ], [ 1.000000e+06, %9 ], [ 1.000000e+03, %11 ], [ 1.000000e+00, %13 ], [ 0x3F50624DE0000000, %15 ], [ 0x3EB0C6F7A0000000, %17 ], [ 0x3E112E0BE0000000, %19 ], [ %., %21 ]
  %.sink = phi i8 [ 112, %3 ], [ 110, %7 ], [ 117, %9 ], [ 109, %11 ], [ 32, %13 ], [ 107, %15 ], [ 77, %17 ], [ 71, %19 ], [ %.31, %21 ]
  store float %.sink30, ptr %2, align 4, !tbaa !5
  store i8 %.sink, ptr %1, align 1, !tbaa !9
  ret i32 0
}

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

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

!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 = !{!7, !7, i64 0}


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