int test_split(void) {
  char **result;
  int size;
  const char *test_1 = "\nHello World\n ";
  result = split(test_1, " ", &size);
  do {
    if (!(strcmp(result[0], "Hello") == 0)) {
      printf("%sERROR!%s [%s:%d] %s %sFAILED!%s\n", "\x1B[1;31m", "\x1B[1;0m",
             __func__, 163, "strcmp(result[0], \"Hello\") == 0", "\x1B[1;31m",
             "\x1B[1;0m");
      return -1;
    }
  } while (0);
  do {
    if (!(strcmp(result[1], "World") == 0)) {
      printf("%sERROR!%s [%s:%d] %s %sFAILED!%s\n", "\x1B[1;31m", "\x1B[1;0m",
             __func__, 164, "strcmp(result[1], \"World\") == 0", "\x1B[1;31m",
             "\x1B[1;0m");
      return -1;
    }
  } while (0);
  do {
    if (!(size == 2)) {
      printf("%sERROR!%s [%s:%d] %s %sFAILED!%s\n", "\x1B[1;31m", "\x1B[1;0m",
             __func__, 165, "size == 2", "\x1B[1;31m", "\x1B[1;0m");
      return -1;
    }
  } while (0);
  free(result[0]);
  free(result[1]);
  free(result);
  return 0;
}


x86 assembly (clang, -O0):
<test_split>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xeb1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xeaf(%rip),%rsi
lea    -0x14(%rbp),%rdx
mov    $0x0,%al
call   1050 <split@plt>
cltq
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe92(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
je     11d6 <test_split+0x96>
lea    0xe83(%rip),%rdi
lea    0xe9f(%rip),%r10
lea    0xea0(%rip),%rax
lea    0xea0(%rip),%rcx
mov    $0xa3,%r8d
lea    0xe9e(%rip),%r9
mov    %r10,%rsi
mov    %rax,%rdx
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12d5 <test_split+0x195>
jmp    11db <test_split+0x9b>
jmp    11e0 <test_split+0xa0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe83(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
je     1248 <test_split+0x108>
lea    0xe11(%rip),%rdi
lea    0xe2d(%rip),%r10
lea    0xe2e(%rip),%rax
lea    0xe2e(%rip),%rcx
mov    $0xa4,%r8d
lea    0xe52(%rip),%r9
mov    %r10,%rsi
mov    %rax,%rdx
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12d5 <test_split+0x195>
jmp    124d <test_split+0x10d>
jmp    1252 <test_split+0x112>
cmpl   $0x2,-0x14(%rbp)
je     12a7 <test_split+0x167>
lea    0xdb2(%rip),%rdi
lea    0xdce(%rip),%r10
lea    0xdcf(%rip),%rax
lea    0xdcf(%rip),%rcx
mov    $0xa5,%r8d
lea    0xe13(%rip),%r9
mov    %r10,%rsi
mov    %rax,%rdx
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12d5 <test_split+0x195>
jmp    12ac <test_split+0x16c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_split>:
push   %r14
push   %rbx
push   %rax
lea    0xeb5(%rip),%rdi
lea    0xebb(%rip),%rsi
lea    0x4(%rsp),%rdx
xor    %eax,%eax
call   1050 <split@plt>
movslq %eax,%rbx
mov    (%rbx),%r14
lea    0xea4(%rip),%rsi
mov    %r14,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
je     11a5 <test_split+0x65>
lea    0xec2(%rip),%rdx
lea    0xeb3(%rip),%rsi
lea    0xe89(%rip),%rdi
lea    0xeb4(%rip),%rcx
lea    0xeb8(%rip),%r9
mov    $0xa3,%r8d
jmp    1231 <test_split+0xf1>
mov    0x8(%rbx),%rdi
lea    0xec2(%rip),%rsi
call   1060 <strcmp@plt>
test   %eax,%eax
je     11e4 <test_split+0xa4>
lea    0xe80(%rip),%rdx
lea    0xe71(%rip),%rsi
lea    0xe47(%rip),%rdi
lea    0xe72(%rip),%rcx
lea    0xe9c(%rip),%r9
mov    $0xa4,%r8d
jmp    1231 <test_split+0xf1>
cmpl   $0x2,0x4(%rsp)
jne    1208 <test_split+0xc8>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x8(%rbx),%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
jmp    1243 <test_split+0x103>
lea    0xe31(%rip),%rdx
lea    0xe22(%rip),%rsi
lea    0xdf8(%rip),%rdi
lea    0xe23(%rip),%rcx
lea    0xe6d(%rip),%r9
mov    $0xa5,%r8d
xor    %eax,%eax
push   %rdx
push   %rsi
call   1040 <printf@plt>
add    $0x10,%rsp
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [15 x i8] c"\0AHello World\0A \00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [6 x i8] c"Hello\00"
@.str.3 = [35 x i8] c"%sERROR!%s [%s:%d] %s %sFAILED!%s\0A\00"
@.str.4 = [8 x i8] c"\1B[1;31m\00"
@.str.5 = [7 x i8] c"\1B[1;0m\00"
@__func__.test_split = [11 x i8] c"test_split\00"
@.str.6 = [32 x i8] c"strcmp(result[0], \22Hello\22) == 0\00"
@.str.7 = [6 x i8] c"World\00"
@.str.8 = [32 x i8] c"strcmp(result[1], \22World\22) == 0\00"
@.str.9 = [10 x i8] c"size == 2\00"
define i32 @test_split() {
%1 = alloca i32
%2 = alloca i8**
%3 = alloca i32
%4 = alloca i8*
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8** %4
%5 = load i8*, i8** %4
%6 = call i32 (i8*, i8*, i32*, ...) bitcast (i32 (...)* @split to i32 (i8*, i8*, i32*, ...)*)(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%7 = sext i32 %6 to i64
%8 = inttoptr i64 %7 to i8**
store i8** %8, i8*** %2
br label %9
9: ; preds = %0
%10 = load i8**, i8*** %2
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
%13 = call i32 @strcmp(i8* %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %9
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__func__.test_split, i64 0, i64 0), i32 163, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %1
br label %44
17: ; preds = %9
br label %18
18: ; preds = %17
br label %19
19: ; preds = %18
%20 = load i8**, i8*** %2
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @strcmp(i8* %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%24 = icmp eq i32 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %19
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__func__.test_split, i64 0, i64 0), i32 164, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %1
br label %44
27: ; preds = %19
br label %28
28: ; preds = %27
br label %29
29: ; preds = %28
%30 = load i32, i32* %3
%31 = icmp eq i32 %30, 2
br i1 %31, label %34, label %32
32: ; preds = %29
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__func__.test_split, i64 0, i64 0), i32 165, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %1
br label %44
34: ; preds = %29
br label %35
35: ; preds = %34
%36 = load i8**, i8*** %2
%37 = getelementptr inbounds i8*, i8** %36, i64 0
%38 = load i8*, i8** %37
%39 = load i8**, i8*** %2
%40 = getelementptr inbounds i8*, i8** %39, i64 1
%41 = load i8*, i8** %40
%42 = load i8**, i8*** %2
%43 = bitcast i8** %42 to i8*
store i32 0, i32* %1
br label %44
44: ; preds = %35, %32, %25, %15
%45 = load i32, i32* %1
ret i32 %45
}

LLVM IR (-O2):
@.str = [15 x i8] c"\0AHello World\0A \00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [6 x i8] c"Hello\00"
@.str.3 = [35 x i8] c"%sERROR!%s [%s:%d] %s %sFAILED!%s\0A\00"
@.str.4 = [8 x i8] c"\1B[1;31m\00"
@.str.5 = [7 x i8] c"\1B[1;0m\00"
@__func__.test_split = [11 x i8] c"test_split\00"
@.str.6 = [32 x i8] c"strcmp(result[0], \22Hello\22) == 0\00"
@.str.7 = [6 x i8] c"World\00"
@.str.8 = [32 x i8] c"strcmp(result[1], \22World\22) == 0\00"
@.str.9 = [10 x i8] c"size == 2\00"
define i32 @test_split() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 (i8*, i8*, i32*, ...) bitcast (i32 (...)* @split to i32 (i8*, i8*, i32*, ...)*)(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%4 = sext i32 %3 to i64
%5 = inttoptr i64 %4 to i8**
%6 = load i8*, i8** %5
%7 = call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__func__.test_split, i64 0, i64 0), i32 163, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %26
11: ; preds = %0
%12 = getelementptr inbounds i8*, i8** %5, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @strcmp(i8* dereferenceable(1) %13, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %11
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__func__.test_split, i64 0, i64 0), i32 164, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %26
18: ; preds = %11
%19 = load i32, i32* %1
%20 = icmp eq i32 %19, 2
br i1 %20, label %23, label %21
21: ; preds = %18
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__func__.test_split, i64 0, i64 0), i32 165, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %26
23: ; preds = %18
%24 = load i8*, i8** %12
%25 = inttoptr i64 %4 to i8*
br label %26
26: ; preds = %23, %21, %16, %9
%27 = phi i32 [ 0, %23 ], [ -1, %21 ], [ -1, %16 ], [ -1, %9 ]
ret i32 %27
}