// File: aempirei[P]Chat-Art/calibration.cc
// Function: process_tiles(config&, pnm const&, int const*, int const*)
void process_tiles(config& cfg, const pnm& snapshot, const pos_t size, const pos_t origin) {

	tile base(&snapshot, size, origin);

	tiles     solid_tiles( 8, base);
	tiles uppercase_tiles(26, base);
	tiles lowercase_tiles(26, base);
	tiles    number_tiles(10, base);

	cfg.bg_colors.resize(8, base);
	cfg.fg_colors.resize(8, base);

	assign_tiles(    solid_tiles, 1, geometry::NOP    , 0);

	assign_tiles(  cfg.bg_colors, 2, geometry::BGCOLOR, 0);
	assign_tiles(  cfg.fg_colors, 3, geometry::FGCOLOR, 1);

	assign_tiles(uppercase_tiles, 4, geometry::SYMBOL, 'A');
	assign_tiles(lowercase_tiles, 5, geometry::SYMBOL, 'a');
	assign_tiles(   number_tiles, 6, geometry::SYMBOL, '0');

	for(tile t : cfg.bg_colors) {
		t.geo.mode = geometry::FGCOLOR;
		cfg.fg_colors.push_back(t);
	}

	tile space_tile = solid_tiles.front();

	space_tile.set_status(geometry::SYMBOL, 0, ' ');

	assign_symbolic_tiles(cfg, {uppercase_tiles, lowercase_tiles, number_tiles, tiles(1, space_tile)});

	print_tiles(cfg.bg_colors, "background colors");
	print_tiles(cfg.fg_colors, "foreground colors");
	print_tiles(cfg.symbols  , "character symbols");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x300, %rsp            # imm = 0x300
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0x78(%rbp), %rdi
movq %rdi, -0x288(%rbp)
callq 0x2ce0
leaq -0x91(%rbp), %rdi
movq %rdi, -0x280(%rbp)
callq 0x5340
movq -0x288(%rbp), %rdx
movq -0x280(%rbp), %rcx
leaq -0x90(%rbp), %rdi
movl $0x8, %esi
callq 0x5360
jmp 0x3c4b
leaq -0x91(%rbp), %rdi
callq 0x53e0
leaq -0xc1(%rbp), %rdi
movq %rdi, -0x290(%rbp)
callq 0x5340
movq -0x290(%rbp), %rcx
leaq -0xc0(%rbp), %rdi
movl $0x1a, %esi
leaq -0x78(%rbp), %rdx
callq 0x5360
jmp 0x3c88
leaq -0xc1(%rbp), %rdi
callq 0x53e0
leaq -0xe1(%rbp), %rdi
movq %rdi, -0x298(%rbp)
callq 0x5340
movq -0x298(%rbp), %rcx
leaq -0xe0(%rbp), %rdi
movl $0x1a, %esi
leaq -0x78(%rbp), %rdx
callq 0x5360
jmp 0x3cc5
leaq -0xe1(%rbp), %rdi
callq 0x53e0
leaq -0x101(%rbp), %rdi
movq %rdi, -0x2a0(%rbp)
callq 0x5340
movq -0x2a0(%rbp), %rcx
leaq -0x100(%rbp), %rdi
movl $0xa, %esi
leaq -0x78(%rbp), %rdx
callq 0x5360
jmp 0x3d02
leaq -0x101(%rbp), %rdi
callq 0x53e0
movq -0x8(%rbp), %rdi
movl $0x8, %esi
leaq -0x78(%rbp), %rdx
callq 0x5400
jmp 0x3d22
movq -0x8(%rbp), %rdi
addq $0x18, %rdi
movl $0x8, %esi
leaq -0x78(%rbp), %rdx
callq 0x5400
jmp 0x3d3a
leaq -0x90(%rbp), %rdi
movl $0x1, %esi
xorl %ecx, %ecx
movl %ecx, %edx
callq 0x3850
jmp 0x3d51
movq -0x8(%rbp), %rdi
movl $0x2, %esi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x3850
jmp 0x3d68
movq -0x8(%rbp), %rdi
addq $0x18, %rdi
movl $0x3, %esi
movl $0x2, %edx
movl $0x1, %ecx
callq 0x3850
jmp 0x3d86
leaq -0xc0(%rbp), %rdi
movl $0x4, %esi
movl $0x3, %edx
movl $0x41, %ecx
callq 0x3850
jmp 0x3da3
leaq -0xe0(%rbp), %rdi
movl $0x5, %esi
movl $0x3, %edx
movl $0x61, %ecx
callq 0x3850
jmp 0x3dc0
leaq -0x100(%rbp), %rdi
movl $0x6, %esi
movl $0x3, %edx
movl $0x30, %ecx
callq 0x3850
jmp 0x3ddd
movq -0x8(%rbp), %rax
movq %rax, -0x110(%rbp)
movq -0x110(%rbp), %rdi
callq 0x4f90
movq %rax, -0x118(%rbp)
movq -0x110(%rbp), %rdi
callq 0x4fc0
movq %rax, -0x120(%rbp)
leaq -0x118(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x4ff0
testb $0x1, %al
jne 0x3e2a
jmp 0x3f4d
leaq -0x118(%rbp), %rdi
callq 0x5030
movq 0x50(%rax), %rcx
movq %rcx, -0x130(%rbp)
movups 0x40(%rax), %xmm0
movaps %xmm0, -0x140(%rbp)
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups 0x20(%rax), %xmm2
movups 0x30(%rax), %xmm3
movaps %xmm3, -0x150(%rbp)
movaps %xmm2, -0x160(%rbp)
movaps %xmm1, -0x170(%rbp)
movaps %xmm0, -0x180(%rbp)
movl $0x2, -0x160(%rbp)
movq -0x8(%rbp), %rdi
addq $0x18, %rdi
leaq -0x180(%rbp), %rsi
callq 0x5130
jmp 0x3e97
jmp 0x3e99
leaq -0x118(%rbp), %rdi
callq 0x51a0
jmp 0x3e0e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x91(%rbp), %rdi
callq 0x53e0
jmp 0x42ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0xc1(%rbp), %rdi
callq 0x53e0
jmp 0x42f3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0xe1(%rbp), %rdi
callq 0x53e0
jmp 0x42e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x101(%rbp), %rdi
callq 0x53e0
jmp 0x42db
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x42cf
leaq -0x90(%rbp), %rdi
callq 0x54b0
movq 0x50(%rax), %rcx
movq %rcx, -0x190(%rbp)
movups 0x40(%rax), %xmm0
movaps %xmm0, -0x1a0(%rbp)
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups 0x20(%rax), %xmm2
movups 0x30(%rax), %xmm3
movaps %xmm3, -0x1b0(%rbp)
movaps %xmm2, -0x1c0(%rbp)
movaps %xmm1, -0x1d0(%rbp)
movaps %xmm0, -0x1e0(%rbp)
leaq -0x1e0(%rbp), %rdi
movl $0x3, %esi
xorl %edx, %edx
movl $0x20, %ecx
callq 0x2df0
movq -0x8(%rbp), %rax
movq %rax, -0x2a8(%rbp)
movb $0x1, -0x272(%rbp)
leaq -0x268(%rbp), %rdi
movq %rdi, -0x270(%rbp)
leaq -0xc0(%rbp), %rsi
callq 0x4ea0
jmp 0x3fe0
leaq -0x250(%rbp), %rdi
movq %rdi, -0x270(%rbp)
leaq -0xe0(%rbp), %rsi
callq 0x4ea0
jmp 0x3ffc
leaq -0x238(%rbp), %rdi
movq %rdi, -0x270(%rbp)
leaq -0x100(%rbp), %rsi
callq 0x4ea0
jmp 0x4018
leaq -0x220(%rbp), %rax
movq %rax, -0x2b8(%rbp)
movq %rax, -0x270(%rbp)
leaq -0x271(%rbp), %rdi
movq %rdi, -0x2b0(%rbp)
callq 0x5340
movq -0x2b8(%rbp), %rdi
movq -0x2b0(%rbp), %rcx
movl $0x1, %esi
leaq -0x1e0(%rbp), %rdx
callq 0x5360
jmp 0x4061
movb $0x0, -0x272(%rbp)
leaq -0x268(%rbp), %rax
movq %rax, -0x208(%rbp)
movq $0x4, -0x200(%rbp)
leaq -0x273(%rbp), %rdi
movq %rdi, -0x2c0(%rbp)
callq 0x54e0
movq -0x2c0(%rbp), %rcx
movq -0x208(%rbp), %rsi
movq -0x200(%rbp), %rdx
leaq -0x1f8(%rbp), %rdi
callq 0x5500
jmp 0x40b7
movq -0x2a8(%rbp), %rdi
leaq -0x1f8(%rbp), %rsi
callq 0x38e0
jmp 0x40cc
leaq -0x1f8(%rbp), %rdi
callq 0x55b0
leaq -0x273(%rbp), %rdi
callq 0x55d0
leaq -0x268(%rbp), %rax
movq %rax, -0x2d0(%rbp)
addq $0x60, %rax
movq %rax, -0x2c8(%rbp)
movq -0x2c8(%rbp), %rdi
addq $-0x18, %rdi
movq %rdi, -0x2d8(%rbp)
callq 0x51c0
movq -0x2d0(%rbp), %rcx
movq -0x2d8(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x2c8(%rbp)
jne 0x40fd
leaq -0x271(%rbp), %rdi
callq 0x53e0
movq -0x8(%rbp), %rdi
leaq 0x6047(%rip), %rsi      # 0xa18c
callq 0x3ac0
jmp 0x414c
movq -0x8(%rbp), %rdi
addq $0x18, %rdi
leaq 0x6043(%rip), %rsi      # 0xa19e
callq 0x3ac0
jmp 0x4162
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
leaq 0x603f(%rip), %rsi      # 0xa1b0
callq 0x3ac0
jmp 0x4178
leaq -0x100(%rbp), %rdi
callq 0x51c0
leaq -0xe0(%rbp), %rdi
callq 0x51c0
leaq -0xc0(%rbp), %rdi
callq 0x51c0
leaq -0x90(%rbp), %rdi
callq 0x51c0
addq $0x300, %rsp            # imm = 0x300
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x4275
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x4269
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x4211
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x1f8(%rbp), %rdi
callq 0x55b0
leaq -0x273(%rbp), %rdi
callq 0x55d0
leaq -0x268(%rbp), %rax
movq %rax, -0x2e8(%rbp)
addq $0x60, %rax
movq %rax, -0x2e0(%rbp)
movq -0x2e0(%rbp), %rdi
addq $-0x18, %rdi
movq %rdi, -0x2f0(%rbp)
callq 0x51c0
movq -0x2e8(%rbp), %rcx
movq -0x2f0(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x2e0(%rbp)
jne 0x4236
jmp 0x4269
leaq -0x271(%rbp), %rdi
callq 0x53e0
testb $0x1, -0x272(%rbp)
jne 0x4280
jmp 0x42cd
movq -0x270(%rbp), %rax
leaq -0x268(%rbp), %rcx
cmpq %rax, %rcx
movq %rax, -0x2f8(%rbp)
je 0x42cb
movq -0x2f8(%rbp), %rdi
addq $-0x18, %rdi
movq %rdi, -0x300(%rbp)
callq 0x51c0
movq -0x300(%rbp), %rax
leaq -0x268(%rbp), %rcx
cmpq %rcx, %rax
movq %rax, -0x2f8(%rbp)
jne 0x429a
jmp 0x42cd
jmp 0x42cf
leaq -0x100(%rbp), %rdi
callq 0x51c0
leaq -0xe0(%rbp), %rdi
callq 0x51c0
leaq -0xc0(%rbp), %rdi
callq 0x51c0
leaq -0x90(%rbp), %rdi
callq 0x51c0
movq -0xa0(%rbp), %rdi
callq 0x2350
nopl (%rax,%rax)