// File: 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 %rbp
movq %rsp, %rbp
subq $0x420, %rsp            # imm = 0x420
movq %rdi, -0x3c8(%rbp)
movq %rdi, %rax
movq %rax, -0x3d0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x190(%rbp), %rdi
movl $0x8, %edx
callq 0x55c0
movq -0x3c8(%rbp), %rdi
movb $0x0, -0x191(%rbp)
callq 0x29540
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x5390
movsbl (%rax), %eax
movl %eax, -0x3bc(%rbp)
subl $0x21, %eax
je 0x23999
jmp 0x2380d
movl -0x3bc(%rbp), %eax
subl $0x2d, %eax
je 0x23999
jmp 0x2381e
movl -0x3bc(%rbp), %eax
subl $0x63, %eax
jne 0x23bc5
jmp 0x2382f
leaq -0x1b8(%rbp), %rdi
movq %rdi, -0x3e0(%rbp)
callq 0x54c0
leaq -0x1d8(%rbp), %rdi
callq 0x54c0
movq -0x3e0(%rbp), %rsi
leaq -0x190(%rbp), %rdi
callq 0x5430
movq %rax, -0x3d8(%rbp)
jmp 0x2386a
movq -0x3d8(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
callq 0x5430
jmp 0x2387f
leaq -0x1f8(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
callq 0x2c690
jmp 0x23894
jmp 0x23896
leaq 0x4efcb(%rip), %rdi     # 0x72868
callq 0x242b0
movb %al, -0x3e1(%rbp)
jmp 0x238aa
movb -0x3e1(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x238bb
jmp 0x23940
leaq -0x1f8(%rbp), %rdi
callq 0x2c700
addq $0x50, %rax
movq %rax, -0x3f8(%rbp)
leaq 0x4ef8f(%rip), %rdi     # 0x72868
callq 0x2c790
movq %rax, -0x3f0(%rbp)
jmp 0x238e7
movq -0x3f0(%rbp), %rsi
movq -0x3f8(%rbp), %rdi
callq 0x2c720
jmp 0x238fc
leaq 0x4ef65(%rip), %rdi     # 0x72868
callq 0x242d0
jmp 0x2390a
jmp 0x23896
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1e0(%rbp)
movl %eax, -0x1e4(%rbp)
jmp 0x2397c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1e0(%rbp)
movl %eax, -0x1e4(%rbp)
leaq -0x1f8(%rbp), %rdi
callq 0x2c7e0
jmp 0x2397c
movq -0x3c8(%rbp), %rdi
leaq -0x1f8(%rbp), %rsi
callq 0x2c7b0
leaq -0x1f8(%rbp), %rdi
callq 0x2c7e0
leaq -0x1d8(%rbp), %rdi
callq 0x56c0
leaq -0x1b8(%rbp), %rdi
callq 0x56c0
jmp 0x23fb1
leaq -0x1d8(%rbp), %rdi
callq 0x56c0
leaq -0x1b8(%rbp), %rdi
callq 0x56c0
jmp 0x23ff3
leaq -0x220(%rbp), %rdi
callq 0x54c0
leaq -0x190(%rbp), %rdi
leaq -0x1f9(%rbp), %rsi
callq 0x5470
jmp 0x239ba
movq -0x10(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
leaq -0x240(%rbp), %rdi
movl $0x1, %ecx
callq 0x5340
jmp 0x239d5
leaq -0x190(%rbp), %rdi
callq 0x5130
movl %eax, -0x3fc(%rbp)
jmp 0x239e9
movl -0x3fc(%rbp), %edi
callq 0x52c0
cmpl $0x0, %eax
je 0x23add
leaq -0x190(%rbp), %rdi
leaq -0x244(%rbp), %rsi
callq 0x51f0
jmp 0x23a12
leaq 0x2a3b3(%rip), %rsi     # 0x4ddcc
leaq -0x240(%rbp), %rdi
callq 0x13dd0
movb %al, -0x3fd(%rbp)
jmp 0x23a2d
movb -0x3fd(%rbp), %al
testb $0x1, %al
jne 0x23a39
jmp 0x23a52
cmpl $0x0, -0x244(%rbp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x404(%rbp)
jmp 0x23a60
xorl %eax, %eax
subl -0x244(%rbp), %eax
movl %eax, -0x404(%rbp)
movl -0x404(%rbp), %eax
movl %eax, -0x244(%rbp)
leaq -0x258(%rbp), %rdi
leaq -0x244(%rbp), %rsi
callq 0x2af40
jmp 0x23a81
movq -0x3c8(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x2c800
leaq -0x258(%rbp), %rdi
callq 0x2afe0
movl $0x2, -0x25c(%rbp)
jmp 0x23b8b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1e0(%rbp)
movl %eax, -0x1e4(%rbp)
jmp 0x23bb4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1e0(%rbp)
movl %eax, -0x1e4(%rbp)
jmp 0x23ba8
leaq -0x190(%rbp), %rdi
leaq -0x220(%rbp), %rsi
callq 0x5430
jmp 0x23af2
leaq -0x270(%rbp), %rdi
leaq -0x220(%rbp), %rsi
callq 0x2c830
jmp 0x23b07
movl $0x3, -0x284(%rbp)
leaq -0x280(%rbp), %rdi
leaq -0x284(%rbp), %rsi
leaq -0x240(%rbp), %rdx
leaq -0x270(%rbp), %rcx
callq 0x2c8a0
jmp 0x23b34
movq -0x3c8(%rbp), %rdi
leaq -0x280(%rbp), %rsi
callq 0x2c920
leaq -0x280(%rbp), %rdi
callq 0x25790
movl $0x2, -0x25c(%rbp)
leaq -0x270(%rbp), %rdi
callq 0x2b0a0
jmp 0x23b8b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1e0(%rbp)
movl %eax, -0x1e4(%rbp)
leaq -0x270(%rbp), %rdi
callq 0x2b0a0
jmp 0x23ba8
leaq -0x240(%rbp), %rdi
callq 0x56c0
leaq -0x220(%rbp), %rdi
callq 0x56c0
jmp 0x23fb1
leaq -0x240(%rbp), %rdi
callq 0x56c0
leaq -0x220(%rbp), %rdi
callq 0x56c0
jmp 0x23ff3
movq -0x10(%rbp), %rdi
movl $0x5b, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x5460
movq %rax, -0x290(%rbp)
movq -0x10(%rbp), %rdi
movl $0x5d, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x5460
movq %rax, -0x298(%rbp)
cmpq $-0x1, -0x290(%rbp)
je 0x23da4
movq -0x10(%rbp), %rsi
movq -0x290(%rbp), %rcx
xorl %eax, %eax
movl %eax, %edx
leaq -0x2b8(%rbp), %rdi
callq 0x5340
jmp 0x23c22
movq -0x10(%rbp), %rsi
movq -0x290(%rbp), %rcx
movq %rcx, %rdx
incq %rdx
movq -0x298(%rbp), %rax
notq %rcx
addq %rax, %rcx
leaq -0x2d8(%rbp), %rdi
callq 0x5340
jmp 0x23c4e
movl $0x2, -0x2ec(%rbp)
leaq -0x300(%rbp), %rdi
leaq -0x2b8(%rbp), %rsi
callq 0x23670
jmp 0x23c6d
leaq -0x310(%rbp), %rdi
leaq -0x2d8(%rbp), %rsi
callq 0x23670
jmp 0x23c82
leaq 0x2aedf(%rip), %rdx     # 0x4eb68
leaq -0x2e8(%rbp), %rdi
leaq -0x2ec(%rbp), %rsi
leaq -0x300(%rbp), %rcx
leaq -0x310(%rbp), %r8
callq 0x2c950
jmp 0x23cac
movq -0x3c8(%rbp), %rdi
leaq -0x2e8(%rbp), %rsi
callq 0x2c920
leaq -0x2e8(%rbp), %rdi
callq 0x25790
leaq -0x310(%rbp), %rdi
callq 0x25790
leaq -0x300(%rbp), %rdi
callq 0x25790
movl $0x2, -0x25c(%rbp)
leaq -0x2d8(%rbp), %rdi
callq 0x56c0
leaq -0x2b8(%rbp), %rdi
callq 0x56c0
jmp 0x23fb1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1e0(%rbp)
movl %eax, -0x1e4(%rbp)
jmp 0x23ff3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1e0(%rbp)
movl %eax, -0x1e4(%rbp)
jmp 0x23d93
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1e0(%rbp)
movl %eax, -0x1e4(%rbp)
jmp 0x23d87
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1e0(%rbp)
movl %eax, -0x1e4(%rbp)
jmp 0x23d7b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1e0(%rbp)
movl %eax, -0x1e4(%rbp)
leaq -0x310(%rbp), %rdi
callq 0x25790
leaq -0x300(%rbp), %rdi
callq 0x25790
leaq -0x2d8(%rbp), %rdi
callq 0x56c0
leaq -0x2b8(%rbp), %rdi
callq 0x56c0
jmp 0x23ff3
leaq -0x330(%rbp), %rdi
movq %rdi, -0x410(%rbp)
callq 0x54c0
leaq -0x350(%rbp), %rdi
callq 0x54c0
leaq -0x370(%rbp), %rdi
callq 0x54c0
movq -0x410(%rbp), %rsi
leaq -0x190(%rbp), %rdi
callq 0x5430
jmp 0x23de4
leaq -0x190(%rbp), %rdi
callq 0x5130
movl %eax, -0x414(%rbp)
jmp 0x23df8
movl -0x414(%rbp), %eax
cmpl $-0x1, %eax
jne 0x23e53
leaq -0x380(%rbp), %rdi
leaq -0x330(%rbp), %rsi
callq 0x23670
jmp 0x23e18
movq -0x3c8(%rbp), %rdi
leaq -0x380(%rbp), %rsi
callq 0x2c920
leaq -0x380(%rbp), %rdi
callq 0x25790
jmp 0x23f5b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1e0(%rbp)
movl %eax, -0x1e4(%rbp)
jmp 0x23f8b
leaq -0x190(%rbp), %rdi
leaq -0x350(%rbp), %rsi
callq 0x5430
movq %rax, -0x420(%rbp)
jmp 0x23e6f
movq -0x420(%rbp), %rdi
leaq -0x370(%rbp), %rsi
callq 0x5430
jmp 0x23e84
movl $0x3, -0x394(%rbp)
leaq -0x3a8(%rbp), %rdi
leaq -0x330(%rbp), %rsi
callq 0x23670
jmp 0x23ea3
leaq -0x3b8(%rbp), %rdi
leaq -0x370(%rbp), %rsi
callq 0x23670
jmp 0x23eb8
leaq -0x390(%rbp), %rdi
leaq -0x394(%rbp), %rsi
leaq -0x350(%rbp), %rdx
leaq -0x3a8(%rbp), %rcx
leaq -0x3b8(%rbp), %r8
callq 0x2c9e0
jmp 0x23ee2
movq -0x3c8(%rbp), %rdi
leaq -0x390(%rbp), %rsi
callq 0x2c920
leaq -0x390(%rbp), %rdi
callq 0x25790
leaq -0x3b8(%rbp), %rdi
callq 0x25790
leaq -0x3a8(%rbp), %rdi
callq 0x25790
jmp 0x23f5b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1e0(%rbp)
movl %eax, -0x1e4(%rbp)
jmp 0x23f4d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1e0(%rbp)
movl %eax, -0x1e4(%rbp)
leaq -0x3b8(%rbp), %rdi
callq 0x25790
leaq -0x3a8(%rbp), %rdi
callq 0x25790
jmp 0x23f8b
movl $0x2, -0x25c(%rbp)
leaq -0x370(%rbp), %rdi
callq 0x56c0
leaq -0x350(%rbp), %rdi
callq 0x56c0
leaq -0x330(%rbp), %rdi
callq 0x56c0
jmp 0x23fb1
leaq -0x370(%rbp), %rdi
callq 0x56c0
leaq -0x350(%rbp), %rdi
callq 0x56c0
leaq -0x330(%rbp), %rdi
callq 0x56c0
jmp 0x23ff3
movb $0x1, -0x191(%rbp)
movl $0x1, -0x25c(%rbp)
testb $0x1, -0x191(%rbp)
jne 0x23fd7
movq -0x3c8(%rbp), %rdi
callq 0x25790
leaq -0x190(%rbp), %rdi
callq 0x56b8
movq -0x3d0(%rbp), %rax
addq $0x420, %rsp            # imm = 0x420
popq %rbp
retq
movq -0x3c8(%rbp), %rdi
callq 0x25790
leaq -0x190(%rbp), %rdi
callq 0x56b8
movq -0x1e0(%rbp), %rdi
callq 0x5610
nopw (%rax,%rax)