#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);
int /*<<< orphan*/ rtIsInf(double);
scalar_t__ rtIsNaN(double);
double sqrt(double);
double xdlapy3(double x1, double x2, double x3) {
  double y;
  double a;
  double b;
  double c;
  a = fabs(x1);
  b = fabs(x2);
  c = fabs(x3);
  if ((a > b) || rtIsNaN(b)) {
    y = a;
  } else {
    y = b;
  }
  if (c > y) {
    y = c;
  }
  if ((y > 0.0) && (!rtIsInf(y))) {
    a /= y;
    b /= y;
    c /= y;
    y *= sqrt((a * a + c * c) + b * b);
  } else {
    y = (a + b) + c;
  }
  return y;
}


x86 assembly (clang, -O0):
<xdlapy3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
movaps 0xead(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movaps 0xe98(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
movaps 0xe83(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
ucomisd -0x30(%rbp),%xmm0
ja     11aa <xdlapy3+0x7a>
movsd  -0x30(%rbp),%xmm0
call   1030 <rtIsNaN@plt>
cmp    $0x0,%rax
je     11b9 <xdlapy3+0x89>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11c3 <xdlapy3+0x93>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x38(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    11dd <xdlapy3+0xad>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    127d <xdlapy3+0x14d>
movsd  -0x20(%rbp),%xmm0
call   1050 <rtIsInf@plt>
cmp    $0x0,%eax
jne    127d <xdlapy3+0x14d>
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1291 <xdlapy3+0x161>
movsd  -0x28(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xdlapy3>:
sub    $0x48,%rsp
movapd %xmm0,%xmm3
movapd 0xec0(%rip),%xmm0
andpd  %xmm0,%xmm3
andpd  %xmm0,%xmm1
andpd  %xmm0,%xmm2
ucomisd %xmm1,%xmm3
movapd %xmm1,0x30(%rsp)
movapd %xmm3,0x20(%rsp)
movapd %xmm2,0x10(%rsp)
jbe    116a <xdlapy3+0x3a>
movapd %xmm3,%xmm4
jmp    1192 <xdlapy3+0x62>
movapd %xmm1,%xmm0
call   1030 <rtIsNaN@plt>
movapd 0x20(%rsp),%xmm3
movapd 0x30(%rsp),%xmm1
movapd %xmm1,%xmm4
test   %rax,%rax
je     118c <xdlapy3+0x5c>
movapd %xmm3,%xmm4
movapd 0x10(%rsp),%xmm2
movapd %xmm2,%xmm0
maxsd  %xmm4,%xmm0
xorpd  %xmm4,%xmm4
ucomisd %xmm4,%xmm0
jbe    11cb <xdlapy3+0x9b>
movsd  %xmm0,0x8(%rsp)
call   1050 <rtIsInf@plt>
movsd  0x8(%rsp),%xmm4
movapd 0x10(%rsp),%xmm2
movapd 0x20(%rsp),%xmm3
movapd 0x30(%rsp),%xmm1
test   %eax,%eax
je     11e0 <xdlapy3+0xb0>
addsd  %xmm1,%xmm3
addsd  %xmm2,%xmm3
movapd %xmm3,%xmm4
movapd %xmm4,%xmm0
add    $0x48,%rsp
ret
divsd  %xmm4,%xmm3
divsd  %xmm4,%xmm1
divsd  %xmm4,%xmm2
mulsd  %xmm2,%xmm2
mulsd  %xmm3,%xmm3
addsd  %xmm2,%xmm3
mulsd  %xmm1,%xmm1
addsd  %xmm3,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jb     1217 <xdlapy3+0xe7>
xorps  %xmm0,%xmm0
sqrtsd %xmm1,%xmm0
mulsd  %xmm0,%xmm4
jmp    11d7 <xdlapy3+0xa7>
movapd %xmm1,%xmm0
call   1040 <sqrt@plt>
movsd  0x8(%rsp),%xmm4
mulsd  %xmm0,%xmm4
jmp    11d7 <xdlapy3+0xa7>

LLVM IR (-O0):
define double @xdlapy3(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
%11 = load double, double* %4
%12 = call double @llvm.fabs.f64(double %11)
store double %12, double* %8
%13 = load double, double* %5
%14 = call double @llvm.fabs.f64(double %13)
store double %14, double* %9
%15 = load double, double* %6
%16 = call double @llvm.fabs.f64(double %15)
store double %16, double* %10
%17 = load double, double* %8
%18 = load double, double* %9
%19 = fcmp ogt double %17, %18
br i1 %19, label %24, label %20
20: ; preds = %3
%21 = load double, double* %9
%22 = call i64 @rtIsNaN(double %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20, %3
%25 = load double, double* %8
store double %25, double* %7
br label %28
26: ; preds = %20
%27 = load double, double* %9
store double %27, double* %7
br label %28
28: ; preds = %26, %24
%29 = load double, double* %10
%30 = load double, double* %7
%31 = fcmp ogt double %29, %30
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = load double, double* %10
store double %33, double* %7
br label %34
34: ; preds = %32, %28
%35 = load double, double* %7
%36 = fcmp ogt double %35, 0.000000e+00
br i1 %36, label %37, label %63
37: ; preds = %34
%38 = load double, double* %7
%39 = call i32 @rtIsInf(double %38)
%40 = icmp ne i32 %39, 0
br i1 %40, label %63, label %41
41: ; preds = %37
%42 = load double, double* %7
%43 = load double, double* %8
%44 = fdiv double %43, %42
store double %44, double* %8
%45 = load double, double* %7
%46 = load double, double* %9
%47 = fdiv double %46, %45
store double %47, double* %9
%48 = load double, double* %7
%49 = load double, double* %10
%50 = fdiv double %49, %48
store double %50, double* %10
%51 = load double, double* %8
%52 = load double, double* %8
%53 = load double, double* %10
%54 = load double, double* %10
%55 = fmul double %53, %54
%56 = call double @llvm.fmuladd.f64(double %51, double %52, double %55)
%57 = load double, double* %9
%58 = load double, double* %9
%59 = call double @llvm.fmuladd.f64(double %57, double %58, double %56)
%60 = call double @sqrt(double %59)
%61 = load double, double* %7
%62 = fmul double %61, %60
store double %62, double* %7
br label %69
63: ; preds = %37, %34
%64 = load double, double* %8
%65 = load double, double* %9
%66 = fadd double %64, %65
%67 = load double, double* %10
%68 = fadd double %66, %67
store double %68, double* %7
br label %69
69: ; preds = %63, %41
%70 = load double, double* %7
ret double %70
}

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