// File: /workspace/github_c_makefile_star2_O3/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 0x1e3a0
movabsq $0x4e41494441523f23, %rax # imm = 0x4E41494441523F23
xorq (%r12), %rax
movabsq $0x45434e41494441, %rcx # imm = 0x45434E41494441
xorq 0x3(%r12), %rcx
orq %rax, %rcx
je 0x17b09
leaq 0x9ad2(%rip), %rax      # 0x215d6
jmp 0x18153
movq %r13, 0x10(%rsp)
leaq 0x90(%rsp), %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1e3a0
cmpb $0x0, (%r12)
je 0x18143
movq %r14, 0x8(%rsp)
movq %rbp, %r14
movl %r15d, %ebp
xorl %r15d, %r15d
movl $0x1, %r13d
leaq 0x90(%rsp), %r12
movdqu 0x97(%rsp), %xmm0
pcmpeqb 0x8e57(%rip), %xmm0     # 0x209b0
movdqa 0x90(%rsp), %xmm1
pcmpeqb 0x8e56(%rip), %xmm1     # 0x209c0
pand %xmm0, %xmm1
pmovmskb %xmm1, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
cmovel %r13d, %r15d
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1e3a0
cmpb $0x0, 0x90(%rsp)
jne 0x17b48
testl %r15d, %r15d
movl %ebp, %r13d
movq %r14, %rbp
movq 0x8(%rsp), %r14
je 0x18143
leaq 0x90(%rsp), %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1e3a0
movl $0x592d, %eax           # imm = 0x592D
xorl (%r12), %eax
movzbl 0x2(%r12), %ecx
xorl $0x20, %ecx
orw %ax, %cx
jne 0x1814c
leaq 0x93(%rsp), %rdi
leaq 0x80(%rsp), %r12
movq %rdi, (%r12)
movq %r12, %rsi
movl $0xa, %edx
callq 0x8460
movq %rax, %r15
movq (%r12), %rdi
addq $0x2, %rdi
movb -0x2(%rdi), %al
incq %rdi
cmpb $0x20, %al
je 0x17bfe
cmpb $0x2b, %al
jne 0x1814c
cmpb $0x58, -0x2(%rdi)
jne 0x1814c
cmpb $0x20, -0x1(%rdi)
jne 0x1814c
movq %rdi, 0x80(%rsp)
xorl %esi, %esi
movl $0xa, %edx
callq 0x8460
movl %eax, (%r14)
movq %rax, %r14
movl %r15d, (%rbp)
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x17c52
movl $0x3, (%rax)
testl %r13d, %r13d
movl %r13d, %eax
movl $0x3, %r13d
cmovnel %eax, %r13d
movq %r15, 0x40(%rsp)
movl %r15d, %eax
imull %r14d, %eax
imull %r13d, %eax
movslq %eax, %rdi
shlq $0x2, %rdi
callq 0x8420
movq %rax, %r12
leal -0x8000(%r14), %eax
cmpl $0xffff8008, %eax       # imm = 0xFFFF8008
movq %r14, 0x30(%rsp)
movl $0x0, %eax
jb 0x181f7
movq %r12, 0x20(%rsp)
movq 0x40(%rsp), %r15
testl %r15d, %r15d
jle 0x18172
movl %r13d, %eax
leaq 0x38(%rbx), %r13
leaq 0x39(%rbx), %rcx
movq %rcx, 0x8(%rsp)
leal (,%r14,4), %ecx
movq %rcx, 0x48(%rsp)
movl %eax, 0x1c(%rsp)
movslq %eax, %rcx
movl %r14d, %edx
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andq %rax, %r15
movq %r15, 0x58(%rsp)
andq %rax, %r14
movq %r14, 0x50(%rsp)
imulq %rcx, %rdx
shlq $0x2, %rdx
movq %rdx, 0x60(%rsp)
shlq $0x2, %rcx
movq %rcx, 0x68(%rsp)
xorl %r12d, %r12d
movq 0x20(%rsp), %rax
movq %rax, 0x38(%rsp)
xorl %r15d, %r15d
movq 0xb8(%rbx), %rcx
movq 0xc0(%rbx), %rax
cmpq %rax, %rcx
jae 0x17d38
leaq 0x1(%rcx), %rdx
movq %rdx, 0xb8(%rbx)
movb (%rcx), %sil
movq %rdx, %rcx
jmp 0x17d86
cmpl $0x0, 0x30(%rbx)
je 0x17d5f
movq 0x28(%rbx), %rdi
movl 0x34(%rbx), %edx
movq %r13, %rsi
callq *0x10(%rbx)
testl %eax, %eax
je 0x17d63
cltq
addq %r13, %rax
movb (%r13), %sil
movq 0x8(%rsp), %rcx
jmp 0x17d78
xorl %esi, %esi
jmp 0x17d86
movl $0x0, 0x30(%rbx)
movb $0x0, 0x38(%rbx)
xorl %esi, %esi
movq 0x8(%rsp), %rcx
movq %rcx, %rax
movq %rax, 0xc0(%rbx)
movq %rcx, 0xb8(%rbx)
cmpq %rax, %rcx
jae 0x17d9e
leaq 0x1(%rcx), %rdx
movq %rdx, 0xb8(%rbx)
movb (%rcx), %r14b
movq %rdx, %rcx
jmp 0x17df2
cmpl $0x0, 0x30(%rbx)
je 0x17dc7
movl %esi, %ebp
movq 0x28(%rbx), %rdi
movl 0x34(%rbx), %edx
movq %r13, %rsi
callq *0x10(%rbx)
testl %eax, %eax
je 0x17dcc
cltq
addq %r13, %rax
movb (%r13), %r14b
movq 0x8(%rsp), %rcx
jmp 0x17de2
xorl %r14d, %r14d
jmp 0x17df2
movl $0x0, 0x30(%rbx)
movb $0x0, 0x38(%rbx)
xorl %r14d, %r14d
movq 0x8(%rsp), %rcx
movq %rcx, %rax
movq %rax, 0xc0(%rbx)
movq %rcx, 0xb8(%rbx)
movl %ebp, %esi
cmpq %rax, %rcx
jae 0x17e0a
leaq 0x1(%rcx), %rdx
movq %rdx, 0xb8(%rbx)
movb (%rcx), %bpl
movq %rdx, %rcx
jmp 0x17e60
cmpl $0x0, 0x30(%rbx)
je 0x17e35
movl %esi, 0x10(%rsp)
movq 0x28(%rbx), %rdi
movl 0x34(%rbx), %edx
movq %r13, %rsi
callq *0x10(%rbx)
testl %eax, %eax
je 0x17e39
cltq
addq %r13, %rax
movb (%r13), %bpl
movq 0x8(%rsp), %rcx
jmp 0x17e4e
xorl %ebp, %ebp
jmp 0x17e60
movl $0x0, 0x30(%rbx)
movb $0x0, 0x38(%rbx)
xorl %ebp, %ebp
movq 0x8(%rsp), %rcx
movq %rcx, %rax
movl 0x10(%rsp), %esi
movq %rax, 0xc0(%rbx)
movq %rcx, 0xb8(%rbx)
cmpb $0x2, %sil
jne 0x18184
cmpb $0x2, %r14b
jne 0x18184
testb %bpl, %bpl
js 0x18184
cmpq %rax, %rcx
jae 0x17e96
leaq 0x1(%rcx), %rax
movq %rax, 0xb8(%rbx)
movb (%rcx), %al
movq 0x30(%rsp), %r14
jmp 0x17eea
cmpl $0x0, 0x30(%rbx)
movq 0x30(%rsp), %r14
je 0x17ec3
movq 0x28(%rbx), %rdi
movl 0x34(%rbx), %edx
movq %r13, %rsi
callq *0x10(%rbx)
testl %eax, %eax
je 0x17ec7
movslq %eax, %rcx
addq %r13, %rcx
movb (%r13), %al
movq 0x8(%rsp), %rdx
jmp 0x17edc
xorl %eax, %eax
jmp 0x17eea
movl $0x0, 0x30(%rbx)
movb $0x0, 0x38(%rbx)
xorl %eax, %eax
movq 0x8(%rsp), %rdx
movq %rdx, %rcx
movq %rcx, 0xc0(%rbx)
movq %rdx, 0xb8(%rbx)
movzbl %bpl, %ecx
shll $0x8, %ecx
movzbl %al, %eax
orl %ecx, %eax
cmpl %r14d, %eax
jne 0x181d4
testq %r15, %r15
jne 0x17f11
movq 0x48(%rsp), %rdi
callq 0x8420
movq %rax, %r15
movq %r12, 0x70(%rsp)
movq %r15, 0x28(%rsp)
xorl %eax, %eax
movq %rax, 0x78(%rsp)
xorl %ebp, %ebp
movq %r15, 0x10(%rsp)
movq 0xb8(%rbx), %rdx
movq 0xc0(%rbx), %rax
cmpq %rax, %rdx
jae 0x17f4c
leaq 0x1(%rdx), %rcx
movq %rcx, 0xb8(%rbx)
movb (%rdx), %r12b
jmp 0x17f9b
cmpl $0x0, 0x30(%rbx)
je 0x180cd
movq 0x28(%rbx), %rdi
movl 0x34(%rbx), %edx
movq %r13, %rsi
callq *0x10(%rbx)
testl %eax, %eax
je 0x17f77
cltq
addq %r13, %rax
movb (%r13), %r12b
movq 0x8(%rsp), %rcx
jmp 0x17f8d
movl $0x0, 0x30(%rbx)
movb $0x0, 0x38(%rbx)
xorl %r12d, %r12d
movq 0x8(%rsp), %rcx
movq %rcx, %rax
movq %rax, 0xc0(%rbx)
movq %rcx, 0xb8(%rbx)
cmpb $-0x80, %r12b
jbe 0x17fbc
cmpq %rax, %rcx
jae 0x1805c
leaq 0x1(%rcx), %rax
movq %rax, 0xb8(%rbx)
movb (%rcx), %al
jmp 0x180ab
testb %r12b, %r12b
je 0x180cd
movslq %ebp, %rax
leaq (%r15,%rax,4), %r14
movzbl %r12b, %r12d
xorl %r15d, %r15d
movq 0xb8(%rbx), %rax
cmpq 0xc0(%rbx), %rax
jae 0x17ff2
leaq 0x1(%rax), %rcx
movq %rcx, 0xb8(%rbx)
movb (%rax), %al
jmp 0x18041
cmpl $0x0, 0x30(%rbx)
je 0x1801a
movq 0x28(%rbx), %rdi
movl 0x34(%rbx), %edx
movq %r13, %rsi
callq *0x10(%rbx)
testl %eax, %eax
je 0x1801e
movslq %eax, %rcx
addq %r13, %rcx
movb (%r13), %al
movq 0x8(%rsp), %rdx
jmp 0x18033
xorl %eax, %eax
jmp 0x18041
movl $0x0, 0x30(%rbx)
movb $0x0, 0x38(%rbx)
xorl %eax, %eax
movq 0x8(%rsp), %rdx
movq %rdx, %rcx
movq %rcx, 0xc0(%rbx)
movq %rdx, 0xb8(%rbx)
movb %al, (%r14,%r15,4)
incq %r15
cmpl %r15d, %r12d
jne 0x17fd3
addl %r15d, %ebp
movq 0x30(%rsp), %r14
movq 0x10(%rsp), %r15
jmp 0x180cd
cmpl $0x0, 0x30(%rbx)
je 0x18084
movq 0x28(%rbx), %rdi
movl 0x34(%rbx), %edx
movq %r13, %rsi
callq *0x10(%rbx)
testl %eax, %eax
je 0x18088
movslq %eax, %rcx
addq %r13, %rcx
movb (%r13), %al
movq 0x8(%rsp), %rdx
jmp 0x1809d
xorl %eax, %eax
jmp 0x180ab
movl $0x0, 0x30(%rbx)
movb $0x0, 0x38(%rbx)
xorl %eax, %eax
movq 0x8(%rsp), %rdx
movq %rdx, %rcx
movq %rcx, 0xc0(%rbx)
movq %rdx, 0xb8(%rbx)
testb $0x7f, %r12b
je 0x180cd
movslq %ebp, %rcx
leaq (%r15,%rcx,4), %rcx
movzbl %r12b, %edx
andl $0x7f, %edx
xorl %esi, %esi
movb %al, (%rcx,%rsi,4)
incq %rsi
cmpl %esi, %edx
jne 0x180c1
addl %esi, %ebp
cmpl %r14d, %ebp
jl 0x17f29
movq 0x78(%rsp), %rax
incq %rax
incq %r15
cmpq $0x4, %rax
jne 0x17f1d
movq 0x50(%rsp), %r15
movq 0x28(%rsp), %r14
movq 0x38(%rsp), %rbp
movq 0x68(%rsp), %r12
movq %rbp, %rdi
movq %r14, %rsi
movl 0x1c(%rsp), %edx
callq 0x1e5c4
addq %r12, %rbp
addq $0x4, %r14
decq %r15
jne 0x180ff
movq 0x70(%rsp), %r12
incq %r12
movq 0x38(%rsp), %rax
addq 0x60(%rsp), %rax
movq %rax, 0x38(%rsp)
cmpq 0x58(%rsp), %r12
movq 0x28(%rsp), %r15
jne 0x17d12
jmp 0x18175
leaq 0x94ab(%rip), %rax      # 0x215f5
jmp 0x18153
leaq 0x94b9(%rip), %rax      # 0x2160c
movq %rax, 0xf28e(%rip)      # 0x273e8
xorl %r12d, %r12d
movq %r12, %rax
addq $0x498, %rsp            # imm = 0x498
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r15d, %r15d
movq %r15, %rdi
callq 0x83e0
movq 0x20(%rsp), %r12
jmp 0x1815d
movq %r15, 0x28(%rsp)
leaq 0x88(%rsp), %r15
movb %sil, (%r15)
movb %r14b, 0x1(%r15)
movb %bpl, 0x2(%r15)
movq %rbx, %rdi
callq 0x1a234
movb %al, 0x3(%r15)
movq 0x20(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movl 0x1c(%rsp), %r13d
movl %r13d, %edx
callq 0x1e5c4
movq 0x28(%rsp), %rdi
callq 0x83e0
xorl %r15d, %r15d
movl $0x1, %ebp
jmp 0x1820b
movq 0x20(%rsp), %rdi
callq 0x83e0
movq %r15, %rdi
callq 0x83e0
leaq 0x9437(%rip), %rax      # 0x21624
jmp 0x18153
movq %r15, %rax
incl %eax
xorl %ebp, %ebp
movq %rax, %r15
cmpl 0x40(%rsp), %eax
jge 0x1815d
cmpl %r14d, %ebp
jge 0x181f2
leaq 0x8c(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
movl $0x4, %edx
callq 0x1c7de
movl %r13d, %eax
movq 0x30(%rsp), %rdx
imull %edx, %eax
imull %r15d, %eax
cltq
leaq (%r12,%rax,4), %rax
movl %ebp, %ecx
imull %r13d, %ecx
movslq %ecx, %rcx
leaq (%rax,%rcx,4), %rdi
movq %r14, %rsi
movq %rdx, %r14
movl %r13d, %edx
callq 0x1e5c4
incl %ebp
jmp 0x18206