// File: khedoros[P]khednes/util.cpp
// Function: util::inst_string[abi:cxx11](int, int, int)
std::string util::inst_string(int byte0, int byte1, int byte2) {
    std::string inst = "";
    if(byte0 >= 0 && byte0 < 256) {
        inst = inst_names[byte0];
    }
    else {
        return std::string("Opcode out of range");
    }
    std::stringstream ss;
    ss<<std::hex;
    switch(inst_types[byte0]) {
        case inv: //invalid operation
            return std::string("Unofficial/invalid opcode");
        //Fall-through for types that don't show any arguments
        case acc: //accumulator
        case imp: //implied
            break;
        case imm: //immediate
            ss<<" #$"<<std::setfill('0')<<std::setw(2)<<byte1;
            break;
        case zpa: //zero-page absolute
            ss<<" $"<<std::setfill('0')<<std::setw(2)<<byte1;
            break;
        case rel: //relative
            ss<<" $"<<std::setfill('0')<<std::setw(2)<<byte1;
            break;
        case abso: //absolute
            ss<<" $"<<std::setfill('0')<<std::setw(2)<<byte2<<std::setfill('0')<<std::setw(2)<<byte1;
            break;
        case absx://absolute, x-indexed
            ss<<" $"<<std::setfill('0')<<std::setw(2)<<byte2<<std::setfill('0')<<std::setw(2)<<byte1<<", X";
            break;
        case absy://absolute, y-indexed
            ss<<" $"<<std::setfill('0')<<std::setw(2)<<byte2<<std::setfill('0')<<std::setw(2)<<byte1<<", Y";
            break;
        case zpx: //zero-page absolute, x-indexed
            ss<<" $"<<std::setfill('0')<<std::setw(2)<<byte1<<", X";
            break;
        case zpy: //zero-page absolute, y-indexed
            ss<<" $"<<std::setfill('0')<<std::setw(2)<<byte1<<", Y";
            break;
        case ind: //indirect
            ss<<" ($"<<std::setfill('0')<<std::setw(2)<<byte2<<std::setfill('0')<<std::setw(2)<<byte1<<")";
            break;
        case zpix://zero-page indirect, x-pre-indexed
            ss<<" ($"<<std::setfill('0')<<std::setw(2)<<byte1<<",X)";
            break;
        case zpiy: //zero-page indirect, y-post-indexed
            ss<<" ($"<<std::setfill('0')<<std::setw(2)<<byte1<<"), Y";
            break;
        default:
            break;
            return std::string("Don't know how you got here.");
    }
    return inst + ss.str();
}

// Assembly:
subq $0x538, %rsp            # imm = 0x538
movq %rdi, 0x2a8(%rsp)
movq %rdi, %rax
movq %rax, 0x2b0(%rsp)
movq %rdi, 0x530(%rsp)
movl %esi, 0x52c(%rsp)
movl %edx, 0x528(%rsp)
movl %ecx, 0x524(%rsp)
leaq 0x4ff(%rsp), %rdi
movq %rdi, 0x2b8(%rsp)
callq 0x4690
movq 0x2b8(%rsp), %rdx
leaq 0x9f82(%rip), %rsi      # 0x2b16d
leaq 0x500(%rsp), %rdi
callq 0x4500
jmp 0x211fa
leaq 0x4ff(%rsp), %rdi
callq 0x4410
cmpl $0x0, 0x52c(%rsp)
jl 0x21287
cmpl $0x100, 0x52c(%rsp) # imm = 0x100
jge 0x21287
movslq 0x52c(%rsp), %rax
shlq $0x5, %rax
leaq 0x162ff(%rip), %rsi     # 0x37530
addq %rax, %rsi
leaq 0x500(%rsp), %rdi
callq 0x4040
jmp 0x21243
jmp 0x212fd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4f0(%rsp)
movl %eax, 0x4ec(%rsp)
leaq 0x4ff(%rsp), %rdi
callq 0x4410
jmp 0x21f78
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4f0(%rsp)
movl %eax, 0x4ec(%rsp)
jmp 0x21f6b
leaq 0x4eb(%rsp), %rdi
movq %rdi, 0x2a0(%rsp)
callq 0x4690
movq 0x2a8(%rsp), %rdi
movq 0x2a0(%rsp), %rdx
leaq 0xb971(%rip), %rsi      # 0x2cc24
callq 0x4500
jmp 0x212ba
leaq 0x4eb(%rsp), %rdi
callq 0x4410
movl $0x1, 0x4e4(%rsp)
jmp 0x21f4e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4f0(%rsp)
movl %eax, 0x4ec(%rsp)
leaq 0x4eb(%rsp), %rdi
callq 0x4410
jmp 0x21f6b
leaq 0x358(%rsp), %rdi
callq 0x42b0
jmp 0x2130c
leaq 0x368(%rsp), %rdi
leaq -0xfcfb(%rip), %rsi     # 0x11620
callq 0x4150
jmp 0x21322
movslq 0x52c(%rsp), %rcx
leaq 0xb47f(%rip), %rax      # 0x2c7b0
movl (%rax,%rcx,4), %eax
movq %rax, 0x298(%rsp)
subq $0xd, %rax
ja 0x21ebb
movq 0x298(%rsp), %rax
leaq 0xb41b(%rip), %rcx      # 0x2c770
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4f0(%rsp)
movl %eax, 0x4ec(%rsp)
jmp 0x21f3f
leaq 0x357(%rsp), %rdi
movq %rdi, 0x290(%rsp)
callq 0x4690
movq 0x2a8(%rsp), %rdi
movq 0x290(%rsp), %rdx
leaq 0xb895(%rip), %rsi      # 0x2cc38
callq 0x4500
jmp 0x213aa
leaq 0x357(%rsp), %rdi
callq 0x4410
movl $0x1, 0x4e4(%rsp)
jmp 0x21f30
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4f0(%rsp)
movl %eax, 0x4ec(%rsp)
leaq 0x357(%rsp), %rdi
callq 0x4410
jmp 0x21f3f
jmp 0x21ebd
leaq 0x368(%rsp), %rdi
leaq 0xb851(%rip), %rsi      # 0x2cc52
callq 0x43c0
movq %rax, 0x288(%rsp)
jmp 0x21410
movl $0x30, %edi
callq 0x22090
movb %al, 0x287(%rsp)
jmp 0x21423
movq 0x288(%rsp), %rdi
movb 0x287(%rsp), %al
movb %al, 0x356(%rsp)
movzbl 0x356(%rsp), %esi
callq 0x45c0
movq %rax, 0x278(%rsp)
jmp 0x21450
movl $0x2, %edi
callq 0x220b0
movl %eax, 0x274(%rsp)
jmp 0x21463
movq 0x278(%rsp), %rdi
movl 0x274(%rsp), %eax
movl %eax, 0x350(%rsp)
movl 0x350(%rsp), %esi
callq 0x4440
movq %rax, 0x268(%rsp)
jmp 0x2148f
movq 0x268(%rsp), %rdi
movl 0x528(%rsp), %esi
callq 0x4660
jmp 0x214a5
jmp 0x21ebd
leaq 0x368(%rsp), %rdi
leaq 0xb79d(%rip), %rsi      # 0x2cc56
callq 0x43c0
movq %rax, 0x260(%rsp)
jmp 0x214c8
movl $0x30, %edi
callq 0x22090
movb %al, 0x25f(%rsp)
jmp 0x214db
movq 0x260(%rsp), %rdi
movb 0x25f(%rsp), %al
movb %al, 0x34f(%rsp)
movzbl 0x34f(%rsp), %esi
callq 0x45c0
movq %rax, 0x250(%rsp)
jmp 0x21508
movl $0x2, %edi
callq 0x220b0
movl %eax, 0x24c(%rsp)
jmp 0x2151b
movq 0x250(%rsp), %rdi
movl 0x24c(%rsp), %eax
movl %eax, 0x348(%rsp)
movl 0x348(%rsp), %esi
callq 0x4440
movq %rax, 0x240(%rsp)
jmp 0x21547
movq 0x240(%rsp), %rdi
movl 0x528(%rsp), %esi
callq 0x4660
jmp 0x2155d
jmp 0x21ebd
leaq 0x368(%rsp), %rdi
leaq 0xb6e5(%rip), %rsi      # 0x2cc56
callq 0x43c0
movq %rax, 0x238(%rsp)
jmp 0x21580
movl $0x30, %edi
callq 0x22090
movb %al, 0x237(%rsp)
jmp 0x21593
movq 0x238(%rsp), %rdi
movb 0x237(%rsp), %al
movb %al, 0x347(%rsp)
movzbl 0x347(%rsp), %esi
callq 0x45c0
movq %rax, 0x228(%rsp)
jmp 0x215c0
movl $0x2, %edi
callq 0x220b0
movl %eax, 0x224(%rsp)
jmp 0x215d3
movq 0x228(%rsp), %rdi
movl 0x224(%rsp), %eax
movl %eax, 0x340(%rsp)
movl 0x340(%rsp), %esi
callq 0x4440
movq %rax, 0x218(%rsp)
jmp 0x215ff
movq 0x218(%rsp), %rdi
movl 0x528(%rsp), %esi
callq 0x4660
jmp 0x21615
jmp 0x21ebd
leaq 0x368(%rsp), %rdi
leaq 0xb62d(%rip), %rsi      # 0x2cc56
callq 0x43c0
movq %rax, 0x210(%rsp)
jmp 0x21638
movl $0x30, %edi
callq 0x22090
movb %al, 0x20f(%rsp)
jmp 0x2164b
movq 0x210(%rsp), %rdi
movb 0x20f(%rsp), %al
movb %al, 0x33f(%rsp)
movzbl 0x33f(%rsp), %esi
callq 0x45c0
movq %rax, 0x200(%rsp)
jmp 0x21678
movl $0x2, %edi
callq 0x220b0
movl %eax, 0x1fc(%rsp)
jmp 0x2168b
movq 0x200(%rsp), %rdi
movl 0x1fc(%rsp), %eax
movl %eax, 0x338(%rsp)
movl 0x338(%rsp), %esi
callq 0x4440
movq %rax, 0x1f0(%rsp)
jmp 0x216b7
movq 0x1f0(%rsp), %rdi
movl 0x524(%rsp), %esi
callq 0x4660
movq %rax, 0x1e8(%rsp)
jmp 0x216d5
movl $0x30, %edi
callq 0x22090
movb %al, 0x1e7(%rsp)
jmp 0x216e8
movq 0x1e8(%rsp), %rdi
movb 0x1e7(%rsp), %al
movb %al, 0x337(%rsp)
movzbl 0x337(%rsp), %esi
callq 0x45c0
movq %rax, 0x1d8(%rsp)
jmp 0x21715
movl $0x2, %edi
callq 0x220b0
movl %eax, 0x1d4(%rsp)
jmp 0x21728
movq 0x1d8(%rsp), %rdi
movl 0x1d4(%rsp), %eax
movl %eax, 0x330(%rsp)
movl 0x330(%rsp), %esi
callq 0x4440
movq %rax, 0x1c8(%rsp)
jmp 0x21754
movq 0x1c8(%rsp), %rdi
movl 0x528(%rsp), %esi
callq 0x4660
jmp 0x2176a
jmp 0x21ebd
leaq 0x368(%rsp), %rdi
leaq 0xb4d8(%rip), %rsi      # 0x2cc56
callq 0x43c0
movq %rax, 0x1c0(%rsp)
jmp 0x2178d
movl $0x30, %edi
callq 0x22090
movb %al, 0x1bf(%rsp)
jmp 0x217a0
movq 0x1c0(%rsp), %rdi
movb 0x1bf(%rsp), %al
movb %al, 0x32f(%rsp)
movzbl 0x32f(%rsp), %esi
callq 0x45c0
movq %rax, 0x1b0(%rsp)
jmp 0x217cd
movl $0x2, %edi
callq 0x220b0
movl %eax, 0x1ac(%rsp)
jmp 0x217e0
movq 0x1b0(%rsp), %rdi
movl 0x1ac(%rsp), %eax
movl %eax, 0x328(%rsp)
movl 0x328(%rsp), %esi
callq 0x4440
movq %rax, 0x1a0(%rsp)
jmp 0x2180c
movq 0x1a0(%rsp), %rdi
movl 0x524(%rsp), %esi
callq 0x4660
movq %rax, 0x198(%rsp)
jmp 0x2182a
movl $0x30, %edi
callq 0x22090
movb %al, 0x197(%rsp)
jmp 0x2183d
movq 0x198(%rsp), %rdi
movb 0x197(%rsp), %al
movb %al, 0x327(%rsp)
movzbl 0x327(%rsp), %esi
callq 0x45c0
movq %rax, 0x188(%rsp)
jmp 0x2186a
movl $0x2, %edi
callq 0x220b0
movl %eax, 0x184(%rsp)
jmp 0x2187d
movq 0x188(%rsp), %rdi
movl 0x184(%rsp), %eax
movl %eax, 0x320(%rsp)
movl 0x320(%rsp), %esi
callq 0x4440
movq %rax, 0x178(%rsp)
jmp 0x218a9
movq 0x178(%rsp), %rdi
movl 0x528(%rsp), %esi
callq 0x4660
movq %rax, 0x170(%rsp)
jmp 0x218c7
movq 0x170(%rsp), %rdi
leaq 0xb383(%rip), %rsi      # 0x2cc59
callq 0x43c0
jmp 0x218dd
jmp 0x21ebd
leaq 0x368(%rsp), %rdi
leaq 0xb365(%rip), %rsi      # 0x2cc56
callq 0x43c0
movq %rax, 0x168(%rsp)
jmp 0x21900
movl $0x30, %edi
callq 0x22090
movb %al, 0x167(%rsp)
jmp 0x21913
movq 0x168(%rsp), %rdi
movb 0x167(%rsp), %al
movb %al, 0x31f(%rsp)
movzbl 0x31f(%rsp), %esi
callq 0x45c0
movq %rax, 0x158(%rsp)
jmp 0x21940
movl $0x2, %edi
callq 0x220b0
movl %eax, 0x154(%rsp)
jmp 0x21953
movq 0x158(%rsp), %rdi
movl 0x154(%rsp), %eax
movl %eax, 0x318(%rsp)
movl 0x318(%rsp), %esi
callq 0x4440
movq %rax, 0x148(%rsp)
jmp 0x2197f
movq 0x148(%rsp), %rdi
movl 0x524(%rsp), %esi
callq 0x4660
movq %rax, 0x140(%rsp)
jmp 0x2199d
movl $0x30, %edi
callq 0x22090
movb %al, 0x13f(%rsp)
jmp 0x219b0
movq 0x140(%rsp), %rdi
movb 0x13f(%rsp), %al
movb %al, 0x317(%rsp)
movzbl 0x317(%rsp), %esi
callq 0x45c0
movq %rax, 0x130(%rsp)
jmp 0x219dd
movl $0x2, %edi
callq 0x220b0
movl %eax, 0x12c(%rsp)
jmp 0x219f0
movq 0x130(%rsp), %rdi
movl 0x12c(%rsp), %eax
movl %eax, 0x310(%rsp)
movl 0x310(%rsp), %esi
callq 0x4440
movq %rax, 0x120(%rsp)
jmp 0x21a1c
movq 0x120(%rsp), %rdi
movl 0x528(%rsp), %esi
callq 0x4660
movq %rax, 0x118(%rsp)
jmp 0x21a3a
movq 0x118(%rsp), %rdi
leaq 0xb21d(%rip), %rsi      # 0x2cc66
callq 0x43c0
jmp 0x21a50
jmp 0x21ebd
leaq 0x368(%rsp), %rdi
leaq 0xb1f2(%rip), %rsi      # 0x2cc56
callq 0x43c0
movq %rax, 0x110(%rsp)
jmp 0x21a73
movl $0x30, %edi
callq 0x22090
movb %al, 0x10f(%rsp)
jmp 0x21a86
movq 0x110(%rsp), %rdi
movb 0x10f(%rsp), %al
movb %al, 0x30f(%rsp)
movzbl 0x30f(%rsp), %esi
callq 0x45c0
movq %rax, 0x100(%rsp)
jmp 0x21ab3
movl $0x2, %edi
callq 0x220b0
movl %eax, 0xfc(%rsp)
jmp 0x21ac6
movq 0x100(%rsp), %rdi
movl 0xfc(%rsp), %eax
movl %eax, 0x308(%rsp)
movl 0x308(%rsp), %esi
callq 0x4440
movq %rax, 0xf0(%rsp)
jmp 0x21af2
movq 0xf0(%rsp), %rdi
movl 0x528(%rsp), %esi
callq 0x4660
movq %rax, 0xe8(%rsp)
jmp 0x21b10
movq 0xe8(%rsp), %rdi
leaq 0xb13a(%rip), %rsi      # 0x2cc59
callq 0x43c0
jmp 0x21b26
jmp 0x21ebd
leaq 0x368(%rsp), %rdi
leaq 0xb11c(%rip), %rsi      # 0x2cc56
callq 0x43c0
movq %rax, 0xe0(%rsp)
jmp 0x21b49
movl $0x30, %edi
callq 0x22090
movb %al, 0xdf(%rsp)
jmp 0x21b5c
movq 0xe0(%rsp), %rdi
movb 0xdf(%rsp), %al
movb %al, 0x307(%rsp)
movzbl 0x307(%rsp), %esi
callq 0x45c0
movq %rax, 0xd0(%rsp)
jmp 0x21b89
movl $0x2, %edi
callq 0x220b0
movl %eax, 0xcc(%rsp)
jmp 0x21b9c
movq 0xd0(%rsp), %rdi
movl 0xcc(%rsp), %eax
movl %eax, 0x300(%rsp)
movl 0x300(%rsp), %esi
callq 0x4440
movq %rax, 0xc0(%rsp)
jmp 0x21bc8
movq 0xc0(%rsp), %rdi
movl 0x528(%rsp), %esi
callq 0x4660
movq %rax, 0xb8(%rsp)
jmp 0x21be6
movq 0xb8(%rsp), %rdi
leaq 0xb071(%rip), %rsi      # 0x2cc66
callq 0x43c0
jmp 0x21bfc
jmp 0x21ebd
leaq 0x368(%rsp), %rdi
leaq 0xb04d(%rip), %rsi      # 0x2cc5d
callq 0x43c0
movq %rax, 0xb0(%rsp)
jmp 0x21c1f
movl $0x30, %edi
callq 0x22090
movb %al, 0xaf(%rsp)
jmp 0x21c32
movq 0xb0(%rsp), %rdi
movb 0xaf(%rsp), %al
movb %al, 0x2ff(%rsp)
movzbl 0x2ff(%rsp), %esi
callq 0x45c0
movq %rax, 0xa0(%rsp)
jmp 0x21c5f
movl $0x2, %edi
callq 0x220b0
movl %eax, 0x9c(%rsp)
jmp 0x21c72
movq 0xa0(%rsp), %rdi
movl 0x9c(%rsp), %eax
movl %eax, 0x2f8(%rsp)
movl 0x2f8(%rsp), %esi
callq 0x4440
movq %rax, 0x90(%rsp)
jmp 0x21c9e
movq 0x90(%rsp), %rdi
movl 0x524(%rsp), %esi
callq 0x4660
movq %rax, 0x88(%rsp)
jmp 0x21cbc
movl $0x30, %edi
callq 0x22090
movb %al, 0x87(%rsp)
jmp 0x21ccf
movq 0x88(%rsp), %rdi
movb 0x87(%rsp), %al
movb %al, 0x2f7(%rsp)
movzbl 0x2f7(%rsp), %esi
callq 0x45c0
movq %rax, 0x78(%rsp)
jmp 0x21cf9
movl $0x2, %edi
callq 0x220b0
movl %eax, 0x74(%rsp)
jmp 0x21d09
movq 0x78(%rsp), %rdi
movl 0x74(%rsp), %eax
movl %eax, 0x2f0(%rsp)
movl 0x2f0(%rsp), %esi
callq 0x4440
movq %rax, 0x68(%rsp)
jmp 0x21d2c
movq 0x68(%rsp), %rdi
movl 0x528(%rsp), %esi
callq 0x4660
movq %rax, 0x60(%rsp)
jmp 0x21d44
movq 0x60(%rsp), %rdi
leaq 0xa792(%rip), %rsi      # 0x2c4e2
callq 0x43c0
jmp 0x21d57
jmp 0x21ebd
leaq 0x368(%rsp), %rdi
leaq 0xaef2(%rip), %rsi      # 0x2cc5d
callq 0x43c0
movq %rax, 0x58(%rsp)
jmp 0x21d77
movl $0x30, %edi
callq 0x22090
movb %al, 0x57(%rsp)
jmp 0x21d87
movq 0x58(%rsp), %rdi
movb 0x57(%rsp), %al
movb %al, 0x2ef(%rsp)
movzbl 0x2ef(%rsp), %esi
callq 0x45c0
movq %rax, 0x48(%rsp)
jmp 0x21dab
movl $0x2, %edi
callq 0x220b0
movl %eax, 0x44(%rsp)
jmp 0x21dbb
movq 0x48(%rsp), %rdi
movl 0x44(%rsp), %eax
movl %eax, 0x2e8(%rsp)
movl 0x2e8(%rsp), %esi
callq 0x4440
movq %rax, 0x38(%rsp)
jmp 0x21dde
movq 0x38(%rsp), %rdi
movl 0x528(%rsp), %esi
callq 0x4660
movq %rax, 0x30(%rsp)
jmp 0x21df6
movq 0x30(%rsp), %rdi
leaq 0xae5f(%rip), %rsi      # 0x2cc61
callq 0x43c0
jmp 0x21e09
jmp 0x21ebd
leaq 0x368(%rsp), %rdi
leaq 0xae40(%rip), %rsi      # 0x2cc5d
callq 0x43c0
movq %rax, 0x28(%rsp)
jmp 0x21e29
movl $0x30, %edi
callq 0x22090
movb %al, 0x27(%rsp)
jmp 0x21e39
movq 0x28(%rsp), %rdi
movb 0x27(%rsp), %al
movb %al, 0x2e7(%rsp)
movzbl 0x2e7(%rsp), %esi
callq 0x45c0
movq %rax, 0x18(%rsp)
jmp 0x21e5d
movl $0x2, %edi
callq 0x220b0
movl %eax, 0x14(%rsp)
jmp 0x21e6d
movq 0x18(%rsp), %rdi
movl 0x14(%rsp), %eax
movl %eax, 0x2e0(%rsp)
movl 0x2e0(%rsp), %esi
callq 0x4440
movq %rax, 0x8(%rsp)
jmp 0x21e90
movq 0x8(%rsp), %rdi
movl 0x528(%rsp), %esi
callq 0x4660
movq %rax, (%rsp)
jmp 0x21ea7
movq (%rsp), %rdi
leaq 0xadb3(%rip), %rsi      # 0x2cc65
callq 0x43c0
jmp 0x21eb9
jmp 0x21ebd
jmp 0x21ebd
leaq 0x2c0(%rsp), %rdi
leaq 0x358(%rsp), %rsi
callq 0x43b0
jmp 0x21ed4
movq 0x2a8(%rsp), %rdi
leaq 0x500(%rsp), %rsi
leaq 0x2c0(%rsp), %rdx
callq 0x220d0
jmp 0x21ef3
leaq 0x2c0(%rsp), %rdi
callq 0x4240
movl $0x1, 0x4e4(%rsp)
jmp 0x21f30
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4f0(%rsp)
movl %eax, 0x4ec(%rsp)
leaq 0x2c0(%rsp), %rdi
callq 0x4240
jmp 0x21f3f
leaq 0x358(%rsp), %rdi
callq 0x42f0
jmp 0x21f4e
leaq 0x358(%rsp), %rdi
callq 0x42f0
jmp 0x21f6b
leaq 0x500(%rsp), %rdi
callq 0x4240
movq 0x2b0(%rsp), %rax
addq $0x538, %rsp            # imm = 0x538
retq
leaq 0x500(%rsp), %rdi
callq 0x4240
movq 0x4f0(%rsp), %rdi
callq 0x4680
nopw %cs:(%rax,%rax)
nop