// File: /workspace/github_c_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x30, %rsp
movq %rdi, %rbx
callq 0xb152
leaq 0x5950(%rip), %rsi      # 0x10b45
movq %rbx, %rdi
callq 0x21c0
testq %rax, %rax
je 0xb29f
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
pushq $0x20
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0xb12e
testq %rax, %rax
jne 0xb292
leaq 0xc(%rsp), %rdi
movl $0x40000, (%rdi)        # imm = 0x40000
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0xb12e
testq %rax, %rax
jne 0xb292
leaq 0xc(%rsp), %rdi
movl $0x40000, (%rdi)        # imm = 0x40000
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0xb12e
testq %rax, %rax
je 0xb2b6
movq %rax, %r14
movq %rbx, %rdi
callq 0x2070
jmp 0xb2a6
leaq 0x58a2(%rip), %r14      # 0x10b48
movq %r14, %rax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0xbf23(%rip), %r12      # 0x171e0
pushq $0x4
popq %rbp
pushq $0x1
popq %r15
movq (%r12), %rdi
testq %rdi, %rdi
je 0xb2e8
movl %ebp, %esi
movl %r15d, %edx
movq %rbx, %rcx
callq 0xb12e
movq %rax, %r14
addq $0x8, %r12
testq %rax, %rax
je 0xb2c4
jmp 0xb295
movq 0xc051(%rip), %rdi      # 0x17340
pushq $0x1
popq %rsi
movl $0x100000, %edx         # imm = 0x100000
movq %rbx, %rcx
callq 0x2200
leaq 0x586a(%rip), %r14      # 0x10b70
cmpq $0x100000, %rax         # imm = 0x100000
jne 0xb295
movq 0xc033(%rip), %rdi      # 0x17348
pushq $0x1
popq %rsi
movl $0x100000, %edx         # imm = 0x100000
movq %rbx, %rcx
callq 0x2200
cmpq $0x100000, %rax         # imm = 0x100000
jne 0xb295
movq 0xc018(%rip), %rdi      # 0x17350
pushq $0x1
popq %rsi
movl $0x40000, %edx          # imm = 0x40000
movq %rbx, %rcx
callq 0x2200
cmpq $0x40000, %rax          # imm = 0x40000
jne 0xb295
movq 0xbffd(%rip), %rdi      # 0x17358
pushq $0x1
popq %rsi
movl $0x100000, %edx         # imm = 0x100000
movq %rbx, %rcx
callq 0x2200
xorl %r14d, %r14d
cmpq $0x100000, %rax         # imm = 0x100000
leaq 0x57f5(%rip), %rax      # 0x10b70
cmovneq %rax, %r14
jmp 0xb295