// File: /workspace/github_cpp_makefile_star2_O2/dannye[P]jed/src/decoder.cpp
// Function: printScanInfo(JPGImage const*)
void printScanInfo(const JPGImage* const image) {
    if (image == nullptr) return;
    std::cout << "SOS=============\n";
    std::cout << "Start of Selection: " << (uint)image->startOfSelection << '\n';
    std::cout << "End of Selection: " << (uint)image->endOfSelection << '\n';
    std::cout << "Successive Approximation High: " << (uint)image->successiveApproximationHigh << '\n';
    std::cout << "Successive Approximation Low: " << (uint)image->successiveApproximationLow << '\n';
    std::cout << "Color Components:\n";
    for (uint i = 0; i < image->numComponents; ++i) {
        if (image->colorComponents[i].usedInScan) {
            std::cout << "Component ID: " << (i + 1) << '\n';
            std::cout << "Huffman DC Table ID: " << (uint)image->colorComponents[i].huffmanDCTableID << '\n';
            std::cout << "Huffman AC Table ID: " << (uint)image->colorComponents[i].huffmanACTableID << '\n';
        }
    }
    std::cout << "DHT=============\n";
    std::cout << "DC Tables:\n";
    for (uint i = 0; i < 4; ++i) {
        if (image->huffmanDCTables[i].set) {
            std::cout << "Table ID: " << i << '\n';
            std::cout << "Symbols:\n";
            for (uint j = 0; j < 16; ++j) {
                std::cout << (j + 1) << ": ";
                for (uint k = image->huffmanDCTables[i].offsets[j]; k < image->huffmanDCTables[i].offsets[j + 1]; ++k) {
                    std::cout << std::hex << (uint)image->huffmanDCTables[i].symbols[k] << std::dec << ' ';
                }
                std::cout << '\n';
            }
        }
    }
    std::cout << "AC Tables:\n";
    for (uint i = 0; i < 4; ++i) {
        if (image->huffmanACTables[i].set) {
            std::cout << "Table ID: " << i << '\n';
            std::cout << "Symbols:\n";
            for (uint j = 0; j < 16; ++j) {
                std::cout << (j + 1) << ": ";
                for (uint k = image->huffmanACTables[i].offsets[j]; k < image->huffmanACTables[i].offsets[j + 1]; ++k) {
                    std::cout << std::hex << (uint)image->huffmanACTables[i].symbols[k] << std::dec << ' ';
                }
                std::cout << '\n';
            }
        }
    }
    std::cout << "DRI=============\n";
    std::cout << "Restart Interval: " << image->restartInterval << '\n';
}

// Assembly:
testq %rdi, %rdi
je 0x3571
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq 0x5ec2(%rip), %r14      # 0x8fd8
leaq 0x35c9(%rip), %rsi      # 0x66e6
movq %rdi, (%rsp)
movq %r14, %rdi
callq 0x20e0
leaq 0x35c8(%rip), %rsi      # 0x66f8
movq %r14, %rdi
callq 0x20e0
movq (%rsp), %rcx
movzbl 0x2073(%rcx), %esi
movq %rax, %rdi
callq 0x20a0
pushq $0xa
popq %rbp
movq %rax, %rdi
movl %ebp, %esi
callq 0x2120
leaq 0x35ae(%rip), %rsi      # 0x670d
movq %r14, %rdi
callq 0x20e0
movq (%rsp), %rcx
movzbl 0x2074(%rcx), %esi
movq %rax, %rdi
callq 0x20a0
movq %rax, %rdi
movl %ebp, %esi
callq 0x2120
leaq 0x3595(%rip), %rsi      # 0x6720
movq %r14, %rdi
callq 0x20e0
movq (%rsp), %rcx
movzbl 0x2075(%rcx), %esi
movq %rax, %rdi
callq 0x20a0
movq %rax, %rdi
movl %ebp, %esi
callq 0x2120
leaq 0x3589(%rip), %rsi      # 0x6740
movq %r14, %rdi
callq 0x20e0
movq (%rsp), %rcx
movzbl 0x2076(%rcx), %esi
movq %rax, %rdi
callq 0x20a0
movq %rax, %rdi
movl %ebp, %esi
callq 0x2120
leaq 0x3473(%rip), %rsi      # 0x6656
movq %r14, %rdi
callq 0x20e0
movq (%rsp), %rcx
leaq 0x2050(%rcx), %rbx
xorl %r15d, %r15d
leaq 0x3575(%rip), %r12      # 0x6775
movzbl 0x2070(%rcx), %eax
cmpq %rax, %r15
jae 0x329f
imulq $0x7, %r15, %r13
cmpb $0x0, 0x6(%rbx,%r13)
je 0x3297
addq %rbx, %r13
movq %r14, %rdi
leaq 0x3440(%rip), %rsi      # 0x6669
callq 0x20e0
incq %r15
movq %rax, %rdi
movq %r15, %rsi
callq 0x20a0
movq %rax, %rdi
movl %ebp, %esi
callq 0x2120
movq %r14, %rdi
leaq 0x350f(%rip), %rsi      # 0x675f
callq 0x20e0
movzbl 0x3(%r13), %esi
movq %rax, %rdi
callq 0x20a0
movq %rax, %rdi
movl %ebp, %esi
callq 0x2120
movq %r14, %rdi
movq %r12, %rsi
callq 0x20e0
movzbl 0x4(%r13), %esi
movq %rax, %rdi
callq 0x20a0
movq %rax, %rdi
movl %ebp, %esi
callq 0x2120
movq (%rsp), %rcx
jmp 0x3200
incq %r15
jmp 0x3200
leaq 0x34e5(%rip), %rsi      # 0x678b
movq %rcx, %rbx
movq %r14, %rdi
callq 0x20e0
leaq 0x34e5(%rip), %rsi      # 0x679d
movq %r14, %rdi
callq 0x20e0
leaq 0x410(%rbx), %rax
movq %rax, 0x8(%rsp)
leaq 0x421(%rbx), %r15
xorl %eax, %eax
pushq $0x20
popq %r13
cmpq $0x4, %rax
je 0x33e7
movq %rax, 0x10(%rsp)
imulq $0x388, %rax, %r12      # imm = 0x388
movq 0x8(%rsp), %rax
cmpb $0x1, 0x384(%rax,%r12)
jne 0x33d3
addq 0x8(%rsp), %r12
movq %r14, %rdi
leaq 0x346e(%rip), %rsi      # 0x6780
callq 0x20e0
movq %rax, %rdi
movq 0x10(%rsp), %rsi
callq 0x20a0
movq %rax, %rdi
pushq $0xa
popq %rsi
callq 0x2120
movq %r14, %rdi
leaq 0x3470(%rip), %rsi      # 0x67a9
callq 0x20e0
xorl %ebp, %ebp
cmpq $0x10, %rbp
je 0x33d3
leaq 0x1(%rbp), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x20a0
movq %rax, %rdi
leaq 0x3425(%rip), %rsi      # 0x6788
callq 0x20e0
movzbl (%r12,%rbp), %ebp
movzbl (%r12,%rbx), %eax
cmpq %rax, %rbp
jae 0x33c0
movq (%r14), %rax
movq -0x18(%rax), %rax
movl 0x18(%r14,%rax), %ecx
andl $-0x4b, %ecx
orl $0x8, %ecx
movl %ecx, 0x18(%r14,%rax)
movzbl (%r15,%rbp), %esi
movq %r14, %rdi
callq 0x20a0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movl 0x18(%rax,%rcx), %edx
andl $-0x4b, %edx
orl $0x2, %edx
movl %edx, 0x18(%rax,%rcx)
movq %rax, %rdi
movl %r13d, %esi
callq 0x2120
incq %rbp
jmp 0x336d
movq %r14, %rdi
pushq $0xa
popq %rsi
callq 0x2120
movq %rbx, %rbp
jmp 0x3340
movq 0x10(%rsp), %rax
incq %rax
addq $0x388, %r15            # imm = 0x388
jmp 0x32d9
leaq 0x33c5(%rip), %rsi      # 0x67b3
movq %r14, %rdi
callq 0x20e0
movq (%rsp), %rax
leaq 0x1230(%rax), %rcx
movq %rcx, 0x8(%rsp)
leaq 0x1241(%rax), %r15
xorl %eax, %eax
pushq $0x20
popq %r13
cmpq $0x4, %rax
je 0x3521
movq %rax, 0x10(%rsp)
imulq $0x388, %rax, %r12      # imm = 0x388
movq 0x8(%rsp), %rax
cmpb $0x1, 0x384(%rax,%r12)
jne 0x350d
addq 0x8(%rsp), %r12
movq %r14, %rdi
leaq 0x3334(%rip), %rsi      # 0x6780
callq 0x20e0
movq %rax, %rdi
movq 0x10(%rsp), %rsi
callq 0x20a0
movq %rax, %rdi
pushq $0xa
popq %rsi
callq 0x2120
movq %r14, %rdi
leaq 0x3336(%rip), %rsi      # 0x67a9
callq 0x20e0
xorl %ebp, %ebp
cmpq $0x10, %rbp
je 0x350d
leaq 0x1(%rbp), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x20a0
movq %rax, %rdi
leaq 0x32eb(%rip), %rsi      # 0x6788
callq 0x20e0
movzbl (%r12,%rbp), %ebp
movzbl (%r12,%rbx), %eax
cmpq %rax, %rbp
jae 0x34fa
movq (%r14), %rax
movq -0x18(%rax), %rax
movl 0x18(%r14,%rax), %ecx
andl $-0x4b, %ecx
orl $0x8, %ecx
movl %ecx, 0x18(%r14,%rax)
movzbl (%r15,%rbp), %esi
movq %r14, %rdi
callq 0x20a0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movl 0x18(%rax,%rcx), %edx
andl $-0x4b, %edx
orl $0x2, %edx
movl %edx, 0x18(%rax,%rcx)
movq %rax, %rdi
movl %r13d, %esi
callq 0x2120
incq %rbp
jmp 0x34a7
movq %r14, %rdi
pushq $0xa
popq %rsi
callq 0x2120
movq %rbx, %rbp
jmp 0x347a
movq 0x10(%rsp), %rax
incq %rax
addq $0x388, %r15            # imm = 0x388
jmp 0x3413
movq 0x5ab0(%rip), %rbx      # 0x8fd8
leaq 0x3290(%rip), %rsi      # 0x67bf
movq %rbx, %rdi
callq 0x20e0
leaq 0x3293(%rip), %rsi      # 0x67d1
movq %rbx, %rdi
callq 0x20e0
movq (%rsp), %rcx
movl 0x2078(%rcx), %esi
movq %rax, %rdi
callq 0x20a0
pushq $0xa
popq %rsi
movq %rax, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2120
retq