// File: /workspace/github_c_makefile_star2_O3/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 0xd833(%rip), %rsi      # 0x17311
movq %r14, %rdi
callq 0x5430
movb $0x0, 0x28(%r15)
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
callq 0xa676
cmpq $0x0, 0x28(%rsp)
je 0x9cfc
movq (%rsp), %rax
movb $0x1, 0x28(%rax)
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
callq 0xa75a
movq 0x8(%rbx), %rax
cmpq 0x10(%rbx), %rax
jae 0x9cfc
leaq 0x78(%rsp), %r14
leaq 0x28(%rsp), %r13
leaq 0xd7df(%rip), %rbp      # 0x17317
leaq 0xd7db(%rip), %r15      # 0x1731a
leaq 0x68(%rsp), %r12
movq %r13, %rdi
callq 0x9dde
movl %eax, %ebx
movl %eax, 0x14(%rsp)
movq %r13, %rdi
callq 0xa75a
movq 0x30(%rsp), %rax
cmpq 0x38(%rsp), %rax
jae 0x9b82
cmpb $0x21, (%rax)
jne 0x9b82
incq %rax
movq %rax, 0x30(%rsp)
movq (%rsp), %rax
cmpl $0x0, (%rax)
jne 0x9b82
movq (%rsp), %rax
movl %ebx, (%rax)
movq %r13, %rdi
callq 0xa75a
movq 0x30(%rsp), %rax
cmpq 0x38(%rsp), %rax
jae 0x9baf
cmpb $0x2a, (%rax)
jne 0x9baf
incq %rax
movq %rax, 0x30(%rsp)
movl %ebx, %eax
shrl $0x10, %eax
movq (%rsp), %rcx
movb %al, 0x4(%rcx)
movq %r13, %rdi
callq 0xa75a
movq 0x30(%rsp), %rax
cmpq 0x38(%rsp), %rax
jae 0x9c82
cmpb $0x3a, (%rax)
jne 0x9c82
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 0x6920
movq %r13, %rdi
movq %r12, %rsi
callq 0x9ec0
movl %eax, %ebx
movq 0x68(%rsp), %rdi
cmpq %r14, %rdi
je 0x9c19
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x5230
movzbl %bl, %eax
cmpl $0x6c, %eax
jg 0x9c2c
testl %eax, %eax
je 0x9c4f
cmpl $0x65, %eax
jne 0x9be2
jmp 0x9c44
cmpl $0x6d, %eax
je 0x9c3d
cmpl $0x78, %eax
jne 0x9be2
movl $0x10, %eax
jmp 0x9c49
movl $0x20, %eax
jmp 0x9c49
movl $0x130, %eax            # imm = 0x130
orl 0xc(%rsp), %eax
jmp 0x9bde
movq (%rsp), %rcx
movq 0x38(%rcx), %rsi
cmpq 0x40(%rcx), %rsi
je 0x9c73
movl 0x10(%rsp), %eax
movl %eax, 0x8(%rsi)
movq 0x8(%rsp), %rax
movq %rax, (%rsi)
addq $0xc, 0x38(%rcx)
jmp 0x9c82
movq 0x18(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0xad72
movq %r13, %rdi
callq 0xa75a
movq 0x30(%rsp), %rax
cmpq 0x38(%rsp), %rax
jae 0x9ce4
cmpb $0x3c, (%rax)
jne 0x9ce4
incq %rax
movq %rax, 0x30(%rsp)
movq %r12, %rdi
movq %r13, %rsi
movl $0x3e, %edx
callq 0x9f0e
movq 0x20(%rsp), %rdi
leaq 0x14(%rsp), %rsi
callq 0xa7a6
movq %rax, %rdi
movq %r12, %rsi
callq 0x5280
movq 0x68(%rsp), %rdi
cmpq %r14, %rdi
je 0x9ce4
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x5230
movq %r13, %rdi
callq 0xa75a
movq 0x30(%rsp), %rax
cmpq 0x38(%rsp), %rax
jb 0x9b44
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9d17
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 0x9d50
jmp 0x9d2d
movq %rax, %r15
jmp 0x9d6e
movq %rax, %r15
movq 0x68(%rsp), %rdi
cmpq %r14, %rdi
je 0x9d53
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x5230
jmp 0x9d53
jmp 0x9d50
movq %rax, %r15
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9d6e
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x5230
movq 0x20(%rsp), %rdi
callq 0x678a
movq 0x18(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x9d95
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 0x9db8
movq (%rax), %rsi
incq %rsi
callq 0x5230
movq %r15, %rdi
callq 0x53e0