#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*/ printf(char *, char);
int countWordsInStr(char *pStr) {
  int ii = 0, count = 1;
  while (pStr[ii] != '\n') {
    if (((*pStr == ' ') && (*(pStr + 1) != ' ')) ||
        ((*pStr == '\t') && (*(pStr + 1) != '\t'))) {
      printf("char = %c\n", *pStr);
      count++;
    }
    pStr++;
  }
  return count;
}


x86 assembly (clang, -O0):
<countWordsInStr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
je     11ae <countWordsInStr+0x9e>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    1160 <countWordsInStr+0x50>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x20,%eax
jne    1181 <countWordsInStr+0x71>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
jne    119d <countWordsInStr+0x8d>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x9,%eax
je     119d <countWordsInStr+0x8d>
mov    -0x8(%rbp),%rax
lea    0xe74(%rip),%rdi
movsbl (%rax),%esi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    112a <countWordsInStr+0x1a>
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<countWordsInStr>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
add    $0x1,%rbx
mov    $0x1,%ebp
lea    0xed9(%rip),%r14
jmp    1138 <countWordsInStr+0x28>
nopl   0x0(%rax)
cmp    $0xa,%al
je     1165 <countWordsInStr+0x55>
add    $0x1,%rbx
movzbl -0x1(%rbx),%eax
cmp    $0x9,%al
je     1150 <countWordsInStr+0x40>
cmp    $0x20,%al
jne    1130 <countWordsInStr+0x20>
cmpb   $0x20,(%rbx)
je     1134 <countWordsInStr+0x24>
jmp    1155 <countWordsInStr+0x45>
nopl   0x0(%rax,%rax,1)
cmpb   $0x9,(%rbx)
je     1134 <countWordsInStr+0x24>
movsbl %al,%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%ebp
jmp    1134 <countWordsInStr+0x24>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"char = %c\0A\00"
define i32 @countWordsInStr(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
store i32 1, i32* %4
br label %5
5: ; preds = %41, %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, 10
br i1 %12, label %13, label %44
13: ; preds = %5
%14 = load i8*, i8** %2
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 32
br i1 %17, label %18, label %24
18: ; preds = %13
%19 = load i8*, i8** %2
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 32
br i1 %23, label %35, label %24
24: ; preds = %18, %13
%25 = load i8*, i8** %2
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 9
br i1 %28, label %29, label %41
29: ; preds = %24
%30 = load i8*, i8** %2
%31 = getelementptr inbounds i8, i8* %30, i64 1
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %33, 9
br i1 %34, label %35, label %41
35: ; preds = %29, %18
%36 = load i8*, i8** %2
%37 = load i8, i8* %36
%38 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8 signext %37)
%39 = load i32, i32* %4
%40 = add nsw i32 %39, 1
store i32 %40, i32* %4
br label %41
41: ; preds = %35, %29, %24
%42 = load i8*, i8** %2
%43 = getelementptr inbounds i8, i8* %42, i32 1
store i8* %43, i8** %2
br label %5
44: ; preds = %5
%45 = load i32, i32* %4
ret i32 %45
}

LLVM IR (-O2):
@.str = [11 x i8] c"char = %c\0A\00"
define i32 @countWordsInStr(i8* nocapture %0) {
br label %2
2: ; preds = %17, %1
%3 = phi i8* [ %0, %1 ], [ %19, %17 ]
%4 = phi i32 [ 1, %1 ], [ %18, %17 ]
%5 = load i8, i8* %3
switch i8 %5, label %17 [
i8 10, label %20
i8 32, label %6
i8 9, label %10
]
6: ; preds = %2
%7 = getelementptr inbounds i8, i8* %3, i64 1
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 32
br i1 %9, label %17, label %14
10: ; preds = %2
%11 = getelementptr inbounds i8, i8* %3, i64 1
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 9
br i1 %13, label %17, label %14
14: ; preds = %10, %6
%15 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8 signext %5)
%16 = add nsw i32 %4, 1
br label %17
17: ; preds = %2, %6, %14, %10
%18 = phi i32 [ %16, %14 ], [ %4, %10 ], [ %4, %6 ], [ %4, %2 ]
%19 = getelementptr inbounds i8, i8* %3, i64 1
br label %2
20: ; preds = %2
ret i32 %4
}