// File: /workspace/github_cpp_makefile_star2_O3/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 %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %r13d
andl $0xf, %r13d
je 0x4805
movl %esi, %ebp
movq %rdi, %rbx
movq 0x30(%rdi), %r14
leaq 0xcb49(%rip), %rsi      # 0x11191
movq %r14, %rdi
callq 0x2070
testl %eax, %eax
jne 0x4658
movb $0x0, (%r14)
testb $0x10, %bpl
jne 0x479d
movq 0x30(%rbx), %r14
movzbl (%r14), %ebp
cmpl $0x2f, %ebp
je 0x479d
cmpl $0x24, %ebp
jne 0x4683
cmpb $0x28, 0x1(%r14)
je 0x479d
movq 0x38(%rbx), %r12
movq %r12, %rdi
movl $0x2f, %esi
callq 0x2150
leaq 0x1(%rax), %r15
testq %rax, %rax
cmoveq %r12, %r15
cmpb $0x2e, %bpl
jne 0x471e
cmpb $0x2e, 0x1(%r14)
movq 0x38(%rbx), %r12
jne 0x471e
cmpq %r12, %r15
je 0x471e
decq %r15
movq %r15, %rax
movq %rax, %r15
cmpq %r12, %rax
jbe 0x46ce
leaq -0x1(%r15), %rax
cmpb $0x2f, -0x1(%r15)
jne 0x46bb
leaq 0x2(%r14), %r12
movq %r12, %rdi
callq 0x2120
leaq 0x1(%rax), %rdx
movq %r14, %rdi
movq %r12, %rsi
callq 0x22c0
movq 0x30(%rbx), %r14
movb (%r14), %al
cmpb $0x2f, %al
jne 0x4716
leaq 0x1(%r14), %r12
movq %r12, %rdi
callq 0x2120
leaq 0x1(%rax), %rdx
movq %r14, %rdi
movq %r12, %rsi
callq 0x22c0
movq 0x30(%rbx), %r14
movb (%r14), %al
cmpb $0x2e, %al
je 0x46a5
movq 0x38(%rbx), %r12
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x3598
movl 0x10(%rbx), %esi
movl 0x14(%rbx), %eax
andl $-0x10, %esi
andl $0xf, %eax
orl %eax, %esi
movl %esi, 0x10(%rbx)
cmpl %eax, %r13d
je 0x479d
cmpl $0x3, %r13d
jne 0x47c6
cmpq $0x0, 0x12ac0(%rip)     # 0x17210
jne 0x47c6
movq 0x30(%rbx), %r14
leaq 0x126a3(%rip), %r15     # 0x16e00
movq %r15, %rdi
callq 0x2120
movq %rax, %r12
leaq (%r14,%rax), %rbp
movq %r14, %rdi
callq 0x2120
leaq 0x1(%rax), %rdx
movq %rbp, %rdi
movq %r14, %rsi
callq 0x22c0
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x2240
movl 0x10(%rbx), %eax
andl $-0x10, %eax
orl %r13d, %eax
movl %eax, 0x10(%rbx)
movq 0x30(%rbx), %rax
movzbl (%rax), %ecx
cmpl $0x5c, %ecx
je 0x47af
testl %ecx, %ecx
jne 0x47b2
jmp 0x47b7
movb $0x2f, (%rax)
incq %rax
jmp 0x47a1
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x30(%rbx), %rdi
callq 0x4533
cmpl $0x1, %r13d
je 0x47f5
cmpl $0x3, %r13d
je 0x4752
cmpl $0x2, %r13d
jne 0x4791
movq 0x30(%rbx), %r14
leaq 0x12210(%rip), %r15     # 0x16a00
jmp 0x475d
movq 0x30(%rbx), %r14
leaq 0x11e00(%rip), %r15     # 0x16600
jmp 0x475d
leaq 0xca21(%rip), %rdi      # 0x1122d
leaq 0xc893(%rip), %rsi      # 0x110a6
leaq 0xca46(%rip), %rcx      # 0x11260
movl $0x4fc, %edx            # imm = 0x4FC
callq 0x2160