#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 */
int getchar();
int isletter(int);
int getword(char *buf) {
  char *s;
  int c;
  while ((c = getchar()) != -1 && isletter(c) == 0)
    ;
  for (s = buf; (c = isletter(c)) != 0; c = getchar())
    *s++ = c;
  *s = 0;
  if (s > buf)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<getword>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,%ecx
mov    %ecx,-0x1c(%rbp)
xor    %eax,%eax
cmp    $0xffffffff,%ecx
mov    %al,-0x1d(%rbp)
je     1157 <getword+0x37>
mov    -0x1c(%rbp),%edi
call   1030 <isletter@plt>
cmp    $0x0,%eax
sete   %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    1167 <getword+0x47>
jmp    116c <getword+0x4c>
jmp    112c <getword+0xc>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%edi
call   1030 <isletter@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
je     11ad <getword+0x8d>
mov    -0x1c(%rbp),%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x1c(%rbp)
jmp    1174 <getword+0x54>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jbe    11ce <getword+0xae>
movl   $0x1,-0x4(%rbp)
jmp    11d5 <getword+0xb5>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getword>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
je     1149 <getword+0x29>
mov    %ebp,%edi
call   1030 <isletter@plt>
test   %eax,%eax
je     1130 <getword+0x10>
mov    %ebp,%edi
call   1030 <isletter@plt>
mov    %r14,%rbx
test   %eax,%eax
je     1178 <getword+0x58>
mov    %r14,%rbx
nopw   0x0(%rax,%rax,1)
mov    %al,(%rbx)
add    $0x1,%rbx
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,%edi
call   1030 <isletter@plt>
test   %eax,%eax
jne    1160 <getword+0x40>
movb   $0x0,(%rbx)
xor    %eax,%eax
cmp    %r14,%rbx
seta   %al
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @getword(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
br label %6
6: ; preds = %15, %1
%7 = call i32 (...) @getchar()
store i32 %7, i32* %5
%8 = icmp ne i32 %7, -1
br i1 %8, label %9, label %13
9: ; preds = %6
%10 = load i32, i32* %5
%11 = call i32 @isletter(i32 %10)
%12 = icmp eq i32 %11, 0
br label %13
13: ; preds = %9, %6
%14 = phi i1 [ false, %6 ], [ %12, %9 ]
br i1 %14, label %15, label %16
15: ; preds = %13
br label %6
16: ; preds = %13
%17 = load i8*, i8** %3
store i8* %17, i8** %4
br label %18
18: ; preds = %27, %16
%19 = load i32, i32* %5
%20 = call i32 @isletter(i32 %19)
store i32 %20, i32* %5
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %29
22: ; preds = %18
%23 = load i32, i32* %5
%24 = trunc i32 %23 to i8
%25 = load i8*, i8** %4
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %4
store i8 %24, i8* %25
br label %27
27: ; preds = %22
%28 = call i32 (...) @getchar()
store i32 %28, i32* %5
br label %18
29: ; preds = %18
%30 = load i8*, i8** %4
store i8 0, i8* %30
%31 = load i8*, i8** %4
%32 = load i8*, i8** %3
%33 = icmp ugt i8* %31, %32
br i1 %33, label %34, label %35
34: ; preds = %29
store i32 1, i32* %2
br label %36
35: ; preds = %29
store i32 0, i32* %2
br label %36
36: ; preds = %35, %34
%37 = load i32, i32* %2
ret i32 %37
}

LLVM IR (-O2):
define i32 @getword(i8* writeonly %0) {
br label %2
2: ; preds = %5, %1
%3 = tail call i32 (...) @getchar()
%4 = icmp eq i32 %3, -1
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = tail call i32 @isletter(i32 %3)
%7 = icmp eq i32 %6, 0
br i1 %7, label %2, label %8
8: ; preds = %2, %5
%9 = tail call i32 @isletter(i32 %3)
%10 = icmp eq i32 %9, 0
br i1 %10, label %19, label %11
11: ; preds = %8, %11
%12 = phi i32 [ %17, %11 ], [ %9, %8 ]
%13 = phi i8* [ %15, %11 ], [ %0, %8 ]
%14 = trunc i32 %12 to i8
%15 = getelementptr inbounds i8, i8* %13, i64 1
store i8 %14, i8* %13
%16 = tail call i32 (...) @getchar()
%17 = tail call i32 @isletter(i32 %16)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %11
19: ; preds = %11, %8
%20 = phi i8* [ %0, %8 ], [ %15, %11 ]
store i8 0, i8* %20
%21 = icmp ugt i8* %20, %0
%22 = zext i1 %21 to i32
ret i32 %22
}