#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);
  printf("Irina is a free adaptation of Winglet, chess engine created by Stef "
         "Luijten.\nUsed to implement child personalities of Lucas Chess "
         "GUI.\n\n");
  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    0xdc2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x800(%rbp),%rdi
mov    0x2d8b(%rip),%rax
mov    (%rax),%edx
mov    $0x800,%esi
call   1080 <fgets@plt>
cmp    $0x0,%eax
jne    1281 <loop+0x61>
mov    $0x186a0,%edi
call   1130 <usleep@plt>
jmp    124f <loop+0x2f>
lea    -0x800(%rbp),%rdi
lea    0xe04(%rip),%rsi
call   1030 <scandin@plt>
cmp    $0x0,%rax
je     1328 <loop+0x108>
lea    0xdf2(%rip),%rdi
lea    0xdfd(%rip),%rsi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xefa(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xf23(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xf42(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xf6b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1584 <loop+0x364>
lea    -0x800(%rbp),%rdi
lea    0xf58(%rip),%rsi
call   1030 <scandin@plt>
cmp    $0x0,%rax
je     1358 <loop+0x138>
lea    0xf4a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    157f <loop+0x35f>
lea    -0x800(%rbp),%rdi
lea    0xf39(%rip),%rsi
call   1030 <scandin@plt>
cmp    $0x0,%rax
je     137a <loop+0x15a>
jmp    124f <loop+0x2f>
lea    -0x800(%rbp),%rdi
lea    0xf1c(%rip),%rsi
call   1030 <scandin@plt>
cmp    $0x0,%rax
je     139c <loop+0x17c>
jmp    1589 <loop+0x369>
lea    -0x800(%rbp),%rdi
lea    0xeff(%rip),%rsi
call   1030 <scandin@plt>
cmp    $0x0,%rax
je     13df <loop+0x1bf>
lea    -0x800(%rbp),%rdi
call   10e0 <board_fen@plt>
lea    -0x800(%rbp),%rsi
lea    0xcd2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1570 <loop+0x350>
lea    -0x800(%rbp),%rdi
lea    0xec0(%rip),%rsi
call   1030 <scandin@plt>
cmp    $0x0,%rax
je     1408 <loop+0x1e8>
mov    $0x0,%al
call   1140 <test@plt>
jmp    156b <loop+0x34b>
lea    -0x800(%rbp),%rdi
lea    0xe9c(%rip),%rsi
call   1030 <scandin@plt>
cmp    $0x0,%rax
je     1459 <loop+0x239>
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    1566 <loop+0x346>
lea    -0x800(%rbp),%rdi
lea    0xe57(%rip),%rsi
call   1030 <scandin@plt>
cmp    $0x0,%rax
je     149f <loop+0x27f>
lea    -0x800(%rbp),%rdi
lea    0xe3a(%rip),%rsi
call   1100 <scan_int@plt>
mov    %eax,-0x904(%rbp)
mov    -0x904(%rbp),%edi
call   10d0 <perft@plt>
jmp    1561 <loop+0x341>
lea    -0x800(%rbp),%rdi
lea    0xe17(%rip),%rsi
call   1030 <scandin@plt>
cmp    $0x0,%rax
je     14c8 <loop+0x2a8>
mov    $0x0,%al
call   10b0 <open_book@plt>
jmp    124f <loop+0x2f>
lea    -0x800(%rbp),%rdi
lea    0xdf9(%rip),%rsi
call   1030 <scandin@plt>
cmp    $0x0,%rax
je     14f6 <loop+0x2d6>
lea    -0x800(%rbp),%rdi
call   1120 <set_position@plt>
jmp    1557 <loop+0x337>
lea    -0x800(%rbp),%rdi
lea    0xdd4(%rip),%rsi
call   1030 <scandin@plt>
cmp    $0x0,%rax
je     1524 <loop+0x304>
lea    -0x800(%rbp),%rdi
call   1050 <go@plt>
jmp    1552 <loop+0x332>
lea    -0x800(%rbp),%rdi
lea    0xda9(%rip),%rsi
call   1030 <scandin@plt>
cmp    $0x0,%rax
je     154d <loop+0x32d>
lea    -0x800(%rbp),%rdi
call   10c0 <set_option@plt>
jmp    1552 <loop+0x332>
jmp    1557 <loop+0x337>
jmp    155c <loop+0x33c>
jmp    1561 <loop+0x341>
jmp    1566 <loop+0x346>
jmp    156b <loop+0x34b>
jmp    1570 <loop+0x350>
jmp    1575 <loop+0x355>
jmp    157a <loop+0x35a>
jmp    157f <loop+0x35f>
jmp    1584 <loop+0x364>
jmp    124f <loop+0x2f>
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    0x107e(%rip),%rdi
call   1120 <set_ownbookfile@plt>
mov    $0x1,%edi
call   1100 <set_ownbook@plt>
lea    0xe10(%rip),%rdi
call   1050 <puts@plt>
mov    0x2d7e(%rip),%r14
lea    0x100(%rsp),%rbx
lea    0xd87(%rip),%r15
lea    0xfee(%rip),%r12
lea    0x1013(%rip),%rbp
lea    0x1042(%rip),%r13
jmp    129a <loop+0x6a>
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    0xe24(%rip),%rdi
call   1050 <puts@plt>
lea    0xe2e(%rip),%rdi
call   1050 <puts@plt>
lea    0xe57(%rip),%rdi
call   1050 <puts@plt>
lea    0xf04(%rip),%rdi
call   1050 <puts@plt>
lea    0xf2e(%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    0xdab(%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"
@.str.1 = [137 x i8] c"Irina is a free adaptation of Winglet, chess engine created by Stef Luijten.\0AUsed to implement child personalities of Lucas Chess GUI.\0A\0A\00"
@stdin = global i32 0
@.str.2 = [4 x i8] c"uci\00"
@.str.3 = [18 x i8] c"id name Irina %s\0A\00"
@.str.4 = [5 x i8] c"0.15\00"
@.str.5 = [23 x i8] c"id author Lucas Monge\0A\00"
@.str.6 = [54 x i8] c"option name Hash type spin min 2 max 1024 default 32\0A\00"
@.str.7 = [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.8 = [55 x i8] c"option name Min Time type spin default 0 min 0 max 99\0A\00"
@.str.9 = [55 x i8] c"option name Max Time type spin default 0 min 0 max 99\0A\00"
@.str.10 = [45 x i8] c"option name OwnBook type check default true\0A\00"
@.str.11 = [55 x i8] c"option name OwnBookFile type string default irina.bin\0A\00"
@.str.12 = [7 x i8] c"uciok\0A\00"
@.str.13 = [8 x i8] c"isready\00"
@.str.14 = [9 x i8] c"readyok\0A\00"
@.str.15 = [5 x i8] c"stop\00"
@.str.16 = [5 x i8] c"quit\00"
@.str.17 = [4 x i8] c"fen\00"
@.str.18 = [4 x i8] c"%s\0A\00"
@.str.19 = [5 x i8] c"test\00"
@.str.20 = [12 x i8] c"perft file \00"
@.str.21 = [6 x i8] c"perft\00"
@.str.22 = [11 x i8] c"ucinewgame\00"
@.str.23 = [9 x i8] c"position\00"
@.str.24 = [3 x i8] c"go\00"
@.str.25 = [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)
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.1, i64 0, i64 0))
br label %7
7: ; preds = %119, %85, %38, %12, %0
%8 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%9 = load i32, i32* @stdin
%10 = call i32 @fgets(i8* %8, i32 2048, i32 %9)
%11 = icmp ne i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %7
%13 = call i32 @usleep(i32 100000)
br label %7
14: ; preds = %7
%15 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%16 = call i64 @scandin(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %28
18: ; preds = %14
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.6, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([186 x i8], [186 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 ([55 x i8], [55 x i8]* @.str.9, i64 0, i64 0))
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.10, i64 0, i64 0))
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.11, i64 0, i64 0))
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0))
br label %119
28: ; preds = %14
%29 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%30 = call i64 @scandin(i8* %29, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i64 0, i64 0))
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.14, i64 0, i64 0))
br label %118
34: ; preds = %28
%35 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%36 = call i64 @scandin(i8* %35, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i64 0, i64 0))
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %34
br label %7
39: ; preds = %34
%40 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%41 = call i64 @scandin(i8* %40, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0))
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %39
br label %120
44: ; preds = %39
%45 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%46 = call i64 @scandin(i8* %45, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.17, i64 0, i64 0))
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %53
48: ; preds = %44
%49 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%50 = call i32 @board_fen(i8* %49)
%51 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.18, i64 0, i64 0), i8* %51)
br label %115
53: ; preds = %44
%54 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%55 = call i64 @scandin(i8* %54, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.19, i64 0, i64 0))
%56 = icmp ne i64 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %53
%58 = call i32 (...) @test()
br label %114
59: ; preds = %53
%60 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%61 = call i64 @scandin(i8* %60, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.20, i64 0, i64 0))
%62 = icmp ne i64 %61, 0
br i1 %62, label %63, label %72
63: ; preds = %59
%64 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%65 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%66 = getelementptr inbounds i8, i8* %65, i64 11
%67 = call i32 @strcpy(i8* %64, i8* %66)
%68 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%69 = call i32 @strip(i8* %68)
%70 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%71 = call i32 @perft_file(i8* %70)
br label %113
72: ; preds = %59
%73 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%74 = call i64 @scandin(i8* %73, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.21, i64 0, i64 0))
%75 = icmp ne i64 %74, 0
br i1 %75, label %76, label %81
76: ; preds = %72
%77 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%78 = call i32 @scan_int(i8* %77, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.21, i64 0, i64 0))
store i32 %78, i32* %3
%79 = load i32, i32* %3
%80 = call i32 @perft(i32 %79)
br label %112
81: ; preds = %72
%82 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%83 = call i64 @scandin(i8* %82, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.22, i64 0, i64 0))
%84 = icmp ne i64 %83, 0
br i1 %84, label %85, label %87
85: ; preds = %81
%86 = call i32 (...) @open_book()
br label %7
87: ; preds = %81
%88 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%89 = call i64 @scandin(i8* %88, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.23, i64 0, i64 0))
%90 = icmp ne i64 %89, 0
br i1 %90, label %91, label %94
91: ; preds = %87
%92 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%93 = call i32 @set_position(i8* %92)
br label %110
94: ; preds = %87
%95 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%96 = call i64 @scandin(i8* %95, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.24, i64 0, i64 0))
%97 = icmp ne i64 %96, 0
br i1 %97, label %98, label %101
98: ; preds = %94
%99 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%100 = call i32 @go(i8* %99)
br label %109
101: ; preds = %94
%102 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%103 = call i64 @scandin(i8* %102, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.25, i64 0, i64 0))
%104 = icmp ne i64 %103, 0
br i1 %104, label %105, label %108
105: ; preds = %101
%106 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%107 = call i32 @set_option(i8* %106)
br label %108
108: ; preds = %105, %101
br label %109
109: ; preds = %108, %98
br label %110
110: ; preds = %109, %91
br label %111
111: ; preds = %110
br label %112
112: ; preds = %111, %76
br label %113
113: ; preds = %112, %63
br label %114
114: ; preds = %113, %57
br label %115
115: ; preds = %114, %48
br label %116
116: ; preds = %115
br label %117
117: ; preds = %116
br label %118
118: ; preds = %117, %32
br label %119
119: ; preds = %118, %18
br label %7
120: ; preds = %43
%121 = call i32 (...) @close_book()
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"irina.bin\00"
@stdin = global i32 0
@.str.2 = [4 x i8] c"uci\00"
@.str.3 = [18 x i8] c"id name Irina %s\0A\00"
@.str.4 = [5 x i8] c"0.15\00"
@.str.13 = [8 x i8] c"isready\00"
@.str.15 = [5 x i8] c"stop\00"
@.str.16 = [5 x i8] c"quit\00"
@.str.17 = [4 x i8] c"fen\00"
@.str.19 = [5 x i8] c"test\00"
@.str.20 = [12 x i8] c"perft file \00"
@.str.21 = [6 x i8] c"perft\00"
@.str.22 = [11 x i8] c"ucinewgame\00"
@.str.23 = [9 x i8] c"position\00"
@.str.24 = [3 x i8] c"go\00"
@.str.25 = [15 x i8] c"setoption name\00"
@str = [136 x i8] c"Irina is a free adaptation of Winglet, chess engine created by Stef Luijten.\0AUsed to implement child personalities of Lucas Chess GUI.\0A\00"
@str.26 = [8 x i8] c"readyok\00"
@str.27 = [22 x i8] c"id author Lucas Monge\00"
@str.28 = [53 x i8] c"option name Hash type spin min 2 max 1024 default 32\00"
@str.29 = [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.30 = [54 x i8] c"option name Min Time type spin default 0 min 0 max 99\00"
@str.31 = [54 x i8] c"option name Max Time type spin default 0 min 0 max 99\00"
@str.32 = [44 x i8] c"option name OwnBook type check default true\00"
@str.33 = [54 x i8] c"option name OwnBookFile type string default irina.bin\00"
@str.34 = [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 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([136 x i8], [136 x i8]* @str, i64 0, i64 0))
%8 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 11
br label %9
9: ; preds = %28, %0
%10 = load i32, i32* @stdin
%11 = call i32 @fgets(i8* %3, i32 2048, i32 %10)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = call i32 @usleep(i32 100000)
br label %28
15: ; preds = %9
%16 = call i64 @scandin(i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %29, label %18
18: ; preds = %15
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.27, i64 0, i64 0))
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.28, i64 0, i64 0))
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([185 x i8], [185 x i8]* @str.29, i64 0, i64 0))
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.30, i64 0, i64 0))
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.31, i64 0, i64 0))
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.32, i64 0, i64 0))
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.33, i64 0, i64 0))
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.34, i64 0, i64 0))
br label %28
28: ; preds = %18, %43, %54, %77, %82, %79, %72, %61, %49, %32, %13, %67, %34
br label %9
29: ; preds = %15
%30 = call i64 @scandin(i8* %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %29
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.26, i64 0, i64 0))
br label %28
34: ; preds = %29
%35 = call i64 @scandin(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %28
37: ; preds = %34
%38 = call i64 @scandin(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %84
40: ; preds = %37
%41 = call i64 @scandin(i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.17, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %46, label %43
43: ; preds = %40
%44 = call i32 @board_fen(i8* %3)
%45 = call i32 @puts(i8* %3)
br label %28
46: ; preds = %40
%47 = call i64 @scandin(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.19, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %51, label %49
49: ; preds = %46
%50 = call i32 (...) @test()
br label %28
51: ; preds = %46
%52 = call i64 @scandin(i8* %3, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.20, i64 0, i64 0))
%53 = icmp eq i64 %52, 0
br i1 %53, label %58, label %54
54: ; preds = %51
%55 = call i32 @strcpy(i8* %4, i8* %8)
%56 = call i32 @strip(i8* %4)
%57 = call i32 @perft_file(i8* %4)
br label %28
58: ; preds = %51
%59 = call i64 @scandin(i8* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.21, i64 0, i64 0))
%60 = icmp eq i64 %59, 0
br i1 %60, label %64, label %61
61: ; preds = %58
%62 = call i32 @scan_int(i8* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.21, i64 0, i64 0))
%63 = call i32 @perft(i32 %62)
br label %28
64: ; preds = %58
%65 = call i64 @scandin(i8* %3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.22, i64 0, i64 0))
%66 = icmp eq i64 %65, 0
br i1 %66, label %69, label %67
67: ; preds = %64
%68 = call i32 (...) @open_book()
br label %28
69: ; preds = %64
%70 = call i64 @scandin(i8* %3, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.23, i64 0, i64 0))
%71 = icmp eq i64 %70, 0
br i1 %71, label %74, label %72
72: ; preds = %69
%73 = call i32 @set_position(i8* %3)
br label %28
74: ; preds = %69
%75 = call i64 @scandin(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.24, i64 0, i64 0))
%76 = icmp eq i64 %75, 0
br i1 %76, label %79, label %77
77: ; preds = %74
%78 = call i32 @go(i8* %3)
br label %28
79: ; preds = %74
%80 = call i64 @scandin(i8* %3, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.25, i64 0, i64 0))
%81 = icmp eq i64 %80, 0
br i1 %81, label %28, label %82
82: ; preds = %79
%83 = call i32 @set_option(i8* %3)
br label %28
84: ; preds = %37
%85 = call i32 (...) @close_book()
ret void
}