// File: /workspace/github_c_makefile_star2_O0/vtereshkov[P]umka-lang/src/umka_common.c
// Function: moduleNameFromPath
void moduleNameFromPath(const Modules *modules, const char *path, char *folder, char *name, int size)
{
    const char *slash = strrchr(path, '/');
    const char *backslash = strrchr(path, '\\');

    if (backslash && (!slash || backslash > slash))
        slash = backslash;

    const char *start = slash ? (slash + 1) : path;

    const char *dot = strrchr(path, '.');
    const char *stop = dot ? dot : (path + strlen(path));

    if (stop <= start)
        modules->error->handler(modules->error->context, "Illegal module path %s", path);

    strncpy(folder, path, (start - path < size - 1) ? (start - path) : (size - 1));
    strncpy(name, start,  (stop - start < size - 1) ? (stop - start) : (size - 1));

    folder[size - 1] = 0;
    name[size - 1] = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq -0x10(%rbp), %rdi
movl $0x2f, %esi
callq 0x3180
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movl $0x5c, %esi
callq 0x3180
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x5103
cmpq $0x0, -0x30(%rbp)
je 0x50fb
movq -0x38(%rbp), %rax
cmpq -0x30(%rbp), %rax
jbe 0x5103
movq -0x38(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x5118
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x5120
movq -0x10(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
movl $0x2e, %esi
callq 0x3180
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x514b
movq -0x48(%rbp), %rax
movq %rax, -0x60(%rbp)
jmp 0x516a
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rdi
callq 0x3120
movq %rax, %rcx
movq -0x68(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x40(%rbp), %rax
ja 0x51a8
movq -0x8(%rbp), %rax
movq 0x4118(%rax), %rax
movq (%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x4118(%rax), %rax
movq 0x20(%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0x1cf13b(%rip), %rsi    # 0x1d42df
movb $0x0, %al
callq *%rcx
movq -0x18(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jge 0x51e2
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x80(%rbp)
jmp 0x51ee
movl -0x24(%rbp), %eax
subl $0x1, %eax
cltq
movq %rax, -0x80(%rbp)
movq -0x70(%rbp), %rsi
movq -0x78(%rbp), %rdi
movq -0x80(%rbp), %rdx
callq 0x3080
movq -0x20(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x50(%rbp), %rax
movq -0x40(%rbp), %rcx
subq %rcx, %rax
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jge 0x5242
movq -0x50(%rbp), %rax
movq -0x40(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x98(%rbp)
jmp 0x5251
movl -0x24(%rbp), %eax
subl $0x1, %eax
cltq
movq %rax, -0x98(%rbp)
movq -0x88(%rbp), %rsi
movq -0x90(%rbp), %rdi
movq -0x98(%rbp), %rdx
callq 0x3080
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movb $0x0, (%rax,%rcx)
movq -0x20(%rbp), %rax
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movb $0x0, (%rax,%rcx)
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)