#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 x, double y) {
  if (x < 0.)
    x = -x;
  else if (x == 0.)
    return (y < 0. ? -y : y);
  if (y < 0.)
    y = -y;
  else if (y == 0.)
    return (x);
  if (x < y) {
    x /= y;
    return (y * sqrt(1. + x * x));
  } else {
    y /= x;
    return (x * sqrt(1. + 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    1156 <hypot+0x46>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    11c0 <hypot+0xb0>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11bb <hypot+0xab>
jp     11bb <hypot+0xab>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11a2 <hypot+0x92>
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11ac <hypot+0x9c>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12db <hypot+0x1cb>
jmp    11c0 <hypot+0xb0>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11f4 <hypot+0xe4>
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1220 <hypot+0x110>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    121b <hypot+0x10b>
jp     121b <hypot+0x10b>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12db <hypot+0x1cb>
jmp    1220 <hypot+0x110>
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    128a <hypot+0x17a>
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  0xd99(%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)
jmp    12db <hypot+0x1cb>
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd43(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%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
xorpd  %xmm0,%xmm0
ucomisd %xmm2,%xmm0
jbe    112c <hypot+0x1c>
xorpd  0xed6(%rip),%xmm2
jmp    115b <hypot+0x4b>
ucomisd %xmm0,%xmm2
jne    115b <hypot+0x4b>
jp     115b <hypot+0x4b>
movapd 0xec4(%rip),%xmm0
xorpd  %xmm1,%xmm0
xorpd  %xmm3,%xmm3
movapd %xmm1,%xmm2
cmpltsd %xmm3,%xmm2
andpd  %xmm2,%xmm0
andnpd %xmm1,%xmm2
orpd   %xmm0,%xmm2
jmp    11cd <hypot+0xbd>
xorpd  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    116f <hypot+0x5f>
xorpd  0xe93(%rip),%xmm1
jmp    1177 <hypot+0x67>
ucomisd %xmm0,%xmm1
jne    1177 <hypot+0x67>
jnp    11cd <hypot+0xbd>
ucomisd %xmm2,%xmm1
jbe    11a6 <hypot+0x96>
divsd  %xmm1,%xmm2
mulsd  %xmm2,%xmm2
addsd  0xe83(%rip),%xmm2
cvttsd2si %xmm2,%edi
movapd %xmm1,(%rsp)
call   1030 <sqrt@plt>
movapd %xmm0,%xmm2
mulsd  (%rsp),%xmm2
jmp    11cd <hypot+0xbd>
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm1
addsd  0xe5a(%rip),%xmm1
cvttsd2si %xmm1,%edi
movapd %xmm2,(%rsp)
call   1030 <sqrt@plt>
movapd (%rsp),%xmm2
mulsd  %xmm0,%xmm2
movapd %xmm2,%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* %4
store double %1, double* %5
%6 = load double, double* %4
%7 = fcmp olt double %6, 0.000000e+00
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load double, double* %4
%10 = fneg double %9
store double %10, double* %4
br label %25
11: ; preds = %2
%12 = load double, double* %4
%13 = fcmp oeq double %12, 0.000000e+00
br i1 %13, label %14, label %24
14: ; preds = %11
%15 = load double, double* %5
%16 = fcmp olt double %15, 0.000000e+00
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load double, double* %5
%19 = fneg double %18
br label %22
20: ; preds = %14
%21 = load double, double* %5
br label %22
22: ; preds = %20, %17
%23 = phi double [ %19, %17 ], [ %21, %20 ]
store double %23, double* %3
br label %63
24: ; preds = %11
br label %25
25: ; preds = %24, %8
%26 = load double, double* %5
%27 = fcmp olt double %26, 0.000000e+00
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = load double, double* %5
%30 = fneg double %29
store double %30, double* %5
br label %37
31: ; preds = %25
%32 = load double, double* %5
%33 = fcmp oeq double %32, 0.000000e+00
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = load double, double* %4
store double %35, double* %3
br label %63
36: ; preds = %31
br label %37
37: ; preds = %36, %28
%38 = load double, double* %4
%39 = load double, double* %5
%40 = fcmp olt double %38, %39
br i1 %40, label %41, label %52
41: ; preds = %37
%42 = load double, double* %5
%43 = load double, double* %4
%44 = fdiv double %43, %42
store double %44, double* %4
%45 = load double, double* %5
%46 = load double, double* %4
%47 = load double, double* %4
%48 = call double @llvm.fmuladd.f64(double %46, double %47, double 1.000000e+00)
%49 = fptosi double %48 to i32
%50 = call double @sqrt(i32 %49)
%51 = fmul double %45, %50
store double %51, double* %3
br label %63
52: ; preds = %37
%53 = load double, double* %4
%54 = load double, double* %5
%55 = fdiv double %54, %53
store double %55, double* %5
%56 = load double, double* %4
%57 = load double, double* %5
%58 = load double, double* %5
%59 = call double @llvm.fmuladd.f64(double %57, double %58, double 1.000000e+00)
%60 = fptosi double %59 to i32
%61 = call double @sqrt(i32 %60)
%62 = fmul double %56, %61
store double %62, double* %3
br label %63
63: ; preds = %52, %41, %34, %22
%64 = load double, double* %3
ret double %64
}

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