; LLVM IR from pms67/HadesFCS :: Firmware/F4Quad/Core/Src (LowPassFilter)

; 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.LPFTwoPole = type { float, [2 x float], float, [2 x float] }

; Function Attrs: nounwind uwtable
define dso_local void @LPFTwoPole_Init(ptr noundef %0, i8 noundef zeroext %1, float noundef %2, float noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i8 %1, ptr %6, align 1, !tbaa !9
  store float %2, ptr %7, align 4, !tbaa !10
  store float %3, ptr %8, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %10 = load float, ptr %7, align 4, !tbaa !10
  %11 = fmul float 0x401921FB60000000, %10
  store float %11, ptr %9, align 4, !tbaa !10
  %12 = load i8, ptr %6, align 1, !tbaa !9
  %13 = zext i8 %12 to i32
  %14 = icmp eq i32 %13, 1
  br i1 %14, label %15, label %46

15:                                               ; preds = %4
  %16 = load float, ptr %9, align 4, !tbaa !10
  %17 = fmul float 0x3FF9F41F20000000, %16
  %18 = load float, ptr %9, align 4, !tbaa !10
  %19 = fmul float %17, %18
  %20 = load float, ptr %8, align 4, !tbaa !10
  %21 = fmul float %19, %20
  %22 = load float, ptr %8, align 4, !tbaa !10
  %23 = fmul float %21, %22
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.LPFTwoPole, ptr %24, i32 0, i32 2
  store float %23, ptr %25, align 4, !tbaa !12
  %26 = load float, ptr %9, align 4, !tbaa !10
  %27 = fmul float 0x4001A5E360000000, %26
  %28 = load float, ptr %8, align 4, !tbaa !10
  %29 = call float @llvm.fmuladd.f32(float %27, float %28, float 1.000000e+00)
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.LPFTwoPole, ptr %30, i32 0, i32 2
  %32 = load float, ptr %31, align 4, !tbaa !12
  %33 = fadd float %29, %32
  %34 = fdiv float 1.000000e+00, %33
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.LPFTwoPole, ptr %35, i32 0, i32 3
  %37 = getelementptr inbounds [2 x float], ptr %36, i64 0, i64 0
  store float %34, ptr %37, align 4, !tbaa !10
  %38 = load float, ptr %9, align 4, !tbaa !10
  %39 = fmul float 0x4001A5E360000000, %38
  %40 = load float, ptr %8, align 4, !tbaa !10
  %41 = call float @llvm.fmuladd.f32(float %39, float %40, float 2.000000e+00)
  %42 = fneg float %41
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.LPFTwoPole, ptr %43, i32 0, i32 3
  %45 = getelementptr inbounds [2 x float], ptr %44, i64 0, i64 1
  store float %42, ptr %45, align 4, !tbaa !10
  br label %46

46:                                               ; preds = %15, %4
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.LPFTwoPole, ptr %47, i32 0, i32 1
  %49 = getelementptr inbounds [2 x float], ptr %48, i64 0, i64 0
  store float 0.000000e+00, ptr %49, align 4, !tbaa !10
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.LPFTwoPole, ptr %50, i32 0, i32 1
  %52 = getelementptr inbounds [2 x float], ptr %51, i64 0, i64 1
  store float 0.000000e+00, ptr %52, align 4, !tbaa !10
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.LPFTwoPole, ptr %53, i32 0, i32 0
  store float 0.000000e+00, ptr %54, align 4, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"float", !7, i64 0}
!12 = !{!13, !11, i64 12}
!13 = !{!"", !11, i64 0, !7, i64 4, !11, i64 12, !7, i64 16}
!14 = !{!13, !11, 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 nofree norecurse nosync nounwind willreturn memory(argmem: write) uwtable
define dso_local void @LPFTwoPole_Init(ptr nocapture noundef writeonly %0, i8 noundef zeroext %1, float noundef %2, float noundef %3) local_unnamed_addr #0 {
  %5 = icmp eq i8 %1, 1
  br i1 %5, label %6, label %21

6:                                                ; preds = %4
  %7 = fmul float %2, 0x401921FB60000000
  %8 = fmul float %7, 0x3FF9F41F20000000
  %9 = fmul float %7, %8
  %10 = fmul float %9, %3
  %11 = fmul float %10, %3
  %12 = getelementptr inbounds i8, ptr %0, i64 12
  store float %11, ptr %12, align 4, !tbaa !5
  %13 = fmul float %7, 0x4001A5E360000000
  %14 = tail call float @llvm.fmuladd.f32(float %13, float %3, float 1.000000e+00)
  %15 = fadd float %14, %11
  %16 = fdiv float 1.000000e+00, %15
  %17 = getelementptr inbounds i8, ptr %0, i64 16
  store float %16, ptr %17, align 4, !tbaa !10
  %18 = tail call float @llvm.fmuladd.f32(float %13, float %3, float 2.000000e+00)
  %19 = fneg float %18
  %20 = getelementptr inbounds i8, ptr %0, i64 20
  store float %19, ptr %20, align 4, !tbaa !10
  br label %21

21:                                               ; preds = %6, %4
  %22 = getelementptr inbounds i8, ptr %0, i64 8
  store float 0.000000e+00, ptr %22, align 4, !tbaa !10
  store <2 x float> zeroinitializer, ptr %0, align 4, !tbaa !10
  ret void
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) 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 #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 12}
!6 = !{!"", !7, i64 0, !8, i64 4, !7, i64 12, !8, i64 16}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!7, !7, i64 0}


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