// File: /workspace/github_c_makefile_star2_O0/patriciogonzalezvivo[P]tprint/include/std/stb_image.h
// Function: stbi__tga_load(stbi__context*, int*, int*, int*, int)
static stbi_uc *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp)
{
   //   read in the TGA header stuff
   int tga_offset = stbi__get8(s);
   int tga_indexed = stbi__get8(s);
   int tga_image_type = stbi__get8(s);
   int tga_is_RLE = 0;
   int tga_palette_start = stbi__get16le(s);
   int tga_palette_len = stbi__get16le(s);
   int tga_palette_bits = stbi__get8(s);
   int tga_x_origin = stbi__get16le(s);
   int tga_y_origin = stbi__get16le(s);
   int tga_width = stbi__get16le(s);
   int tga_height = stbi__get16le(s);
   int tga_bits_per_pixel = stbi__get8(s);
   int tga_comp = tga_bits_per_pixel / 8;
   int tga_inverted = stbi__get8(s);
   //   image data
   unsigned char *tga_data;
   unsigned char *tga_palette = NULL;
   int i, j;
   unsigned char raw_data[4];
   int RLE_count = 0;
   int RLE_repeating = 0;
   int read_next_pixel = 1;

   //   do a tiny bit of precessing
   if ( tga_image_type >= 8 )
   {
      tga_image_type -= 8;
      tga_is_RLE = 1;
   }
   /* int tga_alpha_bits = tga_inverted & 15; */
   tga_inverted = 1 - ((tga_inverted >> 5) & 1);

   //   error check
   if ( //(tga_indexed) ||
      (tga_width < 1) || (tga_height < 1) ||
      (tga_image_type < 1) || (tga_image_type > 3) ||
      ((tga_bits_per_pixel != 8) && (tga_bits_per_pixel != 16) &&
      (tga_bits_per_pixel != 24) && (tga_bits_per_pixel != 32))
      )
   {
      return NULL; // we don't report this as a bad TGA because we don't even know if it's TGA
   }

   //   If I'm paletted, then I'll use the number of bits from the palette
   if ( tga_indexed )
   {
      tga_comp = tga_palette_bits / 8;
   }

   //   tga info
   *x = tga_width;
   *y = tga_height;
   if (comp) *comp = tga_comp;

   tga_data = (unsigned char*)stbi__malloc( (size_t)tga_width * tga_height * tga_comp );
   if (!tga_data) return stbi__errpuc("outofmem", "Out of memory");

   // skip to the data's starting position (offset usually = 0)
   stbi__skip(s, tga_offset );

   if ( !tga_indexed && !tga_is_RLE) {
      for (i=0; i < tga_height; ++i) {
         int y = tga_inverted ? tga_height -i - 1 : i;
         stbi_uc *tga_row = tga_data + y*tga_width*tga_comp;
         stbi__getn(s, tga_row, tga_width * tga_comp);
      }
   } else  {
      //   do I need to load a palette?
      if ( tga_indexed)
      {
         //   any data to skip? (offset usually = 0)
         stbi__skip(s, tga_palette_start );
         //   load the palette
         tga_palette = (unsigned char*)stbi__malloc( tga_palette_len * tga_palette_bits / 8 );
         if (!tga_palette) {
            STBI_FREE(tga_data);
            return stbi__errpuc("outofmem", "Out of memory");
         }
         if (!stbi__getn(s, tga_palette, tga_palette_len * tga_palette_bits / 8 )) {
            STBI_FREE(tga_data);
            STBI_FREE(tga_palette);
            return stbi__errpuc("bad palette", "Corrupt TGA");
         }
      }
      //   load the data
      for (i=0; i < tga_width * tga_height; ++i)
      {
         //   if I'm in RLE mode, do I need to get a RLE stbi__pngchunk?
         if ( tga_is_RLE )
         {
            if ( RLE_count == 0 )
            {
               //   yep, get the next byte as a RLE command
               int RLE_cmd = stbi__get8(s);
               RLE_count = 1 + (RLE_cmd & 127);
               RLE_repeating = RLE_cmd >> 7;
               read_next_pixel = 1;
            } else if ( !RLE_repeating )
            {
               read_next_pixel = 1;
            }
         } else
         {
            read_next_pixel = 1;
         }
         //   OK, if I need to read a pixel, do it now
         if ( read_next_pixel )
         {
            //   load however much data we did have
            if ( tga_indexed )
            {
               //   read in 1 byte, then perform the lookup
               int pal_idx = stbi__get8(s);
               if ( pal_idx >= tga_palette_len )
               {
                  //   invalid index
                  pal_idx = 0;
               }
               pal_idx *= tga_bits_per_pixel / 8;
               for (j = 0; j*8 < tga_bits_per_pixel; ++j)
               {
                  raw_data[j] = tga_palette[pal_idx+j];
               }
            } else
            {
               //   read in the data raw
               for (j = 0; j*8 < tga_bits_per_pixel; ++j)
               {
                  raw_data[j] = stbi__get8(s);
               }
            }
            //   clear the reading flag for the next pixel
            read_next_pixel = 0;
         } // end of reading a pixel

         // copy data
         for (j = 0; j < tga_comp; ++j)
           tga_data[i*tga_comp+j] = raw_data[j];

         //   in case we're in RLE mode, keep counting down
         --RLE_count;
      }
      //   do I need to invert the image?
      if ( tga_inverted )
      {
         for (j = 0; j*2 < tga_height; ++j)
         {
            int index1 = j * tga_width * tga_comp;
            int index2 = (tga_height - 1 - j) * tga_width * tga_comp;
            for (i = tga_width * tga_comp; i > 0; --i)
            {
               unsigned char temp = tga_data[index1];
               tga_data[index1] = tga_data[index2];
               tga_data[index2] = temp;
               ++index1;
               ++index2;
            }
         }
      }
      //   clear my palette, if I had one
      if ( tga_palette != NULL )
      {
         STBI_FREE( tga_palette );
      }
   }

   // swap RGB
   if (tga_comp >= 3)
   {
      unsigned char* tga_pixel = tga_data;
      for (i=0; i < tga_width * tga_height; ++i)
      {
         unsigned char temp = tga_pixel[0];
         tga_pixel[0] = tga_pixel[2];
         tga_pixel[2] = temp;
         tga_pixel += tga_comp;
      }
   }

   // convert to target component count
   if (req_comp && req_comp != tga_comp)
      tga_data = stbi__convert_format(tga_data, tga_comp, req_comp, tga_width, tga_height);

   //   the things I do to get rid of an error message, and yet keep
   //   Microsoft's C compilers happy... [8^(
   tga_palette_start = tga_palette_len = tga_palette_bits =
         tga_x_origin = tga_y_origin = 0;
   //   OK, done
   return tga_data;
}

// Assembly:
subq $0xc8, %rsp
movq %rdi, 0xb8(%rsp)
movq %rsi, 0xb0(%rsp)
movq %rdx, 0xa8(%rsp)
movq %rcx, 0xa0(%rsp)
movl %r8d, 0x9c(%rsp)
movq 0xb8(%rsp), %rdi
callq 0x21530
movzbl %al, %eax
movl %eax, 0x98(%rsp)
movq 0xb8(%rsp), %rdi
callq 0x21530
movzbl %al, %eax
movl %eax, 0x94(%rsp)
movq 0xb8(%rsp), %rdi
callq 0x21530
movzbl %al, %eax
movl %eax, 0x90(%rsp)
movl $0x0, 0x8c(%rsp)
movq 0xb8(%rsp), %rdi
callq 0x28960
movl %eax, 0x88(%rsp)
movq 0xb8(%rsp), %rdi
callq 0x28960
movl %eax, 0x84(%rsp)
movq 0xb8(%rsp), %rdi
callq 0x21530
movzbl %al, %eax
movl %eax, 0x80(%rsp)
movq 0xb8(%rsp), %rdi
callq 0x28960
movl %eax, 0x7c(%rsp)
movq 0xb8(%rsp), %rdi
callq 0x28960
movl %eax, 0x78(%rsp)
movq 0xb8(%rsp), %rdi
callq 0x28960
movl %eax, 0x74(%rsp)
movq 0xb8(%rsp), %rdi
callq 0x28960
movl %eax, 0x70(%rsp)
movq 0xb8(%rsp), %rdi
callq 0x21530
movzbl %al, %eax
movl %eax, 0x6c(%rsp)
movl 0x6c(%rsp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, 0x68(%rsp)
movq 0xb8(%rsp), %rdi
callq 0x21530
movzbl %al, %eax
movl %eax, 0x64(%rsp)
movq $0x0, 0x50(%rsp)
movl $0x0, 0x40(%rsp)
movl $0x0, 0x3c(%rsp)
movl $0x1, 0x38(%rsp)
cmpl $0x8, 0x90(%rsp)
jl 0x1f2c1
movl 0x90(%rsp), %eax
subl $0x8, %eax
movl %eax, 0x90(%rsp)
movl $0x1, 0x8c(%rsp)
movl 0x64(%rsp), %ecx
sarl $0x5, %ecx
andl $0x1, %ecx
movl $0x1, %eax
subl %ecx, %eax
movl %eax, 0x64(%rsp)
cmpl $0x1, 0x74(%rsp)
jl 0x1f314
cmpl $0x1, 0x70(%rsp)
jl 0x1f314
cmpl $0x1, 0x90(%rsp)
jl 0x1f314
cmpl $0x3, 0x90(%rsp)
jg 0x1f314
cmpl $0x8, 0x6c(%rsp)
je 0x1f325
cmpl $0x10, 0x6c(%rsp)
je 0x1f325
cmpl $0x18, 0x6c(%rsp)
je 0x1f325
cmpl $0x20, 0x6c(%rsp)
je 0x1f325
movq $0x0, 0xc0(%rsp)
jmp 0x1f8e2
cmpl $0x0, 0x94(%rsp)
je 0x1f342
movl 0x80(%rsp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, 0x68(%rsp)
movl 0x74(%rsp), %ecx
movq 0xb0(%rsp), %rax
movl %ecx, (%rax)
movl 0x70(%rsp), %ecx
movq 0xa8(%rsp), %rax
movl %ecx, (%rax)
cmpq $0x0, 0xa0(%rsp)
je 0x1f377
movl 0x68(%rsp), %ecx
movq 0xa0(%rsp), %rax
movl %ecx, (%rax)
movslq 0x74(%rsp), %rdi
movslq 0x70(%rsp), %rax
imulq %rax, %rdi
movslq 0x68(%rsp), %rax
imulq %rax, %rdi
callq 0x1ac80
movq %rax, 0x58(%rsp)
cmpq $0x0, 0x58(%rsp)
jne 0x1f3c4
leaq 0xe79c(%rip), %rdi      # 0x2db43
callq 0x1a190
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, 0xc0(%rsp)
jmp 0x1f8e2
movq 0xb8(%rsp), %rdi
movl 0x98(%rsp), %esi
callq 0x21ab0
cmpl $0x0, 0x94(%rsp)
jne 0x1f476
cmpl $0x0, 0x8c(%rsp)
jne 0x1f476
movl $0x0, 0x4c(%rsp)
movl 0x4c(%rsp), %eax
cmpl 0x70(%rsp), %eax
jge 0x1f471
cmpl $0x0, 0x64(%rsp)
je 0x1f41d
movl 0x70(%rsp), %eax
subl 0x4c(%rsp), %eax
subl $0x1, %eax
movl %eax, (%rsp)
jmp 0x1f424
movl 0x4c(%rsp), %eax
movl %eax, (%rsp)
movl (%rsp), %eax
movl %eax, 0x34(%rsp)
movq 0x58(%rsp), %rax
movl 0x34(%rsp), %ecx
imull 0x74(%rsp), %ecx
imull 0x68(%rsp), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, 0x28(%rsp)
movq 0xb8(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl 0x74(%rsp), %edx
imull 0x68(%rsp), %edx
callq 0x26210
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0x1f3fc
jmp 0x1f7f7
cmpl $0x0, 0x94(%rsp)
je 0x1f55c
movq 0xb8(%rsp), %rdi
movl 0x88(%rsp), %esi
callq 0x21ab0
movl 0x84(%rsp), %eax
imull 0x80(%rsp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movslq %eax, %rdi
callq 0x1ac80
movq %rax, 0x50(%rsp)
cmpq $0x0, 0x50(%rsp)
jne 0x1f4f2
movq 0x58(%rsp), %rdi
callq 0xd4e0
leaq 0xe66e(%rip), %rdi      # 0x2db43
callq 0x1a190
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, 0xc0(%rsp)
jmp 0x1f8e2
movq 0xb8(%rsp), %rdi
movq 0x50(%rsp), %rsi
movl 0x84(%rsp), %eax
imull 0x80(%rsp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, %edx
callq 0x26210
cmpl $0x0, %eax
jne 0x1f55a
movq 0x58(%rsp), %rdi
callq 0xd4e0
movq 0x50(%rsp), %rdi
callq 0xd4e0
leaq 0xecb7(%rip), %rdi      # 0x2e1f4
callq 0x1a190
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, 0xc0(%rsp)
jmp 0x1f8e2
jmp 0x1f55c
movl $0x0, 0x4c(%rsp)
movl 0x4c(%rsp), %eax
movl 0x74(%rsp), %ecx
imull 0x70(%rsp), %ecx
cmpl %ecx, %eax
jge 0x1f70e
cmpl $0x0, 0x8c(%rsp)
je 0x1f5d4
cmpl $0x0, 0x40(%rsp)
jne 0x1f5c1
movq 0xb8(%rsp), %rdi
callq 0x21530
movzbl %al, %eax
movl %eax, 0x24(%rsp)
movl 0x24(%rsp), %eax
andl $0x7f, %eax
addl $0x1, %eax
movl %eax, 0x40(%rsp)
movl 0x24(%rsp), %eax
sarl $0x7, %eax
movl %eax, 0x3c(%rsp)
movl $0x1, 0x38(%rsp)
jmp 0x1f5d2
cmpl $0x0, 0x3c(%rsp)
jne 0x1f5d0
movl $0x1, 0x38(%rsp)
jmp 0x1f5d2
jmp 0x1f5dc
movl $0x1, 0x38(%rsp)
cmpl $0x0, 0x38(%rsp)
je 0x1f6b3
cmpl $0x0, 0x94(%rsp)
je 0x1f66f
movq 0xb8(%rsp), %rdi
callq 0x21530
movzbl %al, %eax
movl %eax, 0x20(%rsp)
movl 0x20(%rsp), %eax
cmpl 0x84(%rsp), %eax
jl 0x1f61a
movl $0x0, 0x20(%rsp)
movl 0x6c(%rsp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
imull 0x20(%rsp), %eax
movl %eax, 0x20(%rsp)
movl $0x0, 0x48(%rsp)
movl 0x48(%rsp), %eax
shll $0x3, %eax
cmpl 0x6c(%rsp), %eax
jge 0x1f66d
movq 0x50(%rsp), %rax
movl 0x20(%rsp), %ecx
addl 0x48(%rsp), %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %cl
movslq 0x48(%rsp), %rax
movb %cl, 0x44(%rsp,%rax)
movl 0x48(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x48(%rsp)
jmp 0x1f637
jmp 0x1f6ab
movl $0x0, 0x48(%rsp)
movl 0x48(%rsp), %eax
shll $0x3, %eax
cmpl 0x6c(%rsp), %eax
jge 0x1f6a9
movq 0xb8(%rsp), %rdi
callq 0x21530
movb %al, %cl
movslq 0x48(%rsp), %rax
movb %cl, 0x44(%rsp,%rax)
movl 0x48(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x48(%rsp)
jmp 0x1f677
jmp 0x1f6ab
movl $0x0, 0x38(%rsp)
movl $0x0, 0x48(%rsp)
movl 0x48(%rsp), %eax
cmpl 0x68(%rsp), %eax
jge 0x1f6f3
movslq 0x48(%rsp), %rax
movb 0x44(%rsp,%rax), %dl
movq 0x58(%rsp), %rax
movl 0x4c(%rsp), %ecx
imull 0x68(%rsp), %ecx
addl 0x48(%rsp), %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl 0x48(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x48(%rsp)
jmp 0x1f6bb
movl 0x40(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x40(%rsp)
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0x1f564
cmpl $0x0, 0x64(%rsp)
je 0x1f7e3
movl $0x0, 0x48(%rsp)
movl 0x48(%rsp), %eax
shll %eax
cmpl 0x70(%rsp), %eax
jge 0x1f7e1
movl 0x48(%rsp), %eax
imull 0x74(%rsp), %eax
imull 0x68(%rsp), %eax
movl %eax, 0x1c(%rsp)
movl 0x70(%rsp), %eax
subl $0x1, %eax
subl 0x48(%rsp), %eax
imull 0x74(%rsp), %eax
imull 0x68(%rsp), %eax
movl %eax, 0x18(%rsp)
movl 0x74(%rsp), %eax
imull 0x68(%rsp), %eax
movl %eax, 0x4c(%rsp)
cmpl $0x0, 0x4c(%rsp)
jle 0x1f7cf
movq 0x58(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movb (%rax,%rcx), %al
movb %al, 0x17(%rsp)
movq 0x58(%rsp), %rax
movslq 0x18(%rsp), %rcx
movb (%rax,%rcx), %dl
movq 0x58(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movb %dl, (%rax,%rcx)
movb 0x17(%rsp), %dl
movq 0x58(%rsp), %rax
movslq 0x18(%rsp), %rcx
movb %dl, (%rax,%rcx)
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
movl 0x18(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x18(%rsp)
movl 0x4c(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0x1f769
jmp 0x1f7d1
movl 0x48(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x48(%rsp)
jmp 0x1f721
jmp 0x1f7e3
cmpq $0x0, 0x50(%rsp)
je 0x1f7f5
movq 0x50(%rsp), %rdi
callq 0xd4e0
jmp 0x1f7f7
cmpl $0x3, 0x68(%rsp)
jl 0x1f86a
movq 0x58(%rsp), %rax
movq %rax, 0x8(%rsp)
movl $0x0, 0x4c(%rsp)
movl 0x4c(%rsp), %eax
movl 0x74(%rsp), %ecx
imull 0x70(%rsp), %ecx
cmpl %ecx, %eax
jge 0x1f868
movq 0x8(%rsp), %rax
movb (%rax), %al
movb %al, 0x7(%rsp)
movq 0x8(%rsp), %rax
movb 0x2(%rax), %cl
movq 0x8(%rsp), %rax
movb %cl, (%rax)
movb 0x7(%rsp), %cl
movq 0x8(%rsp), %rax
movb %cl, 0x2(%rax)
movl 0x68(%rsp), %ecx
movq 0x8(%rsp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, 0x8(%rsp)
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0x1f810
jmp 0x1f86a
cmpl $0x0, 0x9c(%rsp)
je 0x1f8a4
movl 0x9c(%rsp), %eax
cmpl 0x68(%rsp), %eax
je 0x1f8a4
movq 0x58(%rsp), %rdi
movl 0x68(%rsp), %esi
movl 0x9c(%rsp), %edx
movl 0x74(%rsp), %ecx
movl 0x70(%rsp), %r8d
callq 0x25b30
movq %rax, 0x58(%rsp)
movl $0x0, 0x78(%rsp)
movl $0x0, 0x7c(%rsp)
movl $0x0, 0x80(%rsp)
movl $0x0, 0x84(%rsp)
movl $0x0, 0x88(%rsp)
movq 0x58(%rsp), %rax
movq %rax, 0xc0(%rsp)
movq 0xc0(%rsp), %rax
addq $0xc8, %rsp
retq
nopw %cs:(%rax,%rax)