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

    if(first_level_cache != nullptr)
        first_level_cache->tick();

    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.
        // Hasan: overriding this behavior. We start the trace from the
        // beginning until the requested amount of instructions are
        // simulated. This should never be reached now.
        assert((expected_limit_insts == 0) && "Shouldn't be reached when expected_limit_insts > 0 since we start over the trace");
        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)
movq 0x488(%rdi), %rdi
testq %rdi, %rdi
je 0x12f66c
callq 0x107d28
leaq 0x410(%rbx), %r15
movq %r15, %rdi
callq 0x131354
addq %rax, 0x8(%rbx)
cmpq $0x0, 0x1d0(%rbx)
jne 0x12f696
cmpb $0x1, 0x47c(%rbx)
jne 0x12fb3f
leaq 0x468(%rbx), %r14
cmpq $0x0, 0x468(%rbx)
jle 0x12f759
xorl %r12d, %r12d
cmpl (%r15), %r12d
je 0x12fb3f
movl 0x418(%rbx), %eax
cmpl 0x414(%rbx), %eax
je 0x12fb3f
movq %r15, %rdi
movl $0x1, %esi
movq $-0x1, %rdx
callq 0x1313e2
decq 0x468(%rbx)
movsd 0x598(%rbx), %xmm0
addsd 0x1d984(%rip), %xmm0    # 0x14d078
movsd %xmm0, 0x598(%rbx)
cvttsd2si %xmm0, %rax
cmpq %rax, 0x1d0(%rbx)
jne 0x12f74a
cmpb $0x0, 0x1d8(%rbx)
jne 0x12f74a
xorps %xmm0, %xmm0
cvtsi2sdq (%rbx), %xmm0
movsd %xmm0, 0x110(%rbx)
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x1a8(%rbx)
movq 0x5c0(%rbx), %rdi
movl 0x10(%rbx), %esi
movq (%rdi), %rax
callq *0x40(%rax)
movb $0x1, 0x1d8(%rbx)
incl %r12d
cmpq $0x0, (%r14)
jg 0x12f6ae
jmp 0x12f75c
xorl %r12d, %r12d
movl 0x478(%rbx), %ebp
cmpl $0x1, %ebp
je 0x12f8b4
testl %ebp, %ebp
jne 0x12fb51
cmpl (%r15), %r12d
je 0x12fb3f
movl 0x418(%rbx), %eax
cmpl 0x414(%rbx), %eax
je 0x12fb3f
movq 0x470(%rbx), %r12
leaq 0x38(%rbx), %rsi
leaq 0x80(%rsp), %r13
movq %r13, %rdi
callq 0x295b4
movl 0x10(%rbx), %r8d
movq %rsp, %rdi
movq %r12, %rsi
movl %ebp, %edx
movq %r13, %rcx
callq 0x2c85e
movq 0x90(%rsp), %rax
testq %rax, %rax
je 0x12f7dc
leaq 0x80(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
leaq 0x10(%rsp), %rsi
movupd -0x10(%rsi), %xmm0
leaq 0x110(%rsp), %rdi
movapd %xmm0, -0x10(%rdi)
callq 0x24b6e
leaq 0x40(%rsp), %rsi
movq -0x8(%rsi), %rax
leaq 0x140(%rsp), %r12
movq %rax, -0x8(%r12)
movupd -0x18(%rsi), %xmm0
movupd %xmm0, -0x18(%r12)
movq %r12, %rdi
callq 0x295b4
cmpq $0x0, 0x28(%rbx)
je 0x12fb75
leaq 0x18(%rbx), %rdi
leaq 0x100(%rsp), %rsi
callq *0x30(%rbx)
movl %eax, %ebp
movq 0x150(%rsp), %rax
testq %rax, %rax
je 0x12f858
movq %r12, %rdi
movq %r12, %rsi
movl $0x3, %edx
callq *%rax
movq 0x110(%rsp), %rdi
testq %rdi, %rdi
je 0x12f875
movq 0x120(%rsp), %rsi
subq %rdi, %rsi
callq 0xb2f0
testb %bpl, %bpl
je 0x12fb37
movq 0x470(%rbx), %rdx
movq %r15, %rdi
xorl %esi, %esi
callq 0x1313e2
movsd 0x598(%rbx), %xmm0
addsd 0x1d7d9(%rip), %xmm0    # 0x14d078
movsd %xmm0, 0x598(%rbx)
movq %rsp, %rdi
callq 0x25bb6
jmp 0x12f9e5
movq 0x470(%rbx), %r15
leaq 0x38(%rbx), %rsi
leaq 0x60(%rsp), %r12
movq %r12, %rdi
callq 0x295b4
movl 0x10(%rbx), %r8d
movq %rsp, %rdi
movq %r15, %rsi
movl %ebp, %edx
movq %r12, %rcx
callq 0x2c85e
movq 0x70(%rsp), %rax
testq %rax, %rax
je 0x12f8f9
leaq 0x60(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
leaq 0x10(%rsp), %rsi
movupd -0x10(%rsi), %xmm0
leaq 0xb0(%rsp), %rdi
movapd %xmm0, -0x10(%rdi)
callq 0x24b6e
leaq 0x40(%rsp), %r15
movq -0x8(%r15), %rax
leaq 0xe0(%rsp), %r12
movq %rax, -0x8(%r12)
movupd -0x18(%r15), %xmm0
movupd %xmm0, -0x18(%r12)
movq %r12, %rdi
movq %r15, %rsi
callq 0x295b4
cmpq $0x0, 0x28(%rbx)
je 0x12fb70
leaq 0x18(%rbx), %rdi
leaq 0xa0(%rsp), %rsi
callq *0x30(%rbx)
movl %eax, %ebp
movq 0xf0(%rsp), %rax
testq %rax, %rax
je 0x12f979
movq %r12, %rdi
movq %r12, %rsi
movl $0x3, %edx
callq *%rax
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0x12f996
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0xb2f0
testb %bpl, %bpl
je 0x12fa6b
movsd 0x598(%rbx), %xmm0
addsd 0x1d6c9(%rip), %xmm0    # 0x14d078
movsd %xmm0, 0x598(%rbx)
movq 0x50(%rsp), %rax
testq %rax, %rax
je 0x12f9ce
movq %r15, %rdi
movq %r15, %rsi
movl $0x3, %edx
callq *%rax
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x12f9e5
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0xb2f0
testb %bpl, %bpl
je 0x12fb3f
cvttsd2si 0x598(%rbx), %rax
cmpq %rax, 0x1d0(%rbx)
jne 0x12fa40
cmpb $0x0, 0x1d8(%rbx)
jne 0x12fa40
xorps %xmm0, %xmm0
cvtsi2sdq (%rbx), %xmm0
movsd %xmm0, 0x110(%rbx)
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x1a8(%rbx)
movq 0x5c0(%rbx), %rdi
movl 0x10(%rbx), %esi
movq (%rdi), %rax
callq *0x40(%rax)
movb $0x1, 0x1d8(%rbx)
leaq 0x478(%rbx), %rcx
leaq 0x1e0(%rbx), %rdi
leaq 0x470(%rbx), %rdx
cmpb $0x1, 0x58(%rbx)
jne 0x12faa2
movq %r14, %rsi
callq 0x130cce
movb %al, 0x47c(%rbx)
jmp 0x12fab1
movq 0x50(%rsp), %rax
testq %rax, %rax
je 0x12fa82
movq %r15, %rdi
movq %r15, %rsi
movl $0x3, %edx
callq *%rax
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x12fb3f
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0xb2f0
jmp 0x12fb3f
movq %r14, %rsi
callq 0x131052
movb $0x1, 0x47c(%rbx)
movq 0x470(%rbx), %rsi
cmpq $-0x1, %rsi
je 0x12fad5
movq 0x5c0(%rbx), %rdi
movl 0x10(%rbx), %edx
movq (%rdi), %rax
callq *0x38(%rax)
movq %rax, 0x470(%rbx)
cmpb $0x0, 0x47c(%rbx)
jne 0x12fb3f
cmpb $0x0, 0x1d8(%rbx)
jne 0x12fb3f
cmpq $0x0, 0x1d0(%rbx)
jne 0x12fb7a
xorps %xmm0, %xmm0
cvtsi2sdq (%rbx), %xmm0
movsd %xmm0, 0x110(%rbx)
cvttsd2si 0x598(%rbx), %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x1a8(%rbx)
movq 0x5c0(%rbx), %rdi
movl 0x10(%rbx), %esi
movq (%rdi), %rax
callq *0x40(%rax)
movb $0x1, 0x1d8(%rbx)
jmp 0x12fb3f
movq %rsp, %rdi
callq 0x25bb6
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2e203(%rip), %rdi     # 0x15dd5b
leaq 0x2df55(%rip), %rsi     # 0x15dab4
leaq 0x2e216(%rip), %rcx     # 0x15dd7c
movl $0xfd, %edx
callq 0xb200
callq 0xb160
callq 0xb160
leaq 0x2e218(%rip), %rdi     # 0x15dd99
leaq 0x2df2c(%rip), %rsi     # 0x15dab4
leaq 0x2e1ed(%rip), %rcx     # 0x15dd7c
movl $0x11b, %edx            # imm = 0x11B
callq 0xb200
jmp 0x12fc47
jmp 0x12fc47
movq %rax, %rbx
movq 0x110(%rsp), %rdi
testq %rdi, %rdi
je 0x12fc5f
movq 0x120(%rsp), %rsi
jmp 0x12fc1a
movq %rax, %rbx
movq 0x90(%rsp), %rax
testq %rax, %rax
je 0x12fc67
leaq 0x80(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x12fc67
jmp 0x12fc47
jmp 0x12fc47
jmp 0x12fc47
jmp 0x12fc24
movq %rax, %rbx
leaq 0x100(%rsp), %rdi
jmp 0x12fc5a
jmp 0x12fc47
jmp 0x12fc47
movq %rax, %rbx
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0x12fc5f
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0xb2f0
jmp 0x12fc5f
movq %rax, %rbx
jmp 0x12fc5f
movq %rax, %rbx
movq 0x70(%rsp), %rax
testq %rax, %rax
je 0x12fc67
leaq 0x60(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x12fc67
movq %rax, %rdi
callq 0x1718f
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x25bb6
movq %rsp, %rdi
callq 0x25bb6
movq %rbx, %rdi
callq 0xb510
nop