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

; 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 float @liquid_lnbesselif(float noundef %0, float noundef %1) #0 {
  %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 float, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca i32, align 4
  store float %0, ptr %4, align 4, !tbaa !5
  store float %1, ptr %5, align 4, !tbaa !5
  %12 = load float, ptr %5, align 4, !tbaa !5
  %13 = fcmp oeq float %12, 0.000000e+00
  br i1 %13, label %14, label %19

14:                                               ; preds = %2
  %15 = load float, ptr %4, align 4, !tbaa !5
  %16 = fcmp oeq float %15, 0.000000e+00
  %17 = zext i1 %16 to i64
  %18 = select i1 %16, float 0.000000e+00, float 0xC7EFFFFFE0000000
  store float %18, ptr %3, align 4
  br label %93

19:                                               ; preds = %2
  %20 = load float, ptr %4, align 4, !tbaa !5
  %21 = fcmp oeq float %20, 5.000000e-01
  br i1 %21, label %22, label %33

22:                                               ; preds = %19
  %23 = load float, ptr %5, align 4, !tbaa !5
  %24 = fpext float %23 to double
  %25 = fmul double 0x400921FB54442D18, %24
  %26 = fdiv double 2.000000e+00, %25
  %27 = fptrunc double %26 to float
  %28 = call float @logf(float noundef %27) #5
  %29 = load float, ptr %5, align 4, !tbaa !5
  %30 = call float @sinhf(float noundef %29) #5
  %31 = call float @logf(float noundef %30) #5
  %32 = call float @llvm.fmuladd.f32(float 5.000000e-01, float %28, float %31)
  store float %32, ptr %3, align 4
  br label %93

33:                                               ; preds = %19
  %34 = load float, ptr %5, align 4, !tbaa !5
  %35 = load float, ptr %4, align 4, !tbaa !5
  %36 = fadd float %35, 1.000000e+00
  %37 = call float @sqrtf(float noundef %36) #5
  %38 = fmul float 0x3F50624DE0000000, %37
  %39 = fcmp olt float %34, %38
  br i1 %39, label %40, label %50

40:                                               ; preds = %33
  %41 = load float, ptr %4, align 4, !tbaa !5
  %42 = fadd float %41, 1.000000e+00
  %43 = call float @liquid_lngammaf(float noundef %42)
  %44 = fneg float %43
  %45 = load float, ptr %4, align 4, !tbaa !5
  %46 = load float, ptr %5, align 4, !tbaa !5
  %47 = fmul float 5.000000e-01, %46
  %48 = call float @logf(float noundef %47) #5
  %49 = call float @llvm.fmuladd.f32(float %45, float %48, float %44)
  store float %49, ptr %3, align 4
  br label %93

50:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %51 = load float, ptr %4, align 4, !tbaa !5
  %52 = load float, ptr %5, align 4, !tbaa !5
  %53 = fmul float 5.000000e-01, %52
  %54 = call float @logf(float noundef %53) #5
  %55 = fmul float %51, %54
  store float %55, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store float 0.000000e+00, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store float 0.000000e+00, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store float 0.000000e+00, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store float 0.000000e+00, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %56

56:                                               ; preds = %85, %50
  %57 = load i32, ptr %11, align 4, !tbaa !9
  %58 = icmp ult i32 %57, 64
  br i1 %58, label %59, label %88

59:                                               ; preds = %56
  %60 = load i32, ptr %11, align 4, !tbaa !9
  %61 = uitofp i32 %60 to float
  %62 = fmul float 2.000000e+00, %61
  %63 = load float, ptr %5, align 4, !tbaa !5
  %64 = fmul float 5.000000e-01, %63
  %65 = call float @logf(float noundef %64) #5
  %66 = fmul float %62, %65
  store float %66, ptr %7, align 4, !tbaa !5
  %67 = load i32, ptr %11, align 4, !tbaa !9
  %68 = uitofp i32 %67 to float
  %69 = fadd float %68, 1.000000e+00
  %70 = call float @liquid_lngammaf(float noundef %69)
  store float %70, ptr %8, align 4, !tbaa !5
  %71 = load float, ptr %4, align 4, !tbaa !5
  %72 = load i32, ptr %11, align 4, !tbaa !9
  %73 = uitofp i32 %72 to float
  %74 = fadd float %71, %73
  %75 = fadd float %74, 1.000000e+00
  %76 = call float @liquid_lngammaf(float noundef %75)
  store float %76, ptr %9, align 4, !tbaa !5
  %77 = load float, ptr %7, align 4, !tbaa !5
  %78 = load float, ptr %8, align 4, !tbaa !5
  %79 = fsub float %77, %78
  %80 = load float, ptr %9, align 4, !tbaa !5
  %81 = fsub float %79, %80
  %82 = call float @expf(float noundef %81) #5, !tbaa !9
  %83 = load float, ptr %10, align 4, !tbaa !5
  %84 = fadd float %83, %82
  store float %84, ptr %10, align 4, !tbaa !5
  br label %85

85:                                               ; preds = %59
  %86 = load i32, ptr %11, align 4, !tbaa !9
  %87 = add i32 %86, 1
  store i32 %87, ptr %11, align 4, !tbaa !9
  br label %56, !llvm.loop !11

88:                                               ; preds = %56
  %89 = load float, ptr %6, align 4, !tbaa !5
  %90 = load float, ptr %10, align 4, !tbaa !5
  %91 = call float @logf(float noundef %90) #5
  %92 = fadd float %89, %91
  store float %92, ptr %3, align 4
  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
  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 %93

93:                                               ; preds = %88, %40, %22, %14
  %94 = load float, ptr %3, align 4
  ret float %94
}

; Function Attrs: nounwind
declare float @logf(float noundef) #1

; Function Attrs: nounwind
declare float @sinhf(float noundef) #1

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

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

declare float @liquid_lngammaf(float noundef) #3

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

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

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

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 = { 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 #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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: nounwind uwtable
define dso_local float @liquid_lnbesselif(float noundef %0, float noundef %1) local_unnamed_addr #0 {
  %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 0.000000e+00, float 0xC7EFFFFFE0000000
  br label %51

7:                                                ; preds = %2
  %8 = fcmp oeq float %0, 5.000000e-01
  br i1 %8, label %9, label %18

9:                                                ; preds = %7
  %10 = fpext float %1 to double
  %11 = fmul double %10, 0x400921FB54442D18
  %12 = fdiv double 2.000000e+00, %11
  %13 = fptrunc double %12 to float
  %14 = tail call float @logf(float noundef %13) #4
  %15 = tail call float @sinhf(float noundef %1) #4
  %16 = tail call float @logf(float noundef %15) #4
  %17 = tail call float @llvm.fmuladd.f32(float %14, float 5.000000e-01, float %16)
  br label %51

18:                                               ; preds = %7
  %19 = fadd float %0, 1.000000e+00
  %20 = tail call float @sqrtf(float noundef %19) #4
  %21 = fmul float %20, 0x3F50624DE0000000
  %22 = fcmp ogt float %21, %1
  br i1 %22, label %23, label %29

23:                                               ; preds = %18
  %24 = tail call float @liquid_lngammaf(float noundef %19) #4
  %25 = fneg float %24
  %26 = fmul float %1, 5.000000e-01
  %27 = tail call float @logf(float noundef %26) #4
  %28 = tail call float @llvm.fmuladd.f32(float %0, float %27, float %25)
  br label %51

29:                                               ; preds = %18
  %30 = fmul float %1, 5.000000e-01
  %31 = tail call float @logf(float noundef %30) #4
  br label %32

32:                                               ; preds = %29, %32
  %.030 = phi i32 [ 0, %29 ], [ %46, %32 ]
  %.02529 = phi float [ 0.000000e+00, %29 ], [ %45, %32 ]
  %33 = uitofp nneg i32 %.030 to float
  %34 = fmul float %33, 2.000000e+00
  %35 = tail call float @logf(float noundef %30) #4
  %36 = fmul float %34, %35
  %37 = fadd float %33, 1.000000e+00
  %38 = tail call float @liquid_lngammaf(float noundef %37) #4
  %39 = fadd float %33, %0
  %40 = fadd float %39, 1.000000e+00
  %41 = tail call float @liquid_lngammaf(float noundef %40) #4
  %42 = fsub float %36, %38
  %43 = fsub float %42, %41
  %44 = tail call float @expf(float noundef %43) #4, !tbaa !5
  %45 = fadd float %.02529, %44
  %46 = add nuw nsw i32 %.030, 1
  %exitcond.not = icmp eq i32 %46, 64
  br i1 %exitcond.not, label %47, label %32, !llvm.loop !9

47:                                               ; preds = %32
  %48 = fmul float %31, %0
  %49 = tail call float @logf(float noundef %45) #4
  %50 = fadd float %48, %49
  br label %51

51:                                               ; preds = %47, %23, %9, %4
  %.026 = phi float [ %6, %4 ], [ %17, %9 ], [ %28, %23 ], [ %50, %47 ]
  ret float %.026
}

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

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

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

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

declare float @liquid_lngammaf(float noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @expf(float noundef) local_unnamed_addr #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 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { "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,LCSSAPass,LoopRotatePass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass