#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 */

/* Variables and functions */
char fgetc(int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int read_word(int max_len, char *target) {
  char new_char;
  int i;
  while ((new_char = fgetc(stdin) != ' ') && (new_char != '\n') &&
         (new_char != '\0') && (new_char == '\t'))
    ;
  for (i = 0; i < max_len - 1; i++) {
    new_char = (char)fgetc(stdin);
    ;
    target[i] = new_char;
    if ((new_char == ' ') || (new_char == '\n') || (new_char == '\0') ||
        (new_char == '\t')) {
      break;
    }
  }
  new_char = '\0';
  target[i] = new_char;
  ;
  return i;
}


x86 assembly (clang, -O0):
<read_word>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2ec2(%rip),%rax
mov    (%rax),%edi
call   1030 <fgetc@plt>
movsbl %al,%eax
cmp    $0x20,%eax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %al,-0x11(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
je     1180 <read_word+0x70>
movsbl -0x11(%rbp),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x19(%rbp)
je     1180 <read_word+0x70>
movsbl -0x11(%rbp),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
je     1180 <read_word+0x70>
movsbl -0x11(%rbp),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1190 <read_word+0x80>
jmp    1195 <read_word+0x85>
jmp    111f <read_word+0xf>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1218 <read_word+0x108>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
call   1030 <fgetc@plt>
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%dl
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
movsbl -0x11(%rbp),%eax
cmp    $0x20,%eax
je     1200 <read_word+0xf0>
movsbl -0x11(%rbp),%eax
cmp    $0xa,%eax
je     1200 <read_word+0xf0>
movsbl -0x11(%rbp),%eax
cmp    $0x0,%eax
je     1200 <read_word+0xf0>
movsbl -0x11(%rbp),%eax
cmp    $0x9,%eax
jne    1205 <read_word+0xf5>
jmp    1218 <read_word+0x108>
jmp    120a <read_word+0xfa>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    119c <read_word+0x8c>
movb   $0x0,-0x11(%rbp)
mov    -0x11(%rbp),%dl
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_word>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%r14d
mov    0x2ec0(%rip),%r15
mov    (%r15),%edi
call   1030 <fgetc@plt>
xor    %ebp,%ebp
cmp    $0x2,%r14d
jl     1176 <read_word+0x66>
add    $0xffffffff,%r14d
mov    %r14d,%r12d
xor    %ebp,%ebp
movabs $0x100000601,%r13
jmp    1159 <read_word+0x49>
nopl   (%rax)
add    $0x1,%rbp
cmp    %rbp,%r12
je     1173 <read_word+0x63>
mov    (%r15),%edi
call   1030 <fgetc@plt>
mov    %al,(%rbx,%rbp,1)
cmp    $0x20,%al
ja     1150 <read_word+0x40>
movzbl %al,%eax
bt     %rax,%r13
jae    1150 <read_word+0x40>
jmp    1176 <read_word+0x66>
mov    %r14d,%ebp
mov    %ebp,%eax
movb   $0x0,(%rbx,%rax,1)
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
define i32 @read_word(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
br label %7
7: ; preds = %30, %2
%8 = load i32, i32* @stdin
%9 = call signext i8 @fgetc(i32 %8)
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 32
%12 = zext i1 %11 to i32
%13 = trunc i32 %12 to i8
store i8 %13, i8* %5
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %28
16: ; preds = %7
%17 = load i8, i8* %5
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 10
br i1 %19, label %20, label %28
20: ; preds = %16
%21 = load i8, i8* %5
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %20
%25 = load i8, i8* %5
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 9
br label %28
28: ; preds = %24, %20, %16, %7
%29 = phi i1 [ false, %20 ], [ false, %16 ], [ false, %7 ], [ %27, %24 ]
br i1 %29, label %30, label %31
30: ; preds = %28
br label %7
31: ; preds = %28
store i32 0, i32* %6
br label %32
32: ; preds = %62, %31
%33 = load i32, i32* %6
%34 = load i32, i32* %3
%35 = sub nsw i32 %34, 1
%36 = icmp slt i32 %33, %35
br i1 %36, label %37, label %65
37: ; preds = %32
%38 = load i32, i32* @stdin
%39 = call signext i8 @fgetc(i32 %38)
store i8 %39, i8* %5
%40 = load i8, i8* %5
%41 = load i8*, i8** %4
%42 = load i32, i32* %6
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
store i8 %40, i8* %44
%45 = load i8, i8* %5
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 32
br i1 %47, label %60, label %48
48: ; preds = %37
%49 = load i8, i8* %5
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 10
br i1 %51, label %60, label %52
52: ; preds = %48
%53 = load i8, i8* %5
%54 = sext i8 %53 to i32
%55 = icmp eq i32 %54, 0
br i1 %55, label %60, label %56
56: ; preds = %52
%57 = load i8, i8* %5
%58 = sext i8 %57 to i32
%59 = icmp eq i32 %58, 9
br i1 %59, label %60, label %61
60: ; preds = %56, %52, %48, %37
br label %65
61: ; preds = %56
br label %62
62: ; preds = %61
%63 = load i32, i32* %6
%64 = add nsw i32 %63, 1
store i32 %64, i32* %6
br label %32
65: ; preds = %60, %32
store i8 0, i8* %5
%66 = load i8, i8* %5
%67 = load i8*, i8** %4
%68 = load i32, i32* %6
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i8, i8* %67, i64 %69
store i8 %66, i8* %70
%71 = load i32, i32* %6
ret i32 %71
}

LLVM IR (-O2):
@stdin = global i32 0
define i32 @read_word(i32 %0, i8* nocapture writeonly %1) {
%3 = load i32, i32* @stdin
%4 = tail call signext i8 @fgetc(i32 %3)
%5 = add i32 %0, -1
%6 = icmp sgt i32 %0, 1
br i1 %6, label %7, label %19
7: ; preds = %2
%8 = zext i32 %5 to i64
br label %9
9: ; preds = %7, %14
%10 = phi i64 [ 0, %7 ], [ %15, %14 ]
%11 = load i32, i32* @stdin
%12 = tail call signext i8 @fgetc(i32 %11)
%13 = getelementptr inbounds i8, i8* %1, i64 %10
store i8 %12, i8* %13
switch i8 %12, label %14 [
i8 32, label %17
i8 10, label %17
i8 9, label %17
i8 0, label %17
]
14: ; preds = %9
%15 = add nuw nsw i64 %10, 1
%16 = icmp eq i64 %15, %8
br i1 %16, label %19, label %9
17: ; preds = %9, %9, %9, %9
%18 = trunc i64 %10 to i32
br label %19
19: ; preds = %14, %17, %2
%20 = phi i32 [ 0, %2 ], [ %18, %17 ], [ %5, %14 ]
%21 = zext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %1, i64 %21
store i8 0, i8* %22
ret i32 %20
}