// File: /workspace/github_c_makefile_star2_O0/patriciogonzalezvivo[P]tprint/include/std/stb_image.h
// Function: stbi__psd_load(stbi__context*, int*, int*, int*, int)
static stbi_uc *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp)
{
   int   pixelCount;
   int channelCount, compression;
   int channel, i, count, len;
   int w,h;
   stbi_uc *out;

   // Check identifier
   if (stbi__get32be(s) != 0x38425053)   // "8BPS"
      return stbi__errpuc("not PSD", "Corrupt PSD image");

   // Check file type version.
   if (stbi__get16be(s) != 1)
      return stbi__errpuc("wrong version", "Unsupported version of PSD image");

   // Skip 6 reserved bytes.
   stbi__skip(s, 6 );

   // Read the number of channels (R, G, B, A, etc).
   channelCount = stbi__get16be(s);
   if (channelCount < 0 || channelCount > 16)
      return stbi__errpuc("wrong channel count", "Unsupported number of channels in PSD image");

   // Read the rows and columns of the image.
   h = stbi__get32be(s);
   w = stbi__get32be(s);

   // Make sure the depth is 8 bits.
   if (stbi__get16be(s) != 8)
      return stbi__errpuc("unsupported bit depth", "PSD bit depth is not 8 bit");

   // Make sure the color mode is RGB.
   // Valid options are:
   //   0: Bitmap
   //   1: Grayscale
   //   2: Indexed color
   //   3: RGB color
   //   4: CMYK color
   //   7: Multichannel
   //   8: Duotone
   //   9: Lab color
   if (stbi__get16be(s) != 3)
      return stbi__errpuc("wrong color format", "PSD is not in RGB color format");

   // Skip the Mode Data.  (It's the palette for indexed color; other info for other modes.)
   stbi__skip(s,stbi__get32be(s) );

   // Skip the image resources.  (resolution, pen tool paths, etc)
   stbi__skip(s, stbi__get32be(s) );

   // Skip the reserved data.
   stbi__skip(s, stbi__get32be(s) );

   // Find out if the data is compressed.
   // Known values:
   //   0: no compression
   //   1: RLE compressed
   compression = stbi__get16be(s);
   if (compression > 1)
      return stbi__errpuc("bad compression", "PSD has an unknown compression format");

   // Create the destination image.
   out = (stbi_uc *) stbi__malloc(4 * w*h);
   if (!out) return stbi__errpuc("outofmem", "Out of memory");
   pixelCount = w*h;

   // Initialize the data to zero.
   //memset( out, 0, pixelCount * 4 );

   // Finally, the image data.
   if (compression) {
      // RLE as used by .PSD and .TIFF
      // Loop until you get the number of unpacked bytes you are expecting:
      //     Read the next source byte into n.
      //     If n is between 0 and 127 inclusive, copy the next n+1 bytes literally.
      //     Else if n is between -127 and -1 inclusive, copy the next byte -n+1 times.
      //     Else if n is 128, noop.
      // Endloop

      // The RLE-compressed data is preceeded by a 2-byte data count for each row in the data,
      // which we're going to just skip.
      stbi__skip(s, h * channelCount * 2 );

      // Read the RLE data by channel.
      for (channel = 0; channel < 4; channel++) {
         stbi_uc *p;

         p = out+channel;
         if (channel >= channelCount) {
            // Fill this channel with default data.
            for (i = 0; i < pixelCount; i++) *p = (channel == 3 ? 255 : 0), p += 4;
         } else {
            // Read the RLE data.
            count = 0;
            while (count < pixelCount) {
               len = stbi__get8(s);
               if (len == 128) {
                  // No-op.
               } else if (len < 128) {
                  // Copy next len+1 bytes literally.
                  len++;
                  count += len;
                  while (len) {
                     *p = stbi__get8(s);
                     p += 4;
                     len--;
                  }
               } else if (len > 128) {
                  stbi_uc   val;
                  // Next -len+1 bytes in the dest are replicated from next source byte.
                  // (Interpret len as a negative 8-bit int.)
                  len ^= 0x0FF;
                  len += 2;
                  val = stbi__get8(s);
                  count += len;
                  while (len) {
                     *p = val;
                     p += 4;
                     len--;
                  }
               }
            }
         }
      }

   } else {
      // We're at the raw image data.  It's each channel in order (Red, Green, Blue, Alpha, ...)
      // where each channel consists of an 8-bit value for each pixel in the image.

      // Read the data by channel.
      for (channel = 0; channel < 4; channel++) {
         stbi_uc *p;

         p = out + channel;
         if (channel > channelCount) {
            // Fill this channel with default data.
            for (i = 0; i < pixelCount; i++) *p = channel == 3 ? 255 : 0, p += 4;
         } else {
            // Read the data.
            for (i = 0; i < pixelCount; i++)
               *p = stbi__get8(s), p += 4;
         }
      }
   }

   if (req_comp && req_comp != 4) {
      out = stbi__convert_format(out, 4, req_comp, w, h);
      if (out == NULL) return out; // stbi__convert_format frees input on failure
   }

   if (comp) *comp = channelCount;
   *y = h;
   *x = w;

   return out;
}

// Assembly:
subq $0x88, %rsp
movq %rdi, 0x78(%rsp)
movq %rsi, 0x70(%rsp)
movq %rdx, 0x68(%rsp)
movq %rcx, 0x60(%rsp)
movl %r8d, 0x5c(%rsp)
movq 0x78(%rsp), %rdi
callq 0x261d0
cmpl $0x38425053, %eax       # imm = 0x38425053
je 0x1df05
leaq 0x101fe(%rip), %rdi     # 0x2e0e6
callq 0x1a190
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, 0x80(%rsp)
jmp 0x1e3f4
movq 0x78(%rsp), %rdi
callq 0x21680
cmpl $0x1, %eax
je 0x1df38
leaq 0x101d3(%rip), %rdi     # 0x2e0ee
callq 0x1a190
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, 0x80(%rsp)
jmp 0x1e3f4
movq 0x78(%rsp), %rdi
movl $0x6, %esi
callq 0x21ab0
movq 0x78(%rsp), %rdi
callq 0x21680
movl %eax, 0x54(%rsp)
cmpl $0x0, 0x54(%rsp)
jl 0x1df63
cmpl $0x10, 0x54(%rsp)
jle 0x1df87
leaq 0x10192(%rip), %rdi     # 0x2e0fc
callq 0x1a190
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, 0x80(%rsp)
jmp 0x1e3f4
movq 0x78(%rsp), %rdi
callq 0x261d0
movl %eax, 0x38(%rsp)
movq 0x78(%rsp), %rdi
callq 0x261d0
movl %eax, 0x3c(%rsp)
movq 0x78(%rsp), %rdi
callq 0x21680
cmpl $0x8, %eax
je 0x1dfd6
leaq 0x10157(%rip), %rdi     # 0x2e110
callq 0x1a190
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, 0x80(%rsp)
jmp 0x1e3f4
movq 0x78(%rsp), %rdi
callq 0x21680
cmpl $0x3, %eax
je 0x1e009
leaq 0x1013a(%rip), %rdi     # 0x2e126
callq 0x1a190
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, 0x80(%rsp)
jmp 0x1e3f4
movq 0x78(%rsp), %rax
movq %rax, (%rsp)
movq 0x78(%rsp), %rdi
callq 0x261d0
movq (%rsp), %rdi
movl %eax, %esi
callq 0x21ab0
movq 0x78(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x78(%rsp), %rdi
callq 0x261d0
movq 0x8(%rsp), %rdi
movl %eax, %esi
callq 0x21ab0
movq 0x78(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x78(%rsp), %rdi
callq 0x261d0
movq 0x10(%rsp), %rdi
movl %eax, %esi
callq 0x21ab0
movq 0x78(%rsp), %rdi
callq 0x21680
movl %eax, 0x50(%rsp)
cmpl $0x1, 0x50(%rsp)
jle 0x1e0a0
leaq 0x100b6(%rip), %rdi     # 0x2e139
callq 0x1a190
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, 0x80(%rsp)
jmp 0x1e3f4
movl 0x3c(%rsp), %eax
shll $0x2, %eax
imull 0x38(%rsp), %eax
movslq %eax, %rdi
callq 0x1ac80
movq %rax, 0x30(%rsp)
cmpq $0x0, 0x30(%rsp)
jne 0x1e0e5
leaq 0xfa7b(%rip), %rdi      # 0x2db43
callq 0x1a190
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, 0x80(%rsp)
jmp 0x1e3f4
movl 0x3c(%rsp), %eax
imull 0x38(%rsp), %eax
movl %eax, 0x58(%rsp)
cmpl $0x0, 0x50(%rsp)
je 0x1e2a8
movq 0x78(%rsp), %rdi
movl 0x38(%rsp), %esi
imull 0x54(%rsp), %esi
shll %esi
callq 0x21ab0
movl $0x0, 0x4c(%rsp)
cmpl $0x4, 0x4c(%rsp)
jge 0x1e2a3
movq 0x30(%rsp), %rax
movslq 0x4c(%rsp), %rcx
addq %rcx, %rax
movq %rax, 0x28(%rsp)
movl 0x4c(%rsp), %eax
cmpl 0x54(%rsp), %eax
jl 0x1e18d
movl $0x0, 0x48(%rsp)
movl 0x48(%rsp), %eax
cmpl 0x58(%rsp), %eax
jge 0x1e188
movl 0x4c(%rsp), %edx
xorl %eax, %eax
movl $0xff, %ecx
cmpl $0x3, %edx
cmovel %ecx, %eax
movb %al, %cl
movq 0x28(%rsp), %rax
movb %cl, (%rax)
movq 0x28(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x28(%rsp)
movl 0x48(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x48(%rsp)
jmp 0x1e149
jmp 0x1e291
movl $0x0, 0x44(%rsp)
movl 0x44(%rsp), %eax
cmpl 0x58(%rsp), %eax
jge 0x1e28f
movq 0x78(%rsp), %rdi
callq 0x21530
movzbl %al, %eax
movl %eax, 0x40(%rsp)
cmpl $0x80, 0x40(%rsp)
jne 0x1e1c3
jmp 0x1e28a
cmpl $0x80, 0x40(%rsp)
jge 0x1e21b
movl 0x40(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x40(%rsp)
movl 0x40(%rsp), %eax
addl 0x44(%rsp), %eax
movl %eax, 0x44(%rsp)
cmpl $0x0, 0x40(%rsp)
je 0x1e219
movq 0x78(%rsp), %rdi
callq 0x21530
movb %al, %cl
movq 0x28(%rsp), %rax
movb %cl, (%rax)
movq 0x28(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x28(%rsp)
movl 0x40(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x40(%rsp)
jmp 0x1e1e4
jmp 0x1e288
cmpl $0x80, 0x40(%rsp)
jle 0x1e286
movl 0x40(%rsp), %eax
xorl $0xff, %eax
movl %eax, 0x40(%rsp)
movl 0x40(%rsp), %eax
addl $0x2, %eax
movl %eax, 0x40(%rsp)
movq 0x78(%rsp), %rdi
callq 0x21530
movb %al, 0x27(%rsp)
movl 0x40(%rsp), %eax
addl 0x44(%rsp), %eax
movl %eax, 0x44(%rsp)
cmpl $0x0, 0x40(%rsp)
je 0x1e284
movb 0x27(%rsp), %cl
movq 0x28(%rsp), %rax
movb %cl, (%rax)
movq 0x28(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x28(%rsp)
movl 0x40(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x40(%rsp)
jmp 0x1e257
jmp 0x1e286
jmp 0x1e288
jmp 0x1e28a
jmp 0x1e195
jmp 0x1e291
jmp 0x1e293
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0x1e11a
jmp 0x1e376
movl $0x0, 0x4c(%rsp)
cmpl $0x4, 0x4c(%rsp)
jge 0x1e374
movq 0x30(%rsp), %rax
movslq 0x4c(%rsp), %rcx
addq %rcx, %rax
movq %rax, 0x18(%rsp)
movl 0x4c(%rsp), %eax
cmpl 0x54(%rsp), %eax
jle 0x1e320
movl $0x0, 0x48(%rsp)
movl 0x48(%rsp), %eax
cmpl 0x58(%rsp), %eax
jge 0x1e31e
movl 0x4c(%rsp), %edx
xorl %eax, %eax
movl $0xff, %ecx
cmpl $0x3, %edx
cmovel %ecx, %eax
movb %al, %cl
movq 0x18(%rsp), %rax
movb %cl, (%rax)
movq 0x18(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x18(%rsp)
movl 0x48(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x48(%rsp)
jmp 0x1e2df
jmp 0x1e362
movl $0x0, 0x48(%rsp)
movl 0x48(%rsp), %eax
cmpl 0x58(%rsp), %eax
jge 0x1e360
movq 0x78(%rsp), %rdi
callq 0x21530
movb %al, %cl
movq 0x18(%rsp), %rax
movb %cl, (%rax)
movq 0x18(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x18(%rsp)
movl 0x48(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x48(%rsp)
jmp 0x1e328
jmp 0x1e362
jmp 0x1e364
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0x1e2b0
jmp 0x1e376
cmpl $0x0, 0x5c(%rsp)
je 0x1e3be
cmpl $0x4, 0x5c(%rsp)
je 0x1e3be
movq 0x30(%rsp), %rdi
movl 0x5c(%rsp), %edx
movl 0x3c(%rsp), %ecx
movl 0x38(%rsp), %r8d
movl $0x4, %esi
callq 0x25b30
movq %rax, 0x30(%rsp)
cmpq $0x0, 0x30(%rsp)
jne 0x1e3bc
movq 0x30(%rsp), %rax
movq %rax, 0x80(%rsp)
jmp 0x1e3f4
jmp 0x1e3be
cmpq $0x0, 0x60(%rsp)
je 0x1e3d1
movl 0x54(%rsp), %ecx
movq 0x60(%rsp), %rax
movl %ecx, (%rax)
movl 0x38(%rsp), %ecx
movq 0x68(%rsp), %rax
movl %ecx, (%rax)
movl 0x3c(%rsp), %ecx
movq 0x70(%rsp), %rax
movl %ecx, (%rax)
movq 0x30(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0x80(%rsp), %rax
addq $0x88, %rsp
retq
nopw %cs:(%rax,%rax)