; 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_Value = type { %struct.sig_dsp_Signal, %struct.sig_dsp_Value_Parameters, %struct.sig_dsp_Signal_SingleMonoOutput, float }
%struct.sig_dsp_Signal = type { ptr, ptr }
%struct.sig_dsp_Value_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: nounwind uwtable
define dso_local void @sig_dsp_Value_generate(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %6, ptr %3, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.sig_dsp_Value, ptr %7, i32 0, i32 1
  %9 = getelementptr inbounds %struct.sig_dsp_Value_Parameters, ptr %8, i32 0, i32 0
  %10 = load float, ptr %9, align 8, !tbaa !9
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.sig_dsp_Value, ptr %11, i32 0, i32 3
  %13 = load float, ptr %12, align 8, !tbaa !15
  %14 = fcmp oeq float %10, %13
  br i1 %14, label %15, label %16

15:                                               ; preds = %1
  store i32 1, ptr %4, align 4
  br label %48

16:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  store i64 0, ptr %5, align 8, !tbaa !16
  br label %17

17:                                               ; preds = %38, %16
  %18 = load i64, ptr %5, align 8, !tbaa !16
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.sig_dsp_Value, 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 !18
  %23 = getelementptr inbounds %struct.sig_AudioSettings, ptr %22, i32 0, i32 2
  %24 = load i64, ptr %23, align 8, !tbaa !19
  %25 = icmp ult i64 %18, %24
  br i1 %25, label %27, label %26

26:                                               ; preds = %17
  store i32 2, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  br label %41

27:                                               ; preds = %17
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.sig_dsp_Value, ptr %28, i32 0, i32 1
  %30 = getelementptr inbounds %struct.sig_dsp_Value_Parameters, ptr %29, i32 0, i32 0
  %31 = load float, ptr %30, align 8, !tbaa !9
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.sig_dsp_Value, ptr %32, i32 0, i32 2
  %34 = getelementptr inbounds %struct.sig_dsp_Signal_SingleMonoOutput, ptr %33, i32 0, i32 0
  %35 = load ptr, ptr %34, align 8, !tbaa !21
  %36 = load i64, ptr %5, align 8, !tbaa !16
  %37 = getelementptr inbounds float, ptr %35, i64 %36
  store float %31, ptr %37, align 4, !tbaa !22
  br label %38

38:                                               ; preds = %27
  %39 = load i64, ptr %5, align 8, !tbaa !16
  %40 = add i64 %39, 1
  store i64 %40, ptr %5, align 8, !tbaa !16
  br label %17, !llvm.loop !23

41:                                               ; preds = %26
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.sig_dsp_Value, ptr %42, i32 0, i32 1
  %44 = getelementptr inbounds %struct.sig_dsp_Value_Parameters, ptr %43, i32 0, i32 0
  %45 = load float, ptr %44, align 8, !tbaa !9
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.sig_dsp_Value, ptr %46, i32 0, i32 3
  store float %45, ptr %47, align 8, !tbaa !15
  store i32 0, ptr %4, align 4
  br label %48

48:                                               ; preds = %41, %15
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  %49 = load i32, ptr %4, align 4
  switch i32 %49, label %51 [
    i32 0, label %50
    i32 1, label %50
  ]

50:                                               ; preds = %48, %48
  ret void

51:                                               ; preds = %48
  unreachable
}

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 = { 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, !13, i64 16}
!10 = !{!"sig_dsp_Value", !11, i64 0, !12, i64 16, !14, i64 24, !13, i64 32}
!11 = !{!"sig_dsp_Signal", !6, i64 0, !6, i64 8}
!12 = !{!"sig_dsp_Value_Parameters", !13, i64 0}
!13 = !{!"float", !7, i64 0}
!14 = !{!"sig_dsp_Signal_SingleMonoOutput", !6, i64 0}
!15 = !{!10, !13, i64 32}
!16 = !{!17, !17, i64 0}
!17 = !{!"long", !7, i64 0}
!18 = !{!10, !6, i64 0}
!19 = !{!20, !17, i64 16}
!20 = !{!"sig_AudioSettings", !13, i64 0, !17, i64 8, !17, i64 16}
!21 = !{!10, !6, i64 24}
!22 = !{!13, !13, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"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_Value_generate(ptr nocapture noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 16
  %3 = load float, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 32
  %5 = load float, ptr %4, align 8, !tbaa !14
  %6 = fcmp oeq float %3, %5
  br i1 %6, label %17, label %.preheader

.preheader:                                       ; preds = %1
  %7 = load ptr, ptr %0, align 8, !tbaa !15
  %8 = getelementptr inbounds i8, ptr %7, i64 16
  %9 = load i64, ptr %8, align 8, !tbaa !16
  %.not = icmp eq i64 %9, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %10 = getelementptr inbounds i8, ptr %0, i64 24
  %11 = load ptr, ptr %10, align 8, !tbaa !19
  %min.iters.check = icmp ult i64 %9, 8
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

scalar.ph.preheader:                              ; preds = %middle.block, %.lr.ph
  %.010.ph = phi i64 [ 0, %.lr.ph ], [ %n.vec, %middle.block ]
  br label %scalar.ph

vector.ph:                                        ; preds = %.lr.ph
  %n.vec = and i64 %9, -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
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %12 = getelementptr inbounds float, ptr %11, i64 %index
  %13 = getelementptr inbounds i8, ptr %12, i64 16
  store <4 x float> %broadcast.splat, ptr %12, align 4, !tbaa !20
  store <4 x float> %broadcast.splat, ptr %13, align 4, !tbaa !20
  %index.next = add nuw i64 %index, 8
  %14 = icmp eq i64 %index.next, %n.vec
  br i1 %14, label %middle.block, label %vector.body, !llvm.loop !21

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

._crit_edge:                                      ; preds = %scalar.ph, %middle.block, %.preheader
  store float %3, ptr %4, align 8, !tbaa !14
  br label %17

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %.010 = phi i64 [ %16, %scalar.ph ], [ %.010.ph, %scalar.ph.preheader ]
  %15 = getelementptr inbounds float, ptr %11, i64 %.010
  store float %3, ptr %15, align 4, !tbaa !20
  %16 = add nuw i64 %.010, 1
  %exitcond.not = icmp eq i64 %16, %9
  br i1 %exitcond.not, label %._crit_edge, label %scalar.ph, !llvm.loop !25

17:                                               ; preds = %1, %._crit_edge
  ret void
}

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" }

!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, !12, i64 16}
!6 = !{!"sig_dsp_Value", !7, i64 0, !11, i64 16, !13, i64 24, !12, 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_Value_Parameters", !12, i64 0}
!12 = !{!"float", !9, i64 0}
!13 = !{!"sig_dsp_Signal_SingleMonoOutput", !8, i64 0}
!14 = !{!6, !12, i64 32}
!15 = !{!6, !8, i64 0}
!16 = !{!17, !18, i64 16}
!17 = !{!"sig_AudioSettings", !12, i64 0, !18, i64 8, !18, i64 16}
!18 = !{!"long", !9, i64 0}
!19 = !{!6, !8, i64 24}
!20 = !{!12, !12, i64 0}
!21 = distinct !{!21, !22, !23, !24}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!"llvm.loop.isvectorized", i32 1}
!24 = !{!"llvm.loop.unroll.runtime.disable"}
!25 = distinct !{!25, !22, !24, !23}


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