// File: /workspace/github_c_makefile_star2_O0/serge-404[P]CPM32/cpm.c
// Function: mk_filename
char *mk_filename( char *s, byte *fcb)
{
    int i, j;
    char *dir;
#ifdef __linux__
    char *dot=NULL;
#endif
    i = fcb[ 0];
    if ( i == '?' || i == 0) i = cpm_disk_no;
    else i--;
    if ( i >= MAXDRV) return NULL;
    if ( cpm_drive[ i] == NULL) {
	if ( cpm_disk_vct == 0) setup_disk_vct();
	if ( cpm_drive[ i] == NULL) return NULL;
    }
    strcpy( s, cpm_drive[ i]);
    s += i = strlen( s);
    if ( i && s[ -1] != CH_SLASH && s[ -1] != '/' && s[ -1] != ':') *s++ = '/';
    dir = s;

    for ( j = 8; j >= 1 && fcb[ j] == '?'; j--);
    j++;
    for ( i = 1; i < j; i++) {
		if ( fcb[ i] == ' ') break;
		*s++ = fcb[ i];
    }
    if ( i == j && i <= 8) *s++ = '*';

#ifdef __linux__
	dot=s;
#endif
    *s++ = '.';

    for ( j = 11; j >= 9 && fcb[ j] == '?'; j--);
    j++;
    for ( i = 9; i < j; i++) {
	if ( fcb[ i] == ' ') break;
		*s++ = fcb[ i];
#ifdef __linux__
		dot=NULL;
#endif
    }
    if ( i == j && i <= 11) *s++ = '*';
#ifdef __linux__
	if (dot) s=dot;
#endif
	*s = '\0';
    return dir;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
movl %eax, -0x1c(%rbp)
cmpl $0x3f, -0x1c(%rbp)
je 0xe34e
cmpl $0x0, -0x1c(%rbp)
jne 0xe35a
movzbl 0xced3(%rip), %eax      # 0x1b228
movl %eax, -0x1c(%rbp)
jmp 0xe363
movl -0x1c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rbp)
cmpl $0x10, -0x1c(%rbp)
jl 0xe376
movq $0x0, -0x8(%rbp)
jmp 0xe5d3
movslq -0x1c(%rbp), %rcx
leaq 0x10d25f(%rip), %rax    # 0x11b5e0
cmpq $0x0, (%rax,%rcx,8)
jne 0xe3ba
movzwl 0x10d12b(%rip), %eax    # 0x11b4ba
cmpl $0x0, %eax
jne 0xe399
callq 0xd5a0
movslq -0x1c(%rbp), %rcx
leaq 0x10d23c(%rip), %rax    # 0x11b5e0
cmpq $0x0, (%rax,%rcx,8)
jne 0xe3b8
movq $0x0, -0x8(%rbp)
jmp 0xe5d3
jmp 0xe3ba
movq -0x10(%rbp), %rdi
movslq -0x1c(%rbp), %rcx
leaq 0x10d217(%rip), %rax    # 0x11b5e0
movq (%rax,%rcx,8), %rsi
callq 0x2090
movq -0x10(%rbp), %rdi
callq 0x20f0
movl %eax, %ecx
movl %ecx, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0xe42d
movq -0x10(%rbp), %rax
movsbl -0x1(%rax), %eax
cmpl $0x2f, %eax
je 0xe42d
movq -0x10(%rbp), %rax
movsbl -0x1(%rax), %eax
cmpl $0x2f, %eax
je 0xe42d
movq -0x10(%rbp), %rax
movsbl -0x1(%rax), %eax
cmpl $0x3a, %eax
je 0xe42d
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rbp)
movb $0x2f, (%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movl $0x8, -0x20(%rbp)
xorl %eax, %eax
cmpl $0x1, -0x20(%rbp)
movb %al, -0x31(%rbp)
jl 0xe45c
movq -0x18(%rbp), %rax
movslq -0x20(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x3f, %eax
sete %al
movb %al, -0x31(%rbp)
movb -0x31(%rbp), %al
testb $0x1, %al
jne 0xe465
jmp 0xe472
jmp 0xe467
movl -0x20(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xe43c
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movl $0x1, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0xe4c4
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x20, %eax
jne 0xe49d
jmp 0xe4c4
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movb (%rax,%rcx), %cl
movq -0x10(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x10(%rbp)
movb %cl, (%rax)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xe482
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jne 0xe4e4
cmpl $0x8, -0x1c(%rbp)
jg 0xe4e4
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rbp)
movb $0x2a, (%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rbp)
movb $0x2e, (%rax)
movl $0xb, -0x20(%rbp)
xorl %eax, %eax
cmpl $0x9, -0x20(%rbp)
movb %al, -0x32(%rbp)
jl 0xe525
movq -0x18(%rbp), %rax
movslq -0x20(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x3f, %eax
sete %al
movb %al, -0x32(%rbp)
movb -0x32(%rbp), %al
testb $0x1, %al
jne 0xe52e
jmp 0xe53b
jmp 0xe530
movl -0x20(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xe505
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movl $0x9, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0xe595
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x20, %eax
jne 0xe566
jmp 0xe595
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movb (%rax,%rcx), %cl
movq -0x10(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x10(%rbp)
movb %cl, (%rax)
movq $0x0, -0x30(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xe54b
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jne 0xe5b5
cmpl $0xb, -0x1c(%rbp)
jg 0xe5b5
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rbp)
movb $0x2a, (%rax)
cmpq $0x0, -0x30(%rbp)
je 0xe5c4
movq -0x30(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movb $0x0, (%rax)
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)