; LLVM IR from jgaeddert/liquid-dsp :: src/audio/src (cvsd)

; 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: 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: nounwind uwtable
declare dso_local zeroext i8 @cvsd_encode(ptr noundef, float noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @cvsd_encode8(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i8, align 1
  %8 = 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 1, ptr %7) #2
  store i8 0, ptr %7, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  store i32 0, ptr %8, align 4, !tbaa !10
  br label %9

9:                                                ; preds = %29, %3
  %10 = load i32, ptr %8, align 4, !tbaa !10
  %11 = icmp ult i32 %10, 8
  br i1 %11, label %12, label %32

12:                                               ; preds = %9
  %13 = load i8, ptr %7, align 1, !tbaa !9
  %14 = zext i8 %13 to i32
  %15 = shl i32 %14, 1
  %16 = trunc i32 %15 to i8
  store i8 %16, ptr %7, align 1, !tbaa !9
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = load i32, ptr %8, align 4, !tbaa !10
  %20 = zext i32 %19 to i64
  %21 = getelementptr inbounds float, ptr %18, i64 %20
  %22 = load float, ptr %21, align 4, !tbaa !12
  %23 = call zeroext i8 @cvsd_encode(ptr noundef %17, float noundef %22)
  %24 = zext i8 %23 to i32
  %25 = load i8, ptr %7, align 1, !tbaa !9
  %26 = zext i8 %25 to i32
  %27 = or i32 %26, %24
  %28 = trunc i32 %27 to i8
  store i8 %28, ptr %7, align 1, !tbaa !9
  br label %29

29:                                               ; preds = %12
  %30 = load i32, ptr %8, align 4, !tbaa !10
  %31 = add i32 %30, 1
  store i32 %31, ptr %8, align 4, !tbaa !10
  br label %9, !llvm.loop !14

32:                                               ; preds = %9
  %33 = load i8, ptr %7, align 1, !tbaa !9
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  store i8 %33, ptr %34, align 1, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #2
  ret i32 0
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"float", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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
declare dso_local zeroext i8 @cvsd_encode(ptr noundef, float noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @cvsd_encode8(ptr noundef %0, ptr nocapture noundef readonly %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #0 {
  %4 = load float, ptr %1, align 4, !tbaa !5
  %5 = tail call zeroext i8 @cvsd_encode(ptr noundef %0, float noundef %4)
  %6 = getelementptr inbounds i8, ptr %1, i64 4
  %7 = load float, ptr %6, align 4, !tbaa !5
  %8 = tail call zeroext i8 @cvsd_encode(ptr noundef %0, float noundef %7)
  %9 = shl i8 %5, 2
  %10 = shl i8 %8, 1
  %11 = or i8 %9, %10
  %12 = getelementptr inbounds i8, ptr %1, i64 8
  %13 = load float, ptr %12, align 4, !tbaa !5
  %14 = tail call zeroext i8 @cvsd_encode(ptr noundef %0, float noundef %13)
  %15 = or i8 %14, %11
  %16 = getelementptr inbounds i8, ptr %1, i64 12
  %17 = load float, ptr %16, align 4, !tbaa !5
  %18 = tail call zeroext i8 @cvsd_encode(ptr noundef %0, float noundef %17)
  %19 = shl i8 %15, 2
  %20 = shl i8 %18, 1
  %21 = or i8 %19, %20
  %22 = getelementptr inbounds i8, ptr %1, i64 16
  %23 = load float, ptr %22, align 4, !tbaa !5
  %24 = tail call zeroext i8 @cvsd_encode(ptr noundef %0, float noundef %23)
  %25 = or i8 %24, %21
  %26 = getelementptr inbounds i8, ptr %1, i64 20
  %27 = load float, ptr %26, align 4, !tbaa !5
  %28 = tail call zeroext i8 @cvsd_encode(ptr noundef %0, float noundef %27)
  %29 = shl i8 %25, 2
  %30 = shl i8 %28, 1
  %31 = or i8 %29, %30
  %32 = getelementptr inbounds i8, ptr %1, i64 24
  %33 = load float, ptr %32, align 4, !tbaa !5
  %34 = tail call zeroext i8 @cvsd_encode(ptr noundef %0, float noundef %33)
  %35 = or i8 %34, %31
  %36 = shl i8 %35, 1
  %37 = getelementptr inbounds i8, ptr %1, i64 28
  %38 = load float, ptr %37, align 4, !tbaa !5
  %39 = tail call zeroext i8 @cvsd_encode(ptr noundef %0, float noundef %38)
  %40 = or i8 %39, %36
  store i8 %40, ptr %2, align 1, !tbaa !9
  ret i32 0
}

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

!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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}


; Effective O3 passes: GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass