void test_split() {
  int size = 0;
  char the_string[] = "fooasdbar";
  char **ret_val;
  ret_val = pl_split(the_string, "asd", &size);
  assert_equal_str("foo", ret_val[0], "test_split",
                   "Test 1: The strings are not equal.");
  assert_equal_str("bar", ret_val[1], "test_split",
                   "Test 2: The strings are not equal.");
  assert_equal_int(2, size, "test_split", "Test 3: Size is not correct.");
  free(ret_val[0]);
  free(ret_val[1]);
  free(ret_val);
}


x86 assembly (clang, -O0):
<test_split>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0xe(%rbp)
mov    0xea7(%rip),%ax
mov    %ax,-0x6(%rbp)
lea    -0xe(%rbp),%rdi
lea    0xe9a(%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    0xe7f(%rip),%rdi
lea    0xe7c(%rip),%rdx
lea    0xe80(%rip),%rcx
mov    $0x0,%al
call   1040 <assert_equal_str@plt>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe53(%rip),%rdi
lea    0xe58(%rip),%rdx
lea    0xe7f(%rip),%rcx
mov    $0x0,%al
call   1040 <assert_equal_str@plt>
mov    -0x4(%rbp),%esi
mov    $0x2,%edi
lea    0xe3b(%rip),%rdx
lea    0xe85(%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),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_split>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movl   $0x0,0x4(%rsp)
movabs $0x61626473616f6f66,%rax
64 62 61
mov    %rax,0x8(%rsp)
movw   $0x72,0x10(%rsp)
lea    0xe9e(%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    0xe84(%rip),%rdi
lea    0xe81(%rip),%r14
lea    0xe85(%rip),%rcx
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <assert_equal_str@plt>
mov    0x8(%rbx),%rsi
lea    0xe59(%rip),%rdi
lea    0xe8c(%rip),%rcx
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <assert_equal_str@plt>
mov    0x4(%rsp),%esi
lea    0xe9a(%rip),%rcx
mov    $0x2,%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    %rbx,%rdi
call   1030 <free@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.test_split.the_string = [10 x i8] c"fooasdbar\00"
@.str = [4 x i8] c"asd\00"
@.str.1 = [4 x i8] c"foo\00"
@.str.2 = [11 x i8] c"test_split\00"
@.str.3 = [35 x i8] c"Test 1: The strings are not equal.\00"
@.str.4 = [4 x i8] c"bar\00"
@.str.5 = [35 x i8] c"Test 2: The strings are not equal.\00"
@.str.6 = [29 x i8] c"Test 3: Size is not correct.\00"
define void @test_split() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = alloca i8**
store i32 0, i32* %1
%4 = bitcast [10 x i8]* %2 to i8*
%5 = getelementptr inbounds [10 x i8], [10 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 ([4 x i8], [4 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 ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([35 x i8], [35 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 ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
%17 = load i32, i32* %1
%18 = call i32 (i32, i32, i8*, i8*, ...) bitcast (i32 (...)* @assert_equal_int to i32 (i32, i32, i8*, i8*, ...)*)(i32 2, i32 %17, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0))
%19 = load i8**, i8*** %3
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = load i8**, i8*** %3
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = load i8**, i8*** %3
%26 = bitcast i8** %25 to i8*
ret void
}

LLVM IR (-O2):
@__const.test_split.the_string = [10 x i8] c"fooasdbar\00"
@.str = [4 x i8] c"asd\00"
@.str.1 = [4 x i8] c"foo\00"
@.str.2 = [11 x i8] c"test_split\00"
@.str.3 = [35 x i8] c"Test 1: The strings are not equal.\00"
@.str.4 = [4 x i8] c"bar\00"
@.str.5 = [35 x i8] c"Test 2: The strings are not equal.\00"
@.str.6 = [29 x i8] c"Test 3: Size is not correct.\00"
define void @test_split() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = getelementptr inbounds [10 x i8], [10 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 ([4 x i8], [4 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 ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([35 x i8], [35 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 ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
%13 = load i32, i32* %1
%14 = call i32 (i32, i32, i8*, i8*, ...) bitcast (i32 (...)* @assert_equal_int to i32 (i32, i32, i8*, i8*, ...)*)(i32 2, i32 %13, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0))
%15 = load i8*, i8** %7
%16 = load i8*, i8** %10
%17 = inttoptr i64 %6 to i8*
ret void
}