// File: 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:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
shll $0x4, %eax
movl %eax, %ecx
leaq 0xfeaa(%rip), %rax      # 0x15430
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movl 0x8(%rax), %eax
movq %rax, -0x30(%rbp)
subq $0xe, %rax
ja 0x58b0
movq -0x30(%rbp), %rax
leaq 0x9beb(%rip), %rcx      # 0xf198
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rdx
leaq 0x9c0c(%rip), %rsi      # 0xf1d4
movb $0x0, %al
callq 0x40b0
movl $0x1, -0x4(%rbp)
jmp 0x58c9
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rdx
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %ecx
leaq 0x9be2(%rip), %rsi      # 0xf1d7
movb $0x0, %al
callq 0x40b0
movl $0x2, -0x4(%rbp)
jmp 0x58c9
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rdx
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %ecx
leaq 0x9bc0(%rip), %rsi      # 0xf1e2
movb $0x0, %al
callq 0x40b0
movl $0x2, -0x4(%rbp)
jmp 0x58c9
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rdx
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %ecx
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %eax
shll $0x8, %eax
orl %eax, %ecx
leaq 0x9b90(%rip), %rsi      # 0xf1ec
movb $0x0, %al
callq 0x40b0
movl $0x3, -0x4(%rbp)
jmp 0x58c9
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rdx
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %ecx
leaq 0x9b6d(%rip), %rsi      # 0xf1f6
movb $0x0, %al
callq 0x40b0
movl $0x2, -0x4(%rbp)
jmp 0x58c9
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rdx
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %ecx
leaq 0x9b4d(%rip), %rsi      # 0xf203
movb $0x0, %al
callq 0x40b0
movl $0x2, -0x4(%rbp)
jmp 0x58c9
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rdx
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %ecx
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %eax
shll $0x8, %eax
orl %eax, %ecx
leaq 0x9b20(%rip), %rsi      # 0xf210
movb $0x0, %al
callq 0x40b0
movl $0x3, -0x4(%rbp)
jmp 0x58c9
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rdx
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %ecx
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %eax
shll $0x8, %eax
orl %eax, %ecx
leaq 0x9af3(%rip), %rsi      # 0xf21d
movb $0x0, %al
callq 0x40b0
movl $0x3, -0x4(%rbp)
jmp 0x58c9
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rdx
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %ecx
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %eax
shll $0x8, %eax
orl %eax, %ecx
leaq 0x9ac6(%rip), %rsi      # 0xf22a
movb $0x0, %al
callq 0x40b0
movl $0x3, -0x4(%rbp)
jmp 0x58c9
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rdx
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %ecx
leaq 0x9aa5(%rip), %rsi      # 0xf236
movb $0x0, %al
callq 0x40b0
movl $0x2, -0x4(%rbp)
jmp 0x58c9
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rdx
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %ecx
leaq 0x9a87(%rip), %rsi      # 0xf245
movb $0x0, %al
callq 0x40b0
movl $0x2, -0x4(%rbp)
jmp 0x58c9
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rdx
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %ecx
leaq 0x9a69(%rip), %rsi      # 0xf254
movb $0x0, %al
callq 0x40b0
movl $0x2, -0x4(%rbp)
jmp 0x58c9
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rdx
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %ecx
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %eax
shll $0x8, %eax
orl %eax, %ecx
leaq 0x9a3b(%rip), %rsi      # 0xf260
movb $0x0, %al
callq 0x40b0
movl $0x3, -0x4(%rbp)
jmp 0x58c9
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rdx
movl -0x14(%rbp), %ecx
addl $0x2, %ecx
movq -0x10(%rbp), %rax
movsbl 0x1(%rax), %eax
addl %eax, %ecx
movq -0x10(%rbp), %rax
movsbl 0x1(%rax), %r8d
leaq 0x9a0b(%rip), %rsi      # 0xf26e
movb $0x0, %al
callq 0x40b0
movl $0x2, -0x4(%rbp)
jmp 0x58c9
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rdx
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %ecx
movl -0x14(%rbp), %r8d
addl $0x2, %r8d
movq -0x10(%rbp), %rax
movsbl 0x2(%rax), %eax
addl %eax, %r8d
leaq 0x99e4(%rip), %rsi      # 0xf284
movb $0x0, %al
callq 0x40b0
movl $0x3, -0x4(%rbp)
jmp 0x58c9
movq -0x20(%rbp), %rdi
leaq 0x99da(%rip), %rsi      # 0xf295
movb $0x0, %al
callq 0x40b0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)