#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 is_available(int, int, int);
int num_available(int pos_x, int pos_y) {
  int to_return = 0;
  int a;
  for (a = 1; a < 10; a++) {
    int avail = is_available(pos_x, pos_y, a);
    if (avail == 1) {
      if (to_return == 0) {
        to_return = a;
      } else {
        to_return = -1;
        break;
      }
    }
  }
  if (to_return == 0) {
    to_return = -1;
  }
  return to_return;
}


x86 assembly (clang, -O0):
<num_available>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
cmpl   $0xa,-0x10(%rbp)
jge    118a <num_available+0x7a>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1030 <is_available@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    1177 <num_available+0x67>
cmpl   $0x0,-0xc(%rbp)
jne    1166 <num_available+0x56>
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1172 <num_available+0x62>
movl   $0xffffffff,-0xc(%rbp)
jmp    118a <num_available+0x7a>
jmp    1177 <num_available+0x67>
jmp    117c <num_available+0x6c>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    112c <num_available+0x1c>
cmpl   $0x0,-0xc(%rbp)
jne    119b <num_available+0x8b>
movl   $0xffffffff,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<num_available>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r14d
mov    %edi,%r12d
mov    $0x1,%ebp
mov    $0x1,%edx
call   1030 <is_available@plt>
mov    %eax,%ebx
mov    %r12d,%edi
mov    %r14d,%esi
mov    $0x2,%edx
call   1030 <is_available@plt>
cmp    $0x1,%ebx
jne    1153 <num_available+0x43>
mov    $0xffffffff,%ebx
cmp    $0x1,%eax
jne    115d <num_available+0x4d>
jmp    12e0 <num_available+0x1d0>
mov    $0x2,%ebp
cmp    $0x1,%eax
jne    117c <num_available+0x6c>
mov    %r12d,%edi
mov    %r14d,%esi
mov    $0x3,%edx
call   1030 <is_available@plt>
mov    $0xffffffff,%ebx
cmp    $0x1,%eax
jne    11b8 <num_available+0xa8>
jmp    12e0 <num_available+0x1d0>
mov    $0x3,%r15d
mov    %r12d,%edi
mov    %r14d,%esi
mov    $0x3,%edx
call   1030 <is_available@plt>
xor    %ebp,%ebp
cmp    $0x1,%eax
jne    11b8 <num_available+0xa8>
mov    %r12d,%edi
mov    %r14d,%esi
mov    $0x4,%edx
call   1030 <is_available@plt>
mov    $0xffffffff,%ebx
cmp    $0x1,%eax
jne    11e5 <num_available+0xd5>
jmp    12e0 <num_available+0x1d0>
mov    $0x4,%r15d
mov    %r12d,%edi
mov    %r14d,%esi
mov    $0x4,%edx
call   1030 <is_available@plt>
cmp    $0x1,%eax
jne    11e2 <num_available+0xd2>
mov    $0xffffffff,%ebx
test   %ebp,%ebp
jne    12e0 <num_available+0x1d0>
jmp    11e5 <num_available+0xd5>
mov    %ebp,%r15d
mov    %r12d,%edi
mov    %r14d,%esi
mov    $0x5,%edx
call   1030 <is_available@plt>
cmp    $0x1,%eax
jne    1227 <num_available+0x117>
mov    $0xffffffff,%ebx
test   %r15d,%r15d
jne    12e0 <num_available+0x1d0>
mov    %r12d,%edi
mov    %r14d,%esi
mov    $0x6,%edx
call   1030 <is_available@plt>
mov    $0x5,%ebp
cmp    $0x1,%eax
jne    1254 <num_available+0x144>
jmp    12e0 <num_available+0x1d0>
mov    $0x6,%ebp
mov    %r12d,%edi
mov    %r14d,%esi
mov    $0x6,%edx
call   1030 <is_available@plt>
cmp    $0x1,%eax
jne    1251 <num_available+0x141>
mov    $0xffffffff,%ebx
test   %r15d,%r15d
jne    12e0 <num_available+0x1d0>
jmp    1254 <num_available+0x144>
mov    %r15d,%ebp
mov    %r12d,%edi
mov    %r14d,%esi
mov    $0x7,%edx
call   1030 <is_available@plt>
cmp    $0x1,%eax
jne    128f <num_available+0x17f>
mov    $0xffffffff,%ebx
test   %ebp,%ebp
jne    12e0 <num_available+0x1d0>
mov    %r12d,%edi
mov    %r14d,%esi
mov    $0x8,%edx
call   1030 <is_available@plt>
mov    $0x7,%r15d
cmp    $0x1,%eax
jne    12b8 <num_available+0x1a8>
jmp    12e0 <num_available+0x1d0>
mov    $0x8,%r15d
mov    %r12d,%edi
mov    %r14d,%esi
mov    $0x8,%edx
call   1030 <is_available@plt>
cmp    $0x1,%eax
jne    12b5 <num_available+0x1a5>
mov    $0xffffffff,%ebx
test   %ebp,%ebp
jne    12e0 <num_available+0x1d0>
jmp    12b8 <num_available+0x1a8>
mov    %ebp,%r15d
mov    %r12d,%edi
mov    %r14d,%esi
mov    $0x9,%edx
call   1030 <is_available@plt>
cmp    $0x1,%eax
jne    12d7 <num_available+0x1c7>
neg    %r15d
sbb    %ebx,%ebx
or     $0x9,%ebx
jmp    12e0 <num_available+0x1d0>
cmp    $0x1,%r15d
sbb    %ebx,%ebx
or     %r15d,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @num_available(i32 %0, i32 %1) {
%3 = tail call i32 @is_available(i32 %0, i32 %1, i32 1)
%4 = icmp eq i32 %3, 1
%5 = tail call i32 @is_available(i32 %0, i32 %1, i32 2)
%6 = icmp eq i32 %5, 1
br i1 %4, label %7, label %8
7: ; preds = %2
br i1 %6, label %62, label %9
8: ; preds = %2
br i1 %6, label %9, label %13
9: ; preds = %8, %7
%10 = phi i32 [ 1, %7 ], [ 2, %8 ]
%11 = tail call i32 @is_available(i32 %0, i32 %1, i32 3)
%12 = icmp eq i32 %11, 1
br i1 %12, label %62, label %16
13: ; preds = %8
%14 = tail call i32 @is_available(i32 %0, i32 %1, i32 3)
%15 = icmp eq i32 %14, 1
br i1 %15, label %20, label %16
16: ; preds = %13, %9
%17 = phi i32 [ %10, %9 ], [ 0, %13 ]
%18 = tail call i32 @is_available(i32 %0, i32 %1, i32 4)
%19 = icmp eq i32 %18, 1
br i1 %19, label %23, label %25
20: ; preds = %13
%21 = tail call i32 @is_available(i32 %0, i32 %1, i32 4)
%22 = icmp eq i32 %21, 1
br i1 %22, label %62, label %25
23: ; preds = %16
%24 = icmp eq i32 %17, 0
br i1 %24, label %25, label %62
25: ; preds = %20, %23, %16
%26 = phi i32 [ %17, %16 ], [ 4, %23 ], [ 3, %20 ]
%27 = tail call i32 @is_available(i32 %0, i32 %1, i32 5)
%28 = icmp eq i32 %27, 1
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = icmp eq i32 %26, 0
br i1 %30, label %34, label %62
31: ; preds = %25
%32 = tail call i32 @is_available(i32 %0, i32 %1, i32 6)
%33 = icmp eq i32 %32, 1
br i1 %33, label %37, label %39
34: ; preds = %29
%35 = tail call i32 @is_available(i32 %0, i32 %1, i32 6)
%36 = icmp eq i32 %35, 1
br i1 %36, label %62, label %39
37: ; preds = %31
%38 = icmp eq i32 %26, 0
br i1 %38, label %39, label %62
39: ; preds = %34, %37, %31
%40 = phi i32 [ %26, %31 ], [ 6, %37 ], [ 5, %34 ]
%41 = tail call i32 @is_available(i32 %0, i32 %1, i32 7)
%42 = icmp eq i32 %41, 1
br i1 %42, label %43, label %45
43: ; preds = %39
%44 = icmp eq i32 %40, 0
br i1 %44, label %48, label %62
45: ; preds = %39
%46 = tail call i32 @is_available(i32 %0, i32 %1, i32 8)
%47 = icmp eq i32 %46, 1
br i1 %47, label %51, label %53
48: ; preds = %43
%49 = tail call i32 @is_available(i32 %0, i32 %1, i32 8)
%50 = icmp eq i32 %49, 1
br i1 %50, label %62, label %53
51: ; preds = %45
%52 = icmp eq i32 %40, 0
br i1 %52, label %53, label %62
53: ; preds = %48, %51, %45
%54 = phi i32 [ %40, %45 ], [ 8, %51 ], [ 7, %48 ]
%55 = tail call i32 @is_available(i32 %0, i32 %1, i32 9)
%56 = icmp eq i32 %55, 1
%57 = icmp eq i32 %54, 0
br i1 %56, label %58, label %60
58: ; preds = %53
%59 = select i1 %57, i32 9, i32 -1
br label %62
60: ; preds = %53
%61 = select i1 %57, i32 -1, i32 %54
br label %62
62: ; preds = %60, %58, %48, %34, %20, %7, %23, %29, %37, %43, %51, %9
%63 = phi i32 [ -1, %9 ], [ -1, %51 ], [ -1, %43 ], [ -1, %37 ], [ -1, %29 ], [ -1, %23 ], [ -1, %7 ], [ -1, %20 ], [ -1, %34 ], [ -1, %48 ], [ %59, %58 ], [ %61, %60 ]
ret i32 %63
}