// File: lionell[P]huffman-rle/main.cc
// Function: build(std::map<char, int, std::less<char>, std::allocator<std::pair<char const, int>>> const&)
Node *build(const map<char, int> &fs) {
  set<Node*, Cmp> s;
  for (auto const& p : fs) {
    s.insert(new Node{nullptr, nullptr, p.first, p.second});
  }
  while (s.size() > 1) {
    Node *left = *s.begin();
    s.erase(s.begin());
    Node *right = *s.begin();
    s.erase(s.begin());
    s.insert(new Node{left, right, 0, left->freq + right->freq});
  }
  return *s.begin();
}

// Assembly:
subq $0x138, %rsp            # imm = 0x138
movq %rdi, 0x130(%rsp)
leaq 0x100(%rsp), %rdi
callq 0x3970
movq 0x130(%rsp), %rax
movq %rax, 0xf8(%rsp)
movq 0xf8(%rsp), %rdi
callq 0x3980
movq %rax, 0xf0(%rsp)
movq 0xf8(%rsp), %rdi
callq 0x39b0
movq %rax, 0xe8(%rsp)
leaq 0xf0(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x39e0
testb $0x1, %al
jne 0x2784
jmp 0x2850
leaq 0xf0(%rsp), %rdi
callq 0x3a00
movq %rax, 0xe0(%rsp)
movl $0x18, %edi
callq 0x21b0
movq %rax, 0x50(%rsp)
jmp 0x27aa
movq 0x50(%rsp), %rax
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq 0xe0(%rsp), %rcx
movb (%rcx), %cl
movb %cl, 0x10(%rax)
movq 0xe0(%rsp), %rcx
movl 0x4(%rcx), %ecx
movl %ecx, 0x14(%rax)
movq %rax, 0xd8(%rsp)
leaq 0x100(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x3a20
movb %dl, 0x47(%rsp)
movq %rax, 0x48(%rsp)
jmp 0x2800
movb 0x47(%rsp), %al
movq 0x48(%rsp), %rcx
movq %rcx, 0xb8(%rsp)
movb %al, 0xc0(%rsp)
leaq 0xf0(%rsp), %rdi
callq 0x3a80
jmp 0x2766
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
leaq 0x100(%rsp), %rdi
callq 0x3b60
jmp 0x29fb
jmp 0x2852
leaq 0x100(%rsp), %rdi
callq 0x3ab0
cmpq $0x1, %rax
jbe 0x29bf
leaq 0x100(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0x3ac0
movq %rax, 0xa8(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0x3af0
movq 0x30(%rsp), %rdi
movq (%rax), %rax
movq %rax, 0xb0(%rsp)
callq 0x3ac0
movq 0x30(%rsp), %rdi
movq %rax, 0xa0(%rsp)
movq 0xa0(%rsp), %rsi
callq 0x3b10
movq %rax, 0x38(%rsp)
jmp 0x28c6
movq 0x38(%rsp), %rax
movq %rax, 0x98(%rsp)
leaq 0x100(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x3ac0
movq %rax, 0x88(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x3af0
movq 0x20(%rsp), %rdi
movq (%rax), %rax
movq %rax, 0x90(%rsp)
callq 0x3ac0
movq 0x20(%rsp), %rdi
movq %rax, 0x80(%rsp)
movq 0x80(%rsp), %rsi
callq 0x3b10
movq %rax, 0x28(%rsp)
jmp 0x2930
movq 0x28(%rsp), %rax
movq %rax, 0x78(%rsp)
movl $0x18, %edi
callq 0x21b0
movq %rax, 0x18(%rsp)
jmp 0x294b
movq 0x18(%rsp), %rax
movq 0xb0(%rsp), %rcx
movq %rcx, (%rax)
movq 0x90(%rsp), %rcx
movq %rcx, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0xb0(%rsp), %rcx
movl 0x14(%rcx), %ecx
movq 0x90(%rsp), %rdx
movl 0x14(%rdx), %edx
addl %edx, %ecx
movl %ecx, 0x14(%rax)
movq %rax, 0x70(%rsp)
leaq 0x100(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x3a20
movb %dl, 0xf(%rsp)
movq %rax, 0x10(%rsp)
jmp 0x29a8
movb 0xf(%rsp), %al
movq 0x10(%rsp), %rcx
movq %rcx, 0x60(%rsp)
movb %al, 0x68(%rsp)
jmp 0x2852
leaq 0x100(%rsp), %rdi
callq 0x3ac0
movq %rax, 0x58(%rsp)
leaq 0x58(%rsp), %rdi
callq 0x3af0
movq (%rax), %rax
movq %rax, (%rsp)
leaq 0x100(%rsp), %rdi
callq 0x3b60
movq (%rsp), %rax
addq $0x138, %rsp            # imm = 0x138
retq
movq 0xd0(%rsp), %rdi
callq 0x2320
nopl (%rax,%rax)