// File: OpenFirework[P]MyJPEG_Decoder/./jpeg/jpeg_decoder.cpp
// Function: readMCU(unsigned char*&)
MCU readMCU(byte *&framedata) {
    static int dc[4] = {0, 0, 0, 0};
    auto mcu = MCU();
    for (int i = 1; i <= 3; i++) {
        for (int h = 0; h < subVector[i].height; h++) {
            for (int w = 0; w < subVector[i].width; w++) {              
                dc[i] = readDC(framedata, i/2) + dc[i];
                mcu.mcu[i][h][w][0][0] = dc[i];
                unsigned int count = 1;
                while (count < 64) {   //8*8个数据
                    acCode ac = readAC(framedata, i/2);
                    if (ac.len == 0 && ac.zeros == 16) {
                        for (int j = 0; j < ac.zeros; j++) {
                            mcu.mcu[i][h][w][count/8][count%8] = 0;
                            count++;
                        }
                    } else if (ac.len == 0) { //如果读到0，提前结束
                        break;
                    } else {                //补足对应的0的个数
                        for (int j = 0; j < ac.zeros; j++) {
                            mcu.mcu[i][h][w][count/8][count%8] = 0;
                            count++;
                        }
                        mcu.mcu[i][h][w][count/8][count%8] = ac.value;
                        count++;
                    }
                }
                while (count < 64) {  //补足对应的0的个数，补足8*8个位置
                    mcu.mcu[i][h][w][count/8][count%8] = 0;
                    count++;
                }
            }
        }
    } //end for
    return mcu;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x38(%rbp)
movq %rdi, %rax
movq %rax, -0x30(%rbp)
movq %rsi, -0x8(%rbp)
xorl %esi, %esi
movl $0x2000, %edx           # imm = 0x2000
callq 0x20c0
movl $0x1, -0xc(%rbp)
cmpl $0x3, -0xc(%rbp)
jg 0x49b8
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
movslq -0xc(%rbp), %rdx
leaq 0x79b7(%rip), %rcx      # 0xc0d0
movzbl 0x2(%rcx,%rdx,4), %ecx
cmpl %ecx, %eax
jge 0x49a8
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movslq -0xc(%rbp), %rdx
leaq 0x7995(%rip), %rcx      # 0xc0d0
movzbl 0x1(%rcx,%rdx,4), %ecx
cmpl %ecx, %eax
jge 0x4998
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movzbl %al, %esi
callq 0x3fe0
movl %eax, %esi
movq -0x38(%rbp), %rax
movslq -0xc(%rbp), %rdx
leaq 0x7980(%rip), %rcx      # 0xc0f0
addl (%rcx,%rdx,4), %esi
movslq -0xc(%rbp), %rdx
leaq 0x7972(%rip), %rcx      # 0xc0f0
movl %esi, (%rcx,%rdx,4)
movslq -0xc(%rbp), %rdx
leaq 0x7964(%rip), %rcx      # 0xc0f0
cvtsi2sdl (%rcx,%rdx,4), %xmm0
movslq -0xc(%rbp), %rcx
shlq $0xb, %rcx
addq %rcx, %rax
movslq -0x10(%rbp), %rcx
shlq $0xa, %rcx
addq %rcx, %rax
movslq -0x14(%rbp), %rcx
shlq $0x9, %rcx
addq %rcx, %rax
movsd %xmm0, (%rax)
movl $0x1, -0x18(%rbp)
cmpl $0x40, -0x18(%rbp)
jae 0x4931
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movzbl %al, %esi
callq 0x4310
movq %rax, -0x20(%rbp)
movzbl -0x20(%rbp), %eax
cmpl $0x0, %eax
jne 0x4863
movzbl -0x1f(%rbp), %eax
cmpl $0x10, %eax
jne 0x4863
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movzbl -0x1f(%rbp), %ecx
cmpl %ecx, %eax
jge 0x485e
movq -0x38(%rbp), %rax
movslq -0xc(%rbp), %rcx
shlq $0xb, %rcx
addq %rcx, %rax
movslq -0x10(%rbp), %rcx
shlq $0xa, %rcx
addq %rcx, %rax
movslq -0x14(%rbp), %rcx
shlq $0x9, %rcx
addq %rcx, %rax
movl -0x18(%rbp), %ecx
shrl $0x3, %ecx
movl %ecx, %ecx
shlq $0x6, %rcx
addq %rcx, %rax
movl -0x18(%rbp), %ecx
andl $0x7, %ecx
movl %ecx, %ecx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x47fb
jmp 0x492c
movzbl -0x20(%rbp), %eax
cmpl $0x0, %eax
jne 0x4871
jmp 0x4931
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
movzbl -0x1f(%rbp), %ecx
cmpl %ecx, %eax
jge 0x48db
movq -0x38(%rbp), %rax
movslq -0xc(%rbp), %rcx
shlq $0xb, %rcx
addq %rcx, %rax
movslq -0x10(%rbp), %rcx
shlq $0xa, %rcx
addq %rcx, %rax
movslq -0x14(%rbp), %rcx
shlq $0x9, %rcx
addq %rcx, %rax
movl -0x18(%rbp), %ecx
shrl $0x3, %ecx
movl %ecx, %ecx
shlq $0x6, %rcx
addq %rcx, %rax
movl -0x18(%rbp), %ecx
andl $0x7, %ecx
movl %ecx, %ecx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x4878
movq -0x38(%rbp), %rax
cvtsi2sdl -0x1c(%rbp), %xmm0
movslq -0xc(%rbp), %rcx
shlq $0xb, %rcx
addq %rcx, %rax
movslq -0x10(%rbp), %rcx
shlq $0xa, %rcx
addq %rcx, %rax
movslq -0x14(%rbp), %rcx
shlq $0x9, %rcx
addq %rcx, %rax
movl -0x18(%rbp), %ecx
shrl $0x3, %ecx
movl %ecx, %ecx
shlq $0x6, %rcx
addq %rcx, %rax
movl -0x18(%rbp), %ecx
andl $0x7, %ecx
movl %ecx, %ecx
movsd %xmm0, (%rax,%rcx,8)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x492c
jmp 0x47bd
jmp 0x4933
cmpl $0x40, -0x18(%rbp)
jae 0x4988
movq -0x38(%rbp), %rax
movslq -0xc(%rbp), %rcx
shlq $0xb, %rcx
addq %rcx, %rax
movslq -0x10(%rbp), %rcx
shlq $0xa, %rcx
addq %rcx, %rax
movslq -0x14(%rbp), %rcx
shlq $0x9, %rcx
addq %rcx, %rax
movl -0x18(%rbp), %ecx
shrl $0x3, %ecx
movl %ecx, %ecx
shlq $0x6, %rcx
addq %rcx, %rax
movl -0x18(%rbp), %ecx
andl $0x7, %ecx
movl %ecx, %ecx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x4933
jmp 0x498a
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x472d
jmp 0x499a
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x470b
jmp 0x49aa
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x46fa
movq -0x30(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)