#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EOF;
int /*<<< orphan*/ SEEK_CUR;
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int getc(int /*<<< orphan*/ *);
int next_word(FILE *file, char *buffer, int buffer_len) {
  int ch;
  int len = 0;
  int quoted = 0;
  int escaped = 0;
  while ((ch = getc(file)) != EOF && len < buffer_len) {
    if (escaped) {
      escaped = 0;
      buffer[len] = (char)ch;
      len++;
      continue;
    }
    switch (ch) {
    case '\\':
      escaped = 1;
      break;
    case '\"':
      quoted = 1 - quoted;
      break;
    case ' ':
    case '\t':
    case ';':
    case '\n':
    case '\r':
    case '#':
    case '{':
    case '}':
      if (quoted == 0) {
        fseek(file, -1, SEEK_CUR);
        buffer[len] = '\0';
        len++;
        return len;
      }
    default:
      buffer[len] = (char)ch;
      len++;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<next_word>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <getc@plt>
mov    %eax,%ecx
mov    %ecx,-0x20(%rbp)
xor    %eax,%eax
mov    0x2e81(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x2d(%rbp)
je     1176 <next_word+0x56>
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
setl   %al
mov    %al,-0x2d(%rbp)
mov    -0x2d(%rbp),%al
test   $0x1,%al
jne    1186 <next_word+0x66>
jmp    12d4 <next_word+0x1b4>
cmpl   $0x0,-0x2c(%rbp)
je     11b5 <next_word+0x95>
movl   $0x0,-0x2c(%rbp)
mov    -0x20(%rbp),%eax
mov    %al,%dl
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1148 <next_word+0x28>
mov    -0x20(%rbp),%eax
mov    %eax,-0x34(%rbp)
add    $0xfffffff7,%eax
sub    $0x2,%eax
jb     1270 <next_word+0x150>
jmp    11cc <next_word+0xac>
mov    -0x34(%rbp),%eax
sub    $0xd,%eax
je     1270 <next_word+0x150>
jmp    11dd <next_word+0xbd>
mov    -0x34(%rbp),%eax
sub    $0x20,%eax
je     1270 <next_word+0x150>
jmp    11ee <next_word+0xce>
mov    -0x34(%rbp),%eax
sub    $0x22,%eax
je     1260 <next_word+0x140>
jmp    11ff <next_word+0xdf>
mov    -0x34(%rbp),%eax
sub    $0x23,%eax
je     1270 <next_word+0x150>
jmp    1210 <next_word+0xf0>
mov    -0x34(%rbp),%eax
sub    $0x3b,%eax
je     1270 <next_word+0x150>
jmp    1221 <next_word+0x101>
mov    -0x34(%rbp),%eax
sub    $0x5c,%eax
je     1254 <next_word+0x134>
jmp    1232 <next_word+0x112>
mov    -0x34(%rbp),%eax
sub    $0x7b,%eax
je     1270 <next_word+0x150>
jmp    1243 <next_word+0x123>
mov    -0x34(%rbp),%eax
sub    $0x7d,%eax
je     1270 <next_word+0x150>
jmp    12b6 <next_word+0x196>
movl   $0x1,-0x2c(%rbp)
jmp    12cf <next_word+0x1af>
mov    $0x1,%eax
sub    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    12cf <next_word+0x1af>
cmpl   $0x0,-0x28(%rbp)
jne    12b1 <next_word+0x191>
mov    -0x10(%rbp),%rdi
mov    0x2d63(%rip),%rax
mov    (%rax),%edx
mov    $0xffffffff,%esi
call   1030 <fseek@plt>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12db <next_word+0x1bb>
jmp    12b6 <next_word+0x196>
mov    -0x20(%rbp),%eax
mov    %al,%dl
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1148 <next_word+0x28>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<next_word>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,%ebx
mov    %rsi,0x8(%rsp)
mov    %rdi,%rbp
call   1040 <getc@plt>
mov    0x2e9c(%rip),%rdx
mov    $0xffffffff,%ecx
cmp    (%rdx),%eax
je     1264 <next_word+0x144>
test   %ebx,%ebx
jle    1264 <next_word+0x144>
mov    %ebx,0x14(%rsp)
mov    %ebx,%r14d
xor    %r12d,%r12d
movl   $0x0,0x4(%rsp)
xor    %ebx,%ebx
movslq %ebx,%r15
mov    %r15,%r13
shl    $0x20,%r13
add    $0x1,%r15
nopl   0x0(%rax,%rax,1)
test   %r12d,%r12d
je     11d0 <next_word+0xb0>
mov    0x8(%rsp),%rcx
mov    %al,-0x1(%rcx,%r15,1)
mov    %rbp,%rdi
call   1040 <getc@plt>
mov    0x2e42(%rip),%rcx
cmp    (%rcx),%eax
je     125f <next_word+0x13f>
movabs $0x100000000,%rcx
add    %rcx,%r13
add    $0x1,%ebx
lea    0x1(%r15),%rcx
xor    %r12d,%r12d
cmp    %r14,%r15
mov    %rcx,%r15
jl     1180 <next_word+0x60>
jmp    125f <next_word+0x13f>
nopw   0x0(%rax,%rax,1)
cmp    $0x5b,%eax
jg     1230 <next_word+0x110>
cmp    $0x3b,%eax
ja     11f7 <next_word+0xd7>
mov    %eax,%ecx
movabs $0x800000900002600,%rdx
bt     %rcx,%rdx
jae    1247 <next_word+0x127>
cmpl   $0x0,0x4(%rsp)
je     1275 <next_word+0x155>
sar    $0x20,%r13
mov    0x8(%rsp),%rcx
mov    %al,(%rcx,%r13,1)
add    $0x1,%ebx
xor    %r12d,%r12d
mov    %rbp,%rdi
call   1040 <getc@plt>
mov    0x2dc7(%rip),%rcx
cmp    (%rcx),%eax
je     125f <next_word+0x13f>
cmp    0x14(%rsp),%ebx
jl     116d <next_word+0x4d>
jmp    125f <next_word+0x13f>
nopl   0x0(%rax)
cmp    $0x7d,%eax
je     11ec <next_word+0xcc>
cmp    $0x7b,%eax
je     11ec <next_word+0xcc>
cmp    $0x5c,%eax
jne    11f7 <next_word+0xd7>
mov    $0x1,%r12d
jmp    120a <next_word+0xea>
cmp    $0x22,%rcx
jne    11f7 <next_word+0xd7>
mov    $0x1,%eax
sub    0x4(%rsp),%eax
xor    %r12d,%r12d
mov    %eax,0x4(%rsp)
jmp    120a <next_word+0xea>
mov    $0xffffffff,%ecx
mov    %ecx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d6c(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
mov    $0xffffffff,%esi
call   1030 <fseek@plt>
sar    $0x20,%r13
mov    0x8(%rsp),%rax
movb   $0x0,(%rax,%r13,1)
add    $0x1,%ebx
mov    %ebx,%ecx
jmp    1264 <next_word+0x144>

LLVM IR (-O0):
@EOF = global i32 0
@SEEK_CUR = global i32 0
define i32 @next_word(i32* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32* %0, i32** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
br label %12
12: ; preds = %65, %26, %3
%13 = load i32*, i32** %5
%14 = call i32 @getc(i32* %13)
store i32 %14, i32* %8
%15 = load i32, i32* @EOF
%16 = icmp ne i32 %14, %15
br i1 %16, label %17, label %21
17: ; preds = %12
%18 = load i32, i32* %9
%19 = load i32, i32* %7
%20 = icmp slt i32 %18, %19
br label %21
21: ; preds = %17, %12
%22 = phi i1 [ false, %12 ], [ %20, %17 ]
br i1 %22, label %23, label %66
23: ; preds = %21
%24 = load i32, i32* %11
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %35
26: ; preds = %23
store i32 0, i32* %11
%27 = load i32, i32* %8
%28 = trunc i32 %27 to i8
%29 = load i8*, i8** %6
%30 = load i32, i32* %9
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
store i8 %28, i8* %32
%33 = load i32, i32* %9
%34 = add nsw i32 %33, 1
store i32 %34, i32* %9
br label %12
35: ; preds = %23
%36 = load i32, i32* %8
switch i32 %36, label %56 [
i32 92, label %37
i32 34, label %38
i32 32, label %41
i32 9, label %41
i32 59, label %41
i32 10, label %41
i32 13, label %41
i32 35, label %41
i32 123, label %41
i32 125, label %41
]
37: ; preds = %35
store i32 1, i32* %11
br label %65
38: ; preds = %35
%39 = load i32, i32* %10
%40 = sub nsw i32 1, %39
store i32 %40, i32* %10
br label %65
41: ; preds = %35, %35, %35, %35, %35, %35, %35, %35
%42 = load i32, i32* %10
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %55
44: ; preds = %41
%45 = load i32*, i32** %5
%46 = load i32, i32* @SEEK_CUR
%47 = call i32 @fseek(i32* %45, i32 -1, i32 %46)
%48 = load i8*, i8** %6
%49 = load i32, i32* %9
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
store i8 0, i8* %51
%52 = load i32, i32* %9
%53 = add nsw i32 %52, 1
store i32 %53, i32* %9
%54 = load i32, i32* %9
store i32 %54, i32* %4
br label %67
55: ; preds = %41
br label %56
56: ; preds = %35, %55
%57 = load i32, i32* %8
%58 = trunc i32 %57 to i8
%59 = load i8*, i8** %6
%60 = load i32, i32* %9
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %59, i64 %61
store i8 %58, i8* %62
%63 = load i32, i32* %9
%64 = add nsw i32 %63, 1
store i32 %64, i32* %9
br label %65
65: ; preds = %56, %38, %37
br label %12
66: ; preds = %21
store i32 -1, i32* %4
br label %67
67: ; preds = %66, %44
%68 = load i32, i32* %4
ret i32 %68
}

LLVM IR (-O2):
@EOF = global i32 0
@SEEK_CUR = global i32 0
define i32 @next_word(i32* nocapture %0, i8* nocapture writeonly %1, i32 %2) {
%4 = tail call i32 @getc(i32* %0)
%5 = load i32, i32* @EOF
%6 = icmp ne i32 %4, %5
%7 = icmp sgt i32 %2, 0
%8 = and i1 %6, %7
br i1 %8, label %9, label %60
9: ; preds = %3
%10 = zext i32 %2 to i64
br label %11
11: ; preds = %9, %51
%12 = phi i32 [ %55, %51 ], [ %4, %9 ]
%13 = phi i32 [ %54, %51 ], [ 0, %9 ]
%14 = phi i32 [ %53, %51 ], [ 0, %9 ]
%15 = phi i32 [ %52, %51 ], [ 0, %9 ]
%16 = sext i32 %15 to i64
br label %17
17: ; preds = %11, %22
%18 = phi i64 [ %16, %11 ], [ %25, %22 ]
%19 = phi i32 [ %12, %11 ], [ %26, %22 ]
%20 = phi i32 [ %13, %11 ], [ 0, %22 ]
%21 = icmp eq i32 %20, 0
br i1 %21, label %31, label %22
22: ; preds = %17
%23 = trunc i32 %19 to i8
%24 = getelementptr inbounds i8, i8* %1, i64 %18
store i8 %23, i8* %24
%25 = add nsw i64 %18, 1
%26 = tail call i32 @getc(i32* %0)
%27 = load i32, i32* @EOF
%28 = icmp ne i32 %26, %27
%29 = icmp slt i64 %25, %10
%30 = select i1 %28, i1 %29, i1 false
br i1 %30, label %17, label %60
31: ; preds = %17
%32 = trunc i64 %18 to i32
switch i32 %19, label %45 [
i32 92, label %51
i32 34, label %33
i32 32, label %35
i32 9, label %35
i32 59, label %35
i32 10, label %35
i32 13, label %35
i32 35, label %35
i32 123, label %35
i32 125, label %35
]
33: ; preds = %31
%34 = sub nsw i32 1, %14
br label %51
35: ; preds = %31, %31, %31, %31, %31, %31, %31, %31
%36 = icmp eq i32 %14, 0
br i1 %36, label %37, label %45
37: ; preds = %35
%38 = trunc i64 %18 to i32
%39 = load i32, i32* @SEEK_CUR
%40 = tail call i32 @fseek(i32* %0, i32 -1, i32 %39)
%41 = shl i64 %18, 32
%42 = ashr exact i64 %41, 32
%43 = getelementptr inbounds i8, i8* %1, i64 %42
store i8 0, i8* %43
%44 = add nsw i32 %38, 1
br label %60
45: ; preds = %35, %31
%46 = trunc i32 %19 to i8
%47 = shl i64 %18, 32
%48 = ashr exact i64 %47, 32
%49 = getelementptr inbounds i8, i8* %1, i64 %48
store i8 %46, i8* %49
%50 = add nsw i32 %32, 1
br label %51
51: ; preds = %31, %45, %33
%52 = phi i32 [ %50, %45 ], [ %32, %33 ], [ %32, %31 ]
%53 = phi i32 [ %14, %45 ], [ %34, %33 ], [ %14, %31 ]
%54 = phi i32 [ 0, %45 ], [ 0, %33 ], [ 1, %31 ]
%55 = tail call i32 @getc(i32* %0)
%56 = load i32, i32* @EOF
%57 = icmp ne i32 %55, %56
%58 = icmp slt i32 %52, %2
%59 = select i1 %57, i1 %58, i1 false
br i1 %59, label %11, label %60
60: ; preds = %51, %22, %3, %37
%61 = phi i32 [ %44, %37 ], [ -1, %3 ], [ -1, %22 ], [ -1, %51 ]
ret i32 %61
}