#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 */
unsigned int strlen(char *);
char **splitStrBySpaces(char *str) {
  unsigned int i = 0;
  unsigned int letter = 0;
  unsigned int word = 0;
  char **words;
  for (i; i < strlen(str); i++) {
    if (str[i] == ' ') {
      if (i != 0 && str[i - 1] != ' ') {
        word++;
        letter = 0;
      }
    } else {
      words[word][letter] = str[i];
      letter++;
    }
  }
  return words;
}


x86 assembly (clang, -O0):
<splitStrBySpaces>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jae    11d0 <splitStrBySpaces+0xc0>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    1199 <splitStrBySpaces+0x89>
cmpl   $0x0,-0xc(%rbp)
je     1194 <splitStrBySpaces+0x84>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
mov    %ecx,%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
je     1194 <splitStrBySpaces+0x84>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
jmp    11bd <splitStrBySpaces+0xad>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
mov    (%rax,%rcx,1),%dl
mov    -0x20(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
mov    -0x10(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11c2 <splitStrBySpaces+0xb2>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1131 <splitStrBySpaces+0x21>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<splitStrBySpaces>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <strlen@plt>
test   %eax,%eax
je     1153 <splitStrBySpaces+0x43>
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
jb     1153 <splitStrBySpaces+0x43>
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%eax
cmp    %rax,%rbx
jb     1140 <splitStrBySpaces+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8** @splitStrBySpaces(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
store i8* %0, i8** %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
%7 = load i32, i32* %3
br label %8
8: ; preds = %54, %1
%9 = load i32, i32* %3
%10 = load i8*, i8** %2
%11 = call i32 @strlen(i8* %10)
%12 = icmp ult i32 %9, %11
br i1 %12, label %13, label %57
13: ; preds = %8
%14 = load i8*, i8** %2
%15 = load i32, i32* %3
%16 = zext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 32
br i1 %20, label %21, label %37
21: ; preds = %13
%22 = load i32, i32* %3
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %36
24: ; preds = %21
%25 = load i8*, i8** %2
%26 = load i32, i32* %3
%27 = sub i32 %26, 1
%28 = zext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %25, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 32
br i1 %32, label %33, label %36
33: ; preds = %24
%34 = load i32, i32* %5
%35 = add i32 %34, 1
store i32 %35, i32* %5
store i32 0, i32* %4
br label %36
36: ; preds = %33, %24, %21
br label %53
37: ; preds = %13
%38 = load i8*, i8** %2
%39 = load i32, i32* %3
%40 = zext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
%42 = load i8, i8* %41
%43 = load i8**, i8*** %6
%44 = load i32, i32* %5
%45 = zext i32 %44 to i64
%46 = getelementptr inbounds i8*, i8** %43, i64 %45
%47 = load i8*, i8** %46
%48 = load i32, i32* %4
%49 = zext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %47, i64 %49
store i8 %42, i8* %50
%51 = load i32, i32* %4
%52 = add i32 %51, 1
store i32 %52, i32* %4
br label %53
53: ; preds = %37, %36
br label %54
54: ; preds = %53
%55 = load i32, i32* %3
%56 = add i32 %55, 1
store i32 %56, i32* %3
br label %8
57: ; preds = %8
%58 = load i8**, i8*** %6
ret i8** %58
}

LLVM IR (-O2):
define noalias i8** @splitStrBySpaces(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %18, label %4
4: ; preds = %1
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 32
tail call void @llvm.assume(i1 %6)
%7 = tail call i32 @strlen(i8* %0)
%8 = icmp ugt i32 %7, 1
br i1 %8, label %9, label %18
9: ; preds = %4, %9
%10 = phi i64 [ %14, %9 ], [ 1, %4 ]
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 32
tail call void @llvm.assume(i1 %13)
%14 = add nuw nsw i64 %10, 1
%15 = tail call i32 @strlen(i8* %0)
%16 = zext i32 %15 to i64
%17 = icmp ult i64 %14, %16
br i1 %17, label %9, label %18
18: ; preds = %9, %4, %1
ret i8** undef
}