// File: /workspace/github_cpp_makefile_star2_O1/jingdao[P]PointCloudApp/pcd.cpp
// Function: PCD::LoadFromMatrix(char const*)
PCD* PCD::LoadFromMatrix(const char* fileName) {
	FILE* f = fopen(fileName, "r");
	if (!f) {
		printf("File not found: %s\n", fileName);
		return NULL;
	}

	int dimensions = -1;
	std::vector<float> arr;
	char buf[256];
	while (fgets(buf,255,f)) {
		char* c = buf;
		while (*c) {
			if (*c<='9'&&*c>='0') {
				float f = (float) strtod(c,&c);
				arr.push_back(f);
			} else if (dimensions<0 && *c=='}') {
				dimensions = arr.size();
			} else if (*c=='}'&&*(c+1)=='}') {
				break;
			} else c++;
		}
		if (*c=='}'&&*(c+1)=='}')
			break;
	}

	fclose(f);
	int numPoints = arr.size()/dimensions;
	PCD* p = new PCD(numPoints);
	int i,j;
	for (i=0;i<numPoints;i++) {
		for (j=0;j<dimensions;j++) {
			p->float_data[i*4+j] = arr[i*dimensions+j];
		}
		p->float_data[i*4+3] = 255.0f;
	}

	return p;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rdi, %r15
leaq 0x7241(%rip), %rsi      # 0xb7a4
callq 0x2230
testq %rax, %rax
je 0x476f
movq %rax, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl $0xff, %esi
movq %rax, %rdx
callq 0x2330
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x4661
leaq 0x20(%rsp), %r15
movq %rsp, %r12
leaq 0x2c(%rsp), %r13
movq %r14, 0x20(%rsp)
movb 0x30(%rsp), %al
testb %al, %al
je 0x4640
movq %r14, %rdi
leal -0x30(%rax), %ecx
cmpb $0x9, %cl
ja 0x45f9
movq %r15, %rsi
callq 0x2150
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x2c(%rsp)
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x462a
movss %xmm0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rsp)
jmp 0x4635
testl %ebp, %ebp
setns %cl
cmpb $0x7d, %al
setne %dl
orb %cl, %dl
jne 0x4616
movq 0x8(%rsp), %rbp
subq (%rsp), %rbp
shrq $0x2, %rbp
jmp 0x4635
cmpb $0x7d, %al
jne 0x4620
cmpb $0x7d, 0x1(%rdi)
je 0x465b
incq %rdi
movq %rdi, 0x20(%rsp)
jmp 0x4635
movq %r12, %rdi
movq %r13, %rdx
callq 0x7c62
movq 0x20(%rsp), %rdi
movb (%rdi), %al
testb %al, %al
jne 0x45c4
movq %r14, %rdi
movl $0xff, %esi
movq %rbx, %rdx
callq 0x2330
testq %rax, %rax
jne 0x45b4
jmp 0x4661
cmpb $0x7d, 0x1(%rdi)
jne 0x4640
movq %rbx, %rdi
callq 0x21f0
movq (%rsp), %rbx
movq 0x8(%rsp), %rax
subq %rbx, %rax
sarq $0x2, %rax
movslq %ebp, %rcx
xorl %edx, %edx
divq %rcx
movq %rax, %r15
movl $0x78, %edi
callq 0x2200
movq %rax, %r14
movl $0x4, 0x40(%rax)
xorl %r12d, %r12d
movq %r12, 0x50(%rax)
leal (,%r15,4), %eax
movslq %eax, %rdi
shlq $0x2, %rdi
callq 0x2270
movq %rax, 0x58(%r14)
movq %r12, 0x48(%r14)
movl %r15d, 0x60(%r14)
movl %r15d, 0x64(%r14)
movl $0x0, 0x68(%r14)
movq %r12, 0x70(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x1c(%r14)
movl $0x3f800000, 0x2c(%r14) # imm = 0x3F800000
movq %r12, 0x30(%r14)
movabsq $0x3f80000000000000, %rax # imm = 0x3F80000000000000
movq %rax, 0x38(%r14)
testl %r15d, %r15d
jle 0x4758
movq 0x58(%r14), %rax
andl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
movl %ebp, %ecx
leaq (,%rcx,4), %rdx
xorl %esi, %esi
movq %rbx, %rdi
testl %ebp, %ebp
jle 0x473d
movl %esi, %r8d
andl $0x3fffffff, %r8d       # imm = 0x3FFFFFFF
shlq $0x4, %r8
addq 0x58(%r14), %r8
xorl %r9d, %r9d
movss (%rdi,%r9,4), %xmm0
movss %xmm0, (%r8,%r9,4)
incq %r9
cmpq %r9, %rcx
jne 0x4729
movq %rsi, %r8
shlq $0x4, %r8
movl $0x437f0000, 0xc(%rax,%r8) # imm = 0x437F0000
incq %rsi
addq %rdx, %rdi
cmpq %r15, %rsi
jb 0x4710
testq %rbx, %rbx
je 0x4783
movq 0x10(%rsp), %rsi
subq %rbx, %rsi
movq %rbx, %rdi
callq 0x2210
jmp 0x4783
leaq 0x6c8a(%rip), %rdi      # 0xb400
xorl %r14d, %r14d
movq %r15, %rsi
xorl %eax, %eax
callq 0x2050
movq %r14, %rax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x479a
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x47b3
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq %rbx, %rdi
callq 0x23a0
nop