; LLVM IR from jgaeddert/liquid-dsp :: src/agc/src (agc_crcf)

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

%struct.agc_crcf_s = type { float, float, float, float, float, i32, i32, float, i32, i32 }

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

; 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 i32 @agc_crcf_execute(ptr noundef %0, <2 x float> noundef %1, ptr noundef %2) #1 {
  %4 = alloca i32, align 4
  %5 = alloca { float, float }, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca float, align 4
  %9 = alloca { float, float }, align 4
  %10 = alloca i32, align 4
  store <2 x float> %1, ptr %5, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %11 = getelementptr inbounds { float, float }, ptr %5, i32 0, i32 0
  %12 = load float, ptr %11, align 4
  %13 = getelementptr inbounds { float, float }, ptr %5, i32 0, i32 1
  %14 = load float, ptr %13, align 4
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.agc_crcf_s, ptr %15, i32 0, i32 0
  %17 = load float, ptr %16, align 4, !tbaa !9
  %18 = fmul float %12, %17
  %19 = fmul float %14, %17
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = getelementptr inbounds { float, float }, ptr %20, i32 0, i32 0
  %22 = getelementptr inbounds { float, float }, ptr %20, i32 0, i32 1
  store float %18, ptr %21, align 4
  store float %19, ptr %22, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = getelementptr inbounds { float, float }, ptr %23, i32 0, i32 0
  %25 = load float, ptr %24, align 4
  %26 = getelementptr inbounds { float, float }, ptr %23, i32 0, i32 1
  %27 = load float, ptr %26, align 4
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = getelementptr inbounds { float, float }, ptr %28, i32 0, i32 0
  %30 = load float, ptr %29, align 4
  %31 = getelementptr inbounds { float, float }, ptr %28, i32 0, i32 1
  %32 = load float, ptr %31, align 4
  %33 = fneg float %32
  %34 = fmul float %25, %30
  %35 = fmul float %27, %33
  %36 = fmul float %25, %33
  %37 = fmul float %27, %30
  %38 = fsub float %34, %35
  %39 = fadd float %36, %37
  %40 = fcmp uno float %38, %38
  br i1 %40, label %41, label %49, !prof !13

41:                                               ; preds = %3
  %42 = fcmp uno float %39, %39
  br i1 %42, label %43, label %49, !prof !13

43:                                               ; preds = %41
  %44 = call <2 x float> @__mulsc3(float noundef %25, float noundef %27, float noundef %30, float noundef %33) #5
  store <2 x float> %44, ptr %9, align 4
  %45 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %46 = load float, ptr %45, align 4
  %47 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  %48 = load float, ptr %47, align 4
  br label %49

49:                                               ; preds = %43, %41, %3
  %50 = phi float [ %38, %3 ], [ %38, %41 ], [ %46, %43 ]
  %51 = phi float [ %39, %3 ], [ %39, %41 ], [ %48, %43 ]
  store float %50, ptr %8, align 4, !tbaa !14
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.agc_crcf_s, ptr %52, i32 0, i32 3
  %54 = load float, ptr %53, align 4, !tbaa !15
  %55 = fpext float %54 to double
  %56 = fsub double 1.000000e+00, %55
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.agc_crcf_s, ptr %57, i32 0, i32 4
  %59 = load float, ptr %58, align 4, !tbaa !16
  %60 = fpext float %59 to double
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.agc_crcf_s, ptr %61, i32 0, i32 3
  %63 = load float, ptr %62, align 4, !tbaa !15
  %64 = load float, ptr %8, align 4, !tbaa !14
  %65 = fmul float %63, %64
  %66 = fpext float %65 to double
  %67 = call double @llvm.fmuladd.f64(double %56, double %60, double %66)
  %68 = fptrunc double %67 to float
  %69 = load ptr, ptr %6, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.agc_crcf_s, ptr %69, i32 0, i32 4
  store float %68, ptr %70, align 4, !tbaa !16
  %71 = load ptr, ptr %6, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.agc_crcf_s, ptr %71, i32 0, i32 5
  %73 = load i32, ptr %72, align 4, !tbaa !17
  %74 = icmp ne i32 %73, 0
  br i1 %74, label %75, label %76

75:                                               ; preds = %49
  store i32 0, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %124

76:                                               ; preds = %49
  %77 = load ptr, ptr %6, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.agc_crcf_s, ptr %77, i32 0, i32 4
  %79 = load float, ptr %78, align 4, !tbaa !16
  %80 = fcmp ogt float %79, 0x3EB0C6F7A0000000
  br i1 %80, label %81, label %96

81:                                               ; preds = %76
  %82 = load ptr, ptr %6, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.agc_crcf_s, ptr %82, i32 0, i32 3
  %84 = load float, ptr %83, align 4, !tbaa !15
  %85 = fmul float -5.000000e-01, %84
  %86 = load ptr, ptr %6, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.agc_crcf_s, ptr %86, i32 0, i32 4
  %88 = load float, ptr %87, align 4, !tbaa !16
  %89 = call float @logf(float noundef %88) #5
  %90 = fmul float %85, %89
  %91 = call float @expf(float noundef %90) #5, !tbaa !18
  %92 = load ptr, ptr %6, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.agc_crcf_s, ptr %92, i32 0, i32 0
  %94 = load float, ptr %93, align 4, !tbaa !9
  %95 = fmul float %94, %91
  store float %95, ptr %93, align 4, !tbaa !9
  br label %96

96:                                               ; preds = %81, %76
  %97 = load ptr, ptr %6, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.agc_crcf_s, ptr %97, i32 0, i32 0
  %99 = load float, ptr %98, align 4, !tbaa !9
  %100 = fcmp ogt float %99, 1.000000e+06
  br i1 %100, label %101, label %102

101:                                              ; preds = %96
  br label %106

102:                                              ; preds = %96
  %103 = load ptr, ptr %6, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.agc_crcf_s, ptr %103, i32 0, i32 0
  %105 = load float, ptr %104, align 4, !tbaa !9
  br label %106

106:                                              ; preds = %102, %101
  %107 = phi float [ 1.000000e+06, %101 ], [ %105, %102 ]
  %108 = load ptr, ptr %6, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.agc_crcf_s, ptr %108, i32 0, i32 0
  store float %107, ptr %109, align 4, !tbaa !9
  %110 = load ptr, ptr %6, align 8, !tbaa !5
  %111 = call i32 @agc_crcf_squelch_update_mode(ptr noundef %110)
  %112 = load ptr, ptr %6, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.agc_crcf_s, ptr %112, i32 0, i32 1
  %114 = load float, ptr %113, align 4, !tbaa !19
  %115 = load ptr, ptr %7, align 8, !tbaa !5
  %116 = getelementptr inbounds { float, float }, ptr %115, i32 0, i32 0
  %117 = load float, ptr %116, align 4
  %118 = getelementptr inbounds { float, float }, ptr %115, i32 0, i32 1
  %119 = load float, ptr %118, align 4
  %120 = fmul float %117, %114
  %121 = fmul float %119, %114
  %122 = getelementptr inbounds { float, float }, ptr %115, i32 0, i32 0
  %123 = getelementptr inbounds { float, float }, ptr %115, i32 0, i32 1
  store float %120, ptr %122, align 4
  store float %121, ptr %123, align 4
  store i32 0, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %124

124:                                              ; preds = %106, %75
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  %125 = load i32, ptr %4, align 4
  ret i32 %125
}

declare <2 x float> @__mulsc3(float, float, float, float)

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

; Function Attrs: nounwind
declare float @expf(float noundef) #3

; Function Attrs: nounwind
declare float @logf(float noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local i32 @agc_crcf_squelch_update_mode(ptr noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"agc_crcf_s", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !12, i64 20, !12, i64 24, !11, i64 28, !12, i64 32, !12, i64 36}
!11 = !{!"float", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"branch_weights", i32 1, i32 1048575}
!14 = !{!11, !11, i64 0}
!15 = !{!10, !11, i64 12}
!16 = !{!10, !11, i64 16}
!17 = !{!10, !12, i64 20}
!18 = !{!12, !12, i64 0}
!19 = !{!10, !11, i64 4}


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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @agc_crcf_execute(ptr noundef %0, <2 x float> noundef %1, ptr nocapture noundef %2) local_unnamed_addr #0 {
  %4 = load float, ptr %0, align 4, !tbaa !5
  %5 = insertelement <2 x float> poison, float %4, i64 0
  %6 = shufflevector <2 x float> %5, <2 x float> poison, <2 x i32> zeroinitializer
  %7 = fmul <2 x float> %6, %1
  store <2 x float> %7, ptr %2, align 4
  %8 = extractelement <2 x float> %7, i64 1
  %9 = fneg float %8
  %10 = fmul <2 x float> %7, %7
  %shift = shufflevector <2 x float> %10, <2 x float> poison, <2 x i32> <i32 1, i32 poison>
  %11 = fadd <2 x float> %10, %shift
  %12 = extractelement <2 x float> %11, i64 0
  %13 = fcmp uno float %12, 0.000000e+00
  br i1 %13, label %14, label %21, !prof !11

14:                                               ; preds = %3
  %15 = extractelement <2 x float> %7, i64 0
  %16 = fmul float %8, %15
  %17 = fsub float %16, %16
  %18 = fcmp uno float %17, 0.000000e+00
  br i1 %18, label %19, label %21, !prof !11

19:                                               ; preds = %14
  %20 = tail call <2 x float> @__mulsc3(float noundef %15, float noundef %8, float noundef %15, float noundef %9) #4
  %.sroa.0.0.vec.extract = extractelement <2 x float> %20, i64 0
  br label %21

21:                                               ; preds = %19, %14, %3
  %22 = phi float [ %12, %3 ], [ %12, %14 ], [ %.sroa.0.0.vec.extract, %19 ]
  %23 = getelementptr inbounds i8, ptr %0, i64 12
  %24 = load float, ptr %23, align 4, !tbaa !12
  %25 = fpext float %24 to double
  %26 = fsub double 1.000000e+00, %25
  %27 = getelementptr inbounds i8, ptr %0, i64 16
  %28 = load float, ptr %27, align 4, !tbaa !13
  %29 = fpext float %28 to double
  %30 = fmul float %22, %24
  %31 = fpext float %30 to double
  %32 = tail call double @llvm.fmuladd.f64(double %26, double %29, double %31)
  %33 = fptrunc double %32 to float
  store float %33, ptr %27, align 4, !tbaa !13
  %34 = getelementptr inbounds i8, ptr %0, i64 20
  %35 = load i32, ptr %34, align 4, !tbaa !14
  %.not = icmp eq i32 %35, 0
  br i1 %.not, label %36, label %56

36:                                               ; preds = %21
  %37 = fcmp ogt float %33, 0x3EB0C6F7A0000000
  br i1 %37, label %38, label %._crit_edge

._crit_edge:                                      ; preds = %36
  %.pre = load float, ptr %0, align 4, !tbaa !5
  br label %45

38:                                               ; preds = %36
  %39 = fmul float %24, -5.000000e-01
  %40 = tail call float @logf(float noundef %33) #4
  %41 = fmul float %39, %40
  %42 = tail call float @expf(float noundef %41) #4, !tbaa !15
  %43 = load float, ptr %0, align 4, !tbaa !5
  %44 = fmul float %42, %43
  br label %45

45:                                               ; preds = %._crit_edge, %38
  %46 = phi float [ %.pre, %._crit_edge ], [ %44, %38 ]
  %47 = fcmp ogt float %46, 1.000000e+06
  %48 = select i1 %47, float 1.000000e+06, float %46
  store float %48, ptr %0, align 4, !tbaa !5
  %49 = tail call i32 @agc_crcf_squelch_update_mode(ptr noundef nonnull %0)
  %50 = getelementptr inbounds i8, ptr %0, i64 4
  %51 = load float, ptr %50, align 4, !tbaa !16
  %52 = load <2 x float>, ptr %2, align 4
  %53 = insertelement <2 x float> poison, float %51, i64 0
  %54 = shufflevector <2 x float> %53, <2 x float> poison, <2 x i32> zeroinitializer
  %55 = fmul <2 x float> %54, %52
  store <2 x float> %55, ptr %2, align 4
  br label %56

56:                                               ; preds = %21, %45
  ret i32 0
}

declare <2 x float> @__mulsc3(float, float, float, float) local_unnamed_addr

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @expf(float noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @logf(float noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @agc_crcf_squelch_update_mode(ptr noundef) local_unnamed_addr #3

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { 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 #4 = { 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, !7, i64 0}
!6 = !{!"agc_crcf_s", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !10, i64 20, !10, i64 24, !7, i64 28, !10, i64 32, !10, i64 36}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"branch_weights", i32 1, i32 1048575}
!12 = !{!6, !7, i64 12}
!13 = !{!6, !7, i64 16}
!14 = !{!6, !10, i64 20}
!15 = !{!10, !10, i64 0}
!16 = !{!6, !7, i64 4}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass,VectorCombinePass