// File: Ziang95[P]Tomasulo_simulator/output.cpp
// Function: output_automat(void*)
void* output_automat(void *args)
{
    next_vdd = 0;
    while (true)
    {
        at_rising_edge(next_vdd);
        at_falling_edge(next_vdd);
        if (sys_clk.is_instr_ended() && sys_clk.is_mem_ended())
        {
            pthread_mutex_lock(&cout_lock);
            for (auto s : CPU_output_Q)
                cout<<s.name<<endl;
            cout<<endl;
            memCell m;
            cout<<"\tINT_REG:\t\t\t\tFLP_REG:"<<endl;
            for (int i = 0; i<REG_NUM/2; i++)
            {
                stringstream tmp;
                reg->get("R"+to_string(2*i), m);
                cout<<setw(3)<<"R"+to_string(2*i)<<"="<<m.i<<(m.i>9999?"\t":"\t\t");
                if (2*i + 1 < REG_NUM)
                {
                    reg->get("R"+to_string(2*i+1), m);
                    cout<<setw(3)<<"R"+to_string(i*2+1)<<"="<<m.i<<(m.i>9999?"\t":"\t\t");
                }
                reg->get("F"+to_string(2*i), m);
                cout<<"\t"<<setw(3)<<"F"+to_string(2*i)<<"="<<fixed<<setprecision(2)<<m.f<<"\t";
                if (2*i + 1 < REG_NUM)
                {
                    reg->get("F"+to_string(2*i+1), m);
                    cout<<setw(3)<<"F"+to_string(2*i+1)<<"="<<fixed<<setprecision(2)<<m.f<<"\t";
                }
                cout<<endl;
            }
            cout<<endl;
            for (int i = 0; i<MEM_LEN; i++)
            {
                if (abs(main_mem.getMem(i).f) > 0.001)
                    cout<<"Mem["<<i<<"]="<<fixed<<setprecision(2)<<main_mem.getMem(i).f<<", ";
            }
            cout<<endl<<endl;
            pthread_mutex_unlock(&cout_lock);
            return nullptr;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x540, %rsp            # imm = 0x540
movq %rdi, -0x8(%rbp)
movl $0x0, 0x158b3(%rip)     # 0x32edc
leaq 0x158ac(%rip), %rdi     # 0x32edc
callq 0x12130
leaq 0x158a0(%rip), %rdi     # 0x32edc
callq 0x121a0
leaq 0x12750(%rip), %rdi     # 0x2fd98
callq 0x116e0
testb $0x1, %al
jne 0x1d656
jmp 0x1e160
leaq 0x1273b(%rip), %rdi     # 0x2fd98
callq 0x11720
testb $0x1, %al
jne 0x1d66b
jmp 0x1e160
leaq 0x11d16(%rip), %rdi     # 0x2f388
callq 0x4510
leaq 0x1583a(%rip), %rax     # 0x32eb8
movq %rax, -0x10(%rbp)
leaq 0x1582f(%rip), %rdi     # 0x32eb8
callq 0x1f590
movq %rax, -0x18(%rbp)
leaq 0x1581f(%rip), %rdi     # 0x32eb8
callq 0x1f5c0
movq %rax, -0x20(%rbp)
leaq -0x18(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x1f5f0
testb $0x1, %al
jne 0x1d6b5
jmp 0x1d726
leaq -0x18(%rbp), %rdi
callq 0x1f630
movq %rax, %rsi
leaq -0x48(%rbp), %rdi
callq 0x1f650
leaq -0x40(%rbp), %rsi
movq 0x118eb(%rip), %rdi     # 0x2efc0
callq 0x4340
movq %rax, -0x430(%rbp)
jmp 0x1d6e3
movq -0x430(%rbp), %rdi
movq 0x118b7(%rip), %rsi     # 0x2efa8
callq 0x43a0
jmp 0x1d6f8
leaq -0x48(%rbp), %rdi
callq 0x1cec0
leaq -0x18(%rbp), %rdi
callq 0x1f690
jmp 0x1d6a2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x1cec0
jmp 0x1e165
movq 0x11893(%rip), %rdi     # 0x2efc0
movq 0x11874(%rip), %rsi     # 0x2efa8
callq 0x43a0
movq 0x11880(%rip), %rdi     # 0x2efc0
leaq 0x525c(%rip), %rsi      # 0x229a3
callq 0x4370
movq %rax, %rdi
movq 0x11852(%rip), %rsi     # 0x2efa8
callq 0x43a0
movl $0x0, -0x5c(%rbp)
cmpl $0x10, -0x5c(%rbp)
jge 0x1dfff
leaq -0x1e8(%rbp), %rdi
callq 0x4280
leaq 0x12611(%rip), %rax     # 0x2fd90
movq (%rax), %rax
movq %rax, -0x438(%rbp)
movl -0x5c(%rbp), %esi
addl %esi, %esi
leaq -0x228(%rbp), %rdi
callq 0x8410
jmp 0x1d79c
leaq 0x5216(%rip), %rsi      # 0x229b9
leaq -0x208(%rbp), %rdi
leaq -0x228(%rbp), %rdx
callq 0x83c0
jmp 0x1d7b8
movq -0x438(%rbp), %rdi
leaq -0x208(%rbp), %rsi
leaq -0x58(%rbp), %rdx
callq 0x206c0
jmp 0x1d7d1
leaq -0x208(%rbp), %rdi
callq 0x4240
leaq -0x228(%rbp), %rdi
callq 0x4240
movl $0x3, %edi
callq 0x1f6b0
movl %eax, -0x43c(%rbp)
jmp 0x1d7fb
movl -0x43c(%rbp), %eax
movl %eax, -0x22c(%rbp)
movl -0x22c(%rbp), %esi
movq 0x117ac(%rip), %rdi     # 0x2efc0
callq 0x4400
movq %rax, -0x448(%rbp)
jmp 0x1d822
movl -0x5c(%rbp), %esi
addl %esi, %esi
leaq -0x270(%rbp), %rdi
callq 0x8410
jmp 0x1d835
leaq 0x517d(%rip), %rsi      # 0x229b9
leaq -0x250(%rbp), %rdi
leaq -0x270(%rbp), %rdx
callq 0x83c0
jmp 0x1d851
movq -0x448(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0x4340
movq %rax, -0x450(%rbp)
jmp 0x1d86d
movq -0x450(%rbp), %rdi
leaq 0x5148(%rip), %rsi      # 0x229c3
callq 0x4370
movq %rax, -0x458(%rbp)
jmp 0x1d889
movq -0x458(%rbp), %rdi
movl -0x58(%rbp), %esi
callq 0x45e0
movq %rax, -0x460(%rbp)
jmp 0x1d8a1
movq -0x460(%rbp), %rdi
movl -0x58(%rbp), %eax
subl $0x2710, %eax           # imm = 0x2710
leaq 0x50ea(%rip), %rax      # 0x229a1
leaq 0x50e2(%rip), %rsi      # 0x229a0
cmovgeq %rax, %rsi
callq 0x4370
jmp 0x1d8c9
leaq -0x250(%rbp), %rdi
callq 0x4240
leaq -0x270(%rbp), %rdi
callq 0x4240
movl -0x5c(%rbp), %eax
shll %eax
addl $0x1, %eax
cmpl $0x20, %eax
jge 0x1db55
leaq 0x12497(%rip), %rax     # 0x2fd90
movq (%rax), %rax
movq %rax, -0x468(%rbp)
movl -0x5c(%rbp), %ecx
movl %ecx, %eax
leal 0x1(%rax,%rax), %esi
leaq -0x2b0(%rbp), %rdi
callq 0x8410
jmp 0x1d91a
leaq 0x5098(%rip), %rsi      # 0x229b9
leaq -0x290(%rbp), %rdi
leaq -0x2b0(%rbp), %rdx
callq 0x83c0
jmp 0x1d936
movq -0x468(%rbp), %rdi
leaq -0x290(%rbp), %rsi
leaq -0x58(%rbp), %rdx
callq 0x206c0
jmp 0x1d94f
leaq -0x290(%rbp), %rdi
callq 0x4240
leaq -0x2b0(%rbp), %rdi
callq 0x4240
movl $0x3, %edi
callq 0x1f6b0
movl %eax, -0x46c(%rbp)
jmp 0x1d979
movl -0x46c(%rbp), %eax
movl %eax, -0x2b4(%rbp)
movl -0x2b4(%rbp), %esi
movq 0x1162e(%rip), %rdi     # 0x2efc0
callq 0x4400
movq %rax, -0x478(%rbp)
jmp 0x1d9a0
movl -0x5c(%rbp), %ecx
movl %ecx, %eax
leal 0x1(%rax,%rax), %esi
leaq -0x2f8(%rbp), %rdi
callq 0x8410
jmp 0x1d9b7
leaq 0x4ffb(%rip), %rsi      # 0x229b9
leaq -0x2d8(%rbp), %rdi
leaq -0x2f8(%rbp), %rdx
callq 0x83c0
jmp 0x1d9d3
movq -0x478(%rbp), %rdi
leaq -0x2d8(%rbp), %rsi
callq 0x4340
movq %rax, -0x480(%rbp)
jmp 0x1d9ef
movq -0x480(%rbp), %rdi
leaq 0x4fc6(%rip), %rsi      # 0x229c3
callq 0x4370
movq %rax, -0x488(%rbp)
jmp 0x1da0b
movq -0x488(%rbp), %rdi
movl -0x58(%rbp), %esi
callq 0x45e0
movq %rax, -0x490(%rbp)
jmp 0x1da23
movq -0x490(%rbp), %rdi
movl -0x58(%rbp), %eax
subl $0x2710, %eax           # imm = 0x2710
leaq 0x4f68(%rip), %rax      # 0x229a1
leaq 0x4f60(%rip), %rsi      # 0x229a0
cmovgeq %rax, %rsi
callq 0x4370
jmp 0x1da4b
leaq -0x2d8(%rbp), %rdi
callq 0x4240
leaq -0x2f8(%rbp), %rdi
callq 0x4240
jmp 0x1db55
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1dfee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1da9f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x208(%rbp), %rdi
callq 0x4240
leaq -0x228(%rbp), %rdi
callq 0x4240
jmp 0x1dfee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1dad6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x250(%rbp), %rdi
callq 0x4240
leaq -0x270(%rbp), %rdi
callq 0x4240
jmp 0x1dfee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1db0d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x290(%rbp), %rdi
callq 0x4240
leaq -0x2b0(%rbp), %rdi
callq 0x4240
jmp 0x1dfee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1db44
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x2d8(%rbp), %rdi
callq 0x4240
leaq -0x2f8(%rbp), %rdi
callq 0x4240
jmp 0x1dfee
leaq 0x12234(%rip), %rax     # 0x2fd90
movq (%rax), %rax
movq %rax, -0x498(%rbp)
movl -0x5c(%rbp), %esi
addl %esi, %esi
leaq -0x338(%rbp), %rdi
callq 0x8410
jmp 0x1db79
leaq 0x4e3b(%rip), %rsi      # 0x229bb
leaq -0x318(%rbp), %rdi
leaq -0x338(%rbp), %rdx
callq 0x83c0
jmp 0x1db95
movq -0x498(%rbp), %rdi
leaq -0x318(%rbp), %rsi
leaq -0x58(%rbp), %rdx
callq 0x206c0
jmp 0x1dbae
leaq -0x318(%rbp), %rdi
callq 0x4240
leaq -0x338(%rbp), %rdi
callq 0x4240
movq 0x113f3(%rip), %rdi     # 0x2efc0
leaq 0x4dcd(%rip), %rsi      # 0x229a1
callq 0x4370
movq %rax, -0x4a0(%rbp)
jmp 0x1dbe2
movl $0x3, %edi
callq 0x1f6b0
movl %eax, -0x4a4(%rbp)
jmp 0x1dbf4
movq -0x4a0(%rbp), %rdi
movl -0x4a4(%rbp), %eax
movl %eax, -0x33c(%rbp)
movl -0x33c(%rbp), %esi
callq 0x4400
movq %rax, -0x4b0(%rbp)
jmp 0x1dc1b
movl -0x5c(%rbp), %esi
addl %esi, %esi
leaq -0x380(%rbp), %rdi
callq 0x8410
jmp 0x1dc2e
leaq 0x4d86(%rip), %rsi      # 0x229bb
leaq -0x360(%rbp), %rdi
leaq -0x380(%rbp), %rdx
callq 0x83c0
jmp 0x1dc4a
movq -0x4b0(%rbp), %rdi
leaq -0x360(%rbp), %rsi
callq 0x4340
movq %rax, -0x4b8(%rbp)
jmp 0x1dc66
movq -0x4b8(%rbp), %rdi
leaq 0x4d4f(%rip), %rsi      # 0x229c3
callq 0x4370
movq %rax, -0x4c0(%rbp)
jmp 0x1dc82
movq -0x4c0(%rbp), %rdi
leaq 0x1a40(%rip), %rsi      # 0x1f6d0
callq 0x4120
movq %rax, -0x4c8(%rbp)
jmp 0x1dc9e
movl $0x2, %edi
callq 0x1f700
movl %eax, -0x4cc(%rbp)
jmp 0x1dcb0
movq -0x4c8(%rbp), %rdi
movl -0x4cc(%rbp), %eax
movl %eax, -0x384(%rbp)
movl -0x384(%rbp), %esi
callq 0x4560
movq %rax, -0x4d8(%rbp)
jmp 0x1dcd7
movq -0x4d8(%rbp), %rdi
movss -0x58(%rbp), %xmm0
callq 0x42a0
movq %rax, -0x4e0(%rbp)
jmp 0x1dcf1
movq -0x4e0(%rbp), %rdi
leaq 0x4ca2(%rip), %rsi      # 0x229a1
callq 0x4370
jmp 0x1dd06
leaq -0x360(%rbp), %rdi
callq 0x4240
leaq -0x380(%rbp), %rdi
callq 0x4240
movl -0x5c(%rbp), %eax
shll %eax
addl $0x1, %eax
cmpl $0x20, %eax
jge 0x1dfbf
leaq 0x1205a(%rip), %rax     # 0x2fd90
movq (%rax), %rax
movq %rax, -0x4e8(%rbp)
movl -0x5c(%rbp), %ecx
movl %ecx, %eax
leal 0x1(%rax,%rax), %esi
leaq -0x3c8(%rbp), %rdi
callq 0x8410
jmp 0x1dd57
leaq 0x4c5d(%rip), %rsi      # 0x229bb
leaq -0x3a8(%rbp), %rdi
leaq -0x3c8(%rbp), %rdx
callq 0x83c0
jmp 0x1dd73
movq -0x4e8(%rbp), %rdi
leaq -0x3a8(%rbp), %rsi
leaq -0x58(%rbp), %rdx
callq 0x206c0
jmp 0x1dd8c
leaq -0x3a8(%rbp), %rdi
callq 0x4240
leaq -0x3c8(%rbp), %rdi
callq 0x4240
movl $0x3, %edi
callq 0x1f6b0
movl %eax, -0x4ec(%rbp)
jmp 0x1ddb6
movl -0x4ec(%rbp), %eax
movl %eax, -0x3cc(%rbp)
movl -0x3cc(%rbp), %esi
movq 0x111f1(%rip), %rdi     # 0x2efc0
callq 0x4400
movq %rax, -0x4f8(%rbp)
jmp 0x1dddd
movl -0x5c(%rbp), %ecx
movl %ecx, %eax
leal 0x1(%rax,%rax), %esi
leaq -0x410(%rbp), %rdi
callq 0x8410
jmp 0x1ddf4
leaq 0x4bc0(%rip), %rsi      # 0x229bb
leaq -0x3f0(%rbp), %rdi
leaq -0x410(%rbp), %rdx
callq 0x83c0
jmp 0x1de10
movq -0x4f8(%rbp), %rdi
leaq -0x3f0(%rbp), %rsi
callq 0x4340
movq %rax, -0x500(%rbp)
jmp 0x1de2c
movq -0x500(%rbp), %rdi
leaq 0x4b89(%rip), %rsi      # 0x229c3
callq 0x4370
movq %rax, -0x508(%rbp)
jmp 0x1de48
movq -0x508(%rbp), %rdi
leaq 0x187a(%rip), %rsi      # 0x1f6d0
callq 0x4120
movq %rax, -0x510(%rbp)
jmp 0x1de64
movl $0x2, %edi
callq 0x1f700
movl %eax, -0x514(%rbp)
jmp 0x1de76
movq -0x510(%rbp), %rdi
movl -0x514(%rbp), %eax
movl %eax, -0x414(%rbp)
movl -0x414(%rbp), %esi
callq 0x4560
movq %rax, -0x520(%rbp)
jmp 0x1de9d
movq -0x520(%rbp), %rdi
movss -0x58(%rbp), %xmm0
callq 0x42a0
movq %rax, -0x528(%rbp)
jmp 0x1deb7
movq -0x528(%rbp), %rdi
leaq 0x4adc(%rip), %rsi      # 0x229a1
callq 0x4370
jmp 0x1decc
leaq -0x3f0(%rbp), %rdi
callq 0x4240
leaq -0x410(%rbp), %rdi
callq 0x4240
jmp 0x1dfbf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1df0f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x318(%rbp), %rdi
callq 0x4240
leaq -0x338(%rbp), %rdi
callq 0x4240
jmp 0x1dfee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1df46
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x360(%rbp), %rdi
callq 0x4240
leaq -0x380(%rbp), %rdi
callq 0x4240
jmp 0x1dfee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1df7d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x3a8(%rbp), %rdi
callq 0x4240
leaq -0x3c8(%rbp), %rdi
callq 0x4240
jmp 0x1dfee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1dfb1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x3f0(%rbp), %rdi
callq 0x4240
leaq -0x410(%rbp), %rdi
callq 0x4240
jmp 0x1dfee
movq 0x10ffa(%rip), %rdi     # 0x2efc0
movq 0x10fdb(%rip), %rsi     # 0x2efa8
callq 0x43a0
jmp 0x1dfd4
leaq -0x1e8(%rbp), %rdi
callq 0x42b0
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x1d762
leaq -0x1e8(%rbp), %rdi
callq 0x42b0
jmp 0x1e165
movq 0x10fba(%rip), %rdi     # 0x2efc0
movq 0x10f9b(%rip), %rsi     # 0x2efa8
callq 0x43a0
movl $0x0, -0x418(%rbp)
cmpl $0x100, -0x418(%rbp)    # imm = 0x100
jge 0x1e127
movl -0x418(%rbp), %esi
leaq 0x11de7(%rip), %rdi     # 0x2fe20
callq 0x1b2e0
movl %eax, -0x41c(%rbp)
movss -0x41c(%rbp), %xmm0
callq 0x1f720
cvtss2sd %xmm0, %xmm0
movsd 0x4923(%rip), %xmm1     # 0x22980
ucomisd %xmm1, %xmm0
jbe 0x1e111
movq 0x10f52(%rip), %rdi     # 0x2efc0
leaq 0x4948(%rip), %rsi      # 0x229bd
callq 0x4370
movq %rax, %rdi
movl -0x418(%rbp), %esi
callq 0x45e0
movq %rax, %rdi
leaq 0x4930(%rip), %rsi      # 0x229c2
callq 0x4370
movq %rax, %rdi
leaq 0x162f(%rip), %rsi      # 0x1f6d0
callq 0x4120
movq %rax, -0x538(%rbp)
movl $0x2, %edi
callq 0x1f700
movq -0x538(%rbp), %rdi
movl %eax, -0x420(%rbp)
movl -0x420(%rbp), %esi
callq 0x4560
movq %rax, -0x530(%rbp)
movl -0x418(%rbp), %esi
leaq 0x11d3d(%rip), %rdi     # 0x2fe20
callq 0x1b2e0
movq -0x530(%rbp), %rdi
movl %eax, -0x424(%rbp)
movss -0x424(%rbp), %xmm0
callq 0x42a0
movq %rax, %rdi
leaq 0x4226(%rip), %rsi      # 0x22332
callq 0x4370
jmp 0x1e113
movl -0x418(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x418(%rbp)
jmp 0x1e01c
movq 0x10e92(%rip), %rdi     # 0x2efc0
movq 0x10e73(%rip), %rsi     # 0x2efa8
callq 0x43a0
movq %rax, %rdi
movq 0x10e64(%rip), %rsi     # 0x2efa8
callq 0x43a0
leaq 0x11238(%rip), %rdi     # 0x2f388
callq 0x42c0
xorl %eax, %eax
addq $0x540, %rsp            # imm = 0x540
popq %rbp
retq
jmp 0x1d629
movq -0x50(%rbp), %rdi
callq 0x45f0
nop