// File: /workspace/github_cpp_makefile_star2_O3/tap3edit[P]tap3xml/TapInfo.cpp
// Function: TapInfo::buffin(Buffin*)
void TapInfo::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",      "TAP"),    /* Tap file */
        pair<string,string>("62",      "TAP"),    /* Notification file */
        pair<string,string>("7f8416",  "RAP"),    /* Rap file */
        pair<string,string>("7f8417",  "ACK")    /* Acknowledgment file */
    };

    for(i=0;i<5;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 *>("5f814901",  &_version),
        pair<string,int *>("5f813d01",  &_release),
        pair<string,int *>("5f842001",  &_suplversion),
        pair<string,int *>("5f841f01",  &_suplrelease)
    };

    if (_type=="ACK" )
    {
        _version=1;
        _release=1;
        _suplversion=3;
        _suplrelease=1;
        _type="RAP";
    }
    else
    {
        for(i=0;i<4;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 (_type=="RAP")
        {
            i=_version;
            _version=_suplversion;
            _suplversion=i;

            i=_release;
            _release=_suplrelease;
            _suplrelease=i;

            if ( _suplversion < 0 )
                _suplversion=3;

            if ( _suplrelease < 0 )
                _suplrelease=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 $0x2a8, %rsp            # imm = 0x2A8
movq %rdi, %r12
leaq 0x30(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq %rsi, (%rdi)
movq %rsi, %rdi
callq 0xe624
movq %rax, %r15
movq (%r12), %rdi
leaq 0x160(%rsp), %rsi
movq $0x0, (%rsi)
callq 0xe62c
movq (%r12), %r14
movq %r14, %rdi
callq 0xe764
movl $0x1f4, %esi            # imm = 0x1F4
cmpq $0x1f4, %rax            # imm = 0x1F4
jg 0x77b5
movq (%r12), %rdi
callq 0xe764
movq %rax, %rsi
movq %r14, %rdi
callq 0xe76c
movq (%r12), %rsi
leaq 0xa0(%rsp), %rdi
callq 0xe8f0
leaq 0x160(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0xd15a
leaq 0x20(%rsp), %rdi
leaq 0x160(%rsp), %rbx
movq %rbx, %rsi
callq 0x43a0
movq (%rbx), %rdi
leaq 0x170(%rsp), %rax
cmpq %rax, %rdi
je 0x7818
movq 0x170(%rsp), %rsi
incq %rsi
callq 0x42e0
leaq 0xb0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7839
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x42e0
movq %r15, 0x10(%rsp)
leaq 0xf28b(%rip), %rsi      # 0x16ad0
leaq 0xd930(%rip), %rdx      # 0x1517c
leaq 0x160(%rsp), %r14
movq %r14, %rdi
callq 0x82c4
leaq 0x1a0(%rsp), %r15
leaq 0xda55(%rip), %rsi      # 0x152c0
leaq 0xd939(%rip), %rdx      # 0x151ab
movq %r15, %rdi
callq 0x8342
leaq 0x1e0(%rsp), %r15
leaq 0xda3a(%rip), %rsi      # 0x152c3
leaq 0xd91b(%rip), %rdx      # 0x151ab
movq %r15, %rdi
callq 0x8342
leaq 0x220(%rsp), %r15
leaq 0xda1f(%rip), %rsi      # 0x152c6
leaq 0xd8f9(%rip), %rdx      # 0x151a7
movq %r15, %rdi
callq 0x83c0
leaq 0x260(%rsp), %r15
leaq 0xda08(%rip), %rsi      # 0x152cd
leaq 0xda08(%rip), %rdx      # 0x152d4
movq %r15, %rdi
callq 0x83c0
movq %r12, 0x18(%rsp)
leaq 0x18(%r12), %rax
movq %rax, 0x8(%rsp)
movl $0x5, %r12d
leaq 0x180(%rsp), %r14
leaq 0xa0(%rsp), %r15
leaq 0x20(%rsp), %rbp
movq -0x18(%r14), %rcx
movq %r15, %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq 0x4300
movq 0xa8(%rsp), %rdx
cmpq -0x18(%r14), %rdx
jne 0x793d
movq 0xa0(%rsp), %r13
testq %rdx, %rdx
je 0x7949
movq -0x20(%r14), %rsi
movq %r13, %rdi
callq 0x42f0
testl %eax, %eax
sete %bl
jmp 0x794b
movq 0xa0(%rsp), %r13
xorl %ebx, %ebx
jmp 0x794b
movb $0x1, %bl
leaq 0xb0(%rsp), %rax
cmpq %rax, %r13
je 0x796b
movq 0xb0(%rsp), %rsi
incq %rsi
movq %r13, %rdi
callq 0x42e0
testb %bl, %bl
je 0x797c
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x4180
addq $0x40, %r14
decq %r12
jne 0x78fe
leaq 0xa0(%rsp), %r14
leaq 0xb0(%rsp), %rax
movq %rax, (%r14)
leaq 0xd935(%rip), %rsi      # 0x152d8
leaq 0xd936(%rip), %rdx      # 0x152e0
movq %r14, %rdi
callq 0x70e2
movq 0x18(%rsp), %rbx
leaq 0x8(%rbx), %r13
leaq 0xc8(%rsp), %r15
movq %r13, -0x8(%r15)
leaq 0xd8(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0xd907(%rip), %rsi      # 0x152e1
leaq 0xd908(%rip), %rdx      # 0x152e9
movq %r15, %rdi
callq 0x70e2
leaq 0x10(%rbx), %rbp
leaq 0xf0(%rsp), %r15
movq %rbp, -0x8(%r15)
leaq 0x100(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0xd8de(%rip), %rsi      # 0x152ea
leaq 0xd8df(%rip), %rdx      # 0x152f2
movq %r15, %rdi
callq 0x70e2
leaq 0xc(%rbx), %rax
leaq 0x118(%rsp), %r15
movq %rax, 0x48(%rsp)
movq %rax, -0x8(%r15)
leaq 0x128(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xd8af(%rip), %rsi      # 0x152f3
leaq 0xd8b0(%rip), %rdx      # 0x152fb
movq %r15, %rdi
callq 0x70e2
leaq 0x14(%rbx), %r14
movq %r14, 0x138(%rsp)
leaq 0xd86e(%rip), %rsi      # 0x152d4
movq 0x8(%rsp), %rdi
callq 0x40d0
testl %eax, %eax
je 0x7bce
movq %r14, 0x40(%rsp)
movq %rbp, 0x50(%rsp)
movq %r13, 0x58(%rsp)
movl $0x20, %r15d
leaq 0x20(%rsp), %r13
leaq 0x60(%rsp), %rbp
leaq 0x80(%rsp), %r14
movq 0x80(%rsp,%r15), %rsi
movq 0x88(%rsp,%r15), %rcx
movq %r13, %rdi
xorl %edx, %edx
callq 0x4580
cmpl $-0x1, %eax
jne 0x7ad1
movq 0xa0(%rsp,%r15), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
jmp 0x7b82
movslq %eax, %rdx
addq 0x88(%rsp,%r15), %rdx
movl $0x2, %ecx
movq %rbp, %rdi
movq %r13, %rsi
callq 0x4300
movq %r14, %rdi
movq %rbp, %rsi
callq 0xd263
leaq 0x140(%rsp), %rdi
movq %r14, %rsi
callq 0xce90
movq 0x140(%rsp), %rbx
movq %rbx, %rdi
callq 0x44d0
movq 0xa0(%rsp,%r15), %rcx
movl %eax, (%rcx)
leaq 0x150(%rsp), %rax
cmpq %rax, %rbx
je 0x7b41
movq 0x150(%rsp), %rsi
incq %rsi
movq %rbx, %rdi
callq 0x42e0
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x7b66
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x42e0
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x7b82
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x42e0
addq $0x28, %r15
cmpq $0xc0, %r15
jne 0x7a9f
leaq 0xd60d(%rip), %rsi      # 0x151a7
movq 0x8(%rsp), %rdi
callq 0x40d0
movq 0x58(%rsp), %rcx
movl (%rcx), %esi
movq 0x50(%rsp), %r8
movl (%r8), %edx
testl %eax, %eax
je 0x7be8
movl %edx, %edi
movl %esi, %eax
movq 0x18(%rsp), %rbx
movq 0x10(%rsp), %r14
leaq 0xd5b0(%rip), %rcx      # 0x1517c
jmp 0x7c2a
movaps 0xd6db(%rip), %xmm0     # 0x152b0
movups %xmm0, (%r13)
leaq 0xd5c6(%rip), %rcx      # 0x151a7
movq 0x10(%rsp), %r14
jmp 0x7c2e
movq 0x48(%rsp), %r9
movl (%r9), %eax
movl %eax, (%rcx)
movl %esi, (%r9)
movq 0x40(%rsp), %r10
movl (%r10), %edi
movl %edi, (%r8)
movl %edx, (%r10)
testl %esi, %esi
movq 0x18(%rsp), %rbx
movq 0x10(%rsp), %r14
leaq 0xd566(%rip), %rcx      # 0x1517c
jns 0x7c1f
movl $0x3, (%r9)
testl %edx, %edx
jns 0x7c2a
movl $0x1, (%r10)
orl %eax, %edi
jns 0x7c44
movq 0x20(%rbx), %rdx
movl $0x3, %r8d
movq 0x8(%rsp), %rdi
xorl %esi, %esi
callq 0x44c0
movq (%rbx), %rdi
movslq %r14d, %rax
leaq 0x140(%rsp), %rsi
movq %rax, (%rsi)
callq 0xe62c
movq $-0xa0, %rbx
movq -0x10(%r12), %rdi
cmpq %rdi, %r12
je 0x7c77
movq (%r12), %rsi
incq %rsi
callq 0x42e0
addq $-0x28, %r12
addq $0x28, %rbx
jne 0x7c61
movq $-0x140, %rbx           # imm = 0xFEC0
leaq 0x290(%rsp), %r14
leaq 0x30(%rsp), %r15
movq -0x10(%r14), %rdi
cmpq %rdi, %r14
je 0x7ca9
movq (%r14), %rsi
incq %rsi
callq 0x42e0
movq -0x30(%r14), %rdi
leaq -0x20(%r14), %rax
cmpq %rdi, %rax
je 0x7cc1
movq (%rax), %rsi
incq %rsi
callq 0x42e0
addq $-0x40, %r14
addq $0x40, %rbx
jne 0x7c95
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
je 0x7ce2
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x42e0
addq $0x2a8, %rsp            # imm = 0x2A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7d89
jmp 0x7d89
jmp 0x7d02
jmp 0x7d02
movq %rax, %rbx
movq -0x28(%r15), %rdi
leaq -0x18(%r15), %rax
cmpq %rdi, %rax
je 0x7d1d
movq (%rax), %rsi
incq %rsi
callq 0x42e0
addq $-0x28, %r15
cmpq %r14, %r15
jne 0x7d05
jmp 0x7e05
jmp 0x7e02
jmp 0x7d63
movq %rax, %rbx
leaq 0xb0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7e25
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x42e0
jmp 0x7e25
jmp 0x7d63
jmp 0x7d63
movq %rax, %rbx
jmp 0x7e25
movq %rax, %rbx
addq $-0x40, %r15
movq %r15, %rdi
callq 0x843e
cmpq %r14, %r15
jne 0x7d6e
jmp 0x7e25
movq %rax, %rbx
jmp 0x7db6
movq %rax, %rbx
jmp 0x7dd2
movq %rax, %rbx
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x7db6
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x42e0
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x7dd2
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x42e0
xorl %r14d, %r14d
movq 0x118(%rsp,%r14), %rdi
leaq (%r12,%r14), %rax
cmpq %rdi, %rax
je 0x7df1
movq (%rax), %rsi
incq %rsi
callq 0x42e0
addq $-0x28, %r14
cmpq $-0xa0, %r14
jne 0x7dd5
jmp 0x7e05
jmp 0x7e02
movq %rax, %rbx
movl $0x100, %r14d           # imm = 0x100
leaq (%rsp,%r14), %rdi
addq $0x160, %rdi            # imm = 0x160
callq 0x843e
addq $-0x40, %r14
cmpq $-0x40, %r14
jne 0x7e0b
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x7e41
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x42e0
movq %rbx, %rdi
callq 0x4590
nop