// File: rapirent[P]JPEG/decoder.c
// Function: read_frame(_IO_FILE*)
void read_frame(FILE *fp)
{
    int len = read_word_to_bigendian(fp);

    fread(&(f0.precision),1,1,fp);
    f0.height = read_word_to_bigendian(fp);
    f0.width = read_word_to_bigendian(fp);
    fread(&(f0.components_num),1,1,fp);

    byte component_id;
    byte sample;
    f0.vmax = 0x00;
    f0.hmax = 0x00;
    for (int i = 0; i < f0.components_num; i++) {
        fread(&component_id,1,1,fp);
        fread(&sample,1,1,fp);
        (f0.frame_components[component_id-1]).horizontal_sample = (sample >> 4) & 0x0f;
        (f0.frame_components[component_id-1]).vertical_sample = sample & 0x0f;
        if( (f0.frame_components[component_id-1]).horizontal_sample > f0.hmax) {
            f0.hmax = (f0.frame_components[component_id-1]).horizontal_sample;
        }
        if( (f0.frame_components[component_id-1]).vertical_sample > f0.vmax) {
            f0.vmax = (f0.frame_components[component_id-1]).vertical_sample;
        }
        fread(&((f0.frame_components[component_id-1]).qantize_table_id),1,1,fp);
    }
}

// Assembly:
subq $0x18, %rsp
movq %rdi, 0x10(%rsp)
movq 0x10(%rsp), %rdi
callq 0x5470
movzwl %ax, %eax
movl %eax, 0xc(%rsp)
movq 0x10(%rsp), %rcx
leaq 0x956a(%rip), %rdi      # 0xece0
addq $0x7, %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5290
movq 0x10(%rsp), %rdi
callq 0x5470
movw %ax, 0x9548(%rip)       # 0xece0
movq 0x10(%rsp), %rdi
callq 0x5470
movw %ax, 0x9539(%rip)       # 0xece2
movq 0x10(%rsp), %rcx
leaq 0x952b(%rip), %rdi      # 0xece0
addq $0x6, %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5290
movb $0x0, 0x9517(%rip)      # 0xece4
movb $0x0, 0x9511(%rip)      # 0xece5
movl $0x0, 0x4(%rsp)
movl 0x4(%rsp), %eax
movzbl 0x94ff(%rip), %ecx      # 0xece6
cmpl %ecx, %eax
jge 0x5957
movq 0x10(%rsp), %rcx
leaq 0xb(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5290
movq 0x10(%rsp), %rcx
leaq 0xa(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5290
movzbl 0xa(%rsp), %eax
sarl $0x4, %eax
andl $0xf, %eax
movb %al, %cl
movzbl 0xb(%rsp), %eax
subl $0x1, %eax
movslq %eax, %rdx
leaq 0x94a4(%rip), %rax      # 0xece0
addq $0x8, %rax
imulq $0x3, %rdx, %rdx
addq %rdx, %rax
movb %cl, (%rax)
movzbl 0xa(%rsp), %eax
andl $0xf, %eax
movb %al, %cl
movzbl 0xb(%rsp), %eax
subl $0x1, %eax
movslq %eax, %rdx
leaq 0x947b(%rip), %rax      # 0xece0
addq $0x8, %rax
imulq $0x3, %rdx, %rdx
addq %rdx, %rax
movb %cl, 0x1(%rax)
movzbl 0xb(%rsp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x945b(%rip), %rax      # 0xece0
addq $0x8, %rax
imulq $0x3, %rcx, %rcx
addq %rcx, %rax
movzbl (%rax), %eax
movzbl 0x944b(%rip), %ecx      # 0xece5
cmpl %ecx, %eax
jle 0x58c3
movzbl 0xb(%rsp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x9430(%rip), %rax      # 0xece0
addq $0x8, %rax
imulq $0x3, %rcx, %rcx
addq %rcx, %rax
movb (%rax), %al
movb %al, 0x9422(%rip)       # 0xece5
movzbl 0xb(%rsp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x940b(%rip), %rax      # 0xece0
addq $0x8, %rax
imulq $0x3, %rcx, %rcx
addq %rcx, %rax
movzbl 0x1(%rax), %eax
movzbl 0x93f9(%rip), %ecx      # 0xece4
cmpl %ecx, %eax
jle 0x5915
movzbl 0xb(%rsp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x93df(%rip), %rax      # 0xece0
addq $0x8, %rax
imulq $0x3, %rcx, %rcx
addq %rcx, %rax
movb 0x1(%rax), %al
movb %al, 0x93cf(%rip)       # 0xece4
movzbl 0xb(%rsp), %eax
subl $0x1, %eax
cltq
leaq 0x93ba(%rip), %rdi      # 0xece0
addq $0x8, %rdi
imulq $0x3, %rax, %rax
addq %rax, %rdi
addq $0x2, %rdi
movq 0x10(%rsp), %rcx
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5290
movl 0x4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4(%rsp)
jmp 0x57dc
addq $0x18, %rsp
retq
nopl (%rax)