#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*/ fread(char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ memcpy(char *, char const *, int);
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ stdin;
int stok(char const *, char **);
int /*<<< orphan*/ uesc(char *, char *);
int main() {
  static char buffer[65536];
  static char *names[] = {"EOF",  "SPACE",  "INT",    "FLOAT",
                          "NAME", "SYMBOL", "LITERAL"};
  int tok;
  const char *s, *t;
  fread(buffer, 1, sizeof buffer, stdin);
  s = buffer;
  do {
    static char buf[65536];
    tok = stok(s, (char **)&t);
    memcpy(buf, s, t - s);
    buf[t - s] = '\0';
    if (tok == 6) {
      uesc(buf, buf);
    }
    printf("%s\t%s\n", (tok < 0 ? "INVALID" : names[tok]), buf);
    s = t;
  } while (tok > 0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e82(%rip),%rax
mov    (%rax),%ecx
lea    0x2f31(%rip),%rdi
mov    $0x1,%esi
mov    $0x10000,%edx
call   1040 <fread@plt>
lea    0x2f1b(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1070 <stok@plt>
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
lea    0x12eff(%rip),%rdi
call   1060 <memcpy@plt>
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rax
sub    %rax,%rcx
lea    0x12ee8(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
cmpl   $0x6,-0x8(%rbp)
jne    11e5 <main+0x95>
lea    0x12ed3(%rip),%rsi
mov    %rsi,%rdi
call   1030 <uesc@plt>
cmpl   $0x0,-0x8(%rbp)
jge    11ff <main+0xaf>
lea    0xe39(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1212 <main+0xc2>
movslq -0x8(%rbp),%rcx
lea    0x2e46(%rip),%rax
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe0b(%rip),%rdi
lea    0x12e8c(%rip),%rdx
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
jg     1189 <main+0x39>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2e86(%rip),%rax
mov    (%rax),%ecx
lea    0x2ef5(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x10000,%edx
call   1040 <fread@plt>
mov    %rsp,%r14
lea    0x12ee9(%rip),%r12
lea    0xe72(%rip),%r13
lea    0xeaf(%rip),%r15
jmp    11c8 <main+0x78>
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r12,%rsi
call   1030 <uesc@plt>
mov    %ebp,%eax
movslq 0x0(%r13,%rax,4),%rsi
add    %r13,%rsi
mov    %r15,%rdi
mov    %r12,%rdx
call   1050 <printf@plt>
mov    (%rsp),%rbx
test   %ebp,%ebp
je     1214 <main+0xc4>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <stok@plt>
mov    %eax,%ebp
mov    (%rsp),%edx
sub    %ebx,%edx
mov    %r12,%rdi
mov    %rbx,%rsi
call   1060 <memcpy@plt>
mov    (%rsp),%rax
sub    %rbx,%rax
movb   $0x0,(%rax,%r12,1)
cmp    $0x6,%ebp
je     11a0 <main+0x50>
test   %ebp,%ebp
jns    11ab <main+0x5b>
lea    0xe43(%rip),%rdi
lea    0xe43(%rip),%rsi
lea    0x12e61(%rip),%rdx
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@main.buffer = internal global [65536 x i8] zeroinitializer
@main.names = internal global [7 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i32 0, i32 0)]
@.str = [4 x i8] c"EOF\00"
@.str.1 = [6 x i8] c"SPACE\00"
@.str.2 = [4 x i8] c"INT\00"
@.str.3 = [6 x i8] c"FLOAT\00"
@.str.4 = [5 x i8] c"NAME\00"
@.str.5 = [7 x i8] c"SYMBOL\00"
@.str.6 = [8 x i8] c"LITERAL\00"
@stdin = global i32 0
@main.buf = internal global [65536 x i8] zeroinitializer
@.str.7 = [7 x i8] c"%s\09%s\0A\00"
@.str.8 = [8 x i8] c"INVALID\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i32 0, i32* %1
%5 = load i32, i32* @stdin
%6 = call i32 @fread(i8* getelementptr inbounds ([65536 x i8], [65536 x i8]* @main.buffer, i64 0, i64 0), i32 1, i32 65536, i32 %5)
store i8* getelementptr inbounds ([65536 x i8], [65536 x i8]* @main.buffer, i64 0, i64 0), i8** %3
br label %7
7: ; preds = %41, %0
%8 = load i8*, i8** %3
%9 = call i32 @stok(i8* %8, i8** %4)
store i32 %9, i32* %2
%10 = load i8*, i8** %3
%11 = load i8*, i8** %4
%12 = load i8*, i8** %3
%13 = ptrtoint i8* %11 to i64
%14 = ptrtoint i8* %12 to i64
%15 = sub i64 %13, %14
%16 = trunc i64 %15 to i32
%17 = call i32 @memcpy(i8* getelementptr inbounds ([65536 x i8], [65536 x i8]* @main.buf, i64 0, i64 0), i8* %10, i32 %16)
%18 = load i8*, i8** %4
%19 = load i8*, i8** %3
%20 = ptrtoint i8* %18 to i64
%21 = ptrtoint i8* %19 to i64
%22 = sub i64 %20, %21
%23 = getelementptr inbounds [65536 x i8], [65536 x i8]* @main.buf, i64 0, i64 %22
store i8 0, i8* %23
%24 = load i32, i32* %2
%25 = icmp eq i32 %24, 6
br i1 %25, label %26, label %28
26: ; preds = %7
%27 = call i32 @uesc(i8* getelementptr inbounds ([65536 x i8], [65536 x i8]* @main.buf, i64 0, i64 0), i8* getelementptr inbounds ([65536 x i8], [65536 x i8]* @main.buf, i64 0, i64 0))
br label %28
28: ; preds = %26, %7
%29 = load i32, i32* %2
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %28
br label %37
32: ; preds = %28
%33 = load i32, i32* %2
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [7 x i8*], [7 x i8*]* @main.names, i64 0, i64 %34
%36 = load i8*, i8** %35
br label %37
37: ; preds = %32, %31
%38 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), %31 ], [ %36, %32 ]
%39 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* %38, i8* getelementptr inbounds ([65536 x i8], [65536 x i8]* @main.buf, i64 0, i64 0))
%40 = load i8*, i8** %4
store i8* %40, i8** %3
br label %41
41: ; preds = %37
%42 = load i32, i32* %2
%43 = icmp sgt i32 %42, 0
br i1 %43, label %7, label %44
44: ; preds = %41
ret i32 0
}

LLVM IR (-O2):
@main.buffer = internal global [65536 x i8] zeroinitializer
@reltable.main = internal unnamed_addr constant [7 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.1 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.2 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.3 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.4 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.5 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.6 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32)]
@.str = [4 x i8] c"EOF\00"
@.str.1 = [6 x i8] c"SPACE\00"
@.str.2 = [4 x i8] c"INT\00"
@.str.3 = [6 x i8] c"FLOAT\00"
@.str.4 = [5 x i8] c"NAME\00"
@.str.5 = [7 x i8] c"SYMBOL\00"
@.str.6 = [8 x i8] c"LITERAL\00"
@stdin = global i32 0
@main.buf = internal global [65536 x i8] zeroinitializer
@.str.7 = [7 x i8] c"%s\09%s\0A\00"
@.str.8 = [8 x i8] c"INVALID\00"
define i32 @main() {
%1 = alloca i8*
%2 = bitcast i8** %1 to i8*
%3 = load i32, i32* @stdin
%4 = tail call i32 @fread(i8* getelementptr inbounds ([65536 x i8], [65536 x i8]* @main.buffer, i64 0, i64 0), i32 1, i32 65536, i32 %3)
br label %5
5: ; preds = %25, %0
%6 = phi i8* [ getelementptr inbounds ([65536 x i8], [65536 x i8]* @main.buffer, i64 0, i64 0), %0 ], [ %30, %25 ]
%7 = call i32 @stok(i8* %6, i8** %1)
%8 = load i8*, i8** %1
%9 = ptrtoint i8* %8 to i64
%10 = ptrtoint i8* %6 to i64
%11 = sub i64 %9, %10
%12 = trunc i64 %11 to i32
%13 = call i32 @memcpy(i8* getelementptr inbounds ([65536 x i8], [65536 x i8]* @main.buf, i64 0, i64 0), i8* %6, i32 %12)
%14 = load i8*, i8** %1
%15 = ptrtoint i8* %14 to i64
%16 = sub i64 %15, %10
%17 = getelementptr inbounds [65536 x i8], [65536 x i8]* @main.buf, i64 0, i64 %16
store i8 0, i8* %17
%18 = icmp eq i32 %7, 6
br i1 %18, label %19, label %21
19: ; preds = %5
%20 = call i32 @uesc(i8* getelementptr inbounds ([65536 x i8], [65536 x i8]* @main.buf, i64 0, i64 0), i8* getelementptr inbounds ([65536 x i8], [65536 x i8]* @main.buf, i64 0, i64 0))
br label %25
21: ; preds = %5
%22 = icmp slt i32 %7, 0
br i1 %22, label %23, label %25
23: ; preds = %21
%24 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([65536 x i8], [65536 x i8]* @main.buf, i64 0, i64 0))
br label %32
25: ; preds = %21, %19
%26 = zext i32 %7 to i64
%27 = shl i64 %26, 2
%28 = call i8* @llvm.load.relative.i64(i8* bitcast ([7 x i32]* @reltable.main to i8*), i64 %27)
%29 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* %28, i8* getelementptr inbounds ([65536 x i8], [65536 x i8]* @main.buf, i64 0, i64 0))
%30 = load i8*, i8** %1
%31 = icmp eq i32 %7, 0
br i1 %31, label %32, label %5
32: ; preds = %25, %23
ret i32 0
}