#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 */
int /*<<< orphan*/ ERANGE;
long double INFINITY;
int LDBL_MAX_EXP;
int LDBL_MIN_EXP;
long double NAN;
int /*<<< orphan*/ errno;
long double fabsl(long double);
int /*<<< orphan*/ isfinite(long double);
scalar_t__ isinf(long double);
int logbl(long double);
long double scalbnl(long double, int);
long double sqrtl(long double);
long double hypotl(long double x, long double y) {
  int exx;
  int eyy;
  int scale;
  long double xx = fabsl(x);
  long double yy = fabsl(y);
  if (!isfinite(xx) || !isfinite(yy)) {
    return (isinf(xx) || isinf(yy)) ? INFINITY : NAN;
  }
  if (xx == 0.0L)
    return yy;
  if (yy == 0.0L)
    return xx;
  exx = logbl(xx);
  eyy = logbl(yy);
  scale = exx - eyy;
  if (scale > 32)
    return xx;
  if (scale < -32)
    return yy;
  scale = (exx + eyy) >> 1;
  x = scalbnl(xx, -scale);
  y = scalbnl(yy, -scale);
  xx = sqrtl(x * x + y * y);
  exx = logbl(xx);
  exx += scale;
  if (exx > LDBL_MAX_EXP) {
    errno = ERANGE;
    return INFINITY;
  }
  if (exx < LDBL_MIN_EXP)
    return 0.0L;
  return (scalbnl(xx, scale));
}


x86 assembly (clang, -O0):
<hypotl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
fldt   0x20(%rbp)
fldt   0x10(%rbp)
fstpt  -0x20(%rbp)
fstpt  -0x30(%rbp)
fldt   -0x20(%rbp)
fabs
fstpt  -0x50(%rbp)
fldt   -0x30(%rbp)
fabs
fstpt  -0x60(%rbp)
fldt   -0x50(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1040 <isfinite@plt>
cmp    $0x0,%eax
je     11a3 <hypotl+0x53>
fldt   -0x60(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1040 <isfinite@plt>
cmp    $0x0,%eax
jne    11f9 <hypotl+0xa9>
fldt   -0x50(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1070 <isinf@plt>
cmp    $0x0,%rax
jne    11d1 <hypotl+0x81>
fldt   -0x60(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1070 <isinf@plt>
cmp    $0x0,%rax
je     11e2 <hypotl+0x92>
mov    0x2e08(%rip),%rax
fldt   (%rax)
fstpt  -0x6c(%rbp)
jmp    11ee <hypotl+0x9e>
mov    0x2e0f(%rip),%rax
fldt   (%rax)
fstpt  -0x6c(%rbp)
fldt   -0x6c(%rbp)
fstpt  -0x10(%rbp)
jmp    1369 <hypotl+0x219>
fldt   -0x50(%rbp)
fldz
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jne    1220 <hypotl+0xd0>
jp     1220 <hypotl+0xd0>
jmp    1215 <hypotl+0xc5>
fldt   -0x60(%rbp)
fstpt  -0x10(%rbp)
jmp    1369 <hypotl+0x219>
fldt   -0x60(%rbp)
fldz
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jne    1247 <hypotl+0xf7>
jp     1247 <hypotl+0xf7>
jmp    123c <hypotl+0xec>
fldt   -0x50(%rbp)
fstpt  -0x10(%rbp)
jmp    1369 <hypotl+0x219>
fldt   -0x50(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1030 <logbl@plt>
mov    %eax,-0x34(%rbp)
fldt   -0x60(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1030 <logbl@plt>
mov    %eax,-0x38(%rbp)
mov    -0x34(%rbp),%eax
sub    -0x38(%rbp),%eax
mov    %eax,-0x3c(%rbp)
cmpl   $0x20,-0x3c(%rbp)
jle    1285 <hypotl+0x135>
fldt   -0x50(%rbp)
fstpt  -0x10(%rbp)
jmp    1369 <hypotl+0x219>
cmpl   $0xffffffe0,-0x3c(%rbp)
jge    129a <hypotl+0x14a>
fldt   -0x60(%rbp)
fstpt  -0x10(%rbp)
jmp    1369 <hypotl+0x219>
mov    -0x34(%rbp),%eax
mov    -0x38(%rbp),%ecx
add    %ecx,%eax
sar    %eax
mov    %eax,-0x3c(%rbp)
fldt   -0x50(%rbp)
mov    -0x3c(%rbp),%edi
neg    %edi
mov    %rsp,%rax
fstpt  (%rax)
call   1060 <scalbnl@plt>
fstpt  -0x20(%rbp)
fldt   -0x60(%rbp)
mov    -0x3c(%rbp),%edi
neg    %edi
mov    %rsp,%rax
fstpt  (%rax)
call   1060 <scalbnl@plt>
fstpt  -0x30(%rbp)
fldt   -0x20(%rbp)
fldt   -0x30(%rbp)
fmul   %st,%st(0)
fxch   %st(1)
fmul   %st,%st(0)
faddp  %st,%st(1)
mov    %rsp,%rax
fstpt  (%rax)
call   1050 <sqrtl@plt>
fstpt  -0x50(%rbp)
fldt   -0x50(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1030 <logbl@plt>
mov    %eax,-0x34(%rbp)
mov    -0x3c(%rbp),%eax
add    -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    0x2cb9(%rip),%rcx
cmp    (%rcx),%eax
jle    133a <hypotl+0x1ea>
mov    0x2cba(%rip),%rax
mov    (%rax),%ecx
mov    0x2c99(%rip),%rax
mov    %ecx,(%rax)
mov    0x2cb0(%rip),%rax
fldt   (%rax)
fstpt  -0x10(%rbp)
jmp    1369 <hypotl+0x219>
mov    -0x34(%rbp),%eax
mov    0x2c74(%rip),%rcx
cmp    (%rcx),%eax
jge    1356 <hypotl+0x206>
fldz
fstpt  -0x10(%rbp)
jmp    1369 <hypotl+0x219>
fldt   -0x50(%rbp)
mov    -0x3c(%rbp),%edi
mov    %rsp,%rax
fstpt  (%rax)
call   1060 <scalbnl@plt>
fstpt  -0x10(%rbp)
fldt   -0x10(%rbp)
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hypotl>:
push   %rbp
push   %rbx
sub    $0x48,%rsp
fldt   0x70(%rsp)
fldt   0x60(%rsp)
fld    %st(0)
fstpt  0x30(%rsp)
fabs
fld    %st(1)
fstpt  0x3c(%rsp)
fxch   %st(1)
fabs
fstpt  0x18(%rsp)
fld    %st(0)
fstpt  0x24(%rsp)
fstpt  (%rsp)
call   1040 <isfinite@plt>
test   %eax,%eax
je     11b3 <hypotl+0x63>
fldt   0x18(%rsp)
fstpt  (%rsp)
call   1040 <isfinite@plt>
test   %eax,%eax
je     11b3 <hypotl+0x63>
fldt   0x18(%rsp)
fstp   %st(0)
fldz
fldt   0x30(%rsp)
fucomip %st(1),%st
jne    11ef <hypotl+0x9f>
jp     11ef <hypotl+0x9f>
fstp   %st(0)
fldt   0x18(%rsp)
jmp    12ae <hypotl+0x15e>
fldt   0x18(%rsp)
fstp   %st(0)
fldt   0x24(%rsp)
fstpt  (%rsp)
call   1070 <isinf@plt>
test   %rax,%rax
jne    12a5 <hypotl+0x155>
fldt   0x18(%rsp)
fstpt  (%rsp)
call   1070 <isinf@plt>
test   %rax,%rax
jne    12a5 <hypotl+0x155>
mov    0x2e0e(%rip),%rax
jmp    12ac <hypotl+0x15c>
fldt   0x3c(%rsp)
fucomip %st(1),%st
jne    1204 <hypotl+0xb4>
jp     1204 <hypotl+0xb4>
fstp   %st(0)
fldt   0x24(%rsp)
jmp    12ae <hypotl+0x15e>
fstpt  0x30(%rsp)
fldt   0x24(%rsp)
fstpt  (%rsp)
call   1030 <logbl@plt>
mov    %eax,%ebp
fldt   0x18(%rsp)
fstpt  (%rsp)
call   1030 <logbl@plt>
mov    %eax,%ebx
mov    %ebp,%eax
sub    %ebx,%eax
cmp    $0x20,%eax
jle    1233 <hypotl+0xe3>
fldt   0x24(%rsp)
jmp    12ae <hypotl+0x15e>
cmp    $0xffffffe0,%eax
jge    123e <hypotl+0xee>
fldt   0x18(%rsp)
jmp    12ae <hypotl+0x15e>
add    %ebp,%ebx
sar    %ebx
mov    %ebx,%ebp
neg    %ebp
fldt   0x24(%rsp)
fstpt  (%rsp)
mov    %ebp,%edi
call   1060 <scalbnl@plt>
fstpt  0x24(%rsp)
fldt   0x18(%rsp)
fstpt  (%rsp)
mov    %ebp,%edi
call   1060 <scalbnl@plt>
fmul   %st,%st(0)
fldt   0x24(%rsp)
fmul   %st,%st(0)
faddp  %st,%st(1)
fstpt  (%rsp)
call   1050 <sqrtl@plt>
fld    %st(0)
fstpt  0x18(%rsp)
fstpt  (%rsp)
call   1030 <logbl@plt>
add    %ebx,%eax
mov    0x2d39(%rip),%rcx
cmp    (%rcx),%eax
jle    12b5 <hypotl+0x165>
mov    0x2d3e(%rip),%rax
mov    (%rax),%eax
mov    0x2d1d(%rip),%rcx
mov    %eax,(%rcx)
mov    0x2d34(%rip),%rax
fldt   (%rax)
add    $0x48,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2cfc(%rip),%rcx
cmp    (%rcx),%eax
fldt   0x30(%rsp)
jl     12ae <hypotl+0x15e>
fstp   %st(0)
fldt   0x18(%rsp)
fstpt  (%rsp)
mov    %ebx,%edi
call   1060 <scalbnl@plt>
jmp    12ae <hypotl+0x15e>

LLVM IR (-O0):
@INFINITY = global x86_fp80 0xK00000000000000000000
@NAN = global x86_fp80 0xK00000000000000000000
@LDBL_MAX_EXP = global i32 0
@ERANGE = global i32 0
@errno = global i32 0
@LDBL_MIN_EXP = global i32 0
define x86_fp80 @hypotl(x86_fp80 %0, x86_fp80 %1) {
%3 = alloca x86_fp80
%4 = alloca x86_fp80
%5 = alloca x86_fp80
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca x86_fp80
%10 = alloca x86_fp80
store x86_fp80 %0, x86_fp80* %4
store x86_fp80 %1, x86_fp80* %5
%11 = load x86_fp80, x86_fp80* %4
%12 = call x86_fp80 @llvm.fabs.f80(x86_fp80 %11)
store x86_fp80 %12, x86_fp80* %9
%13 = load x86_fp80, x86_fp80* %5
%14 = call x86_fp80 @llvm.fabs.f80(x86_fp80 %13)
store x86_fp80 %14, x86_fp80* %10
%15 = load x86_fp80, x86_fp80* %9
%16 = call i32 @isfinite(x86_fp80 %15)
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %2
%19 = load x86_fp80, x86_fp80* %10
%20 = call i32 @isfinite(x86_fp80 %19)
%21 = icmp ne i32 %20, 0
br i1 %21, label %36, label %22
22: ; preds = %18, %2
%23 = load x86_fp80, x86_fp80* %9
%24 = call i64 @isinf(x86_fp80 %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %30, label %26
26: ; preds = %22
%27 = load x86_fp80, x86_fp80* %10
%28 = call i64 @isinf(x86_fp80 %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %26, %22
%31 = load x86_fp80, x86_fp80* @INFINITY
br label %34
32: ; preds = %26
%33 = load x86_fp80, x86_fp80* @NAN
br label %34
34: ; preds = %32, %30
%35 = phi x86_fp80 [ %31, %30 ], [ %33, %32 ]
store x86_fp80 %35, x86_fp80* %3
br label %103
36: ; preds = %18
%37 = load x86_fp80, x86_fp80* %9
%38 = fcmp oeq x86_fp80 %37, 0xK00000000000000000000
br i1 %38, label %39, label %41
39: ; preds = %36
%40 = load x86_fp80, x86_fp80* %10
store x86_fp80 %40, x86_fp80* %3
br label %103
41: ; preds = %36
%42 = load x86_fp80, x86_fp80* %10
%43 = fcmp oeq x86_fp80 %42, 0xK00000000000000000000
br i1 %43, label %44, label %46
44: ; preds = %41
%45 = load x86_fp80, x86_fp80* %9
store x86_fp80 %45, x86_fp80* %3
br label %103
46: ; preds = %41
%47 = load x86_fp80, x86_fp80* %9
%48 = call i32 @logbl(x86_fp80 %47)
store i32 %48, i32* %6
%49 = load x86_fp80, x86_fp80* %10
%50 = call i32 @logbl(x86_fp80 %49)
store i32 %50, i32* %7
%51 = load i32, i32* %6
%52 = load i32, i32* %7
%53 = sub nsw i32 %51, %52
store i32 %53, i32* %8
%54 = load i32, i32* %8
%55 = icmp sgt i32 %54, 32
br i1 %55, label %56, label %58
56: ; preds = %46
%57 = load x86_fp80, x86_fp80* %9
store x86_fp80 %57, x86_fp80* %3
br label %103
58: ; preds = %46
%59 = load i32, i32* %8
%60 = icmp slt i32 %59, -32
br i1 %60, label %61, label %63
61: ; preds = %58
%62 = load x86_fp80, x86_fp80* %10
store x86_fp80 %62, x86_fp80* %3
br label %103
63: ; preds = %58
%64 = load i32, i32* %6
%65 = load i32, i32* %7
%66 = add nsw i32 %64, %65
%67 = ashr i32 %66, 1
store i32 %67, i32* %8
%68 = load x86_fp80, x86_fp80* %9
%69 = load i32, i32* %8
%70 = sub nsw i32 0, %69
%71 = call x86_fp80 @scalbnl(x86_fp80 %68, i32 %70)
store x86_fp80 %71, x86_fp80* %4
%72 = load x86_fp80, x86_fp80* %10
%73 = load i32, i32* %8
%74 = sub nsw i32 0, %73
%75 = call x86_fp80 @scalbnl(x86_fp80 %72, i32 %74)
store x86_fp80 %75, x86_fp80* %5
%76 = load x86_fp80, x86_fp80* %4
%77 = load x86_fp80, x86_fp80* %4
%78 = load x86_fp80, x86_fp80* %5
%79 = load x86_fp80, x86_fp80* %5
%80 = fmul x86_fp80 %78, %79
%81 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %76, x86_fp80 %77, x86_fp80 %80)
%82 = call x86_fp80 @sqrtl(x86_fp80 %81)
store x86_fp80 %82, x86_fp80* %9
%83 = load x86_fp80, x86_fp80* %9
%84 = call i32 @logbl(x86_fp80 %83)
store i32 %84, i32* %6
%85 = load i32, i32* %8
%86 = load i32, i32* %6
%87 = add nsw i32 %86, %85
store i32 %87, i32* %6
%88 = load i32, i32* %6
%89 = load i32, i32* @LDBL_MAX_EXP
%90 = icmp sgt i32 %88, %89
br i1 %90, label %91, label %94
91: ; preds = %63
%92 = load i32, i32* @ERANGE
store i32 %92, i32* @errno
%93 = load x86_fp80, x86_fp80* @INFINITY
store x86_fp80 %93, x86_fp80* %3
br label %103
94: ; preds = %63
%95 = load i32, i32* %6
%96 = load i32, i32* @LDBL_MIN_EXP
%97 = icmp slt i32 %95, %96
br i1 %97, label %98, label %99
98: ; preds = %94
store x86_fp80 0xK00000000000000000000, x86_fp80* %3
br label %103
99: ; preds = %94
%100 = load x86_fp80, x86_fp80* %9
%101 = load i32, i32* %8
%102 = call x86_fp80 @scalbnl(x86_fp80 %100, i32 %101)
store x86_fp80 %102, x86_fp80* %3
br label %103
103: ; preds = %99, %98, %91, %61, %56, %44, %39, %34
%104 = load x86_fp80, x86_fp80* %3
ret x86_fp80 %104
}

LLVM IR (-O2):
@INFINITY = global x86_fp80 0xK00000000000000000000
@NAN = global x86_fp80 0xK00000000000000000000
@LDBL_MAX_EXP = global i32 0
@ERANGE = global i32 0
@errno = global i32 0
@LDBL_MIN_EXP = global i32 0
define x86_fp80 @hypotl(x86_fp80 %0, x86_fp80 %1) {
%3 = tail call x86_fp80 @llvm.fabs.f80(x86_fp80 %0)
%4 = tail call x86_fp80 @llvm.fabs.f80(x86_fp80 %1)
%5 = tail call i32 @isfinite(x86_fp80 %3)
%6 = icmp eq i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = tail call i32 @isfinite(x86_fp80 %4)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %20
10: ; preds = %7, %2
%11 = tail call i64 @isinf(x86_fp80 %3)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = tail call i64 @isinf(x86_fp80 %4)
%15 = icmp eq i64 %14, 0
%16 = select i1 %15, x86_fp80* @NAN, x86_fp80* @INFINITY
br label %17
17: ; preds = %13, %10
%18 = phi x86_fp80* [ @INFINITY, %10 ], [ %16, %13 ]
%19 = load x86_fp80, x86_fp80* %18
br label %52
20: ; preds = %7
%21 = fcmp oeq x86_fp80 %0, 0xK00000000000000000000
br i1 %21, label %52, label %22
22: ; preds = %20
%23 = fcmp oeq x86_fp80 %1, 0xK00000000000000000000
br i1 %23, label %52, label %24
24: ; preds = %22
%25 = tail call i32 @logbl(x86_fp80 %3)
%26 = tail call i32 @logbl(x86_fp80 %4)
%27 = sub nsw i32 %25, %26
%28 = icmp sgt i32 %27, 32
br i1 %28, label %52, label %29
29: ; preds = %24
%30 = icmp slt i32 %27, -32
br i1 %30, label %52, label %31
31: ; preds = %29
%32 = add nsw i32 %26, %25
%33 = ashr i32 %32, 1
%34 = sub nsw i32 0, %33
%35 = tail call x86_fp80 @scalbnl(x86_fp80 %3, i32 %34)
%36 = tail call x86_fp80 @scalbnl(x86_fp80 %4, i32 %34)
%37 = fmul x86_fp80 %36, %36
%38 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %35, x86_fp80 %35, x86_fp80 %37)
%39 = tail call x86_fp80 @sqrtl(x86_fp80 %38)
%40 = tail call i32 @logbl(x86_fp80 %39)
%41 = add nsw i32 %40, %33
%42 = load i32, i32* @LDBL_MAX_EXP
%43 = icmp sgt i32 %41, %42
br i1 %43, label %44, label %47
44: ; preds = %31
%45 = load i32, i32* @ERANGE
store i32 %45, i32* @errno
%46 = load x86_fp80, x86_fp80* @INFINITY
br label %52
47: ; preds = %31
%48 = load i32, i32* @LDBL_MIN_EXP
%49 = icmp slt i32 %41, %48
br i1 %49, label %52, label %50
50: ; preds = %47
%51 = tail call x86_fp80 @scalbnl(x86_fp80 %39, i32 %33)
br label %52
52: ; preds = %47, %29, %24, %22, %20, %50, %44, %17
%53 = phi x86_fp80 [ %46, %44 ], [ %51, %50 ], [ %19, %17 ], [ %4, %20 ], [ %3, %22 ], [ %3, %24 ], [ %4, %29 ], [ 0xK00000000000000000000, %47 ]
ret x86_fp80 %53
}