// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movl $0xa, %esi
leaq 0x1089(%rip), %rdx      # 0xe0c9
callq 0xc430
cmpl $0x0, %eax
jne 0xd056
movl $0x0, -0x4(%rbp)
jmp 0xd375
movq -0x18(%rbp), %rdi
movl $0x2, %esi
leaq 0x106d(%rip), %rdx      # 0xe0d3
callq 0xc430
cmpl $0x0, %eax
jne 0xd07c
movl $0x0, -0x4(%rbp)
jmp 0xd375
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rax
movswl %ax, %esi
callq 0xc240
cmpl $0x0, %eax
jne 0xd0a0
movl $0x0, -0x4(%rbp)
jmp 0xd375
movq -0x18(%rbp), %rdi
movl $0x2, %esi
leaq 0x1029(%rip), %rdx      # 0xe0d9
callq 0xc430
cmpl $0x0, %eax
jne 0xd0c6
movl $0x0, -0x4(%rbp)
jmp 0xd375
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movswl %ax, %esi
callq 0xc240
cmpl $0x0, %eax
jne 0xd0eb
movl $0x0, -0x4(%rbp)
jmp 0xd375
movq -0x18(%rbp), %rdi
movl $0x2, %esi
leaq 0xfe5(%rip), %rdx       # 0xe0e0
callq 0xc430
cmpl $0x0, %eax
jne 0xd111
movl $0x0, -0x4(%rbp)
jmp 0xd375
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movswl %ax, %esi
callq 0xc240
cmpl $0x0, %eax
jne 0xd136
movl $0x0, -0x4(%rbp)
jmp 0xd375
movq -0x18(%rbp), %rdi
movl $0x8, %esi
leaq 0xfa1(%rip), %rdx       # 0xe0e7
callq 0xc430
cmpl $0x0, %eax
jne 0xd15c
movl $0x0, -0x4(%rbp)
jmp 0xd375
movq -0x18(%rbp), %rdi
leaq 0xf8a(%rip), %rsi       # 0xe0f1
callq 0xc3b0
cmpl $0x0, %eax
jne 0xd17d
movl $0x0, -0x4(%rbp)
jmp 0xd375
movq -0x18(%rbp), %rdi
movl $0x7, %esi
leaq 0xf6a(%rip), %rdx       # 0xe0f7
callq 0xc430
cmpl $0x0, %eax
jne 0xd1a3
movl $0x0, -0x4(%rbp)
jmp 0xd375
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rcx
imulq 0x10(%rcx), %rax
movq -0x10(%rbp), %rcx
imulq 0x8(%rcx), %rax
movl %eax, %esi
callq 0xc380
cmpl $0x0, %eax
jne 0xd1d8
movl $0x0, -0x4(%rbp)
jmp 0xd375
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jae 0xd273
movq $0x0, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jae 0xd260
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq (%rcx), %rax
jae 0xd250
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
callq 0xc9f0
movb %al, -0x31(%rbp)
movq -0x18(%rbp), %rdi
movsbl -0x31(%rbp), %esi
callq 0xc200
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0xd210
jmp 0xd252
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0xd1fa
jmp 0xd262
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0xd1e0
movq -0x18(%rbp), %rdi
movl $0x7, %esi
leaq 0xe7b(%rip), %rdx       # 0xe0fe
callq 0xc430
cmpl $0x0, %eax
jne 0xd299
movl $0x0, -0x4(%rbp)
jmp 0xd375
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rcx
imulq 0x10(%rcx), %rax
movq -0x10(%rbp), %rcx
imulq 0x8(%rcx), %rax
movl %eax, %esi
callq 0xc380
cmpl $0x0, %eax
jne 0xd2ce
movl $0x0, -0x4(%rbp)
jmp 0xd375
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jae 0xd369
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jae 0xd356
movq $0x0, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq (%rcx), %rax
jae 0xd346
movq -0x10(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x48(%rbp), %rcx
callq 0xcab0
movb %al, -0x51(%rbp)
movq -0x18(%rbp), %rdi
movsbl -0x51(%rbp), %esi
callq 0xc200
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0xd306
jmp 0xd348
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0xd2f0
jmp 0xd358
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0xd2d6
movq -0x18(%rbp), %rdi
callq 0xc410
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nop