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

; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

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

; Function Attrs: nounwind uwtable
define dso_local float @iirdes_freqprewarp(i32 noundef %0, float noundef %1, float noundef %2) #2 {
  %4 = alloca i32, align 4
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store float %1, ptr %5, align 4, !tbaa !9
  store float %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store float 0.000000e+00, ptr %7, align 4, !tbaa !9
  %8 = load i32, ptr %4, align 4, !tbaa !5
  %9 = icmp eq i32 %8, 0
  br i1 %9, label %10, label %16

10:                                               ; preds = %3
  %11 = load float, ptr %5, align 4, !tbaa !9
  %12 = fpext float %11 to double
  %13 = fmul double 0x400921FB54442D18, %12
  %14 = fptrunc double %13 to float
  %15 = call float @tanf(float noundef %14) #4
  store float %15, ptr %7, align 4, !tbaa !9
  br label %77

16:                                               ; preds = %3
  %17 = load i32, ptr %4, align 4, !tbaa !5
  %18 = icmp eq i32 %17, 1
  br i1 %18, label %19, label %32

19:                                               ; preds = %16
  %20 = load float, ptr %5, align 4, !tbaa !9
  %21 = fpext float %20 to double
  %22 = fmul double 0x400921FB54442D18, %21
  %23 = fptrunc double %22 to float
  %24 = call float @cosf(float noundef %23) #4
  %25 = fneg float %24
  %26 = load float, ptr %5, align 4, !tbaa !9
  %27 = fpext float %26 to double
  %28 = fmul double 0x400921FB54442D18, %27
  %29 = fptrunc double %28 to float
  %30 = call float @sinf(float noundef %29) #4
  %31 = fdiv float %25, %30
  store float %31, ptr %7, align 4, !tbaa !9
  br label %76

32:                                               ; preds = %16
  %33 = load i32, ptr %4, align 4, !tbaa !5
  %34 = icmp eq i32 %33, 2
  br i1 %34, label %35, label %53

35:                                               ; preds = %32
  %36 = load float, ptr %5, align 4, !tbaa !9
  %37 = fpext float %36 to double
  %38 = fmul double 0x401921FB54442D18, %37
  %39 = fptrunc double %38 to float
  %40 = call float @cosf(float noundef %39) #4
  %41 = load float, ptr %6, align 4, !tbaa !9
  %42 = fpext float %41 to double
  %43 = fmul double 0x401921FB54442D18, %42
  %44 = fptrunc double %43 to float
  %45 = call float @cosf(float noundef %44) #4
  %46 = fsub float %40, %45
  %47 = load float, ptr %5, align 4, !tbaa !9
  %48 = fpext float %47 to double
  %49 = fmul double 0x401921FB54442D18, %48
  %50 = fptrunc double %49 to float
  %51 = call float @sinf(float noundef %50) #4
  %52 = fdiv float %46, %51
  store float %52, ptr %7, align 4, !tbaa !9
  br label %75

53:                                               ; preds = %32
  %54 = load i32, ptr %4, align 4, !tbaa !5
  %55 = icmp eq i32 %54, 3
  br i1 %55, label %56, label %74

56:                                               ; preds = %53
  %57 = load float, ptr %5, align 4, !tbaa !9
  %58 = fpext float %57 to double
  %59 = fmul double 0x401921FB54442D18, %58
  %60 = fptrunc double %59 to float
  %61 = call float @sinf(float noundef %60) #4
  %62 = load float, ptr %5, align 4, !tbaa !9
  %63 = fpext float %62 to double
  %64 = fmul double 0x401921FB54442D18, %63
  %65 = fptrunc double %64 to float
  %66 = call float @cosf(float noundef %65) #4
  %67 = load float, ptr %6, align 4, !tbaa !9
  %68 = fpext float %67 to double
  %69 = fmul double 0x401921FB54442D18, %68
  %70 = fptrunc double %69 to float
  %71 = call float @cosf(float noundef %70) #4
  %72 = fsub float %66, %71
  %73 = fdiv float %61, %72
  store float %73, ptr %7, align 4, !tbaa !9
  br label %74

74:                                               ; preds = %56, %53
  br label %75

75:                                               ; preds = %74, %35
  br label %76

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

77:                                               ; preds = %76, %10
  %78 = load float, ptr %7, align 4, !tbaa !9
  %79 = call float @llvm.fabs.f32(float %78)
  store float %79, ptr %7, align 4, !tbaa !9
  %80 = load float, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  ret float %80
}

; Function Attrs: nounwind
declare float @tanf(float noundef) #3

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

; Function Attrs: nounwind
declare float @sinf(float noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fabs.f32(float) #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(write) uwtable
define dso_local float @iirdes_freqprewarp(i32 noundef %0, float noundef %1, float noundef %2) local_unnamed_addr #1 {
  switch i32 %0, label %41 [
    i32 0, label %4
    i32 1, label %9
    i32 2, label %17
    i32 3, label %29
  ]

4:                                                ; preds = %3
  %5 = fpext float %1 to double
  %6 = fmul double %5, 0x400921FB54442D18
  %7 = fptrunc double %6 to float
  %8 = tail call float @tanf(float noundef %7) #3
  br label %41

9:                                                ; preds = %3
  %10 = fpext float %1 to double
  %11 = fmul double %10, 0x400921FB54442D18
  %12 = fptrunc double %11 to float
  %13 = tail call float @cosf(float noundef %12) #3
  %14 = fneg float %13
  %15 = tail call float @sinf(float noundef %12) #3
  %16 = fdiv float %14, %15
  br label %41

17:                                               ; preds = %3
  %18 = fpext float %1 to double
  %19 = fmul double %18, 0x401921FB54442D18
  %20 = fptrunc double %19 to float
  %21 = tail call float @cosf(float noundef %20) #3
  %22 = fpext float %2 to double
  %23 = fmul double %22, 0x401921FB54442D18
  %24 = fptrunc double %23 to float
  %25 = tail call float @cosf(float noundef %24) #3
  %26 = fsub float %21, %25
  %27 = tail call float @sinf(float noundef %20) #3
  %28 = fdiv float %26, %27
  br label %41

29:                                               ; preds = %3
  %30 = fpext float %1 to double
  %31 = fmul double %30, 0x401921FB54442D18
  %32 = fptrunc double %31 to float
  %33 = tail call float @sinf(float noundef %32) #3
  %34 = tail call float @cosf(float noundef %32) #3
  %35 = fpext float %2 to double
  %36 = fmul double %35, 0x401921FB54442D18
  %37 = fptrunc double %36 to float
  %38 = tail call float @cosf(float noundef %37) #3
  %39 = fsub float %34, %38
  %40 = fdiv float %33, %39
  br label %41

41:                                               ; preds = %3, %9, %29, %17, %4
  %.0 = phi float [ %8, %4 ], [ %16, %9 ], [ %28, %17 ], [ %40, %29 ], [ 0.000000e+00, %3 ]
  %42 = tail call float @llvm.fabs.f32(float %.0)
  ret float %42
}

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

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

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

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


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