// File: srajangarg[P]raytracer/src/core/stb_image.hpp
// Function: stbi__tga_test(stbi__context*)
static int stbi__tga_test(stbi__context *s)
{
   int res = 0;
   int sz, tga_color_type;
   stbi__get8(s);      //   discard Offset
   tga_color_type = stbi__get8(s);   //   color type
   if ( tga_color_type > 1 ) goto errorEnd;   //   only RGB or indexed allowed
   sz = stbi__get8(s);   //   image type
   if ( tga_color_type == 1 ) { // colormapped (paletted) image
      if (sz != 1 && sz != 9) goto errorEnd; // colortype 1 demands image type 1 or 9
      stbi__skip(s,4);       // skip index of first colormap entry and number of entries
      sz = stbi__get8(s);    //   check bits per palette color entry
      if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) goto errorEnd;
      stbi__skip(s,4);       // skip image x and y origin
   } else { // "normal" image w/o colormap
      if ( (sz != 2) && (sz != 3) && (sz != 10) && (sz != 11) ) goto errorEnd; // only RGB or grey allowed, +/- RLE
      stbi__skip(s,9); // skip colormap specification and image x/y origin
   }
   if ( stbi__get16le(s) < 1 ) goto errorEnd;      //   test width
   if ( stbi__get16le(s) < 1 ) goto errorEnd;      //   test height
   sz = stbi__get8(s);   //   bits per pixel
   if ( (tga_color_type == 1) && (sz != 8) && (sz != 16) ) goto errorEnd; // for colormapped images, bpp is size of an index
   if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) goto errorEnd;

   res = 1; // if we got this far, everything's good and we can return 1 instead of 0

errorEnd:
   stbi__rewind(s);
   return res;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
movq -0x8(%rbp), %rdi
callq 0x2ce50
movq -0x8(%rbp), %rdi
callq 0x2ce50
movzbl %al, %eax
movl %eax, -0x14(%rbp)
cmpl $0x1, -0x14(%rbp)
jle 0x2a9f6
jmp 0x2aafe
movq -0x8(%rbp), %rdi
callq 0x2ce50
movzbl %al, %eax
movl %eax, -0x10(%rbp)
cmpl $0x1, -0x14(%rbp)
jne 0x2aa6c
cmpl $0x1, -0x10(%rbp)
je 0x2aa1c
cmpl $0x9, -0x10(%rbp)
je 0x2aa1c
jmp 0x2aafe
movq -0x8(%rbp), %rdi
movl $0x4, %esi
callq 0x2d340
movq -0x8(%rbp), %rdi
callq 0x2ce50
movzbl %al, %eax
movl %eax, -0x10(%rbp)
cmpl $0x8, -0x10(%rbp)
je 0x2aa5c
cmpl $0xf, -0x10(%rbp)
je 0x2aa5c
cmpl $0x10, -0x10(%rbp)
je 0x2aa5c
cmpl $0x18, -0x10(%rbp)
je 0x2aa5c
cmpl $0x20, -0x10(%rbp)
je 0x2aa5c
jmp 0x2aafe
movq -0x8(%rbp), %rdi
movl $0x4, %esi
callq 0x2d340
jmp 0x2aa94
cmpl $0x2, -0x10(%rbp)
je 0x2aa86
cmpl $0x3, -0x10(%rbp)
je 0x2aa86
cmpl $0xa, -0x10(%rbp)
je 0x2aa86
cmpl $0xb, -0x10(%rbp)
je 0x2aa86
jmp 0x2aafe
movq -0x8(%rbp), %rdi
movl $0x9, %esi
callq 0x2d340
movq -0x8(%rbp), %rdi
callq 0x28370
cmpl $0x1, %eax
jge 0x2aaa4
jmp 0x2aafe
movq -0x8(%rbp), %rdi
callq 0x28370
cmpl $0x1, %eax
jge 0x2aab4
jmp 0x2aafe
movq -0x8(%rbp), %rdi
callq 0x2ce50
movzbl %al, %eax
movl %eax, -0x10(%rbp)
cmpl $0x1, -0x14(%rbp)
jne 0x2aad7
cmpl $0x8, -0x10(%rbp)
je 0x2aad7
cmpl $0x10, -0x10(%rbp)
je 0x2aad7
jmp 0x2aafe
cmpl $0x8, -0x10(%rbp)
je 0x2aaf7
cmpl $0xf, -0x10(%rbp)
je 0x2aaf7
cmpl $0x10, -0x10(%rbp)
je 0x2aaf7
cmpl $0x18, -0x10(%rbp)
je 0x2aaf7
cmpl $0x20, -0x10(%rbp)
je 0x2aaf7
jmp 0x2aafe
movl $0x1, -0xc(%rbp)
movq -0x8(%rbp), %rdi
callq 0x2b420
movl -0xc(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq