// File: /workspace/github_cpp_makefile_star2_O1/tap3edit[P]tap3xml/NrtInfo.cpp
// Function: NrtInfo::buffin(Buffin*)
void NrtInfo::buffin(Buffin *bfin)
{
    string str;
    int pos, bfin_pos, i;

    _bfin=bfin;
    bfin_pos=_bfin->get_pos();
    _bfin->set_pos(0);
    _bfin->read(_bfin->get_end() > 500 ? 500 : _bfin->get_end());

    str=bcd2hexa(_bfin->get_buf());


    /* 1. Find out which kind of file it is */

    pair<string, string> types[] =
    {
        pair<string,string>("",        "ERR"),    /* Not recognized file */
        pair<string,string>("61",      "NRT"),    /* Nrt file */
    };

    for(i=0;i<2;i++)
    {
        if (str.substr(0,types[i].first.size())==types[i].first)
        {
            _type=types[i].second;
        }
    }


    /* 2. Find its version */

    pair<string, int *> version[] =
    {
        pair<string,int *>("5f2901",  &_version),
        pair<string,int *>("5f2501",  &_release)
    };

    for(i=0;i<2;i++)
    {
        if ((pos=str.find(version[i].first)) != (int)string::npos)
        {
            *(version[i].second)=atoi(bcd2dec(hexa2bcd(str.substr(pos+version[i].first.size(),2))).c_str());
        }
        else
        {
            *(version[i].second)=-1;
        }
    }

    if (_version<0 || _release<0)
        _type="ERR";


    _bfin->set_pos(bfin_pos);

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %rdi, %r12
leaq 0x20(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq %rsi, (%rdi)
movq %rsi, %rdi
callq 0xe34a
movq %rax, %rbx
movq (%r12), %rdi
leaq 0x100(%rsp), %rsi
movq $0x0, (%rsi)
callq 0xe352
movq (%r12), %r14
movq %r14, %rdi
callq 0xe48a
movl $0x1f4, %esi            # imm = 0x1F4
cmpq $0x1f4, %rax            # imm = 0x1F4
jg 0x7501
movq (%r12), %rdi
callq 0xe48a
movq %rax, %rsi
movq %r14, %rdi
callq 0xe492
movq (%r12), %rsi
leaq 0x30(%rsp), %rdi
callq 0xe616
leaq 0x100(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xcb12
movq %rbx, 0x98(%rsp)
leaq 0x10(%rsp), %rdi
leaq 0x100(%rsp), %r14
movq %r14, %rsi
callq 0x43a0
movq (%r14), %rdi
leaq 0x110(%rsp), %rax
cmpq %rax, %rdi
je 0x7566
movq 0x110(%rsp), %rsi
incq %rsi
callq 0x42e0
leaq 0x40(%rsp), %rbx
movq -0x10(%rbx), %rdi
cmpq %rbx, %rdi
je 0x7581
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x42e0
leaq 0xf488(%rip), %rsi      # 0x16a10
leaq 0xdbec(%rip), %rdx      # 0x1517b
movq %r14, %r15
movq %r14, %rdi
callq 0x7cf0
leaq 0x140(%rsp), %r15
leaq 0xdce4(%rip), %rsi      # 0x1528d
leaq 0xdce0(%rip), %rdx      # 0x15290
movq %r15, %rdi
callq 0x7d6e
movq %r12, (%rsp)
leaq 0x10(%r12), %rax
movq %rax, 0x8(%rsp)
movl $0x1, %r15d
leaq 0x120(%rsp), %r14
leaq 0x30(%rsp), %r12
leaq 0x10(%rsp), %r13
movq -0x18(%r14), %rcx
movq %r12, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x4300
movq 0x38(%rsp), %rdx
cmpq -0x18(%r14), %rdx
jne 0x7615
testq %rdx, %rdx
je 0x7619
movq -0x20(%r14), %rsi
movq 0x30(%rsp), %rdi
callq 0x42f0
testl %eax, %eax
sete %bpl
jmp 0x761c
xorl %ebp, %ebp
jmp 0x761c
movb $0x1, %bpl
movq 0x30(%rsp), %rdi
cmpq %rbx, %rdi
je 0x7633
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x42e0
testb %bpl, %bpl
je 0x7645
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x4180
addq $0x40, %r14
decq %r15
je 0x75de
leaq 0x30(%rsp), %r12
movq %rbx, (%r12)
leaq 0xdc36(%rip), %rsi      # 0x15294
leaq 0xdc35(%rip), %rdx      # 0x1529a
movq %r12, %rdi
callq 0x6e3c
movq (%rsp), %rbx
leaq 0x8(%rbx), %rax
leaq 0x58(%rsp), %r14
movq %rax, 0x90(%rsp)
movq %rax, -0x8(%r14)
leaq 0x68(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xdc05(%rip), %rsi      # 0x1529b
leaq 0xdc04(%rip), %rdx      # 0x152a1
movq %r14, %rdi
callq 0x6e3c
leaq 0xc(%rbx), %rax
movq %rax, 0x88(%rsp)
movq %rax, 0x78(%rsp)
movl $0x20, %r14d
leaq 0x10(%rsp), %r12
leaq 0xa0(%rsp), %r13
leaq 0xc0(%rsp), %rbp
movq 0x10(%rsp,%r14), %rsi
movq 0x18(%rsp,%r14), %rcx
movq %r12, %rdi
xorl %edx, %edx
callq 0x4580
cmpl $-0x1, %eax
jne 0x76fa
movq 0x30(%rsp,%r14), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
jmp 0x77ae
movslq %eax, %rdx
addq 0x18(%rsp,%r14), %rdx
movl $0x2, %ecx
movq %r13, %rdi
movq %r12, %rsi
callq 0x4300
movq %rbp, %rdi
movq %r13, %rsi
callq 0xcc27
leaq 0xe0(%rsp), %rdi
movq %rbp, %rsi
callq 0xc848
movq 0xe0(%rsp), %rbx
movq %rbx, %rdi
callq 0x44d0
movq 0x30(%rsp,%r14), %rcx
movl %eax, (%rcx)
leaq 0xf0(%rsp), %rax
cmpq %rax, %rbx
je 0x7764
movq 0xf0(%rsp), %rsi
incq %rsi
movq %rbx, %rdi
callq 0x42e0
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0x7789
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x42e0
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x77ae
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x42e0
addq $0x28, %r14
cmpq $0x48, %r14
je 0x76d1
movq 0x90(%rsp), %rax
cmpl $0x0, (%rax)
movq (%rsp), %rbx
js 0x77da
movq 0x88(%rsp), %rax
cmpl $0x0, (%rax)
jns 0x77f7
movq 0x18(%rbx), %rdx
leaq 0xd996(%rip), %rcx      # 0x1517b
movl $0x3, %r8d
movq 0x8(%rsp), %rdi
xorl %esi, %esi
callq 0x44c0
movq (%rbx), %rdi
movslq 0x98(%rsp), %rax
leaq 0xe0(%rsp), %rsi
movq %rax, (%rsi)
callq 0xe352
movq $-0x50, %rbx
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0x782d
movq (%r15), %rsi
incq %rsi
callq 0x42e0
addq $-0x28, %r15
addq $0x28, %rbx
jne 0x7819
movq $-0x80, %rbx
leaq 0x170(%rsp), %r14
movq -0x10(%r14), %rdi
cmpq %rdi, %r14
je 0x785a
movq (%r14), %rsi
incq %rsi
callq 0x42e0
movq -0x30(%r14), %rdi
leaq -0x20(%r14), %rax
cmpq %rdi, %rax
je 0x7872
movq (%rax), %rsi
incq %rsi
callq 0x42e0
addq $-0x40, %r14
addq $0x40, %rbx
jne 0x7846
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x7898
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x42e0
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7955
jmp 0x7955
movq %rax, %rbx
jmp 0x78bf
movq %rax, %rbx
movq %r12, %r14
cmpq %r14, %r12
je 0x79d4
leaq 0x30(%rsp), %r15
movq -0x28(%r14), %rdi
leaq -0x18(%r14), %rax
cmpq %rdi, %rax
je 0x78e5
movq (%rax), %rsi
incq %rsi
callq 0x42e0
addq $-0x28, %r14
cmpq %r15, %r14
jne 0x78cd
jmp 0x79d4
movq %rax, %rbx
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x79f4
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x42e0
jmp 0x79f4
jmp 0x7948
jmp 0x7948
movq %rax, %rbx
cmpq %r15, %r14
je 0x79f4
leaq 0x100(%rsp), %r14
addq $-0x40, %r15
movq %r15, %rdi
callq 0x7dec
cmpq %r14, %r15
jne 0x7932
jmp 0x79f4
movq %rax, %rbx
jmp 0x79f4
movq %rax, %rbx
jmp 0x7982
movq %rax, %rbx
jmp 0x79a7
movq %rax, %rbx
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0x7982
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x42e0
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x79a7
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x42e0
xorl %r14d, %r14d
movq 0x58(%rsp,%r14), %rdi
leaq (%r15,%r14), %rax
cmpq %rdi, %rax
je 0x79c3
movq (%rax), %rsi
incq %rsi
callq 0x42e0
addq $-0x28, %r14
cmpq $-0x50, %r14
jne 0x79aa
jmp 0x79d4
jmp 0x79d1
movq %rax, %rbx
movl $0x40, %r14d
leaq (%rsp,%r14), %rdi
addq $0x100, %rdi            # imm = 0x100
callq 0x7dec
addq $-0x40, %r14
cmpq $-0x40, %r14
jne 0x79da
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x7a10
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x42e0
movq %rbx, %rdi
callq 0x4590