// File: kiven-li[P]xbytes/xbytes.cpp
// Function: xbytes::xbytes::make_symbol(xbytes::rule&, xbytes::symbol&)
void xbytes::make_symbol(rule& r, symbol& s)
{
	if(s.name.size() == 0) return;

	//add to symbol table
	symbol* ss = find_symbol(s.name);
	if(ss == NULL)
	{
		ss = new symbol();
		ss->index = symbols.size();
		ss->name = s.name;
		ss->alias = s.alias;
		ss->type = ss->name[0] >= 'a' && ss->name[0] <= 'z' ? ST_NONTERMINAL : ST_TERMINAL;
		ss->precedence = -1;
		ss->associativity = AT_NONE;
		symbols.push_back(ss);
	}
	assert(ss != NULL);

	//attach to rule
	if(r.left == NULL)
	{
		r.left = ss;
		r.left_alias = s.alias;
	}
	else
	{
		r.rights.push_back(ss);
		r.right_alias.push_back(s.alias);
	}

	//clear symbol
	s.name.clear();
	s.alias.clear();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rdi
addq $0x8, %rdi
callq 0x3200
cmpq $0x0, %rax
jne 0x96d4
jmp 0x988f
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x8, %rsi
callq 0x9b70
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x97f9
movl $0xa8, %edi
callq 0x32f0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x40(%rbp)
callq 0xc1f0
jmp 0x970f
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rax
movq %rax, -0x20(%rbp)
addq $0x8, %rdi
callq 0xc4d0
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x18(%rbp), %rsi
addq $0x8, %rsi
movq -0x20(%rbp), %rdi
addq $0x8, %rdi
callq 0x3030
movq -0x18(%rbp), %rsi
addq $0x28, %rsi
movq -0x20(%rbp), %rdi
addq $0x28, %rdi
callq 0x3030
movq -0x20(%rbp), %rdi
addq $0x8, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3550
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x61, %ecx
movb %al, -0x41(%rbp)
jl 0x9791
movq -0x20(%rbp), %rdi
addq $0x8, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3550
movsbl (%rax), %eax
cmpl $0x7a, %eax
setle %al
movb %al, -0x41(%rbp)
movq -0x38(%rbp), %rdi
movb -0x41(%rbp), %dl
movl $0x1, %ecx
movl $0x2, %eax
testb $0x1, %dl
cmovnel %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x48(%rax)
movq -0x20(%rbp), %rax
movl $0xffffffff, 0xa0(%rax) # imm = 0xFFFFFFFF
movq -0x20(%rbp), %rax
movl $0x0, 0xa4(%rax)
addq $0x8, %rdi
leaq -0x20(%rbp), %rsi
callq 0xc690
jmp 0x97f9
movq -0x40(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0xa8, %esi
callq 0x3300
jmp 0x9895
cmpq $0x0, -0x20(%rbp)
je 0x9802
jmp 0x9821
leaq 0xfcd0(%rip), %rdi      # 0x194d9
leaq 0xf988(%rip), %rsi      # 0x19198
movl $0x45a, %edx            # imm = 0x45A
leaq 0xfcc8(%rip), %rcx      # 0x194e4
callq 0x31d0
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x984f
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rsi
addq $0x28, %rsi
movq -0x10(%rbp), %rdi
addq $0x10, %rdi
callq 0x3030
jmp 0x9875
movq -0x10(%rbp), %rdi
addq $0x30, %rdi
leaq -0x20(%rbp), %rsi
callq 0xc690
movq -0x10(%rbp), %rdi
addq $0x48, %rdi
movq -0x18(%rbp), %rsi
addq $0x28, %rsi
callq 0xd060
movq -0x18(%rbp), %rdi
addq $0x8, %rdi
callq 0x33e0
movq -0x18(%rbp), %rdi
addq $0x28, %rdi
callq 0x33e0
addq $0x50, %rsp
popq %rbp
retq
movq -0x28(%rbp), %rdi
callq 0x34e0
nop