// File: /workspace/github_cpp_makefile_star2_O1/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, %r13
leaq -0x268(%rbp), %r15
movq %r15, %rdi
callq 0x2350
movq %r15, %rdi
movq %r14, %rsi
movl $0x10, %edx
callq 0x2060
leaq -0x1260(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x3d48(%rip), %rsi      # 0x8020
leaq 0x3d4b(%rip), %rdx      # 0x802a
leaq -0x1270(%rbp), %rdi
callq 0x7388
leaq -0x1270(%rbp), %rsi
movq %rbx, %rdi
callq 0x711e
movq (%rax), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2290
movq %rax, %r12
movq -0x1270(%rbp), %rdi
cmpq %r14, %rdi
je 0x4324
movq -0x1260(%rbp), %rsi
incq %rsi
callq 0x2210
leaq 0x4337(%rip), %rsi      # 0x8662
leaq -0x268(%rbp), %rbx
movl $0x2a, %edx
movq %rbx, %rdi
callq 0x2240
movq -0x268(%rbp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
leaq -0x268(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
leaq 0x4318(%rip), %rsi      # 0x868d
leaq -0x268(%rbp), %rbx
movl $0x1c, %edx
movq %rbx, %rdi
callq 0x2240
movq -0x268(%rbp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
leaq -0x268(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
leaq 0x42eb(%rip), %rsi      # 0x86aa
leaq -0x268(%rbp), %rbx
movl $0x7, %edx
movq %rbx, %rdi
callq 0x2240
movq -0x268(%rbp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
leaq -0x268(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
leaq 0x42a9(%rip), %rsi      # 0x86b2
leaq -0x268(%rbp), %rbx
movl $0x16, %edx
movq %rbx, %rdi
callq 0x2240
movq -0x268(%rbp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
leaq -0x268(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
leaq 0x4276(%rip), %rsi      # 0x86c9
leaq -0x268(%rbp), %rbx
movl $0x8, %edx
movq %rbx, %rdi
callq 0x2240
movq -0x268(%rbp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
leaq -0x268(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
leaq 0x4235(%rip), %rsi      # 0x86d2
leaq -0x268(%rbp), %rbx
movl $0xe, %edx
movq %rbx, %rdi
callq 0x2240
movq -0x268(%rbp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
leaq -0x268(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
leaq 0x41fa(%rip), %rsi      # 0x86e1
leaq -0x268(%rbp), %rbx
movl $0x20, %edx
movq %rbx, %rdi
callq 0x2240
movq -0x268(%rbp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
leaq -0x268(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
leaq 0x41d1(%rip), %rsi      # 0x8702
leaq -0x268(%rbp), %rbx
movl $0xf, %edx
movq %rbx, %rdi
callq 0x2240
movq -0x268(%rbp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
leaq -0x268(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
leaq 0x4197(%rip), %rsi      # 0x8712
leaq -0x268(%rbp), %rbx
movl $0x8, %edx
movq %rbx, %rdi
callq 0x2240
movq -0x268(%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 0x45da
leaq 0x4154(%rip), %rax      # 0x871e
movq %rax, -0x30(%rbp)
leaq 0x4146(%rip), %rdx      # 0x871b
jmp 0x4660
cmpl $0x186a0, %r12d         # imm = 0x186A0
jge 0x45f7
leaq 0x4141(%rip), %rax      # 0x872b
movq %rax, -0x30(%rbp)
leaq 0x4133(%rip), %rdx      # 0x8728
jmp 0x4660
cmpl $0xf4240, %r12d         # imm = 0xF4240
jge 0x4614
leaq 0x4131(%rip), %rax      # 0x8738
movq %rax, -0x30(%rbp)
leaq 0x4123(%rip), %rdx      # 0x8735
jmp 0x4660
cmpl $0x989680, %r12d        # imm = 0x989680
jge 0x4631
leaq 0x4121(%rip), %rax      # 0x8745
movq %rax, -0x30(%rbp)
leaq 0x4113(%rip), %rdx      # 0x8742
jmp 0x4660
cmpl $0x5f5e100, %r12d       # imm = 0x5F5E100
leaq 0x4110(%rip), %rax      # 0x874f
leaq 0x4116(%rip), %rdx      # 0x875c
cmovlq %rax, %rdx
leaq 0x4101(%rip), %rax      # 0x8752
leaq 0x4107(%rip), %rcx      # 0x875f
cmovlq %rax, %rcx
movq %rcx, -0x30(%rbp)
movq %rdx, -0x68(%rbp)
movq %r12, -0x38(%rbp)
testl %r12d, %r12d
jle 0x46e4
movq %r13, %r12
movq -0x38(%rbp), %rbx
negl %ebx
movq %rbx, -0x60(%rbp)
movl $0x1, %r14d
leaq -0x1270(%rbp), %rbx
leaq -0x2270(%rbp), %r13
movl $0x1000, %esi           # imm = 0x1000
movq %rbx, %rdi
leaq 0x40cd(%rip), %rdx      # 0x876a
movq %r12, %rcx
movl %r14d, %r8d
xorl %eax, %eax
callq 0x2310
movl $0x1000, %esi           # imm = 0x1000
movq %r13, %rdi
movq -0x68(%rbp), %rdx
movq %r12, %rcx
movl %r14d, %r8d
xorl %eax, %eax
callq 0x2310
movq %rbx, %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 0x468e
xorl %eax, %eax
movq -0x38(%rbp), %r13
testl %r13d, %r13d
cmovlel %eax, %r13d
negl %r13d
movl $0x1, %r14d
leaq -0x2270(%rbp), %rbx
leal (%r14,%r13), %eax
cmpl $0x1, %eax
je 0x484d
movl $0x9, %edx
movq %r15, %rdi
leaq 0x4057(%rip), %rsi      # 0x8774
callq 0x2240
movq -0x268(%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 0x400c(%rip), %rsi      # 0x877e
callq 0x2240
leaq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
movq %rbx, %rdi
callq 0x2110
leaq (%rax,%rbp), %rdx
addq $-0x2270, %rdx          # imm = 0xDD90
leaq -0x58(%rbp), %rdi
movq %rbx, %rsi
callq 0x7388
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq %r15, %rdi
callq 0x2240
movq %rax, %r12
movl $0x7, %edx
movq %rax, %rdi
leaq 0x3f01(%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 -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x4806
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x2210
movl $0xa, %edx
movq %r15, %rdi
leaq 0x3f72(%rip), %rsi      # 0x8787
callq 0x2240
movq -0x268(%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 0x4701
leaq 0x3f3e(%rip), %rsi      # 0x8792
leaq -0x268(%rbp), %rbx
movl $0x9, %edx
movq %rbx, %rdi
callq 0x2240
movq -0x268(%rbp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
leaq -0x268(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
leaq 0x3efe(%rip), %rsi      # 0x879c
leaq -0x268(%rbp), %rbx
movl $0xf, %edx
movq %rbx, %rdi
callq 0x2240
movq -0x268(%rbp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
leaq -0x268(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
leaq 0x3ec4(%rip), %rsi      # 0x87ac
leaq -0x268(%rbp), %rbx
movl $0xe, %edx
movq %rbx, %rdi
callq 0x2240
movq -0x268(%rbp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
leaq -0x268(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
leaq 0x3e89(%rip), %rsi      # 0x87bb
leaq -0x268(%rbp), %rbx
movl $0x1d, %edx
movq %rbx, %rdi
callq 0x2240
movq -0x268(%rbp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
leaq -0x268(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
leaq 0x3e5d(%rip), %rsi      # 0x87d9
leaq -0x268(%rbp), %rbx
movl $0xf, %edx
movq %rbx, %rdi
callq 0x2240
movq -0x268(%rbp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
leaq -0x268(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
leaq 0x3e23(%rip), %rsi      # 0x87e9
leaq -0x268(%rbp), %rbx
movl $0xb, %edx
movq %rbx, %rdi
callq 0x2240
movq -0x268(%rbp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
leaq -0x268(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
leaq -0x268(%rbp), %rdi
callq 0x22a0
movq 0x65b4(%rip), %rax      # 0xafd0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq -0x260(%rbp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, -0x268(%rbp,%rcx)
callq 0x21b0
leaq -0x170(%rbp), %rdi
callq 0x20e0
addq $0x2248, %rsp           # imm = 0x2248
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0x1270(%rbp), %rdi
cmpq %r14, %rdi
je 0x4aa0
movq -0x1260(%rbp), %rsi
jmp 0x4a93
jmp 0x4a9d
jmp 0x4a9d
jmp 0x4a9d
jmp 0x4a9d
jmp 0x4a9d
movq %rax, %rbx
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x4aa0
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x2210
jmp 0x4aa0
movq %rax, %rbx
leaq -0x268(%rbp), %rdi
callq 0x22d0
movq %rbx, %rdi
callq 0x2380