; 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_test_BufferPlayer = type { %struct.sig_dsp_Signal, %struct.sig_dsp_Signal_SingleMonoOutput, ptr, i64 }
%struct.sig_dsp_Signal = type { ptr, ptr }
%struct.sig_dsp_Signal_SingleMonoOutput = type { ptr }
%struct.sig_dsp_ClockDetector = type { %struct.sig_dsp_Signal, %struct.sig_dsp_ClockDetector_Inputs, %struct.sig_dsp_ClockDetector_Parameters, %struct.sig_dsp_ClockDetector_Outputs, float, i8, i8, i32, float, i32 }
%struct.sig_dsp_ClockDetector_Inputs = type { ptr }
%struct.sig_dsp_ClockDetector_Parameters = type { float }
%struct.sig_dsp_ClockDetector_Outputs = type { ptr, ptr }

@allocator = external dso_local global %struct.sig_Allocator, align 8
@audioSettings = external dso_local global ptr, align 8
@context = external dso_local global ptr, align 8
@.str.28 = external hidden unnamed_addr constant [59 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [59 x i8], align 1

; 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

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

; Function Attrs: nounwind uwtable
define dso_local void @testClockDetector(ptr noundef %0, float noundef %1, float noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca ptr, align 8
  %8 = alloca [2 x ptr], align 16
  %9 = alloca float, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store float %1, ptr %5, align 4, !tbaa !9
  store float %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %10 = load ptr, ptr @context, align 8, !tbaa !5
  %11 = call ptr @sig_dsp_ClockDetector_new(ptr noundef @allocator, ptr noundef %10)
  store ptr %11, ptr %7, align 8, !tbaa !5
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.sig_test_BufferPlayer, ptr %12, i32 0, i32 1
  %14 = getelementptr inbounds %struct.sig_dsp_Signal_SingleMonoOutput, ptr %13, i32 0, i32 0
  %15 = load ptr, ptr %14, align 8, !tbaa !11
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.sig_dsp_ClockDetector, ptr %16, i32 0, i32 1
  %18 = getelementptr inbounds %struct.sig_dsp_ClockDetector_Inputs, ptr %17, i32 0, i32 0
  store ptr %15, ptr %18, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #3
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.sig_test_BufferPlayer, ptr %19, i32 0, i32 0
  store ptr %20, ptr %8, align 8, !tbaa !5
  %21 = getelementptr inbounds ptr, ptr %8, i64 1
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.sig_dsp_ClockDetector, ptr %22, i32 0, i32 0
  store ptr %23, ptr %21, align 8, !tbaa !5
  %24 = load ptr, ptr @audioSettings, align 8, !tbaa !5
  %25 = getelementptr inbounds [2 x ptr], ptr %8, i64 0, i64 0
  %26 = load float, ptr %5, align 4, !tbaa !9
  call void @evaluateSignals(ptr noundef %24, ptr noundef %25, i64 noundef 2, float noundef %26)
  %27 = load float, ptr %6, align 4, !tbaa !9
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.sig_dsp_ClockDetector, ptr %28, i32 0, i32 3
  %30 = getelementptr inbounds %struct.sig_dsp_ClockDetector_Outputs, ptr %29, i32 0, i32 0
  %31 = load ptr, ptr %30, align 8, !tbaa !23
  %32 = getelementptr inbounds float, ptr %31, i64 0
  %33 = load float, ptr %32, align 4, !tbaa !9
  call void @UnityAssertFloatsWithin(float noundef 0x3F2A36E2E0000000, float noundef %27, float noundef %33, ptr noundef @.str.28, i64 noundef 767)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %34 = load float, ptr %6, align 4, !tbaa !9
  %35 = fmul float %34, 6.000000e+01
  store float %35, ptr %9, align 4, !tbaa !9
  %36 = load float, ptr %9, align 4, !tbaa !9
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.sig_dsp_ClockDetector, ptr %37, i32 0, i32 3
  %39 = getelementptr inbounds %struct.sig_dsp_ClockDetector_Outputs, ptr %38, i32 0, i32 1
  %40 = load ptr, ptr %39, align 8, !tbaa !24
  %41 = getelementptr inbounds float, ptr %40, i64 0
  %42 = load float, ptr %41, align 4, !tbaa !9
  call void @UnityAssertFloatsWithin(float noundef 0x3FA99999A0000000, float noundef %36, float noundef %42, ptr noundef @.str.29, i64 noundef 774)
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  call void @sig_dsp_ClockDetector_destroy(ptr noundef @allocator, ptr noundef %43)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret void
}

declare ptr @sig_dsp_ClockDetector_new(ptr noundef, ptr noundef) #1

declare void @evaluateSignals(ptr noundef, ptr noundef, i64 noundef, float noundef) #1

declare void @sig_dsp_ClockDetector_destroy(ptr noundef, ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 = { 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 = !{!"float", !7, i64 0}
!11 = !{!12, !6, i64 16}
!12 = !{!"sig_test_BufferPlayer", !13, i64 0, !14, i64 16, !6, i64 24, !15, i64 32}
!13 = !{!"sig_dsp_Signal", !6, i64 0, !6, i64 8}
!14 = !{!"sig_dsp_Signal_SingleMonoOutput", !6, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!17, !6, i64 16}
!17 = !{!"sig_dsp_ClockDetector", !13, i64 0, !18, i64 16, !19, i64 24, !20, i64 32, !10, i64 48, !21, i64 52, !7, i64 53, !22, i64 56, !10, i64 60, !22, i64 64}
!18 = !{!"sig_dsp_ClockDetector_Inputs", !6, i64 0}
!19 = !{!"sig_dsp_ClockDetector_Parameters", !10, i64 0}
!20 = !{!"sig_dsp_ClockDetector_Outputs", !6, i64 0, !6, i64 8}
!21 = !{!"_Bool", !7, i64 0}
!22 = !{!"int", !7, i64 0}
!23 = !{!17, !6, i64 32}
!24 = !{!17, !6, i64 40}


; 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 }

@allocator = external dso_local global %struct.sig_Allocator, align 8
@audioSettings = external dso_local local_unnamed_addr global ptr, align 8
@context = external dso_local local_unnamed_addr global ptr, align 8
@.str.28 = external hidden unnamed_addr constant [59 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [59 x i8], align 1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @testClockDetector(ptr noundef %0, float noundef %1, float noundef %2) local_unnamed_addr #2 {
  %4 = alloca [2 x ptr], align 16
  %5 = load ptr, ptr @context, align 8, !tbaa !5
  %6 = tail call ptr @sig_dsp_ClockDetector_new(ptr noundef nonnull @allocator, ptr noundef %5) #3
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  %9 = getelementptr inbounds i8, ptr %6, i64 16
  store ptr %8, ptr %9, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #3
  store ptr %0, ptr %4, align 16, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %4, i64 8
  store ptr %6, ptr %10, align 8, !tbaa !5
  %11 = load ptr, ptr @audioSettings, align 8, !tbaa !5
  call void @evaluateSignals(ptr noundef %11, ptr noundef nonnull %4, i64 noundef 2, float noundef %1) #3
  %12 = getelementptr inbounds i8, ptr %6, i64 32
  %13 = load ptr, ptr %12, align 8, !tbaa !22
  %14 = load float, ptr %13, align 4, !tbaa !23
  call void @UnityAssertFloatsWithin(float noundef 0x3F2A36E2E0000000, float noundef %2, float noundef %14, ptr noundef nonnull @.str.28, i64 noundef 767) #3
  %15 = fmul float %2, 6.000000e+01
  %16 = getelementptr inbounds i8, ptr %6, i64 40
  %17 = load ptr, ptr %16, align 8, !tbaa !24
  %18 = load float, ptr %17, align 4, !tbaa !23
  call void @UnityAssertFloatsWithin(float noundef 0x3FA99999A0000000, float noundef %15, float noundef %18, ptr noundef nonnull @.str.29, i64 noundef 774) #3
  call void @sig_dsp_ClockDetector_destroy(ptr noundef nonnull @allocator, ptr noundef %6) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #3
  ret void
}

declare ptr @sig_dsp_ClockDetector_new(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @evaluateSignals(ptr noundef, ptr noundef, i64 noundef, float noundef) local_unnamed_addr #1

declare void @sig_dsp_ClockDetector_destroy(ptr noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 = { 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_test_BufferPlayer", !11, i64 0, !12, i64 16, !6, i64 24, !13, i64 32}
!11 = !{!"sig_dsp_Signal", !6, i64 0, !6, i64 8}
!12 = !{!"sig_dsp_Signal_SingleMonoOutput", !6, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!15, !6, i64 16}
!15 = !{!"sig_dsp_ClockDetector", !11, i64 0, !16, i64 16, !17, i64 24, !19, i64 32, !18, i64 48, !20, i64 52, !7, i64 53, !21, i64 56, !18, i64 60, !21, i64 64}
!16 = !{!"sig_dsp_ClockDetector_Inputs", !6, i64 0}
!17 = !{!"sig_dsp_ClockDetector_Parameters", !18, i64 0}
!18 = !{!"float", !7, i64 0}
!19 = !{!"sig_dsp_ClockDetector_Outputs", !6, i64 0, !6, i64 8}
!20 = !{!"_Bool", !7, i64 0}
!21 = !{!"int", !7, i64 0}
!22 = !{!15, !6, i64 32}
!23 = !{!18, !18, i64 0}
!24 = !{!15, !6, i64 40}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,TailCallElimPass