// File: /workspace/github_cpp_makefile_star2_O1/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 $0x208, %rsp            # imm = 0x208
movq %rdi, %r15
movq 0xdf9d(%rip), %rbx      # 0x1cfd8
leaq 0x8350(%rip), %rsi      # 0x17392
movl $0x13, %edx
movq %rbx, %rdi
callq 0x3240
leaq 0x150(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x8344(%rip), %rsi      # 0x173a6
leaq 0x834e(%rip), %rdx      # 0x173b7
leaq 0x140(%rsp), %rdi
callq 0x5346
leaq 0xf0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x832f(%rip), %rsi      # 0x173b8
leaq 0x8339(%rip), %rdx      # 0x173c9
leaq 0xe0(%rsp), %rdi
callq 0x5346
leaq 0x130(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x831a(%rip), %rsi      # 0x173ca
leaq 0x8324(%rip), %rdx      # 0x173db
leaq 0x120(%rsp), %rdi
callq 0x5346
leaq 0xd0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x8305(%rip), %rsi      # 0x173dc
leaq 0x830f(%rip), %rdx      # 0x173ed
leaq 0xc0(%rsp), %rdi
callq 0x5346
leaq 0x78(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x82f3(%rip), %rsi      # 0x173ee
leaq 0x82fd(%rip), %rdx      # 0x173ff
leaq 0x68(%rsp), %rdi
callq 0x5346
leaq 0xb0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x82e1(%rip), %rsi      # 0x17400
leaq 0x82ee(%rip), %rdx      # 0x17414
leaq 0xa0(%rsp), %rdi
callq 0x5346
leaq 0x58(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x82d2(%rip), %rsi      # 0x17415
leaq 0x82dc(%rip), %rdx      # 0x17426
leaq 0x48(%rsp), %rdi
callq 0x5346
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x82c3(%rip), %rsi      # 0x17427
leaq 0x82ce(%rip), %rdx      # 0x17439
leaq 0x28(%rsp), %rdi
callq 0x5346
leaq 0x110(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x82b2(%rip), %rsi      # 0x1743a
leaq 0x82b1(%rip), %rdx      # 0x17440
leaq 0x100(%rsp), %rdi
callq 0x5346
movq 0x10(%r15), %r13
movq 0x30(%r15), %rax
movq %rax, 0x1f8(%rsp)
cmpq %rax, %r13
je 0xf807
movq 0x20(%r15), %rax
movq %rax, 0x90(%rsp)
movq 0x28(%r15), %rax
movq %rax, 0x88(%rsp)
movq %rsp, %r14
movl $0xa, %ecx
leaq 0x180(%rsp), %rdi
movq %r13, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x1e0(%rsp), %rax
movq %rax, 0x1d0(%rsp)
movq 0x50(%r13), %rsi
movq 0x58(%r13), %rdx
addq %rsi, %rdx
leaq 0x1d0(%rsp), %rdi
callq 0x52b6
movq 0x70(%r13), %rax
movq %rax, 0x1f0(%rsp)
movq 0x1d0(%rsp), %rsi
movq 0x1d8(%rsp), %rdx
movq %rbx, %rdi
callq 0x3240
movl $0x1, %edx
movq %rax, %rdi
leaq 0x80be(%rip), %rsi      # 0x172fc
callq 0x3240
movl $0x2, %r15d
leal -0x1(%r15), %ebp
cmpl 0x1cc(%rsp), %ebp
jge 0xf27f
cmpl 0x1b4(%rsp), %ebp
jge 0xf27c
movq 0x100(%rsp), %rsi
movq 0x108(%rsp), %rdx
incl %r15d
movq %rbx, %rdi
callq 0x3240
jmp 0xf249
movl %r15d, %ebp
movq 0x140(%rsp), %rsi
movq 0x148(%rsp), %rdx
movq %rbx, %rdi
callq 0x3240
cmpl 0x1cc(%rsp), %ebp
jge 0xf2c1
cmpl 0x1b8(%rsp), %ebp
jge 0xf2bf
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
incl %ebp
movq %rbx, %rdi
callq 0x3240
jmp 0xf297
incl %ebp
movq 0xe0(%rsp), %rsi
movq 0xe8(%rsp), %rdx
movq %rbx, %rdi
callq 0x3240
cmpl 0x1bc(%rsp), %ebp
jge 0xf2f8
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
incl %ebp
movq %rbx, %rdi
callq 0x3240
jmp 0xf2d9
movq 0x120(%rsp), %rsi
movq 0x128(%rsp), %rdx
movq %rbx, %rdi
callq 0x3240
incl %ebp
cmpl 0x1c0(%rsp), %ebp
jge 0xf331
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
incl %ebp
movq %rbx, %rdi
callq 0x3240
jmp 0xf312
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rdx
movq %rbx, %rdi
callq 0x3240
movq %r13, 0x98(%rsp)
leaq 0x20(%rsp), %rdi
leaq 0x180(%rsp), %rsi
callq 0xac8c
movl 0x24(%rsp), %r13d
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
movq %r14, %rdi
leaq 0x7cf8(%rip), %rsi      # 0x1706d
leaq 0x7cf3(%rip), %rdx      # 0x1706f
callq 0x5346
leaq 0xde88(%rip), %rdi      # 0x1d210
movq %r14, %rsi
callq 0x517a
movl (%rax), %r15d
movb $0x1, %r12b
cmpl %r15d, %r13d
je 0xf3fc
leaq 0x200(%rsp), %rdi
leaq 0x180(%rsp), %rsi
callq 0xac8c
movl 0x204(%rsp), %r12d
leaq 0x170(%rsp), %rax
movq %rax, 0x160(%rsp)
leaq 0x160(%rsp), %r14
movq %r14, %rdi
leaq 0x7c43(%rip), %rsi      # 0x1701d
leaq 0x7c3e(%rip), %rdx      # 0x1701f
callq 0x5346
leaq 0xde23(%rip), %rdi      # 0x1d210
movq %r14, %rsi
callq 0x517a
cmpl (%rax), %r12d
sete %r12b
cmpl %r15d, %r13d
movq 0x98(%rsp), %r13
je 0xf42e
movq 0x160(%rsp), %rdi
leaq 0x170(%rsp), %rax
cmpq %rax, %rdi
je 0xf42e
movq 0x170(%rsp), %rsi
incq %rsi
callq 0x3200
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0xf449
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3200
incl %ebp
testb %r12b, %r12b
je 0xf476
movq %rsp, %r14
cmpl 0x1c4(%rsp), %ebp
jge 0xf50e
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
incl %ebp
movq %rbx, %rdi
callq 0x3240
jmp 0xf453
movq %rsp, %r14
movq %r14, %rdi
leaq 0x180(%rsp), %rsi
callq 0xac8c
cmpl $0x0, 0x4(%rsp)
movl $0x1, %r13d
jne 0xf69f
leaq 0x20(%rsp), %rdi
leaq 0x180(%rsp), %rsi
callq 0xac8c
movl 0x20(%rsp), %r15d
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
movq %r14, %rdi
leaq 0x7b40(%rip), %rsi      # 0x17004
leaq 0x7b3c(%rip), %rdx      # 0x17007
callq 0x5346
leaq 0xdd69(%rip), %rdi      # 0x1d240
movq %r14, %rsi
callq 0x517a
movl (%rax), %r12d
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0xf4fd
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3200
cmpl %r12d, %r15d
jne 0xf5bc
movq %rsp, %r14
jmp 0xf69f
movq 0xc0(%rsp), %rsi
movq 0xc8(%rsp), %rdx
movq %rbx, %rdi
callq 0x3240
incl %ebp
cmpl 0x1c8(%rsp), %ebp
jge 0xf547
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
incl %ebp
movq %rbx, %rdi
callq 0x3240
jmp 0xf528
movq 0xa0(%rsp), %rsi
movq 0xa8(%rsp), %rdx
movq %rbx, %rdi
callq 0x3240
incl %ebp
cmpl 0x1cc(%rsp), %ebp
jge 0xf57e
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq %rbx, %rdi
callq 0x3240
jmp 0xf55f
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq %rbx, %rdi
callq 0x3240
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x31e0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3180
jmp 0xf723
leaq 0x20(%rsp), %rdi
leaq 0x180(%rsp), %rsi
callq 0xac8c
movq %rsp, %r12
movl 0x20(%rsp), %r15d
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
movq %r12, %rdi
leaq 0x7a1f(%rip), %rsi      # 0x17008
leaq 0x7a1b(%rip), %rdx      # 0x1700b
callq 0x5346
leaq 0xdc44(%rip), %rdi      # 0x1d240
movq %r12, %rsi
callq 0x517a
movl (%rax), %r12d
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0xf622
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3200
cmpl %r12d, %r15d
movq %rsp, %r14
je 0xf69f
leaq 0x20(%rsp), %rdi
leaq 0x180(%rsp), %rsi
callq 0xac8c
movl 0x20(%rsp), %r15d
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
movq %r14, %rdi
leaq 0x79c0(%rip), %rsi      # 0x17014
leaq 0x79bd(%rip), %rdx      # 0x17018
callq 0x5346
leaq 0xdbd9(%rip), %rdi      # 0x1d240
movq %r14, %rsi
callq 0x517a
movl (%rax), %r12d
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0xf68d
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3200
movl $0x6, %r13d
cmpl %r12d, %r15d
movq %rsp, %r14
jne 0xf78d
movl 0x1c0(%rsp), %eax
addl %r13d, %eax
cmpl %eax, %ebp
jge 0xf6c3
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rdx
incl %ebp
movq %rbx, %rdi
callq 0x3240
jmp 0xf69f
movq 0x98(%rsp), %r13
incl %ebp
cmpl 0x1cc(%rsp), %ebp
jge 0xf6ea
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq %rbx, %rdi
callq 0x3240
jmp 0xf6cb
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq %rbx, %rdi
callq 0x3240
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x31e0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3180
movq 0x1d0(%rsp), %rdi
leaq 0x1e0(%rsp), %rax
cmpq %rax, %rdi
je 0xf748
movq 0x1e0(%rsp), %rsi
incq %rsi
callq 0x3200
addq $0x78, %r13
cmpq 0x90(%rsp), %r13
jne 0xf77d
movq 0x88(%rsp), %rax
movq 0x8(%rax), %r13
addq $0x8, %rax
movq %rax, 0x88(%rsp)
leaq 0x1e0(%r13), %rax
movq %rax, 0x90(%rsp)
cmpq 0x1f8(%rsp), %r13
jne 0xf1d0
jmp 0xf807
leaq 0x20(%rsp), %rdi
leaq 0x180(%rsp), %rsi
callq 0xac8c
movl 0x20(%rsp), %r15d
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
movq %r14, %rdi
leaq 0x7862(%rip), %rsi      # 0x17019
leaq 0x785e(%rip), %rdx      # 0x1701c
callq 0x5346
leaq 0xda76(%rip), %rdi      # 0x1d240
movq %r14, %rsi
callq 0x517a
movl (%rax), %r12d
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0xf7f0
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3200
cmpl %r12d, %r15d
movl $0x1, %r13d
movl $0x23, %eax
cmovel %eax, %r13d
jmp 0xf506
movq 0x100(%rsp), %rdi
leaq 0x110(%rsp), %rax
cmpq %rax, %rdi
je 0xf82c
movq 0x110(%rsp), %rsi
incq %rsi
callq 0x3200
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0xf848
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3200
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0xf864
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3200
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0xf889
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x3200
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0xf8a5
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x3200
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0xf8ca
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x3200
movq 0x120(%rsp), %rdi
leaq 0x130(%rsp), %rax
cmpq %rax, %rdi
je 0xf8ef
movq 0x130(%rsp), %rsi
incq %rsi
callq 0x3200
movq 0xe0(%rsp), %rdi
leaq 0xf0(%rsp), %rax
cmpq %rax, %rdi
je 0xf914
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x3200
movq 0x140(%rsp), %rdi
leaq 0x150(%rsp), %rax
cmpq %rax, %rdi
je 0xf939
movq 0x150(%rsp), %rsi
incq %rsi
callq 0x3200
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xf9e9
jmp 0xfa22
jmp 0xfa22
jmp 0xf9e9
jmp 0xfa22
jmp 0xfa22
movq %rax, %rbx
jmp 0xfa6f
movq %rax, %rbx
jmp 0xfa8b
movq %rax, %rbx
jmp 0xfaa7
movq %rax, %rbx
jmp 0xfacc
movq %rax, %rbx
jmp 0xfae8
movq %rax, %rbx
jmp 0xfb0d
movq %rax, %rbx
jmp 0xfb32
movq %rax, %rbx
jmp 0xfb57
jmp 0xf9e9
jmp 0xfa22
jmp 0xfa22
jmp 0xf9e9
jmp 0xfa22
jmp 0xfa22
jmp 0xf9e9
jmp 0xfa22
jmp 0xf9e9
movq %rax, %rbx
movq 0x160(%rsp), %rdi
leaq 0x170(%rsp), %rax
cmpq %rax, %rdi
je 0xf9ec
movq 0x170(%rsp), %rsi
incq %rsi
callq 0x3200
jmp 0xf9ec
jmp 0xfa22
jmp 0xfa22
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0xfa25
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3200
jmp 0xfa25
movq %rax, %rbx
jmp 0xfa4a
jmp 0xfa22
jmp 0xfa22
jmp 0xfa22
jmp 0xfa22
jmp 0xfa22
jmp 0xfa22
jmp 0xfa22
jmp 0xfa22
jmp 0xfa22
jmp 0xfa22
movq %rax, %rbx
movq 0x1d0(%rsp), %rdi
leaq 0x1e0(%rsp), %rax
cmpq %rax, %rdi
je 0xfa4a
movq 0x1e0(%rsp), %rsi
incq %rsi
callq 0x3200
movq 0x100(%rsp), %rdi
leaq 0x110(%rsp), %rax
cmpq %rax, %rdi
je 0xfa6f
movq 0x110(%rsp), %rsi
incq %rsi
callq 0x3200
leaq 0x38(%rsp), %rax
movq 0x28(%rsp), %rdi
cmpq %rax, %rdi
je 0xfa8b
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3200
leaq 0x58(%rsp), %rax
movq 0x48(%rsp), %rdi
cmpq %rax, %rdi
je 0xfaa7
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3200
leaq 0xb0(%rsp), %rax
movq 0xa0(%rsp), %rdi
cmpq %rax, %rdi
je 0xfacc
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x3200
leaq 0x78(%rsp), %rax
movq 0x68(%rsp), %rdi
cmpq %rax, %rdi
je 0xfae8
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x3200
leaq 0xd0(%rsp), %rax
movq 0xc0(%rsp), %rdi
cmpq %rax, %rdi
je 0xfb0d
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x3200
movq 0x120(%rsp), %rdi
leaq 0x130(%rsp), %rax
cmpq %rax, %rdi
je 0xfb32
movq 0x130(%rsp), %rsi
incq %rsi
callq 0x3200
leaq 0xf0(%rsp), %rax
movq 0xe0(%rsp), %rdi
cmpq %rax, %rdi
je 0xfb57
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x3200
movq 0x140(%rsp), %rdi
leaq 0x150(%rsp), %rax
cmpq %rax, %rdi
je 0xfb7c
movq 0x150(%rsp), %rsi
incq %rsi
callq 0x3200
movq %rbx, %rdi
callq 0x3340