LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/excess-c64[P]lib1541img/src/lib/1541img/d64writer.c
// Function: writeD64
SOEXPORT int writeD64(FILE *file, const D64 *d64)
{
    for (uint8_t tracknum = 1; tracknum <= D64_tracks(d64); ++tracknum)
    {
	const Track *track = D64_rtrack(d64, tracknum);
	for (uint8_t sectnum = 0; sectnum < Track_sectors(track); ++sectnum)
	{
	    const Sector *sector = Track_rsector(track, sectnum);
	    const uint8_t *content = Sector_rcontent(sector);
	    if (!fwrite(content, SECTOR_SIZE, 1, file))
            {
                logmsg(L_ERROR, "writeD64: unknown write error.");
                return -1;
            }
	}
    }
    logmsg(L_DEBUG, "writeD64: success.");
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq %rsi, %rdi
callq 0x45f0
testb %al, %al
sete %r13b
je 0x564e
movb $0x1, %bpl
movq %rbx, (%rsp)
movzbl %bpl, %esi
movq %rbx, %rdi
callq 0x4060
movq %rax, %r12
movq %rax, %rdi
callq 0x4740
testb %al, %al
setne %r15b
je 0x5632
movq %r12, %rdi
xorl %esi, %esi
callq 0x4480
movq %rax, %rdi
callq 0x4670
movl $0x100, %esi            # imm = 0x100
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rcx
callq 0x46e0
testq %rax, %rax
je 0x561c
movb $0x1, %bl
movq %r12, %rdi
callq 0x4740
cmpb %al, %bl
setb %r15b
jae 0x5632
movzbl %bl, %esi
movq %r12, %rdi
callq 0x4480
movq %rax, %rdi
callq 0x4670
movl $0x100, %esi            # imm = 0x100
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rcx
callq 0x46e0
incb %bl
testq %rax, %rax
jne 0x55dd
movl $0x1, %edi
leaq 0x7fb5(%rip), %rsi      # 0xd5dd
callq 0x491c
testb %r15b, %r15b
jne 0x5670
incb %bpl
movq (%rsp), %rbx
movq %rbx, %rdi
callq 0x45f0
cmpb %al, %bpl
seta %r13b
jbe 0x558c
leaq 0x7fa7(%rip), %rsi      # 0xd5fc
movl $0x4, %edi
callq 0x491c
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testb $0x1, %r13b
jne 0x564e
jmp 0x5661
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O1/excess-c64[P]lib1541img/src/lib/1541img/filename.c
// Function: Filename_clone
SOLOCAL Filename *Filename_clone(const Filename *self)
{
    Filename *clone = Filename_create();
    if (self->full) clone->full = copystr(self->full);
    if (self->dir) clone->dir = copystr(self->dir);
    if (self->base) clone->base = copystr(self->base);
    if (self->ext) clone->ext = copystr(self->ext);
    return clone;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
movl $0x20, %edi
callq 0x485c
movq %rax, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movups %xmm0, 0x10(%rax)
movq (%r14), %rdi
testq %rdi, %rdi
je 0x56c5
callq 0x489c
movq %rax, (%rbx)
movq 0x8(%r14), %rdi
testq %rdi, %rdi
je 0x56d7
callq 0x489c
movq %rax, 0x8(%rbx)
movq 0x10(%r14), %rdi
testq %rdi, %rdi
je 0x56e9
callq 0x489c
movq %rax, 0x10(%rbx)
movq 0x18(%r14), %rdi
testq %rdi, %rdi
je 0x56fb
callq 0x489c
movq %rax, 0x18(%rbx)
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/filename.c
// Function: Filename_setFull
SOLOCAL void Filename_setFull(Filename *self, const char *full)
{
    free(self->full);
    free(self->dir);
    free(self->base);
    free(self->ext);
    memset(self, 0, sizeof *self);
    if (!full) return;
    self->full = copystr(full);
#ifdef _WIN32
    for (char *c = self->full; *c; ++c)
    {
        if (*c == '/') *c = PATHSEP;
    }
#endif
    const char *pathsep = strrchr(self->full, PATHSEP);
    const char *base;
    if (pathsep)
    {
	size_t dirlen = pathsep - self->full;
	self->dir = xmalloc(dirlen + 1);
	strncpy(self->dir, self->full, dirlen);
	self->dir[dirlen] = 0;
	base = pathsep+1;
    }
    else
    {
	base = self->full;
    }

    const char *extsep = *base ? strrchr(base, '.') : 0;
    if (extsep)
    {
	self->ext = copystr(extsep+1);
	size_t baselen = extsep - base;
	self->base = xmalloc(baselen + 1);
	strncpy(self->base, base, baselen);
	self->base[baselen] = 0;
    }
    else
    {
	self->base = *base ? copystr(base) : 0;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movq (%rdi), %rdi
callq 0x4080
movq 0x8(%rbx), %rdi
callq 0x4080
movq 0x10(%rbx), %rdi
callq 0x4080
movq 0x18(%rbx), %rdi
callq 0x4080
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
movups %xmm0, (%rbx)
testq %r14, %r14
je 0x581e
movq %r14, %rdi
callq 0x489c
movq %rax, %r14
movq %rax, (%rbx)
movq %rax, %rdi
movl $0x2f, %esi
callq 0x42b0
testq %rax, %rax
je 0x57b1
movq %rax, %r15
movq %rax, %r12
subq %r14, %r12
leaq 0x1(%r12), %rdi
callq 0x485c
movq %rax, 0x8(%rbx)
movq (%rbx), %rsi
movq %rax, %rdi
movq %r12, %rdx
callq 0x40b0
movq 0x8(%rbx), %rax
movb $0x0, (%rax,%r12)
incq %r15
movq %r15, %r14
movb (%r14), %bpl
testb %bpl, %bpl
je 0x57cb
movq %r14, %rdi
movl $0x2e, %esi
callq 0x42b0
movq %rax, %r15
jmp 0x57ce
xorl %r15d, %r15d
testq %r15, %r15
je 0x5809
leaq 0x1(%r15), %rdi
callq 0x489c
movq %rax, 0x18(%rbx)
subq %r14, %r15
leaq 0x1(%r15), %rdi
callq 0x485c
movq %rax, 0x10(%rbx)
movq %rax, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x40b0
movq 0x10(%rbx), %rax
movb $0x0, (%rax,%r15)
jmp 0x581e
testb %bpl, %bpl
je 0x5818
movq %r14, %rdi
callq 0x489c
jmp 0x581a
xorl %eax, %eax
movq %rax, 0x10(%rbx)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/excess-c64[P]lib1541img/src/lib/1541img/filename.c
// Function: Filename_updateFull
static void Filename_updateFull(Filename *self)
{
    free(self->full);
    if (!self->base)
    {
	self->full = 0;
	return;
    }
    size_t fulllen = strlen(self->base);
    if (self->dir) fulllen += strlen(self->dir) + 1;
    if (self->ext) fulllen += strlen(self->ext) + 1;
    self->full = xmalloc(fulllen+1);
    char *wrptr = self->full;
    if (self->dir)
    {
	strcpy(wrptr, self->dir);
	wrptr += strlen(self->dir);
	*wrptr++ = PATHSEP;
    }
    strcpy(wrptr, self->base);
    wrptr += strlen(self->base);
    if (self->ext)
    {
	*wrptr++ = '.';
	strcpy(wrptr, self->ext);
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rdi), %rdi
callq 0x4080
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x590b
callq 0x4250
movq %rax, %r14
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
je 0x588a
callq 0x4250
addq %rax, %r14
incq %r14
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x589e
callq 0x4250
addq %rax, %r14
incq %r14
incq %r14
movq %r14, %rdi
callq 0x485c
movq %rax, %r14
movq %rax, (%rbx)
movq 0x8(%rbx), %rsi
testq %rsi, %rsi
je 0x58d4
movq %r14, %rdi
callq 0x4100
movq 0x8(%rbx), %rdi
callq 0x4250
movb $0x2f, (%r14,%rax)
addq %rax, %r14
incq %r14
movq 0x10(%rbx), %rsi
movq %r14, %rdi
callq 0x4100
cmpq $0x0, 0x18(%rbx)
je 0x5912
movq 0x10(%rbx), %rdi
callq 0x4250
leaq (%r14,%rax), %rdi
incq %rdi
movb $0x2e, -0x1(%rdi)
movq 0x18(%rbx), %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x4100
movq $0x0, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/excess-c64[P]lib1541img/src/lib/1541img/filename.c
// Function: Filename_destroy
SOLOCAL void Filename_destroy(Filename *self)
{
    if (!self) return;
    free(self->full);
    free(self->dir);
    free(self->base);
    free(self->ext);
    free(self);
}

// Assembly:
testq %rdi, %rdi
je 0x59ab
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdi
callq 0x4080
movq 0x8(%rbx), %rdi
callq 0x4080
movq 0x10(%rbx), %rdi
callq 0x4080
movq 0x18(%rbx), %rdi
callq 0x4080
movq %rbx, %rdi
popq %rbx
jmp 0x4080
retq
// File: /workspace/github_c_makefile_star2_O1/excess-c64[P]lib1541img/src/lib/1541img/zcfileset.c
// Function: ZcFileSet_create
SOEXPORT ZcFileSet *ZcFileSet_create(ZcType type, const char *name)
{
    int count;
    switch (type)
    {
        case ZT_4PACK:
            count = 4;
            break;
        case ZT_5PACK:
            count = 5;
            break;
        case ZT_6PACK:
            count = 6;
            break;
        default:
            logmsg(L_ERROR, "ZcFileSet: invalid type.");
            return 0;
    }

    ZcFileSet *self = xmalloc(sizeof *self + count * sizeof *self->files);
    self->type = type;
    self->count = count;
    self->name = copystr(name);
    for (int i = 0; i < count; ++i) self->files[i] = FileData_create();
    return self;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
cmpl $0x3, %edi
jae 0x5a00
movq %rsi, %r14
movl %edi, %r15d
movl %edi, %r12d
orl $0x4, %r12d
leal 0x30(,%r15,8), %edi
callq 0x485c
movq %rax, %rbx
movl %r15d, (%rax)
movl %r12d, 0x4(%rax)
movq %r14, %rdi
callq 0x489c
movq %rax, 0x8(%rbx)
xorl %r14d, %r14d
callq 0x44f0
movq %rax, 0x10(%rbx,%r14,8)
incq %r14
cmpq %r14, %r12
jne 0x59ec
jmp 0x5a13
leaq 0x7c08(%rip), %rsi      # 0xd60f
movl $0x1, %edi
callq 0x491c
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/zcfileset.c
// Function: fromVfsInternal
static ZcFileSet *fromVfsInternal(const CbmdosVfs *vfs, int logerrors)
{
    logfmt(L_INFO, "ZcFileSet: checking disk `%s,%s'", CbmdosVfs_name(vfs, 0),
            CbmdosVfs_id(vfs, 0));

    const char *compare = 0;
    FileData *files[5] = { 0 };
    for (unsigned pos = 0; pos < CbmdosVfs_fileCount(vfs); ++pos)
    {
        const CbmdosFile *dosfile = CbmdosVfs_rfile(vfs, pos);
        if (CbmdosFile_type(dosfile) != CFT_PRG) continue;
        uint8_t namelen;
        const char *name = CbmdosFile_name(dosfile, &namelen);
        if (namelen < 3) continue;
        if (name[1] != '!' || name[2] == '!') continue;
        if (name[0] < '1' || name[0] > '5') continue;
        if (compare)
        {
            if (strcmp(name+2, compare)) continue;
        }
        else compare = name+2;
        int partidx = name[0] - '1';
        if (files[partidx])
        {
            logfmt(logerrors ? L_WARNING : L_INFO,
                    "ZcFileSet: skipping duplicate `%s.PRG'", name);
            continue;
        }
        files[partidx] = FileData_clone(CbmdosFile_rdata(dosfile));
        logfmt(L_INFO, "ZcFileSet: found `%s.PRG' (%lu bytes)", name,
                (unsigned long)FileData_size(files[partidx]));
    }

    return fromFileData(compare, files, logerrors);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %esi, 0xc(%rsp)
movq %rdi, %r14
xorl %esi, %esi
callq 0x4190
movq %rax, %rbx
movq %r14, %rdi
xorl %esi, %esi
callq 0x43e0
leaq 0x7cef(%rip), %rsi      # 0xd748
movl $0x3, %edi
movq %rbx, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x4949
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x40(%rsp)
movq %r14, %rdi
callq 0x4240
movl $0x0, %ecx
movq %rcx, 0x10(%rsp)
testl %eax, %eax
je 0x5ba5
cmpl $0x1, 0xc(%rsp)
movl $0x0, %eax
adcl $0x2, %eax
movl %eax, 0x1c(%rsp)
leaq 0xb(%rsp), %r12
movq $0x0, 0x10(%rsp)
xorl %r13d, %r13d
movq %r14, %rdi
movl %r13d, %esi
callq 0x4340
movq %rax, %rbp
movq %rax, %rdi
callq 0x4780
cmpl $0x2, %eax
jne 0x5b91
movq %rbp, %rdi
movq %r12, %rsi
callq 0x4360
cmpb $0x3, 0xb(%rsp)
jb 0x5b91
movq %rax, %rbx
cmpb $0x21, 0x1(%rax)
jne 0x5b91
cmpb $0x21, 0x2(%rbx)
je 0x5b91
movzbl (%rbx), %r15d
leal -0x36(%r15), %eax
cmpb $-0x5, %al
jb 0x5b91
movq %rbx, %rdi
addq $0x2, %rdi
movq 0x10(%rsp), %rsi
testq %rsi, %rsi
je 0x5b31
callq 0x4400
testl %eax, %eax
jne 0x5b91
jmp 0x5b36
movq %rdi, 0x10(%rsp)
cmpq $0x0, -0x168(%rsp,%r15,8)
je 0x5b58
movl 0x1c(%rsp), %edi
leaq 0x7c1d(%rip), %rsi      # 0xd769
movq %rbx, %rdx
xorl %eax, %eax
callq 0x4949
jmp 0x5b91
movq %rbp, %rdi
callq 0x4180
movq %rax, %rdi
callq 0x4150
movq %rax, -0x168(%rsp,%r15,8)
movq %rax, %rdi
callq 0x4500
movl $0x3, %edi
leaq 0x7c0c(%rip), %rsi      # 0xd790
movq %rbx, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x4949
incl %r13d
movq %r14, %rdi
callq 0x4240
cmpl %eax, %r13d
jb 0x5abd
leaq 0x20(%rsp), %rsi
movq 0x10(%rsp), %rdi
movl 0xc(%rsp), %edx
callq 0x5e64
addq $0x48, %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/zcfileset.c
// Function: fromFileDataInternal
static ZcFileSet *fromFileDataInternal(const FileData *file, int logerrors)
{
    D64 *d64 = readD64FromFileData(file);
    if (!d64) return 0;
    CbmdosVfs *vfs = CbmdosVfs_create();
    int rc = readCbmdosVfs(vfs, d64, 0);
    D64_destroy(d64);
    if (rc < 0)
    {
        CbmdosVfs_destroy(vfs);
        return 0;
    }
    ZcFileSet *self = fromVfsInternal(vfs, logerrors);
    CbmdosVfs_destroy(vfs);
    return self;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %esi, %ebx
callq 0x4200
testq %rax, %rax
je 0x5c29
movq %rax, %r12
callq 0x4520
movq %rax, %r15
xorl %r14d, %r14d
movq %rax, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x42c0
movl %eax, %ebp
movq %r12, %rdi
callq 0x45b0
testl %ebp, %ebp
js 0x5c1f
movq %r15, %rdi
movl %ebx, %esi
callq 0x5a29
movq %rax, %r14
movq %r15, %rdi
callq 0x4490
jmp 0x5c2c
xorl %r14d, %r14d
movq %r14, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/excess-c64[P]lib1541img/src/lib/1541img/zcfileset.c
// Function: fromFileData
static ZcFileSet *fromFileData(
        const char *name, FileData **files, int logerrors)
{
    ZcFileSet *self = 0;

    if (files[0] && files[1] && files[2] && files[3])
    {
        if (files[4])
        {
            logmsg(L_INFO, "ZcFileSet: 5-file disk-packed zipcode "
                    "read successfully.");
            self = xmalloc(sizeof *self + 5 * sizeof *self->files);
            self->type = ZT_5PACK;
            self->count = 5;
            memcpy(self->files, files, 5 * sizeof *self->files);
        }
        else
        {
            logmsg(L_INFO, "ZcFileSet: 4-file disk-packed zipcode "
                    "read successfully.");
            self = xmalloc(sizeof *self + 4 * sizeof *self->files);
            self->type = ZT_4PACK;
            self->count = 4;
            memcpy(self->files, files, 4 * sizeof *self->files);
        }
        self->name = copystr(name);
    }
    else
    {
        if (logerrors)
        {
            logmsg(L_ERROR, "ZcFileSet: reading failed (missing or "
                    "unreadable files).");
        }
        for (int i = 0; i < 5; ++i) FileData_destroy(files[i]);
    }

    return self;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
cmpq $0x0, (%rsi)
je 0x5ed7
cmpq $0x0, 0x8(%rbx)
je 0x5ed7
cmpq $0x0, 0x10(%rbx)
je 0x5ed7
cmpq $0x0, 0x18(%rbx)
je 0x5ed7
movq %rdi, %r14
cmpq $0x0, 0x20(%rbx)
je 0x5f0d
leaq 0x791e(%rip), %rsi      # 0xd7b6
movl $0x3, %edi
callq 0x491c
movl $0x38, %edi
callq 0x485c
movq %rax, %r15
movabsq $0x500000001, %rax      # imm = 0x500000001
movq %rax, (%r15)
movups (%rbx), %xmm0
movups 0x10(%rbx), %xmm1
movups %xmm0, 0x10(%r15)
movups %xmm1, 0x20(%r15)
movq 0x20(%rbx), %rax
movq %rax, 0x30(%r15)
jmp 0x5f49
testl %edx, %edx
je 0x5eec
leaq 0x7946(%rip), %rsi      # 0xd828
movl $0x1, %edi
callq 0x491c
xorl %r15d, %r15d
xorl %r14d, %r14d
movq (%rbx,%r14,8), %rdi
callq 0x43d0
incq %r14
cmpq $0x5, %r14
jne 0x5ef2
movq %r15, %rax
popq %rbx
popq %r14
popq %r15
retq
leaq 0x78db(%rip), %rsi      # 0xd7ef
movl $0x3, %edi
callq 0x491c
movl $0x30, %edi
callq 0x485c
movq %rax, %r15
movabsq $0x400000000, %rax      # imm = 0x400000000
movq %rax, (%r15)
movups (%rbx), %xmm0
movups 0x10(%rbx), %xmm1
movups %xmm0, 0x10(%r15)
movups %xmm1, 0x20(%r15)
movq %r14, %rdi
callq 0x489c
movq %rax, 0x8(%r15)
jmp 0x5f04
// File: /workspace/github_c_makefile_star2_O1/excess-c64[P]lib1541img/src/lib/1541img/zcfileset.c
// Function: ZcFileSet_saveVfs
SOEXPORT int ZcFileSet_saveVfs(const ZcFileSet *self, CbmdosVfs *vfs)
{
    char name[16];
    uint8_t baselen = strlen(self->name) > 14 ? 14 : strlen(self->name);
    memcpy(name+2, self->name, baselen);
    name[1] = '!';
    for (name[0] = '1'; name[0] < (self->type == ZT_5PACK ? '6' : '5');
	    ++name [0])
    {
	CbmdosFile *file = CbmdosFile_create();
	CbmdosFile_setName(file, name, baselen+2);
	FileData *cfd = CbmdosFile_data(file);
	const FileData *fd = self->files[name[0]-'1'];
	if (FileData_append(cfd, FileData_rcontent(fd), FileData_size(fd)) < 0)
	{
	    return -1;
	}
	if (CbmdosVfs_append(vfs, file))
	{
	    return -1;
	}
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, 0x10(%rsp)
movq %rdi, %r14
movq 0x8(%rdi), %r15
movq %r15, %rdi
callq 0x4250
cmpq $0xe, %rax
movl $0xe, %r12d
cmovbq %rax, %r12
leaq 0x2(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x4470
movw $0x2131, -0x2(%r13)     # imm = 0x2131
leal 0x2(%r12), %eax
movzbl %al, %ebp
callq 0x4390
movq %rax, %r12
movq %rax, %rdi
movq %rsp, %rsi
movl %ebp, %edx
callq 0x42f0
movq %r12, %rdi
callq 0x4610
movq %rax, %r13
movsbq (%rsp), %rax
movq -0x178(%r14,%rax,8), %r15
movq %r15, %rdi
callq 0x4640
movq %rax, %rbx
movq %r15, %rdi
callq 0x4500
movq %r13, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x4720
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
testl %eax, %eax
js 0x626f
movq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0x44b0
testl %eax, %eax
jne 0x626f
movb (%rsp), %al
incb %al
movb %al, (%rsp)
xorl %ecx, %ecx
cmpl $0x1, (%r14)
movsbl %al, %eax
sete %cl
addl $0x35, %ecx
cmpl %eax, %ecx
jg 0x61e4
xorl %r13d, %r13d
movl %r13d, %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/zcfileset.c
// Function: ZcFileSet_destroy
SOEXPORT void ZcFileSet_destroy(ZcFileSet *self)
{
    if (!self) return;
    free(self->name);
    for (int i = 0; i < self->count; ++i) FileData_destroy(self->files[i]);
    free(self);
}

// Assembly:
testq %rdi, %rdi
je 0x62c4
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
callq 0x4080
cmpl $0x0, 0x4(%rbx)
jle 0x62b5
xorl %r14d, %r14d
movq 0x10(%rbx,%r14,8), %rdi
callq 0x43d0
incq %r14
movslq 0x4(%rbx), %rax
cmpq %rax, %r14
jl 0x629f
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x4080
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O1/excess-c64[P]lib1541img/src/lib/1541img/zc45extractor.c
// Function: extractZc45
SOEXPORT D64 *extractZc45(const ZcFileSet *fileset)
{
    if (!fileset) return 0;
    ZcType type = ZcFileSet_type(fileset);
    if (type != ZT_4PACK && type != ZT_5PACK)
    {
        logmsg(L_ERROR, "extractZc45: trying to extract something that isn't "
                "a 4 or 5 file disk Zippack.");
        return 0;
    }

    D64 *extracted = D64_create(type == ZT_4PACK ? D64_STANDARD : D64_40TRACK);
    for (int i = 0; i < (type == ZT_4PACK ? 4 : 5); ++i)
    {
	const FileData *fd = ZcFileSet_rfileData(fileset, i);
	if (zc45_read(extracted, sectorcount[i],
                    FileData_rcontent(fd), FileData_size(fd))
		!= sectorcount[i])
	{
            logfmt(L_ERROR, "extractZc45: extraction failed in part %d.", i+1);
	    D64_destroy(extracted);
	    return 0;
	}
    }

    logfmt(L_DEBUG, "extractZc45: %d-file zipcode successfully extracted.",
            type == ZT_4PACK ? 4 : 5);
    return extracted;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testq %rdi, %rdi
je 0x63b9
movq %rdi, %rbx
callq 0x44e0
cmpl $0x2, %eax
jb 0x6302
leaq 0x75ef(%rip), %rsi      # 0xd8e2
movl $0x1, %edi
callq 0x491c
jmp 0x63b9
movl %eax, %ebp
movl %eax, %edi
callq 0x45c0
movq %rax, %r13
cmpl $0x1, %ebp
movl $0x5, %eax
sbbl $0x0, %eax
movq %rax, 0x8(%rsp)
leaq 0x767b(%rip), %r15      # 0xd9a0
xorl %r12d, %r12d
movq %r13, 0x10(%rsp)
movq %rbx, %r14
movq %rbx, %rdi
movl %r12d, %esi
callq 0x4350
movq %rax, %r13
movl (%r15), %ebp
movq %rax, %rdi
callq 0x4640
movq %rax, %rbx
movq %r13, %rdi
movq 0x10(%rsp), %r13
callq 0x4500
movq %r13, %rdi
movl %ebp, %esi
movq %rbx, %rdx
movq %rax, %rcx
callq 0x4070
cmpl %ebp, %eax
jne 0x6398
incq %r12
addq $0x4, %r15
cmpq %r12, 0x8(%rsp)
movq %r14, %rbx
jne 0x632d
leaq 0x75d8(%rip), %rsi      # 0xd95d
movl $0x4, %edi
movq 0x8(%rsp), %rdx
xorl %eax, %eax
callq 0x4949
jmp 0x63bc
incl %r12d
leaq 0x7590(%rip), %rsi      # 0xd932
movl $0x1, %edi
movl %r12d, %edx
xorl %eax, %eax
callq 0x4949
movq %r13, %rdi
callq 0x45b0
xorl %r13d, %r13d
movq %r13, %rax
addq $0x18, %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/cbmdosfile.c
// Function: CbmdosFile_baseCreate
static CbmdosFile *CbmdosFile_baseCreate(CbmdosInode *inode)
{
    CbmdosFile *self = xmalloc(sizeof *self);
    memset(self, 0, sizeof *self);
    self->inode = inode;
    self->changedEvent = Event_create(0, self);
    self->type = CFT_PRG;
    self->invalidType = -1;
    self->closed = 1;
    self->forcedBlocks = 0xffff;
    self->recordLength = 254;
    CbmdosInode_attach(self->inode);
    Event_register(CbmdosInode_changedEvent(self->inode), self, inodeHandler);
    return self;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
movl $0x30, %edi
callq 0x485c
movq %rax, %rbx
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
movups %xmm0, 0x20(%rax)
movq %r14, 0x10(%rax)
xorl %edi, %edi
movq %rax, %rsi
callq 0x4270
movq %rax, (%rbx)
movabsq $-0xfffffffe, %rax      # imm = 0xFFFFFFFF00000002
movq %rax, 0x18(%rbx)
movl $0x1, 0x24(%rbx)
movw $0xffff, 0x2e(%rbx)     # imm = 0xFFFF
movb $-0x2, 0x2d(%rbx)
movq 0x10(%rbx), %rdi
callq 0xa8a6
movq 0x10(%rbx), %rdi
callq 0x46c0
leaq 0x196(%rip), %rdx       # 0x65f3
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/cbmdosfile.c
// Function: CbmdosFile_clone
SOEXPORT CbmdosFile *CbmdosFile_clone(const CbmdosFile *other)
{
    CbmdosFile *self = xmalloc(sizeof *self);
    self->type = other->type;
    self->invalidType = other->invalidType;
    self->locked = other->locked;
    self->closed = other->closed;
    self->autoMapToLc = 0;
    self->name = 0;
    self->inode = CbmdosInode_clone(other->inode);
    self->changedEvent = Event_create(0, self);
    self->nameLength = 0;
    self->recordLength = other->recordLength;
    self->forcedBlocks = other->forcedBlocks;
    uint8_t len;
    const char *name = CbmdosFile_name(other, &len);
    CbmdosFile_setName(self, name, len);
    self->autoMapToLc = other->autoMapToLc;
    CbmdosInode_attach(self->inode);
    Event_register(CbmdosInode_changedEvent(self->inode), self, inodeHandler);
    return self;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
movl $0x30, %edi
callq 0x485c
movq %rax, %rbx
movl 0x18(%r14), %eax
movl %eax, 0x18(%rbx)
movl 0x1c(%r14), %eax
movl %eax, 0x1c(%rbx)
movl 0x20(%r14), %eax
movl %eax, 0x20(%rbx)
movl 0x24(%r14), %eax
movl %eax, 0x24(%rbx)
movl $0x0, 0x28(%rbx)
movq $0x0, 0x8(%rbx)
movq 0x10(%r14), %rdi
callq 0xa749
movq %rax, 0x10(%rbx)
xorl %edi, %edi
movq %rbx, %rsi
callq 0x4270
movq %rax, (%rbx)
movb $0x0, 0x2c(%rbx)
movb 0x2d(%r14), %al
movb %al, 0x2d(%rbx)
movzwl 0x2e(%r14), %eax
movw %ax, 0x2e(%rbx)
movzbl 0x2c(%r14), %edx
movq 0x8(%r14), %rsi
movq %rbx, %rdi
callq 0x42f0
movl 0x28(%r14), %eax
movl %eax, 0x28(%rbx)
movq 0x10(%rbx), %rdi
callq 0xa8a6
movq 0x10(%rbx), %rdi
callq 0x46c0
leaq 0xe2(%rip), %rdx        # 0x65f3
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/cbmdosfile.c
// Function: CbmdosFile_setName
SOEXPORT void CbmdosFile_setName(
	CbmdosFile *self, const char *name, uint8_t length)
{
    if (length > 16)
    {
        logmsg(L_WARNING, "CbmdosFile_setName: truncating long name.");
        length = 16;
    }
    free(self->name);
    if (name)
    {
        self->name = xmalloc(length+1);
        memcpy(self->name, name, length);
        self->name[length] = 0;
    }
    else
    {
        self->name = 0;
        if (length)
        {
            logmsg(L_WARNING, "CbmdosFile_setName: length > 0 given for empty "
                    "name.");
            length = 0;
        }
    }
    self->nameLength = length;
    if (self->autoMapToLc)
    {
	petscii_mapUpperGfxToLower(self->name, self->nameLength);
    }
    CbmdosFileEventArgs args = { CFE_NAMECHANGED };
    Event_raise(self->changedEvent, &args);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %rbx
cmpb $0x11, %r14b
jb 0x6561
leaq 0x7482(%rip), %rsi      # 0xd9d6
movl $0x2, %edi
callq 0x491c
movb $0x10, %r14b
movq 0x8(%rbx), %rdi
callq 0x4080
testq %r15, %r15
je 0x659c
leal 0x1(%r14), %eax
movzbl %al, %edi
callq 0x485c
movq %rax, 0x8(%rbx)
movzbl %r14b, %r12d
movq %rax, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x4470
movq 0x8(%rbx), %rax
movb $0x0, (%rax,%r12)
jmp 0x65bd
movq $0x0, 0x8(%rbx)
testb %r14b, %r14b
je 0x65ba
leaq 0x7450(%rip), %rsi      # 0xda00
movl $0x2, %edi
callq 0x491c
xorl %r14d, %r14d
movb %r14b, 0x2c(%rbx)
cmpl $0x0, 0x28(%rbx)
je 0x65d4
movq 0x8(%rbx), %rdi
movzbl %r14b, %esi
callq 0x4760
leaq 0x4(%rsp), %rsi
movl $0x1, (%rsi)
movq (%rbx), %rdi
callq 0x45e0
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/cbmdosfile.c
// Function: CbmdosFile_setType
SOEXPORT int CbmdosFile_setType(CbmdosFile *self, CbmdosFileType type)
{
    int rc = 0;
    int invalidType = -1;
    type &= 0xf;
    if (type < CFT_DEL || type > CFT_REL)
    {
        logmsg(L_WARNING, "CbmdosFile_setType: invalid type.");
	invalidType = type;
        type = CFT_DEL;
	rc = -1;
    }
    if (type == self->type && invalidType == self->invalidType) return rc;
    if ((self->invalidType < 0 && self->type == CFT_DEL) ||
	    (invalidType < 0 && type == CFT_DEL))
    {
	CbmdosFile_setData(self, FileData_create());
    }
    self->type = type;
    self->invalidType = invalidType;
    CbmdosFileEventArgs args = { CFE_TYPECHANGED };
    Event_raise(self->changedEvent, &args);
    return rc;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
andl $0xf, %ebp
cmpl $0x5, %ebp
jb 0x6660
leaq 0x7369(%rip), %rsi      # 0xd9b4
movl $0x2, %edi
callq 0x491c
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
xorl %r15d, %r15d
jmp 0x666b
xorl %r14d, %r14d
movl %ebp, %r15d
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl 0x18(%rbx), %eax
cmpl %eax, %r15d
jne 0x6678
cmpl 0x1c(%rbx), %ebp
je 0x66bc
testl %eax, %eax
jne 0x6682
cmpl $0x0, 0x1c(%rbx)
js 0x6691
testl %ebp, %ebp
setns %al
testl %r15d, %r15d
setne %cl
orb %al, %cl
jne 0x66a2
callq 0x44f0
movq 0x10(%rbx), %rdi
movq %rax, %rsi
callq 0x41c0
movl %r15d, 0x18(%rbx)
movl %ebp, 0x1c(%rbx)
leaq 0x4(%rsp), %rsi
movl $0x0, (%rsi)
movq (%rbx), %rdi
callq 0x45e0
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/excess-c64[P]lib1541img/src/lib/1541img/cbmdosfile.c
// Function: CbmdosFile_exportPC64
SOEXPORT int CbmdosFile_exportPC64(const CbmdosFile *self, FILE *file)
{
    uint8_t header[26] = "C64File";
    memcpy(header+8, self->name, self->nameLength);
    if (self->type == CFT_REL) header[25] = self->recordLength;
    if (fwrite(header, sizeof header, 1, file) != 1) return -1;
    return writeHostFile(CbmdosInode_rdata(self->inode), file);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movups 0x739a(%rip), %xmm0     # 0xdada
leaq 0x8(%rsp), %rdi
movups %xmm0, 0x2(%rdi)
movaps 0x7380(%rip), %xmm0     # 0xdad0
movaps %xmm0, -0x8(%rdi)
movq 0x8(%r14), %rsi
movzbl 0x2c(%r14), %edx
callq 0x4470
cmpl $0x4, 0x18(%r14)
jne 0x6771
movb 0x2d(%r14), %al
movb %al, 0x19(%rsp)
movq %rsp, %rdi
movl $0x1a, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x46e0
cmpq $0x1, %rax
jne 0x67a7
movq 0x10(%r14), %rdi
callq 0x4230
movq %rax, %rdi
movq %rbx, %rsi
addq $0x28, %rsp
popq %rbx
popq %r14
jmp 0x45a0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x28, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/excess-c64[P]lib1541img/src/lib/1541img/cbmdosfile.c
// Function: CbmdosFile_import
SOEXPORT int CbmdosFile_import(CbmdosFile *self, FILE *file)
{
    FileData *data = readHostFile(file);
    if (!data) return -1;
    const uint8_t *content = FileData_rcontent(data);
    if (FileData_size(data) > 26 && !content[24]
	    && !memcmp(content, "C64File", sizeof "C64File"))
    {
	FileData *raw = FileData_create();
	if (!raw)
	{
	    FileData_destroy(data);
	    return -1;
	}
	if (FileData_append(raw, content+26, FileData_size(data)-26) < 0)
	{
	    FileData_destroy(raw);
	    FileData_destroy(data);
	    return -1;
	}
	CbmdosFile_setData(self, raw);
	CbmdosFile_setName(self, (const char *)content+8,
		strlen((const char *)content+8));
	CbmdosFile_setRecordLength(self, content[25] ? content[25] : 254);
	FileData_destroy(data);
    }
    else
    {
	CbmdosFile_setData(self, data);
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
movq %rsi, %rdi
callq 0x42d0
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x6814
movq %rax, %rbx
movq %rax, %rdi
callq 0x4640
movq %rax, %r15
movq %rbx, %rdi
callq 0x4500
cmpq $0x1b, %rax
jb 0x6806
cmpb $0x0, 0x18(%r15)
jne 0x6806
movabsq $0x656c6946343643, %rax # imm = 0x656C6946343643
cmpq %rax, (%r15)
je 0x6825
movq 0x10(%r14), %rdi
movq %rbx, %rsi
callq 0x41c0
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x44f0
testq %rax, %rax
je 0x68ae
movq %rax, %r12
leaq 0x1a(%r15), %r13
movq %rbx, %rdi
callq 0x4500
leaq -0x1a(%rax), %rdx
movq %r12, %rdi
movq %r13, %rsi
callq 0x4720
testl %eax, %eax
js 0x68a6
movq 0x10(%r14), %rdi
movq %r12, %rsi
callq 0x41c0
movq %r15, %r12
addq $0x8, %r12
movq %r12, %rdi
callq 0x4250
movl $0xff, %ebp
andl %ebp, %eax
movq %r14, %rdi
movq %r12, %rsi
movl %eax, %edx
callq 0x42f0
movzbl 0x19(%r15), %eax
testb %al, %al
movl $0xfe, %esi
cmovnel %eax, %esi
andl %ebp, %esi
movq %r14, %rdi
callq 0x4580
movq %rbx, %rdi
callq 0x43d0
jmp 0x6812
movq %r12, %rdi
callq 0x43d0
movq %rbx, %rdi
callq 0x43d0
jmp 0x6814
// File: /workspace/github_c_makefile_star2_O1/excess-c64[P]lib1541img/src/lib/1541img/cbmdosfile.c
// Function: CbmdosFile_setRecordLength
SOEXPORT int CbmdosFile_setRecordLength(CbmdosFile *self, uint8_t recordLength)
{
    if (recordLength > 254)
    {
        logmsg(L_WARNING, "CbmdosFile_setRecordLength: invalid length, "
                "max is 254.");
        return -1;
    }
    if (recordLength < 1)
    {
        logmsg(L_WARNING, "CbmdosFile_setRecordLength: invalid length, "
                "min is 1.");
        return -1;
    }
    self->recordLength = recordLength;
    CbmdosFileEventArgs ea = { CFE_RECORDLENGTHCHANGED };
    Event_raise(self->changedEvent, &ea);
    return 0;
}

// Assembly:
pushq %rax
testl %esi, %esi
je 0x68d1
cmpl $0xff, %esi
jne 0x68e9
leaq 0x716e(%rip), %rsi      # 0xda3d
jmp 0x68d8
leaq 0x719d(%rip), %rsi      # 0xda75
movl $0x2, %edi
callq 0x491c
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x6902
movb %sil, 0x2d(%rdi)
leaq 0x4(%rsp), %rsi
movl $0x6, (%rsi)
movq (%rdi), %rdi
callq 0x45e0
xorl %eax, %eax
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O1/excess-c64[P]lib1541img/src/lib/1541img/cbmdosfile.c
// Function: CbmdosFile_getDirLine
SOEXPORT void CbmdosFile_getDirLine(const CbmdosFile *self, uint8_t *line)
{
    int blocklen = sprintf((char *)line, "%u", CbmdosFile_blocks(self));
    memset(line + blocklen, 0xa0, 28 - blocklen);
    memcpy(line + 6, self->name, self->nameLength);
    if (self->invalidType < 0)
    {
	memcpy(line + 24, CbmdosFileType_name(self->type), 3);
    }
    else
    {
	memcpy(line + 24, "?  ", 3);
    }
    line[5] = 0x22;
    uint8_t endidx = 6;
    int qclosed = 0;
    while (line[endidx] != 0xa0)
    {
	if (line[endidx] == 0x22) qclosed = 1;
	++endidx;
    }
    if (!qclosed) line[endidx] = 0x22;
    if (!self->closed) line[23] = 0x2a;
    if (self->locked) line[27] = 0x3c;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movzwl 0x2e(%rdi), %eax
cmpw $-0x1, %ax
jne 0x69e7
cmpl $0x0, 0x18(%r14)
je 0x69e5
movq 0x10(%r14), %rdi
callq 0x4300
jmp 0x69e7
xorl %eax, %eax
movzwl %ax, %edx
leaq 0x70ba(%rip), %rsi      # 0xdaab
movq %rbx, %rdi
xorl %eax, %eax
callq 0x46d0
cltq
leaq (%rbx,%rax), %rdi
movl $0x1c, %ecx
subl %eax, %ecx
movslq %ecx, %rdx
movl $0xa0, %esi
callq 0x4320
leaq 0x6(%rbx), %rdi
movq 0x8(%r14), %rsi
movzbl 0x2c(%r14), %edx
callq 0x4470
leaq 0x18(%rbx), %rax
cmpl $0x0, 0x1c(%r14)
js 0x6a3d
movb $0x20, 0x2(%rax)
movw $0x203f, (%rax)         # imm = 0x203F
jmp 0x6a58
movl 0x18(%r14), %ecx
leaq 0xbf88(%rip), %rdx      # 0x129d0
movq (%rdx,%rcx,8), %rcx
movb 0x2(%rcx), %dl
movb %dl, 0x2(%rax)
movzwl (%rcx), %ecx
movw %cx, (%rax)
movb $0x22, 0x5(%rbx)
xorl %ecx, %ecx
movb $0x6, %al
movzbl %al, %eax
movzbl (%rbx,%rax), %edx
cmpl $0x22, %edx
je 0x6a76
cmpl $0xa0, %edx
jne 0x6a7b
jmp 0x6a7f
movl $0x1, %ecx
incb %al
jmp 0x6a60
testl %ecx, %ecx
jne 0x6a87
movb $0x22, (%rbx,%rax)
cmpl $0x0, 0x24(%r14)
jne 0x6a92
movb $0x2a, 0x17(%rbx)
cmpl $0x0, 0x20(%r14)
je 0x6a9d
movb $0x3c, 0x1b(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/excess-c64[P]lib1541img/src/lib/1541img/cbmdosfile.c
// Function: CbmdosFile_destroy
SOEXPORT void CbmdosFile_destroy(CbmdosFile *self)
{
    if (!self) return;
    free(self->name);
    Event_destroy(self->changedEvent);
    Event_unregister(CbmdosInode_changedEvent(self->inode), self, inodeHandler);
    CbmdosInode_detach(self->inode);
    CbmdosInode_tryDestroy(self->inode);
    free(self);
}

// Assembly:
testq %rdi, %rdi
je 0x6af9
pushq %rbx
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
callq 0x4080
movq (%rbx), %rdi
callq 0x4170
movq 0x10(%rbx), %rdi
callq 0x46c0
leaq -0x4e0(%rip), %rdx      # 0x65f3
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4330
movq 0x10(%rbx), %rdi
callq 0xa8aa
movq 0x10(%rbx), %rdi
callq 0xa8c8
movq %rbx, %rdi
popq %rbx
jmp 0x4080
retq
nop
// File: /workspace/github_c_makefile_star2_O1/excess-c64[P]lib1541img/src/lib/1541img/cbmdosvfs.c
// Function: CbmdosVfs_create
SOEXPORT CbmdosVfs *CbmdosVfs_create(void)
{
    CbmdosVfs *self = xmalloc(sizeof *self);
    memset(self, 0, sizeof *self);
    self->files = xmalloc(DIRCHUNKSIZE * sizeof *self->files);
    self->fileCapa = DIRCHUNKSIZE;
    self->dosver = 0x41;
    self->changedEvent = Event_create(0, self);
    return self;
}

// Assembly:
pushq %rbx
movl $0x38, %edi
callq 0x485c
movq %rax, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, 0x20(%rax)
movq $0x0, 0x30(%rax)
movl $0x480, %edi            # imm = 0x480
callq 0x485c
movq %rax, 0x18(%rbx)
movl $0x90, 0x2c(%rbx)
movb $0x41, 0x32(%rbx)
xorl %edi, %edi
movq %rbx, %rsi
callq 0x4270
movq %rax, 0x20(%rbx)
movq %rbx, %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/excess-c64[P]lib1541img/src/lib/1541img/cbmdosvfs.c
// Function: CbmdosVfs_setName
SOEXPORT void CbmdosVfs_setName(
	CbmdosVfs *self, const char *name, uint8_t length)
{
    if (length > 16)
    {
        logmsg(L_WARNING, "CbmdosVfs_setName: truncating long name.");
        length = 16;
    }
    free(self->name);
    if (name)
    {
        self->name = xmalloc(length+1);
        memcpy(self->name, name, length);
        self->name[length] = 0;
    }
    else
    {
        self->name = 0;
        if (length)
        {
            logmsg(L_WARNING, "CbmdosVfs_setName: length > 0 given for empty "
                    "name.");
            length = 0;
        }
    }
    self->nameLength = length;
    if (self->autoMapToLc)
    {
	petscii_mapUpperGfxToLower(self->name, self->nameLength);
    }
    CbmdosVfsEventArgs args = { .what = CVE_NAMECHANGED };
    Event_raise(self->changedEvent, &args);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %rbx
cmpb $0x11, %r14b
jb 0x6bb3
leaq 0x6f5a(%rip), %rsi      # 0xdb00
movl $0x2, %edi
callq 0x491c
movb $0x10, %r14b
movq (%rbx), %rdi
callq 0x4080
testq %r15, %r15
je 0x6beb
leal 0x1(%r14), %eax
movzbl %al, %edi
callq 0x485c
movq %rax, (%rbx)
movzbl %r14b, %r12d
movq %rax, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x4470
movq (%rbx), %rax
movb $0x0, (%rax,%r12)
jmp 0x6c0b
movq $0x0, (%rbx)
testb %r14b, %r14b
je 0x6c08
leaq 0x6f2b(%rip), %rsi      # 0xdb29
movl $0x2, %edi
callq 0x491c
xorl %r14d, %r14d
movb %r14b, 0x30(%rbx)
cmpl $0x0, 0x10(%rbx)
je 0x6c21
movq (%rbx), %rdi
movzbl %r14b, %esi
callq 0x4760
movq 0x7040(%rip), %rax      # 0xdc68
movq %rsp, %rsi
movq %rax, 0x10(%rsi)
movups 0x7022(%rip), %xmm0     # 0xdc58
movaps %xmm0, (%rsi)
movq 0x20(%rbx), %rdi
callq 0x45e0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/excess-c64[P]lib1541img/src/lib/1541img/cbmdosvfs.c
// Function: CbmdosVfs_setId
SOEXPORT void CbmdosVfs_setId(CbmdosVfs *self, const char *id, uint8_t length)
{
    if (length > 5)
    {
        logmsg(L_WARNING, "CbmdosVfs_setId: truncating long id.");
        length = 5;
    }
    free(self->id);
    if (id)
    {
        self->id = xmalloc(length+1);
        memcpy(self->id, id, length);
        self->id[length] = 0;
    }
    else
    {
        self->id = 0;
        if (length)
        {
            logmsg(L_WARNING, "CbmdosVfs_setId: length > 0 given for empty "
                    "id.");
            length = 0;
        }
    }
    self->idLength = length;
    if (self->autoMapToLc)
    {
	petscii_mapUpperGfxToLower(self->id, self->idLength);
    }
    CbmdosVfsEventArgs args = { .what = CVE_IDCHANGED };
    Event_raise(self->changedEvent, &args);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %rbx
cmpb $0x6, %r14b
jb 0x6c8b
leaq 0x6edf(%rip), %rsi      # 0xdb5d
movl $0x2, %edi
callq 0x491c
movb $0x5, %r14b
movq 0x8(%rbx), %rdi
callq 0x4080
testq %r15, %r15
je 0x6cc6
leal 0x1(%r14), %eax
movzbl %al, %edi
callq 0x485c
movq %rax, 0x8(%rbx)
movzbl %r14b, %r12d
movq %rax, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x4470
movq 0x8(%rbx), %rax
movb $0x0, (%rax,%r12)
jmp 0x6ce7
movq $0x0, 0x8(%rbx)
testb %r14b, %r14b
je 0x6ce4
leaq 0x6ea8(%rip), %rsi      # 0xdb82
movl $0x2, %edi
callq 0x491c
xorl %r14d, %r14d
movb %r14b, 0x31(%rbx)
cmpl $0x0, 0x10(%rbx)
je 0x6cfe
movq 0x8(%rbx), %rdi
movzbl %r14b, %esi
callq 0x4760
movq 0x6f4b(%rip), %rax      # 0xdc50
movq %rsp, %rsi
movq %rax, 0x10(%rsi)
movups 0x6f2d(%rip), %xmm0     # 0xdc40
movaps %xmm0, (%rsi)
movq 0x20(%rbx), %rdi
callq 0x45e0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x6d5a
cmpl $0x0, 0x28(%rbx)
je 0x6d5a
xorl %r14d, %r14d
movq 0x18(%rbx), %rax
movq (%rax,%r14,8), %rdi
callq 0x4710
incq %r14
movl 0x28(%rbx), %eax
cmpq %rax, %r14
jb 0x6d42
movq (%rbx), %rdi
movzbl 0x30(%rbx), %esi
callq 0x4760
movq 0x6efb(%rip), %rax      # 0xdc68
movq %rsp, %r14
movq %rax, 0x10(%r14)
movups 0x6edd(%rip), %xmm0     # 0xdc58
movaps %xmm0, (%r14)
movq 0x20(%rbx), %rdi
movq %r14, %rsi
callq 0x45e0
movq 0x8(%rbx), %rdi
movzbl 0x31(%rbx), %esi
callq 0x4760
movl $0x2, (%r14)
movq 0x20(%rbx), %rdi
movq %r14, %rsi
callq 0x45e0
addq $0x18, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x6e00
movq %rsi, %rax
movq 0x18(%rdi), %rdx
xorl %esi, %esi
cmpq %rax, (%rdx,%rsi,8)
je 0x6e02
incq %rsi
cmpl %esi, %ecx
jne 0x6def
movl %ecx, %esi
jmp 0x6e02
xorl %esi, %esi
cmpl %ecx, %esi
jne 0x6e1e
leaq 0x6da5(%rip), %rsi      # 0xdbb2
movl $0x2, %edi
callq 0x491c
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
popq %rcx
retq
popq %rax
jmp 0x4120
// File: /workspace/github_c_makefile_star2_O1/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 0x6e95
movl %esi, %ebp
movq %rdi, %rbx
movq 0x18(%rdi), %rax
movl %esi, %r14d
movq (%rax,%r14,8), %rdi
callq 0x40e0
movl 0x28(%rbx), %edx
decl %edx
movl %edx, 0x28(%rbx)
subl %ebp, %edx
jbe 0x6e6b
movq 0x18(%rbx), %rax
leaq (%rax,%r14,8), %rdi
leaq (%rax,%r14,8), %rsi
addq $0x8, %rsi
shlq $0x3, %rdx
callq 0x4620
leaq 0x8(%rsp), %rsi
movl $0x4, (%rsi)
movq $0x0, 0x8(%rsi)
movl %ebp, 0x10(%rsi)
movl $0x0, 0x14(%rsi)
movq 0x20(%rbx), %rdi
callq 0x45e0
xorl %eax, %eax
jmp 0x6eab
leaq 0x6d38(%rip), %rsi      # 0xdbd4
movl $0x2, %edi
callq 0x491c
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x20, %rsp
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_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 0x6f2f
testl %eax, %eax
js 0x6f22
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 0x4660
leaq 0xa2(%rip), %rdx        # 0x6f8c
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4550
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 0x45e0
xorl %eax, %eax
jmp 0x6f27
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x18, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x2c(%rdi), %ebp
xorl %ebx, %ebx
cmpl %ebp, 0x28(%rdi)
jne 0x6f85
subl $0xffffff70, %ebp       # imm = 0xFFFFFF70
jae 0x6f66
movq %rdi, %r14
movq 0x18(%rdi), %rdi
movl %ebp, %esi
shlq $0x3, %rsi
callq 0x4590
testq %rax, %rax
je 0x6f6f
movq %rax, 0x18(%r14)
movl %ebp, 0x2c(%r14)
jmp 0x6f85
leaq 0x6c8b(%rip), %rsi      # 0xdbf8
jmp 0x6f76
leaq 0x6ca1(%rip), %rsi      # 0xdc17
movl $0x1, %edi
callq 0x491c
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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), %eax
testq %rax, %rax
je 0x6fad
movq 0x18(%rdi), %r8
xorl %esi, %esi
cmpq %rdx, (%r8,%rsi,8)
je 0x6fb1
incq %rsi
cmpl %esi, %eax
jne 0x6f9e
jmp 0x6fb3
xorl %eax, %eax
jmp 0x6fb3
movl %esi, %eax
movq %rsp, %rsi
movl $0x6, (%rsi)
movq %rcx, 0x8(%rsi)
movl %eax, 0x10(%rsi)
movl $0x0, 0x14(%rsi)
movq 0x20(%rdi), %rdi
callq 0x45e0
addq $0x18, %rsp
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x7074
movl %edx, %ebp
movq %rbx, %rdi
callq 0x6f2f
testl %eax, %eax
js 0x7089
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 0x4620
movq 0x18(%rbx), %rax
movq %r14, (%rax,%r15,8)
movq %r14, %rdi
callq 0x4660
leaq -0xb5(%rip), %rdx       # 0x6f8c
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4550
movq %rsp, %rsi
movl $0x3, (%rsi)
movq $0x0, 0x8(%rsi)
movl %ebp, 0x10(%rsi)
movl $0x0, 0x14(%rsi)
movq 0x20(%rbx), %rdi
callq 0x45e0
xorl %eax, %eax
jmp 0x708e
movq %rbx, %rdi
movq %r14, %rsi
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x44b0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq