// File: /workspace/github_c_makefile_star2_O3/kobolt[P]curses-collection/fileselect/fileselect.c
// Function: curses_update_screen
static void curses_update_screen(file_node_t *node)
{
  int n, i, maxy, maxx;
  int scrollbar_size, scrollbar_pos;
  int list_size;
  
  list_size = file_node_list_size(node);
  
  getmaxyx(stdscr, maxy, maxx);
  erase();
  
  /* Draw text lines. */
  for (n = 0; n < maxy; n++) { 
    if ((n + curses_scroll_offset) >= list_size)
      break;
    
    if (n == (curses_selected_entry - curses_scroll_offset)) {
      curses_list_draw(node, n, n + curses_scroll_offset + 1, 1);
    } else {
      curses_list_draw(node, n, n + curses_scroll_offset + 1, 0);
    }
  }
  
  /* Draw scrollbar. */
  if (list_size <= maxy)
    scrollbar_size = maxy;
  else
    scrollbar_size = maxy / (list_size / (double)maxy);
  
  scrollbar_pos = curses_selected_entry / (double)list_size * (maxy - scrollbar_size);
  attron(A_REVERSE);
  for (i = 0; i <= scrollbar_size; i++)
    mvaddch(i + scrollbar_pos, maxx - 1, ' ');
  attroff(A_REVERSE);
  
  mvvline(0, maxx - 2, 0, maxy);
  
  /* Place cursor at end of selected line. */ 
  move(curses_selected_entry - curses_scroll_offset, maxx - 3);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r15
callq 0x1a98
movl %eax, %r14d
movq 0x24de(%rip), %r13      # 0x3fd8
movq (%r13), %rdi
testq %rdi, %rdi
je 0x1b5a
movswl 0x4(%rdi), %r12d
leal 0x1(%r12), %ebp
movswl 0x6(%rdi), %ebx
incl %ebx
callq 0x1030
testl %r12d, %r12d
js 0x1b69
xorl %r12d, %r12d
movl 0x260a(%rip), %eax      # 0x4130
leal (%r12,%rax), %ecx
cmpl %r14d, %ecx
jge 0x1b69
movl 0x25f7(%rip), %edx      # 0x412c
subl %eax, %edx
xorl %ecx, %ecx
cmpl %edx, %r12d
sete %cl
leal (%r12,%rax), %edx
incl %edx
movq %r15, %rdi
movl %r12d, %esi
callq 0x1c6a
incl %r12d
cmpl %r12d, %ebp
jne 0x1b20
jmp 0x1b69
callq 0x1030
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpl %ebp, %r14d
jle 0x1b8c
cvtsi2sd %ebp, %xmm0
cvtsi2sd %r14d, %xmm1
movsd %xmm1, 0x8(%rsp)
divsd %xmm0, %xmm1
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %r12d
jmp 0x1b9a
cvtsi2sd %r14d, %xmm0
movsd %xmm0, 0x8(%rsp)
movl %ebp, %r12d
xorps %xmm0, %xmm0
cvtsi2sdl 0x2587(%rip), %xmm0 # 0x412c
movsd %xmm0, 0x10(%rsp)
movq (%r13), %rdi
movl $0x40000, %esi          # imm = 0x40000
xorl %edx, %edx
callq 0x1140
testl %r12d, %r12d
js 0x1c12
movsd 0x10(%rsp), %xmm1
divsd 0x8(%rsp), %xmm1
movl %ebp, %eax
subl %r12d, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %r14d
leal -0x1(%rbx), %r15d
incl %r12d
movq (%r13), %rdi
movl %r14d, %esi
movl %r15d, %edx
callq 0x11d0
cmpl $-0x1, %eax
je 0x1c0a
movq (%r13), %rdi
movl $0x20, %esi
callq 0x11f0
incl %r14d
decl %r12d
jne 0x1be8
movq (%r13), %rdi
movl $0x40000, %esi          # imm = 0x40000
xorl %edx, %edx
callq 0x1220
movq (%r13), %rdi
leal -0x2(%rbx), %edx
xorl %esi, %esi
callq 0x11d0
cmpl $-0x1, %eax
je 0x1c42
movq (%r13), %rdi
xorl %esi, %esi
movl %ebp, %edx
callq 0x11c0
movq (%r13), %rdi
movl 0x24e0(%rip), %esi      # 0x412c
subl 0x24de(%rip), %esi      # 0x4130
addl $-0x3, %ebx
movl %ebx, %edx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x11d0