// File: /workspace/github_c_makefile_star2_O3/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:
movaps 0x30774(%rip), %xmm2    # 0x32030
movaps 0x3077d(%rip), %xmm3    # 0x32040
movapd 0x30785(%rip), %xmm4    # 0x32050
xorl %ecx, %ecx
xorpd %xmm5, %xmm5
movapd 0x30787(%rip), %xmm0    # 0x32060
movapd 0x3078f(%rip), %xmm6    # 0x32070
movdqa 0x30797(%rip), %xmm7    # 0x32080
movdqa 0x3079e(%rip), %xmm8    # 0x32090
leaq 0x327a7(%rip), %rax     # 0x340a0
movdqa 0x3079e(%rip), %xmm9    # 0x320a0
movdqa 0x307a6(%rip), %xmm1    # 0x320b0
movapd %xmm4, %xmm10
unpckhps %xmm5, %xmm10           # xmm10 = xmm10[2],xmm5[2],xmm10[3],xmm5[3]
orpd %xmm0, %xmm10
subpd %xmm0, %xmm10
movapd %xmm4, %xmm11
unpcklps %xmm5, %xmm11           # xmm11 = xmm11[0],xmm5[0],xmm11[1],xmm5[1]
orpd %xmm0, %xmm11
subpd %xmm0, %xmm11
mulpd %xmm6, %xmm11
mulpd %xmm6, %xmm10
cvttpd2dq %xmm10, %xmm10
cvttpd2dq %xmm11, %xmm11
unpcklpd %xmm10, %xmm11          # xmm11 = xmm11[0],xmm10[0]
pslld $0x8, %xmm11
movdqa %xmm7, %xmm10
psubd %xmm11, %xmm10
movaps %xmm3, %xmm11
shufps $0x88, %xmm2, %xmm11    # xmm11 = xmm11[0,2],xmm2[0,2]
pslld $0x2, %xmm11
movdqa %xmm8, %xmm12
psubd %xmm11, %xmm12
movdqa %xmm12, %xmm11
pslld $0x10, %xmm11
por %xmm12, %xmm11
por %xmm10, %xmm11
movdqa %xmm11, (%rcx,%rax)
paddq %xmm9, %xmm3
paddq %xmm9, %xmm2
paddd %xmm1, %xmm4
addq $0x10, %rcx
cmpq $0x100, %rcx            # imm = 0x100
jne 0x190a
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movdqa 0x30691(%rip), %xmm2    # 0x32050
xorl %ecx, %ecx
movdqa 0x306f7(%rip), %xmm3    # 0x320c0
movdqa 0x306ff(%rip), %xmm4    # 0x320d0
movdqa %xmm2, %xmm5
pmuludq %xmm3, %xmm5
pshufd $0xe8, %xmm5, %xmm5     # xmm5 = xmm5[0,2,2,3]
pshufd $0xf5, %xmm2, %xmm6     # xmm6 = xmm2[1,1,3,3]
pmuludq %xmm3, %xmm6
pshufd $0xe8, %xmm6, %xmm6     # xmm6 = xmm6[0,2,2,3]
punpckldq %xmm6, %xmm5    # xmm5 = xmm5[0],xmm6[0],xmm5[1],xmm6[1]
por %xmm4, %xmm5
movdqa %xmm5, 0x100(%rax,%rcx,4)
addq $0x4, %rcx
paddd %xmm1, %xmm2
cmpq $0x40, %rcx
jne 0x19d1
movapd 0x3063d(%rip), %xmm5    # 0x32050
xorl %ecx, %ecx
xorpd %xmm6, %xmm6
movapd 0x306bf(%rip), %xmm2    # 0x320e0
movdqa 0x306c7(%rip), %xmm7    # 0x320f0
movapd 0x306cf(%rip), %xmm3    # 0x32100
movapd %xmm5, %xmm8
unpckhps %xmm6, %xmm8            # xmm8 = xmm8[2],xmm6[2],xmm8[3],xmm6[3]
orpd %xmm0, %xmm8
subpd %xmm0, %xmm8
movapd %xmm5, %xmm10
unpcklps %xmm6, %xmm10           # xmm10 = xmm10[0],xmm6[0],xmm10[1],xmm6[1]
orpd %xmm0, %xmm10
subpd %xmm0, %xmm10
mulpd %xmm2, %xmm10
mulpd %xmm2, %xmm8
cvttpd2dq %xmm8, %xmm9
cvttpd2dq %xmm10, %xmm11
movapd %xmm11, %xmm12
subpd %xmm3, %xmm10
cvttpd2dq %xmm10, %xmm10
psrad $0x1f, %xmm12
andpd %xmm12, %xmm10
orpd %xmm11, %xmm10
unpcklpd %xmm9, %xmm11           # xmm11 = xmm11[0],xmm9[0]
pslld $0x10, %xmm11
movdqa %xmm7, %xmm12
psubd %xmm11, %xmm12
movapd %xmm9, %xmm11
subpd %xmm3, %xmm8
cvttpd2dq %xmm8, %xmm8
psrad $0x1f, %xmm11
andpd %xmm11, %xmm8
orpd %xmm9, %xmm8
unpcklpd %xmm8, %xmm10           # xmm10 = xmm10[0],xmm8[0]
pslld $0x8, %xmm10
movdqa %xmm4, %xmm8
psubd %xmm10, %xmm8
por %xmm12, %xmm8
movdqa %xmm8, 0x200(%rax,%rcx,4)
addq $0x4, %rcx
paddd %xmm1, %xmm5
cmpq $0x40, %rcx
jne 0x1a31
movapd 0x30554(%rip), %xmm4    # 0x32050
xorl %ecx, %ecx
xorpd %xmm5, %xmm5
movdqa 0x30606(%rip), %xmm6    # 0x32110
movdqa 0x3060e(%rip), %xmm7    # 0x32120
movapd %xmm4, %xmm8
unpckhps %xmm5, %xmm8            # xmm8 = xmm8[2],xmm5[2],xmm8[3],xmm5[3]
orpd %xmm0, %xmm8
subpd %xmm0, %xmm8
movapd %xmm4, %xmm10
unpcklps %xmm5, %xmm10           # xmm10 = xmm10[0],xmm5[0],xmm10[1],xmm5[1]
orpd %xmm0, %xmm10
subpd %xmm0, %xmm10
mulpd %xmm2, %xmm10
mulpd %xmm2, %xmm8
cvttpd2dq %xmm8, %xmm9
cvttpd2dq %xmm10, %xmm11
movapd %xmm11, %xmm12
psrad $0x1f, %xmm12
subpd %xmm3, %xmm10
cvttpd2dq %xmm10, %xmm10
andpd %xmm12, %xmm10
orpd %xmm11, %xmm10
unpcklpd %xmm9, %xmm11           # xmm11 = xmm11[0],xmm9[0]
pslld $0x10, %xmm11
movdqa %xmm6, %xmm12
psubd %xmm11, %xmm12
movapd %xmm9, %xmm11
psrad $0x1f, %xmm11
subpd %xmm3, %xmm8
cvttpd2dq %xmm8, %xmm8
andpd %xmm11, %xmm8
orpd %xmm9, %xmm8
unpcklpd %xmm8, %xmm10           # xmm10 = xmm10[0],xmm8[0]
pslld $0x8, %xmm10
paddd %xmm7, %xmm10
por %xmm12, %xmm10
movdqa %xmm10, 0x300(%rax,%rcx,4)
addq $0x4, %rcx
paddd %xmm1, %xmm4
cmpq $0x40, %rcx
jne 0x1b12
xorl %ecx, %ecx
movdqa 0x30556(%rip), %xmm0    # 0x32130
movdqa (%rcx,%rax), %xmm1
psrld $0x1, %xmm1
pand %xmm0, %xmm1
movdqa %xmm1, (%rcx,%rax)
addq $0x10, %rcx
cmpq $0x400, %rcx            # imm = 0x400
jne 0x1bda
movl $0x16dc400, %edi        # imm = 0x16DC400
movl $0x1, %esi
callq 0x10c0
movq %rax, %r14
movl $0x1, %eax
testq %r14, %r14
je 0x1cb1
xorl %r13d, %r13d
leaq 0x30554(%rip), %r15     # 0x32178
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 0x1c57
addq $0x14400, %r12          # imm = 0x14400
incq %rbx
jne 0x1c36
jmp 0x1c61
movq %r15, %rdi
callq 0x10e0
jmp 0x1c49
incq %r13
addq $0x158400, %r14         # imm = 0x158400
cmpq $0x11, %r13
jne 0x1c28
movl $0x5b7100, %edi         # imm = 0x5B7100
movl $0x4, %esi
callq 0x10c0
testq %rax, %rax
je 0x1cc0
movq %rax, %r15
movq (%rsp), %rdi
movq %rax, %rsi
callq 0x166a
leaq 0x304ef(%rip), %rdi     # 0x3218a
movq %r15, %rsi
callq 0x177d
testl %eax, %eax
jne 0x1cce
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 0x304bc(%rip), %rdi     # 0x32183
callq 0x10e0
jmp 0x1ce2
leaq 0x304c0(%rip), %rdi     # 0x32195
callq 0x10e0
movq %r15, %rdi
callq 0x1030
movl $0x1, %eax
jmp 0x1cb1