// File: mdpkh[P]retro6k/src/main.cpp
// Function: DisplayArgs(char*, unsigned char, char*, char**)
inline void DisplayArgs(char* dest, unsigned char opc, char* args, char** end)
{
	const enum amode : char {
		AM_IMP,
		AM_ACC,
		AM_IMM,
		AM_REL,
		AM_ZP,
		AM_ZPX,
		AM_ZPY,
		AM_INDX,
		AM_INDY,
		AM_ABS,
		AM_ABSX,
		AM_ABSY,
		AM_IND
	} amodes[256] = {
		AM_IMP, AM_INDX, AM_IMP, AM_INDX,  AM_ZP,  AM_ZP,  AM_ZP,  AM_ZP, AM_IMP,  AM_IMM, AM_ACC,  AM_IMM,  AM_ABS,  AM_ABS,  AM_ABS,  AM_ABS,
		AM_REL, AM_INDY, AM_IMP, AM_INDY, AM_ZPX, AM_ZPX, AM_ZPX, AM_ZPX, AM_IMP, AM_ABSY, AM_IMP, AM_ABSY, AM_ABSX, AM_ABSX, AM_ABSX, AM_ABSX,
		AM_ABS, AM_INDX, AM_IMP, AM_INDX,  AM_ZP,  AM_ZP,  AM_ZP,  AM_ZP, AM_IMP,  AM_IMM, AM_ACC,  AM_IMM,  AM_ABS,  AM_ABS,  AM_ABS,  AM_ABS,
		AM_REL, AM_INDY, AM_IMP, AM_INDY, AM_ZPX, AM_ZPX, AM_ZPX, AM_ZPX, AM_IMP, AM_ABSY, AM_IMP, AM_ABSY, AM_ABSX, AM_ABSX, AM_ABSX, AM_ABSX,
		AM_IMP, AM_INDX, AM_IMP, AM_INDX,  AM_ZP,  AM_ZP,  AM_ZP,  AM_ZP, AM_IMP,  AM_IMM, AM_ACC,  AM_IMM,  AM_ABS,  AM_ABS,  AM_ABS,  AM_ABS,
		AM_REL, AM_INDY, AM_IMP, AM_INDY, AM_ZPX, AM_ZPX, AM_ZPX, AM_ZPX, AM_IMP, AM_ABSY, AM_IMP, AM_ABSY, AM_ABSX, AM_ABSX, AM_ABSX, AM_ABSX,
		AM_IMP, AM_INDX, AM_IMP, AM_INDX,  AM_ZP,  AM_ZP,  AM_ZP,  AM_ZP, AM_IMP,  AM_IMM, AM_ACC,  AM_IMM,  AM_IND,  AM_ABS,  AM_ABS,  AM_ABS,
		AM_REL, AM_INDY, AM_IMP, AM_INDY, AM_ZPX, AM_ZPX, AM_ZPX, AM_ZPX, AM_IMP, AM_ABSY, AM_IMP, AM_ABSY, AM_ABSX, AM_ABSX, AM_ABSX, AM_ABSX,
		AM_IMM, AM_INDX, AM_IMM, AM_INDX,  AM_ZP,  AM_ZP,  AM_ZP,  AM_ZP, AM_IMP,  AM_IMM, AM_IMP,  AM_IMM,  AM_ABS,  AM_ABS,  AM_ABS,  AM_ABS,
		AM_REL, AM_INDY, AM_IMP, AM_INDY, AM_ZPX, AM_ZPX, AM_ZPY, AM_ZPY, AM_IMP, AM_ABSY, AM_IMP, AM_ABSY, AM_ABSX, AM_ABSX, AM_ABSY, AM_ABSY,
		AM_IMM, AM_INDX, AM_IMM, AM_INDX,  AM_ZP,  AM_ZP,  AM_ZP,  AM_ZP, AM_IMP,  AM_IMM, AM_IMP,  AM_IMM,  AM_ABS,  AM_ABS,  AM_ABS,  AM_ABS,
		AM_REL, AM_INDY, AM_IMP, AM_INDY, AM_ZPX, AM_ZPX, AM_ZPY, AM_ZPY, AM_IMP, AM_ABSY, AM_IMP, AM_ABSY, AM_ABSX, AM_ABSX, AM_ABSY, AM_ABSY,
		AM_IMM, AM_INDX, AM_IMM, AM_INDX,  AM_ZP,  AM_ZP,  AM_ZP,  AM_ZP, AM_IMP,  AM_IMM, AM_IMP,  AM_IMM,  AM_ABS,  AM_ABS,  AM_ABS,  AM_ABS,
		AM_REL, AM_INDY, AM_IMP, AM_INDY, AM_ZPX, AM_ZPX, AM_ZPX, AM_ZPX, AM_IMP, AM_ABSY, AM_IMP, AM_ABSY, AM_ABSX, AM_ABSX, AM_ABSX, AM_ABSX,
		AM_IMM, AM_INDX, AM_IMM, AM_INDX,  AM_ZP,  AM_ZP,  AM_ZP,  AM_ZP, AM_IMP,  AM_IMM, AM_IMP,  AM_IMM,  AM_ABS,  AM_ABS,  AM_ABS,  AM_ABS,
		AM_REL, AM_INDY, AM_IMP, AM_INDY, AM_ZPX, AM_ZPX, AM_ZPX, AM_ZPX, AM_IMP, AM_ABSY, AM_IMP, AM_ABSY, AM_ABSX, AM_ABSX, AM_ABSX, AM_ABSX 
	};
	switch (amodes[opc])
	{
	case AM_IMP:
		*end = dest;
		break;
	case AM_ACC:
		*dest = 0x41;
		*++dest = 0x20;
		*end = dest + 1;
		break;
	case AM_IMM:
		*dest = 0x23;
		*++dest = 0x24;
		DisplayHexByte(++dest, args[0]);
		dest += 2;
		*dest = 0x20;
		*end = dest + 1;
		break;
	case AM_REL:
	case AM_ZP:
		*dest = 0x24;
		DisplayHexByte(++dest, args[0]);
		dest += 2;
		*dest = 0x20;
		*end = dest + 1;
		break;
	case AM_ZPX:
		*dest = 0x24;
		DisplayHexByte(++dest, args[0]);
		dest += 2;
		*dest = 0x2c;
		*++dest = 0x58;
		*++dest = 0x20;
		*end = dest + 1;
		break;
	case AM_ZPY:
		*dest = 0x24;
		DisplayHexByte(++dest, args[0]);
		dest += 2;
		*dest = 0x2c;
		*++dest = 0x59;
		*++dest = 0x20;
		*end = dest + 1;
		break;
	case AM_INDX:
		*dest = 0x28;
		*++dest = 0x24;
		DisplayHexByte(++dest, args[0]);
		dest += 2;
		*dest = 0x2c;
		*++dest = 0x58;
		*++dest = 0x29;
		*++dest = 0x20;
		*end = dest + 1;
		break;
	case AM_INDY:
		*dest = 0x28;
		*++dest = 0x24;
		DisplayHexByte(++dest, args[0]);
		dest += 2;
		*dest = 0x29;
		*++dest = 0x2c;
		*++dest = 0x59;
		*++dest = 0x20;
		*end = dest + 1;
		break;
	case AM_ABS:
		*dest = 0x24;
		DisplayHexByte(++dest, args[1]);
		dest += 2;
		DisplayHexByte(dest, args[0]);
		dest += 2;
		*dest = 0x20;
		*end = dest + 1;
		break;
	case AM_ABSX:
		*dest = 0x24;
		DisplayHexByte(++dest, args[1]);
		dest += 2;
		DisplayHexByte(dest, args[0]);
		dest += 2;
		*dest = 0x2c;
		*++dest = 0x58;
		*++dest = 0x20;
		*end = dest + 1;
		break;
	case AM_ABSY:
		*dest = 0x24;
		DisplayHexByte(++dest, args[1]);
		dest += 2;
		DisplayHexByte(dest, args[0]);
		dest += 2;
		*dest = 0x2c;
		*++dest = 0x59;
		*++dest = 0x20;
		*end = dest + 1;
		break;
	case AM_IND:
		*dest = 0x28;
		*++dest = 0x24;
		DisplayHexByte(++dest, args[1]);
		dest += 2;
		DisplayHexByte(dest, args[0]);
		dest += 2;
		*dest = 0x29;
		*++dest = 0x20;
		*end = dest + 1;
		break;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movb %sil, %al
movq %rdi, -0x8(%rbp)
movb %al, -0x9(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
leaq 0xdc3c(%rip), %rsi      # 0x20eb0
leaq -0x120(%rbp), %rdi
movl $0x100, %edx            # imm = 0x100
callq 0x73c0
movzbl -0x9(%rbp), %eax
movsbl -0x120(%rbp,%rax), %eax
movl %eax, %ecx
movq %rcx, -0x128(%rbp)
subl $0xc, %eax
ja 0x1378c
movq -0x128(%rbp), %rax
leaq 0x100ff(%rip), %rcx     # 0x233b0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x8(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
jmp 0x1378c
movq -0x8(%rbp), %rax
movb $0x41, (%rax)
movq -0x8(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x8(%rbp)
movb $0x20, 0x1(%rax)
movq -0x8(%rbp), %rcx
addq $0x1, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
jmp 0x1378c
movq -0x8(%rbp), %rax
movb $0x23, (%rax)
movq -0x8(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x8(%rbp)
movb $0x24, 0x1(%rax)
movq -0x8(%rbp), %rdi
addq $0x1, %rdi
movq %rdi, -0x8(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %esi
callq 0x13130
movq -0x8(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
movb $0x20, (%rax)
movq -0x8(%rbp), %rcx
addq $0x1, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
jmp 0x1378c
movq -0x8(%rbp), %rax
movb $0x24, (%rax)
movq -0x8(%rbp), %rdi
addq $0x1, %rdi
movq %rdi, -0x8(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %esi
callq 0x13130
movq -0x8(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
movb $0x20, (%rax)
movq -0x8(%rbp), %rcx
addq $0x1, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
jmp 0x1378c
movq -0x8(%rbp), %rax
movb $0x24, (%rax)
movq -0x8(%rbp), %rdi
addq $0x1, %rdi
movq %rdi, -0x8(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %esi
callq 0x13130
movq -0x8(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
movb $0x2c, (%rax)
movq -0x8(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x8(%rbp)
movb $0x58, 0x1(%rax)
movq -0x8(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x8(%rbp)
movb $0x20, 0x1(%rax)
movq -0x8(%rbp), %rcx
addq $0x1, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
jmp 0x1378c
movq -0x8(%rbp), %rax
movb $0x24, (%rax)
movq -0x8(%rbp), %rdi
addq $0x1, %rdi
movq %rdi, -0x8(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %esi
callq 0x13130
movq -0x8(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
movb $0x2c, (%rax)
movq -0x8(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x8(%rbp)
movb $0x59, 0x1(%rax)
movq -0x8(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x8(%rbp)
movb $0x20, 0x1(%rax)
movq -0x8(%rbp), %rcx
addq $0x1, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
jmp 0x1378c
movq -0x8(%rbp), %rax
movb $0x28, (%rax)
movq -0x8(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x8(%rbp)
movb $0x24, 0x1(%rax)
movq -0x8(%rbp), %rdi
addq $0x1, %rdi
movq %rdi, -0x8(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %esi
callq 0x13130
movq -0x8(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
movb $0x2c, (%rax)
movq -0x8(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x8(%rbp)
movb $0x58, 0x1(%rax)
movq -0x8(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x8(%rbp)
movb $0x29, 0x1(%rax)
movq -0x8(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x8(%rbp)
movb $0x20, 0x1(%rax)
movq -0x8(%rbp), %rcx
addq $0x1, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
jmp 0x1378c
movq -0x8(%rbp), %rax
movb $0x28, (%rax)
movq -0x8(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x8(%rbp)
movb $0x24, 0x1(%rax)
movq -0x8(%rbp), %rdi
addq $0x1, %rdi
movq %rdi, -0x8(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %esi
callq 0x13130
movq -0x8(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
movb $0x29, (%rax)
movq -0x8(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x8(%rbp)
movb $0x2c, 0x1(%rax)
movq -0x8(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x8(%rbp)
movb $0x59, 0x1(%rax)
movq -0x8(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x8(%rbp)
movb $0x20, 0x1(%rax)
movq -0x8(%rbp), %rcx
addq $0x1, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
jmp 0x1378c
movq -0x8(%rbp), %rax
movb $0x24, (%rax)
movq -0x8(%rbp), %rdi
addq $0x1, %rdi
movq %rdi, -0x8(%rbp)
movq -0x18(%rbp), %rax
movsbl 0x1(%rax), %esi
callq 0x13130
movq -0x8(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movsbl (%rax), %esi
callq 0x13130
movq -0x8(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
movb $0x20, (%rax)
movq -0x8(%rbp), %rcx
addq $0x1, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
jmp 0x1378c
movq -0x8(%rbp), %rax
movb $0x24, (%rax)
movq -0x8(%rbp), %rdi
addq $0x1, %rdi
movq %rdi, -0x8(%rbp)
movq -0x18(%rbp), %rax
movsbl 0x1(%rax), %esi
callq 0x13130
movq -0x8(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movsbl (%rax), %esi
callq 0x13130
movq -0x8(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
movb $0x2c, (%rax)
movq -0x8(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x8(%rbp)
movb $0x58, 0x1(%rax)
movq -0x8(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x8(%rbp)
movb $0x20, 0x1(%rax)
movq -0x8(%rbp), %rcx
addq $0x1, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
jmp 0x1378c
movq -0x8(%rbp), %rax
movb $0x24, (%rax)
movq -0x8(%rbp), %rdi
addq $0x1, %rdi
movq %rdi, -0x8(%rbp)
movq -0x18(%rbp), %rax
movsbl 0x1(%rax), %esi
callq 0x13130
movq -0x8(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movsbl (%rax), %esi
callq 0x13130
movq -0x8(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
movb $0x2c, (%rax)
movq -0x8(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x8(%rbp)
movb $0x59, 0x1(%rax)
movq -0x8(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x8(%rbp)
movb $0x20, 0x1(%rax)
movq -0x8(%rbp), %rcx
addq $0x1, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
jmp 0x1378c
movq -0x8(%rbp), %rax
movb $0x28, (%rax)
movq -0x8(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x8(%rbp)
movb $0x24, 0x1(%rax)
movq -0x8(%rbp), %rdi
addq $0x1, %rdi
movq %rdi, -0x8(%rbp)
movq -0x18(%rbp), %rax
movsbl 0x1(%rax), %esi
callq 0x13130
movq -0x8(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movsbl (%rax), %esi
callq 0x13130
movq -0x8(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
movb $0x29, (%rax)
movq -0x8(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x8(%rbp)
movb $0x20, 0x1(%rax)
movq -0x8(%rbp), %rcx
addq $0x1, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop