; 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fabs.f32(float) #2

; 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_LFTriangle_generate(ptr noundef %0) #3 {
  %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
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %8, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  store i64 0, ptr %4, align 8, !tbaa !9
  br label %9

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

18:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  br label %77

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

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

77:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  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 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, !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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fabs.f32(float) #1

; 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_LFTriangle_generate(ptr noundef %0) local_unnamed_addr #2 {
  %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
  %.022 = phi i64 [ 0, %.lr.ph ], [ %36, %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 %.022
  %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 = fmul float %19, 0x3FC45F3060000000
  %21 = tail call float @llvm.fmuladd.f32(float %20, float 2.000000e+00, float -1.000000e+00)
  %22 = tail call float @llvm.fabs.f32(float %21)
  %23 = fadd float %22, -5.000000e-01
  %24 = fmul float %23, 2.000000e+00
  %25 = load ptr, ptr %7, align 8, !tbaa !20
  %26 = getelementptr inbounds float, ptr %25, i64 %.022
  %27 = load float, ptr %26, align 4, !tbaa !19
  %28 = load ptr, ptr %8, align 8, !tbaa !21
  %29 = getelementptr inbounds float, ptr %28, i64 %.022
  %30 = load float, ptr %29, align 4, !tbaa !19
  %31 = tail call float @llvm.fmuladd.f32(float %24, float %27, float %30)
  %32 = load ptr, ptr %9, align 8, !tbaa !22
  %33 = getelementptr inbounds float, ptr %32, i64 %.022
  store float %31, ptr %33, align 4, !tbaa !19
  %34 = load ptr, ptr %10, align 8, !tbaa !23
  %35 = getelementptr inbounds float, ptr %34, i64 %.022
  store float %17, ptr %35, align 4, !tbaa !19
  tail call void @sig_dsp_Oscillator_accumulatePhase(ptr noundef nonnull %0, i64 noundef %.022)
  %36 = add nuw i64 %.022, 1
  %37 = load ptr, ptr %0, align 8, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %37, i64 16
  %39 = load i64, ptr %38, align 8, !tbaa !14
  %40 = icmp ult i64 %36, %39
  br i1 %40, 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 = { 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" }

!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