// File: /workspace/github_cpp_makefile_star2_O3/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 0x7341(%rip), %rsi      # 0xb874
callq 0x2230
testq %rax, %rax
je 0x4737
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 0x4623
leaq 0x20(%rsp), %r15
movq %rsp, %r12
leaq 0x2c(%rsp), %r13
movq %r14, 0x20(%rsp)
movb 0x30(%rsp), %al
testb %al, %al
je 0x460a
movq %r14, %rdi
leal -0x30(%rax), %ecx
cmpb $0x9, %cl
ja 0x45c9
movq %r15, %rsi
callq 0x2150
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x2c(%rsp)
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x45f4
movss %xmm0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rsp)
jmp 0x45ff
testl %ebp, %ebp
jns 0x45e0
cmpb $0x7d, %al
jne 0x45e0
movq 0x8(%rsp), %rbp
subq (%rsp), %rbp
shrq $0x2, %rbp
jmp 0x4604
cmpb $0x7d, %al
jne 0x45ea
cmpb $0x7d, 0x1(%rdi)
je 0x4623
incq %rdi
movq %rdi, 0x20(%rsp)
jmp 0x4604
movq %r12, %rdi
movq %r13, %rdx
callq 0x7c96
movq 0x20(%rsp), %rdi
movb (%rdi), %al
testb %al, %al
jne 0x4594
movq %r14, %rdi
movl $0xff, %esi
movq %rbx, %rdx
callq 0x2330
testq %rax, %rax
jne 0x4584
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, %rcx # imm = 0x3F80000000000000
movq %rcx, 0x38(%r14)
testl %r15d, %r15d
jle 0x4720
movl %ebp, %ecx
andl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
leaq (,%rcx,4), %rdx
xorl %esi, %esi
movq %rbx, %rdi
testl %ebp, %ebp
jle 0x4704
movl %esi, %r9d
andl $0x3fffffff, %r9d       # imm = 0x3FFFFFFF
shlq $0x4, %r9
addq %rax, %r9
leaq (,%rsi,4), %r8
xorl %r10d, %r10d
movss (%rdi,%r10,4), %xmm0
movss %xmm0, (%r9,%r10,4)
incq %r10
cmpq %r10, %rcx
jne 0x46ee
jmp 0x470c
leaq (,%rsi,4), %r8
movl $0x437f0000, 0xc(%rax,%r8,4) # imm = 0x437F0000
incq %rsi
addq %rdx, %rdi
cmpq %r15, %rsi
jb 0x46ce
testq %rbx, %rbx
je 0x474b
movq 0x10(%rsp), %rsi
subq %rbx, %rsi
movq %rbx, %rdi
callq 0x2210
jmp 0x474b
leaq 0x6d92(%rip), %rdi      # 0xb4d0
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
movq %rax, %r14
jmp 0x476c
movq %rax, %r14
movq (%rsp), %rbx
testq %rbx, %rbx
je 0x4781
movq 0x10(%rsp), %rsi
subq %rbx, %rsi
movq %rbx, %rdi
callq 0x2210
movq %r14, %rdi
callq 0x23a0
nop