#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 pow(double, int);
double pythag(double a, double b) {
  double p, r, s, t, u;
  p = (((fabs(a)) > (fabs(b))) ? (fabs(a)) : (fabs(b)));
  if (p == 0.0)
    return p;
  r = pow((((fabs(a)) < (fabs(b))) ? (fabs(a)) : (fabs(b))) / p, 2);
  while (1) {
    t = 4.0 + r;
    if (t == 4.0)
      break;
    s = r / t;
    u = 1.0 + 2.0 * s;
    p = u * p;
    r = pow(s / u, 2) * r;
  }
  return p;
}


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  -0x18(%rbp),%xmm1
movaps 0xec2(%rip),%xmm2
pand   %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    1166 <pythag+0x56>
movsd  -0x10(%rbp),%xmm0
movaps 0xea8(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    117b <pythag+0x6b>
movsd  -0x18(%rbp),%xmm0
movaps 0xe8e(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11ac <pythag+0x9c>
jp     11ac <pythag+0x9c>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12b7 <pythag+0x1a7>
movsd  -0x10(%rbp),%xmm1
movaps 0xe48(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
movaps 0xe38(%rip),%xmm2
pand   %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    11f0 <pythag+0xe0>
movsd  -0x10(%rbp),%xmm0
movaps 0xe1e(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    1205 <pythag+0xf5>
movsd  -0x18(%rbp),%xmm0
movaps 0xe04(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  0xdea(%rip),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xdd3(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1252 <pythag+0x142>
jp     1252 <pythag+0x142>
jmp    12ad <pythag+0x19d>
movsd  -0x28(%rbp),%xmm0
divsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
addsd  %xmm0,%xmm0
movsd  0xda6(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x30(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    121e <pythag+0x10e>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pythag>:
sub    $0x28,%rsp
movapd 0xee4(%rip),%xmm2
andpd  %xmm2,%xmm0
andpd  %xmm2,%xmm1
movapd %xmm0,%xmm3
maxsd  %xmm1,%xmm3
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm3
jne    113c <pythag+0x2c>
jnp    11ec <pythag+0xdc>
minsd  %xmm1,%xmm0
movapd %xmm3,0x10(%rsp)
divsd  %xmm3,%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
movsd  0xeb4(%rip),%xmm2
movapd %xmm0,%xmm1
addsd  %xmm2,%xmm1
ucomisd %xmm2,%xmm1
jne    1174 <pythag+0x64>
jp     1174 <pythag+0x64>
movapd 0x10(%rsp),%xmm3
jmp    11ec <pythag+0xdc>
movapd 0x10(%rsp),%xmm3
nopw   0x0(%rax,%rax,1)
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
divsd  %xmm1,%xmm0
movapd %xmm0,%xmm1
addsd  %xmm0,%xmm1
addsd  0xe78(%rip),%xmm1
mulsd  %xmm1,%xmm3
movapd %xmm3,0x10(%rsp)
divsd  %xmm1,%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
movsd  0xe50(%rip),%xmm2
movapd 0x10(%rsp),%xmm3
movsd  0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
movapd %xmm0,%xmm1
addsd  %xmm2,%xmm1
ucomisd %xmm2,%xmm1
jne    1180 <pythag+0x70>
jp     1180 <pythag+0x70>
movapd %xmm3,%xmm0
add    $0x28,%rsp
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
%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)
%13 = load double, double* %5
%14 = call double @llvm.fabs.f64(double %13)
%15 = fcmp ogt double %12, %14
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = load double, double* %4
%18 = call double @llvm.fabs.f64(double %17)
br label %22
19: ; preds = %2
%20 = load double, double* %5
%21 = call double @llvm.fabs.f64(double %20)
br label %22
22: ; preds = %19, %16
%23 = phi double [ %18, %16 ], [ %21, %19 ]
store double %23, double* %6
%24 = load double, double* %6
%25 = fcmp oeq double %24, 0.000000e+00
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = load double, double* %6
store double %27, double* %3
br label %68
28: ; preds = %22
%29 = load double, double* %4
%30 = call double @llvm.fabs.f64(double %29)
%31 = load double, double* %5
%32 = call double @llvm.fabs.f64(double %31)
%33 = fcmp olt double %30, %32
br i1 %33, label %34, label %37
34: ; preds = %28
%35 = load double, double* %4
%36 = call double @llvm.fabs.f64(double %35)
br label %40
37: ; preds = %28
%38 = load double, double* %5
%39 = call double @llvm.fabs.f64(double %38)
br label %40
40: ; preds = %37, %34
%41 = phi double [ %36, %34 ], [ %39, %37 ]
%42 = load double, double* %6
%43 = fdiv double %41, %42
%44 = call double @pow(double %43, i32 2)
store double %44, double* %7
br label %45
45: ; preds = %40, %51
%46 = load double, double* %7
%47 = fadd double 4.000000e+00, %46
store double %47, double* %9
%48 = load double, double* %9
%49 = fcmp oeq double %48, 4.000000e+00
br i1 %49, label %50, label %51
50: ; preds = %45
br label %66
51: ; preds = %45
%52 = load double, double* %7
%53 = load double, double* %9
%54 = fdiv double %52, %53
store double %54, double* %8
%55 = load double, double* %8
%56 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %55, double 1.000000e+00)
store double %56, double* %10
%57 = load double, double* %10
%58 = load double, double* %6
%59 = fmul double %57, %58
store double %59, double* %6
%60 = load double, double* %8
%61 = load double, double* %10
%62 = fdiv double %60, %61
%63 = call double @pow(double %62, i32 2)
%64 = load double, double* %7
%65 = fmul double %63, %64
store double %65, double* %7
br label %45
66: ; preds = %50
%67 = load double, double* %6
store double %67, double* %3
br label %68
68: ; preds = %66, %26
%69 = load double, double* %3
ret double %69
}

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
%6 = select i1 %5, double %3, double %4
%7 = fcmp oeq double %6, 0.000000e+00
br i1 %7, label %27, label %8
8: ; preds = %2
%9 = fcmp olt double %3, %4
%10 = select i1 %9, double %3, double %4
%11 = fdiv double %10, %6
%12 = tail call double @pow(double %11, i32 2)
%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 = tail call double @pow(double %22, i32 2)
%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 [ %6, %2 ], [ %6, %8 ], [ %21, %15 ]
ret double %28
}