#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 */
scalar_t__ chessGame(int /*<<< orphan*/);
int /*<<< orphan*/ chessInit();
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ setbuf(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
int main() {
  char buf[256];
  setbuf(stdout, NULL);
  do {
    fgets(buf, 256, stdin);
    printf("# received %s\n", buf);
  } while (strcmp(buf, "protover 2\n") != 0);
  printf("feature sigint=0 done=1\n");
  chessInit();
  while (1) {
    if (chessGame(0)) {
      return 0;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <setbuf@plt>
lea    -0x110(%rbp),%rdi
mov    0x2e56(%rip),%rax
mov    (%rax),%edx
mov    $0x100,%esi
call   1050 <fgets@plt>
lea    -0x110(%rbp),%rsi
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x110(%rbp),%rdi
lea    0xe4e(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1184 <main+0x24>
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <chessInit@plt>
xor    %edi,%edi
call   1080 <chessGame@plt>
cmp    $0x0,%rax
je     1201 <main+0xa1>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbp
ret
jmp    11e5 <main+0x85>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1040 <setbuf@plt>
mov    0x2e53(%rip),%r12
mov    %rsp,%rbx
lea    0xe61(%rip),%r14
lea    0xe69(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x100,%esi
call   1060 <fgets@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    11b0 <main+0x40>
lea    0xe36(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1080 <chessInit@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %edi,%edi
call   1090 <chessGame@plt>
test   %rax,%rax
je     1200 <main+0x90>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdout = global i32 0
@stdin = global i32 0
@.str = [15 x i8] c"# received %s\0A\00"
@.str.1 = [12 x i8] c"protover 2\0A\00"
@.str.2 = [25 x i8] c"feature sigint=0 done=1\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [256 x i8]
store i32 0, i32* %1
%3 = load i32, i32* @stdout
%4 = call i32 @setbuf(i32 %3, i32* null)
br label %5
5: ; preds = %11, %0
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%7 = load i32, i32* @stdin
%8 = call i32 @fgets(i8* %6, i32 256, i32 %7)
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %11
11: ; preds = %5
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%13 = call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp ne i64 %13, 0
br i1 %14, label %5, label %15
15: ; preds = %11
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 (...) @chessInit()
br label %18
18: ; preds = %15, %22
%19 = call i64 @chessGame(i32 0)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %18
ret i32 0
22: ; preds = %18
br label %18
}

LLVM IR (-O2):
@stdout = global i32 0
@stdin = global i32 0
@.str = [15 x i8] c"# received %s\0A\00"
@.str.1 = [12 x i8] c"protover 2\0A\00"
@str = [24 x i8] c"feature sigint=0 done=1\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @stdout
%4 = tail call i32 @setbuf(i32 %3, i32* null)
br label %5
5: ; preds = %5, %0
%6 = load i32, i32* @stdin
%7 = call i32 @fgets(i8* %2, i32 256, i32 %6)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %2)
%9 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %5
11: ; preds = %5
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%13 = call i32 (...) @chessInit()
br label %14
14: ; preds = %14, %11
%15 = call i64 @chessGame(i32 0)
%16 = icmp eq i64 %15, 0
br i1 %16, label %14, label %17
17: ; preds = %14
ret i32 0
}