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

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

@liquid_autotest_verbose = external global i32, align 4
@.str = external hidden unnamed_addr constant [25 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [96 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @autotest_compand_float() #0 {
  %1 = alloca float, align 4
  %2 = alloca float, align 4
  %3 = alloca i32, align 4
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #5
  store float -1.000000e+00, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store float 2.550000e+02, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 30, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  %9 = load i32, ptr %3, align 4, !tbaa !9
  %10 = uitofp i32 %9 to float
  %11 = fdiv float 2.000000e+00, %10
  store float %11, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store float 0x3EB0C6F7A0000000, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %100, %0
  %13 = load i32, ptr %8, align 4, !tbaa !9
  %14 = load i32, ptr %3, align 4, !tbaa !9
  %15 = icmp ult i32 %13, %14
  br i1 %15, label %16, label %103

16:                                               ; preds = %12
  %17 = load float, ptr %1, align 4, !tbaa !5
  %18 = load float, ptr %2, align 4, !tbaa !5
  %19 = call float @compress_mulaw(float noundef %17, float noundef %18)
  store float %19, ptr %5, align 4, !tbaa !5
  %20 = load float, ptr %5, align 4, !tbaa !5
  %21 = load float, ptr %2, align 4, !tbaa !5
  %22 = call float @expand_mulaw(float noundef %20, float noundef %21)
  store float %22, ptr %6, align 4, !tbaa !5
  %23 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !9
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %25, label %33

25:                                               ; preds = %16
  %26 = load float, ptr %1, align 4, !tbaa !5
  %27 = fpext float %26 to double
  %28 = load float, ptr %5, align 4, !tbaa !5
  %29 = fpext float %28 to double
  %30 = load float, ptr %6, align 4, !tbaa !5
  %31 = fpext float %30 to double
  %32 = call i32 (ptr, ...) @printf(ptr noundef @.str, double noundef %27, double noundef %29, double noundef %31)
  br label %33

33:                                               ; preds = %25, %16
  %34 = load float, ptr %1, align 4, !tbaa !5
  %35 = load float, ptr %6, align 4, !tbaa !5
  %36 = fsub float %34, %35
  %37 = fpext float %36 to double
  %38 = load float, ptr %1, align 4, !tbaa !5
  %39 = load float, ptr %6, align 4, !tbaa !5
  %40 = fsub float %38, %39
  %41 = fpext float %40 to double
  %42 = load float, ptr %1, align 4, !tbaa !5
  %43 = load float, ptr %6, align 4, !tbaa !5
  %44 = fsub float %42, %43
  %45 = fpext float %44 to double
  %46 = load float, ptr %1, align 4, !tbaa !5
  %47 = load float, ptr %6, align 4, !tbaa !5
  %48 = fsub float %46, %47
  %49 = fpext float %48 to double
  %50 = call double @llvm.fmuladd.f64(double %37, double %41, double 0.000000e+00)
  %51 = call double @sqrt(double noundef %50) #5
  %52 = load float, ptr %7, align 4, !tbaa !5
  %53 = fpext float %52 to double
  %54 = fcmp ogt double %51, %53
  br i1 %54, label %67, label %55

55:                                               ; preds = %33
  %56 = load float, ptr %1, align 4, !tbaa !5
  %57 = call i1 @llvm.is.fpclass.f32(float %56, i32 3)
  br i1 %57, label %67, label %58

58:                                               ; preds = %55
  %59 = load float, ptr %1, align 4, !tbaa !5
  %60 = call i1 @llvm.is.fpclass.f32(float 0.000000e+00, i32 3)
  br i1 %60, label %67, label %61

61:                                               ; preds = %58
  %62 = load float, ptr %6, align 4, !tbaa !5
  %63 = call i1 @llvm.is.fpclass.f32(float %62, i32 3)
  br i1 %63, label %67, label %64

64:                                               ; preds = %61
  %65 = load float, ptr %6, align 4, !tbaa !5
  %66 = call i1 @llvm.is.fpclass.f32(float 0.000000e+00, i32 3)
  br i1 %66, label %67, label %88

67:                                               ; preds = %64, %61, %58, %55, %33
  %68 = load float, ptr %1, align 4, !tbaa !5
  %69 = load float, ptr %6, align 4, !tbaa !5
  %70 = fsub float %68, %69
  %71 = fpext float %70 to double
  %72 = load float, ptr %1, align 4, !tbaa !5
  %73 = load float, ptr %6, align 4, !tbaa !5
  %74 = fsub float %72, %73
  %75 = fpext float %74 to double
  %76 = load float, ptr %1, align 4, !tbaa !5
  %77 = load float, ptr %6, align 4, !tbaa !5
  %78 = fsub float %76, %77
  %79 = fpext float %78 to double
  %80 = load float, ptr %1, align 4, !tbaa !5
  %81 = load float, ptr %6, align 4, !tbaa !5
  %82 = fsub float %80, %81
  %83 = fpext float %82 to double
  %84 = call double @llvm.fmuladd.f64(double %71, double %75, double 0.000000e+00)
  %85 = call double @sqrt(double noundef %84) #5
  %86 = load float, ptr %7, align 4, !tbaa !5
  %87 = fpext float %86 to double
  call void @liquid_autotest_failed_expr(ptr noundef @.str.1, i32 noundef 44, ptr noundef @.str.2, double noundef %85, ptr noundef @.str.3, ptr noundef @.str.4, double noundef %87)
  br label %89

88:                                               ; preds = %64
  call void (...) @liquid_autotest_passed()
  br label %89

89:                                               ; preds = %88, %67
  %90 = load float, ptr %4, align 4, !tbaa !5
  %91 = load float, ptr %1, align 4, !tbaa !5
  %92 = fadd float %91, %90
  store float %92, ptr %1, align 4, !tbaa !5
  %93 = load float, ptr %1, align 4, !tbaa !5
  %94 = fcmp ogt float %93, 1.000000e+00
  br i1 %94, label %95, label %96

95:                                               ; preds = %89
  br label %98

96:                                               ; preds = %89
  %97 = load float, ptr %1, align 4, !tbaa !5
  br label %98

98:                                               ; preds = %96, %95
  %99 = phi float [ 1.000000e+00, %95 ], [ %97, %96 ]
  store float %99, ptr %1, align 4, !tbaa !5
  br label %100

100:                                              ; preds = %98
  %101 = load i32, ptr %8, align 4, !tbaa !9
  %102 = add i32 %101, 1
  store i32 %102, ptr %8, align 4, !tbaa !9
  br label %12, !llvm.loop !11

103:                                              ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #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 float @compress_mulaw(float noundef, float noundef) #2

declare float @expand_mulaw(float noundef, float noundef) #2

declare i32 @printf(ptr noundef, ...) #2

; Function Attrs: nounwind
declare double @sqrt(double noundef) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #4

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i1 @llvm.is.fpclass.f32(float, i32 immarg) #4

declare void @liquid_autotest_failed_expr(ptr noundef, i32 noundef, ptr noundef, double noundef, ptr noundef, ptr noundef, double noundef) #2

declare void @liquid_autotest_passed(...) #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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"float", !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 = distinct !{!11, !12}
!12 = !{!"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"

@liquid_autotest_verbose = external local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [25 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [96 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @autotest_compand_float() local_unnamed_addr #0 {
  br label %1

1:                                                ; preds = %0, %19
  %.040 = phi i32 [ 0, %0 ], [ %23, %19 ]
  %.03639 = phi float [ -1.000000e+00, %0 ], [ %22, %19 ]
  %2 = tail call float @compress_mulaw(float noundef %.03639, float noundef 2.550000e+02) #5
  %3 = tail call float @expand_mulaw(float noundef %2, float noundef 2.550000e+02) #5
  %4 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !5
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %10, label %5

5:                                                ; preds = %1
  %6 = fpext float %.03639 to double
  %7 = fpext float %2 to double
  %8 = fpext float %3 to double
  %9 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %6, double noundef %7, double noundef %8)
  br label %10

10:                                               ; preds = %5, %1
  %11 = fsub float %.03639, %3
  %12 = fpext float %11 to double
  %13 = tail call double @llvm.fmuladd.f64(double %12, double %12, double 0.000000e+00)
  %sqrt = tail call double @llvm.sqrt.f64(double %13)
  %14 = fcmp ogt double %sqrt, 0x3EB0C6F7A0000000
  %15 = fcmp uno float %.03639, 0.000000e+00
  %or.cond = or i1 %14, %15
  %16 = fcmp uno float %3, 0.000000e+00
  %or.cond37 = select i1 %or.cond, i1 true, i1 %16
  br i1 %or.cond37, label %17, label %18

17:                                               ; preds = %10
  tail call void @liquid_autotest_failed_expr(ptr noundef nonnull @.str.1, i32 noundef 44, ptr noundef nonnull @.str.2, double noundef %sqrt, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.4, double noundef 0x3EB0C6F7A0000000) #5
  br label %19

18:                                               ; preds = %10
  tail call void (...) @liquid_autotest_passed() #5
  br label %19

19:                                               ; preds = %18, %17
  %20 = fadd float %.03639, 0x3FB1111120000000
  %21 = fcmp ogt float %20, 1.000000e+00
  %22 = select i1 %21, float 1.000000e+00, float %20
  %23 = add nuw nsw i32 %.040, 1
  %exitcond.not = icmp eq i32 %23, 30
  br i1 %exitcond.not, label %24, label %1, !llvm.loop !9

24:                                               ; preds = %19
  ret void
}

declare float @compress_mulaw(float noundef, float noundef) local_unnamed_addr #1

declare float @expand_mulaw(float noundef, float noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

declare void @liquid_autotest_failed_expr(ptr noundef, i32 noundef, ptr noundef, double noundef, ptr noundef, ptr noundef, double noundef) local_unnamed_addr #1

declare void @liquid_autotest_passed(...) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.sqrt.f64(double) #4

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 = { "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 = { nofree 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"int", !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: AggressiveInstCombinePass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass