// File: /workspace/github_c_makefile_star2_O2/azhai[P]mlite/mlite.c
// Function: dump_image
void dump_image(char *p) {
	FILE		*f;
	cell		n, **v;
	int		i, k;
	struct magic	m;
	char		buf[100];

	f = fopen(p, "wb");
	if (f == NULL) {
		error("cannot create image file",
			make_string(p, (int) strlen(p)));
		return;
	}
	memset(&m, '_', sizeof(m));
	strncpy(m.id, "mL", sizeof(m.id));
	strncpy(m.version, VERSION, sizeof(m.version));
	m.cell_size[0] = sizeof(cell)+'0';
	m.mantissa_size[0] = MANTISSA_SEGMENTS+'0';
	n = ENDIANNESS;
	memcpy(m.byte_order, &n, sizeof(n)>8? 8: sizeof(n));
	n = Last_prim;
	memcpy(m.prim_slots, &n, sizeof(n)>8? 8: sizeof(n));
	fwrite(&m, sizeof(m), 1, f);
	i = Cons_pool_size;
	fwrite(&i, sizeof(int), 1, f);
	i = Vec_pool_size;
	fwrite(&i, sizeof(int), 1, f);
	v = Image_vars;
	i = 0;
	while (v[i]) {
		fwrite(v[i], sizeof(cell), 1, f);
		i++;
	}
	if (	fwrite(Car, 1, Cons_pool_size*sizeof(cell), f)
		 != Cons_pool_size*sizeof(cell) ||
		fwrite(Cdr, 1, Cons_pool_size*sizeof(cell), f)
		 != Cons_pool_size*sizeof(cell) ||
		fwrite(Tag, 1, Cons_pool_size, f) != Cons_pool_size ||
		fwrite(Vectors, 1, Vec_pool_size*sizeof(cell), f)
		 != Vec_pool_size*sizeof(cell)
	) {
		fclose(f);
		error("image dump failed", NOEXPR);
		return;
	}
	fclose(f);
	k = gc();
	if (!Quiet_mode) {
		sprintf(buf, "image dumped: %d nodes used, %d free",
				Cons_pool_size-k, k);
		pr(buf); nl();
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x90, %rsp
movq %rdi, %r14
leaq 0x4af5(%rip), %rsi      # 0x15195
callq 0x31c0
testq %rax, %rax
je 0x10837
movq %rax, %rbx
leaq -0x42(%rbp), %rdi
movw $0x4c6d, (%rdi)         # imm = 0x4C6D
movabsq $0x2d32312d34313032, %rax # imm = 0x2D32312D34313032
movq %rax, 0x2(%rdi)
movl $0x34383932, 0xa(%rdi)  # imm = 0x34383932
movq $0x31323334, 0xe(%rdi)  # imm = 0x31323334
movslq 0xc532(%rip), %rax      # 0x1cc10
movq %rax, 0x16(%rdi)
pushq $0x1e
popq %rsi
pushq $0x1
popq %r14
movq %r14, %rdx
movq %rbx, %rcx
callq 0x3210
movl 0xbeda(%rip), %eax      # 0x1c5d4
leaq -0x24(%rbp), %r15
movl %eax, (%r15)
pushq $0x4
popq %r12
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x3210
movl 0xbed4(%rip), %eax      # 0x1c5f0
movl %eax, (%r15)
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x3210
leaq 0xb859(%rip), %r12      # 0x1bf90
pushq $0x8
popq %r15
movq (%r12), %rdi
testq %rdi, %rdi
je 0x10758
movq %r15, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x3210
addq $0x8, %r12
jmp 0x1073b
movq 0xba11(%rip), %rdi      # 0x1c170
movslq 0xbe6e(%rip), %rdx      # 0x1c5d4
shlq $0x3, %rdx
pushq $0x1
popq %rsi
movq %rbx, %rcx
callq 0x3210
movslq 0xbe58(%rip), %rcx      # 0x1c5d4
shlq $0x3, %rcx
cmpq %rcx, %rax
jne 0x10823
movq 0xbe30(%rip), %rdi      # 0x1c5c0
pushq $0x1
popq %rsi
movq %rax, %rdx
movq %rbx, %rcx
callq 0x3210
movslq 0xbe2f(%rip), %rdx      # 0x1c5d4
leaq (,%rdx,8), %rcx
cmpq %rcx, %rax
jne 0x10823
movq 0xbe27(%rip), %rdi      # 0x1c5e0
pushq $0x1
popq %rsi
movq %rbx, %rcx
callq 0x3210
movslq 0xbe09(%rip), %rcx      # 0x1c5d4
cmpq %rcx, %rax
jne 0x10823
movq 0xbe11(%rip), %rdi      # 0x1c5e8
movslq 0xbe12(%rip), %rdx      # 0x1c5f0
shlq $0x3, %rdx
pushq $0x1
popq %rsi
movq %rbx, %rcx
callq 0x3210
movslq 0xbdfc(%rip), %rcx      # 0x1c5f0
shlq $0x3, %rcx
cmpq %rcx, %rax
jne 0x10823
movq %rbx, %rdi
callq 0x3090
callq 0x3dd2
cmpl $0x0, 0xbda7(%rip)      # 0x1c5b8
je 0x10867
addq $0x90, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0x3090
leaq 0x498d(%rip), %rdi      # 0x151bf
pushq $-0x8
popq %rsi
jmp 0x10853
movq %r14, %rdi
callq 0x30a0
movq %r14, %rdi
movl %eax, %esi
callq 0x729e
leaq 0x4948(%rip), %rdi      # 0x15198
movq %rax, %rsi
addq $0x90, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x33e4
movl 0xbd67(%rip), %edx      # 0x1c5d4
subl %eax, %edx
leaq 0x495b(%rip), %rsi      # 0x151d1
leaq -0xb0(%rbp), %rbx
movq %rbx, %rdi
movl %eax, %ecx
xorl %eax, %eax
callq 0x31f0
movq %rbx, %rdi
callq 0x3873
leaq 0x503f(%rip), %rdi      # 0x158d7
addq $0x90, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x3873