// File: /workspace/github_c_makefile_star2_O0/zhiyb[P]png2tlg/./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
movq %rsp, %rbp
subq $0x4a0, %rsp            # imm = 0x4A0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movq %r9, -0x38(%rbp)
movl $0x0, -0x44c(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x440(%rbp), %rsi
callq 0x1ca60
movq %rax, -0x490(%rbp)
movq -0x490(%rbp), %rdi
leaq 0x16841(%rip), %rsi     # 0x20ff3
callq 0x2310
cmpl $0x0, %eax
je 0xa7f4
movq -0x490(%rbp), %rdi
leaq 0x16834(%rip), %rsi     # 0x20ffe
callq 0x2310
cmpl $0x0, %eax
je 0xa7f4
leaq 0x1682a(%rip), %rdi     # 0x21005
callq 0x2680
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, -0x8(%rbp)
jmp 0xaf53
jmp 0xa7f6
movq -0x10(%rbp), %rdi
leaq -0x440(%rbp), %rsi
callq 0x1ca60
movq %rax, -0x448(%rbp)
movq -0x448(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0xa81e
jmp 0xa842
movq -0x448(%rbp), %rdi
leaq 0x167e1(%rip), %rsi     # 0x2100d
callq 0x2310
cmpl $0x0, %eax
jne 0xa840
movl $0x1, -0x44c(%rbp)
jmp 0xa7f6
cmpl $0x0, -0x44c(%rbp)
jne 0xa86b
leaq 0x167d2(%rip), %rdi     # 0x21024
callq 0x2680
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, -0x8(%rbp)
jmp 0xaf53
movq -0x10(%rbp), %rdi
leaq -0x440(%rbp), %rsi
callq 0x1ca60
movq %rax, -0x448(%rbp)
movq -0x448(%rbp), %rdi
leaq 0x167a7(%rip), %rsi     # 0x21037
movl $0x3, %edx
callq 0x20e0
cmpl $0x0, %eax
je 0xa8bf
leaq 0x16795(%rip), %rdi     # 0x2103b
callq 0x2680
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, -0x8(%rbp)
jmp 0xaf53
movq -0x448(%rbp), %rax
addq $0x3, %rax
movq %rax, -0x448(%rbp)
movq -0x448(%rbp), %rdi
leaq -0x448(%rbp), %rsi
movl $0xa, %edx
callq 0x2320
movl %eax, -0x454(%rbp)
movq -0x448(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x20, %eax
jne 0xa912
movq -0x448(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x448(%rbp)
jmp 0xa8ef
movq -0x448(%rbp), %rdi
leaq 0x16733(%rip), %rsi     # 0x21053
movl $0x3, %edx
callq 0x20e0
cmpl $0x0, %eax
je 0xa94f
leaq 0x16705(%rip), %rdi     # 0x2103b
callq 0x2680
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, -0x8(%rbp)
jmp 0xaf53
movq -0x448(%rbp), %rax
addq $0x3, %rax
movq %rax, -0x448(%rbp)
movq -0x448(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x2320
movl %eax, -0x450(%rbp)
movl -0x450(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movl -0x454(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
cmpq $0x0, -0x28(%rbp)
je 0xa9a5
movq -0x28(%rbp), %rax
movl $0x3, (%rax)
cmpl $0x0, -0x2c(%rbp)
jne 0xa9b2
movl $0x3, -0x2c(%rbp)
movl -0x450(%rbp), %edi
movl -0x454(%rbp), %esi
movl -0x2c(%rbp), %edx
movl $0x4, %ecx
xorl %r8d, %r8d
callq 0x1cb40
cmpl $0x0, %eax
jne 0xa9f3
leaq 0x15f5a(%rip), %rdi     # 0x20934
callq 0x2680
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, -0x8(%rbp)
jmp 0xaf53
movl -0x450(%rbp), %edi
movl -0x454(%rbp), %esi
movl -0x2c(%rbp), %edx
movl $0x4, %ecx
xorl %r8d, %r8d
callq 0x1cbe0
movq %rax, -0x468(%rbp)
cmpq $0x0, -0x468(%rbp)
jne 0xaa40
leaq 0x15f17(%rip), %rdi     # 0x2093e
callq 0x2680
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, -0x8(%rbp)
jmp 0xaf53
cmpl $0x8, -0x450(%rbp)
jl 0xaa59
cmpl $0x8000, -0x450(%rbp)   # imm = 0x8000
jl 0xab13
movl $0x0, -0x478(%rbp)
movl -0x478(%rbp), %eax
cmpl -0x454(%rbp), %eax
jge 0xab0e
movl $0x0, -0x474(%rbp)
movl -0x474(%rbp), %eax
cmpl -0x450(%rbp), %eax
jge 0xaaf8
jmp 0xaa8f
movq -0x10(%rbp), %rdi
leaq -0x494(%rbp), %rsi
movl $0x4, %edx
callq 0x185b0
movq -0x468(%rbp), %rdi
movl -0x478(%rbp), %eax
imull -0x450(%rbp), %eax
imull -0x2c(%rbp), %eax
cltq
shlq $0x2, %rax
addq %rax, %rdi
movl -0x474(%rbp), %eax
imull -0x2c(%rbp), %eax
cltq
shlq $0x2, %rax
addq %rax, %rdi
leaq -0x494(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x1cc50
movl -0x474(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x474(%rbp)
jmp 0xaa7f
jmp 0xaafa
movl -0x478(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x478(%rbp)
jmp 0xaa63
jmp 0xaf48
movq $0x0, -0x460(%rbp)
movl $0x0, -0x478(%rbp)
movl -0x478(%rbp), %eax
cmpl -0x454(%rbp), %eax
jge 0xaf30
movq -0x10(%rbp), %rdi
callq 0x12e60
movzbl %al, %eax
movl %eax, -0x480(%rbp)
movq -0x10(%rbp), %rdi
callq 0x12e60
movzbl %al, %eax
movl %eax, -0x484(%rbp)
movq -0x10(%rbp), %rdi
callq 0x12e60
movzbl %al, %eax
movl %eax, -0x46c(%rbp)
cmpl $0x2, -0x480(%rbp)
jne 0xab92
cmpl $0x2, -0x484(%rbp)
jne 0xab92
movl -0x46c(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0xac00
movl -0x480(%rbp), %eax
movb %al, -0x498(%rbp)
movl -0x484(%rbp), %eax
movb %al, -0x497(%rbp)
movl -0x46c(%rbp), %eax
movb %al, -0x496(%rbp)
movq -0x10(%rbp), %rdi
callq 0x12e60
movb %al, -0x495(%rbp)
movq -0x468(%rbp), %rdi
leaq -0x498(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x1cc50
movl $0x1, -0x474(%rbp)
movl $0x0, -0x478(%rbp)
movq -0x460(%rbp), %rdi
callq 0x22a0
jmp 0xaa8f
movl -0x46c(%rbp), %eax
shll $0x8, %eax
movl %eax, -0x46c(%rbp)
movq -0x10(%rbp), %rdi
callq 0x12e60
movzbl %al, %eax
orl -0x46c(%rbp), %eax
movl %eax, -0x46c(%rbp)
movl -0x46c(%rbp), %eax
cmpl -0x450(%rbp), %eax
je 0xac6d
movq -0x468(%rbp), %rdi
callq 0x22a0
movq -0x460(%rbp), %rdi
callq 0x22a0
leaq 0x16403(%rip), %rdi     # 0x21057
callq 0x2680
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, -0x8(%rbp)
jmp 0xaf53
cmpq $0x0, -0x460(%rbp)
jne 0xacc8
movl -0x450(%rbp), %edi
movl $0x4, %esi
xorl %edx, %edx
callq 0x13470
movq %rax, -0x460(%rbp)
cmpq $0x0, -0x460(%rbp)
jne 0xacc6
movq -0x468(%rbp), %rdi
callq 0x22a0
leaq 0x15c91(%rip), %rdi     # 0x2093e
callq 0x2680
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, -0x8(%rbp)
jmp 0xaf53
jmp 0xacc8
movl $0x0, -0x47c(%rbp)
cmpl $0x4, -0x47c(%rbp)
jge 0xaead
movl $0x0, -0x474(%rbp)
movl -0x450(%rbp), %eax
subl -0x474(%rbp), %eax
movl %eax, -0x49c(%rbp)
cmpl $0x0, %eax
jle 0xae97
movq -0x10(%rbp), %rdi
callq 0x12e60
movb %al, -0x46d(%rbp)
movzbl -0x46d(%rbp), %eax
cmpl $0x80, %eax
jle 0xadeb
movq -0x10(%rbp), %rdi
callq 0x12e60
movb %al, -0x46e(%rbp)
movzbl -0x46d(%rbp), %eax
subl $0x80, %eax
movb %al, -0x46d(%rbp)
movzbl -0x46d(%rbp), %eax
cmpl -0x49c(%rbp), %eax
jle 0xad8d
movq -0x468(%rbp), %rdi
callq 0x22a0
movq -0x460(%rbp), %rdi
callq 0x22a0
leaq 0x1649a(%rip), %rdi     # 0x2120e
callq 0x2680
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, -0x8(%rbp)
jmp 0xaf53
movl $0x0, -0x488(%rbp)
movl -0x488(%rbp), %eax
movzbl -0x46d(%rbp), %ecx
cmpl %ecx, %eax
jge 0xade6
movb -0x46e(%rbp), %dl
movq -0x460(%rbp), %rax
movl -0x474(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x474(%rbp)
shll $0x2, %ecx
addl -0x47c(%rbp), %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl -0x488(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x488(%rbp)
jmp 0xad97
jmp 0xae92
movzbl -0x46d(%rbp), %eax
cmpl -0x49c(%rbp), %eax
jle 0xae32
movq -0x468(%rbp), %rdi
callq 0x22a0
movq -0x460(%rbp), %rdi
callq 0x22a0
leaq 0x163f5(%rip), %rdi     # 0x2120e
callq 0x2680
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, -0x8(%rbp)
jmp 0xaf53
movl $0x0, -0x488(%rbp)
movl -0x488(%rbp), %eax
movzbl -0x46d(%rbp), %ecx
cmpl %ecx, %eax
jge 0xae90
movq -0x10(%rbp), %rdi
callq 0x12e60
movb %al, %dl
movq -0x460(%rbp), %rax
movl -0x474(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x474(%rbp)
shll $0x2, %ecx
addl -0x47c(%rbp), %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl -0x488(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x488(%rbp)
jmp 0xae3c
jmp 0xae92
jmp 0xace9
jmp 0xae99
movl -0x47c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x47c(%rbp)
jmp 0xacd2
movl $0x0, -0x474(%rbp)
movl -0x474(%rbp), %eax
cmpl -0x450(%rbp), %eax
jge 0xaf1a
movq -0x468(%rbp), %rdi
movl -0x478(%rbp), %eax
imull -0x450(%rbp), %eax
addl -0x474(%rbp), %eax
imull -0x2c(%rbp), %eax
cltq
shlq $0x2, %rax
addq %rax, %rdi
movq -0x460(%rbp), %rsi
movl -0x474(%rbp), %eax
shll $0x2, %eax
cltq
addq %rax, %rsi
movl -0x2c(%rbp), %edx
callq 0x1cc50
movl -0x474(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x474(%rbp)
jmp 0xaeb7
jmp 0xaf1c
movl -0x478(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x478(%rbp)
jmp 0xab28
cmpq $0x0, -0x460(%rbp)
je 0xaf46
movq -0x460(%rbp), %rdi
callq 0x22a0
jmp 0xaf48
movq -0x468(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x4a0, %rsp            # imm = 0x4A0
popq %rbp
retq