#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 Pythag(double a, double b) {
  double p, r, s, t, u;
  p = fabs(a);
  if (fabs(b) > p)
    p = fabs(b);
  if (p == 0.0)
    return 0.0;
  r = fabs(a);
  if (fabs(b) < r)
    r = fabs(b);
  r /= p;
  r *= r;
  for (;;) {
    t = 4.0 + r;
    if (t == 4.0)
      break;
    s = r / t;
    u = 1.0 + 2.0 * s;
    p = u * p;
    s /= u;
    r = s * s * r;
  }
  return p;
}


x86 assembly (clang, -O0):
<Pythag>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movaps 0xee6(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movaps 0xed1(%rip),%xmm1
pand   %xmm1,%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1153 <Pythag+0x53>
movsd  -0x18(%rbp),%xmm0
movaps 0xeb6(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1178 <Pythag+0x78>
jp     1178 <Pythag+0x78>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1285 <Pythag+0x185>
movsd  -0x10(%rbp),%xmm0
movaps 0xe7c(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm1
movaps 0xe67(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11c1 <Pythag+0xc1>
movsd  -0x18(%rbp),%xmm0
movaps 0xe48(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe25(%rip),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xe0e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1217 <Pythag+0x117>
jp     1217 <Pythag+0x117>
jmp    127b <Pythag+0x17b>
movsd  -0x28(%rbp),%xmm0
divsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
addsd  %xmm0,%xmm0
movsd  0xde1(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x40(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11e3 <Pythag+0xe3>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<Pythag>:
movapd %xmm0,%xmm2
movapd 0xef4(%rip),%xmm0
andpd  %xmm0,%xmm2
andpd  %xmm0,%xmm1
movapd %xmm1,%xmm4
maxsd  %xmm2,%xmm4
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm4
jne    1129 <Pythag+0x29>
jp     1129 <Pythag+0x29>
ret
minsd  %xmm2,%xmm1
divsd  %xmm4,%xmm1
mulsd  %xmm1,%xmm1
movsd  0xed3(%rip),%xmm2
movapd %xmm1,%xmm5
addsd  %xmm2,%xmm5
ucomisd %xmm2,%xmm5
jne    1152 <Pythag+0x52>
jp     1152 <Pythag+0x52>
movapd %xmm4,%xmm0
ret
movsd  0xebe(%rip),%xmm3
movapd %xmm4,%xmm0
xchg   %ax,%ax
movapd %xmm1,%xmm4
divsd  %xmm5,%xmm4
movapd %xmm4,%xmm5
addsd  %xmm4,%xmm5
addsd  %xmm3,%xmm5
mulsd  %xmm5,%xmm0
divsd  %xmm5,%xmm4
mulsd  %xmm4,%xmm4
mulsd  %xmm4,%xmm1
movapd %xmm1,%xmm5
addsd  %xmm2,%xmm5
ucomisd %xmm2,%xmm5
jne    1160 <Pythag+0x60>
jp     1160 <Pythag+0x60>
jmp    1128 <Pythag+0x28>

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

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 %4, %3
%6 = select i1 %5, double %4, double %3
%7 = fcmp oeq double %6, 0.000000e+00
br i1 %7, label %27, label %8
8: ; preds = %2
%9 = fcmp olt double %4, %3
%10 = select i1 %9, double %4, double %3
%11 = fdiv double %10, %6
%12 = fmul double %11, %11
%13 = fadd double %12, 4.000000e+00
%14 = fcmp oeq double %13, 4.000000e+00
br i1 %14, label %27, label %15
15: ; preds = %8, %15
%16 = phi double [ %25, %15 ], [ %13, %8 ]
%17 = phi double [ %21, %15 ], [ %6, %8 ]
%18 = phi double [ %24, %15 ], [ %12, %8 ]
%19 = fdiv double %18, %16
%20 = tail call double @llvm.fmuladd.f64(double %19, double 2.000000e+00, double 1.000000e+00)
%21 = fmul double %17, %20
%22 = fdiv double %19, %20
%23 = fmul double %22, %22
%24 = fmul double %18, %23
%25 = fadd double %24, 4.000000e+00
%26 = fcmp oeq double %25, 4.000000e+00
br i1 %26, label %27, label %15
27: ; preds = %15, %8, %2
%28 = phi double [ 0.000000e+00, %2 ], [ %6, %8 ], [ %21, %15 ]
ret double %28
}