#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*/ *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ ungetc(int, int /*<<< orphan*/ *);
void ReadWord(char *word, FILE *fin) {
  int a = 0, ch;
  while (!feof(fin)) {
    ch = fgetc(fin);
    if (ch == 13)
      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;
  printf("%s\n", word);
}


x86 assembly (clang, -O0):
<ReadWord>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1185 <ReadWord+0x35>
jmp    1238 <ReadWord+0xe8>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xd,-0x18(%rbp)
jne    11a0 <ReadWord+0x50>
jmp    1167 <ReadWord+0x17>
cmpl   $0x20,-0x18(%rbp)
je     11be <ReadWord+0x6e>
cmpl   $0x9,-0x18(%rbp)
je     11be <ReadWord+0x6e>
cmpl   $0xa,-0x18(%rbp)
jne    1207 <ReadWord+0xb7>
cmpl   $0x0,-0x14(%rbp)
jle    11e3 <ReadWord+0x93>
cmpl   $0xa,-0x18(%rbp)
jne    11de <ReadWord+0x8e>
mov    -0x18(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1070 <ungetc@plt>
jmp    1238 <ReadWord+0xe8>
cmpl   $0xa,-0x18(%rbp)
jne    1202 <ReadWord+0xb2>
mov    -0x8(%rbp),%rdi
lea    0xe08(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1254 <ReadWord+0x104>
jmp    1167 <ReadWord+0x17>
mov    -0x18(%rbp),%eax
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x63,-0x14(%rbp)
jl     1233 <ReadWord+0xe3>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1167 <ReadWord+0x17>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rsi
lea    0xdb6(%rip),%rdi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReadWord>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1060 <feof@plt>
xor    %ebp,%ebp
test   %eax,%eax
je     118c <ReadWord+0x3c>
movslq %ebp,%rax
movb   $0x0,(%r14,%rax,1)
lea    0xe8b(%rip),%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>
xor    %ebp,%ebp
movabs $0x100000600,%r15
jmp    11bc <ReadWord+0x6c>
mov    %ebp,%ecx
mov    %al,(%r14,%rcx,1)
cmp    $0x62,%ebp
adc    $0x0,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    116b <ReadWord+0x1b>
mov    %rbx,%rdi
call   1050 <fgetc@plt>
cmp    $0xd,%eax
je     11b0 <ReadWord+0x60>
cmp    $0x20,%eax
ja     119a <ReadWord+0x4a>
mov    %eax,%ecx
bt     %rcx,%r15
jae    119a <ReadWord+0x4a>
test   %ebp,%ebp
jne    11f8 <ReadWord+0xa8>
cmp    $0xa,%eax
jne    11b0 <ReadWord+0x60>
lea    0xe1a(%rip),%rsi
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <strcpy@plt>
cmp    $0xa,%eax
jne    116b <ReadWord+0x1b>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1070 <ungetc@plt>
jmp    116b <ReadWord+0x1b>

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

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