; 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_Abs = type { %struct.sig_dsp_Signal, %struct.sig_dsp_Abs_Inputs, %struct.sig_dsp_Signal_SingleMonoOutput }
%struct.sig_dsp_Signal = type { ptr, ptr }
%struct.sig_dsp_Abs_Inputs = type { ptr }
%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: nounwind uwtable
define dso_local void @sig_dsp_Abs_generate(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %7, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  store i64 0, ptr %4, align 8, !tbaa !9
  br label %8

8:                                                ; preds = %35, %1
  %9 = load i64, ptr %4, align 8, !tbaa !9
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.sig_dsp_Abs, ptr %10, i32 0, i32 0
  %12 = getelementptr inbounds %struct.sig_dsp_Signal, ptr %11, i32 0, i32 0
  %13 = load ptr, ptr %12, align 8, !tbaa !11
  %14 = getelementptr inbounds %struct.sig_AudioSettings, ptr %13, i32 0, i32 2
  %15 = load i64, ptr %14, align 8, !tbaa !16
  %16 = icmp ult i64 %9, %15
  br i1 %16, label %18, label %17

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

18:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.sig_dsp_Abs, ptr %19, i32 0, i32 1
  %21 = getelementptr inbounds %struct.sig_dsp_Abs_Inputs, ptr %20, i32 0, i32 0
  %22 = load ptr, ptr %21, align 8, !tbaa !19
  %23 = load i64, ptr %4, align 8, !tbaa !9
  %24 = getelementptr inbounds float, ptr %22, i64 %23
  %25 = load float, ptr %24, align 4, !tbaa !20
  store float %25, ptr %5, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %26 = load float, ptr %5, align 4, !tbaa !20
  %27 = call float @llvm.fabs.f32(float %26)
  store float %27, ptr %6, align 4, !tbaa !20
  %28 = load float, ptr %6, align 4, !tbaa !20
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.sig_dsp_Abs, ptr %29, i32 0, i32 2
  %31 = getelementptr inbounds %struct.sig_dsp_Signal_SingleMonoOutput, ptr %30, i32 0, i32 0
  %32 = load ptr, ptr %31, align 8, !tbaa !21
  %33 = load i64, ptr %4, align 8, !tbaa !9
  %34 = getelementptr inbounds float, ptr %32, i64 %33
  store float %28, ptr %34, align 4, !tbaa !20
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %35

35:                                               ; preds = %18
  %36 = load i64, ptr %4, align 8, !tbaa !9
  %37 = add i64 %36, 1
  store i64 %37, ptr %4, align 8, !tbaa !9
  br label %8, !llvm.loop !22

38:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret void
}

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

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 = { 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 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"sig_dsp_Abs", !13, i64 0, !14, i64 16, !15, i64 24}
!13 = !{!"sig_dsp_Signal", !6, i64 0, !6, i64 8}
!14 = !{!"sig_dsp_Abs_Inputs", !6, i64 0}
!15 = !{!"sig_dsp_Signal_SingleMonoOutput", !6, i64 0}
!16 = !{!17, !10, i64 16}
!17 = !{!"sig_AudioSettings", !18, i64 0, !10, i64 8, !10, i64 16}
!18 = !{!"float", !7, i64 0}
!19 = !{!12, !6, i64 16}
!20 = !{!18, !18, i64 0}
!21 = !{!12, !6, i64 24}
!22 = distinct !{!22, !23}
!23 = !{!"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: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @sig_dsp_Abs_generate(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = load ptr, ptr %0, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %2, i64 16
  %4 = load i64, ptr %3, align 8, !tbaa !13
  %.not = icmp eq i64 %4, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load ptr, ptr %5, align 8, !tbaa !17
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  %8 = load ptr, ptr %7, align 8, !tbaa !18
  %min.iters.check = icmp ult i64 %4, 8
  %9 = ptrtoint ptr %8 to i64
  %10 = ptrtoint ptr %6 to i64
  %11 = sub i64 %9, %10
  %diff.check = icmp ult i64 %11, 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
  %.09.ph = phi i64 [ 0, %.lr.ph ], [ %n.vec, %middle.block ]
  %xtraiter = and i64 %4, 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
  %.09.prol = phi i64 [ %16, %scalar.ph.prol ], [ %.09.ph, %scalar.ph.preheader ]
  %prol.iter = phi i64 [ %prol.iter.next, %scalar.ph.prol ], [ 0, %scalar.ph.preheader ]
  %12 = getelementptr inbounds float, ptr %6, i64 %.09.prol
  %13 = load float, ptr %12, align 4, !tbaa !19
  %14 = tail call float @llvm.fabs.f32(float %13)
  %15 = getelementptr inbounds float, ptr %8, i64 %.09.prol
  store float %14, ptr %15, align 4, !tbaa !19
  %16 = add nuw i64 %.09.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 !20

scalar.ph.prol.loopexit:                          ; preds = %scalar.ph.prol, %scalar.ph.preheader
  %.09.unr = phi i64 [ %.09.ph, %scalar.ph.preheader ], [ %16, %scalar.ph.prol ]
  %17 = sub i64 %.09.ph, %4
  %18 = icmp ugt i64 %17, -4
  br i1 %18, label %._crit_edge, label %scalar.ph

vector.ph:                                        ; preds = %.lr.ph
  %n.vec = and i64 %4, -8
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %19 = getelementptr inbounds float, ptr %6, i64 %index
  %20 = getelementptr inbounds i8, ptr %19, i64 16
  %wide.load = load <4 x float>, ptr %19, align 4, !tbaa !19
  %wide.load10 = load <4 x float>, ptr %20, align 4, !tbaa !19
  %21 = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %wide.load)
  %22 = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %wide.load10)
  %23 = getelementptr inbounds float, ptr %8, i64 %index
  %24 = getelementptr inbounds i8, ptr %23, i64 16
  store <4 x float> %21, ptr %23, align 4, !tbaa !19
  store <4 x float> %22, ptr %24, align 4, !tbaa !19
  %index.next = add nuw i64 %index, 8
  %25 = icmp eq i64 %index.next, %n.vec
  br i1 %25, label %middle.block, label %vector.body, !llvm.loop !22

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %4, %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
  %.09 = phi i64 [ %45, %scalar.ph ], [ %.09.unr, %scalar.ph.prol.loopexit ]
  %26 = getelementptr inbounds float, ptr %6, i64 %.09
  %27 = load float, ptr %26, align 4, !tbaa !19
  %28 = tail call float @llvm.fabs.f32(float %27)
  %29 = getelementptr inbounds float, ptr %8, i64 %.09
  store float %28, ptr %29, align 4, !tbaa !19
  %30 = add nuw i64 %.09, 1
  %31 = getelementptr inbounds float, ptr %6, i64 %30
  %32 = load float, ptr %31, align 4, !tbaa !19
  %33 = tail call float @llvm.fabs.f32(float %32)
  %34 = getelementptr inbounds float, ptr %8, i64 %30
  store float %33, ptr %34, align 4, !tbaa !19
  %35 = add nuw i64 %.09, 2
  %36 = getelementptr inbounds float, ptr %6, i64 %35
  %37 = load float, ptr %36, align 4, !tbaa !19
  %38 = tail call float @llvm.fabs.f32(float %37)
  %39 = getelementptr inbounds float, ptr %8, i64 %35
  store float %38, ptr %39, align 4, !tbaa !19
  %40 = add nuw i64 %.09, 3
  %41 = getelementptr inbounds float, ptr %6, i64 %40
  %42 = load float, ptr %41, align 4, !tbaa !19
  %43 = tail call float @llvm.fabs.f32(float %42)
  %44 = getelementptr inbounds float, ptr %8, i64 %40
  store float %43, ptr %44, align 4, !tbaa !19
  %45 = add nuw i64 %.09, 4
  %exitcond.not.3 = icmp eq i64 %45, %4
  br i1 %exitcond.not.3, label %._crit_edge, label %scalar.ph, !llvm.loop !26
}

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

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !8, i64 0}
!6 = !{!"sig_dsp_Abs", !7, i64 0, !11, i64 16, !12, i64 24}
!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_Abs_Inputs", !8, i64 0}
!12 = !{!"sig_dsp_Signal_SingleMonoOutput", !8, i64 0}
!13 = !{!14, !16, i64 16}
!14 = !{!"sig_AudioSettings", !15, i64 0, !16, i64 8, !16, i64 16}
!15 = !{!"float", !9, i64 0}
!16 = !{!"long", !9, i64 0}
!17 = !{!6, !8, i64 16}
!18 = !{!6, !8, i64 24}
!19 = !{!15, !15, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.unroll.disable"}
!22 = distinct !{!22, !23, !24, !25}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{!"llvm.loop.isvectorized", i32 1}
!25 = !{!"llvm.loop.unroll.runtime.disable"}
!26 = distinct !{!26, !23, !24}


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