// File: /workspace/github_c_makefile_star2_O3/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 %rbx
subq $0x88, %rsp
movq %rdi, %r14
leaq 0x5251(%rip), %rsi      # 0x17195
callq 0x31c0
testq %rax, %rax
je 0x120f6
movq %rax, %rbx
leaq -0x3a(%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 0xcc8e(%rip), %rax      # 0x1ec10
movq %rax, 0x16(%rdi)
movl $0x1e, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x3210
movl 0xc636(%rip), %eax      # 0x1e5d4
leaq -0x1c(%rbp), %r14
movl %eax, (%r14)
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rdi
movq %rbx, %rcx
callq 0x3210
movl 0xc630(%rip), %eax      # 0x1e5f0
movl %eax, (%r14)
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rdi
movq %rbx, %rcx
callq 0x3210
movq 0xbfb1(%rip), %rdi      # 0x1df90
testq %rdi, %rdi
je 0x12009
leaq 0xbfad(%rip), %r14      # 0x1df98
movl $0x8, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x3210
movq (%r14), %rdi
addq $0x8, %r14
testq %rdi, %rdi
jne 0x11feb
movq 0xc160(%rip), %rdi      # 0x1e170
movslq 0xc5bd(%rip), %rdx      # 0x1e5d4
shlq $0x3, %rdx
movl $0x1, %esi
movq %rbx, %rcx
callq 0x3210
movslq 0xc5a5(%rip), %rcx      # 0x1e5d4
shlq $0x3, %rcx
cmpq %rcx, %rax
jne 0x120de
movq 0xc57d(%rip), %rdi      # 0x1e5c0
movl $0x1, %esi
movq %rax, %rdx
movq %rbx, %rcx
callq 0x3210
movslq 0xc57a(%rip), %rdx      # 0x1e5d4
leaq (,%rdx,8), %rcx
cmpq %rcx, %rax
jne 0x120de
movq 0xc572(%rip), %rdi      # 0x1e5e0
movl $0x1, %esi
movq %rbx, %rcx
callq 0x3210
movslq 0xc552(%rip), %rcx      # 0x1e5d4
cmpq %rcx, %rax
jne 0x120de
movq 0xc55a(%rip), %rdi      # 0x1e5e8
movslq 0xc55b(%rip), %rdx      # 0x1e5f0
shlq $0x3, %rdx
movl $0x1, %esi
movq %rbx, %rcx
callq 0x3210
movslq 0xc543(%rip), %rcx      # 0x1e5f0
shlq $0x3, %rcx
cmpq %rcx, %rax
jne 0x120de
movq %rbx, %rdi
callq 0x3090
callq 0x3ed9
cmpl $0x0, 0xc4ee(%rip)      # 0x1e5b8
je 0x12151
addq $0x88, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0x3090
leaq 0x50d2(%rip), %rdi      # 0x171bf
movq $-0x8, %rsi
jmp 0x1213f
movq %r14, %rdi
callq 0x30a0
movq %rax, %rbx
incl %ebx
movq $-0x21, %rdi
movl %ebx, %esi
callq 0x416e
movq %rax, %r15
movq 0xc4a5(%rip), %rax      # 0x1e5c0
movq (%rax,%r15,8), %rdi
shlq $0x3, %rdi
addq 0xc4be(%rip), %rdi      # 0x1e5e8
movslq %ebx, %rdx
movq %r14, %rsi
callq 0x3050
leaq 0x505c(%rip), %rdi      # 0x17198
movq %r15, %rsi
addq $0x88, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x33eb
movl 0xc47d(%rip), %edx      # 0x1e5d4
subl %eax, %edx
leaq 0x5071(%rip), %rsi      # 0x171d1
leaq -0xa0(%rbp), %rbx
movq %rbx, %rdi
movl %eax, %ecx
xorl %eax, %eax
callq 0x31f0
movq %rbx, %rdi
callq 0x3964
leaq 0x5755(%rip), %rdi      # 0x178d7
addq $0x88, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x3964