; LLVM IR from jgaeddert/liquid-dsp :: src/math/src/math.bessel (liquid_besselj0f)

; 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
declare float @sqrtf(float noundef) #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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind
declare float @powf(float noundef, float noundef) #0

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

; Function Attrs: nounwind uwtable
define dso_local float @liquid_besselj0f(float noundef %0) #3 {
  %2 = alloca float, align 4
  %3 = alloca float, align 4
  %4 = alloca i32, align 4
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  store float %0, ptr %3, align 4, !tbaa !5
  %7 = load float, ptr %3, align 4, !tbaa !5
  %8 = call float @llvm.fabs.f32(float %7)
  %9 = fcmp ogt float %8, 1.000000e+01
  br i1 %9, label %10, label %25

10:                                               ; preds = %1
  %11 = load float, ptr %3, align 4, !tbaa !5
  %12 = call float @llvm.fabs.f32(float %11)
  %13 = fpext float %12 to double
  %14 = fmul double 0x400921FB54442D18, %13
  %15 = fdiv double 2.000000e+00, %14
  %16 = fptrunc double %15 to float
  %17 = call float @sqrtf(float noundef %16) #4
  %18 = load float, ptr %3, align 4, !tbaa !5
  %19 = call float @llvm.fabs.f32(float %18)
  %20 = fpext float %19 to double
  %21 = fsub double %20, 0x3FE921FB54442D18
  %22 = fptrunc double %21 to float
  %23 = call float @cosf(float noundef %22) #4
  %24 = fmul float %17, %23
  store float %24, ptr %2, align 4
  br label %64

25:                                               ; preds = %1
  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
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %26

26:                                               ; preds = %59, %25
  %27 = load i32, ptr %4, align 4, !tbaa !9
  %28 = icmp ult i32 %27, 16
  br i1 %28, label %29, label %62

29:                                               ; preds = %26
  %30 = load float, ptr %3, align 4, !tbaa !5
  %31 = fdiv float %30, 2.000000e+00
  %32 = load i32, ptr %4, align 4, !tbaa !9
  %33 = uitofp i32 %32 to float
  %34 = call float @powf(float noundef %31, float noundef %33) #4
  %35 = fpext float %34 to double
  %36 = load i32, ptr %4, align 4, !tbaa !9
  %37 = uitofp i32 %36 to float
  %38 = fadd float %37, 1.000000e+00
  %39 = fpext float %38 to double
  %40 = call double @tgamma(double noundef %39) #4
  %41 = fdiv double %35, %40
  %42 = fptrunc double %41 to float
  store float %42, ptr %5, align 4, !tbaa !5
  %43 = load i32, ptr %4, align 4, !tbaa !9
  %44 = urem i32 %43, 2
  %45 = icmp ne i32 %44, 0
  br i1 %45, label %46, label %51

46:                                               ; preds = %29
  %47 = load float, ptr %5, align 4, !tbaa !5
  %48 = fneg float %47
  %49 = load float, ptr %5, align 4, !tbaa !5
  %50 = fmul float %48, %49
  br label %55

51:                                               ; preds = %29
  %52 = load float, ptr %5, align 4, !tbaa !5
  %53 = load float, ptr %5, align 4, !tbaa !5
  %54 = fmul float %52, %53
  br label %55

55:                                               ; preds = %51, %46
  %56 = phi float [ %50, %46 ], [ %54, %51 ]
  %57 = load float, ptr %6, align 4, !tbaa !5
  %58 = fadd float %57, %56
  store float %58, ptr %6, align 4, !tbaa !5
  br label %59

59:                                               ; preds = %55
  %60 = load i32, ptr %4, align 4, !tbaa !9
  %61 = add i32 %60, 1
  store i32 %61, ptr %4, align 4, !tbaa !9
  br label %26, !llvm.loop !11

62:                                               ; preds = %26
  %63 = load float, ptr %6, align 4, !tbaa !5
  store float %63, ptr %2, align 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 %64

64:                                               ; preds = %62, %10
  %65 = load float, ptr %2, align 4
  ret float %65
}

; Function Attrs: nounwind
declare float @cosf(float noundef) #0

; Function Attrs: nounwind
declare double @tgamma(double noundef) #0

attributes #0 = { 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 #1 = { nocallback nofree nosync 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}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; 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 nounwind willreturn memory(write)
declare float @sqrtf(float noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @powf(float noundef, float noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local float @liquid_besselj0f(float noundef %0) local_unnamed_addr #2 {
  %2 = tail call float @llvm.fabs.f32(float %0)
  %3 = fcmp ogt float %2, 1.000000e+01
  br i1 %3, label %124, label %.preheader

.preheader:                                       ; preds = %1
  %4 = fmul float %0, 5.000000e-01
  %5 = tail call double @tgamma(double noundef 1.000000e+00) #4
  %6 = fdiv double 1.000000e+00, %5
  %7 = fptrunc double %6 to float
  %8 = fmul float %7, %7
  %9 = fpext float %4 to double
  %10 = tail call double @tgamma(double noundef 2.000000e+00) #4
  %11 = fdiv double %9, %10
  %12 = fptrunc double %11 to float
  %13 = fmul float %12, %12
  %14 = fsub float %8, %13
  %square = fmul float %4, %4
  %15 = fpext float %square to double
  %16 = tail call double @tgamma(double noundef 3.000000e+00) #4
  %17 = fdiv double %15, %16
  %18 = fptrunc double %17 to float
  %19 = fmul float %18, %18
  %20 = fadd float %14, %19
  %21 = tail call float @powf(float noundef %4, float noundef 3.000000e+00) #4
  %22 = fpext float %21 to double
  %23 = tail call double @tgamma(double noundef 4.000000e+00) #4
  %24 = fdiv double %22, %23
  %25 = fptrunc double %24 to float
  %26 = fmul float %25, %25
  %27 = fsub float %20, %26
  %28 = tail call float @powf(float noundef %4, float noundef 4.000000e+00) #4
  %29 = tail call double @tgamma(double noundef 5.000000e+00) #4
  %30 = tail call float @powf(float noundef %4, float noundef 5.000000e+00) #4
  %31 = tail call double @tgamma(double noundef 6.000000e+00) #4
  %32 = insertelement <2 x float> poison, float %28, i64 0
  %33 = insertelement <2 x float> %32, float %30, i64 1
  %34 = fpext <2 x float> %33 to <2 x double>
  %35 = insertelement <2 x double> poison, double %29, i64 0
  %36 = insertelement <2 x double> %35, double %31, i64 1
  %37 = fdiv <2 x double> %34, %36
  %38 = fptrunc <2 x double> %37 to <2 x float>
  %39 = fmul <2 x float> %38, %38
  %40 = extractelement <2 x float> %39, i64 0
  %41 = fadd float %27, %40
  %42 = extractelement <2 x float> %39, i64 1
  %43 = fsub float %41, %42
  %44 = tail call float @powf(float noundef %4, float noundef 6.000000e+00) #4
  %45 = tail call double @tgamma(double noundef 7.000000e+00) #4
  %46 = tail call float @powf(float noundef %4, float noundef 7.000000e+00) #4
  %47 = tail call double @tgamma(double noundef 8.000000e+00) #4
  %48 = insertelement <2 x float> poison, float %44, i64 0
  %49 = insertelement <2 x float> %48, float %46, i64 1
  %50 = fpext <2 x float> %49 to <2 x double>
  %51 = insertelement <2 x double> poison, double %45, i64 0
  %52 = insertelement <2 x double> %51, double %47, i64 1
  %53 = fdiv <2 x double> %50, %52
  %54 = fptrunc <2 x double> %53 to <2 x float>
  %55 = fmul <2 x float> %54, %54
  %56 = extractelement <2 x float> %55, i64 0
  %57 = fadd float %43, %56
  %58 = extractelement <2 x float> %55, i64 1
  %59 = fsub float %57, %58
  %60 = tail call float @powf(float noundef %4, float noundef 8.000000e+00) #4
  %61 = tail call double @tgamma(double noundef 9.000000e+00) #4
  %62 = tail call float @powf(float noundef %4, float noundef 9.000000e+00) #4
  %63 = tail call double @tgamma(double noundef 1.000000e+01) #4
  %64 = insertelement <2 x float> poison, float %60, i64 0
  %65 = insertelement <2 x float> %64, float %62, i64 1
  %66 = fpext <2 x float> %65 to <2 x double>
  %67 = insertelement <2 x double> poison, double %61, i64 0
  %68 = insertelement <2 x double> %67, double %63, i64 1
  %69 = fdiv <2 x double> %66, %68
  %70 = fptrunc <2 x double> %69 to <2 x float>
  %71 = fmul <2 x float> %70, %70
  %72 = extractelement <2 x float> %71, i64 0
  %73 = fadd float %59, %72
  %74 = extractelement <2 x float> %71, i64 1
  %75 = fsub float %73, %74
  %76 = tail call float @powf(float noundef %4, float noundef 1.000000e+01) #4
  %77 = tail call double @tgamma(double noundef 1.100000e+01) #4
  %78 = tail call float @powf(float noundef %4, float noundef 1.100000e+01) #4
  %79 = tail call double @tgamma(double noundef 1.200000e+01) #4
  %80 = insertelement <2 x float> poison, float %76, i64 0
  %81 = insertelement <2 x float> %80, float %78, i64 1
  %82 = fpext <2 x float> %81 to <2 x double>
  %83 = insertelement <2 x double> poison, double %77, i64 0
  %84 = insertelement <2 x double> %83, double %79, i64 1
  %85 = fdiv <2 x double> %82, %84
  %86 = fptrunc <2 x double> %85 to <2 x float>
  %87 = fmul <2 x float> %86, %86
  %88 = extractelement <2 x float> %87, i64 0
  %89 = fadd float %75, %88
  %90 = extractelement <2 x float> %87, i64 1
  %91 = fsub float %89, %90
  %92 = tail call float @powf(float noundef %4, float noundef 1.200000e+01) #4
  %93 = tail call double @tgamma(double noundef 1.300000e+01) #4
  %94 = tail call float @powf(float noundef %4, float noundef 1.300000e+01) #4
  %95 = tail call double @tgamma(double noundef 1.400000e+01) #4
  %96 = insertelement <2 x float> poison, float %92, i64 0
  %97 = insertelement <2 x float> %96, float %94, i64 1
  %98 = fpext <2 x float> %97 to <2 x double>
  %99 = insertelement <2 x double> poison, double %93, i64 0
  %100 = insertelement <2 x double> %99, double %95, i64 1
  %101 = fdiv <2 x double> %98, %100
  %102 = fptrunc <2 x double> %101 to <2 x float>
  %103 = fmul <2 x float> %102, %102
  %104 = extractelement <2 x float> %103, i64 0
  %105 = fadd float %91, %104
  %106 = extractelement <2 x float> %103, i64 1
  %107 = fsub float %105, %106
  %108 = tail call float @powf(float noundef %4, float noundef 1.400000e+01) #4
  %109 = tail call double @tgamma(double noundef 1.500000e+01) #4
  %110 = tail call float @powf(float noundef %4, float noundef 1.500000e+01) #4
  %111 = tail call double @tgamma(double noundef 1.600000e+01) #4
  %112 = insertelement <2 x float> poison, float %108, i64 0
  %113 = insertelement <2 x float> %112, float %110, i64 1
  %114 = fpext <2 x float> %113 to <2 x double>
  %115 = insertelement <2 x double> poison, double %109, i64 0
  %116 = insertelement <2 x double> %115, double %111, i64 1
  %117 = fdiv <2 x double> %114, %116
  %118 = fptrunc <2 x double> %117 to <2 x float>
  %119 = fmul <2 x float> %118, %118
  %120 = extractelement <2 x float> %119, i64 0
  %121 = fadd float %107, %120
  %122 = extractelement <2 x float> %119, i64 1
  %123 = fsub float %121, %122
  br label %.loopexit

124:                                              ; preds = %1
  %125 = fpext float %2 to double
  %126 = fmul double %125, 0x400921FB54442D18
  %127 = fdiv double 2.000000e+00, %126
  %128 = fptrunc double %127 to float
  %129 = tail call float @sqrtf(float noundef %128) #4
  %130 = fadd double %125, 0xBFE921FB54442D18
  %131 = fptrunc double %130 to float
  %132 = tail call float @cosf(float noundef %131) #4
  %133 = fmul float %129, %132
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader, %124
  %.015 = phi float [ %133, %124 ], [ %123, %.preheader ]
  ret float %.015
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @cosf(float noundef) local_unnamed_addr #0

; Function Attrs: nounwind
declare double @tgamma(double noundef) local_unnamed_addr #3

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass