// File: /workspace/github_cpp_makefile_star2_O1/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, 0x74145(%rip)     # 0x1a4e31
jne 0x130d16
movq $0x0, (%r12)
movq 0x7413b(%rip), %rax     # 0x1a4e38
movq %rax, (%r15)
movl $0x1, (%r14)
movb $0x0, 0x74123(%rip)     # 0x1a4e31
movb $0x1, %bpl
jmp 0x130f87
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 0x740e4(%rip)           # 0x1a4e40
movq (%rbx), %rax
movq -0x18(%rax), %rdi
testb $0x2, 0x20(%rbx,%rdi)
jne 0x130d72
cmpq $0x0, 0x18(%rsp)
jne 0x130dc7
addq %rbx, %rdi
xorl %esi, %esi
callq 0xb4d0
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xb380
movl $0x0, 0x740ae(%rip)     # 0x1a4e40
cmpq $0x0, (%r13)
je 0x130f62
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 0x74079(%rip)           # 0x1a4e40
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 0x130f98
movl (%rbx), %ecx
cmpl $0x22, %ecx
je 0x130fa4
testl %ecx, %ecx
jne 0x130e17
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 0x130fb0
movl (%rbx), %ecx
cmpl $0x22, %ecx
je 0x130fbc
testl %ecx, %ecx
jne 0x130e8f
movl 0xc(%rsp), %ecx
movl %ecx, (%rbx)
movq %rax, (%r15)
leaq 0x40(%rsp), %r15
movq -0x10(%r15), %rdi
cmpq %r15, %rdi
je 0x130ead
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 0x130f6b
movq %r15, %r13
movb $0x1, 0x73f4e(%rip)     # 0x1a4e31
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 0x130fc8
movl (%rbx), %ecx
testl %ecx, %ecx
movq %r13, %rdx
je 0x130f3f
cmpl $0x22, %ecx
jne 0x130f42
leaq 0x2cfe0(%rip), %rdi     # 0x15df1a
callq 0xb3d0
movl %r12d, (%rbx)
movq %rax, 0x73eef(%rip)     # 0x1a4e38
movq 0x30(%rsp), %rdi
cmpq %rdx, %rdi
je 0x130f6b
movq 0x40(%rsp), %rsi
incq %rsi
callq 0xb2f0
jmp 0x130f6b
movb $0x0, 0x73ec8(%rip)     # 0x1a4e31
xorl %ebp, %ebp
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x130f87
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 0x2cf7b(%rip), %rdi     # 0x15df1a
callq 0xb1f0
leaq 0x2cf6f(%rip), %rdi     # 0x15df1a
callq 0xb3d0
leaq 0x2cf63(%rip), %rdi     # 0x15df1a
callq 0xb1f0
leaq 0x2cf57(%rip), %rdi     # 0x15df1a
callq 0xb3d0
leaq 0x2cf4b(%rip), %rdi     # 0x15df1a
callq 0xb1f0
jmp 0x13102a
movq %rax, %r14
cmpl $0x0, (%rbx)
jne 0x130fe1
movl %r12d, (%rbx)
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
jne 0x13100b
jmp 0x13102d
jmp 0x13102a
movq %rax, %r14
cmpl $0x0, (%rbx)
jne 0x130ffd
movl 0xc(%rsp), %eax
movl %eax, (%rbx)
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x13102d
movq 0x40(%rsp), %rsi
incq %rsi
callq 0xb2f0
jmp 0x13102d
movq %rax, %r14
cmpl $0x0, (%rbx)
jne 0x13102d
movl 0xc(%rsp), %eax
movl %eax, (%rbx)
jmp 0x13102d
movq %rax, %r14
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x131049
movq 0x20(%rsp), %rsi
incq %rsi
callq 0xb2f0
movq %r14, %rdi
callq 0xb510
nop