// File: /workspace/github_cpp_makefile_star2_O3/lhydave[P]SysYCompilerLab/back/eeyore_AST.cpp
// Function: eeyore_AST::parseop(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
static shared_ptr<op_node> parseop(const string &line)
{
	std::istringstream line_f(line);
	shared_ptr<op_node> ret;
	switch (line[0])
	{
	// function call
	case 'c':
	{
		string temp, func_name;
		line_f >> temp >> func_name;
		auto func_call = make_shared<call_node>(func_name);
		while (!params.empty())
		{
			func_call->params.push_back(params.front());
			params.pop();
		}
		ret = func_call;
		break;
	}
	// unary operator
	case '-':
	case '!':
	{
		char ch;
		string subline;
		line_f >> ch;
		auto op = line.substr(0, 1);
		// number
		if (isdigit(line_f.peek()))
		{
			int num;
			line_f >> num;
			num = op == "!" ? !num : -num;
			ret = make_shared<num_node>(num);
			break;
		}
		// variable
		line_f >> subline;
		auto var = make_shared<var_node>(subline);
		ret = make_shared<op_node>(EXP_OP, op, var);
		break;
	}
	// binary, number, or variable
	default:
	{
		auto first_sq = line.find('[');
		auto last_sq = line.find(']');
		if (first_sq != std::string::npos) // array
		{
			auto left = line.substr(0, first_sq);
			auto right = line.substr(first_sq + 1, last_sq - first_sq - 1);
			ret = make_shared<op_node>(
				EXP_ARRAY, "m", parse_var_num(left), parse_var_num(right));
			break;
		}
		string left, op, right;
		line_f >> left;
		if (line_f.peek() == EOF) // a number of variable
			ret = parse_var_num(left);
		else // a binary operator
		{
			line_f >> op >> right;
			ret = make_shared<op_node>(
				EXP_OP, op, parse_var_num(left), parse_var_num(right));
			dbg_printf("left: %s, right: %s\n", left.c_str(), right.c_str());
		}
		break;
	}
	} // switch
	return ret;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x230, %rsp            # imm = 0x230
movq %rsi, %r14
movq %rdi, %rbx
leaq 0xb0(%rsp), %rdi
movl $0x8, %edx
callq 0x5480
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq (%r14), %rax
movzbl (%rax), %eax
cmpl $0x21, %eax
je 0x17fda
cmpl $0x2d, %eax
je 0x17fda
cmpl $0x63, %eax
jne 0x18095
leaq 0x60(%rsp), %r12
movq %r12, -0x10(%r12)
xorl %eax, %eax
movq %rax, -0x8(%r12)
movb %al, (%r12)
leaq 0x40(%rsp), %r13
movq %r13, -0x10(%r13)
movq %rax, -0x8(%r13)
movb %al, (%r13)
leaq 0xb0(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x5320
leaq 0x30(%rsp), %rsi
movq %rax, %rdi
callq 0x5320
leaq 0x78(%rsp), %r14
movq $0x0, -0x8(%r14)
leaq 0x70(%rsp), %rsi
leaq 0x10(%rsp), %rdx
leaq 0x30(%rsp), %rcx
movq %r14, %rdi
callq 0x19ae6
movq 0x1d864(%rip), %rsi     # 0x357b8
cmpq %rsi, 0x1d87d(%rip)     # 0x357d8
je 0x17f8a
leaq 0x1d844(%rip), %r15     # 0x357a8
movq 0x70(%rsp), %rdi
addq $0x50, %rdi
callq 0x19aa0
movq %r15, %rdi
callq 0x1b096
movq 0x1d837(%rip), %rsi     # 0x357b8
cmpq %rsi, 0x1d850(%rip)     # 0x357d8
jne 0x17f64
movq 0x70(%rsp), %rax
movq %rax, (%rbx)
addq $0x8, %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x19ee0
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x17fb0
callq 0x18806
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0x17fc7
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x5240
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
jne 0x1825b
jmp 0x18268
leaq 0x60(%rsp), %r15
movq %r15, -0x10(%r15)
movq $0x0, -0x8(%r15)
movb $0x0, (%r15)
leaq 0xb0(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x5340
leaq 0x30(%rsp), %rdi
movl $0x1, %ecx
movq %r14, %rsi
xorl %edx, %edx
callq 0x5260
leaq 0xb0(%rsp), %rdi
callq 0x50f0
addl $-0x30, %eax
cmpl $0x9, %eax
ja 0x181b5
leaq 0xb0(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x5160
leaq 0x10fbb(%rip), %rsi     # 0x29002
leaq 0x30(%rsp), %rdi
callq 0x50a0
leaq 0x10(%rsp), %rcx
movl (%rcx), %edx
xorl %esi, %esi
testl %edx, %edx
sete %sil
negl %edx
testl %eax, %eax
cmovnel %edx, %esi
movl %esi, (%rcx)
leaq 0x78(%rsp), %rdi
movq $0x0, -0x8(%rdi)
leaq 0x70(%rsp), %rsi
leaq 0x90(%rsp), %rdx
callq 0x196ac
movaps 0x70(%rsp), %xmm0
movups %xmm0, (%rbx)
jmp 0x18236
movq %r14, %rdi
movl $0x5b, %esi
xorl %edx, %edx
callq 0x5330
movq %rax, %r15
movq %r14, %rdi
movl $0x5d, %esi
xorl %edx, %edx
callq 0x5330
cmpq $-0x1, %r15
je 0x1829a
movq %rax, %r12
leaq 0x50(%rsp), %rdi
movq %r14, %rsi
xorl %edx, %edx
movq %r15, %rcx
callq 0x5260
leaq 0x1(%r15), %rdx
notq %r15
addq %r15, %r12
leaq 0x30(%rsp), %rdi
movq %r14, %rsi
movq %r12, %rcx
callq 0x5260
movl $0x2, 0xa0(%rsp)
leaq 0x10(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x17db8
leaq 0x90(%rsp), %r14
leaq 0x30(%rsp), %rsi
movq %r14, %rdi
callq 0x17db8
leaq 0x78(%rsp), %rdi
movq $0x0, -0x8(%rdi)
movq %r14, (%rsp)
leaq 0x11703(%rip), %r8      # 0x29839
leaq 0x70(%rsp), %rsi
leaq 0x28(%rsp), %rdx
leaq 0xa0(%rsp), %rcx
leaq 0x10(%rsp), %r9
callq 0x1a232
movaps 0x70(%rsp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, 0x70(%rsp)
movups %xmm0, (%rbx)
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x18174
callq 0x18806
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x18183
callq 0x18806
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1819e
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x5240
leaq 0x60(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x1825b
jmp 0x18268
leaq 0xb0(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x5320
leaq 0x78(%rsp), %rdi
movq $0x0, -0x8(%rdi)
leaq 0x70(%rsp), %rsi
leaq 0x10(%rsp), %rdx
leaq 0x50(%rsp), %rcx
callq 0x19f2a
leaq 0x90(%rsp), %rcx
movl $0x3, (%rcx)
leaq 0x18(%rsp), %rdi
movq $0x0, -0x8(%rdi)
leaq 0x10(%rsp), %rsi
leaq 0xa0(%rsp), %rdx
leaq 0x30(%rsp), %r8
leaq 0x70(%rsp), %r9
callq 0x19f9c
movaps 0x10(%rsp), %xmm0
movups %xmm0, (%rbx)
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x18236
callq 0x18806
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x18251
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x5240
movq 0x50(%rsp), %rdi
cmpq %r15, %rdi
je 0x18268
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x5240
movq 0x1cd59(%rip), %rsi     # 0x34fc8
leaq 0xb0(%rsp), %rdi
callq 0x5390
leaq 0x128(%rsp), %rdi
callq 0x50d0
addq $0x230, %rsp            # imm = 0x230
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x60(%rsp), %r15
movq %r15, -0x10(%r15)
xorl %eax, %eax
movq %rax, -0x8(%r15)
movb %al, (%r15)
leaq 0x40(%rsp), %r12
movq %r12, -0x10(%r12)
movq %rax, -0x8(%r12)
movb %al, (%r12)
leaq 0x80(%rsp), %r13
movq %r13, -0x10(%r13)
movq %rax, -0x8(%r13)
movb %al, (%r13)
leaq 0xb0(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x5320
leaq 0xb0(%rsp), %rdi
callq 0x50f0
cmpl $-0x1, %eax
je 0x183b1
leaq 0xb0(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x5320
leaq 0x70(%rsp), %rsi
movq %rax, %rdi
callq 0x5320
movl $0x3, 0x28(%rsp)
leaq 0x90(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x17db8
leaq 0xa0(%rsp), %r14
leaq 0x70(%rsp), %rsi
movq %r14, %rdi
callq 0x17db8
leaq 0x18(%rsp), %rdi
movq $0x0, -0x8(%rdi)
movq %r14, (%rsp)
leaq 0x10(%rsp), %rsi
leaq 0x2f(%rsp), %rdx
leaq 0x28(%rsp), %rcx
leaq 0x30(%rsp), %r8
leaq 0x90(%rsp), %r9
callq 0x1a370
movaps 0x10(%rsp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, 0x10(%rsp)
movups %xmm0, (%rbx)
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
je 0x1839d
callq 0x18806
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x183c8
callq 0x18806
jmp 0x183c8
leaq 0x10(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x17db8
movaps 0x10(%rsp), %xmm0
movups %xmm0, (%rbx)
movq 0x70(%rsp), %rdi
cmpq %r13, %rdi
je 0x183e2
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x5240
movq 0x30(%rsp), %rdi
cmpq %r12, %rdi
jne 0x18244
jmp 0x18251
jmp 0x184bd
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
je 0x18414
callq 0x18806
jmp 0x18414
movq %rax, %rbx
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x184c0
callq 0x18806
jmp 0x184c0
jmp 0x184bd
movq %rax, %rbx
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x1844e
callq 0x18806
jmp 0x1844e
movq %rax, %rbx
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x18462
callq 0x18806
jmp 0x18462
movq %rax, %rbx
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x18482
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x5240
jmp 0x18482
movq %rax, %rbx
leaq 0x60(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x1854f
jmp 0x1855c
movq %rax, %rbx
jmp 0x1855c
movq %rax, %rbx
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x184f5
callq 0x18806
jmp 0x184f5
jmp 0x184f2
jmp 0x184f2
jmp 0x184f2
jmp 0x184e8
movq %rax, %rbx
movq 0x70(%rsp), %rdi
cmpq %r13, %rdi
je 0x184da
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x5240
movq 0x30(%rsp), %rdi
cmpq %r12, %rdi
jne 0x18503
jmp 0x18510
jmp 0x184ed
movq %rax, %rbx
jmp 0x1852e
movq %rax, %rbx
jmp 0x18510
movq %rax, %rbx
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x18510
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x5240
movq 0x50(%rsp), %rdi
cmpq %r15, %rdi
jne 0x1854f
jmp 0x1855c
movq %rax, %rbx
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x1852e
callq 0x18806
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0x18545
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x5240
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
je 0x1855c
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x5240
movq 0x1ca65(%rip), %rsi     # 0x34fc8
leaq 0xb0(%rsp), %rdi
callq 0x5390
leaq 0x128(%rsp), %rdi
callq 0x50d0
movq %rbx, %rdi
callq 0x54c0
nop