#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_handicap(int, int, char *);
int /*<<< orphan*/ add_output(char *);
int atoi(char *);
int get_board_size();
scalar_t__ get_stone_count(int);
int /*<<< orphan*/ set_output_error();
int /*<<< orphan*/ strcat(char *, char *);
void gtp_fixed_handicap(int gtp_argc, char gtp_argv[][20]) {
  int i, j;
  int handicap;
  char output[40];
  int max_handicap;
  int edge_distance;
  int board_size = get_board_size();
  if (get_stone_count(1) + get_stone_count(-1) != 0) {
    set_output_error();
    add_output("board not empty");
    return;
  }
  if (board_size <= 6) {
    set_output_error();
    add_output("invalid handicap");
    return;
  }
  edge_distance = (board_size > 12) ? 4 : 3;
  max_handicap = (board_size % 2 == 0) ? 4 : 9;
  if (board_size == 7) {
    max_handicap = 4;
  }
  handicap = atoi(gtp_argv[0]);
  if (handicap < 2 || handicap > max_handicap) {
    set_output_error();
    add_output("invalid handicap");
    return;
  }
  output[0] = '\0';
  i = board_size - edge_distance;
  j = board_size - edge_distance;
  add_handicap(i, j, output);
  i = edge_distance - 1;
  j = edge_distance - 1;
  strcat(output, " ");
  add_handicap(i, j, output);
  if (handicap == 2) {
    add_output(output);
    return;
  }
  i = board_size - edge_distance;
  j = edge_distance - 1;
  strcat(output, " ");
  add_handicap(i, j, output);
  if (handicap == 3) {
    add_output(output);
    return;
  }
  i = edge_distance - 1;
  j = board_size - edge_distance;
  strcat(output, " ");
  add_handicap(i, j, output);
  if (handicap == 4) {
    add_output(output);
    return;
  }
  if (handicap == 5 || handicap == 7 || handicap == 9) {
    i = board_size / 2;
    j = board_size / 2;
    strcat(output, " ");
    add_handicap(i, j, output);
  }
  if (handicap == 5) {
    add_output(output);
    return;
  }
  i = edge_distance - 1;
  j = board_size / 2;
  strcat(output, " ");
  add_handicap(i, j, output);
  i = board_size - edge_distance;
  j = board_size / 2;
  strcat(output, " ");
  add_handicap(i, j, output);
  if (handicap == 6 || handicap == 7) {
    add_output(output);
    return;
  }
  i = board_size / 2;
  j = edge_distance - 1;
  strcat(output, " ");
  add_handicap(i, j, output);
  i = board_size / 2;
  j = board_size - edge_distance;
  strcat(output, " ");
  add_handicap(i, j, output);
  add_output(output);
  return;
}


x86 assembly (clang, -O0):
<gtp_fixed_handicap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1090 <get_board_size@plt>
mov    %eax,-0x5c(%rbp)
mov    $0x1,%edi
call   1040 <get_stone_count@plt>
mov    %rax,-0x68(%rbp)
mov    $0xffffffff,%edi
call   1040 <get_stone_count@plt>
mov    %rax,%rcx
mov    -0x68(%rbp),%rax
add    %rcx,%rax
cmp    $0x0,%rax
je     11cd <gtp_fixed_handicap+0x5d>
mov    $0x0,%al
call   1030 <set_output_error@plt>
lea    0xe3d(%rip),%rdi
call   1080 <add_output@plt>
jmp    14e2 <gtp_fixed_handicap+0x372>
cmpl   $0x6,-0x5c(%rbp)
jg     11ef <gtp_fixed_handicap+0x7f>
mov    $0x0,%al
call   1030 <set_output_error@plt>
lea    0xe2b(%rip),%rdi
call   1080 <add_output@plt>
jmp    14e2 <gtp_fixed_handicap+0x372>
mov    -0x5c(%rbp),%edx
mov    $0x3,%eax
mov    $0x4,%ecx
cmp    $0xc,%edx
cmovg  %ecx,%eax
mov    %eax,-0x58(%rbp)
mov    -0x5c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    $0x9,%eax
mov    $0x4,%ecx
cmp    $0x0,%edx
cmove  %ecx,%eax
mov    %eax,-0x54(%rbp)
cmpl   $0x7,-0x5c(%rbp)
jne    1234 <gtp_fixed_handicap+0xc4>
movl   $0x4,-0x54(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jl     1256 <gtp_fixed_handicap+0xe6>
mov    -0x1c(%rbp),%eax
cmp    -0x54(%rbp),%eax
jle    126e <gtp_fixed_handicap+0xfe>
mov    $0x0,%al
call   1030 <set_output_error@plt>
lea    0xdac(%rip),%rdi
call   1080 <add_output@plt>
jmp    14e2 <gtp_fixed_handicap+0x372>
movb   $0x0,-0x50(%rbp)
mov    -0x5c(%rbp),%eax
sub    -0x58(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x5c(%rbp),%eax
sub    -0x58(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
lea    -0x50(%rbp),%rdx
call   1050 <add_handicap@plt>
mov    -0x58(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x58(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xd71(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
lea    -0x50(%rbp),%rdx
call   1050 <add_handicap@plt>
cmpl   $0x2,-0x1c(%rbp)
jne    12dc <gtp_fixed_handicap+0x16c>
lea    -0x50(%rbp),%rdi
call   1080 <add_output@plt>
jmp    14e2 <gtp_fixed_handicap+0x372>
mov    -0x5c(%rbp),%eax
sub    -0x58(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x58(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xd28(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
lea    -0x50(%rbp),%rdx
call   1050 <add_handicap@plt>
cmpl   $0x3,-0x1c(%rbp)
jne    1325 <gtp_fixed_handicap+0x1b5>
lea    -0x50(%rbp),%rdi
call   1080 <add_output@plt>
jmp    14e2 <gtp_fixed_handicap+0x372>
mov    -0x58(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x5c(%rbp),%eax
sub    -0x58(%rbp),%eax
mov    %eax,-0x18(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xcdf(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
lea    -0x50(%rbp),%rdx
call   1050 <add_handicap@plt>
cmpl   $0x4,-0x1c(%rbp)
jne    136e <gtp_fixed_handicap+0x1fe>
lea    -0x50(%rbp),%rdi
call   1080 <add_output@plt>
jmp    14e2 <gtp_fixed_handicap+0x372>
cmpl   $0x5,-0x1c(%rbp)
je     138c <gtp_fixed_handicap+0x21c>
cmpl   $0x7,-0x1c(%rbp)
je     138c <gtp_fixed_handicap+0x21c>
cmpl   $0x9,-0x1c(%rbp)
jne    13c7 <gtp_fixed_handicap+0x257>
mov    -0x5c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x5c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xc6e(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
lea    -0x50(%rbp),%rdx
call   1050 <add_handicap@plt>
cmpl   $0x5,-0x1c(%rbp)
jne    13df <gtp_fixed_handicap+0x26f>
lea    -0x50(%rbp),%rdi
call   1080 <add_output@plt>
jmp    14e2 <gtp_fixed_handicap+0x372>
mov    -0x58(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x5c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xc20(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
lea    -0x50(%rbp),%rdx
call   1050 <add_handicap@plt>
mov    -0x5c(%rbp),%eax
sub    -0x58(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x5c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xbea(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
lea    -0x50(%rbp),%rdx
call   1050 <add_handicap@plt>
cmpl   $0x6,-0x1c(%rbp)
je     145f <gtp_fixed_handicap+0x2ef>
cmpl   $0x7,-0x1c(%rbp)
jne    146d <gtp_fixed_handicap+0x2fd>
lea    -0x50(%rbp),%rdi
call   1080 <add_output@plt>
jmp    14e2 <gtp_fixed_handicap+0x372>
mov    -0x5c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x58(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xb92(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
lea    -0x50(%rbp),%rdx
call   1050 <add_handicap@plt>
mov    -0x5c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x5c(%rbp),%eax
sub    -0x58(%rbp),%eax
mov    %eax,-0x18(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xb5c(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
lea    -0x50(%rbp),%rdx
call   1050 <add_handicap@plt>
lea    -0x50(%rbp),%rdi
call   1080 <add_output@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gtp_fixed_handicap>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbp
xor    %eax,%eax
call   1090 <get_board_size@plt>
mov    %eax,%r13d
mov    $0x1,%edi
call   1040 <get_stone_count@plt>
mov    %rax,%rbx
mov    $0xffffffff,%edi
call   1040 <get_stone_count@plt>
add    %rbx,%rax
jne    11f6 <gtp_fixed_handicap+0x86>
cmp    $0x6,%r13d
jle    11e6 <gtp_fixed_handicap+0x76>
cmp    $0xd,%r13d
mov    $0x3,%r12d
sbb    $0xffffffff,%r12d
mov    %rbp,%rdi
call   1060 <atoi@plt>
cmp    $0x2,%eax
jl     11e6 <gtp_fixed_handicap+0x76>
mov    %eax,%r15d
mov    %r13d,%eax
and    $0x1,%eax
cmp    $0x7,%r13d
lea    0x4(%rax,%rax,4),%eax
mov    $0x4,%ecx
cmovne %eax,%ecx
cmp    %ecx,%r15d
jbe    1217 <gtp_fixed_handicap+0xa7>
xor    %eax,%eax
call   1030 <set_output_error@plt>
lea    0xe34(%rip),%rdi
jmp    1204 <gtp_fixed_handicap+0x94>
xor    %eax,%eax
call   1030 <set_output_error@plt>
lea    0xe14(%rip),%rdi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1080 <add_output@plt>
movb   $0x0,(%rsp)
mov    %r13d,%r14d
sub    %r12d,%r14d
mov    %rsp,%rbx
mov    %r14d,%edi
mov    %r14d,%esi
mov    %rbx,%rdx
call   1050 <add_handicap@plt>
add    $0xffffffff,%r12d
lea    0xdfc(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
mov    %r12d,%edi
mov    %r12d,%esi
mov    %rbx,%rdx
call   1050 <add_handicap@plt>
cmp    $0x2,%r15d
je     1334 <gtp_fixed_handicap+0x1c4>
lea    0xdd5(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1070 <strcat@plt>
mov    %r14d,%edi
mov    %r12d,%esi
mov    %rbx,%rdx
call   1050 <add_handicap@plt>
cmp    $0x3,%r15d
je     1334 <gtp_fixed_handicap+0x1c4>
lea    0xdab(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1070 <strcat@plt>
mov    %r12d,%edi
mov    %r14d,%esi
mov    %rbx,%rdx
call   1050 <add_handicap@plt>
lea    -0x4(%r15),%eax
cmp    $0x5,%eax
ja     12eb <gtp_fixed_handicap+0x17b>
lea    0xd49(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
shr    %r13d
lea    0xd6f(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1070 <strcat@plt>
mov    %r13d,%edi
mov    %r13d,%esi
mov    %rbx,%rdx
call   1050 <add_handicap@plt>
cmp    $0x5,%r15d
jne    12ee <gtp_fixed_handicap+0x17e>
jmp    1334 <gtp_fixed_handicap+0x1c4>
shr    %r13d
lea    0xd44(%rip),%rbx
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1070 <strcat@plt>
mov    %r12d,%edi
mov    %r13d,%esi
mov    %rbp,%rdx
call   1050 <add_handicap@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1070 <strcat@plt>
mov    %r14d,%edi
mov    %r13d,%esi
mov    %rbp,%rdx
call   1050 <add_handicap@plt>
and    $0xfffffffe,%r15d
cmp    $0x6,%r15d
jne    134b <gtp_fixed_handicap+0x1db>
mov    %rsp,%rdi
call   1080 <add_output@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xce7(%rip),%rbx
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1070 <strcat@plt>
mov    %r13d,%edi
mov    %r12d,%esi
mov    %rbp,%rdx
call   1050 <add_handicap@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1070 <strcat@plt>
mov    %r13d,%edi
mov    %r14d,%esi
mov    %rbp,%rdx
call   1050 <add_handicap@plt>
mov    %rbp,%rdi
jmp    1337 <gtp_fixed_handicap+0x1c7>

LLVM IR (-O0):
@.str = [16 x i8] c"board not empty\00"
@.str.1 = [17 x i8] c"invalid handicap\00"
@.str.2 = [2 x i8] c" \00"
define void @gtp_fixed_handicap(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 [40 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %3
store [20 x i8]* %1, [20 x i8]** %4
%12 = call i32 (...) @get_board_size()
store i32 %12, i32* %11
%13 = call i64 @get_stone_count(i32 1)
%14 = call i64 @get_stone_count(i32 -1)
%15 = add nsw i64 %13, %14
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = call i32 (...) @set_output_error()
%19 = call i32 @add_output(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %194
20: ; preds = %2
%21 = load i32, i32* %11
%22 = icmp sle i32 %21, 6
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = call i32 (...) @set_output_error()
%25 = call i32 @add_output(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %194
26: ; preds = %20
%27 = load i32, i32* %11
%28 = icmp sgt i32 %27, 12
%29 = zext i1 %28 to i64
%30 = select i1 %28, i32 4, i32 3
store i32 %30, i32* %10
%31 = load i32, i32* %11
%32 = srem i32 %31, 2
%33 = icmp eq i32 %32, 0
%34 = zext i1 %33 to i64
%35 = select i1 %33, i32 4, i32 9
store i32 %35, i32* %9
%36 = load i32, i32* %11
%37 = icmp eq i32 %36, 7
br i1 %37, label %38, label %39
38: ; preds = %26
store i32 4, i32* %9
br label %39
39: ; preds = %38, %26
%40 = load [20 x i8]*, [20 x i8]** %4
%41 = getelementptr inbounds [20 x i8], [20 x i8]* %40, i64 0
%42 = getelementptr inbounds [20 x i8], [20 x i8]* %41, i64 0, i64 0
%43 = call i32 @atoi(i8* %42)
store i32 %43, i32* %7
%44 = load i32, i32* %7
%45 = icmp slt i32 %44, 2
br i1 %45, label %50, label %46
46: ; preds = %39
%47 = load i32, i32* %7
%48 = load i32, i32* %9
%49 = icmp sgt i32 %47, %48
br i1 %49, label %50, label %53
50: ; preds = %46, %39
%51 = call i32 (...) @set_output_error()
%52 = call i32 @add_output(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %194
53: ; preds = %46
%54 = getelementptr inbounds [40 x i8], [40 x i8]* %8, i64 0, i64 0
store i8 0, i8* %54
%55 = load i32, i32* %11
%56 = load i32, i32* %10
%57 = sub nsw i32 %55, %56
store i32 %57, i32* %5
%58 = load i32, i32* %11
%59 = load i32, i32* %10
%60 = sub nsw i32 %58, %59
store i32 %60, i32* %6
%61 = load i32, i32* %5
%62 = load i32, i32* %6
%63 = getelementptr inbounds [40 x i8], [40 x i8]* %8, i64 0, i64 0
%64 = call i32 @add_handicap(i32 %61, i32 %62, i8* %63)
%65 = load i32, i32* %10
%66 = sub nsw i32 %65, 1
store i32 %66, i32* %5
%67 = load i32, i32* %10
%68 = sub nsw i32 %67, 1
store i32 %68, i32* %6
%69 = getelementptr inbounds [40 x i8], [40 x i8]* %8, i64 0, i64 0
%70 = call i32 @strcat(i8* %69, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%71 = load i32, i32* %5
%72 = load i32, i32* %6
%73 = getelementptr inbounds [40 x i8], [40 x i8]* %8, i64 0, i64 0
%74 = call i32 @add_handicap(i32 %71, i32 %72, i8* %73)
%75 = load i32, i32* %7
%76 = icmp eq i32 %75, 2
br i1 %76, label %77, label %80
77: ; preds = %53
%78 = getelementptr inbounds [40 x i8], [40 x i8]* %8, i64 0, i64 0
%79 = call i32 @add_output(i8* %78)
br label %194
80: ; preds = %53
%81 = load i32, i32* %11
%82 = load i32, i32* %10
%83 = sub nsw i32 %81, %82
store i32 %83, i32* %5
%84 = load i32, i32* %10
%85 = sub nsw i32 %84, 1
store i32 %85, i32* %6
%86 = getelementptr inbounds [40 x i8], [40 x i8]* %8, i64 0, i64 0
%87 = call i32 @strcat(i8* %86, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%88 = load i32, i32* %5
%89 = load i32, i32* %6
%90 = getelementptr inbounds [40 x i8], [40 x i8]* %8, i64 0, i64 0
%91 = call i32 @add_handicap(i32 %88, i32 %89, i8* %90)
%92 = load i32, i32* %7
%93 = icmp eq i32 %92, 3
br i1 %93, label %94, label %97
94: ; preds = %80
%95 = getelementptr inbounds [40 x i8], [40 x i8]* %8, i64 0, i64 0
%96 = call i32 @add_output(i8* %95)
br label %194
97: ; preds = %80
%98 = load i32, i32* %10
%99 = sub nsw i32 %98, 1
store i32 %99, i32* %5
%100 = load i32, i32* %11
%101 = load i32, i32* %10
%102 = sub nsw i32 %100, %101
store i32 %102, i32* %6
%103 = getelementptr inbounds [40 x i8], [40 x i8]* %8, i64 0, i64 0
%104 = call i32 @strcat(i8* %103, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%105 = load i32, i32* %5
%106 = load i32, i32* %6
%107 = getelementptr inbounds [40 x i8], [40 x i8]* %8, i64 0, i64 0
%108 = call i32 @add_handicap(i32 %105, i32 %106, i8* %107)
%109 = load i32, i32* %7
%110 = icmp eq i32 %109, 4
br i1 %110, label %111, label %114
111: ; preds = %97
%112 = getelementptr inbounds [40 x i8], [40 x i8]* %8, i64 0, i64 0
%113 = call i32 @add_output(i8* %112)
br label %194
114: ; preds = %97
%115 = load i32, i32* %7
%116 = icmp eq i32 %115, 5
br i1 %116, label %123, label %117
117: ; preds = %114
%118 = load i32, i32* %7
%119 = icmp eq i32 %118, 7
br i1 %119, label %123, label %120
120: ; preds = %117
%121 = load i32, i32* %7
%122 = icmp eq i32 %121, 9
br i1 %122, label %123, label %134
123: ; preds = %120, %117, %114
%124 = load i32, i32* %11
%125 = sdiv i32 %124, 2
store i32 %125, i32* %5
%126 = load i32, i32* %11
%127 = sdiv i32 %126, 2
store i32 %127, i32* %6
%128 = getelementptr inbounds [40 x i8], [40 x i8]* %8, i64 0, i64 0
%129 = call i32 @strcat(i8* %128, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%130 = load i32, i32* %5
%131 = load i32, i32* %6
%132 = getelementptr inbounds [40 x i8], [40 x i8]* %8, i64 0, i64 0
%133 = call i32 @add_handicap(i32 %130, i32 %131, i8* %132)
br label %134
134: ; preds = %123, %120
%135 = load i32, i32* %7
%136 = icmp eq i32 %135, 5
br i1 %136, label %137, label %140
137: ; preds = %134
%138 = getelementptr inbounds [40 x i8], [40 x i8]* %8, i64 0, i64 0
%139 = call i32 @add_output(i8* %138)
br label %194
140: ; preds = %134
%141 = load i32, i32* %10
%142 = sub nsw i32 %141, 1
store i32 %142, i32* %5
%143 = load i32, i32* %11
%144 = sdiv i32 %143, 2
store i32 %144, i32* %6
%145 = getelementptr inbounds [40 x i8], [40 x i8]* %8, i64 0, i64 0
%146 = call i32 @strcat(i8* %145, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%147 = load i32, i32* %5
%148 = load i32, i32* %6
%149 = getelementptr inbounds [40 x i8], [40 x i8]* %8, i64 0, i64 0
%150 = call i32 @add_handicap(i32 %147, i32 %148, i8* %149)
%151 = load i32, i32* %11
%152 = load i32, i32* %10
%153 = sub nsw i32 %151, %152
store i32 %153, i32* %5
%154 = load i32, i32* %11
%155 = sdiv i32 %154, 2
store i32 %155, i32* %6
%156 = getelementptr inbounds [40 x i8], [40 x i8]* %8, i64 0, i64 0
%157 = call i32 @strcat(i8* %156, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%158 = load i32, i32* %5
%159 = load i32, i32* %6
%160 = getelementptr inbounds [40 x i8], [40 x i8]* %8, i64 0, i64 0
%161 = call i32 @add_handicap(i32 %158, i32 %159, i8* %160)
%162 = load i32, i32* %7
%163 = icmp eq i32 %162, 6
br i1 %163, label %167, label %164
164: ; preds = %140
%165 = load i32, i32* %7
%166 = icmp eq i32 %165, 7
br i1 %166, label %167, label %170
167: ; preds = %164, %140
%168 = getelementptr inbounds [40 x i8], [40 x i8]* %8, i64 0, i64 0
%169 = call i32 @add_output(i8* %168)
br label %194
170: ; preds = %164
%171 = load i32, i32* %11
%172 = sdiv i32 %171, 2
store i32 %172, i32* %5
%173 = load i32, i32* %10
%174 = sub nsw i32 %173, 1
store i32 %174, i32* %6
%175 = getelementptr inbounds [40 x i8], [40 x i8]* %8, i64 0, i64 0
%176 = call i32 @strcat(i8* %175, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%177 = load i32, i32* %5
%178 = load i32, i32* %6
%179 = getelementptr inbounds [40 x i8], [40 x i8]* %8, i64 0, i64 0
%180 = call i32 @add_handicap(i32 %177, i32 %178, i8* %179)
%181 = load i32, i32* %11
%182 = sdiv i32 %181, 2
store i32 %182, i32* %5
%183 = load i32, i32* %11
%184 = load i32, i32* %10
%185 = sub nsw i32 %183, %184
store i32 %185, i32* %6
%186 = getelementptr inbounds [40 x i8], [40 x i8]* %8, i64 0, i64 0
%187 = call i32 @strcat(i8* %186, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%188 = load i32, i32* %5
%189 = load i32, i32* %6
%190 = getelementptr inbounds [40 x i8], [40 x i8]* %8, i64 0, i64 0
%191 = call i32 @add_handicap(i32 %188, i32 %189, i8* %190)
%192 = getelementptr inbounds [40 x i8], [40 x i8]* %8, i64 0, i64 0
%193 = call i32 @add_output(i8* %192)
br label %194
194: ; preds = %170, %167, %137, %111, %94, %77, %50, %23, %17
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"board not empty\00"
@.str.1 = [17 x i8] c"invalid handicap\00"
@.str.2 = [2 x i8] c" \00"
define void @gtp_fixed_handicap(i32 %0, [20 x i8]* nocapture %1) {
%3 = alloca [40 x i8]
%4 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%5 = tail call i32 (...) @get_board_size()
%6 = tail call i64 @get_stone_count(i32 1)
%7 = tail call i64 @get_stone_count(i32 -1)
%8 = sub i64 0, %7
%9 = icmp eq i64 %6, %8
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = tail call i32 (...) @set_output_error()
%12 = tail call i32 @add_output(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %79
13: ; preds = %2
%14 = icmp slt i32 %5, 7
br i1 %14, label %15, label %18
15: ; preds = %13
%16 = tail call i32 (...) @set_output_error()
%17 = tail call i32 @add_output(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %79
18: ; preds = %13
%19 = icmp ugt i32 %5, 12
%20 = select i1 %19, i32 4, i32 3
%21 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%22 = tail call i32 @atoi(i8* %21)
%23 = icmp slt i32 %22, 2
br i1 %23, label %31, label %24
24: ; preds = %18
%25 = icmp eq i32 %5, 7
%26 = and i32 %5, 1
%27 = icmp eq i32 %26, 0
%28 = or i1 %25, %27
%29 = select i1 %28, i32 4, i32 9
%30 = icmp ugt i32 %22, %29
br i1 %30, label %31, label %34
31: ; preds = %24, %18
%32 = tail call i32 (...) @set_output_error()
%33 = tail call i32 @add_output(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %79
34: ; preds = %24
store i8 0, i8* %4
%35 = sub nuw nsw i32 %5, %20
%36 = call i32 @add_handicap(i32 %35, i32 %35, i8* %4)
%37 = add nsw i32 %20, -1
%38 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%39 = call i32 @add_handicap(i32 %37, i32 %37, i8* %4)
%40 = icmp eq i32 %22, 2
br i1 %40, label %41, label %43
41: ; preds = %34
%42 = call i32 @add_output(i8* %4)
br label %79
43: ; preds = %34
%44 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%45 = call i32 @add_handicap(i32 %35, i32 %37, i8* %4)
%46 = icmp eq i32 %22, 3
br i1 %46, label %47, label %49
47: ; preds = %43
%48 = call i32 @add_output(i8* %4)
br label %79
49: ; preds = %43
%50 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%51 = call i32 @add_handicap(i32 %37, i32 %35, i8* %4)
switch i32 %22, label %52 [
i32 4, label %54
i32 9, label %56
i32 7, label %56
i32 5, label %56
]
52: ; preds = %49
%53 = lshr i32 %5, 1
br label %63
54: ; preds = %49
%55 = call i32 @add_output(i8* %4)
br label %79
56: ; preds = %49, %49, %49
%57 = icmp eq i32 %22, 5
%58 = lshr i32 %5, 1
%59 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%60 = call i32 @add_handicap(i32 %58, i32 %58, i8* %4)
br i1 %57, label %61, label %63
61: ; preds = %56
%62 = call i32 @add_output(i8* %4)
br label %79
63: ; preds = %52, %56
%64 = phi i32 [ %53, %52 ], [ %58, %56 ]
%65 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%66 = call i32 @add_handicap(i32 %37, i32 %64, i8* %4)
%67 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%68 = call i32 @add_handicap(i32 %35, i32 %64, i8* %4)
%69 = and i32 %22, -2
%70 = icmp eq i32 %69, 6
br i1 %70, label %71, label %73
71: ; preds = %63
%72 = call i32 @add_output(i8* %4)
br label %79
73: ; preds = %63
%74 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%75 = call i32 @add_handicap(i32 %64, i32 %37, i8* %4)
%76 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%77 = call i32 @add_handicap(i32 %64, i32 %35, i8* %4)
%78 = call i32 @add_output(i8* %4)
br label %79
79: ; preds = %73, %71, %61, %54, %47, %41, %31, %15, %10
ret void
}