#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 */
char *calloc(scalar_t__, int);
char **malloc(int);
char **realloc(char **, int);
int /*<<< orphan*/ strcpy(char *, char const *);
scalar_t__ strlen(char const *);
char *strtok_r(char *, char *, char **);
char **chop_words(const char *src) {
  char **v = NULL, *str, *r;
  int count = 2;
  if (!src)
    return NULL;
  str = calloc(1 + strlen(src), sizeof(char));
  *(v = malloc(count * sizeof(char **))) = str;
  strcpy(str, src);
  *(v + count - 1) = strtok_r(str, " \t\r\n", &r);
  do
    v = realloc(v, ++count * sizeof(char **));
  while ((*(v + count - 1) = strtok_r(NULL, " \t\r\n", &r)));
  return v;
}


x86 assembly (clang, -O0):
<chop_words>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x2,-0x2c(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1193 <chop_words+0x33>
movq   $0x0,-0x8(%rbp)
jmp    1255 <chop_words+0xf5>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
movslq -0x2c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    -0x38(%rbp),%rcx
mov    %rax,-0x18(%rbp)
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rdi
lea    0xe15(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1050 <strtok_r@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    %rdx,-0x8(%rax,%rcx,8)
mov    -0x18(%rbp),%rdi
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
cltq
shl    $0x3,%rax
mov    %eax,%esi
call   1080 <realloc@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xdd3(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1050 <strtok_r@plt>
mov    -0x18(%rbp),%rcx
movslq -0x2c(%rbp),%rdx
mov    %rax,-0x8(%rcx,%rdx,8)
cmp    $0x0,%rax
jne    1204 <chop_words+0xa4>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chop_words>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
test   %rdi,%rdi
je     11fe <chop_words+0x9e>
mov    %rdi,%r14
call   1040 <strlen@plt>
lea    0x1(%rax),%rdi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,%r12
mov    $0x10,%edi
call   1070 <malloc@plt>
mov    %rax,%r13
mov    %r12,(%rax)
mov    %r12,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
lea    0xe4f(%rip),%r14
lea    0x8(%rsp),%r15
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1050 <strtok_r@plt>
mov    %rax,0x8(%r13)
mov    $0x10,%ebx
nopl   (%rax)
lea    0x8(%rbx),%r12
mov    %r13,%rdi
mov    %r12d,%esi
call   1080 <realloc@plt>
mov    %rax,%r13
xor    %edi,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1050 <strtok_r@plt>
mov    %rax,0x0(%r13,%rbx,1)
mov    %r12,%rbx
test   %rax,%rax
jne    11d0 <chop_words+0x70>
jmp    1201 <chop_words+0xa1>
xor    %r13d,%r13d
mov    %r13,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c" \09\0D\0A\00"
define i8** @chop_words(i8* %0) {
%2 = alloca i8**
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %3
store i8** null, i8*** %4
store i32 2, i32* %7
%8 = load i8*, i8** %3
%9 = icmp ne i8* %8, null
br i1 %9, label %11, label %10
10: ; preds = %1
store i8** null, i8*** %2
br label %50
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = call i64 @strlen(i8* %12)
%14 = add nsw i64 1, %13
%15 = call i8* @calloc(i64 %14, i32 1)
store i8* %15, i8** %5
%16 = load i8*, i8** %5
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = mul i64 %18, 8
%20 = trunc i64 %19 to i32
%21 = call i8** @malloc(i32 %20)
store i8** %21, i8*** %4
store i8* %16, i8** %21
%22 = load i8*, i8** %5
%23 = load i8*, i8** %3
%24 = call i32 @strcpy(i8* %22, i8* %23)
%25 = load i8*, i8** %5
%26 = call i8* @strtok_r(i8* %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %6)
%27 = load i8**, i8*** %4
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
%31 = getelementptr inbounds i8*, i8** %30, i64 -1
store i8* %26, i8** %31
br label %32
32: ; preds = %40, %11
%33 = load i8**, i8*** %4
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
store i32 %35, i32* %7
%36 = sext i32 %35 to i64
%37 = mul i64 %36, 8
%38 = trunc i64 %37 to i32
%39 = call i8** @realloc(i8** %33, i32 %38)
store i8** %39, i8*** %4
br label %40
40: ; preds = %32
%41 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %6)
%42 = load i8**, i8*** %4
%43 = load i32, i32* %7
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8*, i8** %42, i64 %44
%46 = getelementptr inbounds i8*, i8** %45, i64 -1
store i8* %41, i8** %46
%47 = icmp ne i8* %41, null
br i1 %47, label %32, label %48
48: ; preds = %40
%49 = load i8**, i8*** %4
store i8** %49, i8*** %2
br label %50
50: ; preds = %48, %10
%51 = load i8**, i8*** %2
ret i8** %51
}

LLVM IR (-O2):
@.str = [5 x i8] c" \09\0D\0A\00"
define i8** @chop_words(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = icmp eq i8* %0, null
br i1 %4, label %23, label %5
5: ; preds = %1
%6 = tail call i64 @strlen(i8* %0)
%7 = add nsw i64 %6, 1
%8 = tail call i8* @calloc(i64 %7, i32 1)
%9 = tail call i8** @malloc(i32 16)
store i8* %8, i8** %9
%10 = tail call i32 @strcpy(i8* %8, i8* %0)
%11 = call i8* @strtok_r(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %2)
%12 = getelementptr inbounds i8*, i8** %9, i64 1
store i8* %11, i8** %12
br label %13
13: ; preds = %13, %5
%14 = phi i64 [ %16, %13 ], [ 2, %5 ]
%15 = phi i8** [ %19, %13 ], [ %9, %5 ]
%16 = add nuw nsw i64 %14, 1
%17 = trunc i64 %16 to i32
%18 = shl i32 %17, 3
%19 = call i8** @realloc(i8** %15, i32 %18)
%20 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %2)
%21 = getelementptr inbounds i8*, i8** %19, i64 %14
store i8* %20, i8** %21
%22 = icmp eq i8* %20, null
br i1 %22, label %23, label %13
23: ; preds = %13, %1
%24 = phi i8** [ null, %1 ], [ %19, %13 ]
ret i8** %24
}