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

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

%struct.firhilbf_s = type { ptr, ptr, i32, float, i32, ptr, i32, ptr, ptr, ptr, ptr, ptr, i32 }

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

declare i32 @windowf_push(ptr noundef, float noundef) #1

declare i32 @windowf_read(ptr noundef, ptr noundef) #1

declare i32 @windowf_index(ptr noundef, i32 noundef, ptr noundef) #1

declare i32 @dotprod_rrrf_execute(ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @firhilbf_decim_execute(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca { float, float }, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.firhilbf_s, ptr %11, i32 0, i32 8
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds float, ptr %14, i64 0
  %16 = load float, ptr %15, align 4, !tbaa !13
  %17 = call i32 @windowf_push(ptr noundef %13, float noundef %16)
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.firhilbf_s, ptr %18, i32 0, i32 8
  %20 = load ptr, ptr %19, align 8, !tbaa !9
  %21 = call i32 @windowf_read(ptr noundef %20, ptr noundef %7)
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.firhilbf_s, ptr %22, i32 0, i32 11
  %24 = load ptr, ptr %23, align 8, !tbaa !14
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = call i32 @dotprod_rrrf_execute(ptr noundef %24, ptr noundef %25, ptr noundef %9)
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.firhilbf_s, ptr %27, i32 0, i32 7
  %29 = load ptr, ptr %28, align 8, !tbaa !15
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds float, ptr %30, i64 1
  %32 = load float, ptr %31, align 4, !tbaa !13
  %33 = call i32 @windowf_push(ptr noundef %29, float noundef %32)
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.firhilbf_s, ptr %34, i32 0, i32 7
  %36 = load ptr, ptr %35, align 8, !tbaa !15
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.firhilbf_s, ptr %37, i32 0, i32 4
  %39 = load i32, ptr %38, align 8, !tbaa !16
  %40 = sub i32 %39, 1
  %41 = call i32 @windowf_index(ptr noundef %36, i32 noundef %40, ptr noundef %8)
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %42 = load float, ptr %8, align 4, !tbaa !13
  %43 = load float, ptr %9, align 4, !tbaa !13
  %44 = fmul float 0.000000e+00, %43
  %45 = fmul float 1.000000e+00, %43
  %46 = fadd float %42, %44
  %47 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 0
  %48 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 1
  store float %46, ptr %47, align 4
  store float %45, ptr %48, align 4
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.firhilbf_s, ptr %49, i32 0, i32 12
  %51 = load i32, ptr %50, align 8, !tbaa !17
  %52 = icmp ne i32 %51, 0
  br i1 %52, label %53, label %60

53:                                               ; preds = %3
  %54 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 0
  %55 = load float, ptr %54, align 4
  %56 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 1
  %57 = load float, ptr %56, align 4
  %58 = fneg float %55
  %59 = fneg float %57
  br label %65

60:                                               ; preds = %3
  %61 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 0
  %62 = load float, ptr %61, align 4
  %63 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 1
  %64 = load float, ptr %63, align 4
  br label %65

65:                                               ; preds = %60, %53
  %66 = phi float [ %58, %53 ], [ %62, %60 ]
  %67 = phi float [ %59, %53 ], [ %64, %60 ]
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = getelementptr inbounds { float, float }, ptr %68, i32 0, i32 0
  %70 = getelementptr inbounds { float, float }, ptr %68, i32 0, i32 1
  store float %66, ptr %69, align 4
  store float %67, ptr %70, align 4
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.firhilbf_s, ptr %71, i32 0, i32 12
  %73 = load i32, ptr %72, align 8, !tbaa !17
  %74 = sub i32 1, %73
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.firhilbf_s, ptr %75, i32 0, i32 12
  store i32 %74, ptr %76, align 8, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret i32 0
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 }

!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, !6, i64 56}
!10 = !{!"firhilbf_s", !6, i64 0, !6, i64 8, !11, i64 16, !12, i64 20, !11, i64 24, !6, i64 32, !11, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !11, i64 88}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!12, !12, i64 0}
!14 = !{!10, !6, i64 80}
!15 = !{!10, !6, i64 48}
!16 = !{!10, !11, i64 24}
!17 = !{!10, !11, i64 88}


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

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

declare i32 @windowf_push(ptr noundef, float noundef) local_unnamed_addr #1

declare i32 @windowf_read(ptr noundef, ptr noundef) local_unnamed_addr #1

declare i32 @windowf_index(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

declare i32 @dotprod_rrrf_execute(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @firhilbf_decim_execute(ptr nocapture noundef %0, ptr nocapture noundef readonly %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #2 {
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #3
  %7 = getelementptr inbounds i8, ptr %0, i64 56
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = load float, ptr %1, align 4, !tbaa !12
  %10 = tail call i32 @windowf_push(ptr noundef %8, float noundef %9) #3
  %11 = load ptr, ptr %7, align 8, !tbaa !5
  %12 = call i32 @windowf_read(ptr noundef %11, ptr noundef nonnull %4) #3
  %13 = getelementptr inbounds i8, ptr %0, i64 80
  %14 = load ptr, ptr %13, align 8, !tbaa !13
  %15 = load ptr, ptr %4, align 8, !tbaa !14
  %16 = call i32 @dotprod_rrrf_execute(ptr noundef %14, ptr noundef %15, ptr noundef nonnull %6) #3
  %17 = getelementptr inbounds i8, ptr %0, i64 48
  %18 = load ptr, ptr %17, align 8, !tbaa !15
  %19 = getelementptr inbounds i8, ptr %1, i64 4
  %20 = load float, ptr %19, align 4, !tbaa !12
  %21 = call i32 @windowf_push(ptr noundef %18, float noundef %20) #3
  %22 = load ptr, ptr %17, align 8, !tbaa !15
  %23 = getelementptr inbounds i8, ptr %0, i64 24
  %24 = load i32, ptr %23, align 8, !tbaa !16
  %25 = add i32 %24, -1
  %26 = call i32 @windowf_index(ptr noundef %22, i32 noundef %25, ptr noundef nonnull %5) #3
  %27 = load float, ptr %5, align 4, !tbaa !12
  %28 = load float, ptr %6, align 4, !tbaa !12
  %29 = fmul float %28, 0.000000e+00
  %30 = fadd float %27, %29
  %31 = getelementptr inbounds i8, ptr %0, i64 88
  %32 = load i32, ptr %31, align 8, !tbaa !17
  %.not = icmp eq i32 %32, 0
  %33 = insertelement <2 x float> poison, float %30, i64 0
  %34 = insertelement <2 x float> %33, float %28, i64 1
  %35 = fneg <2 x float> %34
  %36 = insertelement <2 x i1> poison, i1 %.not, i64 0
  %37 = shufflevector <2 x i1> %36, <2 x i1> poison, <2 x i32> zeroinitializer
  %38 = select <2 x i1> %37, <2 x float> %34, <2 x float> %35
  store <2 x float> %38, ptr %2, align 4
  %39 = load i32, ptr %31, align 8, !tbaa !17
  %40 = sub i32 1, %39
  store i32 %40, ptr %31, align 8, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  ret i32 0
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 }

!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, !7, i64 56}
!6 = !{!"firhilbf_s", !7, i64 0, !7, i64 8, !10, i64 16, !11, i64 20, !10, i64 24, !7, i64 32, !10, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !10, i64 88}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"float", !8, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!6, !7, i64 80}
!14 = !{!7, !7, i64 0}
!15 = !{!6, !7, i64 48}
!16 = !{!6, !10, i64 24}
!17 = !{!6, !10, i64 88}


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