// File: /workspace/github_cpp_makefile_star2_O1/sangwoojun[P]rv32emulator/emulator.cpp
// Function: parse_instr(char*)
instr_type parse_instr(char* tok) {
	// 2r->1r
	if ( streq(tok, "add") ) return ADD;
	if ( streq(tok, "sub") ) return SUB;
	if ( streq(tok, "slt") ) return SLT;
	if ( streq(tok, "sltu") ) return SLTU;
	if ( streq(tok, "and") ) return AND;
	if ( streq(tok, "or") ) return OR;
	if ( streq(tok, "xor") ) return XOR;
	if ( streq(tok, "sll") ) return SLL;
	if ( streq(tok, "srl") ) return SRL;
	if ( streq(tok, "sra") ) return SRA;

	// 1r, imm -> 1r
	if ( streq(tok, "addi") ) return ADDI;
	if ( streq(tok, "slti") ) return SLTI;
	if ( streq(tok, "sltiu") ) return SLTIU;
	if ( streq(tok, "andi") ) return ANDI;
	if ( streq(tok, "ori") ) return ORI;
	if ( streq(tok, "xori") ) return XORI;
	if ( streq(tok, "slli") ) return SLLI;
	if ( streq(tok, "srli") ) return SRLI;
	if ( streq(tok, "srai") ) return SRAI;

	//load/store
	if ( streq(tok, "lb") ) return LB;
	if ( streq(tok, "lbu") ) return LBU;
	if ( streq(tok, "lh") ) return LH;
	if ( streq(tok, "lhu") ) return LHU;
	if ( streq(tok, "lw") ) return LW;
	if ( streq(tok, "sb") ) return SB;
	if ( streq(tok, "sh") ) return SH;
	if ( streq(tok, "sw") ) return SW;

	//branch
	if ( streq(tok, "beq") ) return BEQ;
	if ( streq(tok, "bge") ) return BGE;
	if ( streq(tok, "bgeu") ) return BGEU;
	if ( streq(tok, "blt") ) return BLT;
	if ( streq(tok, "bltu") ) return BLTU;
	if ( streq(tok, "bne") ) return BNE;

	// jal
	if ( streq(tok, "jal") ) return JAL;
	if ( streq(tok, "jalr") ) return JALR;

	// lui
	if ( streq(tok, "auipc") ) return AUIPC;
	if ( streq(tok, "lui") ) return LUI;

	// unimpl
	//if ( streq(tok, "unimpl") ) return UNIMPL;
	if ( streq(tok, "hcf") ) return HCF;
	return UNIMPL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x8cfa(%rip), %rsi      # 0xb56a
callq 0x2280
testl %eax, %eax
je 0x2bd9
leaq 0x8cea(%rip), %rsi      # 0xb56e
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2be3
leaq 0x8cd7(%rip), %rsi      # 0xb572
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2bed
leaq 0x8cc4(%rip), %rsi      # 0xb576
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2bf7
leaq 0x8cb2(%rip), %rsi      # 0xb57b
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2c01
leaq 0x8ca0(%rip), %rsi      # 0xb580
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2c0b
leaq 0x8c88(%rip), %rsi      # 0xb57f
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2c15
leaq 0x8c75(%rip), %rsi      # 0xb583
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2c1f
leaq 0x8c62(%rip), %rsi      # 0xb587
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2c29
leaq 0x8c4f(%rip), %rsi      # 0xb58b
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2c33
leaq 0x8c3c(%rip), %rsi      # 0xb58f
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2c3d
leaq 0x8c2a(%rip), %rsi      # 0xb594
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2c47
leaq 0x8c18(%rip), %rsi      # 0xb599
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2c51
leaq 0x8c07(%rip), %rsi      # 0xb59f
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2c5b
leaq 0x8bf6(%rip), %rsi      # 0xb5a5
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2c65
leaq 0x8bde(%rip), %rsi      # 0xb5a4
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2c6f
leaq 0x8bcc(%rip), %rsi      # 0xb5a9
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2c79
leaq 0x8bba(%rip), %rsi      # 0xb5ae
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2c83
leaq 0x8ba8(%rip), %rsi      # 0xb5b3
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2c8d
leaq 0x8b96(%rip), %rsi      # 0xb5b8
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2c94
leaq 0x8b82(%rip), %rsi      # 0xb5bb
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2c9b
leaq 0x8b6f(%rip), %rsi      # 0xb5bf
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2ca2
leaq 0x8b5b(%rip), %rsi      # 0xb5c2
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2ca9
leaq 0x8b48(%rip), %rsi      # 0xb5c6
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2cb0
leaq 0x8b34(%rip), %rsi      # 0xb5c9
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2cb7
leaq 0x8b20(%rip), %rsi      # 0xb5cc
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2cbe
leaq 0x8b0c(%rip), %rsi      # 0xb5cf
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2cc5
leaq 0x8af8(%rip), %rsi      # 0xb5d2
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2ccc
leaq 0x8ae5(%rip), %rsi      # 0xb5d6
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2cd3
leaq 0x8ad2(%rip), %rsi      # 0xb5da
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2cda
leaq 0x8ac0(%rip), %rsi      # 0xb5df
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2ce1
leaq 0x8aad(%rip), %rsi      # 0xb5e3
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2ce8
leaq 0x8a9b(%rip), %rsi      # 0xb5e8
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2cef
leaq 0x8a88(%rip), %rsi      # 0xb5ec
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2cf6
leaq 0x8a75(%rip), %rsi      # 0xb5f0
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2cfd
leaq 0x8a63(%rip), %rsi      # 0xb5f5
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2d04
leaq 0x8a52(%rip), %rsi      # 0xb5fb
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2d0b
leaq 0x8a3f(%rip), %rsi      # 0xb5ff
movq %rbx, %rdi
callq 0x2280
xorl %ecx, %ecx
testl %eax, %eax
movl $0x26, %eax
cmovnel %ecx, %eax
jmp 0x2d10
movl $0x1, %eax
jmp 0x2d10
movl $0x22, %eax
jmp 0x2d10
movl $0x1a, %eax
jmp 0x2d10
movl $0x1d, %eax
jmp 0x2d10
movl $0x3, %eax
jmp 0x2d10
movl $0x14, %eax
jmp 0x2d10
movl $0x24, %eax
jmp 0x2d10
movl $0x18, %eax
jmp 0x2d10
movl $0x20, %eax
jmp 0x2d10
movl $0x1e, %eax
jmp 0x2d10
movl $0x2, %eax
jmp 0x2d10
movl $0x1b, %eax
jmp 0x2d10
movl $0x1c, %eax
jmp 0x2d10
movl $0x4, %eax
jmp 0x2d10
movl $0x15, %eax
jmp 0x2d10
movl $0x25, %eax
jmp 0x2d10
movl $0x19, %eax
jmp 0x2d10
movl $0x21, %eax
jmp 0x2d10
movl $0x1f, %eax
jmp 0x2d10
movl $0xe, %eax
jmp 0x2d10
movl $0xf, %eax
jmp 0x2d10
movl $0x10, %eax
jmp 0x2d10
movl $0x11, %eax
jmp 0x2d10
movl $0x13, %eax
jmp 0x2d10
movl $0x16, %eax
jmp 0x2d10
movl $0x17, %eax
jmp 0x2d10
movl $0x23, %eax
jmp 0x2d10
movl $0x6, %eax
jmp 0x2d10
movl $0x7, %eax
jmp 0x2d10
movl $0x8, %eax
jmp 0x2d10
movl $0x9, %eax
jmp 0x2d10
movl $0xa, %eax
jmp 0x2d10
movl $0xb, %eax
jmp 0x2d10
movl $0xc, %eax
jmp 0x2d10
movl $0xd, %eax
jmp 0x2d10
movl $0x5, %eax
jmp 0x2d10
movl $0x12, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq