; LLVM IR from jgaeddert/liquid-dsp :: src/agc/tests (agc_crcf_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 [88 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@liquid_autotest_verbose = external global i32, align 4
@.str.12 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [20 x i8], align 1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare ptr @agc_crcf_create() #1

declare i32 @agc_crcf_set_bandwidth(ptr noundef, float noundef) #1

declare i32 @agc_crcf_execute(ptr noundef, <2 x float> noundef, ptr noundef) #1

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

; Function Attrs: 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 i1 @llvm.is.fpclass.f32(float, i32 immarg) #3

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

declare void @liquid_autotest_passed(...) #1

declare i32 @agc_crcf_destroy(ptr noundef) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: nounwind uwtable
define dso_local void @autotest_agc_crcf_rssi_noise() #4 {
  %1 = alloca float, align 4
  %2 = alloca float, align 4
  %3 = alloca float, align 4
  %4 = alloca float, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca { float, float }, align 4
  %8 = alloca { float, float }, align 4
  %9 = alloca { float, float }, align 4
  %10 = alloca float, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #5
  store float -3.000000e+01, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store float 0x3F60624DE0000000, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store float 1.000000e+00, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  %11 = load float, ptr %1, align 4, !tbaa !5
  %12 = fdiv float %11, 2.000000e+01
  %13 = call float @powf(float noundef 1.000000e+01, float noundef %12) #5
  store float %13, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %14 = call ptr @agc_crcf_create()
  store ptr %14, ptr %5, align 8, !tbaa !9
  %15 = load ptr, ptr %5, align 8, !tbaa !9
  %16 = load float, ptr %2, align 4, !tbaa !5
  %17 = call i32 @agc_crcf_set_bandwidth(ptr noundef %15, float noundef %16)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  store i32 0, ptr %6, align 4, !tbaa !11
  br label %18

18:                                               ; preds = %47, %0
  %19 = load i32, ptr %6, align 4, !tbaa !11
  %20 = icmp ult i32 %19, 8000
  br i1 %20, label %21, label %50

21:                                               ; preds = %18
  %22 = load float, ptr %4, align 4, !tbaa !5
  %23 = call float (...) @randnf()
  %24 = call float (...) @randnf()
  %25 = fmul float 0.000000e+00, %24
  %26 = fmul float 1.000000e+00, %24
  %27 = fadd float %23, %25
  %28 = fmul float %22, %27
  %29 = fmul float %22, %26
  %30 = fpext float %28 to double
  %31 = fpext float %29 to double
  %32 = fmul double %30, 0x3FE6A09E667F3BCD
  %33 = fmul double %31, 0x3FE6A09E667F3BCD
  %34 = fptrunc double %32 to float
  %35 = fptrunc double %33 to float
  %36 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 0
  %37 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 1
  store float %34, ptr %36, align 4
  store float %35, ptr %37, align 4
  %38 = load ptr, ptr %5, align 8, !tbaa !9
  %39 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 0
  %40 = load float, ptr %39, align 4
  %41 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 1
  %42 = load float, ptr %41, align 4
  %43 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %44 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  store float %40, ptr %43, align 4
  store float %42, ptr %44, align 4
  %45 = load <2 x float>, ptr %9, align 4
  %46 = call i32 @agc_crcf_execute(ptr noundef %38, <2 x float> noundef %45, ptr noundef %8)
  br label %47

47:                                               ; preds = %21
  %48 = load i32, ptr %6, align 4, !tbaa !11
  %49 = add i32 %48, 1
  store i32 %49, ptr %6, align 4, !tbaa !11
  br label %18, !llvm.loop !13

50:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %51 = load ptr, ptr %5, align 8, !tbaa !9
  %52 = call float @agc_crcf_get_rssi(ptr noundef %51)
  store float %52, ptr %10, align 4, !tbaa !5
  %53 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !11
  %54 = icmp ne i32 %53, 0
  br i1 %54, label %55, label %61

55:                                               ; preds = %50
  %56 = load float, ptr %1, align 4, !tbaa !5
  %57 = fpext float %56 to double
  %58 = load float, ptr %10, align 4, !tbaa !5
  %59 = fpext float %58 to double
  %60 = call i32 (ptr, ...) @printf(ptr noundef @.str.12, double noundef %57, double noundef %59)
  br label %61

61:                                               ; preds = %55, %50
  %62 = load float, ptr %10, align 4, !tbaa !5
  %63 = load float, ptr %1, align 4, !tbaa !5
  %64 = fsub float %62, %63
  %65 = fpext float %64 to double
  %66 = load float, ptr %10, align 4, !tbaa !5
  %67 = load float, ptr %1, align 4, !tbaa !5
  %68 = fsub float %66, %67
  %69 = fpext float %68 to double
  %70 = load float, ptr %10, align 4, !tbaa !5
  %71 = load float, ptr %1, align 4, !tbaa !5
  %72 = fsub float %70, %71
  %73 = fpext float %72 to double
  %74 = load float, ptr %10, align 4, !tbaa !5
  %75 = load float, ptr %1, align 4, !tbaa !5
  %76 = fsub float %74, %75
  %77 = fpext float %76 to double
  %78 = call double @llvm.fmuladd.f64(double %65, double %69, double 0.000000e+00)
  %79 = call double @sqrt(double noundef %78) #5
  %80 = load float, ptr %3, align 4, !tbaa !5
  %81 = fpext float %80 to double
  %82 = fcmp ogt double %79, %81
  br i1 %82, label %95, label %83

83:                                               ; preds = %61
  %84 = load float, ptr %10, align 4, !tbaa !5
  %85 = call i1 @llvm.is.fpclass.f32(float %84, i32 3)
  br i1 %85, label %95, label %86

86:                                               ; preds = %83
  %87 = load float, ptr %10, align 4, !tbaa !5
  %88 = call i1 @llvm.is.fpclass.f32(float 0.000000e+00, i32 3)
  br i1 %88, label %95, label %89

89:                                               ; preds = %86
  %90 = load float, ptr %1, align 4, !tbaa !5
  %91 = call i1 @llvm.is.fpclass.f32(float %90, i32 3)
  br i1 %91, label %95, label %92

92:                                               ; preds = %89
  %93 = load float, ptr %1, align 4, !tbaa !5
  %94 = call i1 @llvm.is.fpclass.f32(float 0.000000e+00, i32 3)
  br i1 %94, label %95, label %116

95:                                               ; preds = %92, %89, %86, %83, %61
  %96 = load float, ptr %10, align 4, !tbaa !5
  %97 = load float, ptr %1, align 4, !tbaa !5
  %98 = fsub float %96, %97
  %99 = fpext float %98 to double
  %100 = load float, ptr %10, align 4, !tbaa !5
  %101 = load float, ptr %1, align 4, !tbaa !5
  %102 = fsub float %100, %101
  %103 = fpext float %102 to double
  %104 = load float, ptr %10, align 4, !tbaa !5
  %105 = load float, ptr %1, align 4, !tbaa !5
  %106 = fsub float %104, %105
  %107 = fpext float %106 to double
  %108 = load float, ptr %10, align 4, !tbaa !5
  %109 = load float, ptr %1, align 4, !tbaa !5
  %110 = fsub float %108, %109
  %111 = fpext float %110 to double
  %112 = call double @llvm.fmuladd.f64(double %99, double %103, double 0.000000e+00)
  %113 = call double @sqrt(double noundef %112) #5
  %114 = load float, ptr %3, align 4, !tbaa !5
  %115 = fpext float %114 to double
  call void @liquid_autotest_failed_expr(ptr noundef @.str, i32 noundef 185, ptr noundef @.str.13, double noundef %113, ptr noundef @.str.2, ptr noundef @.str.3, double noundef %115)
  br label %117

116:                                              ; preds = %92
  call void (...) @liquid_autotest_passed()
  br label %117

117:                                              ; preds = %116, %95
  %118 = load ptr, ptr %5, align 8, !tbaa !9
  %119 = call i32 @agc_crcf_destroy(ptr noundef %118)
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, 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: nounwind
declare float @powf(float noundef, float noundef) #2

declare float @randnf(...) #1

declare float @agc_crcf_get_rssi(ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 #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 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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 [88 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@liquid_autotest_verbose = external local_unnamed_addr global i32, align 4
@.str.12 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [20 x i8], align 1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare ptr @agc_crcf_create() local_unnamed_addr #1

declare i32 @agc_crcf_set_bandwidth(ptr noundef, float noundef) local_unnamed_addr #1

declare i32 @agc_crcf_execute(ptr noundef, <2 x float> noundef, ptr noundef) local_unnamed_addr #1

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

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 i32 @agc_crcf_destroy(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: nounwind uwtable
define dso_local void @autotest_agc_crcf_rssi_noise() local_unnamed_addr #4 {
  %1 = alloca { float, float }, align 4
  %2 = tail call ptr @agc_crcf_create() #6
  %3 = tail call i32 @agc_crcf_set_bandwidth(ptr noundef %2, float noundef 0x3F60624DE0000000) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #6
  br label %4

4:                                                ; preds = %0, %4
  %.035 = phi i32 [ 0, %0 ], [ %16, %4 ]
  %5 = call float (...) @randnf() #6
  %6 = call float (...) @randnf() #6
  %7 = fmul float %6, 0.000000e+00
  %8 = fadd float %5, %7
  %9 = insertelement <2 x float> poison, float %8, i64 0
  %10 = insertelement <2 x float> %9, float %6, i64 1
  %11 = fmul <2 x float> %10, <float 0x3FA030DC40000000, float 0x3FA030DC40000000>
  %12 = fpext <2 x float> %11 to <2 x double>
  %13 = fmul <2 x double> %12, <double 0x3FE6A09E667F3BCD, double 0x3FE6A09E667F3BCD>
  %14 = fptrunc <2 x double> %13 to <2 x float>
  %15 = call i32 @agc_crcf_execute(ptr noundef %2, <2 x float> noundef %14, ptr noundef nonnull %1) #6
  %16 = add nuw nsw i32 %.035, 1
  %exitcond.not = icmp eq i32 %16, 8000
  br i1 %exitcond.not, label %17, label %4, !llvm.loop !5

17:                                               ; preds = %4
  %18 = call float @agc_crcf_get_rssi(ptr noundef %2) #6
  %19 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !7
  %.not = icmp eq i32 %19, 0
  br i1 %.not, label %23, label %20

20:                                               ; preds = %17
  %21 = fpext float %18 to double
  %22 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, double noundef -3.000000e+01, double noundef %21)
  br label %23

23:                                               ; preds = %20, %17
  %24 = fadd float %18, 3.000000e+01
  %25 = fpext float %24 to double
  %26 = call double @llvm.fmuladd.f64(double %25, double %25, double 0.000000e+00)
  %sqrt = call double @llvm.sqrt.f64(double %26)
  %27 = fcmp ogt double %sqrt, 1.000000e+00
  %28 = fcmp uno float %18, 0.000000e+00
  %or.cond = select i1 %27, i1 true, i1 %28
  br i1 %or.cond, label %29, label %30

29:                                               ; preds = %23
  call void @liquid_autotest_failed_expr(ptr noundef nonnull @.str, i32 noundef 185, ptr noundef nonnull @.str.13, double noundef %sqrt, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, double noundef 1.000000e+00) #6
  br label %31

30:                                               ; preds = %23
  call void (...) @liquid_autotest_passed() #6
  br label %31

31:                                               ; preds = %30, %29
  %32 = call i32 @agc_crcf_destroy(ptr noundef %2) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #6
  ret void
}

declare float @randnf(...) local_unnamed_addr #1

declare float @agc_crcf_get_rssi(ptr noundef) local_unnamed_addr #1

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #4 = { 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 #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: AggressiveInstCombinePass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass