#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*/ create_next_move();
int get_board_size();
int get_captured_now(int **);
int get_nr_of_liberties(int);
int get_size_of_worm(int);
int get_worm_nr(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_vertex(int, int, int);
int strlen(char *);
bool sgf_move(int color, char *value) {
  int i, j;
  int nr_of_removed_stones;
  int group_nr;
  int nr_of_liberties;
  int group_size;
  int captured_now[21 * 21][2];
  int board_size = get_board_size();
  if (strlen(value) == 0) {
    create_next_move();
    set_move_pass(color);
    push_move();
    return true;
  }
  if (strlen(value) > 2) {
    return false;
  }
  i = value[0] - 97;
  j = board_size - (value[1] - 97) - 1;
  if (i < 0 || i > board_size) {
    return false;
  }
  if (j < 0 || j > board_size) {
    return false;
  }
  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);
    return false;
  }
  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 true;
}


x86 assembly (clang, -O0):
<sgf_move>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe00,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1110 <get_board_size@plt>
mov    %eax,-0xdf4(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
cmp    $0x0,%eax
jne    1243 <sgf_move+0x53>
mov    $0x0,%al
call   1050 <create_next_move@plt>
mov    -0x8(%rbp),%edi
call   1090 <set_move_pass@plt>
mov    $0x0,%al
call   10c0 <push_move@plt>
movl   $0x1,-0x4(%rbp)
jmp    13b7 <sgf_move+0x1c7>
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
cmp    $0x2,%eax
jle    1261 <sgf_move+0x71>
movl   $0x0,-0x4(%rbp)
jmp    13b7 <sgf_move+0x1c7>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
sub    $0x61,%eax
mov    %eax,-0x14(%rbp)
mov    -0xdf4(%rbp),%eax
mov    -0x10(%rbp),%rcx
movsbl 0x1(%rcx),%ecx
sub    $0x61,%ecx
sub    %ecx,%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     12a0 <sgf_move+0xb0>
mov    -0x14(%rbp),%eax
cmp    -0xdf4(%rbp),%eax
jle    12ac <sgf_move+0xbc>
movl   $0x0,-0x4(%rbp)
jmp    13b7 <sgf_move+0x1c7>
cmpl   $0x0,-0x18(%rbp)
jl     12c5 <sgf_move+0xd5>
mov    -0x18(%rbp),%eax
cmp    -0xdf4(%rbp),%eax
jle    12d1 <sgf_move+0xe1>
movl   $0x0,-0x4(%rbp)
jmp    13b7 <sgf_move+0x1c7>
mov    -0x8(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   10a0 <set_vertex@plt>
mov    $0x0,%al
call   1070 <scan_board_1@plt>
imul   $0xffffffff,-0x8(%rbp),%edi
call   1040 <remove_stones@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    1303 <sgf_move+0x113>
mov    $0x0,%al
call   1070 <scan_board_1@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1030 <get_worm_nr@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
call   1080 <get_nr_of_liberties@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%edi
call   10b0 <get_size_of_worm@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    134a <sgf_move+0x15a>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
xor    %edi,%edi
call   10a0 <set_vertex@plt>
movl   $0x0,-0x4(%rbp)
jmp    13b7 <sgf_move+0x1c7>
lea    -0xdf0(%rbp),%rdi
call   10d0 <get_captured_now@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1050 <create_next_move@plt>
mov    -0x8(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   10e0 <set_move_vertex@plt>
lea    -0xdf0(%rbp),%rdi
call   10f0 <set_move_captured_stones@plt>
cmpl   $0x1,-0x1c(%rbp)
jne    13a9 <sgf_move+0x1b9>
cmpl   $0x1,-0x28(%rbp)
jne    13a9 <sgf_move+0x1b9>
cmpl   $0x1,-0x24(%rbp)
jne    13a9 <sgf_move+0x1b9>
mov    -0xdf0(%rbp),%edi
mov    -0xdec(%rbp),%esi
call   1100 <set_move_ko@plt>
mov    $0x0,%al
call   10c0 <push_move@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xe00,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sgf_move>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xdc8,%rsp
mov    %rsi,%rbp
mov    %edi,%r15d
xor    %ebx,%ebx
xor    %eax,%eax
call   1110 <get_board_size@plt>
mov    %eax,%r13d
mov    %rbp,%rdi
call   1060 <strlen@plt>
test   %eax,%eax
je     1300 <sgf_move+0x110>
mov    %rbp,%rdi
call   1060 <strlen@plt>
cmp    $0x2,%eax
jg     131b <sgf_move+0x12b>
movsbl 0x0(%rbp),%r12d
cmp    $0x61,%r12d
jl     131b <sgf_move+0x12b>
add    $0xffffff9f,%r12d
cmp    %r13d,%r12d
jg     131b <sgf_move+0x12b>
movsbl 0x1(%rbp),%eax
mov    %r13d,%r14d
sub    %eax,%r14d
add    $0x60,%r14d
js     131b <sgf_move+0x12b>
cmp    %r13d,%r14d
jg     131b <sgf_move+0x12b>
mov    %r15d,%edi
mov    %r12d,%esi
mov    %r14d,%edx
call   10a0 <set_vertex@plt>
xor    %eax,%eax
call   1070 <scan_board_1@plt>
mov    %r15d,%edi
neg    %edi
call   1040 <remove_stones@plt>
test   %eax,%eax
jle    1297 <sgf_move+0xa7>
xor    %eax,%eax
call   1070 <scan_board_1@plt>
mov    %r12d,%edi
mov    %r14d,%esi
call   1030 <get_worm_nr@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1080 <get_nr_of_liberties@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   10b0 <get_size_of_worm@plt>
test   %ebx,%ebx
je     132f <sgf_move+0x13f>
mov    %eax,%ebp
mov    %rsp,%rdi
call   10d0 <get_captured_now@plt>
mov    %eax,%r13d
xor    %eax,%eax
call   1050 <create_next_move@plt>
mov    %r15d,%edi
mov    %r12d,%esi
mov    %r14d,%edx
call   10e0 <set_move_vertex@plt>
mov    %rsp,%rdi
call   10f0 <set_move_captured_stones@plt>
cmp    $0x1,%r13d
jne    130f <sgf_move+0x11f>
cmp    $0x1,%ebp
jne    130f <sgf_move+0x11f>
cmp    $0x1,%ebx
jne    130f <sgf_move+0x11f>
mov    (%rsp),%edi
mov    0x4(%rsp),%esi
call   1100 <set_move_ko@plt>
jmp    130f <sgf_move+0x11f>
xor    %eax,%eax
call   1050 <create_next_move@plt>
mov    %r15d,%edi
call   1090 <set_move_pass@plt>
xor    %eax,%eax
call   10c0 <push_move@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0xdc8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebx,%ebx
xor    %edi,%edi
mov    %r12d,%esi
mov    %r14d,%edx
call   10a0 <set_vertex@plt>
jmp    131b <sgf_move+0x12b>

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

LLVM IR (-O2):
define i32 @sgf_move(i32 %0, i8* %1) {
%3 = alloca [441 x [2 x i32]]
%4 = bitcast [441 x [2 x i32]]* %3 to i8*
%5 = tail call i32 (...) @get_board_size()
%6 = tail call i32 @strlen(i8* %1)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = tail call i32 (...) @create_next_move()
%10 = tail call i32 @set_move_pass(i32 %0)
%11 = tail call i32 (...) @push_move()
br label %65
12: ; preds = %2
%13 = tail call i32 @strlen(i8* %1)
%14 = icmp sgt i32 %13, 2
br i1 %14, label %65, label %15
15: ; preds = %12
%16 = load i8, i8* %1
%17 = sext i8 %16 to i32
%18 = add nsw i32 %17, -97
%19 = getelementptr inbounds i8, i8* %1, i64 1
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = sub nsw i32 96, %21
%23 = add i32 %22, %5
%24 = icmp slt i8 %16, 97
%25 = icmp sgt i32 %18, %5
%26 = select i1 %24, i1 true, i1 %25
br i1 %26, label %65, label %27
27: ; preds = %15
%28 = icmp slt i32 %23, 0
%29 = icmp sgt i32 %23, %5
%30 = or i1 %28, %29
br i1 %30, label %65, label %31
31: ; preds = %27
%32 = tail call i32 @set_vertex(i32 %0, i32 %18, i32 %23)
%33 = tail call i32 (...) @scan_board_1()
%34 = sub nsw i32 0, %0
%35 = tail call i32 @remove_stones(i32 %34)
%36 = icmp sgt i32 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %31
%38 = tail call i32 (...) @scan_board_1()
br label %39
39: ; preds = %37, %31
%40 = tail call i32 @get_worm_nr(i32 %18, i32 %23)
%41 = tail call i32 @get_nr_of_liberties(i32 %40)
%42 = tail call i32 @get_size_of_worm(i32 %40)
%43 = icmp eq i32 %41, 0
br i1 %43, label %44, label %46
44: ; preds = %39
%45 = tail call i32 @set_vertex(i32 0, i32 %18, i32 %23)
br label %65
46: ; preds = %39
%47 = bitcast [441 x [2 x i32]]* %3 to i32**
%48 = call i32 @get_captured_now(i32** %47)
%49 = call i32 (...) @create_next_move()
%50 = call i32 @set_move_vertex(i32 %0, i32 %18, i32 %23)
%51 = call i32 @set_move_captured_stones(i32** %47)
%52 = icmp eq i32 %48, 1
%53 = icmp eq i32 %42, 1
%54 = select i1 %52, i1 %53, i1 false
%55 = icmp eq i32 %41, 1
%56 = select i1 %54, i1 %55, i1 false
br i1 %56, label %57, label %63
57: ; preds = %46
%58 = getelementptr inbounds [441 x [2 x i32]], [441 x [2 x i32]]* %3, i64 0, i64 0, i64 0
%59 = load i32, i32* %58
%60 = getelementptr inbounds [441 x [2 x i32]], [441 x [2 x i32]]* %3, i64 0, i64 0, i64 1
%61 = load i32, i32* %60
%62 = call i32 @set_move_ko(i32 %59, i32 %61)
br label %63
63: ; preds = %57, %46
%64 = call i32 (...) @push_move()
br label %65
65: ; preds = %27, %15, %12, %63, %44, %8
%66 = phi i32 [ 1, %8 ], [ 0, %44 ], [ 1, %63 ], [ 0, %12 ], [ 0, %15 ], [ 0, %27 ]
ret i32 %66
}