#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 /*<<< orphan*/ ai_surroundingverts(int, int *);
int /*<<< orphan*/ map_islegalvert(int);
int road_areadjacent(int pos1, int pos2) {
  if (!map_islegalvert(pos1) || !map_islegalvert(pos2))
    return 0;
  int surrounding[3];
  ai_surroundingverts(pos1, surrounding);
  int i;
  for (i = 0; i < 3; i++) {
    if (surrounding[i] == pos2)
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<road_areadjacent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <map_islegalvert@plt>
cmp    $0x0,%eax
je     1150 <road_areadjacent+0x30>
mov    -0xc(%rbp),%edi
call   1040 <map_islegalvert@plt>
cmp    $0x0,%eax
jne    115c <road_areadjacent+0x3c>
movl   $0x0,-0x4(%rbp)
jmp    11b0 <road_areadjacent+0x90>
mov    -0x8(%rbp),%edi
lea    -0x18(%rbp),%rsi
call   1030 <ai_surroundingverts@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    11a9 <road_areadjacent+0x89>
movslq -0x1c(%rbp),%rax
mov    -0x18(%rbp,%rax,4),%eax
cmp    -0xc(%rbp),%eax
jne    1196 <road_areadjacent+0x76>
movl   $0x1,-0x4(%rbp)
jmp    11b0 <road_areadjacent+0x90>
jmp    119b <road_areadjacent+0x7b>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116f <road_areadjacent+0x4f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<road_areadjacent>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%r14d
mov    %edi,%ebp
call   1040 <map_islegalvert@plt>
xor    %ebx,%ebx
test   %eax,%eax
je     116f <road_areadjacent+0x4f>
mov    %r14d,%edi
call   1040 <map_islegalvert@plt>
test   %eax,%eax
je     116f <road_areadjacent+0x4f>
lea    0x4(%rsp),%rsi
mov    %ebp,%edi
call   1030 <ai_surroundingverts@plt>
cmp    %r14d,0x4(%rsp)
sete   %al
cmp    %r14d,0x8(%rsp)
sete   %cl
or     %al,%cl
cmp    %r14d,0xc(%rsp)
sete   %al
or     %cl,%al
movzbl %al,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @road_areadjacent(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [3 x i32]
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%8 = load i32, i32* %4
%9 = call i32 @map_islegalvert(i32 %8)
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i32, i32* %5
%13 = call i32 @map_islegalvert(i32 %12)
%14 = icmp ne i32 %13, 0
br i1 %14, label %16, label %15
15: ; preds = %11, %2
store i32 0, i32* %3
br label %36
16: ; preds = %11
%17 = load i32, i32* %4
%18 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%19 = call i32 @ai_surroundingverts(i32 %17, i32* %18)
store i32 0, i32* %7
br label %20
20: ; preds = %32, %16
%21 = load i32, i32* %7
%22 = icmp slt i32 %21, 3
br i1 %22, label %23, label %35
23: ; preds = %20
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 %25
%27 = load i32, i32* %26
%28 = load i32, i32* %5
%29 = icmp eq i32 %27, %28
br i1 %29, label %30, label %31
30: ; preds = %23
store i32 1, i32* %3
br label %36
31: ; preds = %23
br label %32
32: ; preds = %31
%33 = load i32, i32* %7
%34 = add nsw i32 %33, 1
store i32 %34, i32* %7
br label %20
35: ; preds = %20
store i32 0, i32* %3
br label %36
36: ; preds = %35, %30, %15
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
define i32 @road_areadjacent(i32 %0, i32 %1) {
%3 = alloca [3 x i32]
%4 = tail call i32 @map_islegalvert(i32 %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %24, label %6
6: ; preds = %2
%7 = tail call i32 @map_islegalvert(i32 %1)
%8 = icmp eq i32 %7, 0
br i1 %8, label %24, label %9
9: ; preds = %6
%10 = bitcast [3 x i32]* %3 to i8*
%11 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 0
%12 = call i32 @ai_surroundingverts(i32 %0, i32* %11)
%13 = load i32, i32* %11
%14 = icmp eq i32 %13, %1
%15 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 1
%16 = load i32, i32* %15
%17 = icmp eq i32 %16, %1
%18 = select i1 %14, i1 true, i1 %17
%19 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 2
%20 = load i32, i32* %19
%21 = icmp eq i32 %20, %1
%22 = select i1 %18, i1 true, i1 %21
%23 = zext i1 %22 to i32
br label %24
24: ; preds = %2, %6, %9
%25 = phi i32 [ %23, %9 ], [ 0, %6 ], [ 0, %2 ]
ret i32 %25
}