// File: /workspace/github_c_makefile_star2_O3/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 %rbx
subq $0x30, %rsp
movq %rdi, %rbx
callq 0xd008
leaq 0x6ad9(%rip), %rsi      # 0x13b85
movq %rbx, %rdi
callq 0x21c0
testq %rax, %rax
je 0xd247
movq %rax, %rbx
movabsq $0x5f5f5f5f5f5f5f5f, %rax # imm = 0x5F5F5F5F5F5F5F5F
leaq 0x10(%rsp), %rdi
movq %rax, 0x18(%rdi)
movq %rax, 0x12(%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 0x6a47(%rip), %r14      # 0x13b5a
cmpq $0x1, %rax
jne 0xd23d
leaq 0xc(%rsp), %rdi
movl $0x40000, (%rdi)        # imm = 0x40000
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2200
cmpq $0x1, %rax
jne 0xd23d
leaq 0xc(%rsp), %rdi
movl $0x40000, (%rdi)        # imm = 0x40000
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2200
cmpq $0x1, %rax
jne 0xd23d
movq 0xc06e(%rip), %rdi      # 0x191e0
testq %rdi, %rdi
je 0xd1a6
leaq 0xc06a(%rip), %r15      # 0x191e8
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2200
cmpq $0x1, %rax
jne 0xd23d
movq (%r15), %rdi
addq $0x8, %r15
testq %rdi, %rdi
jne 0xd17e
movq 0xc193(%rip), %rdi      # 0x19340
movl $0x1, %esi
movl $0x100000, %edx         # imm = 0x100000
movq %rbx, %rcx
callq 0x2200
leaq 0x69ea(%rip), %r14      # 0x13bb0
cmpq $0x100000, %rax         # imm = 0x100000
jne 0xd23d
movq 0xc173(%rip), %rdi      # 0x19348
movl $0x1, %esi
movl $0x100000, %edx         # imm = 0x100000
movq %rbx, %rcx
callq 0x2200
cmpq $0x100000, %rax         # imm = 0x100000
jne 0xd23d
movq 0xc15a(%rip), %rdi      # 0x19350
movl $0x1, %esi
movl $0x40000, %edx          # imm = 0x40000
movq %rbx, %rcx
callq 0x2200
cmpq $0x40000, %rax          # imm = 0x40000
jne 0xd23d
movq 0xc141(%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 0x6977(%rip), %rax      # 0x13bb0
cmovneq %rax, %r14
movq %rbx, %rdi
callq 0x2070
jmp 0xd24e
leaq 0x693a(%rip), %r14      # 0x13b88
movq %r14, %rax
addq $0x30, %rsp
popq %rbx
popq %r14
popq %r15
retq