// File: /workspace/github_c_makefile_star2_O2/sasairc[P]clangsay/src/libbenly/src/typestring.c
// Function: split
static
size_t split(STRING* self, char* const delim, STRING*** dest)
{
    size_t  y       = 0,
            idx     = 0;

    char*   tok     = NULL,
        *   tmp     = NULL;

    if (delim == NULL) {
        status = EARGISNULPTR; goto ERR;
    }
    if (self->empty(self)) {
        status = ESTRISEMPTY; goto ERR;
    }
    if ((idx = self->count(self, delim)) == 0)
        return 0;
    else
        idx++;

    if ((tmp = (char*)
                malloc(sizeof(char) * (self->size(self) + 1))) == NULL) {
#ifdef  LIBRARY_VERBOSE
        print_error();
/* LIBRARY_VERBOSE */
#endif
        status = EMEMORYALLOC; goto ERR;
    } else {
        memcpy(tmp, self->c_str(self), self->size(self));
        *(tmp + self->size(self)) = '\0';
    }
    if ((*dest = (STRING**)
                malloc(sizeof(STRING*) * idx)) == NULL) {
#ifdef  LIBRARY_VERBOSE
        print_error();
/* LIBRARY_VERBOSE */
#endif
        status = EMEMORYALLOC; goto ERR;
    }
    tok = mbstrtok(tmp, delim);
    while (tok != NULL) {
        if ((*((*dest) + y) = new_string(tok))
                == NULL)
            goto ERR;
        tok = mbstrtok(NULL, delim);
        y++;
    }
    if (tmp != NULL) {
        free(tmp);
        tmp = NULL;
    }

    return idx;

ERR:
    if (tmp != NULL) {
        free(tmp);
        tmp = NULL;
    }
    if (dest != NULL &&
            *dest != NULL) {
        y = 0;
        while (y < idx) {
            self->release(*((*dest) + y));
            *((*dest) + y) = NULL;
            y++;
        }
        free(*dest);
        *dest = NULL;
    }

    return status;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rdi, %r14
testq %rsi, %rsi
je 0x6d24
movq %rsi, %r12
movq %r14, %rdi
callq *0xa0(%r14)
testl %eax, %eax
je 0x6d94
pushq $-0x4
jmp 0x6d26
pushq $-0x5
popq %rbp
xorl %r15d, %r15d
xorl %r13d, %r13d
leaq 0xa544(%rip), %rax      # 0x11278
movl %ebp, (%rax)
movq %r13, %rdi
callq 0x21a0
testq %rbx, %rbx
je 0x6d78
cmpq $0x0, (%rbx)
je 0x6d78
xorl %r12d, %r12d
cmpq %r12, %r15
je 0x6d6c
movq (%rbx), %rax
movq (%rax,%r12,8), %rdi
callq *0x268(%r14)
movq (%rbx), %rax
andq $0x0, (%rax,%r12,8)
incq %r12
jmp 0x6d4c
movq (%rbx), %rdi
callq 0x21a0
andq $0x0, (%rbx)
leaq 0xa4f9(%rip), %rax      # 0x11278
movslq (%rax), %r15
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
movq %r12, %rsi
callq *0x30(%r14)
testq %rax, %rax
je 0x6e50
movq %rax, %r15
incq %r15
movq %r14, %rdi
callq *0x18(%r14)
leaq 0x1(%rax), %rdi
callq 0x20e0
pushq $-0x3
popq %rbp
testq %rax, %rax
je 0x6d2a
movq %rax, %r13
movq %r14, %rdi
callq *0xc8(%r14)
movq %rax, (%rsp)
movq %r14, %rdi
callq *0x18(%r14)
movq %r13, %rdi
movq (%rsp), %rsi
movq %rax, %rdx
callq 0x2470
movq %r14, %rdi
callq *0x18(%r14)
movb $0x0, (%r13,%rax)
leaq (,%r15,8), %rdi
callq 0x20e0
movq %rax, (%rbx)
testq %rax, %rax
je 0x6d2d
movq %r13, %rdi
movq %r12, %rsi
callq 0x8e2d
xorl %ebp, %ebp
testq %rax, %rax
je 0x6e58
movq %rax, %rdi
callq 0x59a4
movq (%rbx), %rcx
movq %rax, (%rcx,%rbp)
testq %rax, %rax
je 0x6d36
xorl %edi, %edi
movq %r12, %rsi
callq 0x8e2d
addq $0x8, %rbp
jmp 0x6e23
xorl %r15d, %r15d
jmp 0x6d82
movq %r13, %rdi
callq 0x21a0
jmp 0x6d82