#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 /*<<< orphan*/ islower(char);
bool validate_word(char *buffer) {
  if ((*buffer == '\n') || (*buffer == '\0'))
    return false;
  for (;;) {
    if (!*buffer)
      return true;
    if (*buffer == '\n') {
      *buffer = '\0';
      return true;
    }
    if (!islower(*buffer))
      return false;
    buffer++;
  }
}


x86 assembly (clang, -O0):
<validate_word>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
je     113c <validate_word+0x2c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1148 <validate_word+0x38>
movl   $0x0,-0x4(%rbp)
jmp    11bb <validate_word+0xab>
jmp    114d <validate_word+0x3d>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1166 <validate_word+0x56>
movl   $0x1,-0x4(%rbp)
jmp    11bb <validate_word+0xab>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    1189 <validate_word+0x79>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11bb <validate_word+0xab>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <islower@plt>
cmp    $0x0,%eax
jne    11aa <validate_word+0x9a>
movl   $0x0,-0x4(%rbp)
jmp    11bb <validate_word+0xab>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    114d <validate_word+0x3d>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<validate_word>:
push   %rbx
mov    (%rdi),%cl
test   %cl,%cl
je     111c <validate_word+0xc>
cmp    $0xa,%cl
jne    1120 <validate_word+0x10>
xor    %eax,%eax
pop    %rbx
ret
mov    %rdi,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbx
mov    $0x1,%eax
test   %cl,%cl
je     111e <validate_word+0xe>
cmp    $0xa,%cl
je     1153 <validate_word+0x43>
movsbl %cl,%edi
call   1030 <islower@plt>
test   %eax,%eax
je     111c <validate_word+0xc>
movzbl (%rbx),%ecx
jmp    1130 <validate_word+0x20>
movb   $0x0,-0x1(%rbx)
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @validate_word(i8* nocapture %0) {
%2 = load i8, i8* %0
switch i8 %2, label %3 [
i8 10, label %13
i8 0, label %13
]
3: ; preds = %1, %10
%4 = phi i8 [ %12, %10 ], [ %2, %1 ]
%5 = phi i8* [ %11, %10 ], [ %0, %1 ]
switch i8 %4, label %7 [
i8 0, label %13
i8 10, label %6
]
6: ; preds = %3
store i8 0, i8* %5
br label %13
7: ; preds = %3
%8 = tail call i32 @islower(i8 signext %4)
%9 = icmp eq i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = getelementptr inbounds i8, i8* %5, i64 1
%12 = load i8, i8* %11
br label %3
13: ; preds = %7, %3, %1, %1, %6
%14 = phi i32 [ 1, %6 ], [ 0, %1 ], [ 0, %1 ], [ 0, %7 ], [ 1, %3 ]
ret i32 %14
}