// File: /workspace/github_c_makefile_star2_O0/vlenhart[P]q3bsp/./stb_image_write.h
// Function: stbiw__write_hdr_scanline(_IO_FILE*, int, int, unsigned char*, float const*)
void stbiw__write_hdr_scanline(FILE *f, int width, int comp, unsigned char *scratch, const 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 (comp) {
            case 4: /* fallthrough */
            case 3: linear[2] = scanline[x*comp + 2];
                    linear[1] = scanline[x*comp + 1];
                    linear[0] = scanline[x*comp + 0];
                    break;
            case 2: /* fallthrough */
            case 1: linear[0] = linear[1] = linear[2] = scanline[x*comp + 0];
                    break;
         }
         stbiw__linear_to_rgbe(rgbe, linear);
         fwrite(rgbe, 4, 1, f);
      }
   } else {
      int c,r;
      /* encode into scratch buffer */
      for (x=0; x < width; x++) {
         switch(comp) {
            case 4: /* fallthrough */
            case 3: linear[2] = scanline[x*comp + 2];
                    linear[1] = scanline[x*comp + 1];
                    linear[0] = scanline[x*comp + 0];
                    break;
            case 2: /* fallthrough */
            case 1: linear[0] = linear[1] = linear[2] = scanline[x*comp + 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];
      }

      fwrite(scanlineheader, 4, 1, f);

      /* 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(f, 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(f, 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 0x24650(%rip), %eax     # 0x29010
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 0x49ef
cmpl $0x8000, -0xc(%rbp)     # imm = 0x8000
jl 0x4acd
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x4ac8
movl -0x10(%rbp), %eax
movl %eax, -0x54(%rbp)
decl %eax
subl $0x2, %eax
jb 0x4a71
jmp 0x4a11
movl -0x54(%rbp), %eax
addl $-0x3, %eax
subl $0x1, %eax
ja 0x4a96
jmp 0x4a1e
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 0x4a96
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 0x4710
leaq -0x28(%rbp), %rdi
movq -0x8(%rbp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x3560
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x49f6
jmp 0x4d9e
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x4bea
movl -0x10(%rbp), %eax
movl %eax, -0x58(%rbp)
decl %eax
subl $0x2, %eax
jb 0x4b4f
jmp 0x4aef
movl -0x58(%rbp), %eax
addl $-0x3, %eax
subl $0x1, %eax
ja 0x4b74
jmp 0x4afc
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 0x4b74
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 0x4710
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 0x4ad4
leaq -0x24(%rbp), %rdi
movq -0x8(%rbp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x3560
movl $0x0, -0x3c(%rbp)
cmpl $0x4, -0x3c(%rbp)
jge 0x4d9c
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 0x4d8c
movl -0x38(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
addl $0x2, %eax
cmpl -0xc(%rbp), %eax
jge 0x4c9a
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 0x4c8f
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 0x4c8f
jmp 0x4c9a
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x4c40
movl -0x40(%rbp), %eax
addl $0x2, %eax
cmpl -0xc(%rbp), %eax
jl 0x4cab
movl -0xc(%rbp), %eax
movl %eax, -0x40(%rbp)
jmp 0x4cad
movl -0x38(%rbp), %eax
cmpl -0x40(%rbp), %eax
jge 0x4cf0
movl -0x40(%rbp), %eax
subl -0x38(%rbp), %eax
movl %eax, -0x4c(%rbp)
cmpl $0x80, -0x4c(%rbp)
jle 0x4cce
movl $0x80, -0x4c(%rbp)
movq -0x8(%rbp), %rdi
movl -0x4c(%rbp), %esi
movq -0x48(%rbp), %rdx
movslq -0x38(%rbp), %rax
addq %rax, %rdx
callq 0x4920
movl -0x4c(%rbp), %eax
addl -0x38(%rbp), %eax
movl %eax, -0x38(%rbp)
jmp 0x4cad
movl -0x40(%rbp), %eax
addl $0x2, %eax
cmpl -0xc(%rbp), %eax
jge 0x4d87
jmp 0x4d01
movl -0x40(%rbp), %ecx
xorl %eax, %eax
cmpl -0xc(%rbp), %ecx
movb %al, -0x59(%rbp)
jge 0x4d2e
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, -0x59(%rbp)
movb -0x59(%rbp), %al
testb $0x1, %al
jne 0x4d37
jmp 0x4d42
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x4d01
jmp 0x4d44
movl -0x38(%rbp), %eax
cmpl -0x40(%rbp), %eax
jge 0x4d85
movl -0x40(%rbp), %eax
subl -0x38(%rbp), %eax
movl %eax, -0x50(%rbp)
cmpl $0x7f, -0x50(%rbp)
jle 0x4d62
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 0x48a0
movl -0x50(%rbp), %eax
addl -0x38(%rbp), %eax
movl %eax, -0x38(%rbp)
jmp 0x4d44
jmp 0x4d87
jmp 0x4c2e
jmp 0x4d8e
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x4c08
jmp 0x4d9e
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)