#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*/ feof(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
void ReadWord(char *word, FILE *fin, int MAX_STRING) {
  int a = 0, ch;
  while (!feof(fin)) {
    ch = fgetc(fin);
    if (ch == 13)
      continue;
    if ((ch == ' ') || (ch == '\t') || (ch == '\n')) {
      if (a > 0)
        break;
      else
        continue;
    }
    word[a] = ch;
    a++;
    if (a >= MAX_STRING - 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    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1158 <ReadWord+0x38>
jmp    11dd <ReadWord+0xbd>
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xd,-0x1c(%rbp)
jne    1173 <ReadWord+0x53>
jmp    113a <ReadWord+0x1a>
cmpl   $0x20,-0x1c(%rbp)
je     1191 <ReadWord+0x71>
cmpl   $0x9,-0x1c(%rbp)
je     1191 <ReadWord+0x71>
cmpl   $0xa,-0x1c(%rbp)
jne    11a5 <ReadWord+0x85>
cmpl   $0x0,-0x18(%rbp)
jle    11a0 <ReadWord+0x80>
jmp    11dd <ReadWord+0xbd>
jmp    113a <ReadWord+0x1a>
mov    -0x1c(%rbp),%eax
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jl     11d8 <ReadWord+0xb8>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    113a <ReadWord+0x1a>
mov    -0x8(%rbp),%rax
movslq -0x18(%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   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%rbp
mov    %rdi,%r15
mov    %rsi,%rdi
call   1040 <feof@plt>
xor    %ebx,%ebx
test   %eax,%eax
je     1151 <ReadWord+0x31>
movslq %ebx,%rax
movb   $0x0,(%r15,%rax,1)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
add    $0xffffffff,%r14d
xor    %ebx,%ebx
jmp    1170 <ReadWord+0x50>
nopl   0x0(%rax)
test   %ebx,%ebx
jg     113e <ReadWord+0x1e>
mov    %rbp,%rdi
call   1040 <feof@plt>
test   %eax,%eax
jne    113e <ReadWord+0x1e>
mov    %rbp,%rdi
call   1030 <fgetc@plt>
lea    -0x9(%rax),%ecx
cmp    $0x2,%ecx
jb     1160 <ReadWord+0x40>
cmp    $0xd,%eax
je     1164 <ReadWord+0x44>
cmp    $0x20,%eax
je     1160 <ReadWord+0x40>
movslq %ebx,%rcx
mov    %al,(%r15,%rcx,1)
lea    0x1(%rbx),%eax
cmp    %r14d,%eax
cmovl  %eax,%ebx
jmp    1164 <ReadWord+0x44>

LLVM IR (-O0):
define void @ReadWord(i8* %0, i32* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %9
9: ; preds = %50, %33, %19, %3
%10 = load i32*, i32** %5
%11 = call i32 @feof(i32* %10)
%12 = icmp ne i32 %11, 0
%13 = xor i1 %12, true
br i1 %13, label %14, label %51
14: ; preds = %9
%15 = load i32*, i32** %5
%16 = call i32 @fgetc(i32* %15)
store i32 %16, i32* %8
%17 = load i32, i32* %8
%18 = icmp eq i32 %17, 13
br i1 %18, label %19, label %20
19: ; preds = %14
br label %9
20: ; preds = %14
%21 = load i32, i32* %8
%22 = icmp eq i32 %21, 32
br i1 %22, label %29, label %23
23: ; preds = %20
%24 = load i32, i32* %8
%25 = icmp eq i32 %24, 9
br i1 %25, label %29, label %26
26: ; preds = %23
%27 = load i32, i32* %8
%28 = icmp eq i32 %27, 10
br i1 %28, label %29, label %34
29: ; preds = %26, %23, %20
%30 = load i32, i32* %7
%31 = icmp sgt i32 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %29
br label %51
33: ; preds = %29
br label %9
34: ; preds = %26
%35 = load i32, i32* %8
%36 = trunc i32 %35 to i8
%37 = load i8*, i8** %4
%38 = load i32, i32* %7
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %37, i64 %39
store i8 %36, i8* %40
%41 = load i32, i32* %7
%42 = add nsw i32 %41, 1
store i32 %42, i32* %7
%43 = load i32, i32* %7
%44 = load i32, i32* %6
%45 = sub nsw i32 %44, 1
%46 = icmp sge i32 %43, %45
br i1 %46, label %47, label %50
47: ; preds = %34
%48 = load i32, i32* %7
%49 = add nsw i32 %48, -1
store i32 %49, i32* %7
br label %50
50: ; preds = %47, %34
br label %9
51: ; preds = %32, %9
%52 = load i8*, i8** %4
%53 = load i32, i32* %7
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8, i8* %52, i64 %54
store i8 0, i8* %55
ret void
}

LLVM IR (-O2):
define void @ReadWord(i8* nocapture writeonly %0, i32* nocapture %1, i32 %2) {
%4 = tail call i32 @feof(i32* %1)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %26
6: ; preds = %3
%7 = add nsw i32 %2, -1
br label %8
8: ; preds = %6, %17
%9 = phi i32 [ 0, %6 ], [ %23, %17 ]
%10 = icmp sgt i32 %9, 0
br label %11
11: ; preds = %8, %14
%12 = tail call i32 @fgetc(i32* %1)
switch i32 %12, label %17 [
i32 13, label %14
i32 32, label %13
i32 10, label %13
i32 9, label %13
]
13: ; preds = %11, %11, %11
br i1 %10, label %26, label %14
14: ; preds = %13, %11
%15 = tail call i32 @feof(i32* %1)
%16 = icmp eq i32 %15, 0
br i1 %16, label %11, label %26
17: ; preds = %11
%18 = trunc i32 %12 to i8
%19 = sext i32 %9 to i64
%20 = getelementptr inbounds i8, i8* %0, i64 %19
store i8 %18, i8* %20
%21 = add nsw i32 %9, 1
%22 = icmp slt i32 %21, %7
%23 = select i1 %22, i32 %21, i32 %9
%24 = tail call i32 @feof(i32* %1)
%25 = icmp eq i32 %24, 0
br i1 %25, label %8, label %26
26: ; preds = %17, %14, %13, %3
%27 = phi i32 [ 0, %3 ], [ %9, %13 ], [ %9, %14 ], [ %23, %17 ]
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %0, i64 %28
store i8 0, i8* %29
ret void
}