// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x24(%rbp)
cmpl $0x40, -0x24(%rbp)
jae 0x1c77
movl -0x24(%rbp), %eax
movl %eax, %ecx
shll $0x2, %ecx
movl $0xff, %edx
subl %ecx, %edx
shll $0x10, %edx
cvtsi2sd %rax, %xmm0
movsd 0x30406(%rip), %xmm1    # 0x32038
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
movl $0xff, %eax
subl %ecx, %eax
shll $0x8, %eax
orl %eax, %edx
movl -0x24(%rbp), %ecx
shll $0x2, %ecx
movl $0xff, %eax
subl %ecx, %eax
andl $0xff, %eax
shll $0x0, %eax
orl %eax, %edx
movl -0x24(%rbp), %eax
movl %eax, %ecx
leaq 0x32437(%rip), %rax     # 0x340a0
movl %edx, (%rax,%rcx,4)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x1c0d
movl $0x0, -0x24(%rbp)
cmpl $0x40, -0x24(%rbp)
jae 0x1cb3
imull $0x3, -0x24(%rbp), %edx
shll $0x10, %edx
orl $0x9000, %edx           # imm = 0x9000
orl $0x0, %edx
movl -0x24(%rbp), %eax
addl $0x40, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x323fb(%rip), %rax     # 0x340a0
movl %edx, (%rax,%rcx,4)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x1c7e
movl $0x0, -0x24(%rbp)
cmpl $0x40, -0x24(%rbp)
jae 0x1d19
movl -0x24(%rbp), %eax
cvtsi2sd %rax, %xmm0
movsd 0x30360(%rip), %xmm1    # 0x32030
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl $0xc0, %edx
subl %eax, %edx
shll $0x10, %edx
cvttsd2si %xmm0, %rax
movl %eax, %ecx
movl $0x90, %eax
subl %ecx, %eax
shll $0x8, %eax
orl %eax, %edx
orl $0x0, %edx
movl -0x24(%rbp), %eax
addl $0x80, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x32395(%rip), %rax     # 0x340a0
movl %edx, (%rax,%rcx,4)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x1cba
movl $0x0, -0x24(%rbp)
cmpl $0x40, -0x24(%rbp)
jae 0x1d79
movl -0x24(%rbp), %eax
cvtsi2sd %rax, %xmm0
movsd 0x302fa(%rip), %xmm1    # 0x32030
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl $0x60, %edx
subl %eax, %edx
shll $0x10, %edx
cvttsd2si %xmm0, %rax
addl $0x30, %eax
shll $0x8, %eax
orl %eax, %edx
orl $0x0, %edx
movl -0x24(%rbp), %eax
addl $0xc0, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x32335(%rip), %rax     # 0x340a0
movl %edx, (%rax,%rcx,4)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x1d20
movl $0x0, -0x24(%rbp)
cmpl $0x100, -0x24(%rbp)     # imm = 0x100
jae 0x1dba
movl -0x24(%rbp), %eax
movl %eax, %ecx
leaq 0x3230b(%rip), %rax     # 0x340a0
movl (%rax,%rcx,4), %edx
shrl %edx
andl $0x7f7f7f, %edx         # imm = 0x7F7F7F
movl -0x24(%rbp), %eax
movl %eax, %ecx
leaq 0x322f4(%rip), %rax     # 0x340a0
movl %edx, (%rax,%rcx,4)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x1d80
movl $0x16dc400, %edi        # imm = 0x16DC400
movl $0x1, %esi
callq 0x10c0
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
jne 0x1ddf
movl $0x1, -0x4(%rbp)
jmp 0x1ef6
movl $0x0, -0x1c(%rbp)
cmpl $0x11, -0x1c(%rbp)
jae 0x1e55
movl $0x0, -0x20(%rbp)
cmpl $0x11, -0x20(%rbp)
jae 0x1e48
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %eax
imulq $0x158400, %rax, %rax   # imm = 0x158400
addq %rax, %rdi
movl -0x20(%rbp), %eax
imulq $0x14400, %rax, %rax    # imm = 0x14400
addq %rax, %rdi
movl -0x1c(%rbp), %esi
addl $0x30, %esi
movl -0x20(%rbp), %edx
addl $0x27, %edx
xorl %ecx, %ecx
callq 0x11f0
cmpl $0x0, %eax
je 0x1e3b
leaq 0x30242(%rip), %rdi     # 0x32078
callq 0x10e0
jmp 0x1e3d
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1df3
jmp 0x1e4a
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x1de6
movl $0x5b7100, %edi         # imm = 0x5B7100
movl $0x4, %esi
callq 0x10c0
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
jne 0x1e83
leaq 0x3020e(%rip), %rdi     # 0x32083
callq 0x10e0
movl $0x1, -0x4(%rbp)
jmp 0x1ef6
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x1880
cmpl $0x0, %eax
je 0x1eb3
leaq 0x301ee(%rip), %rdi     # 0x3208a
callq 0x10e0
movq -0x30(%rbp), %rdi
callq 0x1030
movl $0x1, -0x4(%rbp)
jmp 0x1ef6
movq -0x30(%rbp), %rsi
leaq 0x301d9(%rip), %rdi     # 0x32097
callq 0x1a60
cmpl $0x0, %eax
je 0x1ee6
leaq 0x301d3(%rip), %rdi     # 0x320a2
callq 0x10e0
movq -0x30(%rbp), %rdi
callq 0x1030
movl $0x1, -0x4(%rbp)
jmp 0x1ef6
movq -0x30(%rbp), %rdi
callq 0x1030
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq