#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 find(char const *, char *, int);
int wspace(char const *, int);
int numstr(const char *d) {
  int k2, k3;
  int cnt = 0;
  k3 = -1;
  do {
    k2 = wspace(d, k3 + 1);
    if (k2 == -1)
      return cnt;
    k3 = find(d, " \t", k2);
    if (k3 == -1)
      return ++cnt;
    ++cnt;
  } while (k3 != -1);
  return -1;
}


x86 assembly (clang, -O0):
<numstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0xffffffff,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
add    $0x1,%esi
call   1040 <wspace@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1161 <numstr+0x41>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ac <numstr+0x8c>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe91(%rip),%rsi
call   1030 <find@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    1192 <numstr+0x72>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    %eax,-0x4(%rbp)
jmp    11ac <numstr+0x8c>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    113a <numstr+0x1a>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<numstr>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %ebx,%ebx
xor    %esi,%esi
call   1040 <wspace@plt>
cmp    $0xffffffff,%eax
je     1179 <numstr+0x59>
mov    $0x1,%ecx
lea    0xebe(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ecx,%ebx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1030 <find@plt>
cmp    $0xffffffff,%eax
je     1179 <numstr+0x59>
add    $0x1,%eax
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <wspace@plt>
lea    0x1(%rbx),%ecx
cmp    $0xffffffff,%eax
jne    1150 <numstr+0x30>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c" \09\00"
define i32 @numstr(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %6
store i32 -1, i32* %5
br label %7
7: ; preds = %28, %1
%8 = load i8*, i8** %3
%9 = load i32, i32* %5
%10 = add nsw i32 %9, 1
%11 = call i32 @wspace(i8* %8, i32 %10)
store i32 %11, i32* %4
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %16
14: ; preds = %7
%15 = load i32, i32* %6
store i32 %15, i32* %2
br label %32
16: ; preds = %7
%17 = load i8*, i8** %3
%18 = load i32, i32* %4
%19 = call i32 @find(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %18)
store i32 %19, i32* %5
%20 = load i32, i32* %5
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %25
22: ; preds = %16
%23 = load i32, i32* %6
%24 = add nsw i32 %23, 1
store i32 %24, i32* %6
store i32 %24, i32* %2
br label %32
25: ; preds = %16
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 1
store i32 %27, i32* %6
br label %28
28: ; preds = %25
%29 = load i32, i32* %5
%30 = icmp ne i32 %29, -1
br i1 %30, label %7, label %31
31: ; preds = %28
store i32 -1, i32* %2
br label %32
32: ; preds = %31, %22, %14
%33 = load i32, i32* %2
ret i32 %33
}

LLVM IR (-O2):
@.str = [3 x i8] c" \09\00"
define i32 @numstr(i8* %0) {
%2 = tail call i32 @wspace(i8* %0, i32 0)
%3 = icmp eq i32 %2, -1
br i1 %3, label %14, label %4
4: ; preds = %1, %10
%5 = phi i32 [ %12, %10 ], [ %2, %1 ]
%6 = phi i32 [ %9, %10 ], [ 0, %1 ]
%7 = tail call i32 @find(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %5)
%8 = icmp eq i32 %7, -1
%9 = add nuw nsw i32 %6, 1
br i1 %8, label %14, label %10
10: ; preds = %4
%11 = add nuw nsw i32 %7, 1
%12 = tail call i32 @wspace(i8* %0, i32 %11)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %4
14: ; preds = %10, %4, %1
%15 = phi i32 [ 0, %1 ], [ %9, %4 ], [ %9, %10 ]
ret i32 %15
}