; 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_Oscillator = type { %struct.sig_dsp_Signal, %struct.sig_dsp_Oscillator_Inputs, %struct.sig_dsp_Oscillator_Outputs, float }
%struct.sig_dsp_Signal = type { ptr, ptr }
%struct.sig_dsp_Oscillator_Inputs = type { ptr, ptr, ptr, ptr }
%struct.sig_dsp_Oscillator_Outputs = type { ptr, 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: inlinehint nounwind uwtable
declare dso_local float @sig_flooredfmodf(float noundef, float noundef) #1

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

; Function Attrs: nounwind
declare float @sinf(float noundef) #3

; Function Attrs: inlinehint nounwind uwtable
declare dso_local float @sig_dsp_Oscillator_eoc(float noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare dso_local void @sig_dsp_Oscillator_accumulatePhase(ptr noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @sig_dsp_Sine_generate(ptr noundef %0) #4 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %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) #5
  store i64 0, ptr %4, align 8, !tbaa !9
  br label %11

11:                                               ; preds = %73, %1
  %12 = load i64, ptr %4, align 8, !tbaa !9
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.sig_dsp_Oscillator, ptr %13, i32 0, i32 0
  %15 = getelementptr inbounds %struct.sig_dsp_Signal, ptr %14, i32 0, i32 0
  %16 = load ptr, ptr %15, align 8, !tbaa !11
  %17 = getelementptr inbounds %struct.sig_AudioSettings, ptr %16, i32 0, i32 2
  %18 = load i64, ptr %17, align 8, !tbaa !17
  %19 = icmp ult i64 %12, %18
  br i1 %19, label %21, label %20

20:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  br label %76

21:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.sig_dsp_Oscillator, ptr %22, i32 0, i32 3
  %24 = load float, ptr %23, align 8, !tbaa !19
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.sig_dsp_Oscillator, ptr %25, i32 0, i32 1
  %27 = getelementptr inbounds %struct.sig_dsp_Oscillator_Inputs, ptr %26, i32 0, i32 1
  %28 = load ptr, ptr %27, align 8, !tbaa !20
  %29 = load i64, ptr %4, align 8, !tbaa !9
  %30 = getelementptr inbounds float, ptr %28, i64 %29
  %31 = load float, ptr %30, align 4, !tbaa !21
  %32 = fadd float %24, %31
  store float %32, ptr %5, align 4, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %33 = load float, ptr %5, align 4, !tbaa !21
  %34 = call float @sig_dsp_Oscillator_eoc(float noundef %33)
  store float %34, ptr %6, align 4, !tbaa !21
  %35 = load float, ptr %5, align 4, !tbaa !21
  %36 = call float @sig_flooredfmodf(float noundef %35, float noundef 1.000000e+00)
  store float %36, ptr %5, align 4, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %37 = load float, ptr %5, align 4, !tbaa !21
  %38 = fmul float %37, 0x401921FB60000000
  store float %38, ptr %7, align 4, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %39 = load float, ptr %7, align 4, !tbaa !21
  %40 = call float @sinf(float noundef %39) #5
  store float %40, ptr %8, align 4, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %41 = load float, ptr %8, align 4, !tbaa !21
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.sig_dsp_Oscillator, ptr %42, i32 0, i32 1
  %44 = getelementptr inbounds %struct.sig_dsp_Oscillator_Inputs, ptr %43, i32 0, i32 2
  %45 = load ptr, ptr %44, align 8, !tbaa !22
  %46 = load i64, ptr %4, align 8, !tbaa !9
  %47 = getelementptr inbounds float, ptr %45, i64 %46
  %48 = load float, ptr %47, align 4, !tbaa !21
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.sig_dsp_Oscillator, ptr %49, i32 0, i32 1
  %51 = getelementptr inbounds %struct.sig_dsp_Oscillator_Inputs, ptr %50, i32 0, i32 3
  %52 = load ptr, ptr %51, align 8, !tbaa !23
  %53 = load i64, ptr %4, align 8, !tbaa !9
  %54 = getelementptr inbounds float, ptr %52, i64 %53
  %55 = load float, ptr %54, align 4, !tbaa !21
  %56 = call float @llvm.fmuladd.f32(float %41, float %48, float %55)
  store float %56, ptr %9, align 4, !tbaa !21
  %57 = load float, ptr %9, align 4, !tbaa !21
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.sig_dsp_Oscillator, ptr %58, i32 0, i32 2
  %60 = getelementptr inbounds %struct.sig_dsp_Oscillator_Outputs, ptr %59, i32 0, i32 0
  %61 = load ptr, ptr %60, align 8, !tbaa !24
  %62 = load i64, ptr %4, align 8, !tbaa !9
  %63 = getelementptr inbounds float, ptr %61, i64 %62
  store float %57, ptr %63, align 4, !tbaa !21
  %64 = load float, ptr %6, align 4, !tbaa !21
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.sig_dsp_Oscillator, ptr %65, i32 0, i32 2
  %67 = getelementptr inbounds %struct.sig_dsp_Oscillator_Outputs, ptr %66, i32 0, i32 1
  %68 = load ptr, ptr %67, align 8, !tbaa !25
  %69 = load i64, ptr %4, align 8, !tbaa !9
  %70 = getelementptr inbounds float, ptr %68, i64 %69
  store float %64, ptr %70, align 4, !tbaa !21
  %71 = load ptr, ptr %3, align 8, !tbaa !5
  %72 = load i64, ptr %4, align 8, !tbaa !9
  call void @sig_dsp_Oscillator_accumulatePhase(ptr noundef %71, i64 noundef %72)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %73

73:                                               ; preds = %21
  %74 = load i64, ptr %4, align 8, !tbaa !9
  %75 = add i64 %74, 1
  store i64 %75, ptr %4, align 8, !tbaa !9
  br label %11, !llvm.loop !26

76:                                               ; preds = %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 "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 #4 = { 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 #5 = { 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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"sig_dsp_Oscillator", !13, i64 0, !14, i64 16, !15, i64 48, !16, i64 64}
!13 = !{!"sig_dsp_Signal", !6, i64 0, !6, i64 8}
!14 = !{!"sig_dsp_Oscillator_Inputs", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!15 = !{!"sig_dsp_Oscillator_Outputs", !6, i64 0, !6, i64 8}
!16 = !{!"float", !7, i64 0}
!17 = !{!18, !10, i64 16}
!18 = !{!"sig_AudioSettings", !16, i64 0, !10, i64 8, !10, i64 16}
!19 = !{!12, !16, i64 64}
!20 = !{!12, !6, i64 24}
!21 = !{!16, !16, i64 0}
!22 = !{!12, !6, i64 32}
!23 = !{!12, !6, i64 40}
!24 = !{!12, !6, i64 48}
!25 = !{!12, !6, i64 56}
!26 = distinct !{!26, !27}
!27 = !{!"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: inlinehint nounwind uwtable
declare dso_local float @sig_flooredfmodf(float noundef, float noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @sinf(float noundef) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare dso_local float @sig_dsp_Oscillator_eoc(float noundef) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare dso_local void @sig_dsp_Oscillator_accumulatePhase(ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @sig_dsp_Sine_generate(ptr noundef %0) local_unnamed_addr #3 {
  %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 !14
  %.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 64
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  %7 = getelementptr inbounds i8, ptr %0, i64 32
  %8 = getelementptr inbounds i8, ptr %0, i64 40
  %9 = getelementptr inbounds i8, ptr %0, i64 48
  %10 = getelementptr inbounds i8, ptr %0, i64 56
  br label %11

._crit_edge:                                      ; preds = %11, %1
  ret void

11:                                               ; preds = %.lr.ph, %11
  %.023 = phi i64 [ 0, %.lr.ph ], [ %32, %11 ]
  %12 = load float, ptr %5, align 8, !tbaa !17
  %13 = load ptr, ptr %6, align 8, !tbaa !18
  %14 = getelementptr inbounds float, ptr %13, i64 %.023
  %15 = load float, ptr %14, align 4, !tbaa !19
  %16 = fadd float %12, %15
  %17 = tail call float @sig_dsp_Oscillator_eoc(float noundef %16)
  %18 = tail call float @sig_flooredfmodf(float noundef %16, float noundef 1.000000e+00)
  %19 = fmul float %18, 0x401921FB60000000
  %20 = tail call float @sinf(float noundef %19) #4
  %21 = load ptr, ptr %7, align 8, !tbaa !20
  %22 = getelementptr inbounds float, ptr %21, i64 %.023
  %23 = load float, ptr %22, align 4, !tbaa !19
  %24 = load ptr, ptr %8, align 8, !tbaa !21
  %25 = getelementptr inbounds float, ptr %24, i64 %.023
  %26 = load float, ptr %25, align 4, !tbaa !19
  %27 = tail call float @llvm.fmuladd.f32(float %20, float %23, float %26)
  %28 = load ptr, ptr %9, align 8, !tbaa !22
  %29 = getelementptr inbounds float, ptr %28, i64 %.023
  store float %27, ptr %29, align 4, !tbaa !19
  %30 = load ptr, ptr %10, align 8, !tbaa !23
  %31 = getelementptr inbounds float, ptr %30, i64 %.023
  store float %17, ptr %31, align 4, !tbaa !19
  tail call void @sig_dsp_Oscillator_accumulatePhase(ptr noundef nonnull %0, i64 noundef %.023)
  %32 = add nuw i64 %.023, 1
  %33 = load ptr, ptr %0, align 8, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %33, i64 16
  %35 = load i64, ptr %34, align 8, !tbaa !14
  %36 = icmp ult i64 %32, %35
  br i1 %36, label %11, label %._crit_edge, !llvm.loop !24
}

attributes #0 = { inlinehint 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 #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { mustprogress nofree nounwind willreturn memory(write) "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 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 #4 = { 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, !8, i64 0}
!6 = !{!"sig_dsp_Oscillator", !7, i64 0, !11, i64 16, !12, i64 48, !13, i64 64}
!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_Oscillator_Inputs", !8, i64 0, !8, i64 8, !8, i64 16, !8, i64 24}
!12 = !{!"sig_dsp_Oscillator_Outputs", !8, i64 0, !8, i64 8}
!13 = !{!"float", !9, i64 0}
!14 = !{!15, !16, i64 16}
!15 = !{!"sig_AudioSettings", !13, i64 0, !16, i64 8, !16, i64 16}
!16 = !{!"long", !9, i64 0}
!17 = !{!6, !13, i64 64}
!18 = !{!6, !8, i64 24}
!19 = !{!13, !13, i64 0}
!20 = !{!6, !8, i64 32}
!21 = !{!6, !8, i64 40}
!22 = !{!6, !8, i64 48}
!23 = !{!6, !8, i64 56}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}


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