// File: skyshore2001[P]symfind/symfind.cpp
// Function: GetFullName(char*, char const*, char const*, char const*)
char *GetFullName(char *buf, const char *root, const char *dirname, const char *file = NULL)
{
// 	static char buf[1024];
	// 1. replace root
	root = g_rootsubs.Substitue(root);

	char quote[2] = {0,0};
	if (file && (strchr(root, ' ') != NULL || strchr(dirname, ' ') != NULL || strchr(file, ' ') != NULL))
		quote[0] = '"';

	// 2. remove ./ at the beginning of dirname
	const char *p = dirname;
	if (*p == '.') {
		++ p;
		if (*p == '/' || *p == '\\') // './xxx'
		{
			++p;
			dirname = p;
		}
		else if (*p == 0) // '.'
			dirname = p;
	}
	if (dirname[0] == 0) {
		if (file == NULL)
			sprintf(buf, "%s%s%s", quote, root, quote);
		else 
			sprintf(buf, "%s%s%c%s%s", quote, root, SEP, file, quote);
	}
	else {
		if (file == NULL)
			sprintf(buf, "%s%s%c%s%s", quote, root, SEP, dirname, quote);
		else 
			sprintf(buf, "%s%s%c%s%c%s%s", quote, root, SEP, dirname, SEP, file, quote);
	}
	return buf;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq 0xe159(%rip), %rdi      # 0x11318
addq $0x8, %rdi
movq -0x10(%rbp), %rsi
callq 0x3380
movq %rax, -0x10(%rbp)
leaq -0x22(%rbp), %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x2120
cmpq $0x0, -0x20(%rbp)
je 0x3227
movq -0x10(%rbp), %rdi
movl $0x20, %esi
callq 0x20a0
cmpq $0x0, %rax
jne 0x3223
movq -0x18(%rbp), %rdi
movl $0x20, %esi
callq 0x20a0
cmpq $0x0, %rax
jne 0x3223
movq -0x20(%rbp), %rdi
movl $0x20, %esi
callq 0x20a0
cmpq $0x0, %rax
je 0x3227
movb $0x22, -0x22(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2e, %eax
jne 0x328d
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2f, %eax
je 0x325f
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5c, %eax
jne 0x3275
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x328b
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x3289
movq -0x30(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x328b
jmp 0x328d
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x32f0
cmpq $0x0, -0x20(%rbp)
jne 0x32c0
movq -0x8(%rbp), %rdi
leaq -0x22(%rbp), %rdx
movq -0x10(%rbp), %rcx
leaq -0x22(%rbp), %r8
leaq 0x815c(%rip), %rsi      # 0xb413
movb $0x0, %al
callq 0x2050
jmp 0x32ee
movq -0x8(%rbp), %rdi
leaq -0x22(%rbp), %rdx
movq -0x10(%rbp), %rcx
movsbl 0xdfec(%rip), %r8d      # 0x112c0
movq -0x20(%rbp), %r9
leaq -0x22(%rbp), %rax
leaq 0x8137(%rip), %rsi      # 0xb41a
movq %rax, (%rsp)
movb $0x0, %al
callq 0x2050
jmp 0x336d
cmpq $0x0, -0x20(%rbp)
jne 0x3327
movq -0x8(%rbp), %rdi
leaq -0x22(%rbp), %rdx
movq -0x10(%rbp), %rcx
movsbl 0xdfb5(%rip), %r8d      # 0x112c0
movq -0x18(%rbp), %r9
leaq -0x22(%rbp), %rax
leaq 0x8100(%rip), %rsi      # 0xb41a
movq %rax, (%rsp)
movb $0x0, %al
callq 0x2050
jmp 0x336b
movq -0x8(%rbp), %rdi
leaq -0x22(%rbp), %rdx
movq -0x10(%rbp), %rcx
movsbl 0xdf85(%rip), %r8d      # 0x112c0
movq -0x18(%rbp), %r9
movsbl 0xdf79(%rip), %r11d     # 0x112c0
movq -0x20(%rbp), %r10
leaq -0x22(%rbp), %rax
leaq 0x80cf(%rip), %rsi      # 0xb425
movl %r11d, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movb $0x0, %al
callq 0x2050
jmp 0x336d
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)