#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__ ai_shouldsettle(int, int);
scalar_t__ data_atvertex(int, int);
scalar_t__ data_elementsremaining(int, int);
scalar_t__ data_poslegal(int);
int ai_cansettle(int player) {
  int i;
  for (i = 1; i < 64; i++) {
    if (data_elementsremaining(player, 1) && data_atvertex(player, i) == 0 &&
        data_poslegal(i) && ai_shouldsettle(player, i))
      return i;
  }
  return 0;
}


x86 assembly (clang, -O0):
<ai_cansettle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0x40,-0xc(%rbp)
jge    11cd <ai_cansettle+0x8d>
mov    -0x8(%rbp),%edi
mov    $0x1,%esi
call   1060 <data_elementsremaining@plt>
cmp    $0x0,%rax
je     11ba <ai_cansettle+0x7a>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <data_atvertex@plt>
cmp    $0x0,%rax
jne    11ba <ai_cansettle+0x7a>
mov    -0xc(%rbp),%edi
call   1050 <data_poslegal@plt>
cmp    $0x0,%rax
je     11ba <ai_cansettle+0x7a>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <ai_shouldsettle@plt>
cmp    $0x0,%rax
je     11ba <ai_cansettle+0x7a>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11d4 <ai_cansettle+0x94>
jmp    11bf <ai_cansettle+0x7f>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1152 <ai_cansettle+0x12>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ai_cansettle>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
mov    $0x1,%ebx
jmp    1158 <ai_cansettle+0x18>
nopl   0x0(%rax)
add    $0x1,%ebx
cmp    $0x40,%ebx
je     1193 <ai_cansettle+0x53>
mov    %ebp,%edi
mov    $0x1,%esi
call   1060 <data_elementsremaining@plt>
test   %rax,%rax
je     1150 <ai_cansettle+0x10>
mov    %ebp,%edi
mov    %ebx,%esi
call   1030 <data_atvertex@plt>
test   %rax,%rax
jne    1150 <ai_cansettle+0x10>
mov    %ebx,%edi
call   1050 <data_poslegal@plt>
test   %rax,%rax
je     1150 <ai_cansettle+0x10>
mov    %ebp,%edi
mov    %ebx,%esi
call   1040 <ai_shouldsettle@plt>
test   %rax,%rax
je     1150 <ai_cansettle+0x10>
jmp    1195 <ai_cansettle+0x55>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @ai_cansettle(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 1, i32* %4
br label %5
5: ; preds = %29, %1
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 64
br i1 %7, label %8, label %32
8: ; preds = %5
%9 = load i32, i32* %3
%10 = call i64 @data_elementsremaining(i32 %9, i32 1)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %28
12: ; preds = %8
%13 = load i32, i32* %3
%14 = load i32, i32* %4
%15 = call i64 @data_atvertex(i32 %13, i32 %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %28
17: ; preds = %12
%18 = load i32, i32* %4
%19 = call i64 @data_poslegal(i32 %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %28
21: ; preds = %17
%22 = load i32, i32* %3
%23 = load i32, i32* %4
%24 = call i64 @ai_shouldsettle(i32 %22, i32 %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %21
%27 = load i32, i32* %4
store i32 %27, i32* %2
br label %33
28: ; preds = %21, %17, %12, %8
br label %29
29: ; preds = %28
%30 = load i32, i32* %4
%31 = add nsw i32 %30, 1
store i32 %31, i32* %4
br label %5
32: ; preds = %5
store i32 0, i32* %2
br label %33
33: ; preds = %32, %26
%34 = load i32, i32* %2
ret i32 %34
}

LLVM IR (-O2):
define i32 @ai_cansettle(i32 %0) {
br label %2
2: ; preds = %1, %15
%3 = phi i32 [ 1, %1 ], [ %16, %15 ]
%4 = tail call i64 @data_elementsremaining(i32 %0, i32 1)
%5 = icmp eq i64 %4, 0
br i1 %5, label %15, label %6
6: ; preds = %2
%7 = tail call i64 @data_atvertex(i32 %0, i32 %3)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %6
%10 = tail call i64 @data_poslegal(i32 %3)
%11 = icmp eq i64 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = tail call i64 @ai_shouldsettle(i32 %0, i32 %3)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %2, %6, %9, %12
%16 = add nuw nsw i32 %3, 1
%17 = icmp eq i32 %16, 64
br i1 %17, label %18, label %2
18: ; preds = %15, %12
%19 = phi i32 [ %3, %12 ], [ 0, %15 ]
ret i32 %19
}