// File: /workspace/github_c_makefile_star2_O2/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
andq $0x0, 0x8(%rsp)
callq *0xa0(%rdi)
testl %eax, %eax
je 0x68d0
leaq 0xa9c4(%rip), %rax      # 0x11278
movl $0xfffffffc, (%rax)     # imm = 0xFFFFFFFC
pushq $-0x4
popq %r12
movl %r12d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %r12, %r12
je 0x68fa
movq %r12, %rdi
callq 0x21b0
movq %rax, %r15
movq %r14, %rdi
callq *0x18(%r14)
cmpq %rax, %r15
jbe 0x690b
leaq 0xa985(%rip), %rax      # 0x11278
orl $-0x1, (%rax)
pushq $-0x1
jmp 0x68bc
leaq 0xa977(%rip), %rax      # 0x11278
movl $0xfffffffb, (%rax)     # imm = 0xFFFFFFFB
pushq $-0x5
jmp 0x68bc
leaq 0x8(%rsp), %rcx
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq *0x1b8(%r14)
testl %eax, %eax
js 0x6a85
pushq $0x10
popq %rdi
callq 0x20e0
movq %rax, (%rbx)
testq %rax, %rax
je 0x6ae8
xorl %edi, %edi
callq 0x59a4
movq (%rbx), %rcx
movq %rax, (%rcx)
testq %rax, %rax
je 0x6a99
xorl %edi, %edi
callq 0x59a4
movq (%rbx), %rcx
movq %rax, 0x8(%rcx)
testq %rax, %rax
je 0x6a99
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 0x6a99
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 0x2470
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 0x6a99
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 0x2470
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 0x68be
leaq 0xa7ec(%rip), %rax      # 0x11278
movl $0xfffffffa, (%rax)     # imm = 0xFFFFFFFA
pushq $-0x6
jmp 0x68bc
leaq 0xa7d8(%rip), %r14      # 0x11278
movl $0xfffffffd, (%r14)     # imm = 0xFFFFFFFD
movq (%rbx), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x6abb
callq *0x268(%rdi)
movq (%rbx), %rax
movq 0x8(%rax), %rdi
testq %rdi, %rdi
je 0x6ad0
movq (%rax), %rax
callq *0x268(%rax)
movq (%rbx), %rax
andq $0x0, 0x8(%rax)
movq (%rbx), %rax
andq $0x0, (%rax)
andq $0x0, (%rbx)
movl (%r14), %r12d
jmp 0x68be
leaq 0xa789(%rip), %rax      # 0x11278
movl $0xfffffffd, (%rax)     # imm = 0xFFFFFFFD
pushq $-0x3
jmp 0x68bc