; 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_ScaleOffset = type { %struct.sig_dsp_Signal, %struct.sig_dsp_ScaleOffset_Inputs, %struct.sig_dsp_ScaleOffset_Parameters, %struct.sig_dsp_Signal_SingleMonoOutput }
%struct.sig_dsp_Signal = type { ptr, ptr }
%struct.sig_dsp_ScaleOffset_Inputs = type { ptr }
%struct.sig_dsp_ScaleOffset_Parameters = type { float, 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

; Function Attrs: nounwind uwtable
define dso_local void @sig_dsp_ScaleOffset_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
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %8, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.sig_dsp_ScaleOffset, ptr %9, i32 0, i32 2
  %11 = getelementptr inbounds %struct.sig_dsp_ScaleOffset_Parameters, ptr %10, i32 0, i32 0
  %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_ScaleOffset, ptr %13, i32 0, i32 2
  %15 = getelementptr inbounds %struct.sig_dsp_ScaleOffset_Parameters, ptr %14, i32 0, i32 1
  %16 = load float, ptr %15, align 4, !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 = %45, %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_ScaleOffset, 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 %48

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_ScaleOffset, ptr %28, i32 0, i32 1
  %30 = getelementptr inbounds %struct.sig_dsp_ScaleOffset_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
  %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 @llvm.fmuladd.f32(float %35, float %36, float %37)
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.sig_dsp_ScaleOffset, ptr %39, i32 0, i32 3
  %41 = getelementptr inbounds %struct.sig_dsp_Signal_SingleMonoOutput, ptr %40, i32 0, i32 0
  %42 = load ptr, ptr %41, align 8, !tbaa !24
  %43 = load i64, ptr %6, align 8, !tbaa !18
  %44 = getelementptr inbounds float, ptr %42, i64 %43
  store float %38, ptr %44, align 4, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %45

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

48:                                               ; preds = %26
  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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 24}
!10 = !{!"sig_dsp_ScaleOffset", !11, i64 0, !12, i64 16, !13, i64 24, !15, i64 32}
!11 = !{!"sig_dsp_Signal", !6, i64 0, !6, i64 8}
!12 = !{!"sig_dsp_ScaleOffset_Inputs", !6, i64 0}
!13 = !{!"sig_dsp_ScaleOffset_Parameters", !14, i64 0, !14, i64 4}
!14 = !{!"float", !7, i64 0}
!15 = !{!"sig_dsp_Signal_SingleMonoOutput", !6, i64 0}
!16 = !{!14, !14, i64 0}
!17 = !{!10, !14, i64 28}
!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: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #0

; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @sig_dsp_ScaleOffset_generate(ptr nocapture noundef readonly %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 24
  %3 = load float, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 28
  %5 = load float, ptr %4, align 4, !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 = load ptr, ptr %9, align 8, !tbaa !20
  %11 = getelementptr inbounds i8, ptr %0, i64 32
  %12 = load ptr, ptr %11, align 8, !tbaa !21
  %min.iters.check = icmp ult i64 %8, 8
  %13 = ptrtoint ptr %12 to i64
  %14 = ptrtoint ptr %10 to i64
  %15 = sub i64 %13, %14
  %diff.check = icmp ult i64 %15, 32
  %or.cond = select i1 %min.iters.check, i1 true, i1 %diff.check
  br i1 %or.cond, label %scalar.ph.preheader, label %vector.ph

scalar.ph.preheader:                              ; preds = %middle.block, %.lr.ph
  %.012.ph = phi i64 [ 0, %.lr.ph ], [ %n.vec, %middle.block ]
  %xtraiter = and i64 %8, 3
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %scalar.ph.prol.loopexit, label %scalar.ph.prol

scalar.ph.prol:                                   ; preds = %scalar.ph.preheader, %scalar.ph.prol
  %.012.prol = phi i64 [ %20, %scalar.ph.prol ], [ %.012.ph, %scalar.ph.preheader ]
  %prol.iter = phi i64 [ %prol.iter.next, %scalar.ph.prol ], [ 0, %scalar.ph.preheader ]
  %16 = getelementptr inbounds float, ptr %10, i64 %.012.prol
  %17 = load float, ptr %16, align 4, !tbaa !22
  %18 = tail call float @llvm.fmuladd.f32(float %17, float %3, float %5)
  %19 = getelementptr inbounds float, ptr %12, i64 %.012.prol
  store float %18, ptr %19, align 4, !tbaa !22
  %20 = add nuw i64 %.012.prol, 1
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %scalar.ph.prol.loopexit, label %scalar.ph.prol, !llvm.loop !23

scalar.ph.prol.loopexit:                          ; preds = %scalar.ph.prol, %scalar.ph.preheader
  %.012.unr = phi i64 [ %.012.ph, %scalar.ph.preheader ], [ %20, %scalar.ph.prol ]
  %21 = sub i64 %.012.ph, %8
  %22 = icmp ugt i64 %21, -4
  br i1 %22, label %._crit_edge, label %scalar.ph

vector.ph:                                        ; preds = %.lr.ph
  %n.vec = and i64 %8, -8
  %broadcast.splatinsert = insertelement <4 x float> poison, float %3, i64 0
  %broadcast.splat = shufflevector <4 x float> %broadcast.splatinsert, <4 x float> poison, <4 x i32> zeroinitializer
  %broadcast.splatinsert14 = insertelement <4 x float> poison, float %5, i64 0
  %broadcast.splat15 = shufflevector <4 x float> %broadcast.splatinsert14, <4 x float> poison, <4 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %23 = getelementptr inbounds float, ptr %10, i64 %index
  %24 = getelementptr inbounds i8, ptr %23, i64 16
  %wide.load = load <4 x float>, ptr %23, align 4, !tbaa !22
  %wide.load13 = load <4 x float>, ptr %24, align 4, !tbaa !22
  %25 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %wide.load, <4 x float> %broadcast.splat, <4 x float> %broadcast.splat15)
  %26 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %wide.load13, <4 x float> %broadcast.splat, <4 x float> %broadcast.splat15)
  %27 = getelementptr inbounds float, ptr %12, i64 %index
  %28 = getelementptr inbounds i8, ptr %27, i64 16
  store <4 x float> %25, ptr %27, align 4, !tbaa !22
  store <4 x float> %26, ptr %28, align 4, !tbaa !22
  %index.next = add nuw i64 %index, 8
  %29 = icmp eq i64 %index.next, %n.vec
  br i1 %29, label %middle.block, label %vector.body, !llvm.loop !25

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %8, %n.vec
  br i1 %cmp.n, label %._crit_edge, label %scalar.ph.preheader

._crit_edge:                                      ; preds = %scalar.ph.prol.loopexit, %scalar.ph, %middle.block, %1
  ret void

scalar.ph:                                        ; preds = %scalar.ph.prol.loopexit, %scalar.ph
  %.012 = phi i64 [ %49, %scalar.ph ], [ %.012.unr, %scalar.ph.prol.loopexit ]
  %30 = getelementptr inbounds float, ptr %10, i64 %.012
  %31 = load float, ptr %30, align 4, !tbaa !22
  %32 = tail call float @llvm.fmuladd.f32(float %31, float %3, float %5)
  %33 = getelementptr inbounds float, ptr %12, i64 %.012
  store float %32, ptr %33, align 4, !tbaa !22
  %34 = add nuw i64 %.012, 1
  %35 = getelementptr inbounds float, ptr %10, i64 %34
  %36 = load float, ptr %35, align 4, !tbaa !22
  %37 = tail call float @llvm.fmuladd.f32(float %36, float %3, float %5)
  %38 = getelementptr inbounds float, ptr %12, i64 %34
  store float %37, ptr %38, align 4, !tbaa !22
  %39 = add nuw i64 %.012, 2
  %40 = getelementptr inbounds float, ptr %10, i64 %39
  %41 = load float, ptr %40, align 4, !tbaa !22
  %42 = tail call float @llvm.fmuladd.f32(float %41, float %3, float %5)
  %43 = getelementptr inbounds float, ptr %12, i64 %39
  store float %42, ptr %43, align 4, !tbaa !22
  %44 = add nuw i64 %.012, 3
  %45 = getelementptr inbounds float, ptr %10, i64 %44
  %46 = load float, ptr %45, align 4, !tbaa !22
  %47 = tail call float @llvm.fmuladd.f32(float %46, float %3, float %5)
  %48 = getelementptr inbounds float, ptr %12, i64 %44
  store float %47, ptr %48, align 4, !tbaa !22
  %49 = add nuw i64 %.012, 4
  %exitcond.not.3 = icmp eq i64 %49, %8
  br i1 %exitcond.not.3, label %._crit_edge, label %scalar.ph, !llvm.loop !29
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <4 x float> @llvm.fmuladd.v4f32(<4 x float>, <4 x float>, <4 x float>) #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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 = { 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, !13, i64 24}
!6 = !{!"sig_dsp_ScaleOffset", !7, i64 0, !11, i64 16, !12, i64 24, !14, i64 32}
!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_ScaleOffset_Inputs", !8, i64 0}
!12 = !{!"sig_dsp_ScaleOffset_Parameters", !13, i64 0, !13, i64 4}
!13 = !{!"float", !9, i64 0}
!14 = !{!"sig_dsp_Signal_SingleMonoOutput", !8, i64 0}
!15 = !{!6, !13, i64 28}
!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 = !{!6, !8, i64 32}
!22 = !{!13, !13, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.unroll.disable"}
!25 = distinct !{!25, !26, !27, !28}
!26 = !{!"llvm.loop.mustprogress"}
!27 = !{!"llvm.loop.isvectorized", i32 1}
!28 = !{!"llvm.loop.unroll.runtime.disable"}
!29 = distinct !{!29, !26, !27}


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