; 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
@.str.5 = external hidden unnamed_addr constant [41 x i8], align 1
@liquid_autotest_verbose = external global i32, align 4
@.str.12 = external hidden unnamed_addr constant [31 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 float @agc_crcf_get_gain(ptr noundef) #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 uwtable
define dso_local void @autotest_agc_crcf_ac_gain_control() #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
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #5
  store float 0x3FB99999A0000000, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store float 0x3FB99999A0000000, 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
  %12 = call ptr @agc_crcf_create()
  store ptr %12, ptr %5, align 8, !tbaa !9
  %13 = load ptr, ptr %5, align 8, !tbaa !9
  %14 = load float, ptr %2, align 4, !tbaa !5
  %15 = call i32 @agc_crcf_set_bandwidth(ptr noundef %13, float noundef %14)
  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 %16

16:                                               ; preds = %49, %0
  %17 = load i32, ptr %6, align 4, !tbaa !11
  %18 = icmp ult i32 %17, 256
  br i1 %18, label %19, label %52

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

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

52:                                               ; preds = %16
  %53 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !11
  %54 = icmp ne i32 %53, 0
  br i1 %54, label %55, label %62

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

62:                                               ; preds = %55, %52
  %63 = load ptr, ptr %5, align 8, !tbaa !9
  %64 = call float @agc_crcf_get_gain(ptr noundef %63)
  %65 = load float, ptr %1, align 4, !tbaa !5
  %66 = fdiv float 1.000000e+00, %65
  %67 = fsub float %64, %66
  %68 = fpext float %67 to double
  %69 = load ptr, ptr %5, align 8, !tbaa !9
  %70 = call float @agc_crcf_get_gain(ptr noundef %69)
  %71 = load float, ptr %1, align 4, !tbaa !5
  %72 = fdiv float 1.000000e+00, %71
  %73 = fsub float %70, %72
  %74 = fpext float %73 to double
  %75 = load ptr, ptr %5, align 8, !tbaa !9
  %76 = call float @agc_crcf_get_gain(ptr noundef %75)
  %77 = load float, ptr %1, align 4, !tbaa !5
  %78 = fdiv float 1.000000e+00, %77
  %79 = fsub float %76, %78
  %80 = fpext float %79 to double
  %81 = load ptr, ptr %5, align 8, !tbaa !9
  %82 = call float @agc_crcf_get_gain(ptr noundef %81)
  %83 = load float, ptr %1, align 4, !tbaa !5
  %84 = fdiv float 1.000000e+00, %83
  %85 = fsub float %82, %84
  %86 = fpext float %85 to double
  %87 = call double @llvm.fmuladd.f64(double %68, double %74, double 0.000000e+00)
  %88 = call double @sqrt(double noundef %87) #5
  %89 = load float, ptr %3, align 4, !tbaa !5
  %90 = fpext float %89 to double
  %91 = fcmp ogt double %88, %90
  br i1 %91, label %108, label %92

92:                                               ; preds = %62
  %93 = load ptr, ptr %5, align 8, !tbaa !9
  %94 = call float @agc_crcf_get_gain(ptr noundef %93)
  %95 = call i1 @llvm.is.fpclass.f32(float %94, i32 3)
  br i1 %95, label %108, label %96

96:                                               ; preds = %92
  %97 = load ptr, ptr %5, align 8, !tbaa !9
  %98 = call float @agc_crcf_get_gain(ptr noundef %97)
  %99 = call i1 @llvm.is.fpclass.f32(float 0.000000e+00, i32 3)
  br i1 %99, label %108, label %100

100:                                              ; preds = %96
  %101 = load float, ptr %1, align 4, !tbaa !5
  %102 = fdiv float 1.000000e+00, %101
  %103 = call i1 @llvm.is.fpclass.f32(float %102, i32 3)
  br i1 %103, label %108, label %104

104:                                              ; preds = %100
  %105 = load float, ptr %1, align 4, !tbaa !5
  %106 = fdiv float 1.000000e+00, %105
  %107 = call i1 @llvm.is.fpclass.f32(float 0.000000e+00, i32 3)
  br i1 %107, label %108, label %137

108:                                              ; preds = %104, %100, %96, %92, %62
  %109 = load ptr, ptr %5, align 8, !tbaa !9
  %110 = call float @agc_crcf_get_gain(ptr noundef %109)
  %111 = load float, ptr %1, align 4, !tbaa !5
  %112 = fdiv float 1.000000e+00, %111
  %113 = fsub float %110, %112
  %114 = fpext float %113 to double
  %115 = load ptr, ptr %5, align 8, !tbaa !9
  %116 = call float @agc_crcf_get_gain(ptr noundef %115)
  %117 = load float, ptr %1, align 4, !tbaa !5
  %118 = fdiv float 1.000000e+00, %117
  %119 = fsub float %116, %118
  %120 = fpext float %119 to double
  %121 = load ptr, ptr %5, align 8, !tbaa !9
  %122 = call float @agc_crcf_get_gain(ptr noundef %121)
  %123 = load float, ptr %1, align 4, !tbaa !5
  %124 = fdiv float 1.000000e+00, %123
  %125 = fsub float %122, %124
  %126 = fpext float %125 to double
  %127 = load ptr, ptr %5, align 8, !tbaa !9
  %128 = call float @agc_crcf_get_gain(ptr noundef %127)
  %129 = load float, ptr %1, align 4, !tbaa !5
  %130 = fdiv float 1.000000e+00, %129
  %131 = fsub float %128, %130
  %132 = fpext float %131 to double
  %133 = call double @llvm.fmuladd.f64(double %114, double %120, double 0.000000e+00)
  %134 = call double @sqrt(double noundef %133) #5
  %135 = load float, ptr %3, align 4, !tbaa !5
  %136 = fpext float %135 to double
  call void @liquid_autotest_failed_expr(ptr noundef @.str, i32 noundef 109, ptr noundef @.str.5, double noundef %134, ptr noundef @.str.2, ptr noundef @.str.3, double noundef %136)
  br label %138

137:                                              ; preds = %104
  call void (...) @liquid_autotest_passed()
  br label %138

138:                                              ; preds = %137, %108
  %139 = load ptr, ptr %5, align 8, !tbaa !9
  %140 = call i32 @agc_crcf_destroy(ptr noundef %139)
  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 <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

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
@.str.5 = external hidden unnamed_addr constant [41 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

; 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 nofree nounwind willreturn memory(write)
declare double @sqrt(double noundef) 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

declare float @agc_crcf_get_gain(ptr noundef) 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 uwtable
define dso_local void @autotest_agc_crcf_ac_gain_control() local_unnamed_addr #4 {
  %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 0x3FB99999A0000000) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #7
  br label %4

4:                                                ; preds = %0, %4
  %.037 = phi i32 [ 0, %0 ], [ %10, %4 ]
  %5 = uitofp nneg i32 %.037 to float
  %6 = fmul float %5, 0x3FB99999A0000000
  %.sroa.03.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.03.4.vec.insert) #7
  %8 = fmul <2 x float> %7, <float 0x3FB99999A0000000, float 0x3FB99999A0000000>
  %9 = call i32 @agc_crcf_execute(ptr noundef %2, <2 x float> noundef %8, ptr noundef nonnull %1) #7
  %10 = add nuw nsw i32 %.037, 1
  %exitcond.not = icmp eq i32 %10, 256
  br i1 %exitcond.not, label %11, label %4, !llvm.loop !5

11:                                               ; preds = %4
  %12 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !7
  %.not = icmp eq i32 %12, 0
  br i1 %.not, label %17, label %13

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

17:                                               ; preds = %13, %11
  %18 = call float @agc_crcf_get_gain(ptr noundef %2) #7
  %19 = fadd float %18, -1.000000e+01
  %20 = fpext float %19 to double
  %21 = call float @agc_crcf_get_gain(ptr noundef %2) #7
  %22 = fadd float %21, -1.000000e+01
  %23 = fpext float %22 to double
  %24 = call float @agc_crcf_get_gain(ptr noundef %2) #7
  %25 = call float @agc_crcf_get_gain(ptr noundef %2) #7
  %26 = call double @llvm.fmuladd.f64(double %20, double %23, double 0.000000e+00)
  %27 = call double @sqrt(double noundef %26) #7
  %28 = fcmp ogt double %27, 0x3F50624DE0000000
  br i1 %28, label %34, label %29

29:                                               ; preds = %17
  %30 = call float @agc_crcf_get_gain(ptr noundef %2) #7
  %31 = fcmp uno float %30, 0.000000e+00
  br i1 %31, label %34, label %32

32:                                               ; preds = %29
  %33 = call float @agc_crcf_get_gain(ptr noundef %2) #7
  call void (...) @liquid_autotest_passed() #7
  br label %45

34:                                               ; preds = %29, %17
  %35 = call float @agc_crcf_get_gain(ptr noundef %2) #7
  %36 = fadd float %35, -1.000000e+01
  %37 = fpext float %36 to double
  %38 = call float @agc_crcf_get_gain(ptr noundef %2) #7
  %39 = fadd float %38, -1.000000e+01
  %40 = fpext float %39 to double
  %41 = call float @agc_crcf_get_gain(ptr noundef %2) #7
  %42 = call float @agc_crcf_get_gain(ptr noundef %2) #7
  %43 = call double @llvm.fmuladd.f64(double %37, double %40, double 0.000000e+00)
  %44 = call double @sqrt(double noundef %43) #7
  call void @liquid_autotest_failed_expr(ptr noundef nonnull @.str, i32 noundef 109, ptr noundef nonnull @.str.5, double noundef %44, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, double noundef 0x3F50624DE0000000) #7
  br label %45

45:                                               ; preds = %32, %34
  %46 = 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: nounwind
declare <2 x float> @cexpf(<2 x float> noundef) local_unnamed_addr #5

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

declare float @agc_crcf_get_signal_level(ptr noundef) local_unnamed_addr #1

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 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 #3 = { mustprogress 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 "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 = { 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 #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: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass