// File: /workspace/github_cpp_makefile_star2_O3/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 %r12
pushq %rbx
subq $0x160, %rsp            # imm = 0x160
movq %rdi, %rbx
incq (%rdi)
leaq 0x408(%rdi), %r14
movq %r14, %rdi
callq 0x407e6
addq %rax, 0x8(%rbx)
cmpq $0x0, 0x1d0(%rbx)
jne 0x3eccb
cmpb $0x1, 0x474(%rbx)
jne 0x3f15c
cmpq $0x0, 0x460(%rbx)
jle 0x3ed95
xorl %ebp, %ebp
cmpl (%r14), %ebp
je 0x3f15c
movl 0x410(%rbx), %eax
cmpl 0x40c(%rbx), %eax
je 0x3f15c
movq %r14, %rdi
movl $0x1, %esi
movq $-0x1, %rdx
callq 0x40870
movq 0x460(%rbx), %rax
decq %rax
movq %rax, 0x460(%rbx)
movsd 0x588(%rbx), %xmm0
addsd 0xf36d(%rip), %xmm0     # 0x4e098
movsd %xmm0, 0x588(%rbx)
cvttsd2si %xmm0, %rcx
cmpq %rcx, 0x1d0(%rbx)
jne 0x3ed88
cmpb $0x0, 0x1d8(%rbx)
jne 0x3ed88
xorps %xmm0, %xmm0
cvtsi2sdq (%rbx), %xmm0
movsd %xmm0, 0x110(%rbx)
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
movsd %xmm0, 0x1a8(%rbx)
movq 0x5b0(%rbx), %rdi
movl 0x10(%rbx), %esi
movq (%rdi), %rax
callq *0x40(%rax)
movb $0x1, 0x1d8(%rbx)
movq 0x460(%rbx), %rax
incl %ebp
testq %rax, %rax
jg 0x3ecdb
jmp 0x3ed97
xorl %ebp, %ebp
movl 0x470(%rbx), %eax
cmpl $0x1, %eax
je 0x3eeed
testl %eax, %eax
jne 0x3f16c
cmpl (%r14), %ebp
je 0x3f15c
movl 0x410(%rbx), %eax
cmpl 0x40c(%rbx), %eax
je 0x3f15c
movq 0x468(%rbx), %r15
leaq 0x38(%rbx), %rsi
leaq 0x80(%rsp), %r12
movq %r12, %rdi
callq 0x18d0c
movl 0x10(%rbx), %r8d
movq %rsp, %rdi
movq %r15, %rsi
xorl %edx, %edx
movq %r12, %rcx
callq 0x1b6e2
movq 0x90(%rsp), %rax
testq %rax, %rax
je 0x3ee17
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 0x14f2e
leaq 0x40(%rsp), %rsi
movq -0x8(%rsi), %rax
leaq 0x140(%rsp), %r15
movq %rax, -0x8(%r15)
movupd -0x18(%rsi), %xmm0
movupd %xmm0, -0x18(%r15)
movq %r15, %rdi
callq 0x18d0c
cmpq $0x0, 0x28(%rbx)
je 0x3f190
leaq 0x18(%rbx), %rdi
leaq 0x100(%rsp), %rsi
callq *0x30(%rbx)
movl %eax, %ebp
movq 0x150(%rsp), %rax
testq %rax, %rax
je 0x3ee91
movq %r15, %rdi
movq %r15, %rsi
movl $0x3, %edx
callq *%rax
movq 0x110(%rsp), %rdi
testq %rdi, %rdi
je 0x3eeae
movq 0x120(%rsp), %rsi
subq %rdi, %rsi
callq 0x52d0
testb %bpl, %bpl
je 0x3f154
movq 0x468(%rbx), %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0x40870
movsd 0x588(%rbx), %xmm0
addsd 0xf1c0(%rip), %xmm0     # 0x4e098
movsd %xmm0, 0x588(%rbx)
movq %rsp, %rdi
callq 0x16284
jmp 0x3f01f
movq 0x468(%rbx), %r14
leaq 0x38(%rbx), %rsi
leaq 0x60(%rsp), %r15
movq %r15, %rdi
callq 0x18d0c
movl 0x10(%rbx), %r8d
movq %rsp, %rdi
movq %r14, %rsi
movl $0x1, %edx
movq %r15, %rcx
callq 0x1b6e2
movq 0x70(%rsp), %rax
testq %rax, %rax
je 0x3ef35
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 0x14f2e
leaq 0x40(%rsp), %r14
movq -0x8(%r14), %rax
leaq 0xe0(%rsp), %r15
movq %rax, -0x8(%r15)
movupd -0x18(%r14), %xmm0
movupd %xmm0, -0x18(%r15)
movq %r15, %rdi
movq %r14, %rsi
callq 0x18d0c
cmpq $0x0, 0x28(%rbx)
je 0x3f18b
leaq 0x18(%rbx), %rdi
leaq 0xa0(%rsp), %rsi
callq *0x30(%rbx)
movl %eax, %ebp
movq 0xf0(%rsp), %rax
testq %rax, %rax
je 0x3efb3
movq %r15, %rdi
movq %r15, %rsi
movl $0x3, %edx
callq *%rax
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0x3efd0
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0x52d0
testb %bpl, %bpl
je 0x3f09a
movsd 0x588(%rbx), %xmm0
addsd 0xf0af(%rip), %xmm0     # 0x4e098
movsd %xmm0, 0x588(%rbx)
movq 0x50(%rsp), %rax
testq %rax, %rax
je 0x3f008
movq %r14, %rdi
movq %r14, %rsi
movl $0x3, %edx
callq *%rax
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3f01f
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x52d0
cvttsd2si 0x588(%rbx), %rax
cmpq %rax, 0x1d0(%rbx)
jne 0x3f071
cmpb $0x0, 0x1d8(%rbx)
jne 0x3f071
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 0x460(%rbx), %rsi
leaq 0x470(%rbx), %rcx
leaq 0x1e0(%rbx), %rdi
leaq 0x468(%rbx), %rdx
cmpb $0x1, 0x58(%rbx)
jne 0x3f0d1
callq 0x40170
jmp 0x3f0d6
movq 0x50(%rsp), %rax
testq %rax, %rax
je 0x3f0b1
movq %r14, %rdi
movq %r14, %rsi
movl $0x3, %edx
callq *%rax
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3f15c
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x52d0
jmp 0x3f15c
callq 0x404e2
movb %al, 0x474(%rbx)
movq 0x468(%rbx), %rsi
cmpq $-0x1, %rsi
je 0x3f100
movq 0x5b0(%rbx), %rdi
movl 0x10(%rbx), %edx
movq (%rdi), %rax
callq *0x38(%rax)
movq %rax, 0x468(%rbx)
cmpb $0x0, 0x474(%rbx)
jne 0x3f15c
cmpb $0x0, 0x1d8(%rbx)
jne 0x3f15c
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 0x3f15c
movq %rsp, %rdi
callq 0x16284
addq $0x160, %rsp            # imm = 0x160
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1284c(%rip), %rdi     # 0x519bf
leaq 0x125ba(%rip), %rsi     # 0x51734
leaq 0x1285f(%rip), %rcx     # 0x519e0
movl $0xde, %edx
callq 0x51f0
callq 0x5150
callq 0x5150
jmp 0x3f243
jmp 0x3f243
movq %rax, %rbx
movq 0x110(%rsp), %rdi
testq %rdi, %rdi
je 0x3f25b
movq 0x120(%rsp), %rsi
jmp 0x3f216
movq %rax, %rbx
movq 0x90(%rsp), %rax
testq %rax, %rax
je 0x3f263
leaq 0x80(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x3f263
jmp 0x3f243
jmp 0x3f243
jmp 0x3f243
jmp 0x3f220
movq %rax, %rbx
leaq 0x100(%rsp), %rdi
jmp 0x3f256
jmp 0x3f243
jmp 0x3f243
movq %rax, %rbx
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0x3f25b
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0x52d0
jmp 0x3f25b
movq %rax, %rbx
jmp 0x3f25b
movq %rax, %rbx
movq 0x70(%rsp), %rax
testq %rax, %rax
je 0x3f263
leaq 0x60(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x3f263
movq %rax, %rdi
callq 0x7cd9
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x16284
movq %rsp, %rdi
callq 0x16284
movq %rbx, %rdi
callq 0x54c0
nop