// File: mxy161610207[P]codesim/src/MyPaser.cpp
// Function: MyPaser::Program::GetFuncOpFromStr(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
int MyPaser::Program::GetFuncOpFromStr(const string& context) {
	vector<string> lines;
	lines.clear();
	SplitStringToVect(context, lines, "\n");

	bool inFunc = 0;
	string curFunc = "";
	for (auto &l : lines) {
		//cout << l<< endl;
		if (!inFunc) {
			for (auto &func : this->funcName_) {
				//string afunc = "<" + func + ">";
				if (l.find(func) != string::npos) {
					inFunc = 1;
					curFunc = func;
				}
			}
		}
		else {
			//  0:   lea    0x0(%rip),%rsi        # 7 <main+0x7>
			//	7:   sub    $0x8, % rsp
			// 12:   callq  17 <main+0x17>
			// 1d:   retq

			int pos = l.find(":\t");
			if (pos != string::npos) {
				string op = l.substr(pos + 2, l.size() - pos - 2);
				int pos = op.find_first_of(" ");
				op = op.substr(0, pos);
				//cout << curFunc << ":" << op << endl;
				this->functOp_[curFunc].push_back(op);
			}
			else
			{
				inFunc = 0;
			}
		}
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x138(%rbp)
leaq -0x28(%rbp), %rdi
movq %rdi, -0x130(%rbp)
callq 0x45e0
movq -0x130(%rbp), %rdi
callq 0x4600
movq -0x10(%rbp), %rax
movq %rax, -0x128(%rbp)
leaq -0x49(%rbp), %rdi
movq %rdi, -0x120(%rbp)
callq 0x2400
movq -0x120(%rbp), %rdx
leaq 0x73a1(%rip), %rsi      # 0xa074
leaq -0x48(%rbp), %rdi
callq 0x44a0
jmp 0x2cde
movq -0x128(%rbp), %rdi
leaq -0x28(%rbp), %rsi
leaq -0x48(%rbp), %rdx
callq 0x28c0
jmp 0x2cf4
leaq -0x48(%rbp), %rdi
callq 0x2180
leaq -0x49(%rbp), %rdi
callq 0x22a0
movb $0x0, -0x5d(%rbp)
leaq -0x81(%rbp), %rdi
movq %rdi, -0x140(%rbp)
callq 0x2400
movq -0x140(%rbp), %rdx
leaq 0x735f(%rip), %rsi      # 0xa08a
leaq -0x80(%rbp), %rdi
callq 0x44a0
jmp 0x2d36
leaq -0x81(%rbp), %rdi
callq 0x22a0
leaq -0x28(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rdi
callq 0x4620
movq %rax, -0x98(%rbp)
movq -0x90(%rbp), %rdi
callq 0x4650
movq %rax, -0xa0(%rbp)
leaq -0x98(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x4680
testb $0x1, %al
jne 0x2d8f
jmp 0x3022
leaq -0x98(%rbp), %rdi
callq 0x46c0
movq %rax, -0xa8(%rbp)
testb $0x1, -0x5d(%rbp)
jne 0x2ebb
movq -0x138(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rdi
callq 0x4620
movq %rax, -0xb8(%rbp)
movq -0xb0(%rbp), %rdi
callq 0x4650
movq %rax, -0xc0(%rbp)
leaq -0xb8(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x4680
testb $0x1, %al
jne 0x2dfc
jmp 0x2eb6
leaq -0xb8(%rbp), %rdi
callq 0x46c0
movq %rax, -0xc8(%rbp)
movq -0xa8(%rbp), %rdi
movq -0xc8(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x2460
cmpq $-0x1, %rax
je 0x2ea3
movb $0x1, -0x5d(%rbp)
movq -0xc8(%rbp), %rsi
leaq -0x80(%rbp), %rdi
callq 0x2050
jmp 0x2e42
jmp 0x2ea3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x2e67
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x2180
leaq -0x49(%rbp), %rdi
callq 0x22a0
jmp 0x3048
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x81(%rbp), %rdi
callq 0x22a0
jmp 0x3048
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x303f
jmp 0x2ea5
leaq -0xb8(%rbp), %rdi
callq 0x46e0
jmp 0x2de0
jmp 0x300f
movq -0xa8(%rbp), %rdi
leaq 0x71bf(%rip), %rsi      # 0xa088
xorl %eax, %eax
movl %eax, %edx
callq 0x2450
movl %eax, -0xcc(%rbp)
movslq -0xcc(%rbp), %rax
cmpq $-0x1, %rax
je 0x3009
movq -0xa8(%rbp), %rdi
movq %rdi, -0x150(%rbp)
movl -0xcc(%rbp), %eax
addl $0x2, %eax
cltq
movq %rax, -0x148(%rbp)
callq 0x21b0
movq -0x150(%rbp), %rsi
movq -0x148(%rbp), %rdx
movq %rax, %rcx
movslq -0xcc(%rbp), %rax
subq %rax, %rcx
addq $-0x2, %rcx
leaq -0xf0(%rbp), %rdi
callq 0x2270
jmp 0x2f3b
leaq 0x7144(%rip), %rsi      # 0xa086
xorl %eax, %eax
movl %eax, %edx
movq %rdx, -0x158(%rbp)
leaq -0xf0(%rbp), %rdi
movq %rdi, -0x160(%rbp)
callq 0x2140
movq -0x160(%rbp), %rsi
movq -0x158(%rbp), %rdx
movl %eax, -0xf4(%rbp)
movslq -0xf4(%rbp), %rcx
leaq -0x118(%rbp), %rdi
callq 0x2270
jmp 0x2f89
leaq -0xf0(%rbp), %rdi
leaq -0x118(%rbp), %rsi
movq %rsi, -0x170(%rbp)
callq 0x22f0
movq -0x170(%rbp), %rdi
callq 0x2180
movq -0x138(%rbp), %rdi
addq $0x18, %rdi
leaq -0x80(%rbp), %rsi
callq 0x4760
movq %rax, -0x168(%rbp)
jmp 0x2fcc
movq -0x168(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x4550
jmp 0x2fe1
leaq -0xf0(%rbp), %rdi
callq 0x2180
jmp 0x300d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x2180
jmp 0x303f
movb $0x0, -0x5d(%rbp)
jmp 0x300f
jmp 0x3011
leaq -0x98(%rbp), %rdi
callq 0x46e0
jmp 0x2d73
leaq -0x80(%rbp), %rdi
callq 0x2180
leaq -0x28(%rbp), %rdi
callq 0x4700
xorl %eax, %eax
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
leaq -0x80(%rbp), %rdi
callq 0x2180
leaq -0x28(%rbp), %rdi
callq 0x4700
movq -0x58(%rbp), %rdi
callq 0x23f0
nopw (%rax,%rax)