#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 my_char_is_print(char);
int my_strword(char *str) {
  int i;
  int w;
  i = 0;
  w = 0;
  while (str[i] != '\0') {
    if (my_char_is_print(str[i]) == 1) {
      w++;
      while (my_char_is_print(str[i]) == 1)
        i++;
    } else
      i++;
  }
  return (w);
}


x86 assembly (clang, -O0):
<my_strword>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     119d <my_strword+0x8d>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <my_char_is_print@plt>
cmp    $0x1,%eax
jne    118f <my_strword+0x7f>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <my_char_is_print@plt>
cmp    $0x1,%eax
jne    118a <my_strword+0x7a>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1162 <my_strword+0x52>
jmp    1198 <my_strword+0x88>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    112a <my_strword+0x1a>
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_strword>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%al
test   %al,%al
je     117a <my_strword+0x6a>
mov    %rdi,%r15
xor    %r14d,%r14d
xor    %ebp,%ebp
jmp    113e <my_strword+0x2e>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebp
movslq %ebp,%rax
mov    (%r15,%rax,1),%al
test   %al,%al
je     117d <my_strword+0x6d>
movsbl %al,%edi
call   1030 <my_char_is_print@plt>
cmp    $0x1,%eax
jne    1130 <my_strword+0x20>
movslq %ebp,%rbx
add    $0xffffffff,%ebp
add    %r15,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl (%rbx),%edi
call   1030 <my_char_is_print@plt>
add    $0x1,%ebp
add    $0x1,%rbx
cmp    $0x1,%eax
je     1160 <my_strword+0x50>
add    $0x1,%r14d
jmp    1133 <my_strword+0x23>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @my_strword(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %31, label %4
4: ; preds = %1, %24
%5 = phi i8 [ %29, %24 ], [ %2, %1 ]
%6 = phi i32 [ %26, %24 ], [ 0, %1 ]
%7 = phi i32 [ %25, %24 ], [ 0, %1 ]
%8 = tail call i32 @my_char_is_print(i8 signext %5)
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %19
10: ; preds = %4
%11 = sext i32 %7 to i64
br label %12
12: ; preds = %12, %10
%13 = phi i64 [ %18, %12 ], [ %11, %10 ]
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = load i8, i8* %14
%16 = tail call i32 @my_char_is_print(i8 signext %15)
%17 = icmp eq i32 %16, 1
%18 = add i64 %13, 1
br i1 %17, label %12, label %21
19: ; preds = %4
%20 = add nsw i32 %7, 1
br label %24
21: ; preds = %12
%22 = add nsw i32 %6, 1
%23 = trunc i64 %13 to i32
br label %24
24: ; preds = %21, %19
%25 = phi i32 [ %20, %19 ], [ %23, %21 ]
%26 = phi i32 [ %6, %19 ], [ %22, %21 ]
%27 = sext i32 %25 to i64
%28 = getelementptr inbounds i8, i8* %0, i64 %27
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 0
br i1 %30, label %31, label %4
31: ; preds = %24, %1
%32 = phi i32 [ 0, %1 ], [ %26, %24 ]
ret i32 %32
}