; 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_encode.x = external hidden unnamed_addr constant [8 x float], align 16

; Function Attrs: nounwind uwtable
define dso_local void @benchmark_cvsd_encode(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 float, align 4
  %10 = alloca float, align 4
  %11 = alloca i8, align 1
  %12 = alloca ptr, align 8
  %13 = alloca [8 x float], align 16
  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 1, ptr %11) #5
  store i8 0, ptr %11, align 1, !tbaa !13
  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 32, ptr %13) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %13, ptr align 16 @__const.benchmark_cvsd_encode.x, i64 32, 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 !14
  br label %20

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

25:                                               ; preds = %20
  %26 = load ptr, ptr %12, align 8, !tbaa !5
  %27 = getelementptr inbounds [8 x float], ptr %13, i64 0, i64 0
  %28 = load float, ptr %27, align 16, !tbaa !11
  %29 = call zeroext i8 @cvsd_encode(ptr noundef %26, float noundef %28)
  %30 = zext i8 %29 to i32
  %31 = load i8, ptr %11, align 1, !tbaa !13
  %32 = sext i8 %31 to i32
  %33 = xor i32 %32, %30
  %34 = trunc i32 %33 to i8
  store i8 %34, ptr %11, align 1, !tbaa !13
  %35 = load ptr, ptr %12, align 8, !tbaa !5
  %36 = getelementptr inbounds [8 x float], ptr %13, i64 0, i64 2
  %37 = load float, ptr %36, align 8, !tbaa !11
  %38 = call zeroext i8 @cvsd_encode(ptr noundef %35, float noundef %37)
  %39 = zext i8 %38 to i32
  %40 = load i8, ptr %11, align 1, !tbaa !13
  %41 = sext i8 %40 to i32
  %42 = xor i32 %41, %39
  %43 = trunc i32 %42 to i8
  store i8 %43, ptr %11, align 1, !tbaa !13
  %44 = load ptr, ptr %12, align 8, !tbaa !5
  %45 = getelementptr inbounds [8 x float], ptr %13, i64 0, i64 3
  %46 = load float, ptr %45, align 4, !tbaa !11
  %47 = call zeroext i8 @cvsd_encode(ptr noundef %44, float noundef %46)
  %48 = zext i8 %47 to i32
  %49 = load i8, ptr %11, align 1, !tbaa !13
  %50 = sext i8 %49 to i32
  %51 = xor i32 %50, %48
  %52 = trunc i32 %51 to i8
  store i8 %52, ptr %11, align 1, !tbaa !13
  %53 = load ptr, ptr %12, align 8, !tbaa !5
  %54 = getelementptr inbounds [8 x float], ptr %13, i64 0, i64 3
  %55 = load float, ptr %54, align 4, !tbaa !11
  %56 = call zeroext i8 @cvsd_encode(ptr noundef %53, float noundef %55)
  %57 = zext i8 %56 to i32
  %58 = load i8, ptr %11, align 1, !tbaa !13
  %59 = sext i8 %58 to i32
  %60 = xor i32 %59, %57
  %61 = trunc i32 %60 to i8
  store i8 %61, ptr %11, align 1, !tbaa !13
  %62 = load ptr, ptr %12, align 8, !tbaa !5
  %63 = getelementptr inbounds [8 x float], ptr %13, i64 0, i64 4
  %64 = load float, ptr %63, align 16, !tbaa !11
  %65 = call zeroext i8 @cvsd_encode(ptr noundef %62, float noundef %64)
  %66 = zext i8 %65 to i32
  %67 = load i8, ptr %11, align 1, !tbaa !13
  %68 = sext i8 %67 to i32
  %69 = xor i32 %68, %66
  %70 = trunc i32 %69 to i8
  store i8 %70, ptr %11, align 1, !tbaa !13
  %71 = load ptr, ptr %12, align 8, !tbaa !5
  %72 = getelementptr inbounds [8 x float], ptr %13, i64 0, i64 5
  %73 = load float, ptr %72, align 4, !tbaa !11
  %74 = call zeroext i8 @cvsd_encode(ptr noundef %71, float noundef %73)
  %75 = zext i8 %74 to i32
  %76 = load i8, ptr %11, align 1, !tbaa !13
  %77 = sext i8 %76 to i32
  %78 = xor i32 %77, %75
  %79 = trunc i32 %78 to i8
  store i8 %79, ptr %11, align 1, !tbaa !13
  %80 = load ptr, ptr %12, align 8, !tbaa !5
  %81 = getelementptr inbounds [8 x float], ptr %13, i64 0, i64 6
  %82 = load float, ptr %81, align 8, !tbaa !11
  %83 = call zeroext i8 @cvsd_encode(ptr noundef %80, float noundef %82)
  %84 = zext i8 %83 to i32
  %85 = load i8, ptr %11, align 1, !tbaa !13
  %86 = sext i8 %85 to i32
  %87 = xor i32 %86, %84
  %88 = trunc i32 %87 to i8
  store i8 %88, ptr %11, align 1, !tbaa !13
  %89 = load ptr, ptr %12, align 8, !tbaa !5
  %90 = getelementptr inbounds [8 x float], ptr %13, i64 0, i64 7
  %91 = load float, ptr %90, align 4, !tbaa !11
  %92 = call zeroext i8 @cvsd_encode(ptr noundef %89, float noundef %91)
  %93 = zext i8 %92 to i32
  %94 = load i8, ptr %11, align 1, !tbaa !13
  %95 = sext i8 %94 to i32
  %96 = xor i32 %95, %93
  %97 = trunc i32 %96 to i8
  store i8 %97, ptr %11, align 1, !tbaa !13
  %98 = load i8, ptr %11, align 1, !tbaa !13
  %99 = sext i8 %98 to i32
  %100 = icmp ne i32 %99, 0
  %101 = zext i1 %100 to i64
  %102 = select i1 %100, float 0x3FB99999A0000000, float 0xBFB99999A0000000
  %103 = load i64, ptr %7, align 8, !tbaa !14
  %104 = urem i64 %103, 8
  %105 = getelementptr inbounds [8 x float], ptr %13, i64 0, i64 %104
  %106 = load float, ptr %105, align 4, !tbaa !11
  %107 = fadd float %106, %102
  store float %107, ptr %105, align 4, !tbaa !11
  br label %108

108:                                              ; preds = %25
  %109 = load i64, ptr %7, align 8, !tbaa !14
  %110 = add i64 %109, 1
  store i64 %110, ptr %7, align 8, !tbaa !14
  br label %20, !llvm.loop !16

111:                                              ; preds = %20
  %112 = load ptr, ptr %5, align 8, !tbaa !5
  %113 = call i32 @getrusage(i32 noundef 0, ptr noundef %112) #5
  %114 = load ptr, ptr %6, align 8, !tbaa !5
  %115 = load i64, ptr %114, align 8, !tbaa !14
  %116 = mul i64 %115, 8
  store i64 %116, ptr %114, align 8, !tbaa !14
  %117 = load ptr, ptr %12, align 8, !tbaa !5
  %118 = call i32 @cvsd_destroy(ptr noundef %117)
  call void @llvm.lifetime.end.p0(i64 32, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 1, 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
}

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

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

; 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) #3

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

declare zeroext i8 @cvsd_encode(ptr noundef, float noundef) #2

declare i32 @cvsd_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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #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 = !{!7, !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"long", !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_encode.x = external hidden unnamed_addr constant [8 x float], align 16

; Function Attrs: nounwind uwtable
define dso_local void @benchmark_cvsd_encode(ptr noundef %0, ptr noundef %1, ptr nocapture noundef %2) local_unnamed_addr #0 {
  %4 = alloca [8 x float], align 16
  %5 = tail call ptr @cvsd_create(i32 noundef 4, float noundef 1.500000e+00, float noundef 0x3FEE666660000000) #5
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %4) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(32) %4, ptr noundef nonnull align 16 dereferenceable(32) @__const.benchmark_cvsd_encode.x, i64 32, i1 false)
  %6 = tail call i32 @getrusage(i32 noundef 0, ptr noundef %0) #5
  %7 = load i64, ptr %2, align 8, !tbaa !5
  %.not30 = icmp eq i64 %7, 0
  br i1 %.not30, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %8 = getelementptr inbounds i8, ptr %4, i64 8
  %9 = getelementptr inbounds i8, ptr %4, i64 12
  %10 = getelementptr inbounds i8, ptr %4, i64 16
  %11 = getelementptr inbounds i8, ptr %4, i64 20
  %12 = getelementptr inbounds i8, ptr %4, i64 24
  %13 = getelementptr inbounds i8, ptr %4, i64 28
  br label %14

14:                                               ; preds = %.lr.ph, %14
  %.029 = phi i64 [ 0, %.lr.ph ], [ %43, %14 ]
  %.02728 = phi i8 [ 0, %.lr.ph ], [ %37, %14 ]
  %15 = load float, ptr %4, align 16, !tbaa !9
  %16 = tail call zeroext i8 @cvsd_encode(ptr noundef %5, float noundef %15) #5
  %17 = xor i8 %16, %.02728
  %18 = load float, ptr %8, align 8, !tbaa !9
  %19 = tail call zeroext i8 @cvsd_encode(ptr noundef %5, float noundef %18) #5
  %20 = xor i8 %17, %19
  %21 = load float, ptr %9, align 4, !tbaa !9
  %22 = tail call zeroext i8 @cvsd_encode(ptr noundef %5, float noundef %21) #5
  %23 = xor i8 %20, %22
  %24 = tail call zeroext i8 @cvsd_encode(ptr noundef %5, float noundef %21) #5
  %25 = xor i8 %23, %24
  %26 = load float, ptr %10, align 16, !tbaa !9
  %27 = tail call zeroext i8 @cvsd_encode(ptr noundef %5, float noundef %26) #5
  %28 = xor i8 %25, %27
  %29 = load float, ptr %11, align 4, !tbaa !9
  %30 = tail call zeroext i8 @cvsd_encode(ptr noundef %5, float noundef %29) #5
  %31 = xor i8 %28, %30
  %32 = load float, ptr %12, align 8, !tbaa !9
  %33 = tail call zeroext i8 @cvsd_encode(ptr noundef %5, float noundef %32) #5
  %34 = xor i8 %31, %33
  %35 = load float, ptr %13, align 4, !tbaa !9
  %36 = tail call zeroext i8 @cvsd_encode(ptr noundef %5, float noundef %35) #5
  %37 = xor i8 %36, %34
  %.not = icmp eq i8 %36, %34
  %38 = select i1 %.not, float 0xBFB99999A0000000, float 0x3FB99999A0000000
  %39 = and i64 %.029, 7
  %40 = getelementptr inbounds [8 x float], ptr %4, i64 0, i64 %39
  %41 = load float, ptr %40, align 4, !tbaa !9
  %42 = fadd float %41, %38
  store float %42, ptr %40, align 4, !tbaa !9
  %43 = add nuw i64 %.029, 1
  %44 = load i64, ptr %2, align 8, !tbaa !5
  %45 = icmp ult i64 %43, %44
  br i1 %45, label %14, label %._crit_edge, !llvm.loop !11

._crit_edge:                                      ; preds = %14, %3
  %46 = tail call i32 @getrusage(i32 noundef 0, ptr noundef %1) #5
  %47 = load i64, ptr %2, align 8, !tbaa !5
  %48 = shl i64 %47, 3
  store i64 %48, ptr %2, align 8, !tbaa !5
  %49 = tail call i32 @cvsd_destroy(ptr noundef %5) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %4) #5
  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 @cvsd_create(i32 noundef, float noundef, float noundef) local_unnamed_addr #2

; Function Attrs: mustprogress 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) #3

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

declare zeroext i8 @cvsd_encode(ptr noundef, float noundef) local_unnamed_addr #2

declare i32 @cvsd_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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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