// File: 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
movq %rsp, %rbp
subq $0x260, %rsp            # imm = 0x260
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x208(%rbp)
movq (%rdi), %rax
addq $0x1, %rax
movq %rax, (%rdi)
addq $0x408, %rdi            # imm = 0x408
callq 0x6e550
movq %rax, %rcx
movq -0x208(%rbp), %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
cmpq $0x0, 0x1d0(%rax)
jne 0x6c6c1
movq -0x208(%rbp), %rax
testb $0x1, 0x474(%rax)
jne 0x6c6c1
jmp 0x6ce11
movl $0x0, -0xc(%rbp)
movq -0x208(%rbp), %rax
cmpq $0x0, 0x460(%rax)
jle 0x6c80c
movq -0x208(%rbp), %rcx
movl -0xc(%rbp), %eax
cmpl 0x408(%rcx), %eax
jne 0x6c6f4
jmp 0x6ce11
movq -0x208(%rbp), %rdi
addq $0x408, %rdi            # imm = 0x408
callq 0x6e640
testb $0x1, %al
jne 0x6c70d
jmp 0x6c712
jmp 0x6ce11
movq -0x208(%rbp), %rdi
addq $0x408, %rdi            # imm = 0x408
movl $0x1, %esi
movq $-0x1, %rdx
callq 0x6e660
movq -0x208(%rbp), %rdi
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
movq 0x460(%rdi), %rax
addq $-0x1, %rax
movq %rax, 0x460(%rdi)
addq $0x518, %rdi            # imm = 0x518
xorl %esi, %esi
callq 0x29c60
movq -0x208(%rbp), %rdi
addq $0x518, %rdi            # imm = 0x518
callq 0x30140
movq -0x208(%rbp), %rcx
cvttsd2si %xmm0, %rax
cmpq 0x1d0(%rcx), %rax
jne 0x6c807
movq -0x208(%rbp), %rax
testb $0x1, 0x1d8(%rax)
jne 0x6c807
movq -0x208(%rbp), %rsi
movq %rsi, %rdi
addq $0xa0, %rdi
callq 0x258f0
movq -0x208(%rbp), %rdi
addq $0x518, %rdi            # imm = 0x518
callq 0x30140
movq -0x208(%rbp), %rdi
cvttsd2si %xmm0, %rax
movq %rax, -0x18(%rbp)
addq $0x138, %rdi            # imm = 0x138
leaq -0x18(%rbp), %rsi
callq 0x258f0
movq -0x208(%rbp), %rax
movq 0x5b0(%rax), %rdi
movl 0x10(%rax), %esi
movq (%rdi), %rax
callq *0x40(%rax)
movq -0x208(%rbp), %rax
movb $0x1, 0x1d8(%rax)
jmp 0x6c6c8
movq -0x208(%rbp), %rax
cmpl $0x0, 0x470(%rax)
jne 0x6ca00
movq -0x208(%rbp), %rcx
movl -0xc(%rbp), %eax
cmpl 0x408(%rcx), %eax
jne 0x6c837
jmp 0x6ce11
movq -0x208(%rbp), %rdi
addq $0x408, %rdi            # imm = 0x408
callq 0x6e640
testb $0x1, %al
jne 0x6c850
jmp 0x6c855
jmp 0x6ce11
movq -0x208(%rbp), %rsi
movq 0x468(%rsi), %rax
movq %rax, -0x220(%rbp)
movl 0x470(%rsi), %eax
movl %eax, -0x214(%rbp)
addq $0x38, %rsi
leaq -0x98(%rbp), %rdi
movq %rdi, -0x210(%rbp)
callq 0x2bb50
movq -0x208(%rbp), %rax
movq -0x220(%rbp), %rsi
movl -0x214(%rbp), %edx
movq -0x210(%rbp), %rcx
movl 0x10(%rax), %r8d
leaq -0x78(%rbp), %rdi
callq 0x34460
jmp 0x6c8b7
leaq -0x98(%rbp), %rdi
callq 0x242c0
movq -0x208(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x228(%rbp)
leaq -0x108(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x2be20
jmp 0x6c8e7
movq -0x228(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x652f0
movb %al, -0x229(%rbp)
jmp 0x6c902
movb -0x229(%rbp), %al
xorb $-0x1, %al
movb %al, -0x22a(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x24290
movb -0x22a(%rbp), %al
testb $0x1, %al
jne 0x6c928
jmp 0x6c991
movl $0x1, -0x10c(%rbp)
jmp 0x6c9d3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x242c0
jmp 0x6ce1a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x6c9f2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x24290
jmp 0x6c9f2
movq -0x208(%rbp), %rax
movq %rax, %rdi
addq $0x408, %rdi            # imm = 0x408
movq 0x468(%rax), %rdx
xorl %esi, %esi
callq 0x6e660
jmp 0x6c9b2
movq -0x208(%rbp), %rdi
addq $0x518, %rdi            # imm = 0x518
xorl %esi, %esi
callq 0x29c60
jmp 0x6c9c9
movl $0x0, -0x10c(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x24290
movl -0x10c(%rbp), %eax
testl %eax, %eax
je 0x6c9ed
jmp 0x6c9e8
jmp 0x6ce11
jmp 0x6cbbe
leaq -0x78(%rbp), %rdi
callq 0x24290
jmp 0x6ce1a
movq -0x208(%rbp), %rax
cmpl $0x1, 0x470(%rax)
jne 0x6ca12
jmp 0x6ca31
leaq 0x311a2(%rip), %rdi     # 0x9dbbb
leaq 0x30f10(%rip), %rsi     # 0x9d930
movl $0xde, %edx
leaq 0x311b0(%rip), %rcx     # 0x9dbdc
callq 0x6270
movq -0x208(%rbp), %rsi
movq 0x468(%rsi), %rax
movq %rax, -0x248(%rbp)
movl 0x470(%rsi), %eax
movl %eax, -0x23c(%rbp)
addq $0x38, %rsi
leaq -0x190(%rbp), %rdi
movq %rdi, -0x238(%rbp)
callq 0x2bb50
movq -0x208(%rbp), %rax
movq -0x248(%rbp), %rsi
movl -0x23c(%rbp), %edx
movq -0x238(%rbp), %rcx
movl 0x10(%rax), %r8d
leaq -0x170(%rbp), %rdi
callq 0x34460
jmp 0x6ca96
leaq -0x190(%rbp), %rdi
callq 0x242c0
movq -0x208(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x250(%rbp)
leaq -0x1f0(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x2be20
jmp 0x6cac9
movq -0x250(%rbp), %rdi
leaq -0x1f0(%rbp), %rsi
callq 0x652f0
movb %al, -0x251(%rbp)
jmp 0x6cae4
movb -0x251(%rbp), %al
xorb $-0x1, %al
movb %al, -0x252(%rbp)
leaq -0x1f0(%rbp), %rdi
callq 0x24290
movb -0x252(%rbp), %al
testb $0x1, %al
jne 0x6cb0a
jmp 0x6cb6d
movl $0x1, -0x10c(%rbp)
jmp 0x6cb8e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x190(%rbp), %rdi
callq 0x242c0
jmp 0x6ce1a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x6cbad
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x1f0(%rbp), %rdi
callq 0x24290
jmp 0x6cbad
movq -0x208(%rbp), %rdi
addq $0x518, %rdi            # imm = 0x518
xorl %esi, %esi
callq 0x29c60
jmp 0x6cb84
movl $0x0, -0x10c(%rbp)
leaq -0x170(%rbp), %rdi
callq 0x24290
movl -0x10c(%rbp), %eax
testl %eax, %eax
je 0x6cbab
jmp 0x6cba6
jmp 0x6ce11
jmp 0x6cbbe
leaq -0x170(%rbp), %rdi
callq 0x24290
jmp 0x6ce1a
movq -0x208(%rbp), %rdi
addq $0x518, %rdi            # imm = 0x518
callq 0x30140
movq -0x208(%rbp), %rcx
cvttsd2si %xmm0, %rax
cmpq 0x1d0(%rcx), %rax
jne 0x6cc6e
movq -0x208(%rbp), %rax
testb $0x1, 0x1d8(%rax)
jne 0x6cc6e
movq -0x208(%rbp), %rsi
movq %rsi, %rdi
addq $0xa0, %rdi
callq 0x258f0
movq -0x208(%rbp), %rdi
addq $0x518, %rdi            # imm = 0x518
callq 0x30140
movq -0x208(%rbp), %rdi
cvttsd2si %xmm0, %rax
movq %rax, -0x1f8(%rbp)
addq $0x138, %rdi            # imm = 0x138
leaq -0x1f8(%rbp), %rsi
callq 0x258f0
movq -0x208(%rbp), %rax
movq 0x5b0(%rax), %rdi
movl 0x10(%rax), %esi
movq (%rdi), %rax
callq *0x40(%rax)
movq -0x208(%rbp), %rax
movb $0x1, 0x1d8(%rax)
movq -0x208(%rbp), %rax
testb $0x1, 0x58(%rax)
je 0x6ccf9
movq -0x208(%rbp), %rcx
movq %rcx, %rdi
addq $0x1e0, %rdi            # imm = 0x1E0
movq %rcx, %rsi
addq $0x460, %rsi            # imm = 0x460
movq %rcx, %rdx
addq $0x468, %rdx            # imm = 0x468
addq $0x470, %rcx            # imm = 0x470
callq 0x6df40
movb %al, %cl
movq -0x208(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x474(%rax)
cmpq $-0x1, 0x468(%rax)
je 0x6ccf7
movq -0x208(%rbp), %rax
movq 0x5b0(%rax), %rdi
movq 0x468(%rax), %rsi
movl 0x10(%rax), %edx
movq (%rdi), %rax
callq *0x38(%rax)
movq %rax, %rcx
movq -0x208(%rbp), %rax
movq %rcx, 0x468(%rax)
jmp 0x6cd77
movq -0x208(%rbp), %rcx
movq %rcx, %rdi
addq $0x1e0, %rdi            # imm = 0x1E0
movq %rcx, %rsi
addq $0x460, %rsi            # imm = 0x460
movq %rcx, %rdx
addq $0x468, %rdx            # imm = 0x468
addq $0x470, %rcx            # imm = 0x470
callq 0x6e200
movb %al, %cl
movq -0x208(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x474(%rax)
cmpq $-0x1, 0x468(%rax)
je 0x6cd75
movq -0x208(%rbp), %rax
movq 0x5b0(%rax), %rdi
movq 0x468(%rax), %rsi
movl 0x10(%rax), %edx
movq (%rdi), %rax
callq *0x38(%rax)
movq %rax, %rcx
movq -0x208(%rbp), %rax
movq %rcx, 0x468(%rax)
jmp 0x6cd77
movq -0x208(%rbp), %rax
testb $0x1, 0x474(%rax)
jne 0x6ce11
movq -0x208(%rbp), %rax
testb $0x1, 0x1d8(%rax)
jne 0x6ce0f
movq -0x208(%rbp), %rsi
movq %rsi, %rdi
addq $0xa0, %rdi
callq 0x258f0
movq -0x208(%rbp), %rdi
addq $0x518, %rdi            # imm = 0x518
callq 0x30140
movq -0x208(%rbp), %rdi
cvttsd2si %xmm0, %rax
movq %rax, -0x200(%rbp)
addq $0x138, %rdi            # imm = 0x138
leaq -0x200(%rbp), %rsi
callq 0x258f0
movq -0x208(%rbp), %rax
movq 0x5b0(%rax), %rdi
movl 0x10(%rax), %esi
movq (%rdi), %rax
callq *0x40(%rax)
movq -0x208(%rbp), %rax
movb $0x1, 0x1d8(%rax)
jmp 0x6ce11
addq $0x260, %rsp            # imm = 0x260
popq %rbp
retq
movq -0xa0(%rbp), %rdi
callq 0x65b0
nopw %cs:(%rax,%rax)