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

; 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"

@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.48 = external hidden unnamed_addr constant [87 x i8], align 1
@.str.59 = external hidden unnamed_addr constant [67 x i8], align 1

declare ptr @liquid_error_config_fl(ptr noundef, i32 noundef, ptr 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: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #2

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #2

; Function Attrs: nounwind uwtable
declare dso_local ptr @firinterp_crcf_create(i32 noundef, ptr noundef, i32 noundef) #3

; Function Attrs: nounwind uwtable
define dso_local ptr @firinterp_crcf_create_window(i32 noundef %0, i32 noundef %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  %9 = load i32, ptr %4, align 4, !tbaa !5
  %10 = icmp ult i32 %9, 1
  br i1 %10, label %11, label %13

11:                                               ; preds = %2
  %12 = call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef @.str.48, i32 noundef 172, ptr noundef @.str.59, ptr noundef @.str.2)
  store ptr %12, ptr %3, align 8
  br label %62

13:                                               ; preds = %2
  %14 = load i32, ptr %5, align 4, !tbaa !5
  %15 = icmp ult i32 %14, 1
  br i1 %15, label %16, label %18

16:                                               ; preds = %13
  %17 = call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef @.str.48, i32 noundef 174, ptr noundef @.str.59, ptr noundef @.str.2)
  store ptr %17, ptr %3, align 8
  br label %62

18:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %19 = load i32, ptr %5, align 4, !tbaa !5
  %20 = mul i32 2, %19
  %21 = load i32, ptr %4, align 4, !tbaa !5
  %22 = mul i32 %20, %21
  %23 = zext i32 %22 to i64
  %24 = call ptr @llvm.stacksave.p0()
  store ptr %24, ptr %7, align 8
  %25 = alloca float, i64 %23, align 16
  store i64 %23, ptr %8, align 8
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %51, %18
  %27 = load i32, ptr %6, align 4, !tbaa !5
  %28 = load i32, ptr %5, align 4, !tbaa !5
  %29 = mul i32 2, %28
  %30 = load i32, ptr %4, align 4, !tbaa !5
  %31 = mul i32 %29, %30
  %32 = icmp ult i32 %27, %31
  br i1 %32, label %33, label %54

33:                                               ; preds = %26
  %34 = load i32, ptr %6, align 4, !tbaa !5
  %35 = uitofp i32 %34 to float
  %36 = fpext float %35 to double
  %37 = fmul double 0x400921FB54442D18, %36
  %38 = load i32, ptr %5, align 4, !tbaa !5
  %39 = mul i32 2, %38
  %40 = load i32, ptr %4, align 4, !tbaa !5
  %41 = mul i32 %39, %40
  %42 = uitofp i32 %41 to float
  %43 = fpext float %42 to double
  %44 = fdiv double %37, %43
  %45 = fptrunc double %44 to float
  %46 = call float @sinf(float noundef %45) #5
  %47 = call float @powf(float noundef %46, float noundef 2.000000e+00) #5
  %48 = load i32, ptr %6, align 4, !tbaa !5
  %49 = zext i32 %48 to i64
  %50 = getelementptr inbounds float, ptr %25, i64 %49
  store float %47, ptr %50, align 4, !tbaa !9
  br label %51

51:                                               ; preds = %33
  %52 = load i32, ptr %6, align 4, !tbaa !5
  %53 = add i32 %52, 1
  store i32 %53, ptr %6, align 4, !tbaa !5
  br label %26, !llvm.loop !11

54:                                               ; preds = %26
  %55 = load i32, ptr %4, align 4, !tbaa !5
  %56 = load i32, ptr %5, align 4, !tbaa !5
  %57 = mul i32 2, %56
  %58 = load i32, ptr %4, align 4, !tbaa !5
  %59 = mul i32 %57, %58
  %60 = call ptr @firinterp_crcf_create(i32 noundef %55, ptr noundef %25, i32 noundef %59)
  store ptr %60, ptr %3, align 8
  %61 = load ptr, ptr %7, align 8
  call void @llvm.stackrestore.p0(ptr %61)
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %62

62:                                               ; preds = %54, %16, %11
  %63 = load ptr, ptr %3, align 8
  ret ptr %63
}

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

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

attributes #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 willreturn }
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 "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 = !{!"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}
!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"

@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.48 = external hidden unnamed_addr constant [87 x i8], align 1
@.str.59 = external hidden unnamed_addr constant [67 x i8], align 1

declare ptr @liquid_error_config_fl(ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @firinterp_crcf_create(i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local ptr @firinterp_crcf_create_window(i32 noundef %0, i32 noundef %1) local_unnamed_addr #2 {
  %3 = icmp eq i32 %0, 0
  br i1 %3, label %4, label %6

4:                                                ; preds = %2
  %5 = tail call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef nonnull @.str.48, i32 noundef 172, ptr noundef nonnull @.str.59, ptr noundef nonnull @.str.2) #4
  br label %36

6:                                                ; preds = %2
  %7 = icmp eq i32 %1, 0
  br i1 %7, label %8, label %10

8:                                                ; preds = %6
  %9 = tail call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef nonnull @.str.48, i32 noundef 174, ptr noundef nonnull @.str.59, ptr noundef nonnull @.str.2) #4
  br label %36

10:                                               ; preds = %6
  %11 = shl i32 %1, 1
  %12 = mul i32 %11, %0
  %13 = zext i32 %12 to i64
  %14 = tail call ptr @llvm.stacksave.p0()
  %15 = alloca float, i64 %13, align 16
  %.not = icmp eq i32 %12, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %10
  %16 = uitofp i32 %12 to float
  %17 = fpext float %16 to double
  br label %18

18:                                               ; preds = %18, %.lr.ph
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next.1, %18 ]
  %19 = trunc nuw i64 %indvars.iv to i32
  %20 = uitofp i32 %19 to float
  %21 = fpext float %20 to double
  %22 = fmul double %21, 0x400921FB54442D18
  %23 = fdiv double %22, %17
  %24 = fptrunc double %23 to float
  %25 = tail call float @sinf(float noundef %24) #4
  %square = fmul float %25, %25
  %26 = getelementptr inbounds float, ptr %15, i64 %indvars.iv
  store float %square, ptr %26, align 8, !tbaa !5
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %27 = trunc nuw i64 %indvars.iv.next to i32
  %28 = uitofp i32 %27 to float
  %29 = fpext float %28 to double
  %30 = fmul double %29, 0x400921FB54442D18
  %31 = fdiv double %30, %17
  %32 = fptrunc double %31 to float
  %33 = tail call float @sinf(float noundef %32) #4
  %square.1 = fmul float %33, %33
  %34 = getelementptr inbounds float, ptr %15, i64 %indvars.iv.next
  store float %square.1, ptr %34, align 4, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, %13
  br i1 %exitcond.not.1, label %._crit_edge, label %18, !llvm.loop !9

._crit_edge:                                      ; preds = %18, %10
  %35 = call ptr @firinterp_crcf_create(i32 noundef %0, ptr noundef nonnull %15, i32 noundef %12)
  call void @llvm.stackrestore.p0(ptr %14)
  br label %36

36:                                               ; preds = %._crit_edge, %8, %4
  %.0 = phi ptr [ %5, %4 ], [ %9, %8 ], [ %35, %._crit_edge ]
  ret ptr %.0
}

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

attributes #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 willreturn }
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 = { 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 #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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass