// File: /workspace/github_c_makefile_star2_O2/mrkite[P]regs/docmaker/output.cc
// Function: Output::save(std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, Symbol, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, Symbol>>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void Output::save(const std::map<std::string, Symbol> &symbols,
                  const std::string &filename) {
  std::ofstream f(filename, std::ios::out | std::ios::binary | std::ios::trunc);
  if (!f.is_open()) {
    std::cerr << "Failed to create " << filename << std::endl;
    exit(-1);
  }
  w32(&f, symbols.size());
  uint32_t id = 1;
  for (auto it = symbols.begin(); it != symbols.end(); it++) {
    w32(&f, id);
    w8(&f, it->second.kind);
    ws(&f, it->first);
    ids[it->first] = id++;
  }
  for (auto it = symbols.begin(); it != symbols.end(); it++) {
    auto symbol = it->second;
    w32(&f, lookup(it->first));
    w32(&f, symbol.size);
    switch (symbol.kind) {
      case isIntrinsic:
        setIntrinsic(&f, symbol.asIntrinsic);
        break;
      case isEnum:
        setEnum(&f, symbol.asEnum);
        break;
      case isAlias:
        setRef(&f, symbol.asAlias);
        break;
      case isStruct:
        setStruct(&f, symbol.asStruct);
        break;
      case isUnion:
        setStruct(&f, symbol.asStruct);
        break;
      case isFunction:
        setFunction(&f, symbol.asFunction);
        break;
      default:
        std::cerr << "Unknown symbol type" << std::endl;
        exit(-1);
    }
  }
  f.close();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x298, %rsp            # imm = 0x298
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x98(%rsp), %rdi
pushq $0x34
popq %rdx
movq %r15, %rsi
callq 0x23e0
leaq 0x108(%rsp), %rdi
callq 0x2080
testb %al, %al
je 0x651f
movl 0x28(%r14), %edx
leaq 0x98(%rsp), %rsi
callq 0x6576
movq 0x18(%r14), %r12
movq %r14, 0x8(%rsp)
addq $0x8, %r14
pushq $0x1
popq %rbp
leaq 0x98(%rsp), %r15
cmpq %r14, %r12
je 0x63e3
movq %r15, %rsi
movl %ebp, %edx
callq 0x6576
movzbl 0xb8(%r12), %edx
movq %r15, %rsi
callq 0x658c
leaq 0x20(%r12), %r13
movq %r15, %rsi
movq %r13, %rdx
callq 0x65a2
movq %rbx, %rdi
movq %r13, %rsi
callq 0x6868
movl %ebp, (%rax)
incl %ebp
movq %r12, %rdi
callq 0x2210
movq %rax, %r12
jmp 0x6397
movq 0x8(%rsp), %rax
movq 0x18(%rax), %r12
leaq 0x10(%rsp), %r13
leaq 0x98(%rsp), %r15
leaq 0x1028(%rip), %rbp      # 0x7428
cmpq %r14, %r12
je 0x64d0
leaq 0x40(%r12), %rsi
movq %r13, %rdi
callq 0x3f3e
leaq 0x20(%r12), %rsi
movq %rbx, %rdi
callq 0x65ee
movq %r15, %rsi
movl %eax, %edx
callq 0x6576
movl 0x34(%rsp), %edx
movq %r15, %rsi
callq 0x6576
movl 0x88(%rsp), %eax
cmpq $0x6, %rax
ja 0x64fc
movslq (%rbp,%rax,4), %rax
addq %rbp, %rax
jmpq *%rax
movq 0x90(%rsp), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x66ca
jmp 0x64b8
movq 0x90(%rsp), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6720
jmp 0x64b8
movq 0x90(%rsp), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6600
jmp 0x64b8
movzbl 0x90(%rsp), %edx
movq %r15, %rsi
callq 0x658c
jmp 0x64b8
movq 0x90(%rsp), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x666c
movq %r13, %rdi
callq 0x28ae
movq %r12, %rdi
callq 0x2210
movq %rax, %r12
jmp 0x6400
leaq 0x98(%rsp), %rdi
callq 0x22c0
leaq 0x98(%rsp), %rdi
callq 0x2300
addq $0x298, %rsp            # imm = 0x298
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x4aed(%rip), %rdi      # 0xaff0
leaq 0xf4c(%rip), %rsi       # 0x7456
callq 0x21c0
movq %rax, %rdi
callq 0x2110
pushq $-0x1
popq %rdi
callq 0x2220
movq 0x4aca(%rip), %rdi      # 0xaff0
leaq 0xf17(%rip), %rsi       # 0x7444
callq 0x21c0
movq %rax, %rdi
movq %r15, %rsi
callq 0x21b0
movq %rax, %rdi
callq 0x2110
jmp 0x6517
jmp 0x655e
jmp 0x655e
jmp 0x654f
jmp 0x655e
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x28ae
jmp 0x6561
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x2300
movq %rbx, %rdi
callq 0x23a0