// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x1c8, %rsp            # imm = 0x1C8
movl %ecx, %r14d
movl %edx, %ebp
movl %esi, %r15d
movq %rdi, %rbx
leaq 0x3c7c(%rip), %rsi      # 0x12139
leaq 0x20(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x4150
cmpl $0xff, %r15d
ja 0xe54a
movl %r15d, %r15d
movq %r15, %rax
shlq $0x5, %rax
leaq 0xd01a(%rip), %rsi      # 0x1b500
addq %rax, %rsi
leaq 0x20(%rsp), %rdi
callq 0x4200
leaq 0x40(%rsp), %rdi
callq 0x4290
movq 0x50(%rsp), %rax
movq -0x18(%rax), %rax
movl 0x68(%rsp,%rax), %ecx
andl $-0x4b, %ecx
orl $0x8, %ecx
movl %ecx, 0x68(%rsp,%rax)
leaq 0x51b5(%rip), %rax      # 0x136d0
movl (%rax,%r15,4), %eax
cmpq $0xd, %rax
ja 0xe7ac
leaq 0x50(%rsp), %rdi
leaq 0x515b(%rip), %rcx      # 0x13690
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x5671(%rip), %rsi      # 0x13bb6
jmp 0xe6dd
leaq 0x5633(%rip), %rsi      # 0x13b84
leaq 0x40(%rsp), %rdx
movq %rbx, %rdi
callq 0x4150
jmp 0xe7db
leaq 0x5653(%rip), %rsi      # 0x13bbd
callq 0x4390
pushq $0x30
popq %rsi
movq %rax, %rdi
callq 0x4560
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq $0x2, 0x10(%rax,%rcx)
movq %rax, %rdi
movl %ebp, %esi
callq 0x4610
leaq 0x5626(%rip), %rsi      # 0x13bc1
jmp 0xe7a4
leaq 0x560f(%rip), %rsi      # 0x13bb6
callq 0x4390
pushq $0x30
popq %rsi
movq %rax, %rdi
callq 0x4560
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq $0x2, 0x10(%rax,%rcx)
movq %rax, %rdi
movl %r14d, %esi
callq 0x4610
jmp 0xe68e
leaq 0x55df(%rip), %rsi      # 0x13bbd
callq 0x4390
pushq $0x30
popq %rsi
movq %rax, %rdi
callq 0x4560
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq $0x2, 0x10(%rax,%rcx)
movq %rax, %rdi
movl %ebp, %esi
callq 0x4610
leaq 0x55b6(%rip), %rsi      # 0x13bc5
jmp 0xe7a4
leaq 0x559b(%rip), %rsi      # 0x13bb6
callq 0x4390
pushq $0x30
popq %rsi
movq %rax, %rdi
callq 0x4560
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq $0x2, 0x10(%rax,%rcx)
movq %rax, %rdi
movl %r14d, %esi
callq 0x4610
jmp 0xe6e2
leaq 0x5564(%rip), %rsi      # 0x13bb6
callq 0x4390
pushq $0x30
popq %rsi
movq %rax, %rdi
callq 0x4560
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq $0x2, 0x10(%rax,%rcx)
movq %rax, %rdi
movl %r14d, %esi
callq 0x4610
jmp 0xe778
leaq 0x552d(%rip), %rsi      # 0x13bb6
callq 0x4390
pushq $0x30
popq %rsi
movq %rax, %rdi
callq 0x4560
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq $0x2, 0x10(%rax,%rcx)
movq %rax, %rdi
movl %ebp, %esi
callq 0x4610
leaq 0x54ff(%rip), %rsi      # 0x13bb9
jmp 0xe7a4
leaq 0x54d2(%rip), %rsi      # 0x13b98
movq %rsp, %rdx
movq %rbx, %rdi
callq 0x4150
jmp 0xe7d1
leaq 0x54d5(%rip), %rsi      # 0x13bb2
callq 0x4390
pushq $0x30
popq %rsi
movq %rax, %rdi
callq 0x4560
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq $0x2, 0x10(%rax,%rcx)
movq %rax, %rdi
movl %ebp, %esi
callq 0x4610
jmp 0xe7ac
leaq 0x54aa(%rip), %rsi      # 0x13bbd
callq 0x4390
pushq $0x30
popq %rsi
movq %rax, %rdi
callq 0x4560
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq $0x2, 0x10(%rax,%rcx)
movq %rax, %rdi
movl %r14d, %esi
callq 0x4610
pushq $0x30
popq %rsi
movq %rax, %rdi
callq 0x4560
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq $0x2, 0x10(%rax,%rcx)
movq %rax, %rdi
movl %ebp, %esi
callq 0x4610
leaq 0x4cc8(%rip), %rsi      # 0x13432
jmp 0xe7a4
leaq 0x5443(%rip), %rsi      # 0x13bb6
callq 0x4390
pushq $0x30
popq %rsi
movq %rax, %rdi
callq 0x4560
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq $0x2, 0x10(%rax,%rcx)
movq %rax, %rdi
movl %ebp, %esi
callq 0x4610
leaq 0x5422(%rip), %rsi      # 0x13bc6
movq %rax, %rdi
callq 0x4390
leaq 0x58(%rsp), %rsi
movq %rsp, %rdi
callq 0x4570
leaq 0x20(%rsp), %rsi
movq %rsp, %rdx
movq %rbx, %rdi
callq 0xe851
movq %rsp, %rdi
callq 0x41b0
leaq 0x40(%rsp), %rdi
callq 0x42d0
leaq 0x20(%rsp), %rdi
callq 0x41b0
movq %rbx, %rax
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0xe810
movq %rax, %rbx
movq %rsp, %rdi
callq 0x41b0
jmp 0xe813
jmp 0xe810
jmp 0xe80b
jmp 0xe80b
movq %rax, %rbx
jmp 0xe81d
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x42d0
leaq 0x20(%rsp), %rdi
callq 0x41b0
movq %rbx, %rdi
callq 0x4640
nop