#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 /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int strlen(char *);
void getWord(FILE *fp, char *word) {
  do {
    fgets(word, 1024, fp);
  } while (strlen(word) > 8 + 1 && !feof(fp));
  for (int i = 0; word[i] != '\0'; i++) {
    if (word[i] == '\n') {
      word[i] = '\0';
    }
  }
}


x86 assembly (clang, -O0):
<getWord>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x400,%esi
call   1040 <fgets@plt>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x9,%ecx
mov    %al,-0x15(%rbp)
jle    117f <getWord+0x4f>
mov    -0x8(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    1140 <getWord+0x10>
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11da <getWord+0xaa>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    11c7 <getWord+0x97>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    11cc <getWord+0x9c>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1191 <getWord+0x61>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getWord>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r14,%rdx
call   1040 <fgets@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0xa,%eax
jl     1177 <getWord+0x47>
mov    %r14,%rdi
call   1050 <feof@plt>
test   %eax,%eax
je     1140 <getWord+0x10>
jmp    1177 <getWord+0x47>
nopl   0x0(%rax,%rax,1)
movb   $0x0,(%rbx)
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0xa,%al
je     1170 <getWord+0x40>
test   %al,%al
jne    1173 <getWord+0x43>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @getWord(i32* nocapture %0, i8* %1) {
br label %3
3: ; preds = %7, %2
%4 = tail call i32 @fgets(i8* %1, i32 1024, i32* %0)
%5 = tail call i32 @strlen(i8* %1)
%6 = icmp sgt i32 %5, 9
br i1 %6, label %7, label %10
7: ; preds = %3
%8 = tail call i32 @feof(i32* %0)
%9 = icmp eq i32 %8, 0
br i1 %9, label %3, label %10
10: ; preds = %3, %7
br label %11
11: ; preds = %10, %17
%12 = phi i64 [ %18, %17 ], [ 0, %10 ]
%13 = getelementptr inbounds i8, i8* %1, i64 %12
%14 = load i8, i8* %13
switch i8 %14, label %17 [
i8 0, label %15
i8 10, label %16
]
15: ; preds = %11
ret void
16: ; preds = %11
store i8 0, i8* %13
br label %17
17: ; preds = %11, %16
%18 = add nuw i64 %12, 1
br label %11
}