// File: Lut99[P]RayTracer/src/lib/LodePNG.cpp
// Function: ensureBits32(LodePNGBitReader*, unsigned long)
static LODEPNG_INLINE unsigned ensureBits32(LodePNGBitReader* reader, size_t nbits) {
  size_t start = reader->bp >> 3u;
  size_t size = reader->size;
  if(start + 4u < size) {
    reader->buffer = (unsigned)reader->data[start + 0] | ((unsigned)reader->data[start + 1] << 8u) |
                     ((unsigned)reader->data[start + 2] << 16u) | ((unsigned)reader->data[start + 3] << 24u);
    reader->buffer >>= (reader->bp & 7u);
    reader->buffer |= (((unsigned)reader->data[start + 4] << 24u) << (8u - (reader->bp & 7u)));
    return 1;
  } else {
    reader->buffer = 0;
    if(start + 0u < size) reader->buffer |= reader->data[start + 0];
    if(start + 1u < size) reader->buffer |= ((unsigned)reader->data[start + 1] << 8u);
    if(start + 2u < size) reader->buffer |= ((unsigned)reader->data[start + 2] << 16u);
    if(start + 3u < size) reader->buffer |= ((unsigned)reader->data[start + 3] << 24u);
    reader->buffer >>= (reader->bp & 7u);
    return reader->bp + nbits <= reader->bitsize;
  }
}

// Assembly:
movq %rdi, -0x10(%rsp)
movq %rsi, -0x18(%rsp)
movq -0x10(%rsp), %rax
movq 0x18(%rax), %rax
shrq $0x3, %rax
movq %rax, -0x20(%rsp)
movq -0x10(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rsp)
movq -0x20(%rsp), %rax
addq $0x4, %rax
cmpq -0x28(%rsp), %rax
jae 0x13d28e
movq -0x10(%rsp), %rax
movq (%rax), %rax
movq -0x20(%rsp), %rcx
movzbl (%rax,%rcx), %ecx
movq -0x10(%rsp), %rax
movq (%rax), %rax
movq -0x20(%rsp), %rdx
movzbl 0x1(%rax,%rdx), %eax
shll $0x8, %eax
orl %eax, %ecx
movq -0x10(%rsp), %rax
movq (%rax), %rax
movq -0x20(%rsp), %rdx
movzbl 0x2(%rax,%rdx), %eax
shll $0x10, %eax
orl %eax, %ecx
movq -0x10(%rsp), %rax
movq (%rax), %rax
movq -0x20(%rsp), %rdx
movzbl 0x3(%rax,%rdx), %eax
shll $0x18, %eax
orl %eax, %ecx
movq -0x10(%rsp), %rax
movl %ecx, 0x20(%rax)
movq -0x10(%rsp), %rax
movq 0x18(%rax), %rcx
andq $0x7, %rcx
movq -0x10(%rsp), %rax
movl 0x20(%rax), %edx
shrl %cl, %edx
movl %edx, %ecx
movl %ecx, 0x20(%rax)
movq -0x10(%rsp), %rax
movq (%rax), %rax
movq -0x20(%rsp), %rcx
movzbl 0x4(%rax,%rcx), %eax
shll $0x18, %eax
movq -0x10(%rsp), %rcx
movq 0x18(%rcx), %rdx
andq $0x7, %rdx
movl $0x8, %ecx
subq %rdx, %rcx
shll %cl, %eax
movl %eax, %ecx
movq -0x10(%rsp), %rax
orl 0x20(%rax), %ecx
movl %ecx, 0x20(%rax)
movl $0x1, -0x4(%rsp)
jmp 0x13d395
movq -0x10(%rsp), %rax
movl $0x0, 0x20(%rax)
movq -0x20(%rsp), %rax
addq $0x0, %rax
cmpq -0x28(%rsp), %rax
jae 0x13d2c6
movq -0x10(%rsp), %rax
movq (%rax), %rax
movq -0x20(%rsp), %rcx
movzbl (%rax,%rcx), %ecx
movq -0x10(%rsp), %rax
orl 0x20(%rax), %ecx
movl %ecx, 0x20(%rax)
movq -0x20(%rsp), %rax
addq $0x1, %rax
cmpq -0x28(%rsp), %rax
jae 0x13d2f6
movq -0x10(%rsp), %rax
movq (%rax), %rax
movq -0x20(%rsp), %rcx
movzbl 0x1(%rax,%rcx), %ecx
shll $0x8, %ecx
movq -0x10(%rsp), %rax
orl 0x20(%rax), %ecx
movl %ecx, 0x20(%rax)
movq -0x20(%rsp), %rax
addq $0x2, %rax
cmpq -0x28(%rsp), %rax
jae 0x13d326
movq -0x10(%rsp), %rax
movq (%rax), %rax
movq -0x20(%rsp), %rcx
movzbl 0x2(%rax,%rcx), %ecx
shll $0x10, %ecx
movq -0x10(%rsp), %rax
orl 0x20(%rax), %ecx
movl %ecx, 0x20(%rax)
movq -0x20(%rsp), %rax
addq $0x3, %rax
cmpq -0x28(%rsp), %rax
jae 0x13d356
movq -0x10(%rsp), %rax
movq (%rax), %rax
movq -0x20(%rsp), %rcx
movzbl 0x3(%rax,%rcx), %ecx
shll $0x18, %ecx
movq -0x10(%rsp), %rax
orl 0x20(%rax), %ecx
movl %ecx, 0x20(%rax)
movq -0x10(%rsp), %rax
movq 0x18(%rax), %rcx
andq $0x7, %rcx
movq -0x10(%rsp), %rax
movl 0x20(%rax), %edx
shrl %cl, %edx
movl %edx, %ecx
movl %ecx, 0x20(%rax)
movq -0x10(%rsp), %rax
movq 0x18(%rax), %rax
addq -0x18(%rsp), %rax
movq -0x10(%rsp), %rcx
cmpq 0x10(%rcx), %rax
setbe %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4(%rsp)
movl -0x4(%rsp), %eax
retq
nopw (%rax,%rax)