// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/lib/filePath.c
// Function: expandRelativePath
char *expandRelativePath(char *baseDir, char *relPath)
/* Expand relative path to more absolute one. */
{
if (relPath[0] == '/')
   // hey, it's absolute actually... 
   return cloneString(relPath);

char *e = baseDir + strlen(baseDir);
int slashCount;
char *rel = relPath;
char *result;
int size, baseSize;
undosPath(baseDir);
undosPath(relPath);
slashCount = countChars(baseDir, '/');
if (baseDir[0] == 0)
    slashCount = -1;
while (startsWith("../", rel))
    {
    if (slashCount < 0)
        {
	warn("More ..'s in \"%s\" than directories in \"%s\"", relPath, baseDir);
	return NULL;
	}
    else if (slashCount == 0)
        e = baseDir;
    else
        e = findSlashBefore(baseDir, e);
    slashCount -= 1;
    rel += 3;
    }
baseSize = e - baseDir;
size = strlen(rel) + 1;
if (baseSize > 0)
    size += baseSize + 1;
if (baseSize > 0)
    {
    result = needMem(size);
    memcpy(result, baseDir, baseSize);
    result[baseSize] = '/';
    strcpy(result + baseSize + 1, rel);
    }
else
    result = cloneString(rel);
return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2f, %eax
jne 0x3879e
movq -0x18(%rbp), %rdi
callq 0x2a450
movq %rax, -0x8(%rbp)
jmp 0x38904
movq -0x10(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
callq 0x62c0
movq %rax, %rcx
movq -0x48(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
callq 0x38590
movq -0x18(%rbp), %rdi
callq 0x38590
movq -0x10(%rbp), %rdi
movl $0x2f, %esi
callq 0x2e520
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x387fb
movl $0xffffffff, -0x24(%rbp) # imm = 0xFFFFFFFF
jmp 0x387fd
movq -0x30(%rbp), %rsi
leaq 0xa4b66(%rip), %rdi     # 0xdd36e
callq 0x2d3d0
cmpl $0x0, %eax
je 0x38875
cmpl $0x0, -0x24(%rbp)
jge 0x3883b
movq -0x18(%rbp), %rsi
movq -0x10(%rbp), %rdx
leaq 0xa227a(%rip), %rdi     # 0xdaaa1
movb $0x0, %al
callq 0x358e0
movq $0x0, -0x8(%rbp)
jmp 0x38904
cmpl $0x0, -0x24(%rbp)
jne 0x3884b
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x3885c
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x38910
movq %rax, -0x20(%rbp)
jmp 0x3885e
movl -0x24(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x24(%rbp)
movq -0x30(%rbp), %rax
addq $0x3, %rax
movq %rax, -0x30(%rbp)
jmp 0x387fd
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0x40(%rbp)
movq -0x30(%rbp), %rdi
callq 0x62c0
addq $0x1, %rax
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x40(%rbp)
jle 0x388a5
movl -0x40(%rbp), %eax
addl $0x1, %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x40(%rbp)
jle 0x388ef
movslq -0x3c(%rbp), %rdi
callq 0x40c50
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rsi
movslq -0x40(%rbp), %rdx
callq 0x6570
movq -0x38(%rbp), %rax
movslq -0x40(%rbp), %rcx
movb $0x2f, (%rax,%rcx)
movq -0x38(%rbp), %rdi
movslq -0x40(%rbp), %rax
addq %rax, %rdi
addq $0x1, %rdi
movq -0x30(%rbp), %rsi
callq 0x6680
jmp 0x388fc
movq -0x30(%rbp), %rdi
callq 0x2a450
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nop