// File: /workspace/github_cpp_makefile_star2_O1/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, %ebp
andl $0xf, %ebp
je 0x434d
movl %r9d, %r14d
movq %rdx, %r12
movl %esi, %r15d
movq %rdi, %rbx
movl %r8d, 0x4(%rsp)
leaq 0x10(%rsp), %r13
movq %r13, %rdi
movq %rbx, %rsi
callq 0x20b0
movzbl (%r13), %eax
cmpl $0x5c, %eax
je 0x40cb
testl %eax, %eax
jne 0x40d0
jmp 0x40d5
movb $0x2f, (%r13)
incq %r13
jmp 0x40bb
leaq 0x410(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x20b0
movzbl (%r13), %eax
cmpl $0x5c, %eax
je 0x40f8
testl %eax, %eax
jne 0x40fd
jmp 0x4102
movb $0x2f, (%r13)
incq %r13
jmp 0x40e8
testb $0x10, %r15b
jne 0x431c
movq %rbx, 0x8(%rsp)
leaq 0x410(%rsp), %rbx
movq %rbx, %rdi
callq 0x4016
testl %eax, %eax
je 0x435f
cmpl $0x3, %ebp
je 0x419c
cmpl $0x2, %ebp
je 0x4177
cmpl $0x1, %ebp
jne 0x41fc
movq 0x140bd(%rip), %rdx     # 0x18200
leaq 0x134b6(%rip), %rsi     # 0x17600
leaq 0x10(%rsp), %rdi
callq 0x2270
testl %eax, %eax
je 0x41fc
leaq 0x10(%rsp), %rdi
callq 0x4016
testl %eax, %eax
jne 0x41fc
leaq 0x1348b(%rip), %r15     # 0x17600
jmp 0x41bf
movq 0x1408a(%rip), %rdx     # 0x18208
leaq 0x1387b(%rip), %rsi     # 0x17a00
leaq 0x10(%rsp), %rdi
callq 0x2270
testl %eax, %eax
je 0x41fc
leaq 0x13866(%rip), %r15     # 0x17a00
jmp 0x41bf
movq 0x1406d(%rip), %rdx     # 0x18210
leaq 0x13c56(%rip), %rsi     # 0x17e00
leaq 0x10(%rsp), %rdi
callq 0x2270
testl %eax, %eax
je 0x41fc
leaq 0x13c41(%rip), %r15     # 0x17e00
movq %r15, %rdi
callq 0x2120
movq %rax, %r13
leaq (%rsp,%rax), %r12
addq $0x10, %r12
leaq 0x10(%rsp), %rbp
movq %rbp, %rdi
callq 0x2120
leaq 0x1(%rax), %rdx
movq %r12, %rdi
movq %rbp, %rsi
callq 0x22d0
movq %rbp, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x2240
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movl $0x1, %esi
callq 0x437e
movq %rbx, %rdi
movl $0x1, %esi
callq 0x437e
movq %r12, %rdi
movl $0x2f, %esi
callq 0x2130
movq %rax, %rbp
leaq 0x1(%rax), %r13
movq %rbx, %rdi
movl $0x2f, %esi
callq 0x2130
leaq 0x1(%rax), %r15
testq %rax, %rax
cmoveq %rax, %r15
xorl %ecx, %ecx
testq %rbp, %rbp
cmoveq %rbp, %r13
je 0x4279
testq %rax, %rax
je 0x4279
movq %r13, %rdx
subq %r12, %rdx
movq %r15, %rax
subq %rbx, %rax
cmpq %rax, %rdx
jne 0x4277
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2270
testl %eax, %eax
je 0x427f
xorl %ecx, %ecx
testb %cl, %cl
jne 0x421b
jmp 0x429d
movq %r13, %rdi
callq 0x2120
leaq 0x1(%rax), %rdx
movq %r12, %rdi
movq %r13, %rsi
callq 0x22d0
movb $0x1, %cl
movq %r15, %rbx
jmp 0x4279
movq %rbx, %rdi
movl $0x2f, %esi
callq 0x2130
testq %rax, %rax
movq 0x8(%rsp), %rbx
je 0x4309
movq %rax, %r15
incq %r15
leaq 0x13(%rsp), %r12
leaq 0x10(%rsp), %r13
testl %r14d, %r14d
jg 0x42ec
movq %r13, %rdi
callq 0x2120
leaq 0x1(%rax), %rdx
movq %r12, %rdi
movq %r13, %rsi
callq 0x22d0
movw $0x2e2e, 0x10(%rsp)     # imm = 0x2E2E
movb $0x2f, 0x12(%rsp)
movq %r15, %rdi
movl $0x2f, %esi
callq 0x2130
leaq 0x1(%rax), %r15
decl %r14d
testq %rax, %rax
cmoveq %rax, %r15
jne 0x42c4
cmpb $0x0, 0x10(%rsp)
jne 0x431c
movb $0x0, 0x12(%rsp)
movw $0x2f2e, 0x10(%rsp)     # imm = 0x2F2E
cmpl $0x0, 0x4(%rsp)
je 0x4340
cmpb $0x0, 0x10(%rsp)
je 0x4340
leaq 0x10(%rsp), %rdi
callq 0x2120
cmpb $0x2f, 0xf(%rsp,%rax)
jne 0x4340
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 0xde2b(%rip), %rdi      # 0x12191
leaq 0xdd39(%rip), %rsi      # 0x120a6
leaq 0xde2d(%rip), %rcx      # 0x121a1
movl $0x4ac, %edx            # imm = 0x4AC
callq 0x2160