; LLVM IR from jgaeddert/liquid-dsp :: src/quantization/bench (quantizer_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_quantize_adc(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 i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca float, 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 8, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 8, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store float 0xBFB99999A0000000, ptr %10, align 4, !tbaa !11
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = call i32 @getrusage(i32 noundef 0, ptr noundef %11) #4
  store i64 0, ptr %7, align 8, !tbaa !13
  br label %13

13:                                               ; preds = %39, %3
  %14 = load i64, ptr %7, align 8, !tbaa !13
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = load i64, ptr %15, align 8, !tbaa !13
  %17 = icmp ult i64 %14, %16
  br i1 %17, label %18, label %42

18:                                               ; preds = %13
  %19 = load float, ptr %10, align 4, !tbaa !11
  %20 = load i32, ptr %9, align 4, !tbaa !9
  %21 = call i32 @quantize_adc(float noundef %19, i32 noundef %20)
  %22 = load i32, ptr %8, align 4, !tbaa !9
  %23 = xor i32 %22, %21
  store i32 %23, ptr %8, align 4, !tbaa !9
  %24 = load float, ptr %10, align 4, !tbaa !11
  %25 = load i32, ptr %9, align 4, !tbaa !9
  %26 = call i32 @quantize_adc(float noundef %24, i32 noundef %25)
  %27 = load i32, ptr %8, align 4, !tbaa !9
  %28 = xor i32 %27, %26
  store i32 %28, ptr %8, align 4, !tbaa !9
  %29 = load float, ptr %10, align 4, !tbaa !11
  %30 = load i32, ptr %9, align 4, !tbaa !9
  %31 = call i32 @quantize_adc(float noundef %29, i32 noundef %30)
  %32 = load i32, ptr %8, align 4, !tbaa !9
  %33 = xor i32 %32, %31
  store i32 %33, ptr %8, align 4, !tbaa !9
  %34 = load float, ptr %10, align 4, !tbaa !11
  %35 = load i32, ptr %9, align 4, !tbaa !9
  %36 = call i32 @quantize_adc(float noundef %34, i32 noundef %35)
  %37 = load i32, ptr %8, align 4, !tbaa !9
  %38 = xor i32 %37, %36
  store i32 %38, ptr %8, align 4, !tbaa !9
  br label %39

39:                                               ; preds = %18
  %40 = load i64, ptr %7, align 8, !tbaa !13
  %41 = add i64 %40, 1
  store i64 %41, ptr %7, align 8, !tbaa !13
  br label %13, !llvm.loop !15

42:                                               ; preds = %13
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = call i32 @getrusage(i32 noundef 0, ptr noundef %43) #4
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = load i64, ptr %45, align 8, !tbaa !13
  %47 = mul i64 %46, 4
  store i64 %47, ptr %45, align 8, !tbaa !13
  %48 = load i32, ptr %8, align 4, !tbaa !9
  %49 = and i32 %48, 1
  %50 = zext i32 %49 to i64
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = load i64, ptr %51, align 8, !tbaa !13
  %53 = add i64 %52, %50
  store i64 %53, ptr %51, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, 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

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

declare i32 @quantize_adc(float noundef, i32 noundef) #3

; 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 = { 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 = { "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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"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_quantize_adc(ptr noundef %0, ptr noundef %1, ptr nocapture noundef %2) local_unnamed_addr #0 {
  %4 = tail call i32 @getrusage(i32 noundef 0, ptr noundef %0) #3
  %5 = load i64, ptr %2, align 8, !tbaa !5
  %.not = icmp eq i64 %5, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3, %.lr.ph
  %.021 = phi i64 [ %14, %.lr.ph ], [ 0, %3 ]
  %.01920 = phi i32 [ %13, %.lr.ph ], [ 0, %3 ]
  %6 = tail call i32 @quantize_adc(float noundef 0xBFB99999A0000000, i32 noundef 8) #3
  %7 = tail call i32 @quantize_adc(float noundef 0xBFB99999A0000000, i32 noundef 8) #3
  %8 = tail call i32 @quantize_adc(float noundef 0xBFB99999A0000000, i32 noundef 8) #3
  %9 = tail call i32 @quantize_adc(float noundef 0xBFB99999A0000000, i32 noundef 8) #3
  %10 = xor i32 %6, %.01920
  %11 = xor i32 %10, %7
  %12 = xor i32 %11, %8
  %13 = xor i32 %12, %9
  %14 = add nuw i64 %.021, 1
  %15 = load i64, ptr %2, align 8, !tbaa !5
  %16 = icmp ult i64 %14, %15
  br i1 %16, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !9

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %17 = and i32 %13, 1
  %18 = zext nneg i32 %17 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %3
  %.019.lcssa = phi i64 [ 0, %3 ], [ %18, %._crit_edge.loopexit ]
  %19 = tail call i32 @getrusage(i32 noundef 0, ptr noundef %1) #3
  %20 = load i64, ptr %2, align 8, !tbaa !5
  %21 = shl i64 %20, 2
  %22 = or disjoint i64 %21, %.019.lcssa
  store i64 %22, ptr %2, align 8, !tbaa !5
  ret void
}

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

declare i32 @quantize_adc(float noundef, i32 noundef) local_unnamed_addr #2

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 "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 = { "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 = !{!"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: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass