// File: /workspace/github_c_makefile_star2_O1/sasairc[P]clangsay/src/libbenly/src/typestring.c
// Function: partition
static
int partition(STRING* self, char* const str, STRING*** 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 = (STRING**)
                malloc(sizeof(STRING*) * 2)) == NULL) {
#ifdef  LIBRARY_VERBOSE
        print_error();
/* LIBRARY_VERBOSE */
#endif
        return (status = EMEMORYALLOC);
    }

    if ((*(*dest) = new_string(NULL)) == NULL ||
            (*(*dest + 1) = new_string(NULL)) == NULL) {
        status = EMEMORYALLOC; goto ERR;
    }

    if ((*(*dest))->reserve(*dest, self->capacity(self)) < 0) {
        status = EMEMORYALLOC; goto ERR;
    } else {
        memcpy((*(*dest))->c_str(*(*dest)),
                self->c_str(self), idx);
        *((*(*dest))->c_str(*(*dest)) + idx) = '\0';
        (*(*dest))->reconf(*dest, 0);
    }

    if ((*(*dest + 1))->reserve(*dest + 1, self->capacity(self)) < 0) {
        status = EMEMORYALLOC; goto ERR;
    } else {
        memcpy((*(*dest + 1))->c_str(*(*dest + 1)),
                self->c_str(self) + idx + len,
                self->size(self) - idx - len);
        *((*(*dest + 1))->c_str(*(*dest + 1)) +
                self->size(self) - idx - len) = '\0';
        (*(*dest + 1))->reconf(*dest + 1, 0);
    }

    return 0;

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

    return status;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %rbx
movq %rsi, %r12
movq %rdi, %r14
movq $0x0, 0x8(%rsp)
callq *0xa0(%rdi)
testl %eax, %eax
je 0x758d
leaq 0x9d01(%rip), %rax      # 0x11270
movl $0xfffffffc, (%rax)     # imm = 0xFFFFFFFC
movl $0xfffffffc, %r12d      # imm = 0xFFFFFFFC
movl %r12d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %r12, %r12
je 0x75be
movq %r12, %rdi
callq 0x21b0
movq %rax, %r15
movq %r14, %rdi
callq *0x18(%r14)
cmpq %rax, %r15
jbe 0x75d3
leaq 0x9cc0(%rip), %rax      # 0x11270
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
jmp 0x757b
leaq 0x9cab(%rip), %rax      # 0x11270
movl $0xfffffffb, (%rax)     # imm = 0xFFFFFFFB
movl $0xfffffffb, %r12d      # imm = 0xFFFFFFFB
jmp 0x757b
leaq 0x8(%rsp), %rcx
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq *0x1b8(%r14)
testl %eax, %eax
js 0x774f
movl $0x10, %edi
callq 0x20e0
movq %rax, (%rbx)
testq %rax, %rax
je 0x77b5
xorl %edi, %edi
callq 0x65a4
movq (%rbx), %rcx
movq %rax, (%rcx)
testq %rax, %rax
je 0x7767
xorl %edi, %edi
callq 0x65a4
movq (%rbx), %rcx
movq %rax, 0x8(%rcx)
testq %rax, %rax
je 0x7767
movq (%rbx), %r12
movq (%r12), %rax
movq 0x40(%rax), %r13
movq %r14, %rdi
callq *0x28(%r14)
movq %r12, %rdi
movq %rax, %rsi
callq *%r13
testl %eax, %eax
js 0x7767
movq (%rbx), %rax
movq (%rax), %rdi
callq *0xc8(%rdi)
movq %rax, %r12
movq %r14, %rdi
callq *0xc8(%r14)
movq 0x8(%rsp), %rdx
movq %r12, %rdi
movq %rax, %rsi
callq 0x2460
movq (%rbx), %rax
movq (%rax), %rdi
callq *0xc8(%rdi)
movq 0x8(%rsp), %rcx
movb $0x0, (%rax,%rcx)
movq (%rbx), %rdi
movq (%rdi), %rax
xorl %r12d, %r12d
xorl %esi, %esi
callq *0x38(%rax)
movq (%rbx), %r13
movq 0x8(%r13), %rax
addq $0x8, %r13
movq 0x40(%rax), %rbp
movq %r14, %rdi
callq *0x28(%r14)
movq %r13, %rdi
movq %rax, %rsi
callq *%rbp
testl %eax, %eax
js 0x7767
movq %r15, %r13
negq %r13
movq (%rbx), %rax
movq 0x8(%rax), %rdi
callq *0xc8(%rdi)
movq %rax, 0x10(%rsp)
movq %r14, %rdi
callq *0xc8(%r14)
addq 0x8(%rsp), %rax
movq %r15, %rbp
addq %rax, %rbp
movq %r14, %rdi
callq *0x18(%r14)
movq 0x8(%rsp), %rcx
addq %r15, %rcx
subq %rcx, %rax
movq 0x10(%rsp), %rdi
movq %rbp, %rsi
movq %rax, %rdx
callq 0x2460
movq (%rbx), %rax
movq 0x8(%rax), %rdi
callq *0xc8(%rdi)
movq %rax, %r15
movq %r14, %rdi
callq *0x18(%r14)
addq %r15, %rax
subq 0x8(%rsp), %rax
movb $0x0, (%rax,%r13)
movq (%rbx), %rdi
movq 0x8(%rdi), %rax
addq $0x8, %rdi
xorl %esi, %esi
callq *0x38(%rax)
jmp 0x757b
leaq 0x9b1a(%rip), %rax      # 0x11270
movl $0xfffffffa, (%rax)     # imm = 0xFFFFFFFA
movl $0xfffffffa, %r12d      # imm = 0xFFFFFFFA
jmp 0x757b
leaq 0x9b02(%rip), %r14      # 0x11270
movl $0xfffffffd, (%r14)     # imm = 0xFFFFFFFD
movq (%rbx), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x7786
callq *0x268(%rdi)
movq (%rbx), %rax
movq 0x8(%rax), %rdi
testq %rdi, %rdi
je 0x779b
movq (%rax), %rax
callq *0x268(%rax)
movq (%rbx), %rax
xorl %ecx, %ecx
movq %rcx, 0x8(%rax)
movq (%rbx), %rax
movq %rcx, (%rax)
movq %rcx, (%rbx)
movl (%r14), %r12d
jmp 0x757b
leaq 0x9ab4(%rip), %rax      # 0x11270
movl $0xfffffffd, (%rax)     # imm = 0xFFFFFFFD
movl $0xfffffffd, %r12d      # imm = 0xFFFFFFFD
jmp 0x757b