#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 atoi(char const *);
int /*<<< orphan*/ fatal_error(char *, char *, int);
int strlen(char const *);
int get_move_count_int(const char *nmoves_str) {
  int nmoves;
  if ((1) <= 1 && !(nmoves_str != NULL))
    fatal_error("%s:%u: Assertion '"
                "nmoves_str != NULL"
                "' failed.",
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/cutechess/sloppy/refs/heads/"
                "master/src/notation.c",
                198);
  ;
  if (strlen(nmoves_str) < 1)
    return -1;
  nmoves = atoi(nmoves_str);
  if (nmoves < 0 || (nmoves * 2) >= 1024)
    return -1;
  return nmoves;
}


x86 assembly (clang, -O0):
<get_move_count_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    115f <get_move_count_int+0x2f>
lea    0xeb2(%rip),%rdi
lea    0xed9(%rip),%rsi
mov    $0xc6,%edx
call   1040 <fatal_error@plt>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
jge    117d <get_move_count_int+0x4d>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b6 <get_move_count_int+0x86>
mov    -0x10(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     11a4 <get_move_count_int+0x74>
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
cmp    $0x400,%eax
jl     11b0 <get_move_count_int+0x80>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b6 <get_move_count_int+0x86>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_move_count_int>:
push   %rbx
mov    %rdi,%rbx
test   %rdi,%rdi
jne    1151 <get_move_count_int+0x21>
lea    0xec0(%rip),%rdi
lea    0xee7(%rip),%rsi
mov    $0xc6,%edx
call   1040 <fatal_error@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    1176 <get_move_count_int+0x46>
mov    %rbx,%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
cmp    $0x200,%eax
mov    $0xffffffff,%eax
cmovb  %ecx,%eax
pop    %rbx
ret
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [46 x i8] c"%s:%u: Assertion 'nmoves_str != NULL' failed.\00"
@.str.1 = [140 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/cutechess/sloppy/refs/heads/master/src/notation.c\00"
define i32 @get_move_count_int(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = call i32 @fatal_error(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i32 198)
br label %9
9: ; preds = %7, %1
%10 = load i8*, i8** %3
%11 = call i32 @strlen(i8* %10)
%12 = icmp slt i32 %11, 1
br i1 %12, label %13, label %14
13: ; preds = %9
store i32 -1, i32* %2
br label %26
14: ; preds = %9
%15 = load i8*, i8** %3
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %4
%17 = load i32, i32* %4
%18 = icmp slt i32 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %14
%20 = load i32, i32* %4
%21 = mul nsw i32 %20, 2
%22 = icmp sge i32 %21, 1024
br i1 %22, label %23, label %24
23: ; preds = %19, %14
store i32 -1, i32* %2
br label %26
24: ; preds = %19
%25 = load i32, i32* %4
store i32 %25, i32* %2
br label %26
26: ; preds = %24, %23, %13
%27 = load i32, i32* %2
ret i32 %27
}

LLVM IR (-O2):
@.str = [46 x i8] c"%s:%u: Assertion 'nmoves_str != NULL' failed.\00"
@.str.1 = [140 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/cutechess/sloppy/refs/heads/master/src/notation.c\00"
define i32 @get_move_count_int(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @fatal_error(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i32 198)
br label %5
5: ; preds = %3, %1
%6 = tail call i32 @strlen(i8* %0)
%7 = icmp slt i32 %6, 1
br i1 %7, label %12, label %8
8: ; preds = %5
%9 = tail call i32 @atoi(i8* %0)
%10 = icmp ugt i32 %9, 511
%11 = select i1 %10, i32 -1, i32 %9
br label %12
12: ; preds = %8, %5
%13 = phi i32 [ -1, %5 ], [ %11, %8 ]
ret i32 %13
}