void test_split_single_delim() {
  int size = 0;
  char the_string[] = "abc def ghi";
  char **ret_val;
  ret_val = pl_split(the_string, " ", &size);
  assert_equal_str("abc", ret_val[0], "test_split_single_delim",
                   "Test 1: Strings not equal.");
  assert_equal_str("def", ret_val[1], "test_split_single_delim",
                   "Test 2: Strings not equal.");
  assert_equal_str("ghi", ret_val[2], "test_split_single_delim",
                   "Test 3: Strings not equal.");
  assert_equal_int(3, size, "test_split_single_delim",
                   "Test 4: Size of the returned array is not right.");
  free(ret_val[0]);
  free(ret_val[1]);
  free(ret_val[2]);
  free(ret_val);
}


x86 assembly (clang, -O0):
<test_split_single_delim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xea8(%rip),%eax
mov    %eax,-0x8(%rbp)
lea    -0x10(%rbp),%rdi
lea    0xe9e(%rip),%rsi
lea    -0x4(%rbp),%rdx
mov    $0x0,%al
call   1050 <pl_split@plt>
cltq
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
lea    0xe81(%rip),%rdi
lea    0xe7e(%rip),%rdx
lea    0xe8f(%rip),%rcx
mov    $0x0,%al
call   1040 <assert_equal_str@plt>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe94(%rip),%rdi
lea    0xe5a(%rip),%rdx
lea    0xe8a(%rip),%rcx
mov    $0x0,%al
call   1040 <assert_equal_str@plt>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe33(%rip),%rdi
lea    0xe36(%rip),%rdx
lea    0xe81(%rip),%rcx
mov    $0x0,%al
call   1040 <assert_equal_str@plt>
mov    -0x4(%rbp),%esi
mov    $0x3,%edi
lea    0xe19(%rip),%rdx
lea    0xe7f(%rip),%rcx
mov    $0x0,%al
call   1060 <assert_equal_int@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_split_single_delim>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movl   $0x0,0x4(%rsp)
movabs $0x2066656420636261,%rax
65 66 20
mov    %rax,0x8(%rsp)
movl   $0x696867,0x10(%rsp)
lea    0xe9f(%rip),%rsi
lea    0x8(%rsp),%rdi
lea    0x4(%rsp),%rdx
xor    %eax,%eax
call   1050 <pl_split@plt>
movslq %eax,%rbx
mov    (%rbx),%rsi
lea    0xe83(%rip),%rdi
lea    0xe80(%rip),%r14
lea    0xe91(%rip),%rcx
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <assert_equal_str@plt>
mov    0x8(%rbx),%rsi
lea    0xe97(%rip),%rdi
lea    0xe94(%rip),%rcx
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <assert_equal_str@plt>
mov    0x10(%rbx),%rsi
lea    0xe3e(%rip),%rdi
lea    0xe93(%rip),%rcx
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <assert_equal_str@plt>
mov    0x4(%rsp),%esi
lea    0xe99(%rip),%rcx
mov    $0x3,%edi
mov    %r14,%rdx
xor    %eax,%eax
call   1060 <assert_equal_int@plt>
mov    (%rbx),%rdi
call   1030 <free@plt>
mov    0x8(%rbx),%rdi
call   1030 <free@plt>
mov    0x10(%rbx),%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.test_split_single_delim.the_string = [12 x i8] c"abc def ghi\00"
@.str = [2 x i8] c" \00"
@.str.1 = [4 x i8] c"abc\00"
@.str.2 = [24 x i8] c"test_split_single_delim\00"
@.str.3 = [27 x i8] c"Test 1: Strings not equal.\00"
@.str.4 = [4 x i8] c"def\00"
@.str.5 = [27 x i8] c"Test 2: Strings not equal.\00"
@.str.6 = [4 x i8] c"ghi\00"
@.str.7 = [27 x i8] c"Test 3: Strings not equal.\00"
@.str.8 = [49 x i8] c"Test 4: Size of the returned array is not right.\00"
define void @test_split_single_delim() {
%1 = alloca i32
%2 = alloca [12 x i8]
%3 = alloca i8**
store i32 0, i32* %1
%4 = bitcast [12 x i8]* %2 to i8*
%5 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%6 = call i32 (i8*, i8*, i32*, ...) bitcast (i32 (...)* @pl_split to i32 (i8*, i8*, i32*, ...)*)(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32* %1)
%7 = sext i32 %6 to i64
%8 = inttoptr i64 %7 to i8**
store i8** %8, i8*** %3
%9 = load i8**, i8*** %3
%10 = getelementptr inbounds i8*, i8** %9, i64 0
%11 = load i8*, i8** %10
%12 = call i32 (i8*, i8*, i8*, i8*, ...) bitcast (i32 (...)* @assert_equal_str to i32 (i8*, i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %11, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%13 = load i8**, i8*** %3
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 (i8*, i8*, i8*, i8*, ...) bitcast (i32 (...)* @assert_equal_str to i32 (i8*, i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %15, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
%17 = load i8**, i8*** %3
%18 = getelementptr inbounds i8*, i8** %17, i64 2
%19 = load i8*, i8** %18
%20 = call i32 (i8*, i8*, i8*, i8*, ...) bitcast (i32 (...)* @assert_equal_str to i32 (i8*, i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %19, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0))
%21 = load i32, i32* %1
%22 = call i32 (i32, i32, i8*, i8*, ...) bitcast (i32 (...)* @assert_equal_int to i32 (i32, i32, i8*, i8*, ...)*)(i32 3, i32 %21, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.8, i64 0, i64 0))
%23 = load i8**, i8*** %3
%24 = getelementptr inbounds i8*, i8** %23, i64 0
%25 = load i8*, i8** %24
%26 = load i8**, i8*** %3
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = load i8**, i8*** %3
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = load i8**, i8*** %3
%33 = bitcast i8** %32 to i8*
ret void
}

LLVM IR (-O2):
@__const.test_split_single_delim.the_string = [12 x i8] c"abc def ghi\00"
@.str = [2 x i8] c" \00"
@.str.1 = [4 x i8] c"abc\00"
@.str.2 = [24 x i8] c"test_split_single_delim\00"
@.str.3 = [27 x i8] c"Test 1: Strings not equal.\00"
@.str.4 = [4 x i8] c"def\00"
@.str.5 = [27 x i8] c"Test 2: Strings not equal.\00"
@.str.6 = [4 x i8] c"ghi\00"
@.str.7 = [27 x i8] c"Test 3: Strings not equal.\00"
@.str.8 = [49 x i8] c"Test 4: Size of the returned array is not right.\00"
define void @test_split_single_delim() {
%1 = alloca i32
%2 = alloca [12 x i8]
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%5 = call i32 (i8*, i8*, i32*, ...) bitcast (i32 (...)* @pl_split to i32 (i8*, i8*, i32*, ...)*)(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = sext i32 %5 to i64
%7 = inttoptr i64 %6 to i8**
%8 = load i8*, i8** %7
%9 = call i32 (i8*, i8*, i8*, i8*, ...) bitcast (i32 (...)* @assert_equal_str to i32 (i8*, i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %8, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%10 = getelementptr inbounds i8*, i8** %7, i64 1
%11 = load i8*, i8** %10
%12 = call i32 (i8*, i8*, i8*, i8*, ...) bitcast (i32 (...)* @assert_equal_str to i32 (i8*, i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %11, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
%13 = getelementptr inbounds i8*, i8** %7, i64 2
%14 = load i8*, i8** %13
%15 = call i32 (i8*, i8*, i8*, i8*, ...) bitcast (i32 (...)* @assert_equal_str to i32 (i8*, i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %14, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0))
%16 = load i32, i32* %1
%17 = call i32 (i32, i32, i8*, i8*, ...) bitcast (i32 (...)* @assert_equal_int to i32 (i32, i32, i8*, i8*, ...)*)(i32 3, i32 %16, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.8, i64 0, i64 0))
%18 = load i8*, i8** %7
%19 = load i8*, i8** %10
%20 = load i8*, i8** %13
%21 = inttoptr i64 %6 to i8*
ret void
}