// File: /workspace/github_c_makefile_star2_O2/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 0x2732(%rip), %r12      # 0x3fd0
movq (%r12), %rdi
testq %rdi, %rdi
je 0x18b6
movswl 0x4(%rdi), %eax
movl %eax, (%rsp)
movswl 0x6(%rdi), %ebx
incl %ebx
jmp 0x18bf
pushq $-0x1
popq %rbx
pushq $-0x2
popq %rax
movl %eax, (%rsp)
callq 0x1030
xorl %r14d, %r14d
leaq 0x2942(%rip), %r13      # 0x4210
xorl %r15d, %r15d
cmpq $0xff, %r14
je 0x1911
cmpl $-0x1, (%r13)
je 0x1908
movq (%r12), %rdi
xorl %esi, %esi
movl %r15d, %edx
callq 0x1140
cmpl $-0x1, %eax
je 0x1900
movq (%r12), %rdi
movl %r14d, %esi
callq 0x1160
cmpl %ebx, %r15d
jge 0x1911
incl %r15d
incq %r14
addq $0x4, %r13
jmp 0x18d1
xorl %r14d, %r14d
testl %ebx, %ebx
movl $0x0, %r13d
cmovgl %ebx, %r13d
pushq $0x1
popq %r15
leaq 0x27e5(%rip), %rbp      # 0x4110
cmpq $0xff, %r14
je 0x1960
movq (%r12), %rdi
movl %r15d, %esi
movl %r14d, %edx
callq 0x1140
cmpl $-0x1, %eax
je 0x1956
movq (%r12), %rdi
movzbl (%r14,%rbp), %esi
callq 0x1160
cmpq %r14, %r13
je 0x1960
incq %r14
jmp 0x192b
movq (%r12), %rdi
pushq $0x2
popq %rsi
xorl %edx, %edx
callq 0x1140
cmpl $-0x1, %eax
je 0x198b
movq (%r12), %rdi
movq 0x264a(%rip), %rax      # 0x3fc8
movl 0x1c4(%rax), %esi
movl %ebx, %edx
callq 0x1180
movl %ebx, 0x4(%rsp)
movl 0x2772(%rip), %r15d     # 0x4108
movq (%r12), %rdi
pushq $0x3
popq %rsi
xorl %r13d, %r13d
xorl %edx, %edx
callq 0x1140
leaq 0x2c62(%rip), %rbp      # 0x4610
cmpq $0x10000, %r13          # imm = 0x10000
je 0x1a2e
movb (%r13,%rbp), %bl
testb %bl, %bl
je 0x1a2e
testl %r15d, %r15d
jle 0x19d2
xorl %eax, %eax
cmpb $0xa, %bl
sete %al
subl %eax, %r15d
jmp 0x1a29
movzbl %bl, %edi
callq 0x1a84
movl %eax, %r14d
movq (%r12), %rdi
cmpb %bl, %al
je 0x19f5
movl $0x40000, %esi          # imm = 0x40000
xorl %edx, %edx
callq 0x10f0
movq (%r12), %rdi
movzbl %r14b, %esi
callq 0x1160
cmpb (%r13,%rbp), %r14b
je 0x1a15
movq (%r12), %rdi
movl $0x40000, %esi          # imm = 0x40000
xorl %edx, %edx
callq 0x1190
movq (%r12), %rcx
pushq $-0x1
popq %rax
testq %rcx, %rcx
je 0x1a24
movswl (%rcx), %eax
cmpl (%rsp), %eax
jge 0x1a2e
incq %r13
jmp 0x19ae
movq (%r12), %rdi
movl (%rsp), %esi
xorl %edx, %edx
callq 0x1140
cmpl $-0x1, %eax
je 0x1a5b
movq (%r12), %rdi
movq 0x257c(%rip), %rax      # 0x3fc8
movl 0x1c4(%rax), %esi
movl 0x4(%rsp), %edx
callq 0x1180
movq (%r12), %rdi
movl 0x269b(%rip), %edx      # 0x4100
pushq $0x1
popq %rsi
callq 0x1140
movq (%r12), %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10b0