#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 */
scalar_t__ floor(float);
int sqrt(double);
float cone(float x, float y) {
  x -= floor(x);
  y -= floor(y);
  x -= .5;
  y -= .5;
  return 1 - 2 * sqrt(.5 * (x * x + y * y));
}


x86 assembly (clang, -O0):
<cone>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
call   1040 <floor@plt>
cvtsi2ss %rax,%xmm1
movss  -0x4(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x8(%rbp),%xmm0
call   1040 <floor@plt>
cvtsi2ss %rax,%xmm1
movss  -0x8(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe83(%rip),%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe65(%rip),%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
movss  -0x4(%rbp),%xmm2
movss  -0x8(%rbp),%xmm1
mulss  -0x8(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe30(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
mov    %eax,%ecx
shl    $0x1,%ecx
mov    $0x1,%eax
sub    %ecx,%eax
cvtsi2ss %eax,%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cone>:
push   %rax
movss  %xmm1,0x4(%rsp)
movss  %xmm0,(%rsp)
call   1040 <floor@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  (%rsp),%xmm1
subss  %xmm0,%xmm1
movss  %xmm1,(%rsp)
movss  0x4(%rsp),%xmm0
call   1040 <floor@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  0x4(%rsp),%xmm2
subss  %xmm0,%xmm2
movss  0xe94(%rip),%xmm0
movss  (%rsp),%xmm1
addss  %xmm0,%xmm1
addss  %xmm0,%xmm2
mulss  %xmm2,%xmm2
mulss  %xmm1,%xmm1
addss  %xmm2,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
mulsd  0xe74(%rip),%xmm0
call   1030 <sqrt@plt>
add    %eax,%eax
mov    $0x1,%ecx
sub    %eax,%ecx
xorps  %xmm0,%xmm0
cvtsi2ss %ecx,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @cone(float %0, float %1) {
%3 = alloca float
%4 = alloca float
store float %0, float* %3
store float %1, float* %4
%5 = load float, float* %3
%6 = call i64 @floor(float %5)
%7 = sitofp i64 %6 to float
%8 = load float, float* %3
%9 = fsub float %8, %7
store float %9, float* %3
%10 = load float, float* %4
%11 = call i64 @floor(float %10)
%12 = sitofp i64 %11 to float
%13 = load float, float* %4
%14 = fsub float %13, %12
store float %14, float* %4
%15 = load float, float* %3
%16 = fpext float %15 to double
%17 = fsub double %16, 5.000000e-01
%18 = fptrunc double %17 to float
store float %18, float* %3
%19 = load float, float* %4
%20 = fpext float %19 to double
%21 = fsub double %20, 5.000000e-01
%22 = fptrunc double %21 to float
store float %22, float* %4
%23 = load float, float* %3
%24 = load float, float* %3
%25 = load float, float* %4
%26 = load float, float* %4
%27 = fmul float %25, %26
%28 = call float @llvm.fmuladd.f32(float %23, float %24, float %27)
%29 = fpext float %28 to double
%30 = fmul double 5.000000e-01, %29
%31 = call i32 @sqrt(double %30)
%32 = mul nsw i32 2, %31
%33 = sub nsw i32 1, %32
%34 = sitofp i32 %33 to float
ret float %34
}

LLVM IR (-O2):
define float @cone(float %0, float %1) {
%3 = tail call i64 @floor(float %0)
%4 = sitofp i64 %3 to float
%5 = fsub float %0, %4
%6 = tail call i64 @floor(float %1)
%7 = sitofp i64 %6 to float
%8 = fsub float %1, %7
%9 = fadd float %5, -5.000000e-01
%10 = fadd float %8, -5.000000e-01
%11 = fmul float %10, %10
%12 = tail call float @llvm.fmuladd.f32(float %9, float %9, float %11)
%13 = fpext float %12 to double
%14 = fmul double %13, 5.000000e-01
%15 = tail call i32 @sqrt(double %14)
%16 = mul i32 %15, -2
%17 = or i32 %16, 1
%18 = sitofp i32 %17 to float
ret float %18
}