#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 */
int abs(int);
int inHexagon(int size, int x, int y) {
  int result = 0;
  x = abs(x);
  y = abs(y);
  if (x < size / 2 && y < size / 4) {
    if (x < size / 4) {
      result = 1;
    } else {
      if (x < ((size / 2) - y)) {
        result = 1;
      }
    }
  }
  return (result);
}


x86 assembly (clang, -O0):
<inHexagon>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jge    11d6 <inHexagon+0xc6>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    11d6 <inHexagon+0xc6>
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    11a4 <inHexagon+0x94>
movl   $0x1,-0x10(%rbp)
jmp    11d1 <inHexagon+0xc1>
mov    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
sub    -0xc(%rbp),%ecx
cmp    %ecx,%eax
jge    11cc <inHexagon+0xbc>
movl   $0x1,-0x10(%rbp)
jmp    11d1 <inHexagon+0xc1>
jmp    11d6 <inHexagon+0xc6>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inHexagon>:
mov    %esi,%ecx
neg    %ecx
cmovs  %esi,%ecx
mov    %edx,%esi
neg    %esi
cmovs  %edx,%esi
mov    %edi,%edx
shr    $0x1f,%edx
add    %edi,%edx
sar    %edx
xor    %eax,%eax
cmp    %edx,%ecx
jge    1143 <inHexagon+0x43>
lea    0x3(%rdi),%r8d
test   %edi,%edi
cmovns %edi,%r8d
sar    $0x2,%r8d
cmp    %r8d,%esi
jge    1143 <inHexagon+0x43>
mov    $0x1,%eax
cmp    %r8d,%ecx
jl     1143 <inHexagon+0x43>
sub    %esi,%edx
xor    %eax,%eax
cmp    %edx,%ecx
setl   %al
ret

LLVM IR (-O0):
define i32 @inHexagon(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %7
%8 = load i32, i32* %5
%9 = call i32 @abs(i32 %8)
store i32 %9, i32* %5
%10 = load i32, i32* %6
%11 = call i32 @abs(i32 %10)
store i32 %11, i32* %6
%12 = load i32, i32* %5
%13 = load i32, i32* %4
%14 = sdiv i32 %13, 2
%15 = icmp slt i32 %12, %14
br i1 %15, label %16, label %37
16: ; preds = %3
%17 = load i32, i32* %6
%18 = load i32, i32* %4
%19 = sdiv i32 %18, 4
%20 = icmp slt i32 %17, %19
br i1 %20, label %21, label %37
21: ; preds = %16
%22 = load i32, i32* %5
%23 = load i32, i32* %4
%24 = sdiv i32 %23, 4
%25 = icmp slt i32 %22, %24
br i1 %25, label %26, label %27
26: ; preds = %21
store i32 1, i32* %7
br label %36
27: ; preds = %21
%28 = load i32, i32* %5
%29 = load i32, i32* %4
%30 = sdiv i32 %29, 2
%31 = load i32, i32* %6
%32 = sub nsw i32 %30, %31
%33 = icmp slt i32 %28, %32
br i1 %33, label %34, label %35
34: ; preds = %27
store i32 1, i32* %7
br label %35
35: ; preds = %34, %27
br label %36
36: ; preds = %35, %26
br label %37
37: ; preds = %36, %16, %3
%38 = load i32, i32* %7
ret i32 %38
}

LLVM IR (-O2):
define i32 @inHexagon(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32 @llvm.abs.i32(i32 %1, i1 true)
%5 = tail call i32 @llvm.abs.i32(i32 %2, i1 true)
%6 = sdiv i32 %0, 2
%7 = icmp slt i32 %4, %6
br i1 %7, label %8, label %17
8: ; preds = %3
%9 = sdiv i32 %0, 4
%10 = icmp slt i32 %5, %9
br i1 %10, label %11, label %17
11: ; preds = %8
%12 = icmp slt i32 %4, %9
br i1 %12, label %17, label %13
13: ; preds = %11
%14 = sub nsw i32 %6, %5
%15 = icmp slt i32 %4, %14
%16 = zext i1 %15 to i32
br label %17
17: ; preds = %13, %11, %8, %3
%18 = phi i32 [ 0, %8 ], [ 0, %3 ], [ 1, %11 ], [ %16, %13 ]
ret i32 %18
}