// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x488, %rsp            # imm = 0x488
movq %rdi, 0x478(%rsp)
movq %rsi, 0x470(%rsp)
movq %rdx, 0x468(%rsp)
movq %rcx, 0x460(%rsp)
movl %r8d, 0x45c(%rsp)
movl $0x0, 0x44(%rsp)
movq 0x478(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x2a620
movq %rax, %rdi
leaq 0xf964(%rip), %rsi      # 0x2e177
callq 0xd5c0
cmpl $0x0, %eax
je 0x1e841
leaq 0xf95e(%rip), %rdi      # 0x2e182
callq 0x1a190
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, 0x480(%rsp)
jmp 0x1edcc
jmp 0x1e843
movq 0x478(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x2a620
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x1e869
jmp 0x1e889
movq 0x48(%rsp), %rdi
leaq 0xf915(%rip), %rsi      # 0x2e18a
callq 0xd5c0
cmpl $0x0, %eax
jne 0x1e887
movl $0x1, 0x44(%rsp)
jmp 0x1e843
cmpl $0x0, 0x44(%rsp)
jne 0x1e8b4
leaq 0xf90a(%rip), %rdi      # 0x2e1a1
callq 0x1a190
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, 0x480(%rsp)
jmp 0x1edcc
movq 0x478(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x2a620
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rdi
leaq 0xf8dd(%rip), %rsi      # 0x2e1b4
movl $0x3, %edx
callq 0xd1d0
cmpl $0x0, %eax
je 0x1e90a
leaq 0xf8cb(%rip), %rdi      # 0x2e1b8
callq 0x1a190
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, 0x480(%rsp)
jmp 0x1edcc
movq 0x48(%rsp), %rax
addq $0x3, %rax
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rdi
leaq 0x48(%rsp), %rsi
movl $0xa, %edx
callq 0xd5d0
movl %eax, 0x3c(%rsp)
movq 0x48(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x20, %eax
jne 0x1e94d
movq 0x48(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x48(%rsp)
jmp 0x1e930
movq 0x48(%rsp), %rdi
leaq 0xf877(%rip), %rsi      # 0x2e1d0
movl $0x3, %edx
callq 0xd1d0
cmpl $0x0, %eax
je 0x1e98c
leaq 0xf849(%rip), %rdi      # 0x2e1b8
callq 0x1a190
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, 0x480(%rsp)
jmp 0x1edcc
movq 0x48(%rsp), %rax
addq $0x3, %rax
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0xd5d0
movl %eax, 0x40(%rsp)
movl 0x40(%rsp), %ecx
movq 0x470(%rsp), %rax
movl %ecx, (%rax)
movl 0x3c(%rsp), %ecx
movq 0x468(%rsp), %rax
movl %ecx, (%rax)
cmpq $0x0, 0x460(%rsp)
je 0x1e9e6
movq 0x460(%rsp), %rax
movl $0x3, (%rax)
cmpl $0x0, 0x45c(%rsp)
jne 0x1e9fb
movl $0x3, 0x45c(%rsp)
movl 0x3c(%rsp), %eax
imull 0x40(%rsp), %eax
imull 0x45c(%rsp), %eax
movslq %eax, %rdi
shlq $0x2, %rdi
callq 0x1ac80
movq %rax, 0x28(%rsp)
cmpl $0x8, 0x40(%rsp)
jl 0x1ea32
cmpl $0x8000, 0x40(%rsp)     # imm = 0x8000
jl 0x1eadc
movl $0x0, 0x18(%rsp)
movl 0x18(%rsp), %eax
cmpl 0x3c(%rsp), %eax
jge 0x1ead7
movl $0x0, 0x1c(%rsp)
movl 0x1c(%rsp), %eax
cmpl 0x40(%rsp), %eax
jge 0x1eac5
jmp 0x1ea5c
movq 0x478(%rsp), %rdi
leaq 0x4(%rsp), %rsi
movl $0x4, %edx
callq 0x26210
movq 0x28(%rsp), %rdi
movl 0x18(%rsp), %eax
imull 0x40(%rsp), %eax
imull 0x45c(%rsp), %eax
cltq
shlq $0x2, %rax
addq %rax, %rdi
movl 0x1c(%rsp), %eax
imull 0x45c(%rsp), %eax
cltq
shlq $0x2, %rax
addq %rax, %rdi
leaq 0x4(%rsp), %rsi
movl 0x45c(%rsp), %edx
callq 0x2a710
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0x1ea50
jmp 0x1eac7
movl 0x18(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x18(%rsp)
jmp 0x1ea3a
jmp 0x1edbf
movq $0x0, 0x30(%rsp)
movl $0x0, 0x18(%rsp)
movl 0x18(%rsp), %eax
cmpl 0x3c(%rsp), %eax
jge 0x1edb5
movq 0x478(%rsp), %rdi
callq 0x21530
movzbl %al, %eax
movl %eax, 0x10(%rsp)
movq 0x478(%rsp), %rdi
callq 0x21530
movzbl %al, %eax
movl %eax, 0xc(%rsp)
movq 0x478(%rsp), %rdi
callq 0x21530
movzbl %al, %eax
movl %eax, 0x24(%rsp)
cmpl $0x2, 0x10(%rsp)
jne 0x1eb53
cmpl $0x2, 0xc(%rsp)
jne 0x1eb53
movl 0x24(%rsp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x1ebae
movl 0x10(%rsp), %eax
movb %al, (%rsp)
movl 0xc(%rsp), %eax
movb %al, 0x1(%rsp)
movl 0x24(%rsp), %eax
movb %al, 0x2(%rsp)
movq 0x478(%rsp), %rdi
callq 0x21530
movb %al, 0x3(%rsp)
movq 0x28(%rsp), %rdi
movq %rsp, %rsi
movl 0x45c(%rsp), %edx
callq 0x2a710
movl $0x1, 0x1c(%rsp)
movl $0x0, 0x18(%rsp)
movq 0x30(%rsp), %rdi
callq 0xd4e0
jmp 0x1ea5c
movl 0x24(%rsp), %eax
shll $0x8, %eax
movl %eax, 0x24(%rsp)
movq 0x478(%rsp), %rdi
callq 0x21530
movzbl %al, %eax
orl 0x24(%rsp), %eax
movl %eax, 0x24(%rsp)
movl 0x24(%rsp), %eax
cmpl 0x40(%rsp), %eax
je 0x1ec13
movq 0x28(%rsp), %rdi
callq 0xd4e0
movq 0x30(%rsp), %rdi
callq 0xd4e0
leaq 0xf5de(%rip), %rdi      # 0x2e1d4
callq 0x1a190
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, 0x480(%rsp)
jmp 0x1edcc
cmpq $0x0, 0x30(%rsp)
jne 0x1ec2f
movl 0x40(%rsp), %eax
shll $0x2, %eax
movslq %eax, %rdi
callq 0x1ac80
movq %rax, 0x30(%rsp)
movl $0x0, 0x14(%rsp)
cmpl $0x4, 0x14(%rsp)
jge 0x1ed44
movl $0x0, 0x1c(%rsp)
movl 0x1c(%rsp), %eax
cmpl 0x40(%rsp), %eax
jge 0x1ed32
movq 0x478(%rsp), %rdi
callq 0x21530
movb %al, 0x23(%rsp)
movzbl 0x23(%rsp), %eax
cmpl $0x80, %eax
jle 0x1ecdb
movq 0x478(%rsp), %rdi
callq 0x21530
movb %al, 0x22(%rsp)
movzbl 0x23(%rsp), %eax
subl $0x80, %eax
movb %al, 0x23(%rsp)
movl $0x0, 0x8(%rsp)
movl 0x8(%rsp), %eax
movzbl 0x23(%rsp), %ecx
cmpl %ecx, %eax
jge 0x1ecd9
movb 0x22(%rsp), %dl
movq 0x30(%rsp), %rax
movl 0x1c(%rsp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, 0x1c(%rsp)
shll $0x2, %ecx
addl 0x14(%rsp), %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl 0x8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8(%rsp)
jmp 0x1ec9c
jmp 0x1ed2d
movl $0x0, 0x8(%rsp)
movl 0x8(%rsp), %eax
movzbl 0x23(%rsp), %ecx
cmpl %ecx, %eax
jge 0x1ed2b
movq 0x478(%rsp), %rdi
callq 0x21530
movb %al, %dl
movq 0x30(%rsp), %rax
movl 0x1c(%rsp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, 0x1c(%rsp)
shll $0x2, %ecx
addl 0x14(%rsp), %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl 0x8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8(%rsp)
jmp 0x1ece3
jmp 0x1ed2d
jmp 0x1ec4a
jmp 0x1ed34
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0x1ec37
movl $0x0, 0x1c(%rsp)
movl 0x1c(%rsp), %eax
cmpl 0x40(%rsp), %eax
jge 0x1eda3
movq 0x28(%rsp), %rdi
movl 0x18(%rsp), %eax
imull 0x40(%rsp), %eax
addl 0x1c(%rsp), %eax
imull 0x45c(%rsp), %eax
cltq
shlq $0x2, %rax
addq %rax, %rdi
movq 0x30(%rsp), %rsi
movl 0x1c(%rsp), %eax
shll $0x2, %eax
cltq
addq %rax, %rsi
movl 0x45c(%rsp), %edx
callq 0x2a710
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0x1ed4c
jmp 0x1eda5
movl 0x18(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x18(%rsp)
jmp 0x1eaed
movq 0x30(%rsp), %rdi
callq 0xd4e0
movq 0x28(%rsp), %rax
movq %rax, 0x480(%rsp)
movq 0x480(%rsp), %rax
addq $0x488, %rsp            # imm = 0x488
retq
nopl (%rax)