// File: /workspace/github_c_makefile_star2_O0/baines[P]MiniGBS/ui.c
// Function: ui_chart_draw
static void ui_chart_draw(void){
	static const char* glyphs[3] = {
		" ", "▀", "▄",
	};

	const int c = col - &grid[0];
	const int start_x = MAX(0, (cfg.win_w - GRID_W)/2);

	for(size_t x = 0; x < GRID_W; ++x){
		for(size_t y = 0; y < GRID_H; y += 2){
			int xx = (GRID_W + (c - x)) % GRID_W;

			int color_lo = __builtin_ffs(grid[xx][y+0]);
			int color_hi = __builtin_ffs(grid[xx][y+1]);

			int color;
			const char* glyph;

			if(color_hi && color_lo){
				glyph = glyphs[1 + (color_hi > color_lo)];
				color = color_hi + color_lo + 5;
			} else {
				glyph = glyphs[((color_lo > 0) << 1) | (color_hi > 0)];
				color = color_hi ?: color_lo;
			}

			attron(COLOR_PAIR(color));
			mvprintw((GRID_H/2) - (y/2), start_x + (GRID_W - x), "%s", glyph);
			attroff(COLOR_PAIR(color));
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq 0x8b71(%rip), %rax      # 0x16720
leaq 0x90ea(%rip), %rcx      # 0x16ca0
subq %rcx, %rax
movl $0x3c, %ecx
cqto
idivq %rcx
movl %eax, -0x4(%rbp)
movl $0x0, -0xc(%rbp)
leaq 0x8d44(%rip), %rax      # 0x16918
movl 0x28(%rax), %eax
subl $0x3c, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x10(%rbp)
movl -0xc(%rbp), %eax
cmpl -0x10(%rbp), %eax
jle 0xdbf5
movl -0xc(%rbp), %eax
movl %eax, -0x44(%rbp)
jmp 0xdbfb
movl -0x10(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x8(%rbp)
movq $0x0, -0x20(%rbp)
cmpq $0x3c, -0x20(%rbp)
jae 0xddc3
movq $0x0, -0x28(%rbp)
cmpq $0x3c, -0x28(%rbp)
jae 0xddb0
movslq -0x4(%rbp), %rax
subq -0x20(%rbp), %rax
addq $0x3c, %rax
movl $0x3c, %ecx
xorl %edx, %edx
divq %rcx
movl %edx, %eax
movl %eax, -0x2c(%rbp)
movslq -0x2c(%rbp), %rcx
leaq 0x904d(%rip), %rax      # 0x16ca0
imulq $0x3c, %rcx, %rcx
addq %rcx, %rax
movq -0x28(%rbp), %rcx
movzbl (%rax,%rcx), %edx
tzcntl %edx, %eax
addl $0x1, %eax
xorl %ecx, %ecx
cmpl $0x0, %edx
cmovel %ecx, %eax
movl %eax, -0x30(%rbp)
movslq -0x2c(%rbp), %rcx
leaq 0x9021(%rip), %rax      # 0x16ca0
imulq $0x3c, %rcx, %rcx
addq %rcx, %rax
movq -0x28(%rbp), %rcx
movzbl 0x1(%rax,%rcx), %edx
tzcntl %edx, %eax
addl $0x1, %eax
xorl %ecx, %ecx
cmpl $0x0, %edx
cmovel %ecx, %eax
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0xdcde
cmpl $0x0, -0x30(%rbp)
je 0xdcde
movl -0x34(%rbp), %eax
cmpl -0x30(%rbp), %eax
setg %al
andb $0x1, %al
movzbl %al, %eax
addl $0x1, %eax
movslq %eax, %rcx
leaq 0x8a68(%rip), %rax      # 0x16730
movq (%rax,%rcx,8), %rax
movq %rax, -0x40(%rbp)
movl -0x34(%rbp), %eax
addl -0x30(%rbp), %eax
addl $0x5, %eax
movl %eax, -0x38(%rbp)
jmp 0xdd2c
cmpl $0x0, -0x30(%rbp)
setg %al
andb $0x1, %al
movzbl %al, %eax
shll %eax
cmpl $0x0, -0x34(%rbp)
setg %cl
andb $0x1, %cl
movzbl %cl, %ecx
orl %ecx, %eax
movslq %eax, %rcx
leaq 0x8a2b(%rip), %rax      # 0x16730
movq (%rax,%rcx,8), %rax
movq %rax, -0x40(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x48(%rbp)
cmpl $0x0, %eax
je 0xdd20
movl -0x48(%rbp), %eax
movl %eax, -0x4c(%rbp)
jmp 0xdd26
movl -0x30(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0x38(%rbp)
movq 0x729d(%rip), %rax      # 0x14fd0
movq (%rax), %rdi
movl -0x38(%rbp), %esi
shll $0x8, %esi
andl $0xff00, %esi           # imm = 0xFF00
xorl %eax, %eax
movl %eax, %edx
callq 0x52b0
movq -0x28(%rbp), %rcx
shrq %rcx
movl $0x1e, %eax
subq %rcx, %rax
movl %eax, %edi
movslq -0x8(%rbp), %rax
movl $0x3c, %ecx
subq -0x20(%rbp), %rcx
addq %rcx, %rax
movl %eax, %esi
movq -0x40(%rbp), %rcx
leaq 0x30d6(%rip), %rdx      # 0x10e4f
movb $0x0, %al
callq 0x50e0
movq 0x7249(%rip), %rax      # 0x14fd0
movq (%rax), %rdi
movl -0x38(%rbp), %esi
shll $0x8, %esi
andl $0xff00, %esi           # imm = 0xFF00
xorl %eax, %eax
movl %eax, %edx
callq 0x55a0
movq -0x28(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x28(%rbp)
jmp 0xdc22
jmp 0xddb2
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0xdc0f
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)