// File: /workspace/github_cpp_makefile_star2_O2/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 $0x2248, %rsp           # imm = 0x2248
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, -0x48(%rbp)
leaq -0x268(%rbp), %r15
movq %r15, %rdi
callq 0x2330
pushq $0x10
popq %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x2050
leaq 0x2b23(%rip), %rsi      # 0x6008
leaq -0x1270(%rbp), %rdi
leaq -0x2270(%rbp), %rdx
callq 0x4b8c
leaq -0x1270(%rbp), %rsi
movq %rbx, %rdi
callq 0x4c3a
movq (%rax), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2290
movq %rax, %r13
leaq -0x1270(%rbp), %rdi
callq 0x2110
leaq 0x3121(%rip), %rsi      # 0x664a
leaq -0x268(%rbp), %rdi
callq 0x21f0
movq %rax, %rdi
callq 0x2120
leaq 0x3131(%rip), %rsi      # 0x6675
leaq -0x268(%rbp), %rdi
callq 0x21f0
movq %rax, %rdi
callq 0x2120
leaq 0x3133(%rip), %rsi      # 0x6692
leaq -0x268(%rbp), %rdi
callq 0x21f0
movq %rax, %rdi
callq 0x2120
leaq 0x3120(%rip), %rsi      # 0x669a
leaq -0x268(%rbp), %rdi
callq 0x21f0
movq %rax, %rdi
callq 0x2120
leaq 0x311c(%rip), %rsi      # 0x66b1
leaq -0x268(%rbp), %rdi
callq 0x21f0
movq %rax, %rdi
callq 0x2120
leaq 0x310a(%rip), %rsi      # 0x66ba
leaq -0x268(%rbp), %rdi
callq 0x21f0
movq %rax, %rdi
callq 0x2120
leaq 0x30fe(%rip), %rsi      # 0x66c9
leaq -0x268(%rbp), %rdi
callq 0x21f0
movq %rax, %rdi
callq 0x2120
leaq 0x3104(%rip), %rsi      # 0x66ea
leaq -0x268(%rbp), %rdi
callq 0x21f0
movq %rax, %rdi
callq 0x2120
leaq 0x30f9(%rip), %rsi      # 0x66fa
leaq -0x268(%rbp), %rdi
callq 0x21f0
movq %rax, %rdi
callq 0x2120
cmpl $0x2710, %r13d          # imm = 0x2710
jge 0x3632
leaq 0x30e1(%rip), %rax      # 0x6706
movq %rax, -0x38(%rbp)
leaq 0x30d3(%rip), %rax      # 0x6703
jmp 0x368b
cmpl $0x186a0, %r13d         # imm = 0x186A0
jae 0x364f
leaq 0x30d1(%rip), %rax      # 0x6713
movq %rax, -0x38(%rbp)
leaq 0x30c3(%rip), %rax      # 0x6710
jmp 0x368b
cmpl $0xf4240, %r13d         # imm = 0xF4240
jae 0x366c
leaq 0x30c1(%rip), %rax      # 0x6720
movq %rax, -0x38(%rbp)
leaq 0x30b3(%rip), %rax      # 0x671d
jmp 0x368b
cmpl $0x989680, %r13d        # imm = 0x989680
jae 0x3886
leaq 0x30ad(%rip), %rax      # 0x672d
movq %rax, -0x38(%rbp)
leaq 0x309f(%rip), %rax      # 0x672a
movq %rax, -0x40(%rbp)
xorl %eax, %eax
testl %r13d, %r13d
cmovlel %eax, %r13d
negl %r13d
pushq $0x1
popq %r12
leaq -0x1270(%rbp), %rbx
leaq -0x2270(%rbp), %r14
movq -0x48(%rbp), %r15
leal (%r12,%r13), %eax
cmpl $0x1, %eax
je 0x36ff
movl $0x1000, %esi           # imm = 0x1000
movq %rbx, %rdi
leaq 0x3089(%rip), %rdx      # 0x6752
movq %r15, %rcx
movl %r12d, %r8d
xorl %eax, %eax
callq 0x2310
movl $0x1000, %esi           # imm = 0x1000
movq %r14, %rdi
movq -0x40(%rbp), %rdx
movq %r15, %rcx
movl %r12d, %r8d
xorl %eax, %eax
callq 0x2310
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2140
incl %r12d
jmp 0x36b1
pushq $0x1
popq %r14
leaq -0x268(%rbp), %r12
leaq -0x68(%rbp), %r15
leal (%r14,%r13), %eax
cmpl $0x1, %eax
je 0x37ba
movq %r12, %rdi
leaq 0x3037(%rip), %rsi      # 0x675c
callq 0x21f0
movq %rax, %rdi
callq 0x2120
movl $0x1000, %esi           # imm = 0x1000
leaq -0x2270(%rbp), %rdi
movq -0x38(%rbp), %rdx
movl %r14d, %ecx
xorl %eax, %eax
callq 0x2310
movq %r12, %rdi
leaq 0x3010(%rip), %rsi      # 0x6766
callq 0x21f0
movq %rax, %rbx
movq %r15, %rdi
leaq -0x2270(%rbp), %rsi
leaq -0x29(%rbp), %rdx
callq 0x4b8c
movq %rbx, %rdi
movq %r15, %rsi
callq 0x21d0
movq %rax, %rdi
leaq 0x2f23(%rip), %rsi      # 0x66a9
callq 0x21f0
movq %rax, %rdi
callq 0x2120
movq %r15, %rdi
callq 0x2110
movq %r12, %rdi
leaq 0x2fca(%rip), %rsi      # 0x676f
callq 0x21f0
incl %r14d
movq %rax, %rdi
callq 0x2120
jmp 0x370e
leaq 0x2fb9(%rip), %rsi      # 0x677a
leaq -0x268(%rbp), %rdi
callq 0x21f0
movq %rax, %rdi
callq 0x2120
leaq 0x2fa8(%rip), %rsi      # 0x6784
leaq -0x268(%rbp), %rdi
callq 0x21f0
movq %rax, %rdi
callq 0x2120
leaq 0x2f9d(%rip), %rsi      # 0x6794
leaq -0x268(%rbp), %rdi
callq 0x21f0
movq %rax, %rdi
callq 0x2120
leaq 0x2f91(%rip), %rsi      # 0x67a3
leaq -0x268(%rbp), %rdi
callq 0x21f0
movq %rax, %rdi
callq 0x2120
leaq 0x2f94(%rip), %rsi      # 0x67c1
leaq -0x268(%rbp), %rdi
callq 0x21f0
movq %rax, %rdi
callq 0x2120
leaq 0x2f89(%rip), %rsi      # 0x67d1
leaq -0x268(%rbp), %rdi
callq 0x21f0
movq %rax, %rdi
callq 0x2120
leaq -0x268(%rbp), %rdi
callq 0x22a0
leaq -0x268(%rbp), %rdi
callq 0x22d0
addq $0x2248, %rsp           # imm = 0x2248
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x5f5e100, %r13d       # imm = 0x5F5E100
leaq 0x2ea3(%rip), %rax      # 0x6737
leaq 0x2ea9(%rip), %rcx      # 0x6744
cmovbq %rax, %rcx
movq %rcx, -0x40(%rbp)
leaq 0x2e90(%rip), %rax      # 0x673a
leaq 0x2e96(%rip), %rcx      # 0x6747
cmovbq %rax, %rcx
movq %rcx, -0x38(%rbp)
jmp 0x368f
movq %rax, %rbx
leaq -0x1270(%rbp), %rdi
jmp 0x38db
jmp 0x38e2
jmp 0x38e2
jmp 0x38e2
jmp 0x38e2
jmp 0x38e2
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x2110
jmp 0x38e5
movq %rax, %rbx
leaq -0x268(%rbp), %rdi
callq 0x22d0
movq %rbx, %rdi
callq 0x2350