// File: /workspace/github_cpp_makefile_star2_O2/ys1998[P]spsim/src/main.cpp
// Function: print_std(std::deque<Instruction, std::allocator<Instruction>>)
void print_std(Buffer<Instruction> output_order){
	std::cout << "Space-Time Diagram\n";

	std::string IF =  "\033[1;43m  IF  \033[0m";
	std::string DE =  "\033[1;42m  DE  \033[0m";
	std::string RF1 = "\033[1;41m  RF1 \033[0m";
	std::string RF2 = "\033[1;46m  RF2 \033[0m";
	std::string EX =  "\033[1;44m EXEC \033[0m";
	std::string MEM = "\033[1;47;30m  MEM \033[0m";
	std::string WB =  "\033[1;45m  WB  \033[0m";
	std::string ST =  "\033[1;100m  STL \033[0m";
	std::string sp =  "      ";

	for(auto instr : output_order){
		int i = 1;
		std::cout << instr.text << "\t";
		while(i < instr.WB && i++ < instr.IF)
			std::cout << sp;
		std::cout << IF;
		while(i < instr.WB && i++ < instr.DE)
			std::cout << ST;
		std::cout << DE;
		while(i++ < instr.RF1)
			std::cout << ST;
		std::cout << RF1;
		while(i++ < instr.EXEC)
			std::cout << ST;
		std::cout << EX;
		if(std::get<0>(instr.type()) == OPCODE["lw"] || std::get<0>(instr.type()) == OPCODE["sw"]){
//			while(i++ < instr.EXEC + LATENCY_ADD)
//				std::cout << EX;
			while(i++ < instr.RF2)
				std::cout << ST;
			std::cout << RF2;
			while (i++ < instr.MEM)
				std::cout << ST;
			std::cout << MEM;
			while(i++ < instr.WB)
				std::cout << ST;
			std::cout << WB;
			std::cout << std::endl;
		}
		else {
			int latency = 1;
			if(std::get<0>(instr.type()) == 0){
				if(std::get<1>(instr.type()) == FUNCT["add"])
					latency = LATENCY_ADD;
				else if(std::get<1>(instr.type()) == FUNCT["sub"])
					latency = LATENCY_SUB;
				else if(std::get<1>(instr.type()) == FUNCT["mult"])
					latency = LATENCY_MULT;
				else if(std::get<1>(instr.type()) == FUNCT["div"])
					latency = LATENCY_DIV;
			}
			while(i++ < instr.EXEC + latency)
				std::cout << EX;
			while(i++ < instr.WB)
				std::cout << ST;
			std::cout << WB;
			std::cout << std::endl;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
movq %rdi, %rbx
movq 0xc98b(%rip), %rdi      # 0x16fd0
leaq 0x5d27(%rip), %rsi      # 0x10373
callq 0x31d0
leaq 0x5d2f(%rip), %rsi      # 0x10387
leaq 0x1f8(%rsp), %rdi
leaq 0x68(%rsp), %rdx
callq 0x4860
leaq 0x5d28(%rip), %rsi      # 0x10399
leaq 0x1d8(%rsp), %rdi
leaq 0x68(%rsp), %rdx
callq 0x4860
leaq 0x5d21(%rip), %rsi      # 0x103ab
leaq 0x1b8(%rsp), %rdi
leaq 0x68(%rsp), %rdx
callq 0x4860
leaq 0x5d1a(%rip), %rsi      # 0x103bd
leaq 0x198(%rsp), %rdi
leaq 0x68(%rsp), %rdx
callq 0x4860
leaq 0x5d13(%rip), %rsi      # 0x103cf
leaq 0x118(%rsp), %rdi
leaq 0x68(%rsp), %rdx
callq 0x4860
leaq 0x5d0c(%rip), %rsi      # 0x103e1
leaq 0x178(%rsp), %rdi
leaq 0x68(%rsp), %rdx
callq 0x4860
leaq 0x5d08(%rip), %rsi      # 0x103f6
leaq 0xf8(%rsp), %rdi
leaq 0x68(%rsp), %rdx
callq 0x4860
leaq 0x5d01(%rip), %rsi      # 0x10408
leaq 0x158(%rsp), %rdi
leaq 0x68(%rsp), %rdx
callq 0x4860
leaq 0x5cfb(%rip), %rsi      # 0x1041b
leaq 0x138(%rsp), %rdi
leaq 0x68(%rsp), %rdx
callq 0x4860
movq 0x10(%rbx), %rsi
movq 0x20(%rbx), %rax
movq %rax, 0x40(%rsp)
movq 0x28(%rbx), %rax
movq %rax, 0x38(%rsp)
movq 0x30(%rbx), %rax
movq %rax, 0xe0(%rsp)
leaq 0xb8(%rsp), %r14
movq 0xc86d(%rip), %r12      # 0x16fd0
leaq 0x158(%rsp), %r13
cmpq 0xe0(%rsp), %rsi
je 0xabcb
leaq 0x68(%rsp), %rdi
movq %rsi, 0xe8(%rsp)
callq 0x49ba
movq %r12, %rdi
movq %r14, %rsi
callq 0x31c0
movq %rax, %rdi
leaq 0x5b3d(%rip), %rsi      # 0x102dd
callq 0x31d0
pushq $0x2
popq %rax
movl %eax, %ebx
leal -0x1(%rbx), %r15d
cmpl 0xb4(%rsp), %r15d
jge 0xa7d9
cmpl 0x9c(%rsp), %r15d
jge 0xa7d6
incl %ebx
movq %r12, %rdi
leaq 0x138(%rsp), %rsi
callq 0x31c0
jmp 0xa7aa
movl %ebx, %r15d
movq %r12, %rdi
leaq 0x1f8(%rsp), %rsi
callq 0x31c0
cmpl 0xb4(%rsp), %r15d
jge 0xa810
cmpl 0xa0(%rsp), %r15d
jge 0xa80d
incl %r15d
movq %r12, %rdi
movq %r13, %rsi
callq 0x31c0
jmp 0xa7e9
incl %r15d
movq %r12, %rdi
leaq 0x1d8(%rsp), %rsi
callq 0x31c0
cmpl 0xa4(%rsp), %r15d
jge 0xa83a
incl %r15d
movq %r12, %rdi
movq %r13, %rsi
callq 0x31c0
jmp 0xa820
movq %r12, %rdi
leaq 0x1b8(%rsp), %rsi
callq 0x31c0
incl %r15d
cmpl 0xa8(%rsp), %r15d
jge 0xa867
incl %r15d
movq %r12, %rdi
movq %r13, %rsi
callq 0x31c0
jmp 0xa84d
movq %r12, %rdi
leaq 0x118(%rsp), %rsi
callq 0x31c0
leaq 0x10(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x7c7c
movl 0x14(%rsp), %ebx
leaq 0x18(%rsp), %rbp
movq %rbp, %rdi
leaq 0x57d4(%rip), %rsi      # 0x1006d
leaq 0xf(%rsp), %rdx
callq 0x4860
leaq 0xc95e(%rip), %rdi      # 0x17208
movq %rbp, %rsi
callq 0x47fa
incl %r15d
cmpl (%rax), %ebx
jne 0xa8c5
leaq 0x18(%rsp), %rdi
callq 0x3100
jmp 0xa92f
leaq 0xf0(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x7c7c
movl 0xf4(%rsp), %r14d
leaq 0x48(%rsp), %rbx
movq %rbx, %rdi
leaq 0x572f(%rip), %rsi      # 0x1001d
leaq 0xe(%rsp), %rdx
callq 0x4860
leaq 0xc909(%rip), %rdi      # 0x17208
movq %rbx, %rsi
callq 0x47fa
movl (%rax), %ebp
movq %rbx, %rdi
callq 0x3100
leaq 0x18(%rsp), %rbx
movq %rbx, %rdi
callq 0x3100
cmpl %ebp, %r14d
leaq 0xb8(%rsp), %r14
jne 0xa9bd
cmpl 0xac(%rsp), %r15d
jge 0xa949
incl %r15d
movq %r12, %rdi
movq %r13, %rsi
callq 0x31c0
jmp 0xa92f
movq %r12, %rdi
leaq 0x198(%rsp), %rsi
callq 0x31c0
incl %r15d
cmpl 0xb0(%rsp), %r15d
jge 0xa976
incl %r15d
movq %r12, %rdi
movq %r13, %rsi
callq 0x31c0
jmp 0xa95c
movq %r12, %rdi
leaq 0x178(%rsp), %rsi
callq 0x31c0
incl %r15d
cmpl 0xb4(%rsp), %r15d
jge 0xa9a0
movq %r12, %rdi
movq %r13, %rsi
callq 0x31c0
jmp 0xa986
movq %r12, %rdi
leaq 0xf8(%rsp), %rsi
callq 0x31c0
movq %r12, %rdi
callq 0x3120
jmp 0xab89
movq %rbx, %rdi
leaq 0x68(%rsp), %rsi
callq 0x7c7c
cmpl $0x0, 0x1c(%rsp)
pushq $0x1
popq %rbx
jne 0xab36
leaq 0x48(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x7c7c
movl 0x48(%rsp), %ebp
leaq 0x18(%rsp), %rbx
movq %rbx, %rdi
leaq 0x560a(%rip), %rsi      # 0x10004
leaq 0x10(%rsp), %rdx
callq 0x4860
movl %ebp, %r14d
leaq 0xc82a(%rip), %rdi      # 0x17238
movq %rbx, %rsi
callq 0x47fa
movl (%rax), %ebp
movq %rbx, %rdi
callq 0x3100
pushq $0x1
popq %rbx
cmpl %ebp, %r14d
leaq 0xb8(%rsp), %r14
je 0xab36
leaq 0x48(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x7c7c
movl 0x48(%rsp), %ebp
leaq 0x18(%rsp), %rbx
movq %rbx, %rdi
leaq 0x55b2(%rip), %rsi      # 0x10008
leaq 0x10(%rsp), %rdx
callq 0x4860
movl %ebp, %r14d
leaq 0xc7ce(%rip), %rdi      # 0x17238
movq %rbx, %rsi
callq 0x47fa
movl (%rax), %ebp
movq %rbx, %rdi
callq 0x3100
pushq $0x1
popq %rbx
cmpl %ebp, %r14d
leaq 0xb8(%rsp), %r14
je 0xab36
leaq 0x48(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x7c7c
movl 0x48(%rsp), %ebp
leaq 0x18(%rsp), %rbx
movq %rbx, %rdi
leaq 0x5562(%rip), %rsi      # 0x10014
leaq 0x10(%rsp), %rdx
callq 0x4860
movl %ebp, %r14d
leaq 0xc772(%rip), %rdi      # 0x17238
movq %rbx, %rsi
callq 0x47fa
movl (%rax), %ebp
movq %rbx, %rdi
callq 0x3100
pushq $0x6
popq %rbx
cmpl %ebp, %r14d
leaq 0xb8(%rsp), %r14
je 0xab36
leaq 0x48(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x7c7c
movl 0x48(%rsp), %ebx
leaq 0x18(%rsp), %rbp
movq %rbp, %rdi
leaq 0x550f(%rip), %rsi      # 0x10019
leaq 0x10(%rsp), %rdx
callq 0x4860
leaq 0xc71d(%rip), %rdi      # 0x17238
movq %rbp, %rsi
callq 0x47fa
cmpl (%rax), %ebx
pushq $0x1
popq %rbx
pushq $0x23
popq %rax
cmovel %eax, %ebx
movq %rbp, %rdi
callq 0x3100
movl 0xa8(%rsp), %eax
addl %ebx, %eax
cmpl %eax, %r15d
jge 0xab64
incl %r15d
movq %r12, %rdi
leaq 0x118(%rsp), %rsi
callq 0x31c0
jmp 0xab36
movq %r12, %rdi
movq %r13, %rsi
callq 0x31c0
incl %r15d
cmpl 0xb4(%rsp), %r15d
jl 0xab59
movq %r12, %rdi
leaq 0xf8(%rsp), %rsi
callq 0x31c0
movq %r12, %rdi
callq 0x3120
movq %r14, %rdi
callq 0x3100
movq 0xe8(%rsp), %rsi
addq $0x78, %rsi
cmpq 0x40(%rsp), %rsi
jne 0xa76b
movq 0x38(%rsp), %rax
movq 0x8(%rax), %rsi
addq $0x8, %rax
movq %rax, 0x38(%rsp)
leaq 0x1e0(%rsi), %rax
movq %rax, 0x40(%rsp)
jmp 0xa76b
leaq 0x138(%rsp), %rdi
callq 0x3100
leaq 0x158(%rsp), %rdi
callq 0x3100
leaq 0xf8(%rsp), %rdi
callq 0x3100
leaq 0x178(%rsp), %rdi
callq 0x3100
leaq 0x118(%rsp), %rdi
callq 0x3100
leaq 0x198(%rsp), %rdi
callq 0x3100
leaq 0x1b8(%rsp), %rdi
callq 0x3100
leaq 0x1d8(%rsp), %rdi
callq 0x3100
leaq 0x1f8(%rsp), %rdi
callq 0x3100
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x3100
jmp 0xad12
jmp 0xad0f
jmp 0xad0f
jmp 0xacdd
jmp 0xad0f
jmp 0xad0f
movq %rax, %rbx
jmp 0xad27
movq %rax, %rbx
jmp 0xad34
movq %rax, %rbx
jmp 0xad41
movq %rax, %rbx
jmp 0xad4e
movq %rax, %rbx
jmp 0xad5b
movq %rax, %rbx
jmp 0xad68
movq %rax, %rbx
jmp 0xad75
movq %rax, %rbx
jmp 0xad82
jmp 0xacdd
jmp 0xad0f
jmp 0xad0f
jmp 0xacdd
jmp 0xad0f
jmp 0xad0f
jmp 0xad0f
jmp 0xad0f
jmp 0xacdd
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x3100
jmp 0xace0
jmp 0xacdd
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x3100
leaq 0xb8(%rsp), %r14
jmp 0xad12
jmp 0xad0f
jmp 0xad0f
movq %rax, %rbx
jmp 0xad1a
jmp 0xad0f
jmp 0xad0f
jmp 0xad0f
jmp 0xad0f
jmp 0xad0f
jmp 0xad0f
jmp 0xad0f
jmp 0xad0f
jmp 0xad0f
movq %rax, %rbx
movq %r14, %rdi
callq 0x3100
leaq 0x138(%rsp), %rdi
callq 0x3100
leaq 0x158(%rsp), %rdi
callq 0x3100
leaq 0xf8(%rsp), %rdi
callq 0x3100
leaq 0x178(%rsp), %rdi
callq 0x3100
leaq 0x118(%rsp), %rdi
callq 0x3100
leaq 0x198(%rsp), %rdi
callq 0x3100
leaq 0x1b8(%rsp), %rdi
callq 0x3100
leaq 0x1d8(%rsp), %rdi
callq 0x3100
leaq 0x1f8(%rsp), %rdi
callq 0x3100
movq %rbx, %rdi
callq 0x3320