; 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.resamp2_rrrf_s = type { ptr, i32, i32, float, float, ptr, ptr, i32, ptr, ptr, float, 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 @resamp2_rrrf_filter_execute(ptr noundef %0, float noundef %1, ptr noundef %2, ptr noundef %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca float, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store float %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.resamp2_rrrf_s, ptr %12, i32 0, i32 11
  %14 = load i32, ptr %13, align 4, !tbaa !11
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %16, label %39

16:                                               ; preds = %4
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.resamp2_rrrf_s, ptr %17, i32 0, i32 8
  %19 = load ptr, ptr %18, align 8, !tbaa !14
  %20 = load float, ptr %6, align 4, !tbaa !9
  %21 = call i32 @windowf_push(ptr noundef %19, float noundef %20)
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.resamp2_rrrf_s, ptr %22, i32 0, i32 8
  %24 = load ptr, ptr %23, align 8, !tbaa !14
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.resamp2_rrrf_s, ptr %25, i32 0, i32 1
  %27 = load i32, ptr %26, align 8, !tbaa !15
  %28 = sub i32 %27, 1
  %29 = call i32 @windowf_index(ptr noundef %24, i32 noundef %28, ptr noundef %10)
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.resamp2_rrrf_s, ptr %30, i32 0, i32 9
  %32 = load ptr, ptr %31, align 8, !tbaa !16
  %33 = call i32 @windowf_read(ptr noundef %32, ptr noundef %9)
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.resamp2_rrrf_s, ptr %34, i32 0, i32 6
  %36 = load ptr, ptr %35, align 8, !tbaa !17
  %37 = load ptr, ptr %9, align 8, !tbaa !5
  %38 = call i32 @dotprod_rrrf_execute(ptr noundef %36, ptr noundef %37, ptr noundef %11)
  br label %62

39:                                               ; preds = %4
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.resamp2_rrrf_s, ptr %40, i32 0, i32 9
  %42 = load ptr, ptr %41, align 8, !tbaa !16
  %43 = load float, ptr %6, align 4, !tbaa !9
  %44 = call i32 @windowf_push(ptr noundef %42, float noundef %43)
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.resamp2_rrrf_s, ptr %45, i32 0, i32 9
  %47 = load ptr, ptr %46, align 8, !tbaa !16
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.resamp2_rrrf_s, ptr %48, i32 0, i32 1
  %50 = load i32, ptr %49, align 8, !tbaa !15
  %51 = sub i32 %50, 1
  %52 = call i32 @windowf_index(ptr noundef %47, i32 noundef %51, ptr noundef %10)
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.resamp2_rrrf_s, ptr %53, i32 0, i32 8
  %55 = load ptr, ptr %54, align 8, !tbaa !14
  %56 = call i32 @windowf_read(ptr noundef %55, ptr noundef %9)
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.resamp2_rrrf_s, ptr %57, i32 0, i32 6
  %59 = load ptr, ptr %58, align 8, !tbaa !17
  %60 = load ptr, ptr %9, align 8, !tbaa !5
  %61 = call i32 @dotprod_rrrf_execute(ptr noundef %59, ptr noundef %60, ptr noundef %11)
  br label %62

62:                                               ; preds = %39, %16
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.resamp2_rrrf_s, ptr %63, i32 0, i32 11
  %65 = load i32, ptr %64, align 4, !tbaa !11
  %66 = sub i32 1, %65
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.resamp2_rrrf_s, ptr %67, i32 0, i32 11
  store i32 %66, ptr %68, align 4, !tbaa !11
  %69 = load float, ptr %10, align 4, !tbaa !9
  %70 = load float, ptr %11, align 4, !tbaa !9
  %71 = fadd float %69, %70
  %72 = fmul float 5.000000e-01, %71
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.resamp2_rrrf_s, ptr %73, i32 0, i32 10
  %75 = load float, ptr %74, align 8, !tbaa !18
  %76 = fmul float %72, %75
  %77 = load ptr, ptr %7, align 8, !tbaa !5
  store float %76, ptr %77, align 4, !tbaa !9
  %78 = load float, ptr %10, align 4, !tbaa !9
  %79 = load float, ptr %11, align 4, !tbaa !9
  %80 = fsub float %78, %79
  %81 = fmul float 5.000000e-01, %80
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.resamp2_rrrf_s, ptr %82, i32 0, i32 10
  %84 = load float, ptr %83, align 8, !tbaa !18
  %85 = fmul float %81, %84
  %86 = load ptr, ptr %8, align 8, !tbaa !5
  store float %85, ptr %86, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #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, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !13, i64 68}
!12 = !{!"resamp2_rrrf_s", !6, i64 0, !13, i64 8, !13, i64 12, !10, i64 16, !10, i64 20, !6, i64 24, !6, i64 32, !13, i64 40, !6, i64 48, !6, i64 56, !10, i64 64, !13, i64 68}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !6, i64 48}
!15 = !{!12, !13, i64 8}
!16 = !{!12, !6, i64 56}
!17 = !{!12, !6, i64 32}
!18 = !{!12, !10, i64 64}


; 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 @resamp2_rrrf_filter_execute(ptr nocapture noundef %0, float noundef %1, ptr nocapture noundef writeonly %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #2 {
  %5 = alloca ptr, align 8
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #3
  %8 = getelementptr inbounds i8, ptr %0, i64 68
  %9 = load i32, ptr %8, align 4, !tbaa !5
  %10 = icmp eq i32 %9, 0
  %11 = getelementptr inbounds i8, ptr %0, i64 8
  %12 = getelementptr inbounds i8, ptr %0, i64 32
  br i1 %10, label %13, label %27

13:                                               ; preds = %4
  %14 = getelementptr inbounds i8, ptr %0, i64 48
  %15 = load ptr, ptr %14, align 8, !tbaa !12
  %16 = tail call i32 @windowf_push(ptr noundef %15, float noundef %1) #3
  %17 = load ptr, ptr %14, align 8, !tbaa !12
  %18 = load i32, ptr %11, align 8, !tbaa !13
  %19 = add i32 %18, -1
  %20 = call i32 @windowf_index(ptr noundef %17, i32 noundef %19, ptr noundef nonnull %6) #3
  %21 = getelementptr inbounds i8, ptr %0, i64 56
  %22 = load ptr, ptr %21, align 8, !tbaa !14
  %23 = call i32 @windowf_read(ptr noundef %22, ptr noundef nonnull %5) #3
  %24 = load ptr, ptr %12, align 8, !tbaa !15
  %25 = load ptr, ptr %5, align 8, !tbaa !16
  %26 = call i32 @dotprod_rrrf_execute(ptr noundef %24, ptr noundef %25, ptr noundef nonnull %7) #3
  br label %41

27:                                               ; preds = %4
  %28 = getelementptr inbounds i8, ptr %0, i64 56
  %29 = load ptr, ptr %28, align 8, !tbaa !14
  %30 = tail call i32 @windowf_push(ptr noundef %29, float noundef %1) #3
  %31 = load ptr, ptr %28, align 8, !tbaa !14
  %32 = load i32, ptr %11, align 8, !tbaa !13
  %33 = add i32 %32, -1
  %34 = call i32 @windowf_index(ptr noundef %31, i32 noundef %33, ptr noundef nonnull %6) #3
  %35 = getelementptr inbounds i8, ptr %0, i64 48
  %36 = load ptr, ptr %35, align 8, !tbaa !12
  %37 = call i32 @windowf_read(ptr noundef %36, ptr noundef nonnull %5) #3
  %38 = load ptr, ptr %12, align 8, !tbaa !15
  %39 = load ptr, ptr %5, align 8, !tbaa !16
  %40 = call i32 @dotprod_rrrf_execute(ptr noundef %38, ptr noundef %39, ptr noundef nonnull %7) #3
  br label %41

41:                                               ; preds = %27, %13
  %42 = load i32, ptr %8, align 4, !tbaa !5
  %43 = sub i32 1, %42
  store i32 %43, ptr %8, align 4, !tbaa !5
  %44 = load float, ptr %6, align 4, !tbaa !17
  %45 = load float, ptr %7, align 4, !tbaa !17
  %46 = fadd float %44, %45
  %47 = fmul float %46, 5.000000e-01
  %48 = getelementptr inbounds i8, ptr %0, i64 64
  %49 = load float, ptr %48, align 8, !tbaa !18
  %50 = fmul float %49, %47
  store float %50, ptr %2, align 4, !tbaa !17
  %51 = fsub float %44, %45
  %52 = fmul float %51, 5.000000e-01
  %53 = load float, ptr %48, align 8, !tbaa !18
  %54 = fmul float %52, %53
  store float %54, ptr %3, align 4, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #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, !10, i64 68}
!6 = !{!"resamp2_rrrf_s", !7, i64 0, !10, i64 8, !10, i64 12, !11, i64 16, !11, i64 20, !7, i64 24, !7, i64 32, !10, i64 40, !7, i64 48, !7, i64 56, !11, i64 64, !10, i64 68}
!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 8}
!14 = !{!6, !7, i64 56}
!15 = !{!6, !7, i64 32}
!16 = !{!7, !7, i64 0}
!17 = !{!11, !11, i64 0}
!18 = !{!6, !11, i64 64}


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