// File: /workspace/github_c_makefile_star2_O1/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 $0x98, %rsp
movq %rdi, %r14
leaq 0x4f97(%rip), %rsi      # 0x171b0
callq 0x31c0
testq %rax, %rax
je 0x123de
movq %rax, %rbx
movaps 0x3f6f(%rip), %xmm0     # 0x161a0
leaq -0x40(%rbp), %rdi
movaps %xmm0, (%rdi)
movups %xmm0, 0xe(%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 0xc9ab(%rip), %rax      # 0x1ec10
movq %rax, 0x16(%rdi)
movl $0x1e, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x3210
movl 0xc353(%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 0xc34d(%rip), %eax      # 0x1e5f0
movl %eax, (%r14)
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rdi
movq %rbx, %rcx
callq 0x3210
movq 0xbcce(%rip), %rdi      # 0x1df90
xorl %r14d, %r14d
testq %rdi, %rdi
je 0x122f0
leaq 0xbcbf(%rip), %r15      # 0x1df90
movl $0x8, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x3210
movq 0x8(%r15,%r14,8), %rdi
incq %r14
testq %rdi, %rdi
jne 0x122d1
movl %r14d, -0x1c(%rbp)
movq 0xbe75(%rip), %rdi      # 0x1e170
movslq 0xc2d2(%rip), %rdx      # 0x1e5d4
shlq $0x3, %rdx
movl $0x1, %esi
movq %rbx, %rcx
callq 0x3210
movslq 0xc2ba(%rip), %rdx      # 0x1e5d4
shlq $0x3, %rdx
cmpq %rdx, %rax
jne 0x123c6
movq 0xc292(%rip), %rdi      # 0x1e5c0
movl $0x1, %esi
movq %rbx, %rcx
callq 0x3210
movslq 0xc292(%rip), %rdx      # 0x1e5d4
leaq (,%rdx,8), %rcx
cmpq %rcx, %rax
jne 0x123c6
movq 0xc28a(%rip), %rdi      # 0x1e5e0
movl $0x1, %esi
movq %rbx, %rcx
callq 0x3210
movslq 0xc26a(%rip), %rcx      # 0x1e5d4
cmpq %rcx, %rax
jne 0x123c6
movq 0xc272(%rip), %rdi      # 0x1e5e8
movslq 0xc273(%rip), %rdx      # 0x1e5f0
shlq $0x3, %rdx
movl $0x1, %esi
movq %rbx, %rcx
callq 0x3210
movslq 0xc25b(%rip), %rcx      # 0x1e5f0
shlq $0x3, %rcx
cmpq %rcx, %rax
jne 0x123c6
movq %rbx, %rdi
callq 0x3090
callq 0x3ef8
cmpl $0x0, 0xc206(%rip)      # 0x1e5b8
je 0x12439
addq $0x98, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0x3090
leaq 0x4e05(%rip), %rdi      # 0x171da
movq $-0x8, %rsi
jmp 0x12427
movq %r14, %rdi
callq 0x30a0
movq %rax, %rbx
incl %ebx
movq $-0x21, %rdi
movl %ebx, %esi
callq 0x417e
movq %rax, %r15
movq 0xc1bd(%rip), %rax      # 0x1e5c0
movq (%rax,%r15,8), %rdi
shlq $0x3, %rdi
addq 0xc1d6(%rip), %rdi      # 0x1e5e8
movslq %ebx, %rdx
movq %r14, %rsi
callq 0x3050
leaq 0x4d8f(%rip), %rdi      # 0x171b3
movq %r15, %rsi
addq $0x98, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x33eb
movl 0xc195(%rip), %edx      # 0x1e5d4
subl %eax, %edx
leaq 0x4da4(%rip), %rsi      # 0x171ec
leaq -0xb0(%rbp), %rbx
movq %rbx, %rdi
movl %eax, %ecx
xorl %eax, %eax
callq 0x31f0
movq %rbx, %rdi
callq 0x3965
leaq 0x548b(%rip), %rdi      # 0x178f5
addq $0x98, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x3965