// File: /workspace/github_c_makefile_star2_O3/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, %rbx
leaq 0xa0(%rsp), %rcx
movl $0x0, (%rcx)
xorl %eax, %eax
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
leaq 0x98(%rsp), %rdi
movq %rbx, %rsi
callq 0xa80c
movb $0x1, 0x29(%rax)
movzbl 0x4(%rbx), %eax
testl %eax, %eax
je 0x9fe8
shll $0x10, %eax
leaq 0xc8(%rsp), %rsi
movl %eax, (%rsi)
leaq 0x98(%rsp), %rdi
callq 0xa872
movb $0x1, 0x2a(%rax)
movq 0x30(%rbx), %r12
movq 0x38(%rbx), %r13
cmpq %r13, %r12
je 0xa08f
leaq 0x98(%rsp), %r14
leaq 0xc8(%rsp), %r15
movl (%r12), %eax
movl %eax, 0xc8(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0xa80c
movb $0x1, 0x28(%rax)
movl 0x4(%r12), %eax
btl $0x8, %eax
jb 0xa066
testb $0x20, %al
je 0xa053
movq %r14, %rdi
movq %r15, %rsi
callq 0xa80c
addq $0x8, %rax
movq %rax, %rdi
movl $0x6d, %esi
callq 0x51f0
movl 0x4(%r12), %eax
testb $0x10, %al
je 0xa082
movq %r14, %rdi
movq %r15, %rsi
callq 0xa80c
movb $0x78, %cl
jmp 0xa073
movq %r14, %rdi
movq %r15, %rsi
callq 0xa80c
movb $0x65, %cl
addq $0x8, %rax
movzbl %cl, %esi
movq %rax, %rdi
callq 0x51f0
addq $0xc, %r12
cmpq %r13, %r12
jne 0xa009
movq 0x60(%rbx), %r14
movq %rbx, 0x90(%rsp)
addq $0x50, %rbx
cmpq %rbx, %r14
je 0xa135
leaq 0xd0(%rsp), %r15
leaq 0xe0(%rsp), %rbp
leaq 0x98(%rsp), %r12
leaq 0xc8(%rsp), %r13
movl 0x20(%r14), %eax
movl %eax, 0xc8(%rsp)
movq %rbp, 0xd0(%rsp)
movq 0x28(%r14), %rsi
movq 0x30(%r14), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x688a
movq %r12, %rdi
movq %r13, %rsi
callq 0xa80c
addq $0x30, %rax
movq %rax, %rdi
movq %r15, %rsi
callq 0x5170
movq 0xd0(%rsp), %rdi
cmpq %rbp, %rdi
je 0xa125
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x5230
movq %r14, %rdi
callq 0x51a0
movq %rax, %r14
cmpq %rbx, %rax
jne 0xa0c8
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movq 0xb0(%rsp), %r14
leaq 0xa0(%rsp), %rax
cmpq %rax, %r14
je 0xa24f
leaq 0xd0(%rsp), %r15
leaq 0x110(%rsp), %rbx
leaq 0xe8(%rsp), %rbp
leaq 0xc8(%rsp), %r12
movq %rsp, %r13
leaq 0x20(%r14), %rsi
movq %r12, %rdi
callq 0xa8d8
movl 0xc8(%rsp), %eax
movl %eax, 0xd0(%rsp)
movq %r13, %rdi
movq %r15, %rsi
callq 0xa968
movq 0x100(%rsp), %rdi
cmpq %rbx, %rdi
je 0xa1c3
movq 0x110(%rsp), %rsi
incq %rsi
callq 0x5230
movq 0xd8(%rsp), %rdi
cmpq %rbp, %rdi
je 0xa1e0
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x5230
movq %r14, %rdi
callq 0x51a0
movq %rax, %r14
leaq 0xa0(%rsp), %rax
cmpq %rax, %r14
jne 0xa181
movq (%rsp), %r14
movq 0x8(%rsp), %r15
cmpq %r15, %r14
je 0xa24f
movq %r15, %rax
subq %r14, %rax
sarq $0x4, %rax
movabsq $-0x3333333333333333, %rcx # imm = 0xCCCCCCCCCCCCCCCD
imulq %rax, %rcx
bsrq %rcx, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
leaq 0x33d(%rip), %rcx       # 0xa56f
movq %r14, %rdi
movq %r15, %rsi
callq 0xb7b3
leaq 0x32b(%rip), %rdx       # 0xa56f
movq %r14, %rdi
movq %r15, %rsi
callq 0xb905
movq 0x90(%rsp), %rsi
addq $0x8, %rsi
leaq 0xc8(%rsp), %r14
movq %r14, %rdi
movl $0x34, %edx
callq 0x5440
movq (%rsp), %rbp
movq 0x8(%rsp), %r13
cmpq %r13, %rbp
je 0xa42b
leaq 0x28(%rsp), %rbx
leaq 0x38(%rsp), %r15
leaq 0x60(%rsp), %r12
movl (%rbp), %eax
movl %eax, 0x20(%rsp)
movq %r15, 0x28(%rsp)
movq 0x8(%rbp), %rsi
movq 0x10(%rbp), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x688a
movb 0x2a(%rbp), %al
movb %al, 0x22(%rbx)
movzwl 0x28(%rbp), %eax
movw %ax, 0x20(%rbx)
movq %r12, 0x50(%rsp)
movq 0x30(%rbp), %rsi
movq 0x38(%rbp), %rdx
addq %rsi, %rdx
leaq 0x50(%rsp), %rdi
callq 0x688a
movl 0x20(%rsp), %edx
leaq 0x70(%rsp), %rdi
callq 0xa578
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rdx
movq %r14, %rdi
callq 0x5260
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0xa31a
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x5230
cmpb $0x1, 0x49(%rsp)
jne 0xa335
movl $0x1, %edx
movq %r14, %rdi
leaq 0xd869(%rip), %rsi      # 0x17b99
callq 0x5260
cmpb $0x1, 0x4a(%rsp)
jne 0xa350
movl $0x1, %edx
movq %r14, %rdi
leaq 0xcfd0(%rip), %rsi      # 0x1731b
callq 0x5260
cmpb $0x1, 0x48(%rsp)
jne 0xa36b
movl $0x1, %edx
movq %r14, %rdi
leaq 0xd247(%rip), %rsi      # 0x175ad
callq 0x5260
movq 0x30(%rsp), %rdx
testq %rdx, %rdx
je 0xa382
movq 0x28(%rsp), %rsi
movq %r14, %rdi
callq 0x5260
cmpq $0x0, 0x58(%rsp)
je 0xa3c4
movl $0x1, %edx
movq %r14, %rdi
leaq 0xcf84(%rip), %rsi      # 0x1731d
callq 0x5260
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
movq %r14, %rdi
callq 0x5260
movl $0x1, %edx
movq %rax, %rdi
leaq 0xcf60(%rip), %rsi      # 0x1731f
callq 0x5260
movq 0xc8(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x5210
movsbl %al, %esi
movq %r14, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5190
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
je 0xa407
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x5230
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0xa41e
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x5230
addq $0x50, %rbp
cmpq %r13, %rbp
jne 0xa291
leaq 0xc8(%rsp), %rdi
callq 0x5300
movq 0x16b81(%rip), %rax     # 0x20fc0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0xd0(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0xc8(%rsp,%rcx)
callq 0x51e0
leaq 0x1c0(%rsp), %rdi
callq 0x5110
movq %rsp, %rdi
callq 0xaa02
leaq 0x98(%rsp), %rdi
callq 0xaac4
addq $0x2c8, %rsp            # imm = 0x2C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xa533
jmp 0xa4f8
jmp 0xa4a7
jmp 0xa4f8
jmp 0xa533
movq %rax, %rbx
jmp 0xa545
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0xa545
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x5230
jmp 0xa545
jmp 0xa538
movq %rax, %rbx
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0xa53b
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x5230
jmp 0xa53b
movq %rax, %rbx
jmp 0xa552
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
callq 0xa992
jmp 0xa552
jmp 0xa533
movq %rax, %rbx
movq 0xd0(%rsp), %rdi
cmpq %rbp, %rdi
je 0xa55a
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x5230
jmp 0xa55a
movq %rax, %rbx
jmp 0xa55a
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0xa9ca
leaq 0xc8(%rsp), %rdi
callq 0x5330
movq %rsp, %rdi
callq 0xaa02
leaq 0x98(%rsp), %rdi
callq 0xaac4
movq %rbx, %rdi
callq 0x53e0