int *ai_surroundinghexes(int vert) {
  static int ret[3];
  int vnum = vert % 12;
  if (vnum < 6)
    ret[0] = vnum / 2 - 5 + 5 * (vert / 12);
  else if (vnum > 6 && vnum < 11)
    ret[0] = (vnum - 1) / 2 - 5 + 5 * (vert / 12);
  else
    ret[0] = -100;
  if (ret[0] != -100)
    ret[1] = ret[0] + 5;
  else
    ret[1] = -100;
  if (vnum < 5 && vnum > 0)
    ret[2] = (vnum - 1) / 2 - 2 + 5 * (vert / 12);
  else if (vnum > 5)
    ret[2] = vnum / 2 - 3 + 5 * (vert / 12);
  else
    ret[2] = -100;
  return ret;
}


x86 assembly (clang, -O0):
<ai_surroundinghexes>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xc,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
cmpl   $0x6,-0x8(%rbp)
jge    1150 <ai_surroundinghexes+0x50>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
sub    $0x5,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xc,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
imul   $0x5,%ecx,%ecx
add    %ecx,%eax
mov    %eax,0x2ed9(%rip)
jmp    11a7 <ai_surroundinghexes+0xa7>
cmpl   $0x6,-0x8(%rbp)
jle    1198 <ai_surroundinghexes+0x98>
cmpl   $0xb,-0x8(%rbp)
jge    1198 <ai_surroundinghexes+0x98>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
sub    $0x5,%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xc,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
imul   $0x5,%ecx,%ecx
add    %ecx,%eax
mov    %eax,0x2e91(%rip)
jmp    11a2 <ai_surroundinghexes+0xa2>
movl   $0xffffff9c,0x2e82(%rip)
ff ff ff
jmp    11a7 <ai_surroundinghexes+0xa7>
cmpl   $0xffffff9c,0x2e76(%rip)
je     11c8 <ai_surroundinghexes+0xc8>
mov    0x2e6a(%rip),%eax
add    $0x5,%eax
mov    %eax,0x2e65(%rip)
jmp    11d2 <ai_surroundinghexes+0xd2>
movl   $0xffffff9c,0x2e56(%rip)
ff ff ff
cmpl   $0x5,-0x8(%rbp)
jge    121a <ai_surroundinghexes+0x11a>
cmpl   $0x0,-0x8(%rbp)
jle    121a <ai_surroundinghexes+0x11a>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
sub    $0x2,%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xc,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
imul   $0x5,%ecx,%ecx
add    %ecx,%eax
mov    %eax,0x2e17(%rip)
jmp    1264 <ai_surroundinghexes+0x164>
cmpl   $0x5,-0x8(%rbp)
jle    1255 <ai_surroundinghexes+0x155>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
sub    $0x3,%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xc,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
imul   $0x5,%ecx,%ecx
add    %ecx,%eax
mov    %eax,0x2ddc(%rip)
jmp    125f <ai_surroundinghexes+0x15f>
movl   $0xffffff9c,0x2dcd(%rip)
ff ff ff
jmp    1264 <ai_surroundinghexes+0x164>
lea    0x2db9(%rip),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ai_surroundinghexes>:
movslq %edi,%rax
imul   $0x2aaaaaab,%rax,%rcx
mov    %rcx,%rsi
shr    $0x3f,%rsi
sar    $0x21,%rcx
lea    (%rcx,%rsi,1),%r8d
lea    0x0(,%r8,4),%edi
lea    (%rdi,%rdi,2),%edi
sub    %edi,%eax
cmp    $0x5,%eax
jg     1144 <ai_surroundinghexes+0x44>
mov    %eax,%edx
shr    $0x7,%dl
add    %al,%dl
sar    %dl
add    $0xfb,%dl
movsbl %dl,%edx
lea    (%rcx,%rsi,1),%edi
lea    (%rdi,%rdi,4),%edi
add    %edx,%edi
jmp    1161 <ai_surroundinghexes+0x61>
cmp    $0x6,%eax
je     1171 <ai_surroundinghexes+0x71>
cmp    $0xa,%eax
ja     1171 <ai_surroundinghexes+0x71>
lea    -0x1(%rax),%edx
shr    %edx
and    $0x7f,%edx
lea    (%rcx,%rsi,1),%edi
lea    (%rdi,%rdi,4),%edi
add    %edx,%edi
add    $0xfffffffb,%edi
mov    %edi,0x2ebd(%rip)
cmp    $0xffffff9c,%edi
je     117b <ai_surroundinghexes+0x7b>
add    $0x5,%edi
jmp    1180 <ai_surroundinghexes+0x80>
movl   $0xffffff9c,0x2ea9(%rip)
ff ff ff
mov    $0xffffff9c,%edi
mov    %edi,0x2ea2(%rip)
lea    -0x1(%rax),%edi
cmp    $0x3,%edi
ja     119d <ai_surroundinghexes+0x9d>
shr    %edi
add    %esi,%ecx
lea    (%rcx,%rcx,4),%eax
lea    (%rdi,%rax,1),%ecx
add    $0xfffffffe,%ecx
jmp    11b2 <ai_surroundinghexes+0xb2>
mov    $0xffffff9c,%ecx
cmp    $0x6,%eax
jl     11b2 <ai_surroundinghexes+0xb2>
shr    %eax
lea    (%r8,%r8,4),%ecx
add    %eax,%ecx
add    $0xfffffffd,%ecx
mov    %ecx,0x2e74(%rip)
lea    0x2e65(%rip),%rax
ret

LLVM IR (-O0):
@ai_surroundinghexes.ret = internal global [3 x i32] zeroinitializer
define i32* @ai_surroundinghexes(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = srem i32 %4, 12
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 6
br i1 %7, label %8, label %16
8: ; preds = %1
%9 = load i32, i32* %3
%10 = sdiv i32 %9, 2
%11 = sub nsw i32 %10, 5
%12 = load i32, i32* %2
%13 = sdiv i32 %12, 12
%14 = mul nsw i32 5, %13
%15 = add nsw i32 %11, %14
store i32 %15, i32* getelementptr inbounds ([3 x i32], [3 x i32]* @ai_surroundinghexes.ret, i64 0, i64 0)
br label %33
16: ; preds = %1
%17 = load i32, i32* %3
%18 = icmp sgt i32 %17, 6
br i1 %18, label %19, label %31
19: ; preds = %16
%20 = load i32, i32* %3
%21 = icmp slt i32 %20, 11
br i1 %21, label %22, label %31
22: ; preds = %19
%23 = load i32, i32* %3
%24 = sub nsw i32 %23, 1
%25 = sdiv i32 %24, 2
%26 = sub nsw i32 %25, 5
%27 = load i32, i32* %2
%28 = sdiv i32 %27, 12
%29 = mul nsw i32 5, %28
%30 = add nsw i32 %26, %29
store i32 %30, i32* getelementptr inbounds ([3 x i32], [3 x i32]* @ai_surroundinghexes.ret, i64 0, i64 0)
br label %32
31: ; preds = %19, %16
store i32 -100, i32* getelementptr inbounds ([3 x i32], [3 x i32]* @ai_surroundinghexes.ret, i64 0, i64 0)
br label %32
32: ; preds = %31, %22
br label %33
33: ; preds = %32, %8
%34 = load i32, i32* getelementptr inbounds ([3 x i32], [3 x i32]* @ai_surroundinghexes.ret, i64 0, i64 0)
%35 = icmp ne i32 %34, -100
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = load i32, i32* getelementptr inbounds ([3 x i32], [3 x i32]* @ai_surroundinghexes.ret, i64 0, i64 0)
%38 = add nsw i32 %37, 5
store i32 %38, i32* getelementptr inbounds ([3 x i32], [3 x i32]* @ai_surroundinghexes.ret, i64 0, i64 1)
br label %40
39: ; preds = %33
store i32 -100, i32* getelementptr inbounds ([3 x i32], [3 x i32]* @ai_surroundinghexes.ret, i64 0, i64 1)
br label %40
40: ; preds = %39, %36
%41 = load i32, i32* %3
%42 = icmp slt i32 %41, 5
br i1 %42, label %43, label %55
43: ; preds = %40
%44 = load i32, i32* %3
%45 = icmp sgt i32 %44, 0
br i1 %45, label %46, label %55
46: ; preds = %43
%47 = load i32, i32* %3
%48 = sub nsw i32 %47, 1
%49 = sdiv i32 %48, 2
%50 = sub nsw i32 %49, 2
%51 = load i32, i32* %2
%52 = sdiv i32 %51, 12
%53 = mul nsw i32 5, %52
%54 = add nsw i32 %50, %53
store i32 %54, i32* getelementptr inbounds ([3 x i32], [3 x i32]* @ai_surroundinghexes.ret, i64 0, i64 2)
br label %68
55: ; preds = %43, %40
%56 = load i32, i32* %3
%57 = icmp sgt i32 %56, 5
br i1 %57, label %58, label %66
58: ; preds = %55
%59 = load i32, i32* %3
%60 = sdiv i32 %59, 2
%61 = sub nsw i32 %60, 3
%62 = load i32, i32* %2
%63 = sdiv i32 %62, 12
%64 = mul nsw i32 5, %63
%65 = add nsw i32 %61, %64
store i32 %65, i32* getelementptr inbounds ([3 x i32], [3 x i32]* @ai_surroundinghexes.ret, i64 0, i64 2)
br label %67
66: ; preds = %55
store i32 -100, i32* getelementptr inbounds ([3 x i32], [3 x i32]* @ai_surroundinghexes.ret, i64 0, i64 2)
br label %67
67: ; preds = %66, %58
br label %68
68: ; preds = %67, %46
ret i32* getelementptr inbounds ([3 x i32], [3 x i32]* @ai_surroundinghexes.ret, i64 0, i64 0)
}

LLVM IR (-O2):
@ai_surroundinghexes.ret = internal global [3 x i32] zeroinitializer
define i32* @ai_surroundinghexes(i32 %0) {
%2 = srem i32 %0, 12
%3 = sdiv i32 %0, 12
%4 = icmp slt i32 %2, 6
br i1 %4, label %5, label %13
5: ; preds = %1
%6 = trunc i32 %2 to i8
%7 = sdiv i8 %6, 2
%8 = add nsw i8 %7, -5
%9 = sext i8 %8 to i32
%10 = sdiv i32 %0, 12
%11 = mul nsw i32 %10, 5
%12 = add nsw i32 %11, %9
br label %26
13: ; preds = %1
%14 = icmp ne i32 %2, 6
%15 = icmp ult i32 %2, 11
%16 = and i1 %14, %15
br i1 %16, label %17, label %25
17: ; preds = %13
%18 = add nuw nsw i32 %2, 255
%19 = lshr i32 %18, 1
%20 = and i32 %19, 127
%21 = sdiv i32 %0, 12
%22 = mul nsw i32 %21, 5
%23 = add nsw i32 %22, -5
%24 = add nsw i32 %23, %20
br label %26
25: ; preds = %13
store i32 -100, i32* getelementptr inbounds ([3 x i32], [3 x i32]* @ai_surroundinghexes.ret, i64 0, i64 0)
br label %30
26: ; preds = %17, %5
%27 = phi i32 [ %24, %17 ], [ %12, %5 ]
store i32 %27, i32* getelementptr inbounds ([3 x i32], [3 x i32]* @ai_surroundinghexes.ret, i64 0, i64 0)
%28 = icmp eq i32 %27, -100
%29 = add nsw i32 %27, 5
br i1 %28, label %30, label %31
30: ; preds = %25, %26
br label %31
31: ; preds = %26, %30
%32 = phi i32 [ -100, %30 ], [ %29, %26 ]
store i32 %32, i32* getelementptr inbounds ([3 x i32], [3 x i32]* @ai_surroundinghexes.ret, i64 0, i64 1)
%33 = add nsw i32 %2, -1
%34 = icmp ult i32 %33, 4
br i1 %34, label %35, label %41
35: ; preds = %31
%36 = lshr i32 %33, 1
%37 = sdiv i32 %0, 12
%38 = mul nsw i32 %37, 5
%39 = add nsw i32 %38, -2
%40 = add nsw i32 %39, %36
br label %48
41: ; preds = %31
%42 = icmp sgt i32 %2, 5
br i1 %42, label %43, label %48
43: ; preds = %41
%44 = lshr i32 %2, 1
%45 = mul nsw i32 %3, 5
%46 = add nsw i32 %45, -3
%47 = add nsw i32 %46, %44
br label %48
48: ; preds = %41, %43, %35
%49 = phi i32 [ %47, %43 ], [ %40, %35 ], [ -100, %41 ]
store i32 %49, i32* getelementptr inbounds ([3 x i32], [3 x i32]* @ai_surroundinghexes.ret, i64 0, i64 2)
ret i32* getelementptr inbounds ([3 x i32], [3 x i32]* @ai_surroundinghexes.ret, i64 0, i64 0)
}