; LLVM IR from ClecioJung/digital-control :: digitalControl (filterDiscreet)

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

; Function Attrs: nounwind uwtable
define dso_local void @filterDiscreet(ptr noundef %0, float noundef %1, float noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store float %1, ptr %5, align 4, !tbaa !9
  store float %2, ptr %6, align 4, !tbaa !9
  %7 = load float, ptr %6, align 4, !tbaa !9
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.FirstOrderFilter, ptr %8, i32 0, i32 2
  %10 = load float, ptr %9, align 4, !tbaa !11
  %11 = fmul float %7, %10
  %12 = fpext float %11 to double
  %13 = fsub double 2.000000e+00, %12
  %14 = load float, ptr %6, align 4, !tbaa !9
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.FirstOrderFilter, ptr %15, i32 0, i32 2
  %17 = load float, ptr %16, align 4, !tbaa !11
  %18 = fmul float %14, %17
  %19 = fpext float %18 to double
  %20 = fadd double 2.000000e+00, %19
  %21 = fdiv double %13, %20
  %22 = fptrunc double %21 to float
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.FirstOrderFilter, ptr %23, i32 0, i32 3
  %25 = getelementptr inbounds [3 x float], ptr %24, i64 0, i64 0
  store float %22, ptr %25, align 4, !tbaa !9
  %26 = load float, ptr %6, align 4, !tbaa !9
  %27 = load float, ptr %5, align 4, !tbaa !9
  %28 = fdiv float %26, %27
  %29 = fpext float %28 to double
  %30 = load float, ptr %6, align 4, !tbaa !9
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.FirstOrderFilter, ptr %31, i32 0, i32 2
  %33 = load float, ptr %32, align 4, !tbaa !11
  %34 = fmul float %30, %33
  %35 = fpext float %34 to double
  %36 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %29, double %35)
  %37 = load float, ptr %6, align 4, !tbaa !9
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.FirstOrderFilter, ptr %38, i32 0, i32 2
  %40 = load float, ptr %39, align 4, !tbaa !11
  %41 = fmul float %37, %40
  %42 = fpext float %41 to double
  %43 = fadd double 2.000000e+00, %42
  %44 = fdiv double %36, %43
  %45 = fptrunc double %44 to float
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.FirstOrderFilter, ptr %46, i32 0, i32 3
  %48 = getelementptr inbounds [3 x float], ptr %47, i64 0, i64 1
  store float %45, ptr %48, align 4, !tbaa !9
  %49 = load float, ptr %6, align 4, !tbaa !9
  %50 = load float, ptr %5, align 4, !tbaa !9
  %51 = fdiv float %49, %50
  %52 = fpext float %51 to double
  %53 = load float, ptr %6, align 4, !tbaa !9
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.FirstOrderFilter, ptr %54, i32 0, i32 2
  %56 = load float, ptr %55, align 4, !tbaa !11
  %57 = fmul float %53, %56
  %58 = fpext float %57 to double
  %59 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %52, double %58)
  %60 = load float, ptr %6, align 4, !tbaa !9
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.FirstOrderFilter, ptr %61, i32 0, i32 2
  %63 = load float, ptr %62, align 4, !tbaa !11
  %64 = fmul float %60, %63
  %65 = fpext float %64 to double
  %66 = fadd double 2.000000e+00, %65
  %67 = fdiv double %59, %66
  %68 = fptrunc double %67 to float
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.FirstOrderFilter, ptr %69, i32 0, i32 3
  %71 = getelementptr inbounds [3 x float], ptr %70, i64 0, i64 2
  store float %68, ptr %71, align 4, !tbaa !9
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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" }

!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, !10, i64 8}
!12 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !7, i64 12}


; 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 speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @filterDiscreet(ptr nocapture noundef %0, float noundef %1, float noundef %2) local_unnamed_addr #1 {
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load float, ptr %4, align 4, !tbaa !5
  %6 = fmul float %5, %2
  %7 = fpext float %6 to double
  %8 = fsub double 2.000000e+00, %7
  %9 = fadd double %7, 2.000000e+00
  %10 = getelementptr inbounds i8, ptr %0, i64 12
  %11 = fdiv float %2, %1
  %12 = fpext float %11 to double
  %13 = tail call double @llvm.fmuladd.f64(double %12, double 2.000000e+00, double %7)
  %14 = insertelement <2 x double> poison, double %8, i64 0
  %15 = insertelement <2 x double> %14, double %13, i64 1
  %16 = insertelement <2 x double> poison, double %9, i64 0
  %17 = shufflevector <2 x double> %16, <2 x double> poison, <2 x i32> zeroinitializer
  %18 = fdiv <2 x double> %15, %17
  %19 = fptrunc <2 x double> %18 to <2 x float>
  store <2 x float> %19, ptr %10, align 4, !tbaa !10
  %20 = tail call double @llvm.fmuladd.f64(double %12, double -2.000000e+00, double %7)
  %21 = fdiv double %20, %9
  %22 = fptrunc double %21 to float
  %23 = getelementptr inbounds i8, ptr %0, i64 20
  store float %22, ptr %23, align 4, !tbaa !10
  ret void
}

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

!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 8}
!6 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !8, i64 12}
!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