// File: /workspace/github_c_makefile_star2_O0/blakemcbride[P]LISP9/ls9.c
// Function: loadimg
char *loadimg(char *path) {
	FILE		*f;
	cell		n, **v;
	int		i;
	struct imghdr	m;
	int		image_nodes, image_vcells;
	char		*s;

	f = fopen(path, "rb");
	if (NULL == f)
		return "could not open file";
	if ((s = xfread(&m, sizeof(m), 1, f)) != NULL)
		return s;
	if (memcmp(m.magic, "LISP9", sizeof(m.magic))) {
		fclose(f);
		return "imghdr match failed";
	}
	if (memcmp(m.version, VERSION, sizeof(m.version))) {
		fclose(f);
		return "wrong image version";
	}
	if (m.cell_size[0]-'0' != sizeof(cell)) {
		fclose(f);
		return "wrong cell size";
	}
	memcpy(&n, m.byte_order, sizeof(cell));
	if (n != 0x31323334L) {
		fclose(f);
		return "wrong byte order";
	}
	memset(Tag, 0, NNODES);
	if ((s = xfread(&image_nodes, sizeof(int), 1, f)) != NULL)
		return s;
	if ((s = xfread(&image_vcells, sizeof(int), 1, f)) != NULL)
		return s;
	if (image_nodes != NNODES) {
		fclose(f);
		return "wrong node pool size";
	}
	if (image_vcells != NVCELLS) {
		fclose(f);
		return "wrong vector pool size";
	}
	v = Imagevars;
	i = 0;
	while (v && v[i]) {
		if ((s = xfread(v[i], sizeof(cell), 1, f)) != NULL)
			return s;
		i++;
	}
	if (	(fread(Car, 1, sizeof(cell) * NNODES, f)
		  != sizeof(cell) * NNODES ||
		 fread(Cdr, 1, sizeof(cell) * NNODES, f)
		  != sizeof(cell) * NNODES ||
		 fread(Tag, 1, NNODES, f) != NNODES ||
		 fread(Vectors, 1, sizeof(cell) * NVCELLS, f)
		  != sizeof(cell) * NVCELLS ||
		 fgetc(f) != EOF))
	{
		fclose(f);
		return "wrong file size";
	}
	fclose(f);
	return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x9b79(%rip), %rsi      # 0x1bc50
callq 0x21c0
movq %rax, -0x18(%rbp)
xorl %eax, %eax
cmpq -0x18(%rbp), %rax
jne 0x120f8
leaq 0x9b64(%rip), %rax      # 0x1bc53
movq %rax, -0x8(%rbp)
jmp 0x123d3
movq -0x18(%rbp), %rcx
leaq -0x4c(%rbp), %rdi
movl $0x20, %esi
movl $0x1, %edx
callq 0x12060
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0x12126
movq -0x60(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x123d3
leaq -0x4c(%rbp), %rdi
leaq 0x9ae8(%rip), %rsi      # 0x1bc19
movl $0x5, %edx
callq 0x20f0
cmpl $0x0, %eax
je 0x12159
movq -0x18(%rbp), %rdi
callq 0x2080
leaq 0x9b17(%rip), %rax      # 0x1bc67
movq %rax, -0x8(%rbp)
jmp 0x123d3
leaq -0x4c(%rbp), %rax
addq $0x5, %rax
movq (%rax), %rax
movabsq $0x3231383039313032, %rcx # imm = 0x3231383039313032
subq %rcx, %rax
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
je 0x12195
movq -0x18(%rbp), %rdi
callq 0x2080
leaq 0x9aef(%rip), %rax      # 0x1bc7b
movq %rax, -0x8(%rbp)
jmp 0x123d3
movsbl -0x3f(%rbp), %eax
subl $0x30, %eax
cltq
cmpq $0x4, %rax
je 0x121bd
movq -0x18(%rbp), %rdi
callq 0x2080
leaq 0x9adb(%rip), %rax      # 0x1bc8f
movq %rax, -0x8(%rbp)
jmp 0x123d3
movl -0x3e(%rbp), %eax
movl %eax, -0x1c(%rbp)
movslq -0x1c(%rbp), %rax
cmpq $0x31323334, %rax       # imm = 0x31323334
je 0x121e8
movq -0x18(%rbp), %rdi
callq 0x2080
leaq 0x9ac0(%rip), %rax      # 0x1bc9f
movq %rax, -0x8(%rbp)
jmp 0x123d3
movq 0xe161(%rip), %rdi      # 0x20350
xorl %esi, %esi
movl $0x40000, %edx          # imm = 0x40000
callq 0x20d0
movq -0x18(%rbp), %rcx
leaq -0x50(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x12060
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0x12229
movq -0x60(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x123d3
movq -0x18(%rbp), %rcx
leaq -0x54(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x12060
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0x12257
movq -0x60(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x123d3
cmpl $0x40000, -0x50(%rbp)   # imm = 0x40000
je 0x12279
movq -0x18(%rbp), %rdi
callq 0x2080
leaq 0x9a40(%rip), %rax      # 0x1bcb0
movq %rax, -0x8(%rbp)
jmp 0x123d3
cmpl $0x40000, -0x54(%rbp)   # imm = 0x40000
je 0x1229b
movq -0x18(%rbp), %rdi
callq 0x2080
leaq 0x9a33(%rip), %rax      # 0x1bcc5
movq %rax, -0x8(%rbp)
jmp 0x123d3
leaq 0xdf3e(%rip), %rax      # 0x201e0
movq %rax, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x28(%rbp)
movb %al, -0x61(%rbp)
je 0x122cc
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
setne %al
movb %al, -0x61(%rbp)
movb -0x61(%rbp), %al
testb $0x1, %al
jne 0x122d5
jmp 0x12316
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x18(%rbp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x12060
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0x1230b
movq -0x60(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x123d3
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x122ad
movq 0xe023(%rip), %rdi      # 0x20340
movq -0x18(%rbp), %rcx
movl $0x1, %esi
movl $0x100000, %edx         # imm = 0x100000
callq 0x2070
cmpq $0x100000, %rax         # imm = 0x100000
jne 0x123ac
movq 0xe009(%rip), %rdi      # 0x20348
movq -0x18(%rbp), %rcx
movl $0x1, %esi
movl $0x100000, %edx         # imm = 0x100000
callq 0x2070
cmpq $0x100000, %rax         # imm = 0x100000
jne 0x123ac
movq 0xdfef(%rip), %rdi      # 0x20350
movq -0x18(%rbp), %rcx
movl $0x1, %esi
movl $0x40000, %edx          # imm = 0x40000
callq 0x2070
cmpq $0x40000, %rax          # imm = 0x40000
jne 0x123ac
movq 0xdfd5(%rip), %rdi      # 0x20358
movq -0x18(%rbp), %rcx
movl $0x1, %esi
movl $0x100000, %edx         # imm = 0x100000
callq 0x2070
cmpq $0x100000, %rax         # imm = 0x100000
jne 0x123ac
movq -0x18(%rbp), %rdi
callq 0x20e0
cmpl $-0x1, %eax
je 0x123c2
movq -0x18(%rbp), %rdi
callq 0x2080
leaq 0x9920(%rip), %rax      # 0x1bcdc
movq %rax, -0x8(%rbp)
jmp 0x123d3
movq -0x18(%rbp), %rdi
callq 0x2080
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)