// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
leaq 0x148af(%rip), %rax     # 0x1b3b8
movq (%rax), %r14
movq 0x8(%rax), %r15
cmpq %r14, %r15
je 0x6b36
movq (%r14), %rbx
testq %rbx, %rbx
je 0x6b2d
movq %rbx, %rdi
callq 0x450e
movq %rbx, %rdi
callq 0x3230
addq $0x8, %r14
cmpq %r15, %r14
jne 0x6b15
leaq 0x14893(%rip), %rax     # 0x1b3d0
movq (%rax), %r14
movq 0x8(%rax), %r15
cmpq %r14, %r15
je 0x6b6a
movq (%r14), %rbx
testq %rbx, %rbx
je 0x6b61
movq %rbx, %rdi
callq 0x5272
movq %rbx, %rdi
callq 0x3230
addq $0x8, %r14
cmpq %r15, %r14
jne 0x6b49
leaq 0x14877(%rip), %rax     # 0x1b3e8
movq (%rax), %r14
movq 0x8(%rax), %r15
cmpq %r14, %r15
je 0x6b9e
movq (%r14), %rbx
testq %rbx, %rbx
je 0x6b95
movq %rbx, %rdi
callq 0x59ce
movq %rbx, %rdi
callq 0x3230
addq $0x8, %r14
cmpq %r15, %r14
jne 0x6b7d
leaq 0x1485b(%rip), %rax     # 0x1b400
movq (%rax), %r14
movq 0x8(%rax), %r15
cmpq %r14, %r15
je 0x6bd2
movq (%r14), %rbx
testq %rbx, %rbx
je 0x6bc9
movq %rbx, %rdi
callq 0x60ca
movq %rbx, %rdi
callq 0x3230
addq $0x8, %r14
cmpq %r15, %r14
jne 0x6bb1
leaq 0x147d7(%rip), %rax     # 0x1b3b0
movq (%rax), %rdi
testq %rdi, %rdi
je 0x6be6
callq 0x3230
leaq 0x147cb(%rip), %r12     # 0x1b3b8
xorl %r15d, %r15d
movq %r12, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x7510
leaq 0x147cd(%rip), %rdi     # 0x1b3d0
xorl %esi, %esi
xorl %edx, %edx
callq 0x762a
leaq 0x147d5(%rip), %rdi     # 0x1b3e8
xorl %esi, %esi
xorl %edx, %edx
callq 0x7744
leaq 0x147dd(%rip), %rdi     # 0x1b400
xorl %esi, %esi
xorl %edx, %edx
callq 0x785e
leaq 0x14725(%rip), %rax     # 0x1b358
movq (%rax), %rax
movq 0x8(%rax), %rax
cmpl $0x0, 0xc(%rax)
jle 0x6cf6
leaq -0x197(%rip), %r13      # 0x6ab4
leaq 0x150be(%rip), %rbx     # 0x1bd10
movl $0x38a8, %edi           # imm = 0x38A8
callq 0x3250
movq %rax, %r14
movq %rax, %rdi
callq 0x43f2
movq %r14, -0x30(%rbp)
movq -0x30(%rbp), %rcx
leaq 0x3890(%rcx), %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x3460
testl %eax, %eax
jne 0x6c6b
movq -0x30(%rbp), %rax
movl $0x3888, %ecx           # imm = 0x3888
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x6ca8
movq %rax, (%rsi)
addq $0x8, 0x8(%rbx)
jmp 0x6cb4
movq %rbx, %rdi
leaq -0x38(%rbp), %rdx
callq 0x729c
movq 0x8(%r12), %rsi
cmpq 0x10(%r12), %rsi
je 0x6ccf
movq -0x30(%rbp), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%r12)
jmp 0x6cdb
movq %r12, %rdi
leaq -0x30(%rbp), %rdx
callq 0x7978
incl %r15d
leaq 0x14673(%rip), %rax     # 0x1b358
movq (%rax), %rax
movq 0x8(%rax), %rax
cmpl 0xc(%rax), %r15d
jl 0x6c52
leaq 0x1465b(%rip), %rax     # 0x1b358
movq (%rax), %rax
movq 0x10(%rax), %rax
cmpl $0x0, 0xc(%rax)
jle 0x6dcc
xorl %r15d, %r15d
leaq -0x257(%rip), %r12      # 0x6ac1
movl $0x3888, %r13d          # imm = 0x3888
leaq 0x14feb(%rip), %rbx     # 0x1bd10
movl $0x38b0, %edi           # imm = 0x38B0
callq 0x3250
movq %rax, %r14
movq %rax, %rdi
callq 0x50f6
movq %r14, -0x30(%rbp)
movq -0x30(%rbp), %rcx
leaq 0x3890(%rcx), %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x3460
testl %eax, %eax
jne 0x6d3e
movq -0x30(%rbp), %rax
addq %r13, %rax
movq %rax, -0x38(%rbp)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x6d76
movq %rax, (%rsi)
addq $0x8, 0x8(%rbx)
jmp 0x6d82
movq %rbx, %rdi
leaq -0x38(%rbp), %rdx
callq 0x729c
leaq 0x14647(%rip), %rcx     # 0x1b3d0
movq 0x8(%rcx), %rsi
cmpq 0x10(%rcx), %rsi
je 0x6da1
movq -0x30(%rbp), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%rcx)
jmp 0x6db1
leaq 0x14628(%rip), %rdi     # 0x1b3d0
leaq -0x30(%rbp), %rdx
callq 0x7a94
incl %r15d
leaq 0x1459d(%rip), %rax     # 0x1b358
movq (%rax), %rax
movq 0x10(%rax), %rax
cmpl 0xc(%rax), %r15d
jl 0x6d25
leaq 0x14585(%rip), %rax     # 0x1b358
movq (%rax), %rax
movq 0x18(%rax), %rax
cmpl $0x0, 0xc(%rax)
jle 0x6e9b
xorl %r12d, %r12d
leaq -0x320(%rip), %r15      # 0x6ace
movl $0x3888, %r13d          # imm = 0x3888
leaq 0x14f15(%rip), %rbx     # 0x1bd10
movl $0x38b0, %edi           # imm = 0x38B0
callq 0x3250
movq %rax, %r14
movq %rax, %rdi
callq 0x5852
movq %r14, -0x30(%rbp)
movq -0x30(%rbp), %rcx
leaq 0x3890(%rcx), %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x3460
testl %eax, %eax
jne 0x6e14
movq -0x30(%rbp), %rax
addq %r13, %rax
movq %rax, -0x38(%rbp)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x6e4c
movq %rax, (%rsi)
addq $0x8, 0x8(%rbx)
jmp 0x6e58
movq %rbx, %rdi
leaq -0x38(%rbp), %rdx
callq 0x729c
leaq 0x14589(%rip), %rdi     # 0x1b3e8
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x6e77
movq -0x30(%rbp), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0x6e80
leaq -0x30(%rbp), %rdx
callq 0x7bb0
incl %r12d
leaq 0x144ce(%rip), %rax     # 0x1b358
movq (%rax), %rax
movq 0x18(%rax), %rax
cmpl 0xc(%rax), %r12d
jl 0x6dfb
leaq 0x144b6(%rip), %rax     # 0x1b358
movq (%rax), %rax
movq 0x20(%rax), %rax
cmpl $0x0, 0xc(%rax)
jle 0x6f6d
xorl %r15d, %r15d
leaq -0x3e2(%rip), %r14      # 0x6adb
movl $0x3888, %r12d          # imm = 0x3888
leaq 0x14e46(%rip), %rbx     # 0x1bd10
movl $0x38a8, %edi           # imm = 0x38A8
callq 0x3250
movq %rax, %r13
movq %rax, %rdi
callq 0x5fae
movq %r13, -0x30(%rbp)
movq -0x30(%rbp), %rcx
leaq 0x3890(%rcx), %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x3460
testl %eax, %eax
jne 0x6ee3
movq -0x30(%rbp), %rax
addq %r12, %rax
movq %rax, -0x38(%rbp)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
leaq 0x144ea(%rip), %r13     # 0x1b400
je 0x6f22
movq %rax, (%rsi)
addq $0x8, 0x8(%rbx)
jmp 0x6f2e
movq %rbx, %rdi
leaq -0x38(%rbp), %rdx
callq 0x729c
movq 0x8(%r13), %rsi
cmpq 0x10(%r13), %rsi
je 0x6f46
movq -0x30(%rbp), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%r13)
jmp 0x6f52
movq %r13, %rdi
leaq -0x30(%rbp), %rdx
callq 0x7ccc
incl %r15d
leaq 0x143fc(%rip), %rax     # 0x1b358
movq (%rax), %rax
movq 0x20(%rax), %rax
cmpl 0xc(%rax), %r15d
jl 0x6eca
movl $0x50, %edi
callq 0x3250
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq $0x0, 0x8(%rax)
movl $0x18, %ecx
movl $0xffffffff, -0x8(%rax,%rcx) # imm = 0xFFFFFFFF
movq $0x0, (%rax,%rcx)
addq $0x10, %rcx
cmpq $0x48, %rcx
jne 0x6f8a
leaq 0x14405(%rip), %r14     # 0x1b3b0
movq %rax, (%r14)
leaq -0x4cd(%rip), %rbx      # 0x6ae8
movq (%r14), %rcx
leaq 0x40(%rcx), %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x3460
testl %eax, %eax
jne 0x6fb5
movq (%r14), %rax
addq $0x48, %rax
movq %rax, -0x30(%rbp)
leaq 0x14d34(%rip), %rcx     # 0x1bd10
movq 0x8(%rcx), %rsi
cmpq 0x10(%rcx), %rsi
je 0x6ff0
movq %rax, (%rsi)
addq $0x8, 0x8(%rcx)
jmp 0x7000
leaq 0x14d19(%rip), %rdi     # 0x1bd10
leaq -0x30(%rbp), %rdx
callq 0x729c
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq %r13, %rdi
jmp 0x7021
jmp 0x701b
jmp 0x701b
movq %rax, %rbx
movq %r14, %rdi
callq 0x3230
movq %rbx, %rdi
callq 0x3440