// File: /workspace/github_cpp_makefile_star2_O1/sangwoojun[P]rv32emulator/emulator.cpp
// Function: parse_reg(char*, int, bool)
int parse_reg(char* tok, int line, bool strict = true) {
	if ( tok[0] == 'x' ) {
		int ri = atoi(tok+1);
		if ( ri < 0 || ri > 32 ) {
			if ( strict ) print_syntax_error(line, "Malformed register name");
			return -1;
		}
		return ri;
	}
	if ( streq(tok, "zero") ) return 0; 
	if ( streq(tok, "ra") ) return 1;
	if ( streq(tok, "sp") ) return 2;
	if ( streq(tok, "gp") ) return 3;
	if ( streq(tok, "tp") ) return 4;
	if ( streq(tok, "t0") ) return 5;
	if ( streq(tok, "t1") ) return 6;
	if ( streq(tok, "t2") ) return 7;
	if ( streq(tok, "s0") ) return 8;
	if ( streq(tok, "s1") ) return 9;
	if ( streq(tok, "a0") ) return 10;
	if ( streq(tok, "a1") ) return 11;
	if ( streq(tok, "a2") ) return 12;
	if ( streq(tok, "a3") ) return 13;
	if ( streq(tok, "a4") ) return 14;
	if ( streq(tok, "a5") ) return 15;
	if ( streq(tok, "a6") ) return 16;
	if ( streq(tok, "a7") ) return 17;
	if ( streq(tok, "s2") ) return 18;
	if ( streq(tok, "s3") ) return 19;
	if ( streq(tok, "s4") ) return 20;
	if ( streq(tok, "s5") ) return 21;
	if ( streq(tok, "s6") ) return 22;
	if ( streq(tok, "s7") ) return 23;
	if ( streq(tok, "s8") ) return 24;
	if ( streq(tok, "s9") ) return 25;
	if ( streq(tok, "s10") ) return 26;
	if ( streq(tok, "s11") ) return 27;
	if ( streq(tok, "t3") ) return 28;
	if ( streq(tok, "t4") ) return 29;
	if ( streq(tok, "t5") ) return 30;
	if ( streq(tok, "t6") ) return 31;

	if ( strict ) print_syntax_error(line, "Malformed register name");
	return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %r14d
movl %esi, %ebx
movq %rdi, %r15
cmpb $0x78, (%rdi)
jne 0x2d76
incq %r15
movq %r15, %rdi
callq 0x2310
movl %eax, %ecx
cmpl $0x21, %eax
setae %dl
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmovbl %ecx, %eax
andb %r14b, %dl
cmpb $0x1, %dl
jne 0x3168
leaq 0x87e4(%rip), %rdi      # 0xb540
leaq 0x88a0(%rip), %rdx      # 0xb603
movl %ebx, %esi
xorl %eax, %eax
callq 0x2040
movl $0x1, %edi
callq 0x2210
leaq 0x89ef(%rip), %rsi      # 0xb76c
movq %r15, %rdi
callq 0x2280
testl %eax, %eax
je 0x3070
leaq 0x87f8(%rip), %rsi      # 0xb58c
movq %r15, %rdi
callq 0x2280
testl %eax, %eax
je 0x3077
leaq 0x8870(%rip), %rsi      # 0xb61b
movq %r15, %rdi
callq 0x2280
testl %eax, %eax
je 0x3081
leaq 0x885c(%rip), %rsi      # 0xb61e
movq %r15, %rdi
callq 0x2280
testl %eax, %eax
je 0x308b
leaq 0x8848(%rip), %rsi      # 0xb621
movq %r15, %rdi
callq 0x2280
testl %eax, %eax
je 0x3095
leaq 0x8834(%rip), %rsi      # 0xb624
movq %r15, %rdi
callq 0x2280
testl %eax, %eax
je 0x309f
leaq 0x8820(%rip), %rsi      # 0xb627
movq %r15, %rdi
callq 0x2280
testl %eax, %eax
je 0x30a9
leaq 0x880c(%rip), %rsi      # 0xb62a
movq %r15, %rdi
callq 0x2280
testl %eax, %eax
je 0x30b3
leaq 0x87f8(%rip), %rsi      # 0xb62d
movq %r15, %rdi
callq 0x2280
testl %eax, %eax
je 0x30bd
leaq 0x87e4(%rip), %rsi      # 0xb630
movq %r15, %rdi
callq 0x2280
testl %eax, %eax
je 0x30c7
leaq 0x87d0(%rip), %rsi      # 0xb633
movq %r15, %rdi
callq 0x2280
testl %eax, %eax
je 0x30d1
leaq 0x87bc(%rip), %rsi      # 0xb636
movq %r15, %rdi
callq 0x2280
testl %eax, %eax
je 0x30db
leaq 0x87a8(%rip), %rsi      # 0xb639
movq %r15, %rdi
callq 0x2280
testl %eax, %eax
je 0x30e5
leaq 0x8794(%rip), %rsi      # 0xb63c
movq %r15, %rdi
callq 0x2280
testl %eax, %eax
je 0x30ec
leaq 0x8780(%rip), %rsi      # 0xb63f
movq %r15, %rdi
callq 0x2280
testl %eax, %eax
je 0x30f3
leaq 0x876c(%rip), %rsi      # 0xb642
movq %r15, %rdi
callq 0x2280
testl %eax, %eax
je 0x30fa
leaq 0x8758(%rip), %rsi      # 0xb645
movq %r15, %rdi
callq 0x2280
testl %eax, %eax
je 0x3101
leaq 0x8744(%rip), %rsi      # 0xb648
movq %r15, %rdi
callq 0x2280
testl %eax, %eax
je 0x3108
leaq 0x8730(%rip), %rsi      # 0xb64b
movq %r15, %rdi
callq 0x2280
testl %eax, %eax
je 0x310f
leaq 0x871c(%rip), %rsi      # 0xb64e
movq %r15, %rdi
callq 0x2280
testl %eax, %eax
je 0x3116
leaq 0x8708(%rip), %rsi      # 0xb651
movq %r15, %rdi
callq 0x2280
testl %eax, %eax
je 0x311d
leaq 0x86f4(%rip), %rsi      # 0xb654
movq %r15, %rdi
callq 0x2280
testl %eax, %eax
je 0x3124
leaq 0x86e0(%rip), %rsi      # 0xb657
movq %r15, %rdi
callq 0x2280
testl %eax, %eax
je 0x312b
leaq 0x86cc(%rip), %rsi      # 0xb65a
movq %r15, %rdi
callq 0x2280
testl %eax, %eax
je 0x3132
leaq 0x86b8(%rip), %rsi      # 0xb65d
movq %r15, %rdi
callq 0x2280
testl %eax, %eax
je 0x3139
leaq 0x86a4(%rip), %rsi      # 0xb660
movq %r15, %rdi
callq 0x2280
testl %eax, %eax
je 0x3140
leaq 0x8690(%rip), %rsi      # 0xb663
movq %r15, %rdi
callq 0x2280
testl %eax, %eax
je 0x3147
leaq 0x867d(%rip), %rsi      # 0xb667
movq %r15, %rdi
callq 0x2280
testl %eax, %eax
je 0x314e
leaq 0x866a(%rip), %rsi      # 0xb66b
movq %r15, %rdi
callq 0x2280
testl %eax, %eax
je 0x3155
leaq 0x8656(%rip), %rsi      # 0xb66e
movq %r15, %rdi
callq 0x2280
testl %eax, %eax
je 0x315c
leaq 0x8642(%rip), %rsi      # 0xb671
movq %r15, %rdi
callq 0x2280
testl %eax, %eax
je 0x3163
leaq 0x862e(%rip), %rsi      # 0xb674
movq %r15, %rdi
callq 0x2280
movl %eax, %ecx
xorl %eax, %eax
testl %ecx, %ecx
setne %cl
andb %cl, %r14b
cmpb $0x1, %r14b
je 0x2d55
movb %cl, %al
negl %eax
orl $0x1f, %eax
jmp 0x3168
xorl %eax, %eax
jmp 0x3168
movl $0x1, %eax
jmp 0x3168
movl $0x2, %eax
jmp 0x3168
movl $0x3, %eax
jmp 0x3168
movl $0x4, %eax
jmp 0x3168
movl $0x5, %eax
jmp 0x3168
movl $0x6, %eax
jmp 0x3168
movl $0x7, %eax
jmp 0x3168
movl $0x8, %eax
jmp 0x3168
movl $0x9, %eax
jmp 0x3168
movl $0xa, %eax
jmp 0x3168
movl $0xb, %eax
jmp 0x3168
movl $0xc, %eax
jmp 0x3168
movl $0xd, %eax
jmp 0x3168
movl $0xe, %eax
jmp 0x3168
movl $0xf, %eax
jmp 0x3168
movl $0x10, %eax
jmp 0x3168
movl $0x11, %eax
jmp 0x3168
movl $0x12, %eax
jmp 0x3168
movl $0x13, %eax
jmp 0x3168
movl $0x14, %eax
jmp 0x3168
movl $0x15, %eax
jmp 0x3168
movl $0x16, %eax
jmp 0x3168
movl $0x17, %eax
jmp 0x3168
movl $0x18, %eax
jmp 0x3168
movl $0x19, %eax
jmp 0x3168
movl $0x1a, %eax
jmp 0x3168
movl $0x1b, %eax
jmp 0x3168
movl $0x1c, %eax
jmp 0x3168
movl $0x1d, %eax
jmp 0x3168
movl $0x1e, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq