// File: /workspace/github_cpp_makefile_star2_O3/alan0201tw[P]RayTracer/include/stb_image.h
// Function: stbi__hdr_load(stbi__context*, int*, int*, int*, int, stbi__result_info*)
static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)
{
   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;
   const char *headerToken;
   STBI_NOTUSED(ri);

   // Check identifier
   headerToken = stbi__hdr_gettoken(s,buffer);
   if (strcmp(headerToken, "#?RADIANCE") != 0 && strcmp(headerToken, "#?RGBE") != 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;

   if (!stbi__mad4sizes_valid(width, height, req_comp, sizeof(float), 0))
      return stbi__errpf("too large", "HDR image is too large");

   // Read data
   hdr_data = (float *) stbi__malloc_mad4(width, height, req_comp, sizeof(float), 0);
   if (!hdr_data)
      return stbi__errpf("outofmem", "Out of memory");

   // 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_mad2(width, 4, 0);
            if (!scanline) {
               STBI_FREE(hdr_data);
               return stbi__errpf("outofmem", "Out of memory");
            }
         }

         for (k = 0; k < 4; ++k) {
            int nleft;
            i = 0;
            while ((nleft = width - i) > 0) {
               count = stbi__get8(s);
               if (count > 128) {
                  // Run
                  value = stbi__get8(s);
                  count -= 128;
                  if (count > nleft) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); }
                  for (z = 0; z < count; ++z)
                     scanline[i++ * 4 + k] = value;
               } else {
                  // Dump
                  if (count > nleft) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); }
                  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);
      }
      if (scanline)
         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, %r14
movq %rsi, %rbp
movq %rdi, %rbx
leaq 0x90(%rsp), %r12
movq %r12, %rsi
callq 0x37497
movabsq $0x4e41494441523f23, %rax # imm = 0x4E41494441523F23
xorq (%r12), %rax
movabsq $0x45434e41494441, %rcx # imm = 0x45434E41494441
xorq 0x3(%r12), %rcx
orq %rax, %rcx
je 0x2e7d8
movl $0x47523f23, %eax       # imm = 0x47523F23
xorl 0x90(%rsp), %eax
movl $0x454247, %ecx         # imm = 0x454247
xorl 0x93(%rsp), %ecx
orl %eax, %ecx
je 0x2e7d8
leaq 0x11880(%rip), %rax     # 0x40053
jmp 0x2ee86
movq %rbp, 0x28(%rsp)
movq %r14, 0x10(%rsp)
leaq 0x90(%rsp), %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x37497
cmpb $0x0, (%r12)
je 0x2ee76
movq %r13, %r14
movl %r15d, %ebp
xorl %r15d, %r15d
movl $0x1, %r13d
leaq 0x90(%rsp), %r12
movdqu 0x97(%rsp), %xmm0
pcmpeqb 0xece8(%rip), %xmm0     # 0x3d510
movdqa 0x90(%rsp), %xmm1
pcmpeqb 0xece7(%rip), %xmm1     # 0x3d520
pand %xmm0, %xmm1
pmovmskb %xmm1, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
cmovel %r13d, %r15d
movq %rbx, %rdi
movq %r12, %rsi
callq 0x37497
cmpb $0x0, 0x90(%rsp)
jne 0x2e817
testl %r15d, %r15d
je 0x2ee76
movl %ebp, %r15d
movq %r14, %rbp
leaq 0x90(%rsp), %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x37497
movl $0x592d, %eax           # imm = 0x592D
xorl (%r12), %eax
movzbl 0x2(%r12), %ecx
xorl $0x20, %ecx
orw %ax, %cx
jne 0x2ee7f
leaq 0x93(%rsp), %rdi
leaq 0x80(%rsp), %r12
movq %rdi, (%r12)
movq %r12, %rsi
movl $0xa, %edx
callq 0x6520
movq %rax, %r13
movq (%r12), %rdi
addq $0x2, %rdi
movb -0x2(%rdi), %al
incq %rdi
cmpb $0x20, %al
je 0x2e8c8
cmpb $0x2b, %al
jne 0x2ee7f
cmpb $0x58, -0x2(%rdi)
jne 0x2ee7f
cmpb $0x20, -0x1(%rdi)
jne 0x2ee7f
movq %rdi, 0x80(%rsp)
xorl %esi, %esi
movl $0xa, %edx
callq 0x6520
movq %rax, %r14
movq 0x28(%rsp), %rcx
movl %r14d, (%rcx)
movq 0x10(%rsp), %rax
movl %r13d, (%rax)
testq %rbp, %rbp
je 0x2e921
movl $0x3, (%rbp)
testl %r15d, %r15d
movl $0x3, %ebp
cmovnel %r15d, %ebp
movl %r14d, %edi
movl %r13d, %esi
movl %ebp, %edx
callq 0x376bb
testl %eax, %eax
je 0x2eea5
movl %r14d, %edi
movl %r13d, %esi
movl %ebp, %edx
callq 0x37717
testq %rax, %rax
je 0x2ef37
movq %rax, %r15
movl %ebp, 0x1c(%rsp)
leal -0x8000(%r14), %eax
xorl %ebp, %ebp
cmpl $0xffff8008, %eax       # imm = 0xFFFF8008
movq %r14, 0x28(%rsp)
jb 0x2ef45
testl %r13d, %r13d
jle 0x2ee90
movq %r13, %rcx
leaq 0x38(%rbx), %r13
leaq 0x39(%rbx), %rax
movq %rax, 0x10(%rsp)
leal (,%r14,4), %eax
movq %rax, 0x70(%rsp)
movslq 0x1c(%rsp), %r12
movl %r14d, %edx
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rcx, 0x48(%rsp)
andq %rax, %rcx
movq %rcx, 0x58(%rsp)
andq %rax, %r14
movq %r14, 0x50(%rsp)
imulq %r12, %rdx
shlq $0x2, %rdx
movq %rdx, 0x60(%rsp)
shlq $0x2, %r12
xorl %r14d, %r14d
movq %r15, 0x30(%rsp)
movq $0x0, 0x20(%rsp)
movq %r12, 0x78(%rsp)
movq 0xb8(%rbx), %rcx
movq 0xc0(%rbx), %rax
cmpq %rax, %rcx
jae 0x2ea0d
leaq 0x1(%rcx), %rdx
movq %rdx, 0xb8(%rbx)
movb (%rcx), %sil
movq %rdx, %rcx
jmp 0x2ea5b
cmpl $0x0, 0x30(%rbx)
je 0x2ea34
movq 0x28(%rbx), %rdi
movl 0x34(%rbx), %edx
movq %r13, %rsi
callq *0x10(%rbx)
testl %eax, %eax
je 0x2ea38
cltq
addq %r13, %rax
movb (%r13), %sil
movq 0x10(%rsp), %rcx
jmp 0x2ea4d
xorl %esi, %esi
jmp 0x2ea5b
movl $0x0, 0x30(%rbx)
movb $0x0, 0x38(%rbx)
xorl %esi, %esi
movq 0x10(%rsp), %rcx
movq %rcx, %rax
movq %rax, 0xc0(%rbx)
movq %rcx, 0xb8(%rbx)
cmpq %rax, %rcx
jae 0x2ea73
leaq 0x1(%rcx), %rdx
movq %rdx, 0xb8(%rbx)
movb (%rcx), %bpl
movq %rdx, %rcx
jmp 0x2eac9
cmpl $0x0, 0x30(%rbx)
je 0x2ea9e
movl %esi, 0xc(%rsp)
movq 0x28(%rbx), %rdi
movl 0x34(%rbx), %edx
movq %r13, %rsi
callq *0x10(%rbx)
testl %eax, %eax
je 0x2eaa2
cltq
addq %r13, %rax
movb (%r13), %bpl
movq 0x10(%rsp), %rcx
jmp 0x2eab7
xorl %ebp, %ebp
jmp 0x2eac9
movl $0x0, 0x30(%rbx)
movb $0x0, 0x38(%rbx)
xorl %ebp, %ebp
movq 0x10(%rsp), %rcx
movq %rcx, %rax
movq %rax, 0xc0(%rbx)
movq %rcx, 0xb8(%rbx)
movl 0xc(%rsp), %esi
cmpq %rax, %rcx
movq %r14, 0x68(%rsp)
jae 0x2eae6
leaq 0x1(%rcx), %rdx
movq %rdx, 0xb8(%rbx)
movb (%rcx), %r14b
movq %rdx, %rcx
jmp 0x2eb3c
cmpl $0x0, 0x30(%rbx)
je 0x2eb10
movl %esi, %r12d
movq 0x28(%rbx), %rdi
movl 0x34(%rbx), %edx
movq %r13, %rsi
callq *0x10(%rbx)
testl %eax, %eax
je 0x2eb15
cltq
addq %r13, %rax
movb (%r13), %r14b
movq 0x10(%rsp), %rcx
jmp 0x2eb2b
xorl %r14d, %r14d
jmp 0x2eb3c
movl $0x0, 0x30(%rbx)
movb $0x0, 0x38(%rbx)
xorl %r14d, %r14d
movq 0x10(%rsp), %rcx
movq %rcx, %rax
movl %r12d, %esi
movq %rax, 0xc0(%rbx)
movq %rcx, 0xb8(%rbx)
cmpb $0x2, %sil
jne 0x2eec9
cmpb $0x2, %bpl
jne 0x2eec9
testb %r14b, %r14b
js 0x2eec9
cmpq %rax, %rcx
jae 0x2eb6d
leaq 0x1(%rcx), %rax
movq %rax, 0xb8(%rbx)
movb (%rcx), %al
jmp 0x2ebbc
cmpl $0x0, 0x30(%rbx)
je 0x2eb95
movq 0x28(%rbx), %rdi
movl 0x34(%rbx), %edx
movq %r13, %rsi
callq *0x10(%rbx)
testl %eax, %eax
je 0x2eb99
movslq %eax, %rcx
addq %r13, %rcx
movb (%r13), %al
movq 0x10(%rsp), %rdx
jmp 0x2ebae
xorl %eax, %eax
jmp 0x2ebbc
movl $0x0, 0x30(%rbx)
movb $0x0, 0x38(%rbx)
xorl %eax, %eax
movq 0x10(%rsp), %rdx
movq %rdx, %rcx
movq %rcx, 0xc0(%rbx)
movq %rdx, 0xb8(%rbx)
movzbl %r14b, %ecx
shll $0x8, %ecx
movzbl %al, %eax
orl %ecx, %eax
movq 0x28(%rsp), %r14
cmpl %r14d, %eax
jne 0x2ef11
movq 0x20(%rsp), %rax
testq %rax, %rax
jne 0x2ebf3
movq 0x70(%rsp), %rdi
callq 0x64c0
testq %rax, %rax
je 0x2ef2f
movq %rax, 0x20(%rsp)
movq %rax, 0x38(%rsp)
movq $0x0, 0x40(%rsp)
xorl %r12d, %r12d
movl %r14d, %ebp
movq 0xb8(%rbx), %rdx
movq 0xc0(%rbx), %rax
cmpq %rax, %rdx
jae 0x2ec34
movl %r12d, 0xc(%rsp)
leaq 0x1(%rdx), %rcx
movq %rcx, 0xb8(%rbx)
movb (%rdx), %r14b
jmp 0x2ec88
cmpl $0x0, 0x30(%rbx)
je 0x2edf4
movq 0x28(%rbx), %rdi
movl 0x34(%rbx), %edx
movq %r13, %rsi
callq *0x10(%rbx)
testl %eax, %eax
je 0x2ec5f
cltq
addq %r13, %rax
movb (%r13), %r14b
movq 0x10(%rsp), %rcx
jmp 0x2ec75
movl $0x0, 0x30(%rbx)
movb $0x0, 0x38(%rbx)
xorl %r14d, %r14d
movq 0x10(%rsp), %rcx
movq %rcx, %rax
movl %r12d, 0xc(%rsp)
movq %rax, 0xc0(%rbx)
movq %rcx, 0xb8(%rbx)
movzbl %r14b, %r12d
cmpb $-0x7f, %r12b
jb 0x2ecad
cmpq %rax, %rcx
jae 0x2ed5e
leaq 0x1(%rcx), %rax
movq %rax, 0xb8(%rbx)
movb (%rcx), %al
jmp 0x2edad
cmpl %r12d, %ebp
jb 0x2eeae
testl %r12d, %r12d
je 0x2edea
movslq 0xc(%rsp), %rax
movq 0x38(%rsp), %rcx
leaq (%rcx,%rax,4), %r14
movl %r12d, %r12d
xorl %ebp, %ebp
movq 0xb8(%rbx), %rax
cmpq 0xc0(%rbx), %rax
jae 0x2ecf1
leaq 0x1(%rax), %rcx
movq %rcx, 0xb8(%rbx)
movb (%rax), %al
jmp 0x2ed40
cmpl $0x0, 0x30(%rbx)
je 0x2ed19
movq 0x28(%rbx), %rdi
movl 0x34(%rbx), %edx
movq %r13, %rsi
callq *0x10(%rbx)
testl %eax, %eax
je 0x2ed1d
movslq %eax, %rcx
addq %r13, %rcx
movb (%r13), %al
movq 0x10(%rsp), %rdx
jmp 0x2ed32
xorl %eax, %eax
jmp 0x2ed40
movl $0x0, 0x30(%rbx)
movb $0x0, 0x38(%rbx)
xorl %eax, %eax
movq 0x10(%rsp), %rdx
movq %rdx, %rcx
movq %rcx, 0xc0(%rbx)
movq %rdx, 0xb8(%rbx)
movb %al, (%r14,%rbp,4)
incq %rbp
cmpl %ebp, %r12d
jne 0x2ecd2
movl 0xc(%rsp), %r12d
addl %ebp, %r12d
movq 0x28(%rsp), %r14
jmp 0x2edf4
cmpl $0x0, 0x30(%rbx)
je 0x2ed86
movq 0x28(%rbx), %rdi
movl 0x34(%rbx), %edx
movq %r13, %rsi
callq *0x10(%rbx)
testl %eax, %eax
je 0x2ed8a
movslq %eax, %rcx
addq %r13, %rcx
movb (%r13), %al
movq 0x10(%rsp), %rdx
jmp 0x2ed9f
xorl %eax, %eax
jmp 0x2edad
movl $0x0, 0x30(%rbx)
movb $0x0, 0x38(%rbx)
xorl %eax, %eax
movq 0x10(%rsp), %rdx
movq %rdx, %rcx
movq %rcx, 0xc0(%rbx)
movq %rdx, 0xb8(%rbx)
andl $0x7f, %r12d
cmpl %r12d, %ebp
jb 0x2eeae
andb $0x7f, %r14b
je 0x2edea
movslq 0xc(%rsp), %rcx
movq 0x38(%rsp), %rdx
leaq (%rdx,%rcx,4), %rcx
xorl %edx, %edx
movq 0x28(%rsp), %r14
movb %al, (%rcx,%rdx,4)
incq %rdx
cmpl %edx, %r12d
jne 0x2edd5
movl 0xc(%rsp), %r12d
addl %edx, %r12d
jmp 0x2edf4
movq 0x28(%rsp), %r14
movl 0xc(%rsp), %r12d
movl %r14d, %ebp
subl %r12d, %ebp
jg 0x2ec0c
movq 0x40(%rsp), %rcx
incq %rcx
incq 0x38(%rsp)
movq %rcx, 0x40(%rsp)
cmpq $0x4, %rcx
jne 0x2ec06
movq 0x50(%rsp), %r14
movq 0x20(%rsp), %r12
movq 0x30(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
movl 0x1c(%rsp), %edx
callq 0x37748
addq 0x78(%rsp), %rbp
addq $0x4, %r12
decq %r14
jne 0x2ee2b
movq 0x68(%rsp), %r14
incq %r14
movq 0x30(%rsp), %rax
addq 0x60(%rsp), %rax
movq %rax, 0x30(%rsp)
cmpq 0x58(%rsp), %r14
jne 0x2e9e7
movq 0x20(%rsp), %rdi
callq 0x6490
jmp 0x2ee90
leaq 0x111f5(%rip), %rax     # 0x40072
jmp 0x2ee86
leaq 0x11203(%rip), %rax     # 0x40089
movq %rax, 0x2063b(%rip)     # 0x4f4c8
xorl %r15d, %r15d
movq %r15, %rax
addq $0x498, %rsp            # imm = 0x498
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x10ad6(%rip), %rax     # 0x3f982
jmp 0x2ee86
movq %r15, %rdi
callq 0x6490
movq 0x20(%rsp), %rdi
callq 0x6490
leaq 0x11391(%rip), %rax     # 0x40258
jmp 0x2ee86
leaq 0x88(%rsp), %r13
movb %sil, (%r13)
movb %bpl, 0x1(%r13)
movb %r14b, 0x2(%r13)
movq %rbx, %rdi
callq 0x31aa8
movb %al, 0x3(%r13)
movq %r15, %rdi
movq %r13, %rsi
movl 0x1c(%rsp), %edx
callq 0x37748
movq 0x20(%rsp), %rdi
callq 0x6490
xorl %ebp, %ebp
movl $0x1, %r12d
movq 0x48(%rsp), %r13
jmp 0x2ef59
movq %r15, %rdi
callq 0x6490
movq 0x20(%rsp), %rdi
callq 0x6490
leaq 0x11177(%rip), %rax     # 0x400a1
jmp 0x2ee86
movq %r15, %rdi
callq 0x6490
leaq 0x10a4e(%rip), %rax     # 0x3f98c
jmp 0x2ee86
incl %ebp
movl $0x0, %r12d
cmpl %r13d, %ebp
jge 0x2ee90
cmpl %r14d, %r12d
jge 0x2ef43
leaq 0x8c(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
movl $0x4, %edx
callq 0x345e4
movl 0x1c(%rsp), %edx
movl %edx, %eax
movq 0x28(%rsp), %r8
imull %r8d, %eax
imull %ebp, %eax
cltq
leaq (%r15,%rax,4), %rax
movl %r12d, %ecx
imull %edx, %ecx
movslq %ecx, %rcx
leaq (%rax,%rcx,4), %rdi
movq %r14, %rsi
movq %r8, %r14
callq 0x37748
incl %r12d
jmp 0x2ef54