// File: /workspace/github_cpp_makefile_star2_O2/ALSchwalm[P]entrospy/entrospy/shannon.cpp
// Function: shannon_file(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, unsigned long, PrintingPolicy const&, DataFormat, EntropyGraph&)
void shannon_file(const std::string& path, uint64_t block_size,
                  const PrintingPolicy& policy, DataFormat format,
                  EntropyGraph& graph) {
    std::ifstream file_stream{path, std::ifstream::binary};

    if (!block_size) {
        shannon_iterator iter{file_stream, DEFAULT_BLOCK_SIZE, format, false};
        shannon_iterator end{};
        for (; iter != end; ++iter) {
        }
        auto score = *iter;

        if (score < policy.bounds.first || score > policy.bounds.second) {
            return;
        }

        print_score(path, score, policy);
    } else {
        shannon_iterator iter{file_stream, block_size, format};
        shannon_iterator end{};
        auto file_size = fs::file_size(path);
        auto addr_width = address_width(policy.addr_format, file_size);

        for (; iter != end; ++iter) {
            auto score = *iter;

            if (score < policy.bounds.first || score > policy.bounds.second) {
                continue;
            }

            if (policy.print_graph) {
                graph.insert(path, iter.position(), score);
                continue;
            }
            print_score(path, iter.position(), addr_width, score, policy);
            if (policy.print_blocks) {
                print_block_bytes(iter.block().begin(), iter.block().end(),
                                  iter.position(), addr_width, policy);
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x12b8, %rsp           # imm = 0x12B8
movq %r8, 0x18(%rsp)
movl %ecx, %ebp
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %rsi
leaq 0x40(%rsp), %rdi
pushq $0x4
popq %rdx
movq %rsi, 0x8(%rsp)
callq 0x8640
testq %r15, %r15
je 0x13c87
leaq 0x248(%rsp), %rdi
leaq 0x40(%rsp), %rsi
pushq $0x1
popq %r8
movq %r15, %rdx
movl %ebp, %ecx
callq 0x13d9a
leaq 0xa80(%rsp), %rdi
movl $0x838, %edx            # imm = 0x838
xorl %esi, %esi
callq 0x8220
leaq 0x20(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x8540
leaq 0x20(%rsp), %rdi
callq 0x12e64
movq %rax, %r15
leaq 0x20(%rsp), %rdi
callq 0x87d8
movl 0x18(%rbx), %edi
movq %r15, %rsi
callq 0x1360c
movzbl %al, %ebp
leaq 0x248(%rsp), %r15
leaq 0xa80(%rsp), %r13
movq %r15, %rdi
movq %r13, %rsi
callq 0x13e01
testb %al, %al
je 0x13c7a
movq %r15, %rdi
callq 0x144b0
movsd 0x8(%rbx), %xmm1
ucomisd %xmm0, %xmm1
ja 0x13c6d
ucomisd 0x10(%rbx), %xmm0
ja 0x13c6d
movsd %xmm0, 0x10(%rsp)
cmpb $0x1, 0x1(%rbx)
jne 0x13c1b
movq %r15, %rdi
callq 0x13e0c
movsd 0x10(%rsp), %xmm0
movq %rdx, %rcx
movq 0x18(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq %rax, %rdx
callq 0x129e0
jmp 0x13c6d
movq %r15, %rdi
callq 0x13e0c
movq 0x8(%rsp), %rdi
movq %rax, %rsi
movq %rbp, %rdx
movsd 0x10(%rsp), %xmm0
movq %rbx, %rcx
callq 0x13658
cmpb $0x1, (%rbx)
jne 0x13c6d
movq 0x260(%rsp), %r12
movq 0x268(%rsp), %r14
movq %r15, %rdi
callq 0x13e0c
movq %r12, %rdi
movq %r14, %rsi
movq %rax, %rdx
movq %rbp, %rcx
movq %rbx, %r8
callq 0x13e1e
movq %r15, %rdi
callq 0x141da
jmp 0x13bb5
leaq 0xa98(%rsp), %rdi
jmp 0x13d12
leaq 0x248(%rsp), %rdi
leaq 0x40(%rsp), %rsi
movl $0x4000, %edx           # imm = 0x4000
movl %ebp, %ecx
xorl %r8d, %r8d
callq 0x13d9a
leaq 0xa98(%rsp), %r15
leaq 0xa80(%rsp), %r12
movl $0x838, %edx            # imm = 0x838
movq %r12, %rdi
xorl %esi, %esi
callq 0x8220
leaq 0x248(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x13e01
testb %al, %al
je 0x13ce3
movq %r13, %rdi
callq 0x141da
jmp 0x13cca
leaq 0x248(%rsp), %rdi
callq 0x144b0
movsd 0x8(%rbx), %xmm1
ucomisd %xmm0, %xmm1
ja 0x13d0f
ucomisd 0x10(%rbx), %xmm0
ja 0x13d0f
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x1377e
movq %r15, %rdi
callq 0x142b4
leaq 0x260(%rsp), %rdi
callq 0x142b4
leaq 0x40(%rsp), %rdi
callq 0x80b0
addq $0x12b8, %rsp           # imm = 0x12B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x13d57
jmp 0x13d60
jmp 0x13d6a
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x87d8
jmp 0x13d6d
jmp 0x13d6a
movq %rax, %rbx
jmp 0x13d87
jmp 0x13d6a
jmp 0x13d6a
movq %rax, %rbx
movq %r15, %rdi
jmp 0x13d75
jmp 0x13d6a
movq %rax, %rbx
leaq 0xa98(%rsp), %rdi
callq 0x142b4
leaq 0x260(%rsp), %rdi
callq 0x142b4
leaq 0x40(%rsp), %rdi
callq 0x80b0
movq %rbx, %rdi
callq 0x86f0
nop