// File: /workspace/github_c_makefile_star2_O0/serge-404[P]CPM32/cpm.c
// Function: cpm_file_delete
byte cpm_file_delete( byte *fcbaddr)
{
    struct FCB *fcb = (struct FCB *)fcbaddr;
    int i;
    HANDLE hFndFile;
    WIN32_FIND_DATA aFindData;
    char *fname;
    byte st = 0xff;

    if ( memcmp( fcbaddr, "\1$$$     SUB", 1+8+3) == 0) abort_submit = TRUE;

    if (( i = fcb->d[ 0]) > 0 && --i < MAXFCB && 
		fcbs[ i].addr == fcbaddr && fcbs[ i].fp) {
DEBUGOUT( stderr, "REUSE %d - ", i);
	fclose( fcbs[ i].fp); fcbs[ i].fp = NULL;
    }

    if (( fname = mk_filename( filename, fcbaddr)) == NULL) return 0xff;
    hFndFile = FindFirstFile( filename, &aFindData);
    if ( hFndFile == INVALID_HANDLE_VALUE) return 0xff;
    do {
	char *p = aFindData.cAlternateFileName;
	if ( !*p) p = aFindData.cFileName;
	if ( *p != '.') {
	    strcpy( fname, p);
	    if ( remove( filename) == 0) st = 0;
	}
    } while( FindNextFile( hFndFile, &aFindData));
    FindClose( hFndFile);

    return st;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
movb $-0x1, -0x161(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x8af5(%rip), %rsi      # 0x1851e
movl $0xc, %edx
callq 0x21d0
cmpl $0x0, %eax
jne 0xfa42
movl $0x1, 0x10e06e(%rip)    # 0x11dab0
movq -0x18(%rbp), %rax
movzbl 0x10(%rax), %eax
movl %eax, -0x1c(%rbp)
cmpl $0x0, %eax
jle 0xfaf3
movl -0x1c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rbp)
cmpl $0x40, %eax
jge 0xfaf3
movslq -0x1c(%rbp), %rcx
leaq 0x10d83d(%rip), %rax    # 0x11d2b0
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
cmpq -0x10(%rbp), %rax
jne 0xfaf3
movslq -0x1c(%rbp), %rcx
leaq 0x10d821(%rip), %rax    # 0x11d2b0
shlq $0x5, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
je 0xfaf3
cmpl $0x0, 0x10ba11(%rip)    # 0x11b4b4
je 0xfac0
movq 0xb54c(%rip), %rax      # 0x1aff8
movq (%rax), %rdi
movl -0x1c(%rbp), %edx
leaq 0x8a72(%rip), %rsi      # 0x1852b
movb $0x0, %al
callq 0x2220
movslq -0x1c(%rbp), %rcx
leaq 0x10d7e5(%rip), %rax    # 0x11d2b0
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rdi
callq 0x20d0
movslq -0x1c(%rbp), %rcx
leaq 0x10d7cb(%rip), %rax    # 0x11d2b0
shlq $0x5, %rcx
addq %rcx, %rax
movq $0x0, (%rax)
movq -0x10(%rbp), %rsi
leaq 0x10d182(%rip), %rdi    # 0x11cc80
callq 0xe320
movq %rax, -0x160(%rbp)
cmpq $0x0, %rax
jne 0xfb19
movb $-0x1, -0x1(%rbp)
jmp 0xfbdd
leaq 0x10d160(%rip), %rdi    # 0x11cc80
leaq -0x158(%rbp), %rsi
callq 0xe5e0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0xfb40
movb $-0x1, -0x1(%rbp)
jmp 0xfbdd
jmp 0xfb42
leaq -0x158(%rbp), %rax
addq $0x11c, %rax            # imm = 0x11C
movq %rax, -0x170(%rbp)
movq -0x170(%rbp), %rax
cmpb $0x0, (%rax)
jne 0xfb74
leaq -0x158(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x170(%rbp)
movq -0x170(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2e, %eax
je 0xfbb0
movq -0x160(%rbp), %rdi
movq -0x170(%rbp), %rsi
callq 0x2090
leaq 0x10d0e3(%rip), %rdi    # 0x11cc80
callq 0x2070
cmpl $0x0, %eax
jne 0xfbae
movb $0x0, -0x161(%rbp)
jmp 0xfbb0
jmp 0xfbb2
movq -0x28(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0xe8b0
cmpl $0x0, %eax
jne 0xfb42
movq -0x28(%rbp), %rdi
callq 0xea00
movb -0x161(%rbp), %al
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
nopl (%rax)