; 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_GateIn = type { %struct.sig_dsp_Signal, %struct.sig_host_CV_Parameters, %struct.sig_dsp_Signal_SingleMonoOutput, ptr }
%struct.sig_dsp_Signal = type { ptr, ptr }
%struct.sig_host_CV_Parameters = type { float, float, i32 }
%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: nounwind uwtable
define dso_local void @sig_host_GateIn_generate(ptr noundef %0) #1 {
  %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_GateIn, ptr %11, i32 0, i32 3
  %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_GateIn, 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 !16
  store float %17, ptr %5, align 4, !tbaa !17
  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_GateIn, 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 !18
  store float %21, ptr %6, align 4, !tbaa !17
  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_GateIn, 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 !19
  store i32 %25, ptr %7, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store i64 0, ptr %8, align 8, !tbaa !21
  br label %26

26:                                               ; preds = %54, %1
  %27 = load i64, ptr %8, align 8, !tbaa !21
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.sig_host_GateIn, 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 !23
  %32 = getelementptr inbounds %struct.sig_AudioSettings, ptr %31, i32 0, i32 2
  %33 = load i64, ptr %32, align 8, !tbaa !24
  %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 %57

36:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.sig_host_HardwareInterface, ptr %37, i32 0, i32 13
  %39 = load ptr, ptr %38, align 8, !tbaa !26
  %40 = load i32, ptr %7, align 4, !tbaa !20
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds float, ptr %39, i64 %41
  %43 = load float, ptr %42, align 4, !tbaa !17
  store float %43, ptr %9, align 4, !tbaa !17
  %44 = load float, ptr %9, align 4, !tbaa !17
  %45 = load float, ptr %5, align 4, !tbaa !17
  %46 = load float, ptr %6, align 4, !tbaa !17
  %47 = call float @llvm.fmuladd.f32(float %44, float %45, float %46)
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.sig_host_GateIn, ptr %48, i32 0, i32 2
  %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 !21
  %53 = getelementptr inbounds float, ptr %51, i64 %52
  store float %47, ptr %53, align 4, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %54

54:                                               ; preds = %36
  %55 = load i64, ptr %8, align 8, !tbaa !21
  %56 = add i64 %55, 1
  store i64 %56, ptr %8, align 8, !tbaa !21
  br label %26, !llvm.loop !29

57:                                               ; 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
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, 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, !6, i64 40}
!10 = !{!"sig_host_GateIn", !11, i64 0, !12, i64 16, !15, i64 32, !6, i64 40}
!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_dsp_Signal_SingleMonoOutput", !6, i64 0}
!16 = !{!10, !13, i64 16}
!17 = !{!13, !13, i64 0}
!18 = !{!10, !13, i64 20}
!19 = !{!10, !14, i64 24}
!20 = !{!14, !14, i64 0}
!21 = !{!22, !22, i64 0}
!22 = !{!"long", !7, i64 0}
!23 = !{!10, !6, i64 0}
!24 = !{!25, !22, i64 16}
!25 = !{!"sig_AudioSettings", !13, i64 0, !22, i64 8, !22, i64 16}
!26 = !{!27, !6, i64 104}
!27 = !{!"sig_host_HardwareInterface", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !22, i64 32, !6, i64 40, !22, i64 48, !6, i64 56, !22, i64 64, !6, i64 72, !22, i64 80, !6, i64 88, !22, i64 96, !6, i64 104, !22, i64 112, !6, i64 120, !22, i64 128, !6, i64 136, !22, i64 144, !6, i64 152, !22, i64 160, !6, i64 168}
!28 = !{!10, !6, i64 32}
!29 = distinct !{!29, !30}
!30 = !{!"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_host_GateIn_generate(ptr nocapture noundef readonly %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 20
  %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 24
  %10 = load i32, ptr %9, align 8, !tbaa !20
  %11 = getelementptr inbounds i8, ptr %0, i64 40
  %12 = load ptr, ptr %11, align 8, !tbaa !21
  %13 = getelementptr inbounds i8, ptr %12, i64 104
  %14 = load ptr, ptr %13, align 8, !tbaa !22
  %15 = sext i32 %10 to i64
  %16 = getelementptr inbounds float, ptr %14, i64 %15
  %17 = getelementptr inbounds i8, ptr %0, i64 32
  %18 = load ptr, ptr %17, align 8, !tbaa !24
  %min.iters.check = icmp ult i64 %8, 8
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.memcheck

scalar.ph.preheader:                              ; preds = %middle.block, %vector.memcheck, %.lr.ph
  %.014.ph = phi i64 [ 0, %vector.memcheck ], [ 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
  %.014.prol = phi i64 [ %22, %scalar.ph.prol ], [ %.014.ph, %scalar.ph.preheader ]
  %prol.iter = phi i64 [ %prol.iter.next, %scalar.ph.prol ], [ 0, %scalar.ph.preheader ]
  %19 = load float, ptr %16, align 4, !tbaa !25
  %20 = tail call float @llvm.fmuladd.f32(float %19, float %3, float %5)
  %21 = getelementptr inbounds float, ptr %18, i64 %.014.prol
  store float %20, ptr %21, align 4, !tbaa !25
  %22 = add nuw i64 %.014.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 !26

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

scalar.ph.preheader.new:                          ; preds = %scalar.ph.prol.loopexit
  %invariant.gep = getelementptr i8, ptr %18, i64 4
  %invariant.gep22 = getelementptr i8, ptr %18, i64 8
  %invariant.gep24 = getelementptr i8, ptr %18, i64 12
  br label %scalar.ph

vector.memcheck:                                  ; preds = %.lr.ph
  %25 = shl i64 %8, 2
  %scevgep = getelementptr i8, ptr %18, i64 %25
  %26 = shl nsw i64 %15, 2
  %27 = getelementptr i8, ptr %14, i64 %26
  %scevgep15 = getelementptr i8, ptr %27, i64 4
  %bound0 = icmp ult ptr %18, %scevgep15
  %bound1 = icmp ult ptr %16, %scevgep
  %found.conflict = and i1 %bound0, %bound1
  br i1 %found.conflict, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %n.vec = and i64 %8, -8
  %broadcast.splatinsert16 = insertelement <4 x float> poison, float %3, i64 0
  %broadcast.splat17 = shufflevector <4 x float> %broadcast.splatinsert16, <4 x float> poison, <4 x i32> zeroinitializer
  %broadcast.splatinsert18 = insertelement <4 x float> poison, float %5, i64 0
  %broadcast.splat19 = shufflevector <4 x float> %broadcast.splatinsert18, <4 x float> poison, <4 x i32> zeroinitializer
  %28 = load float, ptr %16, align 4, !tbaa !25, !alias.scope !28
  %broadcast.splatinsert20 = insertelement <4 x float> poison, float %28, i64 0
  %broadcast.splat21 = shufflevector <4 x float> %broadcast.splatinsert20, <4 x float> poison, <4 x i32> zeroinitializer
  %29 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %broadcast.splat21, <4 x float> %broadcast.splat17, <4 x float> %broadcast.splat19)
  %30 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %broadcast.splat21, <4 x float> %broadcast.splat17, <4 x float> %broadcast.splat19)
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %31 = getelementptr inbounds float, ptr %18, i64 %index
  %32 = getelementptr inbounds i8, ptr %31, i64 16
  store <4 x float> %29, ptr %31, align 4, !tbaa !25, !alias.scope !31, !noalias !28
  store <4 x float> %30, ptr %32, align 4, !tbaa !25, !alias.scope !31, !noalias !28
  %index.next = add nuw i64 %index, 8
  %33 = icmp eq i64 %index.next, %n.vec
  br i1 %33, label %middle.block, label %vector.body, !llvm.loop !33

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, %scalar.ph.preheader.new
  %.014 = phi i64 [ %.014.unr, %scalar.ph.preheader.new ], [ %43, %scalar.ph ]
  %34 = load float, ptr %16, align 4, !tbaa !25
  %35 = tail call float @llvm.fmuladd.f32(float %34, float %3, float %5)
  %36 = getelementptr inbounds float, ptr %18, i64 %.014
  store float %35, ptr %36, align 4, !tbaa !25
  %37 = load float, ptr %16, align 4, !tbaa !25
  %38 = tail call float @llvm.fmuladd.f32(float %37, float %3, float %5)
  %gep = getelementptr float, ptr %invariant.gep, i64 %.014
  store float %38, ptr %gep, align 4, !tbaa !25
  %39 = load float, ptr %16, align 4, !tbaa !25
  %40 = tail call float @llvm.fmuladd.f32(float %39, float %3, float %5)
  %gep23 = getelementptr float, ptr %invariant.gep22, i64 %.014
  store float %40, ptr %gep23, align 4, !tbaa !25
  %41 = load float, ptr %16, align 4, !tbaa !25
  %42 = tail call float @llvm.fmuladd.f32(float %41, float %3, float %5)
  %gep25 = getelementptr float, ptr %invariant.gep24, i64 %.014
  store float %42, ptr %gep25, align 4, !tbaa !25
  %43 = add nuw i64 %.014, 4
  %exitcond.not.3 = icmp eq i64 %43, %8
  br i1 %exitcond.not.3, label %._crit_edge, label %scalar.ph, !llvm.loop !37
}

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

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


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