// File: /workspace/github_c_makefile_star2_O1/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %r8d, 0x74(%rsp)
movq %rcx, 0x18(%rsp)
movq %rdx, 0x30(%rsp)
movq %rsi, 0x28(%rsp)
movq %rdi, %r14
movq 0xb8(%rdi), %rax
cmpq 0xc0(%rdi), %rax
jb 0x1913d
cmpl $0x0, 0x30(%r14)
je 0x1910d
movq 0x28(%r14), %rdi
leaq 0x38(%r14), %rbx
movl 0x34(%r14), %edx
movq %rbx, %rsi
callq *0x10(%r14)
testl %eax, %eax
je 0x19117
movq %rbx, 0xb8(%r14)
cltq
addq %rbx, %rax
movq %rax, 0xc0(%r14)
jmp 0x19136
movl $0x0, 0x8(%rsp)
jmp 0x1914f
movl $0x0, 0x30(%r14)
movq %rbx, 0xb8(%r14)
leaq 0x39(%r14), %rax
movq %rax, 0xc0(%r14)
movb $0x0, 0x38(%r14)
movq 0xb8(%r14), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0xb8(%r14)
movzbl (%rax), %eax
movl %eax, 0x8(%rsp)
movq 0xb8(%r14), %rax
cmpq 0xc0(%r14), %rax
jb 0x191bd
cmpl $0x0, 0x30(%r14)
je 0x19192
movq 0x28(%r14), %rdi
leaq 0x38(%r14), %rbx
movl 0x34(%r14), %edx
movq %rbx, %rsi
callq *0x10(%r14)
testl %eax, %eax
je 0x19197
movq %rbx, 0xb8(%r14)
cltq
addq %rbx, %rax
movq %rax, 0xc0(%r14)
jmp 0x191b6
xorl %r15d, %r15d
jmp 0x191cf
movl $0x0, 0x30(%r14)
movq %rbx, 0xb8(%r14)
leaq 0x39(%r14), %rax
movq %rax, 0xc0(%r14)
movb $0x0, 0x38(%r14)
movq 0xb8(%r14), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0xb8(%r14)
cmpb $0x0, (%rax)
setne %r15b
movq 0xb8(%r14), %rax
cmpq 0xc0(%r14), %rax
jb 0x19242
cmpl $0x0, 0x30(%r14)
je 0x19212
movq 0x28(%r14), %rdi
leaq 0x38(%r14), %rbx
movl 0x34(%r14), %edx
movq %rbx, %rsi
callq *0x10(%r14)
testl %eax, %eax
je 0x1921c
movq %rbx, 0xb8(%r14)
cltq
addq %rbx, %rax
movq %rax, 0xc0(%r14)
jmp 0x1923b
movl $0x0, 0x10(%rsp)
jmp 0x19253
movl $0x0, 0x30(%r14)
movq %rbx, 0xb8(%r14)
leaq 0x39(%r14), %rax
movq %rax, 0xc0(%r14)
movb $0x0, 0x38(%r14)
movq 0xb8(%r14), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0xb8(%r14)
movb (%rax), %al
movl %eax, 0x10(%rsp)
movq %r14, %rdi
callq 0x1e0d5
movl %eax, 0x48(%rsp)
movq %r14, %rdi
callq 0x1e0d5
movl %eax, 0x40(%rsp)
movq 0xb8(%r14), %rax
cmpq 0xc0(%r14), %rax
jb 0x192df
cmpl $0x0, 0x30(%r14)
je 0x192ae
movq 0x28(%r14), %rdi
leaq 0x38(%r14), %rbx
movl 0x34(%r14), %edx
movq %rbx, %rsi
callq *0x10(%r14)
testl %eax, %eax
je 0x192b9
movq %rbx, 0xb8(%r14)
cltq
addq %rbx, %rax
movq %rax, 0xc0(%r14)
jmp 0x192d8
movq $0x0, 0x38(%rsp)
jmp 0x192f2
movl $0x0, 0x30(%r14)
movq %rbx, 0xb8(%r14)
leaq 0x39(%r14), %rax
movq %rax, 0xc0(%r14)
movb $0x0, 0x38(%r14)
movq 0xb8(%r14), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0xb8(%r14)
movzbl (%rax), %eax
movq %rax, 0x38(%rsp)
movq %r14, %rdi
callq 0x1e0d5
movq %r14, %rdi
callq 0x1e0d5
movq %r14, %rdi
callq 0x1e0d5
movl %eax, %ebx
movq %r14, %rdi
callq 0x1e0d5
movl %eax, %ebp
movq 0xb8(%r14), %rax
cmpq 0xc0(%r14), %rax
jb 0x1938a
cmpl $0x0, 0x30(%r14)
je 0x1935c
movl %ebx, %r12d
movq 0x28(%r14), %rdi
leaq 0x38(%r14), %rbx
movl 0x34(%r14), %edx
movq %rbx, %rsi
callq *0x10(%r14)
testl %eax, %eax
je 0x19361
movq %rbx, 0xb8(%r14)
cltq
addq %rbx, %rax
movq %rax, 0xc0(%r14)
jmp 0x19380
xorl %r12d, %r12d
jmp 0x19398
movl $0x0, 0x30(%r14)
movq %rbx, 0xb8(%r14)
leaq 0x39(%r14), %rax
movq %rax, 0xc0(%r14)
movb $0x0, 0x38(%r14)
movq 0xb8(%r14), %rax
movl %r12d, %ebx
leaq 0x1(%rax), %rcx
movq %rcx, 0xb8(%r14)
movb (%rax), %r12b
movzbl 0x10(%rsp), %r13d
movq 0xb8(%r14), %rax
cmpq 0xc0(%r14), %rax
jb 0x1941b
cmpl $0x0, 0x30(%r14)
je 0x193e9
movl %r15d, 0x14(%rsp)
movl %ebx, %r15d
movq 0x28(%r14), %rdi
leaq 0x38(%r14), %rbx
movl 0x34(%r14), %edx
movq %rbx, %rsi
callq *0x10(%r14)
testl %eax, %eax
je 0x193ed
movq %rbx, 0xb8(%r14)
cltq
addq %rbx, %rax
movq %rax, 0xc0(%r14)
jmp 0x1940c
movb $0x1, %cl
jmp 0x1942c
movl $0x0, 0x30(%r14)
movq %rbx, 0xb8(%r14)
leaq 0x39(%r14), %rax
movq %rax, 0xc0(%r14)
movb $0x0, 0x38(%r14)
movq 0xb8(%r14), %rax
movl %r15d, %ebx
movl 0x14(%rsp), %r15d
leaq 0x1(%rax), %rcx
movq %rcx, 0xb8(%r14)
testb $0x20, (%rax)
sete %cl
leal -0x8(%r13), %eax
cmpb $0x8, 0x10(%rsp)
cmovbl %r13d, %eax
xorl %edi, %edi
testl %ebx, %ebx
je 0x19954
testl %ebp, %ebp
je 0x19954
addl $-0x4, %eax
cmpl $-0x3, %eax
jb 0x19954
leal -0x8(%r12), %eax
rolb $0x5, %al
cmpb $0x3, %al
ja 0x19952
movl %ebp, %edx
movb %cl, 0x7(%rsp)
movzbl %r12b, %eax
movq %rax, 0x68(%rsp)
shrl $0x3, %eax
movq 0x38(%rsp), %rcx
movl %ecx, %ebp
shrl $0x3, %ebp
testb %r15b, %r15b
movl %eax, 0x70(%rsp)
cmovel %eax, %ebp
movq 0x28(%rsp), %rax
movl %ebx, (%rax)
movq 0x30(%rsp), %rax
movl %edx, (%rax)
movq 0x18(%rsp), %rax
testq %rax, %rax
je 0x194a7
movl %ebp, (%rax)
movl %edx, 0xc(%rsp)
movl %edx, %eax
imull %ebx, %eax
movl %ebp, %r13d
movq %r13, %rdi
movq %rax, 0x58(%rsp)
imulq %rax, %rdi
callq 0x8430
testq %rax, %rax
je 0x19944
movq %rax, 0x18(%rsp)
movl %ebx, 0x24(%rsp)
cmpb $0x8, 0x10(%rsp)
setae %bl
movq %r14, %rdi
movl 0x8(%rsp), %esi
callq 0x1b0e3
orb %r15b, %bl
movl %ebp, 0x30(%rsp)
je 0x1954f
testb %r15b, %r15b
je 0x195a4
movq %r14, %rdi
movl 0x48(%rsp), %esi
callq 0x1b0e3
movq 0x38(%rsp), %rbp
imull 0x40(%rsp), %ebp
shrl $0x3, %ebp
movq %rbp, %rdi
callq 0x8430
testq %rax, %rax
je 0x1993a
movq %rax, %rbx
movq %r14, %rdi
movq %rax, %rsi
movl %ebp, %edx
callq 0x1d2f6
testl %eax, %eax
je 0x19966
movq %rbx, 0x50(%rsp)
movq %r13, 0x28(%rsp)
movl %r15d, 0x14(%rsp)
jmp 0x195b7
movq %r13, 0x28(%rsp)
cmpl $0x0, 0xc(%rsp)
movq 0x18(%rsp), %r12
movb 0x7(%rsp), %r13b
je 0x198d8
movl 0x24(%rsp), %ebp
imull 0x30(%rsp), %ebp
movl 0xc(%rsp), %ebx
decl %ebx
xorl %r15d, %r15d
testb %r13b, %r13b
movl %r15d, %eax
cmovnel %ebx, %eax
imull %ebp, %eax
movslq %eax, %rsi
addq %r12, %rsi
movq %r14, %rdi
movl %ebp, %edx
callq 0x1d2f6
incl %r15d
addl $-0x1, %ebx
jb 0x1957b
jmp 0x198d8
movq %r13, 0x28(%rsp)
movl %r15d, 0x14(%rsp)
movq $0x0, 0x50(%rsp)
movb 0x7(%rsp), %cl
cmpl $0x0, 0x58(%rsp)
je 0x1985a
leaq 0x38(%r14), %r8
leaq 0x39(%r14), %rax
movq %rax, 0x60(%rsp)
movq 0x68(%rsp), %rax
leal -0x1(%rax), %r12d
shrl $0x3, %r12d
incl %r12d
movl 0x58(%rsp), %eax
movq %rax, 0x38(%rsp)
xorl %ebx, %ebx
xorl %eax, %eax
movl $0x0, 0x8(%rsp)
xorl %r13d, %r13d
movq %r8, 0x48(%rsp)
cmpb $0x8, 0x10(%rsp)
jb 0x196b4
testl %r13d, %r13d
je 0x19625
xorl %ecx, %ecx
cmpl $0x0, 0x8(%rsp)
setne %cl
andb %cl, %al
movl %ecx, 0x8(%rsp)
jmp 0x196b6
movq 0xb8(%r14), %rax
cmpq 0xc0(%r14), %rax
jb 0x19695
cmpl $0x0, 0x30(%r14)
je 0x19667
movq 0x28(%r14), %rdi
movl 0x34(%r14), %edx
movq %r8, %rsi
movq %r8, %r13
callq *0x10(%r14)
testl %eax, %eax
je 0x1966b
movq %r13, 0xb8(%r14)
cltq
addq %r13, %rax
movq %rax, 0xc0(%r14)
jmp 0x1968b
xorl %eax, %eax
jmp 0x196a3
movl $0x0, 0x30(%r14)
movq %r13, 0xb8(%r14)
movq 0x60(%rsp), %rax
movq %rax, 0xc0(%r14)
movb $0x0, 0x38(%r14)
movq %r13, %r8
movq 0xb8(%r14), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0xb8(%r14)
movzbl (%rax), %eax
movl %eax, %r13d
andl $0x7f, %r13d
incl %r13d
shrl $0x7, %eax
movl %eax, 0x8(%rsp)
xorl %eax, %eax
testb %al, %al
jne 0x1981d
cmpb $0x0, 0x14(%rsp)
je 0x19716
movq 0xb8(%r14), %rax
cmpq 0xc0(%r14), %rax
jb 0x197e0
cmpl $0x0, 0x30(%r14)
je 0x197b2
movq 0x28(%r14), %rdi
movl 0x34(%r14), %edx
movq %r8, %rsi
movq %r8, %rbp
callq *0x10(%r14)
testl %eax, %eax
je 0x197b6
movq %rbp, 0xb8(%r14)
cltq
addq %rbp, %rax
movq %rax, 0xc0(%r14)
jmp 0x197d6
cmpl $0x0, 0x68(%rsp)
je 0x1981d
xorl %ebp, %ebp
movq 0xb8(%r14), %rax
cmpq 0xc0(%r14), %rax
jb 0x19793
cmpl $0x0, 0x30(%r14)
je 0x19765
movq 0x28(%r14), %rdi
movl 0x34(%r14), %edx
movq %r8, %rsi
movq %r8, %r15
callq *0x10(%r14)
testl %eax, %eax
je 0x19769
movq %r15, 0xb8(%r14)
cltq
addq %r15, %rax
movq %rax, 0xc0(%r14)
jmp 0x19789
xorl %eax, %eax
jmp 0x197a0
movl $0x0, 0x30(%r14)
movq %r15, 0xb8(%r14)
movq 0x60(%rsp), %rax
movq %rax, 0xc0(%r14)
movb $0x0, 0x38(%r14)
movq %r15, %r8
movq 0xb8(%r14), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0xb8(%r14)
movb (%rax), %al
movb %al, 0x44(%rsp,%rbp)
incq %rbp
cmpq %rbp, %r12
jne 0x19723
jmp 0x1981d
xorl %esi, %esi
jmp 0x197ee
movl $0x0, 0x30(%r14)
movq %rbp, 0xb8(%r14)
movq 0x60(%rsp), %rax
movq %rax, 0xc0(%r14)
movb $0x0, 0x38(%r14)
movq %rbp, %r8
movq 0xb8(%r14), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0xb8(%r14)
movzbl (%rax), %esi
cmpb $0x0, 0x68(%rsp)
je 0x1981d
cmpl %esi, 0x40(%rsp)
movl $0x0, %eax
cmovbel %eax, %esi
imull 0x70(%rsp), %esi
addq 0x50(%rsp), %rsi
leaq 0x44(%rsp), %rdi
movq %r12, %rdx
callq 0x82a0
movq 0x48(%rsp), %r8
movl 0x30(%rsp), %eax
testl %eax, %eax
je 0x19843
movl %eax, %edi
imull %ebx, %edi
addq 0x18(%rsp), %rdi
leaq 0x44(%rsp), %rsi
movq 0x28(%rsp), %rdx
callq 0x82a0
movq 0x48(%rsp), %r8
decl %r13d
incq %rbx
movb $0x1, %al
cmpq 0x38(%rsp), %rbx
movb 0x7(%rsp), %cl
jne 0x19600
cmpl $0x0, 0xc(%rsp)
sete %al
xorb $0x1, %cl
orb %al, %cl
jne 0x198c4
movl 0x24(%rsp), %eax
imull 0x30(%rsp), %eax
movl 0xc(%rsp), %ecx
decl %ecx
movl %eax, %edx
imull %ecx, %edx
shrl %ecx
leal 0x1(%rax), %esi
xorl %edi, %edi
xorl %r8d, %r8d
movl %edi, %edi
testl %eax, %eax
je 0x198b4
movslq %edx, %r9
movl %esi, %r10d
movq 0x18(%rsp), %r11
movb (%r11,%rdi), %bl
movb (%r11,%r9), %bpl
movb %bpl, (%r11,%rdi)
movb %bl, (%r11,%r9)
incq %r11
decl %r10d
cmpl $0x1, %r10d
jg 0x19898
leal 0x1(%r8), %r9d
subl %eax, %edx
addl %eax, %edi
cmpl %ecx, %r8d
movl %r9d, %r8d
jne 0x19887
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
movq 0x18(%rsp), %r12
je 0x198d8
callq 0x83f0
movl 0x30(%rsp), %esi
cmpl $0x3, %esi
setb %al
movq 0x58(%rsp), %r9
testl %r9d, %r9d
sete %cl
orb %al, %cl
movq %r12, %rdi
movq 0x28(%rsp), %r8
jne 0x19912
movq %rdi, %rax
addq $0x2, %rax
movb -0x2(%rax), %cl
movb (%rax), %dl
movb %dl, -0x2(%rax)
movb %cl, (%rax)
addq %r8, %rax
decl %r9d
jne 0x19900
movl 0x74(%rsp), %edx
testl %edx, %edx
movl 0x24(%rsp), %ecx
je 0x19954
cmpl %edx, %esi
je 0x19954
movl 0xc(%rsp), %r8d
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1ce9a
movq 0x18(%rsp), %rdi
callq 0x83f0
leaq 0x863c(%rip), %rax      # 0x21f87
movq %rax, 0xeab6(%rip)      # 0x28408
xorl %edi, %edi
movq %rdi, %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18(%rsp), %rdi
callq 0x83f0
movq %rbx, %rdi
callq 0x83f0
leaq 0x8cb9(%rip), %rax      # 0x22638
jmp 0x1994b