; 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_decim_execute(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %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
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, 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) #2
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.iirhilbf_s, ptr %13, i32 0, i32 2
  %15 = load i32, ptr %14, align 8, !tbaa !9
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %17, label %22

17:                                               ; preds = %3
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds float, ptr %18, i64 0
  %20 = load float, ptr %19, align 4, !tbaa !12
  %21 = fneg float %20
  br label %26

22:                                               ; preds = %3
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds float, ptr %23, i64 0
  %25 = load float, ptr %24, align 4, !tbaa !12
  br label %26

26:                                               ; preds = %22, %17
  %27 = phi float [ %21, %17 ], [ %25, %22 ]
  store float %27, ptr %7, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.iirhilbf_s, ptr %28, i32 0, i32 2
  %30 = load i32, ptr %29, align 8, !tbaa !9
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %32, label %36

32:                                               ; preds = %26
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds float, ptr %33, i64 1
  %35 = load float, ptr %34, align 4, !tbaa !12
  br label %41

36:                                               ; preds = %26
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds float, ptr %37, i64 1
  %39 = load float, ptr %38, align 4, !tbaa !12
  %40 = fneg float %39
  br label %41

41:                                               ; preds = %36, %32
  %42 = phi float [ %35, %32 ], [ %40, %36 ]
  store float %42, ptr %8, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.iirhilbf_s, ptr %43, i32 0, i32 0
  %45 = load ptr, ptr %44, align 8, !tbaa !14
  %46 = load float, ptr %7, align 4, !tbaa !12
  %47 = call i32 @iirfilt_rrrf_execute(ptr noundef %45, float noundef %46, ptr noundef %9)
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.iirhilbf_s, ptr %48, i32 0, i32 0
  %50 = load ptr, ptr %49, align 8, !tbaa !14
  %51 = call i32 @iirfilt_rrrf_execute(ptr noundef %50, float noundef 0.000000e+00, ptr noundef %10)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.iirhilbf_s, ptr %52, i32 0, i32 1
  %54 = load ptr, ptr %53, align 8, !tbaa !15
  %55 = call i32 @iirfilt_rrrf_execute(ptr noundef %54, float noundef 0.000000e+00, ptr noundef %11)
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.iirhilbf_s, ptr %56, i32 0, i32 1
  %58 = load ptr, ptr %57, align 8, !tbaa !15
  %59 = load float, ptr %8, align 4, !tbaa !12
  %60 = call i32 @iirfilt_rrrf_execute(ptr noundef %58, float noundef %59, ptr noundef %12)
  %61 = load float, ptr %9, align 4, !tbaa !12
  %62 = load float, ptr %11, align 4, !tbaa !12
  %63 = fmul float 0.000000e+00, %62
  %64 = fmul float 1.000000e+00, %62
  %65 = fadd float %61, %63
  %66 = fmul float 2.000000e+00, %65
  %67 = fmul float 2.000000e+00, %64
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = getelementptr inbounds { float, float }, ptr %68, i32 0, i32 0
  %70 = getelementptr inbounds { float, float }, ptr %68, i32 0, i32 1
  store float %66, ptr %69, align 4
  store float %67, ptr %70, align 4
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.iirhilbf_s, ptr %71, i32 0, i32 2
  %73 = load i32, ptr %72, align 8, !tbaa !9
  %74 = sub i32 1, %73
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.iirhilbf_s, ptr %75, i32 0, i32 2
  store i32 %74, ptr %76, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  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, !11, i64 16}
!10 = !{!"iirhilbf_s", !6, i64 0, !6, i64 8, !11, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"float", !7, i64 0}
!14 = !{!10, !6, i64 0}
!15 = !{!10, !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_decim_execute(ptr nocapture noundef %0, ptr nocapture noundef readonly %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #1 {
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  %9 = load i32, ptr %8, align 8, !tbaa !5
  %.not = icmp eq i32 %9, 0
  %10 = load float, ptr %1, align 4, !tbaa !11
  br i1 %.not, label %15, label %11

11:                                               ; preds = %3
  %12 = fneg float %10
  %13 = getelementptr inbounds i8, ptr %1, i64 4
  %14 = load float, ptr %13, align 4, !tbaa !11
  br label %19

15:                                               ; preds = %3
  %16 = getelementptr inbounds i8, ptr %1, i64 4
  %17 = load float, ptr %16, align 4, !tbaa !11
  %18 = fneg float %17
  br label %19

19:                                               ; preds = %15, %11
  %20 = phi float [ %12, %11 ], [ %10, %15 ]
  %21 = phi float [ %14, %11 ], [ %18, %15 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #2
  %22 = load ptr, ptr %0, align 8, !tbaa !13
  %23 = call i32 @iirfilt_rrrf_execute(ptr noundef %22, float noundef %20, ptr noundef nonnull %4)
  %24 = load ptr, ptr %0, align 8, !tbaa !13
  %25 = call i32 @iirfilt_rrrf_execute(ptr noundef %24, float noundef 0.000000e+00, ptr noundef nonnull %5)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #2
  %26 = getelementptr inbounds i8, ptr %0, i64 8
  %27 = load ptr, ptr %26, align 8, !tbaa !14
  %28 = call i32 @iirfilt_rrrf_execute(ptr noundef %27, float noundef 0.000000e+00, ptr noundef nonnull %6)
  %29 = load ptr, ptr %26, align 8, !tbaa !14
  %30 = call i32 @iirfilt_rrrf_execute(ptr noundef %29, float noundef %21, ptr noundef nonnull %7)
  %31 = load float, ptr %4, align 4, !tbaa !11
  %32 = load float, ptr %6, align 4, !tbaa !11
  %33 = fmul float %32, 0.000000e+00
  %34 = fadd float %31, %33
  %35 = insertelement <2 x float> poison, float %34, i64 0
  %36 = insertelement <2 x float> %35, float %32, i64 1
  %37 = fmul <2 x float> %36, <float 2.000000e+00, float 2.000000e+00>
  store <2 x float> %37, ptr %2, align 4
  %38 = load i32, ptr %8, align 8, !tbaa !5
  %39 = sub i32 1, %38
  store i32 %39, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #2
  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, !10, i64 16}
!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 = !{!12, !12, i64 0}
!12 = !{!"float", !8, i64 0}
!13 = !{!6, !7, i64 0}
!14 = !{!6, !7, i64 8}


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