; 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.2 = external hidden unnamed_addr constant [32 x i8], align 1

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

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

; 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

; Function Attrs: nounwind uwtable
define dso_local i32 @expand_cf_mulaw(<2 x float> noundef %0, float noundef %1, ptr noundef %2) #2 {
  %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 73, ptr noundef @.str.2)
  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) #3
  %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) #3
  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 = fdiv float 1.000000e+00, %35
  %37 = fmul float %32, %36
  %38 = fmul float %34, %36
  %39 = load float, ptr %6, align 4, !tbaa !5
  %40 = fadd float 1.000000e+00, %39
  %41 = getelementptr inbounds { float, float }, ptr %5, i32 0, i32 0
  %42 = load float, ptr %41, align 4
  %43 = getelementptr inbounds { float, float }, ptr %5, i32 0, i32 1
  %44 = load float, ptr %43, align 4
  %45 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 0
  %46 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 1
  store float %42, ptr %45, align 4
  store float %44, ptr %46, align 4
  %47 = load <2 x float>, ptr %11, align 4
  %48 = call float @cabsf(<2 x float> noundef %47) #3
  %49 = call float @powf(float noundef %40, float noundef %48) #3
  %50 = fsub float %49, 1.000000e+00
  %51 = fmul float %37, %50
  %52 = fmul float %38, %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
}

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"="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 #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 = !{!"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.2 = external hidden unnamed_addr constant [32 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 @powf(float noundef, float noundef) local_unnamed_addr #1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @expand_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 73, ptr noundef nonnull @.str.2) #4
  br label %22

7:                                                ; preds = %3
  %8 = tail call float @cargf(<2 x float> noundef %0) #4
  %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) #4
  %11 = fdiv float 1.000000e+00, %1
  %12 = fadd float %1, 1.000000e+00
  %13 = tail call float @cabsf(<2 x float> noundef %0) #4
  %14 = tail call float @powf(float noundef %12, float noundef %13) #4
  %15 = fadd float %14, -1.000000e+00
  %16 = insertelement <2 x float> poison, float %11, i64 0
  %17 = shufflevector <2 x float> %16, <2 x float> poison, <2 x i32> zeroinitializer
  %18 = fmul <2 x float> %17, %10
  %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 = fmul <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
}

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 = { 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 = { 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)"}


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