LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/excess-c64[P]lib1541img/src/lib/1541img/cbmdosvfs.c
// Function: CbmdosVfs_mapUpperGfxToLower
SOEXPORT void CbmdosVfs_mapUpperGfxToLower(CbmdosVfs *self, int mapFiles)
{
    if (mapFiles)
    {
	for (unsigned i = 0; i < self->fileCount; ++i)
	{
	    CbmdosFile_mapUpperGfxToLower(self->files[i]);
	}
    }
    petscii_mapUpperGfxToLower(self->name, self->nameLength);
    CbmdosVfsEventArgs args = { .what = CVE_NAMECHANGED };
    Event_raise(self->changedEvent, &args);
    petscii_mapUpperGfxToLower(self->id, self->idLength);
    args.what = CVE_IDCHANGED;
    Event_raise(self->changedEvent, &args);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
testl %esi, %esi
je 0x7bf6
cmpl $0x0, 0x28(%rbx)
je 0x7bf6
xorl %r14d, %r14d
movq 0x18(%rbx), %rax
movq (%rax,%r14,8), %rdi
callq 0x5710
incq %r14
movl 0x28(%rbx), %eax
cmpq %rax, %r14
jb 0x7bde
movq (%rbx), %rdi
movzbl 0x30(%rbx), %esi
callq 0x5760
movq 0x705f(%rip), %rax      # 0xec68
movq %rsp, %r14
movq %rax, 0x10(%r14)
movups 0x7041(%rip), %xmm0     # 0xec58
movaps %xmm0, (%r14)
movq 0x20(%rbx), %rdi
movq %r14, %rsi
callq 0x55e0
movq 0x8(%rbx), %rdi
movzbl 0x31(%rbx), %esi
callq 0x5760
movl $0x2, (%r14)
movq 0x20(%rbx), %rdi
movq %r14, %rsi
callq 0x55e0
addq $0x18, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/excess-c64[P]lib1541img/src/lib/1541img/cbmdosvfs.c
// Function: CbmdosVfs_delete
SOEXPORT int CbmdosVfs_delete(CbmdosVfs *self, const CbmdosFile *file)
{
    unsigned pos;
    for (pos = 0; pos < self->fileCount; ++pos)
    {
        if (self->files[pos] == file) break;
    }
    if (pos == self->fileCount)
    {
        logmsg(L_WARNING, "CbmdosVfs_delete: file not found.");
        return -1;
    }
    return CbmdosVfs_deleteAt(self, pos);
}

// Assembly:
pushq %rax
movl 0x28(%rdi), %ecx
testq %rcx, %rcx
je 0x7c9b
movq %rsi, %rax
movq 0x18(%rdi), %rdx
xorl %esi, %esi
cmpq %rax, (%rdx,%rsi,8)
je 0x7c9d
incq %rsi
cmpq %rsi, %rcx
jne 0x7c8b
jmp 0x7ca1
xorl %esi, %esi
cmpl %ecx, %esi
jne 0x7cb9
leaq 0x6f0a(%rip), %rsi      # 0xebb2
movl $0x2, %edi
callq 0x591c
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
popq %rcx
retq
popq %rax
jmp 0x5120
// File: /workspace/github_c_makefile_star2_O3/excess-c64[P]lib1541img/src/lib/1541img/cbmdosvfs.c
// Function: CbmdosVfs_deleteAt
SOEXPORT int CbmdosVfs_deleteAt(CbmdosVfs *self, unsigned pos)
{
    if (pos >= self->fileCount)
    {
        logmsg(L_WARNING, "CbmdosVfs_deleteAt: file not found.");
        return -1;
    }
    CbmdosFile_destroy(self->files[pos]);
    if (pos < --self->fileCount)
    {
        memmove(self->files + pos, self->files + pos + 1,
                (self->fileCount - pos) * sizeof *self->files);
    }
    CbmdosVfsEventArgs args = {
        .what = CVE_FILEDELETED,
        .filepos = pos
    };
    Event_raise(self->changedEvent, &args);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
cmpl %esi, 0x28(%rdi)
jbe 0x7d30
movl %esi, %ebp
movq %rdi, %rbx
movq 0x18(%rdi), %rax
movl %esi, %r14d
movq (%rax,%r14,8), %rdi
callq 0x50e0
movl 0x28(%rbx), %edx
decl %edx
movl %edx, 0x28(%rbx)
subl %ebp, %edx
jbe 0x7d06
movq 0x18(%rbx), %rax
leaq (%rax,%r14,8), %rdi
leaq (%rax,%r14,8), %rsi
addq $0x8, %rsi
shlq $0x3, %rdx
callq 0x5620
leaq 0x8(%rsp), %rsi
movl $0x4, (%rsi)
movq $0x0, 0x8(%rsi)
movl %ebp, 0x10(%rsi)
movl $0x0, 0x14(%rsi)
movq 0x20(%rbx), %rdi
callq 0x55e0
xorl %eax, %eax
jmp 0x7d46
leaq 0x6e9d(%rip), %rsi      # 0xebd4
movl $0x2, %edi
callq 0x591c
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/excess-c64[P]lib1541img/src/lib/1541img/cbmdosvfs.c
// Function: CbmdosVfs_append
SOEXPORT int CbmdosVfs_append(CbmdosVfs *self, CbmdosFile *file)
{
    if (ensureSpace(self) < 0) return -1;
    self->files[self->fileCount++] = file;
    Event_register(CbmdosFile_changedEvent(file), self, fileHandler);
    CbmdosVfsEventArgs args = {
        .what = CVE_FILEADDED,
        .filepos = self->fileCount - 1
    };
    Event_raise(self->changedEvent, &args);
    return 0;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movq %rdi, %rbx
callq 0x7dca
testl %eax, %eax
js 0x7dbd
movq 0x18(%rbx), %rax
movl 0x28(%rbx), %ecx
leal 0x1(%rcx), %edx
movl %edx, 0x28(%rbx)
movq %r14, (%rax,%rcx,8)
movq %r14, %rdi
callq 0x5660
leaq 0xa2(%rip), %rdx        # 0x7e27
movq %rax, %rdi
movq %rbx, %rsi
callq 0x5550
movq %rsp, %rsi
movl $0x3, (%rsi)
movq $0x0, 0x8(%rsi)
movl 0x28(%rbx), %eax
decl %eax
movl %eax, 0x10(%rsi)
movl $0x0, 0x14(%rsi)
movq 0x20(%rbx), %rdi
callq 0x55e0
xorl %eax, %eax
jmp 0x7dc2
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x18, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/excess-c64[P]lib1541img/src/lib/1541img/cbmdosvfs.c
// Function: ensureSpace
static int ensureSpace(CbmdosVfs *self)
{
    if (self->fileCount == self->fileCapa)
    {
        unsigned newCapa = self->fileCapa + DIRCHUNKSIZE;
        if (newCapa <= self->fileCapa)
        {
            logmsg(L_ERROR, "CbmdosVfs: directory overflow.");
            return -1;
        }
        CbmdosFile **newFiles = realloc(self->files,
                newCapa * sizeof *newFiles);
        if (!newFiles)
        {
            logmsg(L_ERROR, "CbmdosVfs: memory allocation failed.");
            return -1;
        }
        self->files = newFiles;
        self->fileCapa = newCapa;
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl 0x28(%rdi), %ebp
xorl %ebx, %ebx
cmpl 0x2c(%rdi), %ebp
jne 0x7e20
subl $0xffffff70, %ebp       # imm = 0xFFFFFF70
jae 0x7e01
movq %rdi, %r14
movq 0x18(%rdi), %rdi
movl %ebp, %esi
shlq $0x3, %rsi
callq 0x5590
testq %rax, %rax
je 0x7e0a
movq %rax, 0x18(%r14)
movl %ebp, 0x2c(%r14)
jmp 0x7e20
leaq 0x6df0(%rip), %rsi      # 0xebf8
jmp 0x7e11
leaq 0x6e06(%rip), %rsi      # 0xec17
movl $0x1, %edi
callq 0x591c
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/excess-c64[P]lib1541img/src/lib/1541img/cbmdosvfs.c
// Function: fileHandler
static void fileHandler(void *receiver, int id, const void *sender,
        const void *args)
{
    (void)id;

    CbmdosVfs *self = receiver;
    unsigned pos;
    for (pos = 0; pos < self->fileCount; ++pos)
    {
        if (self->files[pos] == sender) break;
    }
    CbmdosVfsEventArgs ea = {
        .what = CVE_FILECHANGED,
        .fileEventArgs = args,
        .filepos = pos
    };
    Event_raise(self->changedEvent, &ea);
}

// Assembly:
subq $0x18, %rsp
movl 0x28(%rdi), %esi
testq %rsi, %rsi
je 0x7e4b
movq 0x18(%rdi), %r8
xorl %eax, %eax
cmpq %rdx, (%r8,%rax,8)
je 0x7e4d
incq %rax
cmpq %rax, %rsi
jne 0x7e39
movl %esi, %eax
jmp 0x7e4d
xorl %eax, %eax
movq %rsp, %rsi
movl $0x6, (%rsi)
movq %rcx, 0x8(%rsi)
movl %eax, 0x10(%rsi)
movl $0x0, 0x14(%rsi)
movq 0x20(%rdi), %rdi
callq 0x55e0
addq $0x18, %rsp
retq
// File: /workspace/github_c_makefile_star2_O3/excess-c64[P]lib1541img/src/lib/1541img/cbmdosvfs.c
// Function: CbmdosVfs_insert
SOEXPORT int CbmdosVfs_insert(CbmdosVfs *self, CbmdosFile *file, unsigned pos)
{
    if (pos >= self->fileCount) return CbmdosVfs_append(self, file);
    if (ensureSpace(self) < 0) return -1;
    memmove(self->files + pos + 1, self->files + pos,
            (self->fileCount++ - pos) * sizeof *self->files);
    self->files[pos] = file;
    Event_register(CbmdosFile_changedEvent(file), self, fileHandler);
    CbmdosVfsEventArgs args = {
        .what = CVE_FILEADDED,
        .filepos = pos
    };
    Event_raise(self->changedEvent, &args);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movq %rdi, %rbx
cmpl %edx, 0x28(%rdi)
jbe 0x7f0e
movl %edx, %ebp
movq %rbx, %rdi
callq 0x7dca
testl %eax, %eax
js 0x7f23
movq 0x18(%rbx), %rax
movl %ebp, %r15d
leaq (%rax,%r15,8), %rsi
leaq (%rax,%r15,8), %rdi
addq $0x8, %rdi
movl 0x28(%rbx), %edx
leal 0x1(%rdx), %eax
movl %eax, 0x28(%rbx)
subl %ebp, %edx
shlq $0x3, %rdx
callq 0x5620
movq 0x18(%rbx), %rax
movq %r14, (%rax,%r15,8)
movq %r14, %rdi
callq 0x5660
leaq -0xb4(%rip), %rdx       # 0x7e27
movq %rax, %rdi
movq %rbx, %rsi
callq 0x5550
movq %rsp, %rsi
movl $0x3, (%rsi)
movq $0x0, 0x8(%rsi)
movl %ebp, 0x10(%rsi)
movl $0x0, 0x14(%rsi)
movq 0x20(%rbx), %rdi
callq 0x55e0
xorl %eax, %eax
jmp 0x7f28
movq %rbx, %rdi
movq %r14, %rsi
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x54b0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/excess-c64[P]lib1541img/src/lib/1541img/cbmdosvfs.c
// Function: CbmdosVfs_move
SOEXPORT int CbmdosVfs_move(CbmdosVfs *self, unsigned to, unsigned from)
{
    if (from >= self->fileCount) return -1;
    if (to >= self->fileCount) to = self->fileCount - 1;
    if (to == from) return 0;
    CbmdosFile *tmp = self->files[from];
    if (to > from)
    {
	memmove(self->files + from, self->files + from + 1,
		(to - from) * sizeof *self->files);
    }
    else
    {
	memmove(self->files + to + 1, self->files + to,
		(from - to) * sizeof *self->files);
    }
    self->files[to] = tmp;
    CbmdosVfsEventArgs args = {
	.what = CVE_FILEMOVED,
	.filepos = from,
	.targetpos = to
    };
    Event_raise(self->changedEvent, &args);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl 0x28(%rdi), %eax
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl %edx, %eax
jbe 0x7fd4
movl %edx, %ebp
leal -0x1(%rax), %r15d
cmpl %esi, %eax
cmoval %esi, %r15d
xorl %ebx, %ebx
cmpl %edx, %r15d
je 0x7fd4
movq %rdi, %r14
movq 0x18(%rdi), %rax
movl %ebp, %ecx
movq (%rax,%rcx,8), %r12
movl %r15d, %edx
subl %ebp, %edx
jbe 0x7f8e
leaq (%rax,%rcx,8), %rdi
leaq 0x8(%rdi), %rsi
shlq $0x3, %rdx
callq 0x5620
movl %r15d, %r13d
jmp 0x7fab
movl %r15d, %r13d
leaq (%rax,%r13,8), %rsi
leaq (%rax,%r13,8), %rdi
addq $0x8, %rdi
movl %ebp, %edx
subl %r15d, %edx
shlq $0x3, %rdx
callq 0x5620
movq 0x18(%r14), %rax
movq %r12, (%rax,%r13,8)
movq %rsp, %rsi
movl $0x5, (%rsi)
movq $0x0, 0x8(%rsi)
movl %ebp, 0x10(%rsi)
movl %r15d, 0x14(%rsi)
movq 0x20(%r14), %rdi
callq 0x55e0
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/excess-c64[P]lib1541img/src/lib/1541img/cbmdosvfs.c
// Function: CbmdosVfs_getDirHeader
SOEXPORT void CbmdosVfs_getDirHeader(const CbmdosVfs *self, uint8_t *line)
{
    memset(line, 0xa0, 24);
    line[0] = 0x22;
    line[17] = 0x22;
    line[22] = 0x32;
    line[23] = self->dosver;
    memcpy(line+1, self->name, self->nameLength);
    memcpy(line+19, self->id, self->idLength);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x1(%rsi), %rdi
movabsq $-0x5f5f5f5f5f5f5f60, %rax # imm = 0xA0A0A0A0A0A0A0A0
movq %rax, 0x10(%rsi)
movaps 0x6ae8(%rip), %xmm0     # 0xeaf0
movups %xmm0, 0x1(%rsi)
movb $0x22, %al
movb %al, (%rsi)
movb %al, 0x11(%rsi)
movb $0x32, 0x16(%rsi)
movb 0x32(%r14), %al
movb %al, 0x17(%rsi)
movq (%r14), %rsi
movzbl 0x30(%r14), %edx
callq 0x5470
addq $0x13, %rbx
movq 0x8(%r14), %rsi
movzbl 0x31(%r14), %edx
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x5470
// File: /workspace/github_c_makefile_star2_O3/excess-c64[P]lib1541img/src/lib/1541img/cbmdosvfs.c
// Function: CbmdosVfs_setAutoMapToLc
SOEXPORT void CbmdosVfs_setAutoMapToLc(
	CbmdosVfs *self, int autoMapToLc, int applyToFiles)
{
    if (applyToFiles)
    {
	for (unsigned i = 0; i < self->fileCount; ++i)
	{
	    CbmdosFile_setAutoMapToLc(self->files[i], autoMapToLc);
	}
    }
    self->autoMapToLc = !!autoMapToLc;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebp
movq %rdi, %rbx
testl %edx, %edx
je 0x807b
cmpl $0x0, 0x28(%rbx)
je 0x807b
xorl %r14d, %r14d
movq 0x18(%rbx), %rax
movq (%rax,%r14,8), %rdi
movl %ebp, %esi
callq 0x50d0
incq %r14
movl 0x28(%rbx), %eax
cmpq %rax, %r14
jb 0x8061
xorl %eax, %eax
testl %ebp, %ebp
setne %al
movl %eax, 0x10(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/excess-c64[P]lib1541img/src/lib/1541img/cbmdosvfs.c
// Function: CbmdosVfs_destroy
SOEXPORT void CbmdosVfs_destroy(CbmdosVfs *self)
{
    if (!self) return;
    for (unsigned pos = 0; pos < self->fileCount; ++pos)
    {
        CbmdosFile_destroy(self->files[pos]);
    }
    Event_destroy(self->changedEvent);
    free(self->files);
    free(self->name);
    free(self->id);
    free(self);
}

// Assembly:
testq %rdi, %rdi
je 0x80ee
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpl $0x0, 0x28(%rdi)
je 0x80bc
xorl %r14d, %r14d
movq 0x18(%rbx), %rax
movq (%rax,%r14,8), %rdi
callq 0x50e0
incq %r14
movl 0x28(%rbx), %eax
cmpq %rax, %r14
jb 0x80a4
movq 0x20(%rbx), %rdi
callq 0x5170
movq 0x18(%rbx), %rdi
callq 0x5080
movq (%rbx), %rdi
callq 0x5080
movq 0x8(%rbx), %rdi
callq 0x5080
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x5080
retq
nop
// File: /workspace/github_c_makefile_star2_O3/excess-c64[P]lib1541img/src/lib/1541img/cbmdosvfsreader.c
// Function: parseTrackBam
static int parseTrackBam(uint8_t *bamdata, uint8_t sectors,
	const uint8_t *trackbam)
{
    uint8_t tmp[21] = {0};
    uint8_t sectfree = 0;
    for (uint8_t sectno = 0; sectno < sectors; ++sectno)
    {
	if (trackbam[1+sectno/8] & (1U << (sectno%8)))
	{
	    ++sectfree;
	}
	else
	{
	    tmp[sectno] = 1;
	}
    }
    if (bamdata) memcpy(bamdata, tmp, 21);
    if (sectfree != trackbam[0]) return -1;
    return 0;
}

// Assembly:
xorps %xmm0, %xmm0
movaps %xmm0, -0x18(%rsp)
movq $0x0, -0xb(%rsp)
testl %esi, %esi
je 0x8a10
movzbl %sil, %eax
xorl %esi, %esi
xorl %ecx, %ecx
movl %esi, %r8d
shrl $0x3, %r8d
movzbl 0x1(%rdx,%r8), %r8d
movl %esi, %r9d
andl $0x7, %r9d
btl %r9d, %r8d
jae 0x8a01
incb %cl
jmp 0x8a06
movb $0x1, -0x18(%rsp,%rsi)
incq %rsi
cmpq %rsi, %rax
jne 0x89e3
jmp 0x8a12
xorl %ecx, %ecx
testq %rdi, %rdi
je 0x8a28
movq -0xb(%rsp), %rax
movq %rax, 0xd(%rdi)
movaps -0x18(%rsp), %xmm0
movups %xmm0, (%rdi)
xorl %eax, %eax
cmpb (%rdx), %cl
setne %al
negl %eax
retq
// File: /workspace/github_c_makefile_star2_O3/excess-c64[P]lib1541img/src/lib/1541img/cbmdosvfsreader.c
// Function: readCbmdosVfs
SOEXPORT int readCbmdosVfs(CbmdosVfs *vfs, const D64 *d64,
	const CbmdosFsOptions *options)
{
    CbmdosFsOptions probeopts = CFO_DEFAULT;
    if (!options)
    {
	if (probeCbmdosFsOptions(&probeopts, d64) < 0) return -1;
	options = &probeopts;
    }
    return readCbmdosVfsInternal(vfs, d64, options, 0, 0);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
movq 0xb595(%rip), %rax      # 0x13fe0
movq (%rax), %rax
movq %rax, 0x8(%rsp)
testq %rdx, %rdx
jne 0x8a6c
leaq 0x8(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x5370
testl %eax, %eax
js 0x8a89
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x80f0
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x8a7f
// File: /workspace/github_c_makefile_star2_O3/excess-c64[P]lib1541img/src/lib/1541img/d64reader.c
// Function: readD64FromFileData
SOEXPORT D64 *readD64FromFileData(const FileData *file)
{
    size_t size = FileData_size(file);
    D64Type type;

    switch (size)
    {
        case 174848UL:
        case 175531UL:
            type = D64_STANDARD;
            break;
        case 196608UL:
        case 197376UL:
            type = D64_40TRACK;
            break;
        case 205312UL:
        case 206114UL:
            type = D64_42TRACK;
            break;
        default:
            logmsg(L_WARNING, "readD64FromFileData: not a valid D64 file.");
            return 0;
    }

    D64 *d64 = D64_create(type);
    const uint8_t *bytes = FileData_rcontent(file);
    uint8_t tracks = D64_tracks(d64);
    for (uint8_t trackno = 1; trackno <= tracks; ++trackno)
    {
        Track *track = D64_track(d64, trackno);
        uint8_t sectors = Track_sectors(track);
        for (uint8_t sectno = 0; sectno < sectors; ++sectno)
        {
            uint8_t *sectbytes = Sector_content(Track_sector(track, sectno));
            memcpy(sectbytes, bytes, 256);
            bytes += 256;
        }
    }
    return d64;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
callq 0x5500
cmpq $0x302ff, %rax          # imm = 0x302FF
jg 0x924b
xorl %edi, %edi
cmpq $0x2ab00, %rax          # imm = 0x2AB00
je 0x926f
cmpq $0x2adab, %rax          # imm = 0x2ADAB
je 0x926f
cmpq $0x30000, %rax          # imm = 0x30000
je 0x9263
leaq 0x5c41(%rip), %rsi      # 0xee75
movl $0x2, %edi
callq 0x591c
movq $0x0, (%rsp)
jmp 0x92f4
cmpq $0x32522, %rax          # imm = 0x32522
je 0x926a
cmpq $0x32200, %rax          # imm = 0x32200
je 0x926a
cmpq $0x30300, %rax          # imm = 0x30300
jne 0x922d
movl $0x1, %edi
jmp 0x926f
movl $0x2, %edi
callq 0x55c0
movq %rax, %rbx
movq %r14, %rdi
callq 0x5640
movq %rax, %r14
movq %rbx, (%rsp)
movq %rbx, %rdi
callq 0x55f0
testb %al, %al
je 0x92f4
movl %eax, %ebp
movb $0x1, %bl
movzbl %bl, %esi
movq (%rsp), %rdi
callq 0x5280
movq %rax, %r15
movq %rax, %rdi
callq 0x5740
testb %al, %al
je 0x92ed
movl %eax, %r12d
xorl %r13d, %r13d
movzbl %r13b, %r13d
movq %r15, %rdi
movl %r13d, %esi
callq 0x5090
movq %rax, %rdi
callq 0x5690
movl $0x100, %edx            # imm = 0x100
movq %rax, %rdi
movq %r14, %rsi
callq 0x5470
addq $0x100, %r14            # imm = 0x100
incb %r13b
cmpb %r13b, %r12b
jne 0x92b7
incb %bl
cmpb %bpl, %bl
jbe 0x9296
movq (%rsp), %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/excess-c64[P]lib1541img/src/lib/1541img/d64reader.c
// Function: readD64
SOEXPORT D64 *readD64(FILE *file)
{
    FileData *data = readHostFile(file);
    if (!data)
    {
        logmsg(L_WARNING, "readD64: error reading file.");
        return 0;
    }

    D64 *d64 = readD64FromFileData(data);
    FileData_destroy(data);
    return d64;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
callq 0x52d0
testq %rax, %rax
je 0x9330
movq %rax, %rbx
movq %rax, %rdi
callq 0x5200
movq %rax, %r14
movq %rbx, %rdi
callq 0x53d0
movq %r14, %rax
jmp 0x9343
leaq 0x5b69(%rip), %rsi      # 0xeea0
movl $0x2, %edi
callq 0x591c
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_c_makefile_star2_O3/excess-c64[P]lib1541img/src/lib/1541img/zc45compressor.c
// Function: compressZc45
SOEXPORT ZcFileSet *compressZc45(const D64 *d64)
{
    char name[17];
    uint8_t buf[MAXZCFILESIZE];
    if (!d64) return 0;
    D64Type type = D64_type(d64);
    const uint8_t *bam = Sector_rcontent(D64_rsector(d64, 18, 0));
    int namelen = 16;
    while (namelen && bam[0x8f + namelen] == 0xa0) --namelen;
    memcpy(name, bam+0x90, namelen);
    name[namelen] = 0;

    ZcFileSet *compressed = ZcFileSet_create(
            type == D64_STANDARD ? ZT_4PACK : ZT_5PACK, name);

    for (int i = 0; i < (type == D64_STANDARD ? 4 : 5); ++i)
    {
        size_t filelen = zc45_write(buf, MAXZCFILESIZE, i+1, d64);
        if (!filelen)
        {
            logfmt(L_ERROR, "compressZc45: compression failed in part %d.",
                    i+1);
            ZcFileSet_destroy(compressed);
            return 0;
        }
        FileData *fd = ZcFileSet_fileData(compressed, i);
        if (FileData_append(fd, buf, filelen) < 0)
        {
            logfmt(L_ERROR, "compressZc45: compression failed in part %d.",
                    i+1);
            ZcFileSet_destroy(compressed);
            return 0;
        }
    }

    logfmt(L_DEBUG, "compressZc45: %d-file zipcode successfully created.",
            type == D64_40TRACK ? 5 : 4);
    return compressed;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb098, %rsp           # imm = 0xB098
testq %rdi, %rdi
je 0x9968
movq %rdi, %r14
callq 0x5430
movl %eax, %ebp
xorl %ebx, %ebx
movq %r14, %rdi
movl $0x12, %esi
xorl %edx, %edx
callq 0x50c0
movq %rax, %rdi
callq 0x5670
xorl %ecx, %ecx
movq %r14, 0x8(%rsp)
cmpb $-0x60, 0x9f(%rax,%rcx)
jne 0x9881
decq %rcx
cmpq $-0x10, %rcx
jne 0x986c
jmp 0x9888
addq $0x10, %rcx
movq %rcx, %rbx
addq $0x90, %rax
movslq %ebx, %rbx
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x5470
movb $0x0, 0x10(%rsp,%rbx)
xorl %r15d, %r15d
movl %ebp, 0x4(%rsp)
testl %ebp, %ebp
setne %r15b
movl %r15d, %edi
movq %r14, %rsi
callq 0x51f0
movq %rax, %r14
orl $0x4, %r15d
xorl %r13d, %r13d
leaq 0x30(%rsp), %r12
cmpl %r13d, %r15d
je 0x9925
leal 0x1(%r13), %ebp
movl $0xb060, %esi           # imm = 0xB060
movq %r12, %rdi
movl %ebp, %edx
movq 0x8(%rsp), %rcx
callq 0x5210
testq %rax, %rax
je 0x9947
movq %rax, %rbx
movq %r14, %rdi
movl %r13d, %esi
callq 0x5730
movq %rax, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x5720
movl %ebp, %r13d
testl %eax, %eax
jns 0x98d0
leaq 0x5729(%rip), %rsi      # 0xf045
movl $0x1, %edi
movl %ebp, %edx
jmp 0x9959
xorl %edx, %edx
cmpl $0x1, 0x4(%rsp)
sete %dl
orl $0x4, %edx
leaq 0x5739(%rip), %rsi      # 0xf072
movl $0x4, %edi
xorl %eax, %eax
callq 0x5949
jmp 0x996b
incl %r13d
leaq 0x56f4(%rip), %rsi      # 0xf045
movl $0x1, %edi
movl %r13d, %edx
xorl %eax, %eax
callq 0x5949
movq %r14, %rdi
callq 0x5750
xorl %r14d, %r14d
movq %r14, %rax
addq $0xb098, %rsp           # imm = 0xB098
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/excess-c64[P]lib1541img/src/lib/1541img/event.c
// Function: Event_create
SOEXPORT Event *Event_create(int id, const void *sender)
{
    Event *self = xmalloc(sizeof *self);
    self->sender = sender;
    self->handlers = 0;
    self->size = 0;
    self->capa = 0;
    self->id = id;
    return self;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rsi, %rbx
movl %edi, %ebp
movl $0x28, %edi
callq 0x585c
movq %rbx, (%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
movq $0x0, 0x18(%rax)
movl %ebp, 0x20(%rax)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/excess-c64[P]lib1541img/src/lib/1541img/event.c
// Function: Event_register
SOEXPORT void Event_register(Event *self, void *receiver, EventHandler handler)
{
    if (self->size == self->capa)
    {
        self->capa += EVCHUNKSIZE;
        self->handlers = xrealloc(self->handlers,
                self->capa * sizeof *self->handlers);
    }
    self->handlers[self->size].receiver = receiver;
    self->handlers[self->size].handler = handler;
    ++self->size;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movq 0x10(%rdi), %rsi
cmpq 0x18(%rdi), %rsi
jne 0x99e5
addq $0x4, %rsi
movq %rsi, 0x18(%rbx)
movq 0x8(%rbx), %rdi
shlq $0x4, %rsi
callq 0x587c
movq %rax, 0x8(%rbx)
movq 0x10(%rbx), %rsi
jmp 0x99e9
movq 0x8(%rbx), %rax
movq %rsi, %rcx
shlq $0x4, %rcx
movq %r15, (%rax,%rcx)
movq %r14, 0x8(%rax,%rcx)
incq %rsi
movq %rsi, 0x10(%rbx)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/excess-c64[P]lib1541img/src/lib/1541img/event.c
// Function: Event_unregister
SOEXPORT void Event_unregister(
	Event *self, void *receiver, EventHandler handler)
{
    size_t pos;
    for (pos = 0; pos < self->size; ++pos)
    {
        if (self->handlers[pos].receiver == receiver
                && self->handlers[pos].handler == handler)
        {
            break;
        }
    }
    if (pos < self->size)
    {
        --self->size;
        if (pos < self->size)
        {
            memmove(self->handlers + pos, self->handlers + pos + 1,
                    (self->size - pos) * sizeof *self->handlers);
        }
    }
}

// Assembly:
movq %rdx, %rcx
movq 0x10(%rdi), %rdx
testq %rdx, %rdx
je 0x9a38
movq %rdi, %rax
movq 0x8(%rdi), %rdi
xorl %r8d, %r8d
xorl %r9d, %r9d
cmpq %rsi, (%rdi,%r8)
jne 0x9a2c
cmpq %rcx, 0x8(%rdi,%r8)
je 0x9a39
incq %r9
addq $0x10, %r8
cmpq %r9, %rdx
jne 0x9a1f
retq
leaq -0x1(%rdx), %rcx
movq %rcx, 0x10(%rax)
cmpq %rcx, %r9
jae 0x9a38
leaq (%rdi,%r8), %rsi
addq $0x10, %rsi
addq %r8, %rdi
shlq $0x4, %rdx
subq %r8, %rdx
addq $-0x10, %rdx
jmp 0x5620
// File: /workspace/github_c_makefile_star2_O3/excess-c64[P]lib1541img/src/lib/1541img/cbmdosfs.c
// Function: CbmdosFs_create
SOEXPORT CbmdosFs *CbmdosFs_create(CbmdosFsOptions options)
{
    if (validateOptions(options) < 0) return 0;
    CbmdosFs *self = xmalloc(sizeof *self);
    memset(self, 0, sizeof *self);
    D64Type d64Type = D64_STANDARD;
    if (options.flags & CFF_42TRACK) d64Type = D64_42TRACK;
    else if (options.flags & CFF_40TRACK) d64Type = D64_40TRACK;
    self->d64 = D64_create(d64Type);
    self->dir.capa = DIRCHUNK;
    self->dir.entries = xmalloc(DIRCHUNK * sizeof *self->dir.entries);
    self->vfs = CbmdosVfs_create();
    if (options.flags & CFF_PROLOGICDOSBAM)
    {
	CbmdosVfs_setDosver(self->vfs, 0x50);
    }
    self->options = options;
    self->bam[17][0] = 1;
    updateDir(self);
    updateBam(self);
    Event_register(CbmdosVfs_changedEvent(self->vfs), self, vfsChanged);
    return self;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %r14
callq 0x9b99
testl %eax, %eax
js 0x9b8e
movq %r14, %r15
shrq $0x20, %r15
movl $0x3a0, %edi            # imm = 0x3A0
callq 0x585c
movq %rax, %rbx
movl $0x3a0, %edx            # imm = 0x3A0
movq %rax, %rdi
xorl %esi, %esi
callq 0x5320
movl %r14d, %eax
shrl $0x2, %eax
andl $0x1, %eax
testb $0x8, %r14b
movl $0x2, %edi
cmovel %eax, %edi
callq 0x55c0
movq %rax, (%rbx)
movl $0x90, 0x1c(%rbx)
movl $0x360, %edi            # imm = 0x360
callq 0x585c
movq %rax, 0x10(%rbx)
callq 0x5520
movq %rax, 0x8(%rbx)
testb $0x40, %r14b
je 0x9b52
movq %rax, %rdi
movl $0x50, %esi
callq 0x5600
movl %r14d, 0x24(%rbx)
movl %r15d, 0x28(%rbx)
movb $0x1, 0x191(%rbx)
movq %rbx, %rdi
callq 0x9c0b
movq %rbx, %rdi
callq 0x9eba
movq 0x8(%rbx), %rdi
callq 0x51e0
leaq 0x4aa(%rip), %rdx       # 0xa02b
movq %rax, %rdi
movq %rbx, %rsi
callq 0x5550
jmp 0x9b90
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/excess-c64[P]lib1541img/src/lib/1541img/cbmdosfs.c
// Function: validateOptions
static int validateOptions(CbmdosFsOptions options)
{
    if ((options.flags & (CFF_SPEEDDOSBAM | CFF_DOLPHINDOSBAM))
	    && (options.flags & CFF_PROLOGICDOSBAM))
    {
	logmsg(L_ERROR, "Cannot combine Prologic DOS extended BAM with any "
		"other extended BAM formats.");
	return -1;
    }
    if ((options.flags & CFF_TALLOC_TRACKLOAD)
	    && (options.flags & CFF_TALLOC_SIMPLE))
    {
	logmsg(L_ERROR, "Cannot combine `trackload' track allocation strategy "
		"with `simple' track allocation strategy.");
	return -1;
    }
    if (options.dirInterleave < 1 || options.dirInterleave > 20
            || options.fileInterleave < 1 || options.fileInterleave > 20)
    {
        logmsg(L_ERROR, "Cannot set interleave values outside the range from "
                "1 to 20.");
        return -1;
    }
    return 0;
}

// Assembly:
testb $0x30, %dil
setne %al
movl %edi, %ecx
andl $0x40, %ecx
shrl $0x6, %ecx
testb %cl, %al
jne 0x9bc0
movl %edi, %eax
notl %eax
testl $0xc00, %eax            # imm = 0xC00
jne 0x9bdc
leaq 0x5761(%rip), %rsi      # 0xf31f
jmp 0x9bc7
leaq 0x570a(%rip), %rsi      # 0xf2d1
pushq %rax
movl $0x1, %edi
callq 0x591c
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
retq
movq %rdi, %rcx
shrq $0x20, %rcx
movl $0xff, %eax
andl %eax, %ecx
addl $-0x15, %ecx
leaq 0x5789(%rip), %rsi      # 0xf37d
cmpl $-0x14, %ecx
jb 0x9bc7
shrq $0x28, %rdi
andl %eax, %edi
addl $-0x15, %edi
xorl %eax, %eax
cmpl $-0x15, %edi
ja 0x9bdb
jmp 0x9bc7
// File: /workspace/github_c_makefile_star2_O3/excess-c64[P]lib1541img/src/lib/1541img/cbmdosfs.c
// Function: updateBam
static void updateBam(CbmdosFs *self)
{
    uint8_t *bam = Sector_content(D64_sector(self->d64, 18, 0));
    memset(bam, 0, 256);
    bam[0] = 18;
    bam[1] = 1;
    bam[2] = CbmdosVfs_dosver(self->vfs);
    for (uint8_t trackno = 1; trackno <= D64_tracks(self->d64); ++trackno)
    {
        if (trackno < 36)
        {
            createTrackBam(self, bam + 4*trackno, trackno);
        }
        else if (trackno < 41)
        {
            if (self->options.flags & CFF_DOLPHINDOSBAM)
            {
                createTrackBam(self, bam + 0x1c + 4*trackno, trackno);
            }
            if (self->options.flags & CFF_SPEEDDOSBAM)
            {
                createTrackBam(self, bam + 0x30 + 4*trackno, trackno);
            }
            if (self->options.flags & CFF_PROLOGICDOSBAM)
            {
                createTrackBam(self, bam + 4*trackno, trackno);
            }
        }
    }
    uint8_t nameoffset = 0;
    if (self->options.flags & CFF_PROLOGICDOSBAM) nameoffset = 0x14;
    memset(bam+0x90+nameoffset, 0xa0, 0x1b);
    bam[0xa5+nameoffset] = 0x32;
    bam[0xa6+nameoffset] = CbmdosVfs_dosver(self->vfs);
    uint8_t length;
    const char *name = CbmdosVfs_name(self->vfs, &length);
    memcpy(bam+0x90+nameoffset, name, length);
    const char *id = CbmdosVfs_id(self->vfs, &length);
    memcpy(bam+0xa2+nameoffset, id, length);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rdi), %rdi
movl $0x12, %esi
xorl %edx, %edx
callq 0x5030
movq %rax, %rdi
callq 0x5690
movq %rax, %r14
leaq 0x2(%rax), %rdi
movl $0xfe, %edx
xorl %esi, %esi
callq 0x5320
movw $0x112, (%r14)          # imm = 0x112
movq 0x8(%rbx), %rdi
callq 0x5560
movb %al, 0x2(%r14)
movq (%rbx), %rdi
callq 0x55f0
testb %al, %al
je 0x9f96
leaq 0x1c(%r14), %r15
leaq 0x30(%r14), %r12
movb $0x1, %bpl
movl $0x1, %r13d
cmpb $0x24, %bpl
jae 0x9f41
movl %r13d, %eax
leaq (%r14,%rax,4), %rsi
movzbl %bpl, %edx
movq %rbx, %rdi
callq 0xafa3
jmp 0x9f82
cmpb $0x28, %bpl
ja 0x9f82
movl 0x24(%rbx), %eax
testb $0x10, %al
je 0x9f64
movl %r13d, %eax
leaq (%r15,%rax,4), %rsi
movzbl %bpl, %edx
movq %rbx, %rdi
callq 0xafa3
movl 0x24(%rbx), %eax
testb $0x20, %al
je 0x9f7e
movl %r13d, %eax
leaq (%r12,%rax,4), %rsi
movzbl %bpl, %edx
movq %rbx, %rdi
callq 0xafa3
movl 0x24(%rbx), %eax
testb $0x40, %al
jne 0x9f2c
incb %bpl
movzbl %bpl, %r13d
movq (%rbx), %rdi
callq 0x55f0
cmpb %al, %r13b
jbe 0x9f26
leaq 0x14(%r14), %r15
testb $0x40, 0x24(%rbx)
cmoveq %r14, %r15
leaq 0x90(%r15), %r14
movaps 0x4b40(%rip), %xmm0     # 0xeaf0
movups %xmm0, 0x9b(%r15)
movups %xmm0, 0x90(%r15)
movb $0x32, 0xa5(%r15)
movq 0x8(%rbx), %rdi
callq 0x5560
movb %al, 0xa6(%r15)
movq 0x8(%rbx), %rdi
leaq 0x7(%rsp), %r12
movq %r12, %rsi
callq 0x5190
movzbl (%r12), %edx
movq %r14, %rdi
movq %rax, %rsi
callq 0x5470
movq 0x8(%rbx), %rdi
movq %r12, %rsi
callq 0x53e0
addq $0xa2, %r15
movzbl (%r12), %edx
movq %r15, %rdi
movq %rax, %rsi
callq 0x5470
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/excess-c64[P]lib1541img/src/lib/1541img/cbmdosfs.c
// Function: CbmdosFs_destroy
SOEXPORT void CbmdosFs_destroy(CbmdosFs *self)
{
    if (!self) return;
    free(self->dir.entries);
    CbmdosVfs_destroy(self->vfs);
    D64_destroy(self->d64);
    free(self);
}

// Assembly:
testq %rdi, %rdi
je 0xa459
pushq %rbx
movq %rdi, %rbx
movq 0x10(%rdi), %rdi
callq 0x5080
movq 0x8(%rbx), %rdi
callq 0x5490
movq (%rbx), %rdi
callq 0x55b0
movq %rbx, %rdi
popq %rbx
jmp 0x5080
retq
// File: /workspace/github_c_makefile_star2_O3/excess-c64[P]lib1541img/src/lib/1541img/cbmdosfs.c
// Function: CbmdosFs_fromVfs
SOEXPORT CbmdosFs *CbmdosFs_fromVfs(CbmdosVfs *vfs, CbmdosFsOptions options)
{
    if (validateOptions(options) < 0) return 0;
    CbmdosFs *self = xmalloc(sizeof *self);
    memset(self, 0, sizeof *self);
    self->dir.capa = DIRCHUNK;
    self->dir.size = CbmdosVfs_fileCount(vfs);
    while (self->dir.capa < self->dir.size)
    {
	self->dir.capa += DIRCHUNK;
    }
    self->dir.entries = xmalloc(self->dir.capa * sizeof *self->dir.entries);
    if ((options.flags & CFF_PROLOGICDOSBAM)
	    && CbmdosVfs_dosver(vfs) == 0x41)
    {
	CbmdosVfs_setDosver(vfs, 0x50);
    }
    self->vfs = vfs;
    self->options = options;
    if (CbmdosFs_rewrite(self) < 0)
    {
	self->vfs = 0;
	CbmdosFs_destroy(self);
	return 0;
    }
    Event_register(CbmdosVfs_changedEvent(self->vfs), self, vfsChanged);
    return self;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %r15
movq %rsi, %rdi
callq 0x9b99
testl %eax, %eax
js 0xa537
movq %r14, %r12
shrq $0x20, %r12
movl $0x3a0, %edi            # imm = 0x3A0
callq 0x585c
movq %rax, %rbx
movl $0x3a0, %edx            # imm = 0x3A0
movq %rax, %rdi
xorl %esi, %esi
callq 0x5320
movl $0x90, 0x1c(%rbx)
movq %r15, %rdi
callq 0x5240
movl %eax, 0x18(%rbx)
movl 0x1c(%rbx), %ecx
cmpl %eax, %ecx
jae 0xa4c1
addl $0x90, %ecx
cmpl %eax, %ecx
jb 0xa4b4
movl %ecx, 0x1c(%rbx)
movl %ecx, %eax
addq %rax, %rax
leaq (%rax,%rax,2), %rdi
callq 0x585c
movq %rax, 0x10(%rbx)
testb $0x40, %r14b
je 0xa4f2
movq %r15, %rdi
callq 0x5560
cmpb $0x41, %al
jne 0xa4f2
movq %r15, %rdi
movl $0x50, %esi
callq 0x5600
movq %r15, 0x8(%rbx)
movl %r14d, 0x24(%rbx)
movl %r12d, 0x28(%rbx)
movq %rbx, %rdi
callq 0x5770
testl %eax, %eax
js 0xa527
movq 0x8(%rbx), %rdi
callq 0x51e0
leaq -0x4ef(%rip), %rdx      # 0xa02b
movq %rax, %rdi
movq %rbx, %rsi
callq 0x5550
jmp 0xa539
movq $0x0, 0x8(%rbx)
movq %rbx, %rdi
callq 0x5460
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/excess-c64[P]lib1541img/src/lib/1541img/cbmdosfs.c
// Function: CbmdosFs_rewrite
SOEXPORT int CbmdosFs_rewrite(CbmdosFs *self)
{
    D64_destroy(self->d64);
    D64Type d64Type = D64_STANDARD;
    if (self->options.flags & CFF_42TRACK) d64Type = D64_42TRACK;
    else if (self->options.flags & CFF_40TRACK) d64Type = D64_40TRACK;
    self->d64 = D64_create(d64Type);
    self->status = CFS_OK;
    memset(self->dir.entries, 0, self->dir.size * sizeof *self->dir.entries);
    memset(self->bam, 0, sizeof self->bam);
    self->bam[17][0] = 1;
    if (updateDir(self) < 0)
    {
	self->status |= CFS_DIRFULL;
	return -1;
    }
    for (unsigned pos = 0; pos < self->dir.size; ++pos)
    {
	if (updateFile(self, pos) < 0)
	{
	    self->status |= CFS_DISKFULL;
	    return -1;
	}
    }
    updateDir(self);
    updateBam(self);
    return 0;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rdi), %rdi
callq 0x55b0
movl 0x24(%rbx), %eax
movl %eax, %ecx
shrl $0x2, %ecx
andl $0x1, %ecx
testb $0x8, %al
movl $0x2, %edi
cmovel %ecx, %edi
callq 0x55c0
movq %rax, (%rbx)
movl $0x0, 0x20(%rbx)
movq 0x10(%rbx), %rdi
movl 0x18(%rbx), %eax
addq %rax, %rax
leaq (%rax,%rax,2), %rdx
xorl %esi, %esi
callq 0x5320
leaq 0x2c(%rbx), %rdi
movl $0x372, %edx            # imm = 0x372
xorl %esi, %esi
callq 0x5320
movb $0x1, 0x191(%rbx)
movq %rbx, %rdi
callq 0x9c0b
testl %eax, %eax
js 0xa5e3
cmpl $0x0, 0x18(%rbx)
je 0xa5cf
xorl %ebp, %ebp
movq %rbx, %rdi
movl %ebp, %esi
callq 0xa6c1
testl %eax, %eax
js 0xa5e9
incl %ebp
cmpl 0x18(%rbx), %ebp
jb 0xa5ba
movq %rbx, %rdi
callq 0x9c0b
movq %rbx, %rdi
callq 0x9eba
xorl %eax, %eax
jmp 0xa5f2
orb $0x4, 0x20(%rbx)
jmp 0xa5ed
orb $0x2, 0x20(%rbx)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/excess-c64[P]lib1541img/src/lib/1541img/cbmdosfs.c
// Function: CbmdosFs_setOptions
SOEXPORT int CbmdosFs_setOptions(CbmdosFs *self, CbmdosFsOptions options)
{
    int needRewrite = CbmdosFs_optionsWillRewrite(self, options);
    if (needRewrite < 0) return -1;
    CbmdosFsFlags changedFlags = self->options.flags ^ options.flags;
    self->options = options;
    if (needRewrite)
    {
        CbmdosFs_rewrite(self);
        return 1;
    }
    else if (changedFlags & (CFF_SPEEDDOSBAM|CFF_DOLPHINDOSBAM
                |CFF_PROLOGICDOSBAM|CFF_ZEROFREE))
    {
        updateBam(self);
        return 1;
    }
    return 0;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
callq 0x56f0
testl %eax, %eax
js 0xa636
movl 0x24(%rbx), %eax
movq %r14, 0x24(%rbx)
je 0xa63d
movq %rbx, %rdi
callq 0x5770
jmp 0xa64c
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0xa651
xorl %r14d, %eax
testb $-0x10, %al
je 0xa659
movq %rbx, %rdi
callq 0x9eba
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
xorl %eax, %eax
jmp 0xa651
// File: /workspace/github_c_makefile_star2_O3/excess-c64[P]lib1541img/src/lib/1541img/cbmdosfs.c
// Function: CbmdosFs_optionsWillRewrite
SOEXPORT int CbmdosFs_optionsWillRewrite(
	const CbmdosFs *self, CbmdosFsOptions options)
{
    if (validateOptions(options) < 0) return -1;
    CbmdosFsFlags changedFlags = self->options.flags ^ options.flags;
    if (changedFlags & (
		CFF_FILESONDIRTRACK|CFF_ALLOWLONGDIR|CFF_42TRACK|
		CFF_SIMPLEINTERLEAVE|CFF_TALLOC_TRACKLOAD|CFF_TALLOC_SIMPLE|
		CFF_TALLOC_PREFDIRTRACK|CFF_TALLOC_CHAININTERLV))
    {
	return 1;
    }
    if (!(self->options.flags & CFF_42TRACK) && (changedFlags & CFF_40TRACK))
    {
        return 1;
    }
    if (options.dirInterleave != self->options.dirInterleave) return 1;
    if (options.fileInterleave != self->options.fileInterleave) return 1;
    return 0;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq %rsi, %rdi
callq 0x9b99
testl %eax, %eax
js 0xa6b4
movl 0x24(%r14), %edx
movl %edx, %ecx
xorl %ebx, %ecx
movl $0x1, %eax
testl $0x3e0b, %ecx           # imm = 0x3E0B
jne 0xa6b9
testb $0x8, %dl
sete %dl
andl $0x4, %ecx
shrl $0x2, %ecx
testb %cl, %dl
jne 0xa6b9
movq %rbx, %rcx
shrq $0x20, %rcx
cmpb %cl, 0x28(%r14)
jne 0xa6b9
shrq $0x28, %rbx
xorl %eax, %eax
cmpb %bl, 0x29(%r14)
setne %al
jmp 0xa6b9
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/excess-c64[P]lib1541img/src/lib/1541img/cbmdosfs.c
// Function: CbmdosFs_freeBlocks
SOEXPORT uint16_t CbmdosFs_freeBlocks(const CbmdosFs *self)
{
    uint16_t free = 664;
    if (self->options.flags & CFF_42TRACK)
    {
	free += 119;
    }
    else if (self->options.flags & CFF_40TRACK)
    {
	free += 85;
    }
    unsigned filecount = CbmdosVfs_fileCount(self->vfs);
    if (filecount > 144)
    {
	if (!(self->options.flags & CFF_ALLOWLONGDIR)) return 0xffff;
	unsigned extrafiles = filecount - 144;
	unsigned dirblocks = extrafiles / 8;
	if (extrafiles % 8) ++dirblocks;
	if (dirblocks > free) return 0xffff;
	free -= dirblocks;
    }
    else if (self->options.flags & CFF_FILESONDIRTRACK)
    {
	unsigned freefiles = 144 - filecount;
	unsigned freedirblocks = freefiles / 8;
	free += freedirblocks;
    }
    for (unsigned n = 0; n < filecount; ++n)
    {
	const CbmdosFile *file = CbmdosVfs_rfile(self->vfs, n);
	uint16_t fileBlocks = CbmdosFile_realBlocks(file);
        if (CbmdosFile_type(file) == CFT_REL)
        {
            uint8_t sidesects = fileBlocks / 120 + !!(fileBlocks % 120);
            fileBlocks += sidesects;
        }
	if (fileBlocks > free) return 0xffff;
	free -= fileBlocks;
    }
    return free;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl 0x24(%rdi), %eax
testb $0x4, %al
movl $0x298, %ecx            # imm = 0x298
movl $0x2ed, %edx            # imm = 0x2ED
cmovel %ecx, %edx
testb $0x8, %al
movl $0x30f, %r15d           # imm = 0x30F
cmovel %edx, %r15d
movq 0x8(%rdi), %rdi
callq 0x5240
movl %eax, %r14d
movl 0x24(%rbx), %eax
cmpl $0x91, %r14d
jb 0xabff
movw $0xffff, %bp            # imm = 0xFFFF
testb $0x1, %al
je 0xac8f
leal -0x90(%r14), %eax
shrl $0x3, %eax
movl %r14d, %ecx
andl $0x7, %ecx
cmpl $0x1, %ecx
sbbl $-0x1, %eax
movzwl %r15w, %ecx
cmpl %ecx, %eax
ja 0xac8f
subl %eax, %ecx
movl %ecx, %ebp
jmp 0xac1d
andl $0x2, %eax
movl $0x90, %ecx
subl %r14d, %ecx
shrl $0x3, %ecx
testl %eax, %eax
cmovel %eax, %ecx
movzwl %r15w, %ebp
addl %ecx, %ebp
testl %r14d, %r14d
je 0xac8f
xorl %r15d, %r15d
movq 0x8(%rbx), %rdi
movl %r15d, %esi
callq 0x5340
movq %rax, %r13
movq %rax, %rdi
callq 0x5680
movl %eax, %r12d
movq %r13, %rdi
callq 0x5780
cmpl $0x4, %eax
jne 0xac78
movzwl %r12w, %eax
imull $0x8889, %eax, %eax     # imm = 0x8889
shrl $0x16, %eax
imull $0xffffeeef, %r12d, %ecx # imm = 0xFFFFEEEF
rorw $0x3, %cx
movzwl %cx, %ecx
xorl %edx, %edx
cmpl $0x223, %ecx            # imm = 0x223
setae %dl
addl %eax, %edx
movzbl %dl, %eax
addl %r12d, %eax
movl %eax, %r12d
cmpw %r12w, %bp
jb 0xac8b
subl %r12d, %ebp
incl %r15d
cmpl %r15d, %r14d
jne 0xac20
jmp 0xac8f
movw $0xffff, %bp            # imm = 0xFFFF
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/excess-c64[P]lib1541img/src/lib/1541img/cbmdosfs.c
// Function: CbmdosFs_getFreeBlocksLine
SOEXPORT void CbmdosFs_getFreeBlocksLine(const CbmdosFs *self, uint8_t *line)
{
    uint16_t rawFree = CbmdosFs_freeBlocks(self);
    int free = (rawFree == 0xffff) ? -1 : rawFree;
    if (free > 0 && (self->options.flags & CFF_ZEROFREE)) free = 0;
    char freestr[4];
    snprintf(freestr, sizeof freestr, "%d", free);
    memset(line, 0xa0, 16);
    const char *blocksfree = " BLOCKS FREE.";
    uint8_t *w = line;
    const char *r = freestr;
    while (*r) *w++ = *r++;
    r = blocksfree;
    while (*r) *w++ = *r++;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
callq 0x53c0
movzwl %ax, %eax
cmpw $-0x1, %ax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmovnel %eax, %ecx
testl %ecx, %ecx
jle 0xaccc
xorl %eax, %eax
testb $-0x80, 0x24(%r14)
cmovnel %eax, %ecx
leaq 0x45ed(%rip), %rdx      # 0xf2c0
leaq 0x4(%rsp), %r14
movl $0x4, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x5290
movaps 0x3e02(%rip), %xmm0     # 0xeaf0
movups %xmm0, (%rbx)
movb (%r14), %al
testb %al, %al
je 0xad0b
leaq 0x5(%rsp), %rcx
movb %al, (%rbx)
incq %rbx
movb (%rcx), %al
incq %rcx
testb %al, %al
jne 0xacfd
movb $0x20, %al
xorl %edx, %edx
leaq 0x45ad(%rip), %rcx      # 0xf2c3
movb %al, (%rbx,%rdx)
movb 0x1(%rdx,%rcx), %al
leaq 0x1(%rdx), %rsi
movq %rsi, %rdx
cmpq $0xd, %rsi
jne 0xad16
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/excess-c64[P]lib1541img/src/lib/1541img/cbmdosfs.c
// Function: deleteChain
static void deleteChain(CbmdosFs *self, uint8_t nexttrack, uint8_t nextsect)
{
    if (self->bam[nexttrack-1][nextsect] != 1) return;
    do
    {
        if (nexttrack == 18 && nextsect == 0)
        {
            logmsg(L_WARNING, "CbmdosFs: refusing to delete BAM at [18:0]");
            return;
        }
        uint8_t *dir = Sector_content(
                D64_sector(self->d64, nexttrack, nextsect));
        self->bam[nexttrack-1][nextsect] = 0;
        nexttrack = dir[0];
        nextsect = dir[1];
    } while (nexttrack && self->bam[nexttrack-1][nextsect] == 1);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %rbx
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
leal (%r12,%rsi), %eax
movl %edx, %ecx
leaq (%rax,%rax,4), %rdi
leaq (%rax,%rdi,4), %rax
addq %rbx, %rax
addq $0x2c, %rax
cmpb $0x1, (%rcx,%rax)
jne 0xadbc
leaq 0x2c(%rbx), %r13
movl %esi, %eax
xorb $0x12, %al
orb %dl, %al
je 0xadc6
movzbl %sil, %r14d
movq (%rbx), %rdi
movzbl %dl, %r15d
movl %r14d, %esi
movl %r15d, %edx
callq 0x5030
movq %rax, %rdi
callq 0x5690
leaq (%r14,%r14,4), %rcx
leaq (%r14,%rcx,4), %rcx
addq %r13, %rcx
movb $0x0, -0x15(%r15,%rcx)
movzbl (%rax), %esi
testq %rsi, %rsi
je 0xadbc
movzbl 0x1(%rax), %edx
movl %esi, %eax
addl %r12d, %eax
leaq (%rax,%rax,4), %rcx
leaq (%rax,%rcx,4), %rax
addq %r13, %rax
cmpb $0x1, (%rdx,%rax)
je 0xad63
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x4618(%rip), %rsi      # 0xf3e5
movl $0x2, %edi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x591c
// File: /workspace/github_c_makefile_star2_O3/excess-c64[P]lib1541img/src/lib/1541img/cbmdosfs.c
// Function: freeSectorOnTrack
static uint8_t freeSectorOnTrack(CbmdosFs *self, uint8_t trackno,
        uint8_t sectno, uint8_t interlv, int simpleInterlv)
{
    uint8_t sectors = Track_sectors(D64_track(self->d64, trackno));
    uint8_t nextsect = 0;
    if (interlv)
    {
	if (simpleInterlv)
	{
	    nextsect = (sectno + interlv) % sectors;
	}
	else
	{
	    nextsect = sectno + interlv;
	    if (nextsect >= sectors)
	    {
		nextsect -= sectors;
		if (nextsect) --nextsect;
	    }
	}
    }
    uint8_t tmp = nextsect;
    while (self->bam[trackno-1][nextsect])
    {
        ++nextsect;
        if (nextsect == sectors) nextsect = 0;
        if (nextsect == tmp) break;
    }
    return self->bam[trackno-1][nextsect] ? 0xff : nextsect;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %r8d, %r12d
movl %ecx, %ebx
movl %edx, %r15d
movl %esi, %ebp
movq %rdi, %r14
movq (%rdi), %rdi
callq 0x5280
movq %rax, %rdi
callq 0x5740
movl %eax, %ecx
xorl %esi, %esi
testl %ebx, %ebx
je 0xae30
testl %r12d, %r12d
je 0xae27
movzbl %r15b, %edx
movzbl %bl, %eax
addl %edx, %eax
movzbl %cl, %edi
xorl %edx, %edx
divw %di
movl %edx, %ebx
jmp 0xae32
addb %r15b, %bl
cmpb %cl, %bl
jb 0xae32
jne 0xae76
xorl %ebx, %ebx
addq $0x2c, %r14
movzbl %bpl, %eax
decq %rax
leaq (%rax,%rax,4), %rdx
leaq (%rax,%rdx,4), %rdx
addq %r14, %rdx
movl %ebx, %eax
movzbl %al, %edi
cmpb $0x0, (%rdi,%rdx)
je 0xae6d
incb %al
cmpb %cl, %al
movzbl %al, %eax
cmovel %esi, %eax
cmpb %bl, %al
jne 0xae4a
movzbl %bl, %ecx
xorl %eax, %eax
cmpb (%rcx,%rdx), %al
sbbl %eax, %eax
orb %bl, %al
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl %ecx, %eax
notb %al
addb %al, %bl
jmp 0xae32
// File: /workspace/github_c_makefile_star2_O3/excess-c64[P]lib1541img/src/lib/1541img/cbmdosfs.c
// Function: createTrackBam
static void createTrackBam(CbmdosFs *self, uint8_t *tbam, uint8_t trackno)
{
    uint8_t sectors = Track_sectors(D64_track(self->d64, trackno));
    tbam[0] = sectors;
    tbam[1] = 0xff;
    tbam[2] = 0xff;
    tbam[3] = 0xff >> (24 - sectors);
    for (uint8_t sectno = 0; sectno < sectors; ++sectno)
    {
        if (self->bam[trackno-1][sectno])
        {
            --tbam[0];
            tbam[1+sectno/8] ^= (1U << (sectno%8));
        }
    }
    if (self->options.flags & CFF_ZEROFREE)
    {
	tbam[0] = 0;
    }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
movq (%rdi), %rdi
movl %edx, %esi
callq 0x5280
movq %rax, %rdi
callq 0x5740
movb $0x18, %cl
subb %al, %cl
movl $0xff, %edx
shrl %cl, %edx
movb %al, (%rbx)
movw $0xffff, 0x1(%rbx)      # imm = 0xFFFF
movb %dl, 0x3(%rbx)
testb %al, %al
je 0xb01e
movzbl %bpl, %ecx
movzbl %al, %edx
leaq (%rcx,%rcx,4), %rsi
leaq (%rcx,%rsi,4), %rcx
leaq (%r14,%rcx), %rsi
addq $0x17, %rsi
xorl %edi, %edi
cmpb $0x0, (%rsi,%rdi)
je 0xb016
movl %edi, %ecx
andb $0x7, %cl
movb $0x1, %r8b
shlb %cl, %r8b
decb %al
movb %al, (%rbx)
movl %edi, %ecx
shrl $0x3, %ecx
andl $0x1f, %ecx
xorb %r8b, 0x1(%rbx,%rcx)
incq %rdi
cmpq %rdi, %rdx
jne 0xaff4
testb $-0x80, 0x24(%r14)
je 0xb028
movb $0x0, (%rbx)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/excess-c64[P]lib1541img/src/lib/1541img/cbmdosfs.c
// Function: scratchFile
static void scratchFile(CbmdosFs *self, unsigned pos)
{
    if (self->dir.entries[pos].sidetrack)
    {
        deleteChain(self, self->dir.entries[pos].sidetrack,
                self->dir.entries[pos].sidesector);
    }
    if (self->dir.entries[pos].starttrack)
    {
        deleteChain(self, self->dir.entries[pos].starttrack,
                self->dir.entries[pos].startsector);
    }
    memset(self->dir.entries + pos, 0, sizeof *self->dir.entries);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x10(%rdi), %rax
movl %esi, %ecx
leaq (%rcx,%rcx,2), %r14
movb 0x4(%rax,%r14,2), %cl
testb %cl, %cl
je 0xb05e
leaq (%rax,%r14,2), %rax
movzbl 0x5(%rax), %edx
movzbl %cl, %esi
movq %rbx, %rdi
callq 0xad32
movq 0x10(%rbx), %rax
movb 0x2(%rax,%r14,2), %cl
testb %cl, %cl
je 0xb07e
leaq (%rax,%r14,2), %rax
movzbl 0x3(%rax), %edx
movzbl %cl, %esi
movq %rbx, %rdi
callq 0xad32
movq 0x10(%rbx), %rax
movw $0x0, 0x4(%rax,%r14,2)
movl $0x0, (%rax,%r14,2)
addq $0x8, %rsp
popq %rbx
popq %r14
retq