#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 countWords(char *, char);
void *malloc(int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *wordParse(char *, int, char);
char **strParser(char *str, char c) {
  int i = 0, j = 0, words;
  char **retstr, *tempword;
  words = countWords(str, c);
  retstr = malloc(words);
  for (i = 1; i <= words; i++) {
    tempword = wordParse(str, i, c);
    retstr[i - 1] = malloc(strlen(tempword) + 1);
    strcpy(retstr[i - 1], tempword);
  }
  return retstr;
}


x86 assembly (clang, -O0):
<strParser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
movsbl -0x9(%rbp),%esi
call   1050 <countWords@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     1202 <strParser+0xb2>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
movsbl -0x9(%rbp),%edx
call   1070 <wordParse@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%edi
add    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1193 <strParser+0x43>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strParser>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%r14
call   1050 <countWords@plt>
mov    %eax,%r12d
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
test   %r12d,%r12d
jle    11c9 <strParser+0x79>
add    $0x1,%r12d
mov    $0x1,%ebx
movsbl %bpl,%r13d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    %ebx,%esi
mov    %r13d,%edx
call   1070 <wordParse@plt>
mov    %rax,%rbp
mov    %rax,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%edi
call   1060 <malloc@plt>
mov    %rax,-0x8(%r15,%rbx,8)
mov    %rax,%rdi
mov    %rbp,%rsi
call   1030 <strcpy@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1190 <strParser+0x40>
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8** @strParser(i8* %0, i8 signext %1) {
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i8*
store i8* %0, i8** %3
store i8 %1, i8* %4
store i32 0, i32* %5
store i32 0, i32* %6
%10 = load i8*, i8** %3
%11 = load i8, i8* %4
%12 = call i32 @countWords(i8* %10, i8 signext %11)
store i32 %12, i32* %7
%13 = load i32, i32* %7
%14 = call i8* @malloc(i32 %13)
%15 = bitcast i8* %14 to i8**
store i8** %15, i8*** %8
store i32 1, i32* %5
br label %16
16: ; preds = %42, %2
%17 = load i32, i32* %5
%18 = load i32, i32* %7
%19 = icmp sle i32 %17, %18
br i1 %19, label %20, label %45
20: ; preds = %16
%21 = load i8*, i8** %3
%22 = load i32, i32* %5
%23 = load i8, i8* %4
%24 = call i8* @wordParse(i8* %21, i32 %22, i8 signext %23)
store i8* %24, i8** %9
%25 = load i8*, i8** %9
%26 = call i32 @strlen(i8* %25)
%27 = add nsw i32 %26, 1
%28 = call i8* @malloc(i32 %27)
%29 = load i8**, i8*** %8
%30 = load i32, i32* %5
%31 = sub nsw i32 %30, 1
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8*, i8** %29, i64 %32
store i8* %28, i8** %33
%34 = load i8**, i8*** %8
%35 = load i32, i32* %5
%36 = sub nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8*, i8** %34, i64 %37
%39 = load i8*, i8** %38
%40 = load i8*, i8** %9
%41 = call i32 @strcpy(i8* %39, i8* %40)
br label %42
42: ; preds = %20
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 1
store i32 %44, i32* %5
br label %16
45: ; preds = %16
%46 = load i8**, i8*** %8
ret i8** %46
}

LLVM IR (-O2):
define noalias i8** @strParser(i8* %0, i8 signext %1) {
%3 = tail call i32 @countWords(i8* %0, i8 signext %1)
%4 = tail call i8* @malloc(i32 %3)
%5 = bitcast i8* %4 to i8**
%6 = icmp slt i32 %3, 1
br i1 %6, label %22, label %7
7: ; preds = %2
%8 = add nuw i32 %3, 1
%9 = zext i32 %8 to i64
br label %10
10: ; preds = %7, %10
%11 = phi i64 [ 1, %7 ], [ %20, %10 ]
%12 = trunc i64 %11 to i32
%13 = tail call i8* @wordParse(i8* %0, i32 %12, i8 signext %1)
%14 = tail call i32 @strlen(i8* %13)
%15 = add nsw i32 %14, 1
%16 = tail call i8* @malloc(i32 %15)
%17 = add nsw i64 %11, -1
%18 = getelementptr inbounds i8*, i8** %5, i64 %17
store i8* %16, i8** %18
%19 = tail call i32 @strcpy(i8* %16, i8* %13)
%20 = add nuw nsw i64 %11, 1
%21 = icmp eq i64 %20, %9
br i1 %21, label %22, label %10
22: ; preds = %10, %2
ret i8** %5
}