// File: /workspace/github_c_makefile_star2_O2/mortie[P]makeschem/makeschem.c
// Function: schem_write
int schem_write(struct blocks *blocks, FILE *out) {
	if (!nbt_start_named_tag(out, TAG_COMPOUND, "Schematic")) return 0;

	if (!nbt_start_named_tag(out, TAG_SHORT, "Width")) return 0;
	if (!nbt_write_short(out, blocks->width)) return 0;
	if (!nbt_start_named_tag(out, TAG_SHORT, "Height")) return 0;
	if (!nbt_write_short(out, blocks->height)) return 0;
	if (!nbt_start_named_tag(out, TAG_SHORT, "Length")) return 0;
	if (!nbt_write_short(out, blocks->length)) return 0;
	if (!nbt_start_named_tag(out, TAG_STRING, "Materials")) return 0;
	if (!nbt_write_string(out, "Alpha")) return 0;

	if (!nbt_start_named_tag(out, TAG_BYTE_ARRAY, "Blocks")) return 0;
	if (!nbt_start_byte_array(out, blocks->width * blocks->length * blocks->height)) return 0;
	for (size_t y = 0; y < blocks->height; ++y) {
		for (size_t z = 0; z < blocks->length; ++z) {
			for (size_t x = 0; x < blocks->width; ++x) {
				uint8_t id = blocks_get_id(blocks, x, y, z);
				nbt_write_byte(out, id);
			}
		}
	}

	if (!nbt_start_named_tag(out, TAG_BYTE_ARRAY, "Data")) return 0;
	if (!nbt_start_byte_array(out, blocks->width * blocks->length * blocks->height)) return 0;
	for (size_t y = 0; y < blocks->height; ++y) {
		for (size_t z = 0; z < blocks->length; ++z) {
			for (size_t x = 0; x < blocks->width; ++x) {
				uint8_t data = blocks_get_data(blocks, x, y, z);
				nbt_write_byte(out, data);
			}
		}
	}

	return nbt_write_end(out);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x723(%rip), %rdx       # 0xd0c9
pushq $0xa
popq %rsi
movq %rbx, %rdi
callq 0xc304
testl %eax, %eax
je 0xcb66
leaq 0x713(%rip), %rdx       # 0xd0d3
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0xc304
testl %eax, %eax
je 0xcb66
movswl (%r14), %esi
movq %rbx, %rdi
callq 0xc220
testl %eax, %eax
je 0xcb66
leaq 0x6eb(%rip), %rdx       # 0xd0d9
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0xc304
testl %eax, %eax
je 0xcb66
movswl 0x8(%r14), %esi
movq %rbx, %rdi
callq 0xc220
testl %eax, %eax
je 0xcb66
leaq 0x6c3(%rip), %rdx       # 0xd0e0
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0xc304
testl %eax, %eax
je 0xcb66
movswl 0x10(%r14), %esi
movq %rbx, %rdi
callq 0xc220
testl %eax, %eax
je 0xcb66
leaq 0x69b(%rip), %rdx       # 0xd0e7
pushq $0x8
popq %rsi
movq %rbx, %rdi
callq 0xc304
testl %eax, %eax
je 0xcb66
leaq 0x68b(%rip), %rsi       # 0xd0f1
movq %rbx, %rdi
callq 0xc2ba
testl %eax, %eax
je 0xcb66
leaq 0x67a(%rip), %rdx       # 0xd0f7
pushq $0x7
popq %rsi
movq %rbx, %rdi
callq 0xc304
testl %eax, %eax
je 0xcb66
movl 0x10(%r14), %esi
imull (%r14), %esi
imull 0x8(%r14), %esi
movq %rbx, %rdi
callq 0xc248
testl %eax, %eax
je 0xcb66
xorl %r15d, %r15d
cmpq 0x8(%r14), %r15
jae 0xcaf2
xorl %r12d, %r12d
cmpq 0x10(%r14), %r12
jae 0xcaed
xorl %r13d, %r13d
cmpq (%r14), %r13
jae 0xcae8
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %r12, %rcx
callq 0xc5b7
movsbl %al, %esi
movq %rbx, %rdi
callq 0xc1fc
incq %r13
jmp 0xcac2
incq %r12
jmp 0xcab9
incq %r15
jmp 0xcab0
leaq 0x605(%rip), %rdx       # 0xd0fe
pushq $0x7
popq %rsi
movq %rbx, %rdi
callq 0xc304
testl %eax, %eax
je 0xcb66
movl 0x10(%r14), %esi
imull (%r14), %esi
imull 0x8(%r14), %esi
movq %rbx, %rdi
callq 0xc248
testl %eax, %eax
je 0xcb66
xorl %r15d, %r15d
cmpq 0x8(%r14), %r15
jae 0xcb72
xorl %r12d, %r12d
cmpq 0x10(%r14), %r12
jae 0xcb61
xorl %r13d, %r13d
cmpq (%r14), %r13
jae 0xcb5c
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %r12, %rcx
callq 0xc61a
movsbl %al, %esi
movq %rbx, %rdi
callq 0xc1fc
incq %r13
jmp 0xcb36
incq %r12
jmp 0xcb2d
incq %r15
jmp 0xcb24
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0xc2fd