// File: Ziang95[P]Tomasulo_simulator/mips.cpp
// Function: main
int main(int argc, char** argv)
{
    if (argc < 2 || argc > 3)
    {
        cout<<"Require 1 or 2 arguments"<<endl;
        return -1;
    }
    if (argc == 3)
        debug_level = stoi(argv[2]);
    if (!read_config_instrs(string(argv[1])))
        return -1;
    init_CPU_ROB();
    init_FUs();
    init_FU_CDB();
    init_main_mem();
    init_issue_unit();
    init_brcUnit();
    init_output_unit();
    msg_log("Threads count is: "+to_string(clk_wait_list.size()), 0);
    msg_log("instr buffer size is: " + to_string(instr_Q->size), 3);
    start_sys_clk();
    cin.get();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x2, -0x8(%rbp)
jl 0x1be85
cmpl $0x3, -0x8(%rbp)
jle 0x1beb3
movq 0x13134(%rip), %rdi     # 0x2efc0
leaq 0x69d7(%rip), %rsi      # 0x2286a
callq 0x4370
movq %rax, %rdi
movq 0x13106(%rip), %rsi     # 0x2efa8
callq 0x43a0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1c111
cmpl $0x3, -0x8(%rbp)
jne 0x1bf60
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x100(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0xf8(%rbp)
callq 0x4600
movq -0x100(%rbp), %rsi
movq -0xf8(%rbp), %rdx
leaq -0x30(%rbp), %rdi
callq 0x44c0
jmp 0x1bef5
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
movl $0xa, %edx
callq 0x15bd0
movl %eax, -0x104(%rbp)
jmp 0x1bf0f
movl -0x104(%rbp), %eax
movl %eax, 0x16fb5(%rip)     # 0x32ed0
leaq -0x30(%rbp), %rdi
callq 0x4240
leaq -0x31(%rbp), %rdi
callq 0x43d0
jmp 0x1bf60
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1bf52
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x4240
leaq -0x31(%rbp), %rdi
callq 0x43d0
jmp 0x1c183
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x118(%rbp)
leaq -0x69(%rbp), %rdi
movq %rdi, -0x110(%rbp)
callq 0x4600
movq -0x118(%rbp), %rsi
movq -0x110(%rbp), %rdx
leaq -0x68(%rbp), %rdi
callq 0x44c0
jmp 0x1bf98
leaq -0x68(%rbp), %rdi
callq 0x12540
movb %al, -0x119(%rbp)
jmp 0x1bfa9
movb -0x119(%rbp), %al
xorb $-0x1, %al
movb %al, -0x11a(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x4240
leaq -0x69(%rbp), %rdi
callq 0x43d0
movb -0x11a(%rbp), %al
testb $0x1, %al
jne 0x1bfd5
jmp 0x1c012
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1c111
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1c004
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x4240
leaq -0x69(%rbp), %rdi
callq 0x43d0
jmp 0x1c183
callq 0xef10
callq 0x7bb0
callq 0x5300
callq 0x1bcd0
callq 0x19a50
callq 0x10a20
callq 0x1e170
leaq 0x13dcc(%rip), %rdi     # 0x2fe08
callq 0x9d90
movq %rax, %rsi
leaq -0xb0(%rbp), %rdi
movq %rdi, -0x128(%rbp)
callq 0x1c490
movq -0x128(%rbp), %rdx
leaq 0x681e(%rip), %rsi      # 0x22883
leaq -0x90(%rbp), %rdi
callq 0x83c0
jmp 0x1c073
leaq -0x90(%rbp), %rdi
xorl %esi, %esi
callq 0x12060
jmp 0x1c083
leaq -0x90(%rbp), %rdi
callq 0x4240
leaq -0xb0(%rbp), %rdi
callq 0x4240
movq 0x133b6(%rip), %rax     # 0x2f458
movq 0x8(%rax), %rsi
leaq -0xf0(%rbp), %rdi
movq %rdi, -0x130(%rbp)
callq 0x1c490
movq -0x130(%rbp), %rdx
leaq 0x67cf(%rip), %rsi      # 0x22896
leaq -0xd0(%rbp), %rdi
callq 0x83c0
jmp 0x1c0d5
leaq -0xd0(%rbp), %rdi
movl $0x3, %esi
callq 0x12060
jmp 0x1c0e8
leaq -0xd0(%rbp), %rdi
callq 0x4240
leaq -0xf0(%rbp), %rdi
callq 0x4240
callq 0x12210
movq 0x12ed4(%rip), %rdi     # 0x2efe0
callq 0x4410
movl -0x4(%rbp), %eax
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1c143
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x4240
leaq -0xb0(%rbp), %rdi
callq 0x4240
jmp 0x1c183
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1c177
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x4240
leaq -0xf0(%rbp), %rdi
callq 0x4240
movq -0x40(%rbp), %rdi
callq 0x45f0
nopl (%rax)