// File: /workspace/github_cpp_makefile_star2_O1/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 0xe0f1
movq 0xef9b(%rip), %rdi      # 0x1cff0
leaq 0x8a47(%rip), %rsi      # 0x16aa3
movl $0x15, %edx
callq 0x4340
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq 0xef7c(%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 0x8a05(%rip), %rsi      # 0x16ab9
leaq 0x8a08(%rip), %rdx      # 0x16ac3
leaq 0x10(%rsp), %rdi
callq 0x6e3c
leaq 0xc(%rsp), %rsi
movl $0x4d, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0xd138
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0xe0f1
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 0xe1e0
movq 0xeec0(%rip), %rdi      # 0x1cff0
leaq 0x88c8(%rip), %rsi      # 0x169ff
movl $0x6, %edx
callq 0x4340
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq 0xeea1(%rip), %rdi      # 0x1cff0
callq 0x4340
movq %rax, %r15
leaq 0x8966(%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 0x8916(%rip), %rsi      # 0x16ab9
leaq 0x8919(%rip), %rdx      # 0x16ac3
leaq 0x10(%rsp), %rdi
callq 0x6e3c
leaq 0xc(%rsp), %rsi
movl $0x5a, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0xd138
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0xe1e0
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x42e0
testl %ebp, %ebp
jne 0xe226
movq 0x228(%r14), %rdi
addq $0x2, %rdi
callq 0x4030
movq %rax, (%r14)
movq (%r14), %rsi
movq 0x228(%r14), %rdx
movq %rbx, %rdi
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 0xe316
jmp 0xe336
movq %rax, %r15
cmpl $0x1, %edx
jne 0xe339
movq %r15, %rdi
callq 0x4130
movq %rax, %r15
movq 0xed95(%rip), %rdi      # 0x1cff0
leaq 0x886c(%rip), %rsi      # 0x16ace
movl $0xf, %edx
callq 0x4340
movq (%r15), %rax
movq %r15, %rdi
callq *0x10(%rax)
movq 0xed74(%rip), %rdi      # 0x1cff0
movq %rax, %rsi
callq 0x42b0
movq %rax, %rdi
callq 0x4150
leaq 0x20(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x881c(%rip), %rsi      # 0x16ab9
leaq 0x881f(%rip), %rdx      # 0x16ac3
leaq 0x10(%rsp), %rdi
callq 0x6e3c
leaq 0xc(%rsp), %rsi
movl $0x72, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0xd138
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0xe2da
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x42e0
callq 0x4510
jmp 0xe1f7
jmp 0xe336
movq %rax, %r15
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0xe307
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x42e0
jmp 0xe307
jmp 0xe304
movq %rax, %r15
callq 0x4510
jmp 0xe339
movq %rax, %rdi
callq 0x6da0
movq %rax, %r15
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0xe339
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x42e0
jmp 0xe339
jmp 0xe336
jmp 0xe336
movq %rax, %r15
movq %rbx, %rdi
callq 0x40b0
movq %r15, %rdi
callq 0x4590
nop