#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 fabs(double);
double sqrt(double);
double rt_hypotd(double u0, double u1) {
  double y;
  double a;
  double b;
  a = fabs(u0);
  b = fabs(u1);
  if (a < b) {
    a /= b;
    y = b * sqrt(a * a + 1.0);
  } else if (a > b) {
    b /= a;
    y = a * sqrt(b * b + 1.0);
  } else
    y = a * sqrt(2.0);
  return y;
}


x86 assembly (clang, -O0):
<rt_hypotd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
movaps 0xed2(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movaps 0xebd(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11b2 <rt_hypotd+0xa2>
movsd  -0x28(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe85(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1241 <rt_hypotd+0x131>
movsd  -0x20(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    1214 <rt_hypotd+0x104>
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe23(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    123c <rt_hypotd+0x12c>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xdea(%rip),%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1241 <rt_hypotd+0x131>
movsd  -0x18(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rt_hypotd>:
sub    $0x18,%rsp
movapd %xmm0,%xmm2
movapd 0xee0(%rip),%xmm0
andpd  %xmm0,%xmm2
andpd  %xmm0,%xmm1
ucomisd %xmm2,%xmm1
jbe    1151 <rt_hypotd+0x41>
divsd  %xmm1,%xmm2
mulsd  %xmm2,%xmm2
addsd  0xeda(%rip),%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
jb     117a <rt_hypotd+0x6a>
xorps  %xmm0,%xmm0
sqrtsd %xmm2,%xmm0
jmp    118d <rt_hypotd+0x7d>
ucomisd %xmm1,%xmm2
jbe    1196 <rt_hypotd+0x86>
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm1
addsd  0xeb1(%rip),%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jb     11a0 <rt_hypotd+0x90>
xorps  %xmm0,%xmm0
sqrtsd %xmm1,%xmm0
jmp    11b3 <rt_hypotd+0xa3>
movapd %xmm2,%xmm0
movapd %xmm1,(%rsp)
call   1030 <sqrt@plt>
movapd (%rsp),%xmm1
mulsd  %xmm1,%xmm0
add    $0x18,%rsp
ret
movsd  0xe72(%rip),%xmm0
jmp    11b3 <rt_hypotd+0xa3>
movapd %xmm1,%xmm0
movapd %xmm2,(%rsp)
call   1030 <sqrt@plt>
movapd (%rsp),%xmm2
mulsd  %xmm2,%xmm0
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
define double @rt_hypotd(double %0, double %1) {
%3 = tail call double @llvm.fabs.f64(double %0)
%4 = tail call double @llvm.fabs.f64(double %1)
%5 = fcmp olt double %3, %4
br i1 %5, label %6, label %11
6: ; preds = %2
%7 = fdiv double %3, %4
%8 = tail call double @llvm.fmuladd.f64(double %7, double %7, double 1.000000e+00)
%9 = tail call double @sqrt(double %8)
%10 = fmul double %4, %9
br label %20
11: ; preds = %2
%12 = fcmp ogt double %3, %4
br i1 %12, label %13, label %18
13: ; preds = %11
%14 = fdiv double %4, %3
%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 %3, %16
br label %20
18: ; preds = %11
%19 = fmul double %3, 0x3FF6A09E667F3BCD
br label %20
20: ; preds = %13, %18, %6
%21 = phi double [ %10, %6 ], [ %17, %13 ], [ %19, %18 ]
ret double %21
}