// File: /workspace/github_c_makefile_star2_O0/Cotix[P]cReddit/src/main.c
// Function: showThread
void showThread(RedditLink *link)
{
    CommentScreen *screen = NULL;
    RedditCommentList *list = NULL;
    RedditErrno err;

    if (link == NULL)
        return ;

    list = redditCommentListNew();
    list->permalink = redditCopyString(link->permalink);

    err = redditGetCommentList(list);
    if (err != REDDIT_SUCCESS || list->baseComment->replyCount == 0)
        goto cleanup;

    /*screen = getCommentScreenFromCommentList(list, COLS); */
    screen = commentScreenNew();

    screen->offset = 0;
    screen->selected = 0;
    screen->displayed = LINES - 1;
    screen->commentOpenSize = (screen->displayed / 5) * 4;
    screen->list = list;
    screen->width = COLS;

    commentScreenRenderLines(screen);
    commentScreenDisplay(screen);
    int c;
    while((c = wgetch(stdscr))) {
        switch(c) {
            case 'j': case KEY_DOWN:
                commentScreenDown(screen);
                break;
            case 'k': case KEY_UP:
                commentScreenUp(screen);
                break;
                
            case KEY_NPAGE:
                commentScreenLevelDown(screen);
                break;
            case KEY_PPAGE:
                commentScreenLevelUp(screen);
                break;

            case 'J':
                commentScreenCommentScrollDown(screen);
                break;
            case 'K':
                commentScreenCommentScrollUp(screen);
                break;

            case 'l': case '\n': case KEY_ENTER:
                commentScreenToggleComment(screen);
                break;
            case 'm':
                redditGetCommentChildren(screen->list, screen->lines[screen->selected]->comment);
                commentScreenRenderLines(screen);
                break;

            case 'q': case 'h':
                if (screen->commentOpen) {
                    commentScreenCloseComment(screen);
                } else {
                    goto cleanup;
                }
                break;
        }
        commentScreenDisplay(screen);
    }

cleanup:;
    redditCommentListFree(list);
    commentScreenFree(screen);
    return ;
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x20(%rsp)
movq $0x0, 0x18(%rsp)
movq $0x0, 0x10(%rsp)
cmpq $0x0, 0x20(%rsp)
jne 0x3768
jmp 0x39fc
movb $0x0, %al
callq 0x22d0
movq %rax, 0x10(%rsp)
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x2060
movq %rax, %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x10(%rsp), %rdi
callq 0x2310
movl %eax, 0xc(%rsp)
cmpl $0x0, 0xc(%rsp)
jne 0x37b0
movq 0x10(%rsp), %rax
movq (%rax), %rax
cmpl $0x0, (%rax)
jne 0x37b5
jmp 0x39e8
callq 0x2840
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
movl $0x0, 0x1c(%rax)
movq 0x18(%rsp), %rax
movl $0x0, 0x20(%rax)
movq 0x67e2(%rip), %rax      # 0x9fc0
movl (%rax), %ecx
subl $0x1, %ecx
movq 0x18(%rsp), %rax
movl %ecx, 0x18(%rax)
movq 0x18(%rsp), %rax
movl 0x18(%rax), %eax
movl $0x5, %ecx
cltd
idivl %ecx
movl %eax, %ecx
shll $0x2, %ecx
movq 0x18(%rsp), %rax
movl %ecx, 0x28(%rax)
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %rax
movq %rcx, (%rax)
movq 0x67ac(%rip), %rax      # 0x9fc8
movl (%rax), %ecx
movq 0x18(%rsp), %rax
movl %ecx, 0x24(%rax)
movq 0x18(%rsp), %rdi
callq 0x2c60
movq 0x18(%rsp), %rdi
callq 0x3160
movq 0x679f(%rip), %rax      # 0x9fe0
movq (%rax), %rdi
callq 0x2240
movl %eax, 0x8(%rsp)
cmpl $0x0, %eax
je 0x39e6
movl 0x8(%rsp), %eax
movl %eax, 0x4(%rsp)
subl $0xa, %eax
je 0x3976
jmp 0x3869
movl 0x4(%rsp), %eax
subl $0x4a, %eax
je 0x395e
jmp 0x3878
movl 0x4(%rsp), %eax
subl $0x4b, %eax
je 0x396a
jmp 0x3887
movl 0x4(%rsp), %eax
subl $0x68, %eax
je 0x39b5
jmp 0x3896
movl 0x4(%rsp), %eax
subl $0x6a, %eax
je 0x3925
jmp 0x38a5
movl 0x4(%rsp), %eax
subl $0x6b, %eax
je 0x3934
jmp 0x38b4
movl 0x4(%rsp), %eax
subl $0x6c, %eax
je 0x3976
jmp 0x38c3
movl 0x4(%rsp), %eax
subl $0x6d, %eax
je 0x3982
jmp 0x38d2
movl 0x4(%rsp), %eax
subl $0x71, %eax
je 0x39b5
jmp 0x38e1
movl 0x4(%rsp), %eax
subl $0x102, %eax            # imm = 0x102
je 0x3925
jmp 0x38ee
movl 0x4(%rsp), %eax
subl $0x103, %eax            # imm = 0x103
je 0x3934
jmp 0x38fb
movl 0x4(%rsp), %eax
subl $0x152, %eax            # imm = 0x152
je 0x3943
jmp 0x3908
movl 0x4(%rsp), %eax
subl $0x153, %eax            # imm = 0x153
je 0x3952
jmp 0x3915
movl 0x4(%rsp), %eax
subl $0x157, %eax            # imm = 0x157
je 0x3976
jmp 0x39d7
movq 0x18(%rsp), %rdi
callq 0x2d00
jmp 0x39d7
movq 0x18(%rsp), %rdi
callq 0x2f10
jmp 0x39d7
movq 0x18(%rsp), %rdi
callq 0x2da0
jmp 0x39d7
movq 0x18(%rsp), %rdi
callq 0x2e50
jmp 0x39d7
movq 0x18(%rsp), %rdi
callq 0x2f60
jmp 0x39d7
movq 0x18(%rsp), %rdi
callq 0x3040
jmp 0x39d7
movq 0x18(%rsp), %rdi
callq 0x3710
jmp 0x39d7
movq 0x18(%rsp), %rax
movq (%rax), %rdi
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x18(%rsp), %rcx
movslq 0x20(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rsi
callq 0x2080
movq 0x18(%rsp), %rdi
callq 0x2c60
jmp 0x39d7
movq 0x18(%rsp), %rax
movb 0x2c(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
je 0x39d3
movq 0x18(%rsp), %rdi
callq 0x36d0
jmp 0x39d5
jmp 0x39e8
jmp 0x39d7
movq 0x18(%rsp), %rdi
callq 0x3160
jmp 0x383a
jmp 0x39e8
movq 0x10(%rsp), %rdi
callq 0x2040
movq 0x18(%rsp), %rdi
callq 0x2900
addq $0x28, %rsp
retq
nopw %cs:(%rax,%rax)