; LLVM IR from lichen-community-systems/signaletic :: libsignaletic/tests (test-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_Allocator = type { ptr, ptr }
%struct.sig_AudioSettings = type { float, i64, i64 }
%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 }

@allocator = external dso_local global %struct.sig_Allocator, align 8
@mono441kAudioSettings = external dso_local global %struct.sig_AudioSettings, align 8
@__const.test_sig_dsp_Sine.expected = external hidden unnamed_addr constant [64 x float], align 16

declare ptr @sig_SignalContext_new(ptr noundef, ptr noundef) #0

declare void @sig_SignalContext_destroy(ptr noundef, ptr noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

declare void @UnityAssertFloatsWithin(float noundef, float noundef, float noundef, ptr noundef, i64 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @createOscInputs(ptr noundef, ptr noundef, float noundef, float noundef, float noundef, float noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @destroyOscInputs(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @test_sig_dsp_Sine() #2 {
  %1 = alloca [64 x float], align 16
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 256, ptr %1) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %1, ptr align 16 @__const.test_sig_dsp_Sine.expected, i64 256, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  %5 = call ptr @sig_SignalContext_new(ptr noundef @allocator, ptr noundef @mono441kAudioSettings)
  store ptr %5, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = call ptr @sig_dsp_Sine_new(ptr noundef @allocator, ptr noundef %6)
  store ptr %7, ptr %3, align 8, !tbaa !5
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  call void @createOscInputs(ptr noundef @allocator, ptr noundef %8, float noundef 4.400000e+02, float noundef 0.000000e+00, float noundef 1.000000e+00, float noundef 0.000000e+00)
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.sig_dsp_Oscillator, ptr %9, i32 0, i32 0
  %11 = getelementptr inbounds %struct.sig_dsp_Signal, ptr %10, i32 0, i32 1
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  call void %12(ptr noundef %13)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  store i64 0, ptr %4, align 8, !tbaa !15
  br label %14

14:                                               ; preds = %29, %0
  %15 = load i64, ptr %4, align 8, !tbaa !15
  %16 = icmp ult i64 %15, 64
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  br label %32

18:                                               ; preds = %14
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.sig_dsp_Oscillator, ptr %19, i32 0, i32 2
  %21 = getelementptr inbounds %struct.sig_dsp_Oscillator_Outputs, ptr %20, i32 0, i32 0
  %22 = load ptr, ptr %21, align 8, !tbaa !17
  %23 = load i64, ptr %4, align 8, !tbaa !15
  %24 = getelementptr inbounds float, ptr %22, i64 %23
  %25 = load float, ptr %24, align 4, !tbaa !18
  %26 = load i64, ptr %4, align 8, !tbaa !15
  %27 = getelementptr inbounds [64 x float], ptr %1, i64 0, i64 %26
  %28 = load float, ptr %27, align 4, !tbaa !18
  call void @UnityAssertFloatsWithin(float noundef 0x3EE4F8B580000000, float noundef %25, float noundef %28, ptr noundef null, i64 noundef 608)
  br label %29

29:                                               ; preds = %18
  %30 = load i64, ptr %4, align 8, !tbaa !15
  %31 = add i64 %30, 1
  store i64 %31, ptr %4, align 8, !tbaa !15
  br label %14, !llvm.loop !19

32:                                               ; preds = %17
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.sig_dsp_Oscillator, ptr %33, i32 0, i32 1
  call void @destroyOscInputs(ptr noundef @allocator, ptr noundef %34)
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  call void @sig_dsp_Sine_destroy(ptr noundef @allocator, ptr noundef %35)
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  call void @sig_SignalContext_destroy(ptr noundef @allocator, ptr noundef %36)
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 256, ptr %1) #4
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

declare ptr @sig_dsp_Sine_new(ptr noundef, ptr noundef) #0

declare void @sig_dsp_Sine_destroy(ptr noundef, ptr noundef) #0

attributes #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !6, i64 8}
!10 = !{!"sig_dsp_Oscillator", !11, i64 0, !12, i64 16, !13, i64 48, !14, i64 64}
!11 = !{!"sig_dsp_Signal", !6, i64 0, !6, i64 8}
!12 = !{!"sig_dsp_Oscillator_Inputs", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!13 = !{!"sig_dsp_Oscillator_Outputs", !6, i64 0, !6, i64 8}
!14 = !{!"float", !7, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"long", !7, i64 0}
!17 = !{!10, !6, i64 48}
!18 = !{!14, !14, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"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"

%struct.sig_Allocator = type { ptr, ptr }
%struct.sig_AudioSettings = type { float, i64, i64 }

@allocator = external dso_local global %struct.sig_Allocator, align 8
@mono441kAudioSettings = external dso_local global %struct.sig_AudioSettings, align 8
@__const.test_sig_dsp_Sine.expected = external hidden unnamed_addr constant [64 x float], align 16

declare ptr @sig_SignalContext_new(ptr noundef, ptr noundef) local_unnamed_addr #0

declare void @sig_SignalContext_destroy(ptr noundef, ptr noundef) local_unnamed_addr #0

declare void @UnityAssertFloatsWithin(float noundef, float noundef, float noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @createOscInputs(ptr noundef, ptr noundef, float noundef, float noundef, float noundef, float noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @destroyOscInputs(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @test_sig_dsp_Sine() local_unnamed_addr #1 {
  %1 = tail call ptr @sig_SignalContext_new(ptr noundef nonnull @allocator, ptr noundef nonnull @mono441kAudioSettings) #2
  %2 = tail call ptr @sig_dsp_Sine_new(ptr noundef nonnull @allocator, ptr noundef %1) #2
  tail call void @createOscInputs(ptr noundef nonnull @allocator, ptr noundef %2, float noundef 4.400000e+02, float noundef 0.000000e+00, float noundef 1.000000e+00, float noundef 0.000000e+00)
  %3 = getelementptr inbounds i8, ptr %2, i64 8
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  tail call void %4(ptr noundef %2) #2
  %5 = getelementptr inbounds i8, ptr %2, i64 48
  br label %8

6:                                                ; preds = %8
  %7 = getelementptr inbounds i8, ptr %2, i64 16
  tail call void @destroyOscInputs(ptr noundef nonnull @allocator, ptr noundef nonnull %7)
  tail call void @sig_dsp_Sine_destroy(ptr noundef nonnull @allocator, ptr noundef nonnull %2) #2
  tail call void @sig_SignalContext_destroy(ptr noundef nonnull @allocator, ptr noundef %1) #2
  ret void

8:                                                ; preds = %0, %8
  %.011 = phi i64 [ 0, %0 ], [ %14, %8 ]
  %9 = load ptr, ptr %5, align 8, !tbaa !14
  %10 = getelementptr inbounds float, ptr %9, i64 %.011
  %11 = load float, ptr %10, align 4, !tbaa !15
  %12 = getelementptr inbounds [64 x float], ptr @__const.test_sig_dsp_Sine.expected, i64 0, i64 %.011
  %13 = load float, ptr %12, align 4, !tbaa !15
  tail call void @UnityAssertFloatsWithin(float noundef 0x3EE4F8B580000000, float noundef %11, float noundef %13, ptr noundef null, i64 noundef 608) #2
  %14 = add nuw nsw i64 %.011, 1
  %exitcond.not = icmp eq i64 %14, 64
  br i1 %exitcond.not, label %6, label %8, !llvm.loop !16
}

declare ptr @sig_dsp_Sine_new(ptr noundef, ptr noundef) local_unnamed_addr #0

declare void @sig_dsp_Sine_destroy(ptr noundef, ptr noundef) local_unnamed_addr #0

attributes #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 = { 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, !8, i64 8}
!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 = !{!6, !8, i64 48}
!15 = !{!13, !13, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass