; LLVM IR from lichen-community-systems/signaletic :: libsignaletic/tests/util (buffer-test-utils)

; 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_test_BufferRecorder = type { %struct.sig_dsp_Signal, %struct.sig_test_BufferRecorder_Inputs, %struct.sig_dsp_Signal_SingleMonoOutput, ptr, i64 }
%struct.sig_dsp_Signal = type { ptr, ptr }
%struct.sig_test_BufferRecorder_Inputs = type { ptr }
%struct.sig_dsp_Signal_SingleMonoOutput = type { ptr }
%struct.sig_AudioSettings = type { float, i64, i64 }
%struct.sig_Buffer = type { i64, ptr }

@.str.5 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [114 x i8], align 1
@__PRETTY_FUNCTION__.sig_test_BufferRecorder_generate = external hidden unnamed_addr constant [46 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

; Function Attrs: nounwind uwtable
define dso_local void @sig_test_BufferRecorder_generate(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %5, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  store i64 0, ptr %4, align 8, !tbaa !9
  br label %6

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

15:                                               ; preds = %6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  br label %52

16:                                               ; preds = %6
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.sig_test_BufferRecorder, ptr %17, i32 0, i32 4
  %19 = load i64, ptr %18, align 8, !tbaa !19
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.sig_test_BufferRecorder, ptr %20, i32 0, i32 3
  %22 = load ptr, ptr %21, align 8, !tbaa !20
  %23 = getelementptr inbounds %struct.sig_Buffer, ptr %22, i32 0, i32 0
  %24 = load i64, ptr %23, align 8, !tbaa !21
  %25 = icmp ult i64 %19, %24
  br i1 %25, label %26, label %27

26:                                               ; preds = %16
  br label %28

27:                                               ; preds = %16
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.6, i32 noundef 183, ptr noundef @__PRETTY_FUNCTION__.sig_test_BufferRecorder_generate) #4
  unreachable

28:                                               ; preds = %26
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.sig_test_BufferRecorder, ptr %29, i32 0, i32 1
  %31 = getelementptr inbounds %struct.sig_test_BufferRecorder_Inputs, ptr %30, i32 0, i32 0
  %32 = load ptr, ptr %31, align 8, !tbaa !23
  %33 = load i64, ptr %4, align 8, !tbaa !9
  %34 = getelementptr inbounds float, ptr %32, i64 %33
  %35 = load float, ptr %34, align 4, !tbaa !24
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.sig_test_BufferRecorder, ptr %36, i32 0, i32 3
  %38 = load ptr, ptr %37, align 8, !tbaa !20
  %39 = getelementptr inbounds %struct.sig_Buffer, ptr %38, i32 0, i32 1
  %40 = load ptr, ptr %39, align 8, !tbaa !25
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.sig_test_BufferRecorder, ptr %41, i32 0, i32 4
  %43 = load i64, ptr %42, align 8, !tbaa !19
  %44 = getelementptr inbounds float, ptr %40, i64 %43
  store float %35, ptr %44, align 4, !tbaa !24
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.sig_test_BufferRecorder, ptr %45, i32 0, i32 4
  %47 = load i64, ptr %46, align 8, !tbaa !19
  %48 = add i64 %47, 1
  store i64 %48, ptr %46, align 8, !tbaa !19
  br label %49

49:                                               ; preds = %28
  %50 = load i64, ptr %4, align 8, !tbaa !9
  %51 = add i64 %50, 1
  store i64 %51, ptr %4, align 8, !tbaa !9
  br label %6, !llvm.loop !26

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { noreturn 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 #3 = { nounwind }
attributes #4 = { noreturn 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_test_BufferRecorder", !13, i64 0, !14, i64 16, !15, i64 24, !6, i64 32, !10, i64 40}
!13 = !{!"sig_dsp_Signal", !6, i64 0, !6, i64 8}
!14 = !{!"sig_test_BufferRecorder_Inputs", !6, i64 0}
!15 = !{!"sig_dsp_Signal_SingleMonoOutput", !6, i64 0}
!16 = !{!17, !10, i64 16}
!17 = !{!"sig_AudioSettings", !18, i64 0, !10, i64 8, !10, i64 16}
!18 = !{!"float", !7, i64 0}
!19 = !{!12, !10, i64 40}
!20 = !{!12, !6, i64 32}
!21 = !{!22, !10, i64 0}
!22 = !{!"sig_Buffer", !10, i64 0, !6, i64 8}
!23 = !{!12, !6, i64 16}
!24 = !{!18, !18, i64 0}
!25 = !{!22, !6, i64 8}
!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"

@.str.5 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [114 x i8], align 1
@__PRETTY_FUNCTION__.sig_test_BufferRecorder_generate = external hidden unnamed_addr constant [46 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @sig_test_BufferRecorder_generate(ptr nocapture noundef %0) local_unnamed_addr #0 {
  %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 40
  %6 = getelementptr inbounds i8, ptr %0, i64 32
  %7 = load ptr, ptr %6, align 8, !tbaa !17
  %8 = load i64, ptr %7, align 8, !tbaa !18
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  %10 = getelementptr inbounds i8, ptr %7, i64 8
  %.promoted = load i64, ptr %5, align 8, !tbaa !20
  br label %11

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

11:                                               ; preds = %.lr.ph, %15
  %12 = phi i64 [ %.promoted, %.lr.ph ], [ %21, %15 ]
  %.011 = phi i64 [ 0, %.lr.ph ], [ %22, %15 ]
  %13 = icmp ult i64 %12, %8
  br i1 %13, label %15, label %14

14:                                               ; preds = %11
  tail call void @__assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.6, i32 noundef 183, ptr noundef nonnull @__PRETTY_FUNCTION__.sig_test_BufferRecorder_generate) #2
  unreachable

15:                                               ; preds = %11
  %16 = load ptr, ptr %9, align 8, !tbaa !21
  %17 = getelementptr inbounds float, ptr %16, i64 %.011
  %18 = load float, ptr %17, align 4, !tbaa !22
  %19 = load ptr, ptr %10, align 8, !tbaa !23
  %20 = getelementptr inbounds float, ptr %19, i64 %12
  store float %18, ptr %20, align 4, !tbaa !22
  %21 = add nuw i64 %12, 1
  store i64 %21, ptr %5, align 8, !tbaa !20
  %22 = add nuw i64 %.011, 1
  %exitcond.not = icmp eq i64 %22, %4
  br i1 %exitcond.not, label %._crit_edge, label %11, !llvm.loop !24
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { 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 = { noreturn 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 #2 = { noreturn 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_test_BufferRecorder", !7, i64 0, !11, i64 16, !12, i64 24, !8, i64 32, !13, i64 40}
!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_test_BufferRecorder_Inputs", !8, i64 0}
!12 = !{!"sig_dsp_Signal_SingleMonoOutput", !8, i64 0}
!13 = !{!"long", !9, i64 0}
!14 = !{!15, !13, i64 16}
!15 = !{!"sig_AudioSettings", !16, i64 0, !13, i64 8, !13, i64 16}
!16 = !{!"float", !9, i64 0}
!17 = !{!6, !8, i64 32}
!18 = !{!19, !13, i64 0}
!19 = !{!"sig_Buffer", !13, i64 0, !8, i64 8}
!20 = !{!6, !13, i64 40}
!21 = !{!6, !8, i64 16}
!22 = !{!16, !16, i64 0}
!23 = !{!19, !8, i64 8}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}


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