// File: /workspace/github_cpp_makefile_star2_O1/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 0x412f
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq 0x640e(%rip), %r14      # 0x9fd8
leaq 0x3bb5(%rip), %rsi      # 0x7786
movl $0x11, %edx
movq %rdi, 0x18(%rsp)
movq %r14, %rdi
callq 0x2130
leaq 0x3bae(%rip), %rsi      # 0x7798
movl $0x14, %edx
movq %r14, %rdi
callq 0x2130
movq 0x18(%rsp), %rax
movzbl 0x2073(%rax), %esi
movq %r14, %rdi
callq 0x20a0
movb $0xa, %bl
leaq 0x23(%rsp), %rsi
movb %bl, (%rsi)
movl $0x1, %r15d
movl $0x1, %edx
movq %rax, %rdi
callq 0x2130
leaq 0x3b7f(%rip), %rsi      # 0x77ad
movl $0x12, %edx
movq %r14, %rdi
callq 0x2130
movq 0x18(%rsp), %rax
movzbl 0x2074(%rax), %esi
movq %r14, %rdi
callq 0x20a0
leaq 0x24(%rsp), %rsi
movb %bl, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x2130
leaq 0x3b56(%rip), %rsi      # 0x77c0
movl $0x1f, %edx
movq %r14, %rdi
callq 0x2130
movq 0x18(%rsp), %rax
movzbl 0x2075(%rax), %esi
movq %r14, %rdi
callq 0x20a0
leaq 0x25(%rsp), %rsi
movb %bl, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x2130
leaq 0x3b3a(%rip), %rsi      # 0x77e0
movl $0x1e, %edx
movq %r14, %rdi
callq 0x2130
movq 0x18(%rsp), %rax
movzbl 0x2076(%rax), %esi
movq %r14, %rdi
callq 0x20a0
leaq 0x26(%rsp), %rsi
movb %bl, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x2130
leaq 0x3a14(%rip), %rsi      # 0x76f6
movl $0x12, %edx
movq %r14, %rdi
callq 0x2130
movq 0x18(%rsp), %rdi
cmpb $0x0, 0x2070(%rdi)
je 0x3de0
leaq 0x2056(%rdi), %r13
movq 0x62c9(%rip), %r12      # 0x9fd8
leaq 0x11(%rsp), %rbp
cmpb $0x1, (%r13)
jne 0x3dc5
movl $0xe, %edx
movq %r12, %rdi
leaq 0x39db(%rip), %rsi      # 0x7709
callq 0x2130
movq %r12, %rdi
movq %r15, %rsi
callq 0x20a0
movb %bl, 0xf(%rsp)
movl $0x1, %edx
movq %rax, %rdi
leaq 0xf(%rsp), %rsi
callq 0x2130
movl $0x15, %edx
movq %r12, %rdi
leaq 0x3a9c(%rip), %rsi      # 0x77ff
callq 0x2130
movzbl -0x3(%r13), %esi
movq %r12, %rdi
callq 0x20a0
movb %bl, 0x10(%rsp)
movl $0x1, %edx
movq %rax, %rdi
leaq 0x10(%rsp), %rsi
callq 0x2130
movl $0x15, %edx
movq %r12, %rdi
leaq 0x3a7b(%rip), %rsi      # 0x7815
callq 0x2130
movzbl -0x2(%r13), %esi
movq %r12, %rdi
callq 0x20a0
movb %bl, 0x11(%rsp)
movl $0x1, %edx
movq %rax, %rdi
movq %rbp, %rsi
callq 0x2130
movq 0x18(%rsp), %rdi
movzbl 0x2070(%rdi), %eax
leaq 0x1(%r15), %rcx
addq $0x7, %r13
cmpq %rax, %r15
movq %rcx, %r15
jb 0x3d14
leaq 0x3a44(%rip), %rsi      # 0x782b
movl $0x11, %edx
movq %rdi, %rbx
movq %r14, %rdi
callq 0x2130
leaq 0x3a3f(%rip), %rsi      # 0x783d
movl $0xb, %edx
movq %r14, %rdi
callq 0x2130
leaq 0x410(%rbx), %rax
movq %rax, 0x28(%rsp)
leaq 0x421(%rbx), %r12
xorl %eax, %eax
movq %rax, 0x30(%rsp)
imulq $0x388, %rax, %r15      # imm = 0x388
movq 0x28(%rsp), %rax
cmpb $0x1, 0x384(%rax,%r15)
jne 0x3f45
addq 0x28(%rsp), %r15
movl $0xa, %edx
movq %r14, %rdi
leaq 0x39cc(%rip), %rsi      # 0x7820
callq 0x2130
movq %r14, %rdi
movq 0x30(%rsp), %rsi
callq 0x20a0
movb $0xa, 0x12(%rsp)
movl $0x1, %edx
movq %rax, %rdi
leaq 0x12(%rsp), %rsi
callq 0x2130
movl $0x9, %edx
movq %r14, %rdi
leaq 0x39bd(%rip), %rsi      # 0x7849
callq 0x2130
xorl %ebx, %ebx
movq %rbx, %r13
incq %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x20a0
movl $0x2, %edx
movq %rax, %rdi
leaq 0x3975(%rip), %rsi      # 0x7828
callq 0x2130
movzbl (%r15,%r13), %ebp
cmpb 0x1(%r15,%r13), %bpl
leaq 0x14(%rsp), %r13
jae 0x3f24
movq (%r14), %rax
movq -0x18(%rax), %rax
movl 0x18(%r14,%rax), %ecx
andl $-0x4b, %ecx
orl $0x8, %ecx
movl %ecx, 0x18(%r14,%rax)
movzbl (%r12,%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)
movb $0x20, 0x14(%rsp)
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x2130
incq %rbp
movzbl (%r15,%rbx), %eax
cmpq %rax, %rbp
jb 0x3ec9
movb $0xa, 0x13(%rsp)
movl $0x1, %edx
movq %r14, %rdi
leaq 0x13(%rsp), %rsi
callq 0x2130
cmpq $0x10, %rbx
jne 0x3e93
movq 0x30(%rsp), %rax
incq %rax
addq $0x388, %r12            # imm = 0x388
cmpq $0x4, %rax
jne 0x3e20
leaq 0x38ee(%rip), %rsi      # 0x7853
movl $0xb, %edx
movq %r14, %rdi
callq 0x2130
movq 0x18(%rsp), %rax
leaq 0x1230(%rax), %rcx
movq %rcx, 0x28(%rsp)
leaq 0x1241(%rax), %r12
xorl %eax, %eax
movq %rax, 0x30(%rsp)
imulq $0x388, %rax, %r15      # imm = 0x388
movq 0x28(%rsp), %rax
cmpb $0x1, 0x384(%rax,%r15)
jne 0x40b1
addq 0x28(%rsp), %r15
movl $0xa, %edx
movq %r14, %rdi
leaq 0x3860(%rip), %rsi      # 0x7820
callq 0x2130
movq %r14, %rdi
movq 0x30(%rsp), %rsi
callq 0x20a0
movb $0xa, 0x15(%rsp)
movl $0x1, %edx
movq %rax, %rdi
leaq 0x15(%rsp), %rsi
callq 0x2130
movl $0x9, %edx
movq %r14, %rdi
leaq 0x3851(%rip), %rsi      # 0x7849
callq 0x2130
xorl %ebx, %ebx
movq %rbx, %r13
incq %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x20a0
movl $0x2, %edx
movq %rax, %rdi
leaq 0x3809(%rip), %rsi      # 0x7828
callq 0x2130
movzbl (%r15,%r13), %ebp
cmpb 0x1(%r15,%r13), %bpl
leaq 0x17(%rsp), %r13
jae 0x4090
movq (%r14), %rax
movq -0x18(%rax), %rax
movl 0x18(%r14,%rax), %ecx
andl $-0x4b, %ecx
orl $0x8, %ecx
movl %ecx, 0x18(%r14,%rax)
movzbl (%r12,%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)
movb $0x20, 0x17(%rsp)
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x2130
incq %rbp
movzbl (%r15,%rbx), %eax
cmpq %rax, %rbp
jb 0x4035
movb $0xa, 0x16(%rsp)
movl $0x1, %edx
movq %r14, %rdi
leaq 0x16(%rsp), %rsi
callq 0x2130
cmpq $0x10, %rbx
jne 0x3fff
movq 0x30(%rsp), %rax
incq %rax
addq $0x388, %r12            # imm = 0x388
cmpq $0x4, %rax
jne 0x3f8c
movq 0x5f07(%rip), %rbx      # 0x9fd8
leaq 0x3787(%rip), %rsi      # 0x785f
movl $0x11, %edx
movq %rbx, %rdi
callq 0x2130
leaq 0x3785(%rip), %rsi      # 0x7871
movl $0x12, %edx
movq %rbx, %rdi
callq 0x2130
movq 0x18(%rsp), %rax
movl 0x2078(%rax), %esi
movq %rbx, %rdi
callq 0x20a0
leaq 0x27(%rsp), %rsi
movb $0xa, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x2130
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq