; LLVM IR from lichen-community-systems/signaletic :: hosts/daisy/src (signaletic-host)

; 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_host_CVOut = type { %struct.sig_dsp_Signal, %struct.sig_host_CV_Parameters, %struct.sig_host_CVOut_Inputs, %struct.sig_dsp_Signal_SingleMonoOutput, ptr }
%struct.sig_dsp_Signal = type { ptr, ptr }
%struct.sig_host_CV_Parameters = type { float, float, i32 }
%struct.sig_host_CVOut_Inputs = type { ptr }
%struct.sig_dsp_Signal_SingleMonoOutput = type { ptr }
%struct.sig_AudioSettings = type { float, i64, i64 }
%struct.sig_host_HardwareInterface = type { ptr, ptr, ptr, ptr, i64, ptr, i64, ptr, i64, ptr, i64, ptr, i64, ptr, i64, ptr, i64, ptr, i64, ptr, i64, ptr }

; 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_host_CVOut_generate(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %11, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.sig_host_CVOut, ptr %12, i32 0, i32 4
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  store ptr %14, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.sig_host_CVOut, ptr %15, i32 0, i32 1
  %17 = getelementptr inbounds %struct.sig_host_CV_Parameters, ptr %16, i32 0, i32 0
  %18 = load float, ptr %17, align 8, !tbaa !17
  store float %18, ptr %5, align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.sig_host_CVOut, ptr %19, i32 0, i32 1
  %21 = getelementptr inbounds %struct.sig_host_CV_Parameters, ptr %20, i32 0, i32 1
  %22 = load float, ptr %21, align 4, !tbaa !19
  store float %22, ptr %6, align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.sig_host_CVOut, ptr %23, i32 0, i32 1
  %25 = getelementptr inbounds %struct.sig_host_CV_Parameters, ptr %24, i32 0, i32 2
  %26 = load i32, ptr %25, align 8, !tbaa !20
  store i32 %26, ptr %7, align 4, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store i64 0, ptr %8, align 8, !tbaa !22
  br label %27

27:                                               ; preds = %63, %1
  %28 = load i64, ptr %8, align 8, !tbaa !22
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.sig_host_CVOut, ptr %29, i32 0, i32 0
  %31 = getelementptr inbounds %struct.sig_dsp_Signal, ptr %30, i32 0, i32 0
  %32 = load ptr, ptr %31, align 8, !tbaa !24
  %33 = getelementptr inbounds %struct.sig_AudioSettings, ptr %32, i32 0, i32 2
  %34 = load i64, ptr %33, align 8, !tbaa !25
  %35 = icmp ult i64 %28, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %66

37:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.sig_host_CVOut, ptr %38, i32 0, i32 2
  %40 = getelementptr inbounds %struct.sig_host_CVOut_Inputs, ptr %39, i32 0, i32 0
  %41 = load ptr, ptr %40, align 8, !tbaa !27
  %42 = load i64, ptr %8, align 8, !tbaa !22
  %43 = getelementptr inbounds float, ptr %41, i64 %42
  %44 = load float, ptr %43, align 4, !tbaa !18
  store float %44, ptr %9, align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %45 = load float, ptr %9, align 4, !tbaa !18
  %46 = load float, ptr %5, align 4, !tbaa !18
  %47 = load float, ptr %6, align 4, !tbaa !18
  %48 = call float @llvm.fmuladd.f32(float %45, float %46, float %47)
  store float %48, ptr %10, align 4, !tbaa !18
  %49 = load float, ptr %10, align 4, !tbaa !18
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.sig_host_CVOut, ptr %50, i32 0, i32 3
  %52 = getelementptr inbounds %struct.sig_dsp_Signal_SingleMonoOutput, ptr %51, i32 0, i32 0
  %53 = load ptr, ptr %52, align 8, !tbaa !28
  %54 = load i64, ptr %8, align 8, !tbaa !22
  %55 = getelementptr inbounds float, ptr %53, i64 %54
  store float %49, ptr %55, align 4, !tbaa !18
  %56 = load float, ptr %10, align 4, !tbaa !18
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.sig_host_HardwareInterface, ptr %57, i32 0, i32 11
  %59 = load ptr, ptr %58, align 8, !tbaa !29
  %60 = load i32, ptr %7, align 4, !tbaa !21
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds float, ptr %59, i64 %61
  store float %56, ptr %62, align 4, !tbaa !18
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %63

63:                                               ; preds = %37
  %64 = load i64, ptr %8, align 8, !tbaa !22
  %65 = add i64 %64, 1
  store i64 %65, ptr %8, align 8, !tbaa !22
  br label %27, !llvm.loop !31

66:                                               ; preds = %36
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, 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, !6, i64 48}
!10 = !{!"sig_host_CVOut", !11, i64 0, !12, i64 16, !15, i64 32, !16, i64 40, !6, i64 48}
!11 = !{!"sig_dsp_Signal", !6, i64 0, !6, i64 8}
!12 = !{!"sig_host_CV_Parameters", !13, i64 0, !13, i64 4, !14, i64 8}
!13 = !{!"float", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!"sig_host_CVOut_Inputs", !6, i64 0}
!16 = !{!"sig_dsp_Signal_SingleMonoOutput", !6, i64 0}
!17 = !{!10, !13, i64 16}
!18 = !{!13, !13, i64 0}
!19 = !{!10, !13, i64 20}
!20 = !{!10, !14, i64 24}
!21 = !{!14, !14, i64 0}
!22 = !{!23, !23, i64 0}
!23 = !{!"long", !7, i64 0}
!24 = !{!10, !6, i64 0}
!25 = !{!26, !23, i64 16}
!26 = !{!"sig_AudioSettings", !13, i64 0, !23, i64 8, !23, i64 16}
!27 = !{!10, !6, i64 32}
!28 = !{!10, !6, i64 40}
!29 = !{!30, !6, i64 88}
!30 = !{!"sig_host_HardwareInterface", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !23, i64 32, !6, i64 40, !23, i64 48, !6, i64 56, !23, i64 64, !6, i64 72, !23, i64 80, !6, i64 88, !23, i64 96, !6, i64 104, !23, i64 112, !6, i64 120, !23, i64 128, !6, i64 136, !23, i64 144, !6, i64 152, !23, i64 160, !6, i64 168}
!31 = distinct !{!31, !32}
!32 = !{!"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_host_CVOut_generate(ptr nocapture noundef readonly %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 16
  %3 = load float, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 20
  %5 = load float, ptr %4, align 4, !tbaa !16
  %6 = load ptr, ptr %0, align 8, !tbaa !17
  %7 = getelementptr inbounds i8, ptr %6, i64 16
  %8 = load i64, ptr %7, align 8, !tbaa !18
  %.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 24
  %10 = load i32, ptr %9, align 8, !tbaa !21
  %11 = getelementptr inbounds i8, ptr %0, i64 48
  %12 = load ptr, ptr %11, align 8, !tbaa !22
  %13 = getelementptr inbounds i8, ptr %0, i64 32
  %14 = load ptr, ptr %13, align 8, !tbaa !23
  %15 = getelementptr inbounds i8, ptr %0, i64 40
  %16 = load ptr, ptr %15, align 8, !tbaa !24
  %17 = getelementptr inbounds i8, ptr %12, i64 88
  %18 = load ptr, ptr %17, align 8, !tbaa !25
  %19 = sext i32 %10 to i64
  %20 = getelementptr inbounds float, ptr %18, i64 %19
  %min.iters.check = icmp ult i64 %8, 16
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.memcheck

scalar.ph.preheader:                              ; preds = %middle.block, %vector.memcheck, %.lr.ph
  %.018.ph = phi i64 [ 0, %vector.memcheck ], [ 0, %.lr.ph ], [ %n.vec, %middle.block ]
  %.neg = or disjoint i64 %.018.ph, 1
  %xtraiter = and i64 %8, 1
  %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
  %21 = getelementptr inbounds float, ptr %14, i64 %.018.ph
  %22 = load float, ptr %21, align 4, !tbaa !27
  %23 = tail call float @llvm.fmuladd.f32(float %22, float %3, float %5)
  %24 = getelementptr inbounds float, ptr %16, i64 %.018.ph
  store float %23, ptr %24, align 4, !tbaa !27
  store float %23, ptr %20, align 4, !tbaa !27
  %25 = or disjoint i64 %.018.ph, 1
  br label %scalar.ph.prol.loopexit

scalar.ph.prol.loopexit:                          ; preds = %scalar.ph.prol, %scalar.ph.preheader
  %.018.unr = phi i64 [ %.018.ph, %scalar.ph.preheader ], [ %25, %scalar.ph.prol ]
  %26 = icmp eq i64 %8, %.neg
  br i1 %26, label %._crit_edge, label %scalar.ph

vector.memcheck:                                  ; preds = %.lr.ph
  %27 = shl i64 %8, 2
  %scevgep = getelementptr i8, ptr %16, i64 %27
  %28 = shl nsw i64 %19, 2
  %29 = getelementptr i8, ptr %18, i64 %28
  %scevgep19 = getelementptr i8, ptr %29, i64 4
  %scevgep20 = getelementptr i8, ptr %14, i64 %27
  %bound0 = icmp ult ptr %16, %scevgep19
  %bound1 = icmp ult ptr %20, %scevgep
  %found.conflict = and i1 %bound0, %bound1
  %bound021 = icmp ult ptr %16, %scevgep20
  %bound122 = icmp ult ptr %14, %scevgep
  %found.conflict23 = and i1 %bound021, %bound122
  %conflict.rdx = or i1 %found.conflict, %found.conflict23
  %bound024 = icmp ult ptr %20, %scevgep20
  %bound125 = icmp ult ptr %14, %scevgep19
  %found.conflict26 = and i1 %bound024, %bound125
  %conflict.rdx27 = or i1 %conflict.rdx, %found.conflict26
  br i1 %conflict.rdx27, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %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.splatinsert29 = insertelement <4 x float> poison, float %5, i64 0
  %broadcast.splat30 = shufflevector <4 x float> %broadcast.splatinsert29, <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 ]
  %30 = getelementptr inbounds float, ptr %14, i64 %index
  %31 = getelementptr inbounds i8, ptr %30, i64 16
  %wide.load = load <4 x float>, ptr %30, align 4, !tbaa !27, !alias.scope !28
  %wide.load28 = load <4 x float>, ptr %31, align 4, !tbaa !27, !alias.scope !28
  %32 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %wide.load, <4 x float> %broadcast.splat, <4 x float> %broadcast.splat30)
  %33 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %wide.load28, <4 x float> %broadcast.splat, <4 x float> %broadcast.splat30)
  %34 = getelementptr inbounds float, ptr %16, i64 %index
  %35 = getelementptr inbounds i8, ptr %34, i64 16
  store <4 x float> %32, ptr %34, align 4, !tbaa !27, !alias.scope !31, !noalias !33
  store <4 x float> %33, ptr %35, align 4, !tbaa !27, !alias.scope !31, !noalias !33
  %36 = extractelement <4 x float> %33, i64 3
  %index.next = add nuw i64 %index, 8
  %37 = icmp eq i64 %index.next, %n.vec
  br i1 %37, label %middle.block, label %vector.body, !llvm.loop !35

middle.block:                                     ; preds = %vector.body
  store float %36, ptr %20, align 4, !tbaa !27, !alias.scope !39, !noalias !28
  %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
  %.018 = phi i64 [ %47, %scalar.ph ], [ %.018.unr, %scalar.ph.prol.loopexit ]
  %38 = getelementptr inbounds float, ptr %14, i64 %.018
  %39 = load float, ptr %38, align 4, !tbaa !27
  %40 = tail call float @llvm.fmuladd.f32(float %39, float %3, float %5)
  %41 = getelementptr inbounds float, ptr %16, i64 %.018
  store float %40, ptr %41, align 4, !tbaa !27
  store float %40, ptr %20, align 4, !tbaa !27
  %42 = add nuw i64 %.018, 1
  %43 = getelementptr inbounds float, ptr %14, i64 %42
  %44 = load float, ptr %43, align 4, !tbaa !27
  %45 = tail call float @llvm.fmuladd.f32(float %44, float %3, float %5)
  %46 = getelementptr inbounds float, ptr %16, i64 %42
  store float %45, ptr %46, align 4, !tbaa !27
  store float %45, ptr %20, align 4, !tbaa !27
  %47 = add nuw i64 %.018, 2
  %exitcond.not.1 = icmp eq i64 %47, %8
  br i1 %exitcond.not.1, label %._crit_edge, label %scalar.ph, !llvm.loop !40
}

; 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, !12, i64 16}
!6 = !{!"sig_host_CVOut", !7, i64 0, !11, i64 16, !14, i64 32, !15, i64 40, !8, i64 48}
!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_host_CV_Parameters", !12, i64 0, !12, i64 4, !13, i64 8}
!12 = !{!"float", !9, i64 0}
!13 = !{!"int", !9, i64 0}
!14 = !{!"sig_host_CVOut_Inputs", !8, i64 0}
!15 = !{!"sig_dsp_Signal_SingleMonoOutput", !8, i64 0}
!16 = !{!6, !12, i64 20}
!17 = !{!6, !8, i64 0}
!18 = !{!19, !20, i64 16}
!19 = !{!"sig_AudioSettings", !12, i64 0, !20, i64 8, !20, i64 16}
!20 = !{!"long", !9, i64 0}
!21 = !{!6, !13, i64 24}
!22 = !{!6, !8, i64 48}
!23 = !{!6, !8, i64 32}
!24 = !{!6, !8, i64 40}
!25 = !{!26, !8, i64 88}
!26 = !{!"sig_host_HardwareInterface", !8, i64 0, !8, i64 8, !8, i64 16, !8, i64 24, !20, i64 32, !8, i64 40, !20, i64 48, !8, i64 56, !20, i64 64, !8, i64 72, !20, i64 80, !8, i64 88, !20, i64 96, !8, i64 104, !20, i64 112, !8, i64 120, !20, i64 128, !8, i64 136, !20, i64 144, !8, i64 152, !20, i64 160, !8, i64 168}
!27 = !{!12, !12, i64 0}
!28 = !{!29}
!29 = distinct !{!29, !30}
!30 = distinct !{!30, !"LVerDomain"}
!31 = !{!32}
!32 = distinct !{!32, !30}
!33 = !{!34, !29}
!34 = distinct !{!34, !30}
!35 = distinct !{!35, !36, !37, !38}
!36 = !{!"llvm.loop.mustprogress"}
!37 = !{!"llvm.loop.isvectorized", i32 1}
!38 = !{!"llvm.loop.unroll.runtime.disable"}
!39 = !{!34}
!40 = distinct !{!40, !36, !37}


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