// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x68, %rsp
movq %rdi, 0x58(%rsp)
movq %rsi, 0x50(%rsp)
movq %rdx, 0x48(%rsp)
movq 0x50(%rsp), %rdi
movl $0x1, %esi
leaq 0xade3(%rip), %rdx      # 0x10aa7
leaq 0xabb2(%rip), %rcx      # 0x1087d
movl $0x140, %r8d            # imm = 0x140
callq 0x5c30
testb $0x1, %al
jne 0x5cdc
jmp 0x5ce8
movq 0x50(%rsp), %rax
movq $0x0, (%rax)
movq 0x48(%rsp), %rdi
movl $0x1, %esi
leaq 0xadae(%rip), %rdx      # 0x10aa7
leaq 0xab7d(%rip), %rcx      # 0x1087d
movl $0x142, %r8d            # imm = 0x142
callq 0x5c30
testb $0x1, %al
jne 0x5d11
jmp 0x5d1d
movq 0x48(%rsp), %rax
movq $0x0, (%rax)
movq 0x58(%rsp), %rdi
callq 0x5100
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x27(%rsp)
jne 0x5d36
jmp 0x5d8f
movq 0x50(%rsp), %rdi
movl $0x1, %esi
leaq 0xad60(%rip), %rdx      # 0x10aa7
leaq 0xab2f(%rip), %rcx      # 0x1087d
movl $0x145, %r8d            # imm = 0x145
callq 0x5c30
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x27(%rsp)
jne 0x5d68
jmp 0x5d8f
movq 0x48(%rsp), %rdi
movl $0x1, %esi
leaq 0xad2e(%rip), %rdx      # 0x10aa7
leaq 0xaafd(%rip), %rcx      # 0x1087d
movl $0x145, %r8d            # imm = 0x145
callq 0x5c30
movb %al, 0x27(%rsp)
movb 0x27(%rsp), %al
andb $0x1, %al
movb %al, 0x47(%rsp)
testb $0x1, 0x47(%rsp)
je 0x5fda
movq 0x58(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x58(%rsp), %rax
movq (%rax), %rdi
movl $0x1000, %esi           # imm = 0x1000
callq 0x21d0
movq 0x18(%rsp), %rdi
movq %rax, %rsi
callq 0x2210
movq %rax, 0x38(%rsp)
cmpq $0x0, 0x38(%rsp)
jne 0x5e07
callq 0x2070
movl (%rax), %edi
leaq 0xacbc(%rip), %rsi      # 0x10aa7
leaq 0xaa8b(%rip), %rdx      # 0x1087d
movl $0x14a, %ecx            # imm = 0x14A
callq 0x3c00
andb $0x1, %al
movb %al, 0x67(%rsp)
jmp 0x5fe4
movq 0x38(%rsp), %rdi
movl $0x2e, %esi
callq 0x2190
movq %rax, 0x30(%rsp)
cmpq $0x0, 0x30(%rsp)
je 0x5f17
movq 0x30(%rsp), %rax
cmpq 0x38(%rsp), %rax
je 0x5f17
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
subq %rcx, %rax
movq %rax, 0x28(%rsp)
movq 0x38(%rsp), %rax
movq 0x28(%rsp), %rcx
movb $0x0, (%rax,%rcx)
movq 0x28(%rsp), %rdi
addq $0x1, %rdi
movl $0x1, %esi
callq 0x2230
movq %rax, %rcx
movq 0x50(%rsp), %rax
movq %rcx, (%rax)
movq 0x50(%rsp), %rax
cmpq $0x0, (%rax)
jne 0x5eb4
leaq 0x38(%rsp), %rdi
callq 0x7910
callq 0x2070
movl (%rax), %edi
leaq 0xac0f(%rip), %rsi      # 0x10aa7
leaq 0xa9de(%rip), %rdx      # 0x1087d
movl $0x155, %ecx            # imm = 0x155
callq 0x3c00
andb $0x1, %al
movb %al, 0x67(%rsp)
jmp 0x5fe4
movq 0x50(%rsp), %rax
movq (%rax), %rdi
movq 0x28(%rsp), %rsi
addq $0x1, %rsi
movq 0x38(%rsp), %rdx
movq 0x28(%rsp), %rcx
callq 0x83d0
movq 0x58(%rsp), %rax
movq (%rax), %rax
addq 0x28(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x58(%rsp), %rax
movq (%rax), %rdi
addq 0x28(%rsp), %rdi
movl $0x1000, %esi           # imm = 0x1000
callq 0x21d0
movq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x2210
movq %rax, %rcx
movq 0x48(%rsp), %rax
movq %rcx, (%rax)
jmp 0x5f57
movq $0x0, 0x30(%rsp)
movq 0x58(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x8(%rsp)
movq 0x58(%rsp), %rax
movq (%rax), %rdi
movl $0x1000, %esi           # imm = 0x1000
callq 0x21d0
movq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x2210
movq %rax, %rcx
movq 0x50(%rsp), %rax
movq %rcx, (%rax)
leaq 0x38(%rsp), %rdi
callq 0x7910
movq 0x50(%rsp), %rax
movq (%rax), %rdi
xorl %esi, %esi
leaq 0xab35(%rip), %rdx      # 0x10aa7
leaq 0xa904(%rip), %rcx      # 0x1087d
movl $0x160, %r8d            # imm = 0x160
callq 0x4f70
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x7(%rsp)
jne 0x5f93
jmp 0x5fd0
movb $0x1, %al
cmpq $0x0, 0x30(%rsp)
movb %al, 0x6(%rsp)
je 0x5fc8
movq 0x48(%rsp), %rax
movq (%rax), %rdi
xorl %esi, %esi
leaq 0xaaf5(%rip), %rdx      # 0x10aa7
leaq 0xa8c4(%rip), %rcx      # 0x1087d
movl $0x160, %r8d            # imm = 0x160
callq 0x4f70
movb %al, 0x6(%rsp)
movb 0x6(%rsp), %al
movb %al, 0x7(%rsp)
movb 0x7(%rsp), %al
andb $0x1, %al
movb %al, 0x47(%rsp)
movb 0x47(%rsp), %al
andb $0x1, %al
movb %al, 0x67(%rsp)
movb 0x67(%rsp), %al
andb $0x1, %al
addq $0x68, %rsp
retq
nop