; 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_r2c_execute(ptr noundef %0, float noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca ptr, align 8
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store float %1, ptr %5, align 4, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  store float 0.000000e+00, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  store float 0.000000e+00, ptr %8, align 4, !tbaa !9
  %9 = load ptr, ptr %4, 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 %98 [
    i32 0, label %12
    i32 1, label %32
    i32 2, label %54
    i32 3, label %77
  ]

12:                                               ; preds = %3
  %13 = load ptr, ptr %4, 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 = load float, ptr %5, align 4, !tbaa !9
  %17 = call i32 @iirfilt_rrrf_execute(ptr noundef %15, float noundef %16, ptr noundef %7)
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.iirhilbf_s, ptr %18, i32 0, i32 1
  %20 = load ptr, ptr %19, align 8, !tbaa !15
  %21 = call i32 @iirfilt_rrrf_execute(ptr noundef %20, float noundef 0.000000e+00, ptr noundef %8)
  %22 = load float, ptr %7, align 4, !tbaa !9
  %23 = load float, ptr %8, align 4, !tbaa !9
  %24 = fmul float 0.000000e+00, %23
  %25 = fmul float 1.000000e+00, %23
  %26 = fadd float %22, %24
  %27 = fmul float 2.000000e+00, %26
  %28 = fmul float 2.000000e+00, %25
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = getelementptr inbounds { float, float }, ptr %29, i32 0, i32 0
  %31 = getelementptr inbounds { float, float }, ptr %29, i32 0, i32 1
  store float %27, ptr %30, align 4
  store float %28, ptr %31, align 4
  br label %99

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

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

77:                                               ; preds = %3
  %78 = load ptr, ptr %4, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.iirhilbf_s, ptr %78, i32 0, i32 0
  %80 = load ptr, ptr %79, align 8, !tbaa !14
  %81 = call i32 @iirfilt_rrrf_execute(ptr noundef %80, float noundef 0.000000e+00, ptr noundef %7)
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.iirhilbf_s, ptr %82, i32 0, i32 1
  %84 = load ptr, ptr %83, align 8, !tbaa !15
  %85 = load float, ptr %5, align 4, !tbaa !9
  %86 = call i32 @iirfilt_rrrf_execute(ptr noundef %84, float noundef %85, ptr noundef %8)
  %87 = load float, ptr %8, align 4, !tbaa !9
  %88 = load float, ptr %7, align 4, !tbaa !9
  %89 = fmul float 0.000000e+00, %88
  %90 = fmul float 1.000000e+00, %88
  %91 = fsub float %87, %89
  %92 = fneg float %90
  %93 = fmul float 2.000000e+00, %91
  %94 = fmul float 2.000000e+00, %92
  %95 = load ptr, ptr %6, align 8, !tbaa !5
  %96 = getelementptr inbounds { float, float }, ptr %95, i32 0, i32 0
  %97 = getelementptr inbounds { float, float }, ptr %95, i32 0, i32 1
  store float %93, ptr %96, align 4
  store float %94, ptr %97, align 4
  br label %99

98:                                               ; preds = %3
  br label %99

99:                                               ; preds = %98, %77, %54, %32, %12
  %100 = load ptr, ptr %4, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.iirhilbf_s, ptr %100, i32 0, i32 2
  %102 = load i32, ptr %101, align 8, !tbaa !11
  %103 = add i32 %102, 1
  %104 = and i32 %103, 3
  %105 = load ptr, ptr %4, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.iirhilbf_s, ptr %105, i32 0, i32 2
  store i32 %104, ptr %106, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  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 }

!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_r2c_execute(ptr nocapture noundef %0, float noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #1 {
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #2
  store float 0.000000e+00, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #2
  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 %56 [
    i32 0, label %8
    i32 1, label %19
    i32 2, label %31
    i32 3, label %44
  ]

8:                                                ; preds = %3
  %9 = load ptr, ptr %0, align 8, !tbaa !13
  %10 = call i32 @iirfilt_rrrf_execute(ptr noundef %9, float noundef %1, ptr noundef nonnull %4)
  %11 = getelementptr inbounds i8, ptr %0, i64 8
  %12 = load ptr, ptr %11, align 8, !tbaa !14
  %13 = call i32 @iirfilt_rrrf_execute(ptr noundef %12, float noundef 0.000000e+00, ptr noundef nonnull %5)
  %14 = load float, ptr %4, align 4, !tbaa !5
  %15 = load float, ptr %5, align 4, !tbaa !5
  %16 = fmul float %15, 0.000000e+00
  %17 = fadd float %14, %16
  %18 = fmul float %15, 2.000000e+00
  br label %.sink.split

19:                                               ; preds = %3
  %20 = load ptr, ptr %0, align 8, !tbaa !13
  %21 = call i32 @iirfilt_rrrf_execute(ptr noundef %20, float noundef 0.000000e+00, ptr noundef nonnull %4)
  %22 = getelementptr inbounds i8, ptr %0, i64 8
  %23 = load ptr, ptr %22, align 8, !tbaa !14
  %24 = fneg float %1
  %25 = call i32 @iirfilt_rrrf_execute(ptr noundef %23, float noundef %24, ptr noundef nonnull %5)
  %26 = load float, ptr %5, align 4, !tbaa !5
  %27 = load float, ptr %4, align 4, !tbaa !5
  %28 = fmul float %27, 0.000000e+00
  %29 = fsub float %28, %26
  %30 = fmul float %27, 2.000000e+00
  br label %.sink.split

31:                                               ; preds = %3
  %32 = load ptr, ptr %0, align 8, !tbaa !13
  %33 = fneg float %1
  %34 = call i32 @iirfilt_rrrf_execute(ptr noundef %32, float noundef %33, ptr noundef nonnull %4)
  %35 = getelementptr inbounds i8, ptr %0, i64 8
  %36 = load ptr, ptr %35, align 8, !tbaa !14
  %37 = call i32 @iirfilt_rrrf_execute(ptr noundef %36, float noundef 0.000000e+00, ptr noundef nonnull %5)
  %38 = load float, ptr %4, align 4, !tbaa !5
  %39 = fneg float %38
  %40 = load float, ptr %5, align 4, !tbaa !5
  %41 = fmul float %40, 0.000000e+00
  %42 = fsub float %39, %41
  %43 = fmul float %40, -2.000000e+00
  br label %.sink.split

44:                                               ; preds = %3
  %45 = load ptr, ptr %0, align 8, !tbaa !13
  %46 = call i32 @iirfilt_rrrf_execute(ptr noundef %45, float noundef 0.000000e+00, ptr noundef nonnull %4)
  %47 = getelementptr inbounds i8, ptr %0, i64 8
  %48 = load ptr, ptr %47, align 8, !tbaa !14
  %49 = call i32 @iirfilt_rrrf_execute(ptr noundef %48, float noundef %1, ptr noundef nonnull %5)
  %50 = load float, ptr %5, align 4, !tbaa !5
  %51 = load float, ptr %4, align 4, !tbaa !5
  %52 = fmul float %51, 0.000000e+00
  %53 = fsub float %50, %52
  %54 = fmul float %51, -2.000000e+00
  br label %.sink.split

.sink.split:                                      ; preds = %8, %19, %31, %44
  %.sink20.in = phi float [ %53, %44 ], [ %42, %31 ], [ %29, %19 ], [ %17, %8 ]
  %.sink = phi float [ %54, %44 ], [ %43, %31 ], [ %30, %19 ], [ %18, %8 ]
  %.sink20 = fmul float %.sink20.in, 2.000000e+00
  %55 = getelementptr inbounds i8, ptr %2, i64 4
  store float %.sink20, ptr %2, align 4
  store float %.sink, ptr %55, align 4
  br label %56

56:                                               ; preds = %.sink.split, %3
  %57 = load i32, ptr %6, align 8, !tbaa !9
  %58 = add i32 %57, 1
  %59 = and i32 %58, 3
  store i32 %59, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #2
  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 }

!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