// File: /workspace/github_c_makefile_star2_O3/excess-c64[P]lib1541img/src/lib/1541img/zcfileset.c
// Function: ZcFileSet_fromFile
SOEXPORT ZcFileSet *ZcFileSet_fromFile(const char *filename)
{
    ZcFileSet *self = 0;
    Filename *fn = Filename_create();
    Filename_setFull(fn, filename);
    char *ext = upperstr(Filename_ext(fn));
    if ((!ext || strcmp(ext, "D64"))
	    && Filename_base(fn)[1] == '!')
    {
	char *base = copystr(Filename_base(fn));
	if (base[0] >= '1' && base[0] <= '5'
		&& base[1] == '!' && base[2] != '!')
	{
            logmsg(L_INFO, "ZcFileSet: 4/5-file disk-packed zipcode "
                    "detected, looking for all member files...");
	    FileData *files[5] = { 0 };
	    for (base[0] = '1'; base[0] <= '5'; ++base[0])
	    {
		Filename *pn = Filename_clone(fn);
		Filename_setBase(pn, base);
                const char *ffn = Filename_full(pn);
                logfmt(L_INFO, "ZcFileSet: trying to read `%s'.", ffn);
		FILE *p = fopen_internal(ffn, "rb");
		if (p)
		{
		    files[base[0]-'1'] = readHostFile(p);
		    fclose(p);
		}
	    }
	    self = fromFileData(base+2, files, 1);
	}
        else
        {
            logmsg(L_WARNING, "ZcFileSet: no known ZipCode structure found.");
        }
	free(base);
    }
    else if (!strcmp(ext, "D64"))
    {
        self = fromD64(filename);
    }
    else
    {
        logmsg(L_WARNING, "ZcFileSet: no known ZipCode structure found.");
    }
    free(ext);
    return self;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %r15
callq 0x6554
movq %rax, %r14
movq %rax, %rdi
movq %r15, %rsi
callq 0x65ed
movq %r14, %rdi
callq 0x65e8
movq %rax, %rdi
callq 0x58c2
movq %rax, %rbx
testq %rax, %rax
je 0x6b57
leaq 0x7add(%rip), %rsi      # 0xe628
movq %rbx, %rdi
callq 0x5400
testl %eax, %eax
je 0x6bb3
movq %r14, %rdi
callq 0x65e3
cmpb $0x21, 0x1(%rax)
jne 0x6bb3
movq %r14, %rdi
callq 0x65e3
movq %rax, %rdi
callq 0x589c
movq %rax, %r15
movb (%rax), %al
addb $-0x31, %al
cmpb $0x4, %al
ja 0x6b92
cmpb $0x21, 0x1(%r15)
jne 0x6b92
cmpb $0x21, 0x2(%r15)
jne 0x6c61
leaq 0x7b08(%rip), %rsi      # 0xe6a1
movl $0x2, %edi
callq 0x591c
xorl %r14d, %r14d
movq %r15, %rdi
callq 0x5080
jmp 0x6c47
leaq 0x7a6e(%rip), %rsi      # 0xe628
movq %rbx, %rdi
callq 0x5400
testl %eax, %eax
je 0x6bdc
leaq 0x7ad4(%rip), %rsi      # 0xe6a1
movl $0x2, %edi
callq 0x591c
xorl %r14d, %r14d
jmp 0x6c47
leaq 0x7abb(%rip), %rsi      # 0xe69e
movq %r15, %rdi
callq 0x5650
testq %rax, %rax
je 0x6c25
movq %rax, %r14
movq %rax, %rdi
callq 0x52d0
movq %rax, %r12
movq %r14, %rdi
callq 0x5220
testq %r12, %r12
je 0x6c2e
movq %r12, %rdi
movl $0x1, %esi
callq 0x6aa1
movq %rax, %r14
movq %r12, %rdi
callq 0x53d0
jmp 0x6c47
leaq 0x7c35(%rip), %rsi      # 0xe861
jmp 0x6c35
leaq 0x7c57(%rip), %rsi      # 0xe88c
xorl %r14d, %r14d
movl $0x1, %edi
movq %r15, %rdx
xorl %eax, %eax
callq 0x5949
movq %rbx, %rdi
callq 0x5080
movq %r14, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rax
addq $0x2, %rax
movq %rax, 0x8(%rsp)
leaq 0x79b8(%rip), %rsi      # 0xe62c
movl $0x3, %edi
callq 0x591c
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x30(%rsp)
movb $0x31, (%r15)
leaq 0x79df(%rip), %r13      # 0xe67e
leaq 0x79f8(%rip), %rbp      # 0xe69e
movq %r14, %rdi
callq 0x656b
movq %rax, %r12
movq %rax, %rdi
movq %r15, %rsi
callq 0x67e5
movq %r12, %rdi
callq 0x65da
movq %rax, %r12
movl $0x3, %edi
movq %r13, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x5949
movq %r12, %rdi
movq %rbp, %rsi
callq 0x5650
testq %rax, %rax
je 0x6d08
movq %rax, %r12
movq %rax, %rdi
callq 0x52d0
movsbq (%r15), %rcx
movq %rax, -0x178(%rsp,%rcx,8)
movq %r12, %rdi
callq 0x5220
movb (%r15), %al
incb %al
movb %al, (%r15)
cmpb $0x36, %al
jl 0x6ca6
leaq 0x10(%rsp), %rsi
movq 0x8(%rsp), %rdi
movl $0x1, %edx
callq 0x6d30
movq %rax, %r14
jmp 0x6ba6