// File: /workspace/github_c_makefile_star2_O0/c-zhou[P]oatk/misc.c
// Function: parse_pathname
void parse_pathname(char *path, char **_dirname, char **_basename)
{
    if (_dirname) *_dirname = 0;
    if (_basename) *_basename = 0;
    if (path == 0) return;
    int len, i, n_token;
    len = strlen(path);
    if (len == 0) return;
    if (path[len-1] == '/') {
        if (_dirname) *_dirname = strdup(path);
        return;
    }
    char *dirname, *basename, *token;
    dirname = strdup(path);
    token = strtok(dirname, "/");
    n_token = 0;
    do {
        ++n_token;
        basename = token;
        token = strtok(NULL, "/");
    } while (token);
    // necessary for duplicate '/'
    for (i = 0; i < len; ++i)
        if (dirname[i] == '/')
            dirname[i] = 0;
    len = basename - dirname - 1;
    for (i = 0; i < len; ++i)
        if (!dirname[i])
            dirname[i] = '/';
    if (dirname != basename) {
        if (len) {
            // here need to strdup basename
            if (_dirname) *_dirname = dirname;
            if (_basename) *_basename = strdup(basename);
        } else {
            // basename with point to dirname
            if (_dirname) *_dirname = strdup("/");
            if (_basename) *_basename = basename;
        }
    } else {
        if ((strlen(basename)==1 && basename[0] == '.') ||
                (strlen(basename)==2 && 
                 basename[0] == '.' && basename[1] == '.')) {
            if (_dirname) *_dirname = dirname;
        } else {
            if (_dirname) *_dirname = strdup(".");
            if (_basename) *_basename = basename;
        }
    }
    return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x7136
movq -0x10(%rbp), %rax
movq $0x0, (%rax)
cmpq $0x0, -0x18(%rbp)
je 0x7148
movq -0x18(%rbp), %rax
movq $0x0, (%rax)
cmpq $0x0, -0x8(%rbp)
jne 0x7154
jmp 0x7375
movq -0x8(%rbp), %rdi
callq 0x2130
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x716b
jmp 0x7375
movq -0x8(%rbp), %rax
movl -0x1c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2f, %eax
jne 0x71a0
cmpq $0x0, -0x10(%rbp)
je 0x719b
movq -0x8(%rbp), %rdi
callq 0x23a0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
jmp 0x7375
movq -0x8(%rbp), %rdi
callq 0x23a0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x2615(%rip), %rsi      # 0x97cd
callq 0x2330
movq %rax, -0x40(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x38(%rbp)
xorl %eax, %eax
movl %eax, %edi
leaq 0x25e9(%rip), %rsi      # 0x97cd
callq 0x2330
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x71c8
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x722d
movq -0x30(%rbp), %rax
movslq -0x20(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2f, %eax
jne 0x7220
movq -0x30(%rbp), %rax
movslq -0x20(%rbp), %rcx
movb $0x0, (%rax,%rcx)
jmp 0x7222
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x71fb
movq -0x38(%rbp), %rax
movq -0x30(%rbp), %rcx
subq %rcx, %rax
subq $0x1, %rax
movl %eax, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x7275
movq -0x30(%rbp), %rax
movslq -0x20(%rbp), %rcx
cmpb $0x0, (%rax,%rcx)
jne 0x7268
movq -0x30(%rbp), %rax
movslq -0x20(%rbp), %rcx
movb $0x2f, (%rax,%rcx)
jmp 0x726a
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x7246
movq -0x30(%rbp), %rax
cmpq -0x38(%rbp), %rax
je 0x72e9
cmpl $0x0, -0x1c(%rbp)
je 0x72b3
cmpq $0x0, -0x10(%rbp)
je 0x7297
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
cmpq $0x0, -0x18(%rbp)
je 0x72b1
movq -0x38(%rbp), %rdi
callq 0x23a0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
jmp 0x72e4
cmpq $0x0, -0x10(%rbp)
je 0x72d0
leaq 0x250c(%rip), %rdi      # 0x97cd
callq 0x23a0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
cmpq $0x0, -0x18(%rbp)
je 0x72e2
movq -0x38(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
jmp 0x72e4
jmp 0x7373
movq -0x38(%rbp), %rdi
callq 0x2130
cmpq $0x1, %rax
jne 0x7304
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2e, %eax
je 0x732c
movq -0x38(%rbp), %rdi
callq 0x2130
cmpq $0x2, %rax
jne 0x7340
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2e, %eax
jne 0x7340
movq -0x38(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x2e, %eax
jne 0x7340
cmpq $0x0, -0x10(%rbp)
je 0x733e
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
jmp 0x7371
cmpq $0x0, -0x10(%rbp)
je 0x735d
leaq 0x24f7(%rip), %rdi      # 0x9845
callq 0x23a0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
cmpq $0x0, -0x18(%rbp)
je 0x736f
movq -0x38(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
jmp 0x7371
jmp 0x7373
jmp 0x7375
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)