#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 */
scalar_t__ checkPointerError(int /*<<< orphan*/, char *, char *, int, int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ realloc(char **, int);
char *strdup(char *);
char *strtok(char *, char *);
size_t splitString(char ***dest, char *src, char *delimiter) {
  size_t count = 0;
  char *token;
  char *srccpy;
  srccpy = strdup(src);
  *dest = NULL;
  token = strtok(srccpy, delimiter);
  while (token) {
    *dest = (char **)checkPointerError(
        realloc(*dest, sizeof(char **) * (count + 1)), "Can't allocate memory",
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/r78v10a07/gTools/refs/heads/master/gTools/"
        "src/bstring.c",
        33, -1);
    (*dest)[count] = strdup(token);
    token = strtok(NULL, delimiter);
    count++;
  }
  if (srccpy)
    free(srccpy);
  return count;
}


x86 assembly (clang, -O0):
<splitString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1221 <splitString+0xd1>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%rax
add    $0x1,%rax
shl    $0x3,%rax
mov    %eax,%esi
call   1040 <realloc@plt>
mov    %eax,%edi
lea    0xe3d(%rip),%rsi
lea    0xe4c(%rip),%rdx
mov    $0x21,%ecx
mov    $0xffffffff,%r8d
call   1060 <checkPointerError@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rdi
call   1070 <strdup@plt>
mov    %rax,%rdx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x20(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1050 <strtok@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1195 <splitString+0x45>
cmpq   $0x0,-0x30(%rbp)
je     1235 <splitString+0xe5>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<splitString>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r12
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1070 <strdup@plt>
movq   $0x0,(%rbx)
mov    %rax,(%rsp)
mov    %rax,%rdi
mov    %r12,%rsi
call   1050 <strtok@plt>
test   %rax,%rax
je     1209 <splitString+0xb9>
mov    %rax,%r13
mov    $0x8,%ebp
mov    %rbx,0x8(%rsp)
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    0x8(%rsp),%r15
mov    (%r15),%rdi
lea    0x1(%rbx),%rax
mov    %rax,0x10(%rsp)
mov    %ebp,%esi
call   1040 <realloc@plt>
mov    %eax,%edi
lea    0xe3f(%rip),%rsi
lea    0xe4e(%rip),%rdx
mov    $0x21,%ecx
mov    $0xffffffff,%r8d
call   1060 <checkPointerError@plt>
mov    %rax,%r14
mov    %rax,(%r15)
mov    0x10(%rsp),%r15
mov    %r13,%rdi
call   1070 <strdup@plt>
mov    %rax,(%r14,%rbx,8)
xor    %edi,%edi
mov    %r12,%rsi
call   1050 <strtok@plt>
mov    %rax,%r13
add    $0x8,%ebp
mov    %r15,%rbx
test   %rax,%rax
jne    11a0 <splitString+0x50>
jmp    120c <splitString+0xbc>
xor    %r15d,%r15d
mov    (%rsp),%rdi
test   %rdi,%rdi
je     121a <splitString+0xca>
call   1030 <free@plt>
mov    %r15,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Can't allocate memory\00"
@.str.1 = [146 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/r78v10a07/gTools/refs/heads/master/gTools/src/bstring.c\00"
define i64 @splitString(i8*** %0, i8* %1, i8* %2) {
%4 = alloca i8***
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i8*
store i8*** %0, i8**** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i64 0, i64* %7
%10 = load i8*, i8** %5
%11 = call i8* @strdup(i8* %10)
store i8* %11, i8** %9
%12 = load i8***, i8**** %4
store i8** null, i8*** %12
%13 = load i8*, i8** %9
%14 = load i8*, i8** %6
%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 %40
19: ; preds = %16
%20 = load i8***, i8**** %4
%21 = load i8**, i8*** %20
%22 = load i64, i64* %7
%23 = add i64 %22, 1
%24 = mul i64 8, %23
%25 = trunc i64 %24 to i32
%26 = call i32 @realloc(i8** %21, i32 %25)
%27 = call i64 @checkPointerError(i32 %26, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str.1, i64 0, i64 0), i32 33, i32 -1)
%28 = inttoptr i64 %27 to i8**
%29 = load i8***, i8**** %4
store i8** %28, i8*** %29
%30 = load i8*, i8** %8
%31 = call i8* @strdup(i8* %30)
%32 = load i8***, i8**** %4
%33 = load i8**, i8*** %32
%34 = load i64, i64* %7
%35 = getelementptr inbounds i8*, i8** %33, i64 %34
store i8* %31, i8** %35
%36 = load i8*, i8** %6
%37 = call i8* @strtok(i8* null, i8* %36)
store i8* %37, i8** %8
%38 = load i64, i64* %7
%39 = add i64 %38, 1
store i64 %39, i64* %7
br label %16
40: ; preds = %16
%41 = load i8*, i8** %9
%42 = icmp ne i8* %41, null
br i1 %42, label %43, label %46
43: ; preds = %40
%44 = load i8*, i8** %9
%45 = call i32 @free(i8* %44)
br label %46
46: ; preds = %43, %40
%47 = load i64, i64* %7
ret i64 %47
}

LLVM IR (-O2):
@.str = [22 x i8] c"Can't allocate memory\00"
@.str.1 = [146 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/r78v10a07/gTools/refs/heads/master/gTools/src/bstring.c\00"
define i64 @splitString(i8*** nocapture %0, i8* nocapture %1, i8* nocapture %2) {
%4 = tail call i8* @strdup(i8* %1)
store i8** null, i8*** %0
%5 = tail call i8* @strtok(i8* %4, i8* %2)
%6 = icmp eq i8* %5, null
br i1 %6, label %21, label %7
7: ; preds = %3, %7
%8 = phi i64 [ %11, %7 ], [ 0, %3 ]
%9 = phi i8* [ %19, %7 ], [ %5, %3 ]
%10 = load i8**, i8*** %0
%11 = add i64 %8, 1
%12 = trunc i64 %11 to i32
%13 = shl i32 %12, 3
%14 = tail call i32 @realloc(i8** %10, i32 %13)
%15 = tail call i64 @checkPointerError(i32 %14, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str.1, i64 0, i64 0), i32 33, i32 -1)
%16 = inttoptr i64 %15 to i8**
store i8** %16, i8*** %0
%17 = tail call i8* @strdup(i8* %9)
%18 = getelementptr inbounds i8*, i8** %16, i64 %8
store i8* %17, i8** %18
%19 = tail call i8* @strtok(i8* null, i8* %2)
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %7
21: ; preds = %7, %3
%22 = phi i64 [ 0, %3 ], [ %11, %7 ]
%23 = icmp eq i8* %4, null
br i1 %23, label %26, label %24
24: ; preds = %21
%25 = tail call i32 @free(i8* %4)
br label %26
26: ; preds = %24, %21
ret i64 %22
}