// File: /workspace/github_cpp_makefile_star2_O3/corecodec[P]coremake/coremake.c
// Function: getrelpath
void getrelpath(char* path, int path_flags, const char* __curr, int curr_flags, int delend, int levelup)
{
    char *__path,_path[MAX_PATH];
    char *curr,_curr[MAX_PATH];

    if ((path_flags & FLAG_PATH_MASK) == FLAG_PATH_NOT_PATH)
        return;

    __path = path;
    strcpy(_path,path);
    pathunix(_path);
    path = _path;
    strcpy(_curr,__curr);
    pathunix(_curr);
    curr = _curr;

    if (!(path_flags & FLAG_PATH_SET_ABSOLUTE))
    {
        // ensure that we deal with absolute pathes to compare
        assert(ispathabs(curr));

        switch (path_flags & FLAG_PATH_MASK)
        {
        case FLAG_PATH_SOURCE:
            if (strnicmp(path,src_root,src_root_len)!=0 && !ispathabs(path))
                strins(path,src_root,NULL);
            break;
        case FLAG_PATH_GENERATED:
            if (strnicmp(path,proj_root,proj_root_len)!=0)
                strins(path,proj_root,NULL);
            break;
        case FLAG_PATH_COREMAKE:
            if (strnicmp(path,coremake_root,coremake_root_len)!=0)
                strins(path,coremake_root,NULL);
            break;
        }

        simplifypath(path,1);
        simplifypath(curr,1);

        for (;;)
	    {
		    char* i = nextlevel(path);
		    char* j = nextlevel(curr);

		    if (i && j && (i-path)==(j-curr) && strnicmp(path,curr,i-path)==0)
		    {
			    strdel(path,i);
			    curr = j;
		    }
		    else
			    break;
	    }

	    while ((curr = nextlevel(curr)) != NULL)
        {
            if (--levelup < 0)
		        strins(path,"../",NULL);
        }

	    if (!path[0])
		    strcpy(path,"./");
    }

	if (delend)
		delendpath(path);
    strcpy(__path,path);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x818, %rsp            # imm = 0x818
movl %esi, %r15d
andl $0xf, %r15d
je 0x43ca
movl %r9d, %r14d
movq %rdx, %r12
movl %esi, %ebp
movq %rdi, %rbx
movl %r8d, 0xc(%rsp)
leaq 0x10(%rsp), %r13
movq %r13, %rdi
movq %rbx, %rsi
callq 0x20b0
movzbl (%r13), %eax
cmpl $0x5c, %eax
je 0x40aa
testl %eax, %eax
jne 0x40af
jmp 0x40b4
movb $0x2f, (%r13)
incq %r13
jmp 0x409a
leaq 0x410(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x20b0
movzbl (%r13), %eax
cmpl $0x5c, %eax
je 0x40d7
testl %eax, %eax
jne 0x40dc
jmp 0x40e1
movb $0x2f, (%r13)
incq %r13
jmp 0x40c7
testb $0x10, %bpl
jne 0x4195
leaq 0x410(%rsp), %rbp
movq %rbp, %rdi
callq 0x3ff4
testl %eax, %eax
je 0x43dc
cmpl $0x3, %r15d
je 0x4201
cmpl $0x2, %r15d
je 0x41a2
cmpl $0x1, %r15d
jne 0x4262
movq 0x130d8(%rip), %rdx     # 0x17200
leaq 0x124d1(%rip), %rsi     # 0x16600
leaq 0x10(%rsp), %rdi
callq 0x2260
testl %eax, %eax
je 0x4262
leaq 0x10(%rsp), %rdi
callq 0x3ff4
testl %eax, %eax
jne 0x4262
leaq 0x124a6(%rip), %rdi     # 0x16600
callq 0x2120
movq %rax, %r12
leaq (%rsp,%rax), %r13
addq $0x10, %r13
leaq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0x2120
leaq 0x1(%rax), %rdx
movq %r13, %rdi
movq %r15, %rsi
callq 0x22c0
movq %r15, %rdi
leaq 0x12470(%rip), %rsi     # 0x16600
jmp 0x425a
cmpb $0x0, 0x10(%rsp)
sete %al
jmp 0x439c
movq 0x1305f(%rip), %rdx     # 0x17208
leaq 0x12850(%rip), %rsi     # 0x16a00
leaq 0x10(%rsp), %rdi
callq 0x2260
testl %eax, %eax
je 0x4262
leaq 0x12837(%rip), %rdi     # 0x16a00
callq 0x2120
movq %rax, %r12
leaq (%rsp,%rax), %r13
addq $0x10, %r13
leaq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0x2120
leaq 0x1(%rax), %rdx
movq %r13, %rdi
movq %r15, %rsi
callq 0x22c0
movq %r15, %rdi
leaq 0x12801(%rip), %rsi     # 0x16a00
jmp 0x425a
movq 0x13008(%rip), %rdx     # 0x17210
leaq 0x12bf1(%rip), %rsi     # 0x16e00
leaq 0x10(%rsp), %rdi
callq 0x2260
testl %eax, %eax
je 0x4262
leaq 0x12bdc(%rip), %rdi     # 0x16e00
callq 0x2120
movq %rax, %r12
leaq (%rsp,%rax), %r13
addq $0x10, %r13
leaq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0x2120
leaq 0x1(%rax), %rdx
movq %r13, %rdi
movq %r15, %rsi
callq 0x22c0
movq %r15, %rdi
leaq 0x12ba6(%rip), %rsi     # 0x16e00
movq %r12, %rdx
callq 0x2240
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movl $0x1, %esi
callq 0x43fb
movq %rbp, %rdi
movl $0x1, %esi
callq 0x43fb
movq %r12, %rdi
movl $0x2f, %esi
callq 0x2130
movq %rax, %r13
testq %rax, %rax
setne %r15b
movq %rbp, %rdi
movl $0x2f, %esi
callq 0x2130
testq %rax, %rax
setne %cl
andb %r15b, %cl
cmpb $0x1, %cl
jne 0x4325
leaq 0x410(%rsp), %rbp
incq %r13
movq %rax, %r15
incq %r15
movq %r13, %rdx
subq %r12, %rdx
movq %r15, %rax
subq %rbp, %rax
cmpq %rax, %rdx
jne 0x4325
movq %r12, %rdi
movq %rbp, %rsi
callq 0x2260
testl %eax, %eax
jne 0x4325
movq %r13, %rdi
callq 0x2120
leaq 0x1(%rax), %rdx
movq %r12, %rdi
movq %r13, %rsi
callq 0x22c0
movq %r12, %rdi
movl $0x2f, %esi
callq 0x2130
movq %rax, %r13
movq %r15, %rdi
movl $0x2f, %esi
callq 0x2130
movq %r15, %rbp
testq %r13, %r13
je 0x4325
testq %rax, %rax
jne 0x42bb
movq %rbp, %rdi
movl $0x2f, %esi
callq 0x2130
testq %rax, %rax
je 0x4387
movq %rax, %r15
leaq 0x13(%rsp), %r12
leaq 0x10(%rsp), %r13
testl %r14d, %r14d
jg 0x436c
movq %r13, %rdi
callq 0x2120
leaq 0x1(%rax), %rdx
movq %r12, %rdi
movq %r13, %rsi
callq 0x22c0
movw $0x2e2e, 0x10(%rsp)     # imm = 0x2E2E
movb $0x2f, 0x12(%rsp)
incq %r15
movq %r15, %rdi
movl $0x2f, %esi
callq 0x2130
movq %rax, %r15
decl %r14d
testq %rax, %rax
jne 0x4344
cmpb $0x0, 0x10(%rsp)
jne 0x439a
movb $0x0, 0x12(%rsp)
movw $0x2f2e, 0x10(%rsp)     # imm = 0x2F2E
xorl %eax, %eax
cmpl $0x0, 0xc(%rsp)
je 0x43bd
testb %al, %al
jne 0x43bd
leaq 0x10(%rsp), %rdi
callq 0x2120
cmpb $0x2f, 0xf(%rsp,%rax)
jne 0x43bd
movb $0x0, 0xf(%rsp,%rax)
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x20b0
addq $0x818, %rsp            # imm = 0x818
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xcdb0(%rip), %rdi      # 0x11193
leaq 0xccbc(%rip), %rsi      # 0x110a6
leaq 0xcdb2(%rip), %rcx      # 0x111a3
movl $0x4ac, %edx            # imm = 0x4AC
callq 0x2160