// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %esi, %r12d
andl $0xf, %r12d
je 0x41a4
movl %esi, %ebp
movq %rdi, %rbx
movq 0x30(%rdi), %r14
leaq 0xc114(%rip), %rsi      # 0x10191
movq %r14, %rdi
callq 0x2070
testl %eax, %eax
jne 0x408d
movb $0x0, (%r14)
testb $0x10, %bpl
jne 0x4193
movq 0x30(%rbx), %r14
movzbl (%r14), %ebp
cmpl $0x2f, %ebp
je 0x4193
cmpl $0x24, %ebp
jne 0x40b8
cmpb $0x28, 0x1(%r14)
je 0x4193
movq 0x38(%rbx), %rdi
callq 0x3853
movq %rax, %r15
cmpb $0x2e, %bpl
jne 0x4121
cmpb $0x2e, 0x1(%r14)
movq 0x38(%rbx), %rsi
jne 0x4125
cmpq %rsi, %r15
je 0x4125
decq %r15
movq %r15, %rax
movq %rax, %r15
cmpq %rsi, %rax
jbe 0x40f3
leaq -0x1(%r15), %rax
cmpb $0x2f, -0x1(%r15)
jne 0x40e0
leaq 0x2(%r14), %rsi
movq %r14, %rdi
callq 0x33a5
movq 0x30(%rbx), %r14
movb (%r14), %bpl
cmpb $0x2f, %bpl
jne 0x40c4
leaq 0x1(%r14), %rsi
movq %r14, %rdi
callq 0x33a5
movq 0x30(%rbx), %r14
movb (%r14), %bpl
jmp 0x40c4
movq 0x38(%rbx), %rsi
movq %r14, %rdi
movq %r15, %rdx
callq 0x334b
movl 0x10(%rbx), %eax
movl 0x14(%rbx), %ecx
andl $-0x10, %eax
andl $0xf, %ecx
orl %ecx, %eax
movl %eax, 0x10(%rbx)
cmpl %ecx, %r12d
je 0x4193
cmpl $0x3, %r12d
jne 0x415f
cmpq $0x0, 0x130bc(%rip)     # 0x17210
jne 0x415f
leaq 0x12ca3(%rip), %rsi     # 0x16e00
jmp 0x417c
movq %rbx, %rdi
callq 0x4049
cmpl $0x3, %r12d
ja 0x4187
movl %r12d, %eax
leaq 0x11c61(%rip), %rcx     # 0x15dd8
movq -0x8(%rcx,%rax,8), %rsi
movq 0x30(%rbx), %rdi
xorl %edx, %edx
callq 0x334b
movl 0x10(%rbx), %eax
andl $-0x10, %eax
orl %r12d, %eax
movl %eax, 0x10(%rbx)
movq 0x30(%rbx), %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x3a94
leaq 0xc082(%rip), %rdi      # 0x1022d
leaq 0xbef4(%rip), %rsi      # 0x100a6
leaq 0xc0a7(%rip), %rcx      # 0x10260
movl $0x4fc, %edx            # imm = 0x4FC
callq 0x2160