// File: /workspace/github_c_makefile_star2_O1/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 0x307e
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r15
movq 0x6428(%rip), %rax      # 0x8fc8
movslq (%rax), %r14
leal 0x4(,%r14,4), %eax
movslq %eax, %r12
movq %r12, %rdi
callq 0x2250
movq %rax, %rbx
movq %rax, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x2110
testq %r14, %r14
jle 0x2cc9
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 0x2420(%rip), %xmm1     # 0x5010
movdqa 0x2428(%rip), %xmm2     # 0x5020
xorl %ecx, %ecx
movdqa 0x242e(%rip), %xmm3     # 0x5030
pxor %xmm3, %xmm0
pcmpeqd %xmm4, %xmm4
movdqa 0x242e(%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 0x2c4d
movl $0x20, (%rbx,%rcx)
pxor %xmm4, %xmm6
pextrw $0x4, %xmm6, %edx
testb $0x1, %dl
je 0x2c63
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 0x2ca2
movl $0x20, 0x8(%rbx,%rcx)
pextrw $0x4, %xmm6, %edx
testb $0x1, %dl
je 0x2cb4
movl $0x20, 0xc(%rbx,%rcx)
paddq %xmm5, %xmm2
paddq %xmm5, %xmm1
addq $0x10, %rcx
cmpq %rcx, %rax
jne 0x2c12
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 0x2d2b
xorl %ebp, %ebp
movq 0x62ee(%rip), %r13      # 0x8fe0
movq (%r13), %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0x2160
cmpl $-0x1, %eax
je 0x2d15
movq (%r13), %rdi
movq %rbx, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x22a0
incl %ebp
movl 0x18(%r15), %eax
movl 0x28(%r15), %ecx
addl 0x1c(%r15), %eax
addl %ecx, %eax
incl %eax
cmpl %eax, %ebp
jl 0x2cf2
movq 0x62ae(%rip), %r13      # 0x8fe0
movq (%r13), %rdi
movl $0x100, %esi            # imm = 0x100
xorl %edx, %edx
callq 0x22d0
movslq 0x1c(%r15), %rbp
cmpl %r14d, %ebp
movq (%rsp), %r14
jg 0x2df0
cmpl 0x20(%r15), %ebp
jne 0x2d69
movq (%r13), %rdi
movl $0x200, %esi            # imm = 0x200
xorl %edx, %edx
callq 0x22d0
movslq 0x8(%r15), %rax
cmpq %rax, %rbp
jge 0x2da7
movq 0x10(%r15), %rax
movq (%rax,%rbp,8), %rax
cmpq $0x0, (%rax)
je 0x2da7
movq (%r13), %rdi
movl %ebp, %esi
subl 0x1c(%r15), %esi
xorl %edx, %edx
callq 0x2160
cmpl $-0x1, %eax
je 0x2dce
movq (%r13), %rdi
movq 0x10(%r15), %rax
movq (%rax,%rbp,8), %rax
movq (%rax), %rsi
jmp 0x2dc4
movq (%r13), %rdi
movl %ebp, %esi
subl 0x1c(%r15), %esi
xorl %edx, %edx
callq 0x2160
cmpl $-0x1, %eax
je 0x2dce
movq (%r13), %rdi
movq %rbx, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x22a0
cmpl 0x20(%r15), %ebp
jne 0x2de4
movq (%r13), %rdi
movl $0x100, %esi            # imm = 0x100
xorl %edx, %edx
callq 0x22d0
incq %rbp
cmpl %ebp, %r12d
jne 0x2d53
testb $0x1, 0x2c(%r15)
je 0x305f
subl 0x1c(%r15), %r12d
cmpl $0x0, 0x28(%r15)
jle 0x2e39
movl %r12d, %ebp
movq (%r13), %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0x2160
cmpl $-0x1, %eax
je 0x2e2c
movq (%r13), %rdi
movq %rbx, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x22a0
incl %ebp
movl 0x28(%r15), %eax
addl %r12d, %eax
cmpl %eax, %ebp
jl 0x2e09
testl %r14d, %r14d
jle 0x2f3c
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 0x21ad(%rip), %xmm1     # 0x5010
movdqa 0x21b5(%rip), %xmm2     # 0x5020
xorl %ecx, %ecx
movdqa 0x21bb(%rip), %xmm3     # 0x5030
pxor %xmm3, %xmm0
pcmpeqd %xmm4, %xmm4
movdqa 0x21bb(%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 0x2ec0
movl $0x2d, (%rbx,%rcx)
pxor %xmm4, %xmm6
pextrw $0x4, %xmm6, %edx
testb $0x1, %dl
je 0x2ed6
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 0x2f15
movl $0x2d, 0x8(%rbx,%rcx)
pextrw $0x4, %xmm6, %edx
testb $0x1, %dl
je 0x2f27
movl $0x2d, 0xc(%rbx,%rcx)
paddq %xmm5, %xmm2
paddq %xmm5, %xmm1
addq $0x10, %rcx
cmpq %rcx, %rax
jne 0x2e85
movl $0x0, (%rbx,%r14,4)
movq (%r13), %rdi
movl $0x200, %esi            # imm = 0x200
xorl %edx, %edx
callq 0x22d0
movq (%r13), %rdi
movl %r12d, %esi
xorl %edx, %edx
callq 0x2160
cmpl $-0x1, %eax
je 0x2f78
movq (%r13), %rdi
movq %rbx, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x22a0
movq (%r13), %rdi
movl $0x100, %esi            # imm = 0x100
xorl %edx, %edx
callq 0x22d0
movslq 0x20(%r15), %rax
cmpl %eax, 0x8(%r15)
jl 0x305f
movq 0x10(%r15), %rcx
movq (%rcx,%rax,8), %rax
movq 0x8(%rax), %r15
testq %r15, %r15
je 0x305f
movq 0x20(%r15), %rcx
movl 0x50(%r15), %r8d
movq 0x78(%r15), %r9
leaq 0x344e(%rip), %rdx      # 0x640c
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x2280
movq (%r13), %rdi
leal 0x1(%r12), %esi
xorl %edx, %edx
callq 0x2160
cmpl $-0x1, %eax
je 0x2ff1
movq (%r13), %rdi
movq %rbx, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x22a0
leaq 0x3460(%rip), %rdx      # 0x6458
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x2280
movq (%r13), %rdi
leal 0x2(%r12), %esi
xorl %edx, %edx
callq 0x2160
cmpl $-0x1, %eax
je 0x302b
movq (%r13), %rdi
movq %rbx, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x22a0
movq (%r13), %rdi
addl $0x3, %r12d
movl %r12d, %esi
xorl %edx, %edx
callq 0x2160
cmpl $-0x1, %eax
je 0x305f
movq (%r13), %rdi
movslq 0x84(%r15), %rsi
shlq $0x2, %rsi
addq 0x48(%r15), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x22a0
movq %rbx, %rdi
callq 0x2220
movq (%r13), %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2210
retq