; 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_dsp_TimedGate = type { %struct.sig_dsp_Signal, %struct.sig_dsp_TimedGate_Inputs, %struct.sig_dsp_TimedGate_Parameters, %struct.sig_dsp_Signal_SingleMonoOutput, float, float, float, i64, i64 }
%struct.sig_dsp_Signal = type { ptr, ptr }
%struct.sig_dsp_TimedGate_Inputs = type { ptr, ptr }
%struct.sig_dsp_TimedGate_Parameters = type { float, float }
%struct.sig_dsp_Signal_SingleMonoOutput = type { ptr }
%struct.sig_test_BufferPlayer = type { %struct.sig_dsp_Signal, %struct.sig_dsp_Signal_SingleMonoOutput, ptr, i64 }
%struct.sig_test_BufferRecorder = type { %struct.sig_dsp_Signal, %struct.sig_test_BufferRecorder_Inputs, %struct.sig_dsp_Signal_SingleMonoOutput, ptr, i64 }
%struct.sig_test_BufferRecorder_Inputs = type { 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

; 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 ptr @sig_AudioBlock_newWithValue(ptr noundef, ptr noundef, float noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @runTimedGate(ptr noundef %0, ptr noundef %1, float noundef %2, float noundef %3, float noundef %4, float noundef %5) #2 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca [3 x ptr], align 16
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store float %2, ptr %9, align 4, !tbaa !9
  store float %3, ptr %10, align 4, !tbaa !9
  store float %4, ptr %11, align 4, !tbaa !9
  store float %5, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %16 = load ptr, ptr @context, align 8, !tbaa !5
  %17 = call ptr @sig_dsp_TimedGate_new(ptr noundef @allocator, ptr noundef %16)
  store ptr %17, ptr %13, align 8, !tbaa !5
  %18 = load ptr, ptr @audioSettings, align 8, !tbaa !5
  %19 = load float, ptr %10, align 4, !tbaa !9
  %20 = call ptr @sig_AudioBlock_newWithValue(ptr noundef @allocator, ptr noundef %18, float noundef %19)
  %21 = load ptr, ptr %13, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.sig_dsp_TimedGate, ptr %21, i32 0, i32 1
  %23 = getelementptr inbounds %struct.sig_dsp_TimedGate_Inputs, ptr %22, i32 0, i32 1
  store ptr %20, ptr %23, align 8, !tbaa !11
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.sig_test_BufferPlayer, ptr %24, i32 0, i32 1
  %26 = getelementptr inbounds %struct.sig_dsp_Signal_SingleMonoOutput, ptr %25, i32 0, i32 0
  %27 = load ptr, ptr %26, align 8, !tbaa !18
  %28 = load ptr, ptr %13, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.sig_dsp_TimedGate, ptr %28, i32 0, i32 1
  %30 = getelementptr inbounds %struct.sig_dsp_TimedGate_Inputs, ptr %29, i32 0, i32 0
  store ptr %27, ptr %30, align 8, !tbaa !20
  %31 = load float, ptr %11, align 4, !tbaa !9
  %32 = load ptr, ptr %13, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.sig_dsp_TimedGate, ptr %32, i32 0, i32 2
  %34 = getelementptr inbounds %struct.sig_dsp_TimedGate_Parameters, ptr %33, i32 0, i32 0
  store float %31, ptr %34, align 8, !tbaa !21
  %35 = load float, ptr %12, align 4, !tbaa !9
  %36 = load ptr, ptr %13, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.sig_dsp_TimedGate, ptr %36, i32 0, i32 2
  %38 = getelementptr inbounds %struct.sig_dsp_TimedGate_Parameters, ptr %37, i32 0, i32 1
  store float %35, ptr %38, align 4, !tbaa !22
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %39 = load ptr, ptr @context, align 8, !tbaa !5
  %40 = load ptr, ptr %8, align 8, !tbaa !5
  %41 = call ptr @sig_test_BufferRecorder_new(ptr noundef @allocator, ptr noundef %39, ptr noundef %40)
  store ptr %41, ptr %14, align 8, !tbaa !5
  %42 = load ptr, ptr %13, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.sig_dsp_TimedGate, ptr %42, i32 0, i32 3
  %44 = getelementptr inbounds %struct.sig_dsp_Signal_SingleMonoOutput, ptr %43, i32 0, i32 0
  %45 = load ptr, ptr %44, align 8, !tbaa !23
  %46 = load ptr, ptr %14, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.sig_test_BufferRecorder, ptr %46, i32 0, i32 1
  %48 = getelementptr inbounds %struct.sig_test_BufferRecorder_Inputs, ptr %47, i32 0, i32 0
  store ptr %45, ptr %48, align 8, !tbaa !24
  call void @llvm.lifetime.start.p0(i64 24, ptr %15) #3
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.sig_test_BufferPlayer, ptr %49, i32 0, i32 0
  store ptr %50, ptr %15, align 8, !tbaa !5
  %51 = getelementptr inbounds ptr, ptr %15, i64 1
  %52 = load ptr, ptr %13, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.sig_dsp_TimedGate, ptr %52, i32 0, i32 0
  store ptr %53, ptr %51, align 8, !tbaa !5
  %54 = getelementptr inbounds ptr, ptr %15, i64 2
  %55 = load ptr, ptr %14, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.sig_test_BufferRecorder, ptr %55, i32 0, i32 0
  store ptr %56, ptr %54, align 8, !tbaa !5
  %57 = load ptr, ptr @audioSettings, align 8, !tbaa !5
  %58 = getelementptr inbounds [3 x ptr], ptr %15, i64 0, i64 0
  %59 = load float, ptr %9, align 4, !tbaa !9
  call void @evaluateSignals(ptr noundef %57, ptr noundef %58, i64 noundef 3, float noundef %59)
  call void @llvm.lifetime.end.p0(i64 24, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  ret void
}

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

declare ptr @sig_test_BufferRecorder_new(ptr noundef, 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 24}
!12 = !{!"sig_dsp_TimedGate", !13, i64 0, !14, i64 16, !15, i64 32, !16, i64 40, !10, i64 48, !10, i64 52, !10, i64 56, !17, i64 64, !17, i64 72}
!13 = !{!"sig_dsp_Signal", !6, i64 0, !6, i64 8}
!14 = !{!"sig_dsp_TimedGate_Inputs", !6, i64 0, !6, i64 8}
!15 = !{!"sig_dsp_TimedGate_Parameters", !10, i64 0, !10, i64 4}
!16 = !{!"sig_dsp_Signal_SingleMonoOutput", !6, i64 0}
!17 = !{!"long", !7, i64 0}
!18 = !{!19, !6, i64 16}
!19 = !{!"sig_test_BufferPlayer", !13, i64 0, !16, i64 16, !6, i64 24, !17, i64 32}
!20 = !{!12, !6, i64 16}
!21 = !{!12, !10, i64 32}
!22 = !{!12, !10, i64 36}
!23 = !{!12, !6, i64 40}
!24 = !{!25, !6, i64 16}
!25 = !{!"sig_test_BufferRecorder", !13, i64 0, !26, i64 16, !16, i64 24, !6, i64 32, !17, i64 40}
!26 = !{!"sig_test_BufferRecorder_Inputs", !6, i64 0}


; 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

; 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 ptr @sig_AudioBlock_newWithValue(ptr noundef, ptr noundef, float noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local void @runTimedGate(ptr noundef %0, ptr noundef %1, float noundef %2, float noundef %3, float noundef %4, float noundef %5) local_unnamed_addr #2 {
  %7 = alloca [3 x ptr], align 16
  %8 = load ptr, ptr @context, align 8, !tbaa !5
  %9 = tail call ptr @sig_dsp_TimedGate_new(ptr noundef nonnull @allocator, ptr noundef %8) #3
  %10 = load ptr, ptr @audioSettings, align 8, !tbaa !5
  %11 = tail call ptr @sig_AudioBlock_newWithValue(ptr noundef nonnull @allocator, ptr noundef %10, float noundef %3) #3
  %12 = getelementptr inbounds i8, ptr %9, i64 16
  %13 = getelementptr inbounds i8, ptr %9, i64 24
  store ptr %11, ptr %13, align 8, !tbaa !9
  %14 = getelementptr inbounds i8, ptr %0, i64 16
  %15 = load ptr, ptr %14, align 8, !tbaa !17
  store ptr %15, ptr %12, align 8, !tbaa !19
  %16 = getelementptr inbounds i8, ptr %9, i64 32
  store float %4, ptr %16, align 8, !tbaa !20
  %17 = getelementptr inbounds i8, ptr %9, i64 36
  store float %5, ptr %17, align 4, !tbaa !21
  %18 = load ptr, ptr @context, align 8, !tbaa !5
  %19 = tail call ptr @sig_test_BufferRecorder_new(ptr noundef nonnull @allocator, ptr noundef %18, ptr noundef %1) #3
  %20 = getelementptr inbounds i8, ptr %9, i64 40
  %21 = load ptr, ptr %20, align 8, !tbaa !22
  %22 = getelementptr inbounds i8, ptr %19, i64 16
  store ptr %21, ptr %22, align 8, !tbaa !23
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %7) #3
  store ptr %0, ptr %7, align 16, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %7, i64 8
  store ptr %9, ptr %23, align 8, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %7, i64 16
  store ptr %19, ptr %24, align 16, !tbaa !5
  %25 = load ptr, ptr @audioSettings, align 8, !tbaa !5
  call void @evaluateSignals(ptr noundef %25, ptr noundef nonnull %7, i64 noundef 3, float noundef %2) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %7) #3
  ret void
}

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

declare ptr @sig_test_BufferRecorder_new(ptr noundef, 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 24}
!10 = !{!"sig_dsp_TimedGate", !11, i64 0, !12, i64 16, !13, i64 32, !15, i64 40, !14, i64 48, !14, i64 52, !14, i64 56, !16, i64 64, !16, i64 72}
!11 = !{!"sig_dsp_Signal", !6, i64 0, !6, i64 8}
!12 = !{!"sig_dsp_TimedGate_Inputs", !6, i64 0, !6, i64 8}
!13 = !{!"sig_dsp_TimedGate_Parameters", !14, i64 0, !14, i64 4}
!14 = !{!"float", !7, i64 0}
!15 = !{!"sig_dsp_Signal_SingleMonoOutput", !6, i64 0}
!16 = !{!"long", !7, i64 0}
!17 = !{!18, !6, i64 16}
!18 = !{!"sig_test_BufferPlayer", !11, i64 0, !15, i64 16, !6, i64 24, !16, i64 32}
!19 = !{!10, !6, i64 16}
!20 = !{!10, !14, i64 32}
!21 = !{!10, !14, i64 36}
!22 = !{!10, !6, i64 40}
!23 = !{!24, !6, i64 16}
!24 = !{!"sig_test_BufferRecorder", !11, i64 0, !25, i64 16, !15, i64 24, !6, i64 32, !16, i64 40}
!25 = !{!"sig_test_BufferRecorder_Inputs", !6, i64 0}


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