// File: /workspace/github_c_makefile_star2_O1/mrkite[P]regs/src/map.cc
// Function: Map::Map(char const*, unsigned int)
Map::Map(const char *filename, uint32_t org) : org(org) {
  mapname = filename;
  mapname += ".regs";
  usedMap = false;
  File file(mapname);
  if (!file.is_open()) {
    return;
  }

  usedMap = true;
  while (!file.eof()) {
    uint32_t ofs = file.hex();
    if (file.check('!')) {
      if (!this->org) {  // commandline overrides
        this->org = ofs;
      }
    }
    if (file.check('*')) {
      this->b = ofs >> 16;
    }
    if (file.check(':')) {
      Entry entry;
      entry.org = ofs;
      entry.flags = 0;
      uint8_t ch;
      while ((ch = file.oneOf("emx")) != 0) {
        switch (ch) {
          case 'e':
            entry.flags |= IsEmu;
            entry.flags |= IsM8;
            entry.flags |= IsX8;
            break;
          case 'm':
            entry.flags |= IsM8;
            break;
          case 'x':
            entry.flags |= IsX8;
            break;
        }
      }
      entryPoints.push_back(entry);
    }
    if (file.check('<')) {
      symbols[ofs] = file.until('>');
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rsi, %rbx
movq %rdi, %r15
movl %edx, (%rdi)
xorl %eax, %eax
movb %al, 0x4(%rdi)
leaq 0x8(%rdi), %r14
leaq 0x18(%rdi), %rcx
movq %rcx, 0x90(%rsp)
movq %rcx, 0x8(%rdi)
movq %rax, 0x10(%rdi)
movb %al, 0x18(%rdi)
leaq 0x30(%rdi), %rcx
movq %rcx, 0x18(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rdi)
movq %rax, 0x40(%rdi)
leaq 0x48(%rdi), %rcx
movq %rcx, 0x20(%rsp)
leaq 0x50(%rdi), %rcx
movl $0x0, 0x50(%rdi)
movq %rax, 0x58(%rdi)
movq %rcx, 0x60(%rdi)
movq %rcx, 0x68(%rdi)
movq %rax, 0x70(%rdi)
movq %rsi, %rdi
callq 0x5150
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
movq %rbx, %rcx
movq %rax, %r8
movq %r15, (%rsp)
movq %r14, 0x88(%rsp)
callq 0x5360
leaq 0xd62f(%rip), %rsi      # 0x17311
movq %r14, %rdi
callq 0x5430
movb $0x0, 0x28(%r15)
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
callq 0xa87e
cmpq $0x0, 0x28(%rsp)
je 0x9f0a
movq (%rsp), %rax
movb $0x1, 0x28(%rax)
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
callq 0xa962
movq 0x8(%rbx), %rax
cmpq 0x10(%rbx), %rax
jae 0x9f0a
leaq 0x78(%rsp), %r14
leaq 0x28(%rsp), %r13
leaq 0xd5db(%rip), %rbp      # 0x17317
leaq 0xd5d7(%rip), %r15      # 0x1731a
leaq 0x68(%rsp), %r12
movq %r13, %rdi
callq 0x9fec
movl %eax, %ebx
movl %eax, 0x14(%rsp)
movq %r13, %rdi
callq 0xa962
movq 0x30(%rsp), %rax
cmpq 0x38(%rsp), %rax
jae 0x9d7b
cmpb $0x21, (%rax)
jne 0x9d7b
incq %rax
movq %rax, 0x30(%rsp)
movb $0x1, %al
jmp 0x9d7d
xorl %eax, %eax
testb %al, %al
je 0x9d90
movq (%rsp), %rax
cmpl $0x0, (%rax)
jne 0x9d90
movq (%rsp), %rax
movl %ebx, (%rax)
movq %r13, %rdi
callq 0xa962
movq 0x30(%rsp), %rax
cmpq 0x38(%rsp), %rax
jae 0x9dbd
cmpb $0x2a, (%rax)
jne 0x9dbd
incq %rax
movq %rax, 0x30(%rsp)
movl %ebx, %eax
shrl $0x10, %eax
movq (%rsp), %rcx
movb %al, 0x4(%rcx)
movq %r13, %rdi
callq 0xa962
movq 0x30(%rsp), %rax
cmpq 0x38(%rsp), %rax
jae 0x9e90
cmpb $0x3a, (%rax)
jne 0x9e90
incq %rax
movq %rax, 0x30(%rsp)
movl %ebx, 0x8(%rsp)
xorl %eax, %eax
movl %eax, 0xc(%rsp)
movq %r14, 0x68(%rsp)
movq %r12, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x6952
movq %r13, %rdi
movq %r12, %rsi
callq 0xa0ca
movl %eax, %ebx
movq 0x68(%rsp), %rdi
cmpq %r14, %rdi
je 0x9e27
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x5230
movzbl %bl, %eax
cmpl $0x6c, %eax
jg 0x9e3a
testl %eax, %eax
je 0x9e5d
cmpl $0x65, %eax
jne 0x9df0
jmp 0x9e52
cmpl $0x6d, %eax
je 0x9e4b
cmpl $0x78, %eax
jne 0x9df0
movl $0x10, %eax
jmp 0x9e57
movl $0x20, %eax
jmp 0x9e57
movl $0x130, %eax            # imm = 0x130
orl 0xc(%rsp), %eax
jmp 0x9dec
movq (%rsp), %rcx
movq 0x38(%rcx), %rsi
cmpq 0x40(%rcx), %rsi
je 0x9e81
movl 0x10(%rsp), %eax
movl %eax, 0x8(%rsi)
movq 0x8(%rsp), %rax
movq %rax, (%rsi)
addq $0xc, 0x38(%rcx)
jmp 0x9e90
movq 0x18(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0xaf74
movq %r13, %rdi
callq 0xa962
movq 0x30(%rsp), %rax
cmpq 0x38(%rsp), %rax
jae 0x9ef2
cmpb $0x3c, (%rax)
jne 0x9ef2
incq %rax
movq %rax, 0x30(%rsp)
movq %r12, %rdi
movq %r13, %rsi
movl $0x3e, %edx
callq 0xa118
movq 0x20(%rsp), %rdi
leaq 0x14(%rsp), %rsi
callq 0xa9ae
movq %rax, %rdi
movq %r12, %rsi
callq 0x5280
movq 0x68(%rsp), %rdi
cmpq %r14, %rdi
je 0x9ef2
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x5230
movq %r13, %rdi
callq 0xa962
movq 0x30(%rsp), %rax
cmpq 0x38(%rsp), %rax
jb 0x9d48
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9f25
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x5230
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x9f5e
jmp 0x9f3b
movq %rax, %r15
jmp 0x9f7c
movq %rax, %r15
movq 0x68(%rsp), %rdi
cmpq %r14, %rdi
je 0x9f61
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x5230
jmp 0x9f61
jmp 0x9f5e
movq %rax, %r15
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9f7c
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x5230
movq 0x20(%rsp), %rdi
callq 0x67c2
movq 0x18(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x9fa3
movq (%rsp), %rax
movq 0x40(%rax), %rsi
subq %rdi, %rsi
callq 0x5230
movq 0x88(%rsp), %rax
movq (%rax), %rdi
movq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x9fc6
movq (%rax), %rsi
incq %rsi
callq 0x5230
movq %r15, %rdi
callq 0x53e0