// File: /workspace/github_c_makefile_star2_O1/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, %r14
callq 0x1a9d
movl %eax, %r15d
movq 0x24d9(%rip), %r13      # 0x3fd8
movq (%r13), %rdi
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rdi, %rdi
je 0x1b18
movswl 0x4(%rdi), %ebp
incl %ebp
testq %rdi, %rdi
je 0x1b23
movswl 0x6(%rdi), %ebx
incl %ebx
callq 0x1030
testl %ebp, %ebp
jle 0x1b67
xorl %r12d, %r12d
movl 0x25fb(%rip), %eax      # 0x4130
leal (%r12,%rax), %ecx
cmpl %r15d, %ecx
jge 0x1b67
movl 0x25e8(%rip), %edx      # 0x412c
subl %eax, %edx
xorl %ecx, %ecx
cmpl %edx, %r12d
sete %cl
leal (%r12,%rax), %edx
incl %edx
movq %r14, %rdi
movl %r12d, %esi
callq 0x1c5f
incl %r12d
cmpl %r12d, %ebp
jne 0x1b2f
cvtsi2sd %r15d, %xmm2
movl %ebp, %r12d
cmpl %ebp, %r15d
jle 0x1b89
cvtsi2sd %ebp, %xmm0
movapd %xmm2, %xmm1
divsd %xmm0, %xmm1
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %r12d
movsd %xmm2, 0x10(%rsp)
xorps %xmm0, %xmm0
cvtsi2sdl 0x2592(%rip), %xmm0 # 0x412c
movsd %xmm0, 0x8(%rsp)
movq (%r13), %rdi
movl $0x40000, %esi          # imm = 0x40000
xorl %edx, %edx
callq 0x1140
testl %r12d, %r12d
js 0x1c07
movsd 0x8(%rsp), %xmm1
divsd 0x10(%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 0x1bff
movq (%r13), %rdi
movl $0x20, %esi
callq 0x11f0
incl %r14d
decl %r12d
jne 0x1bdd
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 0x1c37
movq (%r13), %rdi
xorl %esi, %esi
movl %ebp, %edx
callq 0x11c0
movq (%r13), %rdi
movl 0x24eb(%rip), %esi      # 0x412c
subl 0x24e9(%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