// File: /workspace/github_c_makefile_star2_O3/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
testq %rsi, %rsi
je 0x4563
movq $0x0, (%r14)
jmp 0x4580
leaq 0x53b0(%rip), %rsi      # 0x991a
leaq 0x529d(%rip), %rdx      # 0x980e
movl $0x800b0000, %edi       # imm = 0x800B0000
movl $0x140, %ecx            # imm = 0x140
callq 0x31c0
testq %rbx, %rbx
je 0x458e
movq $0x0, (%rbx)
jmp 0x45ab
leaq 0x5385(%rip), %rsi      # 0x991a
leaq 0x5272(%rip), %rdx      # 0x980e
movl $0x800b0000, %edi       # imm = 0x800B0000
movl $0x142, %ecx            # imm = 0x142
callq 0x31c0
testq %r15, %r15
je 0x4671
cmpq $0x0, 0x10(%r15)
je 0x4671
movq (%r15), %r12
testq %r12, %r12
je 0x4671
cmpb $0x0, (%r12)
je 0x4671
cmpl $0x0, 0x18(%r15)
je 0x4671
testq %r14, %r14
je 0x4654
testq %rbx, %rbx
je 0x4654
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 0x4682
movq %rax, %r13
movq %rax, %rdi
movl $0x2e, %esi
callq 0x2180
testq %rax, %rax
sete %cl
movq %rax, %rbp
subq %r13, %rbp
sete %dl
orb %cl, %dl
movb %dl, 0xf(%rsp)
je 0x46a1
movl $0x1000, %esi           # imm = 0x1000
movq %r12, %rdi
callq 0x21c0
movq %r12, %rdi
movq %rax, %rsi
callq 0x2200
movq %rax, (%r14)
jmp 0x46ec
leaq 0x52bf(%rip), %rsi      # 0x991a
leaq 0x51ac(%rip), %rdx      # 0x980e
movl $0x800b0000, %edi       # imm = 0x800B0000
movl $0x145, %ecx            # imm = 0x145
callq 0x31c0
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 0x528a(%rip), %rsi      # 0x991a
leaq 0x5177(%rip), %rdx      # 0x980e
movl $0x14a, %ecx            # imm = 0x14A
jmp 0x4750
movb $0x0, (%rax)
leaq 0x1(%rbp), %r12
movl $0x1, %esi
movq %r12, %rdi
callq 0x2220
movq %rax, (%r14)
testq %rax, %rax
je 0x472c
movq %rax, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %rbp, %rcx
callq 0x56fc
addq (%r15), %rbp
movl $0x1000, %esi           # imm = 0x1000
movq %rbp, %rdi
callq 0x21c0
movq %rbp, %rdi
movq %rax, %rsi
callq 0x2200
movq %rax, (%rbx)
leaq 0x10(%rsp), %rdi
callq 0x53e0
movq (%r14), %rax
testq %rax, %rax
je 0x4671
cmpb $0x0, (%rax)
setne %al
sete %cl
orb %cl, 0xf(%rsp)
jne 0x4673
movq (%rbx), %rax
testq %rax, %rax
je 0x4671
cmpb $0x0, (%rax)
setne %al
jmp 0x4673
leaq 0x10(%rsp), %rdi
callq 0x53e0
callq 0x2080
movl (%rax), %edi
leaq 0x51d6(%rip), %rsi      # 0x991a
leaq 0x50c3(%rip), %rdx      # 0x980e
movl $0x155, %ecx            # imm = 0x155
callq 0x32bc
jmp 0x4673