// File: /workspace/github_cpp_makefile_star2_O2/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 %r13d, %r13d
pushq $0x1
popq %r15
pushq $0xc
popq %r12
movq %rbx, %rdi
callq 0x2af1
movzbl %al, %eax
leal (%rax,%r13,2), %r13d
testb %r14b, %r14b
je 0x2be0
movq 0x54d6(%rip), %rax      # 0x8080
movq 0x54c7(%rip), %rcx      # 0x8078
subq %rcx, %rax
cqto
idivq %r12
addq $0x8, %rcx
subq $0x1, %rax
jb 0x2bd5
cmpl %r15d, -0x8(%rcx)
jne 0x2bcf
cmpl %r13d, -0x4(%rcx)
je 0x2c3d
addq $0xc, %rcx
jmp 0x2bbd
cmpl $0x11, %r15d
jge 0x2c18
incl %r15d
jmp 0x2b8f
movq 0x5469(%rip), %rax      # 0x8050
movq 0x545a(%rip), %rcx      # 0x8048
subq %rcx, %rax
cqto
idivq %r12
addq $0x8, %rcx
subq $0x1, %rax
jb 0x2c12
cmpl %r15d, -0x8(%rcx)
jne 0x2c0c
cmpl %r13d, -0x4(%rcx)
je 0x2c74
addq $0xc, %rcx
jmp 0x2bfa
cmpl $0x10, %r15d
jle 0x2bdb
movq 0x43b9(%rip), %rax      # 0x6fd8
movq (%rax), %rcx
leaq 0x16b4(%rip), %rdi      # 0x42dd
pushq $0xe
popq %rsi
pushq $0x1
popq %rdx
callq 0x2250
xorl %r13d, %r13d
pushq $0x1
popq %r15
jmp 0x2bdb
movzbl (%rcx), %r15d
testl %r15d, %r15d
je 0x2cb9
movq %rbx, %rdi
callq 0x2af1
movl %eax, %r14d
decl %r15d
pushq $0x1
popq %r12
subl $0x1, %r15d
jb 0x2cab
movq %rbx, %rdi
callq 0x2af1
xorb %r14b, %al
xorb $0x1, %al
movzbl %al, %eax
leal (%rax,%r12,2), %r12d
jmp 0x2c58
movzbl (%rcx), %r15d
testl %r15d, %r15d
je 0x2cb9
movq %rbx, %rdi
callq 0x2af1
movl %eax, %r14d
decl %r15d
pushq $0x1
popq %r12
subl $0x1, %r15d
jb 0x2cab
movq %rbx, %rdi
callq 0x2af1
xorb %r14b, %al
xorb $0x1, %al
movzbl %al, %eax
leal (%rax,%r12,2), %r12d
jmp 0x2c8f
movl %r12d, %eax
negl %eax
testb %r14b, %r14b
cmovnel %r12d, %eax
jmp 0x2cbb
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq