// File: Alcaro[P]bridges/gamemap.cpp
// Function: gamemap::serialize()
string gamemap::serialize()
{
	char ret[100*101+1];
	memset(ret, 0, (width+1)*height+1);
	
	for (int y=0;y<height;y++)
	{
		for (int x=0;x<width;x++)
		{
			island& here = map[y][x];
			
			if (here.rootnode != y*100+x) continue;
			
			char ch = -1; // populations other than the listed ones are impossible, but gcc won't realize that
			
			if(0);
			else if (here.population == -1) ch = ' ';
			else if (here.population == -2) ch = '#';
			else if (here.population <  10) ch = '0'+here.population;
			else if (here.population <  36) ch = 'A'+here.population-10;
			else if (here.population == 80) ch = 'r';
			else if (here.population == 81) ch = 'b';
			else if (here.population == 82) ch = 'y';
			else if (here.population == 83) ch = 'g';
			
			serialize_fill(*this, ret, width, x, y);
			
			ret[(width+1)*y + x] = ch;
		}
		ret[(width+1)*y + width] = '\n';
	}
	
	return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x27e0, %rsp           # imm = 0x27E0
movq %rdi, -0x27d0(%rbp)
movq %rdi, %rax
movq %rax, -0x27c8(%rbp)
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movq -0x20(%rbp), %rcx
movq %rcx, -0x27c0(%rbp)
leaq -0x27a0(%rbp), %rdi
movl (%rcx), %eax
addl $0x1, %eax
imull 0x4(%rcx), %eax
addl $0x1, %eax
movslq %eax, %rdx
xorl %esi, %esi
callq 0x4170
movl $0x0, -0x27a4(%rbp)
movq -0x27c0(%rbp), %rcx
movl -0x27a4(%rbp), %eax
cmpl 0x4(%rcx), %eax
jge 0x4fa55
movl $0x0, -0x27a8(%rbp)
movq -0x27c0(%rbp), %rcx
movl -0x27a8(%rbp), %eax
cmpl (%rcx), %eax
jge 0x4fa22
movq -0x27c0(%rbp), %rax
addq $0xc, %rax
movslq -0x27a4(%rbp), %rcx
imulq $0x4b0, %rcx, %rcx      # imm = 0x4B0
addq %rcx, %rax
movslq -0x27a8(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x27b0(%rbp)
movq -0x27b0(%rbp), %rax
movswl 0x2(%rax), %eax
imull $0x64, -0x27a4(%rbp), %ecx
addl -0x27a8(%rbp), %ecx
cmpl %ecx, %eax
je 0x4f8cd
jmp 0x4fa0e
movb $-0x1, -0x27b1(%rbp)
movq -0x27b0(%rbp), %rax
movsbl (%rax), %eax
cmpl $-0x1, %eax
jne 0x4f8ef
movb $0x20, -0x27b1(%rbp)
jmp 0x4f9c4
movq -0x27b0(%rbp), %rax
movsbl (%rax), %eax
cmpl $-0x2, %eax
jne 0x4f90a
movb $0x23, -0x27b1(%rbp)
jmp 0x4f9c2
movq -0x27b0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xa, %eax
jge 0x4f931
movq -0x27b0(%rbp), %rax
movsbl (%rax), %eax
addl $0x30, %eax
movb %al, -0x27b1(%rbp)
jmp 0x4f9c0
movq -0x27b0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x24, %eax
jge 0x4f958
movq -0x27b0(%rbp), %rax
movsbl (%rax), %eax
addl $0x41, %eax
subl $0xa, %eax
movb %al, -0x27b1(%rbp)
jmp 0x4f9be
movq -0x27b0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x50, %eax
jne 0x4f970
movb $0x72, -0x27b1(%rbp)
jmp 0x4f9bc
movq -0x27b0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x51, %eax
jne 0x4f988
movb $0x62, -0x27b1(%rbp)
jmp 0x4f9ba
movq -0x27b0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x52, %eax
jne 0x4f9a0
movb $0x79, -0x27b1(%rbp)
jmp 0x4f9b8
movq -0x27b0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x53, %eax
jne 0x4f9b6
movb $0x67, -0x27b1(%rbp)
jmp 0x4f9b8
jmp 0x4f9ba
jmp 0x4f9bc
jmp 0x4f9be
jmp 0x4f9c0
jmp 0x4f9c2
jmp 0x4f9c4
movq -0x27c0(%rbp), %rdi
leaq -0x27a0(%rbp), %rsi
movl (%rdi), %edx
movl -0x27a8(%rbp), %ecx
movl -0x27a4(%rbp), %r8d
callq 0x4faa0
movq -0x27c0(%rbp), %rax
movb -0x27b1(%rbp), %cl
movl (%rax), %eax
addl $0x1, %eax
imull -0x27a4(%rbp), %eax
addl -0x27a8(%rbp), %eax
cltq
movb %cl, -0x27a0(%rbp,%rax)
movl -0x27a8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x27a8(%rbp)
jmp 0x4f866
movq -0x27c0(%rbp), %rcx
movl (%rcx), %eax
addl $0x1, %eax
imull -0x27a4(%rbp), %eax
addl (%rcx), %eax
cltq
movb $0xa, -0x27a0(%rbp,%rax)
movl -0x27a4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x27a4(%rbp)
jmp 0x4f846
movq -0x27d0(%rbp), %rcx
leaq -0x27a0(%rbp), %rax
movq %rcx, -0x8(%rbp)
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x27d8(%rbp)
callq 0x5c00
movq -0x27d8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x5c20
movq -0x27c8(%rbp), %rax
addq $0x27e0, %rsp           # imm = 0x27E0
popq %rbp
retq
nopl (%rax,%rax)