#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*/ EINVAL;
int /*<<< orphan*/ errno;
scalar_t__ isspace(char const);
int token_letter_get(const char **src, char *letter) {
  const char *tmp_src = NULL;
  if (src == NULL || letter == NULL) {
    errno = EINVAL;
    return -1;
  }
  tmp_src = *src;
  while (*tmp_src != '\0') {
    if (*tmp_src == '\n') {
      errno = EINVAL;
      return -1;
    } else if (isspace(*tmp_src)) {
      tmp_src++;
    } else {
      *letter = *tmp_src;
      *src = tmp_src + 1;
      return 0;
    }
  }
  errno = EINVAL;
  return -1;
}


x86 assembly (clang, -O0):
<token_letter_get>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     113e <token_letter_get+0x2e>
cmpq   $0x0,-0x18(%rbp)
jne    115c <token_letter_get+0x4c>
mov    0x2e93(%rip),%rax
mov    (%rax),%ecx
mov    0x2e92(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    1216 <token_letter_get+0x106>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11fd <token_letter_get+0xed>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    11a5 <token_letter_get+0x95>
mov    0x2e4a(%rip),%rax
mov    (%rax),%ecx
mov    0x2e49(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    1216 <token_letter_get+0x106>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
je     11cc <token_letter_get+0xbc>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11f3 <token_letter_get+0xe3>
mov    -0x20(%rbp),%rax
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x20(%rbp),%rcx
add    $0x1,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    1216 <token_letter_get+0x106>
jmp    11f8 <token_letter_get+0xe8>
jmp    1167 <token_letter_get+0x57>
mov    0x2dd4(%rip),%rax
mov    (%rax),%ecx
mov    0x2dd3(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<token_letter_get>:
push   %r15
push   %r14
push   %rbx
test   %rdi,%rdi
je     115a <token_letter_get+0x4a>
mov    %rsi,%r14
test   %rsi,%rsi
je     115a <token_letter_get+0x4a>
mov    %rdi,%r15
mov    (%rdi),%rbx
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
movzbl -0x1(%rbx),%eax
test   %al,%al
je     115a <token_letter_get+0x4a>
cmp    $0xa,%al
je     115a <token_letter_get+0x4a>
movsbl %al,%edi
call   1030 <isspace@plt>
test   %rax,%rax
jne    1130 <token_letter_get+0x20>
mov    -0x1(%rbx),%al
mov    %al,(%r14)
mov    %rbx,(%r15)
xor    %eax,%eax
jmp    1171 <token_letter_get+0x61>
mov    0x2e77(%rip),%rax
mov    (%rax),%eax
mov    0x2e76(%rip),%rcx
mov    %eax,(%rcx)
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EINVAL = global i32 0
@errno = global i32 0
define i32 @token_letter_get(i8** %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8*
store i8** %0, i8*** %4
store i8* %1, i8** %5
store i8* null, i8** %6
%7 = load i8**, i8*** %4
%8 = icmp eq i8** %7, null
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = load i8*, i8** %5
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %14
12: ; preds = %9, %2
%13 = load i32, i32* @EINVAL
store i32 %13, i32* @errno
store i32 -1, i32* %3
br label %48
14: ; preds = %9
%15 = load i8**, i8*** %4
%16 = load i8*, i8** %15
store i8* %16, i8** %6
br label %17
17: ; preds = %45, %14
%18 = load i8*, i8** %6
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %46
22: ; preds = %17
%23 = load i8*, i8** %6
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 10
br i1 %26, label %27, label %29
27: ; preds = %22
%28 = load i32, i32* @EINVAL
store i32 %28, i32* @errno
store i32 -1, i32* %3
br label %48
29: ; preds = %22
%30 = load i8*, i8** %6
%31 = load i8, i8* %30
%32 = call i64 @isspace(i8 signext %31)
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %29
%35 = load i8*, i8** %6
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %6
br label %44
37: ; preds = %29
%38 = load i8*, i8** %6
%39 = load i8, i8* %38
%40 = load i8*, i8** %5
store i8 %39, i8* %40
%41 = load i8*, i8** %6
%42 = getelementptr inbounds i8, i8* %41, i64 1
%43 = load i8**, i8*** %4
store i8* %42, i8** %43
store i32 0, i32* %3
br label %48
44: ; preds = %34
br label %45
45: ; preds = %44
br label %17
46: ; preds = %17
%47 = load i32, i32* @EINVAL
store i32 %47, i32* @errno
store i32 -1, i32* %3
br label %48
48: ; preds = %46, %37, %27, %12
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
@EINVAL = global i32 0
@errno = global i32 0
define i32 @token_letter_get(i8** %0, i8* writeonly %1) {
%3 = icmp eq i8** %0, null
%4 = icmp eq i8* %1, null
%5 = or i1 %3, %4
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = load i32, i32* @EINVAL
store i32 %7, i32* @errno
br label %25
8: ; preds = %2
%9 = load i8*, i8** %0
br label %10
10: ; preds = %18, %8
%11 = phi i8* [ %9, %8 ], [ %19, %18 ]
%12 = load i8, i8* %11
switch i8 %12, label %15 [
i8 0, label %23
i8 10, label %13
]
13: ; preds = %10
%14 = load i32, i32* @EINVAL
store i32 %14, i32* @errno
br label %25
15: ; preds = %10
%16 = tail call i64 @isspace(i8 signext %12)
%17 = icmp eq i64 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = getelementptr inbounds i8, i8* %11, i64 1
br label %10
20: ; preds = %15
%21 = load i8, i8* %11
store i8 %21, i8* %1
%22 = getelementptr inbounds i8, i8* %11, i64 1
store i8* %22, i8** %0
br label %25
23: ; preds = %10
%24 = load i32, i32* @EINVAL
store i32 %24, i32* @errno
br label %25
25: ; preds = %23, %20, %13, %6
%26 = phi i32 [ -1, %6 ], [ -1, %13 ], [ 0, %20 ], [ -1, %23 ]
ret i32 %26
}