// File: /workspace/github_c_makefile_star2_O3/Cotix[P]cReddit/src/main.c
// Function: commentScreenDisplay
void commentScreenDisplay(CommentScreen *screen)
{
    int i, screenLines;
    wchar_t *tmpbuf;
    int bufSize, lastLine, 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->commentOpenSize; 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->lineCount && screen->lines[i]->text != NULL)
            mvaddwstr(i - screen->offset, 0, screen->lines[i]->text);
        else
            mvaddwstr(i - screen->offset, 0, tmpbuf);

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

    if (screen->commentOpen) {
        RedditComment *current;
        lastLine = screenLines - screen->offset;

        for (i = lastLine; i < lastLine + screen->commentOpenSize; i++)
            mvaddwstr(i, 0, tmpbuf);

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

        tmpbuf[bufLen] = (wchar_t)0;
        attron(COLOR_PAIR(2));
        mvaddwstr(lastLine, 0, tmpbuf);

        attron(COLOR_PAIR(1));
        if (screen->lineCount >= screen->selected) {
            current = screen->lines[screen->selected]->comment;
            if (current != NULL) {
                swprintf(tmpbuf, bufLen, L"%s - %d Score - %s", current->author, current->ups, current->created_utc);
                mvaddwstr(lastLine + 1, 0, tmpbuf);
                swprintf(tmpbuf, bufLen, L"-------");
                mvaddwstr(lastLine + 2, 0, tmpbuf);

                mvaddwstr(lastLine + 3, 0, &(current->wbodyEsc[current->advance] ));
            }
        }
    }

    free(tmpbuf);
    refresh();
}

// Assembly:
testq %rdi, %rdi
je 0x3062
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r15
movq 0x643d(%rip), %rax      # 0x8fc8
movslq (%rax), %r14
leal 0x4(,%r14,4), %eax
movslq %eax, %rsi
movl $0x1, %edi
callq 0x2170
movq %rax, %rbx
testq %r14, %r14
jle 0x2ca9
leal 0x3(%r14), %eax
leaq -0x1(%r14), %rcx
movq %rcx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
shrl $0x2, %eax
shlq $0x4, %rax
movdqa 0x2440(%rip), %xmm1     # 0x5010
movdqa 0x2448(%rip), %xmm2     # 0x5020
xorl %ecx, %ecx
movdqa 0x244e(%rip), %xmm3     # 0x5030
pxor %xmm3, %xmm0
pcmpeqd %xmm4, %xmm4
movdqa 0x244e(%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 0x2c2d
movl $0x20, (%rbx,%rcx)
pxor %xmm4, %xmm6
pextrw $0x4, %xmm6, %edx
testb $0x1, %dl
je 0x2c43
movl $0x20, 0x4(%rbx,%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 0x2c82
movl $0x20, 0x8(%rbx,%rcx)
pextrw $0x4, %xmm6, %edx
testb $0x1, %dl
je 0x2c94
movl $0x20, 0xc(%rbx,%rcx)
paddq %xmm5, %xmm2
paddq %xmm5, %xmm1
addq $0x10, %rcx
cmpq %rcx, %rax
jne 0x2bf2
movq %r14, (%rsp)
movl 0x18(%r15), %eax
movl 0x1c(%r15), %ecx
leal (%rax,%rcx), %r14d
leal (%rax,%rcx), %r12d
incl %r12d
movl 0x28(%r15), %eax
addl %r12d, %eax
jle 0x2d0b
xorl %ebp, %ebp
movq 0x630e(%rip), %r13      # 0x8fe0
movq (%r13), %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0x2160
cmpl $-0x1, %eax
je 0x2cf5
movq (%r13), %rdi
movq %rbx, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x22b0
incl %ebp
movl 0x18(%r15), %eax
movl 0x28(%r15), %ecx
addl 0x1c(%r15), %eax
addl %ecx, %eax
incl %eax
cmpl %eax, %ebp
jl 0x2cd2
movq 0x62ce(%rip), %r13      # 0x8fe0
movq (%r13), %rdi
movl $0x100, %esi            # imm = 0x100
xorl %edx, %edx
callq 0x22e0
movslq 0x1c(%r15), %rbp
cmpl %r14d, %ebp
movq (%rsp), %r14
jg 0x2dd4
cmpl 0x20(%r15), %ebp
jne 0x2d49
movq (%r13), %rdi
movl $0x200, %esi            # imm = 0x200
xorl %edx, %edx
callq 0x22e0
movslq 0x8(%r15), %rax
cmpq %rax, %rbp
jge 0x2d89
movq 0x10(%r15), %rax
movq (%rax,%rbp,8), %rax
cmpq $0x0, (%rax)
movl 0x1c(%r15), %eax
je 0x2d8d
movq (%r13), %rdi
movl %ebp, %esi
subl %eax, %esi
xorl %edx, %edx
callq 0x2160
cmpl $-0x1, %eax
je 0x2db2
movq (%r13), %rdi
movq 0x10(%r15), %rax
movq (%rax,%rbp,8), %rax
movq (%rax), %rsi
jmp 0x2da8
movl 0x1c(%r15), %eax
movq (%r13), %rdi
movl %ebp, %esi
subl %eax, %esi
xorl %edx, %edx
callq 0x2160
cmpl $-0x1, %eax
je 0x2db2
movq (%r13), %rdi
movq %rbx, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x22b0
cmpl 0x20(%r15), %ebp
jne 0x2dc8
movq (%r13), %rdi
movl $0x100, %esi            # imm = 0x100
xorl %edx, %edx
callq 0x22e0
incq %rbp
cmpl %ebp, %r12d
jne 0x2d33
testb $0x1, 0x2c(%r15)
je 0x3043
subl 0x1c(%r15), %r12d
cmpl $0x0, 0x28(%r15)
jle 0x2e1d
movl %r12d, %ebp
movq (%r13), %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0x2160
cmpl $-0x1, %eax
je 0x2e10
movq (%r13), %rdi
movq %rbx, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x22b0
incl %ebp
movl 0x28(%r15), %eax
addl %r12d, %eax
cmpl %eax, %ebp
jl 0x2ded
testl %r14d, %r14d
jle 0x2f20
leal 0x3(%r14), %eax
leaq -0x1(%r14), %rcx
movq %rcx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
shrl $0x2, %eax
shlq $0x4, %rax
movdqa 0x21c9(%rip), %xmm1     # 0x5010
movdqa 0x21d1(%rip), %xmm2     # 0x5020
xorl %ecx, %ecx
movdqa 0x21d7(%rip), %xmm3     # 0x5030
pxor %xmm3, %xmm0
pcmpeqd %xmm4, %xmm4
movdqa 0x21d7(%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 0x2ea4
movl $0x2d, (%rbx,%rcx)
pxor %xmm4, %xmm6
pextrw $0x4, %xmm6, %edx
testb $0x1, %dl
je 0x2eba
movl $0x2d, 0x4(%rbx,%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 0x2ef9
movl $0x2d, 0x8(%rbx,%rcx)
pextrw $0x4, %xmm6, %edx
testb $0x1, %dl
je 0x2f0b
movl $0x2d, 0xc(%rbx,%rcx)
paddq %xmm5, %xmm2
paddq %xmm5, %xmm1
addq $0x10, %rcx
cmpq %rcx, %rax
jne 0x2e69
movl $0x0, (%rbx,%r14,4)
movq (%r13), %rdi
movl $0x200, %esi            # imm = 0x200
xorl %edx, %edx
callq 0x22e0
movq (%r13), %rdi
movl %r12d, %esi
xorl %edx, %edx
callq 0x2160
cmpl $-0x1, %eax
je 0x2f5c
movq (%r13), %rdi
movq %rbx, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x22b0
movq (%r13), %rdi
movl $0x100, %esi            # imm = 0x100
xorl %edx, %edx
callq 0x22e0
movslq 0x20(%r15), %rax
cmpl %eax, 0x8(%r15)
jl 0x3043
movq 0x10(%r15), %rcx
movq (%rcx,%rax,8), %rax
movq 0x8(%rax), %r15
testq %r15, %r15
je 0x3043
movq 0x20(%r15), %rcx
movl 0x50(%r15), %r8d
movq 0x78(%r15), %r9
leaq 0x346a(%rip), %rdx      # 0x640c
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x2290
movq (%r13), %rdi
leal 0x1(%r12), %esi
xorl %edx, %edx
callq 0x2160
cmpl $-0x1, %eax
je 0x2fd5
movq (%r13), %rdi
movq %rbx, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x22b0
leaq 0x347c(%rip), %rdx      # 0x6458
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x2290
movq (%r13), %rdi
leal 0x2(%r12), %esi
xorl %edx, %edx
callq 0x2160
cmpl $-0x1, %eax
je 0x300f
movq (%r13), %rdi
movq %rbx, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x22b0
movq (%r13), %rdi
addl $0x3, %r12d
movl %r12d, %esi
xorl %edx, %edx
callq 0x2160
cmpl $-0x1, %eax
je 0x3043
movq (%r13), %rdi
movslq 0x84(%r15), %rsi
shlq $0x2, %rsi
addq 0x48(%r15), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x22b0
movq %rbx, %rdi
callq 0x2230
movq (%r13), %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2220
retq