// File: /workspace/github_cpp_makefile_star2_O2/sbme-tutorials[P]huffman-encoding/huffman.cpp
// Function: Huffman::outputEncoded(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void Huffman::outputEncoded(std::string outputFile)
{
    std::string directory = "./encoded/" + outputFile + ".txt";
    std::ofstream myFile;
    myFile.open(directory);
    myFile << intensity << "\n"
           << width << " " << height << " " << maxIntensity << " "
           << codeTable.size() << " " << sizeOfEncoded << " " << std::endl; //<< bitSize << " "; // print info
    for (auto c : codeTable)
    {
        myFile << (int)c.first << " " << c.second << " " << std::endl;
    }
    bitPacking();
    for (auto p : packed)
    {
        myFile << p;
    }
    myFile.close();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x258, %rsp            # imm = 0x258
movq %rsi, %rdx
movq %rdi, %r14
leaq 0x1ed5(%rip), %rsi      # 0x5070
leaq -0x278(%rbp), %rbx
movq %rbx, %rdi
callq 0x3a94
leaq 0x1eca(%rip), %rdx      # 0x507b
leaq -0x50(%rbp), %rdi
movq %rbx, %rsi
callq 0x3a6b
leaq -0x278(%rbp), %rdi
callq 0x20e0
leaq -0x278(%rbp), %rdi
callq 0x2340
leaq -0x278(%rbp), %rdi
leaq -0x50(%rbp), %rsi
pushq $0x10
popq %rdx
callq 0x20f0
leaq 0x30(%r14), %rsi
leaq -0x278(%rbp), %rdi
callq 0x21d0
leaq 0x1e81(%rip), %rsi      # 0x5080
movq %rax, %rdi
callq 0x21e0
movl 0x20(%r14), %esi
movq %rax, %rdi
callq 0x2350
leaq 0x1e68(%rip), %rsi      # 0x5082
movq %rax, %rdi
callq 0x21e0
movl 0x24(%r14), %esi
movq %rax, %rdi
callq 0x2350
leaq 0x1e4d(%rip), %rsi      # 0x5082
movq %rax, %rdi
callq 0x21e0
movl 0x28(%r14), %esi
movq %rax, %rdi
callq 0x2350
leaq 0x1e32(%rip), %rsi      # 0x5082
movq %rax, %rdi
callq 0x21e0
movq 0xc8(%r14), %rsi
movq %rax, %rdi
callq 0x2160
leaq 0x1e14(%rip), %rsi      # 0x5082
movq %rax, %rdi
callq 0x21e0
movq 0xf0(%r14), %rsi
movq %rax, %rdi
callq 0x2150
leaq 0x1df6(%rip), %rsi      # 0x5082
movq %rax, %rdi
callq 0x21e0
movq %rax, %rdi
callq 0x2100
movq 0xb8(%r14), %r12
movq %r14, -0x30(%rbp)
leaq 0xa8(%r14), %r15
leaq -0x70(%rbp), %r14
leaq -0x278(%rbp), %r13
leaq 0x1dc2(%rip), %rbx      # 0x5082
cmpq %r15, %r12
je 0x331d
leaq 0x20(%r12), %rsi
leaq -0x78(%rbp), %rdi
callq 0x3b0a
movzbl -0x78(%rbp), %esi
movq %r13, %rdi
callq 0x2350
movq %rax, %rdi
movq %rbx, %rsi
callq 0x21e0
movq %rax, %rdi
movq %r14, %rsi
callq 0x21d0
movq %rax, %rdi
movq %rbx, %rsi
callq 0x21e0
movq %rax, %rdi
callq 0x2100
movq %r14, %rdi
callq 0x20e0
movq %r12, %rdi
callq 0x2170
movq %rax, %r12
jmp 0x32c0
movq -0x30(%rbp), %rbx
movq %rbx, %rdi
callq 0x33ca
movq 0x110(%rbx), %r14
movq 0x118(%rbx), %r15
leaq -0x278(%rbp), %rbx
cmpq %r15, %r14
je 0x3354
movsbl (%r14), %esi
movq %rbx, %rdi
callq 0x2220
incq %r14
jmp 0x333e
leaq -0x278(%rbp), %rdi
callq 0x22c0
leaq -0x278(%rbp), %rdi
callq 0x22e0
leaq -0x50(%rbp), %rdi
callq 0x20e0
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x33b8
movq %rax, %rbx
leaq -0x278(%rbp), %rdi
jmp 0x33bc
jmp 0x339c
jmp 0x339c
movq %rax, %rbx
jmp 0x33ac
movq %rax, %rbx
movq %r14, %rdi
callq 0x20e0
leaq -0x278(%rbp), %rdi
callq 0x22e0
leaq -0x50(%rbp), %rdi
callq 0x20e0
movq %rbx, %rdi
callq 0x2370
nop