// File: /workspace/github_cpp_makefile_star2_O2/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 0x10cf7(%rip), %rax     # 0x163c0
movq (%rax), %r14
movq 0x8(%rax), %r15
cmpq %r14, %r15
je 0x56f8
cmpq %r15, %r14
je 0x56f8
movq (%r14), %rbx
testq %rbx, %rbx
je 0x56ea
movq %rbx, %rdi
callq 0x4114
movq %rbx, %rdi
callq 0x3270
addq $0x8, %r14
jmp 0x56d5
leaq 0x10cd9(%rip), %rax     # 0x163d8
movq (%rax), %r14
movq 0x8(%rax), %r15
cmpq %r14, %r15
je 0x572e
cmpq %r15, %r14
je 0x572e
movq (%r14), %rbx
testq %rbx, %rbx
je 0x5720
movq %rbx, %rdi
callq 0x480a
movq %rbx, %rdi
callq 0x3270
addq $0x8, %r14
jmp 0x570b
leaq 0x10cbb(%rip), %rax     # 0x163f0
movq (%rax), %r14
movq 0x8(%rax), %r15
cmpq %r14, %r15
je 0x5764
cmpq %r15, %r14
je 0x5764
movq (%r14), %rbx
testq %rbx, %rbx
je 0x5756
movq %rbx, %rdi
callq 0x4cda
movq %rbx, %rdi
callq 0x3270
addq $0x8, %r14
jmp 0x5741
leaq 0x10c9d(%rip), %rax     # 0x16408
movq (%rax), %r14
movq 0x8(%rax), %r15
cmpq %r14, %r15
je 0x579a
cmpq %r15, %r14
je 0x579a
movq (%r14), %rbx
testq %rbx, %rbx
je 0x578c
movq %rbx, %rdi
callq 0x514e
movq %rbx, %rdi
callq 0x3270
addq $0x8, %r14
jmp 0x5777
leaq 0x10c17(%rip), %rax     # 0x163b8
movq (%rax), %rdi
testq %rdi, %rdi
je 0x57ae
callq 0x3270
leaq 0x10c0b(%rip), %rdi     # 0x163c0
xorl %r12d, %r12d
xorl %esi, %esi
xorl %edx, %edx
callq 0x618a
leaq 0x10c10(%rip), %rdi     # 0x163d8
xorl %esi, %esi
xorl %edx, %edx
callq 0x630a
leaq 0x10c18(%rip), %rdi     # 0x163f0
xorl %esi, %esi
xorl %edx, %edx
callq 0x648a
leaq 0x10c20(%rip), %rdi     # 0x16408
xorl %esi, %esi
xorl %edx, %edx
callq 0x660a
leaq 0x10b68(%rip), %r15     # 0x16360
leaq -0x18b(%rip), %r14      # 0x5674
leaq -0x30(%rbp), %r13
movq (%r15), %rax
movq 0x8(%rax), %rcx
cmpl 0xc(%rcx), %r12d
jge 0x5876
movl $0x38a8, %edi           # imm = 0x38A8
callq 0x3290
movq %rax, %rbx
movq %rax, %rdi
callq 0x403e
movq %rbx, -0x30(%rbp)
movq -0x30(%rbp), %rcx
leaq 0x3890(%rcx), %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x3460
testl %eax, %eax
jne 0x5829
movq -0x30(%rbp), %rax
movl $0x3888, %ecx           # imm = 0x3888
addq %rcx, %rax
movq %rax, -0x38(%rbp)
leaq 0x114bf(%rip), %rdi     # 0x16d18
leaq -0x38(%rbp), %rsi
callq 0x5ec2
leaq 0x10b57(%rip), %rdi     # 0x163c0
movq %r13, %rsi
callq 0x5c20
incl %r12d
jmp 0x5803
xorl %r12d, %r12d
leaq -0x1ff(%rip), %rbx      # 0x5681
leaq -0x30(%rbp), %r13
movq 0x10(%rax), %rcx
cmpl 0xc(%rcx), %r12d
jge 0x58f7
movl $0x38b0, %edi           # imm = 0x38B0
callq 0x3290
movq %rax, %r14
movq %rax, %rdi
callq 0x46d8
movq %r14, -0x30(%rbp)
movq -0x30(%rbp), %rcx
leaq 0x3890(%rcx), %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x3460
testl %eax, %eax
jne 0x58a7
movq -0x30(%rbp), %rax
movl $0x3888, %ecx           # imm = 0x3888
addq %rcx, %rax
movq %rax, -0x38(%rbp)
leaq 0x11441(%rip), %rdi     # 0x16d18
leaq -0x38(%rbp), %rsi
callq 0x5ec2
leaq 0x10af1(%rip), %rdi     # 0x163d8
movq %r13, %rsi
callq 0x5c44
incl %r12d
movq (%r15), %rax
jmp 0x5884
xorl %r12d, %r12d
leaq -0x273(%rip), %rbx      # 0x568e
leaq -0x30(%rbp), %r13
movq 0x18(%rax), %rcx
cmpl 0xc(%rcx), %r12d
jge 0x5978
movl $0x38b0, %edi           # imm = 0x38B0
callq 0x3290
movq %rax, %r14
movq %rax, %rdi
callq 0x4ba8
movq %r14, -0x30(%rbp)
movq -0x30(%rbp), %rcx
leaq 0x3890(%rcx), %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x3460
testl %eax, %eax
jne 0x5928
movq -0x30(%rbp), %rax
movl $0x3888, %ecx           # imm = 0x3888
addq %rcx, %rax
movq %rax, -0x38(%rbp)
leaq 0x113c0(%rip), %rdi     # 0x16d18
leaq -0x38(%rbp), %rsi
callq 0x5ec2
leaq 0x10a88(%rip), %rdi     # 0x163f0
movq %r13, %rsi
callq 0x5c68
incl %r12d
movq (%r15), %rax
jmp 0x5905
xorl %r12d, %r12d
leaq -0x2e7(%rip), %rbx      # 0x569b
leaq -0x30(%rbp), %r13
movq 0x20(%rax), %rax
cmpl 0xc(%rax), %r12d
jge 0x59f9
movl $0x38a8, %edi           # imm = 0x38A8
callq 0x3290
movq %rax, %r14
movq %rax, %rdi
callq 0x5078
movq %r14, -0x30(%rbp)
movq -0x30(%rbp), %rcx
leaq 0x3890(%rcx), %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x3460
testl %eax, %eax
jne 0x59a9
movq -0x30(%rbp), %rax
movl $0x3888, %ecx           # imm = 0x3888
addq %rcx, %rax
movq %rax, -0x38(%rbp)
leaq 0x1133f(%rip), %rdi     # 0x16d18
leaq -0x38(%rbp), %rsi
callq 0x5ec2
leaq 0x10a1f(%rip), %rdi     # 0x16408
movq %r13, %rsi
callq 0x5c8c
incl %r12d
movq (%r15), %rax
jmp 0x5986
pushq $0x50
popq %rdi
callq 0x3290
movq %rax, %rbx
movq %rax, %rdi
callq 0x5508
leaq 0x109a5(%rip), %r14     # 0x163b8
movq %rbx, (%r14)
leaq -0x375(%rip), %rbx      # 0x56a8
movq (%r14), %rcx
leaq 0x40(%rcx), %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x3460
testl %eax, %eax
jne 0x5a1d
movq (%r14), %rax
addq $0x48, %rax
leaq -0x30(%rbp), %rsi
movq %rax, (%rsi)
leaq 0x112d1(%rip), %rdi     # 0x16d18
callq 0x5ec2
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5a5f
jmp 0x5a5f
movq %rax, %r15
movq %r14, %rdi
jmp 0x5a6d
movq %rax, %r15
movq %rbx, %rdi
callq 0x3270
movq %r15, %rdi
callq 0x3440