// File: /workspace/github_c_makefile_star2_O1/nilesr[P]dotter/./stb/stb_image_write.h
// Function: stbi_write_tga_core
static int stbi_write_tga_core(stbi__write_context *s, int x, int y, int comp, void *data)
{
   int has_alpha = (comp == 2 || comp == 4);
   int colorbytes = has_alpha ? comp-1 : comp;
   int format = colorbytes < 2 ? 3 : 2; // 3 color channels (RGB/RGBA) = 2, 1 color channel (Y/YA) = 3

   if (y < 0 || x < 0)
      return 0;

   if (!stbi_write_tga_with_rle) {
      return stbiw__outfile(s, -1, -1, x, y, comp, 0, (void *) data, has_alpha, 0,
         "111 221 2222 11", 0, 0, format, 0, 0, 0, 0, 0, x, y, (colorbytes + has_alpha) * 8, has_alpha * 8);
   } else {
      int i,j,k;

      stbiw__writef(s, "111 221 2222 11", 0,0,format+8, 0,0,0, 0,0,x,y, (colorbytes + has_alpha) * 8, has_alpha * 8);

      for (j = y - 1; j >= 0; --j) {
          unsigned char *row = (unsigned char *) data + j * x * comp;
         int len;

         for (i = 0; i < x; i += len) {
            unsigned char *begin = row + i * comp;
            int diff = 1;
            len = 1;

            if (i < x - 1) {
               ++len;
               diff = memcmp(begin, row + (i + 1) * comp, comp);
               if (diff) {
                  const unsigned char *prev = begin;
                  for (k = i + 2; k < x && len < 128; ++k) {
                     if (memcmp(prev, row + k * comp, comp)) {
                        prev += comp;
                        ++len;
                     } else {
                        --len;
                        break;
                     }
                  }
               } else {
                  for (k = i + 2; k < x && len < 128; ++k) {
                     if (!memcmp(begin, row + k * comp, comp)) {
                        ++len;
                     } else {
                        break;
                     }
                  }
               }
            }

            if (diff) {
               unsigned char header = STBIW_UCHAR(len - 1);
               s->func(s->context, &header, 1);
               for (k = 0; k < len; ++k) {
                  stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin + k * comp);
               }
            } else {
               unsigned char header = STBIW_UCHAR(len - 129);
               s->func(s->context, &header, 1);
               stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin);
            }
         }
      }
   }
   return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %r8, 0x48(%rsp)
leal -0x2(%rcx), %eax
xorl %ebp, %ebp
testl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
sete %bpl
movq %rcx, 0x30(%rsp)
movl %ecx, %r10d
subl %ebp, %r10d
xorl %r14d, %r14d
cmpl $0x2, %r10d
setl %al
movl %edx, %ecx
orl %esi, %ecx
js 0x1758
movl %edx, %r12d
movq %rdi, %r15
movq %rsi, 0x10(%rsp)
movb %al, %r14b
orl $0x2, %r14d
cmpl $0x0, 0xdc7a(%rip)      # 0xf0f0
je 0x1763
orl $0x8, %r14d
addl %ebp, %r10d
shll $0x3, %r10d
leal (,%rbp,8), %r11d
xorl %ebx, %ebx
movq %r15, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
movl %r14d, %r8d
xorl %r9d, %r9d
xorl %eax, %eax
pushq %r11
pushq %r10
pushq %r12
movq 0x28(%rsp), %r14
pushq %r14
pushq %rbx
pushq %rbx
pushq %rbx
pushq %rbx
callq 0x584c
addq $0x40, %rsp
testl %r12d, %r12d
jle 0x1751
movq %r15, 0x58(%rsp)
movq 0x30(%rsp), %r13
movl %r13d, %ecx
imull %r14d, %ecx
leal -0x1(%r14), %r8d
movslq %r13d, %rdx
movslq %r14d, %rsi
movq %rsi, 0x68(%rsp)
movl %r12d, %esi
movq %rsi, 0x38(%rsp)
decl %r12d
movl %ecx, 0x2c(%rsp)
imull %ecx, %r12d
movq %rbp, 0x20(%rsp)
movq %r14, %rbx
movq %rdx, 0x18(%rsp)
movl %r8d, 0x8(%rsp)
movq 0x38(%rsp), %rax
movq %rax, 0x70(%rsp)
decq %rax
movq %rax, 0x38(%rsp)
movslq %r12d, %r12
movq %r12, 0x50(%rsp)
testl %ebx, %ebx
jle 0x173b
movl 0x2c(%rsp), %eax
imull 0x38(%rsp), %eax
movslq %eax, %rdi
movq 0x48(%rsp), %rax
addq %rax, %rdi
movq 0x50(%rsp), %rcx
addq %rcx, %rax
movq %rax, 0x40(%rsp)
xorl %r14d, %r14d
movq %rdi, 0x78(%rsp)
movl %r14d, %eax
imull %r13d, %eax
movslq %eax, %r12
leaq (%rdi,%r12), %r15
cmpl %r8d, %r14d
movq %r14, 0x80(%rsp)
jge 0x15e9
leal 0x1(%r14), %eax
imull %r13d, %eax
movslq %eax, %rsi
addq %rdi, %rsi
movq %r15, %rdi
callq 0x1110
leal 0x2(%r14), %ecx
testl %eax, %eax
je 0x15f4
cmpl %ebx, %ecx
jge 0x165b
movslq %ecx, %rbp
movq 0x18(%rsp), %rdx
movq %rdx, %rbx
imulq %rbp, %rbx
addq 0x40(%rsp), %rbx
incq %rbp
movl $0x1, %r13d
movq %r15, %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1110
testl %eax, %eax
je 0x15e4
incl %r13d
cmpq 0x68(%rsp), %rbp
movq 0x18(%rsp), %rdx
jge 0x15e1
addq %rdx, %r14
addq %rdx, %rbx
incq %rbp
cmpl $0x7f, %r13d
jb 0x15b4
incl %r13d
xorl %r14d, %r14d
jmp 0x164f
movl $0x1, %r13d
xorl %r14d, %r14d
jmp 0x1669
movb $0x1, %r14b
movl $0x2, %r13d
cmpl %ebx, %ecx
jge 0x1664
movslq %ecx, %rbp
movq 0x18(%rsp), %rdx
movq %rdx, %rbx
imulq %rbp, %rbx
addq 0x40(%rsp), %rbx
incq %rbp
movl $0x2, %r13d
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1110
testl %eax, %eax
jne 0x164f
leal 0x1(%r13), %eax
cmpq 0x68(%rsp), %rbp
jge 0x164c
movq 0x18(%rsp), %rdx
addq %rdx, %rbx
incq %rbp
cmpl $0x7f, %r13d
movl %eax, %r13d
jb 0x161e
movl %eax, %r13d
movq 0x20(%rsp), %rbp
movq 0x10(%rsp), %rbx
jmp 0x1664
movl $0x2, %r13d
xorl %r14d, %r14d
movl 0x8(%rsp), %r8d
testb %r14b, %r14b
je 0x16b6
leal 0x7f(%r13), %eax
movb %al, 0xe(%rsp)
movq 0x58(%rsp), %r14
movq 0x8(%r14), %rdi
leaq 0xe(%rsp), %rsi
movl $0x1, %edx
movl %r8d, %r12d
callq *(%r14)
movq %r14, %rdi
movq 0x30(%rsp), %r14
movl %r14d, %esi
movl %ebp, %edx
xorl %ecx, %ecx
movq %r15, %r8
callq 0x573c
movq %r13, %rax
movq %r14, %r13
movl %r12d, %r8d
movq 0x18(%rsp), %rdx
jmp 0x1724
leal -0x1(%r13), %eax
movb %al, 0xf(%rsp)
movq %rbp, %r15
movq 0x58(%rsp), %rbp
movq 0x8(%rbp), %rdi
leaq 0xf(%rsp), %rsi
movl $0x1, %edx
callq *(%rbp)
movq %r13, 0x60(%rsp)
testl %r13d, %r13d
movq 0x30(%rsp), %r13
movq 0x18(%rsp), %r14
jle 0x170f
movl 0x60(%rsp), %ebx
addq 0x40(%rsp), %r12
movq %rbp, %rdi
movl %r13d, %esi
movl %r15d, %edx
xorl %ecx, %ecx
movq %r12, %r8
callq 0x573c
addq %r14, %r12
decq %rbx
jne 0x16f4
movq 0x10(%rsp), %rbx
movq %r15, %rbp
movl 0x8(%rsp), %r8d
movq %r14, %rdx
movq 0x60(%rsp), %rax
addl 0x80(%rsp), %eax
movl %eax, %r14d
cmpl %ebx, %eax
movq 0x78(%rsp), %rdi
jl 0x1553
movq 0x50(%rsp), %r12
subl 0x2c(%rsp), %r12d
cmpq $0x2, 0x70(%rsp)
jge 0x1508
movl $0x1, %eax
jmp 0x175a
xorl %eax, %eax
addq $0x88, %rsp
jmp 0x17b7
addl %ebp, %r10d
shll $0x3, %r10d
leal (,%rbp,8), %ebx
subq $0x8, %rsp
xorl %edx, %edx
leaq 0x9aee(%rip), %r11      # 0xb26c
movq %r15, %rdi
movq 0x18(%rsp), %rcx
movl %r12d, %r8d
movq 0x38(%rsp), %r9
xorl %eax, %eax
pushq %rbx
pushq %r10
pushq %r12
pushq %rcx
pushq %rdx
pushq %rdx
pushq %rdx
pushq %rdx
pushq %rdx
pushq %r14
pushq %rdx
pushq %rdx
pushq %r11
pushq %rdx
pushq %rbp
pushq 0xc8(%rsp)
pushq %rdx
callq 0x5494
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq