#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int getMoveFromLine(char *, char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
int getNextMove(FILE *gameFile, char *nextMove) {
  char line[1000];
  int status = -99;
  while (fgets(line, 1000, gameFile) != NULL) {
    char *szB = ";B[";
    char *szW = ";W[";
    if (!strncmp(line, szB, 3) || !strncmp(line, szW, 3)) {
      status = getMoveFromLine(line, nextMove);
      if (status == 0) {
        return 0;
      }
    }
  }
  return status;
}


x86 assembly (clang, -O0):
<getNextMove>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0xffffff9d,-0x404(%rbp)
ff ff ff
lea    -0x400(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x3e8,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1203 <getNextMove+0xd3>
lea    0xe8d(%rip),%rax
mov    %rax,-0x410(%rbp)
lea    0xe83(%rip),%rax
mov    %rax,-0x418(%rbp)
lea    -0x400(%rbp),%rdi
mov    -0x410(%rbp),%rsi
mov    $0x3,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
je     11ca <getNextMove+0x9a>
lea    -0x400(%rbp),%rdi
mov    -0x418(%rbp),%rsi
mov    $0x3,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    11fe <getNextMove+0xce>
lea    -0x400(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <getMoveFromLine@plt>
mov    %eax,-0x404(%rbp)
cmpl   $0x0,-0x404(%rbp)
jne    11f9 <getNextMove+0xc9>
movl   $0x0,-0x4(%rbp)
jmp    120c <getNextMove+0xdc>
jmp    11fe <getNextMove+0xce>
jmp    114d <getNextMove+0x1d>
mov    -0x404(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getNextMove>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3e8,%rsp
mov    %rsi,%r14
mov    %rdi,%r12
mov    %rsp,%rdi
mov    $0x3e8,%esi
mov    %r12,%rdx
call   1050 <fgets@plt>
mov    $0xffffff9d,%ebp
test   %rax,%rax
je     11d2 <getNextMove+0xa2>
lea    0xe98(%rip),%r15
mov    %rsp,%rbx
lea    0xe92(%rip),%r13
jmp    11a6 <getNextMove+0x76>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <getMoveFromLine@plt>
mov    %eax,%ebp
test   %eax,%eax
je     11d0 <getNextMove+0xa0>
mov    %rbx,%rdi
mov    $0x3e8,%esi
mov    %r12,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11d2 <getNextMove+0xa2>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x3,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
je     1180 <getNextMove+0x50>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x3,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
jne    1191 <getNextMove+0x61>
jmp    1180 <getNextMove+0x50>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x3e8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c";B[\00"
@.str.1 = [4 x i8] c";W[\00"
define i32 @getNextMove(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca [1000 x i8]
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32 -99, i32* %7
br label %10
10: ; preds = %33, %2
%11 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%12 = load i32*, i32** %4
%13 = call i32* @fgets(i8* %11, i32 1000, i32* %12)
%14 = icmp ne i32* %13, null
br i1 %14, label %15, label %34
15: ; preds = %10
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %8
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %9
%16 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%17 = load i8*, i8** %8
%18 = call i32 @strncmp(i8* %16, i8* %17, i32 3)
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %15
%21 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%22 = load i8*, i8** %9
%23 = call i32 @strncmp(i8* %21, i8* %22, i32 3)
%24 = icmp ne i32 %23, 0
br i1 %24, label %33, label %25
25: ; preds = %20, %15
%26 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%27 = load i8*, i8** %5
%28 = call i32 @getMoveFromLine(i8* %26, i8* %27)
store i32 %28, i32* %7
%29 = load i32, i32* %7
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %25
store i32 0, i32* %3
br label %36
32: ; preds = %25
br label %33
33: ; preds = %32, %20
br label %10
34: ; preds = %10
%35 = load i32, i32* %7
store i32 %35, i32* %3
br label %36
36: ; preds = %34, %31
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@.str = [4 x i8] c";B[\00"
@.str.1 = [4 x i8] c";W[\00"
define i32 @getNextMove(i32* nocapture %0, i8* %1) {
%3 = alloca [1000 x i8]
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%5 = call i32* @fgets(i8* %4, i32 1000, i32* %0)
%6 = icmp eq i32* %5, null
br i1 %6, label %21, label %7
7: ; preds = %2, %17
%8 = phi i32 [ %18, %17 ], [ -99, %2 ]
%9 = call i32 @strncmp(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%10 = icmp eq i32 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %7
%12 = call i32 @strncmp(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %11, %7
%15 = call i32 @getMoveFromLine(i8* %4, i8* %1)
%16 = icmp eq i32 %15, 0
br i1 %16, label %21, label %17
17: ; preds = %11, %14
%18 = phi i32 [ %8, %11 ], [ %15, %14 ]
%19 = call i32* @fgets(i8* %4, i32 1000, i32* %0)
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %7
21: ; preds = %17, %14, %2
%22 = phi i32 [ -99, %2 ], [ 0, %14 ], [ %18, %17 ]
ret i32 %22
}