#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ strcpy(char *, char const *);
char *strtok(char *, char *);
int numOfWorldsInString(const char *str) {
  int count = 0;
  char *word;
  char *sep = " ,./;:'\"\\!@#$%^*1234567890";
  char *array = (char *)malloc(sizeof(char));
  strcpy(array, str);
  for (word = strtok(array, sep); word; word = strtok(NULL, sep)) {
    count++;
  }
  return count;
}


x86 assembly (clang, -O0):
<numOfWorldsInString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xeb6(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    $0x1,%edi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11a4 <numOfWorldsInString+0x74>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x20(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1050 <strtok@plt>
mov    %rax,-0x18(%rbp)
jmp    117a <numOfWorldsInString+0x4a>
mov    -0xc(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<numOfWorldsInString>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x1,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
lea    0xeaa(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strtok@plt>
xor    %ebx,%ebx
test   %rax,%rax
je     1182 <numOfWorldsInString+0x52>
lea    0xe94(%rip),%r14
nopl   0x0(%rax)
add    $0x1,%ebx
xor    %edi,%edi
mov    %r14,%rsi
call   1050 <strtok@plt>
test   %rax,%rax
jne    1170 <numOfWorldsInString+0x40>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [27 x i8] c" ,./;:'\22\\!@#$%^*1234567890\00"
define i32 @numOfWorldsInString(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %2
store i32 0, i32* %3
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8** %5
%7 = call i64 @malloc(i32 1)
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** %6
%9 = load i8*, i8** %6
%10 = load i8*, i8** %2
%11 = call i32 @strcpy(i8* %9, i8* %10)
%12 = load i8*, i8** %6
%13 = load i8*, i8** %5
%14 = call i8* @strtok(i8* %12, i8* %13)
store i8* %14, i8** %4
br label %15
15: ; preds = %21, %1
%16 = load i8*, i8** %4
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %24
18: ; preds = %15
%19 = load i32, i32* %3
%20 = add nsw i32 %19, 1
store i32 %20, i32* %3
br label %21
21: ; preds = %18
%22 = load i8*, i8** %5
%23 = call i8* @strtok(i8* null, i8* %22)
store i8* %23, i8** %4
br label %15
24: ; preds = %15
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
@.str = [27 x i8] c" ,./;:'\22\\!@#$%^*1234567890\00"
define i32 @numOfWorldsInString(i8* %0) {
%2 = tail call i64 @malloc(i32 1)
%3 = inttoptr i64 %2 to i8*
%4 = tail call i32 @strcpy(i8* %3, i8* %0)
%5 = tail call i8* @strtok(i8* %3, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i8* %5, null
br i1 %6, label %12, label %7
7: ; preds = %1, %7
%8 = phi i32 [ %9, %7 ], [ 0, %1 ]
%9 = add nuw nsw i32 %8, 1
%10 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %7
12: ; preds = %7, %1
%13 = phi i32 [ 0, %1 ], [ %9, %7 ]
ret i32 %13
}