#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 fgetc_unlocked(int /*<<< orphan*/ *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ ungetc(int, int /*<<< orphan*/ *);
void ReadWord(char *word, FILE *fin, char *eof) {
  int a = 0, ch;
  while (1) {
    ch = fgetc_unlocked(fin);
    if (ch == EOF) {
      *eof = 1;
      break;
    }
    if (ch == '\r')
      continue;
    if ((ch == ' ') || (ch == '\t') || (ch == '\n')) {
      if (a > 0) {
        if (ch == '\n')
          ungetc(ch, fin);
        break;
      }
      if (ch == '\n') {
        strcpy(word, (char *)"
");
        return;
      } else
        continue;
    }
    word[a] = ch;
    a++;
    if (a >= 100 - 1)
      a--;
  }
  word[a] = 0;
}


x86 assembly (clang, -O0):
<ReadWord>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fgetc_unlocked@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    0x2e87(%rip),%rcx
cmp    (%rcx),%eax
jne    1175 <ReadWord+0x45>
mov    -0x18(%rbp),%rax
movb   $0x1,(%rax)
jmp    121c <ReadWord+0xec>
cmpl   $0xd,-0x20(%rbp)
jne    1184 <ReadWord+0x54>
jmp    114b <ReadWord+0x1b>
cmpl   $0x20,-0x20(%rbp)
je     11a2 <ReadWord+0x72>
cmpl   $0x9,-0x20(%rbp)
je     11a2 <ReadWord+0x72>
cmpl   $0xa,-0x20(%rbp)
jne    11eb <ReadWord+0xbb>
cmpl   $0x0,-0x1c(%rbp)
jle    11c7 <ReadWord+0x97>
cmpl   $0xa,-0x20(%rbp)
jne    11c2 <ReadWord+0x92>
mov    -0x20(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <ungetc@plt>
jmp    121c <ReadWord+0xec>
cmpl   $0xa,-0x20(%rbp)
jne    11e6 <ReadWord+0xb6>
mov    -0x8(%rbp),%rdi
lea    0xe24(%rip),%rsi
call   1040 <strcpy@plt>
jmp    1228 <ReadWord+0xf8>
jmp    114b <ReadWord+0x1b>
mov    -0x20(%rbp),%eax
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x63,-0x1c(%rbp)
jl     1217 <ReadWord+0xe7>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    114b <ReadWord+0x1b>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReadWord>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <fgetc_unlocked@plt>
mov    0x2e95(%rip),%r12
xor    %ebp,%ebp
cmp    (%r12),%eax
jne    1176 <ReadWord+0x46>
movb   $0x1,(%r15)
movslq %ebp,%rax
movb   $0x0,(%r14,%rax,1)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebp,%ebp
movabs $0x100000600,%r13
jmp    119e <ReadWord+0x6e>
mov    %ebp,%ecx
mov    %al,(%r14,%rcx,1)
cmp    $0x62,%ebp
adc    $0x0,%ebp
mov    %rbx,%rdi
call   1030 <fgetc_unlocked@plt>
cmp    (%r12),%eax
je     115b <ReadWord+0x2b>
cmp    $0xd,%eax
je     1190 <ReadWord+0x60>
cmp    $0x20,%eax
ja     1184 <ReadWord+0x54>
mov    %eax,%ecx
bt     %rcx,%r13
jae    1184 <ReadWord+0x54>
test   %ebp,%ebp
jne    11d6 <ReadWord+0xa6>
cmp    $0xa,%eax
jne    1190 <ReadWord+0x60>
lea    0xe40(%rip),%rsi
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <strcpy@plt>
cmp    $0xa,%eax
jne    115f <ReadWord+0x2f>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1050 <ungetc@plt>
jmp    115f <ReadWord+0x2f>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [5 x i8] c"
\00"
define void @ReadWord(i8* %0, i32* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
store i8* %2, i8** %6
store i32 0, i32* %7
br label %9
9: ; preds = %3, %20, %47, %62
%10 = load i32*, i32** %5
%11 = call i32 @fgetc_unlocked(i32* %10)
store i32 %11, i32* %8
%12 = load i32, i32* %8
%13 = load i32, i32* @EOF
%14 = icmp eq i32 %12, %13
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = load i8*, i8** %6
store i8 1, i8* %16
br label %63
17: ; preds = %9
%18 = load i32, i32* %8
%19 = icmp eq i32 %18, 13
br i1 %19, label %20, label %21
20: ; preds = %17
br label %9
21: ; preds = %17
%22 = load i32, i32* %8
%23 = icmp eq i32 %22, 32
br i1 %23, label %30, label %24
24: ; preds = %21
%25 = load i32, i32* %8
%26 = icmp eq i32 %25, 9
br i1 %26, label %30, label %27
27: ; preds = %24
%28 = load i32, i32* %8
%29 = icmp eq i32 %28, 10
br i1 %29, label %30, label %48
30: ; preds = %27, %24, %21
%31 = load i32, i32* %7
%32 = icmp sgt i32 %31, 0
br i1 %32, label %33, label %41
33: ; preds = %30
%34 = load i32, i32* %8
%35 = icmp eq i32 %34, 10
br i1 %35, label %36, label %40
36: ; preds = %33
%37 = load i32, i32* %8
%38 = load i32*, i32** %5
%39 = call i32 @ungetc(i32 %37, i32* %38)
br label %40
40: ; preds = %36, %33
br label %63
41: ; preds = %30
%42 = load i32, i32* %8
%43 = icmp eq i32 %42, 10
br i1 %43, label %44, label %47
44: ; preds = %41
%45 = load i8*, i8** %4
%46 = call i32 @strcpy(i8* %45, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %68
47: ; preds = %41
br label %9
48: ; preds = %27
%49 = load i32, i32* %8
%50 = trunc i32 %49 to i8
%51 = load i8*, i8** %4
%52 = load i32, i32* %7
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %51, i64 %53
store i8 %50, i8* %54
%55 = load i32, i32* %7
%56 = add nsw i32 %55, 1
store i32 %56, i32* %7
%57 = load i32, i32* %7
%58 = icmp sge i32 %57, 99
br i1 %58, label %59, label %62
59: ; preds = %48
%60 = load i32, i32* %7
%61 = add nsw i32 %60, -1
store i32 %61, i32* %7
br label %62
62: ; preds = %59, %48
br label %9
63: ; preds = %40, %15
%64 = load i8*, i8** %4
%65 = load i32, i32* %7
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i8, i8* %64, i64 %66
store i8 0, i8* %67
br label %68
68: ; preds = %63, %44
ret void
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [5 x i8] c"
\00"
define void @ReadWord(i8* %0, i32* nocapture %1, i8* nocapture writeonly %2) {
%4 = tail call i32 @fgetc_unlocked(i32* %1)
%5 = load i32, i32* @EOF
%6 = icmp eq i32 %4, %5
br i1 %6, label %11, label %7
7: ; preds = %3, %29
%8 = phi i32 [ %36, %29 ], [ %4, %3 ]
%9 = phi i32 [ %35, %29 ], [ 0, %3 ]
%10 = icmp eq i32 %9, 0
br label %13
11: ; preds = %29, %16, %3
%12 = phi i32 [ 0, %3 ], [ %9, %16 ], [ %35, %29 ]
store i8 1, i8* %2
br label %39
13: ; preds = %7, %16
%14 = phi i32 [ %8, %7 ], [ %17, %16 ]
%15 = icmp eq i32 %14, 13
br i1 %15, label %16, label %20
16: ; preds = %13, %26
%17 = tail call i32 @fgetc_unlocked(i32* %1)
%18 = load i32, i32* @EOF
%19 = icmp eq i32 %17, %18
br i1 %19, label %11, label %13
20: ; preds = %13
%21 = icmp eq i32 %14, 10
switch i32 %14, label %29 [
i32 32, label %22
i32 10, label %22
i32 9, label %22
]
22: ; preds = %20, %20, %20
br i1 %10, label %26, label %23
23: ; preds = %22
br i1 %21, label %24, label %39
24: ; preds = %23
%25 = tail call i32 @ungetc(i32 10, i32* %1)
br label %39
26: ; preds = %22
br i1 %21, label %27, label %16
27: ; preds = %26
%28 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %43
29: ; preds = %20
%30 = trunc i32 %14 to i8
%31 = zext i32 %9 to i64
%32 = getelementptr inbounds i8, i8* %0, i64 %31
store i8 %30, i8* %32
%33 = icmp ult i32 %9, 98
%34 = zext i1 %33 to i32
%35 = add nuw nsw i32 %9, %34
%36 = tail call i32 @fgetc_unlocked(i32* %1)
%37 = load i32, i32* @EOF
%38 = icmp eq i32 %36, %37
br i1 %38, label %11, label %7
39: ; preds = %23, %24, %11
%40 = phi i32 [ %9, %23 ], [ %9, %24 ], [ %12, %11 ]
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %0, i64 %41
store i8 0, i8* %42
br label %43
43: ; preds = %39, %27
ret void
}