#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*/ board_fen(char *);
int /*<<< orphan*/ close_book();
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ go(char *);
int /*<<< orphan*/ open_book();
int /*<<< orphan*/ perft(int);
int /*<<< orphan*/ perft_file(char *);
int /*<<< orphan*/ printf(char *, ...);
int scan_int(char *, char *);
scalar_t__ scandin(char *, char *);
int /*<<< orphan*/ set_option(char *);
int /*<<< orphan*/ set_ownbook(int);
int /*<<< orphan*/ set_ownbookfile(char *);
int /*<<< orphan*/ set_position(char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strip(char *);
int /*<<< orphan*/ test();
int /*<<< orphan*/ usleep(int);
void loop(void) {
  char s[2048];
  char file[256];
  int num;
  set_ownbookfile("irina.bin");
  set_ownbook(1);
  for (;;) {
    if (!fgets(s, 2048, stdin)) {
      usleep(100000);
      continue;
    }
    if (scandin(s, "uci")) {
      printf("id name Irina %s\n", "0.15");
      printf("id author Lucas Monge\n");
      printf("option name Hash type spin min 2 max 1024 default 32\n");
      printf("option name Personality type combo default Irina var Irina var "
             "Steven var Monkey var Donkey var Bull var Wolf var Lion var Rat "
             "var Snake var Material var Random var Capture var Advance\n");
      printf("option name Min Time type spin default 0 min 0 max 99\n");
      printf("option name Max Time type spin default 0 min 0 max 99\n");
      printf("option name OwnBook type check default true\n");
      printf("option name OwnBookFile type string default irina.bin\n");
      printf("uciok\n");
    } else if (scandin(s, "isready")) {
      printf("readyok\n");
    } else if (scandin(s, "stop")) {
      continue;
    } else if (scandin(s, "quit")) {
      break;
    } else if (scandin(s, "fen")) {
      board_fen(s);
      printf("%s\n", s);
    } else if (scandin(s, "test")) {
      test();
    } else if (scandin(s, "perft file ")) {
      strcpy(file, s + 11);
      strip(file);
      perft_file(file);
    } else if (scandin(s, "perft")) {
      num = scan_int(s, "perft");
      perft(num);
    } else if (scandin(s, "ucinewgame")) {
      open_book();
      continue;
    } else if (scandin(s, "position")) {
      set_position(s);
    } else if (scandin(s, "go")) {
      go(s);
    } else if (scandin(s, "setoption name")) {
      set_option(s);
    }
  }
  close_book();
}


x86 assembly (clang, -O0):
<loop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x910,%rsp
lea    0xdce(%rip),%rdi
call   1110 <set_ownbookfile@plt>
mov    $0x1,%edi
call   10f0 <set_ownbook@plt>
lea    -0x800(%rbp),%rdi
mov    0x2d99(%rip),%rax
mov    (%rax),%edx
mov    $0x800,%esi
call   1080 <fgets@plt>
cmp    $0x0,%eax
jne    1273 <loop+0x53>
mov    $0x186a0,%edi
call   1130 <usleep@plt>
jmp    1241 <loop+0x21>
lea    -0x800(%rbp),%rdi
lea    0xd89(%rip),%rsi
call   1030 <scandin@plt>
cmp    $0x0,%rax
je     131a <loop+0xfa>
lea    0xd77(%rip),%rdi
lea    0xd82(%rip),%rsi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd79(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd82(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xdaa(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xef0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1576 <loop+0x356>
lea    -0x800(%rbp),%rdi
lea    0xedd(%rip),%rsi
call   1030 <scandin@plt>
cmp    $0x0,%rax
je     134a <loop+0x12a>
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1571 <loop+0x351>
lea    -0x800(%rbp),%rdi
lea    0xebe(%rip),%rsi
call   1030 <scandin@plt>
cmp    $0x0,%rax
je     136c <loop+0x14c>
jmp    1241 <loop+0x21>
lea    -0x800(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1030 <scandin@plt>
cmp    $0x0,%rax
je     138e <loop+0x16e>
jmp    157b <loop+0x35b>
lea    -0x800(%rbp),%rdi
lea    0xe84(%rip),%rsi
call   1030 <scandin@plt>
cmp    $0x0,%rax
je     13d1 <loop+0x1b1>
lea    -0x800(%rbp),%rdi
call   10e0 <board_fen@plt>
lea    -0x800(%rbp),%rsi
lea    0xc57(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1562 <loop+0x342>
lea    -0x800(%rbp),%rdi
lea    0xe45(%rip),%rsi
call   1030 <scandin@plt>
cmp    $0x0,%rax
je     13fa <loop+0x1da>
mov    $0x0,%al
call   1140 <test@plt>
jmp    155d <loop+0x33d>
lea    -0x800(%rbp),%rdi
lea    0xe21(%rip),%rsi
call   1030 <scandin@plt>
cmp    $0x0,%rax
je     144b <loop+0x22b>
lea    -0x900(%rbp),%rdi
lea    -0x800(%rbp),%rsi
add    $0xb,%rsi
call   1040 <strcpy@plt>
lea    -0x900(%rbp),%rdi
call   1070 <strip@plt>
lea    -0x900(%rbp),%rdi
call   1090 <perft_file@plt>
jmp    1558 <loop+0x338>
lea    -0x800(%rbp),%rdi
lea    0xddc(%rip),%rsi
call   1030 <scandin@plt>
cmp    $0x0,%rax
je     1491 <loop+0x271>
lea    -0x800(%rbp),%rdi
lea    0xdbf(%rip),%rsi
call   1100 <scan_int@plt>
mov    %eax,-0x904(%rbp)
mov    -0x904(%rbp),%edi
call   10d0 <perft@plt>
jmp    1553 <loop+0x333>
lea    -0x800(%rbp),%rdi
lea    0xd9c(%rip),%rsi
call   1030 <scandin@plt>
cmp    $0x0,%rax
je     14ba <loop+0x29a>
mov    $0x0,%al
call   10b0 <open_book@plt>
jmp    1241 <loop+0x21>
lea    -0x800(%rbp),%rdi
lea    0xd7e(%rip),%rsi
call   1030 <scandin@plt>
cmp    $0x0,%rax
je     14e8 <loop+0x2c8>
lea    -0x800(%rbp),%rdi
call   1120 <set_position@plt>
jmp    1549 <loop+0x329>
lea    -0x800(%rbp),%rdi
lea    0xd59(%rip),%rsi
call   1030 <scandin@plt>
cmp    $0x0,%rax
je     1516 <loop+0x2f6>
lea    -0x800(%rbp),%rdi
call   1050 <go@plt>
jmp    1544 <loop+0x324>
lea    -0x800(%rbp),%rdi
lea    0xd2e(%rip),%rsi
call   1030 <scandin@plt>
cmp    $0x0,%rax
je     153f <loop+0x31f>
lea    -0x800(%rbp),%rdi
call   10c0 <set_option@plt>
jmp    1544 <loop+0x324>
jmp    1549 <loop+0x329>
jmp    154e <loop+0x32e>
jmp    1553 <loop+0x333>
jmp    1558 <loop+0x338>
jmp    155d <loop+0x33d>
jmp    1562 <loop+0x342>
jmp    1567 <loop+0x347>
jmp    156c <loop+0x34c>
jmp    1571 <loop+0x351>
jmp    1576 <loop+0x356>
jmp    1241 <loop+0x21>
mov    $0x0,%al
call   10a0 <close_book@plt>
add    $0x910,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<loop>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x908,%rsp
lea    0xff6(%rip),%rdi
call   1120 <set_ownbookfile@plt>
mov    $0x1,%edi
call   1100 <set_ownbook@plt>
mov    0x2d8a(%rip),%r14
lea    0x100(%rsp),%rbx
lea    0xd93(%rip),%r15
lea    0xf72(%rip),%r12
lea    0xf97(%rip),%rbp
lea    0xfc6(%rip),%r13
jmp    129a <loop+0x6a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x186a0,%edi
call   1140 <usleep@plt>
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0x800,%esi
call   1090 <fgets@plt>
test   %eax,%eax
je     1290 <loop+0x60>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <scandin@plt>
test   %rax,%rax
je     1330 <loop+0x100>
lea    0xd3f(%rip),%rdi
lea    0xd4a(%rip),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xd9c(%rip),%rdi
call   1050 <puts@plt>
lea    0xda6(%rip),%rdi
call   1050 <puts@plt>
lea    0xdcf(%rip),%rdi
call   1050 <puts@plt>
lea    0xe7c(%rip),%rdi
call   1050 <puts@plt>
lea    0xea6(%rip),%rdi
call   1050 <puts@plt>
mov    %r12,%rdi
call   1050 <puts@plt>
mov    %rbp,%rdi
call   1050 <puts@plt>
mov    %r13,%rdi
call   1050 <puts@plt>
jmp    129a <loop+0x6a>
nopl   0x0(%rax)
mov    %rbx,%rdi
lea    0xce1(%rip),%rsi
call   1030 <scandin@plt>
test   %rax,%rax
je     1355 <loop+0x125>
lea    0xd23(%rip),%rdi
call   1050 <puts@plt>
jmp    129a <loop+0x6a>
mov    %rbx,%rdi
lea    0xcc4(%rip),%rsi
call   1030 <scandin@plt>
test   %rax,%rax
jne    129a <loop+0x6a>
mov    %rbx,%rdi
lea    0xcb1(%rip),%rsi
call   1030 <scandin@plt>
test   %rax,%rax
jne    14b1 <loop+0x281>
mov    %rbx,%rdi
lea    0xc9e(%rip),%rsi
call   1030 <scandin@plt>
mov    %rbx,%rdi
test   %rax,%rax
je     13ae <loop+0x17e>
call   10f0 <board_fen@plt>
mov    %rbx,%rdi
call   1050 <puts@plt>
jmp    129a <loop+0x6a>
lea    0xc7c(%rip),%rsi
call   1030 <scandin@plt>
test   %rax,%rax
je     13cb <loop+0x19b>
xor    %eax,%eax
call   1150 <test@plt>
jmp    129a <loop+0x6a>
mov    %rbx,%rdi
lea    0xc61(%rip),%rsi
call   1030 <scandin@plt>
test   %rax,%rax
je     1404 <loop+0x1d4>
mov    %rsp,%rdi
lea    0x10b(%rsp),%rsi
call   1040 <strcpy@plt>
mov    %rsp,%rdi
call   1080 <strip@plt>
mov    %rsp,%rdi
call   10a0 <perft_file@plt>
jmp    129a <loop+0x6a>
mov    %rbx,%rdi
lea    0xc34(%rip),%rsi
call   1030 <scandin@plt>
mov    %rbx,%rdi
test   %rax,%rax
je     1433 <loop+0x203>
lea    0xc20(%rip),%rsi
call   1110 <scan_int@plt>
mov    %eax,%edi
call   10e0 <perft@plt>
jmp    129a <loop+0x6a>
lea    0xc0e(%rip),%rsi
call   1030 <scandin@plt>
test   %rax,%rax
je     1450 <loop+0x220>
xor    %eax,%eax
call   10c0 <open_book@plt>
jmp    129a <loop+0x6a>
mov    %rbx,%rdi
lea    0xbf9(%rip),%rsi
call   1030 <scandin@plt>
mov    %rbx,%rdi
test   %rax,%rax
je     1471 <loop+0x241>
call   1130 <set_position@plt>
jmp    129a <loop+0x6a>
lea    0xbe4(%rip),%rsi
call   1030 <scandin@plt>
mov    %rbx,%rdi
test   %rax,%rax
je     148f <loop+0x25f>
call   1060 <go@plt>
jmp    129a <loop+0x6a>
lea    0xbc9(%rip),%rsi
call   1030 <scandin@plt>
test   %rax,%rax
je     129a <loop+0x6a>
mov    %rbx,%rdi
call   10d0 <set_option@plt>
jmp    129a <loop+0x6a>
xor    %eax,%eax
call   10b0 <close_book@plt>
add    $0x908,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"irina.bin\00"
@stdin = global i32 0
@.str.1 = [4 x i8] c"uci\00"
@.str.2 = [18 x i8] c"id name Irina %s\0A\00"
@.str.3 = [5 x i8] c"0.15\00"
@.str.4 = [23 x i8] c"id author Lucas Monge\0A\00"
@.str.5 = [54 x i8] c"option name Hash type spin min 2 max 1024 default 32\0A\00"
@.str.6 = [186 x i8] c"option name Personality type combo default Irina var Irina var Steven var Monkey var Donkey var Bull var Wolf var Lion var Rat var Snake var Material var Random var Capture var Advance\0A\00"
@.str.7 = [55 x i8] c"option name Min Time type spin default 0 min 0 max 99\0A\00"
@.str.8 = [55 x i8] c"option name Max Time type spin default 0 min 0 max 99\0A\00"
@.str.9 = [45 x i8] c"option name OwnBook type check default true\0A\00"
@.str.10 = [55 x i8] c"option name OwnBookFile type string default irina.bin\0A\00"
@.str.11 = [7 x i8] c"uciok\0A\00"
@.str.12 = [8 x i8] c"isready\00"
@.str.13 = [9 x i8] c"readyok\0A\00"
@.str.14 = [5 x i8] c"stop\00"
@.str.15 = [5 x i8] c"quit\00"
@.str.16 = [4 x i8] c"fen\00"
@.str.17 = [4 x i8] c"%s\0A\00"
@.str.18 = [5 x i8] c"test\00"
@.str.19 = [12 x i8] c"perft file \00"
@.str.20 = [6 x i8] c"perft\00"
@.str.21 = [11 x i8] c"ucinewgame\00"
@.str.22 = [9 x i8] c"position\00"
@.str.23 = [3 x i8] c"go\00"
@.str.24 = [15 x i8] c"setoption name\00"
define void @loop() {
%1 = alloca [2048 x i8]
%2 = alloca [256 x i8]
%3 = alloca i32
%4 = call i32 @set_ownbookfile(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @set_ownbook(i32 1)
br label %6
6: ; preds = %118, %84, %37, %11, %0
%7 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %7, i32 2048, i32 %8)
%10 = icmp ne i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %6
%12 = call i32 @usleep(i32 100000)
br label %6
13: ; preds = %6
%14 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%15 = call i64 @scandin(i8* %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %27
17: ; preds = %13
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.5, i64 0, i64 0))
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([186 x i8], [186 x i8]* @.str.6, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.7, i64 0, i64 0))
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.8, i64 0, i64 0))
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.9, i64 0, i64 0))
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.10, i64 0, i64 0))
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
br label %118
27: ; preds = %13
%28 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%29 = call i64 @scandin(i8* %28, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0))
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.13, i64 0, i64 0))
br label %117
33: ; preds = %27
%34 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%35 = call i64 @scandin(i8* %34, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0))
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %33
br label %6
38: ; preds = %33
%39 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%40 = call i64 @scandin(i8* %39, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i64 0, i64 0))
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %38
br label %119
43: ; preds = %38
%44 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%45 = call i64 @scandin(i8* %44, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.16, i64 0, i64 0))
%46 = icmp ne i64 %45, 0
br i1 %46, label %47, label %52
47: ; preds = %43
%48 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%49 = call i32 @board_fen(i8* %48)
%50 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.17, i64 0, i64 0), i8* %50)
br label %114
52: ; preds = %43
%53 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%54 = call i64 @scandin(i8* %53, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.18, i64 0, i64 0))
%55 = icmp ne i64 %54, 0
br i1 %55, label %56, label %58
56: ; preds = %52
%57 = call i32 (...) @test()
br label %113
58: ; preds = %52
%59 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%60 = call i64 @scandin(i8* %59, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.19, i64 0, i64 0))
%61 = icmp ne i64 %60, 0
br i1 %61, label %62, label %71
62: ; preds = %58
%63 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%64 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%65 = getelementptr inbounds i8, i8* %64, i64 11
%66 = call i32 @strcpy(i8* %63, i8* %65)
%67 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%68 = call i32 @strip(i8* %67)
%69 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%70 = call i32 @perft_file(i8* %69)
br label %112
71: ; preds = %58
%72 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%73 = call i64 @scandin(i8* %72, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.20, i64 0, i64 0))
%74 = icmp ne i64 %73, 0
br i1 %74, label %75, label %80
75: ; preds = %71
%76 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%77 = call i32 @scan_int(i8* %76, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.20, i64 0, i64 0))
store i32 %77, i32* %3
%78 = load i32, i32* %3
%79 = call i32 @perft(i32 %78)
br label %111
80: ; preds = %71
%81 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%82 = call i64 @scandin(i8* %81, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.21, i64 0, i64 0))
%83 = icmp ne i64 %82, 0
br i1 %83, label %84, label %86
84: ; preds = %80
%85 = call i32 (...) @open_book()
br label %6
86: ; preds = %80
%87 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%88 = call i64 @scandin(i8* %87, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.22, i64 0, i64 0))
%89 = icmp ne i64 %88, 0
br i1 %89, label %90, label %93
90: ; preds = %86
%91 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%92 = call i32 @set_position(i8* %91)
br label %109
93: ; preds = %86
%94 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%95 = call i64 @scandin(i8* %94, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.23, i64 0, i64 0))
%96 = icmp ne i64 %95, 0
br i1 %96, label %97, label %100
97: ; preds = %93
%98 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%99 = call i32 @go(i8* %98)
br label %108
100: ; preds = %93
%101 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%102 = call i64 @scandin(i8* %101, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.24, i64 0, i64 0))
%103 = icmp ne i64 %102, 0
br i1 %103, label %104, label %107
104: ; preds = %100
%105 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%106 = call i32 @set_option(i8* %105)
br label %107
107: ; preds = %104, %100
br label %108
108: ; preds = %107, %97
br label %109
109: ; preds = %108, %90
br label %110
110: ; preds = %109
br label %111
111: ; preds = %110, %75
br label %112
112: ; preds = %111, %62
br label %113
113: ; preds = %112, %56
br label %114
114: ; preds = %113, %47
br label %115
115: ; preds = %114
br label %116
116: ; preds = %115
br label %117
117: ; preds = %116, %31
br label %118
118: ; preds = %117, %17
br label %6
119: ; preds = %42
%120 = call i32 (...) @close_book()
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"irina.bin\00"
@stdin = global i32 0
@.str.1 = [4 x i8] c"uci\00"
@.str.2 = [18 x i8] c"id name Irina %s\0A\00"
@.str.3 = [5 x i8] c"0.15\00"
@.str.12 = [8 x i8] c"isready\00"
@.str.14 = [5 x i8] c"stop\00"
@.str.15 = [5 x i8] c"quit\00"
@.str.16 = [4 x i8] c"fen\00"
@.str.18 = [5 x i8] c"test\00"
@.str.19 = [12 x i8] c"perft file \00"
@.str.20 = [6 x i8] c"perft\00"
@.str.21 = [11 x i8] c"ucinewgame\00"
@.str.22 = [9 x i8] c"position\00"
@.str.23 = [3 x i8] c"go\00"
@.str.24 = [15 x i8] c"setoption name\00"
@str = [8 x i8] c"readyok\00"
@str.25 = [22 x i8] c"id author Lucas Monge\00"
@str.26 = [53 x i8] c"option name Hash type spin min 2 max 1024 default 32\00"
@str.27 = [185 x i8] c"option name Personality type combo default Irina var Irina var Steven var Monkey var Donkey var Bull var Wolf var Lion var Rat var Snake var Material var Random var Capture var Advance\00"
@str.28 = [54 x i8] c"option name Min Time type spin default 0 min 0 max 99\00"
@str.29 = [54 x i8] c"option name Max Time type spin default 0 min 0 max 99\00"
@str.30 = [44 x i8] c"option name OwnBook type check default true\00"
@str.31 = [54 x i8] c"option name OwnBookFile type string default irina.bin\00"
@str.32 = [6 x i8] c"uciok\00"
define void @loop() {
%1 = alloca [2048 x i8]
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @set_ownbookfile(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @set_ownbook(i32 1)
%7 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 11
br label %8
8: ; preds = %27, %0
%9 = load i32, i32* @stdin
%10 = call i32 @fgets(i8* %3, i32 2048, i32 %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = call i32 @usleep(i32 100000)
br label %27
14: ; preds = %8
%15 = call i64 @scandin(i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %28, label %17
17: ; preds = %14
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.25, i64 0, i64 0))
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.26, i64 0, i64 0))
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([185 x i8], [185 x i8]* @str.27, i64 0, i64 0))
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.28, i64 0, i64 0))
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.29, i64 0, i64 0))
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.30, i64 0, i64 0))
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.31, i64 0, i64 0))
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.32, i64 0, i64 0))
br label %27
27: ; preds = %17, %42, %53, %76, %81, %78, %71, %60, %48, %31, %12, %66, %33
br label %8
28: ; preds = %14
%29 = call i64 @scandin(i8* %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %33, label %31
31: ; preds = %28
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
br label %27
33: ; preds = %28
%34 = call i64 @scandin(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %27
36: ; preds = %33
%37 = call i64 @scandin(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %83
39: ; preds = %36
%40 = call i64 @scandin(i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.16, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %45, label %42
42: ; preds = %39
%43 = call i32 @board_fen(i8* %3)
%44 = call i32 @puts(i8* %3)
br label %27
45: ; preds = %39
%46 = call i64 @scandin(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.18, i64 0, i64 0))
%47 = icmp eq i64 %46, 0
br i1 %47, label %50, label %48
48: ; preds = %45
%49 = call i32 (...) @test()
br label %27
50: ; preds = %45
%51 = call i64 @scandin(i8* %3, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.19, i64 0, i64 0))
%52 = icmp eq i64 %51, 0
br i1 %52, label %57, label %53
53: ; preds = %50
%54 = call i32 @strcpy(i8* %4, i8* %7)
%55 = call i32 @strip(i8* %4)
%56 = call i32 @perft_file(i8* %4)
br label %27
57: ; preds = %50
%58 = call i64 @scandin(i8* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.20, i64 0, i64 0))
%59 = icmp eq i64 %58, 0
br i1 %59, label %63, label %60
60: ; preds = %57
%61 = call i32 @scan_int(i8* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.20, i64 0, i64 0))
%62 = call i32 @perft(i32 %61)
br label %27
63: ; preds = %57
%64 = call i64 @scandin(i8* %3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.21, i64 0, i64 0))
%65 = icmp eq i64 %64, 0
br i1 %65, label %68, label %66
66: ; preds = %63
%67 = call i32 (...) @open_book()
br label %27
68: ; preds = %63
%69 = call i64 @scandin(i8* %3, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.22, i64 0, i64 0))
%70 = icmp eq i64 %69, 0
br i1 %70, label %73, label %71
71: ; preds = %68
%72 = call i32 @set_position(i8* %3)
br label %27
73: ; preds = %68
%74 = call i64 @scandin(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.23, i64 0, i64 0))
%75 = icmp eq i64 %74, 0
br i1 %75, label %78, label %76
76: ; preds = %73
%77 = call i32 @go(i8* %3)
br label %27
78: ; preds = %73
%79 = call i64 @scandin(i8* %3, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.24, i64 0, i64 0))
%80 = icmp eq i64 %79, 0
br i1 %80, label %27, label %81
81: ; preds = %78
%82 = call i32 @set_option(i8* %3)
br label %27
83: ; preds = %36
%84 = call i32 (...) @close_book()
ret void
}