// File: /workspace/github_cpp_makefile_star2_O3/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 0x4330
movl %ebp, 0x230(%r14)
movq $0x0, 0x220(%r14)
movq (%r15), %rsi
movq %rbx, %rdi
movl $0xc, %edx
callq 0x4190
movq (%rbx), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0x20(%rbx,%rax)
je 0xda51
movq 0xf63b(%rip), %rdi      # 0x1cff0
leaq 0x90e7(%rip), %rsi      # 0x16aa3
movl $0x15, %edx
callq 0x4340
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq 0xf61c(%rip), %rdi      # 0x1cff0
callq 0x4340
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x42a0
movsbl %al, %esi
movq %r12, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x41e0
leaq 0x20(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x90a5(%rip), %rsi      # 0x16ab9
leaq 0x90a8(%rip), %rdx      # 0x16ac3
leaq 0x10(%rsp), %rdi
callq 0x6c96
leaq 0xc(%rsp), %rsi
movl $0x4d, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0xcde4
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0xda51
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x42e0
movq %rbx, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x4430
movq %rbx, %rdi
callq 0x4570
movq %rax, 0x228(%r14)
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4430
cmpq $0x0, 0x228(%r14)
jne 0xdb40
movq 0xf560(%rip), %rdi      # 0x1cff0
leaq 0x8f68(%rip), %rsi      # 0x169ff
movl $0x6, %edx
callq 0x4340
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq 0xf541(%rip), %rdi      # 0x1cff0
callq 0x4340
movq %rax, %r15
leaq 0x9006(%rip), %rsi      # 0x16ac4
movl $0x9, %edx
movq %rax, %rdi
callq 0x4340
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x42a0
movsbl %al, %esi
movq %r15, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x41e0
leaq 0x20(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x8fb6(%rip), %rsi      # 0x16ab9
leaq 0x8fb9(%rip), %rdx      # 0x16ac3
leaq 0x10(%rsp), %rdi
callq 0x6c96
leaq 0xc(%rsp), %rsi
movl $0x5a, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0xcde4
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0xdb40
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x42e0
testl %ebp, %ebp
jne 0xdb82
movq 0x228(%r14), %r15
leaq 0x2(%r15), %rdi
callq 0x4030
movq %rax, (%r14)
movq %rbx, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x43c0
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 0xdc7c
jmp 0xdc9c
movq %rax, %r15
cmpl $0x1, %edx
jne 0xdc9f
movq %r15, %rdi
callq 0x4130
movq %rax, %r15
movq 0xf439(%rip), %rdi      # 0x1cff0
leaq 0x8f10(%rip), %rsi      # 0x16ace
movl $0xf, %edx
callq 0x4340
movq (%r15), %rax
movq %r15, %rdi
callq *0x10(%rax)
movq 0xf418(%rip), %rdi      # 0x1cff0
movq %rax, %rsi
callq 0x42b0
movq %rax, %rdi
callq 0x4150
leaq 0x20(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x8ec0(%rip), %rsi      # 0x16ab9
leaq 0x8ec3(%rip), %rdx      # 0x16ac3
leaq 0x10(%rsp), %rdi
callq 0x6c96
leaq 0xc(%rsp), %rsi
movl $0x72, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0xcde4
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0xdc36
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x42e0
callq 0x4510
movq (%r14), %rax
movq 0x228(%r14), %r15
jmp 0xdb57
jmp 0xdc9c
movq %rax, %r15
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0xdc6d
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x42e0
jmp 0xdc6d
jmp 0xdc6a
movq %rax, %r15
callq 0x4510
jmp 0xdc9f
movq %rax, %rdi
callq 0x6bf4
movq %rax, %r15
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0xdc9f
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x42e0
jmp 0xdc9f
jmp 0xdc9c
jmp 0xdc9c
movq %rax, %r15
movq %rbx, %rdi
callq 0x40b0
movq %r15, %rdi
callq 0x4590
nop