// File: /workspace/github_c_makefile_star2_O1/Cotix[P]cReddit/src/main.c
// Function: drawScreen
void drawScreen(LinkScreen *screen)
{
    int i, screenLines;
    wchar_t *tmpbuf;
    int bufSize, bufLen;

    if (screen == NULL)
        return ;

    bufSize = sizeof(wchar_t) * (COLS + 1);
    bufLen = COLS;
    tmpbuf = malloc(bufSize);
    memset(tmpbuf, 0, bufSize);

    for (i = 0; i < bufLen; i++)
        tmpbuf[i] = L' ';

    screenLines = screen->offset + screen->displayed + 1;

    for (i = 0; i < screen->displayed + screen->offset + 1 + screen->linkOpenSize; i++)
        mvaddwstr(i, 0, tmpbuf);

    attron(COLOR_PAIR(1));

    for(i = screen->offset; i < screenLines; i++) {
        if(i == screen->selected)
            attron(COLOR_PAIR(2));

        if (i < screen->list->linkCount) {
            if (screen->screenLineCount <= i)
                linkScreenRenderLine(screen, i, COLS);

            mvaddwstr(i - screen->offset, 0, screen->screenLines[i]);
        } else {
            mvaddwstr(i - screen->offset, 0, tmpbuf);
        }

        if (i == screen->selected)
            attron(COLOR_PAIR(1));
    }



    if (screen->linkOpen) {
        if (screen->helpOpen == 0)
            linkScreenRenderLinkText(screen, tmpbuf, bufLen, screenLines);
        else
            linkScreenRenderHelpText(screen, tmpbuf, bufLen, screenLines);
    }

    free(tmpbuf);

    refresh();
}

// Assembly:
testq %rdi, %rdi
je 0x39cc
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq 0x5889(%rip), %rax      # 0x8fc8
movslq (%rax), %r15
leal 0x4(,%r15,4), %eax
movslq %eax, %r12
movq %r12, %rdi
callq 0x2250
movq %rax, %r14
movq %rax, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x2110
testq %r15, %r15
jle 0x386c
leal 0x3(%r15), %eax
leaq -0x1(%r15), %rcx
movq %rcx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
shrl $0x2, %eax
shlq $0x4, %rax
movdqa 0x1881(%rip), %xmm1     # 0x5010
movdqa 0x1889(%rip), %xmm2     # 0x5020
xorl %ecx, %ecx
movdqa 0x188f(%rip), %xmm3     # 0x5030
pxor %xmm3, %xmm0
pcmpeqd %xmm4, %xmm4
movdqa 0x188f(%rip), %xmm5     # 0x5040
movdqa %xmm2, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
movd %xmm6, %edx
notl %edx
testb $0x1, %dl
je 0x37ed
movl $0x20, (%r14,%rcx)
pxor %xmm4, %xmm6
pextrw $0x4, %xmm6, %edx
testb $0x1, %dl
je 0x3804
movl $0x20, 0x4(%r14,%rcx)
movdqa %xmm1, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
pxor %xmm4, %xmm6
pextrw $0x0, %xmm6, %edx
testb $0x1, %dl
je 0x3844
movl $0x20, 0x8(%r14,%rcx)
pextrw $0x4, %xmm6, %edx
testb $0x1, %dl
je 0x3857
movl $0x20, 0xc(%r14,%rcx)
paddq %xmm5, %xmm2
paddq %xmm5, %xmm1
addq $0x10, %rcx
cmpq %rcx, %rax
jne 0x37b1
movq %r15, 0x10(%rsp)
movl 0x8(%rbx), %ebp
movl 0xc(%rbx), %r15d
leal (%r15,%rbp), %eax
movl %eax, 0xc(%rsp)
leal (%r15,%rbp), %ecx
incl %ecx
movl 0x28(%rbx), %eax
movl %ecx, 0x8(%rsp)
addl %ecx, %eax
jle 0x38d4
xorl %r12d, %r12d
movq 0x5745(%rip), %r13      # 0x8fe0
movq (%r13), %rdi
movl %r12d, %esi
xorl %edx, %edx
callq 0x2160
cmpl $-0x1, %eax
je 0x38bf
movq (%r13), %rdi
movq %r14, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x22a0
incl %r12d
movl 0x8(%rbx), %eax
movl 0x28(%rbx), %ecx
addl 0xc(%rbx), %eax
addl %ecx, %eax
incl %eax
cmpl %eax, %r12d
jl 0x389b
movq 0x5705(%rip), %r13      # 0x8fe0
movq (%r13), %rdi
movl $0x100, %esi            # imm = 0x100
xorl %edx, %edx
callq 0x22d0
movslq 0xc(%rbx), %r12
cmpl 0xc(%rsp), %r12d
jg 0x39ab
addl %r15d, %ebp
incl %ebp
cmpl 0x10(%rbx), %r12d
jne 0x3915
movq (%r13), %rdi
movl $0x200, %esi            # imm = 0x200
xorl %edx, %edx
callq 0x22d0
movq (%rbx), %rax
movslq 0x14(%rax), %rax
cmpq %rax, %r12
jge 0x3962
movslq 0x14(%rbx), %rax
cmpq %rax, %r12
jl 0x393e
movq 0x5697(%rip), %rax      # 0x8fc8
movl (%rax), %edx
movq %rbx, %rdi
movl %r12d, %esi
callq 0x32e7
movq (%r13), %rdi
movl %r12d, %esi
subl 0xc(%rbx), %esi
xorl %edx, %edx
callq 0x2160
cmpl $-0x1, %eax
je 0x3989
movq (%r13), %rdi
movq 0x20(%rbx), %rax
movq (%rax,%r12,8), %rsi
jmp 0x397f
movq (%r13), %rdi
movl %r12d, %esi
subl 0xc(%rbx), %esi
xorl %edx, %edx
callq 0x2160
cmpl $-0x1, %eax
je 0x3989
movq (%r13), %rdi
movq %r14, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x22a0
cmpl 0x10(%rbx), %r12d
jne 0x399f
movq (%r13), %rdi
movl $0x100, %esi            # imm = 0x100
xorl %edx, %edx
callq 0x22d0
incq %r12
cmpl %r12d, %ebp
jne 0x38ff
movb 0x2c(%rbx), %al
testb $0x1, %al
je 0x39db
movq %rbx, %rdi
movq %r14, %rsi
testb $0x2, %al
jne 0x39cd
movq 0x10(%rsp), %rdx
movl 0x8(%rsp), %ecx
callq 0x3563
jmp 0x39db
retq
movq 0x10(%rsp), %rdx
movl 0x8(%rsp), %ecx
callq 0x36a5
movq %r14, %rdi
callq 0x2220
movq (%r13), %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2210