// File: /workspace/github_c_makefile_star2_O3/antirez[P]stonky/canvas.c
// Function: renderCanvas
sds renderCanvas(canvas *canvas) {
    sds text = sdsempty();
    for (int y = 0; y < canvas->height; y += 4) {
        for (int x = 0; x < canvas->width; x += 2) {
            /* We need to emit groups of 8 bits according to a specific
             * arrangement. See lwTranslatePixelsGroup() for more info. */
            int byte = 0;
            if (getPixel(canvas,x,y)) byte |= (1<<0);
            if (getPixel(canvas,x,y+1)) byte |= (1<<1);
            if (getPixel(canvas,x,y+2)) byte |= (1<<2);
            if (getPixel(canvas,x+1,y)) byte |= (1<<3);
            if (getPixel(canvas,x+1,y+1)) byte |= (1<<4);
            if (getPixel(canvas,x+1,y+2)) byte |= (1<<5);
            if (getPixel(canvas,x,y+3)) byte |= (1<<6);
            if (getPixel(canvas,x+1,y+3)) byte |= (1<<7);
            char unicode[3];
            brailleTranslatePixelsGroup(byte,unicode);
            text = sdscatlen(text,unicode,3);
        }
        if (y != canvas->height-1) text = sdscatlen(text,"\n",1);
    }
    return text;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
callq 0x56c6
movl 0x4(%rbx), %edx
testl %edx, %edx
jle 0x2999
xorl %ebp, %ebp
movl $0x3, 0xc(%rsp)
movl $0x2, 0x14(%rsp)
movl $0x1, 0x10(%rsp)
movl (%rbx), %ecx
testl %ecx, %ecx
jle 0x2961
movl %ebp, %r14d
orl $0x1, %r14d
movl %ebp, %r12d
orl $0x2, %r12d
movl %ebp, %r13d
orl $0x3, %r13d
xorl %r15d, %r15d
movl 0x4(%rbx), %esi
cmpl %ebp, %esi
jle 0x2807
movq 0x8(%rbx), %rdi
movl %ebp, %r8d
imull %ecx, %r8d
addl %r15d, %r8d
movl $0x1, %edx
cmpb $0x0, (%rdi,%r8)
jne 0x2809
xorl %edx, %edx
cmpl %r14d, %esi
jle 0x2828
movq 0x8(%rbx), %rdi
movl 0x10(%rsp), %r8d
imull %ecx, %r8d
addl %r15d, %r8d
cmpb $0x0, (%rdi,%r8)
je 0x2828
orl $0x2, %edx
cmpl %r12d, %esi
jle 0x284a
movq 0x8(%rbx), %rdi
movl 0x14(%rsp), %r8d
imull %ecx, %r8d
addl %r15d, %r8d
cmpb $0x0, (%rdi,%r8)
leal 0x4(%rdx), %edi
cmovel %edx, %edi
movl %edi, %edx
leal 0x1(%r15), %edi
cmpl %edi, %ecx
jle 0x2905
cmpl %ebp, %esi
jle 0x287b
movq 0x8(%rbx), %r8
movl %ebp, %r9d
imull %ecx, %r9d
addl %r15d, %r9d
incl %r9d
cmpb $0x0, (%r8,%r9)
leal 0x8(%rdx), %r8d
cmovel %edx, %r8d
movl %r8d, %edx
cmpl %r14d, %esi
jle 0x28a3
movq 0x8(%rbx), %r8
movl 0x10(%rsp), %r9d
imull %ecx, %r9d
addl %r15d, %r9d
incl %r9d
cmpb $0x0, (%r8,%r9)
leal 0x10(%rdx), %r8d
cmovel %edx, %r8d
movl %r8d, %edx
cmpl %r12d, %esi
jle 0x28cb
movq 0x8(%rbx), %r8
movl 0x14(%rsp), %r9d
imull %ecx, %r9d
addl %r15d, %r9d
incl %r9d
cmpb $0x0, (%r8,%r9)
leal 0x20(%rdx), %r8d
cmovel %edx, %r8d
movl %r8d, %edx
cmpl %r13d, %esi
jle 0x2922
movq 0x8(%rbx), %r8
movl 0xc(%rsp), %esi
imull %ecx, %esi
leal (%r15,%rsi), %r9d
cmpb $0x0, (%r8,%r9)
leal 0x40(%rdx), %r8d
cmovnel %r8d, %edx
cmpl %edi, %ecx
jle 0x2922
movq 0x8(%rbx), %rcx
addl %r15d, %esi
incl %esi
cmpb $0x0, (%rcx,%rsi)
leal 0x80(%rdx), %ecx
jmp 0x291d
cmpl %r13d, %esi
jle 0x2922
movq 0x8(%rbx), %rsi
imull 0xc(%rsp), %ecx
addl %r15d, %ecx
cmpb $0x0, (%rsi,%rcx)
leal 0x40(%rdx), %ecx
cmovel %edx, %ecx
movl %ecx, %edx
movb $-0x1e, 0x9(%rsp)
movl %edx, %ecx
shrl $0x6, %ecx
orb $-0x60, %cl
movb %cl, 0xa(%rsp)
andb $0x3f, %dl
orb $-0x80, %dl
movb %dl, 0xb(%rsp)
movl $0x3, %edx
movq %rax, %rdi
leaq 0x9(%rsp), %rsi
callq 0x5f26
addl $0x2, %r15d
movl (%rbx), %ecx
cmpl %ecx, %r15d
jl 0x27e6
movl 0x4(%rbx), %edx
leal -0x1(%rdx), %ecx
cmpl %ecx, %ebp
je 0x297f
movl $0x1, %edx
movq %rax, %rdi
leaq 0xd3ed(%rip), %rsi      # 0xfd64
callq 0x5f26
movl 0x4(%rbx), %edx
addl $0x4, %ebp
addl $0x4, 0xc(%rsp)
addl $0x4, 0x14(%rsp)
addl $0x4, 0x10(%rsp)
cmpl %edx, %ebp
jl 0x27c4
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq