double hypot(x, y)
double x, y;
{
  extern double sqrt();
  if (x < 0)
    x = -x;
  if (y < 0)
    y = -y;
  if (x > y) {
    double t = y;
    y = x;
    x = t;
  }
  x /= y;
  return y * sqrt(x * x + 1.0);
}


x86 assembly (clang, -O0):
<hypot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1151 <hypot+0x41>
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1180 <hypot+0x70>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11ae <hypot+0x9e>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe1f(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hypot>:
sub    $0x18,%rsp
movapd 0xee4(%rip),%xmm2
movapd %xmm0,%xmm3
xorpd  %xmm2,%xmm3
xorpd  %xmm4,%xmm4
movapd %xmm0,%xmm5
cmpltsd %xmm4,%xmm5
andpd  %xmm5,%xmm3
andnpd %xmm0,%xmm5
orpd   %xmm3,%xmm5
xorpd  %xmm1,%xmm2
movapd %xmm1,%xmm0
cmpltsd %xmm4,%xmm0
andpd  %xmm0,%xmm2
andnpd %xmm1,%xmm0
orpd   %xmm2,%xmm0
movapd %xmm5,%xmm1
maxsd  %xmm0,%xmm1
minsd  %xmm5,%xmm0
divsd  %xmm1,%xmm0
mulsd  %xmm0,%xmm0
addsd  0xe9e(%rip),%xmm0
ucomisd %xmm4,%xmm0
jb     117e <hypot+0x6e>
sqrtsd %xmm0,%xmm0
jmp    118d <hypot+0x7d>
movapd %xmm1,(%rsp)
call   1030 <sqrt@plt>
movapd (%rsp),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @hypot(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double %0, double* %3
store double %1, double* %4
%6 = load double, double* %3
%7 = fcmp olt double %6, 0.000000e+00
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load double, double* %3
%10 = fneg double %9
store double %10, double* %3
br label %11
11: ; preds = %8, %2
%12 = load double, double* %4
%13 = fcmp olt double %12, 0.000000e+00
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load double, double* %4
%16 = fneg double %15
store double %16, double* %4
br label %17
17: ; preds = %14, %11
%18 = load double, double* %3
%19 = load double, double* %4
%20 = fcmp ogt double %18, %19
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = load double, double* %4
store double %22, double* %5
%23 = load double, double* %3
store double %23, double* %4
%24 = load double, double* %5
store double %24, double* %3
br label %25
25: ; preds = %21, %17
%26 = load double, double* %4
%27 = load double, double* %3
%28 = fdiv double %27, %26
store double %28, double* %3
%29 = load double, double* %4
%30 = load double, double* %3
%31 = load double, double* %3
%32 = call double @llvm.fmuladd.f64(double %30, double %31, double 1.000000e+00)
%33 = call double @sqrt(double %32)
%34 = fmul double %29, %33
ret double %34
}

LLVM IR (-O2):
define double @hypot(double %0, double %1) {
%3 = fcmp olt double %0, 0.000000e+00
%4 = fneg double %0
%5 = select i1 %3, double %4, double %0
%6 = fcmp olt double %1, 0.000000e+00
%7 = fneg double %1
%8 = select i1 %6, double %7, double %1
%9 = fcmp ogt double %5, %8
%10 = select i1 %9, double %5, double %8
%11 = select i1 %9, double %8, double %5
%12 = fdiv double %11, %10
%13 = tail call double @llvm.fmuladd.f64(double %12, double %12, double 1.000000e+00)
%14 = tail call double @sqrt(double %13)
%15 = fmul double %10, %14
ret double %15
}