#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 /*<<< orphan*/ bug(char *, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
char getc(int /*<<< orphan*/ *);
int isspace(char);
int /*<<< orphan*/ ungetc(char, int /*<<< orphan*/ *);
char *fread_word(FILE *fp) {
  static char word[1024];
  char *pword;
  char cEnd;
  do {
    cEnd = getc(fp);
  } while (isspace(cEnd));
  if (cEnd == '\'' || cEnd == '"') {
    pword = word;
  } else {
    word[0] = cEnd;
    pword = word + 1;
    cEnd = ' ';
  }
  for (; pword < word + 1024; pword++) {
    *pword = getc(fp);
    if (cEnd == ' ' ? isspace(*pword) : *pword == cEnd) {
      if (cEnd == ' ')
        ungetc(*pword, fp);
      *pword = '\0';
      return word;
    }
  }
  bug("Fread_word: word too long.", 0);
  exit(1);
  return NULL;
}


x86 assembly (clang, -O0):
<fread_word>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <getc@plt>
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%edi
call   1040 <isspace@plt>
cmp    $0x0,%eax
jne    115c <fread_word+0xc>
movsbl -0x11(%rbp),%eax
cmp    $0x27,%eax
je     1194 <fread_word+0x44>
movsbl -0x11(%rbp),%eax
cmp    $0x22,%eax
jne    11a4 <fread_word+0x54>
lea    0x2ec5(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11c0 <fread_word+0x70>
mov    -0x11(%rbp),%al
mov    %al,0x2eb3(%rip)
lea    0x2eac(%rip),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
movb   $0x20,-0x11(%rbp)
jmp    11c5 <fread_word+0x75>
lea    0x2e94(%rip),%rax
add    $0x400,%rax
cmp    %rax,-0x10(%rbp)
jae    1270 <fread_word+0x120>
mov    -0x8(%rbp),%rdi
call   1070 <getc@plt>
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
movsbl -0x11(%rbp),%eax
cmp    $0x20,%eax
jne    1214 <fread_word+0xc4>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%eax
jne    1227 <fread_word+0xd7>
jmp    125a <fread_word+0x10a>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
movsbl -0x11(%rbp),%ecx
cmp    %ecx,%eax
jne    125a <fread_word+0x10a>
movsbl -0x11(%rbp),%eax
cmp    $0x20,%eax
jne    1246 <fread_word+0xf6>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1050 <ungetc@plt>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
lea    0x2e0c(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret
jmp    125f <fread_word+0x10f>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11c5 <fread_word+0x75>
lea    0xd89(%rip),%rdi
xor    %esi,%esi
call   1030 <bug@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<fread_word>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1070 <getc@plt>
mov    %eax,%ebx
movsbl %al,%edi
call   1040 <isspace@plt>
test   %eax,%eax
jne    1160 <fread_word+0x10>
cmp    $0x27,%bl
je     1180 <fread_word+0x30>
cmp    $0x22,%bl
jne    118c <fread_word+0x3c>
movzbl %bl,%ebp
lea    0x2ed6(%rip),%rbx
jmp    119e <fread_word+0x4e>
mov    %bl,0x2ece(%rip)
mov    $0x20,%ebp
lea    0x2ec3(%rip),%rbx
lea    0x32bb(%rip),%r15
jmp    11c0 <fread_word+0x70>
nopw   0x0(%rax,%rax,1)
movsbl %al,%eax
cmp    %eax,%ebp
je     11e6 <fread_word+0x96>
add    $0x1,%rbx
cmp    %r15,%rbx
jae    11fb <fread_word+0xab>
mov    %r14,%rdi
call   1070 <getc@plt>
mov    %al,(%rbx)
cmp    $0x20,%ebp
jne    11b0 <fread_word+0x60>
movsbl %al,%edi
call   1040 <isspace@plt>
test   %eax,%eax
je     11b7 <fread_word+0x67>
movsbl (%rbx),%edi
mov    %r14,%rsi
call   1050 <ungetc@plt>
movb   $0x0,(%rbx)
lea    0x2e70(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdfe(%rip),%rdi
xor    %esi,%esi
call   1030 <bug@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@fread_word.word = internal global [1024 x i8] zeroinitializer
@.str = [27 x i8] c"Fread_word: word too long.\00"
define i8* @fread_word(i32* %0) {
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca i8
store i32* %0, i32** %2
br label %5
5: ; preds = %8, %1
%6 = load i32*, i32** %2
%7 = call signext i8 @getc(i32* %6)
store i8 %7, i8* %4
br label %8
8: ; preds = %5
%9 = load i8, i8* %4
%10 = call i32 @isspace(i8 signext %9)
%11 = icmp ne i32 %10, 0
br i1 %11, label %5, label %12
12: ; preds = %8
%13 = load i8, i8* %4
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 39
br i1 %15, label %20, label %16
16: ; preds = %12
%17 = load i8, i8* %4
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 34
br i1 %19, label %20, label %21
20: ; preds = %16, %12
store i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @fread_word.word, i64 0, i64 0), i8** %3
br label %23
21: ; preds = %16
%22 = load i8, i8* %4
store i8 %22, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @fread_word.word, i64 0, i64 0)
store i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @fread_word.word, i64 0, i64 1), i8** %3
store i8 32, i8* %4
br label %23
23: ; preds = %21, %20
br label %24
24: ; preds = %58, %23
%25 = load i8*, i8** %3
%26 = icmp ult i8* %25, getelementptr inbounds ([1024 x i8], [1024 x i8]* @fread_word.word, i64 1, i64 0)
br i1 %26, label %27, label %61
27: ; preds = %24
%28 = load i32*, i32** %2
%29 = call signext i8 @getc(i32* %28)
%30 = load i8*, i8** %3
store i8 %29, i8* %30
%31 = load i8, i8* %4
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 32
br i1 %33, label %34, label %39
34: ; preds = %27
%35 = load i8*, i8** %3
%36 = load i8, i8* %35
%37 = call i32 @isspace(i8 signext %36)
%38 = icmp ne i32 %37, 0
br i1 %38, label %46, label %57
39: ; preds = %27
%40 = load i8*, i8** %3
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = load i8, i8* %4
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %42, %44
br i1 %45, label %46, label %57
46: ; preds = %39, %34
%47 = load i8, i8* %4
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %48, 32
br i1 %49, label %50, label %55
50: ; preds = %46
%51 = load i8*, i8** %3
%52 = load i8, i8* %51
%53 = load i32*, i32** %2
%54 = call i32 @ungetc(i8 signext %52, i32* %53)
br label %55
55: ; preds = %50, %46
%56 = load i8*, i8** %3
store i8 0, i8* %56
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @fread_word.word, i64 0, i64 0)
57: ; preds = %39, %34
br label %58
58: ; preds = %57
%59 = load i8*, i8** %3
%60 = getelementptr inbounds i8, i8* %59, i32 1
store i8* %60, i8** %3
br label %24
61: ; preds = %24
%62 = call i32 @bug(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 0)
%63 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@fread_word.word = internal global [1024 x i8] zeroinitializer
@.str = [27 x i8] c"Fread_word: word too long.\00"
define i8* @fread_word(i32* nocapture %0) {
br label %2
2: ; preds = %2, %1
%3 = tail call signext i8 @getc(i32* %0)
%4 = tail call i32 @isspace(i8 signext %3)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %2
6: ; preds = %2
switch i8 %3, label %9 [
i8 39, label %7
i8 34, label %7
]
7: ; preds = %6, %6
%8 = zext i8 %3 to i32
br label %10
9: ; preds = %6
store i8 %3, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @fread_word.word, i64 0, i64 0)
br label %10
10: ; preds = %9, %7
%11 = phi i8* [ getelementptr inbounds ([1024 x i8], [1024 x i8]* @fread_word.word, i64 0, i64 0), %7 ], [ getelementptr inbounds ([1024 x i8], [1024 x i8]* @fread_word.word, i64 0, i64 1), %9 ]
%12 = phi i32 [ %8, %7 ], [ 32, %9 ]
%13 = icmp eq i32 %12, 32
br label %14
14: ; preds = %10, %27
%15 = phi i8* [ %11, %10 ], [ %28, %27 ]
%16 = tail call signext i8 @getc(i32* %0)
store i8 %16, i8* %15
br i1 %13, label %17, label %20
17: ; preds = %14
%18 = tail call i32 @isspace(i8 signext %16)
%19 = icmp eq i32 %18, 0
br i1 %19, label %27, label %23
20: ; preds = %14
%21 = sext i8 %16 to i32
%22 = icmp eq i32 %12, %21
br i1 %22, label %26, label %27
23: ; preds = %17
%24 = load i8, i8* %15
%25 = tail call i32 @ungetc(i8 signext %24, i32* %0)
br label %26
26: ; preds = %20, %23
store i8 0, i8* %15
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @fread_word.word, i64 0, i64 0)
27: ; preds = %17, %20
%28 = getelementptr inbounds i8, i8* %15, i64 1
%29 = icmp ult i8* %28, getelementptr inbounds ([1024 x i8], [1024 x i8]* @fread_word.word, i64 1, i64 0)
br i1 %29, label %14, label %30
30: ; preds = %27
%31 = tail call i32 @bug(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 0)
%32 = tail call i32 @exit(i32 1)
unreachable
}