#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 radius(double u, double v) {
  double w;
  u = fabs(u);
  v = fabs(v);
  if (u > v) {
    w = v / u;
    return (u * sqrt(1. + w * w));
  } else {
    if (v) {
      w = u / v;
      return (v * sqrt(1. + w * w));
    } else
      return 0.0;
  }
}


x86 assembly (clang, -O0):
<radius>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movaps 0xed2(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x18(%rbp),%xmm0
movaps 0xebd(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11ae <radius+0x9e>
movsd  -0x18(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe85(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1225 <radius+0x115>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11cb <radius+0xbb>
jp     11cb <radius+0xbb>
jmp    121d <radius+0x10d>
movsd  -0x10(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe16(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1225 <radius+0x115>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

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

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

LLVM IR (-O2):
define double @radius(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 %4, %3
%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 %3, %4
%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
}