// File: /workspace/github_c_makefile_star2_O3/kobolt[P]curses-collection/scca/scca.c
// Function: screen_update
static void screen_update(void)
{
  unsigned char c;
  int i, y, x, maxy, maxx, skip_newline;

  getmaxyx(stdscr, maxy, maxx);
  erase();

  /* Alphabet. */
  x = 0;
  for (c = 0; c < UCHAR_MAX; c++) {
    if (allowed_char[c] != -1) {
      mvaddch(0, x, c);
      x++;
      if (x > maxx)
        break;
    }
  }

  /* Cipher */
  x = 0;
  for (c = 0; c < UCHAR_MAX; c++) {
    mvaddch(1, x, cipher[c]);
    x++;
    if (x > maxx)
      break;
  }

  /* Upper Separation Line */
  mvhline(2, 0, ACS_HLINE, maxx);

  /* Text */
  skip_newline = text_offset;
  move(3, 0);
  for (i = 0; i < TEXT_MAX; i++) {
    if (text[i] == '\0')
      break;

    if (skip_newline > 0) {
      if (text[i] == '\n') {
        skip_newline--;
      }
      continue;
    }

    c = cipher_applied(text[i]);
    if (c != text[i]) {
      attron(A_REVERSE);
    }
    addch(c);
    if (c != text[i]) {
      attroff(A_REVERSE);
    }

    getyx(stdscr, y, x);
    if (y >= (maxy - 1)) {
      break;
    }
  }

  /* Lower Separation Line */
  mvhline(maxy - 1, 0, ACS_HLINE, maxx);

  move(1, cipher_pos);
  refresh();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0x26db(%rip), %r12      # 0x3fd0
movq (%r12), %rdi
testq %rdi, %rdi
je 0x190d
movswl 0x4(%rdi), %eax
movl %eax, (%rsp)
movswl 0x6(%rdi), %ebx
incl %ebx
jmp 0x1919
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl $0xfffffffe, (%rsp)     # imm = 0xFFFFFFFE
callq 0x1030
xorl %r14d, %r14d
leaq 0x28e8(%rip), %r13      # 0x4210
xorl %r15d, %r15d
cmpl $-0x1, (%r13)
je 0x1959
movq (%r12), %rdi
xorl %esi, %esi
movl %r15d, %edx
callq 0x1150
cmpl $-0x1, %eax
je 0x1951
movq (%r12), %rdi
movl %r14d, %esi
callq 0x1170
cmpl %ebx, %r15d
jge 0x1969
incl %r15d
incq %r14
addq $0x4, %r13
cmpq $0xff, %r14
jne 0x192b
xorl %r14d, %r14d
testl %ebx, %ebx
movl $0x0, %r15d
cmovgl %ebx, %r15d
leaq 0x2791(%rip), %r13      # 0x4110
movq (%r12), %rdi
movl $0x1, %esi
movl %r14d, %edx
callq 0x1150
cmpl $-0x1, %eax
je 0x19a3
movq (%r12), %rdi
movzbl (%r14,%r13), %esi
callq 0x1170
cmpq %r14, %r15
je 0x19b4
incq %r14
cmpq $0xff, %r14
jne 0x197f
movq (%r12), %rdi
movl $0x2, %esi
xorl %edx, %edx
callq 0x1150
cmpl $-0x1, %eax
je 0x19e1
movq (%r12), %rdi
movq 0x25f4(%rip), %rax      # 0x3fc8
movl 0x1c4(%rax), %esi
movl %ebx, %edx
callq 0x1190
movl %ebx, 0x4(%rsp)
movl 0x271c(%rip), %r15d     # 0x4108
movq (%r12), %rdi
xorl %r13d, %r13d
movl $0x3, %esi
xorl %edx, %edx
callq 0x1150
leaq 0x2c0a(%rip), %rbp      # 0x4610
movb (%r13,%rbp), %bl
testb %bl, %bl
je 0x1a8c
testl %r15d, %r15d
jle 0x1a21
xorl %eax, %eax
cmpb $0xa, %bl
sete %al
subl %eax, %r15d
jmp 0x1a7c
movzbl %bl, %edi
callq 0x1ae4
movl %eax, %r14d
movq (%r12), %rdi
cmpb %bl, %al
je 0x1a44
movl $0x40000, %esi          # imm = 0x40000
xorl %edx, %edx
callq 0x1100
movq (%r12), %rdi
movzbl %r14b, %esi
callq 0x1170
cmpb (%r13,%rbp), %r14b
je 0x1a64
movq (%r12), %rdi
movl $0x40000, %esi          # imm = 0x40000
xorl %edx, %edx
callq 0x11a0
movq (%r12), %rax
testq %rax, %rax
je 0x1a72
movswl (%rax), %eax
jmp 0x1a77
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl (%rsp), %eax
jge 0x1a8c
incq %r13
cmpq $0x10000, %r13          # imm = 0x10000
jne 0x1a06
movq (%r12), %rdi
movl (%rsp), %esi
xorl %edx, %edx
callq 0x1150
cmpl $-0x1, %eax
je 0x1ab9
movq (%r12), %rdi
movq 0x251e(%rip), %rax      # 0x3fc8
movl 0x1c4(%rax), %esi
movl 0x4(%rsp), %edx
callq 0x1190
movq (%r12), %rdi
movl 0x263d(%rip), %edx      # 0x4100
movl $0x1, %esi
callq 0x1150
movq (%r12), %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10b0