// File: /workspace/github_c_makefile_star2_O3/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 $0x2a8, %rsp            # imm = 0x2A8
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
leaq 0xa8(%rsp), %rdi
movq %rdx, %rsi
movl $0x34, %edx
callq 0x3400
leaq 0x118(%rsp), %rdi
callq 0x3090
testb %al, %al
je 0x8ae9
movl 0x28(%r15), %eax
leaq 0x18(%rsp), %rsi
movl %eax, (%rsi)
leaq 0xa8(%rsp), %rdi
movl $0x4, %edx
callq 0x3290
movq 0x18(%r15), %r14
leaq 0x8(%r15), %rax
movq %rax, 0x8(%rsp)
cmpq %rax, %r14
je 0x888c
movq %r15, 0xa0(%rsp)
movq %rbx, 0x10(%rsp)
movl $0x1, %ebx
leaq 0xa8(%rsp), %r12
leaq 0x18(%rsp), %r13
movl %ebx, 0x18(%rsp)
movl $0x4, %edx
movq %r12, %rdi
movq %r13, %rsi
callq 0x3290
movb 0xb8(%r14), %al
movb %al, 0x18(%rsp)
movl $0x1, %edx
movq %r12, %rdi
movq %r13, %rsi
callq 0x3290
movq 0x28(%r14), %rbp
movl $0xff, %eax
cmpq %rax, %rbp
cmovaeq %rax, %rbp
movb %bpl, 0x18(%rsp)
movl $0x1, %edx
movq %r12, %rdi
movq %r13, %rsi
callq 0x3290
leaq 0x20(%r14), %r15
movq (%r15), %rsi
movq %r12, %rdi
movq %rbp, %rdx
callq 0x3290
movq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x9040
movl %ebx, (%rax)
incl %ebx
movq %r14, %rdi
callq 0x3240
movq %rax, %r14
cmpq 0x8(%rsp), %rax
jne 0x87ee
movq 0xa0(%rsp), %rax
movq 0x18(%rax), %r14
movq 0x10(%rsp), %rbx
cmpq 0x8(%rsp), %r14
je 0x8a64
leaq 0x28(%rsp), %r12
leaq 0xa8(%rsp), %rbp
leaq 0x4(%rsp), %r15
leaq 0x1b78(%rip), %r13      # 0xa428
movq %r12, 0x18(%rsp)
movq 0x40(%r14), %rsi
movq 0x48(%r14), %rdx
addq %rsi, %rdx
leaq 0x18(%rsp), %rdi
callq 0x6342
movups 0x60(%r14), %xmm0
movups %xmm0, 0x10(%r12)
leaq 0x58(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x70(%r14), %rsi
movq 0x78(%r14), %rdx
addq %rsi, %rdx
leaq 0x48(%rsp), %rdi
callq 0x6342
movl 0x90(%r14), %eax
movl %eax, 0x68(%rsp)
leaq 0x80(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x98(%r14), %rsi
movq 0xa0(%r14), %rdx
addq %rsi, %rdx
leaq 0x70(%rsp), %rdi
callq 0x6342
leaq 0x20(%r14), %rsi
movups 0xb8(%r14), %xmm0
movups %xmm0, 0x68(%r12)
movq %rbx, %rdi
callq 0x90bc
movl (%rax), %eax
movl %eax, 0x4(%rsp)
movl $0x4, %edx
movq %rbp, %rdi
movq %r15, %rsi
callq 0x3290
movl 0x3c(%rsp), %eax
movl %eax, 0x4(%rsp)
movl $0x4, %edx
movq %rbp, %rdi
movq %r15, %rsi
callq 0x3290
movl 0x90(%rsp), %eax
cmpq $0x6, %rax
ja 0x8abb
movslq (%r13,%rax,4), %rax
addq %r13, %rax
jmpq *%rax
movq 0x98(%rsp), %rdx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x8dbc
jmp 0x89f9
movq 0x98(%rsp), %rdx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x8e20
jmp 0x89f9
movq 0x98(%rsp), %rdx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x8c2a
jmp 0x89f9
movb 0x98(%rsp), %al
movb %al, 0x4(%rsp)
movl $0x1, %edx
movq %rbp, %rdi
movq %r15, %rsi
callq 0x3290
jmp 0x89f9
movq 0x98(%rsp), %rdx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x8cf4
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x8a1b
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x3200
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x8a37
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3200
movq 0x18(%rsp), %rdi
cmpq %r12, %rdi
je 0x8a4e
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x3200
movq %r14, %rdi
callq 0x3240
movq %rax, %r14
cmpq 0x8(%rsp), %rax
jne 0x88b0
leaq 0xa8(%rsp), %rdi
callq 0x32d0
movq 0x5548(%rip), %rax      # 0xdfc0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0xb0(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0xa8(%rsp,%rcx)
callq 0x31a0
leaq 0x1a0(%rsp), %rdi
callq 0x30e0
addq $0x2a8, %rsp            # imm = 0x2A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x552e(%rip), %rdi      # 0xdff0
leaq 0x198d(%rip), %rsi      # 0xa456
movl $0x13, %edx
callq 0x3230
movq 0x5516(%rip), %rdi      # 0xdff0
callq 0x3120
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x3250
movq 0x5500(%rip), %rdi      # 0xdff0
leaq 0x194d(%rip), %rsi      # 0xa444
movl $0x11, %edx
callq 0x3230
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq 0x54e1(%rip), %rdi      # 0xdff0
callq 0x3230
movq %rax, %rdi
callq 0x3120
jmp 0x8adf
jmp 0x8b72
jmp 0x8b72
jmp 0x8b63
jmp 0x8b72
movq %rax, %rbx
jmp 0x8b4a
movq %rax, %rbx
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x8b4a
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3200
movq 0x18(%rsp), %rdi
cmpq %r12, %rdi
je 0x8b75
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x3200
jmp 0x8b75
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x61c2
jmp 0x8b75
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x3310
movq %rbx, %rdi
callq 0x33d0