#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 isspace(char const);
char *nextArg(char const *);
int getArgCount(const char *argsBuffer) {
  int result = 0;
  argsBuffer = nextArg(argsBuffer);
  while (*argsBuffer != 0) {
    while (!(isspace(*argsBuffer) | *argsBuffer == 0)) {
      ++argsBuffer;
    }
    argsBuffer = nextArg(argsBuffer);
    ++result;
  }
  return result;
}


x86 assembly (clang, -O0):
<getArgCount>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <nextArg@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11b7 <getArgCount+0x97>
jmp    1155 <getArgCount+0x35>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isspace@plt>
mov    -0x8(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    $0x0,%ecx
sete   %cl
and    $0x1,%cl
movzbl %cl,%ecx
or     %ecx,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    118b <getArgCount+0x6b>
jmp    119c <getArgCount+0x7c>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1155 <getArgCount+0x35>
mov    -0x8(%rbp),%rdi
call   1040 <nextArg@plt>
mov    %rax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1140 <getArgCount+0x20>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getArgCount>:
push   %rbp
push   %r14
push   %rbx
call   1040 <nextArg@plt>
mov    %rax,%rbp
mov    (%rax),%al
xor    %r14d,%r14d
jmp    1154 <getArgCount+0x34>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbp,%rbx
mov    %rbx,%rdi
call   1040 <nextArg@plt>
mov    %rax,%rbp
add    $0x1,%r14d
mov    (%rax),%al
test   %al,%al
je     118f <getArgCount+0x6f>
movsbl %al,%edi
call   1030 <isspace@plt>
xor    %ecx,%ecx
cmpb   $0x0,0x0(%rbp)
sete   %cl
or     %eax,%ecx
jne    1140 <getArgCount+0x20>
nopl   (%rax)
lea    0x1(%rbp),%rbx
movsbl 0x1(%rbp),%edi
call   1030 <isspace@plt>
xor    %ecx,%ecx
cmpb   $0x0,0x1(%rbp)
sete   %cl
or     %eax,%ecx
mov    %rbx,%rbp
je     1170 <getArgCount+0x50>
jmp    1143 <getArgCount+0x23>
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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