// File: /workspace/github_cpp_makefile_star2_O1/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 0x64c67
movq $0x0, 0x18(%rsp)
movl $0x0, 0x20(%rsp)
movl $0x1, %ebp
testq %r15, %r15
je 0x64e11
xorl %r12d, %r12d
movq (%r14,%r12,8), %r13
cmpq $0x1a, %r13
jb 0x64cc0
movq 0x8(%rsp), %rcx
movq 0x18(%rsp), %rdx
movq %rdx, %rax
shrq $0x3, %rax
leaq 0x4(%rax), %rsi
cmpq %rcx, %rsi
jae 0x64d04
movq (%rsp), %rsi
movl (%rsi,%rax), %edi
andb $0x7, %dl
movl %edx, %ecx
shrl %cl, %edi
movl %edi, 0x20(%rsp)
movzbl 0x4(%rsi,%rax), %eax
shll $0x18, %eax
movb $0x8, %cl
subb %dl, %cl
shll %cl, %eax
orl %edi, %eax
jmp 0x64cf6
cmpq $0x12, %r13
jb 0x64d63
movq 0x8(%rsp), %rcx
movq 0x18(%rsp), %rdx
movq %rdx, %rax
shrq $0x3, %rax
leaq 0x3(%rax), %rsi
cmpq %rcx, %rsi
jae 0x64d76
movq (%rsp), %rcx
movl (%rcx,%rax), %eax
andb $0x7, %dl
movl %edx, %ecx
shrl %cl, %eax
movl %eax, 0x20(%rsp)
movl $0x1, %eax
jmp 0x64ddc
movl $0x0, 0x20(%rsp)
cmpq %rcx, %rax
jae 0x64d1d
movq (%rsp), %rsi
movzbl (%rsi,%rax), %esi
movl %esi, 0x20(%rsp)
leaq 0x1(%rax), %rsi
cmpq %rcx, %rsi
jae 0x64d35
movq (%rsp), %rdi
movzbl (%rdi,%rsi), %esi
shll $0x8, %esi
orl %esi, 0x20(%rsp)
leaq 0x2(%rax), %rsi
cmpq %rcx, %rsi
jae 0x64d4d
movq (%rsp), %rdi
movzbl (%rdi,%rsi), %esi
shll $0x10, %esi
orl %esi, 0x20(%rsp)
addq $0x3, %rax
cmpq %rcx, %rax
jae 0x64dbf
movq (%rsp), %rcx
movzbl (%rcx,%rax), %eax
shll $0x18, %eax
jmp 0x64dbb
movq %rsp, %rdi
movq %r13, %rsi
cmpq $0xa, %r13
jb 0x64dd7
callq 0x64e22
jmp 0x64ddc
movl $0x0, 0x20(%rsp)
cmpq %rcx, %rax
jae 0x64d8f
movq (%rsp), %rsi
movzbl (%rsi,%rax), %esi
movl %esi, 0x20(%rsp)
leaq 0x1(%rax), %rsi
cmpq %rcx, %rsi
jae 0x64da7
movq (%rsp), %rdi
movzbl (%rdi,%rsi), %esi
shll $0x8, %esi
orl %esi, 0x20(%rsp)
addq $0x2, %rax
cmpq %rcx, %rax
jae 0x64dbf
movq (%rsp), %rcx
movzbl (%rcx,%rax), %eax
shll $0x10, %eax
orl %eax, 0x20(%rsp)
movl %edx, %ecx
andb $0x7, %cl
shrl %cl, 0x20(%rsp)
addq %r13, %rdx
xorl %eax, %eax
cmpq 0x10(%rsp), %rdx
setbe %al
jmp 0x64ddc
callq 0x64e9c
testl %eax, %eax
je 0x64e0f
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %r13d, %ecx
shll %cl, %eax
movl 0x20(%rsp), %edx
notl %eax
andl %edx, %eax
shrl %cl, %edx
movl %edx, 0x20(%rsp)
addq %r13, 0x18(%rsp)
movl %eax, (%rbx,%r12,4)
incq %r12
cmpq %r12, %r15
jne 0x64c78
jmp 0x64e11
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq