#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*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char *);
char *realloc(char *, size_t);
char *trim_whitespace(char *);
char **split_create(const char *src, char token) {
  int index = 0;
  size_t list_size = 0;
  char buf[512];
  char *list = NULL;
  list_size += 4;
  list = realloc(list, list_size);
  while (*src != 0) {
    memset(buf, 0, 512);
    index = 0;
    while (*src != token && *src != 0) {
      buf[index++] = *src;
      src++;
    }
    src++;
    printf("[%s]\n", trim_whitespace(buf));
  }
  return NULL;
}


x86 assembly (clang, -O0):
<split_create>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movl   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x228(%rbp)
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    -0x228(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <realloc@plt>
mov    %rax,-0x228(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1254 <split_create+0x114>
lea    -0x220(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1040 <memset@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
movsbl -0x9(%rbp),%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x229(%rbp)
je     11ea <split_create+0xaa>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x229(%rbp)
mov    -0x229(%rbp),%al
test   $0x1,%al
jne    11fd <split_create+0xbd>
jmp    1228 <split_create+0xe8>
mov    -0x8(%rbp),%rax
mov    (%rax),%cl
mov    -0x10(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x10(%rbp)
cltq
mov    %cl,-0x220(%rbp,%rax,1)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11bc <split_create+0x7c>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
lea    -0x220(%rbp),%rdi
call   1050 <trim_whitespace@plt>
mov    %rax,%rsi
lea    0xdb6(%rip),%rdi
call   1030 <printf@plt>
jmp    1192 <split_create+0x52>
xor    %eax,%eax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<split_create>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x200,%rsp
cmpb   $0x0,(%rdi)
je     11b9 <split_create+0x89>
mov    %esi,%ebp
mov    %rdi,%rbx
mov    %rsp,%r14
lea    0xead(%rip),%r15
jmp    1180 <split_create+0x50>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0x1(%rbx),%r12
mov    %r14,%rdi
call   1050 <trim_whitespace@plt>
mov    %r15,%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
cmpb   $0x0,0x1(%rbx)
mov    %r12,%rbx
je     11b9 <split_create+0x89>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1040 <memset@plt>
mov    (%rbx),%al
cmp    %bpl,%al
je     1160 <split_create+0x30>
test   %al,%al
je     1160 <split_create+0x30>
mov    %r14,%rcx
nopl   (%rax)
mov    %al,(%rcx)
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
cmp    %bpl,%al
je     1160 <split_create+0x30>
add    $0x1,%rcx
test   %al,%al
jne    11a0 <split_create+0x70>
jmp    1160 <split_create+0x30>
xor    %eax,%eax
add    $0x200,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"[%s]\0A\00"
define i8** @split_create(i8* %0, i8 signext %1) {
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i32
%6 = alloca i64
%7 = alloca [512 x i8]
%8 = alloca i8*
store i8* %0, i8** %3
store i8 %1, i8* %4
store i32 0, i32* %5
store i64 0, i64* %6
store i8* null, i8** %8
%9 = load i64, i64* %6
%10 = add i64 %9, 4
store i64 %10, i64* %6
%11 = load i8*, i8** %8
%12 = load i64, i64* %6
%13 = call i8* @realloc(i8* %11, i64 %12)
store i8* %13, i8** %8
br label %14
14: ; preds = %45, %2
%15 = load i8*, i8** %3
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %51
19: ; preds = %14
%20 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%21 = call i32 @memset(i8* %20, i32 0, i32 512)
store i32 0, i32* %5
br label %22
22: ; preds = %36, %19
%23 = load i8*, i8** %3
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = load i8, i8* %4
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %25, %27
br i1 %28, label %29, label %34
29: ; preds = %22
%30 = load i8*, i8** %3
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 0
br label %34
34: ; preds = %29, %22
%35 = phi i1 [ false, %22 ], [ %33, %29 ]
br i1 %35, label %36, label %45
36: ; preds = %34
%37 = load i8*, i8** %3
%38 = load i8, i8* %37
%39 = load i32, i32* %5
%40 = add nsw i32 %39, 1
store i32 %40, i32* %5
%41 = sext i32 %39 to i64
%42 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 %41
store i8 %38, i8* %42
%43 = load i8*, i8** %3
%44 = getelementptr inbounds i8, i8* %43, i32 1
store i8* %44, i8** %3
br label %22
45: ; preds = %34
%46 = load i8*, i8** %3
%47 = getelementptr inbounds i8, i8* %46, i32 1
store i8* %47, i8** %3
%48 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%49 = call i8* @trim_whitespace(i8* %48)
%50 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %49)
br label %14
51: ; preds = %14
ret i8** null
}

LLVM IR (-O2):
@.str = [6 x i8] c"[%s]\0A\00"
define noalias i8** @split_create(i8* nocapture %0, i8 signext %1) {
%3 = alloca [512 x i8]
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 0
br i1 %6, label %32, label %7
7: ; preds = %2, %25
%8 = phi i8* [ %27, %25 ], [ %0, %2 ]
%9 = call i32 @memset(i8* %4, i32 0, i32 512)
%10 = load i8, i8* %8
%11 = icmp eq i8 %10, %1
%12 = icmp eq i8 %10, 0
%13 = or i1 %11, %12
br i1 %13, label %25, label %14
14: ; preds = %7, %14
%15 = phi i64 [ %18, %14 ], [ 0, %7 ]
%16 = phi i8 [ %21, %14 ], [ %10, %7 ]
%17 = phi i8* [ %20, %14 ], [ %8, %7 ]
%18 = add nuw i64 %15, 1
%19 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 %15
store i8 %16, i8* %19
%20 = getelementptr inbounds i8, i8* %17, i64 1
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, %1
%23 = icmp eq i8 %21, 0
%24 = or i1 %22, %23
br i1 %24, label %25, label %14
25: ; preds = %14, %7
%26 = phi i8* [ %8, %7 ], [ %20, %14 ]
%27 = getelementptr inbounds i8, i8* %26, i64 1
%28 = call i8* @trim_whitespace(i8* %4)
%29 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %28)
%30 = load i8, i8* %27
%31 = icmp eq i8 %30, 0
br i1 %31, label %32, label %7
32: ; preds = %25, %2
ret i8** null
}