// File: /workspace/github_cpp_makefile_star2_O2/CMU-SAFARI[P]SMLA/src/Processor.cpp
// Function: ramulator::Core::tick()
void Core::tick()
{
    clk++;

    retired += window.retire();

    if (expected_limit_insts == 0 && !more_reqs) return;

    // bubbles (non-memory operations)
    int inserted = 0;
    while (bubble_cnt > 0) {
        if (inserted == window.ipc) return;
        if (window.is_full()) return;

        window.insert(true, -1);
        inserted++;
        bubble_cnt--;
        cpu_inst++;
        if (long(cpu_inst.value()) == expected_limit_insts && !reached_limit) {
          record_cycs = clk;
          record_insts = long(cpu_inst.value());
          memory.record_core(id);
          reached_limit = true;
        }
    }

    if (req_type == Request::Type::READ) {
        // read request
        if (inserted == window.ipc) return;
        if (window.is_full()) return;

        Request req(req_addr, req_type, callback, id);
        if (!send(req)) return;

        window.insert(false, req_addr);
        cpu_inst++;
    }
    else {
        // write request
        assert(req_type == Request::Type::WRITE);
        Request req(req_addr, req_type, callback, id);
        if (!send(req)) return;
        cpu_inst++;
    }
    if (long(cpu_inst.value()) == expected_limit_insts && !reached_limit) {
      record_cycs = clk;
      record_insts = long(cpu_inst.value());
      memory.record_core(id);
      reached_limit = true;
    }

    if (no_core_caches) {
      more_reqs = trace.get_filtered_request(
          bubble_cnt, req_addr, req_type);
      if (req_addr != -1) {
        req_addr = memory.page_allocator(req_addr, id);
      }
    } else {
      more_reqs = trace.get_unfiltered_request(
          bubble_cnt, req_addr, req_type);
      if (req_addr != -1) {
        req_addr = memory.page_allocator(req_addr, id);
      }
    }
    if (!more_reqs) {
      if (!reached_limit) { // if the length of this trace is shorter than expected length, then record it when the whole trace finishes, and set reached_limit to true.
        record_cycs = clk;
        record_insts = long(cpu_inst.value());
        memory.record_core(id);
        reached_limit = true;
      }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
movq %rdi, %rbx
incq (%rdi)
leaq 0x408(%rdi), %r15
movq %r15, %rdi
callq 0x29a62
addq %rax, 0x8(%rbx)
cmpq $0x0, 0x1d0(%rbx)
jne 0x28983
cmpb $0x1, 0x474(%rbx)
jne 0x28c84
leaq 0x460(%rbx), %r14
xorl %r13d, %r13d
pushq $0x1
popq %rbp
pushq $-0x1
popq %r12
cmpq $0x0, (%r14)
jle 0x28a35
cmpl (%r15), %r13d
je 0x28c84
movl 0x410(%rbx), %eax
cmpl 0x40c(%rbx), %eax
je 0x28c84
movq %r15, %rdi
movl %ebp, %esi
movq %r12, %rdx
callq 0x29ae8
decq 0x460(%rbx)
movsd 0x588(%rbx), %xmm0
addsd 0xb67b(%rip), %xmm0     # 0x34058
movsd %xmm0, 0x588(%rbx)
cvttsd2si %xmm0, %rax
cmpq %rax, 0x1d0(%rbx)
jne 0x28a2d
cmpb $0x0, 0x1d8(%rbx)
jne 0x28a2d
cvtsi2sdq (%rbx), %xmm0
movsd %xmm0, 0x110(%rbx)
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x1a8(%rbx)
movq 0x5b0(%rbx), %rdi
movl 0x10(%rbx), %esi
movq (%rdi), %rax
callq *0x40(%rax)
movb $0x1, 0x1d8(%rbx)
incl %r13d
jmp 0x28994
movl 0x470(%rbx), %eax
cmpl $0x1, %eax
je 0x28af3
testl %eax, %eax
jne 0x28c96
cmpl %r13d, (%r15)
je 0x28c84
movl 0x410(%rbx), %eax
cmpl 0x40c(%rbx), %eax
je 0x28c84
movq 0x468(%rbx), %r12
leaq 0x38(%rbx), %rsi
leaq 0x88(%rsp), %r13
movq %r13, %rdi
callq 0x1237e
movl 0x10(%rbx), %r8d
leaq 0x8(%rsp), %rdi
movq %r12, %rsi
xorl %edx, %edx
movq %r13, %rcx
callq 0x1456c
leaq 0x88(%rsp), %rdi
callq 0x2564a
leaq 0x108(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x12452
leaq 0x18(%rbx), %rdi
leaq 0x108(%rsp), %rsi
callq 0x26de0
movl %eax, %ebp
leaq 0x108(%rsp), %rdi
callq 0x10010
testb %bpl, %bpl
je 0x28bfa
movq 0x468(%rbx), %rdx
movq %r15, %rdi
xorl %esi, %esi
callq 0x29ae8
jmp 0x28b67
movq 0x468(%rbx), %r15
leaq 0x38(%rbx), %rsi
leaq 0x68(%rsp), %r12
movq %r12, %rdi
callq 0x1237e
movl 0x10(%rbx), %r8d
leaq 0x8(%rsp), %rdi
pushq $0x1
popq %rdx
movq %r15, %rsi
movq %r12, %rcx
callq 0x1456c
leaq 0x68(%rsp), %rdi
callq 0x2564a
leaq 0xa8(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x12452
leaq 0x18(%rbx), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x26de0
movl %eax, %ebp
leaq 0xa8(%rsp), %rdi
callq 0x10010
testb %bpl, %bpl
je 0x28bfa
movsd 0x588(%rbx), %xmm0
addsd 0xb4e1(%rip), %xmm0     # 0x34058
movsd %xmm0, 0x588(%rbx)
leaq 0x8(%rsp), %rdi
callq 0x10010
cvttsd2si 0x588(%rbx), %rax
cmpq %rax, 0x1d0(%rbx)
jne 0x28bd5
cmpb $0x0, 0x1d8(%rbx)
jne 0x28bd5
cvtsi2sdq (%rbx), %xmm0
movsd %xmm0, 0x110(%rbx)
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x1a8(%rbx)
movq 0x5b0(%rbx), %rdi
movl 0x10(%rbx), %esi
movq (%rdi), %rax
callq *0x40(%rax)
movb $0x1, 0x1d8(%rbx)
leaq 0x470(%rbx), %rcx
leaq 0x1e0(%rbx), %rdi
leaq 0x468(%rbx), %rdx
cmpb $0x1, 0x58(%rbx)
jne 0x28c06
movq %r14, %rsi
callq 0x29700
jmp 0x28c0e
leaq 0x8(%rsp), %rdi
callq 0x10010
jmp 0x28c84
movq %r14, %rsi
callq 0x298b4
movb %al, 0x474(%rbx)
movq 0x468(%rbx), %rsi
cmpq $-0x1, %rsi
je 0x28c38
movq 0x5b0(%rbx), %rdi
movl 0x10(%rbx), %edx
movq (%rdi), %rax
callq *0x38(%rax)
movq %rax, 0x468(%rbx)
cmpb $0x0, 0x474(%rbx)
jne 0x28c84
cmpb $0x0, 0x1d8(%rbx)
jne 0x28c84
cvtsi2sdq (%rbx), %xmm0
movsd %xmm0, 0x110(%rbx)
cvttsd2si 0x588(%rbx), %rax
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x1a8(%rbx)
movq 0x5b0(%rbx), %rdi
movl 0x10(%rbx), %esi
movq (%rdi), %rax
callq *0x40(%rax)
movb $0x1, 0x1d8(%rbx)
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xed02(%rip), %rdi      # 0x3799f
leaq 0xea70(%rip), %rsi      # 0x37714
leaq 0xed15(%rip), %rcx      # 0x379c0
movl $0xde, %edx
callq 0x5200
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
jmp 0x28cdc
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
jmp 0x28cfa
jmp 0x28ce3
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x10010
jmp 0x28ce6
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x10010
jmp 0x28cff
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x2564a
movq %rbx, %rdi
callq 0x54a0
nop