; LLVM IR from jgaeddert/liquid-dsp :: src/audio/bench (cvsd_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"

@__const.benchmark_cvsd_decode.b = external hidden unnamed_addr constant [8 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

declare ptr @cvsd_create(i32 noundef, float noundef, float noundef) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

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

declare i32 @cvsd_destroy(ptr noundef) #1

; 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 @benchmark_cvsd_decode(ptr noundef %0, ptr noundef %1, ptr noundef %2) #4 {
  %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 float, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = alloca ptr, align 8
  %13 = alloca [8 x i8], align 1
  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) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 4, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store float 1.500000e+00, ptr %9, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store float 0x3FEE666660000000, ptr %10, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  store float 0.000000e+00, ptr %11, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %14 = load i32, ptr %8, align 4, !tbaa !9
  %15 = load float, ptr %9, align 4, !tbaa !11
  %16 = load float, ptr %10, align 4, !tbaa !11
  %17 = call ptr @cvsd_create(i32 noundef %14, float noundef %15, float noundef %16)
  store ptr %17, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %13, ptr align 1 @__const.benchmark_cvsd_decode.b, i64 8, i1 false)
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = call i32 @getrusage(i32 noundef 0, ptr noundef %18) #5
  store i64 0, ptr %7, align 8, !tbaa !13
  br label %20

20:                                               ; preds = %82, %3
  %21 = load i64, ptr %7, align 8, !tbaa !13
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = load i64, ptr %22, align 8, !tbaa !13
  %24 = icmp ult i64 %21, %23
  br i1 %24, label %25, label %85

25:                                               ; preds = %20
  %26 = load ptr, ptr %12, align 8, !tbaa !5
  %27 = getelementptr inbounds [8 x i8], ptr %13, i64 0, i64 0
  %28 = load i8, ptr %27, align 1, !tbaa !15
  %29 = call float @cvsd_decode(ptr noundef %26, i8 noundef zeroext %28)
  %30 = load float, ptr %11, align 4, !tbaa !11
  %31 = fadd float %30, %29
  store float %31, ptr %11, align 4, !tbaa !11
  %32 = load ptr, ptr %12, align 8, !tbaa !5
  %33 = getelementptr inbounds [8 x i8], ptr %13, i64 0, i64 2
  %34 = load i8, ptr %33, align 1, !tbaa !15
  %35 = call float @cvsd_decode(ptr noundef %32, i8 noundef zeroext %34)
  %36 = load float, ptr %11, align 4, !tbaa !11
  %37 = fadd float %36, %35
  store float %37, ptr %11, align 4, !tbaa !11
  %38 = load ptr, ptr %12, align 8, !tbaa !5
  %39 = getelementptr inbounds [8 x i8], ptr %13, i64 0, i64 3
  %40 = load i8, ptr %39, align 1, !tbaa !15
  %41 = call float @cvsd_decode(ptr noundef %38, i8 noundef zeroext %40)
  %42 = load float, ptr %11, align 4, !tbaa !11
  %43 = fadd float %42, %41
  store float %43, ptr %11, align 4, !tbaa !11
  %44 = load ptr, ptr %12, align 8, !tbaa !5
  %45 = getelementptr inbounds [8 x i8], ptr %13, i64 0, i64 3
  %46 = load i8, ptr %45, align 1, !tbaa !15
  %47 = call float @cvsd_decode(ptr noundef %44, i8 noundef zeroext %46)
  %48 = load float, ptr %11, align 4, !tbaa !11
  %49 = fadd float %48, %47
  store float %49, ptr %11, align 4, !tbaa !11
  %50 = load ptr, ptr %12, align 8, !tbaa !5
  %51 = getelementptr inbounds [8 x i8], ptr %13, i64 0, i64 4
  %52 = load i8, ptr %51, align 1, !tbaa !15
  %53 = call float @cvsd_decode(ptr noundef %50, i8 noundef zeroext %52)
  %54 = load float, ptr %11, align 4, !tbaa !11
  %55 = fadd float %54, %53
  store float %55, ptr %11, align 4, !tbaa !11
  %56 = load ptr, ptr %12, align 8, !tbaa !5
  %57 = getelementptr inbounds [8 x i8], ptr %13, i64 0, i64 5
  %58 = load i8, ptr %57, align 1, !tbaa !15
  %59 = call float @cvsd_decode(ptr noundef %56, i8 noundef zeroext %58)
  %60 = load float, ptr %11, align 4, !tbaa !11
  %61 = fadd float %60, %59
  store float %61, ptr %11, align 4, !tbaa !11
  %62 = load ptr, ptr %12, align 8, !tbaa !5
  %63 = getelementptr inbounds [8 x i8], ptr %13, i64 0, i64 6
  %64 = load i8, ptr %63, align 1, !tbaa !15
  %65 = call float @cvsd_decode(ptr noundef %62, i8 noundef zeroext %64)
  %66 = load float, ptr %11, align 4, !tbaa !11
  %67 = fadd float %66, %65
  store float %67, ptr %11, align 4, !tbaa !11
  %68 = load ptr, ptr %12, align 8, !tbaa !5
  %69 = getelementptr inbounds [8 x i8], ptr %13, i64 0, i64 7
  %70 = load i8, ptr %69, align 1, !tbaa !15
  %71 = call float @cvsd_decode(ptr noundef %68, i8 noundef zeroext %70)
  %72 = load float, ptr %11, align 4, !tbaa !11
  %73 = fadd float %72, %71
  store float %73, ptr %11, align 4, !tbaa !11
  %74 = load float, ptr %11, align 4, !tbaa !11
  %75 = fcmp ogt float %74, 0.000000e+00
  %76 = zext i1 %75 to i32
  %77 = getelementptr inbounds [8 x i8], ptr %13, i64 0, i64 0
  %78 = load i8, ptr %77, align 1, !tbaa !15
  %79 = zext i8 %78 to i32
  %80 = xor i32 %79, %76
  %81 = trunc i32 %80 to i8
  store i8 %81, ptr %77, align 1, !tbaa !15
  br label %82

82:                                               ; preds = %25
  %83 = load i64, ptr %7, align 8, !tbaa !13
  %84 = add i64 %83, 1
  store i64 %84, ptr %7, align 8, !tbaa !13
  br label %20, !llvm.loop !16

85:                                               ; preds = %20
  %86 = load ptr, ptr %5, align 8, !tbaa !5
  %87 = call i32 @getrusage(i32 noundef 0, ptr noundef %86) #5
  %88 = load ptr, ptr %6, align 8, !tbaa !5
  %89 = load i64, ptr %88, align 8, !tbaa !13
  %90 = mul i64 %89, 8
  store i64 %90, ptr %88, align 8, !tbaa !13
  %91 = load ptr, ptr %12, align 8, !tbaa !5
  %92 = call i32 @cvsd_destroy(ptr noundef %91)
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  ret void
}

declare float @cvsd_decode(ptr noundef, i8 noundef zeroext) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 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 #5 = { 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 = !{!7, !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"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"

@__const.benchmark_cvsd_decode.b = external hidden unnamed_addr constant [8 x i8], align 1

declare ptr @cvsd_create(i32 noundef, float noundef, float noundef) local_unnamed_addr #0

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

declare i32 @cvsd_destroy(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @benchmark_cvsd_decode(ptr noundef %0, ptr noundef %1, ptr nocapture noundef %2) local_unnamed_addr #2 {
  %4 = tail call ptr @cvsd_create(i32 noundef 4, float noundef 1.500000e+00, float noundef 0x3FEE666660000000) #3
  %.sroa.0.0.copyload = load i8, ptr @__const.benchmark_cvsd_decode.b, align 1
  %.sroa.62.0.copyload = load i8, ptr getelementptr inbounds (i8, ptr @__const.benchmark_cvsd_decode.b, i64 2), align 1
  %.sroa.7.0.copyload = load i8, ptr getelementptr inbounds (i8, ptr @__const.benchmark_cvsd_decode.b, i64 3), align 1
  %.sroa.9.0.copyload = load i8, ptr getelementptr inbounds (i8, ptr @__const.benchmark_cvsd_decode.b, i64 4), align 1
  %.sroa.10.0.copyload = load i8, ptr getelementptr inbounds (i8, ptr @__const.benchmark_cvsd_decode.b, i64 5), align 1
  %.sroa.11.0.copyload = load i8, ptr getelementptr inbounds (i8, ptr @__const.benchmark_cvsd_decode.b, i64 6), align 1
  %.sroa.12.0.copyload = load i8, ptr getelementptr inbounds (i8, ptr @__const.benchmark_cvsd_decode.b, i64 7), align 1
  %5 = tail call i32 @getrusage(i32 noundef 0, ptr noundef %0) #3
  %6 = load i64, ptr %2, align 8, !tbaa !5
  %.not = icmp eq i64 %6, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3, %.lr.ph
  %.sroa.0.032 = phi i8 [ %25, %.lr.ph ], [ %.sroa.0.0.copyload, %3 ]
  %.031 = phi i64 [ %26, %.lr.ph ], [ 0, %3 ]
  %.02930 = phi float [ %22, %.lr.ph ], [ 0.000000e+00, %3 ]
  %7 = tail call float @cvsd_decode(ptr noundef %4, i8 noundef zeroext %.sroa.0.032) #3
  %8 = fadd float %.02930, %7
  %9 = tail call float @cvsd_decode(ptr noundef %4, i8 noundef zeroext %.sroa.62.0.copyload) #3
  %10 = fadd float %8, %9
  %11 = tail call float @cvsd_decode(ptr noundef %4, i8 noundef zeroext %.sroa.7.0.copyload) #3
  %12 = fadd float %10, %11
  %13 = tail call float @cvsd_decode(ptr noundef %4, i8 noundef zeroext %.sroa.7.0.copyload) #3
  %14 = fadd float %12, %13
  %15 = tail call float @cvsd_decode(ptr noundef %4, i8 noundef zeroext %.sroa.9.0.copyload) #3
  %16 = fadd float %14, %15
  %17 = tail call float @cvsd_decode(ptr noundef %4, i8 noundef zeroext %.sroa.10.0.copyload) #3
  %18 = fadd float %16, %17
  %19 = tail call float @cvsd_decode(ptr noundef %4, i8 noundef zeroext %.sroa.11.0.copyload) #3
  %20 = fadd float %18, %19
  %21 = tail call float @cvsd_decode(ptr noundef %4, i8 noundef zeroext %.sroa.12.0.copyload) #3
  %22 = fadd float %20, %21
  %23 = fcmp ogt float %22, 0.000000e+00
  %24 = zext i1 %23 to i8
  %25 = xor i8 %.sroa.0.032, %24
  %26 = add nuw i64 %.031, 1
  %27 = load i64, ptr %2, align 8, !tbaa !5
  %28 = icmp ult i64 %26, %27
  br i1 %28, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph, %3
  %29 = tail call i32 @getrusage(i32 noundef 0, ptr noundef %1) #3
  %30 = load i64, ptr %2, align 8, !tbaa !5
  %31 = shl i64 %30, 3
  store i64 %31, ptr %2, align 8, !tbaa !5
  %32 = tail call i32 @cvsd_destroy(ptr noundef %4) #3
  ret void
}

declare float @cvsd_decode(ptr noundef, i8 noundef zeroext) local_unnamed_addr #0

attributes #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 = { 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 = { 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,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass