// File: /workspace/github_cpp_makefile_star2_O3/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 0x40b9
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movq 0x6480(%rip), %r14      # 0x9fd8
leaq 0x3c27(%rip), %rsi      # 0x7786
movl $0x11, %edx
movq %r14, %rdi
callq 0x2130
leaq 0x3c25(%rip), %rsi      # 0x7798
movl $0x14, %edx
movq %r14, %rdi
callq 0x2130
movzbl 0x2073(%rbx), %esi
movq %r14, %rdi
callq 0x20a0
movb $0xa, %r12b
leaq 0xb(%rsp), %rsi
movb %r12b, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x2130
leaq 0x3bff(%rip), %rsi      # 0x77ad
movl $0x12, %edx
movq %r14, %rdi
callq 0x2130
movzbl 0x2074(%rbx), %esi
movq %r14, %rdi
callq 0x20a0
leaq 0xc(%rsp), %rsi
movb %r12b, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x2130
leaq 0x3bda(%rip), %rsi      # 0x77c0
movl $0x1f, %edx
movq %r14, %rdi
callq 0x2130
movzbl 0x2075(%rbx), %esi
movq %r14, %rdi
callq 0x20a0
leaq 0xd(%rsp), %rsi
movb %r12b, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x2130
leaq 0x3bc2(%rip), %rsi      # 0x77e0
movl $0x1e, %edx
movq %r14, %rdi
callq 0x2130
movzbl 0x2076(%rbx), %esi
movq %r14, %rdi
callq 0x20a0
leaq 0xe(%rsp), %rsi
movb %r12b, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x2130
leaq 0x3aa0(%rip), %rsi      # 0x76f6
movl $0x12, %edx
movq %r14, %rdi
callq 0x2130
movq %rbx, 0x10(%rsp)
movb 0x2070(%rbx), %al
testb %al, %al
je 0x3d68
movq 0x10(%rsp), %rcx
leaq 0x2050(%rcx), %r13
xorl %ebx, %ebx
movq 0x634d(%rip), %r15      # 0x9fd8
leaq (,%rbx,8), %rbp
subq %rbx, %rbp
cmpb $0x0, 0x6(%r13,%rbp)
je 0x3d59
addq %r13, %rbp
movl $0xe, %edx
movq %r15, %rdi
leaq 0x3a55(%rip), %rsi      # 0x7709
callq 0x2130
incq %rbx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x20a0
movb %r12b, 0x2(%rsp)
movl $0x1, %edx
movq %rax, %rdi
leaq 0x2(%rsp), %rsi
callq 0x2130
movl $0x15, %edx
movq %r15, %rdi
leaq 0x3b12(%rip), %rsi      # 0x77ff
callq 0x2130
movzbl 0x3(%rbp), %esi
movq %r15, %rdi
callq 0x20a0
movb %r12b, 0x3(%rsp)
movl $0x1, %edx
movq %rax, %rdi
leaq 0x3(%rsp), %rsi
callq 0x2130
movl $0x15, %edx
movq %r15, %rdi
leaq 0x3af1(%rip), %rsi      # 0x7815
callq 0x2130
movzbl 0x4(%rbp), %esi
movq %r15, %rdi
callq 0x20a0
movb %r12b, 0x4(%rsp)
movl $0x1, %edx
movq %rax, %rdi
leaq 0x4(%rsp), %rsi
callq 0x2130
movq 0x10(%rsp), %rax
movb 0x2070(%rax), %al
jmp 0x3d5c
incq %rbx
movzbl %al, %ecx
cmpq %rcx, %rbx
jb 0x3c8b
leaq 0x3abc(%rip), %rsi      # 0x782b
movl $0x11, %edx
movq %r14, %rdi
callq 0x2130
leaq 0x3aba(%rip), %rsi      # 0x783d
movl $0xb, %edx
movq %r14, %rdi
callq 0x2130
movq 0x10(%rsp), %rax
leaq 0x410(%rax), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x421(%rax), %rbx
xorl %eax, %eax
movq %rax, 0x20(%rsp)
imulq $0x388, %rax, %r15      # imm = 0x388
movq 0x18(%rsp), %rax
cmpb $0x1, 0x384(%rax,%r15)
jne 0x3ecf
addq 0x18(%rsp), %r15
movl $0xa, %edx
movq %r14, %rdi
leaq 0x3a42(%rip), %rsi      # 0x7820
callq 0x2130
movq %r14, %rdi
movq 0x20(%rsp), %rsi
callq 0x20a0
movb $0xa, 0x5(%rsp)
movl $0x1, %edx
movq %rax, %rdi
leaq 0x5(%rsp), %rsi
callq 0x2130
movl $0x9, %edx
movq %r14, %rdi
leaq 0x3a33(%rip), %rsi      # 0x7849
callq 0x2130
xorl %ebp, %ebp
movq %rbp, %r12
incq %rbp
movq %r14, %rdi
movq %rbp, %rsi
callq 0x20a0
movl $0x2, %edx
movq %rax, %rdi
leaq 0x39eb(%rip), %rsi      # 0x7828
callq 0x2130
movzbl (%r15,%r12), %r13d
cmpb 0x1(%r15,%r12), %r13b
leaq 0x7(%rsp), %r12
jae 0x3eae
movq (%r14), %rax
movq -0x18(%rax), %rax
movl 0x18(%r14,%rax), %ecx
andl $-0x4b, %ecx
orl $0x8, %ecx
movl %ecx, 0x18(%r14,%rax)
movzbl (%rbx,%r13), %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)
movb $0x20, 0x7(%rsp)
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2130
incq %r13
movzbl (%r15,%rbp), %eax
cmpq %rax, %r13
jb 0x3e53
movb $0xa, 0x6(%rsp)
movl $0x1, %edx
movq %r14, %rdi
leaq 0x6(%rsp), %rsi
callq 0x2130
cmpq $0x10, %rbp
jne 0x3e1d
movq 0x20(%rsp), %rax
incq %rax
addq $0x388, %rbx            # imm = 0x388
cmpq $0x4, %rax
jne 0x3daa
leaq 0x3964(%rip), %rsi      # 0x7853
movl $0xb, %edx
movq %r14, %rdi
callq 0x2130
movq 0x10(%rsp), %rax
leaq 0x1230(%rax), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x1241(%rax), %rbx
xorl %eax, %eax
movq %rax, 0x20(%rsp)
imulq $0x388, %rax, %r15      # imm = 0x388
movq 0x18(%rsp), %rax
cmpb $0x1, 0x384(%rax,%r15)
jne 0x403b
addq 0x18(%rsp), %r15
movl $0xa, %edx
movq %r14, %rdi
leaq 0x38d6(%rip), %rsi      # 0x7820
callq 0x2130
movq %r14, %rdi
movq 0x20(%rsp), %rsi
callq 0x20a0
movb $0xa, 0x8(%rsp)
movl $0x1, %edx
movq %rax, %rdi
leaq 0x8(%rsp), %rsi
callq 0x2130
movl $0x9, %edx
movq %r14, %rdi
leaq 0x38c7(%rip), %rsi      # 0x7849
callq 0x2130
xorl %ebp, %ebp
movq %rbp, %r12
incq %rbp
movq %r14, %rdi
movq %rbp, %rsi
callq 0x20a0
movl $0x2, %edx
movq %rax, %rdi
leaq 0x387f(%rip), %rsi      # 0x7828
callq 0x2130
movzbl (%r15,%r12), %r13d
cmpb 0x1(%r15,%r12), %r13b
leaq 0xa(%rsp), %r12
jae 0x401a
movq (%r14), %rax
movq -0x18(%rax), %rax
movl 0x18(%r14,%rax), %ecx
andl $-0x4b, %ecx
orl $0x8, %ecx
movl %ecx, 0x18(%r14,%rax)
movzbl (%rbx,%r13), %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)
movb $0x20, 0xa(%rsp)
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2130
incq %r13
movzbl (%r15,%rbp), %eax
cmpq %rax, %r13
jb 0x3fbf
movb $0xa, 0x9(%rsp)
movl $0x1, %edx
movq %r14, %rdi
leaq 0x9(%rsp), %rsi
callq 0x2130
cmpq $0x10, %rbp
jne 0x3f89
movq 0x20(%rsp), %rax
incq %rax
addq $0x388, %rbx            # imm = 0x388
cmpq $0x4, %rax
jne 0x3f16
movq 0x5f7d(%rip), %rbx      # 0x9fd8
leaq 0x37fd(%rip), %rsi      # 0x785f
movl $0x11, %edx
movq %rbx, %rdi
callq 0x2130
leaq 0x37fb(%rip), %rsi      # 0x7871
movl $0x12, %edx
movq %rbx, %rdi
callq 0x2130
movq 0x10(%rsp), %rax
movl 0x2078(%rax), %esi
movq %rbx, %rdi
callq 0x20a0
leaq 0xf(%rsp), %rsi
movb $0xa, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x2130
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq