; 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_interp_execute(ptr noundef %0, <2 x float> noundef %1, ptr noundef %2) #2 {
  %4 = alloca { float, float }, align 4
  %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
  store <2 x float> %1, ptr %4, align 4
  store ptr %0, 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
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.firhilbf_s, ptr %10, i32 0, i32 12
  %12 = load i32, ptr %11, align 8, !tbaa !9
  %13 = icmp ne i32 %12, 0
  br i1 %13, label %14, label %20

14:                                               ; preds = %3
  %15 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %16 = load float, ptr %15, align 4
  %17 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  %18 = load float, ptr %17, align 4
  %19 = fneg float %16
  br label %25

20:                                               ; preds = %3
  %21 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %22 = load float, ptr %21, align 4
  %23 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  %24 = load float, ptr %23, align 4
  br label %25

25:                                               ; preds = %20, %14
  %26 = phi float [ %19, %14 ], [ %22, %20 ]
  store float %26, ptr %8, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.firhilbf_s, ptr %27, i32 0, i32 12
  %29 = load i32, ptr %28, align 8, !tbaa !9
  %30 = icmp ne i32 %29, 0
  br i1 %30, label %31, label %37

31:                                               ; preds = %25
  %32 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %33 = load float, ptr %32, align 4
  %34 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  %35 = load float, ptr %34, align 4
  %36 = fneg float %35
  br label %42

37:                                               ; preds = %25
  %38 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %39 = load float, ptr %38, align 4
  %40 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  %41 = load float, ptr %40, align 4
  br label %42

42:                                               ; preds = %37, %31
  %43 = phi float [ %36, %31 ], [ %41, %37 ]
  store float %43, ptr %9, align 4, !tbaa !13
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.firhilbf_s, ptr %44, i32 0, i32 7
  %46 = load ptr, ptr %45, align 8, !tbaa !14
  %47 = load float, ptr %9, align 4, !tbaa !13
  %48 = call i32 @windowf_push(ptr noundef %46, float noundef %47)
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.firhilbf_s, ptr %49, i32 0, i32 7
  %51 = load ptr, ptr %50, align 8, !tbaa !14
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.firhilbf_s, ptr %52, i32 0, i32 4
  %54 = load i32, ptr %53, align 8, !tbaa !15
  %55 = sub i32 %54, 1
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = getelementptr inbounds float, ptr %56, i64 0
  %58 = call i32 @windowf_index(ptr noundef %51, i32 noundef %55, ptr noundef %57)
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.firhilbf_s, ptr %59, i32 0, i32 8
  %61 = load ptr, ptr %60, align 8, !tbaa !16
  %62 = load float, ptr %8, align 4, !tbaa !13
  %63 = call i32 @windowf_push(ptr noundef %61, float noundef %62)
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.firhilbf_s, ptr %64, i32 0, i32 8
  %66 = load ptr, ptr %65, align 8, !tbaa !16
  %67 = call i32 @windowf_read(ptr noundef %66, ptr noundef %7)
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.firhilbf_s, ptr %68, i32 0, i32 11
  %70 = load ptr, ptr %69, align 8, !tbaa !17
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  %73 = getelementptr inbounds float, ptr %72, i64 1
  %74 = call i32 @dotprod_rrrf_execute(ptr noundef %70, ptr noundef %71, ptr noundef %73)
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.firhilbf_s, ptr %75, i32 0, i32 12
  %77 = load i32, ptr %76, align 8, !tbaa !9
  %78 = sub i32 1, %77
  %79 = load ptr, ptr %5, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.firhilbf_s, ptr %79, i32 0, i32 12
  store i32 %78, ptr %80, align 8, !tbaa !9
  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"="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 #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, !11, i64 88}
!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 48}
!15 = !{!10, !11, i64 24}
!16 = !{!10, !6, i64 56}
!17 = !{!10, !6, i64 80}


; 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_interp_execute(ptr nocapture noundef %0, <2 x float> noundef %1, ptr noundef %2) local_unnamed_addr #2 {
  %4 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  %5 = getelementptr inbounds i8, ptr %0, i64 88
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %.not = icmp eq i32 %6, 0
  %.sroa.0.0.vec.extract = extractelement <2 x float> %1, i64 0
  %7 = fneg float %.sroa.0.0.vec.extract
  %8 = select i1 %.not, float %.sroa.0.0.vec.extract, float %7
  %.sroa.0.4.vec.extract23 = extractelement <2 x float> %1, i64 1
  %9 = fneg float %.sroa.0.4.vec.extract23
  %10 = select i1 %.not, float %.sroa.0.4.vec.extract23, float %9
  %11 = getelementptr inbounds i8, ptr %0, i64 48
  %12 = load ptr, ptr %11, align 8, !tbaa !12
  %13 = tail call i32 @windowf_push(ptr noundef %12, float noundef %10) #3
  %14 = load ptr, ptr %11, align 8, !tbaa !12
  %15 = getelementptr inbounds i8, ptr %0, i64 24
  %16 = load i32, ptr %15, align 8, !tbaa !13
  %17 = add i32 %16, -1
  %18 = tail call i32 @windowf_index(ptr noundef %14, i32 noundef %17, ptr noundef %2) #3
  %19 = getelementptr inbounds i8, ptr %0, i64 56
  %20 = load ptr, ptr %19, align 8, !tbaa !14
  %21 = tail call i32 @windowf_push(ptr noundef %20, float noundef %8) #3
  %22 = load ptr, ptr %19, align 8, !tbaa !14
  %23 = call i32 @windowf_read(ptr noundef %22, ptr noundef nonnull %4) #3
  %24 = getelementptr inbounds i8, ptr %0, i64 80
  %25 = load ptr, ptr %24, align 8, !tbaa !15
  %26 = load ptr, ptr %4, align 8, !tbaa !16
  %27 = getelementptr inbounds i8, ptr %2, i64 4
  %28 = call i32 @dotprod_rrrf_execute(ptr noundef %25, ptr noundef %26, ptr noundef nonnull %27) #3
  %29 = load i32, ptr %5, align 8, !tbaa !5
  %30 = sub i32 1, %29
  store i32 %30, ptr %5, align 8, !tbaa !5
  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"="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 #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, !10, i64 88}
!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 = !{!6, !7, i64 48}
!13 = !{!6, !10, i64 24}
!14 = !{!6, !7, i64 56}
!15 = !{!6, !7, i64 80}
!16 = !{!7, !7, i64 0}


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