; LLVM IR from InsightSoftwareConsortium/ITK :: Modules/ThirdParty/VNL/src/vxl/v3p/netlib/libf2c/cabs.ll_f (cabs)

; 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 double @f__cabs(double noundef %0, double noundef %1) #0 {
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca i32, align 4
  store double %0, ptr %4, align 8, !tbaa !5
  store double %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %8 = load double, ptr %4, align 8, !tbaa !5
  %9 = fcmp olt double %8, 0.000000e+00
  br i1 %9, label %10, label %13

10:                                               ; preds = %2
  %11 = load double, ptr %4, align 8, !tbaa !5
  %12 = fneg double %11
  store double %12, ptr %4, align 8, !tbaa !5
  br label %13

13:                                               ; preds = %10, %2
  %14 = load double, ptr %5, align 8, !tbaa !5
  %15 = fcmp olt double %14, 0.000000e+00
  br i1 %15, label %16, label %19

16:                                               ; preds = %13
  %17 = load double, ptr %5, align 8, !tbaa !5
  %18 = fneg double %17
  store double %18, ptr %5, align 8, !tbaa !5
  br label %19

19:                                               ; preds = %16, %13
  %20 = load double, ptr %5, align 8, !tbaa !5
  %21 = load double, ptr %4, align 8, !tbaa !5
  %22 = fcmp ogt double %20, %21
  br i1 %22, label %23, label %27

23:                                               ; preds = %19
  %24 = load double, ptr %4, align 8, !tbaa !5
  store double %24, ptr %6, align 8, !tbaa !5
  %25 = load double, ptr %5, align 8, !tbaa !5
  store double %25, ptr %4, align 8, !tbaa !5
  %26 = load double, ptr %6, align 8, !tbaa !5
  store double %26, ptr %5, align 8, !tbaa !5
  br label %27

27:                                               ; preds = %23, %19
  %28 = load double, ptr %4, align 8, !tbaa !5
  %29 = load double, ptr %5, align 8, !tbaa !5
  %30 = fadd double %28, %29
  %31 = load double, ptr %4, align 8, !tbaa !5
  %32 = fcmp oeq double %30, %31
  br i1 %32, label %33, label %35

33:                                               ; preds = %27
  %34 = load double, ptr %4, align 8, !tbaa !5
  store double %34, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %46

35:                                               ; preds = %27
  %36 = load double, ptr %5, align 8, !tbaa !5
  %37 = load double, ptr %4, align 8, !tbaa !5
  %38 = fdiv double %36, %37
  store double %38, ptr %6, align 8, !tbaa !5
  %39 = load double, ptr %4, align 8, !tbaa !5
  %40 = load double, ptr %6, align 8, !tbaa !5
  %41 = load double, ptr %6, align 8, !tbaa !5
  %42 = call double @llvm.fmuladd.f64(double %40, double %41, double 1.000000e+00)
  %43 = call double @sqrt(double noundef %42) #4
  %44 = fmul double %39, %43
  store double %44, ptr %6, align 8, !tbaa !5
  %45 = load double, ptr %6, align 8, !tbaa !5
  store double %45, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %46

46:                                               ; preds = %35, %33
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %47 = load double, ptr %3, align 8
  ret double %47
}

; 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 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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

attributes #0 = { 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 #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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !6, i64 0}
!6 = !{!"double", !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: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local double @f__cabs(double noundef %0, double noundef %1) local_unnamed_addr #0 {
  %3 = insertelement <2 x double> poison, double %0, i64 0
  %4 = insertelement <2 x double> %3, double %1, i64 1
  %5 = fcmp olt <2 x double> %4, zeroinitializer
  %6 = fneg <2 x double> %4
  %7 = select <2 x i1> %5, <2 x double> %6, <2 x double> %4
  %8 = extractelement <2 x double> %7, i64 0
  %9 = extractelement <2 x double> %7, i64 1
  %10 = fcmp ogt double %9, %8
  %.121 = select i1 %10, double %9, double %8
  %11 = fadd double %8, %9
  %12 = fcmp oeq double %11, %.121
  br i1 %12, label %17, label %13

13:                                               ; preds = %2
  %.1 = select i1 %10, double %8, double %9
  %14 = fdiv double %.1, %.121
  %15 = tail call double @llvm.fmuladd.f64(double %14, double %14, double 1.000000e+00)
  %sqrt = tail call double @llvm.sqrt.f64(double %15)
  %16 = fmul double %.121, %sqrt
  br label %17

17:                                               ; preds = %2, %13
  %.022 = phi double [ %16, %13 ], [ %.121, %2 ]
  ret double %.022
}

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

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

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) 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 #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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: AggressiveInstCombinePass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass