#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__ isalpha(char const);
int /*<<< orphan*/ printf(char *, char const *, size_t);
void text_word_length_cb(const char *_text) {
  const char *text = _text;
  size_t str_words_len = 0;
  while (*text != '\0') {
    if (isalpha(*text))
      ++str_words_len;
    ++text;
  }
  printf("\"%s\" length of words: %zu\n", _text, str_words_len);
}


x86 assembly (clang, -O0):
<text_word_length_cb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     117f <text_word_length_cb+0x5f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isalpha@plt>
cmp    $0x0,%rax
je     116e <text_word_length_cb+0x4e>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    113c <text_word_length_cb+0x1c>
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<text_word_length_cb>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    (%rdi),%al
test   %al,%al
je     115d <text_word_length_cb+0x3d>
lea    0x1(%r14),%rbx
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nop
movsbl %al,%edi
call   1040 <isalpha@plt>
cmp    $0x1,%rax
sbb    $0xffffffffffffffff,%r15
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1140 <text_word_length_cb+0x20>
jmp    1160 <text_word_length_cb+0x40>
xor    %r15d,%r15d
lea    0xe99(%rip),%rdi
mov    %r14,%rsi
mov    %r15,%rdx
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [27 x i8] c"\22%s\22 length of words: %zu\0A\00"
define void @text_word_length_cb(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i64
store i8* %0, i8** %2
%5 = load i8*, i8** %2
store i8* %5, i8** %3
store i64 0, i64* %4
br label %6
6: ; preds = %19, %1
%7 = load i8*, i8** %3
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %22
11: ; preds = %6
%12 = load i8*, i8** %3
%13 = load i8, i8* %12
%14 = call i64 @isalpha(i8 signext %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = load i64, i64* %4
%18 = add i64 %17, 1
store i64 %18, i64* %4
br label %19
19: ; preds = %16, %11
%20 = load i8*, i8** %3
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %3
br label %6
22: ; preds = %6
%23 = load i8*, i8** %2
%24 = load i64, i64* %4
%25 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %23, i64 %24)
ret void
}

LLVM IR (-O2):
@.str = [27 x i8] c"\22%s\22 length of words: %zu\0A\00"
define void @text_word_length_cb(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %15, label %4
4: ; preds = %1, %4
%5 = phi i8 [ %13, %4 ], [ %2, %1 ]
%6 = phi i64 [ %11, %4 ], [ 0, %1 ]
%7 = phi i8* [ %12, %4 ], [ %0, %1 ]
%8 = tail call i64 @isalpha(i8 signext %5)
%9 = icmp ne i64 %8, 0
%10 = zext i1 %9 to i64
%11 = add i64 %6, %10
%12 = getelementptr inbounds i8, i8* %7, i64 1
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %15, label %4
15: ; preds = %4, %1
%16 = phi i64 [ 0, %1 ], [ %11, %4 ]
%17 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %0, i64 %16)
ret void
}