#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 **malloc(int);
char **realloc(char **, int);
char *strtok(char *, char *);
char **parse_command(char *command) {
  char **args = malloc(100 * sizeof(char *));
  char *token;
  int pos = 0;
  int total_token_size = 100;
  token = strtok(command, "\t\r\n\a ");
  while (token != NULL) {
    args[pos] = token;
    pos++;
    if (pos >= total_token_size) {
      total_token_size += 100;
      args = realloc(args, total_token_size * sizeof(char *));
    }
    token = strtok(NULL, "\t\r\n\a ");
  }
  args[pos] = NULL;
  return args;
}


x86 assembly (clang, -O0):
<parse_command>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x320,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x64,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe9d(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11d5 <parse_command+0xa5>
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jl     11bc <parse_command+0x8c>
mov    -0x20(%rbp),%eax
add    $0x64,%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
movslq -0x20(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%esi
call   1040 <realloc@plt>
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe39(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x18(%rbp)
jmp    116c <parse_command+0x3c>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_command>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
mov    $0x320,%edi
call   1030 <malloc@plt>
mov    %rax,%r15
lea    0xeb1(%rip),%rsi
mov    %r14,%rdi
call   1050 <strtok@plt>
test   %rax,%rax
je     11ae <parse_command+0x7e>
mov    $0x64,%r12d
xor    %ebx,%ebx
lea    0xe95(%rip),%r14
jmp    117f <parse_command+0x4f>
nopl   (%rax)
xor    %edi,%edi
mov    %r14,%rsi
call   1050 <strtok@plt>
test   %rax,%rax
je     11aa <parse_command+0x7a>
mov    %rax,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    %ebx,%r12d
jg     1170 <parse_command+0x40>
mov    %r12d,%ebp
add    $0x64,%ebp
lea    0x320(,%r12,8),%esi
mov    %r15,%rdi
call   1040 <realloc@plt>
mov    %rax,%r15
mov    %ebp,%r12d
jmp    1170 <parse_command+0x40>
mov    %ebx,%eax
jmp    11b0 <parse_command+0x80>
xor    %eax,%eax
movq   $0x0,(%r15,%rax,8)
mov    %r15,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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