// File: Ziang95[P]Tomasulo_simulator/FU.cpp
// Function: init_FUs()
void init_FUs()
{
    if (iAdder.size())
        for (auto &p : iAdder)
            delete p;
    if (fAdder.size())
        for (auto &p : fAdder)
            delete p;
    if (fMtplr.size())
        for (auto &p : fMtplr)
            delete p;
    if (lsUnit.size())
        for (auto &p : lsUnit)
            delete p;
    if (nopBub)
        delete nopBub;
    iAdder = {};
    fAdder = {};
    fMtplr = {};
    lsUnit = {};
    for (int i = 0; i<CPU_cfg->int_add->fu_num; i++)
    {
        auto tmp = new intAdder();
        while(pthread_create(&tmp->handle, NULL, &intAdder_thread_container, tmp));
        clk_wait_list.push_back(&tmp->next_vdd);
        iAdder.push_back(tmp);
    }
    for (int i = 0; i<CPU_cfg->fp_add->fu_num; i++)
    {
        auto tmp = new flpAdder();
        while(pthread_create(&tmp->handle, NULL, &flpAdder_thread_container, tmp));
        clk_wait_list.push_back(&tmp->next_vdd);
        fAdder.push_back(tmp);
    }
    for (int i = 0; i<CPU_cfg->fp_mul->fu_num; i++)
    {
        auto tmp = new flpMtplr();
        while(pthread_create(&tmp->handle, NULL, &flpMlptr_thread_container, tmp));
        clk_wait_list.push_back(&tmp->next_vdd);
        fMtplr.push_back(tmp);
    }
    for (int i = 0; i<CPU_cfg->ld_str->fu_num; i++)
    {
        auto tmp = new ldsdUnit();
        while(pthread_create(&tmp->handle, NULL, &ldsdUnit_thread_container, tmp));
        clk_wait_list.push_back(&tmp->next_vdd);
        lsUnit.push_back(tmp);
    }
    nopBub = new nopBublr();
    while(pthread_create(&nopBub->handle, NULL, &nopBublr_thread_container, nopBub));
    clk_wait_list.push_back(&nopBub->next_vdd);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x190, %rsp            # imm = 0x190
leaq 0x278ee(%rip), %rdi     # 0x2f4b0
callq 0x88b0
cmpq $0x0, %rax
je 0x7c57
leaq 0x278d8(%rip), %rax     # 0x2f4b0
movq %rax, -0x8(%rbp)
leaq 0x278cd(%rip), %rdi     # 0x2f4b0
callq 0x88d0
movq %rax, -0x10(%rbp)
leaq 0x278bd(%rip), %rdi     # 0x2f4b0
callq 0x8900
movq %rax, -0x18(%rbp)
leaq -0x10(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x8930
testb $0x1, %al
jne 0x7c0f
jmp 0x7c55
leaq -0x10(%rbp), %rdi
callq 0x8970
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x140(%rbp)
cmpq $0x0, %rax
je 0x7c48
movq -0x140(%rbp), %rdi
callq 0x59d0
movq -0x140(%rbp), %rdi
callq 0x4350
jmp 0x7c4a
leaq -0x10(%rbp), %rdi
callq 0x8990
jmp 0x7bfc
jmp 0x7c57
leaq 0x2786a(%rip), %rdi     # 0x2f4c8
callq 0x89b0
cmpq $0x0, %rax
je 0x7cf3
leaq 0x27854(%rip), %rax     # 0x2f4c8
movq %rax, -0x28(%rbp)
leaq 0x27849(%rip), %rdi     # 0x2f4c8
callq 0x89d0
movq %rax, -0x30(%rbp)
leaq 0x27839(%rip), %rdi     # 0x2f4c8
callq 0x8a00
movq %rax, -0x38(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x8a30
testb $0x1, %al
jne 0x7cab
jmp 0x7cf1
leaq -0x30(%rbp), %rdi
callq 0x8a70
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x148(%rbp)
cmpq $0x0, %rax
je 0x7ce4
movq -0x148(%rbp), %rdi
callq 0x6590
movq -0x148(%rbp), %rdi
callq 0x4350
jmp 0x7ce6
leaq -0x30(%rbp), %rdi
callq 0x8a90
jmp 0x7c98
jmp 0x7cf3
leaq 0x277e6(%rip), %rdi     # 0x2f4e0
callq 0x8ab0
cmpq $0x0, %rax
je 0x7d8f
leaq 0x277d0(%rip), %rax     # 0x2f4e0
movq %rax, -0x48(%rbp)
leaq 0x277c5(%rip), %rdi     # 0x2f4e0
callq 0x8ad0
movq %rax, -0x50(%rbp)
leaq 0x277b5(%rip), %rdi     # 0x2f4e0
callq 0x8b00
movq %rax, -0x58(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x8b30
testb $0x1, %al
jne 0x7d47
jmp 0x7d8d
leaq -0x50(%rbp), %rdi
callq 0x8b70
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x150(%rbp)
cmpq $0x0, %rax
je 0x7d80
movq -0x150(%rbp), %rdi
callq 0x6c90
movq -0x150(%rbp), %rdi
callq 0x4350
jmp 0x7d82
leaq -0x50(%rbp), %rdi
callq 0x8b90
jmp 0x7d34
jmp 0x7d8f
leaq 0x27762(%rip), %rdi     # 0x2f4f8
callq 0x8bb0
cmpq $0x0, %rax
je 0x7e2b
leaq 0x2774c(%rip), %rax     # 0x2f4f8
movq %rax, -0x68(%rbp)
leaq 0x27741(%rip), %rdi     # 0x2f4f8
callq 0x8bd0
movq %rax, -0x70(%rbp)
leaq 0x27731(%rip), %rdi     # 0x2f4f8
callq 0x8c00
movq %rax, -0x78(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x8c30
testb $0x1, %al
jne 0x7de3
jmp 0x7e29
leaq -0x70(%rbp), %rdi
callq 0x8c70
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x158(%rbp)
cmpq $0x0, %rax
je 0x7e1c
movq -0x158(%rbp), %rdi
callq 0x72f0
movq -0x158(%rbp), %rdi
callq 0x4350
jmp 0x7e1e
leaq -0x70(%rbp), %rdi
callq 0x8c90
jmp 0x7dd0
jmp 0x7e2b
leaq 0x27676(%rip), %rax     # 0x2f4a8
cmpq $0x0, (%rax)
je 0x7e5d
leaq 0x27669(%rip), %rax     # 0x2f4a8
movq (%rax), %rax
movq %rax, -0x160(%rbp)
cmpq $0x0, %rax
je 0x7e5b
movq -0x160(%rbp), %rdi
callq 0x4350
jmp 0x7e5d
leaq -0x90(%rbp), %rdi
callq 0x8cb0
movq -0x90(%rbp), %rsi
movq -0x88(%rbp), %rdx
leaq 0x27632(%rip), %rdi     # 0x2f4b0
callq 0x8cd0
leaq -0xa0(%rbp), %rdi
callq 0x8d20
movq -0xa0(%rbp), %rsi
movq -0x98(%rbp), %rdx
leaq 0x27624(%rip), %rdi     # 0x2f4c8
callq 0x8d40
leaq -0xb0(%rbp), %rdi
callq 0x8d90
movq -0xb0(%rbp), %rsi
movq -0xa8(%rbp), %rdx
leaq 0x27616(%rip), %rdi     # 0x2f4e0
callq 0x8db0
leaq -0xc0(%rbp), %rdi
callq 0x8e00
movq -0xc0(%rbp), %rsi
movq -0xb8(%rbp), %rdx
leaq 0x27608(%rip), %rdi     # 0x2f4f8
callq 0x8e20
movl $0x0, -0xc4(%rbp)
movl -0xc4(%rbp), %eax
leaq 0x27544(%rip), %rcx     # 0x2f450
movq (%rcx), %rcx
movq 0x8(%rcx), %rcx
cmpl 0xc(%rcx), %eax
jge 0x7fe5
movl $0x38a8, %edi           # imm = 0x38A8
callq 0x4380
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x168(%rbp)
callq 0x58e0
jmp 0x7f3a
movq -0x168(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rdi
addq $0x3890, %rdi           # imm = 0x3890
movq -0xd0(%rbp), %rcx
xorl %eax, %eax
movl %eax, %esi
leaq -0x4a8(%rip), %rdx      # 0x7ac0
callq 0x4630
cmpl $0x0, %eax
je 0x7f97
jmp 0x7f48
movq -0x168(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd8(%rbp)
movl %eax, -0xdc(%rbp)
callq 0x4350
jmp 0x8364
movq -0xd0(%rbp), %rax
addq $0x3888, %rax           # imm = 0x3888
movq %rax, -0xe8(%rbp)
leaq 0x27e56(%rip), %rdi     # 0x2fe08
leaq -0xe8(%rbp), %rsi
callq 0x8530
leaq 0x274eb(%rip), %rdi     # 0x2f4b0
leaq -0xd0(%rbp), %rsi
callq 0x8e70
movl -0xc4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc4(%rbp)
jmp 0x7eff
movl $0x0, -0xec(%rbp)
movl -0xec(%rbp), %eax
leaq 0x27454(%rip), %rcx     # 0x2f450
movq (%rcx), %rcx
movq 0x10(%rcx), %rcx
cmpl 0xc(%rcx), %eax
jge 0x80d5
movl $0x38b0, %edi           # imm = 0x38B0
callq 0x4380
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x170(%rbp)
callq 0x6400
jmp 0x802a
movq -0x170(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0xf8(%rbp), %rdi
addq $0x3890, %rdi           # imm = 0x3890
movq -0xf8(%rbp), %rcx
xorl %eax, %eax
movl %eax, %esi
leaq -0x568(%rip), %rdx      # 0x7af0
callq 0x4630
cmpl $0x0, %eax
je 0x8087
jmp 0x8038
movq -0x170(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd8(%rbp)
movl %eax, -0xdc(%rbp)
callq 0x4350
jmp 0x8364
movq -0xf8(%rbp), %rax
addq $0x3888, %rax           # imm = 0x3888
movq %rax, -0x100(%rbp)
leaq 0x27d66(%rip), %rdi     # 0x2fe08
leaq -0x100(%rbp), %rsi
callq 0x8530
leaq 0x27413(%rip), %rdi     # 0x2f4c8
leaq -0xf8(%rbp), %rsi
callq 0x8ee0
movl -0xec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xec(%rbp)
jmp 0x7fef
movl $0x0, -0x104(%rbp)
movl -0x104(%rbp), %eax
leaq 0x27364(%rip), %rcx     # 0x2f450
movq (%rcx), %rcx
movq 0x18(%rcx), %rcx
cmpl 0xc(%rcx), %eax
jge 0x81c5
movl $0x38b0, %edi           # imm = 0x38B0
callq 0x4380
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x178(%rbp)
callq 0x6b00
jmp 0x811a
movq -0x178(%rbp), %rax
movq %rax, -0x110(%rbp)
movq -0x110(%rbp), %rdi
addq $0x3890, %rdi           # imm = 0x3890
movq -0x110(%rbp), %rcx
xorl %eax, %eax
movl %eax, %esi
leaq -0x628(%rip), %rdx      # 0x7b20
callq 0x4630
cmpl $0x0, %eax
je 0x8177
jmp 0x8128
movq -0x178(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd8(%rbp)
movl %eax, -0xdc(%rbp)
callq 0x4350
jmp 0x8364
movq -0x110(%rbp), %rax
addq $0x3888, %rax           # imm = 0x3888
movq %rax, -0x118(%rbp)
leaq 0x27c76(%rip), %rdi     # 0x2fe08
leaq -0x118(%rbp), %rsi
callq 0x8530
leaq 0x2733b(%rip), %rdi     # 0x2f4e0
leaq -0x110(%rbp), %rsi
callq 0x8f50
movl -0x104(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x104(%rbp)
jmp 0x80df
movl $0x0, -0x11c(%rbp)
movl -0x11c(%rbp), %eax
leaq 0x27274(%rip), %rcx     # 0x2f450
movq (%rcx), %rcx
movq 0x20(%rcx), %rcx
cmpl 0xc(%rcx), %eax
jge 0x82b5
movl $0x38a8, %edi           # imm = 0x38A8
callq 0x4380
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x180(%rbp)
callq 0x7200
jmp 0x820a
movq -0x180(%rbp), %rax
movq %rax, -0x128(%rbp)
movq -0x128(%rbp), %rdi
addq $0x3890, %rdi           # imm = 0x3890
movq -0x128(%rbp), %rcx
xorl %eax, %eax
movl %eax, %esi
leaq -0x6e8(%rip), %rdx      # 0x7b50
callq 0x4630
cmpl $0x0, %eax
je 0x8267
jmp 0x8218
movq -0x180(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd8(%rbp)
movl %eax, -0xdc(%rbp)
callq 0x4350
jmp 0x8364
movq -0x128(%rbp), %rax
addq $0x3888, %rax           # imm = 0x3888
movq %rax, -0x130(%rbp)
leaq 0x27b86(%rip), %rdi     # 0x2fe08
leaq -0x130(%rbp), %rsi
callq 0x8530
leaq 0x27263(%rip), %rdi     # 0x2f4f8
leaq -0x128(%rbp), %rsi
callq 0x8fc0
movl -0x11c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x11c(%rbp)
jmp 0x81cf
movl $0x50, %edi
callq 0x4380
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x188(%rbp)
callq 0x7830
jmp 0x82d3
movq -0x188(%rbp), %rcx
leaq 0x271c7(%rip), %rax     # 0x2f4a8
movq %rcx, (%rax)
leaq 0x271bd(%rip), %rax     # 0x2f4a8
movq (%rax), %rdi
addq $0x40, %rdi
leaq 0x271af(%rip), %rax     # 0x2f4a8
movq (%rax), %rcx
xorl %eax, %eax
movl %eax, %esi
leaq -0x787(%rip), %rdx      # 0x7b80
callq 0x4630
cmpl $0x0, %eax
je 0x8333
jmp 0x82e4
movq -0x188(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd8(%rbp)
movl %eax, -0xdc(%rbp)
callq 0x4350
jmp 0x8364
leaq 0x2716e(%rip), %rax     # 0x2f4a8
movq (%rax), %rax
addq $0x48, %rax
movq %rax, -0x138(%rbp)
leaq 0x27ab9(%rip), %rdi     # 0x2fe08
leaq -0x138(%rbp), %rsi
callq 0x8530
addq $0x190, %rsp            # imm = 0x190
popq %rbp
retq
movq -0xd8(%rbp), %rdi
callq 0x45f0