; LLVM IR from lichen-community-systems/signaletic :: libsignaletic/src (libsignaletic)

; 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.sig_dsp_EMA = type { %struct.sig_dsp_Signal, %struct.sig_dsp_EMA_Inputs, %struct.sig_dsp_EMA_Parameters, %struct.sig_dsp_Signal_SingleMonoOutput, float }
%struct.sig_dsp_Signal = type { ptr, ptr }
%struct.sig_dsp_EMA_Inputs = type { ptr }
%struct.sig_dsp_EMA_Parameters = type { float }
%struct.sig_dsp_Signal_SingleMonoOutput = type { ptr }
%struct.sig_AudioSettings = type { float, i64, i64 }

; 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: inlinehint nounwind uwtable
declare dso_local float @sig_filter_ema(float noundef, float noundef, float noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @sig_dsp_EMA_generate(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca i64, align 8
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %9, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.sig_dsp_EMA, ptr %10, i32 0, i32 4
  %12 = load float, ptr %11, align 8, !tbaa !9
  store float %12, ptr %4, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.sig_dsp_EMA, ptr %13, i32 0, i32 2
  %15 = getelementptr inbounds %struct.sig_dsp_EMA_Parameters, ptr %14, i32 0, i32 0
  %16 = load float, ptr %15, align 8, !tbaa !17
  store float %16, ptr %5, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store i64 0, ptr %6, align 8, !tbaa !18
  br label %17

17:                                               ; preds = %47, %1
  %18 = load i64, ptr %6, align 8, !tbaa !18
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.sig_dsp_EMA, ptr %19, i32 0, i32 0
  %21 = getelementptr inbounds %struct.sig_dsp_Signal, ptr %20, i32 0, i32 0
  %22 = load ptr, ptr %21, align 8, !tbaa !20
  %23 = getelementptr inbounds %struct.sig_AudioSettings, ptr %22, i32 0, i32 2
  %24 = load i64, ptr %23, align 8, !tbaa !21
  %25 = icmp ult i64 %18, %24
  br i1 %25, label %27, label %26

26:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %50

27:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.sig_dsp_EMA, ptr %28, i32 0, i32 1
  %30 = getelementptr inbounds %struct.sig_dsp_EMA_Inputs, ptr %29, i32 0, i32 0
  %31 = load ptr, ptr %30, align 8, !tbaa !23
  %32 = load i64, ptr %6, align 8, !tbaa !18
  %33 = getelementptr inbounds float, ptr %31, i64 %32
  %34 = load float, ptr %33, align 4, !tbaa !16
  store float %34, ptr %7, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %35 = load float, ptr %7, align 4, !tbaa !16
  %36 = load float, ptr %4, align 4, !tbaa !16
  %37 = load float, ptr %5, align 4, !tbaa !16
  %38 = call float @sig_filter_ema(float noundef %35, float noundef %36, float noundef %37)
  store float %38, ptr %8, align 4, !tbaa !16
  %39 = load float, ptr %8, align 4, !tbaa !16
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.sig_dsp_EMA, ptr %40, i32 0, i32 3
  %42 = getelementptr inbounds %struct.sig_dsp_Signal_SingleMonoOutput, ptr %41, i32 0, i32 0
  %43 = load ptr, ptr %42, align 8, !tbaa !24
  %44 = load i64, ptr %6, align 8, !tbaa !18
  %45 = getelementptr inbounds float, ptr %43, i64 %44
  store float %39, ptr %45, align 4, !tbaa !16
  %46 = load float, ptr %8, align 4, !tbaa !16
  store float %46, ptr %4, align 4, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %47

47:                                               ; preds = %27
  %48 = load i64, ptr %6, align 8, !tbaa !18
  %49 = add i64 %48, 1
  store i64 %49, ptr %6, align 8, !tbaa !18
  br label %17, !llvm.loop !25

50:                                               ; preds = %26
  %51 = load float, ptr %4, align 4, !tbaa !16
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.sig_dsp_EMA, ptr %52, i32 0, i32 4
  store float %51, ptr %53, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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"="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 #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, !14, i64 40}
!10 = !{!"sig_dsp_EMA", !11, i64 0, !12, i64 16, !13, i64 24, !15, i64 32, !14, i64 40}
!11 = !{!"sig_dsp_Signal", !6, i64 0, !6, i64 8}
!12 = !{!"sig_dsp_EMA_Inputs", !6, i64 0}
!13 = !{!"sig_dsp_EMA_Parameters", !14, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = !{!"sig_dsp_Signal_SingleMonoOutput", !6, i64 0}
!16 = !{!14, !14, i64 0}
!17 = !{!10, !14, i64 24}
!18 = !{!19, !19, i64 0}
!19 = !{!"long", !7, i64 0}
!20 = !{!10, !6, i64 0}
!21 = !{!22, !19, i64 16}
!22 = !{!"sig_AudioSettings", !14, i64 0, !19, i64 8, !19, i64 16}
!23 = !{!10, !6, i64 16}
!24 = !{!10, !6, i64 32}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}


; 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: inlinehint nounwind uwtable
declare dso_local float @sig_filter_ema(float noundef, float noundef, float noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @sig_dsp_EMA_generate(ptr nocapture noundef %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 40
  %3 = load float, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 24
  %5 = load float, ptr %4, align 8, !tbaa !15
  %6 = load ptr, ptr %0, align 8, !tbaa !16
  %7 = getelementptr inbounds i8, ptr %6, i64 16
  %8 = load i64, ptr %7, align 8, !tbaa !17
  %.not = icmp eq i64 %8, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  %10 = getelementptr inbounds i8, ptr %0, i64 32
  br label %11

._crit_edge:                                      ; preds = %11, %1
  %.0.lcssa = phi float [ %3, %1 ], [ %15, %11 ]
  store float %.0.lcssa, ptr %2, align 8, !tbaa !5
  ret void

11:                                               ; preds = %.lr.ph, %11
  %.018 = phi float [ %3, %.lr.ph ], [ %15, %11 ]
  %.01617 = phi i64 [ 0, %.lr.ph ], [ %18, %11 ]
  %12 = load ptr, ptr %9, align 8, !tbaa !20
  %13 = getelementptr inbounds float, ptr %12, i64 %.01617
  %14 = load float, ptr %13, align 4, !tbaa !21
  %15 = tail call float @sig_filter_ema(float noundef %14, float noundef %.018, float noundef %5)
  %16 = load ptr, ptr %10, align 8, !tbaa !22
  %17 = getelementptr inbounds float, ptr %16, i64 %.01617
  store float %15, ptr %17, align 4, !tbaa !21
  %18 = add nuw i64 %.01617, 1
  %19 = load ptr, ptr %0, align 8, !tbaa !16
  %20 = getelementptr inbounds i8, ptr %19, i64 16
  %21 = load i64, ptr %20, align 8, !tbaa !17
  %22 = icmp ult i64 %18, %21
  br i1 %22, label %11, label %._crit_edge, !llvm.loop !23
}

attributes #0 = { inlinehint 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 = { 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, !13, i64 40}
!6 = !{!"sig_dsp_EMA", !7, i64 0, !11, i64 16, !12, i64 24, !14, i64 32, !13, i64 40}
!7 = !{!"sig_dsp_Signal", !8, i64 0, !8, i64 8}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"sig_dsp_EMA_Inputs", !8, i64 0}
!12 = !{!"sig_dsp_EMA_Parameters", !13, i64 0}
!13 = !{!"float", !9, i64 0}
!14 = !{!"sig_dsp_Signal_SingleMonoOutput", !8, i64 0}
!15 = !{!6, !13, i64 24}
!16 = !{!6, !8, i64 0}
!17 = !{!18, !19, i64 16}
!18 = !{!"sig_AudioSettings", !13, i64 0, !19, i64 8, !19, i64 16}
!19 = !{!"long", !9, i64 0}
!20 = !{!6, !8, i64 16}
!21 = !{!13, !13, i64 0}
!22 = !{!6, !8, i64 32}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass