// File: rapirent[P]JPEG/decoder.c
// Function: calcualte_mcu_block(_IO_FILE*, unsigned char)
void calcualte_mcu_block(FILE *fp, byte component_id)
{
    static int dc_block[5] = {0,0,0,0,0};
    memset(block,0,sizeof(block));
    int dc_table_id = huffman_table_index((component_mapping_huffman[component_id]>> 4)&0x0f);
    byte need_read_bit = decode_huffman(fp,dc_table_id);
    byte leading_bit;
    if (need_read_bit) {
        dc_block[component_id] += codeword_decode(fp,need_read_bit);
    }
    block[0][0] = dc_block[component_id];
    int ac_table_id = huffman_table_index((component_mapping_huffman[component_id]
                                           &0x0f)|0x10);
    byte zerosnum_needread,zerosnum;
    for (int i = 1; i< 64;) {
        zerosnum_needread = decode_huffman(fp,ac_table_id);
        if(zerosnum_needread == 0x00) {
            break;
        }
        if(zerosnum_needread == 0xf0) {
            i+=16;
            continue;
        }
        need_read_bit = zerosnum_needread & 0x0f;
        zerosnum = (zerosnum_needread >> 4) & 0x0f;
        for (byte j = 0; j< zerosnum; j++) {
            block[i/8][i%8] = 0.0;
            i++;
        }
        if (need_read_bit) {
            block[i/8][i%8] = codeword_decode(fp,need_read_bit);
            i++;
        }
    }
    for (int quantize_i = 0; quantize_i<64; quantize_i++) {
        block[quantize_i/8][quantize_i%8] *=
            quantize_table_list[(f0.frame_components[component_id]).qantize_table_id][quantize_i];
    }
    double tmp[8][8];
    for (int x = 0; x < 8; x++) {
        for (int y = 0; y < 8; y++) {
            tmp[x][y] = block[zigzag_index[x][y]/8][zigzag_index[x][y]%8];
        }
    }
    double s[8][8];
    memset(s,0,sizeof(s));
    for (int jj = 0; jj < 8; jj++) {
        for (int x = 0; x < 8; x++) {
            for (int y = 0; y < 8; y++) {
                s[jj][x] += c (y) * tmp[x][y] * cos_cache[(jj + jj + 1) * y];
            }
            s[jj][x] = s[jj][x] / 2.0;
        }
    }
    memset(block,0,sizeof(block));
    for (int ii = 0; ii < 8; ii++) {
        for (int jj = 0; jj < 8; jj++) {
            for (int x = 0; x < 8; x++) {
                block[ii][jj] += c(x) * s[jj][x] * cos_cache[(ii + ii + 1) * x];
            }
            block[ii][jj] = block[ii][jj] / 2.0;
            block[ii][jj] += 128.0;
        }
    }
}

// Assembly:
subq $0x478, %rsp            # imm = 0x478
movb %sil, %al
movq %rdi, 0x470(%rsp)
movb %al, 0x46f(%rsp)
leaq 0x8d60(%rip), %rdi      # 0xed50
xorl %esi, %esi
movl $0x200, %edx            # imm = 0x200
callq 0x50c0
movzbl 0x46f(%rsp), %eax
movl %eax, %ecx
leaq 0x8d33(%rip), %rax      # 0xed40
movzbl (%rax,%rcx), %eax
sarl $0x4, %eax
andl $0xf, %eax
movzbl %al, %edi
callq 0x5550
movl %eax, 0x468(%rsp)
movq 0x470(%rsp), %rdi
movl 0x468(%rsp), %esi
callq 0x5e70
movb %al, 0x467(%rsp)
cmpb $0x0, 0x467(%rsp)
je 0x6080
movq 0x470(%rsp), %rdi
movzbl 0x467(%rsp), %esi
callq 0x5db0
movl %eax, %edx
movzbl 0x46f(%rsp), %eax
movl %eax, %ecx
leaq 0x8eed(%rip), %rax      # 0xef60
addl (%rax,%rcx,4), %edx
leaq 0x8ee3(%rip), %rax      # 0xef60
movl %edx, (%rax,%rcx,4)
movzbl 0x46f(%rsp), %eax
movl %eax, %ecx
leaq 0x8ecf(%rip), %rax      # 0xef60
cvtsi2sdl (%rax,%rcx,4), %xmm0
movsd %xmm0, 0x8cb2(%rip)     # 0xed50
movzbl 0x46f(%rsp), %eax
movl %eax, %ecx
leaq 0x8c91(%rip), %rax      # 0xed40
movzbl (%rax,%rcx), %eax
andl $0xf, %eax
orl $0x10, %eax
movzbl %al, %edi
callq 0x5550
movl %eax, 0x460(%rsp)
movl $0x1, 0x458(%rsp)
cmpl $0x40, 0x458(%rsp)
jge 0x6254
movq 0x470(%rsp), %rdi
movl 0x460(%rsp), %esi
callq 0x5e70
movb %al, 0x45f(%rsp)
movzbl 0x45f(%rsp), %eax
cmpl $0x0, %eax
jne 0x610e
jmp 0x6254
movzbl 0x45f(%rsp), %eax
cmpl $0xf0, %eax
jne 0x6130
movl 0x458(%rsp), %eax
addl $0x10, %eax
movl %eax, 0x458(%rsp)
jmp 0x60d3
movzbl 0x45f(%rsp), %eax
andl $0xf, %eax
movb %al, 0x467(%rsp)
movzbl 0x45f(%rsp), %eax
sarl $0x4, %eax
andl $0xf, %eax
movb %al, 0x45e(%rsp)
movb $0x0, 0x457(%rsp)
movzbl 0x457(%rsp), %eax
movzbl 0x45e(%rsp), %ecx
cmpl %ecx, %eax
jge 0x61da
movl 0x458(%rsp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movslq %eax, %rcx
leaq 0x8bc4(%rip), %rax      # 0xed50
shlq $0x6, %rcx
addq %rcx, %rax
movq %rax, 0x20(%rsp)
movl 0x458(%rsp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movq 0x20(%rsp), %rax
movslq %edx, %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl 0x458(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x458(%rsp)
movb 0x457(%rsp), %al
addb $0x1, %al
movb %al, 0x457(%rsp)
jmp 0x615f
cmpb $0x0, 0x467(%rsp)
je 0x624f
movq 0x470(%rsp), %rdi
movzbl 0x467(%rsp), %esi
callq 0x5db0
cvtsi2sd %eax, %xmm0
movl 0x458(%rsp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movslq %eax, %rcx
leaq 0x8b3a(%rip), %rax      # 0xed50
shlq $0x6, %rcx
addq %rcx, %rax
movq %rax, 0x18(%rsp)
movl 0x458(%rsp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movq 0x18(%rsp), %rax
movslq %edx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x458(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x458(%rsp)
jmp 0x60d3
movl $0x0, 0x450(%rsp)
cmpl $0x40, 0x450(%rsp)
jge 0x6306
movzbl 0x46f(%rsp), %eax
movl %eax, %ecx
leaq 0x8a62(%rip), %rax      # 0xece0
addq $0x8, %rax
imulq $0x3, %rcx, %rcx
addq %rcx, %rax
movzbl 0x2(%rax), %eax
movl %eax, %ecx
leaq 0x864a(%rip), %rax      # 0xe8e0
shlq $0x8, %rcx
addq %rcx, %rax
movslq 0x450(%rsp), %rcx
cvtsi2sdl (%rax,%rcx,4), %xmm0
movl 0x450(%rsp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movslq %eax, %rcx
leaq 0x8a8d(%rip), %rax      # 0xed50
shlq $0x6, %rcx
addq %rcx, %rax
movq %rax, 0x10(%rsp)
movl 0x450(%rsp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movq 0x10(%rsp), %rax
movslq %edx, %rcx
mulsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl 0x450(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x450(%rsp)
jmp 0x625f
movl $0x0, 0x24c(%rsp)
cmpl $0x8, 0x24c(%rsp)
jge 0x63ff
movl $0x0, 0x248(%rsp)
cmpl $0x8, 0x248(%rsp)
jge 0x63e7
movslq 0x24c(%rsp), %rcx
leaq 0x3dd9(%rip), %rax      # 0xa120
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x248(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movslq %eax, %rcx
leaq 0x89e5(%rip), %rax      # 0xed50
shlq $0x6, %rcx
addq %rcx, %rax
movq %rax, 0x8(%rsp)
movslq 0x24c(%rsp), %rcx
leaq 0x3d9a(%rip), %rax      # 0xa120
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x248(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movq 0x8(%rsp), %rax
movslq %edx, %rcx
movsd (%rax,%rcx,8), %xmm0
movslq 0x24c(%rsp), %rcx
leaq 0x250(%rsp), %rax
shlq $0x6, %rcx
addq %rcx, %rax
movslq 0x248(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x248(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x248(%rsp)
jmp 0x632a
jmp 0x63e9
movl 0x24c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24c(%rsp)
jmp 0x6311
leaq 0x40(%rsp), %rdi
xorl %esi, %esi
movl $0x200, %edx            # imm = 0x200
callq 0x50c0
movl $0x0, 0x3c(%rsp)
cmpl $0x8, 0x3c(%rsp)
jge 0x6527
movl $0x0, 0x38(%rsp)
cmpl $0x8, 0x38(%rsp)
jge 0x6515
movl $0x0, 0x34(%rsp)
cmpl $0x8, 0x34(%rsp)
jge 0x64c3
movl 0x34(%rsp), %edi
callq 0x5f90
movslq 0x38(%rsp), %rcx
leaq 0x250(%rsp), %rax
shlq $0x6, %rcx
addq %rcx, %rax
movslq 0x34(%rsp), %rcx
mulsd (%rax,%rcx,8), %xmm0
movl 0x3c(%rsp), %eax
addl 0x3c(%rsp), %eax
addl $0x1, %eax
imull 0x34(%rsp), %eax
movslq %eax, %rcx
leaq 0x7e1a(%rip), %rax      # 0xe2a0
movsd (%rax,%rcx,8), %xmm2
movslq 0x3c(%rsp), %rcx
leaq 0x40(%rsp), %rax
shlq $0x6, %rcx
addq %rcx, %rax
movslq 0x38(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl 0x34(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x34(%rsp)
jmp 0x643e
movslq 0x3c(%rsp), %rcx
leaq 0x40(%rsp), %rax
shlq $0x6, %rcx
addq %rcx, %rax
movslq 0x38(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd 0x3d62(%rip), %xmm1     # 0xa248
divsd %xmm1, %xmm0
movslq 0x3c(%rsp), %rcx
leaq 0x40(%rsp), %rax
shlq $0x6, %rcx
addq %rcx, %rax
movslq 0x38(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x38(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x38(%rsp)
jmp 0x642b
jmp 0x6517
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rsp)
jmp 0x6418
leaq 0x8822(%rip), %rdi      # 0xed50
xorl %esi, %esi
movl $0x200, %edx            # imm = 0x200
callq 0x50c0
movl $0x0, 0x30(%rsp)
cmpl $0x8, 0x30(%rsp)
jge 0x667e
movl $0x0, 0x2c(%rsp)
cmpl $0x8, 0x2c(%rsp)
jge 0x666c
movl $0x0, 0x28(%rsp)
cmpl $0x8, 0x28(%rsp)
jge 0x65ec
movl 0x28(%rsp), %edi
callq 0x5f90
movslq 0x2c(%rsp), %rcx
leaq 0x40(%rsp), %rax
shlq $0x6, %rcx
addq %rcx, %rax
movslq 0x28(%rsp), %rcx
mulsd (%rax,%rcx,8), %xmm0
movl 0x30(%rsp), %eax
addl 0x30(%rsp), %eax
addl $0x1, %eax
imull 0x28(%rsp), %eax
movslq %eax, %rcx
leaq 0x7cf3(%rip), %rax      # 0xe2a0
movsd (%rax,%rcx,8), %xmm2
movslq 0x30(%rsp), %rcx
leaq 0x8792(%rip), %rax      # 0xed50
shlq $0x6, %rcx
addq %rcx, %rax
movslq 0x2c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl 0x28(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x28(%rsp)
jmp 0x6568
movslq 0x30(%rsp), %rcx
leaq 0x8758(%rip), %rax      # 0xed50
shlq $0x6, %rcx
addq %rcx, %rax
movslq 0x2c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd 0x3c37(%rip), %xmm1     # 0xa248
divsd %xmm1, %xmm0
movslq 0x30(%rsp), %rcx
leaq 0x872f(%rip), %rax      # 0xed50
shlq $0x6, %rcx
addq %rcx, %rax
movslq 0x2c(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movslq 0x30(%rsp), %rcx
leaq 0x8712(%rip), %rax      # 0xed50
shlq $0x6, %rcx
addq %rcx, %rax
movslq 0x2c(%rsp), %rcx
movsd 0x3bee(%rip), %xmm0     # 0xa240
addsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x6555
jmp 0x666e
movl 0x30(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x30(%rsp)
jmp 0x6542
addq $0x478, %rsp            # imm = 0x478
retq
nopw %cs:(%rax,%rax)