; LLVM IR from lichen-community-systems/signaletic :: libsignaletic/src (libsignaletic)

; 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_dsp_Accumulate = type { %struct.sig_dsp_Signal, %struct.sig_dsp_Accumulate_Inputs, %struct.sig_dsp_Accumulate_Parameters, %struct.sig_dsp_Signal_SingleMonoOutput, float, float }
%struct.sig_dsp_Signal = type { ptr, ptr }
%struct.sig_dsp_Accumulate_Inputs = type { ptr, ptr }
%struct.sig_dsp_Accumulate_Parameters = type { float, float, float }
%struct.sig_dsp_Signal_SingleMonoOutput = type { 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_dsp_Accumulate_generate(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %8, ptr %3, align 8, !tbaa !5
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.sig_dsp_Accumulate, ptr %9, i32 0, i32 1
  %11 = getelementptr inbounds %struct.sig_dsp_Accumulate_Inputs, ptr %10, i32 0, i32 0
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  %13 = getelementptr inbounds float, ptr %12, i64 0
  %14 = load float, ptr %13, align 4, !tbaa !16
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.sig_dsp_Accumulate, ptr %15, i32 0, i32 4
  %17 = load float, ptr %16, align 8, !tbaa !17
  %18 = fadd float %17, %14
  store float %18, ptr %16, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.sig_dsp_Accumulate, ptr %19, i32 0, i32 1
  %21 = getelementptr inbounds %struct.sig_dsp_Accumulate_Inputs, ptr %20, i32 0, i32 1
  %22 = load ptr, ptr %21, align 8, !tbaa !18
  %23 = getelementptr inbounds float, ptr %22, i64 0
  %24 = load float, ptr %23, align 4, !tbaa !16
  store float %24, ptr %4, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.sig_dsp_Accumulate, ptr %25, i32 0, i32 2
  %27 = getelementptr inbounds %struct.sig_dsp_Accumulate_Parameters, ptr %26, i32 0, i32 1
  %28 = load float, ptr %27, align 4, !tbaa !19
  store float %28, ptr %5, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.sig_dsp_Accumulate, ptr %29, i32 0, i32 2
  %31 = getelementptr inbounds %struct.sig_dsp_Accumulate_Parameters, ptr %30, i32 0, i32 2
  %32 = load float, ptr %31, align 8, !tbaa !20
  store float %32, ptr %6, align 4, !tbaa !16
  %33 = load float, ptr %4, align 4, !tbaa !16
  %34 = fcmp ogt float %33, 0.000000e+00
  br i1 %34, label %35, label %47

35:                                               ; preds = %1
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.sig_dsp_Accumulate, ptr %36, i32 0, i32 5
  %38 = load float, ptr %37, align 4, !tbaa !21
  %39 = fcmp ole float %38, 0.000000e+00
  br i1 %39, label %40, label %47

40:                                               ; preds = %35
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.sig_dsp_Accumulate, ptr %41, i32 0, i32 2
  %43 = getelementptr inbounds %struct.sig_dsp_Accumulate_Parameters, ptr %42, i32 0, i32 0
  %44 = load float, ptr %43, align 8, !tbaa !22
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.sig_dsp_Accumulate, ptr %45, i32 0, i32 4
  store float %44, ptr %46, align 8, !tbaa !17
  br label %82

47:                                               ; preds = %35, %1
  %48 = load float, ptr %5, align 4, !tbaa !16
  %49 = fcmp ogt float %48, 0.000000e+00
  br i1 %49, label %50, label %81

50:                                               ; preds = %47
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.sig_dsp_Accumulate, ptr %51, i32 0, i32 4
  %53 = load float, ptr %52, align 8, !tbaa !17
  %54 = load float, ptr %6, align 4, !tbaa !16
  %55 = fcmp ogt float %53, %54
  br i1 %55, label %56, label %63

56:                                               ; preds = %50
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.sig_dsp_Accumulate, ptr %57, i32 0, i32 2
  %59 = getelementptr inbounds %struct.sig_dsp_Accumulate_Parameters, ptr %58, i32 0, i32 0
  %60 = load float, ptr %59, align 8, !tbaa !22
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.sig_dsp_Accumulate, ptr %61, i32 0, i32 4
  store float %60, ptr %62, align 8, !tbaa !17
  br label %80

63:                                               ; preds = %50
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.sig_dsp_Accumulate, ptr %64, i32 0, i32 4
  %66 = load float, ptr %65, align 8, !tbaa !17
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.sig_dsp_Accumulate, ptr %67, i32 0, i32 2
  %69 = getelementptr inbounds %struct.sig_dsp_Accumulate_Parameters, ptr %68, i32 0, i32 0
  %70 = load float, ptr %69, align 8, !tbaa !22
  %71 = fcmp olt float %66, %70
  br i1 %71, label %72, label %79

72:                                               ; preds = %63
  %73 = load ptr, ptr %3, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.sig_dsp_Accumulate, ptr %73, i32 0, i32 2
  %75 = getelementptr inbounds %struct.sig_dsp_Accumulate_Parameters, ptr %74, i32 0, i32 2
  %76 = load float, ptr %75, align 8, !tbaa !20
  %77 = load ptr, ptr %3, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.sig_dsp_Accumulate, ptr %77, i32 0, i32 4
  store float %76, ptr %78, align 8, !tbaa !17
  br label %79

79:                                               ; preds = %72, %63
  br label %80

80:                                               ; preds = %79, %56
  br label %81

81:                                               ; preds = %80, %47
  br label %82

82:                                               ; preds = %81, %40
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  store i64 0, ptr %7, align 8, !tbaa !23
  br label %83

83:                                               ; preds = %103, %82
  %84 = load i64, ptr %7, align 8, !tbaa !23
  %85 = load ptr, ptr %3, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.sig_dsp_Accumulate, ptr %85, i32 0, i32 0
  %87 = getelementptr inbounds %struct.sig_dsp_Signal, ptr %86, i32 0, i32 0
  %88 = load ptr, ptr %87, align 8, !tbaa !25
  %89 = getelementptr inbounds %struct.sig_AudioSettings, ptr %88, i32 0, i32 2
  %90 = load i64, ptr %89, align 8, !tbaa !26
  %91 = icmp ult i64 %84, %90
  br i1 %91, label %93, label %92

92:                                               ; preds = %83
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  br label %106

93:                                               ; preds = %83
  %94 = load ptr, ptr %3, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.sig_dsp_Accumulate, ptr %94, i32 0, i32 4
  %96 = load float, ptr %95, align 8, !tbaa !17
  %97 = load ptr, ptr %3, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.sig_dsp_Accumulate, ptr %97, i32 0, i32 3
  %99 = getelementptr inbounds %struct.sig_dsp_Signal_SingleMonoOutput, ptr %98, i32 0, i32 0
  %100 = load ptr, ptr %99, align 8, !tbaa !28
  %101 = load i64, ptr %7, align 8, !tbaa !23
  %102 = getelementptr inbounds float, ptr %100, i64 %101
  store float %96, ptr %102, align 4, !tbaa !16
  br label %103

103:                                              ; preds = %93
  %104 = load i64, ptr %7, align 8, !tbaa !23
  %105 = add i64 %104, 1
  store i64 %105, ptr %7, align 8, !tbaa !23
  br label %83, !llvm.loop !29

106:                                              ; preds = %92
  %107 = load float, ptr %4, align 4, !tbaa !16
  %108 = load ptr, ptr %3, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.sig_dsp_Accumulate, ptr %108, i32 0, i32 5
  store float %107, ptr %109, align 4, !tbaa !21
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  ret void
}

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 16}
!10 = !{!"sig_dsp_Accumulate", !11, i64 0, !12, i64 16, !13, i64 32, !15, i64 48, !14, i64 56, !14, i64 60}
!11 = !{!"sig_dsp_Signal", !6, i64 0, !6, i64 8}
!12 = !{!"sig_dsp_Accumulate_Inputs", !6, i64 0, !6, i64 8}
!13 = !{!"sig_dsp_Accumulate_Parameters", !14, i64 0, !14, i64 4, !14, i64 8}
!14 = !{!"float", !7, i64 0}
!15 = !{!"sig_dsp_Signal_SingleMonoOutput", !6, i64 0}
!16 = !{!14, !14, i64 0}
!17 = !{!10, !14, i64 56}
!18 = !{!10, !6, i64 24}
!19 = !{!10, !14, i64 36}
!20 = !{!10, !14, i64 40}
!21 = !{!10, !14, i64 60}
!22 = !{!10, !14, i64 32}
!23 = !{!24, !24, i64 0}
!24 = !{!"long", !7, i64 0}
!25 = !{!10, !6, i64 0}
!26 = !{!27, !24, i64 16}
!27 = !{!"sig_AudioSettings", !14, i64 0, !24, i64 8, !24, i64 16}
!28 = !{!10, !6, i64 48}
!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_dsp_Accumulate_generate(ptr nocapture noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 16
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = load float, ptr %3, align 4, !tbaa !15
  %5 = getelementptr inbounds i8, ptr %0, i64 56
  %6 = load float, ptr %5, align 8, !tbaa !16
  %7 = fadd float %4, %6
  store float %7, ptr %5, align 8, !tbaa !16
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = load ptr, ptr %8, align 8, !tbaa !17
  %10 = load float, ptr %9, align 4, !tbaa !15
  %11 = getelementptr inbounds i8, ptr %0, i64 32
  %12 = getelementptr inbounds i8, ptr %0, i64 36
  %13 = load float, ptr %12, align 4, !tbaa !18
  %14 = getelementptr inbounds i8, ptr %0, i64 40
  %15 = load float, ptr %14, align 8, !tbaa !19
  %16 = fcmp ogt float %10, 0.000000e+00
  br i1 %16, label %17, label %23

17:                                               ; preds = %1
  %18 = getelementptr inbounds i8, ptr %0, i64 60
  %19 = load float, ptr %18, align 4, !tbaa !20
  %20 = fcmp ugt float %19, 0.000000e+00
  br i1 %20, label %23, label %21

21:                                               ; preds = %17
  %22 = load float, ptr %11, align 8, !tbaa !21
  br label %.sink.split

23:                                               ; preds = %17, %1
  %24 = fcmp ogt float %13, 0.000000e+00
  br i1 %24, label %25, label %30

25:                                               ; preds = %23
  %26 = fcmp ogt float %7, %15
  %27 = load float, ptr %11, align 8, !tbaa !21
  br i1 %26, label %.sink.split, label %28

28:                                               ; preds = %25
  %29 = fcmp olt float %7, %27
  br i1 %29, label %.sink.split, label %30

.sink.split:                                      ; preds = %28, %25, %21
  %.sink = phi float [ %22, %21 ], [ %27, %25 ], [ %15, %28 ]
  store float %.sink, ptr %5, align 8, !tbaa !16
  br label %30

30:                                               ; preds = %.sink.split, %23, %28
  %31 = phi float [ %7, %23 ], [ %7, %28 ], [ %.sink, %.sink.split ]
  %32 = load ptr, ptr %0, align 8, !tbaa !22
  %33 = getelementptr inbounds i8, ptr %32, i64 16
  %34 = load i64, ptr %33, align 8, !tbaa !23
  %.not = icmp eq i64 %34, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %30
  %35 = getelementptr inbounds i8, ptr %0, i64 48
  %36 = load ptr, ptr %35, align 8, !tbaa !26
  %min.iters.check = icmp ult i64 %34, 8
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

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

vector.ph:                                        ; preds = %.lr.ph
  %n.vec = and i64 %34, -8
  %broadcast.splatinsert = insertelement <4 x float> poison, float %31, 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 ]
  %37 = getelementptr inbounds float, ptr %36, i64 %index
  %38 = getelementptr inbounds i8, ptr %37, i64 16
  store <4 x float> %broadcast.splat, ptr %37, align 4, !tbaa !15
  store <4 x float> %broadcast.splat, ptr %38, align 4, !tbaa !15
  %index.next = add nuw i64 %index, 8
  %39 = icmp eq i64 %index.next, %n.vec
  br i1 %39, label %middle.block, label %vector.body, !llvm.loop !27

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

._crit_edge:                                      ; preds = %scalar.ph, %middle.block, %30
  %40 = getelementptr inbounds i8, ptr %0, i64 60
  store float %10, ptr %40, align 4, !tbaa !20
  ret void

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %.027 = phi i64 [ %42, %scalar.ph ], [ %.027.ph, %scalar.ph.preheader ]
  %41 = getelementptr inbounds float, ptr %36, i64 %.027
  store float %31, ptr %41, align 4, !tbaa !15
  %42 = add nuw i64 %.027, 1
  %exitcond.not = icmp eq i64 %42, %34
  br i1 %exitcond.not, label %._crit_edge, label %scalar.ph, !llvm.loop !31
}

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 16}
!6 = !{!"sig_dsp_Accumulate", !7, i64 0, !11, i64 16, !12, i64 32, !14, i64 48, !13, i64 56, !13, i64 60}
!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_dsp_Accumulate_Inputs", !8, i64 0, !8, i64 8}
!12 = !{!"sig_dsp_Accumulate_Parameters", !13, i64 0, !13, i64 4, !13, i64 8}
!13 = !{!"float", !9, i64 0}
!14 = !{!"sig_dsp_Signal_SingleMonoOutput", !8, i64 0}
!15 = !{!13, !13, i64 0}
!16 = !{!6, !13, i64 56}
!17 = !{!6, !8, i64 24}
!18 = !{!6, !13, i64 36}
!19 = !{!6, !13, i64 40}
!20 = !{!6, !13, i64 60}
!21 = !{!6, !13, i64 32}
!22 = !{!6, !8, i64 0}
!23 = !{!24, !25, i64 16}
!24 = !{!"sig_AudioSettings", !13, i64 0, !25, i64 8, !25, i64 16}
!25 = !{!"long", !9, i64 0}
!26 = !{!6, !8, i64 48}
!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, !28, !30, !29}


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