// File: 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
subq $0x2370, %rsp           # imm = 0x2370
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
leaq -0x218(%rbp), %rdi
movq %rdi, -0x22a8(%rbp)
callq 0x3400
movq -0x22a8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x10, %edx
callq 0x3050
jmp 0x5c21
movq -0x18(%rbp), %rax
movq %rax, -0x22b8(%rbp)
leaq -0x249(%rbp), %rdi
movq %rdi, -0x22b0(%rbp)
callq 0x3430
movq -0x22b0(%rbp), %rdx
leaq 0x53bb(%rip), %rsi      # 0xb008
leaq -0x248(%rbp), %rdi
callq 0x8ae0
jmp 0x5c5b
movq -0x22b8(%rbp), %rdi
leaq -0x248(%rbp), %rsi
callq 0x8c70
movq %rax, -0x22c0(%rbp)
jmp 0x5c77
movq -0x22c0(%rbp), %rdi
callq 0x3100
movq %rax, %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x3340
movl %eax, -0x22cc(%rbp)
leaq -0x248(%rbp), %rdi
callq 0x3170
leaq -0x249(%rbp), %rdi
callq 0x32a0
movl -0x22cc(%rbp), %eax
movl %eax, -0x228(%rbp)
leaq 0x598a(%rip), %rsi      # 0xb64a
leaq -0x218(%rbp), %rdi
callq 0x3240
movq %rax, -0x22c8(%rbp)
jmp 0x5cd5
movq -0x22c8(%rbp), %rdi
movq 0xa2e5(%rip), %rsi      # 0xffc8
callq 0x3280
jmp 0x5cea
leaq 0x5984(%rip), %rsi      # 0xb675
leaq -0x218(%rbp), %rdi
callq 0x3240
movq %rax, -0x22d8(%rbp)
jmp 0x5d06
movq -0x22d8(%rbp), %rdi
movq 0xa2b4(%rip), %rsi      # 0xffc8
callq 0x3280
jmp 0x5d1b
leaq 0x5970(%rip), %rsi      # 0xb692
leaq -0x218(%rbp), %rdi
callq 0x3240
movq %rax, -0x22e0(%rbp)
jmp 0x5d37
movq -0x22e0(%rbp), %rdi
movq 0xa283(%rip), %rsi      # 0xffc8
callq 0x3280
jmp 0x5d4c
leaq 0x5947(%rip), %rsi      # 0xb69a
leaq -0x218(%rbp), %rdi
callq 0x3240
movq %rax, -0x22e8(%rbp)
jmp 0x5d68
movq -0x22e8(%rbp), %rdi
movq 0xa252(%rip), %rsi      # 0xffc8
callq 0x3280
jmp 0x5d7d
leaq 0x592d(%rip), %rsi      # 0xb6b1
leaq -0x218(%rbp), %rdi
callq 0x3240
movq %rax, -0x22f0(%rbp)
jmp 0x5d99
movq -0x22f0(%rbp), %rdi
movq 0xa221(%rip), %rsi      # 0xffc8
callq 0x3280
jmp 0x5dae
leaq 0x5905(%rip), %rsi      # 0xb6ba
leaq -0x218(%rbp), %rdi
callq 0x3240
movq %rax, -0x22f8(%rbp)
jmp 0x5dca
movq -0x22f8(%rbp), %rdi
movq 0xa1f0(%rip), %rsi      # 0xffc8
callq 0x3280
jmp 0x5ddf
leaq 0x58e3(%rip), %rsi      # 0xb6c9
leaq -0x218(%rbp), %rdi
callq 0x3240
movq %rax, -0x2300(%rbp)
jmp 0x5dfb
movq -0x2300(%rbp), %rdi
movq 0xa1bf(%rip), %rsi      # 0xffc8
callq 0x3280
jmp 0x5e10
leaq 0x58d3(%rip), %rsi      # 0xb6ea
leaq -0x218(%rbp), %rdi
callq 0x3240
movq %rax, -0x2308(%rbp)
jmp 0x5e2c
movq -0x2308(%rbp), %rdi
movq 0xa18e(%rip), %rsi      # 0xffc8
callq 0x3280
jmp 0x5e41
leaq 0x58b2(%rip), %rsi      # 0xb6fa
leaq -0x218(%rbp), %rdi
callq 0x3240
movq %rax, -0x2310(%rbp)
jmp 0x5e5d
movq -0x2310(%rbp), %rdi
movq 0xa15d(%rip), %rsi      # 0xffc8
callq 0x3280
jmp 0x5e72
movl -0x228(%rbp), %eax
movl %eax, -0x264(%rbp)
cmpl $0x2710, -0x264(%rbp)   # imm = 0x2710
jge 0x5f05
leaq 0x5872(%rip), %rax      # 0xb703
movq %rax, -0x258(%rbp)
leaq 0x5867(%rip), %rax      # 0xb706
movq %rax, -0x260(%rbp)
jmp 0x6007
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
jmp 0x638a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
jmp 0x5ef4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
leaq -0x248(%rbp), %rdi
callq 0x3170
leaq -0x249(%rbp), %rdi
callq 0x32a0
jmp 0x638a
cmpl $0x2710, -0x264(%rbp)   # imm = 0x2710
jl 0x5f3e
cmpl $0x186a0, -0x264(%rbp)  # imm = 0x186A0
jge 0x5f3e
leaq 0x57ec(%rip), %rax      # 0xb710
movq %rax, -0x258(%rbp)
leaq 0x57e1(%rip), %rax      # 0xb713
movq %rax, -0x260(%rbp)
jmp 0x6005
cmpl $0x186a0, -0x264(%rbp)  # imm = 0x186A0
jl 0x5f77
cmpl $0xf4240, -0x264(%rbp)  # imm = 0xF4240
jge 0x5f77
leaq 0x57c0(%rip), %rax      # 0xb71d
movq %rax, -0x258(%rbp)
leaq 0x57b5(%rip), %rax      # 0xb720
movq %rax, -0x260(%rbp)
jmp 0x6003
cmpl $0xf4240, -0x264(%rbp)  # imm = 0xF4240
jl 0x5fad
cmpl $0x989680, -0x264(%rbp) # imm = 0x989680
jge 0x5fad
leaq 0x5794(%rip), %rax      # 0xb72a
movq %rax, -0x258(%rbp)
leaq 0x5789(%rip), %rax      # 0xb72d
movq %rax, -0x260(%rbp)
jmp 0x6001
cmpl $0x989680, -0x264(%rbp) # imm = 0x989680
jl 0x5fe3
cmpl $0x5f5e100, -0x264(%rbp) # imm = 0x5F5E100
jge 0x5fe3
leaq 0x576b(%rip), %rax      # 0xb737
movq %rax, -0x258(%rbp)
leaq 0x5760(%rip), %rax      # 0xb73a
movq %rax, -0x260(%rbp)
jmp 0x5fff
leaq 0x575a(%rip), %rax      # 0xb744
movq %rax, -0x258(%rbp)
leaq 0x574f(%rip), %rax      # 0xb747
movq %rax, -0x260(%rbp)
jmp 0x6001
jmp 0x6003
jmp 0x6005
jmp 0x6007
movl $0x0, -0x2274(%rbp)
movl -0x2274(%rbp), %eax
cmpl -0x264(%rbp), %eax
jge 0x6098
leaq -0x1270(%rbp), %rdi
movq -0x8(%rbp), %rcx
movl -0x2274(%rbp), %r8d
addl $0x1, %r8d
movl $0x1000, %esi           # imm = 0x1000
leaq 0x5711(%rip), %rdx      # 0xb752
movb $0x0, %al
callq 0x33d0
leaq -0x2270(%rbp), %rdi
movq -0x258(%rbp), %rdx
movq -0x8(%rbp), %rcx
movl -0x2274(%rbp), %r8d
addl $0x1, %r8d
movl $0x1000, %esi           # imm = 0x1000
movb $0x0, %al
callq 0x33d0
leaq -0x1270(%rbp), %rdi
leaq -0x2270(%rbp), %rsi
callq 0x3160
movl -0x2274(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2274(%rbp)
jmp 0x6011
movl $0x0, -0x2278(%rbp)
movl -0x2278(%rbp), %eax
cmpl -0x228(%rbp), %eax
jge 0x6241
leaq 0x56a1(%rip), %rsi      # 0xb75c
leaq -0x218(%rbp), %rdi
callq 0x3240
movq %rax, -0x2318(%rbp)
jmp 0x60d0
movq -0x2318(%rbp), %rdi
movq 0x9eea(%rip), %rsi      # 0xffc8
callq 0x3280
jmp 0x60e5
movq -0x260(%rbp), %rdx
movl -0x2278(%rbp), %ecx
incl %ecx
xorl %eax, %eax
leaq -0x2270(%rbp), %rdi
movl $0x1000, %esi           # imm = 0x1000
callq 0x33d0
leaq 0x5658(%rip), %rsi      # 0xb766
leaq -0x218(%rbp), %rdi
callq 0x3240
movq %rax, -0x2320(%rbp)
jmp 0x6123
leaq -0x2299(%rbp), %rdi
movq %rdi, -0x2328(%rbp)
callq 0x3430
movq -0x2328(%rbp), %rdx
leaq -0x2298(%rbp), %rdi
leaq -0x2270(%rbp), %rsi
callq 0x8ae0
jmp 0x6152
movq -0x2320(%rbp), %rdi
leaq -0x2298(%rbp), %rsi
callq 0x3220
movq %rax, -0x2330(%rbp)
jmp 0x616e
movq -0x2330(%rbp), %rdi
leaq 0x552d(%rip), %rsi      # 0xb6a9
callq 0x3240
movq %rax, -0x2338(%rbp)
jmp 0x618a
movq -0x2338(%rbp), %rdi
movq 0x9e30(%rip), %rsi      # 0xffc8
callq 0x3280
jmp 0x619f
leaq -0x2298(%rbp), %rdi
callq 0x3170
leaq -0x2299(%rbp), %rdi
callq 0x32a0
leaq 0x55b1(%rip), %rsi      # 0xb76f
leaq -0x218(%rbp), %rdi
callq 0x3240
movq %rax, -0x2340(%rbp)
jmp 0x61d3
movq -0x2340(%rbp), %rdi
movq 0x9de7(%rip), %rsi      # 0xffc8
callq 0x3280
jmp 0x61e8
jmp 0x61ea
movl -0x2278(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2278(%rbp)
jmp 0x60a2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
jmp 0x6230
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
leaq -0x2298(%rbp), %rdi
callq 0x3170
leaq -0x2299(%rbp), %rdi
callq 0x32a0
jmp 0x638a
leaq 0x5532(%rip), %rsi      # 0xb77a
leaq -0x218(%rbp), %rdi
callq 0x3240
movq %rax, -0x2348(%rbp)
jmp 0x625d
movq -0x2348(%rbp), %rdi
movq 0x9d5d(%rip), %rsi      # 0xffc8
callq 0x3280
jmp 0x6272
leaq 0x550b(%rip), %rsi      # 0xb784
leaq -0x218(%rbp), %rdi
callq 0x3240
movq %rax, -0x2350(%rbp)
jmp 0x628e
movq -0x2350(%rbp), %rdi
movq 0x9d2c(%rip), %rsi      # 0xffc8
callq 0x3280
jmp 0x62a3
leaq 0x54ea(%rip), %rsi      # 0xb794
leaq -0x218(%rbp), %rdi
callq 0x3240
movq %rax, -0x2358(%rbp)
jmp 0x62bf
movq -0x2358(%rbp), %rdi
movq 0x9cfb(%rip), %rsi      # 0xffc8
callq 0x3280
jmp 0x62d4
leaq 0x54c8(%rip), %rsi      # 0xb7a3
leaq -0x218(%rbp), %rdi
callq 0x3240
movq %rax, -0x2360(%rbp)
jmp 0x62f0
movq -0x2360(%rbp), %rdi
movq 0x9cca(%rip), %rsi      # 0xffc8
callq 0x3280
jmp 0x6305
leaq 0x54b5(%rip), %rsi      # 0xb7c1
leaq -0x218(%rbp), %rdi
callq 0x3240
movq %rax, -0x2368(%rbp)
jmp 0x6321
movq -0x2368(%rbp), %rdi
movq 0x9c99(%rip), %rsi      # 0xffc8
callq 0x3280
jmp 0x6336
leaq 0x5494(%rip), %rsi      # 0xb7d1
leaq -0x218(%rbp), %rdi
callq 0x3240
movq %rax, -0x2370(%rbp)
jmp 0x6352
movq -0x2370(%rbp), %rdi
movq 0x9c68(%rip), %rsi      # 0xffc8
callq 0x3280
jmp 0x6367
leaq -0x218(%rbp), %rdi
callq 0x3350
jmp 0x6375
leaq -0x218(%rbp), %rdi
callq 0x3380
addq $0x2370, %rsp           # imm = 0x2370
popq %rbp
retq
leaq -0x218(%rbp), %rdi
callq 0x3380
movq -0x220(%rbp), %rdi
callq 0x3420
nopw %cs:(%rax,%rax)