#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 sqrt(double);
double pythag(double a, double b) {
  double absa, absb;
  absa = ((a) > 0 ? (a) : -(a));
  absb = ((b) > 0 ? (b) : -(b));
  if (absa > absb)
    return absa * sqrt(1.0 + ((absb * absb) / (absa * absa)));
  else
    return (absb == 0.0 ? 0.0
                        : absb * sqrt(1.0 + ((absa * absa) / (absb * 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
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1143 <pythag+0x33>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    1164 <pythag+0x54>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    118f <pythag+0x7f>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    11b0 <pythag+0xa0>
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    1213 <pythag+0x103>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm1
mulsd  -0x28(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
divsd  %xmm0,%xmm1
movsd  0xe0c(%rip),%xmm0
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1286 <pythag+0x176>
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1238 <pythag+0x128>
jp     1238 <pythag+0x128>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    127c <pythag+0x16c>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x20(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
divsd  %xmm0,%xmm1
movsd  0xd9e(%rip),%xmm0
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pythag>:
push   %rax
movapd 0xee7(%rip),%xmm3
xorpd  %xmm2,%xmm2
cmpltsd %xmm0,%xmm2
movapd %xmm2,%xmm4
andpd  %xmm0,%xmm2
xorpd  %xmm3,%xmm0
xorpd  %xmm5,%xmm5
andnpd %xmm0,%xmm4
orpd   %xmm4,%xmm2
xorpd  %xmm1,%xmm3
xorpd  %xmm0,%xmm0
cmpltsd %xmm1,%xmm0
movapd %xmm0,%xmm4
andnpd %xmm3,%xmm4
andpd  %xmm1,%xmm0
orpd   %xmm4,%xmm0
ucomisd %xmm0,%xmm2
jbe    1173 <pythag+0x63>
mulsd  %xmm0,%xmm0
movapd %xmm2,%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movapd %xmm2,%xmm5
jmp    118f <pythag+0x7f>
ucomisd %xmm5,%xmm0
jne    117b <pythag+0x6b>
jnp    11ba <pythag+0xaa>
movapd %xmm0,%xmm5
mulsd  %xmm2,%xmm2
mulsd  %xmm0,%xmm0
divsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
addsd  0xe79(%rip),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11a7 <pythag+0x97>
sqrtsd %xmm0,%xmm0
jmp    11b6 <pythag+0xa6>
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 = fcmp ogt double %8, 0.000000e+00
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = load double, double* %4
br label %15
12: ; preds = %2
%13 = load double, double* %4
%14 = fneg double %13
br label %15
15: ; preds = %12, %10
%16 = phi double [ %11, %10 ], [ %14, %12 ]
store double %16, double* %6
%17 = load double, double* %5
%18 = fcmp ogt double %17, 0.000000e+00
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = load double, double* %5
br label %24
21: ; preds = %15
%22 = load double, double* %5
%23 = fneg double %22
br label %24
24: ; preds = %21, %19
%25 = phi double [ %20, %19 ], [ %23, %21 ]
store double %25, double* %7
%26 = load double, double* %6
%27 = load double, double* %7
%28 = fcmp ogt double %26, %27
br i1 %28, label %29, label %41
29: ; preds = %24
%30 = load double, double* %6
%31 = load double, double* %7
%32 = load double, double* %7
%33 = fmul double %31, %32
%34 = load double, double* %6
%35 = load double, double* %6
%36 = fmul double %34, %35
%37 = fdiv double %33, %36
%38 = fadd double 1.000000e+00, %37
%39 = call double @sqrt(double %38)
%40 = fmul double %30, %39
store double %40, double* %3
br label %59
41: ; preds = %24
%42 = load double, double* %7
%43 = fcmp oeq double %42, 0.000000e+00
br i1 %43, label %44, label %45
44: ; preds = %41
br label %57
45: ; preds = %41
%46 = load double, double* %7
%47 = load double, double* %6
%48 = load double, double* %6
%49 = fmul double %47, %48
%50 = load double, double* %7
%51 = load double, double* %7
%52 = fmul double %50, %51
%53 = fdiv double %49, %52
%54 = fadd double 1.000000e+00, %53
%55 = call double @sqrt(double %54)
%56 = fmul double %46, %55
br label %57
57: ; preds = %45, %44
%58 = phi double [ 0.000000e+00, %44 ], [ %56, %45 ]
store double %58, double* %3
br label %59
59: ; preds = %57, %29
%60 = load double, double* %3
ret double %60
}

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