// File: /workspace/github_cpp_makefile_star2_O2/tap3edit[P]tap3xml/Buffin.cpp
// Function: Buffin::Buffin(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int)
Buffin::Buffin(
    const string filename,  /* Filename to be buffered */
    int mode=0              /* 0=Read complete file, 1=Read bytes on request from file */
) :
    _buffin(NULL),
    _curbuf(NULL)
{
    /* 1. Declarations and definitions */
    _mode=mode;
    _pos=0;


    /* 2. Open file */

    _file_in.open(filename.c_str(), ios::binary | ios::in);

    if (!_file_in.good())
    {
        cerr << "Unable to open file: " << filename << endl;
        err_trace(__FILE__, __LINE__);
    }


    /* 3. Getting file size */

    _file_in.seekg(0, ios_base::end);
    _end=_file_in.tellg();
    _file_in.seekg(0, ios_base::beg);

    if (!_end)
    {
        cerr << "File: " << filename << " is empty" << endl;
        err_trace( __FILE__, __LINE__) ;
    }


    /* 4. Proceed according to mode */

    if (mode)
    {
        /* 4.1. File read on request */
        ;
    } else {

        /* 4.2. File read complete into _buffin */

        {
            /* 4.2.2. Reading the whole file in buffin */

            try
            {
                _buffin=new uchar [_end+2];
            }
            catch(const bad_alloc &ba)
            {
                cerr << "Out of memory: " << ba.what() << endl ;
                err_trace( __FILE__, __LINE__) ;
            }

            _file_in.read((char *)_buffin, _end);

            /* Note: yy_scan_buffer() from flex needs two */
            /*       null bytes at the end of the string  */

            _buffin[_end+0]='\0';
            _buffin[_end+1]='\0';


            /* 4.2.3. File is not needed anymore */

            // _file_in.close();
        }

    }

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x30, %rsp
movl %edx, %ebp
movq %rsi, %r15
movq %rdi, %r14
leaq 0x18(%rdi), %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movq %rbx, %rdi
callq 0x42f0
movl %ebp, 0x230(%r14)
andq $0x0, 0x220(%r14)
movq (%r15), %rsi
pushq $0xc
popq %rdx
movq %rbx, %rdi
callq 0x4190
movq (%rbx), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0x20(%rbx,%rax)
je 0xba26
movq 0xe61e(%rip), %rdi      # 0x19ff0
leaq 0x70ca(%rip), %rsi      # 0x12aa3
callq 0x4290
movq %rax, %rdi
movq %r15, %rsi
callq 0x4250
movq %rax, %rdi
callq 0x4160
leaq 0x70c1(%rip), %rsi      # 0x12ab9
leaq 0x10(%rsp), %rdi
leaq 0xb(%rsp), %rdx
callq 0x5caa
leaq 0xc(%rsp), %rsi
movl $0x4d, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0xb17a
leaq 0x10(%rsp), %rdi
callq 0x4150
pushq $0x2
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x4410
movq %rbx, %rdi
callq 0x4550
movq %rax, 0x228(%r14)
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4410
cmpq $0x0, 0x228(%r14)
jne 0xbac2
movq 0xe591(%rip), %rdi      # 0x19ff0
leaq 0x6f99(%rip), %rsi      # 0x129ff
callq 0x4290
movq %rax, %rdi
movq %r15, %rsi
callq 0x4250
leaq 0x7047(%rip), %rsi      # 0x12ac4
movq %rax, %rdi
callq 0x4290
movq %rax, %rdi
callq 0x4160
leaq 0x7025(%rip), %rsi      # 0x12ab9
leaq 0x10(%rsp), %rdi
leaq 0xb(%rsp), %rdx
callq 0x5caa
leaq 0xc(%rsp), %rsi
movl $0x5a, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0xb17a
leaq 0x10(%rsp), %rdi
callq 0x4150
testl %ebp, %ebp
jne 0xbb04
movq 0x228(%r14), %r15
leaq 0x2(%r15), %rdi
callq 0x4030
movq %rax, (%r14)
movq %rbx, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x4380
movq (%r14), %rax
movq 0x228(%r14), %rcx
xorl %edx, %edx
movb %dl, (%rax,%rcx)
movq (%r14), %rax
movq 0x228(%r14), %rcx
movb %dl, 0x1(%rax,%rcx)
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0xbbd2
jmp 0xbbe5
movq %rax, %r15
cmpl $0x1, %edx
jne 0xbbe8
movq %r15, %rdi
callq 0x4120
movq %rax, %r15
movq 0xe4b7(%rip), %rdi      # 0x19ff0
leaq 0x6f8e(%rip), %rsi      # 0x12ace
callq 0x4290
movq %rax, %r12
movq (%r15), %rax
movq %r15, %rdi
callq *0x10(%rax)
movq %r12, %rdi
movq %rax, %rsi
callq 0x4290
movq %rax, %rdi
callq 0x4160
leaq 0x6f4e(%rip), %rsi      # 0x12ab9
leaq 0x10(%rsp), %rdi
leaq 0xb(%rsp), %rdx
callq 0x5caa
leaq 0xc(%rsp), %rsi
movl $0x72, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0xb17a
leaq 0x10(%rsp), %rdi
callq 0x4150
callq 0x44f0
movq (%r14), %rax
movq 0x228(%r14), %r15
jmp 0xbad9
jmp 0xbbe5
movq %rax, %r15
leaq 0x10(%rsp), %rdi
callq 0x4150
jmp 0xbbc3
jmp 0xbbc0
movq %rax, %r15
callq 0x44f0
jmp 0xbbe8
movq %rax, %rdi
callq 0x5dae
movq %rax, %r15
leaq 0x10(%rsp), %rdi
callq 0x4150
jmp 0xbbe8
jmp 0xbbe5
jmp 0xbbe5
movq %rax, %r15
movq %rbx, %rdi
callq 0x40b0
movq %r15, %rdi
callq 0x4560