#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 */
struct stat {
  int dummy;
};
struct passwd {
  char *pw_dir;
};

/* Variables and functions */
scalar_t__ ENOENT;
int atoi(char *);
char *board_to_fen1(char *);
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int getopt(int, char **, char *);
struct passwd *getpwuid(int /*<<< orphan*/);
int /*<<< orphan*/ getuid();
scalar_t__ init_read_board(char *, char *);
char *optarg;
int optind;
int /*<<< orphan*/ print_help(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ read_board(char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *, ...);
int stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strncpy(char *, char *, int);
int main(int argc, char **argv) {
  struct passwd *pw = getpwuid(getuid());
  struct stat sts;
  const char *homedir = pw->pw_dir;
  char brd_buf[1024];
  snprintf(brd_buf, 1024, "%s/.robotxq/xq.brd", homedir);
  if (stat(brd_buf, &sts) == -1 && errno == ENOENT)
    strncpy(brd_buf,
            "/etc"
            "/xq.brd",
            1024);
  char *reader = "io_board";
  char *brd_file = brd_buf;
  int pass = 4;
  int opt;
  while ((opt = getopt(argc, argv, "hr:b:n:")) != -1) {
    switch (opt) {
    case 'r':
      reader = optarg;
      break;
    case 'b':
      brd_file = optarg;
      break;
    case 'n':
      pass = atoi(optarg);
      break;
    case 'h':
      print_help(argv[0]);
      return 0;
    default:
      print_help(argv[0]);
      return 1;
    }
  }
  if (optind >= argc) {
    fprintf(stderr, "expect device node after options\n");
    print_help(argv[0]);
    return 1;
  }
  char *dev = argv[optind];
  char reader_buf[1024];
  snprintf(reader_buf, 1024, "%s %s", reader, dev);
  if (init_read_board(reader_buf, brd_file) != 0)
    return 1;
  char board[90];
  read_board(board, pass);
  int i, j;
  printf("\n");
  for (i = 10 - 1; i >= 0; --i) {
    for (j = 0; j < 9; ++j) {
      printf("%c", board[i * 9 + j]);
    }
    printf("\n");
  }
  printf("\n");
  printf("%s\n", board_to_fen1(board));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x8c0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1060 <getuid@plt>
mov    %eax,%edi
call   1040 <getpwuid@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
lea    -0x430(%rbp),%rdi
mov    -0x28(%rbp),%rcx
mov    $0x400,%esi
lea    0xe27(%rip),%rdx
mov    $0x0,%al
call   1080 <snprintf@plt>
lea    -0x430(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   10a0 <stat@plt>
cmp    $0xffffffff,%eax
jne    126f <main+0x9f>
mov    0x2d84(%rip),%rax
mov    (%rax),%rax
mov    0x2d6a(%rip),%rcx
cmp    (%rcx),%rax
jne    126f <main+0x9f>
lea    -0x430(%rbp),%rdi
lea    0xdf2(%rip),%rsi
mov    $0x400,%edx
call   1030 <strncpy@plt>
lea    0xded(%rip),%rax
mov    %rax,-0x438(%rbp)
lea    -0x430(%rbp),%rax
mov    %rax,-0x440(%rbp)
movl   $0x4,-0x444(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xdc9(%rip),%rdx
call   10d0 <getopt@plt>
mov    %eax,-0x448(%rbp)
cmp    $0xffffffff,%eax
je     1364 <main+0x194>
mov    -0x448(%rbp),%eax
add    $0xffffff9e,%eax
mov    %eax,%ecx
mov    %rcx,-0x8c0(%rbp)
sub    $0x10,%eax
ja     1347 <main+0x177>
mov    -0x8c0(%rbp),%rax
lea    0xd20(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2d08(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x438(%rbp)
jmp    135f <main+0x18f>
mov    0x2cf2(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x440(%rbp)
jmp    135f <main+0x18f>
mov    0x2cdc(%rip),%rax
mov    (%rax),%rdi
call   10e0 <atoi@plt>
mov    %eax,-0x444(%rbp)
jmp    135f <main+0x18f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10f0 <print_help@plt>
movl   $0x0,-0x4(%rbp)
jmp    14e8 <main+0x318>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10f0 <print_help@plt>
movl   $0x1,-0x4(%rbp)
jmp    14e8 <main+0x318>
jmp    1295 <main+0xc5>
mov    0x2c75(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jl     13a3 <main+0x1d3>
mov    0x2c53(%rip),%rax
mov    (%rax),%edi
lea    0xcee(%rip),%rsi
call   1090 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10f0 <print_help@plt>
movl   $0x1,-0x4(%rbp)
jmp    14e8 <main+0x318>
mov    -0x10(%rbp),%rax
mov    0x2c32(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x450(%rbp)
lea    -0x850(%rbp),%rdi
mov    -0x438(%rbp),%rcx
mov    -0x450(%rbp),%r8
mov    $0x400,%esi
lea    0xcb9(%rip),%rdx
mov    $0x0,%al
call   1080 <snprintf@plt>
lea    -0x850(%rbp),%rdi
mov    -0x440(%rbp),%rsi
call   10b0 <init_read_board@plt>
cmp    $0x0,%rax
je     140d <main+0x23d>
movl   $0x1,-0x4(%rbp)
jmp    14e8 <main+0x318>
lea    -0x8b0(%rbp),%rdi
mov    -0x444(%rbp),%esi
call   1050 <read_board@plt>
lea    0xc7b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x9,-0x8b4(%rbp)
cmpl   $0x0,-0x8b4(%rbp)
jl     14b6 <main+0x2e6>
movl   $0x0,-0x8b8(%rbp)
cmpl   $0x9,-0x8b8(%rbp)
jge    1494 <main+0x2c4>
imul   $0x9,-0x8b4(%rbp),%eax
add    -0x8b8(%rbp),%eax
cltq
movsbl -0x8b0(%rbp,%rax,1),%esi
ff
lea    0xc23(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x8b8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8b8(%rbp)
jmp    144e <main+0x27e>
lea    0xc06(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x8b4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8b4(%rbp)
jmp    1437 <main+0x267>
lea    0xbe4(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x8b0(%rbp),%rdi
call   10c0 <board_to_fen1@plt>
mov    %rax,%rsi
lea    0xbc5(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x8c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x888,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %eax,%eax
call   1080 <getuid@plt>
mov    %eax,%edi
call   1060 <getpwuid@plt>
mov    (%rax),%rcx
lea    0xe16(%rip),%rdx
lea    0x80(%rsp),%r14
mov    %r14,%rdi
mov    $0x400,%esi
xor    %eax,%eax
call   1090 <snprintf@plt>
lea    0x18(%rsp),%rsi
mov    %r14,%rdi
call   10b0 <stat@plt>
cmp    $0xffffffff,%eax
jne    1266 <main+0x86>
mov    0x2d8a(%rip),%rax
mov    (%rax),%rax
mov    0x2d70(%rip),%rcx
cmp    (%rcx),%rax
jne    1266 <main+0x86>
lea    0xde3(%rip),%rsi
lea    0x80(%rsp),%rdi
mov    $0x400,%edx
call   1040 <strncpy@plt>
lea    0xddf(%rip),%rdx
mov    %ebp,%edi
mov    %rbx,%rsi
call   10e0 <getopt@plt>
cmp    $0xffffffff,%eax
je     130f <main+0x12f>
movl   $0x4,0xc(%rsp)
lea    0xdb4(%rip),%rcx
mov    %rcx,0x10(%rsp)
lea    0x80(%rsp),%r14
lea    0xd5d(%rip),%r15
mov    0x2d4e(%rip),%r12
lea    0xd9b(%rip),%r13
jmp    12db <main+0xfb>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r12),%rax
mov    %rax,0x10(%rsp)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r13,%rdx
call   10e0 <getopt@plt>
cmp    $0xffffffff,%eax
je     1323 <main+0x143>
add    $0xffffff9e,%eax
ror    %eax
cmp    $0x8,%eax
ja     143d <main+0x25d>
movslq (%r15,%rax,4),%rax
add    %r15,%rax
jmp    *%rax
mov    (%r12),%r14
jmp    12c9 <main+0xe9>
nopl   0x0(%rax,%rax,1)
mov    (%r12),%rdi
call   10f0 <atoi@plt>
mov    %eax,0xc(%rsp)
jmp    12c9 <main+0xe9>
lea    0xd2d(%rip),%rax
mov    %rax,0x10(%rsp)
movl   $0x4,0xc(%rsp)
mov    0x2cb6(%rip),%rax
movslq (%rax),%rax
cmp    %ebp,%eax
jge    1428 <main+0x248>
mov    (%rbx,%rax,8),%r8
lea    0xd36(%rip),%rdx
lea    0x480(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
mov    0x10(%rsp),%rcx
xor    %eax,%eax
call   1090 <snprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   10c0 <init_read_board@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    1456 <main+0x276>
lea    0x20(%rsp),%rdi
mov    0xc(%rsp),%esi
call   1070 <read_board@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x5a,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
movsbl 0x17(%rsp,%rbx,1),%edi
call   1030 <putchar@plt>
movsbl 0x18(%rsp,%rbx,1),%edi
call   1030 <putchar@plt>
movsbl 0x19(%rsp,%rbx,1),%edi
call   1030 <putchar@plt>
movsbl 0x1a(%rsp,%rbx,1),%edi
call   1030 <putchar@plt>
movsbl 0x1b(%rsp,%rbx,1),%edi
call   1030 <putchar@plt>
movsbl 0x1c(%rsp,%rbx,1),%edi
call   1030 <putchar@plt>
movsbl 0x1d(%rsp,%rbx,1),%edi
call   1030 <putchar@plt>
movsbl 0x1e(%rsp,%rbx,1),%edi
call   1030 <putchar@plt>
movsbl 0x1f(%rsp,%rbx,1),%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0xfffffffffffffff7,%rbx
jne    13a0 <main+0x1c0>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x20(%rsp),%rdi
call   10d0 <board_to_fen1@plt>
mov    %rax,%rdi
call   1050 <puts@plt>
jmp    1454 <main+0x274>
mov    0x2ba1(%rip),%rax
mov    (%rax),%edi
lea    0xc1c(%rip),%rsi
call   10a0 <fprintf@plt>
mov    (%rbx),%rdi
call   1100 <print_help@plt>
mov    $0x1,%eax
jmp    1456 <main+0x276>
mov    (%rbx),%rdi
call   1100 <print_help@plt>
xor    %eax,%eax
add    $0x888,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.passwd = type { i8* }
%struct.stat = type { i32 }
@.str = [19 x i8] c"%s/.robotxq/xq.brd\00"
@errno = global i64 0
@ENOENT = global i64 0
@.str.1 = [12 x i8] c"/etc/xq.brd\00"
@.str.2 = [9 x i8] c"io_board\00"
@.str.3 = [8 x i8] c"hr:b:n:\00"
@optarg = global i8* null
@optind = global i32 0
@stderr = global i32 0
@.str.4 = [34 x i8] c"expect device node after options\0A\00"
@.str.5 = [6 x i8] c"%s %s\00"
@.str.6 = [2 x i8] c"\0A\00"
@.str.7 = [3 x i8] c"%c\00"
@.str.8 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.passwd*
%7 = alloca %struct.stat
%8 = alloca i8*
%9 = alloca [1024 x i8]
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8*
%15 = alloca [1024 x i8]
%16 = alloca [90 x i8]
%17 = alloca i32
%18 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%19 = call i32 (...) @getuid()
%20 = call %struct.passwd* @getpwuid(i32 %19)
store %struct.passwd* %20, %struct.passwd** %6
%21 = load %struct.passwd*, %struct.passwd** %6
%22 = getelementptr inbounds %struct.passwd, %struct.passwd* %21, i32 0, i32 0
%23 = load i8*, i8** %22
store i8* %23, i8** %8
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%25 = load i8*, i8** %8
%26 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %24, i32 1024, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %25)
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%28 = call i32 @stat(i8* %27, %struct.stat* %7)
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %37
30: ; preds = %2
%31 = load i64, i64* @errno
%32 = load i64, i64* @ENOENT
%33 = icmp eq i64 %31, %32
br i1 %33, label %34, label %37
34: ; preds = %30
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%36 = call i32 @strncpy(i8* %35, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 1024)
br label %37
37: ; preds = %34, %30, %2
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8** %10
%38 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
store i8* %38, i8** %11
store i32 4, i32* %12
br label %39
39: ; preds = %63, %37
%40 = load i32, i32* %4
%41 = load i8**, i8*** %5
%42 = call i32 @getopt(i32 %40, i8** %41, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
store i32 %42, i32* %13
%43 = icmp ne i32 %42, -1
br i1 %43, label %44, label %64
44: ; preds = %39
%45 = load i32, i32* %13
switch i32 %45, label %58 [
i32 114, label %46
i32 98, label %48
i32 110, label %50
i32 104, label %53
]
46: ; preds = %44
%47 = load i8*, i8** @optarg
store i8* %47, i8** %10
br label %63
48: ; preds = %44
%49 = load i8*, i8** @optarg
store i8* %49, i8** %11
br label %63
50: ; preds = %44
%51 = load i8*, i8** @optarg
%52 = call i32 @atoi(i8* %51)
store i32 %52, i32* %12
br label %63
53: ; preds = %44
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 0
%56 = load i8*, i8** %55
%57 = call i32 @print_help(i8* %56)
store i32 0, i32* %3
br label %125
58: ; preds = %44
%59 = load i8**, i8*** %5
%60 = getelementptr inbounds i8*, i8** %59, i64 0
%61 = load i8*, i8** %60
%62 = call i32 @print_help(i8* %61)
store i32 1, i32* %3
br label %125
63: ; preds = %50, %48, %46
br label %39
64: ; preds = %39
%65 = load i32, i32* @optind
%66 = load i32, i32* %4
%67 = icmp sge i32 %65, %66
br i1 %67, label %68, label %75
68: ; preds = %64
%69 = load i32, i32* @stderr
%70 = call i32 @fprintf(i32 %69, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
%71 = load i8**, i8*** %5
%72 = getelementptr inbounds i8*, i8** %71, i64 0
%73 = load i8*, i8** %72
%74 = call i32 @print_help(i8* %73)
store i32 1, i32* %3
br label %125
75: ; preds = %64
%76 = load i8**, i8*** %5
%77 = load i32, i32* @optind
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds i8*, i8** %76, i64 %78
%80 = load i8*, i8** %79
store i8* %80, i8** %14
%81 = getelementptr inbounds [1024 x i8], [1024 x i8]* %15, i64 0, i64 0
%82 = load i8*, i8** %10
%83 = load i8*, i8** %14
%84 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %81, i32 1024, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* %82, i8* %83)
%85 = getelementptr inbounds [1024 x i8], [1024 x i8]* %15, i64 0, i64 0
%86 = load i8*, i8** %11
%87 = call i64 @init_read_board(i8* %85, i8* %86)
%88 = icmp ne i64 %87, 0
br i1 %88, label %89, label %90
89: ; preds = %75
store i32 1, i32* %3
br label %125
90: ; preds = %75
%91 = getelementptr inbounds [90 x i8], [90 x i8]* %16, i64 0, i64 0
%92 = load i32, i32* %12
%93 = call i32 @read_board(i8* %91, i32 %92)
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i32 9, i32* %17
br label %95
95: ; preds = %117, %90
%96 = load i32, i32* %17
%97 = icmp sge i32 %96, 0
br i1 %97, label %98, label %120
98: ; preds = %95
store i32 0, i32* %18
br label %99
99: ; preds = %112, %98
%100 = load i32, i32* %18
%101 = icmp slt i32 %100, 9
br i1 %101, label %102, label %115
102: ; preds = %99
%103 = load i32, i32* %17
%104 = mul nsw i32 %103, 9
%105 = load i32, i32* %18
%106 = add nsw i32 %104, %105
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds [90 x i8], [90 x i8]* %16, i64 0, i64 %107
%109 = load i8, i8* %108
%110 = sext i8 %109 to i32
%111 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 %110)
br label %112
112: ; preds = %102
%113 = load i32, i32* %18
%114 = add nsw i32 %113, 1
store i32 %114, i32* %18
br label %99
115: ; preds = %99
%116 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %117
117: ; preds = %115
%118 = load i32, i32* %17
%119 = add nsw i32 %118, -1
store i32 %119, i32* %17
br label %95
120: ; preds = %95
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%122 = getelementptr inbounds [90 x i8], [90 x i8]* %16, i64 0, i64 0
%123 = call i8* @board_to_fen1(i8* %122)
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %123)
store i32 0, i32* %3
br label %125
125: ; preds = %120, %89, %68, %58, %53
%126 = load i32, i32* %3
ret i32 %126
}

LLVM IR (-O2):
%struct.stat = type { i32 }
%struct.passwd = type { i8* }
@.str = [19 x i8] c"%s/.robotxq/xq.brd\00"
@errno = global i64 0
@ENOENT = global i64 0
@.str.1 = [12 x i8] c"/etc/xq.brd\00"
@.str.2 = [9 x i8] c"io_board\00"
@.str.3 = [8 x i8] c"hr:b:n:\00"
@optarg = global i8* null
@optind = global i32 0
@stderr = global i32 0
@.str.4 = [34 x i8] c"expect device node after options\0A\00"
@.str.5 = [6 x i8] c"%s %s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca %struct.stat
%4 = alloca [1024 x i8]
%5 = alloca [1024 x i8]
%6 = alloca [90 x i8]
%7 = tail call i32 (...) @getuid()
%8 = tail call %struct.passwd* @getpwuid(i32 %7)
%9 = bitcast %struct.stat* %3 to i8*
%10 = getelementptr inbounds %struct.passwd, %struct.passwd* %8, i64 0, i32 0
%11 = load i8*, i8** %10
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%13 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %12, i32 1024, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %11)
%14 = call i32 @stat(i8* %12, %struct.stat* %3)
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %22
16: ; preds = %2
%17 = load i64, i64* @errno
%18 = load i64, i64* @ENOENT
%19 = icmp eq i64 %17, %18
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 @strncpy(i8* %12, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 1024)
br label %22
22: ; preds = %20, %16, %2
%23 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp eq i32 %23, -1
br i1 %24, label %51, label %25
25: ; preds = %22, %45
%26 = phi i32 [ %49, %45 ], [ %23, %22 ]
%27 = phi i8* [ %48, %45 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), %22 ]
%28 = phi i32 [ %47, %45 ], [ 4, %22 ]
%29 = phi i8* [ %46, %45 ], [ %12, %22 ]
%30 = add i32 %26, -98
%31 = call i32 @llvm.fshl.i32(i32 %30, i32 %30, i32 31)
switch i32 %31, label %42 [
i32 8, label %32
i32 0, label %34
i32 6, label %36
i32 3, label %39
]
32: ; preds = %25
%33 = load i8*, i8** @optarg
br label %45
34: ; preds = %25
%35 = load i8*, i8** @optarg
br label %45
36: ; preds = %25
%37 = load i8*, i8** @optarg
%38 = call i32 @atoi(i8* %37)
br label %45
39: ; preds = %25
%40 = load i8*, i8** %1
%41 = call i32 @print_help(i8* %40)
br label %130
42: ; preds = %25
%43 = load i8*, i8** %1
%44 = call i32 @print_help(i8* %43)
br label %130
45: ; preds = %36, %34, %32
%46 = phi i8* [ %29, %36 ], [ %35, %34 ], [ %29, %32 ]
%47 = phi i32 [ %38, %36 ], [ %28, %34 ], [ %28, %32 ]
%48 = phi i8* [ %27, %36 ], [ %27, %34 ], [ %33, %32 ]
%49 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%50 = icmp eq i32 %49, -1
br i1 %50, label %51, label %25
51: ; preds = %45, %22
%52 = phi i8* [ %12, %22 ], [ %46, %45 ]
%53 = phi i32 [ 4, %22 ], [ %47, %45 ]
%54 = phi i8* [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), %22 ], [ %48, %45 ]
%55 = load i32, i32* @optind
%56 = icmp slt i32 %55, %0
br i1 %56, label %62, label %57
57: ; preds = %51
%58 = load i32, i32* @stderr
%59 = call i32 @fprintf(i32 %58, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
%60 = load i8*, i8** %1
%61 = call i32 @print_help(i8* %60)
br label %130
62: ; preds = %51
%63 = sext i32 %55 to i64
%64 = getelementptr inbounds i8*, i8** %1, i64 %63
%65 = load i8*, i8** %64
%66 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%67 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %66, i32 1024, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* %54, i8* %65)
%68 = call i64 @init_read_board(i8* %66, i8* %52)
%69 = icmp eq i64 %68, 0
br i1 %69, label %70, label %128
70: ; preds = %62
%71 = getelementptr inbounds [90 x i8], [90 x i8]* %6, i64 0, i64 0
%72 = call i32 @read_board(i8* %71, i32 %53)
%73 = call i32 @putchar(i32 10)
br label %74
74: ; preds = %70, %74
%75 = phi i64 [ 9, %70 ], [ %122, %74 ]
%76 = mul nuw nsw i64 %75, 9
%77 = getelementptr inbounds [90 x i8], [90 x i8]* %6, i64 0, i64 %76
%78 = load i8, i8* %77
%79 = sext i8 %78 to i32
%80 = call i32 @putchar(i32 %79)
%81 = add nuw nsw i64 %76, 1
%82 = getelementptr inbounds [90 x i8], [90 x i8]* %6, i64 0, i64 %81
%83 = load i8, i8* %82
%84 = sext i8 %83 to i32
%85 = call i32 @putchar(i32 %84)
%86 = add nuw nsw i64 %76, 2
%87 = getelementptr inbounds [90 x i8], [90 x i8]* %6, i64 0, i64 %86
%88 = load i8, i8* %87
%89 = sext i8 %88 to i32
%90 = call i32 @putchar(i32 %89)
%91 = add nuw nsw i64 %76, 3
%92 = getelementptr inbounds [90 x i8], [90 x i8]* %6, i64 0, i64 %91
%93 = load i8, i8* %92
%94 = sext i8 %93 to i32
%95 = call i32 @putchar(i32 %94)
%96 = add nuw nsw i64 %76, 4
%97 = getelementptr inbounds [90 x i8], [90 x i8]* %6, i64 0, i64 %96
%98 = load i8, i8* %97
%99 = sext i8 %98 to i32
%100 = call i32 @putchar(i32 %99)
%101 = add nuw nsw i64 %76, 5
%102 = getelementptr inbounds [90 x i8], [90 x i8]* %6, i64 0, i64 %101
%103 = load i8, i8* %102
%104 = sext i8 %103 to i32
%105 = call i32 @putchar(i32 %104)
%106 = add nuw nsw i64 %76, 6
%107 = getelementptr inbounds [90 x i8], [90 x i8]* %6, i64 0, i64 %106
%108 = load i8, i8* %107
%109 = sext i8 %108 to i32
%110 = call i32 @putchar(i32 %109)
%111 = add nuw nsw i64 %76, 7
%112 = getelementptr inbounds [90 x i8], [90 x i8]* %6, i64 0, i64 %111
%113 = load i8, i8* %112
%114 = sext i8 %113 to i32
%115 = call i32 @putchar(i32 %114)
%116 = add nuw nsw i64 %76, 8
%117 = getelementptr inbounds [90 x i8], [90 x i8]* %6, i64 0, i64 %116
%118 = load i8, i8* %117
%119 = sext i8 %118 to i32
%120 = call i32 @putchar(i32 %119)
%121 = call i32 @putchar(i32 10)
%122 = add nsw i64 %75, -1
%123 = icmp eq i64 %75, 0
br i1 %123, label %124, label %74
124: ; preds = %74
%125 = call i32 @putchar(i32 10)
%126 = call i8* @board_to_fen1(i8* %71)
%127 = call i32 @puts(i8* dereferenceable(1) %126)
br label %128
128: ; preds = %62, %124
%129 = phi i32 [ 0, %124 ], [ 1, %62 ]
br label %130
130: ; preds = %128, %57, %42, %39
%131 = phi i32 [ 1, %42 ], [ 0, %39 ], [ 1, %57 ], [ %129, %128 ]
ret i32 %131
}