// File: Eronana[P]strawberry/src/codedata.cpp
// Function: write_code_data(char const*, int, std::vector<int, std::allocator<int>>, std::vector<double, std::allocator<double>>, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>, std::vector<unsigned char, std::allocator<unsigned char>>)
bool write_code_data(const char *filename,int entry_point,vector<int> int_table_list,vector<FLOAT_TYPE> float_table_list,vector<string> string_table_list,vector<CODE> code)
{
    FILE *fp=fopen(filename,"wb");
    if(!fp)return false;
    CodeConfig config;
    config.magic=HEADER_MAGIC;
    config.int_table_size=int_table_list.size();
    config.float_table_size=float_table_list.size();
    config.string_table_size=string_table_list.size();
    config.string_raw_size=0;
    config.entry_point=entry_point;
    config.code_raw_size=code.size();
    for(int i=0;i<string_table_list.size();i++)config.string_raw_size+=string_table_list[i].length()+1;
    fwrite(&config,sizeof(config),1,fp);

    // int table
    fwrite(&int_table_list[0],sizeof(int_table_list[0]),int_table_list.size(),fp);
    // float table
    fwrite(&float_table_list[0],sizeof(float_table_list[0]),float_table_list.size(),fp);
    //string table
    for(int i=0;i<string_table_list.size();i++)
    {
        string &s=string_table_list[i];
        fwrite(s.c_str(),1,s.length()+1,fp);
    }
    //code
    fwrite(&code[0],sizeof(code[0]),code.size(),fp);
    fclose(fp);
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdx, -0xb0(%rbp)
movq %rcx, -0xa8(%rbp)
movq %r8, -0xa0(%rbp)
movq %r9, -0x98(%rbp)
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x82a5(%rip), %rsi      # 0x595ce
callq 0x73b0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x51342
movb $0x0, -0x1(%rbp)
jmp 0x51575
movq -0xb0(%rbp), %rdi
movl $0x414e5245, -0x80(%rbp) # imm = 0x414E5245
callq 0x47eb0
movq -0xa8(%rbp), %rdi
movq %rax, -0x78(%rbp)
callq 0x49610
movq -0xa0(%rbp), %rdi
movq %rax, -0x70(%rbp)
callq 0x49dc0
movq -0x98(%rbp), %rdi
movq %rax, -0x68(%rbp)
movq $0x0, -0x60(%rbp)
movslq -0x14(%rbp), %rax
movq %rax, -0x48(%rbp)
callq 0x44880
movq %rax, -0x58(%rbp)
movl $0x0, -0x84(%rbp)
movq -0xa0(%rbp), %rdi
movslq -0x84(%rbp), %rax
movq %rax, -0xb8(%rbp)
callq 0x49dc0
movq %rax, %rcx
movq -0xb8(%rbp), %rax
cmpq %rcx, %rax
jae 0x51404
movq -0xa0(%rbp), %rdi
movslq -0x84(%rbp), %rsi
callq 0x517a0
movq %rax, %rdi
callq 0x74f0
addq $0x1, %rax
addq -0x60(%rbp), %rax
movq %rax, -0x60(%rbp)
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0x513a3
movq -0x40(%rbp), %rcx
leaq -0x80(%rbp), %rdi
movl $0x40, %esi
movl $0x1, %edx
callq 0x7640
movq -0xb0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x517c0
movq -0xb0(%rbp), %rdi
movq %rax, -0xc8(%rbp)
callq 0x47eb0
movq -0xc8(%rbp), %rdi
movq %rax, %rdx
movq -0x40(%rbp), %rcx
movl $0x4, %esi
callq 0x7640
movq -0xa8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x517e0
movq -0xa8(%rbp), %rdi
movq %rax, -0xc0(%rbp)
callq 0x49610
movq -0xc0(%rbp), %rdi
movq %rax, %rdx
movq -0x40(%rbp), %rcx
movl $0x8, %esi
callq 0x7640
movl $0x0, -0x88(%rbp)
movq -0xa0(%rbp), %rdi
movslq -0x88(%rbp), %rax
movq %rax, -0xd0(%rbp)
callq 0x49dc0
movq %rax, %rcx
movq -0xd0(%rbp), %rax
cmpq %rcx, %rax
jae 0x5152d
movq -0xa0(%rbp), %rdi
movslq -0x88(%rbp), %rsi
callq 0x517a0
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rdi
callq 0x7120
movq %rax, -0xd8(%rbp)
movq -0x90(%rbp), %rdi
callq 0x74f0
movq -0xd8(%rbp), %rdi
movq %rax, %rdx
addq $0x1, %rdx
movq -0x40(%rbp), %rcx
movl $0x1, %esi
callq 0x7640
movl -0x88(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x88(%rbp)
jmp 0x5149b
movq -0x98(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x44930
movq -0x98(%rbp), %rdi
movq %rax, -0xe0(%rbp)
callq 0x44880
movq -0xe0(%rbp), %rdi
movq %rax, %rdx
movq -0x40(%rbp), %rcx
movl $0x1, %esi
callq 0x7640
movq -0x40(%rbp), %rdi
callq 0x72b0
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xe0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)