; 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_CVIn = 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_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 }
%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: 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_CVIn_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 float, align 4
  %9 = alloca i64, align 8
  %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_CVIn, ptr %12, i32 0, i32 3
  %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_CVIn, 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 !16
  store float %18, ptr %5, align 4, !tbaa !17
  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_CVIn, 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 !18
  store float %22, ptr %6, align 4, !tbaa !17
  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_CVIn, 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 !19
  store i32 %26, ptr %7, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.sig_host_HardwareInterface, ptr %27, i32 0, i32 9
  %29 = load ptr, ptr %28, align 8, !tbaa !21
  %30 = load i32, ptr %7, align 4, !tbaa !20
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds float, ptr %29, i64 %31
  %33 = load float, ptr %32, align 4, !tbaa !17
  store float %33, ptr %8, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store i64 0, ptr %9, align 8, !tbaa !24
  br label %34

34:                                               ; preds = %56, %1
  %35 = load i64, ptr %9, align 8, !tbaa !24
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.sig_host_CVIn, ptr %36, i32 0, i32 0
  %38 = getelementptr inbounds %struct.sig_dsp_Signal, ptr %37, i32 0, i32 0
  %39 = load ptr, ptr %38, align 8, !tbaa !25
  %40 = getelementptr inbounds %struct.sig_AudioSettings, ptr %39, i32 0, i32 2
  %41 = load i64, ptr %40, align 8, !tbaa !26
  %42 = icmp ult i64 %35, %41
  br i1 %42, label %44, label %43

43:                                               ; preds = %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %59

44:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %45 = load float, ptr %8, align 4, !tbaa !17
  %46 = load float, ptr %5, align 4, !tbaa !17
  %47 = load float, ptr %6, align 4, !tbaa !17
  %48 = call float @llvm.fmuladd.f32(float %45, float %46, float %47)
  store float %48, ptr %10, align 4, !tbaa !17
  %49 = load float, ptr %10, align 4, !tbaa !17
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.sig_host_CVIn, ptr %50, i32 0, i32 2
  %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 %9, align 8, !tbaa !24
  %55 = getelementptr inbounds float, ptr %53, i64 %54
  store float %49, ptr %55, align 4, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %56

56:                                               ; preds = %44
  %57 = load i64, ptr %9, align 8, !tbaa !24
  %58 = add i64 %57, 1
  store i64 %58, ptr %9, align 8, !tbaa !24
  br label %34, !llvm.loop !29

59:                                               ; preds = %43
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  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 40}
!10 = !{!"sig_host_CVIn", !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, !6, i64 72}
!22 = !{!"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}
!23 = !{!"long", !7, i64 0}
!24 = !{!23, !23, i64 0}
!25 = !{!10, !6, i64 0}
!26 = !{!27, !23, i64 16}
!27 = !{!"sig_AudioSettings", !13, i64 0, !23, i64 8, !23, i64 16}
!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: 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_CVIn_generate(ptr nocapture noundef readonly %0) local_unnamed_addr #1 {
  %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 !15
  %.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 40
  %6 = load ptr, ptr %5, align 8, !tbaa !18
  %7 = getelementptr inbounds i8, ptr %6, i64 72
  %8 = load ptr, ptr %7, align 8, !tbaa !19
  %9 = getelementptr inbounds i8, ptr %0, i64 24
  %10 = load i32, ptr %9, align 8, !tbaa !21
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds float, ptr %8, i64 %11
  %13 = load float, ptr %12, align 4, !tbaa !22
  %14 = getelementptr inbounds i8, ptr %0, i64 20
  %15 = load float, ptr %14, align 4, !tbaa !23
  %16 = getelementptr inbounds i8, ptr %0, i64 16
  %17 = load float, ptr %16, align 8, !tbaa !24
  %18 = tail call float @llvm.fmuladd.f32(float %13, float %17, float %15)
  %19 = getelementptr inbounds i8, ptr %0, i64 32
  %20 = load ptr, ptr %19, align 8, !tbaa !25
  %min.iters.check = icmp ult i64 %4, 8
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

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

vector.ph:                                        ; preds = %.lr.ph
  %n.vec = and i64 %4, -8
  %broadcast.splatinsert = insertelement <4 x float> poison, float %18, 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 ]
  %21 = getelementptr inbounds float, ptr %20, i64 %index
  %22 = getelementptr inbounds i8, ptr %21, i64 16
  store <4 x float> %broadcast.splat, ptr %21, align 4, !tbaa !22
  store <4 x float> %broadcast.splat, ptr %22, align 4, !tbaa !22
  %index.next = add nuw i64 %index, 8
  %23 = icmp eq i64 %index.next, %n.vec
  br i1 %23, label %middle.block, label %vector.body, !llvm.loop !26

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, %middle.block, %1
  ret void

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %.015 = phi i64 [ %25, %scalar.ph ], [ %.015.ph, %scalar.ph.preheader ]
  %24 = getelementptr inbounds float, ptr %20, i64 %.015
  store float %18, ptr %24, align 4, !tbaa !22
  %25 = add nuw i64 %.015, 1
  %exitcond.not = icmp eq i64 %25, %4
  br i1 %exitcond.not, label %._crit_edge, label %scalar.ph, !llvm.loop !30
}

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

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


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