// File: CMU-SAFARI[P]ramulator/src/Processor.cpp
// Function: ramulator::Trace::get_unfiltered_request(long&, long&, ramulator::Request::Type&)
bool Trace::get_unfiltered_request(long& bubble_cnt, long& req_addr, Request::Type& req_type)
{
    string line;
    getline(file, line);
    if (file.eof()) {
      file.clear();
      file.seekg(0, file.beg);
      getline(file, line);
      //return false;
    }
    size_t pos, end;
    bubble_cnt = std::stoul(line, &pos, 10);
    pos = line.find_first_not_of(' ', pos+1);
    req_addr = std::stoul(line.substr(pos), &end, 0);

    pos = line.find_first_not_of(' ', pos+end);

    if (pos == string::npos || line.substr(pos)[0] == 'R')
        req_type = Request::Type::READ;
    else if (line.substr(pos)[0] == 'W')
        req_type = Request::Type::WRITE;
    else assert(false);
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xd8(%rbp)
leaq -0x40(%rbp), %rdi
movq %rdi, -0xd0(%rbp)
callq 0xc480
movq -0xd8(%rbp), %rdi
movq -0xd0(%rbp), %rsi
addq $0x8, %rdi
callq 0xc0e0
jmp 0x1f996f
movq -0xd8(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x18(%rcx), %rcx
leaq 0x8(%rax,%rcx), %rdi
callq 0xc620
movb %al, -0xd9(%rbp)
jmp 0x1f9990
movb -0xd9(%rbp), %al
testb $0x1, %al
jne 0x1f999c
jmp 0x1f99f8
movq -0xd8(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x18(%rcx), %rcx
leaq 0x8(%rax,%rcx), %rdi
xorl %esi, %esi
callq 0xc580
jmp 0x1f99b9
movq -0xd8(%rbp), %rdi
addq $0x8, %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0xc460
jmp 0x1f99cf
movq -0xd8(%rbp), %rdi
addq $0x8, %rdi
leaq -0x40(%rbp), %rsi
callq 0xc0e0
jmp 0x1f99e5
jmp 0x1f99f8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1f9c4d
leaq -0x40(%rbp), %rdi
leaq -0x58(%rbp), %rsi
movl $0xa, %edx
callq 0x1fb020
movq %rax, -0xe8(%rbp)
jmp 0x1f9a13
movq -0xe8(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x58(%rbp), %rdx
incq %rdx
leaq -0x40(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
movl $0x20, %esi
callq 0xc340
movq -0xf0(%rbp), %rsi
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdx
leaq -0x80(%rbp), %rdi
movq $-0x1, %rcx
callq 0xc380
jmp 0x1f9a5e
leaq -0x80(%rbp), %rdi
leaq -0x60(%rbp), %rsi
xorl %edx, %edx
callq 0x1fb020
movq %rax, -0xf8(%rbp)
jmp 0x1f9a76
movq -0xf8(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
leaq -0x80(%rbp), %rdi
callq 0xc6b8
movq -0x58(%rbp), %rdx
addq -0x60(%rbp), %rdx
leaq -0x40(%rbp), %rdi
movl $0x20, %esi
callq 0xc340
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rcx
movb $0x0, -0xa1(%rbp)
movb $0x1, %al
cmpq $-0x1, %rcx
movb %al, -0xf9(%rbp)
je 0x1f9b13
movq -0x58(%rbp), %rdx
leaq -0xa0(%rbp), %rdi
leaq -0x40(%rbp), %rsi
movq $-0x1, %rcx
callq 0xc380
jmp 0x1f9add
movb $0x1, -0xa1(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0xa0(%rbp), %rdi
callq 0xc690
movq %rax, -0x108(%rbp)
jmp 0x1f9afd
movq -0x108(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x52, %eax
sete %al
movb %al, -0xf9(%rbp)
movb -0xf9(%rbp), %al
movb %al, -0x109(%rbp)
testb $0x1, -0xa1(%rbp)
jne 0x1f9b2a
jmp 0x1f9b36
leaq -0xa0(%rbp), %rdi
callq 0xc6b8
movb -0x109(%rbp), %al
testb $0x1, %al
jne 0x1f9b42
jmp 0x1f9b93
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
jmp 0x1f9c37
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0xc6b8
jmp 0x1f9c4d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
testb $0x1, -0xa1(%rbp)
jne 0x1f9b82
jmp 0x1f9b8e
leaq -0xa0(%rbp), %rdi
callq 0xc6b8
jmp 0x1f9c4d
movq -0x58(%rbp), %rdx
leaq -0xc8(%rbp), %rdi
leaq -0x40(%rbp), %rsi
movq $-0x1, %rcx
callq 0xc380
jmp 0x1f9bb0
xorl %eax, %eax
movl %eax, %esi
leaq -0xc8(%rbp), %rdi
callq 0xc690
movq %rax, -0x118(%rbp)
jmp 0x1f9bc9
movq -0x118(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x11c(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0xc6b8
movl -0x11c(%rbp), %eax
cmpl $0x57, %eax
jne 0x1f9c16
movq -0x20(%rbp), %rax
movl $0x1, (%rax)
jmp 0x1f9c35
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0xc6b8
jmp 0x1f9c4d
leaq 0x55f44(%rip), %rdi     # 0x24fb61
leaq 0x67390(%rip), %rsi     # 0x260fb4
movl $0x196, %edx            # imm = 0x196
leaq 0x67797(%rip), %rcx     # 0x2613c7
callq 0xc280
jmp 0x1f9c37
leaq -0x40(%rbp), %rdi
callq 0xc6b8
movb $0x1, %al
andb $0x1, %al
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
leaq -0x40(%rbp), %rdi
callq 0xc6b8
movq -0x48(%rbp), %rdi
callq 0xc5d0
nop