; 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_AudioOut = type { %struct.sig_dsp_Signal, %struct.sig_host_AudioParameters, %struct.sig_host_AudioOut_Inputs, %struct.sig_dsp_Signal_SingleMonoOutput, ptr }
%struct.sig_dsp_Signal = type { ptr, ptr }
%struct.sig_host_AudioParameters = type { i32, float }
%struct.sig_host_AudioOut_Inputs = type { ptr }
%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: nounwind uwtable
define dso_local void @sig_host_AudioOut_generate(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca float, align 4
  %9 = alloca i32, align 4
  %10 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  %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) #2
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.sig_host_AudioOut, 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 8, ptr %5) #2
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.sig_host_HardwareInterface, ptr %15, i32 0, i32 7
  %17 = load ptr, ptr %16, align 8, !tbaa !17
  store ptr %17, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.sig_host_AudioOut, ptr %18, i32 0, i32 2
  %20 = getelementptr inbounds %struct.sig_host_AudioOut_Inputs, ptr %19, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8, !tbaa !20
  store ptr %21, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.sig_host_AudioOut, ptr %22, i32 0, i32 1
  %24 = getelementptr inbounds %struct.sig_host_AudioParameters, ptr %23, i32 0, i32 0
  %25 = load i32, ptr %24, align 8, !tbaa !21
  store i32 %25, ptr %7, align 4, !tbaa !22
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.sig_host_AudioOut, ptr %26, i32 0, i32 1
  %28 = getelementptr inbounds %struct.sig_host_AudioParameters, ptr %27, i32 0, i32 1
  %29 = load float, ptr %28, align 4, !tbaa !23
  store float %29, ptr %8, align 4, !tbaa !24
  %30 = load i32, ptr %7, align 4, !tbaa !22
  %31 = icmp slt i32 %30, 0
  br i1 %31, label %39, label %32

32:                                               ; preds = %1
  %33 = load i32, ptr %7, align 4, !tbaa !22
  %34 = sext i32 %33 to i64
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.sig_host_HardwareInterface, ptr %35, i32 0, i32 6
  %37 = load i64, ptr %36, align 8, !tbaa !25
  %38 = icmp uge i64 %34, %37
  br i1 %38, label %39, label %40

39:                                               ; preds = %32, %1
  store i32 1, ptr %9, align 4
  br label %69

40:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  store i64 0, ptr %10, align 8, !tbaa !26
  br label %41

41:                                               ; preds = %65, %40
  %42 = load i64, ptr %10, align 8, !tbaa !26
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.sig_host_AudioOut, ptr %43, i32 0, i32 0
  %45 = getelementptr inbounds %struct.sig_dsp_Signal, ptr %44, i32 0, i32 0
  %46 = load ptr, ptr %45, align 8, !tbaa !27
  %47 = getelementptr inbounds %struct.sig_AudioSettings, ptr %46, i32 0, i32 2
  %48 = load i64, ptr %47, align 8, !tbaa !28
  %49 = icmp ult i64 %42, %48
  br i1 %49, label %51, label %50

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

51:                                               ; preds = %41
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = load i64, ptr %10, align 8, !tbaa !26
  %54 = getelementptr inbounds float, ptr %52, i64 %53
  %55 = load float, ptr %54, align 4, !tbaa !24
  %56 = load float, ptr %8, align 4, !tbaa !24
  %57 = fmul float %55, %56
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = load i32, ptr %7, align 4, !tbaa !22
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds ptr, ptr %58, i64 %60
  %62 = load ptr, ptr %61, align 8, !tbaa !5
  %63 = load i64, ptr %10, align 8, !tbaa !26
  %64 = getelementptr inbounds float, ptr %62, i64 %63
  store float %57, ptr %64, align 4, !tbaa !24
  br label %65

65:                                               ; preds = %51
  %66 = load i64, ptr %10, align 8, !tbaa !26
  %67 = add i64 %66, 1
  store i64 %67, ptr %10, align 8, !tbaa !26
  br label %41, !llvm.loop !30

68:                                               ; preds = %50
  store i32 0, ptr %9, align 4
  br label %69

69:                                               ; preds = %68, %39
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  %70 = load i32, ptr %9, align 4
  switch i32 %70, label %72 [
    i32 0, label %71
    i32 1, label %71
  ]

71:                                               ; preds = %69, %69
  ret void

72:                                               ; preds = %69
  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, !6, i64 40}
!10 = !{!"sig_host_AudioOut", !11, i64 0, !12, i64 16, !15, i64 24, !16, i64 32, !6, i64 40}
!11 = !{!"sig_dsp_Signal", !6, i64 0, !6, i64 8}
!12 = !{!"sig_host_AudioParameters", !13, i64 0, !14, i64 4}
!13 = !{!"int", !7, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = !{!"sig_host_AudioOut_Inputs", !6, i64 0}
!16 = !{!"sig_dsp_Signal_SingleMonoOutput", !6, i64 0}
!17 = !{!18, !6, i64 56}
!18 = !{!"sig_host_HardwareInterface", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !19, i64 32, !6, i64 40, !19, i64 48, !6, i64 56, !19, i64 64, !6, i64 72, !19, i64 80, !6, i64 88, !19, i64 96, !6, i64 104, !19, i64 112, !6, i64 120, !19, i64 128, !6, i64 136, !19, i64 144, !6, i64 152, !19, i64 160, !6, i64 168}
!19 = !{!"long", !7, i64 0}
!20 = !{!10, !6, i64 24}
!21 = !{!10, !13, i64 16}
!22 = !{!13, !13, i64 0}
!23 = !{!10, !14, i64 20}
!24 = !{!14, !14, i64 0}
!25 = !{!18, !19, i64 48}
!26 = !{!19, !19, i64 0}
!27 = !{!10, !6, i64 0}
!28 = !{!29, !19, i64 16}
!29 = !{!"sig_AudioSettings", !14, i64 0, !19, i64 8, !19, i64 16}
!30 = distinct !{!30, !31}
!31 = !{!"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_AudioOut_generate(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 40
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %3, i64 56
  %5 = load ptr, ptr %4, align 8, !tbaa !16
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  %7 = load ptr, ptr %6, align 8, !tbaa !19
  %8 = ptrtoint ptr %7 to i64
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  %10 = load i32, ptr %9, align 8, !tbaa !20
  %11 = getelementptr inbounds i8, ptr %0, i64 20
  %12 = load float, ptr %11, align 4, !tbaa !21
  %13 = icmp slt i32 %10, 0
  br i1 %13, label %.loopexit, label %14

14:                                               ; preds = %1
  %15 = zext nneg i32 %10 to i64
  %16 = getelementptr inbounds i8, ptr %3, i64 48
  %17 = load i64, ptr %16, align 8, !tbaa !22
  %.not = icmp ugt i64 %17, %15
  br i1 %.not, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %14
  %18 = load ptr, ptr %0, align 8, !tbaa !23
  %19 = getelementptr inbounds i8, ptr %18, i64 16
  %20 = load i64, ptr %19, align 8, !tbaa !24
  %.not20 = icmp eq i64 %20, 0
  br i1 %.not20, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %21 = getelementptr inbounds ptr, ptr %5, i64 %15
  %22 = load ptr, ptr %21, align 8, !tbaa !26
  %min.iters.check = icmp ult i64 %20, 8
  %23 = ptrtoint ptr %22 to i64
  %24 = sub i64 %23, %8
  %diff.check = icmp ult i64 %24, 32
  %or.cond = select i1 %min.iters.check, i1 true, i1 %diff.check
  br i1 %or.cond, label %scalar.ph.preheader, label %vector.ph

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

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

scalar.ph.preheader:                              ; preds = %middle.block, %.lr.ph
  %.019.ph = phi i64 [ 0, %.lr.ph ], [ %n.vec, %middle.block ]
  %xtraiter = and i64 %20, 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
  %.019.prol = phi i64 [ %36, %scalar.ph.prol ], [ %.019.ph, %scalar.ph.preheader ]
  %prol.iter = phi i64 [ %prol.iter.next, %scalar.ph.prol ], [ 0, %scalar.ph.preheader ]
  %32 = getelementptr inbounds float, ptr %7, i64 %.019.prol
  %33 = load float, ptr %32, align 4, !tbaa !27
  %34 = fmul float %12, %33
  %35 = getelementptr inbounds float, ptr %22, i64 %.019.prol
  store float %34, ptr %35, align 4, !tbaa !27
  %36 = add nuw i64 %.019.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 !32

scalar.ph.prol.loopexit:                          ; preds = %scalar.ph.prol, %scalar.ph.preheader
  %.019.unr = phi i64 [ %.019.ph, %scalar.ph.preheader ], [ %36, %scalar.ph.prol ]
  %37 = sub i64 %.019.ph, %20
  %38 = icmp ugt i64 %37, -4
  br i1 %38, label %.loopexit, label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.prol.loopexit, %scalar.ph
  %.019 = phi i64 [ %58, %scalar.ph ], [ %.019.unr, %scalar.ph.prol.loopexit ]
  %39 = getelementptr inbounds float, ptr %7, i64 %.019
  %40 = load float, ptr %39, align 4, !tbaa !27
  %41 = fmul float %12, %40
  %42 = getelementptr inbounds float, ptr %22, i64 %.019
  store float %41, ptr %42, align 4, !tbaa !27
  %43 = add nuw i64 %.019, 1
  %44 = getelementptr inbounds float, ptr %7, i64 %43
  %45 = load float, ptr %44, align 4, !tbaa !27
  %46 = fmul float %12, %45
  %47 = getelementptr inbounds float, ptr %22, i64 %43
  store float %46, ptr %47, align 4, !tbaa !27
  %48 = add nuw i64 %.019, 2
  %49 = getelementptr inbounds float, ptr %7, i64 %48
  %50 = load float, ptr %49, align 4, !tbaa !27
  %51 = fmul float %12, %50
  %52 = getelementptr inbounds float, ptr %22, i64 %48
  store float %51, ptr %52, align 4, !tbaa !27
  %53 = add nuw i64 %.019, 3
  %54 = getelementptr inbounds float, ptr %7, i64 %53
  %55 = load float, ptr %54, align 4, !tbaa !27
  %56 = fmul float %12, %55
  %57 = getelementptr inbounds float, ptr %22, i64 %53
  store float %56, ptr %57, align 4, !tbaa !27
  %58 = add nuw i64 %.019, 4
  %exitcond.not.3 = icmp eq i64 %58, %20
  br i1 %exitcond.not.3, label %.loopexit, label %scalar.ph, !llvm.loop !34

.loopexit:                                        ; preds = %scalar.ph.prol.loopexit, %scalar.ph, %middle.block, %.preheader, %1, %14
  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, !8, i64 40}
!6 = !{!"sig_host_AudioOut", !7, i64 0, !11, i64 16, !14, i64 24, !15, 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_AudioParameters", !12, i64 0, !13, i64 4}
!12 = !{!"int", !9, i64 0}
!13 = !{!"float", !9, i64 0}
!14 = !{!"sig_host_AudioOut_Inputs", !8, i64 0}
!15 = !{!"sig_dsp_Signal_SingleMonoOutput", !8, i64 0}
!16 = !{!17, !8, i64 56}
!17 = !{!"sig_host_HardwareInterface", !8, i64 0, !8, i64 8, !8, i64 16, !8, i64 24, !18, i64 32, !8, i64 40, !18, i64 48, !8, i64 56, !18, i64 64, !8, i64 72, !18, i64 80, !8, i64 88, !18, i64 96, !8, i64 104, !18, i64 112, !8, i64 120, !18, i64 128, !8, i64 136, !18, i64 144, !8, i64 152, !18, i64 160, !8, i64 168}
!18 = !{!"long", !9, i64 0}
!19 = !{!6, !8, i64 24}
!20 = !{!6, !12, i64 16}
!21 = !{!6, !13, i64 20}
!22 = !{!17, !18, i64 48}
!23 = !{!6, !8, i64 0}
!24 = !{!25, !18, i64 16}
!25 = !{!"sig_AudioSettings", !13, i64 0, !18, i64 8, !18, i64 16}
!26 = !{!8, !8, i64 0}
!27 = !{!13, !13, i64 0}
!28 = distinct !{!28, !29, !30, !31}
!29 = !{!"llvm.loop.mustprogress"}
!30 = !{!"llvm.loop.isvectorized", i32 1}
!31 = !{!"llvm.loop.unroll.runtime.disable"}
!32 = distinct !{!32, !33}
!33 = !{!"llvm.loop.unroll.disable"}
!34 = distinct !{!34, !29, !30}


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