char **perl_split(buf)
char *buf;
{
  char **return_buf;
  int cntr = 0;
  char *temp, *temp2;
  temp2 = (char *)malloc(sizeof(char) * (1 + strlen(buf)));
  while (*buf == ' ' || *buf == '\t')
    ++buf;
  strcpy(temp2, buf);
  return_buf = (char **)malloc(sizeof(char *) * ((numspaces(temp2) + 1) + 2));
  return_buf[cntr++] = (char *)strtok(temp2, " \t");
  while (temp = (char *)strtok(0, " \t"))
    if (temp != 0) {
      return_buf[cntr] = temp;
      ++cntr;
    }
  return_buf[cntr] = 0;
  return (return_buf);
}


x86 assembly (clang, -O0):
<perl_split>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
shl    $0x0,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x29(%rbp)
je     11a5 <perl_split+0x55>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11b5 <perl_split+0x65>
jmp    11c6 <perl_split+0x76>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1180 <perl_split+0x30>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x28(%rbp),%rdi
mov    $0x0,%al
call   1060 <numspaces@plt>
add    $0x1,%eax
add    $0x2,%eax
movslq %eax,%rdi
shl    $0x3,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe01(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x14(%rbp)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
xor    %eax,%eax
mov    %eax,%edi
lea    0xdd8(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     1264 <perl_split+0x114>
cmpq   $0x0,-0x20(%rbp)
je     125f <perl_split+0x10f>
mov    -0x20(%rbp),%rdx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    121d <perl_split+0xcd>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<perl_split>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <strlen@plt>
lea    0x1(%rax),%rdi
call   1050 <malloc@plt>
mov    %rax,%r14
jmp    1174 <perl_split+0x24>
xchg   %ax,%ax
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x20,%al
je     1170 <perl_split+0x20>
cmp    $0x9,%al
je     1170 <perl_split+0x20>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <numspaces@plt>
cltq
lea    0x18(,%rax,8),%rdi
call   1050 <malloc@plt>
mov    %rax,%r12
lea    0xe53(%rip),%r15
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <strtok@plt>
mov    %rax,(%r12)
xor    %edi,%edi
mov    %r15,%rsi
call   1070 <strtok@plt>
test   %rax,%rax
je     11fb <perl_split+0xab>
mov    $0x1,%ebx
lea    0xe29(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    %rax,(%r12,%rbx,8)
add    $0x1,%rbx
xor    %edi,%edi
mov    %r14,%rsi
call   1070 <strtok@plt>
test   %rax,%rax
jne    11e0 <perl_split+0x90>
mov    %ebx,%eax
jmp    1200 <perl_split+0xb0>
mov    $0x1,%eax
movq   $0x0,(%r12,%rax,8)
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c" \09\00"
define i8** @perl_split(i8* %0) {
%2 = alloca i8*
%3 = alloca i8**
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %2
store i32 0, i32* %4
%7 = load i8*, i8** %2
%8 = call i64 @strlen(i8* %7)
%9 = add i64 1, %8
%10 = mul i64 1, %9
%11 = call i8* @malloc(i64 %10)
store i8* %11, i8** %6
br label %12
12: ; preds = %24, %1
%13 = load i8*, i8** %2
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 32
br i1 %16, label %22, label %17
17: ; preds = %12
%18 = load i8*, i8** %2
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 9
br label %22
22: ; preds = %17, %12
%23 = phi i1 [ true, %12 ], [ %21, %17 ]
br i1 %23, label %24, label %27
24: ; preds = %22
%25 = load i8*, i8** %2
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %2
br label %12
27: ; preds = %22
%28 = load i8*, i8** %6
%29 = load i8*, i8** %2
%30 = call i8* @strcpy(i8* %28, i8* %29)
%31 = load i8*, i8** %6
%32 = call i32 (i8*, ...) bitcast (i32 (...)* @numspaces to i32 (i8*, ...)*)(i8* %31)
%33 = add nsw i32 %32, 1
%34 = add nsw i32 %33, 2
%35 = sext i32 %34 to i64
%36 = mul i64 8, %35
%37 = call i8* @malloc(i64 %36)
%38 = bitcast i8* %37 to i8**
store i8** %38, i8*** %3
%39 = load i8*, i8** %6
%40 = call i8* @strtok(i8* %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%41 = load i8**, i8*** %3
%42 = load i32, i32* %4
%43 = add nsw i32 %42, 1
store i32 %43, i32* %4
%44 = sext i32 %42 to i64
%45 = getelementptr inbounds i8*, i8** %41, i64 %44
store i8* %40, i8** %45
br label %46
46: ; preds = %60, %27
%47 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %47, i8** %5
%48 = icmp ne i8* %47, null
br i1 %48, label %49, label %61
49: ; preds = %46
%50 = load i8*, i8** %5
%51 = icmp ne i8* %50, null
br i1 %51, label %52, label %60
52: ; preds = %49
%53 = load i8*, i8** %5
%54 = load i8**, i8*** %3
%55 = load i32, i32* %4
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8*, i8** %54, i64 %56
store i8* %53, i8** %57
%58 = load i32, i32* %4
%59 = add nsw i32 %58, 1
store i32 %59, i32* %4
br label %60
60: ; preds = %52, %49
br label %46
61: ; preds = %46
%62 = load i8**, i8*** %3
%63 = load i32, i32* %4
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8*, i8** %62, i64 %64
store i8* null, i8** %65
%66 = load i8**, i8*** %3
ret i8** %66
}

LLVM IR (-O2):
@.str = [3 x i8] c" \09\00"
define i8** @perl_split(i8* nocapture %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = add i64 %2, 1
%4 = tail call i8* @malloc(i64 %3)
br label %5
5: ; preds = %8, %1
%6 = phi i8* [ %0, %1 ], [ %9, %8 ]
%7 = load i8, i8* %6
switch i8 %7, label %10 [
i8 32, label %8
i8 9, label %8
]
8: ; preds = %5, %5
%9 = getelementptr inbounds i8, i8* %6, i64 1
br label %5
10: ; preds = %5
%11 = tail call i8* @strcpy(i8* dereferenceable(1) %4, i8* %6)
%12 = tail call i32 (i8*, ...) bitcast (i32 (...)* @numspaces to i32 (i8*, ...)*)(i8* %4)
%13 = add nsw i32 %12, 3
%14 = sext i32 %13 to i64
%15 = shl nsw i64 %14, 3
%16 = tail call i8* @malloc(i64 %15)
%17 = bitcast i8* %16 to i8**
%18 = tail call i8* @strtok(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %18, i8** %17
%19 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%20 = icmp eq i8* %19, null
br i1 %20, label %30, label %21
21: ; preds = %10, %21
%22 = phi i64 [ %25, %21 ], [ 1, %10 ]
%23 = phi i8* [ %26, %21 ], [ %19, %10 ]
%24 = getelementptr inbounds i8*, i8** %17, i64 %22
store i8* %23, i8** %24
%25 = add nuw i64 %22, 1
%26 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%27 = icmp eq i8* %26, null
br i1 %27, label %28, label %21
28: ; preds = %21
%29 = and i64 %25, 4294967295
br label %30
30: ; preds = %28, %10
%31 = phi i64 [ 1, %10 ], [ %29, %28 ]
%32 = getelementptr inbounds i8*, i8** %17, i64 %31
store i8* null, i8** %32
ret i8** %17
}