// File: /workspace/github_cpp_makefile_star2_O3/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
cmpb $0x1, 0x73333(%rip)     # 0x1a0e31
jne 0x12db28
movq $0x0, (%r12)
movq 0x73329(%rip), %rax     # 0x1a0e38
movq %rax, (%r15)
movl $0x1, (%r14)
movb $0x0, 0x73311(%rip)     # 0x1a0e31
movb $0x1, %bpl
jmp 0x12dd99
movq %rdi, %r13
leaq 0x20(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x8(%rdi), %rbx
movq 0x8(%rdi), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0xb2c0
movsbl %al, %edx
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0xb540
incl 0x732d2(%rip)           # 0x1a0e40
movq (%rbx), %rax
movq -0x18(%rax), %rdi
testb $0x2, 0x20(%rbx,%rdi)
jne 0x12db84
cmpq $0x0, 0x18(%rsp)
jne 0x12dbd9
addq %rbx, %rdi
xorl %esi, %esi
callq 0xb4d0
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xb380
movl $0x0, 0x7329c(%rip)     # 0x1a0e40
cmpq $0x0, (%r13)
je 0x12dd74
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0xb2c0
movsbl %al, %edx
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0xb540
incl 0x73267(%rip)           # 0x1a0e40
movq 0x10(%rsp), %r13
callq 0xb050
movq %rax, %rbx
movl (%rax), %eax
movl %eax, 0xc(%rsp)
movl $0x0, (%rbx)
leaq 0x30(%rsp), %rbp
movq %r13, %rdi
movq %rbp, %rsi
movl $0xa, %edx
callq 0xb120
movq (%rbp), %rdx
subq %r13, %rdx
je 0x12ddaa
movl (%rbx), %ecx
cmpl $0x22, %ecx
je 0x12ddb6
testl %ecx, %ecx
jne 0x12dc29
movl 0xc(%rsp), %ecx
movl %ecx, (%rbx)
movq %rax, (%r12)
incq %rdx
leaq 0x10(%rsp), %r13
movq %r13, %rdi
movl $0x20, %esi
callq 0xb2a0
movq %rax, %r12
leaq 0x30(%rsp), %rdi
movq %r13, %rsi
movq %rax, %rdx
movq $-0x1, %rcx
callq 0xb310
movq 0x30(%rsp), %r13
movl (%rbx), %eax
movl %eax, 0xc(%rsp)
movl $0x0, (%rbx)
leaq 0x50(%rsp), %rbp
movq %r13, %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq 0xb120
movq (%rbp), %rbp
cmpq %r13, %rbp
je 0x12ddc2
movl (%rbx), %ecx
cmpl $0x22, %ecx
je 0x12ddce
testl %ecx, %ecx
jne 0x12dca1
movl 0xc(%rsp), %ecx
movl %ecx, (%rbx)
movq %rax, (%r15)
leaq 0x40(%rsp), %r15
movq -0x10(%r15), %rdi
cmpq %r15, %rdi
je 0x12dcbf
movq 0x40(%rsp), %rsi
incq %rsi
callq 0xb2f0
movl $0x0, (%r14)
subq %r13, %r12
addq %rbp, %r12
leaq 0x10(%rsp), %rdi
movl $0x20, %esi
movq %r12, %rdx
callq 0xb2a0
movb $0x1, %bpl
cmpq $-0x1, %rax
je 0x12dd7d
movq %r15, %r13
movb $0x1, 0x7313c(%rip)     # 0x1a0e31
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq %rax, %rdx
movq $-0x1, %rcx
callq 0xb310
movq 0x30(%rsp), %r14
movl (%rbx), %r12d
movl $0x0, (%rbx)
leaq 0x50(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0xb120
cmpq %r14, (%r15)
je 0x12ddda
movl (%rbx), %ecx
testl %ecx, %ecx
movq %r13, %rdx
je 0x12dd51
cmpl $0x22, %ecx
jne 0x12dd54
leaq 0x2d22e(%rip), %rdi     # 0x15af7a
callq 0xb3d0
movl %r12d, (%rbx)
movq %rax, 0x730dd(%rip)     # 0x1a0e38
movq 0x30(%rsp), %rdi
cmpq %rdx, %rdi
je 0x12dd7d
movq 0x40(%rsp), %rsi
incq %rsi
callq 0xb2f0
jmp 0x12dd7d
movb $0x0, 0x730b6(%rip)     # 0x1a0e31
xorl %ebp, %ebp
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x12dd99
movq 0x20(%rsp), %rsi
incq %rsi
callq 0xb2f0
movl %ebp, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2d1c9(%rip), %rdi     # 0x15af7a
callq 0xb1f0
leaq 0x2d1bd(%rip), %rdi     # 0x15af7a
callq 0xb3d0
leaq 0x2d1b1(%rip), %rdi     # 0x15af7a
callq 0xb1f0
leaq 0x2d1a5(%rip), %rdi     # 0x15af7a
callq 0xb3d0
leaq 0x2d199(%rip), %rdi     # 0x15af7a
callq 0xb1f0
jmp 0x12de3c
movq %rax, %r14
cmpl $0x0, (%rbx)
jne 0x12ddf3
movl %r12d, (%rbx)
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
jne 0x12de1d
jmp 0x12de3f
jmp 0x12de3c
movq %rax, %r14
cmpl $0x0, (%rbx)
jne 0x12de0f
movl 0xc(%rsp), %eax
movl %eax, (%rbx)
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x12de3f
movq 0x40(%rsp), %rsi
incq %rsi
callq 0xb2f0
jmp 0x12de3f
movq %rax, %r14
cmpl $0x0, (%rbx)
jne 0x12de3f
movl 0xc(%rsp), %eax
movl %eax, (%rbx)
jmp 0x12de3f
movq %rax, %r14
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x12de5b
movq 0x20(%rsp), %rsi
incq %rsi
callq 0xb2f0
movq %r14, %rdi
callq 0xb510
nop