// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, %r15
movq %rdx, %rbx
movq %rsi, 0x20(%rsp)
movq %rdi, %r12
movq 0xb8(%rdi), %rax
movq 0xc0(%rdi), %r13
cmpq %r13, %rax
jae 0x23951
incq %rax
jmp 0x2399c
cmpl $0x0, 0x30(%r12)
je 0x239a4
movq 0x28(%r12), %rdi
leaq 0x38(%r12), %r13
movl 0x34(%r12), %edx
movq %r13, %rsi
callq *0x10(%r12)
testl %eax, %eax
je 0x2397b
cltq
addq %rax, %r13
jmp 0x2398f
movl $0x0, 0x30(%r12)
leaq 0x39(%r12), %r13
movb $0x0, 0x38(%r12)
movq %r13, 0xc0(%r12)
leaq 0x39(%r12), %rax
movq %rax, 0xb8(%r12)
cmpq %r13, %rax
jae 0x239bd
leaq 0x1(%rax), %rcx
movq %rcx, 0xb8(%r12)
movb (%rax), %r14b
movq %rcx, %rax
jmp 0x23a1d
cmpl $0x0, 0x30(%r12)
je 0x239ec
movq 0x28(%r12), %rdi
leaq 0x38(%r12), %rbp
movl 0x34(%r12), %edx
movq %rbp, %rsi
callq *0x10(%r12)
testl %eax, %eax
je 0x239f1
movslq %eax, %r13
addq %rbp, %r13
movb (%rbp), %r14b
jmp 0x23a08
xorl %r14d, %r14d
jmp 0x23a27
movl $0x0, 0x30(%r12)
leaq 0x39(%r12), %r13
movb $0x0, 0x38(%r12)
xorl %r14d, %r14d
movq %r13, 0xc0(%r12)
leaq 0x39(%r12), %rax
movq %rax, 0xb8(%r12)
cmpb $0x2, %r14b
jae 0x23dbc
cmpq %r13, %rax
movq %rbx, 0x8(%rsp)
jae 0x23a44
leaq 0x1(%rax), %rcx
movq %rcx, 0xb8(%r12)
movb (%rax), %bl
movq %rcx, %rax
jmp 0x23aa1
cmpl $0x0, 0x30(%r12)
je 0x23a72
movq 0x28(%r12), %rdi
leaq 0x38(%r12), %rbp
movl 0x34(%r12), %edx
movq %rbp, %rsi
callq *0x10(%r12)
testl %eax, %eax
je 0x23a76
movslq %eax, %r13
addq %rbp, %r13
movb (%rbp), %bl
jmp 0x23a8c
xorl %ebx, %ebx
jmp 0x23aa1
movl $0x0, 0x30(%r12)
leaq 0x39(%r12), %r13
movb $0x0, 0x38(%r12)
xorl %ebx, %ebx
movq %r13, 0xc0(%r12)
leaq 0x39(%r12), %rax
movq %rax, 0xb8(%r12)
movl %ebx, %ecx
testb %r14b, %r14b
je 0x23af1
andb $-0x9, %cl
cmpb $0x1, %cl
jne 0x23dbc
cmpq $0x0, 0x10(%r12)
je 0x23b2a
movl %r13d, %ecx
subl %eax, %ecx
cmpl $0x3, %ecx
jg 0x23b2a
movq %r13, 0xb8(%r12)
movq 0x28(%r12), %rdi
movl $0x4, %esi
subl %ecx, %esi
callq *0x18(%r12)
movq 0xb8(%r12), %rax
movq 0xc0(%r12), %r13
jmp 0x23b36
andb $-0xa, %cl
cmpb $0x2, %cl
jne 0x23dbc
cmpq $0x0, 0x10(%r12)
je 0x23b7f
movl %r13d, %ecx
subl %eax, %ecx
cmpl $0x8, %ecx
jg 0x23b7f
movq %r13, 0xb8(%r12)
movq 0x28(%r12), %rdi
movl $0x9, %esi
subl %ecx, %esi
callq *0x18(%r12)
jmp 0x23b8b
addq $0x4, %rax
movq %rax, 0xb8(%r12)
cmpq %r13, %rax
jae 0x23b4c
leaq 0x1(%rax), %rcx
movq %rcx, 0xb8(%r12)
movb (%rax), %r14b
jmp 0x23bbf
cmpl $0x0, 0x30(%r12)
je 0x23dbc
movq 0x28(%r12), %rdi
leaq 0x38(%r12), %rbp
movl 0x34(%r12), %edx
movq %rbp, %rsi
callq *0x10(%r12)
testl %eax, %eax
je 0x23b93
movslq %eax, %r13
addq %rbp, %r13
movb (%rbp), %r14b
jmp 0x23baa
addq $0x9, %rax
movq %rax, 0xb8(%r12)
xorl %r14d, %r14d
jmp 0x23c1a
movl $0x0, 0x30(%r12)
leaq 0x39(%r12), %r13
movb $0x0, 0x38(%r12)
xorl %r14d, %r14d
movq %r13, 0xc0(%r12)
leaq 0x39(%r12), %rcx
movq %rcx, 0xb8(%r12)
cmpb $0x20, %r14b
ja 0x23dbc
movzbl %r14b, %eax
movabsq $0x101018100, %rdx      # imm = 0x101018100
btq %rax, %rdx
jae 0x23dbc
cmpq $0x0, 0x10(%r12)
je 0x23c0e
movl %r13d, %eax
subl %ecx, %eax
cmpl $0x3, %eax
jg 0x23c0e
movq %r13, 0xb8(%r12)
movq 0x28(%r12), %rdi
movl $0x4, %esi
subl %eax, %esi
callq *0x18(%r12)
jmp 0x23c1a
addq $0x4, %rcx
movq %rcx, 0xb8(%r12)
movq %r12, %rdi
callq 0x158c8
testl %eax, %eax
je 0x23dbc
movl %eax, %ebp
movq %r12, %rdi
callq 0x158c8
testl %eax, %eax
je 0x23dbc
movq 0xb8(%r12), %rcx
movq 0xc0(%r12), %rsi
cmpq %rsi, %rcx
movq %r15, 0x18(%rsp)
jae 0x23c6a
leaq 0x1(%rcx), %rdx
movq %rdx, 0xb8(%r12)
movb (%rcx), %r15b
movq %rdx, %rcx
jmp 0x23cd2
cmpl $0x0, 0x30(%r12)
je 0x23c9d
movl %eax, 0x14(%rsp)
movq 0x28(%r12), %rdi
leaq 0x38(%r12), %r13
movl 0x34(%r12), %edx
movq %r13, %rsi
callq *0x10(%r12)
testl %eax, %eax
je 0x23ca2
movslq %eax, %rsi
addq %r13, %rsi
movb (%r13), %r15b
jmp 0x23cb9
xorl %r15d, %r15d
jmp 0x23cd2
movl $0x0, 0x30(%r12)
leaq 0x39(%r12), %rsi
movb $0x0, 0x38(%r12)
xorl %r15d, %r15d
movq %rsi, 0xc0(%r12)
leaq 0x39(%r12), %rcx
movq %rcx, 0xb8(%r12)
movl 0x14(%rsp), %eax
cmpq %rsi, %rcx
jae 0x23cdc
incq %rcx
jmp 0x23d2f
cmpl $0x0, 0x30(%r12)
je 0x23d37
movl %eax, 0x14(%rsp)
movq 0x28(%r12), %rdi
leaq 0x38(%r12), %r13
movl 0x34(%r12), %edx
movq %r13, %rsi
callq *0x10(%r12)
testl %eax, %eax
je 0x23d0a
cltq
addq %rax, %r13
jmp 0x23d1e
movl $0x0, 0x30(%r12)
leaq 0x39(%r12), %r13
movb $0x0, 0x38(%r12)
movq %r13, 0xc0(%r12)
leaq 0x39(%r12), %rcx
movl 0x14(%rsp), %eax
movq %rcx, 0xb8(%r12)
testb %r14b, %r14b
je 0x23d6f
cmpb $0x8, %r15b
je 0x23d4b
movzbl %r15b, %ecx
cmpl $0x10, %ecx
jne 0x23dbc
movzbl %r14b, %edi
cmpl $0xf, %edi
jle 0x23d9c
cmpl $0x20, %edi
movq 0x18(%rsp), %rdx
movq 0x8(%rsp), %rsi
je 0x23ddf
cmpl $0x18, %edi
je 0x23ddf
cmpl $0x10, %edi
je 0x23db5
jmp 0x23dbc
movzbl %r15b, %edi
cmpl $0xf, %edi
jle 0x23d9c
cmpl $0x20, %edi
je 0x23de9
cmpl $0x18, %edi
je 0x23de9
cmpl $0x10, %edi
movq 0x18(%rsp), %rdx
jne 0x23dbc
andb $-0x9, %bl
xorl %ecx, %ecx
cmpb $0x3, %bl
sete %cl
xorl $0x3, %ecx
jmp 0x23df6
movl $0x1, %ecx
cmpl $0x8, %edi
movq 0x18(%rsp), %rdx
movq 0x8(%rsp), %rsi
je 0x23dfb
cmpl $0xf, %edi
jne 0x23dbc
movl $0x3, %ecx
jmp 0x23df6
movups 0xc8(%r12), %xmm0
movups %xmm0, 0xb8(%r12)
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
shrb $0x3, %r14b
movzbl %r14b, %ecx
jmp 0x23dfb
shrb $0x3, %r15b
movzbl %r15b, %ecx
movq 0x18(%rsp), %rdx
movq 0x8(%rsp), %rsi
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x23e07
movl %ebp, (%rdi)
testq %rsi, %rsi
je 0x23e0e
movl %eax, (%rsi)
movl $0x1, %eax
testq %rdx, %rdx
je 0x23dd0
movl %ecx, (%rdx)
jmp 0x23dd0