#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 pythag(double a, double b) {
  double absa, absb;
  absa = fabs(a);
  absb = fabs(b);
  if (absa > absb)
    return absa *
           sqrt(1.0 +
                (((absb / absa) == 0.0) ? 0.0 : (absb / absa) * (absb / absa)));
  else
    return (absb == 0.0
                ? 0.0
                : absb * sqrt(1.0 + (((absa / absb) == 0.0)
                                         ? 0.0
                                         : (absa / absb) * (absa / absb))));
}


x86 assembly (clang, -O0):
<pythag>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movaps 0xed2(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movaps 0xebd(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    11d9 <pythag+0xc9>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1190 <pythag+0x80>
jp     1190 <pythag+0x80>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    11ad <pythag+0x9d>
movsd  -0x28(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
divsd  -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm1
movsd  0xe56(%rip),%xmm0
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1280 <pythag+0x170>
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11fe <pythag+0xee>
jp     11fe <pythag+0xee>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    1276 <pythag+0x166>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x20(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1232 <pythag+0x122>
jp     1232 <pythag+0x122>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    124f <pythag+0x13f>
movsd  -0x20(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
divsd  -0x28(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm1
movsd  0xdb4(%rip),%xmm0
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pythag>:
push   %rax
movapd %xmm0,%xmm2
movapd 0xee3(%rip),%xmm0
andpd  %xmm0,%xmm2
andpd  %xmm1,%xmm0
ucomisd %xmm0,%xmm2
jbe    113d <pythag+0x2d>
divsd  %xmm2,%xmm0
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm2,%xmm5
jmp    115d <pythag+0x4d>
xorpd  %xmm5,%xmm5
ucomisd %xmm5,%xmm1
jne    1149 <pythag+0x39>
jnp    11a1 <pythag+0x91>
movapd %xmm0,%xmm5
divsd  %xmm0,%xmm2
movapd %xmm2,%xmm1
mulsd  %xmm2,%xmm1
movapd %xmm2,%xmm0
movsd  0xeab(%rip),%xmm2
addsd  %xmm2,%xmm1
xorpd  %xmm3,%xmm3
cmpeqsd %xmm3,%xmm0
movapd %xmm0,%xmm4
andnpd %xmm1,%xmm4
andpd  %xmm2,%xmm0
orpd   %xmm4,%xmm0
ucomisd %xmm3,%xmm0
jb     118e <pythag+0x7e>
sqrtsd %xmm0,%xmm0
jmp    119d <pythag+0x8d>
movsd  %xmm5,(%rsp)
call   1030 <sqrt@plt>
movsd  (%rsp),%xmm5
mulsd  %xmm0,%xmm5
movapd %xmm5,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @pythag(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %4
store double %1, double* %5
%8 = load double, double* %4
%9 = call double @llvm.fabs.f64(double %8)
store double %9, double* %6
%10 = load double, double* %5
%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 ogt double %12, %13
br i1 %14, label %15, label %35
15: ; preds = %2
%16 = load double, double* %6
%17 = load double, double* %7
%18 = load double, double* %6
%19 = fdiv double %17, %18
%20 = fcmp oeq double %19, 0.000000e+00
br i1 %20, label %21, label %22
21: ; preds = %15
br label %30
22: ; preds = %15
%23 = load double, double* %7
%24 = load double, double* %6
%25 = fdiv double %23, %24
%26 = load double, double* %7
%27 = load double, double* %6
%28 = fdiv double %26, %27
%29 = fmul double %25, %28
br label %30
30: ; preds = %22, %21
%31 = phi double [ 0.000000e+00, %21 ], [ %29, %22 ]
%32 = fadd double 1.000000e+00, %31
%33 = call double @sqrt(double %32)
%34 = fmul double %16, %33
store double %34, double* %3
br label %61
35: ; preds = %2
%36 = load double, double* %7
%37 = fcmp oeq double %36, 0.000000e+00
br i1 %37, label %38, label %39
38: ; preds = %35
br label %59
39: ; preds = %35
%40 = load double, double* %7
%41 = load double, double* %6
%42 = load double, double* %7
%43 = fdiv double %41, %42
%44 = fcmp oeq double %43, 0.000000e+00
br i1 %44, label %45, label %46
45: ; preds = %39
br label %54
46: ; preds = %39
%47 = load double, double* %6
%48 = load double, double* %7
%49 = fdiv double %47, %48
%50 = load double, double* %6
%51 = load double, double* %7
%52 = fdiv double %50, %51
%53 = fmul double %49, %52
br label %54
54: ; preds = %46, %45
%55 = phi double [ 0.000000e+00, %45 ], [ %53, %46 ]
%56 = fadd double 1.000000e+00, %55
%57 = call double @sqrt(double %56)
%58 = fmul double %40, %57
br label %59
59: ; preds = %54, %38
%60 = phi double [ 0.000000e+00, %38 ], [ %58, %54 ]
store double %60, double* %3
br label %61
61: ; preds = %59, %30
%62 = load double, double* %3
ret double %62
}

LLVM IR (-O2):
define double @pythag(double %0, double %1) {
%3 = tail call double @llvm.fabs.f64(double %0)
%4 = tail call double @llvm.fabs.f64(double %1)
%5 = fcmp ogt double %3, %4
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = fdiv double %4, %3
%8 = fmul double %7, %7
br label %14
9: ; preds = %2
%10 = fcmp oeq double %1, 0.000000e+00
br i1 %10, label %23, label %11
11: ; preds = %9
%12 = fdiv double %3, %4
%13 = fmul double %12, %12
br label %14
14: ; preds = %6, %11
%15 = phi double [ %13, %11 ], [ %8, %6 ]
%16 = phi double [ %12, %11 ], [ %7, %6 ]
%17 = phi double [ %4, %11 ], [ %3, %6 ]
%18 = fcmp oeq double %16, 0.000000e+00
%19 = fadd double %15, 1.000000e+00
%20 = select i1 %18, double 1.000000e+00, double %19
%21 = tail call double @sqrt(double %20)
%22 = fmul double %17, %21
br label %23
23: ; preds = %14, %9
%24 = phi double [ 0.000000e+00, %9 ], [ %22, %14 ]
ret double %24
}