// File: Eronana[P]strawberry/src/disassembler.cpp
// Function: discode(unsigned char&, CodeData&, _IO_FILE*)
void discode(CODE &op,CodeData &code_data,FILE *out)
{
    switch(op)
    {
        case OP_NPUSH:
            fprintf(out,"PUSH NULL\n");
            break;
        case OP_BPUSH:
            fprintf(out,"PUSH %s\n",get_int8(&op)?"TRUE":"FALSE");
            break;
        case OP_IPUSH:
            fprintf(out,"PUSH %d\n",code_data.int_table[get_int32(&op)]);
            break;
        case OP_FPUSH:
            fprintf(out,"PUSH %f\n",code_data.float_table[get_int32(&op)]);
            break;
        case OP_SPUSH:
            fprintf(out,"PUSH ");
            print_string(out,code_data.string_table[get_int32(&op)]);
            fputc('\n',out);
            break;
        case OP_LOAD_GLOBAL:
        case OP_STORE_GLOBAL:
        case OP_LOAD:
        case OP_STORE:
        case OP_LOAD_EXTERNAL:
        case OP_STORE_EXTERNAL:
        case OP_CREATE_FUNCTION:
        case OP_ADDSP:
        case OP_SUBSP:
        case OP_CALL:
        case OP_JMP:

            fprintf(out,"%s %d\n",op_name[op],get_int32(&op));
            break;
        default:
            if(op>=SIZEOF(op_name))
            {
                fprintf(out,"; unknow instructor: %x\n",op);
                break;
            }
            fprintf(out,"%s\n",op_name[op]);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movzbl (%rax), %eax
movq %rax, -0x20(%rbp)
subq $0x36, %rax
ja 0x4e236
movq -0x20(%rbp), %rax
leaq 0xaed0(%rip), %rcx      # 0x58f84
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x18(%rbp), %rdi
leaq 0xaf9b(%rip), %rsi      # 0x59063
movb $0x0, %al
callq 0x74c0
jmp 0x4e284
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
callq 0x4e040
movq -0x28(%rbp), %rdi
movb %al, %cl
leaq 0xae17(%rip), %rdx      # 0x58f09
leaq 0xae09(%rip), %rax      # 0x58f02
cmpb $0x0, %cl
cmovneq %rax, %rdx
leaq 0xaf67(%rip), %rsi      # 0x5906e
movb $0x0, %al
callq 0x74c0
jmp 0x4e284
movq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
callq 0x4e060
movq -0x38(%rbp), %rdi
movslq %eax, %rsi
callq 0xf770
movq -0x30(%rbp), %rdi
movl (%rax), %edx
leaq 0xaf2e(%rip), %rsi      # 0x59077
movb $0x0, %al
callq 0x74c0
jmp 0x4e284
movq -0x18(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
addq $0x48, %rax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
callq 0x4e060
movq -0x48(%rbp), %rdi
movslq %eax, %rsi
callq 0xf7b0
movq -0x40(%rbp), %rdi
movsd (%rax), %xmm0
leaq 0xaef3(%rip), %rsi      # 0x59080
movb $0x1, %al
callq 0x74c0
jmp 0x4e284
movq -0x18(%rbp), %rdi
leaq 0xaee5(%rip), %rsi      # 0x59089
movb $0x0, %al
callq 0x74c0
movq -0x18(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
addq $0x50, %rax
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rdi
callq 0x4e060
movq -0x58(%rbp), %rdi
movslq %eax, %rsi
callq 0xf7f0
movq -0x50(%rbp), %rdi
movq (%rax), %rsi
callq 0x4df80
movq -0x18(%rbp), %rsi
movl $0xa, %edi
callq 0x7400
jmp 0x4e284
movq -0x18(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x8(%rbp), %rax
movzbl (%rax), %eax
movl %eax, %ecx
leaq 0x3c1c5(%rip), %rax     # 0x8a3d0
movq (%rax,%rcx,8), %rax
movq %rax, -0x60(%rbp)
movq -0x8(%rbp), %rdi
callq 0x4e060
movq -0x68(%rbp), %rdi
movq -0x60(%rbp), %rdx
movl %eax, %ecx
leaq 0xae62(%rip), %rsi      # 0x5908f
movb $0x0, %al
callq 0x74c0
jmp 0x4e284
movq -0x8(%rbp), %rax
movzbl (%rax), %eax
cmpq $0x39, %rax
jb 0x4e25e
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rax
movzbl (%rax), %edx
leaq 0xae41(%rip), %rsi      # 0x59096
movb $0x0, %al
callq 0x74c0
jmp 0x4e284
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rax
movzbl (%rax), %eax
movl %eax, %ecx
leaq 0x3c15e(%rip), %rax     # 0x8a3d0
movq (%rax,%rcx,8), %rdx
leaq 0x9e85(%rip), %rsi      # 0x58102
movb $0x0, %al
callq 0x74c0
addq $0x70, %rsp
popq %rbp
retq
nopw (%rax,%rax)