// File: /workspace/github_c_makefile_star2_O2/aremmell[P]libsir/src/sirfilecache.c
// Function: sirfile_splitpath
bool _sirfile_splitpath(const sirfile* sf, char** name, char** ext) {
    if (_sir_validptrptr(name))
        *name = NULL;
    if (_sir_validptrptr(ext))
        *ext = NULL;

    bool retval = _sirfile_validate(sf) && _sir_validptrptr(name) && _sir_validptrptr(ext);

    if (retval) {
        char* tmp = strndup(sf->path, strnlen(sf->path, SIR_MAXPATH));
        if (!tmp)
            return _sir_handleerr(errno);

        const char* fullstop = strrchr(tmp, '.');
        if (fullstop && fullstop != tmp) {
            uintptr_t namesize = fullstop - tmp;
            SIR_ASSERT(namesize < SIR_MAXPATH);

            tmp[namesize] = '\0';
            *name = (char*)calloc(namesize + 1, sizeof(char));
            if (!*name) {
                _sir_safefree(&tmp);
                return _sir_handleerr(errno);
            }

            (void)_sir_strncpy(*name, namesize + 1, tmp, namesize);
            *ext = strndup(sf->path + namesize, strnlen(sf->path + namesize, SIR_MAXPATH));
        } else {
            fullstop = NULL;
            *name = strndup(sf->path, strnlen(sf->path, SIR_MAXPATH));
        }

        _sir_safefree(&tmp);
        retval = _sir_validstrnofail(*name) && (!fullstop || _sir_validstrnofail(*ext));
    }

    return retval;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq 0x5681(%rip), %rsi      # 0x991a
movq %r14, %rdi
movl $0x140, %edx            # imm = 0x140
callq 0x4257
testb %al, %al
je 0x42ae
andq $0x0, (%r14)
leaq 0x5665(%rip), %rsi      # 0x991a
movq %rbx, %rdi
movl $0x142, %edx            # imm = 0x142
callq 0x4257
testb %al, %al
je 0x42ca
andq $0x0, (%rbx)
movq %r15, %rdi
callq 0x3c66
testb %al, %al
je 0x43ea
leaq 0x5639(%rip), %rsi      # 0x991a
movq %r14, %rdi
movl $0x145, %edx            # imm = 0x145
callq 0x4257
testb %al, %al
je 0x43ea
leaq 0x561d(%rip), %rsi      # 0x991a
movq %rbx, %rdi
movl $0x145, %edx            # imm = 0x145
callq 0x4257
testb %al, %al
je 0x43ea
movq (%r15), %r12
movl $0x1000, %esi           # imm = 0x1000
movq %r12, %rdi
callq 0x21c0
movq %r12, %rdi
movq %rax, %rsi
callq 0x2200
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x43fb
movq %rax, %r13
pushq $0x2e
popq %rsi
movq %rax, %rdi
callq 0x2180
testq %rax, %rax
sete %cl
movq %rax, %rbp
subq %r13, %rbp
sete %dl
orb %cl, %dl
movb %dl, 0xf(%rsp)
movq %r14, %rcx
jne 0x439b
movb $0x0, (%rax)
leaq 0x1(%rbp), %r12
pushq $0x1
popq %rsi
movq %r12, %rdi
callq 0x2220
movq %rax, (%r14)
testq %rax, %rax
je 0x4417
movq %rax, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %rbp, %rcx
callq 0x5401
addq (%r15), %rbp
movq %rbp, %r12
movq %rbx, %rcx
movl $0x1000, %esi           # imm = 0x1000
movq %r12, %rdi
movq %rcx, %r15
callq 0x21c0
movq %r12, %rdi
movq %rax, %rsi
callq 0x2200
movq %rax, (%r15)
leaq 0x10(%rsp), %rdi
callq 0x5098
movq (%r14), %rax
testq %rax, %rax
je 0x43ea
cmpb $0x0, (%rax)
setne %al
sete %cl
orb %cl, 0xf(%rsp)
jne 0x43ec
movq (%rbx), %rax
testq %rax, %rax
je 0x43ea
cmpb $0x0, (%rax)
setne %al
jmp 0x43ec
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2080
movl (%rax), %edi
leaq 0x5511(%rip), %rsi      # 0x991a
leaq 0x53fe(%rip), %rdx      # 0x980e
movl $0x14a, %ecx            # imm = 0x14A
jmp 0x443b
leaq 0x10(%rsp), %rdi
callq 0x5098
callq 0x2080
movl (%rax), %edi
leaq 0x54eb(%rip), %rsi      # 0x991a
leaq 0x53d8(%rip), %rdx      # 0x980e
movl $0x155, %ecx            # imm = 0x155
callq 0x3231
jmp 0x43ec