// File: /workspace/github_cpp_makefile_star2_O3/OpenFirework[P]MyJPEG_Decoder/./jpeg/jpeg_decoder.cpp
// Function: readDC(unsigned char*&, unsigned char)
int readDC(byte *&framedata, unsigned char number) {
    unsigned int len = 0;
    unsigned char codeLen;
    for (int count = 1; ; count++) {
        len = len << 1;
        len += (unsigned int)getBit(framedata);
        if(number == 0) {
            for(int v=0;v<YDCHT.size();v++) {
                if((YDCHT[v].codeLength==count) && (YDCHT[v].encodeValue==len)) {
                    codeLen = YDCHT[v].realVale;
                    if (codeLen == 0) { return 0; }
                    unsigned char first = getBit(framedata);
                    int ret = 1;
                    for (int i = 1; i < codeLen; i++) {
                        unsigned char b = getBit(framedata);
                        ret = ret << 1;
                        ret += first ? b : !b;
                    }
                    ret = first ? ret : -ret;
                    return ret;
                }
            }
            if (count > 16) {fprintf(stderr, "key not found\n"); count = 1; len = 0; }
        } else {
            for(int v=0;v<UVDCHT.size();v++) {
                if((UVDCHT[v].codeLength==count) && (UVDCHT[v].encodeValue==len)) {
                    codeLen = UVDCHT[v].realVale;
                    if (codeLen == 0) { return 0; }
                    unsigned char first = getBit(framedata);
                    int ret = 1;
                    for (int i = 1; i < codeLen; i++) {
                        unsigned char b = getBit(framedata);
                        ret = ret << 1;
                        ret += first ? b : !b;
                    }
                    ret = first ? ret : -ret;
                    return ret;
                }
            }
            if (count > 16) {fprintf(stderr, "key not found\n"); count = 1; len = 0; }
        }
        
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %r14d
movq %rdi, %rbx
xorl %r12d, %r12d
movl $0x1, %r13d
movabsq $-0x5555555555555555, %r15 # imm = 0xAAAAAAAAAAAAAAAB
movq %rbx, %rdi
callq 0x2d62
movzbl %al, %eax
leal (%rax,%r12,2), %r12d
testb %r14b, %r14b
je 0x2e67
movq 0x6259(%rip), %rcx      # 0x9080
movq 0x624a(%rip), %rax      # 0x9078
subq %rax, %rcx
je 0x2e5c
sarq $0x2, %rcx
imulq %r15, %rcx
cmpq $0x1, %rcx
adcq $0x0, %rcx
addq $0x8, %rax
cmpl %r13d, -0x8(%rax)
jne 0x2e53
cmpl %r12d, -0x4(%rax)
je 0x2eb9
addq $0xc, %rax
decq %rcx
jne 0x2e47
cmpl $0x11, %r13d
jge 0x2ea9
incl %r13d
jmp 0x2e0c
movq 0x61e2(%rip), %rcx      # 0x9050
movq 0x61d3(%rip), %rax      # 0x9048
subq %rax, %rcx
je 0x2ea3
sarq $0x2, %rcx
imulq %r15, %rcx
cmpq $0x1, %rcx
adcq $0x0, %rcx
addq $0x8, %rax
cmpl %r13d, -0x8(%rax)
jne 0x2e9a
cmpl %r12d, -0x4(%rax)
je 0x2f01
addq $0xc, %rax
decq %rcx
jne 0x2e8e
cmpl $0x10, %r13d
jle 0x2e62
callq 0x230c
xorl %r12d, %r12d
movl $0x1, %r13d
jmp 0x2e62
movzbl (%rax), %r15d
testl %r15d, %r15d
je 0x2f51
movq %rbx, %rdi
callq 0x2d62
movl %eax, %r14d
movl $0x1, %r12d
cmpl $0x1, %r15d
je 0x2f43
decl %r15d
movl $0x1, %r12d
movq %rbx, %rdi
callq 0x2d62
xorb %r14b, %al
xorb $0x1, %al
movzbl %al, %eax
leal (%rax,%r12,2), %r12d
decl %r15d
jne 0x2ee6
jmp 0x2f43
movzbl (%rax), %r15d
testl %r15d, %r15d
je 0x2f51
movq %rbx, %rdi
callq 0x2d62
movl %eax, %r14d
movl $0x1, %r12d
cmpl $0x1, %r15d
je 0x2f43
decl %r15d
movl $0x1, %r12d
movq %rbx, %rdi
callq 0x2d62
xorb %r14b, %al
xorb $0x1, %al
movzbl %al, %eax
leal (%rax,%r12,2), %r12d
decl %r15d
jne 0x2f2a
movl %r12d, %eax
negl %eax
testb %r14b, %r14b
cmovnel %r12d, %eax
jmp 0x2f53
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq