// File: /workspace/github_cpp_makefile_star2_O1/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
movb $0x2f, 0x190(%rsp,%r14)
movabsq $0x6974636964657270, %rax # imm = 0x6974636964657270
movq %rax, 0x191(%rsp,%r14)
movabsq $0x7478742e6e6f69, %rax # imm = 0x7478742E6E6F69
movq %rax, 0x198(%rsp,%r14)
leaq 0x5e2a(%rip), %rsi      # 0xb7a4
movq %r15, %rdi
callq 0x2230
movq %rax, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
leaq 0x90(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
movq %rax, %rdx
callq 0x2330
testq %rax, %rax
je 0x5a04
leaq 0x90(%rsp), %r15
movq %rsp, %r12
leaq 0x18(%rsp), %r13
movq %r15, %rdi
callq 0x2320
movl %eax, 0x18(%rsp)
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x59e4
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rsp)
jmp 0x59ef
movq %r12, %rdi
movq %r13, %rdx
callq 0x7e82
movq %r15, %rdi
movl $0x100, %esi            # imm = 0x100
movq %rbx, %rdx
callq 0x2330
testq %rax, %rax
jne 0x59bf
movq %rbx, %rdi
callq 0x21f0
movl $0x78, %edi
callq 0x2200
movq %rax, %rbx
movl $0x4, 0x40(%rax)
xorl %r15d, %r15d
movq %r15, 0x50(%rax)
xorl %edi, %edi
callq 0x2270
movq %rax, 0x58(%rbx)
movq %r15, 0x48(%rbx)
movq %r15, 0x60(%rbx)
movl $0x0, 0x68(%rbx)
movq %r15, 0x70(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x1c(%rbx)
movl $0x3f800000, 0x2c(%rbx) # imm = 0x3F800000
movq %r15, 0x30(%rbx)
movabsq $0x3f80000000000000, %rax # imm = 0x3F80000000000000
movq %rax, 0x38(%rbx)
movq (%rsp), %rdi
cmpq %rdi, 0x8(%rsp)
je 0x5b51
addq %rsp, %r14
addq $0x191, %r14            # imm = 0x191
leaq 0x18(%rsp), %r12
leaq 0x190(%rsp), %r13
xorl %ebp, %ebp
movl $0x40, %esi
movq %r14, %rdi
leaq 0x5be3(%rip), %rdx      # 0xb67f
movq %rbp, %rcx
xorl %eax, %eax
callq 0x2340
movq %r12, %rdi
movq %r13, %rsi
callq 0x3182
movslq 0x60(%rbx), %r15
movl 0x78(%rsp), %esi
addl %r15d, %esi
movq %rbx, %rdi
callq 0x34de
movslq 0x78(%rsp), %rax
testq %rax, %rax
jle 0x5b2d
movq 0x70(%rsp), %rcx
movq 0x58(%rbx), %rdx
movq (%rsp), %rsi
movslq (%rsi,%rbp,4), %rsi
leaq 0x5e2a(%rip), %rdi      # 0xb910
movss (%rdi,%rsi,4), %xmm0
shlq $0x4, %r15
addq %r15, %rdx
addq $0xc, %rdx
shlq $0x4, %rax
xorl %esi, %esi
movss (%rcx,%rsi), %xmm1
movss %xmm1, -0xc(%rdx,%rsi)
movss 0x4(%rcx,%rsi), %xmm1
movss %xmm1, -0x8(%rdx,%rsi)
movss 0x8(%rcx,%rsi), %xmm1
movss %xmm1, -0x4(%rdx,%rsi)
movss %xmm0, (%rdx,%rsi)
addq $0x10, %rsi
cmpq %rsi, %rax
jne 0x5afc
movq %r12, %rdi
callq 0x348e
incq %rbp
movq (%rsp), %rdi
movq 0x8(%rsp), %rax
subq %rdi, %rax
sarq $0x2, %rax
cmpq %rax, %rbp
jb 0x5a8d
testq %rdi, %rdi
je 0x5b63
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq %rbx, %rax
addq $0x598, %rsp            # imm = 0x598
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5b7a
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x5b93
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq %rbx, %rdi
callq 0x23a0
nop