#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
double sqrt(double);
double hypot(double x, double y) {
  if (x < 0)
    x = -x;
  if (y < 0)
    y = -y;
  if (x < y) {
    double tmp = x;
    x = y;
    y = tmp;
  }
  if (y == 0.0)
    return x;
  y /= x;
  return x * sqrt(1.0 + y * y);
}


x86 assembly (clang, -O0):
<hypot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1151 <hypot+0x41>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1180 <hypot+0x70>
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11b2 <hypot+0xa2>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11d9 <hypot+0xc9>
jp     11d9 <hypot+0xc9>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1226 <hypot+0x116>
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdf4(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hypot>:
sub    $0x18,%rsp
movapd %xmm0,%xmm2
movapd 0xee0(%rip),%xmm4
movapd %xmm0,%xmm5
xorpd  %xmm4,%xmm5
xorpd  %xmm3,%xmm3
cmpltsd %xmm3,%xmm0
andpd  %xmm0,%xmm5
andnpd %xmm2,%xmm0
orpd   %xmm5,%xmm0
xorpd  %xmm1,%xmm4
movapd %xmm1,%xmm2
cmpltsd %xmm3,%xmm2
andpd  %xmm2,%xmm4
andnpd %xmm1,%xmm2
orpd   %xmm4,%xmm2
movapd %xmm2,%xmm1
maxsd  %xmm0,%xmm1
minsd  %xmm2,%xmm0
ucomisd %xmm3,%xmm0
jne    116a <hypot+0x5a>
jnp    1199 <hypot+0x89>
divsd  %xmm1,%xmm0
mulsd  %xmm0,%xmm0
addsd  0xe96(%rip),%xmm0
ucomisd %xmm3,%xmm0
jb     1186 <hypot+0x76>
sqrtsd %xmm0,%xmm0
jmp    1195 <hypot+0x85>
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
%6 = alloca double
store double %0, double* %4
store double %1, double* %5
%7 = load double, double* %4
%8 = fcmp olt double %7, 0.000000e+00
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load double, double* %4
%11 = fneg double %10
store double %11, double* %4
br label %12
12: ; preds = %9, %2
%13 = load double, double* %5
%14 = fcmp olt double %13, 0.000000e+00
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load double, double* %5
%17 = fneg double %16
store double %17, double* %5
br label %18
18: ; preds = %15, %12
%19 = load double, double* %4
%20 = load double, double* %5
%21 = fcmp olt double %19, %20
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = load double, double* %4
store double %23, double* %6
%24 = load double, double* %5
store double %24, double* %4
%25 = load double, double* %6
store double %25, double* %5
br label %26
26: ; preds = %22, %18
%27 = load double, double* %5
%28 = fcmp oeq double %27, 0.000000e+00
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = load double, double* %4
store double %30, double* %3
br label %41
31: ; preds = %26
%32 = load double, double* %4
%33 = load double, double* %5
%34 = fdiv double %33, %32
store double %34, double* %5
%35 = load double, double* %4
%36 = load double, double* %5
%37 = load double, double* %5
%38 = call double @llvm.fmuladd.f64(double %36, double %37, double 1.000000e+00)
%39 = call double @sqrt(double %38)
%40 = fmul double %35, %39
store double %40, double* %3
br label %41
41: ; preds = %31, %29
%42 = load double, double* %3
ret double %42
}

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 olt double %5, %8
%10 = select i1 %9, double %8, double %5
%11 = select i1 %9, double %5, double %8
%12 = fcmp oeq double %11, 0.000000e+00
br i1 %12, label %18, label %13
13: ; preds = %2
%14 = fdiv double %11, %10
%15 = tail call double @llvm.fmuladd.f64(double %14, double %14, double 1.000000e+00)
%16 = tail call double @sqrt(double %15)
%17 = fmul double %10, %16
br label %18
18: ; preds = %2, %13
%19 = phi double [ %17, %13 ], [ %10, %2 ]
ret double %19
}