// File: Eronana[P]strawberry/src/disassembler.cpp
// Function: disassemble(_IO_FILE*, _IO_FILE*)
bool disassemble(FILE *in,FILE *out)
{
    CodeData code_data;
    if(!code_data.load(in))return false;
    fprintf(out,"; ======[   int table  ]======\n");
    for(int i=0;i<code_data.config.int_table_size;i++)fprintf(out,"; %3d | %d\n",i,code_data.int_table[i]);
    fprintf(out,"; ======[  float table ]======\n");
    for(int i=0;i<code_data.config.float_table_size;i++)fprintf(out,"; %3d | %f\n",i,code_data.float_table[i]);
    fprintf(out,"; ======[ string table ]======\n");
    for(int i=0;i<code_data.config.string_table_size;i++)fprintf(out,"; %3d | %s\n",i,code_data.string_table[i]);
    fprintf(out,"; ======[     code     ]======\n");
    for(int i=0;i<code_data.config.code_raw_size;i+=op_length[code_data.code_raw[i]])
    {
        discode(code_data.code_raw[i],code_data,out);
    }
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
leaq -0x80(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
callq 0xfd80
movq -0xb0(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x51010
movb %al, -0xa1(%rbp)
jmp 0x4dc7b
movb -0xa1(%rbp), %al
testb $0x1, %al
jne 0x4dcba
jmp 0x4dc87
movb $0x0, -0x1(%rbp)
movl $0x1, -0x90(%rbp)
jmp 0x4df05
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x9780
jmp 0x4df1c
movq -0x18(%rbp), %rdi
leaq 0xb3ea(%rip), %rsi      # 0x590af
movb $0x0, %al
callq 0x74c0
movl $0x0, -0x94(%rbp)
movslq -0x94(%rbp), %rax
cmpq -0x78(%rbp), %rax
jae 0x4dd44
movq -0x18(%rbp), %rax
movq %rax, -0xc8(%rbp)
movl -0x94(%rbp), %eax
movl %eax, -0xbc(%rbp)
leaq -0x40(%rbp), %rdi
movslq %eax, %rsi
callq 0xf770
movq %rax, -0xb8(%rbp)
jmp 0x4dd0f
movl -0xbc(%rbp), %edx
movq -0xc8(%rbp), %rdi
movq -0xb8(%rbp), %rax
movl (%rax), %ecx
leaq 0xb3a3(%rip), %rsi      # 0x590cf
movb $0x0, %al
callq 0x74c0
movl -0x94(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x94(%rbp)
jmp 0x4dcd6
movq -0x18(%rbp), %rdi
leaq 0xb38c(%rip), %rsi      # 0x590db
movb $0x0, %al
callq 0x74c0
movl $0x0, -0x98(%rbp)
movslq -0x98(%rbp), %rax
cmpq -0x70(%rbp), %rax
jae 0x4ddd0
movq -0x18(%rbp), %rax
movq %rax, -0xe0(%rbp)
movl -0x98(%rbp), %eax
movl %eax, -0xd4(%rbp)
leaq -0x38(%rbp), %rdi
movslq %eax, %rsi
callq 0xf7b0
movq %rax, -0xd0(%rbp)
jmp 0x4dd99
movl -0xd4(%rbp), %edx
movq -0xe0(%rbp), %rdi
movq -0xd0(%rbp), %rax
movsd (%rax), %xmm0
leaq 0xb343(%rip), %rsi      # 0x590fb
movb $0x1, %al
callq 0x74c0
movl -0x98(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x98(%rbp)
jmp 0x4dd60
movq -0x18(%rbp), %rdi
leaq 0xb32c(%rip), %rsi      # 0x59107
movb $0x0, %al
callq 0x74c0
movl $0x0, -0x9c(%rbp)
movslq -0x9c(%rbp), %rax
cmpq -0x68(%rbp), %rax
jae 0x4de5b
movq -0x18(%rbp), %rax
movq %rax, -0xf8(%rbp)
movl -0x9c(%rbp), %eax
movl %eax, -0xec(%rbp)
leaq -0x30(%rbp), %rdi
movslq %eax, %rsi
callq 0xf7f0
movq %rax, -0xe8(%rbp)
jmp 0x4de25
movl -0xec(%rbp), %edx
movq -0xf8(%rbp), %rdi
movq -0xe8(%rbp), %rax
movq (%rax), %rcx
leaq 0xb2e4(%rip), %rsi      # 0x59127
movb $0x0, %al
callq 0x74c0
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0x4ddec
movq -0x18(%rbp), %rdi
leaq 0xb2cd(%rip), %rsi      # 0x59133
movb $0x0, %al
callq 0x74c0
movl $0x0, -0xa0(%rbp)
movslq -0xa0(%rbp), %rax
cmpq -0x58(%rbp), %rax
jae 0x4def7
leaq -0x20(%rbp), %rdi
movslq -0xa0(%rbp), %rsi
callq 0xf660
movq %rax, -0x100(%rbp)
jmp 0x4de9d
movq -0x100(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq -0x80(%rbp), %rsi
callq 0x4e080
jmp 0x4deb3
jmp 0x4deb5
leaq -0x20(%rbp), %rdi
movslq -0xa0(%rbp), %rsi
callq 0xf660
movq %rax, -0x108(%rbp)
jmp 0x4dece
movq -0x108(%rbp), %rax
movzbl (%rax), %eax
movl %eax, %ecx
leaq 0xad1f(%rip), %rax      # 0x58c00
movq (%rax,%rcx,8), %rcx
movslq -0xa0(%rbp), %rax
addq %rcx, %rax
movl %eax, -0xa0(%rbp)
jmp 0x4de77
movb $0x1, -0x1(%rbp)
movl $0x1, -0x90(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x9780
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
movq -0x88(%rbp), %rdi
callq 0x75e0
nopl (%rax,%rax)