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


x86 assembly (clang, -O0):
<test_split_multiple_delims>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xea7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xea4(%rip),%ax
mov    %ax,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
lea    0xe97(%rip),%rsi
lea    -0x4(%rbp),%rdx
mov    $0x0,%al
call   1050 <pl_split@plt>
cltq
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%rsi
lea    0xe7c(%rip),%rdi
lea    0xe79(%rip),%rdx
lea    0xe8d(%rip),%rcx
mov    $0x0,%al
call   1040 <assert_equal_str@plt>
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe96(%rip),%rdi
lea    0xe55(%rip),%rdx
lea    0xe8c(%rip),%rcx
mov    $0x0,%al
call   1040 <assert_equal_str@plt>
mov    -0x28(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe95(%rip),%rdi
lea    0xe31(%rip),%rdx
lea    0xe8d(%rip),%rcx
mov    $0x0,%al
call   1040 <assert_equal_str@plt>
mov    -0x4(%rbp),%esi
mov    $0x3,%edi
lea    0xe14(%rip),%rdx
lea    0xe8e(%rip),%rcx
mov    $0x0,%al
call   1060 <assert_equal_int@plt>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_split_multiple_delims>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movl   $0x0,0xc(%rsp)
movaps 0xeaa(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movw   $0x63,0x20(%rsp)
lea    0xea9(%rip),%rsi
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1050 <pl_split@plt>
movslq %eax,%rbx
mov    (%rbx),%rsi
lea    0xe8f(%rip),%rdi
lea    0xe8c(%rip),%r14
lea    0xea0(%rip),%rcx
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <assert_equal_str@plt>
mov    0x8(%rbx),%rsi
lea    0xeaa(%rip),%rdi
lea    0xea7(%rip),%rcx
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <assert_equal_str@plt>
mov    0x10(%rbx),%rsi
lea    0xeb1(%rip),%rdi
lea    0xeb0(%rip),%rcx
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <assert_equal_str@plt>
mov    0xc(%rsp),%esi
lea    0xeb9(%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    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.test_split_multiple_delims.the_string = [18 x i8] c"fooasdbarasdmagic\00"
@.str = [4 x i8] c"asd\00"
@.str.1 = [4 x i8] c"foo\00"
@.str.2 = [27 x i8] c"test_split_multiple_delims\00"
@.str.3 = [31 x i8] c"Test 1: Strings are not equal.\00"
@.str.4 = [4 x i8] c"bar\00"
@.str.5 = [31 x i8] c"Test 2: Strings are not equal.\00"
@.str.6 = [6 x i8] c"magic\00"
@.str.7 = [30 x i8] c"Test 3: Strings are not equal\00"
@.str.8 = [29 x i8] c"Test 4: Size is not correct.\00"
define void @test_split_multiple_delims() {
%1 = alloca i32
%2 = alloca [18 x i8]
%3 = alloca i8**
store i32 0, i32* %1
%4 = bitcast [18 x i8]* %2 to i8*
%5 = getelementptr inbounds [18 x i8], [18 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 ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 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 ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 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 ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8* %19, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 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 ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 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_multiple_delims.the_string = [18 x i8] c"fooasdbarasdmagic\00"
@.str = [4 x i8] c"asd\00"
@.str.1 = [4 x i8] c"foo\00"
@.str.2 = [27 x i8] c"test_split_multiple_delims\00"
@.str.3 = [31 x i8] c"Test 1: Strings are not equal.\00"
@.str.4 = [4 x i8] c"bar\00"
@.str.5 = [31 x i8] c"Test 2: Strings are not equal.\00"
@.str.6 = [6 x i8] c"magic\00"
@.str.7 = [30 x i8] c"Test 3: Strings are not equal\00"
@.str.8 = [29 x i8] c"Test 4: Size is not correct.\00"
define void @test_split_multiple_delims() {
%1 = alloca i32
%2 = alloca [18 x i8]
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = getelementptr inbounds [18 x i8], [18 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 ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 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 ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 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 ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8* %14, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 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 ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 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
}