// File: /workspace/github_c_makefile_star2_O0/cath-mawr[P]rscmapgen/mapdump.c
// Function: create_image
int
create_image(const struct world *w, uint32_t *pixels)
{
	unsigned x, y;
	unsigned i, num;
	struct model_spawn m;
	uint32_t colour;

	for (x = 0; x < MAPSIZE; ++x) {
		for (y = 0; y < MAPSIZE; ++y) {
			if (write_chunk(pixels, x, y, &w->chunks[x][y]) != 0) {
				return 1;
			}
		}
	}
	num = sizeof(model_spawns) / sizeof(struct model_spawn);
	for (i = 0; i < num; ++i) {
		m = model_spawns[i];
		if (m.y > 944) continue;
		switch (m.id) {
		case 0:
		case 1:
			colour = 0x00a500;
			break;
#if 0
		case 100: /* mining */
		case 101: /* mining */
		case 102: /* mining */
		case 103: /* mining */
		case 104: /* mining */
		case 105: /* mining */
		case 106: /* mining */
		case 107: /* mining */
		case 108: /* mining */
		case 109: /* mining */
		case 110: /* mining */
		case 111: /* mining */
		case 112: /* mining */
		case 113: /* mining */
		case 195: /* mining */
		case 196: /* mining */
		case 210: /* mining */
		case 588: /* mining */
		case 45: /* railing */
		case 3: /* table */
		case 7: /* chair */
		case 11: /* range */
		case 72: /* wheat */
		case 118: /* furnace */
		case 70: /* dead */
		case 88: /* dead */
		case 209: /* dead */
			colour = 0xb56300;
			break;
#endif
		default:
			colour = 0xb56300;
			break;
		}
		x = XSIZE - ((m.x - 48) * TILESIZE);
		y = (YSIZE - (YSIZE - (m.y - 96))) * TILESIZE;
		if (x == 0 || y == 0 || x >= XSIZE || y >= YSIZE) {
			continue;
		}
		pixels[(x - 1) + y * XSIZE] = colour;
		pixels[(x + 1) + y * XSIZE] = colour;
		pixels[x + (y - 1) * XSIZE] = colour;
		pixels[x + (y + 1) * XSIZE] = colour;
		pixels[x + y * XSIZE] = colour;
		/*pixels[x + y * XSIZE] = 0x00FFFF;*/
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
cmpl $0x11, -0x1c(%rbp)
jae 0x1902
movl $0x0, -0x20(%rbp)
cmpl $0x11, -0x20(%rbp)
jae 0x18f5
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
movl -0x20(%rbp), %edx
movq -0x10(%rbp), %rcx
movl -0x1c(%rbp), %eax
imulq $0x158400, %rax, %rax   # imm = 0x158400
addq %rax, %rcx
movl -0x20(%rbp), %eax
imulq $0x14400, %rax, %rax    # imm = 0x14400
addq %rax, %rcx
callq 0x1590
cmpl $0x0, %eax
je 0x18e8
movl $0x1, -0x4(%rbp)
jmp 0x1a4b
jmp 0x18ea
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x18a4
jmp 0x18f7
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x1897
movl $0x5ff6, -0x28(%rbp)    # imm = 0x5FF6
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
jae 0x1a44
movl -0x24(%rbp), %eax
movl %eax, %ecx
leaq 0x758(%rip), %rax       # 0x2080
movq (%rax,%rcx,8), %rax
movq %rax, -0x30(%rbp)
movzwl -0x2c(%rbp), %eax
cmpl $0x3b0, %eax            # imm = 0x3B0
jle 0x1940
jmp 0x1a36
movw -0x30(%rbp), %ax
subw $0x1, %ax
ja 0x1955
jmp 0x194c
movl $0xa500, -0x34(%rbp)    # imm = 0xA500
jmp 0x195c
movl $0xb56300, -0x34(%rbp)  # imm = 0xB56300
movzwl -0x2e(%rbp), %eax
subl $0x30, %eax
imull $0x3, %eax, %ecx
movl $0x990, %eax            # imm = 0x990
subl %ecx, %eax
movl %eax, -0x1c(%rbp)
movzwl -0x2c(%rbp), %eax
subl $0x60, %eax
movl $0x990, %ecx            # imm = 0x990
subl %eax, %ecx
movl $0x990, %eax            # imm = 0x990
subl %ecx, %eax
imull $0x3, %eax, %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x19a9
cmpl $0x0, -0x20(%rbp)
je 0x19a9
cmpl $0x990, -0x1c(%rbp)     # imm = 0x990
jae 0x19a9
cmpl $0x990, -0x20(%rbp)     # imm = 0x990
jb 0x19ae
jmp 0x1a36
movl -0x34(%rbp), %edx
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
subl $0x1, %ecx
imull $0x990, -0x20(%rbp), %esi # imm = 0x990
addl %esi, %ecx
movl %ecx, %ecx
movl %edx, (%rax,%rcx,4)
movl -0x34(%rbp), %edx
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
imull $0x990, -0x20(%rbp), %esi # imm = 0x990
addl %esi, %ecx
movl %ecx, %ecx
movl %edx, (%rax,%rcx,4)
movl -0x34(%rbp), %edx
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl -0x20(%rbp), %esi
subl $0x1, %esi
imull $0x990, %esi, %esi      # imm = 0x990
addl %esi, %ecx
movl %ecx, %ecx
movl %edx, (%rax,%rcx,4)
movl -0x34(%rbp), %edx
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl -0x20(%rbp), %esi
addl $0x1, %esi
imull $0x990, %esi, %esi      # imm = 0x990
addl %esi, %ecx
movl %ecx, %ecx
movl %edx, (%rax,%rcx,4)
movl -0x34(%rbp), %edx
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
imull $0x990, -0x20(%rbp), %esi # imm = 0x990
addl %esi, %ecx
movl %ecx, %ecx
movl %edx, (%rax,%rcx,4)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x1910
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)