// File: /workspace/github_cpp_makefile_star2_O3/mikeakohn[P]cloudtari/build/../src/Disassembler.cxx
// Function: Disassembler::disassemble(unsigned char*, int, char*)
int Disassembler::disassemble(uint8_t *code, int pc, char *text)
{
  Opcode &opcode = opcodes[code[0]];

  switch (opcode.type)
  {
    case OP_NONE:
      sprintf(text, "%s", opcode.name);
      return 1;
    case OP_IMMEDIATE:
      sprintf(text, "%s #0x%02x", opcode.name, code[1]);
      return 2;
    case OP_ADDRESS8:
      sprintf(text, "%s 0x%02x", opcode.name, code[1]);
      return 2;
    case OP_ADDRESS16:
      sprintf(text, "%s 0x%04x", opcode.name, code[1] | (code[2] << 8));
      return 3;
    case OP_INDEXED8_X:
      sprintf(text, "%s 0x%02x, x", opcode.name, code[1]);
      return 2;
    case OP_INDEXED8_Y:
      sprintf(text, "%s 0x%02x, y", opcode.name, code[1]);
      return 2;
    case OP_INDEXED16_X:
      sprintf(text, "%s 0x%04x, x", opcode.name, code[1] | (code[2] << 8));
      return 3;
    case OP_INDEXED16_Y:
      sprintf(text, "%s 0x%04x, y", opcode.name, code[1] | (code[2] << 8));
      return 3;
    case OP_INDIRECT16:
      sprintf(text, "%s (0x%04x)", opcode.name, code[1] | (code[2] << 8));
      return 3;
    case OP_X_INDIRECT8:
      sprintf(text, "%s (0x%02x, x)", opcode.name, code[1]);
      return 2;
    case OP_INDIRECT8_Y:
      sprintf(text, "%s (0x%02x), y", opcode.name, code[1]);
      return 2;
    case OP_INDIRECT8:
      sprintf(text, "%s (0x%02x)", opcode.name, code[1]);
      return 2;
    case OP_X_INDIRECT16:
      sprintf(text, "%s (0x%04x,x)", opcode.name, code[1] | (code[2] << 8));
      return 3;
    case OP_RELATIVE:
      sprintf(text, "%s 0x%04x (offset=%d)", opcode.name, pc + 2 + (int8_t)code[1], (int8_t)code[1]);
      return 2;
    case OP_ADDRESS8_RELATIVE:
      sprintf(text, "%s 0x%02x 0x%04x", opcode.name, code[1], pc + 2 + (int8_t)code[2]);
      return 3;
    default:
      sprintf(text, "error");
      return 0;
  }
}

// Assembly:
movzbl (%rdi), %ecx
shll $0x4, %ecx
leaq 0xb8df(%rip), %rax      # 0x103e0
movl 0x8(%rcx,%rax), %r8d
cmpq $0xe, %r8
ja 0x4bc5
pushq %rax
addq %rcx, %rax
leaq 0x6681(%rip), %rcx      # 0xb19c
movslq (%rcx,%r8,4), %r8
addq %rcx, %r8
jmpq *%r8
movq (%rax), %rsi
movq %rdx, %rdi
callq 0x41a0
movl $0x1, %eax
jmp 0x4c91
movq (%rax), %rax
movzbl 0x1(%rdi), %ecx
movsbl 0x2(%rdi), %edi
leal (%rsi,%rdi), %r8d
addl $0x2, %r8d
leaq 0x6731(%rip), %rsi      # 0xb285
movq %rdx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x4090
jmp 0x4c8c
movq (%rax), %rax
movzbl 0x1(%rdi), %ecx
leaq 0x66e1(%rip), %rsi      # 0xb255
jmp 0x4c5d
movq (%rax), %rax
movzbl 0x1(%rdi), %ecx
leaq 0x6670(%rip), %rsi      # 0xb1f7
jmp 0x4c5d
movq (%rax), %rax
movzwl 0x1(%rdi), %ecx
leaq 0x66c7(%rip), %rsi      # 0xb261
jmp 0x4c7f
movq (%rax), %rax
movzbl 0x1(%rdi), %ecx
leaq 0x668a(%rip), %rsi      # 0xb237
jmp 0x4c5d
movq (%rax), %rax
movzbl 0x1(%rdi), %ecx
leaq 0x6623(%rip), %rsi      # 0xb1e3
jmp 0x4c5d
movw $0x72, 0x4(%rdx)
movl $0x6f727265, (%rdx)     # imm = 0x6F727265
xorl %eax, %eax
retq
movq (%rax), %rax
movzwl 0x1(%rdi), %ecx
leaq 0x660b(%rip), %rsi      # 0xb1ed
jmp 0x4c7f
movq (%rax), %rax
movzwl 0x1(%rdi), %ecx
leaq 0x6629(%rip), %rsi      # 0xb21e
jmp 0x4c7f
movq (%rax), %rax
movzbl 0x1(%rdi), %ecx
leaq 0x65d0(%rip), %rsi      # 0xb1d8
jmp 0x4c5d
movq (%rax), %rax
movzbl 0x1(%rdi), %ecx
leaq 0x65ec(%rip), %rsi      # 0xb204
jmp 0x4c5d
movq (%rax), %rax
movsbl 0x1(%rdi), %r8d
leal (%rsi,%r8), %ecx
addl $0x2, %ecx
leaq 0x663f(%rip), %rsi      # 0xb26f
movq %rdx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x4090
jmp 0x4c6a
movq (%rax), %rax
movzwl 0x1(%rdi), %ecx
leaq 0x65c4(%rip), %rsi      # 0xb211
jmp 0x4c7f
movq (%rax), %rax
movzbl 0x1(%rdi), %ecx
leaq 0x65e9(%rip), %rsi      # 0xb246
movq %rdx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x4090
movl $0x2, %eax
jmp 0x4c91
movq (%rax), %rax
movzwl 0x1(%rdi), %ecx
leaq 0x65ac(%rip), %rsi      # 0xb22b
movq %rdx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x4090
movl $0x3, %eax
addq $0x8, %rsp
retq
nop