// File: /workspace/github_c_makefile_star2_O0/jonof[P]jftekwar/jfbuild/libsquish/squish.cpp
// Function: squish::DecompressImage(unsigned char*, int, int, int, void const*, int)
void DecompressImage( u8* rgba, int width, int height, int pitch, void const* blocks, int flags )
{
    // fix any bad flags
    flags = FixFlags( flags );

    // loop over blocks
#ifdef SQUISH_USE_OPENMP
#   pragma omp parallel for
#endif
    for( int y = 0; y < height; y += 4 )
    {
        // initialise the block input
        u8 const* sourceBlock = reinterpret_cast< u8 const* >( blocks );
        int bytesPerBlock = ( ( flags & ( kDxt1 | kBc4 ) ) != 0 ) ? 8 : 16;
        sourceBlock += ( (y / 4) * ( (width + 3) / 4) ) * bytesPerBlock;

        for( int x = 0; x < width; x += 4 )
        {
            // decompress the block
            u8 targetRgba[4*16];
            Decompress( targetRgba, sourceBlock, flags );

            // write the decompressed pixels to the correct image locations
            u8 const* sourcePixel = targetRgba;
            for( int py = 0; py < 4; ++py )
            {
                for( int px = 0; px < 4; ++px )
                {
                    // get the target location
                    int sx = x + px;
                    int sy = y + py;

                    // write if we're in the image
                    if( sx < width && sy < height )
                    {
                        // copy the rgba value
                        u8* targetPixel = rgba + pitch*sy + 4*sx;
                        CopyRGBA(sourcePixel, targetPixel, flags);
                    }

                    // advance to the next pixel
                    sourcePixel += 4;
                }
            }

            // advance
            sourceBlock += bytesPerBlock;
        }
    }
}

// Assembly:
subq $0x98, %rsp
movq %rdi, 0x90(%rsp)
movl %esi, 0x8c(%rsp)
movl %edx, 0x88(%rsp)
movl %ecx, 0x84(%rsp)
movq %r8, 0x78(%rsp)
movl %r9d, 0x74(%rsp)
movl 0x74(%rsp), %edi
callq 0xa3600
movl %eax, 0x74(%rsp)
movl $0x0, 0x70(%rsp)
movl 0x70(%rsp), %eax
cmpl 0x88(%rsp), %eax
jge 0xa3cf2
movq 0x78(%rsp), %rax
movq %rax, 0x68(%rsp)
movl 0x74(%rsp), %edx
andl $0x9, %edx
movl $0x10, %eax
movl $0x8, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, 0x64(%rsp)
movl 0x70(%rsp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl 0x8c(%rsp), %eax
addl $0x3, %eax
movl $0x4, %esi
cltd
idivl %esi
imull %eax, %ecx
imull 0x64(%rsp), %ecx
movq 0x68(%rsp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, 0x68(%rsp)
movl $0x0, 0x60(%rsp)
movl 0x60(%rsp), %eax
cmpl 0x8c(%rsp), %eax
jge 0xa3ce0
leaq 0x20(%rsp), %rdi
movq 0x68(%rsp), %rsi
movl 0x74(%rsp), %edx
callq 0xa3680
leaq 0x20(%rsp), %rax
movq %rax, 0x18(%rsp)
movl $0x0, 0x14(%rsp)
cmpl $0x4, 0x14(%rsp)
jge 0xa3cbc
movl $0x0, 0x10(%rsp)
cmpl $0x4, 0x10(%rsp)
jge 0xa3caa
movl 0x60(%rsp), %eax
addl 0x10(%rsp), %eax
movl %eax, 0xc(%rsp)
movl 0x70(%rsp), %eax
addl 0x14(%rsp), %eax
movl %eax, 0x8(%rsp)
movl 0xc(%rsp), %eax
cmpl 0x8c(%rsp), %eax
jge 0xa3c8c
movl 0x8(%rsp), %eax
cmpl 0x88(%rsp), %eax
jge 0xa3c8c
movq 0x90(%rsp), %rax
movl 0x84(%rsp), %ecx
imull 0x8(%rsp), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movl 0xc(%rsp), %ecx
shll $0x2, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, (%rsp)
movq 0x18(%rsp), %rdi
movq (%rsp), %rsi
movl 0x74(%rsp), %edx
callq 0xa37b0
movq 0x18(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x18(%rsp)
movl 0x10(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x10(%rsp)
jmp 0xa3c12
jmp 0xa3cac
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0xa3bff
movl 0x64(%rsp), %ecx
movq 0x68(%rsp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, 0x68(%rsp)
movl 0x60(%rsp), %eax
addl $0x4, %eax
movl %eax, 0x60(%rsp)
jmp 0xa3bc9
jmp 0xa3ce2
movl 0x70(%rsp), %eax
addl $0x4, %eax
movl %eax, 0x70(%rsp)
jmp 0xa3b53
addq $0x98, %rsp
retq
nopw (%rax,%rax)