; LLVM IR from jgaeddert/liquid-dsp :: src/quantization/tests (quantize_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"

@.str = external hidden unnamed_addr constant [97 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@liquid_autotest_verbose = external global i32, align 4
@.str.4 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @autotest_quantize_float_n8() #0 {
  %1 = alloca float, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca float, align 4
  %5 = alloca i32, 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 i32 30, ptr %2, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 8, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  %9 = load i32, ptr %2, 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
  %12 = load i32, ptr %3, align 4, !tbaa !9
  %13 = shl i32 1, %12
  %14 = sitofp i32 %13 to float
  %15 = fdiv float 1.000000e+00, %14
  store float %15, 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 %16

16:                                               ; preds = %114, %0
  %17 = load i32, ptr %8, align 4, !tbaa !9
  %18 = load i32, ptr %2, align 4, !tbaa !9
  %19 = icmp ult i32 %17, %18
  br i1 %19, label %20, label %117

20:                                               ; preds = %16
  %21 = load float, ptr %1, align 4, !tbaa !5
  %22 = load i32, ptr %3, align 4, !tbaa !9
  %23 = call i32 @quantize_adc(float noundef %21, i32 noundef %22)
  store i32 %23, ptr %5, align 4, !tbaa !9
  %24 = load i32, ptr %5, align 4, !tbaa !9
  %25 = load i32, ptr %3, align 4, !tbaa !9
  %26 = lshr i32 %24, %25
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %28, label %33

28:                                               ; preds = %20
  %29 = load i32, ptr %5, align 4, !tbaa !9
  %30 = load i32, ptr %3, align 4, !tbaa !9
  %31 = lshr i32 %29, %30
  %32 = uitofp i32 %31 to double
  call void @liquid_autotest_failed_expr(ptr noundef @.str, i32 noundef 41, ptr noundef @.str.1, double noundef %32, ptr noundef @.str.2, ptr noundef @.str.3, double noundef 0.000000e+00)
  br label %34

33:                                               ; preds = %20
  call void (...) @liquid_autotest_passed()
  br label %34

34:                                               ; preds = %33, %28
  %35 = load i32, ptr %5, align 4, !tbaa !9
  %36 = load i32, ptr %3, align 4, !tbaa !9
  %37 = call float @quantize_dac(i32 noundef %35, i32 noundef %36)
  store float %37, ptr %6, align 4, !tbaa !5
  %38 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !9
  %39 = icmp ne i32 %38, 0
  br i1 %39, label %40, label %47

40:                                               ; preds = %34
  %41 = load float, ptr %1, align 4, !tbaa !5
  %42 = fpext float %41 to double
  %43 = load i32, ptr %5, align 4, !tbaa !9
  %44 = load float, ptr %6, align 4, !tbaa !5
  %45 = fpext float %44 to double
  %46 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, double noundef %42, i32 noundef %43, double noundef %45)
  br label %47

47:                                               ; preds = %40, %34
  %48 = load float, ptr %1, align 4, !tbaa !5
  %49 = load float, ptr %6, align 4, !tbaa !5
  %50 = fsub float %48, %49
  %51 = fpext float %50 to double
  %52 = load float, ptr %1, align 4, !tbaa !5
  %53 = load float, ptr %6, align 4, !tbaa !5
  %54 = fsub float %52, %53
  %55 = fpext float %54 to double
  %56 = load float, ptr %1, align 4, !tbaa !5
  %57 = load float, ptr %6, align 4, !tbaa !5
  %58 = fsub float %56, %57
  %59 = fpext float %58 to double
  %60 = load float, ptr %1, align 4, !tbaa !5
  %61 = load float, ptr %6, align 4, !tbaa !5
  %62 = fsub float %60, %61
  %63 = fpext float %62 to double
  %64 = call double @llvm.fmuladd.f64(double %51, double %55, double 0.000000e+00)
  %65 = call double @sqrt(double noundef %64) #5
  %66 = load float, ptr %7, align 4, !tbaa !5
  %67 = fpext float %66 to double
  %68 = fcmp ogt double %65, %67
  br i1 %68, label %81, label %69

69:                                               ; preds = %47
  %70 = load float, ptr %1, align 4, !tbaa !5
  %71 = call i1 @llvm.is.fpclass.f32(float %70, i32 3)
  br i1 %71, label %81, label %72

72:                                               ; preds = %69
  %73 = load float, ptr %1, align 4, !tbaa !5
  %74 = call i1 @llvm.is.fpclass.f32(float 0.000000e+00, i32 3)
  br i1 %74, label %81, label %75

75:                                               ; preds = %72
  %76 = load float, ptr %6, align 4, !tbaa !5
  %77 = call i1 @llvm.is.fpclass.f32(float %76, i32 3)
  br i1 %77, label %81, label %78

78:                                               ; preds = %75
  %79 = load float, ptr %6, align 4, !tbaa !5
  %80 = call i1 @llvm.is.fpclass.f32(float 0.000000e+00, i32 3)
  br i1 %80, label %81, label %102

81:                                               ; preds = %78, %75, %72, %69, %47
  %82 = load float, ptr %1, align 4, !tbaa !5
  %83 = load float, ptr %6, align 4, !tbaa !5
  %84 = fsub float %82, %83
  %85 = fpext float %84 to double
  %86 = load float, ptr %1, align 4, !tbaa !5
  %87 = load float, ptr %6, align 4, !tbaa !5
  %88 = fsub float %86, %87
  %89 = fpext float %88 to double
  %90 = load float, ptr %1, align 4, !tbaa !5
  %91 = load float, ptr %6, align 4, !tbaa !5
  %92 = fsub float %90, %91
  %93 = fpext float %92 to double
  %94 = load float, ptr %1, align 4, !tbaa !5
  %95 = load float, ptr %6, align 4, !tbaa !5
  %96 = fsub float %94, %95
  %97 = fpext float %96 to double
  %98 = call double @llvm.fmuladd.f64(double %85, double %89, double 0.000000e+00)
  %99 = call double @sqrt(double noundef %98) #5
  %100 = load float, ptr %7, align 4, !tbaa !5
  %101 = fpext float %100 to double
  call void @liquid_autotest_failed_expr(ptr noundef @.str, i32 noundef 49, ptr noundef @.str.5, double noundef %99, ptr noundef @.str.6, ptr noundef @.str.7, double noundef %101)
  br label %103

102:                                              ; preds = %78
  call void (...) @liquid_autotest_passed()
  br label %103

103:                                              ; preds = %102, %81
  %104 = load float, ptr %4, align 4, !tbaa !5
  %105 = load float, ptr %1, align 4, !tbaa !5
  %106 = fadd float %105, %104
  store float %106, ptr %1, align 4, !tbaa !5
  %107 = load float, ptr %1, align 4, !tbaa !5
  %108 = fcmp ogt float %107, 1.000000e+00
  br i1 %108, label %109, label %110

109:                                              ; preds = %103
  br label %112

110:                                              ; preds = %103
  %111 = load float, ptr %1, align 4, !tbaa !5
  br label %112

112:                                              ; preds = %110, %109
  %113 = phi float [ 1.000000e+00, %109 ], [ %111, %110 ]
  store float %113, ptr %1, align 4, !tbaa !5
  br label %114

114:                                              ; preds = %112
  %115 = load i32, ptr %8, align 4, !tbaa !9
  %116 = add i32 %115, 1
  store i32 %116, ptr %8, align 4, !tbaa !9
  br label %16, !llvm.loop !11

117:                                              ; preds = %16
  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 i32 @quantize_adc(float noundef, i32 noundef) #2

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

declare float @quantize_dac(i32 noundef, i32 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

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

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

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

1:                                                ; preds = %0, %23
  %.047 = phi i32 [ 0, %0 ], [ %27, %23 ]
  %.04146 = phi float [ -1.000000e+00, %0 ], [ %26, %23 ]
  %2 = tail call i32 @quantize_adc(float noundef %.04146, i32 noundef 8) #5
  %.not = icmp ult i32 %2, 256
  br i1 %.not, label %6, label %3

3:                                                ; preds = %1
  %4 = lshr i32 %2, 8
  %5 = uitofp nneg i32 %4 to double
  tail call void @liquid_autotest_failed_expr(ptr noundef nonnull @.str, i32 noundef 41, ptr noundef nonnull @.str.1, double noundef %5, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, double noundef 0.000000e+00) #5
  br label %7

6:                                                ; preds = %1
  tail call void (...) @liquid_autotest_passed() #5
  br label %7

7:                                                ; preds = %6, %3
  %8 = tail call float @quantize_dac(i32 noundef %2, i32 noundef 8) #5
  %9 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !5
  %.not43 = icmp eq i32 %9, 0
  br i1 %.not43, label %14, label %10

10:                                               ; preds = %7
  %11 = fpext float %.04146 to double
  %12 = fpext float %8 to double
  %13 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, double noundef %11, i32 noundef %2, double noundef %12)
  br label %14

14:                                               ; preds = %10, %7
  %15 = fsub float %.04146, %8
  %16 = fpext float %15 to double
  %17 = tail call double @llvm.fmuladd.f64(double %16, double %16, double 0.000000e+00)
  %sqrt = tail call double @llvm.sqrt.f64(double %17)
  %18 = fcmp ogt double %sqrt, 3.906250e-03
  %19 = fcmp uno float %.04146, 0.000000e+00
  %or.cond = or i1 %18, %19
  %20 = fcmp uno float %8, 0.000000e+00
  %or.cond44 = select i1 %or.cond, i1 true, i1 %20
  br i1 %or.cond44, label %21, label %22

21:                                               ; preds = %14
  tail call void @liquid_autotest_failed_expr(ptr noundef nonnull @.str, i32 noundef 49, ptr noundef nonnull @.str.5, double noundef %sqrt, ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.7, double noundef 3.906250e-03) #5
  br label %23

22:                                               ; preds = %14
  tail call void (...) @liquid_autotest_passed() #5
  br label %23

23:                                               ; preds = %22, %21
  %24 = fadd float %.04146, 0x3FB1111120000000
  %25 = fcmp ogt float %24, 1.000000e+00
  %26 = select i1 %25, float 1.000000e+00, float %24
  %27 = add nuw nsw i32 %.047, 1
  %exitcond.not = icmp eq i32 %27, 30
  br i1 %exitcond.not, label %28, label %1, !llvm.loop !9

28:                                               ; preds = %23
  ret void
}

declare i32 @quantize_adc(float noundef, i32 noundef) local_unnamed_addr #1

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

declare float @quantize_dac(i32 noundef, i32 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

; 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