// File: /workspace/github_c_makefile_star2_O2/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
andq $0x0, (%rsp)
callq *0xa0(%rdi)
testl %eax, %eax
je 0x6b40
leaq 0xa752(%rip), %rax      # 0x11278
movl $0xfffffffc, (%rax)     # imm = 0xFFFFFFFC
pushq $-0x4
popq %rbp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %r12, %r12
je 0x6b6a
movq %r12, %rdi
callq 0x21b0
movq %rax, %r15
movq %r14, %rdi
callq *0x18(%r14)
cmpq %rax, %r15
jbe 0x6b7b
leaq 0xa715(%rip), %rax      # 0x11278
orl $-0x1, (%rax)
pushq $-0x1
jmp 0x6b2e
leaq 0xa707(%rip), %rax      # 0x11278
movl $0xfffffffb, (%rax)     # imm = 0xFFFFFFFB
pushq $-0x5
jmp 0x6b2e
movq %rsp, %rcx
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq *0x1b8(%r14)
testl %eax, %eax
js 0x6c7a
pushq $0x10
popq %rdi
callq 0x20e0
movq %rax, (%rbx)
testq %rax, %rax
je 0x6c8e
movq %rax, %r12
movq (%rsp), %rdi
incq %rdi
callq 0x20e0
movq %rax, (%r12)
testq %rax, %rax
je 0x6ca2
movq %rax, %r13
movq %r14, %rdi
callq *0xc8(%r14)
movq (%rsp), %r12
movq %r13, %rdi
movq %rax, %rsi
movq %r12, %rdx
callq 0x2470
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)
movq (%rbx), %r12
testq %rax, %rax
je 0x6cb1
movq %r15, %rbp
negq %rbp
movq 0x8(%r12), %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 0x2470
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 0x6b2f
leaq 0xa5f7(%rip), %rax      # 0x11278
movl $0xfffffffa, (%rax)     # imm = 0xFFFFFFFA
pushq $-0x6
jmp 0x6b2e
leaq 0xa5e3(%rip), %rax      # 0x11278
movl $0xfffffffd, (%rax)     # imm = 0xFFFFFFFD
pushq $-0x3
jmp 0x6b2e
leaq 0xa5cf(%rip), %rax      # 0x11278
movl $0xfffffffd, (%rax)     # imm = 0xFFFFFFFD
jmp 0x6cd6
movq (%r12), %rdi
leaq 0xa5bc(%rip), %rax      # 0x11278
movl $0xfffffffd, (%rax)     # imm = 0xFFFFFFFD
testq %rdi, %rdi
je 0x6cd6
callq 0x21a0
movq (%rbx), %rax
andq $0x0, (%rax)
movq (%rbx), %r12
movq 0x8(%r12), %rdi
pushq $-0x1
popq %rbp
testq %rdi, %rdi
je 0x6b2f
callq 0x21a0
movq (%rbx), %rax
andq $0x0, 0x8(%rax)
jmp 0x6b2f