#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 IsNullOrEmpty(char *);
char *strchr(char *, char);
int CountToken(char *pchLine) {
  int inFlag = IsNullOrEmpty(pchLine);
  if (inFlag != 0)
    return (0);
  int inCntToken = 0;
  char *pchSt = pchLine;
  char *pchEd = strchr(pchSt, ' ');
  while (1) {
    inCntToken++;
    if (pchEd == NULL)
      break;
    pchSt = pchEd + 1;
    pchEd = strchr(pchSt, ' ');
  }
  return (inCntToken);
}


x86 assembly (clang, -O0):
<CountToken>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <IsNullOrEmpty@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     114e <CountToken+0x2e>
movl   $0x0,-0x4(%rbp)
jmp    11b1 <CountToken+0x91>
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x20,%esi
call   1040 <strchr@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1188 <CountToken+0x68>
jmp    11ab <CountToken+0x8b>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x20,%esi
call   1040 <strchr@plt>
mov    %rax,-0x28(%rbp)
jmp    116f <CountToken+0x4f>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CountToken>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <IsNullOrEmpty@plt>
xor    %ebx,%ebx
test   %eax,%eax
je     113c <CountToken+0x1c>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %r14,%rdi
mov    $0x20,%esi
call   1040 <strchr@plt>
mov    $0x1,%ebx
test   %rax,%rax
je     1132 <CountToken+0x12>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rax
mov    %rax,%rdi
mov    $0x20,%esi
call   1040 <strchr@plt>
add    $0x1,%ebx
test   %rax,%rax
jne    1160 <CountToken+0x40>
jmp    1132 <CountToken+0x12>

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

LLVM IR (-O2):
define i32 @CountToken(i8* %0) {
%2 = tail call i32 @IsNullOrEmpty(i8* %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %14
4: ; preds = %1
%5 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 32)
%6 = icmp eq i8* %5, null
br i1 %6, label %14, label %7
7: ; preds = %4, %7
%8 = phi i32 [ %12, %7 ], [ 1, %4 ]
%9 = phi i8* [ %11, %7 ], [ %5, %4 ]
%10 = getelementptr inbounds i8, i8* %9, i64 1
%11 = tail call i8* @strchr(i8* %10, i8 signext 32)
%12 = add nuw nsw i32 %8, 1
%13 = icmp eq i8* %11, null
br i1 %13, label %14, label %7
14: ; preds = %7, %4, %1
%15 = phi i32 [ 0, %1 ], [ 1, %4 ], [ %12, %7 ]
ret i32 %15
}