#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 */
char const *MemStr_Stripwhite(char *);
char **Mem_Realloc(char **, size_t, char *, int);
char *Mem_Strdup(char const *, char *, int);
int /*<<< orphan*/ free(char *);
char *strtok(char *, char const *);
char **MemStr_Split(const char *string, const char *delimiter, size_t *n) {
  char *buffer = NULL, *tok = NULL, **list = NULL;
  buffer = Mem_Strdup((string),
                      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                      "outputs/2022-01-22/02-19-57/repos/itahsieh/sparx-alpha/"
                      "refs/heads/alpha3.stable/src/memory.c",
                      117);
  *n = 0;
  tok = strtok(buffer, delimiter);
  while (tok) {
    (*n)++;
    list = Mem_Realloc((list), ((*n)) * sizeof(*(list)),
                       "/scratch/repos/new/home/jordi_armengol_estape/"
                       "c-scraper/outputs/2022-01-22/02-19-57/repos/itahsieh/"
                       "sparx-alpha/refs/heads/alpha3.stable/src/memory.c",
                       123);
    list[(*n) - 1] =
        Mem_Strdup((MemStr_Stripwhite(tok)),
                   "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                   "outputs/2022-01-22/02-19-57/repos/itahsieh/sparx-alpha/"
                   "refs/heads/alpha3.stable/src/memory.c",
                   124);
    tok = strtok(NULL, delimiter);
  }
  free(buffer);
  return list;
}


x86 assembly (clang, -O0):
<MemStr_Split>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe79(%rip),%rsi
mov    $0x75,%edx
call   1070 <Mem_Strdup@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1237 <MemStr_Split+0xe7>
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
shl    $0x3,%rsi
lea    0xe20(%rip),%rdx
mov    $0x7b,%ecx
call   1040 <Mem_Realloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <MemStr_Stripwhite@plt>
mov    %rax,%rdi
lea    0xdff(%rip),%rsi
mov    $0x7c,%edx
call   1070 <Mem_Strdup@plt>
mov    %rax,%rdx
mov    -0x30(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rcx),%rcx
sub    $0x1,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1060 <strtok@plt>
mov    %rax,-0x28(%rbp)
jmp    11b1 <MemStr_Split+0x61>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MemStr_Split>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r12
mov    %rsi,%r14
lea    0xe98(%rip),%rsi
mov    $0x75,%edx
call   1070 <Mem_Strdup@plt>
mov    %rax,%r15
movq   $0x0,(%r12)
mov    %rax,%rdi
mov    %r14,%rsi
call   1060 <strtok@plt>
test   %rax,%rax
je     11fc <MemStr_Split+0xac>
mov    %rax,%rbp
xor    %ebx,%ebx
lea    0xe67(%rip),%r13
nopl   0x0(%rax)
mov    (%r12),%rax
lea    0x1(%rax),%rcx
mov    %rcx,(%r12)
lea    0x8(,%rax,8),%rsi
mov    %rbx,%rdi
mov    %r13,%rdx
mov    $0x7b,%ecx
call   1040 <Mem_Realloc@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1050 <MemStr_Stripwhite@plt>
mov    %rax,%rdi
mov    %r13,%rsi
mov    $0x7c,%edx
call   1070 <Mem_Strdup@plt>
mov    (%r12),%rcx
mov    %rax,-0x8(%rbx,%rcx,8)
xor    %edi,%edi
mov    %r14,%rsi
call   1060 <strtok@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    11a0 <MemStr_Split+0x50>
jmp    11fe <MemStr_Split+0xae>
xor    %ebx,%ebx
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [149 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/itahsieh/sparx-alpha/refs/heads/alpha3.stable/src/memory.c\00"
define i8** @MemStr_Split(i8* %0, i8* %1, i64* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8**
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64* %2, i64** %6
store i8* null, i8** %7
store i8* null, i8** %8
store i8** null, i8*** %9
%10 = load i8*, i8** %4
%11 = call i8* @Mem_Strdup(i8* %10, i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str, i64 0, i64 0), i32 117)
store i8* %11, i8** %7
%12 = load i64*, i64** %6
store i64 0, i64* %12
%13 = load i8*, i8** %7
%14 = load i8*, i8** %5
%15 = call i8* @strtok(i8* %13, i8* %14)
store i8* %15, i8** %8
br label %16
16: ; preds = %19, %3
%17 = load i8*, i8** %8
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %38
19: ; preds = %16
%20 = load i64*, i64** %6
%21 = load i64, i64* %20
%22 = add i64 %21, 1
store i64 %22, i64* %20
%23 = load i8**, i8*** %9
%24 = load i64*, i64** %6
%25 = load i64, i64* %24
%26 = mul i64 %25, 8
%27 = call i8** @Mem_Realloc(i8** %23, i64 %26, i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str, i64 0, i64 0), i32 123)
store i8** %27, i8*** %9
%28 = load i8*, i8** %8
%29 = call i8* @MemStr_Stripwhite(i8* %28)
%30 = call i8* @Mem_Strdup(i8* %29, i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str, i64 0, i64 0), i32 124)
%31 = load i8**, i8*** %9
%32 = load i64*, i64** %6
%33 = load i64, i64* %32
%34 = sub i64 %33, 1
%35 = getelementptr inbounds i8*, i8** %31, i64 %34
store i8* %30, i8** %35
%36 = load i8*, i8** %5
%37 = call i8* @strtok(i8* null, i8* %36)
store i8* %37, i8** %8
br label %16
38: ; preds = %16
%39 = load i8*, i8** %7
%40 = call i32 @free(i8* %39)
%41 = load i8**, i8*** %9
ret i8** %41
}

LLVM IR (-O2):
@.str = [149 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/itahsieh/sparx-alpha/refs/heads/alpha3.stable/src/memory.c\00"
define i8** @MemStr_Split(i8* %0, i8* nocapture %1, i64* nocapture %2) {
%4 = tail call i8* @Mem_Strdup(i8* %0, i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str, i64 0, i64 0), i32 117)
store i64 0, i64* %2
%5 = tail call i8* @strtok(i8* %4, i8* %1)
%6 = icmp eq i8* %5, null
br i1 %6, label %21, label %7
7: ; preds = %3, %7
%8 = phi i8** [ %13, %7 ], [ null, %3 ]
%9 = phi i8* [ %19, %7 ], [ %5, %3 ]
%10 = load i64, i64* %2
%11 = add i64 %10, 1
store i64 %11, i64* %2
%12 = shl i64 %11, 3
%13 = tail call i8** @Mem_Realloc(i8** %8, i64 %12, i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str, i64 0, i64 0), i32 123)
%14 = tail call i8* @MemStr_Stripwhite(i8* %9)
%15 = tail call i8* @Mem_Strdup(i8* %14, i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str, i64 0, i64 0), i32 124)
%16 = load i64, i64* %2
%17 = add i64 %16, -1
%18 = getelementptr inbounds i8*, i8** %13, i64 %17
store i8* %15, i8** %18
%19 = tail call i8* @strtok(i8* null, i8* %1)
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %7
21: ; preds = %7, %3
%22 = phi i8** [ null, %3 ], [ %13, %7 ]
%23 = tail call i32 @free(i8* %4)
ret i8** %22
}