; 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.iirhilbf_s = type { 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

; Function Attrs: nounwind uwtable
declare dso_local i32 @iirfilt_rrrf_execute(ptr noundef, float noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @iirhilbf_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 float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = 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 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.iirhilbf_s, ptr %11, i32 0, i32 0
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %15 = load float, ptr %14, align 4
  %16 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  %17 = load float, ptr %16, align 4
  %18 = call i32 @iirfilt_rrrf_execute(ptr noundef %13, float noundef %15, ptr noundef %7)
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.iirhilbf_s, ptr %19, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8, !tbaa !9
  %22 = call i32 @iirfilt_rrrf_execute(ptr noundef %21, float noundef 0.000000e+00, ptr noundef %8)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.iirhilbf_s, ptr %23, i32 0, i32 1
  %25 = load ptr, ptr %24, align 8, !tbaa !12
  %26 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %27 = load float, ptr %26, align 4
  %28 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  %29 = load float, ptr %28, align 4
  %30 = call i32 @iirfilt_rrrf_execute(ptr noundef %25, float noundef %29, ptr noundef %9)
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.iirhilbf_s, ptr %31, i32 0, i32 1
  %33 = load ptr, ptr %32, align 8, !tbaa !12
  %34 = call i32 @iirfilt_rrrf_execute(ptr noundef %33, float noundef 0.000000e+00, ptr noundef %10)
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.iirhilbf_s, ptr %35, i32 0, i32 2
  %37 = load i32, ptr %36, align 8, !tbaa !13
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %39, label %42

39:                                               ; preds = %3
  %40 = load float, ptr %7, align 4, !tbaa !14
  %41 = fneg float %40
  br label %44

42:                                               ; preds = %3
  %43 = load float, ptr %7, align 4, !tbaa !14
  br label %44

44:                                               ; preds = %42, %39
  %45 = phi float [ %41, %39 ], [ %43, %42 ]
  %46 = fmul float 2.000000e+00, %45
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = getelementptr inbounds float, ptr %47, i64 0
  store float %46, ptr %48, align 4, !tbaa !14
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.iirhilbf_s, ptr %49, i32 0, i32 2
  %51 = load i32, ptr %50, align 8, !tbaa !13
  %52 = icmp ne i32 %51, 0
  br i1 %52, label %53, label %55

53:                                               ; preds = %44
  %54 = load float, ptr %10, align 4, !tbaa !14
  br label %58

55:                                               ; preds = %44
  %56 = load float, ptr %10, align 4, !tbaa !14
  %57 = fneg float %56
  br label %58

58:                                               ; preds = %55, %53
  %59 = phi float [ %54, %53 ], [ %57, %55 ]
  %60 = fmul float 2.000000e+00, %59
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = getelementptr inbounds float, ptr %61, i64 1
  store float %60, ptr %62, align 4, !tbaa !14
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.iirhilbf_s, ptr %63, i32 0, i32 2
  %65 = load i32, ptr %64, align 8, !tbaa !13
  %66 = sub i32 1, %65
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.iirhilbf_s, ptr %67, i32 0, i32 2
  store i32 %66, ptr %68, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 4, 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 4, ptr %7) #3
  ret i32 0
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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, !6, i64 0}
!10 = !{!"iirhilbf_s", !6, i64 0, !6, i64 8, !11, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 8}
!13 = !{!10, !11, i64 16}
!14 = !{!15, !15, i64 0}
!15 = !{!"float", !7, i64 0}


; 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

; Function Attrs: nounwind uwtable
declare dso_local i32 @iirfilt_rrrf_execute(ptr noundef, float noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @iirhilbf_interp_execute(ptr nocapture noundef %0, <2 x float> noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #2 {
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #3
  %8 = load ptr, ptr %0, align 8, !tbaa !5
  %.sroa.0.0.vec.extract = extractelement <2 x float> %1, i64 0
  %9 = call i32 @iirfilt_rrrf_execute(ptr noundef %8, float noundef %.sroa.0.0.vec.extract, ptr noundef nonnull %4)
  %10 = load ptr, ptr %0, align 8, !tbaa !5
  %11 = call i32 @iirfilt_rrrf_execute(ptr noundef %10, float noundef 0.000000e+00, ptr noundef nonnull %5)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #3
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  %13 = load ptr, ptr %12, align 8, !tbaa !11
  %.sroa.0.4.vec.extract13 = extractelement <2 x float> %1, i64 1
  %14 = call i32 @iirfilt_rrrf_execute(ptr noundef %13, float noundef %.sroa.0.4.vec.extract13, ptr noundef nonnull %6)
  %15 = load ptr, ptr %12, align 8, !tbaa !11
  %16 = call i32 @iirfilt_rrrf_execute(ptr noundef %15, float noundef 0.000000e+00, ptr noundef nonnull %7)
  %17 = getelementptr inbounds i8, ptr %0, i64 16
  %18 = load i32, ptr %17, align 8, !tbaa !12
  %.not = icmp eq i32 %18, 0
  %19 = load float, ptr %4, align 4
  %20 = fneg float %19
  %21 = load float, ptr %7, align 4
  %22 = fneg float %21
  %23 = insertelement <2 x i1> poison, i1 %.not, i64 0
  %24 = shufflevector <2 x i1> %23, <2 x i1> poison, <2 x i32> zeroinitializer
  %25 = insertelement <2 x float> poison, float %19, i64 0
  %26 = insertelement <2 x float> %25, float %22, i64 1
  %27 = insertelement <2 x float> poison, float %20, i64 0
  %28 = insertelement <2 x float> %27, float %21, i64 1
  %29 = select <2 x i1> %24, <2 x float> %26, <2 x float> %28
  %30 = fmul <2 x float> %29, <float 2.000000e+00, float 2.000000e+00>
  store <2 x float> %30, ptr %2, align 4, !tbaa !13
  %31 = sub i32 1, %18
  store i32 %31, ptr %17, align 8, !tbaa !12
  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 4, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #3
  ret i32 0
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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, !7, i64 0}
!6 = !{!"iirhilbf_s", !7, i64 0, !7, i64 8, !10, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 8}
!12 = !{!6, !10, i64 16}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !8, i64 0}


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