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

; 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 @logf(float noundef) #0

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

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

declare float @liquid_lngammaf(float noundef) #2

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

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

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

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

declare float @liquid_gammaf(float noundef) #2

; Function Attrs: nounwind uwtable
define dso_local float @liquid_besseljf(float noundef %0, float noundef %1) #4 {
  %3 = alloca float, align 4
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca i32, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  store float %0, ptr %4, align 4, !tbaa !5
  store float %1, ptr %5, align 4, !tbaa !5
  %14 = load float, ptr %5, align 4, !tbaa !5
  %15 = fcmp oeq float %14, 0.000000e+00
  br i1 %15, label %16, label %21

16:                                               ; preds = %2
  %17 = load float, ptr %4, align 4, !tbaa !5
  %18 = fcmp oeq float %17, 0.000000e+00
  %19 = zext i1 %18 to i64
  %20 = select i1 %18, float 1.000000e+00, float 0.000000e+00
  store float %20, ptr %3, align 4
  br label %96

21:                                               ; preds = %2
  %22 = load float, ptr %5, align 4, !tbaa !5
  %23 = load float, ptr %4, align 4, !tbaa !5
  %24 = fadd float %23, 1.000000e+00
  %25 = call float @sqrtf(float noundef %24) #5
  %26 = fmul float 0x3F50624DE0000000, %25
  %27 = fcmp olt float %22, %26
  br i1 %27, label %28, label %37

28:                                               ; preds = %21
  %29 = load float, ptr %5, align 4, !tbaa !5
  %30 = fmul float 5.000000e-01, %29
  %31 = load float, ptr %4, align 4, !tbaa !5
  %32 = call float @powf(float noundef %30, float noundef %31) #5
  %33 = load float, ptr %4, align 4, !tbaa !5
  %34 = fadd float %33, 1.000000e+00
  %35 = call float @liquid_gammaf(float noundef %34)
  %36 = fdiv float %32, %35
  store float %36, ptr %3, align 4
  br label %96

37:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store float 0.000000e+00, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %38 = load float, ptr %4, align 4, !tbaa !5
  %39 = call float @llvm.fabs.f32(float %38)
  store float %39, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %40

40:                                               ; preds = %91, %37
  %41 = load i32, ptr %8, align 4, !tbaa !9
  %42 = icmp ult i32 %41, 128
  br i1 %42, label %43, label %94

43:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %44 = load i32, ptr %8, align 4, !tbaa !9
  %45 = uitofp i32 %44 to float
  %46 = load float, ptr %7, align 4, !tbaa !5
  %47 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %45, float %46)
  store float %47, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %48 = load float, ptr %9, align 4, !tbaa !5
  %49 = load float, ptr %5, align 4, !tbaa !5
  %50 = call float @logf(float noundef %49) #5
  %51 = fmul float %48, %50
  store float %51, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %52 = load float, ptr %9, align 4, !tbaa !5
  %53 = call float @logf(float noundef 2.000000e+00) #5
  %54 = fmul float %52, %53
  store float %54, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %55 = load i32, ptr %8, align 4, !tbaa !9
  %56 = uitofp i32 %55 to float
  %57 = fadd float %56, 1.000000e+00
  %58 = call float @liquid_lngammaf(float noundef %57)
  store float %58, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %59 = load float, ptr %7, align 4, !tbaa !5
  %60 = load i32, ptr %8, align 4, !tbaa !9
  %61 = uitofp i32 %60 to float
  %62 = fadd float %59, %61
  %63 = fadd float %62, 1.000000e+00
  %64 = call float @liquid_lngammaf(float noundef %63)
  store float %64, ptr %13, align 4, !tbaa !5
  %65 = load i32, ptr %8, align 4, !tbaa !9
  %66 = urem i32 %65, 2
  %67 = icmp eq i32 %66, 0
  br i1 %67, label %68, label %79

68:                                               ; preds = %43
  %69 = load float, ptr %10, align 4, !tbaa !5
  %70 = load float, ptr %11, align 4, !tbaa !5
  %71 = fsub float %69, %70
  %72 = load float, ptr %12, align 4, !tbaa !5
  %73 = fsub float %71, %72
  %74 = load float, ptr %13, align 4, !tbaa !5
  %75 = fsub float %73, %74
  %76 = call float @expf(float noundef %75) #5, !tbaa !9
  %77 = load float, ptr %6, align 4, !tbaa !5
  %78 = fadd float %77, %76
  store float %78, ptr %6, align 4, !tbaa !5
  br label %90

79:                                               ; preds = %43
  %80 = load float, ptr %10, align 4, !tbaa !5
  %81 = load float, ptr %11, align 4, !tbaa !5
  %82 = fsub float %80, %81
  %83 = load float, ptr %12, align 4, !tbaa !5
  %84 = fsub float %82, %83
  %85 = load float, ptr %13, align 4, !tbaa !5
  %86 = fsub float %84, %85
  %87 = call float @expf(float noundef %86) #5, !tbaa !9
  %88 = load float, ptr %6, align 4, !tbaa !5
  %89 = fsub float %88, %87
  store float %89, ptr %6, align 4, !tbaa !5
  br label %90

90:                                               ; preds = %79, %68
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %91

91:                                               ; preds = %90
  %92 = load i32, ptr %8, align 4, !tbaa !9
  %93 = add i32 %92, 1
  store i32 %93, ptr %8, align 4, !tbaa !9
  br label %40, !llvm.loop !11

94:                                               ; preds = %40
  %95 = load float, ptr %6, align 4, !tbaa !5
  store float %95, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %96

96:                                               ; preds = %94, %28, %16
  %97 = load float, ptr %3, align 4
  ret float %97
}

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

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 speculatable willreturn memory(none) }
attributes #2 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { 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 @logf(float noundef) local_unnamed_addr #0

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

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

declare float @liquid_lngammaf(float noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @expf(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

declare float @liquid_gammaf(float noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local float @liquid_besseljf(float noundef %0, float noundef %1) local_unnamed_addr #3 {
  %3 = fcmp oeq float %1, 0.000000e+00
  br i1 %3, label %4, label %7

4:                                                ; preds = %2
  %5 = fcmp oeq float %0, 0.000000e+00
  %6 = select i1 %5, float 1.000000e+00, float 0.000000e+00
  br label %.loopexit

7:                                                ; preds = %2
  %8 = fadd float %0, 1.000000e+00
  %9 = tail call float @sqrtf(float noundef %8) #4
  %10 = fmul float %9, 0x3F50624DE0000000
  %11 = fcmp ogt float %10, %1
  br i1 %11, label %12, label %17

12:                                               ; preds = %7
  %13 = fmul float %1, 5.000000e-01
  %14 = tail call float @powf(float noundef %13, float noundef %0) #4
  %15 = tail call float @liquid_gammaf(float noundef %8) #4
  %16 = fdiv float %14, %15
  br label %.loopexit

17:                                               ; preds = %7
  %18 = tail call float @llvm.fabs.f32(float %0)
  br label %19

19:                                               ; preds = %17, %19
  %.03034 = phi float [ 0.000000e+00, %17 ], [ %.1, %19 ]
  %.03133 = phi i32 [ 0, %17 ], [ %37, %19 ]
  %20 = uitofp nneg i32 %.03133 to float
  %21 = tail call float @llvm.fmuladd.f32(float %20, float 2.000000e+00, float %18)
  %22 = tail call float @logf(float noundef %1) #4
  %23 = fmul float %21, %22
  %24 = fmul float %21, 0x3FE62E4300000000
  %25 = fadd float %20, 1.000000e+00
  %26 = tail call float @liquid_lngammaf(float noundef %25) #4
  %27 = fadd float %18, %20
  %28 = fadd float %27, 1.000000e+00
  %29 = tail call float @liquid_lngammaf(float noundef %28) #4
  %30 = and i32 %.03133, 1
  %31 = icmp eq i32 %30, 0
  %32 = fsub float %23, %24
  %33 = fsub float %32, %26
  %34 = fsub float %33, %29
  %35 = tail call float @expf(float noundef %34) #4, !tbaa !5
  %36 = fneg float %35
  %.1.p = select i1 %31, float %35, float %36
  %.1 = fadd float %.03034, %.1.p
  %37 = add nuw nsw i32 %.03133, 1
  %exitcond.not = icmp eq i32 %37, 128
  br i1 %exitcond.not, label %.loopexit, label %19, !llvm.loop !9

.loopexit:                                        ; preds = %19, %12, %4
  %.0 = phi float [ %6, %4 ], [ %16, %12 ], [ %.1, %19 ]
  ret float %.0
}

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

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 = { "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 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass