// File: /workspace/github_cpp_makefile_star2_O2/Ziang95[P]Tomasulo_simulator/FU.cpp
// Function: ldsdUnit::FU_automat()
void ldsdUnit::FU_automat()
{
    next_vdd = 0;
    while (true)
    {
A:      at_rising_edge(next_vdd);
        if (squash_p.flag)
        {
            squash_p.flag = false;
            at_falling_edge(next_vdd);
            continue;
        }
        auto newTask = queue.deQ();
        if (newTask)
        {
            task = *newTask;
            ROBEntry *R = CPU_ROB->get_entry(task.dest);
            R->output.exe = sys_clk.get_prog_cyc();
            for (int i = 0; ;i++)
            {
                if (squash_p.flag)
                {
                    squash_p.flag = false;
                    if (is_prev_index(squash_p.ROB_i, task.dest, squash_p.R_f, squash_p.R_r))
                        break;
                }
                msg_log("Calculating address "+to_string(task.oprnd1->i)+" + "+to_string(task.offset) + ", ROB = " + to_string(task.dest), 3);
                if (i == CPU_cfg->ld_str->exe_time - 1)
                {
                    task.lsqe->addr = task.oprnd1->i + task.offset;
                    if (task.code == SD)
                    {
                        *task.busy = false;
                        if (task.lsqe->SD_source == -1)
                        {
                            at_falling_edge(next_vdd);
                            task.lsqe->ready = true;
                            R->finished = true;
                            goto A;
                        }
                    }
                    else
                    {
                        at_falling_edge(next_vdd);
                        task.lsqe->ready = true;
                        goto A;
                    }
                    break;
                }
                at_falling_edge(next_vdd);
                at_rising_edge(next_vdd);
            }
        }
        at_falling_edge(next_vdd);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %rdi, %r15
andl $0x0, 0x3888(%rdi)
leaq 0x3888(%rdi), %r14
leaq 0x8(%rdi), %rax
movq %rax, -0x50(%rbp)
leaq 0x3838(%rdi), %rax
movq %rax, -0x40(%rbp)
leaq -0x150(%rbp), %r13
movq %r14, -0x38(%rbp)
movq %r14, %rdi
callq 0x83e0
cmpb $0x1, 0x38a4(%r15)
jne 0x51fe
movb $0x0, 0x38a4(%r15)
jmp 0x5438
movq -0x50(%rbp), %rdi
callq 0x3f84
testq %rax, %rax
je 0x5438
movq 0x30(%rax), %rcx
movq -0x40(%rbp), %rdx
movq %rcx, 0x30(%rdx)
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups 0x20(%rax), %xmm2
movups %xmm2, 0x20(%rdx)
movups %xmm1, 0x10(%rdx)
movups %xmm0, (%rdx)
leaq 0x11137(%rip), %rax     # 0x16370
movq (%rax), %rdi
movl 0x383c(%r15), %esi
callq 0x6c7e
movq %rax, %rbx
leaq 0x11a56(%rip), %rdi     # 0x16ca8
callq 0x7e24
movq %rbx, -0x48(%rbp)
movl %eax, 0x54(%rbx)
movl $0x0, -0x2c(%rbp)
cmpb $0x1, 0x38a4(%r15)
jne 0x52a0
movb $0x0, 0x38a4(%r15)
movl 0x38a0(%r15), %edi
movl 0x383c(%r15), %esi
movl 0x3898(%r15), %edx
movl 0x389c(%r15), %ecx
callq 0xc3de
testb %al, %al
jne 0x5438
movq %r13, %rbx
movq %r15, %r12
movq 0x3848(%r15), %rax
movl (%rax), %esi
leaq -0xf0(%rbp), %r15
movq %r15, %rdi
callq 0x5ab8
leaq -0x110(%rbp), %r14
movq %r14, %rdi
leaq 0x9dc0(%rip), %rsi      # 0xf08f
movq %r15, %rdx
callq 0x5a8a
leaq -0x70(%rbp), %rdi
movq %r14, %rsi
leaq 0x9d6f(%rip), %rdx      # 0xf054
callq 0x5bc8
movl 0x3860(%r12), %esi
leaq -0xd0(%rbp), %r14
movq %r14, %rdi
callq 0x5ab8
leaq -0x130(%rbp), %r13
movq %r13, %rdi
leaq -0x70(%rbp), %rsi
movq %r14, %rdx
callq 0x5b57
leaq -0x90(%rbp), %rdi
movq %r13, %rsi
leaq 0xa445(%rip), %rdx      # 0xf76d
callq 0x5bc8
movq %r13, %r14
movl 0x383c(%r12), %esi
leaq -0xb0(%rbp), %r15
movq %r15, %rdi
callq 0x5ab8
movq %rbx, %rdi
leaq -0x90(%rbp), %rsi
movq %r15, %rdx
callq 0x5b57
movq %rbx, %rdi
pushq $0x3
popq %rsi
callq 0x8343
movq %rbx, %r13
movq %rbx, %rdi
callq 0x3140
leaq -0xb0(%rbp), %rdi
callq 0x3140
leaq -0x90(%rbp), %rdi
callq 0x3140
movq %r14, %rdi
callq 0x3140
leaq -0xd0(%rbp), %rdi
callq 0x3140
leaq -0x70(%rbp), %rdi
callq 0x3140
leaq -0x110(%rbp), %rdi
callq 0x3140
leaq -0xf0(%rbp), %rdi
callq 0x3140
leaq 0x10f9d(%rip), %rax     # 0x16360
movq (%rax), %rax
movq 0x20(%rax), %rax
movl 0x4(%rax), %eax
decl %eax
movl -0x2c(%rbp), %ecx
cmpl %eax, %ecx
je 0x53f9
movq -0x38(%rbp), %r14
movq %r14, %rdi
movl %ecx, %ebx
callq 0x8437
movq %r14, %rdi
callq 0x83e0
incl %ebx
movl %ebx, -0x2c(%rbp)
movq %r12, %r15
jmp 0x5265
movq %r12, %r15
movl 0x3860(%r12), %ecx
movq 0x3848(%r12), %rax
addl (%rax), %ecx
movq 0x3858(%r12), %rax
movl %ecx, 0x10(%rax)
cmpl $0x7, 0x3838(%r12)
movq -0x38(%rbp), %r14
jne 0x5445
movq 0x3868(%r15), %rcx
movb $0x0, (%rcx)
cmpl $-0x1, 0x4(%rax)
je 0x545d
movq %r14, %rdi
callq 0x8437
jmp 0x51df
movq %r14, %rdi
callq 0x8437
movq 0x3858(%r15), %rax
movb $0x1, 0x14(%rax)
jmp 0x51df
movq %r14, %rdi
callq 0x8437
movq 0x3858(%r15), %rax
movb $0x1, %cl
movb %cl, 0x14(%rax)
movq -0x48(%rbp), %rax
movb %cl, (%rax)
jmp 0x51df
movq %rax, %rbx
jmp 0x54b2
movq %rax, %rbx
jmp 0x54a6
movq %rax, %rbx
jmp 0x549a
movq %rax, %rbx
leaq -0x150(%rbp), %rdi
callq 0x3140
leaq -0xb0(%rbp), %rdi
callq 0x3140
leaq -0x90(%rbp), %rdi
callq 0x3140
leaq -0x130(%rbp), %rdi
callq 0x3140
jmp 0x54d2
movq %rax, %rbx
jmp 0x54f3
movq %rax, %rbx
jmp 0x54e7
movq %rax, %rbx
jmp 0x54de
movq %rax, %rbx
leaq -0xd0(%rbp), %rdi
callq 0x3140
leaq -0x70(%rbp), %rdi
callq 0x3140
leaq -0x110(%rbp), %rdi
callq 0x3140
leaq -0xf0(%rbp), %rdi
callq 0x3140
movq %rbx, %rdi
callq 0x3440
nop