// File: /workspace/github_c_makefile_star2_O1/blakemcbride[P]LISP9/ls9.c
// Function: dumpimg
char *dumpimg(char *path) {
	FILE		*f;
	cell		n, **v;
	int		i;
	struct imghdr	m;
	char		*s;

	saveimg(path);
	f = fopen(path, "wb");
	if (NULL == f) return "cannot create image file";
	memset(&m, '_', sizeof(m));
	strncpy(m.magic, "LISP9", sizeof(m.magic));
	strncpy(m.version, VERSION, sizeof(m.version));
	m.cell_size[0] = sizeof(cell)+'0';
	n = 0x31323334L;
	memcpy(m.byte_order, &n, 4);
	if ((s = xfwrite(&m, sizeof(m), 1, f)) != NULL) {
		fclose(f);
		return s;
	}
	i = NNODES;
	if ((s = xfwrite(&i, sizeof(int), 1, f)) != NULL) {
		fclose(f);
		return s;
	}
	i = NVCELLS;
	if ((s = xfwrite(&i, sizeof(int), 1, f)) != NULL) {
		fclose(f);
		return s;
	}
	i = 0;
	v = Imagevars;
	while (v && v[i]) {
		if ((s = xfwrite(v[i], sizeof(cell), 1, f)) != NULL) {
			fclose(f);
			return s;
		}
		i++;
	}
	if (	fwrite(Car, 1, sizeof(cell) * NNODES, f)
		 != sizeof(cell) * NNODES ||
		fwrite(Cdr, 1, sizeof(cell) * NNODES, f)
		 != sizeof(cell) * NNODES ||
		fwrite(Tag, 1, NNODES, f) != NNODES||
		fwrite(Vectors, 1, sizeof(cell) * NVCELLS, f)
		 != sizeof(cell) * NVCELLS)
	{
		fclose(f);
		return "image dump failed";
	}
	fclose(f);
	return NULL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
callq 0xcf9d
leaq 0x6b12(%rip), %rsi      # 0x13b55
movq %rbx, %rdi
callq 0x21c0
testq %rax, %rax
je 0xd1dc
movq %rax, %rbx
movaps 0x6282(%rip), %xmm0     # 0x132e0
leaq 0x8(%rsp), %rdi
movups %xmm0, 0x5(%rdi)
movups %xmm0, 0x10(%rdi)
movl $0x5053494c, (%rdi)     # imm = 0x5053494C
movb $0x39, 0x4(%rdi)
movabsq $0x3231383039313032, %rax # imm = 0x3231383039313032
movq %rax, 0x5(%rdi)
movb $0x34, 0xd(%rdi)
movl $0x31323334, 0xe(%rdi)  # imm = 0x31323334
movl $0x20, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2200
leaq 0x6a83(%rip), %r14      # 0x13b2a
cmpq $0x1, %rax
jne 0xd1ea
leaq 0x4(%rsp), %rdi
movl $0x40000, (%rdi)        # imm = 0x40000
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2200
cmpq $0x1, %rax
jne 0xd1ea
leaq 0x4(%rsp), %rdi
movl $0x40000, (%rdi)        # imm = 0x40000
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2200
cmpq $0x1, %rax
jne 0xd1ea
movq 0xc0da(%rip), %rdi      # 0x191e0
xorl %r15d, %r15d
testq %rdi, %rdi
je 0xd13e
leaq 0xc0cb(%rip), %r12      # 0x191e0
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2200
cmpq $0x1, %rax
jne 0xd1e5
movq 0x8(%r12,%r15,8), %rdi
incq %r15
testq %rdi, %rdi
jne 0xd115
movl %r15d, 0x4(%rsp)
movq 0xc1f6(%rip), %rdi      # 0x19340
movl $0x1, %esi
movl $0x100000, %edx         # imm = 0x100000
movq %rbx, %rcx
callq 0x2200
leaq 0x6a1d(%rip), %r14      # 0x13b80
cmpq $0x100000, %rax         # imm = 0x100000
jne 0xd1ea
movq 0xc1d6(%rip), %rdi      # 0x19348
movl $0x1, %esi
movl $0x100000, %edx         # imm = 0x100000
movq %rbx, %rcx
callq 0x2200
cmpq $0x100000, %rax         # imm = 0x100000
jne 0xd1ea
movq 0xc1bd(%rip), %rdi      # 0x19350
movl $0x1, %esi
movl $0x40000, %edx          # imm = 0x40000
movq %rbx, %rcx
callq 0x2200
cmpq $0x40000, %rax          # imm = 0x40000
jne 0xd1ea
movq 0xc1a4(%rip), %rdi      # 0x19358
movl $0x1, %esi
movl $0x100000, %edx         # imm = 0x100000
movq %rbx, %rcx
callq 0x2200
xorl %r14d, %r14d
cmpq $0x100000, %rax         # imm = 0x100000
leaq 0x69aa(%rip), %rax      # 0x13b80
cmovneq %rax, %r14
jmp 0xd1ea
leaq 0x6975(%rip), %r14      # 0x13b58
jmp 0xd1f2
movl %r15d, 0x4(%rsp)
movq %rbx, %rdi
callq 0x2070
movq %r14, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq