// File: /workspace/github_c_makefile_star2_O0/ggerganov[P]font-rasterizer/./stb_image_write.h
// Function: stbiw__write_pixel
static void stbiw__write_pixel(stbi__write_context *s, int rgb_dir, int comp, int write_alpha, int expand_mono, unsigned char *d)
{
   unsigned char bg[3] = { 255, 0, 255}, px[3];
   int k;

   if (write_alpha < 0)
      s->func(s->context, &d[comp - 1], 1);

   switch (comp) {
      case 2: // 2 pixels = mono + alpha, alpha is written separately, so same as 1-channel case
      case 1:
         if (expand_mono)
            stbiw__write3(s, d[0], d[0], d[0]); // monochrome bmp
         else
            s->func(s->context, d, 1);  // monochrome TGA
         break;
      case 4:
         if (!write_alpha) {
            // composite against pink background
            for (k = 0; k < 3; ++k)
               px[k] = bg[k] + ((d[k] - bg[k]) * d[3]) / 255;
            stbiw__write3(s, px[1 - rgb_dir], px[1], px[1 + rgb_dir]);
            break;
         }
         /* FALLTHROUGH */
      case 3:
         stbiw__write3(s, d[1 - rgb_dir], d[1], d[1 + rgb_dir]);
         break;
   }
   if (write_alpha > 0)
      s->func(s->context, &d[comp - 1], 1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movl %r8d, -0x18(%rbp)
movq %r9, -0x20(%rbp)
movw 0x7820(%rip), %ax       # 0x15164
movw %ax, -0x23(%rbp)
movb 0x7818(%rip), %al       # 0x15166
movb %al, -0x21(%rbp)
cmpl $0x0, -0x14(%rbp)
jge 0xd97d
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x8(%rcx), %rdi
movq -0x20(%rbp), %rsi
movl -0x10(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
addq %rcx, %rsi
movl $0x1, %edx
callq *%rax
movl -0x10(%rbp), %eax
movl %eax, -0x30(%rbp)
decl %eax
subl $0x2, %eax
jb 0xd9a7
jmp 0xd98c
movl -0x30(%rbp), %eax
subl $0x3, %eax
je 0xda8a
jmp 0xd99a
movl -0x30(%rbp), %eax
subl $0x4, %eax
je 0xd9f0
jmp 0xdac5
cmpl $0x0, -0x18(%rbp)
je 0xd9d1
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rax
movb (%rax), %dl
movq -0x20(%rbp), %rax
movb (%rax), %cl
movq -0x20(%rbp), %rax
movzbl %dl, %esi
movzbl %cl, %edx
movzbl (%rax), %ecx
callq 0xdb00
jmp 0xd9eb
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x8(%rcx), %rdi
movq -0x20(%rbp), %rsi
movl $0x1, %edx
callq *%rax
jmp 0xdac5
cmpl $0x0, -0x14(%rbp)
jne 0xda88
movl $0x0, -0x2c(%rbp)
cmpl $0x3, -0x2c(%rbp)
jge 0xda59
movslq -0x2c(%rbp), %rax
movzbl -0x23(%rbp,%rax), %eax
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movslq -0x2c(%rbp), %rcx
movzbl -0x23(%rbp,%rcx), %ecx
subl %ecx, %eax
movq -0x20(%rbp), %rcx
movzbl 0x3(%rcx), %ecx
imull %ecx, %eax
movl $0xff, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x34(%rbp), %eax
addl %ecx, %eax
movb %al, %cl
movslq -0x2c(%rbp), %rax
movb %cl, -0x26(%rbp,%rax)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xda01
movq -0x8(%rbp), %rdi
movl $0x1, %eax
subl -0xc(%rbp), %eax
cltq
movb -0x26(%rbp,%rax), %dl
movb -0x25(%rbp), %cl
movl -0xc(%rbp), %eax
addl $0x1, %eax
cltq
movzbl %dl, %esi
movzbl %cl, %edx
movzbl -0x26(%rbp,%rax), %ecx
callq 0xdb00
jmp 0xdac5
jmp 0xda8a
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rax
movl $0x1, %ecx
subl -0xc(%rbp), %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %sil
movq -0x20(%rbp), %rax
movb 0x1(%rax), %dl
movq -0x20(%rbp), %rax
movl -0xc(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movzbl %sil, %esi
movzbl %dl, %edx
movzbl (%rax,%rcx), %ecx
callq 0xdb00
cmpl $0x0, -0x14(%rbp)
jle 0xdaf1
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x8(%rcx), %rdi
movq -0x20(%rbp), %rsi
movl -0x10(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
addq %rcx, %rsi
movl $0x1, %edx
callq *%rax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)