#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 */
char *UWAPI_StringDup(char const *);
int /*<<< orphan*/ free(char *);
int strlen(char *);
char *strtok(char *, char *);
int UWAPI_Board_Custom_ParsePositionString(char const *str, char **board) {
  static char *sep = "_";
  char *str_dup = UWAPI_StringDup(str);
  char *pch;
  pch = strtok(str_dup, sep);
  if (strlen(pch) != 1 || pch[0] != 'C') {
    free(str_dup);
    return 0;
  }
  if (board != NULL)
    *board = UWAPI_StringDup(&(pch[2]));
  free(str_dup);
  return 1;
}


x86 assembly (clang, -O0):
<UWAPI_Board_Custom_ParsePositionString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <UWAPI_StringDup@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2ed8(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x1,%eax
jne    1193 <UWAPI_Board_Custom_ParsePositionString+0x53>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x43,%eax
je     11a8 <UWAPI_Board_Custom_ParsePositionString+0x68>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
jmp    11da <UWAPI_Board_Custom_ParsePositionString+0x9a>
cmpq   $0x0,-0x18(%rbp)
je     11ca <UWAPI_Board_Custom_ParsePositionString+0x8a>
mov    -0x28(%rbp),%rdi
add    $0x2,%rdi
call   1050 <UWAPI_StringDup@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UWAPI_Board_Custom_ParsePositionString>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
call   1050 <UWAPI_StringDup@plt>
mov    %rax,%rbx
lea    0xea7(%rip),%rsi
mov    %rax,%rdi
call   1060 <strtok@plt>
mov    %rax,%rbp
mov    %rax,%rdi
call   1040 <strlen@plt>
xor    %r15d,%r15d
cmp    $0x1,%eax
jne    1194 <UWAPI_Board_Custom_ParsePositionString+0x54>
cmpb   $0x43,0x0(%rbp)
jne    1194 <UWAPI_Board_Custom_ParsePositionString+0x54>
mov    $0x1,%r15d
test   %r14,%r14
je     1194 <UWAPI_Board_Custom_ParsePositionString+0x54>
add    $0x2,%rbp
mov    %rbp,%rdi
call   1050 <UWAPI_StringDup@plt>
mov    %rax,(%r14)
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@UWAPI_Board_Custom_ParsePositionString.sep = internal global i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0)
@.str = [2 x i8] c"_\00"
define i32 @UWAPI_Board_Custom_ParsePositionString(i8* %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %4
store i8** %1, i8*** %5
%8 = load i8*, i8** %4
%9 = call i8* @UWAPI_StringDup(i8* %8)
store i8* %9, i8** %6
%10 = load i8*, i8** %6
%11 = load i8*, i8** @UWAPI_Board_Custom_ParsePositionString.sep
%12 = call i8* @strtok(i8* %10, i8* %11)
store i8* %12, i8** %7
%13 = load i8*, i8** %7
%14 = call i32 @strlen(i8* %13)
%15 = icmp ne i32 %14, 1
br i1 %15, label %22, label %16
16: ; preds = %2
%17 = load i8*, i8** %7
%18 = getelementptr inbounds i8, i8* %17, i64 0
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 67
br i1 %21, label %22, label %25
22: ; preds = %16, %2
%23 = load i8*, i8** %6
%24 = call i32 @free(i8* %23)
store i32 0, i32* %3
br label %36
25: ; preds = %16
%26 = load i8**, i8*** %5
%27 = icmp ne i8** %26, null
br i1 %27, label %28, label %33
28: ; preds = %25
%29 = load i8*, i8** %7
%30 = getelementptr inbounds i8, i8* %29, i64 2
%31 = call i8* @UWAPI_StringDup(i8* %30)
%32 = load i8**, i8*** %5
store i8* %31, i8** %32
br label %33
33: ; preds = %28, %25
%34 = load i8*, i8** %6
%35 = call i32 @free(i8* %34)
store i32 1, i32* %3
br label %36
36: ; preds = %33, %22
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@.str = [2 x i8] c"_\00"
define i32 @UWAPI_Board_Custom_ParsePositionString(i8* %0, i8** writeonly %1) {
%3 = tail call i8* @UWAPI_StringDup(i8* %0)
%4 = tail call i8* @strtok(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @strlen(i8* %4)
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %15
7: ; preds = %2
%8 = load i8, i8* %4
%9 = icmp eq i8 %8, 67
br i1 %9, label %10, label %15
10: ; preds = %7
%11 = icmp eq i8** %1, null
br i1 %11, label %15, label %12
12: ; preds = %10
%13 = getelementptr inbounds i8, i8* %4, i64 2
%14 = tail call i8* @UWAPI_StringDup(i8* %13)
store i8* %14, i8** %1
br label %15
15: ; preds = %10, %12, %2, %7
%16 = phi i32 [ 0, %7 ], [ 0, %2 ], [ 1, %12 ], [ 1, %10 ]
%17 = tail call i32 @free(i8* %3)
ret i32 %16
}