#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 *, ...);
int /*<<< orphan*/ isspace(char);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strip_whitespace(char *);
char *tokenizer_next_string(char *input_p) {
  char *word, *dest, *input;
  assert(input_p != NULL);
  word = dest = input = input_p;
  if (*input == 0)
    return NULL;
  if (*input != '"') {
    fprintf(stderr, "Opening '\"' expected. Got %c \n", *input);
    return NULL;
  }
  ++input;
  while (*input != '"') {
    if (*input == '\\')
      ++input;
    if (*input == 0) {
      input_p = input - 1;
      fprintf(stderr, "Missing closing '\"'\n");
      return NULL;
    }
    *dest++ = *input++;
  }
  ++input;
  if (*input != 0 && !isspace(*input)) {
    input_p = input;
    fprintf(stderr, "Space expected after closing '\"'\n");
    return NULL;
  }
  *dest = 0;
  strip_whitespace(input_p);
  return word;
}


x86 assembly (clang, -O0):
<tokenizer_next_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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,-0x28(%rbp)
mov    %rax,-0x20(%rbp)
mov    %rax,-0x18(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    118b <tokenizer_next_string+0x4b>
movq   $0x0,-0x8(%rbp)
jmp    12da <tokenizer_next_string+0x19a>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
je     11c6 <tokenizer_next_string+0x86>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rax
movsbl (%rax),%edx
lea    0xe4e(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    12da <tokenizer_next_string+0x19a>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
je     1265 <tokenizer_next_string+0x125>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    11fe <tokenizer_next_string+0xbe>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    123e <tokenizer_next_string+0xfe>
mov    -0x28(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
mov    0x2dbf(%rip),%rax
mov    (%rax),%edi
lea    0xdf5(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    12da <tokenizer_next_string+0x19a>
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
mov    (%rax),%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
jmp    11d2 <tokenizer_next_string+0x92>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     12c2 <tokenizer_next_string+0x182>
mov    -0x28(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%eax
jne    12c2 <tokenizer_next_string+0x182>
mov    -0x28(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    0x2d3b(%rip),%rax
mov    (%rax),%edi
lea    0xd86(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    12da <tokenizer_next_string+0x19a>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
call   1030 <strip_whitespace@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tokenizer_next_string>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1050 <assert@plt>
movsbl (%r14),%edx
test   %edx,%edx
je     11a4 <tokenizer_next_string+0x64>
cmp    $0x22,%dl
jne    11a9 <tokenizer_next_string+0x69>
mov    %r14,%rbx
mov    %r14,%rax
nopl   0x0(%rax,%rax,1)
movzbl 0x1(%rax),%ecx
cmp    $0x5c,%cl
je     1190 <tokenizer_next_string+0x50>
cmp    $0x22,%cl
je     11e1 <tokenizer_next_string+0xa1>
add    $0x1,%rax
test   %cl,%cl
jne    119c <tokenizer_next_string+0x5c>
jmp    11c5 <tokenizer_next_string+0x85>
nopl   0x0(%rax,%rax,1)
movzbl 0x2(%rax),%ecx
add    $0x2,%rax
test   %cl,%cl
je     11c5 <tokenizer_next_string+0x85>
mov    %cl,(%rbx)
add    $0x1,%rbx
jmp    1170 <tokenizer_next_string+0x30>
xor    %r14d,%r14d
jmp    11ff <tokenizer_next_string+0xbf>
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
lea    0xe47(%rip),%rsi
xor    %r14d,%r14d
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    11ff <tokenizer_next_string+0xbf>
mov    0x2e14(%rip),%rax
mov    (%rax),%edi
lea    0xe4a(%rip),%rsi
xor    %r14d,%r14d
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    11ff <tokenizer_next_string+0xbf>
mov    0x2(%rax),%al
test   %al,%al
je     11f4 <tokenizer_next_string+0xb4>
movsbl %al,%edi
call   1040 <isspace@plt>
test   %eax,%eax
je     120a <tokenizer_next_string+0xca>
movb   $0x0,(%rbx)
mov    %r14,%rdi
call   1030 <strip_whitespace@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2dcf(%rip),%rax
mov    (%rax),%edi
lea    0xe1a(%rip),%rsi
jmp    11d5 <tokenizer_next_string+0x95>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [31 x i8] c"Opening '\22' expected. Got %c \0A\00"
@.str.1 = [21 x i8] c"Missing closing '\22'\0A\00"
@.str.2 = [34 x i8] c"Space expected after closing '\22'\0A\00"
define i8* @tokenizer_next_string(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = icmp ne i8* %7, null
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = load i8*, i8** %3
store i8* %11, i8** %6
store i8* %11, i8** %5
store i8* %11, i8** %4
%12 = load i8*, i8** %6
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %1
store i8* null, i8** %2
br label %81
17: ; preds = %1
%18 = load i8*, i8** %6
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 34
br i1 %21, label %22, label %28
22: ; preds = %17
%23 = load i32, i32* @stderr
%24 = load i8*, i8** %6
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %26)
store i8* null, i8** %2
br label %81
28: ; preds = %17
%29 = load i8*, i8** %6
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %6
br label %31
31: ; preds = %54, %28
%32 = load i8*, i8** %6
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp ne i32 %34, 34
br i1 %35, label %36, label %60
36: ; preds = %31
%37 = load i8*, i8** %6
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 92
br i1 %40, label %41, label %44
41: ; preds = %36
%42 = load i8*, i8** %6
%43 = getelementptr inbounds i8, i8* %42, i32 1
store i8* %43, i8** %6
br label %44
44: ; preds = %41, %36
%45 = load i8*, i8** %6
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %54
49: ; preds = %44
%50 = load i8*, i8** %6
%51 = getelementptr inbounds i8, i8* %50, i64 -1
store i8* %51, i8** %3
%52 = load i32, i32* @stderr
%53 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
store i8* null, i8** %2
br label %81
54: ; preds = %44
%55 = load i8*, i8** %6
%56 = getelementptr inbounds i8, i8* %55, i32 1
store i8* %56, i8** %6
%57 = load i8, i8* %55
%58 = load i8*, i8** %5
%59 = getelementptr inbounds i8, i8* %58, i32 1
store i8* %59, i8** %5
store i8 %57, i8* %58
br label %31
60: ; preds = %31
%61 = load i8*, i8** %6
%62 = getelementptr inbounds i8, i8* %61, i32 1
store i8* %62, i8** %6
%63 = load i8*, i8** %6
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = icmp ne i32 %65, 0
br i1 %66, label %67, label %76
67: ; preds = %60
%68 = load i8*, i8** %6
%69 = load i8, i8* %68
%70 = call i32 @isspace(i8 signext %69)
%71 = icmp ne i32 %70, 0
br i1 %71, label %76, label %72
72: ; preds = %67
%73 = load i8*, i8** %6
store i8* %73, i8** %3
%74 = load i32, i32* @stderr
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
store i8* null, i8** %2
br label %81
76: ; preds = %67, %60
%77 = load i8*, i8** %5
store i8 0, i8* %77
%78 = load i8*, i8** %3
%79 = call i32 @strip_whitespace(i8* %78)
%80 = load i8*, i8** %4
store i8* %80, i8** %2
br label %81
81: ; preds = %76, %72, %49, %22, %16
%82 = load i8*, i8** %2
ret i8* %82
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [31 x i8] c"Opening '\22' expected. Got %c \0A\00"
@.str.1 = [21 x i8] c"Missing closing '\22'\0A\00"
@.str.2 = [34 x i8] c"Space expected after closing '\22'\0A\00"
define i8* @tokenizer_next_string(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
switch i8 %5, label %6 [
i8 0, label %39
i8 34, label %10
]
6: ; preds = %1
%7 = sext i8 %5 to i32
%8 = load i32, i32* @stderr
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %39
10: ; preds = %1, %25
%11 = phi i8* [ %26, %25 ], [ %0, %1 ]
%12 = phi i8* [ %20, %25 ], [ %0, %1 ]
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = load i8, i8* %13
switch i8 %14, label %18 [
i8 34, label %27
i8 92, label %15
]
15: ; preds = %10
%16 = getelementptr inbounds i8, i8* %12, i64 2
%17 = load i8, i8* %16
br label %18
18: ; preds = %10, %15
%19 = phi i8 [ %14, %10 ], [ %17, %15 ]
%20 = phi i8* [ %13, %10 ], [ %16, %15 ]
%21 = icmp eq i8 %19, 0
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i32, i32* @stderr
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %39
25: ; preds = %18
%26 = getelementptr inbounds i8, i8* %11, i64 1
store i8 %19, i8* %11
br label %10
27: ; preds = %10
%28 = getelementptr inbounds i8, i8* %12, i64 2
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 0
br i1 %30, label %37, label %31
31: ; preds = %27
%32 = tail call i32 @isspace(i8 signext %29)
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = load i32, i32* @stderr
%36 = tail call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
br label %39
37: ; preds = %31, %27
store i8 0, i8* %11
%38 = tail call i32 @strip_whitespace(i8* %0)
br label %39
39: ; preds = %1, %37, %34, %22, %6
%40 = phi i8* [ null, %6 ], [ null, %22 ], [ %0, %37 ], [ null, %34 ], [ null, %1 ]
ret i8* %40
}