// File: /workspace/github_c_makefile_star2_O1/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 0xaa12
movb $0x1, 0x29(%rax)
movzbl 0x4(%rbx), %eax
testl %eax, %eax
je 0xa1f2
shll $0x10, %eax
leaq 0xc8(%rsp), %rsi
movl %eax, (%rsi)
leaq 0x98(%rsp), %rdi
callq 0xaa76
movb $0x1, 0x2a(%rax)
movq 0x30(%rbx), %r12
movq 0x38(%rbx), %r13
cmpq %r13, %r12
je 0xa298
leaq 0x98(%rsp), %r14
leaq 0xc8(%rsp), %r15
movl (%r12), %eax
movl %eax, 0xc8(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0xaa12
movb $0x1, 0x28(%rax)
movl 0x4(%r12), %eax
btl $0x8, %eax
jb 0xa26f
testb $0x20, %al
je 0xa258
movq %r14, %rdi
movq %r15, %rsi
callq 0xaa12
addq $0x8, %rax
movq %rax, %rdi
movl $0x6d, %esi
callq 0x51f0
testb $0x10, 0x4(%r12)
je 0xa28b
movq %r14, %rdi
movq %r15, %rsi
callq 0xaa12
movb $0x78, %cl
jmp 0xa27c
movq %r14, %rdi
movq %r15, %rsi
callq 0xaa12
movb $0x65, %cl
addq $0x8, %rax
movzbl %cl, %esi
movq %rax, %rdi
callq 0x51f0
addq $0xc, %r12
cmpq %r13, %r12
jne 0xa213
movq 0x60(%rbx), %r14
movq %rbx, 0x90(%rsp)
addq $0x50, %rbx
cmpq %rbx, %r14
je 0xa33e
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 0x68c2
movq %r12, %rdi
movq %r13, %rsi
callq 0xaa12
addq $0x30, %rax
movq %rax, %rdi
movq %r15, %rsi
callq 0x5170
movq 0xd0(%rsp), %rdi
cmpq %rbp, %rdi
je 0xa32e
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x5230
movq %r14, %rdi
callq 0x51a0
movq %rax, %r14
cmpq %rbx, %rax
jne 0xa2d1
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movq 0xb0(%rsp), %r14
leaq 0xa0(%rsp), %rax
cmpq %rax, %r14
je 0xa401
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 0xaada
movl 0xc8(%rsp), %eax
movl %eax, 0xd0(%rsp)
movq %r13, %rdi
movq %r15, %rsi
callq 0xab6a
movq 0x100(%rsp), %rdi
cmpq %rbx, %rdi
je 0xa3cc
movq 0x110(%rsp), %rsi
incq %rsi
callq 0x5230
movq 0xd8(%rsp), %rdi
cmpq %rbp, %rdi
je 0xa3e9
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x5230
movq %r14, %rdi
callq 0x51a0
movq %rax, %r14
leaq 0xa0(%rsp), %rax
cmpq %rax, %r14
jne 0xa38a
movq (%rsp), %r14
movq 0x8(%rsp), %r15
cmpq %r15, %r14
je 0xa458
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       # 0xa778
movq %r14, %rdi
movq %r15, %rsi
callq 0xb9ed
leaq 0x32b(%rip), %rdx       # 0xa778
movq %r14, %rdi
movq %r15, %rsi
callq 0xbb3f
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 0xa634
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 0x68c2
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 0x68c2
movl 0x20(%rsp), %edx
leaq 0x70(%rsp), %rdi
callq 0xa780
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 0xa523
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x5230
cmpb $0x1, 0x49(%rsp)
jne 0xa53e
movl $0x1, %edx
movq %r14, %rdi
leaq 0xd660(%rip), %rsi      # 0x17b99
callq 0x5260
cmpb $0x1, 0x4a(%rsp)
jne 0xa559
movl $0x1, %edx
movq %r14, %rdi
leaq 0xcdc7(%rip), %rsi      # 0x1731b
callq 0x5260
cmpb $0x1, 0x48(%rsp)
jne 0xa574
movl $0x1, %edx
movq %r14, %rdi
leaq 0xd03e(%rip), %rsi      # 0x175ad
callq 0x5260
movq 0x30(%rsp), %rdx
testq %rdx, %rdx
je 0xa58b
movq 0x28(%rsp), %rsi
movq %r14, %rdi
callq 0x5260
cmpq $0x0, 0x58(%rsp)
je 0xa5cd
movl $0x1, %edx
movq %r14, %rdi
leaq 0xcd7b(%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 0xcd57(%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 0xa610
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x5230
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0xa627
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x5230
addq $0x50, %rbp
cmpq %r13, %rbp
jne 0xa49a
leaq 0xc8(%rsp), %rdi
callq 0x5300
movq 0x16978(%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 0xac04
leaq 0x98(%rsp), %rdi
callq 0xacc6
addq $0x2c8, %rsp            # imm = 0x2C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xa73c
jmp 0xa6b0
jmp 0xa701
jmp 0xa73c
jmp 0xa701
movq %rax, %rbx
jmp 0xa74e
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0xa74e
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x5230
jmp 0xa74e
jmp 0xa741
movq %rax, %rbx
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0xa744
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x5230
jmp 0xa744
movq %rax, %rbx
jmp 0xa75b
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
callq 0xab94
jmp 0xa75b
jmp 0xa73c
movq %rax, %rbx
movq 0xd0(%rsp), %rdi
cmpq %rbp, %rdi
je 0xa763
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x5230
jmp 0xa763
movq %rax, %rbx
jmp 0xa763
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0xabcc
leaq 0xc8(%rsp), %rdi
callq 0x5330
movq %rsp, %rdi
callq 0xac04
leaq 0x98(%rsp), %rdi
callq 0xacc6
movq %rbx, %rdi
callq 0x53e0