#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 *);
scalar_t__ atoi(char *);
int /*<<< orphan*/ free_board();
int /*<<< orphan*/ init_board(int);
int /*<<< orphan*/ init_move_history();
int /*<<< orphan*/ set_output_error();
void gtp_boardsize(int gtp_argc, char gtp_argv[][20]) {
  int board_size = (int)atoi(gtp_argv[0]);
  if (board_size < 2 || board_size > 21) {
    set_output_error();
    add_output("unacceptable size");
    return;
  }
  free_board();
  init_board(board_size);
  init_move_history();
  return;
}


x86 assembly (clang, -O0):
<gtp_boardsize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x2,-0x14(%rbp)
jl     118f <gtp_boardsize+0x2f>
cmpl   $0x15,-0x14(%rbp)
jle    11a7 <gtp_boardsize+0x47>
mov    $0x0,%al
call   1040 <set_output_error@plt>
lea    0xe63(%rip),%rdi
call   1080 <add_output@plt>
jmp    11bd <gtp_boardsize+0x5d>
mov    $0x0,%al
call   1060 <free_board@plt>
mov    -0x14(%rbp),%edi
call   1030 <init_board@plt>
mov    $0x0,%al
call   1050 <init_move_history@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gtp_boardsize>:
push   %rbx
mov    %rsi,%rdi
call   1070 <atoi@plt>
mov    %rax,%rbx
add    $0xffffffea,%eax
cmp    $0xffffffeb,%eax
ja     1188 <gtp_boardsize+0x28>
xor    %eax,%eax
call   1040 <set_output_error@plt>
lea    0xe7e(%rip),%rdi
pop    %rbx
jmp    1080 <add_output@plt>
xor    %eax,%eax
call   1060 <free_board@plt>
mov    %ebx,%edi
call   1030 <init_board@plt>
xor    %eax,%eax
pop    %rbx
jmp    1050 <init_move_history@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"unacceptable size\00"
define void @gtp_boardsize(i32 %0, [20 x i8]* %1) {
%3 = alloca i32
%4 = alloca [20 x i8]*
%5 = alloca i32
store i32 %0, i32* %3
store [20 x i8]* %1, [20 x i8]** %4
%6 = load [20 x i8]*, [20 x i8]** %4
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%9 = call i64 @atoi(i8* %8)
%10 = trunc i64 %9 to i32
store i32 %10, i32* %5
%11 = load i32, i32* %5
%12 = icmp slt i32 %11, 2
br i1 %12, label %16, label %13
13: ; preds = %2
%14 = load i32, i32* %5
%15 = icmp sgt i32 %14, 21
br i1 %15, label %16, label %19
16: ; preds = %13, %2
%17 = call i32 (...) @set_output_error()
%18 = call i32 @add_output(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %24
19: ; preds = %13
%20 = call i32 (...) @free_board()
%21 = load i32, i32* %5
%22 = call i32 @init_board(i32 %21)
%23 = call i32 (...) @init_move_history()
br label %24
24: ; preds = %19, %16
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"unacceptable size\00"
define void @gtp_boardsize(i32 %0, [20 x i8]* nocapture %1) {
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%4 = tail call i64 @atoi(i8* %3)
%5 = trunc i64 %4 to i32
%6 = add i32 %5, -22
%7 = icmp ult i32 %6, -20
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = tail call i32 (...) @set_output_error()
%10 = tail call i32 @add_output(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %15
11: ; preds = %2
%12 = tail call i32 (...) @free_board()
%13 = tail call i32 @init_board(i32 %5)
%14 = tail call i32 (...) @init_move_history()
br label %15
15: ; preds = %11, %8
ret void
}