// File: /workspace/github_cpp_makefile_star2_O1/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 0xa8cb(%rip), %rax      # 0xf3d0
movl 0x8(%rcx,%rax), %r8d
cmpq $0xe, %r8
ja 0x4bc9
pushq %rax
addq %rcx, %rax
leaq 0x567d(%rip), %rcx      # 0xa19c
movslq (%rcx,%r8,4), %r8
addq %rcx, %r8
jmpq *%r8
movq (%rax), %rsi
movq %rdx, %rdi
callq 0x4190
movl $0x1, %eax
jmp 0x4c95
movq (%rax), %rax
movzbl 0x1(%rdi), %ecx
movsbl 0x2(%rdi), %edi
leal (%rsi,%rdi), %r8d
addl $0x2, %r8d
leaq 0x572d(%rip), %rsi      # 0xa285
movq %rdx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x4090
jmp 0x4c90
movq (%rax), %rax
movzbl 0x1(%rdi), %ecx
leaq 0x56dd(%rip), %rsi      # 0xa255
jmp 0x4c61
movq (%rax), %rax
movzbl 0x1(%rdi), %ecx
leaq 0x566c(%rip), %rsi      # 0xa1f7
jmp 0x4c61
movq (%rax), %rax
movzwl 0x1(%rdi), %ecx
leaq 0x56c3(%rip), %rsi      # 0xa261
jmp 0x4c83
movq (%rax), %rax
movzbl 0x1(%rdi), %ecx
leaq 0x5686(%rip), %rsi      # 0xa237
jmp 0x4c61
movq (%rax), %rax
movzbl 0x1(%rdi), %ecx
leaq 0x561f(%rip), %rsi      # 0xa1e3
jmp 0x4c61
movw $0x72, 0x4(%rdx)
movl $0x6f727265, (%rdx)     # imm = 0x6F727265
xorl %eax, %eax
retq
movq (%rax), %rax
movzwl 0x1(%rdi), %ecx
leaq 0x5607(%rip), %rsi      # 0xa1ed
jmp 0x4c83
movq (%rax), %rax
movzwl 0x1(%rdi), %ecx
leaq 0x5625(%rip), %rsi      # 0xa21e
jmp 0x4c83
movq (%rax), %rax
movzbl 0x1(%rdi), %ecx
leaq 0x55cc(%rip), %rsi      # 0xa1d8
jmp 0x4c61
movq (%rax), %rax
movzbl 0x1(%rdi), %ecx
leaq 0x55e8(%rip), %rsi      # 0xa204
jmp 0x4c61
movq (%rax), %rax
movsbl 0x1(%rdi), %r8d
leal (%rsi,%r8), %ecx
addl $0x2, %ecx
leaq 0x563b(%rip), %rsi      # 0xa26f
movq %rdx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x4090
jmp 0x4c6e
movq (%rax), %rax
movzwl 0x1(%rdi), %ecx
leaq 0x55c0(%rip), %rsi      # 0xa211
jmp 0x4c83
movq (%rax), %rax
movzbl 0x1(%rdi), %ecx
leaq 0x55e5(%rip), %rsi      # 0xa246
movq %rdx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x4090
movl $0x2, %eax
jmp 0x4c95
movq (%rax), %rax
movzwl 0x1(%rdi), %ecx
leaq 0x55a8(%rip), %rsi      # 0xa22b
movq %rdx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x4090
movl $0x3, %eax
addq $0x8, %rsp
retq
nop