// File: /workspace/github_cpp_makefile_star2_O1/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, %rbp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x90(%rsp), %r12
movq %r12, %rsi
callq 0x37a3d
movabsq $0x4e41494441523f23, %rax # imm = 0x4E41494441523F23
xorq (%r12), %rax
movabsq $0x45434e41494441, %rcx # imm = 0x45434E41494441
xorq 0x3(%r12), %rcx
orq %rax, %rcx
je 0x2e314
movl $0x47523f23, %eax       # imm = 0x47523F23
xorl 0x90(%rsp), %eax
movl $0x454247, %ecx         # imm = 0x454247
xorl 0x93(%rsp), %ecx
orl %eax, %ecx
je 0x2e314
leaq 0x11adc(%rip), %rax     # 0x3fdeb
jmp 0x2e43b
leaq 0x90(%rsp), %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x37a3d
cmpb $0x0, (%r12)
je 0x2e42f
movq %r13, 0x8(%rsp)
movl %r15d, 0x38(%rsp)
xorl %r15d, %r15d
movl $0x1, %r13d
leaq 0x90(%rsp), %r12
movdqu 0x97(%rsp), %xmm0
pcmpeqb 0xef72(%rip), %xmm0     # 0x3d2d0
movdqa 0x90(%rsp), %xmm1
pcmpeqb 0xef71(%rip), %xmm1     # 0x3d2e0
pand %xmm0, %xmm1
pmovmskb %xmm1, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
cmovel %r13d, %r15d
movq %rbx, %rdi
movq %r12, %rsi
callq 0x37a3d
cmpb $0x0, 0x90(%rsp)
jne 0x2e34d
movq %r12, 0x28(%rsp)
testl %r15d, %r15d
je 0x2e434
movq %rbx, %rdi
movq %r12, %rsi
callq 0x37a3d
movl $0x592d, %eax           # imm = 0x592D
xorl 0x90(%rsp), %eax
movq %r12, 0x28(%rsp)
movzbl 0x92(%rsp), %ecx
xorl $0x20, %ecx
orw %ax, %cx
jne 0x2e426
leaq 0x93(%rsp), %rdi
leaq 0x28(%rsp), %r12
movq %rdi, (%r12)
movq %r12, %rsi
movl $0xa, %edx
callq 0x6520
movq %rax, %r15
movq (%r12), %r12
decq %r12
cmpb $0x20, 0x1(%r12)
leaq 0x1(%r12), %r12
je 0x2e3f7
movq %r12, 0x28(%rsp)
leaq 0x11a29(%rip), %rsi     # 0x3fe39
movl $0x3, %edx
movq %r12, %rdi
callq 0x61c0
testl %eax, %eax
movq 0x8(%rsp), %r13
je 0x2e45a
leaq 0x119f4(%rip), %rax     # 0x3fe21
jmp 0x2e43b
movq %r12, 0x28(%rsp)
leaq 0x119cf(%rip), %rax     # 0x3fe0a
movq %rax, 0x210a6(%rip)     # 0x4f4e8
xorl %r15d, %r15d
movq %r15, %rax
addq $0x498, %rsp            # imm = 0x498
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq $0x3, %r12
movq %r12, 0x28(%rsp)
movq %r12, %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x6520
movq %rax, %r12
movl %r12d, (%r14)
movl %r15d, (%rbp)
testq %r13, %r13
je 0x2e489
movl $0x3, (%r13)
movl 0x38(%rsp), %eax
testl %eax, %eax
movl $0x3, %ebp
cmovnel %eax, %ebp
movl %r12d, %eax
orl %r15d, %eax
js 0x2ea80
testl %r15d, %r15d
je 0x2e4bb
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
xorl %edx, %edx
divl %r15d
cmpl %r12d, %eax
jl 0x2ea80
movl %r12d, %ecx
imull %r15d, %ecx
movl %ecx, %eax
orl %ebp, %eax
js 0x2ea80
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
xorl %edx, %edx
divl %ebp
cmpl %ecx, %eax
jl 0x2ea80
imull %ebp, %ecx
cmpl $0x20000000, %ecx       # imm = 0x20000000
jae 0x2ea80
movl %r12d, %edi
movq %r15, 0x38(%rsp)
movl %r15d, %esi
movl %ebp, %edx
callq 0x37c61
testq %rax, %rax
je 0x2eb30
movq %rax, %r15
movl %ebp, 0x14(%rsp)
leal -0x8000(%r12), %eax
xorl %ebp, %ebp
cmpl $0xffff8008, %eax       # imm = 0xFFFF8008
jb 0x2eb3e
movq 0x38(%rsp), %rcx
testl %ecx, %ecx
jle 0x2eaaa
movq %r12, %rdx
leaq 0x38(%rbx), %r12
leaq 0x39(%rbx), %rax
movq %rax, 0x20(%rsp)
leal (,%rdx,4), %eax
movq %rax, 0x78(%rsp)
movslq 0x14(%rsp), %rbp
movl %edx, %esi
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andq %rax, %rcx
movq %rcx, 0x68(%rsp)
movq %rdx, 0x18(%rsp)
andq %rax, %rdx
movq %rdx, 0x60(%rsp)
imulq %rbp, %rsi
shlq $0x2, %rsi
movq %rsi, 0x70(%rsp)
shlq $0x2, %rbp
movq $0x0, 0x50(%rsp)
movq %r15, 0x40(%rsp)
xorl %r14d, %r14d
movq %rbp, 0x80(%rsp)
movq 0xb8(%rbx), %rax
cmpq 0xc0(%rbx), %rax
jb 0x2e5fc
cmpl $0x0, 0x30(%rbx)
je 0x2e5d3
movq 0x28(%rbx), %rdi
movl 0x34(%rbx), %edx
movq %r12, %rsi
callq *0x10(%rbx)
testl %eax, %eax
je 0x2e5d7
movq %r12, 0xb8(%rbx)
cltq
addq %r12, %rax
movq %rax, 0xc0(%rbx)
jmp 0x2e5f5
xorl %edx, %edx
jmp 0x2e609
movl $0x0, 0x30(%rbx)
movq %r12, 0xb8(%rbx)
movq 0x20(%rsp), %rax
movq %rax, 0xc0(%rbx)
movb $0x0, 0x38(%rbx)
movq 0xb8(%rbx), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0xb8(%rbx)
movb (%rax), %dl
movq 0xb8(%rbx), %rax
cmpq 0xc0(%rbx), %rax
jb 0x2e67a
cmpl $0x0, 0x30(%rbx)
je 0x2e649
movl %edx, 0x8(%rsp)
movq 0x28(%rbx), %rdi
movl 0x34(%rbx), %edx
movq %r12, %rsi
callq *0x10(%rbx)
testl %eax, %eax
je 0x2e651
movq %r12, 0xb8(%rbx)
cltq
addq %r12, %rax
movq %rax, 0xc0(%rbx)
jmp 0x2e66f
movq %r14, %r13
xorl %r14d, %r14d
jmp 0x2e68b
movl $0x0, 0x30(%rbx)
movq %r12, 0xb8(%rbx)
movq 0x20(%rsp), %rax
movq %rax, 0xc0(%rbx)
movb $0x0, 0x38(%rbx)
movl 0x8(%rsp), %edx
movq 0xb8(%rbx), %rax
movq %r14, %r13
leaq 0x1(%rax), %rcx
movq %rcx, 0xb8(%rbx)
movb (%rax), %r14b
movq 0xb8(%rbx), %rax
cmpq 0xc0(%rbx), %rax
jb 0x2e6f8
cmpl $0x0, 0x30(%rbx)
je 0x2e6cb
movl %edx, 0x8(%rsp)
movq 0x28(%rbx), %rdi
movl 0x34(%rbx), %edx
movq %r12, %rsi
callq *0x10(%rbx)
testl %eax, %eax
je 0x2e6cf
movq %r12, 0xb8(%rbx)
cltq
addq %r12, %rax
movq %rax, 0xc0(%rbx)
jmp 0x2e6ed
xorl %ebp, %ebp
jmp 0x2e706
movl $0x0, 0x30(%rbx)
movq %r12, 0xb8(%rbx)
movq 0x20(%rsp), %rax
movq %rax, 0xc0(%rbx)
movb $0x0, 0x38(%rbx)
movq 0xb8(%rbx), %rax
movl 0x8(%rsp), %edx
leaq 0x1(%rax), %rcx
movq %rcx, 0xb8(%rbx)
movb (%rax), %bpl
cmpb $0x2, %dl
jne 0x2eac3
cmpb $0x2, %r14b
jne 0x2eac3
testb %bpl, %bpl
js 0x2eac3
movq 0xb8(%rbx), %rax
cmpq 0xc0(%rbx), %rax
jb 0x2e787
cmpl $0x0, 0x30(%rbx)
je 0x2e75e
movq 0x28(%rbx), %rdi
movl 0x34(%rbx), %edx
movq %r12, %rsi
callq *0x10(%rbx)
testl %eax, %eax
je 0x2e762
movq %r12, 0xb8(%rbx)
cltq
addq %r12, %rax
movq %rax, 0xc0(%rbx)
jmp 0x2e780
xorl %eax, %eax
jmp 0x2e795
movl $0x0, 0x30(%rbx)
movq %r12, 0xb8(%rbx)
movq 0x20(%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 %bpl, %ecx
shll $0x8, %ecx
orl %eax, %ecx
cmpl 0x18(%rsp), %ecx
jne 0x2eb0c
testq %r13, %r13
jne 0x2e7d2
cmpl $0x1fffffff, 0x18(%rsp) # imm = 0x1FFFFFFF
jle 0x2e7bc
xorl %r13d, %r13d
jmp 0x2e7c9
movq 0x78(%rsp), %rdi
callq 0x64c0
movq %rax, %r13
testq %r13, %r13
je 0x2eb28
movq %r13, 0x30(%rsp)
movq %r13, 0x48(%rsp)
movq $0x0, 0x58(%rsp)
cmpl $0x0, 0x18(%rsp)
jle 0x2e9f2
xorl %ebp, %ebp
movq 0x18(%rsp), %rax
movl %eax, %r14d
movq 0xb8(%rbx), %rax
cmpq 0xc0(%rbx), %rax
movl %ebp, 0x8(%rsp)
jb 0x2e864
cmpl $0x0, 0x30(%rbx)
je 0x2e83a
movq 0x28(%rbx), %rdi
movl 0x34(%rbx), %edx
movq %r12, %rsi
callq *0x10(%rbx)
testl %eax, %eax
je 0x2e83f
movq %r12, 0xb8(%rbx)
cltq
addq %r12, %rax
movq %rax, 0xc0(%rbx)
jmp 0x2e85d
xorl %r13d, %r13d
jmp 0x2e872
movl $0x0, 0x30(%rbx)
movq %r12, 0xb8(%rbx)
movq 0x20(%rsp), %rax
movq %rax, 0xc0(%rbx)
movb $0x0, 0x38(%rbx)
movq 0xb8(%rbx), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0xb8(%rbx)
movb (%rax), %r13b
movzbl %r13b, %ebp
cmpb $-0x7f, %bpl
jb 0x2e8c7
movq 0xb8(%rbx), %rax
cmpq 0xc0(%rbx), %rax
jb 0x2e99c
cmpl $0x0, 0x30(%rbx)
je 0x2e973
movq 0x28(%rbx), %rdi
movl 0x34(%rbx), %edx
movq %r12, %rsi
callq *0x10(%rbx)
testl %eax, %eax
je 0x2e977
movq %r12, 0xb8(%rbx)
cltq
addq %r12, %rax
movq %rax, 0xc0(%rbx)
jmp 0x2e995
cmpl %ebp, %r14d
jb 0x2ea8c
testl %ebp, %ebp
je 0x2e9dd
movslq 0x8(%rsp), %rax
movq 0x48(%rsp), %rcx
leaq (%rcx,%rax,4), %r14
movl %ebp, %r13d
xorl %ebp, %ebp
movq 0xb8(%rbx), %rax
cmpq 0xc0(%rbx), %rax
jb 0x2e950
cmpl $0x0, 0x30(%rbx)
je 0x2e927
movq 0x28(%rbx), %rdi
movl 0x34(%rbx), %edx
movq %r12, %rsi
callq *0x10(%rbx)
testl %eax, %eax
je 0x2e92b
movq %r12, 0xb8(%rbx)
cltq
addq %r12, %rax
movq %rax, 0xc0(%rbx)
jmp 0x2e949
xorl %eax, %eax
jmp 0x2e95d
movl $0x0, 0x30(%rbx)
movq %r12, 0xb8(%rbx)
movq 0x20(%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, (%r14,%rbp,4)
incq %rbp
cmpl %ebp, %r13d
jne 0x2e8eb
movl 0x8(%rsp), %eax
addl %ebp, %eax
movl %eax, %ebp
jmp 0x2e9e1
xorl %eax, %eax
jmp 0x2e9a9
movl $0x0, 0x30(%rbx)
movq %r12, 0xb8(%rbx)
movq 0x20(%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
andl $0x7f, %ebp
cmpl %ebp, %r14d
jb 0x2ea8c
andb $0x7f, %r13b
je 0x2e9dd
movslq 0x8(%rsp), %rcx
movq 0x48(%rsp), %rdx
leaq (%rdx,%rcx,4), %rcx
xorl %edx, %edx
movb %al, (%rcx,%rdx,4)
incq %rdx
cmpl %edx, %ebp
jne 0x2e9cb
movl 0x8(%rsp), %ebp
addl %edx, %ebp
jmp 0x2e9e1
movl 0x8(%rsp), %ebp
movq 0x18(%rsp), %rax
movl %eax, %r14d
subl %ebp, %r14d
jg 0x2e7fa
movq 0x58(%rsp), %rcx
incq %rcx
incq 0x48(%rsp)
movq %rcx, 0x58(%rsp)
cmpq $0x4, %rcx
jne 0x2e7e5
movq %r12, 0x8(%rsp)
movq 0x60(%rsp), %r13
movq 0x30(%rsp), %rbp
movq 0x40(%rsp), %r14
cmpl $0x0, 0x18(%rsp)
movl 0x14(%rsp), %r12d
jle 0x2ea4d
movq %r14, %rdi
movq %rbp, %rsi
movl %r12d, %edx
callq 0x37cb1
addq 0x80(%rsp), %r14
addq $0x4, %rbp
decq %r13
jne 0x2ea2e
movq 0x50(%rsp), %rcx
incq %rcx
movq 0x40(%rsp), %rax
addq 0x70(%rsp), %rax
movq %rax, 0x40(%rsp)
movq %rcx, 0x50(%rsp)
cmpq 0x68(%rsp), %rcx
movq 0x30(%rsp), %r14
movq 0x8(%rsp), %r12
jne 0x2e597
jmp 0x2eaad
leaq 0x10c93(%rip), %rax     # 0x3f71a
jmp 0x2e43b
movq %r15, %rdi
callq 0x6490
movq 0x30(%rsp), %rdi
callq 0x6490
leaq 0x1154f(%rip), %rax     # 0x3fff4
jmp 0x2e43b
xorl %r14d, %r14d
testq %r14, %r14
je 0x2e445
movq %r14, %rdi
callq 0x6490
jmp 0x2e445
leaq 0x88(%rsp), %r12
movb %dl, (%r12)
movb %r14b, 0x1(%r12)
movb %bpl, 0x2(%r12)
movq %rbx, %rdi
callq 0x31e20
movb %al, 0x3(%r12)
movq %r15, %rdi
movq %r12, %rsi
movl 0x14(%rsp), %edx
callq 0x37cb1
movq %r13, %rdi
callq 0x6490
xorl %ebp, %ebp
movl $0x1, %r13d
movq 0x18(%rsp), %r12
jmp 0x2eb53
movq %r15, %rdi
callq 0x6490
movq %r13, %rdi
callq 0x6490
leaq 0x1131a(%rip), %rax     # 0x3fe3d
jmp 0x2e43b
movq %r15, %rdi
callq 0x6490
leaq 0x10bed(%rip), %rax     # 0x3f724
jmp 0x2e43b
incl %ebp
movl $0x0, %r13d
cmpl 0x38(%rsp), %ebp
jge 0x2e445
cmpl %r12d, %r13d
jge 0x2eb3c
leaq 0x8c(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
movl $0x4, %edx
callq 0x3490f
movl 0x14(%rsp), %edx
movl %edx, %eax
imull %r12d, %eax
imull %ebp, %eax
cltq
leaq (%r15,%rax,4), %rax
movl %r13d, %ecx
imull %edx, %ecx
movslq %ecx, %rcx
leaq (%rax,%rcx,4), %rdi
movq %r14, %rsi
callq 0x37cb1
incl %r13d
jmp 0x2eb4e