// File: /workspace/github_c_makefile_star2_O1/cath-mawr[P]rscmapgen/mapdump.c
// Function: main
int
main(int argc, char **argv)
{
	struct world *w;
	unsigned x, y;
	unsigned i;
	uint32_t *pixels;

	for (i = 0; i < 64; ++i) {
		colour_tab[i] = ((255 - i * 4) << 16) |
			((255 - (int)(i * 1.75)) << 8) |
			((255 - i * 4) & 0xFF) << 0;
	}
	for (i = 0; i < 64; ++i) {
		colour_tab[i + 64] = ((i * 3) << 16) |
			(144 << 8) |
			(0 << 0);
	}
	for (i = 0; i < 64; ++i) {
		colour_tab[i + 128] = ((192 - (int)(i * 1.5)) << 16) |
			((144 - (unsigned)(i * 1.5)) << 8) |
			(0 << 0);
	}
	for (i = 0; i < 64; ++i) {
		colour_tab[i + 192] = ((96 - (int)(i * 1.5)) << 16) |
			((48 + (unsigned)(i * 1.5)) << 8) |
			(0 << 0);
	}
	for (i = 0; i < 256; ++i) {
		colour_tab[i] = colour_tab[i] >> 1 & 0x7f7f7f;
	}

	if ((w = calloc(sizeof(struct world), 1)) == NULL) {
		return 1;
	}
	for (x = 0; x < MAPSIZE; ++x) {
		for (y = 0; y < MAPSIZE; ++y) {
			if (load_chunk(&w->chunks[x][y],
				MAPSTARTX + x, MAPSTARTY + y, 0) != 0) {
					perror("load_chunk");
			}
		}
	}
	if ((pixels = calloc(IMGSIZE, sizeof(uint32_t))) == NULL) {
		perror("calloc");
		return 1;
	}
	if (create_image(w, pixels) != 0) {
		perror("create_image");
		free(pixels);
		return 1;
	}
	if (write_tga("./test.tga", pixels) != 0) {
		perror("write_tga");
		free(pixels);
		return 1;
	}
	free(pixels);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0x327c7(%rip), %rax     # 0x340a0
movl $0xff0000, %ecx         # imm = 0xFF0000
movl $0xff, %edx
xorl %esi, %esi
movsd 0x30743(%rip), %xmm0    # 0x32030
xorps %xmm1, %xmm1
cvtsi2sd %esi, %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %edi
shll $0x8, %edi
movl $0xff00, %r8d           # imm = 0xFF00
subl %edi, %r8d
orl %ecx, %r8d
addl %edx, %r8d
movl %r8d, (%rax)
incq %rsi
addq $0x4, %rax
addl $0xfffc0000, %ecx       # imm = 0xFFFC0000
addl $-0x4, %edx
cmpq $0x40, %rsi
jne 0x18ed
movl $0x9000, %ecx           # imm = 0x9000
xorl %edx, %edx
leaq 0x3276b(%rip), %rax     # 0x340a0
movl %ecx, 0x100(%rax,%rdx,4)
incq %rdx
addl $0x30000, %ecx          # imm = 0x30000
cmpq $0x40, %rdx
jne 0x1935
xorl %ecx, %ecx
movsd 0x306e3(%rip), %xmm0    # 0x32038
xorps %xmm1, %xmm1
cvtsi2sd %ecx, %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %edx
shll $0x10, %edx
movl $0xc00000, %esi         # imm = 0xC00000
cvttsd2si %xmm1, %rdi
subl %edx, %esi
shll $0x8, %edi
movl $0x9000, %edx           # imm = 0x9000
subl %edi, %edx
orl %esi, %edx
movl %edx, 0x200(%rax,%rcx,4)
incq %rcx
cmpq $0x40, %rcx
jne 0x1955
xorl %ecx, %ecx
xorps %xmm1, %xmm1
cvtsi2sd %ecx, %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %edx
shll $0x10, %edx
movl $0x600000, %esi         # imm = 0x600000
subl %edx, %esi
cvttsd2si %xmm1, %rdx
shll $0x8, %edx
addl $0x3000, %edx           # imm = 0x3000
orl %esi, %edx
movl %edx, 0x300(%rax,%rcx,4)
incq %rcx
cmpq $0x40, %rcx
jne 0x1991
xorl %ecx, %ecx
movl (%rcx,%rax), %edx
shrl %edx
andl $0x7f7f7f, %edx         # imm = 0x7F7F7F
movl %edx, (%rcx,%rax)
addq $0x4, %rcx
cmpq $0x400, %rcx            # imm = 0x400
jne 0x19cc
movl $0x16dc400, %edi        # imm = 0x16DC400
movl $0x1, %esi
callq 0x10c0
movq %rax, %r14
movl $0x1, %eax
testq %r14, %r14
je 0x1a9e
xorl %r13d, %r13d
leaq 0x30667(%rip), %r15     # 0x32078
movq %r14, (%rsp)
leal 0x30(%r13), %ebp
movq $-0x11, %rbx
movq %r14, %r12
leal 0x38(%rbx), %edx
movq %r12, %rdi
movl %ebp, %esi
xorl %ecx, %ecx
callq 0x11ec
testl %eax, %eax
jne 0x1a44
addq $0x14400, %r12          # imm = 0x14400
incq %rbx
jne 0x1a23
jmp 0x1a4e
movq %r15, %rdi
callq 0x10e0
jmp 0x1a36
incq %r13
addq $0x158400, %r14         # imm = 0x158400
cmpq $0x11, %r13
jne 0x1a15
movl $0x5b7100, %edi         # imm = 0x5B7100
movl $0x4, %esi
callq 0x10c0
testq %rax, %rax
je 0x1aad
movq %rax, %r15
movq (%rsp), %rdi
movq %rax, %rsi
callq 0x166a
leaq 0x30602(%rip), %rdi     # 0x3208a
movq %r15, %rsi
callq 0x178f
testl %eax, %eax
jne 0x1abb
movq %r15, %rdi
callq 0x1030
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x305cf(%rip), %rdi     # 0x32083
callq 0x10e0
jmp 0x1acf
leaq 0x305d3(%rip), %rdi     # 0x32095
callq 0x10e0
movq %r15, %rdi
callq 0x1030
movl $0x1, %eax
jmp 0x1a9e