// File: /workspace/github_cpp_makefile_star2_O1/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 0x40ee2
addq %rax, 0x8(%rbx)
cmpq $0x0, 0x1d0(%rbx)
jne 0x3f33f
cmpb $0x1, 0x474(%rbx)
jne 0x3f7d3
leaq 0x460(%rbx), %r14
cmpq $0x0, 0x460(%rbx)
jle 0x3f402
xorl %r12d, %r12d
cmpl (%r15), %r12d
je 0x3f7d3
movl 0x410(%rbx), %eax
cmpl 0x40c(%rbx), %eax
je 0x3f7d3
movq %r15, %rdi
movl $0x1, %esi
movq $-0x1, %rdx
callq 0x40f70
decq 0x460(%rbx)
movsd 0x588(%rbx), %xmm0
addsd 0xeccb(%rip), %xmm0     # 0x4e068
movsd %xmm0, 0x588(%rbx)
cvttsd2si %xmm0, %rax
cmpq %rax, 0x1d0(%rbx)
jne 0x3f3f3
cmpb $0x0, 0x1d8(%rbx)
jne 0x3f3f3
xorps %xmm0, %xmm0
cvtsi2sdq (%rbx), %xmm0
movsd %xmm0, 0x110(%rbx)
xorps %xmm0, %xmm0
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 %r12d
cmpq $0x0, (%r14)
jg 0x3f357
jmp 0x3f405
xorl %r12d, %r12d
movl 0x470(%rbx), %ebp
cmpl $0x1, %ebp
je 0x3f55d
testl %ebp, %ebp
jne 0x3f7e5
cmpl (%r15), %r12d
je 0x3f7d3
movl 0x410(%rbx), %eax
cmpl 0x40c(%rbx), %eax
je 0x3f7d3
movq 0x468(%rbx), %r12
leaq 0x38(%rbx), %rsi
leaq 0x80(%rsp), %r13
movq %r13, %rdi
callq 0x18a58
movl 0x10(%rbx), %r8d
movq %rsp, %rdi
movq %r12, %rsi
movl %ebp, %edx
movq %r13, %rcx
callq 0x1b552
movq 0x90(%rsp), %rax
testq %rax, %rax
je 0x3f485
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 0x150b6
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 0x18a58
cmpq $0x0, 0x28(%rbx)
je 0x3f809
leaq 0x18(%rbx), %rdi
leaq 0x100(%rsp), %rsi
callq *0x30(%rbx)
movl %eax, %ebp
movq 0x150(%rsp), %rax
testq %rax, %rax
je 0x3f501
movq %r12, %rdi
movq %r12, %rsi
movl $0x3, %edx
callq *%rax
movq 0x110(%rsp), %rdi
testq %rdi, %rdi
je 0x3f51e
movq 0x120(%rsp), %rsi
subq %rdi, %rsi
callq 0x52d0
testb %bpl, %bpl
je 0x3f7cb
movq 0x468(%rbx), %rdx
movq %r15, %rdi
xorl %esi, %esi
callq 0x40f70
movsd 0x588(%rbx), %xmm0
addsd 0xeb20(%rip), %xmm0     # 0x4e068
movsd %xmm0, 0x588(%rbx)
movq %rsp, %rdi
callq 0x16386
jmp 0x3f68e
movq 0x468(%rbx), %r15
leaq 0x38(%rbx), %rsi
leaq 0x60(%rsp), %r12
movq %r12, %rdi
callq 0x18a58
movl 0x10(%rbx), %r8d
movq %rsp, %rdi
movq %r15, %rsi
movl %ebp, %edx
movq %r12, %rcx
callq 0x1b552
movq 0x70(%rsp), %rax
testq %rax, %rax
je 0x3f5a2
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 0x150b6
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 0x18a58
cmpq $0x0, 0x28(%rbx)
je 0x3f804
leaq 0x18(%rbx), %rdi
leaq 0xa0(%rsp), %rsi
callq *0x30(%rbx)
movl %eax, %ebp
movq 0xf0(%rsp), %rax
testq %rax, %rax
je 0x3f622
movq %r12, %rdi
movq %r12, %rsi
movl $0x3, %edx
callq *%rax
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0x3f63f
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0x52d0
testb %bpl, %bpl
je 0x3f70e
movsd 0x588(%rbx), %xmm0
addsd 0xea10(%rip), %xmm0     # 0x4e068
movsd %xmm0, 0x588(%rbx)
movq 0x50(%rsp), %rax
testq %rax, %rax
je 0x3f677
movq %r15, %rdi
movq %r15, %rsi
movl $0x3, %edx
callq *%rax
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3f68e
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x52d0
testb %bpl, %bpl
je 0x3f7d3
cvttsd2si 0x588(%rbx), %rax
cmpq %rax, 0x1d0(%rbx)
jne 0x3f6e9
cmpb $0x0, 0x1d8(%rbx)
jne 0x3f6e9
xorps %xmm0, %xmm0
cvtsi2sdq (%rbx), %xmm0
movsd %xmm0, 0x110(%rbx)
xorps %xmm0, %xmm0
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 0x3f745
movq %r14, %rsi
callq 0x40858
jmp 0x3f74d
movq 0x50(%rsp), %rax
testq %rax, %rax
je 0x3f725
movq %r15, %rdi
movq %r15, %rsi
movl $0x3, %edx
callq *%rax
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3f7d3
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x52d0
jmp 0x3f7d3
movq %r14, %rsi
callq 0x40bca
movb %al, 0x474(%rbx)
movq 0x468(%rbx), %rsi
cmpq $-0x1, %rsi
je 0x3f777
movq 0x5b0(%rbx), %rdi
movl 0x10(%rbx), %edx
movq (%rdi), %rax
callq *0x38(%rax)
movq %rax, 0x468(%rbx)
cmpb $0x0, 0x474(%rbx)
jne 0x3f7d3
cmpb $0x0, 0x1d8(%rbx)
jne 0x3f7d3
xorps %xmm0, %xmm0
cvtsi2sdq (%rbx), %xmm0
movsd %xmm0, 0x110(%rbx)
cvttsd2si 0x588(%rbx), %rax
xorps %xmm0, %xmm0
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)
jmp 0x3f7d3
movq %rsp, %rdi
callq 0x16386
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x121a3(%rip), %rdi     # 0x5198f
leaq 0x11f11(%rip), %rsi     # 0x51704
leaq 0x121b6(%rip), %rcx     # 0x519b0
movl $0xde, %edx
callq 0x51f0
callq 0x5150
callq 0x5150
jmp 0x3f8bc
jmp 0x3f8bc
movq %rax, %rbx
movq 0x110(%rsp), %rdi
testq %rdi, %rdi
je 0x3f8d4
movq 0x120(%rsp), %rsi
jmp 0x3f88f
movq %rax, %rbx
movq 0x90(%rsp), %rax
testq %rax, %rax
je 0x3f8dc
leaq 0x80(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x3f8dc
jmp 0x3f8bc
jmp 0x3f8bc
jmp 0x3f8bc
jmp 0x3f899
movq %rax, %rbx
leaq 0x100(%rsp), %rdi
jmp 0x3f8cf
jmp 0x3f8bc
jmp 0x3f8bc
movq %rax, %rbx
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0x3f8d4
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0x52d0
jmp 0x3f8d4
movq %rax, %rbx
jmp 0x3f8d4
movq %rax, %rbx
movq 0x70(%rsp), %rax
testq %rax, %rax
je 0x3f8dc
leaq 0x60(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x3f8dc
movq %rax, %rdi
callq 0x7ce9
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x16386
movq %rsp, %rdi
callq 0x16386
movq %rbx, %rdi
callq 0x54c0