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

@.str.4 = external hidden unnamed_addr constant [81 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: noreturn
declare void @UnityFail(ptr noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local signext i16 @countNonZeroSamplesGenerated(ptr noundef, ptr noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @testAssertGeneratedSignalContainsApproxNumNonZeroSamples(ptr noundef %0, ptr noundef %1, i16 noundef signext %2, double noundef %3, i32 noundef %4) #2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i16, align 2
  %9 = alloca double, align 8
  %10 = alloca i32, align 4
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i16 %2, ptr %8, align 2, !tbaa !9
  store double %3, ptr %9, align 8, !tbaa !11
  store i32 %4, ptr %10, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %17 = load i16, ptr %8, align 2, !tbaa !9
  %18 = sitofp i16 %17 to double
  store double %18, ptr %11, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %19 = load double, ptr %11, align 8, !tbaa !11
  %20 = load double, ptr %9, align 8, !tbaa !11
  %21 = fmul double %19, %20
  store double %21, ptr %12, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %22 = load double, ptr %11, align 8, !tbaa !11
  %23 = load double, ptr %12, align 8, !tbaa !11
  %24 = fadd double %22, %23
  store double %24, ptr %13, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %25 = load double, ptr %11, align 8, !tbaa !11
  %26 = load double, ptr %12, align 8, !tbaa !11
  %27 = fsub double %25, %26
  store double %27, ptr %14, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = load i32, ptr %10, align 4, !tbaa !13
  %31 = call signext i16 @countNonZeroSamplesGenerated(ptr noundef %28, ptr noundef %29, i32 noundef %30)
  %32 = sitofp i16 %31 to double
  %33 = load i32, ptr %10, align 4, !tbaa !13
  %34 = sitofp i32 %33 to double
  %35 = fdiv double %32, %34
  store double %35, ptr %15, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %36 = load double, ptr %15, align 8, !tbaa !11
  %37 = call double @llvm.round.f64(double %36)
  store double %37, ptr %16, align 8, !tbaa !11
  br label %38

38:                                               ; preds = %5
  %39 = load double, ptr %16, align 8, !tbaa !11
  %40 = load double, ptr %14, align 8, !tbaa !11
  %41 = fcmp oge double %39, %40
  br i1 %41, label %42, label %47

42:                                               ; preds = %38
  %43 = load double, ptr %16, align 8, !tbaa !11
  %44 = load double, ptr %13, align 8, !tbaa !11
  %45 = fcmp ole double %43, %44
  br i1 %45, label %46, label %47

46:                                               ; preds = %42
  br label %48

47:                                               ; preds = %42, %38
  call void @UnityFail(ptr noundef @.str.4, i64 noundef 117) #5
  unreachable

48:                                               ; preds = %46
  br label %49

49:                                               ; preds = %48
  br label %50

50:                                               ; preds = %49
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.round.f64(double) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nounwind }
attributes #5 = { noreturn }

!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 = !{!"short", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, 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"

@.str.4 = external hidden unnamed_addr constant [81 x i8], align 1

; Function Attrs: noreturn
declare void @UnityFail(ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local signext i16 @countNonZeroSamplesGenerated(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @testAssertGeneratedSignalContainsApproxNumNonZeroSamples(ptr noundef %0, ptr noundef %1, i16 noundef signext %2, double noundef %3, i32 noundef %4) local_unnamed_addr #1 {
  %6 = sitofp i16 %2 to double
  %7 = fmul double %6, %3
  %8 = fsub double %6, %7
  %9 = tail call signext i16 @countNonZeroSamplesGenerated(ptr noundef %0, ptr noundef %1, i32 noundef %4)
  %10 = sitofp i16 %9 to double
  %11 = sitofp i32 %4 to double
  %12 = fdiv double %10, %11
  %13 = tail call double @llvm.round.f64(double %12)
  %14 = fcmp ult double %13, %8
  %15 = fadd double %7, %6
  %16 = fcmp ugt double %13, %15
  %or.cond = or i1 %14, %16
  br i1 %or.cond, label %17, label %18

17:                                               ; preds = %5
  tail call void @UnityFail(ptr noundef nonnull @.str.4, i64 noundef 117) #3
  unreachable

18:                                               ; preds = %5
  ret void
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.round.f64(double) #2

attributes #0 = { noreturn "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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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)"}


; Effective O3 passes: GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass