// File: /workspace/github_c_makefile_star2_O3/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 0x3985
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x58b1(%rip), %rax      # 0x8fc8
movslq (%rax), %r15
leal 0x4(,%r15,4), %eax
movslq %eax, %rsi
movl $0x1, %edi
callq 0x2170
movq %rax, %r14
testq %r15, %r15
jle 0x3839
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 0x18b4(%rip), %xmm1     # 0x5010
movdqa 0x18bc(%rip), %xmm2     # 0x5020
xorl %ecx, %ecx
movdqa 0x18c2(%rip), %xmm3     # 0x5030
pxor %xmm3, %xmm0
pcmpeqd %xmm4, %xmm4
movdqa 0x18c2(%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 0x37ba
movl $0x20, (%r14,%rcx)
pxor %xmm4, %xmm6
pextrw $0x4, %xmm6, %edx
testb $0x1, %dl
je 0x37d1
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 0x3811
movl $0x20, 0x8(%r14,%rcx)
pextrw $0x4, %xmm6, %edx
testb $0x1, %dl
je 0x3824
movl $0x20, 0xc(%r14,%rcx)
paddq %xmm5, %xmm2
paddq %xmm5, %xmm1
addq $0x10, %rcx
cmpq %rcx, %rax
jne 0x377e
movq %r15, (%rsp)
movl 0x8(%rbx), %eax
movl 0xc(%rbx), %ecx
leal (%rax,%rcx), %r15d
leal (%rax,%rcx), %ebp
incl %ebp
movl 0x28(%rbx), %eax
addl %ebp, %eax
jle 0x3896
xorl %r12d, %r12d
movq 0x5783(%rip), %r13      # 0x8fe0
movq (%r13), %rdi
movl %r12d, %esi
xorl %edx, %edx
callq 0x2160
cmpl $-0x1, %eax
je 0x3881
movq (%r13), %rdi
movq %r14, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x22b0
incl %r12d
movl 0x8(%rbx), %eax
movl 0x28(%rbx), %ecx
addl 0xc(%rbx), %eax
addl %ecx, %eax
incl %eax
cmpl %eax, %r12d
jl 0x385d
movq 0x5743(%rip), %r13      # 0x8fe0
movq (%r13), %rdi
movl $0x100, %esi            # imm = 0x100
xorl %edx, %edx
callq 0x22e0
movslq 0xc(%rbx), %r12
cmpl %r15d, %r12d
movq 0x570d(%rip), %r15      # 0x8fc8
jg 0x3967
cmpl 0x10(%rbx), %r12d
jne 0x38d7
movq (%r13), %rdi
movl $0x200, %esi            # imm = 0x200
xorl %edx, %edx
callq 0x22e0
movq (%rbx), %rax
movslq 0x14(%rax), %rax
cmpq %rax, %r12
jge 0x391e
movslq 0x14(%rbx), %rax
cmpq %rax, %r12
jl 0x38fa
movl (%r15), %edx
movq %rbx, %rdi
movl %r12d, %esi
callq 0x32c2
movq (%r13), %rdi
movl %r12d, %esi
subl 0xc(%rbx), %esi
xorl %edx, %edx
callq 0x2160
cmpl $-0x1, %eax
je 0x3945
movq (%r13), %rdi
movq 0x20(%rbx), %rax
movq (%rax,%r12,8), %rsi
jmp 0x393b
movq (%r13), %rdi
movl %r12d, %esi
subl 0xc(%rbx), %esi
xorl %edx, %edx
callq 0x2160
cmpl $-0x1, %eax
je 0x3945
movq (%r13), %rdi
movq %r14, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x22b0
cmpl 0x10(%rbx), %r12d
jne 0x395b
movq (%r13), %rdi
movl $0x100, %esi            # imm = 0x100
xorl %edx, %edx
callq 0x22e0
incq %r12
cmpl %r12d, %ebp
jne 0x38c1
movb 0x2c(%rbx), %al
testb $0x1, %al
je 0x3991
movq %rbx, %rdi
movq %r14, %rsi
testb $0x2, %al
jne 0x3986
movq (%rsp), %rdx
movl %ebp, %ecx
callq 0x353e
jmp 0x3991
retq
movq (%rsp), %rdx
movl %ebp, %ecx
callq 0x3680
movq %r14, %rdi
callq 0x2230
movq (%r13), %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2220