#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*/ eatSpace(char **);
scalar_t__ isalnum(char);
scalar_t__ isalpha(char);
char *mktmpstr(char *, int);
char *nextToken(char **p) {
  char *start;
  if (**p == '\0')
    return NULL;
  eatSpace(p);
  start = *p;
  if (isalpha(**p))
    do {
      (*p)++;
    } while (isalnum(**p));
  else if (**p == '[' || **p == ']' || **p == '?' || **p == '*' || **p == '.')
    (*p)++;
  else
    return NULL;
  return mktmpstr(start, (*p) - start);
}


x86 assembly (clang, -O0):
<nextToken>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    116c <nextToken+0x2c>
movq   $0x0,-0x8(%rbp)
jmp    126b <nextToken+0x12b>
mov    -0x10(%rbp),%rdi
call   1050 <eatSpace@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%edi
call   1060 <isalpha@plt>
cmp    $0x0,%rax
je     11ca <nextToken+0x8a>
jmp    119e <nextToken+0x5e>
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%rax
jne    119e <nextToken+0x5e>
jmp    124e <nextToken+0x10e>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x5b,%eax
je     1229 <nextToken+0xe9>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x5d,%eax
je     1229 <nextToken+0xe9>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x3f,%eax
je     1229 <nextToken+0xe9>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2a,%eax
je     1229 <nextToken+0xe9>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    123c <nextToken+0xfc>
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
jmp    1249 <nextToken+0x109>
movq   $0x0,-0x8(%rbp)
jmp    126b <nextToken+0x12b>
jmp    124e <nextToken+0x10e>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
call   1040 <mktmpstr@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nextToken>:
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%rax
cmpb   $0x0,(%rax)
je     11c4 <nextToken+0x84>
mov    %rdi,%rbx
call   1050 <eatSpace@plt>
mov    (%rbx),%r14
movsbl (%r14),%edi
call   1060 <isalpha@plt>
test   %rax,%rax
je     118d <nextToken+0x4d>
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%rbx),%rax
lea    0x1(%rax),%rcx
mov    %rcx,(%rbx)
movsbl 0x1(%rax),%edi
call   1030 <isalnum@plt>
test   %rax,%rax
jne    1170 <nextToken+0x30>
mov    (%rbx),%rsi
jmp    11b2 <nextToken+0x72>
mov    (%rbx),%rsi
mov    (%rsi),%al
add    $0xd6,%al
cmp    $0x33,%al
ja     11c4 <nextToken+0x84>
movzbl %al,%eax
movabs $0xa000000200011,%rcx
bt     %rax,%rcx
jae    11c4 <nextToken+0x84>
add    $0x1,%rsi
mov    %rsi,(%rbx)
sub    %r14d,%esi
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <mktmpstr@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @nextToken(i8** %0) {
%2 = alloca i8*
%3 = alloca i8**
%4 = alloca i8*
store i8** %0, i8*** %3
%5 = load i8**, i8*** %3
%6 = load i8*, i8** %5
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %1
store i8* null, i8** %2
br label %79
11: ; preds = %1
%12 = load i8**, i8*** %3
%13 = call i32 @eatSpace(i8** %12)
%14 = load i8**, i8*** %3
%15 = load i8*, i8** %14
store i8* %15, i8** %4
%16 = load i8**, i8*** %3
%17 = load i8*, i8** %16
%18 = load i8, i8* %17
%19 = call i64 @isalpha(i8 signext %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %33
21: ; preds = %11
br label %22
22: ; preds = %26, %21
%23 = load i8**, i8*** %3
%24 = load i8*, i8** %23
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %23
br label %26
26: ; preds = %22
%27 = load i8**, i8*** %3
%28 = load i8*, i8** %27
%29 = load i8, i8* %28
%30 = call i64 @isalnum(i8 signext %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %22, label %32
32: ; preds = %26
br label %69
33: ; preds = %11
%34 = load i8**, i8*** %3
%35 = load i8*, i8** %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 91
br i1 %38, label %63, label %39
39: ; preds = %33
%40 = load i8**, i8*** %3
%41 = load i8*, i8** %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 93
br i1 %44, label %63, label %45
45: ; preds = %39
%46 = load i8**, i8*** %3
%47 = load i8*, i8** %46
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %49, 63
br i1 %50, label %63, label %51
51: ; preds = %45
%52 = load i8**, i8*** %3
%53 = load i8*, i8** %52
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = icmp eq i32 %55, 42
br i1 %56, label %63, label %57
57: ; preds = %51
%58 = load i8**, i8*** %3
%59 = load i8*, i8** %58
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = icmp eq i32 %61, 46
br i1 %62, label %63, label %67
63: ; preds = %57, %51, %45, %39, %33
%64 = load i8**, i8*** %3
%65 = load i8*, i8** %64
%66 = getelementptr inbounds i8, i8* %65, i32 1
store i8* %66, i8** %64
br label %68
67: ; preds = %57
store i8* null, i8** %2
br label %79
68: ; preds = %63
br label %69
69: ; preds = %68, %32
%70 = load i8*, i8** %4
%71 = load i8**, i8*** %3
%72 = load i8*, i8** %71
%73 = load i8*, i8** %4
%74 = ptrtoint i8* %72 to i64
%75 = ptrtoint i8* %73 to i64
%76 = sub i64 %74, %75
%77 = trunc i64 %76 to i32
%78 = call i8* @mktmpstr(i8* %70, i32 %77)
store i8* %78, i8** %2
br label %79
79: ; preds = %69, %67, %10
%80 = load i8*, i8** %2
ret i8* %80
}

LLVM IR (-O2):
define i8* @nextToken(i8** %0) {
%2 = load i8*, i8** %0
%3 = load i8, i8* %2
%4 = icmp eq i8 %3, 0
br i1 %4, label %31, label %5
5: ; preds = %1
%6 = tail call i32 @eatSpace(i8** %0)
%7 = load i8*, i8** %0
%8 = load i8, i8* %7
%9 = tail call i64 @isalpha(i8 signext %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %5, %11
%12 = load i8*, i8** %0
%13 = getelementptr inbounds i8, i8* %12, i64 1
store i8* %13, i8** %0
%14 = load i8, i8* %13
%15 = tail call i64 @isalnum(i8 signext %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %22, label %11
17: ; preds = %5
%18 = load i8*, i8** %0
%19 = load i8, i8* %18
switch i8 %19, label %31 [
i8 91, label %20
i8 93, label %20
i8 63, label %20
i8 42, label %20
i8 46, label %20
]
20: ; preds = %17, %17, %17, %17, %17
%21 = getelementptr inbounds i8, i8* %18, i64 1
store i8* %21, i8** %0
br label %24
22: ; preds = %11
%23 = load i8*, i8** %0
br label %24
24: ; preds = %22, %20
%25 = phi i8* [ %23, %22 ], [ %21, %20 ]
%26 = ptrtoint i8* %25 to i64
%27 = ptrtoint i8* %7 to i64
%28 = sub i64 %26, %27
%29 = trunc i64 %28 to i32
%30 = tail call i8* @mktmpstr(i8* %7, i32 %29)
br label %31
31: ; preds = %17, %1, %24
%32 = phi i8* [ %30, %24 ], [ null, %1 ], [ null, %17 ]
ret i8* %32
}