#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*/ add_output(char *);
int /*<<< orphan*/ create_next_move();
int get_captured_now(int **);
int get_nr_of_liberties(int);
int get_size_of_worm(int);
scalar_t__ get_vertex(int, int);
int get_worm_nr(int, int);
int /*<<< orphan*/ is_color_valid(char *, int *);
scalar_t__ is_move_ko(int, int, int);
scalar_t__ is_vertex_pass(char *);
int /*<<< orphan*/ is_vertex_valid(char *, int *, int *);
int /*<<< orphan*/ push_move();
int remove_stones(int);
int /*<<< orphan*/ scan_board_1();
int /*<<< orphan*/ set_move_captured_stones(int **);
int /*<<< orphan*/ set_move_ko(int, int);
int /*<<< orphan*/ set_move_pass(int);
int /*<<< orphan*/ set_move_vertex(int, int, int);
int /*<<< orphan*/ set_output_error();
int /*<<< orphan*/ set_vertex(int, int, int);
void gtp_play(int gtp_argc, char gtp_argv[][20]) {
  int color;
  int i, j;
  int nr_of_removed_stones;
  int group_nr;
  int nr_of_liberties;
  int group_size;
  int captured_now[21 * 21][2];
  if (!is_color_valid(gtp_argv[0], &color)) {
    set_output_error();
    add_output("invalid color");
    return;
  }
  if (is_vertex_pass(gtp_argv[1])) {
    create_next_move();
    set_move_pass(color);
    push_move();
    return;
  }
  if (!is_vertex_valid(gtp_argv[1], &i, &j)) {
    set_output_error();
    add_output("invalid coordinate");
    return;
  }
  if (get_vertex(i, j) != 0) {
    set_output_error();
    add_output("illegal move");
    return;
  }
  if (is_move_ko(color, i, j)) {
    set_output_error();
    add_output("illegal move");
    return;
  }
  set_vertex(color, i, j);
  scan_board_1();
  nr_of_removed_stones = remove_stones(color * -1);
  if (nr_of_removed_stones > 0) {
    scan_board_1();
  }
  group_nr = get_worm_nr(i, j);
  nr_of_liberties = get_nr_of_liberties(group_nr);
  group_size = get_size_of_worm(group_nr);
  if (nr_of_liberties == 0) {
    set_vertex(0, i, j);
    set_output_error();
    add_output("illegal move");
    return;
  }
  nr_of_removed_stones = get_captured_now(captured_now);
  create_next_move();
  set_move_vertex(color, i, j);
  set_move_captured_stones(captured_now);
  if (nr_of_removed_stones == 1 && group_size == 1 && nr_of_liberties == 1) {
    set_move_ko(captured_now[0][0], captured_now[0][1]);
  }
  push_move();
  return;
}


x86 assembly (clang, -O0):
<gtp_play>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe00,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1060 <is_color_valid@plt>
cmp    $0x0,%eax
jne    1280 <gtp_play+0x40>
mov    $0x0,%al
call   10f0 <set_output_error@plt>
lea    0xd8a(%rip),%rdi
call   1160 <add_output@plt>
jmp    1430 <gtp_play+0x1f0>
mov    -0x10(%rbp),%rdi
add    $0x14,%rdi
call   1030 <is_vertex_pass@plt>
cmp    $0x0,%rax
je     12b2 <gtp_play+0x72>
mov    $0x0,%al
call   1080 <create_next_move@plt>
mov    -0x14(%rbp),%edi
call   10c0 <set_move_pass@plt>
mov    $0x0,%al
call   1100 <push_move@plt>
jmp    1430 <gtp_play+0x1f0>
mov    -0x10(%rbp),%rdi
add    $0x14,%rdi
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
call   1040 <is_vertex_valid@plt>
cmp    $0x0,%eax
jne    12e8 <gtp_play+0xa8>
mov    $0x0,%al
call   10f0 <set_output_error@plt>
lea    0xd30(%rip),%rdi
call   1160 <add_output@plt>
jmp    1430 <gtp_play+0x1f0>
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1090 <get_vertex@plt>
cmp    $0x0,%rax
je     1315 <gtp_play+0xd5>
mov    $0x0,%al
call   10f0 <set_output_error@plt>
lea    0xd16(%rip),%rdi
call   1160 <add_output@plt>
jmp    1430 <gtp_play+0x1f0>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1150 <is_move_ko@plt>
cmp    $0x0,%rax
je     1345 <gtp_play+0x105>
mov    $0x0,%al
call   10f0 <set_output_error@plt>
lea    0xce6(%rip),%rdi
call   1160 <add_output@plt>
jmp    1430 <gtp_play+0x1f0>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   10d0 <set_vertex@plt>
mov    $0x0,%al
call   10a0 <scan_board_1@plt>
imul   $0xffffffff,-0x14(%rbp),%edi
call   1070 <remove_stones@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jle    1377 <gtp_play+0x137>
mov    $0x0,%al
call   10a0 <scan_board_1@plt>
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1050 <get_worm_nr@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
call   10b0 <get_nr_of_liberties@plt>
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%edi
call   10e0 <get_size_of_worm@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x28(%rbp)
jne    13ca <gtp_play+0x18a>
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
xor    %edi,%edi
call   10d0 <set_vertex@plt>
mov    $0x0,%al
call   10f0 <set_output_error@plt>
lea    0xc61(%rip),%rdi
call   1160 <add_output@plt>
jmp    1430 <gtp_play+0x1f0>
lea    -0xe00(%rbp),%rdi
call   1110 <get_captured_now@plt>
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   1080 <create_next_move@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1120 <set_move_vertex@plt>
lea    -0xe00(%rbp),%rdi
call   1130 <set_move_captured_stones@plt>
cmpl   $0x1,-0x20(%rbp)
jne    1429 <gtp_play+0x1e9>
cmpl   $0x1,-0x2c(%rbp)
jne    1429 <gtp_play+0x1e9>
cmpl   $0x1,-0x28(%rbp)
jne    1429 <gtp_play+0x1e9>
mov    -0xe00(%rbp),%edi
mov    -0xdfc(%rbp),%esi
call   1140 <set_move_ko@plt>
mov    $0x0,%al
call   1100 <push_move@plt>
add    $0xe00,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gtp_play>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0xdd8,%rsp
mov    %rsi,%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <is_color_valid@plt>
test   %eax,%eax
je     128b <gtp_play+0x4b>
add    $0x14,%rbx
mov    %rbx,%rdi
call   1030 <is_vertex_pass@plt>
test   %rax,%rax
je     129b <gtp_play+0x5b>
xor    %eax,%eax
call   1080 <create_next_move@plt>
mov    0xc(%rsp),%edi
call   10c0 <set_move_pass@plt>
xor    %eax,%eax
call   1100 <push_move@plt>
jmp    12fc <gtp_play+0xbc>
xor    %eax,%eax
call   10f0 <set_output_error@plt>
lea    0xd67(%rip),%rdi
jmp    12f7 <gtp_play+0xb7>
lea    0x8(%rsp),%rsi
lea    0x4(%rsp),%rdx
mov    %rbx,%rdi
call   1040 <is_vertex_valid@plt>
test   %eax,%eax
je     12e9 <gtp_play+0xa9>
mov    0x8(%rsp),%edi
mov    0x4(%rsp),%esi
call   1090 <get_vertex@plt>
test   %rax,%rax
jne    12d9 <gtp_play+0x99>
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
mov    0x4(%rsp),%edx
call   1150 <is_move_ko@plt>
test   %rax,%rax
je     130a <gtp_play+0xca>
xor    %eax,%eax
call   10f0 <set_output_error@plt>
lea    0xd3a(%rip),%rdi
jmp    12f7 <gtp_play+0xb7>
xor    %eax,%eax
call   10f0 <set_output_error@plt>
lea    0xd17(%rip),%rdi
call   1160 <add_output@plt>
add    $0xdd8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
mov    0x4(%rsp),%edx
call   10d0 <set_vertex@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   10a0 <scan_board_1@plt>
sub    0xc(%rsp),%ebx
mov    %ebx,%edi
call   1070 <remove_stones@plt>
test   %eax,%eax
jle    133a <gtp_play+0xfa>
xor    %eax,%eax
call   10a0 <scan_board_1@plt>
mov    0x8(%rsp),%edi
mov    0x4(%rsp),%esi
call   1050 <get_worm_nr@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   10b0 <get_nr_of_liberties@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   10e0 <get_size_of_worm@plt>
test   %ebx,%ebx
je     13bd <gtp_play+0x17d>
mov    %eax,%r15d
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   1110 <get_captured_now@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1080 <create_next_move@plt>
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
mov    0x4(%rsp),%edx
call   1120 <set_move_vertex@plt>
mov    %r14,%rdi
call   1130 <set_move_captured_stones@plt>
cmp    $0x1,%ebp
jne    1282 <gtp_play+0x42>
cmp    $0x1,%r15d
jne    1282 <gtp_play+0x42>
cmp    $0x1,%ebx
jne    1282 <gtp_play+0x42>
mov    0x10(%rsp),%edi
mov    0x14(%rsp),%esi
call   1140 <set_move_ko@plt>
jmp    1282 <gtp_play+0x42>
mov    0x8(%rsp),%esi
mov    0x4(%rsp),%edx
xor    %edi,%edi
call   10d0 <set_vertex@plt>
jmp    12d9 <gtp_play+0x99>

LLVM IR (-O0):
@.str = [14 x i8] c"invalid color\00"
@.str.1 = [19 x i8] c"invalid coordinate\00"
@.str.2 = [13 x i8] c"illegal move\00"
define void @gtp_play(i32 %0, [20 x i8]* %1) {
%3 = alloca i32
%4 = alloca [20 x i8]*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [441 x [2 x i32]]
store i32 %0, i32* %3
store [20 x i8]* %1, [20 x i8]** %4
%13 = load [20 x i8]*, [20 x i8]** %4
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %13, i64 0
%15 = getelementptr inbounds [20 x i8], [20 x i8]* %14, i64 0, i64 0
%16 = call i32 @is_color_valid(i8* %15, i32* %5)
%17 = icmp ne i32 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %2
%19 = call i32 (...) @set_output_error()
%20 = call i32 @add_output(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %117
21: ; preds = %2
%22 = load [20 x i8]*, [20 x i8]** %4
%23 = getelementptr inbounds [20 x i8], [20 x i8]* %22, i64 1
%24 = getelementptr inbounds [20 x i8], [20 x i8]* %23, i64 0, i64 0
%25 = call i64 @is_vertex_pass(i8* %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %32
27: ; preds = %21
%28 = call i32 (...) @create_next_move()
%29 = load i32, i32* %5
%30 = call i32 @set_move_pass(i32 %29)
%31 = call i32 (...) @push_move()
br label %117
32: ; preds = %21
%33 = load [20 x i8]*, [20 x i8]** %4
%34 = getelementptr inbounds [20 x i8], [20 x i8]* %33, i64 1
%35 = getelementptr inbounds [20 x i8], [20 x i8]* %34, i64 0, i64 0
%36 = call i32 @is_vertex_valid(i8* %35, i32* %6, i32* %7)
%37 = icmp ne i32 %36, 0
br i1 %37, label %41, label %38
38: ; preds = %32
%39 = call i32 (...) @set_output_error()
%40 = call i32 @add_output(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %117
41: ; preds = %32
%42 = load i32, i32* %6
%43 = load i32, i32* %7
%44 = call i64 @get_vertex(i32 %42, i32 %43)
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %41
%47 = call i32 (...) @set_output_error()
%48 = call i32 @add_output(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %117
49: ; preds = %41
%50 = load i32, i32* %5
%51 = load i32, i32* %6
%52 = load i32, i32* %7
%53 = call i64 @is_move_ko(i32 %50, i32 %51, i32 %52)
%54 = icmp ne i64 %53, 0
br i1 %54, label %55, label %58
55: ; preds = %49
%56 = call i32 (...) @set_output_error()
%57 = call i32 @add_output(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %117
58: ; preds = %49
%59 = load i32, i32* %5
%60 = load i32, i32* %6
%61 = load i32, i32* %7
%62 = call i32 @set_vertex(i32 %59, i32 %60, i32 %61)
%63 = call i32 (...) @scan_board_1()
%64 = load i32, i32* %5
%65 = mul nsw i32 %64, -1
%66 = call i32 @remove_stones(i32 %65)
store i32 %66, i32* %8
%67 = load i32, i32* %8
%68 = icmp sgt i32 %67, 0
br i1 %68, label %69, label %71
69: ; preds = %58
%70 = call i32 (...) @scan_board_1()
br label %71
71: ; preds = %69, %58
%72 = load i32, i32* %6
%73 = load i32, i32* %7
%74 = call i32 @get_worm_nr(i32 %72, i32 %73)
store i32 %74, i32* %9
%75 = load i32, i32* %9
%76 = call i32 @get_nr_of_liberties(i32 %75)
store i32 %76, i32* %10
%77 = load i32, i32* %9
%78 = call i32 @get_size_of_worm(i32 %77)
store i32 %78, i32* %11
%79 = load i32, i32* %10
%80 = icmp eq i32 %79, 0
br i1 %80, label %81, label %87
81: ; preds = %71
%82 = load i32, i32* %6
%83 = load i32, i32* %7
%84 = call i32 @set_vertex(i32 0, i32 %82, i32 %83)
%85 = call i32 (...) @set_output_error()
%86 = call i32 @add_output(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %117
87: ; preds = %71
%88 = getelementptr inbounds [441 x [2 x i32]], [441 x [2 x i32]]* %12, i64 0, i64 0
%89 = bitcast [2 x i32]* %88 to i32**
%90 = call i32 @get_captured_now(i32** %89)
store i32 %90, i32* %8
%91 = call i32 (...) @create_next_move()
%92 = load i32, i32* %5
%93 = load i32, i32* %6
%94 = load i32, i32* %7
%95 = call i32 @set_move_vertex(i32 %92, i32 %93, i32 %94)
%96 = getelementptr inbounds [441 x [2 x i32]], [441 x [2 x i32]]* %12, i64 0, i64 0
%97 = bitcast [2 x i32]* %96 to i32**
%98 = call i32 @set_move_captured_stones(i32** %97)
%99 = load i32, i32* %8
%100 = icmp eq i32 %99, 1
br i1 %100, label %101, label %115
101: ; preds = %87
%102 = load i32, i32* %11
%103 = icmp eq i32 %102, 1
br i1 %103, label %104, label %115
104: ; preds = %101
%105 = load i32, i32* %10
%106 = icmp eq i32 %105, 1
br i1 %106, label %107, label %115
107: ; preds = %104
%108 = getelementptr inbounds [441 x [2 x i32]], [441 x [2 x i32]]* %12, i64 0, i64 0
%109 = getelementptr inbounds [2 x i32], [2 x i32]* %108, i64 0, i64 0
%110 = load i32, i32* %109
%111 = getelementptr inbounds [441 x [2 x i32]], [441 x [2 x i32]]* %12, i64 0, i64 0
%112 = getelementptr inbounds [2 x i32], [2 x i32]* %111, i64 0, i64 1
%113 = load i32, i32* %112
%114 = call i32 @set_move_ko(i32 %110, i32 %113)
br label %115
115: ; preds = %107, %104, %101, %87
%116 = call i32 (...) @push_move()
br label %117
117: ; preds = %115, %81, %55, %46, %38, %27, %18
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"invalid color\00"
@.str.1 = [19 x i8] c"invalid coordinate\00"
@.str.2 = [13 x i8] c"illegal move\00"
define void @gtp_play(i32 %0, [20 x i8]* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [441 x [2 x i32]]
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = bitcast [441 x [2 x i32]]* %6 to i8*
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%12 = call i32 @is_color_valid(i8* %11, i32* %3)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = call i32 (...) @set_output_error()
%16 = call i32 @add_output(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %96
17: ; preds = %2
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 1, i64 0
%19 = call i64 @is_vertex_pass(i8* %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %26, label %21
21: ; preds = %17
%22 = call i32 (...) @create_next_move()
%23 = load i32, i32* %3
%24 = call i32 @set_move_pass(i32 %23)
%25 = call i32 (...) @push_move()
br label %96
26: ; preds = %17
%27 = call i32 @is_vertex_valid(i8* %18, i32* %4, i32* %5)
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = call i32 (...) @set_output_error()
%31 = call i32 @add_output(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %96
32: ; preds = %26
%33 = load i32, i32* %4
%34 = load i32, i32* %5
%35 = call i64 @get_vertex(i32 %33, i32 %34)
%36 = icmp eq i64 %35, 0
br i1 %36, label %40, label %37
37: ; preds = %32
%38 = call i32 (...) @set_output_error()
%39 = call i32 @add_output(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %96
40: ; preds = %32
%41 = load i32, i32* %3
%42 = load i32, i32* %4
%43 = load i32, i32* %5
%44 = call i64 @is_move_ko(i32 %41, i32 %42, i32 %43)
%45 = icmp eq i64 %44, 0
br i1 %45, label %49, label %46
46: ; preds = %40
%47 = call i32 (...) @set_output_error()
%48 = call i32 @add_output(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %96
49: ; preds = %40
%50 = load i32, i32* %3
%51 = load i32, i32* %4
%52 = load i32, i32* %5
%53 = call i32 @set_vertex(i32 %50, i32 %51, i32 %52)
%54 = call i32 (...) @scan_board_1()
%55 = load i32, i32* %3
%56 = sub nsw i32 0, %55
%57 = call i32 @remove_stones(i32 %56)
%58 = icmp sgt i32 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %49
%60 = call i32 (...) @scan_board_1()
br label %61
61: ; preds = %59, %49
%62 = load i32, i32* %4
%63 = load i32, i32* %5
%64 = call i32 @get_worm_nr(i32 %62, i32 %63)
%65 = call i32 @get_nr_of_liberties(i32 %64)
%66 = call i32 @get_size_of_worm(i32 %64)
%67 = icmp eq i32 %65, 0
br i1 %67, label %68, label %74
68: ; preds = %61
%69 = load i32, i32* %4
%70 = load i32, i32* %5
%71 = call i32 @set_vertex(i32 0, i32 %69, i32 %70)
%72 = call i32 (...) @set_output_error()
%73 = call i32 @add_output(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %96
74: ; preds = %61
%75 = bitcast [441 x [2 x i32]]* %6 to i32**
%76 = call i32 @get_captured_now(i32** %75)
%77 = call i32 (...) @create_next_move()
%78 = load i32, i32* %3
%79 = load i32, i32* %4
%80 = load i32, i32* %5
%81 = call i32 @set_move_vertex(i32 %78, i32 %79, i32 %80)
%82 = call i32 @set_move_captured_stones(i32** %75)
%83 = icmp eq i32 %76, 1
%84 = icmp eq i32 %66, 1
%85 = select i1 %83, i1 %84, i1 false
%86 = icmp eq i32 %65, 1
%87 = select i1 %85, i1 %86, i1 false
br i1 %87, label %88, label %94
88: ; preds = %74
%89 = getelementptr inbounds [441 x [2 x i32]], [441 x [2 x i32]]* %6, i64 0, i64 0, i64 0
%90 = load i32, i32* %89
%91 = getelementptr inbounds [441 x [2 x i32]], [441 x [2 x i32]]* %6, i64 0, i64 0, i64 1
%92 = load i32, i32* %91
%93 = call i32 @set_move_ko(i32 %90, i32 %92)
br label %94
94: ; preds = %88, %74
%95 = call i32 (...) @push_move()
br label %96
96: ; preds = %94, %68, %46, %37, %29, %21, %14
ret void
}