#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 */
scalar_t__ isspace(char);
scalar_t__ tolower(char);
void getword(char **buff, char *word) {
  register short i;
  for (i = 0; i < 20; ++i) {
    if (!**buff || isspace(**buff)) {
      *word = '\0';
      return;
    }
    *word++ = (char)tolower(**buff);
    (*buff)++;
  }
  *--word = '\0';
  return;
}


x86 assembly (clang, -O0):
<getword>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movw   $0x0,-0x12(%rbp)
movswl -0x12(%rbp),%eax
cmp    $0x14,%eax
jge    11b9 <getword+0x99>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
cmpb   $0x0,(%rax)
je     116c <getword+0x4c>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
je     1178 <getword+0x58>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
jmp    11cc <getword+0xac>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%edi
call   1040 <tolower@plt>
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
mov    -0x12(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x12(%rbp)
jmp    1136 <getword+0x16>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x0,-0x1(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getword>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    (%rdi),%rax
xor    %ecx,%ecx
mov    %rcx,%rbx
movzbl (%rax),%eax
test   %al,%al
je     116a <getword+0x4a>
movsbl %al,%edi
call   1030 <isspace@plt>
test   %rax,%rax
jne    116a <getword+0x4a>
mov    (%r15),%rax
movsbl (%rax),%edi
call   1040 <tolower@plt>
mov    %al,(%r14,%rbx,1)
mov    (%r15),%rax
add    $0x1,%rax
mov    %rax,(%r15)
lea    0x1(%rbx),%rcx
cmp    $0x14,%cx
jne    1130 <getword+0x10>
movb   $0x0,(%r14,%rbx,1)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @getword(i8** %0, i8* %1) {
%3 = alloca i8**
%4 = alloca i8*
%5 = alloca i16
store i8** %0, i8*** %3
store i8* %1, i8** %4
store i16 0, i16* %5
br label %6
6: ; preds = %34, %2
%7 = load i16, i16* %5
%8 = sext i16 %7 to i32
%9 = icmp slt i32 %8, 20
br i1 %9, label %10, label %37
10: ; preds = %6
%11 = load i8**, i8*** %3
%12 = load i8*, i8** %11
%13 = load i8, i8* %12
%14 = icmp ne i8 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %10
%16 = load i8**, i8*** %3
%17 = load i8*, i8** %16
%18 = load i8, i8* %17
%19 = call i64 @isspace(i8 signext %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %15, %10
%22 = load i8*, i8** %4
store i8 0, i8* %22
br label %40
23: ; preds = %15
%24 = load i8**, i8*** %3
%25 = load i8*, i8** %24
%26 = load i8, i8* %25
%27 = call i64 @tolower(i8 signext %26)
%28 = trunc i64 %27 to i8
%29 = load i8*, i8** %4
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %4
store i8 %28, i8* %29
%31 = load i8**, i8*** %3
%32 = load i8*, i8** %31
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %31
br label %34
34: ; preds = %23
%35 = load i16, i16* %5
%36 = add i16 %35, 1
store i16 %36, i16* %5
br label %6
37: ; preds = %6
%38 = load i8*, i8** %4
%39 = getelementptr inbounds i8, i8* %38, i32 -1
store i8* %39, i8** %4
store i8 0, i8* %39
br label %40
40: ; preds = %37, %21
ret void
}

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