LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/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 0x712a
movl %edx, %ebp
leal -0x1(%rax), %r15d
cmpl %esi, %eax
cmoval %esi, %r15d
xorl %ebx, %ebx
cmpl %edx, %r15d
je 0x712a
movq %rdi, %r14
movq 0x18(%rdi), %rax
movl %ebp, %ecx
movq (%rax,%rcx,8), %r12
movl %r15d, %edx
movl %r15d, %r13d
subl %ebp, %edx
jbe 0x70e7
leaq (%rax,%rcx,8), %rdi
leaq 0x8(%rdi), %rsi
jmp 0x70f8
leaq (%rax,%r13,8), %rsi
leaq (%rax,%r13,8), %rdi
addq $0x8, %rdi
movl %ebp, %edx
subl %r15d, %edx
shlq $0x3, %rdx
callq 0x4620
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 0x45e0
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_O1/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
movaps 0x69a4(%rip), %xmm0     # 0xdaf0
movups %xmm0, (%rsi)
movabsq $-0x5f5f5f5f5f5f5f60, %rax # imm = 0xA0A0A0A0A0A0A0A0
movq %rax, 0x10(%rsi)
movb $0x22, %al
movb %al, (%rsi)
movb %al, 0x11(%rsi)
movb $0x32, 0x16(%rsi)
movb 0x32(%rdi), %al
movb %al, 0x17(%rsi)
leaq 0x1(%rsi), %rdi
movq (%r14), %rsi
movzbl 0x30(%r14), %edx
callq 0x4470
addq $0x13, %rbx
movq 0x8(%r14), %rsi
movzbl 0x31(%r14), %edx
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x4470
// File: /workspace/github_c_makefile_star2_O1/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 0x71cf
cmpl $0x0, 0x28(%rbx)
je 0x71cf
xorl %r14d, %r14d
movq 0x18(%rbx), %rax
movq (%rax,%r14,8), %rdi
movl %ebp, %esi
callq 0x40d0
incq %r14
movl 0x28(%rbx), %eax
cmpq %rax, %r14
jb 0x71b5
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_O1/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 0x7242
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpl $0x0, 0x28(%rdi)
je 0x7210
xorl %r14d, %r14d
movq 0x18(%rbx), %rax
movq (%rax,%r14,8), %rdi
callq 0x40e0
incq %r14
movl 0x28(%rbx), %eax
cmpq %rax, %r14
jb 0x71f8
movq 0x20(%rbx), %rdi
callq 0x4170
movq 0x18(%rbx), %rdi
callq 0x4080
movq (%rbx), %rdi
callq 0x4080
movq 0x8(%rbx), %rdi
callq 0x4080
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x4080
retq
nop
// File: /workspace/github_c_makefile_star2_O1/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 0x7c00
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 0x7bf1
incb %cl
jmp 0x7bf6
movb $0x1, -0x18(%rsp,%rsi)
incq %rsi
cmpq %rsi, %rax
jne 0x7bd3
jmp 0x7c02
xorl %ecx, %ecx
testq %rdi, %rdi
je 0x7c18
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_O1/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 0xb3a5(%rip), %rax      # 0x12fe0
movq (%rax), %rax
movq %rax, 0x8(%rsp)
testq %rdx, %rdx
jne 0x7c5c
leaq 0x8(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4370
testl %eax, %eax
js 0x7c79
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x7244
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x7c6f
// File: /workspace/github_c_makefile_star2_O1/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 0x4500
cmpq $0x302ff, %rax          # imm = 0x302FF
jg 0x8517
xorl %edi, %edi
cmpq $0x2ab00, %rax          # imm = 0x2AB00
je 0x853b
cmpq $0x2adab, %rax          # imm = 0x2ADAB
je 0x853b
cmpq $0x30000, %rax          # imm = 0x30000
je 0x852f
leaq 0x5975(%rip), %rsi      # 0xde75
movl $0x2, %edi
callq 0x491c
movq $0x0, (%rsp)
jmp 0x85c0
cmpq $0x32522, %rax          # imm = 0x32522
je 0x8536
cmpq $0x32200, %rax          # imm = 0x32200
je 0x8536
cmpq $0x30300, %rax          # imm = 0x30300
jne 0x84f9
movl $0x1, %edi
jmp 0x853b
movl $0x2, %edi
callq 0x45c0
movq %rax, %rbx
movq %r14, %rdi
callq 0x4640
movq %rax, %r14
movq %rbx, (%rsp)
movq %rbx, %rdi
callq 0x45f0
testb %al, %al
je 0x85c0
movl %eax, %ebp
movb $0x1, %bl
movzbl %bl, %esi
movq (%rsp), %rdi
callq 0x4280
movq %rax, %r15
movq %rax, %rdi
callq 0x4740
testb %al, %al
je 0x85b9
movl %eax, %r12d
xorl %r13d, %r13d
movzbl %r13b, %r13d
movq %r15, %rdi
movl %r13d, %esi
callq 0x4090
movq %rax, %rdi
callq 0x4690
movl $0x100, %edx            # imm = 0x100
movq %rax, %rdi
movq %r14, %rsi
callq 0x4470
addq $0x100, %r14            # imm = 0x100
incb %r13b
cmpb %r13b, %r12b
jne 0x8583
incb %bl
cmpb %bpl, %bl
jbe 0x8562
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_O1/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 0x42d0
testq %rax, %rax
je 0x85fc
movq %rax, %rbx
movq %rax, %rdi
callq 0x4200
movq %rax, %r14
movq %rbx, %rdi
callq 0x43d0
movq %r14, %rax
jmp 0x860f
leaq 0x589d(%rip), %rsi      # 0xdea0
movl $0x2, %edi
callq 0x491c
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_c_makefile_star2_O1/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 0x8cd4
movq %rdi, %r14
callq 0x4430
movl %eax, %ebp
xorl %ebx, %ebx
movq %r14, %rdi
movl $0x12, %esi
xorl %edx, %edx
callq 0x40c0
movq %rax, %rdi
callq 0x4670
xorl %ecx, %ecx
movq %r14, 0x8(%rsp)
cmpb $-0x60, 0x9f(%rax,%rcx)
jne 0x8bed
decq %rcx
cmpq $-0x10, %rcx
jne 0x8bd8
jmp 0x8bf4
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 0x4470
movb $0x0, 0x10(%rsp,%rbx)
xorl %r15d, %r15d
movl %ebp, 0x4(%rsp)
testl %ebp, %ebp
setne %r15b
movl %r15d, %edi
movq %r14, %rsi
callq 0x41f0
movq %rax, %r14
orl $0x4, %r15d
xorl %r13d, %r13d
leaq 0x30(%rsp), %r12
cmpl %r13d, %r15d
je 0x8c91
leal 0x1(%r13), %ebp
movl $0xb060, %esi           # imm = 0xB060
movq %r12, %rdi
movl %ebp, %edx
movq 0x8(%rsp), %rcx
callq 0x4210
testq %rax, %rax
je 0x8cb3
movq %rax, %rbx
movq %r14, %rdi
movl %r13d, %esi
callq 0x4730
movq %rax, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x4720
movl %ebp, %r13d
testl %eax, %eax
jns 0x8c3c
leaq 0x53bd(%rip), %rsi      # 0xe045
movl $0x1, %edi
movl %ebp, %edx
jmp 0x8cc5
xorl %edx, %edx
cmpl $0x1, 0x4(%rsp)
sete %dl
orl $0x4, %edx
leaq 0x53cd(%rip), %rsi      # 0xe072
movl $0x4, %edi
xorl %eax, %eax
callq 0x4949
jmp 0x8cd7
incl %r13d
leaq 0x5388(%rip), %rsi      # 0xe045
movl $0x1, %edi
movl %r13d, %edx
xorl %eax, %eax
callq 0x4949
movq %r14, %rdi
callq 0x4750
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_O1/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 0x485c
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_O1/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 0x18(%rdi), %rsi
cmpq %rsi, 0x10(%rdi)
jne 0x8d4b
addq $0x4, %rsi
movq %rsi, 0x18(%rbx)
movq 0x8(%rbx), %rdi
shlq $0x4, %rsi
callq 0x487c
movq %rax, 0x8(%rbx)
movq 0x8(%rbx), %rax
movq 0x10(%rbx), %rcx
movq %rcx, %rdx
shlq $0x4, %rdx
movq %r15, (%rax,%rdx)
movq %r14, 0x8(%rax,%rdx)
incq %rcx
movq %rcx, 0x10(%rbx)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/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, %rax
movq 0x10(%rdi), %rdx
testq %rdx, %rdx
setne %r9b
je 0x8da9
movq 0x8(%rdi), %r10
xorl %ecx, %ecx
xorl %r8d, %r8d
cmpq %rsi, (%r10,%rcx)
jne 0x8d96
cmpq %rax, 0x8(%r10,%rcx)
je 0x8daa
incq %r8
cmpq %rdx, %r8
setb %r9b
addq $0x10, %rcx
cmpq %r8, %rdx
jne 0x8d89
retq
testb $0x1, %r9b
je 0x8da9
leaq -0x1(%rdx), %rax
movq %rax, 0x10(%rdi)
cmpq %rax, %r8
jae 0x8da9
movq 0x8(%rdi), %rdi
leaq (%rdi,%rcx), %rsi
addq $0x10, %rsi
addq %rcx, %rdi
shlq $0x4, %rdx
subq %rcx, %rdx
addq $-0x10, %rdx
jmp 0x4620
// File: /workspace/github_c_makefile_star2_O1/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 0x8f15
testl %eax, %eax
js 0x8f0a
movq %r14, %r15
shrq $0x20, %r15
movl $0x3a0, %edi            # imm = 0x3A0
callq 0x485c
movq %rax, %rbx
movl $0x3a0, %edx            # imm = 0x3A0
movq %rax, %rdi
xorl %esi, %esi
callq 0x4320
movl %r14d, %eax
shrl $0x2, %eax
andl $0x1, %eax
testb $0x8, %r14b
movl $0x2, %edi
cmovel %eax, %edi
callq 0x45c0
movq %rax, (%rbx)
movl $0x90, 0x1c(%rbx)
movl $0x360, %edi            # imm = 0x360
callq 0x485c
movq %rax, 0x10(%rbx)
callq 0x4520
movq %rax, 0x8(%rbx)
testb $0x40, %r14b
je 0x8ece
movq %rax, %rdi
movl $0x50, %esi
callq 0x4600
movl %r14d, 0x24(%rbx)
movl %r15d, 0x28(%rbx)
movb $0x1, 0x191(%rbx)
movq %rbx, %rdi
callq 0x8f87
movq %rbx, %rdi
callq 0x9280
movq 0x8(%rbx), %rdi
callq 0x41e0
leaq 0x4ec(%rip), %rdx       # 0x93e9
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4550
jmp 0x8f0c
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x8f3c
movl %edi, %eax
notl %eax
testl $0xc00, %eax            # imm = 0xC00
jne 0x8f58
leaq 0x53e5(%rip), %rsi      # 0xe31f
jmp 0x8f43
leaq 0x538e(%rip), %rsi      # 0xe2d1
pushq %rax
movl $0x1, %edi
callq 0x491c
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 0x540d(%rip), %rsi      # 0xe37d
cmpl $-0x14, %ecx
jb 0x8f43
shrq $0x28, %rdi
andl %eax, %edi
addl $-0x15, %edi
xorl %eax, %eax
cmpl $-0x15, %edi
ja 0x8f57
jmp 0x8f43
// File: /workspace/github_c_makefile_star2_O1/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 0x4030
movq %rax, %rdi
callq 0x4690
movq %rax, %r14
movl $0x100, %edx            # imm = 0x100
movq %rax, %rdi
xorl %esi, %esi
callq 0x4320
movw $0x112, (%r14)          # imm = 0x112
movq 0x8(%rbx), %rdi
callq 0x4560
movb %al, 0x2(%r14)
movq (%rbx), %rdi
callq 0x45f0
testb %al, %al
je 0x9354
leaq 0x1c(%r14), %r15
leaq 0x30(%r14), %r12
movb $0x1, %bpl
movl $0x1, %r13d
cmpb $0x24, %bpl
jae 0x9302
movl %r13d, %eax
leaq (%r14,%rax,4), %rsi
movzbl %bpl, %edx
movq %rbx, %rdi
callq 0xa375
jmp 0x9340
cmpb $0x28, %bpl
ja 0x9340
testb $0x10, 0x24(%rbx)
je 0x9321
movl %r13d, %eax
leaq (%r15,%rax,4), %rsi
movzbl %bpl, %edx
movq %rbx, %rdi
callq 0xa375
testb $0x20, 0x24(%rbx)
je 0x933a
movl %r13d, %eax
leaq (%r12,%rax,4), %rsi
movzbl %bpl, %edx
movq %rbx, %rdi
callq 0xa375
testb $0x40, 0x24(%rbx)
jne 0x92ed
incb %bpl
movzbl %bpl, %r13d
movq (%rbx), %rdi
callq 0x45f0
cmpb %al, %r13b
jbe 0x92e7
leaq 0x14(%r14), %r15
testb $0x40, 0x24(%rbx)
cmoveq %r14, %r15
leaq 0x90(%r15), %r14
movaps 0x4782(%rip), %xmm0     # 0xdaf0
movups %xmm0, 0x9b(%r15)
movups %xmm0, 0x90(%r15)
movb $0x32, 0xa5(%r15)
movq 0x8(%rbx), %rdi
callq 0x4560
movb %al, 0xa6(%r15)
movq 0x8(%rbx), %rdi
leaq 0x7(%rsp), %r12
movq %r12, %rsi
callq 0x4190
movzbl (%r12), %edx
movq %r14, %rdi
movq %rax, %rsi
callq 0x4470
movq 0x8(%rbx), %rdi
movq %r12, %rsi
callq 0x43e0
addq $0xa2, %r15
movzbl (%r12), %edx
movq %r15, %rdi
movq %rax, %rsi
callq 0x4470
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x9808
pushq %rbx
movq %rdi, %rbx
movq 0x10(%rdi), %rdi
callq 0x4080
movq 0x8(%rbx), %rdi
callq 0x4490
movq (%rbx), %rdi
callq 0x45b0
movq %rbx, %rdi
popq %rbx
jmp 0x4080
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x8f15
testl %eax, %eax
js 0x98e6
movq %r14, %r12
shrq $0x20, %r12
movl $0x3a0, %edi            # imm = 0x3A0
callq 0x485c
movq %rax, %rbx
movl $0x3a0, %edx            # imm = 0x3A0
movq %rax, %rdi
xorl %esi, %esi
callq 0x4320
movl $0x90, 0x1c(%rbx)
movq %r15, %rdi
callq 0x4240
movl %eax, 0x18(%rbx)
movl 0x1c(%rbx), %ecx
cmpl %eax, %ecx
jae 0x9870
addl $0x90, %ecx
cmpl %eax, %ecx
jb 0x9863
movl %ecx, 0x1c(%rbx)
movl %ecx, %eax
addq %rax, %rax
leaq (%rax,%rax,2), %rdi
callq 0x485c
movq %rax, 0x10(%rbx)
testb $0x40, %r14b
je 0x98a1
movq %r15, %rdi
callq 0x4560
cmpb $0x41, %al
jne 0x98a1
movq %r15, %rdi
movl $0x50, %esi
callq 0x4600
movq %r15, 0x8(%rbx)
movl %r14d, 0x24(%rbx)
movl %r12d, 0x28(%rbx)
movq %rbx, %rdi
callq 0x4770
testl %eax, %eax
js 0x98d6
movq 0x8(%rbx), %rdi
callq 0x41e0
leaq -0x4e0(%rip), %rdx      # 0x93e9
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4550
jmp 0x98e8
movq $0x0, 0x8(%rbx)
movq %rbx, %rdi
callq 0x4460
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x45b0
movl 0x24(%rbx), %eax
movl %eax, %ecx
shrl $0x2, %ecx
andl $0x1, %ecx
testb $0x8, %al
movl $0x2, %edi
cmovel %ecx, %edi
callq 0x45c0
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 0x4320
leaq 0x2c(%rbx), %rdi
movl $0x372, %edx            # imm = 0x372
xorl %esi, %esi
callq 0x4320
movb $0x1, 0x191(%rbx)
movq %rbx, %rdi
callq 0x8f87
testl %eax, %eax
js 0x9992
cmpl $0x0, 0x18(%rbx)
je 0x997e
xorl %ebp, %ebp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x9a70
testl %eax, %eax
js 0x9998
incl %ebp
cmpl 0x18(%rbx), %ebp
jb 0x9969
movq %rbx, %rdi
callq 0x8f87
movq %rbx, %rdi
callq 0x9280
xorl %eax, %eax
jmp 0x99a1
orb $0x4, 0x20(%rbx)
jmp 0x999c
orb $0x2, 0x20(%rbx)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x46f0
testl %eax, %eax
js 0x99e5
movl 0x24(%rbx), %eax
movq %r14, 0x24(%rbx)
je 0x99ec
movq %rbx, %rdi
callq 0x4770
jmp 0x99fb
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x9a00
xorl %r14d, %eax
testb $-0x10, %al
je 0x9a08
movq %rbx, %rdi
callq 0x9280
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
xorl %eax, %eax
jmp 0x9a00
// File: /workspace/github_c_makefile_star2_O1/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 0x8f15
testl %eax, %eax
js 0x9a63
movl 0x24(%r14), %edx
movl %edx, %ecx
xorl %ebx, %ecx
movl $0x1, %eax
testl $0x3e0b, %ecx           # imm = 0x3E0B
jne 0x9a68
testb $0x8, %dl
sete %dl
andl $0x4, %ecx
shrl $0x2, %ecx
testb %cl, %dl
jne 0x9a68
movq %rbx, %rcx
shrq $0x20, %rcx
cmpb %cl, 0x28(%r14)
jne 0x9a68
shrq $0x28, %rbx
xorl %eax, %eax
cmpb %bl, 0x29(%r14)
setne %al
jmp 0x9a68
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x4240
movl %eax, %r14d
movl 0x24(%rbx), %eax
cmpl $0x91, %r14d
jb 0x9fc7
movw $0xffff, %bp            # imm = 0xFFFF
testb $0x1, %al
je 0xa058
leal -0x90(%r14), %edx
shrl $0x3, %edx
movl %r14d, %eax
andl $0x7, %eax
cmpl $0x1, %eax
sbbl $-0x1, %edx
movzwl %r15w, %eax
xorl %ecx, %ecx
cmpl %eax, %edx
cmovbel %edx, %ecx
ja 0xa058
subl %ecx, %eax
movl %eax, %ebp
jmp 0x9fe1
testb $0x2, %al
jne 0x9fd0
movl %r15d, %ebp
jmp 0x9fe1
movl $0x90, %eax
subl %r14d, %eax
shrl $0x3, %eax
movzwl %r15w, %ebp
addl %eax, %ebp
testl %r14d, %r14d
je 0xa058
xorl %r15d, %r15d
movq 0x8(%rbx), %rdi
movl %r15d, %esi
callq 0x4340
movq %rax, %r13
movq %rax, %rdi
callq 0x4680
movl %eax, %r12d
movq %r13, %rdi
callq 0x4780
cmpl $0x4, %eax
jne 0xa041
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 0xa054
subl %r12d, %ebp
incl %r15d
cmpl %r15d, %r14d
jne 0x9fe9
jmp 0xa058
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_O1/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 0x43c0
movzwl %ax, %eax
cmpw $-0x1, %ax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmovnel %eax, %ecx
testl %ecx, %ecx
jle 0xa095
xorl %eax, %eax
testb $-0x80, 0x24(%r14)
cmovnel %eax, %ecx
leaq 0x4224(%rip), %rdx      # 0xe2c0
leaq 0x4(%rsp), %r14
movl $0x4, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x4290
movaps 0x3a39(%rip), %xmm0     # 0xdaf0
movups %xmm0, (%rbx)
movb (%r14), %al
testb %al, %al
je 0xa0d4
leaq 0x5(%rsp), %rcx
movb %al, (%rbx)
incq %rbx
movb (%rcx), %al
incq %rcx
testb %al, %al
jne 0xa0c6
movb $0x20, %al
xorl %edx, %edx
leaq 0x41e4(%rip), %rcx      # 0xe2c3
movb %al, (%rbx,%rdx)
movb 0x1(%rdx,%rcx), %al
leaq 0x1(%rdx), %rsi
movq %rsi, %rdx
cmpq $0xd, %rsi
jne 0xa0df
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/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 0xa185
leaq 0x2c(%rbx), %r13
movl %esi, %eax
xorb $0x12, %al
orb %dl, %al
je 0xa18f
movzbl %sil, %r14d
movq (%rbx), %rdi
movzbl %dl, %r15d
movl %r14d, %esi
movl %r15d, %edx
callq 0x4030
movq %rax, %rdi
callq 0x4690
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 0xa185
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 0xa12c
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x424f(%rip), %rsi      # 0xe3e5
movl $0x2, %edi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x491c
// File: /workspace/github_c_makefile_star2_O1/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 0x4280
movq %rax, %rdi
callq 0x4740
movl %eax, %ecx
xorl %esi, %esi
testl %ebx, %ebx
je 0xa1f9
testl %r12d, %r12d
je 0xa1f0
movzbl %r15b, %edx
movzbl %bl, %eax
addl %edx, %eax
movzbl %cl, %edi
xorl %edx, %edx
divw %di
movl %edx, %ebx
jmp 0xa1fb
addb %r15b, %bl
cmpb %cl, %bl
jb 0xa1fb
jne 0xa23f
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 0xa22a
incb %al
cmpb %cl, %al
movzbl %al, %eax
cmovel %esi, %eax
cmpb %bl, %al
jne 0xa213
movzbl %al, %eax
xorl %ecx, %ecx
cmpb (%rax,%rdx), %cl
sbbl %ecx, %ecx
orb %cl, %al
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl %ecx, %eax
notb %al
addb %al, %bl
jmp 0xa1fb
// File: /workspace/github_c_makefile_star2_O1/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 0x4280
movq %rax, %rdi
callq 0x4740
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 0xa3ee
movzbl %bpl, %ecx
movzbl %al, %eax
leaq (%rcx,%rcx,4), %rdx
leaq (%rcx,%rdx,4), %rcx
leaq (%r14,%rcx), %rdx
addq $0x17, %rdx
xorl %esi, %esi
cmpb $0x0, (%rdx,%rsi)
je 0xa3e6
decb (%rbx)
movl %esi, %ecx
andb $0x7, %cl
movb $0x1, %dil
shlb %cl, %dil
movl %esi, %ecx
shrl $0x3, %ecx
andl $0x1f, %ecx
xorb %dil, 0x1(%rbx,%rcx)
incq %rsi
cmpq %rsi, %rax
jne 0xa3c6
testb $-0x80, 0x24(%r14)
je 0xa3f8
movb $0x0, (%rbx)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 0xa42a
leaq (%rax,%r14,2), %rax
movzbl 0x5(%rax), %edx
movzbl %cl, %esi
movq %rbx, %rdi
callq 0xa0fb
movq 0x10(%rbx), %rcx
movb 0x2(%rcx,%r14,2), %al
testb %al, %al
je 0xa44a
leaq (%rcx,%r14,2), %rcx
movzbl 0x3(%rcx), %edx
movzbl %al, %esi
movq %rbx, %rdi
callq 0xa0fb
movq 0x10(%rbx), %rax
movw $0x0, 0x4(%rax,%r14,2)
movl $0x0, (%rax,%r14,2)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/excess-c64[P]lib1541img/src/lib/1541img/cbmdosfs.c
// Function: findStartSector
static int findStartSector(CbmdosFs *self,
        uint8_t *trackno, uint8_t *sectno, const CbmdosFsOptions *opts)
{
    uint8_t tn = startTrack(opts, 0);
    do
    {
	for (uint8_t sn = 0;
		sn < Track_sectors(D64_rtrack(self->d64, tn)); ++sn)
	{
	    if (!self->bam[tn-1][sn])
	    {
		*trackno = tn;
		*sectno = sn;
		return 0;
	    }
	}
    } while ((tn = startTrack(opts, tn)));
    return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r14
movq %rdx, 0x8(%rsp)
movq %rsi, (%rsp)
movq %rdi, %r12
movl (%rcx), %eax
movl %eax, %ecx
notl %ecx
movb $0x12, %bl
testl $0x1002, %ecx           # imm = 0x1002
je 0xa4a7
movb $0x1, %bl
btl $0xa, %eax
jb 0xa4a7
shrl $0xb, %eax
andl $0x1, %eax
addb %al, %al
orb $0x11, %al
movl %eax, %ebx
leaq 0x17(%r12), %rax
movq %rax, 0x10(%rsp)
movq (%r12), %rdi
movzbl %bl, %r13d
movl %r13d, %esi
callq 0x4060
movq %rax, %rdi
callq 0x4740
testb %al, %al
je 0xa511
leaq (,%r13,4), %rax
addq %r13, %rax
leaq (,%rax,4), %r15
addq %r13, %r15
addq 0x10(%rsp), %r15
xorl %ebp, %ebp
cmpb $0x0, (%r15,%rbp)
je 0xa59c
movq (%r12), %rdi
movl %r13d, %esi
callq 0x4060
movq %rax, %rdi
callq 0x4740
incq %rbp
cmpb %al, %bpl
jb 0xa4ea
movl (%r14), %ecx
testb %bl, %bl
je 0xa52d
testl $0xc00, %ecx            # imm = 0xC00
je 0xa552
movq %r14, %rdi
movl %r13d, %esi
callq 0xa247
jmp 0xa58b
movl %ecx, %edx
notl %edx
movb $0x12, %al
testl $0x1002, %edx           # imm = 0x1002
je 0xa58b
movb $0x1, %al
btl $0xa, %ecx
jb 0xa58b
shrl $0xb, %ecx
andl $0x1, %ecx
addb %cl, %cl
orb $0x11, %cl
movl %ecx, %eax
jmp 0xa58b
cmpb $0x28, %bl
setae %al
testb $0x8, %cl
sete %dl
testb %dl, %al
je 0xa566
xorl %eax, %eax
jmp 0xa58b
cmpb $0x23, %bl
jb 0xa57a
andl $0xc, %ecx
incb %bl
testl %ecx, %ecx
movzbl %bl, %eax
cmovel %ecx, %eax
jmp 0xa58b
movb $0x11, %al
cmpb $0x12, %bl
je 0xa58b
jae 0xa587
movb $0x24, %al
jmp 0xa589
movb $0x23, %al
subb %bl, %al
movl %eax, %ebx
testb %al, %al
jne 0xa4b1
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0xa5ac
movq (%rsp), %rax
movb %bl, (%rax)
movq 0x8(%rsp), %rax
movb %bpl, (%rax)
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/excess-c64[P]lib1541img/src/lib/1541img/cbmdosfs.c
// Function: findNextSector
static int findNextSector(CbmdosFs *self,
        uint8_t *trackno, uint8_t *sectno, const CbmdosFsOptions *opts)
{
    uint8_t tn = *trackno;
    uint8_t sn = freeSectorOnTrack(self, tn, *sectno, opts->fileInterleave,
            (opts->flags & CFF_SIMPLEINTERLEAVE));
    do
    {
	if (sn != 0xff)
	{
	    *trackno = tn;
	    *sectno = sn;
	    return 0;
	}
	if ((tn = nextTrack(opts, tn)))
	{
	    if (opts->flags & CFF_TALLOC_CHAININTERLV)
	    {
		sn = freeSectorOnTrack(self, tn, sn, opts->fileInterleave,
                        (opts->flags & CFF_SIMPLEINTERLEAVE));
	    }
	    else
	    {
		sn = freeSectorOnTrack(self, tn, sn, 0, 0);
	    }
	}
    } while (tn);
    return findStartSector(self, trackno, sectno, opts);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r14
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r12
movb (%rsi), %bpl
movzbl (%rdx), %edx
movzbl 0x5(%rcx), %ecx
movl $0x200, %r8d            # imm = 0x200
andl (%r14), %r8d
movzbl %bpl, %esi
callq 0xa1a9
movl %eax, %r13d
cmpb $-0x1, %r13b
jne 0xa660
movzbl %bpl, %esi
movq %r14, %rdi
callq 0xa247
movl %eax, %ebp
testb %al, %al
je 0xa63c
movl (%r14), %r8d
btl $0xd, %r8d
movzbl %bpl, %esi
movzbl %r13b, %edx
jb 0xa625
movq %r12, %rdi
xorl %ecx, %ecx
xorl %r8d, %r8d
jmp 0xa634
movzbl 0x5(%r14), %ecx
andl $0x200, %r8d            # imm = 0x200
movq %r12, %rdi
callq 0xa1a9
movl %eax, %r13d
testb %bpl, %bpl
jne 0xa5f1
movq %r12, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq %r14, %rcx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa466
movb %bpl, (%r15)
movb %r13b, (%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O1/excess-c64[P]lib1541img/src/lib/1541img/cbmdosfsoptions.c
// Function: CbmdosFsOptions_applyOverrides
void CbmdosFsOptions_applyOverrides(CbmdosFsOptions *self,
        const CbmdosFsOptOverrides *overrides)
{
    uint8_t interleave = CbmdosFsOptOverrides_interleave(overrides);
    if (interleave != 0xff) self->fileInterleave = interleave;

    CbmdosFsFlags mask = overrides->mask;
    mask &= ~CFF_OVERRIDE_INTERLEAVE;
    self->flags &= ~mask;
    self->flags |= (overrides->flags & mask);
}

// Assembly:
movl 0x4(%rsi), %eax
testl $0x1ff, %eax            # imm = 0x1FF
je 0xa686
movb (%rsi), %cl
jmp 0xa688
movb $-0x1, %cl
cmpb $-0x1, %cl
je 0xa690
movb %cl, 0x5(%rdi)
andl $0xfffffe00, %eax       # imm = 0xFFFFFE00
movl %eax, %ecx
notl %ecx
andl (%rdi), %ecx
movl %ecx, (%rdi)
andl (%rsi), %eax
orl %ecx, %eax
movl %eax, (%rdi)
retq
// File: /workspace/github_c_makefile_star2_O1/excess-c64[P]lib1541img/src/lib/1541img/cbmdosfsoptions.c
// Function: CbmdosFsOptOverrides_setInterleave
void CbmdosFsOptOverrides_setInterleave(
        CbmdosFsOptOverrides *self, uint8_t interleave)
{
    self->flags &= ~CFF_OVERRIDE_INTERLEAVE;
    if (interleave == 0xff)
    {
        self->mask &= ~CFF_OVERRIDE_INTERLEAVE;
    }
    else
    {
        self->mask |= CFF_OVERRIDE_INTERLEAVE;
        self->flags |= (interleave & CFF_OVERRIDE_INTERLEAVE);
    }
}

// Assembly:
movl $0xfffffe00, %eax       # imm = 0xFFFFFE00
andl (%rdi), %eax
movl %eax, (%rdi)
cmpl $0xff, %esi
je 0xa6d6
orl $0x1ff, 0x4(%rdi)       # imm = 0x1FF
movzbl %sil, %ecx
orl %ecx, %eax
movl %eax, (%rdi)
retq
andl $0xfffffe00, 0x4(%rdi)  # imm = 0xFFFFFE00
retq
nop
// File: /workspace/github_c_makefile_star2_O1/excess-c64[P]lib1541img/src/lib/1541img/cbmdosinode.c
// Function: CbmdosInode_create
SOLOCAL CbmdosInode *CbmdosInode_create(void)
{
    CbmdosInode *self = xmalloc(sizeof *self);
    self->data = FileData_create();
    self->changedEvent = Event_create(0, self);
    self->overrides = CFOO_NONE;
    self->refcount = 0;
    Event_register(FileData_changedEvent(self->data), self, fileDataHandler);
    return self;
}

// Assembly:
pushq %rbx
movl $0x20, %edi
callq 0x485c
movq %rax, %rbx
callq 0x44f0
movq %rax, (%rbx)
xorl %edi, %edi
movq %rbx, %rsi
callq 0x4270
movq %rax, 0x8(%rbx)
movq $0x0, 0x10(%rbx)
movl $0x0, 0x18(%rbx)
movq (%rbx), %rdi
callq 0x4410
leaq 0x10(%rip), %rdx        # 0xa732
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4550
movq %rbx, %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/excess-c64[P]lib1541img/src/lib/1541img/cbmdosinode.c
// Function: CbmdosInode_clone
SOLOCAL CbmdosInode *CbmdosInode_clone(const CbmdosInode *other)
{
    CbmdosInode *self = xmalloc(sizeof *self);
    self->data = FileData_clone(other->data);
    self->changedEvent = Event_create(0, self);
    self->overrides = other->overrides;
    self->refcount = 0;
    Event_register(FileData_changedEvent(self->data), self, fileDataHandler);
    return self;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
movl $0x20, %edi
callq 0x485c
movq %rax, %rbx
movq (%r14), %rdi
callq 0x4150
movq %rax, (%rbx)
xorl %edi, %edi
movq %rbx, %rsi
callq 0x4270
movq %rax, 0x8(%rbx)
movq 0x10(%r14), %rax
movq %rax, 0x10(%rbx)
movl $0x0, 0x18(%rbx)
movq (%rbx), %rdi
callq 0x4410
leaq -0x62(%rip), %rdx       # 0xa732
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4550
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/excess-c64[P]lib1541img/src/lib/1541img/cbmdosinode.c
// Function: CbmdosInode_setData
SOEXPORT void CbmdosInode_setData(CbmdosInode *self, FileData *data)
{
    Event_unregister(FileData_changedEvent(self->data), self, fileDataHandler);
    FileData_destroy(self->data);
    self->data = data;
    Event_register(FileData_changedEvent(self->data), self, fileDataHandler);
    CbmdosInodeEventArgs ea = { CIE_DATACHANGED };
    Event_raise(self->changedEvent, &ea);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq (%rdi), %rdi
callq 0x4410
leaq -0x9e(%rip), %r15       # 0xa732
movq %rax, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x4330
movq (%rbx), %rdi
callq 0x43d0
movq %r14, (%rbx)
movq %r14, %rdi
callq 0x4410
movq %rax, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x4550
leaq 0xc(%rsp), %rsi
movl $0x0, (%rsi)
movq 0x8(%rbx), %rdi
callq 0x45e0
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq