// File: /workspace/github_cpp_makefile_star2_O3/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 %r14
pushq %rbx
movq %rdi, %rbx
leaq 0x8cf9(%rip), %rsi      # 0xb56a
callq 0x2280
testl %eax, %eax
je 0x2a7f
leaq 0x8ce9(%rip), %rsi      # 0xb56e
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2a89
leaq 0x8cd6(%rip), %rsi      # 0xb572
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2a93
leaq 0x8cc3(%rip), %rsi      # 0xb576
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2a9d
leaq 0x8cb1(%rip), %rsi      # 0xb57b
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2aa7
movb (%rbx), %r14b
cmpb $0x6f, %r14b
jne 0x28f3
cmpb $0x72, 0x1(%rbx)
jne 0x28f3
cmpb $0x0, 0x2(%rbx)
je 0x2acf
leaq 0x8c85(%rip), %rsi      # 0xb57f
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2ab1
leaq 0x8c72(%rip), %rsi      # 0xb583
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2abb
leaq 0x8c5f(%rip), %rsi      # 0xb587
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2ac5
leaq 0x8c4c(%rip), %rsi      # 0xb58b
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2ad9
leaq 0x8c39(%rip), %rsi      # 0xb58f
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2ae3
leaq 0x8c27(%rip), %rsi      # 0xb594
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2aed
leaq 0x8c15(%rip), %rsi      # 0xb599
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2af7
leaq 0x8c04(%rip), %rsi      # 0xb59f
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2b01
leaq 0x8bf3(%rip), %rsi      # 0xb5a5
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2b0b
leaq 0x8bdb(%rip), %rsi      # 0xb5a4
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2b15
leaq 0x8bc9(%rip), %rsi      # 0xb5a9
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2b1f
leaq 0x8bb7(%rip), %rsi      # 0xb5ae
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2b29
leaq 0x8ba5(%rip), %rsi      # 0xb5b3
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2b33
cmpb $0x6c, %r14b
jne 0x2b3d
cmpb $0x62, 0x1(%rbx)
jne 0x2a38
cmpb $0x0, 0x2(%rbx)
je 0x2ceb
leaq 0x8b79(%rip), %rsi      # 0xb5b8
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2ba3
cmpb $0x68, 0x1(%rbx)
jne 0x2bad
cmpb $0x0, 0x2(%rbx)
je 0x2cf9
leaq 0x8b52(%rip), %rsi      # 0xb5bc
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
jne 0x2bca
jmp 0x2cdd
movl $0x1, %eax
jmp 0x2d4b
movl $0x22, %eax
jmp 0x2d4b
movl $0x1a, %eax
jmp 0x2d4b
movl $0x1d, %eax
jmp 0x2d4b
movl $0x3, %eax
jmp 0x2d4b
movl $0x24, %eax
jmp 0x2d4b
movl $0x18, %eax
jmp 0x2d4b
movl $0x20, %eax
jmp 0x2d4b
movl $0x14, %eax
jmp 0x2d4b
movl $0x1e, %eax
jmp 0x2d4b
movl $0x2, %eax
jmp 0x2d4b
movl $0x1b, %eax
jmp 0x2d4b
movl $0x1c, %eax
jmp 0x2d4b
movl $0x4, %eax
jmp 0x2d4b
movl $0x15, %eax
jmp 0x2d4b
movl $0x25, %eax
jmp 0x2d4b
movl $0x19, %eax
jmp 0x2d4b
movl $0x21, %eax
jmp 0x2d4b
movl $0x1f, %eax
jmp 0x2d4b
leaq 0x8a74(%rip), %rsi      # 0xb5b8
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2ba3
leaq 0x8a65(%rip), %rsi      # 0xb5bc
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2cdd
cmpb $0x73, %r14b
jne 0x2bda
cmpb $0x62, 0x1(%rbx)
jne 0x2b7d
cmpb $0x0, 0x2(%rbx)
je 0x2d0e
cmpb $0x68, 0x1(%rbx)
jne 0x2b8d
cmpb $0x0, 0x2(%rbx)
je 0x2d15
cmpb $0x77, 0x1(%rbx)
jne 0x2bda
cmpb $0x0, 0x2(%rbx)
jne 0x2bda
movl $0x23, %eax
jmp 0x2d4b
movl $0xf, %eax
jmp 0x2d4b
leaq 0x8a08(%rip), %rsi      # 0xb5bc
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2cdd
cmpb $0x6c, %r14b
jne 0x2b67
cmpb $0x77, 0x1(%rbx)
jne 0x2bda
cmpb $0x0, 0x2(%rbx)
je 0x2d1c
leaq 0x89df(%rip), %rsi      # 0xb5c0
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2ce4
leaq 0x89cc(%rip), %rsi      # 0xb5c4
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2cf2
leaq 0x89b9(%rip), %rsi      # 0xb5c8
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2d00
leaq 0x89a7(%rip), %rsi      # 0xb5cd
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2d07
leaq 0x8994(%rip), %rsi      # 0xb5d1
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2d23
leaq 0x8982(%rip), %rsi      # 0xb5d6
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2d2a
leaq 0x896f(%rip), %rsi      # 0xb5da
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2d31
leaq 0x895c(%rip), %rsi      # 0xb5de
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2d38
leaq 0x894a(%rip), %rsi      # 0xb5e3
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2d3f
leaq 0x8939(%rip), %rsi      # 0xb5e9
movq %rbx, %rdi
callq 0x2280
testl %eax, %eax
je 0x2d46
leaq 0x8926(%rip), %rsi      # 0xb5ed
movq %rbx, %rdi
callq 0x2280
xorl %ecx, %ecx
testl %eax, %eax
movl $0x26, %eax
cmovnel %ecx, %eax
jmp 0x2d4b
movl $0x11, %eax
jmp 0x2d4b
movl $0x6, %eax
jmp 0x2d4b
movl $0xe, %eax
jmp 0x2d4b
movl $0x7, %eax
jmp 0x2d4b
movl $0x10, %eax
jmp 0x2d4b
movl $0x8, %eax
jmp 0x2d4b
movl $0x9, %eax
jmp 0x2d4b
movl $0x16, %eax
jmp 0x2d4b
movl $0x17, %eax
jmp 0x2d4b
movl $0x13, %eax
jmp 0x2d4b
movl $0xa, %eax
jmp 0x2d4b
movl $0xb, %eax
jmp 0x2d4b
movl $0xc, %eax
jmp 0x2d4b
movl $0xd, %eax
jmp 0x2d4b
movl $0x5, %eax
jmp 0x2d4b
movl $0x12, %eax
popq %rbx
popq %r14
popq %rbp
retq