// File: /workspace/github_c_makefile_star2_O1/patriciogonzalezvivo[P]tprint/include/std/stb_image.h
// Function: stbi__hdr_load(stbi__context*, int*, int*, int*, int)
static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp)
{
   char buffer[STBI__HDR_BUFLEN];
   char *token;
   int valid = 0;
   int width, height;
   stbi_uc *scanline;
   float *hdr_data;
   int len;
   unsigned char count, value;
   int i, j, k, c1,c2, z;


   // Check identifier
   if (strcmp(stbi__hdr_gettoken(s,buffer), "#?RADIANCE") != 0)
      return stbi__errpf("not HDR", "Corrupt HDR image");

   // Parse header
   for(;;) {
      token = stbi__hdr_gettoken(s,buffer);
      if (token[0] == 0) break;
      if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1;
   }

   if (!valid)    return stbi__errpf("unsupported format", "Unsupported HDR format");

   // Parse width and height
   // can't use sscanf() if we're not using stdio!
   token = stbi__hdr_gettoken(s,buffer);
   if (strncmp(token, "-Y ", 3))  return stbi__errpf("unsupported data layout", "Unsupported HDR format");
   token += 3;
   height = (int) strtol(token, &token, 10);
   while (*token == ' ') ++token;
   if (strncmp(token, "+X ", 3))  return stbi__errpf("unsupported data layout", "Unsupported HDR format");
   token += 3;
   width = (int) strtol(token, NULL, 10);

   *x = width;
   *y = height;

   if (comp) *comp = 3;
   if (req_comp == 0) req_comp = 3;

   // Read data
   hdr_data = (float *) stbi__malloc(height * width * req_comp * sizeof(float));

   // Load image data
   // image data is stored as some number of sca
   if ( width < 8 || width >= 32768) {
      // Read flat data
      for (j=0; j < height; ++j) {
         for (i=0; i < width; ++i) {
            stbi_uc rgbe[4];
           main_decode_loop:
            stbi__getn(s, rgbe, 4);
            stbi__hdr_convert(hdr_data + j * width * req_comp + i * req_comp, rgbe, req_comp);
         }
      }
   } else {
      // Read RLE-encoded data
      scanline = NULL;

      for (j = 0; j < height; ++j) {
         c1 = stbi__get8(s);
         c2 = stbi__get8(s);
         len = stbi__get8(s);
         if (c1 != 2 || c2 != 2 || (len & 0x80)) {
            // not run-length encoded, so we have to actually use THIS data as a decoded
            // pixel (note this can't be a valid pixel--one of RGB must be >= 128)
            stbi_uc rgbe[4];
            rgbe[0] = (stbi_uc) c1;
            rgbe[1] = (stbi_uc) c2;
            rgbe[2] = (stbi_uc) len;
            rgbe[3] = (stbi_uc) stbi__get8(s);
            stbi__hdr_convert(hdr_data, rgbe, req_comp);
            i = 1;
            j = 0;
            STBI_FREE(scanline);
            goto main_decode_loop; // yes, this makes no sense
         }
         len <<= 8;
         len |= stbi__get8(s);
         if (len != width) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("invalid decoded scanline length", "corrupt HDR"); }
         if (scanline == NULL) scanline = (stbi_uc *) stbi__malloc(width * 4);

         for (k = 0; k < 4; ++k) {
            i = 0;
            while (i < width) {
               count = stbi__get8(s);
               if (count > 128) {
                  // Run
                  value = stbi__get8(s);
                  count -= 128;
                  for (z = 0; z < count; ++z)
                     scanline[i++ * 4 + k] = value;
               } else {
                  // Dump
                  for (z = 0; z < count; ++z)
                     scanline[i++ * 4 + k] = stbi__get8(s);
               }
            }
         }
         for (i=0; i < width; ++i)
            stbi__hdr_convert(hdr_data+(j*width + i)*req_comp, scanline + i*4, req_comp);
      }
      STBI_FREE(scanline);
   }

   return hdr_data;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x498, %rsp            # imm = 0x498
movl %r8d, %r15d
movq %rcx, %r13
movq %rdx, %rbp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x90(%rsp), %r12
movq %r12, %rsi
callq 0x1f013
movabsq $0x4e41494441523f23, %rax # imm = 0x4E41494441523F23
xorq (%r12), %rax
movabsq $0x45434e41494441, %rcx # imm = 0x45434E41494441
xorq 0x3(%r12), %rcx
orq %rax, %rcx
je 0x184de
leaq 0xa0ed(%rip), %rax      # 0x225c6
jmp 0x18600
leaq 0x90(%rsp), %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1f013
cmpb $0x0, (%r12)
je 0x185f4
movq %r13, 0x40(%rsp)
movl %r15d, 0x8(%rsp)
xorl %r15d, %r15d
movl $0x1, %r13d
leaq 0x90(%rsp), %r12
movdqu 0x97(%rsp), %xmm0
pcmpeqb 0x9488(%rip), %xmm0     # 0x219b0
movdqa 0x90(%rsp), %xmm1
pcmpeqb 0x9487(%rip), %xmm1     # 0x219c0
pand %xmm0, %xmm1
pmovmskb %xmm1, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
cmovel %r13d, %r15d
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1f013
cmpb $0x0, 0x90(%rsp)
jne 0x18517
movq %r12, 0x20(%rsp)
testl %r15d, %r15d
je 0x185f9
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1f013
movl $0x592d, %eax           # imm = 0x592D
xorl 0x90(%rsp), %eax
movq %r12, 0x20(%rsp)
movzbl 0x92(%rsp), %ecx
xorl $0x20, %ecx
orw %ax, %cx
jne 0x185eb
leaq 0x93(%rsp), %rdi
leaq 0x20(%rsp), %r12
movq %rdi, (%r12)
movq %r12, %rsi
movl $0xa, %edx
callq 0x8470
movq %rax, %r13
movq (%r12), %r12
decq %r12
cmpb $0x20, 0x1(%r12)
leaq 0x1(%r12), %r12
je 0x185c1
movq %r12, 0x20(%rsp)
leaq 0xa03a(%rip), %rsi      # 0x22614
movl $0x3, %edx
movq %r12, %rdi
callq 0x8180
testl %eax, %eax
je 0x1861f
leaq 0xa00a(%rip), %rax      # 0x225fc
jmp 0x18600
movq %r12, 0x20(%rsp)
leaq 0x9fe5(%rip), %rax      # 0x225e5
movq %rax, 0xfe01(%rip)      # 0x28408
xorl %r12d, %r12d
movq %r12, %rax
addq $0x498, %rsp            # imm = 0x498
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq $0x3, %r12
movq %r12, 0x20(%rsp)
xorl %r15d, %r15d
movq %r12, %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x8470
movl %eax, (%r14)
movq %rax, %r14
movl %r13d, (%rbp)
movq 0x40(%rsp), %rax
testq %rax, %rax
je 0x18654
movl $0x3, (%rax)
movl 0x8(%rsp), %ecx
testl %ecx, %ecx
movl $0x3, %eax
cmovnel %ecx, %eax
movl %eax, 0x14(%rsp)
imull %r13d, %eax
imull %r14d, %eax
movslq %eax, %rdi
shlq $0x2, %rdi
callq 0x8430
movq %rax, %r12
leal -0x8000(%r14), %eax
cmpl $0xffff8008, %eax       # imm = 0xFFFF8008
movq %r14, 0x38(%rsp)
jb 0x18c1d
testl %r13d, %r13d
jle 0x18b99
movq %r13, %rcx
leaq 0x38(%rbx), %r13
leaq 0x39(%rbx), %rax
movq %rax, 0x8(%rsp)
leal (,%r14,4), %eax
movq %rax, 0x50(%rsp)
movslq 0x14(%rsp), %rdx
movl %r14d, %esi
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rcx, 0x48(%rsp)
andq %rax, %rcx
movq %rcx, 0x60(%rsp)
andq %rax, %r14
movq %r14, 0x58(%rsp)
imulq %rdx, %rsi
shlq $0x2, %rsi
movq %rsi, 0x68(%rsp)
shlq $0x2, %rdx
movq %rdx, 0x70(%rsp)
xorl %ebp, %ebp
movq %r12, 0x30(%rsp)
movq $0x0, 0x18(%rsp)
movq %r12, 0x28(%rsp)
movq 0xb8(%rbx), %rax
cmpq 0xc0(%rbx), %rax
jb 0x1876d
cmpl $0x0, 0x30(%rbx)
je 0x18743
movq 0x28(%rbx), %rdi
movl 0x34(%rbx), %edx
movq %r13, %rsi
callq *0x10(%rbx)
testl %eax, %eax
je 0x18748
movq %r13, 0xb8(%rbx)
cltq
addq %r13, %rax
movq %rax, 0xc0(%rbx)
jmp 0x18766
xorl %r15d, %r15d
jmp 0x1877b
movl $0x0, 0x30(%rbx)
movq %r13, 0xb8(%rbx)
movq 0x8(%rsp), %rax
movq %rax, 0xc0(%rbx)
movb $0x0, 0x38(%rbx)
movq 0xb8(%rbx), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0xb8(%rbx)
movb (%rax), %r15b
movq 0xb8(%rbx), %rax
cmpq 0xc0(%rbx), %rax
jb 0x187e1
cmpl $0x0, 0x30(%rbx)
je 0x187b7
movq 0x28(%rbx), %rdi
movl 0x34(%rbx), %edx
movq %r13, %rsi
callq *0x10(%rbx)
testl %eax, %eax
je 0x187bc
movq %r13, 0xb8(%rbx)
cltq
addq %r13, %rax
movq %rax, 0xc0(%rbx)
jmp 0x187da
xorl %r12d, %r12d
jmp 0x187ef
movl $0x0, 0x30(%rbx)
movq %r13, 0xb8(%rbx)
movq 0x8(%rsp), %rax
movq %rax, 0xc0(%rbx)
movb $0x0, 0x38(%rbx)
movq 0xb8(%rbx), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0xb8(%rbx)
movb (%rax), %r12b
movq 0xb8(%rbx), %rax
cmpq 0xc0(%rbx), %rax
jb 0x18855
cmpl $0x0, 0x30(%rbx)
je 0x1882b
movq 0x28(%rbx), %rdi
movl 0x34(%rbx), %edx
movq %r13, %rsi
callq *0x10(%rbx)
testl %eax, %eax
je 0x18830
movq %r13, 0xb8(%rbx)
cltq
addq %r13, %rax
movq %rax, 0xc0(%rbx)
jmp 0x1884e
xorl %r14d, %r14d
jmp 0x18863
movl $0x0, 0x30(%rbx)
movq %r13, 0xb8(%rbx)
movq 0x8(%rsp), %rax
movq %rax, 0xc0(%rbx)
movb $0x0, 0x38(%rbx)
movq 0xb8(%rbx), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0xb8(%rbx)
movb (%rax), %r14b
cmpb $0x2, %r15b
jne 0x18bb1
cmpb $0x2, %r12b
jne 0x18bb1
testb %r14b, %r14b
js 0x18bb1
movq 0xb8(%rbx), %rax
cmpq 0xc0(%rbx), %rax
movq 0x28(%rsp), %r15
movq 0x18(%rsp), %r12
jb 0x188ef
cmpl $0x0, 0x30(%rbx)
je 0x188c6
movq 0x28(%rbx), %rdi
movl 0x34(%rbx), %edx
movq %r13, %rsi
callq *0x10(%rbx)
testl %eax, %eax
je 0x188ca
movq %r13, 0xb8(%rbx)
cltq
addq %r13, %rax
movq %rax, 0xc0(%rbx)
jmp 0x188e8
xorl %eax, %eax
jmp 0x188fd
movl $0x0, 0x30(%rbx)
movq %r13, 0xb8(%rbx)
movq 0x8(%rsp), %rax
movq %rax, 0xc0(%rbx)
movb $0x0, 0x38(%rbx)
movq 0xb8(%rbx), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0xb8(%rbx)
movzbl (%rax), %eax
movzbl %r14b, %ecx
shll $0x8, %ecx
orl %eax, %ecx
movq 0x38(%rsp), %r14
cmpl %r14d, %ecx
jne 0x18bfe
testq %r12, %r12
jne 0x18926
movq 0x50(%rsp), %rdi
callq 0x8430
movq %rax, %r12
movq %rbp, 0x78(%rsp)
movq %r12, 0x18(%rsp)
movq %r12, %rbp
xorl %eax, %eax
movq %rax, 0x80(%rsp)
testl %r14d, %r14d
jle 0x18b22
xorl %r15d, %r15d
movq %rbp, 0x40(%rsp)
movq 0xb8(%rbx), %rax
cmpq 0xc0(%rbx), %rax
jb 0x189b4
cmpl $0x0, 0x30(%rbx)
je 0x1898a
movq 0x28(%rbx), %rdi
movl 0x34(%rbx), %edx
movq %r13, %rsi
callq *0x10(%rbx)
testl %eax, %eax
je 0x1898f
movq %r13, 0xb8(%rbx)
cltq
addq %r13, %rax
movq %rax, 0xc0(%rbx)
jmp 0x189ad
xorl %r12d, %r12d
jmp 0x189c2
movl $0x0, 0x30(%rbx)
movq %r13, 0xb8(%rbx)
movq 0x8(%rsp), %rax
movq %rax, 0xc0(%rbx)
movb $0x0, 0x38(%rbx)
movq 0xb8(%rbx), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0xb8(%rbx)
movb (%rax), %r12b
cmpb $-0x80, %r12b
jbe 0x18a13
movq 0xb8(%rbx), %rax
cmpq 0xc0(%rbx), %rax
jb 0x18ae2
cmpl $0x0, 0x30(%rbx)
je 0x18ab9
movq 0x28(%rbx), %rdi
movl 0x34(%rbx), %edx
movq %r13, %rsi
callq *0x10(%rbx)
testl %eax, %eax
je 0x18abd
movq %r13, 0xb8(%rbx)
cltq
addq %r13, %rax
movq %rax, 0xc0(%rbx)
jmp 0x18adb
testb %r12b, %r12b
je 0x18b19
movslq %r15d, %rax
leaq (%rbp,%rax,4), %rbp
movzbl %r12b, %r12d
xorl %r14d, %r14d
movq 0xb8(%rbx), %rax
cmpq 0xc0(%rbx), %rax
jb 0x18a90
cmpl $0x0, 0x30(%rbx)
je 0x18a67
movq 0x28(%rbx), %rdi
movl 0x34(%rbx), %edx
movq %r13, %rsi
callq *0x10(%rbx)
testl %eax, %eax
je 0x18a6b
movq %r13, 0xb8(%rbx)
cltq
addq %r13, %rax
movq %rax, 0xc0(%rbx)
jmp 0x18a89
xorl %eax, %eax
jmp 0x18a9d
movl $0x0, 0x30(%rbx)
movq %r13, 0xb8(%rbx)
movq 0x8(%rsp), %rax
movq %rax, 0xc0(%rbx)
movb $0x0, 0x38(%rbx)
movq 0xb8(%rbx), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0xb8(%rbx)
movb (%rax), %al
movb %al, (%rbp,%r14,4)
incq %r14
cmpl %r14d, %r12d
jne 0x18a2b
addl %r14d, %r15d
movq 0x38(%rsp), %r14
movq 0x40(%rsp), %rbp
jmp 0x18b19
xorl %eax, %eax
jmp 0x18aef
movl $0x0, 0x30(%rbx)
movq %r13, 0xb8(%rbx)
movq 0x8(%rsp), %rax
movq %rax, 0xc0(%rbx)
movb $0x0, 0x38(%rbx)
movq 0xb8(%rbx), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0xb8(%rbx)
movb (%rax), %al
testb $0x7f, %r12b
je 0x18b19
movslq %r15d, %rcx
leaq (,%rcx,4), %rcx
addq %rbp, %rcx
movzbl %r12b, %edx
andl $0x7f, %edx
xorl %esi, %esi
movb %al, (%rcx,%rsi,4)
incq %rsi
cmpl %esi, %edx
jne 0x18b0c
addl %esi, %r15d
cmpl %r14d, %r15d
jl 0x1894e
movq 0x80(%rsp), %rax
incq %rax
incq %rbp
cmpq $0x4, %rax
jne 0x18935
movq 0x58(%rsp), %r12
movq %r14, %rax
movq 0x18(%rsp), %r14
movq 0x30(%rsp), %r15
testl %eax, %eax
movq 0x70(%rsp), %rbp
jle 0x18b70
movq %r15, %rdi
movq %r14, %rsi
movl 0x14(%rsp), %edx
callq 0x1f237
addq %rbp, %r15
addq $0x4, %r14
decq %r12
jne 0x18b55
movq 0x78(%rsp), %rbp
incq %rbp
movq 0x30(%rsp), %rax
addq 0x68(%rsp), %rax
movq %rax, 0x30(%rsp)
cmpq 0x60(%rsp), %rbp
movq 0x28(%rsp), %r12
jne 0x18707
jmp 0x18ba2
movq $0x0, 0x18(%rsp)
movq 0x18(%rsp), %rdi
callq 0x83f0
jmp 0x1860a
leaq 0x88(%rsp), %r13
movb %r15b, (%r13)
movb %r12b, 0x1(%r13)
movb %r14b, 0x2(%r13)
movq %rbx, %rdi
callq 0x1ae1d
movb %al, 0x3(%r13)
movq 0x28(%rsp), %r12
movq %r12, %rdi
movq %r13, %rsi
movl 0x14(%rsp), %edx
callq 0x1f237
movq 0x18(%rsp), %rdi
callq 0x83f0
xorl %r15d, %r15d
movl $0x1, %ebp
movq 0x48(%rsp), %r13
jmp 0x18c2d
movq %r15, %rdi
callq 0x83f0
movq %r12, %rdi
callq 0x83f0
leaq 0x9a03(%rip), %rax      # 0x22618
jmp 0x18600
incl %r15d
xorl %ebp, %ebp
cmpl %r13d, %r15d
jge 0x1860a
cmpl %r14d, %ebp
jge 0x18c1a
leaq 0x8c(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
movl $0x4, %edx
callq 0x1d2f6
movl 0x14(%rsp), %edx
movl %edx, %eax
movq 0x38(%rsp), %r8
imull %r8d, %eax
imull %r15d, %eax
cltq
leaq (%r12,%rax,4), %rax
movl %ebp, %ecx
imull %edx, %ecx
movslq %ecx, %rcx
leaq (%rax,%rcx,4), %rdi
movq %r14, %rsi
movq %r8, %r14
callq 0x1f237
incl %ebp
jmp 0x18c28