#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__ data_atvertex(int, int);
int data_playeratvertex(int vertex) {
  int p;
  for (p = 0; p < 4; p++)
    if (data_atvertex(p, vertex) > 0)
      return p;
  return -1;
}


x86 assembly (clang, -O0):
<data_playeratvertex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jge    115f <data_playeratvertex+0x4f>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <data_atvertex@plt>
cmp    $0x0,%rax
jle    114c <data_playeratvertex+0x3c>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1166 <data_playeratvertex+0x56>
jmp    1151 <data_playeratvertex+0x41>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1122 <data_playeratvertex+0x12>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<data_playeratvertex>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
xor    %ebp,%ebp
xor    %edi,%edi
mov    %ebx,%esi
call   1030 <data_atvertex@plt>
test   %rax,%rax
jg     116c <data_playeratvertex+0x5c>
mov    $0x1,%ebp
mov    $0x1,%edi
mov    %ebx,%esi
call   1030 <data_atvertex@plt>
test   %rax,%rax
jg     116c <data_playeratvertex+0x5c>
mov    $0x2,%ebp
mov    $0x2,%edi
mov    %ebx,%esi
call   1030 <data_atvertex@plt>
test   %rax,%rax
jg     116c <data_playeratvertex+0x5c>
mov    $0x3,%edi
mov    %ebx,%esi
call   1030 <data_atvertex@plt>
xor    %ecx,%ecx
test   %rax,%rax
setg   %cl
lea    -0x1(,%rcx,4),%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @data_playeratvertex(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %16, %1
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 4
br i1 %7, label %8, label %19
8: ; preds = %5
%9 = load i32, i32* %4
%10 = load i32, i32* %3
%11 = call i64 @data_atvertex(i32 %9, i32 %10)
%12 = icmp sgt i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = load i32, i32* %4
store i32 %14, i32* %2
br label %20
15: ; preds = %8
br label %16
16: ; preds = %15
%17 = load i32, i32* %4
%18 = add nsw i32 %17, 1
store i32 %18, i32* %4
br label %5
19: ; preds = %5
store i32 -1, i32* %2
br label %20
20: ; preds = %19, %13
%21 = load i32, i32* %2
ret i32 %21
}

LLVM IR (-O2):
define i32 @data_playeratvertex(i32 %0) {
%2 = tail call i64 @data_atvertex(i32 0, i32 %0)
%3 = icmp sgt i64 %2, 0
br i1 %3, label %14, label %4
4: ; preds = %1
%5 = tail call i64 @data_atvertex(i32 1, i32 %0)
%6 = icmp sgt i64 %5, 0
br i1 %6, label %14, label %7
7: ; preds = %4
%8 = tail call i64 @data_atvertex(i32 2, i32 %0)
%9 = icmp sgt i64 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %7
%11 = tail call i64 @data_atvertex(i32 3, i32 %0)
%12 = icmp sgt i64 %11, 0
%13 = select i1 %12, i32 3, i32 -1
br label %14
14: ; preds = %10, %7, %4, %1
%15 = phi i32 [ 0, %1 ], [ 1, %4 ], [ 2, %7 ], [ %13, %10 ]
ret i32 %15
}