; LLVM IR from jgaeddert/liquid-dsp :: sandbox (math_csqrtf_test)

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

; Function Attrs: nounwind uwtable
define dso_local <2 x float> @sandbox_csqrtf(<2 x float> noundef %0) #0 {
  %2 = alloca { float, float }, align 4
  %3 = alloca { float, float }, align 4
  %4 = alloca float, align 4
  %5 = alloca { float, float }, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  store <2 x float> %0, ptr %3, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %9 = getelementptr inbounds { float, float }, ptr %3, i32 0, i32 0
  %10 = load float, ptr %9, align 4
  %11 = getelementptr inbounds { float, float }, ptr %3, i32 0, i32 1
  %12 = load float, ptr %11, align 4
  %13 = getelementptr inbounds { float, float }, ptr %5, i32 0, i32 0
  %14 = getelementptr inbounds { float, float }, ptr %5, i32 0, i32 1
  store float %10, ptr %13, align 4
  store float %12, ptr %14, align 4
  %15 = load <2 x float>, ptr %5, align 4
  %16 = call float @cabsf(<2 x float> noundef %15) #3
  store float %16, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %17 = getelementptr inbounds { float, float }, ptr %3, i32 0, i32 0
  %18 = load float, ptr %17, align 4
  %19 = getelementptr inbounds { float, float }, ptr %3, i32 0, i32 1
  %20 = load float, ptr %19, align 4
  store float %18, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %21 = load float, ptr %4, align 4, !tbaa !5
  %22 = load float, ptr %6, align 4, !tbaa !5
  %23 = fadd float %21, %22
  %24 = fmul float 5.000000e-01, %23
  %25 = call float @sqrtf(float noundef %24) #3
  store float %25, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %26 = load float, ptr %4, align 4, !tbaa !5
  %27 = load float, ptr %6, align 4, !tbaa !5
  %28 = fsub float %26, %27
  %29 = fmul float 5.000000e-01, %28
  %30 = call float @sqrtf(float noundef %29) #3
  store float %30, ptr %8, align 4, !tbaa !5
  %31 = getelementptr inbounds { float, float }, ptr %3, i32 0, i32 0
  %32 = load float, ptr %31, align 4
  %33 = getelementptr inbounds { float, float }, ptr %3, i32 0, i32 1
  %34 = load float, ptr %33, align 4
  %35 = fcmp ogt float %34, 0.000000e+00
  br i1 %35, label %36, label %42

36:                                               ; preds = %1
  %37 = load float, ptr %7, align 4, !tbaa !5
  %38 = load float, ptr %8, align 4, !tbaa !5
  %39 = fmul float 0.000000e+00, %38
  %40 = fmul float 1.000000e+00, %38
  %41 = fadd float %37, %39
  br label %49

42:                                               ; preds = %1
  %43 = load float, ptr %7, align 4, !tbaa !5
  %44 = load float, ptr %8, align 4, !tbaa !5
  %45 = fmul float 0.000000e+00, %44
  %46 = fmul float 1.000000e+00, %44
  %47 = fsub float %43, %45
  %48 = fneg float %46
  br label %49

49:                                               ; preds = %42, %36
  %50 = phi float [ %41, %36 ], [ %47, %42 ]
  %51 = phi float [ %40, %36 ], [ %48, %42 ]
  %52 = getelementptr inbounds { float, float }, ptr %2, i32 0, i32 0
  %53 = getelementptr inbounds { float, float }, ptr %2, i32 0, i32 1
  store float %50, ptr %52, align 4
  store float %51, ptr %53, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %54 = load <2 x float>, ptr %2, align 4
  ret <2 x float> %54
}

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

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

; Function Attrs: nounwind
declare float @sqrtf(float noundef) #2

; 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"="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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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"}


; 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 <2 x float> @sandbox_csqrtf(<2 x float> noundef %0) local_unnamed_addr #0 {
  %.sroa.09.0.vec.extract = extractelement <2 x float> %0, i64 0
  %.sroa.09.4.vec.extract = extractelement <2 x float> %0, i64 1
  %2 = tail call float @cabsf(<2 x float> noundef %0) #3
  %3 = fadd float %.sroa.09.0.vec.extract, %2
  %4 = fmul float %3, 5.000000e-01
  %5 = tail call float @sqrtf(float noundef %4) #3
  %6 = fsub float %2, %.sroa.09.0.vec.extract
  %7 = fmul float %6, 5.000000e-01
  %8 = tail call float @sqrtf(float noundef %7) #3
  %9 = fcmp ogt float %.sroa.09.4.vec.extract, 0.000000e+00
  %10 = fmul float %8, 0.000000e+00
  %11 = fneg float %8
  %12 = fneg float %10
  %.p = select i1 %9, float %10, float %12
  %13 = fadd float %5, %.p
  %14 = select i1 %9, float %8, float %11
  %.sroa.018.0.vec.insert = insertelement <2 x float> poison, float %13, i64 0
  %.sroa.018.4.vec.insert = insertelement <2 x float> %.sroa.018.0.vec.insert, float %14, i64 1
  ret <2 x float> %.sroa.018.4.vec.insert
}

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

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

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 = { 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 #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 }

!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)"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass