// File: /workspace/github_cpp_makefile_star2_O1/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, %r12
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
movq 0xb8(%rdi), %rax
cmpq 0xc0(%rdi), %rax
jb 0x232c1
cmpl $0x0, 0x30(%r14)
je 0x232cb
movq 0x28(%r14), %rdi
leaq 0x38(%r14), %r13
movl 0x34(%r14), %edx
movq %r13, %rsi
callq *0x10(%r14)
testl %eax, %eax
je 0x2329b
movq %r13, 0xb8(%r14)
cltq
addq %r13, %rax
movq %rax, 0xc0(%r14)
jmp 0x232ba
movl $0x0, 0x30(%r14)
movq %r13, 0xb8(%r14)
leaq 0x39(%r14), %rax
movq %rax, 0xc0(%r14)
movb $0x0, 0x38(%r14)
movq 0xb8(%r14), %rax
incq %rax
movq %rax, 0xb8(%r14)
movq 0xb8(%r14), %rax
cmpq 0xc0(%r14), %rax
jb 0x23338
cmpl $0x0, 0x30(%r14)
je 0x2330e
movq 0x28(%r14), %rdi
leaq 0x38(%r14), %r13
movl 0x34(%r14), %edx
movq %r13, %rsi
callq *0x10(%r14)
testl %eax, %eax
je 0x23312
movq %r13, 0xb8(%r14)
cltq
addq %r13, %rax
movq %rax, 0xc0(%r14)
jmp 0x23331
xorl %ebp, %ebp
jmp 0x23346
movl $0x0, 0x30(%r14)
movq %r13, 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), %bpl
cmpb $0x2, %bpl
jb 0x2336d
movups 0xc8(%r14), %xmm0
movups %xmm0, 0xb8(%r14)
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xb8(%r14), %rax
cmpq 0xc0(%r14), %rax
movq %rbx, 0x10(%rsp)
jb 0x233df
cmpl $0x0, 0x30(%r14)
je 0x233b5
movq 0x28(%r14), %rdi
leaq 0x38(%r14), %r13
movl 0x34(%r14), %edx
movq %r13, %rsi
callq *0x10(%r14)
testl %eax, %eax
je 0x233b9
movq %r13, 0xb8(%r14)
cltq
addq %r13, %rax
movq %rax, 0xc0(%r14)
jmp 0x233d8
xorl %ebx, %ebx
jmp 0x233ec
movl $0x0, 0x30(%r14)
movq %r13, 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), %bl
movl %ebx, %eax
cmpb $0x1, %bpl
jne 0x23434
andb $-0x9, %al
cmpb $0x1, %al
jne 0x2334c
cmpq $0x0, 0x10(%r14)
je 0x23479
movq 0xc0(%r14), %rcx
movl 0xb8(%r14), %edx
movl %ecx, %eax
subl %edx, %eax
cmpl $0x3, %eax
jg 0x23479
movq %rcx, 0xb8(%r14)
movq 0x28(%r14), %rdi
movl $0x4, %esi
subl %eax, %esi
callq *0x18(%r14)
jmp 0x23481
andb $-0xa, %al
cmpb $0x2, %al
jne 0x2334c
movq %r15, 0x18(%rsp)
cmpq $0x0, 0x10(%r14)
je 0x234c9
movq 0xc0(%r14), %rcx
movl 0xb8(%r14), %edx
movl %ecx, %eax
subl %edx, %eax
cmpl $0x8, %eax
jg 0x234c9
movq %rcx, 0xb8(%r14)
movq 0x28(%r14), %rdi
movl $0x9, %esi
subl %eax, %esi
callq *0x18(%r14)
jmp 0x234d1
addq $0x4, 0xb8(%r14)
movq 0xb8(%r14), %rax
cmpq 0xc0(%r14), %rax
movq %r15, 0x18(%rsp)
jb 0x23504
cmpl $0x0, 0x30(%r14)
je 0x234d9
movq 0x28(%r14), %rdi
leaq 0x38(%r14), %r13
movl 0x34(%r14), %edx
movq %r13, %rsi
callq *0x10(%r14)
testl %eax, %eax
je 0x234de
movq %r13, 0xb8(%r14)
cltq
addq %r13, %rax
movq %rax, 0xc0(%r14)
jmp 0x234fd
addq $0x9, 0xb8(%r14)
xorl %r15d, %r15d
jmp 0x23572
xorl %r15d, %r15d
jmp 0x23512
movl $0x0, 0x30(%r14)
movq %r13, 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), %r15b
cmpb $0x20, %r15b
ja 0x2334c
movzbl %r15b, %eax
movabsq $0x101018100, %rcx      # imm = 0x101018100
btq %rax, %rcx
jae 0x2334c
cmpq $0x0, 0x10(%r14)
je 0x2356a
movq 0xc0(%r14), %rcx
movl 0xb8(%r14), %edx
movl %ecx, %eax
subl %edx, %eax
cmpl $0x3, %eax
jg 0x2356a
movq %rcx, 0xb8(%r14)
movq 0x28(%r14), %rdi
movl $0x4, %esi
subl %eax, %esi
callq *0x18(%r14)
jmp 0x23572
addq $0x4, 0xb8(%r14)
movq %r14, %rdi
callq 0x15be7
testl %eax, %eax
je 0x2334c
movl %eax, %ebp
movq %r14, %rdi
callq 0x15be7
testl %eax, %eax
je 0x2334c
movq 0xb8(%r14), %rdx
cmpq 0xc0(%r14), %rdx
movq %r12, 0x20(%rsp)
jb 0x2360f
cmpl $0x0, 0x30(%r14)
je 0x235e0
movl %eax, 0xc(%rsp)
movq 0x28(%r14), %rdi
leaq 0x38(%r14), %r13
movl 0x34(%r14), %edx
movq %r13, %rsi
callq *0x10(%r14)
testl %eax, %eax
je 0x235e5
movq %r13, 0xb8(%r14)
cltq
addq %r13, %rax
movq %rax, 0xc0(%r14)
jmp 0x23604
xorl %r12d, %r12d
jmp 0x2361d
movl $0x0, 0x30(%r14)
movq %r13, 0xb8(%r14)
leaq 0x39(%r14), %rax
movq %rax, 0xc0(%r14)
movb $0x0, 0x38(%r14)
movl 0xc(%rsp), %eax
movq 0xb8(%r14), %rdx
leaq 0x1(%rdx), %rcx
movq %rcx, 0xb8(%r14)
movb (%rdx), %r12b
movq 0xb8(%r14), %rcx
cmpq 0xc0(%r14), %rcx
jb 0x2368e
cmpl $0x0, 0x30(%r14)
je 0x23698
movl %eax, 0xc(%rsp)
movq 0x28(%r14), %rdi
leaq 0x38(%r14), %r13
movl 0x34(%r14), %edx
movq %r13, %rsi
callq *0x10(%r14)
testl %eax, %eax
je 0x23664
movq %r13, 0xb8(%r14)
cltq
addq %r13, %rax
movq %rax, 0xc0(%r14)
jmp 0x23683
movl $0x0, 0x30(%r14)
movq %r13, 0xb8(%r14)
leaq 0x39(%r14), %rax
movq %rax, 0xc0(%r14)
movb $0x0, 0x38(%r14)
movl 0xc(%rsp), %eax
movq 0xb8(%r14), %rcx
incq %rcx
movq %rcx, 0xb8(%r14)
testb %r15b, %r15b
je 0x236ed
cmpb $0x8, %r12b
je 0x236b0
movzbl %r12b, %ecx
cmpl $0x10, %ecx
jne 0x2334c
movzbl %r15b, %r8d
cmpl $0xf, %r8d
jle 0x23723
cmpl $0x20, %r8d
movq 0x20(%rsp), %rdx
movq 0x10(%rsp), %rdi
je 0x2376e
cmpl $0x18, %r8d
je 0x2376e
cmpl $0x10, %r8d
movq 0x18(%rsp), %rsi
jne 0x23743
movl $0x3, %ecx
jmp 0x23793
movzbl %r12b, %r8d
cmpl $0xf, %r8d
jle 0x23747
cmpl $0x20, %r8d
movq 0x18(%rsp), %rsi
je 0x2377d
cmpl $0x18, %r8d
je 0x2377d
cmpl $0x10, %r8d
movq 0x20(%rsp), %rdx
jne 0x2378c
andb $-0x9, %bl
xorl %ecx, %ecx
cmpb $0x3, %bl
sete %cl
xorl $0x3, %ecx
jmp 0x2378e
movl $0x1, %ecx
cmpl $0x8, %r8d
movq 0x20(%rsp), %rdx
movq 0x18(%rsp), %rsi
movq 0x10(%rsp), %rdi
je 0x23793
cmpl $0xf, %r8d
je 0x236e3
xorl %ecx, %ecx
jmp 0x23793
movl $0x1, %ecx
cmpl $0x8, %r8d
movq 0x20(%rsp), %rdx
movq 0x18(%rsp), %rsi
movq 0x10(%rsp), %rdi
je 0x23793
cmpl $0xf, %r8d
jne 0x2378c
movl $0x3, %ecx
jmp 0x2378e
shrb $0x3, %r15b
movzbl %r15b, %ecx
movq 0x18(%rsp), %rsi
jmp 0x23793
shrb $0x3, %r12b
movzbl %r12b, %ecx
movq 0x20(%rsp), %rdx
jmp 0x2378e
xorl %ecx, %ecx
movq 0x10(%rsp), %rdi
testl %ecx, %ecx
je 0x2334c
testq %rdi, %rdi
je 0x237a2
movl %ebp, (%rdi)
testq %rsi, %rsi
je 0x237a9
movl %eax, (%rsi)
movl $0x1, %eax
testq %rdx, %rdx
je 0x2335e
movl %ecx, (%rdx)
jmp 0x2335e
nop