#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(double);
double hypot(double, double);
double modf(double, double *);
int sample(double xx, double yy) {
  double xint, yint, d;
  int xsel, ysel;
  xx += 9 + 32;
  yy += 4;
  xx = modf(xx, &xint);
  yy = modf(yy, &yint);
  if (xx < 0)
    xx += 1;
  if (yy < 0)
    yy += 1;
  d = hypot(xx - .5, yy - .5);
  xsel = (int)floor(xint) & 31;
  ysel = (int)floor(yint);
  if (d < .36 && xsel < 19) {
    return ysel * 19 + xsel;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<sample>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  0xebe(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xea4(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
lea    -0x20(%rbp),%rdi
call   1030 <modf@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    -0x28(%rbp),%rdi
call   1030 <modf@plt>
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11ac <sample+0x7c>
movsd  0xe6e(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11cc <sample+0x9c>
movsd  0xe4e(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe47(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0xe36(%rip),%xmm2
subsd  %xmm2,%xmm1
call   1040 <hypot@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1050 <floor@plt>
and    $0x1f,%eax
mov    %eax,-0x34(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1050 <floor@plt>
mov    %eax,-0x38(%rbp)
movsd  0xdfb(%rip),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    1241 <sample+0x111>
cmpl   $0x13,-0x34(%rbp)
jge    1241 <sample+0x111>
imul   $0x13,-0x38(%rbp),%eax
add    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1248 <sample+0x118>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sample>:
push   %rbx
sub    $0x30,%rsp
addsd  0xec3(%rip),%xmm0
addsd  0xec3(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
lea    0x18(%rsp),%rdi
call   1030 <modf@plt>
movapd %xmm0,0x20(%rsp)
lea    0x10(%rsp),%rdi
movsd  0x8(%rsp),%xmm0
call   1030 <modf@plt>
movsd  0xe9d(%rip),%xmm3
movapd 0x20(%rsp),%xmm5
movapd %xmm5,%xmm1
addsd  %xmm3,%xmm1
xorpd  %xmm4,%xmm4
movapd %xmm5,%xmm2
cmpltsd %xmm4,%xmm2
andpd  %xmm2,%xmm1
andnpd %xmm5,%xmm2
orpd   %xmm1,%xmm2
addsd  %xmm0,%xmm3
movapd %xmm0,%xmm1
cmpltsd %xmm4,%xmm1
andpd  %xmm1,%xmm3
andnpd %xmm0,%xmm1
orpd   %xmm3,%xmm1
movsd  0xe5d(%rip),%xmm0
addsd  %xmm0,%xmm2
addsd  %xmm0,%xmm1
movapd %xmm2,%xmm0
call   1040 <hypot@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
call   1050 <floor@plt>
mov    %rax,%rbx
and    $0x1f,%ebx
movsd  0x10(%rsp),%xmm0
call   1050 <floor@plt>
lea    (%rax,%rax,8),%ecx
lea    (%rax,%rcx,2),%eax
add    %ebx,%eax
xor    %ecx,%ecx
cmp    $0x13,%ebx
cmovae %ecx,%eax
movsd  0xe1a(%rip),%xmm0
ucomisd 0x8(%rsp),%xmm0
cmovbe %ecx,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @sample(double %0, double %1) {
%3 = alloca i32
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca i32
%10 = alloca i32
store double %0, double* %4
store double %1, double* %5
%11 = load double, double* %4
%12 = fadd double %11, 4.100000e+01
store double %12, double* %4
%13 = load double, double* %5
%14 = fadd double %13, 4.000000e+00
store double %14, double* %5
%15 = load double, double* %4
%16 = call double @modf(double %15, double* %6)
store double %16, double* %4
%17 = load double, double* %5
%18 = call double @modf(double %17, double* %7)
store double %18, double* %5
%19 = load double, double* %4
%20 = fcmp olt double %19, 0.000000e+00
br i1 %20, label %21, label %24
21: ; preds = %2
%22 = load double, double* %4
%23 = fadd double %22, 1.000000e+00
store double %23, double* %4
br label %24
24: ; preds = %21, %2
%25 = load double, double* %5
%26 = fcmp olt double %25, 0.000000e+00
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = load double, double* %5
%29 = fadd double %28, 1.000000e+00
store double %29, double* %5
br label %30
30: ; preds = %27, %24
%31 = load double, double* %4
%32 = fsub double %31, 5.000000e-01
%33 = load double, double* %5
%34 = fsub double %33, 5.000000e-01
%35 = call double @hypot(double %32, double %34)
store double %35, double* %8
%36 = load double, double* %6
%37 = call i64 @floor(double %36)
%38 = trunc i64 %37 to i32
%39 = and i32 %38, 31
store i32 %39, i32* %9
%40 = load double, double* %7
%41 = call i64 @floor(double %40)
%42 = trunc i64 %41 to i32
store i32 %42, i32* %10
%43 = load double, double* %8
%44 = fcmp olt double %43, 3.600000e-01
br i1 %44, label %45, label %53
45: ; preds = %30
%46 = load i32, i32* %9
%47 = icmp slt i32 %46, 19
br i1 %47, label %48, label %53
48: ; preds = %45
%49 = load i32, i32* %10
%50 = mul nsw i32 %49, 19
%51 = load i32, i32* %9
%52 = add nsw i32 %50, %51
store i32 %52, i32* %3
br label %54
53: ; preds = %45, %30
store i32 0, i32* %3
br label %54
54: ; preds = %53, %48
%55 = load i32, i32* %3
ret i32 %55
}

LLVM IR (-O2):
define i32 @sample(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = bitcast double* %3 to i8*
%6 = bitcast double* %4 to i8*
%7 = fadd double %0, 4.100000e+01
%8 = fadd double %1, 4.000000e+00
%9 = call double @modf(double %7, double* %3)
%10 = call double @modf(double %8, double* %4)
%11 = fcmp olt double %9, 0.000000e+00
%12 = fadd double %9, 1.000000e+00
%13 = select i1 %11, double %12, double %9
%14 = fcmp olt double %10, 0.000000e+00
%15 = fadd double %10, 1.000000e+00
%16 = select i1 %14, double %15, double %10
%17 = fadd double %13, -5.000000e-01
%18 = fadd double %16, -5.000000e-01
%19 = tail call double @hypot(double %17, double %18)
%20 = load double, double* %3
%21 = tail call i64 @floor(double %20)
%22 = trunc i64 %21 to i32
%23 = and i32 %22, 31
%24 = load double, double* %4
%25 = tail call i64 @floor(double %24)
%26 = fcmp olt double %19, 3.600000e-01
%27 = icmp ult i32 %23, 19
%28 = select i1 %26, i1 %27, i1 false
%29 = trunc i64 %25 to i32
%30 = mul nsw i32 %29, 19
%31 = add nsw i32 %30, %23
%32 = select i1 %28, i32 %31, i32 0
ret i32 %32
}