// File: /workspace/github_cpp_makefile_star2_O2/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 0x2c81
incq %r15
movq %r15, %rdi
callq 0x2320
movl %eax, %ecx
cmpl $0x21, %eax
setae %dl
pushq $-0x1
popq %rax
cmovbl %ecx, %eax
andb %r14b, %dl
cmpb $0x1, %dl
jne 0x2f95
leaq 0x7989(%rip), %rsi      # 0xa603
movl %ebx, %edi
callq 0x27ef
leaq 0x7ae4(%rip), %rsi      # 0xa76c
movq %r15, %rdi
callq 0x27c0
movl %eax, %ecx
xorl %eax, %eax
testb %cl, %cl
jne 0x2f95
leaq 0x78e9(%rip), %rsi      # 0xa58c
movq %r15, %rdi
callq 0x27c0
testb %al, %al
je 0x2cb6
pushq $0x1
jmp 0x2f94
leaq 0x795e(%rip), %rsi      # 0xa61b
movq %r15, %rdi
callq 0x27c0
testb %al, %al
je 0x2cd0
pushq $0x2
jmp 0x2f94
leaq 0x7947(%rip), %rsi      # 0xa61e
movq %r15, %rdi
callq 0x27c0
testb %al, %al
je 0x2cea
pushq $0x3
jmp 0x2f94
leaq 0x7930(%rip), %rsi      # 0xa621
movq %r15, %rdi
callq 0x27c0
testb %al, %al
je 0x2d04
pushq $0x4
jmp 0x2f94
leaq 0x7919(%rip), %rsi      # 0xa624
movq %r15, %rdi
callq 0x27c0
testb %al, %al
je 0x2d1e
pushq $0x5
jmp 0x2f94
leaq 0x7902(%rip), %rsi      # 0xa627
movq %r15, %rdi
callq 0x27c0
testb %al, %al
je 0x2d38
pushq $0x6
jmp 0x2f94
leaq 0x78eb(%rip), %rsi      # 0xa62a
movq %r15, %rdi
callq 0x27c0
testb %al, %al
je 0x2d52
pushq $0x7
jmp 0x2f94
leaq 0x78d4(%rip), %rsi      # 0xa62d
movq %r15, %rdi
callq 0x27c0
testb %al, %al
je 0x2d6c
pushq $0x8
jmp 0x2f94
leaq 0x78bd(%rip), %rsi      # 0xa630
movq %r15, %rdi
callq 0x27c0
testb %al, %al
je 0x2d86
pushq $0x9
jmp 0x2f94
leaq 0x78a6(%rip), %rsi      # 0xa633
movq %r15, %rdi
callq 0x27c0
testb %al, %al
je 0x2da0
pushq $0xa
jmp 0x2f94
leaq 0x788f(%rip), %rsi      # 0xa636
movq %r15, %rdi
callq 0x27c0
testb %al, %al
je 0x2dba
pushq $0xb
jmp 0x2f94
leaq 0x7878(%rip), %rsi      # 0xa639
movq %r15, %rdi
callq 0x27c0
testb %al, %al
je 0x2dd4
pushq $0xc
jmp 0x2f94
leaq 0x7861(%rip), %rsi      # 0xa63c
movq %r15, %rdi
callq 0x27c0
testb %al, %al
je 0x2dee
pushq $0xd
jmp 0x2f94
leaq 0x784a(%rip), %rsi      # 0xa63f
movq %r15, %rdi
callq 0x27c0
testb %al, %al
je 0x2e08
pushq $0xe
jmp 0x2f94
leaq 0x7833(%rip), %rsi      # 0xa642
movq %r15, %rdi
callq 0x27c0
testb %al, %al
je 0x2e22
pushq $0xf
jmp 0x2f94
leaq 0x781c(%rip), %rsi      # 0xa645
movq %r15, %rdi
callq 0x27c0
testb %al, %al
je 0x2e3c
pushq $0x10
jmp 0x2f94
leaq 0x7805(%rip), %rsi      # 0xa648
movq %r15, %rdi
callq 0x27c0
testb %al, %al
je 0x2e56
pushq $0x11
jmp 0x2f94
leaq 0x77ee(%rip), %rsi      # 0xa64b
movq %r15, %rdi
callq 0x27c0
testb %al, %al
je 0x2e70
pushq $0x12
jmp 0x2f94
leaq 0x77d7(%rip), %rsi      # 0xa64e
movq %r15, %rdi
callq 0x27c0
testb %al, %al
je 0x2e8a
pushq $0x13
jmp 0x2f94
leaq 0x77c0(%rip), %rsi      # 0xa651
movq %r15, %rdi
callq 0x27c0
testb %al, %al
je 0x2ea4
pushq $0x14
jmp 0x2f94
leaq 0x77a9(%rip), %rsi      # 0xa654
movq %r15, %rdi
callq 0x27c0
testb %al, %al
je 0x2ebe
pushq $0x15
jmp 0x2f94
leaq 0x7792(%rip), %rsi      # 0xa657
movq %r15, %rdi
callq 0x27c0
testb %al, %al
je 0x2ed8
pushq $0x16
jmp 0x2f94
leaq 0x777b(%rip), %rsi      # 0xa65a
movq %r15, %rdi
callq 0x27c0
testb %al, %al
je 0x2ef2
pushq $0x17
jmp 0x2f94
leaq 0x7764(%rip), %rsi      # 0xa65d
movq %r15, %rdi
callq 0x27c0
testb %al, %al
je 0x2f0c
pushq $0x18
jmp 0x2f94
leaq 0x774d(%rip), %rsi      # 0xa660
movq %r15, %rdi
callq 0x27c0
testb %al, %al
je 0x2f23
pushq $0x19
jmp 0x2f94
leaq 0x7739(%rip), %rsi      # 0xa663
movq %r15, %rdi
callq 0x27c0
testb %al, %al
je 0x2f3a
pushq $0x1a
jmp 0x2f94
leaq 0x7726(%rip), %rsi      # 0xa667
movq %r15, %rdi
callq 0x27c0
testb %al, %al
je 0x2f51
pushq $0x1b
jmp 0x2f94
leaq 0x7713(%rip), %rsi      # 0xa66b
movq %r15, %rdi
callq 0x27c0
testb %al, %al
je 0x2f68
pushq $0x1c
jmp 0x2f94
leaq 0x76ff(%rip), %rsi      # 0xa66e
movq %r15, %rdi
callq 0x27c0
testb %al, %al
je 0x2f7f
pushq $0x1d
jmp 0x2f94
leaq 0x76eb(%rip), %rsi      # 0xa671
movq %r15, %rdi
callq 0x27c0
testb %al, %al
je 0x2fa0
pushq $0x1e
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x76cd(%rip), %rsi      # 0xa674
movq %r15, %rdi
callq 0x27c0
xorb $0x1, %r14b
orb %al, %r14b
je 0x2c73
movzbl %al, %eax
decl %eax
orl $0x1f, %eax
jmp 0x2f95