// File: Eronana[P]strawberry/src/codedata.cpp
// Function: CodeData::load(_IO_FILE*)
bool CodeData::load(FILE *fp)
{
    fread(&config,sizeof(config),1,fp);
    if(config.magic!=HEADER_MAGIC)return false;
    int_table=unique_ptr<int[]>(new int[config.int_table_size]);
    float_table=unique_ptr<double[]>(new double[config.float_table_size]);
    string_table=unique_ptr<char*[]>(new char*[config.string_table_size]);
    string_raw=unique_ptr<char[]>(new char[config.string_raw_size]);
    code_raw=unique_ptr<CODE[]>(new CODE[config.code_raw_size]);
    

    fread(int_table.get(),sizeof(int),config.int_table_size,fp);
    fread(float_table.get(),sizeof(double),config.float_table_size,fp);
    fread(string_raw.get(),1,config.string_raw_size,fp);
    fread(code_raw.get(),sizeof(CODE),config.code_raw_size,fp);
    
    char *buffer=string_raw.get();
    string_table[0]=buffer;
    for(int i=1;i<config.string_table_size;i++)
    {
        while(*buffer++);
        string_table[i]=buffer;
    }
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x58(%rbp)
movq -0x18(%rbp), %rcx
movl $0x40, %esi
movl $0x1, %edx
callq 0x74e0
movq -0x58(%rbp), %rax
cmpl $0x414e5245, (%rax)     # imm = 0x414E5245
je 0x51050
movb $0x0, -0x1(%rbp)
jmp 0x512c8
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x7030
movq %rax, %rsi
leaq -0x20(%rbp), %rdi
callq 0x51590
movq -0x58(%rbp), %rdi
addq $0x40, %rdi
leaq -0x20(%rbp), %rsi
callq 0x515c0
leaq -0x20(%rbp), %rdi
callq 0xa3c0
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x7030
movq %rax, %rsi
leaq -0x28(%rbp), %rdi
callq 0x515f0
movq -0x58(%rbp), %rdi
addq $0x48, %rdi
leaq -0x28(%rbp), %rsi
callq 0x51620
leaq -0x28(%rbp), %rdi
callq 0xa350
movq -0x58(%rbp), %rax
movq 0x18(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x7030
movq %rax, %rsi
leaq -0x30(%rbp), %rdi
callq 0x51650
movq -0x58(%rbp), %rdi
addq $0x50, %rdi
leaq -0x30(%rbp), %rsi
callq 0x51680
leaq -0x30(%rbp), %rdi
callq 0xa2e0
movq -0x58(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x7030
movq %rax, %rsi
leaq -0x38(%rbp), %rdi
callq 0x516b0
movq -0x58(%rbp), %rdi
addq $0x58, %rdi
leaq -0x38(%rbp), %rsi
callq 0x516e0
leaq -0x38(%rbp), %rdi
callq 0xa270
movq -0x58(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x7030
movq %rax, %rsi
leaq -0x40(%rbp), %rdi
callq 0x51710
movq -0x58(%rbp), %rdi
addq $0x60, %rdi
leaq -0x40(%rbp), %rsi
callq 0x51740
leaq -0x40(%rbp), %rdi
callq 0xa200
movq -0x58(%rbp), %rdi
addq $0x40, %rdi
callq 0x112c0
movq %rax, %rdi
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rdx
movq -0x18(%rbp), %rcx
movl $0x4, %esi
callq 0x74e0
movq -0x58(%rbp), %rdi
addq $0x48, %rdi
callq 0x11380
movq %rax, %rdi
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rdx
movq -0x18(%rbp), %rcx
movl $0x8, %esi
callq 0x74e0
movq -0x58(%rbp), %rdi
addq $0x58, %rdi
callq 0x51770
movq %rax, %rdi
movq -0x58(%rbp), %rax
movq 0x20(%rax), %rdx
movq -0x18(%rbp), %rcx
movl $0x1, %esi
callq 0x74e0
movq -0x58(%rbp), %rdi
addq $0x60, %rdi
callq 0x106d0
movq %rax, %rdi
movq -0x58(%rbp), %rax
movq 0x28(%rax), %rdx
movq -0x18(%rbp), %rcx
movl $0x1, %esi
callq 0x74e0
movq -0x58(%rbp), %rdi
addq $0x58, %rdi
callq 0x51770
movq -0x58(%rbp), %rdi
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x60(%rbp)
addq $0x50, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xf7f0
movq -0x60(%rbp), %rcx
movq %rcx, (%rax)
movl $0x1, -0x4c(%rbp)
movq -0x58(%rbp), %rcx
movslq -0x4c(%rbp), %rax
cmpq 0x18(%rcx), %rax
jae 0x512c4
jmp 0x51283
movq -0x48(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x48(%rbp)
cmpb $0x0, (%rax)
je 0x51299
jmp 0x51283
movq -0x58(%rbp), %rdi
movq -0x48(%rbp), %rax
movq %rax, -0x68(%rbp)
addq $0x50, %rdi
movslq -0x4c(%rbp), %rsi
callq 0xf7f0
movq -0x68(%rbp), %rcx
movq %rcx, (%rax)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x51273
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)