#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(int);
double hypot(double a, double b) {
  double t;
  if (a < 0)
    a = -a;
  if (b < 0)
    b = -b;
  if (a > b) {
    t = a;
    a = b;
    b = t;
  }
  if (b == 0)
    return 0;
  a /= b;
  return b * sqrt(1 + a * a);
}


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),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11ae <hypot+0x9e>
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    11d3 <hypot+0xc3>
jp     11d3 <hypot+0xc3>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1224 <hypot+0x114>
movsd  -0x18(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdfa(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
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  %xmm0,%xmm0
movapd %xmm2,%xmm3
cmpltsd %xmm0,%xmm3
andpd  %xmm3,%xmm5
andnpd %xmm2,%xmm3
orpd   %xmm5,%xmm3
xorpd  %xmm1,%xmm4
movapd %xmm1,%xmm2
cmpltsd %xmm0,%xmm2
andpd  %xmm2,%xmm4
andnpd %xmm1,%xmm2
orpd   %xmm4,%xmm2
movapd %xmm3,%xmm1
maxsd  %xmm2,%xmm1
ucomisd %xmm0,%xmm1
jne    116f <hypot+0x5f>
jp     116f <hypot+0x5f>
add    $0x18,%rsp
ret
minsd  %xmm3,%xmm2
divsd  %xmm1,%xmm2
mulsd  %xmm2,%xmm2
addsd  0xe8d(%rip),%xmm2
cvttsd2si %xmm2,%edi
movapd %xmm1,(%rsp)
call   1030 <sqrt@plt>
mulsd  (%rsp),%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 ogt 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 %30
29: ; preds = %26
store double 0.000000e+00, double* %3
br label %41
30: ; preds = %26
%31 = load double, double* %5
%32 = load double, double* %4
%33 = fdiv double %32, %31
store double %33, double* %4
%34 = load double, double* %5
%35 = load double, double* %4
%36 = load double, double* %4
%37 = call double @llvm.fmuladd.f64(double %35, double %36, double 1.000000e+00)
%38 = fptosi double %37 to i32
%39 = call double @sqrt(i32 %38)
%40 = fmul double %34, %39
store double %40, double* %3
br label %41
41: ; preds = %30, %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 ogt double %5, %8
%10 = select i1 %9, double %5, double %8
%11 = fcmp oeq double %10, 0.000000e+00
br i1 %11, label %19, label %12
12: ; preds = %2
%13 = select i1 %9, double %8, double %5
%14 = fdiv double %13, %10
%15 = tail call double @llvm.fmuladd.f64(double %14, double %14, double 1.000000e+00)
%16 = fptosi double %15 to i32
%17 = tail call double @sqrt(i32 %16)
%18 = fmul double %10, %17
br label %19
19: ; preds = %2, %12
%20 = phi double [ %18, %12 ], [ 0.000000e+00, %2 ]
ret double %20
}