; LLVM IR from jgaeddert/liquid-dsp :: src/nco/bench (nco_benchmark)

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

; Function Attrs: nounwind uwtable
define dso_local void @benchmark_nco_sincos(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %11 = call ptr @nco_crcf_create(i32 noundef 0)
  store ptr %11, ptr %9, align 8, !tbaa !5
  %12 = load ptr, ptr %9, align 8, !tbaa !5
  %13 = call i32 @nco_crcf_set_phase(ptr noundef %12, float noundef 0.000000e+00)
  %14 = load ptr, ptr %9, align 8, !tbaa !5
  %15 = call i32 @nco_crcf_set_frequency(ptr noundef %14, float noundef 0x3FB99999A0000000)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = load i64, ptr %16, align 8, !tbaa !9
  %18 = mul i64 %17, 100
  store i64 %18, ptr %16, align 8, !tbaa !9
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = call i32 @getrusage(i32 noundef 0, ptr noundef %19) #4
  store i32 0, ptr %10, align 4, !tbaa !11
  br label %21

21:                                               ; preds = %32, %3
  %22 = load i32, ptr %10, align 4, !tbaa !11
  %23 = zext i32 %22 to i64
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = load i64, ptr %24, align 8, !tbaa !9
  %26 = icmp ult i64 %23, %25
  br i1 %26, label %27, label %35

27:                                               ; preds = %21
  %28 = load ptr, ptr %9, align 8, !tbaa !5
  %29 = call i32 @nco_crcf_sincos(ptr noundef %28, ptr noundef %7, ptr noundef %8)
  %30 = load ptr, ptr %9, align 8, !tbaa !5
  %31 = call i32 @nco_crcf_step(ptr noundef %30)
  br label %32

32:                                               ; preds = %27
  %33 = load i32, ptr %10, align 4, !tbaa !11
  %34 = add i32 %33, 1
  store i32 %34, ptr %10, align 4, !tbaa !11
  br label %21, !llvm.loop !13

35:                                               ; preds = %21
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = call i32 @getrusage(i32 noundef 0, ptr noundef %36) #4
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = call i32 @nco_crcf_destroy(ptr noundef %38)
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  ret void
}

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

declare ptr @nco_crcf_create(i32 noundef) #2

declare i32 @nco_crcf_set_phase(ptr noundef, float noundef) #2

declare i32 @nco_crcf_set_frequency(ptr noundef, float noundef) #2

; Function Attrs: nounwind
declare i32 @getrusage(i32 noundef, ptr noundef) #3

declare i32 @nco_crcf_sincos(ptr noundef, ptr noundef, ptr noundef) #2

declare i32 @nco_crcf_step(ptr noundef) #2

declare i32 @nco_crcf_destroy(ptr noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 "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 #4 = { 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 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

; Function Attrs: nounwind uwtable
define dso_local void @benchmark_nco_sincos(ptr noundef %0, ptr noundef %1, ptr nocapture noundef %2) local_unnamed_addr #0 {
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #4
  %6 = tail call ptr @nco_crcf_create(i32 noundef 0) #4
  %7 = tail call i32 @nco_crcf_set_phase(ptr noundef %6, float noundef 0.000000e+00) #4
  %8 = tail call i32 @nco_crcf_set_frequency(ptr noundef %6, float noundef 0x3FB99999A0000000) #4
  %9 = load i64, ptr %2, align 8, !tbaa !5
  %10 = mul i64 %9, 100
  store i64 %10, ptr %2, align 8, !tbaa !5
  %11 = tail call i32 @getrusage(i32 noundef 0, ptr noundef %0) #4
  %12 = load i64, ptr %2, align 8, !tbaa !5
  %.not = icmp eq i64 %12, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3, %.lr.ph
  %.010 = phi i32 [ %15, %.lr.ph ], [ 0, %3 ]
  %13 = call i32 @nco_crcf_sincos(ptr noundef %6, ptr noundef nonnull %4, ptr noundef nonnull %5) #4
  %14 = call i32 @nco_crcf_step(ptr noundef %6) #4
  %15 = add i32 %.010, 1
  %16 = zext i32 %15 to i64
  %17 = load i64, ptr %2, align 8, !tbaa !5
  %18 = icmp ugt i64 %17, %16
  br i1 %18, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph, %3
  %19 = call i32 @getrusage(i32 noundef 0, ptr noundef %1) #4
  %20 = call i32 @nco_crcf_destroy(ptr noundef %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #4
  ret void
}

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

declare ptr @nco_crcf_create(i32 noundef) local_unnamed_addr #2

declare i32 @nco_crcf_set_phase(ptr noundef, float noundef) local_unnamed_addr #2

declare i32 @nco_crcf_set_frequency(ptr noundef, float noundef) local_unnamed_addr #2

; Function Attrs: nounwind
declare i32 @getrusage(i32 noundef, ptr noundef) local_unnamed_addr #3

declare i32 @nco_crcf_sincos(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare i32 @nco_crcf_step(ptr noundef) local_unnamed_addr #2

declare i32 @nco_crcf_destroy(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 "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 #4 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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