; 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_AudioIn = type { %struct.sig_dsp_Signal, %struct.sig_host_AudioParameters, %struct.sig_dsp_Signal_SingleMonoOutput, ptr }
%struct.sig_dsp_Signal = type { ptr, ptr }
%struct.sig_host_AudioParameters = type { i32, float }
%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_AudioIn_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 i32, align 4
  %7 = alloca float, align 4
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  %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) #2
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.sig_host_AudioIn, 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 8, ptr %5) #2
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.sig_host_HardwareInterface, ptr %14, i32 0, i32 5
  %16 = load ptr, ptr %15, align 8, !tbaa !16
  store ptr %16, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.sig_host_AudioIn, ptr %17, i32 0, i32 1
  %19 = getelementptr inbounds %struct.sig_host_AudioParameters, ptr %18, i32 0, i32 0
  %20 = load i32, ptr %19, align 8, !tbaa !19
  store i32 %20, ptr %6, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.sig_host_AudioIn, ptr %21, i32 0, i32 1
  %23 = getelementptr inbounds %struct.sig_host_AudioParameters, ptr %22, i32 0, i32 1
  %24 = load float, ptr %23, align 4, !tbaa !21
  store float %24, ptr %7, align 4, !tbaa !22
  %25 = load i32, ptr %6, align 4, !tbaa !20
  %26 = icmp slt i32 %25, 0
  br i1 %26, label %34, label %27

27:                                               ; preds = %1
  %28 = load i32, ptr %6, align 4, !tbaa !20
  %29 = sext i32 %28 to i64
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.sig_host_HardwareInterface, ptr %30, i32 0, i32 4
  %32 = load i64, ptr %31, align 8, !tbaa !23
  %33 = icmp uge i64 %29, %32
  br i1 %33, label %34, label %35

34:                                               ; preds = %27, %1
  store i32 1, ptr %8, align 4
  br label %67

35:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  store i64 0, ptr %9, align 8, !tbaa !24
  br label %36

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

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

46:                                               ; preds = %36
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = load i32, ptr %6, align 4, !tbaa !20
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds ptr, ptr %47, i64 %49
  %51 = load ptr, ptr %50, align 8, !tbaa !5
  %52 = load i64, ptr %9, align 8, !tbaa !24
  %53 = getelementptr inbounds float, ptr %51, i64 %52
  %54 = load float, ptr %53, align 4, !tbaa !22
  %55 = load float, ptr %7, align 4, !tbaa !22
  %56 = fmul float %54, %55
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.sig_host_AudioIn, ptr %57, i32 0, i32 2
  %59 = getelementptr inbounds %struct.sig_dsp_Signal_SingleMonoOutput, ptr %58, i32 0, i32 0
  %60 = load ptr, ptr %59, align 8, !tbaa !28
  %61 = load i64, ptr %9, align 8, !tbaa !24
  %62 = getelementptr inbounds float, ptr %60, i64 %61
  store float %56, ptr %62, align 4, !tbaa !22
  br label %63

63:                                               ; preds = %46
  %64 = load i64, ptr %9, align 8, !tbaa !24
  %65 = add i64 %64, 1
  store i64 %65, ptr %9, align 8, !tbaa !24
  br label %36, !llvm.loop !29

66:                                               ; preds = %45
  store i32 0, ptr %8, align 4
  br label %67

67:                                               ; preds = %66, %34
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, 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
  %68 = load i32, ptr %8, align 4
  switch i32 %68, label %70 [
    i32 0, label %69
    i32 1, label %69
  ]

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

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

11:                                               ; preds = %1
  %12 = zext nneg i32 %7 to i64
  %13 = getelementptr inbounds i8, ptr %3, i64 32
  %14 = load i64, ptr %13, align 8, !tbaa !20
  %.not = icmp ugt i64 %14, %12
  br i1 %.not, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %11
  %15 = load ptr, ptr %0, align 8, !tbaa !21
  %16 = getelementptr inbounds i8, ptr %15, i64 16
  %17 = load i64, ptr %16, align 8, !tbaa !22
  %.not19 = icmp eq i64 %17, 0
  br i1 %.not19, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %18 = getelementptr inbounds ptr, ptr %5, i64 %12
  %19 = load ptr, ptr %18, align 8, !tbaa !24
  %20 = getelementptr inbounds i8, ptr %0, i64 24
  %21 = load ptr, ptr %20, align 8, !tbaa !25
  %min.iters.check = icmp ult i64 %17, 8
  %22 = ptrtoint ptr %21 to i64
  %23 = ptrtoint ptr %19 to i64
  %24 = sub i64 %22, %23
  %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 %17, -8
  %broadcast.splatinsert = insertelement <4 x float> poison, float %9, 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 %19, i64 %index
  %26 = getelementptr inbounds i8, ptr %25, i64 16
  %wide.load = load <4 x float>, ptr %25, align 4, !tbaa !26
  %wide.load20 = load <4 x float>, ptr %26, align 4, !tbaa !26
  %27 = fmul <4 x float> %broadcast.splat, %wide.load
  %28 = fmul <4 x float> %broadcast.splat, %wide.load20
  %29 = getelementptr inbounds float, ptr %21, i64 %index
  %30 = getelementptr inbounds i8, ptr %29, i64 16
  store <4 x float> %27, ptr %29, align 4, !tbaa !26
  store <4 x float> %28, ptr %30, align 4, !tbaa !26
  %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 !27

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

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

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

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

.loopexit:                                        ; preds = %scalar.ph.prol.loopexit, %scalar.ph, %middle.block, %.preheader, %1, %11
  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 32}
!6 = !{!"sig_host_AudioIn", !7, i64 0, !11, i64 16, !14, i64 24, !8, i64 32}
!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_dsp_Signal_SingleMonoOutput", !8, i64 0}
!15 = !{!16, !8, i64 40}
!16 = !{!"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}
!17 = !{!"long", !9, i64 0}
!18 = !{!6, !12, i64 16}
!19 = !{!6, !13, i64 20}
!20 = !{!16, !17, i64 32}
!21 = !{!6, !8, i64 0}
!22 = !{!23, !17, i64 16}
!23 = !{!"sig_AudioSettings", !13, i64 0, !17, i64 8, !17, i64 16}
!24 = !{!8, !8, i64 0}
!25 = !{!6, !8, i64 24}
!26 = !{!13, !13, i64 0}
!27 = distinct !{!27, !28, !29, !30}
!28 = !{!"llvm.loop.mustprogress"}
!29 = !{!"llvm.loop.isvectorized", i32 1}
!30 = !{!"llvm.loop.unroll.runtime.disable"}
!31 = distinct !{!31, !32}
!32 = !{!"llvm.loop.unroll.disable"}
!33 = distinct !{!33, !28, !29}


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