// File: /workspace/github_cpp_makefile_star2_O2/jingdao[P]PointCloudApp/pcd.cpp
// Function: PCD::LoadFromCluster(char const*)
PCD* PCD::LoadFromCluster(const char* dir) {
	char buffer[1024];
	int ndir = strlen(dir);
	strncpy(buffer,dir,ndir);
	char* buffer_c = buffer + ndir;
	*buffer_c++ = '/';

	strcpy(buffer_c,"prediction.txt");
	FILE* labelFile = fopen(buffer,"r");
	std::vector<int> labels;
	char line[256];
	while (fgets(line,256,labelFile)) {
		labels.push_back(atoi(line));
	}
	fclose(labelFile);

	PCD* combined = new PCD(0);
	float colorChoice[] = {16777215, 255<<16, 255<<8, 255, (255<<16)|(255<<8), (255<<16)|255, (255<<8)|255};
	for (size_t i=0;i<labels.size();i++) {
		snprintf(buffer_c,64,"%lu-cloud.pcd",i);
		PCD cloud(buffer);
		int offset = combined->numPoints;
		combined->expand(offset + cloud.numPoints);
		for (int j = 0;j<cloud.numPoints;j++) {
			combined->float_data[(offset+j) * 4] = cloud.float_data[j * 4];
			combined->float_data[(offset+j) * 4 + 1] = cloud.float_data[j * 4 + 1];
			combined->float_data[(offset+j) * 4 + 2] = cloud.float_data[j * 4 + 2];
			combined->float_data[(offset+j) * 4 + 3] = colorChoice[labels[i]];
		}
	}

	return combined;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x598, %rsp            # imm = 0x598
movq %rdi, %rbx
callq 0x20c0
movslq %eax, %r14
leaq 0x190(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x20e0
leaq (%rsp,%r14), %rbx
addq $0x191, %rbx            # imm = 0x191
movb $0x2f, -0x1(%rbx)
movabsq $0x6974636964657270, %rax # imm = 0x6974636964657270
movq %rax, (%rbx)
movabsq $0x7478742e6e6f69, %rax # imm = 0x7478742E6E6F69
movq %rax, 0x7(%rbx)
leaq 0x557d(%rip), %rsi      # 0xa81c
movq %r15, %rdi
callq 0x2240
movq %rax, %r14
movq %rsp, %r15
andq $0x0, 0x10(%r15)
xorps %xmm0, %xmm0
movaps %xmm0, (%r15)
leaq 0x90(%rsp), %r12
leaq 0x18(%rsp), %r13
movq %r12, %rdi
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdx
callq 0x2340
testq %rax, %rax
je 0x52f4
movq %r12, %rdi
callq 0x2330
movl %eax, 0x18(%rsp)
movq %r15, %rdi
movq %r13, %rsi
callq 0x7028
jmp 0x52c6
movq %r14, %rdi
callq 0x21f0
pushq $0x78
popq %rdi
callq 0x2200
movq %rax, %r14
movq %rax, %rdi
xorl %esi, %esi
callq 0x3330
leaq 0x18(%rsp), %r13
leaq 0x5673(%rip), %r12      # 0xa990
xorl %r15d, %r15d
movq 0x8(%rsp), %rax
subq (%rsp), %rax
sarq $0x2, %rax
cmpq %rax, %r15
jae 0x53dc
movq %rbx, %rdi
pushq $0x40
popq %rsi
leaq 0x53b4(%rip), %rdx      # 0xa6f7
movq %r15, %rcx
xorl %eax, %eax
callq 0x2350
movq %r13, %rdi
leaq 0x190(%rsp), %rsi
callq 0x30f6
movslq 0x60(%r14), %rbp
movl 0x78(%rsp), %esi
addl %ebp, %esi
movq %r14, %rdi
callq 0x33dc
movslq 0x78(%rsp), %rax
movq 0x70(%rsp), %rcx
movq (%rsp), %rdx
addq $0x8, %rcx
shlq $0x4, %rbp
xorl %esi, %esi
cmpq %rax, %rsi
jge 0x53cc
movss -0x8(%rcx), %xmm0
movq 0x58(%r14), %rdi
movss %xmm0, (%rdi,%rbp)
movss -0x4(%rcx), %xmm0
movss %xmm0, 0x4(%rdi,%rbp)
movss (%rcx), %xmm0
movss %xmm0, 0x8(%rdi,%rbp)
movslq (%rdx,%r15,4), %r8
movss (%r12,%r8,4), %xmm0
movss %xmm0, 0xc(%rdi,%rbp)
incq %rsi
addq $0x10, %rcx
addq $0x10, %rbp
jmp 0x5387
movq %r13, %rdi
callq 0x339e
incq %r15
jmp 0x5320
movq %rsp, %rdi
callq 0x2d00
movq %r14, %rax
addq $0x598, %rsp            # imm = 0x598
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x53fb
movq %rax, %rbx
movq %rsp, %rdi
callq 0x2d00
movq %rbx, %rdi
callq 0x23b0