// File: /workspace/github_cpp_makefile_star2_O3/Lut99[P]RayTracer/src/lib/LodePNG.cpp
// Function: lode_png_test_bitreader(unsigned char const*, unsigned long, unsigned long, unsigned long const*, unsigned int*)
unsigned lode_png_test_bitreader(const unsigned char* data, size_t size,
                                 size_t numsteps, const size_t* steps, unsigned* result) {
  size_t i;
  LodePNGBitReader reader;
  LodePNGBitReader_init(&reader, data, size);
  for(i = 0; i < numsteps; i++) {
    size_t step = steps[i];
    unsigned ok;
    if(step > 25) ok = ensureBits32(&reader, step);
    else if(step > 17) ok = ensureBits25(&reader, step);
    else if(step > 9) ok = ensureBits17(&reader, step);
    else ok = ensureBits9(&reader, step);
    if(!ok) return 0;
    result[i] = readBits(&reader, step);
  }
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r8, %rbx
movq %rcx, %r14
movq %rdx, %r15
movq %rdi, (%rsp)
movq %rsi, 0x8(%rsp)
leaq (,%rsi,8), %rax
movq %rax, 0x10(%rsp)
shrq $0x3d, %rsi
setne %cl
cmpq $-0x40, %rax
setae %al
orb %cl, %al
jne 0x6477f
movq $0x0, 0x18(%rsp)
movl $0x0, 0x20(%rsp)
movl $0x1, %ebp
testq %r15, %r15
je 0x64917
xorl %edx, %edx
xorl %r12d, %r12d
movq (%r14,%r12,8), %r13
cmpq $0x1a, %r13
jb 0x647d6
movq %rdx, %rax
shrq $0x3, %rax
movq 0x8(%rsp), %rcx
leaq 0x4(%rax), %rsi
cmpq %rcx, %rsi
jae 0x6480c
movq (%rsp), %rsi
movl (%rsi,%rax), %edi
movl %edx, %ecx
andb $0x7, %cl
shrl %cl, %edi
movzbl 0x4(%rsi,%rax), %esi
shll $0x18, %esi
movb $0x8, %al
subb %cl, %al
movl %eax, %ecx
shll %cl, %esi
orl %edi, %esi
jmp 0x648e7
cmpq $0x12, %r13
jb 0x6486c
movq %rdx, %rcx
shrq $0x3, %rcx
movq 0x8(%rsp), %rsi
leaq 0x3(%rcx), %rax
cmpq %rsi, %rax
jae 0x6487f
movq (%rsp), %rax
movl (%rax,%rcx), %esi
movl %edx, %ecx
andb $0x7, %cl
shrl %cl, %esi
jmp 0x648e7
xorl %esi, %esi
cmpq %rcx, %rax
jae 0x6481b
movq (%rsp), %rsi
movzbl (%rsi,%rax), %esi
leaq 0x1(%rax), %rdi
cmpq %rcx, %rdi
jae 0x64832
movq (%rsp), %r8
movzbl (%r8,%rdi), %edi
shll $0x8, %edi
orl %edi, %esi
leaq 0x2(%rax), %rdi
cmpq %rcx, %rdi
jae 0x64849
movq (%rsp), %r8
movzbl (%r8,%rdi), %edi
shll $0x10, %edi
orl %edi, %esi
addq $0x3, %rax
cmpq %rcx, %rax
jae 0x6485f
movq (%rsp), %rcx
movzbl (%rcx,%rax), %eax
shll $0x18, %eax
orl %eax, %esi
movl %edx, %ecx
andb $0x7, %cl
shrl %cl, %esi
movl %esi, 0x20(%rsp)
jmp 0x648c6
movq %rsp, %rdi
movq %r13, %rsi
cmpq $0xa, %r13
jb 0x648d5
callq 0x64928
jmp 0x648da
xorl %eax, %eax
cmpq %rsi, %rcx
jae 0x6488e
movq (%rsp), %rax
movzbl (%rax,%rcx), %eax
leaq 0x1(%rcx), %rdi
cmpq %rsi, %rdi
jae 0x648a5
movq (%rsp), %r8
movzbl (%r8,%rdi), %edi
shll $0x8, %edi
orl %edi, %eax
addq $0x2, %rcx
cmpq %rsi, %rcx
jae 0x648bb
movq (%rsp), %rsi
movzbl (%rsi,%rcx), %ecx
shll $0x10, %ecx
orl %ecx, %eax
movl %edx, %ecx
andb $0x7, %cl
shrl %cl, %eax
movl %eax, 0x20(%rsp)
addq %r13, %rdx
xorl %eax, %eax
cmpq 0x10(%rsp), %rdx
setbe %al
jmp 0x648da
callq 0x649a4
testl %eax, %eax
je 0x64915
movl 0x20(%rsp), %esi
movq 0x18(%rsp), %rdx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %r13d, %ecx
shll %cl, %eax
notl %eax
andl %esi, %eax
shrl %cl, %esi
movl %esi, 0x20(%rsp)
addq %r13, %rdx
movq %rdx, 0x18(%rsp)
movl %eax, (%rbx,%r12,4)
incq %r12
cmpq %r12, %r15
jne 0x64792
jmp 0x64917
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq