// File: /workspace/github_c_makefile_star2_O1/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 0x4566
movq $0x0, (%r14)
jmp 0x4583
leaq 0x53ad(%rip), %rsi      # 0x991a
leaq 0x529a(%rip), %rdx      # 0x980e
movl $0x800b0000, %edi       # imm = 0x800B0000
movl $0x140, %ecx            # imm = 0x140
callq 0x31c0
testq %rbx, %rbx
setne %bpl
je 0x4595
movq $0x0, (%rbx)
jmp 0x45b2
leaq 0x537e(%rip), %rsi      # 0x991a
leaq 0x526b(%rip), %rdx      # 0x980e
movl $0x800b0000, %edi       # imm = 0x800B0000
movl $0x142, %ecx            # imm = 0x142
callq 0x31c0
testq %r15, %r15
je 0x4611
cmpq $0x0, 0x10(%r15)
je 0x4611
movq (%r15), %rax
testq %rax, %rax
je 0x4611
cmpb $0x0, (%rax)
je 0x4611
cmpl $0x0, 0x18(%r15)
je 0x4611
testq %rbx, %rbx
setne %al
testq %r14, %r14
setne %cl
testb %al, %cl
jne 0x4613
testq %rbx, %rbx
setne %al
testq %r14, %r14
setne %bpl
andb %al, %bpl
leaq 0x5321(%rip), %rsi      # 0x991a
leaq 0x520e(%rip), %rdx      # 0x980e
movl $0x800b0000, %edi       # imm = 0x800B0000
movl $0x145, %ecx            # imm = 0x145
callq 0x31c0
jmp 0x4613
xorl %ebp, %ebp
testb %bpl, %bpl
je 0x476f
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 0x4688
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 0x46ae
movl $0x1000, %esi           # imm = 0x1000
movq %r12, %rdi
callq 0x21c0
movq %r12, %rdi
movq %rax, %rsi
callq 0x2200
movq %rax, (%r14)
jmp 0x4731
callq 0x2080
movl (%rax), %edi
leaq 0x5284(%rip), %rsi      # 0x991a
leaq 0x5171(%rip), %rdx      # 0x980e
movl $0x14a, %ecx            # imm = 0x14A
callq 0x32bc
movl %eax, %ebp
jmp 0x476f
movb $0x0, (%rax)
leaq 0x1(%rbp), %r12
movl $0x1, %esi
movq %r12, %rdi
callq 0x2220
movq %rax, (%r14)
testq %rax, %rax
je 0x46fe
movq %rax, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %rbp, %rcx
movq %rax, %r12
callq 0x57c8
addq (%r15), %rbp
movl $0x1000, %esi           # imm = 0x1000
movq %rbp, %rdi
callq 0x21c0
movq %rbp, %rdi
movq %rax, %rsi
callq 0x2200
movq %rax, (%rbx)
jmp 0x472c
leaq 0x10(%rsp), %rdi
movq %rax, %r12
callq 0x5490
callq 0x2080
movl (%rax), %edi
leaq 0x5201(%rip), %rsi      # 0x991a
leaq 0x50ee(%rip), %rdx      # 0x980e
movl $0x155, %ecx            # imm = 0x155
callq 0x32bc
movl %eax, %ebp
testq %r12, %r12
je 0x476f
leaq 0x10(%rsp), %rdi
callq 0x5490
movq (%r14), %rax
testq %rax, %rax
je 0x474c
cmpb $0x0, (%rax)
sete %bpl
jmp 0x474f
movb $0x1, %bpl
orb %bpl, 0xf(%rsp)
je 0x475c
xorb $0x1, %bpl
jmp 0x476f
movq (%rbx), %rax
testq %rax, %rax
je 0x476d
cmpb $0x0, (%rax)
setne %bpl
jmp 0x476f
xorl %ebp, %ebp
andb $0x1, %bpl
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq