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

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

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

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

61:                                               ; preds = %36
  %62 = load i64, ptr %8, align 8, !tbaa !22
  %63 = add i64 %62, 1
  store i64 %63, ptr %8, align 8, !tbaa !22
  br label %26, !llvm.loop !31

64:                                               ; preds = %35
  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_GateOut", !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_GateOut_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 120}
!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_GateOut_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 120
  %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
  %.017.ph = phi i64 [ 0, %vector.memcheck ], [ 0, %.lr.ph ], [ %n.vec, %middle.block ]
  %.neg = or disjoint i64 %.017.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 %.017.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 %.017.ph
  store float %23, ptr %24, align 4, !tbaa !27
  store float %23, ptr %20, align 4, !tbaa !27
  %25 = or disjoint i64 %.017.ph, 1
  br label %scalar.ph.prol.loopexit

scalar.ph.prol.loopexit:                          ; preds = %scalar.ph.prol, %scalar.ph.preheader
  %.017.unr = phi i64 [ %.017.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
  %scevgep18 = getelementptr i8, ptr %29, i64 4
  %scevgep19 = getelementptr i8, ptr %14, i64 %27
  %bound0 = icmp ult ptr %16, %scevgep18
  %bound1 = icmp ult ptr %20, %scevgep
  %found.conflict = and i1 %bound0, %bound1
  %bound020 = icmp ult ptr %16, %scevgep19
  %bound121 = icmp ult ptr %14, %scevgep
  %found.conflict22 = and i1 %bound020, %bound121
  %conflict.rdx = or i1 %found.conflict, %found.conflict22
  %bound023 = icmp ult ptr %20, %scevgep19
  %bound124 = icmp ult ptr %14, %scevgep18
  %found.conflict25 = and i1 %bound023, %bound124
  %conflict.rdx26 = or i1 %conflict.rdx, %found.conflict25
  br i1 %conflict.rdx26, 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.splatinsert28 = insertelement <4 x float> poison, float %5, i64 0
  %broadcast.splat29 = shufflevector <4 x float> %broadcast.splatinsert28, <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.load27 = 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.splat29)
  %33 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %wide.load27, <4 x float> %broadcast.splat, <4 x float> %broadcast.splat29)
  %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
  %.017 = phi i64 [ %47, %scalar.ph ], [ %.017.unr, %scalar.ph.prol.loopexit ]
  %38 = getelementptr inbounds float, ptr %14, i64 %.017
  %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 %.017
  store float %40, ptr %41, align 4, !tbaa !27
  store float %40, ptr %20, align 4, !tbaa !27
  %42 = add nuw i64 %.017, 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 %.017, 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_GateOut", !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_GateOut_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 120}
!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