// File: corecodec[P]coremake/coremake.c
// Function: reader_filename
void reader_filename(reader* p, int dst_flags)
{
    assert((dst_flags & FLAG_PATH_MASK) != FLAG_PATH_NOT_PATH);
    if (stricmp(p->token,".")==0)
        p->token[0]='\0';

    if ((dst_flags & FLAG_PATH_SET_ABSOLUTE)==0 && ((p->token[0] != '$' || p->token[1] != '(') && p->token[0] != '/'))
    {
        char* end = getfilename(p->filename);
        while (p->token[0]=='.' && p->token[1]=='.' && end != p->filename)
        {
            char* i;
            for (i=end-1;i>p->filename;--i)
                if (i[-1]=='/')
                    break;

            strdel(p->token,p->token+2);
            if (p->token[0]=='/')
                strdel(p->token,p->token+1);

            end = i;
        }
        strins(p->token,p->filename,end);
        p->r.flags &= ~FLAG_PATH_MASK;
        p->r.flags |= p->r.filename_kind & FLAG_PATH_MASK;
        // adjust the pathes according to their modifier
        if ((dst_flags & FLAG_PATH_MASK) != (p->r.filename_kind & FLAG_PATH_MASK))
        {
            if (coremake_root_len || (dst_flags & FLAG_PATH_MASK) != FLAG_PATH_COREMAKE) // keep the full path to get the coremake_root
                reader_strip_abs(p);

            switch (dst_flags & FLAG_PATH_MASK)
            {
            case FLAG_PATH_GENERATED:
                strins(p->token,proj_root,NULL);
                break;
            case FLAG_PATH_COREMAKE:
                strins(p->token,coremake_root,NULL);
                break;
            case FLAG_PATH_SOURCE:
                strins(p->token,src_root,NULL);
                break;
            }
            p->r.flags &= ~FLAG_PATH_MASK;
            p->r.flags |= (dst_flags & FLAG_PATH_MASK);
        }
    }
    pathunix(p->token);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl -0xc(%rbp), %eax
andl $0xf, %eax
cmpl $0x0, %eax
je 0x585c
jmp 0x587b
leaq 0x109f9(%rip), %rdi     # 0x1625c
leaq 0x1086d(%rip), %rsi     # 0x160d7
movl $0x4fc, %edx            # imm = 0x4FC
leaq 0x10a19(%rip), %rcx     # 0x1628f
callq 0x2140
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rdi
leaq 0x11a37(%rip), %rsi     # 0x172c1
callq 0x2050
cmpl $0x0, %eax
jne 0x589f
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movb $0x0, (%rax)
movl -0xc(%rbp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
jne 0x5ac8
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movsbl (%rax), %eax
cmpl $0x24, %eax
jne 0x58d3
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movsbl 0x1(%rax), %eax
cmpl $0x28, %eax
je 0x5ac8
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movsbl (%rax), %eax
cmpl $0x2f, %eax
je 0x5ac8
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rdi
callq 0x4940
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x2e, %ecx
movb %al, -0x21(%rbp)
jne 0x5935
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movsbl 0x1(%rax), %ecx
xorl %eax, %eax
cmpl $0x2e, %ecx
movb %al, -0x21(%rbp)
jne 0x5935
movq -0x18(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq 0x38(%rcx), %rax
setne %al
movb %al, -0x21(%rbp)
movb -0x21(%rbp), %al
testb $0x1, %al
jne 0x5941
jmp 0x59c9
movq -0x18(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq 0x38(%rcx), %rax
jbe 0x597a
movq -0x20(%rbp), %rax
movsbl -0x1(%rax), %eax
cmpl $0x2f, %eax
jne 0x596a
jmp 0x597a
jmp 0x596c
movq -0x20(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x594d
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rsi
addq $0x2, %rsi
callq 0x3fe0
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movsbl (%rax), %eax
cmpl $0x2f, %eax
jne 0x59bc
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rsi
addq $0x1, %rsi
callq 0x3fe0
movq -0x20(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x58f8
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rsi
movq -0x18(%rbp), %rdx
callq 0x3f50
movq -0x8(%rbp), %rax
movl 0x10(%rax), %ecx
andl $-0x10, %ecx
movl %ecx, 0x10(%rax)
movq -0x8(%rbp), %rax
movl 0x14(%rax), %ecx
andl $0xf, %ecx
movq -0x8(%rbp), %rax
orl 0x10(%rax), %ecx
movl %ecx, 0x10(%rax)
movl -0xc(%rbp), %eax
andl $0xf, %eax
movq -0x8(%rbp), %rcx
movl 0x14(%rcx), %ecx
andl $0xf, %ecx
cmpl %ecx, %eax
je 0x5ac6
cmpq $0x0, 0x157dd(%rip)     # 0x1b200
jne 0x5a30
movl -0xc(%rbp), %eax
andl $0xf, %eax
cmpl $0x3, %eax
je 0x5a39
movq -0x8(%rbp), %rdi
callq 0x5810
movl -0xc(%rbp), %eax
andl $0xf, %eax
movl %eax, -0x28(%rbp)
subl $0x1, %eax
je 0x5a91
jmp 0x5a49
movl -0x28(%rbp), %eax
subl $0x2, %eax
je 0x5a5d
jmp 0x5a53
movl -0x28(%rbp), %eax
subl $0x3, %eax
je 0x5a77
jmp 0x5aa9
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rdi
leaq 0x14f84(%rip), %rsi     # 0x1a9f0
xorl %eax, %eax
movl %eax, %edx
callq 0x3f50
jmp 0x5aa9
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rdi
leaq 0x1536a(%rip), %rsi     # 0x1adf0
xorl %eax, %eax
movl %eax, %edx
callq 0x3f50
jmp 0x5aa9
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rdi
leaq 0x14b50(%rip), %rsi     # 0x1a5f0
xorl %eax, %eax
movl %eax, %edx
callq 0x3f50
movq -0x8(%rbp), %rax
movl 0x10(%rax), %ecx
andl $-0x10, %ecx
movl %ecx, 0x10(%rax)
movl -0xc(%rbp), %ecx
andl $0xf, %ecx
movq -0x8(%rbp), %rax
orl 0x10(%rax), %ecx
movl %ecx, 0x10(%rax)
jmp 0x5ac8
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x4e10
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)