// File: /workspace/github_cpp_makefile_star2_O2/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 %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x98(%rsp), %rdi
pushq $0x8
popq %rdx
callq 0x5480
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq (%r14), %rax
movzbl (%rax), %eax
cmpl $0x21, %eax
je 0x10ed6
cmpl $0x2d, %eax
je 0x10ed6
cmpl $0x63, %eax
jne 0x10f79
leaq 0x60(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
movb %cl, (%rax)
leaq 0x40(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
leaq 0x98(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x5310
leaq 0x30(%rsp), %rsi
movq %rax, %rdi
callq 0x5310
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x12d0c
leaq 0x1d906(%rip), %r14     # 0x2e7b0
movq 0x1d90f(%rip), %rsi     # 0x2e7c0
cmpq %rsi, 0x1d928(%rip)     # 0x2e7e0
je 0x11094
movq 0x10(%rsp), %rdi
addq $0x50, %rdi
callq 0x12d2a
movq %r14, %rdi
callq 0x1492c
jmp 0x10eaa
leaq 0x60(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x98(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x5340
leaq 0x30(%rsp), %rdi
pushq $0x1
popq %rcx
movq %r14, %rsi
xorl %edx, %edx
callq 0x5270
leaq 0x98(%rsp), %rdi
callq 0x50f0
addl $-0x30, %eax
cmpl $0x9, %eax
ja 0x1103f
leaq 0x98(%rsp), %rdi
movq %rsp, %rsi
callq 0x5170
leaq 0xe0af(%rip), %rsi      # 0x1efed
leaq 0x30(%rsp), %rdi
callq 0xc8ce
movq %rsp, %rsi
movl (%rsi), %ecx
xorl %edx, %edx
testl %ecx, %ecx
sete %dl
negl %ecx
testb %al, %al
cmovnel %edx, %ecx
movl %ecx, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0x1288b
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x13270
jmp 0x110a1
pushq $0x5b
popq %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x5330
movq %rax, %r15
pushq $0x5d
popq %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x5330
cmpq $-0x1, %r15
je 0x110de
movq %rax, %r12
leaq 0x50(%rsp), %rdi
movq %r14, %rsi
xorl %edx, %edx
movq %r15, %rcx
callq 0x5270
leaq 0x1(%r15), %rdx
notq %r15
addq %r15, %r12
leaq 0x30(%rsp), %rdi
movq %r14, %rsi
movq %r12, %rcx
callq 0x5270
movl $0x2, 0x88(%rsp)
movq %rsp, %rdi
leaq 0x50(%rsp), %rsi
callq 0x10d64
leaq 0x70(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x10d64
leaq 0xe827(%rip), %rdx      # 0x1f824
leaq 0x10(%rsp), %rdi
leaq 0x88(%rsp), %rsi
movq %rsp, %rcx
leaq 0x70(%rsp), %r8
callq 0x12d98
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x135e0
leaq 0x18(%rsp), %rdi
callq 0x11548
leaq 0x78(%rsp), %rdi
callq 0x11548
leaq 0x8(%rsp), %rdi
jmp 0x110a6
leaq 0x98(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x5310
leaq 0x10(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x12d56
leaq 0x70(%rsp), %rsi
movl $0x3, (%rsi)
movq %rsp, %rdi
leaq 0x30(%rsp), %rdx
leaq 0x10(%rsp), %rcx
callq 0x12d74
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x135e0
leaq 0x8(%rsp), %rdi
callq 0x11548
jmp 0x110a1
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x1320a
leaq 0x18(%rsp), %rdi
callq 0x11548
leaq 0x30(%rsp), %rdi
callq 0x5548
leaq 0x50(%rsp), %rdi
callq 0x5548
leaq 0x98(%rsp), %rdi
callq 0x5550
movq %rbx, %rax
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x60(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
leaq 0x40(%rsp), %rdx
movq %rdx, -0x10(%rdx)
andq $0x0, -0x8(%rdx)
movb %cl, (%rax)
movb %cl, (%rdx)
leaq 0x20(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
leaq 0x98(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x5310
leaq 0x98(%rsp), %rdi
callq 0x50f0
cmpl $-0x1, %eax
je 0x111ce
leaq 0x98(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x5310
leaq 0x10(%rsp), %rsi
movq %rax, %rdi
callq 0x5310
movl $0x3, 0x84(%rsp)
leaq 0x70(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x10d64
leaq 0x88(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x10d64
movq %rsp, %rdi
leaq 0x84(%rsp), %rsi
leaq 0x30(%rsp), %rdx
leaq 0x70(%rsp), %rcx
leaq 0x88(%rsp), %r8
callq 0x12dbf
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x135e0
leaq 0x8(%rsp), %rdi
callq 0x11548
leaq 0x90(%rsp), %rdi
callq 0x11548
leaq 0x78(%rsp), %rdi
jmp 0x111eb
movq %rsp, %rdi
leaq 0x50(%rsp), %rsi
callq 0x10d64
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x135e0
leaq 0x8(%rsp), %rdi
callq 0x11548
leaq 0x10(%rsp), %rdi
callq 0x5548
jmp 0x110ab
jmp 0x11250
movq %rax, %r14
leaq 0x90(%rsp), %rdi
callq 0x11548
jmp 0x11216
movq %rax, %r14
leaq 0x78(%rsp), %rdi
callq 0x11548
jmp 0x11253
jmp 0x11250
movq %rax, %r14
leaq 0x78(%rsp), %rdi
callq 0x11548
jmp 0x11236
movq %rax, %r14
leaq 0x8(%rsp), %rdi
jmp 0x11275
jmp 0x11268
jmp 0x11263
movq %rax, %r14
jmp 0x1128e
jmp 0x1126d
jmp 0x11268
jmp 0x11268
jmp 0x11268
jmp 0x11268
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x5548
jmp 0x1127a
jmp 0x11263
jmp 0x11268
movq %rax, %r14
jmp 0x11284
movq %rax, %r14
jmp 0x1127a
movq %rax, %r14
leaq 0x18(%rsp), %rdi
callq 0x11548
leaq 0x30(%rsp), %rdi
callq 0x5548
leaq 0x50(%rsp), %rdi
callq 0x5548
addq $0x8, %rbx
movq %rbx, %rdi
callq 0x11548
leaq 0x98(%rsp), %rdi
callq 0x5550
movq %r14, %rdi
callq 0x54c0
nop