// File: /workspace/github_c_makefile_star2_O0/mrkite[P]regs/src/scanner.cc
// Function: Scanner::disassemble(std::ostream&, unsigned int, unsigned int, std::function<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> (std::shared_ptr<Inst>)>)
bool Scanner::disassemble(std::ostream &f, uint32_t from, uint32_t to,
                          std::function<std::string(std::shared_ptr<Inst>)>
                          printInst) {
  auto address = from;
  for (auto b : blocks) {
    if (b->address + b->length <= address) {
      continue;
    }
    if (address < b->address) {
      auto last = std::min(to, b->address);
      dumpHex(f, address, last);
      address = last;
    }
    if (address == b->address) {
      auto count = 0;
      std::string preds;
      for (auto pred : b->preds) {
        if (pred->address + pred->length != b->address && count++ < 7) {
          preds += (pred->address < b->address) ? u8"\u25b2 " : u8"\u25bc ";
          preds += hex(pred->address + pred->length - pred->branchLen, 6);
        }
      }
      if (count > 0) {
        f << hex(address, 6) << ": " << preds << std::endl;
      }
    }
    while (address < to && address < b->address + b->length) {
      auto sym = symbols[address];
      if (!sym.empty()) {
        f << sym << std::endl;
      }
      f << hex(address, 6) << ": ";
      auto ptr = getAddress(address);
      if (map[address]->length > 4) {
        f << ".. .. .. .. ";
      } else {
        for (int i = 0; i < map[address]->length; i++) {
          f << hex(ptr->r8(), 2) << " ";
        }
        for (int i = map[address]->length; i < 4; i++) {
          f << "   ";
        }
      }
      f << printInst(map[address]) << std::endl;
      address += map[address]->length;
    }
    if (address < b->address + b->length) {
      break;
    }
  }
  if (address < to) {
    dumpHex(f, address, to);
  }
  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2a0, %rsp            # imm = 0x2A0
movq %r8, -0x1b0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x1a8(%rbp)
movl -0x14(%rbp), %ecx
movl %ecx, -0x24(%rbp)
addq $0xb8, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
callq 0x33850
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rdi
callq 0x33880
movq %rax, -0x40(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x338b0
testb $0x1, %al
jne 0x31e2f
jmp 0x32753
leaq -0x38(%rbp), %rdi
callq 0x338f0
movq %rax, %rsi
leaq -0x50(%rbp), %rdi
callq 0x33910
leaq -0x50(%rbp), %rdi
callq 0x33670
movl (%rax), %eax
movl %eax, -0x1b4(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x33670
movq %rax, %rcx
movl -0x1b4(%rbp), %eax
addl 0x4(%rcx), %eax
cmpl -0x24(%rbp), %eax
ja 0x31e7b
movl $0x3, -0x54(%rbp)
jmp 0x32711
movl -0x24(%rbp), %eax
movl %eax, -0x1b8(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x33670
movq %rax, %rcx
movl -0x1b8(%rbp), %eax
cmpl (%rcx), %eax
jae 0x31ef5
leaq -0x50(%rbp), %rdi
callq 0x33670
movq %rax, %rsi
leaq -0x18(%rbp), %rdi
callq 0x33940
movq %rax, -0x1c0(%rbp)
jmp 0x31eb8
movq -0x1a8(%rbp), %rdi
movq -0x1c0(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x58(%rbp)
movq -0x10(%rbp), %rsi
movl -0x24(%rbp), %edx
movl -0x58(%rbp), %ecx
callq 0x32790
jmp 0x31edc
movl -0x58(%rbp), %eax
movl %eax, -0x24(%rbp)
jmp 0x31ef5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x32748
movl -0x24(%rbp), %eax
movl %eax, -0x1c4(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x33670
movq %rax, %rcx
movl -0x1c4(%rbp), %eax
cmpl (%rcx), %eax
jne 0x32230
movl $0x0, -0x68(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x6420
leaq -0x50(%rbp), %rdi
callq 0x33670
addq $0x10, %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rdi
callq 0x33850
movq %rax, -0x98(%rbp)
movq -0x90(%rbp), %rdi
callq 0x33880
movq %rax, -0xa0(%rbp)
leaq -0x98(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x338b0
testb $0x1, %al
jne 0x31f81
jmp 0x32140
leaq -0x98(%rbp), %rdi
callq 0x338f0
movq %rax, %rsi
leaq -0xb0(%rbp), %rdi
callq 0x33910
leaq -0xb0(%rbp), %rdi
callq 0x33670
movl (%rax), %eax
movl %eax, -0x1cc(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x33670
movq %rax, %rcx
movl -0x1cc(%rbp), %eax
addl 0x4(%rcx), %eax
movl %eax, -0x1c8(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x33670
movq %rax, %rcx
movl -0x1c8(%rbp), %eax
cmpl (%rcx), %eax
je 0x32112
movl -0x68(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x68(%rbp)
cmpl $0x7, %eax
jge 0x32112
leaq -0xb0(%rbp), %rdi
callq 0x33670
movl (%rax), %eax
movl %eax, -0x1d0(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x33670
movq %rax, %rcx
movl -0x1d0(%rbp), %eax
cmpl (%rcx), %eax
jae 0x32036
leaq 0x8e42(%rip), %rax      # 0x3ae6f
movq %rax, -0x1d8(%rbp)
jmp 0x32046
leaq 0x8e37(%rip), %rax      # 0x3ae74
movq %rax, -0x1d8(%rbp)
jmp 0x32046
movq -0x1d8(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0x62e0
jmp 0x3205b
leaq -0xb0(%rbp), %rdi
movq %rdi, -0x1e8(%rbp)
callq 0x33670
movq -0x1e8(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x1e0(%rbp)
callq 0x33670
movq -0x1e8(%rbp), %rdi
movq %rax, %rcx
movl -0x1e0(%rbp), %eax
movl 0x4(%rcx), %ecx
addl %ecx, %eax
movl %eax, -0x1dc(%rbp)
callq 0x33670
movl -0x1dc(%rbp), %edx
movq -0x1a8(%rbp), %rsi
movl 0x8(%rax), %eax
subl %eax, %edx
leaq -0xd0(%rbp), %rdi
movl $0x6, %ecx
callq 0x31120
jmp 0x320c7
leaq -0x88(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x63c0
jmp 0x320dc
leaq -0xd0(%rbp), %rdi
callq 0x61e0
jmp 0x32112
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x3212f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x61e0
jmp 0x3212f
leaq -0xb0(%rbp), %rdi
callq 0x1ea40
leaq -0x98(%rbp), %rdi
callq 0x33980
jmp 0x31f65
leaq -0xb0(%rbp), %rdi
callq 0x1ea40
jmp 0x3221f
cmpl $0x0, -0x68(%rbp)
jle 0x32211
movq -0x1a8(%rbp), %rsi
movq -0x10(%rbp), %rax
movq %rax, -0x1f0(%rbp)
movl -0x24(%rbp), %edx
leaq -0xf0(%rbp), %rdi
movl $0x6, %ecx
callq 0x31120
jmp 0x32172
movq -0x1f0(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x62b0
movq %rax, -0x1f8(%rbp)
jmp 0x3218e
movq -0x1f8(%rbp), %rdi
leaq 0x8a81(%rip), %rsi      # 0x3ac1d
callq 0x62f0
movq %rax, -0x200(%rbp)
jmp 0x321aa
movq -0x200(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x62b0
movq %rax, -0x208(%rbp)
jmp 0x321c6
movq -0x208(%rbp), %rdi
movq 0x24dd4(%rip), %rsi     # 0x56fa8
callq 0x6330
jmp 0x321db
leaq -0xf0(%rbp), %rdi
callq 0x61e0
jmp 0x32211
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x3221f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x61e0
jmp 0x3221f
leaq -0x88(%rbp), %rdi
callq 0x61e0
jmp 0x32230
leaq -0x88(%rbp), %rdi
callq 0x61e0
jmp 0x32748
jmp 0x32232
movl -0x24(%rbp), %ecx
xorl %eax, %eax
cmpl -0x18(%rbp), %ecx
movb %al, -0x209(%rbp)
jae 0x32282
movl -0x24(%rbp), %eax
movl %eax, -0x210(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x33670
movl (%rax), %eax
movl %eax, -0x214(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x33670
movl -0x214(%rbp), %ecx
movq %rax, %rdx
movl -0x210(%rbp), %eax
addl 0x4(%rdx), %ecx
cmpl %ecx, %eax
setb %al
movb %al, -0x209(%rbp)
movb -0x209(%rbp), %al
testb $0x1, %al
jne 0x32291
jmp 0x326c8
movq -0x1a8(%rbp), %rdi
leaq -0x24(%rbp), %rsi
callq 0x13e60
movq %rax, -0x220(%rbp)
jmp 0x322aa
movq -0x220(%rbp), %rsi
leaq -0x110(%rbp), %rdi
callq 0x6170
jmp 0x322bf
leaq -0x110(%rbp), %rdi
callq 0x6510
testb $0x1, %al
jne 0x32310
movq -0x10(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x62b0
movq %rax, -0x228(%rbp)
jmp 0x322e8
movq -0x228(%rbp), %rdi
movq 0x24cb2(%rip), %rsi     # 0x56fa8
callq 0x6330
jmp 0x322fd
jmp 0x32310
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x326b7
movq -0x1a8(%rbp), %rsi
movq -0x10(%rbp), %rax
movq %rax, -0x230(%rbp)
movl -0x24(%rbp), %edx
leaq -0x130(%rbp), %rdi
movl $0x6, %ecx
callq 0x31120
jmp 0x32338
movq -0x230(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x62b0
movq %rax, -0x238(%rbp)
jmp 0x32354
movq -0x238(%rbp), %rdi
leaq 0x88bb(%rip), %rsi      # 0x3ac1d
callq 0x62f0
jmp 0x32369
leaq -0x130(%rbp), %rdi
callq 0x61e0
movq -0x1a8(%rbp), %rsi
movl -0x24(%rbp), %edx
leaq -0x140(%rbp), %rdi
callq 0x31030
jmp 0x3238d
movq -0x1a8(%rbp), %rdi
addq $0xd0, %rdi
leaq -0x24(%rbp), %rsi
callq 0x333b0
movq %rax, -0x240(%rbp)
jmp 0x323ad
movq -0x240(%rbp), %rdi
callq 0x1dc20
movzwl 0x22(%rax), %eax
cmpl $0x4, %eax
jle 0x32407
movq -0x10(%rbp), %rdi
leaq 0x8aac(%rip), %rsi      # 0x3ae79
callq 0x62f0
jmp 0x323d4
jmp 0x3257c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x61e0
jmp 0x326b7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x326ab
movl $0x0, -0x144(%rbp)
movq -0x1a8(%rbp), %rdi
movl -0x144(%rbp), %eax
movl %eax, -0x24c(%rbp)
addq $0xd0, %rdi
leaq -0x24(%rbp), %rsi
callq 0x333b0
movq %rax, -0x248(%rbp)
jmp 0x3243d
movq -0x248(%rbp), %rdi
callq 0x1dc20
movq %rax, %rcx
movl -0x24c(%rbp), %eax
movzwl 0x22(%rcx), %ecx
cmpl %ecx, %eax
jge 0x32516
movq -0x10(%rbp), %rax
movq %rax, -0x258(%rbp)
leaq -0x140(%rbp), %rdi
callq 0xd2c0
movq %rax, %rdi
callq 0x11fc0
movb %al, -0x24d(%rbp)
jmp 0x32485
movq -0x1a8(%rbp), %rsi
movb -0x24d(%rbp), %al
movzbl %al, %edx
leaq -0x168(%rbp), %rdi
movl $0x2, %ecx
callq 0x31120
jmp 0x324a8
movq -0x258(%rbp), %rdi
leaq -0x168(%rbp), %rsi
callq 0x62b0
movq %rax, -0x260(%rbp)
jmp 0x324c4
movq -0x260(%rbp), %rdi
leaq 0x89b6(%rip), %rsi      # 0x3ae88
callq 0x62f0
jmp 0x324d9
leaq -0x168(%rbp), %rdi
callq 0x61e0
movl -0x144(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x144(%rbp)
jmp 0x32411
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x168(%rbp), %rdi
callq 0x61e0
jmp 0x326ab
movq -0x1a8(%rbp), %rdi
addq $0xd0, %rdi
leaq -0x24(%rbp), %rsi
callq 0x333b0
movq %rax, -0x268(%rbp)
jmp 0x32536
movq -0x268(%rbp), %rdi
callq 0x1dc20
movzwl 0x22(%rax), %eax
movl %eax, -0x16c(%rbp)
cmpl $0x4, -0x16c(%rbp)
jge 0x3257a
movq -0x10(%rbp), %rdi
leaq 0x8926(%rip), %rsi      # 0x3ae86
callq 0x62f0
jmp 0x32567
jmp 0x32569
movl -0x16c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x16c(%rbp)
jmp 0x3254c
jmp 0x3257c
movq -0x1a8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0x278(%rbp)
addq $0xd0, %rdi
leaq -0x24(%rbp), %rsi
callq 0x333b0
movq %rax, -0x270(%rbp)
jmp 0x325a7
movq -0x270(%rbp), %rsi
leaq -0x1a0(%rbp), %rdi
movq %rdi, -0x280(%rbp)
callq 0x33730
movq -0x1b0(%rbp), %rsi
movq -0x280(%rbp), %rdx
leaq -0x190(%rbp), %rdi
callq 0x339a0
jmp 0x325dd
movq -0x278(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x62b0
movq %rax, -0x288(%rbp)
jmp 0x325f9
movq -0x288(%rbp), %rdi
movq 0x249a1(%rip), %rsi     # 0x56fa8
callq 0x6330
jmp 0x3260e
leaq -0x190(%rbp), %rdi
callq 0x61e0
leaq -0x1a0(%rbp), %rdi
callq 0x1dc40
movq -0x1a8(%rbp), %rdi
addq $0xd0, %rdi
leaq -0x24(%rbp), %rsi
callq 0x333b0
movq %rax, -0x290(%rbp)
jmp 0x32646
movq -0x290(%rbp), %rdi
callq 0x1dc20
movzwl 0x22(%rax), %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x8b80
leaq -0x110(%rbp), %rdi
callq 0x61e0
jmp 0x32232
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x3269f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x190(%rbp), %rdi
callq 0x61e0
leaq -0x1a0(%rbp), %rdi
callq 0x1dc40
leaq -0x140(%rbp), %rdi
callq 0x8b80
leaq -0x110(%rbp), %rdi
callq 0x61e0
jmp 0x32748
movl -0x24(%rbp), %eax
movl %eax, -0x294(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x33670
movl (%rax), %eax
movl %eax, -0x298(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x33670
movl -0x298(%rbp), %ecx
movq %rax, %rdx
movl -0x294(%rbp), %eax
addl 0x4(%rdx), %ecx
cmpl %ecx, %eax
jae 0x3270a
movl $0x2, -0x54(%rbp)
jmp 0x32711
movl $0x0, -0x54(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x1ea40
movl -0x54(%rbp), %eax
movl %eax, -0x29c(%rbp)
testl %eax, %eax
je 0x32738
jmp 0x32729
movl -0x29c(%rbp), %eax
subl $0x2, %eax
je 0x32753
jmp 0x32736
jmp 0x3273a
jmp 0x3273a
leaq -0x38(%rbp), %rdi
callq 0x33980
jmp 0x31e19
leaq -0x50(%rbp), %rdi
callq 0x1ea40
jmp 0x3277e
movl -0x24(%rbp), %eax
cmpl -0x18(%rbp), %eax
jae 0x32771
movq -0x1a8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x24(%rbp), %edx
movl -0x18(%rbp), %ecx
callq 0x32790
movb $0x1, %al
andb $0x1, %al
addq $0x2a0, %rsp            # imm = 0x2A0
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0x6540
nopw (%rax,%rax)