; 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_AudioSettings = type { float, i64, i64 }
%struct.sig_dsp_Signal = type { ptr, ptr }

; 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 @evaluateSignals(ptr noundef %0, ptr noundef %1, i64 noundef %2, float noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca float, align 4
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  %12 = alloca i64, align 8
  %13 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  store float %3, ptr %8, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %14 = load float, ptr %8, align 4, !tbaa !11
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.sig_AudioSettings, ptr %15, i32 0, i32 0
  %17 = load float, ptr %16, align 8, !tbaa !13
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.sig_AudioSettings, ptr %18, i32 0, i32 2
  %20 = load i64, ptr %19, align 8, !tbaa !15
  %21 = uitofp i64 %20 to float
  %22 = fdiv float %17, %21
  %23 = fmul float %14, %22
  %24 = fptoui float %23 to i64
  store i64 %24, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  store i64 0, ptr %10, align 8, !tbaa !9
  br label %25

25:                                               ; preds = %49, %4
  %26 = load i64, ptr %10, align 8, !tbaa !9
  %27 = load i64, ptr %9, align 8, !tbaa !9
  %28 = icmp ult i64 %26, %27
  br i1 %28, label %30, label %29

29:                                               ; preds = %25
  store i32 2, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  br label %52

30:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #2
  store i64 0, ptr %12, align 8, !tbaa !9
  br label %31

31:                                               ; preds = %45, %30
  %32 = load i64, ptr %12, align 8, !tbaa !9
  %33 = load i64, ptr %7, align 8, !tbaa !9
  %34 = icmp ult i64 %32, %33
  br i1 %34, label %36, label %35

35:                                               ; preds = %31
  store i32 5, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  br label %48

36:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #2
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = load i64, ptr %12, align 8, !tbaa !9
  %39 = getelementptr inbounds ptr, ptr %37, i64 %38
  %40 = load ptr, ptr %39, align 8, !tbaa !5
  store ptr %40, ptr %13, align 8, !tbaa !5
  %41 = load ptr, ptr %13, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.sig_dsp_Signal, ptr %41, i32 0, i32 1
  %43 = load ptr, ptr %42, align 8, !tbaa !16
  %44 = load ptr, ptr %13, align 8, !tbaa !5
  call void %43(ptr noundef %44)
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #2
  br label %45

45:                                               ; preds = %36
  %46 = load i64, ptr %12, align 8, !tbaa !9
  %47 = add i64 %46, 1
  store i64 %47, ptr %12, align 8, !tbaa !9
  br label %31, !llvm.loop !18

48:                                               ; preds = %35
  br label %49

49:                                               ; preds = %48
  %50 = load i64, ptr %10, align 8, !tbaa !9
  %51 = add i64 %50, 1
  store i64 %51, ptr %10, align 8, !tbaa !9
  br label %25, !llvm.loop !20

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

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 = { 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, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"sig_AudioSettings", !12, i64 0, !10, i64 8, !10, i64 16}
!15 = !{!14, !10, i64 16}
!16 = !{!17, !6, i64 8}
!17 = !{!"sig_dsp_Signal", !6, i64 0, !6, i64 8}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}


; 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: nounwind uwtable
define dso_local void @evaluateSignals(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, i64 noundef %2, float noundef %3) local_unnamed_addr #0 {
  %5 = load float, ptr %0, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = load i64, ptr %6, align 8, !tbaa !11
  %8 = uitofp i64 %7 to float
  %9 = fdiv float %5, %8
  %10 = fmul float %9, %3
  %11 = fptoui float %10 to i64
  %.not = icmp eq i64 %11, 0
  %.not16 = icmp eq i64 %2, 0
  %or.cond = or i1 %.not, %.not16
  br i1 %or.cond, label %._crit_edge15, label %.preheader.us

.preheader.us:                                    ; preds = %4, %._crit_edge.us
  %.014.us = phi i64 [ %18, %._crit_edge.us ], [ 0, %4 ]
  br label %12

12:                                               ; preds = %.preheader.us, %12
  %.01213.us = phi i64 [ 0, %.preheader.us ], [ %17, %12 ]
  %13 = getelementptr inbounds ptr, ptr %1, i64 %.01213.us
  %14 = load ptr, ptr %13, align 8, !tbaa !12
  %15 = getelementptr inbounds i8, ptr %14, i64 8
  %16 = load ptr, ptr %15, align 8, !tbaa !14
  tail call void %16(ptr noundef %14) #1
  %17 = add nuw i64 %.01213.us, 1
  %exitcond.not = icmp eq i64 %17, %2
  br i1 %exitcond.not, label %._crit_edge.us, label %12, !llvm.loop !16

._crit_edge.us:                                   ; preds = %12
  %18 = add nuw i64 %.014.us, 1
  %exitcond18.not = icmp eq i64 %18, %11
  br i1 %exitcond18.not, label %._crit_edge15, label %.preheader.us, !llvm.loop !18

._crit_edge15:                                    ; preds = %._crit_edge.us, %4
  ret void
}

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 = { 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, !7, i64 0}
!6 = !{!"sig_AudioSettings", !7, i64 0, !10, i64 8, !10, i64 16}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !10, i64 16}
!12 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!15, !13, i64 8}
!15 = !{!"sig_dsp_Signal", !13, i64 0, !13, i64 8}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


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