// File: /workspace/github_c_makefile_star2_O2/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
movl $0xff0000, %eax         # imm = 0xFF0000
movl $0xff, %ecx
leaq 0x32816(%rip), %rdx     # 0x340a0
xorl %esi, %esi
movsd 0x3079c(%rip), %xmm0    # 0x32030
cmpq $0x40, %rsi
je 0x18cc
cvtsi2sd %esi, %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %edi
shll $0x8, %edi
movl $0xff00, %r8d           # imm = 0xFF00
subl %edi, %r8d
orl %eax, %r8d
addl %ecx, %r8d
movl %r8d, (%rdx)
incq %rsi
addl $0xfffc0000, %eax       # imm = 0xFFFC0000
addl $-0x4, %ecx
addq $0x4, %rdx
jmp 0x1894
movl $0x9000, %ecx           # imm = 0x9000
xorl %edx, %edx
leaq 0x327c6(%rip), %rax     # 0x340a0
cmpq $0x40, %rdx
je 0x18f2
movl %ecx, 0x100(%rax,%rdx,4)
incq %rdx
addl $0x30000, %ecx          # imm = 0x30000
jmp 0x18da
xorl %ecx, %ecx
movsd 0x3073c(%rip), %xmm0    # 0x32038
cmpq $0x40, %rcx
je 0x1935
cvtsi2sd %ecx, %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %edx
shll $0x10, %edx
movl $0xc00000, %esi         # imm = 0xC00000
subl %edx, %esi
cvttsd2si %xmm1, %rdx
shll $0x8, %edx
movl $0x9000, %edi           # imm = 0x9000
subl %edx, %edi
orl %esi, %edi
movl %edi, 0x200(%rax,%rcx,4)
incq %rcx
jmp 0x18fc
xorl %ecx, %ecx
cmpq $0x40, %rcx
je 0x196f
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
jmp 0x1937
xorl %ecx, %ecx
cmpq $0x400, %rcx            # imm = 0x400
je 0x198e
movl (%rcx,%rax), %edx
shrl %edx
andl $0x7f7f7f, %edx         # imm = 0x7F7F7F
movl %edx, (%rcx,%rax)
addq $0x4, %rcx
jmp 0x1971
pushq $0x1
popq %rsi
movl $0x16dc400, %edi        # imm = 0x16DC400
callq 0x10c0
movq %rax, %r14
pushq $0x1
popq %rax
testq %r14, %r14
je 0x1a40
xorl %r13d, %r13d
leaq 0x306c4(%rip), %r15     # 0x32078
movq %r14, (%rsp)
cmpq $0x11, %r13
je 0x1a02
leal 0x30(%r13), %ebp
movq %r14, %r12
pushq $-0x11
popq %rbx
testq %rbx, %rbx
je 0x19f6
leal 0x38(%rbx), %edx
movq %r12, %rdi
movl %ebp, %esi
xorl %ecx, %ecx
callq 0x11ec
testl %eax, %eax
jne 0x19ec
incq %rbx
addq $0x14400, %r12          # imm = 0x14400
jmp 0x19c8
movq %r15, %rdi
callq 0x10e0
jmp 0x19e0
incq %r13
addq $0x158400, %r14         # imm = 0x158400
jmp 0x19b8
pushq $0x4
popq %rsi
movl $0x5b7100, %edi         # imm = 0x5B7100
callq 0x10c0
testq %rax, %rax
je 0x1a4f
movq %rax, %r15
movq (%rsp), %rdi
movq %rax, %rsi
callq 0x1620
leaq 0x30660(%rip), %rdi     # 0x3208a
movq %r15, %rsi
callq 0x1738
testl %eax, %eax
jne 0x1a5d
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 0x3062d(%rip), %rdi     # 0x32083
callq 0x10e0
jmp 0x1a71
leaq 0x30631(%rip), %rdi     # 0x32095
callq 0x10e0
movq %r15, %rdi
callq 0x1030
pushq $0x1
popq %rax
jmp 0x1a40