// File: /workspace/github_c_makefile_star2_O0/ggerganov[P]font-rasterizer/./stb_image_write.h
// Function: stbiw__write_hdr_scanline
static void stbiw__write_hdr_scanline(stbi__write_context *s, int width, int ncomp, unsigned char *scratch, float *scanline)
{
   unsigned char scanlineheader[4] = { 2, 2, 0, 0 };
   unsigned char rgbe[4];
   float linear[3];
   int x;

   scanlineheader[2] = (width&0xff00)>>8;
   scanlineheader[3] = (width&0x00ff);

   /* skip RLE for images too small or large */
   if (width < 8 || width >= 32768) {
      for (x=0; x < width; x++) {
         switch (ncomp) {
            case 4: /* fallthrough */
            case 3: linear[2] = scanline[x*ncomp + 2];
                    linear[1] = scanline[x*ncomp + 1];
                    linear[0] = scanline[x*ncomp + 0];
                    break;
            default:
                    linear[0] = linear[1] = linear[2] = scanline[x*ncomp + 0];
                    break;
         }
         stbiw__linear_to_rgbe(rgbe, linear);
         s->func(s->context, rgbe, 4);
      }
   } else {
      int c,r;
      /* encode into scratch buffer */
      for (x=0; x < width; x++) {
         switch(ncomp) {
            case 4: /* fallthrough */
            case 3: linear[2] = scanline[x*ncomp + 2];
                    linear[1] = scanline[x*ncomp + 1];
                    linear[0] = scanline[x*ncomp + 0];
                    break;
            default:
                    linear[0] = linear[1] = linear[2] = scanline[x*ncomp + 0];
                    break;
         }
         stbiw__linear_to_rgbe(rgbe, linear);
         scratch[x + width*0] = rgbe[0];
         scratch[x + width*1] = rgbe[1];
         scratch[x + width*2] = rgbe[2];
         scratch[x + width*3] = rgbe[3];
      }

      s->func(s->context, scanlineheader, 4);

      /* RLE each component separately */
      for (c=0; c < 4; c++) {
         unsigned char *comp = &scratch[width*c];

         x = 0;
         while (x < width) {
            // find first run
            r = x;
            while (r+2 < width) {
               if (comp[r] == comp[r+1] && comp[r] == comp[r+2])
                  break;
               ++r;
            }
            if (r+2 >= width)
               r = width;
            // dump up to first run
            while (x < r) {
               int len = r-x;
               if (len > 128) len = 128;
               stbiw__write_dump_data(s, len, &comp[x]);
               x += len;
            }
            // if there's a run, output it
            if (r+2 < width) { // same test as what we break out of in search loop, so only true if we break'd
               // find next byte after run
               while (r < width && comp[r] == comp[x])
                  ++r;
               // output run up to r
               while (x < r) {
                  int len = r-x;
                  if (len > 127) len = 127;
                  stbiw__write_run_data(s, len, comp[x]);
                  x += len;
               }
            }
         }
      }
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movl 0x8a3c(%rip), %eax      # 0x1667c
movl %eax, -0x24(%rbp)
movl -0xc(%rbp), %eax
andl $0xff00, %eax           # imm = 0xFF00
sarl $0x8, %eax
movb %al, -0x22(%rbp)
movl -0xc(%rbp), %eax
andl $0xff, %eax
movb %al, -0x21(%rbp)
cmpl $0x8, -0xc(%rbp)
jl 0xdc6f
cmpl $0x8000, -0xc(%rbp)     # imm = 0x8000
jl 0xdd41
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0xdd3c
movl -0x10(%rbp), %eax
addl $-0x3, %eax
subl $0x1, %eax
ja 0xdce2
jmp 0xdc8f
movq -0x20(%rbp), %rax
movl -0x38(%rbp), %ecx
imull -0x10(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movss (%rax,%rcx,4), %xmm0
movss %xmm0, -0x2c(%rbp)
movq -0x20(%rbp), %rax
movl -0x38(%rbp), %ecx
imull -0x10(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movss (%rax,%rcx,4), %xmm0
movss %xmm0, -0x30(%rbp)
movq -0x20(%rbp), %rax
movl -0x38(%rbp), %ecx
imull -0x10(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movss (%rax,%rcx,4), %xmm0
movss %xmm0, -0x34(%rbp)
jmp 0xdd07
movq -0x20(%rbp), %rax
movl -0x38(%rbp), %ecx
imull -0x10(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movss (%rax,%rcx,4), %xmm0
movss %xmm0, -0x2c(%rbp)
movss %xmm0, -0x30(%rbp)
movss %xmm0, -0x34(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x34(%rbp), %rsi
callq 0xe010
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x8(%rcx), %rdi
leaq -0x28(%rbp), %rsi
movl $0x4, %edx
callq *%rax
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0xdc76
jmp 0xe006
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0xde4f
movl -0x10(%rbp), %eax
addl $-0x3, %eax
subl $0x1, %eax
ja 0xddb4
jmp 0xdd61
movq -0x20(%rbp), %rax
movl -0x38(%rbp), %ecx
imull -0x10(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movss (%rax,%rcx,4), %xmm0
movss %xmm0, -0x2c(%rbp)
movq -0x20(%rbp), %rax
movl -0x38(%rbp), %ecx
imull -0x10(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movss (%rax,%rcx,4), %xmm0
movss %xmm0, -0x30(%rbp)
movq -0x20(%rbp), %rax
movl -0x38(%rbp), %ecx
imull -0x10(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movss (%rax,%rcx,4), %xmm0
movss %xmm0, -0x34(%rbp)
jmp 0xddd9
movq -0x20(%rbp), %rax
movl -0x38(%rbp), %ecx
imull -0x10(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movss (%rax,%rcx,4), %xmm0
movss %xmm0, -0x2c(%rbp)
movss %xmm0, -0x30(%rbp)
movss %xmm0, -0x34(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x34(%rbp), %rsi
callq 0xe010
movb -0x28(%rbp), %dl
movq -0x18(%rbp), %rax
movl -0x38(%rbp), %ecx
imull $0x0, -0xc(%rbp), %esi
addl %esi, %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movb -0x27(%rbp), %dl
movq -0x18(%rbp), %rax
movl -0x38(%rbp), %ecx
movl -0xc(%rbp), %esi
shll $0x0, %esi
addl %esi, %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movb -0x26(%rbp), %dl
movq -0x18(%rbp), %rax
movl -0x38(%rbp), %ecx
movl -0xc(%rbp), %esi
shll %esi
addl %esi, %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movb -0x25(%rbp), %dl
movq -0x18(%rbp), %rax
movl -0x38(%rbp), %ecx
imull $0x3, -0xc(%rbp), %esi
addl %esi, %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0xdd48
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x8(%rcx), %rdi
leaq -0x24(%rbp), %rsi
movl $0x4, %edx
callq *%rax
movl $0x0, -0x3c(%rbp)
cmpl $0x4, -0x3c(%rbp)
jge 0xe004
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
imull -0x3c(%rbp), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0xdff4
movl -0x38(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
addl $0x2, %eax
cmpl -0xc(%rbp), %eax
jge 0xdf02
movq -0x48(%rbp), %rax
movslq -0x40(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movq -0x48(%rbp), %rcx
movl -0x40(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
jne 0xdef7
movq -0x48(%rbp), %rax
movslq -0x40(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movq -0x48(%rbp), %rcx
movl -0x40(%rbp), %edx
addl $0x2, %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
jne 0xdef7
jmp 0xdf02
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0xdea8
movl -0x40(%rbp), %eax
addl $0x2, %eax
cmpl -0xc(%rbp), %eax
jl 0xdf13
movl -0xc(%rbp), %eax
movl %eax, -0x40(%rbp)
jmp 0xdf15
movl -0x38(%rbp), %eax
cmpl -0x40(%rbp), %eax
jge 0xdf58
movl -0x40(%rbp), %eax
subl -0x38(%rbp), %eax
movl %eax, -0x4c(%rbp)
cmpl $0x80, -0x4c(%rbp)
jle 0xdf36
movl $0x80, -0x4c(%rbp)
movq -0x8(%rbp), %rdi
movl -0x4c(%rbp), %esi
movq -0x48(%rbp), %rdx
movslq -0x38(%rbp), %rax
addq %rax, %rdx
callq 0xe1a0
movl -0x4c(%rbp), %eax
addl -0x38(%rbp), %eax
movl %eax, -0x38(%rbp)
jmp 0xdf15
movl -0x40(%rbp), %eax
addl $0x2, %eax
cmpl -0xc(%rbp), %eax
jge 0xdfef
jmp 0xdf69
movl -0x40(%rbp), %ecx
xorl %eax, %eax
cmpl -0xc(%rbp), %ecx
movb %al, -0x51(%rbp)
jge 0xdf96
movq -0x48(%rbp), %rax
movslq -0x40(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movq -0x48(%rbp), %rcx
movslq -0x38(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
sete %al
movb %al, -0x51(%rbp)
movb -0x51(%rbp), %al
testb $0x1, %al
jne 0xdf9f
jmp 0xdfaa
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0xdf69
jmp 0xdfac
movl -0x38(%rbp), %eax
cmpl -0x40(%rbp), %eax
jge 0xdfed
movl -0x40(%rbp), %eax
subl -0x38(%rbp), %eax
movl %eax, -0x50(%rbp)
cmpl $0x7f, -0x50(%rbp)
jle 0xdfca
movl $0x7f, -0x50(%rbp)
movq -0x8(%rbp), %rdi
movl -0x50(%rbp), %esi
movq -0x48(%rbp), %rax
movslq -0x38(%rbp), %rcx
movzbl (%rax,%rcx), %edx
callq 0xe220
movl -0x50(%rbp), %eax
addl -0x38(%rbp), %eax
movl %eax, -0x38(%rbp)
jmp 0xdfac
jmp 0xdfef
jmp 0xde96
jmp 0xdff6
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0xde70
jmp 0xe006
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)