// File: /workspace/github_c_makefile_star2_O2/mrkite[P]regs/src/map.cc
// Function: Map::save()
void Map::save() {
  std::map<uint32_t, Field> fields;
  fields[this->org].isOrg = true;
  if (b) {
    fields[b << 16].isB = true;
  }
  for (auto & entryPoint : entryPoints) {
    auto org = entryPoint.org;
    fields[org].isEntry = true;
    if (entryPoint.flags & IsEmu) {
      fields[org].flags += 'e';
    } else {  // only if not emu, otherwise its redundant
      if (entryPoint.flags & IsM8) {
        fields[org].flags += 'm';
      }
      if (entryPoint.flags & IsX8) {
        fields[org].flags += 'x';
      }
    }
  }
  for (auto sym : symbols) {
    fields[sym.first].symbol = sym.second;
  }
  std::vector<Field> outFields;
  for (auto field : fields) {
    field.second.org = field.first;
    outFields.push_back(field.second);
  }
  std::sort(outFields.begin(), outFields.end(), compareFields);
  std::ofstream f(mapname, std::ios::out | std::ios::binary | std::ios::trunc);
  for (auto field : outFields) {
    f << toAddress(field.org);
    if (field.isOrg) {
      f << "!";
    }
    if (field.isB) {
      f << "*";
    }
    if (field.isEntry) {
      f << ":";
    }
    if (!field.flags.empty()) {
      f << field.flags;
    }
    if (!field.symbol.empty()) {
      f << "<" << field.symbol << ">";
    }
    f << std::endl;
  }
  f.close();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2c8, %rsp            # imm = 0x2C8
movq %rdi, %r14
leaq 0x30(%rsp), %rbx
andl $0x0, (%rbx)
andq $0x0, 0x8(%rbx)
movq %rbx, 0x10(%rbx)
movq %rbx, 0x18(%rbx)
andq $0x0, 0x20(%rbx)
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
callq 0x95fa
movb $0x1, 0x29(%rax)
movzbl 0x4(%r14), %eax
testl %eax, %eax
je 0x901f
shll $0x10, %eax
leaq 0xc8(%rsp), %rsi
movl %eax, (%rsi)
leaq 0x28(%rsp), %rdi
callq 0x9648
movb $0x1, 0x2a(%rax)
movq 0x30(%r14), %r12
movq %r14, 0x8(%rsp)
movq 0x38(%r14), %r13
leaq 0x28(%rsp), %r14
leaq 0xc8(%rsp), %r15
pushq $0x6d
popq %rbp
cmpq %r13, %r12
je 0x90c0
movl (%r12), %eax
movl %eax, 0xc8(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x95fa
movb $0x1, 0x28(%rax)
movl 0x4(%r12), %eax
btl $0x8, %eax
jb 0x909b
testb $0x20, %al
je 0x9088
movq %r14, %rdi
movq %r15, %rsi
callq 0x95fa
addq $0x8, %rax
movq %rax, %rdi
movl %ebp, %esi
callq 0x51d0
movl 0x4(%r12), %eax
testb $0x10, %al
je 0x90b7
movq %r14, %rdi
movq %r15, %rsi
callq 0x95fa
movb $0x78, %cl
jmp 0x90a8
movq %r14, %rdi
movq %r15, %rsi
callq 0x95fa
movb $0x65, %cl
addq $0x8, %rax
movzbl %cl, %esi
movq %rax, %rdi
callq 0x51d0
addq $0xc, %r12
jmp 0x903c
movq 0x8(%rsp), %rax
movq 0x60(%rax), %r12
leaq 0x50(%rax), %rbp
leaq 0xd0(%rsp), %r14
leaq 0xc8(%rsp), %r15
leaq 0x28(%rsp), %r13
cmpq %rbp, %r12
je 0x9123
leaq 0x20(%r12), %rsi
movq %r15, %rdi
callq 0x9696
movq %r13, %rdi
movq %r15, %rsi
callq 0x95fa
addq $0x30, %rax
movq %rax, %rdi
movq %r14, %rsi
callq 0x5170
movq %r14, %rdi
callq 0x5140
movq %r12, %rdi
callq 0x5190
movq %rax, %r12
jmp 0x90e2
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %r15
andq $0x0, 0x10(%r15)
movaps %xmm0, (%r15)
movq 0x40(%rsp), %r13
leaq 0xd0(%rsp), %r14
leaq 0xc8(%rsp), %r12
cmpq %rbx, %r13
je 0x9188
leaq 0x20(%r13), %rsi
movq %r12, %rdi
callq 0x96a8
movl 0xc8(%rsp), %eax
movl %eax, 0xd0(%rsp)
movq %r15, %rdi
movq %r14, %rsi
callq 0x96ba
movq %r14, %rdi
callq 0x9744
movq %r13, %rdi
callq 0x5190
movq %rax, %r13
jmp 0x9149
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
leaq 0x1e4(%rip), %rdx       # 0x937d
callq 0xa567
movq 0x8(%rsp), %rsi
addq $0x8, %rsi
leaq 0xc8(%rsp), %rdi
pushq $0x34
popq %rdx
callq 0x5430
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %r14
leaq 0x58(%rsp), %r12
leaq 0xa8(%rsp), %r13
leaq 0xc8(%rsp), %rbp
leaq 0xb142(%rip), %r15      # 0x1431f
cmpq %r14, %rbx
je 0x92be
movq %r12, %rdi
movq %rbx, %rsi
callq 0x96e6
movl 0x58(%rsp), %edx
movq %r13, %rdi
callq 0x9386
movq %rbp, %rdi
movq %r13, %rsi
callq 0x51f0
movq %r13, %rdi
callq 0x5140
cmpb $0x1, 0x81(%rsp)
jne 0x9229
movq %rbp, %rdi
leaq 0xb975(%rip), %rsi      # 0x14b99
callq 0x5200
cmpb $0x1, 0x82(%rsp)
jne 0x9242
movq %rbp, %rdi
leaq 0xb0de(%rip), %rsi      # 0x1431b
callq 0x5200
cmpb $0x1, 0x80(%rsp)
jne 0x925b
movq %rbp, %rdi
leaq 0xb357(%rip), %rsi      # 0x145ad
callq 0x5200
cmpq $0x0, 0x68(%rsp)
je 0x9270
movq %rbp, %rdi
leaq 0x60(%rsp), %rsi
callq 0x51f0
cmpq $0x0, 0x90(%rsp)
je 0x92a5
movq %rbp, %rdi
leaq 0xb098(%rip), %rsi      # 0x1431d
callq 0x5200
movq %rax, %rdi
leaq 0x88(%rsp), %rsi
callq 0x51f0
movq %rax, %rdi
movq %r15, %rsi
callq 0x5200
movq %rbp, %rdi
callq 0x5150
movq %r12, %rdi
callq 0x9744
addq $0x50, %rbx
jmp 0x91dd
leaq 0xc8(%rsp), %rdi
callq 0x52f0
leaq 0xc8(%rsp), %rdi
callq 0x5320
leaq 0x10(%rsp), %rdi
callq 0x975e
leaq 0x28(%rsp), %rdi
callq 0x97d4
addq $0x2c8, %rsp            # imm = 0x2C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x9342
jmp 0x9308
jmp 0x9321
jmp 0x9321
jmp 0x9342
movq %rax, %rbx
jmp 0x9354
jmp 0x9347
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x5140
jmp 0x934a
movq %rax, %rbx
jmp 0x9361
movq %rax, %rbx
movq %r14, %rdi
callq 0x9744
jmp 0x9361
jmp 0x9342
movq %rax, %rbx
movq %r14, %rdi
callq 0x5140
jmp 0x936b
movq %rax, %rbx
jmp 0x936b
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x9744
leaq 0xc8(%rsp), %rdi
callq 0x5320
leaq 0x10(%rsp), %rdi
callq 0x975e
leaq 0x28(%rsp), %rdi
callq 0x97d4
movq %rbx, %rdi
callq 0x53c0