; 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

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

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

declare float @agc_crcf_get_signal_level(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @autotest_agc_crcf_rssi_sinusoid() #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, float }, align 4
  %11 = alloca { float, float }, align 4
  %12 = alloca float, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #5
  store float 0x3FD3333340000000, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store float 0x3FA99999A0000000, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store float 0x3F50624DE0000000, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store float 0x3FB99999A0000000, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %13 = call ptr @agc_crcf_create()
  store ptr %13, ptr %5, align 8, !tbaa !9
  %14 = load ptr, ptr %5, align 8, !tbaa !9
  %15 = load float, ptr %2, align 4, !tbaa !5
  %16 = call i32 @agc_crcf_set_bandwidth(ptr noundef %14, float noundef %15)
  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 %17

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

20:                                               ; preds = %17
  %21 = load float, ptr %1, align 4, !tbaa !5
  %22 = load float, ptr %4, align 4, !tbaa !5
  %23 = fmul float 0.000000e+00, %22
  %24 = fmul float 1.000000e+00, %22
  %25 = load i32, ptr %6, align 4, !tbaa !11
  %26 = uitofp i32 %25 to float
  %27 = fmul float %23, %26
  %28 = fmul float %24, %26
  %29 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %30 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  store float %27, ptr %29, align 4
  store float %28, ptr %30, align 4
  %31 = load <2 x float>, ptr %9, align 4
  %32 = call <2 x float> @cexpf(<2 x float> noundef %31) #5
  store <2 x float> %32, ptr %10, align 4
  %33 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 0
  %34 = load float, ptr %33, align 4
  %35 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 1
  %36 = load float, ptr %35, align 4
  %37 = fmul float %21, %34
  %38 = fmul float %21, %36
  %39 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 0
  %40 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 1
  store float %37, ptr %39, align 4
  store float %38, ptr %40, align 4
  %41 = load ptr, ptr %5, align 8, !tbaa !9
  %42 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 0
  %43 = load float, ptr %42, align 4
  %44 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 1
  %45 = load float, ptr %44, align 4
  %46 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 0
  %47 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 1
  store float %43, ptr %46, align 4
  store float %45, ptr %47, align 4
  %48 = load <2 x float>, ptr %11, align 4
  %49 = call i32 @agc_crcf_execute(ptr noundef %41, <2 x float> noundef %48, ptr noundef %8)
  br label %50

50:                                               ; preds = %20
  %51 = load i32, ptr %6, align 4, !tbaa !11
  %52 = add i32 %51, 1
  store i32 %52, ptr %6, align 4, !tbaa !11
  br label %17, !llvm.loop !13

53:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %54 = load ptr, ptr %5, align 8, !tbaa !9
  %55 = call float @agc_crcf_get_signal_level(ptr noundef %54)
  store float %55, ptr %12, align 4, !tbaa !5
  %56 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !11
  %57 = icmp ne i32 %56, 0
  br i1 %57, label %58, label %64

58:                                               ; preds = %53
  %59 = load float, ptr %1, align 4, !tbaa !5
  %60 = fpext float %59 to double
  %61 = load float, ptr %12, align 4, !tbaa !5
  %62 = fpext float %61 to double
  %63 = call i32 (ptr, ...) @printf(ptr noundef @.str.12, double noundef %60, double noundef %62)
  br label %64

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

86:                                               ; preds = %64
  %87 = load float, ptr %12, align 4, !tbaa !5
  %88 = call i1 @llvm.is.fpclass.f32(float %87, i32 3)
  br i1 %88, label %98, label %89

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

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

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

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

119:                                              ; preds = %95
  call void (...) @liquid_autotest_passed()
  br label %120

120:                                              ; preds = %119, %98
  %121 = load ptr, ptr %5, align 8, !tbaa !9
  %122 = call i32 @agc_crcf_destroy(ptr noundef %121)
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #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
}

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: nounwind
declare <2 x float> @cexpf(<2 x float> noundef) local_unnamed_addr #3

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

declare float @agc_crcf_get_signal_level(ptr noundef) local_unnamed_addr #1

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

4:                                                ; preds = %0, %4
  %.039 = phi i32 [ 0, %0 ], [ %10, %4 ]
  %5 = uitofp nneg i32 %.039 to float
  %6 = fmul float %5, 0x3FB99999A0000000
  %.sroa.013.4.vec.insert = insertelement <2 x float> <float 0.000000e+00, float poison>, float %6, i64 1
  %7 = call <2 x float> @cexpf(<2 x float> noundef %.sroa.013.4.vec.insert) #7
  %8 = fmul <2 x float> %7, <float 0x3FD3333340000000, float 0x3FD3333340000000>
  %9 = call i32 @agc_crcf_execute(ptr noundef %2, <2 x float> noundef %8, ptr noundef nonnull %1) #7
  %10 = add nuw nsw i32 %.039, 1
  %exitcond.not = icmp eq i32 %10, 512
  br i1 %exitcond.not, label %11, label %4, !llvm.loop !5

11:                                               ; preds = %4
  %12 = call float @agc_crcf_get_signal_level(ptr noundef %2) #7
  %13 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !7
  %.not = icmp eq i32 %13, 0
  br i1 %.not, label %17, label %14

14:                                               ; preds = %11
  %15 = fpext float %12 to double
  %16 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, double noundef 0x3FD3333340000000, double noundef %15)
  br label %17

17:                                               ; preds = %14, %11
  %18 = fadd float %12, 0xBFD3333340000000
  %19 = fpext float %18 to double
  %20 = call double @llvm.fmuladd.f64(double %19, double %19, double 0.000000e+00)
  %sqrt = call double @llvm.sqrt.f64(double %20)
  %21 = fcmp ogt double %sqrt, 0x3F50624DE0000000
  %22 = fcmp uno float %12, 0.000000e+00
  %or.cond = select i1 %21, i1 true, i1 %22
  br i1 %or.cond, label %23, label %24

23:                                               ; preds = %17
  call void @liquid_autotest_failed_expr(ptr noundef nonnull @.str, i32 noundef 147, ptr noundef nonnull @.str.13, double noundef %sqrt, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, double noundef 0x3F50624DE0000000) #7
  br label %25

24:                                               ; preds = %17
  call void (...) @liquid_autotest_passed() #7
  br label %25

25:                                               ; preds = %24, %23
  %26 = call i32 @agc_crcf_destroy(ptr noundef %2) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #7
  ret void
}

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

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 = { 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 = { 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 #5 = { 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 #6 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { 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