// File: /workspace/github_c_makefile_star2_O0/j-hoppe[P]tu58fs/xxdp.c
// Function: xxdp_filename_from_host
char *xxdp_filename_from_host(char *hostfname, char *filnam, char *ext) {
	static char result[80];
	char pathbuff[4096];
	char _filnam[7], _ext[4];
	char *s, *t;

	strcpy(pathbuff, hostfname);

	// upcase and replace forbidden characters
	for (s = pathbuff; *s; s++)
		if (*s == '_')
			*s = ' ';
		else {
			*s = toupper(*s);
			if (!strchr(" ABCDEFGHIJKLMNOPQRSTUVWXYZ$.%0123456789", *s))
				*s = '%';
		}

	// search last "."
	s = extract_extension(pathbuff, /*truncate*/1);
	t = _ext; // extract 3 char ext
	while (s && *s && (t - _ext) < 3)
		*t++ = *s++;
	*t = 0;

	// extract 6 char filnam
	s = pathbuff; // only filename
	t = _filnam;
	while (*s && (t - _filnam) < 6)
		*t++ = *s++;
	*t = 0;

	if (filnam) // length MUST be >= 7
		strcpy(filnam, strtrim(_filnam));
	if (ext) // length MUST be >= 4
		strcpy(ext, strtrim(_ext));

	strcpy(result, strtrim(_filnam));
	if (strlen(_ext)) {
		strcat(result, ".");
		strcat(result, strtrim(_ext));
	}

	return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1060, %rsp           # imm = 0x1060
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
leaq -0x1020(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x30c0
leaq -0x1020(%rbp), %rax
movq %rax, -0x1038(%rbp)
movq -0x1038(%rbp), %rax
cmpb $0x0, (%rax)
je 0x121c4
movq -0x1038(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5f, %eax
jne 0x1216c
movq -0x1038(%rbp), %rax
movb $0x20, (%rax)
jmp 0x121ae
movq -0x1038(%rbp), %rax
movsbl (%rax), %edi
callq 0x30e0
movb %al, %cl
movq -0x1038(%rbp), %rax
movb %cl, (%rax)
movq -0x1038(%rbp), %rax
movsbl (%rax), %esi
leaq 0xab3d(%rip), %rdi      # 0x1ccd4
callq 0x31c0
cmpq $0x0, %rax
jne 0x121ac
movq -0x1038(%rbp), %rax
movb $0x25, (%rax)
jmp 0x121ae
jmp 0x121b0
movq -0x1038(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x1038(%rbp)
jmp 0x12145
leaq -0x1020(%rbp), %rdi
movl $0x1, %esi
callq 0xdc90
movq %rax, -0x1038(%rbp)
leaq -0x102b(%rbp), %rax
movq %rax, -0x1040(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x1038(%rbp)
movb %al, -0x1041(%rbp)
je 0x12231
movq -0x1038(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x1041(%rbp)
je 0x12231
movq -0x1040(%rbp), %rax
leaq -0x102b(%rbp), %rcx
subq %rcx, %rax
cmpq $0x3, %rax
setl %al
movb %al, -0x1041(%rbp)
movb -0x1041(%rbp), %al
testb $0x1, %al
jne 0x1223d
jmp 0x12270
movq -0x1038(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x1038(%rbp)
movb (%rax), %cl
movq -0x1040(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x1040(%rbp)
movb %cl, (%rax)
jmp 0x121ea
movq -0x1040(%rbp), %rax
movb $0x0, (%rax)
leaq -0x1020(%rbp), %rax
movq %rax, -0x1038(%rbp)
leaq -0x1027(%rbp), %rax
movq %rax, -0x1040(%rbp)
movq -0x1038(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x1042(%rbp)
je 0x122cb
movq -0x1040(%rbp), %rax
leaq -0x1027(%rbp), %rcx
subq %rcx, %rax
cmpq $0x6, %rax
setl %al
movb %al, -0x1042(%rbp)
movb -0x1042(%rbp), %al
testb $0x1, %al
jne 0x122d7
jmp 0x12307
movq -0x1038(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x1038(%rbp)
movb (%rax), %cl
movq -0x1040(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x1040(%rbp)
movb %cl, (%rax)
jmp 0x12296
movq -0x1040(%rbp), %rax
movb $0x0, (%rax)
cmpq $0x0, -0x10(%rbp)
je 0x1233e
movq -0x10(%rbp), %rax
movq %rax, -0x1050(%rbp)
leaq -0x1027(%rbp), %rdi
callq 0xd610
movq -0x1050(%rbp), %rdi
movq %rax, %rsi
callq 0x30c0
cmpq $0x0, -0x18(%rbp)
je 0x1236b
movq -0x18(%rbp), %rax
movq %rax, -0x1058(%rbp)
leaq -0x102b(%rbp), %rdi
callq 0xd610
movq -0x1058(%rbp), %rdi
movq %rax, %rsi
callq 0x30c0
leaq -0x1027(%rbp), %rdi
callq 0xd610
movq %rax, %rsi
leaq 0x162bf(%rip), %rdi     # 0x28640
callq 0x30c0
leaq -0x102b(%rbp), %rdi
callq 0x3190
cmpq $0x0, %rax
je 0x123c6
leaq 0x162a1(%rip), %rdi     # 0x28640
leaq 0x8c3c(%rip), %rsi      # 0x1afe2
callq 0x3500
leaq -0x102b(%rbp), %rdi
callq 0xd610
movq %rax, %rsi
leaq 0x1627f(%rip), %rdi     # 0x28640
callq 0x3500
leaq 0x16273(%rip), %rax     # 0x28640
addq $0x1060, %rsp           # imm = 0x1060
popq %rbp
retq
nopw %cs:(%rax,%rax)