// File: /workspace/github_cpp_makefile_star2_O2/CMU-SAFARI[P]ramulator/src/Processor.cpp
// Function: ramulator::Trace::get_filtered_request(long&, long&, ramulator::Request::Type&)
bool Trace::get_filtered_request(long& bubble_cnt, long& req_addr, Request::Type& req_type)
{
    static bool has_write = false;
    static long write_addr;
    static int line_num = 0;
    if (has_write){
        bubble_cnt = 0;
        req_addr = write_addr;
        req_type = Request::Type::WRITE;
        has_write = false;
        return true;
    }
    string line;
    getline(file, line);
    line_num ++;
    if (file.eof() || line.size() == 0) {
        file.clear();
        file.seekg(0, file.beg);
        line_num = 0;

        if(expected_limit_insts == 0) {
            has_write = false;
            return false;
        }
        else { // starting over the input trace file
            getline(file, line);
            line_num++;
        }
    }

    size_t pos, end;
    bubble_cnt = std::stoul(line, &pos, 10);

    pos = line.find_first_not_of(' ', pos+1);
    req_addr = stoul(line.substr(pos), &end, 0);
    req_type = Request::Type::READ;

    pos = line.find_first_not_of(' ', pos+end);
    if (pos != string::npos){
        has_write = true;
        write_addr = stoul(line.substr(pos), NULL, 0);
    }
    return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x50, %rsp
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r15
cmpb $0x1, 0x7bea4(%rip)     # 0x136e31
jne 0xbafb1
andq $0x0, (%r15)
movq 0x7be9e(%rip), %rax     # 0x136e38
movq %rax, (%r14)
movl $0x1, (%rbx)
movb $0x0, 0x7be87(%rip)     # 0x136e31
movb $0x1, %bl
jmp 0xbb0f8
movq %rdi, %r12
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x8(%rdi), %r13
leaq 0x8(%rsp), %rsi
movq %r13, %rdi
callq 0xb0b0
incl 0x7be64(%rip)           # 0x136e40
movq (%r13), %rax
movq -0x18(%rax), %rdi
testb $0x2, 0x20(%r13,%rdi)
jne 0xbaff4
cmpq $0x0, 0x10(%rsp)
jne 0xbb02f
addq %r13, %rdi
xorl %esi, %esi
callq 0xb4a0
movq %r13, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xb360
andl $0x0, 0x7be2f(%rip)     # 0x136e40
cmpq $0x0, (%r12)
je 0xbb108
leaq 0x8(%rsp), %rsi
movq %r13, %rdi
callq 0xb0b0
incl 0x7be11(%rip)           # 0x136e40
leaq 0x8(%rsp), %rdi
movq %rsp, %rsi
pushq $0xa
popq %rdx
callq 0xbbb4b
movq %rax, (%r15)
movq (%rsp), %rdx
incq %rdx
leaq 0x8(%rsp), %r15
pushq $0x20
popq %rsi
movq %r15, %rdi
callq 0xb2a0
movq %rax, (%rsp)
leaq 0x28(%rsp), %rdi
pushq $-0x1
popq %rcx
movq %r15, %rsi
movq %rax, %rdx
callq 0xb2f0
leaq 0x28(%rsp), %rdi
leaq 0x48(%rsp), %rsi
xorl %edx, %edx
callq 0xbbb4b
movq %rax, (%r14)
leaq 0x28(%rsp), %rdi
callq 0xb568
andl $0x0, (%rbx)
movq 0x48(%rsp), %rdx
addq (%rsp), %rdx
leaq 0x8(%rsp), %rdi
pushq $0x20
popq %rsi
callq 0xb2a0
movq %rax, (%rsp)
cmpq $-0x1, %rax
je 0xbb0ec
movb $0x1, 0x7bd79(%rip)     # 0x136e31
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
pushq $-0x1
popq %rcx
movq %rax, %rdx
callq 0xb2f0
leaq 0x28(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xbbb4b
movq %rax, 0x7bd56(%rip)     # 0x136e38
leaq 0x28(%rsp), %rdi
callq 0xb568
movb $0x1, %bl
leaq 0x8(%rsp), %rdi
callq 0xb568
movl %ebx, %eax
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movb $0x0, 0x7bd22(%rip)     # 0x136e31
xorl %ebx, %ebx
jmp 0xbb0ee
jmp 0xbb117
jmp 0xbb12a
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0xb568
jmp 0xbb12d
jmp 0xbb12a
jmp 0xbb12a
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0xb568
movq %rbx, %rdi
callq 0xb4d0
nop