; 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_c2r_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
  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
  store float 0.000000e+00, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store float 0.000000e+00, ptr %8, align 4, !tbaa !9
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.iirhilbf_s, ptr %9, i32 0, i32 2
  %11 = load i32, ptr %10, align 8, !tbaa !11
  switch i32 %11, label %94 [
    i32 0, label %12
    i32 1, label %31
    i32 2, label %52
    i32 3, label %74
  ]

12:                                               ; preds = %3
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.iirhilbf_s, ptr %13, i32 0, i32 0
  %15 = load ptr, ptr %14, align 8, !tbaa !14
  %16 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %17 = load float, ptr %16, align 4
  %18 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  %19 = load float, ptr %18, align 4
  %20 = call i32 @iirfilt_rrrf_execute(ptr noundef %15, float noundef %17, ptr noundef %7)
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.iirhilbf_s, ptr %21, i32 0, i32 1
  %23 = load ptr, ptr %22, align 8, !tbaa !15
  %24 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %25 = load float, ptr %24, align 4
  %26 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  %27 = load float, ptr %26, align 4
  %28 = call i32 @iirfilt_rrrf_execute(ptr noundef %23, float noundef %27, ptr noundef %8)
  %29 = load float, ptr %7, align 4, !tbaa !9
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  store float %29, ptr %30, align 4, !tbaa !9
  br label %95

31:                                               ; preds = %3
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.iirhilbf_s, ptr %32, i32 0, i32 0
  %34 = load ptr, ptr %33, align 8, !tbaa !14
  %35 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %36 = load float, ptr %35, align 4
  %37 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  %38 = load float, ptr %37, align 4
  %39 = call i32 @iirfilt_rrrf_execute(ptr noundef %34, float noundef %38, ptr noundef %7)
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.iirhilbf_s, ptr %40, i32 0, i32 1
  %42 = load ptr, ptr %41, align 8, !tbaa !15
  %43 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %44 = load float, ptr %43, align 4
  %45 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  %46 = load float, ptr %45, align 4
  %47 = fneg float %44
  %48 = call i32 @iirfilt_rrrf_execute(ptr noundef %42, float noundef %47, ptr noundef %8)
  %49 = load float, ptr %8, align 4, !tbaa !9
  %50 = fneg float %49
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  store float %50, ptr %51, align 4, !tbaa !9
  br label %95

52:                                               ; preds = %3
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.iirhilbf_s, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !14
  %56 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %57 = load float, ptr %56, align 4
  %58 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  %59 = load float, ptr %58, align 4
  %60 = fneg float %57
  %61 = call i32 @iirfilt_rrrf_execute(ptr noundef %55, float noundef %60, ptr noundef %7)
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.iirhilbf_s, ptr %62, i32 0, i32 1
  %64 = load ptr, ptr %63, align 8, !tbaa !15
  %65 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %66 = load float, ptr %65, align 4
  %67 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  %68 = load float, ptr %67, align 4
  %69 = fneg float %68
  %70 = call i32 @iirfilt_rrrf_execute(ptr noundef %64, float noundef %69, ptr noundef %8)
  %71 = load float, ptr %7, align 4, !tbaa !9
  %72 = fneg float %71
  %73 = load ptr, ptr %6, align 8, !tbaa !5
  store float %72, ptr %73, align 4, !tbaa !9
  br label %95

74:                                               ; preds = %3
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.iirhilbf_s, ptr %75, i32 0, i32 0
  %77 = load ptr, ptr %76, align 8, !tbaa !14
  %78 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %79 = load float, ptr %78, align 4
  %80 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  %81 = load float, ptr %80, align 4
  %82 = fneg float %81
  %83 = call i32 @iirfilt_rrrf_execute(ptr noundef %77, float noundef %82, ptr noundef %7)
  %84 = load ptr, ptr %5, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.iirhilbf_s, ptr %84, i32 0, i32 1
  %86 = load ptr, ptr %85, align 8, !tbaa !15
  %87 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %88 = load float, ptr %87, align 4
  %89 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  %90 = load float, ptr %89, align 4
  %91 = call i32 @iirfilt_rrrf_execute(ptr noundef %86, float noundef %88, ptr noundef %8)
  %92 = load float, ptr %8, align 4, !tbaa !9
  %93 = load ptr, ptr %6, align 8, !tbaa !5
  store float %92, ptr %93, align 4, !tbaa !9
  br label %95

94:                                               ; preds = %3
  br label %95

95:                                               ; preds = %94, %74, %52, %31, %12
  %96 = load ptr, ptr %5, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.iirhilbf_s, ptr %96, i32 0, i32 2
  %98 = load i32, ptr %97, align 8, !tbaa !11
  %99 = add i32 %98, 1
  %100 = and i32 %99, 3
  %101 = load ptr, ptr %5, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.iirhilbf_s, ptr %101, i32 0, i32 2
  store i32 %100, ptr %102, align 8, !tbaa !11
  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, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !13, i64 16}
!12 = !{!"iirhilbf_s", !6, i64 0, !6, i64 8, !13, i64 16}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !6, i64 0}
!15 = !{!12, !6, i64 8}


; 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_c2r_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
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #3
  store float 0.000000e+00, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #3
  store float 0.000000e+00, ptr %5, align 4, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = load i32, ptr %6, align 8, !tbaa !9
  switch i32 %7, label %42 [
    i32 0, label %8
    i32 1, label %15
    i32 2, label %24
    i32 3, label %34
  ]

8:                                                ; preds = %3
  %9 = load ptr, ptr %0, align 8, !tbaa !13
  %.sroa.0.0.vec.extract = extractelement <2 x float> %1, i64 0
  %10 = call i32 @iirfilt_rrrf_execute(ptr noundef %9, float noundef %.sroa.0.0.vec.extract, ptr noundef nonnull %4)
  %11 = getelementptr inbounds i8, ptr %0, i64 8
  %12 = load ptr, ptr %11, align 8, !tbaa !14
  %.sroa.0.4.vec.extract30 = extractelement <2 x float> %1, i64 1
  %13 = call i32 @iirfilt_rrrf_execute(ptr noundef %12, float noundef %.sroa.0.4.vec.extract30, ptr noundef nonnull %5)
  %14 = load float, ptr %4, align 4, !tbaa !5
  br label %.sink.split

15:                                               ; preds = %3
  %16 = load ptr, ptr %0, align 8, !tbaa !13
  %.sroa.0.4.vec.extract32 = extractelement <2 x float> %1, i64 1
  %17 = call i32 @iirfilt_rrrf_execute(ptr noundef %16, float noundef %.sroa.0.4.vec.extract32, ptr noundef nonnull %4)
  %18 = getelementptr inbounds i8, ptr %0, i64 8
  %19 = load ptr, ptr %18, align 8, !tbaa !14
  %.sroa.0.0.vec.extract20 = extractelement <2 x float> %1, i64 0
  %20 = fneg float %.sroa.0.0.vec.extract20
  %21 = call i32 @iirfilt_rrrf_execute(ptr noundef %19, float noundef %20, ptr noundef nonnull %5)
  %22 = load float, ptr %5, align 4, !tbaa !5
  %23 = fneg float %22
  br label %.sink.split

24:                                               ; preds = %3
  %25 = load ptr, ptr %0, align 8, !tbaa !13
  %.sroa.0.0.vec.extract22 = extractelement <2 x float> %1, i64 0
  %26 = fneg float %.sroa.0.0.vec.extract22
  %27 = call i32 @iirfilt_rrrf_execute(ptr noundef %25, float noundef %26, ptr noundef nonnull %4)
  %28 = getelementptr inbounds i8, ptr %0, i64 8
  %29 = load ptr, ptr %28, align 8, !tbaa !14
  %.sroa.0.4.vec.extract38 = extractelement <2 x float> %1, i64 1
  %30 = fneg float %.sroa.0.4.vec.extract38
  %31 = call i32 @iirfilt_rrrf_execute(ptr noundef %29, float noundef %30, ptr noundef nonnull %5)
  %32 = load float, ptr %4, align 4, !tbaa !5
  %33 = fneg float %32
  br label %.sink.split

34:                                               ; preds = %3
  %35 = load ptr, ptr %0, align 8, !tbaa !13
  %.sroa.0.4.vec.extract40 = extractelement <2 x float> %1, i64 1
  %36 = fneg float %.sroa.0.4.vec.extract40
  %37 = call i32 @iirfilt_rrrf_execute(ptr noundef %35, float noundef %36, ptr noundef nonnull %4)
  %38 = getelementptr inbounds i8, ptr %0, i64 8
  %39 = load ptr, ptr %38, align 8, !tbaa !14
  %.sroa.0.0.vec.extract28 = extractelement <2 x float> %1, i64 0
  %40 = call i32 @iirfilt_rrrf_execute(ptr noundef %39, float noundef %.sroa.0.0.vec.extract28, ptr noundef nonnull %5)
  %41 = load float, ptr %5, align 4, !tbaa !5
  br label %.sink.split

.sink.split:                                      ; preds = %8, %15, %24, %34
  %.sink = phi float [ %41, %34 ], [ %33, %24 ], [ %23, %15 ], [ %14, %8 ]
  store float %.sink, ptr %2, align 4, !tbaa !5
  br label %42

42:                                               ; preds = %.sink.split, %3
  %43 = load i32, ptr %6, align 8, !tbaa !9
  %44 = add i32 %43, 1
  %45 = and i32 %44, 3
  store i32 %45, ptr %6, align 8, !tbaa !9
  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, !6, i64 0}
!6 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !12, i64 16}
!10 = !{!"iirhilbf_s", !11, i64 0, !11, i64 8, !12, i64 16}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !11, i64 0}
!14 = !{!10, !11, i64 8}


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