// File: /workspace/github_c_makefile_star2_O1/sasairc[P]clangsay/src/libbenly/src/typestring.c
// Function: c_partition
static
int c_partition(STRING* self, char* const str, char*** dest)
{
    size_t      idx     = 0,
                len     = 0;

    if (self->empty(self))
        return (status = ESTRISEMPTY);
    if (str == NULL)
        return (status = EARGISNULPTR);
    if ((len = strlen(str)) > self->size(self))
        return (status = EOUTOFRANGE);
    if (self->index(self, str, 0, &idx) < 0)
        return (status = ESTRNOTFOUND);

    if ((*dest = (char**)
                malloc(sizeof(char*) * 2)) == NULL) {
#ifdef  LIBRARY_VERBOSE
        print_error();
/* LIBRARY_VERBOSE */
#endif
        return (status = EMEMORYALLOC);
    }

    if ((*(*dest) = (char*)
                malloc(sizeof(char) * (idx + 1))) == NULL) {
#ifdef  LIBRARY_VERBOSE
        print_error();
/* LIBRARY_VERBOSE */
#endif
        status = EMEMORYALLOC; goto ERR;
    } else {
        memcpy(*(*dest), self->c_str(self), idx);
        *(*((*dest)) + idx) = '\0';
    }

    if ((*(*dest + 1) = (char*)
                malloc(sizeof(char) *
                    (self->size(self) - len + idx + 1))) == NULL) {
#ifdef  LIBRARY_VERBOSE
        print_error();
/* LIBRARY_VERBOSE */
#endif
        status = EMEMORYALLOC; goto ERR;
    } else {
        memcpy(*(*dest + 1),
                self->c_str(self) + idx + len,
                self->size(self) - idx - len);
        *(*((*dest + 1)) + self->size(self) - idx - len) = '\0';
    }

    return 0;
    
ERR:
    switch (status) {
        case    EMEMORYALLOC:
            if (*(*dest) != NULL) {
                free(*(*dest));
                *(*dest) = NULL;
            }
            if (*(*dest + 1) != NULL) {
                free(*(*dest + 1));
                *(*dest + 1) = NULL;
            }
            break;
    }
    
    return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r12
movq %rdi, %r14
movq $0x0, (%rsp)
callq *0xa0(%rdi)
testl %eax, %eax
je 0x7816
leaq 0x9a76(%rip), %rax      # 0x11270
movl $0xfffffffc, (%rax)     # imm = 0xFFFFFFFC
movl $0xfffffffc, %ebp       # imm = 0xFFFFFFFC
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %r12, %r12
je 0x7846
movq %r12, %rdi
callq 0x21b0
movq %rax, %r15
movq %r14, %rdi
callq *0x18(%r14)
cmpq %rax, %r15
jbe 0x785a
leaq 0x9a37(%rip), %rax      # 0x11270
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x7805
leaq 0x9a23(%rip), %rax      # 0x11270
movl $0xfffffffb, (%rax)     # imm = 0xFFFFFFFB
movl $0xfffffffb, %ebp       # imm = 0xFFFFFFFB
jmp 0x7805
movq %rsp, %rcx
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq *0x1b8(%r14)
testl %eax, %eax
js 0x7956
movl $0x10, %edi
callq 0x20e0
movq %rax, (%rbx)
testq %rax, %rax
je 0x79be
movq %rax, %r12
movq (%rsp), %rdi
incq %rdi
callq 0x20e0
movq %rax, (%r12)
testq %rax, %rax
je 0x796d
movq %rax, %r13
movq %r14, %rdi
callq *0xc8(%r14)
movq (%rsp), %r12
movq %r13, %rdi
movq %rax, %rsi
movq %r12, %rdx
callq 0x2460
movq (%rbx), %rax
movq (%rax), %rax
movb $0x0, (%rax,%r12)
movq %r14, %rdi
callq *0x18(%r14)
movq (%rsp), %rcx
subq %r15, %rax
leaq (%rax,%rcx), %rdi
incq %rdi
callq 0x20e0
movq (%rbx), %rcx
movq %rax, 0x8(%rcx)
testq %rax, %rax
je 0x796d
movq %r15, %rbp
negq %rbp
movq (%rbx), %rax
movq 0x8(%rax), %r12
movq %r14, %rdi
callq *0xc8(%r14)
addq (%rsp), %rax
movq %r15, %r13
addq %rax, %r13
movq %r14, %rdi
callq *0x18(%r14)
movq (%rsp), %rcx
addq %r15, %rcx
subq %rcx, %rax
movq %r12, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x2460
movq (%rbx), %rax
movq 0x8(%rax), %rbx
movq %r14, %rdi
callq *0x18(%r14)
addq %rbx, %rax
subq (%rsp), %rax
movb $0x0, (%rax,%rbp)
xorl %ebp, %ebp
jmp 0x7805
leaq 0x9913(%rip), %rax      # 0x11270
movl $0xfffffffa, (%rax)     # imm = 0xFFFFFFFA
movl $0xfffffffa, %ebp       # imm = 0xFFFFFFFA
jmp 0x7805
leaq 0x98fc(%rip), %rax      # 0x11270
movl $0xfffffffd, (%rax)     # imm = 0xFFFFFFFD
movq (%rbx), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x7994
callq 0x21a0
movq (%rbx), %rax
movq $0x0, (%rax)
movq (%rbx), %rax
movq 0x8(%rax), %rdi
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rdi, %rdi
je 0x7805
callq 0x21a0
movq (%rbx), %rax
movq $0x0, 0x8(%rax)
jmp 0x7805
leaq 0x98ab(%rip), %rax      # 0x11270
movl $0xfffffffd, (%rax)     # imm = 0xFFFFFFFD
movl $0xfffffffd, %ebp       # imm = 0xFFFFFFFD
jmp 0x7805