// File: /workspace/github_cpp_makefile_star2_O1/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, %r15
leaq 0x2add(%rip), %rsi      # 0x6070
leaq -0x278(%rbp), %rbx
movq %rbx, %rdi
callq 0x431f
leaq 0x2ad2(%rip), %rsi      # 0x607b
movq %rbx, %rdi
callq 0x2390
leaq -0x38(%rbp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x35d5
movq %rdx, -0x48(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x38(%rbp)
jmp 0x35db
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, -0x40(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq -0x268(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3611
movq -0x268(%rbp), %rsi
incq %rsi
callq 0x2210
leaq -0x278(%rbp), %rdi
callq 0x2340
leaq -0x278(%rbp), %rdi
leaq -0x48(%rbp), %rsi
movl $0x10, %edx
callq 0x2100
movq 0x30(%r15), %rsi
movq 0x38(%r15), %rdx
leaq -0x278(%rbp), %rdi
callq 0x2230
movq %rax, %rbx
leaq 0x2a30(%rip), %rsi      # 0x6080
movl $0x1, %edx
movq %rax, %rdi
callq 0x2230
movl 0x20(%r15), %esi
movq %rbx, %rdi
callq 0x2350
movq %rax, %rbx
leaq 0x2a0f(%rip), %rsi      # 0x6082
movl $0x1, %edx
movq %rax, %rdi
callq 0x2230
movl 0x24(%r15), %esi
movq %rbx, %rdi
callq 0x2350
movq %rax, %rbx
leaq 0x29ec(%rip), %rsi      # 0x6082
movl $0x1, %edx
movq %rax, %rdi
callq 0x2230
movl 0x28(%r15), %esi
movq %rbx, %rdi
callq 0x2350
movq %rax, %rbx
leaq 0x29c9(%rip), %rsi      # 0x6082
movl $0x1, %edx
movq %rax, %rdi
callq 0x2230
movq 0xc8(%r15), %rsi
movq %rbx, %rdi
callq 0x2160
movq %rax, %rbx
leaq 0x29a3(%rip), %rsi      # 0x6082
movl $0x1, %edx
movq %rax, %rdi
callq 0x2230
movq 0xf0(%r15), %rsi
movq %rbx, %rdi
callq 0x2150
movq %rax, %r14
leaq 0x297d(%rip), %rsi      # 0x6082
movl $0x1, %edx
movq %rax, %rdi
callq 0x2230
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21f0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2170
movq 0xb8(%r15), %r14
movq %r15, -0x78(%rbp)
addq $0xa8, %r15
cmpq %r15, %r14
je 0x3814
leaq -0x58(%rbp), %r12
leaq 0x2923(%rip), %r13      # 0x6082
movb 0x20(%r14), %al
movb %al, -0x70(%rbp)
movq %r12, -0x68(%rbp)
movq 0x28(%r14), %rsi
movq 0x30(%r14), %rdx
addq %rsi, %rdx
leaq -0x68(%rbp), %rdi
callq 0x2d8a
movzbl -0x70(%rbp), %esi
leaq -0x278(%rbp), %rdi
callq 0x2350
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x2230
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
movq %rbx, %rdi
callq 0x2230
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x2230
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21f0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2170
movq -0x68(%rbp), %rdi
cmpq %r12, %rdi
je 0x3800
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x2210
movq %r14, %rdi
callq 0x2180
movq %rax, %r14
cmpq %r15, %rax
jne 0x375f
movq -0x78(%rbp), %rbx
movq %rbx, %rdi
callq 0x3938
movq 0x110(%rbx), %r15
movq 0x118(%rbx), %r12
cmpq %r12, %r15
je 0x385c
leaq -0x278(%rbp), %rbx
leaq -0x70(%rbp), %r14
movb (%r15), %al
movb %al, -0x70(%rbp)
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2230
incq %r15
cmpq %r12, %r15
jne 0x383e
leaq -0x278(%rbp), %rdi
callq 0x22b0
movq 0x5761(%rip), %rax      # 0x8fd0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq -0x270(%rbp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, -0x278(%rbp,%rcx)
callq 0x21c0
leaq -0x180(%rbp), %rdi
callq 0x20c0
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x38b7
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2210
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x3917
movq %rax, %rbx
leaq -0x268(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3930
movq -0x268(%rbp), %rsi
jmp 0x3928
jmp 0x38ee
jmp 0x38ee
movq %rax, %rbx
jmp 0x390b
movq %rax, %rbx
movq -0x68(%rbp), %rdi
cmpq %r12, %rdi
je 0x390b
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x2210
leaq -0x278(%rbp), %rdi
callq 0x22d0
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x3930
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2210
movq %rbx, %rdi
callq 0x2360