// File: aempirei[P]Chat-Art/include/tile.hh
// Function: tile::to_string[abi:cxx11]() const
std::string tile::to_string() const {

	char buf[256];
	char basebuf[16];

	switch(geo.mode) {
		case geometry::BGCOLOR: 
			snprintf(basebuf, sizeof(basebuf), "%d,%d", geo.base, 40 + geo.code );
			break;
		case geometry::FGCOLOR: 
			snprintf(basebuf, sizeof(basebuf), "%d,%d", geo.base, 30 + geo.code );
			break;
		case geometry::SYMBOL:
			snprintf(basebuf, sizeof(basebuf), "(%c)" , geo.base + geo.code);
			break;
		case geometry::NOP:
		default:
			*basebuf = '\0';
	}

	snprintf(buf, sizeof(buf), 
			"mode %02x "
			"code %02x "
			"base %02x "
			"%4s "
			"color #%02x%02x%02x "
			"~ #%02x%02x%02x "
			"ratio %2d:%-2d %3d%% "
			"n %3d "
			"x %3d "
			"y %3d "
			"rgb_mean %3d %3d %3d "
			"rgb_stdev %3d %3d %3d "
			"size %dx%d",
			geo.mode,
			geo.code,
			geo.base,
			basebuf,
			(uint8_t)rgb_mean[0], (uint8_t)rgb_mean[1], (uint8_t)rgb_mean[2],
			geo.color[0],geo.color[1],geo.color[2],
			geo.ratio, geometry::ratio_max-geo.ratio, 100*geo.ratio/geometry::ratio_max,
			(int)n(),
			(int)pos[0], (int)pos[1],
			(int)rgb_mean[0],
			(int)rgb_mean[1],
			(int)rgb_mean[2],
			(int)rgb_stdev[0],
			(int)rgb_stdev[1],
			(int)rgb_stdev[2],
			(int)geo.size[1], (int)geo.size[0]
	);

	return std::string(buf);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x268, %rsp            # imm = 0x268
movq %rdi, -0x188(%rbp)
movq %rdi, %rax
movq %rax, -0x180(%rbp)
movq %rdi, -0x30(%rbp)
movq %rsi, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x178(%rbp)
movl 0x20(%rax), %eax
movq %rax, -0x170(%rbp)
subq $0x3, %rax
ja 0x335a
movq -0x170(%rbp), %rax
leaq 0x6d66(%rip), %rcx      # 0xa030
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x178(%rbp), %rax
leaq -0x150(%rbp), %rdi
movl 0x28(%rax), %ecx
movl 0x24(%rax), %r8d
addl $0x28, %r8d
movl $0x10, %esi
leaq 0x6ddd(%rip), %rdx      # 0xa0d5
movb $0x0, %al
callq 0x2310
jmp 0x3361
movq -0x178(%rbp), %rax
leaq -0x150(%rbp), %rdi
movl 0x28(%rax), %ecx
movl 0x24(%rax), %r8d
addl $0x1e, %r8d
movl $0x10, %esi
leaq 0x6daf(%rip), %rdx      # 0xa0d5
movb $0x0, %al
callq 0x2310
jmp 0x3361
movq -0x178(%rbp), %rax
leaq -0x150(%rbp), %rdi
movl 0x28(%rax), %ecx
addl 0x24(%rax), %ecx
movl $0x10, %esi
leaq 0x6d63(%rip), %rdx      # 0xa0b2
movb $0x0, %al
callq 0x2310
jmp 0x3361
jmp 0x335a
movb $0x0, -0x150(%rbp)
movq -0x178(%rbp), %rdi
movl 0x20(%rdi), %eax
movl %eax, -0x19c(%rbp)
movl 0x24(%rdi), %eax
movl %eax, -0x1d0(%rbp)
movl 0x28(%rdi), %eax
movl %eax, -0x1cc(%rbp)
movzbl 0x34(%rdi), %eax
movl %eax, -0x1d8(%rbp)
movzbl 0x38(%rdi), %eax
movl %eax, -0x1dc(%rbp)
movzbl 0x3c(%rdi), %eax
movl %eax, -0x1e0(%rbp)
movl 0x10(%rdi), %eax
movl %eax, -0x1e4(%rbp)
movl 0x14(%rdi), %ebx
movl 0x18(%rdi), %r14d
movl 0x1c(%rdi), %r15d
movl $0x3f, %r12d
subl %r15d, %r12d
imull $0x64, %r15d, %eax
movl %eax, %ecx
imulq $0x4104105, %rcx, %rcx  # imm = 0x4104105
shrq $0x20, %rcx
subl %ecx, %eax
shrl %eax
addl %ecx, %eax
shrl $0x5, %eax
movl %eax, -0x1d4(%rbp)
callq 0x3210
movl -0x1e4(%rbp), %r11d
movl -0x1e0(%rbp), %r10d
movl -0x1dc(%rbp), %edi
movl -0x1d8(%rbp), %esi
movl -0x1d4(%rbp), %edx
movl -0x1d0(%rbp), %r8d
movl -0x1cc(%rbp), %r9d
movq %rax, %rcx
movq -0x178(%rbp), %rax
movl %ecx, %r13d
movl 0x2c(%rax), %ecx
movl %ecx, -0x1a0(%rbp)
movl 0x30(%rax), %ecx
movl %ecx, -0x1a4(%rbp)
movl 0x34(%rax), %ecx
movl %ecx, -0x1a8(%rbp)
movl 0x38(%rax), %ecx
movl %ecx, -0x1ac(%rbp)
movl 0x3c(%rax), %ecx
movl %ecx, -0x1b0(%rbp)
movl 0x4c(%rax), %ecx
movl %ecx, -0x1b4(%rbp)
movl 0x50(%rax), %ecx
movl %ecx, -0x1b8(%rbp)
movl 0x54(%rax), %ecx
movl %ecx, -0x1bc(%rbp)
movl 0x8(%rax), %ecx
movl 0xc(%rax), %eax
movl %eax, -0x1c0(%rbp)
movq %rsp, %rax
movq %rax, -0x1c8(%rbp)
movl %ecx, 0xa0(%rax)
movl -0x1c0(%rbp), %ecx
movl %ecx, 0x98(%rax)
movl -0x1bc(%rbp), %ecx
movl %ecx, 0x90(%rax)
movl -0x1b8(%rbp), %ecx
movl %ecx, 0x88(%rax)
movl -0x1b4(%rbp), %ecx
movl %ecx, 0x80(%rax)
movl -0x1b0(%rbp), %ecx
movl %ecx, 0x78(%rax)
movl -0x1ac(%rbp), %ecx
movl %ecx, 0x70(%rax)
movl -0x1a8(%rbp), %ecx
movl %ecx, 0x68(%rax)
movl -0x1a4(%rbp), %ecx
movl %ecx, 0x60(%rax)
movl -0x1a0(%rbp), %ecx
movl %ecx, 0x58(%rax)
movl -0x19c(%rbp), %ecx
movl %r13d, 0x50(%rax)
movl %r12d, 0x40(%rax)
movl %r15d, 0x38(%rax)
movl %r14d, 0x30(%rax)
movl %ebx, 0x28(%rax)
movl %r11d, 0x20(%rax)
movl %r10d, 0x18(%rax)
movl %edi, 0x10(%rax)
movl %esi, 0x8(%rax)
leaq -0x150(%rbp), %rsi
movq %rsi, (%rax)
movl %edx, 0x48(%rax)
leaq 0x6bc1(%rip), %rdx      # 0xa0db
xorl %eax, %eax
leaq -0x140(%rbp), %rdi
movq %rdi, -0x198(%rbp)
movl $0x100, %esi            # imm = 0x100
callq 0x2310
leaq -0x151(%rbp), %rdi
movq %rdi, -0x190(%rbp)
callq 0x2360
movq -0x188(%rbp), %rdi
movq -0x198(%rbp), %rsi
movq -0x190(%rbp), %rdx
callq 0x4b80
jmp 0x3563
leaq -0x151(%rbp), %rdi
callq 0x2240
movq -0x180(%rbp), %rax
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
leaq -0x151(%rbp), %rdi
callq 0x2240
movq -0x160(%rbp), %rdi
callq 0x2350
nopw %cs:(%rax,%rax)