// File: mxy161610207[P]codesim/src/MyPaser.cpp
// Function: MyPaser::GetFuncList(char*, MyPaser::Program&)
int MyPaser::GetFuncList(char* filename, Program& Prog) {
	char cmd[1000];
	string cmdres;

	sprintf(cmd, "mktemp");
	ExecCmd(cmd, cmdres);
	char tempFilename[50];
	strcpy(tempFilename, cmdres.c_str());
	//cout << tempFilename << endl;

	sprintf(cmd, "g++ -std=c++11 -O2 -c %s -o %s", filename, tempFilename);
	ExecCmd(cmd, cmdres);

	sprintf(cmd, "objdump -t %s", tempFilename);
	ExecCmd(cmd, cmdres);
	Prog.GetFuncNameFromStr(cmdres);
	//printf("%s\n", cmdres.c_str());

	//FILE* f = fopen("1.txt", "w");
	//fprintf(f, "%s", cmdres.c_str());
	//fclose(f);

	sprintf(cmd, "objdump --no-show-raw-insn -d %s", tempFilename);
	ExecCmd(cmd, cmdres);
	Prog.GetFuncOpFromStr(cmdres);

	/*string t = filename;
	if (t.find("a.cpp") != string::npos) {
		Prog.PrintfFuncOptoFile("A_op.txt");
	}
	else {
		Prog.PrintfFuncOptoFile("B_op.txt");
	}

	//f = fopen("2.txt", "w");
	//fprintf(f, "%s", cmdres.c_str());
	//fclose(f);
	//*/
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x550, %rsp            # imm = 0x550
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x420(%rbp), %rdi
callq 0x2340
leaq 0x6114(%rip), %rsi      # 0xa09a
xorl %eax, %eax
leaq -0x400(%rbp), %rdi
movq %rdi, -0x518(%rbp)
callq 0x2090
leaq -0x441(%rbp), %rdi
movq %rdi, -0x510(%rbp)
callq 0x2400
movq -0x518(%rbp), %rsi
movq -0x510(%rbp), %rdx
leaq -0x440(%rbp), %rdi
callq 0x44a0
jmp 0x3fca
leaq -0x440(%rbp), %rdi
leaq -0x420(%rbp), %rsi
callq 0x26e0
jmp 0x3fdf
leaq -0x440(%rbp), %rdi
callq 0x2180
leaq -0x441(%rbp), %rdi
callq 0x22a0
leaq -0x420(%rbp), %rdi
callq 0x2100
movq %rax, %rsi
leaq -0x490(%rbp), %rdi
movq %rdi, -0x530(%rbp)
callq 0x2210
movq -0x530(%rbp), %rcx
movq -0x8(%rbp), %rdx
leaq 0x6076(%rip), %rsi      # 0xa0a1
xorl %eax, %eax
leaq -0x400(%rbp), %rdi
movq %rdi, -0x528(%rbp)
callq 0x2090
leaq -0x4b1(%rbp), %rdi
movq %rdi, -0x520(%rbp)
callq 0x2400
movq -0x528(%rbp), %rsi
movq -0x520(%rbp), %rdx
leaq -0x4b0(%rbp), %rdi
callq 0x44a0
jmp 0x406f
leaq -0x4b0(%rbp), %rdi
leaq -0x420(%rbp), %rsi
callq 0x26e0
jmp 0x4084
leaq -0x4b0(%rbp), %rdi
callq 0x2180
leaq -0x4b1(%rbp), %rdi
callq 0x22a0
leaq 0x601d(%rip), %rsi      # 0xa0c0
xorl %eax, %eax
leaq -0x400(%rbp), %rdi
movq %rdi, -0x540(%rbp)
leaq -0x490(%rbp), %rdx
callq 0x2090
leaq -0x4d9(%rbp), %rdi
movq %rdi, -0x538(%rbp)
callq 0x2400
movq -0x540(%rbp), %rsi
movq -0x538(%rbp), %rdx
leaq -0x4d8(%rbp), %rdi
callq 0x44a0
jmp 0x40ee
leaq -0x4d8(%rbp), %rdi
leaq -0x420(%rbp), %rsi
callq 0x26e0
jmp 0x4103
leaq -0x4d8(%rbp), %rdi
callq 0x2180
leaq -0x4d9(%rbp), %rdi
callq 0x22a0
movq -0x10(%rbp), %rdi
leaq -0x420(%rbp), %rsi
callq 0x2a60
jmp 0x412d
leaq 0x5f9a(%rip), %rsi      # 0xa0ce
xorl %eax, %eax
leaq -0x400(%rbp), %rdi
movq %rdi, -0x550(%rbp)
leaq -0x490(%rbp), %rdx
callq 0x2090
leaq -0x501(%rbp), %rdi
movq %rdi, -0x548(%rbp)
callq 0x2400
movq -0x550(%rbp), %rsi
movq -0x548(%rbp), %rdx
leaq -0x500(%rbp), %rdi
callq 0x44a0
jmp 0x417f
leaq -0x500(%rbp), %rdi
leaq -0x420(%rbp), %rsi
callq 0x26e0
jmp 0x4194
leaq -0x500(%rbp), %rdi
callq 0x2180
leaq -0x501(%rbp), %rdi
callq 0x22a0
movq -0x10(%rbp), %rdi
leaq -0x420(%rbp), %rsi
callq 0x2c70
jmp 0x41be
ud2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x450(%rbp)
movl %eax, -0x454(%rbp)
jmp 0x41f2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x450(%rbp)
movl %eax, -0x454(%rbp)
leaq -0x440(%rbp), %rdi
callq 0x2180
leaq -0x441(%rbp), %rdi
callq 0x22a0
jmp 0x42d8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x450(%rbp)
movl %eax, -0x454(%rbp)
jmp 0x4235
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x450(%rbp)
movl %eax, -0x454(%rbp)
leaq -0x4b0(%rbp), %rdi
callq 0x2180
leaq -0x4b1(%rbp), %rdi
callq 0x22a0
jmp 0x42d8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x450(%rbp)
movl %eax, -0x454(%rbp)
jmp 0x4278
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x450(%rbp)
movl %eax, -0x454(%rbp)
leaq -0x4d8(%rbp), %rdi
callq 0x2180
leaq -0x4d9(%rbp), %rdi
callq 0x22a0
jmp 0x42d8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x450(%rbp)
movl %eax, -0x454(%rbp)
jmp 0x42d8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x450(%rbp)
movl %eax, -0x454(%rbp)
jmp 0x42cc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x450(%rbp)
movl %eax, -0x454(%rbp)
leaq -0x500(%rbp), %rdi
callq 0x2180
leaq -0x501(%rbp), %rdi
callq 0x22a0
leaq -0x420(%rbp), %rdi
callq 0x2180
movq -0x450(%rbp), %rdi
callq 0x23f0