// File: /workspace/github_cpp_makefile_star2_O2/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, %ebx
andl $0xf, %ebx
je 0x3e08
movl %r9d, %r14d
movq %rdx, %r15
movl %esi, %ebp
movq %rdi, %rax
movl %r8d, 0x4(%rsp)
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movq %rax, 0x8(%rsp)
movq %rax, %rsi
callq 0x20b0
movq %r12, %rdi
callq 0x3a94
leaq 0x410(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x20b0
movq %r13, %rdi
callq 0x3a94
testb $0x10, %bpl
jne 0x3de8
leaq 0x410(%rsp), %rbp
movq %rbp, %rdi
callq 0x3bd2
testl %eax, %eax
je 0x3e1a
cmpl $0x3, %ebx
je 0x3d12
cmpl $0x2, %ebx
je 0x3d02
cmpl $0x1, %ebx
jne 0x3d40
movq 0x13526(%rip), %rdx     # 0x17200
leaq 0x1291f(%rip), %r13     # 0x16600
leaq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0x2260
testl %eax, %eax
je 0x3d40
leaq 0x10(%rsp), %rdi
callq 0x3bd2
testl %eax, %eax
jne 0x3d40
jmp 0x3d31
movq 0x134ff(%rip), %rdx     # 0x17208
leaq 0x12cf0(%rip), %r13     # 0x16a00
jmp 0x3d20
movq 0x134f7(%rip), %rdx     # 0x17210
leaq 0x130e0(%rip), %r13     # 0x16e00
leaq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0x2260
testl %eax, %eax
je 0x3d40
leaq 0x10(%rsp), %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x334b
pushq $0x1
popq %r15
movq %r12, %rdi
movl %r15d, %esi
callq 0x3e39
movq %rbp, %rdi
movl %r15d, %esi
callq 0x3e39
movq %r12, %rdi
callq 0x39da
movq %rax, %r13
movq %rbp, %rdi
callq 0x39da
testq %r13, %r13
je 0x3dc8
movq %rax, %r15
testq %rax, %rax
je 0x3dc8
movq %r13, %rdx
subq %r12, %rdx
movq %r15, %rax
subq %rbp, %rax
cmpq %rax, %rdx
jne 0x3dc8
movq %r12, %rdi
movq %rbp, %rsi
callq 0x2260
testl %eax, %eax
jne 0x3dc8
movq %r12, %rdi
movq %r13, %rsi
callq 0x33a5
movq %r15, %rbp
jmp 0x3d5a
movq %rax, %rbp
testl %r14d, %r14d
jg 0x3dc5
leaq 0xd3eb(%rip), %rsi      # 0x111a4
leaq 0x10(%rsp), %rdi
xorl %edx, %edx
callq 0x334b
decl %r14d
movq %rbp, %rdi
callq 0x39da
testq %rax, %rax
jne 0x3daa
cmpb $0x0, 0x10(%rsp)
jne 0x3de8
movb $0x0, 0x12(%rsp)
movw $0x2f2e, 0x10(%rsp)     # imm = 0x2F2E
cmpl $0x0, 0x4(%rsp)
je 0x3df9
leaq 0x10(%rsp), %rdi
callq 0x3a15
leaq 0x10(%rsp), %rsi
movq 0x8(%rsp), %rdi
callq 0x20b0
addq $0x818, %rsp            # imm = 0x818
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xc372(%rip), %rdi      # 0x10193
leaq 0xc27e(%rip), %rsi      # 0x100a6
leaq 0xc374(%rip), %rcx      # 0x101a3
movl $0x4ac, %edx            # imm = 0x4AC
callq 0x2160