// File: /workspace/github_cpp_makefile_star2_O3/haught[P]cws_plugin/cws_plugin.cpp
// Function: writeManifest_xml(char*, char*, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>>&)
void writeManifest_xml(char *dirPath,char *fileName,map<string, string> &valueMap) {
	ofstream ofile;               //��������ļ�
	ofile.open(fileName);     //��Ϊ����ļ���
	
	int layerNum = static_cast<int>(strtol(valueMap.at("totalLayer").c_str(), NULL, 0));
	ofile << "<?xml version = \"1.0\" encoding = \"utf-8\"?>" << endl;
	ofile << "<manifest FileVersion = \"1\">" << endl;

	ofile << "<GCode>" << endl;
	ofile << "  <name>1.gcode</name>" << endl;
	ofile << "</GCode>" << endl;

	ofile << "<ScenePreview>" << endl;
	ofile << "  <Default>preview.png</Default>" << endl;
	ofile << "</ScenePreview>" << endl;


	ofile << "<Slices>" << endl;

	char *format, *fileFormat;
	int totalLayer = layerNum;
	if (totalLayer < 10000) {
		format = (char*)"%s/1%04d.png";
		fileFormat = (char*)"1%04d.png";
	}
	else if (totalLayer >= 10000 && totalLayer < 100000) {
		format = (char*)"%s/1%05d.png";
		fileFormat = (char*)"1%05d.png";
	}
	else if (totalLayer >= 100000 && totalLayer < 1000000) {
		format = (char*)"%s/1%06d.png";
		fileFormat = (char*)"1%06d.png";
	}
	else if (totalLayer >= 1000000 && totalLayer < 10000000) {
		format = (char*)"%s/1%07d.png";
		fileFormat = (char*)"1%07d.png";
	}
	else if (totalLayer >= 10000000 && totalLayer < 100000000) {			//impossible
		format = (char*)"%s/1%08d.png";
		fileFormat = (char*)"1%08d.png";
	}
	else {
		format = (char*)"%s/1%020d.png";
		fileFormat = (char*)"1%020d.png";
	}
	char oldName[4096], newName[4096];
	for (int i = 0; i < totalLayer; i++) {
		snprintf(oldName, sizeof(oldName), "%s/%d.png", dirPath, i + 1);
		snprintf(newName, sizeof(newName), format, dirPath, i + 1);
		rename(oldName, newName);
	}

	for (int i = 0; i < layerNum; i++) {
		ofile << "  <Slice>" << endl;
		snprintf(newName, sizeof(newName), fileFormat, i + 1);
		ofile << "		<name>" << string(newName) << "</name>" << endl;
		ofile << "  </Slice>" << endl;
	}
	ofile << "</Slices>" << endl;

	ofile << "<VectorSlices/>" << endl;

	ofile << "<SliceProfile>" << endl;
	ofile << "	<name>default.slicing</name>" << endl;
	ofile << "</SliceProfile>" << endl;


	ofile << "</manifest>" << endl;

	ofile.close();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2238, %rsp           # imm = 0x2238
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r13
leaq -0x260(%rbp), %r15
movq %r15, %rdi
callq 0x2350
movq %r15, %rdi
movq %r14, %rsi
movl $0x10, %edx
callq 0x2060
leaq -0x1250(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x3dac(%rip), %rsi      # 0x8020
leaq 0x3daf(%rip), %rdx      # 0x802a
leaq -0x1260(%rbp), %rdi
callq 0x7334
leaq -0x1260(%rbp), %rsi
movq %rbx, %rdi
callq 0x70c6
movq (%rax), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2290
movq %rax, %r12
movq -0x1260(%rbp), %rdi
cmpq %r14, %rdi
je 0x42c0
movq -0x1250(%rbp), %rsi
incq %rsi
callq 0x2210
leaq 0x439b(%rip), %rsi      # 0x8662
leaq -0x260(%rbp), %rbx
movl $0x2a, %edx
movq %rbx, %rdi
callq 0x2240
movq -0x260(%rbp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
leaq -0x260(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
leaq 0x437c(%rip), %rsi      # 0x868d
leaq -0x260(%rbp), %rbx
movl $0x1c, %edx
movq %rbx, %rdi
callq 0x2240
movq -0x260(%rbp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
leaq -0x260(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
leaq 0x434f(%rip), %rsi      # 0x86aa
leaq -0x260(%rbp), %rbx
movl $0x7, %edx
movq %rbx, %rdi
callq 0x2240
movq -0x260(%rbp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
leaq -0x260(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
leaq 0x430d(%rip), %rsi      # 0x86b2
leaq -0x260(%rbp), %rbx
movl $0x16, %edx
movq %rbx, %rdi
callq 0x2240
movq -0x260(%rbp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
leaq -0x260(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
leaq 0x42da(%rip), %rsi      # 0x86c9
leaq -0x260(%rbp), %rbx
movl $0x8, %edx
movq %rbx, %rdi
callq 0x2240
movq -0x260(%rbp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
leaq -0x260(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
leaq 0x4299(%rip), %rsi      # 0x86d2
leaq -0x260(%rbp), %rbx
movl $0xe, %edx
movq %rbx, %rdi
callq 0x2240
movq -0x260(%rbp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
leaq -0x260(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
leaq 0x425e(%rip), %rsi      # 0x86e1
leaq -0x260(%rbp), %rbx
movl $0x20, %edx
movq %rbx, %rdi
callq 0x2240
movq -0x260(%rbp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
leaq -0x260(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
leaq 0x4235(%rip), %rsi      # 0x8702
leaq -0x260(%rbp), %rbx
movl $0xf, %edx
movq %rbx, %rdi
callq 0x2240
movq -0x260(%rbp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
leaq -0x260(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
leaq 0x41fb(%rip), %rsi      # 0x8712
leaq -0x260(%rbp), %rbx
movl $0x8, %edx
movq %rbx, %rdi
callq 0x2240
movq -0x260(%rbp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
cmpl $0x2710, %r12d          # imm = 0x2710
jge 0x4582
leaq 0x41b8(%rip), %rax      # 0x871e
movq %rax, -0x30(%rbp)
testl %r12d, %r12d
jle 0x468a
movq %r13, %r15
leaq 0x419e(%rip), %rbx      # 0x871b
jmp 0x460b
cmpl $0x186a0, %r12d         # imm = 0x186A0
jae 0x459f
leaq 0x4199(%rip), %rax      # 0x872b
movq %rax, -0x30(%rbp)
leaq 0x418b(%rip), %rbx      # 0x8728
jmp 0x4608
cmpl $0xf4240, %r12d         # imm = 0xF4240
jae 0x45bc
leaq 0x4189(%rip), %rax      # 0x8738
movq %rax, -0x30(%rbp)
leaq 0x417b(%rip), %rbx      # 0x8735
jmp 0x4608
cmpl $0x989680, %r12d        # imm = 0x989680
jae 0x45d9
leaq 0x4179(%rip), %rax      # 0x8745
movq %rax, -0x30(%rbp)
leaq 0x416b(%rip), %rbx      # 0x8742
jmp 0x4608
cmpl $0x5f5e100, %r12d       # imm = 0x5F5E100
leaq 0x4168(%rip), %rax      # 0x874f
leaq 0x416e(%rip), %rbx      # 0x875c
cmovbq %rax, %rbx
leaq 0x4159(%rip), %rax      # 0x8752
leaq 0x415f(%rip), %rcx      # 0x875f
cmovbq %rax, %rcx
movq %rcx, -0x30(%rbp)
movq %r13, %r15
movq %r12, -0x58(%rbp)
negl %r12d
movq %r12, -0x60(%rbp)
movl $0x1, %r14d
leaq -0x1260(%rbp), %r12
leaq -0x2260(%rbp), %r13
movl $0x1000, %esi           # imm = 0x1000
movq %r12, %rdi
leaq 0x4131(%rip), %rdx      # 0x876a
movq %r15, %rcx
movl %r14d, %r8d
xorl %eax, %eax
callq 0x2310
movl $0x1000, %esi           # imm = 0x1000
movq %r13, %rdi
movq %rbx, %rdx
movq %r15, %rcx
movl %r14d, %r8d
xorl %eax, %eax
callq 0x2310
movq %r12, %rdi
movq %r13, %rsi
callq 0x2140
movq -0x60(%rbp), %rax
addl %r14d, %eax
incl %eax
movl %r14d, %ecx
incl %ecx
movl %ecx, %r14d
cmpl $0x1, %eax
jne 0x462a
movq -0x58(%rbp), %r12
leaq -0x260(%rbp), %r15
xorl %eax, %eax
testl %r12d, %r12d
cmovlel %eax, %r12d
negl %r12d
movl $0x1, %r14d
leaq -0x2260(%rbp), %rbx
leal (%r12,%r14), %eax
cmpl $0x1, %eax
je 0x47f5
movl $0x9, %edx
movq %r15, %rdi
leaq 0x40b5(%rip), %rsi      # 0x8774
callq 0x2240
movq -0x260(%rbp), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
movl $0x1000, %esi           # imm = 0x1000
movq %rbx, %rdi
movq -0x30(%rbp), %rdx
movl %r14d, %ecx
xorl %eax, %eax
callq 0x2310
movl $0x8, %edx
movq %r15, %rdi
leaq 0x406a(%rip), %rsi      # 0x877e
callq 0x2240
movq %r12, %r13
leaq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
movq %rbx, %rdi
callq 0x2110
leaq (%rax,%rbp), %rdx
addq $-0x2260, %rdx          # imm = 0xDDA0
leaq -0x50(%rbp), %rdi
movq %rbx, %rsi
callq 0x7334
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq %r15, %rdi
callq 0x2240
movq %rax, %r12
movl $0x7, %edx
movq %rax, %rdi
leaq 0x3f5c(%rip), %rsi      # 0x86c1
callq 0x2240
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
movq %r12, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
movq %r13, %r12
je 0x47ae
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2210
movl $0xa, %edx
movq %r15, %rdi
leaq 0x3fca(%rip), %rsi      # 0x8787
callq 0x2240
movq -0x260(%rbp), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
incl %r14d
movq %rax, %rdi
callq 0x2170
jmp 0x46a3
leaq 0x3f96(%rip), %rsi      # 0x8792
leaq -0x260(%rbp), %rbx
movl $0x9, %edx
movq %rbx, %rdi
callq 0x2240
movq -0x260(%rbp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
leaq -0x260(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
leaq 0x3f56(%rip), %rsi      # 0x879c
leaq -0x260(%rbp), %rbx
movl $0xf, %edx
movq %rbx, %rdi
callq 0x2240
movq -0x260(%rbp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
leaq -0x260(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
leaq 0x3f1c(%rip), %rsi      # 0x87ac
leaq -0x260(%rbp), %rbx
movl $0xe, %edx
movq %rbx, %rdi
callq 0x2240
movq -0x260(%rbp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
leaq -0x260(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
leaq 0x3ee1(%rip), %rsi      # 0x87bb
leaq -0x260(%rbp), %rbx
movl $0x1d, %edx
movq %rbx, %rdi
callq 0x2240
movq -0x260(%rbp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
leaq -0x260(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
leaq 0x3eb5(%rip), %rsi      # 0x87d9
leaq -0x260(%rbp), %rbx
movl $0xf, %edx
movq %rbx, %rdi
callq 0x2240
movq -0x260(%rbp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
leaq -0x260(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
leaq 0x3e7b(%rip), %rsi      # 0x87e9
leaq -0x260(%rbp), %rbx
movl $0xb, %edx
movq %rbx, %rdi
callq 0x2240
movq -0x260(%rbp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
leaq -0x260(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
leaq -0x260(%rbp), %rdi
callq 0x22a0
movq 0x660c(%rip), %rax      # 0xafd0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq -0x258(%rbp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, -0x260(%rbp,%rcx)
callq 0x21b0
leaq -0x168(%rbp), %rdi
callq 0x20e0
addq $0x2238, %rsp           # imm = 0x2238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0x1260(%rbp), %rdi
cmpq %r14, %rdi
je 0x4a48
movq -0x1250(%rbp), %rsi
jmp 0x4a3b
jmp 0x4a45
jmp 0x4a45
jmp 0x4a45
jmp 0x4a45
jmp 0x4a45
movq %rax, %rbx
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x4a48
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2210
jmp 0x4a48
movq %rax, %rbx
leaq -0x260(%rbp), %rdi
callq 0x22d0
movq %rbx, %rdi
callq 0x2380