// File: /workspace/github_c_makefile_star2_O1/neovim[P]libvterm/bin/unterm.c
// Function: dump_cell
static void dump_cell(const VTermScreenCell *cell, const VTermScreenCell *prevcell)
{
  switch(format) {
    case FORMAT_PLAIN:
      break;
    case FORMAT_SGR:
      {
        // If all 7 attributes change, that means 7 SGRs max
        // Each colour could consume up to 5 entries
        int sgr[7 + 2*5]; int sgri = 0;

        if(!prevcell->attrs.bold && cell->attrs.bold)
          sgr[sgri++] = 1;
        if(prevcell->attrs.bold && !cell->attrs.bold)
          sgr[sgri++] = 22;

        if(!prevcell->attrs.underline && cell->attrs.underline)
          sgr[sgri++] = 4;
        if(prevcell->attrs.underline && !cell->attrs.underline)
          sgr[sgri++] = 24;

        if(!prevcell->attrs.italic && cell->attrs.italic)
          sgr[sgri++] = 3;
        if(prevcell->attrs.italic && !cell->attrs.italic)
          sgr[sgri++] = 23;

        if(!prevcell->attrs.blink && cell->attrs.blink)
          sgr[sgri++] = 5;
        if(prevcell->attrs.blink && !cell->attrs.blink)
          sgr[sgri++] = 25;

        if(!prevcell->attrs.reverse && cell->attrs.reverse)
          sgr[sgri++] = 7;
        if(prevcell->attrs.reverse && !cell->attrs.reverse)
          sgr[sgri++] = 27;

        if(!prevcell->attrs.conceal && cell->attrs.conceal)
          sgr[sgri++] = 8;
        if(prevcell->attrs.conceal && !cell->attrs.conceal)
          sgr[sgri++] = 28;

        if(!prevcell->attrs.strike && cell->attrs.strike)
          sgr[sgri++] = 9;
        if(prevcell->attrs.strike && !cell->attrs.strike)
          sgr[sgri++] = 29;

        if(!prevcell->attrs.font && cell->attrs.font)
          sgr[sgri++] = 10 + cell->attrs.font;
        if(prevcell->attrs.font && !cell->attrs.font)
          sgr[sgri++] = 10;

        if(!vterm_color_is_equal(&prevcell->fg, &cell->fg)) {
          sgri = dump_cell_color(&cell->fg, sgri, sgr, 1);
        }

        if(!vterm_color_is_equal(&prevcell->bg, &cell->bg)) {
          sgri = dump_cell_color(&cell->bg, sgri, sgr, 0);
        }

        if(!sgri)
          break;

        printf("\x1b[");
        for(int i = 0; i < sgri; i++)
          printf(!i               ? "%d" :
              CSI_ARG_HAS_MORE(sgr[i]) ? ":%d" :
              ";%d",
              CSI_ARG(sgr[i]));
        printf("m");
      }
      break;
  }

  for(int i = 0; i < VTERM_MAX_CHARS_PER_CELL && cell->chars[i]; i++) {
    char bytes[6];
    bytes[fill_utf8(cell->chars[i], bytes)] = 0;
    printf("%s", bytes);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
cmpb $0x1, 0x2d7f(%rip)      # 0x4154
jne 0x15f7
movq %rsi, %r14
movl 0x1c(%rsi), %eax
xorl %ebp, %ebp
testb $0x1, %al
jne 0x13f9
testb $0x1, 0x1c(%rbx)
je 0x13f9
movl $0x1, (%rsp)
movl $0x1, %ebp
testb $0x1, %al
je 0x140e
testb $0x1, 0x1c(%rbx)
jne 0x140e
movl %ebp, %ecx
incl %ebp
movl $0x16, (%rsp,%rcx,4)
testb $0x6, %al
jne 0x1423
testb $0x6, 0x1c(%rbx)
je 0x1423
movl %ebp, %ecx
incl %ebp
movl $0x4, (%rsp,%rcx,4)
testb $0x6, %al
je 0x1438
testb $0x6, 0x1c(%rbx)
jne 0x1438
movl %ebp, %ecx
incl %ebp
movl $0x18, (%rsp,%rcx,4)
testb $0x8, %al
jne 0x144d
testb $0x8, 0x1c(%rbx)
je 0x144d
movl %ebp, %ecx
incl %ebp
movl $0x3, (%rsp,%rcx,4)
testb $0x8, %al
je 0x1462
testb $0x8, 0x1c(%rbx)
jne 0x1462
movl %ebp, %ecx
incl %ebp
movl $0x17, (%rsp,%rcx,4)
testb $0x10, %al
jne 0x1477
testb $0x10, 0x1c(%rbx)
je 0x1477
movl %ebp, %ecx
incl %ebp
movl $0x5, (%rsp,%rcx,4)
testb $0x10, %al
je 0x148c
testb $0x10, 0x1c(%rbx)
jne 0x148c
movl %ebp, %ecx
incl %ebp
movl $0x19, (%rsp,%rcx,4)
testb $0x20, %al
jne 0x14a1
testb $0x20, 0x1c(%rbx)
je 0x14a1
movl %ebp, %ecx
incl %ebp
movl $0x7, (%rsp,%rcx,4)
testb $0x20, %al
je 0x14b6
testb $0x20, 0x1c(%rbx)
jne 0x14b6
movl %ebp, %ecx
incl %ebp
movl $0x1b, (%rsp,%rcx,4)
testb $0x40, %al
jne 0x14cb
testb $0x40, 0x1c(%rbx)
je 0x14cb
movl %ebp, %ecx
incl %ebp
movl $0x8, (%rsp,%rcx,4)
testb $0x40, %al
je 0x14e0
testb $0x40, 0x1c(%rbx)
jne 0x14e0
movl %ebp, %ecx
incl %ebp
movl $0x1c, (%rsp,%rcx,4)
testb %al, %al
js 0x14f5
testb $-0x80, 0x1c(%rbx)
je 0x14f5
movl %ebp, %ecx
incl %ebp
movl $0x9, (%rsp,%rcx,4)
testb %al, %al
jns 0x150a
testb $-0x80, 0x1c(%rbx)
jne 0x150a
movl %ebp, %ecx
incl %ebp
movl $0x1d, (%rsp,%rcx,4)
testl $0xf00, %eax            # imm = 0xF00
jne 0x1526
movl 0x1c(%rbx), %ecx
shrl $0x8, %ecx
andl $0xf, %ecx
je 0x1526
addl $0xa, %ecx
movl %ebp, %edx
incl %ebp
movl %ecx, (%rsp,%rdx,4)
testl $0xf00, %eax            # imm = 0xF00
je 0x153e
testb $0xf, 0x1d(%rbx)
jne 0x153e
movl %ebp, %eax
incl %ebp
movl $0xa, (%rsp,%rax,4)
leaq 0x20(%r14), %rdi
leaq 0x20(%rbx), %r15
movq %r15, %rsi
callq 0x1080
testl %eax, %eax
jne 0x1566
movq %rsp, %rdx
movq %r15, %rdi
movl %ebp, %esi
movl $0x1, %ecx
callq 0x1902
movl %eax, %ebp
addq $0x24, %r14
leaq 0x24(%rbx), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x1080
testl %eax, %eax
jne 0x158e
movq %rsp, %rdx
movq %r15, %rdi
movl %ebp, %esi
xorl %ecx, %ecx
callq 0x1902
movl %eax, %ebp
testl %ebp, %ebp
je 0x15f7
leaq 0xac3(%rip), %rdi       # 0x205c
xorl %eax, %eax
callq 0x1090
testl %ebp, %ebp
jle 0x15ed
movl %ebp, %r14d
leaq 0xab2(%rip), %r15       # 0x2060
movl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
leaq 0xaa5(%rip), %r13       # 0x205f
xorl %r12d, %r12d
movq %r15, %rdi
testq %r12, %r12
je 0x15d8
cmpl $0x0, (%rsp,%r12,4)
movq %r13, %rdi
leaq 0xa8f(%rip), %rax       # 0x2063
cmovnsq %rax, %rdi
movl (%rsp,%r12,4), %esi
andl %ebp, %esi
xorl %eax, %eax
callq 0x1090
incq %r12
cmpq %r12, %r14
jne 0x15bd
movl $0x6d, %edi
callq 0x1040
leaq 0xa06(%rip), %r12       # 0x2004
leaq 0xa62(%rip), %r14       # 0x2067
movq %rsp, %r15
xorl %r13d, %r13d
movl (%rbx,%r13,4), %eax
testq %rax, %rax
je 0x16c8
movl $0x1, %edx
cmpl $0x80, %eax
jb 0x1655
movl $0x2, %edx
cmpl $0x800, %eax            # imm = 0x800
jb 0x1655
movl $0x3, %edx
cmpl $0x10000, %eax          # imm = 0x10000
jb 0x1655
movl $0x4, %edx
cmpl $0x200000, %eax         # imm = 0x200000
jb 0x1655
cmpl $0x4000000, %eax        # imm = 0x4000000
movl $0x6, %edx
sbbl $0x0, %edx
movl %edx, %ecx
cmpl $0x2, %edx
jb 0x167c
leaq 0x1(%rcx), %rsi
movl %eax, %edi
andb $0x3f, %dil
orb $-0x80, %dil
movb %dil, -0x2(%rsp,%rsi)
shrq $0x6, %rax
decq %rsi
cmpq $0x2, %rsi
jg 0x1660
decl %edx
movslq (%r12,%rdx,4), %rdx
addq %r12, %rdx
jmpq *%rdx
andb $0x7f, %al
jmp 0x16a7
andb $0x3, %al
orb $-0x8, %al
jmp 0x16a7
andb $0xf, %al
orb $-0x20, %al
jmp 0x16a7
andb $0x7, %al
orb $-0x10, %al
jmp 0x16a7
andb $0x1f, %al
orb $-0x40, %al
jmp 0x16a7
andb $0x1, %al
orb $-0x4, %al
movb %al, (%rsp)
movb $0x0, (%rsp,%rcx)
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x1090
incq %r13
cmpq $0x6, %r13
jne 0x160b
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq