#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*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ isspace(char);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strip_whitespace(char *);
int /*<<< orphan*/ valid_unquoted_char(char);
char *tokenizer_next_unquoted(char *input_p) {
  char *word, *input;
  assert(input_p != NULL);
  word = input = input_p;
  if (*input == 0)
    return NULL;
  if (!valid_unquoted_char(*input)) {
    fprintf(stderr, "Invalid unquoted character\n");
    return NULL;
  }
  while (*++input != 0) {
    if (isspace(*input)) {
      *input = 0;
      strip_whitespace(input + 1);
      break;
    }
    if (!valid_unquoted_char(*input)) {
      input_p = input;
      fprintf(stderr, "Invalid unquoted character\n");
      return NULL;
    }
  }
  input_p = input;
  return word;
}


x86 assembly (clang, -O0):
<tokenizer_next_unquoted>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1197 <tokenizer_next_unquoted+0x47>
movq   $0x0,-0x8(%rbp)
jmp    1272 <tokenizer_next_unquoted+0x122>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1070 <valid_unquoted_char@plt>
cmp    $0x0,%eax
jne    11ce <tokenizer_next_unquoted+0x7e>
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
lea    0xe44(%rip),%rsi
call   1060 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1272 <tokenizer_next_unquoted+0x122>
jmp    11d3 <tokenizer_next_unquoted+0x83>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     1262 <tokenizer_next_unquoted+0x112>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     121e <tokenizer_next_unquoted+0xce>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
call   1030 <strip_whitespace@plt>
jmp    1262 <tokenizer_next_unquoted+0x112>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1070 <valid_unquoted_char@plt>
cmp    $0x0,%eax
jne    125d <tokenizer_next_unquoted+0x10d>
mov    -0x20(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    0x2d9e(%rip),%rax
mov    (%rax),%edi
lea    0xdb5(%rip),%rsi
call   1060 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1272 <tokenizer_next_unquoted+0x122>
jmp    11d3 <tokenizer_next_unquoted+0x83>
mov    -0x20(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tokenizer_next_unquoted>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1050 <assert@plt>
mov    (%r14),%al
test   %al,%al
je     11bb <tokenizer_next_unquoted+0x6b>
movsbl %al,%edi
call   1070 <valid_unquoted_char@plt>
test   %eax,%eax
je     11a6 <tokenizer_next_unquoted+0x56>
lea    0x2(%r14),%rbx
nopl   0x0(%rax)
movzbl -0x1(%rbx),%eax
test   %al,%al
je     11be <tokenizer_next_unquoted+0x6e>
movsbl %al,%edi
call   1040 <isspace@plt>
test   %rax,%rax
jne    11c9 <tokenizer_next_unquoted+0x79>
movsbl -0x1(%rbx),%edi
call   1070 <valid_unquoted_char@plt>
add    $0x1,%rbx
test   %eax,%eax
jne    1180 <tokenizer_next_unquoted+0x30>
mov    0x2e33(%rip),%rax
mov    (%rax),%edi
lea    0xe4a(%rip),%rsi
call   1060 <fprintf@plt>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
movb   $0x0,-0x1(%rbx)
mov    %rbx,%rdi
call   1030 <strip_whitespace@plt>
jmp    11be <tokenizer_next_unquoted+0x6e>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [28 x i8] c"Invalid unquoted character\0A\00"
define i8* @tokenizer_next_unquoted(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = load i8*, i8** %3
store i8* %10, i8** %5
store i8* %10, i8** %4
%11 = load i8*, i8** %5
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %1
store i8* null, i8** %2
br label %54
16: ; preds = %1
%17 = load i8*, i8** %5
%18 = load i8, i8* %17
%19 = call i32 @valid_unquoted_char(i8 signext %18)
%20 = icmp ne i32 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %16
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
store i8* null, i8** %2
br label %54
24: ; preds = %16
br label %25
25: ; preds = %50, %24
%26 = load i8*, i8** %5
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %5
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %51
31: ; preds = %25
%32 = load i8*, i8** %5
%33 = load i8, i8* %32
%34 = call i64 @isspace(i8 signext %33)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %41
36: ; preds = %31
%37 = load i8*, i8** %5
store i8 0, i8* %37
%38 = load i8*, i8** %5
%39 = getelementptr inbounds i8, i8* %38, i64 1
%40 = call i32 @strip_whitespace(i8* %39)
br label %51
41: ; preds = %31
%42 = load i8*, i8** %5
%43 = load i8, i8* %42
%44 = call i32 @valid_unquoted_char(i8 signext %43)
%45 = icmp ne i32 %44, 0
br i1 %45, label %50, label %46
46: ; preds = %41
%47 = load i8*, i8** %5
store i8* %47, i8** %3
%48 = load i32, i32* @stderr
%49 = call i32 @fprintf(i32 %48, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
store i8* null, i8** %2
br label %54
50: ; preds = %41
br label %25
51: ; preds = %36, %25
%52 = load i8*, i8** %5
store i8* %52, i8** %3
%53 = load i8*, i8** %4
store i8* %53, i8** %2
br label %54
54: ; preds = %51, %46, %21, %15
%55 = load i8*, i8** %2
ret i8* %55
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [28 x i8] c"Invalid unquoted character\0A\00"
define i8* @tokenizer_next_unquoted(i8* %0) {
%2 = icmp ne i8* %0, null
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 0
br i1 %6, label %31, label %7
7: ; preds = %1
%8 = tail call i32 @valid_unquoted_char(i8 signext %5)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %31
13: ; preds = %7, %24
%14 = phi i8* [ %15, %24 ], [ %0, %7 ]
%15 = getelementptr inbounds i8, i8* %14, i64 1
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
br i1 %17, label %31, label %18
18: ; preds = %13
%19 = tail call i64 @isspace(i8 signext %16)
%20 = icmp eq i64 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %18
store i8 0, i8* %15
%22 = getelementptr inbounds i8, i8* %14, i64 2
%23 = tail call i32 @strip_whitespace(i8* %22)
br label %31
24: ; preds = %18
%25 = load i8, i8* %15
%26 = tail call i32 @valid_unquoted_char(i8 signext %25)
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %13
28: ; preds = %24
%29 = load i32, i32* @stderr
%30 = tail call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %31
31: ; preds = %13, %21, %1, %28, %10
%32 = phi i8* [ null, %28 ], [ null, %10 ], [ null, %1 ], [ %0, %21 ], [ %0, %13 ]
ret i8* %32
}