#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 map_getcolvert(int);
int map_getrowvert(int);
int *ai_surroundingverts(int vert, int sur[3]) {
  sur[0] = sur[1] = sur[2] = 0;
  if (map_getrowvert(vert) % 2 == map_getcolvert(vert) % 2) {
    if ((vert - 11) % 12 != 0) {
      sur[0] = vert + 1;
    }
  } else if ((vert + 6) % 12 != 0) {
    sur[0] = vert - 1;
  }
  sur[1] = vert + 6;
  sur[2] = vert - 6;
  return sur;
}


x86 assembly (clang, -O0):
<ai_surroundingverts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x0,0x8(%rax)
mov    -0x10(%rbp),%rax
movl   $0x0,0x4(%rax)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x4(%rbp),%edi
call   1030 <map_getrowvert@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <map_getcolvert@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    -0x14(%rbp),%edx
cmp    %eax,%edx
jne    11a7 <ai_surroundingverts+0x87>
mov    -0x4(%rbp),%eax
sub    $0xb,%eax
mov    $0xc,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11a2 <ai_surroundingverts+0x82>
mov    -0x4(%rbp),%ecx
add    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    11cf <ai_surroundingverts+0xaf>
mov    -0x4(%rbp),%eax
add    $0x6,%eax
mov    $0xc,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11ca <ai_surroundingverts+0xaa>
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    11cf <ai_surroundingverts+0xaf>
mov    -0x4(%rbp),%ecx
add    $0x6,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x4(%rbp),%ecx
sub    $0x6,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ai_surroundingverts>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebx
movl   $0x0,0x8(%rsi)
movq   $0x0,(%rsi)
call   1030 <map_getrowvert@plt>
mov    %eax,%ebp
shr    $0x1f,%eax
add    %ebp,%eax
and    $0xfffffffe,%eax
sub    %eax,%ebp
mov    %ebx,%edi
call   1040 <map_getcolvert@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
imul   $0xaaaaaaab,%ebx,%ecx
cmp    %eax,%ebp
jne    117d <ai_surroundingverts+0x5d>
add    $0xd555554f,%ecx
ror    $0x2,%ecx
mov    $0x1,%eax
cmp    $0x15555555,%ecx
jae    1193 <ai_surroundingverts+0x73>
jmp    1198 <ai_surroundingverts+0x78>
add    $0x2aaaaaaa,%ecx
ror    $0x2,%ecx
mov    $0xffffffff,%eax
cmp    $0x15555555,%ecx
jb     1198 <ai_surroundingverts+0x78>
add    %ebx,%eax
mov    %eax,(%r14)
lea    0x6(%rbx),%eax
mov    %eax,0x4(%r14)
add    $0xfffffffa,%ebx
mov    %ebx,0x8(%r14)
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32* @ai_surroundingverts(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
store i32 %0, i32* %3
store i32* %1, i32** %4
%5 = load i32*, i32** %4
%6 = getelementptr inbounds i32, i32* %5, i64 2
store i32 0, i32* %6
%7 = load i32*, i32** %4
%8 = getelementptr inbounds i32, i32* %7, i64 1
store i32 0, i32* %8
%9 = load i32*, i32** %4
%10 = getelementptr inbounds i32, i32* %9, i64 0
store i32 0, i32* %10
%11 = load i32, i32* %3
%12 = call i32 @map_getrowvert(i32 %11)
%13 = srem i32 %12, 2
%14 = load i32, i32* %3
%15 = call i32 @map_getcolvert(i32 %14)
%16 = srem i32 %15, 2
%17 = icmp eq i32 %13, %16
br i1 %17, label %18, label %29
18: ; preds = %2
%19 = load i32, i32* %3
%20 = sub nsw i32 %19, 11
%21 = srem i32 %20, 12
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %18
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
%26 = load i32*, i32** %4
%27 = getelementptr inbounds i32, i32* %26, i64 0
store i32 %25, i32* %27
br label %28
28: ; preds = %23, %18
br label %40
29: ; preds = %2
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 6
%32 = srem i32 %31, 12
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %39
34: ; preds = %29
%35 = load i32, i32* %3
%36 = sub nsw i32 %35, 1
%37 = load i32*, i32** %4
%38 = getelementptr inbounds i32, i32* %37, i64 0
store i32 %36, i32* %38
br label %39
39: ; preds = %34, %29
br label %40
40: ; preds = %39, %28
%41 = load i32, i32* %3
%42 = add nsw i32 %41, 6
%43 = load i32*, i32** %4
%44 = getelementptr inbounds i32, i32* %43, i64 1
store i32 %42, i32* %44
%45 = load i32, i32* %3
%46 = sub nsw i32 %45, 6
%47 = load i32*, i32** %4
%48 = getelementptr inbounds i32, i32* %47, i64 2
store i32 %46, i32* %48
%49 = load i32*, i32** %4
ret i32* %49
}

LLVM IR (-O2):
define i32* @ai_surroundingverts(i32 %0, i32* returned writeonly %1) {
%3 = getelementptr inbounds i32, i32* %1, i64 2
store i32 0, i32* %3
%4 = getelementptr inbounds i32, i32* %1, i64 1
store i32 0, i32* %4
store i32 0, i32* %1
%5 = tail call i32 @map_getrowvert(i32 %0)
%6 = srem i32 %5, 2
%7 = tail call i32 @map_getcolvert(i32 %0)
%8 = srem i32 %7, 2
%9 = icmp eq i32 %6, %8
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = add nsw i32 %0, -11
%12 = srem i32 %11, 12
%13 = icmp eq i32 %12, 0
br i1 %13, label %21, label %18
14: ; preds = %2
%15 = add nsw i32 %0, 6
%16 = srem i32 %15, 12
%17 = icmp eq i32 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %14, %10
%19 = phi i32 [ 1, %10 ], [ -1, %14 ]
%20 = add nsw i32 %19, %0
store i32 %20, i32* %1
br label %21
21: ; preds = %18, %14, %10
%22 = add nsw i32 %0, 6
store i32 %22, i32* %4
%23 = add nsw i32 %0, -6
store i32 %23, i32* %3
ret i32* %1
}