// File: srajangarg[P]raytracer/src/core/stb_image.hpp
// Function: stbi__tga_info(stbi__context*, int*, int*, int*)
static int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp)
{
    int tga_w, tga_h, tga_comp, tga_image_type, tga_bits_per_pixel, tga_colormap_bpp;
    int sz, tga_colormap_type;
    stbi__get8(s);                   // discard Offset
    tga_colormap_type = stbi__get8(s); // colormap type
    if( tga_colormap_type > 1 ) {
        stbi__rewind(s);
        return 0;      // only RGB or indexed allowed
    }
    tga_image_type = stbi__get8(s); // image type
    if ( tga_colormap_type == 1 ) { // colormapped (paletted) image
        if (tga_image_type != 1 && tga_image_type != 9) {
            stbi__rewind(s);
            return 0;
        }
        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) ) {
            stbi__rewind(s);
            return 0;
        }
        stbi__skip(s,4);       // skip image x and y origin
        tga_colormap_bpp = sz;
    } else { // "normal" image w/o colormap - only RGB or grey allowed, +/- RLE
        if ( (tga_image_type != 2) && (tga_image_type != 3) && (tga_image_type != 10) && (tga_image_type != 11) ) {
            stbi__rewind(s);
            return 0; // only RGB or grey allowed, +/- RLE
        }
        stbi__skip(s,9); // skip colormap specification and image x/y origin
        tga_colormap_bpp = 0;
    }
    tga_w = stbi__get16le(s);
    if( tga_w < 1 ) {
        stbi__rewind(s);
        return 0;   // test width
    }
    tga_h = stbi__get16le(s);
    if( tga_h < 1 ) {
        stbi__rewind(s);
        return 0;   // test height
    }
    tga_bits_per_pixel = stbi__get8(s); // bits per pixel
    stbi__get8(s); // ignore alpha bits
    if (tga_colormap_bpp != 0) {
        if((tga_bits_per_pixel != 8) && (tga_bits_per_pixel != 16)) {
            // when using a colormap, tga_bits_per_pixel is the size of the indexes
            // I don't think anything but 8 or 16bit indexes makes sense
            stbi__rewind(s);
            return 0;
        }
        tga_comp = stbi__tga_get_comp(tga_colormap_bpp, 0, NULL);
    } else {
        tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3) || (tga_image_type == 11), NULL);
    }
    if(!tga_comp) {
      stbi__rewind(s);
      return 0;
    }
    if (x) *x = tga_w;
    if (y) *y = tga_h;
    if (comp) *comp = tga_comp;
    return 1;                   // seems to have passed everything
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rdi
callq 0x2ce50
movq -0x10(%rbp), %rdi
callq 0x2ce50
movzbl %al, %eax
movl %eax, -0x48(%rbp)
cmpl $0x1, -0x48(%rbp)
jle 0x372db
movq -0x10(%rbp), %rdi
callq 0x2b420
movl $0x0, -0x4(%rbp)
jmp 0x374de
movq -0x10(%rbp), %rdi
callq 0x2ce50
movzbl %al, %eax
movl %eax, -0x38(%rbp)
cmpl $0x1, -0x48(%rbp)
jne 0x3737b
cmpl $0x1, -0x38(%rbp)
je 0x37315
cmpl $0x9, -0x38(%rbp)
je 0x37315
movq -0x10(%rbp), %rdi
callq 0x2b420
movl $0x0, -0x4(%rbp)
jmp 0x374de
movq -0x10(%rbp), %rdi
movl $0x4, %esi
callq 0x2d340
movq -0x10(%rbp), %rdi
callq 0x2ce50
movzbl %al, %eax
movl %eax, -0x44(%rbp)
cmpl $0x8, -0x44(%rbp)
je 0x37365
cmpl $0xf, -0x44(%rbp)
je 0x37365
cmpl $0x10, -0x44(%rbp)
je 0x37365
cmpl $0x18, -0x44(%rbp)
je 0x37365
cmpl $0x20, -0x44(%rbp)
je 0x37365
movq -0x10(%rbp), %rdi
callq 0x2b420
movl $0x0, -0x4(%rbp)
jmp 0x374de
movq -0x10(%rbp), %rdi
movl $0x4, %esi
callq 0x2d340
movl -0x44(%rbp), %eax
movl %eax, -0x40(%rbp)
jmp 0x373bd
cmpl $0x2, -0x38(%rbp)
je 0x373a8
cmpl $0x3, -0x38(%rbp)
je 0x373a8
cmpl $0xa, -0x38(%rbp)
je 0x373a8
cmpl $0xb, -0x38(%rbp)
je 0x373a8
movq -0x10(%rbp), %rdi
callq 0x2b420
movl $0x0, -0x4(%rbp)
jmp 0x374de
movq -0x10(%rbp), %rdi
movl $0x9, %esi
callq 0x2d340
movl $0x0, -0x40(%rbp)
movq -0x10(%rbp), %rdi
callq 0x28370
movl %eax, -0x2c(%rbp)
cmpl $0x1, -0x2c(%rbp)
jge 0x373e4
movq -0x10(%rbp), %rdi
callq 0x2b420
movl $0x0, -0x4(%rbp)
jmp 0x374de
movq -0x10(%rbp), %rdi
callq 0x28370
movl %eax, -0x30(%rbp)
cmpl $0x1, -0x30(%rbp)
jge 0x3740b
movq -0x10(%rbp), %rdi
callq 0x2b420
movl $0x0, -0x4(%rbp)
jmp 0x374de
movq -0x10(%rbp), %rdi
callq 0x2ce50
movzbl %al, %eax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rdi
callq 0x2ce50
cmpl $0x0, -0x40(%rbp)
je 0x3745d
cmpl $0x8, -0x3c(%rbp)
je 0x3744a
cmpl $0x10, -0x3c(%rbp)
je 0x3744a
movq -0x10(%rbp), %rdi
callq 0x2b420
movl $0x0, -0x4(%rbp)
jmp 0x374de
movl -0x40(%rbp), %edi
xorl %esi, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x35640
movl %eax, -0x34(%rbp)
jmp 0x3748f
movl -0x3c(%rbp), %eax
movl %eax, -0x50(%rbp)
movb $0x1, %al
cmpl $0x3, -0x38(%rbp)
movb %al, -0x49(%rbp)
je 0x37478
cmpl $0xb, -0x38(%rbp)
sete %al
movb %al, -0x49(%rbp)
movl -0x50(%rbp), %edi
movb -0x49(%rbp), %al
andb $0x1, %al
movzbl %al, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x35640
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jne 0x374a7
movq -0x10(%rbp), %rdi
callq 0x2b420
movl $0x0, -0x4(%rbp)
jmp 0x374de
cmpq $0x0, -0x18(%rbp)
je 0x374b7
movl -0x2c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
cmpq $0x0, -0x20(%rbp)
je 0x374c7
movl -0x30(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
cmpq $0x0, -0x28(%rbp)
je 0x374d7
movl -0x34(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)