// File: /workspace/github_c_makefile_star2_O1/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 0x5889
cmpl $0x0, 0x4(%rbx)
jle 0x29c2
xorl %ebp, %ebp
movl $0x3, 0x14(%rsp)
movl $0x2, 0x10(%rsp)
movl $0x1, 0xc(%rsp)
movl (%rbx), %ecx
testl %ecx, %ecx
jle 0x298a
movl %ebp, %r14d
orl $0x1, %r14d
movl %ebp, %r12d
orl $0x2, %r12d
movl %ebp, %r13d
orl $0x3, %r13d
xorl %edx, %edx
movl $0x0, %edi
cmpl %ebp, 0x4(%rbx)
jle 0x27f7
movq 0x8(%rbx), %rsi
movl %ebp, %r8d
imull %ecx, %r8d
addl %edx, %r8d
xorl %edi, %edi
cmpb $0x0, (%rsi,%r8)
setne %dil
movb $0x1, %sil
movb $0x1, %r9b
cmpl %edx, %ecx
jle 0x2820
cmpl %r14d, 0x4(%rbx)
jle 0x2820
movq 0x8(%rbx), %r8
movl 0xc(%rsp), %r9d
imull %ecx, %r9d
addl %edx, %r9d
cmpb $0x0, (%r8,%r9)
sete %r9b
leal 0x2(%rdi), %r8d
testb %r9b, %r9b
cmovnel %edi, %r8d
cmpl %edx, %ecx
jle 0x284a
cmpl %r12d, 0x4(%rbx)
jle 0x284a
movq 0x8(%rbx), %rsi
movl 0x10(%rsp), %edi
imull %ecx, %edi
addl %edx, %edi
cmpb $0x0, (%rsi,%rdi)
sete %sil
leal 0x4(%r8), %edi
testb %sil, %sil
cmovnel %r8d, %edi
leal 0x1(%rdx), %r15d
movb $0x1, %sil
movb $0x1, %r9b
cmpl %r15d, %ecx
jle 0x2883
cmpl %ebp, 0x4(%rbx)
jle 0x2883
movq 0x8(%rbx), %r8
movl %ebp, %r9d
imull %ecx, %r9d
addl %edx, %r9d
incl %r9d
cmpb $0x0, (%r8,%r9)
sete %r9b
leal 0x8(%rdi), %r8d
testb %r9b, %r9b
cmovnel %edi, %r8d
cmpl %r15d, %ecx
jle 0x28b0
cmpl %r14d, 0x4(%rbx)
jle 0x28b0
movq 0x8(%rbx), %rsi
movl 0xc(%rsp), %edi
imull %ecx, %edi
addl %edx, %edi
incl %edi
cmpb $0x0, (%rsi,%rdi)
sete %sil
leal 0x10(%r8), %edi
testb %sil, %sil
cmovnel %r8d, %edi
movb $0x1, %sil
movb $0x1, %r9b
cmpl %r15d, %ecx
jle 0x28e8
cmpl %r12d, 0x4(%rbx)
jle 0x28e8
movq 0x8(%rbx), %r8
movl 0x10(%rsp), %r9d
imull %ecx, %r9d
addl %edx, %r9d
incl %r9d
cmpb $0x0, (%r8,%r9)
sete %r9b
leal 0x20(%rdi), %r8d
testb %r9b, %r9b
cmovnel %edi, %r8d
cmpl %edx, %ecx
jle 0x2912
cmpl %r13d, 0x4(%rbx)
jle 0x2912
movq 0x8(%rbx), %rsi
movl 0x14(%rsp), %edi
imull %ecx, %edi
addl %edx, %edi
cmpb $0x0, (%rsi,%rdi)
sete %sil
leal 0x40(%r8), %edi
testb %sil, %sil
cmovnel %r8d, %edi
movb $0x1, %sil
cmpl %r15d, %ecx
jle 0x2940
cmpl %r13d, 0x4(%rbx)
jle 0x2940
movq 0x8(%rbx), %rsi
imull 0x14(%rsp), %ecx
addl %edx, %ecx
incl %ecx
cmpb $0x0, (%rsi,%rcx)
sete %sil
leal 0x80(%rdi), %ecx
testb %sil, %sil
cmovnel %edi, %ecx
movb $-0x1e, 0x9(%rsp)
movl %ecx, %edx
shrl $0x6, %edx
orb $-0x60, %dl
movb %dl, 0xa(%rsp)
andb $0x3f, %cl
orb $-0x80, %cl
movb %cl, 0xb(%rsp)
movl $0x3, %edx
movq %rax, %rdi
leaq 0x9(%rsp), %rsi
callq 0x6120
movl (%rbx), %ecx
incl %r15d
movl %r15d, %edx
cmpl %ecx, %r15d
jl 0x27d4
movl 0x4(%rbx), %ecx
decl %ecx
cmpl %ecx, %ebp
je 0x29a7
movl $0x1, %edx
movq %rax, %rdi
leaq 0xd3e2(%rip), %rsi      # 0xfd84
callq 0x6120
addl $0x4, %ebp
addl $0x4, 0x14(%rsp)
addl $0x4, 0x10(%rsp)
addl $0x4, 0xc(%rsp)
cmpl 0x4(%rbx), %ebp
jl 0x27b3
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)