#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(int);
double pythagoras(double a, double b) {
  double abs_a, abs_b, sqr;
  abs_a = fabs(a);
  abs_b = fabs(b);
  if (abs_a > abs_b) {
    sqr = abs_b / abs_a;
    sqr *= sqr;
    return abs_a * sqrt(1 + sqr);
  } else if (abs_b > abs_a) {
    sqr = abs_a / abs_b;
    sqr *= sqr;
    return abs_b * sqrt(1 + sqr);
  } else
    return 1.41421356237309504880 * abs_a;
}


x86 assembly (clang, -O0):
<pythagoras>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%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    11b0 <pythagoras+0xa0>
movsd  -0x28(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe8c(%rip),%xmm0
addsd  -0x30(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1226 <pythagoras+0x116>
movsd  -0x28(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1214 <pythagoras+0x104>
movsd  -0x20(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe28(%rip),%xmm0
addsd  -0x30(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1226 <pythagoras+0x116>
movsd  0xdf4(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pythagoras>:
sub    $0x18,%rsp
movapd %xmm0,%xmm2
movapd 0xee0(%rip),%xmm0
andpd  %xmm0,%xmm2
andpd  %xmm0,%xmm1
ucomisd %xmm1,%xmm2
jbe    1149 <pythagoras+0x39>
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm1
addsd  0xeda(%rip),%xmm1
cvttsd2si %xmm1,%edi
movapd %xmm2,(%rsp)
jmp    1168 <pythagoras+0x58>
ucomisd %xmm2,%xmm1
jbe    1177 <pythagoras+0x67>
divsd  %xmm1,%xmm2
mulsd  %xmm2,%xmm2
addsd  0xeb9(%rip),%xmm2
cvttsd2si %xmm2,%edi
movapd %xmm1,(%rsp)
call   1030 <sqrt@plt>
mulsd  (%rsp),%xmm0
add    $0x18,%rsp
ret
movsd  0xe91(%rip),%xmm0
mulsd  %xmm2,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @pythagoras(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %4
store double %1, double* %5
%9 = load double, double* %4
%10 = call double @llvm.fabs.f64(double %9)
store double %10, double* %6
%11 = load double, double* %5
%12 = call double @llvm.fabs.f64(double %11)
store double %12, double* %7
%13 = load double, double* %6
%14 = load double, double* %7
%15 = fcmp ogt double %13, %14
br i1 %15, label %16, label %29
16: ; preds = %2
%17 = load double, double* %7
%18 = load double, double* %6
%19 = fdiv double %17, %18
store double %19, double* %8
%20 = load double, double* %8
%21 = load double, double* %8
%22 = fmul double %21, %20
store double %22, double* %8
%23 = load double, double* %6
%24 = load double, double* %8
%25 = fadd double 1.000000e+00, %24
%26 = fptosi double %25 to i32
%27 = call double @sqrt(i32 %26)
%28 = fmul double %23, %27
store double %28, double* %3
br label %49
29: ; preds = %2
%30 = load double, double* %7
%31 = load double, double* %6
%32 = fcmp ogt double %30, %31
br i1 %32, label %33, label %46
33: ; preds = %29
%34 = load double, double* %6
%35 = load double, double* %7
%36 = fdiv double %34, %35
store double %36, double* %8
%37 = load double, double* %8
%38 = load double, double* %8
%39 = fmul double %38, %37
store double %39, double* %8
%40 = load double, double* %7
%41 = load double, double* %8
%42 = fadd double 1.000000e+00, %41
%43 = fptosi double %42 to i32
%44 = call double @sqrt(i32 %43)
%45 = fmul double %40, %44
store double %45, double* %3
br label %49
46: ; preds = %29
%47 = load double, double* %6
%48 = fmul double 0x3FF6A09E667F3BCD, %47
store double %48, double* %3
br label %49
49: ; preds = %46, %33, %16
%50 = load double, double* %3
ret double %50
}

LLVM IR (-O2):
define double @pythagoras(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 %13
6: ; preds = %2
%7 = fdiv double %4, %3
%8 = fmul double %7, %7
%9 = fadd double %8, 1.000000e+00
%10 = fptosi double %9 to i32
%11 = tail call double @sqrt(i32 %10)
%12 = fmul double %3, %11
br label %24
13: ; preds = %2
%14 = fcmp ogt double %4, %3
br i1 %14, label %15, label %22
15: ; preds = %13
%16 = fdiv double %3, %4
%17 = fmul double %16, %16
%18 = fadd double %17, 1.000000e+00
%19 = fptosi double %18 to i32
%20 = tail call double @sqrt(i32 %19)
%21 = fmul double %4, %20
br label %24
22: ; preds = %13
%23 = fmul double %3, 0x3FF6A09E667F3BCD
br label %24
24: ; preds = %22, %15, %6
%25 = phi double [ %12, %6 ], [ %21, %15 ], [ %23, %22 ]
ret double %25
}