#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 */
float sqrt(float);
signed long srange(signed long argx, signed long argy) {
  signed long res;
  float t0, t1, val;
  t0 = argx / 65536;
  t0 = t0 * t0;
  t1 = argy / 65536;
  t1 = t1 * t1;
  val = sqrt(t0 + t1);
  val = val * 65535;
  res = val;
  return (res);
}


x86 assembly (clang, -O0):
<srange>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x10000,%ecx
cqto
idiv   %rcx
cvtsi2ss %rax,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
mulss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x10000,%ecx
cqto
idiv   %rcx
cvtsi2ss %rax,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm0
mulss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x1c(%rbp),%xmm0
addss  -0x20(%rbp),%xmm0
call   1030 <sqrt@plt>
movss  %xmm0,-0x24(%rbp)
movss  0xe76(%rip),%xmm0
mulss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
cvttss2si -0x24(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<srange>:
push   %rax
lea    0xffff(%rdi),%rax
test   %rdi,%rdi
cmovns %rdi,%rax
sar    $0x10,%rax
cvtsi2ss %rax,%xmm1
mulss  %xmm1,%xmm1
lea    0xffff(%rsi),%rax
test   %rsi,%rsi
cmovns %rsi,%rax
sar    $0x10,%rax
cvtsi2ss %rax,%xmm0
mulss  %xmm0,%xmm0
addss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     1159 <srange+0x49>
sqrtss %xmm0,%xmm0
jmp    115e <srange+0x4e>
call   1030 <sqrt@plt>
mulss  0xe9a(%rip),%xmm0
cvttss2si %xmm0,%rax
pop    %rcx
ret

LLVM IR (-O0):
define i64 @srange(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca float
%7 = alloca float
%8 = alloca float
store i64 %0, i64* %3
store i64 %1, i64* %4
%9 = load i64, i64* %3
%10 = sdiv i64 %9, 65536
%11 = sitofp i64 %10 to float
store float %11, float* %6
%12 = load float, float* %6
%13 = load float, float* %6
%14 = fmul float %12, %13
store float %14, float* %6
%15 = load i64, i64* %4
%16 = sdiv i64 %15, 65536
%17 = sitofp i64 %16 to float
store float %17, float* %7
%18 = load float, float* %7
%19 = load float, float* %7
%20 = fmul float %18, %19
store float %20, float* %7
%21 = load float, float* %6
%22 = load float, float* %7
%23 = fadd float %21, %22
%24 = call float @sqrt(float %23)
store float %24, float* %8
%25 = load float, float* %8
%26 = fmul float %25, 6.553500e+04
store float %26, float* %8
%27 = load float, float* %8
%28 = fptosi float %27 to i64
store i64 %28, i64* %5
%29 = load i64, i64* %5
ret i64 %29
}

LLVM IR (-O2):
define i64 @srange(i64 %0, i64 %1) {
%3 = sdiv i64 %0, 65536
%4 = sitofp i64 %3 to float
%5 = fmul float %4, %4
%6 = sdiv i64 %1, 65536
%7 = sitofp i64 %6 to float
%8 = fmul float %7, %7
%9 = fadd float %5, %8
%10 = tail call float @sqrt(float %9)
%11 = fmul float %10, 6.553500e+04
%12 = fptosi float %11 to i64
ret i64 %12
}