#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 /*<<< orphan*/ cmd_error(char *);
scalar_t__ isspace(int);
char **malloc(int);
char **sa_concat(char **, char *);
char **split_tokens(char *line) {
  char **tokens;
  if ((tokens = malloc(sizeof(char *))) == NULL) {
    cmd_error("out of memory\n");
  }
  tokens[0] = NULL;
  while (1) {
    for (; *line != '\0' && isspace((int)*line); line++)
      ;
    if (*line == '\0') {
      break;
    }
    tokens = sa_concat(tokens, line);
    for (line++; *line != '\0' && !isspace((int)*line); line++)
      ;
    if (*line == '\0') {
      break;
    }
    *line++ = '\0';
  }
  return tokens;
}


x86 assembly (clang, -O0):
<split_tokens>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x8,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    1170 <split_tokens+0x30>
lea    0xe95(%rip),%rdi
call   1060 <cmd_error@plt>
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
jmp    1180 <split_tokens+0x40>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
je     11ab <split_tokens+0x6b>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    11bb <split_tokens+0x7b>
jmp    11d1 <split_tokens+0x91>
jmp    11c0 <split_tokens+0x80>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1180 <split_tokens+0x40>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11e6 <split_tokens+0xa6>
jmp    1282 <split_tokens+0x142>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <sa_concat@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x12(%rbp)
je     1230 <split_tokens+0xf0>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
test   $0x1,%al
jne    1240 <split_tokens+0x100>
jmp    1256 <split_tokens+0x116>
jmp    1245 <split_tokens+0x105>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1203 <split_tokens+0xc3>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    126b <split_tokens+0x12b>
jmp    1282 <split_tokens+0x142>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x0,(%rax)
jmp    117b <split_tokens+0x3b>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<split_tokens>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
mov    $0x8,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
test   %rax,%rax
jne    1166 <split_tokens+0x26>
lea    0xe9f(%rip),%rdi
call   1060 <cmd_error@plt>
movq   $0x0,(%r14)
mov    (%r15),%al
test   %al,%al
je     11e4 <split_tokens+0xa4>
mov    %r15,%rbx
add    $0x1,%r15
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1040 <isspace@plt>
test   %rax,%rax
je     11a0 <split_tokens+0x60>
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
add    $0x1,%r15
test   %al,%al
jne    1180 <split_tokens+0x40>
jmp    11e4 <split_tokens+0xa4>
nop
cmpb   $0x0,(%rbx)
je     11e4 <split_tokens+0xa4>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <sa_concat@plt>
mov    %rax,%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl (%r15),%edi
test   %edi,%edi
je     11e4 <split_tokens+0xa4>
call   1040 <isspace@plt>
add    $0x1,%r15
test   %rax,%rax
je     11c0 <split_tokens+0x80>
cmpb   $0x0,-0x1(%r15)
je     11e4 <split_tokens+0xa4>
movb   $0x0,-0x1(%r15)
jmp    116d <split_tokens+0x2d>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [15 x i8] c"out of memory\0A\00"
define i8** @split_tokens(i8* %0) {
%2 = tail call i8** @malloc(i32 8)
%3 = icmp eq i8** %2, null
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @cmd_error(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %1
store i8* null, i8** %2
%7 = load i8, i8* %0
%8 = icmp eq i8 %7, 0
br i1 %8, label %44, label %9
9: ; preds = %6, %40
%10 = phi i8 [ %42, %40 ], [ %7, %6 ]
%11 = phi i8** [ %27, %40 ], [ %2, %6 ]
%12 = phi i8* [ %41, %40 ], [ %0, %6 ]
br label %13
13: ; preds = %9, %19
%14 = phi i8 [ %10, %9 ], [ %21, %19 ]
%15 = phi i8* [ %12, %9 ], [ %20, %19 ]
%16 = sext i8 %14 to i32
%17 = tail call i64 @isspace(i32 %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %13
%20 = getelementptr inbounds i8, i8* %15, i64 1
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
br i1 %22, label %44, label %13
23: ; preds = %13
%24 = load i8, i8* %15
%25 = icmp eq i8 %24, 0
br i1 %25, label %44, label %26
26: ; preds = %23
%27 = tail call i8** @sa_concat(i8** %11, i8* %15)
br label %28
28: ; preds = %33, %26
%29 = phi i8* [ %15, %26 ], [ %30, %33 ]
%30 = getelementptr inbounds i8, i8* %29, i64 1
%31 = load i8, i8* %30
%32 = icmp eq i8 %31, 0
br i1 %32, label %44, label %33
33: ; preds = %28
%34 = sext i8 %31 to i32
%35 = tail call i64 @isspace(i32 %34)
%36 = icmp eq i64 %35, 0
br i1 %36, label %28, label %37
37: ; preds = %33
%38 = load i8, i8* %30
%39 = icmp eq i8 %38, 0
br i1 %39, label %44, label %40
40: ; preds = %37
%41 = getelementptr inbounds i8, i8* %29, i64 2
store i8 0, i8* %30
%42 = load i8, i8* %41
%43 = icmp eq i8 %42, 0
br i1 %43, label %44, label %9
44: ; preds = %37, %23, %40, %19, %28, %6
%45 = phi i8** [ %2, %6 ], [ %27, %28 ], [ %11, %19 ], [ %27, %40 ], [ %27, %37 ], [ %11, %23 ]
ret i8** %45
}