// File: /workspace/github_cpp_makefile_star2_O1/dannye[P]jed/src/decoder.cpp
// Function: BitReader::readBit()
uint readBit() {
        if (nextBit == 0) {
            if (!hasBits()) {
                return -1;
            }
            nextByte = inFile.get();
            while (nextByte == 0xFF) {
                if (!hasBits()) {
                    return -1;
                }
                byte marker = inFile.peek();
                // ignore multiple 0xFF's in a row
                while (marker == 0xFF) {
                    inFile.get();
                    if (!hasBits()) {
                        return -1;
                    }
                    marker = inFile.peek();
                }
                // literal 0xFF's are encoded in the bitstream as 0xFF00
                if (marker == 0x00) {
                    inFile.get();
                    break;
                }
                // restart marker
                else if (marker >= RST0 && marker <= RST7) {
                    inFile.get();
                    nextByte = inFile.get();
                }
                else {
                    std::cout << "Error - Invalid marker: 0x" << std::hex << (uint)marker << std::dec << '\n';
                    return -1;
                }
            }
        }
        uint bit = (nextByte >> (7 - nextBit)) & 1;
        nextBit = (nextBit + 1) % 8;
        return bit;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpb $0x0, 0x1(%rdi)
je 0x66c6
movzbl (%rbx), %eax
movb 0x1(%rbx), %cl
movb $0x7, %dl
subb %cl, %dl
movzbl %dl, %edx
xorl %ebp, %ebp
btl %edx, %eax
setb %bpl
incb %cl
andb $0x7, %cl
movb %cl, 0x1(%rbx)
jmp 0x66da
movq 0x8(%rbx), %rax
movq -0x18(%rax), %rax
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testb $0x5, 0x28(%rbx,%rax)
je 0x66eb
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8(%rbx), %r14
movq %r14, %rdi
callq 0x2140
movb %al, (%rbx)
movq 0x38d8(%rip), %r15      # 0x9fd8
leaq 0x7(%rsp), %r13
cmpb $-0x1, (%rbx)
jne 0x66a6
movq 0x8(%rbx), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x28(%rbx,%rax)
jne 0x66da
movq %r14, %rdi
callq 0x2070
cmpb $-0x1, %al
jne 0x6741
movq %r14, %rdi
callq 0x2140
movq 0x8(%rbx), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x28(%rbx,%rax)
je 0x6719
jmp 0x67e4
movzbl %al, %ecx
testl %ecx, %ecx
jne 0x675a
movq %r14, %rdi
callq 0x2140
movl $0x3, %eax
jmp 0x67e9
movl %eax, %ecx
andl $0xf8, %ecx
cmpl $0xd0, %ecx
jne 0x6780
movq %r14, %rdi
callq 0x2140
movq %r14, %rdi
callq 0x2140
movb %al, (%rbx)
xorl %eax, %eax
jmp 0x67e9
movzbl %al, %r12d
movl $0x1a, %edx
movq %r15, %rdi
leaq 0x1217(%rip), %rsi      # 0x79aa
callq 0x2130
movq (%r15), %rax
movq -0x18(%rax), %rax
movl 0x18(%r15,%rax), %ecx
andl $-0x4b, %ecx
orl $0x8, %ecx
movl %ecx, 0x18(%r15,%rax)
movq %r15, %rdi
movq %r12, %rsi
callq 0x20a0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movl 0x18(%rax,%rcx), %edx
andl $-0x4b, %edx
orl $0x2, %edx
movl %edx, 0x18(%rax,%rcx)
movb $0xa, 0x7(%rsp)
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x2130
movl $0x1, %eax
testl %eax, %eax
je 0x6705
cmpl $0x1, %eax
jne 0x66a6
jmp 0x66da
nop