#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 */
short get_first_losing_move_4(int, int /*<<< orphan*/, int /*<<< orphan*/, int,
                              int, int, int, int);
int /*<<< orphan*/ printf(char *, short, short);
short test_get_first_losing_move_4() {
  short result, expected;
  short failed_test_count = 0;
  result = get_first_losing_move_4(9, 0, 0, 13, 24, 10, 15, 14);
  expected = -2;
  if (result != expected) {
    printf("\ntest_get_first_losing_move_4(): Expected %hi, got %hi for "
           "position (9, 0, 0, 13, 24, 10, 15, 14).",
           expected, result);
    failed_test_count++;
  }
  result = get_first_losing_move_4(12, 0, 0, 1, 10, 11, 5, 0);
  expected = 24;
  if (result != expected) {
    printf("\ntest_get_first_losing_move_4(): Expected %hi, got %hi for "
           "position (1, 0, 0, 13, 12, 10, 5, 0).",
           expected, result);
    failed_test_count++;
  }
  return failed_test_count;
}


x86 assembly (clang, -O0):
<test_get_first_losing_move_4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movw   $0x0,-0x6(%rbp)
mov    $0x9,%edi
xor    %edx,%edx
mov    $0xd,%ecx
mov    $0x18,%r8d
mov    $0xa,%r9d
mov    %edx,%esi
movl   $0xf,(%rsp)
movl   $0xe,0x8(%rsp)
call   1040 <get_first_losing_move_4@plt>
mov    %ax,-0x2(%rbp)
movw   $0xfffe,-0x4(%rbp)
movswl -0x2(%rbp),%eax
movswl -0x4(%rbp),%ecx
cmp    %ecx,%eax
je     1199 <test_get_first_losing_move_4+0x79>
mov    -0x4(%rbp),%ax
lea    0xe7f(%rip),%rdi
movswl %ax,%esi
movswl -0x2(%rbp),%edx
call   1030 <printf@plt>
mov    -0x6(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x6(%rbp)
mov    $0xc,%edi
xor    %edx,%edx
mov    $0x1,%ecx
mov    $0xa,%r8d
mov    $0xb,%r9d
mov    %edx,%esi
movl   $0x5,(%rsp)
movl   $0x0,0x8(%rsp)
call   1040 <get_first_losing_move_4@plt>
mov    %ax,-0x2(%rbp)
movw   $0x18,-0x4(%rbp)
movswl -0x2(%rbp),%eax
movswl -0x4(%rbp),%ecx
cmp    %ecx,%eax
je     1204 <test_get_first_losing_move_4+0xe4>
mov    -0x4(%rbp),%ax
lea    0xe77(%rip),%rdi
movswl %ax,%esi
movswl -0x2(%rbp),%edx
call   1030 <printf@plt>
mov    -0x6(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x6(%rbp)
movswl -0x6(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_get_first_losing_move_4>:
push   %rbx
xor    %ebx,%ebx
mov    $0x9,%edi
xor    %esi,%esi
xor    %edx,%edx
mov    $0xd,%ecx
mov    $0x18,%r8d
mov    $0xa,%r9d
push   $0xe
push   $0xf
call   1040 <get_first_losing_move_4@plt>
add    $0x10,%rsp
cmp    $0xfffe,%ax
je     1168 <test_get_first_losing_move_4+0x48>
movswl %ax,%edx
lea    0xea6(%rip),%rdi
mov    $0xfffffffe,%esi
call   1030 <printf@plt>
mov    $0x1,%bx
mov    $0xc,%edi
xor    %esi,%esi
xor    %edx,%edx
mov    $0x1,%ecx
mov    $0xa,%r8d
mov    $0xb,%r9d
push   $0x0
push   $0x5
call   1040 <get_first_losing_move_4@plt>
add    $0x10,%rsp
cmp    $0x18,%ax
je     11af <test_get_first_losing_move_4+0x8f>
movswl %ax,%edx
lea    0xec4(%rip),%rdi
mov    $0x18,%esi
call   1030 <printf@plt>
movzwl %bx,%ebx
add    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [99 x i8] c"\0Atest_get_first_losing_move_4(): Expected %hi, got %hi for position (9, 0, 0, 13, 24, 10, 15, 14).\00"
@.str.1 = [97 x i8] c"\0Atest_get_first_losing_move_4(): Expected %hi, got %hi for position (1, 0, 0, 13, 12, 10, 5, 0).\00"
define signext i16 @test_get_first_losing_move_4() {
%1 = alloca i16
%2 = alloca i16
%3 = alloca i16
store i16 0, i16* %3
%4 = call signext i16 @get_first_losing_move_4(i32 9, i32 0, i32 0, i32 13, i32 24, i32 10, i32 15, i32 14)
store i16 %4, i16* %1
store i16 -2, i16* %2
%5 = load i16, i16* %1
%6 = sext i16 %5 to i32
%7 = load i16, i16* %2
%8 = sext i16 %7 to i32
%9 = icmp ne i32 %6, %8
br i1 %9, label %10, label %16
10: ; preds = %0
%11 = load i16, i16* %2
%12 = load i16, i16* %1
%13 = call i32 @printf(i8* getelementptr inbounds ([99 x i8], [99 x i8]* @.str, i64 0, i64 0), i16 signext %11, i16 signext %12)
%14 = load i16, i16* %3
%15 = add i16 %14, 1
store i16 %15, i16* %3
br label %16
16: ; preds = %10, %0
%17 = call signext i16 @get_first_losing_move_4(i32 12, i32 0, i32 0, i32 1, i32 10, i32 11, i32 5, i32 0)
store i16 %17, i16* %1
store i16 24, i16* %2
%18 = load i16, i16* %1
%19 = sext i16 %18 to i32
%20 = load i16, i16* %2
%21 = sext i16 %20 to i32
%22 = icmp ne i32 %19, %21
br i1 %22, label %23, label %29
23: ; preds = %16
%24 = load i16, i16* %2
%25 = load i16, i16* %1
%26 = call i32 @printf(i8* getelementptr inbounds ([97 x i8], [97 x i8]* @.str.1, i64 0, i64 0), i16 signext %24, i16 signext %25)
%27 = load i16, i16* %3
%28 = add i16 %27, 1
store i16 %28, i16* %3
br label %29
29: ; preds = %23, %16
%30 = load i16, i16* %3
ret i16 %30
}

LLVM IR (-O2):
@.str = [99 x i8] c"\0Atest_get_first_losing_move_4(): Expected %hi, got %hi for position (9, 0, 0, 13, 24, 10, 15, 14).\00"
@.str.1 = [97 x i8] c"\0Atest_get_first_losing_move_4(): Expected %hi, got %hi for position (1, 0, 0, 13, 12, 10, 5, 0).\00"
define signext i16 @test_get_first_losing_move_4() {
%1 = tail call signext i16 @get_first_losing_move_4(i32 9, i32 0, i32 0, i32 13, i32 24, i32 10, i32 15, i32 14)
%2 = icmp eq i16 %1, -2
br i1 %2, label %5, label %3
3: ; preds = %0
%4 = tail call i32 @printf(i8* getelementptr inbounds ([99 x i8], [99 x i8]* @.str, i64 0, i64 0), i16 signext -2, i16 signext %1)
br label %5
5: ; preds = %3, %0
%6 = phi i16 [ 1, %3 ], [ 0, %0 ]
%7 = tail call signext i16 @get_first_losing_move_4(i32 12, i32 0, i32 0, i32 1, i32 10, i32 11, i32 5, i32 0)
%8 = icmp eq i16 %7, 24
br i1 %8, label %12, label %9
9: ; preds = %5
%10 = tail call i32 @printf(i8* getelementptr inbounds ([97 x i8], [97 x i8]* @.str.1, i64 0, i64 0), i16 signext 24, i16 signext %7)
%11 = add nuw nsw i16 %6, 1
br label %12
12: ; preds = %9, %5
%13 = phi i16 [ %11, %9 ], [ %6, %5 ]
ret i16 %13
}