#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 *cmdline_car(char *, int *);
char **erealloc(char **, int);
char **split_line(char *line) {
  int i, total = 0;
  char **list = NULL;
  for (i = 0; line[i] != '\0';) {
    char *word = cmdline_car(line, &i);
    if (word) {
      list = erealloc(list, (++total + 1) * sizeof list);
      list[total - 1] = word;
      list[total] = NULL;
    }
  }
  return list;
}


x86 assembly (clang, -O0):
<split_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11be <split_line+0x9e>
mov    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <cmdline_car@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11b9 <split_line+0x99>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%esi
call   1030 <erealloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
movslq -0x10(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
jmp    1142 <split_line+0x22>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<split_line>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
xor    %r13d,%r13d
cmpb   $0x0,(%rdi)
je     119b <split_line+0x7b>
mov    %rdi,%r15
lea    0x4(%rsp),%r14
xor    %r12d,%r12d
jmp    115c <split_line+0x3c>
nopl   0x0(%rax,%rax,1)
movslq 0x4(%rsp),%rax
cmpb   $0x0,(%r15,%rax,1)
je     119e <split_line+0x7e>
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <cmdline_car@plt>
test   %rax,%rax
je     1150 <split_line+0x30>
mov    %rax,%rbx
lea    0x1(%r13),%ebp
lea    0x10(,%r13,8),%esi
mov    %r12,%rdi
call   1030 <erealloc@plt>
mov    %rax,%r12
movslq %r13d,%rax
mov    %rbx,(%r12,%rax,8)
movq   $0x0,0x8(%r12,%rax,8)
mov    %ebp,%r13d
jmp    1150 <split_line+0x30>
xor    %r12d,%r12d
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8** @split_line(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i8* %0, i8** %2
store i32 0, i32* %4
store i8** null, i8*** %5
store i32 0, i32* %3
br label %7
7: ; preds = %39, %1
%8 = load i8*, i8** %2
%9 = load i32, i32* %3
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %8, i64 %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %40
15: ; preds = %7
%16 = load i8*, i8** %2
%17 = call i8* @cmdline_car(i8* %16, i32* %3)
store i8* %17, i8** %6
%18 = load i8*, i8** %6
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %39
20: ; preds = %15
%21 = load i8**, i8*** %5
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
%24 = add nsw i32 %23, 1
%25 = sext i32 %24 to i64
%26 = mul i64 %25, 8
%27 = trunc i64 %26 to i32
%28 = call i8** @erealloc(i8** %21, i32 %27)
store i8** %28, i8*** %5
%29 = load i8*, i8** %6
%30 = load i8**, i8*** %5
%31 = load i32, i32* %4
%32 = sub nsw i32 %31, 1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %30, i64 %33
store i8* %29, i8** %34
%35 = load i8**, i8*** %5
%36 = load i32, i32* %4
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8*, i8** %35, i64 %37
store i8* null, i8** %38
br label %39
39: ; preds = %20, %15
br label %7
40: ; preds = %7
%41 = load i8**, i8*** %5
ret i8** %41
}

LLVM IR (-O2):
define i8** @split_line(i8* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %28, label %6
6: ; preds = %1, %20
%7 = phi i32 [ %22, %20 ], [ 0, %1 ]
%8 = phi i8** [ %21, %20 ], [ null, %1 ]
%9 = call i8* @cmdline_car(i8* %0, i32* %2)
%10 = icmp eq i8* %9, null
br i1 %10, label %20, label %11
11: ; preds = %6
%12 = add nsw i32 %7, 1
%13 = shl i32 %7, 3
%14 = add i32 %13, 16
%15 = call i8** @erealloc(i8** %8, i32 %14)
%16 = sext i32 %7 to i64
%17 = getelementptr inbounds i8*, i8** %15, i64 %16
store i8* %9, i8** %17
%18 = sext i32 %12 to i64
%19 = getelementptr inbounds i8*, i8** %15, i64 %18
store i8* null, i8** %19
br label %20
20: ; preds = %11, %6
%21 = phi i8** [ %15, %11 ], [ %8, %6 ]
%22 = phi i32 [ %12, %11 ], [ %7, %6 ]
%23 = load i32, i32* %2
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %0, i64 %24
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 0
br i1 %27, label %28, label %6
28: ; preds = %20, %1
%29 = phi i8** [ null, %1 ], [ %21, %20 ]
ret i8** %29
}