; LLVM IR from jgaeddert/liquid-dsp :: src/quantization/src (compand)

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

@.str = external hidden unnamed_addr constant [85 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [34 x i8], align 1

declare i32 @liquid_error_fl(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) #0

; Function Attrs: nounwind
declare float @logf(float noundef) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @compress_cf_mulaw(<2 x float> noundef %0, float noundef %1, ptr noundef %2) #3 {
  %4 = alloca i32, align 4
  %5 = alloca { float, float }, align 4
  %6 = alloca float, align 4
  %7 = alloca ptr, align 8
  %8 = alloca { float, float }, align 4
  %9 = alloca { float, float }, align 4
  %10 = alloca { float, float }, align 4
  %11 = alloca { float, float }, align 4
  store <2 x float> %0, ptr %5, align 4
  store float %1, ptr %6, align 4, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !9
  %12 = load float, ptr %6, align 4, !tbaa !5
  %13 = fcmp ole float %12, 0.000000e+00
  br i1 %13, label %14, label %16

14:                                               ; preds = %3
  %15 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 5, ptr noundef @.str, i32 noundef 63, ptr noundef @.str.1)
  store i32 %15, ptr %4, align 4
  br label %56

16:                                               ; preds = %3
  %17 = getelementptr inbounds { float, float }, ptr %5, i32 0, i32 0
  %18 = load float, ptr %17, align 4
  %19 = getelementptr inbounds { float, float }, ptr %5, i32 0, i32 1
  %20 = load float, ptr %19, align 4
  %21 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 0
  %22 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 1
  store float %18, ptr %21, align 4
  store float %20, ptr %22, align 4
  %23 = load <2 x float>, ptr %8, align 4
  %24 = call float @cargf(<2 x float> noundef %23) #4
  %25 = fmul float 0.000000e+00, %24
  %26 = fmul float 1.000000e+00, %24
  %27 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %28 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  store float %25, ptr %27, align 4
  store float %26, ptr %28, align 4
  %29 = load <2 x float>, ptr %9, align 4
  %30 = call <2 x float> @cexpf(<2 x float> noundef %29) #4
  store <2 x float> %30, ptr %10, align 4
  %31 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 0
  %32 = load float, ptr %31, align 4
  %33 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 1
  %34 = load float, ptr %33, align 4
  %35 = load float, ptr %6, align 4, !tbaa !5
  %36 = getelementptr inbounds { float, float }, ptr %5, i32 0, i32 0
  %37 = load float, ptr %36, align 4
  %38 = getelementptr inbounds { float, float }, ptr %5, i32 0, i32 1
  %39 = load float, ptr %38, align 4
  %40 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 0
  %41 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 1
  store float %37, ptr %40, align 4
  store float %39, ptr %41, align 4
  %42 = load <2 x float>, ptr %11, align 4
  %43 = call float @cabsf(<2 x float> noundef %42) #4
  %44 = call float @llvm.fmuladd.f32(float %35, float %43, float 1.000000e+00)
  %45 = call float @logf(float noundef %44) #4
  %46 = fmul float %32, %45
  %47 = fmul float %34, %45
  %48 = load float, ptr %6, align 4, !tbaa !5
  %49 = fadd float 1.000000e+00, %48
  %50 = call float @logf(float noundef %49) #4
  %51 = fdiv float %46, %50
  %52 = fdiv float %47, %50
  %53 = load ptr, ptr %7, align 8, !tbaa !9
  %54 = getelementptr inbounds { float, float }, ptr %53, i32 0, i32 0
  %55 = getelementptr inbounds { float, float }, ptr %53, i32 0, i32 1
  store float %51, ptr %54, align 4
  store float %52, ptr %55, align 4
  store i32 0, ptr %4, align 4
  br label %56

56:                                               ; preds = %16, %14
  %57 = load i32, ptr %4, align 4
  ret i32 %57
}

; Function Attrs: nounwind
declare <2 x float> @cexpf(<2 x float> noundef) #1

; Function Attrs: nounwind
declare float @cargf(<2 x float> noundef) #1

; Function Attrs: nounwind
declare float @cabsf(<2 x float> noundef) #1

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nounwind uwtable "min-legal-vector-width"="64" "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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}


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

@.str = external hidden unnamed_addr constant [85 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [34 x i8], align 1

declare i32 @liquid_error_fl(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @logf(float noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @compress_cf_mulaw(<2 x float> noundef %0, float noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #3 {
  %4 = fcmp ugt float %1, 0.000000e+00
  br i1 %4, label %7, label %5

5:                                                ; preds = %3
  %6 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 5, ptr noundef nonnull @.str, i32 noundef 63, ptr noundef nonnull @.str.1) #5
  br label %22

7:                                                ; preds = %3
  %8 = tail call float @cargf(<2 x float> noundef %0) #5
  %9 = fmul float %8, 0.000000e+00
  %.sroa.03.0.vec.insert = insertelement <2 x float> poison, float %9, i64 0
  %.sroa.03.4.vec.insert = insertelement <2 x float> %.sroa.03.0.vec.insert, float %8, i64 1
  %10 = tail call <2 x float> @cexpf(<2 x float> noundef %.sroa.03.4.vec.insert) #5
  %11 = tail call float @cabsf(<2 x float> noundef %0) #5
  %12 = tail call float @llvm.fmuladd.f32(float %1, float %11, float 1.000000e+00)
  %13 = tail call float @logf(float noundef %12) #5
  %14 = fadd float %1, 1.000000e+00
  %15 = tail call float @logf(float noundef %14) #5
  %16 = insertelement <2 x float> poison, float %13, i64 0
  %17 = shufflevector <2 x float> %16, <2 x float> poison, <2 x i32> zeroinitializer
  %18 = fmul <2 x float> %10, %17
  %19 = insertelement <2 x float> poison, float %15, i64 0
  %20 = shufflevector <2 x float> %19, <2 x float> poison, <2 x i32> zeroinitializer
  %21 = fdiv <2 x float> %18, %20
  store <2 x float> %21, ptr %2, align 4
  br label %22

22:                                               ; preds = %7, %5
  %.0 = phi i32 [ %6, %5 ], [ 0, %7 ]
  ret i32 %.0
}

; Function Attrs: nounwind
declare <2 x float> @cexpf(<2 x float> noundef) local_unnamed_addr #4

; Function Attrs: nounwind
declare float @cargf(<2 x float> noundef) local_unnamed_addr #4

; Function Attrs: nounwind
declare float @cabsf(<2 x float> noundef) local_unnamed_addr #4

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 = { mustprogress nofree nounwind willreturn memory(write) "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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nounwind uwtable "min-legal-vector-width"="64" "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 "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)"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,TailCallElimPass