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

; 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 = external hidden unnamed_addr constant [83 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [45 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local float @fir_group_delay(ptr noundef %0, i32 noundef %1, float noundef %2) #0 {
  %4 = alloca float, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca float, align 4
  %8 = alloca i32, align 4
  %9 = alloca { float, float }, align 4
  %10 = alloca { float, float }, align 4
  %11 = alloca { float, float }, align 4
  %12 = alloca { float, float }, align 4
  %13 = alloca { float, float }, align 4
  %14 = alloca { float, float }, align 4
  %15 = alloca { float, float }, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store float %2, ptr %7, align 4, !tbaa !11
  %16 = load i32, ptr %6, align 4, !tbaa !9
  %17 = icmp eq i32 %16, 0
  br i1 %17, label %18, label %20

18:                                               ; preds = %3
  %19 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str, i32 noundef 40, ptr noundef @.str.1)
  store float 0.000000e+00, ptr %4, align 4
  br label %128

20:                                               ; preds = %3
  %21 = load float, ptr %7, align 4, !tbaa !11
  %22 = fpext float %21 to double
  %23 = fcmp olt double %22, -5.000000e-01
  br i1 %23, label %28, label %24

24:                                               ; preds = %20
  %25 = load float, ptr %7, align 4, !tbaa !11
  %26 = fpext float %25 to double
  %27 = fcmp ogt double %26, 5.000000e-01
  br i1 %27, label %28, label %30

28:                                               ; preds = %24, %20
  %29 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str, i32 noundef 43, ptr noundef @.str.2)
  store float 0.000000e+00, ptr %4, align 4
  br label %128

30:                                               ; preds = %24
  br label %31

31:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %32 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %33 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  store float 0.000000e+00, ptr %32, align 4
  store float 0.000000e+00, ptr %33, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %34 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 0
  %35 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 1
  store float 0.000000e+00, ptr %34, align 4
  store float 0.000000e+00, ptr %35, align 4
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %36

36:                                               ; preds = %111, %31
  %37 = load i32, ptr %8, align 4, !tbaa !9
  %38 = load i32, ptr %6, align 4, !tbaa !9
  %39 = icmp ult i32 %37, %38
  br i1 %39, label %40, label %114

40:                                               ; preds = %36
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = load i32, ptr %8, align 4, !tbaa !9
  %43 = zext i32 %42 to i64
  %44 = getelementptr inbounds float, ptr %41, i64 %43
  %45 = load float, ptr %44, align 4, !tbaa !11
  %46 = load float, ptr %7, align 4, !tbaa !11
  %47 = fpext float %46 to double
  %48 = fmul double 0.000000e+00, %47
  %49 = fmul double 0x401921FB54442D18, %47
  %50 = load i32, ptr %8, align 4, !tbaa !9
  %51 = uitofp i32 %50 to double
  %52 = fmul double %48, %51
  %53 = fmul double %49, %51
  %54 = fptrunc double %52 to float
  %55 = fptrunc double %53 to float
  %56 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 0
  %57 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 1
  store float %54, ptr %56, align 4
  store float %55, ptr %57, align 4
  %58 = load <2 x float>, ptr %11, align 4
  %59 = call <2 x float> @cexpf(<2 x float> noundef %58) #4
  store <2 x float> %59, ptr %12, align 4
  %60 = getelementptr inbounds { float, float }, ptr %12, i32 0, i32 0
  %61 = load float, ptr %60, align 4
  %62 = getelementptr inbounds { float, float }, ptr %12, i32 0, i32 1
  %63 = load float, ptr %62, align 4
  %64 = fmul float %45, %61
  %65 = fmul float %45, %63
  %66 = load i32, ptr %8, align 4, !tbaa !9
  %67 = uitofp i32 %66 to float
  %68 = fmul float %64, %67
  %69 = fmul float %65, %67
  %70 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %71 = load float, ptr %70, align 4
  %72 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  %73 = load float, ptr %72, align 4
  %74 = fadd float %71, %68
  %75 = fadd float %73, %69
  %76 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %77 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  store float %74, ptr %76, align 4
  store float %75, ptr %77, align 4
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = load i32, ptr %8, align 4, !tbaa !9
  %80 = zext i32 %79 to i64
  %81 = getelementptr inbounds float, ptr %78, i64 %80
  %82 = load float, ptr %81, align 4, !tbaa !11
  %83 = load float, ptr %7, align 4, !tbaa !11
  %84 = fpext float %83 to double
  %85 = fmul double 0.000000e+00, %84
  %86 = fmul double 0x401921FB54442D18, %84
  %87 = load i32, ptr %8, align 4, !tbaa !9
  %88 = uitofp i32 %87 to double
  %89 = fmul double %85, %88
  %90 = fmul double %86, %88
  %91 = fptrunc double %89 to float
  %92 = fptrunc double %90 to float
  %93 = getelementptr inbounds { float, float }, ptr %13, i32 0, i32 0
  %94 = getelementptr inbounds { float, float }, ptr %13, i32 0, i32 1
  store float %91, ptr %93, align 4
  store float %92, ptr %94, align 4
  %95 = load <2 x float>, ptr %13, align 4
  %96 = call <2 x float> @cexpf(<2 x float> noundef %95) #4
  store <2 x float> %96, ptr %14, align 4
  %97 = getelementptr inbounds { float, float }, ptr %14, i32 0, i32 0
  %98 = load float, ptr %97, align 4
  %99 = getelementptr inbounds { float, float }, ptr %14, i32 0, i32 1
  %100 = load float, ptr %99, align 4
  %101 = fmul float %82, %98
  %102 = fmul float %82, %100
  %103 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 0
  %104 = load float, ptr %103, align 4
  %105 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 1
  %106 = load float, ptr %105, align 4
  %107 = fadd float %104, %101
  %108 = fadd float %106, %102
  %109 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 0
  %110 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 1
  store float %107, ptr %109, align 4
  store float %108, ptr %110, align 4
  br label %111

111:                                              ; preds = %40
  %112 = load i32, ptr %8, align 4, !tbaa !9
  %113 = add i32 %112, 1
  store i32 %113, ptr %8, align 4, !tbaa !9
  br label %36, !llvm.loop !13

114:                                              ; preds = %36
  %115 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %116 = load float, ptr %115, align 4
  %117 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  %118 = load float, ptr %117, align 4
  %119 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 0
  %120 = load float, ptr %119, align 4
  %121 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 1
  %122 = load float, ptr %121, align 4
  %123 = call <2 x float> @__divsc3(float noundef %116, float noundef %118, float noundef %120, float noundef %122) #4
  store <2 x float> %123, ptr %15, align 4
  %124 = getelementptr inbounds { float, float }, ptr %15, i32 0, i32 0
  %125 = load float, ptr %124, align 4
  %126 = getelementptr inbounds { float, float }, ptr %15, i32 0, i32 1
  %127 = load float, ptr %126, align 4
  store float %125, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %128

128:                                              ; preds = %114, %28, %18
  %129 = load float, ptr %4, align 4
  ret float %129
}

declare i32 @liquid_error_fl(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) #1

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

; Function Attrs: nounwind
declare <2 x float> @cexpf(<2 x float> noundef) #3

declare <2 x float> @__divsc3(float, float, float, float)

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

attributes #0 = { nounwind uwtable "min-legal-vector-width"="64" "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 = { "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 willreturn memory(argmem: readwrite) }
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 = !{!"any pointer", !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 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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 = external hidden unnamed_addr constant [83 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [45 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local float @fir_group_delay(ptr nocapture noundef readonly %0, i32 noundef %1, float noundef %2) local_unnamed_addr #0 {
  %4 = icmp eq i32 %1, 0
  br i1 %4, label %5, label %7

5:                                                ; preds = %3
  %6 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str, i32 noundef 40, ptr noundef nonnull @.str.1) #4
  br label %46

7:                                                ; preds = %3
  %8 = tail call float @llvm.fabs.f32(float %2)
  %or.cond = fcmp ogt float %8, 5.000000e-01
  br i1 %or.cond, label %13, label %.preheader

.preheader:                                       ; preds = %7
  %9 = fpext float %2 to double
  %10 = insertelement <2 x double> poison, double %9, i64 0
  %11 = shufflevector <2 x double> %10, <2 x double> poison, <2 x i32> zeroinitializer
  %12 = fmul <2 x double> %11, <double 0.000000e+00, double 0x401921FB54442D18>
  %wide.trip.count = zext i32 %1 to i64
  br label %15

13:                                               ; preds = %7
  %14 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str, i32 noundef 43, ptr noundef nonnull @.str.2) #4
  br label %46

15:                                               ; preds = %.preheader, %15
  %indvars.iv = phi i64 [ 0, %.preheader ], [ %indvars.iv.next, %15 ]
  %16 = phi <4 x float> [ zeroinitializer, %.preheader ], [ %39, %15 ]
  %17 = getelementptr inbounds float, ptr %0, i64 %indvars.iv
  %18 = load float, ptr %17, align 4, !tbaa !5
  %19 = trunc nuw i64 %indvars.iv to i32
  %20 = uitofp i32 %19 to double
  %21 = insertelement <2 x double> poison, double %20, i64 0
  %22 = shufflevector <2 x double> %21, <2 x double> poison, <2 x i32> zeroinitializer
  %23 = fmul <2 x double> %12, %22
  %24 = fptrunc <2 x double> %23 to <2 x float>
  %25 = tail call <2 x float> @cexpf(<2 x float> noundef %24) #4
  %.sroa.04.0.vec.extract = extractelement <2 x float> %25, i64 0
  %.sroa.04.4.vec.extract = extractelement <2 x float> %25, i64 1
  %26 = fmul float %18, %.sroa.04.0.vec.extract
  %27 = fmul float %18, %.sroa.04.4.vec.extract
  %28 = uitofp i32 %19 to float
  %29 = load float, ptr %17, align 4, !tbaa !5
  %30 = tail call <2 x float> @cexpf(<2 x float> noundef %24) #4
  %31 = insertelement <4 x float> poison, float %27, i64 0
  %32 = insertelement <4 x float> %31, float %29, i64 1
  %33 = insertelement <4 x float> %32, float %26, i64 3
  %34 = shufflevector <4 x float> %33, <4 x float> poison, <4 x i32> <i32 0, i32 1, i32 1, i32 3>
  %35 = shufflevector <2 x float> %30, <2 x float> poison, <4 x i32> <i32 poison, i32 0, i32 1, i32 poison>
  %36 = insertelement <4 x float> %35, float %28, i64 0
  %37 = shufflevector <4 x float> %36, <4 x float> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 0>
  %38 = fmul <4 x float> %34, %37
  %39 = fadd <4 x float> %16, %38
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %40, label %15, !llvm.loop !9

40:                                               ; preds = %15
  %41 = extractelement <4 x float> %39, i64 0
  %42 = extractelement <4 x float> %39, i64 1
  %43 = extractelement <4 x float> %39, i64 2
  %44 = extractelement <4 x float> %39, i64 3
  %45 = tail call <2 x float> @__divsc3(float noundef %44, float noundef %41, float noundef %42, float noundef %43) #4
  %.sroa.0.0.vec.extract = extractelement <2 x float> %45, i64 0
  br label %46

46:                                               ; preds = %40, %13, %5
  %.0 = phi float [ 0.000000e+00, %5 ], [ 0.000000e+00, %13 ], [ %.sroa.0.0.vec.extract, %40 ]
  ret float %.0
}

declare i32 @liquid_error_fl(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: nounwind
declare <2 x float> @cexpf(<2 x float> noundef) local_unnamed_addr #2

declare <2 x float> @__divsc3(float, float, float, float) local_unnamed_addr

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

attributes #0 = { nounwind uwtable "min-legal-vector-width"="64" "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 = { "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 = { 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass