#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 Algebra_hypot(double a, double b) {
  double r;
  if (fabs(a) > fabs(b)) {
    r = b / a;
    r = fabs(a) * sqrt(1 + r * r);
  } else if (b != 0) {
    r = a / b;
    r = fabs(b) * sqrt(1 + r * r);
  } else {
    r = 0.0;
  }
  return r;
}


x86 assembly (clang, -O0):
<Algebra_hypot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
movaps 0xed2(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm1
movaps 0xec2(%rip),%xmm2
pand   %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    11a9 <Algebra_hypot+0x99>
movsd  -0x10(%rbp),%xmm0
divsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
movaps 0xe99(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe8a(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1230 <Algebra_hypot+0x120>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11c6 <Algebra_hypot+0xb6>
jp     11c6 <Algebra_hypot+0xb6>
jmp    1223 <Algebra_hypot+0x113>
movsd  -0x8(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movaps 0xe1f(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe10(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    122b <Algebra_hypot+0x11b>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1230 <Algebra_hypot+0x120>
movsd  -0x18(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Algebra_hypot>:
sub    $0x18,%rsp
movapd 0xee4(%rip),%xmm3
movapd %xmm0,%xmm2
andpd  %xmm3,%xmm2
andpd  %xmm1,%xmm3
ucomisd %xmm3,%xmm2
jbe    1145 <Algebra_hypot+0x35>
divsd  %xmm0,%xmm1
mulsd  %xmm1,%xmm1
addsd  0xed2(%rip),%xmm1
movapd %xmm2,(%rsp)
jmp    116a <Algebra_hypot+0x5a>
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm1
jne    1151 <Algebra_hypot+0x41>
jnp    117c <Algebra_hypot+0x6c>
divsd  %xmm1,%xmm0
mulsd  %xmm0,%xmm0
addsd  0xeaf(%rip),%xmm0
movapd %xmm0,%xmm1
movapd %xmm3,(%rsp)
cvttsd2si %xmm1,%edi
call   1030 <sqrt@plt>
movapd %xmm0,%xmm2
mulsd  (%rsp),%xmm2
movapd %xmm2,%xmm0
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
define double @Algebra_hypot(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 %1, %0
%8 = tail call double @llvm.fmuladd.f64(double %7, double %7, double 1.000000e+00)
br label %14
9: ; preds = %2
%10 = fcmp une double %1, 0.000000e+00
br i1 %10, label %11, label %20
11: ; preds = %9
%12 = fdiv double %0, %1
%13 = tail call double @llvm.fmuladd.f64(double %12, double %12, double 1.000000e+00)
br label %14
14: ; preds = %6, %11
%15 = phi double [ %13, %11 ], [ %8, %6 ]
%16 = phi double [ %4, %11 ], [ %3, %6 ]
%17 = fptosi double %15 to i32
%18 = tail call double @sqrt(i32 %17)
%19 = fmul double %16, %18
br label %20
20: ; preds = %14, %9
%21 = phi double [ 0.000000e+00, %9 ], [ %19, %14 ]
ret double %21
}